Skip to main content

constant_time_eq

Function constant_time_eq 

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

Constant-time byte comparison to prevent timing attacks.

The length check leaks whether the two slices are the same length, but the content comparison always examines every byte regardless of where (or whether) a mismatch occurs.