Add tests for all functions of each algorithm against AEGIS test vectors (JSON). Incremental updates are tested with randomized splits to catch a variety of errors.

This commit is contained in:
2025-11-06 19:56:12 +00:00
parent c16e785203
commit df6b1b2832
13 changed files with 979 additions and 0 deletions
+28
View File
@@ -0,0 +1,28 @@
import random
_rng = random.SystemRandom()
def random_split_bytes(data: bytes) -> list[bytes]:
"""Split ``data`` into one to a few random-sized chunks.
Keeps chunk sizes positive and varies the number of pieces between 1 and 4.
"""
if not data:
return [data]
if len(data) == 1:
return [data]
max_chunks = min(4, len(data))
chunks = _rng.randint(1, max_chunks)
if chunks == 1:
return [data]
cut_points = sorted(_rng.sample(range(1, len(data)), chunks - 1))
start = 0
parts = []
for stop in (*cut_points, len(data)):
parts.append(data[start:stop])
start = stop
return parts