Skip to content

chore(deps): upgrade argon2 to 0.6 and scrypt to 0.12 - #176

Merged
WingZer0o merged 2 commits into
deps/rustcrypto-upgradesfrom
deps/168-password-hash-0.6
Nov 27, 2026
Merged

WingZer0o merged 2 commits into
deps/rustcrypto-upgradesfrom
deps/168-password-hash-0.6

Conversation

@WingZer0o

Copy link
Copy Markdown
Member

Summary

Moves the password hashers to password-hash 0.6 (digest 0.11, rand_core 0.10 / getrandom 0.4).

Crate Before After
argon2 0.5.3 0.6.0
scrypt 0.11.0 0.12.0
password-hash 0.5.0 0.6.1 (+ new phc 0.6.1)
salsa20 0.10.2 0.11.0

The lockfile also drops blake2 0.10, cipher 0.4, inout 0.1 and pbkdf2 0.12, which only the old crates pulled in.

  • argon2 / scrypt: password-hash 0.6 removed SaltString::generate(&mut OsRng); the hashers now call the crates' hash_password(password), which draws a 16-byte salt through getrandom (try_generate_salt). An RNG failure becomes CasError::PasswordHashingFailed instead of a panic.
  • scrypt 0.12 has no default features, so Cargo.toml enables phc and getrandom. The default cost (ln=17, r=8, p=1) and the 32-byte output are now pinned explicitly.
  • argon2 defaults are the same in 0.6 (Argon2id v19, m=19456, t=2, p=1, 32-byte output). The KDF constants were already pinned.
  • pbkdf2::derivation no longer borrows argon2's SaltString. It fills 16 bytes with getrandom::fill and returns their 22-character PHC "B64" salt string, the same length and format as before.
  • The argon2 KDF salt (generate_salt) stays on rand 0.8 (rand::rngs::OsRng); rand is Upgrade rand 0.8 to 0.10 (or replace it with getrandom 0.4) once the RustCrypto stack is migrated #172.
  • No public signature changes, so docs/EXAMPLES.md is unchanged.

Compatibility evidence

  • Before the change, on the base branch (argon2 0.5.3 / scrypt 0.11.0, the same hasher code as v0.7.1), I generated PHC strings with CASArgon::hash_password, CASArgon::hash_password_parameters(19, 2, 1, …), CASScrypt::hash_password and CASScrypt::hash_password_customized(…, 10, 8, 1). They are stored as literals in tests/password_hashers.rs.
  • argon2_verifies_hashes_from_earlier_releases / scrypt_verifies_hashes_from_earlier_releases: with the new crates, the correct password verifies and a wrong password doesn't, for all four.
  • default_parameters_are_unchanged: new hashes still carry $argon2id$v=19$m=19456,t=2,p=1$ / $scrypt$ln=17,r=8,p=1$, with a 22-char salt and a 43-char (32-byte) hash.
  • pbkdf2_derivation_salt_shape_is_unchanged: the salt is 22 B64 characters, matching what the base branch produced (e.g. wg24+3b29iyEXpdoMwBrWw).
  • No existing test vector or expected value was changed. argon2_verify_still_accepts_hashes_below_the_hashing_minimums builds its weak hash with the argon2 crate directly, so only its salt-generation call was updated to the 0.6 API.

Test results (Windows, local)

  • cargo build --release --locked: OK, no warnings
  • cargo test --release --locked: 232 passed, 0 failed (password_hashers: 39, including the 3 new tests; Wycheproof: 21; aes_kw: 14; pqc: 21)
  • cargo audit --deny unsound --deny yanked: clean

Stacking

This PR is stacked on #173 (digest 0.11) and based on deps/167-digest-0.11. Until #173 merges into deps/rustcrypto-upgrades, the diff here also shows #173's commit (20bf931).

Part of #168

🤖 Generated with Claude Code

WingZer0o and others added 2 commits November 27, 2026 11:04
Both move to password-hash 0.6 (digest 0.11, rand_core 0.10 / getrandom 0.4).

- argon2/scrypt: salts are now drawn by the crates' `hash_password`
  (password-hash's `try_generate_salt`, getrandom), so an RNG failure maps
  to CasError::PasswordHashingFailed instead of panicking.
- scrypt 0.12 has no default features: enable `phc` and `getrandom`.
  Pin the default cost (ln=17, r=8, p=1) and the 32-byte output explicitly.
- argon2 defaults (Argon2id v19, m=19456, t=2, p=1, 32-byte output) are
  unchanged in 0.6.
- pbkdf2::derivation generates 16 bytes with getrandom and returns their
  22-character PHC "B64" salt string, the same shape as before.
- argon2 KDF salt generation stays on rand 0.8 (rand is #172).

Adds regression tests that verify argon2 and scrypt PHC strings made by
cas-lib 0.7.1 (argon2 0.5.3 / scrypt 0.11.0), and tests that pin the
default parameters and the pbkdf2 salt shape.

Part of #168

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Resolve the adjacent-line Cargo.toml conflict: keep #175's getrandom comment
(now also naming PBKDF2 salts) and this branch's scrypt 0.12 line.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@WingZer0o
WingZer0o merged commit 6fa9f6a into deps/rustcrypto-upgrades Nov 27, 2026
5 checks passed
This was referenced Nov 27, 2026
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