Botan 3.14.1
Crypto and TLS for C&
ecies.cpp
Go to the documentation of this file.
1/*
2* ECIES
3* (C) 2016 Philipp Weber
4* 2016 Daniel Neus, Rohde & Schwarz Cybersecurity
5* 2025 Jack Lloyd
6*
7* Botan is released under the Simplified BSD License (see license.txt)
8*/
9
10#include <botan/ecies.h>
11
12#include <botan/cipher_mode.h>
13#include <botan/ecdh.h>
14#include <botan/kdf.h>
15#include <botan/mac.h>
16#include <botan/mem_ops.h>
17#include <botan/rng.h>
18#include <botan/internal/concat_util.h>
19#include <botan/internal/ct_utils.h>
20#include <botan/internal/pk_ops_impl.h>
21#include <botan/internal/pk_options_impl.h>
22
23namespace Botan {
24
25namespace {
26
27/**
28* Private key type for ECIES_ECDH_KA_Operation
29*
30* TODO(Botan4) this can be removed once cofactor support is removed from ECDH
31*/
32
35
36class ECIES_PrivateKey final : public virtual EC_PrivateKey,
37 public virtual PK_Key_Agreement_Key {
38 public:
39 explicit ECIES_PrivateKey(const ECDH_PrivateKey& private_key) :
40 // NOLINTNEXTLINE(*-slicing)
41 EC_PublicKey(private_key), EC_PrivateKey(private_key), PK_Key_Agreement_Key(), m_key(private_key) {}
42
43 std::vector<uint8_t> public_value() const override { return m_key.public_value(); }
44
45 std::string algo_name() const override { return "ECIES"; }
46
47 std::unique_ptr<Public_Key> public_key() const override { return m_key.public_key(); }
48
49 bool supports_operation(PublicKeyOperation op) const override { return (op == PublicKeyOperation::KeyAgreement); }
50
51 std::unique_ptr<Private_Key> generate_another(RandomNumberGenerator& rng) const override {
52 return m_key.generate_another(rng);
53 }
54
55 std::unique_ptr<PK_Ops::Key_Agreement> _create_key_agreement_op(
56 RandomNumberGenerator& rng, const PK_Key_Agreement_Options_Reader& options) const override;
57
58 private:
59 ECDH_PrivateKey m_key;
60};
61
63
64/**
65* Implements ECDH key agreement without using the cofactor mode
66*
67* TODO(Botan4) this can be removed once cofactor support is removed from ECDH
68*/
69class ECIES_ECDH_KA_Operation final : public PK_Ops::Key_Agreement_with_KDF {
70 public:
71 ECIES_ECDH_KA_Operation(const ECIES_PrivateKey& private_key,
72 const PK_Key_Agreement_Options_Reader& options,
73 RandomNumberGenerator& rng) :
74 PK_Ops::Key_Agreement_with_KDF(options), m_key(private_key), m_rng(rng) {}
75
76 size_t agreed_value_size() const override { return m_key.domain().get_p_bytes(); }
77
78 secure_vector<uint8_t> raw_agree(const uint8_t w[], size_t w_len) override {
79 const EC_Group& group = m_key.domain();
80 if(auto input_point = EC_AffinePoint::deserialize(group, {w, w_len})) {
81 const auto scope = CT::scoped_poison(m_key._private_key());
82 // Any further secret handling of the output is up to the caller
83 return CT::driveby_unpoison(input_point->mul(m_key._private_key(), m_rng).x_bytes());
84 } else {
85 throw Decoding_Error("ECIES - Invalid elliptic curve point");
86 }
87 }
88
89 private:
90 ECIES_PrivateKey m_key;
91 RandomNumberGenerator& m_rng;
92};
93
94std::unique_ptr<PK_Ops::Key_Agreement> ECIES_PrivateKey::_create_key_agreement_op(
95 RandomNumberGenerator& rng, const PK_Key_Agreement_Options_Reader& options) const {
96 require_software_provider(options, algo_name());
97
98 return std::make_unique<ECIES_ECDH_KA_Operation>(*this, options, rng);
99}
100
101/**
102* Creates a PK_Key_Agreement instance for the given key and ecies_params
103* Returns either ECIES_ECDH_KA_Operation or the default implementation for the given key,
104* depending on the key and ecies_params
105* @param private_key the private key used for the key agreement
106* @param ecies_params settings for ecies
107* @param for_encryption disable cofactor mode if the secret will be used for encryption
108* (according to ISO 18033 cofactor mode is only used during decryption)
109*
110* TODO(Botan4) this entire function can be removed once cofactor support is gone
111*/
112PK_Key_Agreement create_key_agreement(const PK_Key_Agreement_Key& private_key,
113 const ECIES_KA_Params& ecies_params,
114 bool for_encryption,
115 RandomNumberGenerator& rng) {
116 const ECDH_PrivateKey* ecdh_key = dynamic_cast<const ECDH_PrivateKey*>(&private_key);
117
118 if(ecdh_key == nullptr &&
119 (ecies_params.cofactor_mode() || ecies_params.old_cofactor_mode() || ecies_params.check_mode())) {
120 // assume we have a private key from an external provider (e.g. pkcs#11):
121 // there is no way to determine or control whether the provider uses cofactor mode or not.
122 // ISO 18033 does not allow cofactor mode in combination with old cofactor mode or check mode
123 // => disable cofactor mode, old cofactor mode and check mode for unknown keys/providers (as a precaution).
124 throw Invalid_Argument("ECIES: cofactor, old cofactor and check mode are only supported for ECDH_PrivateKey");
125 }
126
127 if(ecdh_key != nullptr && (for_encryption || !ecies_params.cofactor_mode())) {
128 // ECDH_KA_Operation uses cofactor mode: use own key agreement method if cofactor should not be used.
129 return PK_Key_Agreement(ECIES_PrivateKey(*ecdh_key), rng, PK_Key_Agreement_Options().with_raw_shared_key());
130 }
131
132 // use default implementation
133 return PK_Key_Agreement(private_key, rng, PK_Key_Agreement_Options().with_raw_shared_key());
134}
135} // namespace
136
138 const ECIES_KA_Params& ecies_params,
139 bool for_encryption,
141 m_ka(create_key_agreement(private_key, ecies_params, for_encryption, rng)), m_params(ecies_params) {}
142
143#if defined(BOTAN_HAS_LEGACY_EC_POINT)
144/**
145* ECIES secret derivation according to ISO 18033-2
146*/
147SymmetricKey ECIES_KA_Operation::derive_secret(const std::vector<uint8_t>& eph_public_key_bin,
148 const EC_Point& other_public_key_point) const {
149 if(other_public_key_point.is_zero()) {
150 throw Invalid_Argument("ECIES: other public key point is zero");
151 }
152
153 auto kdf = KDF::create_or_throw(m_params.kdf());
154
155 EC_Point other_point = other_public_key_point;
156
157 // ISO 18033: step b
158 // TODO(Botan4) remove when cofactor support is removed
159 if(m_params.old_cofactor_mode() && m_params.group().has_cofactor()) {
160 other_point *= m_params.group().get_cofactor();
161 }
162
163 secure_vector<uint8_t> derivation_input;
164
165 // ISO 18033: encryption step e / decryption step g
166 if(!m_params.single_hash_mode()) {
167 derivation_input += eph_public_key_bin;
168 }
169
170 // ISO 18033: encryption step f / decryption step h
171 std::vector<uint8_t> other_public_key_bin = other_point.encode(m_params.point_format());
172 // Note: the argument `m_params.secret_length()` passed for `key_len` will only be used by providers because
173 // "Raw" is passed to the `PK_Key_Agreement` if the implementation of botan is used.
174 const SymmetricKey peh =
175 m_ka.derive_key(m_params.group().get_order_bytes(), other_public_key_bin.data(), other_public_key_bin.size());
176 derivation_input.insert(derivation_input.end(), peh.begin(), peh.end());
177
178 // ISO 18033: encryption step g / decryption step i
179 return SymmetricKey(kdf->derive_key(m_params.secret_length(), derivation_input));
180}
181#endif
182
183/**
184* ECIES secret derivation according to ISO 18033-2
185*/
186SymmetricKey ECIES_KA_Operation::derive_secret(std::span<const uint8_t> eph_public_key_bin,
187 const EC_AffinePoint& other_public_key_point) const {
188 BOTAN_ARG_CHECK(!other_public_key_point.is_identity(), "ECIES: peer public key point is the identity element");
189
190 auto kdf = KDF::create_or_throw(m_params.kdf());
191
192 auto other_point = other_public_key_point;
193
194 const auto& group = m_params.group();
195
196 // ISO 18033: step b
197 // TODO(Botan4) remove when cofactor support is removed
198 if(m_params.old_cofactor_mode() && group.has_cofactor()) {
199 Null_RNG null_rng;
200 const auto cofactor = EC_Scalar::from_bigint(group, group.get_cofactor());
201 other_point = other_point.mul(cofactor, null_rng);
202 }
203
204 secure_vector<uint8_t> derivation_input;
205
206 // ISO 18033: encryption step e / decryption step g
207 if(!m_params.single_hash_mode()) {
208 derivation_input.assign(eph_public_key_bin.begin(), eph_public_key_bin.end());
209 }
210
211 // ISO 18033: encryption step f / decryption step h
212 std::vector<uint8_t> other_public_key_bin = other_point.serialize(m_params.point_format());
213 // Note: the argument `m_params.secret_length()` passed for `key_len` will only be used by providers because
214 // "Raw" is passed to the `PK_Key_Agreement` if the implementation of botan is used.
215 const SymmetricKey peh =
216 m_ka.derive_key(m_params.group().get_order_bytes(), other_public_key_bin.data(), other_public_key_bin.size());
217 derivation_input.insert(derivation_input.end(), peh.begin(), peh.end());
218
219 // ISO 18033: encryption step g / decryption step i
220 return SymmetricKey(kdf->derive_key(m_params.secret_length(), derivation_input));
221}
222
224 const EC_Group& group, std::string_view kdf, size_t length, EC_Point_Format point_format, ECIES_Flags flags) :
225 m_group(group),
226 m_kdf(kdf),
227 m_length(length),
228 m_point_format(point_format),
229 m_single_hash_mode((flags & ECIES_Flags::SingleHashMode) == ECIES_Flags::SingleHashMode),
230 m_check_mode((flags & ECIES_Flags::CheckMode) == ECIES_Flags::CheckMode),
231 m_cofactor_mode((flags & ECIES_Flags::CofactorMode) == ECIES_Flags::CofactorMode),
232 m_old_cofactor_mode((flags & ECIES_Flags::OldCofactorMode) == ECIES_Flags::OldCofactorMode) {}
233
235 const EC_Group& group, std::string_view kdf, size_t length, EC_Point_Format point_format, bool single_hash_mode) :
236 m_group(group),
237 m_kdf(kdf),
238 m_length(length),
239 m_point_format(point_format),
240 m_single_hash_mode(single_hash_mode),
241 m_check_mode(true),
242 m_cofactor_mode(false),
243 m_old_cofactor_mode(false) {}
244
246 std::string_view kdf,
247 std::string_view dem_algo_spec,
248 size_t dem_key_len,
249 std::string_view mac_spec,
250 size_t mac_key_len,
252 ECIES_Flags flags) :
253 ECIES_KA_Params(group, kdf, dem_key_len + mac_key_len, point_format, flags),
254 m_dem_spec(dem_algo_spec),
255 m_dem_keylen(dem_key_len),
256 m_mac_spec(mac_spec),
257 m_mac_keylen(mac_key_len) {
258 // ISO 18033: "At most one of CofactorMode, OldCofactorMode, and CheckMode may be 1."
259 if(size_t(cofactor_mode()) + size_t(old_cofactor_mode()) + size_t(check_mode()) > 1) {
260 throw Invalid_Argument("ECIES: only one of cofactor_mode, old_cofactor_mode and check_mode can be set");
261 }
262}
263
265 std::string_view kdf,
266 std::string_view dem_algo_spec,
267 size_t dem_key_len,
268 std::string_view mac_spec,
269 size_t mac_key_len,
271 bool single_hash_mode) :
272 ECIES_KA_Params(group, kdf, dem_key_len + mac_key_len, point_format, single_hash_mode),
273 m_dem_spec(dem_algo_spec),
274 m_dem_keylen(dem_key_len),
275 m_mac_spec(mac_spec),
276 m_mac_keylen(mac_key_len) {}
277
278std::unique_ptr<MessageAuthenticationCode> ECIES_System_Params::create_mac() const {
280}
281
282std::unique_ptr<Cipher_Mode> ECIES_System_Params::create_cipher(Cipher_Dir direction) const {
283 return Cipher_Mode::create_or_throw(m_dem_spec, direction);
284}
285
286/*
287* ECIES_Encryptor Constructor
288*/
290 const ECIES_System_Params& ecies_params,
292 m_ka(private_key, ecies_params, true, rng),
293 m_params(ecies_params),
294 m_eph_public_key_bin(private_key.public_value()) {
295 if(ecies_params.point_format() != EC_Point_Format::Uncompressed) {
296 // ISO 18033: step d
297 // convert only if necessary; m_eph_public_key_bin has been initialized with the uncompressed format
298 m_eph_public_key_bin =
299 EC_AffinePoint(m_params.group(), m_eph_public_key_bin).serialize(ecies_params.point_format());
300 }
301 m_mac = m_params.create_mac();
302 m_cipher = m_params.create_cipher(Cipher_Dir::Encryption);
303}
304
305/*
306* ECIES_Encryptor Constructor
307*/
309 ECIES_Encryptor(ECDH_PrivateKey(rng, ecies_params.group()), ecies_params, rng) {}
310
312 /*
313 ECIES should just be used for key transport so this (arbitrary) limit
314 seems sufficient
315 */
316 return 64;
317}
318
319size_t ECIES_Encryptor::ciphertext_length(size_t ptext_len) const {
320 return m_eph_public_key_bin.size() + m_mac->output_length() + m_cipher->output_length(ptext_len);
321}
322
323/*
324* ECIES Encryption according to ISO 18033-2
325*/
326std::vector<uint8_t> ECIES_Encryptor::enc(const uint8_t data[],
327 size_t length,
328 RandomNumberGenerator& /*unused*/) const {
329 if(!m_other_point.has_value()) {
330 throw Invalid_State("ECIES_Encryptor: peer key invalid or not set");
331 }
332 if(!m_iv.has_value()) {
333 throw Invalid_State("ECIES requires a fresh IV be provided for each message");
334 }
335 if(m_iv->empty() && !m_cipher->valid_nonce_length(m_iv->size())) {
336 throw Invalid_Argument("ECIES with " + m_cipher->name() + " requires an IV be set");
337 }
338
339 const SymmetricKey secret_key = m_ka.derive_secret(m_eph_public_key_bin, m_other_point.value());
340
341 BOTAN_ASSERT_NOMSG(secret_key.size() == m_params.dem_keylen() + m_params.mac_keylen());
342
343 // encryption
344
345 m_cipher->set_key(SymmetricKey(secret_key.begin(), m_params.dem_keylen()));
346
347 m_cipher->start(m_iv->bits_of());
348 m_iv.reset();
349
350 secure_vector<uint8_t> encrypted_data(data, data + length);
351 m_cipher->finish(encrypted_data);
352
353 // compute the MAC
354 m_mac->set_key(secret_key.begin() + m_params.dem_keylen(), m_params.mac_keylen());
355 m_mac->update(encrypted_data);
356 if(!m_label.empty()) {
357 m_mac->update(m_label);
358 }
359 const auto mac = m_mac->final();
360
361 // concat elements
362 return concat(m_eph_public_key_bin, encrypted_data, mac);
363}
364
366 const ECIES_System_Params& ecies_params,
368 m_ka(key, ecies_params, false, rng), m_params(ecies_params) {
369 /*
370 ISO 18033: "If v > 1 and CheckMode = 0, then we must have gcd(u, v) = 1." (v = index, u= order)
371
372 We skip this check because even if CheckMode = 0 we actually do check that
373 the point is valid. In addition the check from ISO 18033 is pretty odd; u is
374 the _prime_ order subgroup, and v is the cofactor. For gcd(u, v) > 1 to occur
375 the cofactor would have to be a multiple of the group order, implying that
376 the overall group was at least the square of the group order. Such a curve
377 would also break our assumption that one can check for membership in the
378 prime order subgroup by multiplying by the group order and checking for the
379 identity.
380 */
381
382 m_mac = m_params.create_mac();
383 m_cipher = m_params.create_cipher(Cipher_Dir::Decryption);
384}
385
386namespace {
387
388size_t compute_point_size(const EC_Group& group, EC_Point_Format format) {
389 const size_t fe_bytes = group.get_p_bytes();
390 if(format == EC_Point_Format::Compressed) {
391 return 1 + fe_bytes;
392 } else {
393 return 1 + 2 * fe_bytes;
394 }
395}
396
397} // namespace
398
399size_t ECIES_Decryptor::plaintext_length(size_t ctext_len) const {
400 const size_t point_size = compute_point_size(m_params.group(), m_params.point_format());
401 const size_t overhead = point_size + m_mac->output_length();
402
403 if(ctext_len < overhead) {
404 return 0;
405 }
406
407 return m_cipher->output_length(ctext_len - overhead);
408}
409
410size_t ECIES_Decryptor::ciphertext_length(size_t ptext_len) const {
411 // We need the encryption direction to estimate the ciphertext length given
412 // an expected plaintext length.
413 auto cipher = m_params.create_cipher(Cipher_Dir::Encryption);
414
415 const size_t point_size = compute_point_size(m_params.group(), m_params.point_format());
416 const size_t mac_size = m_mac->output_length();
417 const size_t ct_size_bound = cipher->output_length(ptext_len);
418 return point_size + mac_size + ct_size_bound;
419}
420
421/**
422* ECIES Decryption according to ISO 18033-2
423*/
424size_t ECIES_Decryptor::do_decrypt(uint8_t& valid_mask,
425 std::span<uint8_t> ptext,
426 std::span<const uint8_t> ctext) const {
427 const uint8_t* in = ctext.data();
428 const size_t in_len = ctext.size();
429 const size_t point_size = compute_point_size(m_params.group(), m_params.point_format());
430
431 if(in_len < point_size + m_mac->output_length()) {
432 throw Decoding_Error("ECIES decryption: ciphertext is too short");
433 }
434
435 if(!m_iv.has_value()) {
436 throw Invalid_State("ECIES requires a fresh IV be provided for each message");
437 }
438 if(m_iv->empty() && !m_cipher->valid_nonce_length(m_iv->size())) {
439 throw Invalid_Argument("ECIES with " + m_cipher->name() + " requires an IV be set");
440 }
441
442 // extract data
443 const std::vector<uint8_t> other_public_key_bin(in, in + point_size); // the received (ephemeral) public key
444 const std::vector<uint8_t> encrypted_data(in + point_size, in + in_len - m_mac->output_length());
445 const std::vector<uint8_t> mac_data(in + in_len - m_mac->output_length(), in + in_len);
446
447 // ISO 18033: step a
448 auto other_public_key =
449 [](const EC_Group& group, EC_Point_Format format, std::span<const uint8_t> key) -> std::optional<EC_AffinePoint> {
450 if(format == EC_Point_Format::Compressed) {
452 } else if(format == EC_Point_Format::Uncompressed) {
454 } else {
455 // TODO(Botan4) remove this branch
456 if(key.empty() || (key[0] != 0x06 && key[0] != 0x07)) {
457 return {};
458 } else {
459 return EC_AffinePoint::deserialize(group, key);
460 }
461 }
462 }(m_params.group(), m_params.point_format(), other_public_key_bin);
463
464 if(!other_public_key) {
465 throw Decoding_Error("Invalid ECIES public point");
466 }
467
468 // ISO 18033: step b would check if other_public_key is on the curve iff check_mode is on
469 // but we ignore this and always check if the point is on the curve
470 // ISO 18033: step e (and step f because get_affine_x (called by ECDH_KA_Operation::raw_agree)
471 // throws Illegal_Transformation if the point is zero)
472 const SymmetricKey secret_key = m_ka.derive_secret(other_public_key_bin, *other_public_key);
473
474 BOTAN_ASSERT_NOMSG(secret_key.size() == m_params.dem_keylen() + m_params.mac_keylen());
475
476 // validate mac
477 m_mac->set_key(secret_key.begin() + m_params.dem_keylen(), m_params.mac_keylen());
478 m_mac->update(encrypted_data);
479 if(!m_label.empty()) {
480 m_mac->update(m_label);
481 }
482 const secure_vector<uint8_t> calculated_mac = m_mac->final();
483 valid_mask = CT::is_equal<uint8_t>(mac_data, calculated_mac).value();
484
485 // Consume the IV state even if the message is invalid
486 auto iv = m_iv->bits_of();
487 m_iv.reset();
488
489 if(valid_mask == 0xFF) {
490 // decrypt data
491
492 m_cipher->set_key(SymmetricKey(secret_key.begin(), m_params.dem_keylen()));
493 m_cipher->start(iv);
494
495 try {
496 // the decryption can fail:
497 // e.g. Invalid_Authentication_Tag is thrown if GCM is used and the message does not have a valid tag
498 secure_vector<uint8_t> decrypted_data(encrypted_data.begin(), encrypted_data.end());
499 m_cipher->finish(decrypted_data);
500 BOTAN_ARG_CHECK(ptext.size() >= decrypted_data.size(), "Output buffer too small for decryption");
501 copy_mem(ptext.first(decrypted_data.size()), decrypted_data);
502 return decrypted_data.size();
503 } catch(...) {
504 valid_mask = 0;
505 }
506 }
507 return 0;
508}
509
510} // namespace Botan
#define BOTAN_DIAGNOSTIC_POP
Definition api.h:128
#define BOTAN_DIAGNOSTIC_PUSH
Definition api.h:125
#define BOTAN_DIAGNOSTIC_IGNORE_INHERITED_VIA_DOMINANCE
Definition api.h:127
#define BOTAN_ASSERT_NOMSG(expr)
Definition assert.h:82
#define BOTAN_ARG_CHECK(expr, msg)
Definition assert.h:33
static std::unique_ptr< Cipher_Mode > create_or_throw(std::string_view algo, Cipher_Dir direction, std::string_view provider="")
ECIES_Decryptor(const PK_Key_Agreement_Key &private_key, const ECIES_System_Params &ecies_params, RandomNumberGenerator &rng)
Definition ecies.cpp:365
ECIES_Encryptor(const PK_Key_Agreement_Key &private_key, const ECIES_System_Params &ecies_params, RandomNumberGenerator &rng)
Definition ecies.cpp:289
ECIES_KA_Operation(const PK_Key_Agreement_Key &private_key, const ECIES_KA_Params &ecies_params, bool for_encryption, RandomNumberGenerator &rng)
Definition ecies.cpp:137
SymmetricKey derive_secret(std::span< const uint8_t > eph_public_key_bin, const EC_AffinePoint &other_public_key_point) const
Definition ecies.cpp:186
bool check_mode() const
Definition ecies.h:136
bool old_cofactor_mode() const
Definition ecies.h:133
ECIES_KA_Params(const EC_Group &group, std::string_view kdf_spec, size_t length, EC_Point_Format point_format=EC_Point_Format::Uncompressed, bool single_hash_mode=true)
Definition ecies.cpp:234
bool cofactor_mode() const
Definition ecies.h:130
bool single_hash_mode() const
Definition ecies.h:127
const EC_Group & group() const
Definition ecies.h:123
const std::string & kdf() const
Definition ecies.h:140
EC_Point_Format point_format() const
Definition ecies.h:138
std::unique_ptr< Cipher_Mode > create_cipher(Cipher_Dir direction) const
creates an instance of the data encryption method
Definition ecies.cpp:282
std::unique_ptr< MessageAuthenticationCode > create_mac() const
creates an instance of the message authentication code
Definition ecies.cpp:278
ECIES_System_Params(const EC_Group &group, std::string_view kdf_spec, std::string_view dem_algo_spec, size_t dem_key_len, std::string_view mac_spec, size_t mac_key_len, EC_Point_Format point_format=EC_Point_Format::Uncompressed, bool single_hash_mode=false)
Definition ecies.cpp:264
EC_Group group() const
Return the elliptic curve group this point is associated with.
bool is_identity() const
Return true if this point is the identity element.
static std::optional< EC_AffinePoint > deserialize_uncompressed(const EC_Group &group, std::span< const uint8_t > bytes)
static std::optional< EC_AffinePoint > deserialize(const EC_Group &group, std::span< const uint8_t > bytes)
static std::optional< EC_AffinePoint > deserialize_compressed(const EC_Group &group, std::span< const uint8_t > bytes)
const BigInt & get_cofactor() const
Definition ec_group.cpp:797
bool has_cofactor() const
Definition ec_group.cpp:801
size_t get_p_bytes() const
Definition ec_group.cpp:725
bool is_zero() const
Definition ec_point.h:170
std::vector< uint8_t > encode(EC_Point_Format format) const
Definition ec_point.cpp:813
static EC_Scalar from_bigint(const EC_Group &group, const BigInt &bn)
Definition ec_scalar.cpp:84
static std::unique_ptr< KDF > create_or_throw(std::string_view algo_spec, std::string_view provider="")
Definition kdf.cpp:208
static std::unique_ptr< MessageAuthenticationCode > create_or_throw(std::string_view algo_spec, std::string_view provider="")
Definition mac.cpp:142
const uint8_t * end() const
Definition symkey.h:58
const uint8_t * begin() const
Definition symkey.h:52
virtual size_t maximum_input_size() const =0
constexpr decltype(auto) driveby_unpoison(T &&v)
Definition ct_utils.h:243
constexpr auto scoped_poison(const Ts &... xs)
Definition ct_utils.h:222
constexpr CT::Mask< T > is_equal(const T x[], const T y[], size_t len)
Definition ct_utils.h:803
OctetString SymmetricKey
Definition symkey.h:153
ECIES_Flags
Definition ecies.h:44
@ SingleHashMode
if set: do NOT prefix the input of the (ecdh) key agreement with the encoded (ephemeral) public key
Definition ecies.h:47
constexpr void copy_mem(T *out, const T *in, size_t n)
Definition mem_ops.h:144
void require_software_provider(const OptionsT &options, std::string_view algo_name)
PublicKeyOperation
Definition pk_keys.h:50
constexpr auto concat(Rs &&... ranges)
Definition concat_util.h:95
std::vector< T, secure_allocator< T > > secure_vector
Definition secmem.h:128