Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Hash Algorithm MD5 calculation

  1. Nov 6, 2009 #1
    Hi. I'm studying the cryptography MD5 calculation and have some trouble I'd like to seek help with. I am trying to comprehend the MD5 memo http://www.ietf.org/rfc/rfc1321.txt" [Broken] and have trouble understanding the calculation.

    Here is what I comprehend so far. A message is appended with a 1 followed by enough 0s to make it 64-bits shy of multiples of 512-bit. The last 64-bits appended being the length of the original message. I know that a four-word buffer, and four functions will be used, but I am not sure how and which bits to put in place.

    I'm hoping someone would be able to explain the calculation of the functions and how the hash value is derived. I'm not sure if this is possible, but say given a word, to be able to produce a hash value through calculation. Thank you.
    Last edited by a moderator: May 4, 2017
  2. jcsd
  3. Nov 6, 2009 #2
    Hi, since I'm not getting any replies, I thought I might narrow down my question in hope for some answers or directions.

    From ietf.org/rfc/rfc1321.txt,

    Code (Text):
    The operation a = b + ((a + F(b,c,d) + X[k] + T[i]) <<< s)
    I understand how to get most of the variables except s. The memo states the equation will rotate by s bit, but i do not know where is s derived from.

    Code (Text):
    [ABCD  0  7  1]  [DABC  1 12  2]  [CDAB  2 17  3]  [BCDA  3 22  4]
    [ABCD  4  7  5]  [DABC  5 12  6]  [CDAB  6 17  7]  [BCDA  7 22  8]
    [ABCD  8  7  9]  [DABC  9 12 10]  [CDAB 10 17 11]  [BCDA 11 22 12]
    [ABCD 12  7 13]  [DABC 13 12 14]  [CDAB 14 17 15]  [BCDA 15 22 16]
    I also do not understand how are the numbers in these operation used. In relation to the previous question, one thing I do know is that s only uses the middle number of these operations, that is 7, 12, 17, 22.

    Code (Text):
    word A: 01 23 45 67
    word B: 89 ab cd ef
    word C: fe dc ba 98
    word D: 76 54 32 10
    Another thing I'm also curious about, although not of much importance, is the representation of the buffer. Some sites reverses the register before calculation, for example word a will be 67 45 23 01. I would like to know if there is a reason behind this or just a preferred way of calculating.

    I hope someone might be able to help me with these questions or point me a direction. Thank you.
  4. Nov 21, 2009 #3
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook