diff options
author | Tim Oesterreich <[email protected]> | 2019-02-25 13:17:32 +0100 |
---|---|---|
committer | Hannes Rantzsch <[email protected]> | 2019-04-16 10:47:59 +0200 |
commit | 4c014371f06ff2057b76f7527a66f396e8be5a1b (patch) | |
tree | 9a073066daf8a40a1511899a7bbf032d4740a201 /src/lib/tls | |
parent | 5423ddfe4c58f4fe69107310c0ae4bdcbf891e48 (diff) |
do not use make_error_code and smaller PR review issues
Diffstat (limited to 'src/lib/tls')
-rw-r--r-- | src/lib/tls/asio/asio_convert_exceptions.h | 50 | ||||
-rw-r--r-- | src/lib/tls/asio/asio_error.h | 63 | ||||
-rw-r--r-- | src/lib/tls/asio/asio_stream.h | 8 | ||||
-rw-r--r-- | src/lib/tls/asio/asio_stream_base.h | 2 | ||||
-rw-r--r-- | src/lib/tls/asio/info.txt | 2 |
5 files changed, 63 insertions, 62 deletions
diff --git a/src/lib/tls/asio/asio_convert_exceptions.h b/src/lib/tls/asio/asio_convert_exceptions.h index 7bb1442da..84da936b3 100644 --- a/src/lib/tls/asio/asio_convert_exceptions.h +++ b/src/lib/tls/asio/asio_convert_exceptions.h @@ -24,103 +24,103 @@ inline boost::system::error_code convertException() } catch(const Botan::TLS::Unexpected_Message&) { - return make_error_code(Botan::TLS::error::unexpected_message); + return Botan::TLS::error::unexpected_message; } catch(const Botan::TLS::TLS_Exception& e) { - return make_error_code(e.type()); + return e.type(); } catch(const Botan::Unsupported_Argument&) { - return make_error_code(Botan::TLS::error::unsupported_argument); + return Botan::TLS::error::unsupported_argument; } catch(const Botan::Invalid_Key_Length&) { - return make_error_code(Botan::TLS::error::invalid_key_length); + return Botan::TLS::error::invalid_key_length; } catch(const Botan::Invalid_IV_Length&) { - return make_error_code(Botan::TLS::error::invalid_iv_length); + return Botan::TLS::error::invalid_iv_length; } catch(const Botan::Invalid_Algorithm_Name&) { - return make_error_code(Botan::TLS::error::invalid_algorithm_name); + return Botan::TLS::error::invalid_algorithm_name; } catch(const Botan::Encoding_Error&) { - return make_error_code(Botan::TLS::error::encoding_error); + return Botan::TLS::error::encoding_error; } catch(const Botan::Invalid_OID&) { - return make_error_code(Botan::TLS::error::invalid_oid); + return Botan::TLS::error::invalid_oid; } catch(const Botan::Decoding_Error&) { - return make_error_code(Botan::TLS::error::decoding_error); + return Botan::TLS::error::decoding_error; } catch(const Botan::Invalid_Argument&) { - return make_error_code(Botan::TLS::error::invalid_argument); + return Botan::TLS::error::invalid_argument; } catch(const Botan::Key_Not_Set&) { - return make_error_code(Botan::TLS::error::key_not_set); + return Botan::TLS::error::key_not_set; } catch(const Botan::PRNG_Unseeded&) { - return make_error_code(Botan::TLS::error::prng_unseeded); + return Botan::TLS::error::prng_unseeded; } catch(const Botan::Policy_Violation&) { - return make_error_code(Botan::TLS::error::policy_violation); + return Botan::TLS::error::policy_violation; } catch(const Botan::Invalid_State&) { - return make_error_code(Botan::TLS::error::invalid_state); + return Botan::TLS::error::invalid_state; } catch(const Botan::Algorithm_Not_Found&) { - return make_error_code(Botan::TLS::error::algorithm_not_found); + return Botan::TLS::error::algorithm_not_found; } catch(const Botan::Provider_Not_Found&) { - return make_error_code(Botan::TLS::error::provider_not_found); + return Botan::TLS::error::provider_not_found; } catch(const Botan::Lookup_Error&) { - return make_error_code(Botan::TLS::error::lookup_error); + return Botan::TLS::error::lookup_error; } catch(const Botan::Self_Test_Failure&) { - return make_error_code(Botan::TLS::error::self_test_failure); + return Botan::TLS::error::self_test_failure; } catch(const Botan::Internal_Error&) { - return make_error_code(Botan::TLS::error::internal_error); + return Botan::TLS::error::internal_error; } catch(const Botan::No_Provider_Found&) { - return make_error_code(Botan::TLS::error::no_provider_found); + return Botan::TLS::error::no_provider_found; } catch(const Botan::Integrity_Failure&) { - return make_error_code(Botan::TLS::error::integrity_failure); + return Botan::TLS::error::integrity_failure; } catch(const Botan::Stream_IO_Error&) { - return make_error_code(Botan::TLS::error::stream_io_error); + return Botan::TLS::error::stream_io_error; } catch(const Botan::Not_Implemented&) { - return make_error_code(Botan::TLS::error::not_implemented); + return Botan::TLS::error::not_implemented; } catch(const Botan::Exception&) { - return make_error_code(Botan::TLS::error::unknown); + return Botan::TLS::error::unknown; } catch(const std::exception&) { - return make_error_code(Botan::TLS::error::unknown); + return Botan::TLS::error::unknown; } } diff --git a/src/lib/tls/asio/asio_error.h b/src/lib/tls/asio/asio_error.h index 8291b1671..e6bd01a6b 100644 --- a/src/lib/tls/asio/asio_error.h +++ b/src/lib/tls/asio/asio_error.h @@ -17,35 +17,6 @@ namespace Botan { namespace TLS { -using error_code = boost::system::error_code; -using error_category = boost::system::error_category; - -// TLS Alerts -struct BotanAlertCategory : error_category - { - const char* name() const noexcept override - { - return "asio.botan.tls.alert"; - } - - std::string message(int ev) const override - { - Botan::TLS::Alert alert(static_cast<Botan::TLS::Alert::Type>(ev)); - return alert.type_string(); - } - }; - -inline const BotanAlertCategory& botan_alert_category() noexcept - { - static BotanAlertCategory category; - return category; - } - -inline error_code make_error_code(Botan::TLS::Alert::Type c) - { - return error_code(static_cast<int>(c), botan_alert_category()); - } - enum class error { unexpected_message = 1, @@ -73,6 +44,31 @@ enum class error unknown }; +using error_code = boost::system::error_code; +using error_category = boost::system::error_category; + +namespace detail { +// TLS Alerts +struct BotanAlertCategory : error_category + { + const char* name() const noexcept override + { + return "asio.botan.tls.alert"; + } + + std::string message(int ev) const override + { + Botan::TLS::Alert alert(static_cast<Botan::TLS::Alert::Type>(ev)); + return alert.type_string(); + } + }; + +inline const BotanAlertCategory& botan_alert_category() noexcept + { + static BotanAlertCategory category; + return category; + } + struct BotanErrorCategory : error_category { const char* name() const noexcept override @@ -140,14 +136,19 @@ inline const BotanErrorCategory& botan_category() noexcept static BotanErrorCategory category; return category; } +} // namespace detail + +inline error_code make_error_code(Botan::TLS::Alert::Type c) + { + return error_code(static_cast<int>(c), detail::botan_alert_category()); + } inline error_code make_error_code(error c) { - return error_code(static_cast<int>(c), botan_category()); + return error_code(static_cast<int>(c), detail::botan_category()); } } // namespace TLS - } // namespace Botan namespace boost { diff --git a/src/lib/tls/asio/asio_stream.h b/src/lib/tls/asio/asio_stream.h index 0d31b24d4..1abad507a 100644 --- a/src/lib/tls/asio/asio_stream.h +++ b/src/lib/tls/asio/asio_stream.h @@ -108,7 +108,7 @@ class Stream final : public StreamBase<Channel> boost::system::error_code& ec) { BOTAN_UNUSED(callback); - ec = make_error_code(Botan::TLS::error::not_implemented); + ec = Botan::TLS::error::not_implemented; } void set_verify_depth(int depth) @@ -121,7 +121,7 @@ class Stream final : public StreamBase<Channel> boost::system::error_code& ec) { BOTAN_UNUSED(depth); - ec = make_error_code(Botan::TLS::error::not_implemented); + ec = Botan::TLS::error::not_implemented; } template <typename verify_mode> @@ -136,7 +136,7 @@ class Stream final : public StreamBase<Channel> boost::system::error_code& ec) { BOTAN_UNUSED(v); - ec = make_error_code(Botan::TLS::error::not_implemented); + ec = Botan::TLS::error::not_implemented; } // @@ -245,7 +245,7 @@ class Stream final : public StreamBase<Channel> { BOTAN_UNUSED(buffers); if(validate_handshake_type(type, ec)) - { ec = make_error_code(Botan::TLS::error::not_implemented); } + { ec = Botan::TLS::error::not_implemented; } } template <typename ConstBufferSequence, typename BufferedHandshakeHandler> diff --git a/src/lib/tls/asio/asio_stream_base.h b/src/lib/tls/asio/asio_stream_base.h index ecda81360..44f36d3d9 100644 --- a/src/lib/tls/asio/asio_stream_base.h +++ b/src/lib/tls/asio/asio_stream_base.h @@ -77,7 +77,7 @@ class StreamBase<Botan::TLS::Client> { if(type != handshake_type::client) { - ec = make_error_code(Botan::TLS::error::invalid_argument); + ec = Botan::TLS::error::invalid_argument; return false; } diff --git a/src/lib/tls/asio/info.txt b/src/lib/tls/asio/info.txt index a78f5c85c..2b303c89e 100644 --- a/src/lib/tls/asio/info.txt +++ b/src/lib/tls/asio/info.txt @@ -1,5 +1,5 @@ <defines> -ASIO -> 20181218 +TLS_ASIO_STREAM -> 20181218 </defines> <header:public> |