From b165323185ed05a9fad46ff94ef319b4a18762fe Mon Sep 17 00:00:00 2001 From: Azer Sadykhzadeh Date: Sat, 17 Oct 2026 09:03:56 +0000 Subject: [PATCH] Compute the vault KDF's four lanes in parallel Argon2 was built without its parallel feature, so unlock ran all four lanes one after another on a single thread. --- Cargo.lock | 46 ++++++++++++++++++++++++++++++++++++++++++++++ Cargo.toml | 6 +++++- 2 files changed, 51 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index 33c749f3..6cda9f3b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -114,6 +114,7 @@ dependencies = [ "blake2", "cpufeatures 0.3.1", "password-hash", + "rayon", ] [[package]] @@ -858,6 +859,25 @@ dependencies = [ "crossbeam-utils", ] +[[package]] +name = "crossbeam-deque" +version = "0.8.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "622f3fc73690be383c7214310406f28a90e6edeadc3cea882f9d71e495b9711a" +dependencies = [ + "crossbeam-epoch", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-epoch" +version = "0.9.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc74980687109a3b14c72fd458107bf0baa1da1a1a805e178d15501ba9b86d9d" +dependencies = [ + "crossbeam-utils", +] + [[package]] name = "crossbeam-utils" version = "0.8.23" @@ -1352,6 +1372,12 @@ dependencies = [ "zeroize", ] +[[package]] +name = "either" +version = "1.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e9c71c2167ca323c882b99918929403426e2373ea17242ff5653e0d5e1058be" + [[package]] name = "elliptic-curve" version = "0.14.1" @@ -4070,6 +4096,26 @@ version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "20675572f6f24e9e76ef639bc5552774ed45f1c30e2951e1e99c59888861c539" +[[package]] +name = "rayon" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb39b166781f92d482534ef4b4b1b2568f42613b53e5b6c160e24cfbfa30926d" +dependencies = [ + "either", + "rayon-core", +] + +[[package]] +name = "rayon-core" +version = "1.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22e18b0f0062d30d4230b2e85ff77fdfe4326feb054b9783a3460d8435c8ab91" +dependencies = [ + "crossbeam-deque", + "crossbeam-utils", +] + [[package]] name = "redox_syscall" version = "0.5.18" diff --git a/Cargo.toml b/Cargo.toml index d8e63d11..b076444f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -38,7 +38,11 @@ thiserror = "2" tracing = "0.1" tracing-subscriber = "0.3" zeroize = { version = "1", features = ["derive"] } -argon2 = "0.6" +# `parallel` computes Argon2's lanes on separate threads (rayon). The vault's +# KDF uses four lanes, so unlock waits for roughly a quarter of the work on a +# machine with four or more cores; the result and its cost to an attacker are +# unchanged. +argon2 = { version = "0.6", features = ["parallel"] } aes-gcm = "0.11" uuid = { version = "1", features = ["v4", "serde"] }