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)
358 data->phase2_method->vendor == EAP_VENDOR_IETF &&
359 data->phase2_method->method == EAP_TYPE_MSCHAPV2) {
361 * EAP-FAST uses reverse order for MS-MPPE keys when deriving
362 * MSK from EAP-MSCHAPv2. Swap the keys here to get the correct
363 * ISK for EAP-FAST cryptobinding.
365 os_memcpy(isk, key + 16, 16);
366 os_memcpy(isk + 16, key, 16);
368 os_memcpy(isk, key, key_len);
375 static int eap_fast_update_icmk(struct eap_sm *sm, struct eap_fast_data *data)
377 u8 isk[32], imck[60];
379 wpa_printf(MSG_DEBUG, "EAP-FAST: Deriving ICMK[%d] (S-IMCK and CMK)",
380 data->simck_idx + 1);
383 * RFC 4851, Section 5.2:
384 * IMCK[j] = T-PRF(S-IMCK[j-1], "Inner Methods Compound Keys",
386 * S-IMCK[j] = first 40 octets of IMCK[j]
387 * CMK[j] = last 20 octets of IMCK[j]
390 if (eap_fast_get_phase2_key(sm, data, isk, sizeof(isk)) < 0)
392 wpa_hexdump_key(MSG_MSGDUMP, "EAP-FAST: ISK[j]", isk, sizeof(isk));
393 sha1_t_prf(data->simck, EAP_FAST_SIMCK_LEN,
394 "Inner Methods Compound Keys",
395 isk, sizeof(isk), imck, sizeof(imck));
397 os_memcpy(data->simck, imck, EAP_FAST_SIMCK_LEN);
398 wpa_hexdump_key(MSG_MSGDUMP, "EAP-FAST: S-IMCK[j]",
399 data->simck, EAP_FAST_SIMCK_LEN);
400 os_memcpy(data->cmk, imck + EAP_FAST_SIMCK_LEN, EAP_FAST_CMK_LEN);
401 wpa_hexdump_key(MSG_MSGDUMP, "EAP-FAST: CMK[j]",
402 data->cmk, EAP_FAST_CMK_LEN);
408 static void * eap_fast_init(struct eap_sm *sm)
410 struct eap_fast_data *data;
412 TLS_CIPHER_ANON_DH_AES128_SHA,
413 TLS_CIPHER_AES128_SHA,
414 TLS_CIPHER_RSA_DHE_AES128_SHA,
419 data = os_zalloc(sizeof(*data));
422 data->fast_version = EAP_FAST_VERSION;
423 data->force_version = -1;
424 if (sm->user && sm->user->force_version >= 0) {
425 data->force_version = sm->user->force_version;
426 wpa_printf(MSG_DEBUG, "EAP-FAST: forcing version %d",
427 data->force_version);
428 data->fast_version = data->force_version;
432 if (eap_server_tls_ssl_init(sm, &data->ssl, 0)) {
433 wpa_printf(MSG_INFO, "EAP-FAST: Failed to initialize SSL.");
434 eap_fast_reset(sm, data);
438 if (tls_connection_set_cipher_list(sm->ssl_ctx, data->ssl.conn,
440 wpa_printf(MSG_INFO, "EAP-FAST: Failed to set TLS cipher "
442 eap_fast_reset(sm, data);
446 if (tls_connection_set_session_ticket_cb(sm->ssl_ctx, data->ssl.conn,
447 eap_fast_session_ticket_cb,
449 wpa_printf(MSG_INFO, "EAP-FAST: Failed to set SessionTicket "
451 eap_fast_reset(sm, data);
455 if (sm->pac_opaque_encr_key == NULL) {
456 wpa_printf(MSG_INFO, "EAP-FAST: No PAC-Opaque encryption key "
458 eap_fast_reset(sm, data);
461 os_memcpy(data->pac_opaque_encr, sm->pac_opaque_encr_key,
462 sizeof(data->pac_opaque_encr));
464 if (sm->eap_fast_a_id == NULL) {
465 wpa_printf(MSG_INFO, "EAP-FAST: No A-ID configured");
466 eap_fast_reset(sm, data);
469 data->srv_id = os_malloc(sm->eap_fast_a_id_len);
470 if (data->srv_id == NULL) {
471 eap_fast_reset(sm, data);
474 os_memcpy(data->srv_id, sm->eap_fast_a_id, sm->eap_fast_a_id_len);
475 data->srv_id_len = sm->eap_fast_a_id_len;
477 if (sm->eap_fast_a_id_info == NULL) {
478 wpa_printf(MSG_INFO, "EAP-FAST: No A-ID-Info configured");
479 eap_fast_reset(sm, data);
482 data->srv_id_info = os_strdup(sm->eap_fast_a_id_info);
483 if (data->srv_id_info == NULL) {
484 eap_fast_reset(sm, data);
488 /* PAC-Key lifetime in seconds (hard limit) */
489 data->pac_key_lifetime = sm->pac_key_lifetime;
492 * PAC-Key refresh time in seconds (soft limit on remaining hard
493 * limit). The server will generate a new PAC-Key when this number of
494 * seconds (or fewer) of the lifetime remains.
496 data->pac_key_refresh_time = sm->pac_key_refresh_time;
502 static void eap_fast_reset(struct eap_sm *sm, void *priv)
504 struct eap_fast_data *data = priv;
507 if (data->phase2_priv && data->phase2_method)
508 data->phase2_method->reset(sm, data->phase2_priv);
509 eap_server_tls_ssl_deinit(sm, &data->ssl);
510 os_free(data->srv_id);
511 os_free(data->srv_id_info);
512 os_free(data->key_block_p);
513 wpabuf_free(data->pending_phase2_resp);
514 os_free(data->identity);
519 static struct wpabuf * eap_fast_build_start(struct eap_sm *sm,
520 struct eap_fast_data *data, u8 id)
524 req = eap_msg_alloc(EAP_VENDOR_IETF, EAP_TYPE_FAST,
525 1 + sizeof(struct pac_tlv_hdr) + data->srv_id_len,
526 EAP_CODE_REQUEST, id);
528 wpa_printf(MSG_ERROR, "EAP-FAST: Failed to allocate memory for"
530 eap_fast_state(data, FAILURE);
534 wpabuf_put_u8(req, EAP_TLS_FLAGS_START | data->fast_version);
536 /* RFC 4851, 4.1.1. Authority ID Data */
537 eap_fast_put_tlv(req, PAC_TYPE_A_ID, data->srv_id, data->srv_id_len);
539 eap_fast_state(data, PHASE1);
545 static int eap_fast_phase1_done(struct eap_sm *sm, struct eap_fast_data *data)
549 wpa_printf(MSG_DEBUG, "EAP-FAST: Phase1 done, starting Phase2");
551 if (tls_get_cipher(sm->ssl_ctx, data->ssl.conn, cipher, sizeof(cipher))
553 wpa_printf(MSG_DEBUG, "EAP-FAST: Failed to get cipher "
555 eap_fast_state(data, FAILURE);
558 data->anon_provisioning = os_strstr(cipher, "ADH") != NULL;
560 if (data->anon_provisioning) {
561 wpa_printf(MSG_DEBUG, "EAP-FAST: Anonymous provisioning");
562 eap_fast_derive_key_provisioning(sm, data);
564 eap_fast_derive_key_auth(sm, data);
566 eap_fast_state(data, PHASE2_START);
572 static struct wpabuf * eap_fast_build_phase2_req(struct eap_sm *sm,
573 struct eap_fast_data *data,
578 if (data->phase2_priv == NULL) {
579 wpa_printf(MSG_DEBUG, "EAP-FAST: Phase 2 method not "
583 req = data->phase2_method->buildReq(sm, data->phase2_priv, id);
587 wpa_hexdump_buf_key(MSG_MSGDUMP, "EAP-FAST: Phase 2 EAP-Request", req);
588 return eap_fast_tlv_eap_payload(req);
592 static struct wpabuf * eap_fast_build_crypto_binding(
593 struct eap_sm *sm, struct eap_fast_data *data)
596 struct eap_tlv_result_tlv *result;
597 struct eap_tlv_crypto_binding_tlv *binding;
599 buf = wpabuf_alloc(2 * sizeof(*result) + sizeof(*binding));
603 if (data->send_new_pac || data->anon_provisioning ||
605 data->final_result = 0;
607 data->final_result = 1;
609 if (!data->final_result || data->eap_seq > 1) {
610 /* Intermediate-Result */
611 wpa_printf(MSG_DEBUG, "EAP-FAST: Add Intermediate-Result TLV "
613 result = wpabuf_put(buf, sizeof(*result));
614 result->tlv_type = host_to_be16(
615 EAP_TLV_TYPE_MANDATORY |
616 EAP_TLV_INTERMEDIATE_RESULT_TLV);
617 result->length = host_to_be16(2);
618 result->status = host_to_be16(EAP_TLV_RESULT_SUCCESS);
621 if (data->final_result) {
623 wpa_printf(MSG_DEBUG, "EAP-FAST: Add Result TLV "
625 result = wpabuf_put(buf, sizeof(*result));
626 result->tlv_type = host_to_be16(EAP_TLV_TYPE_MANDATORY |
628 result->length = host_to_be16(2);
629 result->status = host_to_be16(EAP_TLV_RESULT_SUCCESS);
632 /* Crypto-Binding TLV */
633 binding = wpabuf_put(buf, sizeof(*binding));
634 binding->tlv_type = host_to_be16(EAP_TLV_TYPE_MANDATORY |
635 EAP_TLV_CRYPTO_BINDING_TLV);
636 binding->length = host_to_be16(sizeof(*binding) -
637 sizeof(struct eap_tlv_hdr));
638 binding->version = EAP_FAST_VERSION;
639 binding->received_version = data->peer_version;
640 binding->subtype = EAP_TLV_CRYPTO_BINDING_SUBTYPE_REQUEST;
641 if (os_get_random(binding->nonce, sizeof(binding->nonce)) < 0) {
647 * RFC 4851, Section 4.2.8:
648 * The nonce in a request MUST have its least significant bit set to 0.
650 binding->nonce[sizeof(binding->nonce) - 1] &= ~0x01;
652 os_memcpy(data->crypto_binding_nonce, binding->nonce,
653 sizeof(binding->nonce));
656 * RFC 4851, Section 5.3:
658 * Compound-MAC = HMAC-SHA1( CMK, Crypto-Binding TLV )
661 hmac_sha1(data->cmk, EAP_FAST_CMK_LEN,
662 (u8 *) binding, sizeof(*binding),
663 binding->compound_mac);
665 wpa_printf(MSG_DEBUG, "EAP-FAST: Add Crypto-Binding TLV: Version %d "
666 "Received Version %d SubType %d",
667 binding->version, binding->received_version,
669 wpa_hexdump(MSG_MSGDUMP, "EAP-FAST: NONCE",
670 binding->nonce, sizeof(binding->nonce));
671 wpa_hexdump(MSG_MSGDUMP, "EAP-FAST: Compound MAC",
672 binding->compound_mac, sizeof(binding->compound_mac));
678 static struct wpabuf * eap_fast_build_pac(struct eap_sm *sm,
679 struct eap_fast_data *data)
681 u8 pac_key[EAP_FAST_PAC_KEY_LEN];
682 u8 *pac_buf, *pac_opaque;
685 size_t buf_len, srv_id_info_len, pac_len;
686 struct eap_tlv_hdr *pac_tlv;
687 struct pac_tlv_hdr *pac_info;
688 struct eap_tlv_result_tlv *result;
691 if (os_get_random(pac_key, EAP_FAST_PAC_KEY_LEN) < 0 ||
692 os_get_time(&now) < 0)
694 wpa_hexdump_key(MSG_DEBUG, "EAP-FAST: Generated PAC-Key",
695 pac_key, EAP_FAST_PAC_KEY_LEN);
697 pac_len = (2 + EAP_FAST_PAC_KEY_LEN) + (2 + 4) +
698 (2 + sm->identity_len) + 8;
699 pac_buf = os_malloc(pac_len);
703 srv_id_info_len = os_strlen(data->srv_id_info);
706 *pos++ = PAC_OPAQUE_TYPE_KEY;
707 *pos++ = EAP_FAST_PAC_KEY_LEN;
708 os_memcpy(pos, pac_key, EAP_FAST_PAC_KEY_LEN);
709 pos += EAP_FAST_PAC_KEY_LEN;
711 *pos++ = PAC_OPAQUE_TYPE_LIFETIME;
713 WPA_PUT_BE32(pos, now.sec + data->pac_key_lifetime);
717 *pos++ = PAC_OPAQUE_TYPE_IDENTITY;
718 *pos++ = sm->identity_len;
719 os_memcpy(pos, sm->identity, sm->identity_len);
720 pos += sm->identity_len;
723 pac_len = pos - pac_buf;
724 while (pac_len % 8) {
725 *pos++ = PAC_OPAQUE_TYPE_PAD;
729 pac_opaque = os_malloc(pac_len + 8);
730 if (pac_opaque == NULL) {
734 if (aes_wrap(data->pac_opaque_encr, pac_len / 8, pac_buf,
743 wpa_hexdump(MSG_DEBUG, "EAP-FAST: PAC-Opaque",
744 pac_opaque, pac_len);
746 buf_len = sizeof(*pac_tlv) +
747 sizeof(struct pac_tlv_hdr) + EAP_FAST_PAC_KEY_LEN +
748 sizeof(struct pac_tlv_hdr) + pac_len +
749 data->srv_id_len + srv_id_info_len + 100 + sizeof(*result);
750 buf = wpabuf_alloc(buf_len);
757 wpa_printf(MSG_DEBUG, "EAP-FAST: Add Result TLV (status=SUCCESS)");
758 result = wpabuf_put(buf, sizeof(*result));
759 WPA_PUT_BE16((u8 *) &result->tlv_type,
760 EAP_TLV_TYPE_MANDATORY | EAP_TLV_RESULT_TLV);
761 WPA_PUT_BE16((u8 *) &result->length, 2);
762 WPA_PUT_BE16((u8 *) &result->status, EAP_TLV_RESULT_SUCCESS);
765 wpa_printf(MSG_DEBUG, "EAP-FAST: Add PAC TLV");
766 pac_tlv = wpabuf_put(buf, sizeof(*pac_tlv));
767 pac_tlv->tlv_type = host_to_be16(EAP_TLV_TYPE_MANDATORY |
771 eap_fast_put_tlv(buf, PAC_TYPE_PAC_KEY, pac_key, EAP_FAST_PAC_KEY_LEN);
774 eap_fast_put_tlv(buf, PAC_TYPE_PAC_OPAQUE, pac_opaque, pac_len);
778 pac_info = wpabuf_put(buf, sizeof(*pac_info));
779 pac_info->type = host_to_be16(PAC_TYPE_PAC_INFO);
781 /* PAC-Lifetime (inside PAC-Info) */
782 eap_fast_put_tlv_hdr(buf, PAC_TYPE_CRED_LIFETIME, 4);
783 wpabuf_put_be32(buf, now.sec + data->pac_key_lifetime);
785 /* A-ID (inside PAC-Info) */
786 eap_fast_put_tlv(buf, PAC_TYPE_A_ID, data->srv_id, data->srv_id_len);
788 /* Note: headers may be misaligned after A-ID */
790 /* A-ID-Info (inside PAC-Info) */
791 eap_fast_put_tlv(buf, PAC_TYPE_A_ID_INFO, data->srv_id_info,
794 /* PAC-Type (inside PAC-Info) */
795 eap_fast_put_tlv_hdr(buf, PAC_TYPE_PAC_TYPE, 2);
796 wpabuf_put_be16(buf, PAC_TYPE_TUNNEL_PAC);
798 /* Update PAC-Info and PAC TLV Length fields */
799 pos = wpabuf_put(buf, 0);
800 pac_info->len = host_to_be16(pos - (u8 *) (pac_info + 1));
801 pac_tlv->length = host_to_be16(pos - (u8 *) (pac_tlv + 1));
807 static struct wpabuf * eap_fast_buildReq(struct eap_sm *sm, void *priv, u8 id)
809 struct eap_fast_data *data = priv;
810 struct wpabuf *req = NULL;
813 if (data->ssl.state == FRAG_ACK) {
814 return eap_server_tls_build_ack(id, EAP_TYPE_FAST,
818 if (data->ssl.state == WAIT_FRAG_ACK) {
819 return eap_server_tls_build_msg(&data->ssl, EAP_TYPE_FAST,
820 data->fast_version, id);
823 switch (data->state) {
825 return eap_fast_build_start(sm, data, id);
827 if (tls_connection_established(sm->ssl_ctx, data->ssl.conn)) {
828 if (eap_fast_phase1_done(sm, data) < 0)
834 req = eap_fast_build_phase2_req(sm, data, id);
837 req = eap_fast_build_crypto_binding(sm, data);
838 if (data->phase2_method) {
840 * Include the start of the next EAP method in the
841 * sequence in the same message with Crypto-Binding to
845 eap = eap_fast_build_phase2_req(sm, data, id);
846 req = wpabuf_concat(req, eap);
847 eap_fast_state(data, PHASE2_METHOD);
851 req = eap_fast_build_pac(sm, data);
854 wpa_printf(MSG_DEBUG, "EAP-FAST: %s - unexpected state %d",
855 __func__, data->state);
860 wpa_hexdump_buf_key(MSG_DEBUG, "EAP-FAST: Encrypting Phase 2 "
862 encr = eap_server_tls_encrypt(sm, &data->ssl,
867 wpabuf_free(data->ssl.out_buf);
868 data->ssl.out_used = 0;
869 data->ssl.out_buf = encr;
872 return eap_server_tls_build_msg(&data->ssl, EAP_TYPE_FAST,
873 data->fast_version, id);
877 static Boolean eap_fast_check(struct eap_sm *sm, void *priv,
878 struct wpabuf *respData)
883 pos = eap_hdr_validate(EAP_VENDOR_IETF, EAP_TYPE_FAST, respData, &len);
884 if (pos == NULL || len < 1) {
885 wpa_printf(MSG_INFO, "EAP-FAST: Invalid frame");
893 static int eap_fast_phase2_init(struct eap_sm *sm, struct eap_fast_data *data,
896 if (data->phase2_priv && data->phase2_method) {
897 data->phase2_method->reset(sm, data->phase2_priv);
898 data->phase2_method = NULL;
899 data->phase2_priv = NULL;
901 data->phase2_method = eap_server_get_eap_method(EAP_VENDOR_IETF,
903 if (!data->phase2_method)
906 if (data->key_block_p) {
907 sm->auth_challenge = data->key_block_p->server_challenge;
908 sm->peer_challenge = data->key_block_p->client_challenge;
911 data->phase2_priv = data->phase2_method->init(sm);
913 sm->auth_challenge = NULL;
914 sm->peer_challenge = NULL;
916 return data->phase2_priv == NULL ? -1 : 0;
920 static void eap_fast_process_phase2_response(struct eap_sm *sm,
921 struct eap_fast_data *data,
922 u8 *in_data, size_t in_len)
924 u8 next_type = EAP_TYPE_NONE;
929 const struct eap_method *m = data->phase2_method;
930 void *priv = data->phase2_priv;
933 wpa_printf(MSG_DEBUG, "EAP-FAST: %s - Phase2 not "
934 "initialized?!", __func__);
938 hdr = (struct eap_hdr *) in_data;
939 pos = (u8 *) (hdr + 1);
941 if (in_len > sizeof(*hdr) && *pos == EAP_TYPE_NAK) {
942 left = in_len - sizeof(*hdr);
943 wpa_hexdump(MSG_DEBUG, "EAP-FAST: Phase2 type Nak'ed; "
944 "allowed types", pos + 1, left - 1);
946 if (m && m->vendor == EAP_VENDOR_IETF &&
947 m->method == EAP_TYPE_TNC) {
948 wpa_printf(MSG_DEBUG, "EAP-FAST: Peer Nak'ed required "
950 next_type = eap_fast_req_failure(sm, data);
951 eap_fast_phase2_init(sm, data, next_type);
955 eap_sm_process_nak(sm, pos + 1, left - 1);
956 if (sm->user && sm->user_eap_method_index < EAP_MAX_METHODS &&
957 sm->user->methods[sm->user_eap_method_index].method !=
959 next_type = sm->user->methods[
960 sm->user_eap_method_index++].method;
961 wpa_printf(MSG_DEBUG, "EAP-FAST: try EAP type %d",
964 next_type = eap_fast_req_failure(sm, data);
966 eap_fast_phase2_init(sm, data, next_type);
970 wpabuf_set(&buf, in_data, in_len);
972 if (m->check(sm, priv, &buf)) {
973 wpa_printf(MSG_DEBUG, "EAP-FAST: Phase2 check() asked to "
974 "ignore the packet");
975 next_type = eap_fast_req_failure(sm, data);
979 m->process(sm, priv, &buf);
981 if (!m->isDone(sm, priv))
984 if (!m->isSuccess(sm, priv)) {
985 wpa_printf(MSG_DEBUG, "EAP-FAST: Phase2 method failed");
986 next_type = eap_fast_req_failure(sm, data);
987 eap_fast_phase2_init(sm, data, next_type);
991 switch (data->state) {
993 if (eap_user_get(sm, sm->identity, sm->identity_len, 1) != 0) {
994 wpa_hexdump_ascii(MSG_DEBUG, "EAP-FAST: Phase2 "
995 "Identity not found in the user "
997 sm->identity, sm->identity_len);
998 next_type = eap_fast_req_failure(sm, data);
1002 eap_fast_state(data, PHASE2_METHOD);
1003 if (data->anon_provisioning) {
1005 * Only EAP-MSCHAPv2 is allowed for anonymous
1008 next_type = EAP_TYPE_MSCHAPV2;
1009 sm->user_eap_method_index = 0;
1011 next_type = sm->user->methods[0].method;
1012 sm->user_eap_method_index = 1;
1014 wpa_printf(MSG_DEBUG, "EAP-FAST: try EAP type %d", next_type);
1017 case CRYPTO_BINDING:
1018 eap_fast_update_icmk(sm, data);
1019 eap_fast_state(data, CRYPTO_BINDING);
1021 next_type = EAP_TYPE_NONE;
1023 if (sm->tnc && !data->tnc_started) {
1024 wpa_printf(MSG_DEBUG, "EAP-FAST: Initialize TNC");
1025 next_type = EAP_TYPE_TNC;
1026 data->tnc_started = 1;
1028 #endif /* EAP_TNC */
1033 wpa_printf(MSG_DEBUG, "EAP-FAST: %s - unexpected state %d",
1034 __func__, data->state);
1038 eap_fast_phase2_init(sm, data, next_type);
1042 static void eap_fast_process_phase2_eap(struct eap_sm *sm,
1043 struct eap_fast_data *data,
1044 u8 *in_data, size_t in_len)
1046 struct eap_hdr *hdr;
1049 hdr = (struct eap_hdr *) in_data;
1050 if (in_len < (int) sizeof(*hdr)) {
1051 wpa_printf(MSG_INFO, "EAP-FAST: Too short Phase 2 "
1052 "EAP frame (len=%lu)", (unsigned long) in_len);
1053 eap_fast_req_failure(sm, data);
1056 len = be_to_host16(hdr->length);
1058 wpa_printf(MSG_INFO, "EAP-FAST: Length mismatch in "
1059 "Phase 2 EAP frame (len=%lu hdr->length=%lu)",
1060 (unsigned long) in_len, (unsigned long) len);
1061 eap_fast_req_failure(sm, data);
1064 wpa_printf(MSG_DEBUG, "EAP-FAST: Received Phase 2: code=%d "
1065 "identifier=%d length=%lu", hdr->code, hdr->identifier,
1066 (unsigned long) len);
1067 switch (hdr->code) {
1068 case EAP_CODE_RESPONSE:
1069 eap_fast_process_phase2_response(sm, data, (u8 *) hdr, len);
1072 wpa_printf(MSG_INFO, "EAP-FAST: Unexpected code=%d in "
1073 "Phase 2 EAP header", hdr->code);
1079 static int eap_fast_parse_tlvs(u8 *data, size_t data_len,
1080 struct eap_fast_tlv_parse *tlv)
1082 int mandatory, tlv_type, len, res;
1085 os_memset(tlv, 0, sizeof(*tlv));
1088 end = data + data_len;
1089 while (pos + 4 < end) {
1090 mandatory = pos[0] & 0x80;
1091 tlv_type = WPA_GET_BE16(pos) & 0x3fff;
1093 len = WPA_GET_BE16(pos);
1095 if (pos + len > end) {
1096 wpa_printf(MSG_INFO, "EAP-FAST: TLV overflow");
1099 wpa_printf(MSG_DEBUG, "EAP-FAST: Received Phase 2: "
1100 "TLV type %d length %d%s",
1101 tlv_type, len, mandatory ? " (mandatory)" : "");
1103 res = eap_fast_parse_tlv(tlv, tlv_type, pos, len);
1108 wpa_printf(MSG_DEBUG, "EAP-FAST: Nak unknown "
1109 "mandatory TLV type %d", tlv_type);
1110 /* TODO: generate Nak TLV */
1113 wpa_printf(MSG_DEBUG, "EAP-FAST: Ignored "
1114 "unknown optional TLV type %d",
1126 static int eap_fast_validate_crypto_binding(
1127 struct eap_fast_data *data, struct eap_tlv_crypto_binding_tlv *b,
1130 u8 cmac[SHA1_MAC_LEN];
1132 wpa_printf(MSG_DEBUG, "EAP-FAST: Reply Crypto-Binding TLV: "
1133 "Version %d Received Version %d SubType %d",
1134 b->version, b->received_version, b->subtype);
1135 wpa_hexdump(MSG_MSGDUMP, "EAP-FAST: NONCE",
1136 b->nonce, sizeof(b->nonce));
1137 wpa_hexdump(MSG_MSGDUMP, "EAP-FAST: Compound MAC",
1138 b->compound_mac, sizeof(b->compound_mac));
1140 if (b->version != EAP_FAST_VERSION ||
1141 b->received_version != EAP_FAST_VERSION) {
1142 wpa_printf(MSG_DEBUG, "EAP-FAST: Unexpected version "
1143 "in Crypto-Binding: version %d "
1144 "received_version %d", b->version,
1145 b->received_version);
1149 if (b->subtype != EAP_TLV_CRYPTO_BINDING_SUBTYPE_RESPONSE) {
1150 wpa_printf(MSG_DEBUG, "EAP-FAST: Unexpected subtype in "
1151 "Crypto-Binding: %d", b->subtype);
1155 if (os_memcmp(data->crypto_binding_nonce, b->nonce, 31) != 0 ||
1156 (data->crypto_binding_nonce[31] | 1) != b->nonce[31]) {
1157 wpa_printf(MSG_DEBUG, "EAP-FAST: Invalid nonce in "
1162 os_memcpy(cmac, b->compound_mac, sizeof(cmac));
1163 os_memset(b->compound_mac, 0, sizeof(cmac));
1164 wpa_hexdump(MSG_MSGDUMP, "EAP-FAST: Crypto-Binding TLV for "
1165 "Compound MAC calculation",
1166 (u8 *) b, bind_len);
1167 hmac_sha1(data->cmk, EAP_FAST_CMK_LEN, (u8 *) b, bind_len,
1169 if (os_memcmp(cmac, b->compound_mac, sizeof(cmac)) != 0) {
1170 wpa_hexdump(MSG_MSGDUMP,
1171 "EAP-FAST: Calculated Compound MAC",
1172 b->compound_mac, sizeof(cmac));
1173 wpa_printf(MSG_INFO, "EAP-FAST: Compound MAC did not "
1182 static int eap_fast_pac_type(u8 *pac, size_t len, u16 type)
1184 struct eap_tlv_pac_type_tlv *tlv;
1186 if (pac == NULL || len != sizeof(*tlv))
1189 tlv = (struct eap_tlv_pac_type_tlv *) pac;
1191 return be_to_host16(tlv->tlv_type) == PAC_TYPE_PAC_TYPE &&
1192 be_to_host16(tlv->length) == 2 &&
1193 be_to_host16(tlv->pac_type) == type;
1197 static void eap_fast_process_phase2_tlvs(struct eap_sm *sm,
1198 struct eap_fast_data *data,
1199 u8 *in_data, size_t in_len)
1201 struct eap_fast_tlv_parse tlv;
1202 int check_crypto_binding = data->state == CRYPTO_BINDING;
1204 if (eap_fast_parse_tlvs(in_data, in_len, &tlv) < 0) {
1205 wpa_printf(MSG_DEBUG, "EAP-FAST: Failed to parse received "
1210 if (tlv.result == EAP_TLV_RESULT_FAILURE) {
1211 wpa_printf(MSG_DEBUG, "EAP-FAST: Result TLV indicated "
1213 eap_fast_state(data, FAILURE);
1217 if (data->state == REQUEST_PAC) {
1219 if (tlv.pac == NULL || tlv.pac_len < 6) {
1220 wpa_printf(MSG_DEBUG, "EAP-FAST: No PAC "
1221 "Acknowledgement received");
1222 eap_fast_state(data, FAILURE);
1226 type = WPA_GET_BE16(tlv.pac);
1227 len = WPA_GET_BE16(tlv.pac + 2);
1228 res = WPA_GET_BE16(tlv.pac + 4);
1230 if (type != PAC_TYPE_PAC_ACKNOWLEDGEMENT || len != 2 ||
1231 res != EAP_TLV_RESULT_SUCCESS) {
1232 wpa_printf(MSG_DEBUG, "EAP-FAST: PAC TLV did not "
1233 "contain acknowledgement");
1234 eap_fast_state(data, FAILURE);
1238 wpa_printf(MSG_DEBUG, "EAP-FAST: PAC-Acknowledgement received "
1239 "- PAC provisioning succeeded");
1240 eap_fast_state(data, (data->anon_provisioning ||
1241 data->send_new_pac == 2) ?
1246 if (check_crypto_binding) {
1247 if (tlv.crypto_binding == NULL) {
1248 wpa_printf(MSG_DEBUG, "EAP-FAST: No Crypto-Binding "
1250 eap_fast_state(data, FAILURE);
1254 if (data->final_result &&
1255 tlv.result != EAP_TLV_RESULT_SUCCESS) {
1256 wpa_printf(MSG_DEBUG, "EAP-FAST: Crypto-Binding TLV "
1257 "without Success Result");
1258 eap_fast_state(data, FAILURE);
1262 if (!data->final_result &&
1263 tlv.iresult != EAP_TLV_RESULT_SUCCESS) {
1264 wpa_printf(MSG_DEBUG, "EAP-FAST: Crypto-Binding TLV "
1265 "without intermediate Success Result");
1266 eap_fast_state(data, FAILURE);
1270 if (eap_fast_validate_crypto_binding(data, tlv.crypto_binding,
1271 tlv.crypto_binding_len)) {
1272 eap_fast_state(data, FAILURE);
1276 wpa_printf(MSG_DEBUG, "EAP-FAST: Valid Crypto-Binding TLV "
1278 if (data->final_result) {
1279 wpa_printf(MSG_DEBUG, "EAP-FAST: Authentication "
1280 "completed successfully");
1283 if (data->anon_provisioning &&
1284 sm->eap_fast_prov != ANON_PROV &&
1285 sm->eap_fast_prov != BOTH_PROV) {
1286 wpa_printf(MSG_DEBUG, "EAP-FAST: Client is trying to "
1287 "use unauthenticated provisioning which is "
1289 eap_fast_state(data, FAILURE);
1293 if (sm->eap_fast_prov != AUTH_PROV &&
1294 sm->eap_fast_prov != BOTH_PROV &&
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: Client is trying to "
1299 "use authenticated provisioning which is "
1301 eap_fast_state(data, FAILURE);
1305 if (data->anon_provisioning ||
1306 (tlv.request_action == EAP_TLV_ACTION_PROCESS_TLV &&
1307 eap_fast_pac_type(tlv.pac, tlv.pac_len,
1308 PAC_TYPE_TUNNEL_PAC))) {
1309 wpa_printf(MSG_DEBUG, "EAP-FAST: Requested a new "
1311 eap_fast_state(data, REQUEST_PAC);
1312 } else if (data->send_new_pac) {
1313 wpa_printf(MSG_DEBUG, "EAP-FAST: Server triggered "
1314 "re-keying of Tunnel PAC");
1315 eap_fast_state(data, REQUEST_PAC);
1316 } else if (data->final_result)
1317 eap_fast_state(data, SUCCESS);
1320 if (tlv.eap_payload_tlv) {
1321 eap_fast_process_phase2_eap(sm, data, tlv.eap_payload_tlv,
1322 tlv.eap_payload_tlv_len);
1327 static void eap_fast_process_phase2(struct eap_sm *sm,
1328 struct eap_fast_data *data,
1329 struct wpabuf *in_buf)
1337 in_data = wpabuf_mhead(in_buf);
1338 in_len = wpabuf_len(in_buf);
1340 wpa_printf(MSG_DEBUG, "EAP-FAST: Received %lu bytes encrypted data for"
1341 " Phase 2", (unsigned long) in_len);
1343 if (data->pending_phase2_resp) {
1344 wpa_printf(MSG_DEBUG, "EAP-PEAP: Pending Phase 2 response - "
1345 "skip decryption and use old data");
1346 eap_fast_process_phase2_tlvs(
1347 sm, data, wpabuf_mhead(data->pending_phase2_resp),
1348 wpabuf_len(data->pending_phase2_resp));
1349 wpabuf_free(data->pending_phase2_resp);
1350 data->pending_phase2_resp = NULL;
1356 * Even though we try to disable TLS compression, it is possible that
1357 * this cannot be done with all TLS libraries. Add extra buffer space
1358 * to handle the possibility of the decrypted data being longer than
1363 in_decrypted = os_malloc(buf_len);
1364 if (in_decrypted == NULL) {
1365 wpa_printf(MSG_WARNING, "EAP-FAST: Failed to allocate memory "
1370 len_decrypted = tls_connection_decrypt(sm->ssl_ctx, data->ssl.conn,
1372 in_decrypted, buf_len);
1373 if (len_decrypted < 0) {
1374 wpa_printf(MSG_INFO, "EAP-FAST: Failed to decrypt Phase 2 "
1376 os_free(in_decrypted);
1377 eap_fast_state(data, FAILURE);
1381 wpa_hexdump_key(MSG_DEBUG, "EAP-FAST: Decrypted Phase 2 TLVs",
1382 in_decrypted, len_decrypted);
1384 eap_fast_process_phase2_tlvs(sm, data, in_decrypted, len_decrypted);
1386 if (sm->method_pending == METHOD_PENDING_WAIT) {
1387 wpa_printf(MSG_DEBUG, "EAP-FAST: Phase2 method is in "
1388 "pending wait state - save decrypted response");
1389 wpabuf_free(data->pending_phase2_resp);
1390 data->pending_phase2_resp = wpabuf_alloc_copy(in_decrypted,
1394 os_free(in_decrypted);
1398 static int eap_fast_process_version(struct eap_sm *sm, void *priv,
1401 struct eap_fast_data *data = priv;
1403 data->peer_version = peer_version;
1405 if (data->force_version >= 0 && peer_version != data->force_version) {
1406 wpa_printf(MSG_INFO, "EAP-FAST: peer did not select the forced"
1407 " version (forced=%d peer=%d) - reject",
1408 data->force_version, peer_version);
1412 if (peer_version < data->fast_version) {
1413 wpa_printf(MSG_DEBUG, "EAP-FAST: peer ver=%d, own ver=%d; "
1415 peer_version, data->fast_version, peer_version);
1416 data->fast_version = peer_version;
1423 static int eap_fast_process_phase1(struct eap_sm *sm,
1424 struct eap_fast_data *data)
1426 if (eap_server_tls_phase1(sm, &data->ssl) < 0) {
1427 wpa_printf(MSG_INFO, "EAP-FAST: TLS processing failed");
1428 eap_fast_state(data, FAILURE);
1432 if (!tls_connection_established(sm->ssl_ctx, data->ssl.conn) ||
1433 wpabuf_len(data->ssl.out_buf) > 0)
1437 * Phase 1 was completed with the received message (e.g., when using
1438 * abbreviated handshake), so Phase 2 can be started immediately
1439 * without having to send through an empty message to the peer.
1442 return eap_fast_phase1_done(sm, data);
1446 static void eap_fast_process_phase2_start(struct eap_sm *sm,
1447 struct eap_fast_data *data)
1451 if (data->identity) {
1452 os_free(sm->identity);
1453 sm->identity = data->identity;
1454 data->identity = NULL;
1455 sm->identity_len = data->identity_len;
1456 data->identity_len = 0;
1457 sm->require_identity_match = 1;
1458 if (eap_user_get(sm, sm->identity, sm->identity_len, 1) != 0) {
1459 wpa_hexdump_ascii(MSG_DEBUG, "EAP-FAST: "
1460 "Phase2 Identity not found "
1461 "in the user database",
1462 sm->identity, sm->identity_len);
1463 next_type = eap_fast_req_failure(sm, data);
1465 wpa_printf(MSG_DEBUG, "EAP-FAST: Identity already "
1466 "known - skip Phase 2 Identity Request");
1467 next_type = sm->user->methods[0].method;
1468 sm->user_eap_method_index = 1;
1471 eap_fast_state(data, PHASE2_METHOD);
1473 eap_fast_state(data, PHASE2_ID);
1474 next_type = EAP_TYPE_IDENTITY;
1477 eap_fast_phase2_init(sm, data, next_type);
1481 static void eap_fast_process_msg(struct eap_sm *sm, void *priv,
1482 const struct wpabuf *respData)
1484 struct eap_fast_data *data = priv;
1486 switch (data->state) {
1488 if (eap_fast_process_phase1(sm, data))
1491 /* fall through to PHASE2_START */
1493 eap_fast_process_phase2_start(sm, data);
1497 case CRYPTO_BINDING:
1499 eap_fast_process_phase2(sm, data, data->ssl.in_buf);
1502 wpa_printf(MSG_DEBUG, "EAP-FAST: Unexpected state %d in %s",
1503 data->state, __func__);
1509 static void eap_fast_process(struct eap_sm *sm, void *priv,
1510 struct wpabuf *respData)
1512 struct eap_fast_data *data = priv;
1513 if (eap_server_tls_process(sm, &data->ssl, respData, data,
1514 EAP_TYPE_FAST, eap_fast_process_version,
1515 eap_fast_process_msg) < 0)
1516 eap_fast_state(data, FAILURE);
1520 static Boolean eap_fast_isDone(struct eap_sm *sm, void *priv)
1522 struct eap_fast_data *data = priv;
1523 return data->state == SUCCESS || data->state == FAILURE;
1527 static u8 * eap_fast_getKey(struct eap_sm *sm, void *priv, size_t *len)
1529 struct eap_fast_data *data = priv;
1532 if (data->state != SUCCESS)
1535 eapKeyData = os_malloc(EAP_FAST_KEY_LEN);
1536 if (eapKeyData == NULL)
1539 eap_fast_derive_eap_msk(data->simck, eapKeyData);
1540 *len = EAP_FAST_KEY_LEN;
1546 static u8 * eap_fast_get_emsk(struct eap_sm *sm, void *priv, size_t *len)
1548 struct eap_fast_data *data = priv;
1551 if (data->state != SUCCESS)
1554 eapKeyData = os_malloc(EAP_EMSK_LEN);
1555 if (eapKeyData == NULL)
1558 eap_fast_derive_eap_emsk(data->simck, eapKeyData);
1559 *len = EAP_EMSK_LEN;
1565 static Boolean eap_fast_isSuccess(struct eap_sm *sm, void *priv)
1567 struct eap_fast_data *data = priv;
1568 return data->state == SUCCESS;
1572 int eap_server_fast_register(void)
1574 struct eap_method *eap;
1577 eap = eap_server_method_alloc(EAP_SERVER_METHOD_INTERFACE_VERSION,
1578 EAP_VENDOR_IETF, EAP_TYPE_FAST, "FAST");
1582 eap->init = eap_fast_init;
1583 eap->reset = eap_fast_reset;
1584 eap->buildReq = eap_fast_buildReq;
1585 eap->check = eap_fast_check;
1586 eap->process = eap_fast_process;
1587 eap->isDone = eap_fast_isDone;
1588 eap->getKey = eap_fast_getKey;
1589 eap->get_emsk = eap_fast_get_emsk;
1590 eap->isSuccess = eap_fast_isSuccess;
1592 ret = eap_server_method_register(eap);
1594 eap_server_method_free(eap);