}
-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;
}
* @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
int id;
struct wpa_dev_ik *identity, *last = NULL;
- id = -1;
+ id = 0;
identity = config->identity;
while (identity) {
if (identity->id > id)
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;
}
-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;
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;
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],
}
if (!ik)
- return;
+ return 0;
#ifdef CONFIG_PASN
p2p_pasn_pmksa_set_pmk(wpa_s->global->p2p, wpa_s->global->p2p_dev_addr,
wpabuf_head(ik->pmk), wpabuf_len(ik->pmk),
wpabuf_head(ik->pmkid));
#endif /* CONFIG_PASN */
+
+ return ik->id;
}