aboutsummaryrefslogtreecommitdiffstats
path: root/wpa_supplicant
diff options
context:
space:
mode:
authorAndriy Tkachuk <andriy.v.tkachuk@globallogic.com>2009-02-17 08:30:43 (GMT)
committerJouni Malinen <j@w1.fi>2009-02-27 10:32:25 (GMT)
commit6298e680ade4bb43a017081cb1d1827c551fa844 (patch)
tree39fbd227b4c0375ff73fdf778198a016cb05bc93 /wpa_supplicant
parent70c6552ddfcb4dfbf9a02f1d14927fadfa1f454a (diff)
downloadhostap-06-6298e680ade4bb43a017081cb1d1827c551fa844.zip
hostap-06-6298e680ade4bb43a017081cb1d1827c551fa844.tar.gz
hostap-06-6298e680ade4bb43a017081cb1d1827c551fa844.tar.bz2
WPS: support WEP keys in hex characters format in received credentials
Attached patch makes wpa_supplicant support WEP keys in hex characters format in received credentials from Registrars (tested with WRT610N). (cherry picked from commit 4b195a1bc9750bbe58c73a9661a74317ce2c18b2)
Diffstat (limited to 'wpa_supplicant')
-rw-r--r--wpa_supplicant/wps_supplicant.c33
1 files changed, 28 insertions, 5 deletions
diff --git a/wpa_supplicant/wps_supplicant.c b/wpa_supplicant/wps_supplicant.c
index 9b73601..8ca684f 100644
--- a/wpa_supplicant/wps_supplicant.c
+++ b/wpa_supplicant/wps_supplicant.c
@@ -88,6 +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;
if ((wpa_s->conf->wps_cred_processing == 1 ||
wpa_s->conf->wps_cred_processing == 2) && cred->cred_attr) {
@@ -151,13 +152,35 @@ static int wpa_supplicant_wps_cred(void *ctx,
case WPS_ENCR_NONE:
break;
case WPS_ENCR_WEP:
- if (cred->key_len > 0 && cred->key_len <= MAX_WEP_KEY_LEN &&
- cred->key_idx < NUM_WEP_KEYS) {
- os_memcpy(ssid->wep_key[cred->key_idx], cred->key,
+ if (cred->key_len <= 0)
+ break;
+ if (cred->key_len != 5 && cred->key_len != 13 &&
+ cred->key_len != 10 && cred->key_len != 26) {
+ wpa_printf(MSG_ERROR, "WPS: Invalid WEP Key length "
+ "%lu", (unsigned long) cred->key_len);
+ return -1;
+ }
+ 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_len == 10 || cred->key_len == 26) {
+ if (hexstr2bin((char *) cred->key,
+ ssid->wep_key[key_idx],
+ cred->key_len / 2) < 0) {
+ wpa_printf(MSG_ERROR, "WPS: Invalid WEP Key "
+ "%d", key_idx);
+ return -1;
+ }
+ ssid->wep_key_len[key_idx] = cred->key_len / 2;
+ } else {
+ os_memcpy(ssid->wep_key[key_idx], cred->key,
cred->key_len);
- ssid->wep_key_len[cred->key_idx] = cred->key_len;
- ssid->wep_tx_keyidx = cred->key_idx;
+ ssid->wep_key_len[key_idx] = cred->key_len;
}
+ ssid->wep_tx_keyidx = key_idx;
break;
case WPS_ENCR_TKIP:
ssid->pairwise_cipher = WPA_CIPHER_TKIP;