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

randombit / botan / 21786344715

07 Feb 2026 08:25PM UTC coverage: 90.068% (-0.005%) from 90.073%
21786344715

Pull #5295

github

web-flow
Merge 8d5fc3b23 into ebf8f0044
Pull Request #5295: Reduce header dependencies in tests and cli

102234 of 113507 relevant lines covered (90.07%)

11372278.81 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 "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_eq("all zero signature invalid", verifier.verify_message(message, zero_sig), false);
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_eq("incorrect signature invalid", verifier.verify_message(message, bad_sig), false)) {
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,228✔
78

79
         if(!result.test_ne("incorrect ciphertext different", decrypted, plaintext)) {
6,456✔
80
            result.test_eq("used corrupted ciphertext", bad_ctext, ciphertext);
×
81
         }
82
      } catch(std::exception&) {
6,340✔
83
         ++ciphertext_rejected;
3,112✔
84
      }
3,112✔
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",
2,514✔
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",
2,514✔
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_eq("KAT signature valid", verifier->verify_message(message, signature), true);
1,257✔
151

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

154
      result.test_eq("KAT signature valid (try 2)", verifier->verify_message(message, signature), true);
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_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);
2,514✔
184
      } else if(generated_signature != signature) {
×
185
         for(std::unique_ptr<Botan::PK_Verifier>& verifier : verifiers) {
×
186
            if(!result.test_eq(
×
187
                  "generated signature valid", verifier->verify_message(message, generated_signature), true)) {
×
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",
26,164✔
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_eq("correct signature valid with " + verify_provider, verified, true);
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);
8,632✔
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_eq("incorrect signature rejected", verifier->verify_message(message, invalid_signature), false);
1,412✔
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_eq("correct signature valid with " + provider, verified, true);
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);
2✔
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",
398✔
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_lte("Plaintext within length", decrypted.size(), decryptor->plaintext_length(ciphertext.size()));
398✔
389
      } catch(Botan::Exception& e) {
×
390
         result.test_failure("Failed to decrypt KAT ciphertext", e.what());
×
391
      }
×
392

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

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

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

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

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

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

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

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

436
   return result;
398✔
437
}
995✔
438

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

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

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

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

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

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

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

468
   return result;
42✔
469
}
126✔
470

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

528
   result.test_eq("decrypted K matches", decr_shared_key, K);
20✔
529

530
   return result;
10✔
531
}
50✔
532

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

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

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

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

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

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

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

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

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

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

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

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

578
namespace {
579

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

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

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

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

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

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

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

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

618
}  // namespace
619

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

785
      result.end_timer();
111✔
786

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

790
   return results;
21✔
791
}
×
792

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

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

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

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

805
   result.test_eq("Expected validation result", tested_valid, expected_valid);
9✔
806

807
   return result;
9✔
808
}
9✔
809

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

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

821
   std::ostringstream report_name;
4✔
822

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

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

831
   result.start_timer();
4✔
832

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

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

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

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

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

864
   result.end_timer();
4✔
865

866
   return result;
4✔
867
}
12✔
868

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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