Botan 3.10.0
Crypto and TLS for C&
tls_callbacks.h
Go to the documentation of this file.
1/*
2* TLS Callbacks
3* (C) 2016 Matthias Gierlings
4* 2016 Jack Lloyd
5* 2017 Harry Reimann, Rohde & Schwarz Cybersecurity
6* 2022 René Meusel, Rohde & Schwarz Cybersecurity
7*
8* Botan is released under the Simplified BSD License (see license.txt)
9*/
10
11#ifndef BOTAN_TLS_CALLBACKS_H_
12#define BOTAN_TLS_CALLBACKS_H_
13
14#include <botan/dl_group.h>
15#include <botan/ecc_key.h>
16#include <botan/ocsp.h>
17#include <botan/pubkey.h>
18#include <botan/tls_alert.h>
19#include <botan/tls_session.h>
20#include <chrono>
21#include <optional>
22
23namespace Botan {
24
27
28namespace OCSP {
29
30class Response;
31
32}
33
34namespace TLS {
35
36class Handshake_Message;
37class Policy;
38class Extensions;
39class Certificate_Status_Request;
40
41/**
42* Encapsulates the callbacks that a TLS channel will make which are due to
43* channel specific operations.
44*/
45class BOTAN_PUBLIC_API(2, 0) Callbacks /* NOLINT(*-special-member-functions) */ {
46 public:
47 virtual ~Callbacks() = default;
48
49 /**
50 * @name Mandatory
51 *
52 * Those callbacks must be implemented by all applications that use TLS.
53 * @{
54 */
55
56 /**
57 * Mandatory callback: output function
58 *
59 * The channel will call this with data which needs to be sent to the peer
60 * (eg, over a socket or some other form of IPC). The array will be overwritten
61 * when the function returns so a copy must be made if the data cannot be
62 * sent immediately.
63 *
64 * As an example you could use the syscall ``send`` to perform a blocking
65 * write on a socket, or append the data to a queue managed by your
66 * application and initiate an asynchronous write.
67 *
68 * For TLS all writes must occur *in the order requested*. For DTLS this
69 * ordering is not strictly required, but is still recommended.
70 *
71 * @param data a contiguous data buffer to send
72 */
73 virtual void tls_emit_data(std::span<const uint8_t> data) = 0;
74
75 /**
76 * Mandatory callback: process application data
77 *
78 * Called when application data record is received from the peer. The
79 * array is overwritten immediately after the function returns.
80 *
81 * Currently empty records are ignored and do not instigate a callback,
82 * but this may change in a future release.
83 *
84 * For TLS the record number will always increase. For DTLS, it is
85 * possible to receive records with the @p seq_no field out of order, or
86 * with gaps, corresponding to reordered or lost datagrams.
87 *
88 * @param seq_no the underlying TLS/DTLS record sequence number
89 *
90 * @param data a contiguous data buffer containing the received record
91 */
92 virtual void tls_record_received(uint64_t seq_no, std::span<const uint8_t> data) = 0;
93
94 /**
95 * Mandatory callback: alert received
96 *
97 * Called when an alert is received from the peer. If fatal, the
98 * connection is closing. If not fatal, the connection may still be
99 * closing (depending on the error and the peer).
100 *
101 * Note that alerts received before the handshake is complete are not
102 * authenticated and could have been inserted by a MITM attacker.
103 */
104 virtual void tls_alert(Alert alert) = 0;
105
106 /// @}
107 // End of mandatory callbacks
108
109 /**
110 * @name Informational
111 *
112 * Override these to obtain deeper insights into the TLS connection.
113 * Throwing from any of these callbacks will result in the termination of
114 * the TLS connection.
115 * @{
116 */
117
118 /**
119 * Optional callback: session established
120 *
121 * Called whenever a negotiation completes. This can happen more than once
122 * on TLS 1.2 connections, if renegotiation occurs. The @p session
123 * parameter provides information about the session which was just
124 * established.
125 *
126 * If this function wishes to cancel the handshake, it can throw an
127 * exception which will send a close message to the counterparty and reset
128 * the connection state.
129 *
130 * @param session the session descriptor
131 */
132 virtual void tls_session_established(const Session_Summary& session);
133
134 /**
135 * Optional callback: session activated
136 *
137 * By default does nothing. This is called when the session is activated,
138 * that is once it is possible to send or receive data on the channel. In
139 * particular it is possible for an implementation of this function to
140 * perform an initial write on the channel.
141 */
142 virtual void tls_session_activated() {}
143
144 /**
145 * Optional callback: peer closed connection (sent a "close_notify" alert)
146 *
147 * The peer signaled that it wishes to shut down the connection. The
148 * application should not expect to receive any more data from the peer
149 * and may tear down the underlying transport socket.
150 *
151 * Prior to TLS 1.3 it was required that peers discard pending writes
152 * and immediately respond with their own "close_notify". With TLS 1.3,
153 * applications can continue to send data despite the peer having already
154 * signaled their wish to shut down.
155 *
156 * Returning `true` will cause the TLS 1.3 implementation to write all
157 * pending data and then also signal a connection shut down. Otherwise
158 * the application is responsible to call the `Channel::close()` method.
159 *
160 * For TLS 1.2 the return value has no effect.
161 *
162 * @return true causes the implementation to respond with a "close_notify"
163 */
164 virtual bool tls_peer_closed_connection() { return true; }
165
166 /**
167 * Optional callback: Resumption information was received/established
168 *
169 * TLS 1.3 calls this when we sent or received a TLS 1.3 session ticket at
170 * any point after the initial handshake has finished.
171 *
172 * TLS 1.2 calls this when a session was established successfully and
173 * its resumption information may be stored for later usage.
174 *
175 * Note that for servers this is called as soon as resumption information
176 * is available and _could_ be sent to the client. If this callback
177 * returns 'false', the information will neither be cached nor sent.
178 *
179 * @param session the session descriptor
180 *
181 * @return false to prevent the resumption information from being cached,
182 * and true to cache it in the configured Session_Manager
183 */
184 virtual bool tls_should_persist_resumption_information(const Session& session);
185
186 /**
187 * Optional callback with default impl: verify cert chain
188 *
189 * Default implementation performs a standard PKIX validation
190 * and initiates network OCSP request for end-entity cert.
191 * Override to provide different behavior.
192 *
193 * Check the certificate chain is valid up to a trusted root, and
194 * optionally (if hostname != "") that the hostname given is
195 * consistent with the leaf certificate.
196 *
197 * This function should throw an exception derived from
198 * std::exception with an informative what() result if the
199 * certificate chain cannot be verified.
200 *
201 * @param cert_chain specifies a certificate chain leading to a
202 * trusted root CA certificate.
203 * @param ocsp_responses the server may have provided some
204 * @param trusted_roots the list of trusted certificates
205 * @param usage what this cert chain is being used for
206 * Usage_Type::TLS_SERVER_AUTH for server chains,
207 * Usage_Type::TLS_CLIENT_AUTH for client chains,
208 * Usage_Type::UNSPECIFIED for other uses
209 * @param hostname when authenticating a server, this is the hostname
210 * the client requested (eg via SNI). When authenticating a client,
211 * this is the server name the client is authenticating *to*.
212 * Empty in other cases or if no hostname was used.
213 * @param policy the TLS policy associated with the session being authenticated
214 * using the certificate chain
215 */
216 virtual void tls_verify_cert_chain(const std::vector<X509_Certificate>& cert_chain,
217 const std::vector<std::optional<OCSP::Response>>& ocsp_responses,
218 const std::vector<Certificate_Store*>& trusted_roots,
219 Usage_Type usage,
220 std::string_view hostname,
221 const TLS::Policy& policy);
222
223 /**
224 * Optional callback. Default impl always rejects.
225 *
226 * This allows using raw public keys for authentication of peers as
227 * described in RFC 7250 and RFC 8446 4.2.2. Applications that wish
228 * to use raw public keys MUST override this callback to verify the
229 * authenticity of the received public keys.
230 *
231 * Default implementation always rejects the raw public key.
232 *
233 * This function should throw an exception derived from
234 * std::exception with an informative what() result if the
235 * raw public key cannot be verified.
236 *
237 * @param raw_public_key specifies the raw public key to be used
238 * for peer authentication
239 * @param usage what this cert chain is being used for
240 * Usage_Type::TLS_SERVER_AUTH for server chains,
241 * Usage_Type::TLS_CLIENT_AUTH for client chains,
242 * @param hostname when authenticating a server, this is the hostname
243 * the client requested (eg via SNI). When authenticating a client,
244 * this is the server name the client is authenticating *to*.
245 * Empty in other cases or if no hostname was used.
246 * @param policy the TLS policy associated with the session being authenticated
247 * using the raw public key
248 */
249 virtual void tls_verify_raw_public_key(const Public_Key& raw_public_key,
250 Usage_Type usage,
251 std::string_view hostname,
252 const TLS::Policy& policy);
253
254 /**
255 * Called by default `tls_verify_cert_chain` to get the timeout to use for OCSP
256 * requests. Return 0 to disable online OCSP checks.
257 *
258 * This function should not be "const" since the implementation might need
259 * to perform some side effecting operation to compute the result.
260 */
261 virtual std::chrono::milliseconds tls_verify_cert_chain_ocsp_timeout() const {
262 return std::chrono::milliseconds(0);
263 }
264
265 /**
266 * Called by the TLS server whenever the client included the
267 * status_request extension (see RFC 6066, a.k.a OCSP stapling)
268 * in the ClientHello.
269 *
270 * @return the encoded OCSP response to be sent to the client which
271 * indicates the revocation status of the server certificate. Return an
272 * empty vector to indicate that no response is available, and thus
273 * suppress the Certificate_Status message.
274 *
275 * Default implementation returns an empty vector, disabling certificate status
276 */
277 virtual std::vector<uint8_t> tls_provide_cert_status(const std::vector<X509_Certificate>& chain,
278 const Certificate_Status_Request& csr);
279
280 /**
281 * Called by TLS 1.3 client or server whenever the peer indicated that
282 * OCSP stapling is supported. In contrast to `tls_provide_cert_status`,
283 * this allows providing OCSP responses for each certificate in the chain.
284 *
285 * The default implementation invokes `tls_provide_cert_status` assuming
286 * that no OCSP responses for intermediate certificates are available.
287 *
288 * @return a vector of OCSP response buffers. An empty buffer indicates
289 * that no OCSP response should be provided for the respective
290 * certificate (at the same list index). The returned vector
291 * MUST be exactly the same length as the incoming \p chain.
292 */
293 virtual std::vector<std::vector<uint8_t>> tls_provide_cert_chain_status(
294 const std::vector<X509_Certificate>& chain, const Certificate_Status_Request& csr);
295
296 /**
297 * Optional callback with default impl: sign a message
298 *
299 * Default implementation uses PK_Signer::sign_message().
300 * Override to provide a different approach, e.g. using an external device.
301 *
302 * @param key the private key of the signer
303 * @param rng a random number generator
304 * @param padding the encoding method to be applied to the message
305 * @param format the signature format
306 * @param msg the input data for the signature
307 *
308 * @return the signature
309 */
310 virtual std::vector<uint8_t> tls_sign_message(const Private_Key& key,
312 std::string_view padding,
313 Signature_Format format,
314 const std::vector<uint8_t>& msg);
315
316 /**
317 * Optional callback with default impl: verify a message signature
318 *
319 * Default implementation uses PK_Verifier::verify_message().
320 * Override to provide a different approach, e.g. using an external device.
321 *
322 * @param key the public key of the signer
323 * @param padding the encoding method to be applied to the message
324 * @param format the signature format
325 * @param msg the input data for the signature
326 * @param sig the signature to be checked
327 *
328 * @return true if the signature is valid, false otherwise
329 */
330 virtual bool tls_verify_message(const Public_Key& key,
331 std::string_view padding,
332 Signature_Format format,
333 const std::vector<uint8_t>& msg,
334 const std::vector<uint8_t>& sig);
335
336 /**
337 * Optional callback: deserialize a public key received from the peer
338 *
339 * Default implementation simply parses the public key using Botan's
340 * public keys. Override to provide a different approach, e.g. using an
341 * external device.
342 *
343 * If deserialization fails, the default implementation throws a
344 * Botan::Decoding_Error exception that will be translated into a
345 * TLS_Exception with an Alert::IllegalParameter.
346 *
347 * @param group the group identifier or (in case of TLS 1.2) an explicit
348 * discrete-log group of the public key
349 * @param key_bits the serialized public key
350 *
351 * @return the deserialized and ready-to-use public key
352 */
353 virtual std::unique_ptr<Public_Key> tls_deserialize_peer_public_key(
354 const std::variant<TLS::Group_Params, DL_Group>& group, std::span<const uint8_t> key_bits);
355
356 /**
357 * Generate an ephemeral KEM key for a TLS 1.3 handshake
358 *
359 * Applications may use this to add custom KEM algorithms or entirely
360 * different key exchange schemes to the TLS 1.3 handshake. For instance,
361 * this could provide an entry point to implement a hybrid key exchange
362 * with both a traditional algorithm like ECDH and a quantum-secure KEM.
363 * Typical use cases of the library don't need to do that and serious
364 * security risks are associated with customizing TLS's key encapsulation
365 * mechanism.
366 *
367 * Note that the KEM interface is usable for TLS 1.3 handshakes, only.
368 *
369 * The default implementation simply delegates this to the
370 * tls_generate_ephemeral_key() call when appropriate.
371 *
372 * @param group the group identifier to generate an ephemeral keypair for
373 * @param rng a random number generator
374 *
375 * @returns a keypair whose public key will be provided to the peer and
376 * the private key will be provided to tls_kem_decapsulate later
377 * in the handshake.
378 */
379 virtual std::unique_ptr<Private_Key> tls_kem_generate_key(TLS::Group_Params group, RandomNumberGenerator& rng);
380
381 /**
382 * Performs a key encapsulation operation (used for TLS 1.3 servers)
383 *
384 * Applications may use this to add custom KEM algorithms or entirely
385 * different key exchange schemes to the TLS 1.3 handshake. For instance,
386 * this could provide an entry point to implement a hybrid key exchange
387 * with both a traditional algorithm like ECDH and a quantum-secure KEM.
388 * Typical use cases of the library don't need to do that and serious
389 * security risks are associated with customizing TLS's key encapsulation
390 * mechanism.
391 *
392 * Note that the KEM interface is usable for TLS 1.3 handshakes, only.
393 *
394 * The default implementation implements this key encapsulation as a
395 * combination of tls_generate_ephemeral_key() followed by
396 * tls_ephemeral_key_agreement() with the provided @p encoded_public_key.
397 * The just-generated ephemeral private key is destroyed immediately.
398 *
399 * @param group the group identifier of the KEM/KEX algorithm
400 * @param encoded_public_key the public key used for encapsulation/KEX
401 * @param rng a random number generator
402 * @param policy a TLS policy object
403 *
404 * @returns the shared secret both in plaintext and encapsulated with
405 * @p encoded_public_key.
406 */
407 virtual KEM_Encapsulation tls_kem_encapsulate(TLS::Group_Params group,
408 const std::vector<uint8_t>& encoded_public_key,
410 const Policy& policy);
411
412 /**
413 * Performs a key decapsulation operation (used for TLS 1.3 clients).
414 *
415 * Applications may use this to add custom KEM algorithms or entirely
416 * different key exchange schemes to the TLS 1.3 handshake. For instance,
417 * this could provide an entry point to implement a hybrid key exchange
418 * with both a traditional algorithm like ECDH and a quantum-secure KEM.
419 * Typical use cases of the library don't need to do that and serious
420 * security risks are associated with customizing TLS's key encapsulation
421 * mechanism.
422 *
423 * Note that the KEM interface is usable for TLS 1.3 handshakes, only.
424 *
425 * The default implementation simply delegates this to the
426 * tls_ephemeral_key_agreement() callback to obtain the shared secret.
427 *
428 * @param group the group identifier of the KEM/KEX algorithm
429 * @param private_key the private key used for decapsulation/KEX
430 * @param encapsulated_bytes the content to decapsulate (or the public key share)
431 * @param rng a random number generator
432 * @param policy a TLS policy object
433 *
434 * @returns the plaintext shared secret from @p encapsulated_bytes after
435 * decapsulation with @p private_key.
436 */
437 virtual secure_vector<uint8_t> tls_kem_decapsulate(TLS::Group_Params group,
438 const Private_Key& private_key,
439 const std::vector<uint8_t>& encapsulated_bytes,
441 const Policy& policy);
442
443 /**
444 * Generate an ephemeral key pair for the TLS handshake.
445 *
446 * Applications may use this to add custom groups, curves or entirely
447 * different ephemeral key agreement mechanisms to the TLS handshake.
448 * Note that this callback must be used in conjunction with
449 * Callbacks::tls_ephemeral_key_agreement.
450 *
451 * Typical use cases of the library don't need to do that and serious
452 * security risks are associated with customizing TLS's key exchange
453 * mechanism.
454 *
455 * @throws TLS_Exception(Alert::DecodeError) if the @p group is not known.
456 *
457 * @param group the group identifier to generate an ephemeral keypair for
458 * TLS 1.2 allows for specifying custom discrete logarithm
459 * parameters as part of the protocol. Hence the variant<>.
460 * @param rng a random number generator
461 *
462 * @return a private key of an algorithm usable for key agreement
463 */
464 virtual std::unique_ptr<PK_Key_Agreement_Key> tls_generate_ephemeral_key(
465 const std::variant<TLS::Group_Params, DL_Group>& group, RandomNumberGenerator& rng);
466
467 /**
468 * Generate an ECDH key pair for the TLS 1.2 handshake.
469 *
470 * Note that this callback is called exclusively by TLS 1.2 to handle the
471 * ECDH public key serialization format explicitly. TLS 1.3 fixes this
472 * format to 'uncompressed' and does not allow negotiating anything else.
473 * X25519 and X448 feature a defined and fixed public key encoding and are
474 * therefore not explicitly handled by this callback either.
475 *
476 * Users may override this if they want to provide a custom keypair type
477 * to offload TLS 1.2's ECDH handling to custom hardware, for instance. It
478 * is worth noting that support for compressed points in Botan is
479 * deprecated and this callback will disappear when it is removed in a
480 * future release.
481 *
482 * Typical use cases of the library don't need to do that and serious
483 * security risks are associated with customizing TLS's key exchange
484 * mechanism.
485 *
486 * @throws TLS_Exception(Alert::DecodeError) if the @p group is not known.
487 *
488 * @param group ECDH group identifier to generate an ephemeral keypair for
489 * @param rng a random number generator
490 * @param tls12_ecc_pubkey_encoding_format the key's serialization format
491 *
492 * @return an ECDH private key of an algorithm usable for key agreement
493 */
494 virtual std::unique_ptr<PK_Key_Agreement_Key> tls12_generate_ephemeral_ecdh_key(
495 TLS::Group_Params group, RandomNumberGenerator& rng, EC_Point_Format tls12_ecc_pubkey_encoding_format);
496
497 /**
498 * Agree on a shared secret with the peer's ephemeral public key for
499 * the TLS handshake.
500 *
501 * Applications may use this to add custom groups, curves or entirely
502 * different ephemeral key agreement mechanisms to the TLS handshake.
503 * Note that this callback must be used in conjunction with
504 * Callbacks::tls_generate_ephemeral_key.
505 *
506 * Typical use cases of the library don't need to do that and serious
507 * security risks are associated with customizing TLS's key exchange
508 * mechanism.
509 *
510 * @param group the TLS group identifier to be used
511 * TLS 1.2 allows for specifying custom discrete
512 * logarithm parameters as part of the protocol.
513 * Hence the variant<>.
514 * @param private_key the private key (generated ahead in tls_generate_ephemeral_key)
515 * @param public_value the public key exchange information received by the peer
516 * @param rng a random number generator
517 * @param policy a TLS policy object
518 *
519 * @return the shared secret derived from public_value and private_key
520 */
521 virtual secure_vector<uint8_t> tls_ephemeral_key_agreement(const std::variant<TLS::Group_Params, DL_Group>& group,
522 const PK_Key_Agreement_Key& private_key,
523 const std::vector<uint8_t>& public_value,
525 const Policy& policy);
526
527 /**
528 * Optional callback: inspect handshake message
529 * Throw an exception to abort the handshake.
530 * Default simply ignores the message.
531 *
532 * Note: On connections that negotiated TLS 1.3 this callback is also
533 * invoked for post-handshake messages.
534 *
535 * @param message the handshake message
536 */
537 virtual void tls_inspect_handshake_msg(const Handshake_Message& message);
538
539 /**
540 * Optional callback for server: choose ALPN protocol
541 *
542 * ALPN (RFC 7301) works by the client sending a list of application
543 * protocols it is willing to negotiate. The server then selects which
544 * protocol to use. RFC 7301 requires that if the server does not support
545 * any protocols offered by the client, then it should close the connection
546 * with an alert of no_application_protocol. Within this callback this would
547 * be done by throwing a TLS_Exception(Alert::NoApplicationProtocol)
548 *
549 * @param client_protos the vector of protocols the client is willing to negotiate
550 *
551 * @return the protocol selected by the server; if the empty string is
552 * returned, the server does not reply to the client ALPN extension.
553 *
554 * The default implementation returns the empty string, causing client
555 * ALPN to be ignored.
556 *
557 * It is highly recommended to support ALPN whenever possible to avoid
558 * cross-protocol attacks.
559 */
560 virtual std::string tls_server_choose_app_protocol(const std::vector<std::string>& client_protos);
561
562 /**
563 * Optional callback: examine/modify Extensions before sending.
564 *
565 * Both client and server will call this callback on the Extensions object
566 * before serializing it in the specific handshake message. This allows an
567 * application to modify which extensions are sent during the handshake.
568 *
569 * Default implementation does nothing.
570 *
571 * @param extn the extensions
572 * @param which_side will be Connection_Side::Client or Connection_Side::Server which is the current
573 * applications role in the exchange.
574 * @param which_message will state the handshake message type containing the extensions
575 */
576 virtual void tls_modify_extensions(Extensions& extn, Connection_Side which_side, Handshake_Type which_message);
577
578 /**
579 * Optional callback: examine peer extensions.
580 *
581 * Both client and server will call this callback with the Extensions
582 * object after receiving it from the peer. This allows examining the
583 * Extensions, for example to implement a custom extension. It also allows
584 * an application to require that a particular extension be implemented;
585 * throw an exception from this function to abort the handshake.
586 *
587 * Default implementation does nothing.
588 *
589 * @param extn the extensions
590 * @param which_side will be Connection_Side::Client if these are are the clients extensions (ie we are
591 * the server) or Connection_Side::Server if these are the server extensions (we are the client).
592 * @param which_message will state the handshake message type containing the extensions
593 */
594 virtual void tls_examine_extensions(const Extensions& extn,
595 Connection_Side which_side,
596 Handshake_Type which_message);
597
598 /**
599 * Optional callback: parse a single OCSP Response
600 *
601 * Note: Typically a user of the library would not want to override this
602 * callback. We provide this callback to be able to support OCSP
603 * related tests from BoringSSL's BoGo tests that provide unparsable
604 * responses.
605 *
606 * Default implementation tries to parse the provided raw OCSP response.
607 *
608 * This function should not throw an exception but return a std::nullopt
609 * if the OCSP response cannot be parsed.
610 *
611 * @param raw_response raw OCSP response buffer
612 * @returns the parsed OCSP response or std::nullopt on error
613 */
614 virtual std::optional<OCSP::Response> tls_parse_ocsp_response(const std::vector<uint8_t>& raw_response);
615
616 /**
617 * Optional callback: return peer network identity
618 *
619 * There is no expected or specified format. The only expectation is this
620 * function will return a unique value. For example returning the peer
621 * host IP and port.
622 *
623 * This is used to bind the DTLS cookie to a particular network identity.
624 * It is only called if the dtls-cookie-secret PSK is also defined.
625 */
626 virtual std::string tls_peer_network_identity();
627
628 /**
629 * Optional callback: return a custom time stamp value
630 *
631 * This allows the library user to specify a custom "now" timestamp when
632 * needed. By default it will use the current system clock time.
633 *
634 * Note that typical usages will not need to override this callback but it
635 * is useful for testing purposes to allow for deterministic test outcomes.
636 */
637 virtual std::chrono::system_clock::time_point tls_current_timestamp();
638
639 /**
640 * Optional callback: error logging. (not currently called)
641 * @param err An error message related to this connection.
642 */
643 virtual void tls_log_error(const char* err);
644
645 /**
646 * Optional callback: debug logging. (not currently called)
647 * @param what Some hopefully informative string
648 */
649 virtual void tls_log_debug(const char* what);
650
651 /**
652 * Optional callback: debug logging taking a buffer. (not currently called)
653 * @param descr What this buffer is
654 * @param val the bytes
655 * @param val_len length of val
656 */
657 virtual void tls_log_debug_bin(const char* descr, const uint8_t val[], size_t val_len);
658
659 /**
660 * Optional callback: Allows access to a connection's secret data
661 *
662 * Useful to implement the SSLKEYLOGFILE for connection debugging as
663 * specified in ietf.org/archive/id/draft-thomson-tls-keylogfile-00.html
664 *
665 * Invoked if Policy::allow_ssl_key_log_file returns true.
666 *
667 * Default implementation simply ignores the inputs.
668 *
669 * @param label Identifies the reported secret type
670 * See draft-thomson-tls-keylogfile-00 Section 3.1 and 3.2
671 * @param client_random random value from ClientHello message acting as
672 * an identifier of the TLS sessions
673 * @param secret the actual secret value
674 */
675 virtual void tls_ssl_key_log_data(std::string_view label,
676 std::span<const uint8_t> client_random,
677 std::span<const uint8_t> secret) const;
678};
679
680} // namespace TLS
681
682} // namespace Botan
683
684#endif
#define BOTAN_PUBLIC_API(maj, min)
Definition api.h:21
virtual std::chrono::milliseconds tls_verify_cert_chain_ocsp_timeout() const
virtual ~Callbacks()=default
virtual void tls_session_activated()
virtual void tls_session_established(const Session_Summary &session)
virtual void tls_record_received(uint64_t seq_no, std::span< const uint8_t > data)=0
virtual void tls_alert(Alert alert)=0
virtual bool tls_peer_closed_connection()
virtual void tls_emit_data(std::span< const uint8_t > data)=0
Signature_Format
Definition pk_keys.h:32
std::vector< T, secure_allocator< T > > secure_vector
Definition secmem.h:69
Usage_Type
Definition x509cert.h:22