[−][src]Function orion::util::secure_cmp
#[must_use]pub fn secure_cmp(a: &[u8], b: &[u8]) -> Result<bool, UnknownCryptoError>
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:
a
andb
do not have the same length.a
is not equal tob
.
Example:
use orion::util; let mut mac = [0u8; 64]; assert!(util::secure_cmp(&mac, &[0u8; 64])?); util::secure_rand_bytes(&mut mac)?; assert!(util::secure_cmp(&mac, &[0u8; 64]).is_err());