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

randombit / botan / 5079590438

25 May 2023 12:28PM UTC coverage: 92.228% (+0.5%) from 91.723%
5079590438

Pull #3502

github

Pull Request #3502: Apply clang-format to the codebase

75589 of 81959 relevant lines covered (92.23%)

12139530.51 hits per line

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

83.78
/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_magic.h>
14
#include <botan/tls_messages.h>
15
#include <botan/internal/stl_util.h>
16
#include <botan/internal/tls_handshake_state.h>
17

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

23
namespace Botan::TLS {
24

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

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

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

52
Server::~Server() = default;
3,806✔
53

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

57
   if(m_impl->is_downgrading()) {
81,997✔
58
      auto info = m_impl->extract_downgrade_info();
472✔
59
      m_impl = std::make_unique<Server_Impl_12>(*info);
944✔
60

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

65
   return read;
81,976✔
66
}
67

68
bool Server::is_active() const { return m_impl->is_active(); }
2,134✔
69

70
bool Server::is_closed() const { return m_impl->is_closed(); }
179✔
71

72
bool Server::is_closed_for_reading() const { return m_impl->is_closed_for_reading(); }
×
73

74
bool Server::is_closed_for_writing() const { return m_impl->is_closed_for_writing(); }
11✔
75

76
std::vector<X509_Certificate> Server::peer_cert_chain() const { return m_impl->peer_cert_chain(); }
118✔
77

78
SymmetricKey Server::key_material_export(std::string_view label, std::string_view context, size_t length) const {
202✔
79
   return m_impl->key_material_export(label, context, length);
202✔
80
}
81

82
void Server::renegotiate(bool force_full_renegotiation) { m_impl->renegotiate(force_full_renegotiation); }
×
83

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

86
size_t Server::send_new_session_tickets(const size_t tickets) { return m_impl->send_new_session_tickets(tickets); }
1✔
87

88
void Server::update_traffic_keys(bool request_peer_update) { m_impl->update_traffic_keys(request_peer_update); }
1✔
89

90
bool Server::secure_renegotiation_supported() const { return m_impl->secure_renegotiation_supported(); }
×
91

92
void Server::to_peer(std::span<const uint8_t> data) { m_impl->to_peer(data); }
1,235✔
93

94
void Server::send_alert(const Alert& alert) { m_impl->send_alert(alert); }
890✔
95

96
void Server::send_warning_alert(Alert::Type type) { m_impl->send_warning_alert(type); }
122✔
97

98
void Server::send_fatal_alert(Alert::Type type) { m_impl->send_fatal_alert(type); }
×
99

100
void Server::close() { m_impl->close(); }
50✔
101

102
bool Server::timeout_check() { return m_impl->timeout_check(); }
×
103

104
std::string Server::application_protocol() const { return m_impl->application_protocol(); }
1,025✔
105
}
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