Botan: Botan::PK_Key_Agreement Class Reference

Botan 1.10.17

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 MemoryRegion< 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 MemoryRegion< byte > &in, const std::string &params="") const
| PK_Key_Agreement (const PK_Key_Agreement_Key &key, const std::string &kdf)
| ~PK_Key_Agreement ()

## Detailed Description

Key used for key agreement

Definition at line 312 of file pubkey.h.

## Constructor & Destructor Documentation

## ◆ PK_Key_Agreement()

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

Construct a PK Key Agreement.

Parameters

  key | the key to use
  kdf | name of the KDF to use (or 'Raw' for no KDF)

Definition at line 359 of file pubkey.cpp.

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

361 {
362 Algorithm_Factory::Engine_Iterator i(global_state().algorithm_factory());
363
364 op = 0;
365
366 while(const Engine* engine = i.next())
367 {
368 op = engine->get_key_agreement_op(key);
369 if(op)
370 break;
371 }
372
373 if(!op)
374 throw Lookup_Error("Key agreement with " + key.algo_name() + " not supported");
375
376 kdf = (kdf_name == "Raw") ? 0 : get_kdf(kdf_name);
377 }
Botan::Algorithm_Factory::Engine_Iterator
friend class Engine_Iterator
Definition: algo_factory.h:207
Botan::Global_State_Management::global_state
Library_State & global_state()
Definition: global_state.cpp:32
Botan::get_kdf
KDF * get_kdf(const std::string &algo_spec)
Definition: get_enc.cpp:174

## ◆ ~PK_Key_Agreement()

Botan::PK_Key_Agreement::~PK_Key_Agreement | ( |  | ) |
| inline

Definition at line 386 of file pubkey.h.

386 { delete op; delete kdf; }

## Member Function Documentation

## ◆ derive_key() [1/4]

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 379 of file pubkey.cpp.

References Botan::PK_Ops::Key_Agreement::agree(), and Botan::KDF::derive_key().

382 {
383 SecureVector<byte> z = op->agree(in, in_len);
384
385 if(!kdf)
386 return z;
387
388 return kdf->derive_key(key_len, z, params, params_len);
389 }
Botan::PK_Ops::Key_Agreement::agree
virtual SecureVector< byte > agree(const byte w[], size_t w_len)=0
Botan::KDF::derive_key
SecureVector< byte > derive_key(size_t key_len, const MemoryRegion< byte > &secret, const std::string &salt="") const
Definition: kdf.cpp:15

## ◆ derive_key() [2/4]

SymmetricKey Botan::PK_Key_Agreement::derive_key | ( | size_t | key_len,
|  | const MemoryRegion< byte > & | in,
|  | const byte | params[],
|  | size_t | params_len
| ) |  | const
| inline

Definition at line 338 of file pubkey.h.

References Botan::MemoryRegion< T >::size().

342 {
343 return derive_key(key_len, &in[0], in.size(),
344 params, params_len);
345 }
Botan::MemoryRegion::size
size_t size() const
Definition: secmem.h:29
Botan::PK_Key_Agreement::derive_key
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:379

## ◆ derive_key() [3/4]

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 354 of file pubkey.h.

357 {
358 return derive_key(key_len, in, in_len,
359 reinterpret_cast<const byte*>(params.data()),
360 params.length());
361 }
Botan::PK_Key_Agreement::derive_key
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:379

## ◆ derive_key() [4/4]

SymmetricKey Botan::PK_Key_Agreement::derive_key | ( | size_t | key_len,
|  | const MemoryRegion< byte > & | in,
|  | const std::string & | params = `""`
| ) |  | const
| inline

Definition at line 369 of file pubkey.h.

References Botan::MemoryRegion< T >::size().

372 {
373 return derive_key(key_len, &in[0], in.size(),
374 reinterpret_cast<const byte*>(params.data()),
375 params.length());
376 }
Botan::byte
unsigned char byte
Definition: types.h:22
Botan::MemoryRegion::size
size_t size() const
Definition: secmem.h:29
Botan::PK_Key_Agreement::derive_key
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:379

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

- src/pubkey/pubkey.h
- src/pubkey/pubkey.cpp