[go: up one dir, main page]

Struct Params

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

Argon2 password hash parameters.

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

Implementations§

Source§

impl Params

Source

pub const DEFAULT_M_COST: u32 = 19_456u32

Default memory cost.

Source

pub const MIN_M_COST: u32 = 8u32

Minimum number of 1 KiB memory blocks.

Source

pub const MAX_M_COST: u32 = 4_294_967_295u32

Maximum number of 1 KiB memory blocks.

Source

pub const DEFAULT_T_COST: u32 = 2u32

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

Source

pub const MIN_T_COST: u32 = 1u32

Minimum number of passes.

Source

pub const MAX_T_COST: u32 = 4_294_967_295u32

Maximum number of passes.

Source

pub const DEFAULT_P_COST: u32 = 1u32

Default degree of parallelism.

Source

pub const MIN_P_COST: u32 = 1u32

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

Source

pub const MAX_P_COST: u32 = 16_777_215u32

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

Source

pub const MAX_KEYID_LEN: usize = 8usize

Maximum length of a key ID in bytes.

Source

pub const MAX_DATA_LEN: usize = 32usize

Maximum length of associated data in bytes.

Source

pub const DEFAULT_OUTPUT_LEN: usize = 32usize

Default output length.

Source

pub const MIN_OUTPUT_LEN: usize = 4usize

Minimum digest size in bytes.

Source

pub const MAX_OUTPUT_LEN: usize = 4_294_967_295usize

Maximum digest size in bytes.

Source

pub const DEFAULT: Self

Default parameters (recommended).

Source

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

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

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

Source

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

Source

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

Source

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.

Source

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.

Source

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

Length of the output (in bytes).

Source

pub const fn block_count(&self) -> usize

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

Trait Implementations§

Source§

impl Clone for Params

Source§

fn clone(&self) -> Params

Returns a duplicate 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 Params

Source§

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

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

impl Default for Params

Source§

fn default() -> Params

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

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

Source§

fn from(params: &Params) -> Self

Converts to this type from the input type.
Source§

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

Source§

fn from(params: Params) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for Params

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

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

impl TryFrom<&Params> for ParamsString

Available on crate feature password-hash only.
Source§

type Error = Error

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

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

Performs the conversion.
Source§

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

Available on crate feature password-hash only.
Source§

type Error = Error

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

fn try_from(hash: &'a PasswordHash<'a>) -> Result<Self>

Performs the conversion.
Source§

impl TryFrom<Params> for ParamsString

Available on crate feature password-hash only.
Source§

type Error = Error

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

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

Performs the conversion.
Source§

impl TryFrom<ParamsBuilder> for Params

Source§

type Error = Error

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

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

Performs the conversion.
Source§

impl Eq for Params

Source§

impl StructuralPartialEq for Params

Auto Trait Implementations§

§

impl Freeze for Params

§

impl RefUnwindSafe for Params

§

impl Send for Params

§

impl Sync for Params

§

impl Unpin for Params

§

impl UnwindSafe for Params

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
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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

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>,

Source§

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>,

Source§

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.