Updated through tag hostap_2_5 from git://w1.fi/hostap.git
[mech_eap.git] / libeap / src / eapol_supp / eapol_supp_sm.h
index 1d2a32b..1309ff7 100644 (file)
@@ -1,15 +1,9 @@
 /*
  * EAPOL supplicant state machines
- * Copyright (c) 2004-2008, Jouni Malinen <j@w1.fi>
+ * Copyright (c) 2004-2012, Jouni Malinen <j@w1.fi>
  *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- * Alternatively, this software may be distributed under the terms of BSD
- * license.
- *
- * See README and COPYING for more details.
+ * This software may be distributed under the terms of the BSD license.
+ * See README for more details.
  */
 
 #ifndef EAPOL_SUPP_SM_H
@@ -59,11 +53,29 @@ struct eapol_config {
         * eap_disabled - Whether EAP is disabled
         */
        int eap_disabled;
+
+       /**
+        * external_sim - Use external processing for SIM/USIM operations
+        */
+       int external_sim;
+
+#define EAPOL_LOCAL_WPS_IN_USE BIT(0)
+#define EAPOL_PEER_IS_WPS20_AP BIT(1)
+       /**
+        * wps - Whether this connection is used for WPS
+        */
+       int wps;
 };
 
 struct eapol_sm;
 struct wpa_config_blob;
 
+enum eapol_supp_result {
+       EAPOL_SUPP_RESULT_FAILURE,
+       EAPOL_SUPP_RESULT_SUCCESS,
+       EAPOL_SUPP_RESULT_EXPECTED_FAILURE
+};
+
 /**
  * struct eapol_ctx - Global (for all networks) EAPOL state machine context
  */
@@ -84,7 +96,7 @@ struct eapol_ctx {
        /**
         * cb - Function to be called when EAPOL negotiation has been completed
         * @eapol: Pointer to EAPOL state machine data
-        * @success: Whether the authentication was completed successfully
+        * @result: Whether the authentication was completed successfully
         * @ctx: Pointer to context data (cb_ctx)
         *
         * This optional callback function will be called when the EAPOL
@@ -92,7 +104,8 @@ struct eapol_ctx {
         * EAPOL state machine to process the key and terminate the EAPOL state
         * machine. Currently, this is used only in RSN pre-authentication.
         */
-       void (*cb)(struct eapol_sm *eapol, int success, void *ctx);
+       void (*cb)(struct eapol_sm *eapol, enum eapol_supp_result result,
+                  void *ctx);
 
        /**
         * cb_ctx - Callback context for cb()
@@ -199,6 +212,15 @@ struct eapol_ctx {
        const char *pkcs11_module_path;
 
        /**
+        * openssl_ciphers - OpenSSL cipher string
+        *
+        * This is an OpenSSL specific configuration option for configuring the
+        * default ciphers. If not set, "DEFAULT:!EXP:!LOW" is used as the
+        * default.
+        */
+       const char *openssl_ciphers;
+
+       /**
         * wps - WPS context data
         *
         * This is only used by EAP-WSC and can be left %NULL if not available.
@@ -208,10 +230,10 @@ struct eapol_ctx {
        /**
         * eap_param_needed - Notify that EAP parameter is needed
         * @ctx: Callback context (ctx)
-        * @field: Field name (e.g., "IDENTITY")
+        * @field: Field indicator (e.g., WPA_CTRL_REQ_EAP_IDENTITY)
         * @txt: User readable text describing the required parameter
         */
-       void (*eap_param_needed)(void *ctx, const char *field,
+       void (*eap_param_needed)(void *ctx, enum wpa_ctrl_req_type field,
                                 const char *txt);
 
        /**
@@ -220,10 +242,55 @@ struct eapol_ctx {
         * @authorized: Whether the supplicant port is now in authorized state
         */
        void (*port_cb)(void *ctx, int authorized);
+
+       /**
+        * cert_cb - Notification of a peer certificate
+        * @ctx: Callback context (ctx)
+        * @depth: Depth in certificate chain (0 = server)
+        * @subject: Subject of the peer certificate
+        * @altsubject: Select fields from AltSubject of the peer certificate
+        * @num_altsubject: Number of altsubject values
+        * @cert_hash: SHA-256 hash of the certificate
+        * @cert: Peer certificate
+        */
+       void (*cert_cb)(void *ctx, int depth, const char *subject,
+                       const char *altsubject[], int num_altsubject,
+                       const char *cert_hash, const struct wpabuf *cert);
+
+       /**
+        * cert_in_cb - Include server certificates in callback
+        */
+       int cert_in_cb;
+
+       /**
+        * status_cb - Notification of a change in EAP status
+        * @ctx: Callback context (ctx)
+        * @status: Step in the process of EAP authentication
+        * @parameter: Step-specific parameter, e.g., EAP method name
+        */
+       void (*status_cb)(void *ctx, const char *status,
+                         const char *parameter);
+
+#ifdef CONFIG_EAP_PROXY
+       /**
+        * eap_proxy_cb - Callback signifying any updates from eap_proxy
+        * @ctx: eapol_ctx from eap_peer_sm_init() call
+        */
+       void (*eap_proxy_cb)(void *ctx);
+#endif /* CONFIG_EAP_PROXY */
+
+       /**
+        * set_anon_id - Set or add anonymous identity
+        * @ctx: eapol_ctx from eap_peer_sm_init() call
+        * @id: Anonymous identity (e.g., EAP-SIM pseudonym)
+        * @len: Length of anonymous identity in octets
+        */
+       void (*set_anon_id)(void *ctx, const u8 *id, size_t len);
 };
 
 
 struct eap_peer_config;
+struct ext_password_data;
 
 #ifdef IEEE8021X_EAPOL
 struct eapol_sm *eapol_sm_init(struct eapol_ctx *ctx);
@@ -245,9 +312,10 @@ void eapol_sm_notify_config(struct eapol_sm *sm,
                            struct eap_peer_config *config,
                            const struct eapol_config *conf);
 int eapol_sm_get_key(struct eapol_sm *sm, u8 *key, size_t len);
+const u8 * eapol_sm_get_session_id(struct eapol_sm *sm, size_t *len);
 void eapol_sm_notify_logoff(struct eapol_sm *sm, Boolean logoff);
 void eapol_sm_notify_cached(struct eapol_sm *sm);
-void eapol_sm_notify_pmkid_attempt(struct eapol_sm *sm, int attempt);
+void eapol_sm_notify_pmkid_attempt(struct eapol_sm *sm);
 void eapol_sm_register_scard_ctx(struct eapol_sm *sm, void *ctx);
 void eapol_sm_notify_portControl(struct eapol_sm *sm, PortControl portControl);
 void eapol_sm_notify_ctrl_attached(struct eapol_sm *sm);
@@ -255,6 +323,12 @@ void eapol_sm_notify_ctrl_response(struct eapol_sm *sm);
 void eapol_sm_request_reauth(struct eapol_sm *sm);
 void eapol_sm_notify_lower_layer_success(struct eapol_sm *sm, int in_eapol_sm);
 void eapol_sm_invalidate_cached_session(struct eapol_sm *sm);
+const char * eapol_sm_get_method_name(struct eapol_sm *sm);
+void eapol_sm_set_ext_pw_ctx(struct eapol_sm *sm,
+                            struct ext_password_data *ext);
+int eapol_sm_failed(struct eapol_sm *sm);
+void eapol_sm_erp_flush(struct eapol_sm *sm);
+int eapol_sm_get_eap_proxy_imsi(struct eapol_sm *sm, char *imsi, size_t *len);
 #else /* IEEE8021X_EAPOL */
 static inline struct eapol_sm *eapol_sm_init(struct eapol_ctx *ctx)
 {
@@ -314,13 +388,20 @@ static inline int eapol_sm_get_key(struct eapol_sm *sm, u8 *key, size_t len)
 {
        return -1;
 }
+static inline const u8 *
+eapol_sm_get_session_id(struct eapol_sm *sm, size_t *len)
+{
+       return NULL;
+}
 static inline void eapol_sm_notify_logoff(struct eapol_sm *sm, Boolean logoff)
 {
 }
 static inline void eapol_sm_notify_cached(struct eapol_sm *sm)
 {
 }
-#define eapol_sm_notify_pmkid_attempt(sm, attempt) do { } while (0)
+static inline void eapol_sm_notify_pmkid_attempt(struct eapol_sm *sm)
+{
+}
 #define eapol_sm_register_scard_ctx(sm, ctx) do { } while (0)
 static inline void eapol_sm_notify_portControl(struct eapol_sm *sm,
                                               PortControl portControl)
@@ -342,6 +423,21 @@ static inline void eapol_sm_notify_lower_layer_success(struct eapol_sm *sm,
 static inline void eapol_sm_invalidate_cached_session(struct eapol_sm *sm)
 {
 }
+static inline const char * eapol_sm_get_method_name(struct eapol_sm *sm)
+{
+       return NULL;
+}
+static inline void eapol_sm_set_ext_pw_ctx(struct eapol_sm *sm,
+                                          struct ext_password_data *ext)
+{
+}
+static inline int eapol_sm_failed(struct eapol_sm *sm)
+{
+       return 0;
+}
+static inline void eapol_sm_erp_flush(struct eapol_sm *sm)
+{
+}
 #endif /* IEEE8021X_EAPOL */
 
 #endif /* EAPOL_SUPP_SM_H */