Botan 3.4.0
Crypto and TLS for C&
tls_server.h
Go to the documentation of this file.
1/*
2* TLS Server
3* (C) 2004-2011 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#ifndef BOTAN_TLS_SERVER_H_
12#define BOTAN_TLS_SERVER_H_
13
14#include <botan/credentials_manager.h>
15#include <botan/tls_channel.h>
16#include <botan/tls_policy.h>
17#include <vector>
18
19namespace Botan::TLS {
20
21class Channel_Impl;
22
23/**
24* TLS Server
25*/
26class BOTAN_PUBLIC_API(2, 0) Server final : public Channel {
27 public:
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 Server(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 ~Server() override;
58
59 /**
60 * Return the protocol notification set by the client (using the
61 * ALPN extension) for this connection, if any. This value is not
62 * tied to the session and a later renegotiation of the same
63 * session can choose a new protocol.
64 */
65 std::string application_protocol() const override;
66
67 size_t from_peer(std::span<const uint8_t> data) override;
68
69 bool is_handshake_complete() const override;
70
71 bool is_active() const override;
72
73 bool is_closed() const override;
74
75 bool is_closed_for_reading() const override;
76 bool is_closed_for_writing() const override;
77
78 std::vector<X509_Certificate> peer_cert_chain() const override;
79 std::shared_ptr<const Public_Key> peer_raw_public_key() const override;
80 std::optional<std::string> external_psk_identity() const override;
81
82 SymmetricKey key_material_export(std::string_view label, std::string_view context, size_t length) const override;
83
84 void renegotiate(bool force_full_renegotiation = false) override;
85
86 bool new_session_ticket_supported() const;
87 size_t send_new_session_tickets(size_t tickets = 1);
88
89 void update_traffic_keys(bool request_peer_update = false) override;
90
91 bool secure_renegotiation_supported() const override;
92
93 void to_peer(std::span<const uint8_t> data) override;
94
95 void send_alert(const Alert& alert) override;
96
97 void send_warning_alert(Alert::Type type) override;
98
99 void send_fatal_alert(Alert::Type type) override;
100
101 void close() override;
102
103 bool timeout_check() override;
104
105 private:
106 std::unique_ptr<Channel_Impl> m_impl;
107};
108} // namespace Botan::TLS
109
110#endif
~Server() override
int(* final)(unsigned char *, CTX *)
#define BOTAN_PUBLIC_API(maj, min)
Definition compiler.h:31