Merge wpa_supplicant and hostapd driver wrapper implementations
[mech_eap.git] / hostapd / wpa_ft.c
index 5a5a443..b3801ff 100644 (file)
@@ -344,7 +344,7 @@ static int wpa_ft_pull_pmk_r1(struct wpa_authenticator *wpa_auth,
 
 
 int wpa_auth_derive_ptk_ft(struct wpa_state_machine *sm, const u8 *pmk,
-                          struct wpa_ptk *ptk)
+                          struct wpa_ptk *ptk, size_t ptk_len)
 {
        u8 pmk_r0[PMK_LEN], pmk_r0_name[WPA_PMK_NAME_LEN];
        u8 pmk_r1[PMK_LEN], pmk_r1_name[WPA_PMK_NAME_LEN];
@@ -377,8 +377,8 @@ int wpa_auth_derive_ptk_ft(struct wpa_state_machine *sm, const u8 *pmk,
 
        wpa_pmk_r1_to_ptk(pmk_r1, sm->SNonce, sm->ANonce, sm->addr,
                          sm->wpa_auth->addr, pmk_r1_name,
-                         (u8 *) ptk, sizeof(*ptk), ptk_name);
-       wpa_hexdump_key(MSG_DEBUG, "FT: PTK", (u8 *) ptk, sizeof(*ptk));
+                         (u8 *) ptk, ptk_len, ptk_name);
+       wpa_hexdump_key(MSG_DEBUG, "FT: PTK", (u8 *) ptk, ptk_len);
        wpa_hexdump(MSG_DEBUG, "FT: PTKName", ptk_name, WPA_PMK_NAME_LEN);
 
        return 0;
@@ -526,6 +526,7 @@ static u8 * wpa_ft_process_rdie(u8 *pos, u8 *end, u8 id, u8 descr_count,
                return pos;
        }
 
+#ifdef NEED_MLME
        if (parse.wmm_tspec) {
                struct wmm_tspec_element *tspec;
                int res;
@@ -561,6 +562,7 @@ static u8 * wpa_ft_process_rdie(u8 *pos, u8 *end, u8 id, u8 descr_count,
                }
                return pos;
        }
+#endif /* NEED_MLME */
 
        wpa_printf(MSG_DEBUG, "FT: No supported resource requested");
        rdie->status_code = host_to_le16(WLAN_STATUS_UNSPECIFIED_FAILURE);
@@ -840,7 +842,7 @@ static int wpa_ft_parse_ies(const u8 *ies, size_t ies_len,
 
 static inline int wpa_auth_set_key(struct wpa_authenticator *wpa_auth,
                                   int vlan_id,
-                                  const char *alg, const u8 *addr, int idx,
+                                  wpa_alg alg, const u8 *addr, int idx,
                                   u8 *key, size_t key_len)
 {
        if (wpa_auth->cb.set_key == NULL)
@@ -852,15 +854,15 @@ static inline int wpa_auth_set_key(struct wpa_authenticator *wpa_auth,
 
 static void wpa_ft_install_ptk(struct wpa_state_machine *sm)
 {
-       char *alg;
+       wpa_alg alg;
        int klen;
 
        /* MLME-SETKEYS.request(PTK) */
        if (sm->pairwise == WPA_CIPHER_TKIP) {
-               alg = "TKIP";
+               alg = WPA_ALG_TKIP;
                klen = 32;
        } else if (sm->pairwise == WPA_CIPHER_CCMP) {
-               alg = "CCMP";
+               alg = WPA_ALG_CCMP;
                klen = 16;
        } else
                return;
@@ -889,7 +891,7 @@ static u16 wpa_ft_process_auth_req(struct wpa_state_machine *sm,
        u8 ptk_name[WPA_PMK_NAME_LEN];
        struct wpa_auth_config *conf;
        struct wpa_ft_ies parse;
-       size_t buflen;
+       size_t buflen, ptk_len;
        int ret;
        u8 *pos, *end;
 
@@ -979,11 +981,12 @@ static u16 wpa_ft_process_auth_req(struct wpa_state_machine *sm,
        wpa_hexdump(MSG_DEBUG, "FT: Generated ANonce",
                    sm->ANonce, WPA_NONCE_LEN);
 
+       ptk_len = sm->pairwise == WPA_CIPHER_CCMP ? 48 : 64;
        wpa_pmk_r1_to_ptk(pmk_r1, sm->SNonce, sm->ANonce, sm->addr,
                          sm->wpa_auth->addr, pmk_r1_name,
-                         (u8 *) &sm->PTK, sizeof(sm->PTK), ptk_name);
+                         (u8 *) &sm->PTK, ptk_len, ptk_name);
        wpa_hexdump_key(MSG_DEBUG, "FT: PTK",
-                       (u8 *) &sm->PTK, sizeof(sm->PTK));
+                       (u8 *) &sm->PTK, ptk_len);
        wpa_hexdump(MSG_DEBUG, "FT: PTKName", ptk_name, WPA_PMK_NAME_LEN);
 
        wpa_ft_install_ptk(sm);