Add a callback to notify added PMKSA cache entry details
Add a callback handler to notify details of a PMKSA cache entry when it is added to the PMKSA cache. This can be used to provide external components more convenient access to the PMKSA cache contents. Signed-off-by: Jouni Malinen <quic_jouni@quicinc.com>
This commit is contained in:
parent
e174ec7a07
commit
46e6b72b7b
8 changed files with 55 additions and 1 deletions
|
@ -28,6 +28,7 @@ struct rsn_pmksa_cache {
|
||||||
enum pmksa_free_reason reason);
|
enum pmksa_free_reason reason);
|
||||||
bool (*is_current_cb)(struct rsn_pmksa_cache_entry *entry,
|
bool (*is_current_cb)(struct rsn_pmksa_cache_entry *entry,
|
||||||
void *ctx);
|
void *ctx);
|
||||||
|
void (*notify_cb)(struct rsn_pmksa_cache_entry *entry, void *ctx);
|
||||||
void *ctx;
|
void *ctx;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -360,6 +361,9 @@ pmksa_cache_add_entry(struct rsn_pmksa_cache *pmksa,
|
||||||
if (!pmksa->sm)
|
if (!pmksa->sm)
|
||||||
return entry;
|
return entry;
|
||||||
|
|
||||||
|
if (pmksa->notify_cb)
|
||||||
|
pmksa->notify_cb(entry, pmksa->ctx);
|
||||||
|
|
||||||
wpa_sm_add_pmkid(pmksa->sm, entry->network_ctx, entry->aa, entry->pmkid,
|
wpa_sm_add_pmkid(pmksa->sm, entry->network_ctx, entry->aa, entry->pmkid,
|
||||||
entry->fils_cache_id_set ? entry->fils_cache_id : NULL,
|
entry->fils_cache_id_set ? entry->fils_cache_id : NULL,
|
||||||
entry->pmk, entry->pmk_len,
|
entry->pmk, entry->pmk_len,
|
||||||
|
@ -754,6 +758,8 @@ pmksa_cache_init(void (*free_cb)(struct rsn_pmksa_cache_entry *entry,
|
||||||
void *ctx, enum pmksa_free_reason reason),
|
void *ctx, enum pmksa_free_reason reason),
|
||||||
bool (*is_current_cb)(struct rsn_pmksa_cache_entry *entry,
|
bool (*is_current_cb)(struct rsn_pmksa_cache_entry *entry,
|
||||||
void *ctx),
|
void *ctx),
|
||||||
|
void (*notify_cb)(struct rsn_pmksa_cache_entry *entry,
|
||||||
|
void *ctx),
|
||||||
void *ctx, struct wpa_sm *sm)
|
void *ctx, struct wpa_sm *sm)
|
||||||
{
|
{
|
||||||
struct rsn_pmksa_cache *pmksa;
|
struct rsn_pmksa_cache *pmksa;
|
||||||
|
@ -762,6 +768,7 @@ pmksa_cache_init(void (*free_cb)(struct rsn_pmksa_cache_entry *entry,
|
||||||
if (pmksa) {
|
if (pmksa) {
|
||||||
pmksa->free_cb = free_cb;
|
pmksa->free_cb = free_cb;
|
||||||
pmksa->is_current_cb = is_current_cb;
|
pmksa->is_current_cb = is_current_cb;
|
||||||
|
pmksa->notify_cb = notify_cb;
|
||||||
pmksa->ctx = ctx;
|
pmksa->ctx = ctx;
|
||||||
pmksa->sm = sm;
|
pmksa->sm = sm;
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,6 +62,8 @@ pmksa_cache_init(void (*free_cb)(struct rsn_pmksa_cache_entry *entry,
|
||||||
void *ctx, enum pmksa_free_reason reason),
|
void *ctx, enum pmksa_free_reason reason),
|
||||||
bool (*is_current_cb)(struct rsn_pmksa_cache_entry *entry,
|
bool (*is_current_cb)(struct rsn_pmksa_cache_entry *entry,
|
||||||
void *ctx),
|
void *ctx),
|
||||||
|
void (*notify_cb)(struct rsn_pmksa_cache_entry *entry,
|
||||||
|
void *ctx),
|
||||||
void *ctx, struct wpa_sm *sm);
|
void *ctx, struct wpa_sm *sm);
|
||||||
void pmksa_cache_deinit(struct rsn_pmksa_cache *pmksa);
|
void pmksa_cache_deinit(struct rsn_pmksa_cache *pmksa);
|
||||||
struct rsn_pmksa_cache_entry * pmksa_cache_get(struct rsn_pmksa_cache *pmksa,
|
struct rsn_pmksa_cache_entry * pmksa_cache_get(struct rsn_pmksa_cache *pmksa,
|
||||||
|
@ -101,6 +103,8 @@ pmksa_cache_init(void (*free_cb)(struct rsn_pmksa_cache_entry *entry,
|
||||||
void *ctx, enum pmksa_free_reason reason),
|
void *ctx, enum pmksa_free_reason reason),
|
||||||
bool (*is_current_cb)(struct rsn_pmksa_cache_entry *entry,
|
bool (*is_current_cb)(struct rsn_pmksa_cache_entry *entry,
|
||||||
void *ctx),
|
void *ctx),
|
||||||
|
void (*notify_cb)(struct rsn_pmksa_cache_entry *entry,
|
||||||
|
void *ctx),
|
||||||
void *ctx, struct wpa_sm *sm)
|
void *ctx, struct wpa_sm *sm)
|
||||||
{
|
{
|
||||||
return (void *) -1;
|
return (void *) -1;
|
||||||
|
|
|
@ -3969,6 +3969,15 @@ static bool wpa_sm_pmksa_is_current_cb(struct rsn_pmksa_cache_entry *entry,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void wpa_sm_pmksa_notify_cb(struct rsn_pmksa_cache_entry *entry,
|
||||||
|
void *ctx)
|
||||||
|
{
|
||||||
|
struct wpa_sm *sm = ctx;
|
||||||
|
|
||||||
|
wpa_sm_notify_pmksa_cache_entry(sm, entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* wpa_sm_init - Initialize WPA state machine
|
* wpa_sm_init - Initialize WPA state machine
|
||||||
* @ctx: Context pointer for callbacks; this needs to be an allocated buffer
|
* @ctx: Context pointer for callbacks; this needs to be an allocated buffer
|
||||||
|
@ -3993,7 +4002,8 @@ struct wpa_sm * wpa_sm_init(struct wpa_sm_ctx *ctx)
|
||||||
sm->dot11RSNAConfigSATimeout = 60;
|
sm->dot11RSNAConfigSATimeout = 60;
|
||||||
|
|
||||||
sm->pmksa = pmksa_cache_init(wpa_sm_pmksa_free_cb,
|
sm->pmksa = pmksa_cache_init(wpa_sm_pmksa_free_cb,
|
||||||
wpa_sm_pmksa_is_current_cb, sm, sm);
|
wpa_sm_pmksa_is_current_cb,
|
||||||
|
wpa_sm_pmksa_notify_cb, sm, sm);
|
||||||
if (sm->pmksa == NULL) {
|
if (sm->pmksa == NULL) {
|
||||||
wpa_msg(sm->ctx->msg_ctx, MSG_ERROR,
|
wpa_msg(sm->ctx->msg_ctx, MSG_ERROR,
|
||||||
"RSN: PMKSA cache initialization failed");
|
"RSN: PMKSA cache initialization failed");
|
||||||
|
|
|
@ -19,6 +19,7 @@ struct eapol_sm;
|
||||||
struct wpa_config_blob;
|
struct wpa_config_blob;
|
||||||
struct hostapd_freq_params;
|
struct hostapd_freq_params;
|
||||||
struct wpa_channel_info;
|
struct wpa_channel_info;
|
||||||
|
struct rsn_pmksa_cache_entry;
|
||||||
enum frame_encryption;
|
enum frame_encryption;
|
||||||
|
|
||||||
struct wpa_sm_ctx {
|
struct wpa_sm_ctx {
|
||||||
|
@ -98,6 +99,8 @@ struct wpa_sm_ctx {
|
||||||
const u8 *peer_addr, size_t ltf_keyseed_len,
|
const u8 *peer_addr, size_t ltf_keyseed_len,
|
||||||
const u8 *ltf_keyseed);
|
const u8 *ltf_keyseed);
|
||||||
#endif /* CONFIG_PASN */
|
#endif /* CONFIG_PASN */
|
||||||
|
void (*notify_pmksa_cache_entry)(void *ctx,
|
||||||
|
struct rsn_pmksa_cache_entry *entry);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -497,6 +497,14 @@ static inline int wpa_sm_set_ltf_keyseed(struct wpa_sm *sm, const u8 *own_addr,
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_PASN */
|
#endif /* CONFIG_PASN */
|
||||||
|
|
||||||
|
static inline void
|
||||||
|
wpa_sm_notify_pmksa_cache_entry(struct wpa_sm *sm,
|
||||||
|
struct rsn_pmksa_cache_entry *entry)
|
||||||
|
{
|
||||||
|
if (sm->ctx->notify_pmksa_cache_entry)
|
||||||
|
sm->ctx->notify_pmksa_cache_entry(sm->ctx->ctx, entry);
|
||||||
|
}
|
||||||
|
|
||||||
int wpa_eapol_key_send(struct wpa_sm *sm, struct wpa_ptk *ptk,
|
int wpa_eapol_key_send(struct wpa_sm *sm, struct wpa_ptk *ptk,
|
||||||
int ver, const u8 *dest, u16 proto,
|
int ver, const u8 *dest, u16 proto,
|
||||||
u8 *msg, size_t msg_len, u8 *key_mic);
|
u8 *msg, size_t msg_len, u8 *key_mic);
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
#include "dbus/dbus_common.h"
|
#include "dbus/dbus_common.h"
|
||||||
#include "dbus/dbus_new.h"
|
#include "dbus/dbus_new.h"
|
||||||
#include "rsn_supp/wpa.h"
|
#include "rsn_supp/wpa.h"
|
||||||
|
#include "rsn_supp/pmksa_cache.h"
|
||||||
#include "fst/fst.h"
|
#include "fst/fst.h"
|
||||||
#include "crypto/tls.h"
|
#include "crypto/tls.h"
|
||||||
#include "bss.h"
|
#include "bss.h"
|
||||||
|
@ -976,3 +977,10 @@ void wpas_notify_interworking_select_done(struct wpa_supplicant *wpa_s)
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* CONFIG_INTERWORKING */
|
#endif /* CONFIG_INTERWORKING */
|
||||||
|
|
||||||
|
|
||||||
|
void wpas_notify_pmk_cache_added(struct wpa_supplicant *wpa_s,
|
||||||
|
struct rsn_pmksa_cache_entry *entry)
|
||||||
|
{
|
||||||
|
/* TODO: Notify external entities of the added PMKSA cache entry */
|
||||||
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@ struct wps_event_m2d;
|
||||||
struct wps_event_fail;
|
struct wps_event_fail;
|
||||||
struct tls_cert_data;
|
struct tls_cert_data;
|
||||||
struct wpa_cred;
|
struct wpa_cred;
|
||||||
|
struct rsn_pmksa_cache_entry;
|
||||||
|
|
||||||
int wpas_notify_supplicant_initialized(struct wpa_global *global);
|
int wpas_notify_supplicant_initialized(struct wpa_global *global);
|
||||||
void wpas_notify_supplicant_deinitialized(struct wpa_global *global);
|
void wpas_notify_supplicant_deinitialized(struct wpa_global *global);
|
||||||
|
@ -163,5 +164,7 @@ void wpas_notify_interworking_ap_added(struct wpa_supplicant *wpa_s,
|
||||||
const char *type, int bh, int bss_load,
|
const char *type, int bh, int bss_load,
|
||||||
int conn_capab);
|
int conn_capab);
|
||||||
void wpas_notify_interworking_select_done(struct wpa_supplicant *wpa_s);
|
void wpas_notify_interworking_select_done(struct wpa_supplicant *wpa_s);
|
||||||
|
void wpas_notify_pmk_cache_added(struct wpa_supplicant *wpa_s,
|
||||||
|
struct rsn_pmksa_cache_entry *entry);
|
||||||
|
|
||||||
#endif /* NOTIFY_H */
|
#endif /* NOTIFY_H */
|
||||||
|
|
|
@ -1381,6 +1381,16 @@ static int wpa_supplicant_set_ltf_keyseed(void *_wpa_s, const u8 *own_addr,
|
||||||
#endif /* CONFIG_PASN */
|
#endif /* CONFIG_PASN */
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
wpa_supplicant_notify_pmksa_cache_entry(void *_wpa_s,
|
||||||
|
struct rsn_pmksa_cache_entry *entry)
|
||||||
|
{
|
||||||
|
struct wpa_supplicant *wpa_s = _wpa_s;
|
||||||
|
|
||||||
|
wpas_notify_pmk_cache_added(wpa_s, entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int wpa_supplicant_init_wpa(struct wpa_supplicant *wpa_s)
|
int wpa_supplicant_init_wpa(struct wpa_supplicant *wpa_s)
|
||||||
{
|
{
|
||||||
#ifndef CONFIG_NO_WPA
|
#ifndef CONFIG_NO_WPA
|
||||||
|
@ -1446,6 +1456,7 @@ int wpa_supplicant_init_wpa(struct wpa_supplicant *wpa_s)
|
||||||
#ifdef CONFIG_PASN
|
#ifdef CONFIG_PASN
|
||||||
ctx->set_ltf_keyseed = wpa_supplicant_set_ltf_keyseed;
|
ctx->set_ltf_keyseed = wpa_supplicant_set_ltf_keyseed;
|
||||||
#endif /* CONFIG_PASN */
|
#endif /* CONFIG_PASN */
|
||||||
|
ctx->notify_pmksa_cache_entry = wpa_supplicant_notify_pmksa_cache_entry;
|
||||||
|
|
||||||
wpa_s->wpa = wpa_sm_init(ctx);
|
wpa_s->wpa = wpa_sm_init(ctx);
|
||||||
if (wpa_s->wpa == NULL) {
|
if (wpa_s->wpa == NULL) {
|
||||||
|
|
Loading…
Reference in a new issue