]>
Commit | Line | Data |
---|---|---|
be27e185 JM |
1 | /* |
2 | * wpa_supplicant - DPP | |
3 | * Copyright (c) 2017, Qualcomm Atheros, Inc. | |
4 | * | |
5 | * This software may be distributed under the terms of the BSD license. | |
6 | * See README for more details. | |
7 | */ | |
8 | ||
9 | #include "utils/includes.h" | |
10 | ||
11 | #include "utils/common.h" | |
30d27b04 | 12 | #include "utils/eloop.h" |
be27e185 | 13 | #include "common/dpp.h" |
461d39af JM |
14 | #include "common/gas.h" |
15 | #include "common/gas_server.h" | |
a0d5c56f JM |
16 | #include "rsn_supp/wpa.h" |
17 | #include "rsn_supp/pmksa_cache.h" | |
be27e185 | 18 | #include "wpa_supplicant_i.h" |
a0d5c56f | 19 | #include "config.h" |
30d27b04 JM |
20 | #include "driver_i.h" |
21 | #include "offchannel.h" | |
461d39af | 22 | #include "gas_query.h" |
a0d5c56f JM |
23 | #include "bss.h" |
24 | #include "scan.h" | |
8528994e | 25 | #include "notify.h" |
be27e185 JM |
26 | #include "dpp_supplicant.h" |
27 | ||
28 | ||
30d27b04 JM |
29 | static int wpas_dpp_listen_start(struct wpa_supplicant *wpa_s, |
30 | unsigned int freq); | |
461d39af JM |
31 | static void wpas_dpp_reply_wait_timeout(void *eloop_ctx, void *timeout_ctx); |
32 | static void wpas_dpp_auth_success(struct wpa_supplicant *wpa_s, int initiator); | |
30d27b04 JM |
33 | static void wpas_dpp_tx_status(struct wpa_supplicant *wpa_s, |
34 | unsigned int freq, const u8 *dst, | |
35 | const u8 *src, const u8 *bssid, | |
36 | const u8 *data, size_t data_len, | |
37 | enum offchannel_send_action_result result); | |
38 | ||
39 | static const u8 broadcast[ETH_ALEN] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; | |
40 | ||
85fd8263 JM |
41 | /* Use a hardcoded Transaction ID 1 in Peer Discovery frames since there is only |
42 | * a single transaction in progress at any point in time. */ | |
43 | static const u8 TRANSACTION_ID = 1; | |
44 | ||
30d27b04 | 45 | |
461d39af JM |
46 | static struct dpp_configurator * |
47 | dpp_configurator_get_id(struct wpa_supplicant *wpa_s, unsigned int id) | |
48 | { | |
49 | struct dpp_configurator *conf; | |
50 | ||
51 | dl_list_for_each(conf, &wpa_s->dpp_configurator, | |
52 | struct dpp_configurator, list) { | |
53 | if (conf->id == id) | |
54 | return conf; | |
55 | } | |
56 | return NULL; | |
57 | } | |
58 | ||
59 | ||
be27e185 JM |
60 | static unsigned int wpas_dpp_next_id(struct wpa_supplicant *wpa_s) |
61 | { | |
62 | struct dpp_bootstrap_info *bi; | |
63 | unsigned int max_id = 0; | |
64 | ||
65 | dl_list_for_each(bi, &wpa_s->dpp_bootstrap, struct dpp_bootstrap_info, | |
66 | list) { | |
67 | if (bi->id > max_id) | |
68 | max_id = bi->id; | |
69 | } | |
70 | return max_id + 1; | |
71 | } | |
72 | ||
73 | ||
74 | /** | |
75 | * wpas_dpp_qr_code - Parse and add DPP bootstrapping info from a QR Code | |
76 | * @wpa_s: Pointer to wpa_supplicant data | |
77 | * @cmd: DPP URI read from a QR Code | |
78 | * Returns: Identifier of the stored info or -1 on failure | |
79 | */ | |
80 | int wpas_dpp_qr_code(struct wpa_supplicant *wpa_s, const char *cmd) | |
81 | { | |
82 | struct dpp_bootstrap_info *bi; | |
30d27b04 | 83 | struct dpp_authentication *auth = wpa_s->dpp_auth; |
be27e185 JM |
84 | |
85 | bi = dpp_parse_qr_code(cmd); | |
86 | if (!bi) | |
87 | return -1; | |
88 | ||
89 | bi->id = wpas_dpp_next_id(wpa_s); | |
90 | dl_list_add(&wpa_s->dpp_bootstrap, &bi->list); | |
91 | ||
30d27b04 JM |
92 | if (auth && auth->response_pending && |
93 | dpp_notify_new_qr_code(auth, bi) == 1) { | |
30d27b04 JM |
94 | wpa_printf(MSG_DEBUG, |
95 | "DPP: Sending out pending authentication response"); | |
30d27b04 JM |
96 | offchannel_send_action(wpa_s, auth->curr_freq, |
97 | auth->peer_mac_addr, wpa_s->own_addr, | |
98 | broadcast, | |
dc4d271c JM |
99 | wpabuf_head(auth->resp_msg), |
100 | wpabuf_len(auth->resp_msg), | |
30d27b04 | 101 | 500, wpas_dpp_tx_status, 0); |
30d27b04 JM |
102 | } |
103 | ||
be27e185 JM |
104 | return bi->id; |
105 | } | |
106 | ||
107 | ||
108 | static char * get_param(const char *cmd, const char *param) | |
109 | { | |
110 | const char *pos, *end; | |
111 | char *val; | |
112 | size_t len; | |
113 | ||
114 | pos = os_strstr(cmd, param); | |
115 | if (!pos) | |
116 | return NULL; | |
117 | ||
118 | pos += os_strlen(param); | |
119 | end = os_strchr(pos, ' '); | |
120 | if (end) | |
121 | len = end - pos; | |
122 | else | |
123 | len = os_strlen(pos); | |
124 | val = os_malloc(len + 1); | |
125 | if (!val) | |
126 | return NULL; | |
127 | os_memcpy(val, pos, len); | |
128 | val[len] = '\0'; | |
129 | return val; | |
130 | } | |
131 | ||
132 | ||
133 | int wpas_dpp_bootstrap_gen(struct wpa_supplicant *wpa_s, const char *cmd) | |
134 | { | |
135 | char *chan = NULL, *mac = NULL, *info = NULL, *pk = NULL, *curve = NULL; | |
136 | char *key = NULL; | |
137 | u8 *privkey = NULL; | |
138 | size_t privkey_len = 0; | |
139 | size_t len; | |
140 | int ret = -1; | |
141 | struct dpp_bootstrap_info *bi; | |
142 | ||
143 | bi = os_zalloc(sizeof(*bi)); | |
144 | if (!bi) | |
145 | goto fail; | |
146 | ||
147 | if (os_strstr(cmd, "type=qrcode")) | |
148 | bi->type = DPP_BOOTSTRAP_QR_CODE; | |
500ed7f0 JM |
149 | else if (os_strstr(cmd, "type=pkex")) |
150 | bi->type = DPP_BOOTSTRAP_PKEX; | |
be27e185 JM |
151 | else |
152 | goto fail; | |
153 | ||
154 | chan = get_param(cmd, " chan="); | |
155 | mac = get_param(cmd, " mac="); | |
156 | info = get_param(cmd, " info="); | |
157 | curve = get_param(cmd, " curve="); | |
158 | key = get_param(cmd, " key="); | |
159 | ||
160 | if (key) { | |
161 | privkey_len = os_strlen(key) / 2; | |
162 | privkey = os_malloc(privkey_len); | |
163 | if (!privkey || | |
164 | hexstr2bin(key, privkey, privkey_len) < 0) | |
165 | goto fail; | |
166 | } | |
167 | ||
168 | pk = dpp_keygen(bi, curve, privkey, privkey_len); | |
169 | if (!pk) | |
170 | goto fail; | |
171 | ||
172 | len = 4; /* "DPP:" */ | |
173 | if (chan) { | |
174 | if (dpp_parse_uri_chan_list(bi, chan) < 0) | |
175 | goto fail; | |
176 | len += 3 + os_strlen(chan); /* C:...; */ | |
177 | } | |
178 | if (mac) { | |
179 | if (dpp_parse_uri_mac(bi, mac) < 0) | |
180 | goto fail; | |
181 | len += 3 + os_strlen(mac); /* M:...; */ | |
182 | } | |
183 | if (info) { | |
184 | if (dpp_parse_uri_info(bi, info) < 0) | |
185 | goto fail; | |
186 | len += 3 + os_strlen(info); /* I:...; */ | |
187 | } | |
188 | len += 4 + os_strlen(pk); | |
189 | bi->uri = os_malloc(len + 1); | |
190 | if (!bi->uri) | |
191 | goto fail; | |
192 | os_snprintf(bi->uri, len + 1, "DPP:%s%s%s%s%s%s%s%s%sK:%s;;", | |
193 | chan ? "C:" : "", chan ? chan : "", chan ? ";" : "", | |
194 | mac ? "M:" : "", mac ? mac : "", mac ? ";" : "", | |
195 | info ? "I:" : "", info ? info : "", info ? ";" : "", | |
196 | pk); | |
197 | bi->id = wpas_dpp_next_id(wpa_s); | |
198 | dl_list_add(&wpa_s->dpp_bootstrap, &bi->list); | |
199 | ret = bi->id; | |
200 | bi = NULL; | |
201 | fail: | |
202 | os_free(curve); | |
203 | os_free(pk); | |
204 | os_free(chan); | |
205 | os_free(mac); | |
206 | os_free(info); | |
207 | str_clear_free(key); | |
208 | bin_clear_free(privkey, privkey_len); | |
209 | dpp_bootstrap_info_free(bi); | |
210 | return ret; | |
211 | } | |
212 | ||
213 | ||
214 | static struct dpp_bootstrap_info * | |
215 | dpp_bootstrap_get_id(struct wpa_supplicant *wpa_s, unsigned int id) | |
216 | { | |
217 | struct dpp_bootstrap_info *bi; | |
218 | ||
219 | dl_list_for_each(bi, &wpa_s->dpp_bootstrap, struct dpp_bootstrap_info, | |
220 | list) { | |
221 | if (bi->id == id) | |
222 | return bi; | |
223 | } | |
224 | return NULL; | |
225 | } | |
226 | ||
227 | ||
228 | static int dpp_bootstrap_del(struct wpa_supplicant *wpa_s, unsigned int id) | |
229 | { | |
230 | struct dpp_bootstrap_info *bi, *tmp; | |
231 | int found = 0; | |
232 | ||
233 | dl_list_for_each_safe(bi, tmp, &wpa_s->dpp_bootstrap, | |
234 | struct dpp_bootstrap_info, list) { | |
235 | if (id && bi->id != id) | |
236 | continue; | |
237 | found = 1; | |
238 | dl_list_del(&bi->list); | |
239 | dpp_bootstrap_info_free(bi); | |
240 | } | |
241 | ||
242 | if (id == 0) | |
243 | return 0; /* flush succeeds regardless of entries found */ | |
244 | return found ? 0 : -1; | |
245 | } | |
246 | ||
247 | ||
248 | int wpas_dpp_bootstrap_remove(struct wpa_supplicant *wpa_s, const char *id) | |
249 | { | |
250 | unsigned int id_val; | |
251 | ||
252 | if (os_strcmp(id, "*") == 0) { | |
253 | id_val = 0; | |
254 | } else { | |
255 | id_val = atoi(id); | |
256 | if (id_val == 0) | |
257 | return -1; | |
258 | } | |
259 | ||
260 | return dpp_bootstrap_del(wpa_s, id_val); | |
261 | } | |
262 | ||
263 | ||
264 | const char * wpas_dpp_bootstrap_get_uri(struct wpa_supplicant *wpa_s, | |
265 | unsigned int id) | |
266 | { | |
267 | struct dpp_bootstrap_info *bi; | |
268 | ||
269 | bi = dpp_bootstrap_get_id(wpa_s, id); | |
270 | if (!bi) | |
271 | return NULL; | |
272 | return bi->uri; | |
273 | } | |
274 | ||
275 | ||
6a7182a9 JM |
276 | int wpas_dpp_bootstrap_info(struct wpa_supplicant *wpa_s, int id, |
277 | char *reply, int reply_size) | |
278 | { | |
279 | struct dpp_bootstrap_info *bi; | |
280 | ||
281 | bi = dpp_bootstrap_get_id(wpa_s, id); | |
282 | if (!bi) | |
283 | return -1; | |
284 | return os_snprintf(reply, reply_size, "type=%s\n" | |
285 | "mac_addr=" MACSTR "\n" | |
286 | "info=%s\n" | |
287 | "num_freq=%u\n" | |
288 | "curve=%s\n", | |
484788b8 | 289 | dpp_bootstrap_type_txt(bi->type), |
6a7182a9 JM |
290 | MAC2STR(bi->mac_addr), |
291 | bi->info ? bi->info : "", | |
292 | bi->num_freq, | |
293 | bi->curve->name); | |
294 | } | |
295 | ||
296 | ||
30d27b04 JM |
297 | static void wpas_dpp_tx_status(struct wpa_supplicant *wpa_s, |
298 | unsigned int freq, const u8 *dst, | |
299 | const u8 *src, const u8 *bssid, | |
300 | const u8 *data, size_t data_len, | |
301 | enum offchannel_send_action_result result) | |
302 | { | |
303 | wpa_printf(MSG_DEBUG, "DPP: TX status: freq=%u dst=" MACSTR | |
304 | " result=%s", | |
305 | freq, MAC2STR(dst), | |
306 | result == OFFCHANNEL_SEND_ACTION_SUCCESS ? "SUCCESS" : | |
307 | (result == OFFCHANNEL_SEND_ACTION_NO_ACK ? "no-ACK" : | |
308 | "FAILED")); | |
309 | ||
310 | if (!wpa_s->dpp_auth) { | |
311 | wpa_printf(MSG_DEBUG, | |
312 | "DPP: Ignore TX status since there is no ongoing authentication exchange"); | |
313 | return; | |
314 | } | |
315 | ||
316 | if (wpa_s->dpp_auth->remove_on_tx_status) { | |
317 | wpa_printf(MSG_DEBUG, | |
318 | "DPP: Terminate authentication exchange due to an earlier error"); | |
461d39af JM |
319 | eloop_cancel_timeout(wpas_dpp_reply_wait_timeout, wpa_s, NULL); |
320 | offchannel_send_action_done(wpa_s); | |
30d27b04 JM |
321 | dpp_auth_deinit(wpa_s->dpp_auth); |
322 | wpa_s->dpp_auth = NULL; | |
323 | return; | |
324 | } | |
325 | ||
461d39af JM |
326 | if (wpa_s->dpp_auth_ok_on_ack) |
327 | wpas_dpp_auth_success(wpa_s, 1); | |
328 | ||
30d27b04 JM |
329 | if (!is_broadcast_ether_addr(dst) && |
330 | result != OFFCHANNEL_SEND_ACTION_SUCCESS) { | |
331 | wpa_printf(MSG_DEBUG, | |
332 | "DPP: Unicast DPP Action frame was not ACKed"); | |
333 | /* TODO: In case of DPP Authentication Request frame, move to | |
334 | * the next channel immediately */ | |
335 | } | |
336 | } | |
337 | ||
338 | ||
339 | static void wpas_dpp_reply_wait_timeout(void *eloop_ctx, void *timeout_ctx) | |
340 | { | |
341 | struct wpa_supplicant *wpa_s = eloop_ctx; | |
342 | ||
343 | if (!wpa_s->dpp_auth) | |
344 | return; | |
345 | wpa_printf(MSG_DEBUG, "DPP: Continue reply wait on channel %u MHz", | |
346 | wpa_s->dpp_auth->curr_freq); | |
347 | wpas_dpp_listen_start(wpa_s, wpa_s->dpp_auth->curr_freq); | |
348 | } | |
349 | ||
350 | ||
461d39af JM |
351 | static void wpas_dpp_set_testing_options(struct wpa_supplicant *wpa_s, |
352 | struct dpp_authentication *auth) | |
353 | { | |
354 | #ifdef CONFIG_TESTING_OPTIONS | |
355 | if (wpa_s->dpp_config_obj_override) | |
356 | auth->config_obj_override = | |
357 | os_strdup(wpa_s->dpp_config_obj_override); | |
358 | if (wpa_s->dpp_discovery_override) | |
359 | auth->discovery_override = | |
360 | os_strdup(wpa_s->dpp_discovery_override); | |
361 | if (wpa_s->dpp_groups_override) | |
362 | auth->groups_override = | |
363 | os_strdup(wpa_s->dpp_groups_override); | |
461d39af JM |
364 | auth->ignore_netaccesskey_mismatch = |
365 | wpa_s->dpp_ignore_netaccesskey_mismatch; | |
366 | #endif /* CONFIG_TESTING_OPTIONS */ | |
367 | } | |
368 | ||
369 | ||
b65b22d6 JM |
370 | static void wpas_dpp_set_configurator(struct wpa_supplicant *wpa_s, |
371 | struct dpp_authentication *auth, | |
372 | const char *cmd) | |
30d27b04 | 373 | { |
68cb6dce | 374 | const char *pos, *end; |
461d39af JM |
375 | struct dpp_configuration *conf_sta = NULL, *conf_ap = NULL; |
376 | struct dpp_configurator *conf = NULL; | |
68cb6dce JM |
377 | u8 ssid[32] = { "test" }; |
378 | size_t ssid_len = 4; | |
35f06421 JM |
379 | char pass[64] = { }; |
380 | size_t pass_len = 0; | |
5030d7d9 JM |
381 | u8 psk[PMK_LEN]; |
382 | int psk_set = 0; | |
461d39af | 383 | |
b65b22d6 JM |
384 | if (!cmd) |
385 | return; | |
461d39af | 386 | |
b65b22d6 | 387 | wpa_printf(MSG_DEBUG, "DPP: Set configurator parameters: %s", cmd); |
68cb6dce JM |
388 | pos = os_strstr(cmd, " ssid="); |
389 | if (pos) { | |
390 | pos += 6; | |
391 | end = os_strchr(pos, ' '); | |
392 | ssid_len = end ? (size_t) (end - pos) : os_strlen(pos); | |
393 | ssid_len /= 2; | |
394 | if (ssid_len > sizeof(ssid) || | |
395 | hexstr2bin(pos, ssid, ssid_len) < 0) | |
396 | goto fail; | |
397 | } | |
398 | ||
35f06421 JM |
399 | pos = os_strstr(cmd, " pass="); |
400 | if (pos) { | |
401 | pos += 6; | |
402 | end = os_strchr(pos, ' '); | |
403 | pass_len = end ? (size_t) (end - pos) : os_strlen(pos); | |
404 | pass_len /= 2; | |
405 | if (pass_len > sizeof(pass) - 1 || pass_len < 8 || | |
406 | hexstr2bin(pos, (u8 *) pass, pass_len) < 0) | |
407 | goto fail; | |
408 | } | |
409 | ||
5030d7d9 JM |
410 | pos = os_strstr(cmd, " psk="); |
411 | if (pos) { | |
412 | pos += 5; | |
413 | if (hexstr2bin(pos, psk, PMK_LEN) < 0) | |
414 | goto fail; | |
415 | psk_set = 1; | |
416 | } | |
417 | ||
461d39af JM |
418 | if (os_strstr(cmd, " conf=sta-")) { |
419 | conf_sta = os_zalloc(sizeof(struct dpp_configuration)); | |
420 | if (!conf_sta) | |
421 | goto fail; | |
68cb6dce JM |
422 | os_memcpy(conf_sta->ssid, ssid, ssid_len); |
423 | conf_sta->ssid_len = ssid_len; | |
461d39af JM |
424 | if (os_strstr(cmd, " conf=sta-psk")) { |
425 | conf_sta->dpp = 0; | |
5030d7d9 JM |
426 | if (psk_set) { |
427 | os_memcpy(conf_sta->psk, psk, PMK_LEN); | |
428 | } else { | |
429 | conf_sta->passphrase = os_strdup(pass); | |
430 | if (!conf_sta->passphrase) | |
431 | goto fail; | |
432 | } | |
461d39af JM |
433 | } else if (os_strstr(cmd, " conf=sta-dpp")) { |
434 | conf_sta->dpp = 1; | |
435 | } else { | |
436 | goto fail; | |
437 | } | |
438 | } | |
439 | ||
440 | if (os_strstr(cmd, " conf=ap-")) { | |
441 | conf_ap = os_zalloc(sizeof(struct dpp_configuration)); | |
442 | if (!conf_ap) | |
443 | goto fail; | |
68cb6dce JM |
444 | os_memcpy(conf_ap->ssid, ssid, ssid_len); |
445 | conf_ap->ssid_len = ssid_len; | |
461d39af JM |
446 | if (os_strstr(cmd, " conf=ap-psk")) { |
447 | conf_ap->dpp = 0; | |
5030d7d9 JM |
448 | if (psk_set) { |
449 | os_memcpy(conf_ap->psk, psk, PMK_LEN); | |
450 | } else { | |
451 | conf_ap->passphrase = os_strdup(pass); | |
452 | if (!conf_ap->passphrase) | |
453 | goto fail; | |
454 | } | |
461d39af JM |
455 | } else if (os_strstr(cmd, " conf=ap-dpp")) { |
456 | conf_ap->dpp = 1; | |
457 | } else { | |
458 | goto fail; | |
459 | } | |
460 | } | |
461 | ||
462 | pos = os_strstr(cmd, " expiry="); | |
463 | if (pos) { | |
464 | long int val; | |
465 | ||
466 | pos += 8; | |
467 | val = strtol(pos, NULL, 0); | |
468 | if (val <= 0) | |
469 | goto fail; | |
470 | if (conf_sta) | |
471 | conf_sta->netaccesskey_expiry = val; | |
472 | if (conf_ap) | |
473 | conf_ap->netaccesskey_expiry = val; | |
474 | } | |
475 | ||
476 | pos = os_strstr(cmd, " configurator="); | |
477 | if (pos) { | |
478 | pos += 14; | |
479 | conf = dpp_configurator_get_id(wpa_s, atoi(pos)); | |
480 | if (!conf) { | |
481 | wpa_printf(MSG_INFO, | |
482 | "DPP: Could not find the specified configurator"); | |
483 | goto fail; | |
484 | } | |
30d27b04 | 485 | } |
b65b22d6 JM |
486 | auth->conf_sta = conf_sta; |
487 | auth->conf_ap = conf_ap; | |
488 | auth->conf = conf; | |
489 | return; | |
490 | ||
491 | fail: | |
492 | wpa_printf(MSG_DEBUG, "DPP: Failed to set configurator parameters"); | |
493 | dpp_configuration_free(conf_sta); | |
494 | dpp_configuration_free(conf_ap); | |
495 | } | |
496 | ||
497 | ||
498 | int wpas_dpp_auth_init(struct wpa_supplicant *wpa_s, const char *cmd) | |
499 | { | |
500 | const char *pos; | |
501 | struct dpp_bootstrap_info *peer_bi, *own_bi = NULL; | |
b65b22d6 JM |
502 | const u8 *dst; |
503 | int res; | |
504 | int configurator = 1; | |
505 | unsigned int wait_time; | |
506 | ||
507 | wpa_s->dpp_gas_client = 0; | |
508 | ||
509 | pos = os_strstr(cmd, " peer="); | |
510 | if (!pos) | |
511 | return -1; | |
512 | pos += 6; | |
513 | peer_bi = dpp_bootstrap_get_id(wpa_s, atoi(pos)); | |
514 | if (!peer_bi) { | |
515 | wpa_printf(MSG_INFO, | |
516 | "DPP: Could not find bootstrapping info for the identified peer"); | |
517 | return -1; | |
518 | } | |
519 | ||
520 | pos = os_strstr(cmd, " own="); | |
521 | if (pos) { | |
522 | pos += 5; | |
523 | own_bi = dpp_bootstrap_get_id(wpa_s, atoi(pos)); | |
524 | if (!own_bi) { | |
525 | wpa_printf(MSG_INFO, | |
526 | "DPP: Could not find bootstrapping info for the identified local entry"); | |
527 | return -1; | |
528 | } | |
529 | ||
530 | if (peer_bi->curve != own_bi->curve) { | |
531 | wpa_printf(MSG_INFO, | |
532 | "DPP: Mismatching curves in bootstrapping info (peer=%s own=%s)", | |
533 | peer_bi->curve->name, own_bi->curve->name); | |
534 | return -1; | |
535 | } | |
536 | } | |
537 | ||
538 | pos = os_strstr(cmd, " role="); | |
539 | if (pos) { | |
540 | pos += 6; | |
541 | if (os_strncmp(pos, "configurator", 12) == 0) | |
542 | configurator = 1; | |
543 | else if (os_strncmp(pos, "enrollee", 8) == 0) | |
544 | configurator = 0; | |
545 | else | |
546 | goto fail; | |
547 | } | |
548 | ||
549 | pos = os_strstr(cmd, " netrole="); | |
550 | if (pos) { | |
551 | pos += 9; | |
552 | wpa_s->dpp_netrole_ap = os_strncmp(pos, "ap", 2) == 0; | |
553 | } | |
30d27b04 JM |
554 | |
555 | if (wpa_s->dpp_auth) { | |
556 | eloop_cancel_timeout(wpas_dpp_reply_wait_timeout, wpa_s, NULL); | |
557 | offchannel_send_action_done(wpa_s); | |
558 | dpp_auth_deinit(wpa_s->dpp_auth); | |
559 | } | |
560 | wpa_s->dpp_auth = dpp_auth_init(wpa_s, peer_bi, own_bi, configurator); | |
561 | if (!wpa_s->dpp_auth) | |
461d39af JM |
562 | goto fail; |
563 | wpas_dpp_set_testing_options(wpa_s, wpa_s->dpp_auth); | |
b65b22d6 | 564 | wpas_dpp_set_configurator(wpa_s, wpa_s->dpp_auth, cmd); |
30d27b04 JM |
565 | |
566 | /* TODO: Support iteration over all frequencies and filtering of | |
567 | * frequencies based on locally enabled channels that allow initiation | |
568 | * of transmission. */ | |
569 | if (peer_bi->num_freq > 0) | |
570 | wpa_s->dpp_auth->curr_freq = peer_bi->freq[0]; | |
571 | else | |
572 | wpa_s->dpp_auth->curr_freq = 2412; | |
573 | ||
30d27b04 JM |
574 | if (is_zero_ether_addr(peer_bi->mac_addr)) { |
575 | dst = broadcast; | |
576 | } else { | |
577 | dst = peer_bi->mac_addr; | |
578 | os_memcpy(wpa_s->dpp_auth->peer_mac_addr, peer_bi->mac_addr, | |
579 | ETH_ALEN); | |
580 | } | |
461d39af | 581 | wpa_s->dpp_auth_ok_on_ack = 0; |
30d27b04 JM |
582 | eloop_cancel_timeout(wpas_dpp_reply_wait_timeout, wpa_s, NULL); |
583 | wait_time = wpa_s->max_remain_on_chan; | |
584 | if (wait_time > 2000) | |
585 | wait_time = 2000; | |
586 | eloop_register_timeout(wait_time / 1000, (wait_time % 1000) * 1000, | |
587 | wpas_dpp_reply_wait_timeout, | |
588 | wpa_s, NULL); | |
589 | res = offchannel_send_action(wpa_s, wpa_s->dpp_auth->curr_freq, | |
590 | dst, wpa_s->own_addr, broadcast, | |
dc4d271c JM |
591 | wpabuf_head(wpa_s->dpp_auth->req_msg), |
592 | wpabuf_len(wpa_s->dpp_auth->req_msg), | |
30d27b04 | 593 | wait_time, wpas_dpp_tx_status, 0); |
30d27b04 JM |
594 | |
595 | return res; | |
461d39af | 596 | fail: |
461d39af | 597 | return -1; |
30d27b04 JM |
598 | } |
599 | ||
600 | ||
601 | struct wpas_dpp_listen_work { | |
602 | unsigned int freq; | |
603 | unsigned int duration; | |
604 | struct wpabuf *probe_resp_ie; | |
605 | }; | |
606 | ||
607 | ||
608 | static void wpas_dpp_listen_work_free(struct wpas_dpp_listen_work *lwork) | |
609 | { | |
610 | if (!lwork) | |
611 | return; | |
612 | os_free(lwork); | |
613 | } | |
614 | ||
615 | ||
616 | static void wpas_dpp_listen_work_done(struct wpa_supplicant *wpa_s) | |
617 | { | |
618 | struct wpas_dpp_listen_work *lwork; | |
619 | ||
620 | if (!wpa_s->dpp_listen_work) | |
621 | return; | |
622 | ||
623 | lwork = wpa_s->dpp_listen_work->ctx; | |
624 | wpas_dpp_listen_work_free(lwork); | |
625 | radio_work_done(wpa_s->dpp_listen_work); | |
626 | wpa_s->dpp_listen_work = NULL; | |
627 | } | |
628 | ||
629 | ||
630 | static void dpp_start_listen_cb(struct wpa_radio_work *work, int deinit) | |
631 | { | |
632 | struct wpa_supplicant *wpa_s = work->wpa_s; | |
633 | struct wpas_dpp_listen_work *lwork = work->ctx; | |
634 | ||
635 | if (deinit) { | |
636 | if (work->started) { | |
637 | wpa_s->dpp_listen_work = NULL; | |
638 | wpas_dpp_listen_stop(wpa_s); | |
639 | } | |
640 | wpas_dpp_listen_work_free(lwork); | |
641 | return; | |
642 | } | |
643 | ||
644 | wpa_s->dpp_listen_work = work; | |
645 | ||
646 | wpa_s->dpp_pending_listen_freq = lwork->freq; | |
647 | ||
648 | if (wpa_drv_remain_on_channel(wpa_s, lwork->freq, | |
649 | wpa_s->max_remain_on_chan) < 0) { | |
650 | wpa_printf(MSG_DEBUG, | |
651 | "DPP: Failed to request the driver to remain on channel (%u MHz) for listen", | |
652 | lwork->freq); | |
653 | wpas_dpp_listen_work_done(wpa_s); | |
654 | wpa_s->dpp_pending_listen_freq = 0; | |
655 | return; | |
656 | } | |
657 | wpa_s->off_channel_freq = 0; | |
658 | wpa_s->roc_waiting_drv_freq = lwork->freq; | |
659 | } | |
660 | ||
661 | ||
662 | static int wpas_dpp_listen_start(struct wpa_supplicant *wpa_s, | |
663 | unsigned int freq) | |
664 | { | |
665 | struct wpas_dpp_listen_work *lwork; | |
666 | ||
667 | if (wpa_s->dpp_listen_work) { | |
668 | wpa_printf(MSG_DEBUG, | |
669 | "DPP: Reject start_listen since dpp_listen_work already exists"); | |
670 | return -1; | |
671 | } | |
672 | ||
673 | if (wpa_s->dpp_listen_freq) | |
674 | wpas_dpp_listen_stop(wpa_s); | |
675 | wpa_s->dpp_listen_freq = freq; | |
676 | ||
677 | lwork = os_zalloc(sizeof(*lwork)); | |
678 | if (!lwork) | |
679 | return -1; | |
680 | lwork->freq = freq; | |
681 | ||
682 | if (radio_add_work(wpa_s, freq, "dpp-listen", 0, dpp_start_listen_cb, | |
683 | lwork) < 0) { | |
684 | wpas_dpp_listen_work_free(lwork); | |
685 | return -1; | |
686 | } | |
687 | ||
688 | return 0; | |
689 | } | |
690 | ||
691 | ||
692 | int wpas_dpp_listen(struct wpa_supplicant *wpa_s, const char *cmd) | |
693 | { | |
694 | int freq; | |
695 | ||
696 | freq = atoi(cmd); | |
697 | if (freq <= 0) | |
698 | return -1; | |
699 | ||
700 | if (os_strstr(cmd, " role=configurator")) | |
701 | wpa_s->dpp_allowed_roles = DPP_CAPAB_CONFIGURATOR; | |
702 | else if (os_strstr(cmd, " role=enrollee")) | |
703 | wpa_s->dpp_allowed_roles = DPP_CAPAB_ENROLLEE; | |
704 | else | |
705 | wpa_s->dpp_allowed_roles = DPP_CAPAB_CONFIGURATOR | | |
706 | DPP_CAPAB_ENROLLEE; | |
707 | wpa_s->dpp_qr_mutual = os_strstr(cmd, " qr=mutual") != NULL; | |
461d39af | 708 | wpa_s->dpp_netrole_ap = os_strstr(cmd, " netrole=ap") != NULL; |
30d27b04 JM |
709 | if (wpa_s->dpp_listen_freq == (unsigned int) freq) { |
710 | wpa_printf(MSG_DEBUG, "DPP: Already listening on %u MHz", | |
711 | freq); | |
712 | return 0; | |
713 | } | |
714 | ||
715 | return wpas_dpp_listen_start(wpa_s, freq); | |
716 | } | |
717 | ||
718 | ||
719 | void wpas_dpp_listen_stop(struct wpa_supplicant *wpa_s) | |
720 | { | |
721 | if (!wpa_s->dpp_listen_freq) | |
722 | return; | |
723 | ||
724 | wpa_printf(MSG_DEBUG, "DPP: Stop listen on %u MHz", | |
725 | wpa_s->dpp_listen_freq); | |
726 | wpa_drv_cancel_remain_on_channel(wpa_s); | |
727 | wpa_s->dpp_listen_freq = 0; | |
728 | wpas_dpp_listen_work_done(wpa_s); | |
729 | } | |
730 | ||
731 | ||
732 | void wpas_dpp_remain_on_channel_cb(struct wpa_supplicant *wpa_s, | |
733 | unsigned int freq) | |
734 | { | |
735 | if (!wpa_s->dpp_listen_freq && !wpa_s->dpp_pending_listen_freq) | |
736 | return; | |
737 | ||
738 | wpa_printf(MSG_DEBUG, | |
739 | "DPP: remain-on-channel callback (off_channel_freq=%u dpp_pending_listen_freq=%d roc_waiting_drv_freq=%d freq=%u)", | |
740 | wpa_s->off_channel_freq, wpa_s->dpp_pending_listen_freq, | |
741 | wpa_s->roc_waiting_drv_freq, freq); | |
742 | if (wpa_s->off_channel_freq && | |
743 | wpa_s->off_channel_freq == wpa_s->dpp_pending_listen_freq) { | |
744 | wpa_printf(MSG_DEBUG, "DPP: Listen on %u MHz started", freq); | |
745 | wpa_s->dpp_pending_listen_freq = 0; | |
746 | } else { | |
747 | wpa_printf(MSG_DEBUG, | |
748 | "DPP: Ignore remain-on-channel callback (off_channel_freq=%u dpp_pending_listen_freq=%d freq=%u)", | |
749 | wpa_s->off_channel_freq, | |
750 | wpa_s->dpp_pending_listen_freq, freq); | |
751 | } | |
752 | } | |
753 | ||
754 | ||
755 | void wpas_dpp_cancel_remain_on_channel_cb(struct wpa_supplicant *wpa_s, | |
756 | unsigned int freq) | |
757 | { | |
758 | wpas_dpp_listen_work_done(wpa_s); | |
759 | ||
461d39af | 760 | if (wpa_s->dpp_auth && !wpa_s->dpp_gas_client) { |
30d27b04 JM |
761 | /* Continue listen with a new remain-on-channel */ |
762 | wpa_printf(MSG_DEBUG, | |
763 | "DPP: Continue wait on %u MHz for the ongoing DPP provisioning session", | |
764 | wpa_s->dpp_auth->curr_freq); | |
765 | wpas_dpp_listen_start(wpa_s, wpa_s->dpp_auth->curr_freq); | |
766 | return; | |
767 | } | |
768 | ||
769 | if (wpa_s->dpp_listen_freq) { | |
770 | /* Continue listen with a new remain-on-channel */ | |
771 | wpas_dpp_listen_start(wpa_s, wpa_s->dpp_listen_freq); | |
772 | } | |
773 | } | |
774 | ||
775 | ||
776 | static void wpas_dpp_rx_auth_req(struct wpa_supplicant *wpa_s, const u8 *src, | |
dc4d271c JM |
777 | const u8 *hdr, const u8 *buf, size_t len, |
778 | unsigned int freq) | |
30d27b04 | 779 | { |
27fefbbb JM |
780 | const u8 *r_bootstrap, *i_bootstrap; |
781 | u16 r_bootstrap_len, i_bootstrap_len; | |
30d27b04 | 782 | struct dpp_bootstrap_info *bi, *own_bi = NULL, *peer_bi = NULL; |
30d27b04 JM |
783 | |
784 | wpa_printf(MSG_DEBUG, "DPP: Authentication Request from " MACSTR, | |
785 | MAC2STR(src)); | |
786 | ||
30d27b04 JM |
787 | r_bootstrap = dpp_get_attr(buf, len, DPP_ATTR_R_BOOTSTRAP_KEY_HASH, |
788 | &r_bootstrap_len); | |
27fefbbb | 789 | if (!r_bootstrap || r_bootstrap_len != SHA256_MAC_LEN) { |
30d27b04 JM |
790 | wpa_printf(MSG_DEBUG, |
791 | "DPP: Missing or invalid required Responder Bootstrapping Key Hash attribute"); | |
792 | return; | |
793 | } | |
794 | wpa_hexdump(MSG_MSGDUMP, "DPP: Responder Bootstrapping Key Hash", | |
795 | r_bootstrap, r_bootstrap_len); | |
796 | ||
797 | i_bootstrap = dpp_get_attr(buf, len, DPP_ATTR_I_BOOTSTRAP_KEY_HASH, | |
798 | &i_bootstrap_len); | |
27fefbbb | 799 | if (!i_bootstrap || i_bootstrap_len != SHA256_MAC_LEN) { |
30d27b04 JM |
800 | wpa_printf(MSG_DEBUG, |
801 | "DPP: Missing or invalid required Initiator Bootstrapping Key Hash attribute"); | |
802 | return; | |
803 | } | |
804 | wpa_hexdump(MSG_MSGDUMP, "DPP: Initiator Bootstrapping Key Hash", | |
805 | i_bootstrap, i_bootstrap_len); | |
806 | ||
807 | /* Try to find own and peer bootstrapping key matches based on the | |
808 | * received hash values */ | |
809 | dl_list_for_each(bi, &wpa_s->dpp_bootstrap, struct dpp_bootstrap_info, | |
810 | list) { | |
811 | if (!own_bi && bi->own && | |
812 | os_memcmp(bi->pubkey_hash, r_bootstrap, | |
813 | SHA256_MAC_LEN) == 0) { | |
814 | wpa_printf(MSG_DEBUG, | |
815 | "DPP: Found matching own bootstrapping information"); | |
816 | own_bi = bi; | |
817 | } | |
818 | ||
819 | if (!peer_bi && !bi->own && | |
820 | os_memcmp(bi->pubkey_hash, i_bootstrap, | |
821 | SHA256_MAC_LEN) == 0) { | |
822 | wpa_printf(MSG_DEBUG, | |
823 | "DPP: Found matching peer bootstrapping information"); | |
824 | peer_bi = bi; | |
825 | } | |
826 | ||
827 | if (own_bi && peer_bi) | |
828 | break; | |
829 | } | |
830 | ||
831 | if (!own_bi) { | |
832 | wpa_printf(MSG_DEBUG, | |
833 | "DPP: No matching own bootstrapping key found - ignore message"); | |
834 | return; | |
835 | } | |
836 | ||
837 | if (wpa_s->dpp_auth) { | |
838 | wpa_printf(MSG_DEBUG, | |
839 | "DPP: Already in DPP authentication exchange - ignore new one"); | |
840 | return; | |
841 | } | |
842 | ||
461d39af JM |
843 | wpa_s->dpp_gas_client = 0; |
844 | wpa_s->dpp_auth_ok_on_ack = 0; | |
30d27b04 JM |
845 | wpa_s->dpp_auth = dpp_auth_req_rx(wpa_s, wpa_s->dpp_allowed_roles, |
846 | wpa_s->dpp_qr_mutual, | |
27fefbbb | 847 | peer_bi, own_bi, freq, hdr, buf, len); |
30d27b04 JM |
848 | if (!wpa_s->dpp_auth) { |
849 | wpa_printf(MSG_DEBUG, "DPP: No response generated"); | |
850 | return; | |
851 | } | |
461d39af | 852 | wpas_dpp_set_testing_options(wpa_s, wpa_s->dpp_auth); |
b65b22d6 JM |
853 | wpas_dpp_set_configurator(wpa_s, wpa_s->dpp_auth, |
854 | wpa_s->dpp_configurator_params); | |
30d27b04 JM |
855 | os_memcpy(wpa_s->dpp_auth->peer_mac_addr, src, ETH_ALEN); |
856 | ||
30d27b04 JM |
857 | offchannel_send_action(wpa_s, wpa_s->dpp_auth->curr_freq, |
858 | src, wpa_s->own_addr, broadcast, | |
dc4d271c JM |
859 | wpabuf_head(wpa_s->dpp_auth->resp_msg), |
860 | wpabuf_len(wpa_s->dpp_auth->resp_msg), | |
30d27b04 | 861 | 500, wpas_dpp_tx_status, 0); |
30d27b04 JM |
862 | } |
863 | ||
864 | ||
461d39af JM |
865 | static void wpas_dpp_start_gas_server(struct wpa_supplicant *wpa_s) |
866 | { | |
867 | /* TODO: stop wait and start ROC */ | |
868 | } | |
869 | ||
870 | ||
8528994e JM |
871 | static struct wpa_ssid * wpas_dpp_add_network(struct wpa_supplicant *wpa_s, |
872 | struct dpp_authentication *auth) | |
873 | { | |
874 | struct wpa_ssid *ssid; | |
875 | ||
876 | ssid = wpa_config_add_network(wpa_s->conf); | |
877 | if (!ssid) | |
878 | return NULL; | |
879 | wpas_notify_network_added(wpa_s, ssid); | |
880 | wpa_config_set_network_defaults(ssid); | |
881 | ssid->disabled = 1; | |
882 | ||
883 | ssid->ssid = os_malloc(auth->ssid_len); | |
884 | if (!ssid->ssid) | |
885 | goto fail; | |
886 | os_memcpy(ssid->ssid, auth->ssid, auth->ssid_len); | |
887 | ssid->ssid_len = auth->ssid_len; | |
888 | ||
889 | if (auth->connector) { | |
890 | ssid->key_mgmt = WPA_KEY_MGMT_DPP; | |
891 | ssid->dpp_connector = os_strdup(auth->connector); | |
892 | if (!ssid->dpp_connector) | |
893 | goto fail; | |
894 | } | |
895 | ||
896 | if (auth->c_sign_key) { | |
897 | ssid->dpp_csign = os_malloc(wpabuf_len(auth->c_sign_key)); | |
898 | if (!ssid->dpp_csign) | |
899 | goto fail; | |
900 | os_memcpy(ssid->dpp_csign, wpabuf_head(auth->c_sign_key), | |
901 | wpabuf_len(auth->c_sign_key)); | |
902 | ssid->dpp_csign_len = wpabuf_len(auth->c_sign_key); | |
8528994e JM |
903 | } |
904 | ||
905 | if (auth->net_access_key) { | |
906 | ssid->dpp_netaccesskey = | |
907 | os_malloc(wpabuf_len(auth->net_access_key)); | |
908 | if (!ssid->dpp_netaccesskey) | |
909 | goto fail; | |
910 | os_memcpy(ssid->dpp_netaccesskey, | |
911 | wpabuf_head(auth->net_access_key), | |
912 | wpabuf_len(auth->net_access_key)); | |
913 | ssid->dpp_netaccesskey_len = wpabuf_len(auth->net_access_key); | |
914 | ssid->dpp_netaccesskey_expiry = auth->net_access_key_expiry; | |
915 | } | |
916 | ||
917 | if (!auth->connector) { | |
918 | ssid->key_mgmt = WPA_KEY_MGMT_PSK; | |
919 | if (auth->passphrase[0]) { | |
920 | if (wpa_config_set_quoted(ssid, "psk", | |
921 | auth->passphrase) < 0) | |
922 | goto fail; | |
923 | wpa_config_update_psk(ssid); | |
924 | ssid->export_keys = 1; | |
925 | } else { | |
926 | ssid->psk_set = auth->psk_set; | |
927 | os_memcpy(ssid->psk, auth->psk, PMK_LEN); | |
928 | } | |
929 | } | |
930 | ||
931 | return ssid; | |
932 | fail: | |
933 | wpas_notify_network_removed(wpa_s, ssid); | |
934 | wpa_config_remove_network(wpa_s->conf, ssid->id); | |
935 | return NULL; | |
936 | } | |
937 | ||
938 | ||
939 | static void wpas_dpp_process_config(struct wpa_supplicant *wpa_s, | |
940 | struct dpp_authentication *auth) | |
941 | { | |
942 | struct wpa_ssid *ssid; | |
943 | ||
944 | if (wpa_s->conf->dpp_config_processing < 1) | |
945 | return; | |
946 | ||
947 | ssid = wpas_dpp_add_network(wpa_s, auth); | |
948 | if (!ssid) | |
949 | return; | |
950 | ||
951 | wpa_msg(wpa_s, MSG_INFO, DPP_EVENT_NETWORK_ID "%d", ssid->id); | |
952 | if (wpa_s->conf->dpp_config_processing < 2) | |
953 | return; | |
954 | ||
955 | wpa_printf(MSG_DEBUG, "DPP: Trying to connect to the new network"); | |
956 | ssid->disabled = 0; | |
957 | wpa_s->disconnected = 0; | |
958 | wpa_s->reassociate = 1; | |
959 | wpa_s->scan_runs = 0; | |
960 | wpa_s->normal_scans = 0; | |
961 | wpa_supplicant_cancel_sched_scan(wpa_s); | |
962 | wpa_supplicant_req_scan(wpa_s, 0, 0); | |
963 | } | |
964 | ||
965 | ||
f522bb23 JM |
966 | static void wpas_dpp_handle_config_obj(struct wpa_supplicant *wpa_s, |
967 | struct dpp_authentication *auth) | |
461d39af | 968 | { |
461d39af JM |
969 | wpa_msg(wpa_s, MSG_INFO, DPP_EVENT_CONF_RECEIVED); |
970 | if (auth->ssid_len) | |
971 | wpa_msg(wpa_s, MSG_INFO, DPP_EVENT_CONFOBJ_SSID "%s", | |
972 | wpa_ssid_txt(auth->ssid, auth->ssid_len)); | |
973 | if (auth->connector) { | |
974 | /* TODO: Save the Connector and consider using a command | |
975 | * to fetch the value instead of sending an event with | |
976 | * it. The Connector could end up being larger than what | |
977 | * most clients are ready to receive as an event | |
978 | * message. */ | |
979 | wpa_msg(wpa_s, MSG_INFO, DPP_EVENT_CONNECTOR "%s", | |
980 | auth->connector); | |
981 | } | |
982 | if (auth->c_sign_key) { | |
983 | char *hex; | |
984 | size_t hexlen; | |
985 | ||
986 | hexlen = 2 * wpabuf_len(auth->c_sign_key) + 1; | |
987 | hex = os_malloc(hexlen); | |
988 | if (hex) { | |
989 | wpa_snprintf_hex(hex, hexlen, | |
990 | wpabuf_head(auth->c_sign_key), | |
991 | wpabuf_len(auth->c_sign_key)); | |
c77e2ff0 JM |
992 | wpa_msg(wpa_s, MSG_INFO, DPP_EVENT_C_SIGN_KEY "%s", |
993 | hex); | |
461d39af JM |
994 | os_free(hex); |
995 | } | |
996 | } | |
997 | if (auth->net_access_key) { | |
998 | char *hex; | |
999 | size_t hexlen; | |
1000 | ||
1001 | hexlen = 2 * wpabuf_len(auth->net_access_key) + 1; | |
1002 | hex = os_malloc(hexlen); | |
1003 | if (hex) { | |
1004 | wpa_snprintf_hex(hex, hexlen, | |
1005 | wpabuf_head(auth->net_access_key), | |
1006 | wpabuf_len(auth->net_access_key)); | |
1007 | if (auth->net_access_key_expiry) | |
1008 | wpa_msg(wpa_s, MSG_INFO, | |
1009 | DPP_EVENT_NET_ACCESS_KEY "%s %lu", hex, | |
1010 | (long unsigned) | |
1011 | auth->net_access_key_expiry); | |
1012 | else | |
1013 | wpa_msg(wpa_s, MSG_INFO, | |
1014 | DPP_EVENT_NET_ACCESS_KEY "%s", hex); | |
1015 | os_free(hex); | |
1016 | } | |
1017 | } | |
8528994e JM |
1018 | |
1019 | wpas_dpp_process_config(wpa_s, auth); | |
f522bb23 JM |
1020 | } |
1021 | ||
1022 | ||
1023 | static void wpas_dpp_gas_resp_cb(void *ctx, const u8 *addr, u8 dialog_token, | |
1024 | enum gas_query_result result, | |
1025 | const struct wpabuf *adv_proto, | |
1026 | const struct wpabuf *resp, u16 status_code) | |
1027 | { | |
1028 | struct wpa_supplicant *wpa_s = ctx; | |
1029 | const u8 *pos; | |
1030 | struct dpp_authentication *auth = wpa_s->dpp_auth; | |
1031 | ||
1032 | if (!auth || !auth->auth_success) { | |
1033 | wpa_printf(MSG_DEBUG, "DPP: No matching exchange in progress"); | |
1034 | return; | |
1035 | } | |
1036 | if (!resp || status_code != WLAN_STATUS_SUCCESS) { | |
1037 | wpa_printf(MSG_DEBUG, "DPP: GAS query did not succeed"); | |
1038 | goto fail; | |
1039 | } | |
1040 | ||
1041 | wpa_hexdump_buf(MSG_DEBUG, "DPP: Configuration Response adv_proto", | |
1042 | adv_proto); | |
1043 | wpa_hexdump_buf(MSG_DEBUG, "DPP: Configuration Response (GAS response)", | |
1044 | resp); | |
1045 | ||
1046 | if (wpabuf_len(adv_proto) != 10 || | |
1047 | !(pos = wpabuf_head(adv_proto)) || | |
1048 | pos[0] != WLAN_EID_ADV_PROTO || | |
1049 | pos[1] != 8 || | |
1050 | pos[3] != WLAN_EID_VENDOR_SPECIFIC || | |
1051 | pos[4] != 5 || | |
1052 | WPA_GET_BE24(&pos[5]) != OUI_WFA || | |
1053 | pos[8] != 0x1a || | |
1054 | pos[9] != 1) { | |
1055 | wpa_printf(MSG_DEBUG, | |
1056 | "DPP: Not a DPP Advertisement Protocol ID"); | |
1057 | goto fail; | |
1058 | } | |
8528994e | 1059 | |
f522bb23 JM |
1060 | if (dpp_conf_resp_rx(auth, resp) < 0) { |
1061 | wpa_printf(MSG_DEBUG, "DPP: Configuration attempt failed"); | |
1062 | goto fail; | |
1063 | } | |
1064 | ||
1065 | wpas_dpp_handle_config_obj(wpa_s, auth); | |
461d39af JM |
1066 | dpp_auth_deinit(wpa_s->dpp_auth); |
1067 | wpa_s->dpp_auth = NULL; | |
1068 | return; | |
1069 | ||
1070 | fail: | |
1071 | wpa_msg(wpa_s, MSG_INFO, DPP_EVENT_CONF_FAILED); | |
1072 | dpp_auth_deinit(wpa_s->dpp_auth); | |
1073 | wpa_s->dpp_auth = NULL; | |
1074 | } | |
1075 | ||
1076 | ||
1077 | static void wpas_dpp_start_gas_client(struct wpa_supplicant *wpa_s) | |
1078 | { | |
1079 | struct dpp_authentication *auth = wpa_s->dpp_auth; | |
1080 | struct wpabuf *buf, *conf_req; | |
1081 | char json[100]; | |
1082 | int res; | |
1083 | ||
1084 | wpa_s->dpp_gas_client = 1; | |
1085 | os_snprintf(json, sizeof(json), | |
1086 | "{\"name\":\"Test\"," | |
1087 | "\"wi-fi_tech\":\"infra\"," | |
1088 | "\"netRole\":\"%s\"}", | |
1089 | wpa_s->dpp_netrole_ap ? "ap" : "sta"); | |
1090 | wpa_printf(MSG_DEBUG, "DPP: GAS Config Attributes: %s", json); | |
1091 | ||
1092 | offchannel_send_action_done(wpa_s); | |
1093 | wpas_dpp_listen_stop(wpa_s); | |
1094 | ||
1095 | conf_req = dpp_build_conf_req(auth, json); | |
1096 | if (!conf_req) { | |
1097 | wpa_printf(MSG_DEBUG, | |
1098 | "DPP: No configuration request data available"); | |
1099 | return; | |
1100 | } | |
1101 | ||
1102 | buf = gas_build_initial_req(0, 10 + 2 + wpabuf_len(conf_req)); | |
1103 | if (!buf) { | |
1104 | wpabuf_free(conf_req); | |
1105 | return; | |
1106 | } | |
1107 | ||
1108 | /* Advertisement Protocol IE */ | |
1109 | wpabuf_put_u8(buf, WLAN_EID_ADV_PROTO); | |
1110 | wpabuf_put_u8(buf, 8); /* Length */ | |
1111 | wpabuf_put_u8(buf, 0x7f); | |
1112 | wpabuf_put_u8(buf, WLAN_EID_VENDOR_SPECIFIC); | |
1113 | wpabuf_put_u8(buf, 5); | |
1114 | wpabuf_put_be24(buf, OUI_WFA); | |
1115 | wpabuf_put_u8(buf, DPP_OUI_TYPE); | |
1116 | wpabuf_put_u8(buf, 0x01); | |
1117 | ||
1118 | /* GAS Query */ | |
1119 | wpabuf_put_le16(buf, wpabuf_len(conf_req)); | |
1120 | wpabuf_put_buf(buf, conf_req); | |
1121 | wpabuf_free(conf_req); | |
1122 | ||
1123 | wpa_printf(MSG_DEBUG, "DPP: GAS request to " MACSTR " (freq %u MHz)", | |
1124 | MAC2STR(auth->peer_mac_addr), auth->curr_freq); | |
1125 | ||
1126 | res = gas_query_req(wpa_s->gas, auth->peer_mac_addr, auth->curr_freq, | |
1127 | buf, wpas_dpp_gas_resp_cb, wpa_s); | |
1128 | if (res < 0) { | |
1129 | wpa_msg(wpa_s, MSG_DEBUG, "GAS: Failed to send Query Request"); | |
1130 | wpabuf_free(buf); | |
1131 | } else { | |
1132 | wpa_printf(MSG_DEBUG, | |
1133 | "DPP: GAS query started with dialog token %u", res); | |
1134 | } | |
1135 | } | |
1136 | ||
1137 | ||
1138 | static void wpas_dpp_auth_success(struct wpa_supplicant *wpa_s, int initiator) | |
1139 | { | |
1140 | wpa_printf(MSG_DEBUG, "DPP: Authentication succeeded"); | |
1141 | wpa_msg(wpa_s, MSG_INFO, DPP_EVENT_AUTH_SUCCESS "init=%d", initiator); | |
1142 | ||
1143 | if (wpa_s->dpp_auth->configurator) | |
1144 | wpas_dpp_start_gas_server(wpa_s); | |
1145 | else | |
1146 | wpas_dpp_start_gas_client(wpa_s); | |
1147 | } | |
1148 | ||
1149 | ||
30d27b04 | 1150 | static void wpas_dpp_rx_auth_resp(struct wpa_supplicant *wpa_s, const u8 *src, |
dc4d271c | 1151 | const u8 *hdr, const u8 *buf, size_t len) |
30d27b04 JM |
1152 | { |
1153 | struct dpp_authentication *auth = wpa_s->dpp_auth; | |
dc4d271c | 1154 | struct wpabuf *msg; |
30d27b04 JM |
1155 | |
1156 | wpa_printf(MSG_DEBUG, "DPP: Authentication Response from " MACSTR, | |
1157 | MAC2STR(src)); | |
1158 | ||
1159 | if (!auth) { | |
1160 | wpa_printf(MSG_DEBUG, | |
1161 | "DPP: No DPP Authentication in progress - drop"); | |
1162 | return; | |
1163 | } | |
1164 | ||
1165 | if (!is_zero_ether_addr(auth->peer_mac_addr) && | |
1166 | os_memcmp(src, auth->peer_mac_addr, ETH_ALEN) != 0) { | |
1167 | wpa_printf(MSG_DEBUG, "DPP: MAC address mismatch (expected " | |
1168 | MACSTR ") - drop", MAC2STR(auth->peer_mac_addr)); | |
1169 | return; | |
1170 | } | |
1171 | ||
1172 | eloop_cancel_timeout(wpas_dpp_reply_wait_timeout, wpa_s, NULL); | |
1173 | ||
dc4d271c JM |
1174 | msg = dpp_auth_resp_rx(auth, hdr, buf, len); |
1175 | if (!msg) { | |
30d27b04 JM |
1176 | if (auth->auth_resp_status == DPP_STATUS_RESPONSE_PENDING) { |
1177 | wpa_printf(MSG_DEBUG, | |
1178 | "DPP: Start wait for full response"); | |
1179 | offchannel_send_action_done(wpa_s); | |
1180 | wpas_dpp_listen_start(wpa_s, auth->curr_freq); | |
1181 | return; | |
1182 | } | |
1183 | wpa_printf(MSG_DEBUG, "DPP: No confirm generated"); | |
1184 | return; | |
1185 | } | |
1186 | os_memcpy(auth->peer_mac_addr, src, ETH_ALEN); | |
1187 | ||
30d27b04 JM |
1188 | offchannel_send_action(wpa_s, auth->curr_freq, |
1189 | src, wpa_s->own_addr, broadcast, | |
1190 | wpabuf_head(msg), wpabuf_len(msg), | |
1191 | 500, wpas_dpp_tx_status, 0); | |
1192 | wpabuf_free(msg); | |
461d39af | 1193 | wpa_s->dpp_auth_ok_on_ack = 1; |
30d27b04 JM |
1194 | } |
1195 | ||
1196 | ||
1197 | static void wpas_dpp_rx_auth_conf(struct wpa_supplicant *wpa_s, const u8 *src, | |
dc4d271c | 1198 | const u8 *hdr, const u8 *buf, size_t len) |
30d27b04 JM |
1199 | { |
1200 | struct dpp_authentication *auth = wpa_s->dpp_auth; | |
1201 | ||
1202 | wpa_printf(MSG_DEBUG, "DPP: Authentication Confirmation from " MACSTR, | |
1203 | MAC2STR(src)); | |
1204 | ||
1205 | if (!auth) { | |
1206 | wpa_printf(MSG_DEBUG, | |
1207 | "DPP: No DPP Authentication in progress - drop"); | |
1208 | return; | |
1209 | } | |
1210 | ||
1211 | if (os_memcmp(src, auth->peer_mac_addr, ETH_ALEN) != 0) { | |
1212 | wpa_printf(MSG_DEBUG, "DPP: MAC address mismatch (expected " | |
1213 | MACSTR ") - drop", MAC2STR(auth->peer_mac_addr)); | |
1214 | return; | |
1215 | } | |
1216 | ||
dc4d271c | 1217 | if (dpp_auth_conf_rx(auth, hdr, buf, len) < 0) { |
30d27b04 JM |
1218 | wpa_printf(MSG_DEBUG, "DPP: Authentication failed"); |
1219 | return; | |
1220 | } | |
1221 | ||
461d39af | 1222 | wpas_dpp_auth_success(wpa_s, 0); |
30d27b04 JM |
1223 | } |
1224 | ||
1225 | ||
a0d5c56f JM |
1226 | static void wpas_dpp_rx_peer_disc_resp(struct wpa_supplicant *wpa_s, |
1227 | const u8 *src, | |
1228 | const u8 *buf, size_t len) | |
1229 | { | |
1230 | struct wpa_ssid *ssid; | |
85fd8263 JM |
1231 | const u8 *connector, *trans_id; |
1232 | u16 connector_len, trans_id_len; | |
a0d5c56f JM |
1233 | struct dpp_introduction intro; |
1234 | struct rsn_pmksa_cache_entry *entry; | |
787615b3 JM |
1235 | struct os_time now; |
1236 | struct os_reltime rnow; | |
1237 | os_time_t expiry; | |
1238 | unsigned int seconds; | |
a0d5c56f JM |
1239 | |
1240 | wpa_printf(MSG_DEBUG, "DPP: Peer Discovery Response from " MACSTR, | |
1241 | MAC2STR(src)); | |
1242 | if (is_zero_ether_addr(wpa_s->dpp_intro_bssid) || | |
1243 | os_memcmp(src, wpa_s->dpp_intro_bssid, ETH_ALEN) != 0) { | |
1244 | wpa_printf(MSG_DEBUG, "DPP: Not waiting for response from " | |
1245 | MACSTR " - drop", MAC2STR(src)); | |
1246 | return; | |
1247 | } | |
1248 | offchannel_send_action_done(wpa_s); | |
1249 | ||
1250 | for (ssid = wpa_s->conf->ssid; ssid; ssid = ssid->next) { | |
1251 | if (ssid == wpa_s->dpp_intro_network) | |
1252 | break; | |
1253 | } | |
1254 | if (!ssid || !ssid->dpp_connector || !ssid->dpp_netaccesskey || | |
1255 | !ssid->dpp_csign) { | |
1256 | wpa_printf(MSG_DEBUG, | |
1257 | "DPP: Profile not found for network introduction"); | |
1258 | return; | |
1259 | } | |
1260 | ||
85fd8263 JM |
1261 | trans_id = dpp_get_attr(buf, len, DPP_ATTR_TRANSACTION_ID, |
1262 | &trans_id_len); | |
1263 | if (!trans_id || trans_id_len != 1) { | |
1264 | wpa_printf(MSG_DEBUG, | |
1265 | "DPP: Peer did not include Transaction ID"); | |
1266 | goto fail; | |
1267 | } | |
1268 | if (trans_id[0] != TRANSACTION_ID) { | |
1269 | wpa_printf(MSG_DEBUG, | |
1270 | "DPP: Ignore frame with unexpected Transaction ID %u", | |
1271 | trans_id[0]); | |
1272 | goto fail; | |
1273 | } | |
1274 | ||
a0d5c56f JM |
1275 | connector = dpp_get_attr(buf, len, DPP_ATTR_CONNECTOR, &connector_len); |
1276 | if (!connector) { | |
1277 | wpa_printf(MSG_DEBUG, | |
1278 | "DPP: Peer did not include its Connector"); | |
1279 | return; | |
1280 | } | |
1281 | ||
1282 | if (dpp_peer_intro(&intro, ssid->dpp_connector, | |
1283 | ssid->dpp_netaccesskey, | |
1284 | ssid->dpp_netaccesskey_len, | |
1285 | ssid->dpp_csign, | |
1286 | ssid->dpp_csign_len, | |
787615b3 | 1287 | connector, connector_len, &expiry) < 0) { |
a0d5c56f JM |
1288 | wpa_printf(MSG_INFO, |
1289 | "DPP: Network Introduction protocol resulted in failure"); | |
1290 | goto fail; | |
1291 | } | |
1292 | ||
a0d5c56f JM |
1293 | entry = os_zalloc(sizeof(*entry)); |
1294 | if (!entry) | |
1295 | goto fail; | |
1296 | os_memcpy(entry->aa, src, ETH_ALEN); | |
1297 | os_memcpy(entry->pmkid, intro.pmkid, PMKID_LEN); | |
1298 | os_memcpy(entry->pmk, intro.pmk, intro.pmk_len); | |
1299 | entry->pmk_len = intro.pmk_len; | |
1300 | entry->akmp = WPA_KEY_MGMT_DPP; | |
787615b3 JM |
1301 | if (expiry) { |
1302 | os_get_time(&now); | |
1303 | seconds = expiry - now.sec; | |
1304 | } else { | |
1305 | seconds = 86400 * 7; | |
1306 | } | |
1307 | os_get_reltime(&rnow); | |
1308 | entry->expiration = rnow.sec + seconds; | |
1309 | entry->reauth_time = rnow.sec + seconds; | |
a0d5c56f JM |
1310 | entry->network_ctx = ssid; |
1311 | wpa_sm_pmksa_cache_add_entry(wpa_s->wpa, entry); | |
1312 | ||
1313 | wpa_printf(MSG_DEBUG, | |
1314 | "DPP: Try connection again after successful network introduction"); | |
1315 | if (wpa_supplicant_fast_associate(wpa_s) != 1) { | |
1316 | wpa_supplicant_cancel_sched_scan(wpa_s); | |
1317 | wpa_supplicant_req_scan(wpa_s, 0, 0); | |
1318 | } | |
1319 | fail: | |
1320 | os_memset(&intro, 0, sizeof(intro)); | |
1321 | } | |
1322 | ||
1323 | ||
500ed7f0 JM |
1324 | static void |
1325 | wpas_dpp_tx_pkex_status(struct wpa_supplicant *wpa_s, | |
1326 | unsigned int freq, const u8 *dst, | |
1327 | const u8 *src, const u8 *bssid, | |
1328 | const u8 *data, size_t data_len, | |
1329 | enum offchannel_send_action_result result) | |
1330 | { | |
1331 | wpa_printf(MSG_DEBUG, "DPP: TX status: freq=%u dst=" MACSTR | |
1332 | " result=%s (PKEX)", | |
1333 | freq, MAC2STR(dst), | |
1334 | result == OFFCHANNEL_SEND_ACTION_SUCCESS ? "SUCCESS" : | |
1335 | (result == OFFCHANNEL_SEND_ACTION_NO_ACK ? "no-ACK" : | |
1336 | "FAILED")); | |
1337 | /* TODO: Time out wait for response more quickly in error cases? */ | |
1338 | } | |
1339 | ||
1340 | ||
1341 | static void | |
1342 | wpas_dpp_rx_pkex_exchange_req(struct wpa_supplicant *wpa_s, const u8 *src, | |
1343 | const u8 *buf, size_t len, unsigned int freq) | |
1344 | { | |
1345 | struct wpabuf *msg; | |
1346 | unsigned int wait_time; | |
1347 | ||
1348 | wpa_printf(MSG_DEBUG, "DPP: PKEX Exchange Request from " MACSTR, | |
1349 | MAC2STR(src)); | |
1350 | ||
1351 | /* TODO: Support multiple PKEX codes by iterating over all the enabled | |
1352 | * values here */ | |
1353 | ||
1354 | if (!wpa_s->dpp_pkex_code || !wpa_s->dpp_pkex_bi) { | |
1355 | wpa_printf(MSG_DEBUG, | |
1356 | "DPP: No PKEX code configured - ignore request"); | |
1357 | return; | |
1358 | } | |
1359 | ||
1360 | if (wpa_s->dpp_pkex) { | |
1361 | /* TODO: Support parallel operations */ | |
1362 | wpa_printf(MSG_DEBUG, | |
1363 | "DPP: Already in PKEX session - ignore new request"); | |
1364 | return; | |
1365 | } | |
1366 | ||
1367 | wpa_s->dpp_pkex = dpp_pkex_rx_exchange_req(wpa_s->dpp_pkex_bi, | |
1368 | wpa_s->own_addr, src, | |
1369 | wpa_s->dpp_pkex_identifier, | |
1370 | wpa_s->dpp_pkex_code, | |
1371 | buf, len); | |
1372 | if (!wpa_s->dpp_pkex) { | |
1373 | wpa_printf(MSG_DEBUG, | |
1374 | "DPP: Failed to process the request - ignore it"); | |
1375 | return; | |
1376 | } | |
1377 | ||
1378 | msg = wpa_s->dpp_pkex->exchange_resp; | |
1379 | wait_time = wpa_s->max_remain_on_chan; | |
1380 | if (wait_time > 2000) | |
1381 | wait_time = 2000; | |
1382 | offchannel_send_action(wpa_s, freq, src, wpa_s->own_addr, | |
1383 | broadcast, | |
1384 | wpabuf_head(msg), wpabuf_len(msg), | |
1385 | wait_time, wpas_dpp_tx_pkex_status, 0); | |
1386 | } | |
1387 | ||
1388 | ||
1389 | static void | |
1390 | wpas_dpp_rx_pkex_exchange_resp(struct wpa_supplicant *wpa_s, const u8 *src, | |
1391 | const u8 *buf, size_t len, unsigned int freq) | |
1392 | { | |
1393 | struct wpabuf *msg; | |
1394 | unsigned int wait_time; | |
1395 | ||
1396 | wpa_printf(MSG_DEBUG, "DPP: PKEX Exchange Response from " MACSTR, | |
1397 | MAC2STR(src)); | |
1398 | ||
1399 | /* TODO: Support multiple PKEX codes by iterating over all the enabled | |
1400 | * values here */ | |
1401 | ||
1402 | if (!wpa_s->dpp_pkex || !wpa_s->dpp_pkex->initiator || | |
1403 | wpa_s->dpp_pkex->exchange_done) { | |
1404 | wpa_printf(MSG_DEBUG, "DPP: No matching PKEX session"); | |
1405 | return; | |
1406 | } | |
1407 | ||
1408 | os_memcpy(wpa_s->dpp_pkex->peer_mac, src, ETH_ALEN); | |
1409 | msg = dpp_pkex_rx_exchange_resp(wpa_s->dpp_pkex, buf, len); | |
1410 | if (!msg) { | |
1411 | wpa_printf(MSG_DEBUG, "DPP: Failed to process the response"); | |
1412 | return; | |
1413 | } | |
1414 | ||
1415 | wpa_printf(MSG_DEBUG, "DPP: Send PKEX Commit-Reveal Request to " MACSTR, | |
1416 | MAC2STR(src)); | |
1417 | ||
1418 | wait_time = wpa_s->max_remain_on_chan; | |
1419 | if (wait_time > 2000) | |
1420 | wait_time = 2000; | |
1421 | offchannel_send_action(wpa_s, freq, src, wpa_s->own_addr, | |
1422 | broadcast, | |
1423 | wpabuf_head(msg), wpabuf_len(msg), | |
1424 | wait_time, wpas_dpp_tx_pkex_status, 0); | |
1425 | wpabuf_free(msg); | |
1426 | } | |
1427 | ||
1428 | ||
1429 | static void | |
1430 | wpas_dpp_rx_pkex_commit_reveal_req(struct wpa_supplicant *wpa_s, const u8 *src, | |
4be5bc98 JM |
1431 | const u8 *hdr, const u8 *buf, size_t len, |
1432 | unsigned int freq) | |
500ed7f0 JM |
1433 | { |
1434 | struct wpabuf *msg; | |
1435 | unsigned int wait_time; | |
1436 | struct dpp_pkex *pkex = wpa_s->dpp_pkex; | |
1437 | struct dpp_bootstrap_info *bi; | |
1438 | ||
1439 | wpa_printf(MSG_DEBUG, "DPP: PKEX Commit-Reveal Request from " MACSTR, | |
1440 | MAC2STR(src)); | |
1441 | ||
1442 | if (!pkex || pkex->initiator || !pkex->exchange_done) { | |
1443 | wpa_printf(MSG_DEBUG, "DPP: No matching PKEX session"); | |
1444 | return; | |
1445 | } | |
1446 | ||
4be5bc98 | 1447 | msg = dpp_pkex_rx_commit_reveal_req(pkex, hdr, buf, len); |
500ed7f0 JM |
1448 | if (!msg) { |
1449 | wpa_printf(MSG_DEBUG, "DPP: Failed to process the request"); | |
1450 | return; | |
1451 | } | |
1452 | ||
1453 | wpa_printf(MSG_DEBUG, "DPP: Send PKEX Commit-Reveal Response to " | |
1454 | MACSTR, MAC2STR(src)); | |
1455 | ||
1456 | wait_time = wpa_s->max_remain_on_chan; | |
1457 | if (wait_time > 2000) | |
1458 | wait_time = 2000; | |
1459 | offchannel_send_action(wpa_s, freq, src, wpa_s->own_addr, | |
1460 | broadcast, | |
1461 | wpabuf_head(msg), wpabuf_len(msg), | |
1462 | wait_time, wpas_dpp_tx_pkex_status, 0); | |
1463 | wpabuf_free(msg); | |
1464 | ||
1465 | bi = os_zalloc(sizeof(*bi)); | |
1466 | if (!bi) | |
1467 | return; | |
1468 | bi->id = wpas_dpp_next_id(wpa_s); | |
1469 | bi->type = DPP_BOOTSTRAP_PKEX; | |
1470 | os_memcpy(bi->mac_addr, src, ETH_ALEN); | |
1471 | bi->num_freq = 1; | |
1472 | bi->freq[0] = freq; | |
1473 | bi->curve = pkex->own_bi->curve; | |
1474 | bi->pubkey = pkex->peer_bootstrap_key; | |
1475 | pkex->peer_bootstrap_key = NULL; | |
1476 | dpp_pkex_free(pkex); | |
1477 | wpa_s->dpp_pkex = NULL; | |
1478 | if (dpp_bootstrap_key_hash(bi) < 0) { | |
1479 | dpp_bootstrap_info_free(bi); | |
1480 | return; | |
1481 | } | |
1482 | dl_list_add(&wpa_s->dpp_bootstrap, &bi->list); | |
1483 | } | |
1484 | ||
1485 | ||
1486 | static void | |
1487 | wpas_dpp_rx_pkex_commit_reveal_resp(struct wpa_supplicant *wpa_s, const u8 *src, | |
4be5bc98 | 1488 | const u8 *hdr, const u8 *buf, size_t len, |
500ed7f0 JM |
1489 | unsigned int freq) |
1490 | { | |
1491 | int res; | |
1492 | struct dpp_bootstrap_info *bi, *own_bi; | |
1493 | struct dpp_pkex *pkex = wpa_s->dpp_pkex; | |
1494 | char cmd[500]; | |
1495 | ||
1496 | wpa_printf(MSG_DEBUG, "DPP: PKEX Commit-Reveal Response from " MACSTR, | |
1497 | MAC2STR(src)); | |
1498 | ||
1499 | if (!pkex || !pkex->initiator || !pkex->exchange_done) { | |
1500 | wpa_printf(MSG_DEBUG, "DPP: No matching PKEX session"); | |
1501 | return; | |
1502 | } | |
1503 | ||
4be5bc98 | 1504 | res = dpp_pkex_rx_commit_reveal_resp(pkex, hdr, buf, len); |
500ed7f0 JM |
1505 | if (res < 0) { |
1506 | wpa_printf(MSG_DEBUG, "DPP: Failed to process the response"); | |
1507 | return; | |
1508 | } | |
1509 | ||
1510 | own_bi = pkex->own_bi; | |
1511 | ||
1512 | bi = os_zalloc(sizeof(*bi)); | |
1513 | if (!bi) | |
1514 | return; | |
1515 | bi->id = wpas_dpp_next_id(wpa_s); | |
1516 | bi->type = DPP_BOOTSTRAP_PKEX; | |
1517 | os_memcpy(bi->mac_addr, src, ETH_ALEN); | |
1518 | bi->num_freq = 1; | |
1519 | bi->freq[0] = freq; | |
1520 | bi->curve = own_bi->curve; | |
1521 | bi->pubkey = pkex->peer_bootstrap_key; | |
1522 | pkex->peer_bootstrap_key = NULL; | |
1523 | dpp_pkex_free(pkex); | |
1524 | wpa_s->dpp_pkex = NULL; | |
1525 | if (dpp_bootstrap_key_hash(bi) < 0) { | |
1526 | dpp_bootstrap_info_free(bi); | |
1527 | return; | |
1528 | } | |
1529 | dl_list_add(&wpa_s->dpp_bootstrap, &bi->list); | |
1530 | ||
1531 | os_snprintf(cmd, sizeof(cmd), " peer=%u %s", | |
1532 | bi->id, | |
1533 | wpa_s->dpp_pkex_auth_cmd ? wpa_s->dpp_pkex_auth_cmd : ""); | |
1534 | wpa_printf(MSG_DEBUG, | |
1535 | "DPP: Start authentication after PKEX with parameters: %s", | |
1536 | cmd); | |
1537 | if (wpas_dpp_auth_init(wpa_s, cmd) < 0) { | |
1538 | wpa_printf(MSG_DEBUG, | |
1539 | "DPP: Authentication initialization failed"); | |
1540 | return; | |
1541 | } | |
1542 | } | |
1543 | ||
1544 | ||
30d27b04 JM |
1545 | void wpas_dpp_rx_action(struct wpa_supplicant *wpa_s, const u8 *src, |
1546 | const u8 *buf, size_t len, unsigned int freq) | |
1547 | { | |
8c19ea3f | 1548 | u8 crypto_suite; |
30d27b04 | 1549 | enum dpp_public_action_frame_type type; |
dc4d271c | 1550 | const u8 *hdr; |
30d27b04 | 1551 | |
dc4d271c JM |
1552 | if (len < DPP_HDR_LEN) |
1553 | return; | |
1554 | if (WPA_GET_BE24(buf) != OUI_WFA || buf[3] != DPP_OUI_TYPE) | |
30d27b04 | 1555 | return; |
dc4d271c JM |
1556 | hdr = buf; |
1557 | buf += 4; | |
1558 | len -= 4; | |
8c19ea3f JM |
1559 | crypto_suite = *buf++; |
1560 | type = *buf++; | |
1561 | len -= 2; | |
30d27b04 JM |
1562 | |
1563 | wpa_printf(MSG_DEBUG, | |
8c19ea3f | 1564 | "DPP: Received DPP Public Action frame crypto suite %u type %d from " |
30d27b04 | 1565 | MACSTR " freq=%u", |
8c19ea3f JM |
1566 | crypto_suite, type, MAC2STR(src), freq); |
1567 | if (crypto_suite != 1) { | |
1568 | wpa_printf(MSG_DEBUG, "DPP: Unsupported crypto suite %u", | |
1569 | crypto_suite); | |
1570 | return; | |
1571 | } | |
30d27b04 JM |
1572 | wpa_hexdump(MSG_MSGDUMP, "DPP: Received message attributes", buf, len); |
1573 | if (dpp_check_attrs(buf, len) < 0) | |
1574 | return; | |
1575 | ||
1576 | switch (type) { | |
1577 | case DPP_PA_AUTHENTICATION_REQ: | |
dc4d271c | 1578 | wpas_dpp_rx_auth_req(wpa_s, src, hdr, buf, len, freq); |
30d27b04 JM |
1579 | break; |
1580 | case DPP_PA_AUTHENTICATION_RESP: | |
dc4d271c | 1581 | wpas_dpp_rx_auth_resp(wpa_s, src, hdr, buf, len); |
30d27b04 JM |
1582 | break; |
1583 | case DPP_PA_AUTHENTICATION_CONF: | |
dc4d271c | 1584 | wpas_dpp_rx_auth_conf(wpa_s, src, hdr, buf, len); |
30d27b04 | 1585 | break; |
a0d5c56f JM |
1586 | case DPP_PA_PEER_DISCOVERY_RESP: |
1587 | wpas_dpp_rx_peer_disc_resp(wpa_s, src, buf, len); | |
1588 | break; | |
500ed7f0 JM |
1589 | case DPP_PA_PKEX_EXCHANGE_REQ: |
1590 | wpas_dpp_rx_pkex_exchange_req(wpa_s, src, buf, len, freq); | |
1591 | break; | |
1592 | case DPP_PA_PKEX_EXCHANGE_RESP: | |
1593 | wpas_dpp_rx_pkex_exchange_resp(wpa_s, src, buf, len, freq); | |
1594 | break; | |
1595 | case DPP_PA_PKEX_COMMIT_REVEAL_REQ: | |
4be5bc98 JM |
1596 | wpas_dpp_rx_pkex_commit_reveal_req(wpa_s, src, hdr, buf, len, |
1597 | freq); | |
500ed7f0 JM |
1598 | break; |
1599 | case DPP_PA_PKEX_COMMIT_REVEAL_RESP: | |
4be5bc98 JM |
1600 | wpas_dpp_rx_pkex_commit_reveal_resp(wpa_s, src, hdr, buf, len, |
1601 | freq); | |
500ed7f0 | 1602 | break; |
30d27b04 JM |
1603 | default: |
1604 | wpa_printf(MSG_DEBUG, | |
1605 | "DPP: Ignored unsupported frame subtype %d", type); | |
1606 | break; | |
1607 | } | |
1608 | } | |
1609 | ||
1610 | ||
461d39af JM |
1611 | static struct wpabuf * |
1612 | wpas_dpp_gas_req_handler(void *ctx, const u8 *sa, const u8 *query, | |
1613 | size_t query_len) | |
1614 | { | |
1615 | struct wpa_supplicant *wpa_s = ctx; | |
1616 | struct dpp_authentication *auth = wpa_s->dpp_auth; | |
1617 | struct wpabuf *resp; | |
1618 | ||
1619 | wpa_printf(MSG_DEBUG, "DPP: GAS request from " MACSTR, | |
1620 | MAC2STR(sa)); | |
1621 | if (!auth || !auth->auth_success || | |
1622 | os_memcmp(sa, auth->peer_mac_addr, ETH_ALEN) != 0) { | |
1623 | wpa_printf(MSG_DEBUG, "DPP: No matching exchange in progress"); | |
1624 | return NULL; | |
1625 | } | |
1626 | wpa_hexdump(MSG_DEBUG, | |
1627 | "DPP: Received Configuration Request (GAS Query Request)", | |
1628 | query, query_len); | |
1629 | resp = dpp_conf_req_rx(auth, query, query_len); | |
1630 | if (!resp) | |
1631 | wpa_msg(wpa_s, MSG_INFO, DPP_EVENT_CONF_FAILED); | |
1632 | return resp; | |
1633 | } | |
1634 | ||
1635 | ||
1636 | static void | |
1637 | wpas_dpp_gas_status_handler(void *ctx, struct wpabuf *resp, int ok) | |
1638 | { | |
1639 | struct wpa_supplicant *wpa_s = ctx; | |
1640 | struct dpp_authentication *auth = wpa_s->dpp_auth; | |
1641 | ||
1642 | if (!auth) { | |
1643 | wpabuf_free(resp); | |
1644 | return; | |
1645 | } | |
1646 | ||
1647 | wpa_printf(MSG_DEBUG, "DPP: Configuration exchange completed (ok=%d)", | |
1648 | ok); | |
1649 | eloop_cancel_timeout(wpas_dpp_reply_wait_timeout, wpa_s, NULL); | |
1650 | offchannel_send_action_done(wpa_s); | |
1651 | wpas_dpp_listen_stop(wpa_s); | |
1652 | if (ok) | |
1653 | wpa_msg(wpa_s, MSG_INFO, DPP_EVENT_CONF_SENT); | |
1654 | else | |
1655 | wpa_msg(wpa_s, MSG_INFO, DPP_EVENT_CONF_FAILED); | |
1656 | dpp_auth_deinit(wpa_s->dpp_auth); | |
1657 | wpa_s->dpp_auth = NULL; | |
1658 | wpabuf_free(resp); | |
1659 | } | |
1660 | ||
1661 | ||
1662 | static unsigned int wpas_dpp_next_configurator_id(struct wpa_supplicant *wpa_s) | |
1663 | { | |
1664 | struct dpp_configurator *conf; | |
1665 | unsigned int max_id = 0; | |
1666 | ||
1667 | dl_list_for_each(conf, &wpa_s->dpp_configurator, | |
1668 | struct dpp_configurator, list) { | |
1669 | if (conf->id > max_id) | |
1670 | max_id = conf->id; | |
1671 | } | |
1672 | return max_id + 1; | |
1673 | } | |
1674 | ||
1675 | ||
1676 | int wpas_dpp_configurator_add(struct wpa_supplicant *wpa_s, const char *cmd) | |
1677 | { | |
c77e2ff0 | 1678 | char *curve = NULL; |
461d39af JM |
1679 | char *key = NULL; |
1680 | u8 *privkey = NULL; | |
1681 | size_t privkey_len = 0; | |
1682 | int ret = -1; | |
1683 | struct dpp_configurator *conf = NULL; | |
1684 | ||
461d39af JM |
1685 | curve = get_param(cmd, " curve="); |
1686 | key = get_param(cmd, " key="); | |
1687 | ||
1688 | if (key) { | |
1689 | privkey_len = os_strlen(key) / 2; | |
1690 | privkey = os_malloc(privkey_len); | |
1691 | if (!privkey || | |
1692 | hexstr2bin(key, privkey, privkey_len) < 0) | |
1693 | goto fail; | |
1694 | } | |
1695 | ||
1696 | conf = dpp_keygen_configurator(curve, privkey, privkey_len); | |
1697 | if (!conf) | |
1698 | goto fail; | |
1699 | ||
461d39af JM |
1700 | conf->id = wpas_dpp_next_configurator_id(wpa_s); |
1701 | dl_list_add(&wpa_s->dpp_configurator, &conf->list); | |
1702 | ret = conf->id; | |
1703 | conf = NULL; | |
1704 | fail: | |
1705 | os_free(curve); | |
461d39af JM |
1706 | str_clear_free(key); |
1707 | bin_clear_free(privkey, privkey_len); | |
1708 | dpp_configurator_free(conf); | |
1709 | return ret; | |
1710 | } | |
1711 | ||
1712 | ||
1713 | static int dpp_configurator_del(struct wpa_supplicant *wpa_s, unsigned int id) | |
1714 | { | |
1715 | struct dpp_configurator *conf, *tmp; | |
1716 | int found = 0; | |
1717 | ||
1718 | dl_list_for_each_safe(conf, tmp, &wpa_s->dpp_configurator, | |
1719 | struct dpp_configurator, list) { | |
1720 | if (id && conf->id != id) | |
1721 | continue; | |
1722 | found = 1; | |
1723 | dl_list_del(&conf->list); | |
1724 | dpp_configurator_free(conf); | |
1725 | } | |
1726 | ||
1727 | if (id == 0) | |
1728 | return 0; /* flush succeeds regardless of entries found */ | |
1729 | return found ? 0 : -1; | |
1730 | } | |
1731 | ||
1732 | ||
1733 | int wpas_dpp_configurator_remove(struct wpa_supplicant *wpa_s, const char *id) | |
1734 | { | |
1735 | unsigned int id_val; | |
1736 | ||
1737 | if (os_strcmp(id, "*") == 0) { | |
1738 | id_val = 0; | |
1739 | } else { | |
1740 | id_val = atoi(id); | |
1741 | if (id_val == 0) | |
1742 | return -1; | |
1743 | } | |
1744 | ||
1745 | return dpp_configurator_del(wpa_s, id_val); | |
1746 | } | |
1747 | ||
1748 | ||
f522bb23 JM |
1749 | int wpas_dpp_configurator_sign(struct wpa_supplicant *wpa_s, const char *cmd) |
1750 | { | |
1751 | struct dpp_authentication *auth; | |
1752 | int ret = -1; | |
1753 | char *curve = NULL; | |
1754 | ||
1755 | auth = os_zalloc(sizeof(*auth)); | |
1756 | if (!auth) | |
1757 | return -1; | |
1758 | ||
1759 | curve = get_param(cmd, " curve="); | |
1760 | wpas_dpp_set_configurator(wpa_s, auth, cmd); | |
1761 | ||
1762 | if (dpp_configurator_own_config(auth, curve) == 0) { | |
1763 | wpas_dpp_handle_config_obj(wpa_s, auth); | |
1764 | ret = 0; | |
1765 | } | |
1766 | ||
1767 | dpp_auth_deinit(auth); | |
1768 | os_free(curve); | |
1769 | ||
1770 | return ret; | |
1771 | } | |
1772 | ||
1773 | ||
a0d5c56f JM |
1774 | static void |
1775 | wpas_dpp_tx_introduction_status(struct wpa_supplicant *wpa_s, | |
1776 | unsigned int freq, const u8 *dst, | |
1777 | const u8 *src, const u8 *bssid, | |
1778 | const u8 *data, size_t data_len, | |
1779 | enum offchannel_send_action_result result) | |
1780 | { | |
1781 | wpa_printf(MSG_DEBUG, "DPP: TX status: freq=%u dst=" MACSTR | |
1782 | " result=%s (DPP Peer Discovery Request)", | |
1783 | freq, MAC2STR(dst), | |
1784 | result == OFFCHANNEL_SEND_ACTION_SUCCESS ? "SUCCESS" : | |
1785 | (result == OFFCHANNEL_SEND_ACTION_NO_ACK ? "no-ACK" : | |
1786 | "FAILED")); | |
1787 | /* TODO: Time out wait for response more quickly in error cases? */ | |
1788 | } | |
1789 | ||
1790 | ||
1791 | int wpas_dpp_check_connect(struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid, | |
1792 | struct wpa_bss *bss) | |
1793 | { | |
1794 | struct os_time now; | |
1795 | struct wpabuf *msg; | |
1796 | unsigned int wait_time; | |
1797 | ||
1798 | if (!(ssid->key_mgmt & WPA_KEY_MGMT_DPP) || !bss) | |
1799 | return 0; /* Not using DPP AKM - continue */ | |
1800 | if (wpa_sm_pmksa_exists(wpa_s->wpa, bss->bssid, ssid)) | |
1801 | return 0; /* PMKSA exists for DPP AKM - continue */ | |
1802 | ||
1803 | if (!ssid->dpp_connector || !ssid->dpp_netaccesskey || | |
1804 | !ssid->dpp_csign) { | |
1805 | wpa_msg(wpa_s, MSG_INFO, DPP_EVENT_MISSING_CONNECTOR | |
1806 | "missing %s", | |
1807 | !ssid->dpp_connector ? "Connector" : | |
1808 | (!ssid->dpp_netaccesskey ? "netAccessKey" : | |
1809 | "C-sign-key")); | |
1810 | return -1; | |
1811 | } | |
1812 | ||
1813 | os_get_time(&now); | |
1814 | ||
a0d5c56f JM |
1815 | if (ssid->dpp_netaccesskey_expiry && |
1816 | ssid->dpp_netaccesskey_expiry < now.sec) { | |
1817 | wpa_msg(wpa_s, MSG_INFO, DPP_EVENT_MISSING_CONNECTOR | |
1818 | "netAccessKey expired"); | |
1819 | return -1; | |
1820 | } | |
1821 | ||
1822 | wpa_printf(MSG_DEBUG, | |
1823 | "DPP: Starting network introduction protocol to derive PMKSA for " | |
1824 | MACSTR, MAC2STR(bss->bssid)); | |
1825 | ||
1826 | msg = dpp_alloc_msg(DPP_PA_PEER_DISCOVERY_REQ, | |
85fd8263 | 1827 | 5 + 4 + os_strlen(ssid->dpp_connector)); |
a0d5c56f JM |
1828 | if (!msg) |
1829 | return -1; | |
1830 | ||
85fd8263 JM |
1831 | /* Transaction ID */ |
1832 | wpabuf_put_le16(msg, DPP_ATTR_TRANSACTION_ID); | |
1833 | wpabuf_put_le16(msg, 1); | |
1834 | wpabuf_put_u8(msg, TRANSACTION_ID); | |
1835 | ||
a0d5c56f JM |
1836 | /* DPP Connector */ |
1837 | wpabuf_put_le16(msg, DPP_ATTR_CONNECTOR); | |
1838 | wpabuf_put_le16(msg, os_strlen(ssid->dpp_connector)); | |
1839 | wpabuf_put_str(msg, ssid->dpp_connector); | |
1840 | ||
1841 | /* TODO: Timeout on AP response */ | |
1842 | wait_time = wpa_s->max_remain_on_chan; | |
1843 | if (wait_time > 2000) | |
1844 | wait_time = 2000; | |
1845 | offchannel_send_action(wpa_s, bss->freq, bss->bssid, wpa_s->own_addr, | |
1846 | broadcast, | |
1847 | wpabuf_head(msg), wpabuf_len(msg), | |
1848 | wait_time, wpas_dpp_tx_introduction_status, 0); | |
1849 | wpabuf_free(msg); | |
1850 | ||
1851 | /* Request this connection attempt to terminate - new one will be | |
1852 | * started when network introduction protocol completes */ | |
1853 | os_memcpy(wpa_s->dpp_intro_bssid, bss->bssid, ETH_ALEN); | |
1854 | wpa_s->dpp_intro_network = ssid; | |
1855 | return 1; | |
1856 | } | |
1857 | ||
1858 | ||
500ed7f0 JM |
1859 | int wpas_dpp_pkex_add(struct wpa_supplicant *wpa_s, const char *cmd) |
1860 | { | |
1861 | struct dpp_bootstrap_info *own_bi; | |
1862 | const char *pos, *end; | |
1863 | unsigned int wait_time; | |
1864 | ||
1865 | pos = os_strstr(cmd, " own="); | |
1866 | if (!pos) | |
1867 | return -1; | |
1868 | pos += 5; | |
1869 | own_bi = dpp_bootstrap_get_id(wpa_s, atoi(pos)); | |
1870 | if (!own_bi) { | |
1871 | wpa_printf(MSG_DEBUG, | |
1872 | "DPP: Identified bootstrap info not found"); | |
1873 | return -1; | |
1874 | } | |
1875 | if (own_bi->type != DPP_BOOTSTRAP_PKEX) { | |
1876 | wpa_printf(MSG_DEBUG, | |
1877 | "DPP: Identified bootstrap info not for PKEX"); | |
1878 | return -1; | |
1879 | } | |
1880 | wpa_s->dpp_pkex_bi = own_bi; | |
1881 | ||
1882 | os_free(wpa_s->dpp_pkex_identifier); | |
1883 | wpa_s->dpp_pkex_identifier = NULL; | |
1884 | pos = os_strstr(cmd, " identifier="); | |
1885 | if (pos) { | |
1886 | pos += 12; | |
1887 | end = os_strchr(pos, ' '); | |
1888 | if (!end) | |
1889 | return -1; | |
1890 | wpa_s->dpp_pkex_identifier = os_malloc(end - pos + 1); | |
1891 | if (!wpa_s->dpp_pkex_identifier) | |
1892 | return -1; | |
1893 | os_memcpy(wpa_s->dpp_pkex_identifier, pos, end - pos); | |
1894 | wpa_s->dpp_pkex_identifier[end - pos] = '\0'; | |
1895 | } | |
1896 | ||
1897 | pos = os_strstr(cmd, " code="); | |
1898 | if (!pos) | |
1899 | return -1; | |
1900 | os_free(wpa_s->dpp_pkex_code); | |
1901 | wpa_s->dpp_pkex_code = os_strdup(pos + 6); | |
1902 | if (!wpa_s->dpp_pkex_code) | |
1903 | return -1; | |
1904 | ||
1905 | if (os_strstr(cmd, " init=1")) { | |
1906 | struct wpabuf *msg; | |
1907 | ||
1908 | wpa_printf(MSG_DEBUG, "DPP: Initiating PKEX"); | |
1909 | dpp_pkex_free(wpa_s->dpp_pkex); | |
1910 | wpa_s->dpp_pkex = dpp_pkex_init(own_bi, wpa_s->own_addr, | |
1911 | wpa_s->dpp_pkex_identifier, | |
1912 | wpa_s->dpp_pkex_code); | |
1913 | if (!wpa_s->dpp_pkex) | |
1914 | return -1; | |
1915 | ||
1916 | msg = wpa_s->dpp_pkex->exchange_req; | |
1917 | wait_time = wpa_s->max_remain_on_chan; | |
1918 | if (wait_time > 2000) | |
1919 | wait_time = 2000; | |
1920 | /* TODO: Which channel to use? */ | |
1921 | offchannel_send_action(wpa_s, 2437, broadcast, wpa_s->own_addr, | |
1922 | broadcast, | |
1923 | wpabuf_head(msg), wpabuf_len(msg), | |
1924 | wait_time, wpas_dpp_tx_pkex_status, 0); | |
1925 | } | |
1926 | ||
1927 | /* TODO: Support multiple PKEX info entries */ | |
1928 | ||
1929 | os_free(wpa_s->dpp_pkex_auth_cmd); | |
1930 | wpa_s->dpp_pkex_auth_cmd = os_strdup(cmd); | |
1931 | ||
1932 | return 1; | |
1933 | } | |
1934 | ||
1935 | ||
1936 | int wpas_dpp_pkex_remove(struct wpa_supplicant *wpa_s, const char *id) | |
1937 | { | |
1938 | unsigned int id_val; | |
1939 | ||
1940 | if (os_strcmp(id, "*") == 0) { | |
1941 | id_val = 0; | |
1942 | } else { | |
1943 | id_val = atoi(id); | |
1944 | if (id_val == 0) | |
1945 | return -1; | |
1946 | } | |
1947 | ||
1948 | if ((id_val != 0 && id_val != 1) || !wpa_s->dpp_pkex_code) | |
1949 | return -1; | |
1950 | ||
1951 | /* TODO: Support multiple PKEX entries */ | |
1952 | os_free(wpa_s->dpp_pkex_code); | |
1953 | wpa_s->dpp_pkex_code = NULL; | |
1954 | os_free(wpa_s->dpp_pkex_identifier); | |
1955 | wpa_s->dpp_pkex_identifier = NULL; | |
1956 | os_free(wpa_s->dpp_pkex_auth_cmd); | |
1957 | wpa_s->dpp_pkex_auth_cmd = NULL; | |
1958 | wpa_s->dpp_pkex_bi = NULL; | |
1959 | /* TODO: Remove dpp_pkex only if it is for the identified PKEX code */ | |
1960 | dpp_pkex_free(wpa_s->dpp_pkex); | |
1961 | wpa_s->dpp_pkex = NULL; | |
1962 | return 0; | |
1963 | } | |
1964 | ||
1965 | ||
be27e185 JM |
1966 | int wpas_dpp_init(struct wpa_supplicant *wpa_s) |
1967 | { | |
461d39af JM |
1968 | u8 adv_proto_id[7]; |
1969 | ||
1970 | adv_proto_id[0] = WLAN_EID_VENDOR_SPECIFIC; | |
1971 | adv_proto_id[1] = 5; | |
1972 | WPA_PUT_BE24(&adv_proto_id[2], OUI_WFA); | |
1973 | adv_proto_id[5] = DPP_OUI_TYPE; | |
1974 | adv_proto_id[6] = 0x01; | |
1975 | ||
1976 | if (gas_server_register(wpa_s->gas_server, adv_proto_id, | |
1977 | sizeof(adv_proto_id), wpas_dpp_gas_req_handler, | |
1978 | wpas_dpp_gas_status_handler, wpa_s) < 0) | |
1979 | return -1; | |
be27e185 | 1980 | dl_list_init(&wpa_s->dpp_bootstrap); |
461d39af | 1981 | dl_list_init(&wpa_s->dpp_configurator); |
be27e185 JM |
1982 | wpa_s->dpp_init_done = 1; |
1983 | return 0; | |
1984 | } | |
1985 | ||
1986 | ||
1987 | void wpas_dpp_deinit(struct wpa_supplicant *wpa_s) | |
1988 | { | |
461d39af JM |
1989 | #ifdef CONFIG_TESTING_OPTIONS |
1990 | os_free(wpa_s->dpp_config_obj_override); | |
1991 | wpa_s->dpp_config_obj_override = NULL; | |
1992 | os_free(wpa_s->dpp_discovery_override); | |
1993 | wpa_s->dpp_discovery_override = NULL; | |
1994 | os_free(wpa_s->dpp_groups_override); | |
1995 | wpa_s->dpp_groups_override = NULL; | |
461d39af JM |
1996 | wpa_s->dpp_ignore_netaccesskey_mismatch = 0; |
1997 | #endif /* CONFIG_TESTING_OPTIONS */ | |
be27e185 JM |
1998 | if (!wpa_s->dpp_init_done) |
1999 | return; | |
30d27b04 JM |
2000 | eloop_cancel_timeout(wpas_dpp_reply_wait_timeout, wpa_s, NULL); |
2001 | offchannel_send_action_done(wpa_s); | |
2002 | wpas_dpp_listen_stop(wpa_s); | |
be27e185 | 2003 | dpp_bootstrap_del(wpa_s, 0); |
461d39af | 2004 | dpp_configurator_del(wpa_s, 0); |
30d27b04 JM |
2005 | dpp_auth_deinit(wpa_s->dpp_auth); |
2006 | wpa_s->dpp_auth = NULL; | |
500ed7f0 JM |
2007 | wpas_dpp_pkex_remove(wpa_s, "*"); |
2008 | wpa_s->dpp_pkex = NULL; | |
a0d5c56f | 2009 | os_memset(wpa_s->dpp_intro_bssid, 0, ETH_ALEN); |
b65b22d6 JM |
2010 | os_free(wpa_s->dpp_configurator_params); |
2011 | wpa_s->dpp_configurator_params = NULL; | |
be27e185 | 2012 | } |