pub struct AesGcm<Aes, NonceSize> where
Aes: BlockCipher<BlockSize = U16>,
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
sourceimpl<Aes, NonceSize> AeadInPlace for AesGcm<Aes, NonceSize> where
Aes: BlockCipher<BlockSize = U16>,
Aes::ParBlocks: ArrayLength<Block<Aes>>,
NonceSize: ArrayLength<u8>,
impl<Aes, NonceSize> AeadInPlace for AesGcm<Aes, NonceSize> where
Aes: BlockCipher<BlockSize = U16>,
Aes::ParBlocks: ArrayLength<Block<Aes>>,
NonceSize: ArrayLength<u8>,
type NonceSize = NonceSize
type NonceSize = NonceSize
The length of a nonce.
type CiphertextOverhead = U0
type CiphertextOverhead = U0
The upper bound amount of additional space required to support a ciphertext vs. a plaintext. Read more
sourcefn encrypt_in_place_detached(
&self,
nonce: &GenericArray<u8, NonceSize>,
associated_data: &[u8],
buffer: &mut [u8]
) -> Result<Tag, Error>
fn encrypt_in_place_detached(
&self,
nonce: &GenericArray<u8, NonceSize>,
associated_data: &[u8],
buffer: &mut [u8]
) -> Result<Tag, Error>
Encrypt the data in-place, returning the authentication tag
sourcefn decrypt_in_place_detached(
&self,
nonce: &GenericArray<u8, NonceSize>,
associated_data: &[u8],
buffer: &mut [u8],
tag: &Tag
) -> Result<(), Error>
fn decrypt_in_place_detached(
&self,
nonce: &GenericArray<u8, 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) Read more
sourceimpl<Aes: Clone, NonceSize: Clone> Clone for AesGcm<Aes, NonceSize> where
Aes: BlockCipher<BlockSize = U16>,
Aes::ParBlocks: ArrayLength<Block<Aes>>,
NonceSize: ArrayLength<u8>,
impl<Aes: Clone, NonceSize: Clone> Clone for AesGcm<Aes, NonceSize> where
Aes: BlockCipher<BlockSize = U16>,
Aes::ParBlocks: ArrayLength<Block<Aes>>,
NonceSize: ArrayLength<u8>,
sourceimpl<Aes, NonceSize> From<Aes> for AesGcm<Aes, NonceSize> where
Aes: BlockCipher<BlockSize = U16>,
Aes::ParBlocks: ArrayLength<Block<Aes>>,
NonceSize: ArrayLength<u8>,
impl<Aes, NonceSize> From<Aes> for AesGcm<Aes, NonceSize> where
Aes: BlockCipher<BlockSize = U16>,
Aes::ParBlocks: ArrayLength<Block<Aes>>,
NonceSize: ArrayLength<u8>,
sourceimpl<Aes, NonceSize> NewAead for AesGcm<Aes, NonceSize> where
Aes: BlockCipher<BlockSize = U16> + NewBlockCipher,
Aes::ParBlocks: ArrayLength<Block<Aes>>,
NonceSize: ArrayLength<u8>,
impl<Aes, NonceSize> NewAead for AesGcm<Aes, NonceSize> where
Aes: BlockCipher<BlockSize = U16> + NewBlockCipher,
Aes::ParBlocks: ArrayLength<Block<Aes>>,
NonceSize: ArrayLength<u8>,
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
sourceimpl<Alg> Aead for Alg where
Alg: AeadInPlace,
impl<Alg> Aead for Alg where
Alg: AeadInPlace,
type NonceSize = <Alg as AeadInPlace>::NonceSize
type NonceSize = <Alg as AeadInPlace>::NonceSize
The length of a nonce.
type TagSize = <Alg as AeadInPlace>::TagSize
type TagSize = <Alg as AeadInPlace>::TagSize
The maximum length of the nonce.
type CiphertextOverhead = <Alg as AeadInPlace>::CiphertextOverhead
type CiphertextOverhead = <Alg as AeadInPlace>::CiphertextOverhead
The upper bound amount of additional space required to support a ciphertext vs. a plaintext. Read more
sourceimpl<Alg> AeadMut for Alg where
Alg: AeadMutInPlace,
impl<Alg> AeadMut for Alg where
Alg: AeadMutInPlace,
type NonceSize = <Alg as AeadMutInPlace>::NonceSize
type NonceSize = <Alg as AeadMutInPlace>::NonceSize
The length of a nonce.
type TagSize = <Alg as AeadMutInPlace>::TagSize
type TagSize = <Alg as AeadMutInPlace>::TagSize
The maximum length of the nonce.
type CiphertextOverhead = <Alg as AeadMutInPlace>::CiphertextOverhead
type CiphertextOverhead = <Alg as AeadMutInPlace>::CiphertextOverhead
The upper bound amount of additional space required to support a ciphertext vs. a plaintext. Read more
sourceimpl<Alg> AeadMutInPlace for Alg where
Alg: AeadInPlace,
impl<Alg> AeadMutInPlace for Alg where
Alg: AeadInPlace,
type NonceSize = <Alg as AeadInPlace>::NonceSize
type NonceSize = <Alg as AeadInPlace>::NonceSize
The length of a nonce.
type TagSize = <Alg as AeadInPlace>::TagSize
type TagSize = <Alg as AeadInPlace>::TagSize
The maximum length of the nonce.
type CiphertextOverhead = <Alg as AeadInPlace>::CiphertextOverhead
type CiphertextOverhead = <Alg as AeadInPlace>::CiphertextOverhead
The upper bound amount of additional space required to support a ciphertext vs. a plaintext. Read more
sourcepub fn encrypt_in_place(
&mut self,
nonce: &GenericArray<u8, <Alg as AeadMutInPlace>::NonceSize>,
associated_data: &[u8],
buffer: &mut impl Buffer
) -> Result<(), Error>
pub fn encrypt_in_place(
&mut self,
nonce: &GenericArray<u8, <Alg as AeadMutInPlace>::NonceSize>,
associated_data: &[u8],
buffer: &mut impl Buffer
) -> Result<(), Error>
Encrypt the given buffer containing a plaintext message in-place. Read more
sourcepub fn encrypt_in_place_detached(
&mut self,
nonce: &GenericArray<u8, <Alg as AeadMutInPlace>::NonceSize>,
associated_data: &[u8],
buffer: &mut [u8]
) -> Result<GenericArray<u8, <Alg as AeadMutInPlace>::TagSize>, Error>
pub fn encrypt_in_place_detached(
&mut self,
nonce: &GenericArray<u8, <Alg as AeadMutInPlace>::NonceSize>,
associated_data: &[u8],
buffer: &mut [u8]
) -> Result<GenericArray<u8, <Alg as AeadMutInPlace>::TagSize>, Error>
Encrypt the data in-place, returning the authentication tag
sourcepub fn decrypt_in_place(
&mut self,
nonce: &GenericArray<u8, <Alg as AeadMutInPlace>::NonceSize>,
associated_data: &[u8],
buffer: &mut impl Buffer
) -> Result<(), Error>
pub fn decrypt_in_place(
&mut self,
nonce: &GenericArray<u8, <Alg as AeadMutInPlace>::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
sourcepub fn decrypt_in_place_detached(
&mut self,
nonce: &GenericArray<u8, <Alg as AeadMutInPlace>::NonceSize>,
associated_data: &[u8],
buffer: &mut [u8],
tag: &GenericArray<u8, <Alg as AeadMutInPlace>::TagSize>
) -> Result<(), Error>
pub fn decrypt_in_place_detached(
&mut self,
nonce: &GenericArray<u8, <Alg as AeadMutInPlace>::NonceSize>,
associated_data: &[u8],
buffer: &mut [u8],
tag: &GenericArray<u8, <Alg as AeadMutInPlace>::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) Read more
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more