]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
SAE: Add a define for maximum supported prime length
authorJouni Malinen <j@w1.fi>
Tue, 1 Jan 2013 09:49:01 +0000 (11:49 +0200)
committerJouni Malinen <j@w1.fi>
Sat, 12 Jan 2013 15:51:53 +0000 (17:51 +0200)
This can be used to increase buffer sizes when adding support for new
groups.

Signed-hostap: Jouni Malinen <j@w1.fi>

src/common/sae.c
src/common/sae.h

index 625c95f80f522b58daddba05f91b9751f02db20a..0dfb52a010fcd25bac9d1151ebdea9dfac1d5f0d 100644 (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,
                             struct crypto_ec_point *pwe, u8 *pwe_bin)
 {
-       u8 pwd_value[32];
+       u8 pwd_value[SAE_MAX_PRIME_LEN];
        struct crypto_bignum *x;
        int y_bit;
 
@@ -163,7 +163,7 @@ static int sae_derive_pwe(struct sae_data *sae, const u8 *addr1,
        size_t len[2];
        int found = 0;
        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);
        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_ec_point *elem;
-       u8 mask[32];
+       u8 mask[SAE_MAX_PRIME_LEN];
        int ret = -1;
 
        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)
 {
-       u8 null_key[32], val[32];
+       u8 null_key[32], val[SAE_MAX_PRIME_LEN];
        u8 keyseed[SHA256_MAC_LEN];
        u8 keys[32 + 32];
        struct crypto_bignum *order, *own_scalar, *peer_scalar, *tmp;
@@ -424,7 +424,7 @@ fail:
 
 int sae_process_commit(struct sae_data *sae)
 {
-       u8 k[32];
+       u8 k[SAE_MAX_PRIME_LEN];
        if (sae_check_peer_commit(sae) < 0 ||
            sae_derive_k(sae, k) < 0 ||
            sae_derive_keys(sae, k) < 0)
index 37b9d541f226891ff793dfd0362fb199fa98a532..06727cef78c199e4ac64c502e038f7a0102117d0 100644 (file)
@@ -9,20 +9,21 @@
 #ifndef SAE_H
 #define SAE_H
 
-#define SAE_COMMIT_MAX_LEN (2 + 3 * 32)
-#define SAE_CONFIRM_MAX_LEN (2 + 32)
+#define SAE_MAX_PRIME_LEN 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 {
        enum { SAE_NOTHING, SAE_COMMITTED, SAE_CONFIRMED, SAE_ACCEPTED } state;
        u16 send_confirm;
        u8 kck[32];
        u8 pmk[32];
-       u8 own_commit_scalar[32];
-       u8 own_commit_element[2 * 32];
-       u8 peer_commit_scalar[32];
-       u8 peer_commit_element[2 * 32];
-       u8 pwe[2 * 32];
-       u8 sae_rand[32];
+       u8 own_commit_scalar[SAE_MAX_PRIME_LEN];
+       u8 own_commit_element[2 * SAE_MAX_PRIME_LEN];
+       u8 peer_commit_scalar[SAE_MAX_PRIME_LEN];
+       u8 peer_commit_element[2 * SAE_MAX_PRIME_LEN];
+       u8 pwe[2 * SAE_MAX_PRIME_LEN];
+       u8 sae_rand[SAE_MAX_PRIME_LEN];
        int group;
        struct crypto_ec *ec;
        int prime_len;