003 File Manager
Current Path:
/usr/src/contrib/wpa/src/eap_server
usr
/
src
/
contrib
/
wpa
/
src
/
eap_server
/
📁
..
📄
eap.h
(4.52 KB)
📄
eap_i.h
(6.91 KB)
📄
eap_methods.h
(1.72 KB)
📄
eap_server.c
(53.81 KB)
📄
eap_server_aka.c
(37.32 KB)
📄
eap_server_eke.c
(21 KB)
📄
eap_server_fast.c
(42 KB)
📄
eap_server_gpsk.c
(16.34 KB)
📄
eap_server_gtc.c
(4.92 KB)
📄
eap_server_identity.c
(3.75 KB)
📄
eap_server_ikev2.c
(13.6 KB)
📄
eap_server_md5.c
(3.85 KB)
📄
eap_server_methods.c
(4.31 KB)
📄
eap_server_mschapv2.c
(15.1 KB)
📄
eap_server_pax.c
(15.42 KB)
📄
eap_server_peap.c
(36.17 KB)
📄
eap_server_psk.c
(12.8 KB)
📄
eap_server_pwd.c
(27.15 KB)
📄
eap_server_sake.c
(13 KB)
📄
eap_server_sim.c
(23.77 KB)
📄
eap_server_teap.c
(50.2 KB)
📄
eap_server_tls.c
(12.43 KB)
📄
eap_server_tls_common.c
(13.35 KB)
📄
eap_server_tnc.c
(13.42 KB)
📄
eap_server_ttls.c
(35.64 KB)
📄
eap_server_vendor_test.c
(3.87 KB)
📄
eap_server_wsc.c
(12.29 KB)
📄
eap_sim_db.c
(40.59 KB)
📄
eap_sim_db.h
(2.8 KB)
📄
eap_tls_common.h
(2.87 KB)
📄
ikev2.c
(29.55 KB)
📄
ikev2.h
(1.39 KB)
📄
tncs.c
(26.74 KB)
📄
tncs.h
(1.18 KB)
Editing: eap_server_gtc.c
/* * hostapd / EAP-GTC (RFC 3748) * Copyright (c) 2004-2006, 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 "eap_i.h" struct eap_gtc_data { enum { CONTINUE, SUCCESS, FAILURE } state; int prefix; }; static void * eap_gtc_init(struct eap_sm *sm) { struct eap_gtc_data *data; data = os_zalloc(sizeof(*data)); if (data == NULL) return NULL; data->state = CONTINUE; #ifdef EAP_SERVER_FAST if (sm->m && sm->m->vendor == EAP_VENDOR_IETF && sm->m->method == EAP_TYPE_FAST) { wpa_printf(MSG_DEBUG, "EAP-GTC: EAP-FAST tunnel - use prefix " "with challenge/response"); data->prefix = 1; } #endif /* EAP_SERVER_FAST */ return data; } static void eap_gtc_reset(struct eap_sm *sm, void *priv) { struct eap_gtc_data *data = priv; os_free(data); } static struct wpabuf * eap_gtc_buildReq(struct eap_sm *sm, void *priv, u8 id) { struct eap_gtc_data *data = priv; struct wpabuf *req; char *msg; size_t msg_len; msg = data->prefix ? "CHALLENGE=Password" : "Password"; msg_len = os_strlen(msg); req = eap_msg_alloc(EAP_VENDOR_IETF, EAP_TYPE_GTC, msg_len, EAP_CODE_REQUEST, id); if (req == NULL) { wpa_printf(MSG_ERROR, "EAP-GTC: Failed to allocate memory for " "request"); data->state = FAILURE; return NULL; } wpabuf_put_data(req, msg, msg_len); data->state = CONTINUE; return req; } static Boolean eap_gtc_check(struct eap_sm *sm, void *priv, struct wpabuf *respData) { const u8 *pos; size_t len; pos = eap_hdr_validate(EAP_VENDOR_IETF, EAP_TYPE_GTC, respData, &len); if (pos == NULL || len < 1) { wpa_printf(MSG_INFO, "EAP-GTC: Invalid frame"); return TRUE; } return FALSE; } static void eap_gtc_process(struct eap_sm *sm, void *priv, struct wpabuf *respData) { struct eap_gtc_data *data = priv; const u8 *pos; size_t rlen; pos = eap_hdr_validate(EAP_VENDOR_IETF, EAP_TYPE_GTC, respData, &rlen); if (pos == NULL || rlen < 1) return; /* Should not happen - frame already validated */ wpa_hexdump_ascii_key(MSG_MSGDUMP, "EAP-GTC: Response", pos, rlen); #ifdef EAP_SERVER_FAST if (data->prefix) { const u8 *pos2, *end; /* "RESPONSE=<user>\0<password>" */ if (rlen < 10) { wpa_printf(MSG_DEBUG, "EAP-GTC: Too short response " "for EAP-FAST prefix"); data->state = FAILURE; return; } end = pos + rlen; pos += 9; pos2 = pos; while (pos2 < end && *pos2) pos2++; if (pos2 == end) { wpa_printf(MSG_DEBUG, "EAP-GTC: No password in " "response to EAP-FAST prefix"); data->state = FAILURE; return; } wpa_hexdump_ascii(MSG_MSGDUMP, "EAP-GTC: Response user", pos, pos2 - pos); if (sm->identity && sm->require_identity_match && (pos2 - pos != (int) sm->identity_len || os_memcmp(pos, sm->identity, sm->identity_len))) { wpa_printf(MSG_DEBUG, "EAP-GTC: Phase 2 Identity did " "not match with required Identity"); wpa_hexdump_ascii(MSG_MSGDUMP, "EAP-GTC: Expected " "identity", sm->identity, sm->identity_len); data->state = FAILURE; return; } else { os_free(sm->identity); sm->identity_len = pos2 - pos; sm->identity = os_memdup(pos, sm->identity_len); if (sm->identity == NULL) { data->state = FAILURE; return; } } if (eap_user_get(sm, sm->identity, sm->identity_len, 1) != 0) { wpa_hexdump_ascii(MSG_DEBUG, "EAP-GTC: Phase2 " "Identity not found in the user " "database", sm->identity, sm->identity_len); data->state = FAILURE; return; } pos = pos2 + 1; rlen = end - pos; wpa_hexdump_ascii_key(MSG_MSGDUMP, "EAP-GTC: Response password", pos, rlen); } #endif /* EAP_SERVER_FAST */ if (sm->user == NULL || sm->user->password == NULL || sm->user->password_hash) { wpa_printf(MSG_INFO, "EAP-GTC: Plaintext password not " "configured"); data->state = FAILURE; return; } if (rlen != sm->user->password_len || os_memcmp_const(pos, sm->user->password, rlen) != 0) { wpa_printf(MSG_DEBUG, "EAP-GTC: Done - Failure"); data->state = FAILURE; } else { wpa_printf(MSG_DEBUG, "EAP-GTC: Done - Success"); data->state = SUCCESS; } } static Boolean eap_gtc_isDone(struct eap_sm *sm, void *priv) { struct eap_gtc_data *data = priv; return data->state != CONTINUE; } static Boolean eap_gtc_isSuccess(struct eap_sm *sm, void *priv) { struct eap_gtc_data *data = priv; return data->state == SUCCESS; } int eap_server_gtc_register(void) { struct eap_method *eap; eap = eap_server_method_alloc(EAP_SERVER_METHOD_INTERFACE_VERSION, EAP_VENDOR_IETF, EAP_TYPE_GTC, "GTC"); if (eap == NULL) return -1; eap->init = eap_gtc_init; eap->reset = eap_gtc_reset; eap->buildReq = eap_gtc_buildReq; eap->check = eap_gtc_check; eap->process = eap_gtc_process; eap->isDone = eap_gtc_isDone; eap->isSuccess = eap_gtc_isSuccess; return eap_server_method_register(eap); }
Upload File
Create Folder