src/openssl/src/openssl_stream.cpp
73.9% Lines (342/463)
89.7% List of functions (26/29)
43.2% Branches (469/1086)
Functions (29)
Function
Calls
Lines
Branches
Blocks
boost::corosio::(anonymous namespace)::tls_method_compat()
:65
1172x
100.0%
50.0%
66.0%
boost::corosio::(anonymous namespace)::apply_hostname_verification(ssl_st*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&)
:75
1197x
100.0%
100.0%
100.0%
boost::corosio::(anonymous namespace)::normalize_openssl_shutdown_read_error(std::__1::error_code)
:91
8x
50.0%
25.0%
45.0%
boost::corosio::detail::password_callback(char*, int, int, void*)
:116
0
0.0%
0.0%
0.0%
boost::corosio::detail::sni_callback(ssl_st*, int*, void*)
:138
2x
92.3%
62.5%
88.0%
boost::corosio::detail::openssl_native_context::openssl_native_context(boost::corosio::detail::tls_context_data const&)
:163
2344x
93.7%
57.4%
100.0%
boost::corosio::detail::openssl_native_context::~openssl_native_context()
:295
3516x
100.0%
50.0%
100.0%
boost::corosio::detail::get_openssl_context(boost::corosio::detail::tls_context_data const&)
:303
1177x
100.0%
–
100.0%
boost::corosio::detail::get_openssl_context(boost::corosio::detail::tls_context_data const&)::'lambda'()::operator()() const
:306
1172x
100.0%
50.0%
50.0%
boost::corosio::openssl_stream::impl::impl(boost::capy::any_stream&, boost::corosio::tls_context)
:325
2354x
100.0%
50.0%
100.0%
boost::corosio::openssl_stream::impl::~impl()
:331
2354x
100.0%
50.0%
100.0%
boost::corosio::openssl_stream::impl::reset()
:339
20x
80.0%
50.0%
71.0%
boost::corosio::openssl_stream::impl::flush_output()
:359
101389x
88.5%
50.0%
53.0%
boost::corosio::openssl_stream::impl::read_input()
:390
13541x
86.7%
44.6%
48.0%
boost::corosio::openssl_stream::impl::do_read_some(boost::capy::detail::buffer_array<16ul, false>)
:411
87271x
62.1%
37.3%
44.0%
boost::corosio::openssl_stream::impl::do_write_some(boost::capy::detail::buffer_array<16ul, true>)
:497
87262x
47.6%
19.7%
26.0%
boost::corosio::openssl_stream::impl::do_handshake(int)
:558
885x
86.5%
46.9%
51.0%
boost::corosio::openssl_stream::impl::do_shutdown()
:611
36x
68.2%
44.6%
47.0%
boost::corosio::openssl_stream::impl::init_ssl()
:679
1177x
52.2%
50.0%
62.0%
boost::corosio::openssl_stream::make_impl(boost::capy::any_stream&, boost::corosio::tls_context const&)
:717
1177x
75.0%
25.0%
36.0%
boost::corosio::openssl_stream::~openssl_stream()
:731
2354x
100.0%
50.0%
100.0%
boost::corosio::openssl_stream::openssl_stream(boost::corosio::openssl_stream&&)
:736
0
0.0%
–
0.0%
boost::corosio::openssl_stream::operator=(boost::corosio::openssl_stream&&)
:744
0
0.0%
0.0%
0.0%
boost::corosio::openssl_stream::do_read_some(boost::capy::detail::buffer_array<16ul, false>)
:757
87271x
100.0%
50.0%
48.0%
boost::corosio::openssl_stream::do_write_some(boost::capy::detail::buffer_array<16ul, true>)
:764
87262x
100.0%
50.0%
48.0%
boost::corosio::openssl_stream::handshake(boost::corosio::tls_stream::handshake_type)
:771
885x
100.0%
50.0%
48.0%
boost::corosio::openssl_stream::shutdown()
:777
36x
100.0%
50.0%
48.0%
boost::corosio::openssl_stream::reset()
:783
16x
100.0%
–
100.0%
boost::corosio::openssl_stream::name() const
:789
1x
100.0%
50.0%
66.0%
| Line | Branch | TLA | Hits | Source Code |
|---|---|---|---|---|
| 1 | // | |||
| 2 | // Copyright (c) 2025 Vinnie Falco ([email protected]) | |||
| 3 | // | |||
| 4 | // Distributed under the Boost Software License, Version 1.0. (See accompanying | |||
| 5 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | |||
| 6 | // | |||
| 7 | // Official repository: https://github.com/cppalliance/corosio | |||
| 8 | // | |||
| 9 | ||||
| 10 | #include <boost/corosio/openssl_stream.hpp> | |||
| 11 | #include <boost/corosio/detail/config.hpp> | |||
| 12 | #include <boost/capy/detail/buffer_array.hpp> | |||
| 13 | #include <boost/capy/ex/async_mutex.hpp> | |||
| 14 | #include <boost/capy/error.hpp> | |||
| 15 | #include <boost/capy/write.hpp> | |||
| 16 | ||||
| 17 | // Internal context implementation | |||
| 18 | #include "src/tls/detail/context_impl.hpp" | |||
| 19 | ||||
| 20 | #include <openssl/ssl.h> | |||
| 21 | #include <openssl/err.h> | |||
| 22 | #include <openssl/bio.h> | |||
| 23 | #include <openssl/x509.h> | |||
| 24 | ||||
| 25 | #include <algorithm> | |||
| 26 | #include <array> | |||
| 27 | #include <cstring> | |||
| 28 | #include <vector> | |||
| 29 | ||||
| 30 | /* | |||
| 31 | openssl_stream Architecture | |||
| 32 | =========================== | |||
| 33 | ||||
| 34 | TLS layer wrapping an underlying stream (via any_stream). Supports one | |||
| 35 | concurrent read_some and one concurrent write_some (like Asio's ssl::stream). | |||
| 36 | ||||
| 37 | Data Flow (using BIO pairs) | |||
| 38 | --------------------------- | |||
| 39 | App -> SSL_write -> int_bio_ -> BIO_read(ext_bio_) -> out_buf_ -> s_.write_some -> Network | |||
| 40 | App <- SSL_read <- int_bio_ <- BIO_write(ext_bio_) <- in_buf_ <- s_.read_some <- Network | |||
| 41 | ||||
| 42 | WANT_READ / WANT_WRITE Pattern | |||
| 43 | ------------------------------ | |||
| 44 | OpenSSL's SSL_read/SSL_write return SSL_ERROR_WANT_READ or SSL_ERROR_WANT_WRITE | |||
| 45 | when they need I/O. Our coroutine handles this by: | |||
| 46 | ||||
| 47 | 1. Call SSL_read or SSL_write | |||
| 48 | 2. Check for pending output in ext_bio_ via BIO_ctrl_pending | |||
| 49 | 3. If output pending: write to network via s_.write_some | |||
| 50 | 4. If SSL_ERROR_WANT_READ: read from network into ext_bio_ via s_.read_some + BIO_write | |||
| 51 | 5. Loop back to step 1 | |||
| 52 | ||||
| 53 | Renegotiation causes cross-direction I/O: SSL_read may need to write | |||
| 54 | handshake data, SSL_write may need to read. Each operation handles | |||
| 55 | whatever I/O direction OpenSSL requests. | |||
| 56 | */ | |||
| 57 | ||||
| 58 | namespace boost::corosio { | |||
| 59 | ||||
| 60 | namespace { | |||
| 61 | ||||
| 62 | constexpr std::size_t default_buffer_size = 16384; | |||
| 63 | ||||
| 64 | inline SSL_METHOD const* | |||
| 65 | 1172x | tls_method_compat() noexcept | ||
| 66 | { | |||
| 67 | #if OPENSSL_VERSION_NUMBER >= 0x10100000L | |||
| 68 |
1/2✓ Branch 0 taken 1172 times.
✗ Branch 1 not taken.
|
1172x | return TLS_method(); | |
| 69 | #else | |||
| 70 | return SSLv23_method(); | |||
| 71 | #endif | |||
| 72 | } | |||
| 73 | ||||
| 74 | inline void | |||
| 75 | 1197x | apply_hostname_verification(SSL* ssl, std::string const& hostname) | ||
| 76 | { | |||
| 77 |
2/2✓ Branch 0 taken 1193 times.
✓ Branch 1 taken 4 times.
|
1197x | if (hostname.empty()) | |
| 78 | 1193x | return; | ||
| 79 | ||||
| 80 | 4x | SSL_set_tlsext_host_name(ssl, hostname.c_str()); | ||
| 81 | ||||
| 82 | #if OPENSSL_VERSION_NUMBER >= 0x10100000L | |||
| 83 | 4x | SSL_set1_host(ssl, hostname.c_str()); | ||
| 84 | #else | |||
| 85 | if (auto* param = SSL_get0_param(ssl)) | |||
| 86 | X509_VERIFY_PARAM_set1_host(param, hostname.c_str(), 0); | |||
| 87 | #endif | |||
| 88 | 1197x | } | ||
| 89 | ||||
| 90 | inline std::error_code | |||
| 91 | 8x | normalize_openssl_shutdown_read_error(std::error_code ec) noexcept | ||
| 92 | { | |||
| 93 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
|
8x | if (!ec) | |
| 94 | ✗ | return ec; | ||
| 95 | ||||
| 96 |
2/4✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
|
8x | if (ec == make_error_code(capy::error::eof) || | |
| 97 | ✗ | ec == make_error_code(capy::error::canceled) || | ||
| 98 | ✗ | ec == std::errc::connection_reset || | ||
| 99 | ✗ | ec == std::errc::connection_aborted || ec == std::errc::broken_pipe) | ||
| 100 | 8x | return make_error_code(capy::error::stream_truncated); | ||
| 101 | ||||
| 102 | ✗ | return ec; | ||
| 103 | 8x | } | ||
| 104 | ||||
| 105 | } // namespace | |||
| 106 | ||||
| 107 | // | |||
| 108 | // Native context caching | |||
| 109 | // | |||
| 110 | ||||
| 111 | namespace detail { | |||
| 112 | ||||
| 113 | static int sni_ctx_data_index = -1; | |||
| 114 | ||||
| 115 | static int | |||
| 116 | ✗ | password_callback(char* buf, int size, int rwflag, void* userdata) | ||
| 117 | { | |||
| 118 | ✗ | auto* cd = static_cast<tls_context_data const*>(userdata); | ||
| 119 | ✗ | if (!cd || !cd->password_callback) | ||
| 120 | ✗ | return 0; | ||
| 121 | ||||
| 122 | ✗ | tls_password_purpose purpose = (rwflag == 0) | ||
| 123 | ? tls_password_purpose::for_reading | |||
| 124 | : tls_password_purpose::for_writing; | |||
| 125 | ||||
| 126 | std::string password = | |||
| 127 | ✗ | cd->password_callback(static_cast<std::size_t>(size), purpose); | ||
| 128 | ||||
| 129 | ✗ | int len = static_cast<int>(password.size()); | ||
| 130 | ✗ | if (len > size) | ||
| 131 | ✗ | len = size; | ||
| 132 | ||||
| 133 | ✗ | std::memcpy(buf, password.data(), static_cast<std::size_t>(len)); | ||
| 134 | ✗ | return len; | ||
| 135 | ✗ | } | ||
| 136 | ||||
| 137 | static int | |||
| 138 | 2x | sni_callback(SSL* ssl, int* /* alert */, void* /* arg */) | ||
| 139 | { | |||
| 140 | 2x | char const* servername = SSL_get_servername(ssl, TLSEXT_NAMETYPE_host_name); | ||
| 141 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
2x | if (!servername) | |
| 142 | ✗ | return SSL_TLSEXT_ERR_NOACK; | ||
| 143 | ||||
| 144 | 2x | SSL_CTX* ctx = SSL_get_SSL_CTX(ssl); | ||
| 145 | 2x | auto* cd = static_cast<tls_context_data const*>( | ||
| 146 | 2x | SSL_CTX_get_ex_data(ctx, sni_ctx_data_index)); | ||
| 147 | ||||
| 148 |
2/4✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
|
2x | if (cd && cd->servername_callback) | |
| 149 | { | |||
| 150 |
2/2✓ Branch 0 taken 1 time.
✓ Branch 1 taken 1 time.
|
2x | if (!cd->servername_callback(servername)) | |
| 151 | 1x | return SSL_TLSEXT_ERR_ALERT_FATAL; | ||
| 152 | 1x | } | ||
| 153 | ||||
| 154 | 1x | return SSL_TLSEXT_ERR_OK; | ||
| 155 | 2x | } | ||
| 156 | ||||
| 157 | class openssl_native_context : public native_context_base | |||
| 158 | { | |||
| 159 | public: | |||
| 160 | SSL_CTX* ctx_; | |||
| 161 | tls_context_data const* cd_; | |||
| 162 | ||||
| 163 | 2344x | explicit openssl_native_context(tls_context_data const& cd) | ||
| 164 | 1172x | : ctx_(nullptr) | ||
| 165 | 1172x | , cd_(&cd) | ||
| 166 | 2344x | { | ||
| 167 |
1/2✓ Branch 0 taken 1172 times.
✗ Branch 1 not taken.
|
1172x | ctx_ = SSL_CTX_new(tls_method_compat()); | |
| 168 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1172 times.
|
1172x | if (!ctx_) | |
| 169 | ✗ | return; | ||
| 170 | ||||
| 171 |
2/2✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1168 times.
|
1172x | if (sni_ctx_data_index < 0) | |
| 172 | 4x | sni_ctx_data_index = | ||
| 173 |
1/2✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
|
4x | SSL_CTX_get_ex_new_index(0, nullptr, nullptr, nullptr, nullptr); | |
| 174 | ||||
| 175 |
1/2✓ Branch 0 taken 1172 times.
✗ Branch 1 not taken.
|
1172x | SSL_CTX_set_ex_data( | |
| 176 | 1172x | ctx_, sni_ctx_data_index, const_cast<tls_context_data*>(&cd)); | ||
| 177 | ||||
| 178 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1170 times.
|
1172x | if (cd.servername_callback) | |
| 179 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
2x | SSL_CTX_set_tlsext_servername_callback(ctx_, sni_callback); | |
| 180 | ||||
| 181 |
1/2✓ Branch 0 taken 1172 times.
✗ Branch 1 not taken.
|
1172x | SSL_CTX_set_mode(ctx_, SSL_MODE_ENABLE_PARTIAL_WRITE); | |
| 182 |
1/2✓ Branch 0 taken 1172 times.
✗ Branch 1 not taken.
|
1172x | SSL_CTX_set_mode(ctx_, SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER); | |
| 183 | #if defined(SSL_MODE_RELEASE_BUFFERS) | |||
| 184 |
1/2✓ Branch 0 taken 1172 times.
✗ Branch 1 not taken.
|
1172x | SSL_CTX_set_mode(ctx_, SSL_MODE_RELEASE_BUFFERS); | |
| 185 | #endif | |||
| 186 | ||||
| 187 | 1172x | int verify_mode_flag = SSL_VERIFY_NONE; | ||
| 188 |
2/2✓ Branch 0 taken 582 times.
✓ Branch 1 taken 590 times.
|
1172x | if (cd.verification_mode == tls_verify_mode::peer) | |
| 189 | 582x | verify_mode_flag = SSL_VERIFY_PEER; | ||
| 190 |
2/2✓ Branch 0 taken 587 times.
✓ Branch 1 taken 3 times.
|
590x | else if (cd.verification_mode == tls_verify_mode::require_peer) | |
| 191 | 3x | verify_mode_flag = | ||
| 192 | SSL_VERIFY_PEER | SSL_VERIFY_FAIL_IF_NO_PEER_CERT; | |||
| 193 |
1/2✓ Branch 0 taken 1172 times.
✗ Branch 1 not taken.
|
1172x | SSL_CTX_set_verify(ctx_, verify_mode_flag, nullptr); | |
| 194 | ||||
| 195 |
2/2✓ Branch 0 taken 587 times.
✓ Branch 1 taken 585 times.
|
1172x | if (!cd.entity_certificate.empty()) | |
| 196 | { | |||
| 197 |
1/2✓ Branch 0 taken 587 times.
✗ Branch 1 not taken.
|
587x | BIO* bio = BIO_new_mem_buf( | |
| 198 | 587x | cd.entity_certificate.data(), | ||
| 199 | 587x | static_cast<int>(cd.entity_certificate.size())); | ||
| 200 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 587 times.
|
587x | if (bio) | |
| 201 | { | |||
| 202 | 587x | X509* cert = nullptr; | ||
| 203 |
1/2✓ Branch 0 taken 587 times.
✗ Branch 1 not taken.
|
587x | if (cd.entity_cert_format == tls_file_format::pem) | |
| 204 |
1/2✓ Branch 0 taken 587 times.
✗ Branch 1 not taken.
|
587x | cert = PEM_read_bio_X509(bio, nullptr, nullptr, nullptr); | |
| 205 | else | |||
| 206 | ✗ | cert = d2i_X509_bio(bio, nullptr); | ||
| 207 |
1/2✓ Branch 0 taken 587 times.
✗ Branch 1 not taken.
|
587x | if (cert) | |
| 208 | { | |||
| 209 |
1/2✓ Branch 0 taken 587 times.
✗ Branch 1 not taken.
|
587x | SSL_CTX_use_certificate(ctx_, cert); | |
| 210 |
1/2✓ Branch 0 taken 587 times.
✗ Branch 1 not taken.
|
587x | X509_free(cert); | |
| 211 | 587x | } | ||
| 212 |
1/2✓ Branch 0 taken 587 times.
✗ Branch 1 not taken.
|
587x | BIO_free(bio); | |
| 213 | 587x | } | ||
| 214 | 587x | } | ||
| 215 | ||||
| 216 |
2/2✓ Branch 0 taken 1 time.
✓ Branch 1 taken 1171 times.
|
1172x | if (!cd.certificate_chain.empty()) | |
| 217 | { | |||
| 218 |
1/2✓ Branch 0 taken 1 time.
✗ Branch 1 not taken.
|
1x | BIO* bio = BIO_new_mem_buf( | |
| 219 | 1x | cd.certificate_chain.data(), | ||
| 220 | 1x | static_cast<int>(cd.certificate_chain.size())); | ||
| 221 |
1/2✓ Branch 0 taken 1 time.
✗ Branch 1 not taken.
|
1x | if (bio) | |
| 222 | { | |||
| 223 | 1x | X509* entity = | ||
| 224 |
1/2✓ Branch 0 taken 1 time.
✗ Branch 1 not taken.
|
1x | PEM_read_bio_X509(bio, nullptr, nullptr, nullptr); | |
| 225 |
1/2✓ Branch 0 taken 1 time.
✗ Branch 1 not taken.
|
1x | if (entity) | |
| 226 | { | |||
| 227 |
1/2✓ Branch 0 taken 1 time.
✗ Branch 1 not taken.
|
1x | SSL_CTX_use_certificate(ctx_, entity); | |
| 228 |
1/2✓ Branch 0 taken 1 time.
✗ Branch 1 not taken.
|
1x | X509_free(entity); | |
| 229 | 1x | } | ||
| 230 | ||||
| 231 | X509* cert; | |||
| 232 |
5/6✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 time.
✓ Branch 3 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 5 taken 1 time.
|
2x | while ((cert = PEM_read_bio_X509( | |
| 233 | 2x | bio, nullptr, nullptr, nullptr)) != nullptr) | ||
| 234 | { | |||
| 235 |
1/2✓ Branch 0 taken 1 time.
✗ Branch 1 not taken.
|
1x | SSL_CTX_add_extra_chain_cert(ctx_, cert); | |
| 236 | } | |||
| 237 |
1/2✓ Branch 0 taken 1 time.
✗ Branch 1 not taken.
|
1x | ERR_clear_error(); | |
| 238 |
1/2✓ Branch 0 taken 1 time.
✗ Branch 1 not taken.
|
1x | BIO_free(bio); | |
| 239 | 1x | } | ||
| 240 | 1x | } | ||
| 241 | ||||
| 242 |
2/2✓ Branch 0 taken 588 times.
✓ Branch 1 taken 584 times.
|
1172x | if (!cd.private_key.empty()) | |
| 243 | { | |||
| 244 |
1/2✓ Branch 0 taken 588 times.
✗ Branch 1 not taken.
|
588x | BIO* bio = BIO_new_mem_buf( | |
| 245 | 588x | cd.private_key.data(), static_cast<int>(cd.private_key.size())); | ||
| 246 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 588 times.
|
588x | if (bio) | |
| 247 | { | |||
| 248 | 588x | EVP_PKEY* pkey = nullptr; | ||
| 249 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 588 times.
|
588x | if (cd.private_key_format == tls_file_format::pem) | |
| 250 | { | |||
| 251 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 588 times.
|
588x | if (cd.password_callback) | |
| 252 | ✗ | pkey = PEM_read_bio_PrivateKey( | ||
| 253 | ✗ | bio, nullptr, password_callback, | ||
| 254 | ✗ | const_cast<tls_context_data*>(&cd)); | ||
| 255 | else | |||
| 256 |
1/2✓ Branch 0 taken 588 times.
✗ Branch 1 not taken.
|
588x | pkey = PEM_read_bio_PrivateKey( | |
| 257 | 588x | bio, nullptr, nullptr, nullptr); | ||
| 258 | 588x | } | ||
| 259 | else | |||
| 260 | ✗ | pkey = d2i_PrivateKey_bio(bio, nullptr); | ||
| 261 |
1/2✓ Branch 0 taken 588 times.
✗ Branch 1 not taken.
|
588x | if (pkey) | |
| 262 | { | |||
| 263 |
1/2✓ Branch 0 taken 588 times.
✗ Branch 1 not taken.
|
588x | SSL_CTX_use_PrivateKey(ctx_, pkey); | |
| 264 |
1/2✓ Branch 0 taken 588 times.
✗ Branch 1 not taken.
|
588x | EVP_PKEY_free(pkey); | |
| 265 | 588x | } | ||
| 266 |
1/2✓ Branch 0 taken 588 times.
✗ Branch 1 not taken.
|
588x | BIO_free(bio); | |
| 267 | 588x | } | ||
| 268 | 588x | } | ||
| 269 | ||||
| 270 |
1/2✓ Branch 0 taken 1172 times.
✗ Branch 1 not taken.
|
1172x | X509_STORE* store = SSL_CTX_get_cert_store(ctx_); | |
| 271 |
2/2✓ Branch 0 taken 1172 times.
✓ Branch 1 taken 596 times.
|
1768x | for (auto const& ca : cd.ca_certificates) | |
| 272 | { | |||
| 273 |
1/2✓ Branch 0 taken 596 times.
✗ Branch 1 not taken.
|
596x | BIO* bio = BIO_new_mem_buf(ca.data(), static_cast<int>(ca.size())); | |
| 274 |
1/2✓ Branch 0 taken 596 times.
✗ Branch 1 not taken.
|
596x | if (bio) | |
| 275 | { | |||
| 276 |
1/2✓ Branch 0 taken 596 times.
✗ Branch 1 not taken.
|
596x | X509* cert = PEM_read_bio_X509(bio, nullptr, nullptr, nullptr); | |
| 277 |
2/2✓ Branch 0 taken 595 times.
✓ Branch 1 taken 1 time.
|
596x | if (cert) | |
| 278 | { | |||
| 279 |
1/2✓ Branch 0 taken 595 times.
✗ Branch 1 not taken.
|
595x | X509_STORE_add_cert(store, cert); | |
| 280 |
1/2✓ Branch 0 taken 595 times.
✗ Branch 1 not taken.
|
595x | X509_free(cert); | |
| 281 | 595x | } | ||
| 282 |
1/2✓ Branch 0 taken 596 times.
✗ Branch 1 not taken.
|
596x | BIO_free(bio); | |
| 283 | 596x | } | ||
| 284 | } | |||
| 285 | ||||
| 286 |
1/2✓ Branch 0 taken 1172 times.
✗ Branch 1 not taken.
|
1172x | SSL_CTX_set_verify_depth(ctx_, cd.verify_depth); | |
| 287 | ||||
| 288 |
2/2✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1169 times.
|
1172x | if (!cd.ciphersuites.empty()) | |
| 289 | { | |||
| 290 |
1/2✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
|
3x | SSL_CTX_set_security_level(ctx_, 0); | |
| 291 |
1/2✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
|
3x | SSL_CTX_set_cipher_list(ctx_, cd.ciphersuites.c_str()); | |
| 292 | 3x | } | ||
| 293 | 2344x | } | ||
| 294 | ||||
| 295 | 3516x | ~openssl_native_context() override | ||
| 296 | 3516x | { | ||
| 297 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1172 times.
|
1172x | if (ctx_) | |
| 298 |
1/2✓ Branch 0 taken 1172 times.
✗ Branch 1 not taken.
|
1172x | SSL_CTX_free(ctx_); | |
| 299 | 3516x | } | ||
| 300 | }; | |||
| 301 | ||||
| 302 | inline SSL_CTX* | |||
| 303 | 1177x | get_openssl_context(tls_context_data const& cd) | ||
| 304 | { | |||
| 305 | static char key; | |||
| 306 |
1/2✓ Branch 0 taken 1172 times.
✗ Branch 1 not taken.
|
2349x | auto* p = cd.find(&key, [&] { return new openssl_native_context(cd); }); | |
| 307 | 1177x | return static_cast<openssl_native_context*>(p)->ctx_; | ||
| 308 | } | |||
| 309 | ||||
| 310 | } // namespace detail | |||
| 311 | ||||
| 312 | struct openssl_stream::impl | |||
| 313 | { | |||
| 314 | capy::any_stream& s_; | |||
| 315 | tls_context ctx_; | |||
| 316 | 1177x | SSL* ssl_ = nullptr; | ||
| 317 | 1177x | BIO* ext_bio_ = nullptr; | ||
| 318 | 1177x | bool used_ = false; | ||
| 319 | ||||
| 320 | std::vector<char> in_buf_; | |||
| 321 | std::vector<char> out_buf_; | |||
| 322 | ||||
| 323 | capy::async_mutex io_cm_; | |||
| 324 | ||||
| 325 | 3531x | impl(capy::any_stream& s, tls_context ctx) : s_(s), ctx_(std::move(ctx)) | ||
| 326 | 1177x | { | ||
| 327 |
1/2✓ Branch 0 taken 1177 times.
✗ Branch 1 not taken.
|
1177x | in_buf_.resize(default_buffer_size); | |
| 328 |
1/2✓ Branch 0 taken 1177 times.
✗ Branch 1 not taken.
|
1177x | out_buf_.resize(default_buffer_size); | |
| 329 | 2354x | } | ||
| 330 | ||||
| 331 | 2354x | ~impl() | ||
| 332 | 1177x | { | ||
| 333 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1177 times.
|
1177x | if (ext_bio_) | |
| 334 |
1/2✓ Branch 0 taken 1177 times.
✗ Branch 1 not taken.
|
1177x | BIO_free(ext_bio_); | |
| 335 |
1/2✓ Branch 0 taken 1177 times.
✗ Branch 1 not taken.
|
1177x | if (ssl_) | |
| 336 |
1/2✓ Branch 0 taken 1177 times.
✗ Branch 1 not taken.
|
1177x | SSL_free(ssl_); | |
| 337 | 2354x | } | ||
| 338 | ||||
| 339 | 20x | void reset() | ||
| 340 | { | |||
| 341 |
1/2✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
|
20x | if (!ssl_) | |
| 342 | ✗ | return; | ||
| 343 | ||||
| 344 | // Preserves SSL* and BIO pair, releases session state | |||
| 345 | 20x | SSL_clear(ssl_); | ||
| 346 | ||||
| 347 | // Drain stale data from the external BIO | |||
| 348 | char drain[1024]; | |||
| 349 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
|
20x | while (BIO_ctrl_pending(ext_bio_) > 0) | |
| 350 | ✗ | BIO_read(ext_bio_, drain, sizeof(drain)); | ||
| 351 | ||||
| 352 | // SSL_clear clears per-session settings; reapply hostname | |||
| 353 | 20x | auto& cd = detail::get_tls_context_data(ctx_); | ||
| 354 | 20x | apply_hostname_verification(ssl_, cd.hostname); | ||
| 355 | ||||
| 356 | 20x | used_ = false; | ||
| 357 | 20x | } | ||
| 358 | ||||
| 359 |
10/24✓ Branch 0 taken 101389 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 101389 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 101389 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 101389 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 101389 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✓ Branch 14 taken 101389 times.
✓ Branch 15 taken 101389 times.
✓ Branch 16 taken 101389 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 177484 times.
✓ Branch 19 taken 101389 times.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
|
861913x | capy::task<std::error_code> flush_output() | |
| 360 | 101389x | { | ||
| 361 |
3/4✓ Branch 0 taken 190128 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 101386 times.
✓ Branch 3 taken 88742 times.
|
190128x | while (BIO_ctrl_pending(ext_bio_) > 0) | |
| 362 | { | |||
| 363 | 88742x | std::size_t got = 0; | ||
| 364 |
5/6✓ Branch 0 taken 177484 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 88739 times.
✓ Branch 3 taken 88745 times.
✓ Branch 4 taken 88742 times.
✓ Branch 5 taken 88742 times.
|
177484x | while (BIO_ctrl_pending(ext_bio_) > 0 && got < out_buf_.size()) | |
| 365 | { | |||
| 366 |
1/2✓ Branch 0 taken 88742 times.
✗ Branch 1 not taken.
|
88742x | int put = static_cast<int>(BIO_ctrl_pending(ext_bio_)); | |
| 367 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 88742 times.
|
88742x | put = (std::min)(put, static_cast<int>(out_buf_.size() - got)); | |
| 368 |
1/2✓ Branch 0 taken 88742 times.
✗ Branch 1 not taken.
|
88742x | int r = BIO_read(ext_bio_, out_buf_.data() + got, put); | |
| 369 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 88742 times.
|
88742x | if (r <= 0) | |
| 370 | ✗ | break; | ||
| 371 | 88742x | got += static_cast<std::size_t>(r); | ||
| 372 | 88742x | } | ||
| 373 |
1/2✓ Branch 0 taken 88742 times.
✗ Branch 1 not taken.
|
88742x | if (got == 0) | |
| 374 | ✗ | break; | ||
| 375 | ||||
| 376 | { | |||
| 377 |
5/12✓ Branch 0 taken 88742 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 88742 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 88742 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 177484 times.
✓ Branch 11 taken 266226 times.
|
88742x | auto [lec] = co_await io_cm_.lock(); | |
| 378 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 266226 times.
|
266226x | if (lec) | |
| 379 | ✗ | co_return lec; | ||
| 380 | 266226x | capy::async_mutex::lock_guard io_guard(&io_cm_); | ||
| 381 |
10/18✗ Branch 0 not taken.
✓ Branch 1 taken 266226 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 266226 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 266226 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 266226 times.
✓ Branch 8 taken 88742 times.
✓ Branch 9 taken 177484 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 88742 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✓ Branch 14 taken 88742 times.
✓ Branch 15 taken 88742 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 88742 times.
|
887420x | auto [ec, n] = co_await capy::write( | |
| 382 | 532452x | s_, capy::const_buffer(out_buf_.data(), got)); | ||
| 383 |
2/2✓ Branch 0 taken 3 times.
✓ Branch 1 taken 88739 times.
|
88742x | if (ec) | |
| 384 |
2/4✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
|
6x | co_return ec; | |
| 385 | 266226x | } | ||
| 386 | 266226x | } | ||
| 387 |
1/2✓ Branch 0 taken 101386 times.
✗ Branch 1 not taken.
|
101386x | co_return std::error_code{}; | |
| 388 | 177484x | } | ||
| 389 | ||||
| 390 |
10/24✓ Branch 0 taken 13541 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13541 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 13541 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 13541 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 13541 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✓ Branch 14 taken 13541 times.
✓ Branch 15 taken 13541 times.
✓ Branch 16 taken 13541 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 27082 times.
✓ Branch 19 taken 13541 times.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
|
121869x | capy::task<std::error_code> read_input() | |
| 391 | 13541x | { | ||
| 392 |
4/10✓ Branch 0 taken 13541 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13541 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 27082 times.
✓ Branch 9 taken 40623 times.
|
13541x | auto [lec] = co_await io_cm_.lock(); | |
| 393 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 40623 times.
|
40623x | if (lec) | |
| 394 | ✗ | co_return lec; | ||
| 395 | 40623x | capy::async_mutex::lock_guard io_guard(&io_cm_); | ||
| 396 |
9/16✓ Branch 0 taken 40623 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 40623 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 40623 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 13541 times.
✓ Branch 7 taken 27082 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 13541 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✓ Branch 12 taken 13541 times.
✓ Branch 13 taken 13541 times.
✗ Branch 14 not taken.
✓ Branch 15 taken 13541 times.
|
94787x | auto [ec, n] = co_await s_.read_some( | |
| 397 | 40623x | capy::mutable_buffer(in_buf_.data(), in_buf_.size())); | ||
| 398 |
2/2✓ Branch 0 taken 331 times.
✓ Branch 1 taken 13210 times.
|
13541x | if (ec) | |
| 399 |
2/4✓ Branch 0 taken 331 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 331 times.
✗ Branch 3 not taken.
|
662x | co_return ec; | |
| 400 | ||||
| 401 |
2/4✓ Branch 0 taken 13210 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13210 times.
✗ Branch 3 not taken.
|
26420x | int got = BIO_write(ext_bio_, in_buf_.data(), static_cast<int>(n)); | |
| 402 |
2/4✗ Branch 0 not taken.
✓ Branch 1 taken 13210 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13210 times.
|
26420x | if (got < static_cast<int>(n)) | |
| 403 | { | |||
| 404 | ✗ | co_return make_error_code(std::errc::no_buffer_space); | ||
| 405 | } | |||
| 406 | ||||
| 407 |
1/2✓ Branch 0 taken 13210 times.
✗ Branch 1 not taken.
|
13210x | co_return std::error_code{}; | |
| 408 | 67705x | } | ||
| 409 | ||||
| 410 | capy::io_task<std::size_t> | |||
| 411 |
9/24✓ Branch 0 taken 87271 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 87271 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 87271 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 87271 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 87271 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✓ Branch 14 taken 87271 times.
✓ Branch 15 taken 87271 times.
✓ Branch 16 taken 87271 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 87271 times.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
|
436355x | do_read_some(capy::detail::mutable_buffer_array<capy::detail::max_iovec_> buffers) | |
| 412 | 87271x | { | ||
| 413 | 87271x | std::error_code ec; | ||
| 414 | 87271x | std::size_t total_read = 0; | ||
| 415 | ||||
| 416 |
2/4✗ Branch 0 not taken.
✓ Branch 1 taken 87271 times.
✓ Branch 2 taken 87271 times.
✗ Branch 3 not taken.
|
174542x | for (auto& buf : buffers) | |
| 417 | { | |||
| 418 | 87271x | char* dest = static_cast<char*>(buf.data()); | ||
| 419 | 87271x | int remaining = static_cast<int>(buf.size()); | ||
| 420 | ||||
| 421 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 124250 times.
|
124250x | while (remaining > 0) | |
| 422 | { | |||
| 423 |
1/2✓ Branch 0 taken 124250 times.
✗ Branch 1 not taken.
|
124250x | ERR_clear_error(); | |
| 424 |
1/2✓ Branch 0 taken 124250 times.
✗ Branch 1 not taken.
|
124250x | int ret = SSL_read(ssl_, dest, remaining); | |
| 425 | ||||
| 426 |
2/2✓ Branch 0 taken 87244 times.
✓ Branch 1 taken 37006 times.
|
124250x | if (ret > 0) | |
| 427 | { | |||
| 428 | 87244x | dest += ret; | ||
| 429 | 87244x | remaining -= ret; | ||
| 430 | 87244x | total_read += static_cast<std::size_t>(ret); | ||
| 431 | ||||
| 432 |
1/2✓ Branch 0 taken 87244 times.
✗ Branch 1 not taken.
|
87244x | if (total_read > 0) | |
| 433 |
2/4✓ Branch 0 taken 87244 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 87244 times.
✗ Branch 3 not taken.
|
174515x | co_return {std::error_code{}, total_read}; | |
| 434 | ✗ | } | ||
| 435 | else | |||
| 436 | { | |||
| 437 |
1/2✓ Branch 0 taken 37006 times.
✗ Branch 1 not taken.
|
37006x | int err = SSL_get_error(ssl_, ret); | |
| 438 | ||||
| 439 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 37006 times.
|
37006x | if (err == SSL_ERROR_WANT_WRITE) | |
| 440 | { | |||
| 441 | ✗ | ec = co_await flush_output(); | ||
| 442 | ✗ | if (ec) | ||
| 443 | ✗ | co_return {ec, total_read}; | ||
| 444 | ✗ | } | ||
| 445 |
2/2✓ Branch 0 taken 36984 times.
✓ Branch 1 taken 22 times.
|
37006x | else if (err == SSL_ERROR_WANT_READ) | |
| 446 | { | |||
| 447 |
9/14✓ Branch 0 taken 36984 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36984 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12328 times.
✓ Branch 5 taken 24656 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 12328 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 12328 times.
✓ Branch 11 taken 12328 times.
✓ Branch 12 taken 24656 times.
✓ Branch 13 taken 36984 times.
|
49312x | ec = co_await flush_output(); | |
| 448 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 36984 times.
|
36984x | if (ec) | |
| 449 | ✗ | co_return {ec, total_read}; | ||
| 450 | ||||
| 451 |
8/14✓ Branch 0 taken 36984 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36984 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12328 times.
✓ Branch 5 taken 24656 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 12328 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 12328 times.
✓ Branch 11 taken 12328 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 12328 times.
|
49312x | ec = co_await read_input(); | |
| 452 |
2/2✓ Branch 0 taken 5 times.
✓ Branch 1 taken 12323 times.
|
12328x | if (ec) | |
| 453 | { | |||
| 454 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 3 times.
|
5x | if (ec == make_error_code(capy::error::eof)) | |
| 455 | { | |||
| 456 |
2/4✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
|
2x | if (SSL_get_shutdown(ssl_) & | |
| 457 | SSL_RECEIVED_SHUTDOWN) | |||
| 458 | ✗ | ec = make_error_code(capy::error::eof); | ||
| 459 | else | |||
| 460 | 2x | ec = make_error_code( | ||
| 461 | capy::error::stream_truncated); | |||
| 462 | 2x | } | ||
| 463 |
2/4✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
|
5x | co_return {ec, total_read}; | |
| 464 | } | |||
| 465 | 12323x | } | ||
| 466 |
1/2✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
|
22x | else if (err == SSL_ERROR_ZERO_RETURN) | |
| 467 | { | |||
| 468 |
3/6✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 22 times.
✗ Branch 5 not taken.
|
44x | co_return { | |
| 469 | 22x | make_error_code(capy::error::eof), total_read}; | ||
| 470 | } | |||
| 471 | ✗ | else if (err == SSL_ERROR_SYSCALL) | ||
| 472 | { | |||
| 473 | ✗ | unsigned long ssl_err = ERR_get_error(); | ||
| 474 | ✗ | if (ssl_err == 0) | ||
| 475 | ✗ | ec = make_error_code(capy::error::stream_truncated); | ||
| 476 | else | |||
| 477 | ✗ | ec = std::error_code( | ||
| 478 | ✗ | static_cast<int>(ssl_err), | ||
| 479 | ✗ | std::system_category()); | ||
| 480 | ✗ | co_return {ec, total_read}; | ||
| 481 | ✗ | } | ||
| 482 | else | |||
| 483 | { | |||
| 484 | ✗ | unsigned long ssl_err = ERR_get_error(); | ||
| 485 | ✗ | ec = std::error_code( | ||
| 486 | ✗ | static_cast<int>(ssl_err), std::system_category()); | ||
| 487 | ✗ | co_return {ec, total_read}; | ||
| 488 | ✗ | } | ||
| 489 | 37006x | } | ||
| 490 | 124250x | } | ||
| 491 | 87271x | } | ||
| 492 | ||||
| 493 | ✗ | co_return {std::error_code{}, total_read}; | ||
| 494 | 136583x | } | ||
| 495 | ||||
| 496 | capy::io_task<std::size_t> | |||
| 497 |
9/24✓ Branch 0 taken 87262 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 87262 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 87262 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 87262 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 87262 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✓ Branch 14 taken 87262 times.
✓ Branch 15 taken 87262 times.
✓ Branch 16 taken 87262 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 87262 times.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
|
436310x | do_write_some(capy::detail::const_buffer_array<capy::detail::max_iovec_> buffers) | |
| 498 | 87262x | { | ||
| 499 | 87262x | std::error_code ec; | ||
| 500 | 87262x | std::size_t total_written = 0; | ||
| 501 | ||||
| 502 |
2/4✓ Branch 0 taken 87262 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 87262 times.
✗ Branch 3 not taken.
|
174524x | for (auto const& buf : buffers) | |
| 503 | { | |||
| 504 | 87262x | char const* src = static_cast<char const*>(buf.data()); | ||
| 505 | 87262x | int remaining = static_cast<int>(buf.size()); | ||
| 506 | ||||
| 507 |
1/2✓ Branch 0 taken 261786 times.
✗ Branch 1 not taken.
|
261786x | while (remaining > 0) | |
| 508 | { | |||
| 509 |
1/2✓ Branch 0 taken 261786 times.
✗ Branch 1 not taken.
|
261786x | ERR_clear_error(); | |
| 510 |
1/2✓ Branch 0 taken 261786 times.
✗ Branch 1 not taken.
|
261786x | int ret = SSL_write(ssl_, src, remaining); | |
| 511 | ||||
| 512 |
1/2✓ Branch 0 taken 261786 times.
✗ Branch 1 not taken.
|
261786x | if (ret > 0) | |
| 513 | { | |||
| 514 | 261786x | src += ret; | ||
| 515 | 261786x | remaining -= ret; | ||
| 516 | 261786x | total_written += static_cast<std::size_t>(ret); | ||
| 517 | ||||
| 518 |
1/2✓ Branch 0 taken 261786 times.
✗ Branch 1 not taken.
|
261786x | if (total_written > 0) | |
| 519 | { | |||
| 520 |
8/14✗ Branch 0 not taken.
✓ Branch 1 taken 261786 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 261786 times.
✓ Branch 4 taken 87262 times.
✓ Branch 5 taken 174524 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 87262 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 87262 times.
✓ Branch 11 taken 87262 times.
✓ Branch 12 taken 87262 times.
✗ Branch 13 not taken.
|
436310x | ec = co_await flush_output(); | |
| 521 |
2/4✓ Branch 0 taken 87262 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 87262 times.
✗ Branch 3 not taken.
|
87262x | co_return {ec, total_written}; | |
| 522 | } | |||
| 523 | ✗ | } | ||
| 524 | else | |||
| 525 | { | |||
| 526 | ✗ | int err = SSL_get_error(ssl_, ret); | ||
| 527 | ||||
| 528 | ✗ | if (err == SSL_ERROR_WANT_WRITE) | ||
| 529 | { | |||
| 530 | ✗ | ec = co_await flush_output(); | ||
| 531 | ✗ | if (ec) | ||
| 532 | ✗ | co_return {ec, total_written}; | ||
| 533 | ✗ | } | ||
| 534 | ✗ | else if (err == SSL_ERROR_WANT_READ) | ||
| 535 | { | |||
| 536 | ✗ | ec = co_await flush_output(); | ||
| 537 | ✗ | if (ec) | ||
| 538 | ✗ | co_return {ec, total_written}; | ||
| 539 | ||||
| 540 | ✗ | ec = co_await read_input(); | ||
| 541 | ✗ | if (ec) | ||
| 542 | ✗ | co_return {ec, total_written}; | ||
| 543 | ✗ | } | ||
| 544 | else | |||
| 545 | { | |||
| 546 | ✗ | unsigned long ssl_err = ERR_get_error(); | ||
| 547 | ✗ | ec = std::error_code( | ||
| 548 | ✗ | static_cast<int>(ssl_err), std::system_category()); | ||
| 549 | ✗ | co_return {ec, total_written}; | ||
| 550 | ✗ | } | ||
| 551 | ✗ | } | ||
| 552 | 87262x | } | ||
| 553 | 87262x | } | ||
| 554 | ||||
| 555 | ✗ | co_return {std::error_code{}, total_written}; | ||
| 556 | 261786x | } | ||
| 557 | ||||
| 558 |
11/24✓ Branch 0 taken 885 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 885 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 885 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1116 times.
✓ Branch 7 taken 2001 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 885 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✓ Branch 14 taken 885 times.
✓ Branch 15 taken 885 times.
✓ Branch 16 taken 885 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 1116 times.
✓ Branch 19 taken 885 times.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
|
5541x | capy::io_task<> do_handshake(int type) | |
| 559 | 885x | { | ||
| 560 |
2/2✓ Branch 0 taken 1997 times.
✓ Branch 1 taken 4 times.
|
2001x | if (used_) | |
| 561 |
1/2✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
|
4x | reset(); | |
| 562 | ||||
| 563 | 2001x | std::error_code ec; | ||
| 564 | ||||
| 565 | 5196x | while (true) | ||
| 566 | { | |||
| 567 |
1/2✓ Branch 0 taken 5196 times.
✗ Branch 1 not taken.
|
5196x | ERR_clear_error(); | |
| 568 | 5196x | int ret; | ||
| 569 |
2/2✓ Branch 0 taken 884 times.
✓ Branch 1 taken 4312 times.
|
5196x | if (type == openssl_stream::client) | |
| 570 |
1/2✓ Branch 0 taken 884 times.
✗ Branch 1 not taken.
|
884x | ret = SSL_connect(ssl_); | |
| 571 | else | |||
| 572 |
1/2✓ Branch 0 taken 4312 times.
✗ Branch 1 not taken.
|
4312x | ret = SSL_accept(ssl_); | |
| 573 | ||||
| 574 |
2/2✓ Branch 0 taken 1674 times.
✓ Branch 1 taken 3522 times.
|
5196x | if (ret == 1) | |
| 575 | { | |||
| 576 | 1674x | used_ = true; | ||
| 577 |
8/14✓ Branch 0 taken 1674 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1674 times.
✓ Branch 4 taken 558 times.
✓ Branch 5 taken 1116 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 558 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 558 times.
✓ Branch 11 taken 558 times.
✓ Branch 12 taken 558 times.
✗ Branch 13 not taken.
|
3117x | ec = co_await flush_output(); | |
| 578 |
2/4✓ Branch 0 taken 558 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 558 times.
✗ Branch 3 not taken.
|
558x | co_return {ec}; | |
| 579 | } | |||
| 580 | else | |||
| 581 | { | |||
| 582 |
1/2✓ Branch 0 taken 3522 times.
✗ Branch 1 not taken.
|
3522x | int err = SSL_get_error(ssl_, ret); | |
| 583 | ||||
| 584 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 3522 times.
|
3522x | if (err == SSL_ERROR_WANT_WRITE) | |
| 585 | { | |||
| 586 | ✗ | ec = co_await flush_output(); | ||
| 587 | ✗ | if (ec) | ||
| 588 | ✗ | co_return {ec}; | ||
| 589 | ✗ | } | ||
| 590 |
2/2✓ Branch 0 taken 3513 times.
✓ Branch 1 taken 9 times.
|
3522x | else if (err == SSL_ERROR_WANT_READ) | |
| 591 | { | |||
| 592 |
9/14✗ Branch 0 not taken.
✓ Branch 1 taken 3513 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3513 times.
✓ Branch 4 taken 1171 times.
✓ Branch 5 taken 2342 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 1171 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 1171 times.
✓ Branch 11 taken 1171 times.
✓ Branch 12 taken 2342 times.
✓ Branch 13 taken 3513 times.
|
4684x | ec = co_await flush_output(); | |
| 593 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 3513 times.
|
3513x | if (ec) | |
| 594 | ✗ | co_return {ec}; | ||
| 595 | ||||
| 596 |
8/14✓ Branch 0 taken 3513 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3513 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1171 times.
✓ Branch 5 taken 2342 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 1171 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 1171 times.
✓ Branch 11 taken 1171 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 1171 times.
|
4684x | ec = co_await read_input(); | |
| 597 |
2/2✓ Branch 0 taken 318 times.
✓ Branch 1 taken 853 times.
|
1171x | if (ec) | |
| 598 |
2/4✓ Branch 0 taken 318 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 318 times.
✗ Branch 3 not taken.
|
318x | co_return {ec}; | |
| 599 | 853x | } | ||
| 600 | else | |||
| 601 | { | |||
| 602 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9x | unsigned long ssl_err = ERR_get_error(); | |
| 603 | 18x | ec = std::error_code( | ||
| 604 | 9x | static_cast<int>(ssl_err), std::system_category()); | ||
| 605 |
2/4✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
|
9x | co_return {ec}; | |
| 606 | 9x | } | ||
| 607 | 3522x | } | ||
| 608 | 4080x | } | ||
| 609 | 6685x | } | ||
| 610 | ||||
| 611 |
11/24✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 36 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 56 times.
✓ Branch 7 taken 92 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 36 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✓ Branch 14 taken 36 times.
✓ Branch 15 taken 36 times.
✓ Branch 16 taken 36 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 36 times.
✓ Branch 19 taken 56 times.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
|
236x | capy::io_task<> do_shutdown() | |
| 612 | 36x | { | ||
| 613 | 92x | std::error_code ec; | ||
| 614 | ||||
| 615 | 210x | while (true) | ||
| 616 | { | |||
| 617 |
1/2✓ Branch 0 taken 210 times.
✗ Branch 1 not taken.
|
210x | ERR_clear_error(); | |
| 618 |
1/2✓ Branch 0 taken 210 times.
✗ Branch 1 not taken.
|
210x | int ret = SSL_shutdown(ssl_); | |
| 619 | ||||
| 620 |
2/2✓ Branch 0 taken 84 times.
✓ Branch 1 taken 126 times.
|
210x | if (ret == 1) | |
| 621 | { | |||
| 622 |
8/14✗ Branch 0 not taken.
✓ Branch 1 taken 84 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 84 times.
✓ Branch 4 taken 28 times.
✓ Branch 5 taken 56 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 28 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 28 times.
✓ Branch 11 taken 28 times.
✓ Branch 12 taken 28 times.
✗ Branch 13 not taken.
|
112x | ec = co_await flush_output(); | |
| 623 |
2/4✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 28 times.
✗ Branch 3 not taken.
|
28x | co_return {ec}; | |
| 624 | } | |||
| 625 |
2/2✓ Branch 0 taken 60 times.
✓ Branch 1 taken 66 times.
|
126x | else if (ret == 0) | |
| 626 | { | |||
| 627 |
9/14✗ Branch 0 not taken.
✓ Branch 1 taken 66 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 66 times.
✓ Branch 4 taken 22 times.
✓ Branch 5 taken 44 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 22 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 22 times.
✓ Branch 11 taken 22 times.
✓ Branch 12 taken 44 times.
✓ Branch 13 taken 66 times.
|
88x | ec = co_await flush_output(); | |
| 628 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 66 times.
|
66x | if (ec) | |
| 629 | ✗ | co_return {ec}; | ||
| 630 | ||||
| 631 |
8/14✗ Branch 0 not taken.
✓ Branch 1 taken 66 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 66 times.
✓ Branch 4 taken 22 times.
✓ Branch 5 taken 44 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 22 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 22 times.
✓ Branch 11 taken 22 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 22 times.
|
88x | ec = co_await read_input(); | |
| 632 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 20 times.
|
22x | if (ec) | |
| 633 | { | |||
| 634 | 2x | ec = normalize_openssl_shutdown_read_error(ec); | ||
| 635 |
2/4✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
|
2x | co_return {ec}; | |
| 636 | } | |||
| 637 | 20x | } | ||
| 638 | else | |||
| 639 | { | |||
| 640 |
1/2✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
|
60x | int err = SSL_get_error(ssl_, ret); | |
| 641 | ||||
| 642 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 60 times.
|
60x | if (err == SSL_ERROR_WANT_WRITE) | |
| 643 | { | |||
| 644 | ✗ | ec = co_await flush_output(); | ||
| 645 | ✗ | if (ec) | ||
| 646 | ✗ | co_return {ec}; | ||
| 647 | ✗ | } | ||
| 648 |
1/2✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
|
60x | else if (err == SSL_ERROR_WANT_READ) | |
| 649 | { | |||
| 650 |
9/14✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 60 times.
✓ Branch 4 taken 20 times.
✓ Branch 5 taken 40 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 20 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 20 times.
✓ Branch 11 taken 20 times.
✓ Branch 12 taken 40 times.
✓ Branch 13 taken 60 times.
|
80x | ec = co_await flush_output(); | |
| 651 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 60 times.
|
60x | if (ec) | |
| 652 | ✗ | co_return {ec}; | ||
| 653 | ||||
| 654 |
8/14✗ Branch 0 not taken.
✓ Branch 1 taken 60 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 60 times.
✓ Branch 4 taken 20 times.
✓ Branch 5 taken 40 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 20 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 20 times.
✓ Branch 11 taken 20 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 20 times.
|
80x | ec = co_await read_input(); | |
| 655 |
2/2✓ Branch 0 taken 6 times.
✓ Branch 1 taken 14 times.
|
20x | if (ec) | |
| 656 | { | |||
| 657 | 6x | ec = normalize_openssl_shutdown_read_error(ec); | ||
| 658 |
2/4✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
|
6x | co_return {ec}; | |
| 659 | } | |||
| 660 | 14x | } | ||
| 661 | else | |||
| 662 | { | |||
| 663 | ✗ | unsigned long ssl_err = ERR_get_error(); | ||
| 664 | ✗ | if (ssl_err == 0 && err == SSL_ERROR_SYSCALL) | ||
| 665 | { | |||
| 666 | ✗ | ec = {}; | ||
| 667 | ✗ | } | ||
| 668 | else | |||
| 669 | { | |||
| 670 | ✗ | ec = std::error_code( | ||
| 671 | ✗ | static_cast<int>(ssl_err), std::system_category()); | ||
| 672 | } | |||
| 673 | ✗ | co_return {ec}; | ||
| 674 | ✗ | } | ||
| 675 | 60x | } | ||
| 676 | 154x | } | ||
| 677 | 260x | } | ||
| 678 | ||||
| 679 | 1177x | std::error_code init_ssl() | ||
| 680 | { | |||
| 681 | 1177x | auto& cd = detail::get_tls_context_data(ctx_); | ||
| 682 | 1177x | SSL_CTX* native_ctx = detail::get_openssl_context(cd); | ||
| 683 |
1/2✓ Branch 0 taken 1177 times.
✗ Branch 1 not taken.
|
1177x | if (!native_ctx) | |
| 684 | { | |||
| 685 | ✗ | unsigned long err = ERR_get_error(); | ||
| 686 | ✗ | return std::error_code( | ||
| 687 | ✗ | static_cast<int>(err), std::system_category()); | ||
| 688 | } | |||
| 689 | ||||
| 690 | 1177x | ssl_ = SSL_new(native_ctx); | ||
| 691 |
1/2✓ Branch 0 taken 1177 times.
✗ Branch 1 not taken.
|
1177x | if (!ssl_) | |
| 692 | { | |||
| 693 | ✗ | unsigned long err = ERR_get_error(); | ||
| 694 | ✗ | return std::error_code( | ||
| 695 | ✗ | static_cast<int>(err), std::system_category()); | ||
| 696 | } | |||
| 697 | ||||
| 698 | 1177x | BIO* int_bio = nullptr; | ||
| 699 |
1/2✓ Branch 0 taken 1177 times.
✗ Branch 1 not taken.
|
1177x | if (!BIO_new_bio_pair(&int_bio, 0, &ext_bio_, 0)) | |
| 700 | { | |||
| 701 | ✗ | unsigned long err = ERR_get_error(); | ||
| 702 | ✗ | SSL_free(ssl_); | ||
| 703 | ✗ | ssl_ = nullptr; | ||
| 704 | ✗ | return std::error_code( | ||
| 705 | ✗ | static_cast<int>(err), std::system_category()); | ||
| 706 | } | |||
| 707 | ||||
| 708 | 1177x | SSL_set_bio(ssl_, int_bio, int_bio); | ||
| 709 | ||||
| 710 | 1177x | apply_hostname_verification(ssl_, cd.hostname); | ||
| 711 | ||||
| 712 | 1177x | return {}; | ||
| 713 | 1177x | } | ||
| 714 | }; | |||
| 715 | ||||
| 716 | openssl_stream::impl* | |||
| 717 | 1177x | openssl_stream::make_impl(capy::any_stream& stream, tls_context const& ctx) | ||
| 718 | { | |||
| 719 |
1/4✓ Branch 0 taken 1177 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
1177x | auto* p = new impl(stream, ctx); | |
| 720 | ||||
| 721 | 1177x | auto ec = p->init_ssl(); | ||
| 722 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1177 times.
|
1177x | if (ec) | |
| 723 | { | |||
| 724 | ✗ | delete p; | ||
| 725 | ✗ | return nullptr; | ||
| 726 | } | |||
| 727 | ||||
| 728 | 1177x | return p; | ||
| 729 | 1177x | } | ||
| 730 | ||||
| 731 | 2354x | openssl_stream::~openssl_stream() | ||
| 732 | 1177x | { | ||
| 733 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1177 times.
|
1177x | delete impl_; | |
| 734 | 2354x | } | ||
| 735 | ||||
| 736 | ✗ | openssl_stream::openssl_stream(openssl_stream&& other) noexcept | ||
| 737 | ✗ | : stream_(std::move(other.stream_)) | ||
| 738 | ✗ | , impl_(other.impl_) | ||
| 739 | ✗ | { | ||
| 740 | ✗ | other.impl_ = nullptr; | ||
| 741 | ✗ | } | ||
| 742 | ||||
| 743 | openssl_stream& | |||
| 744 | ✗ | openssl_stream::operator=(openssl_stream&& other) noexcept | ||
| 745 | { | |||
| 746 | ✗ | if (this != &other) | ||
| 747 | { | |||
| 748 | ✗ | delete impl_; | ||
| 749 | ✗ | stream_ = std::move(other.stream_); | ||
| 750 | ✗ | impl_ = other.impl_; | ||
| 751 | ✗ | other.impl_ = nullptr; | ||
| 752 | ✗ | } | ||
| 753 | ✗ | return *this; | ||
| 754 | } | |||
| 755 | ||||
| 756 | capy::io_task<std::size_t> | |||
| 757 |
11/24✓ Branch 0 taken 87271 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 87271 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 87271 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 174542 times.
✓ Branch 7 taken 261813 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 87271 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✓ Branch 14 taken 87271 times.
✓ Branch 15 taken 87271 times.
✓ Branch 16 taken 87271 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 174542 times.
✓ Branch 19 taken 87271 times.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
|
610897x | openssl_stream::do_read_some( | |
| 758 | capy::detail::mutable_buffer_array<capy::detail::max_iovec_> buffers) | |||
| 759 | 87271x | { | ||
| 760 |
9/16✓ Branch 0 taken 261813 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 261813 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 87271 times.
✓ Branch 5 taken 174542 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 87271 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 87271 times.
✓ Branch 11 taken 87271 times.
✓ Branch 12 taken 87271 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 87271 times.
|
436355x | co_return co_await impl_->do_read_some(buffers); | |
| 761 | 174542x | } | ||
| 762 | ||||
| 763 | capy::io_task<std::size_t> | |||
| 764 |
11/24✓ Branch 0 taken 87262 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 87262 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 87262 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 174524 times.
✓ Branch 7 taken 261786 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 87262 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✓ Branch 14 taken 87262 times.
✓ Branch 15 taken 87262 times.
✓ Branch 16 taken 87262 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 174524 times.
✓ Branch 19 taken 87262 times.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
|
610834x | openssl_stream::do_write_some( | |
| 765 | capy::detail::const_buffer_array<capy::detail::max_iovec_> buffers) | |||
| 766 | 87262x | { | ||
| 767 |
9/16✓ Branch 0 taken 261786 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 261786 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 87262 times.
✓ Branch 5 taken 174524 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 87262 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 87262 times.
✓ Branch 11 taken 87262 times.
✓ Branch 12 taken 87262 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 87262 times.
|
436310x | co_return co_await impl_->do_write_some(buffers); | |
| 768 | 174524x | } | ||
| 769 | ||||
| 770 | capy::io_task<> | |||
| 771 |
11/24✓ Branch 0 taken 885 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 885 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 885 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1770 times.
✓ Branch 7 taken 2655 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 885 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✓ Branch 14 taken 885 times.
✓ Branch 15 taken 885 times.
✓ Branch 16 taken 885 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 1770 times.
✓ Branch 19 taken 885 times.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
|
6195x | openssl_stream::handshake(handshake_type type) | |
| 772 | 885x | { | ||
| 773 |
9/16✓ Branch 0 taken 2655 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2655 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 885 times.
✓ Branch 5 taken 1770 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 885 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 885 times.
✓ Branch 11 taken 885 times.
✓ Branch 12 taken 885 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 885 times.
|
4425x | co_return co_await impl_->do_handshake(type); | |
| 774 | 1770x | } | ||
| 775 | ||||
| 776 | capy::io_task<> | |||
| 777 |
11/24✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 36 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 72 times.
✓ Branch 7 taken 108 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 36 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✓ Branch 14 taken 36 times.
✓ Branch 15 taken 36 times.
✓ Branch 16 taken 36 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 72 times.
✓ Branch 19 taken 36 times.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
|
252x | openssl_stream::shutdown() | |
| 778 | 36x | { | ||
| 779 |
9/16✓ Branch 0 taken 108 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 108 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 36 times.
✓ Branch 5 taken 72 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 36 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 36 times.
✓ Branch 11 taken 36 times.
✓ Branch 12 taken 36 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 36 times.
|
144x | co_return co_await impl_->do_shutdown(); | |
| 780 | 72x | } | ||
| 781 | ||||
| 782 | void | |||
| 783 | 16x | openssl_stream::reset() | ||
| 784 | { | |||
| 785 | 16x | impl_->reset(); | ||
| 786 | 16x | } | ||
| 787 | ||||
| 788 | std::string_view | |||
| 789 | 1x | openssl_stream::name() const noexcept | ||
| 790 | { | |||
| 791 |
1/2✓ Branch 0 taken 1 time.
✗ Branch 1 not taken.
|
1x | return "openssl"; | |
| 792 | } | |||
| 793 | ||||
| 794 | } // namespace boost::corosio | |||
| 795 |