Skip to main content

Aes256GcmCipher

Struct Aes256GcmCipher 

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

AES-256-GCM cipher implementation.

Provides authenticated encryption with associated data (AEAD).

  • Key size: 256 bits (32 bytes)
  • Nonce size: 96 bits (12 bytes)
  • Tag size: 128 bits (16 bytes)

§Ciphertext Format

[nonce: 12 bytes][ciphertext + tag: variable]

Implementations§

Source§

impl Aes256GcmCipher

Source

pub const KEY_SIZE: usize = 32

Key size in bytes (256 bits).

Source

pub const NONCE_SIZE: usize = 12

Nonce size in bytes (96 bits).

Source

pub const TAG_SIZE: usize = 16

Authentication tag size in bytes (128 bits).

Source

pub fn new(key: &EncryptionKey) -> CryptoResult<Self>

Create a new AES-256-GCM cipher with the given key.

Trait Implementations§

Source§

impl Cipher for Aes256GcmCipher

Available on crate feature aes only.
Source§

fn encrypt( &self, plaintext: &[u8], associated_data: Option<&[u8]>, ) -> CryptoResult<Vec<u8>>

Encrypt plaintext with optional associated data. Read more
Source§

fn decrypt( &self, ciphertext: &[u8], associated_data: Option<&[u8]>, ) -> CryptoResult<Vec<u8>>

Decrypt ciphertext with optional associated data. Read more
Source§

fn algorithm(&self) -> &'static str

Get the cipher algorithm name.
Source§

fn key_size(&self) -> usize

Get the key size in bytes.
Source§

fn nonce_size(&self) -> usize

Get the nonce size in bytes.
Source§

fn tag_size(&self) -> usize

Get the authentication tag size in bytes.

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

Source§

type Output = T

Should always be Self
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.
Source§

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

Source§

fn vzip(self) -> V