chore: checkpoint before Python removal

This commit is contained in:
2026-03-26 22:33:59 +00:00
parent 683cec9307
commit e568ddf82a
29972 changed files with 11269302 additions and 2 deletions

1
vendor/pbkdf2/.cargo-checksum.json vendored Normal file
View File

@@ -0,0 +1 @@
{"files":{".cargo_vcs_info.json":"e5a0f21bd6f52b375183cf5ed97c568453e10d91c5786b57115e4f4d88fff911","CHANGELOG.md":"435bfe434509591c8aabe74b882233dc14c5f26d2c4ad42a4dcc92b9c5460b4e","Cargo.toml":"dd54bc4dc0f9bc8a75834d83d10c879767e0c9e5160feb2acf251cde21b48035","Cargo.toml.orig":"d25f01d79c2fb70eee2f764e98d96d61058e8b2133f17d5ec5e98075f24bb7d3","LICENSE-APACHE":"a9040321c3712d8fd0b09cf52b17445de04a23a10165049ae187cd39e5c86be5","LICENSE-MIT":"8ea5cea8ddecc46a64a004406414d25529fca7eb71cfd8c0cfe49c343bff79c5","README.md":"3fb689734697a8eabe63be4eb321e6bec679353eec1d3713384f1b8070da2f4f","benches/lib.rs":"0278abc364f75642eb5f1ab211fdc5dcd44f3ab28612c4f422e638998da0a509","src/lib.rs":"4c04c9b4daaafe69da4830982e96faa789078e267f05b963220638d2f6182fae","src/simple.rs":"6db7b4ab32a7c9773459d847069f60d2a14985db7e0c0ce322e91c16b1a2e7b7","tests/mod.rs":"b29b362cfd9a34cf66265873fbae07ef0da0ace59ca37229b18e5188c35fe377","tests/simple.rs":"1623bb65530ef2de6e93e518dbb32425e85a3b7b18b8fc0c1c117262aaa88ba9"},"package":"f8ed6a7761f76e3b9f92dfb0a60a6a6477c61024b775147ff0973a02653abaf2"}

6
vendor/pbkdf2/.cargo_vcs_info.json vendored Normal file
View File

@@ -0,0 +1,6 @@
{
"git": {
"sha1": "5af3bb038e73a9e9a1b95c7074f93ec78c66606d"
},
"path_in_vcs": "pbkdf2"
}

168
vendor/pbkdf2/CHANGELOG.md vendored Normal file
View File

@@ -0,0 +1,168 @@
# Changelog
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## 0.12.2 (2023-07-08)
### Fixed
- Use `RECOMMENDED_ROUNDS` in `Default` impl for `Params` ([#442])
[#442]: https://github.com/RustCrypto/password-hashes/pull/442
## 0.12.1 (2023-03-04)
### Changed
- Re-export `hmac` ([#397])
[#397]: https://github.com/RustCrypto/password-hashes/pull/397
## 0.12.0 (2023-03-04)
### Changed
- Add new wrapper functions: `pbkdf2_array`, `pbkdf2_hmac`, and
`pbkdf2_hmac_array`. `pbkdf2` and `pbkdf2_array` now return
`Result<(), InvalidLength>` instead of unwrapping it internally. ([#337])
- Use `sha1` dependency directly ([#363])
- Make `Ident` values inherent constants of `Algorithm` ([#375])
- Bump `password-hash` to v0.5 ([#383])
- Adopt OWASP recommended default `Params` ([#389])
### Removed
- `simple` feature is no longer enabled by default ([#336])
[#336]: https://github.com/RustCrypto/password-hashes/pull/336
[#337]: https://github.com/RustCrypto/password-hashes/pull/337
[#363]: https://github.com/RustCrypto/password-hashes/pull/363
[#375]: https://github.com/RustCrypto/password-hashes/pull/375
[#383]: https://github.com/RustCrypto/password-hashes/pull/383
[#389]: https://github.com/RustCrypto/password-hashes/pull/389
## 0.11.0 (2022-03-28)
### Changed
- Bump `password-hash` dependency to v0.4; MSRV 1.57 ([#283])
- 2021 edition upgrade ([#284])
[#283]: https://github.com/RustCrypto/password-hashes/pull/283
[#284]: https://github.com/RustCrypto/password-hashes/pull/284
## 0.10.1 (2022-02-17)
### Fixed
- Minimal versions build ([#273])
[#273]: https://github.com/RustCrypto/password-hashes/pull/273
## 0.10.0 (2021-11-25)
### Changed
- Migrate from `crypto-mac` to `digest` v0.10 ([#254])
[#254]: https://github.com/RustCrypto/password-hashes/pull/254
## 0.9.0 (2021-08-27)
### Added
- GOST test vectors ([#191])
### Changed
- Bump `password-hash` to v0.3 ([#217], [RustCrypto/traits#724])
- Use `resolver = "2"`; MSRV 1.51+ ([#220])
### Removed
- `McfHasher` impl on `Pbkdf2` ([#219])
[#191]: https://github.com/RustCrypto/password-hashing/pull/191
[#217]: https://github.com/RustCrypto/password-hashing/pull/217
[#219]: https://github.com/RustCrypto/password-hashing/pull/219
[#220]: https://github.com/RustCrypto/password-hashing/pull/220
[RustCrypto/traits#724]: https://github.com/RustCrypto/traits/pull/724
## 0.8.0 (2021-04-29)
### Changed
- Bump `password-hash` crate dependency to v0.2 ([#164])
- Bump `hmac` and `crypto-mac` crate deps to v0.11 ([#165])
[#164]: https://github.com/RustCrypto/password-hashing/pull/164
[#165]: https://github.com/RustCrypto/password-hashing/pull/165
## 0.7.5 (2021-03-27)
### Fixed
- Pin `password-hash` to v0.1.2 or newer ([#151])
[#151]: https://github.com/RustCrypto/password-hashing/pull/151
## 0.7.4 (2021-03-17)
### Changed
- Bump `base64ct` dependency to v1.0 ([#144])
[#144]: https://github.com/RustCrypto/password-hashing/pull/144
## 0.7.3 (2021-02-08)
### Changed
- Enable `rand_core` feature of `password-hash` ([#130])
[#130]: https://github.com/RustCrypto/password-hashing/pull/130
## 0.7.2 (2021-02-01)
### Changed
- Bump `base64ct` dependency to v0.2 ([#119])
[#119]: https://github.com/RustCrypto/password-hashing/pull/119
## 0.7.1 (2021-01-29)
### Removed
- `alloc` dependencies for `simple` feature ([#107])
[#107]: https://github.com/RustCrypto/password-hashing/pull/107
## 0.7.0 (2021-01-29)
### Added
- PHC hash format support using `password-hash` crate ([#82])
### Changed
- Rename `include_simple` features to `simple` ([#99])
### Removed
- Legacy `simple` API ([#98])
[#82]: https://github.com/RustCrypto/password-hashing/pull/82
[#98]: https://github.com/RustCrypto/password-hashing/pull/98
[#99]: https://github.com/RustCrypto/password-hashing/pull/99
## 0.6.0 (2020-10-18)
### Changed
- Bump `crypto-mac` dependency to v0.10 ([#58])
- Bump `hmac` dependency to v0.10 ([#58])
[#58]: https://github.com/RustCrypto/password-hashing/pull/58
## 0.5.0 (2020-08-18)
### Changed
- Bump `crypto-mac` dependency to v0.9 ([#44])
[#44]: https://github.com/RustCrypto/password-hashing/pull/44
## 0.4.0 (2020-06-10)
### Changed
- Code improvements ([#33])
- Bump `rand` dependency to v0.7 ([#31])
- Bump `hmac` to v0.8 ([#30])
- Bump `sha2` to v0.9 ([#30])
- Bump `subtle` to v2 ([#13])
- MSRV 1.41+ ([#30])
- Upgrade to Rust 2018 edition ([#24])
[#33]: https://github.com/RustCrypto/password-hashing/pull/33
[#31]: https://github.com/RustCrypto/password-hashing/pull/31
[#30]: https://github.com/RustCrypto/password-hashing/pull/30
[#24]: https://github.com/RustCrypto/password-hashing/pull/24
[#13]: https://github.com/RustCrypto/password-hashing/pull/13
## 0.3.0 (2018-10-08)
## 0.2.3 (2018-08-30)
## 0.2.2 (2018-08-15)
## 0.2.1 (2018-08-06)
## 0.2.0 (2018-03-30)
## 0.1.0 (2017-08-16)

97
vendor/pbkdf2/Cargo.toml vendored Normal file
View File

@@ -0,0 +1,97 @@
# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO
#
# When uploading crates to the registry Cargo will automatically
# "normalize" Cargo.toml files for maximal compatibility
# with all versions of Cargo and also rewrite `path` dependencies
# to registry (e.g., crates.io) dependencies.
#
# If you are reading this file be aware that the original Cargo.toml
# will likely look very different (and much more reasonable).
# See Cargo.toml.orig for the original contents.
[package]
edition = "2021"
rust-version = "1.60"
name = "pbkdf2"
version = "0.12.2"
authors = ["RustCrypto Developers"]
description = "Generic implementation of PBKDF2"
documentation = "https://docs.rs/pbkdf2"
readme = "README.md"
keywords = [
"crypto",
"hashing",
"password",
"phf",
]
categories = [
"authentication",
"cryptography",
"no-std",
]
license = "MIT OR Apache-2.0"
repository = "https://github.com/RustCrypto/password-hashes/tree/master/pbkdf2"
[package.metadata.docs.rs]
all-features = true
rustdoc-args = [
"--cfg",
"docsrs",
]
[dependencies.digest]
version = "0.10.7"
features = ["mac"]
[dependencies.hmac]
version = "0.12"
optional = true
default-features = false
[dependencies.password-hash]
version = "0.5"
features = ["rand_core"]
optional = true
default-features = false
[dependencies.rayon]
version = "1.7"
optional = true
[dependencies.sha1]
version = "0.10"
optional = true
default-features = false
[dependencies.sha2]
version = "0.10"
optional = true
default-features = false
[dev-dependencies.hex-literal]
version = "0.4.0"
[dev-dependencies.hmac]
version = "0.12"
[dev-dependencies.sha1]
version = "0.10"
[dev-dependencies.sha2]
version = "0.10"
[dev-dependencies.streebog]
version = "0.10"
[features]
default = ["hmac"]
parallel = [
"rayon",
"std",
]
simple = [
"hmac",
"password-hash",
"sha2",
]
std = ["password-hash/std"]

201
vendor/pbkdf2/LICENSE-APACHE vendored Normal file
View File

@@ -0,0 +1,201 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

26
vendor/pbkdf2/LICENSE-MIT vendored Normal file
View File

@@ -0,0 +1,26 @@
Copyright (c) 2017 Artyom Pavlov
Copyright (c) 2018-2023 The RustCrypto Project Developers
Permission is hereby granted, free of charge, to any
person obtaining a copy of this software and associated
documentation files (the "Software"), to deal in the
Software without restriction, including without
limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software
is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice
shall be included in all copies or substantial portions
of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.

56
vendor/pbkdf2/README.md vendored Normal file
View File

@@ -0,0 +1,56 @@
# RustCrypto: PBKDF2
[![crate][crate-image]][crate-link]
[![Docs][docs-image]][docs-link]
![Apache2/MIT licensed][license-image]
![Rust Version][rustc-image]
[![Project Chat][chat-image]][chat-link]
[![Build Status][build-image]][build-link]
Pure Rust implementation of the [Password-Based Key Derivation Function v2 (PBKDF2)][1].
[Documentation][docs-link]
## Minimum Supported Rust Version
Rust **1.60** or higher.
Minimum supported Rust version can be changed in the future, but it will be
done with a minor version bump.
## SemVer Policy
- All on-by-default features of this library are covered by SemVer
- MSRV is considered exempt from SemVer as noted above
## License
Licensed under either of:
* [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0)
* [MIT license](http://opensource.org/licenses/MIT)
at your option.
### Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted
for inclusion in the work by you, as defined in the Apache-2.0 license, shall be
dual licensed as above, without any additional terms or conditions.
[//]: # (badges)
[crate-image]: https://buildstats.info/crate/pbkdf2
[crate-link]: https://crates.io/crates/pbkdf2
[docs-image]: https://docs.rs/pbkdf2/badge.svg
[docs-link]: https://docs.rs/pbkdf2/
[license-image]: https://img.shields.io/badge/license-Apache2.0/MIT-blue.svg
[rustc-image]: https://img.shields.io/badge/rustc-1.51+-blue.svg
[chat-image]: https://img.shields.io/badge/zulip-join_chat-blue.svg
[chat-link]: https://rustcrypto.zulipchat.com/#narrow/stream/260046-password-hashes
[build-image]: https://github.com/RustCrypto/password-hashes/workflows/pbkdf2/badge.svg?branch=master&event=push
[build-link]: https://github.com/RustCrypto/password-hashes/actions?query=workflow%3Apbkdf2
[//]: # (general links)
[1]: https://en.wikipedia.org/wiki/PBKDF2

41
vendor/pbkdf2/benches/lib.rs vendored Normal file
View File

@@ -0,0 +1,41 @@
#![no_std]
#![feature(test)]
extern crate test;
use hmac::Hmac;
use pbkdf2::pbkdf2;
use test::Bencher;
#[bench]
pub fn pbkdf2_hmac_sha1_16384_20(bh: &mut Bencher) {
let password = b"my secure password";
let salt = b"salty salt";
let mut buf = [0u8; 20];
bh.iter(|| {
pbkdf2::<Hmac<sha1::Sha1>>(password, salt, 16_384, &mut buf);
test::black_box(&buf);
});
}
#[bench]
pub fn pbkdf2_hmac_sha256_16384_20(bh: &mut Bencher) {
let password = b"my secure password";
let salt = b"salty salt";
let mut buf = [0u8; 20];
bh.iter(|| {
pbkdf2::<Hmac<sha2::Sha256>>(password, salt, 16_384, &mut buf);
test::black_box(&buf);
});
}
#[bench]
pub fn pbkdf2_hmac_sha512_16384_20(bh: &mut Bencher) {
let password = b"my secure password";
let salt = b"salty salt";
let mut buf = [0u8; 20];
bh.iter(|| {
pbkdf2::<Hmac<sha2::Sha512>>(password, salt, 16_384, &mut buf);
test::black_box(&buf);
});
}

282
vendor/pbkdf2/src/lib.rs vendored Normal file
View File

@@ -0,0 +1,282 @@
//! This crate implements the PBKDF2 key derivation function as specified
//! in [RFC 2898](https://tools.ietf.org/html/rfc2898).
//!
//! # Examples
//!
//! PBKDF2 is defined in terms of a keyed pseudo-random function (PRF). Most
//! commonly HMAC is used as this PRF. In such cases you can use [`pbkdf2_hmac`]
//! and [`pbkdf2_hmac_array`] functions. The former accepts a byte slice which
//! gets filled with generated key, while the former returns an array with
//! generated key of requested length.
//!
//! ```
//! # #[cfg(feature = "hmac")] {
//! use hex_literal::hex;
//! use pbkdf2::{pbkdf2_hmac, pbkdf2_hmac_array};
//! use sha2::Sha256;
//!
//! let password = b"password";
//! let salt = b"salt";
//! // number of iterations
//! let n = 600_000;
//! // Expected value of generated key
//! let expected = hex!("669cfe52482116fda1aa2cbe409b2f56c8e45637");
//!
//! let mut key1 = [0u8; 20];
//! pbkdf2_hmac::<Sha256>(password, salt, n, &mut key1);
//! assert_eq!(key1, expected);
//!
//! let key2 = pbkdf2_hmac_array::<Sha256, 20>(password, salt, n);
//! assert_eq!(key2, expected);
//! # }
//! ```
//!
//! If you want to use a different PRF, then you can use [`pbkdf2`][crate::pbkdf2]
//! and [`pbkdf2_array`] functions.
//!
//! This crates also provides the high-level password-hashing API through
//! the [`Pbkdf2`] struct and traits defined in the
//! [`password-hash`][password_hash] crate.
//!
//! Add the following to your crate's `Cargo.toml` to import it:
//!
//! ```toml
//! [dependencies]
//! pbkdf2 = { version = "0.12", features = ["simple"] }
//! rand_core = { version = "0.6", features = ["std"] }
//! ```
//!
//! The following example demonstrates the high-level password hashing API:
//!
//! ```
//! # fn main() -> Result<(), Box<dyn std::error::Error>> {
//! # #[cfg(all(feature = "simple", feature = "std"))]
//! # {
//! use pbkdf2::{
//! password_hash::{
//! rand_core::OsRng,
//! PasswordHash, PasswordHasher, PasswordVerifier, SaltString
//! },
//! Pbkdf2
//! };
//!
//! let password = b"hunter42"; // Bad password; don't actually use!
//! let salt = SaltString::generate(&mut OsRng);
//!
//! // Hash password to PHC string ($pbkdf2-sha256$...)
//! let password_hash = Pbkdf2.hash_password(password, &salt)?.to_string();
//!
//! // Verify password against PHC string
//! let parsed_hash = PasswordHash::new(&password_hash)?;
//! assert!(Pbkdf2.verify_password(password, &parsed_hash).is_ok());
//! # }
//! # Ok(())
//! # }
//! ```
#![no_std]
#![cfg_attr(docsrs, feature(doc_cfg))]
#![doc(
html_logo_url = "https://raw.githubusercontent.com/RustCrypto/media/8f1a9894/logo.svg",
html_favicon_url = "https://raw.githubusercontent.com/RustCrypto/media/8f1a9894/logo.svg"
)]
#[cfg(feature = "std")]
extern crate std;
#[cfg(feature = "simple")]
extern crate alloc;
#[cfg(feature = "simple")]
#[cfg_attr(docsrs, doc(cfg(feature = "simple")))]
pub use password_hash;
#[cfg(feature = "simple")]
mod simple;
#[cfg(feature = "hmac")]
pub use hmac;
#[cfg(feature = "simple")]
pub use crate::simple::{Algorithm, Params, Pbkdf2};
#[cfg(feature = "parallel")]
use rayon::prelude::*;
use digest::{generic_array::typenum::Unsigned, FixedOutput, InvalidLength, KeyInit, Update};
#[cfg(feature = "hmac")]
use digest::{
block_buffer::Eager,
core_api::{BlockSizeUser, BufferKindUser, CoreProxy, FixedOutputCore, UpdateCore},
generic_array::typenum::{IsLess, Le, NonZero, U256},
HashMarker,
};
#[inline(always)]
fn xor(res: &mut [u8], salt: &[u8]) {
debug_assert!(salt.len() >= res.len(), "length mismatch in xor");
res.iter_mut().zip(salt.iter()).for_each(|(a, b)| *a ^= b);
}
#[inline(always)]
fn pbkdf2_body<PRF>(i: u32, chunk: &mut [u8], prf: &PRF, salt: &[u8], rounds: u32)
where
PRF: Update + FixedOutput + Clone,
{
for v in chunk.iter_mut() {
*v = 0;
}
let mut salt = {
let mut prfc = prf.clone();
prfc.update(salt);
prfc.update(&(i + 1).to_be_bytes());
let salt = prfc.finalize_fixed();
xor(chunk, &salt);
salt
};
for _ in 1..rounds {
let mut prfc = prf.clone();
prfc.update(&salt);
salt = prfc.finalize_fixed();
xor(chunk, &salt);
}
}
/// Generic implementation of PBKDF2 algorithm which accepts an arbitrary keyed PRF.
///
/// ```
/// use hex_literal::hex;
/// use pbkdf2::pbkdf2;
/// use hmac::Hmac;
/// use sha2::Sha256;
///
/// let mut buf = [0u8; 20];
/// pbkdf2::<Hmac<Sha256>>(b"password", b"salt", 600_000, &mut buf)
/// .expect("HMAC can be initialized with any key length");
/// assert_eq!(buf, hex!("669cfe52482116fda1aa2cbe409b2f56c8e45637"));
/// ```
#[inline]
pub fn pbkdf2<PRF>(
password: &[u8],
salt: &[u8],
rounds: u32,
res: &mut [u8],
) -> Result<(), InvalidLength>
where
PRF: KeyInit + Update + FixedOutput + Clone + Sync,
{
let n = PRF::OutputSize::to_usize();
// note: HMAC can be initialized with keys of any size,
// so this panic never happens with it
let prf = PRF::new_from_slice(password)?;
#[cfg(not(feature = "parallel"))]
{
for (i, chunk) in res.chunks_mut(n).enumerate() {
pbkdf2_body(i as u32, chunk, &prf, salt, rounds);
}
}
#[cfg(feature = "parallel")]
{
res.par_chunks_mut(n).enumerate().for_each(|(i, chunk)| {
pbkdf2_body(i as u32, chunk, &prf, salt, rounds);
});
}
Ok(())
}
/// A variant of the [`pbkdf2`][crate::pbkdf2] function which returns an array
/// instead of filling an input slice.
///
/// ```
/// use hex_literal::hex;
/// use pbkdf2::pbkdf2_array;
/// use hmac::Hmac;
/// use sha2::Sha256;
///
/// let res = pbkdf2_array::<Hmac<Sha256>, 20>(b"password", b"salt", 600_000)
/// .expect("HMAC can be initialized with any key length");
/// assert_eq!(res, hex!("669cfe52482116fda1aa2cbe409b2f56c8e45637"));
/// ```
#[inline]
pub fn pbkdf2_array<PRF, const N: usize>(
password: &[u8],
salt: &[u8],
rounds: u32,
) -> Result<[u8; N], InvalidLength>
where
PRF: KeyInit + Update + FixedOutput + Clone + Sync,
{
let mut buf = [0u8; N];
pbkdf2::<PRF>(password, salt, rounds, &mut buf).map(|()| buf)
}
/// A variant of the [`pbkdf2`][crate::pbkdf2] function which uses HMAC for PRF.
/// It's generic over (eager) hash functions.
///
/// ```
/// use hex_literal::hex;
/// use pbkdf2::pbkdf2_hmac;
/// use sha2::Sha256;
///
/// let mut buf = [0u8; 20];
/// pbkdf2_hmac::<Sha256>(b"password", b"salt", 600_000, &mut buf);
/// assert_eq!(buf, hex!("669cfe52482116fda1aa2cbe409b2f56c8e45637"));
/// ```
#[cfg(feature = "hmac")]
#[cfg_attr(docsrs, doc(cfg(feature = "hmac")))]
pub fn pbkdf2_hmac<D>(password: &[u8], salt: &[u8], rounds: u32, res: &mut [u8])
where
D: CoreProxy,
D::Core: Sync
+ HashMarker
+ UpdateCore
+ FixedOutputCore
+ BufferKindUser<BufferKind = Eager>
+ Default
+ Clone,
<D::Core as BlockSizeUser>::BlockSize: IsLess<U256>,
Le<<D::Core as BlockSizeUser>::BlockSize, U256>: NonZero,
{
crate::pbkdf2::<hmac::Hmac<D>>(password, salt, rounds, res)
.expect("HMAC can be initialized with any key length");
}
/// A variant of the [`pbkdf2_hmac`] function which returns an array
/// instead of filling an input slice.
///
/// ```
/// use hex_literal::hex;
/// use pbkdf2::pbkdf2_hmac_array;
/// use sha2::Sha256;
///
/// assert_eq!(
/// pbkdf2_hmac_array::<Sha256, 20>(b"password", b"salt", 600_000),
/// hex!("669cfe52482116fda1aa2cbe409b2f56c8e45637"),
/// );
/// ```
#[cfg(feature = "hmac")]
#[cfg_attr(docsrs, doc(cfg(feature = "hmac")))]
pub fn pbkdf2_hmac_array<D, const N: usize>(password: &[u8], salt: &[u8], rounds: u32) -> [u8; N]
where
D: CoreProxy,
D::Core: Sync
+ HashMarker
+ UpdateCore
+ FixedOutputCore
+ BufferKindUser<BufferKind = Eager>
+ Default
+ Clone,
<D::Core as BlockSizeUser>::BlockSize: IsLess<U256>,
Le<<D::Core as BlockSizeUser>::BlockSize, U256>: NonZero,
{
let mut buf = [0u8; N];
pbkdf2_hmac::<D>(password, salt, rounds, &mut buf);
buf
}

248
vendor/pbkdf2/src/simple.rs vendored Normal file
View File

@@ -0,0 +1,248 @@
//! Implementation of the `password-hash` crate API.
use crate::pbkdf2_hmac;
use core::{cmp::Ordering, fmt, str::FromStr};
use password_hash::{
errors::InvalidValue, Decimal, Error, Ident, Output, ParamsString, PasswordHash,
PasswordHasher, Result, Salt,
};
use sha2::{Sha256, Sha512};
#[cfg(feature = "sha1")]
use sha1::Sha1;
/// PBKDF2 type for use with [`PasswordHasher`].
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
#[cfg_attr(docsrs, doc(cfg(feature = "simple")))]
pub struct Pbkdf2;
impl PasswordHasher for Pbkdf2 {
type Params = Params;
fn hash_password_customized<'a>(
&self,
password: &[u8],
alg_id: Option<Ident<'a>>,
version: Option<Decimal>,
params: Params,
salt: impl Into<Salt<'a>>,
) -> Result<PasswordHash<'a>> {
let algorithm = Algorithm::try_from(alg_id.unwrap_or(Algorithm::default().ident()))?;
// Versions unsupported
if version.is_some() {
return Err(Error::Version);
}
let salt = salt.into();
let mut salt_arr = [0u8; 64];
let salt_bytes = salt.decode_b64(&mut salt_arr)?;
let output = Output::init_with(params.output_length, |out| {
let f = match algorithm {
#[cfg(feature = "sha1")]
Algorithm::Pbkdf2Sha1 => pbkdf2_hmac::<Sha1>,
Algorithm::Pbkdf2Sha256 => pbkdf2_hmac::<Sha256>,
Algorithm::Pbkdf2Sha512 => pbkdf2_hmac::<Sha512>,
};
f(password, salt_bytes, params.rounds, out);
Ok(())
})?;
Ok(PasswordHash {
algorithm: algorithm.ident(),
version: None,
params: params.try_into()?,
salt: Some(salt),
hash: Some(output),
})
}
}
/// PBKDF2 variants.
///
/// <https://en.wikipedia.org/wiki/PBKDF2>
#[derive(Copy, Clone, Debug, Eq, Hash, PartialEq, PartialOrd, Ord)]
#[non_exhaustive]
#[cfg_attr(docsrs, doc(cfg(feature = "simple")))]
pub enum Algorithm {
/// PBKDF2 SHA1
#[cfg(feature = "sha1")]
#[cfg_attr(docsrs, doc(cfg(feature = "sha1")))]
Pbkdf2Sha1,
/// PBKDF2 SHA-256
Pbkdf2Sha256,
/// PBKDF2 SHA-512
Pbkdf2Sha512,
}
impl Default for Algorithm {
/// Default suggested by the [OWASP cheat sheet]:
///
/// > Use PBKDF2 with a work factor of 600,000 or more and set with an
/// > internal hash function of HMAC-SHA-256.
///
/// [OWASP cheat sheet]: https://cheatsheetseries.owasp.org/cheatsheets/Password_Storage_Cheat_Sheet.html
fn default() -> Self {
Self::Pbkdf2Sha256
}
}
impl Algorithm {
/// PBKDF2 (SHA-1) algorithm identifier
#[cfg(feature = "sha1")]
pub const PBKDF2_SHA1_IDENT: Ident<'static> = Ident::new_unwrap("pbkdf2");
/// PBKDF2 (SHA-256) algorithm identifier
pub const PBKDF2_SHA256_IDENT: Ident<'static> = Ident::new_unwrap("pbkdf2-sha256");
/// PBKDF2 (SHA-512) algorithm identifier
pub const PBKDF2_SHA512_IDENT: Ident<'static> = Ident::new_unwrap("pbkdf2-sha512");
/// Parse an [`Algorithm`] from the provided string.
pub fn new(id: impl AsRef<str>) -> Result<Self> {
id.as_ref().parse()
}
/// Get the [`Ident`] that corresponds to this PBKDF2 [`Algorithm`].
pub fn ident(&self) -> Ident<'static> {
match self {
#[cfg(feature = "sha1")]
Algorithm::Pbkdf2Sha1 => Self::PBKDF2_SHA1_IDENT,
Algorithm::Pbkdf2Sha256 => Self::PBKDF2_SHA256_IDENT,
Algorithm::Pbkdf2Sha512 => Self::PBKDF2_SHA512_IDENT,
}
}
/// Get the identifier string for this PBKDF2 [`Algorithm`].
pub fn as_str(&self) -> &str {
self.ident().as_str()
}
}
impl AsRef<str> for Algorithm {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl fmt::Display for Algorithm {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str(self.as_str())
}
}
impl FromStr for Algorithm {
type Err = Error;
fn from_str(s: &str) -> Result<Algorithm> {
Ident::try_from(s)?.try_into()
}
}
impl From<Algorithm> for Ident<'static> {
fn from(alg: Algorithm) -> Ident<'static> {
alg.ident()
}
}
impl<'a> TryFrom<Ident<'a>> for Algorithm {
type Error = Error;
fn try_from(ident: Ident<'a>) -> Result<Algorithm> {
match ident {
#[cfg(feature = "sha1")]
Self::PBKDF2_SHA1_IDENT => Ok(Algorithm::Pbkdf2Sha1),
Self::PBKDF2_SHA256_IDENT => Ok(Algorithm::Pbkdf2Sha256),
Self::PBKDF2_SHA512_IDENT => Ok(Algorithm::Pbkdf2Sha512),
_ => Err(Error::Algorithm),
}
}
}
/// PBKDF2 params
#[cfg_attr(docsrs, doc(cfg(feature = "simple")))]
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
pub struct Params {
/// Number of rounds
pub rounds: u32,
/// Size of the output (in bytes)
pub output_length: usize,
}
impl Params {
/// Recommended number of PBKDF2 rounds (used by default).
///
/// This number is adopted from the [OWASP cheat sheet]:
///
/// > Use PBKDF2 with a work factor of 600,000 or more
///
/// [OWASP cheat sheet]: https://cheatsheetseries.owasp.org/cheatsheets/Password_Storage_Cheat_Sheet.html
pub const RECOMMENDED_ROUNDS: usize = 600_000;
}
impl Default for Params {
fn default() -> Params {
Params {
rounds: Self::RECOMMENDED_ROUNDS as u32,
output_length: 32,
}
}
}
impl<'a> TryFrom<&'a PasswordHash<'a>> for Params {
type Error = Error;
fn try_from(hash: &'a PasswordHash<'a>) -> Result<Self> {
let mut params = Params::default();
let mut output_length = None;
if hash.version.is_some() {
return Err(Error::Version);
}
for (ident, value) in hash.params.iter() {
match ident.as_str() {
"i" => params.rounds = value.decimal()?,
"l" => {
output_length = Some(
value
.decimal()?
.try_into()
.map_err(|_| InvalidValue::Malformed.param_error())?,
)
}
_ => return Err(Error::ParamNameInvalid),
}
}
if let Some(len) = output_length {
if let Some(hash) = &hash.hash {
match hash.len().cmp(&len) {
Ordering::Less => return Err(InvalidValue::TooShort.param_error()),
Ordering::Greater => return Err(InvalidValue::TooLong.param_error()),
Ordering::Equal => (),
}
}
params.output_length = len;
}
Ok(params)
}
}
impl<'a> TryFrom<Params> for ParamsString {
type Error = Error;
fn try_from(input: Params) -> Result<ParamsString> {
let mut output = ParamsString::new();
output.add_decimal("i", input.rounds)?;
output.add_decimal("l", input.output_length as u32)?;
Ok(output)
}
}

Binary file not shown.

View File

View File

@@ -0,0 +1 @@
{"name":"pbkdf2","vers":"0.12.2","deps":[{"name":"digest","req":"^0.10.7","features":["mac"],"optional":false,"default_features":true,"target":null,"kind":"normal","registry":"https://github.com/rust-lang/crates.io-index","package":null,"public":null,"artifact":null,"bindep_target":null,"lib":false},{"name":"hmac","req":"^0.12","features":[],"optional":true,"default_features":false,"target":null,"kind":"normal","registry":"https://github.com/rust-lang/crates.io-index","package":null,"public":null,"artifact":null,"bindep_target":null,"lib":false},{"name":"password-hash","req":"^0.5","features":["rand_core"],"optional":true,"default_features":false,"target":null,"kind":"normal","registry":"https://github.com/rust-lang/crates.io-index","package":null,"public":null,"artifact":null,"bindep_target":null,"lib":false},{"name":"rayon","req":"^1.7","features":[],"optional":true,"default_features":true,"target":null,"kind":"normal","registry":"https://github.com/rust-lang/crates.io-index","package":null,"public":null,"artifact":null,"bindep_target":null,"lib":false},{"name":"sha1","req":"^0.10","features":[],"optional":true,"default_features":false,"target":null,"kind":"normal","registry":"https://github.com/rust-lang/crates.io-index","package":null,"public":null,"artifact":null,"bindep_target":null,"lib":false},{"name":"sha2","req":"^0.10","features":[],"optional":true,"default_features":false,"target":null,"kind":"normal","registry":"https://github.com/rust-lang/crates.io-index","package":null,"public":null,"artifact":null,"bindep_target":null,"lib":false},{"name":"hex-literal","req":"^0.4.0","features":[],"optional":false,"default_features":true,"target":null,"kind":"dev","registry":"https://github.com/rust-lang/crates.io-index","package":null,"public":null,"artifact":null,"bindep_target":null,"lib":false},{"name":"hmac","req":"^0.12","features":[],"optional":false,"default_features":true,"target":null,"kind":"dev","registry":"https://github.com/rust-lang/crates.io-index","package":null,"public":null,"artifact":null,"bindep_target":null,"lib":false},{"name":"sha1","req":"^0.10","features":[],"optional":false,"default_features":true,"target":null,"kind":"dev","registry":"https://github.com/rust-lang/crates.io-index","package":null,"public":null,"artifact":null,"bindep_target":null,"lib":false},{"name":"sha2","req":"^0.10","features":[],"optional":false,"default_features":true,"target":null,"kind":"dev","registry":"https://github.com/rust-lang/crates.io-index","package":null,"public":null,"artifact":null,"bindep_target":null,"lib":false},{"name":"streebog","req":"^0.10","features":[],"optional":false,"default_features":true,"target":null,"kind":"dev","registry":"https://github.com/rust-lang/crates.io-index","package":null,"public":null,"artifact":null,"bindep_target":null,"lib":false}],"features":{"default":["hmac"],"parallel":["rayon","std"],"simple":["hmac","password-hash","sha2"],"std":["password-hash/std"]},"features2":null,"cksum":"b183fe4a4f9a398a01ea90524bd5504ad73e3042e7b08a6e889b81db6298720b","yanked":null,"links":null,"rust_version":null,"v":2}

Binary file not shown.

117
vendor/pbkdf2/tests/mod.rs vendored Normal file
View File

@@ -0,0 +1,117 @@
#![cfg(feature = "hmac")]
use hex_literal::hex;
use pbkdf2::pbkdf2_hmac_array as f;
use sha1::Sha1;
use streebog::Streebog512;
/// Tests from RFC 6070:
/// https://www.rfc-editor.org/rfc/rfc6070
#[test]
fn rfc6070() {
assert_eq!(
f::<Sha1, 20>(b"password", b"salt", 1),
hex!("0c60c80f961f0e71f3a9b524af6012062fe037a6"),
);
assert_eq!(
f::<Sha1, 20>(b"password", b"salt", 2),
hex!("ea6c014dc72d6f8ccd1ed92ace1d41f0d8de8957"),
);
assert_eq!(
f::<Sha1, 20>(b"password", b"salt", 4096),
hex!("4b007901b765489abead49d926f721d065a429c1"),
);
// this test passes, but takes a long time to execute
/*
assert_eq!(
f::<Sha1, 20>(b"password", b"salt", 16777216),
hex!("eefe3d61cd4da4e4e9945b3d6ba2158c2634e984"),
);
*/
assert_eq!(
f::<Sha1, 25>(
b"passwordPASSWORDpassword",
b"saltSALTsaltSALTsaltSALTsaltSALTsalt",
4096
),
hex!("3d2eec4fe41c849b80c8d83662c0e44a8b291a964cf2f07038"),
);
assert_eq!(
f::<Sha1, 16>(b"pass\0word", b"sa\0lt", 4096),
hex!("56fa6aa75548099dcc37d7f03425e0c3"),
);
}
/// Test vectors from R 50.1.111-2016:
/// https://tc26.ru/standard/rs/Р 50.1.111-2016.pdf
#[test]
fn gost() {
assert_eq!(
f::<Streebog512, 64>(b"password", b"salt", 1),
hex!(
"64770af7f748c3b1c9ac831dbcfd85c2"
"6111b30a8a657ddc3056b80ca73e040d"
"2854fd36811f6d825cc4ab66ec0a68a4"
"90a9e5cf5156b3a2b7eecddbf9a16b47"
),
);
assert_eq!(
f::<Streebog512, 64>(b"password", b"salt", 2),
hex!(
"5a585bafdfbb6e8830d6d68aa3b43ac0"
"0d2e4aebce01c9b31c2caed56f0236d4"
"d34b2b8fbd2c4e89d54d46f50e47d45b"
"bac301571743119e8d3c42ba66d348de"
),
);
assert_eq!(
f::<Streebog512, 64>(b"password", b"salt", 4096),
hex!(
"e52deb9a2d2aaff4e2ac9d47a41f34c2"
"0376591c67807f0477e32549dc341bc7"
"867c09841b6d58e29d0347c996301d55"
"df0d34e47cf68f4e3c2cdaf1d9ab86c3"
),
);
// this test passes, but takes a long time to execute
/*
assert_eq!(
f::<Streebog512, 64>(b"password", b"salt", 16777216),
hex!(
"49e4843bba76e300afe24c4d23dc7392"
"def12f2c0e244172367cd70a8982ac36"
"1adb601c7e2a314e8cb7b1e9df840e36"
"ab5615be5d742b6cf203fb55fdc48071"
),
);
*/
assert_eq!(
f::<Streebog512, 100>(
b"passwordPASSWORDpassword",
b"saltSALTsaltSALTsaltSALTsaltSALTsalt",
4096,
),
hex!(
"b2d8f1245fc4d29274802057e4b54e0a"
"0753aa22fc53760b301cf008679e58fe"
"4bee9addcae99ba2b0b20f431a9c5e50"
"f395c89387d0945aedeca6eb4015dfc2"
"bd2421ee9bb71183ba882ceebfef259f"
"33f9e27dc6178cb89dc37428cf9cc52a"
"2baa2d3a"
),
);
assert_eq!(
f::<Streebog512, 64>(b"pass\0word", b"sa\0lt", 4096),
hex!(
"50df062885b69801a3c10248eb0a27ab"
"6e522ffeb20c991c660f001475d73a4e"
"167f782c18e97e92976d9c1d970831ea"
"78ccb879f67068cdac1910740844e830"
),
);
}

41
vendor/pbkdf2/tests/simple.rs vendored Normal file
View File

@@ -0,0 +1,41 @@
//! Tests for `password-hash` crate integration.
//!
//! PBKDF2-SHA256 vectors adapted from: https://stackoverflow.com/a/5136918
#![cfg(feature = "simple")]
use hex_literal::hex;
use pbkdf2::{
password_hash::{PasswordHasher, Salt},
Algorithm, Params, Pbkdf2,
};
const PASSWORD: &str = "password";
const SALT_B64: &str = "c2FsdA"; // "salt"
/// Test with `algorithm: None` - uses default PBKDF2-SHA256
#[test]
fn hash_with_default_algorithm() {
// Input:
// P = "password" (8 octets)
// S = "salt" (4 octets)
// c = 4096
// dkLen = 32
let salt = Salt::from_b64(SALT_B64).unwrap();
let params = Params {
rounds: 4096,
output_length: 32,
};
let hash = Pbkdf2
.hash_password_customized(PASSWORD.as_bytes(), None, None, params, salt)
.unwrap();
assert_eq!(hash.algorithm, Algorithm::Pbkdf2Sha256.ident());
assert_eq!(hash.salt.unwrap().as_str(), SALT_B64);
assert_eq!(Params::try_from(&hash).unwrap(), params);
let expected_output = hex!("c5e478d59288c841aa530db6845c4c8d962893a001ce4e11a4963873aa98134a");
assert_eq!(hash.hash.unwrap().as_ref(), expected_output);
}