pub struct AesGcm<Aes, NonceSize>where
Aes: BlockCipher<BlockSize = U16> + BlockEncrypt,
Aes::ParBlocks: ArrayLength<Block<Aes>>,
NonceSize: ArrayLength<u8>,{ /* private fields */ }
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§
source§impl<Aes, NonceSize> AeadCore for AesGcm<Aes, NonceSize>where
Aes: NewBlockCipher + BlockCipher<BlockSize = U16> + BlockEncrypt,
Aes::ParBlocks: ArrayLength<Block<Aes>>,
NonceSize: ArrayLength<u8>,
impl<Aes, NonceSize> AeadCore for AesGcm<Aes, NonceSize>where Aes: NewBlockCipher + BlockCipher<BlockSize = U16> + BlockEncrypt, Aes::ParBlocks: ArrayLength<Block<Aes>>, NonceSize: ArrayLength<u8>,
source§impl<Aes, NonceSize> AeadInPlace for AesGcm<Aes, NonceSize>where
Aes: NewBlockCipher + BlockCipher<BlockSize = U16> + BlockEncrypt,
Aes::ParBlocks: ArrayLength<Block<Aes>>,
NonceSize: ArrayLength<u8>,
impl<Aes, NonceSize> AeadInPlace for AesGcm<Aes, NonceSize>where Aes: NewBlockCipher + BlockCipher<BlockSize = U16> + BlockEncrypt, Aes::ParBlocks: ArrayLength<Block<Aes>>, NonceSize: ArrayLength<u8>,
source§fn encrypt_in_place_detached(
&self,
nonce: &Nonce<Self::NonceSize>,
associated_data: &[u8],
buffer: &mut [u8]
) -> Result<Tag, Error>
fn encrypt_in_place_detached( &self, nonce: &Nonce<Self::NonceSize>, associated_data: &[u8], buffer: &mut [u8] ) -> Result<Tag, Error>
Encrypt the data in-place, returning the authentication tag
source§fn decrypt_in_place_detached(
&self,
nonce: &Nonce<Self::NonceSize>,
associated_data: &[u8],
buffer: &mut [u8],
tag: &Tag
) -> Result<(), Error>
fn decrypt_in_place_detached( &self, nonce: &Nonce<Self::NonceSize>, associated_data: &[u8], buffer: &mut [u8], tag: &Tag ) -> Result<(), Error>
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)
source§impl<Aes, NonceSize> Clone for AesGcm<Aes, NonceSize>where
Aes: BlockCipher<BlockSize = U16> + BlockEncrypt + Clone,
Aes::ParBlocks: ArrayLength<Block<Aes>>,
NonceSize: ArrayLength<u8> + Clone,
impl<Aes, NonceSize> Clone for AesGcm<Aes, NonceSize>where Aes: BlockCipher<BlockSize = U16> + BlockEncrypt + Clone, Aes::ParBlocks: ArrayLength<Block<Aes>>, NonceSize: ArrayLength<u8> + Clone,
source§impl<Aes, NonceSize> From<Aes> for AesGcm<Aes, NonceSize>where
Aes: NewBlockCipher + BlockCipher<BlockSize = U16> + BlockEncrypt,
Aes::ParBlocks: ArrayLength<Block<Aes>>,
NonceSize: ArrayLength<u8>,
impl<Aes, NonceSize> From<Aes> for AesGcm<Aes, NonceSize>where Aes: NewBlockCipher + BlockCipher<BlockSize = U16> + BlockEncrypt, Aes::ParBlocks: ArrayLength<Block<Aes>>, NonceSize: ArrayLength<u8>,
source§impl<Aes, NonceSize> NewAead for AesGcm<Aes, NonceSize>where
Aes: NewBlockCipher + BlockCipher<BlockSize = U16> + BlockEncrypt,
Aes::ParBlocks: ArrayLength<Block<Aes>>,
NonceSize: ArrayLength<u8>,
impl<Aes, NonceSize> NewAead for AesGcm<Aes, NonceSize>where Aes: NewBlockCipher + BlockCipher<BlockSize = U16> + BlockEncrypt, Aes::ParBlocks: ArrayLength<Block<Aes>>, NonceSize: ArrayLength<u8>,
§type KeySize = <Aes as NewBlockCipher>::KeySize
type KeySize = <Aes as NewBlockCipher>::KeySize
The size of the key array required by this algorithm.
source§fn new(key: &BlockCipherKey<Aes>) -> Self
fn new(key: &BlockCipherKey<Aes>) -> Self
Create a new AEAD instance with the given key.
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§
source§impl<Alg> Aead for Algwhere
Alg: AeadInPlace,
impl<Alg> Aead for Algwhere Alg: AeadInPlace,
source§impl<Alg> AeadMut for Algwhere
Alg: AeadMutInPlace,
impl<Alg> AeadMut for Algwhere Alg: AeadMutInPlace,
source§impl<Alg> AeadMutInPlace for Algwhere
Alg: AeadInPlace,
impl<Alg> AeadMutInPlace for Algwhere Alg: AeadInPlace,
source§fn encrypt_in_place(
&mut self,
nonce: &GenericArray<u8, <Alg as AeadCore>::NonceSize>,
associated_data: &[u8],
buffer: &mut impl Buffer
) -> Result<(), Error>
fn encrypt_in_place( &mut self, nonce: &GenericArray<u8, <Alg as AeadCore>::NonceSize>, associated_data: &[u8], buffer: &mut impl Buffer ) -> Result<(), Error>
Encrypt the given buffer containing a plaintext message in-place. Read more
source§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>
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>
Encrypt the data in-place, returning the authentication tag
source§fn decrypt_in_place(
&mut self,
nonce: &GenericArray<u8, <Alg as AeadCore>::NonceSize>,
associated_data: &[u8],
buffer: &mut impl Buffer
) -> Result<(), Error>
fn decrypt_in_place( &mut self, nonce: &GenericArray<u8, <Alg as AeadCore>::NonceSize>, associated_data: &[u8], buffer: &mut impl Buffer ) -> Result<(), Error>
Decrypt the message in-place, returning an error in the event the
provided authentication tag does not match the given ciphertext. Read more
source§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>
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>
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)
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more