Botan 3.6.1
Crypto and TLS for C&
tls_server_impl_12.h
Go to the documentation of this file.
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/credentials_manager.h>
13#include <botan/tls_policy.h>
14#include <botan/internal/tls_channel_impl_12.h>
15#include <vector>
16
17namespace Botan::TLS {
18
19class Server_Handshake_State;
20
21/**
22* SSL/TLS Server 1.2 implementation
23*/
25 public:
26 typedef std::function<std::string(std::vector<std::string>)> next_protocol_fn;
27
28 /**
29 * Server initialization
30 *
31 * @param callbacks contains a set of callback function references
32 * required by the TLS server.
33 *
34 * @param session_manager manages session state
35 *
36 * @param creds manages application/user credentials
37 *
38 * @param policy specifies other connection policy information
39 *
40 * @param rng a random number generator
41 *
42 * @param is_datagram set to true if this server should expect DTLS
43 * connections. Otherwise TLS connections are expected.
44 *
45 * @param reserved_io_buffer_size This many bytes of memory will
46 * be preallocated for the read and write buffers. Smaller
47 * values just mean reallocations and copies are more likely.
48 */
49 explicit Server_Impl_12(const std::shared_ptr<Callbacks>& callbacks,
50 const std::shared_ptr<Session_Manager>& session_manager,
51 const std::shared_ptr<Credentials_Manager>& creds,
52 const std::shared_ptr<const Policy>& policy,
53 const std::shared_ptr<RandomNumberGenerator>& rng,
54 bool is_datagram = false,
55 size_t reserved_io_buffer_size = TLS::Channel::IO_BUF_DEFAULT_SIZE);
56
57 explicit Server_Impl_12(const Channel_Impl::Downgrade_Information& downgrade_info);
58
59 private:
60 /**
61 * Return the protocol notification set by the client (using the
62 * ALPN extension) for this connection, if any. This value is not
63 * tied to the session and a later renegotiation of the same
64 * session can choose a new protocol.
65 */
66 std::string application_protocol() const override { return m_next_protocol; }
67
68 std::vector<X509_Certificate> get_peer_cert_chain(const Handshake_State& state) const override;
69
70 void initiate_handshake(Handshake_State& state, bool force_full_renegotiation) override;
71
72 void process_handshake_msg(const Handshake_State* active_state,
73 Handshake_State& pending_state,
74 Handshake_Type type,
75 const std::vector<uint8_t>& contents,
76 bool epoch0_restart) override;
77
78 void process_client_hello_msg(const Handshake_State* active_state,
79 Server_Handshake_State& pending_state,
80 const std::vector<uint8_t>& contents,
81 bool epoch0_restart);
82
83 void process_certificate_msg(Server_Handshake_State& pending_state, const std::vector<uint8_t>& contents);
84
85 void process_client_key_exchange_msg(Server_Handshake_State& pending_state, const std::vector<uint8_t>& contents);
86
87 void process_change_cipher_spec_msg(Server_Handshake_State& pending_state);
88
89 void process_certificate_verify_msg(Server_Handshake_State& pending_state,
90 Handshake_Type type,
91 const std::vector<uint8_t>& contents);
92
93 void process_finished_msg(Server_Handshake_State& pending_state,
94 Handshake_Type type,
95 const std::vector<uint8_t>& contents);
96
97 void session_resume(Server_Handshake_State& pending_state, const Session_with_Handle& session_info);
98
99 void session_create(Server_Handshake_State& pending_state);
100
101 std::unique_ptr<Handshake_State> new_handshake_state(std::unique_ptr<Handshake_IO> io) override;
102
103 std::shared_ptr<Credentials_Manager> m_creds;
104 std::string m_next_protocol;
105};
106
107} // namespace Botan::TLS
108
109#endif
RandomNumberGenerator & rng()
Session_Manager & session_manager()
const Policy & policy() const
static constexpr size_t IO_BUF_DEFAULT_SIZE
Definition tls_channel.h:32
Server_Impl_12(const std::shared_ptr< Callbacks > &callbacks, const std::shared_ptr< Session_Manager > &session_manager, const std::shared_ptr< Credentials_Manager > &creds, const std::shared_ptr< const Policy > &policy, const std::shared_ptr< RandomNumberGenerator > &rng, bool is_datagram=false, size_t reserved_io_buffer_size=TLS::Channel::IO_BUF_DEFAULT_SIZE)
std::function< std::string(std::vector< std::string >)> next_protocol_fn