From 78cb491de3726c35c799448dfb5c29e550c442a1 Mon Sep 17 00:00:00 2001 From: Benjamin Peterson Date: Wed, 24 Sep 2008 22:53:33 +0000 Subject: Merged revisions 66496 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r66496 | benjamin.peterson | 2008-09-17 20:22:16 -0500 (Wed, 17 Sep 2008) | 1 line fix possible integer overflows in _hashopenssl #3886 ........ --- Lib/test/test_hashlib.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'Lib/test/test_hashlib.py') diff --git a/Lib/test/test_hashlib.py b/Lib/test/test_hashlib.py index 912b1334c9..10fe3bea0f 100644 --- a/Lib/test/test_hashlib.py +++ b/Lib/test/test_hashlib.py @@ -9,7 +9,7 @@ import hashlib import unittest from test import support - +from test.support import _4G, precisionbigmemtest def hexstr(s): assert isinstance(s, bytes), repr(s) @@ -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() @@ -76,6 +75,21 @@ class HashLibTestCase(unittest.TestCase): b'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 -- cgit v1.2.1