开发者

after XOR operation find C (and XOR reversability)

Assume:

unsigned char A = 10;
unsigned char B = 11;
unsigned char C = 12;


unsigned char Diff1 = A ^ B;
unsigned char Diff2 = B ^ C;

//find any of A or B or C using Diff1 and Diff2

Question is: There were 3 values initially for which we found 2 differences. Is there any way we can find any of A or B or C using 2 differences Diff1 and Diff2?

I know XOR is not reversible unless you know the key, but keeping in view that unsigned __int8 is 0...255 m开发者_JAVA技巧aximum 256 different values.

stay well.


You don't have enough information to find any of A, B or C from just knowing the values of Diff1 and Diff2.

There are 256 ** 3 different possible inputs and only 256 ** 2 possible outputs so for each output there are 256 different possible inputs that could have given that output - where A, B and C could be any value. But once you know any one of them you can calculate the other two.

Effectively you are using XOR encryption twice on a plaintext (B) with two separate unknown keys (A and C). An XOR encryption is provibly impossible to reverse - there is no useful information at all in the output (assuming the key is chosen uniformly at random and never reused).

You can find A XOR C though:

Diff1 ^ Diff2
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜