• Home
  • Raw
  • Download

Lines Matching refs:sm

43 int wpa_eapol_key_send(struct wpa_sm *sm, const u8 *kck, size_t kck_len,  in wpa_eapol_key_send()  argument
48 size_t mic_len = wpa_mic_len(sm->key_mgmt); in wpa_eapol_key_send()
50 if (is_zero_ether_addr(dest) && is_zero_ether_addr(sm->bssid)) { in wpa_eapol_key_send()
55 if (wpa_sm_get_bssid(sm, sm->bssid) < 0) { in wpa_eapol_key_send()
56 wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG, in wpa_eapol_key_send()
60 dest = sm->bssid; in wpa_eapol_key_send()
61 wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG, in wpa_eapol_key_send()
68 wpa_eapol_key_mic(kck, kck_len, sm->key_mgmt, ver, msg, msg_len, in wpa_eapol_key_send()
70 wpa_msg(sm->ctx->msg_ctx, MSG_ERROR, in wpa_eapol_key_send()
72 ver, sm->key_mgmt); in wpa_eapol_key_send()
78 ret = wpa_sm_ether_send(sm, dest, proto, msg, msg_len); in wpa_eapol_key_send()
79 eapol_sm_notify_tx_eapol_key(sm->eapol); in wpa_eapol_key_send()
96 void wpa_sm_key_request(struct wpa_sm *sm, int error, int pairwise) in wpa_sm_key_request() argument
104 if (sm->key_mgmt == WPA_KEY_MGMT_OSEN || in wpa_sm_key_request()
105 wpa_key_mgmt_suite_b(sm->key_mgmt)) in wpa_sm_key_request()
107 else if (wpa_key_mgmt_ft(sm->key_mgmt) || in wpa_sm_key_request()
108 wpa_key_mgmt_sha256(sm->key_mgmt)) in wpa_sm_key_request()
110 else if (sm->pairwise_cipher != WPA_CIPHER_TKIP) in wpa_sm_key_request()
115 if (wpa_sm_get_bssid(sm, bssid) < 0) { in wpa_sm_key_request()
116 wpa_msg(sm->ctx->msg_ctx, MSG_WARNING, in wpa_sm_key_request()
121 mic_len = wpa_mic_len(sm->key_mgmt); in wpa_sm_key_request()
123 rbuf = wpa_sm_alloc_eapol(sm, IEEE802_1X_TYPE_EAPOL_KEY, NULL, in wpa_sm_key_request()
129 reply->type = (sm->proto == WPA_PROTO_RSN || in wpa_sm_key_request()
130 sm->proto == WPA_PROTO_OSEN) ? in wpa_sm_key_request()
133 if (sm->ptk_set) in wpa_sm_key_request()
141 os_memcpy(reply->replay_counter, sm->request_counter, in wpa_sm_key_request()
143 inc_byte_array(sm->request_counter, WPA_REPLAY_COUNTER_LEN); in wpa_sm_key_request()
154 wpa_msg(sm->ctx->msg_ctx, MSG_INFO, in wpa_sm_key_request()
157 error, pairwise, sm->ptk_set, (unsigned long) rlen); in wpa_sm_key_request()
158 wpa_eapol_key_send(sm, sm->ptk.kck, sm->ptk.kck_len, ver, bssid, in wpa_sm_key_request()
163 static void wpa_supplicant_key_mgmt_set_pmk(struct wpa_sm *sm) in wpa_supplicant_key_mgmt_set_pmk() argument
166 if (sm->key_mgmt == WPA_KEY_MGMT_FT_IEEE8021X) { in wpa_supplicant_key_mgmt_set_pmk()
167 if (wpa_sm_key_mgmt_set_pmk(sm, sm->xxkey, sm->xxkey_len)) in wpa_supplicant_key_mgmt_set_pmk()
168 wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG, in wpa_supplicant_key_mgmt_set_pmk()
172 if (wpa_sm_key_mgmt_set_pmk(sm, sm->pmk, sm->pmk_len)) in wpa_supplicant_key_mgmt_set_pmk()
173 wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG, in wpa_supplicant_key_mgmt_set_pmk()
181 static int wpa_supplicant_get_pmk(struct wpa_sm *sm, in wpa_supplicant_get_pmk() argument
187 if (pmkid && !sm->cur_pmksa) { in wpa_supplicant_get_pmk()
192 sm->cur_pmksa = pmksa_cache_get(sm->pmksa, src_addr, pmkid, in wpa_supplicant_get_pmk()
194 if (sm->cur_pmksa) { in wpa_supplicant_get_pmk()
195 wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG, in wpa_supplicant_get_pmk()
198 wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG, in wpa_supplicant_get_pmk()
204 if (pmkid && sm->cur_pmksa && in wpa_supplicant_get_pmk()
205 os_memcmp_const(pmkid, sm->cur_pmksa->pmkid, PMKID_LEN) == 0) { in wpa_supplicant_get_pmk()
207 wpa_sm_set_pmk_from_pmksa(sm); in wpa_supplicant_get_pmk()
209 sm->pmk, sm->pmk_len); in wpa_supplicant_get_pmk()
210 eapol_sm_notify_cached(sm->eapol); in wpa_supplicant_get_pmk()
212 sm->xxkey_len = 0; in wpa_supplicant_get_pmk()
214 } else if (wpa_key_mgmt_wpa_ieee8021x(sm->key_mgmt) && sm->eapol) { in wpa_supplicant_get_pmk()
217 if (sm->key_mgmt & WPA_KEY_MGMT_IEEE8021X_SUITE_B_192) in wpa_supplicant_get_pmk()
221 res = eapol_sm_get_key(sm->eapol, sm->pmk, pmk_len); in wpa_supplicant_get_pmk()
228 res = eapol_sm_get_key(sm->eapol, sm->pmk, 16); in wpa_supplicant_get_pmk()
234 if (eapol_sm_get_key(sm->eapol, buf, 2 * PMK_LEN) == 0) in wpa_supplicant_get_pmk()
236 os_memcpy(sm->xxkey, buf + PMK_LEN, PMK_LEN); in wpa_supplicant_get_pmk()
237 sm->xxkey_len = PMK_LEN; in wpa_supplicant_get_pmk()
245 "machines", sm->pmk, pmk_len); in wpa_supplicant_get_pmk()
246 sm->pmk_len = pmk_len; in wpa_supplicant_get_pmk()
247 wpa_supplicant_key_mgmt_set_pmk(sm); in wpa_supplicant_get_pmk()
248 if (sm->proto == WPA_PROTO_RSN && in wpa_supplicant_get_pmk()
249 !wpa_key_mgmt_suite_b(sm->key_mgmt) && in wpa_supplicant_get_pmk()
250 !wpa_key_mgmt_ft(sm->key_mgmt)) { in wpa_supplicant_get_pmk()
251 sa = pmksa_cache_add(sm->pmksa, in wpa_supplicant_get_pmk()
252 sm->pmk, pmk_len, NULL, in wpa_supplicant_get_pmk()
254 src_addr, sm->own_addr, in wpa_supplicant_get_pmk()
255 sm->network_ctx, in wpa_supplicant_get_pmk()
256 sm->key_mgmt); in wpa_supplicant_get_pmk()
258 if (!sm->cur_pmksa && pmkid && in wpa_supplicant_get_pmk()
259 pmksa_cache_get(sm->pmksa, src_addr, pmkid, NULL)) in wpa_supplicant_get_pmk()
261 wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG, in wpa_supplicant_get_pmk()
265 } else if (sa && !sm->cur_pmksa && pmkid) { in wpa_supplicant_get_pmk()
273 wpa_msg(sm->ctx->msg_ctx, MSG_INFO, in wpa_supplicant_get_pmk()
278 if (!sm->cur_pmksa) in wpa_supplicant_get_pmk()
279 sm->cur_pmksa = sa; in wpa_supplicant_get_pmk()
281 wpa_msg(sm->ctx->msg_ctx, MSG_WARNING, in wpa_supplicant_get_pmk()
285 if (sm->cur_pmksa) { in wpa_supplicant_get_pmk()
286 wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG, in wpa_supplicant_get_pmk()
289 sm->cur_pmksa = NULL; in wpa_supplicant_get_pmk()
297 if (abort_cached && wpa_key_mgmt_wpa_ieee8021x(sm->key_mgmt) && in wpa_supplicant_get_pmk()
298 !wpa_key_mgmt_suite_b(sm->key_mgmt) && in wpa_supplicant_get_pmk()
299 !wpa_key_mgmt_ft(sm->key_mgmt) && sm->key_mgmt != WPA_KEY_MGMT_OSEN) in wpa_supplicant_get_pmk()
305 wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG, in wpa_supplicant_get_pmk()
308 buf = wpa_sm_alloc_eapol(sm, IEEE802_1X_TYPE_EAPOL_START, in wpa_supplicant_get_pmk()
311 wpa_sm_ether_send(sm, sm->bssid, ETH_P_EAPOL, in wpa_supplicant_get_pmk()
336 int wpa_supplicant_send_2_of_4(struct wpa_sm *sm, const unsigned char *dst, in wpa_supplicant_send_2_of_4() argument
349 wpa_msg(sm->ctx->msg_ctx, MSG_WARNING, "WPA: No wpa_ie set - " in wpa_supplicant_send_2_of_4()
355 if (wpa_key_mgmt_ft(sm->key_mgmt)) { in wpa_supplicant_send_2_of_4()
363 sm->assoc_resp_ies_len); in wpa_supplicant_send_2_of_4()
368 sm->pmk_r1_name); in wpa_supplicant_send_2_of_4()
374 if (sm->assoc_resp_ies) { in wpa_supplicant_send_2_of_4()
375 os_memcpy(rsn_ie_buf + wpa_ie_len, sm->assoc_resp_ies, in wpa_supplicant_send_2_of_4()
376 sm->assoc_resp_ies_len); in wpa_supplicant_send_2_of_4()
377 wpa_ie_len += sm->assoc_resp_ies_len; in wpa_supplicant_send_2_of_4()
386 mic_len = wpa_mic_len(sm->key_mgmt); in wpa_supplicant_send_2_of_4()
388 rbuf = wpa_sm_alloc_eapol(sm, IEEE802_1X_TYPE_EAPOL_KEY, in wpa_supplicant_send_2_of_4()
397 reply->type = (sm->proto == WPA_PROTO_RSN || in wpa_supplicant_send_2_of_4()
398 sm->proto == WPA_PROTO_OSEN) ? in wpa_supplicant_send_2_of_4()
402 if (sm->proto == WPA_PROTO_RSN || sm->proto == WPA_PROTO_OSEN) in wpa_supplicant_send_2_of_4()
423 wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG, "WPA: Sending EAPOL-Key 2/4"); in wpa_supplicant_send_2_of_4()
424 return wpa_eapol_key_send(sm, ptk->kck, ptk->kck_len, ver, dst, in wpa_supplicant_send_2_of_4()
429 static int wpa_derive_ptk(struct wpa_sm *sm, const unsigned char *src_addr, in wpa_derive_ptk() argument
433 if (wpa_key_mgmt_ft(sm->key_mgmt)) in wpa_derive_ptk()
434 return wpa_derive_ptk_ft(sm, src_addr, key, ptk); in wpa_derive_ptk()
437 return wpa_pmk_to_ptk(sm->pmk, sm->pmk_len, "Pairwise key expansion", in wpa_derive_ptk()
438 sm->own_addr, sm->bssid, sm->snonce, in wpa_derive_ptk()
439 key->key_nonce, ptk, sm->key_mgmt, in wpa_derive_ptk()
440 sm->pairwise_cipher); in wpa_derive_ptk()
444 static void wpa_supplicant_process_1_of_4(struct wpa_sm *sm, in wpa_supplicant_process_1_of_4() argument
456 if (wpa_sm_get_network_ctx(sm) == NULL) { in wpa_supplicant_process_1_of_4()
457 wpa_msg(sm->ctx->msg_ctx, MSG_WARNING, "WPA: No SSID info " in wpa_supplicant_process_1_of_4()
462 wpa_sm_set_state(sm, WPA_4WAY_HANDSHAKE); in wpa_supplicant_process_1_of_4()
463 wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG, "WPA: RX message 1 of 4-Way " in wpa_supplicant_process_1_of_4()
468 if (sm->proto == WPA_PROTO_RSN || sm->proto == WPA_PROTO_OSEN) { in wpa_supplicant_process_1_of_4()
480 res = wpa_supplicant_get_pmk(sm, src_addr, ie.pmkid); in wpa_supplicant_process_1_of_4()
482 wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG, "RSN: Do not reply to " in wpa_supplicant_process_1_of_4()
489 if (sm->renew_snonce) { in wpa_supplicant_process_1_of_4()
490 if (random_get_bytes(sm->snonce, WPA_NONCE_LEN)) { in wpa_supplicant_process_1_of_4()
491 wpa_msg(sm->ctx->msg_ctx, MSG_WARNING, in wpa_supplicant_process_1_of_4()
495 sm->renew_snonce = 0; in wpa_supplicant_process_1_of_4()
497 sm->snonce, WPA_NONCE_LEN); in wpa_supplicant_process_1_of_4()
502 ptk = &sm->tptk; in wpa_supplicant_process_1_of_4()
503 wpa_derive_ptk(sm, src_addr, key, ptk); in wpa_supplicant_process_1_of_4()
504 if (sm->pairwise_cipher == WPA_CIPHER_TKIP) { in wpa_supplicant_process_1_of_4()
512 sm->tptk_set = 1; in wpa_supplicant_process_1_of_4()
513 sm->tk_to_set = 1; in wpa_supplicant_process_1_of_4()
515 kde = sm->assoc_wpa_ie; in wpa_supplicant_process_1_of_4()
516 kde_len = sm->assoc_wpa_ie_len; in wpa_supplicant_process_1_of_4()
519 if (sm->p2p) { in wpa_supplicant_process_1_of_4()
538 if (wpa_supplicant_send_2_of_4(sm, sm->bssid, key, ver, sm->snonce, in wpa_supplicant_process_1_of_4()
543 os_memcpy(sm->anonce, key->key_nonce, WPA_NONCE_LEN); in wpa_supplicant_process_1_of_4()
548 wpa_sm_deauthenticate(sm, WLAN_REASON_UNSPECIFIED); in wpa_supplicant_process_1_of_4()
554 struct wpa_sm *sm = eloop_ctx; in wpa_sm_start_preauth() local
555 rsn_preauth_candidate_process(sm); in wpa_sm_start_preauth()
559 static void wpa_supplicant_key_neg_complete(struct wpa_sm *sm, in wpa_supplicant_key_neg_complete() argument
562 wpa_msg(sm->ctx->msg_ctx, MSG_INFO, in wpa_supplicant_key_neg_complete()
565 wpa_cipher_txt(sm->pairwise_cipher), in wpa_supplicant_key_neg_complete()
566 wpa_cipher_txt(sm->group_cipher)); in wpa_supplicant_key_neg_complete()
567 wpa_sm_cancel_auth_timeout(sm); in wpa_supplicant_key_neg_complete()
568 wpa_sm_set_state(sm, WPA_COMPLETED); in wpa_supplicant_key_neg_complete()
572 sm, addr, MLME_SETPROTECTION_PROTECT_TYPE_RX_TX, in wpa_supplicant_key_neg_complete()
574 eapol_sm_notify_portValid(sm->eapol, TRUE); in wpa_supplicant_key_neg_complete()
575 if (wpa_key_mgmt_wpa_psk(sm->key_mgmt)) in wpa_supplicant_key_neg_complete()
576 eapol_sm_notify_eap_success(sm->eapol, TRUE); in wpa_supplicant_key_neg_complete()
584 eloop_register_timeout(1, 0, wpa_sm_start_preauth, sm, NULL); in wpa_supplicant_key_neg_complete()
587 if (sm->cur_pmksa && sm->cur_pmksa->opportunistic) { in wpa_supplicant_key_neg_complete()
588 wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG, in wpa_supplicant_key_neg_complete()
591 sm->cur_pmksa->opportunistic = 0; in wpa_supplicant_key_neg_complete()
595 if (wpa_key_mgmt_ft(sm->key_mgmt)) { in wpa_supplicant_key_neg_complete()
597 wpa_ft_prepare_auth_request(sm, NULL); in wpa_supplicant_key_neg_complete()
605 struct wpa_sm *sm = eloop_ctx; in wpa_sm_rekey_ptk() local
606 wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG, "WPA: Request PTK rekeying"); in wpa_sm_rekey_ptk()
607 wpa_sm_key_request(sm, 0, 1); in wpa_sm_rekey_ptk()
611 static int wpa_supplicant_install_ptk(struct wpa_sm *sm, in wpa_supplicant_install_ptk() argument
618 if (!sm->tk_to_set) { in wpa_supplicant_install_ptk()
619 wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG, in wpa_supplicant_install_ptk()
624 wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG, in wpa_supplicant_install_ptk()
627 if (sm->pairwise_cipher == WPA_CIPHER_NONE) { in wpa_supplicant_install_ptk()
628 wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG, "WPA: Pairwise Cipher " in wpa_supplicant_install_ptk()
633 if (!wpa_cipher_valid_pairwise(sm->pairwise_cipher)) { in wpa_supplicant_install_ptk()
634 wpa_msg(sm->ctx->msg_ctx, MSG_WARNING, in wpa_supplicant_install_ptk()
636 sm->pairwise_cipher); in wpa_supplicant_install_ptk()
640 alg = wpa_cipher_to_alg(sm->pairwise_cipher); in wpa_supplicant_install_ptk()
641 keylen = wpa_cipher_key_len(sm->pairwise_cipher); in wpa_supplicant_install_ptk()
642 rsclen = wpa_cipher_rsc_len(sm->pairwise_cipher); in wpa_supplicant_install_ptk()
644 if (sm->proto == WPA_PROTO_RSN || sm->proto == WPA_PROTO_OSEN) { in wpa_supplicant_install_ptk()
651 if (wpa_sm_set_key(sm, alg, sm->bssid, 0, 1, key_rsc, rsclen, in wpa_supplicant_install_ptk()
652 sm->ptk.tk, keylen) < 0) { in wpa_supplicant_install_ptk()
653 wpa_msg(sm->ctx->msg_ctx, MSG_WARNING, in wpa_supplicant_install_ptk()
656 alg, keylen, MAC2STR(sm->bssid)); in wpa_supplicant_install_ptk()
661 os_memset(sm->ptk.tk, 0, WPA_TK_MAX_LEN); in wpa_supplicant_install_ptk()
662 sm->tk_to_set = 0; in wpa_supplicant_install_ptk()
664 if (sm->wpa_ptk_rekey) { in wpa_supplicant_install_ptk()
665 eloop_cancel_timeout(wpa_sm_rekey_ptk, sm, NULL); in wpa_supplicant_install_ptk()
666 eloop_register_timeout(sm->wpa_ptk_rekey, 0, wpa_sm_rekey_ptk, in wpa_supplicant_install_ptk()
667 sm, NULL); in wpa_supplicant_install_ptk()
674 static int wpa_supplicant_check_group_cipher(struct wpa_sm *sm, in wpa_supplicant_check_group_cipher() argument
684 wpa_msg(sm->ctx->msg_ctx, MSG_WARNING, in wpa_supplicant_check_group_cipher()
693 wpa_msg(sm->ctx->msg_ctx, MSG_WARNING, in wpa_supplicant_check_group_cipher()
710 static int wpa_supplicant_install_gtk(struct wpa_sm *sm, in wpa_supplicant_install_gtk() argument
718 wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG, in wpa_supplicant_install_gtk()
722 if (sm->group_cipher == WPA_CIPHER_TKIP) { in wpa_supplicant_install_gtk()
729 if (sm->pairwise_cipher == WPA_CIPHER_NONE) { in wpa_supplicant_install_gtk()
730 if (wpa_sm_set_key(sm, gd->alg, NULL, in wpa_supplicant_install_gtk()
733 wpa_msg(sm->ctx->msg_ctx, MSG_WARNING, in wpa_supplicant_install_gtk()
739 } else if (wpa_sm_set_key(sm, gd->alg, broadcast_ether_addr, in wpa_supplicant_install_gtk()
742 wpa_msg(sm->ctx->msg_ctx, MSG_WARNING, in wpa_supplicant_install_gtk()
755 static int wpa_supplicant_gtk_tx_bit_workaround(const struct wpa_sm *sm, in wpa_supplicant_gtk_tx_bit_workaround() argument
758 if (tx && sm->pairwise_cipher != WPA_CIPHER_NONE) { in wpa_supplicant_gtk_tx_bit_workaround()
764 wpa_msg(sm->ctx->msg_ctx, MSG_INFO, in wpa_supplicant_gtk_tx_bit_workaround()
773 static int wpa_supplicant_rsc_relaxation(const struct wpa_sm *sm, in wpa_supplicant_rsc_relaxation() argument
778 if (!sm->wpa_rsc_relaxation) in wpa_supplicant_rsc_relaxation()
781 rsclen = wpa_cipher_rsc_len(sm->group_cipher); in wpa_supplicant_rsc_relaxation()
791 wpa_msg(sm->ctx->msg_ctx, MSG_WARNING, in wpa_supplicant_rsc_relaxation()
803 static int wpa_supplicant_pairwise_gtk(struct wpa_sm *sm, in wpa_supplicant_pairwise_gtk() argument
827 gd.tx = wpa_supplicant_gtk_tx_bit_workaround(sm, in wpa_supplicant_pairwise_gtk()
836 if (wpa_supplicant_rsc_relaxation(sm, key->key_rsc)) in wpa_supplicant_pairwise_gtk()
839 if (sm->group_cipher != WPA_CIPHER_GTK_NOT_USED && in wpa_supplicant_pairwise_gtk()
840 (wpa_supplicant_check_group_cipher(sm, sm->group_cipher, in wpa_supplicant_pairwise_gtk()
843 wpa_supplicant_install_gtk(sm, &gd, key_rsc))) { in wpa_supplicant_pairwise_gtk()
844 wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG, in wpa_supplicant_pairwise_gtk()
851 wpa_supplicant_key_neg_complete(sm, sm->bssid, in wpa_supplicant_pairwise_gtk()
857 static int ieee80211w_set_keys(struct wpa_sm *sm, in ieee80211w_set_keys() argument
861 if (!wpa_cipher_valid_mgmt_group(sm->mgmt_group_cipher)) in ieee80211w_set_keys()
868 len = wpa_cipher_key_len(sm->mgmt_group_cipher); in ieee80211w_set_keys()
873 wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG, "WPA: IGTK keyid %d " in ieee80211w_set_keys()
879 wpa_msg(sm->ctx->msg_ctx, MSG_WARNING, in ieee80211w_set_keys()
883 if (wpa_sm_set_key(sm, wpa_cipher_to_alg(sm->mgmt_group_cipher), in ieee80211w_set_keys()
887 wpa_msg(sm->ctx->msg_ctx, MSG_WARNING, in ieee80211w_set_keys()
900 static void wpa_report_ie_mismatch(struct wpa_sm *sm, in wpa_report_ie_mismatch() argument
905 wpa_msg(sm->ctx->msg_ctx, MSG_WARNING, "WPA: %s (src=" MACSTR ")", in wpa_report_ie_mismatch()
908 if (sm->ap_wpa_ie) { in wpa_report_ie_mismatch()
910 sm->ap_wpa_ie, sm->ap_wpa_ie_len); in wpa_report_ie_mismatch()
913 if (!sm->ap_wpa_ie) { in wpa_report_ie_mismatch()
914 wpa_msg(sm->ctx->msg_ctx, MSG_INFO, in wpa_report_ie_mismatch()
921 if (sm->ap_rsn_ie) { in wpa_report_ie_mismatch()
923 sm->ap_rsn_ie, sm->ap_rsn_ie_len); in wpa_report_ie_mismatch()
926 if (!sm->ap_rsn_ie) { in wpa_report_ie_mismatch()
927 wpa_msg(sm->ctx->msg_ctx, MSG_INFO, in wpa_report_ie_mismatch()
934 wpa_sm_deauthenticate(sm, WLAN_REASON_IE_IN_4WAY_DIFFERS); in wpa_report_ie_mismatch()
940 static int ft_validate_mdie(struct wpa_sm *sm, in ft_validate_mdie() argument
949 os_memcmp(mdie->mobility_domain, sm->mobility_domain, in ft_validate_mdie()
951 wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG, "FT: MDIE in msg 3/4 did " in ft_validate_mdie()
959 wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG, "FT: MDIE mismatch"); in ft_validate_mdie()
971 static int ft_validate_ftie(struct wpa_sm *sm, in ft_validate_ftie() argument
977 wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG, in ft_validate_ftie()
987 wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG, "FT: FTIE mismatch"); in ft_validate_ftie()
999 static int ft_validate_rsnie(struct wpa_sm *sm, in ft_validate_rsnie() argument
1014 wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG, "FT: No PMKR1Name in " in ft_validate_rsnie()
1019 if (os_memcmp_const(rsn.pmkid, sm->pmk_r1_name, WPA_PMK_NAME_LEN) != 0) in ft_validate_rsnie()
1021 wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG, in ft_validate_rsnie()
1027 sm->pmk_r1_name, WPA_PMK_NAME_LEN); in ft_validate_rsnie()
1035 static int wpa_supplicant_validate_ie_ft(struct wpa_sm *sm, in wpa_supplicant_validate_ie_ft() argument
1041 if (sm->assoc_resp_ies) { in wpa_supplicant_validate_ie_ft()
1042 pos = sm->assoc_resp_ies; in wpa_supplicant_validate_ie_ft()
1043 end = pos + sm->assoc_resp_ies_len; in wpa_supplicant_validate_ie_ft()
1059 if (ft_validate_mdie(sm, src_addr, ie, mdie) < 0 || in wpa_supplicant_validate_ie_ft()
1060 ft_validate_ftie(sm, src_addr, ie, ftie) < 0 || in wpa_supplicant_validate_ie_ft()
1061 ft_validate_rsnie(sm, src_addr, ie) < 0) in wpa_supplicant_validate_ie_ft()
1070 static int wpa_supplicant_validate_ie(struct wpa_sm *sm, in wpa_supplicant_validate_ie() argument
1074 if (sm->ap_wpa_ie == NULL && sm->ap_rsn_ie == NULL) { in wpa_supplicant_validate_ie()
1075 wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG, in wpa_supplicant_validate_ie()
1078 if (wpa_sm_get_beacon_ie(sm) < 0) { in wpa_supplicant_validate_ie()
1079 wpa_msg(sm->ctx->msg_ctx, MSG_WARNING, in wpa_supplicant_validate_ie()
1083 wpa_msg(sm->ctx->msg_ctx, MSG_DEBUG, in wpa_supplicant_validate_ie()
1090 (sm->ap_wpa_ie || sm->ap_rsn_ie)) { in wpa_supplicant_validate_ie()
1091 wpa_report_ie_mismatch(sm, "IE in 3/4 msg does not match " in wpa_supplicant_validate_ie()
1098 if ((ie->wpa_ie && sm->ap_wpa_ie && in wpa_supplicant_validate_ie()
1099 (ie->wpa_ie_len != sm->ap_wpa_ie_len || in wpa_supplicant_validate_ie()
1100 os_memcmp(ie->wpa_ie, sm->ap_wpa_ie, ie->wpa_ie_len) != 0)) || in wpa_supplicant_validate_ie()
1101 (ie->rsn_ie && sm->ap_rsn_ie && in wpa_supplicant_validate_ie()
1102 wpa_compare_rsn_ie(wpa_key_mgmt_ft(sm->key_mgmt), in wpa_supplicant_validate_ie()
1103 sm->ap_rsn_ie, sm->ap_rsn_ie_len, in wpa_supplicant_validate_ie()
1105 wpa_report_ie_mismatch(sm, "IE in 3/4 msg does not match " in wpa_supplicant_validate_ie()
1112 if (sm->proto == WPA_PROTO_WPA && in wpa_supplicant_validate_ie()
1113 ie->rsn_ie && sm->ap_rsn_ie == NULL && sm->rsn_enabled) { in wpa_supplicant_validate_ie()
1114 wpa_report_ie_mismatch(sm, "Possible downgrade attack " in wpa_supplicant_validate_ie()
1124 if (wpa_key_mgmt_ft(sm->key_mgmt) && in wpa_supplicant_validate_ie()
1125 wpa_supplicant_validate_ie_ft(sm, src_addr, ie) < 0) in wpa_supplicant_validate_ie()
1143 int wpa_supplicant_send_4_of_4(struct wpa_sm *sm, const unsigned char *dst, in wpa_supplicant_send_4_of_4() argument
1153 mic_len = wpa_mic_len(sm->key_mgmt); in wpa_supplicant_send_4_of_4()
1155 rbuf = wpa_sm_alloc_eapol(sm, IEEE802_1X_TYPE_EAPOL_KEY, NULL, in wpa_supplicant_send_4_of_4()
1161 reply->type = (sm->proto == WPA_PROTO_RSN || in wpa_supplicant_send_4_of_4()
1162 sm->proto == WPA_PROTO_OSEN) ? in wpa_supplicant_send_4_of_4()
1167 if (sm->proto == WPA_PROTO_RSN || sm->proto == WPA_PROTO_OSEN) in wpa_supplicant_send_4_of_4()
1180 wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG, "WPA: Sending EAPOL-Key 4/4"); in wpa_supplicant_send_4_of_4()
1181 return wpa_eapol_key_send(sm, ptk->kck, ptk->kck_len, ver, dst, in wpa_supplicant_send_4_of_4()
1186 static void wpa_supplicant_process_3_of_4(struct wpa_sm *sm, in wpa_supplicant_process_3_of_4() argument
1194 wpa_sm_set_state(sm, WPA_4WAY_HANDSHAKE); in wpa_supplicant_process_3_of_4()
1195 wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG, "WPA: RX message 3 of 4-Way " in wpa_supplicant_process_3_of_4()
1196 "Handshake from " MACSTR " (ver=%d)", MAC2STR(sm->bssid), ver); in wpa_supplicant_process_3_of_4()
1204 wpa_msg(sm->ctx->msg_ctx, MSG_WARNING, in wpa_supplicant_process_3_of_4()
1210 wpa_msg(sm->ctx->msg_ctx, MSG_WARNING, in wpa_supplicant_process_3_of_4()
1216 wpa_cipher_valid_mgmt_group(sm->mgmt_group_cipher) && in wpa_supplicant_process_3_of_4()
1218 (unsigned int) wpa_cipher_key_len(sm->mgmt_group_cipher)) { in wpa_supplicant_process_3_of_4()
1219 wpa_msg(sm->ctx->msg_ctx, MSG_WARNING, in wpa_supplicant_process_3_of_4()
1226 if (wpa_supplicant_validate_ie(sm, sm->bssid, &ie) < 0) in wpa_supplicant_process_3_of_4()
1229 if (os_memcmp(sm->anonce, key->key_nonce, WPA_NONCE_LEN) != 0) { in wpa_supplicant_process_3_of_4()
1230 wpa_msg(sm->ctx->msg_ctx, MSG_WARNING, in wpa_supplicant_process_3_of_4()
1233 MACSTR ")", MAC2STR(sm->bssid)); in wpa_supplicant_process_3_of_4()
1238 if (keylen != wpa_cipher_key_len(sm->pairwise_cipher)) { in wpa_supplicant_process_3_of_4()
1239 wpa_msg(sm->ctx->msg_ctx, MSG_WARNING, in wpa_supplicant_process_3_of_4()
1241 ")", wpa_cipher_txt(sm->pairwise_cipher), keylen, in wpa_supplicant_process_3_of_4()
1242 MAC2STR(sm->bssid)); in wpa_supplicant_process_3_of_4()
1248 os_memcpy(sm->p2p_ip_addr, ie.ip_addr_alloc, 3 * 4); in wpa_supplicant_process_3_of_4()
1250 sm->p2p_ip_addr, sizeof(sm->p2p_ip_addr)); in wpa_supplicant_process_3_of_4()
1254 if (wpa_supplicant_send_4_of_4(sm, sm->bssid, key, ver, key_info, in wpa_supplicant_process_3_of_4()
1255 &sm->ptk) < 0) { in wpa_supplicant_process_3_of_4()
1262 sm->renew_snonce = 1; in wpa_supplicant_process_3_of_4()
1265 if (wpa_supplicant_install_ptk(sm, key)) in wpa_supplicant_process_3_of_4()
1271 sm, sm->bssid, MLME_SETPROTECTION_PROTECT_TYPE_RX, in wpa_supplicant_process_3_of_4()
1273 eapol_sm_notify_portValid(sm->eapol, TRUE); in wpa_supplicant_process_3_of_4()
1275 wpa_sm_set_state(sm, WPA_GROUP_HANDSHAKE); in wpa_supplicant_process_3_of_4()
1277 if (sm->group_cipher == WPA_CIPHER_GTK_NOT_USED) { in wpa_supplicant_process_3_of_4()
1278 wpa_supplicant_key_neg_complete(sm, sm->bssid, in wpa_supplicant_process_3_of_4()
1281 wpa_supplicant_pairwise_gtk(sm, key, in wpa_supplicant_process_3_of_4()
1283 wpa_msg(sm->ctx->msg_ctx, MSG_INFO, in wpa_supplicant_process_3_of_4()
1288 if (ieee80211w_set_keys(sm, &ie) < 0) { in wpa_supplicant_process_3_of_4()
1289 wpa_msg(sm->ctx->msg_ctx, MSG_INFO, in wpa_supplicant_process_3_of_4()
1295 wpa_sm_set_rekey_offload(sm); in wpa_supplicant_process_3_of_4()
1297 if (sm->proto == WPA_PROTO_RSN && wpa_key_mgmt_suite_b(sm->key_mgmt)) { in wpa_supplicant_process_3_of_4()
1300 sa = pmksa_cache_add(sm->pmksa, sm->pmk, sm->pmk_len, NULL, in wpa_supplicant_process_3_of_4()
1301 sm->ptk.kck, sm->ptk.kck_len, in wpa_supplicant_process_3_of_4()
1302 sm->bssid, sm->own_addr, in wpa_supplicant_process_3_of_4()
1303 sm->network_ctx, sm->key_mgmt); in wpa_supplicant_process_3_of_4()
1304 if (!sm->cur_pmksa) in wpa_supplicant_process_3_of_4()
1305 sm->cur_pmksa = sa; in wpa_supplicant_process_3_of_4()
1308 sm->msg_3_of_4_ok = 1; in wpa_supplicant_process_3_of_4()
1312 wpa_sm_deauthenticate(sm, WLAN_REASON_UNSPECIFIED); in wpa_supplicant_process_3_of_4()
1316 static int wpa_supplicant_process_1_of_2_rsn(struct wpa_sm *sm, in wpa_supplicant_process_1_of_2_rsn() argument
1329 wpa_msg(sm->ctx->msg_ctx, MSG_WARNING, in wpa_supplicant_process_1_of_2_rsn()
1334 wpa_msg(sm->ctx->msg_ctx, MSG_INFO, in wpa_supplicant_process_1_of_2_rsn()
1340 if (wpa_supplicant_check_group_cipher(sm, sm->group_cipher, in wpa_supplicant_process_1_of_2_rsn()
1348 gd->tx = wpa_supplicant_gtk_tx_bit_workaround(sm, in wpa_supplicant_process_1_of_2_rsn()
1351 wpa_msg(sm->ctx->msg_ctx, MSG_INFO, in wpa_supplicant_process_1_of_2_rsn()
1358 if (ieee80211w_set_keys(sm, &ie) < 0) in wpa_supplicant_process_1_of_2_rsn()
1359 wpa_msg(sm->ctx->msg_ctx, MSG_INFO, in wpa_supplicant_process_1_of_2_rsn()
1366 static int wpa_supplicant_process_1_of_2_wpa(struct wpa_sm *sm, in wpa_supplicant_process_1_of_2_wpa() argument
1379 wpa_msg(sm->ctx->msg_ctx, MSG_INFO, in wpa_supplicant_process_1_of_2_wpa()
1388 wpa_supplicant_check_group_cipher(sm, sm->group_cipher, in wpa_supplicant_process_1_of_2_wpa()
1396 if (ver == WPA_KEY_INFO_TYPE_HMAC_MD5_RC4 && sm->ptk.kek_len == 16) { in wpa_supplicant_process_1_of_2_wpa()
1398 wpa_msg(sm->ctx->msg_ctx, MSG_WARNING, in wpa_supplicant_process_1_of_2_wpa()
1404 wpa_msg(sm->ctx->msg_ctx, MSG_WARNING, in wpa_supplicant_process_1_of_2_wpa()
1410 os_memcpy(ek + 16, sm->ptk.kek, sm->ptk.kek_len); in wpa_supplicant_process_1_of_2_wpa()
1414 wpa_msg(sm->ctx->msg_ctx, MSG_ERROR, in wpa_supplicant_process_1_of_2_wpa()
1422 wpa_msg(sm->ctx->msg_ctx, MSG_WARNING, in wpa_supplicant_process_1_of_2_wpa()
1428 wpa_msg(sm->ctx->msg_ctx, MSG_WARNING, in wpa_supplicant_process_1_of_2_wpa()
1435 if (aes_unwrap(sm->ptk.kek, sm->ptk.kek_len, maxkeylen / 8, in wpa_supplicant_process_1_of_2_wpa()
1437 wpa_msg(sm->ctx->msg_ctx, MSG_WARNING, in wpa_supplicant_process_1_of_2_wpa()
1443 wpa_msg(sm->ctx->msg_ctx, MSG_WARNING, in wpa_supplicant_process_1_of_2_wpa()
1448 sm, !!(key_info & WPA_KEY_INFO_TXRX)); in wpa_supplicant_process_1_of_2_wpa()
1453 static int wpa_supplicant_send_2_of_2(struct wpa_sm *sm, in wpa_supplicant_send_2_of_2() argument
1462 mic_len = wpa_mic_len(sm->key_mgmt); in wpa_supplicant_send_2_of_2()
1464 rbuf = wpa_sm_alloc_eapol(sm, IEEE802_1X_TYPE_EAPOL_KEY, NULL, in wpa_supplicant_send_2_of_2()
1470 reply->type = (sm->proto == WPA_PROTO_RSN || in wpa_supplicant_send_2_of_2()
1471 sm->proto == WPA_PROTO_OSEN) ? in wpa_supplicant_send_2_of_2()
1476 if (sm->proto == WPA_PROTO_RSN || sm->proto == WPA_PROTO_OSEN) in wpa_supplicant_send_2_of_2()
1489 wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG, "WPA: Sending EAPOL-Key 2/2"); in wpa_supplicant_send_2_of_2()
1490 return wpa_eapol_key_send(sm, sm->ptk.kck, sm->ptk.kck_len, ver, in wpa_supplicant_send_2_of_2()
1491 sm->bssid, ETH_P_EAPOL, rbuf, rlen, key_mic); in wpa_supplicant_send_2_of_2()
1495 static void wpa_supplicant_process_1_of_2(struct wpa_sm *sm, in wpa_supplicant_process_1_of_2() argument
1506 if (!sm->msg_3_of_4_ok) { in wpa_supplicant_process_1_of_2()
1507 wpa_msg(sm->ctx->msg_ctx, MSG_INFO, in wpa_supplicant_process_1_of_2()
1514 rekey = wpa_sm_get_state(sm) == WPA_COMPLETED; in wpa_supplicant_process_1_of_2()
1515 wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG, "WPA: RX message 1 of Group Key " in wpa_supplicant_process_1_of_2()
1520 if (sm->proto == WPA_PROTO_RSN || sm->proto == WPA_PROTO_OSEN) { in wpa_supplicant_process_1_of_2()
1521 ret = wpa_supplicant_process_1_of_2_rsn(sm, key_data, in wpa_supplicant_process_1_of_2()
1525 ret = wpa_supplicant_process_1_of_2_wpa(sm, key, key_data, in wpa_supplicant_process_1_of_2()
1530 wpa_sm_set_state(sm, WPA_GROUP_HANDSHAKE); in wpa_supplicant_process_1_of_2()
1536 if (wpa_supplicant_rsc_relaxation(sm, key->key_rsc)) in wpa_supplicant_process_1_of_2()
1539 if (wpa_supplicant_install_gtk(sm, &gd, key_rsc) || in wpa_supplicant_process_1_of_2()
1540 wpa_supplicant_send_2_of_2(sm, key, ver, key_info) < 0) in wpa_supplicant_process_1_of_2()
1545 wpa_msg(sm->ctx->msg_ctx, MSG_INFO, "WPA: Group rekeying " in wpa_supplicant_process_1_of_2()
1547 MAC2STR(sm->bssid), wpa_cipher_txt(sm->group_cipher)); in wpa_supplicant_process_1_of_2()
1548 wpa_sm_cancel_auth_timeout(sm); in wpa_supplicant_process_1_of_2()
1549 wpa_sm_set_state(sm, WPA_COMPLETED); in wpa_supplicant_process_1_of_2()
1551 wpa_supplicant_key_neg_complete(sm, sm->bssid, in wpa_supplicant_process_1_of_2()
1556 wpa_sm_set_rekey_offload(sm); in wpa_supplicant_process_1_of_2()
1562 wpa_sm_deauthenticate(sm, WLAN_REASON_UNSPECIFIED); in wpa_supplicant_process_1_of_2()
1566 static int wpa_supplicant_verify_eapol_key_mic(struct wpa_sm *sm, in wpa_supplicant_verify_eapol_key_mic() argument
1573 size_t mic_len = wpa_mic_len(sm->key_mgmt); in wpa_supplicant_verify_eapol_key_mic()
1576 if (sm->tptk_set) { in wpa_supplicant_verify_eapol_key_mic()
1578 wpa_eapol_key_mic(sm->tptk.kck, sm->tptk.kck_len, sm->key_mgmt, in wpa_supplicant_verify_eapol_key_mic()
1581 wpa_msg(sm->ctx->msg_ctx, MSG_WARNING, in wpa_supplicant_verify_eapol_key_mic()
1586 sm->tptk_set = 0; in wpa_supplicant_verify_eapol_key_mic()
1587 sm->ptk_set = 1; in wpa_supplicant_verify_eapol_key_mic()
1588 os_memcpy(&sm->ptk, &sm->tptk, sizeof(sm->ptk)); in wpa_supplicant_verify_eapol_key_mic()
1589 os_memset(&sm->tptk, 0, sizeof(sm->tptk)); in wpa_supplicant_verify_eapol_key_mic()
1593 if (!ok && sm->ptk_set) { in wpa_supplicant_verify_eapol_key_mic()
1595 wpa_eapol_key_mic(sm->ptk.kck, sm->ptk.kck_len, sm->key_mgmt, in wpa_supplicant_verify_eapol_key_mic()
1598 wpa_msg(sm->ctx->msg_ctx, MSG_WARNING, in wpa_supplicant_verify_eapol_key_mic()
1607 wpa_msg(sm->ctx->msg_ctx, MSG_WARNING, in wpa_supplicant_verify_eapol_key_mic()
1613 os_memcpy(sm->rx_replay_counter, key->replay_counter, in wpa_supplicant_verify_eapol_key_mic()
1615 sm->rx_replay_counter_set = 1; in wpa_supplicant_verify_eapol_key_mic()
1621 static int wpa_supplicant_decrypt_key_data(struct wpa_sm *sm, in wpa_supplicant_decrypt_key_data() argument
1627 if (!sm->ptk_set) { in wpa_supplicant_decrypt_key_data()
1628 wpa_msg(sm->ctx->msg_ctx, MSG_WARNING, in wpa_supplicant_decrypt_key_data()
1636 if (ver == WPA_KEY_INFO_TYPE_HMAC_MD5_RC4 && sm->ptk.kek_len == 16) { in wpa_supplicant_decrypt_key_data()
1638 wpa_msg(sm->ctx->msg_ctx, MSG_WARNING, in wpa_supplicant_decrypt_key_data()
1644 os_memcpy(ek + 16, sm->ptk.kek, sm->ptk.kek_len); in wpa_supplicant_decrypt_key_data()
1647 wpa_msg(sm->ctx->msg_ctx, MSG_ERROR, in wpa_supplicant_decrypt_key_data()
1655 sm->key_mgmt == WPA_KEY_MGMT_OSEN || in wpa_supplicant_decrypt_key_data()
1656 wpa_key_mgmt_suite_b(sm->key_mgmt)) { in wpa_supplicant_decrypt_key_data()
1659 wpa_msg(sm->ctx->msg_ctx, MSG_WARNING, in wpa_supplicant_decrypt_key_data()
1667 wpa_msg(sm->ctx->msg_ctx, MSG_WARNING, in wpa_supplicant_decrypt_key_data()
1671 if (aes_unwrap(sm->ptk.kek, sm->ptk.kek_len, *key_data_len / 8, in wpa_supplicant_decrypt_key_data()
1674 wpa_msg(sm->ctx->msg_ctx, MSG_WARNING, in wpa_supplicant_decrypt_key_data()
1683 wpa_msg(sm->ctx->msg_ctx, MSG_WARNING, in wpa_supplicant_decrypt_key_data()
1697 void wpa_sm_aborted_cached(struct wpa_sm *sm) in wpa_sm_aborted_cached() argument
1699 if (sm && sm->cur_pmksa) { in wpa_sm_aborted_cached()
1700 wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG, in wpa_sm_aborted_cached()
1702 sm->cur_pmksa = NULL; in wpa_sm_aborted_cached()
1707 static void wpa_eapol_key_dump(struct wpa_sm *sm, in wpa_eapol_key_dump() argument
1715 wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG, " EAPOL-Key type=%d", key->type); in wpa_eapol_key_dump()
1716 wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG, in wpa_eapol_key_dump()
1730 wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG, in wpa_eapol_key_dump()
1760 int wpa_sm_rx_eapol(struct wpa_sm *sm, const u8 *src_addr, in wpa_sm_rx_eapol() argument
1775 sm->ft_completed = 0; in wpa_sm_rx_eapol()
1778 mic_len = wpa_mic_len(sm->key_mgmt); in wpa_sm_rx_eapol()
1782 wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG, in wpa_sm_rx_eapol()
1793 wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG, in wpa_sm_rx_eapol()
1801 wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG, in wpa_sm_rx_eapol()
1809 wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG, in wpa_sm_rx_eapol()
1817 wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG, in wpa_sm_rx_eapol()
1840 wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG, in wpa_sm_rx_eapol()
1851 wpa_eapol_key_dump(sm, key, key_data_len, key192->key_mic, mic_len); in wpa_sm_rx_eapol()
1854 wpa_msg(sm->ctx->msg_ctx, MSG_INFO, "WPA: Invalid EAPOL-Key " in wpa_sm_rx_eapol()
1861 eapol_sm_notify_lower_layer_success(sm->eapol, 0); in wpa_sm_rx_eapol()
1869 !wpa_key_mgmt_suite_b(sm->key_mgmt) && in wpa_sm_rx_eapol()
1870 sm->key_mgmt != WPA_KEY_MGMT_OSEN) { in wpa_sm_rx_eapol()
1871 wpa_msg(sm->ctx->msg_ctx, MSG_INFO, in wpa_sm_rx_eapol()
1877 if (sm->key_mgmt == WPA_KEY_MGMT_OSEN && in wpa_sm_rx_eapol()
1879 wpa_msg(sm->ctx->msg_ctx, MSG_INFO, in wpa_sm_rx_eapol()
1885 if (wpa_key_mgmt_suite_b(sm->key_mgmt) && in wpa_sm_rx_eapol()
1887 wpa_msg(sm->ctx->msg_ctx, MSG_INFO, in wpa_sm_rx_eapol()
1894 if (wpa_key_mgmt_ft(sm->key_mgmt)) { in wpa_sm_rx_eapol()
1897 wpa_msg(sm->ctx->msg_ctx, MSG_INFO, in wpa_sm_rx_eapol()
1904 if (wpa_key_mgmt_sha256(sm->key_mgmt)) { in wpa_sm_rx_eapol()
1906 sm->key_mgmt != WPA_KEY_MGMT_OSEN && in wpa_sm_rx_eapol()
1907 !wpa_key_mgmt_suite_b(sm->key_mgmt)) { in wpa_sm_rx_eapol()
1908 wpa_msg(sm->ctx->msg_ctx, MSG_INFO, in wpa_sm_rx_eapol()
1915 if (sm->pairwise_cipher == WPA_CIPHER_CCMP && in wpa_sm_rx_eapol()
1916 !wpa_key_mgmt_suite_b(sm->key_mgmt) && in wpa_sm_rx_eapol()
1918 wpa_msg(sm->ctx->msg_ctx, MSG_INFO, in wpa_sm_rx_eapol()
1921 if (sm->group_cipher != WPA_CIPHER_CCMP && in wpa_sm_rx_eapol()
1927 wpa_msg(sm->ctx->msg_ctx, MSG_INFO, in wpa_sm_rx_eapol()
1931 wpa_msg(sm->ctx->msg_ctx, MSG_INFO, in wpa_sm_rx_eapol()
1935 } else if (sm->pairwise_cipher == WPA_CIPHER_GCMP && in wpa_sm_rx_eapol()
1936 !wpa_key_mgmt_suite_b(sm->key_mgmt) && in wpa_sm_rx_eapol()
1938 wpa_msg(sm->ctx->msg_ctx, MSG_INFO, in wpa_sm_rx_eapol()
1945 for (peerkey = sm->peerkey; peerkey; peerkey = peerkey->next) { in wpa_sm_rx_eapol()
1954 wpa_msg(sm->ctx->msg_ctx, MSG_WARNING, in wpa_sm_rx_eapol()
1965 wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG, in wpa_sm_rx_eapol()
1975 wpa_msg(sm->ctx->msg_ctx, MSG_INFO, in wpa_sm_rx_eapol()
1981 if (!peerkey && sm->rx_replay_counter_set && in wpa_sm_rx_eapol()
1982 os_memcmp(key->replay_counter, sm->rx_replay_counter, in wpa_sm_rx_eapol()
1984 wpa_msg(sm->ctx->msg_ctx, MSG_WARNING, in wpa_sm_rx_eapol()
1995 wpa_msg(sm->ctx->msg_ctx, MSG_INFO, in wpa_sm_rx_eapol()
2001 wpa_msg(sm->ctx->msg_ctx, MSG_INFO, in wpa_sm_rx_eapol()
2007 wpa_supplicant_verify_eapol_key_mic(sm, key192, ver, tmp, data_len)) in wpa_sm_rx_eapol()
2012 peerkey_verify_eapol_key_mic(sm, peerkey, key192, ver, tmp, in wpa_sm_rx_eapol()
2017 if ((sm->proto == WPA_PROTO_RSN || sm->proto == WPA_PROTO_OSEN) && in wpa_sm_rx_eapol()
2019 if (wpa_supplicant_decrypt_key_data(sm, key, ver, key_data, in wpa_sm_rx_eapol()
2026 wpa_msg(sm->ctx->msg_ctx, MSG_WARNING, in wpa_sm_rx_eapol()
2033 peerkey_rx_eapol_4way(sm, peerkey, key, key_info, ver, in wpa_sm_rx_eapol()
2037 wpa_supplicant_process_3_of_4(sm, key, ver, key_data, in wpa_sm_rx_eapol()
2041 wpa_supplicant_process_1_of_4(sm, src_addr, key, in wpa_sm_rx_eapol()
2047 peerkey_rx_eapol_smk(sm, src_addr, key, key_data_len, key_info, in wpa_sm_rx_eapol()
2052 wpa_supplicant_process_1_of_2(sm, src_addr, key, in wpa_sm_rx_eapol()
2056 wpa_msg(sm->ctx->msg_ctx, MSG_WARNING, in wpa_sm_rx_eapol()
2071 static u32 wpa_key_mgmt_suite(struct wpa_sm *sm) in wpa_key_mgmt_suite() argument
2073 switch (sm->key_mgmt) { in wpa_key_mgmt_suite()
2075 return ((sm->proto == WPA_PROTO_RSN || in wpa_key_mgmt_suite()
2076 sm->proto == WPA_PROTO_OSEN) ? in wpa_key_mgmt_suite()
2080 return (sm->proto == WPA_PROTO_RSN ? in wpa_key_mgmt_suite()
2096 return (sm->proto == WPA_PROTO_RSN ? in wpa_key_mgmt_suite()
2124 int wpa_sm_get_mib(struct wpa_sm *sm, char *buf, size_t buflen) in wpa_sm_get_mib() argument
2130 if (sm->cur_pmksa) { in wpa_sm_get_mib()
2132 sm->cur_pmksa->pmkid, PMKID_LEN); in wpa_sm_get_mib()
2136 if ((wpa_key_mgmt_wpa_psk(sm->key_mgmt) || in wpa_sm_get_mib()
2137 wpa_key_mgmt_wpa_ieee8021x(sm->key_mgmt)) && in wpa_sm_get_mib()
2138 sm->proto == WPA_PROTO_RSN) in wpa_sm_get_mib()
2158 wpa_cipher_key_len(sm->group_cipher) * 8, in wpa_sm_get_mib()
2159 sm->dot11RSNAConfigPMKLifetime, in wpa_sm_get_mib()
2160 sm->dot11RSNAConfigPMKReauthThreshold, in wpa_sm_get_mib()
2161 sm->dot11RSNAConfigSATimeout); in wpa_sm_get_mib()
2177 RSN_SUITE_ARG(wpa_key_mgmt_suite(sm)), in wpa_sm_get_mib()
2178 RSN_SUITE_ARG(wpa_cipher_to_suite(sm->proto, in wpa_sm_get_mib()
2179 sm->pairwise_cipher)), in wpa_sm_get_mib()
2180 RSN_SUITE_ARG(wpa_cipher_to_suite(sm->proto, in wpa_sm_get_mib()
2181 sm->group_cipher)), in wpa_sm_get_mib()
2183 RSN_SUITE_ARG(wpa_key_mgmt_suite(sm)), in wpa_sm_get_mib()
2184 RSN_SUITE_ARG(wpa_cipher_to_suite(sm->proto, in wpa_sm_get_mib()
2185 sm->pairwise_cipher)), in wpa_sm_get_mib()
2186 RSN_SUITE_ARG(wpa_cipher_to_suite(sm->proto, in wpa_sm_get_mib()
2187 sm->group_cipher)), in wpa_sm_get_mib()
2188 sm->dot11RSNA4WayHandshakeFailures); in wpa_sm_get_mib()
2200 struct wpa_sm *sm = ctx; in wpa_sm_pmksa_free_cb() local
2203 wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG, "RSN: PMKSA cache entry free_cb: " in wpa_sm_pmksa_free_cb()
2206 if (sm->cur_pmksa == entry) { in wpa_sm_pmksa_free_cb()
2207 wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG, in wpa_sm_pmksa_free_cb()
2210 pmksa_cache_clear_current(sm); in wpa_sm_pmksa_free_cb()
2223 (sm->pmk_len == entry->pmk_len && in wpa_sm_pmksa_free_cb()
2224 os_memcmp(sm->pmk, entry->pmk, sm->pmk_len) == 0)) { in wpa_sm_pmksa_free_cb()
2225 wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG, in wpa_sm_pmksa_free_cb()
2227 pmksa_cache_clear_current(sm); in wpa_sm_pmksa_free_cb()
2232 os_memset(sm->pmk, 0, sizeof(sm->pmk)); in wpa_sm_pmksa_free_cb()
2233 wpa_sm_deauthenticate(sm, WLAN_REASON_UNSPECIFIED); in wpa_sm_pmksa_free_cb()
2248 struct wpa_sm *sm; in wpa_sm_init() local
2250 sm = os_zalloc(sizeof(*sm)); in wpa_sm_init()
2251 if (sm == NULL) in wpa_sm_init()
2253 dl_list_init(&sm->pmksa_candidates); in wpa_sm_init()
2254 sm->renew_snonce = 1; in wpa_sm_init()
2255 sm->ctx = ctx; in wpa_sm_init()
2257 sm->dot11RSNAConfigPMKLifetime = 43200; in wpa_sm_init()
2258 sm->dot11RSNAConfigPMKReauthThreshold = 70; in wpa_sm_init()
2259 sm->dot11RSNAConfigSATimeout = 60; in wpa_sm_init()
2261 sm->pmksa = pmksa_cache_init(wpa_sm_pmksa_free_cb, sm, sm); in wpa_sm_init()
2262 if (sm->pmksa == NULL) { in wpa_sm_init()
2263 wpa_msg(sm->ctx->msg_ctx, MSG_ERROR, in wpa_sm_init()
2265 os_free(sm); in wpa_sm_init()
2269 return sm; in wpa_sm_init()
2277 void wpa_sm_deinit(struct wpa_sm *sm) in wpa_sm_deinit() argument
2279 if (sm == NULL) in wpa_sm_deinit()
2281 pmksa_cache_deinit(sm->pmksa); in wpa_sm_deinit()
2282 eloop_cancel_timeout(wpa_sm_start_preauth, sm, NULL); in wpa_sm_deinit()
2283 eloop_cancel_timeout(wpa_sm_rekey_ptk, sm, NULL); in wpa_sm_deinit()
2284 os_free(sm->assoc_wpa_ie); in wpa_sm_deinit()
2285 os_free(sm->ap_wpa_ie); in wpa_sm_deinit()
2286 os_free(sm->ap_rsn_ie); in wpa_sm_deinit()
2287 wpa_sm_drop_sa(sm); in wpa_sm_deinit()
2288 os_free(sm->ctx); in wpa_sm_deinit()
2289 peerkey_deinit(sm); in wpa_sm_deinit()
2291 os_free(sm->assoc_resp_ies); in wpa_sm_deinit()
2294 wpabuf_free(sm->test_assoc_ie); in wpa_sm_deinit()
2296 os_free(sm); in wpa_sm_deinit()
2308 void wpa_sm_notify_assoc(struct wpa_sm *sm, const u8 *bssid) in wpa_sm_notify_assoc() argument
2312 if (sm == NULL) in wpa_sm_notify_assoc()
2315 wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG, in wpa_sm_notify_assoc()
2317 os_memcpy(sm->bssid, bssid, ETH_ALEN); in wpa_sm_notify_assoc()
2318 os_memset(sm->rx_replay_counter, 0, WPA_REPLAY_COUNTER_LEN); in wpa_sm_notify_assoc()
2319 sm->rx_replay_counter_set = 0; in wpa_sm_notify_assoc()
2320 sm->renew_snonce = 1; in wpa_sm_notify_assoc()
2321 if (os_memcmp(sm->preauth_bssid, bssid, ETH_ALEN) == 0) in wpa_sm_notify_assoc()
2322 rsn_preauth_deinit(sm); in wpa_sm_notify_assoc()
2325 if (wpa_ft_is_completed(sm)) { in wpa_sm_notify_assoc()
2330 eapol_sm_notify_portValid(sm->eapol, FALSE); in wpa_sm_notify_assoc()
2331 wpa_supplicant_key_neg_complete(sm, sm->bssid, 1); in wpa_sm_notify_assoc()
2334 wpa_ft_prepare_auth_request(sm, NULL); in wpa_sm_notify_assoc()
2345 wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG, "WPA: Clear old PTK"); in wpa_sm_notify_assoc()
2346 sm->ptk_set = 0; in wpa_sm_notify_assoc()
2347 os_memset(&sm->ptk, 0, sizeof(sm->ptk)); in wpa_sm_notify_assoc()
2348 sm->tptk_set = 0; in wpa_sm_notify_assoc()
2349 os_memset(&sm->tptk, 0, sizeof(sm->tptk)); in wpa_sm_notify_assoc()
2353 wpa_tdls_assoc(sm); in wpa_sm_notify_assoc()
2357 os_memset(sm->p2p_ip_addr, 0, sizeof(sm->p2p_ip_addr)); in wpa_sm_notify_assoc()
2369 void wpa_sm_notify_disassoc(struct wpa_sm *sm) in wpa_sm_notify_disassoc() argument
2371 eloop_cancel_timeout(wpa_sm_start_preauth, sm, NULL); in wpa_sm_notify_disassoc()
2372 eloop_cancel_timeout(wpa_sm_rekey_ptk, sm, NULL); in wpa_sm_notify_disassoc()
2373 peerkey_deinit(sm); in wpa_sm_notify_disassoc()
2374 rsn_preauth_deinit(sm); in wpa_sm_notify_disassoc()
2375 pmksa_cache_clear_current(sm); in wpa_sm_notify_disassoc()
2376 if (wpa_sm_get_state(sm) == WPA_4WAY_HANDSHAKE) in wpa_sm_notify_disassoc()
2377 sm->dot11RSNA4WayHandshakeFailures++; in wpa_sm_notify_disassoc()
2379 wpa_tdls_disassoc(sm); in wpa_sm_notify_disassoc()
2383 wpa_sm_drop_sa(sm); in wpa_sm_notify_disassoc()
2385 sm->msg_3_of_4_ok = 0; in wpa_sm_notify_disassoc()
2399 void wpa_sm_set_pmk(struct wpa_sm *sm, const u8 *pmk, size_t pmk_len, in wpa_sm_set_pmk() argument
2402 if (sm == NULL) in wpa_sm_set_pmk()
2405 sm->pmk_len = pmk_len; in wpa_sm_set_pmk()
2406 os_memcpy(sm->pmk, pmk, pmk_len); in wpa_sm_set_pmk()
2410 sm->xxkey_len = pmk_len; in wpa_sm_set_pmk()
2411 os_memcpy(sm->xxkey, pmk, pmk_len); in wpa_sm_set_pmk()
2415 pmksa_cache_add(sm->pmksa, pmk, pmk_len, pmkid, NULL, 0, in wpa_sm_set_pmk()
2416 bssid, sm->own_addr, in wpa_sm_set_pmk()
2417 sm->network_ctx, sm->key_mgmt); in wpa_sm_set_pmk()
2429 void wpa_sm_set_pmk_from_pmksa(struct wpa_sm *sm) in wpa_sm_set_pmk_from_pmksa() argument
2431 if (sm == NULL) in wpa_sm_set_pmk_from_pmksa()
2434 if (sm->cur_pmksa) { in wpa_sm_set_pmk_from_pmksa()
2435 sm->pmk_len = sm->cur_pmksa->pmk_len; in wpa_sm_set_pmk_from_pmksa()
2436 os_memcpy(sm->pmk, sm->cur_pmksa->pmk, sm->pmk_len); in wpa_sm_set_pmk_from_pmksa()
2438 sm->pmk_len = PMK_LEN; in wpa_sm_set_pmk_from_pmksa()
2439 os_memset(sm->pmk, 0, PMK_LEN); in wpa_sm_set_pmk_from_pmksa()
2449 void wpa_sm_set_fast_reauth(struct wpa_sm *sm, int fast_reauth) in wpa_sm_set_fast_reauth() argument
2451 if (sm) in wpa_sm_set_fast_reauth()
2452 sm->fast_reauth = fast_reauth; in wpa_sm_set_fast_reauth()
2461 void wpa_sm_set_scard_ctx(struct wpa_sm *sm, void *scard_ctx) in wpa_sm_set_scard_ctx() argument
2463 if (sm == NULL) in wpa_sm_set_scard_ctx()
2465 sm->scard_ctx = scard_ctx; in wpa_sm_set_scard_ctx()
2466 if (sm->preauth_eapol) in wpa_sm_set_scard_ctx()
2467 eapol_sm_register_scard_ctx(sm->preauth_eapol, scard_ctx); in wpa_sm_set_scard_ctx()
2480 void wpa_sm_set_config(struct wpa_sm *sm, struct rsn_supp_config *config) in wpa_sm_set_config() argument
2482 if (!sm) in wpa_sm_set_config()
2486 sm->network_ctx = config->network_ctx; in wpa_sm_set_config()
2487 sm->peerkey_enabled = config->peerkey_enabled; in wpa_sm_set_config()
2488 sm->allowed_pairwise_cipher = config->allowed_pairwise_cipher; in wpa_sm_set_config()
2489 sm->proactive_key_caching = config->proactive_key_caching; in wpa_sm_set_config()
2490 sm->eap_workaround = config->eap_workaround; in wpa_sm_set_config()
2491 sm->eap_conf_ctx = config->eap_conf_ctx; in wpa_sm_set_config()
2493 os_memcpy(sm->ssid, config->ssid, config->ssid_len); in wpa_sm_set_config()
2494 sm->ssid_len = config->ssid_len; in wpa_sm_set_config()
2496 sm->ssid_len = 0; in wpa_sm_set_config()
2497 sm->wpa_ptk_rekey = config->wpa_ptk_rekey; in wpa_sm_set_config()
2498 sm->p2p = config->p2p; in wpa_sm_set_config()
2499 sm->wpa_rsc_relaxation = config->wpa_rsc_relaxation; in wpa_sm_set_config()
2501 sm->network_ctx = NULL; in wpa_sm_set_config()
2502 sm->peerkey_enabled = 0; in wpa_sm_set_config()
2503 sm->allowed_pairwise_cipher = 0; in wpa_sm_set_config()
2504 sm->proactive_key_caching = 0; in wpa_sm_set_config()
2505 sm->eap_workaround = 0; in wpa_sm_set_config()
2506 sm->eap_conf_ctx = NULL; in wpa_sm_set_config()
2507 sm->ssid_len = 0; in wpa_sm_set_config()
2508 sm->wpa_ptk_rekey = 0; in wpa_sm_set_config()
2509 sm->p2p = 0; in wpa_sm_set_config()
2510 sm->wpa_rsc_relaxation = 0; in wpa_sm_set_config()
2520 void wpa_sm_set_own_addr(struct wpa_sm *sm, const u8 *addr) in wpa_sm_set_own_addr() argument
2522 if (sm) in wpa_sm_set_own_addr()
2523 os_memcpy(sm->own_addr, addr, ETH_ALEN); in wpa_sm_set_own_addr()
2533 void wpa_sm_set_ifname(struct wpa_sm *sm, const char *ifname, in wpa_sm_set_ifname() argument
2536 if (sm) { in wpa_sm_set_ifname()
2537 sm->ifname = ifname; in wpa_sm_set_ifname()
2538 sm->bridge_ifname = bridge_ifname; in wpa_sm_set_ifname()
2548 void wpa_sm_set_eapol(struct wpa_sm *sm, struct eapol_sm *eapol) in wpa_sm_set_eapol() argument
2550 if (sm) in wpa_sm_set_eapol()
2551 sm->eapol = eapol; in wpa_sm_set_eapol()
2562 int wpa_sm_set_param(struct wpa_sm *sm, enum wpa_sm_conf_params param, in wpa_sm_set_param() argument
2567 if (sm == NULL) in wpa_sm_set_param()
2573 sm->dot11RSNAConfigPMKLifetime = value; in wpa_sm_set_param()
2579 sm->dot11RSNAConfigPMKReauthThreshold = value; in wpa_sm_set_param()
2585 sm->dot11RSNAConfigSATimeout = value; in wpa_sm_set_param()
2590 sm->proto = value; in wpa_sm_set_param()
2593 sm->pairwise_cipher = value; in wpa_sm_set_param()
2596 sm->group_cipher = value; in wpa_sm_set_param()
2599 sm->key_mgmt = value; in wpa_sm_set_param()
2603 sm->mgmt_group_cipher = value; in wpa_sm_set_param()
2607 sm->rsn_enabled = value; in wpa_sm_set_param()
2610 sm->mfp = value; in wpa_sm_set_param()
2632 int wpa_sm_get_status(struct wpa_sm *sm, char *buf, size_t buflen, in wpa_sm_get_status() argument
2642 wpa_cipher_txt(sm->pairwise_cipher), in wpa_sm_get_status()
2643 wpa_cipher_txt(sm->group_cipher), in wpa_sm_get_status()
2644 wpa_key_mgmt_txt(sm->key_mgmt, sm->proto)); in wpa_sm_get_status()
2649 if (sm->mfp != NO_MGMT_FRAME_PROTECTION && sm->ap_rsn_ie) { in wpa_sm_get_status()
2651 if (wpa_parse_wpa_ie_rsn(sm->ap_rsn_ie, sm->ap_rsn_ie_len, &rsn) in wpa_sm_get_status()
2668 int wpa_sm_pmf_enabled(struct wpa_sm *sm) in wpa_sm_pmf_enabled() argument
2672 if (sm->mfp == NO_MGMT_FRAME_PROTECTION || !sm->ap_rsn_ie) in wpa_sm_pmf_enabled()
2675 if (wpa_parse_wpa_ie_rsn(sm->ap_rsn_ie, sm->ap_rsn_ie_len, &rsn) >= 0 && in wpa_sm_pmf_enabled()
2690 int wpa_sm_set_assoc_wpa_ie_default(struct wpa_sm *sm, u8 *wpa_ie, in wpa_sm_set_assoc_wpa_ie_default() argument
2695 if (sm == NULL) in wpa_sm_set_assoc_wpa_ie_default()
2699 if (sm->test_assoc_ie) { in wpa_sm_set_assoc_wpa_ie_default()
2702 if (*wpa_ie_len < wpabuf_len(sm->test_assoc_ie)) in wpa_sm_set_assoc_wpa_ie_default()
2704 os_memcpy(wpa_ie, wpabuf_head(sm->test_assoc_ie), in wpa_sm_set_assoc_wpa_ie_default()
2705 wpabuf_len(sm->test_assoc_ie)); in wpa_sm_set_assoc_wpa_ie_default()
2706 res = wpabuf_len(sm->test_assoc_ie); in wpa_sm_set_assoc_wpa_ie_default()
2709 res = wpa_gen_wpa_ie(sm, wpa_ie, *wpa_ie_len); in wpa_sm_set_assoc_wpa_ie_default()
2717 if (sm->assoc_wpa_ie == NULL) { in wpa_sm_set_assoc_wpa_ie_default()
2723 sm->assoc_wpa_ie = os_malloc(*wpa_ie_len); in wpa_sm_set_assoc_wpa_ie_default()
2724 if (sm->assoc_wpa_ie == NULL) in wpa_sm_set_assoc_wpa_ie_default()
2727 os_memcpy(sm->assoc_wpa_ie, wpa_ie, *wpa_ie_len); in wpa_sm_set_assoc_wpa_ie_default()
2728 sm->assoc_wpa_ie_len = *wpa_ie_len; in wpa_sm_set_assoc_wpa_ie_default()
2746 int wpa_sm_set_assoc_wpa_ie(struct wpa_sm *sm, const u8 *ie, size_t len) in wpa_sm_set_assoc_wpa_ie() argument
2748 if (sm == NULL) in wpa_sm_set_assoc_wpa_ie()
2751 os_free(sm->assoc_wpa_ie); in wpa_sm_set_assoc_wpa_ie()
2753 wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG, in wpa_sm_set_assoc_wpa_ie()
2755 sm->assoc_wpa_ie = NULL; in wpa_sm_set_assoc_wpa_ie()
2756 sm->assoc_wpa_ie_len = 0; in wpa_sm_set_assoc_wpa_ie()
2759 sm->assoc_wpa_ie = os_malloc(len); in wpa_sm_set_assoc_wpa_ie()
2760 if (sm->assoc_wpa_ie == NULL) in wpa_sm_set_assoc_wpa_ie()
2763 os_memcpy(sm->assoc_wpa_ie, ie, len); in wpa_sm_set_assoc_wpa_ie()
2764 sm->assoc_wpa_ie_len = len; in wpa_sm_set_assoc_wpa_ie()
2781 int wpa_sm_set_ap_wpa_ie(struct wpa_sm *sm, const u8 *ie, size_t len) in wpa_sm_set_ap_wpa_ie() argument
2783 if (sm == NULL) in wpa_sm_set_ap_wpa_ie()
2786 os_free(sm->ap_wpa_ie); in wpa_sm_set_ap_wpa_ie()
2788 wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG, in wpa_sm_set_ap_wpa_ie()
2790 sm->ap_wpa_ie = NULL; in wpa_sm_set_ap_wpa_ie()
2791 sm->ap_wpa_ie_len = 0; in wpa_sm_set_ap_wpa_ie()
2794 sm->ap_wpa_ie = os_malloc(len); in wpa_sm_set_ap_wpa_ie()
2795 if (sm->ap_wpa_ie == NULL) in wpa_sm_set_ap_wpa_ie()
2798 os_memcpy(sm->ap_wpa_ie, ie, len); in wpa_sm_set_ap_wpa_ie()
2799 sm->ap_wpa_ie_len = len; in wpa_sm_set_ap_wpa_ie()
2816 int wpa_sm_set_ap_rsn_ie(struct wpa_sm *sm, const u8 *ie, size_t len) in wpa_sm_set_ap_rsn_ie() argument
2818 if (sm == NULL) in wpa_sm_set_ap_rsn_ie()
2821 os_free(sm->ap_rsn_ie); in wpa_sm_set_ap_rsn_ie()
2823 wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG, in wpa_sm_set_ap_rsn_ie()
2825 sm->ap_rsn_ie = NULL; in wpa_sm_set_ap_rsn_ie()
2826 sm->ap_rsn_ie_len = 0; in wpa_sm_set_ap_rsn_ie()
2829 sm->ap_rsn_ie = os_malloc(len); in wpa_sm_set_ap_rsn_ie()
2830 if (sm->ap_rsn_ie == NULL) in wpa_sm_set_ap_rsn_ie()
2833 os_memcpy(sm->ap_rsn_ie, ie, len); in wpa_sm_set_ap_rsn_ie()
2834 sm->ap_rsn_ie_len = len; in wpa_sm_set_ap_rsn_ie()
2850 int wpa_sm_parse_own_wpa_ie(struct wpa_sm *sm, struct wpa_ie_data *data) in wpa_sm_parse_own_wpa_ie() argument
2852 if (sm == NULL) in wpa_sm_parse_own_wpa_ie()
2855 if (sm->assoc_wpa_ie == NULL) { in wpa_sm_parse_own_wpa_ie()
2856 wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG, in wpa_sm_parse_own_wpa_ie()
2860 if (wpa_parse_wpa_ie(sm->assoc_wpa_ie, sm->assoc_wpa_ie_len, data)) in wpa_sm_parse_own_wpa_ie()
2866 int wpa_sm_pmksa_cache_list(struct wpa_sm *sm, char *buf, size_t len) in wpa_sm_pmksa_cache_list() argument
2868 return pmksa_cache_list(sm->pmksa, buf, len); in wpa_sm_pmksa_cache_list()
2872 void wpa_sm_drop_sa(struct wpa_sm *sm) in wpa_sm_drop_sa() argument
2874 wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG, "WPA: Clear old PMK and PTK"); in wpa_sm_drop_sa()
2875 sm->ptk_set = 0; in wpa_sm_drop_sa()
2876 sm->tptk_set = 0; in wpa_sm_drop_sa()
2877 os_memset(sm->pmk, 0, sizeof(sm->pmk)); in wpa_sm_drop_sa()
2878 os_memset(&sm->ptk, 0, sizeof(sm->ptk)); in wpa_sm_drop_sa()
2879 os_memset(&sm->tptk, 0, sizeof(sm->tptk)); in wpa_sm_drop_sa()
2881 os_memset(sm->xxkey, 0, sizeof(sm->xxkey)); in wpa_sm_drop_sa()
2882 os_memset(sm->pmk_r0, 0, sizeof(sm->pmk_r0)); in wpa_sm_drop_sa()
2883 os_memset(sm->pmk_r1, 0, sizeof(sm->pmk_r1)); in wpa_sm_drop_sa()
2888 int wpa_sm_has_ptk(struct wpa_sm *sm) in wpa_sm_has_ptk() argument
2890 if (sm == NULL) in wpa_sm_has_ptk()
2892 return sm->ptk_set; in wpa_sm_has_ptk()
2896 void wpa_sm_update_replay_ctr(struct wpa_sm *sm, const u8 *replay_ctr) in wpa_sm_update_replay_ctr() argument
2898 os_memcpy(sm->rx_replay_counter, replay_ctr, WPA_REPLAY_COUNTER_LEN); in wpa_sm_update_replay_ctr()
2902 void wpa_sm_pmksa_cache_flush(struct wpa_sm *sm, void *network_ctx) in wpa_sm_pmksa_cache_flush() argument
2904 pmksa_cache_flush(sm->pmksa, network_ctx, NULL, 0); in wpa_sm_pmksa_cache_flush()
2909 int wpa_wnmsleep_install_key(struct wpa_sm *sm, u8 subelem_id, u8 *buf) in wpa_wnmsleep_install_key() argument
2919 keylen = wpa_cipher_key_len(sm->group_cipher); in wpa_wnmsleep_install_key()
2920 gd.key_rsc_len = wpa_cipher_rsc_len(sm->group_cipher); in wpa_wnmsleep_install_key()
2921 gd.alg = wpa_cipher_to_alg(sm->group_cipher); in wpa_wnmsleep_install_key()
2937 sm, !!(keyinfo & WPA_KEY_INFO_TXRX)); in wpa_wnmsleep_install_key()
2943 if (wpa_supplicant_install_gtk(sm, &gd, key_rsc)) { in wpa_wnmsleep_install_key()
2956 keylen = wpa_cipher_key_len(sm->mgmt_group_cipher); in wpa_wnmsleep_install_key()
2965 if (wpa_sm_set_key(sm, wpa_cipher_to_alg(sm->mgmt_group_cipher), in wpa_wnmsleep_install_key()
2987 int wpa_sm_rx_eapol_peerkey(struct wpa_sm *sm, const u8 *src_addr, in wpa_sm_rx_eapol_peerkey() argument
2992 for (peerkey = sm->peerkey; peerkey; peerkey = peerkey->next) { in wpa_sm_rx_eapol_peerkey()
3000 wpa_sm_rx_eapol(sm, src_addr, buf, len); in wpa_sm_rx_eapol_peerkey()
3009 int wpa_sm_get_p2p_ip_addr(struct wpa_sm *sm, u8 *buf) in wpa_sm_get_p2p_ip_addr() argument
3011 if (sm == NULL || WPA_GET_BE32(sm->p2p_ip_addr) == 0) in wpa_sm_get_p2p_ip_addr()
3013 os_memcpy(buf, sm->p2p_ip_addr, 3 * 4); in wpa_sm_get_p2p_ip_addr()
3020 void wpa_sm_set_rx_replay_ctr(struct wpa_sm *sm, const u8 *rx_replay_counter) in wpa_sm_set_rx_replay_ctr() argument
3025 os_memcpy(sm->rx_replay_counter, rx_replay_counter, in wpa_sm_set_rx_replay_ctr()
3027 sm->rx_replay_counter_set = 1; in wpa_sm_set_rx_replay_ctr()
3032 void wpa_sm_set_ptk_kck_kek(struct wpa_sm *sm, in wpa_sm_set_ptk_kck_kek() argument
3037 os_memcpy(sm->ptk.kck, ptk_kck, ptk_kck_len); in wpa_sm_set_ptk_kck_kek()
3038 sm->ptk.kck_len = ptk_kck_len; in wpa_sm_set_ptk_kck_kek()
3042 os_memcpy(sm->ptk.kek, ptk_kek, ptk_kek_len); in wpa_sm_set_ptk_kck_kek()
3043 sm->ptk.kek_len = ptk_kek_len; in wpa_sm_set_ptk_kck_kek()
3046 sm->ptk_set = 1; in wpa_sm_set_ptk_kck_kek()
3051 void wpa_sm_set_test_assoc_ie(struct wpa_sm *sm, struct wpabuf *buf) in wpa_sm_set_test_assoc_ie() argument
3053 wpabuf_free(sm->test_assoc_ie); in wpa_sm_set_test_assoc_ie()
3054 sm->test_assoc_ie = buf; in wpa_sm_set_test_assoc_ie()