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

randombit / botan / 19012754211

02 Nov 2025 01:10PM UTC coverage: 90.677% (+0.006%) from 90.671%
19012754211

push

github

web-flow
Merge pull request #5137 from randombit/jack/clang-tidy-includes

Remove various unused includes flagged by clang-tidy misc-include-cleaner

100457 of 110786 relevant lines covered (90.68%)

12189873.8 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/internal/tls_handshake_state.h>
15

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

21
namespace Botan::TLS {
22

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

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

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

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

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

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

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

63
   return read;
114,917✔
64
}
65

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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