Algorithm Strength and Cryptographic Attacks
Cryptography fails when algorithms are weak, keys are short or implementations are flawed. This lesson explains what makes encryption strong, current recommendations for AES and RSA, and the main categories of cryptographic attack and cryptanalysis.
Learning outcomes
After completing this lesson, you will be able to:
- Identify the factors that determine cryptographic strength.
- Describe current recommendations for AES, RSA and ECC.
- Classify cryptanalytic attacks.
- Describe implementation and protocol attacks and their defences.
What determines strength
The strength of encryption depends on several factors. The algorithm must have no known practical weaknesses after years of public analysis. The key length must make brute force infeasible: each additional bit doubles the number of possible keys, so a 128-bit key has 2 to the power 128 possibilities, far beyond any foreseeable computing. The implementation must be correct: secure modes of operation, unique initialisation vectors and nonces, constant-time code that does not leak information, and proper error handling. Key management must keep keys secret, generated with good randomness and rotated.
Work factor is the time and effort needed to break a cryptosystem; strong systems have a work factor far exceeding the value and lifetime of the data they protect. Data that must remain secret for decades needs a larger margin, including against future quantum computers.
AES and RSA recommendations
AES with 128-bit keys is considered secure against all known classical attacks. AES-256 provides a larger margin, including against quantum attacks that would roughly halve the effective symmetric key length, and is often required for highly sensitive data. AES should be used in an authenticated mode such as GCM.
RSA keys must be much longer because factoring is easier than brute-forcing a symmetric key. 2,048 bits is the minimum generally accepted today, 3,072 bits or more is recommended for protection beyond 2030, and 1,024-bit keys are deprecated. RSA should use secure padding (OAEP for encryption, PSS for signatures). ECC with 256-bit curves provides security comparable to 3,072-bit RSA.
| Use | Recommended | Avoid |
|---|---|---|
| Symmetric encryption | AES-128 or AES-256 in GCM; ChaCha20-Poly1305 | DES, 3DES, RC4, any cipher in ECB mode |
| Asymmetric encryption and signatures | RSA 3,072+ bits; ECC P-256 or Ed25519 | RSA below 2,048 bits |
| Hashing | SHA-256, SHA-384, SHA-3 | MD5, SHA-1 for signatures or integrity |
| Password storage | Argon2, bcrypt, scrypt, PBKDF2 with salt | Unsalted or fast hashes |
The following diagram shows each weak cryptographic setting in a legacy application and its replacement.

Strong or weak choice?
Cryptanalytic attacks
Cryptanalysis is the study of breaking cryptographic systems. Attacks are classified by what the attacker has, as the following list describes.
- Brute force
- Trying every possible key. Defeated by sufficient key length.
- Ciphertext-only
- The attacker has only ciphertext; the hardest situation for the attacker. Frequency analysis breaks simple substitution ciphers this way.
- Known plaintext
- The attacker has matching pairs of plaintext and ciphertext and tries to deduce the key.
- Chosen plaintext
- The attacker can have chosen plaintexts encrypted and study the results.
- Chosen ciphertext
- The attacker can have chosen ciphertexts decrypted, as in padding oracle attacks.
- Birthday attack
- Exploits the probability that two inputs share a hash: finding a collision takes about the square root of the number of possible digests, so digests must be long.
Cryptographic attacks
Implementation and protocol attacks
Many real attacks target how cryptography is used rather than the mathematics.
- Side-channel attacks measure timing, power consumption, electromagnetic emissions or sound to infer keys; constant-time code and hardware protections defend against them.
- Downgrade attacks trick systems into using older, weaker protocol versions or ciphers; disabling old versions and using protocol protections such as TLS 1.3's downgrade detection defend against them.
- Replay attacks resend captured valid messages; nonces, timestamps and sequence numbers defend against them.
- Man-in-the-middle attacks intercept key exchanges; certificate validation and authenticated key exchange defend against them.
- Rainbow table and dictionary attacks target password hashes; salting and slow hashing defend against them.
- Key theft and poor key management: stealing keys from memory, files or source code is often easier than breaking an algorithm.
- Implementation bugs such as Heartbleed, which leaked memory including private keys from OpenSSL servers, are fixed by patching cryptographic libraries.
Assessing a configuration
A legacy application encrypts files with 3DES in ECB mode and signs reports with a 1,024-bit RSA key. What should the practitioner recommend?
Replace 3DES-ECB with AES-256-GCM: 3DES is retired, and ECB reveals patterns and provides no integrity. Replace the 1,024-bit RSA key with RSA 3,072-bit or ECDSA P-256 / Ed25519, and issue a new certificate. Re-encrypt stored files where feasible, and record the algorithms in a cryptographic inventory to support future upgrades.
Naming the attack
An attacker on a café network intercepts a client's connection and causes it to negotiate an obsolete protocol version with weak ciphers, which the attacker can then break. What attack is this and how is it prevented?
A downgrade attack, combined with a man-in-the-middle position. It is prevented by disabling obsolete protocol versions and weak cipher suites on servers and clients (supporting only TLS 1.2 and 1.3 with strong suites), and by protocol mechanisms that detect downgrade attempts.
Why must hash digests be long enough to resist birthday attacks?
Show answer
Finding a collision takes roughly the square root of the number of possible digests, so a digest of n bits offers only about n/2 bits of collision resistance.
Exam Tips
Remember for the exam
- RSA 2,048 bits minimum, 3,072 recommended; AES-128 or AES-256 in an authenticated mode.
- The birthday attack targets hash collisions, so digests must be long.
- Most real attacks target implementation, protocols and key management, not the mathematics.