Skip to content

Commit 7d7dd4c

Browse files
authored
gh-99108: Refresh HACL* from upstream (#104401)
Refresh HACL* from upstream and add a SHA3 test hashing over 4GiB of data.
1 parent 0449ffe commit 7d7dd4c

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

Lib/test/test_hashlib.py

+9
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,15 @@ def test_sha256_update_over_4gb(self):
359359
h.update(b"hello world")
360360
self.assertEqual(h.hexdigest(), "a5364f7a52ebe2e25f1838a4ca715a893b6fd7a23f2a0d9e9762120da8b1bf53")
361361

362+
@requires_resource('cpu')
363+
def test_sha3_256_update_over_4gb(self):
364+
zero_1mb = b"\0" * 1024 * 1024
365+
h = hashlib.sha3_256()
366+
for i in range(0, 4096):
367+
h.update(zero_1mb)
368+
h.update(b"hello world")
369+
self.assertEqual(h.hexdigest(), "e2d4535e3b613135c14f2fe4e026d7ad8d569db44901740beffa30d430acb038")
370+
362371
def check(self, name, data, hexdigest, shake=False, **kwargs):
363372
length = len(hexdigest)//2
364373
hexdigest = hexdigest.lower()

Modules/_hacl/Hacl_Hash_SHA3.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ Hacl_Streaming_Keccak_update(Hacl_Streaming_Keccak_state *p, uint8_t *data, uint
244244
Hacl_Streaming_Keccak_hash_buf block_state = s.block_state;
245245
uint64_t total_len = s.total_len;
246246
Spec_Hash_Definitions_hash_alg i = block_state.fst;
247-
if ((uint64_t)len > (uint64_t)0xffffffffU - total_len)
247+
if ((uint64_t)len > (uint64_t)0xffffffffffffffffU - total_len)
248248
{
249249
return (uint32_t)1U;
250250
}

Modules/_hacl/refresh.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ fi
2222

2323
# Update this when updating to a new version after verifying that the changes
2424
# the update brings in are good.
25-
expected_hacl_star_rev=363eae2c2eb60e46f182ddd4bd1cd3f1d00b35c9
25+
expected_hacl_star_rev=b6903a3e6458000730c3d83174d4b08d6d3e2ece
2626

2727
hacl_dir="$(realpath "$1")"
2828
cd "$(dirname "$0")"

0 commit comments

Comments
 (0)