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

#include <pubkey.h>

Public Member Functions

size_t agreed_value_size () const
 
SymmetricKey derive_key (size_t key_len, const std::vector< uint8_t > &in, const std::string &params="") const
 
SymmetricKey derive_key (size_t key_len, const std::vector< uint8_t > &in, const uint8_t params[], size_t params_len) const
 
SymmetricKey derive_key (size_t key_len, const uint8_t in[], size_t in_len, const std::string &params="") const
 
SymmetricKey derive_key (size_t key_len, const uint8_t in[], size_t in_len, const uint8_t params[], size_t params_len) const
 
PK_Key_Agreementoperator= (const PK_Key_Agreement &)=delete
 
PK_Key_Agreementoperator= (PK_Key_Agreement &&)
 
 PK_Key_Agreement (const PK_Key_Agreement &)=delete
 
 PK_Key_Agreement (const Private_Key &key, RandomNumberGenerator &rng, const std::string &kdf, const std::string &provider="")
 
 PK_Key_Agreement (PK_Key_Agreement &&)
 
 ~PK_Key_Agreement ()
 

Detailed Description

Object used for key agreement

Definition at line 413 of file pubkey.h.

Constructor & Destructor Documentation

◆ PK_Key_Agreement() [1/3]

Botan::PK_Key_Agreement::PK_Key_Agreement ( const Private_Key key,
RandomNumberGenerator rng,
const std::string &  kdf,
const std::string &  provider = "" 
)

Construct a PK Key Agreement.

Parameters
keythe key to use
rngthe random generator to use
kdfname of the KDF to use (or 'Raw' for no KDF)
providerthe algo provider to use (or empty for default)

Definition at line 188 of file pubkey.cpp.

192 {
193 m_op = key.create_key_agreement_op(rng, kdf, provider);
194 if(!m_op)
195 throw Invalid_Argument("Key type " + key.algo_name() + " does not support key agreement");
196 }

References Botan::Public_Key::algo_name(), and Botan::Private_Key::create_key_agreement_op().

◆ ~PK_Key_Agreement()

Botan::PK_Key_Agreement::~PK_Key_Agreement ( )

Definition at line 198 of file pubkey.cpp.

198{ /* for unique_ptr */ }

◆ PK_Key_Agreement() [2/3]

Botan::PK_Key_Agreement::PK_Key_Agreement ( PK_Key_Agreement &&  other)

Definition at line 209 of file pubkey.cpp.

209 :
210 m_op(std::move(other.m_op))
211 {}

◆ PK_Key_Agreement() [3/3]

Botan::PK_Key_Agreement::PK_Key_Agreement ( const PK_Key_Agreement )
delete

Member Function Documentation

◆ agreed_value_size()

size_t Botan::PK_Key_Agreement::agreed_value_size ( ) const

Return the underlying size of the value that is agreed. If derive_key is called with a length of 0 with a "Raw" KDF, it will return a value of this size.

Definition at line 213 of file pubkey.cpp.

214 {
215 return m_op->agreed_value_size();
216 }

Referenced by botan_pk_op_key_agreement_size().

◆ derive_key() [1/4]

SymmetricKey Botan::PK_Key_Agreement::derive_key ( size_t  key_len,
const std::vector< uint8_t > &  in,
const std::string &  params = "" 
) const
inline

Perform Key Agreement Operation

Parameters
key_lenthe desired key output size
inthe other parties key
paramsextra derivation params

Definition at line 505 of file pubkey.h.

508 {
509 return derive_key(key_len, in.data(), in.size(),
510 cast_char_ptr_to_uint8(params.data()),
511 params.length());
512 }
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:218
const uint8_t * cast_char_ptr_to_uint8(const char *s)
Definition mem_ops.h:190

References Botan::cast_char_ptr_to_uint8().

◆ derive_key() [2/4]

SymmetricKey Botan::PK_Key_Agreement::derive_key ( size_t  key_len,
const std::vector< uint8_t > &  in,
const uint8_t  params[],
size_t  params_len 
) const
inline

Perform Key Agreement Operation

Parameters
key_lenthe desired key output size
inthe other parties key
paramsextra derivation params
params_lenthe length of params in bytes

Definition at line 474 of file pubkey.h.

478 {
479 return derive_key(key_len, in.data(), in.size(),
480 params, params_len);
481 }

◆ derive_key() [3/4]

SymmetricKey Botan::PK_Key_Agreement::derive_key ( size_t  key_len,
const uint8_t  in[],
size_t  in_len,
const std::string &  params = "" 
) const
inline

Perform Key Agreement Operation

Parameters
key_lenthe desired key output size
inthe other parties key
in_lenthe length of in in bytes
paramsextra derivation params

Definition at line 490 of file pubkey.h.

493 {
494 return derive_key(key_len, in, in_len,
495 cast_char_ptr_to_uint8(params.data()),
496 params.length());
497 }

References Botan::cast_char_ptr_to_uint8().

◆ derive_key() [4/4]

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

Perform Key Agreement Operation

Parameters
key_lenthe desired key output size
inthe other parties key
in_lenthe length of in in bytes
paramsextra derivation params
params_lenthe length of params in bytes

Definition at line 218 of file pubkey.cpp.

222 {
223 return m_op->agree(key_len, in, in_len, salt, salt_len);
224 }
size_t salt_len
Definition x509_obj.cpp:25

References salt_len.

Referenced by botan_pk_op_key_agreement(), Botan::TLS::Client_Key_Exchange::Client_Key_Exchange(), Botan::ECIES_KA_Operation::derive_secret(), Botan::TLS::Callbacks::tls_dh_agree(), and Botan::TLS::Callbacks::tls_ecdh_agree().

◆ operator=() [1/2]

PK_Key_Agreement & Botan::PK_Key_Agreement::operator= ( const PK_Key_Agreement )
delete

◆ operator=() [2/2]

PK_Key_Agreement & Botan::PK_Key_Agreement::operator= ( PK_Key_Agreement &&  other)

Definition at line 200 of file pubkey.cpp.

201 {
202 if(this != &other)
203 {
204 m_op = std::move(other.m_op);
205 }
206 return (*this);
207 }

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