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

#include <hpke.h>

Public Member Functions

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
secure_vector< uint8_t > open (std::span< const uint8_t > aad, std::span< const uint8_t > ctext)
secure_vector< uint8_t > open_at_sequence (uint64_t seq, std::span< const uint8_t > aad, std::span< const uint8_t > ctext)
Recipient_Context & operator= (const Recipient_Context &)=delete
Recipient_Context & operator= (Recipient_Context &&) noexcept
 Recipient_Context (const Recipient_Context &)=delete
 Recipient_Context (Recipient_Context &&) noexcept
Suite suite () const
 ~Recipient_Context ()

Static Public Member Functions

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

Detailed Description

HPKE recipient (decryption) context

Created by one of the setup_* factories, each corresponding to an RFC 9180 setup function (SetupBaseR, SetupPSKR, SetupAuthR, SetupAuthPSKR).

The factories throw as described for Sender_Context, and additionally throw Decoding_Error if the encapsulated key is malformed (wrong length or encoding, or not a point on the curve), or Invalid_Argument if it or the sender identity key is a low order X25519/X448 point.

Definition at line 547 of file hpke.h.

Constructor & Destructor Documentation

◆ Recipient_Context() [1/2]

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

◆ Recipient_Context() [2/2]

Botan::HPKE::Recipient_Context::Recipient_Context ( Recipient_Context && )
defaultnoexcept

References Recipient_Context().

◆ ~Recipient_Context()

Botan::HPKE::Recipient_Context::~Recipient_Context ( )
default

Member Function Documentation

◆ export_secret()

secure_vector< uint8_t > Botan::HPKE::Recipient_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 664 of file hpke.cpp.

665 {
666 // See RFC 9180 Section 5.3
667 return m_data->export_secret(exporter_context, length);
668}

Referenced by ~Recipient_Context().

◆ mode()

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

Definition at line 674 of file hpke.cpp.

674 {
675 return m_data->mode();
676}

Referenced by ~Recipient_Context().

◆ next_sequence()

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

The sequence number the next call to open() will use

Definition at line 670 of file hpke.cpp.

670 {
671 return m_data->seq();
672}

Referenced by ~Recipient_Context().

◆ open()

secure_vector< uint8_t > Botan::HPKE::Recipient_Context::open ( std::span< const uint8_t > aad,
std::span< const uint8_t > ctext )

Decrypt a message, using the next sequence number

Throws Invalid_Authentication_Tag for truncated or unauthentic ciphertexts, or Invalid_State for export-only suites or an exhausted sequence counter. The sequence number is consumed only if decryption succeeds.

Definition at line 653 of file hpke.cpp.

653 {
654 // See RFC 9180 Section 5.2
655 return m_data->crypt<secure_vector<uint8_t>>(std::nullopt, aad, ctext);
656}
std::vector< T, secure_allocator< T > > secure_vector
Definition secmem.h:128

Referenced by ~Recipient_Context().

◆ open_at_sequence()

secure_vector< uint8_t > Botan::HPKE::Recipient_Context::open_at_sequence ( uint64_t seq,
std::span< const uint8_t > aad,
std::span< const uint8_t > ctext )

Decrypt the message with the given sequence number

This does not read or modify the sequence counter used by open(), in order to support out-of-order transports.

Definition at line 658 of file hpke.cpp.

660 {
661 return m_data->crypt<secure_vector<uint8_t>>(seq, aad, ctext);
662}

Referenced by ~Recipient_Context().

◆ operator=() [1/2]

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

References Recipient_Context().

◆ operator=() [2/2]

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

References Recipient_Context().

◆ setup_auth()

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

Definition at line 632 of file hpke.cpp.

637 {
638 // See RFC 9180 Section 5.1.3
639 return setup(Mode::Auth, suite, recipient_key, enc, &sender_identity_key, nullptr, rng, info);
640}

References Botan::HPKE::Auth, Recipient_Context(), and suite().

◆ setup_auth_psk()

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

Definition at line 642 of file hpke.cpp.

648 {
649 // See RFC 9180 Section 5.1.4
650 return setup(Mode::AuthPSK, suite, recipient_key, enc, &sender_identity_key, &psk, rng, info);
651}

References Botan::HPKE::AuthPSK, Recipient_Context(), and suite().

◆ setup_base()

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

Definition at line 613 of file hpke.cpp.

617 {
618 // See RFC 9180 Section 5.1.1
619 return setup(Mode::Base, suite, recipient_key, enc, nullptr, nullptr, rng, info);
620}

References Botan::HPKE::Base, Recipient_Context(), and suite().

◆ setup_psk()

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

Definition at line 622 of file hpke.cpp.

627 {
628 // See RFC 9180 Section 5.1.2
629 return setup(Mode::PSK, suite, recipient_key, enc, nullptr, &psk, rng, info);
630}

References Botan::HPKE::PSK, Recipient_Context(), and suite().

◆ suite()

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

Definition at line 678 of file hpke.cpp.

678 {
679 return m_data->suite();
680}

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


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