pub type Aes256Gcm = AesGcm<Aes256, U12>;
Expand description
AES-GCM with a 256-bit key and 96-bit nonce.
Aliased Type§
struct Aes256Gcm {
pub(crate) cipher: Aes256,
pub(crate) ghash: GHash,
pub(crate) nonce_size: PhantomData<UInt<UInt<UInt<UInt<UTerm, B1>, B1>, B0>, B0>>,
pub(crate) tag_size: PhantomData<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>>,
}
Fields§
§cipher: Aes256
Encryption cipher.
ghash: GHash
GHASH authenticator.
nonce_size: PhantomData<UInt<UInt<UInt<UInt<UTerm, B1>, B1>, B0>, B0>>
Length of the nonce.
tag_size: PhantomData<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>>
Length of the tag.
Implementations
Source§impl<Aes, NonceSize, TagSize> AesGcm<Aes, NonceSize, TagSize>where
Aes: BlockCipher + BlockSizeUser<BlockSize = U16> + BlockEncrypt,
NonceSize: ArrayLength<u8>,
TagSize: TagSize,
impl<Aes, NonceSize, TagSize> AesGcm<Aes, NonceSize, TagSize>where
Aes: BlockCipher + BlockSizeUser<BlockSize = U16> + BlockEncrypt,
NonceSize: ArrayLength<u8>,
TagSize: TagSize,
Sourcepub(crate) fn init_ctr(
&self,
nonce: &Nonce<NonceSize>,
) -> (CtrCore<&Aes, Ctr32BE>, GenericArray<u8, U16>)
pub(crate) fn init_ctr( &self, nonce: &Nonce<NonceSize>, ) -> (CtrCore<&Aes, Ctr32BE>, GenericArray<u8, U16>)
Initialize counter mode.
See algorithm described in Section 7.2 of NIST SP800-38D: https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38d.pdf
Define a block, J0, as follows: If len(IV)=96, then J0 = IV || 0{31} || 1. If len(IV) ≠ 96, then let s = 128 ⎡len(IV)/128⎤-len(IV), and J0=GHASH(IV||0s+64||[len(IV)]64).
Sourcepub(crate) fn compute_tag(
&self,
mask: GenericArray<u8, U16>,
associated_data: &[u8],
buffer: &[u8],
) -> Tag
pub(crate) fn compute_tag( &self, mask: GenericArray<u8, U16>, associated_data: &[u8], buffer: &[u8], ) -> Tag
Authenticate the given plaintext and associated data using GHASH.
Trait Implementations
Source§impl<Aes, NonceSize, TagSize> AeadCore for AesGcm<Aes, NonceSize, TagSize>
impl<Aes, NonceSize, TagSize> AeadCore for AesGcm<Aes, NonceSize, TagSize>
Source§type CiphertextOverhead = UTerm
type CiphertextOverhead = UTerm
The upper bound amount of additional space required to support a
ciphertext vs. a plaintext.
Source§fn generate_nonce(
rng: impl CryptoRng + RngCore,
) -> GenericArray<u8, Self::NonceSize>
fn generate_nonce( rng: impl CryptoRng + RngCore, ) -> GenericArray<u8, Self::NonceSize>
Generate a random nonce for this AEAD algorithm. Read more
Source§impl<Aes, NonceSize, TagSize> AeadInPlace for AesGcm<Aes, NonceSize, TagSize>where
Aes: BlockCipher + BlockSizeUser<BlockSize = U16> + BlockEncrypt,
NonceSize: ArrayLength<u8>,
TagSize: TagSize,
impl<Aes, NonceSize, TagSize> AeadInPlace for AesGcm<Aes, NonceSize, TagSize>where
Aes: BlockCipher + BlockSizeUser<BlockSize = U16> + BlockEncrypt,
NonceSize: ArrayLength<u8>,
TagSize: TagSize,
Source§fn encrypt_in_place_detached(
&self,
nonce: &Nonce<NonceSize>,
associated_data: &[u8],
buffer: &mut [u8],
) -> Result<Tag<TagSize>, Error>
fn encrypt_in_place_detached( &self, nonce: &Nonce<NonceSize>, associated_data: &[u8], buffer: &mut [u8], ) -> Result<Tag<TagSize>, Error>
Encrypt the data in-place, returning the authentication tag
Source§fn decrypt_in_place_detached(
&self,
nonce: &Nonce<NonceSize>,
associated_data: &[u8],
buffer: &mut [u8],
tag: &Tag<TagSize>,
) -> Result<(), Error>
fn decrypt_in_place_detached( &self, nonce: &Nonce<NonceSize>, associated_data: &[u8], buffer: &mut [u8], tag: &Tag<TagSize>, ) -> 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, TagSize> KeyInit for AesGcm<Aes, NonceSize, TagSize>
impl<Aes, NonceSize, TagSize> KeyInit for AesGcm<Aes, NonceSize, TagSize>
Source§fn new_from_slice(key: &[u8]) -> Result<Self, InvalidLength>
fn new_from_slice(key: &[u8]) -> Result<Self, InvalidLength>
Create new value from variable size key.
Source§fn generate_key(
rng: impl CryptoRng + RngCore,
) -> GenericArray<u8, Self::KeySize>
fn generate_key( rng: impl CryptoRng + RngCore, ) -> GenericArray<u8, Self::KeySize>
Generate random key using the provided
CryptoRng
.