Skip to content

Commit e05b8a9

Browse files
authored
pbkdf2: add PHC hash support using password-hash crate (RustCrypto#82)
Implements the PHC string format for hashes, currently gated under the `include_simple` cargo feature. Specifics of how the format is encoded/decoded are modeled off of the implementation of PHC hashes for PBKDF2 implemented by Auth0. See this thread for more information: https://community.auth0.com/t/bulk-user-import-custom-password-hash-issue/47408/5
1 parent e43df28 commit e05b8a9

File tree

16 files changed

+392
-53
lines changed

16 files changed

+392
-53
lines changed

.github/workflows/bcrypt-pbkdf.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
strategy:
2323
matrix:
2424
rust:
25-
- 1.41.0 # MSRV
25+
- 1.47.0 # MSRV
2626
- stable
2727
target:
2828
- thumbv7em-none-eabi
@@ -42,7 +42,7 @@ jobs:
4242
strategy:
4343
matrix:
4444
rust:
45-
- 1.41.0 # MSRV
45+
- 1.47.0 # MSRV
4646
- stable
4747
steps:
4848
- uses: actions/checkout@v1

.github/workflows/pbkdf2.yml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
strategy:
2323
matrix:
2424
rust:
25-
- 1.41.0 # MSRV
25+
- 1.47.0 # MSRV
2626
- stable
2727
target:
2828
- thumbv7em-none-eabi
@@ -35,14 +35,14 @@ jobs:
3535
toolchain: ${{ matrix.rust }}
3636
target: ${{ matrix.target }}
3737
override: true
38-
- run: cargo build --no-default-features --release --target ${{ matrix.target }}
38+
- run: cargo build --target ${{ matrix.target }} --release --no-default-features
3939

4040
test:
4141
runs-on: ubuntu-latest
4242
strategy:
4343
matrix:
4444
rust:
45-
- 1.41.0 # MSRV
45+
- 1.47.0 # MSRV
4646
- stable
4747
steps:
4848
- uses: actions/checkout@v1
@@ -52,5 +52,9 @@ jobs:
5252
toolchain: ${{ matrix.rust }}
5353
override: true
5454
- run: cargo test --release --no-default-features
55-
- run: cargo test --release --features parallel
5655
- run: cargo test --release
56+
- run: cargo test --release --features include_simple
57+
- run: cargo test --release --features parallel
58+
- run: cargo test --release --features sha1
59+
- run: cargo test --release --features include_simple,sha1
60+
- run: cargo test --release --all-features

.github/workflows/scrypt.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
strategy:
2323
matrix:
2424
rust:
25-
- 1.41.0 # MSRV
25+
- 1.47.0 # MSRV
2626
- stable
2727
target:
2828
- thumbv7em-none-eabi
@@ -42,7 +42,7 @@ jobs:
4242
strategy:
4343
matrix:
4444
rust:
45-
- 1.41.0 # MSRV
45+
- 1.47.0 # MSRV
4646
- stable
4747
steps:
4848
- uses: actions/checkout@v1

.github/workflows/workspace.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
- uses: actions-rs/toolchain@v1
1818
with:
1919
profile: minimal
20-
toolchain: 1.41.0 # MSRV
20+
toolchain: 1.47.0 # MSRV
2121
components: clippy
2222
- run: cargo clippy --all -- -D warnings
2323

Cargo.lock

Lines changed: 24 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,6 @@ members = [
55
"scrypt",
66
"sha-crypt"
77
]
8+
9+
[patch.crates-io]
10+
password-hash = { git = "https://github.com/rustcrypto/traits" }

bcrypt-pbkdf/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ readme = "README.md"
1313
[dependencies]
1414
blowfish = { version = "0.7", features = ["bcrypt"] }
1515
crypto-mac = "0.10"
16-
pbkdf2 = { version = "0.6.0", default-features = false, path = "../pbkdf2" }
16+
pbkdf2 = { version = "=0.7.0-pre", default-features = false, path = "../pbkdf2" }
1717
sha2 = { version = "0.9", default-features = false }
1818
zeroize = { version = "1", default-features = false }
1919

bcrypt-pbkdf/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Pure Rust implementation of the bcrypt-pbkdf password-based key derivation funct
1313

1414
## Minimum Supported Rust Version
1515

16-
Rust **1.41** or higher.
16+
Rust **1.47** or higher.
1717

1818
Minimum supported Rust version can be changed in the future, but it will be
1919
done with a minor version bump.
@@ -45,7 +45,7 @@ dual licensed as above, without any additional terms or conditions.
4545
[docs-image]: https://docs.rs/bcrypt-pbkdf/badge.svg
4646
[docs-link]: https://docs.rs/bcrypt-pbkdf/
4747
[license-image]: https://img.shields.io/badge/license-Apache2.0/MIT-blue.svg
48-
[rustc-image]: https://img.shields.io/badge/rustc-1.41+-blue.svg
48+
[rustc-image]: https://img.shields.io/badge/rustc-1.47+-blue.svg
4949
[chat-image]: https://img.shields.io/badge/zulip-join_chat-blue.svg
5050
[chat-link]: https://rustcrypto.zulipchat.com/#narrow/stream/260046-password-hashes
5151
[build-image]: https://github.com/RustCrypto/password-hashes/workflows/bcrypt-pbkdf/badge.svg?branch=master&event=push

pbkdf2/Cargo.toml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "pbkdf2"
3-
version = "0.6.0"
3+
version = "0.7.0-pre"
44
authors = ["RustCrypto Developers"]
55
license = "MIT OR Apache-2.0"
66
description = "Generic implementation of PBKDF2"
@@ -19,17 +19,24 @@ base64 = { version = "0.13", default-features = false, features = ["alloc"], opt
1919
rand = { version = "0.7", default-features = false, optional = true }
2020
rand_core = { version = "0.5", default-features = false, features = ["getrandom"], optional = true }
2121
hmac = { version = "0.10", default-features = false, optional = true }
22+
password-hash = { version = "0", default-features = false, features = ["alloc"], optional = true }
23+
sha1 = { version = "0.9", package = "sha-1", default-features = false, optional = true }
2224
sha2 = { version = "0.9", default-features = false, optional = true }
2325
subtle = { version = "2", default-features = false, optional = true }
2426

2527
[dev-dependencies]
28+
hex-literal = "0.3"
2629
hmac = "0.10"
27-
sha-1 = "0.9"
30+
sha1 = { version = "0.9", package = "sha-1" }
2831
sha2 = "0.9"
2932

3033
[features]
3134
default = ["include_simple", "thread_rng"]
3235
parallel = ["rayon", "std"]
33-
include_simple = ["sha2", "hmac", "rand_core", "base64", "subtle"]
36+
include_simple = ["sha2", "hmac", "password-hash", "rand_core", "base64", "subtle"]
3437
thread_rng = ["rand"]
3538
std = []
39+
40+
[package.metadata.docs.rs]
41+
all-features = true
42+
rustdoc-args = ["--cfg", "docsrs"]

pbkdf2/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Pure Rust implementation of the [Password-Based Key Derivation Function v2 (PBKD
1313

1414
## Minimum Supported Rust Version
1515

16-
Rust **1.41** or higher.
16+
Rust **1.47** or higher.
1717

1818
Minimum supported Rust version can be changed in the future, but it will be
1919
done with a minor version bump.
@@ -45,7 +45,7 @@ dual licensed as above, without any additional terms or conditions.
4545
[docs-image]: https://docs.rs/pbkdf2/badge.svg
4646
[docs-link]: https://docs.rs/pbkdf2/
4747
[license-image]: https://img.shields.io/badge/license-Apache2.0/MIT-blue.svg
48-
[rustc-image]: https://img.shields.io/badge/rustc-1.41+-blue.svg
48+
[rustc-image]: https://img.shields.io/badge/rustc-1.47+-blue.svg
4949
[chat-image]: https://img.shields.io/badge/zulip-join_chat-blue.svg
5050
[chat-link]: https://rustcrypto.zulipchat.com/#narrow/stream/260046-password-hashes
5151
[build-image]: https://github.com/RustCrypto/password-hashes/workflows/pbkdf2/badge.svg?branch=master&event=push

0 commit comments

Comments
 (0)