sdk-core v2026.11.05
PS2 SDK - core tier (build-critical EE/IOP modules)
Loading...
Searching...
No Matches
eap.h
Go to the documentation of this file.
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 MERCHANTABILITY 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
27#include "netif/ppp/ppp_opts.h"
28#if PPP_SUPPORT && EAP_SUPPORT /* don't build if not configured for use in lwipopts.h */
29
30#ifndef PPP_EAP_H
31#define PPP_EAP_H
32
33#include "ppp.h"
34
35#ifdef __cplusplus
36extern "C" {
37#endif
38
39/*
40 * Packet header = Code, id, length.
41 */
42#define EAP_HEADERLEN 4
43
44
45/* EAP message codes. */
46#define EAP_REQUEST 1
47#define EAP_RESPONSE 2
48#define EAP_SUCCESS 3
49#define EAP_FAILURE 4
50
51/* EAP types */
52#define EAPT_IDENTITY 1
53#define EAPT_NOTIFICATION 2
54#define EAPT_NAK 3 /* (response only) */
55#define EAPT_MD5CHAP 4
56#define EAPT_OTP 5 /* One-Time Password; RFC 1938 */
57#define EAPT_TOKEN 6 /* Generic Token Card */
58/* 7 and 8 are unassigned. */
59#define EAPT_RSA 9 /* RSA Public Key Authentication */
60#define EAPT_DSS 10 /* DSS Unilateral */
61#define EAPT_KEA 11 /* KEA */
62#define EAPT_KEA_VALIDATE 12 /* KEA-VALIDATE */
63#define EAPT_TLS 13 /* EAP-TLS */
64#define EAPT_DEFENDER 14 /* Defender Token (AXENT) */
65#define EAPT_W2K 15 /* Windows 2000 EAP */
66#define EAPT_ARCOT 16 /* Arcot Systems */
67#define EAPT_CISCOWIRELESS 17 /* Cisco Wireless */
68#define EAPT_NOKIACARD 18 /* Nokia IP smart card */
69#define EAPT_SRP 19 /* Secure Remote Password */
70/* 20 is deprecated */
71
72/* EAP SRP-SHA1 Subtypes */
73#define EAPSRP_CHALLENGE 1 /* Request 1 - Challenge */
74#define EAPSRP_CKEY 1 /* Response 1 - Client Key */
75#define EAPSRP_SKEY 2 /* Request 2 - Server Key */
76#define EAPSRP_CVALIDATOR 2 /* Response 2 - Client Validator */
77#define EAPSRP_SVALIDATOR 3 /* Request 3 - Server Validator */
78#define EAPSRP_ACK 3 /* Response 3 - final ack */
79#define EAPSRP_LWRECHALLENGE 4 /* Req/resp 4 - Lightweight rechal */
80
81#define SRPVAL_EBIT 0x00000001 /* Use shared key for ECP */
82
83#define SRP_PSEUDO_ID "pseudo_"
84#define SRP_PSEUDO_LEN 7
85
86#define MD5_SIGNATURE_SIZE 16
87#define EAP_MIN_CHALLENGE_LENGTH 17
88#define EAP_MAX_CHALLENGE_LENGTH 24
89#define EAP_MIN_MAX_POWER_OF_TWO_CHALLENGE_LENGTH 3 /* 2^3-1 = 7, 17+7 = 24 */
90
91#define EAP_STATES \
92 "Initial", "Pending", "Closed", "Listen", "Identify", \
93 "SRP1", "SRP2", "SRP3", "MD5Chall", "Open", "SRP4", "BadAuth"
94
95#define eap_client_active(pcb) ((pcb)->eap.es_client.ea_state == eapListen)
96#if PPP_SERVER
97#define eap_server_active(pcb) \
98 ((pcb)->eap.es_server.ea_state >= eapIdentify && \
99 (pcb)->eap.es_server.ea_state <= eapMD5Chall)
100#endif /* PPP_SERVER */
101
102/*
103 * Complete EAP state for one PPP session.
104 */
105enum eap_state_code {
106 eapInitial = 0, /* No EAP authentication yet requested */
107 eapPending, /* Waiting for LCP (no timer) */
108 eapClosed, /* Authentication not in use */
109 eapListen, /* Client ready (and timer running) */
110 eapIdentify, /* EAP Identify sent */
111 eapSRP1, /* Sent EAP SRP-SHA1 Subtype 1 */
112 eapSRP2, /* Sent EAP SRP-SHA1 Subtype 2 */
113 eapSRP3, /* Sent EAP SRP-SHA1 Subtype 3 */
114 eapMD5Chall, /* Sent MD5-Challenge */
115 eapOpen, /* Completed authentication */
116 eapSRP4, /* Sent EAP SRP-SHA1 Subtype 4 */
117 eapBadAuth /* Failed authentication */
118};
119
120struct eap_auth {
121 const char *ea_name; /* Our name */
122 char ea_peer[MAXNAMELEN +1]; /* Peer's name */
123 void *ea_session; /* Authentication library linkage */
124 u_char *ea_skey; /* Shared encryption key */
125 u_short ea_namelen; /* Length of our name */
126 u_short ea_peerlen; /* Length of peer's name */
127 enum eap_state_code ea_state;
128 u_char ea_id; /* Current id */
129 u_char ea_requests; /* Number of Requests sent/received */
130 u_char ea_responses; /* Number of Responses */
131 u_char ea_type; /* One of EAPT_* */
132 u32_t ea_keyflags; /* SRP shared key usage flags */
133};
134
135#ifndef EAP_MAX_CHALLENGE_LENGTH
136#define EAP_MAX_CHALLENGE_LENGTH 24
137#endif
138typedef struct eap_state {
139 struct eap_auth es_client; /* Client (authenticatee) data */
140#if PPP_SERVER
141 struct eap_auth es_server; /* Server (authenticator) data */
142#endif /* PPP_SERVER */
143 int es_savedtime; /* Saved timeout */
144 int es_rechallenge; /* EAP rechallenge interval */
145 int es_lwrechallenge; /* SRP lightweight rechallenge inter */
146 u8_t es_usepseudo; /* Use SRP Pseudonym if offered one */
147 int es_usedpseudo; /* Set if we already sent PN */
148 int es_challen; /* Length of challenge string */
149 u_char es_challenge[EAP_MAX_CHALLENGE_LENGTH];
150} eap_state;
151
152/*
153 * Timeouts.
154 */
155#if 0 /* moved to ppp_opts.h */
156#define EAP_DEFTIMEOUT 3 /* Timeout (seconds) for rexmit */
157#define EAP_DEFTRANSMITS 10 /* max # times to transmit */
158#define EAP_DEFREQTIME 20 /* Time to wait for peer request */
159#define EAP_DEFALLOWREQ 20 /* max # times to accept requests */
160#endif /* moved to ppp_opts.h */
161
162void eap_authwithpeer(ppp_pcb *pcb, const char *localname);
163void eap_authpeer(ppp_pcb *pcb, const char *localname);
164
165extern const struct protent eap_protent;
166
167#ifdef __cplusplus
168}
169#endif
170
171#endif /* PPP_EAP_H */
172
173#endif /* PPP_SUPPORT && EAP_SUPPORT */