ct_eq

Function ct_eq 

Source
pub fn ct_eq(a: &[u8], b: &[u8]) -> bool
Expand description

Compare two byte slices in constant time, returning true iff they are equal.

The comparison time is proportional to the slice length and does not depend on the data values, preventing timing side-channel attacks.

Slices of different lengths return false immediately (without constant-time behaviour), since lengths are generally not considered secret. If you need to conceal the length, pad both inputs to the same size before calling.

Backed by CRYPTO_memcmp from OpenSSL.