Botan 3.11.0
Crypto and TLS for C&
tls_policy.h
Go to the documentation of this file.
1/*
2* Hooks for application level policies on TLS connections
3* (C) 2004-2006,2013 Jack Lloyd
4* 2017 Harry Reimann, Rohde & Schwarz Cybersecurity
5* 2022 René Meusel, Rohde & Schwarz Cybersecurity
6*
7* Botan is released under the Simplified BSD License (see license.txt)
8*/
9
10#ifndef BOTAN_TLS_POLICY_H_
11#define BOTAN_TLS_POLICY_H_
12
13#include <botan/tls_algos.h>
14#include <botan/tls_version.h>
15#include <chrono>
16#include <map>
17#include <optional>
18#include <vector>
19
20namespace Botan {
21
22class Public_Key;
23
24namespace TLS {
25
26class Ciphersuite;
28
29/**
30* TLS Policy Base Class
31* Inherit and overload as desired to suit local policy concerns
32*/
33class BOTAN_PUBLIC_API(2, 0) Policy /* NOLINT(*-special-member-functions) */ {
34 public:
35 /**
36 * Allow ssl key log file
37 * @note If function returns true, then Callbacks::tls_ssl_key_log_data
38 * will be invoked containing secret information for logging purposes
39 */
40 virtual bool allow_ssl_key_log_file() const;
41
42 /**
43 * Returns a list of ciphers we are willing to negotiate, in
44 * order of preference.
45 */
46 virtual std::vector<std::string> allowed_ciphers() const;
47
48 /**
49 * Returns a list of hash algorithms we are willing to use for
50 * signatures, in order of preference.
51 */
52 virtual std::vector<std::string> allowed_signature_hashes() const;
53
54 /**
55 * Returns a list of MAC algorithms we are willing to use.
56 */
57 virtual std::vector<std::string> allowed_macs() const;
58
59 /**
60 * Returns a list of key exchange algorithms we are willing to
61 * use, in order of preference. Allowed values: DH, empty string
62 * (representing RSA using server certificate key)
63 */
64 virtual std::vector<std::string> allowed_key_exchange_methods() const;
65
66 /**
67 * Returns a list of signature algorithms we are willing to
68 * use, in order of preference.
69 */
70 virtual std::vector<std::string> allowed_signature_methods() const;
71
72 virtual std::vector<Signature_Scheme> allowed_signature_schemes() const;
73
74 /**
75 * Return a list of schemes we are willing to accept
76 */
77 virtual std::vector<Signature_Scheme> acceptable_signature_schemes() const;
78
79 /**
80 * Return a list of schemes we are willing to accept for signatures in
81 * certificates.
82 *
83 * By default, the same restrictions as in acceptable_signature_schemes()
84 * apply.
85 *
86 * @return std::nullopt if the same restrictions as defined in
87 * acceptable_signature_schemes() should apply
88 */
89 virtual std::optional<std::vector<Signature_Scheme>> acceptable_certificate_signature_schemes() const;
90
91 /**
92 * The minimum signature strength we will accept
93 *
94 * Returning 80 allows RSA 1024 and SHA-1. Values larger than 80 disable
95 * SHA-1 support. Returning 110 allows RSA 2048. Return 128 to force ECC
96 * (P-256) or large (~3000 bit) RSA keys.
97 *
98 * Default is 110
99 */
100 virtual size_t minimum_signature_strength() const;
101
102 /**
103 * Return if certificate revocation info (CRL/OCSP) is required
104 *
105 * If true, certificates won't be trusted unless a valid CRL or OCSP
106 * response was examined.
107 *
108 * Default: true
109 */
110 virtual bool require_cert_revocation_info() const;
111
112 bool allowed_signature_method(std::string_view sig_method) const;
113 bool allowed_signature_hash(std::string_view hash) const;
114
115 /**
116 * Return a list of ECC curve and DH group TLS identifiers we are willing
117 * to use, in order of preference. The default ordering puts the best
118 * performing ECC first.
119 *
120 * Default: Group_Params::X25519, Group_Params::SECP256R1,
121 * Group_Params::BRAINPOOL256R1, Group_Params::SECP384R1,
122 * Group_Params::BRAINPOOL384R1, Group_Params::SECP521R1,
123 * Group_Params::BRAINPOOL512R1, Group_Params::FFDHE_2048,
124 * Group_Params::FFDHE_3072, Group_Params::FFDHE_4096,
125 * Group_Params::FFDHE_6144, Group_Params::FFDHE_8192
126 *
127 * No other values are currently defined.
128 */
129 virtual std::vector<Group_Params> key_exchange_groups() const;
130
131 /**
132 * Return a list of groups to provide prepared key share offers in the
133 * initial client hello for. Groups in this list must be reflected in
134 * key_exchange_groups() and in the same order.
135 * If an empty list is returned, no prepared key share offers are sent
136 * and the decision of the group to use is left to the server.
137 *
138 * Default: the most preferred group from key_exchange_groups().
139 *
140 * @note Has an effect on TLS 1.3 clients, only.
141 */
142 virtual std::vector<Group_Params> key_exchange_groups_to_offer() const;
143
144 /**
145 * Request that ECC curve points are sent compressed
146 *
147 * Signals that we prefer ECC points to be compressed when transmitted to
148 * us. The other party may not support ECC point compression and therefore
149 * may still send points uncompressed.
150 *
151 * Note that the certificate used during authentication must also follow
152 * the other party's preference.
153 *
154 * @note Support for EC point compression is deprecated and will be removed
155 * in a future major release. TLS 1.3 does not support point compression
156 * at all (see RFC 8446 4.2.8.2)
157 */
158 virtual bool use_ecc_point_compression() const;
159
160 /**
161 * Select a key exchange group to use, from the list of groups sent by the
162 * peer. In TLS 1.3 handshakes the peer might have provided cryptographic material
163 * for a subset of its available groups. Choosing a group for which no share was
164 * provided will result in an additional round trip. If none are acceptable, return
165 * Group_Params::NONE.
166 *
167 * By default this will try to optimize for less round trips even if this results
168 * in the usage of a less preferred group.
169 */
170 virtual Group_Params choose_key_exchange_group(const std::vector<Group_Params>& supported_by_peer,
171 const std::vector<Group_Params>& offered_by_peer) const;
172
173 /**
174 * Allow renegotiation even if the counterparty doesn't support the secure
175 * renegotiation extension.
176 *
177 * Default: false
178 *
179 * @warning Changing this to true exposes you to injected plaintext
180 * attacks. Read RFC 5746 for background.
181 *
182 * @note Has no effect for TLS 1.3 connections.
183 */
184 virtual bool allow_insecure_renegotiation() const;
185
186 /**
187 * The protocol dictates that the first 32 bits of the random
188 * field are the current time in seconds. However this allows
189 * client fingerprinting attacks. Set to false to disable, in
190 * which case random bytes will be used instead.
191 *
192 * Default: true
193 */
194 virtual bool include_time_in_hello_random() const;
195
196 /**
197 * Consulted by server side. If true, allows clients to initiate a new
198 * handshake
199 *
200 * If this function returns true, a server will accept a client-initiated
201 * renegotiation attempt. Otherwise it will send the client a non-fatal
202 * TLS::AlertType::NoRenegotiation alert.
203 *
204 * Default: false
205 *
206 * @note Has no effect for TLS 1.3 connections.
207 */
208 virtual bool allow_client_initiated_renegotiation() const;
209
210 /**
211 * Consulted by client side. If true, allows servers to initiate a new
212 * handshake
213 *
214 * If this function returns true, a client will accept a server-initiated
215 * renegotiation attempt. Otherwise it will send the server a non-fatal
216 * TLS::AlertType::NoRenegotiation alert.
217 *
218 * Default: false
219 *
220 * @note Has no effect for TLS 1.3 connections.
221 */
222 virtual bool allow_server_initiated_renegotiation() const;
223
224 /**
225 * If true, a request to renegotiate will close the connection with
226 * a fatal alert. Otherwise, a warning alert is sent.
227 *
228 * @sa allow_client_initiated_renegotiation
229 * @sa allow_server_initiated_renegotiation
230 *
231 * Default: false
232 *
233 * @note Has no effect for TLS 1.3 connections.
234 */
236
237 /**
238 * Only resume sessions when their original protocol version matches
239 * the current version exactly.
240 *
241 * Default: true
242 */
243 virtual bool only_resume_with_exact_version() const;
244
245 /**
246 * Allow TLS v1.2
247 */
248 virtual bool allow_tls12() const;
249
250 /**
251 * Allow TLS v1.3
252 */
253 virtual bool allow_tls13() const;
254
255 /**
256 * Allow DTLS v1.2
257 */
258 virtual bool allow_dtls12() const;
259
260 /**
261 * For ephemeral Diffie-Hellman key exchange, the server sends a group
262 * parameter. Return the 2 Byte TLS group identifier specifying the group
263 * parameter a server should use.
264 *
265 * Default: 2048 bit IETF IPsec group ("modp/ietf/2048")
266 *
267 * @note Has no effect for TLS 1.3 connections.
268 */
269 virtual Group_Params default_dh_group() const;
270
271 /**
272 * Return the minimum DH group size we're willing to use
273 *
274 * Return the minimum size in bits for a Diffie-Hellman group that a client
275 * will accept. Due to the design of the protocol the client has only two
276 * options - accept the group, or reject it with a fatal alert then attempt
277 * to reconnect after disabling ephemeral Diffie-Hellman.
278 *
279 * Default: 2048 bits
280 */
281 virtual size_t minimum_dh_group_size() const;
282
283 /**
284 * For ECDSA authenticated ciphersuites, the smallest key size the
285 * client will accept.
286 * This policy is currently only enforced on the server by the client.
287 *
288 * Default: 256
289 */
290 virtual size_t minimum_ecdsa_group_size() const;
291
292 /**
293 * Return the minimum ECDH group size we're willing to use
294 * for key exchange
295 *
296 * Default 255, allowing x25519 and larger
297 * x25519 is the smallest curve we will negotiate
298 * P-521 is the largest
299 */
300 virtual size_t minimum_ecdh_group_size() const;
301
302 /**
303 * Return the minimum bit size we're willing to accept for RSA
304 * key exchange or server signatures.
305 *
306 * It does not place any requirements on the size of any RSA signature(s)
307 * which were used to check the server certificate. This is only
308 * concerned with the server's public key.
309 *
310 * Default is 2048 which is smallest RSA key size still secure
311 * for medium term security.
312 */
313 virtual size_t minimum_rsa_bits() const;
314
315 /**
316 * Allows the policy to examine peer public keys. Throw an exception if the
317 * key should be rejected. Default implementation checks against policy
318 * values minimum_dh_group_size(), minimum_rsa_bits(),
319 * minimum_ecdsa_group_size(), and minimum_ecdh_group_size().
320 *
321 * Override if you'd like to perform some other kind of test on (or logging
322 * of) the peer's keys.
323 */
324 virtual void check_peer_key_acceptable(const Public_Key& public_key) const;
325
326 /**
327 * The PSK suites work using an identifier along with a shared secret. If
328 * this function returns true, when an identifier that the server does not
329 * recognize is provided by a client, a random shared secret will be
330 * generated in such a way that a client should not be able to tell the
331 * difference between the identifier not being known and the secret being
332 * wrong. This can help protect against some username probing attacks. If
333 * it returns false, the server will instead send an
334 * TLS::AlertType::UnknownPSKIdentity alert when an unknown identifier is
335 * used.
336 *
337 * Default: false
338 */
339 virtual bool hide_unknown_users() const;
340
341 /**
342 * Defines the maximum number of session tickets a client might
343 * offer in a single resumption attempt. Must be greater than 0.
344 *
345 * TODO: Currently, the TLS 1.3 client implementation supports
346 * exactly one ticket per handshake. RFC 8446 allows for
347 * an arbitrary amount, though.
348 *
349 * Default: 1
350 *
351 * @note Has an effect on TLS 1.3 connections, only.
352 */
353 virtual size_t maximum_session_tickets_per_client_hello() const;
354
355 /**
356 * Return the allowed lifetime of a session ticket. If 0, session
357 * tickets do not expire until the session ticket key rolls over.
358 * For TLS 1.3 session tickets the lifetime must not be longer than
359 * seven days. Expired session tickets cannot be used to resume a
360 * session.
361 *
362 * Default: 1 day
363 */
364 virtual std::chrono::seconds session_ticket_lifetime() const;
365
366 /**
367 * Decides whether stored session tickets should be used multiple
368 * times (until their lifetime runs out). This might allow passive
369 * observers to correlate connections (RFC 8446 Appendix C.4). This
370 * has no effect on TLS 1.2 resumptions based on session IDs as those
371 * are negotiated in the clear anyway.
372 *
373 * Default: false
374 */
375 virtual bool reuse_session_tickets() const;
376
377 /**
378 * Return the number of new session tickets a TLS 1.3 server should issue
379 * automatically upon a successful handshake. Note that applications can
380 * use `TLS::Server::send_new_session_tickets()` regardless of this policy.
381 *
382 * For convenience (and compatibility with the TLS 1.2 behaviour), this
383 * returns '1' by default.
384 *
385 * @note Has an effect on TLS 1.3 connections, only.
386 */
387 virtual size_t new_session_tickets_upon_handshake_success() const;
388
389 /**
390 * If this returns a non-empty vector, and DTLS is negotiated,
391 * then we will also attempt to negotiate the SRTP extension from
392 * RFC 5764 using the returned values as the profile ids.
393 */
394 virtual std::vector<uint16_t> srtp_profiles() const;
395
396 /**
397 * @return true if and only if we are willing to accept this version
398 * Default accepts TLS v1.2 and later or DTLS v1.2 or later.
399 */
400 virtual bool acceptable_protocol_version(Protocol_Version version) const;
401
402 /**
403 * Returns the most recent protocol version we are willing to
404 * use, for either TLS or DTLS depending on datagram param.
405 * Shouldn't ever need to override this unless you want to allow
406 * a user to disable specific TLS versions.
407 */
408 virtual Protocol_Version latest_supported_version(bool datagram) const;
409
410 /**
411 * Allows policy to reject any ciphersuites which are undesirable
412 * for whatever reason without having to reimplement ciphersuite_list
413 */
414 virtual bool acceptable_ciphersuite(const Ciphersuite& suite) const;
415
416 /**
417 * Default: true
418 *
419 * @return true if servers should choose the ciphersuite matching
420 * their highest preference, rather than the clients.
421 * Has no effect on client side.
422 */
423 virtual bool server_uses_own_ciphersuite_preferences() const;
424
425 /**
426 * Indicates whether the encrypt-then-MAC extension should be negotiated
427 * (RFC 7366)
428 *
429 * @note Has no effect for TLS 1.3 connections.
430 */
431 virtual bool negotiate_encrypt_then_mac() const;
432
433 /**
434 * Defines the maximum TLS record length for TLS connections.
435 * This is based on the Record Size Limit extension described in RFC 8449.
436 * By default (i.e. if std::nullopt is returned), TLS clients will omit
437 * this extension altogether.
438 *
439 * This value may be between 64 and 16385 (TLS 1.3) or 16384 (TLS 1.2).
440 *
441 * @note This is currently not implemented for TLS 1.2, hence the limit
442 * won't be negotiated by TLS 1.3 clients that support downgrading
443 * to TLS 1.2 (i.e. #allow_tls12() returning true).
444 */
445 virtual std::optional<uint16_t> record_size_limit() const;
446
447 /**
448 * Indicates whether certificate status messages should be supported
449 */
450 virtual bool support_cert_status_message() const;
451
452 /**
453 * Indicate if client certificate authentication is required.
454 * If true, then a cert will be requested and if the client does
455 * not send a certificate the connection will be closed.
456 */
458
459 /**
460 * Indicate if client certificate authentication is requested.
461 * If true, then a cert will be requested.
462 */
464
465 /**
466 * Returns a list of accepted certificate types for client authentication
467 * in order of preference. See RFC 7250 and RFC 8446 4.4.2 for details.
468 * Defaults to X509 only.
469 *
470 * Note that it is the application's responsibility to provide public keys
471 * and/or certificates according to the specification in this list via the
472 * Credentials_Manager.
473 */
474 virtual std::vector<Certificate_Type> accepted_client_certificate_types() const;
475
476 /**
477 * Returns a list of accepted certificate types for server authentication
478 * in order of preference. See RFC 7250 and RFC 8446 4.4.2 for details.
479 * Defaults to X509 only.
480 *
481 * Note that it is the application's responsibility to provide public keys
482 * and/or certificates according to the specification in this list via the
483 * Credentials_Manager.
484 */
485 virtual std::vector<Certificate_Type> accepted_server_certificate_types() const;
486
487 /**
488 * If true, then allow a DTLS client to restart a connection to the
489 * same server association as described in section 4.2.8 of the DTLS RFC
490 */
491 virtual bool allow_dtls_epoch0_restart() const;
492
493 /**
494 * Return allowed ciphersuites, in order of preference for the provided
495 * protocol version.
496 *
497 * @param version the exact protocol version to select supported and allowed
498 * ciphersuites for
499 */
500 virtual std::vector<uint16_t> ciphersuite_list(Protocol_Version version) const;
501
502 /**
503 * @return the default MTU for DTLS
504 */
505 virtual size_t dtls_default_mtu() const;
506
507 /**
508 * @return the initial timeout for DTLS
509 */
510 virtual size_t dtls_initial_timeout() const;
511
512 /**
513 * @return the maximum timeout for DTLS
514 */
515 virtual size_t dtls_maximum_timeout() const;
516
517 /**
518 * @return the maximum size of the certificate chain, in bytes.
519 * Return 0 to disable this and accept any size.
520 */
521 virtual size_t maximum_certificate_chain_size() const;
522
523 /**
524 * @note Has no effect for TLS 1.3 connections.
525 */
526 virtual bool allow_resumption_for_renegotiation() const;
527
528 /**
529 * Defines whether or not the middlebox compatibility mode should be
530 * used. Enabled by default.
531 *
532 * RFC 8446 Appendix D.4
533 * [This makes] the TLS 1.3 handshake resemble TLS 1.2 session resumption,
534 * which improves the chance of successfully connecting through middleboxes.
535 *
536 * Default: true
537 *
538 * @note Has an effect on TLS 1.3 connections, only.
539 */
540 virtual bool tls_13_middlebox_compatibility_mode() const;
541
542 /**
543 * Hash the RNG output for the client/server hello random. This is a pre-caution
544 * to avoid writing "raw" RNG output to the wire.
545 *
546 * There's not normally a reason to disable this, except when deterministic output
547 * is required for testing.
548 *
549 * Default: true
550 */
551 virtual bool hash_hello_random() const;
552
553 /**
554 * Convert this policy to a printable format.
555 * @param o stream to be printed to
556 */
557 virtual void print(std::ostream& o) const;
558
559 /**
560 * Convert this policy to a printable format.
561 * Same as calling `print` on a ostringstream and reading o.str()
562 */
563 std::string to_string() const;
564
565 virtual ~Policy() = default;
566};
567
569
570/**
571* NSA Suite B 128-bit security level (RFC 6460)
572*
573* @warning As of August 2015 NSA indicated only the 192-bit Suite B
574* should be used for all classification levels.
575*/
577 public:
578 BOTAN_DEPRECATED("This suite is no longer approved") NSA_Suite_B_128() = default;
579
580 std::vector<std::string> allowed_ciphers() const override { return std::vector<std::string>({"AES-128/GCM"}); }
581
582 std::vector<std::string> allowed_signature_hashes() const override {
583 return std::vector<std::string>({"SHA-256"});
584 }
585
586 std::vector<std::string> allowed_macs() const override { return std::vector<std::string>({"AEAD"}); }
587
588 std::vector<std::string> allowed_key_exchange_methods() const override {
589 return std::vector<std::string>({"ECDH"});
590 }
591
592 std::vector<std::string> allowed_signature_methods() const override {
593 return std::vector<std::string>({"ECDSA"});
594 }
595
596 std::vector<Group_Params> key_exchange_groups() const override { return {Group_Params::SECP256R1}; }
597
598 size_t minimum_signature_strength() const override { return 128; }
599
600 bool allow_tls12() const override { return true; }
601
602 bool allow_tls13() const override { return false; }
603
604 bool allow_dtls12() const override { return false; }
605};
606
607/**
608* NSA Suite B 192-bit security level (RFC 6460)
609*/
611 public:
612 std::vector<std::string> allowed_ciphers() const override { return std::vector<std::string>({"AES-256/GCM"}); }
613
614 std::vector<std::string> allowed_signature_hashes() const override {
615 return std::vector<std::string>({"SHA-384"});
616 }
617
618 std::vector<std::string> allowed_macs() const override { return std::vector<std::string>({"AEAD"}); }
619
620 std::vector<std::string> allowed_key_exchange_methods() const override {
621 return std::vector<std::string>({"ECDH"});
622 }
623
624 std::vector<std::string> allowed_signature_methods() const override {
625 return std::vector<std::string>({"ECDSA"});
626 }
627
628 std::vector<Group_Params> key_exchange_groups() const override { return {Group_Params::SECP384R1}; }
629
630 size_t minimum_signature_strength() const override { return 192; }
631
632 bool allow_tls12() const override { return true; }
633
634 bool allow_tls13() const override { return false; }
635
636 bool allow_dtls12() const override { return false; }
637};
638
639/**
640* BSI TR-02102-2 Policy
641*/
643 public:
644 std::vector<std::string> allowed_ciphers() const override {
645 return std::vector<std::string>(
646 {"AES-256/GCM", "AES-128/GCM", "AES-256/CCM", "AES-128/CCM", "AES-256", "AES-128"});
647 }
648
649 std::vector<std::string> allowed_signature_hashes() const override {
650 return std::vector<std::string>({"SHA-512", "SHA-384", "SHA-256"});
651 }
652
653 std::vector<std::string> allowed_macs() const override {
654 return std::vector<std::string>({"AEAD", "SHA-384", "SHA-256"});
655 }
656
657 std::vector<std::string> allowed_key_exchange_methods() const override {
658 return std::vector<std::string>({"ECDH", "DH", "ECDHE_PSK"});
659 }
660
661 std::vector<std::string> allowed_signature_methods() const override {
662 return std::vector<std::string>({"ECDSA", "RSA", "DSA"});
663 }
664
665 std::vector<Group_Params> key_exchange_groups() const override {
666 return std::vector<Group_Params>({Group_Params::BRAINPOOL512R1,
667 Group_Params::BRAINPOOL384R1,
668 Group_Params::BRAINPOOL256R1,
669 Group_Params::SECP521R1,
670 Group_Params::SECP384R1,
671 Group_Params::SECP256R1,
672 Group_Params::FFDHE_4096,
673 Group_Params::FFDHE_3072});
674 }
675
676 size_t minimum_signature_strength() const override { return 120; }
677
678 bool allow_insecure_renegotiation() const override { return false; }
679
680 bool allow_server_initiated_renegotiation() const override { return true; }
681
682 bool server_uses_own_ciphersuite_preferences() const override { return true; }
683
684 bool negotiate_encrypt_then_mac() const override { return true; }
685
686 size_t minimum_rsa_bits() const override { return 3000; }
687
688 size_t minimum_dh_group_size() const override { return 3000; }
689
690 size_t minimum_ecdh_group_size() const override { return 250; }
691
692 size_t minimum_ecdsa_group_size() const override { return 250; }
693
694 bool allow_tls12() const override { return true; }
695
696 bool allow_tls13() const override { return true; }
697
698 bool allow_dtls12() const override { return false; }
699};
700
701/**
702* Policy for DTLS. We require DTLS v1.2 and an AEAD mode.
703*/
705 public:
706 std::vector<std::string> allowed_macs() const override { return std::vector<std::string>({"AEAD"}); }
707
708 bool allow_tls12() const override { return false; }
709
710 bool allow_tls13() const override { return false; }
711
712 bool allow_dtls12() const override { return true; }
713};
714
715/*
716* This policy requires a secure version of TLS and disables all insecure
717* algorithms. It is compatible with other botan TLSes (including those using the
718* default policy) and with many other recent implementations. It is a great idea
719* to use if you control both sides of the protocol and don't have to worry
720* about ancient and/or bizarre TLS implementations.
721*/
723 public:
724 std::vector<std::string> allowed_ciphers() const override;
725
726 std::vector<std::string> allowed_signature_hashes() const override;
727
728 std::vector<std::string> allowed_macs() const override;
729
730 std::vector<std::string> allowed_key_exchange_methods() const override;
731};
732
733class BOTAN_PUBLIC_API(2, 0) Text_Policy : public Policy {
734 public:
735 bool allow_ssl_key_log_file() const override;
736
737 std::vector<std::string> allowed_ciphers() const override;
738
739 std::vector<std::string> allowed_signature_hashes() const override;
740
741 std::vector<std::string> allowed_macs() const override;
742
743 std::vector<std::string> allowed_key_exchange_methods() const override;
744
745 std::vector<std::string> allowed_signature_methods() const override;
746
747 std::vector<Group_Params> key_exchange_groups() const override;
748
749 std::vector<Group_Params> key_exchange_groups_to_offer() const override;
750
751 bool use_ecc_point_compression() const override;
752
753 bool allow_tls12() const override;
754
755 bool allow_tls13() const override;
756
757 bool allow_dtls12() const override;
758
759 bool allow_insecure_renegotiation() const override;
760
761 bool include_time_in_hello_random() const override;
762
763 bool allow_client_initiated_renegotiation() const override;
764 bool allow_server_initiated_renegotiation() const override;
765
766 bool server_uses_own_ciphersuite_preferences() const override;
767
768 bool negotiate_encrypt_then_mac() const override;
769
770 std::optional<uint16_t> record_size_limit() const override;
771
772 bool support_cert_status_message() const override;
773
774 bool require_client_certificate_authentication() const override;
775
776 std::vector<Certificate_Type> accepted_client_certificate_types() const override;
777 std::vector<Certificate_Type> accepted_server_certificate_types() const override;
778
779 size_t minimum_ecdh_group_size() const override;
780
781 size_t minimum_ecdsa_group_size() const override;
782
783 size_t minimum_dh_group_size() const override;
784
785 size_t minimum_rsa_bits() const override;
786
787 size_t minimum_signature_strength() const override;
788
789 size_t dtls_default_mtu() const override;
790
791 size_t dtls_initial_timeout() const override;
792
793 size_t dtls_maximum_timeout() const override;
794
795 bool require_cert_revocation_info() const override;
796
797 bool hide_unknown_users() const override;
798
799 size_t maximum_session_tickets_per_client_hello() const override;
800
801 std::chrono::seconds session_ticket_lifetime() const override;
802
803 bool reuse_session_tickets() const override;
804
805 size_t new_session_tickets_upon_handshake_success() const override;
806
807 bool tls_13_middlebox_compatibility_mode() const override;
808
809 bool hash_hello_random() const override;
810
811 std::vector<uint16_t> srtp_profiles() const override;
812
813 void set(const std::string& key, const std::string& value);
814
815 explicit Text_Policy(std::string_view s);
816
817 explicit Text_Policy(std::istream& in);
818
819 protected:
820 std::vector<std::string> get_list(const std::string& key, const std::vector<std::string>& def) const;
821
822 std::vector<Group_Params> read_group_list(std::string_view group_str) const;
823 std::vector<Certificate_Type> read_cert_type_list(const std::string& cert_type_str) const;
824
825 size_t get_len(const std::string& key, size_t def) const;
826
827 std::chrono::seconds get_duration(const std::string& key, std::chrono::seconds def) const;
828
829 bool get_bool(const std::string& key, bool def) const;
830
831 std::string get_str(const std::string& key, const std::string& def = "") const;
832
833 bool set_value(const std::string& key, std::string_view val, bool overwrite);
834
835 private:
836 std::map<std::string, std::string> m_kv;
837};
838
839} // namespace TLS
840
841} // namespace Botan
842
843#endif
#define BOTAN_PUBLIC_API(maj, min)
Definition api.h:21
#define BOTAN_DEPRECATED(msg)
Definition api.h:73
bool allow_dtls12() const override
Definition tls_policy.h:698
size_t minimum_ecdh_group_size() const override
Definition tls_policy.h:690
std::vector< std::string > allowed_signature_hashes() const override
Definition tls_policy.h:649
bool negotiate_encrypt_then_mac() const override
Definition tls_policy.h:684
std::vector< std::string > allowed_ciphers() const override
Definition tls_policy.h:644
std::vector< std::string > allowed_signature_methods() const override
Definition tls_policy.h:661
bool allow_server_initiated_renegotiation() const override
Definition tls_policy.h:680
bool server_uses_own_ciphersuite_preferences() const override
Definition tls_policy.h:682
bool allow_tls12() const override
Definition tls_policy.h:694
std::vector< std::string > allowed_macs() const override
Definition tls_policy.h:653
size_t minimum_rsa_bits() const override
Definition tls_policy.h:686
bool allow_tls13() const override
Definition tls_policy.h:696
std::vector< Group_Params > key_exchange_groups() const override
Definition tls_policy.h:665
size_t minimum_dh_group_size() const override
Definition tls_policy.h:688
bool allow_insecure_renegotiation() const override
Definition tls_policy.h:678
size_t minimum_ecdsa_group_size() const override
Definition tls_policy.h:692
std::vector< std::string > allowed_key_exchange_methods() const override
Definition tls_policy.h:657
size_t minimum_signature_strength() const override
Definition tls_policy.h:676
bool allow_dtls12() const override
Definition tls_policy.h:712
bool allow_tls13() const override
Definition tls_policy.h:710
bool allow_tls12() const override
Definition tls_policy.h:708
std::vector< std::string > allowed_macs() const override
Definition tls_policy.h:706
std::vector< std::string > allowed_macs() const override
Definition tls_policy.h:586
bool allow_dtls12() const override
Definition tls_policy.h:604
std::vector< Group_Params > key_exchange_groups() const override
Definition tls_policy.h:596
size_t minimum_signature_strength() const override
Definition tls_policy.h:598
std::vector< std::string > allowed_signature_methods() const override
Definition tls_policy.h:592
std::vector< std::string > allowed_key_exchange_methods() const override
Definition tls_policy.h:588
std::vector< std::string > allowed_signature_hashes() const override
Definition tls_policy.h:582
std::vector< std::string > allowed_ciphers() const override
Definition tls_policy.h:580
bool allow_tls12() const override
Definition tls_policy.h:600
bool allow_tls13() const override
Definition tls_policy.h:602
std::vector< Group_Params > key_exchange_groups() const override
Definition tls_policy.h:628
bool allow_tls12() const override
Definition tls_policy.h:632
bool allow_tls13() const override
Definition tls_policy.h:634
std::vector< std::string > allowed_macs() const override
Definition tls_policy.h:618
bool allow_dtls12() const override
Definition tls_policy.h:636
std::vector< std::string > allowed_ciphers() const override
Definition tls_policy.h:612
std::vector< std::string > allowed_key_exchange_methods() const override
Definition tls_policy.h:620
size_t minimum_signature_strength() const override
Definition tls_policy.h:630
std::vector< std::string > allowed_signature_methods() const override
Definition tls_policy.h:624
std::vector< std::string > allowed_signature_hashes() const override
Definition tls_policy.h:614
virtual bool include_time_in_hello_random() const
virtual void check_peer_key_acceptable(const Public_Key &public_key) const
virtual bool abort_connection_on_undesired_renegotiation() const
virtual size_t dtls_maximum_timeout() const
virtual size_t minimum_ecdh_group_size() const
virtual size_t dtls_default_mtu() const
virtual bool allow_tls12() const
virtual std::vector< Signature_Scheme > allowed_signature_schemes() const
std::string to_string() const
virtual bool reuse_session_tickets() const
virtual std::vector< uint16_t > ciphersuite_list(Protocol_Version version) const
virtual std::vector< Certificate_Type > accepted_server_certificate_types() const
virtual std::vector< Certificate_Type > accepted_client_certificate_types() const
bool allowed_signature_method(std::string_view sig_method) const
virtual bool require_client_certificate_authentication() const
virtual std::vector< Group_Params > key_exchange_groups() const
virtual size_t new_session_tickets_upon_handshake_success() const
virtual std::vector< Group_Params > key_exchange_groups_to_offer() const
bool allowed_signature_hash(std::string_view hash) const
virtual size_t minimum_rsa_bits() const
virtual bool tls_13_middlebox_compatibility_mode() const
virtual bool only_resume_with_exact_version() const
virtual bool allow_client_initiated_renegotiation() const
virtual bool allow_ssl_key_log_file() const
virtual ~Policy()=default
virtual bool allow_dtls_epoch0_restart() const
virtual bool request_client_certificate_authentication() const
virtual bool require_cert_revocation_info() const
virtual bool negotiate_encrypt_then_mac() const
virtual bool server_uses_own_ciphersuite_preferences() const
virtual Protocol_Version latest_supported_version(bool datagram) const
virtual bool acceptable_protocol_version(Protocol_Version version) const
virtual std::vector< uint16_t > srtp_profiles() const
virtual bool support_cert_status_message() const
virtual bool acceptable_ciphersuite(const Ciphersuite &suite) const
virtual std::vector< std::string > allowed_macs() const
virtual bool hide_unknown_users() const
virtual std::optional< std::vector< Signature_Scheme > > acceptable_certificate_signature_schemes() const
virtual bool hash_hello_random() const
virtual bool allow_tls13() const
virtual std::vector< std::string > allowed_key_exchange_methods() const
virtual size_t dtls_initial_timeout() const
virtual size_t maximum_session_tickets_per_client_hello() const
virtual std::vector< Signature_Scheme > acceptable_signature_schemes() const
virtual bool use_ecc_point_compression() const
virtual bool allow_dtls12() const
virtual size_t minimum_dh_group_size() const
virtual bool allow_insecure_renegotiation() const
virtual std::optional< uint16_t > record_size_limit() const
virtual std::vector< std::string > allowed_ciphers() const
virtual std::chrono::seconds session_ticket_lifetime() const
virtual size_t minimum_signature_strength() const
virtual Group_Params default_dh_group() const
virtual size_t maximum_certificate_chain_size() const
virtual std::vector< std::string > allowed_signature_methods() const
virtual size_t minimum_ecdsa_group_size() const
virtual Group_Params choose_key_exchange_group(const std::vector< Group_Params > &supported_by_peer, const std::vector< Group_Params > &offered_by_peer) const
virtual bool allow_resumption_for_renegotiation() const
virtual std::vector< std::string > allowed_signature_hashes() const
virtual bool allow_server_initiated_renegotiation() const
virtual void print(std::ostream &o) const
std::vector< std::string > allowed_macs() const override
std::vector< std::string > allowed_ciphers() const override
std::vector< std::string > allowed_key_exchange_methods() const override
std::vector< std::string > allowed_signature_hashes() const override
size_t dtls_initial_timeout() const override
bool allow_dtls12() const override
bool server_uses_own_ciphersuite_preferences() const override
bool hash_hello_random() const override
std::chrono::seconds session_ticket_lifetime() const override
std::optional< uint16_t > record_size_limit() const override
bool allow_ssl_key_log_file() const override
bool include_time_in_hello_random() const override
bool allow_client_initiated_renegotiation() const override
std::string get_str(const std::string &key, const std::string &def="") const
bool support_cert_status_message() const override
std::vector< std::string > allowed_signature_methods() const override
std::vector< Group_Params > key_exchange_groups() const override
bool require_cert_revocation_info() const override
std::vector< std::string > allowed_key_exchange_methods() const override
size_t minimum_ecdsa_group_size() const override
bool set_value(const std::string &key, std::string_view val, bool overwrite)
bool allow_tls13() const override
size_t maximum_session_tickets_per_client_hello() const override
std::vector< Certificate_Type > accepted_server_certificate_types() const override
std::vector< Group_Params > key_exchange_groups_to_offer() const override
std::chrono::seconds get_duration(const std::string &key, std::chrono::seconds def) const
size_t new_session_tickets_upon_handshake_success() const override
std::vector< std::string > allowed_signature_hashes() const override
std::vector< uint16_t > srtp_profiles() const override
bool hide_unknown_users() const override
std::vector< std::string > allowed_ciphers() const override
Text_Policy(std::string_view s)
size_t minimum_ecdh_group_size() const override
void set(const std::string &key, const std::string &value)
bool allow_server_initiated_renegotiation() const override
bool get_bool(const std::string &key, bool def) const
size_t minimum_signature_strength() const override
std::vector< Certificate_Type > accepted_client_certificate_types() const override
bool negotiate_encrypt_then_mac() const override
bool require_client_certificate_authentication() const override
bool tls_13_middlebox_compatibility_mode() const override
size_t dtls_maximum_timeout() const override
bool reuse_session_tickets() const override
size_t get_len(const std::string &key, size_t def) const
bool allow_insecure_renegotiation() const override
bool allow_tls12() const override
bool use_ecc_point_compression() const override
std::vector< Certificate_Type > read_cert_type_list(const std::string &cert_type_str) const
size_t dtls_default_mtu() const override
std::vector< Group_Params > read_group_list(std::string_view group_str) const
size_t minimum_rsa_bits() const override
std::vector< std::string > allowed_macs() const override
size_t minimum_dh_group_size() const override
std::vector< std::string > get_list(const std::string &key, const std::vector< std::string > &def) const
Policy Default_Policy
Definition tls_policy.h:568