12#include <botan/cipher_mode.h>
13#include <botan/ec_apoint.h>
14#include <botan/ec_group.h>
16#include <botan/pubkey.h>
17#include <botan/secmem.h>
18#include <botan/symkey.h>
25#if defined(BOTAN_HAS_LEGACY_EC_POINT)
26 #include <botan/ec_point.h>
67 return static_cast<ECIES_Flags>(
static_cast<uint32_t
>(a) |
static_cast<uint32_t
>(b));
71 return static_cast<ECIES_Flags>(
static_cast<uint32_t
>(a) &
static_cast<uint32_t
>(b));
136 const std::string&
kdf()
const {
return m_kdf; }
146 const std::string m_kdf;
147 const size_t m_length;
149 const bool m_single_hash_mode;
150 const bool m_check_mode;
151 const bool m_cofactor_mode;
152 const bool m_old_cofactor_mode;
167 std::string_view dem_algo_spec,
169 std::string_view mac_spec,
193 std::string_view dem_algo_spec,
195 std::string_view mac_spec,
207 std::unique_ptr<MessageAuthenticationCode>
create_mac()
const;
219 const std::string m_dem_spec;
220 const size_t m_dem_keylen;
221 const std::string m_mac_spec;
222 const size_t m_mac_keylen;
242#if defined(BOTAN_HAS_LEGACY_EC_POINT)
249 const EC_Point& other_public_key_point)
const;
286#if defined(BOTAN_HAS_LEGACY_EC_POINT)
300 void set_label(std::string_view label) { m_label.assign(label.begin(), label.end()); }
303 std::vector<uint8_t> enc(
const uint8_t data[],
size_t length,
RandomNumberGenerator& rng)
const override;
305 size_t maximum_input_size()
const override;
307 size_t ciphertext_length(
size_t ptext_len)
const override;
311 std::unique_ptr<MessageAuthenticationCode> m_mac;
312 std::unique_ptr<Cipher_Mode> m_cipher;
313 std::vector<uint8_t> m_eph_public_key_bin;
315 std::optional<EC_AffinePoint> m_other_point;
316 std::vector<uint8_t> m_label;
337 void set_label(std::string_view label) { m_label = std::vector<uint8_t>(label.begin(), label.end()); }
342 size_t plaintext_length(
size_t ctext_len)
const override;
346 std::unique_ptr<MessageAuthenticationCode> m_mac;
347 std::unique_ptr<Cipher_Mode> m_cipher;
349 std::vector<uint8_t> m_label;
#define BOTAN_PUBLIC_API(maj, min)
#define BOTAN_DEPRECATED(msg)
void set_label(std::string_view label)
Set the label which is appended to the input for the message authentication code.
void set_initialization_vector(const InitializationVector &iv)
Set the initialization vector for the data encryption method.
ECIES_Decryptor(const PK_Key_Agreement_Key &private_key, const ECIES_System_Params &ecies_params, RandomNumberGenerator &rng)
void set_other_key(const EC_AffinePoint &pt)
Set the public key of the other party.
ECIES_Encryptor(const PK_Key_Agreement_Key &private_key, const ECIES_System_Params &ecies_params, RandomNumberGenerator &rng)
void set_initialization_vector(const InitializationVector &iv)
Set the initialization vector for the data encryption method.
void set_label(std::string_view label)
Set the label which is appended to the input for the message authentication code.
ECIES_KA_Operation(const PK_Key_Agreement_Key &private_key, const ECIES_KA_Params &ecies_params, bool for_encryption, RandomNumberGenerator &rng)
SymmetricKey derive_secret(std::span< const uint8_t > eph_public_key_bin, const EC_AffinePoint &other_public_key_point) const
ECIES_KA_Params(const ECIES_KA_Params &)=default
size_t secret_length() const
bool old_cofactor_mode() const
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)
EC_Point_Format compression_type() const
bool cofactor_mode() const
virtual ~ECIES_KA_Params()=default
bool single_hash_mode() const
const std::string & kdf_spec() const
const EC_Group & group() const
const std::string & kdf() const
ECIES_KA_Params & operator=(ECIES_KA_Params &&)=delete
const EC_Group & domain() const
EC_Point_Format point_format() const
ECIES_KA_Params & operator=(const ECIES_KA_Params &)=delete
ECIES_KA_Params(ECIES_KA_Params &&)=default
ECIES_System_Params(ECIES_System_Params &&)=default
ECIES_System_Params(const ECIES_System_Params &)=default
~ECIES_System_Params() override=default
size_t dem_keylen() const
returns the length of the key used by the data encryption method
ECIES_System_Params & operator=(ECIES_System_Params &&)=delete
size_t mac_keylen() const
returns the length of the key used by the message authentication code
std::unique_ptr< Cipher_Mode > create_cipher(Cipher_Dir direction) const
creates an instance of the data encryption method
std::unique_ptr< MessageAuthenticationCode > create_mac() const
creates an instance of the message authentication code
ECIES_System_Params & operator=(const ECIES_System_Params &)=delete
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)
ASN1_Type operator|(ASN1_Type x, ASN1_Type y)
@ SingleHashMode
if set: prefix the input of the (ecdh) key agreement with the encoded (ephemeral) public key
OctetString InitializationVector
std::vector< T, secure_allocator< T > > secure_vector
ECIES_Flags operator&(ECIES_Flags a, ECIES_Flags b)