The question is quite similar to Many time pad attack and I was trying to rely on the top answer, but still am a bit confused, so any explanation and help will be much appreciated. Assume I have a bunch of ciphertexts with the same key. I need to decipher one of them. At the moment I understand that I need to XOR the desired one with each of the rest, but I am confused whether I should do it one by one or XOR it will all at once? Where do I go from there checking whether there's been a space or no, surely all of them will have spaces in different places? How do I recover the symbols then? Thank you so much.
1 Answer
A character is usually encoded as an ASCII. This means that it uses up one byte. That's a number from $0 - 255$. It can be represented as a hexadecimal $\text{0x00} - \text{0xFF}$. All your operations must be done character by character. From now on by "message", "key" and "cipher" i mean a single $0-255$ number. $$ message1 \oplus key = cipher1 \\ message2 \oplus key = cipher2 $$ when we xor two ciphered letters $$ cipher1 \oplus cipher2 = \\ message1 \oplus key \oplus message2 \oplus key = \\ message1 \oplus message2 $$ So when we xor one character of the cipher with corresponding character of a second cipher we remove the key from the equation, and receive a character of first message xored with character of second message. Now we do some deduction. We look for numbers looking like $\text{0x42}$ I did some calculations previously and I know that we can get this number within a-z(space)A-Z only by xoring "b" (lowercase b) and " " (space). Rest is pretty much a lot of guessing.
To get that byte of the key all you need is to xor byte of message with byte of cipher. $$ key = message \oplus cipher $$ Example: We have two ciphertexts from which we take the third character: $$48A6\color{red}{48}3C\\7692\color{red}{0A}A2$$ We xor them together: $$\text{0x48} \oplus \text{0x0A} = \text{0x42}$$ I made myself a table of all possible letters xored with space, and I see that $\text{0x42}$ is in that table. This means that it's possible that one of the letters is "b" ($\text{0x62}$) and second is " " ($\text{0x20}$) Let's assume that " " is encrypted in first ciphertext and get the key: $$\text{0x48} \oplus \text{0x20} = \text{0x68}$$
If we assume that " " is encrypted in second ciphertext we get another possibility of the key: $$\text{0x0A} \oplus \text{0x20} = \text{0x2A}$$
So the key can be: $$\_\_\_\_\color{red}{68}\_\_$$ or $$\_\_\_\_\color{red}{2A}\_\_$$
We just decreased the number of possibilities for this byte of the key from 256 to 2.
-
$\begingroup$ As an addition - you may have part of message which is knows (like login requests, HTTP headers, ...), greetings, .. Using a key directly would reveal it. That's why in reality we use the "One time pad" stream generated from the key (PRNG), not the key itself. Once the stream is reused, you are able to decipher the other messages as well. $\endgroup$– gusto2Mar 14, 2016 at 8:51