2 * EAP-FAST server (RFC 4851)
3 * Copyright (c) 2004-2008, Jouni Malinen <j@w1.fi>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
9 * Alternatively, this software may be distributed under the terms of BSD
12 * See README and COPYING for more details.
21 #include "eap_tls_common.h"
23 #include "eap_common/eap_tlv_common.h"
24 #include "eap_common/eap_fast_common.h"
27 static void eap_fast_reset(struct eap_sm *sm, void *priv);
30 /* Private PAC-Opaque TLV types */
31 #define PAC_OPAQUE_TYPE_PAD 0
32 #define PAC_OPAQUE_TYPE_KEY 1
33 #define PAC_OPAQUE_TYPE_LIFETIME 2
34 #define PAC_OPAQUE_TYPE_IDENTITY 3
36 struct eap_fast_data {
37 struct eap_ssl_data ssl;
39 START, PHASE1, PHASE2_START, PHASE2_ID, PHASE2_METHOD,
40 CRYPTO_BINDING, REQUEST_PAC, SUCCESS, FAILURE
44 const struct eap_method *phase2_method;
49 u8 crypto_binding_nonce[32];
52 struct eap_fast_key_block_provisioning *key_block_p;
54 u8 simck[EAP_FAST_SIMCK_LEN];
55 u8 cmk[EAP_FAST_CMK_LEN];
58 u8 pac_opaque_encr[16];
63 int anon_provisioning;
64 int send_new_pac; /* server triggered re-keying of Tunnel PAC */
65 struct wpabuf *pending_phase2_resp;
66 u8 *identity; /* from PAC-Opaque */
72 int pac_key_refresh_time;
76 static const char * eap_fast_state_txt(int state)
84 return "PHASE2_START";
88 return "PHASE2_METHOD";
90 return "CRYPTO_BINDING";
103 static void eap_fast_state(struct eap_fast_data *data, int state)
105 wpa_printf(MSG_DEBUG, "EAP-FAST: %s -> %s",
106 eap_fast_state_txt(data->state),
107 eap_fast_state_txt(state));
112 static EapType eap_fast_req_failure(struct eap_sm *sm,
113 struct eap_fast_data *data)
115 /* TODO: send Result TLV(FAILURE) */
116 eap_fast_state(data, FAILURE);
117 return EAP_TYPE_NONE;
121 static int eap_fast_session_ticket_cb(void *ctx, const u8 *ticket, size_t len,
122 const u8 *client_random,
123 const u8 *server_random,
126 struct eap_fast_data *data = ctx;
127 const u8 *pac_opaque;
128 size_t pac_opaque_len;
129 u8 *buf, *pos, *end, *pac_key = NULL;
130 os_time_t lifetime = 0;
133 size_t identity_len = 0;
135 wpa_printf(MSG_DEBUG, "EAP-FAST: SessionTicket callback");
136 wpa_hexdump(MSG_DEBUG, "EAP-FAST: SessionTicket (PAC-Opaque)",
139 if (len < 4 || WPA_GET_BE16(ticket) != PAC_TYPE_PAC_OPAQUE) {
140 wpa_printf(MSG_DEBUG, "EAP-FAST: Ignore invalid "
145 pac_opaque_len = WPA_GET_BE16(ticket + 2);
146 pac_opaque = ticket + 4;
147 if (pac_opaque_len < 8 || pac_opaque_len % 8 ||
148 pac_opaque_len > len - 4) {
149 wpa_printf(MSG_DEBUG, "EAP-FAST: Ignore invalid PAC-Opaque "
150 "(len=%lu left=%lu)",
151 (unsigned long) pac_opaque_len,
152 (unsigned long) len);
155 wpa_hexdump(MSG_DEBUG, "EAP-FAST: Received PAC-Opaque",
156 pac_opaque, pac_opaque_len);
158 buf = os_malloc(pac_opaque_len - 8);
160 wpa_printf(MSG_DEBUG, "EAP-FAST: Failed to allocate memory "
161 "for decrypting PAC-Opaque");
165 if (aes_unwrap(data->pac_opaque_encr, (pac_opaque_len - 8) / 8,
166 pac_opaque, buf) < 0) {
167 wpa_printf(MSG_DEBUG, "EAP-FAST: Failed to decrypt "
171 * This may have been caused by server changing the PAC-Opaque
172 * encryption key, so just ignore this PAC-Opaque instead of
173 * failing the authentication completely. Provisioning can now
174 * be used to provision a new PAC.
179 end = buf + pac_opaque_len - 8;
180 wpa_hexdump_key(MSG_DEBUG, "EAP-FAST: Decrypted PAC-Opaque",
184 while (pos + 1 < end) {
185 if (pos + 2 + pos[1] > end)
189 case PAC_OPAQUE_TYPE_PAD:
192 case PAC_OPAQUE_TYPE_KEY:
193 if (pos[1] != EAP_FAST_PAC_KEY_LEN) {
194 wpa_printf(MSG_DEBUG, "EAP-FAST: Invalid "
195 "PAC-Key length %d", pos[1]);
200 wpa_hexdump_key(MSG_DEBUG, "EAP-FAST: PAC-Key from "
201 "decrypted PAC-Opaque",
202 pac_key, EAP_FAST_PAC_KEY_LEN);
204 case PAC_OPAQUE_TYPE_LIFETIME:
206 wpa_printf(MSG_DEBUG, "EAP-FAST: Invalid "
207 "PAC-Key lifetime length %d",
212 lifetime = WPA_GET_BE32(pos + 2);
214 case PAC_OPAQUE_TYPE_IDENTITY:
216 identity_len = pos[1];
223 if (pac_key == NULL) {
224 wpa_printf(MSG_DEBUG, "EAP-FAST: No PAC-Key included in "
231 wpa_hexdump_ascii(MSG_DEBUG, "EAP-FAST: Identity from "
232 "PAC-Opaque", identity, identity_len);
233 os_free(data->identity);
234 data->identity = os_malloc(identity_len);
235 if (data->identity) {
236 os_memcpy(data->identity, identity, identity_len);
237 data->identity_len = identity_len;
241 if (os_get_time(&now) < 0 || lifetime <= 0 || now.sec > lifetime) {
242 wpa_printf(MSG_DEBUG, "EAP-FAST: PAC-Key not valid anymore "
243 "(lifetime=%ld now=%ld)", lifetime, now.sec);
244 data->send_new_pac = 2;
246 * Allow PAC to be used to allow a PAC update with some level
247 * of server authentication (i.e., do not fall back to full TLS
248 * handshake since we cannot be sure that the peer would be
249 * able to validate server certificate now). However, reject
250 * the authentication since the PAC was not valid anymore. Peer
251 * can connect again with the newly provisioned PAC after this.
253 } else if (lifetime - now.sec < data->pac_key_refresh_time) {
254 wpa_printf(MSG_DEBUG, "EAP-FAST: PAC-Key soft timeout; send "
255 "an update if authentication succeeds");
256 data->send_new_pac = 1;
259 eap_fast_derive_master_secret(pac_key, server_random, client_random,
268 static void eap_fast_derive_key_auth(struct eap_sm *sm,
269 struct eap_fast_data *data)
273 /* RFC 4851, Section 5.1:
274 * Extra key material after TLS key_block: session_key_seed[40]
277 sks = eap_fast_derive_key(sm->ssl_ctx, data->ssl.conn, "key expansion",
280 wpa_printf(MSG_DEBUG, "EAP-FAST: Failed to derive "
286 * RFC 4851, Section 5.2:
287 * S-IMCK[0] = session_key_seed
289 wpa_hexdump_key(MSG_DEBUG,
290 "EAP-FAST: session_key_seed (SKS = S-IMCK[0])",
291 sks, EAP_FAST_SKS_LEN);
293 os_memcpy(data->simck, sks, EAP_FAST_SIMCK_LEN);
298 static void eap_fast_derive_key_provisioning(struct eap_sm *sm,
299 struct eap_fast_data *data)
301 os_free(data->key_block_p);
302 data->key_block_p = (struct eap_fast_key_block_provisioning *)
303 eap_fast_derive_key(sm->ssl_ctx, data->ssl.conn,
305 sizeof(*data->key_block_p));
306 if (data->key_block_p == NULL) {
307 wpa_printf(MSG_DEBUG, "EAP-FAST: Failed to derive key block");
311 * RFC 4851, Section 5.2:
312 * S-IMCK[0] = session_key_seed
314 wpa_hexdump_key(MSG_DEBUG,
315 "EAP-FAST: session_key_seed (SKS = S-IMCK[0])",
316 data->key_block_p->session_key_seed,
317 sizeof(data->key_block_p->session_key_seed));
319 os_memcpy(data->simck, data->key_block_p->session_key_seed,
321 wpa_hexdump_key(MSG_DEBUG, "EAP-FAST: server_challenge",
322 data->key_block_p->server_challenge,
323 sizeof(data->key_block_p->server_challenge));
324 wpa_hexdump_key(MSG_DEBUG, "EAP-FAST: client_challenge",
325 data->key_block_p->client_challenge,
326 sizeof(data->key_block_p->client_challenge));
330 static int eap_fast_get_phase2_key(struct eap_sm *sm,
331 struct eap_fast_data *data,
332 u8 *isk, size_t isk_len)
337 os_memset(isk, 0, isk_len);
339 if (data->phase2_method == NULL || data->phase2_priv == NULL) {
340 wpa_printf(MSG_DEBUG, "EAP-FAST: Phase 2 method not "
345 if (data->phase2_method->getKey == NULL)
348 if ((key = data->phase2_method->getKey(sm, data->phase2_priv,
349 &key_len)) == NULL) {
350 wpa_printf(MSG_DEBUG, "EAP-FAST: Could not get key material "
355 if (key_len > isk_len)
357 os_memcpy(isk, key, key_len);
364 static int eap_fast_update_icmk(struct eap_sm *sm, struct eap_fast_data *data)
366 u8 isk[32], imck[60];
368 wpa_printf(MSG_DEBUG, "EAP-FAST: Deriving ICMK[%d] (S-IMCK and CMK)",
369 data->simck_idx + 1);
372 * RFC 4851, Section 5.2:
373 * IMCK[j] = T-PRF(S-IMCK[j-1], "Inner Methods Compound Keys",
375 * S-IMCK[j] = first 40 octets of IMCK[j]
376 * CMK[j] = last 20 octets of IMCK[j]
379 if (eap_fast_get_phase2_key(sm, data, isk, sizeof(isk)) < 0)
381 wpa_hexdump_key(MSG_MSGDUMP, "EAP-FAST: ISK[j]", isk, sizeof(isk));
382 sha1_t_prf(data->simck, EAP_FAST_SIMCK_LEN,
383 "Inner Methods Compound Keys",
384 isk, sizeof(isk), imck, sizeof(imck));
386 os_memcpy(data->simck, imck, EAP_FAST_SIMCK_LEN);
387 wpa_hexdump_key(MSG_MSGDUMP, "EAP-FAST: S-IMCK[j]",
388 data->simck, EAP_FAST_SIMCK_LEN);
389 os_memcpy(data->cmk, imck + EAP_FAST_SIMCK_LEN, EAP_FAST_CMK_LEN);
390 wpa_hexdump_key(MSG_MSGDUMP, "EAP-FAST: CMK[j]",
391 data->cmk, EAP_FAST_CMK_LEN);
397 static void * eap_fast_init(struct eap_sm *sm)
399 struct eap_fast_data *data;
401 TLS_CIPHER_ANON_DH_AES128_SHA,
402 TLS_CIPHER_AES128_SHA,
403 TLS_CIPHER_RSA_DHE_AES128_SHA,
408 data = os_zalloc(sizeof(*data));
411 data->fast_version = EAP_FAST_VERSION;
412 data->force_version = -1;
413 if (sm->user && sm->user->force_version >= 0) {
414 data->force_version = sm->user->force_version;
415 wpa_printf(MSG_DEBUG, "EAP-FAST: forcing version %d",
416 data->force_version);
417 data->fast_version = data->force_version;
421 if (eap_server_tls_ssl_init(sm, &data->ssl, 0)) {
422 wpa_printf(MSG_INFO, "EAP-FAST: Failed to initialize SSL.");
423 eap_fast_reset(sm, data);
427 if (tls_connection_set_cipher_list(sm->ssl_ctx, data->ssl.conn,
429 wpa_printf(MSG_INFO, "EAP-FAST: Failed to set TLS cipher "
431 eap_fast_reset(sm, data);
435 if (tls_connection_set_session_ticket_cb(sm->ssl_ctx, data->ssl.conn,
436 eap_fast_session_ticket_cb,
438 wpa_printf(MSG_INFO, "EAP-FAST: Failed to set SessionTicket "
440 eap_fast_reset(sm, data);
444 if (sm->pac_opaque_encr_key == NULL) {
445 wpa_printf(MSG_INFO, "EAP-FAST: No PAC-Opaque encryption key "
447 eap_fast_reset(sm, data);
450 os_memcpy(data->pac_opaque_encr, sm->pac_opaque_encr_key,
451 sizeof(data->pac_opaque_encr));
453 if (sm->eap_fast_a_id == NULL) {
454 wpa_printf(MSG_INFO, "EAP-FAST: No A-ID configured");
455 eap_fast_reset(sm, data);
458 data->srv_id = os_malloc(sm->eap_fast_a_id_len);
459 if (data->srv_id == NULL) {
460 eap_fast_reset(sm, data);
463 os_memcpy(data->srv_id, sm->eap_fast_a_id, sm->eap_fast_a_id_len);
464 data->srv_id_len = sm->eap_fast_a_id_len;
466 if (sm->eap_fast_a_id_info == NULL) {
467 wpa_printf(MSG_INFO, "EAP-FAST: No A-ID-Info configured");
468 eap_fast_reset(sm, data);
471 data->srv_id_info = os_strdup(sm->eap_fast_a_id_info);
472 if (data->srv_id_info == NULL) {
473 eap_fast_reset(sm, data);
477 /* PAC-Key lifetime in seconds (hard limit) */
478 data->pac_key_lifetime = sm->pac_key_lifetime;
481 * PAC-Key refresh time in seconds (soft limit on remaining hard
482 * limit). The server will generate a new PAC-Key when this number of
483 * seconds (or fewer) of the lifetime remains.
485 data->pac_key_refresh_time = sm->pac_key_refresh_time;
491 static void eap_fast_reset(struct eap_sm *sm, void *priv)
493 struct eap_fast_data *data = priv;
496 if (data->phase2_priv && data->phase2_method)
497 data->phase2_method->reset(sm, data->phase2_priv);
498 eap_server_tls_ssl_deinit(sm, &data->ssl);
499 os_free(data->srv_id);
500 os_free(data->srv_id_info);
501 os_free(data->key_block_p);
502 wpabuf_free(data->pending_phase2_resp);
503 os_free(data->identity);
508 static struct wpabuf * eap_fast_build_start(struct eap_sm *sm,
509 struct eap_fast_data *data, u8 id)
513 req = eap_msg_alloc(EAP_VENDOR_IETF, EAP_TYPE_FAST,
514 1 + sizeof(struct pac_tlv_hdr) + data->srv_id_len,
515 EAP_CODE_REQUEST, id);
517 wpa_printf(MSG_ERROR, "EAP-FAST: Failed to allocate memory for"
519 eap_fast_state(data, FAILURE);
523 wpabuf_put_u8(req, EAP_TLS_FLAGS_START | data->fast_version);
525 /* RFC 4851, 4.1.1. Authority ID Data */
526 eap_fast_put_tlv(req, PAC_TYPE_A_ID, data->srv_id, data->srv_id_len);
528 eap_fast_state(data, PHASE1);
534 static int eap_fast_phase1_done(struct eap_sm *sm, struct eap_fast_data *data)
538 wpa_printf(MSG_DEBUG, "EAP-FAST: Phase1 done, starting Phase2");
540 if (tls_get_cipher(sm->ssl_ctx, data->ssl.conn, cipher, sizeof(cipher))
542 wpa_printf(MSG_DEBUG, "EAP-FAST: Failed to get cipher "
544 eap_fast_state(data, FAILURE);
547 data->anon_provisioning = os_strstr(cipher, "ADH") != NULL;
549 if (data->anon_provisioning) {
550 wpa_printf(MSG_DEBUG, "EAP-FAST: Anonymous provisioning");
551 eap_fast_derive_key_provisioning(sm, data);
553 eap_fast_derive_key_auth(sm, data);
555 eap_fast_state(data, PHASE2_START);
561 static struct wpabuf * eap_fast_build_phase2_req(struct eap_sm *sm,
562 struct eap_fast_data *data,
567 if (data->phase2_priv == NULL) {
568 wpa_printf(MSG_DEBUG, "EAP-FAST: Phase 2 method not "
572 req = data->phase2_method->buildReq(sm, data->phase2_priv, id);
576 wpa_hexdump_buf_key(MSG_MSGDUMP, "EAP-FAST: Phase 2 EAP-Request", req);
577 return eap_fast_tlv_eap_payload(req);
581 static struct wpabuf * eap_fast_build_crypto_binding(
582 struct eap_sm *sm, struct eap_fast_data *data)
585 struct eap_tlv_result_tlv *result;
586 struct eap_tlv_crypto_binding_tlv *binding;
588 buf = wpabuf_alloc(2 * sizeof(*result) + sizeof(*binding));
592 if (data->send_new_pac || data->anon_provisioning ||
594 data->final_result = 0;
596 data->final_result = 1;
598 if (!data->final_result || data->eap_seq > 1) {
599 /* Intermediate-Result */
600 wpa_printf(MSG_DEBUG, "EAP-FAST: Add Intermediate-Result TLV "
602 result = wpabuf_put(buf, sizeof(*result));
603 result->tlv_type = host_to_be16(
604 EAP_TLV_TYPE_MANDATORY |
605 EAP_TLV_INTERMEDIATE_RESULT_TLV);
606 result->length = host_to_be16(2);
607 result->status = host_to_be16(EAP_TLV_RESULT_SUCCESS);
610 if (data->final_result) {
612 wpa_printf(MSG_DEBUG, "EAP-FAST: Add Result TLV "
614 result = wpabuf_put(buf, sizeof(*result));
615 result->tlv_type = host_to_be16(EAP_TLV_TYPE_MANDATORY |
617 result->length = host_to_be16(2);
618 result->status = host_to_be16(EAP_TLV_RESULT_SUCCESS);
621 /* Crypto-Binding TLV */
622 binding = wpabuf_put(buf, sizeof(*binding));
623 binding->tlv_type = host_to_be16(EAP_TLV_TYPE_MANDATORY |
624 EAP_TLV_CRYPTO_BINDING_TLV);
625 binding->length = host_to_be16(sizeof(*binding) -
626 sizeof(struct eap_tlv_hdr));
627 binding->version = EAP_FAST_VERSION;
628 binding->received_version = data->peer_version;
629 binding->subtype = EAP_TLV_CRYPTO_BINDING_SUBTYPE_REQUEST;
630 if (os_get_random(binding->nonce, sizeof(binding->nonce)) < 0) {
636 * RFC 4851, Section 4.2.8:
637 * The nonce in a request MUST have its least significant bit set to 0.
639 binding->nonce[sizeof(binding->nonce) - 1] &= ~0x01;
641 os_memcpy(data->crypto_binding_nonce, binding->nonce,
642 sizeof(binding->nonce));
645 * RFC 4851, Section 5.3:
647 * Compound-MAC = HMAC-SHA1( CMK, Crypto-Binding TLV )
650 hmac_sha1(data->cmk, EAP_FAST_CMK_LEN,
651 (u8 *) binding, sizeof(*binding),
652 binding->compound_mac);
654 wpa_printf(MSG_DEBUG, "EAP-FAST: Add Crypto-Binding TLV: Version %d "
655 "Received Version %d SubType %d",
656 binding->version, binding->received_version,
658 wpa_hexdump(MSG_MSGDUMP, "EAP-FAST: NONCE",
659 binding->nonce, sizeof(binding->nonce));
660 wpa_hexdump(MSG_MSGDUMP, "EAP-FAST: Compound MAC",
661 binding->compound_mac, sizeof(binding->compound_mac));
667 static struct wpabuf * eap_fast_build_pac(struct eap_sm *sm,
668 struct eap_fast_data *data)
670 u8 pac_key[EAP_FAST_PAC_KEY_LEN];
671 u8 *pac_buf, *pac_opaque;
674 size_t buf_len, srv_id_info_len, pac_len;
675 struct eap_tlv_hdr *pac_tlv;
676 struct pac_tlv_hdr *pac_info;
677 struct eap_tlv_result_tlv *result;
680 if (os_get_random(pac_key, EAP_FAST_PAC_KEY_LEN) < 0 ||
681 os_get_time(&now) < 0)
683 wpa_hexdump_key(MSG_DEBUG, "EAP-FAST: Generated PAC-Key",
684 pac_key, EAP_FAST_PAC_KEY_LEN);
686 pac_len = (2 + EAP_FAST_PAC_KEY_LEN) + (2 + 4) +
687 (2 + sm->identity_len) + 8;
688 pac_buf = os_malloc(pac_len);
692 srv_id_info_len = os_strlen(data->srv_id_info);
695 *pos++ = PAC_OPAQUE_TYPE_KEY;
696 *pos++ = EAP_FAST_PAC_KEY_LEN;
697 os_memcpy(pos, pac_key, EAP_FAST_PAC_KEY_LEN);
698 pos += EAP_FAST_PAC_KEY_LEN;
700 *pos++ = PAC_OPAQUE_TYPE_LIFETIME;
702 WPA_PUT_BE32(pos, now.sec + data->pac_key_lifetime);
706 *pos++ = PAC_OPAQUE_TYPE_IDENTITY;
707 *pos++ = sm->identity_len;
708 os_memcpy(pos, sm->identity, sm->identity_len);
709 pos += sm->identity_len;
712 pac_len = pos - pac_buf;
713 while (pac_len % 8) {
714 *pos++ = PAC_OPAQUE_TYPE_PAD;
718 pac_opaque = os_malloc(pac_len + 8);
719 if (pac_opaque == NULL) {
723 if (aes_wrap(data->pac_opaque_encr, pac_len / 8, pac_buf,
732 wpa_hexdump(MSG_DEBUG, "EAP-FAST: PAC-Opaque",
733 pac_opaque, pac_len);
735 buf_len = sizeof(*pac_tlv) +
736 sizeof(struct pac_tlv_hdr) + EAP_FAST_PAC_KEY_LEN +
737 sizeof(struct pac_tlv_hdr) + pac_len +
738 data->srv_id_len + srv_id_info_len + 100 + sizeof(*result);
739 buf = wpabuf_alloc(buf_len);
746 wpa_printf(MSG_DEBUG, "EAP-FAST: Add Result TLV (status=SUCCESS)");
747 result = wpabuf_put(buf, sizeof(*result));
748 WPA_PUT_BE16((u8 *) &result->tlv_type,
749 EAP_TLV_TYPE_MANDATORY | EAP_TLV_RESULT_TLV);
750 WPA_PUT_BE16((u8 *) &result->length, 2);
751 WPA_PUT_BE16((u8 *) &result->status, EAP_TLV_RESULT_SUCCESS);
754 wpa_printf(MSG_DEBUG, "EAP-FAST: Add PAC TLV");
755 pac_tlv = wpabuf_put(buf, sizeof(*pac_tlv));
756 pac_tlv->tlv_type = host_to_be16(EAP_TLV_TYPE_MANDATORY |
760 eap_fast_put_tlv(buf, PAC_TYPE_PAC_KEY, pac_key, EAP_FAST_PAC_KEY_LEN);
763 eap_fast_put_tlv(buf, PAC_TYPE_PAC_OPAQUE, pac_opaque, pac_len);
767 pac_info = wpabuf_put(buf, sizeof(*pac_info));
768 pac_info->type = host_to_be16(PAC_TYPE_PAC_INFO);
770 /* PAC-Lifetime (inside PAC-Info) */
771 eap_fast_put_tlv_hdr(buf, PAC_TYPE_CRED_LIFETIME, 4);
772 wpabuf_put_be32(buf, now.sec + data->pac_key_lifetime);
774 /* A-ID (inside PAC-Info) */
775 eap_fast_put_tlv(buf, PAC_TYPE_A_ID, data->srv_id, data->srv_id_len);
777 /* Note: headers may be misaligned after A-ID */
779 /* A-ID-Info (inside PAC-Info) */
780 eap_fast_put_tlv(buf, PAC_TYPE_A_ID_INFO, data->srv_id_info,
783 /* PAC-Type (inside PAC-Info) */
784 eap_fast_put_tlv_hdr(buf, PAC_TYPE_PAC_TYPE, 2);
785 wpabuf_put_be16(buf, PAC_TYPE_TUNNEL_PAC);
787 /* Update PAC-Info and PAC TLV Length fields */
788 pos = wpabuf_put(buf, 0);
789 pac_info->len = host_to_be16(pos - (u8 *) (pac_info + 1));
790 pac_tlv->length = host_to_be16(pos - (u8 *) (pac_tlv + 1));
796 static struct wpabuf * eap_fast_buildReq(struct eap_sm *sm, void *priv, u8 id)
798 struct eap_fast_data *data = priv;
799 struct wpabuf *req = NULL;
802 if (data->ssl.state == FRAG_ACK) {
803 return eap_server_tls_build_ack(id, EAP_TYPE_FAST,
807 if (data->ssl.state == WAIT_FRAG_ACK) {
808 return eap_server_tls_build_msg(&data->ssl, EAP_TYPE_FAST,
809 data->fast_version, id);
812 switch (data->state) {
814 return eap_fast_build_start(sm, data, id);
816 if (tls_connection_established(sm->ssl_ctx, data->ssl.conn)) {
817 if (eap_fast_phase1_done(sm, data) < 0)
823 req = eap_fast_build_phase2_req(sm, data, id);
826 req = eap_fast_build_crypto_binding(sm, data);
827 if (data->phase2_method) {
829 * Include the start of the next EAP method in the
830 * sequence in the same message with Crypto-Binding to
834 eap = eap_fast_build_phase2_req(sm, data, id);
835 req = wpabuf_concat(req, eap);
836 eap_fast_state(data, PHASE2_METHOD);
840 req = eap_fast_build_pac(sm, data);
843 wpa_printf(MSG_DEBUG, "EAP-FAST: %s - unexpected state %d",
844 __func__, data->state);
849 wpa_hexdump_buf_key(MSG_DEBUG, "EAP-FAST: Encrypting Phase 2 "
851 encr = eap_server_tls_encrypt(sm, &data->ssl,
856 wpabuf_free(data->ssl.out_buf);
857 data->ssl.out_used = 0;
858 data->ssl.out_buf = encr;
861 return eap_server_tls_build_msg(&data->ssl, EAP_TYPE_FAST,
862 data->fast_version, id);
866 static Boolean eap_fast_check(struct eap_sm *sm, void *priv,
867 struct wpabuf *respData)
872 pos = eap_hdr_validate(EAP_VENDOR_IETF, EAP_TYPE_FAST, respData, &len);
873 if (pos == NULL || len < 1) {
874 wpa_printf(MSG_INFO, "EAP-FAST: Invalid frame");
882 static int eap_fast_phase2_init(struct eap_sm *sm, struct eap_fast_data *data,
885 if (data->phase2_priv && data->phase2_method) {
886 data->phase2_method->reset(sm, data->phase2_priv);
887 data->phase2_method = NULL;
888 data->phase2_priv = NULL;
890 data->phase2_method = eap_server_get_eap_method(EAP_VENDOR_IETF,
892 if (!data->phase2_method)
895 if (data->key_block_p) {
896 sm->auth_challenge = data->key_block_p->server_challenge;
897 sm->peer_challenge = data->key_block_p->client_challenge;
900 data->phase2_priv = data->phase2_method->init(sm);
902 sm->auth_challenge = NULL;
903 sm->peer_challenge = NULL;
905 return data->phase2_priv == NULL ? -1 : 0;
909 static void eap_fast_process_phase2_response(struct eap_sm *sm,
910 struct eap_fast_data *data,
911 u8 *in_data, size_t in_len)
913 u8 next_type = EAP_TYPE_NONE;
918 const struct eap_method *m = data->phase2_method;
919 void *priv = data->phase2_priv;
922 wpa_printf(MSG_DEBUG, "EAP-FAST: %s - Phase2 not "
923 "initialized?!", __func__);
927 hdr = (struct eap_hdr *) in_data;
928 pos = (u8 *) (hdr + 1);
930 if (in_len > sizeof(*hdr) && *pos == EAP_TYPE_NAK) {
931 left = in_len - sizeof(*hdr);
932 wpa_hexdump(MSG_DEBUG, "EAP-FAST: Phase2 type Nak'ed; "
933 "allowed types", pos + 1, left - 1);
935 if (m && m->vendor == EAP_VENDOR_IETF &&
936 m->method == EAP_TYPE_TNC) {
937 wpa_printf(MSG_DEBUG, "EAP-FAST: Peer Nak'ed required "
939 next_type = eap_fast_req_failure(sm, data);
940 eap_fast_phase2_init(sm, data, next_type);
944 eap_sm_process_nak(sm, pos + 1, left - 1);
945 if (sm->user && sm->user_eap_method_index < EAP_MAX_METHODS &&
946 sm->user->methods[sm->user_eap_method_index].method !=
948 next_type = sm->user->methods[
949 sm->user_eap_method_index++].method;
950 wpa_printf(MSG_DEBUG, "EAP-FAST: try EAP type %d",
953 next_type = eap_fast_req_failure(sm, data);
955 eap_fast_phase2_init(sm, data, next_type);
959 wpabuf_set(&buf, in_data, in_len);
961 if (m->check(sm, priv, &buf)) {
962 wpa_printf(MSG_DEBUG, "EAP-FAST: Phase2 check() asked to "
963 "ignore the packet");
964 next_type = eap_fast_req_failure(sm, data);
968 m->process(sm, priv, &buf);
970 if (!m->isDone(sm, priv))
973 if (!m->isSuccess(sm, priv)) {
974 wpa_printf(MSG_DEBUG, "EAP-FAST: Phase2 method failed");
975 next_type = eap_fast_req_failure(sm, data);
976 eap_fast_phase2_init(sm, data, next_type);
980 switch (data->state) {
982 if (eap_user_get(sm, sm->identity, sm->identity_len, 1) != 0) {
983 wpa_hexdump_ascii(MSG_DEBUG, "EAP-FAST: Phase2 "
984 "Identity not found in the user "
986 sm->identity, sm->identity_len);
987 next_type = eap_fast_req_failure(sm, data);
991 eap_fast_state(data, PHASE2_METHOD);
992 if (data->anon_provisioning) {
994 * Only EAP-MSCHAPv2 is allowed for anonymous
997 next_type = EAP_TYPE_MSCHAPV2;
998 sm->user_eap_method_index = 0;
1000 next_type = sm->user->methods[0].method;
1001 sm->user_eap_method_index = 1;
1003 wpa_printf(MSG_DEBUG, "EAP-FAST: try EAP type %d", next_type);
1006 case CRYPTO_BINDING:
1007 eap_fast_update_icmk(sm, data);
1008 eap_fast_state(data, CRYPTO_BINDING);
1010 next_type = EAP_TYPE_NONE;
1012 if (sm->tnc && !data->tnc_started) {
1013 wpa_printf(MSG_DEBUG, "EAP-FAST: Initialize TNC");
1014 next_type = EAP_TYPE_TNC;
1015 data->tnc_started = 1;
1017 #endif /* EAP_TNC */
1022 wpa_printf(MSG_DEBUG, "EAP-FAST: %s - unexpected state %d",
1023 __func__, data->state);
1027 eap_fast_phase2_init(sm, data, next_type);
1031 static void eap_fast_process_phase2_eap(struct eap_sm *sm,
1032 struct eap_fast_data *data,
1033 u8 *in_data, size_t in_len)
1035 struct eap_hdr *hdr;
1038 hdr = (struct eap_hdr *) in_data;
1039 if (in_len < (int) sizeof(*hdr)) {
1040 wpa_printf(MSG_INFO, "EAP-FAST: Too short Phase 2 "
1041 "EAP frame (len=%lu)", (unsigned long) in_len);
1042 eap_fast_req_failure(sm, data);
1045 len = be_to_host16(hdr->length);
1047 wpa_printf(MSG_INFO, "EAP-FAST: Length mismatch in "
1048 "Phase 2 EAP frame (len=%lu hdr->length=%lu)",
1049 (unsigned long) in_len, (unsigned long) len);
1050 eap_fast_req_failure(sm, data);
1053 wpa_printf(MSG_DEBUG, "EAP-FAST: Received Phase 2: code=%d "
1054 "identifier=%d length=%lu", hdr->code, hdr->identifier,
1055 (unsigned long) len);
1056 switch (hdr->code) {
1057 case EAP_CODE_RESPONSE:
1058 eap_fast_process_phase2_response(sm, data, (u8 *) hdr, len);
1061 wpa_printf(MSG_INFO, "EAP-FAST: Unexpected code=%d in "
1062 "Phase 2 EAP header", hdr->code);
1068 static int eap_fast_parse_tlvs(u8 *data, size_t data_len,
1069 struct eap_fast_tlv_parse *tlv)
1071 int mandatory, tlv_type, len, res;
1074 os_memset(tlv, 0, sizeof(*tlv));
1077 end = data + data_len;
1078 while (pos + 4 < end) {
1079 mandatory = pos[0] & 0x80;
1080 tlv_type = WPA_GET_BE16(pos) & 0x3fff;
1082 len = WPA_GET_BE16(pos);
1084 if (pos + len > end) {
1085 wpa_printf(MSG_INFO, "EAP-FAST: TLV overflow");
1088 wpa_printf(MSG_DEBUG, "EAP-FAST: Received Phase 2: "
1089 "TLV type %d length %d%s",
1090 tlv_type, len, mandatory ? " (mandatory)" : "");
1092 res = eap_fast_parse_tlv(tlv, tlv_type, pos, len);
1097 wpa_printf(MSG_DEBUG, "EAP-FAST: Nak unknown "
1098 "mandatory TLV type %d", tlv_type);
1099 /* TODO: generate Nak TLV */
1102 wpa_printf(MSG_DEBUG, "EAP-FAST: Ignored "
1103 "unknown optional TLV type %d",
1115 static int eap_fast_validate_crypto_binding(
1116 struct eap_fast_data *data, struct eap_tlv_crypto_binding_tlv *b,
1119 u8 cmac[SHA1_MAC_LEN];
1121 wpa_printf(MSG_DEBUG, "EAP-FAST: Reply Crypto-Binding TLV: "
1122 "Version %d Received Version %d SubType %d",
1123 b->version, b->received_version, b->subtype);
1124 wpa_hexdump(MSG_MSGDUMP, "EAP-FAST: NONCE",
1125 b->nonce, sizeof(b->nonce));
1126 wpa_hexdump(MSG_MSGDUMP, "EAP-FAST: Compound MAC",
1127 b->compound_mac, sizeof(b->compound_mac));
1129 if (b->version != EAP_FAST_VERSION ||
1130 b->received_version != EAP_FAST_VERSION) {
1131 wpa_printf(MSG_DEBUG, "EAP-FAST: Unexpected version "
1132 "in Crypto-Binding: version %d "
1133 "received_version %d", b->version,
1134 b->received_version);
1138 if (b->subtype != EAP_TLV_CRYPTO_BINDING_SUBTYPE_RESPONSE) {
1139 wpa_printf(MSG_DEBUG, "EAP-FAST: Unexpected subtype in "
1140 "Crypto-Binding: %d", b->subtype);
1144 if (os_memcmp(data->crypto_binding_nonce, b->nonce, 31) != 0 ||
1145 (data->crypto_binding_nonce[31] | 1) != b->nonce[31]) {
1146 wpa_printf(MSG_DEBUG, "EAP-FAST: Invalid nonce in "
1151 os_memcpy(cmac, b->compound_mac, sizeof(cmac));
1152 os_memset(b->compound_mac, 0, sizeof(cmac));
1153 wpa_hexdump(MSG_MSGDUMP, "EAP-FAST: Crypto-Binding TLV for "
1154 "Compound MAC calculation",
1155 (u8 *) b, bind_len);
1156 hmac_sha1(data->cmk, EAP_FAST_CMK_LEN, (u8 *) b, bind_len,
1158 if (os_memcmp(cmac, b->compound_mac, sizeof(cmac)) != 0) {
1159 wpa_hexdump(MSG_MSGDUMP,
1160 "EAP-FAST: Calculated Compound MAC",
1161 b->compound_mac, sizeof(cmac));
1162 wpa_printf(MSG_INFO, "EAP-FAST: Compound MAC did not "
1171 static int eap_fast_pac_type(u8 *pac, size_t len, u16 type)
1173 struct eap_tlv_pac_type_tlv *tlv;
1175 if (pac == NULL || len != sizeof(*tlv))
1178 tlv = (struct eap_tlv_pac_type_tlv *) pac;
1180 return be_to_host16(tlv->tlv_type) == PAC_TYPE_PAC_TYPE &&
1181 be_to_host16(tlv->length) == 2 &&
1182 be_to_host16(tlv->pac_type) == type;
1186 static void eap_fast_process_phase2_tlvs(struct eap_sm *sm,
1187 struct eap_fast_data *data,
1188 u8 *in_data, size_t in_len)
1190 struct eap_fast_tlv_parse tlv;
1191 int check_crypto_binding = data->state == CRYPTO_BINDING;
1193 if (eap_fast_parse_tlvs(in_data, in_len, &tlv) < 0) {
1194 wpa_printf(MSG_DEBUG, "EAP-FAST: Failed to parse received "
1199 if (tlv.result == EAP_TLV_RESULT_FAILURE) {
1200 wpa_printf(MSG_DEBUG, "EAP-FAST: Result TLV indicated "
1202 eap_fast_state(data, FAILURE);
1206 if (data->state == REQUEST_PAC) {
1208 if (tlv.pac == NULL || tlv.pac_len < 6) {
1209 wpa_printf(MSG_DEBUG, "EAP-FAST: No PAC "
1210 "Acknowledgement received");
1211 eap_fast_state(data, FAILURE);
1215 type = WPA_GET_BE16(tlv.pac);
1216 len = WPA_GET_BE16(tlv.pac + 2);
1217 res = WPA_GET_BE16(tlv.pac + 4);
1219 if (type != PAC_TYPE_PAC_ACKNOWLEDGEMENT || len != 2 ||
1220 res != EAP_TLV_RESULT_SUCCESS) {
1221 wpa_printf(MSG_DEBUG, "EAP-FAST: PAC TLV did not "
1222 "contain acknowledgement");
1223 eap_fast_state(data, FAILURE);
1227 wpa_printf(MSG_DEBUG, "EAP-FAST: PAC-Acknowledgement received "
1228 "- PAC provisioning succeeded");
1229 eap_fast_state(data, (data->anon_provisioning ||
1230 data->send_new_pac == 2) ?
1235 if (check_crypto_binding) {
1236 if (tlv.crypto_binding == NULL) {
1237 wpa_printf(MSG_DEBUG, "EAP-FAST: No Crypto-Binding "
1239 eap_fast_state(data, FAILURE);
1243 if (data->final_result &&
1244 tlv.result != EAP_TLV_RESULT_SUCCESS) {
1245 wpa_printf(MSG_DEBUG, "EAP-FAST: Crypto-Binding TLV "
1246 "without Success Result");
1247 eap_fast_state(data, FAILURE);
1251 if (!data->final_result &&
1252 tlv.iresult != EAP_TLV_RESULT_SUCCESS) {
1253 wpa_printf(MSG_DEBUG, "EAP-FAST: Crypto-Binding TLV "
1254 "without intermediate Success Result");
1255 eap_fast_state(data, FAILURE);
1259 if (eap_fast_validate_crypto_binding(data, tlv.crypto_binding,
1260 tlv.crypto_binding_len)) {
1261 eap_fast_state(data, FAILURE);
1265 wpa_printf(MSG_DEBUG, "EAP-FAST: Valid Crypto-Binding TLV "
1267 if (data->final_result) {
1268 wpa_printf(MSG_DEBUG, "EAP-FAST: Authentication "
1269 "completed successfully");
1272 if (data->anon_provisioning &&
1273 sm->eap_fast_prov != ANON_PROV &&
1274 sm->eap_fast_prov != BOTH_PROV) {
1275 wpa_printf(MSG_DEBUG, "EAP-FAST: Client is trying to "
1276 "use unauthenticated provisioning which is "
1278 eap_fast_state(data, FAILURE);
1282 if (sm->eap_fast_prov != AUTH_PROV &&
1283 sm->eap_fast_prov != BOTH_PROV &&
1284 tlv.request_action == EAP_TLV_ACTION_PROCESS_TLV &&
1285 eap_fast_pac_type(tlv.pac, tlv.pac_len,
1286 PAC_TYPE_TUNNEL_PAC)) {
1287 wpa_printf(MSG_DEBUG, "EAP-FAST: Client is trying to "
1288 "use authenticated provisioning which is "
1290 eap_fast_state(data, FAILURE);
1294 if (data->anon_provisioning ||
1295 (tlv.request_action == EAP_TLV_ACTION_PROCESS_TLV &&
1296 eap_fast_pac_type(tlv.pac, tlv.pac_len,
1297 PAC_TYPE_TUNNEL_PAC))) {
1298 wpa_printf(MSG_DEBUG, "EAP-FAST: Requested a new "
1300 eap_fast_state(data, REQUEST_PAC);
1301 } else if (data->send_new_pac) {
1302 wpa_printf(MSG_DEBUG, "EAP-FAST: Server triggered "
1303 "re-keying of Tunnel PAC");
1304 eap_fast_state(data, REQUEST_PAC);
1305 } else if (data->final_result)
1306 eap_fast_state(data, SUCCESS);
1309 if (tlv.eap_payload_tlv) {
1310 eap_fast_process_phase2_eap(sm, data, tlv.eap_payload_tlv,
1311 tlv.eap_payload_tlv_len);
1316 static void eap_fast_process_phase2(struct eap_sm *sm,
1317 struct eap_fast_data *data,
1318 struct wpabuf *in_buf)
1326 in_data = wpabuf_mhead(in_buf);
1327 in_len = wpabuf_len(in_buf);
1329 wpa_printf(MSG_DEBUG, "EAP-FAST: Received %lu bytes encrypted data for"
1330 " Phase 2", (unsigned long) in_len);
1332 if (data->pending_phase2_resp) {
1333 wpa_printf(MSG_DEBUG, "EAP-PEAP: Pending Phase 2 response - "
1334 "skip decryption and use old data");
1335 eap_fast_process_phase2_tlvs(
1336 sm, data, wpabuf_mhead(data->pending_phase2_resp),
1337 wpabuf_len(data->pending_phase2_resp));
1338 wpabuf_free(data->pending_phase2_resp);
1339 data->pending_phase2_resp = NULL;
1345 * Even though we try to disable TLS compression, it is possible that
1346 * this cannot be done with all TLS libraries. Add extra buffer space
1347 * to handle the possibility of the decrypted data being longer than
1352 in_decrypted = os_malloc(buf_len);
1353 if (in_decrypted == NULL) {
1354 wpa_printf(MSG_WARNING, "EAP-FAST: Failed to allocate memory "
1359 len_decrypted = tls_connection_decrypt(sm->ssl_ctx, data->ssl.conn,
1361 in_decrypted, buf_len);
1362 if (len_decrypted < 0) {
1363 wpa_printf(MSG_INFO, "EAP-FAST: Failed to decrypt Phase 2 "
1365 os_free(in_decrypted);
1366 eap_fast_state(data, FAILURE);
1370 wpa_hexdump_key(MSG_DEBUG, "EAP-FAST: Decrypted Phase 2 TLVs",
1371 in_decrypted, len_decrypted);
1373 eap_fast_process_phase2_tlvs(sm, data, in_decrypted, len_decrypted);
1375 if (sm->method_pending == METHOD_PENDING_WAIT) {
1376 wpa_printf(MSG_DEBUG, "EAP-FAST: Phase2 method is in "
1377 "pending wait state - save decrypted response");
1378 wpabuf_free(data->pending_phase2_resp);
1379 data->pending_phase2_resp = wpabuf_alloc_copy(in_decrypted,
1383 os_free(in_decrypted);
1387 static int eap_fast_process_version(struct eap_sm *sm, void *priv,
1390 struct eap_fast_data *data = priv;
1392 data->peer_version = peer_version;
1394 if (data->force_version >= 0 && peer_version != data->force_version) {
1395 wpa_printf(MSG_INFO, "EAP-FAST: peer did not select the forced"
1396 " version (forced=%d peer=%d) - reject",
1397 data->force_version, peer_version);
1401 if (peer_version < data->fast_version) {
1402 wpa_printf(MSG_DEBUG, "EAP-FAST: peer ver=%d, own ver=%d; "
1404 peer_version, data->fast_version, peer_version);
1405 data->fast_version = peer_version;
1412 static int eap_fast_process_phase1(struct eap_sm *sm,
1413 struct eap_fast_data *data)
1415 if (eap_server_tls_phase1(sm, &data->ssl) < 0) {
1416 wpa_printf(MSG_INFO, "EAP-FAST: TLS processing failed");
1417 eap_fast_state(data, FAILURE);
1421 if (!tls_connection_established(sm->ssl_ctx, data->ssl.conn) ||
1422 wpabuf_len(data->ssl.out_buf) > 0)
1426 * Phase 1 was completed with the received message (e.g., when using
1427 * abbreviated handshake), so Phase 2 can be started immediately
1428 * without having to send through an empty message to the peer.
1431 return eap_fast_phase1_done(sm, data);
1435 static void eap_fast_process_phase2_start(struct eap_sm *sm,
1436 struct eap_fast_data *data)
1440 if (data->identity) {
1441 os_free(sm->identity);
1442 sm->identity = data->identity;
1443 data->identity = NULL;
1444 sm->identity_len = data->identity_len;
1445 data->identity_len = 0;
1446 sm->require_identity_match = 1;
1447 if (eap_user_get(sm, sm->identity, sm->identity_len, 1) != 0) {
1448 wpa_hexdump_ascii(MSG_DEBUG, "EAP-FAST: "
1449 "Phase2 Identity not found "
1450 "in the user database",
1451 sm->identity, sm->identity_len);
1452 next_type = eap_fast_req_failure(sm, data);
1454 wpa_printf(MSG_DEBUG, "EAP-FAST: Identity already "
1455 "known - skip Phase 2 Identity Request");
1456 next_type = sm->user->methods[0].method;
1457 sm->user_eap_method_index = 1;
1460 eap_fast_state(data, PHASE2_METHOD);
1462 eap_fast_state(data, PHASE2_ID);
1463 next_type = EAP_TYPE_IDENTITY;
1466 eap_fast_phase2_init(sm, data, next_type);
1470 static void eap_fast_process_msg(struct eap_sm *sm, void *priv,
1471 const struct wpabuf *respData)
1473 struct eap_fast_data *data = priv;
1475 switch (data->state) {
1477 if (eap_fast_process_phase1(sm, data))
1480 /* fall through to PHASE2_START */
1482 eap_fast_process_phase2_start(sm, data);
1486 case CRYPTO_BINDING:
1488 eap_fast_process_phase2(sm, data, data->ssl.in_buf);
1491 wpa_printf(MSG_DEBUG, "EAP-FAST: Unexpected state %d in %s",
1492 data->state, __func__);
1498 static void eap_fast_process(struct eap_sm *sm, void *priv,
1499 struct wpabuf *respData)
1501 struct eap_fast_data *data = priv;
1502 if (eap_server_tls_process(sm, &data->ssl, respData, data,
1503 EAP_TYPE_FAST, eap_fast_process_version,
1504 eap_fast_process_msg) < 0)
1505 eap_fast_state(data, FAILURE);
1509 static Boolean eap_fast_isDone(struct eap_sm *sm, void *priv)
1511 struct eap_fast_data *data = priv;
1512 return data->state == SUCCESS || data->state == FAILURE;
1516 static u8 * eap_fast_getKey(struct eap_sm *sm, void *priv, size_t *len)
1518 struct eap_fast_data *data = priv;
1521 if (data->state != SUCCESS)
1524 eapKeyData = os_malloc(EAP_FAST_KEY_LEN);
1525 if (eapKeyData == NULL)
1528 eap_fast_derive_eap_msk(data->simck, eapKeyData);
1529 *len = EAP_FAST_KEY_LEN;
1535 static u8 * eap_fast_get_emsk(struct eap_sm *sm, void *priv, size_t *len)
1537 struct eap_fast_data *data = priv;
1540 if (data->state != SUCCESS)
1543 eapKeyData = os_malloc(EAP_EMSK_LEN);
1544 if (eapKeyData == NULL)
1547 eap_fast_derive_eap_emsk(data->simck, eapKeyData);
1548 *len = EAP_EMSK_LEN;
1554 static Boolean eap_fast_isSuccess(struct eap_sm *sm, void *priv)
1556 struct eap_fast_data *data = priv;
1557 return data->state == SUCCESS;
1561 int eap_server_fast_register(void)
1563 struct eap_method *eap;
1566 eap = eap_server_method_alloc(EAP_SERVER_METHOD_INTERFACE_VERSION,
1567 EAP_VENDOR_IETF, EAP_TYPE_FAST, "FAST");
1571 eap->init = eap_fast_init;
1572 eap->reset = eap_fast_reset;
1573 eap->buildReq = eap_fast_buildReq;
1574 eap->check = eap_fast_check;
1575 eap->process = eap_fast_process;
1576 eap->isDone = eap_fast_isDone;
1577 eap->getKey = eap_fast_getKey;
1578 eap->get_emsk = eap_fast_get_emsk;
1579 eap->isSuccess = eap_fast_isSuccess;
1581 ret = eap_server_method_register(eap);
1583 eap_server_method_free(eap);