Re: Could anyone verify a term for me?

"Hipo" <no@xxxxxxxxx> wrote in message
I'm coding a SHA-1 implementation and I'm stuck at a point for
two days
now. I have to compute:
T = _rotl(0x67452301, 5) + ((0xefcdab89 & 0x98badcfe) xor
(~0xefcdab89 &
0x10325476)) + 0xc3d2e1f0 + 0x5a827999 + 0x80636261;

All numbers are unsigned ints and therfor 2^32 bit long. My
result for T
is always 0x2017fb14, but the partial result of a testvector
in the
standard paper claims T to be 0x0116fc33.

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 +

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. However, you do have an error
in that it should be inclusive or and not exclusive or. A bit
surprisingly, however, both yield the same results for the
initial values used - I wonder if that is coincidental or it if
is intentional.

After cranking though the Boolean algebra, it turns out that both
expressions are logically equivalent (due to the (b) and (~b)
which end up providing masking for the exclusive portion of the

So the real question, as near as I can tell, is what was the
message for the test vector you are trying to use? And keep in
mind that it's always possible the test vector is wrong - depends
on where it comes from. Could be nothing more than an editorial
goof, either in the test message or in the expected output - be
sure to check the errata for the book, if that's where it comes