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.
This commit is contained in:
1 parent
32954c4eba
commit
9d36d3b81b
9 files changed
+163
-64
No files matched your search
+3
-2
@@ -31,8 +31,9 @@ class Random:
|
||||
Each call produces keystream under the current key/nonce and increments
|
||||
the nonce afterwards, so no output block is ever produced twice.
|
||||
|
||||
The primary way to create one is the cipher module's own random()
|
||||
helper, e.g. ``aeg.cipher("AEGIS-128X2").random()``.
|
||||
The primary way to get one is the cipher module's own random() helper,
|
||||
e.g. ``aeg.cipher("AEGIS-128X2").random()``, which returns a per-thread
|
||||
singleton (each thread gets its own OS-seeded generator; no locking).
|
||||
"""
|
||||
|
||||
def __init__(self, cipher, *, seed: Buffer | None = None):
|
||||
|
||||
Reference in new issue
Block a user