Struct ChaCha20Poly1305
pub struct ChaCha20Poly1305 { /* private fields */ }Expand description
ChaCha20-Poly1305 AEAD as specified in RFC 8439.
§Parameters
- Key: 256 bits (32 bytes)
- Nonce: 96 bits (12 bytes)
- Tag: 128 bits (16 bytes)
§Panics
encrypt_in_place panics if in_out exceeds
[CHACHA20_IETF_MAX_LEN] bytes (~256 GiB), the maximum allowed by RFC 8439’s 32-bit block
counter. decrypt_in_place returns
[AeadError::InvalidCiphertext] in that case instead.
Implementations§
§impl ChaCha20Poly1305
impl ChaCha20Poly1305
pub fn new(key: &[u8; 32]) -> ChaCha20Poly1305
pub fn new(key: &[u8; 32]) -> ChaCha20Poly1305
Creates a new AEAD instance from a 32-byte key.
Trait Implementations§
§impl Aead for ChaCha20Poly1305
impl Aead for ChaCha20Poly1305
const KEY_SIZE: usize = 32
const TAG_SIZE: usize = 16
const NONCE_SIZE: usize = 12
fn encrypt_in_place(&self, in_out: &mut [u8], nonce: &[u8], aad: &[u8]) -> Hash
fn decrypt_in_place( &self, in_out: &mut [u8], nonce: &[u8], aad: &[u8], tag: &[u8], ) -> Result<(), AeadError>
fn encrypt(&self, plaintext: &[u8], nonce: &[u8], aad: &[u8]) -> Vec<u8> ⓘ
fn decrypt( &self, ciphertext: &[u8], nonce: &[u8], aad: &[u8], ) -> Result<Vec<u8>, AeadError>
Source§impl Aead for ChaCha20Poly1305
ChaCha20-Poly1305 (AEAD id 0x0003).
impl Aead for ChaCha20Poly1305
ChaCha20-Poly1305 (AEAD id 0x0003).
Source§const HPKE_AEAD_ID: u16 = 0x0003
const HPKE_AEAD_ID: u16 = 0x0003
The HPKE AEAD identifier (
draft-ietf-hpke-hpke-05 Section 7.3, IANA
“HPKE AEAD Identifiers”), used to build the ciphersuite suite_id.Source§const MAX_PLAINTEXT_SIZE: u64 = CHACHA20_POLY1305_MAX_PLAINTEXT_SIZE
const MAX_PLAINTEXT_SIZE: u64 = CHACHA20_POLY1305_MAX_PLAINTEXT_SIZE
Source§const MAX_CIPHERTEXT_SIZE: u64 = CHACHA20_POLY1305_MAX_CIPHERTEXT_SIZE
const MAX_CIPHERTEXT_SIZE: u64 = CHACHA20_POLY1305_MAX_CIPHERTEXT_SIZE
Source§fn new(key: &[u8]) -> Result<Self, HpkeError>
fn new(key: &[u8]) -> Result<Self, HpkeError>
Instantiates the cipher from
KEY_SIZE raw key bytes, as produced by
the HPKE key schedule. Read more§impl Drop for ChaCha20Poly1305
impl Drop for ChaCha20Poly1305
§impl Zeroize for ChaCha20Poly1305
impl Zeroize for ChaCha20Poly1305
Auto Trait Implementations§
impl Freeze for ChaCha20Poly1305
impl RefUnwindSafe for ChaCha20Poly1305
impl Send for ChaCha20Poly1305
impl Sync for ChaCha20Poly1305
impl Unpin for ChaCha20Poly1305
impl UnsafeUnpin 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