]> git.ozlabs.org Git - ppp.git/blob - pppd/eap.h
cf5adace7c1c103ae160fbbcc80b86a522ef913e
[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.1 2002/11/02 19:48:12 carlsonj 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 enum eap_state_code {
78         eapInitial = 0, /* No EAP authentication yet requested */
79         eapPending,     /* Waiting for LCP (no timer) */
80         eapClosed,      /* Authentication not in use */
81         eapListen,      /* Client ready (and timer running) */
82         eapIdentify,    /* EAP Identify sent */
83         eapSRP1,        /* Sent EAP SRP-SHA1 Subtype 1 */
84         eapSRP2,        /* Sent EAP SRP-SHA1 Subtype 2 */
85         eapSRP3,        /* Sent EAP SRP-SHA1 Subtype 3 */
86         eapMD5Chall,    /* Sent MD5-Challenge */
87         eapOpen,        /* Completed authentication */
88         eapSRP4,        /* Sent EAP SRP-SHA1 Subtype 4 */
89         eapBadAuth      /* Failed authentication */
90 };
91
92 #define EAP_STATES      \
93         "Initial", "Pending", "Closed", "Listen", "Identify", \
94         "SRP1", "SRP2", "SRP3", "MD5Chall", "Open", "SRP4", "BadAuth"
95
96 #define eap_client_active(esp)  ((esp)->es_client.ea_state == eapListen)
97 #define eap_server_active(esp)  \
98         ((esp)->es_server.ea_state >= eapIdentify && \
99          (esp)->es_server.ea_state <= eapMD5Chall)
100
101 struct eap_auth {
102         char *ea_name;          /* Our name */
103         char *ea_peer;          /* Peer's name */
104         void *ea_session;       /* Authentication library linkage */
105         u_char *ea_skey;        /* Shared encryption key */
106         int ea_timeout;         /* Time to wait (for retransmit/fail) */
107         int ea_maxrequests;     /* Max Requests allowed */
108         u_short ea_namelen;     /* Length of our name */
109         u_short ea_peerlen;     /* Length of peer's name */
110         enum eap_state_code ea_state;
111         u_char ea_id;           /* Current id */
112         u_char ea_requests;     /* Number of Requests sent/received */
113         u_char ea_responses;    /* Number of Responses */
114         u_char ea_type;         /* One of EAPT_* */
115         u_int32_t ea_keyflags;  /* SRP shared key usage flags */
116 };
117
118 /*
119  * Complete EAP state for one PPP session.
120  */
121 typedef struct eap_state {
122         int es_unit;                    /* Interface unit number */
123         struct eap_auth es_client;      /* Client (authenticatee) data */
124         struct eap_auth es_server;      /* Server (authenticator) data */
125         int es_savedtime;               /* Saved timeout */
126         int es_rechallenge;             /* EAP rechallenge interval */
127         int es_lwrechallenge;           /* SRP lightweight rechallenge inter */
128         bool es_usepseudo;              /* Use SRP Pseudonym if offered one */
129         int es_usedpseudo;              /* Set if we already sent PN */
130         int es_challen;                 /* Length of challenge string */
131         u_char es_challenge[MAX_CHALLENGE_LENGTH];
132 } eap_state;
133
134 /*
135  * Timeouts.
136  */
137 #define EAP_DEFTIMEOUT          3       /* Timeout (seconds) for rexmit */
138 #define EAP_DEFTRANSMITS        10      /* max # times to transmit */
139 #define EAP_DEFREQTIME          20      /* Time to wait for peer request */
140 #define EAP_DEFALLOWREQ         20      /* max # times to accept requests */
141
142 extern eap_state eap_states[];
143
144 void eap_authwithpeer __P((int unit, char *localname));
145 void eap_authpeer __P((int unit, char *localname));
146
147 extern struct protent eap_protent;
148
149 #ifdef  __cplusplus
150 }
151 #endif
152
153 #endif /* PPP_EAP_H */
154