core/crypto

crypto

Constants

2

Procedures

6

compare_constant_time

compare_constant_time :: proc(a: []u8, b: []u8) -> (int)Source

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.

rand_bytes

rand_bytes :: proc(dst: []u8)Source

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.

zero_explicit

zero_explicit :: proc(data: rawptr, len: int) -> (rawptr)Source

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.

Reference search

Find anything

Documentation preferences

Settings

System theme variants

Used only while Theme is set to System.