vorherigerMenunächster

One Time Pad

Functionality and Example

In cryptography the one-time pad (OTP) is a type of encryption which has been proven to be impossible to crack if used correctly. Each bit or character from a plaintext is encrypted by a modular addition with a bit or character from a secret random key of the same length as the plaintext, resulting in a ciphertext. If the key is truly random, as large as or greater than the plaintext, never reused in whole or part, and kept secret, the ciphertext will be impossible to decrypt or break without knowing the key. It has also been proven that any encryption with perfect secrecy must use keys with effectively the same requirements as OTP keys.

The way used to combine plaintext and key is not essential and it can be done in different ways. A common method for encryption is e.g. the letter-wise addition of plaintext and key. In order to do this first of all all letters of the plaintext are replaced by numbers using a substitution table.
The easiest way to do this would be to assign the 26 letters of the alphabet to their position in the alphabet, in other words you just number the letters serially (A=1...Z=26). Now a letter-by-letter addition can be done easily. For example the addition of the letters A and F will result in the letter G according to their place in the alphabet 1+6=7. If the sum exceeds 26, 26 is just subtracted from the result (Modulo-Operation). An example would be the letters X and U which results in 24+21=45 which after the subtraction of 26 results in 19, so the encoding can be described as X+U= S.

One-Time-Pads have been used already before the Second World War. Furthermore also the “Hotline” (also known as the “Red Telephone”) between the American President and the soviet Secretary-General, which once was a highly secured telegraphy connection, was protected by an One-Time-Encryption method.
So the question arises, why this encryption method is not used more often. One of the reasons for not using it, is the length of the required key. For example the encryption of all data on a PC hard drive would require just another hard drive of at least the same size to save the key.
Another reason is the high logistic effort which would be required to exchange the keys because both parties need to have the same key, so also key transmission needs to be highly secure in that case.

It could be realized by a delivery boy, but he might be corruptible. If it is done electronically the key itself has to be encrypted again, in order not to be intercepted or read along. But a secure encryption of the key would again result in another encryption using OTP – a vicious circle.
In former military times small codebooks have been used, which were just crammed with random blocks of numbers. These books had to be distributed among the relevant parties in beforehand. To identify a key it was only required to name the page and row within this book, the length of the key could be determined by the length of the encrypted message.
But of course these codebooks must not fall into the hands of the enemy. Therefore they have usually been quite small, allowing the holder to easily hide them in cuttlings of his clothes or even in his shoes.

The general problem of this encryption method has already been mentioned:
Although it is mathematically secure, the key can be stolen or the key-holder can be bribed to release it. Also due to the high logistic effort mentioned before, the OTP method could never prevail in big communication networks. Nevertheless for a highly secure communication between only two parties it is still the first choice in terms of security.
Another more theoretical problem is that the encryption keys have to be created truly random and independent of each other. Ideally this can only be done by a non-deterministic physical random generator. Practically this is not done most of the time but suboptimal random numbers are used. For example common computers are not able to create real random numbers but only pseudo-random numbers.

Examples

The OTP-encryption of “TREE” with the key “KEYS” using simple letter-addition results in

So the encrypted text is „EWDX“

To decrypt the message “EWDX” the key “KEYS” has to be subtracted again (In case of a negative result 26 is added to the result):

Further information and in part source of this text: Wikipedia

Usage

The OTP supported by GCC is the letter-to-number case, meaning the addition of letter-values of message and key.

Input
  1. The text to be encrypted
  2. The key to be used (Be aware: The key must have the same length as the message !)
  3. Select if the message shall be encrypted or decrypted
  4. Selection of an additional deferral (Default is 1)
  5. Click!
Output
The encrypted or decrypted text or an error message in case message and key are not of the same length.