axess-rng 0.2.0

Injectable cryptographically-secure RNG trait for deterministic simulation testing (DST). Production code depends on the `SecureRng` trait; tests inject `MockRng` (a seeded PRNG) for reproducible randomness in auth flows, token issuance, and key generation.
docs.rs failed to build axess-rng-0.2.0
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.

axess-rng

Version Status License

crates.io · docs.rs · GitHub

Injectable cryptographically-secure RNG trait for deterministic simulation testing (DST). Foundational primitive used by Axess and adjacent crates.

Production code depends on the SecureRng trait. Tests inject MockRng (a seeded PRNG) for reproducible randomness in auth flows, token issuance, and key generation; the same seed always produces the same byte stream.

Usage

use axess_rng::{MockRng, SecureRng, SystemRng};
use std::sync::Arc;

// Production: pulls from the OS CSPRNG.
let rng: Arc<dyn SecureRng> = Arc::new(SystemRng);

// Tests: deterministic seed.
let rng: Arc<dyn SecureRng> = Arc::new(MockRng::new(0xDEADBEEF));

let mut buf = [0u8; 32];
rng.fill_bytes(&mut buf);

SecureRng::fill_bytes(&self, …) uses interior mutability so Arc<dyn SecureRng> is dyn-compatible. MockRng serialises its seed under std::sync::Mutex so concurrent calls never produce colliding byte streams while single-threaded determinism is preserved.

Licence

Dual-licensed under MIT and Apache-2.0.