aws_lc_rs::aead

Struct RandomizedNonceKey

Source
pub struct RandomizedNonceKey { /* private fields */ }
Expand description

AEAD Cipher key using a randomized nonce.

RandomizedNonceKey handles generation random nonce values.

The following algorithms are supported:

  • AES_128_GCM
  • AES_256_GCM

Prefer this type in place of LessSafeKey, OpeningKey, SealingKey.

Implementations§

Source§

impl RandomizedNonceKey

Source

pub fn new( algorithm: &'static Algorithm, key_bytes: &[u8], ) -> Result<Self, Unspecified>

New Random Nonce Sequence

§Errors
Source

pub fn open_in_place<'in_out, A>( &self, nonce: Nonce, aad: Aad<A>, in_out: &'in_out mut [u8], ) -> Result<&'in_out mut [u8], Unspecified>
where A: AsRef<[u8]>,

Authenticates and decrypts (“opens”) data in place.

§Errors

error::Unspecified when ciphertext is invalid.

Source

pub fn seal_in_place_append_tag<'a, A, InOut>( &self, aad: Aad<A>, in_out: &'a mut InOut, ) -> Result<Nonce, Unspecified>
where A: AsRef<[u8]>, InOut: AsMut<[u8]> + for<'in_out> Extend<&'in_out u8>,

Encrypts and signs (“seals”) data in place, appending the tag to the resulting ciphertext.

key.seal_in_place_append_tag(aad, in_out) is equivalent to:

key.seal_in_place_separate_tag(aad, in_out.as_mut())
    .map(|tag| in_out.extend(tag.as_ref()))

The Nonce used for the operation is randomly generated, and returned to the caller.

§Errors

error::Unspecified if encryption operation fails.

Source

pub fn seal_in_place_separate_tag<A>( &self, aad: Aad<A>, in_out: &mut [u8], ) -> Result<(Nonce, Tag), Unspecified>
where A: AsRef<[u8]>,

Encrypts and signs (“seals”) data in place.

aad is the additional authenticated data (AAD), if any. This is authenticated but not encrypted. The type A could be a byte slice &[u8], a byte array [u8; N] for some constant N, Vec<u8>, etc. If there is no AAD then use Aad::empty().

The plaintext is given as the input value of in_out. seal_in_place() will overwrite the plaintext with the ciphertext and return the tag. For most protocols, the caller must append the tag to the ciphertext. The tag will be self.algorithm.tag_len() bytes long.

The Nonce used for the operation is randomly generated, and returned to the caller.

§Errors

error::Unspecified if encryption operation fails.

Source

pub fn algorithm(&self) -> &'static Algorithm

The key’s AEAD algorithm.

Trait Implementations§

Source§

impl Debug for RandomizedNonceKey

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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.