[PATCH] NAN: Set new NIK before computing the new tag

Andrei Otcheretianski andrei.otcheretianski at intel.com
Thu May 7 12:11:30 PDT 2026


From: Ilan Peer <ilan.peer at intel.com>

Set the new NIK before computing the new tag, as the
computation uses the stored NIK.

Signed-off-by: Ilan Peer <ilan.peer at intel.com>
---
 src/nan/nan_pairing.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/nan/nan_pairing.c b/src/nan/nan_pairing.c
index b03ca68dac..ad29c8427e 100644
--- a/src/nan/nan_pairing.c
+++ b/src/nan/nan_pairing.c
@@ -1493,6 +1493,8 @@ int nan_pairing_set_nik(struct nan_data *nan, const u8 *nik, size_t nik_len)
 		return -1;
 	}
 
+	os_memcpy(nan->cfg->nik, nik, NAN_NIK_LEN);
+
 	if (nan->cfg->pairing_cfg.pairing_verification) {
 		if (nan_nira_get_tag_nonce(nan->cfg, nonce, tag) < 0) {
 			wpa_printf(MSG_INFO,
@@ -1510,8 +1512,6 @@ int nan_pairing_set_nik(struct nan_data *nan, const u8 *nik, size_t nik_len)
 		os_memset(nan->nira_tag, 0, NAN_NIRA_TAG_LEN);
 	}
 
-	os_memcpy(nan->cfg->nik, nik, NAN_NIK_LEN);
-
 	wpa_hexdump_key(MSG_DEBUG, "NAN: New NIK", nan->cfg->nik, NAN_NIK_LEN);
 
 	return 0;
-- 
2.53.0




More information about the Hostap mailing list