A selection of cryptography algorithms and useful helper routines.

Collection Info

View Source
Collection
core
Path
crypto
Entries
10

Source Files

Constants

2

COMPACT_IMPLS #

Source
COMPACT_IMPLS :: #config(ODIN_CRYPTO_COMPACT, false)

Omit large precomputed tables, trading off performance for size.

HAS_RAND_BYTES #

Source
HAS_RAND_BYTES :: runtime.HAS_RAND_BYTES

HAS_RAND_BYTES is true if and only if (⟺) the runtime provides a cryptographic entropy source.

Config Values

1

COMPACT_IMPLS #

Source
COMPACT_IMPLS :: #config(ODIN_CRYPTO_COMPACT, false)

Omit large precomputed tables, trading off performance for size.

Procedures

7

compare_byte_ptrs_constant_time #

Source
@(optimization_mode="none")
compare_byte_ptrs_constant_time :: proc "contextless" (a, b: ^u8, n: int) -> int {…}

compare_byte_ptrs_constant_time returns 1 if and only if (⟺) the bytes pointed to by a and b are equal, 0 otherwise. The execution time of this routine is constant regardless of the contents of the memory being compared.

compare_constant_time #

Source
compare_constant_time :: proc "contextless" (a, b: []u8) -> int {…}

compare_constant_time returns 1 if and only if (⟺) a and b are equal, 0 otherwise. The execution time of this routine is constant regardless of the contents of the slices being compared, as long as the length of the slices is equal. If and only if (⟺) the length of the two slices is diferent, it will early-return 0.

is_zero_constant_time #

Source
is_zero_constant_time :: proc "contextless" (b: []u8) -> int {…}

is_zero_constant_time returns 1 if and only if (⟺) b is all 0s, 0 otherwise.

rand_bytes #

Source
rand_bytes :: proc(dst: []u8) {…}

rand_bytes fills the dst buffer with cryptographic entropy taken from the system entropy source. This routine will block if the system entropy source is not ready yet. All system entropy source failures are treated as catastrophic, resulting in a panic. Support for the system entropy source can be checked with the `HAS_RAND_BYTES` boolean constant.

random_generator #

Source
random_generator :: proc() -> Random_Generator {…}

random_generator returns a `runtime.Random_Generator` backed by the system entropy source. Support for the system entropy source can be checked with the `HAS_RAND_BYTES` boolean constant.

set #

Source
set :: proc "contextless" (data: rawptr, value: u8, len: int) -> rawptr {…}

Set each byte of a memory range to a specific value. This procedure copies value specified by the `value` parameter into each of the `len` bytes of a memory range, located at address `data`. This procedure returns the pointer to `data`.

zero_explicit #

Source
zero_explicit :: proc "contextless" (data: rawptr, len: int) -> rawptr {…}

Set each byte of a memory range to zero. This procedure copies the value `0` into the `len` bytes of a memory range, starting at address `data`. This procedure returns the pointer to `data`. Unlike the `zero()` procedure, which can be optimized away or reordered by the compiler under certain circumstances, `zero_explicit()` procedure can not be optimized away or reordered with other memory access operations, and the compiler assumes volatile semantics of the memory.