iPXE
eap.h
Go to the documentation of this file.
1#ifndef _IPXE_EAP_H
2#define _IPXE_EAP_H
3
4/** @file
5 *
6 * Extensible Authentication Protocol
7 *
8 */
9
10FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
11FILE_SECBOOT ( PERMITTED );
12
13#include <stdint.h>
14#include <ipxe/netdevice.h>
15#include <ipxe/timer.h>
16#include <ipxe/tables.h>
17
18/** EAP header */
19struct eap_header {
20 /** Code */
22 /** Identifier */
24 /** Length */
26} __attribute__ (( packed ));
27
28/** EAP request */
29#define EAP_CODE_REQUEST 1
30
31/** EAP response */
32#define EAP_CODE_RESPONSE 2
33
34/** EAP request/response message */
36 /** Header */
38 /** Type */
40 /** Type data */
42} __attribute__ (( packed ));
43
44/** EAP "no available types" marker */
45#define EAP_TYPE_NONE 0
46
47/** EAP identity */
48#define EAP_TYPE_IDENTITY 1
49
50/** EAP NAK */
51#define EAP_TYPE_NAK 3
52
53/** EAP MD5 challenge request/response */
54#define EAP_TYPE_MD5 4
55
56/** EAP MD5 challenge request/response type data */
57struct eap_md5 {
58 /** Value length */
60 /** Value */
62} __attribute__ (( packed ));
63
64/** EAP MS-CHAPv2 request/response */
65#define EAP_TYPE_MSCHAPV2 26
66
67/** EAP MS-CHAPv2 request/response type data */
69 /** Code
70 *
71 * This is in the same namespace as the EAP header's code
72 * field, but is used to extend the handshake by allowing for
73 * "success request" and "success response" packets.
74 */
76 /** Identifier
77 *
78 * This field serves no purposes: it always has the same value
79 * as the EAP header's identifier field (located 5 bytes
80 * earlier in the same packet).
81 */
83 /** Length
84 *
85 * This field serves no purpose: it always has the same value
86 * as the EAP header's length field (located 5 bytes earlier
87 * in the same packet), minus the 5 byte length of the EAP
88 * header.
89 */
91} __attribute__ (( packed ));
92
93/** EAP success */
94#define EAP_CODE_SUCCESS 3
95
96/** EAP failure */
97#define EAP_CODE_FAILURE 4
98
99/** EAP packet */
101 /** Header */
103 /** Request/response message */
105};
106
107/** EAP link block timeout
108 *
109 * We mark the link as blocked upon receiving a Request-Identity, on
110 * the basis that this most likely indicates that the switch will not
111 * yet be forwarding packets.
112 *
113 * There is no way to tell how frequently the Request-Identity packet
114 * will be retransmitted by the switch. The default value for Cisco
115 * switches seems to be 30 seconds, so treat the link as blocked for
116 * 45 seconds.
117 */
118#define EAP_BLOCK_TIMEOUT ( 45 * TICKS_PER_SEC )
119
120/** EAP protocol wait timeout
121 *
122 * In the EAP model, the supplicant is a pure responder. The model
123 * also defines no acknowledgement response for the final Success or
124 * Failure "requests". This leaves open the possibility that the
125 * final Success or Failure packet is lost, with the supplicant having
126 * no way to determine the final authentication status.
127 *
128 * Sideband mechanisms such as EAPoL-Start may be used to restart the
129 * entire EAP process, as a (crude) workaround for this protocol flaw.
130 * When expecting to receive a further EAP request (e.g. an
131 * authentication challenge), we may wait for some length of time
132 * before triggering this restart. Choose a duration that is shorter
133 * than the link block timeout, so that there is no period during
134 * which we erroneously leave the link marked as not blocked.
135 */
136#define EAP_WAIT_TIMEOUT ( EAP_BLOCK_TIMEOUT * 7 / 8 )
137
138/** An EAP supplicant */
140 /** Network device */
142 /** Flags */
144 /** ID for current request/response */
146 /** Type for current request/response */
148 /**
149 * Transmit EAP response
150 *
151 * @v supplicant EAP supplicant
152 * @v data Response data
153 * @v len Length of response data
154 * @ret rc Return status code
155 */
156 int ( * tx ) ( struct eap_supplicant *supplicant,
157 const void *data, size_t len );
158};
159
160/** EAP authentication is in progress
161 *
162 * This indicates that we have received an EAP Request-Identity, but
163 * have not yet received a final EAP Success or EAP Failure.
164 */
165#define EAP_FL_ONGOING 0x0001
166
167/** EAP supplicant is passive
168 *
169 * This indicates that the supplicant should not transmit any futher
170 * unsolicited packets (e.g. EAPoL-Start for a supplicant running over
171 * EAPoL). This could be because authentication has already
172 * completed, or because we are relying upon MAC Authentication Bypass
173 * (MAB) which may have a very long timeout.
174 */
175#define EAP_FL_PASSIVE 0x0002
176
177/** An EAP method */
179 /** Type */
181 /**
182 * Handle EAP request
183 *
184 * @v supplicant EAP supplicant
185 * @v req Request type data
186 * @v req_len Length of request type data
187 * @ret rc Return status code
188 */
189 int ( * rx ) ( struct eap_supplicant *supplicant,
190 const void *req, size_t req_len );
191};
192
193/** EAP method table */
194#define EAP_METHODS __table ( struct eap_method, "eap_methods" )
195
196/** Declare an EAP method */
197#define __eap_method __table_entry ( EAP_METHODS, 01 )
198
199extern int eap_tx_response ( struct eap_supplicant *supplicant,
200 const void *rsp, size_t rsp_len );
201extern int eap_rx ( struct eap_supplicant *supplicant,
202 const void *data, size_t len );
203
204#endif /* _IPXE_EAP_H */
unsigned short uint16_t
Definition stdint.h:11
unsigned char uint8_t
Definition stdint.h:10
ring len
Length.
Definition dwmac.h:226
int eap_rx(struct eap_supplicant *supplicant, const void *data, size_t len)
Handle EAP packet.
Definition eap.c:264
int eap_tx_response(struct eap_supplicant *supplicant, const void *rsp, size_t rsp_len)
Transmit EAP response.
Definition eap.c:48
uint8_t data[48]
Additional event data.
Definition ena.h:11
#define FILE_LICENCE(_licence)
Declare a particular licence as applying to a file.
Definition compiler.h:896
#define FILE_SECBOOT(_status)
Declare a file's UEFI Secure Boot permission status.
Definition compiler.h:926
#define __attribute__(x)
Definition compiler.h:10
iPXE timers
uint64_t rsp
Definition librm.h:18
Network device management.
EAP header.
Definition eap.h:19
uint8_t code
Code.
Definition eap.h:21
uint8_t id
Identifier.
Definition eap.h:23
uint16_t len
Length.
Definition eap.h:25
EAP MD5 challenge request/response type data.
Definition eap.h:57
uint8_t value[0]
Value.
Definition eap.h:61
uint8_t len
Value length.
Definition eap.h:59
EAP request/response message.
Definition eap.h:35
uint8_t data[0]
Type data.
Definition eap.h:41
uint8_t type
Type.
Definition eap.h:39
struct eap_header hdr
Header.
Definition eap.h:37
An EAP method.
Definition eap.h:178
uint8_t type
Type.
Definition eap.h:180
int(* rx)(struct eap_supplicant *supplicant, const void *req, size_t req_len)
Handle EAP request.
Definition eap.h:189
EAP MS-CHAPv2 request/response type data.
Definition eap.h:68
uint16_t len
Length.
Definition eap.h:90
uint8_t code
Code.
Definition eap.h:75
uint8_t id
Identifier.
Definition eap.h:82
An EAP supplicant.
Definition eap.h:139
uint8_t id
ID for current request/response.
Definition eap.h:145
uint8_t type
Type for current request/response.
Definition eap.h:147
uint16_t flags
Flags.
Definition eap.h:143
struct net_device * netdev
Network device.
Definition eap.h:141
int(* tx)(struct eap_supplicant *supplicant, const void *data, size_t len)
Transmit EAP response.
Definition eap.h:156
A network device.
Definition netdevice.h:353
Linker tables.
EAP packet.
Definition eap.h:100
struct eap_message msg
Request/response message.
Definition eap.h:104
struct eap_header hdr
Header.
Definition eap.h:102