diff options
author | Jack Lloyd <[email protected]> | 2016-12-20 00:00:25 -0500 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2016-12-20 00:00:25 -0500 |
commit | 46bf28e0b6d9627a57862a180142fbf158f33ce7 (patch) | |
tree | 08735043ffc08d3a1518acd322caa837ece94756 /src/tests/test_pubkey.cpp | |
parent | c7530347f1d49752d5977d8b3d3e13f2342cb8ff (diff) |
Add RSA PKCS1v1.5 signature verification tests from Wycheproof suite.
A set of carefully generated invalid signatures which are sometimes
accepted by implementations due to bugs in padding verification.
Diffstat (limited to 'src/tests/test_pubkey.cpp')
-rw-r--r-- | src/tests/test_pubkey.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/tests/test_pubkey.cpp b/src/tests/test_pubkey.cpp index bc20da9d9..86d04169e 100644 --- a/src/tests/test_pubkey.cpp +++ b/src/tests/test_pubkey.cpp @@ -197,6 +197,35 @@ PK_Signature_Verification_Test::run_one_test(const std::string&, const VarMap& v } Test::Result +PK_Signature_NonVerification_Test::run_one_test(const std::string&, const VarMap& vars) + { + const std::string padding = get_opt_str(vars, "Padding", default_padding(vars)); + const std::vector<uint8_t> message = get_req_bin(vars, "Msg"); + std::unique_ptr<Botan::Public_Key> pubkey = load_public_key(vars); + + const std::vector<uint8_t> invalid_signature = get_req_bin(vars, "InvalidSignature"); + + Test::Result result(algo_name() + "/" + padding + " verify invalid signature"); + + for(auto&& verify_provider : possible_pk_providers()) + { + std::unique_ptr<Botan::PK_Verifier> verifier; + + try + { + verifier.reset(new Botan::PK_Verifier(*pubkey, padding, Botan::IEEE_1363, verify_provider)); + result.test_eq("incorrect signature rejected", verifier->verify_message(message, invalid_signature), false); + } + catch(Botan::Lookup_Error&) + { + result.test_note("Skipping verifying with " + verify_provider); + } + } + + return result; + } + +Test::Result PK_Encryption_Decryption_Test::run_one_test(const std::string&, const VarMap& vars) { const std::vector<uint8_t> plaintext = get_req_bin(vars, "Msg"); |