constant_time_compare

Function constant_time_compare 

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

Perform constant-time comparison of byte arrays

This function provides protection against timing attacks by ensuring the comparison takes the same amount of time regardless of where the first difference occurs.

§Arguments

  • a - First byte array to compare
  • b - Second byte array to compare

§Returns

true if arrays are equal, false otherwise

§Security

Uses the subtle crate’s constant-time comparison to prevent timing side-channel attacks.