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 side-channel attacks on token validation.

Returns true only when a and b are the same length and every byte matches. The comparison always examines every byte so that the execution time depends only on the length, never on where the first mismatch occurs.