aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlloyd <[email protected]>2014-02-09 16:52:51 +0000
committerlloyd <[email protected]>2014-02-09 16:52:51 +0000
commit4f3b0ce8fccd879791d5a701102ee0737f3509b1 (patch)
tree37ab6f550154de465d2677fdab1cc1d96904fa5c
parent253aa701ffa654af3c880e1e1b4965fabf86be3b (diff)
More fixes for minified builds
-rw-r--r--src/build-data/cc/gcc.txt2
-rw-r--r--src/build-data/makefile/header.in2
-rw-r--r--src/cmd/main.cpp5
-rw-r--r--src/lib/engine/core_engine/lookup_stream.cpp8
-rw-r--r--src/lib/modes/aead/aead.cpp1
-rw-r--r--src/lib/pk_pad/get_pk_pad.cpp7
-rw-r--r--src/tests/nist_x509.cpp5
-rw-r--r--src/tests/test_aead.cpp3
-rw-r--r--src/tests/test_block.cpp5
-rw-r--r--src/tests/test_dh.cpp8
-rw-r--r--src/tests/test_dlies.cpp21
-rw-r--r--src/tests/test_dsa.cpp9
-rw-r--r--src/tests/test_ecdsa.cpp13
-rw-r--r--src/tests/test_elg.cpp19
-rw-r--r--src/tests/test_gost_3410.cpp8
-rw-r--r--src/tests/test_hkdf.cpp18
-rw-r--r--src/tests/test_nr.cpp20
-rw-r--r--src/tests/test_ocb.cpp15
-rw-r--r--src/tests/test_pubkey.cpp2
-rw-r--r--src/tests/test_rng.cpp24
-rw-r--r--src/tests/test_rw.cpp17
-rw-r--r--src/tests/test_transform.cpp2
-rw-r--r--src/tests/unit_ecc.cpp22
23 files changed, 141 insertions, 95 deletions
diff --git a/src/build-data/cc/gcc.txt b/src/build-data/cc/gcc.txt
index 8a3e45461..0002abccd 100644
--- a/src/build-data/cc/gcc.txt
+++ b/src/build-data/cc/gcc.txt
@@ -9,7 +9,7 @@ add_lib_dir_option -L
add_lib_option -l
lang_flags "-std=c++11 -D_REENTRANT -fstack-protector"
-maintainer_warning_flags "-Werror -Wno-error=old-style-cast -Wno-error=zero-as-null-pointer-constant -Wno-error=unused-parameter"
+maintainer_warning_flags "-Werror -Wno-error=old-style-cast -Wno-error=zero-as-null-pointer-constant -Wno-error=unused-parameter -Wno-error=unused-variable"
warning_flags "-Wall -Wextra -Wstrict-aliasing -Wstrict-overflow=5 -Wcast-align -Wmissing-declarations -Wpointer-arith -Wcast-qual -Wold-style-cast -Wzero-as-null-pointer-constant"
lib_opt_flags "-O3"
diff --git a/src/build-data/makefile/header.in b/src/build-data/makefile/header.in
index 1963b57de..4229de29b 100644
--- a/src/build-data/makefile/header.in
+++ b/src/build-data/makefile/header.in
@@ -10,7 +10,7 @@ LIB_LINK_CMD = %{so_link}
LIB_LINKS_TO = %{link_to}
APP_LINKS_TO = $(LIB_LINKS_TO)
-TEST_LINKS_TO = $(LIB_LINKS_TO) -lboost_filesystem
+TEST_LINKS_TO = $(LIB_LINKS_TO) -lboost_filesystem -lboost_system
LIB_FLAGS = $(SO_OBJ_FLAGS) $(LANG_FLAGS) $(LIB_OPT) $(WARN_FLAGS)
APP_FLAGS = $(LANG_FLAGS) $(APP_OPT) $(WARN_FLAGS)
diff --git a/src/cmd/main.cpp b/src/cmd/main.cpp
index 6e4cb6702..37db57f68 100644
--- a/src/cmd/main.cpp
+++ b/src/cmd/main.cpp
@@ -22,7 +22,10 @@
#include <botan/version.h>
#include <botan/auto_rng.h>
#include <botan/cpuid.h>
+
+#if defined(BOTAN_HAS_HTTP_UTIL)
#include <botan/http_util.h>
+#endif
using namespace Botan;
@@ -96,11 +99,13 @@ int main(int argc, char* argv[])
return 0;
}
+#if defined(BOTAN_HAS_HTTP_UTIL)
if(cmd == "http_get")
{
auto resp = HTTP::GET_sync(argv[2]);
std::cout << resp << "\n";
}
+#endif
#define CALL_APP(cmdsym) \
do { if(cmd == #cmdsym) { return cmdsym ##_main (argc - 1, argv + 1); } } while(0)
diff --git a/src/lib/engine/core_engine/lookup_stream.cpp b/src/lib/engine/core_engine/lookup_stream.cpp
index 8461fadc9..9e9a7e8df 100644
--- a/src/lib/engine/core_engine/lookup_stream.cpp
+++ b/src/lib/engine/core_engine/lookup_stream.cpp
@@ -41,16 +41,16 @@ Core_Engine::find_stream_cipher(const SCAN_Name& request,
#if defined(BOTAN_HAS_OFB)
if(request.algo_name() == "OFB" && request.arg_count() == 1)
{
- const BlockCipher* proto = af.prototype_block_cipher(request.arg(0));
- return new OFB(proto->clone());
+ if(auto proto = af.prototype_block_cipher(request.arg(0)))
+ return new OFB(proto->clone());
}
#endif
#if defined(BOTAN_HAS_CTR_BE)
if(request.algo_name() == "CTR-BE" && request.arg_count() == 1)
{
- const BlockCipher* proto = af.prototype_block_cipher(request.arg(0));
- return new CTR_BE(proto->clone());
+ if(auto proto = af.prototype_block_cipher(request.arg(0)))
+ return new CTR_BE(proto->clone());
}
#endif
diff --git a/src/lib/modes/aead/aead.cpp b/src/lib/modes/aead/aead.cpp
index da860c26a..e8316ec63 100644
--- a/src/lib/modes/aead/aead.cpp
+++ b/src/lib/modes/aead/aead.cpp
@@ -6,6 +6,7 @@
*/
#include <botan/aead.h>
+#include <botan/block_cipher.h>
#include <botan/libstate.h>
#if defined(BOTAN_HAS_AEAD_CCM)
diff --git a/src/lib/pk_pad/get_pk_pad.cpp b/src/lib/pk_pad/get_pk_pad.cpp
index 5b4052cde..cac24730d 100644
--- a/src/lib/pk_pad/get_pk_pad.cpp
+++ b/src/lib/pk_pad/get_pk_pad.cpp
@@ -58,14 +58,17 @@ EMSA* get_emsa(const std::string& algo_spec)
return new EMSA_Raw;
#endif
-#if defined(BOTAN_HAS_EMSA1)
if(request.algo_name() == "EMSA1" && request.arg_count() == 1)
{
+#if defined(BOTAN_HAS_EMSA_RAW)
if(request.arg(0) == "Raw")
return new EMSA_Raw;
+#endif
+
+#if defined(BOTAN_HAS_EMSA1)
return new EMSA1(af.make_hash_function(request.arg(0)));
- }
#endif
+ }
#if defined(BOTAN_HAS_EMSA1_BSI)
if(request.algo_name() == "EMSA1_BSI" && request.arg_count() == 1)
diff --git a/src/tests/nist_x509.cpp b/src/tests/nist_x509.cpp
index d6446639a..4e03ecf10 100644
--- a/src/tests/nist_x509.cpp
+++ b/src/tests/nist_x509.cpp
@@ -14,6 +14,7 @@ extensions which are not supported.
#include "tests.h"
#if defined(BOTAN_HAS_X509_CERTIFICATES)
+
#include <botan/x509path.h>
#include <botan/init.h>
@@ -302,4 +303,8 @@ void populate_expected_results()
//expected_results[76] = ;
}
+#else
+
+size_t test_nist_x509() { return 0; }
+
#endif
diff --git a/src/tests/test_aead.cpp b/src/tests/test_aead.cpp
index 8b46e9177..f716c0554 100644
--- a/src/tests/test_aead.cpp
+++ b/src/tests/test_aead.cpp
@@ -24,6 +24,9 @@ size_t aead_test(const std::string& algo,
std::unique_ptr<Cipher_Mode> enc(get_aead(algo, ENCRYPTION));
std::unique_ptr<Cipher_Mode> dec(get_aead(algo, DECRYPTION));
+ if(!enc || !dec)
+ throw std::runtime_error("Unknown AEAD " + algo);
+
enc->set_key(key);
dec->set_key(key);
diff --git a/src/tests/test_block.cpp b/src/tests/test_block.cpp
index 037ea0547..450e5f7fd 100644
--- a/src/tests/test_block.cpp
+++ b/src/tests/test_block.cpp
@@ -25,10 +25,7 @@ size_t block_test(const std::string& algo,
size_t fails = 0;
if(providers.empty())
- {
- std::cout << "Unknown algo " << algo << "\n";
- ++fails;
- }
+ throw std::runtime_error("Unknown block cipher " + algo);
for(auto provider: providers)
{
diff --git a/src/tests/test_dh.cpp b/src/tests/test_dh.cpp
index 890bae632..0b125a5ce 100644
--- a/src/tests/test_dh.cpp
+++ b/src/tests/test_dh.cpp
@@ -1,6 +1,7 @@
#include "tests.h"
#include "test_pubkey.h"
+#if defined(BOTAN_HAS_DIFFIE_HELLMAN)
#include <botan/auto_rng.h>
#include <botan/pubkey.h>
#include <botan/dh.h>
@@ -42,18 +43,21 @@ size_t dh_sig_kat(const std::string& p,
}
}
+#endif
size_t test_dh()
{
- std::ifstream dh_sig(PK_TEST_DATA_DIR "/dh.vec");
-
size_t fails = 0;
+#if defined(BOTAN_HAS_DIFFIE_HELLMAN)
+ std::ifstream dh_sig(PK_TEST_DATA_DIR "/dh.vec");
+
fails += run_tests_bb(dh_sig, "DH Kex", "K", true,
[](std::map<std::string, std::string> m) -> size_t
{
return dh_sig_kat(m["P"], m["G"], m["X"], m["Y"], m["KDF"], m["OutLen"], m["K"]);
});
+#endif
return fails;
}
diff --git a/src/tests/test_dlies.cpp b/src/tests/test_dlies.cpp
index 05fdb863f..d1816bf98 100644
--- a/src/tests/test_dlies.cpp
+++ b/src/tests/test_dlies.cpp
@@ -1,17 +1,21 @@
#include "tests.h"
#include "test_pubkey.h"
-#include <botan/auto_rng.h>
-#include <botan/pubkey.h>
-#include <botan/lookup.h>
-#include <botan/dlies.h>
-#include <botan/dh.h>
#include <botan/hex.h>
#include <iostream>
#include <fstream>
+#if defined(BOTAN_HAS_DLIES)
+ #include <botan/auto_rng.h>
+ #include <botan/pubkey.h>
+ #include <botan/lookup.h>
+ #include <botan/dlies.h>
+ #include <botan/dh.h>
+#endif
+
using namespace Botan;
+#if defined(BOTAN_HAS_DLIES)
namespace {
size_t dlies_kat(const std::string& p,
@@ -59,18 +63,21 @@ size_t dlies_kat(const std::string& p,
}
}
+#endif
size_t test_dlies()
{
- std::ifstream dlies(PK_TEST_DATA_DIR "/dlies.vec");
-
size_t fails = 0;
+#if defined(BOTAN_HAS_DLIES)
+ std::ifstream dlies(PK_TEST_DATA_DIR "/dlies.vec");
+
fails += run_tests_bb(dlies, "DLIES Encryption", "Ciphertext", true,
[](std::map<std::string, std::string> m) -> size_t
{
return dlies_kat(m["P"], m["G"], m["X1"], m["X2"], m["Msg"], m["Ciphertext"]);
});
+#endif
return fails;
}
diff --git a/src/tests/test_dsa.cpp b/src/tests/test_dsa.cpp
index 19c557823..16f03fcc0 100644
--- a/src/tests/test_dsa.cpp
+++ b/src/tests/test_dsa.cpp
@@ -1,6 +1,8 @@
#include "tests.h"
#include "test_pubkey.h"
+#if defined(BOTAN_HAS_DSA)
+
#include <botan/auto_rng.h>
#include <botan/pubkey.h>
#include <botan/dsa.h>
@@ -39,18 +41,21 @@ size_t dsa_sig_kat(const std::string& p,
}
}
+#endif
size_t test_dsa()
{
- std::ifstream dsa_sig(PK_TEST_DATA_DIR "/dsa.vec");
-
size_t fails = 0;
+#if defined(BOTAN_HAS_DSA)
+ std::ifstream dsa_sig(PK_TEST_DATA_DIR "/dsa.vec");
+
fails += run_tests_bb(dsa_sig, "DSA Signature", "Signature", true,
[](std::map<std::string, std::string> m) -> size_t
{
return dsa_sig_kat(m["P"], m["Q"], m["G"], m["X"], m["Hash"], m["Msg"], m["Nonce"], m["Signature"]);
});
+#endif
return fails;
}
diff --git a/src/tests/test_ecdsa.cpp b/src/tests/test_ecdsa.cpp
index 5741580a4..f9e83f117 100644
--- a/src/tests/test_ecdsa.cpp
+++ b/src/tests/test_ecdsa.cpp
@@ -35,24 +35,21 @@ size_t ecdsa_sig_kat(const std::string& group_id,
}
}
+#endif
size_t test_ecdsa()
{
- std::ifstream ecdsa_sig(PK_TEST_DATA_DIR "/ecdsa.vec");
-
size_t fails = 0;
+#if defined(BOTAN_HAS_ECDSA)
+ std::ifstream ecdsa_sig(PK_TEST_DATA_DIR "/ecdsa.vec");
+
fails += run_tests_bb(ecdsa_sig, "ECDSA Signature", "Signature", true,
[](std::map<std::string, std::string> m) -> size_t
{
return ecdsa_sig_kat(m["Group"], m["X"], m["Hash"], m["Msg"], m["Nonce"], m["Signature"]);
});
+#endif
return fails;
}
-
-#else
-
-size_t test_ecdsa() { return 0; }
-
-#endif
diff --git a/src/tests/test_elg.cpp b/src/tests/test_elg.cpp
index 332e5ae0e..8d0a8d1ae 100644
--- a/src/tests/test_elg.cpp
+++ b/src/tests/test_elg.cpp
@@ -1,19 +1,21 @@
#include "tests.h"
#include "test_pubkey.h"
-#include <botan/auto_rng.h>
-#include <botan/pubkey.h>
-#include <botan/dl_group.h>
#include <botan/hex.h>
#include <iostream>
#include <fstream>
#if defined(BOTAN_HAS_ELGAMAL)
#include <botan/elgamal.h>
+ #include <botan/auto_rng.h>
+ #include <botan/pubkey.h>
+ #include <botan/dl_group.h>
#endif
using namespace Botan;
+#if defined(BOTAN_HAS_ELGAMAL)
+
namespace {
size_t elgamal_kat(const std::string& p,
@@ -31,7 +33,6 @@ size_t elgamal_kat(const std::string& p,
const BigInt x_bn = BigInt(x);
DL_Group group(p_bn, g_bn);
-#if defined(BOTAN_HAS_ELGAMAL)
ElGamal_PrivateKey privkey(rng, group, x_bn);
ElGamal_PublicKey pubkey = privkey;
@@ -43,25 +44,25 @@ size_t elgamal_kat(const std::string& p,
PK_Decryptor_EME dec(privkey, padding);
return validate_encryption(enc, dec, "ElGamal/" + padding, msg, nonce, ciphertext);
-#else
- return 1;
-#endif
}
}
+#endif
size_t test_elgamal()
{
- std::ifstream elgamal_enc(PK_TEST_DATA_DIR "/elgamal.vec");
-
size_t fails = 0;
+#if defined(BOTAN_HAS_ELGAMAL)
+ std::ifstream elgamal_enc(PK_TEST_DATA_DIR "/elgamal.vec");
+
fails += run_tests_bb(elgamal_enc, "ElGamal Encryption", "Ciphertext", true,
[](std::map<std::string, std::string> m) -> size_t
{
return elgamal_kat(m["P"], m["G"], m["X"], m["Msg"],
m["Padding"], m["Nonce"], m["Ciphertext"]);
});
+#endif
return fails;
}
diff --git a/src/tests/test_gost_3410.cpp b/src/tests/test_gost_3410.cpp
index 4cd43a027..843a490b1 100644
--- a/src/tests/test_gost_3410.cpp
+++ b/src/tests/test_gost_3410.cpp
@@ -1,6 +1,7 @@
#include "tests.h"
#include "test_pubkey.h"
+#if defined(BOTAN_HAS_GOST_34_10_2001)
#include <botan/auto_rng.h>
#include <botan/pubkey.h>
#include <botan/gost_3410.h>
@@ -37,18 +38,21 @@ size_t gost_verify(const std::string& group_id,
}
}
+#endif
size_t test_gost_3410()
{
- std::ifstream ecdsa_sig(PK_TEST_DATA_DIR "/gost_3410.vec");
-
size_t fails = 0;
+#if defined(BOTAN_HAS_GOST_34_10_2001)
+ std::ifstream ecdsa_sig(PK_TEST_DATA_DIR "/gost_3410.vec");
+
fails += run_tests_bb(ecdsa_sig, "GOST-34.10 Signature", "Signature", true,
[](std::map<std::string, std::string> m) -> size_t
{
return gost_verify(m["Group"], m["Pubkey"], m["Hash"], m["Msg"], m["Signature"]);
});
+#endif
return fails;
}
diff --git a/src/tests/test_hkdf.cpp b/src/tests/test_hkdf.cpp
index 842123968..8bd25829a 100644
--- a/src/tests/test_hkdf.cpp
+++ b/src/tests/test_hkdf.cpp
@@ -1,13 +1,12 @@
#include "tests.h"
-
-#include <botan/libstate.h>
-#if defined(BOTAN_HAS_HKDF)
- #include <botan/hkdf.h>
-#endif
#include <botan/hex.h>
#include <iostream>
#include <fstream>
+#if defined(BOTAN_HAS_HKDF)
+#include <botan/libstate.h>
+#include <botan/hkdf.h>
+
using namespace Botan;
namespace {
@@ -27,7 +26,6 @@ secure_vector<byte> hkdf(const std::string& hkdf_algo,
if(!mac_proto)
throw std::invalid_argument("Bad HKDF hash '" + algo + "'");
-#if defined(BOTAN_HAS_HKDF)
HKDF hkdf(mac_proto->clone(), mac_proto->clone());
hkdf.start_extract(&salt[0], salt.size());
@@ -37,9 +35,6 @@ secure_vector<byte> hkdf(const std::string& hkdf_algo,
secure_vector<byte> key(L);
hkdf.expand(&key[0], key.size(), &info[0], info.size());
return key;
-#else
- return "";
-#endif
}
size_t hkdf_test(const std::string& algo,
@@ -67,9 +62,11 @@ size_t hkdf_test(const std::string& algo,
}
}
+#endif
size_t test_hkdf()
{
+#if defined(BOTAN_HAS_HKDF)
std::ifstream vec(TEST_DATA_DIR "/hkdf.vec");
return run_tests_bb(vec, "HKDF", "OKM", true,
@@ -78,4 +75,7 @@ size_t test_hkdf()
return hkdf_test(m["HKDF"], m["IKM"], m["salt"], m["info"],
m["OKM"], to_u32bit(m["L"]));
});
+#else
+ return 0;
+#endif
}
diff --git a/src/tests/test_nr.cpp b/src/tests/test_nr.cpp
index 982e38bc2..148a527c8 100644
--- a/src/tests/test_nr.cpp
+++ b/src/tests/test_nr.cpp
@@ -1,12 +1,11 @@
#include "tests.h"
#include "test_pubkey.h"
-#include <botan/auto_rng.h>
-#include <botan/pubkey.h>
-#include <botan/dl_group.h>
-
#if defined(BOTAN_HAS_NYBERG_RUEPPEL)
#include <botan/nr.h>
+ #include <botan/auto_rng.h>
+ #include <botan/pubkey.h>
+ #include <botan/dl_group.h>
#endif
#include <botan/hex.h>
@@ -15,6 +14,8 @@
using namespace Botan;
+#if defined(BOTAN_HAS_NYBERG_RUEPPEL)
+
namespace {
size_t nr_sig_kat(const std::string& p,
@@ -32,7 +33,6 @@ size_t nr_sig_kat(const std::string& p,
DL_Group group(p_bn, q_bn, g_bn);
-#if defined(BOTAN_HAS_NYBERG_RUEPPEL)
NR_PrivateKey privkey(rng, group, x_bn);
NR_PublicKey pubkey = privkey;
@@ -43,24 +43,24 @@ size_t nr_sig_kat(const std::string& p,
PK_Signer sign(privkey, padding);
return validate_signature(verify, sign, "nr/" + hash, msg, rng, nonce, signature);
-#else
- return 1;
-#endif
}
}
+#endif
size_t test_nr()
{
- std::ifstream nr_sig(PK_TEST_DATA_DIR "/nr.vec");
-
size_t fails = 0;
+#if defined(BOTAN_HAS_NYBERG_RUEPPEL)
+ std::ifstream nr_sig(PK_TEST_DATA_DIR "/nr.vec");
+
fails += run_tests_bb(nr_sig, "NR Signature", "Signature", true,
[](std::map<std::string, std::string> m) -> size_t
{
return nr_sig_kat(m["P"], m["Q"], m["G"], m["X"], m["Hash"], m["Msg"], m["Nonce"], m["Signature"]);
});
+#endif
return fails;
}
diff --git a/src/tests/test_ocb.cpp b/src/tests/test_ocb.cpp
index b76e26189..17cbf4bb1 100644
--- a/src/tests/test_ocb.cpp
+++ b/src/tests/test_ocb.cpp
@@ -128,23 +128,18 @@ size_t test_ocb_long(size_t taglen, const std::string &expected)
}
}
+#endif
size_t test_ocb()
{
size_t fails = 0;
+
+#if defined(BOTAN_HAS_OCB)
fails += test_ocb_long(128, "B2B41CBF9B05037DA7F16C24A35C1C94");
fails += test_ocb_long(96, "1A4F0654277709A5BDA0D380");
fails += test_ocb_long(64, "B7ECE9D381FE437F");
test_report("OCB long", 3, fails);
- return fails;
- }
-
-#else
+#endif
-size_t test_ocb()
- {
- std::cout << "OCB disabled in build\n";
- return 0;
+ return fails;
}
-
-#endif
diff --git a/src/tests/test_pubkey.cpp b/src/tests/test_pubkey.cpp
index 85e2924be..734ff1803 100644
--- a/src/tests/test_pubkey.cpp
+++ b/src/tests/test_pubkey.cpp
@@ -15,13 +15,13 @@
#include <cstdlib>
#include <memory>
-#include <botan/botan.h>
#include <botan/oids.h>
#if defined(BOTAN_HAS_PUBLIC_KEY_CRYPTO)
#include <botan/x509_key.h>
#include <botan/pkcs8.h>
#include <botan/pubkey.h>
+ #include <botan/auto_rng.h>
#endif
#if defined(BOTAN_HAS_RSA)
diff --git a/src/tests/test_rng.cpp b/src/tests/test_rng.cpp
index 88e21f62c..84e291c6a 100644
--- a/src/tests/test_rng.cpp
+++ b/src/tests/test_rng.cpp
@@ -2,22 +2,25 @@
#include "test_rng.h"
#include <botan/libstate.h>
-#include <botan/x931_rng.h>
-#include <botan/aes.h>
-#include <botan/des.h>
#include <botan/hex.h>
#include <iostream>
#include <fstream>
-#include <deque>
+
+#if defined(BOTAN_HAS_X931_RNG)
+ #include <botan/x931_rng.h>
+ #include <botan/aes.h>
+ #include <botan/des.h>
+#endif
using namespace Botan;
namespace {
-RandomNumberGenerator* get_x931(const std::string& algo, const std::string& ikm_hex)
+RandomNumberGenerator* get_rng(const std::string& algo, const std::string& ikm_hex)
{
const auto ikm = hex_decode(ikm_hex);
+#if defined(BOTAN_HAS_X931_RNG)
if(algo == "X9.31-RNG(TripleDES)")
return new ANSI_X931_RNG(new TripleDES, new Fixed_Output_RNG(ikm));
else if(algo == "X9.31-RNG(AES-128)")
@@ -26,6 +29,7 @@ RandomNumberGenerator* get_x931(const std::string& algo, const std::string& ikm_
return new ANSI_X931_RNG(new AES_192, new Fixed_Output_RNG(ikm));
else if(algo == "X9.31-RNG(AES-256)")
return new ANSI_X931_RNG(new AES_256, new Fixed_Output_RNG(ikm));
+#endif
return nullptr;
}
@@ -35,10 +39,14 @@ size_t x931_test(const std::string& algo,
const std::string& out,
size_t L)
{
- std::unique_ptr<RandomNumberGenerator> x931(get_x931(algo, ikm));
- x931->reseed(0);
+ std::unique_ptr<RandomNumberGenerator> rng(get_rng(algo, ikm));
+
+ if(!rng)
+ throw std::runtime_error("Unknown RNG " + algo);
+
+ rng->reseed(0);
- const std::string got = hex_encode(x931->random_vec(L));
+ const std::string got = hex_encode(rng->random_vec(L));
if(got != out)
{
diff --git a/src/tests/test_rw.cpp b/src/tests/test_rw.cpp
index 4d3bc2d5b..09e746add 100644
--- a/src/tests/test_rw.cpp
+++ b/src/tests/test_rw.cpp
@@ -1,15 +1,19 @@
#include "tests.h"
#include "test_pubkey.h"
-#include <botan/auto_rng.h>
-#include <botan/pubkey.h>
-#include <botan/rw.h>
#include <botan/hex.h>
#include <iostream>
#include <fstream>
+#if defined(BOTAN_HAS_RW)
+ #include <botan/auto_rng.h>
+ #include <botan/pubkey.h>
+ #include <botan/rw.h>
+#endif
+
using namespace Botan;
+#if defined(BOTAN_HAS_RW)
namespace {
const std::string padding = "EMSA2(SHA-1)";
@@ -52,14 +56,16 @@ size_t rw_sig_verify(const std::string& e,
}
}
+#endif
size_t test_rw()
{
+ size_t fails = 0;
+
+#if defined(BOTAN_HAS_RW)
std::ifstream rw_sig(PK_TEST_DATA_DIR "/rw_sig.vec");
std::ifstream rw_verify(PK_TEST_DATA_DIR "/rw_verify.vec");
- size_t fails = 0;
-
fails += run_tests_bb(rw_sig, "RW Signature", "Signature", true,
[](std::map<std::string, std::string> m) -> size_t
{
@@ -71,6 +77,7 @@ size_t test_rw()
{
return rw_sig_verify(m["E"], m["N"], m["Msg"], m["Signature"]);
});
+#endif
return fails;
}
diff --git a/src/tests/test_transform.cpp b/src/tests/test_transform.cpp
index 7e771d051..df13af8f4 100644
--- a/src/tests/test_transform.cpp
+++ b/src/tests/test_transform.cpp
@@ -1,8 +1,6 @@
#include "tests.h"
-#include <botan/botan.h>
#include <botan/transform.h>
-#include <botan/benchmark.h>
#include <botan/hex.h>
#include <iostream>
#include <fstream>
diff --git a/src/tests/unit_ecc.cpp b/src/tests/unit_ecc.cpp
index 6f97c558c..3a4fbe5a3 100644
--- a/src/tests/unit_ecc.cpp
+++ b/src/tests/unit_ecc.cpp
@@ -7,6 +7,10 @@
#include "tests.h"
#include <botan/hex.h>
+#include <iostream>
+#include <memory>
+
+#if defined(BOTAN_HAS_ECC_GROUP)
#include <botan/auto_rng.h>
#include <botan/bigint.h>
#include <botan/numthry.h>
@@ -15,8 +19,6 @@
#include <botan/ec_group.h>
#include <botan/reducer.h>
#include <botan/oids.h>
-#include <iostream>
-#include <memory>
using namespace Botan;
@@ -744,13 +746,14 @@ size_t test_mult_by_order()
return fails;
}
-size_t test_point_swap(RandomNumberGenerator& rng)
+size_t test_point_swap()
{
size_t fails = 0;
-
EC_Group dom_pars(OID("1.3.132.0.8"));
+ AutoSeeded_RNG rng;
+
PointGFp a(create_random_point(rng, dom_pars.get_curve()));
PointGFp b(create_random_point(rng, dom_pars.get_curve()));
b *= BigInt(20);
@@ -768,10 +771,11 @@ size_t test_point_swap(RandomNumberGenerator& rng)
* This test verifies that the side channel attack resistant multiplication function
* yields the same result as the normal (insecure) multiplication via operator*=
*/
-size_t test_mult_sec_mass(RandomNumberGenerator& rng)
+size_t test_mult_sec_mass()
{
size_t fails = 0;
+ RandomNumberGenerator rng;
EC_Group dom_pars(OID("1.3.132.0.8"));
for(int i = 0; i<50; i++)
@@ -804,13 +808,15 @@ size_t test_curve_cp_ctor()
}
}
+#endif
size_t test_ecc_unit()
{
- AutoSeeded_RNG rng;
-
size_t fails = 0;
+#if defined(BOTAN_HAS_ECC_GROUP)
+ AutoSeeded_RNG rng;
+
fails += test_point_turn_on_sp_red_mul();
fails += test_coordinates();
fails += test_point_transformation ();
@@ -835,8 +841,8 @@ size_t test_ecc_unit()
fails += test_point_swap(rng);
fails += test_mult_sec_mass(rng);
fails += test_curve_cp_ctor();
-
test_report("ECC", 0, fails);
+#endif
return fails;
}