3 * Copyright (c) 2017, Qualcomm Atheros, Inc.
4 * Copyright (c) 2018-2019, 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_try_to_connect(struct wpa_supplicant
*wpa_s
)
369 wpa_printf(MSG_DEBUG
, "DPP: Trying to connect to the new network");
370 wpa_s
->disconnected
= 0;
371 wpa_s
->reassociate
= 1;
372 wpa_s
->scan_runs
= 0;
373 wpa_s
->normal_scans
= 0;
374 wpa_supplicant_cancel_sched_scan(wpa_s
);
375 wpa_supplicant_req_scan(wpa_s
, 0, 0);
379 static void wpas_dpp_tx_status(struct wpa_supplicant
*wpa_s
,
380 unsigned int freq
, const u8
*dst
,
381 const u8
*src
, const u8
*bssid
,
382 const u8
*data
, size_t data_len
,
383 enum offchannel_send_action_result result
)
386 struct dpp_authentication
*auth
= wpa_s
->dpp_auth
;
388 res_txt
= result
== OFFCHANNEL_SEND_ACTION_SUCCESS
? "SUCCESS" :
389 (result
== OFFCHANNEL_SEND_ACTION_NO_ACK
? "no-ACK" :
391 wpa_printf(MSG_DEBUG
, "DPP: TX status: freq=%u dst=" MACSTR
392 " result=%s", freq
, MAC2STR(dst
), res_txt
);
393 wpa_msg(wpa_s
, MSG_INFO
, DPP_EVENT_TX_STATUS
"dst=" MACSTR
394 " freq=%u result=%s", MAC2STR(dst
), freq
, res_txt
);
396 if (!wpa_s
->dpp_auth
) {
397 wpa_printf(MSG_DEBUG
,
398 "DPP: Ignore TX status since there is no ongoing authentication exchange");
403 if (auth
->connect_on_tx_status
) {
404 wpa_printf(MSG_DEBUG
,
405 "DPP: Try to connect after completed configuration result");
406 wpas_dpp_try_to_connect(wpa_s
);
407 dpp_auth_deinit(wpa_s
->dpp_auth
);
408 wpa_s
->dpp_auth
= NULL
;
411 #endif /* CONFIG_DPP2 */
413 if (wpa_s
->dpp_auth
->remove_on_tx_status
) {
414 wpa_printf(MSG_DEBUG
,
415 "DPP: Terminate authentication exchange due to an earlier error");
416 eloop_cancel_timeout(wpas_dpp_init_timeout
, wpa_s
, NULL
);
417 eloop_cancel_timeout(wpas_dpp_reply_wait_timeout
, wpa_s
, NULL
);
418 eloop_cancel_timeout(wpas_dpp_auth_resp_retry_timeout
, wpa_s
,
420 offchannel_send_action_done(wpa_s
);
421 dpp_auth_deinit(wpa_s
->dpp_auth
);
422 wpa_s
->dpp_auth
= NULL
;
426 if (wpa_s
->dpp_auth_ok_on_ack
)
427 wpas_dpp_auth_success(wpa_s
, 1);
429 if (!is_broadcast_ether_addr(dst
) &&
430 result
!= OFFCHANNEL_SEND_ACTION_SUCCESS
) {
431 wpa_printf(MSG_DEBUG
,
432 "DPP: Unicast DPP Action frame was not ACKed");
433 if (auth
->waiting_auth_resp
) {
434 /* In case of DPP Authentication Request frame, move to
435 * the next channel immediately. */
436 offchannel_send_action_done(wpa_s
);
437 wpas_dpp_auth_init_next(wpa_s
);
440 if (auth
->waiting_auth_conf
) {
441 wpas_dpp_auth_resp_retry(wpa_s
);
446 if (!is_broadcast_ether_addr(dst
) && auth
->waiting_auth_resp
&&
447 result
== OFFCHANNEL_SEND_ACTION_SUCCESS
) {
448 /* Allow timeout handling to stop iteration if no response is
449 * received from a peer that has ACKed a request. */
450 auth
->auth_req_ack
= 1;
453 if (!wpa_s
->dpp_auth_ok_on_ack
&& wpa_s
->dpp_auth
->neg_freq
> 0 &&
454 wpa_s
->dpp_auth
->curr_freq
!= wpa_s
->dpp_auth
->neg_freq
) {
455 wpa_printf(MSG_DEBUG
,
456 "DPP: Move from curr_freq %u MHz to neg_freq %u MHz for response",
457 wpa_s
->dpp_auth
->curr_freq
,
458 wpa_s
->dpp_auth
->neg_freq
);
459 offchannel_send_action_done(wpa_s
);
460 wpas_dpp_listen_start(wpa_s
, wpa_s
->dpp_auth
->neg_freq
);
463 if (wpa_s
->dpp_auth_ok_on_ack
)
464 wpa_s
->dpp_auth_ok_on_ack
= 0;
468 static void wpas_dpp_reply_wait_timeout(void *eloop_ctx
, void *timeout_ctx
)
470 struct wpa_supplicant
*wpa_s
= eloop_ctx
;
471 struct dpp_authentication
*auth
= wpa_s
->dpp_auth
;
473 struct os_reltime now
, diff
;
474 unsigned int wait_time
, diff_ms
;
476 if (!auth
|| !auth
->waiting_auth_resp
)
479 wait_time
= wpa_s
->dpp_resp_wait_time
?
480 wpa_s
->dpp_resp_wait_time
: 2000;
481 os_get_reltime(&now
);
482 os_reltime_sub(&now
, &wpa_s
->dpp_last_init
, &diff
);
483 diff_ms
= diff
.sec
* 1000 + diff
.usec
/ 1000;
484 wpa_printf(MSG_DEBUG
,
485 "DPP: Reply wait timeout - wait_time=%u diff_ms=%u",
488 if (auth
->auth_req_ack
&& diff_ms
>= wait_time
) {
489 /* Peer ACK'ed Authentication Request frame, but did not reply
490 * with Authentication Response frame within two seconds. */
492 "DPP: No response received from responder - stopping initiation attempt");
493 wpa_msg(wpa_s
, MSG_INFO
, DPP_EVENT_AUTH_INIT_FAILED
);
494 offchannel_send_action_done(wpa_s
);
495 wpas_dpp_listen_stop(wpa_s
);
496 dpp_auth_deinit(auth
);
497 wpa_s
->dpp_auth
= NULL
;
501 if (diff_ms
>= wait_time
) {
502 /* Authentication Request frame was not ACK'ed and no reply
503 * was receiving within two seconds. */
504 wpa_printf(MSG_DEBUG
,
505 "DPP: Continue Initiator channel iteration");
506 offchannel_send_action_done(wpa_s
);
507 wpas_dpp_listen_stop(wpa_s
);
508 wpas_dpp_auth_init_next(wpa_s
);
512 /* Driver did not support 2000 ms long wait_time with TX command, so
513 * schedule listen operation to continue waiting for the response.
515 * DPP listen operations continue until stopped, so simply schedule a
516 * new call to this function at the point when the two second reply
517 * wait has expired. */
518 wait_time
-= diff_ms
;
520 freq
= auth
->curr_freq
;
521 if (auth
->neg_freq
> 0)
522 freq
= auth
->neg_freq
;
523 wpa_printf(MSG_DEBUG
,
524 "DPP: Continue reply wait on channel %u MHz for %u ms",
526 wpa_s
->dpp_in_response_listen
= 1;
527 wpas_dpp_listen_start(wpa_s
, freq
);
529 eloop_register_timeout(wait_time
/ 1000, (wait_time
% 1000) * 1000,
530 wpas_dpp_reply_wait_timeout
, wpa_s
, NULL
);
534 static void wpas_dpp_set_testing_options(struct wpa_supplicant
*wpa_s
,
535 struct dpp_authentication
*auth
)
537 #ifdef CONFIG_TESTING_OPTIONS
538 if (wpa_s
->dpp_config_obj_override
)
539 auth
->config_obj_override
=
540 os_strdup(wpa_s
->dpp_config_obj_override
);
541 if (wpa_s
->dpp_discovery_override
)
542 auth
->discovery_override
=
543 os_strdup(wpa_s
->dpp_discovery_override
);
544 if (wpa_s
->dpp_groups_override
)
545 auth
->groups_override
=
546 os_strdup(wpa_s
->dpp_groups_override
);
547 auth
->ignore_netaccesskey_mismatch
=
548 wpa_s
->dpp_ignore_netaccesskey_mismatch
;
549 #endif /* CONFIG_TESTING_OPTIONS */
553 static int wpas_dpp_set_configurator(struct wpa_supplicant
*wpa_s
,
554 struct dpp_authentication
*auth
,
562 wpa_printf(MSG_DEBUG
, "DPP: Set configurator parameters: %s", cmd
);
564 pos
= os_strstr(cmd
, " configurator=");
567 auth
->conf
= dpp_configurator_get_id(wpa_s
, atoi(pos
));
570 "DPP: Could not find the specified configurator");
575 if (dpp_configuration_parse(auth
, cmd
) < 0) {
576 wpa_msg(wpa_s
, MSG_INFO
,
577 "DPP: Failed to set configurator parameters");
584 static void wpas_dpp_init_timeout(void *eloop_ctx
, void *timeout_ctx
)
586 struct wpa_supplicant
*wpa_s
= eloop_ctx
;
588 if (!wpa_s
->dpp_auth
)
590 wpa_printf(MSG_DEBUG
, "DPP: Retry initiation after timeout");
591 wpas_dpp_auth_init_next(wpa_s
);
595 static int wpas_dpp_auth_init_next(struct wpa_supplicant
*wpa_s
)
597 struct dpp_authentication
*auth
= wpa_s
->dpp_auth
;
599 unsigned int wait_time
, max_wait_time
, freq
, max_tries
, used
;
600 struct os_reltime now
, diff
;
602 wpa_s
->dpp_in_response_listen
= 0;
606 if (auth
->freq_idx
== 0)
607 os_get_reltime(&wpa_s
->dpp_init_iter_start
);
609 if (auth
->freq_idx
>= auth
->num_freq
) {
610 auth
->num_freq_iters
++;
611 if (wpa_s
->dpp_init_max_tries
)
612 max_tries
= wpa_s
->dpp_init_max_tries
;
615 if (auth
->num_freq_iters
>= max_tries
|| auth
->auth_req_ack
) {
617 "DPP: No response received from responder - stopping initiation attempt");
618 wpa_msg(wpa_s
, MSG_INFO
, DPP_EVENT_AUTH_INIT_FAILED
);
619 eloop_cancel_timeout(wpas_dpp_reply_wait_timeout
,
621 offchannel_send_action_done(wpa_s
);
622 dpp_auth_deinit(wpa_s
->dpp_auth
);
623 wpa_s
->dpp_auth
= NULL
;
627 eloop_cancel_timeout(wpas_dpp_init_timeout
, wpa_s
, NULL
);
628 if (wpa_s
->dpp_init_retry_time
)
629 wait_time
= wpa_s
->dpp_init_retry_time
;
632 os_get_reltime(&now
);
633 os_reltime_sub(&now
, &wpa_s
->dpp_init_iter_start
, &diff
);
634 used
= diff
.sec
* 1000 + diff
.usec
/ 1000;
635 if (used
> wait_time
)
639 wpa_printf(MSG_DEBUG
, "DPP: Next init attempt in %u ms",
641 eloop_register_timeout(wait_time
/ 1000,
642 (wait_time
% 1000) * 1000,
643 wpas_dpp_init_timeout
, wpa_s
,
647 freq
= auth
->freq
[auth
->freq_idx
++];
648 auth
->curr_freq
= freq
;
650 if (is_zero_ether_addr(auth
->peer_bi
->mac_addr
))
653 dst
= auth
->peer_bi
->mac_addr
;
654 wpa_s
->dpp_auth_ok_on_ack
= 0;
655 eloop_cancel_timeout(wpas_dpp_reply_wait_timeout
, wpa_s
, NULL
);
656 wait_time
= wpa_s
->max_remain_on_chan
;
657 max_wait_time
= wpa_s
->dpp_resp_wait_time
?
658 wpa_s
->dpp_resp_wait_time
: 2000;
659 if (wait_time
> max_wait_time
)
660 wait_time
= max_wait_time
;
661 wait_time
+= 10; /* give the driver some extra time to complete */
662 eloop_register_timeout(wait_time
/ 1000, (wait_time
% 1000) * 1000,
663 wpas_dpp_reply_wait_timeout
,
666 if (auth
->neg_freq
> 0 && freq
!= auth
->neg_freq
) {
667 wpa_printf(MSG_DEBUG
,
668 "DPP: Initiate on %u MHz and move to neg_freq %u MHz for response",
669 freq
, auth
->neg_freq
);
671 wpa_msg(wpa_s
, MSG_INFO
, DPP_EVENT_TX
"dst=" MACSTR
" freq=%u type=%d",
672 MAC2STR(dst
), freq
, DPP_PA_AUTHENTICATION_REQ
);
673 auth
->auth_req_ack
= 0;
674 os_get_reltime(&wpa_s
->dpp_last_init
);
675 return offchannel_send_action(wpa_s
, freq
, dst
,
676 wpa_s
->own_addr
, broadcast
,
677 wpabuf_head(auth
->req_msg
),
678 wpabuf_len(auth
->req_msg
),
679 wait_time
, wpas_dpp_tx_status
, 0);
683 int wpas_dpp_auth_init(struct wpa_supplicant
*wpa_s
, const char *cmd
)
686 struct dpp_bootstrap_info
*peer_bi
, *own_bi
= NULL
;
687 u8 allowed_roles
= DPP_CAPAB_CONFIGURATOR
;
688 unsigned int neg_freq
= 0;
690 wpa_s
->dpp_gas_client
= 0;
692 pos
= os_strstr(cmd
, " peer=");
696 peer_bi
= dpp_bootstrap_get_id(wpa_s
, atoi(pos
));
699 "DPP: Could not find bootstrapping info for the identified peer");
703 pos
= os_strstr(cmd
, " own=");
706 own_bi
= dpp_bootstrap_get_id(wpa_s
, atoi(pos
));
709 "DPP: Could not find bootstrapping info for the identified local entry");
713 if (peer_bi
->curve
!= own_bi
->curve
) {
715 "DPP: Mismatching curves in bootstrapping info (peer=%s own=%s)",
716 peer_bi
->curve
->name
, own_bi
->curve
->name
);
721 pos
= os_strstr(cmd
, " role=");
724 if (os_strncmp(pos
, "configurator", 12) == 0)
725 allowed_roles
= DPP_CAPAB_CONFIGURATOR
;
726 else if (os_strncmp(pos
, "enrollee", 8) == 0)
727 allowed_roles
= DPP_CAPAB_ENROLLEE
;
728 else if (os_strncmp(pos
, "either", 6) == 0)
729 allowed_roles
= DPP_CAPAB_CONFIGURATOR
|
735 pos
= os_strstr(cmd
, " netrole=");
738 wpa_s
->dpp_netrole_ap
= os_strncmp(pos
, "ap", 2) == 0;
741 pos
= os_strstr(cmd
, " neg_freq=");
743 neg_freq
= atoi(pos
+ 10);
745 if (wpa_s
->dpp_auth
) {
746 eloop_cancel_timeout(wpas_dpp_init_timeout
, wpa_s
, NULL
);
747 eloop_cancel_timeout(wpas_dpp_reply_wait_timeout
, wpa_s
, NULL
);
748 eloop_cancel_timeout(wpas_dpp_auth_resp_retry_timeout
, wpa_s
,
750 offchannel_send_action_done(wpa_s
);
751 dpp_auth_deinit(wpa_s
->dpp_auth
);
753 wpa_s
->dpp_auth
= dpp_auth_init(wpa_s
, peer_bi
, own_bi
, allowed_roles
,
755 wpa_s
->hw
.modes
, wpa_s
->hw
.num_modes
);
756 if (!wpa_s
->dpp_auth
)
758 wpas_dpp_set_testing_options(wpa_s
, wpa_s
->dpp_auth
);
759 if (wpas_dpp_set_configurator(wpa_s
, wpa_s
->dpp_auth
, cmd
) < 0) {
760 dpp_auth_deinit(wpa_s
->dpp_auth
);
761 wpa_s
->dpp_auth
= NULL
;
765 wpa_s
->dpp_auth
->neg_freq
= neg_freq
;
767 if (!is_zero_ether_addr(peer_bi
->mac_addr
))
768 os_memcpy(wpa_s
->dpp_auth
->peer_mac_addr
, peer_bi
->mac_addr
,
771 return wpas_dpp_auth_init_next(wpa_s
);
777 struct wpas_dpp_listen_work
{
779 unsigned int duration
;
780 struct wpabuf
*probe_resp_ie
;
784 static void wpas_dpp_listen_work_free(struct wpas_dpp_listen_work
*lwork
)
792 static void wpas_dpp_listen_work_done(struct wpa_supplicant
*wpa_s
)
794 struct wpas_dpp_listen_work
*lwork
;
796 if (!wpa_s
->dpp_listen_work
)
799 lwork
= wpa_s
->dpp_listen_work
->ctx
;
800 wpas_dpp_listen_work_free(lwork
);
801 radio_work_done(wpa_s
->dpp_listen_work
);
802 wpa_s
->dpp_listen_work
= NULL
;
806 static void dpp_start_listen_cb(struct wpa_radio_work
*work
, int deinit
)
808 struct wpa_supplicant
*wpa_s
= work
->wpa_s
;
809 struct wpas_dpp_listen_work
*lwork
= work
->ctx
;
813 wpa_s
->dpp_listen_work
= NULL
;
814 wpas_dpp_listen_stop(wpa_s
);
816 wpas_dpp_listen_work_free(lwork
);
820 wpa_s
->dpp_listen_work
= work
;
822 wpa_s
->dpp_pending_listen_freq
= lwork
->freq
;
824 if (wpa_drv_remain_on_channel(wpa_s
, lwork
->freq
,
825 wpa_s
->max_remain_on_chan
) < 0) {
826 wpa_printf(MSG_DEBUG
,
827 "DPP: Failed to request the driver to remain on channel (%u MHz) for listen",
829 wpa_s
->dpp_listen_freq
= 0;
830 wpas_dpp_listen_work_done(wpa_s
);
831 wpa_s
->dpp_pending_listen_freq
= 0;
834 wpa_s
->off_channel_freq
= 0;
835 wpa_s
->roc_waiting_drv_freq
= lwork
->freq
;
839 static int wpas_dpp_listen_start(struct wpa_supplicant
*wpa_s
,
842 struct wpas_dpp_listen_work
*lwork
;
844 if (wpa_s
->dpp_listen_work
) {
845 wpa_printf(MSG_DEBUG
,
846 "DPP: Reject start_listen since dpp_listen_work already exists");
850 if (wpa_s
->dpp_listen_freq
)
851 wpas_dpp_listen_stop(wpa_s
);
852 wpa_s
->dpp_listen_freq
= freq
;
854 lwork
= os_zalloc(sizeof(*lwork
));
859 if (radio_add_work(wpa_s
, freq
, "dpp-listen", 0, dpp_start_listen_cb
,
861 wpas_dpp_listen_work_free(lwork
);
869 int wpas_dpp_listen(struct wpa_supplicant
*wpa_s
, const char *cmd
)
877 if (os_strstr(cmd
, " role=configurator"))
878 wpa_s
->dpp_allowed_roles
= DPP_CAPAB_CONFIGURATOR
;
879 else if (os_strstr(cmd
, " role=enrollee"))
880 wpa_s
->dpp_allowed_roles
= DPP_CAPAB_ENROLLEE
;
882 wpa_s
->dpp_allowed_roles
= DPP_CAPAB_CONFIGURATOR
|
884 wpa_s
->dpp_qr_mutual
= os_strstr(cmd
, " qr=mutual") != NULL
;
885 wpa_s
->dpp_netrole_ap
= os_strstr(cmd
, " netrole=ap") != NULL
;
886 if (wpa_s
->dpp_listen_freq
== (unsigned int) freq
) {
887 wpa_printf(MSG_DEBUG
, "DPP: Already listening on %u MHz",
892 return wpas_dpp_listen_start(wpa_s
, freq
);
896 void wpas_dpp_listen_stop(struct wpa_supplicant
*wpa_s
)
898 wpa_s
->dpp_in_response_listen
= 0;
899 if (!wpa_s
->dpp_listen_freq
)
902 wpa_printf(MSG_DEBUG
, "DPP: Stop listen on %u MHz",
903 wpa_s
->dpp_listen_freq
);
904 wpa_drv_cancel_remain_on_channel(wpa_s
);
905 wpa_s
->dpp_listen_freq
= 0;
906 wpas_dpp_listen_work_done(wpa_s
);
910 void wpas_dpp_cancel_remain_on_channel_cb(struct wpa_supplicant
*wpa_s
,
913 wpas_dpp_listen_work_done(wpa_s
);
915 if (wpa_s
->dpp_auth
&& wpa_s
->dpp_in_response_listen
) {
916 unsigned int new_freq
;
918 /* Continue listen with a new remain-on-channel */
919 if (wpa_s
->dpp_auth
->neg_freq
> 0)
920 new_freq
= wpa_s
->dpp_auth
->neg_freq
;
922 new_freq
= wpa_s
->dpp_auth
->curr_freq
;
923 wpa_printf(MSG_DEBUG
,
924 "DPP: Continue wait on %u MHz for the ongoing DPP provisioning session",
926 wpas_dpp_listen_start(wpa_s
, new_freq
);
930 if (wpa_s
->dpp_listen_freq
) {
931 /* Continue listen with a new remain-on-channel */
932 wpas_dpp_listen_start(wpa_s
, wpa_s
->dpp_listen_freq
);
937 static void wpas_dpp_rx_auth_req(struct wpa_supplicant
*wpa_s
, const u8
*src
,
938 const u8
*hdr
, const u8
*buf
, size_t len
,
941 const u8
*r_bootstrap
, *i_bootstrap
;
942 u16 r_bootstrap_len
, i_bootstrap_len
;
943 struct dpp_bootstrap_info
*bi
, *own_bi
= NULL
, *peer_bi
= NULL
;
945 wpa_printf(MSG_DEBUG
, "DPP: Authentication Request from " MACSTR
,
948 r_bootstrap
= dpp_get_attr(buf
, len
, DPP_ATTR_R_BOOTSTRAP_KEY_HASH
,
950 if (!r_bootstrap
|| r_bootstrap_len
!= SHA256_MAC_LEN
) {
951 wpa_msg(wpa_s
, MSG_INFO
, DPP_EVENT_FAIL
952 "Missing or invalid required Responder Bootstrapping Key Hash attribute");
955 wpa_hexdump(MSG_MSGDUMP
, "DPP: Responder Bootstrapping Key Hash",
956 r_bootstrap
, r_bootstrap_len
);
958 i_bootstrap
= dpp_get_attr(buf
, len
, DPP_ATTR_I_BOOTSTRAP_KEY_HASH
,
960 if (!i_bootstrap
|| i_bootstrap_len
!= SHA256_MAC_LEN
) {
961 wpa_msg(wpa_s
, MSG_INFO
, DPP_EVENT_FAIL
962 "Missing or invalid required Initiator Bootstrapping Key Hash attribute");
965 wpa_hexdump(MSG_MSGDUMP
, "DPP: Initiator Bootstrapping Key Hash",
966 i_bootstrap
, i_bootstrap_len
);
968 /* Try to find own and peer bootstrapping key matches based on the
969 * received hash values */
970 dl_list_for_each(bi
, &wpa_s
->dpp_bootstrap
, struct dpp_bootstrap_info
,
972 if (!own_bi
&& bi
->own
&&
973 os_memcmp(bi
->pubkey_hash
, r_bootstrap
,
974 SHA256_MAC_LEN
) == 0) {
975 wpa_printf(MSG_DEBUG
,
976 "DPP: Found matching own bootstrapping information");
980 if (!peer_bi
&& !bi
->own
&&
981 os_memcmp(bi
->pubkey_hash
, i_bootstrap
,
982 SHA256_MAC_LEN
) == 0) {
983 wpa_printf(MSG_DEBUG
,
984 "DPP: Found matching peer bootstrapping information");
988 if (own_bi
&& peer_bi
)
993 wpa_msg(wpa_s
, MSG_INFO
, DPP_EVENT_FAIL
994 "No matching own bootstrapping key found - ignore message");
998 if (wpa_s
->dpp_auth
) {
999 wpa_msg(wpa_s
, MSG_INFO
, DPP_EVENT_FAIL
1000 "Already in DPP authentication exchange - ignore new one");
1004 wpa_s
->dpp_gas_client
= 0;
1005 wpa_s
->dpp_auth_ok_on_ack
= 0;
1006 wpa_s
->dpp_auth
= dpp_auth_req_rx(wpa_s
, wpa_s
->dpp_allowed_roles
,
1007 wpa_s
->dpp_qr_mutual
,
1008 peer_bi
, own_bi
, freq
, hdr
, buf
, len
);
1009 if (!wpa_s
->dpp_auth
) {
1010 wpa_printf(MSG_DEBUG
, "DPP: No response generated");
1013 wpas_dpp_set_testing_options(wpa_s
, wpa_s
->dpp_auth
);
1014 if (wpas_dpp_set_configurator(wpa_s
, wpa_s
->dpp_auth
,
1015 wpa_s
->dpp_configurator_params
) < 0) {
1016 dpp_auth_deinit(wpa_s
->dpp_auth
);
1017 wpa_s
->dpp_auth
= NULL
;
1020 os_memcpy(wpa_s
->dpp_auth
->peer_mac_addr
, src
, ETH_ALEN
);
1022 if (wpa_s
->dpp_listen_freq
&&
1023 wpa_s
->dpp_listen_freq
!= wpa_s
->dpp_auth
->curr_freq
) {
1024 wpa_printf(MSG_DEBUG
,
1025 "DPP: Stop listen on %u MHz to allow response on the request %u MHz",
1026 wpa_s
->dpp_listen_freq
, wpa_s
->dpp_auth
->curr_freq
);
1027 wpas_dpp_listen_stop(wpa_s
);
1030 wpa_msg(wpa_s
, MSG_INFO
, DPP_EVENT_TX
"dst=" MACSTR
" freq=%u type=%d",
1031 MAC2STR(src
), wpa_s
->dpp_auth
->curr_freq
,
1032 DPP_PA_AUTHENTICATION_RESP
);
1033 offchannel_send_action(wpa_s
, wpa_s
->dpp_auth
->curr_freq
,
1034 src
, wpa_s
->own_addr
, broadcast
,
1035 wpabuf_head(wpa_s
->dpp_auth
->resp_msg
),
1036 wpabuf_len(wpa_s
->dpp_auth
->resp_msg
),
1037 500, wpas_dpp_tx_status
, 0);
1041 static void wpas_dpp_start_gas_server(struct wpa_supplicant
*wpa_s
)
1043 /* TODO: stop wait and start ROC */
1047 static struct wpa_ssid
* wpas_dpp_add_network(struct wpa_supplicant
*wpa_s
,
1048 struct dpp_authentication
*auth
)
1050 struct wpa_ssid
*ssid
;
1053 if (auth
->akm
== DPP_AKM_SAE
) {
1055 struct wpa_driver_capa capa
;
1058 res
= wpa_drv_get_capa(wpa_s
, &capa
);
1060 !(capa
.key_mgmt
& WPA_DRIVER_CAPA_KEY_MGMT_SAE
) &&
1061 !(wpa_s
->drv_flags
& WPA_DRIVER_FLAGS_SAE
)) {
1062 wpa_printf(MSG_DEBUG
,
1063 "DPP: SAE not supported by the driver");
1066 #else /* CONFIG_SAE */
1067 wpa_printf(MSG_DEBUG
, "DPP: SAE not supported in the build");
1069 #endif /* CONFIG_SAE */
1071 #endif /* CONFIG_DPP2 */
1073 ssid
= wpa_config_add_network(wpa_s
->conf
);
1076 wpas_notify_network_added(wpa_s
, ssid
);
1077 wpa_config_set_network_defaults(ssid
);
1080 ssid
->ssid
= os_malloc(auth
->ssid_len
);
1083 os_memcpy(ssid
->ssid
, auth
->ssid
, auth
->ssid_len
);
1084 ssid
->ssid_len
= auth
->ssid_len
;
1086 if (auth
->connector
) {
1087 ssid
->key_mgmt
= WPA_KEY_MGMT_DPP
;
1088 ssid
->ieee80211w
= MGMT_FRAME_PROTECTION_REQUIRED
;
1089 ssid
->dpp_connector
= os_strdup(auth
->connector
);
1090 if (!ssid
->dpp_connector
)
1094 if (auth
->c_sign_key
) {
1095 ssid
->dpp_csign
= os_malloc(wpabuf_len(auth
->c_sign_key
));
1096 if (!ssid
->dpp_csign
)
1098 os_memcpy(ssid
->dpp_csign
, wpabuf_head(auth
->c_sign_key
),
1099 wpabuf_len(auth
->c_sign_key
));
1100 ssid
->dpp_csign_len
= wpabuf_len(auth
->c_sign_key
);
1103 if (auth
->net_access_key
) {
1104 ssid
->dpp_netaccesskey
=
1105 os_malloc(wpabuf_len(auth
->net_access_key
));
1106 if (!ssid
->dpp_netaccesskey
)
1108 os_memcpy(ssid
->dpp_netaccesskey
,
1109 wpabuf_head(auth
->net_access_key
),
1110 wpabuf_len(auth
->net_access_key
));
1111 ssid
->dpp_netaccesskey_len
= wpabuf_len(auth
->net_access_key
);
1112 ssid
->dpp_netaccesskey_expiry
= auth
->net_access_key_expiry
;
1115 if (!auth
->connector
|| dpp_akm_psk(auth
->akm
) ||
1116 dpp_akm_sae(auth
->akm
)) {
1117 if (!auth
->connector
)
1119 if (dpp_akm_psk(auth
->akm
))
1120 ssid
->key_mgmt
|= WPA_KEY_MGMT_PSK
|
1121 WPA_KEY_MGMT_PSK_SHA256
| WPA_KEY_MGMT_FT_PSK
;
1122 if (dpp_akm_sae(auth
->akm
))
1123 ssid
->key_mgmt
|= WPA_KEY_MGMT_SAE
|
1124 WPA_KEY_MGMT_FT_SAE
;
1125 ssid
->ieee80211w
= MGMT_FRAME_PROTECTION_OPTIONAL
;
1126 if (auth
->passphrase
[0]) {
1127 if (wpa_config_set_quoted(ssid
, "psk",
1128 auth
->passphrase
) < 0)
1130 wpa_config_update_psk(ssid
);
1131 ssid
->export_keys
= 1;
1133 ssid
->psk_set
= auth
->psk_set
;
1134 os_memcpy(ssid
->psk
, auth
->psk
, PMK_LEN
);
1140 wpas_notify_network_removed(wpa_s
, ssid
);
1141 wpa_config_remove_network(wpa_s
->conf
, ssid
->id
);
1146 static int wpas_dpp_process_config(struct wpa_supplicant
*wpa_s
,
1147 struct dpp_authentication
*auth
)
1149 struct wpa_ssid
*ssid
;
1151 if (wpa_s
->conf
->dpp_config_processing
< 1)
1154 ssid
= wpas_dpp_add_network(wpa_s
, auth
);
1158 wpa_msg(wpa_s
, MSG_INFO
, DPP_EVENT_NETWORK_ID
"%d", ssid
->id
);
1159 if (wpa_s
->conf
->dpp_config_processing
== 2)
1162 #ifndef CONFIG_NO_CONFIG_WRITE
1163 if (wpa_s
->conf
->update_config
&&
1164 wpa_config_write(wpa_s
->confname
, wpa_s
->conf
))
1165 wpa_printf(MSG_DEBUG
, "DPP: Failed to update configuration");
1166 #endif /* CONFIG_NO_CONFIG_WRITE */
1168 if (wpa_s
->conf
->dpp_config_processing
< 2)
1172 if (auth
->peer_version
>= 2) {
1173 wpa_printf(MSG_DEBUG
,
1174 "DPP: Postpone connection attempt to wait for completion of DPP Configuration Result");
1175 auth
->connect_on_tx_status
= 1;
1178 #endif /* CONFIG_DPP2 */
1180 wpas_dpp_try_to_connect(wpa_s
);
1185 static int wpas_dpp_handle_config_obj(struct wpa_supplicant
*wpa_s
,
1186 struct dpp_authentication
*auth
)
1188 wpa_msg(wpa_s
, MSG_INFO
, DPP_EVENT_CONF_RECEIVED
);
1190 wpa_msg(wpa_s
, MSG_INFO
, DPP_EVENT_CONFOBJ_SSID
"%s",
1191 wpa_ssid_txt(auth
->ssid
, auth
->ssid_len
));
1192 if (auth
->connector
) {
1193 /* TODO: Save the Connector and consider using a command
1194 * to fetch the value instead of sending an event with
1195 * it. The Connector could end up being larger than what
1196 * most clients are ready to receive as an event
1198 wpa_msg(wpa_s
, MSG_INFO
, DPP_EVENT_CONNECTOR
"%s",
1201 if (auth
->c_sign_key
) {
1205 hexlen
= 2 * wpabuf_len(auth
->c_sign_key
) + 1;
1206 hex
= os_malloc(hexlen
);
1208 wpa_snprintf_hex(hex
, hexlen
,
1209 wpabuf_head(auth
->c_sign_key
),
1210 wpabuf_len(auth
->c_sign_key
));
1211 wpa_msg(wpa_s
, MSG_INFO
, DPP_EVENT_C_SIGN_KEY
"%s",
1216 if (auth
->net_access_key
) {
1220 hexlen
= 2 * wpabuf_len(auth
->net_access_key
) + 1;
1221 hex
= os_malloc(hexlen
);
1223 wpa_snprintf_hex(hex
, hexlen
,
1224 wpabuf_head(auth
->net_access_key
),
1225 wpabuf_len(auth
->net_access_key
));
1226 if (auth
->net_access_key_expiry
)
1227 wpa_msg(wpa_s
, MSG_INFO
,
1228 DPP_EVENT_NET_ACCESS_KEY
"%s %lu", hex
,
1230 auth
->net_access_key_expiry
);
1232 wpa_msg(wpa_s
, MSG_INFO
,
1233 DPP_EVENT_NET_ACCESS_KEY
"%s", hex
);
1238 return wpas_dpp_process_config(wpa_s
, auth
);
1242 static void wpas_dpp_gas_resp_cb(void *ctx
, const u8
*addr
, u8 dialog_token
,
1243 enum gas_query_result result
,
1244 const struct wpabuf
*adv_proto
,
1245 const struct wpabuf
*resp
, u16 status_code
)
1247 struct wpa_supplicant
*wpa_s
= ctx
;
1249 struct dpp_authentication
*auth
= wpa_s
->dpp_auth
;
1251 enum dpp_status_error status
= DPP_STATUS_CONFIG_REJECTED
;
1253 wpa_s
->dpp_gas_dialog_token
= -1;
1255 if (!auth
|| !auth
->auth_success
) {
1256 wpa_printf(MSG_DEBUG
, "DPP: No matching exchange in progress");
1259 if (result
!= GAS_QUERY_SUCCESS
||
1260 !resp
|| status_code
!= WLAN_STATUS_SUCCESS
) {
1261 wpa_printf(MSG_DEBUG
, "DPP: GAS query did not succeed");
1265 wpa_hexdump_buf(MSG_DEBUG
, "DPP: Configuration Response adv_proto",
1267 wpa_hexdump_buf(MSG_DEBUG
, "DPP: Configuration Response (GAS response)",
1270 if (wpabuf_len(adv_proto
) != 10 ||
1271 !(pos
= wpabuf_head(adv_proto
)) ||
1272 pos
[0] != WLAN_EID_ADV_PROTO
||
1274 pos
[3] != WLAN_EID_VENDOR_SPECIFIC
||
1276 WPA_GET_BE24(&pos
[5]) != OUI_WFA
||
1279 wpa_printf(MSG_DEBUG
,
1280 "DPP: Not a DPP Advertisement Protocol ID");
1284 if (dpp_conf_resp_rx(auth
, resp
) < 0) {
1285 wpa_printf(MSG_DEBUG
, "DPP: Configuration attempt failed");
1289 res
= wpas_dpp_handle_config_obj(wpa_s
, auth
);
1293 status
= DPP_STATUS_OK
;
1294 #ifdef CONFIG_TESTING_OPTIONS
1295 if (dpp_test
== DPP_TEST_REJECT_CONFIG
) {
1296 wpa_printf(MSG_INFO
, "DPP: TESTING - Reject Config Object");
1297 status
= DPP_STATUS_CONFIG_REJECTED
;
1299 #endif /* CONFIG_TESTING_OPTIONS */
1301 if (status
!= DPP_STATUS_OK
)
1302 wpa_msg(wpa_s
, MSG_INFO
, DPP_EVENT_CONF_FAILED
);
1304 if (auth
->peer_version
>= 2 &&
1305 auth
->conf_resp_status
== DPP_STATUS_OK
) {
1308 wpa_printf(MSG_DEBUG
, "DPP: Send DPP Configuration Result");
1309 msg
= dpp_build_conf_result(auth
, status
);
1313 wpa_msg(wpa_s
, MSG_INFO
,
1314 DPP_EVENT_TX
"dst=" MACSTR
" freq=%u type=%d",
1315 MAC2STR(addr
), auth
->curr_freq
,
1316 DPP_PA_CONFIGURATION_RESULT
);
1317 offchannel_send_action(wpa_s
, auth
->curr_freq
,
1318 addr
, wpa_s
->own_addr
, broadcast
,
1321 500, wpas_dpp_tx_status
, 0);
1324 /* This exchange will be terminated in the TX status handler */
1328 #endif /* CONFIG_DPP2 */
1329 dpp_auth_deinit(wpa_s
->dpp_auth
);
1330 wpa_s
->dpp_auth
= NULL
;
1334 static void wpas_dpp_start_gas_client(struct wpa_supplicant
*wpa_s
)
1336 struct dpp_authentication
*auth
= wpa_s
->dpp_auth
;
1337 struct wpabuf
*buf
, *conf_req
;
1341 wpa_s
->dpp_gas_client
= 1;
1342 os_snprintf(json
, sizeof(json
),
1343 "{\"name\":\"Test\","
1344 "\"wi-fi_tech\":\"infra\","
1345 "\"netRole\":\"%s\"}",
1346 wpa_s
->dpp_netrole_ap
? "ap" : "sta");
1347 #ifdef CONFIG_TESTING_OPTIONS
1348 if (dpp_test
== DPP_TEST_INVALID_CONFIG_ATTR_OBJ_CONF_REQ
) {
1349 wpa_printf(MSG_INFO
, "DPP: TESTING - invalid Config Attr");
1350 json
[29] = 'k'; /* replace "infra" with "knfra" */
1352 #endif /* CONFIG_TESTING_OPTIONS */
1353 wpa_printf(MSG_DEBUG
, "DPP: GAS Config Attributes: %s", json
);
1355 offchannel_send_action_done(wpa_s
);
1356 wpas_dpp_listen_stop(wpa_s
);
1358 conf_req
= dpp_build_conf_req(auth
, json
);
1360 wpa_printf(MSG_DEBUG
,
1361 "DPP: No configuration request data available");
1365 buf
= gas_build_initial_req(0, 10 + 2 + wpabuf_len(conf_req
));
1367 wpabuf_free(conf_req
);
1371 /* Advertisement Protocol IE */
1372 wpabuf_put_u8(buf
, WLAN_EID_ADV_PROTO
);
1373 wpabuf_put_u8(buf
, 8); /* Length */
1374 wpabuf_put_u8(buf
, 0x7f);
1375 wpabuf_put_u8(buf
, WLAN_EID_VENDOR_SPECIFIC
);
1376 wpabuf_put_u8(buf
, 5);
1377 wpabuf_put_be24(buf
, OUI_WFA
);
1378 wpabuf_put_u8(buf
, DPP_OUI_TYPE
);
1379 wpabuf_put_u8(buf
, 0x01);
1382 wpabuf_put_le16(buf
, wpabuf_len(conf_req
));
1383 wpabuf_put_buf(buf
, conf_req
);
1384 wpabuf_free(conf_req
);
1386 wpa_printf(MSG_DEBUG
, "DPP: GAS request to " MACSTR
" (freq %u MHz)",
1387 MAC2STR(auth
->peer_mac_addr
), auth
->curr_freq
);
1389 res
= gas_query_req(wpa_s
->gas
, auth
->peer_mac_addr
, auth
->curr_freq
,
1390 1, buf
, wpas_dpp_gas_resp_cb
, wpa_s
);
1392 wpa_msg(wpa_s
, MSG_DEBUG
, "GAS: Failed to send Query Request");
1395 wpa_printf(MSG_DEBUG
,
1396 "DPP: GAS query started with dialog token %u", res
);
1397 wpa_s
->dpp_gas_dialog_token
= res
;
1402 static void wpas_dpp_auth_success(struct wpa_supplicant
*wpa_s
, int initiator
)
1404 wpa_printf(MSG_DEBUG
, "DPP: Authentication succeeded");
1405 wpa_msg(wpa_s
, MSG_INFO
, DPP_EVENT_AUTH_SUCCESS
"init=%d", initiator
);
1406 #ifdef CONFIG_TESTING_OPTIONS
1407 if (dpp_test
== DPP_TEST_STOP_AT_AUTH_CONF
) {
1408 wpa_printf(MSG_INFO
,
1409 "DPP: TESTING - stop at Authentication Confirm");
1410 if (wpa_s
->dpp_auth
->configurator
) {
1411 /* Prevent GAS response */
1412 wpa_s
->dpp_auth
->auth_success
= 0;
1416 #endif /* CONFIG_TESTING_OPTIONS */
1418 if (wpa_s
->dpp_auth
->configurator
)
1419 wpas_dpp_start_gas_server(wpa_s
);
1421 wpas_dpp_start_gas_client(wpa_s
);
1425 static void wpas_dpp_rx_auth_resp(struct wpa_supplicant
*wpa_s
, const u8
*src
,
1426 const u8
*hdr
, const u8
*buf
, size_t len
,
1429 struct dpp_authentication
*auth
= wpa_s
->dpp_auth
;
1432 wpa_printf(MSG_DEBUG
, "DPP: Authentication Response from " MACSTR
1433 " (freq %u MHz)", MAC2STR(src
), freq
);
1436 wpa_printf(MSG_DEBUG
,
1437 "DPP: No DPP Authentication in progress - drop");
1441 if (!is_zero_ether_addr(auth
->peer_mac_addr
) &&
1442 os_memcmp(src
, auth
->peer_mac_addr
, ETH_ALEN
) != 0) {
1443 wpa_printf(MSG_DEBUG
, "DPP: MAC address mismatch (expected "
1444 MACSTR
") - drop", MAC2STR(auth
->peer_mac_addr
));
1448 eloop_cancel_timeout(wpas_dpp_reply_wait_timeout
, wpa_s
, NULL
);
1450 if (auth
->curr_freq
!= freq
&& auth
->neg_freq
== freq
) {
1451 wpa_printf(MSG_DEBUG
,
1452 "DPP: Responder accepted request for different negotiation channel");
1453 auth
->curr_freq
= freq
;
1456 eloop_cancel_timeout(wpas_dpp_init_timeout
, wpa_s
, NULL
);
1457 msg
= dpp_auth_resp_rx(auth
, hdr
, buf
, len
);
1459 if (auth
->auth_resp_status
== DPP_STATUS_RESPONSE_PENDING
) {
1460 wpa_printf(MSG_DEBUG
,
1461 "DPP: Start wait for full response");
1462 offchannel_send_action_done(wpa_s
);
1463 wpas_dpp_listen_start(wpa_s
, auth
->curr_freq
);
1466 wpa_printf(MSG_DEBUG
, "DPP: No confirm generated");
1469 os_memcpy(auth
->peer_mac_addr
, src
, ETH_ALEN
);
1471 wpa_msg(wpa_s
, MSG_INFO
, DPP_EVENT_TX
"dst=" MACSTR
" freq=%u type=%d",
1472 MAC2STR(src
), auth
->curr_freq
, DPP_PA_AUTHENTICATION_CONF
);
1473 offchannel_send_action(wpa_s
, auth
->curr_freq
,
1474 src
, wpa_s
->own_addr
, broadcast
,
1475 wpabuf_head(msg
), wpabuf_len(msg
),
1476 500, wpas_dpp_tx_status
, 0);
1478 wpa_s
->dpp_auth_ok_on_ack
= 1;
1482 static void wpas_dpp_rx_auth_conf(struct wpa_supplicant
*wpa_s
, const u8
*src
,
1483 const u8
*hdr
, const u8
*buf
, size_t len
)
1485 struct dpp_authentication
*auth
= wpa_s
->dpp_auth
;
1487 wpa_printf(MSG_DEBUG
, "DPP: Authentication Confirmation from " MACSTR
,
1491 wpa_printf(MSG_DEBUG
,
1492 "DPP: No DPP Authentication in progress - drop");
1496 if (os_memcmp(src
, auth
->peer_mac_addr
, ETH_ALEN
) != 0) {
1497 wpa_printf(MSG_DEBUG
, "DPP: MAC address mismatch (expected "
1498 MACSTR
") - drop", MAC2STR(auth
->peer_mac_addr
));
1502 if (dpp_auth_conf_rx(auth
, hdr
, buf
, len
) < 0) {
1503 wpa_printf(MSG_DEBUG
, "DPP: Authentication failed");
1507 wpas_dpp_auth_success(wpa_s
, 0);
1513 static void wpas_dpp_config_result_wait_timeout(void *eloop_ctx
,
1516 struct wpa_supplicant
*wpa_s
= eloop_ctx
;
1517 struct dpp_authentication
*auth
= wpa_s
->dpp_auth
;
1519 if (!auth
|| !auth
->waiting_conf_result
)
1522 wpa_printf(MSG_DEBUG
,
1523 "DPP: Timeout while waiting for Configuration Result");
1524 wpa_msg(wpa_s
, MSG_INFO
, DPP_EVENT_CONF_FAILED
);
1525 dpp_auth_deinit(auth
);
1526 wpa_s
->dpp_auth
= NULL
;
1530 static void wpas_dpp_rx_conf_result(struct wpa_supplicant
*wpa_s
, const u8
*src
,
1531 const u8
*hdr
, const u8
*buf
, size_t len
)
1533 struct dpp_authentication
*auth
= wpa_s
->dpp_auth
;
1534 enum dpp_status_error status
;
1536 wpa_printf(MSG_DEBUG
, "DPP: Configuration Result from " MACSTR
,
1539 if (!auth
|| !auth
->waiting_conf_result
) {
1540 wpa_printf(MSG_DEBUG
,
1541 "DPP: No DPP Configuration waiting for result - drop");
1545 if (os_memcmp(src
, auth
->peer_mac_addr
, ETH_ALEN
) != 0) {
1546 wpa_printf(MSG_DEBUG
, "DPP: MAC address mismatch (expected "
1547 MACSTR
") - drop", MAC2STR(auth
->peer_mac_addr
));
1551 status
= dpp_conf_result_rx(auth
, hdr
, buf
, len
);
1553 offchannel_send_action_done(wpa_s
);
1554 wpas_dpp_listen_stop(wpa_s
);
1555 if (status
== DPP_STATUS_OK
)
1556 wpa_msg(wpa_s
, MSG_INFO
, DPP_EVENT_CONF_SENT
);
1558 wpa_msg(wpa_s
, MSG_INFO
, DPP_EVENT_CONF_FAILED
);
1559 dpp_auth_deinit(auth
);
1560 wpa_s
->dpp_auth
= NULL
;
1561 eloop_cancel_timeout(wpas_dpp_config_result_wait_timeout
, wpa_s
, NULL
);
1564 #endif /* CONFIG_DPP2 */
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 case DPP_PA_CONFIGURATION_RESULT
:
2112 wpas_dpp_rx_conf_result(wpa_s
, src
, hdr
, buf
, len
);
2114 #endif /* CONFIG_DPP2 */
2116 wpa_printf(MSG_DEBUG
,
2117 "DPP: Ignored unsupported frame subtype %d", type
);
2121 if (wpa_s
->dpp_pkex
)
2122 pkex_t
= wpa_s
->dpp_pkex
->t
;
2123 else if (wpa_s
->dpp_pkex_bi
)
2124 pkex_t
= wpa_s
->dpp_pkex_bi
->pkex_t
;
2127 if (pkex_t
>= PKEX_COUNTER_T_LIMIT
) {
2128 wpa_msg(wpa_s
, MSG_INFO
, DPP_EVENT_PKEX_T_LIMIT
"id=0");
2129 wpas_dpp_pkex_remove(wpa_s
, "*");
2134 static struct wpabuf
*
2135 wpas_dpp_gas_req_handler(void *ctx
, const u8
*sa
, const u8
*query
,
2138 struct wpa_supplicant
*wpa_s
= ctx
;
2139 struct dpp_authentication
*auth
= wpa_s
->dpp_auth
;
2140 struct wpabuf
*resp
;
2142 wpa_printf(MSG_DEBUG
, "DPP: GAS request from " MACSTR
,
2144 if (!auth
|| !auth
->auth_success
||
2145 os_memcmp(sa
, auth
->peer_mac_addr
, ETH_ALEN
) != 0) {
2146 wpa_printf(MSG_DEBUG
, "DPP: No matching exchange in progress");
2149 wpa_hexdump(MSG_DEBUG
,
2150 "DPP: Received Configuration Request (GAS Query Request)",
2152 wpa_msg(wpa_s
, MSG_INFO
, DPP_EVENT_CONF_REQ_RX
"src=" MACSTR
,
2154 resp
= dpp_conf_req_rx(auth
, query
, query_len
);
2156 wpa_msg(wpa_s
, MSG_INFO
, DPP_EVENT_CONF_FAILED
);
2157 auth
->conf_resp
= resp
;
2163 wpas_dpp_gas_status_handler(void *ctx
, struct wpabuf
*resp
, int ok
)
2165 struct wpa_supplicant
*wpa_s
= ctx
;
2166 struct dpp_authentication
*auth
= wpa_s
->dpp_auth
;
2172 if (auth
->conf_resp
!= resp
) {
2173 wpa_printf(MSG_DEBUG
,
2174 "DPP: Ignore GAS status report (ok=%d) for unknown response",
2180 wpa_printf(MSG_DEBUG
, "DPP: Configuration exchange completed (ok=%d)",
2182 eloop_cancel_timeout(wpas_dpp_reply_wait_timeout
, wpa_s
, NULL
);
2183 eloop_cancel_timeout(wpas_dpp_auth_resp_retry_timeout
, wpa_s
, NULL
);
2185 if (ok
&& auth
->peer_version
>= 2 &&
2186 auth
->conf_resp_status
== DPP_STATUS_OK
) {
2187 wpa_printf(MSG_DEBUG
, "DPP: Wait for Configuration Result");
2188 auth
->waiting_conf_result
= 1;
2189 auth
->conf_resp
= NULL
;
2191 eloop_cancel_timeout(wpas_dpp_config_result_wait_timeout
,
2193 eloop_register_timeout(2, 0,
2194 wpas_dpp_config_result_wait_timeout
,
2198 #endif /* CONFIG_DPP2 */
2199 offchannel_send_action_done(wpa_s
);
2200 wpas_dpp_listen_stop(wpa_s
);
2202 wpa_msg(wpa_s
, MSG_INFO
, DPP_EVENT_CONF_SENT
);
2204 wpa_msg(wpa_s
, MSG_INFO
, DPP_EVENT_CONF_FAILED
);
2205 dpp_auth_deinit(wpa_s
->dpp_auth
);
2206 wpa_s
->dpp_auth
= NULL
;
2211 static unsigned int wpas_dpp_next_configurator_id(struct wpa_supplicant
*wpa_s
)
2213 struct dpp_configurator
*conf
;
2214 unsigned int max_id
= 0;
2216 dl_list_for_each(conf
, &wpa_s
->dpp_configurator
,
2217 struct dpp_configurator
, list
) {
2218 if (conf
->id
> max_id
)
2225 int wpas_dpp_configurator_add(struct wpa_supplicant
*wpa_s
, const char *cmd
)
2230 size_t privkey_len
= 0;
2232 struct dpp_configurator
*conf
= NULL
;
2234 curve
= get_param(cmd
, " curve=");
2235 key
= get_param(cmd
, " key=");
2238 privkey_len
= os_strlen(key
) / 2;
2239 privkey
= os_malloc(privkey_len
);
2241 hexstr2bin(key
, privkey
, privkey_len
) < 0)
2245 conf
= dpp_keygen_configurator(curve
, privkey
, privkey_len
);
2249 conf
->id
= wpas_dpp_next_configurator_id(wpa_s
);
2250 dl_list_add(&wpa_s
->dpp_configurator
, &conf
->list
);
2255 str_clear_free(key
);
2256 bin_clear_free(privkey
, privkey_len
);
2257 dpp_configurator_free(conf
);
2262 static int dpp_configurator_del(struct wpa_supplicant
*wpa_s
, unsigned int id
)
2264 struct dpp_configurator
*conf
, *tmp
;
2267 dl_list_for_each_safe(conf
, tmp
, &wpa_s
->dpp_configurator
,
2268 struct dpp_configurator
, list
) {
2269 if (id
&& conf
->id
!= id
)
2272 dl_list_del(&conf
->list
);
2273 dpp_configurator_free(conf
);
2277 return 0; /* flush succeeds regardless of entries found */
2278 return found
? 0 : -1;
2282 int wpas_dpp_configurator_remove(struct wpa_supplicant
*wpa_s
, const char *id
)
2284 unsigned int id_val
;
2286 if (os_strcmp(id
, "*") == 0) {
2294 return dpp_configurator_del(wpa_s
, id_val
);
2298 int wpas_dpp_configurator_sign(struct wpa_supplicant
*wpa_s
, const char *cmd
)
2300 struct dpp_authentication
*auth
;
2304 auth
= os_zalloc(sizeof(*auth
));
2308 curve
= get_param(cmd
, " curve=");
2309 wpas_dpp_set_testing_options(wpa_s
, auth
);
2310 if (wpas_dpp_set_configurator(wpa_s
, auth
, cmd
) == 0 &&
2311 dpp_configurator_own_config(auth
, curve
, 0) == 0)
2312 ret
= wpas_dpp_handle_config_obj(wpa_s
, auth
);
2314 dpp_auth_deinit(auth
);
2321 int wpas_dpp_configurator_get_key(struct wpa_supplicant
*wpa_s
, unsigned int id
,
2322 char *buf
, size_t buflen
)
2324 struct dpp_configurator
*conf
;
2326 conf
= dpp_configurator_get_id(wpa_s
, id
);
2330 return dpp_configurator_get_key(conf
, buf
, buflen
);
2335 wpas_dpp_tx_introduction_status(struct wpa_supplicant
*wpa_s
,
2336 unsigned int freq
, const u8
*dst
,
2337 const u8
*src
, const u8
*bssid
,
2338 const u8
*data
, size_t data_len
,
2339 enum offchannel_send_action_result result
)
2341 const char *res_txt
;
2343 res_txt
= result
== OFFCHANNEL_SEND_ACTION_SUCCESS
? "SUCCESS" :
2344 (result
== OFFCHANNEL_SEND_ACTION_NO_ACK
? "no-ACK" :
2346 wpa_printf(MSG_DEBUG
, "DPP: TX status: freq=%u dst=" MACSTR
2347 " result=%s (DPP Peer Discovery Request)",
2348 freq
, MAC2STR(dst
), res_txt
);
2349 wpa_msg(wpa_s
, MSG_INFO
, DPP_EVENT_TX_STATUS
"dst=" MACSTR
2350 " freq=%u result=%s", MAC2STR(dst
), freq
, res_txt
);
2351 /* TODO: Time out wait for response more quickly in error cases? */
2355 int wpas_dpp_check_connect(struct wpa_supplicant
*wpa_s
, struct wpa_ssid
*ssid
,
2356 struct wpa_bss
*bss
)
2360 unsigned int wait_time
;
2362 struct wpa_ie_data ied
;
2364 if (!(ssid
->key_mgmt
& WPA_KEY_MGMT_DPP
) || !bss
)
2365 return 0; /* Not using DPP AKM - continue */
2366 rsn
= wpa_bss_get_ie(bss
, WLAN_EID_RSN
);
2367 if (rsn
&& wpa_parse_wpa_ie(rsn
, 2 + rsn
[1], &ied
) == 0 &&
2368 !(ied
.key_mgmt
& WPA_KEY_MGMT_DPP
))
2369 return 0; /* AP does not support DPP AKM - continue */
2370 if (wpa_sm_pmksa_exists(wpa_s
->wpa
, bss
->bssid
, ssid
))
2371 return 0; /* PMKSA exists for DPP AKM - continue */
2373 if (!ssid
->dpp_connector
|| !ssid
->dpp_netaccesskey
||
2375 wpa_msg(wpa_s
, MSG_INFO
, DPP_EVENT_MISSING_CONNECTOR
2377 !ssid
->dpp_connector
? "Connector" :
2378 (!ssid
->dpp_netaccesskey
? "netAccessKey" :
2385 if (ssid
->dpp_netaccesskey_expiry
&&
2386 (os_time_t
) ssid
->dpp_netaccesskey_expiry
< now
.sec
) {
2387 wpa_msg(wpa_s
, MSG_INFO
, DPP_EVENT_MISSING_CONNECTOR
2388 "netAccessKey expired");
2392 wpa_printf(MSG_DEBUG
,
2393 "DPP: Starting network introduction protocol to derive PMKSA for "
2394 MACSTR
, MAC2STR(bss
->bssid
));
2396 msg
= dpp_alloc_msg(DPP_PA_PEER_DISCOVERY_REQ
,
2397 5 + 4 + os_strlen(ssid
->dpp_connector
));
2401 #ifdef CONFIG_TESTING_OPTIONS
2402 if (dpp_test
== DPP_TEST_NO_TRANSACTION_ID_PEER_DISC_REQ
) {
2403 wpa_printf(MSG_INFO
, "DPP: TESTING - no Transaction ID");
2406 if (dpp_test
== DPP_TEST_INVALID_TRANSACTION_ID_PEER_DISC_REQ
) {
2407 wpa_printf(MSG_INFO
, "DPP: TESTING - invalid Transaction ID");
2408 wpabuf_put_le16(msg
, DPP_ATTR_TRANSACTION_ID
);
2409 wpabuf_put_le16(msg
, 0);
2412 #endif /* CONFIG_TESTING_OPTIONS */
2414 /* Transaction ID */
2415 wpabuf_put_le16(msg
, DPP_ATTR_TRANSACTION_ID
);
2416 wpabuf_put_le16(msg
, 1);
2417 wpabuf_put_u8(msg
, TRANSACTION_ID
);
2419 #ifdef CONFIG_TESTING_OPTIONS
2421 if (dpp_test
== DPP_TEST_NO_CONNECTOR_PEER_DISC_REQ
) {
2422 wpa_printf(MSG_INFO
, "DPP: TESTING - no Connector");
2423 goto skip_connector
;
2425 if (dpp_test
== DPP_TEST_INVALID_CONNECTOR_PEER_DISC_REQ
) {
2428 wpa_printf(MSG_INFO
, "DPP: TESTING - invalid Connector");
2429 connector
= dpp_corrupt_connector_signature(
2430 ssid
->dpp_connector
);
2435 wpabuf_put_le16(msg
, DPP_ATTR_CONNECTOR
);
2436 wpabuf_put_le16(msg
, os_strlen(connector
));
2437 wpabuf_put_str(msg
, connector
);
2439 goto skip_connector
;
2441 #endif /* CONFIG_TESTING_OPTIONS */
2444 wpabuf_put_le16(msg
, DPP_ATTR_CONNECTOR
);
2445 wpabuf_put_le16(msg
, os_strlen(ssid
->dpp_connector
));
2446 wpabuf_put_str(msg
, ssid
->dpp_connector
);
2448 #ifdef CONFIG_TESTING_OPTIONS
2450 #endif /* CONFIG_TESTING_OPTIONS */
2452 /* TODO: Timeout on AP response */
2453 wait_time
= wpa_s
->max_remain_on_chan
;
2454 if (wait_time
> 2000)
2456 wpa_msg(wpa_s
, MSG_INFO
, DPP_EVENT_TX
"dst=" MACSTR
" freq=%u type=%d",
2457 MAC2STR(bss
->bssid
), bss
->freq
, DPP_PA_PEER_DISCOVERY_REQ
);
2458 offchannel_send_action(wpa_s
, bss
->freq
, bss
->bssid
, wpa_s
->own_addr
,
2460 wpabuf_head(msg
), wpabuf_len(msg
),
2461 wait_time
, wpas_dpp_tx_introduction_status
, 0);
2464 /* Request this connection attempt to terminate - new one will be
2465 * started when network introduction protocol completes */
2466 os_memcpy(wpa_s
->dpp_intro_bssid
, bss
->bssid
, ETH_ALEN
);
2467 wpa_s
->dpp_intro_network
= ssid
;
2472 int wpas_dpp_pkex_add(struct wpa_supplicant
*wpa_s
, const char *cmd
)
2474 struct dpp_bootstrap_info
*own_bi
;
2475 const char *pos
, *end
;
2476 unsigned int wait_time
;
2478 pos
= os_strstr(cmd
, " own=");
2482 own_bi
= dpp_bootstrap_get_id(wpa_s
, atoi(pos
));
2484 wpa_printf(MSG_DEBUG
,
2485 "DPP: Identified bootstrap info not found");
2488 if (own_bi
->type
!= DPP_BOOTSTRAP_PKEX
) {
2489 wpa_printf(MSG_DEBUG
,
2490 "DPP: Identified bootstrap info not for PKEX");
2493 wpa_s
->dpp_pkex_bi
= own_bi
;
2494 own_bi
->pkex_t
= 0; /* clear pending errors on new code */
2496 os_free(wpa_s
->dpp_pkex_identifier
);
2497 wpa_s
->dpp_pkex_identifier
= NULL
;
2498 pos
= os_strstr(cmd
, " identifier=");
2501 end
= os_strchr(pos
, ' ');
2504 wpa_s
->dpp_pkex_identifier
= os_malloc(end
- pos
+ 1);
2505 if (!wpa_s
->dpp_pkex_identifier
)
2507 os_memcpy(wpa_s
->dpp_pkex_identifier
, pos
, end
- pos
);
2508 wpa_s
->dpp_pkex_identifier
[end
- pos
] = '\0';
2511 pos
= os_strstr(cmd
, " code=");
2514 os_free(wpa_s
->dpp_pkex_code
);
2515 wpa_s
->dpp_pkex_code
= os_strdup(pos
+ 6);
2516 if (!wpa_s
->dpp_pkex_code
)
2519 if (os_strstr(cmd
, " init=1")) {
2520 struct dpp_pkex
*pkex
;
2523 wpa_printf(MSG_DEBUG
, "DPP: Initiating PKEX");
2524 dpp_pkex_free(wpa_s
->dpp_pkex
);
2525 wpa_s
->dpp_pkex
= dpp_pkex_init(wpa_s
, own_bi
, wpa_s
->own_addr
,
2526 wpa_s
->dpp_pkex_identifier
,
2527 wpa_s
->dpp_pkex_code
);
2528 pkex
= wpa_s
->dpp_pkex
;
2532 msg
= pkex
->exchange_req
;
2533 wait_time
= wpa_s
->max_remain_on_chan
;
2534 if (wait_time
> 2000)
2537 wpa_msg(wpa_s
, MSG_INFO
, DPP_EVENT_TX
"dst=" MACSTR
2539 MAC2STR(broadcast
), pkex
->freq
,
2540 DPP_PA_PKEX_EXCHANGE_REQ
);
2541 offchannel_send_action(wpa_s
, pkex
->freq
, broadcast
,
2542 wpa_s
->own_addr
, broadcast
,
2543 wpabuf_head(msg
), wpabuf_len(msg
),
2544 wait_time
, wpas_dpp_tx_pkex_status
, 0);
2547 pkex
->exch_req_wait_time
= wait_time
;
2548 pkex
->exch_req_tries
= 1;
2551 /* TODO: Support multiple PKEX info entries */
2553 os_free(wpa_s
->dpp_pkex_auth_cmd
);
2554 wpa_s
->dpp_pkex_auth_cmd
= os_strdup(cmd
);
2560 int wpas_dpp_pkex_remove(struct wpa_supplicant
*wpa_s
, const char *id
)
2562 unsigned int id_val
;
2564 if (os_strcmp(id
, "*") == 0) {
2572 if ((id_val
!= 0 && id_val
!= 1) || !wpa_s
->dpp_pkex_code
)
2575 /* TODO: Support multiple PKEX entries */
2576 os_free(wpa_s
->dpp_pkex_code
);
2577 wpa_s
->dpp_pkex_code
= NULL
;
2578 os_free(wpa_s
->dpp_pkex_identifier
);
2579 wpa_s
->dpp_pkex_identifier
= NULL
;
2580 os_free(wpa_s
->dpp_pkex_auth_cmd
);
2581 wpa_s
->dpp_pkex_auth_cmd
= NULL
;
2582 wpa_s
->dpp_pkex_bi
= NULL
;
2583 /* TODO: Remove dpp_pkex only if it is for the identified PKEX code */
2584 dpp_pkex_free(wpa_s
->dpp_pkex
);
2585 wpa_s
->dpp_pkex
= NULL
;
2590 void wpas_dpp_stop(struct wpa_supplicant
*wpa_s
)
2592 dpp_auth_deinit(wpa_s
->dpp_auth
);
2593 wpa_s
->dpp_auth
= NULL
;
2594 dpp_pkex_free(wpa_s
->dpp_pkex
);
2595 wpa_s
->dpp_pkex
= NULL
;
2596 if (wpa_s
->dpp_gas_client
&& wpa_s
->dpp_gas_dialog_token
>= 0)
2597 gas_query_stop(wpa_s
->gas
, wpa_s
->dpp_gas_dialog_token
);
2601 int wpas_dpp_init(struct wpa_supplicant
*wpa_s
)
2605 adv_proto_id
[0] = WLAN_EID_VENDOR_SPECIFIC
;
2606 adv_proto_id
[1] = 5;
2607 WPA_PUT_BE24(&adv_proto_id
[2], OUI_WFA
);
2608 adv_proto_id
[5] = DPP_OUI_TYPE
;
2609 adv_proto_id
[6] = 0x01;
2611 if (gas_server_register(wpa_s
->gas_server
, adv_proto_id
,
2612 sizeof(adv_proto_id
), wpas_dpp_gas_req_handler
,
2613 wpas_dpp_gas_status_handler
, wpa_s
) < 0)
2615 dl_list_init(&wpa_s
->dpp_bootstrap
);
2616 dl_list_init(&wpa_s
->dpp_configurator
);
2617 wpa_s
->dpp_init_done
= 1;
2622 void wpas_dpp_deinit(struct wpa_supplicant
*wpa_s
)
2624 #ifdef CONFIG_TESTING_OPTIONS
2625 os_free(wpa_s
->dpp_config_obj_override
);
2626 wpa_s
->dpp_config_obj_override
= NULL
;
2627 os_free(wpa_s
->dpp_discovery_override
);
2628 wpa_s
->dpp_discovery_override
= NULL
;
2629 os_free(wpa_s
->dpp_groups_override
);
2630 wpa_s
->dpp_groups_override
= NULL
;
2631 wpa_s
->dpp_ignore_netaccesskey_mismatch
= 0;
2632 #endif /* CONFIG_TESTING_OPTIONS */
2633 if (!wpa_s
->dpp_init_done
)
2635 eloop_cancel_timeout(wpas_dpp_pkex_retry_timeout
, wpa_s
, NULL
);
2636 eloop_cancel_timeout(wpas_dpp_reply_wait_timeout
, wpa_s
, NULL
);
2637 eloop_cancel_timeout(wpas_dpp_init_timeout
, wpa_s
, NULL
);
2638 eloop_cancel_timeout(wpas_dpp_auth_resp_retry_timeout
, wpa_s
, NULL
);
2640 eloop_cancel_timeout(wpas_dpp_config_result_wait_timeout
, wpa_s
, NULL
);
2641 dpp_pfs_free(wpa_s
->dpp_pfs
);
2642 wpa_s
->dpp_pfs
= NULL
;
2643 #endif /* CONFIG_DPP2 */
2644 offchannel_send_action_done(wpa_s
);
2645 wpas_dpp_listen_stop(wpa_s
);
2646 dpp_bootstrap_del(wpa_s
, 0);
2647 dpp_configurator_del(wpa_s
, 0);
2648 wpas_dpp_stop(wpa_s
);
2649 wpas_dpp_pkex_remove(wpa_s
, "*");
2650 os_memset(wpa_s
->dpp_intro_bssid
, 0, ETH_ALEN
);
2651 os_free(wpa_s
->dpp_configurator_params
);
2652 wpa_s
->dpp_configurator_params
= NULL
;