Skip to main content

AesGcmContext

Struct AesGcmContext 

Source
pub struct AesGcmContext { /* private fields */ }
Available on crate feature unstable only.
Expand description

An AES-GCM work queue user.

Operations run on AesDmaBackend, which must be started. On AesBackend, every operation ends with GcmError::Unsupported. A nonce must never repeat under one key, because a repeated nonce breaks the authentication.

§Stability

This API is marked as unstable and is only available when the unstable crate feature is enabled. This comes with no stability guarantees, and could be changed or removed at any time.

Implementations§

Source§

impl AesGcmContext

Source

pub fn new(key: impl Into<Key>) -> Self

Creates a new context that encrypts and decrypts with key.

§Stability

This API is marked as unstable and is only available when the unstable crate feature is enabled. This comes with no stability guarantees, and could be changed or removed at any time.

Source

pub fn encrypt<'t>( &'t mut self, nonce: &[u8; 12], aad: &'t [u8], input: &'t [u8], output: &'t mut [u8], tag: &'t mut [u8; 16], ) -> Result<AesGcmHandle<'t>, Error>

Starts encrypting input into output, and computing the tag over aad and the ciphertext.

The tag is written to tag when the operation completes. The nonce must never repeat under this context’s key.

Dropping the returned handle before the operation completes cancels the operation.

§Errors
§Stability

This API is marked as unstable and is only available when the unstable crate feature is enabled. This comes with no stability guarantees, and could be changed or removed at any time.

Source

pub fn encrypt_in_place<'t>( &'t mut self, nonce: &[u8; 12], aad: &'t [u8], buffer: &'t mut [u8], tag: &'t mut [u8; 16], ) -> Result<AesGcmHandle<'t>, Error>

Starts encrypting buffer in place, and computing the tag over aad and the ciphertext.

Operates as Self::encrypt does.

§Errors

As Self::encrypt.

§Stability

This API is marked as unstable and is only available when the unstable crate feature is enabled. This comes with no stability guarantees, and could be changed or removed at any time.

Source

pub fn decrypt<'t>( &'t mut self, nonce: &[u8; 12], aad: &'t [u8], input: &'t [u8], output: &'t mut [u8], tag: &'t [u8; 16], ) -> Result<AesGcmHandle<'t>, Error>

Starts decrypting input into output, and checking tag over aad and input.

When the tag does not match, the operation ends with GcmError::TagMismatch and output is zeroed.

§Errors

As Self::encrypt.

§Stability

This API is marked as unstable and is only available when the unstable crate feature is enabled. This comes with no stability guarantees, and could be changed or removed at any time.

Source

pub fn decrypt_in_place<'t>( &'t mut self, nonce: &[u8; 12], aad: &'t [u8], buffer: &'t mut [u8], tag: &'t [u8; 16], ) -> Result<AesGcmHandle<'t>, Error>

Starts decrypting buffer in place, and checking tag over aad and buffer.

Operates as Self::decrypt does.

§Errors

As Self::encrypt.

§Stability

This API is marked as unstable and is only available when the unstable crate feature is enabled. This comes with no stability guarantees, and could be changed or removed at any time.

Auto Trait Implementations§

§

impl !Send for AesGcmContext

§

impl !Sync for AesGcmContext

§

impl Forget for AesGcmContext

§

impl Freeze for AesGcmContext

§

impl Move for AesGcmContext

§

impl RefUnwindSafe for AesGcmContext

§

impl Unpin for AesGcmContext

§

impl UnsafeUnpin for AesGcmContext

§

impl UnwindSafe for AesGcmContext

Blanket Implementations§

§

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

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

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

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

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> Same for T

Source§

type Output = T

Should always be Self
§

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

§

type Error = !

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

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

Performs the conversion.
§

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

§

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

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

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

Performs the conversion.