Botan 3.14.1
Crypto and TLS for C&
tls_server_impl_12.cpp
Go to the documentation of this file.
1/*
2* TLS Server
3* (C) 2004-2011,2012,2016 Jack Lloyd
4* 2016 Matthias Gierlings
5*
6* Botan is released under the Simplified BSD License (see license.txt)
7*/
8
9#include <botan/internal/tls_server_impl_12.h>
10
11#include <botan/certstor.h>
12#include <botan/ec_group.h>
13#include <botan/ecc_key.h>
14#include <botan/ocsp.h>
15#include <botan/tls_callbacks.h>
16#include <botan/tls_magic.h>
17#include <botan/tls_messages_12.h>
18#include <botan/tls_policy.h>
19#include <botan/tls_version.h>
20#include <botan/internal/ct_utils.h>
21#include <botan/internal/stl_util.h>
22#include <botan/internal/tls_handshake_state.h>
23#include <botan/internal/tls_messages_internal.h>
24#include <algorithm>
25#include <limits>
26#include <optional>
27#include <unordered_set>
28#include <utility>
29
30namespace Botan::TLS {
31
32class Server_Handshake_State final : public Handshake_State {
33 public:
34 Server_Handshake_State(std::unique_ptr<Handshake_IO> io, Callbacks& cb) : Handshake_State(std::move(io), cb) {}
35
36 Private_Key* server_rsa_kex_key() { return m_server_rsa_kex_key.get(); }
37
38 void set_server_rsa_kex_key(std::shared_ptr<Private_Key> key) { m_server_rsa_kex_key = std::move(key); }
39
40 bool allow_session_resumption() const { return m_allow_session_resumption; }
41
42 void set_allow_session_resumption(bool allow_session_resumption) {
43 m_allow_session_resumption = allow_session_resumption;
44 }
45
46 const std::vector<X509_Certificate>& resume_peer_certs() const { return m_resume_peer_certs; }
47
48 void set_resume_certs(const std::vector<X509_Certificate>& certs) { m_resume_peer_certs = certs; }
49
50 void mark_as_resumption() { m_is_a_resumption = true; }
51
52 // Set if this renegotiation was requested by our HelloRequest
53 void mark_as_server_initiated() { m_server_initiated = true; }
54
55 bool is_server_initiated() const { return m_server_initiated; }
56
57 bool is_a_resumption() const { return m_is_a_resumption; }
58
59 void set_resumption_summary(Session_Summary summary) { m_resumption_summary = std::move(summary); }
60
61 std::optional<Session_Summary> take_resumption_summary() { return std::exchange(m_resumption_summary, {}); }
62
63 std::vector<X509_Certificate> peer_cert_chain() const override {
64 if(!m_resume_peer_certs.empty()) {
65 return m_resume_peer_certs;
66 }
67 if(has_client_certs()) {
68 return client_certs().cert_chain();
69 }
70 return {};
71 }
72
73 private:
74 // Used by the server only, in case of RSA key exchange.
75 std::shared_ptr<Private_Key> m_server_rsa_kex_key;
76
77 /*
78 * Used by the server to know if resumption should be allowed on
79 * a server-initiated renegotiation
80 */
81 bool m_allow_session_resumption = true;
82
83 bool m_is_a_resumption = false;
84
85 bool m_server_initiated = false;
86
87 std::vector<X509_Certificate> m_resume_peer_certs;
88
89 // Reported once the client's Finished proved possession of the session
90 std::optional<Session_Summary> m_resumption_summary;
91};
92
93namespace {
94
95/*
96* RFC 5077 3.3: the ticket_lifetime_hint is a 32-bit value, where zero
97* means that the lifetime is unspecified
98*/
99uint32_t ticket_lifetime_hint(const Policy& policy) {
100 const auto lifetime = policy.session_ticket_lifetime().count();
101 if(lifetime <= 0) {
102 return 0;
103 }
104 return static_cast<uint32_t>(std::min<std::chrono::seconds::rep>(lifetime, std::numeric_limits<uint32_t>::max()));
105}
106
107std::optional<Session> check_for_resume(const Session_Handle& handle_to_resume,
108 Session_Manager& session_manager,
109 Callbacks& cb,
110 const Policy& policy,
111 const Client_Hello_12* client_hello) {
112 auto session = session_manager.retrieve(handle_to_resume, cb, policy);
113 if(!session.has_value()) {
114 return std::nullopt;
115 }
116
117 // A session manager shared with our client role must not resume a session
118 // here that we stored as a client: its peer certificates are a remote
119 // server's, and this connection would adopt them as the client's. The
120 // session manager must never hand out such a session to a server.
121 if(session->side() != Connection_Side::Server) {
122 throw TLS_Exception(Alert::InternalError,
123 "Session manager returned a session stored by a TLS client for server-side resumption");
124 }
125
126 // wrong version
127 if(client_hello->legacy_version() != session->version()) {
128 return std::nullopt;
129 }
130
131 // client didn't send original ciphersuite
132 if(!value_exists(client_hello->ciphersuites(), session->ciphersuite_code())) {
133 return std::nullopt;
134 }
135
136 // the current policy no longer allows the session's ciphersuite
137 if(!value_exists(policy.ciphersuite_list(session->version()), session->ciphersuite_code())) {
138 return std::nullopt;
139 }
140
141 // client sent a different SNI hostname
142 if(!client_hello->sni_hostname().empty() && client_hello->sni_hostname() != session->server_info().hostname()) {
143 return std::nullopt;
144 }
145
146 // An abbreviated handshake cannot authenticate the client; fall back to a
147 // full handshake if the current policy requires client authentication but
148 // the session does not contain a client credential
149 if(policy.require_client_certificate_authentication() && !session->peer_credential_type().has_value()) {
150 return std::nullopt;
151 }
152
153 // Checking extended_master_secret on resume (RFC 7627 section 5.3)
154 if(client_hello->supports_extended_master_secret() != session->supports_extended_master_secret()) {
155 if(!session->supports_extended_master_secret()) {
156 return std::nullopt; // force new handshake with extended master secret
157 } else {
158 /*
159 Client previously negotiated session with extended master secret,
160 but has now attempted to resume without the extension: abort
161 */
162 throw TLS_Exception(Alert::HandshakeFailure, "Client resumed extended ms session without sending extension");
163 }
164 }
165
166 // Checking encrypt_then_mac on resume (RFC 7366 section 3.1)
167 if(!client_hello->supports_encrypt_then_mac() && session->supports_encrypt_then_mac()) {
168 /*
169 Client previously negotiated session with Encrypt-then-MAC,
170 but has now attempted to resume without the extension: abort
171 */
172 throw TLS_Exception(Alert::HandshakeFailure, "Client resumed Encrypt-then-MAC session without sending extension");
173 }
174
175 // The resumed connection would silently lose the DTLS-SRTP profile of the
176 // session, or use one that the current policy no longer allows
177 if(const uint16_t srtp_profile = session->dtls_srtp_profile()) {
178 if(!value_exists(client_hello->srtp_profiles(), srtp_profile) ||
179 !value_exists(policy.srtp_profiles(), srtp_profile)) {
180 return std::nullopt;
181 }
182 }
183
184 return session;
185}
186
187/*
188* Choose which ciphersuite to use
189*/
190uint16_t choose_ciphersuite(const Policy& policy,
191 Protocol_Version version,
192 const std::map<std::string, std::vector<X509_Certificate>>& cert_chains,
193 const Client_Hello_12& client_hello) {
194 const bool our_choice = policy.server_uses_own_ciphersuite_preferences();
195 const std::vector<uint16_t>& client_suites = client_hello.ciphersuites();
196 const std::vector<uint16_t> server_suites = policy.ciphersuite_list(version);
197
198 if(server_suites.empty()) {
199 throw TLS_Exception(Alert::HandshakeFailure, "Policy forbids us from negotiating any ciphersuite");
200 }
201
202 const bool have_shared_ecc_curve =
203 (policy.choose_key_exchange_group(
204 groups_usable_in_version(client_hello.supported_ecc_curves(), Protocol_Version::TLS_V12), {}) !=
205 Group_Params::NONE);
206
207 // RFC 8422 5.1
208 // NOTE: A server participating in an ECDHE_ECDSA key exchange may use
209 // different curves for the ECDSA or EdDSA key in its certificate and
210 // for the ephemeral ECDH key in the ServerKeyExchange message. The
211 // server MUST consider the extensions in both cases.
212 const bool client_supports_ecdsa_cert_curve = [&] {
213 const auto chain = cert_chains.find("ECDSA");
214 if(chain == cert_chains.end() || chain->second.empty()) {
215 return false;
216 }
217 const auto key = chain->second.front().subject_public_key();
218 const auto* ec_key = dynamic_cast<const EC_PublicKey*>(key.get());
219 if(ec_key == nullptr) {
220 return false;
221 }
222 const auto group = Group_Params::from_string(ec_key->domain().get_curve_oid().human_name_or_empty());
223 // The client cannot offer an application specific curve, which has no TLS code point
224 if(!group.has_value()) {
225 return true;
226 }
227 return value_exists(client_hello.supported_ecc_curves(), group.value());
228 }();
229
230 const bool client_supports_ffdhe_groups = !client_hello.supported_dh_groups().empty();
231
232 const bool have_shared_dh_group =
233 (policy.choose_key_exchange_group(client_hello.supported_dh_groups(), {}) != Group_Params::NONE);
234
235 const std::unordered_set<uint16_t> client_suite_set(client_suites.begin(), client_suites.end());
236
237 // PSK suites omit CertificateRequest entirely, so they cannot satisfy a
238 // policy that requires client certificate authentication
239 const bool require_client_cert = policy.require_client_certificate_authentication();
240
241 const std::vector<Signature_Scheme> allowed_sig_schemes = policy.allowed_signature_schemes();
242 const std::vector<Signature_Scheme> client_sig_methods = client_hello.signature_schemes();
243
244 // Algorithm names (eg "RSA", "ECDSA") for which the client offered at least
245 // one signature_scheme that is available, is in our policy, and uses a hash we accept.
246 const std::unordered_set<std::string> client_sig_algs = [&] {
247 std::unordered_set<uint16_t> allowed_codes;
248 allowed_codes.reserve(allowed_sig_schemes.size());
249 for(const auto s : allowed_sig_schemes) {
250 allowed_codes.insert(static_cast<uint16_t>(s.wire_code()));
251 }
252 std::unordered_set<std::string> result;
253 for(const Signature_Scheme scheme : client_sig_methods) {
254 if(!scheme.is_available() || !scheme.is_compatible_with(Protocol_Version::TLS_V12)) {
255 continue;
256 }
257 if(!allowed_codes.contains(static_cast<uint16_t>(scheme.wire_code()))) {
258 continue;
259 }
260 if(!policy.allowed_signature_hash(scheme.hash_function_name())) {
261 continue;
262 }
263 result.insert(scheme.algorithm_name());
264 }
265 return result;
266 }();
267
268 /*
269 Walk down one list in preference order
270 */
271 const std::vector<uint16_t>& pref_list = our_choice ? server_suites : client_suites;
272
273 const auto in_other_list = [&](uint16_t suite_id) {
274 // server_suites is small and policy-controlled
275 return our_choice ? client_suite_set.contains(suite_id) : value_exists(server_suites, suite_id);
276 };
277
278 for(const auto suite_id : pref_list) {
279 if(!in_other_list(suite_id)) {
280 continue;
281 }
282
283 const auto suite = Ciphersuite::by_id(suite_id);
284
285 if(!suite.has_value() || !suite->valid()) {
286 continue;
287 }
288
289 if(have_shared_ecc_curve == false && suite->ecc_ciphersuite()) {
290 continue;
291 }
292
293 if(suite->kex_method() == Kex_Algo::DH && client_supports_ffdhe_groups && !have_shared_dh_group) {
294 continue;
295 }
296
297 if(require_client_cert && !suite->is_certificate_required()) {
298 continue;
299 }
300
301 // For non-anon ciphersuites
302 if(suite->is_certificate_required()) {
303 const std::string cert_algo = suite->signature_used() ? suite->sig_algo() : "RSA";
304
305 // Do we have any certificates for this sig?
306 if(!cert_chains.contains(cert_algo)) {
307 continue;
308 }
309
310 if(cert_algo == "ECDSA" && !client_supports_ecdsa_cert_curve) {
311 continue;
312 }
313 }
314
315 if(suite->signature_used()) {
316 // The client's signature_algorithms list might not include a scheme
317 // matching this suite's sig_algo (e.g. the client offered ECDSA
318 // schemes but we're considering an RSA suite). That's just a
319 // mismatch on this candidate, not a handshake-fatal condition - try
320 // the next suite. The final "Can't agree on a ciphersuite" throw
321 // below fires only if no candidate works.
322 if(!client_sig_algs.contains(suite->sig_algo())) {
323 continue;
324 }
325 }
326
327 return suite_id;
328 }
329
330 // RFC 7919 Section 4.
331 // If the [Supported Groups] extension is present
332 // with FFDHE groups, none of the client's offered groups are acceptable
333 // by the server, and none of the client's proposed non-FFDHE cipher
334 // suites are acceptable to the server, the server MUST end the
335 // connection with a fatal TLS alert of type insufficient_security(71).
336 if(client_supports_ffdhe_groups && !have_shared_dh_group) {
337 throw TLS_Exception(Alert::InsufficientSecurity, "Can't agree on a sufficiently strong ciphersuite with client");
338 }
339
340 throw TLS_Exception(Alert::HandshakeFailure, "Can't agree on a ciphersuite with client");
341}
342
343std::map<std::string, std::vector<X509_Certificate>> get_server_certs(
344 std::string_view hostname, const std::vector<Signature_Scheme>& cert_sig_schemes, Credentials_Manager& creds) {
345 const std::vector<std::string> cert_types = {"RSA", "ECDSA"};
346
347 std::map<std::string, std::vector<X509_Certificate>> cert_chains;
348
349 for(const auto& cert_type : cert_types) {
350 const std::vector<X509_Certificate> certs = creds.cert_chain_single_type(
351 cert_type, to_algorithm_identifiers(cert_sig_schemes), "tls-server", std::string(hostname));
352
353 // The credentials manager might return a chain of another type than requested
354 if(!certs.empty() && certs.front().subject_public_key()->algo_name() == cert_type) {
355 cert_chains[cert_type] = certs;
356 }
357 }
358
359 return cert_chains;
360}
361
362secure_vector<uint8_t> load_dtls_cookie_secret(Credentials_Manager& creds) {
363 auto cookie_secret = [&]() -> secure_vector<uint8_t> {
364 try {
365 return creds.psk("tls-server", "dtls-cookie-secret", "").bits_of();
366 } catch(...) {
367 return {};
368 }
369 }();
370
371 if(cookie_secret.empty()) {
372 // TODO(Botan4): Simplify this error message that was meant to ease the
373 // burden on users running into a deliberate semver violation.
374 throw Invalid_State(
375 "Since Botan 3.13 DTLS server requires setting a non-empty cookie secret. "
376 "Either override Credentials_Manager::dtls_cookie_secret() or disable the "
377 "cookie exchange using TLS::Policy::dtls_server_require_cookie_exchange(), "
378 "if you understand the security implications of doing so.");
379 }
380
381 return cookie_secret;
382}
383
384} // namespace
385
386std::shared_ptr<Server_Impl_12> Server_Impl_12::create(const std::shared_ptr<Callbacks>& callbacks,
387 const std::shared_ptr<Session_Manager>& session_manager,
388 const std::shared_ptr<Credentials_Manager>& creds,
389 const std::shared_ptr<const Policy>& policy,
390 const std::shared_ptr<RandomNumberGenerator>& rng,
392 size_t reserved_io_buffer_size) //
393{
394 auto self = std::make_shared<Server_Impl_12>(
395 Private{}, callbacks, session_manager, creds, policy, rng, flavor, reserved_io_buffer_size);
396 BOTAN_ASSERT_NONNULL(self->m_creds);
397
398 // Try to load the cookie secret on initialization, rather than waiting to fail
399 // until the first client connects.
400 if(flavor == TLS_Flavor::DTLS && policy->dtls_server_require_cookie_exchange()) {
401 load_dtls_cookie_secret(*self->m_creds);
402 }
403
404 return self;
405}
406
408 // The restart replaces an established association on the strength of an
409 // unauthenticated epoch-zero ClientHello, so it is only safe once the cookie
410 // exchange has proved the peer's reachability. RFC 6347 4.2.8 relies on the
411 // cookie for exactly this. With the cookie exchange disabled there is no such
412 // proof, so a spoofed ClientHello could otherwise tear down the association.
414}
415
416std::unique_ptr<Handshake_State> Server_Impl_12::new_handshake_state(std::unique_ptr<Handshake_IO> io) {
417 auto state = std::make_unique<Server_Handshake_State>(std::move(io), callbacks());
418 state->set_expected_next(Handshake_Type::ClientHello);
419 return state;
420}
421
422/*
423* Send a hello request to the client
424*/
425void Server_Impl_12::initiate_handshake(Handshake_State& state, bool force_full_renegotiation) {
426 auto& server_state = dynamic_cast<Server_Handshake_State&>(state);
427 server_state.set_allow_session_resumption(!force_full_renegotiation);
428 server_state.mark_as_server_initiated();
429
430 const Hello_Request hello_req(state.handshake_io());
431
432 // If the HelloRequest above gets lost (or if the peer ignores it), we
433 // retransmit it to ensure that server-initiated renegotiations are reliable.
435}
436
437namespace {
438
439Protocol_Version select_version(const TLS::Policy& policy,
440 Protocol_Version client_offer,
441 Protocol_Version active_version,
442 const std::vector<Protocol_Version>& supported_versions) {
443 const bool is_datagram = client_offer.is_datagram_protocol();
444 const bool initial_handshake = (active_version.valid() == false);
445
446 if(!supported_versions.empty()) {
447 if(is_datagram) {
448 if(policy.allow_dtls12() && value_exists(supported_versions, Protocol_Version(Protocol_Version::DTLS_V12))) {
449 return Protocol_Version::DTLS_V12;
450 }
451 throw TLS_Exception(Alert::ProtocolVersion, "No shared DTLS version");
452 } else {
453 if(policy.allow_tls12() && value_exists(supported_versions, Protocol_Version(Protocol_Version::TLS_V12))) {
454 return Protocol_Version::TLS_V12;
455 }
456 throw TLS_Exception(Alert::ProtocolVersion, "No shared TLS version");
457 }
458 }
459
460 if(!initial_handshake) {
461 /*
462 * If this is a renegotiation, and the client has offered a
463 * later version than what it initially negotiated, negotiate
464 * the old version. This matches OpenSSL's behavior. If the
465 * client is offering a version earlier than what it initially
466 * negotiated, reject as a probable attack.
467 */
468 if(active_version > client_offer) {
469 throw TLS_Exception(
470 Alert::ProtocolVersion,
471 "Client negotiated " + active_version.to_string() + " then renegotiated with " + client_offer.to_string());
472 } else {
473 return active_version;
474 }
475 }
476
477 if(is_datagram) {
478 if(policy.allow_dtls12() && client_offer >= Protocol_Version::DTLS_V12) {
479 return Protocol_Version::DTLS_V12;
480 }
481 } else {
482 if(policy.allow_tls12() && client_offer >= Protocol_Version::TLS_V12) {
483 return Protocol_Version::TLS_V12;
484 }
485 }
486
487 throw TLS_Exception(Alert::ProtocolVersion,
488 "Client version " + client_offer.to_string() + " is unacceptable by policy");
489}
490} // namespace
491
492/*
493* Process a Client Hello Message
494*/
495void Server_Impl_12::process_client_hello_msg(Server_Handshake_State& pending_state,
496 const std::vector<uint8_t>& contents,
497 bool epoch0_restart) {
498 BOTAN_ASSERT_IMPLICATION(epoch0_restart, active_state().has_value(), "Can't restart with a dead connection");
499
500 const bool initial_handshake = epoch0_restart || !active_state().has_value();
501
502 // A renegotiation that we asked for with a HelloRequest is not client initiated
503 if(initial_handshake == false && !pending_state.is_server_initiated() &&
504 policy().allow_client_initiated_renegotiation() == false) {
505 if(policy().abort_connection_on_undesired_renegotiation()) {
506 throw TLS_Exception(Alert::NoRenegotiation, "Server policy prohibits renegotiation");
507 } else {
508 send_warning_alert(Alert::NoRenegotiation);
509 }
510 return;
511 }
512
513 if(!policy().allow_insecure_renegotiation() && !(initial_handshake || secure_renegotiation_supported())) {
514 send_warning_alert(Alert::NoRenegotiation);
515 return;
516 }
517
518 if(pending_state.handshake_io().have_more_data()) {
519 // For an unauthenticated epoch-0 restart attempt, silently drop rather
520 // than alerting the active association: the trailing data may be
521 // attacker-injected garbage on the 5-tuple, and any alert here would
522 // tear down a session the peer hasn't proven it can authenticate.
523 if(epoch0_restart) {
524 return;
525 }
526 throw TLS_Exception(Alert::UnexpectedMessage, "Have data remaining in buffer after ClientHello");
527 }
528
529 pending_state.client_hello(std::make_unique<Client_Hello_12>(contents));
530 const Protocol_Version client_offer = pending_state.client_hello().legacy_version();
531 const bool datagram = client_offer.is_datagram_protocol();
532
533 const auto peer_flavor = datagram ? TLS_Flavor::DTLS : TLS_Flavor::TLS;
534 if(peer_flavor != flavor()) {
535 throw TLS_Exception(Alert::ProtocolVersion, "Client offered a version of the wrong protocol type");
536 }
537
538 if(datagram) {
539 if(client_offer.major_version() == 0xFF) {
540 throw TLS_Exception(Alert::ProtocolVersion, "Client offered DTLS version with major version 0xFF");
541 }
542 } else {
543 if(client_offer.major_version() < 3) {
544 throw TLS_Exception(Alert::ProtocolVersion, "Client offered TLS version with major version under 3");
545 }
546 if(client_offer.major_version() == 3 && client_offer.minor_version() == 0) {
547 throw TLS_Exception(Alert::ProtocolVersion, "Client offered SSLv3 which is not supported");
548 }
549 }
550
551 /*
552 * BoGo test suite expects that we will send the hello verify with a record
553 * version matching the version that is eventually negotiated. This is wrong
554 * but harmless, so go with it. Also doing the version negotiation step first
555 * allows to immediately close the connection with an alert if the client has
556 * offered a version that we are not going to negotiate anyway, instead of
557 * making them first do the cookie exchange and then telling them no.
558 *
559 * There is no issue with amplification here, since the alert is just 2 bytes.
560 */
561 const Protocol_Version negotiated_version =
562 select_version(policy(),
563 client_offer,
564 active_state().has_value() ? active_state()->version() : Protocol_Version(),
565 pending_state.client_hello().supported_versions());
566
567 pending_state.set_version(negotiated_version);
568
569 const auto compression_methods = pending_state.client_hello().compression_methods();
570 if(!value_exists(compression_methods, uint8_t(0))) {
571 throw TLS_Exception(Alert::IllegalParameter, "Client did not offer NULL compression");
572 }
573
574 if(initial_handshake && datagram && policy().dtls_server_require_cookie_exchange()) {
575 // The cookie secret is read each time to allow for refreshing the key
576 const auto cookie_secret = load_dtls_cookie_secret(*m_creds);
577
578 const std::string client_identity = callbacks().tls_peer_network_identity();
579 if(client_identity.empty()) {
580 // RFC 9147 Section 11: the cookie MUST depend on the client's address
581 //
582 // Without an application-supplied identity the cookie is reusable from
583 // any source address, defeating the whole point of the cookie exchange.
584 //
585 // TODO(Botan4): Remove the version hint about the breaking change.
586 throw Invalid_State(
587 "Since Botan 3.13 DTLS server requires tls_peer_network_identity() return a non-empty value");
588 }
589 const Hello_Verify_Request verify(
590 pending_state.client_hello().cookie_input_data(), client_identity, cookie_secret);
591
592 if(!CT::is_equal<uint8_t>(pending_state.client_hello().cookie(), verify.cookie()).as_bool()) {
593 if(epoch0_restart) {
594 pending_state.handshake_io().send_under_epoch(verify, 0);
595 } else {
596 pending_state.handshake_io().send(verify);
597 }
598
599 // Reset the ClientHello state while keeping the Datagram_Handshake_IO
600 // object alive; it is needed to detect the cookie-bearing ClientHello
601 // expected at the next sequence number. A ClientHello that never
602 // validates cannot wedge the exchange: the IO seats its sequence
603 // numbers at whichever complete ClientHello it delivers next.
604 pending_state.client_hello(nullptr);
605 pending_state.set_expected_next(Handshake_Type::ClientHello);
606
607 // RFC 6346 3.2.1
608 // Note that timeout and retransmission do not apply to the
609 // HelloVerifyRequest, because this would require creating state on
610 // the server.
611 //
612 // We don't kick-off a retransmission timer for a HelloVerifyRequest,
613 // if it gets lost in transit the client will retransmit the initial
614 // ClientHello anyway.
615 return;
616 }
617 }
618
619 secure_renegotiation_check(pending_state.maybe_client_hello(), epoch0_restart);
620
621 // RFC 7627 / RFC 9325 4.4: optionally require Extended Master Secret
622 if(policy().require_extended_master_secret() && !pending_state.client_hello().supports_extended_master_secret()) {
623 throw TLS_Exception(Alert::HandshakeFailure,
624 "Policy requires the Extended Master Secret extension but the client did not send it");
625 }
626
627 // RFC 7627 5.3 has an explicit MUST regarding EMS mismatch on resumption
628 //
629 // "If the original session used the 'extended_master_secret'
630 // extension but the new ClientHello does not contain it, the
631 // server MUST abort the abbreviated handshake."
632 //
633 // There is apparently no RFC requirement that a client must not drop EMS between the
634 // initial negotiation and a renegotiation... but there is also no RFC requirement
635 // that we must accept it. So we don't.
636 //
637 // An epoch-zero restart is not a renegotiation: the peer has lost its state and is
638 // negotiating a fresh association, so the old association's EMS choice does not bind
639 // it. Comparing against active_state() there would reject a legitimate restart.
640 if(const auto& active = active_state(); active && !epoch0_restart) {
641 const bool ems_pending = pending_state.client_hello().supports_extended_master_secret();
642 if(active->supports_extended_master_secret() == true && ems_pending == false) {
643 throw TLS_Exception(Alert::HandshakeFailure,
644 "Renegotiation ClientHello dropped the Extended Master Secret extension");
645 }
646 }
647
649 pending_state.client_hello().extensions(), Connection_Side::Client, Handshake_Type::ClientHello);
650
651 const auto session_handle = pending_state.client_hello().session_handle();
652
653 std::optional<Session> session_info;
654 if(pending_state.allow_session_resumption() && session_handle.has_value()) {
655 session_info = check_for_resume(
656 session_handle.value(), session_manager(), callbacks(), policy(), pending_state.maybe_client_hello());
657 }
658
659 m_next_protocol = "";
660 if(!initial_handshake && !pending_state.client_hello().supports_alpn()) {
661 // The application protocol is a property of the connection, which a
662 // renegotiation that does not offer ALPN does not change.
663 m_next_protocol = active_state()->application_protocol();
664 } else if(pending_state.client_hello().supports_alpn()) {
665 const auto offered = pending_state.client_hello().next_protocols();
666 m_next_protocol = callbacks().tls_server_choose_app_protocol(offered);
667 // RFC 7301 3.2: if a protocol is selected, the server MUST select one
668 // of the protocols advertised by the client. An empty return signals
669 // "no ALPN" and is allowed.
670 if(!m_next_protocol.empty() && !value_exists(offered, m_next_protocol)) {
671 throw TLS_Exception(Alert::InternalError, "Application chose an ALPN protocol that the client did not offer");
672 }
673 }
674
675 // For an epoch-0 restart the old association is discarded inside
676 // session_resume()/session_create(), at the point just before the new
677 // ServerHello is sent. Deferring it that far ensures a ClientHello that
678 // authenticates via the cookie but then fails a later check (e.g. no
679 // mutually-acceptable ciphersuite in choose_ciphersuite()) does not destroy
680 // the active session: the rollback in process_handshake_ccs() clears
681 // m_pending_state, but it cannot un-reset m_active_state.
682 if(session_info.has_value()) {
683 this->session_resume(pending_state, {session_info.value(), session_handle.value()}, epoch0_restart);
684 } else {
685 // new session
686 this->session_create(pending_state, epoch0_restart);
687 }
688
689 // We just sent our first flight that might get lost in transit. Hence, we
690 // kick-off a retransmission timer chain for users that implement the
691 // asynchronous timer callback introduced in Botan 3.14.0.
693}
694
695void Server_Impl_12::process_certificate_msg(Server_Handshake_State& pending_state,
696 const std::vector<uint8_t>& contents) {
697 pending_state.client_certs(std::make_unique<Certificate_12>(contents, policy()));
698
699 // CERTIFICATE_REQUIRED would make more sense but BoGo expects handshake failure alert
700 if(pending_state.client_certs().empty() && policy().require_client_certificate_authentication()) {
701 throw TLS_Exception(Alert::HandshakeFailure, "Policy requires client send a certificate, but it did not");
702 }
703
704 pending_state.set_expected_next(Handshake_Type::ClientKeyExchange);
705}
706
707void Server_Impl_12::process_client_key_exchange_msg(Server_Handshake_State& pending_state,
708 const std::vector<uint8_t>& contents) {
709 if(pending_state.has_client_certs() && !pending_state.client_certs().empty()) {
710 pending_state.set_expected_next(Handshake_Type::CertificateVerify);
711 } else {
712 pending_state.set_expected_next(Handshake_Type::HandshakeCCS);
713 }
714
715 pending_state.client_kex(std::make_unique<Client_Key_Exchange>(
716 contents, pending_state, pending_state.server_rsa_kex_key(), *m_creds, policy(), rng()));
717
718 pending_state.compute_session_keys();
719 if(policy().allow_ssl_key_log_file()) {
720 // draft-thomson-tls-keylogfile-00 Section 3.2
721 // An implementation of TLS 1.2 (and also earlier versions) use
722 // the label "CLIENT_RANDOM" to identify the "master" secret for
723 // the connection.
725 "CLIENT_RANDOM", pending_state.client_hello().random(), pending_state.session_keys().master_secret());
726 }
727}
728
729void Server_Impl_12::process_change_cipher_spec_msg(Server_Handshake_State& pending_state) {
730 pending_state.set_expected_next(Handshake_Type::Finished);
732}
733
734void Server_Impl_12::process_certificate_verify_msg(Server_Handshake_State& pending_state,
735 Handshake_Type type,
736 const std::vector<uint8_t>& contents) {
737 pending_state.client_verify(std::make_unique<Certificate_Verify_12>(contents));
738
739 const std::vector<X509_Certificate>& client_certs = pending_state.client_certs().cert_chain();
740
741 if(client_certs.empty()) {
742 throw TLS_Exception(Alert::DecodeError, "No client certificate sent");
743 }
744
745 const auto cert_constraints = client_certs[0].constraints();
746 if(!cert_constraints.empty()) {
747 if(!cert_constraints.includes(Key_Constraints::DigitalSignature)) {
748 throw TLS_Exception(Alert::BadCertificate, "Client certificate does not support signing");
749 }
750 }
751
752 // The chain is verified first, so that an untrusted peer cannot make us
753 // perform an expensive signature verification with a key of its choice
754 try {
755 const std::string sni_hostname = pending_state.client_hello().sni_hostname();
756 const auto trusted_CAs = m_creds->trusted_certificate_authorities("tls-server", sni_hostname);
757
758 callbacks().tls_verify_cert_chain(client_certs,
759 {}, // ocsp
760 trusted_CAs,
762 sni_hostname,
763 policy());
764 } catch(TLS_Exception&) {
765 throw;
766 } catch(std::exception& e) {
767 throw TLS_Exception(Alert::BadCertificate, e.what());
768 }
769
770 const bool sig_valid = pending_state.client_verify().verify(client_certs[0], pending_state, policy());
771
772 pending_state.hash().update(pending_state.handshake_io().format(contents, type));
773
774 /*
775 * Using DECRYPT_ERROR looks weird here, but per RFC 4346 is for
776 * "A handshake cryptographic operation failed, including being
777 * unable to correctly verify a signature, ..."
778 */
779 if(!sig_valid) {
780 throw TLS_Exception(Alert::DecryptError, "Client cert verify failed");
781 }
782
783 pending_state.set_expected_next(Handshake_Type::HandshakeCCS);
784}
785
786void Server_Impl_12::process_finished_msg(Server_Handshake_State& pending_state,
787 Handshake_Type type,
788 const std::vector<uint8_t>& contents) {
789 pending_state.set_expected_next(Handshake_Type::None);
790
791 if(pending_state.handshake_io().have_more_data()) {
792 throw TLS_Exception(Alert::UnexpectedMessage, "Have data remaining in buffer after Finished");
793 }
794
795 pending_state.client_finished(std::make_unique<Finished_12>(contents));
796
797 if(!pending_state.client_finished().verify(pending_state, Connection_Side::Client)) {
798 throw TLS_Exception(Alert::DecryptError, "Finished message didn't verify");
799 }
800
801 if(!pending_state.has_server_finished()) {
802 // already sent finished if resuming, so this is a new session
803
804 pending_state.hash().update(pending_state.handshake_io().format(contents, type));
805
806 Session session_info(pending_state.session_keys().master_secret(),
807 pending_state.server_hello().legacy_version(),
808 pending_state.server_hello().ciphersuite(),
810 pending_state.server_hello().supports_extended_master_secret(),
811 pending_state.server_hello().supports_encrypt_then_mac(),
812 pending_state.peer_cert_chain(),
813 Server_Information(pending_state.client_hello().sni_hostname()),
814 pending_state.server_hello().srtp_profile(),
815 callbacks().tls_current_timestamp());
816
817 // Give the application a chance for a final veto before fully
818 // establishing the connection.
820 Session_Summary summary(session_info, pending_state.is_a_resumption(), pending_state.psk_identity());
821 summary.set_session_id(pending_state.server_hello().session_id());
822 return summary;
823 }());
824
825 if(callbacks().tls_should_persist_resumption_information(session_info)) {
826 auto handle = session_manager().establish(session_info,
827 pending_state.server_hello().session_id(),
828 !pending_state.server_hello().supports_session_ticket());
829
830 if(pending_state.server_hello().supports_session_ticket() && handle.has_value() && handle->is_ticket()) {
831 pending_state.new_session_ticket(std::make_unique<New_Session_Ticket_12>(pending_state.handshake_io(),
832 pending_state.hash(),
833 handle->ticket().value(),
834 ticket_lifetime_hint(policy())));
835 }
836
838 }
839
840 if(!pending_state.has_new_session_ticket() && pending_state.server_hello().supports_session_ticket()) {
841 pending_state.new_session_ticket(
842 std::make_unique<New_Session_Ticket_12>(pending_state.handshake_io(), pending_state.hash()));
843 }
844
845 pending_state.handshake_io().send(Change_Cipher_Spec());
846
848
849 pending_state.server_finished(
850 std::make_unique<Finished_12>(pending_state.handshake_io(), pending_state, Connection_Side::Server));
851 } else if(auto summary = pending_state.take_resumption_summary()) {
852 // Give the application a chance for a final veto before fully
853 // establishing the resumed connection.
854 callbacks().tls_session_established(summary.value());
855 }
856
858}
859
860/*
861* Process a handshake message
862*/
863void Server_Impl_12::process_handshake_msg(Handshake_State& state_base,
864 Handshake_Type type,
865 const std::vector<uint8_t>& contents,
866 bool epoch0_restart) {
867 Server_Handshake_State& state = dynamic_cast<Server_Handshake_State&>(state_base);
868 state.confirm_transition_to(type);
869
870 /*
871 * The change cipher spec message isn't technically a handshake
872 * message so it's not included in the hash. The finished and
873 * certificate verify messages are verified based on the current
874 * state of the hash *before* this message so we delay adding them
875 * to the hash computation until we've processed them below.
876 */
879 state.hash().update(state.handshake_io().format(contents, type));
880 }
881
882 switch(type) {
884 return this->process_client_hello_msg(state, contents, epoch0_restart);
885
887 return this->process_certificate_msg(state, contents);
888
890 return this->process_client_key_exchange_msg(state, contents);
891
893 return this->process_certificate_verify_msg(state, type, contents);
894
896 return this->process_change_cipher_spec_msg(state);
897
899 return this->process_finished_msg(state, type, contents);
900
901 default:
902 throw Unexpected_Message("Unknown handshake message received");
903 }
904}
905
906void Server_Impl_12::session_resume(Server_Handshake_State& pending_state,
907 const Session_with_Handle& session,
908 bool epoch0_restart) {
909 // Only offer a resuming client a new ticket if they didn't send one this time,
910 // ie, resumed via server-side resumption. TODO: also send one if expiring soon?
911
912 const bool offer_new_session_ticket = pending_state.client_hello().supports_session_ticket() &&
913 pending_state.client_hello().session_ticket().empty() &&
915
916 // Commit point for a DTLS epoch-0 restart; see the comment in
917 // session_create() for the rationale.
918 if(epoch0_restart) {
920 }
921
922 pending_state.server_hello(std::make_unique<Server_Hello_12>(pending_state.handshake_io(),
923 pending_state.hash(),
924 policy(),
925 callbacks(),
926 rng(),
928 pending_state.client_hello(),
929 session.session,
930 offer_new_session_ticket,
931 m_next_protocol,
932 flavor()));
933
934 secure_renegotiation_check(pending_state.maybe_server_hello());
935
936 pending_state.mark_as_resumption();
937 pending_state.compute_session_keys(session.session.master_secret());
938 if(policy().allow_ssl_key_log_file()) {
939 // draft-thomson-tls-keylogfile-00 Section 3.2
940 // An implementation of TLS 1.2 (and also earlier versions) use
941 // the label "CLIENT_RANDOM" to identify the "master" secret for
942 // the connection.
944 "CLIENT_RANDOM", pending_state.client_hello().random(), pending_state.session_keys().master_secret());
945 }
946 pending_state.set_resume_certs(session.session.peer_certs());
947
948 // The application is given the chance for a final veto once the client's
949 // Finished message was verified, see process_finished_msg()
950 pending_state.set_resumption_summary([&] {
951 Session_Summary summary(session.session, pending_state.is_a_resumption(), pending_state.psk_identity());
952 summary.set_session_id(pending_state.server_hello().session_id());
953 if(auto ticket = session.handle.ticket()) {
954 summary.set_session_ticket(std::move(ticket.value()));
955 }
956 return summary;
957 }());
958
959 auto new_handle = [&, this]() -> std::optional<Session_Handle> {
960 if(!callbacks().tls_should_persist_resumption_information(session.session)) {
961 session_manager().remove(session.handle);
962 return std::nullopt;
963 } else {
964 return session_manager().establish(session.session, session.handle.id());
965 }
966 }();
967
968 note_resumption_handle(new_handle);
969
970 if(pending_state.server_hello().supports_session_ticket()) {
971 if(new_handle.has_value() && new_handle->is_ticket()) {
972 pending_state.new_session_ticket(std::make_unique<New_Session_Ticket_12>(pending_state.handshake_io(),
973 pending_state.hash(),
974 new_handle->ticket().value(),
975 ticket_lifetime_hint(policy())));
976 } else {
977 pending_state.new_session_ticket(
978 std::make_unique<New_Session_Ticket_12>(pending_state.handshake_io(), pending_state.hash()));
979 }
980 }
981
982 pending_state.handshake_io().send(Change_Cipher_Spec());
983
985
986 pending_state.server_finished(
987 std::make_unique<Finished_12>(pending_state.handshake_io(), pending_state, Connection_Side::Server));
988 pending_state.set_expected_next(Handshake_Type::HandshakeCCS);
989}
990
991void Server_Impl_12::session_create(Server_Handshake_State& pending_state, bool epoch0_restart) {
992 std::map<std::string, std::vector<X509_Certificate>> cert_chains;
993
994 const std::string sni_hostname = pending_state.client_hello().sni_hostname();
995
996 // RFC 8446 1.3
997 // The "signature_algorithms_cert" extension allows a client to indicate
998 // which signature algorithms it can validate in X.509 certificates.
999 //
1000 // RFC 8446 4.2.3
1001 // TLS 1.2 implementations SHOULD also process this extension.
1002 const auto cert_signature_schemes = pending_state.client_hello().certificate_signature_schemes();
1003 cert_chains = get_server_certs(sni_hostname, cert_signature_schemes, *m_creds);
1004
1005 if(!sni_hostname.empty() && cert_chains.empty()) {
1006 cert_chains = get_server_certs("", cert_signature_schemes, *m_creds);
1007
1008 /*
1009 * Only send the unrecognized_name alert if we couldn't
1010 * find any certs for the requested name but did find at
1011 * least one cert to use in general. That avoids sending an
1012 * unrecognized_name when a server is configured for purely
1013 * anonymous/PSK operation.
1014 */
1015 if(!cert_chains.empty()) {
1016 send_warning_alert(Alert::UnrecognizedName);
1017 }
1018 }
1019
1020 const uint16_t ciphersuite =
1021 choose_ciphersuite(policy(), pending_state.version(), cert_chains, pending_state.client_hello());
1022
1023 const Server_Hello_12::Settings srv_settings(Session_ID(make_hello_random(rng(), callbacks(), policy())),
1024 pending_state.version(),
1025 ciphersuite,
1026 session_manager().emits_session_tickets());
1027
1028 // Commit point for a DTLS epoch-0 restart: all validation that can throw has
1029 // now passed (in particular choose_ciphersuite() above, which throws when the
1030 // client offers no mutually-acceptable suite), and the next statement sends
1031 // the ServerHello. Only here do we discard the old association. This must
1032 // precede the Server_Hello_12 construction so that
1033 // secure_renegotiation_data_for_server_hello() sees no active state and emits
1034 // an empty (fresh-handshake) renegotiation_info.
1035 if(epoch0_restart) {
1037 }
1038
1039 pending_state.server_hello(std::make_unique<Server_Hello_12>(pending_state.handshake_io(),
1040 pending_state.hash(),
1041 policy(),
1042 callbacks(),
1043 rng(),
1045 pending_state.client_hello(),
1046 srv_settings,
1047 m_next_protocol,
1048 flavor()));
1049
1050 secure_renegotiation_check(pending_state.maybe_server_hello());
1051
1052 const Ciphersuite& pending_suite = pending_state.ciphersuite();
1053
1054 std::shared_ptr<Private_Key> private_key;
1055
1056 if(pending_suite.is_certificate_required()) {
1057 const std::string algo_used = pending_suite.signature_used() ? pending_suite.sig_algo() : "RSA";
1058
1059 BOTAN_ASSERT(!cert_chains[algo_used].empty(), "Attempting to send empty certificate chain");
1060
1061 pending_state.server_certs(
1062 std::make_unique<Certificate_12>(pending_state.handshake_io(), pending_state.hash(), cert_chains[algo_used]));
1063
1064 // RFC 6066 8.
1065 // Note in addition that a server MUST NOT send the "CertificateStatus"
1066 // message unless it received a "status_request" extension in the client
1067 // hello message and sent a "status_request" extension in the server
1068 // hello message.
1069 if(pending_state.client_hello().supports_cert_status_message() &&
1070 pending_state.server_hello().supports_certificate_status_message() &&
1071 pending_state.is_a_resumption() == false) {
1072 const auto* csr = pending_state.client_hello().extensions().get<Certificate_Status_Request>();
1073 // csr is non-null if client_hello().supports_cert_status_message()
1074 BOTAN_ASSERT_NOMSG(csr != nullptr);
1075 const auto resp_bytes = callbacks().tls_provide_cert_status(cert_chains[algo_used], *csr);
1076 if(!resp_bytes.empty()) {
1077 pending_state.server_cert_status(
1078 std::make_unique<Certificate_Status_12>(pending_state.handshake_io(), pending_state.hash(), resp_bytes));
1079 }
1080 }
1081
1082 private_key = m_creds->private_key_for(pending_state.server_certs().cert_chain()[0], "tls-server", sni_hostname);
1083
1084 if(!private_key) {
1085 throw Internal_Error("No private key located for associated server cert");
1086 }
1087 }
1088
1089 // RFC 4279 2.
1090 // To help the client in selecting which identity to use, the server can
1091 // provide a "PSK identity hint" in the ServerKeyExchange message. If no
1092 // hint is provided, the ServerKeyExchange message is omitted.
1093 const bool omit_psk_server_kex =
1094 pending_suite.kex_method() == Kex_Algo::PSK &&
1095 m_creds->psk_identity_hint("tls-server", pending_state.client_hello().sni_hostname()).empty();
1096
1097 if(pending_suite.kex_method() == Kex_Algo::STATIC_RSA) {
1098 pending_state.set_server_rsa_kex_key(private_key);
1099 } else if(omit_psk_server_kex) {
1100 // nothing to send
1101 } else {
1102 pending_state.server_kex(std::make_unique<Server_Key_Exchange>(
1103 pending_state.handshake_io(), pending_state, policy(), *m_creds, rng(), private_key.get()));
1104 }
1105
1106 const auto trusted_CAs = m_creds->trusted_certificate_authorities("tls-server", sni_hostname);
1107
1108 std::vector<X509_DN> client_auth_CAs;
1109
1110 for(const auto* store : trusted_CAs) {
1111 auto subjects = store->all_subjects();
1112 client_auth_CAs.insert(client_auth_CAs.end(), subjects.begin(), subjects.end());
1113 }
1114
1115 const bool require_cert = policy().require_client_certificate_authentication();
1116
1117 const bool request_cert =
1118 require_cert || (client_auth_CAs.empty() == false) || policy().request_client_certificate_authentication();
1119
1120 // RFC 5246 7.4.4: supported_signature_algorithms<2..2^16-2>
1121 // Without at least one acceptable TLS 1.2 scheme we cannot construct a valid
1122 // CertificateRequest, so client cert auth is unreachable regardless.
1123 const bool can_request_cert = std::ranges::any_of(policy().acceptable_signature_schemes(),
1124 [](const Signature_Scheme& scheme) {
1125 return scheme.is_compatible_with(Protocol_Version::TLS_V12);
1126 }) &&
1127 pending_state.ciphersuite().is_certificate_required();
1128
1129 if(require_cert && !can_request_cert) {
1130 throw TLS_Exception(Alert::HandshakeFailure,
1131 "Policy requires client certificate authentication but no CertificateRequest can be sent");
1132 }
1133
1134 if(request_cert && can_request_cert) {
1135 pending_state.cert_req(std::make_unique<Certificate_Request_12>(
1136 pending_state.handshake_io(), pending_state.hash(), policy(), client_auth_CAs));
1137
1138 /*
1139 SSLv3 allowed clients to skip the Certificate message entirely
1140 if they wanted. In TLS v1.0 and later clients must send a
1141 (possibly empty) Certificate message
1142 */
1143 pending_state.set_expected_next(Handshake_Type::Certificate);
1144 } else {
1145 pending_state.set_expected_next(Handshake_Type::ClientKeyExchange);
1146 }
1147
1148 pending_state.server_hello_done(
1149 std::make_unique<Server_Hello_Done>(pending_state.handshake_io(), pending_state.hash()));
1150}
1151} // namespace Botan::TLS
#define BOTAN_ASSERT_NOMSG(expr)
Definition assert.h:82
#define BOTAN_ASSERT_NONNULL(ptr)
Definition assert.h:121
#define BOTAN_ASSERT_IMPLICATION(expr1, expr2, msg)
Definition assert.h:108
#define BOTAN_ASSERT(expr, assertion_made)
Definition assert.h:69
virtual std::vector< uint8_t > tls_provide_cert_status(const std::vector< X509_Certificate > &chain, const Certificate_Status_Request &csr)
virtual std::string tls_peer_network_identity()
virtual std::string tls_server_choose_app_protocol(const std::vector< std::string > &client_protos)
virtual void tls_examine_extensions(const Extensions &extn, Connection_Side which_side, Handshake_Type which_message)
virtual void tls_session_established(const Session_Summary &session)
virtual void tls_verify_cert_chain(const std::vector< X509_Certificate > &cert_chain, const std::vector< std::optional< OCSP::Response > > &ocsp_responses, const std::vector< Certificate_Store * > &trusted_roots, Usage_Type usage, std::string_view hostname, const TLS::Policy &policy)
virtual void tls_ssl_key_log_data(std::string_view label, std::span< const uint8_t > client_random, std::span< const uint8_t > secret) const
const std::vector< X509_Certificate > & cert_chain() const
RandomNumberGenerator & rng()
void change_cipher_spec_reader(Connection_Side side)
void maybe_arm_dtls_retransmission_timer(TimerGeneration generation_policy=TimerGeneration::Advance)
std::vector< uint8_t > secure_renegotiation_data_for_server_hello() const
virtual bool dtls_epoch0_restart_enabled() const
Session_Manager & session_manager()
const Policy & policy() const
void note_resumption_handle(std::optional< Session_Handle > handle)
void change_cipher_spec_writer(Connection_Side side)
void secure_renegotiation_check(const Client_Hello_12 *client_hello, bool fresh_handshake_mode=false)
const std::optional< Active_Connection_State_12 > & active_state() const
bool secure_renegotiation_supported() const override
void send_warning_alert(Alert::Type type)
static std::optional< Ciphersuite > by_id(uint16_t suite)
static std::optional< Group_Params > from_string(std::string_view group_name)
Handshake_State(std::unique_ptr< Handshake_IO > io, Callbacks &callbacks)
const Certificate_12 & client_certs() const
virtual std::vector< X509_Certificate > peer_cert_chain() const =0
virtual bool require_client_certificate_authentication() const
virtual bool allow_dtls_epoch0_restart() const
virtual bool request_client_certificate_authentication() const
virtual bool dtls_server_require_cookie_exchange() const
static std::shared_ptr< Server_Impl_12 > create(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, TLS_Flavor flavor=TLS_Flavor::TLS, size_t reserved_io_buffer_size=TLS::Channel::IO_BUF_DEFAULT_SIZE)
Helper class to embody a session handle in all protocol versions.
virtual size_t remove(const Session_Handle &handle)=0
virtual std::optional< Session_Handle > establish(const Session &session, const std::optional< Session_ID > &id=std::nullopt, bool tls12_no_ticket=false)
Save a new Session and assign a Session_Handle (TLS Server).
constexpr CT::Mask< T > is_equal(const T x[], const T y[], size_t len)
Definition ct_utils.h:803
std::vector< AlgorithmIdentifier > to_algorithm_identifiers(const std::vector< Signature_Scheme > &schemes)
std::vector< uint8_t > make_hello_random(RandomNumberGenerator &rng, Callbacks &cb, const Policy &policy)
std::vector< Group_Params > groups_usable_in_version(std::span< const Group_Params > groups, Protocol_Version version)
Strong< std::vector< uint8_t >, struct Session_ID_ > Session_ID
holds a TLS 1.2 session ID for stateful resumption
bool value_exists(const std::vector< T > &vec, const V &val)
Definition stl_util.h:44
std::vector< T, secure_allocator< T > > secure_vector
Definition secmem.h:128