blob: 3f7ea6f56839548c9d1ffbe26b90b1e08a96e699 [file] [log] [blame]
Jouni Malinend86e5822017-08-29 03:55:32 +03001/*
2 * Sigma Control API DUT (station/AP/sniffer)
3 * Copyright (c) 2017, Qualcomm Atheros, Inc.
Jouni Malinenc12ea4a2018-01-05 21:07:10 +02004 * Copyright (c) 2018, The Linux Foundation
Jouni Malinend86e5822017-08-29 03:55:32 +03005 * All Rights Reserved.
6 * Licensed under the Clear BSD license. See README for more details.
7 */
8
9#include "sigma_dut.h"
Jouni Malinen1a38cc32018-01-05 20:59:00 +020010#include <sys/wait.h>
Jouni Malinend86e5822017-08-29 03:55:32 +030011#include "wpa_ctrl.h"
12#include "wpa_helpers.h"
13
Jouni Malinen1a38cc32018-01-05 20:59:00 +020014#ifdef ANDROID
Srinivas Dasaribc9e0552018-01-04 19:24:28 +053015char *dpp_qrcode_file = "/sdcard/wpadebug_qrdata.txt";
Jouni Malinen1a38cc32018-01-05 20:59:00 +020016#endif /* ANDROID */
Srinivas Dasaribc9e0552018-01-04 19:24:28 +053017
Jouni Malinend86e5822017-08-29 03:55:32 +030018
19static int sigma_dut_is_ap(struct sigma_dut *dut)
20{
21 return dut->device_type == AP_unknown ||
22 dut->device_type == AP_testbed ||
23 dut->device_type == AP_dut;
24}
25
26
27static int dpp_hostapd_run(struct sigma_dut *dut)
28{
29 if (dut->hostapd_running)
30 return 0;
31
32 sigma_dut_print(dut, DUT_MSG_INFO,
33 "Starting hostapd in unconfigured state for DPP");
34 snprintf(dut->ap_ssid, sizeof(dut->ap_ssid), "unconfigured");
priyadharshini gowthaman9149afc2018-01-15 13:40:18 -080035 if (!dut->ap_oper_chn)
36 dut->ap_channel = 11;
Jouni Malinend86e5822017-08-29 03:55:32 +030037 dut->ap_is_dual = 0;
priyadharshini gowthamanfa2d7c32018-02-20 13:30:13 -080038 dut->ap_mode = dut->ap_channel <= 14 ? AP_11ng : AP_11na;
Jouni Malinend86e5822017-08-29 03:55:32 +030039 dut->ap_key_mgmt = AP_OPEN;
40 dut->ap_cipher = AP_PLAIN;
41 return cmd_ap_config_commit(dut, NULL, NULL) == 1 ? 0 : -1;
42}
43
44
45static const char * dpp_get_curve(struct sigma_cmd *cmd, const char *arg)
46{
47 const char *val = get_param(cmd, arg);
48
49 if (!val)
50 val = "P-256";
51 else if (strcasecmp(val, "BP-256R1") == 0)
52 val = "BP-256";
53 else if (strcasecmp(val, "BP-384R1") == 0)
54 val = "BP-384";
55 else if (strcasecmp(val, "BP-512R1") == 0)
56 val = "BP-512";
57
58 return val;
59}
60
61
62static int dpp_get_local_bootstrap(struct sigma_dut *dut,
63 struct sigma_conn *conn,
Srinivas Dasaribc9e0552018-01-04 19:24:28 +053064 struct sigma_cmd *cmd, int send_result,
65 int *success)
Jouni Malinend86e5822017-08-29 03:55:32 +030066{
67 const char *curve = dpp_get_curve(cmd, "DPPCryptoIdentifier");
68 const char *bs = get_param(cmd, "DPPBS");
Jouni Malinen4161c3f2017-11-13 18:36:09 +020069 const char *chan_list = get_param(cmd, "DPPChannelList");
70 char *pos, mac[50], buf[200], resp[1000], hex[2000];
Jouni Malinend86e5822017-08-29 03:55:32 +030071 const char *ifname = get_station_ifname();
72
Srinivas Dasaribc9e0552018-01-04 19:24:28 +053073 if (success)
74 *success = 0;
Jouni Malinend86e5822017-08-29 03:55:32 +030075 if (strcasecmp(bs, "QR") != 0) {
76 send_resp(dut, conn, SIGMA_ERROR,
77 "errorCode,Unsupported DPPBS");
78 return 0;
79 }
80
81 if (sigma_dut_is_ap(dut)) {
82 u8 bssid[ETH_ALEN];
83
84 if (!dut->hostapd_ifname) {
85 sigma_dut_print(dut, DUT_MSG_ERROR,
86 "hostapd ifname not specified (-j)");
87 return -2;
88 }
89 ifname = dut->hostapd_ifname;
90 if (get_hwaddr(dut->hostapd_ifname, bssid) < 0) {
91 sigma_dut_print(dut, DUT_MSG_ERROR,
92 "Could not get MAC address for %s",
93 dut->hostapd_ifname);
94 return -2;
95 }
96 snprintf(mac, sizeof(mac), "%02x%02x%02x%02x%02x%02x",
97 bssid[0], bssid[1], bssid[2],
98 bssid[3], bssid[4], bssid[5]);
99 } else {
100 if (get_wpa_status(ifname, "address", mac, sizeof(mac)) < 0)
101 return -2;
102 }
103
104 pos = mac;
105 while (*pos) {
106 if (*pos == ':')
107 memmove(pos, pos + 1, strlen(pos));
108 else
109 pos++;
110 }
111
Jouni Malinend86e5822017-08-29 03:55:32 +0300112 if (sigma_dut_is_ap(dut) && dpp_hostapd_run(dut) < 0) {
113 send_resp(dut, conn, SIGMA_ERROR,
114 "errorCode,Failed to start hostapd");
115 return 0;
116 }
117
Jouni Malinen4161c3f2017-11-13 18:36:09 +0200118 if (chan_list &&
119 (strcmp(chan_list, "0/0") == 0 || chan_list[0] == '\0')) {
120 /* No channel list */
121 snprintf(buf, sizeof(buf),
122 "DPP_BOOTSTRAP_GEN type=qrcode curve=%s mac=%s",
123 curve, mac);
124 } else if (chan_list) {
125 /* Channel list override (CTT case) - space separated tuple(s)
126 * of OperatingClass/Channel; convert to wpa_supplicant/hostapd
127 * format: comma separated tuples */
128 strlcpy(resp, chan_list, sizeof(resp));
129 for (pos = resp; *pos; pos++) {
130 if (*pos == ' ')
131 *pos = ',';
132 }
133 snprintf(buf, sizeof(buf),
134 "DPP_BOOTSTRAP_GEN type=qrcode curve=%s chan=%s mac=%s",
135 curve, resp, mac);
136 } else {
137 /* Default channel list (normal DUT case) */
138 snprintf(buf, sizeof(buf),
139 "DPP_BOOTSTRAP_GEN type=qrcode curve=%s chan=81/11 mac=%s",
140 curve, mac);
141 }
142
Jouni Malinend86e5822017-08-29 03:55:32 +0300143 if (wpa_command_resp(ifname, buf, resp, sizeof(resp)) < 0)
144 return -2;
145 if (strncmp(resp, "FAIL", 4) == 0)
146 return -2;
147 dut->dpp_local_bootstrap = atoi(resp);
148 snprintf(buf, sizeof(buf), "DPP_BOOTSTRAP_GET_URI %d",
149 atoi(resp));
150 if (wpa_command_resp(ifname, buf, resp, sizeof(resp)) < 0)
151 return -2;
152 if (strncmp(resp, "FAIL", 4) == 0)
153 return -2;
154
155 sigma_dut_print(dut, DUT_MSG_DEBUG, "URI: %s", resp);
Srinivas Dasaribc9e0552018-01-04 19:24:28 +0530156
157 if (send_result) {
158 ascii2hexstr(resp, hex);
159 snprintf(resp, sizeof(resp), "BootstrappingData,%s", hex);
160 send_resp(dut, conn, SIGMA_COMPLETE, resp);
161 }
162
163 if (success)
164 *success = 1;
Jouni Malinend86e5822017-08-29 03:55:32 +0300165 return 0;
166}
167
168
169static int dpp_set_peer_bootstrap(struct sigma_dut *dut,
170 struct sigma_conn *conn,
171 struct sigma_cmd *cmd)
172{
173 const char *val = get_param(cmd, "DPPBootstrappingdata");
Jouni Malinenb1dd21f2017-11-13 19:14:29 +0200174 char uri[1000];
Jouni Malinend86e5822017-08-29 03:55:32 +0300175 int res;
Jouni Malinend86e5822017-08-29 03:55:32 +0300176
177 if (!val) {
178 send_resp(dut, conn, SIGMA_ERROR,
179 "errorCode,Missing DPPBootstrappingdata");
180 return 0;
181 }
182
183 res = parse_hexstr(val, (unsigned char *) uri, sizeof(uri));
184 if (res < 0 || (size_t) res >= sizeof(uri))
185 return -2;
186 uri[res] = '\0';
187 sigma_dut_print(dut, DUT_MSG_DEBUG, "URI: %s", uri);
Jouni Malinenb1dd21f2017-11-13 19:14:29 +0200188 free(dut->dpp_peer_uri);
189 dut->dpp_peer_uri = strdup(uri);
Jouni Malinend86e5822017-08-29 03:55:32 +0300190
191 return 1;
192}
193
194
195static int dpp_hostapd_conf_update(struct sigma_dut *dut,
196 struct sigma_conn *conn, const char *ifname,
197 struct wpa_ctrl *ctrl)
198{
199 int res;
200 char buf[2000], buf2[2500], *pos, *pos2;
Jouni Malinenb4c5e3b2017-09-15 17:43:20 +0300201 const char *conf_data_events[] = {
202 "DPP-CONNECTOR",
203 "DPP-CONFOBJ-PASS",
204 "DPP-CONFOBJ-PSK",
205 NULL
206 };
Jouni Malinend86e5822017-08-29 03:55:32 +0300207
208 sigma_dut_print(dut, DUT_MSG_INFO,
209 "Update hostapd configuration based on DPP Config Object");
210
211 if (wpa_command(ifname, "SET wpa 2") < 0 ||
212 wpa_command(ifname, "SET wpa_key_mgmt DPP") < 0 ||
Jouni Malinen0d347232017-11-01 17:14:00 +0200213 wpa_command(ifname, "SET ieee80211w 1") < 0 ||
Jouni Malinend86e5822017-08-29 03:55:32 +0300214 wpa_command(ifname, "SET rsn_pairwise CCMP") < 0) {
215 send_resp(dut, conn, SIGMA_ERROR,
216 "errorCode,Failed to update AP security parameters");
217 goto out;
218 }
219
220 res = get_wpa_cli_event(dut, ctrl, "DPP-CONFOBJ-SSID",
221 buf, sizeof(buf));
222 if (res < 0) {
223 send_resp(dut, conn, SIGMA_ERROR,
224 "errorCode,No DPP-CONFOBJ-SSID");
225 goto out;
226 }
227 pos = strchr(buf, ' ');
228 if (!pos)
229 return -2;
230 pos++;
231 sigma_dut_print(dut, DUT_MSG_INFO,
232 "DPP: Config Object SSID: %s", pos);
233 snprintf(buf2, sizeof(buf2), "SET ssid %s", pos);
234 if (wpa_command(ifname, buf2) < 0) {
235 send_resp(dut, conn, SIGMA_ERROR,
236 "errorCode,Failed to update AP SSID");
237 goto out;
238 }
239
Jouni Malinenb4c5e3b2017-09-15 17:43:20 +0300240 res = get_wpa_cli_events(dut, ctrl, conf_data_events, buf, sizeof(buf));
Jouni Malinend86e5822017-08-29 03:55:32 +0300241 if (res < 0) {
242 send_resp(dut, conn, SIGMA_ERROR,
Jouni Malinenb4c5e3b2017-09-15 17:43:20 +0300243 "errorCode,No DPP-CONNECTOR/DPP-CONFOBJ-PASS/PSK");
Jouni Malinend86e5822017-08-29 03:55:32 +0300244 goto out;
245 }
Jouni Malinenb4c5e3b2017-09-15 17:43:20 +0300246
247 if (!strstr(buf, "DPP-CONNECTOR")) {
248 if (wpa_command(ifname, "SET wpa_key_mgmt WPA-PSK") < 0) {
249 send_resp(dut, conn, SIGMA_ERROR,
250 "errorCode,Failed to update AP security parameters");
251 goto out;
252 }
253
254 pos = strchr(buf, ' ');
255 if (!pos)
256 return -2;
257 pos++;
258 if (strstr(buf, "DPP-CONFOBJ-PASS")) {
259 char pass[64];
260 int pass_len;
261
262 pass_len = parse_hexstr(pos, (u8 *) pass, sizeof(pass));
Jouni Malinenfddb7ea2018-01-05 21:02:50 +0200263 if (pass_len < 0 || (size_t) pass_len >= sizeof(pass))
Jouni Malinenb4c5e3b2017-09-15 17:43:20 +0300264 return -2;
265 pass[pass_len] = '\0';
266 sigma_dut_print(dut, DUT_MSG_INFO,
267 "DPP: Passphrase: %s", pass);
268 snprintf(buf2, sizeof(buf2), "SET wpa_passphrase %s",
269 pass);
270 if (wpa_command(ifname, buf2) < 0) {
271 send_resp(dut, conn, SIGMA_ERROR,
272 "errorCode,Failed to set passphrase");
273 goto out;
274 }
275 } else if (strstr(buf, "DPP-CONFOBJ-PSK")) {
276 sigma_dut_print(dut, DUT_MSG_INFO,
277 "DPP: PSK: %s", pos);
278 snprintf(buf2, sizeof(buf2), "SET wpa_psk %s", pos);
279 if (wpa_command(ifname, buf2) < 0) {
280 send_resp(dut, conn, SIGMA_ERROR,
281 "errorCode,Failed to set PSK");
282 goto out;
283 }
284 }
285
286 goto skip_dpp_akm;
287 }
288
Jouni Malinend86e5822017-08-29 03:55:32 +0300289 pos = strchr(buf, ' ');
290 if (!pos)
291 return -2;
292 pos++;
293 sigma_dut_print(dut, DUT_MSG_INFO, "DPP: Connector: %s", pos);
294 snprintf(buf2, sizeof(buf2), "SET dpp_connector %s", pos);
295 if (wpa_command(ifname, buf2) < 0) {
296 send_resp(dut, conn, SIGMA_ERROR,
297 "errorCode,Failed to update AP Connector");
298 goto out;
299 }
300
301 res = get_wpa_cli_event(dut, ctrl, "DPP-C-SIGN-KEY",
302 buf, sizeof(buf));
303 if (res < 0) {
304 send_resp(dut, conn, SIGMA_ERROR,
305 "errorCode,No DPP-C-SIGN-KEY");
306 goto out;
307 }
308 pos = strchr(buf, ' ');
309 if (!pos)
310 return -2;
311 pos++;
Jouni Malinend86e5822017-08-29 03:55:32 +0300312 sigma_dut_print(dut, DUT_MSG_INFO, "DPP: C-sign-key: %s", pos);
313 snprintf(buf2, sizeof(buf2), "SET dpp_csign %s", pos);
314 if (wpa_command(ifname, buf2) < 0) {
315 send_resp(dut, conn, SIGMA_ERROR,
316 "errorCode,Failed to update AP C-sign-key");
317 goto out;
318 }
Jouni Malinend86e5822017-08-29 03:55:32 +0300319
320 res = get_wpa_cli_event(dut, ctrl, "DPP-NET-ACCESS-KEY",
321 buf, sizeof(buf));
322 if (res < 0) {
323 send_resp(dut, conn, SIGMA_ERROR,
324 "errorCode,No DPP-NET-ACCESS-KEY");
325 goto out;
326 }
327 pos = strchr(buf, ' ');
328 if (!pos)
329 return -2;
330 pos++;
331 pos2 = strchr(pos, ' ');
332 if (pos2)
333 *pos2++ = '\0';
334 sigma_dut_print(dut, DUT_MSG_INFO, "DPP: netAccessKey: %s", pos);
335 snprintf(buf2, sizeof(buf2), "SET dpp_netaccesskey %s", pos);
336 if (wpa_command(ifname, buf2) < 0) {
337 send_resp(dut, conn, SIGMA_ERROR,
338 "errorCode,Failed to update AP netAccessKey");
339 goto out;
340 }
341 if (pos2) {
342 sigma_dut_print(dut, DUT_MSG_INFO,
343 "DPP: netAccessKey expiry: %s", pos2);
344 snprintf(buf2, sizeof(buf2), "SET dpp_netaccesskey_expiry %s",
345 pos2);
346 if (wpa_command(ifname, buf2) < 0) {
347 send_resp(dut, conn, SIGMA_ERROR,
348 "errorCode,Failed to update AP netAccessKey expiry");
349 goto out;
350 }
351 }
Jouni Malinenb4c5e3b2017-09-15 17:43:20 +0300352skip_dpp_akm:
Jouni Malinend86e5822017-08-29 03:55:32 +0300353
354 if (wpa_command(ifname, "DISABLE") < 0 ||
355 wpa_command(ifname, "ENABLE") < 0) {
356 send_resp(dut, conn, SIGMA_ERROR,
357 "errorCode,Failed to update AP configuration");
358 goto out;
359 }
360
361 res = get_wpa_cli_event(dut, ctrl, "AP-ENABLED", buf, sizeof(buf));
362 if (res < 0) {
363 send_resp(dut, conn, SIGMA_ERROR, "errorCode,No AP-ENABLED");
364 goto out;
365 }
366
367 return 1;
368out:
369 return 0;
370}
371
372
Jouni Malinen772299f2017-11-06 00:36:26 +0200373struct dpp_test_info {
374 const char *step;
375 const char *frame;
376 const char *attr;
377 int value;
378};
379
380static const struct dpp_test_info dpp_tests[] = {
381 { "InvalidValue", "AuthenticationRequest", "WrappedData", 1 },
382 { "InvalidValue", "AuthenticationResponse", "WrappedData", 2 },
Jouni Malinenf96fcee2017-11-22 16:08:35 +0200383 { "InvalidValue", "AuthenticationResponse", "PrimaryWrappedData", 2 },
Jouni Malinen772299f2017-11-06 00:36:26 +0200384 { "InvalidValue", "AuthenticationConfirm", "WrappedData", 3 },
385 { "InvalidValue", "PKEXCRRequest", "WrappedData", 4 },
386 { "InvalidValue", "PKEXCRResponse", "WrappedData", 5 },
387 { "InvalidValue", "ConfigurationRequest", "WrappedData", 6 },
388 { "InvalidValue", "ConfigurationResponse", "WrappedData", 7 },
389 { "InvalidValue", "AuthenticationRequest", "InitCapabilities", 8 },
Jouni Malinen772299f2017-11-06 00:36:26 +0200390 { "MissingAttribute", "AuthenticationRequest", "RespBSKeyHash", 10 },
391 { "MissingAttribute", "AuthenticationRequest", "InitBSKeyHash", 11 },
392 { "MissingAttribute", "AuthenticationRequest", "InitProtocolKey", 12 },
393 { "MissingAttribute", "AuthenticationRequest", "InitNonce", 13 },
394 { "MissingAttribute", "AuthenticationRequest", "InitCapabilities", 14 },
395 { "MissingAttribute", "AuthenticationRequest", "WrappedData", 15 },
396 { "MissingAttribute", "AuthenticationResponse", "DPPStatus", 16 },
397 { "MissingAttribute", "AuthenticationResponse", "RespBSKeyHash", 17 },
398 { "MissingAttribute", "AuthenticationResponse", "InitBSKeyHash", 18 },
399 { "MissingAttribute", "AuthenticationResponse", "RespProtocolKey", 19 },
400 { "MissingAttribute", "AuthenticationResponse", "RespNonce", 20 },
401 { "MissingAttribute", "AuthenticationResponse", "InitNonce", 21 },
402 { "MissingAttribute", "AuthenticationResponse", "RespCapabilities",
403 22 },
404 { "MissingAttribute", "AuthenticationResponse", "RespAuthTag", 23 },
405 { "MissingAttribute", "AuthenticationResponse", "WrappedData", 24 },
Jouni Malinenf96fcee2017-11-22 16:08:35 +0200406 { "MissingAttribute", "AuthenticationResponse", "PrimaryWrappedData",
407 24 },
Jouni Malinen772299f2017-11-06 00:36:26 +0200408 { "MissingAttribute", "AuthenticationConfirm", "DPPStatus", 25 },
409 { "MissingAttribute", "AuthenticationConfirm", "RespBSKeyHash", 26 },
410 { "MissingAttribute", "AuthenticationConfirm", "InitBSKeyHash", 27 },
411 { "MissingAttribute", "AuthenticationConfirm", "InitAuthTag", 28 },
412 { "MissingAttribute", "AuthenticationConfirm", "WrappedData", 29 },
413 { "InvalidValue", "AuthenticationResponse", "InitNonce", 30 },
414 { "InvalidValue", "AuthenticationResponse", "RespCapabilities", 31 },
415 { "InvalidValue", "AuthenticationResponse", "RespAuthTag", 32 },
416 { "InvalidValue", "AuthenticationConfirm", "InitAuthTag", 33 },
417 { "MissingAttribute", "PKEXExchangeRequest", "FiniteCyclicGroup", 34 },
418 { "MissingAttribute", "PKEXExchangeRequest", "EncryptedKey", 35 },
419 { "MissingAttribute", "PKEXExchangeResponse", "DPPStatus", 36 },
420 { "MissingAttribute", "PKEXExchangeResponse", "EncryptedKey", 37 },
421 { "MissingAttribute", "PKEXCRRequest", "BSKey", 38 },
422 { "MissingAttribute", "PKEXCRRequest", "InitAuthTag", 39 },
423 { "MissingAttribute", "PKEXCRRequest", "WrappedData", 40 },
424 { "MissingAttribute", "PKEXCRResponse", "BSKey", 41 },
425 { "MissingAttribute", "PKEXCRResponse", "RespAuthTag", 42 },
426 { "MissingAttribute", "PKEXCRResponse", "WrappedData", 43 },
427 { "InvalidValue", "PKEXExchangeRequest", "EncryptedKey", 44 },
428 { "InvalidValue", "PKEXExchangeResponse", "EncryptedKey", 45 },
429 { "InvalidValue", "PKEXExchangeResponse", "DPPStatus", 46 },
430 { "InvalidValue", "PKEXCRRequest", "BSKey", 47 },
431 { "InvalidValue", "PKEXCRResponse", "BSKey", 48 },
432 { "InvalidValue", "PKEXCRRequest", "InitAuthTag", 49 },
433 { "InvalidValue", "PKEXCRResponse", "RespAuthTag", 50 },
434 { "MissingAttribute", "ConfigurationRequest", "EnrolleeNonce", 51 },
435 { "MissingAttribute", "ConfigurationRequest", "ConfigAttr", 52 },
436 { "MissingAttribute", "ConfigurationRequest", "WrappedData", 53 },
437 { "MissingAttribute", "ConfigurationResponse", "EnrolleeNonce", 54 },
438 { "MissingAttribute", "ConfigurationResponse", "ConfigObj", 55 },
439 { "MissingAttribute", "ConfigurationResponse", "DPPStatus", 56 },
440 { "MissingAttribute", "ConfigurationResponse", "WrappedData", 57 },
441 { "InvalidValue", "ConfigurationResponse", "DPPStatus", 58 },
442 { "InvalidValue", "ConfigurationResponse", "EnrolleeNonce", 59 },
Jouni Malinen53558e02017-11-06 12:58:28 +0200443 { "MissingAttribute", "PeerDiscoveryRequest", "TransactionID", 60 },
444 { "MissingAttribute", "PeerDiscoveryRequest", "Connector", 61 },
445 { "MissingAttribute", "PeerDiscoveryResponse", "TransactionID", 62 },
446 { "MissingAttribute", "PeerDiscoveryResponse", "DPPStatus", 63 },
447 { "MissingAttribute", "PeerDiscoveryResponse", "Connector", 64 },
Jouni Malinenae624482017-11-19 00:13:51 +0200448 { "InvalidValue", "AuthenticationRequest", "InitProtocolKey", 66 },
449 { "InvalidValue", "AuthenticationResponse", "RespProtocolKey", 67 },
450 { "InvalidValue", "AuthenticationRequest", "RespBSKeyHash", 68 },
451 { "InvalidValue", "AuthenticationRequest", "InitBSKeyHash", 69 },
452 { "InvalidValue", "AuthenticationResponse", "RespBSKeyHash", 70 },
453 { "InvalidValue", "AuthenticationResponse", "InitBSKeyHash", 71 },
454 { "InvalidValue", "AuthenticationConfirm", "RespBSKeyHash", 72 },
455 { "InvalidValue", "AuthenticationConfirm", "InitBSKeyHash", 73 },
456 { "InvalidValue", "AuthenticationResponse", "DPPStatus", 74 },
457 { "InvalidValue", "AuthenticationConfirm", "DPPStatus", 75 },
458 { "InvalidValue", "ConfigurationRequest", "ConfigAttr", 76 },
459 { "InvalidValue", "PeerDiscoveryResponse", "TransactionID", 77 },
460 { "InvalidValue", "PeerDiscoveryResponse", "DPPStatus", 78 },
461 { "InvalidValue", "PeerDiscoveryResponse", "Connector", 79 },
462 { "InvalidValue", "PeerDiscoveryRequest", "Connector", 80 },
Jouni Malinen67795a72017-11-22 16:24:43 +0200463 { "InvalidValue", "AuthenticationRequest", "InitNonce", 81 },
Jouni Malinen188839b2017-11-30 22:02:02 +0200464 { "InvalidValue", "PeerDiscoveryRequest", "TransactionID", 82 },
465 { "InvalidValue", "ConfigurationRequest", "EnrolleeNonce", 83 },
Jouni Malinen3a6b92a2017-12-05 20:22:43 +0200466 { "Timeout", "PKEXExchangeResponse", NULL, 84 },
467 { "Timeout", "PKEXCRRequest", NULL, 85 },
468 { "Timeout", "PKEXCRResponse", NULL, 86 },
469 { "Timeout", "AuthenticationRequest", NULL, 87 },
470 { "Timeout", "AuthenticationResponse", NULL, 88 },
471 { "Timeout", "AuthenticationConfirm", NULL, 89 },
472 { "Timeout", "ConfigurationRequest", NULL, 90 },
Jouni Malinen772299f2017-11-06 00:36:26 +0200473 { NULL, NULL, NULL, 0 }
474};
475
476
477static int dpp_get_test(const char *step, const char *frame, const char *attr)
478{
479 int i;
480
481 for (i = 0; dpp_tests[i].step; i++) {
482 if (strcasecmp(step, dpp_tests[i].step) == 0 &&
483 strcasecmp(frame, dpp_tests[i].frame) == 0 &&
Jouni Malinen3a6b92a2017-12-05 20:22:43 +0200484 ((!attr && dpp_tests[i].attr == NULL) ||
485 (attr && strcasecmp(attr, dpp_tests[i].attr) == 0)))
Jouni Malinen772299f2017-11-06 00:36:26 +0200486 return dpp_tests[i].value;
487 }
488
489 return -1;
490}
491
492
Jouni Malinen6792ff42018-02-13 00:25:56 +0200493static int dpp_wait_tx(struct sigma_dut *dut, struct wpa_ctrl *ctrl,
494 int frame_type)
495{
496 char buf[200], tmp[20];
497 int res;
498
499 snprintf(tmp, sizeof(tmp), "type=%d", frame_type);
500 for (;;) {
501 res = get_wpa_cli_event(dut, ctrl, "DPP-TX", buf, sizeof(buf));
502 if (res < 0)
503 return -1;
504 if (strstr(buf, tmp) != NULL)
505 break;
506 }
507
508 return 0;
509}
510
511
Jouni Malinen772299f2017-11-06 00:36:26 +0200512static int dpp_wait_tx_status(struct sigma_dut *dut, struct wpa_ctrl *ctrl,
513 int frame_type)
514{
515 char buf[200], tmp[20];
516 int res;
517
518 snprintf(tmp, sizeof(tmp), "type=%d", frame_type);
519 for (;;) {
520 res = get_wpa_cli_event(dut, ctrl, "DPP-TX", buf, sizeof(buf));
521 if (res < 0)
522 return -1;
523 if (strstr(buf, tmp) != NULL)
524 break;
525 }
526
527 res = get_wpa_cli_event(dut, ctrl, "DPP-TX-STATUS",
528 buf, sizeof(buf));
529 if (res < 0 || strstr(buf, "result=FAILED") != NULL)
530 return -1;
531
532 return 0;
533}
534
535
Jouni Malinen3a6b92a2017-12-05 20:22:43 +0200536static int dpp_wait_rx(struct sigma_dut *dut, struct wpa_ctrl *ctrl,
Jouni Malinen3e4344e2018-01-22 11:47:37 +0200537 int frame_type, unsigned int max_wait)
Jouni Malinen3a6b92a2017-12-05 20:22:43 +0200538{
539 char buf[200], tmp[20];
540 int res;
Jouni Malinen9a3415c2018-01-10 22:12:22 +0200541 unsigned int old_timeout;
542
543 old_timeout = dut->default_timeout;
544 if (max_wait > 0 && dut->default_timeout > max_wait)
545 dut->default_timeout = max_wait;
Jouni Malinen3a6b92a2017-12-05 20:22:43 +0200546
547 snprintf(tmp, sizeof(tmp), "type=%d", frame_type);
548 for (;;) {
549 res = get_wpa_cli_event(dut, ctrl, "DPP-RX", buf, sizeof(buf));
Jouni Malinen9a3415c2018-01-10 22:12:22 +0200550 if (res < 0) {
551 dut->default_timeout = old_timeout;
Jouni Malinen3a6b92a2017-12-05 20:22:43 +0200552 return -1;
Jouni Malinen9a3415c2018-01-10 22:12:22 +0200553 }
Jouni Malinen3a6b92a2017-12-05 20:22:43 +0200554 if (strstr(buf, tmp) != NULL)
555 break;
556 }
557
Jouni Malinen9a3415c2018-01-10 22:12:22 +0200558 dut->default_timeout = old_timeout;
559 return 0;
560}
561
562
563static int dpp_wait_rx_conf_req(struct sigma_dut *dut, struct wpa_ctrl *ctrl,
Jouni Malinen3e4344e2018-01-22 11:47:37 +0200564 unsigned int max_wait)
Jouni Malinen9a3415c2018-01-10 22:12:22 +0200565{
566 char buf[200];
567 int res;
568 unsigned int old_timeout;
569
570 old_timeout = dut->default_timeout;
571 if (max_wait > 0 && dut->default_timeout > max_wait)
572 dut->default_timeout = max_wait;
573
574 for (;;) {
575 res = get_wpa_cli_event(dut, ctrl, "DPP-CONF-REQ-RX",
576 buf, sizeof(buf));
577 if (res < 0) {
578 dut->default_timeout = old_timeout;
579 return -1;
580 }
581
582 break;
583 }
584
585 dut->default_timeout = old_timeout;
Jouni Malinen3a6b92a2017-12-05 20:22:43 +0200586 return 0;
587}
588
589
Srinivas Dasaribc9e0552018-01-04 19:24:28 +0530590static int dpp_scan_peer_qrcode(struct sigma_dut *dut)
Jouni Malinend86e5822017-08-29 03:55:32 +0300591{
Jouni Malinen1a38cc32018-01-05 20:59:00 +0200592#ifdef ANDROID
Srinivas Dasaribc9e0552018-01-04 19:24:28 +0530593 char buf[100];
594 char *buf2 = NULL;
595 FILE *fp = NULL;
596 uint32_t length;
597 unsigned int count;
598
599 unlink(dpp_qrcode_file);
600
601 snprintf(buf, sizeof(buf),
Jouni Malinen07458342018-02-22 19:23:40 +0200602 "am start -n w1.fi.wpadebug/w1.fi.wpadebug.QrCodeReadActivity");
Srinivas Dasaribc9e0552018-01-04 19:24:28 +0530603 if (system(buf) != 0) {
Jouni Malinen07458342018-02-22 19:23:40 +0200604 sigma_dut_print(dut, DUT_MSG_ERROR,
605 "Failed to launch QR Code scanner");
Srinivas Dasaribc9e0552018-01-04 19:24:28 +0530606 return -1;
607 }
608
609 count = 0;
610 while (!(fp = fopen(dpp_qrcode_file, "r"))) {
611 if (count > dut->default_timeout) {
612 sigma_dut_print(dut, DUT_MSG_ERROR,
613 "Failed to open dpp_qrcode_file - QR Code scanning timed out");
614 return -1;
615 }
616
617 sleep(1);
618 count++;
619 }
620
621 if (fseek(fp, 0, SEEK_END) < 0 || (length = ftell(fp)) <= 0 ||
622 fseek(fp, 0, SEEK_SET) < 0) {
623 sigma_dut_print(dut, DUT_MSG_ERROR,
624 "Failed to get QR Code result file length");
625 fclose(fp);
626 return -1;
627 }
628
629 buf2 = malloc(length + 1);
630 if (!buf2) {
631 fclose(fp);
632 return -1;
633 }
634
635 if (fread(buf2, 1, length, fp) != length) {
636 fclose(fp);
637 free(buf2);
638 return -1;
639 }
640
641 fclose(fp);
642 buf2[length] = '\0';
643
644 free(dut->dpp_peer_uri);
645 dut->dpp_peer_uri = strdup(buf2);
646 free(buf2);
647 return 0;
Jouni Malinen1a38cc32018-01-05 20:59:00 +0200648#else /* ANDROID */
649 pid_t pid;
650 int pid_status;
651 int pipe_out[2];
652 char buf[4000], *pos;
653 ssize_t len;
654 int res = -1, ret;
655 struct timeval tv;
656 fd_set rfd;
657
658 if (pipe(pipe_out) != 0) {
659 perror("pipe");
660 return -1;
661 }
662
663 pid = fork();
664 if (pid < 0) {
665 perror("fork");
666 close(pipe_out[0]);
667 close(pipe_out[1]);
668 return -1;
669 }
670
671 if (pid == 0) {
672 char *argv[4] = { "zbarcam", "--raw", "--prescale=320x240",
673 NULL };
674
675 dup2(pipe_out[1], STDOUT_FILENO);
676 close(pipe_out[0]);
677 close(pipe_out[1]);
678 execv("/usr/bin/zbarcam", argv);
679 perror("execv");
680 exit(0);
681 return -1;
682 }
683
684 close(pipe_out[1]);
685
686 FD_ZERO(&rfd);
687 FD_SET(pipe_out[0], &rfd);
688 tv.tv_sec = dut->default_timeout;
689 tv.tv_usec = 0;
690
691 ret = select(pipe_out[0] + 1, &rfd, NULL, NULL, &tv);
692 if (ret < 0) {
693 perror("select");
694 goto out;
695 }
696 if (ret == 0) {
697 sigma_dut_print(dut, DUT_MSG_DEBUG,
698 "QR Code scanning timed out");
699 goto out;
700 }
701
702 len = read(pipe_out[0], buf, sizeof(buf));
703 if (len <= 0)
704 goto out;
705 if (len == sizeof(buf))
706 len--;
707 buf[len] = '\0';
708 pos = strchr(buf, '\n');
709 if (pos)
710 *pos = '\0';
711 sigma_dut_print(dut, DUT_MSG_DEBUG, "URI from QR scanner: %s", buf);
712
713 free(dut->dpp_peer_uri);
714 dut->dpp_peer_uri = strdup(buf);
715 res = 0;
716out:
717 close(pipe_out[0]);
718 kill(pid, SIGTERM);
719 waitpid(pid, &pid_status, 0);
720
721 return res;
722#endif /* ANDROID */
Srinivas Dasaribc9e0552018-01-04 19:24:28 +0530723}
724
725
726static int dpp_display_own_qrcode(struct sigma_dut *dut)
727{
728 char buf[200], resp[2000];
729 const char *ifname = get_station_ifname();
Jouni Malinen1a38cc32018-01-05 20:59:00 +0200730#ifdef ANDROID
Srinivas Dasaribc9e0552018-01-04 19:24:28 +0530731 FILE *fp;
Jouni Malinen1a38cc32018-01-05 20:59:00 +0200732#else /* ANDROID */
733 pid_t pid;
734 int pid_status;
735#endif /* ANDROID */
Srinivas Dasaribc9e0552018-01-04 19:24:28 +0530736
737 snprintf(buf, sizeof(buf), "DPP_BOOTSTRAP_GET_URI %d",
738 dut->dpp_local_bootstrap);
739 if (wpa_command_resp(ifname, buf, resp, sizeof(resp)) < 0 ||
740 strncmp(resp, "FAIL", 4) == 0)
741 return -2;
Jouni Malinen1a38cc32018-01-05 20:59:00 +0200742 sigma_dut_print(dut, DUT_MSG_DEBUG, "Own bootstrap URI: %s", resp);
Srinivas Dasaribc9e0552018-01-04 19:24:28 +0530743
Jouni Malinen1a38cc32018-01-05 20:59:00 +0200744#ifdef ANDROID
Srinivas Dasaribc9e0552018-01-04 19:24:28 +0530745 unlink(dpp_qrcode_file);
746
747 fp = fopen(dpp_qrcode_file, "w");
748 if (!fp) {
749 sigma_dut_print(dut, DUT_MSG_ERROR, "Failed to open file %s",
750 dpp_qrcode_file);
751 return -2;
752 }
753
Srinivas Dasaribc9e0552018-01-04 19:24:28 +0530754 fwrite(resp, 1, strlen(resp), fp);
755 fclose(fp);
756
757 snprintf(buf, sizeof(buf),
758 "am start -n w1.fi.wpadebug/w1.fi.wpadebug.QrCodeDisplayActivity");
759 if (system(buf) != 0) {
760 sigma_dut_print(dut, DUT_MSG_ERROR, "Failed to display QR Code");
761 return -1;
762 }
Jouni Malinen1a38cc32018-01-05 20:59:00 +0200763#else /* ANDROID */
764 pid = fork();
765 if (pid < 0) {
766 perror("fork");
767 return -1;
768 }
769
770 if (pid == 0) {
771 char *argv[3] = { "qr", resp, NULL };
772
773 execv("/usr/bin/qr", argv);
774 perror("execv");
775 exit(0);
776 return -1;
777 }
778
779 waitpid(pid, &pid_status, 0);
780#endif /* ANDROID */
Srinivas Dasaribc9e0552018-01-04 19:24:28 +0530781
782 return 0;
Jouni Malinend86e5822017-08-29 03:55:32 +0300783}
784
785
Srinivas Dasari8d88d822018-03-26 17:57:34 +0530786static int dpp_process_auth_response(struct sigma_dut *dut,
787 struct sigma_conn *conn,
788 struct wpa_ctrl *ctrl,
789 const char **auth_events,
790 const char *action_type,
791 int check_mutual, char *buf, size_t buflen)
792{
793 int res;
794
795 res = get_wpa_cli_events(dut, ctrl, auth_events, buf, buflen);
796 if (res < 0) {
797 send_resp(dut, conn, SIGMA_COMPLETE,
798 "BootstrapResult,OK,AuthResult,Timeout");
799 return res;
800 }
801 sigma_dut_print(dut, DUT_MSG_DEBUG, "DPP auth result: %s", buf);
802
803 if (strstr(buf, "DPP-RESPONSE-PENDING")) {
804 /* Display own QR code in manual mode */
805 if (action_type && strcasecmp(action_type, "ManualDPP") == 0 &&
806 dpp_display_own_qrcode(dut) < 0) {
807 send_resp(dut, conn, SIGMA_ERROR,
808 "errorCode,Failed to display own QR code");
809 return -1;
810 }
811
812 /* Wait for the actual result after the peer has scanned the
813 * QR Code. */
814 res = get_wpa_cli_events(dut, ctrl, auth_events,
815 buf, buflen);
816 if (res < 0) {
817 send_resp(dut, conn, SIGMA_COMPLETE,
818 "BootstrapResult,OK,AuthResult,Timeout");
819 return res;
820 }
821
822 sigma_dut_print(dut, DUT_MSG_DEBUG, "DPP auth result: %s", buf);
823 }
824
825 if (check_mutual) {
826 if (strstr(buf, "DPP-NOT-COMPATIBLE")) {
827 send_resp(dut, conn, SIGMA_COMPLETE,
828 "BootstrapResult,OK,AuthResult,ROLES_NOT_COMPATIBLE");
829 return -1;
830 }
831
832 if (!strstr(buf, "DPP-AUTH-DIRECTION")) {
833 send_resp(dut, conn, SIGMA_ERROR,
834 "errorCode,No event for auth direction seen");
835 return -1;
836 }
837
838 sigma_dut_print(dut, DUT_MSG_DEBUG, "DPP auth direction: %s",
839 buf);
840 if (strstr(buf, "mutual=1") == NULL) {
841 send_resp(dut, conn, SIGMA_ERROR,
842 "errorCode,Peer did not use mutual authentication");
843 return -1;
844 }
845 }
846
847 return 0;
848}
849
850
Jouni Malinend86e5822017-08-29 03:55:32 +0300851static int dpp_automatic_dpp(struct sigma_dut *dut,
852 struct sigma_conn *conn,
853 struct sigma_cmd *cmd)
854{
855 const char *bs = get_param(cmd, "DPPBS");
856 const char *auth_role = get_param(cmd, "DPPAuthRole");
857 const char *prov_role = get_param(cmd, "DPPProvisioningRole");
858 const char *pkex_code = get_param(cmd, "DPPPKEXCode");
859 const char *pkex_code_id = get_param(cmd, "DPPPKEXCodeIdentifier");
860 const char *wait_conn = get_param(cmd, "DPPWaitForConnect");
861 const char *self_conf = get_param(cmd, "DPPSelfConfigure");
Jouni Malinen772299f2017-11-06 00:36:26 +0200862 const char *step = get_param(cmd, "DPPStep");
863 const char *frametype = get_param(cmd, "DPPFrameType");
864 const char *attr = get_param(cmd, "DPPIEAttribute");
Srinivas Dasaribc9e0552018-01-04 19:24:28 +0530865 const char *action_type = get_param(cmd, "DPPActionType");
Jouni Malinend86e5822017-08-29 03:55:32 +0300866 const char *role;
867 const char *val;
868 const char *conf_role;
Jouni Malinend86e5822017-08-29 03:55:32 +0300869 int conf_index = -1;
870 char buf[2000];
871 char conf_ssid[100];
872 char conf_pass[100];
873 char pkex_identifier[200];
874 struct wpa_ctrl *ctrl;
875 int res;
876 unsigned int old_timeout;
877 int own_pkex_id = -1;
878 const char *ifname = get_station_ifname();
879 const char *auth_events[] = {
880 "DPP-AUTH-SUCCESS",
881 "DPP-NOT-COMPATIBLE",
882 "DPP-RESPONSE-PENDING",
883 "DPP-SCAN-PEER-QR-CODE",
Srinivas Dasaribc9e0552018-01-04 19:24:28 +0530884 "DPP-AUTH-DIRECTION",
Jouni Malinend86e5822017-08-29 03:55:32 +0300885 NULL
886 };
887 const char *conf_events[] = {
888 "DPP-CONF-RECEIVED",
889 "DPP-CONF-SENT",
890 "DPP-CONF-FAILED",
891 NULL
892 };
893 const char *conn_events[] = {
894 "PMKSA-CACHE-ADDED",
895 "CTRL-EVENT-CONNECTED",
896 NULL
897 };
Jouni Malinen3d291f72017-11-02 11:31:05 +0200898 const char *groups_override = NULL;
Jouni Malinen772299f2017-11-06 00:36:26 +0200899 const char *result;
Jouni Malinend1e22f72017-12-05 21:12:17 +0200900 int check_mutual = 0;
Jouni Malinene89cdbf2017-12-11 20:18:24 +0200901 int enrollee_ap;
Jouni Malinenf2fa0d02018-01-11 20:51:31 +0200902 int force_gas_fragm = 0;
Jouni Malinen85a5a2e2018-04-10 21:40:18 +0300903 int not_dpp_akm = 0;
Jouni Malinend86e5822017-08-29 03:55:32 +0300904
905 if (!wait_conn)
906 wait_conn = "no";
907 if (!self_conf)
908 self_conf = "no";
909
910 if (!auth_role) {
911 send_resp(dut, conn, SIGMA_ERROR,
912 "errorCode,Missing DPPAuthRole");
913 return 0;
914 }
915
916 if (!prov_role) {
917 send_resp(dut, conn, SIGMA_ERROR,
918 "errorCode,Missing DPPProvisioningRole");
919 return 0;
920 }
921
Jouni Malinene89cdbf2017-12-11 20:18:24 +0200922 val = get_param(cmd, "DPPConfEnrolleeRole");
923 if (val)
924 enrollee_ap = strcasecmp(val, "AP") == 0;
925 else
926 enrollee_ap = sigma_dut_is_ap(dut);
927
Jouni Malinen3a6b92a2017-12-05 20:22:43 +0200928 if ((step || frametype) && (!step || !frametype)) {
Jouni Malinen772299f2017-11-06 00:36:26 +0200929 send_resp(dut, conn, SIGMA_ERROR,
930 "errorCode,Invalid DPPStep,DPPFrameType,DPPIEAttribute combination");
931 return 0;
932 }
933
Jouni Malinend86e5822017-08-29 03:55:32 +0300934 if (sigma_dut_is_ap(dut)) {
935 if (!dut->hostapd_ifname) {
936 sigma_dut_print(dut, DUT_MSG_ERROR,
937 "hostapd ifname not specified (-j)");
938 return -2;
939 }
940 ifname = dut->hostapd_ifname;
941
942 if (dpp_hostapd_run(dut) < 0) {
943 send_resp(dut, conn, SIGMA_ERROR,
944 "errorCode,Failed to start hostapd");
945 return 0;
946 }
947 }
948
Jouni Malinen67acb0c2017-11-21 01:01:54 +0200949 if (strcasecmp(prov_role, "Configurator") == 0 ||
950 strcasecmp(prov_role, "Both") == 0) {
Jouni Malinend86e5822017-08-29 03:55:32 +0300951 if (dut->dpp_conf_id < 0) {
952 snprintf(buf, sizeof(buf),
953 "DPP_CONFIGURATOR_ADD curve=%s",
954 dpp_get_curve(cmd, "DPPSigningKeyECC"));
955 if (wpa_command_resp(ifname, buf,
956 buf, sizeof(buf)) < 0) {
957 send_resp(dut, conn, SIGMA_ERROR,
958 "errorCode,Failed to set up configurator");
959 return 0;
960 }
961 dut->dpp_conf_id = atoi(buf);
962 }
Jouni Malinen67acb0c2017-11-21 01:01:54 +0200963 if (strcasecmp(prov_role, "Configurator") == 0)
964 role = "configurator";
965 else
966 role = "either";
Jouni Malinend86e5822017-08-29 03:55:32 +0300967 } else if (strcasecmp(prov_role, "Enrollee") == 0) {
968 role = "enrollee";
969 } else {
970 send_resp(dut, conn, SIGMA_ERROR,
971 "errorCode,Unknown DPPProvisioningRole");
972 return 0;
973 }
974
975 pkex_identifier[0] = '\0';
976 if (strcasecmp(bs, "PKEX") == 0) {
Jouni Malinen4f47a272017-11-04 12:29:11 +0200977 if (sigma_dut_is_ap(dut) && dut->ap_channel != 6) {
978 /* For now, have to make operating channel match DPP
979 * listen channel. This should be removed once hostapd
980 * has support for DPP listen on non-operating channel.
981 */
982 sigma_dut_print(dut, DUT_MSG_INFO,
983 "Update hostapd operating channel to match listen needs");
984 dut->ap_channel = 6;
priyadharshini gowthamanb4de1962018-01-15 12:21:04 -0800985
986 if (get_driver_type() == DRIVER_OPENWRT) {
987 snprintf(buf, sizeof(buf),
988 "iwconfig %s channel %d",
989 dut->hostapd_ifname, dut->ap_channel);
990 run_system(dut, buf);
991 }
992
Jouni Malinen4f47a272017-11-04 12:29:11 +0200993 if (wpa_command(ifname, "SET channel 6") < 0 ||
994 wpa_command(ifname, "DISABLE") < 0 ||
995 wpa_command(ifname, "ENABLE") < 0) {
996 send_resp(dut, conn, SIGMA_ERROR,
997 "errorCode,Failed to update channel");
998 return 0;
999 }
1000 }
1001
Jouni Malinend86e5822017-08-29 03:55:32 +03001002 if (!pkex_code) {
1003 send_resp(dut, conn, SIGMA_ERROR,
1004 "errorCode,Missing DPPPKEXCode");
1005 return 0;
1006 }
1007
1008 if (pkex_code_id)
1009 snprintf(pkex_identifier, sizeof(pkex_identifier),
1010 "identifier=%s ", pkex_code_id);
1011
1012 snprintf(buf, sizeof(buf),
1013 "DPP_BOOTSTRAP_GEN type=pkex curve=%s",
1014 dpp_get_curve(cmd, "DPPCryptoIdentifier"));
1015 if (wpa_command_resp(ifname, buf, buf, sizeof(buf)) < 0) {
1016 send_resp(dut, conn, SIGMA_ERROR,
1017 "errorCode,Failed to set up PKEX");
1018 return 0;
1019 }
1020 own_pkex_id = atoi(buf);
1021 }
1022
1023 ctrl = open_wpa_mon(ifname);
1024 if (!ctrl) {
1025 sigma_dut_print(dut, DUT_MSG_ERROR,
1026 "Failed to open wpa_supplicant monitor connection");
1027 return -2;
1028 }
1029
1030 old_timeout = dut->default_timeout;
1031 val = get_param(cmd, "DPPTimeout");
1032 if (val && atoi(val) > 0) {
1033 dut->default_timeout = atoi(val);
1034 sigma_dut_print(dut, DUT_MSG_DEBUG, "DPP timeout: %u",
1035 dut->default_timeout);
1036 }
1037
1038 conf_ssid[0] = '\0';
1039 conf_pass[0] = '\0';
1040 val = get_param(cmd, "DPPConfIndex");
1041 if (val)
1042 conf_index = atoi(val);
Jouni Malinend86e5822017-08-29 03:55:32 +03001043 switch (conf_index) {
Jouni Malinen258cc262017-10-13 00:19:56 +03001044 case -1:
1045 conf_role = NULL;
1046 break;
Jouni Malinend86e5822017-08-29 03:55:32 +03001047 case 1:
1048 ascii2hexstr("DPPNET01", buf);
1049 snprintf(conf_ssid, sizeof(conf_ssid), "ssid=%s", buf);
Jouni Malinene89cdbf2017-12-11 20:18:24 +02001050 if (enrollee_ap) {
Jouni Malinend86e5822017-08-29 03:55:32 +03001051 conf_role = "ap-dpp";
Jouni Malinen3d291f72017-11-02 11:31:05 +02001052 groups_override = "[{\"groupId\":\"DPPGROUP_DPP_INFRA\",\"netRole\":\"ap\"}]";
1053 } else {
Jouni Malinend86e5822017-08-29 03:55:32 +03001054 conf_role = "sta-dpp";
Jouni Malinen3d291f72017-11-02 11:31:05 +02001055 groups_override = "[{\"groupId\":\"DPPGROUP_DPP_INFRA\",\"netRole\":\"sta\"}]";
1056 }
Jouni Malinend86e5822017-08-29 03:55:32 +03001057 break;
1058 case 2:
1059 ascii2hexstr("DPPNET01", buf);
1060 snprintf(conf_ssid, sizeof(conf_ssid), "ssid=%s", buf);
Jouni Malinen8f81cdf2017-09-15 18:15:18 +03001061 snprintf(conf_pass, sizeof(conf_pass),
1062 "psk=10506e102ad1e7f95112f6b127675bb8344dacacea60403f3fa4055aec85b0fc");
Jouni Malinene89cdbf2017-12-11 20:18:24 +02001063 if (enrollee_ap)
Jouni Malinend86e5822017-08-29 03:55:32 +03001064 conf_role = "ap-psk";
1065 else
1066 conf_role = "sta-psk";
1067 break;
1068 case 3:
1069 ascii2hexstr("DPPNET01", buf);
1070 snprintf(conf_ssid, sizeof(conf_ssid), "ssid=%s", buf);
1071 ascii2hexstr("ThisIsDppPassphrase", buf);
1072 snprintf(conf_pass, sizeof(conf_pass), "pass=%s", buf);
Jouni Malinene89cdbf2017-12-11 20:18:24 +02001073 if (enrollee_ap)
Jouni Malinend86e5822017-08-29 03:55:32 +03001074 conf_role = "ap-psk";
1075 else
1076 conf_role = "sta-psk";
1077 break;
Jouni Malinen3d291f72017-11-02 11:31:05 +02001078 case 4:
1079 ascii2hexstr("DPPNET01", buf);
1080 snprintf(conf_ssid, sizeof(conf_ssid), "ssid=%s", buf);
Jouni Malinene89cdbf2017-12-11 20:18:24 +02001081 if (enrollee_ap) {
Jouni Malinen3d291f72017-11-02 11:31:05 +02001082 conf_role = "ap-dpp";
1083 groups_override = "[{\"groupId\":\"DPPGROUP_DPP_INFRA2\",\"netRole\":\"ap\"}]";
1084 } else {
1085 conf_role = "sta-dpp";
1086 groups_override = "[{\"groupId\":\"DPPGROUP_DPP_INFRA2\",\"netRole\":\"sta\"}]";
1087 }
1088 break;
Jouni Malinen7d031c72018-01-09 19:39:56 +02001089 case 5:
1090 ascii2hexstr("DPPNET01", buf);
1091 snprintf(conf_ssid, sizeof(conf_ssid), "ssid=%s", buf);
1092 ascii2hexstr("ThisIsDppPassphrase", buf);
1093 snprintf(conf_pass, sizeof(conf_pass), "pass=%s", buf);
1094 if (enrollee_ap)
1095 conf_role = "ap-sae";
1096 else
1097 conf_role = "sta-sae";
1098 break;
1099 case 6:
1100 ascii2hexstr("DPPNET01", buf);
1101 snprintf(conf_ssid, sizeof(conf_ssid), "ssid=%s", buf);
1102 ascii2hexstr("ThisIsDppPassphrase", buf);
1103 snprintf(conf_pass, sizeof(conf_pass), "pass=%s", buf);
1104 if (enrollee_ap)
1105 conf_role = "ap-psk-sae";
1106 else
1107 conf_role = "sta-psk-sae";
1108 break;
Jouni Malinenf2fa0d02018-01-11 20:51:31 +02001109 case 7:
1110 ascii2hexstr("DPPNET01", buf);
1111 snprintf(conf_ssid, sizeof(conf_ssid), "ssid=%s", buf);
1112 if (enrollee_ap) {
1113 conf_role = "ap-dpp";
1114 groups_override = "[{\"groupId\":\"DPPGROUP_DPP_INFRA\",\"netRole\":\"ap\"}]";
1115 } else {
1116 conf_role = "sta-dpp";
1117 groups_override = "[{\"groupId\":\"DPPGROUP_DPP_INFRA\",\"netRole\":\"sta\"}]";
1118 }
1119 force_gas_fragm = 1;
1120 break;
Jouni Malinenf7490762017-10-12 00:34:37 +03001121 default:
1122 send_resp(dut, conn, SIGMA_ERROR,
1123 "errorCode,Unsupported DPPConfIndex");
1124 goto out;
Jouni Malinend86e5822017-08-29 03:55:32 +03001125 }
1126
Jouni Malinen3d291f72017-11-02 11:31:05 +02001127 if (groups_override) {
Jouni Malinen2b2230f2018-02-12 13:05:06 +02001128 snprintf(buf, sizeof(buf), "SET dpp_groups_override %s",
1129 groups_override);
Jouni Malinen3d291f72017-11-02 11:31:05 +02001130 if (wpa_command(ifname, buf) < 0) {
1131 send_resp(dut, conn, SIGMA_ERROR,
1132 "errorCode,Failed to set cred:groups");
1133 goto out;
1134 }
1135 }
1136
Jouni Malinen2b2230f2018-02-12 13:05:06 +02001137 if (force_gas_fragm) {
1138 char spaces[1500];
1139
1140 memset(spaces, ' ', sizeof(spaces));
1141 spaces[sizeof(spaces) - 1] = '\0';
1142
1143 snprintf(buf, sizeof(buf),
1144 "SET dpp_discovery_override {\"ssid\":\"DPPNET01\"}%s",
1145 spaces);
1146 if (wpa_command(ifname, buf) < 0) {
1147 send_resp(dut, conn, SIGMA_ERROR,
1148 "errorCode,Failed to set discovery override");
1149 goto out;
1150 }
1151 }
1152
Jouni Malinen772299f2017-11-06 00:36:26 +02001153 if (step) {
1154 int test;
1155
1156 test = dpp_get_test(step, frametype, attr);
1157 if (test <= 0) {
1158 send_resp(dut, conn, SIGMA_ERROR,
1159 "errorCode,Unsupported DPPStep/DPPFrameType/DPPIEAttribute");
1160 goto out;
1161 }
1162
1163 snprintf(buf, sizeof(buf), "SET dpp_test %d", test);
1164 if (wpa_command(ifname, buf) < 0) {
1165 send_resp(dut, conn, SIGMA_ERROR,
1166 "errorCode,Failed to set dpp_test");
1167 goto out;
1168 }
1169 } else {
1170 wpa_command(ifname, "SET dpp_test 0");
1171 }
1172
Jouni Malinenfbb268d2017-11-17 18:53:49 +02001173 if (strcasecmp(self_conf, "Yes") == 0) {
1174 if (strcasecmp(prov_role, "Configurator") != 0) {
1175 send_resp(dut, conn, SIGMA_ERROR,
1176 "errorCode,Invalid DPPSelfConfigure use - only allowed for Configurator role");
1177 goto out;
1178 }
1179 if (!conf_role) {
1180 send_resp(dut, conn, SIGMA_ERROR,
1181 "errorCode,Missing DPPConfIndex");
1182 goto out;
1183 }
1184
1185 snprintf(buf, sizeof(buf),
1186 "DPP_CONFIGURATOR_SIGN conf=%s %s %s configurator=%d",
1187 conf_role, conf_ssid, conf_pass, dut->dpp_conf_id);
1188 if (wpa_command(ifname, buf) < 0) {
1189 send_resp(dut, conn, SIGMA_ERROR,
1190 "errorCode,Failed to initiate DPP self-configuration");
1191 goto out;
1192 }
Jouni Malinen174db642017-11-27 20:16:29 +02001193 if (sigma_dut_is_ap(dut))
1194 goto update_ap;
Jouni Malinenfbb268d2017-11-17 18:53:49 +02001195 goto wait_connect;
1196 } else if (strcasecmp(auth_role, "Initiator") == 0) {
Jouni Malinend86e5822017-08-29 03:55:32 +03001197 char own_txt[20];
Jouni Malinenb1dd21f2017-11-13 19:14:29 +02001198 int dpp_peer_bootstrap = -1;
Jouni Malinenb5ab8282017-11-21 01:12:22 +02001199 char neg_freq[30];
1200
Jouni Malinend1e22f72017-12-05 21:12:17 +02001201 val = get_param(cmd, "DPPAuthDirection");
1202 check_mutual = val && strcasecmp(val, "Mutual") == 0;
1203
Jouni Malinenb5ab8282017-11-21 01:12:22 +02001204 neg_freq[0] = '\0';
1205 val = get_param(cmd, "DPPSubsequentChannel");
1206 if (val) {
1207 int opclass, channel, freq;
1208
1209 opclass = atoi(val);
1210 val = strchr(val, '/');
1211 if (opclass == 0 || !val) {
1212 send_resp(dut, conn, SIGMA_ERROR,
1213 "errorCode,Invalid DPPSubsequentChannel");
1214 goto out;
1215 }
1216 val++;
1217 channel = atoi(val);
1218
1219 /* Ignoring opclass for now; could use it here for more
1220 * robust frequency determination. */
1221 freq = channel_to_freq(channel);
1222 if (!freq) {
1223 send_resp(dut, conn, SIGMA_ERROR,
1224 "errorCode,Unsupported DPPSubsequentChannel channel");
1225 goto out;
1226 }
1227 snprintf(neg_freq, sizeof(neg_freq), " neg_freq=%d",
1228 freq);
1229 }
Jouni Malinenb1dd21f2017-11-13 19:14:29 +02001230
1231 if (strcasecmp(bs, "QR") == 0) {
1232 if (!dut->dpp_peer_uri) {
1233 send_resp(dut, conn, SIGMA_ERROR,
1234 "errorCode,Missing peer bootstrapping info");
1235 goto out;
1236 }
1237
1238 snprintf(buf, sizeof(buf), "DPP_QR_CODE %s",
1239 dut->dpp_peer_uri);
1240 if (wpa_command_resp(ifname, buf, buf,
Jouni Malinen3c27aa82018-03-21 12:04:03 +02001241 sizeof(buf)) < 0 ||
1242 strncmp(buf, "FAIL", 4) == 0) {
Jouni Malinenb1dd21f2017-11-13 19:14:29 +02001243 send_resp(dut, conn, SIGMA_ERROR,
1244 "errorCode,Failed to parse URI");
1245 goto out;
1246 }
1247 dpp_peer_bootstrap = atoi(buf);
1248 }
Jouni Malinend86e5822017-08-29 03:55:32 +03001249
Jouni Malinen63d50412017-11-24 11:55:38 +02001250 if (dut->dpp_local_bootstrap >= 0)
Jouni Malinend86e5822017-08-29 03:55:32 +03001251 snprintf(own_txt, sizeof(own_txt), " own=%d",
1252 dut->dpp_local_bootstrap);
1253 else
1254 own_txt[0] = '\0';
1255 if (strcasecmp(bs, "QR") == 0 &&
Jouni Malinen67acb0c2017-11-21 01:01:54 +02001256 (strcasecmp(prov_role, "Configurator") == 0 ||
1257 strcasecmp(prov_role, "Both") == 0)) {
Jouni Malinen258cc262017-10-13 00:19:56 +03001258 if (!conf_role) {
1259 send_resp(dut, conn, SIGMA_ERROR,
1260 "errorCode,Missing DPPConfIndex");
1261 goto out;
1262 }
Jouni Malinend86e5822017-08-29 03:55:32 +03001263 snprintf(buf, sizeof(buf),
Jouni Malinenb5ab8282017-11-21 01:12:22 +02001264 "DPP_AUTH_INIT peer=%d%s role=%s conf=%s %s %s configurator=%d%s",
Jouni Malinenb1dd21f2017-11-13 19:14:29 +02001265 dpp_peer_bootstrap, own_txt, role,
Jouni Malinend86e5822017-08-29 03:55:32 +03001266 conf_role, conf_ssid, conf_pass,
Jouni Malinenb5ab8282017-11-21 01:12:22 +02001267 dut->dpp_conf_id, neg_freq);
Jouni Malinend86e5822017-08-29 03:55:32 +03001268 } else if (strcasecmp(bs, "QR") == 0) {
1269 snprintf(buf, sizeof(buf),
Jouni Malinenb5ab8282017-11-21 01:12:22 +02001270 "DPP_AUTH_INIT peer=%d%s role=%s%s",
1271 dpp_peer_bootstrap, own_txt, role, neg_freq);
Jouni Malinend86e5822017-08-29 03:55:32 +03001272 } else if (strcasecmp(bs, "PKEX") == 0 &&
Jouni Malinen67acb0c2017-11-21 01:01:54 +02001273 (strcasecmp(prov_role, "Configurator") == 0 ||
1274 strcasecmp(prov_role, "Both") == 0)) {
Jouni Malinen258cc262017-10-13 00:19:56 +03001275 if (!conf_role) {
1276 send_resp(dut, conn, SIGMA_ERROR,
1277 "errorCode,Missing DPPConfIndex");
1278 goto out;
1279 }
Jouni Malinend86e5822017-08-29 03:55:32 +03001280 snprintf(buf, sizeof(buf),
1281 "DPP_PKEX_ADD own=%d init=1 role=%s conf=%s %s %s configurator=%d %scode=%s",
1282 own_pkex_id, role, conf_role,
1283 conf_ssid, conf_pass, dut->dpp_conf_id,
1284 pkex_identifier, pkex_code);
1285 } else if (strcasecmp(bs, "PKEX") == 0) {
1286 snprintf(buf, sizeof(buf),
1287 "DPP_PKEX_ADD own=%d init=1 role=%s %scode=%s",
1288 own_pkex_id, role, pkex_identifier, pkex_code);
Jouni Malinend551c6f2017-10-12 00:32:18 +03001289 } else {
1290 send_resp(dut, conn, SIGMA_ERROR,
1291 "errorCode,Unsupported DPPBS");
1292 goto out;
Jouni Malinend86e5822017-08-29 03:55:32 +03001293 }
1294 if (wpa_command(ifname, buf) < 0) {
1295 send_resp(dut, conn, SIGMA_ERROR,
1296 "errorCode,Failed to initiate DPP authentication");
1297 goto out;
1298 }
1299 } else if (strcasecmp(auth_role, "Responder") == 0) {
Jouni Malinen67f096a2017-11-24 11:58:51 +02001300 const char *delay_qr_resp;
Jouni Malinen63d50412017-11-24 11:55:38 +02001301 int mutual;
Jouni Malinend3afc5c2017-11-13 18:39:14 +02001302 int freq = 2462; /* default: channel 11 */
1303
Jouni Malinen06cfcb32018-01-11 20:43:50 +02001304 if (strcasecmp(bs, "PKEX") == 0) {
1305 /* default: channel 6 for PKEX */
1306 freq = 2437;
1307 }
1308
Jouni Malinen67f096a2017-11-24 11:58:51 +02001309 delay_qr_resp = get_param(cmd, "DPPDelayQRResponse");
1310
Jouni Malinen63d50412017-11-24 11:55:38 +02001311 val = get_param(cmd, "DPPAuthDirection");
1312 mutual = val && strcasecmp(val, "Mutual") == 0;
1313
Jouni Malinend3afc5c2017-11-13 18:39:14 +02001314 val = get_param(cmd, "DPPListenChannel");
1315 if (val) {
1316 freq = channel_to_freq(atoi(val));
1317 if (freq == 0) {
1318 send_resp(dut, conn, SIGMA_ERROR,
1319 "errorCode,Unsupported DPPListenChannel value");
1320 goto out;
1321 }
1322 }
Jouni Malinend86e5822017-08-29 03:55:32 +03001323
Jouni Malinenb1dd21f2017-11-13 19:14:29 +02001324 if (!delay_qr_resp && dut->dpp_peer_uri) {
1325 snprintf(buf, sizeof(buf), "DPP_QR_CODE %s",
1326 dut->dpp_peer_uri);
1327 if (wpa_command_resp(ifname, buf, buf,
1328 sizeof(buf)) < 0) {
1329 send_resp(dut, conn, SIGMA_ERROR,
1330 "errorCode,Failed to parse URI");
1331 goto out;
1332 }
1333 }
1334
Jouni Malinend86e5822017-08-29 03:55:32 +03001335 if (strcasecmp(prov_role, "Configurator") == 0) {
Jouni Malinen258cc262017-10-13 00:19:56 +03001336 if (!conf_role) {
1337 send_resp(dut, conn, SIGMA_ERROR,
1338 "errorCode,Missing DPPConfIndex");
1339 goto out;
1340 }
Jouni Malinend86e5822017-08-29 03:55:32 +03001341 snprintf(buf, sizeof(buf),
1342 "SET dpp_configurator_params conf=%s %s %s configurator=%d",
1343 conf_role, conf_ssid, conf_pass,
1344 dut->dpp_conf_id);
1345 if (wpa_command(ifname, buf) < 0) {
1346 send_resp(dut, conn, SIGMA_ERROR,
1347 "errorCode,Failed to set configurator parameters");
1348 goto out;
1349 }
1350 }
1351 if (strcasecmp(bs, "PKEX") == 0) {
Jouni Malinend86e5822017-08-29 03:55:32 +03001352 snprintf(buf, sizeof(buf),
1353 "DPP_PKEX_ADD own=%d role=%s %scode=%s",
1354 own_pkex_id, role, pkex_identifier, pkex_code);
1355 if (wpa_command(ifname, buf) < 0) {
1356 send_resp(dut, conn, SIGMA_ERROR,
1357 "errorCode,Failed to configure DPP PKEX");
1358 goto out;
1359 }
1360 }
1361
Jouni Malinenbafc1932017-11-04 11:31:16 +02001362 snprintf(buf, sizeof(buf), "DPP_LISTEN %d role=%s%s",
1363 freq, role,
1364 (strcasecmp(bs, "QR") == 0 && mutual) ?
1365 " qr=mutual" : "");
1366 if (wpa_command(ifname, buf) < 0) {
1367 send_resp(dut, conn, SIGMA_ERROR,
1368 "errorCode,Failed to start DPP listen");
1369 goto out;
Jouni Malinend86e5822017-08-29 03:55:32 +03001370 }
Jouni Malinenb1dd21f2017-11-13 19:14:29 +02001371
priyadharshini gowthamanb4de1962018-01-15 12:21:04 -08001372 if (get_driver_type() == DRIVER_OPENWRT) {
1373 snprintf(buf, sizeof(buf), "iwconfig %s channel %d",
1374 dut->hostapd_ifname, freq_to_channel(freq));
1375 run_system(dut, buf);
1376 }
1377
Jouni Malinenb1dd21f2017-11-13 19:14:29 +02001378 if (delay_qr_resp && mutual && dut->dpp_peer_uri) {
1379 int wait_time = atoi(delay_qr_resp);
1380
1381 res = get_wpa_cli_events(dut, ctrl, auth_events,
1382 buf, sizeof(buf));
1383 if (res < 0) {
1384 send_resp(dut, conn, SIGMA_COMPLETE,
1385 "BootstrapResult,OK,AuthResult,Timeout");
1386 goto out;
1387 }
1388 sigma_dut_print(dut, DUT_MSG_DEBUG,
1389 "DPP auth result: %s", buf);
1390 if (strstr(buf, "DPP-SCAN-PEER-QR-CODE") == NULL) {
1391 send_resp(dut, conn, SIGMA_ERROR,
1392 "errorCode,No scan request for peer QR Code seen");
1393 goto out;
1394 }
1395 sigma_dut_print(dut, DUT_MSG_INFO,
1396 "Waiting %d second(s) before processing peer URI",
1397 wait_time);
1398 sleep(wait_time);
1399
1400 snprintf(buf, sizeof(buf), "DPP_QR_CODE %s",
1401 dut->dpp_peer_uri);
1402 if (wpa_command_resp(ifname, buf, buf,
1403 sizeof(buf)) < 0) {
1404 send_resp(dut, conn, SIGMA_ERROR,
1405 "errorCode,Failed to parse URI");
1406 goto out;
1407 }
Srinivas Dasaribc9e0552018-01-04 19:24:28 +05301408 } else if (mutual && action_type &&
1409 strcasecmp(action_type, "ManualDPP") == 0) {
1410 res = get_wpa_cli_events(dut, ctrl, auth_events,
1411 buf, sizeof(buf));
1412 if (res < 0) {
1413 send_resp(dut, conn, SIGMA_COMPLETE,
1414 "BootstrapResult,OK,AuthResult,Timeout");
1415 goto out;
1416 }
1417 sigma_dut_print(dut, DUT_MSG_DEBUG,
1418 "DPP auth result: %s", buf);
Srinivas Dasarie3b13932018-03-26 21:51:40 +05301419 if (strstr(buf, "DPP-NOT-COMPATIBLE")) {
1420 send_resp(dut, conn, SIGMA_COMPLETE,
1421 "BootstrapResult,OK,AuthResult,ROLES_NOT_COMPATIBLE");
1422 goto out;
1423 }
1424
Srinivas Dasaribc9e0552018-01-04 19:24:28 +05301425 if (strstr(buf, "DPP-SCAN-PEER-QR-CODE") == NULL) {
1426 send_resp(dut, conn, SIGMA_ERROR,
1427 "errorCode,No scan request for peer QR Code seen");
1428 goto out;
1429 }
1430
1431 if (dpp_scan_peer_qrcode(dut) < 0) {
1432 send_resp(dut, conn, SIGMA_ERROR,
1433 "errorCode,Failed to scan peer QR Code");
1434 goto out;
1435 }
1436
1437 snprintf(buf, sizeof(buf), "DPP_QR_CODE %s",
1438 dut->dpp_peer_uri);
1439 if (wpa_command_resp(ifname, buf, buf,
1440 sizeof(buf)) < 0) {
1441 send_resp(dut, conn, SIGMA_ERROR,
1442 "errorCode,Failed to parse URI");
1443 goto out;
1444 }
Jouni Malinenb1dd21f2017-11-13 19:14:29 +02001445 }
Jouni Malinend86e5822017-08-29 03:55:32 +03001446 } else {
1447 send_resp(dut, conn, SIGMA_ERROR,
1448 "errorCode,Unknown DPPAuthRole");
1449 goto out;
1450 }
1451
Jouni Malinen3a6b92a2017-12-05 20:22:43 +02001452 if (step && strcasecmp(step, "Timeout") == 0) {
1453 result = "errorCode,Unexpected state";
1454
1455 if (strcasecmp(frametype, "PKEXExchangeResponse") == 0) {
Jouni Malinen9a3415c2018-01-10 22:12:22 +02001456 if (dpp_wait_rx(dut, ctrl, 8, -1) < 0)
Jouni Malinen3a6b92a2017-12-05 20:22:43 +02001457 result = "BootstrapResult,Timeout";
1458 else
1459 result = "BootstrapResult,Errorsent";
1460 }
1461
1462 if (strcasecmp(frametype, "PKEXCRRequest") == 0) {
Jouni Malinen9a3415c2018-01-10 22:12:22 +02001463 if (dpp_wait_rx(dut, ctrl, 9, -1) < 0)
Jouni Malinen3a6b92a2017-12-05 20:22:43 +02001464 result = "BootstrapResult,Timeout";
1465 else
1466 result = "BootstrapResult,Errorsent";
1467 }
1468
1469 if (strcasecmp(frametype, "PKEXCRResponse") == 0) {
Jouni Malinen9a3415c2018-01-10 22:12:22 +02001470 if (dpp_wait_rx(dut, ctrl, 10, -1) < 0)
Jouni Malinen3a6b92a2017-12-05 20:22:43 +02001471 result = "BootstrapResult,Timeout";
1472 else
1473 result = "BootstrapResult,Errorsent";
1474 }
1475
1476 if (strcasecmp(frametype, "AuthenticationRequest") == 0) {
Jouni Malinen9a3415c2018-01-10 22:12:22 +02001477 if (dpp_wait_rx(dut, ctrl, 0, -1) < 0)
Jouni Malinen3a6b92a2017-12-05 20:22:43 +02001478 result = "BootstrapResult,OK,AuthResult,Timeout";
1479 else
1480 result = "BootstrapResult,OK,AuthResult,Errorsent";
1481 }
1482
1483 if (strcasecmp(frametype, "AuthenticationResponse") == 0) {
Jouni Malinen9a3415c2018-01-10 22:12:22 +02001484 if (dpp_wait_rx(dut, ctrl, 1, -1) < 0)
Jouni Malinen3a6b92a2017-12-05 20:22:43 +02001485 result = "BootstrapResult,OK,AuthResult,Timeout";
1486 else
1487 result = "BootstrapResult,OK,AuthResult,Errorsent";
1488 }
1489
1490 if (strcasecmp(frametype, "AuthenticationConfirm") == 0) {
Deepak Dhamdhereecb49d82018-03-08 16:48:28 -08001491 if (strcasecmp(auth_role, "Initiator") == 0) {
Jouni Malinena1199882018-03-28 19:34:59 +03001492 /* This special case of DPPStep,Timeout with
1493 * DPPFrameType,AuthenticationConfirm on an
1494 * Initiator is used to cover need for stopping
1495 * the Initiator/Enrollee from sending out
1496 * Configuration Request message. */
1497 if (strcasecmp(prov_role, "Enrollee") != 0) {
1498 send_resp(dut, conn, SIGMA_ERROR,
1499 "errorCode,Unexpected use of timeout after AuthenticationConfirm TX in Configurator role");
1500 goto out;
1501 }
Srinivas Dasari671c9e12018-03-26 17:57:34 +05301502 if (check_mutual &&
1503 dpp_process_auth_response(
1504 dut, conn, ctrl, auth_events,
1505 action_type, check_mutual,
1506 buf, sizeof(buf)) < 0)
1507 goto out;
Deepak Dhamdhereecb49d82018-03-08 16:48:28 -08001508 if (dpp_wait_tx_status(dut, ctrl, 2) < 0)
1509 result = "BootstrapResult,OK,AuthResult,Timeout";
Deepak Dhamdhereecb49d82018-03-08 16:48:28 -08001510 else
Jouni Malinena1199882018-03-28 19:34:59 +03001511 result = "BootstrapResult,OK,AuthResult,Errorsent,LastFrameReceived,AuthenticationResponse";
Deepak Dhamdhereecb49d82018-03-08 16:48:28 -08001512 } else {
1513 if (dpp_wait_rx(dut, ctrl, 2, -1) < 0)
1514 result = "BootstrapResult,OK,AuthResult,Timeout";
1515 else
1516 result = "BootstrapResult,OK,AuthResult,Errorsent,LastFrameReceived,AuthenticationConfirm";
1517 }
Jouni Malinen3a6b92a2017-12-05 20:22:43 +02001518 }
1519
1520 if (strcasecmp(frametype, "ConfigurationRequest") == 0) {
1521 if (get_wpa_cli_event(dut, ctrl, "DPP-CONF-FAILED",
1522 buf, sizeof(buf)) < 0)
1523 result = "BootstrapResult,OK,AuthResult,OK,ConfResult,Timeout";
1524 else
1525 result = "BootstrapResult,OK,AuthResult,OK,ConfResult,Errorsent";
1526 }
1527
1528 send_resp(dut, conn, SIGMA_COMPLETE, result);
1529 goto out;
1530 }
1531
Jouni Malinen772299f2017-11-06 00:36:26 +02001532 if (frametype && strcasecmp(frametype, "PKEXExchangeRequest") == 0) {
1533 if (dpp_wait_tx_status(dut, ctrl, 7) < 0)
1534 result = "BootstrapResult,Timeout";
1535 else
1536 result = "BootstrapResult,Errorsent";
1537 send_resp(dut, conn, SIGMA_COMPLETE, result);
1538 goto out;
1539 }
1540
1541 if (frametype && strcasecmp(frametype, "PKEXExchangeResponse") == 0) {
1542 if (dpp_wait_tx_status(dut, ctrl, 8) < 0)
1543 result = "BootstrapResult,Timeout";
1544 else
1545 result = "BootstrapResult,Errorsent";
1546 send_resp(dut, conn, SIGMA_COMPLETE, result);
1547 goto out;
1548 }
1549
1550 if (frametype && strcasecmp(frametype, "PKEXCRRequest") == 0) {
1551 if (dpp_wait_tx_status(dut, ctrl, 9) < 0)
1552 result = "BootstrapResult,Timeout";
1553 else
1554 result = "BootstrapResult,Errorsent";
1555 send_resp(dut, conn, SIGMA_COMPLETE, result);
1556 goto out;
1557 }
1558
1559 if (frametype && strcasecmp(frametype, "PKEXCRResponse") == 0) {
1560 if (dpp_wait_tx_status(dut, ctrl, 10) < 0)
1561 result = "BootstrapResult,Timeout";
1562 else
1563 result = "BootstrapResult,Errorsent";
1564 send_resp(dut, conn, SIGMA_COMPLETE, result);
1565 goto out;
1566 }
1567
Jouni Malinen6792ff42018-02-13 00:25:56 +02001568 if (!frametype && strcasecmp(bs, "PKEX") == 0 &&
1569 strcasecmp(auth_role, "Responder") == 0) {
1570 if (dpp_wait_tx_status(dut, ctrl, 10) < 0) {
1571 send_resp(dut, conn, SIGMA_COMPLETE,
1572 "BootstrapResult,Timeout");
1573 goto out;
1574 }
1575 }
1576
1577 if (!frametype && strcasecmp(bs, "PKEX") == 0 &&
1578 strcasecmp(auth_role, "Initiator") == 0) {
1579 if (dpp_wait_tx(dut, ctrl, 0) < 0) {
1580 send_resp(dut, conn, SIGMA_COMPLETE,
1581 "BootstrapResult,Timeout");
1582 goto out;
1583 }
1584 }
1585
Jouni Malinen772299f2017-11-06 00:36:26 +02001586 if (frametype && strcasecmp(frametype, "AuthenticationRequest") == 0) {
Jouni Malinen9a3415c2018-01-10 22:12:22 +02001587 if (dpp_wait_tx_status(dut, ctrl, 0) < 0) {
1588 send_resp(dut, conn, SIGMA_COMPLETE,
1589 "BootstrapResult,OK,AuthResult,Timeout");
1590 goto out;
1591 }
1592
1593 if (dpp_wait_rx(dut, ctrl, 1, 5) < 0)
1594 result = "BootstrapResult,OK,AuthResult,Errorsent,LastFrameReceived,None";
Deepak Dhamdhereb9f1eb92018-03-08 16:36:22 -08001595 else if (get_wpa_cli_events(dut, ctrl, auth_events,
1596 buf, sizeof(buf)) >= 0 &&
1597 strstr(buf, "DPP-RESPONSE-PENDING") != NULL)
1598 result = "BootstrapResult,OK,AuthResult,Errorsent,LastFrameReceived,AuthenticationResponseWithStatusPending";
Jouni Malinen772299f2017-11-06 00:36:26 +02001599 else
Jouni Malinen9a3415c2018-01-10 22:12:22 +02001600 result = "BootstrapResult,OK,AuthResult,Errorsent,LastFrameReceived,AuthenticationResponse";
Jouni Malinen772299f2017-11-06 00:36:26 +02001601 send_resp(dut, conn, SIGMA_COMPLETE, result);
1602 goto out;
1603 }
1604
1605 if (frametype && strcasecmp(frametype, "AuthenticationResponse") == 0) {
Jouni Malinen9a3415c2018-01-10 22:12:22 +02001606 if (dpp_wait_tx_status(dut, ctrl, 1) < 0) {
1607 send_resp(dut, conn, SIGMA_COMPLETE,
1608 "BootstrapResult,OK,AuthResult,Timeout");
1609 goto out;
1610 }
1611
1612 if (dpp_wait_rx(dut, ctrl, 2, 5) < 0)
1613 result = "BootstrapResult,OK,AuthResult,Errorsent,LastFrameReceived,AuthenticationRequest";
Jouni Malinen772299f2017-11-06 00:36:26 +02001614 else
Jouni Malinen9a3415c2018-01-10 22:12:22 +02001615 result = "BootstrapResult,OK,AuthResult,Errorsent,LastFrameReceived,AuthenticationConfirm";
Jouni Malinen772299f2017-11-06 00:36:26 +02001616 send_resp(dut, conn, SIGMA_COMPLETE, result);
1617 goto out;
1618 }
1619
Srinivas Dasari8d88d822018-03-26 17:57:34 +05301620 if (dpp_process_auth_response(dut, conn, ctrl, auth_events, action_type,
1621 check_mutual, buf, sizeof(buf)) < 0)
Srinivas Dasaribc9e0552018-01-04 19:24:28 +05301622 goto out;
Jouni Malinend1e22f72017-12-05 21:12:17 +02001623
Jouni Malinen772299f2017-11-06 00:36:26 +02001624 if (frametype && strcasecmp(frametype, "AuthenticationConfirm") == 0) {
Jouni Malinen9a3415c2018-01-10 22:12:22 +02001625 if (dpp_wait_tx_status(dut, ctrl, 2) < 0) {
1626 send_resp(dut, conn, SIGMA_COMPLETE,
1627 "BootstrapResult,OK,AuthResult,Timeout");
1628 goto out;
1629 }
1630
1631 if (dpp_wait_rx_conf_req(dut, ctrl, 5) < 0)
1632 result = "BootstrapResult,OK,AuthResult,Errorsent,LastFrameReceived,AuthenticationResponse";
Jouni Malinen772299f2017-11-06 00:36:26 +02001633 else
Jouni Malinen9a3415c2018-01-10 22:12:22 +02001634 result = "BootstrapResult,OK,AuthResult,Errorsent,LastFrameReceived,ConfigurationRequest";
Jouni Malinen772299f2017-11-06 00:36:26 +02001635 send_resp(dut, conn, SIGMA_COMPLETE, result);
1636 goto out;
1637 }
1638
Srinivas Dasaribc9e0552018-01-04 19:24:28 +05301639 if (strstr(buf, "DPP-AUTH-DIRECTION")) {
Jouni Malinen2e9c8a42017-11-19 12:06:18 +02001640 res = get_wpa_cli_events(dut, ctrl, auth_events,
1641 buf, sizeof(buf));
1642 if (res < 0) {
1643 send_resp(dut, conn, SIGMA_COMPLETE,
1644 "BootstrapResult,OK,AuthResult,Timeout");
1645 goto out;
1646 }
Srinivas Dasaribc9e0552018-01-04 19:24:28 +05301647
1648 sigma_dut_print(dut, DUT_MSG_DEBUG, "DPP auth result: %s", buf);
Jouni Malinen2e9c8a42017-11-19 12:06:18 +02001649 }
1650
Jouni Malinend86e5822017-08-29 03:55:32 +03001651 if (strstr(buf, "DPP-NOT-COMPATIBLE")) {
1652 send_resp(dut, conn, SIGMA_COMPLETE,
1653 "BootstrapResult,OK,AuthResult,ROLES_NOT_COMPATIBLE");
1654 goto out;
1655 }
1656
1657 if (!strstr(buf, "DPP-AUTH-SUCCESS")) {
1658 send_resp(dut, conn, SIGMA_COMPLETE,
1659 "BootstrapResult,OK,AuthResult,FAILED");
1660 goto out;
1661 }
1662
Jouni Malinen772299f2017-11-06 00:36:26 +02001663 if (frametype && strcasecmp(frametype, "ConfigurationRequest") == 0) {
1664 res = get_wpa_cli_event(dut, ctrl, "GAS-QUERY-DONE",
1665 buf, sizeof(buf));
1666 if (res < 0)
1667 result = "BootstrapResult,OK,AuthResult,OK,ConfResult,Timeout";
1668 else
1669 result = "BootstrapResult,OK,AuthResult,OK,ConfResult,Errorsent";
1670 send_resp(dut, conn, SIGMA_COMPLETE, result);
1671 goto out;
1672 }
1673
1674 if (frametype && strcasecmp(frametype, "ConfigurationResponse") == 0) {
1675 res = get_wpa_cli_event(dut, ctrl, "DPP-CONF-SENT",
1676 buf, sizeof(buf));
1677 if (res < 0)
1678 result = "BootstrapResult,OK,AuthResult,OK,ConfResult,Timeout";
1679 else
Deepak Dhamdhere9b4f2752018-03-08 16:36:22 -08001680 result = "BootstrapResult,OK,AuthResult,OK,ConfResult,Errorsent,LastFrameReceived,ConfigurationRequest";
Jouni Malinen772299f2017-11-06 00:36:26 +02001681 send_resp(dut, conn, SIGMA_COMPLETE, result);
1682 goto out;
1683 }
1684
Jouni Malinend86e5822017-08-29 03:55:32 +03001685 res = get_wpa_cli_events(dut, ctrl, conf_events, buf, sizeof(buf));
1686 if (res < 0) {
1687 send_resp(dut, conn, SIGMA_COMPLETE,
1688 "BootstrapResult,OK,AuthResult,OK,ConfResult,Timeout");
1689 goto out;
1690 }
1691 sigma_dut_print(dut, DUT_MSG_DEBUG, "DPP conf result: %s", buf);
1692
1693 if (!strstr(buf, "DPP-CONF-SENT") &&
1694 !strstr(buf, "DPP-CONF-RECEIVED")) {
1695 send_resp(dut, conn, SIGMA_COMPLETE,
1696 "BootstrapResult,OK,AuthResult,OK,ConfResult,FAILED");
1697 goto out;
1698 }
1699
1700 if (sigma_dut_is_ap(dut) &&
1701 strcasecmp(prov_role, "Enrollee") == 0) {
Jouni Malinen174db642017-11-27 20:16:29 +02001702 update_ap:
Jouni Malinend86e5822017-08-29 03:55:32 +03001703 res = dpp_hostapd_conf_update(dut, conn, ifname, ctrl);
1704 if (res == 0)
1705 goto out;
1706 if (res < 0) {
1707 send_resp(dut, conn, SIGMA_ERROR, NULL);
1708 goto out;
1709 }
1710 }
1711
1712 if (strcasecmp(wait_conn, "Yes") == 0 &&
1713 !sigma_dut_is_ap(dut) &&
1714 strcasecmp(prov_role, "Enrollee") == 0) {
Jouni Malinen85a5a2e2018-04-10 21:40:18 +03001715 int netw_id;
1716 char *pos;
1717
1718 res = get_wpa_cli_event(dut, ctrl, "DPP-NETWORK-ID",
1719 buf, sizeof(buf));
1720 if (res < 0) {
1721 send_resp(dut, conn, SIGMA_ERROR,
1722 "errorCode,No DPP-NETWORK-ID");
1723 goto out;
1724 }
1725 pos = strchr(buf, ' ');
1726 if (!pos) {
1727 send_resp(dut, conn, SIGMA_ERROR,
1728 "errorCode,Invalid DPP-NETWORK-ID");
1729 goto out;
1730 }
1731 pos++;
1732 netw_id = atoi(pos);
1733 snprintf(buf, sizeof(buf), "GET_NETWORK %d key_mgmt", netw_id);
1734 if (wpa_command_resp(ifname, buf, buf, sizeof(buf)) < 0) {
1735 send_resp(dut, conn, SIGMA_ERROR,
1736 "errorCode,Could not fetch provisioned key_mgmt");
1737 goto out;
1738 }
1739 if (strncmp(buf, "SAE", 3) == 0) {
1740 /* SAE generates PMKSA-CACHE-ADDED event */
1741 not_dpp_akm = 1;
1742 }
Jouni Malinenfbb268d2017-11-17 18:53:49 +02001743 wait_connect:
Jouni Malinen53558e02017-11-06 12:58:28 +02001744 if (frametype && strcasecmp(frametype,
1745 "PeerDiscoveryRequest") == 0) {
1746 if (dpp_wait_tx_status(dut, ctrl, 5) < 0)
1747 result = "BootstrapResult,OK,AuthResult,OK,ConfResult,OK,NetworkIntroResult,Timeout";
1748 else
1749 result = "BootstrapResult,OK,AuthResult,OK,ConfResult,OK,NetworkIntroResult,Errorsent";
1750 send_resp(dut, conn, SIGMA_COMPLETE, result);
1751 goto out;
1752 }
1753
Jouni Malinend86e5822017-08-29 03:55:32 +03001754 res = get_wpa_cli_events(dut, ctrl, conn_events,
1755 buf, sizeof(buf));
1756 if (res < 0) {
1757 send_resp(dut, conn, SIGMA_COMPLETE,
1758 "BootstrapResult,OK,AuthResult,OK,ConfResult,OK,NetworkIntroResult,Timeout,NetworkConnectResult,Timeout");
1759 goto out;
1760 }
1761 sigma_dut_print(dut, DUT_MSG_DEBUG, "DPP connect result: %s",
1762 buf);
1763
1764 if (strstr(buf, "PMKSA-CACHE-ADDED")) {
1765 res = get_wpa_cli_events(dut, ctrl, conn_events,
1766 buf, sizeof(buf));
1767 if (res < 0) {
1768 send_resp(dut, conn, SIGMA_COMPLETE,
Jouni Malinen85a5a2e2018-04-10 21:40:18 +03001769 not_dpp_akm ?
1770 "BootstrapResult,OK,AuthResult,OK,ConfResult,OK,NetworkConnectResult,Timeout" :
Jouni Malinend86e5822017-08-29 03:55:32 +03001771 "BootstrapResult,OK,AuthResult,OK,ConfResult,OK,NetworkIntroResult,OK,NetworkConnectResult,Timeout");
1772 goto out;
1773 }
1774 sigma_dut_print(dut, DUT_MSG_DEBUG,
1775 "DPP connect result: %s", buf);
1776 if (strstr(buf, "CTRL-EVENT-CONNECTED"))
1777 send_resp(dut, conn, SIGMA_COMPLETE,
Jouni Malinen85a5a2e2018-04-10 21:40:18 +03001778 not_dpp_akm ?
1779 "BootstrapResult,OK,AuthResult,OK,ConfResult,OK,NetworkConnectResult,OK" :
Jouni Malinend86e5822017-08-29 03:55:32 +03001780 "BootstrapResult,OK,AuthResult,OK,ConfResult,OK,NetworkIntroResult,OK,NetworkConnectResult,OK");
1781 else
1782 send_resp(dut, conn, SIGMA_COMPLETE,
Jouni Malinen85a5a2e2018-04-10 21:40:18 +03001783 not_dpp_akm ?
1784 "BootstrapResult,OK,AuthResult,OK,ConfResult,OK,NetworkConnectResult,Timeout" :
Jouni Malinend86e5822017-08-29 03:55:32 +03001785 "BootstrapResult,OK,AuthResult,OK,ConfResult,OK,NetworkIntroResult,OK,NetworkConnectResult,Timeout");
1786 goto out;
1787 }
1788
1789 send_resp(dut, conn, SIGMA_COMPLETE,
1790 "BootstrapResult,OK,AuthResult,OK,ConfResult,OK,NetworkConnectResult,OK");
1791 goto out;
1792 }
1793
Jouni Malinen53558e02017-11-06 12:58:28 +02001794 if (strcasecmp(wait_conn, "Yes") == 0 &&
1795 frametype && strcasecmp(frametype, "PeerDiscoveryResponse") == 0) {
1796 if (dpp_wait_tx_status(dut, ctrl, 6) < 0)
1797 result = "BootstrapResult,OK,AuthResult,OK,ConfResult,OK,NetworkIntroResult,Timeout";
1798 else
1799 result = "BootstrapResult,OK,AuthResult,OK,ConfResult,OK,NetworkIntroResult,Errorsent";
1800 send_resp(dut, conn, SIGMA_COMPLETE, result);
1801 goto out;
1802 }
1803
Jouni Malinend86e5822017-08-29 03:55:32 +03001804 send_resp(dut, conn, SIGMA_COMPLETE,
1805 "BootstrapResult,OK,AuthResult,OK,ConfResult,OK");
1806out:
1807 wpa_ctrl_detach(ctrl);
1808 wpa_ctrl_close(ctrl);
1809 dut->default_timeout = old_timeout;
1810 return 0;
1811}
1812
1813
Srinivas Dasaribc9e0552018-01-04 19:24:28 +05301814static int dpp_manual_dpp(struct sigma_dut *dut,
1815 struct sigma_conn *conn,
1816 struct sigma_cmd *cmd)
1817{
1818 const char *auth_role = get_param(cmd, "DPPAuthRole");
priyadharshini gowthaman2fa651b2018-04-16 17:02:47 -07001819 const char *self_conf = get_param(cmd, "DPPSelfConfigure");
Srinivas Dasaribc9e0552018-01-04 19:24:28 +05301820 int res = -1, success;
1821 const char *val;
1822 unsigned int old_timeout;
1823
1824 if (!auth_role) {
1825 send_resp(dut, conn, SIGMA_ERROR,
1826 "errorCode,Missing DPPAuthRole");
1827 return 0;
1828 }
1829
priyadharshini gowthaman2fa651b2018-04-16 17:02:47 -07001830 if (!self_conf)
1831 self_conf = "no";
1832
Srinivas Dasaribc9e0552018-01-04 19:24:28 +05301833 old_timeout = dut->default_timeout;
1834 val = get_param(cmd, "DPPTimeout");
1835 if (val && atoi(val) > 0) {
1836 dut->default_timeout = atoi(val);
1837 sigma_dut_print(dut, DUT_MSG_DEBUG, "DPP timeout: %u",
1838 dut->default_timeout);
1839 }
1840
1841 res = dpp_get_local_bootstrap(dut, conn, cmd, 0, &success);
1842 if (res || !success)
1843 goto out;
1844
1845 if (strcasecmp(auth_role, "Responder") == 0) {
1846 res = dpp_display_own_qrcode(dut);
1847 if (res < 0)
1848 goto out;
1849
1850 res = dpp_automatic_dpp(dut, conn, cmd);
1851 goto out;
1852 }
1853
1854 if (strcasecmp(auth_role, "Initiator") == 0) {
priyadharshini gowthaman2fa651b2018-04-16 17:02:47 -07001855 if (strcasecmp(self_conf, "Yes") != 0) {
1856 res = dpp_scan_peer_qrcode(dut);
1857 if (res < 0) {
1858 send_resp(dut, conn, SIGMA_ERROR,
1859 "errorCode,Failed to scan peer QR Code");
1860 res = 0;
1861 goto out;
1862 }
Jouni Malinen1a38cc32018-01-05 20:59:00 +02001863 }
Srinivas Dasaribc9e0552018-01-04 19:24:28 +05301864
1865 res = dpp_automatic_dpp(dut, conn, cmd);
1866 goto out;
1867 }
1868
1869 send_resp(dut, conn, SIGMA_ERROR, "errorCode,Unknown DPPAuthRole");
1870 res = 0;
1871out:
1872 dut->default_timeout = old_timeout;
1873 return res;
1874}
1875
1876
Jouni Malinend86e5822017-08-29 03:55:32 +03001877int dpp_dev_exec_action(struct sigma_dut *dut, struct sigma_conn *conn,
1878 struct sigma_cmd *cmd)
1879{
1880 const char *type = get_param(cmd, "DPPActionType");
1881 const char *bs = get_param(cmd, "DPPBS");
1882
1883 if (!bs) {
1884 send_resp(dut, conn, SIGMA_ERROR,
1885 "errorCode,Missing DPPBS");
1886 return 0;
1887 }
1888
1889 if (!type) {
1890 send_resp(dut, conn, SIGMA_ERROR,
1891 "errorCode,Missing DPPActionType");
1892 return 0;
1893 }
1894
1895 if (strcasecmp(type, "GetLocalBootstrap") == 0)
Srinivas Dasaribc9e0552018-01-04 19:24:28 +05301896 return dpp_get_local_bootstrap(dut, conn, cmd, 1, NULL);
Jouni Malinend86e5822017-08-29 03:55:32 +03001897 if (strcasecmp(type, "SetPeerBootstrap") == 0)
1898 return dpp_set_peer_bootstrap(dut, conn, cmd);
1899 if (strcasecmp(type, "ManualDPP") == 0)
1900 return dpp_manual_dpp(dut, conn, cmd);
1901 if (strcasecmp(type, "AutomaticDPP") == 0)
1902 return dpp_automatic_dpp(dut, conn, cmd);
1903
1904 send_resp(dut, conn, SIGMA_ERROR,
1905 "errorCode,Unsupported DPPActionType");
1906 return 0;
1907}