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