]> git.ozlabs.org Git - ppp.git/blob - pppd/eap.h
Add support for EAP-TLS (including experimental TLS v1.3 support).
[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 #ifdef  __cplusplus
27 extern "C" {
28 #endif
29
30 /*
31  * Packet header = Code, id, length.
32  */
33 #define EAP_HEADERLEN   4
34
35
36 /* EAP message codes. */
37 #define EAP_REQUEST     1
38 #define EAP_RESPONSE    2
39 #define EAP_SUCCESS     3
40 #define EAP_FAILURE     4
41
42 /* EAP types */
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
63 /* EAP SRP-SHA1 Subtypes */
64 #define EAPSRP_CHALLENGE        1       /* Request 1 - Challenge */
65 #define EAPSRP_CKEY             1       /* Response 1 - Client Key */
66 #define EAPSRP_SKEY             2       /* Request 2 - Server Key */
67 #define EAPSRP_CVALIDATOR       2       /* Response 2 - Client Validator */
68 #define EAPSRP_SVALIDATOR       3       /* Request 3 - Server Validator */
69 #define EAPSRP_ACK              3       /* Response 3 - final ack */
70 #define EAPSRP_LWRECHALLENGE    4       /* Req/resp 4 - Lightweight rechal */
71
72 #define SRPVAL_EBIT     0x00000001      /* Use shared key for ECP */
73
74 #define SRP_PSEUDO_ID   "pseudo_"
75 #define SRP_PSEUDO_LEN  7
76
77 #define MD5_SIGNATURE_SIZE      16
78 #define MIN_CHALLENGE_LENGTH    16
79 #define MAX_CHALLENGE_LENGTH    24
80
81 enum eap_state_code {
82         eapInitial = 0, /* No EAP authentication yet requested */
83         eapPending,     /* Waiting for LCP (no timer) */
84         eapClosed,      /* Authentication not in use */
85         eapListen,      /* Client ready (and timer running) */
86         eapIdentify,    /* EAP Identify sent */
87         eapTlsStart,    /* Send EAP-TLS start packet */
88         eapTlsRecv,     /* Receive EAP-TLS tls data */
89         eapTlsSendAck,  /* Send EAP-TLS ack */
90         eapTlsSend,     /* Send EAP-TLS tls data */
91         eapTlsRecvAck,  /* Receive EAP-TLS ack */
92         eapTlsRecvClient,       /* Receive EAP-TLS auth response from client*/
93         eapTlsSendAlert,        /* Send EAP-TLS tls alert (server)*/
94         eapTlsRecvAlertAck,     /* Receive EAP-TLS ack after sending alert */
95         eapTlsRecvSuccess,      /* Receive EAP success */
96         eapTlsRecvFailure,      /* Receive EAP failure */
97         eapSRP1,        /* Sent EAP SRP-SHA1 Subtype 1 */
98         eapSRP2,        /* Sent EAP SRP-SHA1 Subtype 2 */
99         eapSRP3,        /* Sent EAP SRP-SHA1 Subtype 3 */
100         eapMD5Chall,    /* Sent MD5-Challenge */
101         eapOpen,        /* Completed authentication */
102         eapSRP4,        /* Sent EAP SRP-SHA1 Subtype 4 */
103         eapBadAuth      /* Failed authentication */
104 };
105
106 #define EAP_STATES      \
107         "Initial", "Pending", "Closed", "Listen", "Identify", \
108         "TlsStart", "TlsRecv", "TlsSendAck", "TlsSend", "TlsRecvAck", "TlsRecvClient",\
109         "TlsSendAlert", "TlsRecvAlertAck" , "TlsRecvSuccess", "TlsRecvFailure", \
110         "SRP1", "SRP2", "SRP3", "MD5Chall", "Open", "SRP4", "BadAuth"
111
112 #ifdef USE_EAPTLS
113 #define eap_client_active(esp)  ((esp)->es_client.ea_state != eapInitial &&\
114                                  (esp)->es_client.ea_state != eapPending &&\
115                                  (esp)->es_client.ea_state != eapClosed)
116 #else
117 #define eap_client_active(esp)  ((esp)->es_client.ea_state == eapListen)
118 #endif /* USE_EAPTLS */
119
120 #define eap_server_active(esp)  \
121         ((esp)->es_server.ea_state >= eapIdentify && \
122          (esp)->es_server.ea_state <= eapMD5Chall)
123
124 struct eap_auth {
125         char *ea_name;          /* Our name */
126         char *ea_peer;          /* Peer's name */
127         void *ea_session;       /* Authentication library linkage */
128         u_char *ea_skey;        /* Shared encryption key */
129         int ea_timeout;         /* Time to wait (for retransmit/fail) */
130         int ea_maxrequests;     /* Max Requests allowed */
131         u_short ea_namelen;     /* Length of our name */
132         u_short ea_peerlen;     /* Length of peer's name */
133         enum eap_state_code ea_state;
134 #ifdef USE_EAPTLS
135         enum eap_state_code ea_prev_state;
136 #endif
137         u_char ea_id;           /* Current id */
138         u_char ea_requests;     /* Number of Requests sent/received */
139         u_char ea_responses;    /* Number of Responses */
140         u_char ea_type;         /* One of EAPT_* */
141         u_int32_t ea_keyflags;  /* SRP shared key usage flags */
142 #ifdef USE_EAPTLS
143         bool ea_using_eaptls;
144 #endif
145 };
146
147 /*
148  * Complete EAP state for one PPP session.
149  */
150 typedef struct eap_state {
151         int es_unit;                    /* Interface unit number */
152         struct eap_auth es_client;      /* Client (authenticatee) data */
153         struct eap_auth es_server;      /* Server (authenticator) data */
154         int es_savedtime;               /* Saved timeout */
155         int es_rechallenge;             /* EAP rechallenge interval */
156         int es_lwrechallenge;           /* SRP lightweight rechallenge inter */
157         bool es_usepseudo;              /* Use SRP Pseudonym if offered one */
158         int es_usedpseudo;              /* Set if we already sent PN */
159         int es_challen;                 /* Length of challenge string */
160         u_char es_challenge[MAX_CHALLENGE_LENGTH];
161 } eap_state;
162
163 /*
164  * Timeouts.
165  */
166 #define EAP_DEFTIMEOUT          3       /* Timeout (seconds) for rexmit */
167 #ifdef USE_EAPTLS
168 #define EAP_DEFTRANSMITS        30      /* max # times to transmit */
169                                         /* certificates can be long ... */
170 #else
171 #define EAP_DEFTRANSMITS        10      /* max # times to transmit */
172 #endif /* USE_EAPTLS */
173 #define EAP_DEFREQTIME          20      /* Time to wait for peer request */
174 #define EAP_DEFALLOWREQ         20      /* max # times to accept requests */
175
176 extern eap_state eap_states[];
177
178 void eap_authwithpeer __P((int unit, char *localname));
179 void eap_authpeer __P((int unit, char *localname));
180
181 extern struct protent eap_protent;
182
183 #ifdef  __cplusplus
184 }
185 #endif
186
187 #endif /* PPP_EAP_H */
188