Pass digest return value to CHAP/MSCHAPv2 caller
authorJouni Malinen <j@w1.fi>
Sun, 16 Aug 2009 15:38:35 +0000 (18:38 +0300)
committerJouni Malinen <j@w1.fi>
Sun, 16 Aug 2009 15:38:35 +0000 (18:38 +0300)
src/eap_common/chap.c
src/eap_common/chap.h
src/eap_peer/mschapv2.c
src/eap_peer/mschapv2.h

index a088aff..5b7e07e 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * CHAP-MD5 (RFC 1994)
- * Copyright (c) 2007, Jouni Malinen <j@w1.fi>
+ * Copyright (c) 2007-2009, 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
@@ -19,7 +19,7 @@
 #include "crypto.h"
 #include "chap.h"
 
-void chap_md5(u8 id, const u8 *secret, size_t secret_len, const u8 *challenge,
+int chap_md5(u8 id, const u8 *secret, size_t secret_len, const u8 *challenge,
              size_t challenge_len, u8 *response)
 {
        const u8 *addr[3];
@@ -31,5 +31,5 @@ void chap_md5(u8 id, const u8 *secret, size_t secret_len, const u8 *challenge,
        len[1] = secret_len;
        addr[2] = challenge;
        len[2] = challenge_len;
-       md5_vector(3, addr, len, response);
+       return md5_vector(3, addr, len, response);
 }
index 209dc8a..b9c400c 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * CHAP-MD5 (RFC 1994)
- * Copyright (c) 2007, Jouni Malinen <j@w1.fi>
+ * Copyright (c) 2007-2009, 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
@@ -17,7 +17,7 @@
 
 #define CHAP_MD5_LEN 16
 
-void chap_md5(u8 id, const u8 *secret, size_t secret_len, const u8 *challenge,
-             size_t challenge_len, u8 *response);
+int chap_md5(u8 id, const u8 *secret, size_t secret_len, const u8 *challenge,
+            size_t challenge_len, u8 *response);
 
 #endif /* CHAP_H */
index 01c22d8..49235b5 100644 (file)
@@ -39,13 +39,13 @@ const u8 * mschapv2_remove_domain(const u8 *username, size_t *len)
 }
 
 
-void mschapv2_derive_response(const u8 *identity, size_t identity_len,
-                             const u8 *password, size_t password_len,
-                             int pwhash,
-                             const u8 *auth_challenge,
-                             const u8 *peer_challenge,
-                             u8 *nt_response, u8 *auth_response,
-                             u8 *master_key)
+int mschapv2_derive_response(const u8 *identity, size_t identity_len,
+                            const u8 *password, size_t password_len,
+                            int pwhash,
+                            const u8 *auth_challenge,
+                            const u8 *peer_challenge,
+                            u8 *nt_response, u8 *auth_response,
+                            u8 *master_key)
 {
        const u8 *username;
        size_t username_len;
@@ -93,14 +93,18 @@ void mschapv2_derive_response(const u8 *identity, size_t identity_len,
 
        /* Generate master_key here since we have the needed data available. */
        if (pwhash) {
-               hash_nt_password_hash(password, password_hash_hash);
+               if (hash_nt_password_hash(password, password_hash_hash))
+                       return -1;
        } else {
-               nt_password_hash(password, password_len, password_hash);
-               hash_nt_password_hash(password_hash, password_hash_hash);
+               if (nt_password_hash(password, password_len, password_hash) ||
+                   hash_nt_password_hash(password_hash, password_hash_hash))
+                       return -1;
        }
        get_master_key(password_hash_hash, nt_response, master_key);
        wpa_hexdump_key(MSG_DEBUG, "MSCHAPV2: Master Key",
                        master_key, MSCHAPV2_MASTER_KEY_LEN);
+
+       return 0;
 }
 
 
index c7c36f7..90dad31 100644 (file)
 #define MSCHAPV2_MASTER_KEY_LEN 16
 
 const u8 * mschapv2_remove_domain(const u8 *username, size_t *len);
-void mschapv2_derive_response(const u8 *username, size_t username_len,
-                             const u8 *password, size_t password_len,
-                             int pwhash,
-                             const u8 *auth_challenge,
-                             const u8 *peer_challenge,
-                             u8 *nt_response, u8 *auth_response,
-                             u8 *master_key);
+int mschapv2_derive_response(const u8 *username, size_t username_len,
+                            const u8 *password, size_t password_len,
+                            int pwhash,
+                            const u8 *auth_challenge,
+                            const u8 *peer_challenge,
+                            u8 *nt_response, u8 *auth_response,
+                            u8 *master_key);
 int mschapv2_verify_auth_response(const u8 *auth_response,
                                  const u8 *buf, size_t buf_len);