Test: Fix diff_dklen_error check salt value and add verify error test for different iteration count
@@ -316,11 +316,11 @@ mod test {
}
#[test]
- fn verify_diff_dklen_panic() {
+ fn verify_diff_dklen_error() {
// Different dklen than expected dk
let dk = Pbkdf2 {
password: "pass\0word".as_bytes().to_vec(),
- salt: "".as_bytes().to_vec(),
+ salt: "sa\0lt".as_bytes().to_vec(),
iterations: 4096,
dklen: 32,
hmac: ShaVariantOption::SHA512,
@@ -330,4 +330,20 @@ mod test {
assert!(dk.verify(&expected_dk).is_err());
}
+
+ #[test]
+ fn verify_diff_iter_error() {
+
+ let dk = Pbkdf2 {
+ password: "pass\0word".as_bytes().to_vec(),
+ salt: "sa\0lt".as_bytes().to_vec(),
+ iterations: 800,
+ dklen: 16,
+ hmac: ShaVariantOption::SHA512,
+ };
+
+ let expected_dk = decode("9d9e9c4cd21fe4be24d5b8244c759665").unwrap();
+
+ assert!(dk.verify(&expected_dk).is_err());
+ }
}
