static void rsn_preauth_timeout(void *eloop_ctx, void *timeout_ctx) { struct wpa_supplicant *wpa_s = eloop_ctx; wpa_msg(wpa_s, MSG_INFO, "RSN: pre-authentication with " MACSTR " timed out", MAC2STR(wpa_s->preauth_bssid)); rsn_preauth_deinit(wpa_s); rsn_preauth_candidate_process(wpa_s); }
static void rsn_preauth_timeout(void *eloop_ctx, void *timeout_ctx) { struct wpa_sm *sm = eloop_ctx; wpa_msg(sm->ctx->ctx, MSG_INFO, "RSN: pre-authentication with " MACSTR " timed out", MAC2STR(sm->preauth_bssid)); rsn_preauth_deinit(sm); rsn_preauth_candidate_process(sm); }
static void rsn_preauth_eapol_cb(struct eapol_sm *eapol, int success, void *ctx) { struct wpa_sm *sm = ctx; u8 pmk[PMK_LEN]; if (success) { int res, pmk_len; pmk_len = PMK_LEN; res = eapol_sm_get_key(eapol, pmk, PMK_LEN); if (res) { /* * EAP-LEAP is an exception from other EAP methods: it * uses only 16-byte PMK. */ res = eapol_sm_get_key(eapol, pmk, 16); pmk_len = 16; } if (res == 0) { wpa_hexdump_key(MSG_DEBUG, "RSN: PMK from pre-auth", pmk, pmk_len); sm->pmk_len = pmk_len; pmksa_cache_add(sm->pmksa, pmk, pmk_len, sm->preauth_bssid, sm->own_addr, sm->network_ctx, WPA_KEY_MGMT_IEEE8021X); } else { wpa_msg(sm->ctx->ctx, MSG_INFO, "RSN: failed to get " "master session key from pre-auth EAPOL state " "machines"); success = 0; } } wpa_msg(sm->ctx->ctx, MSG_INFO, "RSN: pre-authentication with " MACSTR " %s", MAC2STR(sm->preauth_bssid), success ? "completed successfully" : "failed"); rsn_preauth_deinit(sm); rsn_preauth_candidate_process(sm); }
static void rsn_preauth_eapol_cb(struct eapol_sm *eapol, int success, void *ctx) { struct wpa_sm *sm = ctx; u8 pmk[PMK_LEN]; if (success) { int res, pmk_len; pmk_len = PMK_LEN; res = eapol_sm_get_key(eapol, pmk, PMK_LEN); #ifdef EAP_LEAP if (res) { res = eapol_sm_get_key(eapol, pmk, 16); pmk_len = 16; } #endif /* EAP_LEAP */ if (res == 0) { wpa_hexdump_key(MSG_DEBUG, "RSN: PMK from pre-auth", pmk, pmk_len); sm->pmk_len = pmk_len; pmksa_cache_add(sm, pmk, pmk_len, sm->preauth_bssid, sm->own_addr, sm->cur_ssid); } else { wpa_msg(sm->ctx->ctx, MSG_INFO, "RSN: failed to get " "master session key from pre-auth EAPOL state " "machines"); success = 0; } } wpa_msg(sm->ctx->ctx, MSG_INFO, "RSN: pre-authentication with " MACSTR " %s", MAC2STR(sm->preauth_bssid), success ? "completed successfully" : "failed"); rsn_preauth_deinit(sm); rsn_preauth_candidate_process(sm); }
/** * pmksa_candidate_add - Add a new PMKSA candidate * @sm: Pointer to WPA state machine data from wpa_sm_init() * @bssid: BSSID (authenticator address) of the candidate * @prio: Priority (the smaller number, the higher priority) * @preauth: Whether the candidate AP advertises support for pre-authentication * * This function is used to add PMKSA candidates for RSN pre-authentication. It * is called from scan result processing and from driver events for PMKSA * candidates, i.e., EVENT_PMKID_CANDIDATE events to wpa_supplicant_event(). */ void pmksa_candidate_add(struct wpa_sm *sm, const u8 *bssid, int prio, int preauth) { struct rsn_pmksa_candidate *cand, *prev, *pos; if (sm->network_ctx && sm->proactive_key_caching) pmksa_cache_get_opportunistic(sm->pmksa, sm->network_ctx, bssid); if (!preauth) { wpa_printf(MSG_DEBUG, "RSN: Ignored PMKID candidate without " "preauth flag"); return; } /* If BSSID already on candidate list, update the priority of the old * entry. Do not override priority based on normal scan results. */ prev = NULL; cand = sm->pmksa_candidates; while (cand) { if (os_memcmp(cand->bssid, bssid, ETH_ALEN) == 0) { if (prev) prev->next = cand->next; else sm->pmksa_candidates = cand->next; break; } prev = cand; cand = cand->next; } if (cand) { if (prio < PMKID_CANDIDATE_PRIO_SCAN) cand->priority = prio; } else { cand = os_zalloc(sizeof(*cand)); if (cand == NULL) return; os_memcpy(cand->bssid, bssid, ETH_ALEN); cand->priority = prio; } /* Add candidate to the list; order by increasing priority value. i.e., * highest priority (smallest value) first. */ prev = NULL; pos = sm->pmksa_candidates; while (pos) { if (cand->priority <= pos->priority) break; prev = pos; pos = pos->next; } cand->next = pos; if (prev) prev->next = cand; else sm->pmksa_candidates = cand; wpa_msg(sm->ctx->ctx, MSG_DEBUG, "RSN: added PMKSA cache " "candidate " MACSTR " prio %d", MAC2STR(bssid), prio); rsn_preauth_candidate_process(sm); }
static void wpa_sm_start_preauth(void *eloop_ctx, void *timeout_ctx) { struct wpa_sm *sm = eloop_ctx; rsn_preauth_candidate_process(sm); }