Send
Close Add comments:
(status displays here)
Got it! This site "creationpie.com" uses cookies. You consent to this by clicking on "Got it!" or by continuing to use this website. Note: This appears on each machine/browser from which this site is accessed.
The XOR operation and one-time pads
1. The XOR operation and one-time pads
A
OTP (One Time Pad) cipher system that uses the cipher key one time only, and for short messages (key is longer than the message).
The most secure keys are one-time pads of random, but agreed-on keys. It is impossible to break a one-time pad. If the key is ever reused, then it becomes almost trivial to break that one-time pad.
That is why it is called a one-time pad. It can only (securely) be used one time.
The one-time pad was first described in 1882 and re-discovered in 1917 by Gilbert Vernam.
Today, most cryptography systems are based on the
XOR (Exclusive Or) logical bit operation. The complexity arises in negotiating secure distributed keys and distributed difficult-to-guess pseudo random number sequences.
2. History
This is the only known secure system (unbreakable if properly used) for communication, but it has some restrictions that must be insured.
The problem with the one time pad is that of key distribution. Other message security systems are typically based on this system at an internal level, but use a more convenient way to generate a pseudo-random sequence of bits.
3. Brute force attack
Given a sequence of random bits, the problem reduces to guessing that sequence of random bits.
This is not possible, since a brute force attack is not possible (for more than a line of text) and such an attack would generate every possible random message and every possible meaningful message.
4. Exclusive or
The
XOR operation is true if both operands are different. Here is the extended truth table of the XOR operation using the caret "
^N" is the exclusive or operator.

a b | a ^ b
-----------
0 0 | 0 0 0
0 1 | 0 1 1
1 0 | 1 1 0
1 1 | 1 0 1
5. One-time pad proof
m is the message
k is the key
The proof is for one random bit and one bit of the message. Repeat for a longer message (always using a new random bit).
k m | ( ( m ^ k ) ^ k ) = m
---------------------------
0 0 | ( ( 0 0 0 ) 0 0 ) 1 0
0 1 | ( ( 1 1 0 ) 1 0 ) 1 1
1 0 | ( ( 0 1 1 ) 0 1 ) 1 0
1 1 | ( ( 1 0 1 ) 1 1 ) 1 1
The extended truth table shows that encrypting by a random bit and then applying the same operation results in the original value.
6. Re-order and re-name the variables
p is the message
q is the key
The proof is for one random bit and one bit of the message. Repeat for a longer message (always using a new random bit).
p q | p = ( q ^ ( q ^ p ) )
---------------------------
0 0 | 0 1 ( 0 0 ( 0 0 0 ) )
0 1 | 0 1 ( 1 0 ( 1 1 0 ) )
1 0 | 1 1 ( 0 1 ( 0 1 1 ) )
1 1 | 1 1 ( 1 1 ( 1 0 1 ) )
7. Key
11111110101111010101
10100010110010100111
11011100110011111101
10101010000010001000
00011000001000101001
11010101001011011011
01100100101110010100
00111010101001011110
01111101101101000101
11111101011100000010
Here is a (pseudo-random key). In actual use, a truly random key should be used.
8. Message#1
00000000000000000000
01111111111111111110
01000000000000000010
01000000000000000010
01000000000000000010
01000000000000000010
01000000000000000010
01000000000000000010
01111111111111111110
00000000000000000000
Here is message#1. The message is a rectangle within the bit pattern.
9. Encode#1
11111110101111010101
11011101001101011001
10011100110011111111
11101010000010001010
01011000001000101011
10010101001011011001
00100100101110010110
01111010101001011100
00000010010010111011
11111101011100000010
Here is encoded message#1. Message#1 has been fully encrypted using the key.
10. Decode#1
00000000000000000000
01111111111111111110
01000000000000000010
01000000000000000010
01000000000000000010
01000000000000000010
01000000000000000010
01000000000000000010
01111111111111111110
00000000000000000000
Here is decoded message#1. Message#1 has been completely recovered.
11. Message#2
01100000000000000110
00011000000000011000
00000110000001100000
00000001100110000000
00000000011000000000
00000001100110000000
00000110000001100000
00011000000000011000
01100000000000000110
10000000000000000001
Here is message#2. The message is a diagonal slash from each opposing corner.
12. Encode#2
10011110101111010011
10111010110010111111
11011010110010011101
10101011100100001000
00011000010000101001
11010100101101011011
01100010101111110100
00100010101001000110
00011101101101000011
01111101011100000011
Here is encoded message#2. Message#2 has been fully encrypted using the key.
13. Decode#2
01100000000000000110
00011000000000011000
00000110000001100000
00000001100110000000
00000000011000000000
00000001100110000000
00000110000001100000
00011000000000011000
01100000000000000110
10000000000000000001
Here is decoded message#2. Message#2 has been completely recovered.
14. Mixture
01100000000000000110
01100111111111100110
01000110000001100010
01000001100110000010
01000000011000000010
01000001100110000010
01000110000001100010
01011000000000011010
00011111111111111000
10000000000000000001
Here is XOR of encoded message#1 and encoded message#2. Re-using the key results in parts of each message being clearly visible. Once a lot of the message is broken, the rest is much easier to break.
15. Observation
Can you see parts of message#1 and message#2 in the mixture?
This results from using (or re-using) the same key.
In practice, it may not be as easy as this because of aligning a re-used key with a message, but the breaking of the code is much easier than the impossible breaking of the original code (if using a truly random key).
16. End of page