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
impl Params
sourcepub const DEFAULT_M_COST: u32 = 19_456u32
pub const DEFAULT_M_COST: u32 = 19_456u32
Default memory cost.
sourcepub const MIN_M_COST: u32 = 8u32
pub const MIN_M_COST: u32 = 8u32
Minimum number of 1 KiB memory blocks.
sourcepub const MAX_M_COST: u32 = 4_294_967_295u32
pub const MAX_M_COST: u32 = 4_294_967_295u32
Maximum number of 1 KiB memory blocks.
sourcepub const DEFAULT_T_COST: u32 = 2u32
pub const DEFAULT_T_COST: u32 = 2u32
Default number of iterations (i.e. “time”).
sourcepub const MIN_T_COST: u32 = 1u32
pub const MIN_T_COST: u32 = 1u32
Minimum number of passes.
sourcepub const MAX_T_COST: u32 = 4_294_967_295u32
pub const MAX_T_COST: u32 = 4_294_967_295u32
Maximum number of passes.
sourcepub const DEFAULT_P_COST: u32 = 1u32
pub const DEFAULT_P_COST: u32 = 1u32
Default degree of parallelism.
sourcepub const MIN_P_COST: u32 = 1u32
pub const MIN_P_COST: u32 = 1u32
Minimum and maximum number of threads (i.e. parallelism).
sourcepub const MAX_P_COST: u32 = 16_777_215u32
pub const MAX_P_COST: u32 = 16_777_215u32
Minimum and maximum number of threads (i.e. parallelism).
sourcepub const MAX_KEYID_LEN: usize = 8usize
pub const MAX_KEYID_LEN: usize = 8usize
Maximum length of a key ID in bytes.
sourcepub const MAX_DATA_LEN: usize = 32usize
pub const MAX_DATA_LEN: usize = 32usize
Maximum length of associated data in bytes.
sourcepub const DEFAULT_OUTPUT_LEN: usize = 32usize
pub const DEFAULT_OUTPUT_LEN: usize = 32usize
Default output length.
sourcepub const MIN_OUTPUT_LEN: usize = 4usize
pub const MIN_OUTPUT_LEN: usize = 4usize
Minimum digest size in bytes.
sourcepub const MAX_OUTPUT_LEN: usize = 4_294_967_295usize
pub const MAX_OUTPUT_LEN: usize = 4_294_967_295usize
Maximum digest size in bytes.
sourcepub const fn new(
m_cost: u32,
t_cost: u32,
p_cost: u32,
output_len: Option<usize>
) -> Result<Self>
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.
sourcepub const fn m_cost(&self) -> u32
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).
sourcepub const fn t_cost(&self) -> u32
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).
sourcepub const fn p_cost(&self) -> u32
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).
sourcepub fn keyid(&self) -> &[u8] ⓘ
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.
sourcepub fn data(&self) -> &[u8] ⓘ
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.
sourcepub const fn output_len(&self) -> Option<usize>
pub const fn output_len(&self) -> Option<usize>
Length of the output (in bytes).
sourcepub const fn block_count(&self) -> usize
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 PartialEq for Params
impl PartialEq for Params
source§impl TryFrom<&Params> for ParamsString
Available on crate feature password-hash
only.
impl TryFrom<&Params> for ParamsString
password-hash
only.source§impl<'a> TryFrom<&'a PasswordHash<'a>> for Params
Available on crate feature password-hash
only.
impl<'a> TryFrom<&'a PasswordHash<'a>> for Params
password-hash
only.source§impl TryFrom<Params> for ParamsString
Available on crate feature password-hash
only.
impl TryFrom<Params> for ParamsString
password-hash
only.