core/crypto/chacha20poly1305
chacha20poly1305
Types
1Constants
4IV_SIZE
IV_SIZE :: IV_SIZESourceIV_SIZE is the chacha20poly1305 IV size in bytes.
KEY_SIZE
KEY_SIZE :: KEY_SIZESourceKEY_SIZE is the chacha20poly1305 key size in bytes.
TAG_SIZE
TAG_SIZE :: TAG_SIZESourceTAG_SIZE is the chacha20poly1305 tag size in bytes.
XIV_SIZE
XIV_SIZE :: XIV_SIZESourceXIV_SIZE is the xchacha20poly1305 IV size in bytes.
Procedures
5init
init :: proc(ctx: ^Context, key: []u8, impl = chacha20.DEFAULT_IMPLEMENTATION)Sourceinit initializes a Context with the provided key, for AEAD_CHACHA20_POLY1305.
init_xchacha
init_xchacha :: proc(ctx: ^Context, key: []u8, impl = chacha20.DEFAULT_IMPLEMENTATION)Sourceinit_xchacha initializes a Context with the provided key, for AEAD_XChaCha20_Poly1305.
Note: While there are multiple definitions of XChaCha20-Poly1305 this sticks to the IETF draft and uses a 32-bit counter.
open
open :: proc(
ctx: ^Context,
dst: []u8,
iv: []u8,
aad: []u8,
ciphertext: []u8,
tag: []u8,
) -> (bool)Sourceopen authenticates the aad and ciphertext, and decrypts the ciphertext, with the provided Context, iv, and tag, and stores the output in dst, returning true if and only if (⟺) the authentication was successful. If authentication fails, the destination buffer will be zeroed.
dst and plaintext MUST alias exactly or not at all.
reset
reset :: proc(ctx: ^Context)Sourcereset sanitizes the Context. The Context must be re-initialized to be used again.
seal
seal :: proc(
ctx: ^Context,
dst: []u8,
tag: []u8,
iv: []u8,
aad: []u8,
plaintext: []u8,
)Sourceseal encrypts the plaintext and authenticates the aad and ciphertext, with the provided Context and iv, stores the output in dst and tag.
dst and plaintext MUST alias exactly or not at all.