pub struct Kek<Aes>{
pub(crate) cipher: Aes,
}
Expand description
A Key-Encrypting-Key (KEK) that can be used to wrap and unwrap other keys.
Fields§
§cipher: Aes
Initialized cipher
Implementations§
source§impl<Aes> Kek<Aes>
impl<Aes> Kek<Aes>
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>>
pub fn wrap_vec(&self, data: &[u8]) -> Result<Vec<u8>>
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>>
pub fn unwrap_vec(&self, data: &[u8]) -> Result<Vec<u8>>
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>>
pub fn wrap_with_padding_vec(&self, data: &[u8]) -> Result<Vec<u8>>
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>>
pub fn unwrap_with_padding_vec(&self, data: &[u8]) -> Result<Vec<u8>>
Computes Self::unwrap
, allocating a Vec
for the return value.
Trait Implementations§
source§impl<Aes> Clone for Kek<Aes>where
Aes: KeyInit + BlockCipher + BlockSizeUser<BlockSize = U16> + BlockEncrypt + BlockDecrypt + Clone,
impl<Aes> Clone for Kek<Aes>where
Aes: KeyInit + BlockCipher + BlockSizeUser<BlockSize = U16> + BlockEncrypt + BlockDecrypt + Clone,
source§impl<Aes> Debug for Kek<Aes>where
Aes: KeyInit + BlockCipher + BlockSizeUser<BlockSize = U16> + BlockEncrypt + BlockDecrypt + Debug,
impl<Aes> Debug for Kek<Aes>where
Aes: KeyInit + BlockCipher + BlockSizeUser<BlockSize = U16> + BlockEncrypt + BlockDecrypt + Debug,
source§impl<Aes> PartialEq for Kek<Aes>where
Aes: KeyInit + BlockCipher + BlockSizeUser<BlockSize = U16> + BlockEncrypt + BlockDecrypt + PartialEq,
impl<Aes> PartialEq for Kek<Aes>where
Aes: KeyInit + BlockCipher + BlockSizeUser<BlockSize = U16> + BlockEncrypt + BlockDecrypt + PartialEq,
impl<Aes> Copy for Kek<Aes>where
Aes: KeyInit + BlockCipher + BlockSizeUser<BlockSize = U16> + BlockEncrypt + BlockDecrypt + Copy,
impl<Aes> StructuralPartialEq for Kek<Aes>
Auto Trait Implementations§
impl<Aes> Freeze for Kek<Aes>where
Aes: Freeze,
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§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)