Skip to content

Commit 9852168

Browse files
reaperhulkalex
andauthored
Apply suggestions from code review
Co-authored-by: Alex Gaynor <alex.gaynor@gmail.com>
1 parent bef571b commit 9852168

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

openssl/src/kdf.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -99,14 +99,12 @@ cfg_if::cfg_if! {
9999
}
100100
params[idx] = ffi::OSSL_PARAM_construct_end();
101101

102-
let argon2_p = cvt_p(ffi::EVP_KDF_fetch(
102+
let argon2 = EvpKdf(cvt_p(ffi::EVP_KDF_fetch(
103103
ptr::null_mut(),
104104
b"ARGON2ID\0".as_ptr() as *const c_char,
105105
ptr::null(),
106-
))?;
107-
let argon2 = EvpKdf(argon2_p);
108-
let ctx_p = cvt_p(ffi::EVP_KDF_CTX_new(argon2.0))?;
109-
let ctx = EvpKdfCtx(ctx_p);
106+
))?);
107+
let ctx = EvpKdfCtx(cvt_p(ffi::EVP_KDF_CTX_new(argon2.0))?);
110108
cvt(ffi::EVP_KDF_derive(
111109
ctx.0,
112110
out.as_mut_ptr(),
@@ -151,12 +149,12 @@ mod tests {
151149
#[cfg(all(ossl320, not(osslconf = "OPENSSL_NO_ARGON2")))]
152150
fn argon2id_no_ad_secret() {
153151
// Test vector from OpenSSL
154-
let pass = "";
152+
let pass = b"";
155153
let salt = hex::decode("02020202020202020202020202020202").unwrap();
156154
let expected = "0a34f1abde67086c82e785eaf17c68382259a264f4e61b91cd2763cb75ac189a";
157155

158156
let mut actual = [0u8; 32];
159-
super::argon2id(pass.as_bytes(), &salt, None, None, 3, 4, 32, &mut actual).unwrap();
157+
super::argon2id(pass, &salt, None, None, 3, 4, 32, &mut actual).unwrap();
160158
assert_eq!(hex::encode(&actual[..]), expected);
161159
}
162160
}

0 commit comments

Comments
 (0)