[PATCH 36/97] NAN: Modify get_seqnum() to support NDI group keys
Andrei Otcheretianski
andrei.otcheretianski at intel.com
Tue Apr 28 13:05:37 PDT 2026
From: Avraham Stern <avraham.stern at intel.com>
Modify the get_seqnum() callback to support the NDI group keys.
Add a NDI address parameter to the callback. When the NDI address
is set, the sequence number should be queried from the interface
corresponding to the specified NDI address.
Signed-off-by: Avraham Stern <avraham.stern at intel.com>
---
src/nan/nan.h | 4 +++-
src/nan/nan_sec.c | 6 ++++--
wpa_supplicant/nan_supplicant.c | 18 +++++++++++++++++-
3 files changed, 24 insertions(+), 4 deletions(-)
diff --git a/src/nan/nan.h b/src/nan/nan.h
index dbcc195857..294d715bf5 100644
--- a/src/nan/nan.h
+++ b/src/nan/nan.h
@@ -741,9 +741,11 @@ struct nan_config {
* @ctx: Callback context from cb_ctx
* @key_idx: Key index
* @seq: Buffer for returning the latest used PN value
+ * @ndi_addr: For NDI group keys, the NDI MAC address; %NULL for
+ * NMI group keys
* Returns: 0 on success, -1 on failure
*/
- int (*get_seqnum)(void *ctx, int key_idx, u8 *seq);
+ int (*get_seqnum)(void *ctx, int key_idx, u8 *seq, u8 *ndi_addr);
};
struct nan_data * nan_init(const struct nan_config *cfg);
diff --git a/src/nan/nan_sec.c b/src/nan/nan_sec.c
index 7c509b672c..964b6a01a3 100644
--- a/src/nan/nan_sec.c
+++ b/src/nan/nan_sec.c
@@ -950,7 +950,8 @@ static int nan_sec_igtk_kde(struct nan_data *nan, struct wpabuf *buf)
{
u8 tsc[RSN_PN_LEN];
- if (nan->cfg->get_seqnum(nan->cfg->cb_ctx, nan->igtk_id, tsc) < 0) {
+ if (nan->cfg->get_seqnum(nan->cfg->cb_ctx, nan->igtk_id, tsc,
+ NULL) < 0) {
wpa_printf(MSG_DEBUG, "NAN: Failed to get IGTK seqnum");
return -1;
}
@@ -986,7 +987,8 @@ static int nan_sec_bigtk_kde(struct nan_data *nan, struct nan_ndp_sec *ndp_sec,
return 0;
}
- if (nan->cfg->get_seqnum(nan->cfg->cb_ctx, nan->bigtk_id, tsc) < 0) {
+ if (nan->cfg->get_seqnum(nan->cfg->cb_ctx, nan->bigtk_id, tsc,
+ NULL) < 0) {
wpa_printf(MSG_DEBUG, "NAN: Failed to get BIGTK seqnum");
return -1;
}
diff --git a/wpa_supplicant/nan_supplicant.c b/wpa_supplicant/nan_supplicant.c
index db876fc098..aa29bfc021 100644
--- a/wpa_supplicant/nan_supplicant.c
+++ b/wpa_supplicant/nan_supplicant.c
@@ -928,10 +928,26 @@ static int wpas_nan_set_group_key_cb(void *ctx, enum wpa_alg alg,
}
-static int wpas_nan_get_seqnum_cb(void *ctx, int key_idx, u8 *seq)
+static int wpas_nan_get_seqnum_cb(void *ctx, int key_idx, u8 *seq, u8 *ndi_addr)
{
struct wpa_supplicant *wpa_s = ctx;
+ if (ndi_addr) {
+ wpa_s = wpas_nan_get_ndi_iface(wpa_s, ndi_addr);
+ if (!wpa_s) {
+ wpa_printf(MSG_DEBUG,
+ "NAN: No NDI interface found for addr "
+ MACSTR, MAC2STR(ndi_addr));
+ return -1;
+ }
+
+ /* If the NDI GTK is not installed yet, RSC is 0 */
+ if (!wpa_s->ndi_gtk.id) {
+ os_memset(seq, 0, WPA_KEY_RSC_LEN);
+ return 0;
+ }
+ }
+
return wpa_drv_get_seqnum(wpa_s, NULL, key_idx, seq);
}
--
2.53.0
More information about the Hostap
mailing list