]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
SAE: Fix PWE loop termination on excessive iterations
authorJouni Malinen <j@w1.fi>
Tue, 1 Jan 2013 10:50:27 +0000 (12:50 +0200)
committerJouni Malinen <j@w1.fi>
Sat, 12 Jan 2013 15:51:53 +0000 (17:51 +0200)
The counter>200 check needs to be done before the continue-on-not-found
case to be effective in stopping this loop.

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

src/common/sae.c

index ff26e9e3138fca2825537c9718a11eedb84b8387..fcca157f20f951307bf561fb1b872e5a68d02166 100644 (file)
@@ -202,6 +202,12 @@ static int sae_derive_pwe(struct sae_data *sae, const u8 *addr1,
                u8 pwd_seed[SHA256_MAC_LEN];
                int res;
 
+               if (counter > 200) {
+                       /* This should not happen in practice */
+                       wpa_printf(MSG_DEBUG, "SAE: Failed to derive PWE");
+                       break;
+               }
+
                wpa_printf(MSG_DEBUG, "SAE: counter = %u", counter);
                if (hmac_sha256_vector(addrs, sizeof(addrs), 2, addr, len,
                                       pwd_seed) < 0)
@@ -220,12 +226,6 @@ static int sae_derive_pwe(struct sae_data *sae, const u8 *addr1,
                        wpa_printf(MSG_DEBUG, "SAE: Use this PWE");
                        found = 1;
                }
-
-               if (counter > 200) {
-                       /* This should not happen in practice */
-                       wpa_printf(MSG_DEBUG, "SAE: Failed to derive PWE");
-                       break;
-               }
        }
 
        crypto_ec_point_deinit(pwe_tmp, 1);