Botan 3.11.0
Crypto and TLS for C&
Botan::SRP6_Server_Session Class Referencefinal

#include <srp6.h>

Public Member Functions

BigInt step1 (const BigInt &v, const DL_Group &group, std::string_view hash_id, size_t b_bits, RandomNumberGenerator &rng)
BigInt step1 (const BigInt &v, std::string_view group_id, std::string_view hash_id, RandomNumberGenerator &rng)
SymmetricKey step2 (const BigInt &A)

Detailed Description

Represents a SRP-6a server session

Definition at line 102 of file srp6.h.

Member Function Documentation

◆ step1() [1/2]

BigInt Botan::SRP6_Server_Session::step1 ( const BigInt & v,
const DL_Group & group,
std::string_view hash_id,
size_t b_bits,
RandomNumberGenerator & rng )

Server side step 1 This version of step1 added in 2.11

Parameters
vthe verification value saved from client registration
groupthe SRP group
hash_idthe SRP hash in use
rnga random number generator
b_bitssize of secret exponent in bits
Returns
SRP-6 B value

Definition at line 161 of file srp6.cpp.

162 {
163 BOTAN_ARG_CHECK(b_bits <= group.p_bits(), "Invalid b_bits");
164
165 BOTAN_STATE_CHECK(!m_group);
166 m_group = std::make_unique<DL_Group>(group);
167
168 const BigInt& g = m_group->get_g();
169 const BigInt& p = m_group->get_p();
170
171 m_v = v;
172 m_b = BigInt(rng, b_bits);
173 m_hash_id = hash_id;
174
175 auto hash_fn = HashFunction::create_or_throw(hash_id);
176 if(8 * hash_fn->output_length() >= m_group->p_bits()) {
177 throw Invalid_Argument(fmt("Hash function {} too large for SRP6 with this group", hash_fn->name()));
178 }
179
180 const BigInt k = hash_seq(*hash_fn, m_group->p_bytes(), p, g);
181 m_B = m_group->mod_p(v * k + m_group->power_g_p(m_b, b_bits));
182
183 return m_B;
184}
#define BOTAN_STATE_CHECK(expr)
Definition assert.h:49
#define BOTAN_ARG_CHECK(expr, msg)
Definition assert.h:33
static std::unique_ptr< HashFunction > create_or_throw(std::string_view algo_spec, std::string_view provider="")
Definition hash.cpp:308
std::string fmt(std::string_view format, const T &... args)
Definition fmt.h:53

References BOTAN_ARG_CHECK, BOTAN_STATE_CHECK, Botan::HashFunction::create_or_throw(), Botan::fmt(), and Botan::DL_Group::p_bits().

◆ step1() [2/2]

BigInt Botan::SRP6_Server_Session::step1 ( const BigInt & v,
std::string_view group_id,
std::string_view hash_id,
RandomNumberGenerator & rng )

Server side step 1

Parameters
vthe verification value saved from client registration
group_idthe SRP group id
hash_idthe SRP hash in use
rnga random number generator
Returns
SRP-6 B value

Definition at line 152 of file srp6.cpp.

155 {
156 auto group = DL_Group::from_name(group_id);
157 const size_t b_bits = group.exponent_bits();
158 return this->step1(v, group, hash_id, b_bits, rng);
159}
static DL_Group from_name(std::string_view name)
Definition dl_group.cpp:217
BigInt step1(const BigInt &v, std::string_view group_id, std::string_view hash_id, RandomNumberGenerator &rng)
Definition srp6.cpp:152

References Botan::DL_Group::from_name(), and step1().

Referenced by step1().

◆ step2()

SymmetricKey Botan::SRP6_Server_Session::step2 ( const BigInt & A)

Server side step 2

Parameters
Athe client's value
Returns
shared symmetric key

Definition at line 186 of file srp6.cpp.

186 {
187 BOTAN_STATE_CHECK(m_group);
188
189 if(A <= 0 || A >= m_group->get_p()) {
190 throw Decoding_Error("Invalid SRP parameter from client");
191 }
192
193 auto hash_fn = HashFunction::create_or_throw(m_hash_id);
194 if(8 * hash_fn->output_length() >= m_group->p_bits()) {
195 throw Invalid_Argument(fmt("Hash function {} too large for SRP6 with this group", hash_fn->name()));
196 }
197
198 const BigInt u = hash_seq(*hash_fn, m_group->p_bytes(), A, m_B);
199
200 const BigInt vup = m_group->power_b_p(m_v, u, m_group->p_bits());
201 const BigInt S = m_group->power_b_p(m_group->multiply_mod_p(A, vup), m_b, m_group->p_bits());
202
203 return SymmetricKey(S.serialize<secure_vector<uint8_t>>(m_group->p_bytes()));
204}
OctetString SymmetricKey
Definition symkey.h:140
std::vector< T, secure_allocator< T > > secure_vector
Definition secmem.h:68

References BOTAN_STATE_CHECK, Botan::HashFunction::create_or_throw(), Botan::fmt(), and Botan::BigInt::serialize().


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