Tutorial 5: Cryptographic Design Failure Modes

Unit 2 · Cryptography and key management

Objectives

Strong algorithms can fail through weak random number generation, repeated nonces, unauthenticated ciphertext, predictable keys, incorrect certificate validation, or leaked error details. Cryptography should be specified with a library-supported construction, key sizes, lifecycle, and test vectors.

Do not: encrypt(data, key) and trust the ciphertext blindly
Do: authenticatedEncrypt(data, key, uniqueNonce, associatedData)

Review cryptographic code with threat scenarios and misuse resistance in mind. Tests should cover tampering, wrong keys, wrong associated data, replay, rotation, and unavailable key services. Avoid “home-grown” protocols assembled from primitives without expert review.

Exercises

  1. Diagnose four cryptographic anti-patterns.
  2. Write tests for ciphertext tampering and replay.
  3. Create a design review checklist.

Self-check

  1. Why is nonce reuse dangerous?
  2. What does authenticated encryption detect?
  3. Why use reviewed libraries?

Self-Check Quiz

1. Can encryption alone detect tampering?

AnswerNot reliably. Use authenticated encryption or a separately sound integrity mechanism.

2. What is misuse resistance?

AnswerDesign and APIs that reduce the chance ordinary implementation mistakes silently remove security properties.

Homework

  1. Perform a cryptographic review of a fictional document service.
  2. List threats, assumptions, controls, and tests.
  3. Explain one operational failure that defeats a sound algorithm.
Sample answerA sound review covers confidentiality, integrity, authenticity, replay, key compromise, rotation, randomness, nonce uniqueness, error handling, and access to keys. A sound AES-GCM choice can still fail if a nonce repeats or the key is committed in a repository.