]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
WPS: Fix OOB Device Password use for EAP-WSC peer
authorJouni Malinen <j@w1.fi>
Wed, 27 Jun 2012 18:15:29 +0000 (21:15 +0300)
committerJouni Malinen <j@w1.fi>
Wed, 27 Jun 2012 18:22:12 +0000 (21:22 +0300)
The OOB Device Password is passed in as a hexdump of the real Device
Password (16..32 octets of arbitrary binary data). The hexdump needs to
be converted to binary form before passing it for WPS processing.

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

src/eap_peer/eap_wsc.c

index 4473b90698ac0399a304bdc1fa4ce4ddf9fa29bd..2c948a0461b7fa0a3c393187337130c337947b79 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * EAP-WSC peer for Wi-Fi Protected Setup
- * Copyright (c) 2007-2009, Jouni Malinen <j@w1.fi>
+ * Copyright (c) 2007-2009, 2012, Jouni Malinen <j@w1.fi>
  *
  * This software may be distributed under the terms of the BSD license.
  * See README for more details.
@@ -137,6 +137,7 @@ static void * eap_wsc_init(struct eap_sm *sm)
        struct wps_context *wps;
        struct wps_credential new_ap_settings;
        int res;
+       u8 dev_pw[WPS_OOB_DEVICE_PASSWORD_LEN];
 
        wps = sm->wps;
        if (wps == NULL) {
@@ -184,6 +185,14 @@ static void * eap_wsc_init(struct eap_sm *sm)
                while (*pos != '\0' && *pos != ' ')
                        pos++;
                cfg.pin_len = pos - (const char *) cfg.pin;
+               if (cfg.pin_len >= WPS_OOB_DEVICE_PASSWORD_MIN_LEN * 2 &&
+                   cfg.pin_len <= WPS_OOB_DEVICE_PASSWORD_LEN * 2 &&
+                   hexstr2bin((const char *) cfg.pin, dev_pw,
+                              cfg.pin_len / 2) == 0) {
+                       /* Convert OOB Device Password to binary */
+                       cfg.pin = dev_pw;
+                       cfg.pin_len /= 2;
+               }
        } else {
                pos = os_strstr(phase1, "pbc=1");
                if (pos)