Updated through tag hostap_2_5 from git://w1.fi/hostap.git
[mech_eap.git] / libeap / src / eap_common / eap_peap_common.c
index 3a64b8e..68b8878 100644 (file)
@@ -1,15 +1,9 @@
 /*
  * EAP-PEAP common routines
- * Copyright (c) 2008, Jouni Malinen <j@w1.fi>
+ * Copyright (c) 2008-2011, 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"
@@ -18,9 +12,9 @@
 #include "crypto/sha1.h"
 #include "eap_peap_common.h"
 
-void peap_prfplus(int version, const u8 *key, size_t key_len,
-                 const char *label, const u8 *seed, size_t seed_len,
-                 u8 *buf, size_t buf_len)
+int peap_prfplus(int version, const u8 *key, size_t key_len,
+                const char *label, const u8 *seed, size_t seed_len,
+                u8 *buf, size_t buf_len)
 {
        unsigned char counter = 0;
        size_t pos, plen;
@@ -75,7 +69,8 @@ void peap_prfplus(int version, const u8 *key, size_t key_len,
        while (pos < buf_len) {
                counter++;
                plen = buf_len - pos;
-               hmac_sha1_vector(key, key_len, 5, addr, len, hash);
+               if (hmac_sha1_vector(key, key_len, 5, addr, len, hash) < 0)
+                       return -1;
                if (plen >= SHA1_MAC_LEN) {
                        os_memcpy(&buf[pos], hash, SHA1_MAC_LEN);
                        pos += SHA1_MAC_LEN;
@@ -85,4 +80,6 @@ void peap_prfplus(int version, const u8 *key, size_t key_len,
                }
                len[0] = SHA1_MAC_LEN;
        }
+
+       return 0;
 }