pub fn secure_cmp(a: &[u8], b: &[u8]) -> Result<(), UnknownCryptoError>Expand description
Compare two equal length slices in constant time.
§About:
Compare two equal length slices, in constant time, using the subtle crate.
§Parameters:
a: The first slice used in the comparison.b: The second slice used in the comparison.
§Errors:
An error will be returned if:
aandbdo not have the same length.ais not equal tob.
§Example:
use orion::util;
let mut rnd_bytes = [0u8; 64];
assert!(util::secure_cmp(&rnd_bytes, &[0u8; 64]).is_ok());
util::secure_rand_bytes(&mut rnd_bytes)?;
assert!(util::secure_cmp(&rnd_bytes, &[0u8; 64]).is_err());