/*
* 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
#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];
len[1] = secret_len;
addr[2] = challenge;
len[2] = challenge_len;
- md5_vector(3, addr, len, response);
+ return md5_vector(3, addr, len, response);
}
/*
* 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
#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 */
}
-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;
/* 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;
}
#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);