diff options
Diffstat (limited to 'src/tests/test_pubkey.cpp')
-rw-r--r-- | src/tests/test_pubkey.cpp | 40 |
1 files changed, 29 insertions, 11 deletions
diff --git a/src/tests/test_pubkey.cpp b/src/tests/test_pubkey.cpp index faa27f322..025628636 100644 --- a/src/tests/test_pubkey.cpp +++ b/src/tests/test_pubkey.cpp @@ -260,29 +260,47 @@ Test::Result PK_KEM_Test::run_one_test(const std::string&, const VarMap& vars) std::unique_ptr<Botan::Private_Key> privkey = load_private_key(vars); + const Botan::Public_Key& pubkey = *privkey; + const size_t desired_key_len = K.size(); - Botan::PK_KEM_Encryptor enc(*privkey, kdf); + std::unique_ptr<Botan::PK_KEM_Encryptor> enc; + try + { + enc.reset(new Botan::PK_KEM_Encryptor(pubkey, kdf)); + } + catch(Botan::Lookup_Error&) + { + return result; + } Fixed_Output_RNG fixed_output_rng(get_req_bin(vars, "R")); Botan::secure_vector<byte> produced_encap_key, shared_key; - enc.encrypt(produced_encap_key, - shared_key, - desired_key_len, - fixed_output_rng, - salt); + enc->encrypt(produced_encap_key, + shared_key, + desired_key_len, + fixed_output_rng, + salt); result.test_eq("C0 matches", produced_encap_key, C0); result.test_eq("K matches", shared_key, K); - Botan::PK_KEM_Decryptor dec(*privkey, kdf); + std::unique_ptr<Botan::PK_KEM_Decryptor> dec; + try + { + dec.reset(new Botan::PK_KEM_Decryptor(*privkey, kdf)); + } + catch(Botan::Lookup_Error&) + { + return result; + } const Botan::secure_vector<uint8_t> decr_shared_key = - dec.decrypt(C0.data(), C0.size(), - desired_key_len, - salt.data(), - salt.size()); + dec->decrypt(C0.data(), C0.size(), + desired_key_len, + salt.data(), + salt.size()); result.test_eq("decrypted K matches", decr_shared_key, K); |