pub struct Kek<Aes> where
Aes: KeyInit + BlockCipher + BlockSizeUser<BlockSize = U16> + BlockEncrypt + BlockDecrypt, { /* private fields */ }
Expand description
A Key-Encrypting-Key (KEK) that can be used to wrap and unwrap other keys.
Implementations
sourceimpl<Aes> Kek<Aes> where
Aes: KeyInit + BlockCipher + BlockSizeUser<BlockSize = U16> + BlockEncrypt + BlockDecrypt,
impl<Aes> Kek<Aes> where
Aes: KeyInit + BlockCipher + BlockSizeUser<BlockSize = U16> + BlockEncrypt + BlockDecrypt,
sourcepub fn new(key: &GenericArray<u8, Aes::KeySize>) -> Self
pub fn new(key: &GenericArray<u8, Aes::KeySize>) -> Self
Constructs a new Kek based on the appropriate raw key material.
sourcepub fn wrap(&self, data: &[u8], out: &mut [u8]) -> Result<()>
pub fn wrap(&self, data: &[u8], out: &mut [u8]) -> Result<()>
AES Key Wrap, as defined in RFC 3394.
The out
buffer will be overwritten, and must be exactly IV_LEN
bytes (i.e. 8 bytes) longer than the length of data
.
sourcepub fn wrap_vec(&self, data: &[u8]) -> Result<Vec<u8>>
Available on crate feature alloc
only.
pub fn wrap_vec(&self, data: &[u8]) -> Result<Vec<u8>>
alloc
only.Computes Self::wrap
, allocating a Vec
for the return value.
sourcepub fn unwrap(&self, data: &[u8], out: &mut [u8]) -> Result<()>
pub fn unwrap(&self, data: &[u8], out: &mut [u8]) -> Result<()>
AES Key Unwrap, as defined in RFC 3394.
The out
buffer will be overwritten, and must be exactly IV_LEN
bytes (i.e. 8 bytes) shorter than the length of data
.
sourcepub fn unwrap_vec(&self, data: &[u8]) -> Result<Vec<u8>>
Available on crate feature alloc
only.
pub fn unwrap_vec(&self, data: &[u8]) -> Result<Vec<u8>>
alloc
only.Computes Self::unwrap
, allocating a Vec
for the return value.
sourcepub fn wrap_with_padding(&self, data: &[u8], out: &mut [u8]) -> Result<()>
pub fn wrap_with_padding(&self, data: &[u8], out: &mut [u8]) -> Result<()>
AES Key Wrap with Padding, as defined in RFC 5649.
The out
buffer will be overwritten, and must be the smallest
multiple of SEMIBLOCK_SIZE
(i.e. 8) which is at least IV_LEN
bytes (i.e. 8 bytes) longer than the length of data
.
sourcepub fn wrap_with_padding_vec(&self, data: &[u8]) -> Result<Vec<u8>>
Available on crate feature alloc
only.
pub fn wrap_with_padding_vec(&self, data: &[u8]) -> Result<Vec<u8>>
alloc
only.Computes Self::wrap
, allocating a Vec
for the return value.
sourcepub fn unwrap_with_padding<'a>(
&self,
data: &[u8],
out: &'a mut [u8]
) -> Result<&'a [u8]>
pub fn unwrap_with_padding<'a>(
&self,
data: &[u8],
out: &'a mut [u8]
) -> Result<&'a [u8]>
AES Key Wrap with Padding, as defined in RFC 5649.
The out
buffer will be overwritten, and must be exactly IV_LEN
bytes (i.e. 8 bytes) shorter than the length of data
.
This method returns a slice of out
, truncated to the appropriate
length by removing the padding.
sourcepub fn unwrap_with_padding_vec(&self, data: &[u8]) -> Result<Vec<u8>>
Available on crate feature alloc
only.
pub fn unwrap_with_padding_vec(&self, data: &[u8]) -> Result<Vec<u8>>
alloc
only.Computes Self::unwrap
, allocating a Vec
for the return value.
Trait Implementations
sourceimpl<Aes: Clone> Clone for Kek<Aes> where
Aes: KeyInit + BlockCipher + BlockSizeUser<BlockSize = U16> + BlockEncrypt + BlockDecrypt,
impl<Aes: Clone> Clone for Kek<Aes> where
Aes: KeyInit + BlockCipher + BlockSizeUser<BlockSize = U16> + BlockEncrypt + BlockDecrypt,
sourceimpl<Aes: Debug> Debug for Kek<Aes> where
Aes: KeyInit + BlockCipher + BlockSizeUser<BlockSize = U16> + BlockEncrypt + BlockDecrypt,
impl<Aes: Debug> Debug for Kek<Aes> where
Aes: KeyInit + BlockCipher + BlockSizeUser<BlockSize = U16> + BlockEncrypt + BlockDecrypt,
sourceimpl<Aes: PartialEq> PartialEq<Kek<Aes>> for Kek<Aes> where
Aes: KeyInit + BlockCipher + BlockSizeUser<BlockSize = U16> + BlockEncrypt + BlockDecrypt,
impl<Aes: PartialEq> PartialEq<Kek<Aes>> for Kek<Aes> where
Aes: KeyInit + BlockCipher + BlockSizeUser<BlockSize = U16> + BlockEncrypt + BlockDecrypt,
sourceimpl<Aes> TryFrom<&'_ [u8]> for Kek<Aes> where
Aes: KeyInit + BlockCipher + BlockSizeUser<BlockSize = U16> + BlockEncrypt + BlockDecrypt,
impl<Aes> TryFrom<&'_ [u8]> for Kek<Aes> where
Aes: KeyInit + BlockCipher + BlockSizeUser<BlockSize = U16> + BlockEncrypt + BlockDecrypt,
impl<Aes: Copy> Copy for Kek<Aes> where
Aes: KeyInit + BlockCipher + BlockSizeUser<BlockSize = U16> + BlockEncrypt + BlockDecrypt,
impl<Aes> StructuralPartialEq for Kek<Aes> where
Aes: KeyInit + BlockCipher + BlockSizeUser<BlockSize = U16> + BlockEncrypt + BlockDecrypt,
Auto Trait Implementations
impl<Aes> RefUnwindSafe for Kek<Aes> where
Aes: RefUnwindSafe,
impl<Aes> Send for Kek<Aes> where
Aes: Send,
impl<Aes> Sync for Kek<Aes> where
Aes: Sync,
impl<Aes> Unpin for Kek<Aes> where
Aes: Unpin,
impl<Aes> UnwindSafe for Kek<Aes> where
Aes: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more