WPS: Fix WEP key index to use 1..4 instead of 0..3
authorAndriy Tkachuk <andriy.v.tkachuk@globallogic.com>
Wed, 18 Feb 2009 17:58:44 +0000 (19:58 +0200)
committerJouni Malinen <j@w1.fi>
Wed, 18 Feb 2009 17:58:44 +0000 (19:58 +0200)
It seems that WFA WPS spec says that default key index should be 1 (not
0). I think this meas that WEP key indexes region is not from 0 to 3,
but from 1 to 4 in WPS. At least WRT610N implemented it this way.

wpa_supplicant/wps_supplicant.c

index 8ca684f..c2c1dd0 100644 (file)
@@ -88,7 +88,7 @@ static int wpa_supplicant_wps_cred(void *ctx,
 {
        struct wpa_supplicant *wpa_s = ctx;
        struct wpa_ssid *ssid = wpa_s->current_ssid;
-       u8 key_idx;
+       u8 key_idx = 0;
 
        if ((wpa_s->conf->wps_cred_processing == 1 ||
             wpa_s->conf->wps_cred_processing == 2) && cred->cred_attr) {
@@ -160,12 +160,13 @@ static int wpa_supplicant_wps_cred(void *ctx,
                                   "%lu", (unsigned long) cred->key_len);
                        return -1;
                }
-               if (cred->key_idx >= NUM_WEP_KEYS) {
+               if (cred->key_idx > NUM_WEP_KEYS) {
                        wpa_printf(MSG_ERROR, "WPS: Invalid WEP Key index %d",
                                   cred->key_idx);
                        return -1;
                }
-               key_idx = cred->key_idx;
+               if (cred->key_idx)
+                       key_idx = cred->key_idx - 1;
                if (cred->key_len == 10 || cred->key_len == 26) {
                        if (hexstr2bin((char *) cred->key,
                                       ssid->wep_key[key_idx],