• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In
Build has been canceled!

randombit / botan / 13021208024

28 Jan 2025 11:07PM UTC coverage: 91.241% (-0.02%) from 91.258%
13021208024

push

github

web-flow
Merge pull request #4604 from randombit/jack/support-minimal-curves

Avoid requiring legacy_ec_group in order to run the tests

94137 of 103174 relevant lines covered (91.24%)

11291073.45 hits per line

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

94.24
/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(
122✔
52
         Botan::EC_AffinePoint(other_private_key.domain(), other_private_key.raw_public_key_bits()));
122✔
53
      Botan::ECIES_Decryptor ecies_dec(other_private_key, ecies_params, rng);
61✔
54
      if(!iv.bits_of().empty()) {
120✔
55
         ecies_enc.set_initialization_vector(iv);
59✔
56
         ecies_dec.set_initialization_vector(iv);
59✔
57
      }
58
      if(!label.empty()) {
61✔
59
         ecies_enc.set_label(label);
11✔
60
         ecies_dec.set_label(label);
11✔
61
      }
62

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

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

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

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

100
class ECIES_ISO_Tests final : public Text_Based_Test {
×
101
   public:
102
      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✔
103

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

106
      bool skip_this_test(const std::string&, const VarMap&) override {
2✔
107
         return !Botan::EC_Group::supports_application_specific_group();
2✔
108
      }
109

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

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

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

131
         // keys of bob
132
         const Botan::ECDH_PrivateKey other_private_key(this->rng(), domain, x);
2✔
133
         const auto other_public_key_point = Botan::EC_AffinePoint::from_bigint_xy(domain, hx, hy).value();
4✔
134
         const Botan::ECDH_PublicKey other_public_key(domain, other_public_key_point);
2✔
135

136
         // (ephemeral) keys of alice
137
         const Botan::ECDH_PrivateKey eph_private_key(this->rng(), domain, r);
2✔
138
         const auto eph_public_key_bin = eph_private_key.public_value(compression_type);
2✔
139
         result.test_eq("encoded (ephemeral) public key", eph_public_key_bin, c0);
4✔
140

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

149
         // test encryption / decryption
150

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

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

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

191
         return result;
2✔
192
      }
30✔
193
};
194

195
BOTAN_REGISTER_TEST("pubkey", "ecies_iso", ECIES_ISO_Tests);
196

197
   #endif
198

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

207
      bool skip_this_test(const std::string&, const VarMap& vars) override {
12✔
208
         const auto curve = vars.get_req_str("Curve");
12✔
209

210
         if(curve.starts_with("-----BEGIN EC PARAMETERS")) {
12✔
211
            return !Botan::EC_Group::supports_application_specific_group();
5✔
212
         } else {
213
            return !Botan::EC_Group::supports_named_group(curve);
7✔
214
         }
215
      }
12✔
216

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

220
         const std::string curve = vars.get_req_str("Curve");
12✔
221
         const Botan::BigInt private_key_value = vars.get_req_bn("PrivateKey");
12✔
222
         const Botan::BigInt other_private_key_value = vars.get_req_bn("OtherPrivateKey");
12✔
223
         const std::string kdf = vars.get_req_str("Kdf");
12✔
224
         const std::string dem = vars.get_req_str("Dem");
12✔
225
         const size_t dem_key_len = vars.get_req_sz("DemKeyLen");
12✔
226
         const Botan::InitializationVector iv = Botan::InitializationVector(vars.get_opt_bin("Iv"));
22✔
227
         const std::string mac = vars.get_req_str("Mac");
12✔
228
         const size_t mac_key_len = vars.get_req_sz("MacKeyLen");
12✔
229
         const Botan::EC_Point_Format compression_type = get_compression_type(vars.get_req_str("Format"));
12✔
230
         const bool cofactor_mode = vars.get_req_sz("CofactorMode") != 0;
12✔
231
         const bool old_cofactor_mode = vars.get_req_sz("OldCofactorMode") != 0;
12✔
232
         const bool check_mode = vars.get_req_sz("CheckMode") != 0;
12✔
233
         const bool single_hash_mode = vars.get_req_sz("SingleHashMode") != 0;
12✔
234
         const std::string label = vars.get_req_str("Label");
12✔
235
         const std::vector<uint8_t> plaintext = vars.get_req_bin("Plaintext");
12✔
236
         const std::vector<uint8_t> ciphertext = vars.get_req_bin("Ciphertext");
12✔
237

238
         const Flags flags = ecies_flags(cofactor_mode, old_cofactor_mode, check_mode, single_hash_mode);
12✔
239

240
         // This test uses a mix of named curves plus PEM, so we use the deprecated constructor atm
241
         const Botan::EC_Group domain(curve);
12✔
242
         const Botan::ECDH_PrivateKey private_key(this->rng(), domain, private_key_value);
12✔
243
         const Botan::ECDH_PrivateKey other_private_key(this->rng(), domain, other_private_key_value);
12✔
244

245
         const Botan::ECIES_System_Params ecies_params(
12✔
246
            private_key.domain(), kdf, dem, dem_key_len, mac, mac_key_len, compression_type, flags);
12✔
247
         check_encrypt_decrypt(
12✔
248
            result, private_key, other_private_key, ecies_params, iv, label, plaintext, ciphertext, this->rng());
249

250
         return result;
24✔
251
      }
70✔
252
};
253

254
BOTAN_REGISTER_TEST("pubkey", "ecies", ECIES_Tests);
255

256
   #if defined(BOTAN_HAS_KDF1_18033) && defined(BOTAN_HAS_HMAC) && defined(BOTAN_HAS_AES) && defined(BOTAN_HAS_SHA2_64)
257

258
Test::Result test_other_key_not_set() {
1✔
259
   Test::Result result("ECIES other key not set");
1✔
260

261
   auto rng = Test::new_rng("ecies_other_key_not_set");
1✔
262

263
   const Flags flags = ecies_flags(false, false, false, true);
1✔
264
   const auto domain = Botan::EC_Group::from_name("secp521r1");
1✔
265

266
   const Botan::BigInt private_key_value(
1✔
267
      "405029866705438137604064977397053031159826489755682166267763407"
268
      "5002761777100287880684822948852132235484464537021197213998300006"
269
      "547176718172344447619746779823");
1✔
270

271
   const Botan::ECDH_PrivateKey private_key(*rng, domain, private_key_value);
1✔
272
   const Botan::ECIES_System_Params ecies_params(private_key.domain(),
1✔
273
                                                 "KDF1-18033(SHA-512)",
274
                                                 "AES-256/CBC",
275
                                                 32,
276
                                                 "HMAC(SHA-512)",
277
                                                 20,
278
                                                 Botan::EC_Point_Format::Compressed,
279
                                                 flags);
1✔
280

281
   Botan::ECIES_Encryptor ecies_enc(private_key, ecies_params, *rng);
1✔
282

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

286
   return result;
2✔
287
}
3✔
288

289
Test::Result test_kdf_not_found() {
1✔
290
   Test::Result result("ECIES kdf not found");
1✔
291

292
   auto rng = Test::new_rng("ecies_kdf_not_found");
1✔
293

294
   const Flags flags = ecies_flags(false, false, false, true);
1✔
295
   const auto domain = Botan::EC_Group::from_name("secp521r1");
1✔
296

297
   const Botan::BigInt private_key_value(
1✔
298
      "405029866705438137604064977397053031159826489755682166267763407"
299
      "5002761777100287880684822948852132235484464537021197213998300006"
300
      "547176718172344447619746779823");
1✔
301

302
   const Botan::ECDH_PrivateKey private_key(*rng, domain, private_key_value);
1✔
303
   const Botan::ECIES_System_Params ecies_params(private_key.domain(),
1✔
304
                                                 "KDF-XYZ(SHA-512)",
305
                                                 "AES-256/CBC",
306
                                                 32,
307
                                                 "HMAC(SHA-512)",
308
                                                 20,
309
                                                 Botan::EC_Point_Format::Compressed,
310
                                                 flags);
1✔
311

312
   result.test_throws("kdf not found", [&]() {
2✔
313
      Botan::ECIES_Encryptor ecies_enc(private_key, ecies_params, *rng);
1✔
314
      ecies_enc.encrypt(std::vector<uint8_t>(8), *rng);
2✔
315
   });
1✔
316

317
   return result;
2✔
318
}
3✔
319

320
Test::Result test_mac_not_found() {
1✔
321
   Test::Result result("ECIES mac not found");
1✔
322

323
   auto rng = Test::new_rng("ecies_mac_not_found");
1✔
324

325
   const Flags flags = ecies_flags(false, false, false, true);
1✔
326
   const auto domain = Botan::EC_Group::from_name("secp521r1");
1✔
327

328
   const Botan::BigInt private_key_value(
1✔
329
      "405029866705438137604064977397053031159826489755682166267763407"
330
      "5002761777100287880684822948852132235484464537021197213998300006"
331
      "547176718172344447619746779823");
1✔
332

333
   const Botan::ECDH_PrivateKey private_key(*rng, domain, private_key_value);
1✔
334
   const Botan::ECIES_System_Params ecies_params(private_key.domain(),
1✔
335
                                                 "KDF1-18033(SHA-512)",
336
                                                 "AES-256/CBC",
337
                                                 32,
338
                                                 "XYZMAC(SHA-512)",
339
                                                 20,
340
                                                 Botan::EC_Point_Format::Compressed,
341
                                                 flags);
1✔
342

343
   result.test_throws("mac not found", [&]() {
2✔
344
      Botan::ECIES_Encryptor ecies_enc(private_key, ecies_params, *rng);
1✔
345
      ecies_enc.encrypt(std::vector<uint8_t>(8), *rng);
×
346
   });
×
347

348
   return result;
2✔
349
}
3✔
350

351
Test::Result test_cipher_not_found() {
1✔
352
   Test::Result result("ECIES cipher not found");
1✔
353

354
   auto rng = Test::new_rng("ecies_cipher_not_found");
1✔
355

356
   const Flags flags = ecies_flags(false, false, false, true);
1✔
357
   const auto domain = Botan::EC_Group::from_name("secp521r1");
1✔
358

359
   const Botan::BigInt private_key_value(
1✔
360
      "405029866705438137604064977397053031159826489755682166267763407"
361
      "5002761777100287880684822948852132235484464537021197213998300006"
362
      "547176718172344447619746779823");
1✔
363

364
   const Botan::ECDH_PrivateKey private_key(*rng, domain, private_key_value);
1✔
365
   const Botan::ECIES_System_Params ecies_params(private_key.domain(),
1✔
366
                                                 "KDF1-18033(SHA-512)",
367
                                                 "AES-XYZ-256/CBC",
368
                                                 32,
369
                                                 "HMAC(SHA-512)",
370
                                                 20,
371
                                                 Botan::EC_Point_Format::Compressed,
372
                                                 flags);
1✔
373

374
   result.test_throws("cipher not found", [&]() {
2✔
375
      Botan::ECIES_Encryptor ecies_enc(private_key, ecies_params, *rng);
1✔
376
      ecies_enc.encrypt(std::vector<uint8_t>(8), *rng);
×
377
   });
×
378

379
   return result;
2✔
380
}
3✔
381

382
Test::Result test_system_params_short_ctor() {
1✔
383
   Test::Result result("ECIES short system params ctor");
1✔
384

385
   auto rng = Test::new_rng("ecies_params_short_ctor");
1✔
386

387
   const auto domain = Botan::EC_Group::from_name("secp521r1");
1✔
388
   const Botan::BigInt private_key_value(
1✔
389
      "405029866705438137604064977397053031159826489755682166267763407"
390
      "5002761777100287880684822948852132235484464537021197213998300006"
391
      "547176718172344447619746779823");
1✔
392

393
   const Botan::BigInt other_private_key_value(
1✔
394
      "2294226772740614508941417891614236736606752960073669253551166842"
395
      "5866095315090327914760325168219669828915074071456176066304457448"
396
      "25404691681749451640151380153");
1✔
397

398
   const Botan::ECDH_PrivateKey private_key(*rng, domain, private_key_value);
1✔
399
   const Botan::ECDH_PrivateKey other_private_key(*rng, domain, other_private_key_value);
1✔
400

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

404
   const Botan::InitializationVector iv("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF");
1✔
405
   const std::string label = "Test";
1✔
406

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

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

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

422
   return result;
1✔
423
}
6✔
424

425
Test::Result test_ciphertext_too_short() {
1✔
426
   Test::Result result("ECIES ciphertext too short");
1✔
427

428
   const auto domain = Botan::EC_Group::from_name("secp521r1");
1✔
429
   const Botan::BigInt private_key_value(
1✔
430
      "405029866705438137604064977397053031159826489755682166267763407"
431
      "5002761777100287880684822948852132235484464537021197213998300006"
432
      "547176718172344447619746779823");
1✔
433

434
   const Botan::BigInt other_private_key_value(
1✔
435
      "2294226772740614508941417891614236736606752960073669253551166842"
436
      "5866095315090327914760325168219669828915074071456176066304457448"
437
      "25404691681749451640151380153");
1✔
438

439
   auto rng = Test::new_rng("ecies_ciphertext_too_short");
1✔
440

441
   const Botan::ECDH_PrivateKey private_key(*rng, domain, private_key_value);
1✔
442
   const Botan::ECDH_PrivateKey other_private_key(*rng, domain, other_private_key_value);
1✔
443

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

447
   Botan::ECIES_Decryptor ecies_dec(other_private_key, ecies_params, *rng);
1✔
448

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

452
   return result;
1✔
453
}
4✔
454

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

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

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

475
         return results;
1✔
476
      }
2✔
477
};
478

479
BOTAN_REGISTER_TEST("pubkey", "ecies_unit", ECIES_Unit_Tests);
480

481
   #endif
482

483
#endif
484

485
}  // namespace
486

487
}  // 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

© 2026 Coveralls, Inc