Re: Could anyone verify a term for me?
- From: BRG <brg@xxxxxxxxxxx>
- Date: Tue, 13 Jun 2006 09:43:43 +0100
William L. Bahn wrote:
"Hipo" <no@xxxxxxxxx> wrote in message
I'm coding a SHA-1 implementation and I'm stuck at a point for
now. I have to compute:(~0xefcdab89 &
T = _rotl(0x67452301, 5) + ((0xefcdab89 & 0x98badcfe) xor
0x10325476)) + 0xc3d2e1f0 + 0x5a827999 + 0x80636261;result for T
All numbers are unsigned ints and therfor 2^32 bit long. My
is always 0x2017fb14, but the partial result of a testvectorin the
standard paper claims T to be 0x0116fc33.the
Could please anyone verify my result? It's driving me nuts and
algorithm is almost due.
thanks in advance, Hipo
I get the same result you do.
You didn't provide enough info to really know where in the hash
algorithm you are working, so I'm having to reverse engineer
where you are at. Initially, at least, I'm going to assume you
are at the very first pass through the main loop.
(snippets of algorithm taken from Wikipedia)
a = 0x67452301
b = 0xEFCDAB89
c = 0x98BADCFE
d = 0x10325476
e = 0xC3D2E1F0
f = (b & c) | ((~b) & d) // notice inclusive-OR
k = 0x5A827999
Substituting into your expression:
T = _rotl(0x67452301, 5) + ((0xefcdab89 & 0x98badcfe) xor(~0xefcdab89 &
0x10325476)) + 0xc3d2e1f0 + 0x5a827999 + 0x80636261;
T = _rotl(a, 5) + [((b & c) xor ((~b) & d))] + e + k +0x80636261;
Now, the last term comes from the message being hashed, so I have
no idea where it is coming from in this particular case and
whether or not you have it correct.
0x80636261 is what the ascii string "abc" becomes with a 0x80 terminator
in little endian notation in a 32-bit word.
But SHA-1 requires that its input data is in big-endian form within
32-bit words, in this case as W = 0x61626380.
So the original poster's problem is pretty certain to be that they have
not put the input data into the correct big-endian format.