docs

您正在閱讀 v0.1.2 的文件。Nabi 0.1.2 已停止支援。 最新版本:v0.1.3 →

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 Aead

A key ready for seal / open.

  • pub fn new<B: AsBytes>(alg: AeadAlgorithm, key: B) throws (ValueError) -> Aead§

    Source

    A cipher for alg keyed by key. Throws ValueError when the key is not the algorithm's key length.

  • pub const fn algorithm(self) -> AeadAlgorithm§

    Source

    The cipher this key is for.

  • pub fn wipe(self)§

    Source

    Overwrite the key material with zeros now (every copy shares it); seal and open are meaningless afterwards.

  • pub fn seal<N: AsBytes, A: AsBytes, P: AsBytes>(self, nonce: N, aad: A, plaintext: P) throws (ValueError) -> List<u8>§

    Source

    plaintext encrypted, then the tag.

  • pub fn open<N: AsBytes, A: AsBytes, C: AsBytes>(self, nonce: N, aad: A, ciphertext_and_tag: C) throws (ValueError) -> List<u8> | none§

    Source

    The plaintext, or none when the tag does not match (nothing is decrypted then).

Trait implementations 2

Enums

AeadAlgorithmSource

pub enum AeadAlgorithm

The AEAD ciphers Aead implements.

  • Aes128Gcm§

    Source
  • Aes256Gcm§

    Source
  • ChaCha20Poly1305§

    Source
  • pub const fn key_len(self) -> usize§

    Source

    The key length in bytes: 16 for AES-128-GCM, else 32.

  • pub const fn nonce_len(self) -> usize§

    Source

    The nonce length in bytes: 12.

  • pub const fn tag_len(self) -> usize§

    Source

    The tag length in bytes: 16.