Struct aes_gcm::AesGcm[][src]

pub struct AesGcm<Aes, NonceSize> where
    Aes: BlockCipher<BlockSize = U16> + BlockEncrypt,
    Aes::ParBlocks: ArrayLength<Block<Aes>>,
    NonceSize: ArrayLength<u8>, 
{ /* fields omitted */ }
Expand description

AES-GCM: generic over an underlying AES implementation and nonce size.

This type is generic to support substituting alternative AES implementations (e.g. embedded hardware implementations)

It is NOT intended to be instantiated with any block cipher besides AES! Doing so runs the risk of unintended cryptographic properties!

The N generic parameter can be used to instantiate AES-GCM with other nonce sizes, however it’s recommended to use it with typenum::U12, the default of 96-bits.

If in doubt, use the built-in Aes128Gcm and Aes256Gcm type aliases.

Trait Implementations

impl<Aes, NonceSize> AeadCore for AesGcm<Aes, NonceSize> where
    Aes: NewBlockCipher + BlockCipher<BlockSize = U16> + BlockEncrypt,
    Aes::ParBlocks: ArrayLength<Block<Aes>>,
    NonceSize: ArrayLength<u8>, 
[src]

type NonceSize = NonceSize

The length of a nonce.

type TagSize = U16

The maximum length of the nonce.

type CiphertextOverhead = U0

The upper bound amount of additional space required to support a ciphertext vs. a plaintext. Read more

impl<Aes, NonceSize> AeadInPlace for AesGcm<Aes, NonceSize> where
    Aes: NewBlockCipher + BlockCipher<BlockSize = U16> + BlockEncrypt,
    Aes::ParBlocks: ArrayLength<Block<Aes>>,
    NonceSize: ArrayLength<u8>, 
[src]

fn encrypt_in_place_detached(
    &self,
    nonce: &Nonce<Self::NonceSize>,
    associated_data: &[u8],
    buffer: &mut [u8]
) -> Result<Tag, Error>
[src]

Encrypt the data in-place, returning the authentication tag

fn decrypt_in_place_detached(
    &self,
    nonce: &Nonce<Self::NonceSize>,
    associated_data: &[u8],
    buffer: &mut [u8],
    tag: &Tag
) -> Result<(), Error>
[src]

Decrypt the message in-place, returning an error in the event the provided authentication tag does not match the given ciphertext (i.e. ciphertext is modified/unauthentic) Read more

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

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

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

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

impl<Aes: Clone, NonceSize: Clone> Clone for AesGcm<Aes, NonceSize> where
    Aes: BlockCipher<BlockSize = U16> + BlockEncrypt,
    Aes::ParBlocks: ArrayLength<Block<Aes>>,
    NonceSize: ArrayLength<u8>, 
[src]

fn clone(&self) -> AesGcm<Aes, NonceSize>[src]

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl<Aes, NonceSize> From<Aes> for AesGcm<Aes, NonceSize> where
    Aes: NewBlockCipher + BlockCipher<BlockSize = U16> + BlockEncrypt,
    Aes::ParBlocks: ArrayLength<Block<Aes>>,
    NonceSize: ArrayLength<u8>, 
[src]

fn from(cipher: Aes) -> Self[src]

Performs the conversion.

impl<Aes, NonceSize> NewAead for AesGcm<Aes, NonceSize> where
    Aes: NewBlockCipher + BlockCipher<BlockSize = U16> + BlockEncrypt,
    Aes::ParBlocks: ArrayLength<Block<Aes>>,
    NonceSize: ArrayLength<u8>, 
[src]

type KeySize = Aes::KeySize

The size of the key array required by this algorithm.

fn new(key: &BlockCipherKey<Aes>) -> Self[src]

Create a new AEAD instance with the given key.

fn new_from_slice(key: &[u8]) -> Result<Self, Error>[src]

Create new AEAD instance from key given as a byte slice.. Read more

Auto Trait Implementations

impl<Aes, NonceSize> RefUnwindSafe for AesGcm<Aes, NonceSize> where
    Aes: RefUnwindSafe,
    NonceSize: RefUnwindSafe

impl<Aes, NonceSize> Send for AesGcm<Aes, NonceSize> where
    Aes: Send,
    NonceSize: Send

impl<Aes, NonceSize> Sync for AesGcm<Aes, NonceSize> where
    Aes: Sync,
    NonceSize: Sync

impl<Aes, NonceSize> Unpin for AesGcm<Aes, NonceSize> where
    Aes: Unpin,
    NonceSize: Unpin

impl<Aes, NonceSize> UnwindSafe for AesGcm<Aes, NonceSize> where
    Aes: UnwindSafe,
    NonceSize: UnwindSafe

Blanket Implementations

impl<Alg> Aead for Alg where
    Alg: AeadInPlace
[src]

pub fn encrypt<'msg, 'aad>(
    &self,
    nonce: &GenericArray<u8, <Alg as AeadCore>::NonceSize>,
    plaintext: impl Into<Payload<'msg, 'aad>>
) -> Result<Vec<u8, Global>, Error>
[src]

Encrypt the given plaintext payload, and return the resulting ciphertext as a vector of bytes. Read more

pub fn decrypt<'msg, 'aad>(
    &self,
    nonce: &GenericArray<u8, <Alg as AeadCore>::NonceSize>,
    ciphertext: impl Into<Payload<'msg, 'aad>>
) -> Result<Vec<u8, Global>, Error>
[src]

Decrypt the given ciphertext slice, and return the resulting plaintext as a vector of bytes. Read more

impl<Alg> AeadMut for Alg where
    Alg: AeadMutInPlace
[src]

pub fn encrypt<'msg, 'aad>(
    &mut self,
    nonce: &GenericArray<u8, <Alg as AeadCore>::NonceSize>,
    plaintext: impl Into<Payload<'msg, 'aad>>
) -> Result<Vec<u8, Global>, Error>
[src]

Encrypt the given plaintext slice, and return the resulting ciphertext as a vector of bytes. Read more

pub fn decrypt<'msg, 'aad>(
    &mut self,
    nonce: &GenericArray<u8, <Alg as AeadCore>::NonceSize>,
    ciphertext: impl Into<Payload<'msg, 'aad>>
) -> Result<Vec<u8, Global>, Error>
[src]

Decrypt the given ciphertext slice, and return the resulting plaintext as a vector of bytes. Read more

impl<Alg> AeadMutInPlace for Alg where
    Alg: AeadInPlace
[src]

pub fn encrypt_in_place(
    &mut self,
    nonce: &GenericArray<u8, <Alg as AeadCore>::NonceSize>,
    associated_data: &[u8],
    buffer: &mut impl Buffer
) -> Result<(), Error>
[src]

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

pub fn encrypt_in_place_detached(
    &mut self,
    nonce: &GenericArray<u8, <Alg as AeadCore>::NonceSize>,
    associated_data: &[u8],
    buffer: &mut [u8]
) -> Result<GenericArray<u8, <Alg as AeadCore>::TagSize>, Error>
[src]

Encrypt the data in-place, returning the authentication tag

pub fn decrypt_in_place(
    &mut self,
    nonce: &GenericArray<u8, <Alg as AeadCore>::NonceSize>,
    associated_data: &[u8],
    buffer: &mut impl Buffer
) -> Result<(), Error>
[src]

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

pub fn decrypt_in_place_detached(
    &mut self,
    nonce: &GenericArray<u8, <Alg as AeadCore>::NonceSize>,
    associated_data: &[u8],
    buffer: &mut [u8],
    tag: &GenericArray<u8, <Alg as AeadCore>::TagSize>
) -> Result<(), Error>
[src]

Decrypt the data in-place, returning an error in the event the provided authentication tag does not match the given ciphertext (i.e. ciphertext is modified/unauthentic) Read more

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

pub fn to_owned(&self) -> T[src]

Creates owned data from borrowed data, usually by cloning. Read more

pub fn clone_into(&self, target: &mut T)[src]

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

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

Performs the conversion.