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 $
33 * Packet header = Code, id, length.
35 #define EAP_HEADERLEN 4
38 /* EAP message codes. */
40 #define EAP_RESPONSE 2
45 #define EAPT_IDENTITY 1
46 #define EAPT_NOTIFICATION 2
47 #define EAPT_NAK 3 /* (response only) */
48 #define EAPT_MD5CHAP 4
49 #define EAPT_OTP 5 /* One-Time Password; RFC 1938 */
50 #define EAPT_TOKEN 6 /* Generic Token Card */
51 /* 7 and 8 are unassigned. */
52 #define EAPT_RSA 9 /* RSA Public Key Authentication */
53 #define EAPT_DSS 10 /* DSS Unilateral */
54 #define EAPT_KEA 11 /* KEA */
55 #define EAPT_KEA_VALIDATE 12 /* KEA-VALIDATE */
56 #define EAPT_TLS 13 /* EAP-TLS */
57 #define EAPT_DEFENDER 14 /* Defender Token (AXENT) */
58 #define EAPT_W2K 15 /* Windows 2000 EAP */
59 #define EAPT_ARCOT 16 /* Arcot Systems */
60 #define EAPT_CISCOWIRELESS 17 /* Cisco Wireless */
61 #define EAPT_NOKIACARD 18 /* Nokia IP smart card */
62 #define EAPT_SRP 19 /* Secure Remote Password */
63 /* 20 is deprecated */
64 #define EAPT_TTLS 21 /* EAP Tunneled TLS Authentication Protocol RFC5281 */
65 #define EAPT_RAS 22 /* Remote Access Service */
66 #define EAPT_AKA 23 /* EAP method for 3rd Generation Authentication and Key Agreement RFC4187 */
67 #define EAPT_3COM 24 /* EAP-3Com Wireless */
68 #define EAPT_PEAP 25 /* Protected EAP */
69 #define EAPT_MSCHAPV2 26 /* EAP-MSCHAPv2 RFC-draft-kamath-pppext-eap-mschapv2-02 */
71 /* OpCodes for MSCHAPv2 */
72 #define CHAP_CHALLENGE 1
73 #define CHAP_RESPONSE 2
74 #define CHAP_SUCCESS 3
75 #define CHAP_FAILURE 4
77 /* EAP SRP-SHA1 Subtypes */
78 #define EAPSRP_CHALLENGE 1 /* Request 1 - Challenge */
79 #define EAPSRP_CKEY 1 /* Response 1 - Client Key */
80 #define EAPSRP_SKEY 2 /* Request 2 - Server Key */
81 #define EAPSRP_CVALIDATOR 2 /* Response 2 - Client Validator */
82 #define EAPSRP_SVALIDATOR 3 /* Request 3 - Server Validator */
83 #define EAPSRP_ACK 3 /* Response 3 - final ack */
84 #define EAPSRP_LWRECHALLENGE 4 /* Req/resp 4 - Lightweight rechal */
86 #define SRPVAL_EBIT 0x00000001 /* Use shared key for ECP */
88 #define SRP_PSEUDO_ID "pseudo_"
89 #define SRP_PSEUDO_LEN 7
91 #define MD5_SIGNATURE_SIZE 16
92 #define MIN_CHALLENGE_LENGTH 16
93 #define MAX_CHALLENGE_LENGTH 24
96 eapInitial = 0, /* No EAP authentication yet requested */
97 eapPending, /* Waiting for LCP (no timer) */
98 eapClosed, /* Authentication not in use */
99 eapListen, /* Client ready (and timer running) */
100 eapIdentify, /* EAP Identify sent */
101 eapTlsStart, /* Send EAP-TLS start packet */
102 eapTlsRecv, /* Receive EAP-TLS tls data */
103 eapTlsSendAck, /* Send EAP-TLS ack */
104 eapTlsSend, /* Send EAP-TLS tls data */
105 eapTlsRecvAck, /* Receive EAP-TLS ack */
106 eapTlsRecvClient, /* Receive EAP-TLS auth response from client*/
107 eapTlsSendAlert, /* Send EAP-TLS tls alert (server)*/
108 eapTlsRecvAlertAck, /* Receive EAP-TLS ack after sending alert */
109 eapTlsRecvSuccess, /* Receive EAP success */
110 eapTlsRecvFailure, /* Receive EAP failure */
111 eapSRP1, /* Sent EAP SRP-SHA1 Subtype 1 */
112 eapSRP2, /* Sent EAP SRP-SHA1 Subtype 2 */
113 eapSRP3, /* Sent EAP SRP-SHA1 Subtype 3 */
114 eapMD5Chall, /* Sent MD5-Challenge */
115 eapMSCHAPv2Chall, /* Sent MSCHAPv2-Challenge */
116 eapOpen, /* Completed authentication */
117 eapSRP4, /* Sent EAP SRP-SHA1 Subtype 4 */
118 eapBadAuth /* Failed authentication */
122 "Initial", "Pending", "Closed", "Listen", "Identify", \
123 "TlsStart", "TlsRecv", "TlsSendAck", "TlsSend", "TlsRecvAck", "TlsRecvClient",\
124 "TlsSendAlert", "TlsRecvAlertAck" , "TlsRecvSuccess", "TlsRecvFailure", \
125 "SRP1", "SRP2", "SRP3", "MD5Chall", "MSCHAPv2Chall", "Open", "SRP4", "BadAuth"
128 #define eap_client_active(esp) ((esp)->es_client.ea_state != eapInitial &&\
129 (esp)->es_client.ea_state != eapPending &&\
130 (esp)->es_client.ea_state != eapClosed)
132 #define eap_client_active(esp) ((esp)->es_client.ea_state == eapListen)
133 #endif /* USE_EAPTLS */
135 #define eap_server_active(esp) \
136 ((esp)->es_server.ea_state >= eapIdentify && \
137 (esp)->es_server.ea_state <= eapMD5Chall)
140 char *ea_name; /* Our name */
141 char *ea_peer; /* Peer's name */
142 void *ea_session; /* Authentication library linkage */
143 u_char *ea_skey; /* Shared encryption key */
144 int ea_timeout; /* Time to wait (for retransmit/fail) */
145 int ea_maxrequests; /* Max Requests allowed */
146 u_short ea_namelen; /* Length of our name */
147 u_short ea_peerlen; /* Length of peer's name */
148 enum eap_state_code ea_state;
150 enum eap_state_code ea_prev_state;
153 struct chap_digest_type *digest;
155 u_char ea_id; /* Current id */
156 u_char ea_requests; /* Number of Requests sent/received */
157 u_char ea_responses; /* Number of Responses */
158 u_char ea_type; /* One of EAPT_* */
159 u_int32_t ea_keyflags; /* SRP shared key usage flags */
161 bool ea_using_eaptls;
166 * Complete EAP state for one PPP session.
168 typedef struct eap_state {
169 int es_unit; /* Interface unit number */
170 struct eap_auth es_client; /* Client (authenticatee) data */
171 struct eap_auth es_server; /* Server (authenticator) data */
172 int es_savedtime; /* Saved timeout */
173 int es_rechallenge; /* EAP rechallenge interval */
174 int es_lwrechallenge; /* SRP lightweight rechallenge inter */
175 bool es_usepseudo; /* Use SRP Pseudonym if offered one */
176 int es_usedpseudo; /* Set if we already sent PN */
177 int es_challen; /* Length of challenge string */
178 u_char es_challenge[MAX_CHALLENGE_LENGTH];
184 #define EAP_DEFTIMEOUT 3 /* Timeout (seconds) for rexmit */
186 #define EAP_DEFTRANSMITS 30 /* max # times to transmit */
187 /* certificates can be long ... */
189 #define EAP_DEFTRANSMITS 10 /* max # times to transmit */
190 #endif /* USE_EAPTLS */
191 #define EAP_DEFREQTIME 20 /* Time to wait for peer request */
192 #define EAP_DEFALLOWREQ 20 /* max # times to accept requests */
194 extern eap_state eap_states[];
196 void eap_authwithpeer (int unit, char *localname);
197 void eap_authpeer (int unit, char *localname);
199 extern struct protent eap_protent;
205 #endif /* PPP_EAP_H */