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
impl Params
pub const DEFAULT_M_COST: u32 = 19_456u32
pub const DEFAULT_M_COST: u32 = 19_456u32
Default memory cost.
pub const MIN_M_COST: u32 = 8u32
pub const MIN_M_COST: u32 = 8u32
Minimum number of 1 KiB memory blocks.
pub 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.
pub const DEFAULT_T_COST: u32 = 2u32
pub const DEFAULT_T_COST: u32 = 2u32
Default number of iterations (i.e. “time”).
pub const MIN_T_COST: u32 = 1u32
pub const MIN_T_COST: u32 = 1u32
Minimum number of passes.
pub const MAX_T_COST: u32 = 4_294_967_295u32
pub const MAX_T_COST: u32 = 4_294_967_295u32
Maximum number of passes.
pub const DEFAULT_P_COST: u32 = 1u32
pub const DEFAULT_P_COST: u32 = 1u32
Default degree of parallelism.
pub const MIN_P_COST: u32 = 1u32
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
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
pub const MAX_KEYID_LEN: usize = 8usize
Maximum length of a key ID in bytes.
pub const MAX_DATA_LEN: usize = 32usize
pub const MAX_DATA_LEN: usize = 32usize
Maximum length of associated data in bytes.
pub const DEFAULT_OUTPUT_LEN: usize = 32usize
pub const DEFAULT_OUTPUT_LEN: usize = 32usize
Default output length.
pub const MIN_OUTPUT_LEN: usize = 4usize
pub const MIN_OUTPUT_LEN: usize = 4usize
Minimum digest size in bytes.
pub const MAX_OUTPUT_LEN: usize = 4_294_967_295usize
pub const MAX_OUTPUT_LEN: usize = 4_294_967_295usize
Maximum digest size in bytes.
pub const fn new(
m_cost: u32,
t_cost: u32,
p_cost: u32,
output_len: Option<usize>
) -> Result<Params, Error>
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
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
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
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] ⓘ
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] ⓘ
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>
pub const fn output_len(&self) -> Option<usize>
Length of the output (in bytes).
pub 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§
§impl TryFrom<&Params> for ParamsString
impl TryFrom<&Params> for ParamsString
§impl<'a> TryFrom<&'a PasswordHash<'a>> for Params
impl<'a> TryFrom<&'a PasswordHash<'a>> for Params
§impl TryFrom<Params> for ParamsString
impl TryFrom<Params> for ParamsString
§impl TryFrom<ParamsBuilder> for Params
impl TryFrom<ParamsBuilder> for Params
impl Eq for Params
impl StructuralEq for Params
impl StructuralPartialEq for Params
Auto Trait Implementations§
impl RefUnwindSafe for Params
impl Send for Params
impl Sync for Params
impl Unpin for Params
impl UnwindSafe for Params
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.