]> git.ipfire.org Git - thirdparty/hostap.git/blobdiff - src/eap_peer/eap_i.h
Use a shared helper function for RSN supplicant capabilities
[thirdparty/hostap.git] / src / eap_peer / eap_i.h
index 623701c7fa03b282827354fa420ac9dc4dbeba1d..8f29d4a2623238dc3163fdf60067b8f5c86d6a3a 100644 (file)
@@ -1,24 +1,21 @@
 /*
  * EAP peer state machines internal structures (RFC 4137)
- * Copyright (c) 2004-2007, Jouni Malinen <j@w1.fi>
+ * Copyright (c) 2004-2014, 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 EAP_I_H
 #define EAP_I_H
 
 #include "wpabuf.h"
+#include "utils/list.h"
 #include "eap_peer/eap.h"
 #include "eap_common/eap_common.h"
 
+#define NO_EAP_METHOD_ERROR (-1)
+
 /* RFC 4137 - EAP Peer state machine */
 
 typedef enum {
@@ -75,7 +72,7 @@ struct eap_method {
        /**
         * method - EAP type number (EAP_TYPE_*)
         */
-       EapType method;
+       enum eap_type method;
 
        /**
         * name - Name of the method (e.g., "TLS")
@@ -210,6 +207,17 @@ struct eap_method {
         */
        const u8 * (*get_identity)(struct eap_sm *sm, void *priv, size_t *len);
 
+       /**
+        * get_error_code - Get the latest EAP method error code
+        * @priv: Pointer to private EAP method data from eap_method::init()
+        * Returns: An int for the EAP method specific error code if exists or
+        * NO_EAP_METHOD_ERROR otherwise.
+        *
+        * This method is an optional handler that only EAP methods that need to
+        * report their error code need to implement.
+        */
+       int (*get_error_code)(void *priv);
+
        /**
         * free - Free EAP method data
         * @method: Pointer to the method data registered with
@@ -267,9 +275,32 @@ struct eap_method {
         * private data or this function may derive the key.
         */
        u8 * (*get_emsk)(struct eap_sm *sm, void *priv, size_t *len);
+
+       /**
+        * getSessionId - Get EAP method specific Session-Id
+        * @sm: Pointer to EAP state machine allocated with eap_peer_sm_init()
+        * @priv: Pointer to private EAP method data from eap_method::init()
+        * @len: Pointer to a variable to store Session-Id length
+        * Returns: Session-Id or %NULL if not available
+        *
+        * This function can be used to get the Session-Id from the EAP method.
+        * The Session-Id may already be stored in the method-specific private
+        * data or this function may derive the Session-Id.
+        */
+       u8 * (*getSessionId)(struct eap_sm *sm, void *priv, size_t *len);
 };
 
 
+struct eap_erp_key {
+       struct dl_list list;
+       size_t rRK_len;
+       size_t rIK_len;
+       u8 rRK[ERP_MAX_KEY_LEN];
+       u8 rIK[ERP_MAX_KEY_LEN];
+       u32 next_seq;
+       char keyname_nai[];
+};
+
 /**
  * struct eap_sm - EAP state machine data
  */
@@ -281,7 +312,7 @@ struct eap_sm {
                EAP_FAILURE
        } EAP_state;
        /* Long-term local variables */
-       EapType selectedMethod;
+       enum eap_type selectedMethod;
        EapMethodState methodState;
        int lastId;
        struct wpabuf *lastRespData;
@@ -291,7 +322,7 @@ struct eap_sm {
        Boolean rxSuccess;
        Boolean rxFailure;
        int reqId;
-       EapType reqMethod;
+       enum eap_type reqMethod;
        int reqVendor;
        u32 reqVendorMethod;
        Boolean ignore;
@@ -304,36 +335,56 @@ struct eap_sm {
        Boolean eapKeyAvailable; /* peer to lower layer */
        u8 *eapKeyData; /* peer to lower layer */
        size_t eapKeyDataLen; /* peer to lower layer */
+       u8 *eapSessionId; /* peer to lower layer */
+       size_t eapSessionIdLen; /* peer to lower layer */
        const struct eap_method *m; /* selected EAP method */
        /* not defined in RFC 4137 */
        Boolean changed;
        void *eapol_ctx;
-       struct eapol_callbacks *eapol_cb;
+       const struct eapol_callbacks *eapol_cb;
        void *eap_method_priv;
        int init_phase2;
        int fast_reauth;
+       Boolean reauthInit; /* send EAP-Identity/Re-auth */
+       u32 erp_seq;
 
        Boolean rxResp /* LEAP only */;
        Boolean leap_done;
        Boolean peap_done;
-       u8 req_md5[16]; /* MD5() of the current EAP packet */
-       u8 last_md5[16]; /* MD5() of the previously received EAP packet; used
-                         * in duplicate request detection. */
+       u8 req_sha1[20]; /* SHA1() of the current EAP packet */
+       u8 last_sha1[20]; /* SHA1() of the previously received EAP packet; used
+                          * in duplicate request detection. */
 
        void *msg_ctx;
        void *scard_ctx;
        void *ssl_ctx;
+       void *ssl_ctx2;
 
        unsigned int workaround;
 
        /* Optional challenges generated in Phase 1 (EAP-FAST) */
        u8 *peer_challenge, *auth_challenge;
-       int mschapv2_full_key; /* Request full MSCHAPv2 key */
 
        int num_rounds;
+       int num_rounds_short;
        int force_disabled;
 
-       u8 mac_addr[ETH_ALEN];
+       struct wps_context *wps;
+
+       int prev_failure;
+       struct eap_peer_config *last_config;
+
+       struct ext_password_data *ext_pw;
+       struct wpabuf *ext_pw_buf;
+
+       int external_sim;
+
+       unsigned int expected_failure:1;
+       unsigned int ext_cert_check:1;
+       unsigned int waiting_ext_cert_check:1;
+       unsigned int use_machine_cred:1;
+
+       struct dl_list erp_keys; /* struct eap_erp_key */
 };
 
 const u8 * eap_get_config_identity(struct eap_sm *sm, size_t *len);
@@ -344,10 +395,12 @@ const u8 * eap_get_config_otp(struct eap_sm *sm, size_t *len);
 void eap_clear_config_otp(struct eap_sm *sm);
 const char * eap_get_config_phase1(struct eap_sm *sm);
 const char * eap_get_config_phase2(struct eap_sm *sm);
+int eap_get_config_fragment_size(struct eap_sm *sm);
 struct eap_peer_config * eap_get_config(struct eap_sm *sm);
 void eap_set_config_blob(struct eap_sm *sm, struct wpa_config_blob *blob);
 const struct wpa_config_blob *
 eap_get_config_blob(struct eap_sm *sm, const char *name);
 void eap_notify_pending(struct eap_sm *sm);
+int eap_allowed_method(struct eap_sm *sm, int vendor, u32 method);
 
 #endif /* EAP_I_H */