views:

144

answers:

2

I'm trying to learn about SHA-1, I was looking at the C implementation that was included in the specification (RFC 31741) and this part confuses me:

context->Intermediate_Hash[0]   = 0x67452301;
context->Intermediate_Hash[1]   = 0xEFCDAB89;
context->Intermediate_Hash[2]   = 0x98BADCFE;
context->Intermediate_Hash[3]   = 0x10325476;
context->Intermediate_Hash[4]   = 0xC3D2E1F0;

What are the significance of those hard coded hex values, are they just special sauce that makes the algorithm work, or do they represent some mathematical constants?

You can view the full code here: http://www.faqs.org/rfcs/rfc3174.html

+2  A: 

To save you on an overly verbose answer, they're just constants specific to the algorithm. As an example of a similar usage, refer to the Carmack Square Root. It uses a special value as a way of speeding up traditional methods of square rooting by providing an initial naive guess.

They're just numbers that help out serving as, as implied by the code, intermediate hash elements. They don't necessarily have any meaning as you may imply as mathematical constants, but they're important to the algorithm.

Tony k
A: 

It does not answer your question but do note that the real reference to SHA-1 (as explained in the RFC) is FIPS 180. No more explanations there but at least it is the original source :-(

Also, remember that SHA-1 is today seriously endangered.

bortzmeyer