package core:crypto/chacha20poly1305
Overview
package chacha20poly1305 implements the AEAD_CHACHA20_POLY1305 and AEAD_XChaCha20_Poly1305 Authenticated Encryption with Additional Data algorithms.
See: https://www.rfc-editor.org/rfc/rfc8439 https://datatracker.ietf.org/doc/html/draft-arciszewski-xchacha-03
Types
Context ¶
Context :: struct { _key: [32]u8, _impl: chacha20.Implementation, _is_xchacha: bool, _is_initialized: bool, }
Context is a keyed (X)Chacha20Poly1305 instance.
Related Procedures With Parameters
Constants
Variables
This section is empty.
Procedures
init ¶
init :: proc(ctx: ^Context, key: []u8, impl: chacha20.Implementation = chacha20.DEFAULT_IMPLEMENTATION) {…}
init initializes a Context with the provided key, for AEAD_CHACHA20_POLY1305.
init_xchacha ¶
init_xchacha :: proc(ctx: ^Context, key: []u8, impl: chacha20.Implementation = chacha20.DEFAULT_IMPLEMENTATION) {…}
init_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 authenticates the aad and ciphertext, and decrypts the ciphertext, with the provided Context, iv, and tag, and stores the output in dst, returning true iff 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 "contextless" (ctx: ^Context) {…}
reset sanitizes the Context. The Context must be re-initialized to be used again.
seal ¶
seal 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.
Procedure Groups
This section is empty.
Source Files
Generation Information
Generated with odin version dev-2024-11 (vendor "odin") Windows_amd64 @ 2024-11-16 21:10:09.812441100 +0000 UTC