[PATCH 51/55] RSN: Add a responder helper for PTK rekeying with the PQC AKMs
Ilan Peer
ilan.peer at intel.com
Thu Dec 3 02:44:50 PST 2026
With the PQC AKMs, EAPOL-Key msg 1/4 and 2/4 of a PTK rekey include a
PQC Parameter element (see Section 12.7.6.2 in Draft IEEE
P802.11bt/D1.1).
Add a helper for the Supplicant to process the element of the
Authenticator, derive the shared secrets and build its own element.
Signed-off-by: Ilan Peer <ilan.peer at intel.com>
---
src/common/wpa_common.c | 128 ++++++++++++++++++++++++++++++++++++++++
src/common/wpa_common.h | 4 ++
2 files changed, 132 insertions(+)
diff --git a/src/common/wpa_common.c b/src/common/wpa_common.c
index 16899b10ad2e..4bf12a82512b 100644
--- a/src/common/wpa_common.c
+++ b/src/common/wpa_common.c
@@ -2028,6 +2028,134 @@ int pqc_transcript_2msg(enum rsn_hash_alg hash,
}
+static struct wpabuf * pqc_param_elem(u8 sec_prof, u8 content,
+ const struct wpabuf *pub,
+ const struct wpabuf *ml_kem)
+{
+ struct wpabuf *buf;
+ size_t len;
+
+ len = 2 + (pub ? wpabuf_len(pub) : 0) + wpabuf_len(ml_kem);
+ buf = wpabuf_alloc(5 + len);
+ if (!buf)
+ return NULL;
+
+ wpabuf_put_u8(buf, WLAN_EID_EXT_LENGTH);
+ wpabuf_put_le16(buf, WLAN_EID_EXT_LEN_PQC_PARAMETER);
+ wpabuf_put_le16(buf, len);
+ wpabuf_put_u8(buf, sec_prof);
+ wpabuf_put_u8(buf, content);
+
+ if (pub)
+ wpabuf_put_buf(buf, pub);
+
+ wpabuf_put_buf(buf, ml_kem);
+ return buf;
+}
+
+
+static int pqc_param_parse(int sec_prof, const u8 *param, size_t param_len,
+ u8 expected_content, const u8 **pos, const u8 **end)
+{
+ if (!param || param_len < 2 || param[0] != sec_prof) {
+ wpa_printf(MSG_DEBUG,
+ "RSN: Missing or mismatching PQC Parameter");
+ return -1;
+ }
+
+ if (param[1] != expected_content) {
+ wpa_printf(MSG_DEBUG, "RSN: Unexpected PQC content %u",
+ param[1]);
+ return -1;
+ }
+
+ *pos = param + 2;
+ *end = param + param_len;
+ return 0;
+}
+
+
+/**
+ * pqc_rekey_respond - Respond to the PQC Parameter of the initiator
+ * @sec_prof: Security profile number of the association
+ * @param: PQC Parameter element body from EAPOL-Key msg 1/4
+ * @param_len: Length of @param
+ * @dhss: DHss on success, if the PQC profile uses a finite cyclic group
+ * @ml_kem_ss: MLKEMss on success
+ * Returns: PQC Parameter element for EAPOL-Key msg 2/4, or %NULL on failure
+ */
+struct wpabuf * pqc_rekey_respond(int sec_prof, const u8 *param,
+ size_t param_len, struct wpabuf **dhss,
+ struct wpabuf **ml_kem_ss)
+{
+ const struct ieee80211_pqc_profile *profile;
+ struct crypto_ecdh *ecdh = NULL;
+ struct crypto_ml_kem *ml_kem = NULL;
+ struct wpabuf *pub = NULL, *ct = NULL, *elem = NULL;
+ const u8 *pos, *end;
+
+ *dhss = NULL;
+ *ml_kem_ss = NULL;
+
+ profile = pqc_profile_get(sec_prof);
+ if (!profile ||
+ pqc_param_parse(sec_prof, param, param_len,
+ profile->group ?
+ PQC_CONTENT_PK_PARAM_AND_ML_KEM_ENC_KEY :
+ PQC_CONTENT_ML_KEM_ENC_KEY, &pos, &end) < 0)
+ return NULL;
+
+ /* For PQC: encapsulates with the encapsulation key and perform ECDH */
+ if (profile->group) {
+ size_t pub_len;
+
+ ecdh = crypto_ecdh_init(profile->group);
+ if (!ecdh)
+ goto fail;
+
+ pub_len = crypto_ecdh_prime_len(ecdh);
+ if ((size_t) (end - pos) < pub_len)
+ goto fail;
+
+ *dhss = crypto_ecdh_set_peerkey(ecdh, 0, pos, pub_len);
+ if (!*dhss) {
+ wpa_printf(MSG_DEBUG,
+ "RSN: Invalid PQC ECDH public key");
+ goto fail;
+ }
+
+ pos += pub_len;
+ pub = crypto_ecdh_get_pubkey(ecdh, 0);
+ if (!pub)
+ goto fail;
+ }
+
+ ml_kem = crypto_ml_kem_init(profile->kem);
+ if (!ml_kem || pos == end ||
+ crypto_ml_kem_encapsulate(ml_kem, pos, end - pos, &ct,
+ ml_kem_ss) < 0) {
+ wpa_printf(MSG_DEBUG, "RSN: PQC ML-KEM encapsulation failed");
+ goto fail;
+ }
+
+ elem = pqc_param_elem(sec_prof,
+ pub ? PQC_CONTENT_PK_PARAM_AND_ML_KEM_CT :
+ PQC_CONTENT_ML_KEM_CT, pub, ct);
+fail:
+ crypto_ecdh_deinit(ecdh);
+ crypto_ml_kem_deinit(ml_kem);
+ wpabuf_free(pub);
+ wpabuf_free(ct);
+ if (!elem) {
+ wpabuf_clear_free(*dhss);
+ *dhss = NULL;
+ wpabuf_clear_free(*ml_kem_ss);
+ *ml_kem_ss = NULL;
+ }
+ return elem;
+}
+
+
/**
* pqc_pmk_to_ptk - Derive PTK from PMK for PQC cases
* @pmk: PMK buffer
diff --git a/src/common/wpa_common.h b/src/common/wpa_common.h
index 7c12edcbff76..394ed45b1086 100644
--- a/src/common/wpa_common.h
+++ b/src/common/wpa_common.h
@@ -849,6 +849,10 @@ int pqc_transcript_2msg(enum rsn_hash_alg hash,
size_t msg2_mic_offset, size_t mic_len,
u8 *t, size_t *t_len);
+struct wpabuf * pqc_rekey_respond(int sec_prof, const u8 *param,
+ size_t param_len, struct wpabuf **dhss,
+ struct wpabuf **ml_kem_ss);
+
int pqc_pmk_to_ptk(const u8 *pmk, size_t pmk_len, const u8 *spa, const u8 *aa,
enum rsn_hash_alg hash, int cipher,
const u8 *dhss, size_t dhss_len, const u8 *ml_kem_ss,
--
2.55.0
More information about the Hostap
mailing list