Skip to main content

AesKeyWrap

Struct AesKeyWrap 

Source
pub struct AesKeyWrap<C> { /* private fields */ }
Expand description

AES Key Wrap (RFC 3394) over 64-bit semiblocks with the default IV.

This is the no-padding variant standardized in RFC 3394 and SP 800-38F. Inputs must be a multiple of 8 bytes and at least 16 bytes long.

Implementations§

Source§

impl<C> AesKeyWrap<C>

Source

pub fn new(cipher: C) -> Self

Wrap an AES cipher instance for RFC 3394 key wrap operations.

Source

pub fn cipher(&self) -> &C

Borrow the wrapped AES cipher.

Source§

impl<C: BlockCipher> AesKeyWrap<C>

Source

pub fn wrap_key(&self, key_data: &[u8]) -> Option<Vec<u8>>

Wrap key material with the RFC 3394 default IV (A6A6A6A6A6A6A6A6).

Returns None when key_data is not a multiple of 8 bytes or is shorter than 16 bytes.

Source

pub fn wrap_key_with_iv(&self, key_data: &[u8], iv: &[u8; 8]) -> Option<Vec<u8>>

Wrap key material with an explicit 64-bit initial register value.

Returns None when key_data is not a multiple of 8 bytes or is shorter than 16 bytes.

Source

pub fn unwrap_key(&self, wrapped: &[u8]) -> Option<Vec<u8>>

Unwrap RFC 3394 key material and verify the default IV integrity check.

Returns None when input length is invalid or the integrity check fails.

Source

pub fn unwrap_key_with_iv( &self, wrapped: &[u8], iv: &[u8; 8], ) -> Option<Vec<u8>>

Unwrap RFC 3394 key material and verify against an explicit IV value.

Returns None when input length is invalid or the integrity check fails.

Auto Trait Implementations§

§

impl<C> Freeze for AesKeyWrap<C>
where C: Freeze,

§

impl<C> RefUnwindSafe for AesKeyWrap<C>
where C: RefUnwindSafe,

§

impl<C> Send for AesKeyWrap<C>
where C: Send,

§

impl<C> Sync for AesKeyWrap<C>
where C: Sync,

§

impl<C> Unpin for AesKeyWrap<C>
where C: Unpin,

§

impl<C> UnsafeUnpin for AesKeyWrap<C>
where C: UnsafeUnpin,

§

impl<C> UnwindSafe for AesKeyWrap<C>
where C: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.