diff options
author | René Meusel <[email protected]> | 2019-02-19 15:29:01 +0100 |
---|---|---|
committer | Hannes Rantzsch <[email protected]> | 2019-04-16 10:47:45 +0200 |
commit | e4f0441731088996872fd06e739d521791b33407 (patch) | |
tree | 5e91cfdd077d44ce42c36eaa0ba9f32c22bf9512 /src/lib/tls | |
parent | 96ffc33270ce3487bdb1290612244ad9e84e7889 (diff) |
rename member variables like 'm_***'
Diffstat (limited to 'src/lib/tls')
-rw-r--r-- | src/lib/tls/asio/asio_async_handshake_op.h | 46 | ||||
-rw-r--r-- | src/lib/tls/asio/asio_async_read_op.h | 38 | ||||
-rw-r--r-- | src/lib/tls/asio/asio_async_write_op.h | 22 | ||||
-rw-r--r-- | src/lib/tls/asio/asio_stream.h | 47 | ||||
-rw-r--r-- | src/lib/tls/asio/asio_stream_base.h | 26 | ||||
-rw-r--r-- | src/lib/tls/asio/asio_stream_core.h | 36 |
6 files changed, 108 insertions, 107 deletions
diff --git a/src/lib/tls/asio/asio_async_handshake_op.h b/src/lib/tls/asio/asio_async_handshake_op.h index 5a5a79fbf..6255b4f74 100644 --- a/src/lib/tls/asio/asio_async_handshake_op.h +++ b/src/lib/tls/asio/asio_async_handshake_op.h @@ -15,16 +15,16 @@ struct AsyncHandshakeOperation { AsyncHandshakeOperation(Channel* channel, StreamCore& core, StreamLayer& nextLayer, Handler&& handler) - : channel_(channel), - core_(core), - nextLayer_(nextLayer), - handler_(std::forward<Handler>(handler)) {} + : m_channel(channel), + m_core(core), + m_nextLayer(nextLayer), + m_handler(std::forward<Handler>(handler)) {} AsyncHandshakeOperation(AsyncHandshakeOperation&& right) - : channel_(right.channel_), - core_(right.core_), - nextLayer_(right.nextLayer_), - handler_(std::move(right.handler_)) {} + : m_channel(right.m_channel), + m_core(right.m_core), + m_nextLayer(right.m_nextLayer), + m_handler(std::move(right.m_handler)) {} ~AsyncHandshakeOperation() = default; AsyncHandshakeOperation(AsyncHandshakeOperation const&) = delete; @@ -36,53 +36,53 @@ struct AsyncHandshakeOperation if(bytesTransferred > 0) { auto read_buffer = - boost::asio::buffer(core_.input_buffer_, bytesTransferred); + boost::asio::buffer(m_core.input_buffer, bytesTransferred); try { - channel_->received_data( + m_channel->received_data( static_cast<const uint8_t*>(read_buffer.data()), read_buffer.size()); } catch(...) { ec = convertException(); - handler_(ec); + m_handler(ec); return; } } // send tls packets - if(core_.hasDataToSend()) + if(m_core.hasDataToSend()) { AsyncWriteOperation<AsyncHandshakeOperation<Channel, StreamLayer, Handler>> - op{core_, std::move(*this), 0}; - boost::asio::async_write(nextLayer_, core_.sendBuffer(), + op{m_core, std::move(*this), 0}; + boost::asio::async_write(m_nextLayer, m_core.sendBuffer(), std::move(op)); return; } - if(!channel_->is_active() && !ec) + if(!m_channel->is_active() && !ec) { // we need more tls data from the socket - nextLayer_.async_read_some(core_.input_buffer_, std::move(*this)); + m_nextLayer.async_read_some(m_core.input_buffer, std::move(*this)); return; } if(start) { // don't call the handler directly, similar to io_context.post - nextLayer_.async_read_some( - boost::asio::buffer(core_.input_buffer_, 0), std::move(*this)); + m_nextLayer.async_read_some( + boost::asio::buffer(m_core.input_buffer, 0), std::move(*this)); return; } - handler_(ec); + m_handler(ec); } private: - Channel* channel_; - StreamCore& core_; - StreamLayer& nextLayer_; - Handler handler_; + Channel* m_channel; + StreamCore& m_core; + StreamLayer& m_nextLayer; + Handler m_handler; }; } // namespace TLS diff --git a/src/lib/tls/asio/asio_async_read_op.h b/src/lib/tls/asio/asio_async_read_op.h index 6317fb8c7..6448fc9dd 100644 --- a/src/lib/tls/asio/asio_async_read_op.h +++ b/src/lib/tls/asio/asio_async_read_op.h @@ -15,13 +15,13 @@ struct AsyncReadOperation { AsyncReadOperation(Channel* channel, StreamCore& core, StreamLayer& nextLayer, Handler&& handler, const MutableBufferSequence& buffers) - : channel_(channel), core_(core), nextLayer_(nextLayer), - handler_(std::forward<Handler>(handler)), buffers_(buffers) {} + : m_channel(channel), m_core(core), m_nextLayer(nextLayer), + m_handler(std::forward<Handler>(handler)), m_buffers(buffers) {} AsyncReadOperation(AsyncReadOperation&& right) - : channel_(right.channel_), core_(right.core_), - nextLayer_(right.nextLayer_), handler_(std::move(right.handler_)), - buffers_(right.buffers_) {} + : m_channel(right.m_channel), m_core(right.m_core), + m_nextLayer(right.m_nextLayer), m_handler(std::move(right.m_handler)), + m_buffers(right.m_buffers) {} ~AsyncReadOperation() = default; AsyncReadOperation(AsyncReadOperation const&) = delete; @@ -34,42 +34,42 @@ struct AsyncReadOperation if(bytes_transferred > 0) { auto read_buffer = - boost::asio::buffer(core_.input_buffer_, bytes_transferred); + boost::asio::buffer(m_core.input_buffer, bytes_transferred); try { - channel_->received_data(static_cast<const uint8_t*>(read_buffer.data()), - read_buffer.size()); + m_channel->received_data(static_cast<const uint8_t*>(read_buffer.data()), + read_buffer.size()); } catch(...) { // TODO: don't call handler directly - handler_(convertException(), 0); + m_handler(convertException(), 0); return; } } - if(!core_.hasReceivedData() && !ec) + if(!m_core.hasReceivedData() && !ec) { // we need more tls packets from the socket - nextLayer_.async_read_some(core_.input_buffer_, std::move(*this)); + m_nextLayer.async_read_some(m_core.input_buffer, std::move(*this)); return; } - if(core_.hasReceivedData()) + if(m_core.hasReceivedData()) { - decodedBytes = core_.copyReceivedData(buffers_); + decodedBytes = m_core.copyReceivedData(m_buffers); ec = boost::system::error_code{}; } - handler_(ec, decodedBytes); + m_handler(ec, decodedBytes); } private: - Channel* channel_; - StreamCore& core_; - StreamLayer& nextLayer_; - Handler handler_; - MutableBufferSequence buffers_; + Channel* m_channel; + StreamCore& m_core; + StreamLayer& m_nextLayer; + Handler m_handler; + MutableBufferSequence m_buffers; }; } // namespace TLS diff --git a/src/lib/tls/asio/asio_async_write_op.h b/src/lib/tls/asio/asio_async_write_op.h index b91c0de11..ef3bae88a 100644 --- a/src/lib/tls/asio/asio_async_write_op.h +++ b/src/lib/tls/asio/asio_async_write_op.h @@ -13,14 +13,14 @@ struct AsyncWriteOperation { AsyncWriteOperation(StreamCore& core, Handler&& handler, std::size_t plainBytesTransferred) - : core_(core), - handler_(std::forward<Handler>(handler)), - plainBytesTransferred_(plainBytesTransferred) {} + : m_core(core), + m_handler(std::forward<Handler>(handler)), + m_plainBytesTransferred(plainBytesTransferred) {} AsyncWriteOperation(AsyncWriteOperation&& right) - : core_(right.core_), - handler_(std::move(right.handler_)), - plainBytesTransferred_(right.plainBytesTransferred_) {} + : m_core(right.m_core), + m_handler(std::move(right.m_handler)), + m_plainBytesTransferred(right.m_plainBytesTransferred) {} ~AsyncWriteOperation() = default; AsyncWriteOperation(AsyncWriteOperation const&) = delete; @@ -28,14 +28,14 @@ struct AsyncWriteOperation void operator()(boost::system::error_code ec, std::size_t bytes_transferred = ~std::size_t(0)) { - core_.consumeSendBuffer(bytes_transferred); + m_core.consumeSendBuffer(bytes_transferred); // TODO: make sure returning 0 in error case is correct here--core has already eaten the data - handler_(ec, ec ? 0 : plainBytesTransferred_); + m_handler(ec, ec ? 0 : m_plainBytesTransferred); } - StreamCore& core_; - Handler handler_; - std::size_t plainBytesTransferred_; + StreamCore& m_core; + Handler m_handler; + std::size_t m_plainBytesTransferred; }; } // namespace TLS diff --git a/src/lib/tls/asio/asio_stream.h b/src/lib/tls/asio/asio_stream.h index b21bc1fb5..0e3a00bb5 100644 --- a/src/lib/tls/asio/asio_stream.h +++ b/src/lib/tls/asio/asio_stream.h @@ -29,7 +29,7 @@ namespace TLS { * boost::asio compatible SSL/TLS stream based on TLS::Client or TLS::Server. */ template <class StreamLayer, class Channel> -class Stream : public StreamBase<Channel> +class Stream final : public StreamBase<Channel> { public: using next_layer_type = typename std::remove_reference<StreamLayer>::type; @@ -67,11 +67,11 @@ class Stream : public StreamBase<Channel> template <typename... Args> Stream(StreamLayer&& nextLayer, Args&& ... args) : StreamBase<Channel>(std::forward<Args>(args)...), - nextLayer_(std::forward<StreamLayer>(nextLayer)) {} + m_nextLayer(std::forward<StreamLayer>(nextLayer)) {} Stream(StreamLayer&& nextLayer, boost::asio::ssl::context&) : StreamBase<Channel>(Botan::TLS::Session_Manager_Noop(), Botan::Credentials_Manager()), - nextLayer_(std::forward<StreamLayer>(nextLayer)) + m_nextLayer(std::forward<StreamLayer>(nextLayer)) { // Configuring a TLS stream via asio::ssl::context is not supported. // The corresponding configuration objects for Botan are: @@ -96,15 +96,15 @@ class Stream : public StreamBase<Channel> // -- -- accessor methods // - executor_type get_executor() noexcept { return nextLayer_.get_executor(); } + executor_type get_executor() noexcept { return m_nextLayer.get_executor(); } - const next_layer_type& next_layer() const { return nextLayer_; } - next_layer_type& next_layer() { return nextLayer_; } + const next_layer_type& next_layer() const { return m_nextLayer; } + next_layer_type& next_layer() { return m_nextLayer; } - lowest_layer_type& lowest_layer() { return nextLayer_.lowest_layer(); } - const lowest_layer_type& lowest_layer() const { return nextLayer_.lowest_layer(); } + lowest_layer_type& lowest_layer() { return m_nextLayer.lowest_layer(); } + const lowest_layer_type& lowest_layer() const { return m_nextLayer.lowest_layer(); } - native_handle_type native_handle() { return &this->channel_; } + native_handle_type native_handle() { return &this->m_channel; } // // -- -- configuration and callback setters @@ -184,8 +184,8 @@ class Stream : public StreamBase<Channel> } auto read_buffer = boost::asio::buffer( - this->core_.input_buffer_, - nextLayer_.read_some(this->core_.input_buffer_, ec)); + this->m_core.input_buffer, + m_nextLayer.read_some(this->m_core.input_buffer, ec)); if(ec) { return; @@ -300,14 +300,14 @@ class Stream : public StreamBase<Channel> std::size_t read_some(const MutableBufferSequence& buffers, boost::system::error_code& ec) { - if(this->core_.hasReceivedData()) + if(this->m_core.hasReceivedData()) { - return this->core_.copyReceivedData(buffers); + return this->m_core.copyReceivedData(buffers); } auto read_buffer = boost::asio::buffer( - this->core_.input_buffer_, - nextLayer_.read_some(this->core_.input_buffer_, ec)); + this->m_core.input_buffer, + m_nextLayer.read_some(this->m_core.input_buffer, ec)); if(ec) { return 0; @@ -324,7 +324,7 @@ class Stream : public StreamBase<Channel> return 0; } - return this->core_.copyReceivedData(buffers); + return this->m_core.copyReceivedData(buffers); } template <typename MutableBufferSequence> @@ -400,7 +400,7 @@ class Stream : public StreamBase<Channel> auto op = create_async_write_op(std::move(init.completion_handler), buffer.size()); - boost::asio::async_write(nextLayer_, this->core_.sendBuffer(), + boost::asio::async_write(m_nextLayer, this->m_core.sendBuffer(), std::move(op)); return init.result.get(); } @@ -425,9 +425,9 @@ class Stream : public StreamBase<Channel> size_t writePendingTlsData(boost::system::error_code& ec) { auto writtenBytes = - boost::asio::write(nextLayer_, this->core_.sendBuffer(), ec); + boost::asio::write(m_nextLayer, this->m_core.sendBuffer(), ec); - this->core_.consumeSendBuffer(writtenBytes); + this->m_core.consumeSendBuffer(writtenBytes); return writtenBytes; } @@ -436,7 +436,7 @@ class Stream : public StreamBase<Channel> create_async_handshake_op(Handler&& handler) { return Botan::TLS::AsyncHandshakeOperation<Channel, StreamLayer, Handler>( - native_handle(), this->core_, nextLayer_, std::forward<Handler>(handler)); + native_handle(), this->m_core, m_nextLayer, std::forward<Handler>(handler)); } template <typename Handler, typename MutableBufferSequence> @@ -447,7 +447,7 @@ class Stream : public StreamBase<Channel> { return Botan::TLS::AsyncReadOperation<Channel, StreamLayer, Handler, MutableBufferSequence>( - native_handle(), this->core_, nextLayer_, std::forward<Handler>(handler), + native_handle(), this->m_core, m_nextLayer, std::forward<Handler>(handler), buffers); } @@ -456,10 +456,11 @@ class Stream : public StreamBase<Channel> create_async_write_op(Handler&& handler, std::size_t plainBytesTransferred) { return Botan::TLS::AsyncWriteOperation<Handler>( - this->core_, std::forward<Handler>(handler), plainBytesTransferred); + this->m_core, std::forward<Handler>(handler), plainBytesTransferred); } - StreamLayer nextLayer_; + protected: + StreamLayer m_nextLayer; }; } // TLS diff --git a/src/lib/tls/asio/asio_stream_base.h b/src/lib/tls/asio/asio_stream_base.h index d475bb667..c6cc2aaf1 100644 --- a/src/lib/tls/asio/asio_stream_base.h +++ b/src/lib/tls/asio/asio_stream_base.h @@ -23,12 +23,12 @@ class StreamBase<Botan::TLS::Client> const Botan::TLS::Policy& policy = Botan::TLS::Strict_Policy{}, const Botan::TLS::Server_Information& serverInfo = Botan::TLS::Server_Information{}) - : channel_(core_, - sessionManager, - credentialsManager, - policy, - rng_, - serverInfo) + : m_channel(m_core, + sessionManager, + credentialsManager, + policy, + m_rng, + serverInfo) { } @@ -36,9 +36,9 @@ class StreamBase<Botan::TLS::Client> StreamBase& operator=(const StreamBase&) = delete; protected: - Botan::TLS::StreamCore core_; - Botan::AutoSeeded_RNG rng_; - Botan::TLS::Client channel_; + Botan::TLS::StreamCore m_core; + Botan::AutoSeeded_RNG m_rng; + Botan::TLS::Client m_channel; }; template <> @@ -48,7 +48,7 @@ class StreamBase<Botan::TLS::Server> StreamBase(Botan::TLS::Session_Manager& sessionManager, Botan::Credentials_Manager& credentialsManager, const Botan::TLS::Policy& policy = Botan::TLS::Strict_Policy{}) - : channel_(core_, sessionManager, credentialsManager, policy, rng_) + : m_channel(m_core, sessionManager, credentialsManager, policy, m_rng) { } @@ -56,9 +56,9 @@ class StreamBase<Botan::TLS::Server> StreamBase& operator=(const StreamBase&) = delete; protected: - Botan::TLS::StreamCore core_; - Botan::AutoSeeded_RNG rng_; - Botan::TLS::Server channel_; + Botan::TLS::StreamCore m_core; + Botan::AutoSeeded_RNG m_rng; + Botan::TLS::Server m_channel; }; } // namespace TLS diff --git a/src/lib/tls/asio/asio_stream_core.h b/src/lib/tls/asio/asio_stream_core.h index c2e1d0d0c..a33aeaef8 100644 --- a/src/lib/tls/asio/asio_stream_core.h +++ b/src/lib/tls/asio/asio_stream_core.h @@ -25,26 +25,26 @@ struct StreamCore : public Botan::TLS::Callbacks }; StreamCore() - : input_buffer_space_(17 * 1024, '\0'), // enough for a TLS Datagram - input_buffer_(boost::asio::buffer(input_buffer_space_)) {} + : m_input_buffer_space(17 * 1024, '\0'), // enough for a TLS Datagram + input_buffer(boost::asio::buffer(m_input_buffer_space)) {} virtual ~StreamCore() = default; void tls_emit_data(const uint8_t data[], size_t size) override { - auto buffer = send_buffer_.dynamicBuffer.prepare(size); + auto buffer = m_send_buffer.dynamicBuffer.prepare(size); auto copySize = boost::asio::buffer_copy(buffer, boost::asio::buffer(data, size)); - send_buffer_.dynamicBuffer.commit(copySize); + m_send_buffer.dynamicBuffer.commit(copySize); } void tls_record_received(uint64_t, const uint8_t data[], size_t size) override { - auto buffer = receive_buffer_.dynamicBuffer.prepare(size); + auto buffer = m_receive_buffer.dynamicBuffer.prepare(size); auto copySize = boost::asio::buffer_copy(buffer, boost::asio::buffer(data, size)); - receive_buffer_.dynamicBuffer.commit(copySize); + m_receive_buffer.dynamicBuffer.commit(copySize); } void tls_alert(Botan::TLS::Alert alert) override @@ -68,39 +68,39 @@ struct StreamCore : public Botan::TLS::Callbacks bool hasReceivedData() const { - return receive_buffer_.dynamicBuffer.size() > 0; + return m_receive_buffer.dynamicBuffer.size() > 0; } template <typename MutableBufferSequence> std::size_t copyReceivedData(MutableBufferSequence buffers) { const auto copiedBytes = - boost::asio::buffer_copy(buffers, receive_buffer_.dynamicBuffer.data()); - receive_buffer_.dynamicBuffer.consume(copiedBytes); + boost::asio::buffer_copy(buffers, m_receive_buffer.dynamicBuffer.data()); + m_receive_buffer.dynamicBuffer.consume(copiedBytes); return copiedBytes; } - bool hasDataToSend() const { return send_buffer_.dynamicBuffer.size() > 0; } + bool hasDataToSend() const { return m_send_buffer.dynamicBuffer.size() > 0; } boost::asio::const_buffer sendBuffer() const { - return send_buffer_.dynamicBuffer.data(); + return m_send_buffer.dynamicBuffer.data(); } void consumeSendBuffer(std::size_t bytesConsumed) { - send_buffer_.dynamicBuffer.consume(bytesConsumed); + m_send_buffer.dynamicBuffer.consume(bytesConsumed); } + private: // Buffer space used to read input intended for the engine. - std::vector<uint8_t> input_buffer_space_; + std::vector<uint8_t> m_input_buffer_space; + Buffer m_receive_buffer; + Buffer m_send_buffer; + public: // A buffer that may be used to read input intended for the engine. - const boost::asio::mutable_buffer input_buffer_; - - private: - Buffer receive_buffer_; - Buffer send_buffer_; + const boost::asio::mutable_buffer input_buffer; }; } // namespace TLS |