Debian Codegraph @

pppd/eap.h

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