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
3281x
100.0%
62.0%
boost::corosio::openssl_stream::~openssl_stream()
:43
3283x
100.0%
100.0%
boost::corosio::openssl_stream::openssl_stream(boost::corosio::openssl_stream&&)
:48
2x
100.0%
100.0%
boost::corosio::openssl_stream::operator=(boost::corosio::openssl_stream&&)
:58
1x
100.0%
100.0%
boost::corosio::openssl_stream::do_read_some(boost::capy::detail::buffer_array<16ul, false>)
:73
67195x
100.0%
42.0%
boost::corosio::openssl_stream::do_write_some(boost::capy::detail::buffer_array<16ul, true>)
:80
67293x
100.0%
42.0%
boost::corosio::openssl_stream::handshake(boost::corosio::tls_role)
:87
2324x
100.0%
44.0%
boost::corosio::openssl_stream::shutdown()
:93
133x
100.0%
44.0%
boost::corosio::openssl_stream::reset()
:99
60x
100.0%
100.0%
boost::corosio::openssl_stream::set_hostname(std::basic_string_view<char, std::char_traits<char> >)
:105
13x
100.0%
100.0%
boost::corosio::openssl_stream::name() const
:111
1x
100.0%
100.0%
boost::corosio::openssl_stream::alpn_protocol() const
:117
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 | 3281x | openssl_stream::make_implementation(capy::any_stream& stream, tls_context const& ctx) | |
| 35 | { | ||
| 36 | // Session creation is deferred to handshake time (the engine's | ||
| 37 | // prepare hook builds it lazily), so a session setup failure | ||
| 38 | // surfaces through the handshake completion instead of leaving a | ||
| 39 | // null implementation behind. | ||
| 40 | 3281x | return new implementation(stream, ctx); | |
| 41 | } | ||
| 42 | |||
| 43 | 3283x | openssl_stream::~openssl_stream() | |
| 44 | { | ||
| 45 | 3283x | delete impl_; | |
| 46 | 3283x | } | |
| 47 | |||
| 48 | 2x | openssl_stream::openssl_stream(openssl_stream&& other) noexcept | |
| 49 | 2x | : stream_(std::move(other.stream_)) | |
| 50 | 2x | , impl_(other.impl_) | |
| 51 | { | ||
| 52 | 2x | other.impl_ = nullptr; | |
| 53 | 2x | if (impl_) | |
| 54 | 2x | impl_->rebind_stream(stream_); | |
| 55 | 2x | } | |
| 56 | |||
| 57 | openssl_stream& | ||
| 58 | 1x | openssl_stream::operator=(openssl_stream&& other) noexcept | |
| 59 | { | ||
| 60 | 1x | if (this != &other) | |
| 61 | { | ||
| 62 | 1x | delete impl_; | |
| 63 | 1x | stream_ = std::move(other.stream_); | |
| 64 | 1x | impl_ = other.impl_; | |
| 65 | 1x | other.impl_ = nullptr; | |
| 66 | 1x | if (impl_) | |
| 67 | 1x | impl_->rebind_stream(stream_); | |
| 68 | } | ||
| 69 | 1x | return *this; | |
| 70 | } | ||
| 71 | |||
| 72 | capy::io_task<std::size_t> | ||
| 73 | 67195x | openssl_stream::do_read_some( | |
| 74 | capy::detail::mutable_buffer_array<capy::detail::max_iovec_> buffers) | ||
| 75 | { | ||
| 76 | co_return co_await impl_->do_read_some(buffers); | ||
| 77 | 134390x | } | |
| 78 | |||
| 79 | capy::io_task<std::size_t> | ||
| 80 | 67293x | openssl_stream::do_write_some( | |
| 81 | capy::detail::const_buffer_array<capy::detail::max_iovec_> buffers) | ||
| 82 | { | ||
| 83 | co_return co_await impl_->do_write_some(buffers); | ||
| 84 | 134586x | } | |
| 85 | |||
| 86 | capy::io_task<> | ||
| 87 | 2324x | openssl_stream::handshake(tls_role role) | |
| 88 | { | ||
| 89 | co_return co_await impl_->do_handshake(role); | ||
| 90 | 4648x | } | |
| 91 | |||
| 92 | capy::io_task<> | ||
| 93 | 133x | openssl_stream::shutdown() | |
| 94 | { | ||
| 95 | co_return co_await impl_->do_shutdown(); | ||
| 96 | 266x | } | |
| 97 | |||
| 98 | void | ||
| 99 | 60x | openssl_stream::reset() | |
| 100 | { | ||
| 101 | 60x | impl_->reset(); | |
| 102 | 60x | } | |
| 103 | |||
| 104 | void | ||
| 105 | 13x | openssl_stream::set_hostname(std::string_view hostname) | |
| 106 | { | ||
| 107 | 13x | impl_->set_hostname(hostname); | |
| 108 | 13x | } | |
| 109 | |||
| 110 | std::string_view | ||
| 111 | 1x | openssl_stream::name() const noexcept | |
| 112 | { | ||
| 113 | 1x | return "openssl"; | |
| 114 | } | ||
| 115 | |||
| 116 | std::string_view | ||
| 117 | 3x | openssl_stream::alpn_protocol() const noexcept | |
| 118 | { | ||
| 119 | 3x | return impl_->alpn_protocol(); | |
| 120 | } | ||
| 121 | |||
| 122 | } // namespace boost::corosio | ||
| 123 |