diff options
author | Benjamin Peterson <benjamin@python.org> | 2008-09-18 01:22:16 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2008-09-18 01:22:16 (GMT) |
commit | 8c2b7dc46360f5610e25476c4dc0680ea3b06234 (patch) | |
tree | 82a11fe0991ba2d04666e86d94f0a5066f2a3f90 /Lib/test | |
parent | b8966ab7538c4a4739a78a93bdeee508ed663d53 (diff) | |
download | cpython-8c2b7dc46360f5610e25476c4dc0680ea3b06234.zip cpython-8c2b7dc46360f5610e25476c4dc0680ea3b06234.tar.gz cpython-8c2b7dc46360f5610e25476c4dc0680ea3b06234.tar.bz2 |
fix possible integer overflows in _hashopenssl #3886
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_hashlib.py | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/Lib/test/test_hashlib.py b/Lib/test/test_hashlib.py index cfb94e2..b543fd0 100644 --- a/Lib/test/test_hashlib.py +++ b/Lib/test/test_hashlib.py @@ -9,7 +9,7 @@ import hashlib import unittest from test import test_support - +from test.test_support import _4G, precisionbigmemtest def hexstr(s): import string @@ -55,7 +55,6 @@ class HashLibTestCase(unittest.TestCase): m2.update(aas + bees + cees) self.assertEqual(m1.digest(), m2.digest()) - def check(self, name, data, digest): # test the direct constructors computed = getattr(hashlib, name)(data).hexdigest() @@ -75,6 +74,21 @@ class HashLibTestCase(unittest.TestCase): self.check('md5', 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789', 'd174ab98d277d9f5a5611c2c9f419d9f') + @precisionbigmemtest(size=_4G + 5, memuse=1) + def test_case_md5_huge(self, size): + if size == _4G + 5: + try: + self.check('md5', 'A'*size, 'c9af2dff37468ce5dfee8f2cfc0a9c6d') + except OverflowError: + pass # 32-bit arch + + @precisionbigmemtest(size=_4G - 1, memuse=1) + def test_case_md5_uintmax(self, size): + if size == _4G - 1: + try: + self.check('md5', 'A'*size, '28138d306ff1b8281f1a9067e1a1a2b3') + except OverflowError: + pass # 32-bit arch # use the three examples from Federal Information Processing Standards # Publication 180-1, Secure Hash Standard, 1995 April 17 |