Skip to content

Commit

Permalink
Prepare pre.0 prereleases
Browse files Browse the repository at this point in the history
  • Loading branch information
baloo committed Feb 6, 2024
1 parent 2940192 commit 3b1503f
Show file tree
Hide file tree
Showing 15 changed files with 137 additions and 98 deletions.
92 changes: 64 additions & 28 deletions Cargo.lock

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

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@ exclude = ["benches"]

[profile.dev]
opt-level = 2

[patch.crates-io]
blake2 = { git = "https://github.com/RustCrypto/hashes.git" }
4 changes: 2 additions & 2 deletions argon2/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "argon2"
version = "0.5.3"
version = "0.6.0-pre.0"
description = """
Pure Rust implementation of the Argon2 password hashing function with support
for the Argon2d, Argon2i, and Argon2id algorithmic variants
Expand All @@ -17,7 +17,7 @@ rust-version = "1.65"

[dependencies]
base64ct = "1"
blake2 = { version = "0.10.6", default-features = false }
blake2 = { version = "0.11.0-pre", default-features = false }

# optional dependencies
password-hash = { version = "0.5", optional = true }
Expand Down
8 changes: 4 additions & 4 deletions balloon-hash/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "balloon-hash"
version = "0.4.0"
version = "0.5.0-pre.0"
description = "Pure Rust implementation of the Balloon password hashing function"
authors = ["RustCrypto Developers"]
license = "MIT OR Apache-2.0"
Expand All @@ -13,8 +13,8 @@ edition = "2021"
rust-version = "1.65"

[dependencies]
digest = { version = "0.10.7", default-features = false }
crypto-bigint = { version = "0.5", default-features = false, features = ["generic-array"] }
digest = { version = "=0.11.0-pre.8", default-features = false }
crypto-bigint = { version = "=0.6.0-pre.12", default-features = false, features = ["hybrid-array"] }

# optional dependencies
password-hash = { version = "0.5", default-features = false, optional = true }
Expand All @@ -23,7 +23,7 @@ zeroize = { version = "1", default-features = false, optional = true }

[dev-dependencies]
hex-literal = "0.4"
sha2 = "0.10"
sha2 = "=0.11.0-pre.3"

[features]
default = ["alloc", "password-hash", "rand"]
Expand Down
28 changes: 14 additions & 14 deletions balloon-hash/src/balloon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@ use crate::error::{Error, Result};
use crate::Params;
use core::mem;
use crypto_bigint::{ArrayDecoding, ArrayEncoding, NonZero};
use digest::generic_array::GenericArray;
use digest::array::Array;
use digest::{Digest, FixedOutputReset};

pub fn balloon<D: Digest + FixedOutputReset>(
pwd: &[u8],
salt: &[u8],
secret: Option<&[u8]>,
params: Params,
memory_blocks: &mut [GenericArray<u8, D::OutputSize>],
) -> Result<GenericArray<u8, D::OutputSize>>
memory_blocks: &mut [Array<u8, D::OutputSize>],
) -> Result<Array<u8, D::OutputSize>>
where
GenericArray<u8, D::OutputSize>: ArrayDecoding,
Array<u8, D::OutputSize>: ArrayDecoding,
{
if params.p_cost.get() == 1 {
hash_internal::<D>(pwd, salt, secret, params, memory_blocks, None)
Expand All @@ -27,15 +27,15 @@ pub fn balloon_m<D: Digest + FixedOutputReset>(
salt: &[u8],
secret: Option<&[u8]>,
params: Params,
memory_blocks: &mut [GenericArray<u8, D::OutputSize>],
output: &mut GenericArray<u8, D::OutputSize>,
memory_blocks: &mut [Array<u8, D::OutputSize>],
output: &mut Array<u8, D::OutputSize>,
) -> Result<()>
where
GenericArray<u8, D::OutputSize>: ArrayDecoding,
Array<u8, D::OutputSize>: ArrayDecoding,
{
#[cfg(not(feature = "parallel"))]
let output_xor = {
let mut output = GenericArray::<_, D::OutputSize>::default();
let mut output = Array::<_, D::OutputSize>::default();

for thread in 1..=u64::from(params.p_cost.get()) {
let hash = hash_internal::<D>(pwd, salt, secret, params, memory_blocks, Some(thread))?;
Expand Down Expand Up @@ -63,7 +63,7 @@ where
.map_with((params, secret), |(params, secret), (thread, memory)| {
hash_internal::<D>(pwd, salt, *secret, *params, memory, Some(thread))
})
.try_reduce(GenericArray::default, |a, b| {
.try_reduce(Array::default, |a, b| {
Ok(a.into_iter().zip(b).map(|(a, b)| a ^ b).collect())
})
}?
Expand All @@ -88,16 +88,16 @@ fn hash_internal<D: Digest + FixedOutputReset>(
salt: &[u8],
secret: Option<&[u8]>,
params: Params,
memory_blocks: &mut [GenericArray<u8, D::OutputSize>],
memory_blocks: &mut [Array<u8, D::OutputSize>],
thread_id: Option<u64>,
) -> Result<GenericArray<u8, D::OutputSize>>
) -> Result<Array<u8, D::OutputSize>>
where
GenericArray<u8, D::OutputSize>: ArrayDecoding,
Array<u8, D::OutputSize>: ArrayDecoding,
{
// we will use `s_cost` to index arrays regularly
let s_cost = params.s_cost.get() as usize;
let s_cost_bigint = {
let mut s_cost = GenericArray::<u8, D::OutputSize>::default();
let mut s_cost = Array::<u8, D::OutputSize>::default();
s_cost[..mem::size_of::<u32>()].copy_from_slice(&params.s_cost.get().to_le_bytes());
NonZero::new(s_cost.into_uint_le()).unwrap()
};
Expand Down Expand Up @@ -183,7 +183,7 @@ where
}

Digest::update(&mut digest, idx_block);
let other = digest.finalize_reset().into_uint_le() % s_cost_bigint;
let other = digest.finalize_reset().into_uint_le() % s_cost_bigint.clone();
let other = usize::from_le_bytes(
other.to_le_byte_array()[..mem::size_of::<usize>()]
.try_into()
Expand Down
Loading

0 comments on commit 3b1503f

Please sign in to comment.