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

#include <pubkey.h>

Public Member Functions

SymmetricKey derive_key (size_t key_len, const byte in[], size_t in_len, const byte params[], size_t params_len) const
 
SymmetricKey derive_key (size_t key_len, const std::vector< byte > &in, const byte params[], size_t params_len) const
 
SymmetricKey derive_key (size_t key_len, const byte in[], size_t in_len, const std::string &params="") const
 
SymmetricKey derive_key (size_t key_len, const std::vector< byte > &in, const std::string &params="") const
 
 PK_Key_Agreement (const PK_Key_Agreement_Key &key, const std::string &kdf)
 

Detailed Description

Key used for key agreement

Definition at line 313 of file pubkey.h.

Constructor & Destructor Documentation

Botan::PK_Key_Agreement::PK_Key_Agreement ( const PK_Key_Agreement_Key key,
const std::string &  kdf 
)

Construct a PK Key Agreement.

Parameters
keythe key to use
kdfname of the KDF to use (or 'Raw' for no KDF)

Definition at line 353 of file pubkey.cpp.

References Botan::Public_Key::algo_name(), Botan::get_kdf(), Botan::Library_State::global_rng(), Botan::Global_State_Management::global_state(), and Botan::Algorithm_Factory::Engine_Iterator::next().

355  {
356  Algorithm_Factory::Engine_Iterator i(global_state().algorithm_factory());
357  RandomNumberGenerator& rng = global_state().global_rng();
358 
359  while(const Engine* engine = i.next())
360  {
361  m_op.reset(engine->get_key_agreement_op(key, rng));
362  if(m_op)
363  break;
364  }
365 
366  if(!m_op)
367  throw Lookup_Error("Key agreement with " + key.algo_name() + " not supported");
368 
369  m_kdf.reset(get_kdf(kdf_name));
370  }
RandomNumberGenerator & global_rng()
Definition: libstate.cpp:56
friend class Engine_Iterator
Definition: algo_factory.h:205
Library_State & global_state()
KDF * get_kdf(const std::string &algo_spec)
Definition: kdf.cpp:34

Member Function Documentation

SymmetricKey Botan::PK_Key_Agreement::derive_key ( size_t  key_len,
const byte  in[],
size_t  in_len,
const byte  params[],
size_t  params_len 
) const

Definition at line 372 of file pubkey.cpp.

Referenced by Botan::TLS::Client_Key_Exchange::Client_Key_Exchange().

375  {
376  secure_vector<byte> z = m_op->agree(in, in_len);
377 
378  if(!m_kdf)
379  return z;
380 
381  return m_kdf->derive_key(key_len, z, params, params_len);
382  }
SymmetricKey Botan::PK_Key_Agreement::derive_key ( size_t  key_len,
const std::vector< byte > &  in,
const byte  params[],
size_t  params_len 
) const
inline

Definition at line 339 of file pubkey.h.

343  {
344  return derive_key(key_len, &in[0], in.size(),
345  params, params_len);
346  }
SymmetricKey derive_key(size_t key_len, const byte in[], size_t in_len, const byte params[], size_t params_len) const
Definition: pubkey.cpp:372
SymmetricKey Botan::PK_Key_Agreement::derive_key ( size_t  key_len,
const byte  in[],
size_t  in_len,
const std::string &  params = "" 
) const
inline

Definition at line 355 of file pubkey.h.

358  {
359  return derive_key(key_len, in, in_len,
360  reinterpret_cast<const byte*>(params.data()),
361  params.length());
362  }
SymmetricKey derive_key(size_t key_len, const byte in[], size_t in_len, const byte params[], size_t params_len) const
Definition: pubkey.cpp:372
SymmetricKey Botan::PK_Key_Agreement::derive_key ( size_t  key_len,
const std::vector< byte > &  in,
const std::string &  params = "" 
) const
inline

Definition at line 370 of file pubkey.h.

373  {
374  return derive_key(key_len, &in[0], in.size(),
375  reinterpret_cast<const byte*>(params.data()),
376  params.length());
377  }
SymmetricKey derive_key(size_t key_len, const byte in[], size_t in_len, const byte params[], size_t params_len) const
Definition: pubkey.cpp:372
uint8_t byte
Definition: types.h:30

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