]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
P2P2: Return ID of identity block for p2p_validate_dira()
authorJouni Malinen <quic_jouni@quicinc.com>
Fri, 27 Dec 2024 14:07:30 +0000 (19:37 +0530)
committerJouni Malinen <j@w1.fi>
Thu, 23 Jan 2025 10:35:50 +0000 (12:35 +0200)
Start the identity block ID from a non-zero value and return the ID on
successful DIRA validation. This is used to process invitation request
and handle random SSID by group owner which will be covered in separate
commits.

Signed-off-by: Vinay Gannevaram <quic_vganneva@quicinc.com>
src/p2p/p2p.c
src/p2p/p2p.h
wpa_supplicant/config.c
wpa_supplicant/config_file.c
wpa_supplicant/p2p_supplicant.c

index 18c8b2eb56a0b9dfc2e91bd7406da0b75eb1bfdd..74775d2061d057df976536e222a5619569987469 100644 (file)
@@ -6041,13 +6041,14 @@ static int p2p_derive_nonce_tag(struct p2p_data *p2p)
 }
 
 
-static void p2p_validate_dira(struct p2p_data *p2p, struct p2p_device *dev,
-                             const u8 *dira, u16 dira_len)
+static int p2p_validate_dira(struct p2p_data *p2p, struct p2p_device *dev,
+                            const u8 *dira, u16 dira_len)
 {
        if (p2p->cfg->validate_dira)
-               p2p->cfg->validate_dira(p2p->cfg->cb_ctx,
-                                       dev->info.p2p_device_addr,
-                                       dira, dira_len);
+               return p2p->cfg->validate_dira(p2p->cfg->cb_ctx,
+                                              dev->info.p2p_device_addr,
+                                              dira, dira_len);
+       return 0;
 }
 
 
index 7724859ade9a556ba61f73c931c025612770cea2..fc158db04f6e3d9e6d3c5c77f0d1043415be7f45 100644 (file)
@@ -1346,14 +1346,15 @@ struct p2p_config {
         * @peer_addr: P2P Device address of the peer
         * @dira: DIRA attribute present in the USD frames
         * @dira_len: Length of DIRA
+        * Returns: Identity block ID on success, 0 on failure
         *
         * This function can be used to validate DIRA and configure PMK of a
         * paired/persistent peer from configuration. The handler function is
         * expected to call p2p_pasn_pmksa_set_pmk() to set the PMK/PMKID in
         * case a matching entry is found.
         */
-       void (*validate_dira)(void *ctx, const u8 *peer_addr,
-                             const u8 *dira, size_t dira_len);
+       int (*validate_dira)(void *ctx, const u8 *peer_addr,
+                            const u8 *dira, size_t dira_len);
 
        /**
         * pasn_send_mgmt - Function handler to transmit a Management frame
index 228b1b2c9fb07534765f9ffe90367f094f3b6342..2413fd39e63277680b3080b98b36baaadb82c242 100644 (file)
@@ -5861,7 +5861,7 @@ struct wpa_dev_ik * wpa_config_add_identity(struct wpa_config *config)
        int id;
        struct wpa_dev_ik *identity, *last = NULL;
 
-       id = -1;
+       id = 0;
        identity = config->identity;
        while (identity) {
                if (identity->id > id)
index f0c3727ddfddca4eaeb60da323eef803da04f468..f96b225b84e5c2b9e5620cde36fc3a3ddcb0bce3 100644 (file)
@@ -367,7 +367,7 @@ struct wpa_config * wpa_config_read(const char *name, struct wpa_config *cfgp,
        struct wpa_config *config;
        static int id = 0;
        static int cred_id = 0;
-       static int identity_id = 0;
+       static int identity_id = 1;
 
        if (name == NULL)
                return NULL;
index 1d20ea3bcdf3f018e6cc1c7ebc3bbfc98b9d7188..0f82283d9712673638a00a85fee5afde3ca8c6de 100644 (file)
@@ -5344,8 +5344,8 @@ static void wpas_bootstrap_completed(void *ctx, const u8 *addr,
 }
 
 
-static void wpas_validate_dira(void *ctx, const u8 *peer_addr,
-                              const u8 *dira, size_t dira_len)
+static int wpas_validate_dira(void *ctx, const u8 *peer_addr,
+                             const u8 *dira, size_t dira_len)
 {
        struct wpa_supplicant *wpa_s = ctx;
        int ret;
@@ -5358,14 +5358,14 @@ static void wpas_validate_dira(void *ctx, const u8 *peer_addr,
        if (dira_len < 1 || dira[0] != DIRA_CIPHER_VERSION_128) {
                wpa_printf(MSG_ERROR,
                           "P2P2: Unsupported DIRA cipher version %d", dira[0]);
-               return;
+               return 0;
        }
 
        if (dira_len < 1 + DEVICE_IDENTITY_NONCE_LEN + DEVICE_IDENTITY_TAG_LEN)
        {
                wpa_printf(MSG_INFO, "P2P2: Truncated DIRA (length %zu)",
                           dira_len);
-               return;
+               return 0;
        }
 
        addr[0] = (const u8 *) label;
@@ -5386,7 +5386,7 @@ static void wpas_validate_dira(void *ctx, const u8 *peer_addr,
                if (ret < 0) {
                        wpa_printf(MSG_ERROR,
                                   "P2P2: Failed to derive DIRA Tag");
-                       return;
+                       return 0;
                }
 
                if (os_memcmp(tag, &dira[1 + DEVICE_IDENTITY_NONCE_LEN],
@@ -5397,7 +5397,7 @@ static void wpas_validate_dira(void *ctx, const u8 *peer_addr,
        }
 
        if (!ik)
-               return;
+               return 0;
 
 #ifdef CONFIG_PASN
        p2p_pasn_pmksa_set_pmk(wpa_s->global->p2p, wpa_s->global->p2p_dev_addr,
@@ -5405,6 +5405,8 @@ static void wpas_validate_dira(void *ctx, const u8 *peer_addr,
                               wpabuf_head(ik->pmk), wpabuf_len(ik->pmk),
                               wpabuf_head(ik->pmkid));
 #endif /* CONFIG_PASN */
+
+       return ik->id;
 }