package core:crypto/chacha20

⌘K
Ctrl+K
or
/

    Overview

    package chacha20 implements the ChaCha20 and XChaCha20 stream ciphers.

    See: https://datatracker.ietf.org/doc/html/rfc8439 https://datatracker.ietf.org/doc/draft-irtf-cfrg-xchacha/03/

    Index

    Types (1)
    Variables (0)

    This section is empty.

    Procedure Groups (0)

    This section is empty.

    Types

    Context ¶

    Context :: struct {
    	_s:              [16]u32,
    	_buffer:         [64]u8,
    	_off:            int,
    	_is_ietf_flavor: bool,
    	_is_initialized: bool,
    }
     

    Context is a ChaCha20 or XChaCha20 instance.

    Related Procedures With Parameters

    Constants

    KEY_SIZE ¶

    KEY_SIZE :: 32
     

    KEY_SIZE is the (X)ChaCha20 key size in bytes.

    NONCE_SIZE ¶

    NONCE_SIZE :: 12
     

    NONCE_SIZE is the ChaCha20 nonce size in bytes.

    XNONCE_SIZE ¶

    XNONCE_SIZE :: 24
     

    XNONCE_SIZE is the XChaCha20 nonce size in bytes.

    Variables

    This section is empty.

    Procedures

    init ¶

    init :: proc(ctx: ^Context, key, nonce: []u8) {…}
     

    init inititializes a Context for ChaCha20 or XChaCha20 with the provided key and nonce.

    keystream_bytes ¶

    keystream_bytes :: proc(ctx: ^Context, dst: []u8) {…}
     

    keystream_bytes fills dst with the raw (X)ChaCha20 keystream output.

    reset ¶

    reset :: proc(ctx: ^Context) {…}
     

    reset sanitizes the Context. The Context must be re-initialized to be used again.

    seek ¶

    seek :: proc(ctx: ^Context, block_nr: u64) {…}
     

    seek seeks the (X)ChaCha20 stream counter to the specified block.

    xor_bytes ¶

    xor_bytes :: proc(ctx: ^Context, dst, src: []u8) {…}
     

    xor_bytes XORs each byte in src with bytes taken from the (X)ChaCha20 keystream, and writes the resulting output to dst. Dst and src MUST alias exactly or not at all.

    Procedure Groups

    This section is empty.

    Source Files

    Generation Information

    Generated with odin version dev-2024-04 (vendor "odin") Windows_amd64 @ 2024-04-23 21:09:30.020441600 +0000 UTC