# One Time Pad 一次性密碼本 [TOC] ## What is OPT ? - Aka Vernam Cipher - the improvement to Vernam Cipher (key is reused) - it produces random output ### History - Frank Miller v.s Gilbert Vernam - straight-forward ciphers & superenciphered codes ### Features - Key - As long as the total set of messages - Absolutely random - Never re-used - Unbreakable(if used correctly) - For the cipher to be 100% secure, the following requirements apply: 1. The key must be truly random 2. The key must be at least as long as the plaintext 3. The key must never be reused (not even a part of it) 4. The key must be kept completely secret ### Why is it Unbreakable? 1. The key is as long as the given message. 2. The key is truly random and specially auto-generated. 3. Key and plain text calculated as modulo 10/26/2. 4. Each key should be used once and destroyed by both sender and receiver. 5. There should be two copies of key: one with the sender and other with the receiver. ### Disadvantage - **Unbreakable(if used correctly) but weak** - Key management is at best difficult, often completely impossible. - It is useful primarily for low-bandwidth channels. - It is highly vulnerable to a **substitution attack**. ## History - Gilbert Vernam ## How to encrypt ? modular addition (refer. the standard Vigenère cipher) 1. assign each letter a numerical value (e.g. `a` is `0`, `b` is `1`, and so on) 2. (message) alphabet -> number 3. cipher = (message + key) mod 26 4. (ciphertext) number -> alphabet - True randomness - $c = p \oplus k$ ## How to decrypt ? plaintext = ciphertext – key (mod 26) ## Reference - [Wikipedia - One-time pad](https://en.wikipedia.org/wiki/One-time_pad) - [OPT - FAQ](http://www.ranum.com/security/computer_security/papers/otp-faq/) - [FreeS/WAN - Discussion](https://www.freeswan.org/freeswan_trees/freeswan-2.06/doc/glossary.html#OTP) - [Wikipedia - Gilbert Vernam](https://en.wikipedia.org/wiki/Gilbert_Vernam) - [Youtube - One Time Pad](https://www.youtube.com/watch?v=6iYqHn3q8sY&ab_channel=NesoAcademy) - [擁有 Perfect Secrecy 的加密函式 One Time Pad](https://medium.com/fcamels-notes/%E6%93%81%E6%9C%89-perfect-secrecy-%E7%9A%84-one-time-pad-d9ad353f2af1) - [Tutorialpoints - One Time Pad Cipher](https://www.tutorialspoint.com/cryptography_with_python/cryptography_with_python_one_time_pad_cipher.htm) - [MAT - One-time Pad (OTP)](https://www.nku.edu/~christensen/1402%20one%20time%20pads.pdf)