Botan 3.14.1
Crypto and TLS for C&
Botan::PK_Key_Agreement_Options Class Referencefinal

#include <pk_options.h>

Public Member Functions

PK_Key_Agreement_Options & operator= (const PK_Key_Agreement_Options &other)=default
PK_Key_Agreement_Options & operator= (PK_Key_Agreement_Options &&other)=default
 PK_Key_Agreement_Options ()=default
 PK_Key_Agreement_Options (const PK_Key_Agreement_Options &)=default
 PK_Key_Agreement_Options (PK_Key_Agreement_Options &&other)=default
std::string to_string () const
PK_Key_Agreement_Options with_kdf (std::string_view kdf)
PK_Key_Agreement_Options with_provider (std::string_view provider)
PK_Key_Agreement_Options with_raw_shared_key ()
 ~PK_Key_Agreement_Options ()

Friends

class PK_Key_Agreement_Options_Reader

Detailed Description

Key agreement options

The normal usage of this is in a builder style, eg

PK_Key_Agreement_Options().with_kdf("HKDF(SHA-256)")

As with PK_Signature_Options, every option that is set must be understood by the scheme in use; constructing the PK_Key_Agreement throws an exception otherwise.

Definition at line 351 of file pk_options.h.

Constructor & Destructor Documentation

◆ PK_Key_Agreement_Options() [1/3]

Botan::PK_Key_Agreement_Options::PK_Key_Agreement_Options ( )
default

◆ PK_Key_Agreement_Options() [2/3]

Botan::PK_Key_Agreement_Options::PK_Key_Agreement_Options ( PK_Key_Agreement_Options && other)
default

◆ PK_Key_Agreement_Options() [3/3]

Botan::PK_Key_Agreement_Options::PK_Key_Agreement_Options ( const PK_Key_Agreement_Options & )
default

◆ ~PK_Key_Agreement_Options()

Botan::PK_Key_Agreement_Options::~PK_Key_Agreement_Options ( )
default

Member Function Documentation

◆ operator=() [1/2]

PK_Key_Agreement_Options & Botan::PK_Key_Agreement_Options::operator= ( const PK_Key_Agreement_Options & other)
default

◆ operator=() [2/2]

PK_Key_Agreement_Options & Botan::PK_Key_Agreement_Options::operator= ( PK_Key_Agreement_Options && other)
default

◆ to_string()

std::string Botan::PK_Key_Agreement_Options::to_string ( ) const

Format this PK_Key_Agreement_Options as a string

This is primarily intended for debugging and error messages; the format is not fixed

Definition at line 547 of file pk_options.cpp.

547 {
548 std::ostringstream out;
549
550 if(m_kdf) {
551 out << "KDF='" << *m_kdf << "' ";
552 }
553 if(m_raw_shared_key) {
554 out << "RawSharedKey ";
555 }
556 if(m_provider) {
557 out << "Provider='" << *m_provider << "' ";
558 }
559
560 return out.str();
561}

Referenced by ~PK_Key_Agreement_Options().

◆ with_kdf()

PK_Key_Agreement_Options Botan::PK_Key_Agreement_Options::with_kdf ( std::string_view kdf)

Specify a KDF used to derive the shared key from the agreed value

The salt and desired length passed to derive_key are inputs to this KDF.

The name must not be empty; this cannot be combined with with_raw_shared_key

Definition at line 481 of file pk_options.cpp.

481 {
482 BOTAN_STATE_CHECK_MSG(!m_kdf.has_value(), "PK_Key_Agreement_Options::with_kdf cannot specify KDF twice");
483 BOTAN_STATE_CHECK_MSG(!m_raw_shared_key,
484 "PK_Key_Agreement_Options::with_kdf cannot be combined with with_raw_shared_key");
485 // Silently accepting an empty name would turn a request for a KDF into the raw agreed value
486 BOTAN_ARG_CHECK(!kdf.empty(), "PK_Key_Agreement_Options::with_kdf requires a KDF name");
487 auto next = (*this);
488 next.m_kdf = kdf;
489 return next;
490}
#define BOTAN_ARG_CHECK(expr, msg)
Definition assert.h:33
#define BOTAN_STATE_CHECK_MSG(expr, msg)
Definition assert.h:59

References BOTAN_ARG_CHECK, BOTAN_STATE_CHECK_MSG, and PK_Key_Agreement_Options().

Referenced by Botan::parse_legacy_ka_options(), and ~PK_Key_Agreement_Options().

◆ with_provider()

PK_Key_Agreement_Options Botan::PK_Key_Agreement_Options::with_provider ( std::string_view provider)

Specify a provider that should be used

This is rarely relevant

Definition at line 501 of file pk_options.cpp.

501 {
502 BOTAN_STATE_CHECK_MSG(provider.empty() || !m_provider.has_value(),
503 "PK_Key_Agreement_Options::with_provider cannot specify provider twice");
504 auto next = (*this);
505 if(!provider.empty()) {
506 next.m_provider = provider;
507 }
508 return next;
509}

References BOTAN_STATE_CHECK_MSG, and PK_Key_Agreement_Options().

Referenced by Botan::Private_Key::create_key_agreement_op(), and ~PK_Key_Agreement_Options().

◆ with_raw_shared_key()

PK_Key_Agreement_Options Botan::PK_Key_Agreement_Options::with_raw_shared_key ( )

Request the raw agreed value as the shared key

The agreed value (for example the x coordinate of an elliptic curve point) is not a uniformly random key, so key agreement requires either a KDF or this explicit request; the default options are rejected.

This cannot be combined with with_kdf

Definition at line 492 of file pk_options.cpp.

492 {
493 BOTAN_STATE_CHECK_MSG(!m_raw_shared_key, "PK_Key_Agreement_Options::with_raw_shared_key cannot be specified twice");
494 BOTAN_STATE_CHECK_MSG(!m_kdf.has_value(),
495 "PK_Key_Agreement_Options::with_raw_shared_key cannot be combined with with_kdf");
496 auto next = (*this);
497 next.m_raw_shared_key = true;
498 return next;
499}

References BOTAN_STATE_CHECK_MSG, and PK_Key_Agreement_Options().

Referenced by Botan::parse_legacy_ka_options(), and ~PK_Key_Agreement_Options().

◆ PK_Key_Agreement_Options_Reader

friend class PK_Key_Agreement_Options_Reader
friend

Definition at line 391 of file pk_options.h.

References PK_Key_Agreement_Options_Reader.

Referenced by PK_Key_Agreement_Options_Reader.


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