Skip to main content
This is unreleased documentation for the main (development) branch of crypto-glue.

AesKw

Struct AesKw 

Source
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>

Source

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.

Source

pub fn wrap_fixed_key<N>(&self, key: &Array<u8, N>) -> Array<u8, Sum<N, IvLen>>
where N: ArraySize + NonZero + Add<IvLen> + Rem<IvLen>, Sum<N, IvLen>: ArraySize, Mod<N, IvLen>: Zero,

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>

Source

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().

Source

pub fn unwrap_fixed_key<N>( &self, wkey: &Array<u8, Sum<N, IvLen>>, ) -> Result<Array<u8, N>, IntegrityCheckFailed>
where N: ArraySize + NonZero + Add<IvLen> + Rem<IvLen>, Sum<N, IvLen>: ArraySize, Mod<N, IvLen>: Zero,

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§

Source§

impl<C: Clone> Clone for AesKw<C>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<C: Copy> Copy for AesKw<C>

Source§

impl<C: Debug> Debug for AesKw<C>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<C> InnerInit for AesKw<C>

Source§

fn inner_init(cipher: Self::Inner) -> Self

Initialize value from the inner.
Source§

impl<C> InnerUser for AesKw<C>

Source§

type Inner = C

Inner type.
Source§

impl<C: PartialEq> PartialEq for AesKw<C>

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl<C: PartialEq> StructuralPartialEq for AesKw<C>

Auto Trait Implementations§

§

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

§

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

§

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

§

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

§

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

§

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

§

impl<C> UnwindSafe for AesKw<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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynAssociatedOid for T
where T: AssociatedOid,

Source§

fn oid(&self) -> ObjectIdentifier

Get the OID associated with this value.
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> KeyInit for T
where T: InnerInit, <T as InnerUser>::Inner: KeyInit,

Source§

fn new(key: &Array<u8, <T as KeySizeUser>::KeySize>) -> T

Create new value from fixed size key.
Source§

fn new_from_slice(key: &[u8]) -> Result<T, InvalidLength>

Create new value from variable size key. Read more
Source§

fn generate_key<R>(rng: &mut R) -> Array<u8, Self::KeySize>
where R: CryptoRng,

👎Deprecated since 0.2.0:

use the Generate trait impl on Key instead

DEPRECATED: generate random key using the provided CryptoRng. Read more
Source§

impl<T> KeySizeUser for T
where T: InnerUser, <T as InnerUser>::Inner: KeySizeUser,

Source§

type KeySize = <<T as InnerUser>::Inner as KeySizeUser>::KeySize

Key size in bytes.
Source§

fn key_size() -> usize

Return key size in bytes.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.