$search
00001 /* 00002 * EAP peer state machines internal structures (RFC 4137) 00003 * Copyright (c) 2004-2007, Jouni Malinen <j@w1.fi> 00004 * 00005 * This program is free software; you can redistribute it and/or modify 00006 * it under the terms of the GNU General Public License version 2 as 00007 * published by the Free Software Foundation. 00008 * 00009 * Alternatively, this software may be distributed under the terms of BSD 00010 * license. 00011 * 00012 * See README and COPYING for more details. 00013 */ 00014 00015 #ifndef EAP_I_H 00016 #define EAP_I_H 00017 00018 #include "wpabuf.h" 00019 #include "eap_peer/eap.h" 00020 #include "eap_common/eap_common.h" 00021 00022 /* RFC 4137 - EAP Peer state machine */ 00023 00024 typedef enum { 00025 DECISION_FAIL, DECISION_COND_SUCC, DECISION_UNCOND_SUCC 00026 } EapDecision; 00027 00028 typedef enum { 00029 METHOD_NONE, METHOD_INIT, METHOD_CONT, METHOD_MAY_CONT, METHOD_DONE 00030 } EapMethodState; 00031 00040 struct eap_method_ret { 00044 Boolean ignore; 00045 00049 EapMethodState methodState; 00050 00054 EapDecision decision; 00055 00059 Boolean allowNotifications; 00060 }; 00061 00062 00069 struct eap_method { 00073 int vendor; 00074 00078 EapType method; 00079 00083 const char *name; 00084 00095 void * (*init)(struct eap_sm *sm); 00096 00104 void (*deinit)(struct eap_sm *sm, void *priv); 00105 00121 struct wpabuf * (*process)(struct eap_sm *sm, void *priv, 00122 struct eap_method_ret *ret, 00123 const struct wpabuf *reqData); 00124 00131 Boolean (*isKeyAvailable)(struct eap_sm *sm, void *priv); 00132 00144 u8 * (*getKey)(struct eap_sm *sm, void *priv, size_t *len); 00145 00160 int (*get_status)(struct eap_sm *sm, void *priv, char *buf, 00161 size_t buflen, int verbose); 00162 00173 Boolean (*has_reauth_data)(struct eap_sm *sm, void *priv); 00174 00186 void (*deinit_for_reauth)(struct eap_sm *sm, void *priv); 00187 00198 void * (*init_for_reauth)(struct eap_sm *sm, void *priv); 00199 00211 const u8 * (*get_identity)(struct eap_sm *sm, void *priv, size_t *len); 00212 00226 void (*free)(struct eap_method *method); 00227 00228 #define EAP_PEER_METHOD_INTERFACE_VERSION 1 00229 00237 int version; 00238 00245 struct eap_method *next; 00246 00247 #ifdef CONFIG_DYNAMIC_EAP_METHODS 00248 00255 void *dl_handle; 00256 #endif /* CONFIG_DYNAMIC_EAP_METHODS */ 00257 00269 u8 * (*get_emsk)(struct eap_sm *sm, void *priv, size_t *len); 00270 }; 00271 00272 00276 struct eap_sm { 00277 enum { 00278 EAP_INITIALIZE, EAP_DISABLED, EAP_IDLE, EAP_RECEIVED, 00279 EAP_GET_METHOD, EAP_METHOD, EAP_SEND_RESPONSE, EAP_DISCARD, 00280 EAP_IDENTITY, EAP_NOTIFICATION, EAP_RETRANSMIT, EAP_SUCCESS, 00281 EAP_FAILURE 00282 } EAP_state; 00283 /* Long-term local variables */ 00284 EapType selectedMethod; 00285 EapMethodState methodState; 00286 int lastId; 00287 struct wpabuf *lastRespData; 00288 EapDecision decision; 00289 /* Short-term local variables */ 00290 Boolean rxReq; 00291 Boolean rxSuccess; 00292 Boolean rxFailure; 00293 int reqId; 00294 EapType reqMethod; 00295 int reqVendor; 00296 u32 reqVendorMethod; 00297 Boolean ignore; 00298 /* Constants */ 00299 int ClientTimeout; 00300 00301 /* Miscellaneous variables */ 00302 Boolean allowNotifications; /* peer state machine <-> methods */ 00303 struct wpabuf *eapRespData; /* peer to lower layer */ 00304 Boolean eapKeyAvailable; /* peer to lower layer */ 00305 u8 *eapKeyData; /* peer to lower layer */ 00306 size_t eapKeyDataLen; /* peer to lower layer */ 00307 const struct eap_method *m; /* selected EAP method */ 00308 /* not defined in RFC 4137 */ 00309 Boolean changed; 00310 void *eapol_ctx; 00311 struct eapol_callbacks *eapol_cb; 00312 void *eap_method_priv; 00313 int init_phase2; 00314 int fast_reauth; 00315 00316 Boolean rxResp /* LEAP only */; 00317 Boolean leap_done; 00318 Boolean peap_done; 00319 u8 req_md5[16]; /* MD5() of the current EAP packet */ 00320 u8 last_md5[16]; /* MD5() of the previously received EAP packet; used 00321 * in duplicate request detection. */ 00322 00323 void *msg_ctx; 00324 void *scard_ctx; 00325 void *ssl_ctx; 00326 00327 unsigned int workaround; 00328 00329 /* Optional challenges generated in Phase 1 (EAP-FAST) */ 00330 u8 *peer_challenge, *auth_challenge; 00331 00332 int num_rounds; 00333 int force_disabled; 00334 00335 struct wps_context *wps; 00336 00337 int prev_failure; 00338 }; 00339 00340 const u8 * eap_get_config_identity(struct eap_sm *sm, size_t *len); 00341 const u8 * eap_get_config_password(struct eap_sm *sm, size_t *len); 00342 const u8 * eap_get_config_password2(struct eap_sm *sm, size_t *len, int *hash); 00343 const u8 * eap_get_config_new_password(struct eap_sm *sm, size_t *len); 00344 const u8 * eap_get_config_otp(struct eap_sm *sm, size_t *len); 00345 void eap_clear_config_otp(struct eap_sm *sm); 00346 const char * eap_get_config_phase1(struct eap_sm *sm); 00347 const char * eap_get_config_phase2(struct eap_sm *sm); 00348 struct eap_peer_config * eap_get_config(struct eap_sm *sm); 00349 void eap_set_config_blob(struct eap_sm *sm, struct wpa_config_blob *blob); 00350 const struct wpa_config_blob * 00351 eap_get_config_blob(struct eap_sm *sm, const char *name); 00352 void eap_notify_pending(struct eap_sm *sm); 00353 int eap_allowed_method(struct eap_sm *sm, int vendor, u32 method); 00354 00355 #endif /* EAP_I_H */