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
3 changes: 2 additions & 1 deletion .github/workflows/argon2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
toolchain: ${{ matrix.rust }}
targets: ${{ matrix.target }}
- run: cargo build --target ${{ matrix.target }} --no-default-features
- run: cargo build --target ${{ matrix.target }} --no-default-features --features password-hash
- run: cargo build --target ${{ matrix.target }} --no-default-features --features kdf
- run: cargo build --target ${{ matrix.target }} --no-default-features --features password-hash
- run: cargo build --target ${{ matrix.target }} --no-default-features --features zeroize

Expand Down Expand Up @@ -73,6 +73,7 @@ jobs:
targets: ${{ matrix.target }}
- run: ${{ matrix.deps }}
- run: cargo test --no-default-features
- run: cargo test --no-default-features --features kdf
- run: cargo test --no-default-features --features password-hash
- run: cargo test
- run: cargo test --all-features
Expand Down
11 changes: 7 additions & 4 deletions .github/workflows/balloon-hash.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ jobs:
toolchain: ${{ matrix.rust }}
targets: ${{ matrix.target }}
- run: cargo build --target ${{ matrix.target }} --release --no-default-features
- run: cargo build --target ${{ matrix.target }} --release --no-default-features --features kdf
- run: cargo build --target ${{ matrix.target }} --release --no-default-features --features password-hash

minimal-versions:
Expand All @@ -56,7 +57,9 @@ jobs:
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust }}
- run: cargo test --release
- run: cargo test --release --no-default-features --features alloc
- run: cargo test --release --no-default-features --features alloc,zeroize
- run: cargo test --release --all-features
- run: cargo test
- run: cargo test --no-default-features --features alloc
- run: cargo test --no-default-features --features alloc,zeroize
- run: cargo test --no-default-features --features kdf
- run: cargo test --all-features
- run: cargo test --all-features --release
8 changes: 7 additions & 1 deletion .github/workflows/pbkdf2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,11 @@ jobs:
with:
toolchain: ${{ matrix.rust }}
- uses: RustCrypto/actions/cargo-hack-install@master
- run: cargo hack test --feature-powerset
- run: cargo hack check --feature-powerset --no-dev-deps
- run: cargo hack test --feature-powerset --exclude-features default,getrandom,hmac,kdf,password-hash,rand_core
- run: cargo test --no-default-features --features getrandom
- run: cargo test --no-default-features --features hmac
- run: cargo test --no-default-features --features kdf
- run: cargo test --no-default-features --features password-hash
- run: cargo test --no-default-features --features rand_core
- run: cargo test --all-features --release
10 changes: 7 additions & 3 deletions .github/workflows/scrypt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,15 @@ jobs:
toolchain: ${{ matrix.rust }}
targets: ${{ matrix.target }}
- run: cargo build --target ${{ matrix.target }} --no-default-features
- run: cargo build --target ${{ matrix.target }} --no-default-features --features kdf
- run: cargo build --target ${{ matrix.target }} --no-default-features --features password-hash

minimal-versions:
# disabled until belt-block gets published
if: false
uses: RustCrypto/actions/.github/workflows/minimal-versions.yml@master
with:
working-directory: ${{ github.workflow }}
working-directory: ${{ github.workflow }}

test:
runs-on: ubuntu-latest
Expand All @@ -59,5 +60,8 @@ jobs:
toolchain: ${{ matrix.rust }}
- run: cargo test --no-default-features
- run: cargo test
- run: cargo test --all-features
- run: cargo doc --no-default-features
- run: cargo test --no-default-features --features kdf
- run: cargo test --no-default-features --features mcf
- run: cargo test --no-default-features --features phc
- run: cargo test --all-features --release
- run: cargo test --all-features --release
21 changes: 21 additions & 0 deletions .github/workflows/yescrypt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,27 @@ jobs:
with:
working-directory: ${{ github.workflow }}

build:
runs-on: ubuntu-latest
strategy:
matrix:
rust:
- 1.85.0 # MSRV
- stable
target:
- thumbv7em-none-eabi
- wasm32-unknown-unknown
steps:
- uses: actions/checkout@v6
- uses: RustCrypto/actions/cargo-cache@master
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust }}
targets: ${{ matrix.target }}
- run: cargo build --target ${{ matrix.target }} --no-default-features
- run: cargo build --target ${{ matrix.target }} --no-default-features --features kdf
- run: cargo build --target ${{ matrix.target }} --no-default-features --features password-hash

test:
runs-on: ubuntu-latest
strategy:
Expand Down
11 changes: 11 additions & 0 deletions Cargo.lock

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

2 changes: 2 additions & 0 deletions argon2/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ base64ct = "1.7"
blake2 = { version = "0.11.0-rc.3", default-features = false }

# optional dependencies
kdf = { version = "0.1.0-pre.1", optional = true }
rayon = { version = "1.7", optional = true }
password-hash = { version = "0.6.0-rc.9", optional = true, features = ["phc"] }
zeroize = { version = "1", default-features = false, optional = true }
Expand All @@ -35,6 +36,7 @@ hex-literal = "1"
default = ["alloc", "getrandom", "password-hash"]
alloc = ["password-hash?/alloc"]

kdf = ["alloc", "dep:kdf"]
getrandom = ["password-hash/getrandom"]
parallel = ["dep:rayon"]
password-hash = ["dep:password-hash"]
Expand Down
25 changes: 16 additions & 9 deletions argon2/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,15 @@ pub enum Error {
OutOfMemory,
}

impl core::error::Error for Error {
fn source(&self) -> Option<&(dyn core::error::Error + 'static)> {
match self {
Self::B64Encoding(err) => Some(err),
_ => None,
}
}
}

impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str(match self {
Expand Down Expand Up @@ -90,6 +99,13 @@ impl From<base64ct::Error> for Error {
}
}

#[cfg(feature = "kdf")]
impl From<Error> for kdf::Error {
fn from(_err: Error) -> kdf::Error {
kdf::Error
}
}

#[cfg(feature = "password-hash")]
impl From<Error> for password_hash::Error {
fn from(err: Error) -> password_hash::Error {
Expand All @@ -114,12 +130,3 @@ impl From<Error> for password_hash::Error {
}
}
}

impl core::error::Error for Error {
fn source(&self) -> Option<&(dyn core::error::Error + 'static)> {
match self {
Self::B64Encoding(err) => Some(err),
_ => None,
}
}
}
13 changes: 13 additions & 0 deletions argon2/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,8 @@ pub use crate::{
version::Version,
};

#[cfg(feature = "kdf")]
pub use kdf::{self, Kdf, Pbkdf};
#[cfg(feature = "password-hash")]
pub use {
crate::algorithm::{ARGON2D_IDENT, ARGON2I_IDENT, ARGON2ID_IDENT},
Expand Down Expand Up @@ -608,6 +610,17 @@ impl<'key> Argon2<'key> {
}
}

#[cfg(feature = "kdf")]
impl Kdf for Argon2<'_> {
fn derive_key(&self, password: &[u8], salt: &[u8], out: &mut [u8]) -> kdf::Result<()> {
self.hash_password_into(password, &salt, out)?;
Ok(())
}
}

#[cfg(feature = "kdf")]
impl Pbkdf for Argon2<'_> {}

#[cfg(all(feature = "alloc", feature = "password-hash"))]
impl CustomizedPasswordHasher<PasswordHash> for Argon2<'_> {
type Params = Params;
Expand Down
2 changes: 2 additions & 0 deletions balloon-hash/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ digest = { version = "0.11.0-rc.4", default-features = false }
crypto-bigint = { version = "0.7.0-rc.9", default-features = false, features = ["hybrid-array"] }

# optional dependencies
kdf = { version = "0.1.0-pre.1", optional = true }
password-hash = { version = "0.6.0-rc.9", optional = true, default-features = false, features = ["phc"] }
rayon = { version = "1.7", optional = true }
zeroize = { version = "1", default-features = false, optional = true }
Expand All @@ -30,6 +31,7 @@ sha2 = "0.11.0-rc.3"
default = ["alloc", "getrandom", "password-hash"]
alloc = ["password-hash/alloc"]

kdf = ["alloc", "dep:kdf"]
getrandom = ["password-hash/getrandom"]
parallel = ["dep:rayon"]
password-hash = ["dep:password-hash"]
Expand Down
11 changes: 9 additions & 2 deletions balloon-hash/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ pub enum Error {
},
}

impl core::error::Error for Error {}

impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Expand All @@ -43,6 +45,13 @@ impl fmt::Display for Error {
}
}

#[cfg(feature = "kdf")]
impl From<Error> for kdf::Error {
fn from(_err: Error) -> kdf::Error {
kdf::Error
}
}

#[cfg(feature = "password-hash")]
impl From<Error> for password_hash::Error {
fn from(err: Error) -> password_hash::Error {
Expand All @@ -56,5 +65,3 @@ impl From<Error> for password_hash::Error {
}
}
}

impl core::error::Error for Error {}
Loading