Thursday, March 2, 2017

Deciphering a key from XOR encrypted cypher using boolean logic

following the white rabbit direct to cables i have this hotdog ..because xor is the base of all hardware encryption 



Elsa David of course i know we're talking about optic tronics


If K is random and you only know A or B (but not both) then, no, there is no way to infer anything about the key - this is the (in)famous one-time-pad.
If you know A and B, then you can recover K very easily. Exclusive-or has those properties:
  • n    nn=0
  • n    n0=n (identity element)
  • a,b    ab=ba (commutativity)
  • a,b,c    abc=(ab)c=a(bc) (associativity)
So we can do the following:
B=AK      AB=A(AK)=(AA)K=0K=K
So AB=K
Viewed differently, the exclusive-or operator is invertible:
01001110
AB000011101110
And since the truth table is symmetric, the exclusive-or operation just happens to be its own inverse, i.e. x1y=xy. So if we take our original equation:
AK=B
We can represent it as follows:
KA=B
And we can then undo (invert) the exclusive-or by A:
KA1A=B1A      K=B1A
And as we found above, this is identical to:
K=BA=AB
As found at the beginning.
However, this is assuming A, B and K are all the same length. If K is smaller than A and B, then it means that K will be used multiple times (repeated over the length of the plaintext, presumably). This repetition can be exploited to successfully recover K from only B provided there is enough repetition and there is enough ciphertext to work with - see Vigenere cipher.

No comments:

Man in the Rain