8 #include <botan/srp6.h>
9 #include <botan/dl_group.h>
10 #include <botan/numthry.h>
16 BigInt hash_seq(
const std::string& hash_id,
29 BigInt compute_x(
const std::string& hash_id,
30 const std::string& identifier,
31 const std::string& password,
32 const std::vector<uint8_t>& salt)
36 hash_fn->update(identifier);
38 hash_fn->update(password);
40 secure_vector<uint8_t> inner_h = hash_fn->final();
42 hash_fn->update(salt);
43 hash_fn->update(inner_h);
45 secure_vector<uint8_t> outer_h = hash_fn->final();
64 if(group.get_p() == N && group.get_g() == g)
75 std::pair<BigInt, SymmetricKey>
77 const std::string& password,
78 const std::string& group_id,
79 const std::string& hash_id,
80 const std::vector<uint8_t>& salt,
91 throw Exception(
"Invalid SRP parameter from server");
93 BigInt k = hash_seq(hash_id, p_bytes, p, g);
99 BigInt u = hash_seq(hash_id, p_bytes, A, B);
101 const BigInt x = compute_x(hash_id, identifier, password, salt);
107 return std::make_pair(A, Sk);
111 const std::string& password,
112 const std::vector<uint8_t>& salt,
113 const std::string& group_id,
114 const std::string& hash_id)
116 const BigInt x = compute_x(hash_id, identifier, password, salt);
123 const std::string& group_id,
124 const std::string& hash_id,
131 m_p_bytes = p.
bytes();
137 const BigInt k = hash_seq(hash_id, m_p_bytes, p, g);
146 if(A <= 0 || A >= m_p)
147 throw Exception(
"Invalid SRP parameter from client");
149 const BigInt u = hash_seq(m_hash_id, m_p_bytes, A, m_B);
static std::unique_ptr< HashFunction > create_or_throw(const std::string &algo_spec, const std::string &provider="")
BigInt step1(const BigInt &v, const std::string &group_id, const std::string &hash_id, RandomNumberGenerator &rng)
const BigInt & get_p() const
std::string to_string(const BER_Object &obj)
SymmetricKey step2(const BigInt &A)
const BigInt & get_g() const
std::pair< BigInt, SymmetricKey > srp6_client_agree(const std::string &identifier, const std::string &password, const std::string &group_id, const std::string &hash_id, const std::vector< uint8_t > &salt, const BigInt &B, RandomNumberGenerator &rng)
BigInt power_mod(const BigInt &base, const BigInt &exp, const BigInt &mod)
static secure_vector< uint8_t > encode_1363(const BigInt &n, size_t bytes)
BigInt generate_srp6_verifier(const std::string &identifier, const std::string &password, const std::vector< uint8_t > &salt, const std::string &group_id, const std::string &hash_id)
std::string srp6_group_identifier(const BigInt &N, const BigInt &g)
static BigInt decode(const uint8_t buf[], size_t length, Base base=Binary)