Skip to content

Commit

Permalink
argon2: add Params::DEFAULT constant (#439)
Browse files Browse the repository at this point in the history
Allows for accessing default parameters in const contexts
  • Loading branch information
tarcieri authored Jul 3, 2023
1 parent b0cc634 commit 3571f10
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions argon2/src/params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,22 @@ impl Params {
/// Maximum digest size in bytes.
pub const MAX_OUTPUT_LEN: usize = 0xFFFFFFFF;

/// Default parameters (recommended).
pub const DEFAULT: Self = Params {
m_cost: Self::DEFAULT_M_COST,
t_cost: Self::DEFAULT_T_COST,
p_cost: Self::DEFAULT_P_COST,
keyid: KeyId {
bytes: [0u8; Self::MAX_KEYID_LEN],
len: 0,
},
data: AssociatedData {
bytes: [0u8; Self::MAX_DATA_LEN],
len: 0,
},
output_len: None,
};

/// Create new parameters.
///
/// # Arguments
Expand Down Expand Up @@ -186,14 +202,7 @@ impl Params {

impl Default for Params {
fn default() -> Params {
Params {
m_cost: Self::DEFAULT_M_COST,
t_cost: Self::DEFAULT_T_COST,
p_cost: Self::DEFAULT_P_COST,
keyid: KeyId::default(),
data: AssociatedData::default(),
output_len: None,
}
Params::DEFAULT
}
}

Expand Down

0 comments on commit 3571f10

Please sign in to comment.