pub struct AesGcm<Aes, NonceSize, TagSize = U16>where
TagSize: TagSize,{ /* 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 NonceSize 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.
The TagSize generic parameter can be used to instantiate AES-GCM with other
authorization tag sizes, however it’s recommended to use it with typenum::U16,
the default of 128-bits.
If in doubt, use the built-in Aes128Gcm and Aes256Gcm type aliases.
§⚠️ WARNING: Hazmat!
When using short authentication tags, namely 32-bit tags with typenum::U4 or
64-bit tags with typenum::U8 (which require the crate feature hazmat), it is
RECOMMENDED that a key not be used for more than the maximum invocations of
authenticated decryption specified in Table 1 or Table 2 of NIST SP 800-38D,
respectively.
Trait Implementations§
Source§impl<Aes, NonceSize, TagSize> AeadCore for AesGcm<Aes, NonceSize, TagSize>where
NonceSize: ArraySize,
TagSize: TagSize,
impl<Aes, NonceSize, TagSize> AeadCore for AesGcm<Aes, NonceSize, TagSize>where
NonceSize: ArraySize,
TagSize: TagSize,
Source§const TAG_POSITION: TagPosition = TagPosition::Postfix
const TAG_POSITION: TagPosition = TagPosition::Postfix
Source§impl<Aes, NonceSize, TagSize> AeadInOut for AesGcm<Aes, NonceSize, TagSize>where
Aes: BlockSizeUser<BlockSize = U16> + BlockCipherEncrypt,
NonceSize: ArraySize,
TagSize: TagSize,
impl<Aes, NonceSize, TagSize> AeadInOut for AesGcm<Aes, NonceSize, TagSize>where
Aes: BlockSizeUser<BlockSize = U16> + BlockCipherEncrypt,
NonceSize: ArraySize,
TagSize: TagSize,
Source§fn encrypt_inout_detached(
&self,
nonce: &Nonce<NonceSize>,
associated_data: &[u8],
buffer: InOutBuf<'_, '_, u8>,
) -> Result<Tag<TagSize>, Error>
fn encrypt_inout_detached( &self, nonce: &Nonce<NonceSize>, associated_data: &[u8], buffer: InOutBuf<'_, '_, u8>, ) -> Result<Tag<TagSize>, Error>
InOutBuf], returning the authentication tag. Read moreSource§fn decrypt_inout_detached(
&self,
nonce: &Nonce<NonceSize>,
associated_data: &[u8],
buffer: InOutBuf<'_, '_, u8>,
tag: &Tag<TagSize>,
) -> Result<(), Error>
fn decrypt_inout_detached( &self, nonce: &Nonce<NonceSize>, associated_data: &[u8], buffer: InOutBuf<'_, '_, u8>, tag: &Tag<TagSize>, ) -> Result<(), Error>
InOutBuf], returning an error in the event the
provided authentication tag is invalid for the given ciphertext (i.e. ciphertext
is modified/unauthentic). Read moreSource§impl<Aes, NonceSize, TagSize> Debug for AesGcm<Aes, NonceSize, TagSize>where
TagSize: TagSize,
impl<Aes, NonceSize, TagSize> Debug for AesGcm<Aes, NonceSize, TagSize>where
TagSize: TagSize,
Source§impl<Aes, NonceSize, TagSize> KeyInit for AesGcm<Aes, NonceSize, TagSize>
impl<Aes, NonceSize, TagSize> KeyInit for AesGcm<Aes, NonceSize, TagSize>
§fn new_from_slice(key: &[u8]) -> Result<Self, InvalidLength>
fn new_from_slice(key: &[u8]) -> Result<Self, InvalidLength>
Source§impl<Aes, NonceSize, TagSize> KeySizeUser for AesGcm<Aes, NonceSize, TagSize>where
Aes: KeySizeUser,
TagSize: TagSize,
impl<Aes, NonceSize, TagSize> KeySizeUser for AesGcm<Aes, NonceSize, TagSize>where
Aes: KeySizeUser,
TagSize: TagSize,
Auto Trait Implementations§
impl<Aes, NonceSize, TagSize> Freeze for AesGcm<Aes, NonceSize, TagSize>where
Aes: Freeze,
impl<Aes, NonceSize, TagSize> RefUnwindSafe for AesGcm<Aes, NonceSize, TagSize>
impl<Aes, NonceSize, TagSize> Send for AesGcm<Aes, NonceSize, TagSize>
impl<Aes, NonceSize, TagSize> Sync for AesGcm<Aes, NonceSize, TagSize>
impl<Aes, NonceSize, TagSize> Unpin for AesGcm<Aes, NonceSize, TagSize>
impl<Aes, NonceSize, TagSize> UnsafeUnpin for AesGcm<Aes, NonceSize, TagSize>where
Aes: UnsafeUnpin,
impl<Aes, NonceSize, TagSize> UnwindSafe for AesGcm<Aes, NonceSize, TagSize>
Blanket Implementations§
Source§impl<T> Aead for Twhere
T: AeadInOut,
impl<T> Aead for Twhere
T: AeadInOut,
Source§impl<T> AeadInPlace for Twhere
T: AeadInOut,
impl<T> AeadInPlace for Twhere
T: AeadInOut,
Source§fn encrypt_in_place(
&self,
nonce: &Array<u8, <T as AeadCore>::NonceSize>,
associated_data: &[u8],
buffer: &mut dyn Buffer,
) -> Result<(), Error>
fn encrypt_in_place( &self, nonce: &Array<u8, <T as AeadCore>::NonceSize>, associated_data: &[u8], buffer: &mut dyn Buffer, ) -> Result<(), Error>
use AeadInOut::encrypt_in_place instead
Source§fn encrypt_in_place_detached(
&self,
nonce: &Array<u8, <T as AeadCore>::NonceSize>,
associated_data: &[u8],
buffer: &mut [u8],
) -> Result<Array<u8, <T as AeadCore>::TagSize>, Error>
fn encrypt_in_place_detached( &self, nonce: &Array<u8, <T as AeadCore>::NonceSize>, associated_data: &[u8], buffer: &mut [u8], ) -> Result<Array<u8, <T as AeadCore>::TagSize>, Error>
use AeadInOut::encrypt_inout_detached instead
Source§fn decrypt_in_place(
&self,
nonce: &Array<u8, <T as AeadCore>::NonceSize>,
associated_data: &[u8],
buffer: &mut dyn Buffer,
) -> Result<(), Error>
fn decrypt_in_place( &self, nonce: &Array<u8, <T as AeadCore>::NonceSize>, associated_data: &[u8], buffer: &mut dyn Buffer, ) -> Result<(), Error>
use AeadInOut::decrypt_in_place instead
Source§fn decrypt_in_place_detached(
&self,
nonce: &Array<u8, <T as AeadCore>::NonceSize>,
associated_data: &[u8],
buffer: &mut [u8],
tag: &Array<u8, <T as AeadCore>::TagSize>,
) -> Result<(), Error>
fn decrypt_in_place_detached( &self, nonce: &Array<u8, <T as AeadCore>::NonceSize>, associated_data: &[u8], buffer: &mut [u8], tag: &Array<u8, <T as AeadCore>::TagSize>, ) -> Result<(), Error>
use AeadInOut::decrypt_inout_detached instead