Skip to main content

Module ct

Module ct 

Source
Expand description

Constant-time primitives for branchless cryptographic operations.

All functions in this module are designed to avoid secret-dependent control flow and secret-dependent memory accesses. Values pass through core::hint::black_box to inhibit LLVM optimizations that might otherwise reintroduce branches.

How far this is verified (release-assembly audit, dudect timing tests) is tracked in SECURITY.md.

Structs§

Choice
A constant-time boolean represented internally as 0u8 (false) or 1u8 (true).

Functions§

ct_eq_slice
Constant-time equality for two byte slices.
ct_eq_u8
Constant-time equality for two u8 values.
ct_select_array
Constant-time selection of fixed-size byte arrays, returning the selected array.
ct_select_array_into
Constant-time selection of fixed-size byte arrays directly into out.
ct_select_i16
Constant-time selection between two i16 values (used in lattice polynomial arithmetic).
ct_select_u8
Constant-time selection between two u8 values: returns if_true when choice is true, otherwise if_false.
ct_select_u16
Constant-time selection between two u16 values.