Coverage Report

Created: 2022-06-23 06:44

/src/botan/build/include/botan/internal/tls_server_impl_12.h
Line
Count
Source (jump to first uncovered line)
1
/*
2
* TLS Server - implementation for TLS 1.2
3
* (C) 2004-2011 Jack Lloyd
4
*     2016 Matthias Gierlings
5
*
6
* Botan is released under the Simplified BSD License (see license.txt)
7
*/
8
9
#ifndef BOTAN_TLS_SERVER_IMPL_12_H_
10
#define BOTAN_TLS_SERVER_IMPL_12_H_
11
12
#include <botan/tls_policy.h>
13
#include <botan/credentials_manager.h>
14
#include <botan/internal/tls_channel_impl_12.h>
15
#include <botan/internal/tls_server_impl.h>
16
#include <vector>
17
18
namespace Botan {
19
20
namespace TLS {
21
22
class Server_Handshake_State;
23
24
25
/**
26
* SSL/TLS Server 1.2 implementation
27
*/
28
class Server_Impl_12 : public Channel_Impl_12, public Server_Impl
29
   {
30
   public:
31
      typedef std::function<std::string(std::vector<std::string>)> next_protocol_fn;
32
33
      /**
34
      * Server initialization
35
      *
36
      * @param callbacks contains a set of callback function references
37
      *        required by the TLS server.
38
      *
39
      * @param session_manager manages session state
40
      *
41
      * @param creds manages application/user credentials
42
      *
43
      * @param policy specifies other connection policy information
44
      *
45
      * @param rng a random number generator
46
      *
47
      * @param is_datagram set to true if this server should expect DTLS
48
      *        connections. Otherwise TLS connections are expected.
49
      *
50
      * @param reserved_io_buffer_size This many bytes of memory will
51
      *        be preallocated for the read and write buffers. Smaller
52
      *        values just mean reallocations and copies are more likely.
53
      */
54
      explicit Server_Impl_12(Callbacks& callbacks,
55
                              Session_Manager& session_manager,
56
                              Credentials_Manager& creds,
57
                              const Policy& policy,
58
                              RandomNumberGenerator& rng,
59
                              bool is_datagram = false,
60
                              size_t reserved_io_buffer_size = TLS::Channel::IO_BUF_DEFAULT_SIZE);
61
   private:
62
      /**
63
      * Return the protocol notification set by the client (using the
64
      * ALPN extension) for this connection, if any. This value is not
65
      * tied to the session and a later renegotiation of the same
66
      * session can choose a new protocol.
67
      */
68
0
      std::string next_protocol() const override { return m_next_protocol; }
69
70
      /**
71
      * Return the protocol notification set by the client (using the
72
      * ALPN extension) for this connection, if any. This value is not
73
      * tied to the session and a later renegotiation of the same
74
      * session can choose a new protocol.
75
      */
76
0
      std::string application_protocol() const override { return m_next_protocol; }
77
78
      std::vector<X509_Certificate>
79
      get_peer_cert_chain(const Handshake_State& state) const override;
80
81
      void initiate_handshake(Handshake_State& state,
82
                              bool force_full_renegotiation) override;
83
84
      void process_handshake_msg(const Handshake_State* active_state,
85
                                 Handshake_State& pending_state,
86
                                 Handshake_Type type,
87
                                 const std::vector<uint8_t>& contents,
88
                                 bool epoch0_restart) override;
89
90
      void process_client_hello_msg(const Handshake_State* active_state,
91
                                    Server_Handshake_State& pending_state,
92
                                    const std::vector<uint8_t>& contents,
93
                                    bool epoch0_restart);
94
95
      void process_certificate_msg(Server_Handshake_State& pending_state,
96
                                   const std::vector<uint8_t>& contents);
97
98
      void process_client_key_exchange_msg(Server_Handshake_State& pending_state,
99
                                           const std::vector<uint8_t>& contents);
100
101
      void process_change_cipher_spec_msg(Server_Handshake_State& pending_state);
102
103
      void process_certificate_verify_msg(Server_Handshake_State& pending_state,
104
                                          Handshake_Type type,
105
                                          const std::vector<uint8_t>& contents);
106
107
      void process_finished_msg(Server_Handshake_State& pending_state,
108
                                Handshake_Type type,
109
                                const std::vector<uint8_t>& contents);
110
111
      void session_resume(Server_Handshake_State& pending_state,
112
                          bool have_session_ticket_key,
113
                          Session& session_info);
114
115
      void session_create(Server_Handshake_State& pending_state,
116
                          bool have_session_ticket_key);
117
118
      std::unique_ptr<Handshake_State> new_handshake_state(std::unique_ptr<Handshake_IO> io) override;
119
120
      Credentials_Manager& m_creds;
121
      std::string m_next_protocol;
122
123
      // Set by deprecated constructor, Server calls both this fn and Callbacks version
124
      next_protocol_fn m_choose_next_protocol;
125
   };
126
127
}
128
129
}
130
131
#endif