Botan 3.0.0
Crypto and TLS for C&
Public Member Functions | List of all members
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, const 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 107 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,
const 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 176 of file srp6.cpp.

181 {
182 BOTAN_ARG_CHECK(b_bits <= group.p_bits(), "Invalid b_bits");
183
184 m_group = group;
185
186 const BigInt& g = group.get_g();
187 const BigInt& p = group.get_p();
188
189 m_v = v;
190 m_b = BigInt(rng, b_bits);
191 m_hash_id = hash_id;
192
193 auto hash_fn = HashFunction::create_or_throw(hash_id);
194 if(8*hash_fn->output_length() >= group.p_bits())
195 throw Invalid_Argument(fmt("Hash function {} too large for SRP6 with this group",
196 hash_fn->name()));
197
198 const BigInt k = hash_seq(*hash_fn, m_group.p_bytes(), p, g);
199 m_B = group.mod_p(v*k + group.power_g_p(m_b, b_bits));
200
201 return m_B;
202 }
#define BOTAN_ARG_CHECK(expr, msg)
Definition: assert.h:36
size_t p_bytes() const
Definition: dl_group.cpp:516
const BigInt & get_g() const
Definition: dl_group.cpp:488
static std::unique_ptr< HashFunction > create_or_throw(std::string_view algo_spec, std::string_view provider="")
Definition: hash.cpp:320
std::string fmt(std::string_view format, const T &... args)
Definition: fmt.h:60

References BOTAN_ARG_CHECK, Botan::HashFunction::create_or_throw(), Botan::fmt(), Botan::DL_Group::get_g(), Botan::DL_Group::get_p(), Botan::DL_Group::mod_p(), Botan::DL_Group::p_bits(), Botan::DL_Group::p_bytes(), and Botan::DL_Group::power_g_p().

◆ 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 166 of file srp6.cpp.

170 {
171 DL_Group group(group_id);
172 const size_t b_bits = group.exponent_bits();
173 return this->step1(v, group, hash_id, b_bits, rng);
174 }
BigInt step1(const BigInt &v, std::string_view group_id, std::string_view hash_id, RandomNumberGenerator &rng)
Definition: srp6.cpp:166

References Botan::DL_Group::exponent_bits(), 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 204 of file srp6.cpp.

205 {
206 if(A <= 0 || A >= m_group.get_p())
207 throw Decoding_Error("Invalid SRP parameter from client");
208
209 auto hash_fn = HashFunction::create_or_throw(m_hash_id);
210 if(8*hash_fn->output_length() >= m_group.p_bits())
211 throw Invalid_Argument(fmt("Hash function {} too large for SRP6 with this group",
212 hash_fn->name()));
213
214 const BigInt u = hash_seq(*hash_fn, m_group.p_bytes(), A, m_B);
215
216 const BigInt vup = m_group.power_b_p(m_v, u, m_group.p_bits());
217 const BigInt S = m_group.power_b_p(m_group.multiply_mod_p(A, vup), m_b, m_group.p_bits());
218
219 return SymmetricKey(BigInt::encode_1363(S, m_group.p_bytes()));
220 }
static secure_vector< uint8_t > encode_1363(const BigInt &n, size_t bytes)
Definition: big_code.cpp:107
BigInt multiply_mod_p(const BigInt &x, const BigInt &y) const
Definition: dl_group.cpp:554
size_t p_bits() const
Definition: dl_group.cpp:511
const BigInt & get_p() const
Definition: dl_group.cpp:480
BigInt power_b_p(const BigInt &b, const BigInt &x, size_t max_x_bits) const
Definition: dl_group.cpp:610
OctetString SymmetricKey
Definition: symkey.h:145

References Botan::HashFunction::create_or_throw(), Botan::BigInt::encode_1363(), Botan::fmt(), Botan::DL_Group::get_p(), Botan::DL_Group::multiply_mod_p(), Botan::DL_Group::p_bits(), Botan::DL_Group::p_bytes(), and Botan::DL_Group::power_b_p().


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