aboutsummaryrefslogtreecommitdiffstats
path: root/src/tests/test_pubkey.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/tests/test_pubkey.cpp')
-rw-r--r--src/tests/test_pubkey.cpp17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/tests/test_pubkey.cpp b/src/tests/test_pubkey.cpp
index 722056b2f..2d4113c6d 100644
--- a/src/tests/test_pubkey.cpp
+++ b/src/tests/test_pubkey.cpp
@@ -191,6 +191,8 @@ PK_Signature_Verification_Test::run_one_test(const std::string& pad_hdr, const V
const std::vector<uint8_t> signature = get_req_bin(vars, "Signature");
const std::string padding = choose_padding(vars, pad_hdr);
+ const bool expected_valid = (get_opt_sz(vars, "Valid", 1) == 1);
+
std::unique_ptr<Botan::Public_Key> pubkey = load_public_key(vars);
Test::Result result(algo_name() + "/" + padding + " signature verification");
@@ -202,13 +204,24 @@ PK_Signature_Verification_Test::run_one_test(const std::string& pad_hdr, const V
try
{
verifier.reset(new Botan::PK_Verifier(*pubkey, padding, Botan::IEEE_1363, verify_provider));
- result.test_eq("correct signature valid", verifier->verify_message(message, signature), true);
- check_invalid_signatures(result, *verifier, message, signature);
}
catch(Botan::Lookup_Error&)
{
result.test_note("Skipping verifying with " + verify_provider);
}
+
+ if(verifier)
+ {
+ const bool verified = verifier->verify_message(message, signature);
+
+ if(expected_valid)
+ {
+ result.test_eq("correct signature valid", verified, true);
+ check_invalid_signatures(result, *verifier, message, signature);
+ }
+ else
+ result.test_eq("incorrect signature invalid", verified, false);
+ }
}
return result;