Skip to content

Commit

Permalink
argon2: Fix Params docs (#458)
Browse files Browse the repository at this point in the history
* The minimum value of `m_cost` is 8, not 1.
* The maximum value of `p_cost` is (2^24)-1, not 255.
  • Loading branch information
sorairolake committed Sep 5, 2023
1 parent 2410ffc commit 144b2e4
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions argon2/src/params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use password_hash::{ParamsString, PasswordHash};
/// These are parameters which can be encoded into a PHC hash string.
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct Params {
/// Memory size, expressed in kibibytes, between 1 and (2^32)-1.
/// Memory size, expressed in kibibytes, between 8 and (2^32)-1.
///
/// Value is an integer in decimal (1 to 10 digits).
m_cost: u32,
Expand Down Expand Up @@ -100,9 +100,9 @@ impl Params {
/// Create new parameters.
///
/// # Arguments
/// - `m_cost`: memory size in 1 KiB blocks. Between 1 and (2^32)-1.
/// - `m_cost`: memory size in 1 KiB blocks. Between 8 and (2^32)-1.
/// - `t_cost`: number of iterations. Between 1 and (2^32)-1.
/// - `p_cost`: degree of parallelism. Between 1 and 255.
/// - `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 new(
m_cost: u32,
Expand Down Expand Up @@ -154,7 +154,7 @@ impl Params {
})
}

/// Memory size, expressed in kibibytes. Between 1 and (2^32)-1.
/// Memory size, expressed in kibibytes. Between 8 and (2^32)-1.
///
/// Value is an integer in decimal (1 to 10 digits).
pub const fn m_cost(&self) -> u32 {
Expand All @@ -168,7 +168,7 @@ impl Params {
self.t_cost
}

/// Degree of parallelism. Between 1 and 255.
/// Degree of parallelism. Between 1 and (2^24)-1.
///
/// Value is an integer in decimal (1 to 3 digits).
pub const fn p_cost(&self) -> u32 {
Expand Down Expand Up @@ -432,7 +432,7 @@ impl ParamsBuilder {
Self::DEFAULT
}

/// Set memory size, expressed in kibibytes, between 1 and (2^32)-1.
/// Set memory size, expressed in kibibytes, between 8 and (2^32)-1.
pub fn m_cost(&mut self, m_cost: u32) -> &mut Self {
self.m_cost = m_cost;
self
Expand All @@ -444,7 +444,7 @@ impl ParamsBuilder {
self
}

/// Set degree of parallelism, between 1 and 255.
/// Set degree of parallelism, between 1 and (2^24)-1.
pub fn p_cost(&mut self, p_cost: u32) -> &mut Self {
self.p_cost = p_cost;
self
Expand Down

0 comments on commit 144b2e4

Please sign in to comment.