Botan 3.14.1
Crypto and TLS for C&
tls_callbacks.cpp
Go to the documentation of this file.
1/*
2* TLS Callbacks
3* (C) 2016 Jack Lloyd
4* 2017 Harry Reimann, Rohde & Schwarz Cybersecurity
5* 2022 René Meusel, Hannes Rantzsch - neXenio GmbH
6* 2023 René Meusel - Rohde & Schwarz Cybersecurity
7*
8* Botan is released under the Simplified BSD License (see license.txt)
9*/
10
11#include <botan/tls_callbacks.h>
12
13#include <botan/dh.h>
14#include <botan/dl_group.h>
15#include <botan/ec_group.h>
16#include <botan/ecdh.h>
17#include <botan/ocsp.h>
18#include <botan/pk_algs.h>
19#include <botan/tls_algos.h>
20#include <botan/tls_exceptn.h>
21#include <botan/tls_policy.h>
22#include <botan/tls_session.h>
23#include <botan/x509path.h>
24#include <botan/internal/fmt.h>
25#include <botan/internal/stl_util.h>
26
27#if defined(BOTAN_HAS_X25519)
28 #include <botan/x25519.h>
29#endif
30
31#if defined(BOTAN_HAS_X448)
32 #include <botan/x448.h>
33#endif
34
35#if defined(BOTAN_HAS_ML_KEM)
36 #include <botan/ml_kem.h>
37#endif
38
39#if defined(BOTAN_HAS_FRODOKEM)
40 #include <botan/frodokem.h>
41#endif
42
43#if defined(BOTAN_HAS_TLS_13_PQC)
44 #include <botan/internal/hybrid_public_key.h>
45 #include <botan/internal/kex_to_kem_adapter.h>
46#endif
47
48namespace Botan {
49
51 // default is no op
52}
53
54std::string TLS::Callbacks::tls_server_choose_app_protocol(const std::vector<std::string>& /*unused*/) {
55 return "";
56}
57
59 return "";
60}
61
62std::chrono::system_clock::time_point TLS::Callbacks::tls_current_timestamp() {
63 return std::chrono::system_clock::now();
64}
65
67 const auto now = std::chrono::steady_clock::now().time_since_epoch();
68 return std::chrono::duration_cast<std::chrono::milliseconds>(now).count();
69}
70
71void TLS::Callbacks::tls_register_deferred_operation(uint64_t monotonic_delay_ms,
72 std::function<void()> op /* NOLINT(*-value-param) */) {
73 BOTAN_UNUSED(monotonic_delay_ms, op); // no-op
74}
75
77 Connection_Side /*unused*/,
78 Handshake_Type /*unused*/) {}
79
81 Connection_Side /*unused*/,
82 Handshake_Type /*unused*/) {}
83
85 // RFC 5077 3.3
86 // The ticket_lifetime_hint field contains a hint from the server about
87 // how long the ticket should be stored. A value of zero is reserved to
88 // indicate that the lifetime of the ticket is unspecified.
89 //
90 // RFC 8446 4.6.1
91 // [A ticket_lifetime] of zero indicates that the ticket should be discarded
92 // immediately.
93 //
94 // By default we opt to keep all sessions, except for TLS 1.3 with a lifetime
95 // hint of zero.
96 return session.lifetime_hint().count() > 0 || session.version().is_pre_tls_13();
97}
98
99void TLS::Callbacks::tls_verify_cert_chain(const std::vector<X509_Certificate>& cert_chain,
100 const std::vector<std::optional<OCSP::Response>>& ocsp_responses,
101 const std::vector<Certificate_Store*>& trusted_roots,
102 Usage_Type usage,
103 std::string_view hostname,
104 const TLS::Policy& policy) {
105 if(cert_chain.empty()) {
106 throw Invalid_Argument("Certificate chain was empty");
107 }
108
111
112 /*
113 Hostname is always provided in order to allow host-specific logic if required,
114 but it should not be passed to x509_path_validate unless we are verifying
115 the server.
116 */
117 const std::string_view name_to_match = (usage == Usage_Type::TLS_CLIENT_AUTH) ? std::string_view{} : hostname;
118
119 const Path_Validation_Result result = x509_path_validate(cert_chain,
120 restrictions,
121 trusted_roots,
122 name_to_match,
123 usage,
126 ocsp_responses);
127
128 if(!result.successful_validation()) {
129 throw TLS_Exception(Alert::BadCertificate, "Certificate validation failure: " + result.result_string());
130 }
131}
132
134 Usage_Type usage,
135 std::string_view hostname,
136 const TLS::Policy& policy) {
137 BOTAN_UNUSED(raw_public_key, usage, hostname, policy);
138 // There is no good default implementation for authenticating raw public key.
139 // Applications that wish to use them for authentication, must override this.
140 throw TLS_Exception(Alert::CertificateUnknown, "Application did not provide a means to validate the raw public key");
141}
142
143std::optional<OCSP::Response> TLS::Callbacks::tls_parse_ocsp_response(const std::vector<uint8_t>& raw_response) {
144 try {
145 return OCSP::Response(raw_response);
146 } catch(const Decoding_Error&) {
147 // ignore parsing errors and just ignore the broken OCSP response
148 return std::nullopt;
149 }
150}
151
152std::vector<std::vector<uint8_t>> TLS::Callbacks::tls_provide_cert_chain_status(
153 const std::vector<X509_Certificate>& chain, const Certificate_Status_Request& csr) {
154 std::vector<std::vector<uint8_t>> result(chain.size());
155 if(!chain.empty()) {
156 result[0] = tls_provide_cert_status(chain, csr);
157 }
158 return result;
159}
160
161std::vector<uint8_t> TLS::Callbacks::tls_sign_message(const Private_Key& key,
163 std::string_view padding,
164 Signature_Format format,
165 const std::vector<uint8_t>& msg) {
166 PK_Signer signer(key, rng, padding, format);
167
168 return signer.sign_message(msg, rng);
169}
170
172 std::string_view padding,
173 Signature_Format format,
174 const std::vector<uint8_t>& msg,
175 const std::vector<uint8_t>& sig) {
176 PK_Verifier verifier(key, padding, format);
177
178 return verifier.verify_message(msg, sig);
179}
180
181namespace {
182
183bool is_dh_group(const std::variant<TLS::Group_Params, DL_Group>& group) {
184 return std::holds_alternative<DL_Group>(group) || std::get<TLS::Group_Params>(group).is_dh_named_group();
185}
186
187DL_Group get_dl_group(const std::variant<TLS::Group_Params, DL_Group>& group) {
188 BOTAN_ASSERT_NOMSG(is_dh_group(group));
189
190 // TLS 1.2 allows specifying arbitrary DL_Group parameters in-lieu of
191 // a standardized DH group identifier. TLS 1.3 just offers pre-defined
192 // groups.
193 return std::visit(overloaded{[](const DL_Group& dl_group) { return dl_group; },
194 [&](TLS::Group_Params group_param) {
195 return DL_Group::from_name(group_param.to_algorithm_spec().value());
196 }},
197 group);
198}
199
200} // namespace
201
203 const std::variant<TLS::Group_Params, DL_Group>& group, std::span<const uint8_t> key_bits) {
204 if(is_dh_group(group)) {
205 // TLS 1.2 allows specifying arbitrary DL_Group parameters in-lieu of
206 // a standardized DH group identifier.
207 const auto dl_group = get_dl_group(group);
208
209 const auto Y = BigInt::from_bytes(key_bits);
210
211 /*
212 * A basic check for key validity. As we do not know q here we
213 * cannot check that Y is in the right subgroup. However since
214 * our key is ephemeral there does not seem to be any
215 * advantage to bogus keys anyway.
216 */
217 if(Y <= 1 || Y >= dl_group.get_p() - 1) {
218 throw Decoding_Error("Server sent bad DH key for DHE exchange");
219 }
220
221 return std::make_unique<DH_PublicKey>(dl_group, Y);
222 }
223
224 // The special case for TLS 1.2 with an explicit DH group definition is
225 // handled above. All other cases are based on the opaque group definition.
226 BOTAN_ASSERT_NOMSG(std::holds_alternative<TLS::Group_Params>(group));
227 const auto group_params = std::get<TLS::Group_Params>(group);
228
229 if(group_params.is_ecdh_named_curve()) {
230 const auto ec_group = EC_Group::from_name(group_params.to_algorithm_spec().value());
231 // TLS 1.3 requires uncompressed points (checked when parsing the key
232 // share); TLS 1.2 may negotiate the compressed format. The deprecated
233 // hybrid encoding and the identity element are never accepted.
234
235 const auto point = [&]() -> EC_AffinePoint {
236 if(auto pt_uncompressed = EC_AffinePoint::deserialize_uncompressed(ec_group, key_bits)) {
237 return std::move(pt_uncompressed).value();
238 } else if(auto pt_compressed = EC_AffinePoint::deserialize_compressed(ec_group, key_bits)) {
239 return std::move(pt_compressed).value();
240 } else {
241 throw Decoding_Error("Invalid ECDH public key encoding");
242 }
243 }();
244 return std::make_unique<ECDH_PublicKey>(ec_group, point);
245 }
246
247#if defined(BOTAN_HAS_X25519)
248 if(group_params.is_x25519()) {
249 return std::make_unique<X25519_PublicKey>(key_bits);
250 }
251#endif
252
253#if defined(BOTAN_HAS_X448)
254 if(group_params.is_x448()) {
255 return std::make_unique<X448_PublicKey>(key_bits);
256 }
257#endif
258
259#if defined(BOTAN_HAS_TLS_13_PQC)
260 if(group_params.is_pqc_hybrid()) {
261 return Hybrid_KEM_PublicKey::load_for_group(group_params, key_bits);
262 }
263#endif
264
265#if defined(BOTAN_HAS_ML_KEM)
266 if(group_params.is_pure_ml_kem()) {
267 return std::make_unique<ML_KEM_PublicKey>(key_bits, ML_KEM_Mode(group_params.to_algorithm_spec().value()));
268 }
269#endif
270
271#if defined(BOTAN_HAS_FRODOKEM)
272 if(group_params.is_pure_frodokem()) {
273 return std::make_unique<FrodoKEM_PublicKey>(key_bits, FrodoKEMMode(group_params.to_algorithm_spec().value()));
274 }
275#endif
276
277 throw Decoding_Error("cannot create a key offering without a group definition");
278}
279
281#if defined(BOTAN_HAS_ML_KEM)
282 if(group.is_pure_ml_kem()) {
283 return std::make_unique<ML_KEM_PrivateKey>(rng, ML_KEM_Mode(group.to_algorithm_spec().value()));
284 }
285#endif
286
287#if defined(BOTAN_HAS_FRODOKEM)
288 if(group.is_pure_frodokem()) {
289 return std::make_unique<FrodoKEM_PrivateKey>(rng, FrodoKEMMode(group.to_algorithm_spec().value()));
290 }
291#endif
292
293#if defined(BOTAN_HAS_TLS_13_PQC)
294 if(group.is_pqc_hybrid()) {
296 }
297#endif
298
299 return tls_generate_ephemeral_key(group, rng);
300}
301
303 const std::vector<uint8_t>& encoded_public_key,
305 const Policy& policy) {
306 if(group.is_kem()) {
307 const auto kem_pub_key = [&] {
308 try {
309 return tls_deserialize_peer_public_key(group, encoded_public_key);
310 } catch(const Decoding_Error& ex) {
311 // This exception means that the public key was invalid. However,
312 // TLS' DecodeError would imply that a protocol message was invalid.
313 throw TLS_Exception(Alert::IllegalParameter, ex.what());
314 } catch(const Invalid_Argument& ex) {
315 throw TLS_Exception(Alert::IllegalParameter, ex.what());
316 }
317 }();
318
319 BOTAN_ASSERT_NONNULL(kem_pub_key);
320 policy.check_peer_key_acceptable(*kem_pub_key);
321
322#if defined(BOTAN_HAS_TLS_13_PQC)
323 // The policy's minimum key sizes also apply to each component of a hybrid key
324 if(const auto* hybrid = dynamic_cast<const Hybrid_PublicKey*>(kem_pub_key.get())) {
325 for(const auto& component : hybrid->public_keys()) {
326 if(const auto* adapted = dynamic_cast<const KEX_to_KEM_Adapter_PublicKey*>(component.get())) {
327 policy.check_peer_key_acceptable(adapted->kex_public_key());
328 } else {
329 policy.check_peer_key_acceptable(*component);
330 }
331 }
332 }
333#endif
334
335 try {
336 return PK_KEM_Encryptor(*kem_pub_key, "Raw").encrypt(rng);
337 } catch(const Decoding_Error& ex) {
338 throw TLS_Exception(Alert::IllegalParameter, ex.what());
339 } catch(const Invalid_Argument& ex) {
340 throw TLS_Exception(Alert::IllegalParameter, ex.what());
341 }
342 } else {
343 // TODO: We could use the KEX_to_KEM_Adapter to remove the case distinction
344 // of KEM and KEX. However, the workarounds in this adapter class
345 // should first be addressed.
346 auto ephemeral_keypair = tls_generate_ephemeral_key(group, rng);
347 BOTAN_ASSERT_NONNULL(ephemeral_keypair);
348 return {ephemeral_keypair->public_value(),
349 tls_ephemeral_key_agreement(group, *ephemeral_keypair, encoded_public_key, rng, policy)};
350 }
351}
352
354 const Private_Key& private_key,
355 const std::vector<uint8_t>& encapsulated_bytes,
357 const Policy& policy) {
358 if(group.is_kem()) {
359 PK_KEM_Decryptor kemdec(private_key, rng, "Raw");
360 if(encapsulated_bytes.size() != kemdec.encapsulated_key_length()) {
361 throw TLS_Exception(Alert::IllegalParameter, "Invalid encapsulated key length");
362 }
363 try {
364 return kemdec.decrypt(encapsulated_bytes, 0, {});
365 } catch(const Decoding_Error& ex) {
366 throw TLS_Exception(Alert::IllegalParameter, ex.what());
367 } catch(const Invalid_Argument& ex) {
368 throw TLS_Exception(Alert::IllegalParameter, ex.what());
369 }
370 }
371
372 try {
373 const auto& key_agreement_key = dynamic_cast<const PK_Key_Agreement_Key&>(private_key);
374 return tls_ephemeral_key_agreement(group, key_agreement_key, encapsulated_bytes, rng, policy);
375 } catch(const std::bad_cast&) {
376 throw Invalid_Argument("provided ephemeral key is not a PK_Key_Agreement_Key");
377 }
378}
379
380std::unique_ptr<PK_Key_Agreement_Key> TLS::Callbacks::tls_generate_ephemeral_key(
381 const std::variant<TLS::Group_Params, DL_Group>& group, RandomNumberGenerator& rng) {
382 if(is_dh_group(group)) {
383 const DL_Group dl_group = get_dl_group(group);
384 return std::make_unique<DH_PrivateKey>(rng, dl_group);
385 }
386
387 BOTAN_ASSERT_NOMSG(std::holds_alternative<TLS::Group_Params>(group));
388 const auto group_params = std::get<TLS::Group_Params>(group);
389
390 if(group_params.is_ecdh_named_curve()) {
391 const auto ec_group = EC_Group::from_name(group_params.to_algorithm_spec().value());
392 auto ecdh_key = std::make_unique<ECDH_PrivateKey>(rng, ec_group);
393
394 // RFC 8446 Ch. 4.2.8.2
395 //
396 // Note: Versions of TLS prior to 1.3 permitted point format
397 // negotiation; TLS 1.3 removes this feature in favor of a single point
398 // format for each curve.
399 //
400 // Hence, TLS 1.3 won't take Policy::use_ecc_point_compression() or
401 // ClientHello::prefers_compressed_ec_points() into account but always use
402 // uncompressed point encoding. Note that TLS 1.2 uses the
403 // `tls12_generate_ephemeral_ecdh_key()` callback, which allows to specify
404 // the point encoding format.
405 ecdh_key->set_point_encoding(EC_Point_Format::Uncompressed);
406 return ecdh_key;
407 }
408
409#if defined(BOTAN_HAS_X25519)
410 if(group_params.is_x25519()) {
411 return std::make_unique<X25519_PrivateKey>(rng);
412 }
413#endif
414
415#if defined(BOTAN_HAS_X448)
416 if(group_params.is_x448()) {
417 return std::make_unique<X448_PrivateKey>(rng);
418 }
419#endif
420
421 if(group_params.is_kem()) {
422 throw TLS_Exception(Alert::IllegalParameter, "cannot generate an ephemeral KEX key for a KEM");
423 }
424
425 throw TLS_Exception(Alert::DecodeError, "cannot create a key offering without a group definition");
426}
427
428std::unique_ptr<PK_Key_Agreement_Key> TLS::Callbacks::tls12_generate_ephemeral_ecdh_key(
429 TLS::Group_Params group, RandomNumberGenerator& rng, EC_Point_Format tls12_ecc_pubkey_encoding_format) {
430 // Delegating to the "universal" callback to obtain an ECDH key pair
431 auto key = tls_generate_ephemeral_key(group, rng);
432
433 // For ordinary ECDH key pairs (that are derived from `ECDH_PublicKey`), we
434 // set the internal point encoding flag for the key before passing it on into
435 // the TLS 1.2 implementation. For user-defined keypair types (e.g. to
436 // offload to some crypto hardware) inheriting from Botan's `ECDH_PublicKey`
437 // might not be feasible. Such users should consider overriding this
438 // ECDH-specific callback and ensure that their custom class handles the
439 // public point encoding as requested by `tls12_ecc_pubkey_encoding_format`.
440 if(auto* ecc_key = dynamic_cast<ECDH_PublicKey*>(key.get())) {
441 ecc_key->set_point_encoding(tls12_ecc_pubkey_encoding_format);
442 }
443
444 return key;
445}
446
448 const std::variant<TLS::Group_Params, DL_Group>& group,
449 const PK_Key_Agreement_Key& private_key,
450 const std::vector<uint8_t>& public_value,
452 const Policy& policy) {
453 const auto kex_pub_key = [&]() {
454 try {
455 return tls_deserialize_peer_public_key(group, public_value);
456 } catch(const Decoding_Error& ex) {
457 // This exception means that the public key was invalid. However,
458 // TLS' DecodeError would imply that a protocol message was invalid.
459 throw TLS_Exception(Alert::IllegalParameter, ex.what());
460 } catch(const Invalid_Argument& ex) {
461 throw TLS_Exception(Alert::IllegalParameter, ex.what());
462 }
463 }();
464
465 BOTAN_ASSERT_NONNULL(kex_pub_key);
466 policy.check_peer_key_acceptable(*kex_pub_key);
467
468 // RFC 8422 - 5.11.
469 // With X25519 and X448, a receiving party MUST check whether the
470 // computed premaster secret is the all-zero value and abort the
471 // handshake if so, as described in Section 6 of [RFC7748].
472 //
473 // This is done within the key agreement operation and throws
474 // an Invalid_Argument exception if the shared secret is all-zero.
475 try {
476 const PK_Key_Agreement ka(private_key, rng, PK_Key_Agreement_Options().with_raw_shared_key());
477 return ka.derive_key(0, kex_pub_key->raw_public_key_bits()).bits_of();
478 } catch(const Invalid_Argument& ex) {
479 throw TLS_Exception(Alert::IllegalParameter, ex.what());
480 }
481}
482
486
487std::vector<uint8_t> TLS::Callbacks::tls_provide_cert_status(const std::vector<X509_Certificate>& chain,
488 const Certificate_Status_Request& csr) {
489 BOTAN_UNUSED(chain, csr);
490 return std::vector<uint8_t>();
491}
492
493void TLS::Callbacks::tls_log_error(const char* err) {
494 BOTAN_UNUSED(err);
495}
496
497void TLS::Callbacks::tls_log_debug(const char* what) {
498 BOTAN_UNUSED(what);
499}
500
501void TLS::Callbacks::tls_log_debug_bin(const char* descr, const uint8_t val[], size_t val_len) {
502 BOTAN_UNUSED(descr, val, val_len);
503}
504
505void TLS::Callbacks::tls_ssl_key_log_data(std::string_view label,
506 std::span<const uint8_t> client_random,
507 std::span<const uint8_t> secret) const {
508 BOTAN_UNUSED(label, client_random, secret);
509}
510
511std::unique_ptr<KDF> TLS::Callbacks::tls12_protocol_specific_kdf(std::string_view prf_algo) const {
512 if(prf_algo == "MD5" || prf_algo == "SHA-1") {
513 return KDF::create_or_throw("TLS-12-PRF(SHA-256)");
514 }
515
516 return KDF::create_or_throw(Botan::fmt("TLS-12-PRF({})", prf_algo));
517}
518
519} // namespace Botan
#define BOTAN_UNUSED
Definition assert.h:151
#define BOTAN_ASSERT_NOMSG(expr)
Definition assert.h:82
#define BOTAN_ASSERT_NONNULL(ptr)
Definition assert.h:121
static BigInt from_bytes(std::span< const uint8_t > bytes)
Definition bigint.cpp:84
static DL_Group from_name(std::string_view name)
Definition dl_group.cpp:266
static std::optional< EC_AffinePoint > deserialize_uncompressed(const EC_Group &group, std::span< const uint8_t > bytes)
static std::optional< EC_AffinePoint > deserialize_compressed(const EC_Group &group, std::span< const uint8_t > bytes)
static EC_Group from_name(std::string_view name)
Definition ec_group.cpp:529
const char * what() const noexcept override
Definition exceptn.h:94
Abstraction for a combined KEM public key.
Definition hybrid_kem.h:31
static std::unique_ptr< KDF > create_or_throw(std::string_view algo_spec, std::string_view provider="")
Definition kdf.cpp:208
secure_vector< uint8_t > bits_of() const
Definition symkey.h:46
size_t encapsulated_key_length() const
Definition pubkey.cpp:229
void decrypt(std::span< uint8_t > out_shared_key, std::span< const uint8_t > encap_key, size_t desired_shared_key_len=32, std::span< const uint8_t > salt={})
Definition pubkey.cpp:255
KEM_Encapsulation encrypt(RandomNumberGenerator &rng, size_t desired_shared_key_len=32, std::span< const uint8_t > salt={})
Definition pubkey.h:745
SymmetricKey derive_key(size_t key_len, std::span< const uint8_t > peer_key, std::span< const uint8_t > salt) const
Definition pubkey.cpp:305
std::vector< uint8_t > sign_message(const uint8_t in[], size_t length, RandomNumberGenerator &rng)
Definition pubkey.h:222
bool verify_message(const uint8_t msg[], size_t msg_length, const uint8_t sig[], size_t sig_length)
Definition pubkey.cpp:501
std::string result_string() const
virtual std::chrono::milliseconds tls_verify_cert_chain_ocsp_timeout() const
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 void tls_modify_extensions(Extensions &extn, Connection_Side which_side, Handshake_Type which_message)
virtual std::vector< std::vector< uint8_t > > tls_provide_cert_chain_status(const std::vector< X509_Certificate > &chain, const Certificate_Status_Request &csr)
virtual void tls_log_debug_bin(const char *descr, const uint8_t val[], size_t val_len)
virtual void tls_log_error(const char *err)
virtual void tls_log_debug(const char *what)
virtual void tls_register_deferred_operation(uint64_t monotonic_delay_ms, std::function< void()> op)
virtual std::unique_ptr< PK_Key_Agreement_Key > tls12_generate_ephemeral_ecdh_key(TLS::Group_Params group, RandomNumberGenerator &rng, EC_Point_Format tls12_ecc_pubkey_encoding_format)
virtual std::string tls_server_choose_app_protocol(const std::vector< std::string > &client_protos)
virtual std::optional< OCSP::Response > tls_parse_ocsp_response(const std::vector< uint8_t > &raw_response)
virtual void tls_examine_extensions(const Extensions &extn, Connection_Side which_side, Handshake_Type which_message)
virtual std::vector< uint8_t > tls_sign_message(const Private_Key &key, RandomNumberGenerator &rng, std::string_view padding, Signature_Format format, const std::vector< uint8_t > &msg)
virtual void tls_session_established(const Session_Summary &session)
virtual void tls_verify_raw_public_key(const Public_Key &raw_public_key, Usage_Type usage, std::string_view hostname, const TLS::Policy &policy)
virtual std::unique_ptr< KDF > tls12_protocol_specific_kdf(std::string_view prf_algo) const
virtual KEM_Encapsulation tls_kem_encapsulate(TLS::Group_Params group, const std::vector< uint8_t > &encoded_public_key, RandomNumberGenerator &rng, const Policy &policy)
virtual bool tls_should_persist_resumption_information(const Session &session)
virtual std::unique_ptr< Private_Key > tls_kem_generate_key(TLS::Group_Params group, RandomNumberGenerator &rng)
virtual std::unique_ptr< Public_Key > tls_deserialize_peer_public_key(const std::variant< TLS::Group_Params, DL_Group > &group, std::span< const uint8_t > key_bits)
virtual secure_vector< uint8_t > tls_ephemeral_key_agreement(const std::variant< TLS::Group_Params, DL_Group > &group, const PK_Key_Agreement_Key &private_key, const std::vector< uint8_t > &public_value, RandomNumberGenerator &rng, const Policy &policy)
virtual secure_vector< uint8_t > tls_kem_decapsulate(TLS::Group_Params group, const Private_Key &private_key, const std::vector< uint8_t > &encapsulated_bytes, RandomNumberGenerator &rng, const Policy &policy)
virtual std::chrono::system_clock::time_point tls_current_timestamp()
virtual uint64_t tls_current_monotonic_clock_ms()
virtual std::unique_ptr< PK_Key_Agreement_Key > tls_generate_ephemeral_key(const std::variant< TLS::Group_Params, DL_Group > &group, RandomNumberGenerator &rng)
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
virtual bool tls_verify_message(const Public_Key &key, std::string_view padding, Signature_Format format, const std::vector< uint8_t > &msg, const std::vector< uint8_t > &sig)
virtual void tls_inspect_handshake_msg(const Handshake_Message &message)
std::optional< std::string > to_algorithm_spec() const
constexpr bool is_pqc_hybrid() const
Definition tls_algos.h:240
constexpr bool is_kem() const
Definition tls_algos.h:242
constexpr bool is_pure_frodokem() const
Definition tls_algos.h:201
constexpr bool is_pure_ml_kem() const
Definition tls_algos.h:196
static std::unique_ptr< Hybrid_KEM_PrivateKey > generate_from_group(Group_Params group, RandomNumberGenerator &rng)
static std::unique_ptr< Hybrid_KEM_PublicKey > load_for_group(Group_Params group, std::span< const uint8_t > concatenated_public_values)
virtual void check_peer_key_acceptable(const Public_Key &public_key) const
virtual bool require_cert_revocation_info() const
virtual size_t minimum_signature_strength() const
Protocol_Version version() const
Definition tls_session.h:74
std::chrono::seconds lifetime_hint() const
std::string fmt(std::string_view format, const T &... args)
Definition fmt.h:53
KyberMode ML_KEM_Mode
Definition ml_kem.h:21
Path_Validation_Result x509_path_validate(const std::vector< X509_Certificate > &end_certs, const Path_Validation_Restrictions &restrictions, const std::vector< Certificate_Store * > &trusted_roots, std::string_view hostname, Usage_Type usage, std::chrono::system_clock::time_point ref_time, std::chrono::milliseconds ocsp_timeout, const std::vector< std::optional< OCSP::Response > > &ocsp_resp)
Signature_Format
Definition pk_keys.h:36
std::vector< T, secure_allocator< T > > secure_vector
Definition secmem.h:128