Struct bonsaidb::local::argon2::Params

pub struct Params { /* private fields */ }
Expand description

Argon2 password hash parameters.

These are parameters which can be encoded into a PHC hash string.

Implementations§

§

impl Params

pub const DEFAULT_M_COST: u32 = 19_456u32

Default memory cost.

pub const MIN_M_COST: u32 = 8u32

Minimum number of 1 KiB memory blocks.

pub const MAX_M_COST: u32 = 4_294_967_295u32

Maximum number of 1 KiB memory blocks.

pub const DEFAULT_T_COST: u32 = 2u32

Default number of iterations (i.e. “time”).

pub const MIN_T_COST: u32 = 1u32

Minimum number of passes.

pub const MAX_T_COST: u32 = 4_294_967_295u32

Maximum number of passes.

pub const DEFAULT_P_COST: u32 = 1u32

Default degree of parallelism.

pub const MIN_P_COST: u32 = 1u32

Minimum and maximum number of threads (i.e. parallelism).

pub const MAX_P_COST: u32 = 16_777_215u32

Minimum and maximum number of threads (i.e. parallelism).

pub const MAX_KEYID_LEN: usize = 8usize

Maximum length of a key ID in bytes.

pub const MAX_DATA_LEN: usize = 32usize

Maximum length of associated data in bytes.

pub const DEFAULT_OUTPUT_LEN: usize = 32usize

Default output length.

pub const MIN_OUTPUT_LEN: usize = 4usize

Minimum digest size in bytes.

pub const MAX_OUTPUT_LEN: usize = 4_294_967_295usize

Maximum digest size in bytes.

pub const DEFAULT: Params = _

Default parameters (recommended).

pub const fn new( m_cost: u32, t_cost: u32, p_cost: u32, output_len: Option<usize> ) -> Result<Params, Error>

Create new parameters.

Arguments
  • m_cost: memory size in 1 KiB blocks. Between 8*p_cost and (2^32)-1.
  • t_cost: number of iterations. Between 1 and (2^32)-1.
  • p_cost: degree of parallelism. Between 1 and (2^24)-1.
  • output_len: size of the KDF output in bytes. Default 32.

pub const fn m_cost(&self) -> u32

Memory size, expressed in kibibytes. Between 8*p_cost and (2^32)-1.

Value is an integer in decimal (1 to 10 digits).

pub const fn t_cost(&self) -> u32

Number of iterations. Between 1 and (2^32)-1.

Value is an integer in decimal (1 to 10 digits).

pub const fn p_cost(&self) -> u32

Degree of parallelism. Between 1 and (2^24)-1.

Value is an integer in decimal (1 to 3 digits).

pub fn keyid(&self) -> &[u8]

Key identifier: byte slice between 0 and 8 bytes in length.

Defaults to an empty byte slice.

Note this field is only present as a helper for reading/storing in the PHC hash string format (i.e. it is totally ignored from a cryptographical standpoint).

On top of that, this field is not longer part of the Argon2 standard (see: https://github.com/P-H-C/phc-winner-argon2/pull/173), and should not be used for any non-legacy work.

pub fn data(&self) -> &[u8]

Associated data: byte slice between 0 and 32 bytes in length.

Defaults to an empty byte slice.

This field is not longer part of the argon2 standard (see: https://github.com/P-H-C/phc-winner-argon2/pull/173), and should not be used for any non-legacy work.

pub const fn output_len(&self) -> Option<usize>

Length of the output (in bytes).

pub const fn block_count(&self) -> usize

Get the number of blocks required given the configured m_cost and p_cost.

Trait Implementations§

§

impl Clone for Params

§

fn clone(&self) -> Params

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
§

impl Debug for Params

§

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

Formats the value using the given formatter. Read more
§

impl Default for Params

§

fn default() -> Params

Returns the “default value” for a type. Read more
§

impl<'key> From<&Params> for Argon2<'key>

§

fn from(params: &Params) -> Argon2<'key>

Converts to this type from the input type.
§

impl<'key> From<Params> for Argon2<'key>

§

fn from(params: Params) -> Argon2<'key>

Converts to this type from the input type.
§

impl PartialEq for Params

§

fn eq(&self, other: &Params) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
§

impl TryFrom<&Params> for ParamsString

§

type Error = Error

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

fn try_from(params: &Params) -> Result<ParamsString, Error>

Performs the conversion.
§

impl<'a> TryFrom<&'a PasswordHash<'a>> for Params

§

type Error = Error

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

fn try_from(hash: &'a PasswordHash<'a>) -> Result<Params, Error>

Performs the conversion.
§

impl TryFrom<Params> for ParamsString

§

type Error = Error

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

fn try_from(params: Params) -> Result<ParamsString, Error>

Performs the conversion.
§

impl TryFrom<ParamsBuilder> for Params

§

type Error = Error

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

fn try_from(builder: ParamsBuilder) -> Result<Params, Error>

Performs the conversion.
§

impl Eq for Params

§

impl StructuralEq for Params

§

impl StructuralPartialEq for Params

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
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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