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

randombit / botan / 11087146043

28 Sep 2024 09:28PM UTC coverage: 92.003% (+0.7%) from 91.274%
11087146043

push

github

web-flow
Create terraform.yml

82959 of 90170 relevant lines covered (92.0%)

9376319.11 hits per line

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

95.52
/src/lib/pubkey/pk_algs.cpp
1
/*
2
* PK Key
3
* (C) 1999-2010,2016 Jack Lloyd
4
*
5
* Botan is released under the Simplified BSD License (see license.txt)
6
*/
7

8
#include <botan/pk_algs.h>
9

10
#include <botan/internal/fmt.h>
11
#include <botan/internal/parsing.h>
12

13
#if defined(BOTAN_HAS_RSA)
14
   #include <botan/rsa.h>
15
#endif
16

17
#if defined(BOTAN_HAS_DSA)
18
   #include <botan/dsa.h>
19
#endif
20

21
#if defined(BOTAN_HAS_DL_GROUP)
22
   #include <botan/dl_group.h>
23
#endif
24

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

29
#if defined(BOTAN_HAS_ECC_PUBLIC_KEY_CRYPTO)
30
   #include <botan/ecc_key.h>
31
#endif
32

33
#if defined(BOTAN_HAS_ECDSA)
34
   #include <botan/ecdsa.h>
35
#endif
36

37
#if defined(BOTAN_HAS_ECGDSA)
38
   #include <botan/ecgdsa.h>
39
#endif
40

41
#if defined(BOTAN_HAS_ECKCDSA)
42
   #include <botan/eckcdsa.h>
43
#endif
44

45
#if defined(BOTAN_HAS_ED25519)
46
   #include <botan/ed25519.h>
47
#endif
48

49
#if defined(BOTAN_HAS_ED448)
50
   #include <botan/ed448.h>
51
#endif
52

53
#if defined(BOTAN_HAS_GOST_34_10_2001)
54
   #include <botan/gost_3410.h>
55
#endif
56

57
#if defined(BOTAN_HAS_ELGAMAL)
58
   #include <botan/elgamal.h>
59
#endif
60

61
#if defined(BOTAN_HAS_ECDH)
62
   #include <botan/ecdh.h>
63
#endif
64

65
#if defined(BOTAN_HAS_X25519)
66
   #include <botan/x25519.h>
67
#endif
68

69
#if defined(BOTAN_HAS_X448)
70
   #include <botan/x448.h>
71
#endif
72

73
#if defined(BOTAN_HAS_MCELIECE)
74
   #include <botan/mceliece.h>
75
#endif
76

77
#if defined(BOTAN_HAS_FRODOKEM)
78
   #include <botan/frodokem.h>
79
#endif
80

81
#if defined(BOTAN_HAS_KYBER) || defined(BOTAN_HAS_KYBER_90S)
82
   #include <botan/kyber.h>
83
#endif
84

85
#if defined(BOTAN_HAS_XMSS_RFC8391)
86
   #include <botan/xmss.h>
87
#endif
88

89
#if defined(BOTAN_HAS_SM2)
90
   #include <botan/sm2.h>
91
#endif
92

93
#if defined(BOTAN_HAS_DILITHIUM) || defined(BOTAN_HAS_DILITHIUM_AES)
94
   #include <botan/dilithium.h>
95
#endif
96

97
#if defined(BOTAN_HAS_SPHINCS_PLUS_WITH_SHA2) || defined(BOTAN_HAS_SPHINCS_PLUS_WITH_SHAKE)
98
   #include <botan/sphincsplus.h>
99
#endif
100

101
namespace Botan {
102

103
std::unique_ptr<Public_Key> load_public_key(const AlgorithmIdentifier& alg_id,
17,940✔
104
                                            [[maybe_unused]] std::span<const uint8_t> key_bits) {
105
   const std::string oid_str = alg_id.oid().to_formatted_string();
17,940✔
106
   const std::vector<std::string> alg_info = split_on(oid_str, '/');
17,940✔
107
   std::string_view alg_name = alg_info[0];
17,940✔
108

109
#if defined(BOTAN_HAS_RSA)
110
   if(alg_name == "RSA") {
18,192✔
111
      return std::make_unique<RSA_PublicKey>(alg_id, key_bits);
24,771✔
112
   }
113
#endif
114

115
#if defined(BOTAN_HAS_X25519)
116
   if(alg_name == "X25519" || alg_name == "Curve25519") {
5,226✔
117
      return std::make_unique<X25519_PublicKey>(alg_id, key_bits);
48✔
118
   }
119
#endif
120

121
#if defined(BOTAN_HAS_X448)
122
   if(alg_name == "X448") {
5,165✔
123
      return std::make_unique<X448_PublicKey>(alg_id, key_bits);
4✔
124
   }
125
#endif
126

127
#if defined(BOTAN_HAS_MCELIECE)
128
   if(alg_name == "McEliece") {
5,103✔
129
      return std::make_unique<McEliece_PublicKey>(key_bits);
2✔
130
   }
131
#endif
132

133
#if defined(BOTAN_HAS_FRODOKEM)
134
   if(alg_name == "FrodoKEM" || alg_name.starts_with("FrodoKEM-") || alg_name.starts_with("eFrodoKEM-")) {
5,102✔
135
      return std::make_unique<FrodoKEM_PublicKey>(alg_id, key_bits);
632✔
136
   }
137
#endif
138

139
#if defined(BOTAN_HAS_KYBER) || defined(BOTAN_HAS_KYBER_90S)
140
   if(alg_name == "Kyber" || alg_name.starts_with("Kyber-")) {
7,912✔
141
      return std::make_unique<Kyber_PublicKey>(alg_id, key_bits);
328✔
142
   }
143
#endif
144

145
#if defined(BOTAN_HAS_ECDSA)
146
   if(alg_name == "ECDSA") {
4,695✔
147
      return std::make_unique<ECDSA_PublicKey>(alg_id, key_bits);
5,877✔
148
   }
149
#endif
150

151
#if defined(BOTAN_HAS_ECDH)
152
   if(alg_name == "ECDH") {
1,612✔
153
      return std::make_unique<ECDH_PublicKey>(alg_id, key_bits);
33✔
154
   }
155
#endif
156

157
#if defined(BOTAN_HAS_DIFFIE_HELLMAN)
158
   if(alg_name == "DH") {
1,551✔
159
      return std::make_unique<DH_PublicKey>(alg_id, key_bits);
16✔
160
   }
161
#endif
162

163
#if defined(BOTAN_HAS_DSA)
164
   if(alg_name == "DSA") {
1,554✔
165
      return std::make_unique<DSA_PublicKey>(alg_id, key_bits);
357✔
166
   }
167
#endif
168

169
#if defined(BOTAN_HAS_ELGAMAL)
170
   if(alg_name == "ElGamal") {
2,139✔
171
      return std::make_unique<ElGamal_PublicKey>(alg_id, key_bits);
8✔
172
   }
173
#endif
174

175
#if defined(BOTAN_HAS_ECGDSA)
176
   if(alg_name == "ECGDSA") {
1,298✔
177
      return std::make_unique<ECGDSA_PublicKey>(alg_id, key_bits);
146✔
178
   }
179
#endif
180

181
#if defined(BOTAN_HAS_ECKCDSA)
182
   if(alg_name == "ECKCDSA") {
1,990✔
183
      return std::make_unique<ECKCDSA_PublicKey>(alg_id, key_bits);
144✔
184
   }
185
#endif
186

187
#if defined(BOTAN_HAS_ED25519)
188
   if(alg_name == "Ed25519") {
1,154✔
189
      return std::make_unique<Ed25519_PublicKey>(alg_id, key_bits);
1,528✔
190
   }
191
#endif
192

193
#if defined(BOTAN_HAS_ED448)
194
   if(alg_name == "Ed448") {
390✔
195
      return std::make_unique<Ed448_PublicKey>(alg_id, key_bits);
146✔
196
   }
197
#endif
198

199
#if defined(BOTAN_HAS_GOST_34_10_2001)
200
   if(alg_name == "GOST-34.10" || alg_name == "GOST-34.10-2012-256" || alg_name == "GOST-34.10-2012-512") {
395✔
201
      return std::make_unique<GOST_3410_PublicKey>(alg_id, key_bits);
132✔
202
   }
203
#endif
204

205
#if defined(BOTAN_HAS_SM2)
206
   if(alg_name == "SM2" || alg_name == "SM2_Sig" || alg_name == "SM2_Enc") {
268✔
207
      return std::make_unique<SM2_PublicKey>(alg_id, key_bits);
30✔
208
   }
209
#endif
210

211
#if defined(BOTAN_HAS_XMSS_RFC8391)
212
   if(alg_name == "XMSS") {
235✔
213
      return std::make_unique<XMSS_PublicKey>(key_bits);
88✔
214
   }
215
#endif
216

217
#if defined(BOTAN_HAS_DILITHIUM) || defined(BOTAN_HAS_DILITHIUM_AES)
218
   if(alg_name == "Dilithium" || alg_name.starts_with("Dilithium-")) {
194✔
219
      return std::make_unique<Dilithium_PublicKey>(alg_id, key_bits);
168✔
220
   }
221
#endif
222

223
#if defined(BOTAN_HAS_SPHINCS_PLUS_WITH_SHA2) || defined(BOTAN_HAS_SPHINCS_PLUS_WITH_SHAKE)
224
   if(alg_name == "SPHINCS+" || alg_name.starts_with("SphincsPlus-")) {
108✔
225
      return std::make_unique<SphincsPlus_PublicKey>(alg_id, key_bits);
50✔
226
   }
227
#endif
228

229
   throw Decoding_Error(fmt("Unknown or unavailable public key algorithm '{}'", alg_name));
164✔
230
}
18,512✔
231

232
std::unique_ptr<Private_Key> load_private_key(const AlgorithmIdentifier& alg_id,
4,591✔
233
                                              [[maybe_unused]] std::span<const uint8_t> key_bits) {
234
   const std::string oid_str = alg_id.oid().to_formatted_string();
4,591✔
235
   const std::vector<std::string> alg_info = split_on(oid_str, '/');
4,591✔
236
   std::string_view alg_name = alg_info[0];
4,591✔
237

238
#if defined(BOTAN_HAS_RSA)
239
   if(alg_name == "RSA") {
4,928✔
240
      return std::make_unique<RSA_PrivateKey>(alg_id, key_bits);
2,120✔
241
   }
242
#endif
243

244
#if defined(BOTAN_HAS_X25519)
245
   if(alg_name == "X25519" || alg_name == "Curve25519") {
2,519✔
246
      return std::make_unique<X25519_PrivateKey>(alg_id, key_bits);
54✔
247
   }
248
#endif
249

250
#if defined(BOTAN_HAS_X448)
251
   if(alg_name == "X448") {
2,602✔
252
      return std::make_unique<X448_PrivateKey>(alg_id, key_bits);
12✔
253
   }
254
#endif
255

256
#if defined(BOTAN_HAS_ECDSA)
257
   if(alg_name == "ECDSA") {
2,455✔
258
      return std::make_unique<ECDSA_PrivateKey>(alg_id, key_bits);
1,656✔
259
   }
260
#endif
261

262
#if defined(BOTAN_HAS_ECDH)
263
   if(alg_name == "ECDH") {
1,397✔
264
      return std::make_unique<ECDH_PrivateKey>(alg_id, key_bits);
244✔
265
   }
266
#endif
267

268
#if defined(BOTAN_HAS_DIFFIE_HELLMAN)
269
   if(alg_name == "DH") {
1,238✔
270
      return std::make_unique<DH_PrivateKey>(alg_id, key_bits);
67✔
271
   }
272
#endif
273

274
#if defined(BOTAN_HAS_DSA)
275
   if(alg_name == "DSA") {
1,219✔
276
      return std::make_unique<DSA_PrivateKey>(alg_id, key_bits);
373✔
277
   }
278
#endif
279

280
#if defined(BOTAN_HAS_FRODOKEM)
281
   if(alg_name == "FrodoKEM" || alg_name.starts_with("FrodoKEM-") || alg_name.starts_with("eFrodoKEM-")) {
886✔
282
      return std::make_unique<FrodoKEM_PrivateKey>(alg_id, key_bits);
348✔
283
   }
284
#endif
285

286
#if defined(BOTAN_HAS_KYBER) || defined(BOTAN_HAS_KYBER_90S)
287
   if(alg_name == "Kyber" || alg_name.starts_with("Kyber-")) {
552✔
288
      return std::make_unique<Kyber_PrivateKey>(alg_id, key_bits);
211✔
289
   }
290
#endif
291

292
#if defined(BOTAN_HAS_MCELIECE)
293
   if(alg_name == "McEliece") {
323✔
294
      return std::make_unique<McEliece_PrivateKey>(key_bits);
4✔
295
   }
296
#endif
297

298
#if defined(BOTAN_HAS_ECGDSA)
299
   if(alg_name == "ECGDSA") {
319✔
300
      return std::make_unique<ECGDSA_PrivateKey>(alg_id, key_bits);
36✔
301
   }
302
#endif
303

304
#if defined(BOTAN_HAS_ECKCDSA)
305
   if(alg_name == "ECKCDSA") {
325✔
306
      return std::make_unique<ECKCDSA_PrivateKey>(alg_id, key_bits);
36✔
307
   }
308
#endif
309

310
#if defined(BOTAN_HAS_ED25519)
311
   if(alg_name == "Ed25519") {
297✔
312
      return std::make_unique<Ed25519_PrivateKey>(alg_id, key_bits);
17✔
313
   }
314
#endif
315

316
#if defined(BOTAN_HAS_ED448)
317
   if(alg_name == "Ed448") {
273✔
318
      return std::make_unique<Ed448_PrivateKey>(alg_id, key_bits);
36✔
319
   }
320
#endif
321

322
#if defined(BOTAN_HAS_GOST_34_10_2001)
323
   if(alg_name == "GOST-34.10" || alg_name == "GOST-34.10-2012-256" || alg_name == "GOST-34.10-2012-512") {
271✔
324
      return std::make_unique<GOST_3410_PrivateKey>(alg_id, key_bits);
24✔
325
   }
326
#endif
327

328
#if defined(BOTAN_HAS_SM2)
329
   if(alg_name == "SM2" || alg_name == "SM2_Sig" || alg_name == "SM2_Enc") {
292✔
330
      return std::make_unique<SM2_PrivateKey>(alg_id, key_bits);
40✔
331
   }
332
#endif
333

334
#if defined(BOTAN_HAS_ELGAMAL)
335
   if(alg_name == "ElGamal") {
223✔
336
      return std::make_unique<ElGamal_PrivateKey>(alg_id, key_bits);
28✔
337
   }
338
#endif
339

340
#if defined(BOTAN_HAS_XMSS_RFC8391)
341
   if(alg_name == "XMSS") {
209✔
342
      return std::make_unique<XMSS_PrivateKey>(key_bits);
19✔
343
   }
344
#endif
345

346
#if defined(BOTAN_HAS_DILITHIUM) || defined(BOTAN_HAS_DILITHIUM_AES)
347
   if(alg_name == "Dilithium" || alg_name.starts_with("Dilithium-")) {
202✔
348
      return std::make_unique<Dilithium_PrivateKey>(alg_id, key_bits);
55✔
349
   }
350
#endif
351

352
#if defined(BOTAN_HAS_SPHINCS_PLUS_WITH_SHA2) || defined(BOTAN_HAS_SPHINCS_PLUS_WITH_SHAKE)
353
   if(alg_name == "SPHINCS+" || alg_name.starts_with("SphincsPlus-")) {
135✔
354
      return std::make_unique<SphincsPlus_PrivateKey>(alg_id, key_bits);
72✔
355
   }
356
#endif
357

358
   throw Decoding_Error(fmt("Unknown or unavailable public key algorithm '{}'", alg_name));
126✔
359
}
5,171✔
360

361
std::unique_ptr<Private_Key> create_ec_private_key(std::string_view alg_name,
138✔
362
                                                   const EC_Group& ec_group,
363
                                                   RandomNumberGenerator& rng) {
364
   // Potentially unused if all EC algorithms are disabled
365
   BOTAN_UNUSED(alg_name, ec_group, rng);
138✔
366

367
#if defined(BOTAN_HAS_ECDSA)
368
   if(alg_name == "ECDSA") {
138✔
369
      return std::make_unique<ECDSA_PrivateKey>(rng, ec_group);
96✔
370
   }
371
#endif
372

373
#if defined(BOTAN_HAS_ECDH)
374
   if(alg_name == "ECDH") {
90✔
375
      return std::make_unique<ECDH_PrivateKey>(rng, ec_group);
58✔
376
   }
377
#endif
378

379
#if defined(BOTAN_HAS_ECKCDSA)
380
   if(alg_name == "ECKCDSA") {
69✔
381
      return std::make_unique<ECKCDSA_PrivateKey>(rng, ec_group);
36✔
382
   }
383
#endif
384

385
#if defined(BOTAN_HAS_GOST_34_10_2001)
386
   if(alg_name == "GOST-34.10" || alg_name == "GOST-34.10-2012-256" || alg_name == "GOST-34.10-2012-512") {
55✔
387
      return std::make_unique<GOST_3410_PrivateKey>(rng, ec_group);
24✔
388
   }
389
#endif
390

391
#if defined(BOTAN_HAS_SM2)
392
   if(alg_name == "SM2" || alg_name == "SM2_Sig" || alg_name == "SM2_Enc") {
45✔
393
      return std::make_unique<SM2_PrivateKey>(rng, ec_group);
26✔
394
   }
395
#endif
396

397
#if defined(BOTAN_HAS_ECGDSA)
398
   if(alg_name == "ECGDSA") {
18✔
399
      return std::make_unique<ECGDSA_PrivateKey>(rng, ec_group);
36✔
400
   }
401
#endif
402

403
   return nullptr;
×
404
}
405

406
std::unique_ptr<Private_Key> create_private_key(std::string_view alg_name,
775✔
407
                                                RandomNumberGenerator& rng,
408
                                                std::string_view params,
409
                                                std::string_view provider) {
410
   /*
411
   * Default paramaters are chosen for work factor > 2**128 where possible
412
   */
413

414
#if defined(BOTAN_HAS_X25519)
415
   if(alg_name == "X25519" || alg_name == "Curve25519") {
813✔
416
      return std::make_unique<X25519_PrivateKey>(rng);
16✔
417
   }
418
#endif
419

420
#if defined(BOTAN_HAS_X448)
421
   if(alg_name == "X448") {
801✔
422
      return std::make_unique<X448_PrivateKey>(rng);
10✔
423
   }
424
#endif
425

426
#if defined(BOTAN_HAS_RSA)
427
   if(alg_name == "RSA") {
781✔
428
      const size_t modulus_bits = params.empty() ? 3072 : to_u32bit(params);
51✔
429
      return std::make_unique<RSA_PrivateKey>(rng, modulus_bits);
51✔
430
   }
431
#endif
432

433
#if defined(BOTAN_HAS_MCELIECE)
434
   if(alg_name == "McEliece") {
1,034✔
435
      const auto [n, t] = [&]() -> std::pair<size_t, size_t> {
2✔
436
         if(params.empty()) {
2✔
437
            return {2960, 57};
×
438
         }
439

440
         const auto mce_params = split_on(params, ',');
2✔
441

442
         if(mce_params.size() != 2) {
2✔
443
            throw Invalid_Argument(fmt("create_private_key: invalid McEliece parameters '{}'", params));
×
444
         }
445

446
         const size_t mce_n = to_u32bit(mce_params[0]);
2✔
447
         const size_t mce_t = to_u32bit(mce_params[1]);
2✔
448
         return {mce_n, mce_t};
2✔
449
      }();
4✔
450

451
      return std::make_unique<McEliece_PrivateKey>(rng, n, t);
2✔
452
   }
453
#endif
454

455
#if defined(BOTAN_HAS_FRODOKEM)
456
   if(alg_name == "FrodoKEM") {
723✔
457
      const auto mode = params.empty() ? FrodoKEMMode::FrodoKEM976_SHAKE : FrodoKEMMode(params);
309✔
458
      return std::make_unique<FrodoKEM_PrivateKey>(rng, mode);
309✔
459
   }
460
#endif
461

462
#if defined(BOTAN_HAS_KYBER) || defined(BOTAN_HAS_KYBER_90S)
463
   if(alg_name == "Kyber") {
461✔
464
      const auto mode = [&]() -> KyberMode {
324✔
465
         if(params.empty()) {
162✔
466
            return KyberMode::Kyber1024_R3;
1✔
467
         }
468
         return KyberMode(params);
161✔
469
      }();
162✔
470

471
      return std::make_unique<Kyber_PrivateKey>(rng, mode);
162✔
472
   }
473
#endif
474

475
#if defined(BOTAN_HAS_DILITHIUM) || defined(BOTAN_HAS_DILITHIUM_AES)
476
   if(alg_name == "Dilithium" || alg_name == "Dilithium-") {
269✔
477
      const auto mode = [&]() -> DilithiumMode {
19✔
478
         if(params.empty()) {
19✔
479
            return DilithiumMode::Dilithium6x5;
480
         }
481
         return DilithiumMode(params);
11✔
482
      }();
19✔
483

484
      return std::make_unique<Dilithium_PrivateKey>(rng, mode);
19✔
485
   }
486
#endif
487

488
#if defined(BOTAN_HAS_SPHINCS_PLUS_WITH_SHA2) || defined(BOTAN_HAS_SPHINCS_PLUS_WITH_SHAKE)
489
   if(alg_name == "SPHINCS+" || alg_name == "SphincsPlus-") {
233✔
490
      auto sphincs_params = Sphincs_Parameters::create(params);
14✔
491

492
      return std::make_unique<SphincsPlus_PrivateKey>(rng, sphincs_params);
14✔
493
   }
494
#endif
495

496
#if defined(BOTAN_HAS_XMSS_RFC8391)
497
   if(alg_name == "XMSS") {
234✔
498
      const auto xmss_oid = [&]() -> XMSS_Parameters::xmss_algorithm_t {
10✔
499
         if(params.empty()) {
5✔
500
            return XMSS_Parameters::XMSS_SHA2_10_512;
501
         }
502
         return XMSS_Parameters(params).oid();
4✔
503
      }();
5✔
504

505
      return std::make_unique<XMSS_PrivateKey>(xmss_oid, rng);
5✔
506
   }
507
#endif
508

509
#if defined(BOTAN_HAS_ED25519)
510
   if(alg_name == "Ed25519") {
233✔
511
      return std::make_unique<Ed25519_PrivateKey>(rng);
26✔
512
   }
513
#endif
514

515
#if defined(BOTAN_HAS_ED448)
516
   if(alg_name == "Ed448") {
235✔
517
      return std::make_unique<Ed448_PrivateKey>(rng);
26✔
518
   }
519
#endif
520

521
   // ECC crypto
522
#if defined(BOTAN_HAS_ECC_PUBLIC_KEY_CRYPTO)
523

524
   if(alg_name == "ECDSA" || alg_name == "ECDH" || alg_name == "ECKCDSA" || alg_name == "ECGDSA" || alg_name == "SM2" ||
321✔
525
      alg_name == "SM2_Sig" || alg_name == "SM2_Enc" || alg_name == "GOST-34.10" || alg_name == "GOST-34.10-2012-256" ||
91✔
526
      alg_name == "GOST-34.10-2012-512") {
36✔
527
      const std::string group_id = [&]() -> std::string {
276✔
528
         if(!params.empty()) {
138✔
529
            return std::string(params);
129✔
530
         }
531
         if(alg_name == "SM2" || alg_name == "SM2_Enc" || alg_name == "SM2_Sig") {
9✔
532
            return "sm2p256v1";
×
533
         }
534
         if(alg_name == "GOST-34.10" || alg_name == "GOST-34.10-2012-256") {
9✔
535
            return "gost_256A";
×
536
         }
537
         if(alg_name == "GOST-34.10-2012-512") {
9✔
538
            return "gost_512A";
×
539
         }
540
         if(alg_name == "ECGDSA") {
9✔
541
            return "brainpool256r1";
×
542
         }
543
         return "secp256r1";
9✔
544
      }();
138✔
545

546
      const EC_Group ec_group(group_id);
138✔
547
      return create_ec_private_key(alg_name, ec_group, rng);
138✔
548
   }
138✔
549
#endif
550

551
   // DL crypto
552
#if defined(BOTAN_HAS_DL_GROUP)
553
   if(alg_name == "DH" || alg_name == "DSA" || alg_name == "ElGamal") {
72✔
554
      const std::string group_id = [&]() -> std::string {
72✔
555
         if(!params.empty()) {
36✔
556
            return std::string(params);
26✔
557
         }
558
         if(alg_name == "DSA") {
10✔
559
            return "dsa/botan/2048";
8✔
560
         }
561
         return "modp/ietf/2048";
2✔
562
      }();
36✔
563

564
      DL_Group modp_group(group_id);
36✔
565

566
   #if defined(BOTAN_HAS_DIFFIE_HELLMAN)
567
      if(alg_name == "DH") {
36✔
568
         return std::make_unique<DH_PrivateKey>(rng, modp_group);
30✔
569
      }
570
   #endif
571

572
   #if defined(BOTAN_HAS_DSA)
573
      if(alg_name == "DSA") {
21✔
574
         return std::make_unique<DSA_PrivateKey>(rng, modp_group);
28✔
575
      }
576
   #endif
577

578
   #if defined(BOTAN_HAS_ELGAMAL)
579
      if(alg_name == "ElGamal") {
7✔
580
         return std::make_unique<ElGamal_PrivateKey>(rng, modp_group);
14✔
581
      }
582
   #endif
583
   }
36✔
584
#endif
585

586
   BOTAN_UNUSED(alg_name, rng, params, provider);
×
587

588
   return std::unique_ptr<Private_Key>();
775✔
589
}
590

591
std::vector<std::string> probe_provider_private_key(std::string_view alg_name,
67✔
592
                                                    const std::vector<std::string>& possible) {
593
   std::vector<std::string> providers;
67✔
594

595
   for(auto&& prov : possible) {
335✔
596
      if(prov == "base") {
268✔
597
         providers.push_back(prov);
67✔
598
      }
599
   }
600

601
   BOTAN_UNUSED(alg_name);
67✔
602

603
   return providers;
67✔
604
}
×
605
}  // namespace Botan
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