Skip to content

Interview question · Cryptography, PKI & TLS

Why is HMAC built the way it is, rather than simply hashing the key followed by the message?

A classic that tests whether you know how hash functions work inside. The scored answer explains length extension, the nested HMAC construction, and how to verify a MAC safely.

mediumNewPreparation tags: Google, Amazon, MicrosoftUpdated Nov 2026

A classic that tests whether you know how hash functions work inside. The scored answer explains length extension, the nested HMAC construction, and how to verify a MAC safely.

Make your first attempt

What would you say before reading the answer?

  1. 01 State the assumptions your answer depends on.
  2. 02 Explain the mechanism and choose a control.
  3. 03 Name a condition that would change your decision.

The worked answer includes an approach, scoring criteria and follow-up questions. Compare the reasoning with your own.

10 answers per topic instead of 5, plus saved progress and bookmarks · costs nothingor unlock all 529 remaining answers · $25

Every worked answer in all 17 topics, every lesson in every course, the full concept curriculum, the complete practice-test bank, and the downloadable security field guides.

6 months · One payment · No auto-renewal

What if · the follow-ups in this answer

The answer works through 6 follow-ups like an interviewer would

A developer builds a message authentication code for API requests as SHA-256(key + message) and asks why a reviewer flagged it.

  1. What is a length-extension attack?
  2. Why does that break this MAC?
  3. How does HMAC fix it?
  4. Are there other options?
  5. What else matters when verifying tags?
  6. What would you tell the developer?

Each rung has a nudge, a model answer, the principle that carries over and the weak answer to avoid. Premium opens every answer and ladder.

UP NEXT ON YOUR JOURNEY
DISCUSSION · 0

No comments yet. Share a correction or a different way to answer it.