pub struct AesGcmCrypter { /* private fields */ }Expand description
AES-256-GCM crypter (cryptographically secure).
Uses the AES-256-GCM AEAD algorithm and generates a random 12-byte nonce on
each encryption. Ciphertext format: nonce(12) || ciphertext || tag(16)
(handled internally by the aes-gcm crate).
Implementations§
Source§impl AesGcmCrypter
impl AesGcmCrypter
Source§impl AesGcmCrypter
impl AesGcmCrypter
Sourcepub fn encrypt_with_aad(
&self,
plaintext: &[u8],
aad: &[u8],
) -> Result<Vec<u8>, CryptoError>
pub fn encrypt_with_aad( &self, plaintext: &[u8], aad: &[u8], ) -> Result<Vec<u8>, CryptoError>
AES-GCM authenticated encryption (with Additional Authenticated Data, AAD).
Ciphertext format: nonce(12) || ciphertext || tag(16).
AAD (Additional Authenticated Data) is not included in the ciphertext but
participates in the authentication tag computation; the same AAD must be
provided during decryption to succeed.
Sourcepub fn decrypt_with_aad(
&self,
ciphertext: &[u8],
aad: &[u8],
) -> Result<Vec<u8>, CryptoError>
pub fn decrypt_with_aad( &self, ciphertext: &[u8], aad: &[u8], ) -> Result<Vec<u8>, CryptoError>
AES-GCM authenticated decryption (with Additional Authenticated Data, AAD).
The same AAD used during encryption must be provided, otherwise the authentication tag verification fails.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for AesGcmCrypter
impl RefUnwindSafe for AesGcmCrypter
impl Send for AesGcmCrypter
impl Sync for AesGcmCrypter
impl Unpin for AesGcmCrypter
impl UnsafeUnpin for AesGcmCrypter
impl UnwindSafe for AesGcmCrypter
Blanket Implementations§
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