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

randombit / botan / 20300409060

17 Dec 2025 10:55AM UTC coverage: 90.526% (+0.2%) from 90.36%
20300409060

Pull #5167

github

web-flow
Merge b37a2cfb3 into 3d96b675e
Pull Request #5167: Changes to reduce unnecessary inclusions

101175 of 111763 relevant lines covered (90.53%)

12570909.12 hits per line

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

73.13
/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_messages.h>
14
#include <botan/tls_policy.h>
15
#include <botan/internal/tls_handshake_state.h>
16
#include <botan/internal/tls_server_impl_12.h>
17

18
#if defined(BOTAN_HAS_TLS_13)
19
   #include <botan/internal/tls_server_impl_13.h>
20
#endif
21

22
namespace Botan::TLS {
23

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

36
   if(!max_version.is_pre_tls_13()) {
2,555✔
37
#if defined(BOTAN_HAS_TLS_13)
38
      m_impl = std::make_unique<Server_Impl_13>(callbacks, session_manager, creds, policy, rng);
2,036✔
39

40
      if(m_impl->expects_downgrade()) {
2,036✔
41
         m_impl->set_io_buffer_size(io_buf_sz);
2,014✔
42
      }
43
#else
44
      throw Not_Implemented("TLS 1.3 server is not available in this build");
45
#endif
46
   } else {
47
      m_impl = std::make_unique<Server_Impl_12>(callbacks, session_manager, creds, policy, rng, is_datagram, io_buf_sz);
519✔
48
   }
49
}
2,555✔
50

51
Server::~Server() = default;
3,960✔
52

53
size_t Server::from_peer(std::span<const uint8_t> data) {
117,123✔
54
   auto read = m_impl->from_peer(data);
117,123✔
55

56
   if(m_impl->is_downgrading()) {
115,718✔
57
      auto info = m_impl->extract_downgrade_info();
503✔
58
      m_impl = std::make_unique<Server_Impl_12>(*info);
1,006✔
59

60
      // replay peer data received so far
61
      read = m_impl->from_peer(info->peer_transcript);
503✔
62
   }
503✔
63

64
   return read;
115,694✔
65
}
66

67
bool Server::is_handshake_complete() const {
169✔
68
   return m_impl->is_handshake_complete();
169✔
69
}
70

71
bool Server::is_active() const {
2,152✔
72
   return m_impl->is_active();
2,152✔
73
}
74

75
bool Server::is_closed() const {
218✔
76
   return m_impl->is_closed();
218✔
77
}
78

79
bool Server::is_closed_for_reading() const {
×
80
   return m_impl->is_closed_for_reading();
×
81
}
82

83
bool Server::is_closed_for_writing() const {
×
84
   return m_impl->is_closed_for_writing();
×
85
}
86

87
std::vector<X509_Certificate> Server::peer_cert_chain() const {
122✔
88
   return m_impl->peer_cert_chain();
122✔
89
}
90

91
std::shared_ptr<const Public_Key> Server::peer_raw_public_key() const {
1✔
92
   return m_impl->peer_raw_public_key();
1✔
93
}
94

95
std::optional<std::string> Server::external_psk_identity() const {
×
96
   return m_impl->external_psk_identity();
×
97
}
98

99
SymmetricKey Server::key_material_export(std::string_view label, std::string_view context, size_t length) const {
203✔
100
   return m_impl->key_material_export(label, context, length);
203✔
101
}
102

103
void Server::renegotiate(bool force_full_renegotiation) {
×
104
   m_impl->renegotiate(force_full_renegotiation);
×
105
}
×
106

107
bool Server::new_session_ticket_supported() const {
×
108
   return m_impl->new_session_ticket_supported();
×
109
}
110

111
size_t Server::send_new_session_tickets(const size_t tickets) {
1✔
112
   return m_impl->send_new_session_tickets(tickets);
1✔
113
}
114

115
void Server::update_traffic_keys(bool request_peer_update) {
1✔
116
   m_impl->update_traffic_keys(request_peer_update);
1✔
117
}
1✔
118

119
bool Server::secure_renegotiation_supported() const {
×
120
   return m_impl->secure_renegotiation_supported();
×
121
}
122

123
void Server::to_peer(std::span<const uint8_t> data) {
1,243✔
124
   m_impl->to_peer(data);
1,243✔
125
}
1,243✔
126

127
void Server::send_alert(const Alert& alert) {
914✔
128
   m_impl->send_alert(alert);
914✔
129
}
914✔
130

131
void Server::send_warning_alert(Alert::Type type) {
125✔
132
   m_impl->send_warning_alert(type);
125✔
133
}
125✔
134

135
void Server::send_fatal_alert(Alert::Type type) {
×
136
   m_impl->send_fatal_alert(type);
×
137
}
×
138

139
void Server::close() {
48✔
140
   m_impl->close();
48✔
141
}
48✔
142

143
bool Server::timeout_check() {
×
144
   return m_impl->timeout_check();
×
145
}
146

147
std::string Server::application_protocol() const {
1,052✔
148
   return m_impl->application_protocol();
1,052✔
149
}
150
}  // 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