2
* WPA Supplicant / EAPOL state machines
3
* Copyright (c) 2004-2005, Jouni Malinen <j@w1.fi>
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License version 2 as
7
* published by the Free Software Foundation.
9
* Alternatively, this software may be distributed under the terms of BSD
12
* See README and COPYING for more details.
20
typedef enum { Unauthorized, Authorized } PortStatus;
21
typedef enum { Auto, ForceUnauthorized, ForceAuthorized } PortControl;
24
* struct eapol_config - Per network configuration for EAPOL state machines
28
* accept_802_1x_keys - Accept IEEE 802.1X (non-WPA) EAPOL-Key frames
30
* This variable should be set to 1 when using EAPOL state machines
31
* with non-WPA security policy to generate dynamic WEP keys. When
32
* using WPA, this should be set to 0 so that WPA state machine can
33
* process the EAPOL-Key frames.
35
int accept_802_1x_keys;
37
#define EAPOL_REQUIRE_KEY_UNICAST BIT(0)
38
#define EAPOL_REQUIRE_KEY_BROADCAST BIT(1)
40
* required_keys - Which EAPOL-Key packets are required
42
* This variable determines which EAPOL-Key packets are required before
43
* marking connection authenticated. This is a bit field of
44
* EAPOL_REQUIRE_KEY_UNICAST and EAPOL_REQUIRE_KEY_BROADCAST flags.
49
* fast_reauth - Whether fast EAP reauthentication is enabled
54
* workaround - Whether EAP workarounds are enabled
56
unsigned int workaround;
59
* eap_disabled - Whether EAP is disabled
65
struct wpa_config_blob;
68
* struct eapol_ctx - Global (for all networks) EAPOL state machine context
72
* ctx - Pointer to arbitrary upper level context
77
* preauth - IEEE 802.11i/RSN pre-authentication
79
* This EAPOL state machine is used for IEEE 802.11i/RSN
85
* cb - Function to be called when EAPOL negotiation has been completed
86
* @eapol: Pointer to EAPOL state machine data
87
* @success: Whether the authentication was completed successfully
88
* @ctx: Pointer to context data (cb_ctx)
90
* This optional callback function will be called when the EAPOL
91
* authentication has been completed. This allows the owner of the
92
* EAPOL state machine to process the key and terminate the EAPOL state
93
* machine. Currently, this is used only in RSN pre-authentication.
95
void (*cb)(struct eapol_sm *eapol, int success, void *ctx);
98
* cb_ctx - Callback context for cb()
103
* msg_ctx - Callback context for wpa_msg() calls
108
* scard_ctx - Callback context for PC/SC scard_*() function calls
110
* This context can be updated with eapol_sm_register_scard_ctx().
115
* eapol_send_ctx - Callback context for eapol_send() calls
117
void *eapol_send_ctx;
120
* eapol_done_cb - Function to be called at successful completion
121
* @ctx: Callback context (ctx)
123
* This function is called at the successful completion of EAPOL
124
* authentication. If dynamic WEP keys are used, this is called only
125
* after all the expected keys have been received.
127
void (*eapol_done_cb)(void *ctx);
130
* eapol_send - Send EAPOL packets
131
* @ctx: Callback context (eapol_send_ctx)
132
* @type: EAPOL type (IEEE802_1X_TYPE_*)
133
* @buf: Pointer to EAPOL payload
134
* @len: Length of the EAPOL payload
135
* Returns: 0 on success, -1 on failure
137
int (*eapol_send)(void *ctx, int type, const u8 *buf, size_t len);
140
* set_wep_key - Configure WEP keys
141
* @ctx: Callback context (ctx)
142
* @unicast: Non-zero = unicast, 0 = multicast/broadcast key
143
* @keyidx: Key index (0..3)
145
* @keylen: Length of the WEP key
146
* Returns: 0 on success, -1 on failure
148
int (*set_wep_key)(void *ctx, int unicast, int keyidx,
149
const u8 *key, size_t keylen);
152
* set_config_blob - Set or add a named configuration blob
153
* @ctx: Callback context (ctx)
154
* @blob: New value for the blob
156
* Adds a new configuration blob or replaces the current value of an
159
void (*set_config_blob)(void *ctx, struct wpa_config_blob *blob);
162
* get_config_blob - Get a named configuration blob
163
* @ctx: Callback context (ctx)
164
* @name: Name of the blob
165
* Returns: Pointer to blob data or %NULL if not found
167
const struct wpa_config_blob * (*get_config_blob)(void *ctx,
171
* aborted_cached - Notify that cached PMK attempt was aborted
172
* @ctx: Callback context (ctx)
174
void (*aborted_cached)(void *ctx);
177
* opensc_engine_path - Path to the OpenSSL engine for opensc
179
* This is an OpenSSL specific configuration option for loading OpenSC
180
* engine (engine_opensc.so); if %NULL, this engine is not loaded.
182
const char *opensc_engine_path;
185
* pkcs11_engine_path - Path to the OpenSSL engine for PKCS#11
187
* This is an OpenSSL specific configuration option for loading PKCS#11
188
* engine (engine_pkcs11.so); if %NULL, this engine is not loaded.
190
const char *pkcs11_engine_path;
193
* pkcs11_module_path - Path to the OpenSSL OpenSC/PKCS#11 module
195
* This is an OpenSSL specific configuration option for configuring
196
* path to OpenSC/PKCS#11 engine (opensc-pkcs11.so); if %NULL, this
197
* module is not loaded.
199
const char *pkcs11_module_path;
205
#ifdef IEEE8021X_EAPOL
206
struct eapol_sm *eapol_sm_init(struct eapol_ctx *ctx);
207
void eapol_sm_deinit(struct eapol_sm *sm);
208
void eapol_sm_step(struct eapol_sm *sm);
209
int eapol_sm_get_status(struct eapol_sm *sm, char *buf, size_t buflen,
211
int eapol_sm_get_mib(struct eapol_sm *sm, char *buf, size_t buflen);
212
void eapol_sm_configure(struct eapol_sm *sm, int heldPeriod, int authPeriod,
213
int startPeriod, int maxStart);
214
int eapol_sm_rx_eapol(struct eapol_sm *sm, const u8 *src, const u8 *buf,
216
void eapol_sm_notify_tx_eapol_key(struct eapol_sm *sm);
217
void eapol_sm_notify_portEnabled(struct eapol_sm *sm, Boolean enabled);
218
void eapol_sm_notify_portValid(struct eapol_sm *sm, Boolean valid);
219
void eapol_sm_notify_eap_success(struct eapol_sm *sm, Boolean success);
220
void eapol_sm_notify_eap_fail(struct eapol_sm *sm, Boolean fail);
221
void eapol_sm_notify_config(struct eapol_sm *sm, struct wpa_ssid *config,
222
const struct eapol_config *conf);
223
int eapol_sm_get_key(struct eapol_sm *sm, u8 *key, size_t len);
224
void eapol_sm_notify_logoff(struct eapol_sm *sm, Boolean logoff);
225
void eapol_sm_notify_cached(struct eapol_sm *sm);
226
void eapol_sm_notify_pmkid_attempt(struct eapol_sm *sm, int attempt);
227
void eapol_sm_register_scard_ctx(struct eapol_sm *sm, void *ctx);
228
void eapol_sm_notify_portControl(struct eapol_sm *sm, PortControl portControl);
229
void eapol_sm_notify_ctrl_attached(struct eapol_sm *sm);
230
void eapol_sm_notify_ctrl_response(struct eapol_sm *sm);
231
void eapol_sm_request_reauth(struct eapol_sm *sm);
232
void eapol_sm_notify_lower_layer_success(struct eapol_sm *sm);
233
void eapol_sm_invalidate_cached_session(struct eapol_sm *sm);
234
#else /* IEEE8021X_EAPOL */
235
static inline struct eapol_sm *eapol_sm_init(struct eapol_ctx *ctx)
238
return (struct eapol_sm *) 1;
240
static inline void eapol_sm_deinit(struct eapol_sm *sm)
243
static inline void eapol_sm_step(struct eapol_sm *sm)
246
static inline int eapol_sm_get_status(struct eapol_sm *sm, char *buf,
247
size_t buflen, int verbose)
251
static inline int eapol_sm_get_mib(struct eapol_sm *sm, char *buf,
256
static inline void eapol_sm_configure(struct eapol_sm *sm, int heldPeriod,
257
int authPeriod, int startPeriod,
261
static inline int eapol_sm_rx_eapol(struct eapol_sm *sm, const u8 *src,
262
const u8 *buf, size_t len)
266
static inline void eapol_sm_notify_tx_eapol_key(struct eapol_sm *sm)
269
static inline void eapol_sm_notify_portEnabled(struct eapol_sm *sm,
273
static inline void eapol_sm_notify_portValid(struct eapol_sm *sm,
277
static inline void eapol_sm_notify_eap_success(struct eapol_sm *sm,
281
static inline void eapol_sm_notify_eap_fail(struct eapol_sm *sm, Boolean fail)
284
static inline void eapol_sm_notify_config(struct eapol_sm *sm,
285
struct wpa_ssid *config,
286
struct eapol_config *conf)
289
static inline int eapol_sm_get_key(struct eapol_sm *sm, u8 *key, size_t len)
293
static inline void eapol_sm_notify_logoff(struct eapol_sm *sm, Boolean logoff)
296
static inline void eapol_sm_notify_cached(struct eapol_sm *sm)
299
#define eapol_sm_notify_pmkid_attempt(sm, attempt) do { } while (0)
300
#define eapol_sm_register_scard_ctx(sm, ctx) do { } while (0)
301
static inline void eapol_sm_notify_portControl(struct eapol_sm *sm,
302
PortControl portControl)
305
static inline void eapol_sm_notify_ctrl_attached(struct eapol_sm *sm)
308
static inline void eapol_sm_notify_ctrl_response(struct eapol_sm *sm)
311
static inline void eapol_sm_request_reauth(struct eapol_sm *sm)
314
static inline void eapol_sm_notify_lower_layer_success(struct eapol_sm *sm)
317
static inline void eapol_sm_invalidate_cached_session(struct eapol_sm *sm)
320
#endif /* IEEE8021X_EAPOL */
322
#endif /* EAPOL_SM_H */