]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
Helper functions for fetching PMK and PMKID
authorShivani Baranwal <quic_shivbara@quicinc.com>
Mon, 5 Aug 2024 06:33:44 +0000 (12:03 +0530)
committerJouni Malinen <j@w1.fi>
Tue, 19 Nov 2024 21:46:22 +0000 (23:46 +0200)
These are needed to avoid direct use of struct rsn_pmksa_cache_entry
which is defined differently for Authenticator and Supplicant.

Signed-off-by: Shivani Baranwal <quic_shivbara@quicinc.com>
src/ap/wpa_auth.c
src/ap/wpa_auth.h
src/rsn_supp/wpa.c
src/rsn_supp/wpa.h

index d067b2cfab29d9e602435071c3a4a11a114d846f..5de4e09b7ffaff948c64734ee621b50bf8a4152a 100644 (file)
@@ -6603,6 +6603,26 @@ wpa_auth_pmksa_get(struct wpa_authenticator *wpa_auth, const u8 *sta_addr,
 }
 
 
+int wpa_auth_pmksa_get_pmk(struct wpa_authenticator *wpa_auth,
+                          const u8 *sta_addr, const u8 **pmk, size_t *pmk_len,
+                          const u8 **pmkid)
+{
+       struct rsn_pmksa_cache_entry *pmksa;
+
+       pmksa = wpa_auth_pmksa_get(wpa_auth, sta_addr, NULL);
+       if (!pmksa) {
+               wpa_printf(MSG_DEBUG, "RSN: Failed to get PMKSA for " MACSTR,
+                          MAC2STR(sta_addr));
+               return -1;
+       }
+
+       *pmk = pmksa->pmk;
+       *pmk_len = pmksa->pmk_len;
+       *pmkid = pmksa->pmkid;
+       return 0;
+}
+
+
 void wpa_auth_pmksa_set_to_sm(struct rsn_pmksa_cache_entry *pmksa,
                              struct wpa_state_machine *sm,
                              struct wpa_authenticator *wpa_auth,
index 82d09f097291b86ebe46593bc7e0097cd0418927..9514e55b7f557118cabead35ec2e7f8d5948cbe4 100644 (file)
@@ -529,6 +529,9 @@ wpa_auth_get_pmksa_cache(struct wpa_authenticator *wpa_auth);
 struct rsn_pmksa_cache_entry *
 wpa_auth_pmksa_get(struct wpa_authenticator *wpa_auth, const u8 *sta_addr,
                   const u8 *pmkid);
+int wpa_auth_pmksa_get_pmk(struct wpa_authenticator *wpa_auth,
+                          const u8 *sta_addr, const u8 **pmk, size_t *pmk_len,
+                          const u8 **pmkid);
 struct rsn_pmksa_cache_entry *
 wpa_auth_pmksa_get_fils_cache_id(struct wpa_authenticator *wpa_auth,
                                 const u8 *sta_addr, const u8 *pmkid);
index e127093ca8ed3a447d5f1ccaf6eaa699c0474a23..9e4b0b219eda74f36d370ba1afc1ba4d05be9005 100644 (file)
@@ -5648,6 +5648,25 @@ struct rsn_pmksa_cache_entry * wpa_sm_pmksa_cache_get(struct wpa_sm *sm,
 }
 
 
+int wpa_sm_pmksa_get_pmk(struct wpa_sm *sm, const u8 *aa, const u8 **pmk,
+                        size_t *pmk_len, const u8 **pmkid)
+{
+       struct rsn_pmksa_cache_entry *pmksa;
+
+       pmksa = wpa_sm_pmksa_cache_get(sm, aa, NULL, NULL, 0);
+       if (!pmksa) {
+               wpa_printf(MSG_DEBUG, "RSN: Failed to get PMKSA for " MACSTR,
+                          MAC2STR(aa));
+               return -1;
+       }
+
+       *pmk = pmksa->pmk;
+       *pmk_len = pmksa->pmk_len;
+       *pmkid = pmksa->pmkid;
+       return 0;
+}
+
+
 void wpa_sm_pmksa_cache_remove(struct wpa_sm *sm,
                               struct rsn_pmksa_cache_entry *entry)
 {
index 57ee0a63532f49a49a58f3467106f2a997bad755..a4a32ed284e8dd656ad716fa1e81dab90ef5dcee 100644 (file)
@@ -256,6 +256,8 @@ struct rsn_pmksa_cache_entry * wpa_sm_pmksa_cache_get(struct wpa_sm *sm,
                                                      const u8 *pmkid,
                                                      const void *network_ctx,
                                                      int akmp);
+int wpa_sm_pmksa_get_pmk(struct wpa_sm *sm, const u8 *aa, const u8 **pmk,
+                        size_t *pmk_len, const u8 **pmkid);
 void wpa_sm_pmksa_cache_remove(struct wpa_sm *sm,
                               struct rsn_pmksa_cache_entry *entry);
 bool wpa_sm_has_ft_keys(struct wpa_sm *sm, const u8 *md);