A developer is choosing how to apply AES to messages of many blocks. Match each mode of operation to how it behaves.
Choose the match for each entry. Every match has to be right.
A block cipher such as AES encrypts one small block of data. A mode of operation is the rule for using it on a whole file or message, and the choice of mode can decide whether the result is safe. It is like a first-class lock that can be fitted to a door well or badly. No background beyond symmetric encryption is assumed. Most real failures of encryption are failures of use, so a security professional must be able to recognise them.
An illustrative example
A payroll bureau encrypts its monthly salary file with AES and a 256-bit key before sending it to the bank. Each employee's record fills exactly one block. The cipher is the strongest in general use, and nobody at the bureau has lost the key.
A clerk at the bank, who cannot decrypt the file, notices that the same block of ciphertext turns up again and again. Staff on the same salary have identical encrypted records. He also finds that he can cut a director's encrypted record out and paste it over his own, and the file still decrypts without complaint.
The cipher was never broken. What went wrong?
AES turns one block of 128 bits, which is 16 characters of text, into one block of . Almost every real message is longer than that.
A mode of operation is the rule for applying a block to a message of many blocks. The cipher and the key stay the same. The mode decides what goes into the cipher for each block and how the blocks depend on one another.
Two messages with the same cipher and the same key, in two different modes, can differ completely in how safe they are.
Electronic Codebook (ECB) is the simplest mode. Each block is encrypted on its own, with the same key and nothing else.
Its fault follows directly: two blocks that are the same give two ciphertext blocks that are the same. The content stays hidden, but the pattern of repeats does not. An image encrypted in ECB still shows its outline, and a file of records shows which records match.
An attacker can also move, repeat or swap whole blocks, and the result still cleanly. That is what the bank clerk found.
A mode of operation decides how a block cipher handles a message longer than one block. The same four plaintext blocks, A B A C, with the first and third equal, go through two modes under the same key.
ECB is tolerable only for encrypting one block of random data. For messages and files it is the wrong choice, and keys are protected with a dedicated key-wrap method, which encrypts a key and detects any change to it, not ECB.
Common misconception
“A longer key would have protected the payroll file.”
The key was never the weakness. ECB with a 256-bit key leaks repeats exactly as ECB with a 128-bit key does. The repair is a different mode.
The other modes break the link between equal plaintext and equal ciphertext. Cipher Block Chaining (CBC) combines each plaintext block with the previous ciphertext block before encrypting it, so every block depends on all the blocks before it.
Cipher Feedback (CFB), Output Feedback (OFB) and Counter (CTR) use the block cipher to generate a keystream and combine it with the plaintext. They make a block cipher behave as a .
| Mode | How it works | Starting value | One damaged ciphertext bit |
|---|---|---|---|
| ECB | Each block encrypted on its own | None | Ruins that block only |
| CBC | Each block mixed with the previous ciphertext block, then encrypted | , unpredictable | Ruins that block and flips the same bit in the next |
| CFB | Previous ciphertext is encrypted to make keystream | IV, unpredictable | Flips that bit and ruins about one following block |
| OFB | The cipher's own output is fed back to make keystream | IV, never reused | Flips that bit only |
| CTR | A counter is encrypted to make keystream | Counter, never reused | Flips that bit only |
| GCM | Counter mode with an authentication tag | IV, never reused | Detected: the message is rejected |
| CCM | Counter mode with a CBC-based authentication code | Nonce, never reused | Detected: the message is rejected |
Speed differs too. ECB and CTR can encrypt many blocks at once, in parallel, and CTR can decrypt any single block without the rest. CBC must encrypt in order, because each block waits for the one before.
An initialisation vector (IV) is a starting value fed into the mode along with the first block. It makes the same message, under the same key, encrypt differently each time. It is not secret, and it normally travels with the ciphertext.
A nonce is a value that is used only once. The modes that generate a keystream need their IV or counter to be a nonce: it must never repeat under the same key.
A third value with a similar job, the salt, is added to a password before it is hashed. All three exist to make equal inputs give unequal outputs.
Common misconception
“The IV must be kept as secret as the key.”
The IV is public. What matters is that it is unpredictable, or never repeated, according to the mode. Only the key is secret.
The five older modes give only. An attacker who cannot read a message can still change it. In CTR mode, flipping one bit of ciphertext flips the same bit of plaintext, so a payment of 1,000 pounds could be altered without the key.
Authenticated encryption encrypts the message and also produces a short check value, called a tag, that depends on the key and on every bit of the ciphertext. The recipient recalculates the tag before using the plaintext. A message that has been altered fails the check.
Galois/Counter Mode (GCM) and Counter with CBC-MAC (CCM) are the two standard authenticated modes. Both are built on counter mode, and both give confidentiality and together. Current versions of the protocol that protects web traffic allow only authenticated modes.
An implementation attack exploits the way a cryptosystem has been built, configured or used. It does not find a weakness in the mathematics of the algorithm. The payroll bureau's AES was sound, and its file was open to attack.
A second family of implementation attacks works on the physical device: measuring its timing or power use, or disturbing it to cause errors.
The defences are matters of engineering practice. Use well-tested libraries and standard modes. Prefer cryptographic modules that an independent laboratory has validated against a standard such as FIPS 140-3, the United States standard for such modules. Review and test the code, and keep keys out of it.
If the question says the algorithm is strong and the system still failed, look at the mode, the IV, the random numbers and where the key was kept.
An application security lead at a bank reviews a mobile app before release. The app encrypts each stored transaction record with AES and a 256-bit key in counter mode. To keep the code simple, the developers start the counter from the same fixed value for every record. The key is created on the phone the first time the app runs and is used for the life of the app. A tester has reported that the cipher itself is sound.
Which is the BEST description of the weakness that most needs fixing?
Answer: A. An implementation flaw: the counter repeats under one key, so every record is encrypted with the same keystream
4 questions on this unit, easiest first. Confirm an answer to see the reasoning for it, then the right answer, the other options and the rule to reuse. Your answers are kept in this browser and feed readiness and review.
These questions are drafts that no named reviewer has approved yet.
Question 1 of 4
A developer is choosing how to apply AES to messages of many blocks. Match each mode of operation to how it behaves.
Choose the match for each entry. Every match has to be right.
An attack on the way a cryptosystem is built, configured or used, which leaves the algorithm's mathematics unbroken. Examples: ECB used for files, a repeated IV or nonce, predictable random numbers, a key left in code, no integrity check. Defences: tested libraries, standard modes, modules validated to FIPS 140-3, code review and testing.
A mode of operation is the rule for applying a block cipher to a message of many blocks. The cipher and the key stay the same; the mode decides what goes into the cipher for each block and how the blocks depend on one another. Two messages under the same cipher and key, in different modes, can differ completely in how safe they are.
Each block is encrypted on its own, so two equal plaintext blocks give two equal ciphertext blocks. The pattern of repeats shows, and whole blocks can be moved, repeated or swapped and still decrypt cleanly. A longer key does not fix it; the repair is a different mode.
CBC combines each plaintext block with the previous ciphertext block before encrypting it, so every block depends on those before it. CFB, OFB and CTR use the block cipher to generate a keystream combined with the plaintext, making it behave as a stream cipher. ECB and CTR can encrypt many blocks in parallel; CBC must encrypt in order.
The IV is not secret and normally travels with the ciphertext. CBC and CFB need an IV an attacker cannot predict in advance. OFB, CTR and GCM need a starting value never used twice with one key, because a reused value repeats the keystream and exposes the plaintexts.
It encrypts the message and also produces a tag that depends on the key and every bit of the ciphertext; the recipient recalculates it, and an altered message fails the check. Galois/Counter Mode (GCM) and Counter with CBC-MAC (CCM) are the two standard authenticated modes, both built on counter mode.