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

#include <spake2p.h>

Public Member Functions

size_t confirmation_size () const
const EC_Groupgroup () const
const std::string & hash_function () const
size_t share_size () const
const EC_AffinePointspake2p_m () const
const EC_AffinePointspake2p_n () const

Static Public Member Functions

static SystemParameters custom (const EC_Group &group, std::span< const uint8_t > seed, std::string_view hash_fn)
static SystemParameters rfc9383_p256_sha256 ()
static SystemParameters rfc9383_p256_sha512 ()
static SystemParameters rfc9383_p384_sha256 ()
static SystemParameters rfc9383_p384_sha512 ()
static SystemParameters rfc9383_p521_sha512 ()

Detailed Description

SPAKE2+ (RFC 9383) System Parameters

This selects the elliptic curve group, the M/N group elements, and the hash function; the hash also fixes the KDF (HKDF) and the MAC (HMAC)

Definition at line 63 of file spake2p.h.

Member Function Documentation

◆ confirmation_size()

size_t Botan::SPAKE2p::SystemParameters::confirmation_size ( ) const

Return the size in bytes of a key confirmation message (confirmP or confirmV)

Definition at line 240 of file spake2p.cpp.

240 {
241 if(m_hash_fn == "SHA-256") {
242 return 32;
243 } else if(m_hash_fn == "SHA-384") {
244 return 48;
245 } else if(m_hash_fn == "SHA-512") {
246 return 64;
247 } else {
248 return HashFunction::create_or_throw(m_hash_fn)->output_length();
249 }
250}
static std::unique_ptr< HashFunction > create_or_throw(std::string_view algo_spec, std::string_view provider="")
Definition hash.cpp:308

References Botan::HashFunction::create_or_throw().

◆ custom()

SystemParameters Botan::SPAKE2p::SystemParameters::custom ( const EC_Group & group,
std::span< const uint8_t > seed,
std::string_view hash_fn )
static

SPAKE2+ custom system parameters for an arbitrary group

The M/N values will be derived from the seed using hash2curve; note that not all groups support hash2curve.

RFC 9383 Section 3.2: "Applications MAY use different M and N values, provided they are computed, e.g., using different input seeds to the algorithm in Appendix B, as random elements for which the discrete log is unknown."

If the seed includes the identities of the participants, this additionally makes the scheme "quantum annoying", in that an attacker with a discrete logarithm oracle must compute a new discrete log for each (user, verifier) pair they wish to attack.

Parameters
groupthe elliptic curve group to use
SEEDthe seed bytes used to derive M and N
hash_fnthe hash function to use (eg "SHA-256")

Definition at line 221 of file spake2p.cpp.

223 {
224 BOTAN_ARG_CHECK(group.has_cofactor() == false, "SPAKE2+ is not supported for groups with a cofactor");
225
226 if(!group.hash_to_curve_supported(hash_fn)) {
227 throw Not_Implemented("SPAKE2+ custom params require hash2curve support which is not available for this curve");
228 }
229
230 auto m = EC_AffinePoint::hash_to_curve_ro(group, hash_fn, seed, "SPAKE2+ M");
231 auto n = EC_AffinePoint::hash_to_curve_ro(group, hash_fn, seed, "SPAKE2+ N");
232
233 return SystemParameters(group, std::move(m), std::move(n), hash_fn);
234}
#define BOTAN_ARG_CHECK(expr, msg)
Definition assert.h:33
static EC_AffinePoint hash_to_curve_ro(const EC_Group &group, std::string_view hash_fn, std::span< const uint8_t > input, std::span< const uint8_t > domain_sep)
const EC_Group & group() const
Definition spake2p.h:115

References BOTAN_ARG_CHECK, group(), and Botan::EC_AffinePoint::hash_to_curve_ro().

Referenced by botan_spake2p_params_init_custom().

◆ group()

const EC_Group & Botan::SPAKE2p::SystemParameters::group ( ) const
inline

◆ hash_function()

const std::string & Botan::SPAKE2p::SystemParameters::hash_function ( ) const
inline

Return the name of the hash function

Definition at line 130 of file spake2p.h.

130{ return m_hash_fn; }

◆ rfc9383_p256_sha256()

SystemParameters Botan::SPAKE2p::SystemParameters::rfc9383_p256_sha256 ( )
static

The RFC 9383 ciphersuite P256-SHA256-HKDF-HMAC-SHA256

Definition at line 196 of file spake2p.cpp.

196 {
197 auto [group, m, n] = spake2p_group_params("secp256r1", SPAKE2P_P256_M, SPAKE2P_P256_N);
198 return SystemParameters(std::move(group), std::move(m), std::move(n), "SHA-256");
199}

References group().

◆ rfc9383_p256_sha512()

SystemParameters Botan::SPAKE2p::SystemParameters::rfc9383_p256_sha512 ( )
static

The RFC 9383 ciphersuite P256-SHA512-HKDF-HMAC-SHA512

Definition at line 201 of file spake2p.cpp.

201 {
202 auto [group, m, n] = spake2p_group_params("secp256r1", SPAKE2P_P256_M, SPAKE2P_P256_N);
203 return SystemParameters(std::move(group), std::move(m), std::move(n), "SHA-512");
204}

References group().

◆ rfc9383_p384_sha256()

SystemParameters Botan::SPAKE2p::SystemParameters::rfc9383_p384_sha256 ( )
static

The RFC 9383 ciphersuite P384-SHA256-HKDF-HMAC-SHA256

Definition at line 206 of file spake2p.cpp.

206 {
207 auto [group, m, n] = spake2p_group_params("secp384r1", SPAKE2P_P384_M, SPAKE2P_P384_N);
208 return SystemParameters(std::move(group), std::move(m), std::move(n), "SHA-256");
209}

References group().

◆ rfc9383_p384_sha512()

SystemParameters Botan::SPAKE2p::SystemParameters::rfc9383_p384_sha512 ( )
static

The RFC 9383 ciphersuite P384-SHA512-HKDF-HMAC-SHA512

Definition at line 211 of file spake2p.cpp.

211 {
212 auto [group, m, n] = spake2p_group_params("secp384r1", SPAKE2P_P384_M, SPAKE2P_P384_N);
213 return SystemParameters(std::move(group), std::move(m), std::move(n), "SHA-512");
214}

References group().

◆ rfc9383_p521_sha512()

SystemParameters Botan::SPAKE2p::SystemParameters::rfc9383_p521_sha512 ( )
static

The RFC 9383 ciphersuite P521-SHA512-HKDF-HMAC-SHA512

Definition at line 216 of file spake2p.cpp.

216 {
217 auto [group, m, n] = spake2p_group_params("secp521r1", SPAKE2P_P521_M, SPAKE2P_P521_N);
218 return SystemParameters(std::move(group), std::move(m), std::move(n), "SHA-512");
219}

References group().

◆ share_size()

size_t Botan::SPAKE2p::SystemParameters::share_size ( ) const

Return the size in bytes of a key share (shareP or shareV)

Definition at line 236 of file spake2p.cpp.

236 {
237 return 1 + 2 * m_group.get_p_bytes();
238}

Referenced by Botan::SPAKE2p::RegistrationRecord::deserialize().

◆ spake2p_m()

const EC_AffinePoint & Botan::SPAKE2p::SystemParameters::spake2p_m ( ) const
inline

Return the SPAKE2+ M group element

Definition at line 120 of file spake2p.h.

120{ return m_spake2p_m; }

◆ spake2p_n()

const EC_AffinePoint & Botan::SPAKE2p::SystemParameters::spake2p_n ( ) const
inline

Return the SPAKE2+ N group element

Definition at line 125 of file spake2p.h.

125{ return m_spake2p_n; }

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