Applied Cryptography for Developers Module 4
Hash functions and their uses interview questions
Interview questions on hash functions and their uses: short warm-ups, then what each harder question tests, the first step of a good answer and its follow-ups.
Warm-up questions
Short questions with short answers, each answered in full.
-
Fresher to mid
How do second-preimage resistance and collision resistance differ?
Answered in the lesson Hash functions: SHA-2, SHA-3 and BLAKE2
-
Fresher to mid
How do integrity and authenticity differ, and which tools give each?
Answered in the lesson Integrity checks, SRI and canonical hashing
-
Fresher to mid
What does a Merkle inclusion proof prove, and what does it not?
Questions with model answers
What each question tests, the first step of a good answer and the follow-ups to expect.
-
Senior to staff
Your company signs firmware images by computing their SHA-1 digest and signing it with RSA; 200,000 devices in the field verify those signatures. Several partner teams submit images for signing. Assess the risk and plan the move to a safe hash without bricking devices.
- What it tests
- Seeing a collision threat in a signing workflow, weighing who controls the inputs, and planning a staged migration across devices that verify signatures and cannot all be updated at once.
- First step
- Ask who chooses what gets signed. Partner teams submit the images, so anyone among them could prepare two images with one SHA-1 digest, have the harmless one signed, and ship the other with the same signature. Signing is a collision use, the one property SHA-1 has publicly lost.
- Follow-ups
-
- Some devices can never be updated. What do you do about them?
- Is switching the hash enough, or should the signature scheme change too?
- How do you check whether old signatures were abused?
From the lesson Hash functions: SHA-2, SHA-3 and BLAKE2
Model answer, Pro. Model answers open with any pass; prices are in the notice on this page.Opening the model answers with your pass…
Model answers open with any MySmartCoPilot pass.
- Pro pass · 1 week₹79$2.99
- 30 days₹179$5.99
- 1 year₹1,699$45
One payment; a pass never renews. The price shown is the total you pay: no fees or charges are added at checkout.
Passes can’t be bought right now, so the model answers can’t be opened at the moment. If you have a pass, enter your licence key.
It also opens every other in-depth part in Learn and every Pro tool. Sales are final, except where the law gives you a right to withdraw, for example in the EU and the UK (refund policy).
In the answer:
- Model answer
- Follow-up answers
- Common mistakes
- Rubric
- Variants
- about 3 minutes
-
Fresher to senior
A design proposes document IDs made of the first 64 bits of the SHA-256 of each document's content, for up to a billion documents. Evaluate the chance of a clash, consider users who choose their documents, and recommend a length.
- What it tests
- Applying the birthday bound to a truncated hash, separating accidental clashes from chosen ones, and tying a length to a requirement such as ASVS 11.4.3.
- First step
- Use the birthday bound for accidents: n²/2^(b+1) with n = 10⁹ and b = 64 gives the chance of any clash. Then ask the second question separately: how much work does someone need to make two documents clash on purpose, when the collision search for 64 bits takes about 2³² hashes?
- Follow-ups
-
- Does keeping the first or the last 64 bits matter?
- What would 128 bits give, by accident and on purpose?
- Could a version 4 UUID be the ID instead?
From the lesson Hash functions: SHA-2, SHA-3 and BLAKE2
Model answer, Pro.In the answer:
- Model answer
- Follow-up answers
- Common mistakes
- Rubric
- Variants
- about 2 minutes
-
Mid to senior
Your checkout page loads a script from a partner's content delivery network. How do you protect the page if that network is ever compromised, what breaks when the partner ships a new version, and what do you do about it?
- What it tests
- Using Subresource Integrity correctly, understanding its failure mode and CORS needs, and planning versioned updates or alternatives for scripts that change.
- First step
- Pin the exact bytes: give the script tag an integrity value of the form sha384-…, with crossorigin="anonymous" so the browser can check it. Then ask what the pin does on the day the file at that address changes: the browser refuses it, which is the protection, and also a coming outage if nobody plans for it.
- Follow-ups
-
- The partner says its script changes several times a week. What then?
- How does the page behave for users while a mismatch lasts?
- Should the integrity value list two digests, and when?
From the lesson Integrity checks, SRI and canonical hashing
Model answer, Pro.In the answer:
- Model answer
- Follow-up answers
- Common mistakes
- Rubric
- Variants
- about 3 minutes
-
Mid to senior
Service A signs JSON payloads and service B verifies them, and about 3 % of valid payloads fail verification after a library upgrade in B. Find the cause and fix the design so that it cannot come back.
- What it tests
- Recognising that signatures cover exact bytes, finding re-serialisation differences, and choosing between signing raw bytes and a canonical form such as RFC 8785.
- First step
- Capture one failing payload as the bytes A signed and the bytes B verified, and compare them. Key order, spacing, number spellings such as 500.00 and 5e2, and escaping of non-ASCII characters all change the bytes without changing the data, and a library upgrade is a typical moment for such a change.
- Follow-ups
-
- Why does it fail for only 3 % of payloads?
- Should B verify the bytes it received or the JSON it parsed?
- When is a canonical form the better design?
From the lesson Integrity checks, SRI and canonical hashing
Model answer, Pro.In the answer:
- Model answer
- Follow-up answers
- Common mistakes
- Rubric
- Variants
- about 2 minutes
-
Senior to staff
Design a tamper-evident audit log for an internal administration system, so that not even its own operators can remove or edit an entry without being noticed. What do you store, what do you publish, who checks what, and how often?
- What it tests
- Applying Merkle trees, signed tree heads, inclusion and consistency proofs to a real system, and seeing that detection depends on parties outside the log keeping old heads.
- First step
- Separate what the log does from what makes cheating visible. A Merkle tree over the entries, hashed as RFC 9162 defines it, gives a root per size; the protection comes from publishing signed tree heads somewhere the operators cannot rewrite, and from checkers that demand consistency proofs between heads.
- Follow-ups
-
- Where do the tree heads go, concretely?
- An investigator wants to prove one entry existed at a given time. What do they need?
- What does this design not protect against?
From the lesson Merkle trees and transparency logs
Model answer, Pro.In the answer:
- Model answer
- Follow-up answers
- Common mistakes
- Rubric
- Variants
- about 3 minutes
-
Mid to senior
Your monitoring of Certificate Transparency logs reports a certificate for login.example.com, one of your domains, that nobody on your team requested. What do you do, in order, and what do you change afterwards?
- What it tests
- Turning CT detection into a response: verification, revocation through the issuing authority, finding how domain validation was passed, and prevention with CAA records and monitoring.
- First step
- Confirm before acting: read the logged certificate's issuer, names and validity, and check it against your own records and every team or vendor that may request certificates for the domain. If none did, treat it as misissuance or a compromise of how the domain is validated, and start the response at once.
- Follow-ups
-
- How do you get the certificate revoked?
- What could have let someone pass the authority's domain validation?
- Which DNS record limits the authorities that may issue for your domain?
From the lesson Merkle trees and transparency logs
Model answer, Pro.In the answer:
- Model answer
- Follow-up answers
- Common mistakes
- Rubric
- Variants
- about 2 minutes
All Applied Cryptography for Developers interview questions · The Applied Cryptography for Developers track