Botan  2.4.0
Crypto and TLS for C++11
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 std::string &group_id, const std::string &hash_id, RandomNumberGenerator &rng)
 
SymmetricKey step2 (const BigInt &A)
 

Detailed Description

Represents a SRP-6a server session

Definition at line 66 of file srp6.h.

Member Function Documentation

◆ step1()

BigInt Botan::SRP6_Server_Session::step1 ( const BigInt v,
const std::string &  group_id,
const std::string &  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 123 of file srp6.cpp.

References Botan::BigInt::bytes(), Botan::DL_Group::get_g(), Botan::DL_Group::get_p(), and Botan::power_mod().

127  {
128  DL_Group group(group_id);
129  const BigInt& g = group.get_g();
130  const BigInt& p = group.get_p();
131 
132  m_p_bytes = p.bytes();
133  m_v = v;
134  m_b = BigInt(rng, 256);
135  m_p = p;
136  m_hash_id = hash_id;
137 
138  const BigInt k = hash_seq(hash_id, m_p_bytes, p, g);
139 
140  m_B = (v*k + power_mod(g, m_b, p)) % p;
141 
142  return m_B;
143  }
BigInt power_mod(const BigInt &base, const BigInt &exp, const BigInt &mod)
Definition: numthry.cpp:374

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

References Botan::BigInt::encode_1363(), and Botan::power_mod().

Referenced by Botan::TLS::Client_Key_Exchange::Client_Key_Exchange().

146  {
147  if(A <= 0 || A >= m_p)
148  throw Exception("Invalid SRP parameter from client");
149 
150  const BigInt u = hash_seq(m_hash_id, m_p_bytes, A, m_B);
151 
152  const BigInt S = power_mod(A * power_mod(m_v, u, m_p), m_b, m_p);
153 
154  return BigInt::encode_1363(S, m_p_bytes);
155  }
BigInt power_mod(const BigInt &base, const BigInt &exp, const BigInt &mod)
Definition: numthry.cpp:374
static secure_vector< uint8_t > encode_1363(const BigInt &n, size_t bytes)
Definition: big_code.cpp:82

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