concept constant - time in category cryptography

appears as: Constt-Time, constt-time
Real-World Cryptography

This is an excerpt from Manning's book Real-World Cryptography.

When verifying an authentication tag, the comparison between the received authentication tag and the one you computed must be done in constant-time. This means the comparison should always take the same time (assuming the received one is of the correct size). If the time it takes to compare the two authentication tags is not constant-time, it is probably because it returns the moment the two tags differ. This usually gives enough information to enable attacks that can re-create a valid authentication tag byte-by-byte by measuring how long it took for the verification to finish. I explain this in the following comicstrip. We call these types of attacks timing attacks.

timing

Fortunately for us, cryptographic libraries implementing MACs also provide conveniant functions to verify an authentication tag in constant-time. If you’re wondering how this is done, here is how Golang implements hmac.Equal in constant-time code (taken from golang.org/src/crypto/subtle/constant_time.go?s=505:546#L2):