• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

randombit / botan / 23269093546

18 Mar 2026 09:53PM UTC coverage: 89.674% (-0.005%) from 89.679%
23269093546

push

github

web-flow
Merge pull request #5464 from randombit/jack/missing-deps

Add some missing dependencies and includes

104434 of 116460 relevant lines covered (89.67%)

11784783.5 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

70.83
/src/lib/tls/tls_server.cpp
1
/*
2
* TLS Server
3
* (C) 2004-2011,2012,2016 Jack Lloyd
4
*     2016 Matthias Gierlings
5
*     2021 Elektrobit Automotive GmbH
6
*     2022 René Meusel, Hannes Rantzsch - neXenio GmbH
7
*
8
* Botan is released under the Simplified BSD License (see license.txt)
9
*/
10

11
#include <botan/tls_server.h>
12

13
#include <botan/tls_policy.h>
14
#include <botan/x509cert.h>
15
#include <botan/internal/tls_channel_impl.h>
16

17
#if defined(BOTAN_HAS_TLS_12)
18
   #include <botan/internal/tls_server_impl_12.h>
19
#endif
20

21
#if defined(BOTAN_HAS_TLS_13)
22
   #include <botan/internal/tls_server_impl_13.h>
23
#endif
24

25
namespace Botan::TLS {
26

27
/*
28
* TLS Server Constructor
29
*/
30
Server::Server(const std::shared_ptr<Callbacks>& callbacks,
2,556✔
31
               const std::shared_ptr<Session_Manager>& session_manager,
32
               const std::shared_ptr<Credentials_Manager>& creds,
33
               const std::shared_ptr<const Policy>& policy,
34
               const std::shared_ptr<RandomNumberGenerator>& rng,
35
               bool is_datagram,
36
               size_t io_buf_sz) {
2,556✔
37
   const auto max_version = policy->latest_supported_version(is_datagram);
2,556✔
38

39
#if defined(BOTAN_HAS_TLS_13)
40
   if(!max_version.is_pre_tls_13()) {
2,556✔
41
      m_impl = std::make_unique<Server_Impl_13>(callbacks, session_manager, creds, policy, rng);
2,036✔
42

43
      if(m_impl->expects_downgrade()) {
2,036✔
44
         m_impl->set_io_buffer_size(io_buf_sz);
2,014✔
45
      }
46

47
      return;
2,036✔
48
   }
49
#endif
50

51
#if defined(BOTAN_HAS_TLS_12)
52
   if(max_version.is_pre_tls_13()) {
520✔
53
      m_impl = std::make_unique<Server_Impl_12>(callbacks, session_manager, creds, policy, rng, is_datagram, io_buf_sz);
520✔
54
      return;
520✔
55
   }
56
#endif
57

58
   BOTAN_UNUSED(max_version, callbacks, session_manager, creds, policy, rng, is_datagram, io_buf_sz);
×
59
   throw Not_Implemented("Requested TLS server version is not available in this build");
×
60
}
×
61

62
Server::~Server() = default;
3,962✔
63

64
size_t Server::from_peer(std::span<const uint8_t> data) {
118,878✔
65
   auto read = m_impl->from_peer(data);
118,878✔
66

67
#if defined(BOTAN_HAS_TLS_12)
68
   // If TLS 1.2 is not available, we will never downgrade, the downgrade info
69
   // won't even be created and `is_downgrading()` would always return false.
70
   if(m_impl->is_downgrading()) {
117,473✔
71
      auto info = m_impl->extract_downgrade_info();
503✔
72
      m_impl = std::make_unique<Server_Impl_12>(*info);
1,006✔
73

74
      // replay peer data received so far
75
      read = m_impl->from_peer(info->peer_transcript);
503✔
76
   }
503✔
77
#endif
78

79
   return read;
117,449✔
80
}
81

82
bool Server::is_handshake_complete() const {
169✔
83
   return m_impl->is_handshake_complete();
169✔
84
}
85

86
bool Server::is_active() const {
2,159✔
87
   return m_impl->is_active();
2,159✔
88
}
89

90
bool Server::is_closed() const {
223✔
91
   return m_impl->is_closed();
223✔
92
}
93

94
bool Server::is_closed_for_reading() const {
×
95
   return m_impl->is_closed_for_reading();
×
96
}
97

98
bool Server::is_closed_for_writing() const {
×
99
   return m_impl->is_closed_for_writing();
×
100
}
101

102
std::vector<X509_Certificate> Server::peer_cert_chain() const {
123✔
103
   return m_impl->peer_cert_chain();
123✔
104
}
105

106
std::shared_ptr<const Public_Key> Server::peer_raw_public_key() const {
1✔
107
   return m_impl->peer_raw_public_key();
1✔
108
}
109

110
std::optional<std::string> Server::external_psk_identity() const {
×
111
   return m_impl->external_psk_identity();
×
112
}
113

114
SymmetricKey Server::key_material_export(std::string_view label, std::string_view context, size_t length) const {
204✔
115
   return m_impl->key_material_export(label, context, length);
204✔
116
}
117

118
void Server::renegotiate(bool force_full_renegotiation) {
×
119
   m_impl->renegotiate(force_full_renegotiation);
×
120
}
×
121

122
bool Server::new_session_ticket_supported() const {
×
123
   return m_impl->new_session_ticket_supported();
×
124
}
125

126
size_t Server::send_new_session_tickets(const size_t tickets) {
1✔
127
   return m_impl->send_new_session_tickets(tickets);
1✔
128
}
129

130
void Server::update_traffic_keys(bool request_peer_update) {
1✔
131
   m_impl->update_traffic_keys(request_peer_update);
1✔
132
}
1✔
133

134
bool Server::secure_renegotiation_supported() const {
×
135
   return m_impl->secure_renegotiation_supported();
×
136
}
137

138
void Server::to_peer(std::span<const uint8_t> data) {
1,244✔
139
   m_impl->to_peer(data);
1,244✔
140
}
1,244✔
141

142
void Server::send_alert(const Alert& alert) {
914✔
143
   m_impl->send_alert(alert);
914✔
144
}
914✔
145

146
void Server::send_warning_alert(Alert::Type type) {
126✔
147
   m_impl->send_warning_alert(type);
126✔
148
}
126✔
149

150
void Server::send_fatal_alert(Alert::Type type) {
×
151
   m_impl->send_fatal_alert(type);
×
152
}
×
153

154
void Server::close() {
48✔
155
   m_impl->close();
48✔
156
}
48✔
157

158
bool Server::timeout_check() {
×
159
   return m_impl->timeout_check();
×
160
}
161

162
std::string Server::application_protocol() const {
1,053✔
163
   return m_impl->application_protocol();
1,053✔
164
}
165
}  // namespace Botan::TLS
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc