Symmetric Encryption: AES, Modes of Operation and Key Distribution

Symmetric encryption uses one key for both encryption and decryption. That single fact produces both its great advantage — it is fast, by orders of magnitude — and its central difficulty: everyone who needs to read the data needs the key, and getting the key to them safely is a harder problem than the encryption itself.

AES, and What Came Before

AES is the standard, with key sizes of 128, 192 and 256 bits and a fixed 128-bit block size. All three key sizes remain secure; 256-bit is chosen for long-lived data and where regulation requires it, not because 128-bit is broken.

The historical ciphers still appear as distractors. DES used a 56-bit key and is trivially brute-forced today. 3DES applied DES three times to extend the effective key length and is now deprecated, partly for weakness and partly because its 64-bit block size makes collisions practical on large data volumes. RC4, a stream cipher, is broken and removed from TLS. Blowfish and Twofish are secure but largely superseded.

Block Versus Stream

A block cipher encrypts fixed-size blocks and pads the final one to fit. A stream cipher generates a keystream and XORs it with the plaintext a bit or byte at a time, so the ciphertext is the same length as the plaintext.

Stream ciphers suit continuous data of unknown length and constrained devices. They carry one severe rule: never reuse a keystream. Encrypting two messages with the same key and nonce lets an attacker XOR the ciphertexts together and eliminate the keystream entirely. ChaCha20 is the modern choice where a stream cipher is wanted.

Modes of Operation

A block cipher alone only encrypts one block. The mode decides how to handle a message longer than that, and this is where real systems fail.

ECB (Electronic Codebook) encrypts each block independently. Identical plaintext blocks produce identical ciphertext blocks, so structure in the data survives encryption — the reason the famous encrypted-penguin image is still recognizably a penguin. ECB is never the right answer.

CBC (Cipher Block Chaining) XORs each block with the previous ciphertext block and uses a random initialization vector for the first. Identical plaintexts now encrypt differently. The IV must be random and unpredictable; a predictable IV reintroduces the problem CBC exists to solve.

CTR (Counter) turns a block cipher into a stream cipher by encrypting a counter and XORing the result. It parallelizes well and needs no padding. The counter must never repeat under the same key.

GCM (Galois/Counter Mode) is CTR plus an authentication tag. This is authenticated encryption, and it is the one to know: it provides confidentiality and integrity together, so tampered ciphertext is detected rather than silently decrypted into garbage that the application then trusts.

The general rule worth memorizing: encryption without authentication is a vulnerability. AES-GCM and ChaCha20-Poly1305 are the modern defaults precisely because they refuse to separate the two. Padding-oracle attacks against unauthenticated CBC are the classic illustration, and they appear among the cryptographic vulnerabilities exams like to test.

The Key Distribution Problem

Symmetric encryption assumes both parties already share a secret. Getting that secret to them is the part symmetric cryptography cannot solve on its own.

Real systems combine both families. Asymmetric cryptography, built on the certificate infrastructure described in public key infrastructure, is used to authenticate the parties and agree a session key; the bulk data is then encrypted symmetrically because asymmetric operations are far too slow for volume. TLS works exactly this way.

Beyond the initial exchange, keys need lifecycle management: generation from a proper random source, secure storage in a key vault or hardware security module, periodic rotation, and defined destruction. A hard-coded key in source code is a common and serious finding, because rotating it means shipping new code.

Where It Is Applied

Full-disk and database encryption protecting data at rest. TLS session encryption protecting data in transit. Encrypted backups and archives. Note that encrypting stored data protects against theft of the media, not against an attacker who already has valid access to the running system — the data is decrypted for them automatically.

Exam Focus

Know AES key sizes and that the block size is always 128 bits. Know ECB leaks patterns and is never acceptable. Know CBC needs a random IV. Know GCM provides authenticated encryption. Know symmetric is fast but faces the key distribution problem, which asymmetric solves. And know 3DES and RC4 are deprecated.

Comments