Botan 3.14.1
Crypto and TLS for C&
Botan::PK_Ops::Key_Agreement_with_KDF Class Referenceabstract

#include <pk_ops_impl.h>

Inheritance diagram for Botan::PK_Ops::Key_Agreement_with_KDF:
Botan::PK_Ops::Key_Agreement

Public Member Functions

secure_vector< uint8_t > agree (size_t key_len, std::span< const uint8_t > other_key, std::span< const uint8_t > salt) override
virtual size_t agreed_value_size () const =0
 ~Key_Agreement_with_KDF () override

Protected Member Functions

 Key_Agreement_with_KDF (const PK_Key_Agreement_Options_Reader &options)

Detailed Description

Definition at line 126 of file pk_ops_impl.h.

Constructor & Destructor Documentation

◆ ~Key_Agreement_with_KDF()

Botan::PK_Ops::Key_Agreement_with_KDF::~Key_Agreement_with_KDF ( )
overridedefault

◆ Key_Agreement_with_KDF()

Botan::PK_Ops::Key_Agreement_with_KDF::Key_Agreement_with_KDF ( const PK_Key_Agreement_Options_Reader & options)
explicitprotected
Parameters
optionsmust specify either a KDF or the raw shared key, since the agreed value is never a uniform key

Definition at line 77 of file pk_ops.cpp.

77 {
78 if(options.using_kdf()) {
79 m_kdf = KDF::create_or_throw(options.kdf().value());
80 } else if(!options.using_raw_shared_key()) {
81 throw Invalid_Argument(
82 "Key agreement does not produce a uniform shared key, so a KDF must be specified (or the raw shared key "
83 "explicitly requested)");
84 }
85}
static std::unique_ptr< KDF > create_or_throw(std::string_view algo_spec, std::string_view provider="")
Definition kdf.cpp:208

References Botan::KDF::create_or_throw(), Botan::PK_Key_Agreement_Options_Reader::kdf(), Botan::PK_Key_Agreement_Options_Reader::using_kdf(), and Botan::PK_Key_Agreement_Options_Reader::using_raw_shared_key().

Referenced by ~Key_Agreement_with_KDF().

Member Function Documentation

◆ agree()

secure_vector< uint8_t > Botan::PK_Ops::Key_Agreement_with_KDF::agree ( size_t key_len,
std::span< const uint8_t > other_key,
std::span< const uint8_t > salt )
overridevirtual

Implements Botan::PK_Ops::Key_Agreement.

Definition at line 89 of file pk_ops.cpp.

91 {
92 if(!salt.empty() && m_kdf == nullptr) {
93 throw Invalid_Argument("PK_Key_Agreement::derive_key requires a KDF to use a salt");
94 }
95
96 secure_vector<uint8_t> z = raw_agree(other_key.data(), other_key.size());
97 if(m_kdf) {
98 return m_kdf->derive_key(key_len, z, salt.data(), salt.size());
99 }
100 return z;
101}
std::vector< T, secure_allocator< T > > secure_vector
Definition secmem.h:128

◆ agreed_value_size()

virtual size_t Botan::PK_Ops::Key_Agreement::agreed_value_size ( ) const
pure virtualinherited

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