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) -> 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 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<(), Error>

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

impl Default for TimedArgonParams

source§

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

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

§

fn implicit( self, class: Class, constructed: bool, tag: u32 ) -> TaggedParser<'a, Implicit, Self, E>

source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where 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.

§

impl<T> Instrument for T

§

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

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

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 T
where 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 for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where 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 T
where 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 T
where 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 T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

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