pub struct AesKw<C> { /* private fields */ }Expand description
AES Key Wrapper (KW), as defined in RFC 3394.
Implementations§
Source§impl<C: BlockCipherEncrypt<BlockSize = U16>> AesKw<C>
impl<C: BlockCipherEncrypt<BlockSize = U16>> AesKw<C>
Sourcepub fn wrap_key<'a>(
&self,
key: &[u8],
buf: &'a mut [u8],
) -> Result<&'a [u8], Error>
pub fn wrap_key<'a>( &self, key: &[u8], buf: &'a mut [u8], ) -> Result<&'a [u8], Error>
Wrap key and write result to buf.
Returns slice which points to buf and contains wrapped data.
Length of data must be multiple of IV_LEN and bigger than zero.
Length of buf must be bigger or equal to data.len() + IV_LEN.
Sourcepub fn wrap_fixed_key<N>(&self, key: &Array<u8, N>) -> Array<u8, Sum<N, IvLen>>
pub fn wrap_fixed_key<N>(&self, key: &Array<u8, N>) -> Array<u8, Sum<N, IvLen>>
Wrap fixed-size key key and return wrapped key.
This method is roughly equivalent to:
const fn check_key_size(n: usize) -> usize {
assert!(n != 0 && n % IV_LEN == 0);
0
}
pub fn wrap_fixed_key<const N: usize>(
&self,
key: &[u8; N],
) -> [u8; N + IV_LEN]
where
[(); check_key_size(N)]: Sized,
{ ... }but uses hybrid_array::Array instead of built-in arrays
to work around current limitations of the const generics system.
Source§impl<C: BlockCipherDecrypt<BlockSize = U16>> AesKw<C>
impl<C: BlockCipherDecrypt<BlockSize = U16>> AesKw<C>
Sourcepub fn unwrap_key<'a>(
&self,
wkey: &[u8],
buf: &'a mut [u8],
) -> Result<&'a [u8], Error>
pub fn unwrap_key<'a>( &self, wkey: &[u8], buf: &'a mut [u8], ) -> Result<&'a [u8], Error>
Unwrap data and write result to buf.
Returns slice which points to buf and contains unwrapped data.
Length of data must be multiple of IV_LEN and bigger than zero.
Length of buf must be bigger or equal to data.len().
Sourcepub fn unwrap_fixed_key<N>(
&self,
wkey: &Array<u8, Sum<N, IvLen>>,
) -> Result<Array<u8, N>, IntegrityCheckFailed>
pub fn unwrap_fixed_key<N>( &self, wkey: &Array<u8, Sum<N, IvLen>>, ) -> Result<Array<u8, N>, IntegrityCheckFailed>
Unwrap key in data and return unwrapped key.
This method is roughly equivalent to:
const fn check_key_size(n: usize) -> usize {
assert!(n != 0 && n % IV_LEN == 0);
0
}
fn unwrap_fixed_key<const N: usize>(
&self,
data: &[u8; N + IV_LEN],
) -> [u8; N]
where
[(); check_key_size(N)]: Sized,
{ ... }but uses hybrid_array::Array instead of built-in arrays
to work around current limitations of the const generics system.
Trait Implementations§
impl<C: Copy> Copy for AesKw<C>
Source§impl<C> InnerInit for AesKw<C>
impl<C> InnerInit for AesKw<C>
Source§fn inner_init(cipher: Self::Inner) -> Self
fn inner_init(cipher: Self::Inner) -> Self
inner.