Cybersecurity
06 Sep 2026
9 min read
Compare Secret Values with Constant-Time Functions
A verifier often ends with a simple question: does a value derived from this request match the value the system expects? That question appears when checking message authentication codes, signed-request authenticators, reset-token digests, and other security-sensitive values. Using an ordinary string or byte comparison can introduce a subtle problem. Some comparison routines stop as soon as they find the first difference. Their work can therefore depend on how much of the input matches. If an attacker can make many measurements under sufficiently stable conditions, that timing difference may reveal information about a secret-dependent value.