eap_i.h revision 051af73b8f8014eff33330aead0f36944b3403e6
19f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson/* 29f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * EAP peer state machines internal structures (RFC 4137) 39f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Copyright (c) 2004-2007, Jouni Malinen <j@w1.fi> 49f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 59f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * This software may be distributed under the terms of the BSD license. 69f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * See README for more details. 79f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 89f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 99f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson#ifndef EAP_I_H 109f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson#define EAP_I_H 119f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 129f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson#include "wpabuf.h" 139f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson#include "eap_peer/eap.h" 149f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson#include "eap_common/eap_common.h" 159f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 169f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson/* RFC 4137 - EAP Peer state machine */ 179f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 189f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilsontypedef enum { 199f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson DECISION_FAIL, DECISION_COND_SUCC, DECISION_UNCOND_SUCC 209f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson} EapDecision; 219f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 229f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilsontypedef enum { 239f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson METHOD_NONE, METHOD_INIT, METHOD_CONT, METHOD_MAY_CONT, METHOD_DONE 249f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson} EapMethodState; 259f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 269f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson/** 279f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * struct eap_method_ret - EAP return values from struct eap_method::process() 289f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 299f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * These structure contains OUT variables for the interface between peer state 309f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * machine and methods (RFC 4137, Sect. 4.2). eapRespData will be returned as 319f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * the return value of struct eap_method::process() so it is not included in 329f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * this structure. 339f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 349f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilsonstruct eap_method_ret { 359f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 369f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * ignore - Whether method decided to drop the current packed (OUT) 379f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 389f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson Boolean ignore; 399f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 409f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 419f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * methodState - Method-specific state (IN/OUT) 429f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 439f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson EapMethodState methodState; 449f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 459f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 469f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * decision - Authentication decision (OUT) 479f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 489f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson EapDecision decision; 499f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 509f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 519f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * allowNotifications - Whether method allows notifications (OUT) 529f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 539f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson Boolean allowNotifications; 549f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson}; 559f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 569f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 579f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson/** 589f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * struct eap_method - EAP method interface 599f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * This structure defines the EAP method interface. Each method will need to 609f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * register its own EAP type, EAP name, and set of function pointers for method 619f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * specific operations. This interface is based on section 4.4 of RFC 4137. 629f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 639f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilsonstruct eap_method { 649f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 659f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * vendor - EAP Vendor-ID (EAP_VENDOR_*) (0 = IETF) 669f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 679f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson int vendor; 689f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 699f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 709f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * method - EAP type number (EAP_TYPE_*) 719f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 729f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson EapType method; 739f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 749f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 759f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * name - Name of the method (e.g., "TLS") 769f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 779f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson const char *name; 789f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 799f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 809f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * init - Initialize an EAP method 819f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @sm: Pointer to EAP state machine allocated with eap_peer_sm_init() 829f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Returns: Pointer to allocated private data, or %NULL on failure 839f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 849f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * This function is used to initialize the EAP method explicitly 859f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * instead of using METHOD_INIT state as specific in RFC 4137. The 869f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * method is expected to initialize it method-specific state and return 879f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * a pointer that will be used as the priv argument to other calls. 889f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 899f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson void * (*init)(struct eap_sm *sm); 909f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 919f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 929f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * deinit - Deinitialize an EAP method 939f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @sm: Pointer to EAP state machine allocated with eap_peer_sm_init() 949f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @priv: Pointer to private EAP method data from eap_method::init() 959f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 969f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Deinitialize the EAP method and free any allocated private data. 979f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 989f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson void (*deinit)(struct eap_sm *sm, void *priv); 999f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 1009f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 1019f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * process - Process an EAP request 1029f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @sm: Pointer to EAP state machine allocated with eap_peer_sm_init() 1039f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @priv: Pointer to private EAP method data from eap_method::init() 1049f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @ret: Return values from EAP request validation and processing 1059f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @reqData: EAP request to be processed (eapReqData) 1069f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Returns: Pointer to allocated EAP response packet (eapRespData) 1079f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 1089f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * This function is a combination of m.check(), m.process(), and 1099f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * m.buildResp() procedures defined in section 4.4 of RFC 4137 In other 1109f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * words, this function validates the incoming request, processes it, 1119f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * and build a response packet. m.check() and m.process() return values 1129f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * are returned through struct eap_method_ret *ret variable. Caller is 1139f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * responsible for freeing the returned EAP response packet. 1149f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 1159f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson struct wpabuf * (*process)(struct eap_sm *sm, void *priv, 1169f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson struct eap_method_ret *ret, 1179f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson const struct wpabuf *reqData); 1189f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 1199f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 1209f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * isKeyAvailable - Find out whether EAP method has keying material 1219f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @sm: Pointer to EAP state machine allocated with eap_peer_sm_init() 1229f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @priv: Pointer to private EAP method data from eap_method::init() 1239f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Returns: %TRUE if key material (eapKeyData) is available 1249f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 1259f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson Boolean (*isKeyAvailable)(struct eap_sm *sm, void *priv); 1269f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 1279f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 1289f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * getKey - Get EAP method specific keying material (eapKeyData) 1299f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @sm: Pointer to EAP state machine allocated with eap_peer_sm_init() 1309f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @priv: Pointer to private EAP method data from eap_method::init() 1319f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @len: Pointer to variable to store key length (eapKeyDataLen) 1329f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Returns: Keying material (eapKeyData) or %NULL if not available 1339f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 1349f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * This function can be used to get the keying material from the EAP 1359f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * method. The key may already be stored in the method-specific private 1369f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * data or this function may derive the key. 1379f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 1389f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson u8 * (*getKey)(struct eap_sm *sm, void *priv, size_t *len); 1399f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 1409f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 1419f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * get_status - Get EAP method status 1429f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @sm: Pointer to EAP state machine allocated with eap_peer_sm_init() 1439f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @priv: Pointer to private EAP method data from eap_method::init() 1449f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @buf: Buffer for status information 1459f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @buflen: Maximum buffer length 1469f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @verbose: Whether to include verbose status information 1479f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Returns: Number of bytes written to buf 1489f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 1499f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Query EAP method for status information. This function fills in a 1509f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * text area with current status information from the EAP method. If 1519f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * the buffer (buf) is not large enough, status information will be 1529f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * truncated to fit the buffer. 1539f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 1549f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson int (*get_status)(struct eap_sm *sm, void *priv, char *buf, 1559f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson size_t buflen, int verbose); 1569f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 1579f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 1589f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * has_reauth_data - Whether method is ready for fast reauthentication 1599f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @sm: Pointer to EAP state machine allocated with eap_peer_sm_init() 1609f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @priv: Pointer to private EAP method data from eap_method::init() 1619f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Returns: %TRUE or %FALSE based on whether fast reauthentication is 1629f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * possible 1639f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 1649f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * This function is an optional handler that only EAP methods 1659f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * supporting fast re-authentication need to implement. 1669f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 1679f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson Boolean (*has_reauth_data)(struct eap_sm *sm, void *priv); 1689f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 1699f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 1709f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * deinit_for_reauth - Release data that is not needed for fast re-auth 1719f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @sm: Pointer to EAP state machine allocated with eap_peer_sm_init() 1729f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @priv: Pointer to private EAP method data from eap_method::init() 1739f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 1749f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * This function is an optional handler that only EAP methods 1759f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * supporting fast re-authentication need to implement. This is called 1769f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * when authentication has been completed and EAP state machine is 1779f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * requesting that enough state information is maintained for fast 1789f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * re-authentication 1799f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 1809f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson void (*deinit_for_reauth)(struct eap_sm *sm, void *priv); 1819f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 1829f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 1839f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * init_for_reauth - Prepare for start of fast re-authentication 1849f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @sm: Pointer to EAP state machine allocated with eap_peer_sm_init() 1859f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @priv: Pointer to private EAP method data from eap_method::init() 1869f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 1879f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * This function is an optional handler that only EAP methods 1889f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * supporting fast re-authentication need to implement. This is called 1899f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * when EAP authentication is started and EAP state machine is 1909f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * requesting fast re-authentication to be used. 1919f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 1929f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson void * (*init_for_reauth)(struct eap_sm *sm, void *priv); 1939f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 1949f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 1959f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * get_identity - Get method specific identity for re-authentication 1969f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @sm: Pointer to EAP state machine allocated with eap_peer_sm_init() 1979f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @priv: Pointer to private EAP method data from eap_method::init() 1989f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @len: Length of the returned identity 1999f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Returns: Pointer to the method specific identity or %NULL if default 2009f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * identity is to be used 2019f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 2029f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * This function is an optional handler that only EAP methods 2039f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * that use method specific identity need to implement. 2049f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 2059f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson const u8 * (*get_identity)(struct eap_sm *sm, void *priv, size_t *len); 2069f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson 2079f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson /** 2089f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * free - Free EAP method data 2099f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * @method: Pointer to the method data registered with 2109f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * eap_peer_method_register(). 2119f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * 2129f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * This function will be called when the EAP method is being 2139f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * unregistered. If the EAP method allocated resources during 2149f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * registration (e.g., allocated struct eap_method), they should be 2159f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * freed in this function. No other method functions will be called 2169f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * after this call. If this function is not defined (i.e., function 2179f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * pointer is %NULL), a default handler is used to release the method 2189f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * data with free(method). This is suitable for most cases. 2199f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */ 2209f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson void (*free)(struct eap_method *method); 221 222#define EAP_PEER_METHOD_INTERFACE_VERSION 1 223 /** 224 * version - Version of the EAP peer method interface 225 * 226 * The EAP peer method implementation should set this variable to 227 * EAP_PEER_METHOD_INTERFACE_VERSION. This is used to verify that the 228 * EAP method is using supported API version when using dynamically 229 * loadable EAP methods. 230 */ 231 int version; 232 233 /** 234 * next - Pointer to the next EAP method 235 * 236 * This variable is used internally in the EAP method registration code 237 * to create a linked list of registered EAP methods. 238 */ 239 struct eap_method *next; 240 241#ifdef CONFIG_DYNAMIC_EAP_METHODS 242 /** 243 * dl_handle - Handle for the dynamic library 244 * 245 * This variable is used internally in the EAP method registration code 246 * to store a handle for the dynamic library. If the method is linked 247 * in statically, this is %NULL. 248 */ 249 void *dl_handle; 250#endif /* CONFIG_DYNAMIC_EAP_METHODS */ 251 252 /** 253 * get_emsk - Get EAP method specific keying extended material (EMSK) 254 * @sm: Pointer to EAP state machine allocated with eap_peer_sm_init() 255 * @priv: Pointer to private EAP method data from eap_method::init() 256 * @len: Pointer to a variable to store EMSK length 257 * Returns: EMSK or %NULL if not available 258 * 259 * This function can be used to get the extended keying material from 260 * the EAP method. The key may already be stored in the method-specific 261 * private data or this function may derive the key. 262 */ 263 u8 * (*get_emsk)(struct eap_sm *sm, void *priv, size_t *len); 264 265 /** 266 * getSessionId - Get EAP method specific Session-Id 267 * @sm: Pointer to EAP state machine allocated with eap_peer_sm_init() 268 * @priv: Pointer to private EAP method data from eap_method::init() 269 * @len: Pointer to a variable to store Session-Id length 270 * Returns: Session-Id or %NULL if not available 271 * 272 * This function can be used to get the Session-Id from the EAP method. 273 * The Session-Id may already be stored in the method-specific private 274 * data or this function may derive the Session-Id. 275 */ 276 u8 * (*getSessionId)(struct eap_sm *sm, void *priv, size_t *len); 277}; 278 279 280/** 281 * struct eap_sm - EAP state machine data 282 */ 283struct eap_sm { 284 enum { 285 EAP_INITIALIZE, EAP_DISABLED, EAP_IDLE, EAP_RECEIVED, 286 EAP_GET_METHOD, EAP_METHOD, EAP_SEND_RESPONSE, EAP_DISCARD, 287 EAP_IDENTITY, EAP_NOTIFICATION, EAP_RETRANSMIT, EAP_SUCCESS, 288 EAP_FAILURE 289 } EAP_state; 290 /* Long-term local variables */ 291 EapType selectedMethod; 292 EapMethodState methodState; 293 int lastId; 294 struct wpabuf *lastRespData; 295 EapDecision decision; 296 /* Short-term local variables */ 297 Boolean rxReq; 298 Boolean rxSuccess; 299 Boolean rxFailure; 300 int reqId; 301 EapType reqMethod; 302 int reqVendor; 303 u32 reqVendorMethod; 304 Boolean ignore; 305 /* Constants */ 306 int ClientTimeout; 307 308 /* Miscellaneous variables */ 309 Boolean allowNotifications; /* peer state machine <-> methods */ 310 struct wpabuf *eapRespData; /* peer to lower layer */ 311 Boolean eapKeyAvailable; /* peer to lower layer */ 312 u8 *eapKeyData; /* peer to lower layer */ 313 size_t eapKeyDataLen; /* peer to lower layer */ 314 u8 *eapSessionId; /* peer to lower layer */ 315 size_t eapSessionIdLen; /* peer to lower layer */ 316 const struct eap_method *m; /* selected EAP method */ 317 /* not defined in RFC 4137 */ 318 Boolean changed; 319 void *eapol_ctx; 320 struct eapol_callbacks *eapol_cb; 321 void *eap_method_priv; 322 int init_phase2; 323 int fast_reauth; 324 325 Boolean rxResp /* LEAP only */; 326 Boolean leap_done; 327 Boolean peap_done; 328 u8 req_md5[16]; /* MD5() of the current EAP packet */ 329 u8 last_md5[16]; /* MD5() of the previously received EAP packet; used 330 * in duplicate request detection. */ 331 332 void *msg_ctx; 333 void *scard_ctx; 334 void *ssl_ctx; 335 void *ssl_ctx2; 336 337 unsigned int workaround; 338 339 /* Optional challenges generated in Phase 1 (EAP-FAST) */ 340 u8 *peer_challenge, *auth_challenge; 341 342 int num_rounds; 343 int force_disabled; 344 345 struct wps_context *wps; 346 347 int prev_failure; 348 349 struct ext_password_data *ext_pw; 350 struct wpabuf *ext_pw_buf; 351 352 int external_sim; 353}; 354 355const u8 * eap_get_config_identity(struct eap_sm *sm, size_t *len); 356const u8 * eap_get_config_password(struct eap_sm *sm, size_t *len); 357const u8 * eap_get_config_password2(struct eap_sm *sm, size_t *len, int *hash); 358const u8 * eap_get_config_new_password(struct eap_sm *sm, size_t *len); 359const u8 * eap_get_config_otp(struct eap_sm *sm, size_t *len); 360void eap_clear_config_otp(struct eap_sm *sm); 361const char * eap_get_config_phase1(struct eap_sm *sm); 362const char * eap_get_config_phase2(struct eap_sm *sm); 363int eap_get_config_fragment_size(struct eap_sm *sm); 364struct eap_peer_config * eap_get_config(struct eap_sm *sm); 365void eap_set_config_blob(struct eap_sm *sm, struct wpa_config_blob *blob); 366const struct wpa_config_blob * 367eap_get_config_blob(struct eap_sm *sm, const char *name); 368void eap_notify_pending(struct eap_sm *sm); 369int eap_allowed_method(struct eap_sm *sm, int vendor, u32 method); 370 371#endif /* EAP_I_H */ 372