The most worrying cryptographic attack right now doesn’t break anything on the day it happens. An attacker simply copies encrypted data, stores it and waits for a future quantum computer powerful enough to break the public-key encryption protecting it, such as Rivest-Shamir-Adleman (RSA) or elliptic-curve cryptography (ECC). The tactic is called harvest now, decrypt later (HNDL), and it sits at the end of a much older list of ways to attack encryption.
The short answer: the types of attack in cryptography fall into three groups. Guessing attacks try to find a secret (brute-force, dictionary and rainbow table). Access-based attacks depend on what the attacker can see or control (ciphertext-only, known-plaintext, chosen-plaintext and chosen-ciphertext). The third group exploits weaknesses in the maths, the hardware or the protocol (key and algorithm, birthday, side-channel, replay and harvest now, decrypt later).
This guide explains all 12, with a real example wherever one exists, what the attacker needs and how to defend against each. The list is up to date for a reason: the National Institute of Standards and Technology (NIST) published its first post-quantum encryption standards on Tuesday 13 August 2024, which turned harvest now, decrypt later into something security teams can plan against, not just worry about.
What is Cryptography and What Does it Protect?
Cryptography uses mathematics to protect information so that only the right people can read it, change it or prove where it came from. Those jobs are known as confidentiality (nobody else can read the data), integrity (nobody can alter it without being noticed) and authenticity (the sender is who they claim to be).
You rely on it constantly: online banking, messaging apps, software updates and the padlock in a browser, which depends on Transport Layer Security (TLS). Behind many of those padlocks sits public key infrastructure (PKI), the system of certificates and keys that allows devices to decide whether to trust each other.
Two families of encryption do the work. Symmetric encryption uses one shared key and is fast, so it protects files and bulk data. Public-key encryption uses a pair of keys, mainly to agree on shared keys and to sign data, and it’s the family that quantum computers threaten most.
What are Cryptography Attacks?
A cryptographic attack is any attempt to read, modify, or alter protected data by defeating the cryptography itself or the way it’s used. The phrase covers more ground than most people expect, because the maths is rarely the weakest part of the system.
Most attacks on cryptography go after one of four targets: the key, the algorithm, the implementation (i.e., the code or hardware that runs the algorithm) or the way people use it, such as how they store passwords. Well-reviewed algorithms rarely fall to a head-on attack. Successful attacks in cryptography mostly exploit mistakes around them.
Attackers also differ in what they know and what they can do. Some only listen, some interact with the system and some have physical access to the hardware, and that difference is what separates many of the attacks below.
12 Types of Attack in Cryptography
The types of security attacks in cryptography are easier to remember once you sort them into the three groups above. The table puts all 12 side by side, which helps because several of them differ only in what access the attacker has. Each section after it covers one attack in more detail.
| Attack | What the attacker has | What the attacker wants | Main defence |
| Brute-force | Ciphertext or a password hash, plus computing power | The key or password | Long keys, strong passwords, rate limits |
| Dictionary | A hash or a login page, plus a list of likely passwords | A weak password | Long unique passwords, breached-password checks |
| Rainbow table | Stolen unsalted hashes, plus precomputed tables | The original passwords | Unique salts, slow hashing |
| Ciphertext-only | Intercepted ciphertext | Plaintext or the key | Modern cyphers with large keys |
| Known-plaintext | Matching plaintext and ciphertext pairs | The key | Standard algorithms, key rotation |
| Chosen plaintext | The ability to encrypt text of their choice | The key or hidden data | Randomised encryption, fresh values per message |
| Chosen-cyphertext | The ability to submit ciphertext and see responses | Plaintext or the key | Authenticated encryption, uniform error responses |
| Key and algorithm | Weak keys, poor randomness or a flawed algorithm | The key, or a shortcut around it | Vetted algorithms, strong key management |
| Birthday | The ability to craft inputs for a hash function | Two inputs with the same hash | Modern hash functions with long outputs |
| Side-channel | Physical or shared access to hardware | Keys leaked through timing, power, or radiation | Constant-time code, shielding, updates |
| Replay | Captured valid messages | Unauthorised access by resending them | Timestamps, sequence numbers, one-time values |
| Harvest now, decrypt later | Stored encrypted traffic or files | Plaintext, once quantum computers mature | Post-quantum algorithms, shorter data lifetimes |
Brute-Force Attack
A brute-force attack or exhaustive key search tries every possible key or password until one works. It needs no clever maths, only time and computing power, so the length of the key decides how long it takes.
In July 1998, the Electronic Frontier Foundation (EFF) built a machine that found a 56-bit Data Encryption Standard (DES) key in 56 hours, at a cost of under US$250,000. That result showed that DES keys were within reach of a well-funded attacker.
Every extra bit of key length doubles the work, so modern keys of 128 or 256 bits are far beyond guessing. Passwords are much shorter than keys, so their defences are length, rate limiting, and account lockout.
Dictionary Attack
A dictionary attack avoids the detailed search and tries the most probable options first: common words, leaked passwords and predictable patterns (e.g., a name followed by a year). Against weak passwords, it can finish in seconds, long before a full brute-force search would get close.
The attack comes in two forms. An online attack guesses at a login page, where lockouts and rate limits slow it down. An offline attack runs against stolen password hashes on the attacker’s own hardware, where nothing slows it at all, which makes it the more dangerous form.
Long, unique passwords or passphrases, checks against lists of breached passwords, and multi-factor authentication make this attack much harder.
Rainbow Table Attack
A rainbow table is a precomputed lookup table that links hash values back to the passwords that produced them. Attackers exchange storage space for time: instead of hashing millions of guesses during the attack, they look the stolen hash up in a table built in advance. This works well only against unsalted hashes.
LinkedIn showed the cost of skipping salts. After a 2012 breach, 6.5 million password hashes were posted online, and because they were unsalted Secure Hash Algorithm 1 (SHA-1) hashes, many were cracked quickly. In 2016, a much larger set of 117 million credentials from the same breach surfaced for sale.
The fix is salting, which adds a unique random value to each password before hashing so that a precomputed table is useless. Pair it with a specially designed slow password hashing function such as bcrypt, scrypt or Argon2.
Ciphertext-Only Attack
In a ciphertext-only attack, the attacker has intercepted encrypted data and nothing else: no plaintext and no key. It’s the weakest position an attacker can be in, which is why every cypher is expected to survive it.
Classical cyphers such as the Caesar cypher fail this test because letter frequencies show through the cyphertext. Modern cyphers are designed so that cyphertext looks like random noise, leaving the attacker with nothing to analyse.
The defence is a current, well-reviewed cypher with a large key and a correctly implemented mode of operation. The real risk now is misuse, such as encrypting two messages with the same key and the same one-time value, which can hand an attacker the patterns a good cypher is designed to hide.
Known-Plaintext Attack
Here the attacker holds some plaintext and its matching ciphertext and tries to work out the key from the pair. It sounds unlikely, but plaintext is often guessable, because file headers, standard greetings and routine formats repeat.
The best-known case is Second World War codebreaking at Bletchley Park, where predictable phrases in German messages, known as cribs, gave analysts a way into the settings of the Enigma machine. Weather reports were a favourite source, as they followed a set format.
Modern cyphers are designed to resist this attack, so the defence is mostly about not weakening them: use standard algorithms and modes, rotate keys and never invent a custom cypher.
Chosen-Plaintext Attack
In a chosen-plaintext attack, the attacker can feed text of their choosing into the encryption process and study the output. By comparing carefully chosen inputs with what comes out, the attacker searches for patterns that point to the key or to hidden data.
The BEAST attack against TLS 1.0 in 2011 is the classic case. A predictable detail in how TLS 1.0 chained encrypted blocks together let an attacker who could inject chosen data decrypt parts of a session, as the CERT Coordination Center advisory explains. TLS 1.1 and 1.2 closed the gap.
The defence is randomised encryption that uses a fresh, unpredictable value for every message, along with the current protocol versions.
Chosen Ciphertext Attack
This method is the mirror image of the previous attack. The attacker submits designed ciphertexts to a system that decrypts them and learns from the responses, including error messages, which turns the system into what cryptographers call an oracle.
Daniel Bleichenbacher described such an attack on RSA padding in 1998. In 2017, researchers showed that variants still worked against well-known sites, including Facebook and PayPal, in an attack named Return of Bleichenbacher’s Oracle Threat (ROBOT).
Authenticated encryption, which rejects tampered ciphertext before decryption, is the main defence. Error responses that look the same whatever went wrong also help, and so does TLS 1.3, which dropped the vulnerable RSA key exchange.
Key and Algorithm Attack
These attacks target either the key (by stealing it, guessing it or recovering it from poor randomness) or the algorithm (by exploiting a flaw in the maths). Key attacks are far more common because keys have to be generated, stored and moved around by people and software.
Heartbleed, a 2014 bug in the OpenSSL library, shows how an implementation flaw can expose keys. It let attackers read blocks of server memory, which could include private keys, without breaking any algorithm at all. Algorithms also age, and DES, covered above, is the standard example of a design that exceeded its key length.
The defence is to choose standard, publicly reviewed algorithms, generate keys with a strong random number generator, store them in hardware security modules or managed key vaults and replace them on a schedule.
Birthday Attack (Hash Collision)
A birthday attack looks for a hash collision: two different inputs that produce the same hash. It’s named after the birthday paradox, which says that in a room of just 23 people, the chance of two sharing a birthday exceeds 50%. Collisions are easier to find than intuition suggests for the same reason, because the attacker requires any matching pair, not a match for one specific value.
In practice, finding a collision takes roughly the square root of the effort needed to match one specific hash. If an attacker can create two documents with the same hash, a signature on the harmless one also validates the harmful one.
In 2017, researchers at Google and Centrum Wiskunde & Informatica in Amsterdam produced two different PDF files with the same SHA-1 hash, the first practical SHA-1 collision. It took roughly nine quintillion hash computations, which is still an enormous job, but it pushed the industry to finish moving away from SHA-1.
The defence is a modern hash function with a long output, such as Secure Hash Algorithm 2 (SHA-2) or Secure Hash Algorithm 3 (SHA-3), and it involves retiring SHA-1 wherever signatures are important.
Side-Channel Attacks
A side-channel attack ignores the algorithm and the key and watches what the hardware gives away instead: how long an operation takes, how much power it uses, what electromagnetic radiation it generates or how it uses a processor’s cache. Small differences can lead to a recovered key.
Spectre and Meltdown, disclosed in 2018, brought the idea into the mainstream by showing that ordinary processors could leak data through their performance features. Shared cloud hardware makes the issue a practical concern even for organisations that never touch a physical device.
Useful defences include code that takes the same time whatever the secret value is (constant-time code), randomised operations, shielding, hardware designed to resist breaches and prompt firmware and microcode updates.
Replay Attacks
A replay attack captures a valid message and sends it again later. The attacker doesn’t need to read or break anything, because the replayed message is genuine, which is the point: encryption protects secrecy, not freshness.
Early car key fobs that sent a fixed code are a familiar example, since a recorded signal could be played back to open the car. Rolling codes, which change with every press, were introduced to stop exactly that.
The defence is timestamps, sequence numbers and nonces (random values used only once), plus short-lived session tokens. The receiving system then rejects anything old, out of order or already seen.
Harvest Now, Decrypt Later Attack
Harvest now, decrypt later, sometimes called “catch now, break later”, means capturing encrypted traffic or files that can’t be read today and storing them until a quantum computer can. The target is the public-key encryption (RSA and ECC) that protects keys in transit, which a large, fault-tolerant quantum computer could break using Shor’s algorithm.
The Cybersecurity and Infrastructure Security Agency (CISA), the National Security Agency (NSA) and NIST warned in an August 2023 joint factsheet that cyber-threat actors could already be collecting data that will still need protection years from now.
What makes this attack unusual is that the danger depends on how long the data must stay secret, not on when quantum computers arrive. If information needs protecting for 20 years and a capable machine appears in 15, it has been exposed since the day it was captured. Medical records, state secrets, long-term contracts and intellectual property all fit the long-lifetime description.
NIST finalised its first post-quantum standards on Tuesday 13 August 2024, including Federal Information Processing Standard (FIPS) 203 for key establishment and two further standards for digital signatures. Moving key exchange to quantum-resistant methods protects traffic from that point on, but data captured earlier stays exposed, so the work needs to start before the threat is proven.
How to Prevent Cryptography Attacks
No single control stops all 12 attacks, but a small set of habits covers most of them. The list below starts with the choices that matter most and ends with the one that looks furthest ahead. Together they address both today’s attacks and the quantum-era threat.
Choose modern, vetted algorithms
Use well-reviewed standards, such as the Advanced Encryption Standard (AES) with 256-bit keys, when data must stay secret for years. Retire DES and SHA-1, and avoid writing custom cryptography, because a homemade algorithm hasn’t faced the years of public attack that standard ones have.
Keep systems and libraries updated
Many real attacks exploit flaws in cryptographic libraries and firmware rather than in algorithms, as Heartbleed showed. Keep an inventory of where cryptographic software runs and apply security updates promptly, including on easily forgotten devices such as routers and embedded systems.
Manage keys properly
Generate keys with a strong random number generator, keep them in hardware security modules or managed key vaults and rotate them on a schedule. Strong access control limits who and what can use a key, and logging each use makes theft easier to spot.
Salt and slow down password hashing
Give each password a unique salt, which defeats the rainbow table attack described earlier, and use a deliberately slow hashing function such as Argon2 or bcrypt. Add multi-factor authentication so that a cracked password alone isn’t enough.
Protect data in transit
Use TLS 1.3 where you can, disable old protocol versions and validate certificates properly. Good encryption in transit should be combined with timestamps or nonces so that captured messages can’t be replayed.
Monitor for unusual activity
Watch for patterns that point to testing: repeated failed logins, bursts of malformed ciphertext sent to a decryption service, odd response timing and large volumes of data leaving the network, which can be the first sign of a harvest attempt.
Start your post-quantum migration
Begin by listing where RSA and elliptic-curve cryptography are used, then put long-lived data first. NIST’s draft guidance (Internal Report 8547) proposes removing quantum-vulnerable public-key algorithms after 2030 and disallowing them after 2035. Hybrid key exchange, which combines classical and post-quantum methods, is already in everyday use: according to Cloudflare, the majority of human-initiated traffic on its network will use post-quantum key agreement by late October 2025.
Common mistakes to avoid
- Writing a custom cypher or hash instead of using a verified one
- Hard-coding keys in source code or configuration files
- Reusing a nonce or initialisation value with the same key
- Storing passwords unsalted or with a fast general-purpose hash
- Leaving old protocol versions switched on for compatibility
- Assuming encrypted data stays safe forever, which ignores long-lived data
Other Types of Cyber-Attacks that Put Cryptography at Risk
Cryptography is rarely the cause of failure. More often, attackers go around it by stealing keys, tricking people or breaking the connection that carries encrypted data. These types of cyber-attacks matter because they decide whether strong encryption actually protects anything.
Malware Attacks
Malware such as ransomware turns encryption against its victims, while information-stealing programmes target saved passwords and private keys. Neither needs to break any cryptography.
Phishing Attacks
Phishing tricks people into handing over passwords, approving a login or installing something harmful, usually through a convincing email or fake website. It’s the easiest way around strong encryption, since a stolen password or key opens the door without any cryptographic work. Staff training, spam filtering and phishing-resistant sign-in methods such as security keys all reduce the risk.
Denial-of-Service (DoS) Attacks
A Denial-of-Service (DoS) attack disables a system so that authorised users cannot access it, while a Distributed Denial-of-Service (DDoS) attack does the same from multiple sources at once. Encrypted connections cost a server more processing than unencrypted ones, which gives attackers an extra advantage. Firewalls, load balancing, rate limiting and traffic monitoring are the usual defences.
Man-in-the-Middle (MitM) Attacks
In a Man-in-the-Middle (MitM) attack or on-path attack, an attacker secretly sits between two parties and reads or changes what passes between them. Properly configured TLS defeats it, but ignoring certificate warnings or switching off validation removes that protection.
Zero-Day Exploits
A zero-day exploit uses a bug that the vendor doesn’t yet know about, so no solution exists. Cryptographic libraries are valuable targets because one defect can affect thousands of products. Layered controls, timely patching once a fix appears and monitoring for unusual behaviour limit the damage.
Conclusion
Cryptographic attacks can take many forms, from brute-force and dictionary attacks to replay, side-channel and chosen-ciphertext attacks. Each one targets a different weakness. In many cases, attackers do not need to break the encryption itself. Weak passwords, poor key management, outdated protocols and software flaws can give them a way around otherwise strong security.
The best defence starts with using trusted cryptographic algorithms and managing keys and passwords properly. Regular updates, strong access controls, multi-factor authentication and security monitoring can also close common gaps. There is also a longer-term concern to consider. The harvest now, decrypt later approach means attackers can collect encrypted data today and try to decrypt it when capable quantum computers become available. For data that needs to stay confidential for many years, preparing for post-quantum cryptography now can help reduce this future risk.
FAQs
What is the most common type of cryptography attack?
There’s no official ranking, but guessing attacks on passwords, mainly dictionary and brute-force attacks run against stolen password hashes, are the ones organisations meet most often. Passwords are short and chosen by people, which makes them far easier to crack than a modern encryption key. Attacks on well-reviewed algorithms themselves are rare by comparison.
What is a harvest now, decrypt later attack?
It’s a strategy where an attacker captures and stores encrypted data today, planning to decrypt it once quantum computers can break the public-key encryption protecting it. The data doesn’t need to be readable now for the attack to work; it’s only valuable for long enough. The main defence is post-quantum cryptography, which is applied first to data that must remain secret for many years.
How is a dictionary attack different from brute force?
A brute-force attack tries every possible combination, while a dictionary attack tries only likely candidates such as common words and leaked passwords. The dictionary approach is much faster against weak passwords, but it fails against a long, random one that isn’t on any list. Brute force is guaranteed to find the answer given enough time, which is why long keys matter.
Can quantum computers break current encryption?
Not yet. A large, fault-tolerant quantum computer running Shor’s algorithm could break RSA and elliptic-curve cryptography, but no machine of that size exists today. Estimates of the machine needed have fallen sharply, while symmetric encryption such as AES with 256-bit keys is considered far less affected.