SAE: Add a define for maximum supported prime length

This can be used to increase buffer sizes when adding support for new
groups.

Signed-hostap: Jouni Malinen <j@w1.fi>
This commit is contained in:
Jouni Malinen 2013-01-01 11:49:01 +02:00
parent 12e06dc228
commit 7babd2539c
2 changed files with 14 additions and 13 deletions

View file

@ -111,7 +111,7 @@ static void sae_pwd_seed_key(const u8 *addr1, const u8 *addr2, u8 *key)
static int sae_test_pwd_seed(struct sae_data *sae, const u8 *pwd_seed, static int sae_test_pwd_seed(struct sae_data *sae, const u8 *pwd_seed,
struct crypto_ec_point *pwe, u8 *pwe_bin) struct crypto_ec_point *pwe, u8 *pwe_bin)
{ {
u8 pwd_value[32]; u8 pwd_value[SAE_MAX_PRIME_LEN];
struct crypto_bignum *x; struct crypto_bignum *x;
int y_bit; int y_bit;
@ -163,7 +163,7 @@ static int sae_derive_pwe(struct sae_data *sae, const u8 *addr1,
size_t len[2]; size_t len[2];
int found = 0; int found = 0;
struct crypto_ec_point *pwe_tmp; struct crypto_ec_point *pwe_tmp;
u8 pwe_bin_tmp[2 * 32]; u8 pwe_bin_tmp[2 * SAE_MAX_PRIME_LEN];
pwe_tmp = crypto_ec_point_init(sae->ec); pwe_tmp = crypto_ec_point_init(sae->ec);
if (pwe_tmp == NULL) if (pwe_tmp == NULL)
@ -229,7 +229,7 @@ static int sae_derive_commit(struct sae_data *sae, struct crypto_ec_point *pwe)
{ {
struct crypto_bignum *x, *bn_rand, *bn_mask, *order; struct crypto_bignum *x, *bn_rand, *bn_mask, *order;
struct crypto_ec_point *elem; struct crypto_ec_point *elem;
u8 mask[32]; u8 mask[SAE_MAX_PRIME_LEN];
int ret = -1; int ret = -1;
if (sae_get_rand(sae->sae_rand) < 0 || sae_get_rand(mask) < 0) if (sae_get_rand(sae->sae_rand) < 0 || sae_get_rand(mask) < 0)
@ -375,7 +375,7 @@ fail:
static int sae_derive_keys(struct sae_data *sae, const u8 *k) static int sae_derive_keys(struct sae_data *sae, const u8 *k)
{ {
u8 null_key[32], val[32]; u8 null_key[32], val[SAE_MAX_PRIME_LEN];
u8 keyseed[SHA256_MAC_LEN]; u8 keyseed[SHA256_MAC_LEN];
u8 keys[32 + 32]; u8 keys[32 + 32];
struct crypto_bignum *order, *own_scalar, *peer_scalar, *tmp; struct crypto_bignum *order, *own_scalar, *peer_scalar, *tmp;
@ -424,7 +424,7 @@ fail:
int sae_process_commit(struct sae_data *sae) int sae_process_commit(struct sae_data *sae)
{ {
u8 k[32]; u8 k[SAE_MAX_PRIME_LEN];
if (sae_check_peer_commit(sae) < 0 || if (sae_check_peer_commit(sae) < 0 ||
sae_derive_k(sae, k) < 0 || sae_derive_k(sae, k) < 0 ||
sae_derive_keys(sae, k) < 0) sae_derive_keys(sae, k) < 0)

View file

@ -9,20 +9,21 @@
#ifndef SAE_H #ifndef SAE_H
#define SAE_H #define SAE_H
#define SAE_COMMIT_MAX_LEN (2 + 3 * 32) #define SAE_MAX_PRIME_LEN 32
#define SAE_CONFIRM_MAX_LEN (2 + 32) #define SAE_COMMIT_MAX_LEN (2 + 3 * SAE_MAX_PRIME_LEN)
#define SAE_CONFIRM_MAX_LEN (2 + SAE_MAX_PRIME_LEN)
struct sae_data { struct sae_data {
enum { SAE_NOTHING, SAE_COMMITTED, SAE_CONFIRMED, SAE_ACCEPTED } state; enum { SAE_NOTHING, SAE_COMMITTED, SAE_CONFIRMED, SAE_ACCEPTED } state;
u16 send_confirm; u16 send_confirm;
u8 kck[32]; u8 kck[32];
u8 pmk[32]; u8 pmk[32];
u8 own_commit_scalar[32]; u8 own_commit_scalar[SAE_MAX_PRIME_LEN];
u8 own_commit_element[2 * 32]; u8 own_commit_element[2 * SAE_MAX_PRIME_LEN];
u8 peer_commit_scalar[32]; u8 peer_commit_scalar[SAE_MAX_PRIME_LEN];
u8 peer_commit_element[2 * 32]; u8 peer_commit_element[2 * SAE_MAX_PRIME_LEN];
u8 pwe[2 * 32]; u8 pwe[2 * SAE_MAX_PRIME_LEN];
u8 sae_rand[32]; u8 sae_rand[SAE_MAX_PRIME_LEN];
int group; int group;
struct crypto_ec *ec; struct crypto_ec *ec;
int prime_len; int prime_len;