aes_kw

Type Alias KekAes256

Source
pub type KekAes256 = Kek<Aes256>;
Expand description

AES-256 KEK

Aliased Type§

struct KekAes256 {
    pub(crate) cipher: Aes256,
}

Fields§

§cipher: Aes256

Initialized cipher

Implementations

Source§

impl<Aes> Kek<Aes>

Source

pub fn new(key: &GenericArray<u8, Aes::KeySize>) -> Self

Constructs a new Kek based on the appropriate raw key material.

Source

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.

Source

pub fn wrap_vec(&self, data: &[u8]) -> Result<Vec<u8>>

Computes Self::wrap, allocating a Vec for the return value.

Source

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.

Source

pub fn unwrap_vec(&self, data: &[u8]) -> Result<Vec<u8>>

Computes Self::unwrap, allocating a Vec for the return value.

Source

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.

Source

pub fn wrap_with_padding_vec(&self, data: &[u8]) -> Result<Vec<u8>>

Computes Self::wrap, allocating a Vec for the return value.

Source

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.

Source

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 From<[u8; 32]> for KekAes256

Source§

fn from(kek: [u8; 32]) -> Self

Converts to this type from the input type.
Source§

impl From<GenericArray<u8, UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>>> for KekAes256

Source§

fn from(kek: GenericArray<u8, U32>) -> Self

Converts to this type from the input type.
Source§

impl<Aes> Clone for Kek<Aes>

Source§

fn clone(&self) -> Kek<Aes>

Returns a copy of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<Aes> Debug for Kek<Aes>

Source§

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

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

impl<Aes> PartialEq for Kek<Aes>

Source§

fn eq(&self, other: &Kek<Aes>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<Aes> TryFrom<&[u8]> for Kek<Aes>

Source§

type Error = Error

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

fn try_from(value: &[u8]) -> Result<Self>

Performs the conversion.
Source§

impl<Aes> Copy for Kek<Aes>

Source§

impl<Aes> StructuralPartialEq for Kek<Aes>