package core:crypto/chacha20poly1305

⌘K
Ctrl+K
or
/

    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

    Index

    Types (1)
    Variables (0)

    This section is empty.

    Procedures (5)
    Procedure Groups (0)

    This section is empty.

    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

    IV_SIZE ¶

    IV_SIZE :: chacha20.IV_SIZE
     

    IV_SIZE is the chacha20poly1305 IV size in bytes.

    KEY_SIZE ¶

    KEY_SIZE :: chacha20.KEY_SIZE
     

    KEY_SIZE is the chacha20poly1305 key size in bytes.

    TAG_SIZE ¶

    TAG_SIZE :: poly1305.TAG_SIZE
     

    TAG_SIZE is the chacha20poly1305 tag size in bytes.

    XIV_SIZE ¶

    XIV_SIZE :: chacha20.XIV_SIZE
     

    XIV_SIZE is the xchacha20poly1305 IV size in bytes.

    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 :: proc(
    	ctx:                      ^Context, 
    	dst, iv, aad, ciphertext, 
    	tag:                      []u8, 
    ) -> bool {…}
     

    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 :: proc(
    	ctx:               ^Context, 
    	dst, tag, iv, aad, 
    	plaintext:         []u8, 
    ) {…}
     

    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-12 (vendor "odin") Windows_amd64 @ 2024-12-17 21:11:00.936125300 +0000 UTC