You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
security(keygen): use OsRng instead of thread_rng for cryptographic key generation
Replace thread_rng() with OsRng for SSH key generation, which provides
stronger security guarantees:
**Why OsRng is better:**
- Direct access to OS CSPRNG (not cached)
- Stateless (no internal state to leak)
- No fork-safety concerns
- Explicitly designed for cryptographic operations
**Why this change:**
- thread_rng() prioritizes performance over crypto guarantees
- rand 0.8 didn't clearly document crypto status of ThreadRng
- OsRng is the recommended RNG for SSH key generation
**Compatibility note:**
Cannot upgrade to rand 0.9 yet because ssh-key 0.6 requires rand_core 0.6.
The RustCrypto ecosystem is still migrating to rand_core 0.9. When ssh-key
releases a version compatible with rand_core 0.9, we can upgrade.
Changes:
- tools/ssh_keygen/src/main.rs: Use rand::rngs::OsRng (3 locations)
- tools/ssh_keygen/Cargo.toml: Add comment about rand 0.9 compatibility
Tests: All tests pass (3/3) with OsRng
0 commit comments