aboutsummaryrefslogtreecommitdiffstats
path: root/src/tests/test_pbkdf.cpp
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2020-09-27 11:20:58 -0400
committerJack Lloyd <[email protected]>2020-09-27 11:20:58 -0400
commitff2e536ae58d0b4efd462703ab96e24257382be0 (patch)
tree5e1a4ec27737e6ce77a1e5d67f9e81efb69cd2c1 /src/tests/test_pbkdf.cpp
parent9a4e6c5b285ec9319006f17c4556bee5870452b4 (diff)
Test Argon2 via Pwdhash interface
Only works for vectors without AD since that's not supported...
Diffstat (limited to 'src/tests/test_pbkdf.cpp')
-rw-r--r--src/tests/test_pbkdf.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/tests/test_pbkdf.cpp b/src/tests/test_pbkdf.cpp
index f10b721e2..71c589f90 100644
--- a/src/tests/test_pbkdf.cpp
+++ b/src/tests/test_pbkdf.cpp
@@ -291,6 +291,27 @@ class Argon2_KAT_Tests final : public Text_Based_Test
result.test_eq("derived key", output, expected);
+ auto pwdhash_fam = Botan::PasswordHashFamily::create(mode);
+
+ if(!pwdhash_fam)
+ {
+ result.test_failure("Argon2 is missing PasswordHashFamily");
+ return result;
+ }
+
+ if(ad.size() == 0)
+ {
+ auto pwdhash = pwdhash_fam->from_params(M, T, P);
+
+ std::vector<uint8_t> pwdhash_derived(expected.size());
+ pwdhash->derive_key(pwdhash_derived.data(), pwdhash_derived.size(),
+ reinterpret_cast<const char*>(passphrase.data()),
+ passphrase.size(),
+ salt.data(), salt.size());
+
+ result.test_eq("pwdhash derived key", pwdhash_derived, expected);
+ }
+
return result;
}