[ pycrypto-Bugs-1154530 ] SHA 256 doesn't match test vectors on AMD64
"SourceForge.net" <[email protected]> Fri, 10 Jun 2005 12:24:34 -0700
| Newsgroups | gmane.comp.python.cryptography.cvs |
|---|---|
| Message-ID | <[email protected]> |
Bugs item #1154530, was opened at 2005-03-01 15:24
Message generated for change (Settings changed) made by akuchling
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=120937&aid=1154530&group_id=20937
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: None
>Status: Closed
>Resolution: Fixed
Priority: 6
Submitted By: Zooko O'Whielacronx (zooko)
>Assigned to: A.M. Kuchling (akuchling)
Summary: SHA 256 doesn't match test vectors on AMD64
Initial Comment:
On my Macintosh PPC G4 laptop:
>>> hex(bytes_to_long(SHA256.new('abc').digest()))
'0xBA7816BF8F01CFEA414140DE5DAE2223B00361A396177A9CB410FF61F20015ADL'
On my Linux Athlon64 workstation:
>>> hex(bytes_to_long(SHA256.new('abc').digest()))
'0x551CE4769446B343295EA7F819BAE21157541986A4DE11AB46B2340EA9831F22L'
The former is correct the FIPS 180-2 test vector for
SHA-256.
I see that the implementation is by Tom St. Denis but
it is very different from the one in his current
libtomcrypt 1.0.
Perhaps we should upgrade to that version?
I tried to run test_hashes.py, but it is apparently
written for an older (?) version of sancho that the
sancho 2.0 that I just downloaded.
----------------------------------------------------------------------
>Comment By: A.M. Kuchling (akuchling)
Date: 2005-06-10 15:24
Message:
Logged In: YES
user_id=11375
Fixed by applying the patch attached to the RIPEMD bug;
thanks for reporting this!
----------------------------------------------------------------------
Comment By: Mihai Ibanescu (misa)
Date: 2005-04-19 13:28
Message:
Logged In: YES
user_id=205865
I am on an amd64. The problem was more with the usage of
unsigned longs. Take a look at my patch that solved the
problem for me.
----------------------------------------------------------------------
Comment By: Zooko O'Whielacronx (zooko)
Date: 2005-04-19 11:21
Message:
Logged In: YES
user_id=52562
misa, what platform are you on? On 64-bit linux on
Athlon64, an int is 32 bits, but a long is 64 bits. So the
patch that you describe shouldn't change anything on an
Athlon64.
However, your suggestion caused me to clue into another
issue that probably *is* my problem on my Athlon64: the code
uses "unsigned long" in several places where it almost
certainly intends to have an unsigned 32-bit thing. So I've
written a patch that replaces all those "unsigned long"s
with U32s.
I also threw in your inttypes.h patch, just for good measure.
https://yumyum.zooko.com:19144/pub/repos/pycrypto-plus-patches
----------------------------------------------------------------------
Comment By: Mihai Ibanescu (misa)
Date: 2005-04-19 10:53
Message:
Logged In: YES
user_id=205865
Check out the patch attached to the RIPEMD bug, it makes
SHA256 work for me.
----------------------------------------------------------------------
Comment By: Mihai Ibanescu (misa)
Date: 2005-04-19 10:01
Message:
Logged In: YES
user_id=205865
Please see:
http://sourceforge.net/tracker/index.php?func=detail&aid=1185980&group_id=20937&atid=120937
a possible solution for problems on 64-bits.
typedef unsigned int U32;^M
This is asking for trouble - on 64-bit systems ints are
32-bit. See the proposed patch in the RIPEMD bug.
----------------------------------------------------------------------
Comment By: Gregory P. Smith (greg)
Date: 2005-03-01 16:14
Message:
Logged In: YES
user_id=413
this SHA256 also fails on the Alpha.
a (presumably different, i haven't looked at the code)
libtomcrypt sha256 implementation works just fine for me as
seen in this python patch that adds a hashlib module that
uses it:
https://sourceforge.net/tracker/?func=detail&aid=1121611&group_id=5470&atid=305470
----------------------------------------------------------------------
Comment By: Zooko O'Whielacronx (zooko)
Date: 2005-03-01 15:24
Message:
Logged In: YES
user_id=52562
Bumping priority, just to distinguish this one from the crowd.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=120937&aid=1154530&group_id=20937
-------------------------------------------------------
This SF.Net email is sponsored by: NEC IT Guy Games. How far can you shotput
a projector? How fast can you ride your desk chair down the office luge track?
If you want to score the big prize, get to know the little guy.
Play to win an NEC 61" plasma display: http://www.necitguy.com/?r=20