Merged the hostap_2.6 updates, and the Leap of Faith work, from the hostap_update...
[mech_eap.git] / libeap / src / eap_peer / eap_leap.c
index a7c94a4..ff6fa4a 100644 (file)
@@ -2,14 +2,8 @@
  * EAP peer method: LEAP
  * Copyright (c) 2004-2007, Jouni Malinen <j@w1.fi>
  *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- * Alternatively, this software may be distributed under the terms of BSD
- * license.
- *
- * See README and COPYING for more details.
+ * This software may be distributed under the terms of the BSD license.
+ * See README for more details.
  */
 
 #include "includes.h"
@@ -17,6 +11,7 @@
 #include "common.h"
 #include "crypto/ms_funcs.h"
 #include "crypto/crypto.h"
+#include "crypto/random.h"
 #include "eap_i.h"
 
 #define LEAP_VERSION 1
@@ -167,7 +162,7 @@ static struct wpabuf * eap_leap_process_success(struct eap_sm *sm, void *priv,
        wpabuf_put_u8(resp, 0); /* unused */
        wpabuf_put_u8(resp, LEAP_CHALLENGE_LEN);
        pos = wpabuf_put(resp, LEAP_CHALLENGE_LEN);
-       if (os_get_random(pos, LEAP_CHALLENGE_LEN)) {
+       if (random_get_bytes(pos, LEAP_CHALLENGE_LEN)) {
                wpa_printf(MSG_WARNING, "EAP-LEAP: Failed to read random data "
                           "for challenge");
                wpabuf_free(resp);
@@ -249,7 +244,7 @@ static struct wpabuf * eap_leap_process_response(struct eap_sm *sm, void *priv,
        ret->methodState = METHOD_DONE;
        ret->allowNotifications = FALSE;
 
-       if (os_memcmp(pos, expected, LEAP_RESPONSE_LEN) != 0) {
+       if (os_memcmp_const(pos, expected, LEAP_RESPONSE_LEN) != 0) {
                wpa_printf(MSG_WARNING, "EAP-LEAP: AP sent an invalid "
                           "response - authentication failed");
                wpa_hexdump(MSG_DEBUG, "EAP-LEAP: Expected response from AP",
@@ -388,6 +383,9 @@ static u8 * eap_leap_getKey(struct eap_sm *sm, void *priv, size_t *len)
        wpa_hexdump_key(MSG_DEBUG, "EAP-LEAP: master key", key, LEAP_KEY_LEN);
        *len = LEAP_KEY_LEN;
 
+       os_memset(pw_hash, 0, sizeof(pw_hash));
+       os_memset(pw_hash_hash, 0, sizeof(pw_hash_hash));
+
        return key;
 }
 
@@ -395,7 +393,6 @@ static u8 * eap_leap_getKey(struct eap_sm *sm, void *priv, size_t *len)
 int eap_peer_leap_register(void)
 {
        struct eap_method *eap;
-       int ret;
 
        eap = eap_peer_method_alloc(EAP_PEER_METHOD_INTERFACE_VERSION,
                                    EAP_VENDOR_IETF, EAP_TYPE_LEAP, "LEAP");
@@ -408,8 +405,5 @@ int eap_peer_leap_register(void)
        eap->isKeyAvailable = eap_leap_isKeyAvailable;
        eap->getKey = eap_leap_getKey;
 
-       ret = eap_peer_method_register(eap);
-       if (ret)
-               eap_peer_method_free(eap);
-       return ret;
+       return eap_peer_method_register(eap);
 }