Botan 2.1.0 Crypto and TLS for C++11

- Main Page
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Member Functions | List of all members
Botan::ECIES_Encryptor Class Reference

`#include <ecies.h>`

Inheritance diagram for Botan::ECIES_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)
std::vector< uint8_t > | encrypt (const uint8_t in[], size_t length, RandomNumberGenerator &rng) const
template<typename Alloc >
std::vector< uint8_t > | encrypt (const std::vector< uint8_t, Alloc > &in, 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

Botan::ECIES_Encryptor::ECIES_Encryptor | ( | const PK_Key_Agreement_Key & | private_key,
|  | const ECIES_System_Params & | ecies_params,
|  | RandomNumberGenerator & | rng
| ) |  |

Parameters

  private_key | the (ephemeral) private key which is used for the key agreement
  ecies_params | settings for ecies
  rng | random generator to use

Definition at line 228 of file ecies.cpp.

References Botan::ECIES_KA_Params::compression_type(), Botan::ECIES_KA_Params::domain(), Botan::EC2OSP(), Botan::EC_Group::get_curve(), Botan::OS2ECP(), Botan::PointGFp::UNCOMPRESSED, and Botan::unlock().

230 :
231 m_ka(private_key, ecies_params, true, rng),
232 m_params(ecies_params),
233 m_eph_public_key_bin(private_key.public_value()), // returns the uncompressed public key, see conversion below
234 m_iv(),
235 m_other_point(),
236 m_label()
237 {
238 if(ecies_params.compression_type() != PointGFp::UNCOMPRESSED)
239 {
240 // ISO 18033: step d
241 // convert only if necessary; m_eph_public_key_bin has been initialized with the uncompressed format
242 m_eph_public_key_bin = unlock(EC2OSP(OS2ECP(m_eph_public_key_bin, m_params.domain().get_curve()),
243 static_cast<uint8_t>(ecies_params.compression_type())));
244 }
245 }
Botan::PointGFp::UNCOMPRESSED
Definition: point_gfp.h:45
Botan::EC2OSP
secure_vector< uint8_t > EC2OSP(const PointGFp &point, uint8_t format)
Definition: point_gfp.cpp:470
Botan::ECIES_KA_Params::domain
const EC_Group & domain() const
Definition: ecies.h:75
Botan::EC_Group::get_curve
const CurveGFp & get_curve() const
Definition: ec_group.h:89
Botan::OS2ECP
PointGFp OS2ECP(const uint8_t data[], size_t data_len, const CurveGFp &curve)
Definition: point_gfp.cpp:544
Botan::unlock
std::vector< T > unlock(const secure_vector< T > &in)
Definition: secmem.h:125

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

  rng | random generator used during private key generation
  ecies_params | settings for ecies

Definition at line 250 of file ecies.cpp.

250 :
251 ECIES_Encryptor(ECDH_PrivateKey(rng, ecies_params.domain()), ecies_params, rng)
252 {
253 }
Botan::ECIES_Encryptor::ECIES_Encryptor
ECIES_Encryptor(const PK_Key_Agreement_Key &private_key, const ECIES_System_Params &ecies_params, RandomNumberGenerator &rng)
Definition: ecies.cpp:228

## Member Function Documentation

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

Encrypt a message.

Parameters

  in | the message as a byte array
  length | the length of the above byte array
  rng | the random number source to use

Returns
  encrypted message

Definition at line 46 of file pubkey.h.

Referenced by Botan::TLS::Client_Key_Exchange::Client_Key_Exchange(), and Botan::KeyPair::encryption_consistency_check().

48 {
49 return enc(in, length, rng);
50 }
template<typename Alloc >

std::vector<uint8_t> Botan::PK_Encryptor::encrypt | ( | const std::vector< uint8_t, Alloc > & | in,
|  | RandomNumberGenerator & | rng
| ) |  | const
| inline inherited

Encrypt a message.

Parameters

  in | the message
  rng | the random number source to use

Returns
  encrypted message

Definition at line 59 of file pubkey.h.

61 {
62 return enc(in.data(), in.size(), rng);
63 }

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 }

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 }

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:

- src/lib/pubkey/ecies/ecies.h
- src/lib/pubkey/ecies/ecies.cpp