Skip to main content

AeadInOut

Trait AeadInOut 

Source
pub trait AeadInOut: AeadCore {
    // Required methods
    fn encrypt_inout_detached(
        &self,
        nonce: &Nonce<Self>,
        associated_data: &[u8],
        buffer: InOutBuf<'_, '_, u8>,
    ) -> Result<Tag<Self>>;
    fn decrypt_inout_detached(
        &self,
        nonce: &Nonce<Self>,
        associated_data: &[u8],
        buffer: InOutBuf<'_, '_, u8>,
        tag: &Tag<Self>,
    ) -> Result<()>;

    // Provided methods
    fn encrypt_in_place(
        &self,
        nonce: &Nonce<Self>,
        associated_data: &[u8],
        buffer: &mut dyn Buffer,
    ) -> Result<()> { ... }
    fn decrypt_in_place(
        &self,
        nonce: &Nonce<Self>,
        associated_data: &[u8],
        buffer: &mut dyn Buffer,
    ) -> Result<()> { ... }
}
Expand description

In-place and inout AEAD trait which handles the authentication tag as a return value/separate parameter.

Required Methods§

Source

fn encrypt_inout_detached( &self, nonce: &Nonce<Self>, associated_data: &[u8], buffer: InOutBuf<'_, '_, u8>, ) -> Result<Tag<Self>>

Encrypt the data in the provided InOutBuf, returning the authentication tag.

§Errors

AEAD algorithm implementations may return an error if the plaintext or AAD are too long.

Source

fn decrypt_inout_detached( &self, nonce: &Nonce<Self>, associated_data: &[u8], buffer: InOutBuf<'_, '_, u8>, tag: &Tag<Self>, ) -> Result<()>

Decrypt the data in the provided InOutBuf, returning an error in the event the provided authentication tag is invalid for the given ciphertext (i.e. ciphertext is modified/unauthentic).

§Errors
  • if the ciphertext is inauthentic (i.e. tag verification failure)
  • if the ciphertext is too long
  • if the aad is too long

Provided Methods§

Source

fn encrypt_in_place( &self, nonce: &Nonce<Self>, associated_data: &[u8], buffer: &mut dyn Buffer, ) -> Result<()>

Encrypt the given buffer containing a plaintext message in-place.

The buffer must have sufficient capacity to store the ciphertext message, which will always be larger than the original plaintext. The exact size needed is cipher-dependent, but generally includes the size of an authentication tag.

§Errors

Returns an error if the buffer has insufficient capacity to store the resulting ciphertext message.

Source

fn decrypt_in_place( &self, nonce: &Nonce<Self>, associated_data: &[u8], buffer: &mut dyn Buffer, ) -> Result<()>

Decrypt the message in-place, returning an error in the event the provided authentication tag does not match the given ciphertext.

The buffer will be truncated to the length of the original plaintext message upon success.

§Errors
  • if the ciphertext is inauthentic (i.e. tag verification failure)

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§