Add salt length tests to default API
@@ -233,17 +233,6 @@ mod test {
assert_eq!(default::hkdf_verify(&hkdf_dk, &salt, data, info, 64), true);
}
- #[test]
- fn pbkdf2_verify() {
-
- let salt = util::gen_rand_key(64);
- let password = util::gen_rand_key(64);
-
- let pbkdf2_dk = default::pbkdf2(&password, &salt);
-
- assert_eq!(default::pbkdf2_verify(&pbkdf2_dk, &password, &salt), true);
- }
-
#[test]
#[should_panic]
fn hkdf_salt_too_short() {
@@ -256,9 +245,26 @@ mod test {
default::hkdf(&vec![0x61; 89], &vec![0x61; 10], &vec![0x61; 10], 20);
}
+ #[test]
+ fn pbkdf2_verify() {
+
+ let salt = util::gen_rand_key(64);
+ let password = util::gen_rand_key(64);
+
+ let pbkdf2_dk = default::pbkdf2(&password, &salt);
+
+ assert_eq!(default::pbkdf2_verify(&pbkdf2_dk, &password, &salt), true);
+ }
+
#[test]
#[should_panic]
fn pbkdf2_salt_too_short() {
default::pbkdf2("Secret password".as_bytes(), "Very weak salt".as_bytes());
}
+
+ #[test]
+ fn pbkdf2_salt_allowed_len() {
+ default::pbkdf2(&vec![0x61; 10], &vec![0x61; 67]);
+ default::pbkdf2(&vec![0x61; 10], &vec![0x61; 64]);
+ }
}
