I have 2 different 3DES (ede) keys (meaning double length). I encrypted an 8-byte block using the keys and got the same output. Is this okay? Or is it rare? Is this even possible?
One thing I observed was key1 xor 0101....01 = key2
. Can this be the reason. Is it like, for all such pairs of keys, 3DES works same? Also, are there any other such blocks (like 0101...01) which have the same effect?
example:
data: a21156bcdd00018a
key1: ff41777b3372b7817872b4b212f0c942
cipher text: 76 4f ab e0 2a e0 9b 11
key2: FE40767A3273B6807973B5B313F1C843
cipher text: 76 4f ab e0 2a e0 9b 11
and when data: 0000000000000000
ciphertext 1 = ciphertext 1 = 7adfa8ccbb7b3d29
basically, giving all same output.
Does this have to do something with 3DES algo?
Take a look at your keys in binary:
FF/FE 41/40 77/76 7B/7A 33/32 72/73 B7/B6 81/80
Key1 bit 0-63: 11111111 01000001 01110111 01111011 00110011 01110010 10110111 10000001
Key2 bit 0-63: 11111110 01000000 01110110 01111010 00110010 01110011 10110110 10000000
78/79 72/73 B4/B5 B2/B3 12/13 F0/F1 C9/C8 42/43
Key1 bit 64-127: 01111000 01110010 10110100 10110010 00010010 11110000 11001001 01000010
Key2 bit 64-127: 01111001 01110011 10110101 10110011 00010011 11110001 11001000 01000011
You might notice that they only differ on the last bit of each byte. This is a parity bit that ain't used by DES during encryption. From DES's point of view they are the same key.