XU XUv0.13.1
中文

#crypto/chacha20poly1305

import: #crypto/chacha20poly1305

counts: 1 functions, 2 methods, 1 types, 3 constants, 0 method sets

`.org/x/crypto/chacha20poly1305`: ChaCha20-Poly1305 AEAD per RFC 8439. Key is 32 bytes, Nonce is 12 bytes, Tag is 16 bytes. XU-CT-CLASS: variable-time XU-CT-USE: fixed-shape-only

const KEY_SIZE

XuAPI
pub const KEY_SIZE = 32

Purpose

Constant KEY_SIZE, defining protocol or algorithm parameters.

const NONCE_SIZE

XuAPI
pub const NONCE_SIZE = 12

Purpose

Constant NONCE_SIZE, defining protocol or algorithm parameters.

const TAG_SIZE

XuAPI
pub const TAG_SIZE = 16

Purpose

Constant TAG_SIZE, defining protocol or algorithm parameters.

struct AEAD

XuAPI
pub struct AEAD {

}

Purpose

AEAD context or state structure.

Public fields

This type has no public fields.

new

XuAPI
pub fn new(key &string) AEAD

Purpose

Construct a new value of this type. Throws on failure; handle the error or propagate it to the caller.

Parameters

key &string
key (read-only borrow; caller keeps the original; type &string)

Returns

AEAD — a value of this type

(&AEAD) seal

XuAPI
pub fn (a &AEAD) seal(nonce &string, plaintext &string, additional_data &string) string

Purpose

seal encrypts and authenticates plaintext with additional data using nonce. Returns ciphertext with 16-byte authentication tag appended. Throws on failure; handle the error or propagate it to the caller.

Parameters

a &AEAD
The AEAD instance used by this call (borrow).
nonce &string
nonce (read-only borrow; caller keeps the original; type &string)
plaintext &string
plaintext (read-only borrow; caller keeps the original; type &string)
additional_data &string
additional_data (read-only borrow; caller keeps the original; type &string)

Returns

string — result string

(&AEAD) open

XuAPI
pub fn (a &AEAD) open(nonce &string, ciphertext_and_tag &string, additional_data &string) string

Purpose

open authenticates and decrypts ciphertext_and_tag using nonce and additional data. Throws on failure; handle the error or propagate it to the caller.

Parameters

a &AEAD
The AEAD instance used by this call (borrow).
nonce &string
nonce (read-only borrow; caller keeps the original; type &string)
ciphertext_and_tag &string
ciphertext_and_tag (read-only borrow; caller keeps the original; type &string)
additional_data &string
additional_data (read-only borrow; caller keeps the original; type &string)

Returns

string — result string