Skip to main content

Aes256Gcm

Struct Aes256Gcm 

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

AES-256-GCM authenticated cipher (pure-Rust implementation).

On x86-64 machines with AES-NI + PCLMULQDQ the methods automatically dispatch to the hardware-accelerated path (see aes256_amd64).

Implementations§

Source§

impl Aes256Gcm

Source

pub const KEY_SIZE: usize = 32

Source

pub const TAG_SIZE: usize = 16

Source

pub const NONCE_SIZE: usize = 12

Source

pub fn new(key: &[u8; 32]) -> Self

Create a new Aes256Gcm instance from a 32-byte key.

Source

pub fn encrypt_in_place( &self, in_out: &mut [u8], nonce: &[u8; 12], aad: &[u8], ) -> [u8; 16]

Encrypt in_out in-place and return the 16-byte authentication tag.

  • nonce – 12-byte nonce (must be unique per (key, plaintext) pair)
  • aad – additional authenticated data (not encrypted)
Source

pub fn decrypt_in_place( &self, in_out: &mut [u8], tag: &[u8; 16], nonce: &[u8; 12], aad: &[u8], ) -> Result<(), AeadError>

Decrypt in_out in-place and verify the authentication tag.

Returns Err(Error::Unspecified) if the tag does not match.

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
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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.

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V