Botan 3.14.1
Crypto and TLS for C&
pubkey.cpp
Go to the documentation of this file.
1/*
2* (C) 1999-2010,2015,2018,2024 Jack Lloyd
3*
4* Botan is released under the Simplified BSD License (see license.txt)
5*/
6
7#include <botan/pubkey.h>
8
9#include <botan/ber_dec.h>
10#include <botan/bigint.h>
11#include <botan/der_enc.h>
12#include <botan/pk_ops.h>
13#include <botan/pk_options_readers.h>
14#include <botan/rng.h>
15#include <botan/internal/buffer_slicer.h>
16#include <botan/internal/ct_utils.h>
17#include <botan/internal/fmt.h>
18#include <botan/internal/mem_utils.h>
19#include <botan/internal/pk_options_impl.h>
20#include <algorithm>
21
22namespace Botan {
23
24secure_vector<uint8_t> PK_Decryptor::decrypt(const uint8_t in[], size_t length) const {
26
27 uint8_t valid_mask = 0;
28 const size_t ptext_len = do_decrypt(valid_mask, ptext, {in, length});
29
30 // This function reveals whether decryption succeeded, and the length of the plaintext
31 CT::unpoison_all(valid_mask, ptext_len, ptext);
32
33 if(valid_mask == 0) {
34 throw Decoding_Error("Invalid public key ciphertext, cannot decrypt");
35 }
36
37 ptext.resize(ptext_len);
38 return ptext;
39}
40
42 size_t length,
43 size_t expected_pt_len,
45 const uint8_t required_content_bytes[],
46 const uint8_t required_content_offsets[],
47 size_t required_contents_length) const {
48 const secure_vector<uint8_t> fake_pms = [&]() {
49 auto pms = rng.random_vec(expected_pt_len);
50
51 for(size_t i = 0; i != required_contents_length; ++i) {
52 const uint8_t exp = required_content_bytes[i];
53
54 /*
55 If an offset repeats we don't detect this and just return a PMS that satisfies
56 the last requested index. If the requested (idx,value) tuple is the same, that's
57 fine and just redundant. If they disagree, decryption will always fail, since the
58 same byte cannot possibly have two distinct values.
59 */
60 const uint8_t off = required_content_offsets[i];
61 BOTAN_ASSERT(off < expected_pt_len, "Offset in range of plaintext");
62 pms[off] = exp;
63 }
64
65 return pms;
66 }();
67
68 // Whether the ciphertext was valid, and the length of the plaintext, are secret
69 secure_vector<uint8_t> decoded(std::max(plaintext_length(length), expected_pt_len));
70
71 uint8_t decrypt_valid = 0;
72 const size_t decoded_len = do_decrypt(decrypt_valid, decoded, {in, length});
73
74 auto valid_mask = CT::Mask<uint8_t>::is_equal(decrypt_valid, 0xFF);
75 valid_mask &= CT::Mask<uint8_t>(CT::Mask<size_t>::is_equal(decoded_len, expected_pt_len));
76
77 decoded.resize(expected_pt_len);
78
79 for(size_t i = 0; i != required_contents_length; ++i) {
80 const uint8_t exp = required_content_bytes[i];
81
82 // We know off is in range because we already checked it when creating the fake premaster above
83 const uint8_t off = required_content_offsets[i];
84
85 const auto eq = CT::Mask<uint8_t>::is_equal(decoded[off], exp);
86
87 valid_mask &= eq;
88 }
89
90 // If valid_mask is false, assign fake pre master instead
91 valid_mask.select_n(decoded.data(), decoded.data(), fake_pms.data(), expected_pt_len);
92
93 // Any further secret handling of the output is up to the caller
94 CT::unpoison(decoded);
95 return decoded;
96}
97
99 size_t length,
100 size_t expected_pt_len,
101 RandomNumberGenerator& rng) const {
102 return decrypt_or_random(in, length, expected_pt_len, rng, nullptr, nullptr, 0);
103}
104
107 std::string_view padding,
108 std::string_view provider) :
109 PK_Encryptor_EME(key, rng, parse_legacy_enc_options(key, padding).with_provider(provider)) {}
110
113 const PK_Encryption_Options& options) {
114 const PK_Encryption_Options_Reader reader(options);
115
116 m_op = key._create_encryption_op(rng, reader);
117 if(!m_op) {
118 throw Invalid_Argument(fmt("Key type {} does not support encryption", key.algo_name()));
119 }
120
121 reader.throw_if_unexamined(key.algo_name());
122}
123
125
127PK_Encryptor_EME& PK_Encryptor_EME::operator=(PK_Encryptor_EME&&) noexcept = default;
128
129size_t PK_Encryptor_EME::ciphertext_length(size_t ptext_len) const {
130 return m_op->ciphertext_length(ptext_len);
131}
132
133std::vector<uint8_t> PK_Encryptor_EME::enc(const uint8_t ptext[], size_t len, RandomNumberGenerator& rng) const {
134 return m_op->encrypt(std::span{ptext, len}, rng);
135}
136
138 return m_op->max_input_bits() / 8;
139}
140
143 std::string_view padding,
144 std::string_view provider) :
145 PK_Decryptor_EME(key, rng, parse_legacy_enc_options(key, padding).with_provider(provider)) {}
146
149 const PK_Encryption_Options& options) {
150 const PK_Encryption_Options_Reader reader(options);
151
152 m_op = key._create_decryption_op(rng, reader);
153 if(!m_op) {
154 throw Invalid_Argument(fmt("Key type {} does not support decryption", key.algo_name()));
155 }
156
157 reader.throw_if_unexamined(key.algo_name());
158}
159
161
163PK_Decryptor_EME& PK_Decryptor_EME::operator=(PK_Decryptor_EME&&) noexcept = default;
164
165size_t PK_Decryptor_EME::plaintext_length(size_t ctext_len) const {
166 return m_op->plaintext_length(ctext_len);
167}
168
169size_t PK_Decryptor_EME::ciphertext_length(size_t ptext_len) const {
170 return m_op->ciphertext_length(ptext_len);
171}
172
173size_t PK_Decryptor_EME::do_decrypt(uint8_t& valid_mask,
174 std::span<uint8_t> ptext,
175 std::span<const uint8_t> ctext) const {
176 return m_op->decrypt(valid_mask, ptext, ctext);
177}
178
179PK_KEM_Encryptor::PK_KEM_Encryptor(const Public_Key& key, std::string_view param, std::string_view provider) :
180 PK_KEM_Encryptor(key, parse_legacy_kem_options(param).with_provider(provider)) {}
181
183 const PK_KEM_Options_Reader reader(options);
184
185 m_op = key._create_kem_encryption_op(reader);
186 if(!m_op) {
187 throw Invalid_Argument(fmt("Key type {} does not support KEM encryption", key.algo_name()));
188 }
189
190 reader.throw_if_unexamined(key.algo_name());
191}
192
195 std::string_view kem_param,
196 std::string_view provider) :
197 PK_KEM_Encryptor(key, kem_param, provider) {
198 BOTAN_UNUSED(rng);
199}
200
202
204PK_KEM_Encryptor& PK_KEM_Encryptor::operator=(PK_KEM_Encryptor&&) noexcept = default;
205
206size_t PK_KEM_Encryptor::shared_key_length(size_t desired_shared_key_len) const {
207 return m_op->shared_key_length(desired_shared_key_len);
208}
209
211 return m_op->encapsulated_key_length();
212}
213
214void PK_KEM_Encryptor::encrypt(std::span<uint8_t> out_encapsulated_key,
215 std::span<uint8_t> out_shared_key,
217 size_t desired_shared_key_len,
218 std::span<const uint8_t> salt) {
219 BOTAN_ARG_CHECK(out_encapsulated_key.size() == encapsulated_key_length(), "not enough space for encapsulated key");
220 BOTAN_ARG_CHECK(out_shared_key.size() == shared_key_length(desired_shared_key_len),
221 "not enough space for shared key");
222 m_op->kem_encrypt(out_encapsulated_key, out_shared_key, rng, desired_shared_key_len, salt);
223}
224
225size_t PK_KEM_Decryptor::shared_key_length(size_t desired_shared_key_len) const {
226 return m_op->shared_key_length(desired_shared_key_len);
227}
228
230 return m_op->encapsulated_key_length();
231}
232
235 std::string_view param,
236 std::string_view provider) :
237 PK_KEM_Decryptor(key, rng, parse_legacy_kem_options(param).with_provider(provider)) {}
238
240 const PK_KEM_Options_Reader reader(options);
241
242 m_op = key._create_kem_decryption_op(rng, reader);
243 if(!m_op) {
244 throw Invalid_Argument(fmt("Key type {} does not support KEM decryption", key.algo_name()));
245 }
246
247 reader.throw_if_unexamined(key.algo_name());
248}
249
251
253PK_KEM_Decryptor& PK_KEM_Decryptor::operator=(PK_KEM_Decryptor&&) noexcept = default;
254
255void PK_KEM_Decryptor::decrypt(std::span<uint8_t> out_shared_key,
256 std::span<const uint8_t> encap_key,
257 size_t desired_shared_key_len,
258 std::span<const uint8_t> salt) {
259 BOTAN_ARG_CHECK(out_shared_key.size() == shared_key_length(desired_shared_key_len),
260 "inconsistent size of shared key output buffer");
261 m_op->kem_decrypt(out_shared_key, encap_key, desired_shared_key_len, salt);
262}
263
266 std::string_view kdf,
267 std::string_view provider) :
268 PK_Key_Agreement(key, rng, parse_legacy_ka_options(kdf).with_provider(provider)) {}
269
272 const PK_Key_Agreement_Options& options) {
273 const PK_Key_Agreement_Options_Reader reader(options);
274
275 m_op = key._create_key_agreement_op(rng, reader);
276 if(!m_op) {
277 throw Invalid_Argument(fmt("Key type {} does not support key agreement", key.algo_name()));
278 }
279
280 reader.throw_if_unexamined(key.algo_name());
281}
282
284
286PK_Key_Agreement& PK_Key_Agreement::operator=(PK_Key_Agreement&&) noexcept = default;
287
289 return m_op->agreed_value_size();
290}
291
293 const uint8_t peer_key[],
294 size_t peer_key_len,
295 std::string_view salt) const {
296 return this->derive_key(key_len, {peer_key, peer_key_len}, as_span_of_bytes(salt));
297}
298
300 const std::span<const uint8_t> peer_key,
301 std::string_view salt) const {
302 return this->derive_key(key_len, peer_key, as_span_of_bytes(salt));
303}
304
306 std::span<const uint8_t> peer_key,
307 std::span<const uint8_t> salt) const {
308 return SymmetricKey(m_op->agree(key_len, peer_key, salt));
309}
310
313 std::string_view padding,
314 Signature_Format format,
315 std::string_view provider) :
316 PK_Signer(key,
317 rng,
318 parse_legacy_sig_options(key, padding)
319 .with_der_encoded_signature(format == Signature_Format::DerSequence)
320 .with_provider(provider)) {}
321
323 const PK_Signature_Options_Reader reader(options, PK_Signature_Options_Reader::Usage::Signing);
324
325 m_op = key._create_signature_op(rng, reader);
326
327 if(!m_op) {
328 throw Invalid_Argument(fmt("Key type {} does not support signature generation", key.algo_name()));
329 }
331 m_sig_element_size = key._signature_element_size_for_DER_encoding();
332
333 if(m_sig_format == Signature_Format::DerSequence && !m_sig_element_size.has_value()) {
334 throw Invalid_Argument(fmt("Key type {} does not support DER encoded signatures", key.algo_name()));
335 }
336
337 reader.throw_if_unexamined(key.algo_name());
338}
339
341 return m_op->algorithm_identifier();
342}
343
344std::string PK_Signer::hash_function() const {
345 return m_op->hash_function();
346}
347
348PK_Signer::~PK_Signer() = default;
349
350PK_Signer::PK_Signer(PK_Signer&&) noexcept = default;
351PK_Signer& PK_Signer::operator=(PK_Signer&&) noexcept = default;
352
353void PK_Signer::update(std::string_view in) {
354 this->update(as_span_of_bytes(in));
355}
356
357void PK_Signer::update(const uint8_t in[], size_t length) {
358 m_op->update({in, length});
359}
360
361namespace {
362
363std::vector<uint8_t> der_encode_signature(std::span<const uint8_t> sig, size_t parts, size_t part_size) {
364 if(sig.size() % parts != 0 || sig.size() != parts * part_size) {
365 throw Encoding_Error("Unexpected size for DER signature");
366 }
367
368 BufferSlicer bs_sig(sig);
369 std::vector<BigInt> sig_parts;
370 sig_parts.reserve(parts);
371 for(size_t i = 0; i != parts; ++i) {
372 sig_parts.emplace_back(BigInt::from_bytes(bs_sig.take(part_size)));
373 }
374
375 std::vector<uint8_t> output;
376 DER_Encoder(output).start_sequence().encode_list(sig_parts).end_cons();
377 return output;
378}
379
380} // namespace
381
383 if(m_sig_format == Signature_Format::Standard) {
384 return m_op->signature_length();
385 } else if(m_sig_format == Signature_Format::DerSequence) {
386 const size_t sig_len = m_op->signature_length();
387
388 const size_t der_overhead = [sig_len]() {
389 /*
390 This was computed by DER encoding of some maximal value signatures
391 (since DER is variable length)
392
393 The first two cases covers all EC schemes since groups are at most 521
394 bits.
395
396 The other cases are only for finite field DSA which practically is only
397 used up to 3072 bit groups but the calculation is correct up to a
398 262096 (!) bit group so allow it. There are some intermediate sizes but
399 this function is allowed to (and indeed must) return an over-estimate
400 rather than an exact value since the actual length will change based on
401 the computed signature.
402 */
403
404 if(sig_len <= 120) {
405 // EC signatures <= 480 bits
406 return 8;
407 } else if(sig_len <= 248) {
408 // EC signatures > 480 bits (or very small DSA groups...)
409 return 9;
410 } else {
411 // Everything else. This is an over-estimate for groups under
412 // 2040 bits but exact otherwise
413
414 // This requires 15 bytes DER overhead and should never happen
415 BOTAN_ASSERT_NOMSG(sig_len < 65524);
416 return 14;
417 }
418 }();
419
420 return sig_len + der_overhead;
421 } else {
422 throw Internal_Error("PK_Signer: Invalid signature format enum");
423 }
424}
425
427 if(format == Signature_Format::DerSequence) {
428 BOTAN_ARG_CHECK(m_sig_element_size.has_value(), "This key does not support DER signatures");
429 }
430 m_sig_format = format;
431}
432
433std::vector<uint8_t> PK_Signer::signature(RandomNumberGenerator& rng) {
434 // The format is checked before signing, since signing may consume a stateful key index
435 if(m_sig_format == Signature_Format::Standard) {
436 return m_op->sign(rng);
437 } else if(m_sig_format == Signature_Format::DerSequence) {
438 BOTAN_ASSERT_NOMSG(m_sig_element_size.has_value());
439 return der_encode_signature(m_op->sign(rng), 2, m_sig_element_size.value());
440 } else {
441 throw Internal_Error("PK_Signer: Invalid signature format enum");
442 }
443}
444
446 std::string_view padding,
447 Signature_Format format,
448 std::string_view provider) :
449 PK_Verifier(pub_key,
450 parse_legacy_sig_options(pub_key, padding)
451 .with_der_encoded_signature(format == Signature_Format::DerSequence)
452 .with_provider(provider)) {}
453
455 const PK_Signature_Options_Reader reader(options, PK_Signature_Options_Reader::Usage::Verification);
456
457 m_op = key._create_verification_op(reader);
458
459 if(!m_op) {
460 throw Invalid_Argument(fmt("Key type {} does not support signature verification", key.algo_name()));
461 }
462
463 m_sig_element_size = key._signature_element_size_for_DER_encoding();
465
466 if(m_sig_format == Signature_Format::DerSequence && !m_sig_element_size.has_value()) {
467 throw Invalid_Argument(fmt("Key type {} does not support DER encoded signatures", key.algo_name()));
468 }
469
470 reader.throw_if_unexamined(key.algo_name());
471}
472
474 const AlgorithmIdentifier& signature_algorithm,
475 std::string_view provider) {
476 m_op = key.create_x509_verification_op(signature_algorithm, provider);
477 if(!m_op) {
478 throw Invalid_Argument(fmt("Key type {} does not support X.509 signature verification", key.algo_name()));
479 }
480
481 m_sig_format = key._default_x509_signature_format();
482 m_sig_element_size = key._signature_element_size_for_DER_encoding();
483}
484
485PK_Verifier::~PK_Verifier() = default;
486
487PK_Verifier::PK_Verifier(PK_Verifier&&) noexcept = default;
488PK_Verifier& PK_Verifier::operator=(PK_Verifier&&) noexcept = default;
489
490std::string PK_Verifier::hash_function() const {
491 return m_op->hash_function();
492}
493
495 if(format == Signature_Format::DerSequence) {
496 BOTAN_ARG_CHECK(m_sig_element_size.has_value(), "This key does not support DER signatures");
497 }
498 m_sig_format = format;
499}
500
501bool PK_Verifier::verify_message(const uint8_t msg[], size_t msg_length, const uint8_t sig[], size_t sig_length) {
502 update(msg, msg_length);
503 return check_signature(sig, sig_length);
504}
505
506void PK_Verifier::update(std::string_view in) {
507 this->update(as_span_of_bytes(in));
508}
509
510void PK_Verifier::update(const uint8_t in[], size_t length) {
511 m_op->update({in, length});
512}
513
514namespace {
515
516std::vector<uint8_t> decode_der_signature_pair(std::span<const uint8_t> der_sig, size_t sig_part_size) {
517 BOTAN_ASSERT_NOMSG(sig_part_size > 0);
518
519 BigInt r;
520 BigInt s;
521
522 // TODO should be able to just get the integer bytes directly from
523 // BER_Decoder without using BigInt here
525
526 const bool invalid_r = r.is_negative() || r.bytes() > sig_part_size;
527 const bool invalid_s = s.is_negative() || s.bytes() > sig_part_size;
528
529 if(invalid_r || invalid_s) {
530 throw Decoding_Error("Invalid DER encoding of signature");
531 }
532
533 std::vector<uint8_t> sig(2 * sig_part_size);
534 r.serialize_to(std::span{sig}.first(sig_part_size));
535 s.serialize_to(std::span{sig}.last(sig_part_size));
536 return sig;
537}
538
539} // namespace
540
541bool PK_Verifier::check_signature(const uint8_t sig[], size_t length) {
542 try {
543 if(m_sig_format == Signature_Format::Standard) {
544 return m_op->is_valid_signature({sig, length});
545 } else if(m_sig_format == Signature_Format::DerSequence) {
546 bool decoding_success = false;
547 std::vector<uint8_t> real_sig;
548
549 BOTAN_ASSERT_NOMSG(m_sig_element_size.has_value());
550
551 try {
552 real_sig = decode_der_signature_pair({sig, length}, m_sig_element_size.value());
553 decoding_success = true;
554 } catch(...) {}
555
556 // It is critical that is_valid_signature is called even if DER decoding failed, since
557 // that is what resets the internal state (message hashes, etc)
558 const bool accept = m_op->is_valid_signature(real_sig);
559
560 return accept && decoding_success;
561 } else {
562 throw Internal_Error("PK_Verifier: Invalid signature format enum");
563 }
564 } catch(Invalid_Argument&) {
565 return false;
566 } catch(Decoding_Error&) {
567 return false;
568 } catch(Encoding_Error&) {
569 return false;
570 }
571}
572
573} // namespace Botan
#define BOTAN_UNUSED
Definition assert.h:151
#define BOTAN_ASSERT_NOMSG(expr)
Definition assert.h:82
#define BOTAN_ARG_CHECK(expr, msg)
Definition assert.h:33
#define BOTAN_ASSERT(expr, assertion_made)
Definition assert.h:69
virtual std::string algo_name() const =0
virtual std::optional< size_t > _signature_element_size_for_DER_encoding() const
Definition pk_keys.h:148
virtual Signature_Format _default_x509_signature_format() const
Definition pk_keys.cpp:32
static Limits DER()
Definition ber_dec.h:44
BER_Decoder & decode(bool &out)
Definition ber_dec.h:361
BER_Decoder & verify_end()
Definition ber_dec.cpp:471
BER_Decoder & end_cons()
Definition ber_dec.cpp:635
BER_Decoder start_sequence()
Definition ber_dec.h:279
void serialize_to(std::span< uint8_t > out) const
Definition bigint.cpp:396
static BigInt from_bytes(std::span< const uint8_t > bytes)
Definition bigint.cpp:84
bool is_negative() const
Definition bigint.h:623
size_t bytes() const
Definition bigint.cpp:295
static constexpr Mask< T > is_equal(T x, T y)
Definition ct_utils.h:447
DER_Encoder & encode_list(const std::vector< T > &values)
Definition der_enc.h:327
DER_Encoder & start_sequence()
Definition der_enc.h:86
DER_Encoder & end_cons()
Definition der_enc.cpp:208
PK_Decryptor_EME(const Private_Key &key, RandomNumberGenerator &rng, const PK_Encryption_Options &options)
Definition pubkey.cpp:147
~PK_Decryptor_EME() override
size_t plaintext_length(size_t ctext_len) const override
Definition pubkey.cpp:165
size_t ciphertext_length(size_t ptext_len) const override
Definition pubkey.cpp:169
virtual size_t plaintext_length(size_t ctext_len) const =0
secure_vector< uint8_t > decrypt_or_random(const uint8_t in[], size_t length, size_t expected_pt_len, RandomNumberGenerator &rng) const
Definition pubkey.cpp:98
secure_vector< uint8_t > decrypt(const uint8_t in[], size_t length) const
Definition pubkey.cpp:24
~PK_Encryptor_EME() override
PK_Encryptor_EME(const Public_Key &key, RandomNumberGenerator &rng, const PK_Encryption_Options &options)
Definition pubkey.cpp:111
size_t maximum_input_size() const override
Definition pubkey.cpp:137
size_t ciphertext_length(size_t ptext_len) const override
Definition pubkey.cpp:129
size_t encapsulated_key_length() const
Definition pubkey.cpp:229
PK_KEM_Decryptor(const Private_Key &key, RandomNumberGenerator &rng, const PK_KEM_Options &options)
Definition pubkey.cpp:239
size_t shared_key_length(size_t desired_shared_key_len) const
Definition pubkey.cpp:225
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
PK_KEM_Encryptor(const Public_Key &key, const PK_KEM_Options &options)
Definition pubkey.cpp:182
KEM_Encapsulation encrypt(RandomNumberGenerator &rng, size_t desired_shared_key_len=32, std::span< const uint8_t > salt={})
Definition pubkey.h:745
size_t shared_key_length(size_t desired_shared_key_len) const
Definition pubkey.cpp:206
size_t encapsulated_key_length() const
Definition pubkey.cpp:210
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
PK_Key_Agreement(const Private_Key &key, RandomNumberGenerator &rng, const PK_Key_Agreement_Options &options)
Definition pubkey.cpp:270
size_t agreed_value_size() const
Definition pubkey.cpp:288
void update(uint8_t in)
Definition pubkey.h:241
PK_Signer(const Private_Key &key, RandomNumberGenerator &rng, const PK_Signature_Options &options=PK_Signature_Options())
Definition pubkey.cpp:322
size_t signature_length() const
Definition pubkey.cpp:382
std::vector< uint8_t > signature(RandomNumberGenerator &rng)
Definition pubkey.cpp:433
void set_output_format(Signature_Format format)
Definition pubkey.cpp:426
std::string hash_function() const
Definition pubkey.cpp:344
AlgorithmIdentifier algorithm_identifier() const
Definition pubkey.cpp:340
PK_Verifier(const Public_Key &pub_key, const PK_Signature_Options &options=PK_Signature_Options())
Definition pubkey.cpp:454
void set_input_format(Signature_Format format)
Definition pubkey.cpp:494
void update(uint8_t in)
Definition pubkey.h:378
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 hash_function() const
Definition pubkey.cpp:490
bool check_signature(const uint8_t sig[], size_t length)
Definition pubkey.cpp:541
virtual std::unique_ptr< PK_Ops::Key_Agreement > _create_key_agreement_op(RandomNumberGenerator &rng, const PK_Key_Agreement_Options_Reader &options) const
Definition pk_keys.cpp:148
virtual std::unique_ptr< PK_Ops::Signature > _create_signature_op(RandomNumberGenerator &rng, const PK_Signature_Options_Reader &options) const
Definition pk_keys.cpp:142
virtual std::unique_ptr< PK_Ops::KEM_Decryption > _create_kem_decryption_op(RandomNumberGenerator &rng, const PK_KEM_Options_Reader &options) const
Definition pk_keys.cpp:136
virtual std::unique_ptr< PK_Ops::Decryption > _create_decryption_op(RandomNumberGenerator &rng, const PK_Encryption_Options_Reader &options) const
Definition pk_keys.cpp:130
virtual std::unique_ptr< PK_Ops::Verification > _create_verification_op(const PK_Signature_Options_Reader &options) const
Definition pk_keys.cpp:119
virtual std::unique_ptr< PK_Ops::KEM_Encryption > _create_kem_encryption_op(const PK_KEM_Options_Reader &options) const
Definition pk_keys.cpp:113
virtual std::unique_ptr< PK_Ops::Verification > create_x509_verification_op(const AlgorithmIdentifier &signature_algorithm, std::string_view provider) const
Definition pk_keys.cpp:125
virtual std::unique_ptr< PK_Ops::Encryption > _create_encryption_op(RandomNumberGenerator &rng, const PK_Encryption_Options_Reader &options) const
Definition pk_keys.cpp:107
void random_vec(std::span< uint8_t > v)
Definition rng.h:254
constexpr void unpoison_all(const Ts &... ts)
Definition ct_utils.h:207
constexpr void unpoison(const T *p, size_t n)
Definition ct_utils.h:67
OctetString SymmetricKey
Definition symkey.h:153
PK_Encryption_Options parse_legacy_enc_options(const Public_Key &key, std::string_view params)
std::span< const uint8_t > as_span_of_bytes(const char *s, size_t len)
Definition mem_utils.h:59
std::string fmt(std::string_view format, const T &... args)
Definition fmt.h:53
PK_KEM_Options parse_legacy_kem_options(std::string_view params)
PK_Key_Agreement_Options parse_legacy_ka_options(std::string_view params)
PK_Signature_Options parse_legacy_sig_options(const Public_Key &key, std::string_view params)
Signature_Format
Definition pk_keys.h:36
std::vector< T, secure_allocator< T > > secure_vector
Definition secmem.h:128