6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 * Copyright 2001 hereUare Communications, Inc. <raghud@hereuare.com>
21 * Copyright 2003 Alan DeKok <aland@freeradius.org>
26 * TLS Packet Format in EAP
27 * --- ------ ------ -- ---
29 * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
30 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
31 * | Code | Identifier | Length |
32 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
33 * | Type | Flags | TLS Message Length
34 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
35 * | TLS Message Length | TLS Data...
36 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
45 * Allocate a new TLS_PACKET
47 EAPTLS_PACKET *eaptls_alloc(void)
51 if ((rp = malloc(sizeof(EAPTLS_PACKET))) == NULL) {
52 radlog(L_ERR, "rlm_eap_tls: out of memory");
55 memset(rp, 0, sizeof(EAPTLS_PACKET));
62 void eaptls_free(EAPTLS_PACKET **eaptls_packet_ptr)
64 EAPTLS_PACKET *eaptls_packet;
66 if (!eaptls_packet_ptr) return;
67 eaptls_packet = *eaptls_packet_ptr;
68 if (eaptls_packet == NULL) return;
70 if (eaptls_packet->data) {
71 free(eaptls_packet->data);
72 eaptls_packet->data = NULL;
76 *eaptls_packet_ptr = NULL;
80 The S flag is set only within the EAP-TLS start message
81 sent from the EAP server to the peer.
83 int eaptls_start(EAP_DS *eap_ds, int peap_flag)
87 reply.code = EAPTLS_START;
88 reply.length = TLS_HEADER_LEN + 1/*flags*/;
90 reply.flags = peap_flag;
91 reply.flags = SET_START(reply.flags);
96 eaptls_compose(eap_ds, &reply);
101 int eaptls_success(EAP_DS *eap_ds, int peap_flag)
105 reply.code = EAPTLS_SUCCESS;
106 reply.length = TLS_HEADER_LEN;
107 reply.flags = peap_flag;
111 eaptls_compose(eap_ds, &reply);
116 int eaptls_fail(EAP_DS *eap_ds, int peap_flag)
120 reply.code = EAPTLS_FAIL;
121 reply.length = TLS_HEADER_LEN;
122 reply.flags = peap_flag;
126 eaptls_compose(eap_ds, &reply);
132 A single TLS record may be up to 16384 octets in length, but a TLS
133 message may span multiple TLS records, and a TLS certificate message
134 may in principle be as long as 16MB.
138 * Frame the Dirty data that needs to be send to the client in an
139 * EAP-Request. We always embed the TLS-length in all EAP-TLS
140 * packets that we send, for easy reference purpose. Handle
141 * fragmentation and sending the next fragment etc.
143 int eaptls_request(EAP_DS *eap_ds, tls_session_t *ssn)
148 unsigned int lbit = 0;
150 /* This value determines whether we set (L)ength flag for
151 EVERY packet we send and add corresponding
152 "TLS Message Length" field.
155 This means we include L flag and "TLS Msg Len" in EVERY
159 This means we include L flag and "TLS Msg Len" **ONLY**
160 in First packet of a fragment series. We do not use
163 Having L flag in every packet is prefered.
166 if (ssn->length_flag) {
169 if (ssn->fragment == 0) {
170 ssn->tls_msg_len = ssn->dirty_out.used;
173 reply.code = EAPTLS_REQUEST;
174 reply.flags = ssn->peap_flag;
176 /* Send data, NOT more than the FRAGMENT size */
177 if (ssn->dirty_out.used > ssn->offset) {
179 reply.flags = SET_MORE_FRAGMENTS(reply.flags);
180 /* Length MUST be included if it is the First Fragment */
181 if (ssn->fragment == 0) {
186 size = ssn->dirty_out.used;
190 reply.dlen = lbit + size;
191 reply.length = TLS_HEADER_LEN + 1/*flags*/ + reply.dlen;
193 reply.data = malloc(reply.dlen);
195 nlen = htonl(ssn->tls_msg_len);
196 memcpy(reply.data, &nlen, lbit);
197 reply.flags = SET_LENGTH_INCLUDED(reply.flags);
199 (ssn->record_minus)(&ssn->dirty_out, reply.data + lbit, size);
201 eaptls_compose(eap_ds, &reply);
209 * Acknowledge received is for one of the following messages sent earlier
210 * 1. Handshake completed Message, so now send, EAP-Success
211 * 2. Alert Message, now send, EAP-Failure
212 * 3. Fragment Message, now send, next Fragment
214 static eaptls_status_t eaptls_ack_handler(EAP_HANDLER *handler)
216 tls_session_t *tls_session;
218 tls_session = (tls_session_t *)handler->opaque;
219 if (tls_session == NULL){
220 radlog(L_ERR, "rlm_eap_tls: Unexpected ACK received");
223 if (tls_session->info.initialized == 0) {
224 DEBUG(" rlm_eap_tls: No SSL info available. Waiting for more SSL data.");
225 return EAPTLS_REQUEST;
227 if (tls_session->info.origin == 0) {
228 radlog(L_ERR, "rlm_eap_tls: Unexpected ACK received");
232 switch (tls_session->info.content_type) {
234 DEBUG2(" rlm_eap_tls: ack alert");
235 eaptls_fail(handler->eap_ds, tls_session->peap_flag);
239 if (tls_session->info.handshake_type == finished) {
240 DEBUG2(" rlm_eap_tls: ack handshake is finished");
241 return EAPTLS_SUCCESS;
244 DEBUG2(" rlm_eap_tls: ack handshake fragment handler");
245 /* Fragmentation handler, send next fragment */
246 return EAPTLS_REQUEST;
249 * For the rest of the conditions, switch over
250 * to the default section below.
253 DEBUG2(" rlm_eap_tls: ack default");
254 radlog(L_ERR, "rlm_eap_tls: Invalid ACK received: %d",
255 tls_session->info.content_type);
261 * Similarly, when the EAP server receives an EAP-Response with
262 * the M bit set, it MUST respond with an EAP-Request with
263 * EAP-Type=EAP-TLS and no data. This serves as a fragment ACK.
265 * In order to prevent errors in the processing of fragments, the
266 * EAP server MUST use increment the Identifier value for each
267 * fragment ACK contained within an EAP-Request, and the peer
268 * MUST include this Identifier value in the subsequent fragment
269 * contained within an EAP- Reponse.
271 * EAP server sends an ACK when it determines there are More
272 * fragments to receive to make the complete
273 * TLS-record/TLS-Message
275 static int eaptls_send_ack(EAP_DS *eap_ds, int peap_flag)
279 reply.code = EAPTLS_ACK;
280 reply.length = TLS_HEADER_LEN + 1/*flags*/;
281 reply.flags = peap_flag;
285 eaptls_compose(eap_ds, &reply);
291 * The S flag is set only within the EAP-TLS start message sent
292 * from the EAP server to the peer.
294 * Similarly, when the EAP server receives an EAP-Response with
295 * the M bit set, it MUST respond with an EAP-Request with
296 * EAP-Type=EAP-TLS and no data. This serves as a fragment
297 * ACK. The EAP peer MUST wait.
299 static eaptls_status_t eaptls_verify(EAP_HANDLER *handler)
301 EAP_DS *eap_ds = handler->eap_ds;
302 EAP_DS *prev_eap_ds = handler->prev_eapds;
303 eaptls_packet_t *eaptls_packet, *eaptls_prev = NULL;
306 * We don't check ANY of the input parameters. It's all
307 * code which works together, so if something is wrong,
308 * we SHOULD core dump.
310 * e.g. if eap_ds is NULL, of if eap_ds->response is
311 * NULL, of if it's NOT an EAP-Response, or if the packet
312 * is too short. See eap_validation()., in ../../eap.c
314 * Also, eaptype_select() takes care of selecting the
315 * appropriate type, so we don't need to check
316 * eap_ds->response->type.type == PW_EAP_TLS, or anything
319 eaptls_packet = (eaptls_packet_t *)eap_ds->response->type.data;
320 if (prev_eap_ds && prev_eap_ds->response)
321 eaptls_prev = (eaptls_packet_t *)prev_eap_ds->response->type.data;
326 * If there's no TLS data, or there's 1 byte of TLS data,
327 * with the flags set to zero, then it's an ACK.
329 * Find if this is a reply to the previous request sent
331 if ((eaptls_packet == NULL) ||
332 ((eap_ds->response->length == EAP_HEADER_LEN + 2) &&
333 ((eaptls_packet->flags & 0xc0) == 0x00))) {
336 (prev_eap_ds->request->id == eap_ds->response->id)) {
338 * Run the ACK handler directly from here.
340 DEBUG2("rlm_eap_tls: Received EAP-TLS ACK message");
341 return eaptls_ack_handler(handler);
343 radlog(L_ERR, "rlm_eap_tls: Received Invalid EAP-TLS ACK message");
344 return EAPTLS_INVALID;
349 * We send TLS_START, but do not receive it.
351 if (TLS_START(eaptls_packet->flags)) {
352 radlog(L_ERR, "rlm_eap_tls: Received unexpected EAP-TLS Start message");
353 return EAPTLS_INVALID;
357 * The L bit (length included) is set to indicate the
358 * presence of the four octet TLS Message Length field,
359 * and MUST be set for the first fragment of a fragmented
360 * TLS message or set of messages.
362 * The M bit (more fragments) is set on all but the last
365 * The S bit (EAP-TLS start) is set in an EAP-TLS Start
366 * message. This differentiates the EAP-TLS Start message
367 * from a fragment acknowledgement.
369 if (TLS_LENGTH_INCLUDED(eaptls_packet->flags)) {
370 if (TLS_MORE_FRAGMENTS(eaptls_packet->flags)) {
372 * FIRST_FRAGMENT is identified
373 * 1. If there is no previous EAP-response received.
374 * 2. If EAP-response received, then its M bit not set.
375 * (It is because Last fragment will not have M bit set)
378 (prev_eap_ds->response == NULL) ||
379 (eaptls_prev == NULL) ||
380 !TLS_MORE_FRAGMENTS(eaptls_prev->flags)) {
382 DEBUG2("rlm_eap_tls: Received EAP-TLS First Fragment of the message");
383 return EAPTLS_FIRST_FRAGMENT;
386 DEBUG2("rlm_eap_tls: More Fragments with length included");
387 return EAPTLS_MORE_FRAGMENTS_WITH_LENGTH;
391 DEBUG2("rlm_eap_tls: Length Included");
392 return EAPTLS_LENGTH_INCLUDED;
396 if (TLS_MORE_FRAGMENTS(eaptls_packet->flags)) {
397 DEBUG2("rlm_eap_tls: More fragments to follow");
398 return EAPTLS_MORE_FRAGMENTS;
402 * None of the flags are set, but it's still a valid
412 * length = code + id + length + flags + tlsdata
413 * = 1 + 1 + 2 + 1 + X
414 * length = EAP-length - 1(EAP-Type = 1 octet)
415 * flags = EAP-typedata[0] (1 octet)
416 * dlen = EAP-typedata[1-4] (4 octets), if L flag set
417 * = length - 5(code+id+length+flags), otherwise
418 * data = EAP-typedata[5-n], if L flag set
419 * = EAP-typedata[1-n], otherwise
420 * packet = EAP-typedata (complete typedata)
422 * Points to consider during EAP-TLS data extraction
423 * 1. In the received packet, No data will be present incase of ACK-NAK
424 * 2. Incase if more fragments need to be received then ACK after retreiving this fragment.
426 * RFC 2716 Section 4.2. PPP EAP TLS Request Packet
429 * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
430 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
431 * | Code | Identifier | Length |
432 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
433 * | Type | Flags | TLS Message Length
434 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
435 * | TLS Message Length | TLS Data...
436 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
438 * The Length field is two octets and indicates the length of the EAP
439 * packet including the Code, Identifir, Length, Type, and TLS data
442 static EAPTLS_PACKET *eaptls_extract(EAP_DS *eap_ds, eaptls_status_t status)
444 EAPTLS_PACKET *tlspacket;
445 uint32_t data_len = 0;
447 uint8_t *data = NULL;
449 if (status == EAPTLS_INVALID)
453 * The main EAP code & eaptls_verify() take care of
454 * ensuring that the packet is OK, and that we can
455 * extract the various fields we want.
457 * e.g. a TLS packet with zero data is allowed as an ACK,
458 * but we will never see it here, as we will simply
459 * send another fragment, instead of trying to extract
462 * MUST have TLS type octet, followed by flags, followed
465 assert(eap_ds->response->length > 2);
467 tlspacket = eaptls_alloc();
468 if (tlspacket == NULL) return NULL;
471 * Code & id for EAPTLS & EAP are same
472 * but eaptls_length = eap_length - 1(EAP-Type = 1 octet)
474 * length = code + id + length + type + tlsdata
475 * = 1 + 1 + 2 + 1 + X
477 tlspacket->code = eap_ds->response->code;
478 tlspacket->id = eap_ds->response->id;
479 tlspacket->length = eap_ds->response->length - 1; /* EAP type */
480 tlspacket->flags = eap_ds->response->type.data[0];
483 * A quick sanity check of the flags. If we've been told
484 * that there's a length, and there isn't one, then stop.
486 if (TLS_LENGTH_INCLUDED(tlspacket->flags) &&
487 (tlspacket->length < 5)) { /* flags + TLS message length */
488 radlog(L_ERR, "rlm_eap_tls: Invalid EAP-TLS packet received. (Length bit is set, but no length was found.)");
489 eaptls_free(&tlspacket);
494 * If the final TLS packet is larger than we can handle, die
497 * Likewise, if the EAP packet says N bytes, and the TLS
498 * packet says there's fewer bytes, it's a problem.
500 * FIXME: Try to ensure that the claimed length is
501 * consistent across multiple TLS fragments.
503 if (TLS_LENGTH_INCLUDED(tlspacket->flags)) {
504 memcpy(&data_len, &eap_ds->response->type.data[1], 4);
505 data_len = ntohl(data_len);
506 if (data_len > MAX_RECORD_SIZE) {
507 radlog(L_ERR, "rlm_eap_tls: The EAP-TLS packet will contain more data than we can process.");
508 eaptls_free(&tlspacket);
513 DEBUG2(" TLS: %d %d\n", data_len, tlspacket->length);
515 if (data_len < tlspacket->length) {
516 radlog(L_ERR, "rlm_eap_tls: EAP-TLS packet claims to be smaller than the encapsulating EAP packet.");
517 eaptls_free(&tlspacket);
525 * The TLS Message Length field is four octets, and
526 * provides the total length of the TLS message or set of
527 * messages that is being fragmented; this simplifies
530 * Dynamic allocation of buffers as & when we know the
531 * length should solve the problem.
533 case EAPTLS_FIRST_FRAGMENT:
534 case EAPTLS_LENGTH_INCLUDED:
535 case EAPTLS_MORE_FRAGMENTS_WITH_LENGTH:
536 if (tlspacket->length < 5) { /* flags + TLS message length */
537 radlog(L_ERR, "rlm_eap_tls: Invalid EAP-TLS packet received. (Expected length, got none.)");
538 eaptls_free(&tlspacket);
543 * Extract all the TLS fragments from the
544 * previous eap_ds Start appending this
545 * fragment to the above ds
547 memcpy(&data_len, &eap_ds->response->type.data[1], sizeof(uint32_t));
548 data_len = ntohl(data_len);
549 data = (eap_ds->response->type.data + 5/*flags+TLS-Length*/);
550 len = eap_ds->response->type.length - 5/*flags+TLS-Length*/;
553 * Hmm... this should be an error, too.
555 if (data_len > len) {
561 * Data length is implicit, from the EAP header.
563 case EAPTLS_MORE_FRAGMENTS:
565 data_len = eap_ds->response->type.length - 1/*flags*/;
566 data = eap_ds->response->type.data + 1/*flags*/;
570 radlog(L_ERR, "rlm_eap_tls: Invalid EAP-TLS packet received");
571 eaptls_free(&tlspacket);
575 tlspacket->dlen = data_len;
577 tlspacket->data = (unsigned char *)malloc(data_len);
578 if (tlspacket->data == NULL) {
579 radlog(L_ERR, "rlm_eap_tls: out of memory");
580 eaptls_free(&tlspacket);
583 memcpy(tlspacket->data, data, data_len);
592 * To process the TLS,
594 * 1. EAP-TLS should get the compelete TLS data from the peer.
595 * 2. Store that data in a data structure with any other required info
596 * 3. Handle that data structure to the TLS module.
597 * 4. TLS module will perform its operations on the data and
598 * handle back to EAP-TLS
601 * 1. EAP-TLS if necessary will fragment it and send it to the
604 * During EAP-TLS initialization, TLS Context object will be
605 * initialized and stored. For every new authentication
606 * requests, TLS will open a new session object and that session
607 * object should be maintained even after the session is
608 * completed for session resumption. (Probably later as a feature
609 * as we donot know who maintains these session objects ie,
610 * SSL_CTX (internally) or TLS module(explicitly). If TLS module,
611 * then how to let SSL API know about these sessions.)
613 static void eaptls_operation(EAPTLS_PACKET *eaptls_packet UNUSED,
614 eaptls_status_t status, EAP_HANDLER *handler)
616 tls_session_t *tls_session;
618 tls_session = (tls_session_t *)handler->opaque;
620 if ((status == EAPTLS_MORE_FRAGMENTS) ||
621 (status == EAPTLS_MORE_FRAGMENTS_WITH_LENGTH) ||
622 (status == EAPTLS_FIRST_FRAGMENT)) {
626 eaptls_send_ack(handler->eap_ds, tls_session->peap_flag);
629 * We have the complete TLS-data or TLS-message.
631 * Clean the dirty message.
633 * Authenticate the user and send
637 * is required then send another request. */
638 if (tls_handshake_recv(tls_session)) {
640 * FIXME: return success/fail.
642 * TLS proper can decide what to do, then.
644 eaptls_request(handler->eap_ds, tls_session);
646 eaptls_fail(handler->eap_ds, tls_session->peap_flag);
654 * In the actual authentication first verify the packet and then create the data structure
657 * To process the TLS,
659 * 1. EAP-TLS should get the compelete TLS data from the peer.
660 * 2. Store that data in a data structure with any other required info
661 * 3. Hand this data structure to the TLS module.
662 * 4. TLS module will perform its operations on the data and hands back to EAP-TLS
664 * 1. EAP-TLS if necessary will fragment it and send it to the destination.
666 * During EAP-TLS initialization, TLS Context object will be
667 * initialized and stored. For every new authentication
668 * requests, TLS will open a new session object and that
669 * session object SHOULD be maintained even after the session
670 * is completed, for session resumption. (Probably later as a
671 * feature, as we do not know who maintains these session
672 * objects ie, SSL_CTX (internally) or TLS module (explicitly). If
673 * TLS module, then how to let SSL API know about these
678 * Process an EAP request
680 eaptls_status_t eaptls_process(EAP_HANDLER *handler)
682 tls_session_t *tls_session = (tls_session_t *) handler->opaque;
683 EAPTLS_PACKET *tlspacket;
684 eaptls_status_t status;
686 DEBUG2(" rlm_eap_tls: processing TLS");
688 /* This case is when SSL generates Alert then we
689 * send that alert to the client and then send the EAP-Failure
691 status = eaptls_verify(handler);
692 DEBUG2(" eaptls_verify returned %d\n", status);
700 * Success means that we're done the initial
701 * handshake. For TTLS, this means send stuff
702 * back to the client, and the client sends us
703 * more tunneled data.
710 * Normal TLS request, continue with the "get rest
711 * of fragments" phase.
714 eaptls_request(handler->eap_ds, tls_session);
715 return EAPTLS_HANDLED;
719 * The handshake is done, and we're in the "tunnel
723 DEBUG2(" rlm_eap_tls: Done initial handshake");
726 * Get the rest of the fragments.
728 case EAPTLS_FIRST_FRAGMENT:
729 case EAPTLS_MORE_FRAGMENTS:
730 case EAPTLS_LENGTH_INCLUDED:
731 case EAPTLS_MORE_FRAGMENTS_WITH_LENGTH:
736 * Extract the TLS packet from the buffer.
738 if ((tlspacket = eaptls_extract(handler->eap_ds, status)) == NULL)
742 * Get the session struct from the handler
744 * update the dirty_in buffer
746 * NOTE: This buffer will contain partial data when M bit is set.
748 * CAUTION while reinitializing this buffer, it should be
749 * reinitialized only when this M bit is NOT set.
751 if (tlspacket->dlen !=
752 (tls_session->record_plus)(&tls_session->dirty_in, tlspacket->data, tlspacket->dlen)) {
753 eaptls_free(&tlspacket);
754 radlog(L_ERR, "rlm_eap_tls: Exceeded maximum record size");
759 * SSL initalization is done. Return.
761 * The TLS data will be in the tls_session structure.
763 if (SSL_is_init_finished(tls_session->ssl)) {
764 eaptls_free(&tlspacket);
769 * Continue the handshake.
771 eaptls_operation(tlspacket, status, handler);
773 eaptls_free(&tlspacket);
774 return EAPTLS_HANDLED;
779 * compose the TLS reply packet in the EAP reply typedata
781 int eaptls_compose(EAP_DS *eap_ds, EAPTLS_PACKET *reply)
786 * Don't set eap_ds->request->type.type, as the main EAP
787 * handler will do that for us. This allows the TLS
788 * module to be called from TTLS & PEAP.
792 * When the EAP server receives an EAP-Response with the
793 * M bit set, it MUST respond with an EAP-Request with
794 * EAP-Type=EAP-TLS and no data. This serves as a
795 * fragment ACK. The EAP peer MUST wait until it receives
796 * the EAP-Request before sending another fragment.
798 * In order to prevent errors in the processing of
799 * fragments, the EAP server MUST use increment the
800 * Identifier value for each fragment ACK contained
801 * within an EAP-Request, and the peer MUST include this
802 * Identifier value in the subsequent fragment contained
803 * within an EAP- Reponse.
805 eap_ds->request->type.data = malloc(reply->length - TLS_HEADER_LEN + 1);
806 if (eap_ds->request->type.data == NULL) {
807 radlog(L_ERR, "rlm_eap_tls: out of memory");
811 /* EAPTLS Header length is excluded while computing EAP typelen */
812 eap_ds->request->type.length = reply->length - TLS_HEADER_LEN;
814 ptr = eap_ds->request->type.data;
815 *ptr++ = (uint8_t)(reply->flags & 0xFF);
817 if (reply->dlen) memcpy(ptr, reply->data, reply->dlen);
819 switch (reply->code) {
823 eap_ds->request->code = PW_EAP_REQUEST;
826 eap_ds->request->code = PW_EAP_SUCCESS;
829 eap_ds->request->code = PW_EAP_FAILURE;
832 /* Should never enter here */
833 eap_ds->request->code = PW_EAP_FAILURE;