Wayne, I have a question re. above: If you were to choose your own single keyword above from the ~2^32 possible, and prompt for it rather then coding it into the program, would that prevent the "immediate" cracking of it using your technique?
The only thing that matters is that if I can deduce two of the three values in your XOR calculation then I can immediately deduce the 3rd - your key.

In other words, the 'security' of XOR requires that the attacker only has one of the three values (the resulting ciphertext). If any two of the three values are known then it's game over, and if the attacker can send your algorithm his own input (thats one value) and get the resulting ciphertext (thats now two values) he can deduce the third.
Consider for example if MY secret key is the number 5. YOU then send a sequence of your own bytes as input to my algorithm (it doesn't matter what the sequence is as long as you know what it is). So for example, you might send 7, 7, 7, 7, 7 to my algorithm, in which case the output would be 2, 2, 2, 2, 2.
You then XOR 2 with 7, and voila ... you've got 5 - my secret key.
Multi-byte keys
... it's exactly the same. Lets say my secret key is 5, 7, 2.
If you then send me custom input of say, 3, 3, 3, 3, 3, 3, 3, 3, 3, you'll get the following output: 6, 4, 1, 6, 4, 1, 6, 4, 1.
Usually you'd send it a longer input sequence than that, but you can see in this example that the custom input was still long enough to reveal that the cipher is repeating after every 3 bytes. In other words the key is essentially just 3 bytes.
So ...
6 xor 3 = 5
4 xor 3 = 7
1 xor 3 = 2
You've now got my key.
Keys as big as or bigger than the plaintext/ciphertext
In the case of the RANDOMIZE [seed] function the key it produces is almost of unlimited length (im not sure what its period is, but it should be quite large so the size of the key could be several terabytes in size).
Breaking these keys is actually no different to the above example of breaking a 3-byte key, BUT your custom input needs to be as long as the plaintext/ciphertext, although thats usually not a problem.
But out of curiosity, I generated an unknown random keyword for it and it took me 40 minutes to find it, where as it looks like your technique might take what, maybe 40 micro-seconds? Can it be done that fast even if prompting for the keyWord?
btw, this isn't exclusively an XOR issue ... consider if you use addition/substitution instead for example.
If your key is say 3, and I input 5, 5, 5, 5, 5, 5, the resulting ciphertext would be 8, 8, 8, 8, 8, 8. I can then simply reverse the cipher by substituting 5 from 8 to get 3 - your key.
XOR on its own CAN actually be secure but only if correctly implemented in the form of a One Time Pad, but even then the security of that still requires that the attacker only has 1 of the 3 values (the ciphertext). As soon as the attacker has any two of the three values it's game over.
Leave a comment: