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

randombit / botan / 11844561993

14 Nov 2024 07:58PM UTC coverage: 91.178% (+0.1%) from 91.072%
11844561993

Pull #4435

github

web-flow
Merge 81dcb29da into e430f157a
Pull Request #4435: Test duration values ​​are now presented in seconds with six digits of precision. Tests without time measurements have been edited.

91856 of 100744 relevant lines covered (91.18%)

9311006.71 hits per line

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

94.33
/src/tests/test_ecies.cpp
1
/*
2
* (C) 2016 Philipp Weber
3
* (C) 2016 Daniel Neus
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_ECIES)
11
   #include <botan/ecdh.h>
12
   #include <botan/ecies.h>
13
#endif
14

15
namespace Botan_Tests {
16

17
namespace {
18

19
#if defined(BOTAN_HAS_ECIES) && defined(BOTAN_HAS_AES) && defined(BOTAN_HAS_MODE_CBC)
20

21
using Flags = Botan::ECIES_Flags;
22

23
Botan::EC_Point_Format get_compression_type(const std::string& format) {
14✔
24
   if(format == "uncompressed") {
14✔
25
      return Botan::EC_Point_Format::Uncompressed;
26
   } else if(format == "compressed") {
6✔
27
      return Botan::EC_Point_Format::Compressed;
28
   } else if(format == "hybrid") {
×
29
      return Botan::EC_Point_Format::Hybrid;
30
   }
31
   throw Botan::Invalid_Argument("invalid compression format");
×
32
}
33

34
Flags ecies_flags(bool cofactor_mode, bool old_cofactor_mode, bool check_mode, bool single_hash_mode) {
108✔
35
   return (cofactor_mode ? Flags::CofactorMode : Flags::None) |
108✔
36
          (single_hash_mode ? Flags::SingleHashMode : Flags::None) |
37
          (old_cofactor_mode ? Flags::OldCofactorMode : Flags::None) | (check_mode ? Flags::CheckMode : Flags::None);
216✔
38
}
39

40
void check_encrypt_decrypt(Test::Result& result,
61✔
41
                           const Botan::ECDH_PrivateKey& private_key,
42
                           const Botan::ECDH_PrivateKey& other_private_key,
43
                           const Botan::ECIES_System_Params& ecies_params,
44
                           const Botan::InitializationVector& iv,
45
                           const std::string& label,
46
                           const std::vector<uint8_t>& plaintext,
47
                           const std::vector<uint8_t>& ciphertext,
48
                           Botan::RandomNumberGenerator& rng) {
49
   try {
61✔
50
      Botan::ECIES_Encryptor ecies_enc(private_key, ecies_params, rng);
61✔
51
      ecies_enc.set_other_key(other_private_key.public_point());
61✔
52
      Botan::ECIES_Decryptor ecies_dec(other_private_key, ecies_params, rng);
61✔
53
      if(!iv.bits_of().empty()) {
120✔
54
         ecies_enc.set_initialization_vector(iv);
59✔
55
         ecies_dec.set_initialization_vector(iv);
59✔
56
      }
57
      if(!label.empty()) {
61✔
58
         ecies_enc.set_label(label);
11✔
59
         ecies_dec.set_label(label);
11✔
60
      }
61

62
      const std::vector<uint8_t> encrypted = ecies_enc.encrypt(plaintext, rng);
61✔
63
      if(!ciphertext.empty()) {
61✔
64
         result.test_eq("encrypted data", encrypted, ciphertext);
26✔
65
      }
66
      const Botan::secure_vector<uint8_t> decrypted = ecies_dec.decrypt(encrypted);
61✔
67
      result.test_eq("decrypted data equals plaintext", decrypted, plaintext);
61✔
68

69
      std::vector<uint8_t> invalid_encrypted = encrypted;
61✔
70
      uint8_t& last_byte = invalid_encrypted[invalid_encrypted.size() - 1];
61✔
71
      last_byte = ~last_byte;
61✔
72
      result.test_throws("throw on invalid ciphertext",
183✔
73
                         [&ecies_dec, &invalid_encrypted] { ecies_dec.decrypt(invalid_encrypted); });
122✔
74
   } catch(Botan::Lookup_Error& e) {
183✔
75
      result.test_note(std::string("Test not executed: ") + e.what());
×
76
   }
×
77
}
61✔
78

79
void check_encrypt_decrypt(Test::Result& result,
48✔
80
                           const Botan::ECDH_PrivateKey& private_key,
81
                           const Botan::ECDH_PrivateKey& other_private_key,
82
                           const Botan::ECIES_System_Params& ecies_params,
83
                           size_t iv_length,
84
                           Botan::RandomNumberGenerator& rng) {
85
   const std::vector<uint8_t> plaintext{1, 2, 3};
48✔
86
   check_encrypt_decrypt(result,
96✔
87
                         private_key,
88
                         other_private_key,
89
                         ecies_params,
90
                         Botan::InitializationVector(std::vector<uint8_t>(iv_length, 0)),
192✔
91
                         "",
92
                         plaintext,
93
                         std::vector<uint8_t>(),
48✔
94
                         rng);
95
}
48✔
96

97
   #if defined(BOTAN_HAS_KDF1_18033) && defined(BOTAN_HAS_SHA1)
98

99
class ECIES_ISO_Tests final : public Text_Based_Test {
×
100
   public:
101
      ECIES_ISO_Tests() : Text_Based_Test("pubkey/ecies-18033.vec", "format,p,a,b,Order,Gx,Gy,Oid,hx,hy,x,r,C0,K") {}
2✔
102

103
      bool clear_between_callbacks() const override { return false; }
2✔
104

105
      Test::Result run_one_test(const std::string& /*header*/, const VarMap& vars) override {
2✔
106
         Test::Result result("ECIES-ISO");
2✔
107

108
         // get test vectors defined by ISO 18033
109
         const Botan::EC_Point_Format compression_type = get_compression_type(vars.get_req_str("format"));
2✔
110
         const Botan::BigInt p = vars.get_req_bn("p");
2✔
111
         const Botan::BigInt a = vars.get_req_bn("a");
2✔
112
         const Botan::BigInt b = vars.get_req_bn("b");
2✔
113
         const Botan::BigInt order = vars.get_req_bn("Order");  // order
2✔
114
         const Botan::BigInt gx = vars.get_req_bn("Gx");        // base point x
2✔
115
         const Botan::BigInt gy = vars.get_req_bn("Gy");        // base point y
2✔
116
         const Botan::OID oid(vars.get_req_str("Oid"));
4✔
117
         const Botan::BigInt hx = vars.get_req_bn("hx");          // x of public point of bob
2✔
118
         const Botan::BigInt hy = vars.get_req_bn("hy");          // y of public point of bob
2✔
119
         const Botan::BigInt x = vars.get_req_bn("x");            // private key of bob
2✔
120
         const Botan::BigInt r = vars.get_req_bn("r");            // (ephemeral) private key of alice
2✔
121
         const std::vector<uint8_t> c0 = vars.get_req_bin("C0");  // expected encoded (ephemeral) public key
2✔
122
         const std::vector<uint8_t> k = vars.get_req_bin("K");    // expected derived secret
2✔
123

124
         const Botan::EC_Group domain(oid, p, a, b, gx, gy, order);
2✔
125

126
         // keys of bob
127
         const Botan::ECDH_PrivateKey other_private_key(this->rng(), domain, x);
2✔
128
         const Botan::EC_Point other_public_key_point = domain.point(hx, hy);
2✔
129
         const Botan::ECDH_PublicKey other_public_key(domain, other_public_key_point);
2✔
130

131
         // (ephemeral) keys of alice
132
         const Botan::ECDH_PrivateKey eph_private_key(this->rng(), domain, r);
2✔
133
         const Botan::EC_Point eph_public_key_point = eph_private_key.public_point();
2✔
134
         const std::vector<uint8_t> eph_public_key_bin = eph_public_key_point.encode(compression_type);
2✔
135
         result.test_eq("encoded (ephemeral) public key", eph_public_key_bin, c0);
2✔
136

137
         // test secret derivation: ISO 18033 test vectors use KDF1 from ISO 18033
138
         // no cofactor-/oldcofactor-/singlehash-/check-mode and 128 byte secret length
139
         Botan::ECIES_KA_Params ka_params(
2✔
140
            eph_private_key.domain(), "KDF1-18033(SHA-1)", 128, compression_type, Flags::None);
2✔
141
         const Botan::ECIES_KA_Operation ka(eph_private_key, ka_params, true, this->rng());
2✔
142
         const Botan::SymmetricKey secret_key = ka.derive_secret(eph_public_key_bin, other_public_key_point);
2✔
143
         result.test_eq("derived secret key", secret_key.bits_of(), k);
4✔
144

145
         // test encryption / decryption
146

147
         for(auto comp_type : {Botan::EC_Point_Format::Uncompressed,
6✔
148
                               Botan::EC_Point_Format::Compressed,
149
                               Botan::EC_Point_Format::Hybrid}) {
8✔
150
            for(bool cofactor_mode : {true, false}) {
18✔
151
               for(bool single_hash_mode : {true, false}) {
36✔
152
                  for(bool old_cofactor_mode : {true, false}) {
72✔
153
                     for(bool check_mode : {true, false}) {
144✔
154
                        Flags flags = ecies_flags(cofactor_mode, old_cofactor_mode, check_mode, single_hash_mode);
96✔
155

156
                        if(size_t(cofactor_mode) + size_t(check_mode) + size_t(old_cofactor_mode) > 1) {
96✔
157
                           auto onThrow = [&]() {
96✔
158
                              Botan::ECIES_System_Params(eph_private_key.domain(),
48✔
159
                                                         "KDF2(SHA-1)",
160
                                                         "AES-256/CBC",
161
                                                         32,
162
                                                         "HMAC(SHA-1)",
163
                                                         20,
164
                                                         comp_type,
165
                                                         flags);
166
                           };
48✔
167
                           result.test_throws("throw on invalid ECIES_Flags", onThrow);
96✔
168
                           continue;
48✔
169
                        }
48✔
170

171
                        Botan::ECIES_System_Params ecies_params(eph_private_key.domain(),
48✔
172
                                                                "KDF2(SHA-1)",
173
                                                                "AES-256/CBC",
174
                                                                32,
175
                                                                "HMAC(SHA-1)",
176
                                                                20,
177
                                                                comp_type,
178
                                                                flags);
48✔
179
                        check_encrypt_decrypt(
48✔
180
                           result, eph_private_key, other_private_key, ecies_params, 16, this->rng());
181
                     }
48✔
182
                  }
183
               }
184
            }
185
         }
186

187
         return result;
2✔
188
      }
30✔
189
};
190

191
BOTAN_REGISTER_TEST("pubkey", "ecies_iso", ECIES_ISO_Tests);
192

193
   #endif
194

195
class ECIES_Tests final : public Text_Based_Test {
×
196
   public:
197
      ECIES_Tests() :
1✔
198
            Text_Based_Test("pubkey/ecies.vec",
199
                            "Curve,PrivateKey,OtherPrivateKey,Kdf,Dem,DemKeyLen,Mac,MacKeyLen,Format,"
200
                            "CofactorMode,OldCofactorMode,CheckMode,SingleHashMode,Label,Plaintext,Ciphertext",
201
                            "Iv") {}
2✔
202

203
      Test::Result run_one_test(const std::string& /*header*/, const VarMap& vars) override {
12✔
204
         Test::Result result("ECIES");
12✔
205

206
         const std::string curve = vars.get_req_str("Curve");
12✔
207
         const Botan::BigInt private_key_value = vars.get_req_bn("PrivateKey");
12✔
208
         const Botan::BigInt other_private_key_value = vars.get_req_bn("OtherPrivateKey");
12✔
209
         const std::string kdf = vars.get_req_str("Kdf");
12✔
210
         const std::string dem = vars.get_req_str("Dem");
12✔
211
         const size_t dem_key_len = vars.get_req_sz("DemKeyLen");
12✔
212
         const Botan::InitializationVector iv = Botan::InitializationVector(vars.get_opt_bin("Iv"));
22✔
213
         const std::string mac = vars.get_req_str("Mac");
12✔
214
         const size_t mac_key_len = vars.get_req_sz("MacKeyLen");
12✔
215
         const Botan::EC_Point_Format compression_type = get_compression_type(vars.get_req_str("Format"));
12✔
216
         const bool cofactor_mode = vars.get_req_sz("CofactorMode") != 0;
12✔
217
         const bool old_cofactor_mode = vars.get_req_sz("OldCofactorMode") != 0;
12✔
218
         const bool check_mode = vars.get_req_sz("CheckMode") != 0;
12✔
219
         const bool single_hash_mode = vars.get_req_sz("SingleHashMode") != 0;
12✔
220
         const std::string label = vars.get_req_str("Label");
12✔
221
         const std::vector<uint8_t> plaintext = vars.get_req_bin("Plaintext");
12✔
222
         const std::vector<uint8_t> ciphertext = vars.get_req_bin("Ciphertext");
12✔
223

224
         const Flags flags = ecies_flags(cofactor_mode, old_cofactor_mode, check_mode, single_hash_mode);
12✔
225

226
         // This test uses a mix of named curves plus PEM, so we use the deprecated constructor atm
227
         const Botan::EC_Group domain(curve);
12✔
228
         const Botan::ECDH_PrivateKey private_key(this->rng(), domain, private_key_value);
12✔
229
         const Botan::ECDH_PrivateKey other_private_key(this->rng(), domain, other_private_key_value);
12✔
230

231
         const Botan::ECIES_System_Params ecies_params(
12✔
232
            private_key.domain(), kdf, dem, dem_key_len, mac, mac_key_len, compression_type, flags);
12✔
233
         check_encrypt_decrypt(
12✔
234
            result, private_key, other_private_key, ecies_params, iv, label, plaintext, ciphertext, this->rng());
235

236
         return result;
24✔
237
      }
70✔
238
};
239

240
BOTAN_REGISTER_TEST("pubkey", "ecies", ECIES_Tests);
241

242
   #if defined(BOTAN_HAS_KDF1_18033) && defined(BOTAN_HAS_HMAC) && defined(BOTAN_HAS_AES) && defined(BOTAN_HAS_SHA2_64)
243

244
Test::Result test_other_key_not_set() {
1✔
245
   Test::Result result("ECIES other key not set");
1✔
246
   result.start_timer();
1✔
247

248
   auto rng = Test::new_rng("ecies_other_key_not_set");
1✔
249

250
   const Flags flags = ecies_flags(false, false, false, true);
1✔
251
   const auto domain = Botan::EC_Group::from_name("secp521r1");
1✔
252

253
   const Botan::BigInt private_key_value(
1✔
254
      "405029866705438137604064977397053031159826489755682166267763407"
255
      "5002761777100287880684822948852132235484464537021197213998300006"
256
      "547176718172344447619746779823");
1✔
257

258
   const Botan::ECDH_PrivateKey private_key(*rng, domain, private_key_value);
1✔
259
   const Botan::ECIES_System_Params ecies_params(private_key.domain(),
1✔
260
                                                 "KDF1-18033(SHA-512)",
261
                                                 "AES-256/CBC",
262
                                                 32,
263
                                                 "HMAC(SHA-512)",
264
                                                 20,
265
                                                 Botan::EC_Point_Format::Compressed,
266
                                                 flags);
1✔
267

268
   Botan::ECIES_Encryptor ecies_enc(private_key, ecies_params, *rng);
1✔
269

270
   result.test_throws("encrypt not possible without setting other public key",
2✔
271
                      [&ecies_enc, &rng]() { ecies_enc.encrypt(std::vector<uint8_t>(8), *rng); });
2✔
272

273
   result.end_timer();
1✔
274
   return result;
2✔
275
}
3✔
276

277
Test::Result test_kdf_not_found() {
1✔
278
   Test::Result result("ECIES kdf not found");
1✔
279
   result.start_timer();
1✔
280

281
   auto rng = Test::new_rng("ecies_kdf_not_found");
1✔
282

283
   const Flags flags = ecies_flags(false, false, false, true);
1✔
284
   const auto domain = Botan::EC_Group::from_name("secp521r1");
1✔
285

286
   const Botan::BigInt private_key_value(
1✔
287
      "405029866705438137604064977397053031159826489755682166267763407"
288
      "5002761777100287880684822948852132235484464537021197213998300006"
289
      "547176718172344447619746779823");
1✔
290

291
   const Botan::ECDH_PrivateKey private_key(*rng, domain, private_key_value);
1✔
292
   const Botan::ECIES_System_Params ecies_params(private_key.domain(),
1✔
293
                                                 "KDF-XYZ(SHA-512)",
294
                                                 "AES-256/CBC",
295
                                                 32,
296
                                                 "HMAC(SHA-512)",
297
                                                 20,
298
                                                 Botan::EC_Point_Format::Compressed,
299
                                                 flags);
1✔
300

301
   result.test_throws("kdf not found", [&]() {
2✔
302
      Botan::ECIES_Encryptor ecies_enc(private_key, ecies_params, *rng);
1✔
303
      ecies_enc.encrypt(std::vector<uint8_t>(8), *rng);
2✔
304
   });
1✔
305

306
   result.end_timer();
1✔
307
   return result;
2✔
308
}
3✔
309

310
Test::Result test_mac_not_found() {
1✔
311
   Test::Result result("ECIES mac not found");
1✔
312
   result.start_timer();
1✔
313

314
   auto rng = Test::new_rng("ecies_mac_not_found");
1✔
315

316
   const Flags flags = ecies_flags(false, false, false, true);
1✔
317
   const auto domain = Botan::EC_Group::from_name("secp521r1");
1✔
318

319
   const Botan::BigInt private_key_value(
1✔
320
      "405029866705438137604064977397053031159826489755682166267763407"
321
      "5002761777100287880684822948852132235484464537021197213998300006"
322
      "547176718172344447619746779823");
1✔
323

324
   const Botan::ECDH_PrivateKey private_key(*rng, domain, private_key_value);
1✔
325
   const Botan::ECIES_System_Params ecies_params(private_key.domain(),
1✔
326
                                                 "KDF1-18033(SHA-512)",
327
                                                 "AES-256/CBC",
328
                                                 32,
329
                                                 "XYZMAC(SHA-512)",
330
                                                 20,
331
                                                 Botan::EC_Point_Format::Compressed,
332
                                                 flags);
1✔
333

334
   result.test_throws("mac not found", [&]() {
2✔
335
      Botan::ECIES_Encryptor ecies_enc(private_key, ecies_params, *rng);
1✔
336
      ecies_enc.encrypt(std::vector<uint8_t>(8), *rng);
×
337
   });
×
338

339
   result.end_timer();
1✔
340
   return result;
2✔
341
}
3✔
342

343
Test::Result test_cipher_not_found() {
1✔
344
   Test::Result result("ECIES cipher not found");
1✔
345
   result.start_timer();
1✔
346

347
   auto rng = Test::new_rng("ecies_cipher_not_found");
1✔
348

349
   const Flags flags = ecies_flags(false, false, false, true);
1✔
350
   const auto domain = Botan::EC_Group::from_name("secp521r1");
1✔
351

352
   const Botan::BigInt private_key_value(
1✔
353
      "405029866705438137604064977397053031159826489755682166267763407"
354
      "5002761777100287880684822948852132235484464537021197213998300006"
355
      "547176718172344447619746779823");
1✔
356

357
   const Botan::ECDH_PrivateKey private_key(*rng, domain, private_key_value);
1✔
358
   const Botan::ECIES_System_Params ecies_params(private_key.domain(),
1✔
359
                                                 "KDF1-18033(SHA-512)",
360
                                                 "AES-XYZ-256/CBC",
361
                                                 32,
362
                                                 "HMAC(SHA-512)",
363
                                                 20,
364
                                                 Botan::EC_Point_Format::Compressed,
365
                                                 flags);
1✔
366

367
   result.test_throws("cipher not found", [&]() {
2✔
368
      Botan::ECIES_Encryptor ecies_enc(private_key, ecies_params, *rng);
1✔
369
      ecies_enc.encrypt(std::vector<uint8_t>(8), *rng);
×
370
   });
×
371

372
   result.end_timer();
1✔
373
   return result;
2✔
374
}
3✔
375

376
Test::Result test_system_params_short_ctor() {
1✔
377
   Test::Result result("ECIES short system params ctor");
1✔
378
   result.start_timer();
1✔
379

380
   auto rng = Test::new_rng("ecies_params_short_ctor");
1✔
381

382
   const auto domain = Botan::EC_Group::from_name("secp521r1");
1✔
383
   const Botan::BigInt private_key_value(
1✔
384
      "405029866705438137604064977397053031159826489755682166267763407"
385
      "5002761777100287880684822948852132235484464537021197213998300006"
386
      "547176718172344447619746779823");
1✔
387

388
   const Botan::BigInt other_private_key_value(
1✔
389
      "2294226772740614508941417891614236736606752960073669253551166842"
390
      "5866095315090327914760325168219669828915074071456176066304457448"
391
      "25404691681749451640151380153");
1✔
392

393
   const Botan::ECDH_PrivateKey private_key(*rng, domain, private_key_value);
1✔
394
   const Botan::ECDH_PrivateKey other_private_key(*rng, domain, other_private_key_value);
1✔
395

396
   const Botan::ECIES_System_Params ecies_params(
1✔
397
      private_key.domain(), "KDF1-18033(SHA-512)", "AES-256/CBC", 32, "HMAC(SHA-512)", 16);
1✔
398

399
   const Botan::InitializationVector iv("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF");
1✔
400
   const std::string label = "Test";
1✔
401

402
   const std::vector<uint8_t> plaintext = Botan::hex_decode("000102030405060708090A0B0C0D0E0F");
1✔
403

404
   // generated with botan
405
   const std::vector<uint8_t> ciphertext = Botan::hex_decode(
1✔
406
      "0401519EAA0489FF9D51E98E4C22349463E2001CD06F8CE47D81D4007A"
407
      "79ACF98E92C814686477CEA666EFC277DC84E15FC95E38AFF8E16D478A"
408
      "44CD5C5F1517F8B1F300000591317F261C3D04A7207F01EAE3EC70F2360"
409
      "0F82C53CC0B85BE7AC9F6CE79EF2AB416E5934D61BA9D346385D7545C57F"
410
      "77C7EA7C58E18C70CBFB0A24AE1B9943EC5A8D0657522CCDF30BA95674D81"
411
      "B397635D215178CD13BD9504AE957A9888F4128FFC0F0D3F1CEC646AEC8CE"
412
      "3F2463D233B22A7A12B679F4C06501F584D4DEFF6D26592A8D873398BD892"
413
      "B477B3468813C053DA43C4F3D49009F7A12D6EF7");
1✔
414

415
   check_encrypt_decrypt(result, private_key, other_private_key, ecies_params, iv, label, plaintext, ciphertext, *rng);
1✔
416

417
   result.end_timer();
1✔
418
   return result;
1✔
419
}
6✔
420

421
Test::Result test_ciphertext_too_short() {
1✔
422
   Test::Result result("ECIES ciphertext too short");
1✔
423
   result.start_timer();
1✔
424

425
   const auto domain = Botan::EC_Group::from_name("secp521r1");
1✔
426
   const Botan::BigInt private_key_value(
1✔
427
      "405029866705438137604064977397053031159826489755682166267763407"
428
      "5002761777100287880684822948852132235484464537021197213998300006"
429
      "547176718172344447619746779823");
1✔
430

431
   const Botan::BigInt other_private_key_value(
1✔
432
      "2294226772740614508941417891614236736606752960073669253551166842"
433
      "5866095315090327914760325168219669828915074071456176066304457448"
434
      "25404691681749451640151380153");
1✔
435

436
   auto rng = Test::new_rng("ecies_ciphertext_too_short");
1✔
437

438
   const Botan::ECDH_PrivateKey private_key(*rng, domain, private_key_value);
1✔
439
   const Botan::ECDH_PrivateKey other_private_key(*rng, domain, other_private_key_value);
1✔
440

441
   const Botan::ECIES_System_Params ecies_params(
1✔
442
      private_key.domain(), "KDF1-18033(SHA-512)", "AES-256/CBC", 32, "HMAC(SHA-512)", 16);
1✔
443

444
   Botan::ECIES_Decryptor ecies_dec(other_private_key, ecies_params, *rng);
1✔
445

446
   result.test_throws("ciphertext too short",
2✔
447
                      [&ecies_dec]() { ecies_dec.decrypt(Botan::hex_decode("0401519EAA0489FF9D51E98E4C22349A")); });
2✔
448

449
   result.end_timer();
1✔
450
   return result;
1✔
451
}
4✔
452

453
class ECIES_Unit_Tests final : public Test {
×
454
   public:
455
      std::vector<Test::Result> run() override {
1✔
456
         std::vector<Test::Result> results;
1✔
457

458
         std::vector<std::function<Test::Result()>> fns = {test_other_key_not_set,
1✔
459
                                                           test_kdf_not_found,
460
                                                           test_mac_not_found,
461
                                                           test_cipher_not_found,
462
                                                           test_system_params_short_ctor,
463
                                                           test_ciphertext_too_short};
7✔
464

465
         for(size_t i = 0; i != fns.size(); ++i) {
7✔
466
            try {
6✔
467
               results.emplace_back(fns[i]());
12✔
468
            } catch(std::exception& e) {
×
469
               results.emplace_back(Test::Result::Failure("ECIES unit tests " + std::to_string(i), e.what()));
×
470
            }
×
471
         }
472

473
         return results;
1✔
474
      }
2✔
475
};
476

477
BOTAN_REGISTER_TEST("pubkey", "ecies_unit", ECIES_Unit_Tests);
478

479
   #endif
480

481
#endif
482

483
}  // namespace
484

485
}  // namespace Botan_Tests
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

© 2025 Coveralls, Inc