Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 0 additions & 15 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ members = [
"cipher",
"crypto-common",
"digest",
"password-hash",
"signature",
"signature/async",
"universal-hash",
Expand Down
6 changes: 3 additions & 3 deletions elliptic-curve/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#![no_std]
#![cfg_attr(docsrs, feature(doc_cfg))]
#![forbid(unsafe_code, clippy::unwrap_used)]
#![warn(missing_docs, rust_2018_idioms, unused_qualifications)]
#![doc = include_str!("../README.md")]
#![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",
html_root_url = "https://docs.rs/elliptic-curve/0.12.0-pre"
)]
#![doc = include_str!("../README.md")]
#![forbid(unsafe_code, clippy::unwrap_used)]
#![warn(missing_docs, rust_2018_idioms, unused_qualifications)]

//! ## Usage
//!
Expand Down
62 changes: 62 additions & 0 deletions password-hash/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion password-hash/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,16 @@ version = "0.4.0-pre" # Also update html_root_url in lib.rs when bumping this
authors = ["RustCrypto Developers"]
license = "MIT OR Apache-2.0"
readme = "README.md"
edition = "2018"
documentation = "https://docs.rs/password-hash"
repository = "https://github.com/RustCrypto/traits/tree/master/password-hash"
categories = ["cryptography", "no-std"]
keywords = ["crypt", "mcf", "password", "pbkdf", "phc"]
edition = "2021"
rust-version = "1.57"

# Hack to allow this crate to coexist with pre-2021 edition crates
[workspace]
members = ["."]

[dependencies]
base64ct = ">=1, <1.1.0"
Expand Down
25 changes: 19 additions & 6 deletions password-hash/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,23 @@

Traits which describe the functionality of [password hashing algorithms].

Includes a `no_std`-friendly implementation of the [PHC string format]
(a well-defined subset of the Modular Crypt Format a.k.a. MCF) which
uses the traits this crate defines.
[Documentation][docs-link]

## About

Provides a `no_std`-friendly implementation of the
[Password Hashing Competition (PHC) string format specification][PHC]
(a well-defined subset of the [Modular Crypt Format a.k.a. MCF][MCF]) which
works in conjunction with the traits this crate defines.

## Supported Crates

See [RustCrypto/password-hashes] for algorithm implementations which use
these traits.
this crate for interoperability:

[Documentation][docs-link]
- [`argon2`] - Argon2 memory hard key derivation function
- [`pbkdf2`] - Password-Based Key Derivation Function v2
- [`scrypt`] - scrypt key derivation function

## Minimum Supported Rust Version

Expand Down Expand Up @@ -61,5 +70,9 @@ dual licensed as above, without any additional terms or conditions.
[//]: # (general links)

[password hashing algorithms]: https://en.wikipedia.org/wiki/Cryptographic_hash_function#Password_verification
[PHC string format]: https://github.com/P-H-C/phc-string-format/blob/master/phc-sf-spec.md
[PHC]: https://github.com/P-H-C/phc-string-format/blob/master/phc-sf-spec.md
[MCF]: https://passlib.readthedocs.io/en/stable/modular_crypt_format.html
[RustCrypto/password-hashes]: https://github.com/RustCrypto/password-hashes
[`argon2`]: https://docs.rs/argon2
[`pbkdf2`]: https://docs.rs/pbkdf2
[`scrypt`]: https://docs.rs/scrypt
3 changes: 1 addition & 2 deletions password-hash/src/ident.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
//! [1]: https://github.com/P-H-C/phc-string-format/blob/master/phc-sf-spec.md

use crate::{Error, Result};
use core::{convert::TryFrom, fmt, ops::Deref, str};
use core::{fmt, ops::Deref, str};

/// Algorithm or parameter identifier.
///
Expand Down Expand Up @@ -151,7 +151,6 @@ const fn is_char_valid(c: u8) -> bool {
#[cfg(test)]
mod tests {
use super::{Error, Ident};
use core::convert::TryFrom;

// Invalid ident examples
const INVALID_EMPTY: &str = "";
Expand Down
50 changes: 12 additions & 38 deletions password-hash/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
//! This crate defines a set of traits which describe the functionality of
//! [password hashing algorithms].
//!
//! Provides a `no_std`-friendly implementation of the
//! [Password Hashing Competition (PHC) string format specification][PHC]
//! (a well-defined subset of the [Modular Crypt Format a.k.a. MCF][MCF]) which
//! works in conjunction with the traits this crate defines.
//!
//! # Supported Crates
//!
//! See [RustCrypto/password-hashes] for algorithm implementations which use
//! this crate for interoperability:
//!
//! - [`argon2`] - Argon2 memory hard key derivation function
//! - [`pbkdf2`] - Password-Based Key Derivation Function v2
//! - [`scrypt`] - scrypt key derivation function
#![no_std]
#![cfg_attr(docsrs, feature(doc_cfg))]
#![doc = include_str!("../README.md")]
#![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",
html_root_url = "https://docs.rs/password-hash/0.4.0-pre"
)]
#![forbid(unsafe_code)]
#![warn(missing_docs, rust_2018_idioms, unused_lifetimes)]

//!
//! # Usage
//!
Expand All @@ -25,24 +20,6 @@
//! ```
//!
//! For more information, please see the documentation for [`PasswordHash`].
//!
//! [password hashing algorithms]: https://en.wikipedia.org/wiki/Cryptographic_hash_function#Password_verification
//! [PHC]: https://github.com/P-H-C/phc-string-format/blob/master/phc-sf-spec.md
//! [MCF]: https://passlib.readthedocs.io/en/stable/modular_crypt_format.html
//! [RustCrypto/password-hashes]: https://github.com/RustCrypto/password-hashes
//! [`argon2`]: https://docs.rs/argon2
//! [`pbkdf2`]: https://docs.rs/pbkdf2
//! [`scrypt`]: https://docs.rs/scrypt

#![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",
html_root_url = "https://docs.rs/password-hash/0.4.0-pre"
)]
#![forbid(unsafe_code)]
#![warn(missing_docs, rust_2018_idioms, unused_lifetimes)]

#[cfg(feature = "alloc")]
extern crate alloc;
Expand Down Expand Up @@ -74,10 +51,7 @@ pub use crate::{
value::{Decimal, Value},
};

use core::{
convert::{TryFrom, TryInto},
fmt::{self, Debug},
};
use core::fmt::{self, Debug};

#[cfg(feature = "alloc")]
use alloc::{
Expand Down
2 changes: 1 addition & 1 deletion password-hash/src/output.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Outputs from password hashing functions.

use crate::{Encoding, Error, Result};
use core::{cmp::PartialEq, convert::TryFrom, fmt, str::FromStr};
use core::{cmp::PartialEq, fmt, str::FromStr};
use subtle::{Choice, ConstantTimeEq};

/// Output from password hashing functions, i.e. the "hash" or "digest"
Expand Down
3 changes: 1 addition & 2 deletions password-hash/src/params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use crate::{
Encoding, Error, Ident, Result,
};
use core::{
convert::{TryFrom, TryInto},
fmt::{self, Debug, Write},
iter::FromIterator,
str::{self, FromStr},
Expand Down Expand Up @@ -325,7 +324,7 @@ mod tests {

#[cfg(feature = "alloc")]
use alloc::string::ToString;
use core::{convert::TryFrom, str::FromStr};
use core::str::FromStr;

#[test]
fn add() {
Expand Down
5 changes: 1 addition & 4 deletions password-hash/src/salt.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
//! Salt string support.

use crate::{Encoding, Error, Result, Value};
use core::{
convert::{TryFrom, TryInto},
fmt, str,
};
use core::{fmt, str};

use crate::errors::InvalidValue;
#[cfg(feature = "rand_core")]
Expand Down
5 changes: 1 addition & 4 deletions password-hash/src/traits.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
//! Trait definitions.

use crate::{Decimal, Error, Ident, ParamsString, PasswordHash, Result, Salt};
use core::{
convert::{TryFrom, TryInto},
fmt::Debug,
};
use core::fmt::Debug;

/// Trait for password hashing functions.
pub trait PasswordHasher {
Expand Down
3 changes: 1 addition & 2 deletions password-hash/src/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

use crate::errors::InvalidValue;
use crate::{Encoding, Error, Result};
use core::{convert::TryFrom, fmt, str};
use core::{fmt, str};

/// Type used to represent decimal (i.e. integer) values.
pub type Decimal = u32;
Expand Down Expand Up @@ -209,7 +209,6 @@ fn is_char_valid(c: char) -> bool {
#[cfg(test)]
mod tests {
use super::{Error, InvalidValue, Value};
use core::convert::TryFrom;

// Invalid value examples
const INVALID_CHAR: &str = "x;y";
Expand Down
1 change: 0 additions & 1 deletion password-hash/tests/hashing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
pub use password_hash::{
Decimal, Error, Ident, Output, ParamsString, PasswordHash, PasswordHasher, Result, Salt,
};
use std::convert::{TryFrom, TryInto};

const ALG: Ident = Ident::new("example");

Expand Down
1 change: 0 additions & 1 deletion password-hash/tests/password_hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
//! of the string encoding, and ensures password hashes round trip under each
//! of the conditions.

use core::convert::{TryFrom, TryInto};
use password_hash::{Ident, ParamsString, PasswordHash, Salt};

const EXAMPLE_ALGORITHM: Ident = Ident::new("argon2d");
Expand Down