Skip to content

chore(deps): remove the rand dependency - #186

Merged
WingZer0o merged 3 commits into
deps/remove-randfrom
deps/182-remove-rand
Nov 27, 2026
Merged

WingZer0o merged 3 commits into
deps/remove-randfrom
deps/182-remove-rand

Conversation

@WingZer0o

Copy link
Copy Markdown
Member

Summary

Nothing in src/ uses rand once #185 is in, so this drops rand = "0.8.6".

  • Cargo.toml: rand is removed. The comment on getrandom now says it is the crate's only OS RNG: rand_core 0.10 SysRng for RSA keys, and getrandom::fill / fill_uninit for Ed25519 keys, SLH-DSA seeds, AEAD keys and nonces, and Argon2 / PBKDF2 salts.
  • Cargo.lock: only removals: rand 0.8.6, rand_chacha 0.3.1, ppv-lite86 0.2.21, getrandom 0.2.17, wasi 0.11.1, zerocopy / zerocopy-derive 0.8.40. rand_core 0.6.4 loses its getrandom dependency, and zerocopy 0.7.35 references drop their version suffix because it's now the only zerocopy. No remaining crate changes version.
  • Tests: tests/kdf.rs and tests/password_hashers.rs now draw random inputs from getrandom::fill (already a normal dependency) instead of rand. Random passwords are still 20 alphanumeric characters, freshly random on each run: each random byte is mapped onto the 62-character alphabet by modulo, and the small bias is fine for test data. Vectors and expected values are unchanged, and rand isn't added back as a dev-dependency.
  • Docs and comments: CLAUDE.md (seal "draws the nonce internally via OsRng"), docs/EXAMPLES.md (symmetric keys "via OsRng"), and the panic docs in src/signatures/ed25519.rs and src/symmetric/aead_helpers.rs now name the OS random number generator (getrandom) instead of rand's OsRng. docs/EXAMPLES.md never used rand, so the examples still compile in a fresh crate that depends only on cas-lib.

Dependency tree (with #185 merged)

  • cargo tree -i rand and cargo tree -i rand_chacha: no matching package.
  • rand_core 0.6.4 is still there, but only through slh-dsa 0.0.3 and its signature 2.2.0. That's expected and goes away with Track slh-dsa 0.2.0 (currently 0.2.0-rc.5) #171.
  • getrandom 0.2: gone.
  • getrandom 0.3.4 is still there, but only as a build-time dependency (zstd → zstd-safe → zstd-sys [build] → cc → jobserver). It isn't linked into the library.
  • getrandom 0.4.3 is the runtime OS RNG (cas-lib, bcrypt, crypto-bigint, crypto-common, hpke, password-hash, phc, uuid, x25519-dalek).

Tests

I ran these on Windows, on a local scratch branch with #185 merged in:

  • cargo build --release --locked: passes with no warnings.
  • cargo test --release --locked: 243 passed, 0 failed, including Wycheproof (needs network). Per binary: lib 4, aead_seal 17, aes_gcm_siv 8, aes_kw 15, asymmetric 22, compression 13, hashers 21, hybrid 7, kdf 7, key_exchange 7, message 8, password_hashers 40, pqc 24, signatures 6, sponges 1, symmetric 14, wycheproof 21, zeroize 8.
  • cargo audit --deny unsound --deny yanked: clean.

Depends on #185

#185 (SLH-DSA keygen via getrandom) was not yet merged into deps/remove-rand when I pushed. src/pqc/slh_dsa.rs on the parent still uses rand, so CI on this PR fails until #185 lands. After that, this branch needs updating from deps/remove-rand. This PR contains only its own commit on top of the parent.

One follow-up once #185 is in: its generate_signing_and_verification_key doc comment still ends with "(and rand's OsRng)". It should be reworded like the Ed25519 one here. I left it alone so this PR doesn't conflict with #185.

Part of #182

🤖 Generated with Claude Code

WingZer0o and others added 3 commits November 27, 2026 11:35
Nothing in src/ uses rand any more: RSA keys come from getrandom's SysRng,
and Ed25519 keys, SLH-DSA seeds, AEAD keys and nonces, and Argon2/PBKDF2
salts from getrandom::fill / fill_uninit. Drop rand 0.8 from Cargo.toml;
Cargo.lock loses rand, rand_chacha, ppv-lite86, getrandom 0.2, wasi 0.11
and zerocopy 0.8 (removals only, no remaining crate changes version).

The HKDF and password-hasher tests draw their random inputs from getrandom
directly, with alphanumeric test passwords mapped from random bytes. Docs
and comments that said OsRng now name the OS random number generator.

Part of #182.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@WingZer0o

Copy link
Copy Markdown
Member Author

Update: #185 is now merged into deps/remove-rand, and the parent has been merged into this branch (fcb0e5c), so CI should now pass. Also added 371627c, which drops the stale "(and rand's OsRng)" from the SLH-DSA keygen panic docs to match the Ed25519 wording. Locally on Windows: build has no warnings, cargo test --release --locked 243 passed / 0 failed, cargo audit clean, and cargo tree -i rand finds nothing.

@WingZer0o
WingZer0o merged commit 7c4e2f6 into deps/remove-rand Nov 27, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant