Skip to content

password-hash: use phc crate#2116

Merged
tarcieri merged 1 commit intomasterfrom
password-hash/use-phc-crate
Dec 9, 2025
Merged

password-hash: use phc crate#2116
tarcieri merged 1 commit intomasterfrom
password-hash/use-phc-crate

Conversation

@tarcieri
Copy link
Member

@tarcieri tarcieri commented Dec 9, 2025

Replaces the phc submodule with a re-export of the phc crate, which was just extracted from the password-hash crate in RustCrypto/formats#2111.

A dependency on the crate is needed to make the blanket impl of PasswordVerifier for PasswordHasher work (notably the former is object safe, and a similar blanket impl can't be supported for MCF since algorithm-specific rules are required)

This also significantly simplifies the Error type now that it's only responsible for errors involving the traits, rather than errors from parsing password hashes.

@tarcieri tarcieri force-pushed the password-hash/use-phc-crate branch 6 times, most recently from 765821c to 6be13af Compare December 9, 2025 21:18
tarcieri added a commit to RustCrypto/password-hashes that referenced this pull request Dec 9, 2025
Companion PR to RustCrypto/traits#2116

The `phc` crate was recently extracted from the `password-hash` crate,
implementing the Password Hashing Competition (PHC) string format for
storing password hashes.

This also factored apart the error types so there are separate ones for
`phc::Error` and `password_hash::Error`, which is the primary source of
changes in this PR.
tarcieri added a commit to RustCrypto/password-hashes that referenced this pull request Dec 9, 2025
Companion PR to RustCrypto/traits#2116

The `phc` crate was recently extracted from the `password-hash` crate,
implementing the Password Hashing Competition (PHC) string format for
storing password hashes.

This also factored apart the error types so there are separate ones for
`phc::Error` and `password_hash::Error`, which is the primary source of
changes in this PR.
tarcieri added a commit to RustCrypto/password-hashes that referenced this pull request Dec 9, 2025
Companion PR to RustCrypto/traits#2116

The `phc` crate was recently extracted from the `password-hash` crate,
implementing the Password Hashing Competition (PHC) string format for
storing password hashes.

This also factored apart the error types so there are separate ones for
`phc::Error` and `password_hash::Error`, which is the primary source of
changes in this PR.
tarcieri added a commit to RustCrypto/password-hashes that referenced this pull request Dec 9, 2025
Companion PR to RustCrypto/traits#2116

The `phc` crate was recently extracted from the `password-hash` crate,
implementing the Password Hashing Competition (PHC) string format for
storing password hashes.

This also factored apart the error types so there are separate ones for
`phc::Error` and `password_hash::Error`, which is the primary source of
changes in this PR.
tarcieri added a commit to RustCrypto/password-hashes that referenced this pull request Dec 9, 2025
Companion PR to RustCrypto/traits#2116

The `phc` crate was recently extracted from the `password-hash` crate,
implementing the Password Hashing Competition (PHC) string format for
storing password hashes.

This also factored apart the error types so there are separate ones for
`phc::Error` and `password_hash::Error`, which is the primary source of
changes in this PR.
Replaces the `phc` submodule with a re-export of the `phc` crate.

A dependency on the crate is needed to make the blanket impl of
`PasswordVerifier` for `PasswordHasher` work (notably the former is
object safe, and a similar blanket impl can't be supported for MCF since
algorithm-specific rules are required)

This also significantly simplifies the `Error` type now that it's only
responsible for errors involving the traits, rather than errors from
parsing password hashes.
@tarcieri tarcieri force-pushed the password-hash/use-phc-crate branch from 6be13af to 42acd52 Compare December 9, 2025 23:09
@tarcieri tarcieri changed the title [WIP] password-hash: use phc crate password-hash: use phc crate Dec 9, 2025
@tarcieri tarcieri marked this pull request as ready for review December 9, 2025 23:09
Comment on lines +24 to +40
/// Output size invalid.
OutputSize,

/// Invalid named parameter.
ParamInvalid {
/// Parameter name.
name: &'static str,
},

/// Invalid parameters.
ParamsInvalid,

/// Invalid password.
PasswordInvalid,

/// Invalid salt.
SaltInvalid,
Copy link
Member Author

@tarcieri tarcieri Dec 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: several of these are significantly less fine-grained, notably you can't tell whether salts and outputs are too small or too big. Hopefully people can figure it out from context, though we may consider adding it back.

The ParamInvalid error should be a significant improvement in that it informs you exactly which parameter was invalid (although perhaps does a poor job of telling you why)

@tarcieri tarcieri merged commit 8b33a08 into master Dec 9, 2025
73 checks passed
@tarcieri tarcieri deleted the password-hash/use-phc-crate branch December 9, 2025 23:14
tarcieri added a commit to RustCrypto/password-hashes that referenced this pull request Dec 9, 2025
Companion PR to RustCrypto/traits#2116

The `phc` crate was recently extracted from the `password-hash` crate,
implementing the Password Hashing Competition (PHC) string format for
storing password hashes.

This also factored apart the error types so there are separate ones for
`phc::Error` and `password_hash::Error`, which is the primary source of
changes in this PR.
tarcieri added a commit to RustCrypto/password-hashes that referenced this pull request Dec 9, 2025
Companion PR to RustCrypto/traits#2116

The `phc` crate was recently extracted from the `password-hash` crate,
implementing the Password Hashing Competition (PHC) string format for
storing password hashes.

This also factored apart the error types so there are separate ones for
`phc::Error` and `password_hash::Error`, which is the primary source of
changes in this PR.
@tarcieri tarcieri mentioned this pull request Mar 9, 2026
tarcieri added a commit that referenced this pull request Mar 10, 2026
## Added
- Generic `H` param to traits to support multiple string formats e.g.
  PHC, MCF (#2110)
- Implement `From<phc::Error>` for `Error` (#2124)
- `rand_core` feature (#2126)
- Salt generating helper functions `(try_)generate_salt` (#2128)
- `Error::RngFailure` variant (#2337)

## Changed
- Edition changed to 2024 and MSRV bumped to 1.85 (#1759)
- Extract `CustomizedPasswordHasher` trait (#2105)
- Bump `getrandom` to v0.4 (#2258)

## Removed
- `Encoding` enum (#2102)
- PHC types moved to the `phc` crate, which is re-exported as
  `password_hash::phc` when the `phc` crate feature is enabled
  (#2103, #2116):
  - `Ident`
  - `Output`
  - `ParamsString`
  - `PasswordHash`
  - `PasswordHashString`
  - `Salt`
  - `SaltString`
  - `Value`
- `McfHasher` trait (#2334)
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