Skip to content
Merged
431 changes: 229 additions & 202 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ panic = "abort"
# Optimize for speed the cryptographic libraries.
[profile.ffi-production.package.num-bigint-dig]
opt-level = 3
[profile.ffi-production.package.crypto-bigint]
opt-level = 3
[profile.ffi-production.package.ed25519-dalek]
opt-level = 3
[profile.ffi-production.package.x25519-dalek]
Expand Down
5 changes: 3 additions & 2 deletions ffi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ picky-asn1 = { path = "../picky-asn1", default-features = false }
picky-asn1-der = { path = "../picky-asn1-der" }
picky-asn1-x509 = { path = "../picky-asn1-x509", features = ["legacy", "zeroize"] }

argon2 = "0.5"
argon2 = "0.6.0-rc.1"
rand = "0.9"

# FFI
diplomat = { git = "https://github.com/CBenoit/diplomat.git", rev = "f4d93d57e93025c57e75e9711d2418faa9311a42" }
Expand All @@ -32,4 +33,4 @@ serde_json = "1"

# WASM support
[target.'cfg(target_arch = "wasm32")'.dependencies]
getrandom = { version = "0.2", features = ["js"] }
getrandom = { version = "0.3", features = ["wasm_js"] }
6 changes: 4 additions & 2 deletions ffi/src/argon2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,12 @@ pub mod ffi {
pub fn hash_password(&self, password: &str, writeable: &mut DiplomatWriteable) -> Result<(), Box<PickyError>> {
use argon2::PasswordHasher as _;
use argon2::password_hash::SaltString;
use argon2::password_hash::rand_core::OsRng;
use rand::SeedableRng;
use rand::rngs::StdRng;
use std::fmt::Write as _;

let salt = SaltString::generate(&mut OsRng);
let mut rng = StdRng::try_from_os_rng().map_err(|_| "failed to create a random number generator")?;
let salt = SaltString::from_rng(&mut rng);

let password_hash = self.0.hash_password(password.as_bytes(), &salt)?.to_string();

Expand Down
Loading
Loading