[PATCH 52/55] RSN: Add initiator helpers for PTK rekeying with the PQC AKMs
Ilan Peer
ilan.peer at intel.com
Thu Dec 3 02:44:51 PST 2026
Add helpers for the Authenticator to start a PQC exchange for a PTK
rekey and to process the Supplicant's PQC Parameter element and
derive the shared secrets.
Signed-off-by: Ilan Peer <ilan.peer at intel.com>
---
src/common/wpa_common.c | 114 ++++++++++++++++++++++++++++++++++++++++
src/common/wpa_common.h | 21 ++++++++
2 files changed, 135 insertions(+)
diff --git a/src/common/wpa_common.c b/src/common/wpa_common.c
index 4bf12a82512b..02c147ae8ff1 100644
--- a/src/common/wpa_common.c
+++ b/src/common/wpa_common.c
@@ -2054,6 +2054,67 @@ static struct wpabuf * pqc_param_elem(u8 sec_prof, u8 content,
}
+void pqc_rekey_deinit(struct pqc_rekey *pqc)
+{
+ crypto_ecdh_deinit(pqc->ecdh);
+ crypto_ml_kem_deinit(pqc->ml_kem);
+ wpabuf_free(pqc->elem);
+ wpabuf_free(pqc->msg1);
+ os_memset(pqc, 0, sizeof(*pqc));
+}
+
+
+/**
+ * pqc_rekey_init - Start a PQC exchange for PTK rekeying
+ * @pqc: Ephemeral state, filled in on success
+ * @sec_prof: Security profile number of the association
+ * Returns: PQC Parameter element for EAPOL-Key msg 1/4, or %NULL on failure
+ */
+struct wpabuf * pqc_rekey_init(struct pqc_rekey *pqc, int sec_prof)
+{
+ struct wpabuf *pub = NULL, *ml_kem_pub = NULL, *elem = NULL;
+
+ pqc_rekey_deinit(pqc);
+ pqc->profile = pqc_profile_get(sec_prof);
+ if (!pqc->profile)
+ return NULL;
+
+ pqc->sec_prof = sec_prof;
+
+ pqc->ml_kem = crypto_ml_kem_init(pqc->profile->kem);
+ if (!pqc->ml_kem || crypto_ml_kem_keygen(pqc->ml_kem) < 0)
+ goto fail;
+
+ ml_kem_pub = crypto_ml_kem_get_pubkey(pqc->ml_kem);
+ if (!ml_kem_pub)
+ goto fail;
+
+ if (pqc->profile->group) {
+ pqc->ecdh = crypto_ecdh_init(pqc->profile->group);
+ if (!pqc->ecdh)
+ goto fail;
+ pub = crypto_ecdh_get_pubkey(pqc->ecdh, 0);
+ if (!pub)
+ goto fail;
+ }
+
+ elem = pqc_param_elem(sec_prof,
+ pub ? PQC_CONTENT_PK_PARAM_AND_ML_KEM_ENC_KEY :
+ PQC_CONTENT_ML_KEM_ENC_KEY, pub, ml_kem_pub);
+ if (elem)
+ pqc->elem = wpabuf_dup(elem);
+fail:
+ wpabuf_free(pub);
+ wpabuf_free(ml_kem_pub);
+ if (!elem || !pqc->elem) {
+ wpabuf_free(elem);
+ elem = NULL;
+ pqc_rekey_deinit(pqc);
+ }
+ return elem;
+}
+
+
static int pqc_param_parse(int sec_prof, const u8 *param, size_t param_len,
u8 expected_content, const u8 **pos, const u8 **end)
{
@@ -2156,6 +2217,59 @@ fail:
}
+/**
+ * pqc_rekey_finish - Process the PQC Parameter of the responder
+ * @pqc: Ephemeral state from pqc_rekey_init()
+ * @param: PQC Parameter element body from EAPOL-Key msg 2/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: 0 on success, -1 on failure
+ */
+int pqc_rekey_finish(struct pqc_rekey *pqc, const u8 *param,
+ size_t param_len, struct wpabuf **dhss,
+ struct wpabuf **ml_kem_ss)
+{
+ const u8 *pos, *end;
+
+ *dhss = NULL;
+ *ml_kem_ss = NULL;
+
+ if (!pqc->profile || !pqc->ml_kem ||
+ pqc_param_parse(pqc->sec_prof, param, param_len,
+ pqc->ecdh ? PQC_CONTENT_PK_PARAM_AND_ML_KEM_CT :
+ PQC_CONTENT_ML_KEM_CT, &pos, &end) < 0)
+ return -1;
+
+ if (pqc->ecdh) {
+ size_t pub_len = crypto_ecdh_prime_len(pqc->ecdh);
+
+ if ((size_t)(end - pos) < pub_len)
+ return -1;
+
+ *dhss = crypto_ecdh_set_peerkey(pqc->ecdh, 0, pos, pub_len);
+ if (!*dhss) {
+ wpa_printf(MSG_DEBUG,
+ "RSN: Invalid PQC ECDH public key");
+ return -1;
+ }
+
+ pos += pub_len;
+ }
+
+ if (pos == end ||
+ crypto_ml_kem_decapsulate(pqc->ml_kem, pos, end - pos,
+ ml_kem_ss) < 0) {
+ wpa_printf(MSG_DEBUG, "RSN: PQC ML-KEM decapsulation failed");
+ wpabuf_clear_free(*dhss);
+ *dhss = NULL;
+ return -1;
+ }
+
+ return 0;
+}
+
+
/**
* 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 394ed45b1086..abb628b62c33 100644
--- a/src/common/wpa_common.h
+++ b/src/common/wpa_common.h
@@ -849,9 +849,30 @@ 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 crypto_ecdh;
+struct crypto_ml_kem;
+
+struct pqc_rekey {
+ const struct ieee80211_pqc_profile *profile;
+ u8 sec_prof;
+ struct crypto_ecdh *ecdh;
+ struct crypto_ml_kem *ml_kem;
+
+ /* own PQC Parameter element, for retransmits */
+ struct wpabuf *elem;
+
+ /* first message for the transcript */
+ struct wpabuf *msg1;
+};
+
+void pqc_rekey_deinit(struct pqc_rekey *pqc);
+struct wpabuf * pqc_rekey_init(struct pqc_rekey *pqc, int sec_prof);
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_rekey_finish(struct pqc_rekey *pqc, 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,
--
2.55.0
More information about the Hostap
mailing list