Function rust_sodium::crypto::verify::verify_16 [] [src]

pub fn verify_16(x: &[u8; 16], y: &[u8; 16]) -> bool

verify_16() returns true if x[0], x[1], ..., x[15] are the same as y[0], y[1], ..., y[15]. Otherwise it returns false.

This function is safe to use for secrets x[0], x[1], ..., x[15], y[0], y[1], ..., y[15]. The time taken by verify_16 is independent of the contents of x[0], x[1], ..., x[15], y[0], y[1], ..., y[15]. In contrast, the standard C comparison function memcmp(x,y,16) takes time that depends on the longest matching prefix of x and y, often allowing easy timing attacks.