Lines Matching defs:pmksa
2 * WPA Supplicant - RSN PMKSA cache
32 struct rsn_pmksa_cache_entry *pmksa; /* PMKSA cache */
33 int pmksa_count; /* number of entries in PMKSA cache */
69 static void pmksa_cache_set_expiration(struct rsn_pmksa_cache *pmksa);
78 static void pmksa_cache_free_entry(struct rsn_pmksa_cache *pmksa,
82 pmksa->pmksa_count--;
83 pmksa->free_cb(entry, pmksa->ctx, replace);
90 struct rsn_pmksa_cache *pmksa = eloop_ctx;
94 while (pmksa->pmksa && pmksa->pmksa->expiration <= now.sec) {
95 struct rsn_pmksa_cache_entry *entry = pmksa->pmksa;
96 pmksa->pmksa = entry->next;
97 wpa_printf(MSG_DEBUG, "RSN: expired PMKSA cache entry for "
99 pmksa_cache_free_entry(pmksa, entry, 0);
102 pmksa_cache_set_expiration(pmksa);
108 struct rsn_pmksa_cache *pmksa = eloop_ctx;
109 pmksa->sm->cur_pmksa = NULL;
110 eapol_sm_request_reauth(pmksa->sm->eapol);
114 static void pmksa_cache_set_expiration(struct rsn_pmksa_cache *pmksa)
120 eloop_cancel_timeout(pmksa_cache_expire, pmksa, NULL);
121 eloop_cancel_timeout(pmksa_cache_reauth, pmksa, NULL);
122 if (pmksa->pmksa == NULL)
125 sec = pmksa->pmksa->expiration - now.sec;
128 eloop_register_timeout(sec + 1, 0, pmksa_cache_expire, pmksa, NULL);
130 entry = pmksa->sm->cur_pmksa ? pmksa->sm->cur_pmksa :
131 pmksa_cache_get(pmksa, pmksa->sm->bssid, NULL);
133 sec = pmksa->pmksa->reauth_time - now.sec;
136 eloop_register_timeout(sec, 0, pmksa_cache_reauth, pmksa,
143 * pmksa_cache_add - Add a PMKSA cache entry
144 * @pmksa: Pointer to PMKSA cache data from pmksa_cache_init()
150 * Returns: Pointer to the added PMKSA cache entry or %NULL on error
152 * This function create a PMKSA entry for a new PMK and adds it to the PMKSA
158 pmksa_cache_add(struct rsn_pmksa_cache *pmksa, const u8 *pmk, size_t pmk_len,
164 if (pmksa->sm->proto != WPA_PROTO_RSN || pmk_len > PMK_LEN)
174 entry->expiration = now.sec + pmksa->sm->dot11RSNAConfigPMKLifetime;
175 entry->reauth_time = now.sec + pmksa->sm->dot11RSNAConfigPMKLifetime *
176 pmksa->sm->dot11RSNAConfigPMKReauthThreshold / 100;
183 pos = pmksa->pmksa;
192 "PMKSA entry");
197 pmksa->pmksa = pos->next;
200 if (pos == pmksa->sm->cur_pmksa) {
201 /* We are about to replace the current PMKSA
202 * cache entry. This happens when the PMKSA
206 * PMKSA cache entry will not be used in the
210 "PMKSA entry");
211 pmksa->sm->cur_pmksa = NULL;
213 wpa_printf(MSG_DEBUG, "RSN: Replace PMKSA entry for "
215 pmksa_cache_free_entry(pmksa, pos, 1);
222 if (pmksa->pmksa_count >= pmksa_cache_max_entries && pmksa->pmksa) {
224 pos = pmksa->pmksa;
225 pmksa->pmksa = pos->next;
226 wpa_printf(MSG_DEBUG, "RSN: removed the oldest PMKSA cache "
229 wpa_sm_remove_pmkid(pmksa->sm, pos->aa, pos->pmkid);
230 pmksa_cache_free_entry(pmksa, pos, 0);
234 pos = pmksa->pmksa;
243 entry->next = pmksa->pmksa;
244 pmksa->pmksa = entry;
245 pmksa_cache_set_expiration(pmksa);
250 pmksa->pmksa_count++;
251 wpa_printf(MSG_DEBUG, "RSN: added PMKSA cache entry for " MACSTR,
253 wpa_sm_add_pmkid(pmksa->sm, entry->aa, entry->pmkid);
260 * pmksa_cache_deinit - Free all entries in PMKSA cache
261 * @pmksa: Pointer to PMKSA cache data from pmksa_cache_init()
263 void pmksa_cache_deinit(struct rsn_pmksa_cache *pmksa)
267 if (pmksa == NULL)
270 entry = pmksa->pmksa;
271 pmksa->pmksa = NULL;
277 pmksa_cache_set_expiration(pmksa);
278 os_free(pmksa);
283 * pmksa_cache_get - Fetch a PMKSA cache entry
284 * @pmksa: Pointer to PMKSA cache data from pmksa_cache_init()
287 * Returns: Pointer to PMKSA cache entry or %NULL if no match was found
289 struct rsn_pmksa_cache_entry * pmksa_cache_get(struct rsn_pmksa_cache *pmksa,
292 struct rsn_pmksa_cache_entry *entry = pmksa->pmksa;
305 * pmksa_cache_notify_reconfig - Reconfiguration notification for PMKSA cache
306 * @pmksa: Pointer to PMKSA cache data from pmksa_cache_init()
310 void pmksa_cache_notify_reconfig(struct rsn_pmksa_cache *pmksa)
312 struct rsn_pmksa_cache_entry *entry = pmksa->pmksa;
321 pmksa_cache_clone_entry(struct rsn_pmksa_cache *pmksa,
327 new_entry = pmksa_cache_add(pmksa, old_entry->pmk, old_entry->pmk_len,
328 aa, pmksa->sm->own_addr, old_entry->ssid);
341 * pmksa_cache_get_opportunistic - Try to get an opportunistic PMKSA entry
342 * @pmksa: Pointer to PMKSA cache data from pmksa_cache_init()
345 * Returns: Pointer to a new PMKSA cache entry or %NULL if not available
347 * Try to create a new PMKSA cache entry opportunistically by guessing that the
349 * already an entry in PMKSA cache.
352 pmksa_cache_get_opportunistic(struct rsn_pmksa_cache *pmksa,
355 struct rsn_pmksa_cache_entry *entry = pmksa->pmksa;
361 entry = pmksa_cache_clone_entry(pmksa, entry, aa);
364 "opportunistic PMKSA cache entry "
376 * pmksa_cache_get_current - Get the current used PMKSA entry
378 * Returns: Pointer to the current PMKSA cache entry or %NULL if not available
389 * pmksa_cache_clear_current - Clear the current PMKSA entry selection
401 * pmksa_cache_set_current - Set the current PMKSA entry selection
403 * @pmkid: PMKID for selecting PMKSA or %NULL if not used
404 * @bssid: BSSID for PMKSA or %NULL if not used
406 * @try_opportunistic: Whether to allow opportunistic PMKSA caching
407 * Returns: 0 if PMKSA was found or -1 if no matching entry was found
413 struct rsn_pmksa_cache *pmksa = sm->pmksa;
416 sm->cur_pmksa = pmksa_cache_get(pmksa, NULL, pmkid);
418 sm->cur_pmksa = pmksa_cache_get(pmksa, bssid, NULL);
420 sm->cur_pmksa = pmksa_cache_get_opportunistic(pmksa, ssid,
432 * pmksa_cache_list - Dump text list of entries in PMKSA cache
439 * current PMKSA cache contents for the ctrl_iface PMKSA command.
456 entry = sm->pmksa->pmksa;
479 * pmksa_cache_init - Initialize PMKSA cache
480 * @free_cb: Callback function to be called when a PMKSA cache entry is freed
483 * Returns: Pointer to PMKSA cache data or %NULL on failure
490 struct rsn_pmksa_cache *pmksa;
492 pmksa = os_zalloc(sizeof(*pmksa));
493 if (pmksa) {
494 pmksa->free_cb = free_cb;
495 pmksa->ctx = ctx;
496 pmksa->sm = sm;
499 return pmksa;