summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_hashlib.py
diff options
context:
space:
mode:
authorJonathan Protzenko <protz@microsoft.com>2023-05-11 21:23:52 (GMT)
committerGitHub <noreply@github.com>2023-05-11 21:23:52 (GMT)
commit7d7dd4cd70ed997ed7c3cda867c4e7b1ab02b205 (patch)
tree7b3c764628c511fea4a1cf37991b546cb2127c48 /Lib/test/test_hashlib.py
parent0449ffe3a4ddf03367a5ee3d943c89f442b7b407 (diff)
downloadcpython-7d7dd4cd70ed997ed7c3cda867c4e7b1ab02b205.zip
cpython-7d7dd4cd70ed997ed7c3cda867c4e7b1ab02b205.tar.gz
cpython-7d7dd4cd70ed997ed7c3cda867c4e7b1ab02b205.tar.bz2
gh-99108: Refresh HACL* from upstream (#104401)
Refresh HACL* from upstream and add a SHA3 test hashing over 4GiB of data.
Diffstat (limited to 'Lib/test/test_hashlib.py')
-rw-r--r--Lib/test/test_hashlib.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/Lib/test/test_hashlib.py b/Lib/test/test_hashlib.py
index 08cb5eb..73d758a 100644
--- a/Lib/test/test_hashlib.py
+++ b/Lib/test/test_hashlib.py
@@ -359,6 +359,15 @@ class HashLibTestCase(unittest.TestCase):
h.update(b"hello world")
self.assertEqual(h.hexdigest(), "a5364f7a52ebe2e25f1838a4ca715a893b6fd7a23f2a0d9e9762120da8b1bf53")
+ @requires_resource('cpu')
+ def test_sha3_256_update_over_4gb(self):
+ zero_1mb = b"\0" * 1024 * 1024
+ h = hashlib.sha3_256()
+ for i in range(0, 4096):
+ h.update(zero_1mb)
+ h.update(b"hello world")
+ self.assertEqual(h.hexdigest(), "e2d4535e3b613135c14f2fe4e026d7ad8d569db44901740beffa30d430acb038")
+
def check(self, name, data, hexdigest, shake=False, **kwargs):
length = len(hexdigest)//2
hexdigest = hexdigest.lower()