From 4680c0c13bf86abedf0ca204999018570a3acb0d Mon Sep 17 00:00:00 2001 From: James Prestwood Date: Fri, 22 Nov 2024 07:15:46 -0800 Subject: [PATCH] handshake: add handshake_state_remove_pmksa This is needed in order to clear the PMKSA from the handshake state without actually putting it back into the cache. This is something that will be needed in case the AP rejects the association due to an expired (or forgotten) PMKSA. --- src/handshake.c | 16 ++++++++++++++++ src/handshake.h | 1 + 2 files changed, 17 insertions(+) diff --git a/src/handshake.c b/src/handshake.c index a93143d1..f73f91d1 100644 --- a/src/handshake.c +++ b/src/handshake.c @@ -1280,3 +1280,19 @@ void handshake_state_cache_pmksa(struct handshake_state *s) if (L_WARN_ON(pmksa_cache_put(pmksa) < 0)) l_free(pmksa); } + +bool handshake_state_remove_pmksa(struct handshake_state *s) +{ + struct pmksa *pmksa; + + if (!s->have_pmksa) + return false; + + pmksa = handshake_state_steal_pmksa(s); + if (!pmksa) + return false; + + l_free(pmksa); + + return true; +} diff --git a/src/handshake.h b/src/handshake.h index c79fc061..c6e3c10b 100644 --- a/src/handshake.h +++ b/src/handshake.h @@ -310,6 +310,7 @@ int handshake_state_verify_oci(struct handshake_state *s, const uint8_t *oci, bool handshake_state_set_pmksa(struct handshake_state *s, struct pmksa *pmksa); void handshake_state_cache_pmksa(struct handshake_state *s); +bool handshake_state_remove_pmksa(struct handshake_state *s); bool handshake_util_ap_ie_matches(const struct ie_rsn_info *msg_info, const uint8_t *scan_ie, bool is_wpa);