3 * Copyright (c) 2017, Qualcomm Atheros, Inc.
4 * Copyright (c) 2018, The Linux Foundation
6 * This software may be distributed under the terms of the BSD license.
7 * See README for more details.
10 #include "utils/includes.h"
12 #include "utils/common.h"
13 #include "utils/eloop.h"
14 #include "common/dpp.h"
15 #include "common/gas.h"
16 #include "common/gas_server.h"
17 #include "rsn_supp/wpa.h"
18 #include "rsn_supp/pmksa_cache.h"
19 #include "wpa_supplicant_i.h"
22 #include "offchannel.h"
23 #include "gas_query.h"
27 #include "dpp_supplicant.h"
30 static int wpas_dpp_listen_start(struct wpa_supplicant
*wpa_s
,
32 static void wpas_dpp_reply_wait_timeout(void *eloop_ctx
, void *timeout_ctx
);
33 static void wpas_dpp_auth_success(struct wpa_supplicant
*wpa_s
, int initiator
);
34 static void wpas_dpp_tx_status(struct wpa_supplicant
*wpa_s
,
35 unsigned int freq
, const u8
*dst
,
36 const u8
*src
, const u8
*bssid
,
37 const u8
*data
, size_t data_len
,
38 enum offchannel_send_action_result result
);
39 static void wpas_dpp_init_timeout(void *eloop_ctx
, void *timeout_ctx
);
40 static int wpas_dpp_auth_init_next(struct wpa_supplicant
*wpa_s
);
42 wpas_dpp_tx_pkex_status(struct wpa_supplicant
*wpa_s
,
43 unsigned int freq
, const u8
*dst
,
44 const u8
*src
, const u8
*bssid
,
45 const u8
*data
, size_t data_len
,
46 enum offchannel_send_action_result result
);
48 static const u8 broadcast
[ETH_ALEN
] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
50 /* Use a hardcoded Transaction ID 1 in Peer Discovery frames since there is only
51 * a single transaction in progress at any point in time. */
52 static const u8 TRANSACTION_ID
= 1;
55 static struct dpp_configurator
*
56 dpp_configurator_get_id(struct wpa_supplicant
*wpa_s
, unsigned int id
)
58 struct dpp_configurator
*conf
;
60 dl_list_for_each(conf
, &wpa_s
->dpp_configurator
,
61 struct dpp_configurator
, list
) {
69 static unsigned int wpas_dpp_next_id(struct wpa_supplicant
*wpa_s
)
71 struct dpp_bootstrap_info
*bi
;
72 unsigned int max_id
= 0;
74 dl_list_for_each(bi
, &wpa_s
->dpp_bootstrap
, struct dpp_bootstrap_info
,
84 * wpas_dpp_qr_code - Parse and add DPP bootstrapping info from a QR Code
85 * @wpa_s: Pointer to wpa_supplicant data
86 * @cmd: DPP URI read from a QR Code
87 * Returns: Identifier of the stored info or -1 on failure
89 int wpas_dpp_qr_code(struct wpa_supplicant
*wpa_s
, const char *cmd
)
91 struct dpp_bootstrap_info
*bi
;
92 struct dpp_authentication
*auth
= wpa_s
->dpp_auth
;
94 bi
= dpp_parse_qr_code(cmd
);
98 bi
->id
= wpas_dpp_next_id(wpa_s
);
99 dl_list_add(&wpa_s
->dpp_bootstrap
, &bi
->list
);
101 if (auth
&& auth
->response_pending
&&
102 dpp_notify_new_qr_code(auth
, bi
) == 1) {
103 wpa_printf(MSG_DEBUG
,
104 "DPP: Sending out pending authentication response");
105 wpa_msg(wpa_s
, MSG_INFO
, DPP_EVENT_TX
"dst=" MACSTR
107 MAC2STR(auth
->peer_mac_addr
), auth
->curr_freq
,
108 DPP_PA_AUTHENTICATION_RESP
);
109 offchannel_send_action(wpa_s
, auth
->curr_freq
,
110 auth
->peer_mac_addr
, wpa_s
->own_addr
,
112 wpabuf_head(auth
->resp_msg
),
113 wpabuf_len(auth
->resp_msg
),
114 500, wpas_dpp_tx_status
, 0);
121 static char * get_param(const char *cmd
, const char *param
)
123 const char *pos
, *end
;
127 pos
= os_strstr(cmd
, param
);
131 pos
+= os_strlen(param
);
132 end
= os_strchr(pos
, ' ');
136 len
= os_strlen(pos
);
137 val
= os_malloc(len
+ 1);
140 os_memcpy(val
, pos
, len
);
146 int wpas_dpp_bootstrap_gen(struct wpa_supplicant
*wpa_s
, const char *cmd
)
148 char *chan
= NULL
, *mac
= NULL
, *info
= NULL
, *pk
= NULL
, *curve
= NULL
;
151 size_t privkey_len
= 0;
154 struct dpp_bootstrap_info
*bi
;
156 bi
= os_zalloc(sizeof(*bi
));
160 if (os_strstr(cmd
, "type=qrcode"))
161 bi
->type
= DPP_BOOTSTRAP_QR_CODE
;
162 else if (os_strstr(cmd
, "type=pkex"))
163 bi
->type
= DPP_BOOTSTRAP_PKEX
;
167 chan
= get_param(cmd
, " chan=");
168 mac
= get_param(cmd
, " mac=");
169 info
= get_param(cmd
, " info=");
170 curve
= get_param(cmd
, " curve=");
171 key
= get_param(cmd
, " key=");
174 privkey_len
= os_strlen(key
) / 2;
175 privkey
= os_malloc(privkey_len
);
177 hexstr2bin(key
, privkey
, privkey_len
) < 0)
181 pk
= dpp_keygen(bi
, curve
, privkey
, privkey_len
);
185 len
= 4; /* "DPP:" */
187 if (dpp_parse_uri_chan_list(bi
, chan
) < 0)
189 len
+= 3 + os_strlen(chan
); /* C:...; */
192 if (dpp_parse_uri_mac(bi
, mac
) < 0)
194 len
+= 3 + os_strlen(mac
); /* M:...; */
197 if (dpp_parse_uri_info(bi
, info
) < 0)
199 len
+= 3 + os_strlen(info
); /* I:...; */
201 len
+= 4 + os_strlen(pk
);
202 bi
->uri
= os_malloc(len
+ 1);
205 os_snprintf(bi
->uri
, len
+ 1, "DPP:%s%s%s%s%s%s%s%s%sK:%s;;",
206 chan
? "C:" : "", chan
? chan
: "", chan
? ";" : "",
207 mac
? "M:" : "", mac
? mac
: "", mac
? ";" : "",
208 info
? "I:" : "", info
? info
: "", info
? ";" : "",
210 bi
->id
= wpas_dpp_next_id(wpa_s
);
211 dl_list_add(&wpa_s
->dpp_bootstrap
, &bi
->list
);
221 bin_clear_free(privkey
, privkey_len
);
222 dpp_bootstrap_info_free(bi
);
227 static struct dpp_bootstrap_info
*
228 dpp_bootstrap_get_id(struct wpa_supplicant
*wpa_s
, unsigned int id
)
230 struct dpp_bootstrap_info
*bi
;
232 dl_list_for_each(bi
, &wpa_s
->dpp_bootstrap
, struct dpp_bootstrap_info
,
241 static int dpp_bootstrap_del(struct wpa_supplicant
*wpa_s
, unsigned int id
)
243 struct dpp_bootstrap_info
*bi
, *tmp
;
246 dl_list_for_each_safe(bi
, tmp
, &wpa_s
->dpp_bootstrap
,
247 struct dpp_bootstrap_info
, list
) {
248 if (id
&& bi
->id
!= id
)
251 dl_list_del(&bi
->list
);
252 dpp_bootstrap_info_free(bi
);
256 return 0; /* flush succeeds regardless of entries found */
257 return found
? 0 : -1;
261 int wpas_dpp_bootstrap_remove(struct wpa_supplicant
*wpa_s
, const char *id
)
265 if (os_strcmp(id
, "*") == 0) {
273 return dpp_bootstrap_del(wpa_s
, id_val
);
277 const char * wpas_dpp_bootstrap_get_uri(struct wpa_supplicant
*wpa_s
,
280 struct dpp_bootstrap_info
*bi
;
282 bi
= dpp_bootstrap_get_id(wpa_s
, id
);
289 int wpas_dpp_bootstrap_info(struct wpa_supplicant
*wpa_s
, int id
,
290 char *reply
, int reply_size
)
292 struct dpp_bootstrap_info
*bi
;
294 bi
= dpp_bootstrap_get_id(wpa_s
, id
);
297 return os_snprintf(reply
, reply_size
, "type=%s\n"
298 "mac_addr=" MACSTR
"\n"
302 dpp_bootstrap_type_txt(bi
->type
),
303 MAC2STR(bi
->mac_addr
),
304 bi
->info
? bi
->info
: "",
310 static void wpas_dpp_auth_resp_retry_timeout(void *eloop_ctx
, void *timeout_ctx
)
312 struct wpa_supplicant
*wpa_s
= eloop_ctx
;
313 struct dpp_authentication
*auth
= wpa_s
->dpp_auth
;
315 if (!auth
|| !auth
->resp_msg
)
318 wpa_printf(MSG_DEBUG
,
319 "DPP: Retry Authentication Response after timeout");
320 wpa_msg(wpa_s
, MSG_INFO
, DPP_EVENT_TX
"dst=" MACSTR
322 MAC2STR(auth
->peer_mac_addr
), auth
->curr_freq
,
323 DPP_PA_AUTHENTICATION_RESP
);
324 offchannel_send_action(wpa_s
, auth
->curr_freq
, auth
->peer_mac_addr
,
325 wpa_s
->own_addr
, broadcast
,
326 wpabuf_head(auth
->resp_msg
),
327 wpabuf_len(auth
->resp_msg
),
328 500, wpas_dpp_tx_status
, 0);
332 static void wpas_dpp_auth_resp_retry(struct wpa_supplicant
*wpa_s
)
334 struct dpp_authentication
*auth
= wpa_s
->dpp_auth
;
335 unsigned int wait_time
, max_tries
;
337 if (!auth
|| !auth
->resp_msg
)
340 if (wpa_s
->dpp_resp_max_tries
)
341 max_tries
= wpa_s
->dpp_resp_max_tries
;
344 auth
->auth_resp_tries
++;
345 if (auth
->auth_resp_tries
>= max_tries
) {
346 wpa_printf(MSG_INFO
, "DPP: No confirm received from initiator - stopping exchange");
347 offchannel_send_action_done(wpa_s
);
348 dpp_auth_deinit(wpa_s
->dpp_auth
);
349 wpa_s
->dpp_auth
= NULL
;
353 if (wpa_s
->dpp_resp_retry_time
)
354 wait_time
= wpa_s
->dpp_resp_retry_time
;
357 wpa_printf(MSG_DEBUG
,
358 "DPP: Schedule retransmission of Authentication Response frame in %u ms",
360 eloop_cancel_timeout(wpas_dpp_auth_resp_retry_timeout
, wpa_s
, NULL
);
361 eloop_register_timeout(wait_time
/ 1000,
362 (wait_time
% 1000) * 1000,
363 wpas_dpp_auth_resp_retry_timeout
, wpa_s
, NULL
);
367 static void wpas_dpp_tx_status(struct wpa_supplicant
*wpa_s
,
368 unsigned int freq
, const u8
*dst
,
369 const u8
*src
, const u8
*bssid
,
370 const u8
*data
, size_t data_len
,
371 enum offchannel_send_action_result result
)
374 struct dpp_authentication
*auth
= wpa_s
->dpp_auth
;
376 res_txt
= result
== OFFCHANNEL_SEND_ACTION_SUCCESS
? "SUCCESS" :
377 (result
== OFFCHANNEL_SEND_ACTION_NO_ACK
? "no-ACK" :
379 wpa_printf(MSG_DEBUG
, "DPP: TX status: freq=%u dst=" MACSTR
380 " result=%s", freq
, MAC2STR(dst
), res_txt
);
381 wpa_msg(wpa_s
, MSG_INFO
, DPP_EVENT_TX_STATUS
"dst=" MACSTR
382 " freq=%u result=%s", MAC2STR(dst
), freq
, res_txt
);
384 if (!wpa_s
->dpp_auth
) {
385 wpa_printf(MSG_DEBUG
,
386 "DPP: Ignore TX status since there is no ongoing authentication exchange");
390 if (wpa_s
->dpp_auth
->remove_on_tx_status
) {
391 wpa_printf(MSG_DEBUG
,
392 "DPP: Terminate authentication exchange due to an earlier error");
393 eloop_cancel_timeout(wpas_dpp_init_timeout
, wpa_s
, NULL
);
394 eloop_cancel_timeout(wpas_dpp_reply_wait_timeout
, wpa_s
, NULL
);
395 eloop_cancel_timeout(wpas_dpp_auth_resp_retry_timeout
, wpa_s
,
397 offchannel_send_action_done(wpa_s
);
398 dpp_auth_deinit(wpa_s
->dpp_auth
);
399 wpa_s
->dpp_auth
= NULL
;
403 if (wpa_s
->dpp_auth_ok_on_ack
)
404 wpas_dpp_auth_success(wpa_s
, 1);
406 if (!is_broadcast_ether_addr(dst
) &&
407 result
!= OFFCHANNEL_SEND_ACTION_SUCCESS
) {
408 wpa_printf(MSG_DEBUG
,
409 "DPP: Unicast DPP Action frame was not ACKed");
410 if (auth
->waiting_auth_resp
) {
411 /* In case of DPP Authentication Request frame, move to
412 * the next channel immediately. */
413 offchannel_send_action_done(wpa_s
);
414 wpas_dpp_auth_init_next(wpa_s
);
417 if (auth
->waiting_auth_conf
) {
418 wpas_dpp_auth_resp_retry(wpa_s
);
423 if (!is_broadcast_ether_addr(dst
) && auth
->waiting_auth_resp
&&
424 result
== OFFCHANNEL_SEND_ACTION_SUCCESS
) {
425 /* Allow timeout handling to stop iteration if no response is
426 * received from a peer that has ACKed a request. */
427 auth
->auth_req_ack
= 1;
430 if (!wpa_s
->dpp_auth_ok_on_ack
&& wpa_s
->dpp_auth
->neg_freq
> 0 &&
431 wpa_s
->dpp_auth
->curr_freq
!= wpa_s
->dpp_auth
->neg_freq
) {
432 wpa_printf(MSG_DEBUG
,
433 "DPP: Move from curr_freq %u MHz to neg_freq %u MHz for response",
434 wpa_s
->dpp_auth
->curr_freq
,
435 wpa_s
->dpp_auth
->neg_freq
);
436 offchannel_send_action_done(wpa_s
);
437 wpas_dpp_listen_start(wpa_s
, wpa_s
->dpp_auth
->neg_freq
);
440 if (wpa_s
->dpp_auth_ok_on_ack
)
441 wpa_s
->dpp_auth_ok_on_ack
= 0;
445 static void wpas_dpp_reply_wait_timeout(void *eloop_ctx
, void *timeout_ctx
)
447 struct wpa_supplicant
*wpa_s
= eloop_ctx
;
448 struct dpp_authentication
*auth
= wpa_s
->dpp_auth
;
450 struct os_reltime now
, diff
;
451 unsigned int wait_time
, diff_ms
;
453 if (!auth
|| !auth
->waiting_auth_resp
)
456 wait_time
= wpa_s
->dpp_resp_wait_time
?
457 wpa_s
->dpp_resp_wait_time
: 2000;
458 os_get_reltime(&now
);
459 os_reltime_sub(&now
, &wpa_s
->dpp_last_init
, &diff
);
460 diff_ms
= diff
.sec
* 1000 + diff
.usec
/ 1000;
461 wpa_printf(MSG_DEBUG
,
462 "DPP: Reply wait timeout - wait_time=%u diff_ms=%u",
465 if (auth
->auth_req_ack
&& diff_ms
>= wait_time
) {
466 /* Peer ACK'ed Authentication Request frame, but did not reply
467 * with Authentication Response frame within two seconds. */
469 "DPP: No response received from responder - stopping initiation attempt");
470 wpa_msg(wpa_s
, MSG_INFO
, DPP_EVENT_AUTH_INIT_FAILED
);
471 offchannel_send_action_done(wpa_s
);
472 wpas_dpp_listen_stop(wpa_s
);
473 dpp_auth_deinit(auth
);
474 wpa_s
->dpp_auth
= NULL
;
478 if (diff_ms
>= wait_time
) {
479 /* Authentication Request frame was not ACK'ed and no reply
480 * was receiving within two seconds. */
481 wpa_printf(MSG_DEBUG
,
482 "DPP: Continue Initiator channel iteration");
483 offchannel_send_action_done(wpa_s
);
484 wpas_dpp_listen_stop(wpa_s
);
485 wpas_dpp_auth_init_next(wpa_s
);
489 /* Driver did not support 2000 ms long wait_time with TX command, so
490 * schedule listen operation to continue waiting for the response.
492 * DPP listen operations continue until stopped, so simply schedule a
493 * new call to this function at the point when the two second reply
494 * wait has expired. */
495 wait_time
-= diff_ms
;
497 freq
= auth
->curr_freq
;
498 if (auth
->neg_freq
> 0)
499 freq
= auth
->neg_freq
;
500 wpa_printf(MSG_DEBUG
,
501 "DPP: Continue reply wait on channel %u MHz for %u ms",
503 wpa_s
->dpp_in_response_listen
= 1;
504 wpas_dpp_listen_start(wpa_s
, freq
);
506 eloop_register_timeout(wait_time
/ 1000, (wait_time
% 1000) * 1000,
507 wpas_dpp_reply_wait_timeout
, wpa_s
, NULL
);
511 static void wpas_dpp_set_testing_options(struct wpa_supplicant
*wpa_s
,
512 struct dpp_authentication
*auth
)
514 #ifdef CONFIG_TESTING_OPTIONS
515 if (wpa_s
->dpp_config_obj_override
)
516 auth
->config_obj_override
=
517 os_strdup(wpa_s
->dpp_config_obj_override
);
518 if (wpa_s
->dpp_discovery_override
)
519 auth
->discovery_override
=
520 os_strdup(wpa_s
->dpp_discovery_override
);
521 if (wpa_s
->dpp_groups_override
)
522 auth
->groups_override
=
523 os_strdup(wpa_s
->dpp_groups_override
);
524 auth
->ignore_netaccesskey_mismatch
=
525 wpa_s
->dpp_ignore_netaccesskey_mismatch
;
526 #endif /* CONFIG_TESTING_OPTIONS */
530 static void wpas_dpp_set_configurator(struct wpa_supplicant
*wpa_s
,
531 struct dpp_authentication
*auth
,
534 const char *pos
, *end
;
535 struct dpp_configuration
*conf_sta
= NULL
, *conf_ap
= NULL
;
536 struct dpp_configurator
*conf
= NULL
;
537 u8 ssid
[32] = { "test" };
543 char *group_id
= NULL
;
548 wpa_printf(MSG_DEBUG
, "DPP: Set configurator parameters: %s", cmd
);
549 pos
= os_strstr(cmd
, " ssid=");
552 end
= os_strchr(pos
, ' ');
553 ssid_len
= end
? (size_t) (end
- pos
) : os_strlen(pos
);
555 if (ssid_len
> sizeof(ssid
) ||
556 hexstr2bin(pos
, ssid
, ssid_len
) < 0)
560 pos
= os_strstr(cmd
, " pass=");
563 end
= os_strchr(pos
, ' ');
564 pass_len
= end
? (size_t) (end
- pos
) : os_strlen(pos
);
566 if (pass_len
> sizeof(pass
) - 1 || pass_len
< 8 ||
567 hexstr2bin(pos
, (u8
*) pass
, pass_len
) < 0)
571 pos
= os_strstr(cmd
, " psk=");
574 if (hexstr2bin(pos
, psk
, PMK_LEN
) < 0)
579 pos
= os_strstr(cmd
, " group_id=");
584 end
= os_strchr(pos
, ' ');
585 group_id_len
= end
? (size_t) (end
- pos
) : os_strlen(pos
);
586 group_id
= os_malloc(group_id_len
+ 1);
589 os_memcpy(group_id
, pos
, group_id_len
);
590 group_id
[group_id_len
] = '\0';
593 if (os_strstr(cmd
, " conf=sta-")) {
594 conf_sta
= os_zalloc(sizeof(struct dpp_configuration
));
597 os_memcpy(conf_sta
->ssid
, ssid
, ssid_len
);
598 conf_sta
->ssid_len
= ssid_len
;
599 if (os_strstr(cmd
, " conf=sta-psk") ||
600 os_strstr(cmd
, " conf=sta-sae") ||
601 os_strstr(cmd
, " conf=sta-psk-sae")) {
602 if (os_strstr(cmd
, " conf=sta-psk-sae"))
603 conf_sta
->akm
= DPP_AKM_PSK_SAE
;
604 else if (os_strstr(cmd
, " conf=sta-sae"))
605 conf_sta
->akm
= DPP_AKM_SAE
;
607 conf_sta
->akm
= DPP_AKM_PSK
;
609 os_memcpy(conf_sta
->psk
, psk
, PMK_LEN
);
611 conf_sta
->passphrase
= os_strdup(pass
);
612 if (!conf_sta
->passphrase
)
615 } else if (os_strstr(cmd
, " conf=sta-dpp")) {
616 conf_sta
->akm
= DPP_AKM_DPP
;
620 if (os_strstr(cmd
, " group_id=")) {
621 conf_sta
->group_id
= group_id
;
626 if (os_strstr(cmd
, " conf=ap-")) {
627 conf_ap
= os_zalloc(sizeof(struct dpp_configuration
));
630 os_memcpy(conf_ap
->ssid
, ssid
, ssid_len
);
631 conf_ap
->ssid_len
= ssid_len
;
632 if (os_strstr(cmd
, " conf=ap-psk") ||
633 os_strstr(cmd
, " conf=ap-sae") ||
634 os_strstr(cmd
, " conf=ap-psk-sae")) {
635 if (os_strstr(cmd
, " conf=ap-psk-sae"))
636 conf_ap
->akm
= DPP_AKM_PSK_SAE
;
637 else if (os_strstr(cmd
, " conf=ap-sae"))
638 conf_ap
->akm
= DPP_AKM_SAE
;
640 conf_ap
->akm
= DPP_AKM_PSK
;
642 os_memcpy(conf_ap
->psk
, psk
, PMK_LEN
);
644 conf_ap
->passphrase
= os_strdup(pass
);
645 if (!conf_ap
->passphrase
)
648 } else if (os_strstr(cmd
, " conf=ap-dpp")) {
649 conf_ap
->akm
= DPP_AKM_DPP
;
653 if (os_strstr(cmd
, " group_id=")) {
654 conf_ap
->group_id
= group_id
;
659 pos
= os_strstr(cmd
, " expiry=");
664 val
= strtol(pos
, NULL
, 0);
668 conf_sta
->netaccesskey_expiry
= val
;
670 conf_ap
->netaccesskey_expiry
= val
;
673 pos
= os_strstr(cmd
, " configurator=");
676 conf
= dpp_configurator_get_id(wpa_s
, atoi(pos
));
679 "DPP: Could not find the specified configurator");
683 auth
->conf_sta
= conf_sta
;
684 auth
->conf_ap
= conf_ap
;
690 wpa_printf(MSG_DEBUG
, "DPP: Failed to set configurator parameters");
691 dpp_configuration_free(conf_sta
);
692 dpp_configuration_free(conf_ap
);
697 static void wpas_dpp_init_timeout(void *eloop_ctx
, void *timeout_ctx
)
699 struct wpa_supplicant
*wpa_s
= eloop_ctx
;
701 if (!wpa_s
->dpp_auth
)
703 wpa_printf(MSG_DEBUG
, "DPP: Retry initiation after timeout");
704 wpas_dpp_auth_init_next(wpa_s
);
708 static int wpas_dpp_auth_init_next(struct wpa_supplicant
*wpa_s
)
710 struct dpp_authentication
*auth
= wpa_s
->dpp_auth
;
712 unsigned int wait_time
, max_wait_time
, freq
, max_tries
, used
;
713 struct os_reltime now
, diff
;
715 wpa_s
->dpp_in_response_listen
= 0;
719 if (auth
->freq_idx
== 0)
720 os_get_reltime(&wpa_s
->dpp_init_iter_start
);
722 if (auth
->freq_idx
>= auth
->num_freq
) {
723 auth
->num_freq_iters
++;
724 if (wpa_s
->dpp_init_max_tries
)
725 max_tries
= wpa_s
->dpp_init_max_tries
;
728 if (auth
->num_freq_iters
>= max_tries
|| auth
->auth_req_ack
) {
730 "DPP: No response received from responder - stopping initiation attempt");
731 wpa_msg(wpa_s
, MSG_INFO
, DPP_EVENT_AUTH_INIT_FAILED
);
732 eloop_cancel_timeout(wpas_dpp_reply_wait_timeout
,
734 offchannel_send_action_done(wpa_s
);
735 dpp_auth_deinit(wpa_s
->dpp_auth
);
736 wpa_s
->dpp_auth
= NULL
;
740 eloop_cancel_timeout(wpas_dpp_init_timeout
, wpa_s
, NULL
);
741 if (wpa_s
->dpp_init_retry_time
)
742 wait_time
= wpa_s
->dpp_init_retry_time
;
745 os_get_reltime(&now
);
746 os_reltime_sub(&now
, &wpa_s
->dpp_init_iter_start
, &diff
);
747 used
= diff
.sec
* 1000 + diff
.usec
/ 1000;
748 if (used
> wait_time
)
752 wpa_printf(MSG_DEBUG
, "DPP: Next init attempt in %u ms",
754 eloop_register_timeout(wait_time
/ 1000,
755 (wait_time
% 1000) * 1000,
756 wpas_dpp_init_timeout
, wpa_s
,
760 freq
= auth
->freq
[auth
->freq_idx
++];
761 auth
->curr_freq
= freq
;
763 if (is_zero_ether_addr(auth
->peer_bi
->mac_addr
))
766 dst
= auth
->peer_bi
->mac_addr
;
767 wpa_s
->dpp_auth_ok_on_ack
= 0;
768 eloop_cancel_timeout(wpas_dpp_reply_wait_timeout
, wpa_s
, NULL
);
769 wait_time
= wpa_s
->max_remain_on_chan
;
770 max_wait_time
= wpa_s
->dpp_resp_wait_time
?
771 wpa_s
->dpp_resp_wait_time
: 2000;
772 if (wait_time
> max_wait_time
)
773 wait_time
= max_wait_time
;
774 wait_time
+= 10; /* give the driver some extra time to complete */
775 eloop_register_timeout(wait_time
/ 1000, (wait_time
% 1000) * 1000,
776 wpas_dpp_reply_wait_timeout
,
779 if (auth
->neg_freq
> 0 && freq
!= auth
->neg_freq
) {
780 wpa_printf(MSG_DEBUG
,
781 "DPP: Initiate on %u MHz and move to neg_freq %u MHz for response",
782 freq
, auth
->neg_freq
);
784 wpa_msg(wpa_s
, MSG_INFO
, DPP_EVENT_TX
"dst=" MACSTR
" freq=%u type=%d",
785 MAC2STR(dst
), freq
, DPP_PA_AUTHENTICATION_REQ
);
786 auth
->auth_req_ack
= 0;
787 os_get_reltime(&wpa_s
->dpp_last_init
);
788 return offchannel_send_action(wpa_s
, freq
, dst
,
789 wpa_s
->own_addr
, broadcast
,
790 wpabuf_head(auth
->req_msg
),
791 wpabuf_len(auth
->req_msg
),
792 wait_time
, wpas_dpp_tx_status
, 0);
796 int wpas_dpp_auth_init(struct wpa_supplicant
*wpa_s
, const char *cmd
)
799 struct dpp_bootstrap_info
*peer_bi
, *own_bi
= NULL
;
800 u8 allowed_roles
= DPP_CAPAB_CONFIGURATOR
;
801 unsigned int neg_freq
= 0;
803 wpa_s
->dpp_gas_client
= 0;
805 pos
= os_strstr(cmd
, " peer=");
809 peer_bi
= dpp_bootstrap_get_id(wpa_s
, atoi(pos
));
812 "DPP: Could not find bootstrapping info for the identified peer");
816 pos
= os_strstr(cmd
, " own=");
819 own_bi
= dpp_bootstrap_get_id(wpa_s
, atoi(pos
));
822 "DPP: Could not find bootstrapping info for the identified local entry");
826 if (peer_bi
->curve
!= own_bi
->curve
) {
828 "DPP: Mismatching curves in bootstrapping info (peer=%s own=%s)",
829 peer_bi
->curve
->name
, own_bi
->curve
->name
);
834 pos
= os_strstr(cmd
, " role=");
837 if (os_strncmp(pos
, "configurator", 12) == 0)
838 allowed_roles
= DPP_CAPAB_CONFIGURATOR
;
839 else if (os_strncmp(pos
, "enrollee", 8) == 0)
840 allowed_roles
= DPP_CAPAB_ENROLLEE
;
841 else if (os_strncmp(pos
, "either", 6) == 0)
842 allowed_roles
= DPP_CAPAB_CONFIGURATOR
|
848 pos
= os_strstr(cmd
, " netrole=");
851 wpa_s
->dpp_netrole_ap
= os_strncmp(pos
, "ap", 2) == 0;
854 pos
= os_strstr(cmd
, " neg_freq=");
856 neg_freq
= atoi(pos
+ 10);
858 if (wpa_s
->dpp_auth
) {
859 eloop_cancel_timeout(wpas_dpp_init_timeout
, wpa_s
, NULL
);
860 eloop_cancel_timeout(wpas_dpp_reply_wait_timeout
, wpa_s
, NULL
);
861 eloop_cancel_timeout(wpas_dpp_auth_resp_retry_timeout
, wpa_s
,
863 offchannel_send_action_done(wpa_s
);
864 dpp_auth_deinit(wpa_s
->dpp_auth
);
866 wpa_s
->dpp_auth
= dpp_auth_init(wpa_s
, peer_bi
, own_bi
, allowed_roles
,
868 wpa_s
->hw
.modes
, wpa_s
->hw
.num_modes
);
869 if (!wpa_s
->dpp_auth
)
871 wpas_dpp_set_testing_options(wpa_s
, wpa_s
->dpp_auth
);
872 wpas_dpp_set_configurator(wpa_s
, wpa_s
->dpp_auth
, cmd
);
874 wpa_s
->dpp_auth
->neg_freq
= neg_freq
;
876 if (!is_zero_ether_addr(peer_bi
->mac_addr
))
877 os_memcpy(wpa_s
->dpp_auth
->peer_mac_addr
, peer_bi
->mac_addr
,
880 return wpas_dpp_auth_init_next(wpa_s
);
886 struct wpas_dpp_listen_work
{
888 unsigned int duration
;
889 struct wpabuf
*probe_resp_ie
;
893 static void wpas_dpp_listen_work_free(struct wpas_dpp_listen_work
*lwork
)
901 static void wpas_dpp_listen_work_done(struct wpa_supplicant
*wpa_s
)
903 struct wpas_dpp_listen_work
*lwork
;
905 if (!wpa_s
->dpp_listen_work
)
908 lwork
= wpa_s
->dpp_listen_work
->ctx
;
909 wpas_dpp_listen_work_free(lwork
);
910 radio_work_done(wpa_s
->dpp_listen_work
);
911 wpa_s
->dpp_listen_work
= NULL
;
915 static void dpp_start_listen_cb(struct wpa_radio_work
*work
, int deinit
)
917 struct wpa_supplicant
*wpa_s
= work
->wpa_s
;
918 struct wpas_dpp_listen_work
*lwork
= work
->ctx
;
922 wpa_s
->dpp_listen_work
= NULL
;
923 wpas_dpp_listen_stop(wpa_s
);
925 wpas_dpp_listen_work_free(lwork
);
929 wpa_s
->dpp_listen_work
= work
;
931 wpa_s
->dpp_pending_listen_freq
= lwork
->freq
;
933 if (wpa_drv_remain_on_channel(wpa_s
, lwork
->freq
,
934 wpa_s
->max_remain_on_chan
) < 0) {
935 wpa_printf(MSG_DEBUG
,
936 "DPP: Failed to request the driver to remain on channel (%u MHz) for listen",
938 wpas_dpp_listen_work_done(wpa_s
);
939 wpa_s
->dpp_pending_listen_freq
= 0;
942 wpa_s
->off_channel_freq
= 0;
943 wpa_s
->roc_waiting_drv_freq
= lwork
->freq
;
947 static int wpas_dpp_listen_start(struct wpa_supplicant
*wpa_s
,
950 struct wpas_dpp_listen_work
*lwork
;
952 if (wpa_s
->dpp_listen_work
) {
953 wpa_printf(MSG_DEBUG
,
954 "DPP: Reject start_listen since dpp_listen_work already exists");
958 if (wpa_s
->dpp_listen_freq
)
959 wpas_dpp_listen_stop(wpa_s
);
960 wpa_s
->dpp_listen_freq
= freq
;
962 lwork
= os_zalloc(sizeof(*lwork
));
967 if (radio_add_work(wpa_s
, freq
, "dpp-listen", 0, dpp_start_listen_cb
,
969 wpas_dpp_listen_work_free(lwork
);
977 int wpas_dpp_listen(struct wpa_supplicant
*wpa_s
, const char *cmd
)
985 if (os_strstr(cmd
, " role=configurator"))
986 wpa_s
->dpp_allowed_roles
= DPP_CAPAB_CONFIGURATOR
;
987 else if (os_strstr(cmd
, " role=enrollee"))
988 wpa_s
->dpp_allowed_roles
= DPP_CAPAB_ENROLLEE
;
990 wpa_s
->dpp_allowed_roles
= DPP_CAPAB_CONFIGURATOR
|
992 wpa_s
->dpp_qr_mutual
= os_strstr(cmd
, " qr=mutual") != NULL
;
993 wpa_s
->dpp_netrole_ap
= os_strstr(cmd
, " netrole=ap") != NULL
;
994 if (wpa_s
->dpp_listen_freq
== (unsigned int) freq
) {
995 wpa_printf(MSG_DEBUG
, "DPP: Already listening on %u MHz",
1000 return wpas_dpp_listen_start(wpa_s
, freq
);
1004 void wpas_dpp_listen_stop(struct wpa_supplicant
*wpa_s
)
1006 wpa_s
->dpp_in_response_listen
= 0;
1007 if (!wpa_s
->dpp_listen_freq
)
1010 wpa_printf(MSG_DEBUG
, "DPP: Stop listen on %u MHz",
1011 wpa_s
->dpp_listen_freq
);
1012 wpa_drv_cancel_remain_on_channel(wpa_s
);
1013 wpa_s
->dpp_listen_freq
= 0;
1014 wpas_dpp_listen_work_done(wpa_s
);
1018 void wpas_dpp_remain_on_channel_cb(struct wpa_supplicant
*wpa_s
,
1021 if (!wpa_s
->dpp_listen_freq
&& !wpa_s
->dpp_pending_listen_freq
)
1024 wpa_printf(MSG_DEBUG
,
1025 "DPP: remain-on-channel callback (off_channel_freq=%u dpp_pending_listen_freq=%d roc_waiting_drv_freq=%d freq=%u)",
1026 wpa_s
->off_channel_freq
, wpa_s
->dpp_pending_listen_freq
,
1027 wpa_s
->roc_waiting_drv_freq
, freq
);
1028 if (wpa_s
->off_channel_freq
&&
1029 wpa_s
->off_channel_freq
== wpa_s
->dpp_pending_listen_freq
) {
1030 wpa_printf(MSG_DEBUG
, "DPP: Listen on %u MHz started", freq
);
1031 wpa_s
->dpp_pending_listen_freq
= 0;
1033 wpa_printf(MSG_DEBUG
,
1034 "DPP: Ignore remain-on-channel callback (off_channel_freq=%u dpp_pending_listen_freq=%d freq=%u)",
1035 wpa_s
->off_channel_freq
,
1036 wpa_s
->dpp_pending_listen_freq
, freq
);
1041 void wpas_dpp_cancel_remain_on_channel_cb(struct wpa_supplicant
*wpa_s
,
1044 wpas_dpp_listen_work_done(wpa_s
);
1046 if (wpa_s
->dpp_auth
&& wpa_s
->dpp_in_response_listen
) {
1047 unsigned int new_freq
;
1049 /* Continue listen with a new remain-on-channel */
1050 if (wpa_s
->dpp_auth
->neg_freq
> 0)
1051 new_freq
= wpa_s
->dpp_auth
->neg_freq
;
1053 new_freq
= wpa_s
->dpp_auth
->curr_freq
;
1054 wpa_printf(MSG_DEBUG
,
1055 "DPP: Continue wait on %u MHz for the ongoing DPP provisioning session",
1057 wpas_dpp_listen_start(wpa_s
, new_freq
);
1061 if (wpa_s
->dpp_listen_freq
) {
1062 /* Continue listen with a new remain-on-channel */
1063 wpas_dpp_listen_start(wpa_s
, wpa_s
->dpp_listen_freq
);
1068 static void wpas_dpp_rx_auth_req(struct wpa_supplicant
*wpa_s
, const u8
*src
,
1069 const u8
*hdr
, const u8
*buf
, size_t len
,
1072 const u8
*r_bootstrap
, *i_bootstrap
;
1073 u16 r_bootstrap_len
, i_bootstrap_len
;
1074 struct dpp_bootstrap_info
*bi
, *own_bi
= NULL
, *peer_bi
= NULL
;
1076 wpa_printf(MSG_DEBUG
, "DPP: Authentication Request from " MACSTR
,
1079 r_bootstrap
= dpp_get_attr(buf
, len
, DPP_ATTR_R_BOOTSTRAP_KEY_HASH
,
1081 if (!r_bootstrap
|| r_bootstrap_len
!= SHA256_MAC_LEN
) {
1082 wpa_msg(wpa_s
, MSG_INFO
, DPP_EVENT_FAIL
1083 "Missing or invalid required Responder Bootstrapping Key Hash attribute");
1086 wpa_hexdump(MSG_MSGDUMP
, "DPP: Responder Bootstrapping Key Hash",
1087 r_bootstrap
, r_bootstrap_len
);
1089 i_bootstrap
= dpp_get_attr(buf
, len
, DPP_ATTR_I_BOOTSTRAP_KEY_HASH
,
1091 if (!i_bootstrap
|| i_bootstrap_len
!= SHA256_MAC_LEN
) {
1092 wpa_msg(wpa_s
, MSG_INFO
, DPP_EVENT_FAIL
1093 "Missing or invalid required Initiator Bootstrapping Key Hash attribute");
1096 wpa_hexdump(MSG_MSGDUMP
, "DPP: Initiator Bootstrapping Key Hash",
1097 i_bootstrap
, i_bootstrap_len
);
1099 /* Try to find own and peer bootstrapping key matches based on the
1100 * received hash values */
1101 dl_list_for_each(bi
, &wpa_s
->dpp_bootstrap
, struct dpp_bootstrap_info
,
1103 if (!own_bi
&& bi
->own
&&
1104 os_memcmp(bi
->pubkey_hash
, r_bootstrap
,
1105 SHA256_MAC_LEN
) == 0) {
1106 wpa_printf(MSG_DEBUG
,
1107 "DPP: Found matching own bootstrapping information");
1111 if (!peer_bi
&& !bi
->own
&&
1112 os_memcmp(bi
->pubkey_hash
, i_bootstrap
,
1113 SHA256_MAC_LEN
) == 0) {
1114 wpa_printf(MSG_DEBUG
,
1115 "DPP: Found matching peer bootstrapping information");
1119 if (own_bi
&& peer_bi
)
1124 wpa_msg(wpa_s
, MSG_INFO
, DPP_EVENT_FAIL
1125 "No matching own bootstrapping key found - ignore message");
1129 if (wpa_s
->dpp_auth
) {
1130 wpa_msg(wpa_s
, MSG_INFO
, DPP_EVENT_FAIL
1131 "Already in DPP authentication exchange - ignore new one");
1135 wpa_s
->dpp_gas_client
= 0;
1136 wpa_s
->dpp_auth_ok_on_ack
= 0;
1137 wpa_s
->dpp_auth
= dpp_auth_req_rx(wpa_s
, wpa_s
->dpp_allowed_roles
,
1138 wpa_s
->dpp_qr_mutual
,
1139 peer_bi
, own_bi
, freq
, hdr
, buf
, len
);
1140 if (!wpa_s
->dpp_auth
) {
1141 wpa_printf(MSG_DEBUG
, "DPP: No response generated");
1144 wpas_dpp_set_testing_options(wpa_s
, wpa_s
->dpp_auth
);
1145 wpas_dpp_set_configurator(wpa_s
, wpa_s
->dpp_auth
,
1146 wpa_s
->dpp_configurator_params
);
1147 os_memcpy(wpa_s
->dpp_auth
->peer_mac_addr
, src
, ETH_ALEN
);
1149 if (wpa_s
->dpp_listen_freq
&&
1150 wpa_s
->dpp_listen_freq
!= wpa_s
->dpp_auth
->curr_freq
) {
1151 wpa_printf(MSG_DEBUG
,
1152 "DPP: Stop listen on %u MHz to allow response on the request %u MHz",
1153 wpa_s
->dpp_listen_freq
, wpa_s
->dpp_auth
->curr_freq
);
1154 wpas_dpp_listen_stop(wpa_s
);
1157 wpa_msg(wpa_s
, MSG_INFO
, DPP_EVENT_TX
"dst=" MACSTR
" freq=%u type=%d",
1158 MAC2STR(src
), wpa_s
->dpp_auth
->curr_freq
,
1159 DPP_PA_AUTHENTICATION_RESP
);
1160 offchannel_send_action(wpa_s
, wpa_s
->dpp_auth
->curr_freq
,
1161 src
, wpa_s
->own_addr
, broadcast
,
1162 wpabuf_head(wpa_s
->dpp_auth
->resp_msg
),
1163 wpabuf_len(wpa_s
->dpp_auth
->resp_msg
),
1164 500, wpas_dpp_tx_status
, 0);
1168 static void wpas_dpp_start_gas_server(struct wpa_supplicant
*wpa_s
)
1170 /* TODO: stop wait and start ROC */
1174 static struct wpa_ssid
* wpas_dpp_add_network(struct wpa_supplicant
*wpa_s
,
1175 struct dpp_authentication
*auth
)
1177 struct wpa_ssid
*ssid
;
1179 ssid
= wpa_config_add_network(wpa_s
->conf
);
1182 wpas_notify_network_added(wpa_s
, ssid
);
1183 wpa_config_set_network_defaults(ssid
);
1186 ssid
->ssid
= os_malloc(auth
->ssid_len
);
1189 os_memcpy(ssid
->ssid
, auth
->ssid
, auth
->ssid_len
);
1190 ssid
->ssid_len
= auth
->ssid_len
;
1192 if (auth
->connector
) {
1193 ssid
->key_mgmt
= WPA_KEY_MGMT_DPP
;
1194 ssid
->ieee80211w
= MGMT_FRAME_PROTECTION_REQUIRED
;
1195 ssid
->dpp_connector
= os_strdup(auth
->connector
);
1196 if (!ssid
->dpp_connector
)
1200 if (auth
->c_sign_key
) {
1201 ssid
->dpp_csign
= os_malloc(wpabuf_len(auth
->c_sign_key
));
1202 if (!ssid
->dpp_csign
)
1204 os_memcpy(ssid
->dpp_csign
, wpabuf_head(auth
->c_sign_key
),
1205 wpabuf_len(auth
->c_sign_key
));
1206 ssid
->dpp_csign_len
= wpabuf_len(auth
->c_sign_key
);
1209 if (auth
->net_access_key
) {
1210 ssid
->dpp_netaccesskey
=
1211 os_malloc(wpabuf_len(auth
->net_access_key
));
1212 if (!ssid
->dpp_netaccesskey
)
1214 os_memcpy(ssid
->dpp_netaccesskey
,
1215 wpabuf_head(auth
->net_access_key
),
1216 wpabuf_len(auth
->net_access_key
));
1217 ssid
->dpp_netaccesskey_len
= wpabuf_len(auth
->net_access_key
);
1218 ssid
->dpp_netaccesskey_expiry
= auth
->net_access_key_expiry
;
1221 if (!auth
->connector
) {
1223 if (auth
->akm
== DPP_AKM_PSK
|| auth
->akm
== DPP_AKM_PSK_SAE
)
1224 ssid
->key_mgmt
|= WPA_KEY_MGMT_PSK
|
1225 WPA_KEY_MGMT_PSK_SHA256
| WPA_KEY_MGMT_FT_PSK
;
1226 if (auth
->akm
== DPP_AKM_SAE
|| auth
->akm
== DPP_AKM_PSK_SAE
)
1227 ssid
->key_mgmt
|= WPA_KEY_MGMT_SAE
|
1228 WPA_KEY_MGMT_FT_SAE
;
1229 ssid
->ieee80211w
= MGMT_FRAME_PROTECTION_OPTIONAL
;
1230 if (auth
->passphrase
[0]) {
1231 if (wpa_config_set_quoted(ssid
, "psk",
1232 auth
->passphrase
) < 0)
1234 wpa_config_update_psk(ssid
);
1235 ssid
->export_keys
= 1;
1237 ssid
->psk_set
= auth
->psk_set
;
1238 os_memcpy(ssid
->psk
, auth
->psk
, PMK_LEN
);
1244 wpas_notify_network_removed(wpa_s
, ssid
);
1245 wpa_config_remove_network(wpa_s
->conf
, ssid
->id
);
1250 static void wpas_dpp_process_config(struct wpa_supplicant
*wpa_s
,
1251 struct dpp_authentication
*auth
)
1253 struct wpa_ssid
*ssid
;
1255 if (wpa_s
->conf
->dpp_config_processing
< 1)
1258 ssid
= wpas_dpp_add_network(wpa_s
, auth
);
1262 wpa_msg(wpa_s
, MSG_INFO
, DPP_EVENT_NETWORK_ID
"%d", ssid
->id
);
1263 if (wpa_s
->conf
->dpp_config_processing
< 2)
1266 wpa_printf(MSG_DEBUG
, "DPP: Trying to connect to the new network");
1268 wpa_s
->disconnected
= 0;
1269 wpa_s
->reassociate
= 1;
1270 wpa_s
->scan_runs
= 0;
1271 wpa_s
->normal_scans
= 0;
1272 wpa_supplicant_cancel_sched_scan(wpa_s
);
1273 wpa_supplicant_req_scan(wpa_s
, 0, 0);
1277 static void wpas_dpp_handle_config_obj(struct wpa_supplicant
*wpa_s
,
1278 struct dpp_authentication
*auth
)
1280 wpa_msg(wpa_s
, MSG_INFO
, DPP_EVENT_CONF_RECEIVED
);
1282 wpa_msg(wpa_s
, MSG_INFO
, DPP_EVENT_CONFOBJ_SSID
"%s",
1283 wpa_ssid_txt(auth
->ssid
, auth
->ssid_len
));
1284 if (auth
->connector
) {
1285 /* TODO: Save the Connector and consider using a command
1286 * to fetch the value instead of sending an event with
1287 * it. The Connector could end up being larger than what
1288 * most clients are ready to receive as an event
1290 wpa_msg(wpa_s
, MSG_INFO
, DPP_EVENT_CONNECTOR
"%s",
1293 if (auth
->c_sign_key
) {
1297 hexlen
= 2 * wpabuf_len(auth
->c_sign_key
) + 1;
1298 hex
= os_malloc(hexlen
);
1300 wpa_snprintf_hex(hex
, hexlen
,
1301 wpabuf_head(auth
->c_sign_key
),
1302 wpabuf_len(auth
->c_sign_key
));
1303 wpa_msg(wpa_s
, MSG_INFO
, DPP_EVENT_C_SIGN_KEY
"%s",
1308 if (auth
->net_access_key
) {
1312 hexlen
= 2 * wpabuf_len(auth
->net_access_key
) + 1;
1313 hex
= os_malloc(hexlen
);
1315 wpa_snprintf_hex(hex
, hexlen
,
1316 wpabuf_head(auth
->net_access_key
),
1317 wpabuf_len(auth
->net_access_key
));
1318 if (auth
->net_access_key_expiry
)
1319 wpa_msg(wpa_s
, MSG_INFO
,
1320 DPP_EVENT_NET_ACCESS_KEY
"%s %lu", hex
,
1322 auth
->net_access_key_expiry
);
1324 wpa_msg(wpa_s
, MSG_INFO
,
1325 DPP_EVENT_NET_ACCESS_KEY
"%s", hex
);
1330 wpas_dpp_process_config(wpa_s
, auth
);
1334 static void wpas_dpp_gas_resp_cb(void *ctx
, const u8
*addr
, u8 dialog_token
,
1335 enum gas_query_result result
,
1336 const struct wpabuf
*adv_proto
,
1337 const struct wpabuf
*resp
, u16 status_code
)
1339 struct wpa_supplicant
*wpa_s
= ctx
;
1341 struct dpp_authentication
*auth
= wpa_s
->dpp_auth
;
1343 wpa_s
->dpp_gas_dialog_token
= -1;
1345 if (!auth
|| !auth
->auth_success
) {
1346 wpa_printf(MSG_DEBUG
, "DPP: No matching exchange in progress");
1349 if (!resp
|| status_code
!= WLAN_STATUS_SUCCESS
) {
1350 wpa_printf(MSG_DEBUG
, "DPP: GAS query did not succeed");
1354 wpa_hexdump_buf(MSG_DEBUG
, "DPP: Configuration Response adv_proto",
1356 wpa_hexdump_buf(MSG_DEBUG
, "DPP: Configuration Response (GAS response)",
1359 if (wpabuf_len(adv_proto
) != 10 ||
1360 !(pos
= wpabuf_head(adv_proto
)) ||
1361 pos
[0] != WLAN_EID_ADV_PROTO
||
1363 pos
[3] != WLAN_EID_VENDOR_SPECIFIC
||
1365 WPA_GET_BE24(&pos
[5]) != OUI_WFA
||
1368 wpa_printf(MSG_DEBUG
,
1369 "DPP: Not a DPP Advertisement Protocol ID");
1373 if (dpp_conf_resp_rx(auth
, resp
) < 0) {
1374 wpa_printf(MSG_DEBUG
, "DPP: Configuration attempt failed");
1378 wpas_dpp_handle_config_obj(wpa_s
, auth
);
1379 dpp_auth_deinit(wpa_s
->dpp_auth
);
1380 wpa_s
->dpp_auth
= NULL
;
1384 wpa_msg(wpa_s
, MSG_INFO
, DPP_EVENT_CONF_FAILED
);
1385 dpp_auth_deinit(wpa_s
->dpp_auth
);
1386 wpa_s
->dpp_auth
= NULL
;
1390 static void wpas_dpp_start_gas_client(struct wpa_supplicant
*wpa_s
)
1392 struct dpp_authentication
*auth
= wpa_s
->dpp_auth
;
1393 struct wpabuf
*buf
, *conf_req
;
1397 wpa_s
->dpp_gas_client
= 1;
1398 os_snprintf(json
, sizeof(json
),
1399 "{\"name\":\"Test\","
1400 "\"wi-fi_tech\":\"infra\","
1401 "\"netRole\":\"%s\"}",
1402 wpa_s
->dpp_netrole_ap
? "ap" : "sta");
1403 #ifdef CONFIG_TESTING_OPTIONS
1404 if (dpp_test
== DPP_TEST_INVALID_CONFIG_ATTR_OBJ_CONF_REQ
) {
1405 wpa_printf(MSG_INFO
, "DPP: TESTING - invalid Config Attr");
1406 json
[29] = 'k'; /* replace "infra" with "knfra" */
1408 #endif /* CONFIG_TESTING_OPTIONS */
1409 wpa_printf(MSG_DEBUG
, "DPP: GAS Config Attributes: %s", json
);
1411 offchannel_send_action_done(wpa_s
);
1412 wpas_dpp_listen_stop(wpa_s
);
1414 conf_req
= dpp_build_conf_req(auth
, json
);
1416 wpa_printf(MSG_DEBUG
,
1417 "DPP: No configuration request data available");
1421 buf
= gas_build_initial_req(0, 10 + 2 + wpabuf_len(conf_req
));
1423 wpabuf_free(conf_req
);
1427 /* Advertisement Protocol IE */
1428 wpabuf_put_u8(buf
, WLAN_EID_ADV_PROTO
);
1429 wpabuf_put_u8(buf
, 8); /* Length */
1430 wpabuf_put_u8(buf
, 0x7f);
1431 wpabuf_put_u8(buf
, WLAN_EID_VENDOR_SPECIFIC
);
1432 wpabuf_put_u8(buf
, 5);
1433 wpabuf_put_be24(buf
, OUI_WFA
);
1434 wpabuf_put_u8(buf
, DPP_OUI_TYPE
);
1435 wpabuf_put_u8(buf
, 0x01);
1438 wpabuf_put_le16(buf
, wpabuf_len(conf_req
));
1439 wpabuf_put_buf(buf
, conf_req
);
1440 wpabuf_free(conf_req
);
1442 wpa_printf(MSG_DEBUG
, "DPP: GAS request to " MACSTR
" (freq %u MHz)",
1443 MAC2STR(auth
->peer_mac_addr
), auth
->curr_freq
);
1445 res
= gas_query_req(wpa_s
->gas
, auth
->peer_mac_addr
, auth
->curr_freq
,
1446 1, buf
, wpas_dpp_gas_resp_cb
, wpa_s
);
1448 wpa_msg(wpa_s
, MSG_DEBUG
, "GAS: Failed to send Query Request");
1451 wpa_printf(MSG_DEBUG
,
1452 "DPP: GAS query started with dialog token %u", res
);
1453 wpa_s
->dpp_gas_dialog_token
= res
;
1458 static void wpas_dpp_auth_success(struct wpa_supplicant
*wpa_s
, int initiator
)
1460 wpa_printf(MSG_DEBUG
, "DPP: Authentication succeeded");
1461 wpa_msg(wpa_s
, MSG_INFO
, DPP_EVENT_AUTH_SUCCESS
"init=%d", initiator
);
1462 #ifdef CONFIG_TESTING_OPTIONS
1463 if (dpp_test
== DPP_TEST_STOP_AT_AUTH_CONF
) {
1464 wpa_printf(MSG_INFO
,
1465 "DPP: TESTING - stop at Authentication Confirm");
1466 if (wpa_s
->dpp_auth
->configurator
) {
1467 /* Prevent GAS response */
1468 wpa_s
->dpp_auth
->auth_success
= 0;
1472 #endif /* CONFIG_TESTING_OPTIONS */
1474 if (wpa_s
->dpp_auth
->configurator
)
1475 wpas_dpp_start_gas_server(wpa_s
);
1477 wpas_dpp_start_gas_client(wpa_s
);
1481 static void wpas_dpp_rx_auth_resp(struct wpa_supplicant
*wpa_s
, const u8
*src
,
1482 const u8
*hdr
, const u8
*buf
, size_t len
,
1485 struct dpp_authentication
*auth
= wpa_s
->dpp_auth
;
1488 wpa_printf(MSG_DEBUG
, "DPP: Authentication Response from " MACSTR
1489 " (freq %u MHz)", MAC2STR(src
), freq
);
1492 wpa_printf(MSG_DEBUG
,
1493 "DPP: No DPP Authentication in progress - drop");
1497 if (!is_zero_ether_addr(auth
->peer_mac_addr
) &&
1498 os_memcmp(src
, auth
->peer_mac_addr
, ETH_ALEN
) != 0) {
1499 wpa_printf(MSG_DEBUG
, "DPP: MAC address mismatch (expected "
1500 MACSTR
") - drop", MAC2STR(auth
->peer_mac_addr
));
1504 eloop_cancel_timeout(wpas_dpp_reply_wait_timeout
, wpa_s
, NULL
);
1506 if (auth
->curr_freq
!= freq
&& auth
->neg_freq
== freq
) {
1507 wpa_printf(MSG_DEBUG
,
1508 "DPP: Responder accepted request for different negotiation channel");
1509 auth
->curr_freq
= freq
;
1512 eloop_cancel_timeout(wpas_dpp_init_timeout
, wpa_s
, NULL
);
1513 msg
= dpp_auth_resp_rx(auth
, hdr
, buf
, len
);
1515 if (auth
->auth_resp_status
== DPP_STATUS_RESPONSE_PENDING
) {
1516 wpa_printf(MSG_DEBUG
,
1517 "DPP: Start wait for full response");
1518 offchannel_send_action_done(wpa_s
);
1519 wpas_dpp_listen_start(wpa_s
, auth
->curr_freq
);
1522 wpa_printf(MSG_DEBUG
, "DPP: No confirm generated");
1525 os_memcpy(auth
->peer_mac_addr
, src
, ETH_ALEN
);
1527 wpa_msg(wpa_s
, MSG_INFO
, DPP_EVENT_TX
"dst=" MACSTR
" freq=%u type=%d",
1528 MAC2STR(src
), auth
->curr_freq
, DPP_PA_AUTHENTICATION_CONF
);
1529 offchannel_send_action(wpa_s
, auth
->curr_freq
,
1530 src
, wpa_s
->own_addr
, broadcast
,
1531 wpabuf_head(msg
), wpabuf_len(msg
),
1532 500, wpas_dpp_tx_status
, 0);
1534 wpa_s
->dpp_auth_ok_on_ack
= 1;
1538 static void wpas_dpp_rx_auth_conf(struct wpa_supplicant
*wpa_s
, const u8
*src
,
1539 const u8
*hdr
, const u8
*buf
, size_t len
)
1541 struct dpp_authentication
*auth
= wpa_s
->dpp_auth
;
1543 wpa_printf(MSG_DEBUG
, "DPP: Authentication Confirmation from " MACSTR
,
1547 wpa_printf(MSG_DEBUG
,
1548 "DPP: No DPP Authentication in progress - drop");
1552 if (os_memcmp(src
, auth
->peer_mac_addr
, ETH_ALEN
) != 0) {
1553 wpa_printf(MSG_DEBUG
, "DPP: MAC address mismatch (expected "
1554 MACSTR
") - drop", MAC2STR(auth
->peer_mac_addr
));
1558 if (dpp_auth_conf_rx(auth
, hdr
, buf
, len
) < 0) {
1559 wpa_printf(MSG_DEBUG
, "DPP: Authentication failed");
1563 wpas_dpp_auth_success(wpa_s
, 0);
1567 static void wpas_dpp_rx_peer_disc_resp(struct wpa_supplicant
*wpa_s
,
1569 const u8
*buf
, size_t len
)
1571 struct wpa_ssid
*ssid
;
1572 const u8
*connector
, *trans_id
, *status
;
1573 u16 connector_len
, trans_id_len
, status_len
;
1574 struct dpp_introduction intro
;
1575 struct rsn_pmksa_cache_entry
*entry
;
1577 struct os_reltime rnow
;
1579 unsigned int seconds
;
1580 enum dpp_status_error res
;
1582 wpa_printf(MSG_DEBUG
, "DPP: Peer Discovery Response from " MACSTR
,
1584 if (is_zero_ether_addr(wpa_s
->dpp_intro_bssid
) ||
1585 os_memcmp(src
, wpa_s
->dpp_intro_bssid
, ETH_ALEN
) != 0) {
1586 wpa_printf(MSG_DEBUG
, "DPP: Not waiting for response from "
1587 MACSTR
" - drop", MAC2STR(src
));
1590 offchannel_send_action_done(wpa_s
);
1592 for (ssid
= wpa_s
->conf
->ssid
; ssid
; ssid
= ssid
->next
) {
1593 if (ssid
== wpa_s
->dpp_intro_network
)
1596 if (!ssid
|| !ssid
->dpp_connector
|| !ssid
->dpp_netaccesskey
||
1598 wpa_printf(MSG_DEBUG
,
1599 "DPP: Profile not found for network introduction");
1603 trans_id
= dpp_get_attr(buf
, len
, DPP_ATTR_TRANSACTION_ID
,
1605 if (!trans_id
|| trans_id_len
!= 1) {
1606 wpa_printf(MSG_DEBUG
,
1607 "DPP: Peer did not include Transaction ID");
1608 wpa_msg(wpa_s
, MSG_INFO
, DPP_EVENT_INTRO
"peer=" MACSTR
1609 " fail=missing_transaction_id", MAC2STR(src
));
1612 if (trans_id
[0] != TRANSACTION_ID
) {
1613 wpa_printf(MSG_DEBUG
,
1614 "DPP: Ignore frame with unexpected Transaction ID %u",
1616 wpa_msg(wpa_s
, MSG_INFO
, DPP_EVENT_INTRO
"peer=" MACSTR
1617 " fail=transaction_id_mismatch", MAC2STR(src
));
1621 status
= dpp_get_attr(buf
, len
, DPP_ATTR_STATUS
, &status_len
);
1622 if (!status
|| status_len
!= 1) {
1623 wpa_printf(MSG_DEBUG
, "DPP: Peer did not include Status");
1624 wpa_msg(wpa_s
, MSG_INFO
, DPP_EVENT_INTRO
"peer=" MACSTR
1625 " fail=missing_status", MAC2STR(src
));
1628 if (status
[0] != DPP_STATUS_OK
) {
1629 wpa_printf(MSG_DEBUG
,
1630 "DPP: Peer rejected network introduction: Status %u",
1632 wpa_msg(wpa_s
, MSG_INFO
, DPP_EVENT_INTRO
"peer=" MACSTR
1633 " status=%u", MAC2STR(src
), status
[0]);
1637 connector
= dpp_get_attr(buf
, len
, DPP_ATTR_CONNECTOR
, &connector_len
);
1639 wpa_printf(MSG_DEBUG
,
1640 "DPP: Peer did not include its Connector");
1641 wpa_msg(wpa_s
, MSG_INFO
, DPP_EVENT_INTRO
"peer=" MACSTR
1642 " fail=missing_connector", MAC2STR(src
));
1646 res
= dpp_peer_intro(&intro
, ssid
->dpp_connector
,
1647 ssid
->dpp_netaccesskey
,
1648 ssid
->dpp_netaccesskey_len
,
1650 ssid
->dpp_csign_len
,
1651 connector
, connector_len
, &expiry
);
1652 if (res
!= DPP_STATUS_OK
) {
1653 wpa_printf(MSG_INFO
,
1654 "DPP: Network Introduction protocol resulted in failure");
1655 wpa_msg(wpa_s
, MSG_INFO
, DPP_EVENT_INTRO
"peer=" MACSTR
1656 " fail=peer_connector_validation_failed", MAC2STR(src
));
1660 entry
= os_zalloc(sizeof(*entry
));
1663 os_memcpy(entry
->aa
, src
, ETH_ALEN
);
1664 os_memcpy(entry
->pmkid
, intro
.pmkid
, PMKID_LEN
);
1665 os_memcpy(entry
->pmk
, intro
.pmk
, intro
.pmk_len
);
1666 entry
->pmk_len
= intro
.pmk_len
;
1667 entry
->akmp
= WPA_KEY_MGMT_DPP
;
1670 seconds
= expiry
- now
.sec
;
1672 seconds
= 86400 * 7;
1674 os_get_reltime(&rnow
);
1675 entry
->expiration
= rnow
.sec
+ seconds
;
1676 entry
->reauth_time
= rnow
.sec
+ seconds
;
1677 entry
->network_ctx
= ssid
;
1678 wpa_sm_pmksa_cache_add_entry(wpa_s
->wpa
, entry
);
1680 wpa_msg(wpa_s
, MSG_INFO
, DPP_EVENT_INTRO
"peer=" MACSTR
1681 " status=%u", MAC2STR(src
), status
[0]);
1683 wpa_printf(MSG_DEBUG
,
1684 "DPP: Try connection again after successful network introduction");
1685 if (wpa_supplicant_fast_associate(wpa_s
) != 1) {
1686 wpa_supplicant_cancel_sched_scan(wpa_s
);
1687 wpa_supplicant_req_scan(wpa_s
, 0, 0);
1690 os_memset(&intro
, 0, sizeof(intro
));
1694 static int wpas_dpp_allow_ir(struct wpa_supplicant
*wpa_s
, unsigned int freq
)
1698 if (!wpa_s
->hw
.modes
)
1701 for (i
= 0; i
< wpa_s
->hw
.num_modes
; i
++) {
1702 struct hostapd_hw_modes
*mode
= &wpa_s
->hw
.modes
[i
];
1704 for (j
= 0; j
< mode
->num_channels
; j
++) {
1705 struct hostapd_channel_data
*chan
= &mode
->channels
[j
];
1707 if (chan
->freq
!= (int) freq
)
1710 if (chan
->flag
& (HOSTAPD_CHAN_DISABLED
|
1711 HOSTAPD_CHAN_NO_IR
|
1712 HOSTAPD_CHAN_RADAR
))
1719 wpa_printf(MSG_DEBUG
,
1720 "DPP: Frequency %u MHz not supported or does not allow PKEX initiation in the current channel list",
1727 static int wpas_dpp_pkex_next_channel(struct wpa_supplicant
*wpa_s
,
1728 struct dpp_pkex
*pkex
)
1730 if (pkex
->freq
== 2437)
1732 else if (pkex
->freq
== 5745)
1734 else if (pkex
->freq
== 5220)
1737 return -1; /* no more channels to try */
1739 if (wpas_dpp_allow_ir(wpa_s
, pkex
->freq
) == 1) {
1740 wpa_printf(MSG_DEBUG
, "DPP: Try to initiate on %u MHz",
1745 /* Could not use this channel - try the next one */
1746 return wpas_dpp_pkex_next_channel(wpa_s
, pkex
);
1750 static void wpas_dpp_pkex_retry_timeout(void *eloop_ctx
, void *timeout_ctx
)
1752 struct wpa_supplicant
*wpa_s
= eloop_ctx
;
1753 struct dpp_pkex
*pkex
= wpa_s
->dpp_pkex
;
1755 if (!pkex
|| !pkex
->exchange_req
)
1757 if (pkex
->exch_req_tries
>= 5) {
1758 if (wpas_dpp_pkex_next_channel(wpa_s
, pkex
) < 0) {
1759 wpa_msg(wpa_s
, MSG_INFO
, DPP_EVENT_FAIL
1760 "No response from PKEX peer");
1761 dpp_pkex_free(pkex
);
1762 wpa_s
->dpp_pkex
= NULL
;
1765 pkex
->exch_req_tries
= 0;
1768 pkex
->exch_req_tries
++;
1769 wpa_printf(MSG_DEBUG
, "DPP: Retransmit PKEX Exchange Request (try %u)",
1770 pkex
->exch_req_tries
);
1771 wpa_msg(wpa_s
, MSG_INFO
, DPP_EVENT_TX
"dst=" MACSTR
" freq=%u type=%d",
1772 MAC2STR(broadcast
), pkex
->freq
, DPP_PA_PKEX_EXCHANGE_REQ
);
1773 offchannel_send_action(wpa_s
, pkex
->freq
, broadcast
,
1774 wpa_s
->own_addr
, broadcast
,
1775 wpabuf_head(pkex
->exchange_req
),
1776 wpabuf_len(pkex
->exchange_req
),
1777 pkex
->exch_req_wait_time
,
1778 wpas_dpp_tx_pkex_status
, 0);
1783 wpas_dpp_tx_pkex_status(struct wpa_supplicant
*wpa_s
,
1784 unsigned int freq
, const u8
*dst
,
1785 const u8
*src
, const u8
*bssid
,
1786 const u8
*data
, size_t data_len
,
1787 enum offchannel_send_action_result result
)
1789 const char *res_txt
;
1790 struct dpp_pkex
*pkex
= wpa_s
->dpp_pkex
;
1792 res_txt
= result
== OFFCHANNEL_SEND_ACTION_SUCCESS
? "SUCCESS" :
1793 (result
== OFFCHANNEL_SEND_ACTION_NO_ACK
? "no-ACK" :
1795 wpa_printf(MSG_DEBUG
, "DPP: TX status: freq=%u dst=" MACSTR
1796 " result=%s (PKEX)",
1797 freq
, MAC2STR(dst
), res_txt
);
1798 wpa_msg(wpa_s
, MSG_INFO
, DPP_EVENT_TX_STATUS
"dst=" MACSTR
1799 " freq=%u result=%s", MAC2STR(dst
), freq
, res_txt
);
1802 wpa_printf(MSG_DEBUG
,
1803 "DPP: Ignore TX status since there is no ongoing PKEX exchange");
1808 wpa_printf(MSG_DEBUG
,
1809 "DPP: Terminate PKEX exchange due to an earlier error");
1810 if (pkex
->t
> pkex
->own_bi
->pkex_t
)
1811 pkex
->own_bi
->pkex_t
= pkex
->t
;
1812 dpp_pkex_free(pkex
);
1813 wpa_s
->dpp_pkex
= NULL
;
1817 if (pkex
->exch_req_wait_time
&& pkex
->exchange_req
) {
1818 /* Wait for PKEX Exchange Response frame and retry request if
1819 * no response is seen. */
1820 eloop_cancel_timeout(wpas_dpp_pkex_retry_timeout
, wpa_s
, NULL
);
1821 eloop_register_timeout(pkex
->exch_req_wait_time
/ 1000,
1822 (pkex
->exch_req_wait_time
% 1000) * 1000,
1823 wpas_dpp_pkex_retry_timeout
, wpa_s
,
1830 wpas_dpp_rx_pkex_exchange_req(struct wpa_supplicant
*wpa_s
, const u8
*src
,
1831 const u8
*buf
, size_t len
, unsigned int freq
)
1834 unsigned int wait_time
;
1836 wpa_printf(MSG_DEBUG
, "DPP: PKEX Exchange Request from " MACSTR
,
1839 /* TODO: Support multiple PKEX codes by iterating over all the enabled
1842 if (!wpa_s
->dpp_pkex_code
|| !wpa_s
->dpp_pkex_bi
) {
1843 wpa_printf(MSG_DEBUG
,
1844 "DPP: No PKEX code configured - ignore request");
1848 if (wpa_s
->dpp_pkex
) {
1849 /* TODO: Support parallel operations */
1850 wpa_printf(MSG_DEBUG
,
1851 "DPP: Already in PKEX session - ignore new request");
1855 wpa_s
->dpp_pkex
= dpp_pkex_rx_exchange_req(wpa_s
, wpa_s
->dpp_pkex_bi
,
1856 wpa_s
->own_addr
, src
,
1857 wpa_s
->dpp_pkex_identifier
,
1858 wpa_s
->dpp_pkex_code
,
1860 if (!wpa_s
->dpp_pkex
) {
1861 wpa_printf(MSG_DEBUG
,
1862 "DPP: Failed to process the request - ignore it");
1866 msg
= wpa_s
->dpp_pkex
->exchange_resp
;
1867 wait_time
= wpa_s
->max_remain_on_chan
;
1868 if (wait_time
> 2000)
1870 wpa_msg(wpa_s
, MSG_INFO
, DPP_EVENT_TX
"dst=" MACSTR
" freq=%u type=%d",
1871 MAC2STR(src
), freq
, DPP_PA_PKEX_EXCHANGE_RESP
);
1872 offchannel_send_action(wpa_s
, freq
, src
, wpa_s
->own_addr
,
1874 wpabuf_head(msg
), wpabuf_len(msg
),
1875 wait_time
, wpas_dpp_tx_pkex_status
, 0);
1880 wpas_dpp_rx_pkex_exchange_resp(struct wpa_supplicant
*wpa_s
, const u8
*src
,
1881 const u8
*buf
, size_t len
, unsigned int freq
)
1884 unsigned int wait_time
;
1886 wpa_printf(MSG_DEBUG
, "DPP: PKEX Exchange Response from " MACSTR
,
1889 /* TODO: Support multiple PKEX codes by iterating over all the enabled
1892 if (!wpa_s
->dpp_pkex
|| !wpa_s
->dpp_pkex
->initiator
||
1893 wpa_s
->dpp_pkex
->exchange_done
) {
1894 wpa_printf(MSG_DEBUG
, "DPP: No matching PKEX session");
1898 eloop_cancel_timeout(wpas_dpp_pkex_retry_timeout
, wpa_s
, NULL
);
1899 wpa_s
->dpp_pkex
->exch_req_wait_time
= 0;
1901 msg
= dpp_pkex_rx_exchange_resp(wpa_s
->dpp_pkex
, src
, buf
, len
);
1903 wpa_printf(MSG_DEBUG
, "DPP: Failed to process the response");
1907 wpa_printf(MSG_DEBUG
, "DPP: Send PKEX Commit-Reveal Request to " MACSTR
,
1910 wait_time
= wpa_s
->max_remain_on_chan
;
1911 if (wait_time
> 2000)
1913 wpa_msg(wpa_s
, MSG_INFO
, DPP_EVENT_TX
"dst=" MACSTR
" freq=%u type=%d",
1914 MAC2STR(src
), freq
, DPP_PA_PKEX_COMMIT_REVEAL_REQ
);
1915 offchannel_send_action(wpa_s
, freq
, src
, wpa_s
->own_addr
,
1917 wpabuf_head(msg
), wpabuf_len(msg
),
1918 wait_time
, wpas_dpp_tx_pkex_status
, 0);
1923 static struct dpp_bootstrap_info
*
1924 wpas_dpp_pkex_finish(struct wpa_supplicant
*wpa_s
, const u8
*peer
,
1927 struct dpp_pkex
*pkex
= wpa_s
->dpp_pkex
;
1928 struct dpp_bootstrap_info
*bi
;
1930 bi
= os_zalloc(sizeof(*bi
));
1933 bi
->id
= wpas_dpp_next_id(wpa_s
);
1934 bi
->type
= DPP_BOOTSTRAP_PKEX
;
1935 os_memcpy(bi
->mac_addr
, peer
, ETH_ALEN
);
1938 bi
->curve
= pkex
->own_bi
->curve
;
1939 bi
->pubkey
= pkex
->peer_bootstrap_key
;
1940 pkex
->peer_bootstrap_key
= NULL
;
1941 dpp_pkex_free(pkex
);
1942 wpa_s
->dpp_pkex
= NULL
;
1943 if (dpp_bootstrap_key_hash(bi
) < 0) {
1944 dpp_bootstrap_info_free(bi
);
1947 dl_list_add(&wpa_s
->dpp_bootstrap
, &bi
->list
);
1953 wpas_dpp_rx_pkex_commit_reveal_req(struct wpa_supplicant
*wpa_s
, const u8
*src
,
1954 const u8
*hdr
, const u8
*buf
, size_t len
,
1958 unsigned int wait_time
;
1959 struct dpp_pkex
*pkex
= wpa_s
->dpp_pkex
;
1961 wpa_printf(MSG_DEBUG
, "DPP: PKEX Commit-Reveal Request from " MACSTR
,
1964 if (!pkex
|| pkex
->initiator
|| !pkex
->exchange_done
) {
1965 wpa_printf(MSG_DEBUG
, "DPP: No matching PKEX session");
1969 msg
= dpp_pkex_rx_commit_reveal_req(pkex
, hdr
, buf
, len
);
1971 wpa_printf(MSG_DEBUG
, "DPP: Failed to process the request");
1973 wpa_printf(MSG_DEBUG
, "DPP: Terminate PKEX exchange");
1974 if (pkex
->t
> pkex
->own_bi
->pkex_t
)
1975 pkex
->own_bi
->pkex_t
= pkex
->t
;
1976 dpp_pkex_free(wpa_s
->dpp_pkex
);
1977 wpa_s
->dpp_pkex
= NULL
;
1982 wpa_printf(MSG_DEBUG
, "DPP: Send PKEX Commit-Reveal Response to "
1983 MACSTR
, MAC2STR(src
));
1985 wait_time
= wpa_s
->max_remain_on_chan
;
1986 if (wait_time
> 2000)
1988 wpa_msg(wpa_s
, MSG_INFO
, DPP_EVENT_TX
"dst=" MACSTR
" freq=%u type=%d",
1989 MAC2STR(src
), freq
, DPP_PA_PKEX_COMMIT_REVEAL_RESP
);
1990 offchannel_send_action(wpa_s
, freq
, src
, wpa_s
->own_addr
,
1992 wpabuf_head(msg
), wpabuf_len(msg
),
1993 wait_time
, wpas_dpp_tx_pkex_status
, 0);
1996 wpas_dpp_pkex_finish(wpa_s
, src
, freq
);
2001 wpas_dpp_rx_pkex_commit_reveal_resp(struct wpa_supplicant
*wpa_s
, const u8
*src
,
2002 const u8
*hdr
, const u8
*buf
, size_t len
,
2006 struct dpp_bootstrap_info
*bi
;
2007 struct dpp_pkex
*pkex
= wpa_s
->dpp_pkex
;
2010 wpa_printf(MSG_DEBUG
, "DPP: PKEX Commit-Reveal Response from " MACSTR
,
2013 if (!pkex
|| !pkex
->initiator
|| !pkex
->exchange_done
) {
2014 wpa_printf(MSG_DEBUG
, "DPP: No matching PKEX session");
2018 res
= dpp_pkex_rx_commit_reveal_resp(pkex
, hdr
, buf
, len
);
2020 wpa_printf(MSG_DEBUG
, "DPP: Failed to process the response");
2024 bi
= wpas_dpp_pkex_finish(wpa_s
, src
, freq
);
2028 os_snprintf(cmd
, sizeof(cmd
), " peer=%u %s",
2030 wpa_s
->dpp_pkex_auth_cmd
? wpa_s
->dpp_pkex_auth_cmd
: "");
2031 wpa_printf(MSG_DEBUG
,
2032 "DPP: Start authentication after PKEX with parameters: %s",
2034 if (wpas_dpp_auth_init(wpa_s
, cmd
) < 0) {
2035 wpa_printf(MSG_DEBUG
,
2036 "DPP: Authentication initialization failed");
2042 void wpas_dpp_rx_action(struct wpa_supplicant
*wpa_s
, const u8
*src
,
2043 const u8
*buf
, size_t len
, unsigned int freq
)
2046 enum dpp_public_action_frame_type type
;
2048 unsigned int pkex_t
;
2050 if (len
< DPP_HDR_LEN
)
2052 if (WPA_GET_BE24(buf
) != OUI_WFA
|| buf
[3] != DPP_OUI_TYPE
)
2057 crypto_suite
= *buf
++;
2061 wpa_printf(MSG_DEBUG
,
2062 "DPP: Received DPP Public Action frame crypto suite %u type %d from "
2064 crypto_suite
, type
, MAC2STR(src
), freq
);
2065 if (crypto_suite
!= 1) {
2066 wpa_printf(MSG_DEBUG
, "DPP: Unsupported crypto suite %u",
2068 wpa_msg(wpa_s
, MSG_INFO
, DPP_EVENT_RX
"src=" MACSTR
2069 " freq=%u type=%d ignore=unsupported-crypto-suite",
2070 MAC2STR(src
), freq
, type
);
2073 wpa_hexdump(MSG_MSGDUMP
, "DPP: Received message attributes", buf
, len
);
2074 if (dpp_check_attrs(buf
, len
) < 0) {
2075 wpa_msg(wpa_s
, MSG_INFO
, DPP_EVENT_RX
"src=" MACSTR
2076 " freq=%u type=%d ignore=invalid-attributes",
2077 MAC2STR(src
), freq
, type
);
2080 wpa_msg(wpa_s
, MSG_INFO
, DPP_EVENT_RX
"src=" MACSTR
" freq=%u type=%d",
2081 MAC2STR(src
), freq
, type
);
2084 case DPP_PA_AUTHENTICATION_REQ
:
2085 wpas_dpp_rx_auth_req(wpa_s
, src
, hdr
, buf
, len
, freq
);
2087 case DPP_PA_AUTHENTICATION_RESP
:
2088 wpas_dpp_rx_auth_resp(wpa_s
, src
, hdr
, buf
, len
, freq
);
2090 case DPP_PA_AUTHENTICATION_CONF
:
2091 wpas_dpp_rx_auth_conf(wpa_s
, src
, hdr
, buf
, len
);
2093 case DPP_PA_PEER_DISCOVERY_RESP
:
2094 wpas_dpp_rx_peer_disc_resp(wpa_s
, src
, buf
, len
);
2096 case DPP_PA_PKEX_EXCHANGE_REQ
:
2097 wpas_dpp_rx_pkex_exchange_req(wpa_s
, src
, buf
, len
, freq
);
2099 case DPP_PA_PKEX_EXCHANGE_RESP
:
2100 wpas_dpp_rx_pkex_exchange_resp(wpa_s
, src
, buf
, len
, freq
);
2102 case DPP_PA_PKEX_COMMIT_REVEAL_REQ
:
2103 wpas_dpp_rx_pkex_commit_reveal_req(wpa_s
, src
, hdr
, buf
, len
,
2106 case DPP_PA_PKEX_COMMIT_REVEAL_RESP
:
2107 wpas_dpp_rx_pkex_commit_reveal_resp(wpa_s
, src
, hdr
, buf
, len
,
2111 wpa_printf(MSG_DEBUG
,
2112 "DPP: Ignored unsupported frame subtype %d", type
);
2116 if (wpa_s
->dpp_pkex
)
2117 pkex_t
= wpa_s
->dpp_pkex
->t
;
2118 else if (wpa_s
->dpp_pkex_bi
)
2119 pkex_t
= wpa_s
->dpp_pkex_bi
->pkex_t
;
2122 if (pkex_t
>= PKEX_COUNTER_T_LIMIT
) {
2123 wpa_msg(wpa_s
, MSG_INFO
, DPP_EVENT_PKEX_T_LIMIT
"id=0");
2124 wpas_dpp_pkex_remove(wpa_s
, "*");
2129 static struct wpabuf
*
2130 wpas_dpp_gas_req_handler(void *ctx
, const u8
*sa
, const u8
*query
,
2133 struct wpa_supplicant
*wpa_s
= ctx
;
2134 struct dpp_authentication
*auth
= wpa_s
->dpp_auth
;
2135 struct wpabuf
*resp
;
2137 wpa_printf(MSG_DEBUG
, "DPP: GAS request from " MACSTR
,
2139 if (!auth
|| !auth
->auth_success
||
2140 os_memcmp(sa
, auth
->peer_mac_addr
, ETH_ALEN
) != 0) {
2141 wpa_printf(MSG_DEBUG
, "DPP: No matching exchange in progress");
2144 wpa_hexdump(MSG_DEBUG
,
2145 "DPP: Received Configuration Request (GAS Query Request)",
2147 wpa_msg(wpa_s
, MSG_INFO
, DPP_EVENT_CONF_REQ_RX
"src=" MACSTR
,
2149 resp
= dpp_conf_req_rx(auth
, query
, query_len
);
2151 wpa_msg(wpa_s
, MSG_INFO
, DPP_EVENT_CONF_FAILED
);
2152 auth
->conf_resp
= resp
;
2158 wpas_dpp_gas_status_handler(void *ctx
, struct wpabuf
*resp
, int ok
)
2160 struct wpa_supplicant
*wpa_s
= ctx
;
2161 struct dpp_authentication
*auth
= wpa_s
->dpp_auth
;
2167 if (auth
->conf_resp
!= resp
) {
2168 wpa_printf(MSG_DEBUG
,
2169 "DPP: Ignore GAS status report (ok=%d) for unknown response",
2175 wpa_printf(MSG_DEBUG
, "DPP: Configuration exchange completed (ok=%d)",
2177 eloop_cancel_timeout(wpas_dpp_reply_wait_timeout
, wpa_s
, NULL
);
2178 eloop_cancel_timeout(wpas_dpp_auth_resp_retry_timeout
, wpa_s
, NULL
);
2179 offchannel_send_action_done(wpa_s
);
2180 wpas_dpp_listen_stop(wpa_s
);
2182 wpa_msg(wpa_s
, MSG_INFO
, DPP_EVENT_CONF_SENT
);
2184 wpa_msg(wpa_s
, MSG_INFO
, DPP_EVENT_CONF_FAILED
);
2185 dpp_auth_deinit(wpa_s
->dpp_auth
);
2186 wpa_s
->dpp_auth
= NULL
;
2191 static unsigned int wpas_dpp_next_configurator_id(struct wpa_supplicant
*wpa_s
)
2193 struct dpp_configurator
*conf
;
2194 unsigned int max_id
= 0;
2196 dl_list_for_each(conf
, &wpa_s
->dpp_configurator
,
2197 struct dpp_configurator
, list
) {
2198 if (conf
->id
> max_id
)
2205 int wpas_dpp_configurator_add(struct wpa_supplicant
*wpa_s
, const char *cmd
)
2210 size_t privkey_len
= 0;
2212 struct dpp_configurator
*conf
= NULL
;
2214 curve
= get_param(cmd
, " curve=");
2215 key
= get_param(cmd
, " key=");
2218 privkey_len
= os_strlen(key
) / 2;
2219 privkey
= os_malloc(privkey_len
);
2221 hexstr2bin(key
, privkey
, privkey_len
) < 0)
2225 conf
= dpp_keygen_configurator(curve
, privkey
, privkey_len
);
2229 conf
->id
= wpas_dpp_next_configurator_id(wpa_s
);
2230 dl_list_add(&wpa_s
->dpp_configurator
, &conf
->list
);
2235 str_clear_free(key
);
2236 bin_clear_free(privkey
, privkey_len
);
2237 dpp_configurator_free(conf
);
2242 static int dpp_configurator_del(struct wpa_supplicant
*wpa_s
, unsigned int id
)
2244 struct dpp_configurator
*conf
, *tmp
;
2247 dl_list_for_each_safe(conf
, tmp
, &wpa_s
->dpp_configurator
,
2248 struct dpp_configurator
, list
) {
2249 if (id
&& conf
->id
!= id
)
2252 dl_list_del(&conf
->list
);
2253 dpp_configurator_free(conf
);
2257 return 0; /* flush succeeds regardless of entries found */
2258 return found
? 0 : -1;
2262 int wpas_dpp_configurator_remove(struct wpa_supplicant
*wpa_s
, const char *id
)
2264 unsigned int id_val
;
2266 if (os_strcmp(id
, "*") == 0) {
2274 return dpp_configurator_del(wpa_s
, id_val
);
2278 int wpas_dpp_configurator_sign(struct wpa_supplicant
*wpa_s
, const char *cmd
)
2280 struct dpp_authentication
*auth
;
2284 auth
= os_zalloc(sizeof(*auth
));
2288 curve
= get_param(cmd
, " curve=");
2289 wpas_dpp_set_configurator(wpa_s
, auth
, cmd
);
2291 if (dpp_configurator_own_config(auth
, curve
, 0) == 0) {
2292 wpas_dpp_handle_config_obj(wpa_s
, auth
);
2296 dpp_auth_deinit(auth
);
2303 int wpas_dpp_configurator_get_key(struct wpa_supplicant
*wpa_s
, unsigned int id
,
2304 char *buf
, size_t buflen
)
2306 struct dpp_configurator
*conf
;
2308 conf
= dpp_configurator_get_id(wpa_s
, id
);
2312 return dpp_configurator_get_key(conf
, buf
, buflen
);
2317 wpas_dpp_tx_introduction_status(struct wpa_supplicant
*wpa_s
,
2318 unsigned int freq
, const u8
*dst
,
2319 const u8
*src
, const u8
*bssid
,
2320 const u8
*data
, size_t data_len
,
2321 enum offchannel_send_action_result result
)
2323 const char *res_txt
;
2325 res_txt
= result
== OFFCHANNEL_SEND_ACTION_SUCCESS
? "SUCCESS" :
2326 (result
== OFFCHANNEL_SEND_ACTION_NO_ACK
? "no-ACK" :
2328 wpa_printf(MSG_DEBUG
, "DPP: TX status: freq=%u dst=" MACSTR
2329 " result=%s (DPP Peer Discovery Request)",
2330 freq
, MAC2STR(dst
), res_txt
);
2331 wpa_msg(wpa_s
, MSG_INFO
, DPP_EVENT_TX_STATUS
"dst=" MACSTR
2332 " freq=%u result=%s", MAC2STR(dst
), freq
, res_txt
);
2333 /* TODO: Time out wait for response more quickly in error cases? */
2337 int wpas_dpp_check_connect(struct wpa_supplicant
*wpa_s
, struct wpa_ssid
*ssid
,
2338 struct wpa_bss
*bss
)
2342 unsigned int wait_time
;
2344 if (!(ssid
->key_mgmt
& WPA_KEY_MGMT_DPP
) || !bss
)
2345 return 0; /* Not using DPP AKM - continue */
2346 if (wpa_sm_pmksa_exists(wpa_s
->wpa
, bss
->bssid
, ssid
))
2347 return 0; /* PMKSA exists for DPP AKM - continue */
2349 if (!ssid
->dpp_connector
|| !ssid
->dpp_netaccesskey
||
2351 wpa_msg(wpa_s
, MSG_INFO
, DPP_EVENT_MISSING_CONNECTOR
2353 !ssid
->dpp_connector
? "Connector" :
2354 (!ssid
->dpp_netaccesskey
? "netAccessKey" :
2361 if (ssid
->dpp_netaccesskey_expiry
&&
2362 (os_time_t
) ssid
->dpp_netaccesskey_expiry
< now
.sec
) {
2363 wpa_msg(wpa_s
, MSG_INFO
, DPP_EVENT_MISSING_CONNECTOR
2364 "netAccessKey expired");
2368 wpa_printf(MSG_DEBUG
,
2369 "DPP: Starting network introduction protocol to derive PMKSA for "
2370 MACSTR
, MAC2STR(bss
->bssid
));
2372 msg
= dpp_alloc_msg(DPP_PA_PEER_DISCOVERY_REQ
,
2373 5 + 4 + os_strlen(ssid
->dpp_connector
));
2377 #ifdef CONFIG_TESTING_OPTIONS
2378 if (dpp_test
== DPP_TEST_NO_TRANSACTION_ID_PEER_DISC_REQ
) {
2379 wpa_printf(MSG_INFO
, "DPP: TESTING - no Transaction ID");
2382 if (dpp_test
== DPP_TEST_INVALID_TRANSACTION_ID_PEER_DISC_REQ
) {
2383 wpa_printf(MSG_INFO
, "DPP: TESTING - invalid Transaction ID");
2384 wpabuf_put_le16(msg
, DPP_ATTR_TRANSACTION_ID
);
2385 wpabuf_put_le16(msg
, 0);
2388 #endif /* CONFIG_TESTING_OPTIONS */
2390 /* Transaction ID */
2391 wpabuf_put_le16(msg
, DPP_ATTR_TRANSACTION_ID
);
2392 wpabuf_put_le16(msg
, 1);
2393 wpabuf_put_u8(msg
, TRANSACTION_ID
);
2395 #ifdef CONFIG_TESTING_OPTIONS
2397 if (dpp_test
== DPP_TEST_NO_CONNECTOR_PEER_DISC_REQ
) {
2398 wpa_printf(MSG_INFO
, "DPP: TESTING - no Connector");
2399 goto skip_connector
;
2401 if (dpp_test
== DPP_TEST_INVALID_CONNECTOR_PEER_DISC_REQ
) {
2404 wpa_printf(MSG_INFO
, "DPP: TESTING - invalid Connector");
2405 connector
= dpp_corrupt_connector_signature(
2406 ssid
->dpp_connector
);
2411 wpabuf_put_le16(msg
, DPP_ATTR_CONNECTOR
);
2412 wpabuf_put_le16(msg
, os_strlen(connector
));
2413 wpabuf_put_str(msg
, connector
);
2415 goto skip_connector
;
2417 #endif /* CONFIG_TESTING_OPTIONS */
2420 wpabuf_put_le16(msg
, DPP_ATTR_CONNECTOR
);
2421 wpabuf_put_le16(msg
, os_strlen(ssid
->dpp_connector
));
2422 wpabuf_put_str(msg
, ssid
->dpp_connector
);
2424 #ifdef CONFIG_TESTING_OPTIONS
2426 #endif /* CONFIG_TESTING_OPTIONS */
2428 /* TODO: Timeout on AP response */
2429 wait_time
= wpa_s
->max_remain_on_chan
;
2430 if (wait_time
> 2000)
2432 wpa_msg(wpa_s
, MSG_INFO
, DPP_EVENT_TX
"dst=" MACSTR
" freq=%u type=%d",
2433 MAC2STR(bss
->bssid
), bss
->freq
, DPP_PA_PEER_DISCOVERY_REQ
);
2434 offchannel_send_action(wpa_s
, bss
->freq
, bss
->bssid
, wpa_s
->own_addr
,
2436 wpabuf_head(msg
), wpabuf_len(msg
),
2437 wait_time
, wpas_dpp_tx_introduction_status
, 0);
2440 /* Request this connection attempt to terminate - new one will be
2441 * started when network introduction protocol completes */
2442 os_memcpy(wpa_s
->dpp_intro_bssid
, bss
->bssid
, ETH_ALEN
);
2443 wpa_s
->dpp_intro_network
= ssid
;
2448 int wpas_dpp_pkex_add(struct wpa_supplicant
*wpa_s
, const char *cmd
)
2450 struct dpp_bootstrap_info
*own_bi
;
2451 const char *pos
, *end
;
2452 unsigned int wait_time
;
2454 pos
= os_strstr(cmd
, " own=");
2458 own_bi
= dpp_bootstrap_get_id(wpa_s
, atoi(pos
));
2460 wpa_printf(MSG_DEBUG
,
2461 "DPP: Identified bootstrap info not found");
2464 if (own_bi
->type
!= DPP_BOOTSTRAP_PKEX
) {
2465 wpa_printf(MSG_DEBUG
,
2466 "DPP: Identified bootstrap info not for PKEX");
2469 wpa_s
->dpp_pkex_bi
= own_bi
;
2470 own_bi
->pkex_t
= 0; /* clear pending errors on new code */
2472 os_free(wpa_s
->dpp_pkex_identifier
);
2473 wpa_s
->dpp_pkex_identifier
= NULL
;
2474 pos
= os_strstr(cmd
, " identifier=");
2477 end
= os_strchr(pos
, ' ');
2480 wpa_s
->dpp_pkex_identifier
= os_malloc(end
- pos
+ 1);
2481 if (!wpa_s
->dpp_pkex_identifier
)
2483 os_memcpy(wpa_s
->dpp_pkex_identifier
, pos
, end
- pos
);
2484 wpa_s
->dpp_pkex_identifier
[end
- pos
] = '\0';
2487 pos
= os_strstr(cmd
, " code=");
2490 os_free(wpa_s
->dpp_pkex_code
);
2491 wpa_s
->dpp_pkex_code
= os_strdup(pos
+ 6);
2492 if (!wpa_s
->dpp_pkex_code
)
2495 if (os_strstr(cmd
, " init=1")) {
2496 struct dpp_pkex
*pkex
;
2499 wpa_printf(MSG_DEBUG
, "DPP: Initiating PKEX");
2500 dpp_pkex_free(wpa_s
->dpp_pkex
);
2501 wpa_s
->dpp_pkex
= dpp_pkex_init(wpa_s
, own_bi
, wpa_s
->own_addr
,
2502 wpa_s
->dpp_pkex_identifier
,
2503 wpa_s
->dpp_pkex_code
);
2504 pkex
= wpa_s
->dpp_pkex
;
2508 msg
= pkex
->exchange_req
;
2509 wait_time
= wpa_s
->max_remain_on_chan
;
2510 if (wait_time
> 2000)
2513 wpa_msg(wpa_s
, MSG_INFO
, DPP_EVENT_TX
"dst=" MACSTR
2515 MAC2STR(broadcast
), pkex
->freq
,
2516 DPP_PA_PKEX_EXCHANGE_REQ
);
2517 offchannel_send_action(wpa_s
, pkex
->freq
, broadcast
,
2518 wpa_s
->own_addr
, broadcast
,
2519 wpabuf_head(msg
), wpabuf_len(msg
),
2520 wait_time
, wpas_dpp_tx_pkex_status
, 0);
2523 pkex
->exch_req_wait_time
= wait_time
;
2524 pkex
->exch_req_tries
= 1;
2527 /* TODO: Support multiple PKEX info entries */
2529 os_free(wpa_s
->dpp_pkex_auth_cmd
);
2530 wpa_s
->dpp_pkex_auth_cmd
= os_strdup(cmd
);
2536 int wpas_dpp_pkex_remove(struct wpa_supplicant
*wpa_s
, const char *id
)
2538 unsigned int id_val
;
2540 if (os_strcmp(id
, "*") == 0) {
2548 if ((id_val
!= 0 && id_val
!= 1) || !wpa_s
->dpp_pkex_code
)
2551 /* TODO: Support multiple PKEX entries */
2552 os_free(wpa_s
->dpp_pkex_code
);
2553 wpa_s
->dpp_pkex_code
= NULL
;
2554 os_free(wpa_s
->dpp_pkex_identifier
);
2555 wpa_s
->dpp_pkex_identifier
= NULL
;
2556 os_free(wpa_s
->dpp_pkex_auth_cmd
);
2557 wpa_s
->dpp_pkex_auth_cmd
= NULL
;
2558 wpa_s
->dpp_pkex_bi
= NULL
;
2559 /* TODO: Remove dpp_pkex only if it is for the identified PKEX code */
2560 dpp_pkex_free(wpa_s
->dpp_pkex
);
2561 wpa_s
->dpp_pkex
= NULL
;
2566 void wpas_dpp_stop(struct wpa_supplicant
*wpa_s
)
2568 dpp_auth_deinit(wpa_s
->dpp_auth
);
2569 wpa_s
->dpp_auth
= NULL
;
2570 dpp_pkex_free(wpa_s
->dpp_pkex
);
2571 wpa_s
->dpp_pkex
= NULL
;
2572 if (wpa_s
->dpp_gas_client
&& wpa_s
->dpp_gas_dialog_token
>= 0)
2573 gas_query_stop(wpa_s
->gas
, wpa_s
->dpp_gas_dialog_token
);
2577 int wpas_dpp_init(struct wpa_supplicant
*wpa_s
)
2581 adv_proto_id
[0] = WLAN_EID_VENDOR_SPECIFIC
;
2582 adv_proto_id
[1] = 5;
2583 WPA_PUT_BE24(&adv_proto_id
[2], OUI_WFA
);
2584 adv_proto_id
[5] = DPP_OUI_TYPE
;
2585 adv_proto_id
[6] = 0x01;
2587 if (gas_server_register(wpa_s
->gas_server
, adv_proto_id
,
2588 sizeof(adv_proto_id
), wpas_dpp_gas_req_handler
,
2589 wpas_dpp_gas_status_handler
, wpa_s
) < 0)
2591 dl_list_init(&wpa_s
->dpp_bootstrap
);
2592 dl_list_init(&wpa_s
->dpp_configurator
);
2593 wpa_s
->dpp_init_done
= 1;
2598 void wpas_dpp_deinit(struct wpa_supplicant
*wpa_s
)
2600 #ifdef CONFIG_TESTING_OPTIONS
2601 os_free(wpa_s
->dpp_config_obj_override
);
2602 wpa_s
->dpp_config_obj_override
= NULL
;
2603 os_free(wpa_s
->dpp_discovery_override
);
2604 wpa_s
->dpp_discovery_override
= NULL
;
2605 os_free(wpa_s
->dpp_groups_override
);
2606 wpa_s
->dpp_groups_override
= NULL
;
2607 wpa_s
->dpp_ignore_netaccesskey_mismatch
= 0;
2608 #endif /* CONFIG_TESTING_OPTIONS */
2609 if (!wpa_s
->dpp_init_done
)
2611 eloop_cancel_timeout(wpas_dpp_pkex_retry_timeout
, wpa_s
, NULL
);
2612 eloop_cancel_timeout(wpas_dpp_reply_wait_timeout
, wpa_s
, NULL
);
2613 eloop_cancel_timeout(wpas_dpp_init_timeout
, wpa_s
, NULL
);
2614 eloop_cancel_timeout(wpas_dpp_auth_resp_retry_timeout
, wpa_s
, NULL
);
2615 offchannel_send_action_done(wpa_s
);
2616 wpas_dpp_listen_stop(wpa_s
);
2617 dpp_bootstrap_del(wpa_s
, 0);
2618 dpp_configurator_del(wpa_s
, 0);
2619 wpas_dpp_stop(wpa_s
);
2620 wpas_dpp_pkex_remove(wpa_s
, "*");
2621 os_memset(wpa_s
->dpp_intro_bssid
, 0, ETH_ALEN
);
2622 os_free(wpa_s
->dpp_configurator_params
);
2623 wpa_s
->dpp_configurator_params
= NULL
;