# Re: Could anyone verify a term for me?

*From*: "William L. Bahn" <william@xxxxxxxxxxxxxxx>*Date*: Tue, 13 Jun 2006 00:36:02 -0600

"Hipo" <no@xxxxxxxxx> wrote in message

news:448dbf8e$0$11094$3b214f66@xxxxxxxxxxxxxxxxxxxxxxx

Hi.two days

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)

http://en.wikipedia.org/wiki/SHA1

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;

becomes

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. 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

expression).

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

from.

.

**Follow-Ups**:**Re: Could anyone verify a term for me?***From:*Bryan Olson

**Re: Could anyone verify a term for me?***From:*BRG

**References**:**Could anyone verify a term for me?***From:*Hipo

- Prev by Date:
**Re: how to detect with cipher method is used?** - Next by Date:
**Re: how to detect with cipher method is used?** - Previous by thread:
**Re: Could anyone verify a term for me?** - Next by thread:
**Re: Could anyone verify a term for me?** - Index(es):