What is the exact number of rounds employed by the MD5 and SHA512 hashing algorithms?

According to various sources, the SHA512 hashing algorithm employs a total of 80 rounds (http://en.wikipedia.org/wiki/SHA2).

On the other hand, I am confused when it comes to the MD5 hashing algorithm. According to Wikipedia, MD5 employs 64 rounds (http://en.wikipedia.org/wiki/SHA2). However, another website states that MD5 employs 4 rounds (http://md5live.com/2013/03/06/encryption-methods-sha1-vs-md5-vs-sha256/). Who is the correct of the two please?

I can't seem to find a reliable source of information regarding the number of rounds. Furthermore, what are these rounds exactly? In simple terms, what does the hashing algorithm do during these rounds? Thank you very much :))

  • I would recommend ignoring the blog post you found. – tylerl Jul 23 '13 at 17:20
  • Thank you for your input :) It does seem to have a little bit of inconsistencies – Matthew Jul 23 '13 at 17:21
  • Don't cross-post – CodesInChaos Jul 23 '13 at 19:43

There is no objective, systematic and consistent notion of what is a "round". Each algorithm specification defines things its own way.

MD5 is described as first padding and then splitting its input into 512-bit blocks. Then, as the RFC puts it, there are four rounds where each round happens to be a sequence of 16 very similar operations. So we could say that MD5 uses "four rounds" (per block). However, cryptographers have soon shunned this terminology, and when they talk about the potential weaknesses of MD5, they concentrate on the internal operations, which they call "rounds". In that view, MD5 has 64 rounds.

SHA-512 is specified similarly as padding and breaking input data into 1024-bit blocks, and each block is processed with a loop which repeats 80 times a sequence of 4 steps. So we could say that SHA-512 uses "320 steps" (per block). There again, cryptographers agree, more or less implicitly, on talking about "80 rounds". It can be noticed that each of these rounds roughly implies twice as many operations as an MD5 "round" (when MD5 is said to have 64 rounds) so it could be argued that SHA-512 actually has 160 rounds. Or not.

These terminology issues are not important as long as everybody agrees about what they are talking about. The important point is that there is no absolute notion of "round" which is more correct than any other, or which could allow comparing different algorithms based on "how many rounds they have".

As for knowing what happens within the rounds, the simplest way to know is to read the specification, and implement it in some language. This is not hard (begin with MD5) and it is a great pedagogical experiment.

  • Thank you so much for the information Tom :) I appreciate it immensely :) – Matthew Jul 24 '13 at 17:11

Hash functions typically work by performing a single operation over and over. Each time through is called a "round".

It's a bit like stirring a pot: you can't expect to thoroughly mix anything with just one turn of the spoon. But stir long enough and the original state of the ingredents can no longer be determined.

Here's an example of a round of SHA-1. A single block of data is divided into smaller chunks, with certain operations performed on each chunk depending on their position. In the end, the positions are shifted a bit, and you run the function again.

Sha1 from wikipedia
[See the Wikipedia page for what the symbols mean]

As for where to find the number of rounds; most technical descriptions will provide these details, including typically even Wikipedia. But if you want the most accurate, reliable definition, then the original technical specification filed with NIST is the definitive source.

  • Thank you so much for the information :) I appreciate it immensely :) – Matthew Jul 23 '13 at 17:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.