← All repos

eqaf

Constant time equal function to avoid timing attacks in OCaml

Browse cluster: OCaml Systems and Utilities
203commits
11contributors
4languages

Tech stack & purpose

Eqaf is an OCaml library that implements constant-time algorithms to prevent timing-based side-channel attacks, with the `Eqaf.equal` function for string comparison as its primary offering. The library is built only with the OCaml standard library and provides additional constant-time implementations including integer comparison functions (`compare_be`, `compare_le`), array search operations (`exists_uint8`, `find_uint8`), arithmetic operations (`divmod`), and encoding functions (`hex_of_string`, `string_of_hex`, `ascii_of_int32`), along with low-level primitives for building custom constant-time code. The project includes a benchmark tool called `check` that uses linear regression and statistical analysis to verify constant-time properties by measuring execution time across varying input sizes and comparing results against standard library implementations. Eqaf addresses the problem domain of cryptographic and security-sensitive applications where short-circuiting comparisons can leak information about operand values to attackers measuring execution time, such as in password or hash verification scenarios.

Community & reference links

Languages

OCaml
95.5%
C
4.3%
Standard ML
0.2%
Makefile
0.1%

Contributors