core::crypto::aead
API 参考只有英文版,由标准库源代码中的英文文档注释生成。
Authenticated encryption with associated data: AES-GCM (NIST SP 800-38D, 96-bit nonces) and ChaCha20-Poly1305 (RFC 8439). Tags are 16 bytes, appended to the ciphertext. The key material is in secret storage; per-message state is in locals.
Structs
AeadSource
pub struct AeadA key ready for seal / open.
Sourcepub fn new<B: AsBytes>(§alg: AeadAlgorithm, key: B) throws (ValueError) -> Aead A cipher for
algkeyed bykey. ThrowsValueErrorwhen the key is not the algorithm's key length.
Sourcepub const fn algorithm(§self) -> AeadAlgorithm The cipher this key is for.
Overwrite the key material with zeros now (every copy shares it);
sealandopenare meaningless afterwards.
Sourcepub fn seal<N: AsBytes, A: AsBytes, P: AsBytes>(§self, nonce: N, aad: A, plaintext: P) throws (ValueError) -> List<u8> plaintextencrypted, then the tag.
Sourcepub fn open<N: AsBytes, A: AsBytes, C: AsBytes>(§self, nonce: N, aad: A, ciphertext_and_tag: C) throws (ValueError) -> List<u8> | none The plaintext, or
nonewhen the tag does not match (nothing is decrypted then).
Enums
AeadAlgorithmSource
pub enum AeadAlgorithmThe AEAD ciphers Aead implements.
The key length in bytes: 16 for AES-128-GCM, else 32.
The nonce length in bytes: 12.
The tag length in bytes: 16.