Skip to content

Commit 00cfbc2

Browse files
authored
yescrypt: mcf simplification (#723)
Uses `push_str` to add params
1 parent c26dd45 commit 00cfbc2

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

yescrypt/src/lib.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,7 @@ pub fn yescrypt(passwd: &[u8], salt: &[u8], params: &Params) -> Result<String> {
109109
// Add params string to the hash
110110
let mut params_buf = [0u8; Params::MAX_ENCODED_LEN];
111111
let params_str = params.encode(&mut params_buf)?;
112-
let field = mcf::Field::new(params_str).map_err(|_| Error::Encoding)?;
113-
mcf_hash.push_field(field);
112+
mcf_hash.push_str(params_str).map_err(|_| Error::Encoding)?;
114113

115114
// Add salt
116115
mcf_hash.push_base64(salt, YESCRYPT_BASE64);
@@ -127,7 +126,7 @@ pub fn yescrypt(passwd: &[u8], salt: &[u8], params: &Params) -> Result<String> {
127126
/// Password hash should begin with `$y$` in Modular Crypt Format (MCF).
128127
#[cfg(feature = "simple")]
129128
pub fn yescrypt_verify(passwd: &[u8], hash: &str) -> Result<()> {
130-
let hash = mcf::PasswordHashRef::try_from(hash).map_err(|_| Error::Encoding)?;
129+
let hash = mcf::PasswordHashRef::new(hash).map_err(|_| Error::Encoding)?;
131130

132131
// verify id matches `$y`
133132
if hash.id() != YESCRYPT_MCF_ID {

0 commit comments

Comments
 (0)