removed tabs
parent
7ec0c6c2ae
commit
5a52bcb31e
40
srp.c
40
srp.c
|
@ -271,15 +271,15 @@ void srp_gen_sv( const char * username,
|
||||||
const unsigned char ** bytes_v, int * len_v )
|
const unsigned char ** bytes_v, int * len_v )
|
||||||
{
|
{
|
||||||
BIGNUM * s = BN_new();
|
BIGNUM * s = BN_new();
|
||||||
BIGNUM * v = BN_new();
|
BIGNUM * v = BN_new();
|
||||||
BIGNUM * x = 0;
|
BIGNUM * x = 0;
|
||||||
BN_CTX *ctx = BN_CTX_new();
|
BN_CTX *ctx = BN_CTX_new();
|
||||||
|
|
||||||
BN_rand(s, 32, -1, 0);
|
BN_rand(s, 32, -1, 0);
|
||||||
|
|
||||||
x = calculate_x( s, username, password, len_password );
|
x = calculate_x( s, username, password, len_password );
|
||||||
|
|
||||||
BN_mod_exp(v, g, x, N, ctx);
|
BN_mod_exp(v, g, x, N, ctx);
|
||||||
|
|
||||||
*len_s = BN_num_bytes(s);
|
*len_s = BN_num_bytes(s);
|
||||||
*len_v = BN_num_bytes(v);
|
*len_v = BN_num_bytes(v);
|
||||||
|
@ -332,24 +332,24 @@ struct SRPVerifier * srp_verifier_new( const char * username,
|
||||||
BN_mod(tmp1, A, N, ctx);
|
BN_mod(tmp1, A, N, ctx);
|
||||||
if ( !BN_is_zero(tmp1) )
|
if ( !BN_is_zero(tmp1) )
|
||||||
{
|
{
|
||||||
BN_rand(b, 256, -1, 0);
|
BN_rand(b, 256, -1, 0);
|
||||||
|
|
||||||
/* B = kv + g^b */
|
/* B = kv + g^b */
|
||||||
BN_mul(tmp1, k, v, ctx);
|
BN_mul(tmp1, k, v, ctx);
|
||||||
BN_mod_exp(tmp2, g, b, N, ctx);
|
BN_mod_exp(tmp2, g, b, N, ctx);
|
||||||
BN_add(B, tmp1, tmp2);
|
BN_add(B, tmp1, tmp2);
|
||||||
|
|
||||||
u = H_nn(A,B);
|
u = H_nn(A,B);
|
||||||
|
|
||||||
/* S = (A *(v^u)) ^ b */
|
/* S = (A *(v^u)) ^ b */
|
||||||
BN_mod_exp(tmp1, v, u, N, ctx);
|
BN_mod_exp(tmp1, v, u, N, ctx);
|
||||||
BN_mul(tmp2, A, tmp1, ctx);
|
BN_mul(tmp2, A, tmp1, ctx);
|
||||||
BN_mod_exp(S, tmp2, b, N, ctx);
|
BN_mod_exp(S, tmp2, b, N, ctx);
|
||||||
|
|
||||||
hash_num(S, ver->session_key);
|
hash_num(S, ver->session_key);
|
||||||
|
|
||||||
calculate_M( ver->M, username, s, A, B, ver->session_key );
|
calculate_M( ver->M, username, s, A, B, ver->session_key );
|
||||||
calculate_H_AMK( ver->H_AMK, A, ver->M, ver->session_key );
|
calculate_H_AMK( ver->H_AMK, A, ver->M, ver->session_key );
|
||||||
|
|
||||||
*len_B = BN_num_bytes(B);
|
*len_B = BN_num_bytes(B);
|
||||||
*bytes_B = malloc( *len_B );
|
*bytes_B = malloc( *len_B );
|
||||||
|
@ -357,7 +357,7 @@ struct SRPVerifier * srp_verifier_new( const char * username,
|
||||||
BN_bn2bin( B, (unsigned char *) *bytes_B );
|
BN_bn2bin( B, (unsigned char *) *bytes_B );
|
||||||
|
|
||||||
ver->bytes_B = *bytes_B;
|
ver->bytes_B = *bytes_B;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
*len_B = 0;
|
*len_B = 0;
|
||||||
|
|
Loading…
Reference in New Issue