diff options
26 files changed, 39 insertions, 41 deletions
diff --git a/src/cli/fpe.cpp b/src/cli/fpe.cpp index 97ca34b24..10b3096bf 100644 --- a/src/cli/fpe.cpp +++ b/src/cli/fpe.cpp @@ -10,7 +10,6 @@ #include <botan/fpe_fe1.h> #include <botan/sha160.h> -#include <stdexcept> using namespace Botan; diff --git a/src/cli/getopt.h b/src/cli/getopt.h index f683159d0..21a12b1dc 100644 --- a/src/cli/getopt.h +++ b/src/cli/getopt.h @@ -9,7 +9,6 @@ #include <string> #include <vector> -#include <stdexcept> #include <map> #include <botan/parsing.h> diff --git a/src/lib/base/algo_registry.h b/src/lib/base/algo_registry.h index 842c4167b..3b1a72d88 100644 --- a/src/lib/base/algo_registry.h +++ b/src/lib/base/algo_registry.h @@ -9,8 +9,8 @@ #define BOTAN_ALGO_REGISTRY_H__ #include <botan/types.h> +#include <botan/exceptn.h> #include <functional> -#include <stdexcept> #include <mutex> #include <vector> #include <map> diff --git a/src/lib/base/scan_name.cpp b/src/lib/base/scan_name.cpp index 5c8c55b27..6f5eac43c 100644 --- a/src/lib/base/scan_name.cpp +++ b/src/lib/base/scan_name.cpp @@ -8,7 +8,6 @@ #include <botan/scan_name.h> #include <botan/parsing.h> #include <botan/exceptn.h> -#include <stdexcept> namespace Botan { diff --git a/src/lib/codec/base64/base64.cpp b/src/lib/codec/base64/base64.cpp index b5f4244a1..bd4d36cfa 100644 --- a/src/lib/codec/base64/base64.cpp +++ b/src/lib/codec/base64/base64.cpp @@ -6,9 +6,9 @@ */ #include <botan/base64.h> +#include <botan/exceptn.h> #include <botan/mem_ops.h> #include <botan/internal/rounding.h> -#include <stdexcept> namespace Botan { diff --git a/src/lib/codec/hex/hex.cpp b/src/lib/codec/hex/hex.cpp index a718cc8be..e47a75cb7 100644 --- a/src/lib/codec/hex/hex.cpp +++ b/src/lib/codec/hex/hex.cpp @@ -7,7 +7,7 @@ #include <botan/hex.h> #include <botan/mem_ops.h> -#include <stdexcept> +#include <botan/exceptn.h> namespace Botan { diff --git a/src/lib/entropy/egd/es_egd.cpp b/src/lib/entropy/egd/es_egd.cpp index 8392996ab..ba43cc86d 100644 --- a/src/lib/entropy/egd/es_egd.cpp +++ b/src/lib/entropy/egd/es_egd.cpp @@ -9,7 +9,6 @@ #include <botan/parsing.h> #include <botan/exceptn.h> #include <botan/mem_ops.h> -#include <stdexcept> #include <sys/types.h> #include <sys/stat.h> diff --git a/src/lib/entropy/unix_procs/unix_procs.cpp b/src/lib/entropy/unix_procs/unix_procs.cpp index 30ea6157b..55ad295cd 100644 --- a/src/lib/entropy/unix_procs/unix_procs.cpp +++ b/src/lib/entropy/unix_procs/unix_procs.cpp @@ -9,6 +9,7 @@ */ #include <botan/internal/unix_procs.h> +#include <botan/exceptn.h> #include <botan/parsing.h> #include <algorithm> #include <atomic> diff --git a/src/lib/ffi/ffi.cpp b/src/lib/ffi/ffi.cpp index dac4cafad..48591a774 100644 --- a/src/lib/ffi/ffi.cpp +++ b/src/lib/ffi/ffi.cpp @@ -6,6 +6,7 @@ #include <botan/ffi.h> #include <botan/system_rng.h> +#include <botan/exceptn.h> #include <botan/auto_rng.h> #include <botan/aead.h> #include <botan/hash.h> @@ -59,7 +60,13 @@ namespace { #define BOTAN_ASSERT_ARG_NON_NULL(p) \ - do { if(!p) throw Invalid_Argument("Argument " #p " is null"); } while(0) + do { if(!p) throw Botan::Invalid_Argument("Argument " #p " is null"); } while(0) + +class FFI_Error : public Botan::Exception + { + public: + FFI_Error(const std::string& what) : Exception("FFI error", what) {} + }; template<typename T, uint32_t MAGIC> struct botan_struct @@ -71,8 +78,8 @@ struct botan_struct T* get() const { if(m_magic != MAGIC) - throw Exception("Bad magic " + std::to_string(m_magic) + - " in ffi object expected " + std::to_string(MAGIC)); + throw FFI_Error("Bad magic " + std::to_string(m_magic) + + " in ffi object expected " + std::to_string(MAGIC)); return m_obj.get(); } private: @@ -95,10 +102,10 @@ template<typename T, uint32_t M> T& safe_get(botan_struct<T,M>* p) { if(!p) - throw Exception("Null pointer argument"); + throw FFI_Error("Null pointer argument"); if(T* t = p->get()) return *t; - throw Exception("Invalid object pointer"); + throw FFI_Error("Invalid object pointer"); } template<typename T, uint32_t M, typename F> @@ -107,7 +114,7 @@ int apply_fn(botan_struct<T, M>* o, const char* func_name, F func) try { if(!o) - throw Exception("Null object to " + std::string(func_name)); + throw FFI_Error("Null object to " + std::string(func_name)); if(T* t = o->get()) return func(*t); } @@ -677,7 +684,7 @@ int botan_bcrypt_generate(uint8_t* out, size_t* out_len, return BOTAN_FFI_ERROR_BAD_FLAG; if(wf < 2 || wf > 30) - throw Exception("Bad bcrypt work factor " + std::to_string(wf)); + throw FFI_Error("Bad bcrypt work factor " + std::to_string(wf)); #if defined(BOTAN_HAS_BCRYPT) Botan::RandomNumberGenerator& rng = safe_get(rng_obj); diff --git a/src/lib/filters/buf_filt.cpp b/src/lib/filters/buf_filt.cpp index eb978cffd..6fb367e5f 100644 --- a/src/lib/filters/buf_filt.cpp +++ b/src/lib/filters/buf_filt.cpp @@ -8,7 +8,7 @@ #include <botan/buf_filt.h> #include <botan/mem_ops.h> #include <botan/internal/rounding.h> -#include <stdexcept> +#include <botan/exceptn.h> namespace Botan { diff --git a/src/lib/hash/comb4p/comb4p.cpp b/src/lib/hash/comb4p/comb4p.cpp index 791d6d950..015873473 100644 --- a/src/lib/hash/comb4p/comb4p.cpp +++ b/src/lib/hash/comb4p/comb4p.cpp @@ -6,7 +6,7 @@ */ #include <botan/comb4p.h> -#include <stdexcept> +#include <botan/exceptn.h> namespace Botan { diff --git a/src/lib/math/mp/mp_misc.cpp b/src/lib/math/mp/mp_misc.cpp index adf4a0a6b..768543a64 100644 --- a/src/lib/math/mp/mp_misc.cpp +++ b/src/lib/math/mp/mp_misc.cpp @@ -7,7 +7,7 @@ #include <botan/internal/mp_core.h> #include <botan/internal/mp_madd.h> -#include <stdexcept> +#include <botan/exceptn.h> namespace Botan { @@ -43,7 +43,7 @@ s32bit bigint_cmp(const word x[], size_t x_size, word bigint_divop(word n1, word n0, word d) { if(d == 0) - throw Exception("bigint_divop divide by zero"); + throw Invalid_Argument("bigint_divop divide by zero"); word high = n1 % d, quotient = 0; diff --git a/src/lib/misc/fpe_fe1/fpe_fe1.cpp b/src/lib/misc/fpe_fe1/fpe_fe1.cpp index bc14c425c..fad17c814 100644 --- a/src/lib/misc/fpe_fe1/fpe_fe1.cpp +++ b/src/lib/misc/fpe_fe1/fpe_fe1.cpp @@ -9,7 +9,6 @@ #include <botan/numthry.h> #include <botan/hmac.h> #include <botan/sha2_32.h> -#include <stdexcept> namespace Botan { diff --git a/src/lib/pbkdf/pbkdf.cpp b/src/lib/pbkdf/pbkdf.cpp index dcaa48852..98722fcc6 100644 --- a/src/lib/pbkdf/pbkdf.cpp +++ b/src/lib/pbkdf/pbkdf.cpp @@ -7,7 +7,6 @@ #include <botan/pbkdf.h> #include <botan/internal/algo_registry.h> -#include <stdexcept> #if defined(BOTAN_HAS_PBKDF1) #include <botan/pbkdf1.h> diff --git a/src/lib/pubkey/mce/code_based_util.h b/src/lib/pubkey/mce/code_based_util.h index a959ad0d3..31c962746 100644 --- a/src/lib/pubkey/mce/code_based_util.h +++ b/src/lib/pubkey/mce/code_based_util.h @@ -13,7 +13,6 @@ #define BOTAN_CODE_BASED_UTIL_H__ #include <botan/gf2m_small_m.h> -#include <stdexcept> namespace Botan { diff --git a/src/lib/pubkey/mce/gf2m_small_m.cpp b/src/lib/pubkey/mce/gf2m_small_m.cpp index f427ab4f3..e74e5c71f 100644 --- a/src/lib/pubkey/mce/gf2m_small_m.cpp +++ b/src/lib/pubkey/mce/gf2m_small_m.cpp @@ -9,8 +9,8 @@ */ #include <botan/gf2m_small_m.h> +#include <botan/exceptn.h> #include <string> -#include <stdexcept> namespace Botan { diff --git a/src/lib/tls/tls_ciphersuite.cpp b/src/lib/tls/tls_ciphersuite.cpp index d14376bdd..76c4e2416 100644 --- a/src/lib/tls/tls_ciphersuite.cpp +++ b/src/lib/tls/tls_ciphersuite.cpp @@ -12,7 +12,6 @@ #include <botan/hash.h> #include <botan/mac.h> #include <sstream> -#include <stdexcept> namespace Botan { diff --git a/src/lib/tls/tls_reader.h b/src/lib/tls/tls_reader.h index 7dd9fde57..b3c6db0c9 100644 --- a/src/lib/tls/tls_reader.h +++ b/src/lib/tls/tls_reader.h @@ -13,7 +13,6 @@ #include <botan/loadstor.h> #include <string> #include <vector> -#include <stdexcept> namespace Botan { diff --git a/src/lib/tls/tls_seq_numbers.h b/src/lib/tls/tls_seq_numbers.h index 2071c810d..09962075e 100644 --- a/src/lib/tls/tls_seq_numbers.h +++ b/src/lib/tls/tls_seq_numbers.h @@ -9,7 +9,6 @@ #define BOTAN_TLS_SEQ_NUMBERS_H__ #include <botan/types.h> -#include <stdexcept> namespace Botan { diff --git a/src/lib/utils/dyn_load/dyn_load.cpp b/src/lib/utils/dyn_load/dyn_load.cpp index 9b99331d1..03bf85090 100644 --- a/src/lib/utils/dyn_load/dyn_load.cpp +++ b/src/lib/utils/dyn_load/dyn_load.cpp @@ -7,7 +7,6 @@ #include <botan/internal/dyn_load.h> #include <botan/build.h> -#include <stdexcept> #if defined(BOTAN_TARGET_OS_HAS_DLOPEN) #include <dlfcn.h> diff --git a/src/lib/utils/exceptn.h b/src/lib/utils/exceptn.h index c9b45f916..7ac32288d 100644 --- a/src/lib/utils/exceptn.h +++ b/src/lib/utils/exceptn.h @@ -11,7 +11,6 @@ #include <botan/types.h> #include <botan/parsing.h> #include <exception> -#include <stdexcept> #include <string> namespace Botan { @@ -24,7 +23,8 @@ class BOTAN_DLL Exception : public std::exception public: Exception(const std::string& what) : m_what(what) {} Exception(const char* prefix, const std::string& what) : m_what(std::string(prefix) + " " + what) {} - const char* what() const override { return m_what.c_str(); } + //const char* what() const override BOTAN_NOEXCEPT { return m_what.c_str(); } + const char* what() const BOTAN_NOEXCEPT override { return m_what.c_str(); } private: std::string m_what; }; diff --git a/src/lib/utils/http_util/http_util.h b/src/lib/utils/http_util/http_util.h index 746b790f1..6688285c6 100644 --- a/src/lib/utils/http_util/http_util.h +++ b/src/lib/utils/http_util/http_util.h @@ -9,6 +9,7 @@ #define BOTAN_UTILS_URLGET_H__ #include <botan/types.h> +#include <botan/exceptn.h> #include <future> #include <vector> #include <map> diff --git a/src/lib/utils/parsing.cpp b/src/lib/utils/parsing.cpp index 179e2e546..2bf41f260 100644 --- a/src/lib/utils/parsing.cpp +++ b/src/lib/utils/parsing.cpp @@ -12,7 +12,6 @@ #include <botan/loadstor.h> #include <limits> #include <set> -#include <stdexcept> namespace Botan { diff --git a/src/lib/utils/read_cfg.cpp b/src/lib/utils/read_cfg.cpp index 0719ee681..1a15f2e63 100644 --- a/src/lib/utils/read_cfg.cpp +++ b/src/lib/utils/read_cfg.cpp @@ -6,7 +6,7 @@ */ #include <botan/parsing.h> -#include <stdexcept> +#include <botan/exceptn.h> namespace Botan { diff --git a/src/lib/utils/sqlite3/sqlite3.cpp b/src/lib/utils/sqlite3/sqlite3.cpp index fde89b91d..1220829dd 100644 --- a/src/lib/utils/sqlite3/sqlite3.cpp +++ b/src/lib/utils/sqlite3/sqlite3.cpp @@ -6,7 +6,6 @@ */ #include <botan/sqlite3.h> -#include <stdexcept> #include <sqlite3.h> namespace Botan { diff --git a/src/tests/test_rng.h b/src/tests/test_rng.h index 3016707dd..343356550 100644 --- a/src/tests/test_rng.h +++ b/src/tests/test_rng.h @@ -7,25 +7,25 @@ #ifndef BOTAN_TESTS_FIXED_RNG_H__ #define BOTAN_TESTS_FIXED_RNG_H__ +#include "tests.h" #include <deque> #include <string> -#include <stdexcept> #include <botan/rng.h> #include <botan/hex.h> -using Botan::byte; +namespace Botan_Tests { class Fixed_Output_RNG : public Botan::RandomNumberGenerator { public: bool is_seeded() const override { return !buf.empty(); } - byte random() + uint8_t random() { if(!is_seeded()) - throw Test_Error("Out of bytes"); + throw Test_Error("Fixed output RNG ran out of bytes, test bug?"); - byte out = buf.front(); + uint8_t out = buf.front(); buf.pop_front(); return out; } @@ -34,13 +34,13 @@ class Fixed_Output_RNG : public Botan::RandomNumberGenerator size_t, std::chrono::milliseconds) { return 0; } - void randomize(byte out[], size_t len) override + void randomize(uint8_t out[], size_t len) override { for(size_t j = 0; j != len; j++) out[j] = random(); } - void add_entropy(const byte b[], size_t s) override + void add_entropy(const uint8_t b[], size_t s) override { buf.insert(buf.end(), b, b + s); } @@ -49,14 +49,14 @@ class Fixed_Output_RNG : public Botan::RandomNumberGenerator void clear() throw() override {} - Fixed_Output_RNG(const std::vector<byte>& in) + Fixed_Output_RNG(const std::vector<uint8_t>& in) { buf.insert(buf.end(), in.begin(), in.end()); } Fixed_Output_RNG(const std::string& in_str) { - std::vector<byte> in = Botan::hex_decode(in_str); + std::vector<uint8_t> in = Botan::hex_decode(in_str); buf.insert(buf.end(), in.begin(), in.end()); } @@ -64,7 +64,9 @@ class Fixed_Output_RNG : public Botan::RandomNumberGenerator protected: size_t remaining() const { return buf.size(); } private: - std::deque<byte> buf; + std::deque<uint8_t> buf; }; +} + #endif |