139beb93cSSam Leffler /* 239beb93cSSam Leffler * wpa_supplicant - WPA2/RSN PMKSA cache functions 3f05cddf9SRui Paulo * Copyright (c) 2003-2009, 2011-2012, Jouni Malinen <j@w1.fi> 439beb93cSSam Leffler * 5f05cddf9SRui Paulo * This software may be distributed under the terms of the BSD license. 6f05cddf9SRui Paulo * See README for more details. 739beb93cSSam Leffler */ 839beb93cSSam Leffler 939beb93cSSam Leffler #ifndef PMKSA_CACHE_H 1039beb93cSSam Leffler #define PMKSA_CACHE_H 1139beb93cSSam Leffler 1239beb93cSSam Leffler /** 1339beb93cSSam Leffler * struct rsn_pmksa_cache_entry - PMKSA cache entry 1439beb93cSSam Leffler */ 1539beb93cSSam Leffler struct rsn_pmksa_cache_entry { 1639beb93cSSam Leffler struct rsn_pmksa_cache_entry *next; 1739beb93cSSam Leffler u8 pmkid[PMKID_LEN]; 18780fb4a2SCy Schubert u8 pmk[PMK_LEN_MAX]; 1939beb93cSSam Leffler size_t pmk_len; 20*a90b9d01SCy Schubert u8 kck[WPA_KCK_MAX_LEN]; 21*a90b9d01SCy Schubert size_t kck_len; 2239beb93cSSam Leffler os_time_t expiration; 2339beb93cSSam Leffler int akmp; /* WPA_KEY_MGMT_* */ 2439beb93cSSam Leffler u8 aa[ETH_ALEN]; 25*a90b9d01SCy Schubert u8 spa[ETH_ALEN]; 2639beb93cSSam Leffler 2785732ac8SCy Schubert /* 2885732ac8SCy Schubert * If FILS Cache Identifier is included (fils_cache_id_set), this PMKSA 2985732ac8SCy Schubert * cache entry is applicable to all BSSs (any BSSID/aa[]) that 3085732ac8SCy Schubert * advertise the same FILS Cache Identifier within the same ESS. 3185732ac8SCy Schubert */ 3285732ac8SCy Schubert u8 fils_cache_id[2]; 3385732ac8SCy Schubert unsigned int fils_cache_id_set:1; 34c1d255d3SCy Schubert unsigned int dpp_pfs:1; 3585732ac8SCy Schubert 3639beb93cSSam Leffler os_time_t reauth_time; 3739beb93cSSam Leffler 3839beb93cSSam Leffler /** 3939beb93cSSam Leffler * network_ctx - Network configuration context 4039beb93cSSam Leffler * 4139beb93cSSam Leffler * This field is only used to match PMKSA cache entries to a specific 4239beb93cSSam Leffler * network configuration (e.g., a specific SSID and security policy). 4339beb93cSSam Leffler * This can be a pointer to the configuration entry, but PMKSA caching 4439beb93cSSam Leffler * code does not dereference the value and this could be any kind of 4539beb93cSSam Leffler * identifier. 4639beb93cSSam Leffler */ 4739beb93cSSam Leffler void *network_ctx; 4839beb93cSSam Leffler int opportunistic; 49c1d255d3SCy Schubert bool external; 50*a90b9d01SCy Schubert 51*a90b9d01SCy Schubert /** 52*a90b9d01SCy Schubert * This field is used to avoid duplicate pmksa_cache_reauth() calls for 53*a90b9d01SCy Schubert * every 10 minutes during the periodic expiration check of the current 54*a90b9d01SCy Schubert * PMKSA for SAE. 55*a90b9d01SCy Schubert */ 56*a90b9d01SCy Schubert bool sae_reauth_scheduled; 5739beb93cSSam Leffler }; 5839beb93cSSam Leffler 5939beb93cSSam Leffler struct rsn_pmksa_cache; 6039beb93cSSam Leffler 61f05cddf9SRui Paulo enum pmksa_free_reason { 62f05cddf9SRui Paulo PMKSA_FREE, 63f05cddf9SRui Paulo PMKSA_REPLACE, 64f05cddf9SRui Paulo PMKSA_EXPIRE, 65f05cddf9SRui Paulo }; 66f05cddf9SRui Paulo 6739beb93cSSam Leffler struct rsn_pmksa_cache * 6839beb93cSSam Leffler pmksa_cache_init(void (*free_cb)(struct rsn_pmksa_cache_entry *entry, 69f05cddf9SRui Paulo void *ctx, enum pmksa_free_reason reason), 704b72b91aSCy Schubert bool (*is_current_cb)(struct rsn_pmksa_cache_entry *entry, 714b72b91aSCy Schubert void *ctx), 72*a90b9d01SCy Schubert void (*notify_cb)(struct rsn_pmksa_cache_entry *entry, 73*a90b9d01SCy Schubert void *ctx), 7439beb93cSSam Leffler void *ctx, struct wpa_sm *sm); 7539beb93cSSam Leffler void pmksa_cache_deinit(struct rsn_pmksa_cache *pmksa); 7639beb93cSSam Leffler struct rsn_pmksa_cache_entry * pmksa_cache_get(struct rsn_pmksa_cache *pmksa, 77*a90b9d01SCy Schubert const u8 *aa, const u8 *spa, 78*a90b9d01SCy Schubert const u8 *pmkid, 7985732ac8SCy Schubert const void *network_ctx, 8085732ac8SCy Schubert int akmp); 81e28a4053SRui Paulo int pmksa_cache_list(struct rsn_pmksa_cache *pmksa, char *buf, size_t len); 8285732ac8SCy Schubert struct rsn_pmksa_cache_entry * pmksa_cache_head(struct rsn_pmksa_cache *pmksa); 8339beb93cSSam Leffler struct rsn_pmksa_cache_entry * 8439beb93cSSam Leffler pmksa_cache_add(struct rsn_pmksa_cache *pmksa, const u8 *pmk, size_t pmk_len, 85780fb4a2SCy Schubert const u8 *pmkid, const u8 *kck, size_t kck_len, 8685732ac8SCy Schubert const u8 *aa, const u8 *spa, void *network_ctx, int akmp, 8785732ac8SCy Schubert const u8 *cache_id); 8885732ac8SCy Schubert struct rsn_pmksa_cache_entry * 8985732ac8SCy Schubert pmksa_cache_add_entry(struct rsn_pmksa_cache *pmksa, 9085732ac8SCy Schubert struct rsn_pmksa_cache_entry *entry); 9139beb93cSSam Leffler struct rsn_pmksa_cache_entry * pmksa_cache_get_current(struct wpa_sm *sm); 9239beb93cSSam Leffler void pmksa_cache_clear_current(struct wpa_sm *sm); 9339beb93cSSam Leffler int pmksa_cache_set_current(struct wpa_sm *sm, const u8 *pmkid, 9439beb93cSSam Leffler const u8 *bssid, void *network_ctx, 9585732ac8SCy Schubert int try_opportunistic, const u8 *fils_cache_id, 96*a90b9d01SCy Schubert int akmp, bool associated); 9739beb93cSSam Leffler struct rsn_pmksa_cache_entry * 9839beb93cSSam Leffler pmksa_cache_get_opportunistic(struct rsn_pmksa_cache *pmksa, 9985732ac8SCy Schubert void *network_ctx, const u8 *aa, int akmp); 1005b9c547cSRui Paulo void pmksa_cache_flush(struct rsn_pmksa_cache *pmksa, void *network_ctx, 101c1d255d3SCy Schubert const u8 *pmk, size_t pmk_len, bool external_only); 102*a90b9d01SCy Schubert void pmksa_cache_remove(struct rsn_pmksa_cache *pmksa, 103*a90b9d01SCy Schubert struct rsn_pmksa_cache_entry *entry); 1044b72b91aSCy Schubert void pmksa_cache_reconfig(struct rsn_pmksa_cache *pmksa); 10539beb93cSSam Leffler 10639beb93cSSam Leffler #endif /* PMKSA_CACHE_H */ 107