Minor corrections and one assert addition to fuzzing hkdf
@@ -8,17 +8,14 @@ use orion::core::options::ShaVariantOption;
use rand::prelude::*;
-fn make_hkdf(salt: &[u8], ikm: &[u8], info: &[u8]) -> Vec<u8> {
+fn make_hkdf(salt: &[u8], ikm: &[u8], info: &[u8]) -> () {
let mut rng = thread_rng();
- let len = rng.gen_range(0, 8160);
-
- let mut prk = Vec::new();
-
if rng.gen() {
let len = rng.gen_range(0, 8160);
+
let dk = Hkdf {
salt: salt.to_vec(),
ikm: ikm.to_vec(),
@@ -29,8 +26,9 @@ fn make_hkdf(salt: &[u8], ikm: &[u8], info: &[u8]) -> Vec<u8> {
let prk = dk.hkdf_extract(ikm, salt);
- dk.hkdf_expand(&prk).unwrap()
- } else { prk }
+ let dk_fin = dk.hkdf_expand(&prk).unwrap();
+ assert_eq!(dk_fin, dk.hkdf_compute().unwrap());
+ } else { () }
}
