Search code examples
md5theorysha1

Is there any difference between md5 and sha1 in this situation?


It is known that

1.    if   ( md5(a)   == md5(b)   )
2.    then ( md5(a.z) == md5(b.z) )
3.    but  ( md5(z.a) != md5(z.b) )

where the dots concatenate the strings.

EDIT ---

Here you can find a and b:
http://www.mscs.dal.ca/~selinger/md5collision/

Check these links:
hexpaste.com/qzNCBRYb/1 - this is a.md5(a)."kutykurutty"
hexpaste.com/mSXMl13A/1 - this is b.md5(b)."kutykurutty"

They share the same md5 hash, yet they are different. But you can call these strings a' and b', because they have the same md5.

--- EDIT

What happens in the second row if we change all the md5 to sha1? So:

1.    if   ( sha1(c)   == sha1(d)   )
2.    then ( sha1(c.z) ?= sha1(d.z) )

I couldn't find two different strings with same sha1, that's why I'm asking this. Are there any other interesting "rules" about sha1?


Solution

  • SHA1 will behave exactly like MD5 in this scenario.

    The only two references I have found are the following -

    1. http://www.iaik.tugraz.at/content/research/krypto/sha1/MeaningfulCollisions.php
    2. http://www.schneier.com/blog/archives/2005/02/sha1_broken.html#c1654 (See comment by David Schwartz)

    From the IAIK website -

    Note that for colliding SHA-1 message pairs (as for all other hash functions following a similar design principle) it is always possible to append suffixes to both messages as long as they are the same.

    I don't think anybody has found two colliding strings for SHA1, so this is mostly an academic discussion. But from what I understand, when a collision is discovered, it should be possible to create several other collisions by using this property.