Lesson 5 of 5 Cryptography Fundamentals

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.

UseRecommendedAvoid
Symmetric encryptionAES-128 or AES-256 in GCM; ChaCha20-Poly1305DES, 3DES, RC4, any cipher in ECB mode
Asymmetric encryption and signaturesRSA 3,072+ bits; ECC P-256 or Ed25519RSA below 2,048 bits
HashingSHA-256, SHA-384, SHA-3MD5, SHA-1 for signatures or integrity
Password storageArgon2, bcrypt, scrypt, PBKDF2 with saltUnsalted or fast hashes

The following diagram shows each weak cryptographic setting in a legacy application and its replacement.

Upgrading a legacy application's cryptography. 3DES is retired, and ECB mode reveals patterns and gives no integrity, so files move to AES-256-GCM; the 1,024-bit RSA signing key is too short and is replaced with RSA 3,072-bit or ECDSA P-256 or Ed25519 with a new certificate. Stored files are re-encrypted where feasible and the algorithms recorded in a cryptographic inventory.
The scenario is illustrative.
Sort into groups

Strong or weak choice?

Exam skills 5.2.5

Decide whether each choice is strong enough for new systems.

Log in to try this activity Interactive activities are free with an account.

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.
Match the pairs

Cryptographic attacks

Exam skills 5.2.6

Match each attack with its description.

Log in to try this activity Interactive activities are free with an account.

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.
Worked example

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.

Worked example

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.

Check yourself

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.