Botan 3.1.1
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::span< const uint8_t > in, std::string_view 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
 
SymmetricKey derive_key (size_t key_len, const uint8_t in[], size_t in_len, std::string_view params="") const
 
SymmetricKey derive_key (size_t key_len, std::span< const uint8_t > in, const uint8_t params[], size_t params_len) const
 
PK_Key_Agreementoperator= (const PK_Key_Agreement &)=delete
 
PK_Key_Agreementoperator= (PK_Key_Agreement &&)=delete
 
 PK_Key_Agreement (const PK_Key_Agreement &)=delete
 
 PK_Key_Agreement (const Private_Key &key, RandomNumberGenerator &rng, std::string_view kdf, std::string_view provider="")
 
 PK_Key_Agreement (PK_Key_Agreement &&) noexcept
 
 ~PK_Key_Agreement ()
 

Detailed Description

Object used for key agreement

Definition at line 392 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,
std::string_view  kdf,
std::string_view  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 181 of file pubkey.cpp.

184 {
185 m_op = key.create_key_agreement_op(rng, kdf, provider);
186 if(!m_op) {
187 throw Invalid_Argument(fmt("Key type {} does not support key agreement", key.algo_name()));
188 }
189}
std::string fmt(std::string_view format, const T &... args)
Definition: fmt.h:53

References Botan::fmt().

◆ ~PK_Key_Agreement()

Botan::PK_Key_Agreement::~PK_Key_Agreement ( )
default

◆ PK_Key_Agreement() [2/3]

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

◆ PK_Key_Agreement() [3/3]

Botan::PK_Key_Agreement::PK_Key_Agreement ( PK_Key_Agreement &&  )
defaultnoexcept

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

193 {
194 return m_op->agreed_value_size();
195}

◆ derive_key() [1/4]

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

Perform Key Agreement Operation

Parameters
key_lenthe desired key output size (ignored if "Raw" KDF is used)
inthe other parties key
paramsextra derivation params

Definition at line 457 of file pubkey.h.

457 {
458 return derive_key(key_len, in.data(), in.size(), cast_char_ptr_to_uint8(params.data()), params.length());
459 }
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:197
const uint8_t * cast_char_ptr_to_uint8(const char *s)
Definition: mem_ops.h:177

References Botan::cast_char_ptr_to_uint8().

◆ derive_key() [2/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 (ignored if "Raw" KDF is used)
inthe other parties key
in_lenthe length of in in bytes
paramsextra derivation params
params_lenthe length of params in bytes

Definition at line 197 of file pubkey.cpp.

198 {
199 return SymmetricKey(m_op->agree(key_len, in, in_len, salt, salt_len));
200}
OctetString SymmetricKey
Definition: symkey.h:141

Referenced by Botan::ECIES_KA_Operation::derive_secret(), and Botan::TLS::Callbacks::tls_ephemeral_key_agreement().

◆ derive_key() [3/4]

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

Perform Key Agreement Operation

Parameters
key_lenthe desired key output size (ignored if "Raw" KDF is used)
inthe other parties key
in_lenthe length of in in bytes
paramsextra derivation params

Definition at line 447 of file pubkey.h.

447 {
448 return derive_key(key_len, in, in_len, cast_char_ptr_to_uint8(params.data()), params.length());
449 }

References Botan::cast_char_ptr_to_uint8().

◆ derive_key() [4/4]

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

Perform Key Agreement Operation

Parameters
key_lenthe desired key output size (ignored if "Raw" KDF is used)
inthe other parties key
paramsextra derivation params
params_lenthe length of params in bytes

Definition at line 433 of file pubkey.h.

436 {
437 return derive_key(key_len, in.data(), in.size(), params, params_len);
438 }

◆ 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 &&  )
delete

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