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