开发者

Hash(m1 xor m2) = Hash(m1) xor Hash (m2) Is this true in case of SHA1

Can anyone shed some knowledge on this?开发者_StackOverflow

My answer is no, it is not true, because SHA1 has a strong collision resistant property.


No this isn't true. (And it would only take a few seconds to actually test it yourself.)


No, it is not true. A function would have to go out of its way to have this property. SHA1 incorporates bytes from its stream on block at a time starting with a predefined initial value. At the end it incorporates the length of the byte stream into the byte stream and pads out to the block size.

It makes no attempt to satisfy the property in question (which is a good thing!)


No. To quote from Wikipedia:

Even a small change in the message will, with overwhelming probability, result in a completely different hash due to the avalanche effect.

Here's a counterexample (0xFF xor 0x00 is 0xFF):

$ echo -ne "\xff" > 1
$ echo -ne "\x00" > 2
$ sha1sum *
85e53271e14006f0265921d02d4d736cdc580b0b *1
5ba93c9db0cff93f52b521d7420e43f6eda2784f *2

If your statement were true, the second hash would have to be 00000000..., but it is not.


I'm affraid this will hold only if your hash function is XOR.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜