2 * hostapd / EAP Authenticator state machine internal structures (RFC 4137)
3 * Copyright (c) 2004-2007, Jouni Malinen <j@w1.fi>
5 * This software may be distributed under the terms of the BSD license.
6 * See README for more details.
13 #include "eap_server/eap.h"
14 #include "eap_common/eap_common.h"
16 /* RFC 4137 - EAP Standalone Authenticator */
19 * struct eap_method - EAP method interface
20 * This structure defines the EAP method interface. Each method will need to
21 * register its own EAP type, EAP name, and set of function pointers for method
22 * specific operations. This interface is based on section 5.4 of RFC 4137.
29 void * (*init
)(struct eap_sm
*sm
);
30 void * (*initPickUp
)(struct eap_sm
*sm
);
31 void (*reset
)(struct eap_sm
*sm
, void *priv
);
33 struct wpabuf
* (*buildReq
)(struct eap_sm
*sm
, void *priv
, u8 id
);
34 int (*getTimeout
)(struct eap_sm
*sm
, void *priv
);
35 Boolean (*check
)(struct eap_sm
*sm
, void *priv
,
36 struct wpabuf
*respData
);
37 void (*process
)(struct eap_sm
*sm
, void *priv
,
38 struct wpabuf
*respData
);
39 Boolean (*isDone
)(struct eap_sm
*sm
, void *priv
);
40 u8
* (*getKey
)(struct eap_sm
*sm
, void *priv
, size_t *len
);
41 /* isSuccess is not specified in draft-ietf-eap-statemachine-05.txt,
42 * but it is useful in implementing Policy.getDecision() */
43 Boolean (*isSuccess
)(struct eap_sm
*sm
, void *priv
);
46 * free - Free EAP method data
47 * @method: Pointer to the method data registered with
48 * eap_server_method_register().
50 * This function will be called when the EAP method is being
51 * unregistered. If the EAP method allocated resources during
52 * registration (e.g., allocated struct eap_method), they should be
53 * freed in this function. No other method functions will be called
54 * after this call. If this function is not defined (i.e., function
55 * pointer is %NULL), a default handler is used to release the method
56 * data with free(method). This is suitable for most cases.
58 void (*free
)(struct eap_method
*method
);
60 #define EAP_SERVER_METHOD_INTERFACE_VERSION 1
62 * version - Version of the EAP server method interface
64 * The EAP server method implementation should set this variable to
65 * EAP_SERVER_METHOD_INTERFACE_VERSION. This is used to verify that the
66 * EAP method is using supported API version when using dynamically
67 * loadable EAP methods.
72 * next - Pointer to the next EAP method
74 * This variable is used internally in the EAP method registration code
75 * to create a linked list of registered EAP methods.
77 struct eap_method
*next
;
80 * get_emsk - Get EAP method specific keying extended material (EMSK)
81 * @sm: Pointer to EAP state machine allocated with eap_sm_init()
82 * @priv: Pointer to private EAP method data from eap_method::init()
83 * @len: Pointer to a variable to store EMSK length
84 * Returns: EMSK or %NULL if not available
86 * This function can be used to get the extended keying material from
87 * the EAP method. The key may already be stored in the method-specific
88 * private data or this function may derive the key.
90 u8
* (*get_emsk
)(struct eap_sm
*sm
, void *priv
, size_t *len
);
93 * getSessionId - Get EAP method specific Session-Id
94 * @sm: Pointer to EAP state machine allocated with eap_server_sm_init()
95 * @priv: Pointer to private EAP method data from eap_method::init()
96 * @len: Pointer to a variable to store Session-Id length
97 * Returns: Session-Id or %NULL if not available
99 * This function can be used to get the Session-Id from the EAP method.
100 * The Session-Id may already be stored in the method-specific private
101 * data or this function may derive the Session-Id.
103 u8
* (*getSessionId
)(struct eap_sm
*sm
, void *priv
, size_t *len
);
107 * struct eap_sm - EAP server state machine data
111 EAP_DISABLED
, EAP_INITIALIZE
, EAP_IDLE
, EAP_RECEIVED
,
112 EAP_INTEGRITY_CHECK
, EAP_METHOD_RESPONSE
, EAP_METHOD_REQUEST
,
113 EAP_PROPOSE_METHOD
, EAP_SELECT_ACTION
, EAP_SEND_REQUEST
,
114 EAP_DISCARD
, EAP_NAK
, EAP_RETRANSMIT
, EAP_SUCCESS
, EAP_FAILURE
,
115 EAP_TIMEOUT_FAILURE
, EAP_PICK_UP_METHOD
,
116 EAP_INITIALIZE_PASSTHROUGH
, EAP_IDLE2
, EAP_RETRANSMIT2
,
117 EAP_RECEIVED2
, EAP_DISCARD2
, EAP_SEND_REQUEST2
,
118 EAP_AAA_REQUEST
, EAP_AAA_RESPONSE
, EAP_AAA_IDLE
,
119 EAP_TIMEOUT_FAILURE2
, EAP_FAILURE2
, EAP_SUCCESS2
,
120 EAP_INITIATE_REAUTH_START
, EAP_INITIATE_RECEIVED
126 struct eap_eapol_interface eap_if
;
128 /* Full authenticator state machine local variables */
130 /* Long-term (maintained between packets) */
131 enum eap_type currentMethod
;
134 METHOD_PROPOSED
, METHOD_CONTINUE
, METHOD_END
137 struct wpabuf
*lastReqData
;
140 /* Short-term (not maintained between packets) */
144 enum eap_type respMethod
;
146 u32 respVendorMethod
;
149 DECISION_SUCCESS
, DECISION_FAILURE
, DECISION_CONTINUE
,
150 DECISION_PASSTHROUGH
, DECISION_INITIATE_REAUTH_START
153 /* Miscellaneous variables */
154 const struct eap_method
*m
; /* selected EAP method */
155 /* not defined in RFC 4137 */
158 const struct eapol_callbacks
*eapol_cb
;
159 void *eap_method_priv
;
164 /* Whether Phase 2 method should validate identity match */
165 int require_identity_match
;
166 int lastId
; /* Identifier used in the last EAP-Packet */
167 struct eap_user
*user
;
168 int user_eap_method_index
;
170 const struct eap_config
*cfg
;
171 struct eap_config cfg_buf
;
175 int num_rounds_short
;
177 METHOD_PENDING_NONE
, METHOD_PENDING_WAIT
, METHOD_PENDING_CONT
183 struct wpabuf
*assoc_wps_ie
;
184 struct wpabuf
*assoc_p2p_ie
;
186 Boolean start_reauth
;
188 u8 peer_addr
[ETH_ALEN
];
190 Boolean initiate_reauth_start_sent
;
191 Boolean try_initiate_reauth
;
193 #ifdef CONFIG_TESTING_OPTIONS
195 #endif /* CONFIG_TESTING_OPTIONS */
198 int eap_user_get(struct eap_sm
*sm
, const u8
*identity
, size_t identity_len
,
200 void eap_log_msg(struct eap_sm
*sm
, const char *fmt
, ...)
202 void eap_sm_process_nak(struct eap_sm
*sm
, const u8
*nak_list
, size_t len
);