aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/tls/asio
diff options
context:
space:
mode:
authorHannes Rantzsch <[email protected]>2019-04-23 10:56:36 +0200
committerHannes Rantzsch <[email protected]>2019-04-23 10:56:36 +0200
commit8729296fd9de82125a58ee59b0d3d31863798e5f (patch)
tree88d6ac784f98d28c0294154d492a7b4e59bee92f /src/lib/tls/asio
parent7cd6f06f1678f51ba21a670bc1a5c76356b223c5 (diff)
use existing TLS::Connection_Side instead of handshake_type
Diffstat (limited to 'src/lib/tls/asio')
-rw-r--r--src/lib/tls/asio/asio_stream.h30
-rw-r--r--src/lib/tls/asio/asio_stream_base.h25
2 files changed, 24 insertions, 31 deletions
diff --git a/src/lib/tls/asio/asio_stream.h b/src/lib/tls/asio/asio_stream.h
index c3666a085..e19cbf0e7 100644
--- a/src/lib/tls/asio/asio_stream.h
+++ b/src/lib/tls/asio/asio_stream.h
@@ -47,7 +47,7 @@ class Stream : public StreamBase<Channel>
using executor_type = typename next_layer_type::executor_type;
using native_handle_type = typename std::add_pointer<Channel>::type;
- using StreamBase<Channel>::validate_handshake_type;
+ using StreamBase<Channel>::validate_connection_side;
public:
template <typename... Args>
@@ -236,11 +236,11 @@ class Stream : public StreamBase<Channel>
* The function call will block until handshaking is complete or an error occurs.
* @param type The type of handshaking to be performed, i.e. as a client or as a server.
* @throws boost::system::system_error if error occured
- * @throws Invalid_Argument if handshake_type could not be validated
+ * @throws Invalid_Argument if Connection_Side could not be validated
*/
- void handshake(handshake_type type)
+ void handshake(Connection_Side side)
{
- validate_handshake_type(type);
+ validate_connection_side(side);
handshake();
}
@@ -250,9 +250,9 @@ class Stream : public StreamBase<Channel>
* @param type The type of handshaking to be performed, i.e. as a client or as a server.
* @param ec Set to indicate what error occurred, if any.
*/
- void handshake(handshake_type type, boost::system::error_code& ec)
+ void handshake(Connection_Side side, boost::system::error_code& ec)
{
- if(validate_handshake_type(type, ec))
+ if(validate_connection_side(side, ec))
{ handshake(ec); }
}
@@ -262,14 +262,14 @@ class Stream : public StreamBase<Channel>
* @param type The type of handshaking to be performed, i.e. as a client or as a server.
* @param handler The handler to be called when the handshake operation completes.
* The equivalent function signature of the handler must be: void(boost::system::error_code)
- * @throws Invalid_Argument if handshake_type could not be validated
+ * @throws Invalid_Argument if Connection_Side could not be validated
*/
template <typename HandshakeHandler>
BOOST_ASIO_INITFN_RESULT_TYPE(HandshakeHandler,
void(boost::system::error_code))
- async_handshake(handshake_type type, HandshakeHandler&& handler)
+ async_handshake(Connection_Side side, HandshakeHandler&& handler)
{
- validate_handshake_type(type);
+ validate_connection_side(side);
return async_handshake(std::forward<HandshakeHandler>(handler));
}
@@ -277,10 +277,10 @@ class Stream : public StreamBase<Channel>
* @throws Not_Implemented
*/
template<typename ConstBufferSequence>
- void handshake(handshake_type type, const ConstBufferSequence& buffers)
+ void handshake(Connection_Side side, const ConstBufferSequence& buffers)
{
BOTAN_UNUSED(buffers);
- validate_handshake_type(type);
+ validate_connection_side(side);
throw Not_Implemented("buffered handshake is not implemented");
}
@@ -289,12 +289,12 @@ class Stream : public StreamBase<Channel>
* @param ec Will be set to `Botan::TLS::error::not_implemented`
*/
template<typename ConstBufferSequence>
- void handshake(handshake_type type,
+ void handshake(Connection_Side side,
const ConstBufferSequence& buffers,
boost::system::error_code& ec)
{
BOTAN_UNUSED(buffers);
- if(validate_handshake_type(type, ec))
+ if(validate_connection_side(side, ec))
{ ec = Botan::TLS::error::not_implemented; }
}
@@ -304,12 +304,12 @@ class Stream : public StreamBase<Channel>
template <typename ConstBufferSequence, typename BufferedHandshakeHandler>
BOOST_ASIO_INITFN_RESULT_TYPE(BufferedHandshakeHandler,
void(boost::system::error_code, std::size_t))
- async_handshake(handshake_type type, const ConstBufferSequence& buffers,
+ async_handshake(Connection_Side side, const ConstBufferSequence& buffers,
BufferedHandshakeHandler&& handler)
{
BOTAN_UNUSED(buffers, handler);
BOOST_ASIO_HANDSHAKE_HANDLER_CHECK(BufferedHandshakeHandler, handler) type_check;
- validate_handshake_type(type);
+ validate_connection_side(side);
throw Not_Implemented("buffered async handshake is not implemented");
}
diff --git a/src/lib/tls/asio/asio_stream_base.h b/src/lib/tls/asio/asio_stream_base.h
index 169d035a3..f1c43254e 100644
--- a/src/lib/tls/asio/asio_stream_base.h
+++ b/src/lib/tls/asio/asio_stream_base.h
@@ -14,21 +14,16 @@
#include <boost/version.hpp>
#if BOOST_VERSION >= 106600
-#include <botan/tls_client.h>
#include <botan/asio_context.h>
#include <botan/asio_error.h>
#include <botan/internal/asio_stream_core.h>
+#include <botan/tls_client.h>
+#include <botan/tls_magic.h>
namespace Botan {
namespace TLS {
-enum handshake_type
- {
- client,
- server
- };
-
/** Base class for all Botan::TLS::Stream implementations.
*
* This template must be specialized for all the Botan::TLS::Channel to be used.
@@ -59,22 +54,20 @@ class StreamBase<Botan::TLS::Client>
StreamBase(const StreamBase&) = delete;
StreamBase& operator=(const StreamBase&) = delete;
- using handshake_type = Botan::TLS::handshake_type;
-
protected:
- //! \brief validate the OpenSSL compatibility enum `handshake_type`
- void validate_handshake_type(handshake_type type)
+ //! \brief validate the connection side (OpenSSL compatibility)
+ void validate_connection_side(Connection_Side side)
{
- if(type != handshake_type::client)
+ if(side != CLIENT)
{
- throw Invalid_Argument("wrong handshake_type");
+ throw Invalid_Argument("wrong connection_side");
}
}
- //! \brief validate the OpenSSL compatibility enum `handshake_type`
- bool validate_handshake_type(handshake_type type, boost::system::error_code& ec)
+ //! \brief validate the connection side (OpenSSL compatibility)
+ bool validate_connection_side(Connection_Side side, boost::system::error_code& ec)
{
- if(type != handshake_type::client)
+ if(side != CLIENT)
{
ec = Botan::TLS::error::invalid_argument;
return false;