From 5a0aef607ccda21ae8a76c687de801632dff2574 Mon Sep 17 00:00:00 2001 From: Falko <10247603+falko17@users.noreply.github.com> Date: Mon, 13 Jun 2022 05:19:26 +0200 Subject: [PATCH] Change argon2 salt length to recommended value (16 bytes) (#275) This commit changes the `Ksf` implementation for Argon2 and sets the salt length to 16 bytes, the value recommended in section 3.1 of the Argon2 specification. --- src/ksf.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/ksf.rs b/src/ksf.rs index 9aacc9e..4af2415 100644 --- a/src/ksf.rs +++ b/src/ksf.rs @@ -11,6 +11,10 @@ use generic_array::{ArrayLength, GenericArray}; use crate::errors::InternalError; +/// Recommended salt length for argon2-based password hashing. +#[cfg(feature = "argon2")] +const ARGON2_RECOMMENDED_SALT_LEN: usize = 16; + /// Used for the key stretching function in OPAQUE pub trait Ksf: Default { /// Computes the key stretching function @@ -40,7 +44,7 @@ impl Ksf for argon2::Argon2<'_> { input: GenericArray, ) -> Result, InternalError> { let mut output = GenericArray::default(); - self.hash_password_into(&input, &[0; argon2::MIN_SALT_LEN], &mut output) + self.hash_password_into(&input, &[0; ARGON2_RECOMMENDED_SALT_LEN], &mut output) .map_err(|_| InternalError::KsfError)?; Ok(output) }