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

AesKwp

Struct AesKwp 

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

AES Key Wrapper with Padding (KWP), as defined in RFC 5649.

Implementations§

Source§

impl<C: BlockCipherEncrypt<BlockSize = U16>> AesKwp<C>

Source

pub fn wrap_key<'a>( &self, key: &[u8], buf: &'a mut [u8], ) -> Result<&'a [u8], Error>

AES Key Wrap with Padding, as defined in RFC 5649.

The buf buffer will be overwritten, and must be the smallest multiple of IV_LEN (i.e. 8) which is at least IV_LEN bytes (i.e. 8 bytes) longer than the length of data.

Source

pub fn wrap_fixed_key<N>( &self, key: &Array<u8, N>, ) -> Array<u8, Prod<Add1<Quot<Sum<N, U7>, IvLen>>, IvLen>>

Wrap fixed-size key key and return wrapped key.

This method is roughly equivalent to:

ⓘ
pub fn wrap_fixed_key<const N: usize>(
    &self,
    key: &[u8; N],
) -> [u8; IV_LEN * (N.div_ceil(IV_LEN) + 1)]
{ ... }

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>> AesKwp<C>

Source

pub fn unwrap_key<'a>( &self, data: &[u8], buf: &'a mut [u8], ) -> Result<&'a [u8], Error>

AES Key Wrap with Padding, as defined in RFC 5649.

The buf 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.

Source

pub fn unwrap_fixed_key<N>( &self, wkey: &Array<u8, Prod<Add1<Quot<Sum<N, U7>, IvLen>>, IvLen>>, ) -> Result<Array<u8, N>, IntegrityCheckFailed>

Unwrap fixed-size wrapped key wkey and return resulting key.

This method is roughly equivalent to:

ⓘ
pub fn unwrap_fixed_key<const N: usize>(
    &self,
    wkey: &[u8; IV_LEN * (N.div_ceil(IV_LEN) + 1)],
) -> [u8; N]
{ ... }

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 AesKwp<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 AesKwp<C>

Source§

impl<C: Debug> Debug for AesKwp<C>

Source§

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

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

impl<C> InnerInit for AesKwp<C>

Source§

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

Initialize value from the inner.
Source§

impl<C> InnerUser for AesKwp<C>

Source§

type Inner = C

Inner type.
Source§

impl<C: PartialEq> PartialEq for AesKwp<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 AesKwp<C>

Auto Trait Implementations§

§

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

§

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

§

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

§

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

§

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

§

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

§

impl<C> UnwindSafe for AesKwp<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.