#constant-time #input

no-std constant_time_eq

Compares two equal-sized byte strings in constant time

17 releases

Uses new Rust 2024

0.4.2 Mar 15, 2025
0.4.0 Feb 22, 2025
0.3.1 Aug 27, 2024
0.3.0 Jun 17, 2023
0.1.0 May 22, 2015

#18 in Cryptography

Download history 1332558/week @ 2024-12-09 992650/week @ 2024-12-16 457887/week @ 2024-12-23 586674/week @ 2024-12-30 1087808/week @ 2025-01-06 1273225/week @ 2025-01-13 1119355/week @ 2025-01-20 1185404/week @ 2025-01-27 1310716/week @ 2025-02-03 1438289/week @ 2025-02-10 1485004/week @ 2025-02-17 1380301/week @ 2025-02-24 1740043/week @ 2025-03-03 1599382/week @ 2025-03-10 1346999/week @ 2025-03-17 1265069/week @ 2025-03-24

6,018,551 downloads per month
Used in 6,193 crates (69 directly)

CC0-1.0 OR MIT-0 OR Apache-2.0

47KB
810 lines

Compares two equal-sized byte strings in constant time.

Inspired by the Linux kernel's crypto_memneq.

Licensed under either of

  • Apache License, Version 2.0 (LICENSE-APACHE)
  • MIT No Attribution License (LICENSE-MIT0)
  • CC0 1.0 Universal (LICENSE-CC0)

at your option.


lib.rs:

Compares two equal-sized byte strings in constant time.

The time of the comparison does not depend on:

  • The contents of the inputs;
  • The position of the difference(s) between the inputs.

The time of the comparison can depend on:

  • The memory addresses of the inputs;
  • The length of the inputs.

No runtime deps