Botan 2.13.0 Crypto and TLS for C++11

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

srp6.h
Go to the documentation of this file.
1 /*
2 * SRP-6a (RFC 5054 compatatible)
3 * (C) 2011,2012,2019 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 DL_Group;
18 class RandomNumberGenerator;
19
20 /**
21 * SRP6a Client side
22 * @param username the username we are attempting login for
23 * @param password the password we are attempting to use
24 * @param group_id specifies the shared SRP group
25 * @param hash_id specifies a secure hash function
26 * @param salt is the salt value sent by the server
27 * @param B is the server's public value
28 * @param rng is a random number generator
29 *
30 * @return (A,K) the client public key and the shared secret key
31 */
32 std::pair<BigInt,SymmetricKey>
33 BOTAN_PUBLIC_API(2,0) srp6_client_agree(const std::string& username,
34 const std::string& password,
35 const std::string& group_id,
36 const std::string& hash_id,
37 const std::vector<uint8_t>& salt,
38 const BigInt& B,
39 RandomNumberGenerator& rng);
40
41
42 /**
43 * SRP6a Client side
44 * @param username the username we are attempting login for
45 * @param password the password we are attempting to use
46 * @param group specifies the shared SRP group
47 * @param hash_id specifies a secure hash function
48 * @param salt is the salt value sent by the server
49 * @param B is the server's public value
50 * @param a_bits size of secret exponent in bits
51 * @param rng is a random number generator
52 *
53 * @return (A,K) the client public key and the shared secret key
54 */
55 std::pair<BigInt,SymmetricKey> BOTAN_PUBLIC_API(2,11)
56 srp6_client_agree(const std::string& username,
57 const std::string& password,
58 const DL_Group& group,
59 const std::string& hash_id,
60 const std::vector<uint8_t>& salt,
61 const BigInt& B,
62 size_t a_bits,
63 RandomNumberGenerator& rng);
64
65 /**
66 * Generate a new SRP-6 verifier
67 * @param identifier a username or other client identifier
68 * @param password the secret used to authenticate user
69 * @param salt a randomly chosen value, at least 128 bits long
70 * @param group_id specifies the shared SRP group
71 * @param hash_id specifies a secure hash function
72 */
73 BigInt BOTAN_PUBLIC_API(2,0)
74 generate_srp6_verifier(const std::string& identifier,
75 const std::string& password,
76 const std::vector<uint8_t>& salt,
77 const std::string& group_id,
78 const std::string& hash_id);
79
80 /**
81 * Generate a new SRP-6 verifier
82 * @param identifier a username or other client identifier
83 * @param password the secret used to authenticate user
84 * @param salt a randomly chosen value, at least 128 bits long
85 * @param group specifies the shared SRP group
86 * @param hash_id specifies a secure hash function
87 */
88 BigInt BOTAN_PUBLIC_API(2,11)
89 generate_srp6_verifier(const std::string& identifier,
90 const std::string& password,
91 const std::vector<uint8_t>& salt,
92 const DL_Group& group,
93 const std::string& hash_id);
94
95 /**
96 * Return the group id for this SRP param set, or else thrown an
97 * exception
98 * @param N the group modulus
99 * @param g the group generator
100 * @return group identifier
101 */
102 std::string BOTAN_PUBLIC_API(2,0) srp6_group_identifier(const BigInt& N, const BigInt& g);
103
104 /**
105 * Represents a SRP-6a server session
106 */
107 class BOTAN_PUBLIC_API(2,0) SRP6_Server_Session final
108 {
109 public:
110 /**
111 * Server side step 1
112 * @param v the verification value saved from client registration
113 * @param group_id the SRP group id
114 * @param hash_id the SRP hash in use
115 * @param rng a random number generator
116 * @return SRP-6 B value
117 */
118 BigInt step1(const BigInt& v,
119 const std::string& group_id,
120 const std::string& hash_id,
121 RandomNumberGenerator& rng);
122
123 /**
124 * Server side step 1
125 * This version of step1 added in 2.11
126 *
127 * @param v the verification value saved from client registration
128 * @param group the SRP group
129 * @param hash_id the SRP hash in use
130 * @param rng a random number generator
131 * @param b_bits size of secret exponent in bits
132 * @return SRP-6 B value
133 */
134 BigInt step1(const BigInt& v,
135 const DL_Group& group,
136 const std::string& hash_id,
137 const size_t b_bits,
138 RandomNumberGenerator& rng);
139
140 /**
141 * Server side step 2
142 * @param A the client's value
143 * @return shared symmetric key
144 */
145 SymmetricKey step2(const BigInt& A);
146
147 private:
148 std::string m_hash_id;
149 BigInt m_B, m_b, m_v, m_S, m_p;
150 size_t m_p_bytes = 0;
151 };
152
153 }
154
155 #endif
Botan::OctetString
Definition: symkey.h:19
Botan::RandomNumberGenerator
Definition: rng.h:24
Botan::srp6_client_agree
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
final
int(* final)(unsigned char *, CTX *)
Definition: commoncrypto_hash.cpp:28
BOTAN_PUBLIC_API
#define BOTAN_PUBLIC_API(maj, min)
Definition: compiler.h:31
std
Definition: bigint.h:1135
m_b
BigInt m_b
Definition: dsa.cpp:105
Botan::SRP6_Server_Session
Definition: srp6.h:107
m_hash_id
std::vector< uint8_t > m_hash_id
Definition: tpm.cpp:447
Botan::DL_Group
Definition: dl_group.h:23
Botan
Definition: alg_id.cpp:13
Botan::SymmetricKey
OctetString SymmetricKey
Definition: symkey.h:141
m_p
BigInt m_p
Definition: pow_mod.cpp:108
Botan::generate_srp6_verifier
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:127
Botan::srp6_group_identifier
std::string srp6_group_identifier(const BigInt &N, const BigInt &g)
Definition: srp6.cpp:53