]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
P2P2: Get ID of device identity block from wpas_p2p_validate_dira()
authorVinay Gannevaram <quic_vganneva@quicinc.com>
Wed, 5 Mar 2025 09:07:46 +0000 (14:37 +0530)
committerJouni Malinen <j@w1.fi>
Thu, 6 Mar 2025 21:52:05 +0000 (23:52 +0200)
Upper layer components can now use the P2P_VALIDATE_DIRA command to
retrieve the device identity key identifier, which is necessary to
initiate P2P reinvoke to an existing group.

Signed-off-by: Vinay Gannevaram <quic_vganneva@quicinc.com>
wpa_supplicant/ctrl_iface.c
wpa_supplicant/p2p_supplicant.c

index a89cb5211966679972220a27170a3590f6085446..3435c1db5e9e00ce8a0faddbc394c76d4f44c7cd 100644 (file)
@@ -6624,12 +6624,15 @@ static int p2p_get_passphrase(struct wpa_supplicant *wpa_s, char *buf,
 }
 
 
-static int p2p_ctrl_validate_dira(struct wpa_supplicant *wpa_s, char *cmd)
+static int p2p_ctrl_validate_dira(struct wpa_supplicant *wpa_s, char *cmd,
+                                 char *buf, size_t buflen)
 {
        char *pos, *pos2;
        u8 addr[ETH_ALEN];
        u8 nonce[DEVICE_IDENTITY_NONCE_LEN];
        u8 tag[DEVICE_IDENTITY_TAG_LEN];
+       int id;
+       int res;
 
        if (hwaddr_aton(cmd, addr))
                return -1;
@@ -6656,7 +6659,14 @@ static int p2p_ctrl_validate_dira(struct wpa_supplicant *wpa_s, char *cmd)
                return -1;
        }
 
-       return wpas_p2p_validate_dira(wpa_s, addr, 0, nonce, tag);
+       id = wpas_p2p_validate_dira(wpa_s, addr, 0, nonce, tag);
+       if (id <= 0)
+               return -1;
+
+       res = os_snprintf(buf, buflen, "%u", id);
+       if (os_snprintf_error(buflen, res))
+               return -1;
+       return res;
 }
 
 
@@ -13047,8 +13057,8 @@ char * wpa_supplicant_ctrl_iface_process(struct wpa_supplicant *wpa_s,
        } else if (os_strcmp(buf, "P2P_GET_DIRA") == 0) {
                reply_len = wpas_p2p_get_dira(wpa_s, reply, reply_size);
        } else if (os_strncmp(buf, "P2P_VALIDATE_DIRA ", 18) == 0) {
-               if (p2p_ctrl_validate_dira(wpa_s, buf + 18) < 0)
-                       reply_len = -1;
+               reply_len = p2p_ctrl_validate_dira(wpa_s, buf + 18,
+                                                  reply, reply_size);
 #ifdef CONFIG_PASN
 #ifdef CONFIG_TESTING_OPTIONS
        } else if (os_strcmp(buf, "P2P_GET_PASNPTK") == 0) {
index d4b69645e139439b561172a83bb13b0de3bfcc2c..6d2551b89a50dae13fbb73da3cec20125f265523 100644 (file)
@@ -11538,13 +11538,10 @@ int wpas_p2p_validate_dira(struct wpa_supplicant *wpa_s, const u8 *addr,
        if (cipher != DIRA_CIPHER_VERSION_128) {
                wpa_printf(MSG_INFO, "P2P2: Unsupported DIRA cipher version %d",
                           cipher);
-               return -1;
-       }
-
-       if (wpas_validate_dira(wpa_s, addr, nonce, tag) > 0)
                return 0;
+       }
 
-       return -1;
+       return wpas_validate_dira(wpa_s, addr, nonce, tag);
 }