EAP-GPSK server: Use configured server identity

Signed-hostap: Jouni Malinen <j@w1.fi>
This commit is contained in:
Jouni Malinen 2013-07-06 18:37:12 +03:00
parent 67fe933d40
commit 8f89d828b1

View file

@ -26,8 +26,6 @@ struct eap_gpsk_data {
size_t pk_len; size_t pk_len;
u8 *id_peer; u8 *id_peer;
size_t id_peer_len; size_t id_peer_len;
u8 *id_server;
size_t id_server_len;
#define MAX_NUM_CSUITES 2 #define MAX_NUM_CSUITES 2
struct eap_gpsk_csuite csuite_list[MAX_NUM_CSUITES]; struct eap_gpsk_csuite csuite_list[MAX_NUM_CSUITES];
size_t csuite_count; size_t csuite_count;
@ -71,11 +69,6 @@ static void * eap_gpsk_init(struct eap_sm *sm)
return NULL; return NULL;
data->state = GPSK_1; data->state = GPSK_1;
/* TODO: add support for configuring ID_Server */
data->id_server = (u8 *) os_strdup("hostapd");
if (data->id_server)
data->id_server_len = os_strlen((char *) data->id_server);
data->csuite_count = 0; data->csuite_count = 0;
if (eap_gpsk_supported_ciphersuite(EAP_GPSK_VENDOR_IETF, if (eap_gpsk_supported_ciphersuite(EAP_GPSK_VENDOR_IETF,
EAP_GPSK_CIPHER_AES)) { EAP_GPSK_CIPHER_AES)) {
@ -101,7 +94,6 @@ static void * eap_gpsk_init(struct eap_sm *sm)
static void eap_gpsk_reset(struct eap_sm *sm, void *priv) static void eap_gpsk_reset(struct eap_sm *sm, void *priv)
{ {
struct eap_gpsk_data *data = priv; struct eap_gpsk_data *data = priv;
os_free(data->id_server);
os_free(data->id_peer); os_free(data->id_peer);
os_free(data); os_free(data);
} }
@ -123,7 +115,7 @@ static struct wpabuf * eap_gpsk_build_gpsk_1(struct eap_sm *sm,
wpa_hexdump(MSG_MSGDUMP, "EAP-GPSK: RAND_Server", wpa_hexdump(MSG_MSGDUMP, "EAP-GPSK: RAND_Server",
data->rand_server, EAP_GPSK_RAND_LEN); data->rand_server, EAP_GPSK_RAND_LEN);
len = 1 + 2 + data->id_server_len + EAP_GPSK_RAND_LEN + 2 + len = 1 + 2 + sm->server_id_len + EAP_GPSK_RAND_LEN + 2 +
data->csuite_count * sizeof(struct eap_gpsk_csuite); data->csuite_count * sizeof(struct eap_gpsk_csuite);
req = eap_msg_alloc(EAP_VENDOR_IETF, EAP_TYPE_GPSK, len, req = eap_msg_alloc(EAP_VENDOR_IETF, EAP_TYPE_GPSK, len,
EAP_CODE_REQUEST, id); EAP_CODE_REQUEST, id);
@ -135,8 +127,8 @@ static struct wpabuf * eap_gpsk_build_gpsk_1(struct eap_sm *sm,
} }
wpabuf_put_u8(req, EAP_GPSK_OPCODE_GPSK_1); wpabuf_put_u8(req, EAP_GPSK_OPCODE_GPSK_1);
wpabuf_put_be16(req, data->id_server_len); wpabuf_put_be16(req, sm->server_id_len);
wpabuf_put_data(req, data->id_server, data->id_server_len); wpabuf_put_data(req, sm->server_id, sm->server_id_len);
wpabuf_put_data(req, data->rand_server, EAP_GPSK_RAND_LEN); wpabuf_put_data(req, data->rand_server, EAP_GPSK_RAND_LEN);
wpabuf_put_be16(req, wpabuf_put_be16(req,
data->csuite_count * sizeof(struct eap_gpsk_csuite)); data->csuite_count * sizeof(struct eap_gpsk_csuite));
@ -158,7 +150,7 @@ static struct wpabuf * eap_gpsk_build_gpsk_3(struct eap_sm *sm,
wpa_printf(MSG_DEBUG, "EAP-GPSK: Request/GPSK-3"); wpa_printf(MSG_DEBUG, "EAP-GPSK: Request/GPSK-3");
miclen = eap_gpsk_mic_len(data->vendor, data->specifier); miclen = eap_gpsk_mic_len(data->vendor, data->specifier);
len = 1 + 2 * EAP_GPSK_RAND_LEN + 2 + data->id_server_len + len = 1 + 2 * EAP_GPSK_RAND_LEN + 2 + sm->server_id_len +
sizeof(struct eap_gpsk_csuite) + 2 + miclen; sizeof(struct eap_gpsk_csuite) + 2 + miclen;
req = eap_msg_alloc(EAP_VENDOR_IETF, EAP_TYPE_GPSK, len, req = eap_msg_alloc(EAP_VENDOR_IETF, EAP_TYPE_GPSK, len,
EAP_CODE_REQUEST, id); EAP_CODE_REQUEST, id);
@ -174,8 +166,8 @@ static struct wpabuf * eap_gpsk_build_gpsk_3(struct eap_sm *sm,
wpabuf_put_data(req, data->rand_peer, EAP_GPSK_RAND_LEN); wpabuf_put_data(req, data->rand_peer, EAP_GPSK_RAND_LEN);
wpabuf_put_data(req, data->rand_server, EAP_GPSK_RAND_LEN); wpabuf_put_data(req, data->rand_server, EAP_GPSK_RAND_LEN);
wpabuf_put_be16(req, data->id_server_len); wpabuf_put_be16(req, sm->server_id_len);
wpabuf_put_data(req, data->id_server, data->id_server_len); wpabuf_put_data(req, sm->server_id, sm->server_id_len);
csuite = wpabuf_put(req, sizeof(*csuite)); csuite = wpabuf_put(req, sizeof(*csuite));
WPA_PUT_BE32(csuite->vendor, data->vendor); WPA_PUT_BE32(csuite->vendor, data->vendor);
WPA_PUT_BE16(csuite->specifier, data->specifier); WPA_PUT_BE16(csuite->specifier, data->specifier);
@ -301,8 +293,8 @@ static void eap_gpsk_process_gpsk_2(struct eap_sm *sm,
eap_gpsk_state(data, FAILURE); eap_gpsk_state(data, FAILURE);
return; return;
} }
if (alen != data->id_server_len || if (alen != sm->server_id_len ||
os_memcmp(pos, data->id_server, alen) != 0) { os_memcmp(pos, sm->server_id, alen) != 0) {
wpa_printf(MSG_DEBUG, "EAP-GPSK: ID_Server in GPSK-1 and " wpa_printf(MSG_DEBUG, "EAP-GPSK: ID_Server in GPSK-1 and "
"GPSK-2 did not match"); "GPSK-2 did not match");
eap_gpsk_state(data, FAILURE); eap_gpsk_state(data, FAILURE);
@ -416,7 +408,7 @@ static void eap_gpsk_process_gpsk_2(struct eap_sm *sm,
data->vendor, data->specifier, data->vendor, data->specifier,
data->rand_peer, data->rand_server, data->rand_peer, data->rand_server,
data->id_peer, data->id_peer_len, data->id_peer, data->id_peer_len,
data->id_server, data->id_server_len, sm->server_id, sm->server_id_len,
data->msk, data->emsk, data->msk, data->emsk,
data->sk, &data->sk_len, data->sk, &data->sk_len,
data->pk, &data->pk_len) < 0) { data->pk, &data->pk_len) < 0) {