A known-plaintext attack is a model of cryptanalysis in which an attacker has access to one or more plaintext messages, or portions of messages, together with their corresponding ciphertexts. The attacker uses these pairs to try to recover the secret key, decrypt other ciphertexts, or identify exploitable properties of an encryption scheme. “Known plaintext” describes the information available to the attacker, not a particular attack algorithm, and possession of such information does not necessarily make a secure system vulnerable.
Attack model
For a deterministic encryption operation, a known plaintext–ciphertext pair can be written as
where is a plaintext, is its ciphertext, and is encryption under a secret key . An attacker knows some pairs and the encryption algorithm, but not . Depending on the system, the attacker may also know public parameters such as an initialization vector or nonce. For randomized or nonce-based encryption, those inputs must also be included in the relationship.
The assumption that the algorithm is public follows Kerckhoffs’s principle: security should depend on the secrecy of the key, rather than on keeping the cryptographic design secret.
Possible objectives include:
- Key recovery: obtaining the original key or an equivalent key that performs the same relevant cryptographic operations.
- Message recovery: decrypting previously unknown plaintext without necessarily recovering the key.
- Distinguishing: detecting a relationship that separates the scheme’s output from an appropriate idealized reference system.
A meaningful threat model also specifies how many pairs are available, whether they share a key, which plaintext positions are known, and what computational resources the attacker can use. Data collected under unrelated keys generally cannot be treated as if it came from one key.
How plaintext becomes known
Known plaintext can arise without an attacker controlling the sender. Examples include:
- A document becoming public after an encrypted version was intercepted.
- Standardized message openings, protocol fields, or file-format signatures.
- Identical material distributed in encrypted and unencrypted forms.
- Records obtained independently from another system.
- Repeated operational messages whose contents can be established from external events.
A likely phrase is not automatically known plaintext. A crib is a suspected plaintext fragment used to test a cryptanalytic hypothesis; the guess may be wrong or may correspond to a different position in the message.
The relevant plaintext is the exact data presented to the encryption operation. A recognizable document heading may not remain recognizable at that stage if compression, serialization, or another transformation is applied first. Alignment and encoding therefore matter as much as the human-readable content.
Relationship to other attack models
Known-plaintext attacks are distinguished from attacks that grant different access to cryptographic operations.
| Attack model | Attacker’s access |
|---|---|
| [[ciphertext-only-attack | Ciphertext-only attack]] |
| Known-plaintext attack | Plaintexts and their corresponding ciphertexts, without needing to select the plaintexts |
| [[chosen-plaintext-attack | Chosen-plaintext attack]] |
| [[chosen-ciphertext-attack | Chosen-ciphertext attack]] |
Chosen-plaintext access generally provides at least the opportunities available from known plaintext, because the attacker can obtain matching pairs deliberately. Adaptive variants allow later queries to depend on earlier results.
These categories describe access to data and operations. They are separate from techniques such as side-channel attacks, which exploit information such as timing, power consumption, or electromagnetic emissions.
Representative mechanisms
Classical substitution and algebraic ciphers
In a simple substitution cipher, a known plaintext fragment directly reveals the substitutions used for the letters appearing in that fragment. These mappings can help decrypt other messages using the same substitution.
For an affine cipher over integers modulo ,
two known character correspondences give
If is invertible modulo , this determines , after which can be calculated. If it is not invertible, additional correspondences may be needed.
Such examples illustrate why a large number of possible keys is not sufficient for security: algebraic relationships may reveal a key without testing every possibility.
Reused keystreams
A stream cipher commonly encrypts plaintext by combining it with a keystream using exclusive OR:
A known plaintext segment reveals the corresponding keystream segment:
If the same keystream segment encrypts another plaintext , that segment can be recovered from its ciphertext :
This is a consequence of keystream reuse, not an automatic failure of stream encryption. Secure designs are intended to prevent the recovered segment from revealing other, unused keystream segments. Repeating a key–nonce combination in many nonce-based stream-encryption schemes causes the same keystream to recur.
The same algebra applies to a one-time pad. Knowing part of a message reveals the pad bits used for that part, but not the independent pad bits used elsewhere. A correctly generated pad that is used only once retains perfect secrecy for the remaining unknown message content. Reusing pad material invalidates that protection.
Candidate-key testing
For a block cipher, known plaintext–ciphertext blocks provide a way to test candidate keys. An attacker encrypts the known plaintext under a trial key and checks whether the result matches the observed ciphertext.
In an idealized model with a -bit key and an -bit block, one pair leaves an expected number of false candidate keys of approximately
With distinct pairs under the same key, and treating their constraints as approximately independent, the estimate becomes
These estimates concern key identification, not the cost of finding the key. Even if enough pairs uniquely identify a key, a brute-force attack may still require an infeasible search through the key space.
Statistical cryptanalysis
Linear cryptanalysis uses statistical relationships involving plaintext bits, ciphertext bits, and key bits. A relationship that holds with a sufficiently detectable bias can support key recovery from many known pairs.
Its feasibility depends on the strength of the bias, the amount and distribution of data, and the work needed to process candidate keys. The existence of a theoretical known-plaintext attack does not by itself establish that a cipher is practically breakable.
Historical significance
Known and suspected plaintext played an important role in attacks on classical and mechanical encryption systems. During World War II, cryptanalysts attacking the Enigma machine used cribs, including predictable language and message formats, to help test possible machine settings.
These efforts combined plaintext hypotheses with properties of the machine and operational procedures. They illustrate an important distinction: an attack may begin with a plausible guess and establish whether it is correct, rather than start with a fully verified plaintext–ciphertext pair.
Significance for modern encryption
Resistance to known-plaintext attacks is a baseline expectation of modern cryptography. Standardized ciphers such as the Advanced Encryption Standard are designed and analyzed with the expectation that attackers may know substantial amounts of plaintext.
Modern encryption security definitions usually demand more than known-plaintext resistance. Chosen-plaintext security addresses an attacker who can obtain encryptions of selected messages. Stronger models also consider restricted decryption access. In public-key cryptography, anyone with the public key can normally encrypt chosen messages, making mere resistance to known plaintext insufficient as a security goal.
Security also depends on how a cipher is used. An otherwise sound primitive can be undermined by repeated keystreams, unsuitable modes of operation, weak keys, or incorrect handling of public parameters. Conversely, finding a recognizable plaintext header does not establish a vulnerability in correctly implemented modern encryption.
Known-plaintext resistance concerns confidentiality. It does not by itself provide authentication or detect message modification; those properties require mechanisms such as a message authentication code or an authenticated-encryption construction.