Common crypto mistakes

The algorithms are rarely the weak point. What breaks systems is how the pieces are combined: a value that must never repeat, a mode chosen for convenience, a hash used for a job it was never meant to do. This set covers the mistakes that keep turning up.

4 questions 1 task Read the lesson

Questions

Each one is marked as you go, and the explanation arrives straight after, which is the part worth reading.

4 questions, marked as you go.

1 Why is reusing a nonce under a stream cipher such as CTR so damaging?
2 What does ECB mode reveal that a chaining mode hides?
3 Why is a plain SHA-256 hash the wrong thing to store a password as?
4 Why must you check a message authentication tag before you decrypt?

Tasks

These need your own device. Run the command in Termux, then paste what it printed. The marking looks at what the output means, so spacing, version numbers and ordering do not matter. If you have not installed anything yet, the lesson covers the setup.

See ECB repeat a block and CBC break the pattern

This encrypts the same two identical blocks with ECB, then with CBC, and prints the ciphertext as hex bytes. Read the ECB pair and the CBC pair and compare them.

Run this in Termux On your own device. Nothing on this page executes it. The command runs in your terminal, and this box only reads what you paste back.

K=00112233445566778899aabbccddeeff; P="YELLOW SUBMARINEYELLOW SUBMARINE"; echo "ECB mode:"; printf '%s' "$P" | openssl enc -aes-128-ecb -K $K -nopad -nosalt | od -An -v -tx1 -w16; echo "CBC mode:"; printf '%s' "$P" | openssl enc -aes-128-cbc -K $K -iv 00000000000000000000000000000000 -nopad -nosalt | od -An -v -tx1 -w16
Marking your own work Both halves of this are checked in your browser, with no server involved, so nothing stops you from pasting output you did not run. The tasks are written so that the easiest way to pass one is to actually do it and read the result, which is the whole intention.

All sets Read the lesson