2 * eap.h - Extensible Authentication Protocol for PPP (RFC 2284)
4 * Copyright (c) 2001 by Sun Microsystems, Inc.
7 * Non-exclusive rights to redistribute, modify, translate, and use
8 * this software in source and binary forms, in whole or in part, is
9 * hereby granted, provided that the above copyright notice is
10 * duplicated in any source form, and that neither the name of the
11 * copyright holder nor the author is used to endorse or promote
12 * products derived from this software.
14 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
15 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
16 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
18 * Original version by James Carlson
20 * $Id: eap.h,v 1.2 2003/06/11 23:56:26 paulus Exp $
31 * Packet header = Code, id, length.
33 #define EAP_HEADERLEN 4
36 /* EAP message codes. */
38 #define EAP_RESPONSE 2
43 #define EAPT_IDENTITY 1
44 #define EAPT_NOTIFICATION 2
45 #define EAPT_NAK 3 /* (response only) */
46 #define EAPT_MD5CHAP 4
47 #define EAPT_OTP 5 /* One-Time Password; RFC 1938 */
48 #define EAPT_TOKEN 6 /* Generic Token Card */
49 /* 7 and 8 are unassigned. */
50 #define EAPT_RSA 9 /* RSA Public Key Authentication */
51 #define EAPT_DSS 10 /* DSS Unilateral */
52 #define EAPT_KEA 11 /* KEA */
53 #define EAPT_KEA_VALIDATE 12 /* KEA-VALIDATE */
54 #define EAPT_TLS 13 /* EAP-TLS */
55 #define EAPT_DEFENDER 14 /* Defender Token (AXENT) */
56 #define EAPT_W2K 15 /* Windows 2000 EAP */
57 #define EAPT_ARCOT 16 /* Arcot Systems */
58 #define EAPT_CISCOWIRELESS 17 /* Cisco Wireless */
59 #define EAPT_NOKIACARD 18 /* Nokia IP smart card */
60 #define EAPT_SRP 19 /* Secure Remote Password */
61 /* 20 is deprecated */
62 #define EAPT_TTLS 21 /* EAP Tunneled TLS Authentication Protocol RFC5281 */
63 #define EAPT_RAS 22 /* Remote Access Service */
64 #define EAPT_AKA 23 /* EAP method for 3rd Generation Authentication and Key Agreement RFC4187 */
65 #define EAPT_3COM 24 /* EAP-3Com Wireless */
66 #define EAPT_PEAP 25 /* Protected EAP */
67 #define EAPT_MSCHAPV2 26 /* EAP-MSCHAPv2 RFC-draft-kamath-pppext-eap-mschapv2-02 */
69 /* OpCodes for MSCHAPv2 */
70 #define CHAP_CHALLENGE 1
71 #define CHAP_RESPONSE 2
72 #define CHAP_SUCCESS 3
73 #define CHAP_FAILURE 4
75 /* EAP SRP-SHA1 Subtypes */
76 #define EAPSRP_CHALLENGE 1 /* Request 1 - Challenge */
77 #define EAPSRP_CKEY 1 /* Response 1 - Client Key */
78 #define EAPSRP_SKEY 2 /* Request 2 - Server Key */
79 #define EAPSRP_CVALIDATOR 2 /* Response 2 - Client Validator */
80 #define EAPSRP_SVALIDATOR 3 /* Request 3 - Server Validator */
81 #define EAPSRP_ACK 3 /* Response 3 - final ack */
82 #define EAPSRP_LWRECHALLENGE 4 /* Req/resp 4 - Lightweight rechal */
84 #define SRPVAL_EBIT 0x00000001 /* Use shared key for ECP */
86 #define SRP_PSEUDO_ID "pseudo_"
87 #define SRP_PSEUDO_LEN 7
89 #define MD5_SIGNATURE_SIZE 16
90 #define MIN_CHALLENGE_LENGTH 16
91 #define MAX_CHALLENGE_LENGTH 24
94 eapInitial = 0, /* No EAP authentication yet requested */
95 eapPending, /* Waiting for LCP (no timer) */
96 eapClosed, /* Authentication not in use */
97 eapListen, /* Client ready (and timer running) */
98 eapIdentify, /* EAP Identify sent */
99 eapTlsStart, /* Send EAP-TLS start packet */
100 eapTlsRecv, /* Receive EAP-TLS tls data */
101 eapTlsSendAck, /* Send EAP-TLS ack */
102 eapTlsSend, /* Send EAP-TLS tls data */
103 eapTlsRecvAck, /* Receive EAP-TLS ack */
104 eapTlsRecvClient, /* Receive EAP-TLS auth response from client*/
105 eapTlsSendAlert, /* Send EAP-TLS tls alert (server)*/
106 eapTlsRecvAlertAck, /* Receive EAP-TLS ack after sending alert */
107 eapTlsRecvSuccess, /* Receive EAP success */
108 eapTlsRecvFailure, /* Receive EAP failure */
109 eapSRP1, /* Sent EAP SRP-SHA1 Subtype 1 */
110 eapSRP2, /* Sent EAP SRP-SHA1 Subtype 2 */
111 eapSRP3, /* Sent EAP SRP-SHA1 Subtype 3 */
112 eapMD5Chall, /* Sent MD5-Challenge */
113 eapMSCHAPv2Chall, /* Sent MSCHAPv2-Challenge */
114 eapOpen, /* Completed authentication */
115 eapSRP4, /* Sent EAP SRP-SHA1 Subtype 4 */
116 eapBadAuth /* Failed authentication */
120 "Initial", "Pending", "Closed", "Listen", "Identify", \
121 "TlsStart", "TlsRecv", "TlsSendAck", "TlsSend", "TlsRecvAck", "TlsRecvClient",\
122 "TlsSendAlert", "TlsRecvAlertAck" , "TlsRecvSuccess", "TlsRecvFailure", \
123 "SRP1", "SRP2", "SRP3", "MD5Chall", "MSCHAPv2Chall", "Open", "SRP4", "BadAuth"
126 #define eap_client_active(esp) ((esp)->es_client.ea_state != eapInitial &&\
127 (esp)->es_client.ea_state != eapPending &&\
128 (esp)->es_client.ea_state != eapClosed)
130 #define eap_client_active(esp) ((esp)->es_client.ea_state == eapListen)
131 #endif /* USE_EAPTLS */
133 #define eap_server_active(esp) \
134 ((esp)->es_server.ea_state >= eapIdentify && \
135 (esp)->es_server.ea_state <= eapMD5Chall)
138 char *ea_name; /* Our name */
139 char *ea_peer; /* Peer's name */
140 void *ea_session; /* Authentication library linkage */
141 u_char *ea_skey; /* Shared encryption key */
142 int ea_timeout; /* Time to wait (for retransmit/fail) */
143 int ea_maxrequests; /* Max Requests allowed */
144 u_short ea_namelen; /* Length of our name */
145 u_short ea_peerlen; /* Length of peer's name */
146 enum eap_state_code ea_state;
148 enum eap_state_code ea_prev_state;
151 struct chap_digest_type *digest;
153 u_char ea_id; /* Current id */
154 u_char ea_requests; /* Number of Requests sent/received */
155 u_char ea_responses; /* Number of Responses */
156 u_char ea_type; /* One of EAPT_* */
157 u_int32_t ea_keyflags; /* SRP shared key usage flags */
159 bool ea_using_eaptls;
164 * Complete EAP state for one PPP session.
166 typedef struct eap_state {
167 int es_unit; /* Interface unit number */
168 struct eap_auth es_client; /* Client (authenticatee) data */
169 struct eap_auth es_server; /* Server (authenticator) data */
170 int es_savedtime; /* Saved timeout */
171 int es_rechallenge; /* EAP rechallenge interval */
172 int es_lwrechallenge; /* SRP lightweight rechallenge inter */
173 bool es_usepseudo; /* Use SRP Pseudonym if offered one */
174 int es_usedpseudo; /* Set if we already sent PN */
175 int es_challen; /* Length of challenge string */
176 u_char es_challenge[MAX_CHALLENGE_LENGTH];
182 #define EAP_DEFTIMEOUT 3 /* Timeout (seconds) for rexmit */
184 #define EAP_DEFTRANSMITS 30 /* max # times to transmit */
185 /* certificates can be long ... */
187 #define EAP_DEFTRANSMITS 10 /* max # times to transmit */
188 #endif /* USE_EAPTLS */
189 #define EAP_DEFREQTIME 20 /* Time to wait for peer request */
190 #define EAP_DEFALLOWREQ 20 /* max # times to accept requests */
192 extern eap_state eap_states[];
194 void eap_authwithpeer (int unit, char *localname);
195 void eap_authpeer (int unit, char *localname);
197 extern struct protent eap_protent;
203 #endif /* PPP_EAP_H */