std1.0.0-beta-7 SafeC docs

Module crypto::ct

#include <std/crypto/ct.h> source

constant-time helpers for cryptographic code.

Comparisons and selections whose running time doesn't depend on the (secret) bytes involved: no early exit, no branch on the data. Used by std's AEADs, RSA/ECDSA and TLS for tags, padding and key material. Freestanding-safe.

Functions

ct_eq1 if a[0..n) == b[0..n), looking at every byte.
ct_is_zero1 if every byte of a[0..n) is zero, looking at every byte.
ct_copy_ifdst[0..n) = bit ? src[0..n) : dst[0..n) ('bit' is 0 or 1), touching every byte either way.
ct_eq_u320xFFFFFFFF when a == b, 0 otherwise (no branch).