Botan  2.4.0
Crypto and TLS for C++11
srp6.h
Go to the documentation of this file.
1 /*
2 * SRP-6a (RFC 5054 compatatible)
3 * (C) 2011,2012 Jack Lloyd
4 *
5 * Botan is released under the Simplified BSD License (see license.txt)
6 */
7 
8 #ifndef BOTAN_RFC5054_SRP6_H_
9 #define BOTAN_RFC5054_SRP6_H_
10 
11 #include <botan/bigint.h>
12 #include <botan/symkey.h>
13 #include <string>
14 
15 namespace Botan {
16 
17 class RandomNumberGenerator;
18 
19 /**
20 * SRP6a Client side
21 * @param username the username we are attempting login for
22 * @param password the password we are attempting to use
23 * @param group_id specifies the shared SRP group
24 * @param hash_id specifies a secure hash function
25 * @param salt is the salt value sent by the server
26 * @param B is the server's public value
27 * @param rng is a random number generator
28 *
29 * @return (A,K) the client public key and the shared secret key
30 */
31 std::pair<BigInt,SymmetricKey>
32 BOTAN_PUBLIC_API(2,0) srp6_client_agree(const std::string& username,
33  const std::string& password,
34  const std::string& group_id,
35  const std::string& hash_id,
36  const std::vector<uint8_t>& salt,
37  const BigInt& B,
38  RandomNumberGenerator& rng);
39 
40 /**
41 * Generate a new SRP-6 verifier
42 * @param identifier a username or other client identifier
43 * @param password the secret used to authenticate user
44 * @param salt a randomly chosen value, at least 128 bits long
45 * @param group_id specifies the shared SRP group
46 * @param hash_id specifies a secure hash function
47 */
48 BigInt BOTAN_PUBLIC_API(2,0) generate_srp6_verifier(const std::string& identifier,
49  const std::string& password,
50  const std::vector<uint8_t>& salt,
51  const std::string& group_id,
52  const std::string& hash_id);
53 
54 /**
55 * Return the group id for this SRP param set, or else thrown an
56 * exception
57 * @param N the group modulus
58 * @param g the group generator
59 * @return group identifier
60 */
61 std::string BOTAN_PUBLIC_API(2,0) srp6_group_identifier(const BigInt& N, const BigInt& g);
62 
63 /**
64 * Represents a SRP-6a server session
65 */
66 class BOTAN_PUBLIC_API(2,0) SRP6_Server_Session final
67  {
68  public:
69  /**
70  * Server side step 1
71  * @param v the verification value saved from client registration
72  * @param group_id the SRP group id
73  * @param hash_id the SRP hash in use
74  * @param rng a random number generator
75  * @return SRP-6 B value
76  */
77  BigInt step1(const BigInt& v,
78  const std::string& group_id,
79  const std::string& hash_id,
81 
82  /**
83  * Server side step 2
84  * @param A the client's value
85  * @return shared symmetric key
86  */
87  SymmetricKey step2(const BigInt& A);
88 
89  private:
90  std::string m_hash_id;
91  BigInt m_B, m_b, m_v, m_S, m_p;
92  size_t m_p_bytes = 0;
93  };
94 
95 }
96 
97 #endif
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)
Definition: srp6.cpp:77
#define BOTAN_PUBLIC_API(maj, min)
Definition: compiler.h:27
Definition: bigint.h:635
Definition: alg_id.cpp:13
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)
Definition: srp6.cpp:111
std::string srp6_group_identifier(const BigInt &N, const BigInt &g)
Definition: srp6.cpp:53