SAE: Clean up exponent calculation for PWE
Signed-hostap: Jouni Malinen <j@w1.fi>
This commit is contained in:
parent
66fc91ab11
commit
f05dad2090
1 changed files with 12 additions and 14 deletions
|
@ -229,25 +229,23 @@ static int sae_test_pwd_seed_ffc(struct sae_data *sae, const u8 *pwd_seed,
|
||||||
*/
|
*/
|
||||||
exp[0] = 2;
|
exp[0] = 2;
|
||||||
b = crypto_bignum_init_set(exp, sizeof(exp));
|
b = crypto_bignum_init_set(exp, sizeof(exp));
|
||||||
if (a == NULL || b == NULL)
|
|
||||||
res = -1;
|
|
||||||
else
|
|
||||||
res = crypto_bignum_exptmod(a, b, sae->prime, pwe);
|
|
||||||
} else {
|
} else {
|
||||||
struct crypto_bignum *tmp;
|
/* Calculate exponent: (p-1)/r */
|
||||||
|
|
||||||
exp[0] = 1;
|
exp[0] = 1;
|
||||||
b = crypto_bignum_init_set(exp, sizeof(exp));
|
b = crypto_bignum_init_set(exp, sizeof(exp));
|
||||||
tmp = crypto_bignum_init();
|
if (b == NULL ||
|
||||||
if (a == NULL || b == NULL || tmp == NULL ||
|
crypto_bignum_sub(sae->prime, b, b) < 0 ||
|
||||||
crypto_bignum_sub(sae->prime, b, tmp) < 0 ||
|
crypto_bignum_div(b, sae->order, b) < 0) {
|
||||||
crypto_bignum_div(tmp, sae->order, b) < 0)
|
crypto_bignum_deinit(b, 0);
|
||||||
res = -1;
|
b = NULL;
|
||||||
else
|
}
|
||||||
res = crypto_bignum_exptmod(a, b, sae->prime, pwe);
|
|
||||||
crypto_bignum_deinit(tmp, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (a == NULL || b == NULL)
|
||||||
|
res = -1;
|
||||||
|
else
|
||||||
|
res = crypto_bignum_exptmod(a, b, sae->prime, pwe);
|
||||||
|
|
||||||
crypto_bignum_deinit(a, 0);
|
crypto_bignum_deinit(a, 0);
|
||||||
crypto_bignum_deinit(b, 0);
|
crypto_bignum_deinit(b, 0);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue