Repository navigation
chore(deps): remove the rand dependency - #186
Merged
Merged
Conversation
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>
Member
Author
|
Update: #185 is now merged into |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Nothing in
src/usesrandonce #185 is in, so this dropsrand = "0.8.6".randis removed. The comment ongetrandomnow says it is the crate's only OS RNG: rand_core 0.10SysRngfor RSA keys, andgetrandom::fill/fill_uninitfor Ed25519 keys, SLH-DSA seeds, AEAD keys and nonces, and Argon2 / PBKDF2 salts.rand0.8.6,rand_chacha0.3.1,ppv-lite860.2.21,getrandom0.2.17,wasi0.11.1,zerocopy/zerocopy-derive0.8.40.rand_core0.6.4 loses itsgetrandomdependency, andzerocopy 0.7.35references drop their version suffix because it's now the only zerocopy. No remaining crate changes version.tests/kdf.rsandtests/password_hashers.rsnow draw random inputs fromgetrandom::fill(already a normal dependency) instead ofrand. 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, andrandisn't added back as a dev-dependency.CLAUDE.md(seal"draws the nonce internally viaOsRng"),docs/EXAMPLES.md(symmetric keys "viaOsRng"), and the panic docs insrc/signatures/ed25519.rsandsrc/symmetric/aead_helpers.rsnow name the OS random number generator (getrandom) instead ofrand'sOsRng.docs/EXAMPLES.mdnever usedrand, so the examples still compile in a fresh crate that depends only on cas-lib.Dependency tree (with #185 merged)
cargo tree -i randandcargo tree -i rand_chacha: no matching package.rand_core0.6.4 is still there, but only throughslh-dsa0.0.3 and itssignature2.2.0. That's expected and goes away with Track slh-dsa 0.2.0 (currently 0.2.0-rc.5) #171.getrandom0.2: gone.getrandom0.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.getrandom0.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-randwhen I pushed.src/pqc/slh_dsa.rson the parent still usesrand, so CI on this PR fails until #185 lands. After that, this branch needs updating fromdeps/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_keydoc comment still ends with "(andrand'sOsRng)". 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