Skip to main content

Aes256GcmStream

Struct Aes256GcmStream 

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

STREAM chunked AEAD using AES-256-GCM.

Nonce layout: 7-byte prefix ‖ 4-byte counter (big-endian) ‖ 1-byte flag.

Provide a 7-byte prefix to init. Each encrypt_update or decrypt_update call processes exactly one buffered chunk.

Trait Implementations§

Source§

impl Debug for Aes256GcmStream

Source§

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

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

impl StreamingAead for Aes256GcmStream

Source§

fn init(key: &[u8], nonce: &[u8], aad: &[u8]) -> Result<Self, CryptoError>

Initialise the stream.

nonce must be exactly 7 bytes (the nonce prefix).

Source§

fn encrypt_update( &mut self, chunk: &[u8], out: &mut [u8], ) -> Result<usize, CryptoError>

Encrypt one chunk.

The previously supplied chunk (from the last encrypt_update call) is encrypted into out with a non-final nonce. The supplied chunk is buffered for the next call. On the first call, only buffering occurs; out receives 0 bytes.

out must be large enough to hold the previous chunk’s ciphertext + 16-byte tag (i.e. prev_chunk.len() + 16).

Source§

fn encrypt_finalize(self, out: &mut [u8]) -> Result<[u8; 16], CryptoError>

Finalize encryption by flushing the buffered last chunk with flag=0x01.

out must hold at least last_buffered_chunk.len() + 16 bytes. Returns the 16-byte final authentication tag (also embedded in out).

Source§

fn decrypt_update( &mut self, chunk: &[u8], out: &mut [u8], ) -> Result<usize, CryptoError>

Decrypt one chunk.

Buffers the supplied ciphertext chunk. If a previous chunk is pending, it is decrypted (with non-final nonce) into out.

Source§

fn decrypt_finalize(self, expected_tag: &[u8]) -> Result<(), CryptoError>

Verify and finalize decryption of the buffered last chunk.

expected_tag is the 16-byte tag from the last ciphertext chunk. The buffered chunk must already contain ciphertext || tag.

Source§

fn reset(&mut self)

Reset the stream to its initial uninitialized state.

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.