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§

source§

impl TimedArgonParams

source

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.

source

pub fn default_for(system: &System, hashers: u32) -> Self

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 than Self::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 recommended OWASP 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 by OWASP.

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§

source§

impl Clone for TimedArgonParams

source§

fn clone(&self) -> TimedArgonParams

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for TimedArgonParams

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for TimedArgonParams

source§

fn default() -> Self

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”.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more