Botan 3.14.1
Crypto and TLS for C&
Botan::HPKE::Sender_Context Class Referencefinal

#include <hpke.h>

Public Member Functions

const std::vector< uint8_t > & encapsulated_key () const
 The KEM encapsulation ("enc") to be transmitted to the recipient.
secure_vector< uint8_t > export_secret (std::span< const uint8_t > exporter_context, size_t length) const
Mode mode () const
uint64_t next_sequence () const
 The sequence number the next call to seal() will use.
Sender_Context & operator= (const Sender_Context &)=delete
Sender_Context & operator= (Sender_Context &&) noexcept
std::vector< uint8_t > seal (std::span< const uint8_t > aad, std::span< const uint8_t > ptext)
 Sender_Context (const Sender_Context &)=delete
 Sender_Context (Sender_Context &&) noexcept
Suite suite () const
 ~Sender_Context ()

Static Public Member Functions

static Sender_Context setup_auth (const Suite &suite, const Public_Key &recipient_key, const Private_Key &sender_identity_key, RandomNumberGenerator &rng, std::span< const uint8_t > info={})
static Sender_Context setup_auth_psk (const Suite &suite, const Public_Key &recipient_key, const Private_Key &sender_identity_key, RandomNumberGenerator &rng, const PSK &psk, std::span< const uint8_t > info={})
static Sender_Context setup_base (const Suite &suite, const Public_Key &recipient_key, RandomNumberGenerator &rng, std::span< const uint8_t > info={})
static Sender_Context setup_psk (const Suite &suite, const Public_Key &recipient_key, RandomNumberGenerator &rng, const PSK &psk, std::span< const uint8_t > info={})

Detailed Description

HPKE sender (encryption) context

Created by one of the setup_* factories, each corresponding to an RFC 9180 setup function (SetupBaseS, SetupPSKS, SetupAuthS, SetupAuthPSKS).

All factories throw Invalid_Argument if the recipient (or sender identity) key does not match the suite's KEM, if the recipient key is a low order X25519/X448 point, or for an auth mode if the KEM does not support sender authentication. They throw Not_Implemented or Lookup_Error if the suite is not available in this build.

Definition at line 465 of file hpke.h.

Constructor & Destructor Documentation

◆ Sender_Context() [1/2]

Botan::HPKE::Sender_Context::Sender_Context ( const Sender_Context & )
delete

◆ Sender_Context() [2/2]

Botan::HPKE::Sender_Context::Sender_Context ( Sender_Context && )
defaultnoexcept

References Sender_Context().

◆ ~Sender_Context()

Botan::HPKE::Sender_Context::~Sender_Context ( )
default

Member Function Documentation

◆ encapsulated_key()

const std::vector< uint8_t > & Botan::HPKE::Sender_Context::encapsulated_key ( ) const

The KEM encapsulation ("enc") to be transmitted to the recipient.

Definition at line 548 of file hpke.cpp.

548 {
549 return m_data->enc();
550}

References encapsulated_key().

Referenced by encapsulated_key(), and ~Sender_Context().

◆ export_secret()

secure_vector< uint8_t > Botan::HPKE::Sender_Context::export_secret ( std::span< const uint8_t > exporter_context,
size_t length ) const

Secret export (RFC 9180 Section 5.3)

length must be at most 255 times the KDF output length

Definition at line 557 of file hpke.cpp.

557 {
558 // See RFC 9180 Section 5.3
559 return m_data->export_secret(exporter_context, length);
560}

References export_secret().

Referenced by export_secret(), and ~Sender_Context().

◆ mode()

Mode Botan::HPKE::Sender_Context::mode ( ) const

Definition at line 566 of file hpke.cpp.

566 {
567 return m_data->mode();
568}

References mode().

Referenced by mode(), and ~Sender_Context().

◆ next_sequence()

uint64_t Botan::HPKE::Sender_Context::next_sequence ( ) const

The sequence number the next call to seal() will use.

Definition at line 562 of file hpke.cpp.

562 {
563 return m_data->seq();
564}

References next_sequence().

Referenced by next_sequence(), and ~Sender_Context().

◆ operator=() [1/2]

Sender_Context & Botan::HPKE::Sender_Context::operator= ( const Sender_Context & )
delete

References Sender_Context().

◆ operator=() [2/2]

Sender_Context & Botan::HPKE::Sender_Context::operator= ( Sender_Context && )
defaultnoexcept

References Sender_Context().

◆ seal()

std::vector< uint8_t > Botan::HPKE::Sender_Context::seal ( std::span< const uint8_t > aad,
std::span< const uint8_t > ptext )

Encrypt a message to the recipient, using the next sequence number

Throws Invalid_State for an export-only suite, or if the message limit has been reached.

Definition at line 552 of file hpke.cpp.

552 {
553 // See RFC 9180 Section 5.2
554 return m_data->crypt<std::vector<uint8_t>>(std::nullopt, aad, ptext);
555}

References seal().

Referenced by seal(), and ~Sender_Context().

◆ setup_auth()

Sender_Context Botan::HPKE::Sender_Context::setup_auth ( const Suite & suite,
const Public_Key & recipient_key,
const Private_Key & sender_identity_key,
RandomNumberGenerator & rng,
std::span< const uint8_t > info = {} )
static

Definition at line 529 of file hpke.cpp.

533 {
534 // See RFC 9180 Section 5.1.3
535 return setup(Mode::Auth, suite, recipient_key, &sender_identity_key, nullptr, rng, info);
536}

References Botan::HPKE::Auth, Sender_Context(), setup_auth(), and suite().

Referenced by setup_auth().

◆ setup_auth_psk()

Sender_Context Botan::HPKE::Sender_Context::setup_auth_psk ( const Suite & suite,
const Public_Key & recipient_key,
const Private_Key & sender_identity_key,
RandomNumberGenerator & rng,
const PSK & psk,
std::span< const uint8_t > info = {} )
static

Definition at line 538 of file hpke.cpp.

543 {
544 // See RFC 9180 Section 5.1.4
545 return setup(Mode::AuthPSK, suite, recipient_key, &sender_identity_key, &psk, rng, info);
546}

References Botan::HPKE::AuthPSK, Sender_Context(), setup_auth_psk(), and suite().

Referenced by setup_auth_psk().

◆ setup_base()

Sender_Context Botan::HPKE::Sender_Context::setup_base ( const Suite & suite,
const Public_Key & recipient_key,
RandomNumberGenerator & rng,
std::span< const uint8_t > info = {} )
static

Definition at line 512 of file hpke.cpp.

515 {
516 // See RFC 9180 Section 5.1.1
517 return setup(Mode::Base, suite, recipient_key, nullptr, nullptr, rng, info);
518}

References Botan::HPKE::Base, Sender_Context(), setup_base(), and suite().

Referenced by setup_base().

◆ setup_psk()

Sender_Context Botan::HPKE::Sender_Context::setup_psk ( const Suite & suite,
const Public_Key & recipient_key,
RandomNumberGenerator & rng,
const PSK & psk,
std::span< const uint8_t > info = {} )
static

Definition at line 520 of file hpke.cpp.

524 {
525 // See RFC 9180 Section 5.1.2
526 return setup(Mode::PSK, suite, recipient_key, nullptr, &psk, rng, info);
527}

References Botan::HPKE::PSK, Sender_Context(), setup_psk(), and suite().

Referenced by setup_psk().

◆ suite()

Suite Botan::HPKE::Sender_Context::suite ( ) const

Definition at line 570 of file hpke.cpp.

570 {
571 return m_data->suite();
572}

References suite().

Referenced by setup_auth(), setup_auth_psk(), setup_base(), setup_psk(), suite(), and ~Sender_Context().


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