diff options
author | Jack Lloyd <[email protected]> | 2017-09-21 13:49:14 -0400 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2017-09-21 13:49:14 -0400 |
commit | 5cc5e1bd3fac87186f511a48cee9cda86e4607ca (patch) | |
tree | ea64916bb405f215bc5aed2cddfecdc85322bada | |
parent | b331caf9ae61410aaa6e7e7fc4b33267562bd78e (diff) |
Clean up header includes
Avoid including build.h or assert.h directly, instead always take
them though types.h
Avoid math.h in favor of cmath
33 files changed, 27 insertions, 53 deletions
diff --git a/src/lib/entropy/rdrand/rdrand.cpp b/src/lib/entropy/rdrand/rdrand.cpp index 7fa05c605..6a5b0f7c4 100644 --- a/src/lib/entropy/rdrand/rdrand.cpp +++ b/src/lib/entropy/rdrand/rdrand.cpp @@ -9,7 +9,6 @@ #include <botan/internal/rdrand.h> #include <botan/rdrand_rng.h> #include <botan/cpuid.h> -#include <botan/build.h> namespace Botan { diff --git a/src/lib/entropy/rdseed/rdseed.cpp b/src/lib/entropy/rdseed/rdseed.cpp index 01cab3a7e..fbb8f921e 100644 --- a/src/lib/entropy/rdseed/rdseed.cpp +++ b/src/lib/entropy/rdseed/rdseed.cpp @@ -7,7 +7,6 @@ #include <botan/internal/rdseed.h> #include <botan/cpuid.h> -#include <botan/build.h> #if !defined(BOTAN_USE_GCC_INLINE_ASM) #include <immintrin.h> diff --git a/src/lib/prov/pkcs11/p11_ecc_key.h b/src/lib/prov/pkcs11/p11_ecc_key.h index 0b4d86243..2ab92790d 100644 --- a/src/lib/prov/pkcs11/p11_ecc_key.h +++ b/src/lib/prov/pkcs11/p11_ecc_key.h @@ -9,7 +9,6 @@ #ifndef BOTAN_P11_ECC_H_ #define BOTAN_P11_ECC_H_ -#include <botan/build.h> #include <botan/p11_object.h> #if defined(BOTAN_HAS_ECC_PUBLIC_KEY_CRYPTO) diff --git a/src/lib/prov/pkcs11/p11_ecdh.h b/src/lib/prov/pkcs11/p11_ecdh.h index 6ad9d8889..d95966a97 100644 --- a/src/lib/prov/pkcs11/p11_ecdh.h +++ b/src/lib/prov/pkcs11/p11_ecdh.h @@ -9,10 +9,10 @@ #ifndef BOTAN_P11_ECDH_H_ #define BOTAN_P11_ECDH_H_ -#include <botan/build.h> +#include <botan/p11.h> + #if defined(BOTAN_HAS_ECDH) -#include <botan/p11.h> #include <botan/p11_ecc_key.h> #include <botan/ecdh.h> diff --git a/src/lib/prov/pkcs11/p11_ecdsa.h b/src/lib/prov/pkcs11/p11_ecdsa.h index 829eaebe7..ae1a9c0bc 100644 --- a/src/lib/prov/pkcs11/p11_ecdsa.h +++ b/src/lib/prov/pkcs11/p11_ecdsa.h @@ -9,7 +9,8 @@ #ifndef BOTAN_P11_ECDSA_H_ #define BOTAN_P11_ECDSA_H_ -#include <botan/build.h> +#include <botan/p11.h> + #if defined(BOTAN_HAS_ECDSA) #include <botan/p11_ecc_key.h> diff --git a/src/lib/prov/pkcs11/p11_rsa.h b/src/lib/prov/pkcs11/p11_rsa.h index b5d601365..ba35db240 100644 --- a/src/lib/prov/pkcs11/p11_rsa.h +++ b/src/lib/prov/pkcs11/p11_rsa.h @@ -9,8 +9,6 @@ #ifndef BOTAN_P11_RSA_H_ #define BOTAN_P11_RSA_H_ -#include <botan/build.h> -#include <botan/p11.h> #include <botan/p11_session.h> #include <botan/p11_object.h> diff --git a/src/lib/prov/pkcs11/p11_session.h b/src/lib/prov/pkcs11/p11_session.h index eab686ed8..8b32063e3 100644 --- a/src/lib/prov/pkcs11/p11_session.h +++ b/src/lib/prov/pkcs11/p11_session.h @@ -9,7 +9,6 @@ #ifndef BOTAN_P11_SESSION_H_ #define BOTAN_P11_SESSION_H_ -#include <botan/p11.h> #include <botan/p11_slot.h> #include <utility> diff --git a/src/lib/prov/pkcs11/p11_slot.h b/src/lib/prov/pkcs11/p11_slot.h index 1787aab0d..63da32a0e 100644 --- a/src/lib/prov/pkcs11/p11_slot.h +++ b/src/lib/prov/pkcs11/p11_slot.h @@ -13,7 +13,6 @@ #include <vector> #include <functional> -#include <botan/p11.h> #include <botan/p11_module.h> namespace Botan { diff --git a/src/lib/prov/pkcs11/p11_x509.h b/src/lib/prov/pkcs11/p11_x509.h index 9066e16c8..ed084e9c1 100644 --- a/src/lib/prov/pkcs11/p11_x509.h +++ b/src/lib/prov/pkcs11/p11_x509.h @@ -9,13 +9,11 @@ #ifndef BOTAN_P11_X509_H_ #define BOTAN_P11_X509_H_ -#include <botan/build.h> -#if defined(BOTAN_HAS_X509_CERTIFICATES) - #include <botan/p11_object.h> -#include <botan/x509cert.h> +#if defined(BOTAN_HAS_X509_CERTIFICATES) +#include <botan/x509cert.h> #include <vector> namespace Botan { diff --git a/src/lib/pubkey/xmss/xmss_common_ops.h b/src/lib/pubkey/xmss/xmss_common_ops.h index 66fc76ef0..176582efe 100644 --- a/src/lib/pubkey/xmss/xmss_common_ops.h +++ b/src/lib/pubkey/xmss/xmss_common_ops.h @@ -10,7 +10,6 @@ #include <vector> #include <botan/secmem.h> -#include <botan/assert.h> #include <botan/xmss_parameters.h> #include <botan/xmss_address.h> #include <botan/xmss_hash.h> diff --git a/src/lib/pubkey/xmss/xmss_hash.h b/src/lib/pubkey/xmss/xmss_hash.h index d507c96f6..7dcfb8465 100644 --- a/src/lib/pubkey/xmss/xmss_hash.h +++ b/src/lib/pubkey/xmss/xmss_hash.h @@ -8,12 +8,7 @@ #ifndef BOTAN_XMSS_HASH_H_ #define BOTAN_XMSS_HASH_H_ -#include <cstddef> -#include <string> -#include <botan/assert.h> #include <botan/hash.h> -#include <botan/secmem.h> -#include <botan/types.h> namespace Botan { diff --git a/src/lib/pubkey/xmss/xmss_parameters.cpp b/src/lib/pubkey/xmss/xmss_parameters.cpp index cc4d923dd..f6d630875 100644 --- a/src/lib/pubkey/xmss/xmss_parameters.cpp +++ b/src/lib/pubkey/xmss/xmss_parameters.cpp @@ -13,6 +13,7 @@ **/ #include <botan/xmss_parameters.h> +#include <botan/exceptn.h> namespace Botan { diff --git a/src/lib/pubkey/xmss/xmss_parameters.h b/src/lib/pubkey/xmss/xmss_parameters.h index 413941b4c..a2f763d97 100644 --- a/src/lib/pubkey/xmss/xmss_parameters.h +++ b/src/lib/pubkey/xmss/xmss_parameters.h @@ -8,12 +8,9 @@ #ifndef BOTAN_XMSS_PARAMETERS_H_ #define BOTAN_XMSS_PARAMETERS_H_ -#include <cstddef> -#include <map> -#include <string> -#include <botan/assert.h> -#include <botan/types.h> #include <botan/xmss_wots_parameters.h> +#include <string> +#include <map> namespace Botan { diff --git a/src/lib/pubkey/xmss/xmss_privatekey.cpp b/src/lib/pubkey/xmss/xmss_privatekey.cpp index 3f2f949ca..753893c8c 100644 --- a/src/lib/pubkey/xmss/xmss_privatekey.cpp +++ b/src/lib/pubkey/xmss/xmss_privatekey.cpp @@ -17,6 +17,7 @@ #include <botan/internal/xmss_signature_operation.h> #include <botan/xmss_privatekey.h> +#include <cmath> namespace Botan { @@ -26,7 +27,7 @@ XMSS_PrivateKey::XMSS_PrivateKey(const secure_vector<uint8_t>& raw_key) m_wots_priv_key(m_wots_params.oid(), m_public_seed), m_index_reg(XMSS_Index_Registry::get_instance()) { - BOTAN_ASSERT(sizeof(size_t) >= ceil( + BOTAN_ASSERT(sizeof(size_t) >= std::ceil( static_cast<float>(XMSS_PublicKey::m_xmss_params.tree_height()) / 8.f), "System type \"size_t\" not big enough to support" " leaf index."); diff --git a/src/lib/pubkey/xmss/xmss_privatekey.h b/src/lib/pubkey/xmss/xmss_privatekey.h index 335f3120d..b5cbf9cac 100644 --- a/src/lib/pubkey/xmss/xmss_privatekey.h +++ b/src/lib/pubkey/xmss/xmss_privatekey.h @@ -12,7 +12,6 @@ #include <iterator> #include <memory> #include <botan/alg_id.h> -#include <botan/assert.h> #include <botan/exceptn.h> #include <botan/pk_keys.h> #include <botan/rng.h> diff --git a/src/lib/pubkey/xmss/xmss_publickey.h b/src/lib/pubkey/xmss/xmss_publickey.h index fbf474793..af14b15b6 100644 --- a/src/lib/pubkey/xmss/xmss_publickey.h +++ b/src/lib/pubkey/xmss/xmss_publickey.h @@ -15,7 +15,6 @@ #include <botan/alg_id.h> #include <botan/asn1_oid.h> #include <botan/der_enc.h> -#include <botan/assert.h> #include <botan/exceptn.h> #include <botan/rng.h> #include <botan/types.h> diff --git a/src/lib/pubkey/xmss/xmss_signature.cpp b/src/lib/pubkey/xmss/xmss_signature.cpp index 497a25f2b..8dbb17909 100644 --- a/src/lib/pubkey/xmss/xmss_signature.cpp +++ b/src/lib/pubkey/xmss/xmss_signature.cpp @@ -6,6 +6,7 @@ **/ #include <botan/internal/xmss_signature.h> +#include <cmath> namespace Botan { @@ -13,7 +14,7 @@ XMSS_Signature::XMSS_Signature(XMSS_Parameters::xmss_algorithm_t oid, const secure_vector<uint8_t>& raw_sig) : m_leaf_idx(0), m_randomness(0, 0x00), m_tree_sig() { - BOTAN_ASSERT(sizeof(size_t) >= ceil(static_cast<float>( + BOTAN_ASSERT(sizeof(size_t) >= std::ceil(static_cast<float>( (XMSS_Parameters(oid)).tree_height()) / 8.f), "System type \"size_t\" not big enough to support" " leaf index."); diff --git a/src/lib/pubkey/xmss/xmss_signature_operation.h b/src/lib/pubkey/xmss/xmss_signature_operation.h index 10197a093..7a5845818 100644 --- a/src/lib/pubkey/xmss/xmss_signature_operation.h +++ b/src/lib/pubkey/xmss/xmss_signature_operation.h @@ -12,7 +12,6 @@ #include <string> #include <botan/secmem.h> #include <botan/types.h> -#include <botan/assert.h> #include <botan/xmss_parameters.h> #include <botan/xmss_privatekey.h> #include <botan/xmss_address.h> diff --git a/src/lib/pubkey/xmss/xmss_verification_operation.h b/src/lib/pubkey/xmss/xmss_verification_operation.h index 948550193..de8816134 100644 --- a/src/lib/pubkey/xmss/xmss_verification_operation.h +++ b/src/lib/pubkey/xmss/xmss_verification_operation.h @@ -12,7 +12,6 @@ #include <cstddef> #include <iterator> #include <string> -#include <botan/assert.h> #include <botan/types.h> #include <botan/xmss_publickey.h> #include <botan/xmss_common_ops.h> diff --git a/src/lib/pubkey/xmss/xmss_wots_parameters.cpp b/src/lib/pubkey/xmss/xmss_wots_parameters.cpp index 704bcab36..20f758ed2 100644 --- a/src/lib/pubkey/xmss/xmss_wots_parameters.cpp +++ b/src/lib/pubkey/xmss/xmss_wots_parameters.cpp @@ -14,6 +14,8 @@ **/ #include <botan/xmss_wots_parameters.h> +#include <botan/exceptn.h> +#include <cmath> namespace Botan { @@ -80,7 +82,7 @@ XMSS_WOTS_Parameters::XMSS_WOTS_Parameters(ots_algorithm_t oid) } m_w == 16 ? m_lg_w = 4 : m_lg_w = 2; - m_len_1 = static_cast<size_t>(ceil((8 * element_size()) / m_lg_w)); + m_len_1 = static_cast<size_t>(std::ceil((8 * element_size()) / m_lg_w)); m_len_2 = static_cast<size_t>( floor(log2(m_len_1 * (wots_parameter() - 1)) / m_lg_w) + 1); BOTAN_ASSERT(m_len == m_len_1 + m_len_2, "Invalid XMSS WOTS parameter " @@ -114,7 +116,7 @@ XMSS_WOTS_Parameters::base_w(size_t value) const { value <<= (8 - ((m_len_2 * m_lg_w) % 8)); size_t len_2_bytes = static_cast<size_t>( - ceil(static_cast<float>(m_len_2 * m_lg_w) / 8.f)); + std::ceil(static_cast<float>(m_len_2 * m_lg_w) / 8.f)); secure_vector<uint8_t> result; XMSS_Tools::concat(result, value, len_2_bytes); return base_w(result, m_len_2); diff --git a/src/lib/pubkey/xmss/xmss_wots_parameters.h b/src/lib/pubkey/xmss/xmss_wots_parameters.h index a1cd8e971..0e16b900b 100644 --- a/src/lib/pubkey/xmss/xmss_wots_parameters.h +++ b/src/lib/pubkey/xmss/xmss_wots_parameters.h @@ -8,17 +8,10 @@ #ifndef BOTAN_XMSS_WOTS_PARAMETERS_H_ #define BOTAN_XMSS_WOTS_PARAMETERS_H_ -#include <cstddef> -#include <cstdint> -#include <iterator> +#include <botan/xmss_tools.h> +#include <botan/secmem.h> #include <map> #include <string> -#include <math.h> -#include <botan/assert.h> -#include <botan/types.h> -#include <botan/secmem.h> -#include <botan/exceptn.h> -#include <botan/xmss_tools.h> namespace Botan { diff --git a/src/lib/pubkey/xmss/xmss_wots_privatekey.h b/src/lib/pubkey/xmss/xmss_wots_privatekey.h index 69d4234c4..fa8a23cad 100644 --- a/src/lib/pubkey/xmss/xmss_wots_privatekey.h +++ b/src/lib/pubkey/xmss/xmss_wots_privatekey.h @@ -11,7 +11,6 @@ #include <cstddef> #include <memory> #include <botan/alg_id.h> -#include <botan/assert.h> #include <botan/exceptn.h> #include <botan/pk_keys.h> #include <botan/types.h> diff --git a/src/lib/pubkey/xmss/xmss_wots_publickey.h b/src/lib/pubkey/xmss/xmss_wots_publickey.h index e111702be..86b4bc803 100644 --- a/src/lib/pubkey/xmss/xmss_wots_publickey.h +++ b/src/lib/pubkey/xmss/xmss_wots_publickey.h @@ -13,7 +13,6 @@ #include <vector> #include <botan/alg_id.h> #include <botan/asn1_oid.h> -#include <botan/assert.h> #include <botan/exceptn.h> #include <botan/pk_keys.h> #include <botan/types.h> diff --git a/src/lib/pubkey/xmss/xmss_wots_signature_operation.h b/src/lib/pubkey/xmss/xmss_wots_signature_operation.h index d9d559cb2..271766e87 100644 --- a/src/lib/pubkey/xmss/xmss_wots_signature_operation.h +++ b/src/lib/pubkey/xmss/xmss_wots_signature_operation.h @@ -10,7 +10,6 @@ #include <cstddef> #include <iterator> -#include <botan/assert.h> #include <botan/types.h> #include <botan/pk_ops.h> #include <botan/internal/xmss_wots_addressed_privatekey.h> diff --git a/src/lib/rng/system_rng/system_rng.cpp b/src/lib/rng/system_rng/system_rng.cpp index 9ee306991..fe9ae0f28 100644 --- a/src/lib/rng/system_rng/system_rng.cpp +++ b/src/lib/rng/system_rng/system_rng.cpp @@ -6,7 +6,6 @@ */ #include <botan/system_rng.h> -#include <botan/build.h> #if defined(BOTAN_TARGET_OS_HAS_CRYPTGENRANDOM) #define NOMINMAX 1 diff --git a/src/lib/utils/assert.h b/src/lib/utils/assert.h index ab0616ff9..3f5f0231d 100644 --- a/src/lib/utils/assert.h +++ b/src/lib/utils/assert.h @@ -9,7 +9,7 @@ #ifndef BOTAN_ASSERTION_CHECKING_H_ #define BOTAN_ASSERTION_CHECKING_H_ -#include <botan/build.h> +#include <botan/compiler.h> namespace Botan { diff --git a/src/lib/utils/compiler.h b/src/lib/utils/compiler.h index ff7f36571..00f22358a 100644 --- a/src/lib/utils/compiler.h +++ b/src/lib/utils/compiler.h @@ -5,6 +5,10 @@ * Botan is released under the Simplified BSD License (see license.txt) */ +/* This header is included in both C++ and C (via ffi.h) and should only + contain macro definitions. +*/ + #ifndef BOTAN_UTIL_COMPILER_FLAGS_H_ #define BOTAN_UTIL_COMPILER_FLAGS_H_ diff --git a/src/lib/utils/dyn_load/dyn_load.cpp b/src/lib/utils/dyn_load/dyn_load.cpp index 2b24e5f6c..2cacf7c46 100644 --- a/src/lib/utils/dyn_load/dyn_load.cpp +++ b/src/lib/utils/dyn_load/dyn_load.cpp @@ -6,7 +6,6 @@ */ #include <botan/dyn_load.h> -#include <botan/build.h> #include <botan/exceptn.h> #if defined(BOTAN_TARGET_OS_HAS_DLOPEN) diff --git a/src/lib/utils/dyn_load/dyn_load.h b/src/lib/utils/dyn_load/dyn_load.h index 31da6b7a2..581eac724 100644 --- a/src/lib/utils/dyn_load/dyn_load.h +++ b/src/lib/utils/dyn_load/dyn_load.h @@ -8,8 +8,8 @@ #ifndef BOTAN_DYNAMIC_LOADER_H_ #define BOTAN_DYNAMIC_LOADER_H_ +#include <botan/types.h> #include <string> -#include <botan/build.h> namespace Botan { diff --git a/src/lib/utils/mutex.h b/src/lib/utils/mutex.h index e8718d5eb..46a652bba 100644 --- a/src/lib/utils/mutex.h +++ b/src/lib/utils/mutex.h @@ -7,7 +7,6 @@ #ifndef BOTAN_UTIL_MUTEX_H_ #define BOTAN_UTIL_MUTEX_H_ -#include <botan/build.h> #include <botan/types.h> #if defined(BOTAN_TARGET_OS_HAS_THREADS) diff --git a/src/lib/utils/rounding.h b/src/lib/utils/rounding.h index e74a80798..a06626b88 100644 --- a/src/lib/utils/rounding.h +++ b/src/lib/utils/rounding.h @@ -9,7 +9,6 @@ #define BOTAN_ROUNDING_H_ #include <botan/types.h> -#include <botan/assert.h> namespace Botan { diff --git a/src/lib/x509/cert_status.h b/src/lib/x509/cert_status.h index 3bc610571..fb246e71a 100644 --- a/src/lib/x509/cert_status.h +++ b/src/lib/x509/cert_status.h @@ -8,7 +8,7 @@ #ifndef BOTAN_X509_PATH_RESULT_H_ #define BOTAN_X509_PATH_RESULT_H_ -#include <botan/build.h> +#include <botan/types.h> namespace Botan { diff --git a/src/lib/x509/key_constraint.h b/src/lib/x509/key_constraint.h index 268bd87f1..3d456f6c4 100644 --- a/src/lib/x509/key_constraint.h +++ b/src/lib/x509/key_constraint.h @@ -9,7 +9,7 @@ #ifndef BOTAN_ENUMS_H_ #define BOTAN_ENUMS_H_ -#include <botan/build.h> +#include <botan/types.h> #include <string> namespace Botan { |