API updates:

- Mac class follows hashlib API: digest functions added and finalization no longer modifies state.
- Encryptor and Decryptor now raise RuntimeError if still used after final.

Documentation updated with the changes and  further examples.

Tests updated with the changes, new test module for error cases (test_raises).

Docstrings improved.
This commit is contained in:
LeoVasanko committed 2025-11-09 06:53:27 +00:00
1 parent 46bc05f547
commit eed36e2463
11 files changed
+1191 -711

No files matched your search

+2 -2
View File
@@ -57,14 +57,14 @@ def bench_mac(ciph) -> None:
buf = bytearray(MSG_LEN)
buf[:] = _random_bytes(len(buf))
mac0 = ciph.Mac(key, nonce)
mac0 = ciph.Mac(key, nonce, maclen=ciph.MACBYTES_LONG)
mac_out = bytearray(ciph.MACBYTES_LONG)
t0 = time.perf_counter()
for _ in range(ITERATIONS):
mac = mac0.clone()
mac.update(buf)
mac.final(maclen=ciph.MACBYTES_LONG, into=mac_out)
mac.final(into=mac_out)
t1 = time.perf_counter()
_ = mac_out[0]