Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2021 edition upgrades #284

Merged
merged 1 commit into from
Mar 10, 2022
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
4 changes: 2 additions & 2 deletions .github/workflows/sha-crypt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
strategy:
matrix:
rust:
- 1.51.0 # MSRV
- 1.56.0 # MSRV
- stable
target:
- thumbv7em-none-eabi
Expand All @@ -48,7 +48,7 @@ jobs:
strategy:
matrix:
rust:
- 1.51.0 # MSRV
- 1.56.0 # MSRV
- stable
steps:
- uses: actions/checkout@v2
Expand Down
26 changes: 13 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ Collection of password hashing algorithms, otherwise known as password-based key

## Supported Algorithms

| Algorithm | Crate | Crates.io | Documentation | MSRV |
|-----------|------------------|:----------:|:-------------:|:----:|
| [Argon2] | [`argon2`] | [![crates.io](https://img.shields.io/crates/v/argon2.svg)](https://crates.io/crates/argon2) | [![Documentation](https://docs.rs/argon2/badge.svg)](https://docs.rs/argon2) | ![MSRV 1.51][msrv-1.51] |
| [Balloon] | [`balloon-hash`] | [![crates.io](https://img.shields.io/crates/v/balloon-hash.svg)](https://crates.io/crates/balloon-hash) | [![Documentation](https://docs.rs/balloon-hash/badge.svg)](https://docs.rs/balloon-hash) | ![MSRV 1.56][msrv-1.56] |
| [bcrypt-pbkdf] | [`bcrypt-pbkdf`] |[![crates.io](https://img.shields.io/crates/v/bcrypt-pbkdf.svg)](https://crates.io/crates/bcrypt-pbkdf) | [![Documentation](https://docs.rs/bcrypt-pbkdf/badge.svg)](https://docs.rs/bcrypt-pbkdf) | ![MSRV 1.56][msrv-1.56] |
| [PBKDF2] | [`pbkdf2`] | [![crates.io](https://img.shields.io/crates/v/pbkdf2.svg)](https://crates.io/crates/pbkdf2) | [![Documentation](https://docs.rs/pbkdf2/badge.svg)](https://docs.rs/pbkdf2) | ![MSRV 1.51][msrv-1.51] |
| [scrypt] | [`scrypt`] | [![crates.io](https://img.shields.io/crates/v/scrypt.svg)](https://crates.io/crates/scrypt) | [![Documentation](https://docs.rs/scrypt/badge.svg)](https://docs.rs/scrypt) | ![MSRV 1.56][msrv-1.56] |
| [SHA-crypt] | [`sha-crypt`] | [![crates.io](https://img.shields.io/crates/v/sha-crypt.svg)](https://crates.io/crates/sha-crypt) | [![Documentation](https://docs.rs/sha-crypt/badge.svg)](https://docs.rs/sha-crypt) | ![MSRV 1.51][msrv-1.51] |
| Algorithm | Crate | Crates.io | Documentation | MSRV |
|----------------|------------------|---------------------------------------------------------------------------------------------------------|---------------|-------------------------|
| [Argon2] | [`argon2`] | [![crates.io](https://img.shields.io/crates/v/argon2.svg)](https://crates.io/crates/argon2) | [![Documentation](https://docs.rs/argon2/badge.svg)](https://docs.rs/argon2) | ![MSRV 1.57][msrv-1.57] |
| [Balloon] | [`balloonhash`] | [![crates.io](https://img.shields.io/crates/v/balloon-hash.svg)](https://crates.io/crates/balloon-hash) | [![Documentation](https://docs.rs/balloon-hash/badge.svg)](https://docs.rs/balloon-hash) | ![MSRV 1.57][msrv-1.57] |
| [bcryptpbkdf] | [`bcryptpbkdf`] | [![crates.io](https://img.shields.io/crates/v/bcrypt-pbkdf.svg)](https://crates.io/crates/bcrypt-pbkdf) | [![Documentation](https://docs.rs/bcrypt-pbkdf/badge.svg)](https://docs.rs/bcrypt-pbkdf) | ![MSRV 1.57][msrv-1.57] |
| [PBKDF2] | [`pbkdf2`] | [![crates.io](https://img.shields.io/crates/v/pbkdf2.svg)](https://crates.io/crates/pbkdf2) | [![Documentation](https://docs.rs/pbkdf2/badge.svg)](https://docs.rs/pbkdf2) | ![MSRV 1.57][msrv-1.57] |
| [scrypt] | [`scrypt`] | [![crates.io](https://img.shields.io/crates/v/scrypt.svg)](https://crates.io/crates/scrypt) | [![Documentation](https://docs.rs/scrypt/badge.svg)](https://docs.rs/scrypt) | ![MSRV 1.57][msrv-1.57] |
| [SHA-crypt] | [`shacrypt`] | [![crates.io](https://img.shields.io/crates/v/sha-crypt.svg)](https://crates.io/crates/sha-crypt) | [![Documentation](https://docs.rs/sha-crypt/badge.svg)](https://docs.rs/sha-crypt) | ![MSRV 1.56][msrv-1.56] |

Please see the [OWASP Password Storage Cheat Sheet] for assistance in selecting an appropriate algorithm for your use case.

Expand Down Expand Up @@ -43,23 +43,23 @@ Unless you explicitly state otherwise, any contribution intentionally submitted
[license-image]: https://img.shields.io/badge/license-Apache2.0/MIT-blue.svg
[deps-image]: https://deps.rs/repo/github/RustCrypto/password-hashes/status.svg
[deps-link]: https://deps.rs/repo/github/RustCrypto/password-hashes
[msrv-1.51]: https://img.shields.io/badge/rustc-1.51.0+-blue.svg
[msrv-1.56]: https://img.shields.io/badge/rustc-1.56.0+-blue.svg
[msrv-1.57]: https://img.shields.io/badge/rustc-1.57.0+-blue.svg

[//]: # (crates)

[`argon2`]: ./argon2
[`balloon-hash`]: ./balloon-hash
[`bcrypt-pbkdf`]: ./bcrypt-pbkdf
[`balloonhash`]: ./balloon-hash
[`bcryptpbkdf`]: ./bcrypt-pbkdf
[`pbkdf2`]: ./pbkdf2
[`scrypt`]: ./scrypt
[`sha-crypt`]: ./sha-crypt
[`shacrypt`]: ./sha-crypt

[//]: # (general links)

[Argon2]: https://en.wikipedia.org/wiki/Argon2
[Balloon]: https://en.wikipedia.org/wiki/Balloon_hashing
[bcrypt-pbkdf]: https://flak.tedunangst.com/post/bcrypt-pbkdf
[bcryptpbkdf]: https://flak.tedunangst.com/post/bcrypt-pbkdf
[PBKDF2]: https://en.wikipedia.org/wiki/PBKDF2
[scrypt]: https://en.wikipedia.org/wiki/Scrypt
[SHA-crypt]: https://www.akkadia.org/drepper/SHA-crypt.txt
Expand Down
3 changes: 2 additions & 1 deletion argon2/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ documentation = "https://docs.rs/argon2"
repository = "https://github.com/RustCrypto/password-hashes/tree/master/argon2"
keywords = ["crypto", "password", "hashing"]
categories = ["cryptography", "no-std"]
edition = "2018"
readme = "README.md"
edition = "2021"
rust-version = "1.57"

[dependencies]
base64ct = "1"
Expand Down
16 changes: 16 additions & 0 deletions argon2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,20 @@ Pure Rust implementation of the [Argon2] password hashing function.

[Documentation][docs-link]

# About

Argon2 is a memory-hard [key derivation function] chosen as the winner of
the [Password Hashing Competition] in July 2015.

It implements the following three three algorithmic variants:

- **Argon2d**: maximizes resistance to GPU cracking attacks
- **Argon2i**: optimized to resist side-channel attacks
- **Argon2id**: (default) hybrid version combining both Argon2i and Argon2d

Support is provided for embedded (i.e. `no_std`) environments, including
ones without `alloc` support.

## Minimum Supported Rust Version

Rust **1.57** or higher.
Expand Down Expand Up @@ -54,3 +68,5 @@ dual licensed as above, without any additional terms or conditions.
[//]: # (general links)

[Argon2]: https://en.wikipedia.org/wiki/Argon2
[key derivation function]: https://en.wikipedia.org/wiki/Key_derivation_function
[Password Hashing Competition]: https://www.password-hashing.net/
2 changes: 1 addition & 1 deletion argon2/src/algorithm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use core::{
};

#[cfg(feature = "password-hash")]
use {core::convert::TryFrom, password_hash::Ident};
use password_hash::Ident;

/// Argon2d algorithm identifier
#[cfg(feature = "password-hash")]
Expand Down
1 change: 0 additions & 1 deletion argon2/src/block.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
//! Argon2 memory block functions

use core::{
convert::TryInto,
num::Wrapping,
ops::{BitXor, BitXorAssign, Index, IndexMut},
slice,
Expand Down
52 changes: 15 additions & 37 deletions argon2/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
//! Pure Rust implementation of the [Argon2] password hashing function.
//!
//! # About
//!
//! Argon2 is a memory-hard [key derivation function] chosen as the winner of
//! the [Password Hashing Competition] in July 2015.
//!
//! It provides three algorithmic variants (chosen via the [`Algorithm`] enum):
//!
//! - **Argon2d**: maximizes resistance to GPU cracking attacks
//! - **Argon2i**: optimized to resist side-channel attacks
//! - **Argon2id**: (default) hybrid version combining both Argon2i and Argon2d
//!
//! Support is provided for embedded (i.e. `no_std`) environments, including
//! ones without `alloc` support.
//!
//! # Usage (simple with default params)
#![no_std]
// TODO(tarcieri): safe parallel implementation
// See: https://github.com/RustCrypto/password-hashes/issues/154
#![cfg_attr(not(feature = "parallel"), forbid(unsafe_code))]
#![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/argon2/0.4.0-pre"
)]
#![warn(rust_2018_idioms, missing_docs)]

//! ## Usage (simple with default params)
//!
//! Note: this example requires the `rand_core` crate with the `std` feature
//! enabled for `rand_core::OsRng` (embedded platforms can substitute their
Expand Down Expand Up @@ -61,22 +58,6 @@
//! # Ok(())
//! # }
//! ```
//!
//! [Argon2]: https://en.wikipedia.org/wiki/Argon2
//! [key derivation function]: https://en.wikipedia.org/wiki/Key_derivation_function
//! [Password Hashing Competition]: https://www.password-hashing.net/

#![no_std]
// TODO(tarcieri): safe parallel implementation
// See: https://github.com/RustCrypto/password-hashes/issues/154
#![cfg_attr(not(feature = "parallel"), forbid(unsafe_code))]
#![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/argon2/0.4.0-pre"
)]
#![warn(rust_2018_idioms, missing_docs)]

#[cfg(feature = "alloc")]
#[macro_use]
Expand Down Expand Up @@ -115,10 +96,7 @@ use crate::{
use blake2::{digest::Output, Blake2b512, Digest};

#[cfg(all(feature = "alloc", feature = "password-hash"))]
use {
core::convert::TryFrom,
password_hash::{Decimal, Ident, ParamsString, Salt},
};
use password_hash::{Decimal, Ident, ParamsString, Salt};

/// Maximum password length in bytes.
pub const MAX_PWD_LEN: usize = 0xFFFFFFFF;
Expand Down
11 changes: 4 additions & 7 deletions argon2/src/params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,10 @@

use crate::{Error, Result, SYNC_POINTS};
use base64ct::{Base64Unpadded as B64, Encoding};
use core::{convert::TryFrom, str::FromStr};
use core::str::FromStr;

#[cfg(feature = "password-hash")]
use {
core::convert::TryInto,
password_hash::{ParamsString, PasswordHash},
};
use password_hash::{ParamsString, PasswordHash};

/// Argon2 password hash parameters.
///
Expand Down Expand Up @@ -127,7 +124,7 @@ impl Params {
/// cryptographical standpoint).
///
/// On top of that, this field is not longer part of the argon2 standard
/// (see: https://github.com/P-H-C/phc-winner-argon2/pull/173), and should
/// (see: <https://github.com/P-H-C/phc-winner-argon2/pull/173>), and should
/// not be used for any non-legacy work.
pub fn keyid(&self) -> &[u8] {
self.keyid.as_bytes()
Expand All @@ -138,7 +135,7 @@ impl Params {
/// Defaults to an empty byte slice.
///
/// This field is not longer part of the argon2 standard
/// (see: https://github.com/P-H-C/phc-winner-argon2/pull/173), and should
/// (see: <https://github.com/P-H-C/phc-winner-argon2/pull/173>), and should
/// not be used for any non-legacy work.
pub fn data(&self) -> &[u8] {
self.data.as_bytes()
Expand Down
1 change: 0 additions & 1 deletion argon2/src/version.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
//! Version of the algorithm.

use crate::{Error, Result};
use core::convert::TryFrom;

/// Version of the algorithm.
#[derive(Copy, Clone, Debug, Eq, PartialEq, PartialOrd, Ord)]
Expand Down
4 changes: 2 additions & 2 deletions balloon-hash/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ documentation = "https://docs.rs/balloon-hash"
repository = "https://github.com/RustCrypto/password-hashes/tree/master/balloon-hash"
keywords = ["crypto", "password", "hashing"]
categories = ["cryptography", "no-std"]
edition = "2021"
rust-version = "1.56"
readme = "README.md"
edition = "2021"
rust-version = "1.57"

[dependencies]
digest = { version = "0.10.3", default-features = false }
Expand Down
2 changes: 1 addition & 1 deletion balloon-hash/src/algorithm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use core::{
};

#[cfg(feature = "password-hash")]
use {core::convert::TryFrom, password_hash::Ident};
use password_hash::Ident;

/// Balloon primitive type: variants of the algorithm.
#[derive(Copy, Clone, Debug, Eq, Hash, PartialEq, PartialOrd, Ord)]
Expand Down
14 changes: 7 additions & 7 deletions balloon-hash/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,18 +73,18 @@ pub use crate::{
error::{Error, Result},
params::Params,
};

#[cfg(feature = "password-hash")]
#[cfg_attr(docsrs, doc(cfg(feature = "password-hash")))]
pub use password_hash::{self, PasswordHash, PasswordHasher, PasswordVerifier};

use core::marker::PhantomData;
use crypto_bigint::ArrayDecoding;
use digest::generic_array::GenericArray;
use digest::{Digest, FixedOutputReset};
#[cfg(feature = "password-hash")]
#[cfg_attr(docsrs, doc(cfg(feature = "password-hash")))]
pub use password_hash::{self, PasswordHash, PasswordHasher, PasswordVerifier};

#[cfg(all(feature = "alloc", feature = "password-hash"))]
use {
core::convert::TryFrom,
password_hash::{Decimal, Ident, ParamsString, Salt},
};
use password_hash::{Decimal, Ident, ParamsString, Salt};

/// Balloon context.
///
Expand Down
6 changes: 2 additions & 4 deletions balloon-hash/src/params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@

use crate::{Error, Result};
use core::num::NonZeroU32;

#[cfg(feature = "password-hash")]
use {
core::convert::TryFrom,
password_hash::{errors::InvalidValue, ParamsString, PasswordHash},
};
use password_hash::{errors::InvalidValue, ParamsString, PasswordHash};

/// Balloon password hash parameters.
///
Expand Down
4 changes: 2 additions & 2 deletions bcrypt-pbkdf/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ version = "0.8.1" # Also update html_root_url in lib.rs when bumping this
description = "bcrypt-pbkdf password-based key derivation function"
authors = ["RustCrypto Developers"]
license = "MIT OR Apache-2.0"
edition = "2021"
rust-version = "1.56"
readme = "README.md"
documentation = "https://docs.rs/bcrypt-pbkdf"
repository = "https://github.com/RustCrypto/password-hashes/tree/master/bcrypt-pbkdf"
keywords = ["crypto", "password", "hashing"]
categories = ["cryptography"]
edition = "2021"
rust-version = "1.57"

[dependencies]
blowfish = { version = "0.9.1", features = ["bcrypt"] }
Expand Down
10 changes: 5 additions & 5 deletions bcrypt-pbkdf/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,11 @@ extern crate alloc;
#[cfg(feature = "std")]
extern crate std;

mod errors;

pub use errors::Error;

use blowfish::Blowfish;
use core::convert::TryInto;
use sha2::{
digest::{
crypto_common::{Key, KeyInit, KeySizeUser},
Expand All @@ -25,13 +28,10 @@ use sha2::{
},
Digest, Sha512,
};

#[cfg(feature = "zeroize")]
use zeroize::Zeroize;

mod errors;

pub use errors::Error;

const BHASH_WORDS: usize = 8;
const BHASH_OUTPUT_SIZE: usize = BHASH_WORDS * 4;
const BHASH_SEED: &[u8; BHASH_OUTPUT_SIZE] = b"OxychromaticBlowfishSwatDynamite";
Expand Down
3 changes: 2 additions & 1 deletion pbkdf2/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ documentation = "https://docs.rs/pbkdf2"
repository = "https://github.com/RustCrypto/password-hashes/tree/master/pbkdf2"
keywords = ["crypto", "password", "hashing"]
categories = ["cryptography", "no-std"]
edition = "2018"
readme = "README.md"
edition = "2021"
rust-version = "1.57"

[dependencies]
digest = { version = "0.10.3", features = ["mac"] }
Expand Down
9 changes: 2 additions & 7 deletions pbkdf2/src/simple.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
//! Implementation of the `password-hash` crate API.

use crate::pbkdf2;
use core::cmp::Ordering;
use core::{
convert::{TryFrom, TryInto},
fmt::{self, Display},
str::FromStr,
};
use core::{cmp::Ordering, fmt, str::FromStr};
use hmac::Hmac;
use password_hash::{
errors::InvalidValue, Decimal, Error, Ident, Output, ParamsString, PasswordHash,
Expand Down Expand Up @@ -123,7 +118,7 @@ impl AsRef<str> for Algorithm {
}
}

impl Display for Algorithm {
impl fmt::Display for Algorithm {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str(self.as_str())
}
Expand Down
1 change: 0 additions & 1 deletion pbkdf2/tests/simple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ use pbkdf2::{
password_hash::{PasswordHasher, Salt},
Algorithm, Params, Pbkdf2,
};
use std::convert::TryFrom;

const PASSWORD: &str = "password";
const SALT_B64: &str = "c2FsdA"; // "salt"
Expand Down
4 changes: 2 additions & 2 deletions scrypt/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ version = "0.10.0-pre" # Also update html_root_url in lib.rs when bumping this
description = "Scrypt password-based key derivation function"
authors = ["RustCrypto Developers"]
license = "MIT OR Apache-2.0"
edition = "2021"
rust-version = "1.56"
readme = "README.md"
documentation = "https://docs.rs/scrypt"
repository = "https://github.com/RustCrypto/password-hashes/tree/master/scrypt"
keywords = ["crypto", "password", "hashing"]
categories = ["cryptography"]
edition = "2021"
rust-version = "1.56"

[dependencies]
hmac = "0.12.1"
Expand Down
Loading