diff options
author | Jack Lloyd <[email protected]> | 2016-10-18 21:08:51 -0400 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2016-10-18 21:09:34 -0400 |
commit | d1817c9960f619b130388a570ed09ccbed568e2e (patch) | |
tree | ac39e7f2e6b33e48fdd913aea236a81d5d4563b3 | |
parent | ff3d2def09eecff9a2431356811e7d9f5f6140c6 (diff) |
Fix pubkey tests when EMEs are disabled.
Test assumed EME was always there and would fail. This caused
failures with BSI policy which disables PKCS1v1.5
-rw-r--r-- | src/tests/test_pubkey.cpp | 44 |
1 files changed, 14 insertions, 30 deletions
diff --git a/src/tests/test_pubkey.cpp b/src/tests/test_pubkey.cpp index 745b18614..8552e1e51 100644 --- a/src/tests/test_pubkey.cpp +++ b/src/tests/test_pubkey.cpp @@ -197,17 +197,22 @@ PK_Encryption_Decryption_Test::run_one_test(const std::string&, const VarMap& va //std::unique_ptr<Botan::Public_Key> pubkey(Botan::X509::load_key(Botan::X509::BER_encode(*privkey))); Botan::Public_Key* pubkey = privkey.get(); - // test EME::maximum_input_size() - std::unique_ptr<Botan::EME> eme(Botan::get_eme(padding)); + try { + // test EME::maximum_input_size() + std::unique_ptr<Botan::EME> eme(Botan::get_eme(padding)); - if(eme) + if(eme) + { + size_t max_input_size = eme->maximum_input_size(1); + result.test_eq("maximum input size( 1 ) should always return 0", max_input_size, 0); + size_t keybits = pubkey->max_input_bits(); + max_input_size = eme->maximum_input_size(keybits); + result.test_gte("maximum input size( keybits ) > 0", max_input_size, 1); + } + } + catch(Botan::Lookup_Error&) { - size_t max_input_size = eme->maximum_input_size(1); - result.test_eq("maximum input size( 1 ) should always return 0", max_input_size, 0); - - size_t keybits = pubkey->max_input_bits(); - max_input_size = eme->maximum_input_size(keybits); - result.test_gte("maximum input size( keybits ) > 0", max_input_size, 1); + result.note_missing("PK padding " + padding); } for(auto&& enc_provider : possible_pk_providers()) @@ -218,10 +223,6 @@ PK_Encryption_Decryption_Test::run_one_test(const std::string&, const VarMap& va { encryptor.reset(new Botan::PK_Encryptor_EME(*pubkey, Test::rng(),padding, enc_provider)); } - catch(Botan::Provider_Not_Found&) - { - continue; - } catch(Botan::Lookup_Error&) { continue; @@ -250,10 +251,6 @@ PK_Encryption_Decryption_Test::run_one_test(const std::string&, const VarMap& va { decryptor.reset(new Botan::PK_Decryptor_EME(*privkey, Test::rng(), padding, dec_provider)); } - catch(Botan::Provider_Not_Found&) - { - continue; - } catch(Botan::Lookup_Error&) { continue; @@ -293,11 +290,6 @@ Test::Result PK_KEM_Test::run_one_test(const std::string&, const VarMap& vars) { enc.reset(new Botan::PK_KEM_Encryptor(pubkey, Test::rng(), kdf)); } - catch(Botan::Provider_Not_Found& e) - { - result.test_note("Skipping test", e.what()); - return result; - } catch(Botan::Lookup_Error&) { result.test_note("Skipping due to missing KDF: " + kdf); @@ -321,11 +313,6 @@ Test::Result PK_KEM_Test::run_one_test(const std::string&, const VarMap& vars) { dec.reset(new Botan::PK_KEM_Decryptor(*privkey, Test::rng(), kdf)); } - catch(Botan::Provider_Not_Found& e) - { - result.test_note("Skipping test", e.what()); - return result; - } catch(Botan::Lookup_Error& e) { result.test_note("Skipping test", e.what()); @@ -366,9 +353,6 @@ Test::Result PK_Key_Agreement_Test::run_one_test(const std::string& header, cons kas.reset(new Botan::PK_Key_Agreement(*privkey, Test::rng(), kdf, provider)); result.test_eq(provider, "agreement", kas->derive_key(key_len, pubkey).bits_of(), shared); } - catch(Botan::Provider_Not_Found&) - { - } catch(Botan::Lookup_Error&) { //result.test_note("Skipping key agreement with with " + provider); |