MCPcopy Create free account
hub / github.com/evilsocket/cake / constant_time_eq

Function constant_time_eq

cake-core/src/cake/sharding/auth.rs:40–48  ·  view source on GitHub ↗

Constant-time comparison of two byte slices.

(a: &[u8], b: &[u8])

Source from the content-addressed store, hash-verified

38
39/// Constant-time comparison of two byte slices.
40pub fn constant_time_eq(a: &[u8], b: &[u8]) -> bool {
41 if a.len() != b.len() {
42 return false;
43 }
44 a.iter()
45 .zip(b.iter())
46 .fold(0u8, |acc, (x, y)| acc | (x ^ y))
47 == 0
48}
49
50/// Master side of the mutual authentication.
51///

Callers 3

constant_time_eq_matchFunction · 0.85
authenticate_as_masterFunction · 0.85
authenticate_as_workerFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected