8 #include <botan/srp6.h>     9 #include <botan/dl_group.h>    10 #include <botan/libstate.h>    11 #include <botan/numthry.h>    18 BigInt hash_seq(
const std::string& hash_id,
    23    std::auto_ptr<HashFunction> hash_fn(
    24       global_state().algorithm_factory().make_hash_function(hash_id));
    32 BigInt hash_seq(
const std::string& hash_id,
    38    std::auto_ptr<HashFunction> hash_fn(
    39       global_state().algorithm_factory().make_hash_function(hash_id));
    48 BigInt compute_x(
const std::string& hash_id,
    49                  const std::string& identifier,
    50                  const std::string& password,
    51                  const MemoryRegion<byte>& salt)
    53    std::auto_ptr<HashFunction> hash_fn(
    54       global_state().algorithm_factory().make_hash_function(hash_id));
    56    hash_fn->update(identifier);
    58    hash_fn->update(password);
    60    SecureVector<byte> inner_h = hash_fn->final();
    62    hash_fn->update(salt);
    63    hash_fn->update(inner_h);
    65    SecureVector<byte> outer_h = hash_fn->final();
    80       const std::string group_name = 
"modp/srp/" + 
to_string(N.
bits());
    84       if(group.get_p() == N && group.get_g() == g)
    87       throw std::runtime_error(
"Unknown SRP params");
    95 std::pair<BigInt, SymmetricKey>
    97                   const std::string& password,
    98                   const std::string& group_id,
    99                   const std::string& hash_id,
   111       throw std::runtime_error(
"Invalid SRP parameter from server");
   113    BigInt k = hash_seq(hash_id, p_bytes, p, g);
   119    BigInt u = hash_seq(hash_id, p_bytes, A, B);
   121    const BigInt x = compute_x(hash_id, identifier, password, salt);
   127    return std::make_pair(A, Sk);
   131                               const std::string& password,
   133                               const std::string& group_id,
   134                               const std::string& hash_id)
   136    const BigInt x = compute_x(hash_id, identifier, password, salt);
   143                                   const std::string& group_id,
   144                                   const std::string& hash_id,
   153    BigInt k = hash_seq(hash_id, p_bytes, p, g);
   162    this->hash_id = hash_id;
   170       throw std::runtime_error(
"Invalid SRP parameter from client");
   172    BigInt u = hash_seq(hash_id, p_bytes, A, B);
 
BigInt generate_srp6_verifier(const std::string &identifier, const std::string &password, const MemoryRegion< byte > &salt, const std::string &group_id, const std::string &hash_id)
BigInt step1(const BigInt &v, const std::string &group_id, const std::string &hash_id, RandomNumberGenerator &rng)
const BigInt & get_g() const
std::invalid_argument Invalid_Argument
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 MemoryRegion< byte > &salt, const BigInt &B, RandomNumberGenerator &rng)
SymmetricKey step2(const BigInt &A)
const BigInt & get_p() const
Library_State & global_state()
BigInt power_mod(const BigInt &base, const BigInt &exp, const BigInt &mod)
static BigInt decode(const byte buf[], size_t length, Base base=Binary)
std::string to_string(u64bit n, size_t min_len)
static SecureVector< byte > encode_1363(const BigInt &n, size_t bytes)
std::string srp6_group_identifier(const BigInt &N, const BigInt &g)