[New-bugs-announce] [issue17891] Wrong MD5 calculation on really long strings and the Hashlib
Alonso Vidales
report at bugs.python.org
Thu May 2 10:08:09 CEST 2013
New submission from Alonso Vidales:
Taking part on a contest I found a bug working with a string of 6227020800 characters, all the characters are the 'a' char.
When I execute:
hashlib.md5(string).hexdigest()
On Python, is takes a pair of seconds (need more to calculate this md5, I think that it crashes without launch any exception), and returns the hash:
8adbd18519be193db41dd5341a260963
When I execute the same code using Pypy the hash is:
38fe0c01bfa0eb9d153b034f8408a8b7
In order to know witch one is the correct hash, I created a file with 6227020800 characters on my system and I executed the "md5" of OpenSSL, I think that we can trust on it, obtaining the same result as Pypy:
unknown7cd1c3ecbb9b:Downloads socialpoint$ wc -c md5_test
6227020800 md5_test
unknown7cd1c3ecbb9b:Downloads socialpoint$ md5 md5_test
MD5 (md5_test) = 38fe0c01bfa0eb9d153b034f8408a8b7
Then Python are doing something wrong.
Pls, find attached a screenshot that shows the result of the tests. If you can't reproduce it, or need more information, please let me know.
My Python version:
Python 2.7.1 (r271:86832, Aug 5 2011, 03:30:24)
[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)] on darwin
Pypy version:
Python 2.7.2 (341e1e3821ff, Jun 07 2012, 15:42:54)
[PyPy 1.9.0 with GCC 4.2.1] on darwin
----------
components: Library (Lib)
files: Screen Shot 2013-05-02 at 3.13.48 AM.png
messages: 188255
nosy: Alonso.Vidales
priority: normal
severity: normal
status: open
title: Wrong MD5 calculation on really long strings and the Hashlib
type: security
versions: Python 2.7
Added file: http://bugs.python.org/file30103/Screen Shot 2013-05-02 at 3.13.48 AM.png
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue17891>
_______________________________________
More information about the New-bugs-announce
mailing list