pub struct ChaCha20Poly1305 { /* private fields */ }Expand description
ChaCha20-Poly1305 AEAD
Implementations§
Source§impl ChaCha20Poly1305
impl ChaCha20Poly1305
Sourcepub fn encrypt_with_nonce(
&self,
nonce: &[u8; 12],
plaintext: &[u8],
aad: Option<&[u8]>,
) -> Result<Vec<u8>>
pub fn encrypt_with_nonce( &self, nonce: &[u8; 12], plaintext: &[u8], aad: Option<&[u8]>, ) -> Result<Vec<u8>>
Encrypt plaintext with a raw nonce array
This method performs ChaCha20-Poly1305 encryption using a raw nonce array instead of a type-safe Nonce object. It is primarily used internally.
§Arguments
nonce- A 12-byte array to use as the nonceplaintext- The data to encryptaad- Optional associated data to authenticate but not encrypt
§Returns
A vector containing the ciphertext followed by the 16-byte Poly1305 authentication tag
Sourcepub fn decrypt_with_nonce(
&self,
nonce: &[u8; 12],
ciphertext: &[u8],
aad: Option<&[u8]>,
) -> Result<Vec<u8>>
pub fn decrypt_with_nonce( &self, nonce: &[u8; 12], ciphertext: &[u8], aad: Option<&[u8]>, ) -> Result<Vec<u8>>
Decrypt ciphertext with a raw nonce array
This method performs ChaCha20-Poly1305 decryption using a raw nonce array instead of a type-safe Nonce object. It is primarily used internally.
§Arguments
nonce- A 12-byte array to use as the nonceciphertext- The ciphertext with appended authentication tagaad- Optional associated data that was authenticated
§Returns
The decrypted plaintext if authentication succeeds
§Errors
Returns an authentication error if the tag verification fails
Sourcepub fn decrypt_with_nonce_protected(
&self,
nonce: &[u8; 12],
ciphertext: &[u8],
aad: Option<&[u8]>,
) -> Result<ZeroizingBytes>
pub fn decrypt_with_nonce_protected( &self, nonce: &[u8; 12], ciphertext: &[u8], aad: Option<&[u8]>, ) -> Result<ZeroizingBytes>
Decrypt into exact-size storage that clears itself on all internal error and drop paths. Callers should use this for intermediate plaintext that has not yet crossed a public output boundary.
Trait Implementations§
Source§impl Clone for ChaCha20Poly1305
impl Clone for ChaCha20Poly1305
Source§fn clone(&self) -> ChaCha20Poly1305
fn clone(&self) -> ChaCha20Poly1305
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more