diff options
27 files changed, 155 insertions, 120 deletions
diff --git a/configure.py b/configure.py index 235c631ef..68ecf3a7a 100755 --- a/configure.py +++ b/configure.py @@ -1922,10 +1922,6 @@ def main(argv = None): if options.via_amalgamation: options.gen_amalgamation = True - if not options.build_shared_lib and not options.via_amalgamation: - raise Exception('Static build is only supported using amalgamation. ' - 'Add --via-amalgamation.') - if options.build_shared_lib and not osinfo.building_shared_supported: raise Exception('Botan does not support building as shared library on the target os. ' 'Build static using --disable-shared.') diff --git a/src/lib/kdf/kdf.cpp b/src/lib/kdf/kdf.cpp index 89bb8d58a..836e9b982 100644 --- a/src/lib/kdf/kdf.cpp +++ b/src/lib/kdf/kdf.cpp @@ -34,6 +34,8 @@ namespace Botan { +KDF::~KDF() {} + KDF* get_kdf(const std::string& algo_spec) { SCAN_Name request(algo_spec); diff --git a/src/lib/kdf/kdf.h b/src/lib/kdf/kdf.h index d69c1ece5..936e7c5f1 100644 --- a/src/lib/kdf/kdf.h +++ b/src/lib/kdf/kdf.h @@ -21,7 +21,7 @@ namespace Botan { class BOTAN_DLL KDF { public: - virtual ~KDF() {} + virtual ~KDF(); virtual std::string name() const = 0; diff --git a/src/lib/pbkdf/info.txt b/src/lib/pbkdf/info.txt index 81f7c1260..3addbdb58 100644 --- a/src/lib/pbkdf/info.txt +++ b/src/lib/pbkdf/info.txt @@ -7,7 +7,3 @@ base <header:public> pbkdf.h </header:public> - -<header:internal> -pbkdf_utils.h -</header:internal> diff --git a/src/lib/pbkdf/pbkdf.cpp b/src/lib/pbkdf/pbkdf.cpp index 7f0a68a01..f11fbc44d 100644 --- a/src/lib/pbkdf/pbkdf.cpp +++ b/src/lib/pbkdf/pbkdf.cpp @@ -6,10 +6,30 @@ */ #include <botan/pbkdf.h> +#include <botan/internal/algo_registry.h> #include <stdexcept> +#if defined(BOTAN_HAS_PBKDF1) +#include <botan/pbkdf1.h> +#endif + +#if defined(BOTAN_HAS_PBKDF2) +#include <botan/pbkdf2.h> +#endif + namespace Botan { +#define BOTAN_REGISTER_PBKDF_1HASH(type, name) \ + BOTAN_REGISTER_NAMED_T(PBKDF, name, type, (make_new_T_1X<type, HashFunction>)) + +#if defined(BOTAN_HAS_PBKDF1) +BOTAN_REGISTER_PBKDF_1HASH(PKCS5_PBKDF1, "PBKDF1"); +#endif + +#if defined(BOTAN_HAS_PBKDF2) +BOTAN_REGISTER_NAMED_T(PBKDF, "PBKDF2", PKCS5_PBKDF2, PKCS5_PBKDF2::make); +#endif + void PBKDF::pbkdf_timed(byte out[], size_t out_len, const std::string& passphrase, const byte salt[], size_t salt_len, diff --git a/src/lib/pbkdf/pbkdf1/pbkdf1.cpp b/src/lib/pbkdf/pbkdf1/pbkdf1.cpp index 28bac9572..49e1cf268 100644 --- a/src/lib/pbkdf/pbkdf1/pbkdf1.cpp +++ b/src/lib/pbkdf/pbkdf1/pbkdf1.cpp @@ -5,14 +5,11 @@ * Botan is released under the Simplified BSD License (see license.txt) */ -#include <botan/internal/pbkdf_utils.h> #include <botan/pbkdf1.h> #include <botan/exceptn.h> namespace Botan { -BOTAN_REGISTER_PBKDF_1HASH(PKCS5_PBKDF1, "PBKDF1"); - size_t PKCS5_PBKDF1::pbkdf(byte output_buf[], size_t output_len, const std::string& passphrase, const byte salt[], size_t salt_len, diff --git a/src/lib/pbkdf/pbkdf2/pbkdf2.cpp b/src/lib/pbkdf/pbkdf2/pbkdf2.cpp index a27b9b15c..a5b7f011e 100644 --- a/src/lib/pbkdf/pbkdf2/pbkdf2.cpp +++ b/src/lib/pbkdf/pbkdf2/pbkdf2.cpp @@ -5,16 +5,14 @@ * Botan is released under the Simplified BSD License (see license.txt) */ -#include <botan/internal/pbkdf_utils.h> #include <botan/pbkdf2.h> +#include <botan/lookup.h> #include <botan/get_byte.h> #include <botan/internal/xor_buf.h> #include <botan/internal/rounding.h> namespace Botan { -BOTAN_REGISTER_NAMED_T(PBKDF, "PBKDF2", PKCS5_PBKDF2, PKCS5_PBKDF2::make); - PKCS5_PBKDF2* PKCS5_PBKDF2::make(const Spec& spec) { if(auto mac = get_mac(spec.arg(0))) diff --git a/src/lib/pbkdf/pbkdf_utils.h b/src/lib/pbkdf/pbkdf_utils.h deleted file mode 100644 index 480fc70eb..000000000 --- a/src/lib/pbkdf/pbkdf_utils.h +++ /dev/null @@ -1,23 +0,0 @@ -/* -* PBKDF Utility Header -* (C) 2015 Jack Lloyd -* -* Botan is released under the Simplified BSD License (see license.txt) -*/ - -#ifndef BOTAN_PBKDF_UTILS_H__ -#define BOTAN_PBKDF_UTILS_H__ - -#include <botan/pbkdf.h> -#include <botan/internal/algo_registry.h> - -namespace Botan { - -#define BOTAN_REGISTER_PBKDF_1HASH(type, name) \ - BOTAN_REGISTER_NAMED_T(PBKDF, name, type, (make_new_T_1X<type, HashFunction>)) -#define BOTAN_REGISTER_PBKDF_1MAC(type, name) \ - BOTAN_REGISTER_NAMED_T(PBKDF, name, type, (make_new_T_1X<type, MessageAuthenticationCode>)) - -} - -#endif diff --git a/src/lib/pk_pad/eme.cpp b/src/lib/pk_pad/eme.cpp index 9398b4c83..153ef8922 100644 --- a/src/lib/pk_pad/eme.cpp +++ b/src/lib/pk_pad/eme.cpp @@ -6,9 +6,47 @@ */ #include <botan/eme.h> +#include <botan/internal/pad_utils.h> + +#if defined(BOTAN_HAS_EME_OAEP) +#include <botan/oaep.h> +#endif + +#if defined(BOTAN_HAS_EME_PKCS1v15) +#include <botan/eme_pkcs.h> +#endif + +#if defined(BOTAN_HAS_EME_RAW) +#include <botan/eme_raw.h> +#endif namespace Botan { +#if defined(BOTAN_HAS_EME_OAEP) +BOTAN_REGISTER_NAMED_T(EME, "OAEP", OAEP, OAEP::make); +#endif + +#if defined(BOTAN_HAS_EME_PKCS1v15) +BOTAN_REGISTER_EME_NAMED_NOARGS(EME_PKCS1v15, "PKCS1v15"); +#endif + +#if defined(BOTAN_HAS_EME_RAW) +BOTAN_REGISTER_EME_NAMED_NOARGS(EME_Raw, "Raw"); +#endif + +EME* get_eme(const std::string& algo_spec) + { + SCAN_Name request(algo_spec); + + if(EME* eme = make_a<EME>(algo_spec)) + return eme; + + if(request.algo_name() == "Raw") + return nullptr; // No padding + + throw Algorithm_Not_Found(algo_spec); + } + /* * Encode a message */ diff --git a/src/lib/pk_pad/eme_oaep/oaep.cpp b/src/lib/pk_pad/eme_oaep/oaep.cpp index 871f40142..a484202da 100644 --- a/src/lib/pk_pad/eme_oaep/oaep.cpp +++ b/src/lib/pk_pad/eme_oaep/oaep.cpp @@ -5,11 +5,10 @@ * Botan is released under the Simplified BSD License (see license.txt) */ -#include <botan/internal/pad_utils.h> #include <botan/oaep.h> #include <botan/mgf1.h> #include <botan/mem_ops.h> - +#include <botan/lookup.h> namespace Botan { @@ -28,9 +27,6 @@ OAEP* OAEP::make(const Spec& request) return nullptr; } -BOTAN_REGISTER_NAMED_T(EME, "OAEP", OAEP, OAEP::make); - - /* * OAEP Pad Operation */ diff --git a/src/lib/pk_pad/eme_pkcs1/eme_pkcs.cpp b/src/lib/pk_pad/eme_pkcs1/eme_pkcs.cpp index 90af17565..65d29cd59 100644 --- a/src/lib/pk_pad/eme_pkcs1/eme_pkcs.cpp +++ b/src/lib/pk_pad/eme_pkcs1/eme_pkcs.cpp @@ -5,13 +5,10 @@ * Botan is released under the Simplified BSD License (see license.txt) */ -#include <botan/internal/pad_utils.h> #include <botan/eme_pkcs.h> namespace Botan { -BOTAN_REGISTER_EME_NAMED_NOARGS(EME_PKCS1v15, "PKCS1v15"); - /* * PKCS1 Pad Operation */ diff --git a/src/lib/pk_pad/eme_raw/eme_raw.cpp b/src/lib/pk_pad/eme_raw/eme_raw.cpp index 9ae894c70..78b670b65 100644 --- a/src/lib/pk_pad/eme_raw/eme_raw.cpp +++ b/src/lib/pk_pad/eme_raw/eme_raw.cpp @@ -4,14 +4,11 @@ * Botan is released under the Simplified BSD License (see license.txt) */ -#include <botan/internal/pad_utils.h> #include <botan/internal/bit_ops.h> #include <botan/eme_raw.h> namespace Botan { -BOTAN_REGISTER_EME_NAMED_NOARGS(EME_Raw, "Raw"); - secure_vector<byte> EME_Raw::pad(const byte in[], size_t in_length, size_t key_bits, RandomNumberGenerator&) const diff --git a/src/lib/pk_pad/emsa.cpp b/src/lib/pk_pad/emsa.cpp new file mode 100644 index 000000000..9682d9b6e --- /dev/null +++ b/src/lib/pk_pad/emsa.cpp @@ -0,0 +1,74 @@ +/* +* (C) 2015 Jack Lloyd +* +* Botan is released under the Simplified BSD License (see license.txt) +*/ + +#include <botan/emsa.h> +#include <botan/internal/pad_utils.h> + +#if defined(BOTAN_HAS_EMSA1) + #include <botan/emsa1.h> +#endif + +#if defined(BOTAN_HAS_EMSA1_BSI) + #include <botan/emsa1_bsi.h> +#endif + +#if defined(BOTAN_HAS_EMSA_X931) + #include <botan/emsa_x931.h> +#endif + +#if defined(BOTAN_HAS_EMSA_PKCS1) + #include <botan/emsa_pkcs1.h> +#endif + +#if defined(BOTAN_HAS_EMSA_PSSR) + #include <botan/pssr.h> +#endif + +#if defined(BOTAN_HAS_EMSA_RAW) + #include <botan/emsa_raw.h> +#endif + +namespace Botan { + +EMSA::~EMSA() {} + +EMSA* get_emsa(const std::string& algo_spec) + { + SCAN_Name request(algo_spec); + + if(EMSA* emsa = make_a<EMSA>(algo_spec)) + return emsa; + + throw Algorithm_Not_Found(algo_spec); + } + +#if defined(BOTAN_HAS_EMSA1) +BOTAN_REGISTER_EMSA_1HASH(EMSA1, "EMSA1"); +#endif + +#if defined(BOTAN_HAS_EMSA1_BSI) +BOTAN_REGISTER_EMSA_1HASH(EMSA1_BSI, "EMSA1_BSI"); +#endif + +#if defined(BOTAN_HAS_EMSA_PKCS1) +BOTAN_REGISTER_NAMED_T(EMSA, "EMSA_PKCS1", EMSA_PCS1v15, EMSA_PKCS1v15::make); +#endif + +#if defined(BOTAN_HAS_EMSA_PSSR) +BOTAN_REGISTER_NAMED_T(EMSA, "PSSR", PSSR, PSSR::make); +#endif + +#if defined(BOTAN_HAS_EMSA_X931) +BOTAN_REGISTER_EMSA_1HASH(EMSA_X931, "EMSA_X931"); +#endif + +#if defined(BOTAN_HAS_EMSA_RAW) +BOTAN_REGISTER_EMSA_NAMED_NOARGS(EMSA_Raw, "Raw"); +#endif + +} + + diff --git a/src/lib/pk_pad/emsa.h b/src/lib/pk_pad/emsa.h index b0295636c..d4fd146da 100644 --- a/src/lib/pk_pad/emsa.h +++ b/src/lib/pk_pad/emsa.h @@ -15,7 +15,9 @@ namespace Botan { /** -* Encoding Method for Signatures, Appendix +* EMSA, from IEEE 1363s Encoding Method for Signatures, Appendix +* +* Any way of encoding/padding signatures */ class BOTAN_DLL EMSA { @@ -55,7 +57,8 @@ class BOTAN_DLL EMSA virtual bool verify(const secure_vector<byte>& coded, const secure_vector<byte>& raw, size_t key_bits) = 0; - virtual ~EMSA() {} + + virtual ~EMSA(); }; /** diff --git a/src/lib/pk_pad/emsa1/emsa1.cpp b/src/lib/pk_pad/emsa1/emsa1.cpp index 89f0d244a..0031bf263 100644 --- a/src/lib/pk_pad/emsa1/emsa1.cpp +++ b/src/lib/pk_pad/emsa1/emsa1.cpp @@ -5,13 +5,10 @@ * Botan is released under the Simplified BSD License (see license.txt) */ -#include <botan/internal/pad_utils.h> #include <botan/emsa1.h> namespace Botan { -BOTAN_REGISTER_EMSA_1HASH(EMSA1, "EMSA1"); - namespace { secure_vector<byte> emsa1_encoding(const secure_vector<byte>& msg, diff --git a/src/lib/pk_pad/emsa1_bsi/emsa1_bsi.cpp b/src/lib/pk_pad/emsa1_bsi/emsa1_bsi.cpp index 81a168b7d..5fc96da8d 100644 --- a/src/lib/pk_pad/emsa1_bsi/emsa1_bsi.cpp +++ b/src/lib/pk_pad/emsa1_bsi/emsa1_bsi.cpp @@ -6,13 +6,10 @@ * Botan is released under the Simplified BSD License (see license.txt) */ -#include <botan/internal/pad_utils.h> #include <botan/emsa1_bsi.h> namespace Botan { -BOTAN_REGISTER_EMSA_1HASH(EMSA1_BSI, "EMSA1_BSI"); - /* * EMSA1 BSI Encode Operation */ diff --git a/src/lib/pk_pad/emsa_pkcs1/emsa_pkcs1.cpp b/src/lib/pk_pad/emsa_pkcs1/emsa_pkcs1.cpp index e6ce5ec2f..d928511d3 100644 --- a/src/lib/pk_pad/emsa_pkcs1/emsa_pkcs1.cpp +++ b/src/lib/pk_pad/emsa_pkcs1/emsa_pkcs1.cpp @@ -11,9 +11,7 @@ namespace Botan { -namespace { - -EMSA* make_pkcs1v15(const EMSA::Spec& spec) +EMSA* EMSA_PKCS1v15::make(const EMSA::Spec& spec) { if(spec.arg(0) == "Raw") return new EMSA_PKCS1v15_Raw; @@ -25,10 +23,6 @@ EMSA* make_pkcs1v15(const EMSA::Spec& spec) return nullptr; } -} - -BOTAN_REGISTER_NAMED_T(EMSA, "EMSA_PKCS1", EMSA_PCS1v15, make_pkcs1v15); - namespace { secure_vector<byte> emsa3_encoding(const secure_vector<byte>& msg, diff --git a/src/lib/pk_pad/emsa_pkcs1/emsa_pkcs1.h b/src/lib/pk_pad/emsa_pkcs1/emsa_pkcs1.h index 7bcae3bd1..19886f80c 100644 --- a/src/lib/pk_pad/emsa_pkcs1/emsa_pkcs1.h +++ b/src/lib/pk_pad/emsa_pkcs1/emsa_pkcs1.h @@ -21,6 +21,8 @@ namespace Botan { class BOTAN_DLL EMSA_PKCS1v15 : public EMSA { public: + static EMSA* make(const EMSA::Spec& spec); + /** * @param hash the hash object to use */ diff --git a/src/lib/pk_pad/emsa_pssr/pssr.cpp b/src/lib/pk_pad/emsa_pssr/pssr.cpp index a4744f8f4..06ca007c8 100644 --- a/src/lib/pk_pad/emsa_pssr/pssr.cpp +++ b/src/lib/pk_pad/emsa_pssr/pssr.cpp @@ -5,10 +5,10 @@ * Botan is released under the Simplified BSD License (see license.txt) */ -#include <botan/internal/pad_utils.h> #include <botan/pssr.h> #include <botan/mgf1.h> #include <botan/internal/bit_ops.h> +#include <botan/lookup.h> namespace Botan { @@ -26,8 +26,6 @@ PSSR* PSSR::make(const Spec& request) return nullptr; } -BOTAN_REGISTER_NAMED_T(EMSA, "PSSR", PSSR, PSSR::make); - /* * PSSR Update Operation */ diff --git a/src/lib/pk_pad/emsa_raw/emsa_raw.cpp b/src/lib/pk_pad/emsa_raw/emsa_raw.cpp index dcce888f2..287acb233 100644 --- a/src/lib/pk_pad/emsa_raw/emsa_raw.cpp +++ b/src/lib/pk_pad/emsa_raw/emsa_raw.cpp @@ -10,8 +10,6 @@ namespace Botan { -BOTAN_REGISTER_EMSA_NAMED_NOARGS(EMSA_Raw, "Raw"); - /* * EMSA-Raw Encode Operation */ diff --git a/src/lib/pk_pad/emsa_x931/emsa_x931.cpp b/src/lib/pk_pad/emsa_x931/emsa_x931.cpp index fb1e4343a..2feedee1c 100644 --- a/src/lib/pk_pad/emsa_x931/emsa_x931.cpp +++ b/src/lib/pk_pad/emsa_x931/emsa_x931.cpp @@ -5,14 +5,11 @@ * Botan is released under the Simplified BSD License (see license.txt) */ -#include <botan/internal/pad_utils.h> #include <botan/emsa_x931.h> #include <botan/hash_id.h> namespace Botan { -BOTAN_REGISTER_EMSA_1HASH(EMSA_X931, "EMSA_X931"); - namespace { secure_vector<byte> emsa2_encoding(const secure_vector<byte>& msg, diff --git a/src/lib/pk_pad/get_pk_pad.cpp b/src/lib/pk_pad/get_pk_pad.cpp deleted file mode 100644 index 691de23e2..000000000 --- a/src/lib/pk_pad/get_pk_pad.cpp +++ /dev/null @@ -1,38 +0,0 @@ -/* -* EMSA/EME Retrieval -* (C) 1999-2007 Jack Lloyd -* -* Botan is released under the Simplified BSD License (see license.txt) -*/ - -#include <botan/emsa.h> -#include <botan/eme.h> -#include <botan/scan_name.h> -#include <botan/internal/algo_registry.h> - -namespace Botan { - -EMSA* get_emsa(const std::string& algo_spec) - { - SCAN_Name request(algo_spec); - - if(EMSA* emsa = make_a<EMSA>(algo_spec)) - return emsa; - - throw Algorithm_Not_Found(algo_spec); - } - -EME* get_eme(const std::string& algo_spec) - { - SCAN_Name request(algo_spec); - - if(EME* eme = make_a<EME>(algo_spec)) - return eme; - - if(request.algo_name() == "Raw") - return nullptr; // No padding - - throw Algorithm_Not_Found(algo_spec); - } - -} diff --git a/src/lib/pk_pad/pad_utils.h b/src/lib/pk_pad/pad_utils.h index 3918e133a..ba2de65ea 100644 --- a/src/lib/pk_pad/pad_utils.h +++ b/src/lib/pk_pad/pad_utils.h @@ -9,9 +9,6 @@ #define BOTAN_PK_PAD_UTILS_H__ #include <botan/internal/algo_registry.h> -#include <botan/internal/xor_buf.h> -#include <botan/loadstor.h> -#include <algorithm> namespace Botan { diff --git a/src/lib/pubkey/ecdh/ecdh.cpp b/src/lib/pubkey/ecdh/ecdh.cpp index bad0f2c0b..6b589df9b 100644 --- a/src/lib/pubkey/ecdh/ecdh.cpp +++ b/src/lib/pubkey/ecdh/ecdh.cpp @@ -12,6 +12,8 @@ namespace Botan { +ECDH_PublicKey::ECDH_PublicKey() {} + namespace { /** diff --git a/src/lib/pubkey/ecdh/ecdh.h b/src/lib/pubkey/ecdh/ecdh.h index ef3e8ef7a..2f892436c 100644 --- a/src/lib/pubkey/ecdh/ecdh.h +++ b/src/lib/pubkey/ecdh/ecdh.h @@ -56,7 +56,7 @@ class BOTAN_DLL ECDH_PublicKey : public virtual EC_PublicKey { return unlock(EC2OSP(public_point(), PointGFp::UNCOMPRESSED)); } protected: - ECDH_PublicKey() {} + ECDH_PublicKey(); }; /** diff --git a/src/scripts/ci/circle/clang-static-debug.sh b/src/scripts/ci/circle/clang-static-debug.sh index 8bf96fcfe..6341dd467 100755 --- a/src/scripts/ci/circle/clang-static-debug.sh +++ b/src/scripts/ci/circle/clang-static-debug.sh @@ -5,6 +5,6 @@ which shellcheck > /dev/null && shellcheck "$0" # Run shellcheck on this if avai BUILD_NICKNAME=$(basename "$0" .sh) BUILD_DIR="./build-$BUILD_NICKNAME" -./configure.py --with-build-dir="$BUILD_DIR" --build-mode=debug --cc=clang --disable-shared --via-amalgamation +./configure.py --with-build-dir="$BUILD_DIR" --build-mode=debug --cc=clang --disable-shared make -j 2 -f "$BUILD_DIR"/Makefile "$BUILD_DIR"/botan-test diff --git a/src/tests/test_ffi.cpp b/src/tests/test_ffi.cpp index 5aa4930b9..63f8a5b20 100644 --- a/src/tests/test_ffi.cpp +++ b/src/tests/test_ffi.cpp @@ -346,9 +346,9 @@ TEST_CASE("FFI ECDH", "[ffi]") botan_rng_init(&rng, "system"); botan_privkey_t priv1; - CHECK_THAT(botan_privkey_create_ecdh(&priv1, rng, "secp256r1"), Equals(0)); + REQUIRE_THAT(botan_privkey_create_ecdh(&priv1, rng, "secp256r1"), Equals(0)); botan_privkey_t priv2; - CHECK_THAT(botan_privkey_create_ecdh(&priv2, rng, "secp256r1"), Equals(0)); + REQUIRE_THAT(botan_privkey_create_ecdh(&priv2, rng, "secp256r1"), Equals(0)); botan_pubkey_t pub1; CHECK_THAT(botan_privkey_export_pubkey(&pub1, priv1), Equals(0)); @@ -356,9 +356,9 @@ TEST_CASE("FFI ECDH", "[ffi]") CHECK_THAT(botan_privkey_export_pubkey(&pub2, priv2), Equals(0)); botan_pk_op_ka_t ka1; - CHECK_THAT(botan_pk_op_key_agreement_create(&ka1, priv1, "KDF2(SHA-256)", 0), Equals(0)); + REQUIRE_THAT(botan_pk_op_key_agreement_create(&ka1, priv1, "KDF2(SHA-256)", 0), Equals(0)); botan_pk_op_ka_t ka2; - CHECK_THAT(botan_pk_op_key_agreement_create(&ka2, priv2, "KDF2(SHA-256)", 0), Equals(0)); + REQUIRE_THAT(botan_pk_op_key_agreement_create(&ka2, priv2, "KDF2(SHA-256)", 0), Equals(0)); std::vector<uint8_t> pubkey1(256); // length problem again size_t pubkey1_len = pubkey1.size(); @@ -371,7 +371,7 @@ TEST_CASE("FFI ECDH", "[ffi]") pubkey2.resize(pubkey2_len); std::vector<uint8_t> salt(32); - CHECK_THAT(botan_rng_get(rng, salt.data(), salt.size()), Equals(0)); + REQUIRE_THAT(botan_rng_get(rng, salt.data(), salt.size()), Equals(0)); const size_t shared_key_len = 64; |