diff options
author | Jack Lloyd <[email protected]> | 2017-09-24 13:04:08 -0400 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2017-09-24 13:04:08 -0400 |
commit | 3785deadff522923299c34bcd2ba364c02abbf0c (patch) | |
tree | d8993e9f91de3353b0be96bd7a5d542c6ae8192d /src | |
parent | 8e70617d88b3f486d03f156f4800673bc4e14d06 (diff) |
Further build/test fixes for restricted configurations
Diffstat (limited to 'src')
-rw-r--r-- | src/cli/speed.cpp | 4 | ||||
-rw-r--r-- | src/cli/utils.cpp | 2 | ||||
-rw-r--r-- | src/lib/math/mp/info.txt | 4 | ||||
-rw-r--r-- | src/lib/modes/aead/siv/siv.cpp | 5 | ||||
-rw-r--r-- | src/lib/modes/aead/siv/siv.h | 4 | ||||
-rw-r--r-- | src/lib/pk_pad/emsa.cpp | 1 | ||||
-rw-r--r-- | src/lib/prov/bearssl/info.txt | 4 | ||||
-rw-r--r-- | src/lib/pubkey/dlies/info.txt | 1 | ||||
-rw-r--r-- | src/lib/pubkey/eckcdsa/info.txt | 2 | ||||
-rw-r--r-- | src/lib/pubkey/pk_algs.cpp | 8 | ||||
-rw-r--r-- | src/lib/stream/shake_cipher/info.txt | 4 | ||||
-rw-r--r-- | src/tests/main.cpp | 18 | ||||
-rw-r--r-- | src/tests/test_c25519.cpp | 21 | ||||
-rw-r--r-- | src/tests/test_certstor.cpp | 3 | ||||
-rw-r--r-- | src/tests/test_ffi.cpp | 4 | ||||
-rw-r--r-- | src/tests/test_mceliece.cpp | 9 | ||||
-rw-r--r-- | src/tests/test_name_constraint.cpp | 2 | ||||
-rw-r--r-- | src/tests/test_ocb.cpp | 4 | ||||
-rw-r--r-- | src/tests/test_ocsp.cpp | 2 | ||||
-rw-r--r-- | src/tests/test_otp.cpp | 9 | ||||
-rw-r--r-- | src/tests/test_pubkey.cpp | 58 | ||||
-rw-r--r-- | src/tests/test_rng.cpp | 4 | ||||
-rw-r--r-- | src/tests/test_srp6.cpp | 3 | ||||
-rw-r--r-- | src/tests/test_x509_path.cpp | 2 | ||||
-rw-r--r-- | src/tests/unit_ecc.cpp | 4 | ||||
-rw-r--r-- | src/tests/unit_x509.cpp | 6 |
26 files changed, 158 insertions, 30 deletions
diff --git a/src/cli/speed.cpp b/src/cli/speed.cpp index d576e15c8..f5cc3c3b8 100644 --- a/src/cli/speed.cpp +++ b/src/cli/speed.cpp @@ -96,6 +96,10 @@ #include <botan/ed25519.h> #endif +#if defined(BOTAN_HAS_DL_GROUP) + #include <botan/dl_group.h> +#endif + #if defined(BOTAN_HAS_DIFFIE_HELLMAN) #include <botan/dh.h> #endif diff --git a/src/cli/utils.cpp b/src/cli/utils.cpp index 92a1a9d02..6b108eb43 100644 --- a/src/cli/utils.cpp +++ b/src/cli/utils.cpp @@ -82,7 +82,7 @@ cli_make_rng(const std::string& rng_type, const std::string& hex_drbg_seed) } #endif -#if defined(BOTAN_HAS_HMAC_DRBG) +#if defined(BOTAN_HAS_HMAC_DRBG) && defined(BOTAN_AUTO_RNG_HMAC) if(rng_type == "drbg") { std::unique_ptr<Botan::MessageAuthenticationCode> mac = diff --git a/src/lib/math/mp/info.txt b/src/lib/math/mp/info.txt index 0f5b075f0..4d748a495 100644 --- a/src/lib/math/mp/info.txt +++ b/src/lib/math/mp/info.txt @@ -11,3 +11,7 @@ mp_core.h mp_madd.h mp_asmi.h </header:internal> + +<requires> +bigint +</requires> diff --git a/src/lib/modes/aead/siv/siv.cpp b/src/lib/modes/aead/siv/siv.cpp index 665d25ec9..1ddfd4d88 100644 --- a/src/lib/modes/aead/siv/siv.cpp +++ b/src/lib/modes/aead/siv/siv.cpp @@ -23,6 +23,11 @@ SIV_Mode::SIV_Mode(BlockCipher* cipher) : throw Invalid_Argument("SIV requires a 128 bit block cipher"); } +SIV_Mode::~SIV_Mode() + { + // for ~unique_ptr + } + void SIV_Mode::clear() { m_ctr->clear(); diff --git a/src/lib/modes/aead/siv/siv.h b/src/lib/modes/aead/siv/siv.h index e4454dade..255e4a277 100644 --- a/src/lib/modes/aead/siv/siv.h +++ b/src/lib/modes/aead/siv/siv.h @@ -10,11 +10,11 @@ #define BOTAN_AEAD_SIV_H_ #include <botan/aead.h> +#include <botan/stream_cipher.h> namespace Botan { class BlockCipher; -class StreamCipher; class MessageAuthenticationCode; /** @@ -55,6 +55,8 @@ class BOTAN_PUBLIC_API(2,0) SIV_Mode : public AEAD_Mode protected: explicit SIV_Mode(BlockCipher* cipher); + ~SIV_Mode(); + StreamCipher& ctr() { return *m_ctr; } void set_ctr_iv(secure_vector<uint8_t> V); diff --git a/src/lib/pk_pad/emsa.cpp b/src/lib/pk_pad/emsa.cpp index 2c3370f4d..9904a0e2f 100644 --- a/src/lib/pk_pad/emsa.cpp +++ b/src/lib/pk_pad/emsa.cpp @@ -5,6 +5,7 @@ */ #include <botan/emsa.h> +#include <botan/hash.h> #include <botan/scan_name.h> #include <botan/exceptn.h> diff --git a/src/lib/prov/bearssl/info.txt b/src/lib/prov/bearssl/info.txt index cf38a1fe7..67bdc157d 100644 --- a/src/lib/prov/bearssl/info.txt +++ b/src/lib/prov/bearssl/info.txt @@ -11,3 +11,7 @@ bearssl.h <libs> all!windows -> bearssl </libs> + +<requires> +pubkey +</requires> diff --git a/src/lib/pubkey/dlies/info.txt b/src/lib/pubkey/dlies/info.txt index 65e3b22c9..ef14958e2 100644 --- a/src/lib/pubkey/dlies/info.txt +++ b/src/lib/pubkey/dlies/info.txt @@ -3,6 +3,7 @@ DLIES -> 20160713 </defines> <requires> +dh kdf mac block diff --git a/src/lib/pubkey/eckcdsa/info.txt b/src/lib/pubkey/eckcdsa/info.txt index 7c6b74b04..2bce4aa79 100644 --- a/src/lib/pubkey/eckcdsa/info.txt +++ b/src/lib/pubkey/eckcdsa/info.txt @@ -7,9 +7,11 @@ asn1 bigint ec_group ecc_key +emsa1 hash keypair numbertheory pk_pad rng +sha2_32 </requires> diff --git a/src/lib/pubkey/pk_algs.cpp b/src/lib/pubkey/pk_algs.cpp index 8a39a5ade..e821e7846 100644 --- a/src/lib/pubkey/pk_algs.cpp +++ b/src/lib/pubkey/pk_algs.cpp @@ -17,10 +17,18 @@ #include <botan/dsa.h> #endif +#if defined(BOTAN_HAS_DL_GROUP) + #include <botan/dl_group.h> +#endif + #if defined(BOTAN_HAS_DIFFIE_HELLMAN) #include <botan/dh.h> #endif +#if defined(BOTAN_HAS_ECC_PUBLIC_KEY_CRYPTO) + #include <botan/ecc_key.h> +#endif + #if defined(BOTAN_HAS_ECDSA) #include <botan/ecdsa.h> #endif diff --git a/src/lib/stream/shake_cipher/info.txt b/src/lib/stream/shake_cipher/info.txt index 500a7265d..ca2a0c079 100644 --- a/src/lib/stream/shake_cipher/info.txt +++ b/src/lib/stream/shake_cipher/info.txt @@ -1,3 +1,7 @@ <defines> SHAKE_CIPHER -> 20161018 </defines> + +<requires> +sha3 +</requires> diff --git a/src/tests/main.cpp b/src/tests/main.cpp index 0ddd28dc2..352b74b75 100644 --- a/src/tests/main.cpp +++ b/src/tests/main.cpp @@ -52,7 +52,7 @@ class Test_Runner final : public Botan_CLI::Command { std::unique_ptr<Botan::RandomNumberGenerator> rng; -#if defined(BOTAN_HAS_HMAC_DRBG) && defined(BOTAN_HAS_SHA2_64) +#if defined(BOTAN_HAS_HMAC_DRBG) && defined(BOTAN_AUTO_RNG_HMAC) std::vector<uint8_t> seed = Botan::hex_decode(drbg_seed); if(seed.empty()) @@ -62,15 +62,17 @@ class Test_Runner final : public Botan_CLI::Command Botan::store_be(ts, seed.data()); } - output() << " rng:HMAC_DRBG with seed '" << Botan::hex_encode(seed) << "'\n"; + output() << " rng:HMAC_DRBG(" << BOTAN_AUTO_RNG_HMAC << ") with seed '" << Botan::hex_encode(seed) << "'\n"; - // Expand out the seed to 512 bits to make the DRBG happy - std::unique_ptr<Botan::HashFunction> sha512(Botan::HashFunction::create("SHA-512")); - sha512->update(seed); - seed.resize(sha512->output_length()); - sha512->final(seed.data()); + // Expand out the seed with a hash to make the DRBG happy + std::unique_ptr<Botan::MessageAuthenticationCode> mac = + Botan::MessageAuthenticationCode::create(BOTAN_AUTO_RNG_HMAC); - std::unique_ptr<Botan::HMAC_DRBG> drbg(new Botan::HMAC_DRBG("SHA-384")); + mac->set_key(seed); + seed.resize(mac->output_length()); + mac->final(seed.data()); + + std::unique_ptr<Botan::HMAC_DRBG> drbg(new Botan::HMAC_DRBG(std::move(mac))); drbg->initialize_with(seed.data(), seed.size()); #if defined(BOTAN_TARGET_OS_HAS_THREADS) diff --git a/src/tests/test_c25519.cpp b/src/tests/test_c25519.cpp index ccc84a4b0..2c7003e1d 100644 --- a/src/tests/test_c25519.cpp +++ b/src/tests/test_c25519.cpp @@ -38,6 +38,7 @@ class Curve25519_Sclarmult_Tests final : public Text_Based_Test return result; } }; +BOTAN_REGISTER_TEST("curve25519_scalar", Curve25519_Sclarmult_Tests); class Curve25519_Roundtrip_Test final : public Test { @@ -57,6 +58,7 @@ class Curve25519_Roundtrip_Test final : public Test const std::string b_pass = "bob pass"; // Then serialize to encrypted storage +#if defined(BOTAN_HAS_AES) && defined(BOTAN_HAS_GCM) const auto pbe_time = std::chrono::milliseconds(10); const std::string a_priv_pem = Botan::PKCS8::PEM_encode(a_priv_gen, Test::rng(), a_pass, pbe_time); const std::string b_priv_pem = Botan::PKCS8::PEM_encode(b_priv_gen, Test::rng(), b_pass, pbe_time); @@ -67,6 +69,17 @@ class Curve25519_Roundtrip_Test final : public Test std::unique_ptr<Botan::Private_Key> a_priv(Botan::PKCS8::load_key(a_priv_ds, Test::rng(), [a_pass]() { return a_pass; })); std::unique_ptr<Botan::Private_Key> b_priv(Botan::PKCS8::load_key(b_priv_ds, Test::rng(), b_pass)); +#else + const std::string a_priv_pem = Botan::PKCS8::PEM_encode(a_priv_gen); + const std::string b_priv_pem = Botan::PKCS8::PEM_encode(b_priv_gen); + + // Reload back into memory + Botan::DataSource_Memory a_priv_ds(a_priv_pem); + Botan::DataSource_Memory b_priv_ds(b_priv_pem); + + std::unique_ptr<Botan::Private_Key> a_priv(Botan::PKCS8::load_key(a_priv_ds, Test::rng())); + std::unique_ptr<Botan::Private_Key> b_priv(Botan::PKCS8::load_key(b_priv_ds, Test::rng())); +#endif // Export public keys as PEM const std::string a_pub_pem = Botan::X509::PEM_encode(*a_priv); @@ -83,8 +96,8 @@ class Curve25519_Roundtrip_Test final : public Test if(a_pub_key && b_pub_key) { - Botan::PK_Key_Agreement a_ka(*a_priv, Test::rng(), "KDF2(SHA-256)"); - Botan::PK_Key_Agreement b_ka(*b_priv, Test::rng(), "KDF2(SHA-256)"); + Botan::PK_Key_Agreement a_ka(*a_priv, Test::rng(), "Raw"); + Botan::PK_Key_Agreement b_ka(*b_priv, Test::rng(), "Raw"); const std::string context = "shared context value"; Botan::SymmetricKey a_key = a_ka.derive_key(32, b_pub_key->public_value(), context); @@ -108,6 +121,8 @@ class Curve25519_Roundtrip_Test final : public Test } }; +BOTAN_REGISTER_TEST("curve25519_rt", Curve25519_Roundtrip_Test); + class Curve25519_Keygen_Tests final : public PK_Key_Generation_Test { public: @@ -121,8 +136,6 @@ class Curve25519_Keygen_Tests final : public PK_Key_Generation_Test } }; -BOTAN_REGISTER_TEST("curve25519_scalar", Curve25519_Sclarmult_Tests); -BOTAN_REGISTER_TEST("curve25519_rt", Curve25519_Roundtrip_Test); BOTAN_REGISTER_TEST("curve25519_keygen", Curve25519_Keygen_Tests); #endif diff --git a/src/tests/test_certstor.cpp b/src/tests/test_certstor.cpp index 24b905cfd..1bdf28a60 100644 --- a/src/tests/test_certstor.cpp +++ b/src/tests/test_certstor.cpp @@ -21,7 +21,8 @@ namespace Botan_Tests { namespace { -#if defined(BOTAN_HAS_CERTSTOR_SQL) +#if defined(BOTAN_HAS_CERTSTOR_SQL) && defined(BOTAN_HAS_RSA) + struct CertificateAndKey { const Botan::X509_Certificate certificate; diff --git a/src/tests/test_ffi.cpp b/src/tests/test_ffi.cpp index 34127893d..b639a95b2 100644 --- a/src/tests/test_ffi.cpp +++ b/src/tests/test_ffi.cpp @@ -233,6 +233,7 @@ class FFI_Unit_Tests final : public Test result.test_note("PBKDF timed 10 ms " + std::to_string(iters_10ms) + " iterations " + "100 ms " + std::to_string(iters_100ms) + " iterations"); +#if defined(BOTAN_HAS_KDF2) const std::vector<uint8_t> kdf_secret = Botan::hex_decode("92167440112E"); const std::vector<uint8_t> kdf_salt = Botan::hex_decode("45A9BEDED69163123D0348F5185F61ABFB1BF18D6AEA454F"); const size_t kdf_out_len = 18; @@ -248,6 +249,7 @@ class FFI_Unit_Tests final : public Test { result.test_eq("KDF output", outbuf, "3A5DC9AA1C872B4744515AC2702D6396FC2A"); } +#endif size_t out_len = 64; outstr.resize(out_len); @@ -263,6 +265,7 @@ class FFI_Unit_Tests final : public Test TEST_FFI_FAIL("bad password", botan_bcrypt_is_valid, ("nope", outstr.data())); } +#if defined(BOTAN_HAS_ECDSA) // x509 cert test botan_x509_cert_t cert; if(TEST_FFI_OK(botan_x509_cert_load_file, (&cert, Test::data_file("ecc/CSCA.CSCA.csca-germany.1.crt").c_str()))) @@ -358,6 +361,7 @@ class FFI_Unit_Tests final : public Test TEST_FFI_OK(botan_x509_cert_destroy, (cert)); } +#endif std::vector<Test::Result> results; results.push_back(ffi_test_errors()); diff --git a/src/tests/test_mceliece.cpp b/src/tests/test_mceliece.cpp index 7f27e844b..bcc467344 100644 --- a/src/tests/test_mceliece.cpp +++ b/src/tests/test_mceliece.cpp @@ -32,7 +32,7 @@ namespace { #if defined(BOTAN_HAS_MCELIECE) -#if defined(BOTAN_HAS_HMAC_DRBG) +#if defined(BOTAN_HAS_HMAC_DRBG) && defined(BOTAN_HAS_SHA2_32) && defined(BOTAN_HASH_SHA2_64) class McEliece_Keygen_Encrypt_Test final : public Text_Based_Test { public: @@ -117,6 +117,9 @@ class McEliece_Keygen_Encrypt_Test final : public Text_Based_Test BOTAN_REGISTER_TEST("mce_keygen", McEliece_Keygen_Encrypt_Test); #endif + +#if defined(BOTAN_HAS_SHA2_32) + class McEliece_Tests final : public Test { public: @@ -190,7 +193,9 @@ class McEliece_Tests final : public Test results.push_back(result); +#if defined(BOTAN_HAS_KDF2) results.push_back(test_kem(sk, pk)); +#endif #if defined(BOTAN_HAS_MCEIES) results.push_back(test_mceies(sk, pk)); @@ -280,6 +285,8 @@ BOTAN_REGISTER_TEST("mceliece", McEliece_Tests); #endif +#endif + } } diff --git a/src/tests/test_name_constraint.cpp b/src/tests/test_name_constraint.cpp index 46ebaa466..62c014fde 100644 --- a/src/tests/test_name_constraint.cpp +++ b/src/tests/test_name_constraint.cpp @@ -17,7 +17,7 @@ namespace Botan_Tests { namespace { -#if defined(BOTAN_HAS_X509_CERTIFICATES) +#if defined(BOTAN_HAS_X509_CERTIFICATES) && defined(BOTAN_HAS_RSA) class Name_Constraint_Tests final : public Test { diff --git a/src/tests/test_ocb.cpp b/src/tests/test_ocb.cpp index 177365409..8fc41c6c6 100644 --- a/src/tests/test_ocb.cpp +++ b/src/tests/test_ocb.cpp @@ -166,8 +166,12 @@ class OCB_Wide_Long_KAT_Tests final : public Text_Based_Test if(algo == "SHACAL2") { +#if defined(BOTAN_HAS_SHACAL2) cipher = Botan::BlockCipher::create_or_throw("SHACAL2"); bs = 32; +#else + return {result}; +#endif } else { diff --git a/src/tests/test_ocsp.cpp b/src/tests/test_ocsp.cpp index 542b4b575..bcf0e517d 100644 --- a/src/tests/test_ocsp.cpp +++ b/src/tests/test_ocsp.cpp @@ -15,7 +15,7 @@ namespace Botan_Tests { -#if defined(BOTAN_HAS_OCSP) +#if defined(BOTAN_HAS_OCSP) && defined(BOTAN_HAS_RSA) class OCSP_Tests final : public Test { diff --git a/src/tests/test_otp.cpp b/src/tests/test_otp.cpp index dfe01aa93..9bd4c0f18 100644 --- a/src/tests/test_otp.cpp +++ b/src/tests/test_otp.cpp @@ -6,6 +6,7 @@ */ #include "tests.h" +#include <botan/hash.h> #if defined(BOTAN_HAS_HOTP) #include <botan/parsing.h> @@ -34,6 +35,10 @@ class HOTP_KAT_Tests final : public Text_Based_Test { Test::Result result("HOTP " + hash_algo); + std::unique_ptr<Botan::HashFunction> hash_test = Botan::HashFunction::create(hash_algo); + if(!hash_test) + return {result}; + const std::vector<uint8_t> key = get_req_bin(vars, "Key"); const size_t otp = get_req_sz(vars, "OTP"); const uint64_t counter = get_req_sz(vars, "Counter"); @@ -85,6 +90,10 @@ class TOTP_KAT_Tests final : public Text_Based_Test { Test::Result result("TOTP " + hash_algo); + std::unique_ptr<Botan::HashFunction> hash_test = Botan::HashFunction::create(hash_algo); + if(!hash_test) + return {result}; + const std::vector<uint8_t> key = get_req_bin(vars, "Key"); const size_t otp = get_req_sz(vars, "OTP"); const size_t digits = get_req_sz(vars, "Digits"); diff --git a/src/tests/test_pubkey.cpp b/src/tests/test_pubkey.cpp index 3859fcf8f..b3038ca0c 100644 --- a/src/tests/test_pubkey.cpp +++ b/src/tests/test_pubkey.cpp @@ -454,7 +454,11 @@ std::vector<Test::Result> PK_Key_Generation_Test::run() const Botan::Private_Key& key = *key_p; - result.confirm("Key passes self tests", key.check_key(Test::rng(), true)); + try + { + result.confirm("Key passes self tests", key.check_key(Test::rng(), true)); + } + catch(Botan::Lookup_Error&) {} result.test_gte("Key has reasonable estimated strength (lower)", key.estimated_strength(), 64); result.test_lt("Key has reasonable estimated strength (upper)", key.estimated_strength(), 512); @@ -467,7 +471,12 @@ std::vector<Test::Result> PK_Key_Generation_Test::run() result.confirm("recovered public key from private", loaded.get() != nullptr); result.test_eq("public key has same type", loaded->algo_name(), key.algo_name()); - result.test_eq("public key passes checks", loaded->check_key(Test::rng(), false), true); + + try + { + result.test_eq("public key passes checks", loaded->check_key(Test::rng(), false), true); + } + catch(Botan::Lookup_Error&) {} } catch(std::exception& e) { @@ -482,7 +491,12 @@ std::vector<Test::Result> PK_Key_Generation_Test::run() result.confirm("recovered public key from private", loaded.get() != nullptr); result.test_eq("public key has same type", loaded->algo_name(), key.algo_name()); - result.test_eq("public key passes checks", loaded->check_key(Test::rng(), false), true); + + try + { + result.confirm("public key passes self tests", loaded->check_key(Test::rng(), true)); + } + catch(Botan::Lookup_Error&) {} } catch(std::exception& e) { @@ -498,7 +512,12 @@ std::vector<Test::Result> PK_Key_Generation_Test::run() result.confirm("recovered private key from PEM blob", loaded.get() != nullptr); result.test_eq("reloaded key has same type", loaded->algo_name(), key.algo_name()); - result.test_eq("private key passes checks", loaded->check_key(Test::rng(), false), true); + + try + { + result.confirm("private key passes self tests", loaded->check_key(Test::rng(), true)); + } + catch(Botan::Lookup_Error&) {} } catch(std::exception& e) { @@ -512,27 +531,39 @@ std::vector<Test::Result> PK_Key_Generation_Test::run() result.confirm("recovered public key from private", loaded.get() != nullptr); result.test_eq("public key has same type", loaded->algo_name(), key.algo_name()); - result.test_eq("public key passes checks", loaded->check_key(Test::rng(), false), true); + try + { + result.confirm("private key passes self tests", loaded->check_key(Test::rng(), true)); + } + catch(Botan::Lookup_Error&) {} } catch(std::exception& e) { result.test_failure("roundtrip BER private key", e.what()); } +#if defined(BOTAN_HAS_PKCS5_PBE2) && defined(BOTAN_HAS_AES) && defined(BOTAN_HAS_SHA2_32) + + const std::string pbe_algo = "PBE-PKCS5v20(AES-128,SHA-256)"; const std::string passphrase = Test::random_password(); try { Botan::DataSource_Memory data_src( Botan::PKCS8::PEM_encode(key, Test::rng(), passphrase, - std::chrono::milliseconds(10))); + std::chrono::milliseconds(10), + pbe_algo)); std::unique_ptr<Botan::Private_Key> loaded( Botan::PKCS8::load_key(data_src, Test::rng(), passphrase)); result.confirm("recovered private key from encrypted blob", loaded.get() != nullptr); result.test_eq("reloaded key has same type", loaded->algo_name(), key.algo_name()); - result.test_eq("private key passes checks", loaded->check_key(Test::rng(), false), true); + try + { + result.confirm("private key passes self tests", loaded->check_key(Test::rng(), true)); + } + catch(Botan::Lookup_Error&) {} } catch(std::exception& e) { @@ -543,21 +574,28 @@ std::vector<Test::Result> PK_Key_Generation_Test::run() { Botan::DataSource_Memory data_src( Botan::PKCS8::BER_encode(key, Test::rng(), passphrase, - std::chrono::milliseconds(10))); + std::chrono::milliseconds(10), + pbe_algo)); std::unique_ptr<Botan::Private_Key> loaded( Botan::PKCS8::load_key(data_src, Test::rng(), passphrase)); result.confirm("recovered private key from BER blob", loaded.get() != nullptr); result.test_eq("reloaded key has same type", loaded->algo_name(), key.algo_name()); - result.test_eq("private key passes checks", loaded->check_key(Test::rng(), false), true); + + try + { + result.confirm("private key passes self tests", loaded->check_key(Test::rng(), true)); + } + catch(Botan::Lookup_Error&) {} } catch(std::exception& e) { result.test_failure("roundtrip encrypted BER private key", e.what()); } - +#endif } + result.end_timer(); results.push_back(result); diff --git a/src/tests/test_rng.cpp b/src/tests/test_rng.cpp index 51d636693..e018349c0 100644 --- a/src/tests/test_rng.cpp +++ b/src/tests/test_rng.cpp @@ -8,6 +8,10 @@ #include "tests.h" #include "test_rng.h" +#if defined(BOTAN_HAS_STATEFUL_RNG) + #include <botan/stateful_rng.h> +#endif + #if defined(BOTAN_HAS_HMAC_DRBG) #include <botan/hmac_drbg.h> #endif diff --git a/src/tests/test_srp6.cpp b/src/tests/test_srp6.cpp index 741e9ef46..831df1b82 100644 --- a/src/tests/test_srp6.cpp +++ b/src/tests/test_srp6.cpp @@ -14,7 +14,8 @@ namespace Botan_Tests { namespace { -#if defined(BOTAN_HAS_SRP6) +#if defined(BOTAN_HAS_SRP6) && defined(BOTAN_HAS_SHA2_32) + class SRP6_Unit_Tests final : public Test { public: diff --git a/src/tests/test_x509_path.cpp b/src/tests/test_x509_path.cpp index e805a29b3..e31d3265c 100644 --- a/src/tests/test_x509_path.cpp +++ b/src/tests/test_x509_path.cpp @@ -23,7 +23,7 @@ namespace Botan_Tests { namespace { -#if defined(BOTAN_HAS_X509_CERTIFICATES) && defined(BOTAN_TARGET_OS_HAS_FILESYSTEM) +#if defined(BOTAN_HAS_X509_CERTIFICATES) && defined(BOTAN_HAS_RSA) && defined(BOTAN_TARGET_OS_HAS_FILESYSTEM) std::map<std::string, std::string> read_results(const std::string& results_file) { diff --git a/src/tests/unit_ecc.cpp b/src/tests/unit_ecc.cpp index f46b94295..212a19dc4 100644 --- a/src/tests/unit_ecc.cpp +++ b/src/tests/unit_ecc.cpp @@ -860,6 +860,8 @@ class ECC_Unit_Tests final : public Test BOTAN_REGISTER_TEST("ecc_unit", ECC_Unit_Tests); +#if defined(BOTAN_HAS_ECDSA) + class ECC_Invalid_Key_Tests final : public Text_Based_Test { public: @@ -890,6 +892,8 @@ BOTAN_REGISTER_TEST("ecc_invalid", ECC_Invalid_Key_Tests); #endif +#endif + } } diff --git a/src/tests/unit_x509.cpp b/src/tests/unit_x509.cpp index bf17fda3f..b9aa1709e 100644 --- a/src/tests/unit_x509.cpp +++ b/src/tests/unit_x509.cpp @@ -996,6 +996,12 @@ Test::Result test_hashes(const std::string& algo, const std::string& hash_fn = " const std::unique_ptr<Botan::Private_Key> key(make_a_private_key(algo)); + if(!key) + { + result.test_note("Skipping due to missing signature algorithm: " + algo); + return result; + } + struct TestData { const std::string issuer, subject, issuer_hash, subject_hash; |