hostapd: fix auth encryption
authorJohannes Berg <johannes@sipsolutions.net>
Sun, 26 Jul 2009 18:15:47 +0000 (21:15 +0300)
committerJouni Malinen <j@w1.fi>
Sun, 26 Jul 2009 18:15:47 +0000 (21:15 +0300)
hostapd currently tries to encrypt all auth frames,
except for "OPEN" and "SHARED with transaction 3".
This means that it will send an encrypted "unknown
auth algorithm" reply for all other algorithsm. Fix
this by changing the logic to only encrypt shared
key auth frames with transaction 3.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
src/drivers/driver_nl80211.c

index 962b8c3..622a47f 100644 (file)
@@ -2197,7 +2197,7 @@ static int wpa_driver_nl80211_send_mlme(void *priv, const u8 *data,
 {
        struct wpa_driver_nl80211_data *drv = priv;
        struct ieee80211_mgmt *mgmt;
-       int do_not_encrypt = 0;
+       int encrypt = 1;
        u16 fc;
 
        mgmt = (struct ieee80211_mgmt *) data;
@@ -2213,13 +2213,11 @@ static int wpa_driver_nl80211_send_mlme(void *priv, const u8 *data,
                 */
                u16 auth_alg = le_to_host16(mgmt->u.auth.auth_alg);
                u16 auth_trans = le_to_host16(mgmt->u.auth.auth_transaction);
-               if (auth_alg == WLAN_AUTH_OPEN ||
-                   (auth_alg == WLAN_AUTH_SHARED_KEY && auth_trans != 3))
-                       do_not_encrypt = 1;
+               if (auth_alg != WLAN_AUTH_SHARED_KEY || auth_trans != 3)
+                       encrypt = 0;
        }
 
-       return wpa_driver_nl80211_send_frame(drv, data, data_len,
-                                            !do_not_encrypt);
+       return wpa_driver_nl80211_send_frame(drv, data, data_len, encrypt);
 }