wpa_supplicant / hostapd  2.5
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Data Structures | Functions
pmksa_cache.c File Reference

WPA Supplicant - RSN PMKSA cache. More...

#include "includes.h"
#include "common.h"
#include "eloop.h"
#include "eapol_supp/eapol_supp_sm.h"
#include "wpa.h"
#include "wpa_i.h"
#include "pmksa_cache.h"

Data Structures

struct  rsn_pmksa_cache
 

Functions

struct rsn_pmksa_cache_entrypmksa_cache_add (struct rsn_pmksa_cache *pmksa, const u8 *pmk, size_t pmk_len, const u8 *kck, size_t kck_len, const u8 *aa, const u8 *spa, void *network_ctx, int akmp)
 Add a PMKSA cache entry. More...
 
void pmksa_cache_flush (struct rsn_pmksa_cache *pmksa, void *network_ctx, const u8 *pmk, size_t pmk_len)
 Flush PMKSA cache entries for a specific network. More...
 
void pmksa_cache_deinit (struct rsn_pmksa_cache *pmksa)
 Free all entries in PMKSA cache. More...
 
struct rsn_pmksa_cache_entrypmksa_cache_get (struct rsn_pmksa_cache *pmksa, const u8 *aa, const u8 *pmkid, const void *network_ctx)
 Fetch a PMKSA cache entry. More...
 
struct rsn_pmksa_cache_entrypmksa_cache_get_opportunistic (struct rsn_pmksa_cache *pmksa, void *network_ctx, const u8 *aa)
 Try to get an opportunistic PMKSA entry. More...
 
struct rsn_pmksa_cache_entrypmksa_cache_get_current (struct wpa_sm *sm)
 Get the current used PMKSA entry. More...
 
void pmksa_cache_clear_current (struct wpa_sm *sm)
 Clear the current PMKSA entry selection. More...
 
int pmksa_cache_set_current (struct wpa_sm *sm, const u8 *pmkid, const u8 *bssid, void *network_ctx, int try_opportunistic)
 Set the current PMKSA entry selection. More...
 
int pmksa_cache_list (struct rsn_pmksa_cache *pmksa, char *buf, size_t len)
 Dump text list of entries in PMKSA cache. More...
 
struct rsn_pmksa_cachepmksa_cache_init (void(*free_cb)(struct rsn_pmksa_cache_entry *entry, void *ctx, enum pmksa_free_reason reason), void *ctx, struct wpa_sm *sm)
 Initialize PMKSA cache. More...
 

Detailed Description

WPA Supplicant - RSN PMKSA cache.

Function Documentation

struct rsn_pmksa_cache_entry* pmksa_cache_add ( struct rsn_pmksa_cache pmksa,
const u8 *  pmk,
size_t  pmk_len,
const u8 *  kck,
size_t  kck_len,
const u8 *  aa,
const u8 *  spa,
void *  network_ctx,
int  akmp 
)

Add a PMKSA cache entry.

Parameters
pmksaPointer to PMKSA cache data from pmksa_cache_init()
pmkThe new pairwise master key
pmk_lenPMK length in bytes, usually PMK_LEN (32)
kckKey confirmation key or NULL if not yet derived
kck_lenKCK length in bytes
aaAuthenticator address
spaSupplicant address
network_ctxNetwork configuration context for this PMK
akmpWPA_KEY_MGMT_* used in key derivation
Returns
Pointer to the added PMKSA cache entry or NULL on error

This function create a PMKSA entry for a new PMK and adds it to the PMKSA cache. If an old entry is already in the cache for the same Authenticator, this entry will be replaced with the new entry. PMKID will be calculated based on the PMK and the driver interface is notified of the new PMKID.

void pmksa_cache_clear_current ( struct wpa_sm sm)

Clear the current PMKSA entry selection.

Parameters
smPointer to WPA state machine data from wpa_sm_init()
void pmksa_cache_deinit ( struct rsn_pmksa_cache pmksa)

Free all entries in PMKSA cache.

Parameters
pmksaPointer to PMKSA cache data from pmksa_cache_init()
void pmksa_cache_flush ( struct rsn_pmksa_cache pmksa,
void *  network_ctx,
const u8 *  pmk,
size_t  pmk_len 
)

Flush PMKSA cache entries for a specific network.

Parameters
pmksaPointer to PMKSA cache data from pmksa_cache_init()
network_ctxNetwork configuration context or NULL to flush all entries
pmkPMK to match for or NYLL to match all PMKs
pmk_lenPMK length
struct rsn_pmksa_cache_entry* pmksa_cache_get ( struct rsn_pmksa_cache pmksa,
const u8 *  aa,
const u8 *  pmkid,
const void *  network_ctx 
)

Fetch a PMKSA cache entry.

Parameters
pmksaPointer to PMKSA cache data from pmksa_cache_init()
aaAuthenticator address or NULL to match any
pmkidPMKID or NULL to match any
network_ctxNetwork context or NULL to match any
Returns
Pointer to PMKSA cache entry or NULL if no match was found
struct rsn_pmksa_cache_entry* pmksa_cache_get_current ( struct wpa_sm sm)

Get the current used PMKSA entry.

Parameters
smPointer to WPA state machine data from wpa_sm_init()
Returns
Pointer to the current PMKSA cache entry or NULL if not available
struct rsn_pmksa_cache_entry* pmksa_cache_get_opportunistic ( struct rsn_pmksa_cache pmksa,
void *  network_ctx,
const u8 *  aa 
)

Try to get an opportunistic PMKSA entry.

Parameters
pmksaPointer to PMKSA cache data from pmksa_cache_init()
network_ctxNetwork configuration context
aaAuthenticator address for the new AP
Returns
Pointer to a new PMKSA cache entry or NULL if not available

Try to create a new PMKSA cache entry opportunistically by guessing that the new AP is sharing the same PMK as another AP that has the same SSID and has already an entry in PMKSA cache.

struct rsn_pmksa_cache* pmksa_cache_init ( void(*)(struct rsn_pmksa_cache_entry *entry, void *ctx, enum pmksa_free_reason reason)  free_cb,
void *  ctx,
struct wpa_sm sm 
)

Initialize PMKSA cache.

Parameters
free_cbCallback function to be called when a PMKSA cache entry is freed
ctxContext pointer for free_cb function
smPointer to WPA state machine data from wpa_sm_init()
Returns
Pointer to PMKSA cache data or NULL on failure
int pmksa_cache_list ( struct rsn_pmksa_cache pmksa,
char *  buf,
size_t  len 
)

Dump text list of entries in PMKSA cache.

Parameters
pmksaPointer to PMKSA cache data from pmksa_cache_init()
bufBuffer for the list
lenLength of the buffer
Returns
number of bytes written to buffer

This function is used to generate a text format representation of the current PMKSA cache contents for the ctrl_iface PMKSA command.

int pmksa_cache_set_current ( struct wpa_sm sm,
const u8 *  pmkid,
const u8 *  bssid,
void *  network_ctx,
int  try_opportunistic 
)

Set the current PMKSA entry selection.

Parameters
smPointer to WPA state machine data from wpa_sm_init()
pmkidPMKID for selecting PMKSA or NULL if not used
bssidBSSID for PMKSA or NULL if not used
network_ctxNetwork configuration context
try_opportunisticWhether to allow opportunistic PMKSA caching
Returns
0 if PMKSA was found or -1 if no matching entry was found