Skip to content

Commit

Permalink
Merge pull request #376 from jbaublitz/reencryption-requirements
Browse files Browse the repository at this point in the history
Allow specifying key length in add_by_key
  • Loading branch information
jbaublitz authored Sep 23, 2024
2 parents ed4db81 + ea45bd1 commit 04dc75f
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/keyslot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use std::{
ptr,
};

use either::Either;
use libc::{c_int, c_uint};

use crate::{
Expand Down Expand Up @@ -111,12 +112,13 @@ impl<'a> CryptKeyslotHandle<'a> {
pub fn add_by_key(
&mut self,
keyslot: Option<c_uint>,
volume_key: Option<&[u8]>,
volume_key: Option<Either<&[u8], usize>>,
passphrase: &[u8],
flags: CryptVolumeKey,
) -> Result<c_uint, LibcryptErr> {
let (vk_ptr, vk_len) = match volume_key {
Some(vk) => (to_byte_ptr!(vk), vk.len()),
Some(Either::Left(vk)) => (to_byte_ptr!(vk), vk.len()),
Some(Either::Right(s)) => (std::ptr::null(), s),
None => (std::ptr::null(), 0),
};
errno_int_success!(mutex!(libcryptsetup_rs_sys::crypt_keyslot_add_by_key(
Expand Down

0 comments on commit 04dc75f

Please sign in to comment.