A one-time pad encrypts plaintext by XORing it with a truly random key equal in length to the message. With a unique key, it provides mathematically perfect security. section 4.1.2 section 4.4
Implement the construction correctly, then preserve its security properties:
- Generate fresh random bits with a true random number generator; an 11-byte message such as “HELLO WORLD” requires 88 random key bits. section 4.1.2
- XOR the plaintext and key to produce ciphertext, and XOR the ciphertext with the original key to reverse the operation. section 4.1.2 section 4.4
- Never reuse a key: communicating it securely requires transporting as many secret bits as the message, limiting large-scale practicality. section 4.1.2 section 4.4
Why key reuse fails
If two ciphertexts use the same key, XORing them cancels the key and reveals the XOR of the two plaintexts. Known plaintext similarly lets an attacker recover the corresponding key bytes; related weaknesses helped break WEP. section 4.1.2 section 4.4
Equation 4.3
\[\begin{aligned} \begin{aligned} \text{Plaintext}_1 &\oplus \text{Key} &=& \; \text{Ciphertext}_1 \\ \text{Plaintext}_2 &\oplus \text{Key} &=& \; \text{Ciphertext}_2 \\ \text{Plaintext}_1 &\oplus \text{Plaintext}_2 &=& \; \text{Ciphertext}_1 \oplus \text{Ciphertext}_2 \\ \end{aligned} \label{equation:encrypt-xor-key-reuse} \end{aligned}\]Trace how reusing one key transforms two plaintexts into an attacker-visible XOR combination. section 4.1.2

