[RFC 18/30] WPA: SMD: Add support for installing a target AP MLD TK
Ilan Peer
ilan.peer at intel.com
Wed Oct 21 06:43:36 PDT 2026
Add support for installing a target AP MLD TK.
Signed-off-by: Ilan Peer <ilan.peer at intel.com>
---
src/rsn_supp/wpa.c | 65 ++++++++++++++++++++++++++++++++++++++++++++++
src/rsn_supp/wpa.h | 2 ++
2 files changed, 67 insertions(+)
diff --git a/src/rsn_supp/wpa.c b/src/rsn_supp/wpa.c
index 1f129a3595a8..5c032e0c5819 100644
--- a/src/rsn_supp/wpa.c
+++ b/src/rsn_supp/wpa.c
@@ -8320,3 +8320,68 @@ int wpa_sm_smd_set_tptk_to_ptk(struct wpa_sm *sm)
return 0;
}
+
+
+static int wpa_sm_smd_install_tk(struct wpa_sm *sm, const u8 *aa,
+ const struct wpa_ptk *ptk, const char *ptk_str)
+{
+ enum wpa_alg alg;
+ int keylen, rsclen;
+
+ if (sm->pairwise_cipher == WPA_CIPHER_NONE ||
+ !wpa_cipher_valid_pairwise(sm->pairwise_cipher)) {
+ wpa_printf(MSG_DEBUG,
+ "SMD: Unsupported pairwise cipher %d for PTK install",
+ sm->pairwise_cipher);
+ return -1;
+ }
+
+ alg = wpa_cipher_to_alg(sm->pairwise_cipher);
+ keylen = wpa_cipher_key_len(sm->pairwise_cipher);
+ if (keylen <= 0 || (unsigned int)keylen != ptk->tk_len) {
+ wpa_printf(MSG_DEBUG,
+ "SMD: TK length mismatch: %d != %zu",
+ keylen, ptk->tk_len);
+ return -1;
+ }
+
+ rsclen = wpa_cipher_rsc_len(sm->pairwise_cipher);
+
+ wpa_printf(MSG_DEBUG,
+ "SMD: Installing %s PTK to the driver (" MACSTR ")",
+ ptk_str, MAC2STR(aa));
+
+ if (wpa_sm_set_key(sm, -1, alg, aa, sm->keyidx_active,
+ 1, null_rsc, rsclen,
+ ptk->tk, keylen,
+ KEY_FLAG_PAIRWISE | KEY_FLAG_RX_TX) < 0) {
+ wpa_printf(MSG_DEBUG,
+ "SMD: Failed to install %s PTK to the driver (alg=%d keylen=%d addr=" MACSTR " idx=%d)",
+ ptk_str, alg, keylen, MAC2STR(aa), sm->keyidx_active);
+ return -1;
+ }
+
+ return 0;
+}
+
+
+int wpa_sm_smd_install_tptk(struct wpa_sm *sm, const u8 *aa)
+{
+ if (!sm->tptk_set) {
+ wpa_printf(MSG_DEBUG, "SMD: TPTK: not set");
+ return -1;
+ }
+
+ return wpa_sm_smd_install_tk(sm, aa, &sm->tptk, "per-AP MLD");
+}
+
+
+int wpa_sm_smd_install_ptk(struct wpa_sm *sm, const u8 *aa)
+{
+ if (!sm->ptk_set) {
+ wpa_printf(MSG_DEBUG, "SMD: PTK: not set");
+ return -1;
+ }
+
+ return wpa_sm_smd_install_tk(sm, aa, &sm->ptk, "per-SMD");
+}
\ No newline at end of file
diff --git a/src/rsn_supp/wpa.h b/src/rsn_supp/wpa.h
index 5a57dd21d12f..c476af9a6e17 100644
--- a/src/rsn_supp/wpa.h
+++ b/src/rsn_supp/wpa.h
@@ -757,5 +757,7 @@ int wpa_sm_smd_calc_mic(struct wpa_sm *sm, const u8 *aa, const u8 *snonce,
int wpa_sm_smd_derive_ptk(struct wpa_sm *sm, const u8 *aa, const u8 *snonce,
const u8 *anonce, const u8 *z, size_t z_len);
int wpa_sm_smd_set_tptk_to_ptk(struct wpa_sm *sm);
+int wpa_sm_smd_install_tptk(struct wpa_sm *sm, const u8 *aa);
+int wpa_sm_smd_install_ptk(struct wpa_sm *sm, const u8 *aa);
#endif /* WPA_H */
--
2.55.0
More information about the Hostap
mailing list