Athena Wiki

Symmetric Cryptography

cryptointermediate

Index of symmetric crypto pages - AES modes, ECB/CBC attacks, padding oracle, and stream ciphers.

cryptosymmetricaesindex

Symmetric Cryptography

Symmetric cryptography uses a shared secret key to both encrypt plaintext and decrypt ciphertext; the same mathematical operations reverse each other when applied with the correct key. How it works: Block ciphers (AES) encrypt fixed-size chunks; a mode of operation (ECB, CBC, CTR) chains blocks together to handle arbitrary-length messages; without proper mode implementation, identical plaintext blocks produce identical ciphertext (ECB) or IVs leak information (CBC with predictable IVs). Why it matters: AES is cryptographically secure; attacks target mode weaknesses and improper key/IV handling; padding oracle attacks, bit-flipping exploits, and keystream reuse are common CTF vectors; essential for understanding real-world encryption failures.


Pages in This Subsection

PageDifficultyKey Attack
AES Modes OverviewIntermediateUnderstand ECB/CBC/CTR weaknesses
ECB AttacksIntermediateByte-at-a-time oracle, cut-and-paste
CBC AttacksIntermediateBit flipping, IV=key, padding oracle
Padding OracleAdvancedDecrypt any CBC ciphertext
Stream CiphersIntermediateNonce reuse, keystream recovery

Quick Attack Selection

Observation / GivenAttack / Technique
Encrypted cookie, same data encrypts same wayECB byte-at-a-time oracle
CBC cipher, ciphertext can be modifiedCBC bit flip (alter Ci1C_{i-1} to change PiP_i)
CBC cipher, server reveals padding errorPadding oracle
Two ciphertexts, same key and nonceStream cipher nonce reuse (P1P2P_1 \oplus P_2 leaks XOR of plaintexts)
AES-CTR, same nonce twiceSame as stream cipher nonce reuse
MAC = MD5/SHA(secretmessage)\mathrm{MD5}/\mathrm{SHA}(\mathrm{secret} \,\|\, \mathrm{message}) styleLength extension (see Hashing)

Python AES Template

from Crypto.Cipher import AES
from Crypto.Util.Padding import pad, unpad
import os

key = os.urandom(16)
iv  = os.urandom(16)

# ECB
cipher = AES.new(key, AES.MODE_ECB)
ct = cipher.encrypt(pad(plaintext, 16))
pt = unpad(AES.new(key, AES.MODE_ECB).decrypt(ct), 16)

# CBC
cipher = AES.new(key, AES.MODE_CBC, iv)
ct = cipher.encrypt(pad(plaintext, 16))
pt = unpad(AES.new(key, AES.MODE_CBC, iv).decrypt(ct), 16)

# CTR
cipher = AES.new(key, AES.MODE_CTR, nonce=iv[:8])
ct = cipher.encrypt(plaintext)  # no padding needed

Last updated on

On this page