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

randombit / botan / 21768358452

06 Feb 2026 10:35PM UTC coverage: 90.064% (-0.003%) from 90.067%
21768358452

Pull #5289

github

web-flow
Merge f589db195 into 8ea0ca252
Pull Request #5289: Further misc header reductions, forward declarations, etc

102238 of 113517 relevant lines covered (90.06%)

11357432.36 hits per line

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

86.4
/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 "test_pubkey.h"
9

10
#if defined(BOTAN_HAS_PUBLIC_KEY_CRYPTO)
11

12
   #include "test_rng.h"
13

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

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

27
   #include <array>
28

29
namespace Botan_Tests {
30

31
namespace {
32

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

40
   const std::vector<uint8_t> zero_sig(signature.size());
2,300✔
41
   result.test_eq("all zero signature invalid", verifier.verify_message(message, zero_sig), false);
2,300✔
42

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

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

57
}  // namespace
58

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

67
   size_t ciphertext_accepted = 0;
317✔
68
   size_t ciphertext_rejected = 0;
317✔
69

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

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

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

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

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

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

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

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

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

117
   Test::Result result(test_name.str());
1,257✔
118

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

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

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

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

135
   std::vector<std::unique_ptr<Botan::PK_Verifier>> verifiers;
1,257✔
136

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

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

148
      result.test_eq("KAT signature valid", verifier->verify_message(message, signature), true);
1,257✔
149

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

152
      result.test_eq("KAT signature valid (try 2)", verifier->verify_message(message, signature), true);
1,257✔
153

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

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

160
      std::vector<uint8_t> generated_signature;
5,028✔
161

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

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

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

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

192
   return result;
1,257✔
193
}
6,285✔
194

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

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

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

206
   auto pubkey = load_public_key(vars);
13,082✔
207

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

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

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

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

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

235
            if(expected_valid) {
8,832✔
236
               result.test_eq("correct signature valid with " + verify_provider, verified, true);
4,516✔
237

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

250
   return result;
26,164✔
251
}
52,328✔
252

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

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

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

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

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

274
   return result;
706✔
275
}
2,118✔
276

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

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

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

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

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

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

307
            result.test_eq("correct signature valid with " + provider, verified, true);
1✔
308

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

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

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

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

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

343
   return {result};
2✔
344
}
5✔
345

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

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

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

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

364
   auto privkey = load_private_key(vars);
199✔
365

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

369
   auto pubkey = privkey->public_key();
199✔
370

371
   std::vector<std::unique_ptr<Botan::PK_Decryptor>> decryptors;
199✔
372

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

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

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

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

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

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

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

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

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

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

422
      result.test_lte(
199✔
423
         "Ciphertext within length", generated_ciphertext.size(), encryptor->ciphertext_length(plaintext.size()));
199✔
424

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

434
   return result;
398✔
435
}
995✔
436

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

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

444
   auto privkey = load_private_key(vars);
42✔
445

446
   for(const auto& dec_provider : possible_providers(algo_name())) {
252✔
447
      std::unique_ptr<Botan::PK_Decryptor> decryptor;
168✔
448

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

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

462
      result.test_eq(dec_provider, "decryption of KAT", decrypted, plaintext);
84✔
463
      check_invalid_ciphertexts(result, *decryptor, plaintext, ciphertext, this->rng());
42✔
464
   }
210✔
465

466
   return result;
42✔
467
}
126✔
468

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

475
   Test::Result result(algo_name() + "/" + kdf + " KEM");
60✔
476

477
   auto privkey = load_private_key(vars);
10✔
478

479
   result.confirm("private key claims to support KEM",
20✔
480
                  privkey->supports_operation(Botan::PublicKeyOperation::KeyEncapsulation));
10✔
481

482
   auto pubkey = privkey->public_key();
10✔
483

484
   const size_t desired_key_len = K.size();
10✔
485

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

494
   Fixed_Output_RNG fixed_output_rng(vars.get_req_bin("R"));
20✔
495

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

498
   result.test_eq("encapsulated key length matches expected",
20✔
499
                  kem_result.encapsulated_shared_key().size(),
10✔
500
                  enc->encapsulated_key_length());
501

502
   result.test_eq(
20✔
503
      "shared key length matches expected", kem_result.shared_key().size(), enc->shared_key_length(desired_key_len));
10✔
504

505
   result.test_eq("C0 matches", kem_result.encapsulated_shared_key(), C0);
20✔
506
   result.test_eq("K matches", kem_result.shared_key(), K);
20✔
507

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

516
   result.test_eq("encapsulated key length matches expected",
20✔
517
                  kem_result.encapsulated_shared_key().size(),
10✔
518
                  dec->encapsulated_key_length());
519

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

523
   result.test_eq(
10✔
524
      "shared key length matches expected", decr_shared_key.size(), dec->shared_key_length(desired_key_len));
525

526
   result.test_eq("decrypted K matches", decr_shared_key, K);
20✔
527

528
   return result;
10✔
529
}
50✔
530

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

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

537
   auto privkey = load_our_key(header, vars);
784✔
538

539
   result.confirm("private key claims to support key agreement",
1,568✔
540
                  privkey->supports_operation(Botan::PublicKeyOperation::KeyAgreement));
784✔
541

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

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

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

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

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

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

567
   return result;
784✔
568
}
2,352✔
569

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

576
namespace {
577

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

586
   auto passphrase = Test::random_password(rng);
222✔
587

588
   try {
222✔
589
      Botan::DataSource_Memory data_src(
222✔
590
         Botan::PKCS8::PEM_encode(key, rng, passphrase, std::chrono::milliseconds(1), pbe_algo));
222✔
591

592
      auto loaded = Botan::PKCS8::load_key(data_src, passphrase);
222✔
593

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

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

605
      auto loaded = Botan::PKCS8::load_key(data_src, passphrase);
222✔
606

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

616
}  // namespace
617

618
std::vector<Test::Result> PK_Key_Generation_Test::run() {
21✔
619
   std::vector<Test::Result> results;
21✔
620

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

625
      Test::Result result(report_name + " keygen");
111✔
626

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

629
      if(providers.empty()) {
111✔
630
         result.note_missing("provider key generation " + algorithm_name);
×
631
      }
632

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

637
         if(key_p == nullptr) {
111✔
638
            continue;
×
639
         }
640

641
         const Botan::Private_Key& key = *key_p;
111✔
642

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

647
         const std::string name = key.algo_name();
111✔
648
         result.confirm("Key has a non-empty name", !name.empty());
222✔
649

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

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

664
         result.test_gte("Key has reasonable estimated strength (lower)", key.estimated_strength(), 64);
111✔
665
         result.test_lt("Key has reasonable estimated strength (upper)", key.estimated_strength(), 512);
111✔
666

667
         auto public_key = key.public_key();
111✔
668

669
         result.test_eq("public_key has same name", public_key->algo_name(), key.algo_name());
222✔
670

671
         result.test_eq(
333✔
672
            "public_key has same encoding", Botan::X509::PEM_encode(key), Botan::X509::PEM_encode(*public_key));
222✔
673

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

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

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

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

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

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

726
            result.confirm("recovered public key from private", loaded != nullptr);
222✔
727
            result.test_eq("public key has same type", loaded->algo_name(), key.algo_name());
222✔
728

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

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

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

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

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

762
         try {
111✔
763
            Botan::DataSource_Memory data_src(Botan::PKCS8::BER_encode(key));
111✔
764
            auto loaded = Botan::PKCS8::load_key(data_src);
111✔
765

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

772
   #if defined(BOTAN_HAS_PKCS5_PBES2) && defined(BOTAN_HAS_AES) && defined(BOTAN_HAS_SHA2_32)
773

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

777
   #if defined(BOTAN_HAS_PKCS5_PBES2) && defined(BOTAN_HAS_AES) && defined(BOTAN_HAS_SCRYPT)
778

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

783
      result.end_timer();
111✔
784

785
      results.push_back(result);
111✔
786
   }
132✔
787

788
   return results;
21✔
789
}
×
790

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

794
   if(header != "Valid" && header != "Invalid") {
9✔
795
      throw Test_Error("Unexpected header for PK_Key_Validity_Test");
×
796
   }
797

798
   const bool expected_valid = (header == "Valid");
9✔
799
   auto pubkey = load_public_key(vars);
9✔
800

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

803
   result.test_eq("Expected validation result", tested_valid, expected_valid);
9✔
804

805
   return result;
9✔
806
}
9✔
807

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

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

819
   std::ostringstream report_name;
4✔
820

821
   report_name << algo_name();
8✔
822
   if(!key_param.empty()) {
4✔
823
      report_name << " " << key_param;
4✔
824
   }
825
   report_name << " keygen stability";
4✔
826

827
   Test::Result result(report_name.str());
4✔
828

829
   result.start_timer();
4✔
830

831
   std::unique_ptr<Botan::RandomNumberGenerator> rng;
4✔
832

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

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

846
   if(rng) {
4✔
847
      rng->add_entropy(rng_seed.data(), rng_seed.size());
4✔
848

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

862
   result.end_timer();
4✔
863

864
   return result;
4✔
865
}
12✔
866

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

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

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

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

896
            return nullptr;
×
897
         }();
14✔
898

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

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

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

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

929
            return std::pair<std::unique_ptr<Botan::PK_Signer>, std::unique_ptr<Botan::PK_Verifier>>{};
×
930
         }();
14✔
931

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

938
         result.confirm("Creating PK_Signer works", signer != nullptr);
28✔
939
         result.confirm("Creating PK_Signer works", verifier != nullptr);
28✔
940

941
         result.test_is_nonempty("PK_Signer should report some hash", signer->hash_function());
28✔
942
         result.test_is_nonempty("PK_Verifier should report some hash", verifier->hash_function());
28✔
943

944
         result.test_eq(
42✔
945
            "PK_Signer and PK_Verifier report the same hash", signer->hash_function(), verifier->hash_function());
28✔
946

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

956
         return result;
14✔
957
      }
42✔
958

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

969
BOTAN_REGISTER_TEST("pubkey", "pk_api_sign", PK_API_Sign_Test);
970

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

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

982
         Test::Result result("PK Key Decoding");
1✔
983

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

997
         return result;
1✔
998
      }
1✔
999
};
1000

1001
BOTAN_REGISTER_TEST("pubkey", "pk_key_decoding", PK_Key_Decoding_Test);
1002

1003
}  // namespace Botan_Tests
1004

1005
#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