• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

randombit / botan / 22020273955

14 Feb 2026 04:02PM UTC coverage: 90.059% (-0.005%) from 90.064%
22020273955

push

github

web-flow
Merge pull request #5328 from randombit/jack/test-predicates

Change Test::Result integer and bool predicates to be specifically named

102238 of 113523 relevant lines covered (90.06%)

11567860.88 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

86.58
/src/tests/test_pubkey.cpp
1
/*
2
* (C) 2009,2015 Jack Lloyd
3
* (C) 2017 Ribose Inc
4
*
5
* Botan is released under the Simplified BSD License (see license.txt)
6
*/
7

8
#include "tests.h"
9

10
#if defined(BOTAN_HAS_PUBLIC_KEY_CRYPTO)
11

12
   #include "test_pubkey.h"
13
   #include "test_rng.h"
14

15
   #include <botan/data_src.h>
16
   #include <botan/exceptn.h>
17
   #include <botan/hex.h>
18
   #include <botan/pk_algs.h>
19
   #include <botan/pkcs8.h>
20
   #include <botan/pubkey.h>
21
   #include <botan/x509_key.h>
22
   #include <botan/internal/fmt.h>
23
   #include <botan/internal/stl_util.h>
24

25
   #if defined(BOTAN_HAS_HMAC_DRBG)
26
      #include <botan/hmac_drbg.h>
27
   #endif
28

29
   #include <array>
30

31
namespace Botan_Tests {
32

33
namespace {
34

35
void check_invalid_signatures(Test::Result& result,
2,300✔
36
                              Botan::PK_Verifier& verifier,
37
                              const std::vector<uint8_t>& message,
38
                              const std::vector<uint8_t>& signature,
39
                              Botan::RandomNumberGenerator& rng) {
40
   const size_t tests_to_run = (Test::run_long_tests() ? 20 : 5);
2,300✔
41

42
   const std::vector<uint8_t> zero_sig(signature.size());
2,300✔
43
   result.test_is_false("all zero signature invalid", verifier.verify_message(message, zero_sig));
2,300✔
44

45
   for(size_t i = 0; i < tests_to_run; ++i) {
48,300✔
46
      const std::vector<uint8_t> bad_sig = Test::mutate_vec(signature, rng);
46,000✔
47

48
      try {
46,000✔
49
         if(!result.test_is_false("incorrect signature invalid", verifier.verify_message(message, bad_sig))) {
46,000✔
50
            result.test_note("Accepted invalid signature " + Botan::hex_encode(bad_sig));
×
51
         }
52
      } catch(std::exception& e) {
×
53
         result.test_note("Accepted invalid signature " + Botan::hex_encode(bad_sig));
×
54
         result.test_failure("Modified signature rejected with exception", e.what());
×
55
      }
×
56
   }
46,000✔
57
}
2,300✔
58

59
}  // namespace
60

61
// Exposed for DLIES tests
62
void check_invalid_ciphertexts(Test::Result& result,
317✔
63
                               Botan::PK_Decryptor& decryptor,
64
                               const std::vector<uint8_t>& plaintext,
65
                               const std::vector<uint8_t>& ciphertext,
66
                               Botan::RandomNumberGenerator& rng) {
67
   const size_t tests_to_run = (Test::run_long_tests() ? 20 : 5);
317✔
68

69
   size_t ciphertext_accepted = 0;
317✔
70
   size_t ciphertext_rejected = 0;
317✔
71

72
   for(size_t i = 0; i < tests_to_run; ++i) {
6,657✔
73
      const std::vector<uint8_t> bad_ctext = Test::mutate_vec(ciphertext, rng);
6,340✔
74

75
      try {
6,340✔
76
         const Botan::secure_vector<uint8_t> decrypted = decryptor.decrypt(bad_ctext);
6,340✔
77
         ++ciphertext_accepted;
3,229✔
78

79
         if(!result.test_ne("incorrect ciphertext different", decrypted, plaintext)) {
3,229✔
80
            result.test_eq("used corrupted ciphertext", bad_ctext, ciphertext);
×
81
         }
82
      } catch(std::exception&) {
6,340✔
83
         ++ciphertext_rejected;
3,111✔
84
      }
3,111✔
85
   }
6,340✔
86

87
   result.test_note("Accepted " + std::to_string(ciphertext_accepted) + " invalid ciphertexts, rejected " +
1,268✔
88
                    std::to_string(ciphertext_rejected));
317✔
89
}
317✔
90

91
std::string PK_Test::choose_padding(const VarMap& vars, const std::string& pad_hdr) {
15,286✔
92
   if(!pad_hdr.empty()) {
15,286✔
93
      return pad_hdr;
1,838✔
94
   }
95
   return vars.get_opt_str("Padding", this->default_padding(vars));
26,896✔
96
}
97

98
std::vector<std::string> PK_Test::possible_providers(const std::string& /*params*/) {
17,526✔
99
   return Test::provider_filter({"base", "commoncrypto", "openssl", "tpm"});
17,526✔
100
}
101

102
std::unique_ptr<Botan::RandomNumberGenerator> PK_Signature_Generation_Test::test_rng(
201✔
103
   const std::vector<uint8_t>& nonce) const {
104
   return std::make_unique<Fixed_Output_RNG>(nonce);
201✔
105
}
106

107
Test::Result PK_Signature_Generation_Test::run_one_test(const std::string& pad_hdr, const VarMap& vars) {
1,257✔
108
   const std::vector<uint8_t> message = vars.get_req_bin("Msg");
1,257✔
109
   const std::vector<uint8_t> signature = vars.get_req_bin("Signature");
1,257✔
110
   const std::string padding = choose_padding(vars, pad_hdr);
1,257✔
111

112
   std::ostringstream test_name;
1,257✔
113
   test_name << algo_name();
2,514✔
114
   if(vars.has_key("Group")) {
1,257✔
115
      test_name << "-" << vars.get_req_str("Group");
254✔
116
   }
117
   test_name << "/" << padding << " signature generation";
1,257✔
118

119
   Test::Result result(test_name.str());
1,257✔
120

121
   std::unique_ptr<Botan::Private_Key> privkey;
1,257✔
122
   try {
1,257✔
123
      privkey = load_private_key(vars);
1,257✔
124
   } catch(Botan::Lookup_Error& e) {
×
125
      result.note_missing(e.what());
×
126
      return result;
×
127
   }
×
128

129
   result.confirm("private key claims to support signatures",
1,257✔
130
                  privkey->supports_operation(Botan::PublicKeyOperation::Signature));
1,257✔
131

132
   auto pubkey = Botan::X509::load_key(Botan::X509::BER_encode(*privkey->public_key()));
2,514✔
133

134
   result.confirm("public key claims to support signatures",
1,257✔
135
                  pubkey->supports_operation(Botan::PublicKeyOperation::Signature));
1,257✔
136

137
   std::vector<std::unique_ptr<Botan::PK_Verifier>> verifiers;
1,257✔
138

139
   for(const auto& verify_provider : possible_providers(algo_name())) {
7,542✔
140
      std::unique_ptr<Botan::PK_Verifier> verifier;
5,028✔
141

142
      try {
5,028✔
143
         verifier =
5,028✔
144
            std::make_unique<Botan::PK_Verifier>(*pubkey, padding, Botan::Signature_Format::Standard, verify_provider);
6,285✔
145
      } catch(Botan::Lookup_Error&) {
3,771✔
146
         //result.test_note("Skipping verifying with " + verify_provider);
147
         continue;
3,771✔
148
      }
3,771✔
149

150
      result.test_is_true("KAT signature valid", verifier->verify_message(message, signature));
1,257✔
151

152
      check_invalid_signatures(result, *verifier, message, signature, this->rng());
1,257✔
153

154
      result.test_is_true("KAT signature valid (try 2)", verifier->verify_message(message, signature));
1,257✔
155

156
      verifiers.push_back(std::move(verifier));
1,257✔
157
   }
6,285✔
158

159
   for(const auto& sign_provider : possible_providers(algo_name())) {
7,542✔
160
      std::unique_ptr<Botan::PK_Signer> signer;
5,028✔
161

162
      std::vector<uint8_t> generated_signature;
5,028✔
163

164
      try {
5,028✔
165
         signer = std::make_unique<Botan::PK_Signer>(
5,028✔
166
            *privkey, this->rng(), padding, Botan::Signature_Format::Standard, sign_provider);
6,285✔
167

168
         if(vars.has_key("Nonce")) {
1,257✔
169
            auto rng = test_rng(vars.get_req_bin("Nonce"));
464✔
170
            generated_signature = signer->sign_message(message, *rng);
464✔
171
         } else {
232✔
172
            generated_signature = signer->sign_message(message, this->rng());
2,050✔
173
         }
174

175
         result.test_sz_lte(
1,257✔
176
            "Generated signature within announced bound", generated_signature.size(), signer->signature_length());
177
      } catch(Botan::Lookup_Error&) {
3,771✔
178
         //result.test_note("Skipping signing with " + sign_provider);
179
         continue;
3,771✔
180
      }
3,771✔
181

182
      if(sign_provider == "base") {
1,257✔
183
         result.test_eq("generated signature matches KAT", generated_signature, signature);
1,257✔
184
      } else if(generated_signature != signature) {
×
185
         for(std::unique_ptr<Botan::PK_Verifier>& verifier : verifiers) {
×
186
            if(!result.test_is_true("generated signature valid",
×
187
                                    verifier->verify_message(message, generated_signature))) {
×
188
               result.test_failure("generated signature", generated_signature);
×
189
            }
190
         }
191
      }
192
   }
6,285✔
193

194
   return result;
1,257✔
195
}
6,285✔
196

197
Botan::Signature_Format PK_Signature_Verification_Test::sig_format() const {
4,872✔
198
   return Botan::Signature_Format::Standard;
4,872✔
199
}
200

201
Test::Result PK_Signature_Verification_Test::run_one_test(const std::string& pad_hdr, const VarMap& vars) {
13,082✔
202
   const std::vector<uint8_t> message = vars.get_req_bin("Msg");
13,082✔
203
   const std::vector<uint8_t> signature = vars.get_req_bin("Signature");
13,082✔
204
   const std::string padding = choose_padding(vars, pad_hdr);
13,082✔
205

206
   const bool expected_valid = (vars.get_opt_sz("Valid", 1) == 1);
13,082✔
207

208
   auto pubkey = load_public_key(vars);
13,082✔
209

210
   std::ostringstream result_name;
13,082✔
211
   result_name << algo_name();
26,164✔
212
   if(vars.has_key("Group")) {
13,082✔
213
      result_name << "-" << vars.get_req_str("Group");
24,260✔
214
   }
215
   if(!padding.empty()) {
13,082✔
216
      result_name << "/" << padding;
13,075✔
217
   }
218
   result_name << " signature verification";
13,082✔
219
   Test::Result result(result_name.str());
13,082✔
220

221
   result.confirm("public key claims to support signatures",
13,082✔
222
                  pubkey->supports_operation(Botan::PublicKeyOperation::Signature));
13,082✔
223

224
   for(const auto& verify_provider : possible_providers(algo_name())) {
78,492✔
225
      std::unique_ptr<Botan::PK_Verifier> verifier;
52,328✔
226

227
      try {
52,328✔
228
         verifier = std::make_unique<Botan::PK_Verifier>(*pubkey, padding, sig_format(), verify_provider);
61,160✔
229
      } catch(Botan::Lookup_Error&) {
43,496✔
230
         //result.test_note("Skipping verifying with " + verify_provider);
231
      }
43,496✔
232

233
      if(verifier) {
52,328✔
234
         try {
8,832✔
235
            const bool verified = verifier->verify_message(message, signature);
8,832✔
236

237
            if(expected_valid) {
8,832✔
238
               result.test_is_true("correct signature valid with " + verify_provider, verified);
4,516✔
239

240
               if(test_random_invalid_sigs()) {
4,516✔
241
                  check_invalid_signatures(result, *verifier, message, signature, this->rng());
1,041✔
242
               }
243
            } else {
244
               result.confirm("incorrect signature is rejected", verified == false);
4,316✔
245
            }
246
         } catch(std::exception& e) {
×
247
            result.test_failure("verification threw exception", e.what());
×
248
         }
×
249
      }
250
   }
65,410✔
251

252
   return result;
26,164✔
253
}
52,328✔
254

255
Test::Result PK_Signature_NonVerification_Test::run_one_test(const std::string& pad_hdr, const VarMap& vars) {
706✔
256
   const std::string padding = choose_padding(vars, pad_hdr);
706✔
257
   const std::vector<uint8_t> message = vars.get_req_bin("Msg");
706✔
258
   auto pubkey = load_public_key(vars);
706✔
259

260
   const std::vector<uint8_t> invalid_signature = vars.get_req_bin("InvalidSignature");
706✔
261

262
   Test::Result result(algo_name() + "/" + padding + " verify invalid signature");
4,236✔
263

264
   for(const auto& verify_provider : possible_providers(algo_name())) {
4,236✔
265
      std::unique_ptr<Botan::PK_Verifier> verifier;
2,824✔
266

267
      try {
2,824✔
268
         verifier =
2,824✔
269
            std::make_unique<Botan::PK_Verifier>(*pubkey, padding, Botan::Signature_Format::Standard, verify_provider);
3,530✔
270
         result.test_is_false("incorrect signature rejected", verifier->verify_message(message, invalid_signature));
706✔
271
      } catch(Botan::Lookup_Error&) {
2,118✔
272
         result.test_note("Skipping verifying with " + verify_provider);
2,118✔
273
      }
2,118✔
274
   }
3,530✔
275

276
   return result;
706✔
277
}
2,118✔
278

279
std::vector<Test::Result> PK_Sign_Verify_DER_Test::run() {
1✔
280
   const std::vector<uint8_t> message = {'f', 'o', 'o', 'b', 'a', 'r'};
1✔
281
   const std::string padding = m_padding;
1✔
282

283
   auto privkey = key();
1✔
284
   if(!privkey) {
1✔
285
      return {};
×
286
   }
287
   auto pubkey = privkey->public_key();
1✔
288

289
   Test::Result result(algo_name() + "/" + padding + " signature sign/verify using DER format");
6✔
290

291
   for(const auto& provider : possible_providers(algo_name())) {
3✔
292
      std::unique_ptr<Botan::PK_Signer> signer;
1✔
293
      std::unique_ptr<Botan::PK_Verifier> verifier;
1✔
294

295
      try {
1✔
296
         signer = std::make_unique<Botan::PK_Signer>(
1✔
297
            *privkey, this->rng(), padding, Botan::Signature_Format::DerSequence, provider);
2✔
298
         verifier =
1✔
299
            std::make_unique<Botan::PK_Verifier>(*pubkey, padding, Botan::Signature_Format::DerSequence, provider);
2✔
300
      } catch(Botan::Lookup_Error& e) {
×
301
         result.test_note("Skipping sign/verify with " + provider, e.what());
×
302
      }
×
303

304
      if(signer && verifier) {
1✔
305
         try {
1✔
306
            std::vector<uint8_t> generated_signature = signer->sign_message(message, this->rng());
1✔
307
            const bool verified = verifier->verify_message(message, generated_signature);
1✔
308

309
            result.test_is_true("correct signature valid with " + provider, verified);
1✔
310

311
            if(test_random_invalid_sigs()) {
1✔
312
               check_invalid_signatures(result, *verifier, message, generated_signature, this->rng());
1✔
313
            }
314
         } catch(std::exception& e) {
1✔
315
            result.test_failure("verification threw exception", e.what());
×
316
         }
×
317
      }
318
   }
2✔
319

320
   // Below follows a regression test for a bug introduced in #4592 that caused
321
   // an assertion in PK_Signer when setting the output format explicitly using
322
   // signer.set_output_format(Signature_Format::DerSequence)
323
   try {
1✔
324
      auto signer = Botan::PK_Signer(*privkey, this->rng(), padding /*, not setting DerSequence here */);
1✔
325
      auto verifier = Botan::PK_Verifier(*pubkey, padding /*, not setting DerSequence here */);
1✔
326

327
      // Setting the in/out formats explicitly, to ensure that PK_Signer/Verifier
328
      // handle their internal state properly and not run into an assertion.
329
      signer.set_output_format(Botan::Signature_Format::DerSequence);
1✔
330
      verifier.set_input_format(Botan::Signature_Format::DerSequence);
1✔
331

332
      const auto sig = signer.sign_message(message, this->rng());
1✔
333
      const auto verified = verifier.verify_message(message, sig);
1✔
334

335
      result.confirm("signature checks out", verified);
1✔
336
      if(test_random_invalid_sigs()) {
1✔
337
         check_invalid_signatures(result, verifier, message, sig, this->rng());
1✔
338
      }
339
   } catch(const Botan::Lookup_Error&) {
1✔
340
      result.test_note("Skipping sign/verify regression test");
×
341
   } catch(const std::exception& e) {
×
342
      result.test_failure("regression test verification failed", e.what());
×
343
   }
×
344

345
   return {result};
2✔
346
}
5✔
347

348
std::vector<std::string> PK_Sign_Verify_DER_Test::possible_providers(const std::string& algo_name) {
1✔
349
   const std::vector<std::string> pk_provider =
1✔
350
      Botan::probe_provider_private_key(algo_name, {"base", "commoncrypto", "openssl", "tpm"});
1✔
351
   return Test::provider_filter(pk_provider);
2✔
352
}
1✔
353

354
std::unique_ptr<Botan::RandomNumberGenerator> PK_Encryption_Decryption_Test::test_rng(
54✔
355
   const std::vector<uint8_t>& nonce) const {
356
   return std::make_unique<Fixed_Output_RNG>(nonce);
54✔
357
}
358

359
Test::Result PK_Encryption_Decryption_Test::run_one_test(const std::string& pad_hdr, const VarMap& vars) {
199✔
360
   const std::vector<uint8_t> plaintext = vars.get_req_bin("Msg");
199✔
361
   const std::vector<uint8_t> ciphertext = vars.get_req_bin("Ciphertext");
199✔
362
   const std::string padding = choose_padding(vars, pad_hdr);
199✔
363

364
   Test::Result result(algo_name() + (padding.empty() ? padding : "/" + padding) + " encryption");
995✔
365

366
   auto privkey = load_private_key(vars);
199✔
367

368
   result.confirm("private key claims to support encryption",
199✔
369
                  privkey->supports_operation(Botan::PublicKeyOperation::Encryption));
199✔
370

371
   auto pubkey = privkey->public_key();
199✔
372

373
   std::vector<std::unique_ptr<Botan::PK_Decryptor>> decryptors;
199✔
374

375
   for(const auto& dec_provider : possible_providers(algo_name())) {
1,194✔
376
      std::unique_ptr<Botan::PK_Decryptor> decryptor;
796✔
377

378
      try {
796✔
379
         decryptor = std::make_unique<Botan::PK_Decryptor_EME>(*privkey, this->rng(), padding, dec_provider);
796✔
380
      } catch(Botan::Lookup_Error&) {
597✔
381
         continue;
597✔
382
      }
597✔
383

384
      Botan::secure_vector<uint8_t> decrypted;
199✔
385
      try {
199✔
386
         decrypted = decryptor->decrypt(ciphertext);
199✔
387

388
         result.test_sz_lte(
199✔
389
            "Plaintext within length", decrypted.size(), decryptor->plaintext_length(ciphertext.size()));
199✔
390
      } catch(Botan::Exception& e) {
×
391
         result.test_failure("Failed to decrypt KAT ciphertext", e.what());
×
392
      }
×
393

394
      result.test_eq(dec_provider, "decryption of KAT", decrypted, plaintext);
199✔
395
      check_invalid_ciphertexts(result, *decryptor, plaintext, ciphertext, this->rng());
199✔
396
      decryptors.push_back(std::move(decryptor));
199✔
397
   }
995✔
398

399
   for(const auto& enc_provider : possible_providers(algo_name())) {
1,194✔
400
      std::unique_ptr<Botan::PK_Encryptor> encryptor;
796✔
401

402
      try {
796✔
403
         encryptor = std::make_unique<Botan::PK_Encryptor_EME>(*pubkey, this->rng(), padding, enc_provider);
796✔
404
      } catch(Botan::Lookup_Error&) {
597✔
405
         continue;
597✔
406
      }
597✔
407

408
      std::unique_ptr<Botan::RandomNumberGenerator> kat_rng;
199✔
409
      if(vars.has_key("Nonce")) {
199✔
410
         kat_rng = test_rng(vars.get_req_bin("Nonce"));
118✔
411
      }
412

413
      if(padding == "Raw") {
199✔
414
         /*
415
         Hack for RSA with no padding since sometimes one more bit will fit in but maximum_input_size
416
         rounds down to nearest byte
417
         */
418
         result.test_sz_lte("Input within accepted bounds", plaintext.size(), encryptor->maximum_input_size() + 1);
146✔
419
      } else {
420
         result.test_sz_lte("Input within accepted bounds", plaintext.size(), encryptor->maximum_input_size());
53✔
421
      }
422

423
      const std::vector<uint8_t> generated_ciphertext = encryptor->encrypt(plaintext, kat_rng ? *kat_rng : this->rng());
199✔
424

425
      result.test_sz_lte(
199✔
426
         "Ciphertext within length", generated_ciphertext.size(), encryptor->ciphertext_length(plaintext.size()));
199✔
427

428
      if(enc_provider == "base") {
199✔
429
         result.test_eq(enc_provider, "generated ciphertext matches KAT", generated_ciphertext, ciphertext);
199✔
430
      } else if(generated_ciphertext != ciphertext) {
×
431
         for(std::unique_ptr<Botan::PK_Decryptor>& dec : decryptors) {
×
432
            result.test_eq("decryption of generated ciphertext", dec->decrypt(generated_ciphertext), plaintext);
×
433
         }
434
      }
435
   }
1,054✔
436

437
   return result;
398✔
438
}
995✔
439

440
Test::Result PK_Decryption_Test::run_one_test(const std::string& pad_hdr, const VarMap& vars) {
42✔
441
   const std::vector<uint8_t> plaintext = vars.get_req_bin("Msg");
42✔
442
   const std::vector<uint8_t> ciphertext = vars.get_req_bin("Ciphertext");
42✔
443
   const std::string padding = choose_padding(vars, pad_hdr);
42✔
444

445
   Test::Result result(algo_name() + (padding.empty() ? padding : "/" + padding) + " decryption");
210✔
446

447
   auto privkey = load_private_key(vars);
42✔
448

449
   for(const auto& dec_provider : possible_providers(algo_name())) {
252✔
450
      std::unique_ptr<Botan::PK_Decryptor> decryptor;
168✔
451

452
      try {
168✔
453
         decryptor = std::make_unique<Botan::PK_Decryptor_EME>(*privkey, this->rng(), padding, dec_provider);
168✔
454
      } catch(Botan::Lookup_Error&) {
126✔
455
         continue;
126✔
456
      }
126✔
457

458
      Botan::secure_vector<uint8_t> decrypted;
42✔
459
      try {
42✔
460
         decrypted = decryptor->decrypt(ciphertext);
42✔
461
      } catch(Botan::Exception& e) {
×
462
         result.test_failure("Failed to decrypt KAT ciphertext", e.what());
×
463
      }
×
464

465
      result.test_eq(dec_provider, "decryption of KAT", decrypted, plaintext);
42✔
466
      check_invalid_ciphertexts(result, *decryptor, plaintext, ciphertext, this->rng());
42✔
467
   }
210✔
468

469
   return result;
42✔
470
}
126✔
471

472
Test::Result PK_KEM_Test::run_one_test(const std::string& /*header*/, const VarMap& vars) {
10✔
473
   const std::vector<uint8_t> K = vars.get_req_bin("K");
10✔
474
   const std::vector<uint8_t> C0 = vars.get_req_bin("C0");
10✔
475
   const std::vector<uint8_t> salt = vars.get_opt_bin("Salt");
10✔
476
   const std::string kdf = vars.get_req_str("KDF");
10✔
477

478
   Test::Result result(algo_name() + "/" + kdf + " KEM");
60✔
479

480
   auto privkey = load_private_key(vars);
10✔
481

482
   result.confirm("private key claims to support KEM",
10✔
483
                  privkey->supports_operation(Botan::PublicKeyOperation::KeyEncapsulation));
10✔
484

485
   auto pubkey = privkey->public_key();
10✔
486

487
   const size_t desired_key_len = K.size();
10✔
488

489
   std::unique_ptr<Botan::PK_KEM_Encryptor> enc;
10✔
490
   try {
10✔
491
      enc = std::make_unique<Botan::PK_KEM_Encryptor>(*pubkey, kdf);
20✔
492
   } catch(Botan::Lookup_Error&) {
×
493
      result.test_note("Skipping due to missing KDF: " + kdf);
×
494
      return result;
×
495
   }
×
496

497
   Fixed_Output_RNG fixed_output_rng(vars.get_req_bin("R"));
20✔
498

499
   const auto kem_result = enc->encrypt(fixed_output_rng, desired_key_len, salt);
10✔
500

501
   result.test_sz_eq("encapsulated key length matches expected",
10✔
502
                     kem_result.encapsulated_shared_key().size(),
10✔
503
                     enc->encapsulated_key_length());
504

505
   result.test_sz_eq(
10✔
506
      "shared key length matches expected", kem_result.shared_key().size(), enc->shared_key_length(desired_key_len));
10✔
507

508
   result.test_eq("C0 matches", kem_result.encapsulated_shared_key(), C0);
10✔
509
   result.test_eq("K matches", kem_result.shared_key(), K);
10✔
510

511
   std::unique_ptr<Botan::PK_KEM_Decryptor> dec;
10✔
512
   try {
10✔
513
      dec = std::make_unique<Botan::PK_KEM_Decryptor>(*privkey, this->rng(), kdf);
20✔
514
   } catch(Botan::Lookup_Error& e) {
×
515
      result.test_note("Skipping test", e.what());
×
516
      return result;
×
517
   }
×
518

519
   result.test_sz_eq("encapsulated key length matches expected",
10✔
520
                     kem_result.encapsulated_shared_key().size(),
10✔
521
                     dec->encapsulated_key_length());
522

523
   const Botan::secure_vector<uint8_t> decr_shared_key =
10✔
524
      dec->decrypt(C0.data(), C0.size(), desired_key_len, salt.data(), salt.size());
10✔
525

526
   result.test_sz_eq(
10✔
527
      "shared key length matches expected", decr_shared_key.size(), dec->shared_key_length(desired_key_len));
528

529
   result.test_eq("decrypted K matches", decr_shared_key, K);
10✔
530

531
   return result;
10✔
532
}
50✔
533

534
Test::Result PK_Key_Agreement_Test::run_one_test(const std::string& header, const VarMap& vars) {
784✔
535
   const std::vector<uint8_t> shared = vars.get_req_bin("K");
784✔
536
   const std::string kdf = vars.get_opt_str("KDF", default_kdf(vars));
1,568✔
537

538
   Test::Result result(algo_name() + "/" + kdf + (header.empty() ? header : " " + header) + " key agreement");
6,076✔
539

540
   auto privkey = load_our_key(header, vars);
784✔
541

542
   result.confirm("private key claims to support key agreement",
784✔
543
                  privkey->supports_operation(Botan::PublicKeyOperation::KeyAgreement));
784✔
544

545
   const std::vector<uint8_t> pubkey = load_their_key(header, vars);
784✔
546

547
   const size_t key_len = vars.get_opt_sz("OutLen", 0);
784✔
548

549
   for(const auto& provider : possible_providers(algo_name())) {
4,704✔
550
      std::unique_ptr<Botan::PK_Key_Agreement> kas;
3,136✔
551

552
      try {
3,136✔
553
         kas = std::make_unique<Botan::PK_Key_Agreement>(*privkey, this->rng(), kdf, provider);
3,920✔
554

555
         if(agreement_should_fail(header, vars)) {
784✔
556
            result.test_throws("key agreement fails", [&] { kas->derive_key(key_len, pubkey); });
50✔
557
         } else {
558
            auto derived_key = kas->derive_key(key_len, pubkey).bits_of();
1,518✔
559
            result.test_eq(provider, "agreement", derived_key, shared);
759✔
560

561
            if(key_len == 0 && kdf == "Raw") {
759✔
562
               result.test_sz_eq("Expected size", derived_key.size(), kas->agreed_value_size());
755✔
563
            }
564
         }
759✔
565
      } catch(Botan::Lookup_Error&) {
2,352✔
566
         //result.test_note("Skipping key agreement with with " + provider);
567
      }
2,352✔
568
   }
3,920✔
569

570
   return result;
784✔
571
}
2,352✔
572

573
std::vector<std::string> PK_Key_Generation_Test::possible_providers(const std::string& algo_name) {
111✔
574
   const std::vector<std::string> pk_provider =
111✔
575
      Botan::probe_provider_private_key(algo_name, {"base", "commoncrypto", "openssl", "tpm"});
111✔
576
   return Test::provider_filter(pk_provider);
222✔
577
}
111✔
578

579
namespace {
580

581
   #if defined(BOTAN_HAS_PKCS5_PBES2) && defined(BOTAN_HAS_AES) && \
582
      (defined(BOTAN_HAS_SHA2_32) || defined(BOTAN_HAS_SCRYPT))
583
void test_pbe_roundtrip(Test::Result& result,
222✔
584
                        const Botan::Private_Key& key,
585
                        const std::string& pbe_algo,
586
                        Botan::RandomNumberGenerator& rng) {
587
   const auto pkcs8 = key.private_key_info();
222✔
588

589
   auto passphrase = Test::random_password(rng);
222✔
590

591
   try {
222✔
592
      Botan::DataSource_Memory data_src(
222✔
593
         Botan::PKCS8::PEM_encode(key, rng, passphrase, std::chrono::milliseconds(1), pbe_algo));
222✔
594

595
      auto loaded = Botan::PKCS8::load_key(data_src, passphrase);
222✔
596

597
      result.confirm("recovered private key from encrypted blob", loaded != nullptr);
222✔
598
      result.test_eq("reloaded key has same type", loaded->algo_name(), key.algo_name());
222✔
599
      result.test_eq("reloaded key has same encoding", loaded->private_key_info(), pkcs8);
444✔
600
   } catch(std::exception& e) {
444✔
601
      result.test_failure("roundtrip encrypted PEM private key", e.what());
×
602
   }
×
603

604
   try {
222✔
605
      Botan::DataSource_Memory data_src(
222✔
606
         Botan::PKCS8::BER_encode(key, rng, passphrase, std::chrono::milliseconds(1), pbe_algo));
444✔
607

608
      auto loaded = Botan::PKCS8::load_key(data_src, passphrase);
222✔
609

610
      result.confirm("recovered private key from BER blob", loaded != nullptr);
222✔
611
      result.test_eq("reloaded key has same type", loaded->algo_name(), key.algo_name());
222✔
612
      result.test_eq("reloaded key has same encoding", loaded->private_key_info(), pkcs8);
444✔
613
   } catch(std::exception& e) {
444✔
614
      result.test_failure("roundtrip encrypted BER private key", e.what());
×
615
   }
×
616
}
444✔
617
   #endif
618

619
}  // namespace
620

621
std::vector<Test::Result> PK_Key_Generation_Test::run() {
21✔
622
   std::vector<Test::Result> results;
21✔
623

624
   for(const auto& param : keygen_params()) {
132✔
625
      const auto algorithm_name = algo_name(param);
111✔
626
      const std::string report_name = Botan::fmt("{}{}", algorithm_name, (param.empty() ? param : " " + param));
115✔
627

628
      Test::Result result(report_name + " keygen");
111✔
629

630
      const std::vector<std::string> providers = possible_providers(algorithm_name);
111✔
631

632
      if(providers.empty()) {
111✔
633
         result.note_missing("provider key generation " + algorithm_name);
×
634
      }
635

636
      result.start_timer();
111✔
637
      for(auto&& prov : providers) {
222✔
638
         auto key_p = Botan::create_private_key(algorithm_name, this->rng(), param, prov);
111✔
639

640
         if(key_p == nullptr) {
111✔
641
            continue;
×
642
         }
643

644
         const Botan::Private_Key& key = *key_p;
111✔
645

646
         try {
111✔
647
            result.confirm("Key passes self tests", key.check_key(this->rng(), true));
111✔
648
         } catch(Botan::Lookup_Error&) {}
×
649

650
         const std::string name = key.algo_name();
111✔
651
         result.confirm("Key has a non-empty name", !name.empty());
111✔
652

653
         if(auto oid = Botan::OID::from_name(name)) {
111✔
654
            result.test_success("Keys name maps to an OID");
65✔
655

656
            result.test_eq("Keys name OID is the same as the object oid",
130✔
657
                           oid.value().to_string(),
130✔
658
                           key.object_identifier().to_string());
130✔
659
         } else {
660
            const bool exception = name == "Kyber" || name == "ML-KEM" || name == "ML-DSA" || name == "SLH-DSA" ||
40✔
661
                                   name == "FrodoKEM" || name == "SPHINCS+" || name == "ClassicMcEliece";
151✔
662
            if(!exception) {
×
663
               result.test_failure("Keys name " + name + " does not map to an OID");
×
664
            }
665
         }
×
666

667
         result.test_sz_gte("Key has reasonable estimated strength (lower)", key.estimated_strength(), 64);
111✔
668
         result.test_sz_lt("Key has reasonable estimated strength (upper)", key.estimated_strength(), 512);
111✔
669

670
         auto public_key = key.public_key();
111✔
671

672
         result.test_eq("public_key has same name", public_key->algo_name(), key.algo_name());
111✔
673

674
         result.test_eq(
222✔
675
            "public_key has same encoding", Botan::X509::PEM_encode(key), Botan::X509::PEM_encode(*public_key));
222✔
676

677
         // Test generation of another key pair from a given (abstract) asymmetric key
678
         // KEX algorithms must support that (so that we can generate ephemeral keys in
679
         // an abstract fashion). For other algorithms it's a nice-to-have.
680
         try {
111✔
681
            auto sk2 = public_key->generate_another(this->rng());
111✔
682
            auto pk2 = sk2->public_key();
110✔
683

684
            result.test_eq("new private key has the same name", sk2->algo_name(), key.algo_name());
110✔
685
            result.test_eq("new public key has the same name", pk2->algo_name(), public_key->algo_name());
110✔
686
            result.test_sz_eq(
110✔
687
               "new private key has the same est. strength", sk2->estimated_strength(), key.estimated_strength());
110✔
688
            result.test_sz_eq("new public key has the same est. strength",
110✔
689
                              pk2->estimated_strength(),
110✔
690
                              public_key->estimated_strength());
110✔
691
            result.test_ne("new private keys are different keys", sk2->private_key_bits(), key.private_key_bits());
330✔
692
         } catch(const Botan::Not_Implemented&) {
221✔
693
            result.confirm("KEX algorithms are required to implement 'generate_another'",
1✔
694
                           !public_key->supports_operation(Botan::PublicKeyOperation::KeyAgreement));
1✔
695
         }
1✔
696

697
         // Test that the raw public key can be encoded. This is not supported
698
         // by all algorithms; we expect Not_Implemented for these.
699
         const std::vector<std::string> algos_that_dont_have_a_raw_encoding = {"RSA"};
111✔
700
         try {
111✔
701
            auto raw = public_key->raw_public_key_bits();
111✔
702
            result.test_sz_ne("raw_public_key_bits is not empty", raw.size(), 0);
109✔
703

704
            if(public_key->supports_operation(Botan::PublicKeyOperation::KeyAgreement)) {
109✔
705
               // For KEX algorithms, raw_public_key_bits must be equal to the canonical
706
               // public value obtained by PK_Key_Agreement_Key::public_value().
707
               const auto* ka_key = dynamic_cast<const Botan::PK_Key_Agreement_Key*>(&key);
10✔
708
               result.require("is a key agreement private key", ka_key != nullptr);
10✔
709
               result.test_eq("public_key_bits has same encoding", raw, ka_key->public_value());
20✔
710
            }
711

712
            if(auto raw_pk = public_key_from_raw(param, prov, raw)) {
109✔
713
               result.test_eq("public_key has same type", raw_pk->algo_name(), public_key->algo_name());
109✔
714
               result.test_eq("public_key has same encoding", raw_pk->public_key_bits(), public_key->public_key_bits());
327✔
715
            }
109✔
716
         } catch(const Botan::Not_Implemented&) {
111✔
717
            if(!Botan::value_exists(algos_that_dont_have_a_raw_encoding, public_key->algo_name())) {
4✔
718
               result.test_failure("raw_public_key_bits not implemented for " + public_key->algo_name());
×
719
            } else {
720
               result.test_note("raw_public_key_bits threw Not_Implemented as expected for " + public_key->algo_name());
6✔
721
            }
722
         }
2✔
723

724
         // Test PEM public key round trips OK
725
         try {
111✔
726
            Botan::DataSource_Memory data_src(Botan::X509::PEM_encode(*public_key));
111✔
727
            auto loaded = Botan::X509::load_key(data_src);
111✔
728

729
            result.confirm("recovered public key from private", loaded != nullptr);
111✔
730
            result.test_eq("public key has same type", loaded->algo_name(), key.algo_name());
111✔
731

732
            try {
111✔
733
               result.test_is_true("public key passes checks", loaded->check_key(this->rng(), false));
111✔
734
            } catch(Botan::Lookup_Error&) {}
×
735
         } catch(std::exception& e) {
222✔
736
            result.test_failure("roundtrip PEM public key", e.what());
×
737
         }
×
738

739
         // Test DER public key round trips OK
740
         try {
111✔
741
            const auto ber = public_key->subject_public_key();
111✔
742
            Botan::DataSource_Memory data_src(ber);
111✔
743
            auto loaded = Botan::X509::load_key(data_src);
111✔
744

745
            result.confirm("recovered public key from private", loaded != nullptr);
111✔
746
            result.test_eq("public key has same type", loaded->algo_name(), key.algo_name());
111✔
747
            result.test_eq("public key has same encoding", loaded->subject_public_key(), ber);
222✔
748
         } catch(std::exception& e) {
333✔
749
            result.test_failure("roundtrip BER public key", e.what());
×
750
         }
×
751

752
         // Test PEM private key round trips OK
753
         try {
111✔
754
            const auto ber = key.private_key_info();
111✔
755
            Botan::DataSource_Memory data_src(ber);
111✔
756
            auto loaded = Botan::PKCS8::load_key(data_src);
111✔
757

758
            result.confirm("recovered private key from PEM blob", loaded != nullptr);
111✔
759
            result.test_eq("reloaded key has same type", loaded->algo_name(), key.algo_name());
111✔
760
            result.test_eq("reloaded key has same encoding", loaded->private_key_info(), ber);
222✔
761
         } catch(std::exception& e) {
333✔
762
            result.test_failure("roundtrip PEM private key", e.what());
×
763
         }
×
764

765
         try {
111✔
766
            Botan::DataSource_Memory data_src(Botan::PKCS8::BER_encode(key));
111✔
767
            auto loaded = Botan::PKCS8::load_key(data_src);
111✔
768

769
            result.confirm("recovered public key from private", loaded != nullptr);
111✔
770
            result.test_eq("public key has same type", loaded->algo_name(), key.algo_name());
111✔
771
         } catch(std::exception& e) {
222✔
772
            result.test_failure("roundtrip BER private key", e.what());
×
773
         }
×
774

775
   #if defined(BOTAN_HAS_PKCS5_PBES2) && defined(BOTAN_HAS_AES) && defined(BOTAN_HAS_SHA2_32)
776

777
         test_pbe_roundtrip(result, key, "PBE-PKCS5v20(AES-128/CBC,SHA-256)", this->rng());
111✔
778
   #endif
779

780
   #if defined(BOTAN_HAS_PKCS5_PBES2) && defined(BOTAN_HAS_AES) && defined(BOTAN_HAS_SCRYPT)
781

782
         test_pbe_roundtrip(result, key, "PBES2(AES-128/CBC,Scrypt)", this->rng());
111✔
783
   #endif
784
      }
333✔
785

786
      result.end_timer();
111✔
787

788
      results.push_back(result);
111✔
789
   }
132✔
790

791
   return results;
21✔
792
}
111✔
793

794
Test::Result PK_Key_Validity_Test::run_one_test(const std::string& header, const VarMap& vars) {
9✔
795
   Test::Result result(algo_name() + " key validity");
27✔
796

797
   if(header != "Valid" && header != "Invalid") {
9✔
798
      throw Test_Error("Unexpected header for PK_Key_Validity_Test");
×
799
   }
800

801
   const bool expected_valid = (header == "Valid");
9✔
802
   auto pubkey = load_public_key(vars);
9✔
803

804
   const bool tested_valid = pubkey->check_key(this->rng(), true);
9✔
805

806
   result.test_bool_eq("Expected validation result", tested_valid, expected_valid);
9✔
807

808
   return result;
9✔
809
}
9✔
810

811
PK_Key_Generation_Stability_Test::PK_Key_Generation_Stability_Test(const std::string& algo,
2✔
812
                                                                   const std::string& test_src) :
2✔
813
      PK_Test(algo, test_src, "Rng,RngSeed,Key", "KeyParams,RngParams") {}
4✔
814

815
Test::Result PK_Key_Generation_Stability_Test::run_one_test(const std::string& /*header*/, const VarMap& vars) {
4✔
816
   const std::string key_param = vars.get_opt_str("KeyParams", "");
8✔
817
   const std::string rng_algo = vars.get_req_str("Rng");
4✔
818
   const std::string rng_params = vars.get_opt_str("RngParams", "");
8✔
819
   const std::vector<uint8_t> rng_seed = vars.get_req_bin("RngSeed");
4✔
820
   const std::vector<uint8_t> expected_key = vars.get_req_bin("Key");
4✔
821

822
   std::ostringstream report_name;
4✔
823

824
   report_name << algo_name();
8✔
825
   if(!key_param.empty()) {
4✔
826
      report_name << " " << key_param;
4✔
827
   }
828
   report_name << " keygen stability";
4✔
829

830
   Test::Result result(report_name.str());
4✔
831

832
   result.start_timer();
4✔
833

834
   std::unique_ptr<Botan::RandomNumberGenerator> rng;
4✔
835

836
   #if defined(BOTAN_HAS_HMAC_DRBG)
837
   if(rng_algo == "HMAC_DRBG") {
4✔
838
      rng = std::make_unique<Botan::HMAC_DRBG>(rng_params);
2✔
839
   }
840
   #endif
841

842
   if(rng_algo == "Fixed") {
4✔
843
      if(!rng_params.empty()) {
2✔
844
         throw Test_Error("Expected empty RngParams for Fixed RNG");
×
845
      }
846
      rng = std::make_unique<Fixed_Output_RNG>();
4✔
847
   }
848

849
   if(rng) {
4✔
850
      rng->add_entropy(rng_seed.data(), rng_seed.size());
4✔
851

852
      try {
4✔
853
         auto key = Botan::create_private_key(algo_name(), *rng, key_param);
8✔
854
         if(key) {
4✔
855
            const auto key_bits = key->private_key_info();
4✔
856
            result.test_eq("Generated key matched expected value", key_bits, expected_key);
4✔
857
         }
4✔
858
      } catch(Botan::Exception& e) {
4✔
859
         result.test_note("failed to create key", e.what());
×
860
      }
×
861
   } else {
862
      result.test_note("Skipping test due to unavailable RNG");
×
863
   }
864

865
   result.end_timer();
4✔
866

867
   return result;
4✔
868
}
12✔
869

870
/**
871
 * @brief Some general tests for minimal API sanity for signing/verification.
872
 */
873
class PK_API_Sign_Test : public Text_Based_Test {
874
   public:
875
      PK_API_Sign_Test() : Text_Based_Test("pubkey/api_sign.vec", "AlgoParams,SigParams", "Provider") {}
2✔
876

877
   protected:
878
      Test::Result run_one_test(const std::string& algorithm, const VarMap& vars) final {
14✔
879
         const std::string algo_params = vars.get_req_str("AlgoParams");
14✔
880
         const std::string sig_params = vars.get_req_str("SigParams");
14✔
881
         const std::string verify_params = vars.get_opt_str("VerifyParams", sig_params);
14✔
882
         const std::string provider = vars.get_opt_str("Provider", "base");
28✔
883

884
         std::ostringstream test_name;
14✔
885
         test_name << "Sign/verify API tests " << algorithm;
14✔
886
         if(!algo_params.empty()) {
14✔
887
            test_name << '(' << algo_params << ')';
12✔
888
         }
889
         if(!sig_params.empty()) {
14✔
890
            test_name << '/' << sig_params;
11✔
891
         }
892
         Test::Result result(test_name.str());
14✔
893

894
         auto privkey = [&]() -> std::unique_ptr<Botan::Private_Key> {
42✔
895
            try {
14✔
896
               return Botan::create_private_key(algorithm, this->rng(), algo_params, provider);
14✔
897
            } catch(Botan::Not_Implemented&) {}
×
898

899
            return nullptr;
×
900
         }();
14✔
901

902
         if(!privkey) {
14✔
903
            result.test_note(Botan::fmt(
×
904
               "Skipping Sign/verify API tests for {}({}) with provider {}", algorithm, algo_params, provider));
905
            return result;
×
906
         }
907

908
         auto pubkey = Botan::X509::load_key(Botan::X509::BER_encode(*privkey->public_key()));
28✔
909
         result.confirm("Storing and loading public key works", pubkey != nullptr);
14✔
910

911
         result.confirm("private key claims to support signatures",
14✔
912
                        privkey->supports_operation(Botan::PublicKeyOperation::Signature));
14✔
913
         result.confirm("public key claims to support signatures",
14✔
914
                        pubkey->supports_operation(Botan::PublicKeyOperation::Signature));
14✔
915
         result.test_sz_gt("Public key length must be greater than 0", pubkey->key_length(), 0);
14✔
916
         if(privkey->stateful_operation()) {
14✔
917
            result.confirm("A stateful key reports the number of remaining operations",
2✔
918
                           privkey->remaining_operations().has_value());
2✔
919
         } else {
920
            result.confirm("A stateless key has an unlimited number of remaining operations",
12✔
921
                           !privkey->remaining_operations().has_value());
12✔
922
         }
923

924
         auto [signer, verifier] = [&] {
14✔
925
            try {
14✔
926
               return std::make_pair(std::make_unique<Botan::PK_Signer>(
14✔
927
                                        *privkey, this->rng(), sig_params, Botan::Signature_Format::Standard, provider),
14✔
928
                                     std::make_unique<Botan::PK_Verifier>(
14✔
929
                                        *pubkey, verify_params, Botan::Signature_Format::Standard, provider));
42✔
930
            } catch(Botan::Algorithm_Not_Found&) {}
×
931

932
            return std::pair<std::unique_ptr<Botan::PK_Signer>, std::unique_ptr<Botan::PK_Verifier>>{};
×
933
         }();
14✔
934

935
         if(!signer || !verifier) {
14✔
936
            result.test_note(Botan::fmt(
×
937
               "Skipping Sign/verify API tests for {}({}) with provider {}", algorithm, algo_params, provider));
938
            return result;
×
939
         }
940

941
         result.confirm("Creating PK_Signer works", signer != nullptr);
14✔
942
         result.confirm("Creating PK_Signer works", verifier != nullptr);
14✔
943

944
         result.test_is_nonempty("PK_Signer should report some hash", signer->hash_function());
14✔
945
         result.test_is_nonempty("PK_Verifier should report some hash", verifier->hash_function());
14✔
946

947
         result.test_eq(
14✔
948
            "PK_Signer and PK_Verifier report the same hash", signer->hash_function(), verifier->hash_function());
28✔
949

950
         pubkey.reset();
14✔
951
         privkey.reset();
14✔
952
         const std::array<uint8_t, 4> msg{0xde, 0xad, 0xbe, 0xef};
14✔
953
         const auto sig = signer->sign_message(msg, this->rng());
14✔
954
         result.test_sz_gt("Signer should still work if no one else hold a reference to the key", sig.size(), 0);
14✔
955
         result.test_is_true("Verifier should still work if no one else hold a reference to the key",
14✔
956
                             verifier->verify_message(msg, sig));
14✔
957

958
         return result;
14✔
959
      }
42✔
960

961
      bool skip_this_test([[maybe_unused]] const std::string& header, const VarMap& /*vars*/) override {
14✔
962
   #if !defined(BOTAN_HAS_SLH_DSA_WITH_SHA2)
963
         if(header == "SLH-DSA") {
964
            return true;
965
         }
966
   #endif
967
         return false;
14✔
968
      }
969
};
970

971
BOTAN_REGISTER_TEST("pubkey", "pk_api_sign", PK_API_Sign_Test);
972

973
/**
974
 * @brief Testing PK key decoding
975
 */
976
class PK_Key_Decoding_Test : public Text_Based_Test {
977
   public:
978
      PK_Key_Decoding_Test() : Text_Based_Test("pubkey/key_encoding.vec", "Key") {}
2✔
979

980
   protected:
981
      Test::Result run_one_test(const std::string& /*header*/, const VarMap& vars) final {
1✔
982
         const auto key = vars.get_req_bin("Key");
1✔
983

984
         Test::Result result("PK Key Decoding");
1✔
985

986
         try {
1✔
987
            auto k = Botan::PKCS8::load_key(key);
1✔
988
            result.test_success("Was able to deserialize the key");
1✔
989
         } catch(Botan::Not_Implemented&) {
1✔
990
            result.test_note("Skipping test due to to algorithm being unavailable");
×
991
         } catch(Botan::Exception& e) {
×
992
            if(std::string(e.what()).starts_with("Unknown or unavailable public key algorithm")) {
×
993
               result.test_note("Skipping test due to to algorithm being unavailable");
×
994
            } else {
995
               result.test_failure("Failed to deserialize key", e.what());
×
996
            }
997
         }
×
998

999
         return result;
1✔
1000
      }
1✔
1001
};
1002

1003
BOTAN_REGISTER_TEST("pubkey", "pk_key_decoding", PK_Key_Decoding_Test);
1004

1005
}  // namespace Botan_Tests
1006

1007
#endif
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc