Commit Graph
15 Commits
Author SHA1 Message Date
LeoVasanko 9d36d3b81b random(): per-thread singleton; random_key/random_nonce use it
Each cipher module's random() now returns a thread-local Random that is
created on first use and reused thereafter. Each thread gets its own
OS-seeded generator (own key+nonce), so no locking and no cross-thread
nonce collisions. random_key() and random_nonce() draw from this CSPRNG
instead of secrets.token_bytes, making them as fast as the stream.
Changes made in the aegis256x4.py template and regenerated.
2026-10-04 15:42:02 +00:00
LeoVasanko 32954c4eba aeg.raf: StreamStorage adapter; accept io.BytesIO directly
StreamStorage wraps any seek-based file-like object using the same
lock + seek/read/write pattern as FileStorage's fallback for platforms
without pread/pwrite. create()/open() auto-wrap io.BytesIO, so in-memory
use no longer requires the explicit BytesIOStorage wrapper. The caller
keeps ownership of the stream (Raf does not close it).
2026-10-04 14:30:59 +00:00
LeoVasanko faa24cf22e Add aeg.securebuf.SecureBuffer: locked, wipe-on-close memory
mmap-backed buffer locked against swapping (mlock/VirtualLock) and
excluded from core dumps (MADV_DONTDUMP) where available, wiped on
close. Not used for return values; intended as an 'into' target (and
key input) to keep sensitive material out of the regular heap.
Adapted from quantumpipe's securebuf module.
2026-10-04 05:44:04 +00:00
LeoVasanko e01d84a560 Add RAF (random-access encrypted file) support and aeg.random CSPRNG
Implement Python bindings for the libaegis 0.10.6 RAF API:

- Thin per-variant wrappers (raf_create/open/read/write/truncate/size/
  sync/close, merkle_rebuild/verify/commitment) generated from a template
  in tools/generate.py, with errno-mapped exceptions.
- aeg.raf: high-level file-like API (Raf, create/open/probe,
  derive_master_key) with pluggable Storage backends (FileStorage,
  BytesIOStorage) and Merkle tree integrity via a MerkleHasher protocol
  (SHA256MerkleHasher default), adapted from pyaegis (MIT).
- aeg.random: CSPRNG facility. Random produces AEGIS keystream seeded
  once from the OS, exposed per cipher module as cipher.random() and
  usable as the RAF RNG (as_raf_rng) or standalone RandomSource.
- Tests: roundtrip/random-access/seek/truncate/Merkle coverage for all
  six variants, pyaegis-style API checks, and a Merkle fuzz test.
2026-10-04 04:25:59 +00:00
LeoVasanko bd8b183e32 Project renamed to aeg, preparing for PyPI release. 2025-12-23 18:25:03 +00:00
LeoVasanko d9a18f43d5 Ruff formatting. 2025-11-12 23:43:04 +00:00
LeoVasanko 0d63844201 Make Mac class prevent further updates or final after finalisation. Keep cached values for hashlib API. 2025-11-09 20:53:19 +00:00
LeoVasanko 7682d5bc8b Cleanup 2025-11-09 08:39:41 +00:00
LeoVasanko 26b883ecbc Simplify implementation: remove bytes_in and bytes_out counters from all classes. 2025-11-09 08:09:26 +00:00
LeoVasanko eed36e2463 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.
2025-11-09 06:53:27 +00:00
LeoVasanko cca78f4224 API cleanup for simplified update/final. Returns bytearrays when into is not used. Allows into buffers larger than needed. Misc other changes. 2025-11-07 07:38:18 +00:00
LeoVasanko 5c04940525 Include zig build in the build process. 2025-11-07 04:43:54 +00:00
LeoVasanko 56b451ac0c Test cleanup, remove debug. 2025-11-07 04:33:51 +00:00
LeoVasanko 0ae8752666 Rename module to pyaegis, implement build with zig. 2025-11-06 21:34:15 +00:00
LeoVasanko df6b1b2832 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. 2025-11-06 19:56:12 +00:00