Botan 3.0.0
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/symkey.h>
13#include <botan/dl_group.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>
33BOTAN_PUBLIC_API(2,0) srp6_client_agree(std::string_view username,
34 std::string_view password,
35 std::string_view group_id,
36 std::string_view 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*/
55std::pair<BigInt,SymmetricKey> BOTAN_PUBLIC_API(2,11)
56 srp6_client_agree(std::string_view username,
57 std::string_view password,
58 const DL_Group& group,
59 std::string_view 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*/
73BigInt BOTAN_PUBLIC_API(2,0)
74 srp6_generate_verifier(std::string_view identifier,
75 std::string_view password,
76 const std::vector<uint8_t>& salt,
77 std::string_view group_id,
78 std::string_view 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*/
88BigInt BOTAN_PUBLIC_API(2,11)
89 srp6_generate_verifier(std::string_view identifier,
90 std::string_view password,
91 const std::vector<uint8_t>& salt,
92 const DL_Group& group,
93 std::string_view 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*/
102std::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*/
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 std::string_view group_id,
120 std::string_view hash_id,
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 std::string_view hash_id,
137 const size_t b_bits,
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 DL_Group m_group;
149 std::string m_hash_id;
150 BigInt m_B, m_b, m_v, m_S;
151 };
152
153}
154
155#endif
int(* final)(unsigned char *, CTX *)
#define BOTAN_PUBLIC_API(maj, min)
Definition: compiler.h:31
Definition: alg_id.cpp:12
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:74
OctetString SymmetricKey
Definition: symkey.h:145
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:141
std::string srp6_group_identifier(const BigInt &N, const BigInt &g)
Definition: srp6.cpp:50
Definition: bigint.h:1092