[PATCH 07/10] WPA: SMD: Derive PTK for SMD association

Pooventhiran G pooventhiran.g at oss.qualcomm.com
Sat Nov 21 12:34:16 PST 2026


From: Rohan Dutta <drohan at qti.qualcomm.com>

Per IEEE802.11bn/D2.1, Section 12.7.1.3 (Pairwise key hierarchy), when a
PTK is derived at the time of (re)association to an SMD-ME, the SMD
identifier is included in the PTK function. Pass SMD identifier to
derive PTK if SMD has been negotiated.

Signed-off-by: Rohan Dutta <drohan at qti.qualcomm.com>
Co-developed-by: Sidhanta Sahu <sidhanta.sahu at oss.qualcomm.com>
Signed-off-by: Sidhanta Sahu <sidhanta.sahu at oss.qualcomm.com>
Signed-off-by: Pooventhiran G <pooventhiran.g at oss.qualcomm.com>
---
 src/ap/wpa_auth.c                |  8 +++++++-
 src/common/common_module_tests.c |  2 +-
 src/common/wpa_common.c          | 19 +++++++++++++++----
 src/common/wpa_common.h          |  3 ++-
 src/rsn_supp/wpa.c               |  2 +-
 wlantest/rx_eapol.c              |  2 +-
 6 files changed, 27 insertions(+), 9 deletions(-)

diff --git a/src/ap/wpa_auth.c b/src/ap/wpa_auth.c
index a6795904440d..ee892c331499 100644
--- a/src/ap/wpa_auth.c
+++ b/src/ap/wpa_auth.c
@@ -3105,6 +3105,7 @@ static int wpa_derive_ptk(struct wpa_state_machine *sm, const u8 *snonce,
 {
 	const u8 *z = NULL;
 	size_t z_len = 0, kdk_len;
+	const u8 *smd_identifier = NULL;
 	int akmp;
 	int ret;
 
@@ -3160,6 +3161,11 @@ static int wpa_derive_ptk(struct wpa_state_machine *sm, const u8 *snonce,
 	}
 #endif /* CONFIG_DPP2 */
 
+#ifdef CONFIG_IEEE80211BN
+	if (sm->smd)
+		smd_identifier = sm->wpa_auth->conf.smd_identifier;
+#endif /* CONFIG_IEEE80211BN */
+
 	akmp = sm->wpa_key_mgmt;
 	if (force_sha256)
 		akmp |= WPA_KEY_MGMT_PSK_SHA256;
@@ -3167,7 +3173,7 @@ static int wpa_derive_ptk(struct wpa_state_machine *sm, const u8 *snonce,
 			     wpa_auth_get_aa(sm), wpa_auth_get_spa(sm),
 			     sm->ANonce, snonce, ptk, akmp,
 			     sm->pairwise, z, z_len, kdk_len,
-			     sm->pasn_group);
+			     sm->pasn_group, smd_identifier);
 	if (ret) {
 		wpa_printf(MSG_DEBUG,
 			   "WPA: PTK derivation failed");
diff --git a/src/common/common_module_tests.c b/src/common/common_module_tests.c
index 8274b5db8600..928c67c83ea2 100644
--- a/src/common/common_module_tests.c
+++ b/src/common/common_module_tests.c
@@ -736,7 +736,7 @@ static int pasn_test_no_pasn_auth(void)
 			     "Pairwise key expansion",
 			     spa, aa, snonce, anonce,
 			     &ptk, WPA_KEY_MGMT_SAE, WPA_CIPHER_CCMP,
-			     NULL, 0, WPA_KDK_MAX_LEN, 19);
+			     NULL, 0, WPA_KDK_MAX_LEN, 19, NULL);
 
 	if (ret)
 		return ret;
diff --git a/src/common/wpa_common.c b/src/common/wpa_common.c
index 106f6eff77fa..01f511ec710a 100644
--- a/src/common/wpa_common.c
+++ b/src/common/wpa_common.c
@@ -596,13 +596,14 @@ int wpa_eapol_key_mic(const u8 *key, size_t key_len, int akmp,
  * @z: Additional context data
  * @z_len: Length of additional context data
  * @kdk_len: The length in octets that should be derived for KDK
+ * @smd_identifier: SMD Identifier
  * Returns: 0 on success, -1 on failure
  *
  * IEEE Std 802.11i-2004 - 8.5.1.2 Pairwise key hierarchy
  * PTK = PRF-X(PMK, "Pairwise key expansion",
  *             Min(AA, SA) || Max(AA, SA) ||
  *             Min(ANonce, SNonce) || Max(ANonce, SNonce)
- *             [ || Z.x ])
+ *             [ || Z.x ] [ || SMD Identifier ])
  *
  * The optional Z.x component is used only with DPP and that part is not defined
  * in IEEE 802.11. The additional context data is also used to carry the DHss
@@ -613,10 +614,11 @@ int wpa_pmk_to_ptk(const u8 *pmk, size_t pmk_len, const char *label,
 		   const u8 *addr1, const u8 *addr2,
 		   const u8 *nonce1, const u8 *nonce2,
 		   struct wpa_ptk *ptk, int akmp, int cipher,
-		   const u8 *z, size_t z_len, size_t kdk_len, u16 pasn_group)
+		   const u8 *z, size_t z_len, size_t kdk_len, u16 pasn_group,
+		   const u8 *smd_identifier)
 {
 #define MAX_Z_LEN 66 /* with NIST P-521 */
-	u8 data[2 * ETH_ALEN + 2 * WPA_NONCE_LEN + MAX_Z_LEN];
+	u8 data[2 * ETH_ALEN + 2 * WPA_NONCE_LEN + MAX_Z_LEN + ETH_ALEN];
 	size_t data_len = 2 * ETH_ALEN + 2 * WPA_NONCE_LEN;
 	u8 tmp[WPA_KCK_MAX_LEN + WPA_KEK_MAX_LEN + WPA_TK_MAX_LEN +
 		WPA_KDK_MAX_LEN];
@@ -661,6 +663,15 @@ int wpa_pmk_to_ptk(const u8 *pmk, size_t pmk_len, const char *label,
 		data_len += z_len;
 	}
 
+#ifdef CONFIG_IEEE80211BN
+	if (smd_identifier) {
+		os_memcpy(data + data_len, smd_identifier, ETH_ALEN);
+		data_len += ETH_ALEN;
+		wpa_hexdump(MSG_DEBUG, "WPA: SMD Identifier in PTK derivation",
+			    smd_identifier, ETH_ALEN);
+	}
+#endif /* CONFIG_IEEE80211BN */
+
 	if (kdk_len > WPA_KDK_MAX_LEN) {
 		wpa_printf(MSG_ERROR,
 			   "WPA: KDK len=%zu exceeds max supported len",
@@ -2145,7 +2156,7 @@ int wpa_auth_802_1x_pmk_to_ptk(const u8 *pmk, size_t pmk_len, const u8 *spa,
 	return wpa_pmk_to_ptk(pmk, pmk_len, "Pairwise key expansion",
 			      spa, aa, snonce, anonce, ptk, akmp,
 			      cipher, dhss, dhss_len, kdk_len,
-			      PASN_GROUP_NOT_SPECIFIED);
+			      PASN_GROUP_NOT_SPECIFIED, NULL);
 }
 
 
diff --git a/src/common/wpa_common.h b/src/common/wpa_common.h
index f55901a94839..7a9e16c75fd7 100644
--- a/src/common/wpa_common.h
+++ b/src/common/wpa_common.h
@@ -495,7 +495,8 @@ int wpa_pmk_to_ptk(const u8 *pmk, size_t pmk_len, const char *label,
 		   const u8 *addr1, const u8 *addr2,
 		   const u8 *nonce1, const u8 *nonce2,
 		   struct wpa_ptk *ptk, int akmp, int cipher,
-		   const u8 *z, size_t z_len, size_t kdk_len, u16 pasn_group);
+		   const u8 *z, size_t z_len, size_t kdk_len, u16 pasn_group,
+		   const u8 *smd_identifier);
 int fils_rmsk_to_pmk(int akmp, const u8 *rmsk, size_t rmsk_len,
 		     const u8 *snonce, const u8 *anonce, const u8 *dh_ss,
 		     size_t dh_ss_len, u8 *pmk, size_t *pmk_len);
diff --git a/src/rsn_supp/wpa.c b/src/rsn_supp/wpa.c
index 5a05a991b9f9..795535d0c60a 100644
--- a/src/rsn_supp/wpa.c
+++ b/src/rsn_supp/wpa.c
@@ -792,7 +792,7 @@ static int wpa_derive_ptk(struct wpa_sm *sm, const unsigned char *src_addr,
 			     sm->own_addr, wpa_sm_get_auth_addr(sm), sm->snonce,
 			     key->key_nonce, ptk, akmp,
 			     sm->pairwise_cipher, z, z_len,
-			     kdk_len, sm->pasn_group);
+			     kdk_len, sm->pasn_group, NULL);
 	if (ret) {
 		wpa_printf(MSG_ERROR, "WPA: PTK derivation failed");
 		return ret;
diff --git a/wlantest/rx_eapol.c b/wlantest/rx_eapol.c
index d0fbd8ad6163..b9a966eb1414 100644
--- a/wlantest/rx_eapol.c
+++ b/wlantest/rx_eapol.c
@@ -250,7 +250,7 @@ static int try_pmk(struct wlantest *wt, struct wlantest_bss *bss,
 				  aa, sa, sta->anonce,
 				  sta->snonce, &ptk, sta->key_mgmt,
 				  sta->pairwise_cipher, NULL, 0, kdk_len,
-				  PASN_GROUP_NOT_SPECIFIED) < 0 ||
+				  PASN_GROUP_NOT_SPECIFIED, NULL) < 0 ||
 		   check_mic(sta, ptk.kck, ptk.kck_len, ver, data, len) < 0) {
 		return -1;
 	}
-- 
2.34.1




More information about the Hostap mailing list