The Pedigree Project 0.1
eap.h
1/*
2 * Copyright (c) 2008-2014, Pedigree Developers
3 *
4 * Please see the CONTRIB file in the root of the source tree for a full
5 * list of contributors.
6 *
7 * Permission to use, copy, modify, and distribute this software for any
8 * purpose with or without fee is hereby granted, provided that the above
9 * copyright notice and this permission notice appear in all copies.
10 *
11 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18 */
19
20/*
21 * eap.h - Extensible Authentication Protocol for PPP (RFC 2284)
22 *
23 * Copyright (c) 2001 by Sun Microsystems, Inc.
24 * All rights reserved.
25 *
26 * Non-exclusive rights to redistribute, modify, translate, and use
27 * this software in source and binary forms, in whole or in part, is
28 * hereby granted, provided that the above copyright notice is
29 * duplicated in any source form, and that neither the name of the
30 * copyright holder nor the author is used to endorse or promote
31 * products derived from this software.
32 *
33 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
34 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
35 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
36 *
37 * Original version by James Carlson
38 *
39 * $Id: eap.h,v 1.2 2003/06/11 23:56:26 paulus Exp $
40 */
41
42#include "netif/ppp/ppp_opts.h"
43#if PPP_SUPPORT && EAP_SUPPORT /* don't build if not configured for use in lwipopts.h */
44
45#ifndef PPP_EAP_H
46#define PPP_EAP_H
47
48#include "ppp.h"
49
50#ifdef __cplusplus
51extern "C" {
52#endif
53
54/*
55 * Packet header = Code, id, length.
56 */
57#define EAP_HEADERLEN 4
58
59
60/* EAP message codes. */
61#define EAP_REQUEST 1
62#define EAP_RESPONSE 2
63#define EAP_SUCCESS 3
64#define EAP_FAILURE 4
65
66/* EAP types */
67#define EAPT_IDENTITY 1
68#define EAPT_NOTIFICATION 2
69#define EAPT_NAK 3 /* (response only) */
70#define EAPT_MD5CHAP 4
71#define EAPT_OTP 5 /* One-Time Password; RFC 1938 */
72#define EAPT_TOKEN 6 /* Generic Token Card */
73/* 7 and 8 are unassigned. */
74#define EAPT_RSA 9 /* RSA Public Key Authentication */
75#define EAPT_DSS 10 /* DSS Unilateral */
76#define EAPT_KEA 11 /* KEA */
77#define EAPT_KEA_VALIDATE 12 /* KEA-VALIDATE */
78#define EAPT_TLS 13 /* EAP-TLS */
79#define EAPT_DEFENDER 14 /* Defender Token (AXENT) */
80#define EAPT_W2K 15 /* Windows 2000 EAP */
81#define EAPT_ARCOT 16 /* Arcot Systems */
82#define EAPT_CISCOWIRELESS 17 /* Cisco Wireless */
83#define EAPT_NOKIACARD 18 /* Nokia IP smart card */
84#define EAPT_SRP 19 /* Secure Remote Password */
85/* 20 is deprecated */
86
87/* EAP SRP-SHA1 Subtypes */
88#define EAPSRP_CHALLENGE 1 /* Request 1 - Challenge */
89#define EAPSRP_CKEY 1 /* Response 1 - Client Key */
90#define EAPSRP_SKEY 2 /* Request 2 - Server Key */
91#define EAPSRP_CVALIDATOR 2 /* Response 2 - Client Validator */
92#define EAPSRP_SVALIDATOR 3 /* Request 3 - Server Validator */
93#define EAPSRP_ACK 3 /* Response 3 - final ack */
94#define EAPSRP_LWRECHALLENGE 4 /* Req/resp 4 - Lightweight rechal */
95
96#define SRPVAL_EBIT 0x00000001 /* Use shared key for ECP */
97
98#define SRP_PSEUDO_ID "pseudo_"
99#define SRP_PSEUDO_LEN 7
100
101#define MD5_SIGNATURE_SIZE 16
102#define EAP_MIN_CHALLENGE_LENGTH 17
103#define EAP_MAX_CHALLENGE_LENGTH 24
104#define EAP_MIN_MAX_POWER_OF_TWO_CHALLENGE_LENGTH 3 /* 2^3-1 = 7, 17+7 = 24 */
105
106#define EAP_STATES \
107 "Initial", "Pending", "Closed", "Listen", "Identify", \
108 "SRP1", "SRP2", "SRP3", "MD5Chall", "Open", "SRP4", "BadAuth"
109
110#define eap_client_active(pcb) ((pcb)->eap.es_client.ea_state == eapListen)
111#if PPP_SERVER
112#define eap_server_active(pcb) \
113 ((pcb)->eap.es_server.ea_state >= eapIdentify && \
114 (pcb)->eap.es_server.ea_state <= eapMD5Chall)
115#endif /* PPP_SERVER */
116
117/*
118 * Complete EAP state for one PPP session.
119 */
120enum eap_state_code {
121 eapInitial = 0, /* No EAP authentication yet requested */
122 eapPending, /* Waiting for LCP (no timer) */
123 eapClosed, /* Authentication not in use */
124 eapListen, /* Client ready (and timer running) */
125 eapIdentify, /* EAP Identify sent */
126 eapSRP1, /* Sent EAP SRP-SHA1 Subtype 1 */
127 eapSRP2, /* Sent EAP SRP-SHA1 Subtype 2 */
128 eapSRP3, /* Sent EAP SRP-SHA1 Subtype 3 */
129 eapMD5Chall, /* Sent MD5-Challenge */
130 eapOpen, /* Completed authentication */
131 eapSRP4, /* Sent EAP SRP-SHA1 Subtype 4 */
132 eapBadAuth /* Failed authentication */
133};
134
135struct eap_auth {
136 const char *ea_name; /* Our name */
137 char ea_peer[MAXNAMELEN +1]; /* Peer's name */
138 void *ea_session; /* Authentication library linkage */
139 u_char *ea_skey; /* Shared encryption key */
140 u_short ea_namelen; /* Length of our name */
141 u_short ea_peerlen; /* Length of peer's name */
142 enum eap_state_code ea_state;
143 u_char ea_id; /* Current id */
144 u_char ea_requests; /* Number of Requests sent/received */
145 u_char ea_responses; /* Number of Responses */
146 u_char ea_type; /* One of EAPT_* */
147 u32_t ea_keyflags; /* SRP shared key usage flags */
148};
149
150#ifndef EAP_MAX_CHALLENGE_LENGTH
151#define EAP_MAX_CHALLENGE_LENGTH 24
152#endif
153typedef struct eap_state {
154 struct eap_auth es_client; /* Client (authenticatee) data */
155#if PPP_SERVER
156 struct eap_auth es_server; /* Server (authenticator) data */
157#endif /* PPP_SERVER */
158 int es_savedtime; /* Saved timeout */
159 int es_rechallenge; /* EAP rechallenge interval */
160 int es_lwrechallenge; /* SRP lightweight rechallenge inter */
161 u8_t es_usepseudo; /* Use SRP Pseudonym if offered one */
162 int es_usedpseudo; /* Set if we already sent PN */
163 int es_challen; /* Length of challenge string */
164 u_char es_challenge[EAP_MAX_CHALLENGE_LENGTH];
165} eap_state;
166
167/*
168 * Timeouts.
169 */
170#if 0 /* moved to ppp_opts.h */
171#define EAP_DEFTIMEOUT 3 /* Timeout (seconds) for rexmit */
172#define EAP_DEFTRANSMITS 10 /* max # times to transmit */
173#define EAP_DEFREQTIME 20 /* Time to wait for peer request */
174#define EAP_DEFALLOWREQ 20 /* max # times to accept requests */
175#endif /* moved to ppp_opts.h */
176
177void eap_authwithpeer(ppp_pcb *pcb, const char *localname);
178void eap_authpeer(ppp_pcb *pcb, const char *localname);
179
180extern const struct protent eap_protent;
181
182#ifdef __cplusplus
183}
184#endif
185
186#endif /* PPP_EAP_H */
187
188#endif /* PPP_SUPPORT && EAP_SUPPORT */