Botan 3.13.0
Crypto and TLS for C&
Botan::SPAKE2p::RegistrationRecord Class Referencefinal

#include <spake2p.h>

Public Member Functions

secure_vector< uint8_t > serialize () const

Static Public Member Functions

static RegistrationRecord deserialize (const SystemParameters &params, std::span< const uint8_t > record)
static RegistrationRecord from_password (const SystemParameters &params, std::string_view password, std::span< const uint8_t > prover_id, std::span< const uint8_t > verifier_id, std::span< const uint8_t > salt, RandomNumberGenerator &rng)

Friends

class ProverSecret
class VerifierContext

Detailed Description

SPAKE2+ Registration Record

This is the information (w0 and L in RFC 9383) which the verifier stores in order to authenticate the prover.

Definition at line 159 of file spake2p.h.

Member Function Documentation

◆ deserialize()

RegistrationRecord Botan::SPAKE2p::RegistrationRecord::deserialize ( const SystemParameters & params,
std::span< const uint8_t > record )
static

Deserialize a RegistrationRecord previously serialized by serialize

Definition at line 261 of file spake2p.cpp.

261 {
262 const size_t scalar_len = params.group().get_order_bytes();
263 const size_t point_len = params.share_size();
264
265 if(record.size() != scalar_len + point_len) {
266 throw Decoding_Error("Invalid length for SPAKE2+ registration record");
267 }
268
269 auto w0 = EC_Scalar::deserialize(params.group(), record.first(scalar_len));
270 auto l = EC_AffinePoint::deserialize_uncompressed(params.group(), record.last(point_len));
271
272 if(!w0 || !l) {
273 throw Decoding_Error("Invalid SPAKE2+ registration record");
274 }
275
276 return RegistrationRecord(std::move(*w0), std::move(*l));
277}
static std::optional< EC_AffinePoint > deserialize_uncompressed(const EC_Group &group, std::span< const uint8_t > bytes)
static std::optional< EC_Scalar > deserialize(const EC_Group &group, std::span< const uint8_t > bytes)

References Botan::EC_Scalar::deserialize(), Botan::EC_AffinePoint::deserialize_uncompressed(), Botan::EC_Group::get_order_bytes(), Botan::SPAKE2p::SystemParameters::group(), and Botan::SPAKE2p::SystemParameters::share_size().

Referenced by botan_spake2p_verifier_init().

◆ from_password()

RegistrationRecord Botan::SPAKE2p::RegistrationRecord::from_password ( const SystemParameters & params,
std::string_view password,
std::span< const uint8_t > prover_id,
std::span< const uint8_t > verifier_id,
std::span< const uint8_t > salt,
RandomNumberGenerator & rng )
static

Perform password registration, returning the registration record

This derives the record from the password using Argon2id; see ProverSecret::from_password for the details. The same password, identities, and salt must later be used to create the prover's secret.

The identities and salt may be empty.

Definition at line 252 of file spake2p.cpp.

257 {
258 return ProverSecret::from_password(params, password, prover_id, verifier_id, salt).registration_record(rng);
259}
static ProverSecret from_password(const SystemParameters &params, std::string_view password, std::span< const uint8_t > prover_id, std::span< const uint8_t > verifier_id, std::span< const uint8_t > salt)
Definition spake2p.cpp:283
RegistrationRecord registration_record(RandomNumberGenerator &rng) const
Definition spake2p.cpp:308

References Botan::SPAKE2p::ProverSecret::from_password(), and Botan::SPAKE2p::ProverSecret::registration_record().

◆ serialize()

secure_vector< uint8_t > Botan::SPAKE2p::RegistrationRecord::serialize ( ) const

Serialize the registration record

Warning
the return value is the unencrypted registration record, which is a sensitive value allowing password guessing attacks. Encrypt it for persistent storage if possible.

Definition at line 279 of file spake2p.cpp.

279 {
280 return concat<secure_vector<uint8_t>>(m_w0.serialize(), m_l.serialize_uncompressed());
281}
constexpr auto concat(Rs &&... ranges)
Definition concat_util.h:90

References Botan::concat().

◆ ProverSecret

friend class ProverSecret
friend

Definition at line 192 of file spake2p.h.

References ProverSecret.

Referenced by ProverSecret.

◆ VerifierContext

friend class VerifierContext
friend

Definition at line 193 of file spake2p.h.

References VerifierContext.

Referenced by VerifierContext.


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