xref: /freebsd/contrib/wpa/src/eap_peer/eap_i.h (revision a90b9d0159070121c221b966469c3e36d912bf82)
139beb93cSSam Leffler /*
239beb93cSSam Leffler  * EAP peer state machines internal structures (RFC 4137)
35b9c547cSRui Paulo  * Copyright (c) 2004-2014, Jouni Malinen <j@w1.fi>
439beb93cSSam Leffler  *
5f05cddf9SRui Paulo  * This software may be distributed under the terms of the BSD license.
6f05cddf9SRui Paulo  * See README for more details.
739beb93cSSam Leffler  */
839beb93cSSam Leffler 
939beb93cSSam Leffler #ifndef EAP_I_H
1039beb93cSSam Leffler #define EAP_I_H
1139beb93cSSam Leffler 
1239beb93cSSam Leffler #include "wpabuf.h"
135b9c547cSRui Paulo #include "utils/list.h"
1439beb93cSSam Leffler #include "eap_peer/eap.h"
1539beb93cSSam Leffler #include "eap_common/eap_common.h"
1639beb93cSSam Leffler 
1785732ac8SCy Schubert #define NO_EAP_METHOD_ERROR (-1)
1885732ac8SCy Schubert 
1939beb93cSSam Leffler /* RFC 4137 - EAP Peer state machine */
2039beb93cSSam Leffler 
2139beb93cSSam Leffler typedef enum {
2239beb93cSSam Leffler 	DECISION_FAIL, DECISION_COND_SUCC, DECISION_UNCOND_SUCC
2339beb93cSSam Leffler } EapDecision;
2439beb93cSSam Leffler 
2539beb93cSSam Leffler typedef enum {
2639beb93cSSam Leffler 	METHOD_NONE, METHOD_INIT, METHOD_CONT, METHOD_MAY_CONT, METHOD_DONE
2739beb93cSSam Leffler } EapMethodState;
2839beb93cSSam Leffler 
2939beb93cSSam Leffler /**
3039beb93cSSam Leffler  * struct eap_method_ret - EAP return values from struct eap_method::process()
3139beb93cSSam Leffler  *
3239beb93cSSam Leffler  * These structure contains OUT variables for the interface between peer state
3339beb93cSSam Leffler  * machine and methods (RFC 4137, Sect. 4.2). eapRespData will be returned as
3439beb93cSSam Leffler  * the return value of struct eap_method::process() so it is not included in
3539beb93cSSam Leffler  * this structure.
3639beb93cSSam Leffler  */
3739beb93cSSam Leffler struct eap_method_ret {
3839beb93cSSam Leffler 	/**
3939beb93cSSam Leffler 	 * ignore - Whether method decided to drop the current packed (OUT)
4039beb93cSSam Leffler 	 */
41c1d255d3SCy Schubert 	bool ignore;
4239beb93cSSam Leffler 
4339beb93cSSam Leffler 	/**
4439beb93cSSam Leffler 	 * methodState - Method-specific state (IN/OUT)
4539beb93cSSam Leffler 	 */
4639beb93cSSam Leffler 	EapMethodState methodState;
4739beb93cSSam Leffler 
4839beb93cSSam Leffler 	/**
4939beb93cSSam Leffler 	 * decision - Authentication decision (OUT)
5039beb93cSSam Leffler 	 */
5139beb93cSSam Leffler 	EapDecision decision;
5239beb93cSSam Leffler 
5339beb93cSSam Leffler 	/**
5439beb93cSSam Leffler 	 * allowNotifications - Whether method allows notifications (OUT)
5539beb93cSSam Leffler 	 */
56c1d255d3SCy Schubert 	bool allowNotifications;
5739beb93cSSam Leffler };
5839beb93cSSam Leffler 
5939beb93cSSam Leffler 
6039beb93cSSam Leffler /**
6139beb93cSSam Leffler  * struct eap_method - EAP method interface
6239beb93cSSam Leffler  * This structure defines the EAP method interface. Each method will need to
6339beb93cSSam Leffler  * register its own EAP type, EAP name, and set of function pointers for method
6439beb93cSSam Leffler  * specific operations. This interface is based on section 4.4 of RFC 4137.
6539beb93cSSam Leffler  */
6639beb93cSSam Leffler struct eap_method {
6739beb93cSSam Leffler 	/**
6839beb93cSSam Leffler 	 * vendor - EAP Vendor-ID (EAP_VENDOR_*) (0 = IETF)
6939beb93cSSam Leffler 	 */
7039beb93cSSam Leffler 	int vendor;
7139beb93cSSam Leffler 
7239beb93cSSam Leffler 	/**
7339beb93cSSam Leffler 	 * method - EAP type number (EAP_TYPE_*)
7439beb93cSSam Leffler 	 */
75c1d255d3SCy Schubert 	enum eap_type method;
7639beb93cSSam Leffler 
7739beb93cSSam Leffler 	/**
7839beb93cSSam Leffler 	 * name - Name of the method (e.g., "TLS")
7939beb93cSSam Leffler 	 */
8039beb93cSSam Leffler 	const char *name;
8139beb93cSSam Leffler 
8239beb93cSSam Leffler 	/**
8339beb93cSSam Leffler 	 * init - Initialize an EAP method
8439beb93cSSam Leffler 	 * @sm: Pointer to EAP state machine allocated with eap_peer_sm_init()
8539beb93cSSam Leffler 	 * Returns: Pointer to allocated private data, or %NULL on failure
8639beb93cSSam Leffler 	 *
8739beb93cSSam Leffler 	 * This function is used to initialize the EAP method explicitly
8839beb93cSSam Leffler 	 * instead of using METHOD_INIT state as specific in RFC 4137. The
8939beb93cSSam Leffler 	 * method is expected to initialize it method-specific state and return
9039beb93cSSam Leffler 	 * a pointer that will be used as the priv argument to other calls.
9139beb93cSSam Leffler 	 */
9239beb93cSSam Leffler 	void * (*init)(struct eap_sm *sm);
9339beb93cSSam Leffler 
9439beb93cSSam Leffler 	/**
9539beb93cSSam Leffler 	 * deinit - Deinitialize an EAP method
9639beb93cSSam Leffler 	 * @sm: Pointer to EAP state machine allocated with eap_peer_sm_init()
9739beb93cSSam Leffler 	 * @priv: Pointer to private EAP method data from eap_method::init()
9839beb93cSSam Leffler 	 *
9939beb93cSSam Leffler 	 * Deinitialize the EAP method and free any allocated private data.
10039beb93cSSam Leffler 	 */
10139beb93cSSam Leffler 	void (*deinit)(struct eap_sm *sm, void *priv);
10239beb93cSSam Leffler 
10339beb93cSSam Leffler 	/**
10439beb93cSSam Leffler 	 * process - Process an EAP request
10539beb93cSSam Leffler 	 * @sm: Pointer to EAP state machine allocated with eap_peer_sm_init()
10639beb93cSSam Leffler 	 * @priv: Pointer to private EAP method data from eap_method::init()
10739beb93cSSam Leffler 	 * @ret: Return values from EAP request validation and processing
10839beb93cSSam Leffler 	 * @reqData: EAP request to be processed (eapReqData)
10939beb93cSSam Leffler 	 * Returns: Pointer to allocated EAP response packet (eapRespData)
11039beb93cSSam Leffler 	 *
11139beb93cSSam Leffler 	 * This function is a combination of m.check(), m.process(), and
11239beb93cSSam Leffler 	 * m.buildResp() procedures defined in section 4.4 of RFC 4137 In other
11339beb93cSSam Leffler 	 * words, this function validates the incoming request, processes it,
11439beb93cSSam Leffler 	 * and build a response packet. m.check() and m.process() return values
11539beb93cSSam Leffler 	 * are returned through struct eap_method_ret *ret variable. Caller is
11639beb93cSSam Leffler 	 * responsible for freeing the returned EAP response packet.
11739beb93cSSam Leffler 	 */
11839beb93cSSam Leffler 	struct wpabuf * (*process)(struct eap_sm *sm, void *priv,
11939beb93cSSam Leffler 				   struct eap_method_ret *ret,
12039beb93cSSam Leffler 				   const struct wpabuf *reqData);
12139beb93cSSam Leffler 
12239beb93cSSam Leffler 	/**
12339beb93cSSam Leffler 	 * isKeyAvailable - Find out whether EAP method has keying material
12439beb93cSSam Leffler 	 * @sm: Pointer to EAP state machine allocated with eap_peer_sm_init()
12539beb93cSSam Leffler 	 * @priv: Pointer to private EAP method data from eap_method::init()
126c1d255d3SCy Schubert 	 * Returns: %true if key material (eapKeyData) is available
12739beb93cSSam Leffler 	 */
128c1d255d3SCy Schubert 	bool (*isKeyAvailable)(struct eap_sm *sm, void *priv);
12939beb93cSSam Leffler 
13039beb93cSSam Leffler 	/**
13139beb93cSSam Leffler 	 * getKey - Get EAP method specific keying material (eapKeyData)
13239beb93cSSam Leffler 	 * @sm: Pointer to EAP state machine allocated with eap_peer_sm_init()
13339beb93cSSam Leffler 	 * @priv: Pointer to private EAP method data from eap_method::init()
13439beb93cSSam Leffler 	 * @len: Pointer to variable to store key length (eapKeyDataLen)
13539beb93cSSam Leffler 	 * Returns: Keying material (eapKeyData) or %NULL if not available
13639beb93cSSam Leffler 	 *
13739beb93cSSam Leffler 	 * This function can be used to get the keying material from the EAP
13839beb93cSSam Leffler 	 * method. The key may already be stored in the method-specific private
13939beb93cSSam Leffler 	 * data or this function may derive the key.
14039beb93cSSam Leffler 	 */
14139beb93cSSam Leffler 	u8 * (*getKey)(struct eap_sm *sm, void *priv, size_t *len);
14239beb93cSSam Leffler 
14339beb93cSSam Leffler 	/**
14439beb93cSSam Leffler 	 * get_status - Get EAP method status
14539beb93cSSam Leffler 	 * @sm: Pointer to EAP state machine allocated with eap_peer_sm_init()
14639beb93cSSam Leffler 	 * @priv: Pointer to private EAP method data from eap_method::init()
14739beb93cSSam Leffler 	 * @buf: Buffer for status information
14839beb93cSSam Leffler 	 * @buflen: Maximum buffer length
14939beb93cSSam Leffler 	 * @verbose: Whether to include verbose status information
15039beb93cSSam Leffler 	 * Returns: Number of bytes written to buf
15139beb93cSSam Leffler 	 *
15239beb93cSSam Leffler 	 * Query EAP method for status information. This function fills in a
15339beb93cSSam Leffler 	 * text area with current status information from the EAP method. If
15439beb93cSSam Leffler 	 * the buffer (buf) is not large enough, status information will be
15539beb93cSSam Leffler 	 * truncated to fit the buffer.
15639beb93cSSam Leffler 	 */
15739beb93cSSam Leffler 	int (*get_status)(struct eap_sm *sm, void *priv, char *buf,
15839beb93cSSam Leffler 			  size_t buflen, int verbose);
15939beb93cSSam Leffler 
16039beb93cSSam Leffler 	/**
16139beb93cSSam Leffler 	 * has_reauth_data - Whether method is ready for fast reauthentication
16239beb93cSSam Leffler 	 * @sm: Pointer to EAP state machine allocated with eap_peer_sm_init()
16339beb93cSSam Leffler 	 * @priv: Pointer to private EAP method data from eap_method::init()
164c1d255d3SCy Schubert 	 * Returns: %true or %false based on whether fast reauthentication is
16539beb93cSSam Leffler 	 * possible
16639beb93cSSam Leffler 	 *
16739beb93cSSam Leffler 	 * This function is an optional handler that only EAP methods
16839beb93cSSam Leffler 	 * supporting fast re-authentication need to implement.
16939beb93cSSam Leffler 	 */
170c1d255d3SCy Schubert 	bool (*has_reauth_data)(struct eap_sm *sm, void *priv);
17139beb93cSSam Leffler 
17239beb93cSSam Leffler 	/**
17339beb93cSSam Leffler 	 * deinit_for_reauth - Release data that is not needed for fast re-auth
17439beb93cSSam Leffler 	 * @sm: Pointer to EAP state machine allocated with eap_peer_sm_init()
17539beb93cSSam Leffler 	 * @priv: Pointer to private EAP method data from eap_method::init()
17639beb93cSSam Leffler 	 *
17739beb93cSSam Leffler 	 * This function is an optional handler that only EAP methods
17839beb93cSSam Leffler 	 * supporting fast re-authentication need to implement. This is called
17939beb93cSSam Leffler 	 * when authentication has been completed and EAP state machine is
18039beb93cSSam Leffler 	 * requesting that enough state information is maintained for fast
18139beb93cSSam Leffler 	 * re-authentication
18239beb93cSSam Leffler 	 */
18339beb93cSSam Leffler 	void (*deinit_for_reauth)(struct eap_sm *sm, void *priv);
18439beb93cSSam Leffler 
18539beb93cSSam Leffler 	/**
18639beb93cSSam Leffler 	 * init_for_reauth - Prepare for start of fast re-authentication
18739beb93cSSam Leffler 	 * @sm: Pointer to EAP state machine allocated with eap_peer_sm_init()
18839beb93cSSam Leffler 	 * @priv: Pointer to private EAP method data from eap_method::init()
18939beb93cSSam Leffler 	 *
19039beb93cSSam Leffler 	 * This function is an optional handler that only EAP methods
19139beb93cSSam Leffler 	 * supporting fast re-authentication need to implement. This is called
19239beb93cSSam Leffler 	 * when EAP authentication is started and EAP state machine is
19339beb93cSSam Leffler 	 * requesting fast re-authentication to be used.
19439beb93cSSam Leffler 	 */
19539beb93cSSam Leffler 	void * (*init_for_reauth)(struct eap_sm *sm, void *priv);
19639beb93cSSam Leffler 
19739beb93cSSam Leffler 	/**
19839beb93cSSam Leffler 	 * get_identity - Get method specific identity for re-authentication
19939beb93cSSam Leffler 	 * @sm: Pointer to EAP state machine allocated with eap_peer_sm_init()
20039beb93cSSam Leffler 	 * @priv: Pointer to private EAP method data from eap_method::init()
20139beb93cSSam Leffler 	 * @len: Length of the returned identity
20239beb93cSSam Leffler 	 * Returns: Pointer to the method specific identity or %NULL if default
20339beb93cSSam Leffler 	 * identity is to be used
20439beb93cSSam Leffler 	 *
20539beb93cSSam Leffler 	 * This function is an optional handler that only EAP methods
20639beb93cSSam Leffler 	 * that use method specific identity need to implement.
20739beb93cSSam Leffler 	 */
20839beb93cSSam Leffler 	const u8 * (*get_identity)(struct eap_sm *sm, void *priv, size_t *len);
20939beb93cSSam Leffler 
21039beb93cSSam Leffler 	/**
21185732ac8SCy Schubert 	 * get_error_code - Get the latest EAP method error code
21285732ac8SCy Schubert 	 * @priv: Pointer to private EAP method data from eap_method::init()
21385732ac8SCy Schubert 	 * Returns: An int for the EAP method specific error code if exists or
21485732ac8SCy Schubert 	 * NO_EAP_METHOD_ERROR otherwise.
21585732ac8SCy Schubert 	 *
21685732ac8SCy Schubert 	 * This method is an optional handler that only EAP methods that need to
21785732ac8SCy Schubert 	 * report their error code need to implement.
21885732ac8SCy Schubert 	 */
21985732ac8SCy Schubert 	int (*get_error_code)(void *priv);
22085732ac8SCy Schubert 
22185732ac8SCy Schubert 	/**
22239beb93cSSam Leffler 	 * free - Free EAP method data
22339beb93cSSam Leffler 	 * @method: Pointer to the method data registered with
22439beb93cSSam Leffler 	 * eap_peer_method_register().
22539beb93cSSam Leffler 	 *
22639beb93cSSam Leffler 	 * This function will be called when the EAP method is being
22739beb93cSSam Leffler 	 * unregistered. If the EAP method allocated resources during
22839beb93cSSam Leffler 	 * registration (e.g., allocated struct eap_method), they should be
22939beb93cSSam Leffler 	 * freed in this function. No other method functions will be called
23039beb93cSSam Leffler 	 * after this call. If this function is not defined (i.e., function
23139beb93cSSam Leffler 	 * pointer is %NULL), a default handler is used to release the method
23239beb93cSSam Leffler 	 * data with free(method). This is suitable for most cases.
23339beb93cSSam Leffler 	 */
23439beb93cSSam Leffler 	void (*free)(struct eap_method *method);
23539beb93cSSam Leffler 
23639beb93cSSam Leffler #define EAP_PEER_METHOD_INTERFACE_VERSION 1
23739beb93cSSam Leffler 	/**
23839beb93cSSam Leffler 	 * version - Version of the EAP peer method interface
23939beb93cSSam Leffler 	 *
24039beb93cSSam Leffler 	 * The EAP peer method implementation should set this variable to
24139beb93cSSam Leffler 	 * EAP_PEER_METHOD_INTERFACE_VERSION. This is used to verify that the
24239beb93cSSam Leffler 	 * EAP method is using supported API version when using dynamically
24339beb93cSSam Leffler 	 * loadable EAP methods.
24439beb93cSSam Leffler 	 */
24539beb93cSSam Leffler 	int version;
24639beb93cSSam Leffler 
24739beb93cSSam Leffler 	/**
24839beb93cSSam Leffler 	 * next - Pointer to the next EAP method
24939beb93cSSam Leffler 	 *
25039beb93cSSam Leffler 	 * This variable is used internally in the EAP method registration code
25139beb93cSSam Leffler 	 * to create a linked list of registered EAP methods.
25239beb93cSSam Leffler 	 */
25339beb93cSSam Leffler 	struct eap_method *next;
25439beb93cSSam Leffler 
25539beb93cSSam Leffler #ifdef CONFIG_DYNAMIC_EAP_METHODS
25639beb93cSSam Leffler 	/**
25739beb93cSSam Leffler 	 * dl_handle - Handle for the dynamic library
25839beb93cSSam Leffler 	 *
25939beb93cSSam Leffler 	 * This variable is used internally in the EAP method registration code
26039beb93cSSam Leffler 	 * to store a handle for the dynamic library. If the method is linked
26139beb93cSSam Leffler 	 * in statically, this is %NULL.
26239beb93cSSam Leffler 	 */
26339beb93cSSam Leffler 	void *dl_handle;
26439beb93cSSam Leffler #endif /* CONFIG_DYNAMIC_EAP_METHODS */
26539beb93cSSam Leffler 
26639beb93cSSam Leffler 	/**
26739beb93cSSam Leffler 	 * get_emsk - Get EAP method specific keying extended material (EMSK)
26839beb93cSSam Leffler 	 * @sm: Pointer to EAP state machine allocated with eap_peer_sm_init()
26939beb93cSSam Leffler 	 * @priv: Pointer to private EAP method data from eap_method::init()
27039beb93cSSam Leffler 	 * @len: Pointer to a variable to store EMSK length
27139beb93cSSam Leffler 	 * Returns: EMSK or %NULL if not available
27239beb93cSSam Leffler 	 *
27339beb93cSSam Leffler 	 * This function can be used to get the extended keying material from
27439beb93cSSam Leffler 	 * the EAP method. The key may already be stored in the method-specific
27539beb93cSSam Leffler 	 * private data or this function may derive the key.
27639beb93cSSam Leffler 	 */
27739beb93cSSam Leffler 	u8 * (*get_emsk)(struct eap_sm *sm, void *priv, size_t *len);
2785b9c547cSRui Paulo 
2795b9c547cSRui Paulo 	/**
2805b9c547cSRui Paulo 	 * getSessionId - Get EAP method specific Session-Id
2815b9c547cSRui Paulo 	 * @sm: Pointer to EAP state machine allocated with eap_peer_sm_init()
2825b9c547cSRui Paulo 	 * @priv: Pointer to private EAP method data from eap_method::init()
2835b9c547cSRui Paulo 	 * @len: Pointer to a variable to store Session-Id length
2845b9c547cSRui Paulo 	 * Returns: Session-Id or %NULL if not available
2855b9c547cSRui Paulo 	 *
2865b9c547cSRui Paulo 	 * This function can be used to get the Session-Id from the EAP method.
2875b9c547cSRui Paulo 	 * The Session-Id may already be stored in the method-specific private
2885b9c547cSRui Paulo 	 * data or this function may derive the Session-Id.
2895b9c547cSRui Paulo 	 */
2905b9c547cSRui Paulo 	u8 * (*getSessionId)(struct eap_sm *sm, void *priv, size_t *len);
29139beb93cSSam Leffler };
29239beb93cSSam Leffler 
29339beb93cSSam Leffler 
2945b9c547cSRui Paulo struct eap_erp_key {
2955b9c547cSRui Paulo 	struct dl_list list;
2965b9c547cSRui Paulo 	size_t rRK_len;
2975b9c547cSRui Paulo 	size_t rIK_len;
2985b9c547cSRui Paulo 	u8 rRK[ERP_MAX_KEY_LEN];
2995b9c547cSRui Paulo 	u8 rIK[ERP_MAX_KEY_LEN];
3005b9c547cSRui Paulo 	u32 next_seq;
3015b9c547cSRui Paulo 	char keyname_nai[];
3025b9c547cSRui Paulo };
3035b9c547cSRui Paulo 
30439beb93cSSam Leffler /**
30539beb93cSSam Leffler  * struct eap_sm - EAP state machine data
30639beb93cSSam Leffler  */
30739beb93cSSam Leffler struct eap_sm {
30839beb93cSSam Leffler 	enum {
30939beb93cSSam Leffler 		EAP_INITIALIZE, EAP_DISABLED, EAP_IDLE, EAP_RECEIVED,
31039beb93cSSam Leffler 		EAP_GET_METHOD, EAP_METHOD, EAP_SEND_RESPONSE, EAP_DISCARD,
31139beb93cSSam Leffler 		EAP_IDENTITY, EAP_NOTIFICATION, EAP_RETRANSMIT, EAP_SUCCESS,
31239beb93cSSam Leffler 		EAP_FAILURE
31339beb93cSSam Leffler 	} EAP_state;
31439beb93cSSam Leffler 	/* Long-term local variables */
315c1d255d3SCy Schubert 	enum eap_type selectedMethod;
31639beb93cSSam Leffler 	EapMethodState methodState;
31739beb93cSSam Leffler 	int lastId;
31839beb93cSSam Leffler 	struct wpabuf *lastRespData;
31939beb93cSSam Leffler 	EapDecision decision;
32039beb93cSSam Leffler 	/* Short-term local variables */
321c1d255d3SCy Schubert 	bool rxReq;
322c1d255d3SCy Schubert 	bool rxSuccess;
323c1d255d3SCy Schubert 	bool rxFailure;
32439beb93cSSam Leffler 	int reqId;
325c1d255d3SCy Schubert 	enum eap_type reqMethod;
32639beb93cSSam Leffler 	int reqVendor;
32739beb93cSSam Leffler 	u32 reqVendorMethod;
328c1d255d3SCy Schubert 	bool ignore;
32939beb93cSSam Leffler 	/* Constants */
33039beb93cSSam Leffler 	int ClientTimeout;
33139beb93cSSam Leffler 
33239beb93cSSam Leffler 	/* Miscellaneous variables */
333c1d255d3SCy Schubert 	bool allowNotifications; /* peer state machine <-> methods */
33439beb93cSSam Leffler 	struct wpabuf *eapRespData; /* peer to lower layer */
335c1d255d3SCy Schubert 	bool eapKeyAvailable; /* peer to lower layer */
33639beb93cSSam Leffler 	u8 *eapKeyData; /* peer to lower layer */
33739beb93cSSam Leffler 	size_t eapKeyDataLen; /* peer to lower layer */
3385b9c547cSRui Paulo 	u8 *eapSessionId; /* peer to lower layer */
3395b9c547cSRui Paulo 	size_t eapSessionIdLen; /* peer to lower layer */
34039beb93cSSam Leffler 	const struct eap_method *m; /* selected EAP method */
34139beb93cSSam Leffler 	/* not defined in RFC 4137 */
342c1d255d3SCy Schubert 	bool changed;
34339beb93cSSam Leffler 	void *eapol_ctx;
344325151a3SRui Paulo 	const struct eapol_callbacks *eapol_cb;
34539beb93cSSam Leffler 	void *eap_method_priv;
34639beb93cSSam Leffler 	int init_phase2;
34739beb93cSSam Leffler 	int fast_reauth;
348c1d255d3SCy Schubert 	bool reauthInit; /* send EAP-Identity/Re-auth */
3495b9c547cSRui Paulo 	u32 erp_seq;
35039beb93cSSam Leffler 
351c1d255d3SCy Schubert 	bool rxResp /* LEAP only */;
352c1d255d3SCy Schubert 	bool leap_done;
353c1d255d3SCy Schubert 	bool peap_done;
354325151a3SRui Paulo 	u8 req_sha1[20]; /* SHA1() of the current EAP packet */
355325151a3SRui Paulo 	u8 last_sha1[20]; /* SHA1() of the previously received EAP packet; used
35639beb93cSSam Leffler 			   * in duplicate request detection. */
35739beb93cSSam Leffler 
35839beb93cSSam Leffler 	void *msg_ctx;
35939beb93cSSam Leffler 	void *scard_ctx;
36039beb93cSSam Leffler 	void *ssl_ctx;
361f05cddf9SRui Paulo 	void *ssl_ctx2;
36239beb93cSSam Leffler 
36339beb93cSSam Leffler 	unsigned int workaround;
36439beb93cSSam Leffler 
36539beb93cSSam Leffler 	/* Optional challenges generated in Phase 1 (EAP-FAST) */
36639beb93cSSam Leffler 	u8 *peer_challenge, *auth_challenge;
36739beb93cSSam Leffler 
368*a90b9d01SCy Schubert 	/* Whether to use the EAP-FAST-MSCHAPv2 instantiation of EAP-MSCHAPv2.
369*a90b9d01SCy Schubert 	 * That variant is otherwise identical, but it generates the MSK using
370*a90b9d01SCy Schubert 	 * MS-MPPE keys in reverse order. */
371*a90b9d01SCy Schubert 	bool eap_fast_mschapv2;
372*a90b9d01SCy Schubert 
37339beb93cSSam Leffler 	int num_rounds;
374c1d255d3SCy Schubert 	int num_rounds_short;
37539beb93cSSam Leffler 	int force_disabled;
37639beb93cSSam Leffler 
37739beb93cSSam Leffler 	struct wps_context *wps;
37839beb93cSSam Leffler 
37939beb93cSSam Leffler 	int prev_failure;
3805b9c547cSRui Paulo 	struct eap_peer_config *last_config;
381f05cddf9SRui Paulo 
382f05cddf9SRui Paulo 	struct ext_password_data *ext_pw;
383f05cddf9SRui Paulo 	struct wpabuf *ext_pw_buf;
3845b9c547cSRui Paulo 
3855b9c547cSRui Paulo 	int external_sim;
3865b9c547cSRui Paulo 
3875b9c547cSRui Paulo 	unsigned int expected_failure:1;
388780fb4a2SCy Schubert 	unsigned int ext_cert_check:1;
389780fb4a2SCy Schubert 	unsigned int waiting_ext_cert_check:1;
390c1d255d3SCy Schubert 	unsigned int use_machine_cred:1;
3915b9c547cSRui Paulo 
3925b9c547cSRui Paulo 	struct dl_list erp_keys; /* struct eap_erp_key */
393*a90b9d01SCy Schubert 
394*a90b9d01SCy Schubert 	/* Identity used in EAP-Response/Identity */
395*a90b9d01SCy Schubert 	u8 *identity;
396*a90b9d01SCy Schubert 	size_t identity_len;
39739beb93cSSam Leffler };
39839beb93cSSam Leffler 
39939beb93cSSam Leffler const u8 * eap_get_config_identity(struct eap_sm *sm, size_t *len);
40039beb93cSSam Leffler const u8 * eap_get_config_password(struct eap_sm *sm, size_t *len);
40139beb93cSSam Leffler const u8 * eap_get_config_password2(struct eap_sm *sm, size_t *len, int *hash);
40239beb93cSSam Leffler const u8 * eap_get_config_new_password(struct eap_sm *sm, size_t *len);
40339beb93cSSam Leffler const u8 * eap_get_config_otp(struct eap_sm *sm, size_t *len);
40439beb93cSSam Leffler void eap_clear_config_otp(struct eap_sm *sm);
40539beb93cSSam Leffler const char * eap_get_config_phase1(struct eap_sm *sm);
40639beb93cSSam Leffler const char * eap_get_config_phase2(struct eap_sm *sm);
407f05cddf9SRui Paulo int eap_get_config_fragment_size(struct eap_sm *sm);
40839beb93cSSam Leffler struct eap_peer_config * eap_get_config(struct eap_sm *sm);
40939beb93cSSam Leffler void eap_set_config_blob(struct eap_sm *sm, struct wpa_config_blob *blob);
41039beb93cSSam Leffler const struct wpa_config_blob *
41139beb93cSSam Leffler eap_get_config_blob(struct eap_sm *sm, const char *name);
41239beb93cSSam Leffler void eap_notify_pending(struct eap_sm *sm);
41339beb93cSSam Leffler int eap_allowed_method(struct eap_sm *sm, int vendor, u32 method);
41439beb93cSSam Leffler 
41539beb93cSSam Leffler #endif /* EAP_I_H */
416