src/openssl/src/openssl_stream.cpp
100.0% Lines (39/0/39)
100.0% List of functions (12/0/12)
Functions (12)
Function
Calls
Lines
Blocks
boost::corosio::openssl_stream::make_implementation(boost::capy::any_stream&, boost::corosio::tls_context const&)
:34
2307x
100.0%
62.0%
boost::corosio::openssl_stream::~openssl_stream()
:44
2309x
100.0%
100.0%
boost::corosio::openssl_stream::openssl_stream(boost::corosio::openssl_stream&&)
:49
2x
100.0%
100.0%
boost::corosio::openssl_stream::operator=(boost::corosio::openssl_stream&&)
:59
1x
100.0%
100.0%
boost::corosio::openssl_stream::do_read_some(boost::capy::detail::buffer_array<16ul, false>)
:74
33441x
100.0%
42.0%
boost::corosio::openssl_stream::do_write_some(boost::capy::detail::buffer_array<16ul, true>)
:81
33390x
100.0%
42.0%
boost::corosio::openssl_stream::handshake(boost::corosio::tls_role)
:88
1676x
100.0%
44.0%
boost::corosio::openssl_stream::shutdown()
:94
135x
100.0%
44.0%
boost::corosio::openssl_stream::reset()
:100
60x
100.0%
100.0%
boost::corosio::openssl_stream::set_hostname(std::basic_string_view<char, std::char_traits<char> >)
:106
13x
100.0%
100.0%
boost::corosio::openssl_stream::name() const
:112
1x
100.0%
100.0%
boost::corosio::openssl_stream::alpn_protocol() const
:118
3x
100.0%
100.0%
| Line | TLA | Hits | Source Code |
|---|---|---|---|
| 1 | // | ||
| 2 | // Copyright (c) 2025 Vinnie Falco ([email protected]) | ||
| 3 | // Copyright (c) 2026 Michael Vandeberg | ||
| 4 | // Copyright (c) 2026 Steve Gerbino | ||
| 5 | // | ||
| 6 | // Distributed under the Boost Software License, Version 1.0. (See accompanying | ||
| 7 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | ||
| 8 | // | ||
| 9 | // Official repository: https://github.com/cppalliance/corosio | ||
| 10 | // | ||
| 11 | |||
| 12 | #include <boost/corosio/openssl_stream.hpp> | ||
| 13 | #include <boost/corosio/detail/config.hpp> | ||
| 14 | |||
| 15 | #include "detail/engine.hpp" | ||
| 16 | #include "src/tls/detail/engine_driver.hpp" | ||
| 17 | |||
| 18 | // The driver logic lives once in detail::engine_driver (see its | ||
| 19 | // header for the architecture); this TU only binds it to the OpenSSL | ||
| 20 | // engine and plumbs the public stream surface through. | ||
| 21 | |||
| 22 | namespace boost::corosio { | ||
| 23 | |||
| 24 | // Readable failure if the engine drifts from the driver's surface. | ||
| 25 | static_assert(detail::tls_engine<detail::openssl::engine>); | ||
| 26 | |||
| 27 | struct openssl_stream::implementation | ||
| 28 | : detail::engine_driver<detail::openssl::engine> | ||
| 29 | { | ||
| 30 | using engine_driver::engine_driver; | ||
| 31 | }; | ||
| 32 | |||
| 33 | openssl_stream::implementation* | ||
| 34 | 2307x | openssl_stream::make_implementation( | |
| 35 | capy::any_stream& stream, tls_context const& ctx) | ||
| 36 | { | ||
| 37 | // Session creation is deferred to handshake time (the engine's | ||
| 38 | // prepare hook builds it lazily), so a session setup failure | ||
| 39 | // surfaces through the handshake completion instead of leaving a | ||
| 40 | // null implementation behind. | ||
| 41 | 2307x | return new implementation(stream, ctx); | |
| 42 | } | ||
| 43 | |||
| 44 | 2309x | openssl_stream::~openssl_stream() | |
| 45 | { | ||
| 46 | 2309x | delete impl_; | |
| 47 | 2309x | } | |
| 48 | |||
| 49 | 2x | openssl_stream::openssl_stream(openssl_stream&& other) noexcept | |
| 50 | 2x | : stream_(std::move(other.stream_)) | |
| 51 | 2x | , impl_(other.impl_) | |
| 52 | { | ||
| 53 | 2x | other.impl_ = nullptr; | |
| 54 | 2x | if (impl_) | |
| 55 | 2x | impl_->rebind_stream(stream_); | |
| 56 | 2x | } | |
| 57 | |||
| 58 | openssl_stream& | ||
| 59 | 1x | openssl_stream::operator=(openssl_stream&& other) noexcept | |
| 60 | { | ||
| 61 | 1x | if (this != &other) | |
| 62 | { | ||
| 63 | 1x | delete impl_; | |
| 64 | 1x | stream_ = std::move(other.stream_); | |
| 65 | 1x | impl_ = other.impl_; | |
| 66 | 1x | other.impl_ = nullptr; | |
| 67 | 1x | if (impl_) | |
| 68 | 1x | impl_->rebind_stream(stream_); | |
| 69 | } | ||
| 70 | 1x | return *this; | |
| 71 | } | ||
| 72 | |||
| 73 | capy::io_task<std::size_t> | ||
| 74 | 33441x | openssl_stream::do_read_some( | |
| 75 | capy::detail::mutable_buffer_array<capy::detail::max_iovec_> buffers) | ||
| 76 | { | ||
| 77 | co_return co_await impl_->do_read_some(buffers); | ||
| 78 | 66882x | } | |
| 79 | |||
| 80 | capy::io_task<std::size_t> | ||
| 81 | 33390x | openssl_stream::do_write_some( | |
| 82 | capy::detail::const_buffer_array<capy::detail::max_iovec_> buffers) | ||
| 83 | { | ||
| 84 | co_return co_await impl_->do_write_some(buffers); | ||
| 85 | 66780x | } | |
| 86 | |||
| 87 | capy::io_task<> | ||
| 88 | 1676x | openssl_stream::handshake(tls_role role) | |
| 89 | { | ||
| 90 | co_return co_await impl_->do_handshake(role); | ||
| 91 | 3352x | } | |
| 92 | |||
| 93 | capy::io_task<> | ||
| 94 | 135x | openssl_stream::shutdown() | |
| 95 | { | ||
| 96 | co_return co_await impl_->do_shutdown(); | ||
| 97 | 270x | } | |
| 98 | |||
| 99 | void | ||
| 100 | 60x | openssl_stream::reset() | |
| 101 | { | ||
| 102 | 60x | impl_->reset(); | |
| 103 | 60x | } | |
| 104 | |||
| 105 | void | ||
| 106 | 13x | openssl_stream::set_hostname(std::string_view hostname) | |
| 107 | { | ||
| 108 | 13x | impl_->set_hostname(hostname); | |
| 109 | 13x | } | |
| 110 | |||
| 111 | std::string_view | ||
| 112 | 1x | openssl_stream::name() const noexcept | |
| 113 | { | ||
| 114 | 1x | return "openssl"; | |
| 115 | } | ||
| 116 | |||
| 117 | std::string_view | ||
| 118 | 3x | openssl_stream::alpn_protocol() const noexcept | |
| 119 | { | ||
| 120 | 3x | return impl_->alpn_protocol(); | |
| 121 | } | ||
| 122 | |||
| 123 | } // namespace boost::corosio | ||
| 124 |