Struct bonsaidb::local::config::TimedArgonParams
pub struct TimedArgonParams {
pub lanes: u32,
pub ram_per_hasher: u32,
pub minimum_duration: Duration,
}
Expand description
Automatic configuration based on execution time. This is measured during the
first set_password
Fields§
§lanes: u32
The number of lanes (p
) that the argon algorithm should use.
ram_per_hasher: u32
The amount of ram each hashing operation should utilize.
minimum_duration: Duration
The minimum execution time that hashing a password should consume.
Implementations§
§impl TimedArgonParams
impl TimedArgonParams
pub const MINIMUM_RAM_PER_HASHER: u32 = 19_922_944u32
pub const MINIMUM_RAM_PER_HASHER: u32 = 19_922_944u32
The minimum amount of ram to allocate per hasher. This value is currently 19MB but will change as the OWASP minimum recommendations are changed.
pub fn default_for(system: &System, hashers: u32) -> TimedArgonParams
pub fn default_for(system: &System, hashers: u32) -> TimedArgonParams
Returns the default configuration based on the system information and number of hashers.
-
ram_per_hasher
: The total amount of RAM allocated will be the total system memory divided by 16. This allocated amount will be divided equally between the hashers. If this number is less thanSelf::MINIMUM_RAM_PER_HASHER
,Self::MINIMUM_RAM_PER_HASHER
will be used instead.For example, if 4 hashers are used on a system with 16GB of RAM, a total of 1GB of RAM will be used between 4 hashers, yielding a
ram_per_hasher
value of 256MB. -
lanes
: defaults to 1, per the recommendedOWASP
minimum settings. -
minimum_duration
: defaults to 1 second. The RFC suggests 0.5 seconds, but many in the community recommend 1 second. When computing the ideal parameters, a minimum iteration count of 2 will be used to ensure compliance with minimum parameters recommended byOWASP
.
The strength of Argon2 is derived largely by the amount of RAM dedicated
to it, so the largest value acceptable should be chosen for
ram_per_hasher
. For more guidance on parameter selection, see RFC
9106, section 4 “Parameter Choice” or the OWASP
Password
Storage Cheetsheet
Debug Mode
When running with debug_assertions
the ram_per_hasher
will be set to
32kb. This is due to how slow debug mode is for the hashing algorithm.
These settings should not be used in production.
Trait Implementations§
§impl Clone for TimedArgonParams
impl Clone for TimedArgonParams
§fn clone(&self) -> TimedArgonParams
fn clone(&self) -> TimedArgonParams
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more§impl Debug for TimedArgonParams
impl Debug for TimedArgonParams
§impl Default for TimedArgonParams
impl Default for TimedArgonParams
§fn default() -> TimedArgonParams
fn default() -> TimedArgonParams
Default Values
When using TimedArgonParams::default()
, the settings are 4 lanes,
Self::MINIMUM_RAM_PER_HASHER
of RAM per hasher, and a minimum
duration of 1 second.
The strength of Argon2 is derived largely by the amount of RAM dedicated
to it, so the largest value acceptable should be chosen for
ram_per_hasher
. For more guidance on parameter selection, see RFC
9106, section 4 “Parameter Choice”.