diff mbox series

[10/15] handshake: add handshake_state_remove_pmksa

Message ID 20241122151551.286355-11-prestwoj@gmail.com (mailing list archive)
State New
Headers show
Series PMKSA support (SAE only) | expand

Checks

Context Check Description
tedd_an/pre-ci_am success Success
prestwoj/iwd-ci-gitlint success GitLint

Commit Message

James Prestwood Nov. 22, 2024, 3:15 p.m. UTC
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 mbox series

Patch

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 cf7dc48c..e4a00531 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);