pub struct Iters { /* private fields */ }Expand description
The number of iterations for PBKDF.
The general rule is bigger is better (in terms of security), however, bigger is also more computationally expensive.
OWASP recommends using at least 600,000 iterations with SHA256 for passwords, a FIPS
requirement. NIST SP 800-132, Section 5.2, back in 2010, recommends anywhere from 1,000
to 10,000,000 iterations (10,000,000 for critical secrets). However SP 800-132 is under
active revision, and the lower bound of 1,000 iterations is now considered inadequate for
modern security needs.
Implementations§
Source§impl Iters
impl Iters
Sourcepub const fn new(iters: u32) -> Option<Self>
pub const fn new(iters: u32) -> Option<Self>
Create a new Iters instance.
§Note
Please see the Iters type documentation for more information and sources to assist in
picking the correct value. The value is context dependent, are you hashing a password?
You’ll need a very large value, minimum 600,000. For key derivation, again it is context
dependent, how critical is this key? How powerful is the host machine? The general rule
is the bigger the value, the better in terms of security.
§Arguments
iters- The desired number of iterations (must be non-zero).
§Returns
Some(Iters): The newItersinstance.None: The provideditersargument was zero.
Sourcepub const unsafe fn new_unchecked(iters: u32) -> Self
pub const unsafe fn new_unchecked(iters: u32) -> Self
Create a new Iters instance without any safety checks.
§Safety
This will cause undefined behavior if the provided iters argument is 0. Iters
may only be constructed with non-zero values (as the underlying type is NonZeroU32).
Sourcepub const fn is_valid_size(&self) -> bool
pub const fn is_valid_size(&self) -> bool
Returns true if the iteration count can safely be cast to an i32.
Certain KDFs (such as the PBKDF family) take the iteration count as an i32, and check
at runtime if the iteration count is greater than 0. This most likely is an older design
choice which they must keep for stability reasons.
For ergonomic reasons, we will represent the iteration count as an unsigned int.