Cryptanalytic Attack Models
Cryptanalytic attacks are classified by what the attacker knows or can do. This lesson covers brute force, the classic attack models and frequency analysis.
Learning outcomes
After completing this lesson, you will be able to:
- Describe brute force, dictionary and rainbow table attacks and their defences.
- Distinguish ciphertext-only, known-plaintext, chosen-plaintext and chosen-ciphertext attacks.
Brute force and password attacks
A brute force attack tries every possible key or password. Its cost grows exponentially with key length: each additional bit doubles the work, so modern 128-bit and 256-bit symmetric keys are beyond brute force. Passwords are far weaker, so attackers use dictionary attacks (lists of likely passwords), hybrid attacks (dictionary words with variations) and rainbow tables (precomputed hash chains that trade storage for time).
Online attacks against a login service are stopped by lockouts, throttling and MFA. Offline attacks against stolen password hashes are slowed by salting (a unique random value per password that defeats rainbow tables) and key stretching functions such as bcrypt, scrypt, PBKDF2 and Argon2 that make each guess expensive. Long passphrases increase the key space.
The distinction between online and offline attacks decides which controls work. In an online attack, every guess is sent to the real login service, so the service can count failures, slow responses, lock the account or demand a second factor. In an offline attack, the attacker has stolen the password database and tests guesses on their own hardware, where no lockout applies and only the cost of each guess limits them.
Salting and key stretching change that cost in two different ways. Without salts, two users with the same password have the same hash, and one precomputed table cracks every account at once. With a unique salt stored next to each hash, the attacker must attack every account separately and cannot use precomputed tables. Key stretching makes each individual guess slow, for example by repeating the hash calculation many thousands of times or requiring large amounts of memory. A fast hash might allow billions of guesses per second on graphics processors; a well-configured memory-hard function reduces that to a tiny fraction, turning hours of cracking into years for strong passwords.
Two related online attacks target many accounts rather than one. Password spraying tries a few common passwords against many accounts, staying below the lockout threshold of each. Credential stuffing uses username and password pairs leaked from other sites, exploiting password reuse. Multi-factor authentication and checks of new passwords against lists of breached passwords are the main defences against both.
The following diagram compares fast unsalted hashing with salted, slow hashing.

Online or offline?
Attack models
Attack models describe what the cryptanalyst has to work with. The following table orders them from least to most attacker capability.
| Model | Attacker has | Example |
|---|---|---|
| Ciphertext-only | Only ciphertext | Statistical analysis of intercepted messages |
| Known plaintext | Some plaintext with matching ciphertext | Standard headers or greetings in messages |
| Chosen plaintext | Ability to encrypt chosen plaintext | Feeding inputs to an encryption oracle |
| Chosen ciphertext | Ability to decrypt chosen ciphertext | Padding oracle attacks on servers that reveal decryption errors |
Modern algorithms are designed to resist all four models. Chosen-ciphertext attacks remain practical against flawed implementations, which is why authenticated encryption and uniform error handling matter.
The models are ordered by what the attacker can control, and each step makes analysis easier. With ciphertext only, the attacker must find patterns in data they cannot read. With known plaintext, they can compare matching pairs; during the Second World War, Allied codebreakers exploited the fact that many German messages contained predictable phrases such as weather reports. With chosen plaintext, the attacker can test hypotheses by encrypting inputs designed to reveal how the cipher behaves, which is realistic whenever an attacker can make a system encrypt data for them, such as submitting text to a service that stores it encrypted.
A padding oracle shows the most powerful model in action. Some servers that used CBC mode returned different error messages depending on whether the padding of a decrypted message was valid. By sending many modified ciphertexts and observing which error came back, an attacker could decrypt the whole message byte by byte without ever learning the key. The server acted as an oracle that answered a yes-or-no question about each attempt. Returning one generic error for every failure, and using authenticated encryption that rejects modified ciphertext before the padding is examined, removes the oracle.
Name the attack model
Frequency analysis and classical ciphers
Frequency analysis breaks monoalphabetic substitution ciphers by comparing symbol frequencies with letter frequencies in the language: in English, E, T and A are most common. Polyalphabetic ciphers such as Vigenère flatten simple frequencies but can still be broken by finding the key length. Modern ciphers produce ciphertext that looks random, so frequency analysis applies mainly to classical ciphers and poorly designed schemes. Other classical techniques include linear and differential cryptanalysis, which study statistical relationships in block ciphers.
Classical cryptanalysis
Protecting stored passwords
A breached web application stored passwords as unsalted SHA-256 hashes. Attackers recovered most passwords within hours. Which change would most improve resistance to offline cracking?
Unsalted fast hashes allow rainbow tables and billions of guesses per second. Storing passwords with a unique salt and a slow, memory-hard key stretching function such as Argon2 or bcrypt makes each guess expensive and precomputation useless. Account lockout would not help, because the attack is offline, and encrypting the hashes only moves the problem to the key.
Which control defeats rainbow tables?
Show answer
A unique salt for each password, which makes precomputed tables useless.
Exam Tips
Remember for the exam
- Salts defeat rainbow tables; key stretching slows guessing.
- Lockouts stop online attacks, not offline cracking.
- Ciphertext-only gives the attacker the least information.