pub struct ChaCha20Poly1305Cipher { /* private fields */ }Expand description
ChaCha20-Poly1305 AEAD cipher supporting zero-copy in-place encryption and decryption directly within pre-allocated network packet buffers (such as AF_XDP UMEM chunks).
Implementations§
Source§impl ChaCha20Poly1305Cipher
impl ChaCha20Poly1305Cipher
Sourcepub fn seal_in_place(
&self,
counter: u64,
buf: &mut [u8],
plaintext_len: usize,
) -> Result<usize, CryptoError>
pub fn seal_in_place( &self, counter: u64, buf: &mut [u8], plaintext_len: usize, ) -> Result<usize, CryptoError>
Seal plaintext in-place inside buf[..plaintext_len], writing the 16-byte Poly1305
authentication tag immediately following the ciphertext into buf[plaintext_len..plaintext_len + 16].
The buffer must have capacity of at least plaintext_len + 16 bytes.
Returns the total sealed ciphertext length (plaintext_len + 16).
Sourcepub fn open_in_place(
&self,
counter: u64,
buf: &mut [u8],
sealed_len: usize,
) -> Result<usize, CryptoError>
pub fn open_in_place( &self, counter: u64, buf: &mut [u8], sealed_len: usize, ) -> Result<usize, CryptoError>
Open and authenticate ciphertext in-place inside buf[..sealed_len].
Expects the 16-byte Poly1305 authentication tag at the end of the ciphertext:
buf[sealed_len - 16..sealed_len].
Returns the decrypted plaintext length (sealed_len - 16).
Sourcepub fn open_in_place_with_window(
&self,
counter: u64,
buf: &mut [u8],
sealed_len: usize,
replay: &mut ReplayWindow,
) -> Result<usize, CryptoError>
pub fn open_in_place_with_window( &self, counter: u64, buf: &mut [u8], sealed_len: usize, replay: &mut ReplayWindow, ) -> Result<usize, CryptoError>
Open and authenticate ciphertext in-place, verifying against a sliding anti-replay window.
The replay window is checked before AEAD decryption and committed only upon successful authentication.