A one-time pad is a method of encryption in which a message is combined with a secret, uniformly random key that is at least as long as the message and is never reused. When these conditions hold, the ciphertext reveals no information about the message’s contents to an observer who does not know the key. This property, called perfect secrecy, holds even against an adversary with unlimited computing power. The one-time pad is a fundamental result in cryptography, but its demanding requirements for key generation, distribution, storage, and use limit its practical deployment.
Operation
In its binary form, a one-time pad represents the message and key as sequences of bits of equal length. Encryption combines corresponding bits using exclusive OR, usually written :
where is the plaintext, is the key, and is the ciphertext. Exclusive OR produces 1 when its two inputs differ and 0 when they agree.
Decryption applies the same operation with the same key:
This works because . For example:
Plaintext: 10110010
Key: 01101101
Ciphertext: 11011111
Applying the key to the ciphertext recovers the plaintext:
Ciphertext: 11011111
Key: 01101101
Plaintext: 10110010
The same principle can be applied to symbols other than bits. If letters are represented by the numbers 0 through 25, encryption can add each plaintext symbol to its corresponding key symbol modulo 26, with decryption subtracting the key modulo 26. The key symbols must be independently and uniformly selected from the same alphabet.
The word pad comes from physical implementations in which correspondents possessed matching pads of random key material. Each sheet or section was used once and then destroyed. The mathematical construction does not depend on paper: keys can also be stored electronically.
Conditions for perfect secrecy
A one-time pad provides its defining guarantee only when all of the following conditions hold:
- Uniform randomness: every possible key of the required length is equally likely. For a binary key, this means independent, unbiased bits.
- Independence: the key is generated independently of the message.
- Sufficient length: each message bit or symbol consumes a corresponding fresh key bit or symbol.
- Single use: no part of the key is used to encrypt more than one part of the plaintext, whether within one message or across different messages.
- Secrecy of the key: the adversary does not obtain the key material used for the message.
These conditions concern the key’s actual generation and handling, not merely its appearance. A long sequence that looks irregular is not necessarily random. Text from books, repeated passwords, and predictable sequences do not satisfy the requirements.
A pseudorandom number generator expands a finite internal state or seed into a longer sequence. Even when such a generator is cryptographically strong, using its output as a pad does not generally provide the information-theoretic guarantee of a true one-time pad. Security instead depends on assumptions about the difficulty of distinguishing or predicting the generated sequence.
Why the ciphertext reveals no information
Perfect secrecy is a concept from information theory. Let , , and denote the message, key, and ciphertext as random variables. Assume the message has a fixed length of bits and the key is independently and uniformly selected from all possible bit strings.
For every candidate message and observed ciphertext , exactly one key makes them correspond:
Since that key occurs with probability ,
The ciphertext therefore has the same probability distribution regardless of which message was encrypted. Consequently,
Observing the ciphertext does not change the adversary’s probability assessment of any candidate message.
This does not mean that every plaintext is equally likely. An observer may already know that some messages are more plausible than others. Perfect secrecy means the ciphertext provides no additional evidence for choosing among them.
It also explains why exhaustive key search cannot uniquely recover a one-time-pad message: trying every key produces every possible plaintext of the appropriate length. The ciphertext alone supplies no way to identify the original.
The key-length requirement
Shannon’s bound for perfectly secret encryption with error-free decryption states, under the standard assumptions, that
where denotes entropy.
If every -bit message is possible and equally likely, the message entropy is bits, so at least bits of key entropy are required. More generally, supporting all possible messages with perfect secrecy requires at least as many possible keys as messages.
The one-time pad is therefore not an inefficient implementation of something that could provide the same unrestricted guarantee from a tiny secret. Its key requirements reflect a fundamental information-theoretic limit.
Key reuse and other failure modes
Reusing a pad
If two messages are encrypted with the same key,
then
The key cancels, exposing a relationship between the plaintexts. This is often called the two-time pad problem.
It does not automatically reveal both messages in every case. However, ordinary language, document formats, protocol headers, and other structured data contain substantial redundancy. Guesses about one plaintext can expose corresponding portions of the other. If an attacker knows one plaintext segment, the corresponding key segment follows directly:
Any other material encrypted with that same segment is then exposed. Reusing only part of a pad compromises the corresponding portions of the messages.
Biased or predictable keys
If some keys are more likely than others, ciphertext observations can favor some plaintexts over others. Correlations between key bits, defects in random-number generation, and deterministic patterns can likewise invalidate the proof of perfect secrecy.
Physical sources of randomness require engineering and statistical characterization; physical origin alone does not guarantee independent, uniformly distributed output.
Exposure of stored keys
The pad contains everything needed to decrypt the associated ciphertext. Copies in storage, backups, printed records, or compromised devices can therefore defeat the system without any cryptanalytic attack.
Practical implementations must also track which key positions have been consumed. Lost state, restored backups, or overlapping allocations can cause accidental reuse.
Confidentiality does not provide authentication
A one-time pad by itself does not provide authentication or message integrity. An attacker can change the decrypted plaintext in a predictable way by modifying the ciphertext.
If the attacker replaces with
the recipient obtains
Thus, selected bit flips in the ciphertext produce the same bit flips in the plaintext. The attacker does not need to know the key, although knowledge of the message format may be needed to make a meaningful alteration.
This property is called malleability. Protecting against active modification requires an additional mechanism, such as a message authentication code, with suitable key separation and protocol design. Information-theoretic authentication is possible, but it is a separate construction with its own assumptions and forgery bounds.
A one-time pad also does not inherently conceal message length, transmission time, communicating parties, or other metadata. Fixed-size messages and padding can reduce some length leakage, but the encryption operation itself does not provide traffic-flow confidentiality.
History
An early description of a related random-key cipher appeared in a proposal by Frank Miller in 1882. Gilbert Vernam developed a teleprinter encryption system in 1917 that combined message signals with a key stream. Joseph Mauborgne is associated with recognizing the importance of random, nonrepeating key material in this line of development.
The expression Vernam cipher is sometimes used for the one-time pad, but the terminology is not always exact: combining text with a key stream gives perfect secrecy only if that stream meets the one-time pad’s requirements.
Claude Shannon established the mathematical theory of perfect secrecy in his 1949 paper Communication Theory of Secrecy Systems. His work explained both the security of the one-time pad and the limits on perfectly secret encryption.
One-time pads were used in military, diplomatic, and intelligence communications during the twentieth century. The VENONA project is a prominent example of the consequences of reuse: duplicated Soviet key material enabled cryptanalysis of portions of otherwise protected communications. The weakness lay in the handling and reuse of key material, not in a violation of the mathematical secrecy result.
Practical uses and limitations
The principal obstacle to widespread use is key distribution. To exchange a gigabyte of encrypted data, the correspondents need a gigabyte of matching, previously shared secret key material. Distributing that material may require a trusted courier, secure physical transfer, or another mechanism whose security must be considered separately.
One-time pads can nevertheless be useful where communication volumes are limited and key material can be distributed securely in advance. Their simple encryption operation can be implemented manually or electronically, while their security does not depend on a computational hardness assumption.
Most modern communication systems instead use compact keys with practical symmetric encryption, such as the Advanced Encryption Standard, or with a stream cipher. Stream ciphers resemble a one-time pad operationally because they combine plaintext with a key stream, but they generate that stream from a shorter secret key. Their security is computational rather than perfect.
Using public-key cryptography to send a pad does not automatically give the overall system information-theoretic secrecy: an attacker who later breaks the key-transport mechanism may recover the pad. Similarly, quantum key distribution can supply key material for use in a one-time pad, but it requires an authenticated classical channel and remains subject to implementation assumptions.
The mathematical guarantee of a correctly implemented one-time pad is unaffected by a quantum computer or any other increase in computational power. It does not, however, protect against compromised endpoints, stolen pads, faulty randomness, key reuse, or unauthenticated message modification.