003 File Manager
Current Path:
/usr/src/contrib/wpa/src/eap_peer
usr
/
src
/
contrib
/
wpa
/
src
/
eap_peer
/
📁
..
📄
eap.c
(85.07 KB)
📄
eap.h
(11.96 KB)
📄
eap_aka.c
(44.5 KB)
📄
eap_config.h
(27.24 KB)
📄
eap_eke.c
(20.08 KB)
📄
eap_fast.c
(48.05 KB)
📄
eap_fast_pac.c
(20.71 KB)
📄
eap_fast_pac.h
(1.41 KB)
📄
eap_gpsk.c
(18.77 KB)
📄
eap_gtc.c
(3.35 KB)
📄
eap_i.h
(13.51 KB)
📄
eap_ikev2.c
(12.79 KB)
📄
eap_leap.c
(10.81 KB)
📄
eap_md5.c
(2.82 KB)
📄
eap_methods.c
(8.63 KB)
📄
eap_methods.h
(2.7 KB)
📄
eap_mschapv2.c
(25.42 KB)
📄
eap_otp.c
(2.1 KB)
📄
eap_pax.c
(13.98 KB)
📄
eap_peap.c
(37.35 KB)
📄
eap_proxy.h
(1.44 KB)
📄
eap_proxy_dummy.c
(1.51 KB)
📄
eap_psk.c
(13.12 KB)
📄
eap_pwd.c
(30.39 KB)
📄
eap_sake.c
(12.78 KB)
📄
eap_sim.c
(36.06 KB)
📄
eap_teap.c
(54.2 KB)
📄
eap_teap_pac.c
(20.29 KB)
📄
eap_teap_pac.h
(1.41 KB)
📄
eap_tls.c
(11.77 KB)
📄
eap_tls_common.c
(36.06 KB)
📄
eap_tls_common.h
(3.94 KB)
📄
eap_tnc.c
(10.06 KB)
📄
eap_ttls.c
(47.59 KB)
📄
eap_vendor_test.c
(4.19 KB)
📄
eap_wsc.c
(14.38 KB)
📄
ikev2.c
(30.38 KB)
📄
ikev2.h
(1.35 KB)
📄
mschapv2.c
(3.58 KB)
📄
mschapv2.h
(834 B)
📄
tncc.c
(29.92 KB)
📄
tncc.h
(994 B)
Editing: mschapv2.c
/* * MSCHAPV2 (RFC 2759) * Copyright (c) 2004-2008, Jouni Malinen <j@w1.fi> * * This software may be distributed under the terms of the BSD license. * See README for more details. */ #include "includes.h" #include "common.h" #include "crypto/ms_funcs.h" #include "mschapv2.h" const u8 * mschapv2_remove_domain(const u8 *username, size_t *len) { size_t i; /* * MSCHAPv2 does not include optional domain name in the * challenge-response calculation, so remove domain prefix * (if present). */ for (i = 0; i < *len; i++) { if (username[i] == '\\') { *len -= i + 1; return username + i + 1; } } return username; } 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; u8 password_hash[16], password_hash_hash[16]; wpa_hexdump_ascii(MSG_DEBUG, "MSCHAPV2: Identity", identity, identity_len); username_len = identity_len; username = mschapv2_remove_domain(identity, &username_len); wpa_hexdump_ascii(MSG_DEBUG, "MSCHAPV2: Username", username, username_len); wpa_hexdump(MSG_DEBUG, "MSCHAPV2: auth_challenge", auth_challenge, MSCHAPV2_CHAL_LEN); wpa_hexdump(MSG_DEBUG, "MSCHAPV2: peer_challenge", peer_challenge, MSCHAPV2_CHAL_LEN); wpa_hexdump_ascii(MSG_DEBUG, "MSCHAPV2: username", username, username_len); /* Authenticator response is not really needed yet, but calculate it * here so that challenges need not be saved. */ if (pwhash) { wpa_hexdump_key(MSG_DEBUG, "MSCHAPV2: password hash", password, password_len); if (generate_nt_response_pwhash(auth_challenge, peer_challenge, username, username_len, password, nt_response) || generate_authenticator_response_pwhash( password, peer_challenge, auth_challenge, username, username_len, nt_response, auth_response)) return -1; } else { wpa_hexdump_ascii_key(MSG_DEBUG, "MSCHAPV2: password", password, password_len); if (generate_nt_response(auth_challenge, peer_challenge, username, username_len, password, password_len, nt_response) || generate_authenticator_response(password, password_len, peer_challenge, auth_challenge, username, username_len, nt_response, auth_response)) return -1; } wpa_hexdump(MSG_DEBUG, "MSCHAPV2: NT Response", nt_response, MSCHAPV2_NT_RESPONSE_LEN); wpa_hexdump(MSG_DEBUG, "MSCHAPV2: Auth Response", auth_response, MSCHAPV2_AUTH_RESPONSE_LEN); /* Generate master_key here since we have the needed data available. */ if (pwhash) { if (hash_nt_password_hash(password, password_hash_hash)) return -1; } else { if (nt_password_hash(password, password_len, password_hash) || hash_nt_password_hash(password_hash, password_hash_hash)) return -1; } if (get_master_key(password_hash_hash, nt_response, master_key)) return -1; wpa_hexdump_key(MSG_DEBUG, "MSCHAPV2: Master Key", master_key, MSCHAPV2_MASTER_KEY_LEN); return 0; } int mschapv2_verify_auth_response(const u8 *auth_response, const u8 *buf, size_t buf_len) { u8 recv_response[MSCHAPV2_AUTH_RESPONSE_LEN]; if (buf_len < 2 + 2 * MSCHAPV2_AUTH_RESPONSE_LEN || buf[0] != 'S' || buf[1] != '=' || hexstr2bin((char *) (buf + 2), recv_response, MSCHAPV2_AUTH_RESPONSE_LEN) || os_memcmp_const(auth_response, recv_response, MSCHAPV2_AUTH_RESPONSE_LEN) != 0) return -1; return 0; }
Upload File
Create Folder