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