Struct KeyEncryptionKey
pub struct KeyEncryptionKey<Cipher>where
Cipher: BlockCipher,{ /* private fields */ }
Expand description
The key-encryption key used with the selected cipher algorithn to wrap or unwrap a key.
Implements the NIST SP 800-38F key wrapping algoirthm.
The NIST specification is similar to that of RFC 3394 but with the following caveats:
- Specifies a maxiumum plaintext length that can be accepted.
- Allows implementations to specify a subset of valid lengths accepted.
- Allows for the usage of other 128-bit block ciphers other than AES.
Implementations§
§impl<Cipher> KeyEncryptionKey<Cipher>where
Cipher: BlockCipher,
impl<Cipher> KeyEncryptionKey<Cipher>where
Cipher: BlockCipher,
pub fn new(
cipher: &'static Cipher,
key: &[u8],
) -> Result<KeyEncryptionKey<Cipher>, Unspecified>
pub fn new( cipher: &'static Cipher, key: &[u8], ) -> Result<KeyEncryptionKey<Cipher>, Unspecified>
Construct a new Key Encryption Key.
§Errors
Unspecified
: Any error that occurs constructing the key encryption key.
pub fn block_cipher_id(&self) -> BlockCipherId
pub fn block_cipher_id(&self) -> BlockCipherId
Returns the block cipher algorithm identifier configured for the key.
Trait Implementations§
§impl<Cipher> Debug for KeyEncryptionKey<Cipher>where
Cipher: BlockCipher,
impl<Cipher> Debug for KeyEncryptionKey<Cipher>where
Cipher: BlockCipher,
§impl KeyWrap for KeyEncryptionKey<AesBlockCipher>
impl KeyWrap for KeyEncryptionKey<AesBlockCipher>
§fn wrap<'output>(
self,
plaintext: &[u8],
output: &'output mut [u8],
) -> Result<&'output mut [u8], Unspecified>
fn wrap<'output>( self, plaintext: &[u8], output: &'output mut [u8], ) -> Result<&'output mut [u8], Unspecified>
Peforms the key wrap encryption algorithm using KeyEncryptionKey
’s configured block cipher.
It wraps plaintext
and writes the corresponding ciphertext to output
.
§Validation
plaintext.len()
must be a multiple of eightoutput.len() >= (input.len() + 8)
§Errors
Unspecified
: An error occurred either due tooutput
being insufficiently sized,input
exceeding the allowed input size, or for other unspecified reasons.
§fn unwrap<'output>(
self,
ciphertext: &[u8],
output: &'output mut [u8],
) -> Result<&'output mut [u8], Unspecified>
fn unwrap<'output>( self, ciphertext: &[u8], output: &'output mut [u8], ) -> Result<&'output mut [u8], Unspecified>
Peforms the key wrap decryption algorithm using KeyEncryptionKey
’s configured block cipher.
It unwraps ciphertext
and writes the corresponding plaintext to output
.
§Validation
ciphertext.len()
must be a multiple of 8output.len() >= (input.len() - 8)
§Errors
Unspecified
: An error occurred either due tooutput
being insufficiently sized,input
exceeding the allowed input size, or for other unspecified reasons.
§impl KeyWrapPadded for KeyEncryptionKey<AesBlockCipher>
impl KeyWrapPadded for KeyEncryptionKey<AesBlockCipher>
§fn wrap_with_padding<'output>(
self,
plaintext: &[u8],
output: &'output mut [u8],
) -> Result<&'output mut [u8], Unspecified>
fn wrap_with_padding<'output>( self, plaintext: &[u8], output: &'output mut [u8], ) -> Result<&'output mut [u8], Unspecified>
Peforms the key wrap padding encryption algorithm using KeyEncryptionKey
’s configured block cipher.
It wraps and pads plaintext
writes the corresponding ciphertext to output
.
§Validation
output.len() >= (input.len() + 15)
§Errors
Unspecified
: An error occurred either due tooutput
being insufficiently sized,input
exceeding the allowed input size, or for other unspecified reasons.
§fn unwrap_with_padding<'output>(
self,
ciphertext: &[u8],
output: &'output mut [u8],
) -> Result<&'output mut [u8], Unspecified>
fn unwrap_with_padding<'output>( self, ciphertext: &[u8], output: &'output mut [u8], ) -> Result<&'output mut [u8], Unspecified>
Peforms the key wrap padding decryption algorithm using KeyEncryptionKey
’s configured block cipher.
It unwraps the padded ciphertext
and writes the corresponding plaintext to output
.
§Sizing output
output.len() >= input.len()
.
§Errors
Unspecified
: An error occurred either due tooutput
being insufficiently sized,input
exceeding the allowed input size, or for other unspecified reasons.
Auto Trait Implementations§
impl<Cipher> Freeze for KeyEncryptionKey<Cipher>
impl<Cipher> RefUnwindSafe for KeyEncryptionKey<Cipher>where
Cipher: RefUnwindSafe,
impl<Cipher> Send for KeyEncryptionKey<Cipher>where
Cipher: Sync,
impl<Cipher> Sync for KeyEncryptionKey<Cipher>where
Cipher: Sync,
impl<Cipher> Unpin for KeyEncryptionKey<Cipher>
impl<Cipher> UnwindSafe for KeyEncryptionKey<Cipher>where
Cipher: RefUnwindSafe,
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§fn and<P, B, E>(self, other: P) -> And<T, P>
fn and<P, B, E>(self, other: P) -> And<T, P>
Policy
that returns Action::Follow
only if self
and other
return
Action::Follow
. Read more