Botan 2.19.1
Crypto and TLS for C&
Public Member Functions | List of all members
Botan::ECIES_Encryptor Class Referencefinal

#include <ecies.h>

Inheritance diagram for Botan::ECIES_Encryptor:
Botan::PK_Encryptor

Public Member Functions

 ECIES_Encryptor (const PK_Key_Agreement_Key &private_key, const ECIES_System_Params &ecies_params, RandomNumberGenerator &rng)
 
 ECIES_Encryptor (RandomNumberGenerator &rng, const ECIES_System_Params &ecies_params)
 
template<typename Alloc >
std::vector< uint8_t > encrypt (const std::vector< uint8_t, Alloc > &in, RandomNumberGenerator &rng) const
 
std::vector< uint8_t > encrypt (const uint8_t in[], size_t length, RandomNumberGenerator &rng) const
 
void set_initialization_vector (const InitializationVector &iv)
 Set the initialization vector for the data encryption method. More...
 
void set_label (const std::string &label)
 Set the label which is appended to the input for the message authentication code. More...
 
void set_other_key (const Botan::PointGFp &public_point)
 Set the public key of the other party. More...
 

Detailed Description

ECIES Encryption according to ISO 18033-2

Definition at line 217 of file ecies.h.

Constructor & Destructor Documentation

◆ ECIES_Encryptor() [1/2]

Botan::ECIES_Encryptor::ECIES_Encryptor ( const PK_Key_Agreement_Key private_key,
const ECIES_System_Params ecies_params,
RandomNumberGenerator rng 
)
Parameters
private_keythe (ephemeral) private key which is used for the key agreement
ecies_paramssettings for ecies
rngrandom generator to use

Definition at line 231 of file ecies.cpp.

233 :
234 m_ka(private_key, ecies_params, true, rng),
235 m_params(ecies_params),
236 m_eph_public_key_bin(private_key.public_value()), // returns the uncompressed public key, see conversion below
237 m_iv(),
238 m_other_point(),
239 m_label()
240 {
241 if(ecies_params.compression_type() != PointGFp::UNCOMPRESSED)
242 {
243 // ISO 18033: step d
244 // convert only if necessary; m_eph_public_key_bin has been initialized with the uncompressed format
245 m_eph_public_key_bin = m_params.domain().OS2ECP(m_eph_public_key_bin).encode(ecies_params.compression_type());
246 }
247 m_mac = m_params.create_mac();
248 m_cipher = m_params.create_cipher(ENCRYPTION);
249 }
const EC_Group & domain() const
Definition: ecies.h:75
std::unique_ptr< Cipher_Mode > create_cipher(Botan::Cipher_Dir direction) const
creates an instance of the data encryption method
Definition: ecies.cpp:222
std::unique_ptr< MessageAuthenticationCode > create_mac() const
creates an instance of the message authentication code
Definition: ecies.cpp:217
PointGFp OS2ECP(const uint8_t bits[], size_t len) const
Definition: ec_group.cpp:573
std::vector< uint8_t > encode(PointGFp::Compression_Type format) const
Definition: point_gfp.cpp:601
@ ENCRYPTION
Definition: cipher_mode.h:23

References Botan::ECIES_KA_Params::compression_type(), Botan::ECIES_System_Params::create_cipher(), Botan::ECIES_System_Params::create_mac(), Botan::ECIES_KA_Params::domain(), Botan::PointGFp::encode(), Botan::ENCRYPTION, Botan::EC_Group::OS2ECP(), and Botan::PointGFp::UNCOMPRESSED.

◆ ECIES_Encryptor() [2/2]

Botan::ECIES_Encryptor::ECIES_Encryptor ( RandomNumberGenerator rng,
const ECIES_System_Params ecies_params 
)

Creates an ephemeral private key which is used for the key agreement

Parameters
rngrandom generator used during private key generation
ecies_paramssettings for ecies

Definition at line 254 of file ecies.cpp.

254 :
255 ECIES_Encryptor(ECDH_PrivateKey(rng, ecies_params.domain()), ecies_params, rng)
256 {
257 }
ECIES_Encryptor(const PK_Key_Agreement_Key &private_key, const ECIES_System_Params &ecies_params, RandomNumberGenerator &rng)
Definition: ecies.cpp:231

Member Function Documentation

◆ encrypt() [1/2]

template<typename Alloc >
std::vector< uint8_t > Botan::PK_Encryptor::encrypt ( const std::vector< uint8_t, Alloc > &  in,
RandomNumberGenerator rng 
) const
inlineinherited

Encrypt a message.

Parameters
inthe message
rngthe random number source to use
Returns
encrypted message

Definition at line 53 of file pubkey.h.

55 {
56 return enc(in.data(), in.size(), rng);
57 }

◆ encrypt() [2/2]

std::vector< uint8_t > Botan::PK_Encryptor::encrypt ( const uint8_t  in[],
size_t  length,
RandomNumberGenerator rng 
) const
inlineinherited

Encrypt a message.

Parameters
inthe message as a byte array
lengththe length of the above byte array
rngthe random number source to use
Returns
encrypted message

Definition at line 40 of file pubkey.h.

42 {
43 return enc(in, length, rng);
44 }

Referenced by Botan::KeyPair::encryption_consistency_check().

◆ set_initialization_vector()

void Botan::ECIES_Encryptor::set_initialization_vector ( const InitializationVector iv)
inline

Set the initialization vector for the data encryption method.

Definition at line 243 of file ecies.h.

244 {
245 m_iv = iv;
246 }

◆ set_label()

void Botan::ECIES_Encryptor::set_label ( const std::string &  label)
inline

Set the label which is appended to the input for the message authentication code.

Definition at line 249 of file ecies.h.

250 {
251 m_label = std::vector<uint8_t>(label.begin(), label.end());
252 }

◆ set_other_key()

void Botan::ECIES_Encryptor::set_other_key ( const Botan::PointGFp public_point)
inline

Set the public key of the other party.

Definition at line 237 of file ecies.h.

238 {
239 m_other_point = public_point;
240 }

The documentation for this class was generated from the following files: