@@ -24,6 +24,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
24
24
#include " sha1.h"
25
25
#include " srp.h"
26
26
#include " string.h"
27
+ #include " debug.h"
27
28
28
29
// Get an sha-1 hash of the player's name combined with
29
30
// the password entered. That's what the server uses as
@@ -50,10 +51,11 @@ void getSRPVerifier(const std::string &name,
50
51
char **bytes_v, size_t *len_v)
51
52
{
52
53
std::string n_name = lowercase (name);
53
- srp_create_salted_verification_key (SRP_SHA256, SRP_NG_2048,
54
+ SRP_Result res = srp_create_salted_verification_key (SRP_SHA256, SRP_NG_2048,
54
55
n_name.c_str (), (const unsigned char *)password.c_str (),
55
56
password.size (), (unsigned char **)salt, salt_len,
56
57
(unsigned char **)bytes_v, len_v, NULL , NULL );
58
+ FATAL_ERROR_IF (res != SRP_OK, " Couldn't create salted SRP verifier" );
57
59
}
58
60
59
61
// Get a db-ready SRP verifier
@@ -67,6 +69,7 @@ inline static std::string getSRPVerifier(const std::string &name,
67
69
size_t len_v;
68
70
getSRPVerifier (name, password, salt, &salt_len,
69
71
&bytes_v, &len_v);
72
+ assert (*salt); // usually, srp_create_salted_verification_key promises us to return SRP_ERR when *salt == NULL
70
73
std::string ret_val = encodeSRPVerifier (std::string (bytes_v, len_v),
71
74
std::string (*salt, salt_len));
72
75
free (bytes_v);
0 commit comments