Pass digest return value to CHAP/MSCHAPv2 caller

This commit is contained in:
Jouni Malinen 2009-08-16 18:38:35 +03:00
parent 76f04b38b0
commit be299ca4ce
4 changed files with 27 additions and 23 deletions

View 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);
}

View 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 */

View 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;
}

View file

@ -21,13 +21,13 @@
#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);