pub struct Argon2Params { /* 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
pub const DEFAULT_M_COST: u32
Default memory cost.
Sourcepub const MIN_M_COST: u32
pub const MIN_M_COST: u32
Minimum number of 1 KiB memory blocks.
Sourcepub const MAX_M_COST: u32 = u32::MAX
pub const MAX_M_COST: u32 = u32::MAX
Maximum number of 1 KiB memory blocks.
Sourcepub const DEFAULT_T_COST: u32 = 2
pub const DEFAULT_T_COST: u32 = 2
Default number of iterations (i.e. “time”).
Sourcepub const MIN_T_COST: u32 = 1
pub const MIN_T_COST: u32 = 1
Minimum number of passes.
Sourcepub const MAX_T_COST: u32 = u32::MAX
pub const MAX_T_COST: u32 = u32::MAX
Maximum number of passes.
Sourcepub const DEFAULT_P_COST: u32 = 1
pub const DEFAULT_P_COST: u32 = 1
Default degree of parallelism.
Sourcepub const MIN_P_COST: u32 = 1
pub const MIN_P_COST: u32 = 1
Minimum and maximum number of threads (i.e. parallelism).
Sourcepub const MAX_P_COST: u32 = 0xFFFFFF
pub const MAX_P_COST: u32 = 0xFFFFFF
Minimum and maximum number of threads (i.e. parallelism).
Sourcepub const MAX_KEYID_LEN: usize = 8
pub const MAX_KEYID_LEN: usize = 8
Maximum length of a key ID in bytes.
Sourcepub const MAX_DATA_LEN: usize = 32
pub const MAX_DATA_LEN: usize = 32
Maximum length of associated data in bytes.
Sourcepub const DEFAULT_OUTPUT_LEN: usize = 32
pub const DEFAULT_OUTPUT_LEN: usize = 32
Default output length.
Sourcepub const MIN_OUTPUT_LEN: usize = 4
pub const MIN_OUTPUT_LEN: usize = 4
Minimum digest size in bytes.
Sourcepub const MAX_OUTPUT_LEN: usize = 0xFFFFFFFF
pub const MAX_OUTPUT_LEN: usize = 0xFFFFFFFF
Maximum digest size in bytes.
Sourcepub 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_costand (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<'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<ParamsBuilder> for Params
impl TryFrom<ParamsBuilder> for Params
impl Eq for Params
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 UnsafeUnpin for Params
impl UnwindSafe for Params
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, _span: NoopSpan) -> Self
fn instrument(self, _span: NoopSpan) -> Self
Source§fn in_current_span(self) -> Self
fn in_current_span(self) -> Self
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().