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
Trait Implementations§
Source§impl Clone for ChaCha20Poly1305
impl Clone for ChaCha20Poly1305
Source§fn clone(&self) -> ChaCha20Poly1305
fn clone(&self) -> ChaCha20Poly1305
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl<'a> DecryptOperation<'a, ChaCha20Poly1305> for ChaCha20Poly1305DecryptOperation<'a>
impl<'a> DecryptOperation<'a, ChaCha20Poly1305> for ChaCha20Poly1305DecryptOperation<'a>
Source§fn with_nonce(
self,
nonce: &'a <ChaCha20Poly1305 as SymmetricCipher>::Nonce,
) -> Self
fn with_nonce( self, nonce: &'a <ChaCha20Poly1305 as SymmetricCipher>::Nonce, ) -> Self
Set the nonce for decryption
Source§fn decrypt(
self,
ciphertext: &'a <ChaCha20Poly1305 as SymmetricCipher>::Ciphertext,
) -> Result<Vec<u8>, CoreError>
fn decrypt( self, ciphertext: &'a <ChaCha20Poly1305 as SymmetricCipher>::Ciphertext, ) -> Result<Vec<u8>, CoreError>
Set ciphertext and execute decryption
Source§impl Drop for ChaCha20Poly1305
impl Drop for ChaCha20Poly1305
Source§impl<'a> EncryptOperation<'a, ChaCha20Poly1305> for ChaCha20Poly1305EncryptOperation<'a>
impl<'a> EncryptOperation<'a, ChaCha20Poly1305> for ChaCha20Poly1305EncryptOperation<'a>
Source§fn with_nonce(
self,
nonce: &'a <ChaCha20Poly1305 as SymmetricCipher>::Nonce,
) -> Self
fn with_nonce( self, nonce: &'a <ChaCha20Poly1305 as SymmetricCipher>::Nonce, ) -> Self
Set the nonce for encryption
Source§impl SymmetricCipher for ChaCha20Poly1305
impl SymmetricCipher for ChaCha20Poly1305
Source§type Key = SecretBytes<CHACHA20POLY1305_KEY_SIZE>
type Key = SecretBytes<CHACHA20POLY1305_KEY_SIZE>
Key type with appropriate algorithm binding
Source§type Ciphertext = Ciphertext
type Ciphertext = Ciphertext
Ciphertext output type
Source§type EncryptOperation<'a> = ChaCha20Poly1305EncryptOperation<'a>
where
Self: 'a
type EncryptOperation<'a> = ChaCha20Poly1305EncryptOperation<'a> where Self: 'a
Operation type for encryption operations
Source§type DecryptOperation<'a> = ChaCha20Poly1305DecryptOperation<'a>
where
Self: 'a
type DecryptOperation<'a> = ChaCha20Poly1305DecryptOperation<'a> where Self: 'a
Operation type for decryption operations
Source§fn encrypt(&self) -> Self::EncryptOperation<'_>
fn encrypt(&self) -> Self::EncryptOperation<'_>
Begin encryption operation
Source§fn decrypt(&self) -> Self::DecryptOperation<'_>
fn decrypt(&self) -> Self::DecryptOperation<'_>
Begin decryption operation
Source§fn generate_key<R: RngCore + CryptoRng>(
rng: &mut R,
) -> Result<Self::Key, CoreError>
fn generate_key<R: RngCore + CryptoRng>( rng: &mut R, ) -> Result<Self::Key, CoreError>
Generate a new random key
Auto Trait Implementations§
impl Freeze for ChaCha20Poly1305
impl RefUnwindSafe for ChaCha20Poly1305
impl Send for ChaCha20Poly1305
impl Sync for ChaCha20Poly1305
impl Unpin for ChaCha20Poly1305
impl UnwindSafe for ChaCha20Poly1305
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