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

    Variables (0)

    This section is empty.

    Procedure Groups (0)

    This section is empty.

    Types

    Context ¶

    Context :: struct {
    	_state: _chacha20.Context,
    	_impl:  Implementation,
    }
     

    Context is a ChaCha20 or XChaCha20 instance.

    Related Procedures With Parameters

    Implementation ¶

    Implementation :: enum int {
    	Portable, 
    	Simd128, 
    	Simd256, 
    }
     

    Implementation is a ChaCha20 implementation. Most callers will not need to use this as the package will automatically select the most performant implementation available.

    Related Procedures With Parameters
    Related Constants

    Constants

    DEFAULT_IMPLEMENTATION ¶

    DEFAULT_IMPLEMENTATION :: Implementation.Simd256
     

    DEFAULT_IMPLEMENTATION is the implementation that will be used by default if possible.

    IV_SIZE ¶

    IV_SIZE :: _chacha20.IV_SIZE
     

    IV_SIZE is the ChaCha20 IV size in bytes.

    KEY_SIZE ¶

    KEY_SIZE :: _chacha20.KEY_SIZE
     

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

    XIV_SIZE ¶

    XIV_SIZE :: _chacha20.XIV_SIZE
     

    XIV_SIZE is the XChaCha20 IV size in bytes.

    Variables

    This section is empty.

    Procedures

    init ¶

    init :: proc(ctx: ^Context, key, iv: []u8, impl: Implementation = DEFAULT_IMPLEMENTATION) {…}
     

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

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