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_KA_Operation Class Reference

`#include <ecies.h>`

## Public Member Functions
SymmetricKey | derive_secret (const std::vector< uint8_t > &eph_public_key_bin, const PointGFp &other_public_key_point) const
| ECIES_KA_Operation (const PK_Key_Agreement_Key &private_key, const ECIES_KA_Params &ecies_params, bool for_encryption, RandomNumberGenerator &rng)

## Detailed Description

ECIES secret derivation according to ISO 18033-2

Definition at line 185 of file ecies.h.

## Constructor & Destructor Documentation

Botan::ECIES_KA_Operation::ECIES_KA_Operation | ( | const PK_Key_Agreement_Key & | private_key,
|  | const ECIES_KA_Params & | ecies_params,
|  | bool | for_encryption,
|  | RandomNumberGenerator & | rng
| ) |  |

Parameters

  private_key | the (ephemeral) private key which is used to derive the secret
  ecies_params | settings for ecies
  for_encryption | disable cofactor mode if the secret will be used for encryption (according to ISO 18033 cofactor mode is only used during decryption)
  rng | the RNG to use

Definition at line 124 of file ecies.cpp.

127 :
128 m_ka(create_key_agreement(private_key, ecies_params, for_encryption, rng)),
129 m_params(ecies_params)
130 {
131 }

## Member Function Documentation

SymmetricKey Botan::ECIES_KA_Operation::derive_secret | ( | const std::vector< uint8_t > & | eph_public_key_bin,
|  | const PointGFp & | other_public_key_point
| ) |  | const

Performs a key agreement with the provided keys and derives the secret from the result

Parameters

  eph_public_key_bin | the encoded (ephemeral) public key which belongs to the used (ephemeral) private key
  other_public_key_point | public key point of the other party

ECIES secret derivation according to ISO 18033-2

Definition at line 136 of file ecies.cpp.

References Botan::OctetString::begin(), Botan::BigInt::bytes(), Botan::ECIES_KA_Params::compression_type(), Botan::KDF::create_or_throw(), Botan::PK_Key_Agreement::derive_key(), Botan::ECIES_KA_Params::domain(), Botan::EC2OSP(), Botan::OctetString::end(), Botan::EC_Group::get_cofactor(), Botan::EC_Group::get_order(), Botan::PointGFp::is_zero(), Botan::ECIES_KA_Params::kdf_spec(), Botan::ECIES_KA_Params::old_cofactor_mode(), Botan::ECIES_KA_Params::secret_length(), and Botan::ECIES_KA_Params::single_hash_mode().

138 {
139 if(other_public_key_point.is_zero())
140 {
141 throw Invalid_Argument("ECIES: other public key point is zero");
142 }
143
144 std::unique_ptr<KDF> kdf = Botan::KDF::create_or_throw(m_params.kdf_spec());
145
146 PointGFp other_point = other_public_key_point;
147
148 // ISO 18033: step b
149 if(m_params.old_cofactor_mode())
150 {
151 other_point *= m_params.domain().get_cofactor();
152 }
153
154 secure_vector<uint8_t> derivation_input;
155
156 // ISO 18033: encryption step e / decryption step g
157 if(!m_params.single_hash_mode())
158 {
159 derivation_input += eph_public_key_bin;
160 }
161
162 // ISO 18033: encryption step f / decryption step h
163 secure_vector<uint8_t> other_public_key_bin = EC2OSP(other_point, static_cast<uint8_t>(m_params.compression_type()));
164 // Note: the argument `m_params.secret_length()` passed for `key_len` will only be used by providers because
165 // "Raw" is passed to the `PK_Key_Agreement` if the implementation of botan is used.
166 const SymmetricKey peh = m_ka.derive_key(m_params.domain().get_order().bytes(), other_public_key_bin.data(), other_public_key_bin.size());
167 derivation_input.insert(derivation_input.end(), peh.begin(), peh.end());
168
169 // ISO 18033: encryption step g / decryption step i
170 return kdf->derive_key(m_params.secret_length(), derivation_input);
171 }
Botan::EC2OSP
secure_vector< uint8_t > EC2OSP(const PointGFp &point, uint8_t format)
Definition: point_gfp.cpp:470
Botan::PK_Key_Agreement::derive_key
SymmetricKey derive_key(size_t key_len, const uint8_t in[], size_t in_len, const uint8_t params[], size_t params_len) const
Definition: pubkey.cpp:202
Botan::ECIES_KA_Params::single_hash_mode
bool single_hash_mode() const
Definition: ecies.h:85
Botan::ECIES_KA_Params::domain
const EC_Group & domain() const
Definition: ecies.h:75
Botan::ECIES_KA_Params::secret_length
size_t secret_length() const
Definition: ecies.h:80
Botan::EC_Group::get_order
const BigInt & get_order() const
Definition: ec_group.h:101
Botan::SymmetricKey
OctetString SymmetricKey
Definition: symkey.h:136
Botan::ECIES_KA_Params::kdf_spec
const std::string & kdf_spec() const
Definition: ecies.h:110
Botan::ECIES_KA_Params::compression_type
PointGFp::Compression_Type compression_type() const
Definition: ecies.h:105
Botan::KDF::create_or_throw
static std::unique_ptr< KDF > create_or_throw(const std::string &algo_spec, const std::string &provider="")
Definition: kdf.cpp:211
Botan::EC_Group::get_cofactor
const BigInt & get_cofactor() const
Definition: ec_group.h:107
Botan::BigInt::bytes
size_t bytes() const
Definition: bigint.cpp:176
Botan::ECIES_KA_Params::old_cofactor_mode
bool old_cofactor_mode() const
Definition: ecies.h:95

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

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