Function sodiumoxide::crypto::verify::verify_32
[−]
[src]
pub fn verify_32(x: &[u8; 32], y: &[u8; 32]) -> bool
verify_32()
returns true if x[0]
, x[1]
, ..., x[31]
are the
same as y[0]
, y[1]
, ..., y[31]
. Otherwise it returns false
.
This function is safe to use for secrets x[0]
, x[1]
, ..., x[31]
,
y[0]
, y[1]
, ..., y[31]
. The time taken by verify_32
is independent
of the contents of x[0]
, x[1]
, ..., x[31]
, y[0]
, y[1]
, ..., y[31]
.
In contrast, the standard C comparison function memcmp(x,y,32)
takes time
that depends on the longest matching prefix of x
and y
, often allowing easy
timing attacks.