Skip to content
Lesson 6 of 8

Step 1 of 5 · Reading · ~1 min

Read

Verification & Storage

Constant-Time Verification

DO NOT use plain == to compare hashes:

python

== returns early on the first byte mismatch. Attacker measures response times to deduce hash bytes ONE AT A TIME.

Use constant-time comparison:

python

Same concept: compare every byte, accumulate result via XOR + OR, return at end.

Side channels are real:

  • 2014: Lucky 13 attack on TLS via timing
  • 2018: Spectre/Meltdown via cache timing
  • 2020: Microarchitectural data sampling

For password comparison: ALWAYS use constant-time.

For full bcrypt/argon2 verify, the library handles this internally. Just call bcrypt.checkpw(input, stored).

Up nextRehash on LoginVerification & Storage

Discussion

Ask a question, share an insight, or help someone who’s stuck.

Sign in to post a comment or reply.

Loading…