blob: 8d62a0e2ac3b7cfb573dbaa0cf5b6f7aba7c9a60 [file] [log] [blame]
lh9ed821d2023-04-07 01:36:19 -07001/*
2 * DPP functionality shared between hostapd and wpa_supplicant
3 * Copyright (c) 2017, Qualcomm Atheros, Inc.
4 * Copyright (c) 2018-2020, The Linux Foundation
5 *
6 * This software may be distributed under the terms of the BSD license.
7 * See README for more details.
8 */
9
10#ifndef DPP_H
11#define DPP_H
12
13#ifdef CONFIG_DPP
14#include "utils/list.h"
15#include "common/wpa_common.h"
16#include "crypto/sha256.h"
17#include "crypto/crypto.h"
18
19struct hostapd_ip_addr;
20struct dpp_global;
21struct json_token;
22struct dpp_reconfig_id;
23
24#ifdef CONFIG_TESTING_OPTIONS
25#define DPP_VERSION (dpp_version_override)
26extern int dpp_version_override;
27#else /* CONFIG_TESTING_OPTIONS */
28#ifdef CONFIG_DPP3
29#define DPP_VERSION 3
30#elif defined(CONFIG_DPP2)
31#define DPP_VERSION 2
32#else
33#define DPP_VERSION 1
34#endif
35#endif /* CONFIG_TESTING_OPTIONS */
36
37#define DPP_HDR_LEN (4 + 2) /* OUI, OUI Type, Crypto Suite, DPP frame type */
38#define DPP_TCP_PORT 8908
39
40enum dpp_public_action_frame_type {
41 DPP_PA_AUTHENTICATION_REQ = 0,
42 DPP_PA_AUTHENTICATION_RESP = 1,
43 DPP_PA_AUTHENTICATION_CONF = 2,
44 DPP_PA_PEER_DISCOVERY_REQ = 5,
45 DPP_PA_PEER_DISCOVERY_RESP = 6,
46 DPP_PA_PKEX_V1_EXCHANGE_REQ = 7,
47 DPP_PA_PKEX_EXCHANGE_RESP = 8,
48 DPP_PA_PKEX_COMMIT_REVEAL_REQ = 9,
49 DPP_PA_PKEX_COMMIT_REVEAL_RESP = 10,
50 DPP_PA_CONFIGURATION_RESULT = 11,
51 DPP_PA_CONNECTION_STATUS_RESULT = 12,
52 DPP_PA_PRESENCE_ANNOUNCEMENT = 13,
53 DPP_PA_RECONFIG_ANNOUNCEMENT = 14,
54 DPP_PA_RECONFIG_AUTH_REQ = 15,
55 DPP_PA_RECONFIG_AUTH_RESP = 16,
56 DPP_PA_RECONFIG_AUTH_CONF = 17,
57 DPP_PA_PKEX_EXCHANGE_REQ = 18,
58};
59
60enum dpp_attribute_id {
61 DPP_ATTR_STATUS = 0x1000,
62 DPP_ATTR_I_BOOTSTRAP_KEY_HASH = 0x1001,
63 DPP_ATTR_R_BOOTSTRAP_KEY_HASH = 0x1002,
64 DPP_ATTR_I_PROTOCOL_KEY = 0x1003,
65 DPP_ATTR_WRAPPED_DATA = 0x1004,
66 DPP_ATTR_I_NONCE = 0x1005,
67 DPP_ATTR_I_CAPABILITIES = 0x1006,
68 DPP_ATTR_R_NONCE = 0x1007,
69 DPP_ATTR_R_CAPABILITIES = 0x1008,
70 DPP_ATTR_R_PROTOCOL_KEY = 0x1009,
71 DPP_ATTR_I_AUTH_TAG = 0x100A,
72 DPP_ATTR_R_AUTH_TAG = 0x100B,
73 DPP_ATTR_CONFIG_OBJ = 0x100C,
74 DPP_ATTR_CONNECTOR = 0x100D,
75 DPP_ATTR_CONFIG_ATTR_OBJ = 0x100E,
76 DPP_ATTR_BOOTSTRAP_KEY = 0x100F,
77 DPP_ATTR_OWN_NET_NK_HASH = 0x1011,
78 DPP_ATTR_FINITE_CYCLIC_GROUP = 0x1012,
79 DPP_ATTR_ENCRYPTED_KEY = 0x1013,
80 DPP_ATTR_ENROLLEE_NONCE = 0x1014,
81 DPP_ATTR_CODE_IDENTIFIER = 0x1015,
82 DPP_ATTR_TRANSACTION_ID = 0x1016,
83 DPP_ATTR_BOOTSTRAP_INFO = 0x1017,
84 DPP_ATTR_CHANNEL = 0x1018,
85 DPP_ATTR_PROTOCOL_VERSION = 0x1019,
86 DPP_ATTR_ENVELOPED_DATA = 0x101A,
87 DPP_ATTR_SEND_CONN_STATUS = 0x101B,
88 DPP_ATTR_CONN_STATUS = 0x101C,
89 DPP_ATTR_RECONFIG_FLAGS = 0x101D,
90 DPP_ATTR_C_SIGN_KEY_HASH = 0x101E,
91 DPP_ATTR_CSR_ATTR_REQ = 0x101F,
92 DPP_ATTR_A_NONCE = 0x1020,
93 DPP_ATTR_E_PRIME_ID = 0x1021,
94 DPP_ATTR_CONFIGURATOR_NONCE = 0x1022,
95};
96
97enum dpp_status_error {
98 DPP_STATUS_OK = 0,
99 DPP_STATUS_NOT_COMPATIBLE = 1,
100 DPP_STATUS_AUTH_FAILURE = 2,
101 DPP_STATUS_UNWRAP_FAILURE = 3,
102 DPP_STATUS_BAD_GROUP = 4,
103 DPP_STATUS_CONFIGURE_FAILURE = 5,
104 DPP_STATUS_RESPONSE_PENDING = 6,
105 DPP_STATUS_INVALID_CONNECTOR = 7,
106 DPP_STATUS_NO_MATCH = 8,
107 DPP_STATUS_CONFIG_REJECTED = 9,
108 DPP_STATUS_NO_AP = 10,
109 DPP_STATUS_CONFIGURE_PENDING = 11,
110 DPP_STATUS_CSR_NEEDED = 12,
111 DPP_STATUS_CSR_BAD = 13,
112};
113
114/* DPP Reconfig Flags object - connectorKey values */
115enum dpp_connector_key {
116 DPP_CONFIG_REUSEKEY = 0,
117 DPP_CONFIG_REPLACEKEY = 1,
118};
119
120#define DPP_CAPAB_ENROLLEE BIT(0)
121#define DPP_CAPAB_CONFIGURATOR BIT(1)
122#define DPP_CAPAB_ROLE_MASK (BIT(0) | BIT(1))
123
124#define DPP_BOOTSTRAP_MAX_FREQ 30
125#define DPP_MAX_NONCE_LEN 32
126#define DPP_MAX_HASH_LEN 64
127#define DPP_MAX_SHARED_SECRET_LEN 66
128#define DPP_CP_LEN 64
129
130struct dpp_curve_params {
131 const char *name;
132 size_t hash_len;
133 size_t aes_siv_key_len;
134 size_t nonce_len;
135 size_t prime_len;
136 const char *jwk_crv;
137 u16 ike_group;
138 const char *jws_alg;
139};
140
141enum dpp_bootstrap_type {
142 DPP_BOOTSTRAP_QR_CODE,
143 DPP_BOOTSTRAP_PKEX,
144 DPP_BOOTSTRAP_NFC_URI,
145};
146
147struct dpp_bootstrap_info {
148 struct dl_list list;
149 unsigned int id;
150 enum dpp_bootstrap_type type;
151 char *uri;
152 u8 mac_addr[ETH_ALEN];
153 char *chan;
154 char *info;
155 char *pk;
156 unsigned int freq[DPP_BOOTSTRAP_MAX_FREQ];
157 unsigned int num_freq;
158 bool channels_listed;
159 u8 version;
160 int own;
161 struct crypto_ec_key *pubkey;
162 u8 pubkey_hash[SHA256_MAC_LEN];
163 u8 pubkey_hash_chirp[SHA256_MAC_LEN];
164 const struct dpp_curve_params *curve;
165 unsigned int pkex_t; /* number of failures before dpp_pkex
166 * instantiation */
167 int nfc_negotiated; /* whether this has been used in NFC negotiated
168 * connection handover */
169 char *configurator_params;
170};
171
172#define PKEX_COUNTER_T_LIMIT 5
173
174struct dpp_pkex {
175 void *msg_ctx;
176 unsigned int initiator:1;
177 unsigned int exchange_done:1;
178 unsigned int failed:1;
179 unsigned int v2:1;
180 struct dpp_bootstrap_info *own_bi;
181 u8 own_mac[ETH_ALEN];
182 u8 peer_mac[ETH_ALEN];
183 char *identifier;
184 char *code;
185 struct crypto_ec_key *x;
186 struct crypto_ec_key *y;
187 u8 Mx[DPP_MAX_SHARED_SECRET_LEN];
188 u8 Nx[DPP_MAX_SHARED_SECRET_LEN];
189 u8 z[DPP_MAX_HASH_LEN];
190 struct crypto_ec_key *peer_bootstrap_key;
191 struct wpabuf *exchange_req;
192 struct wpabuf *exchange_resp;
193 unsigned int t; /* number of failures on code use */
194 unsigned int exch_req_wait_time;
195 unsigned int exch_req_tries;
196 unsigned int freq;
197 u8 peer_version;
198};
199
200enum dpp_akm {
201 DPP_AKM_UNKNOWN,
202 DPP_AKM_DPP,
203 DPP_AKM_PSK,
204 DPP_AKM_SAE,
205 DPP_AKM_PSK_SAE,
206 DPP_AKM_SAE_DPP,
207 DPP_AKM_PSK_SAE_DPP,
208 DPP_AKM_DOT1X,
209};
210
211enum dpp_netrole {
212 DPP_NETROLE_STA,
213 DPP_NETROLE_AP,
214 DPP_NETROLE_CONFIGURATOR,
215};
216
217struct dpp_configuration {
218 u8 ssid[32];
219 size_t ssid_len;
220 int ssid_charset;
221 enum dpp_akm akm;
222 enum dpp_netrole netrole;
223
224 /* For DPP configuration (connector) */
225 os_time_t netaccesskey_expiry;
226
227 /* TODO: groups */
228 char *group_id;
229
230 /* For legacy configuration */
231 char *passphrase;
232 u8 psk[32];
233 int psk_set;
234
235 char *csrattrs;
236};
237
238struct dpp_asymmetric_key {
239 struct dpp_asymmetric_key *next;
240 struct crypto_ec_key *csign;
241 struct crypto_ec_key *pp_key;
242 char *config_template;
243 char *connector_template;
244};
245
246#define DPP_MAX_CONF_OBJ 10
247
248struct dpp_authentication {
249 struct dpp_global *global;
250 void *msg_ctx;
251 u8 peer_version;
252 const struct dpp_curve_params *curve;
253 struct dpp_bootstrap_info *peer_bi;
254 struct dpp_bootstrap_info *own_bi;
255 struct dpp_bootstrap_info *tmp_own_bi;
256 struct dpp_bootstrap_info *tmp_peer_bi;
257 u8 waiting_pubkey_hash[SHA256_MAC_LEN];
258 int response_pending;
259 int reconfig;
260 enum dpp_connector_key reconfig_connector_key;
261 enum dpp_status_error auth_resp_status;
262 enum dpp_status_error conf_resp_status;
263 enum dpp_status_error force_conf_resp_status;
264 u8 peer_mac_addr[ETH_ALEN];
265 u8 i_nonce[DPP_MAX_NONCE_LEN];
266 u8 r_nonce[DPP_MAX_NONCE_LEN];
267 u8 e_nonce[DPP_MAX_NONCE_LEN];
268 u8 c_nonce[DPP_MAX_NONCE_LEN];
269 u8 i_capab;
270 u8 r_capab;
271 enum dpp_netrole e_netrole;
272 struct crypto_ec_key *own_protocol_key;
273 struct crypto_ec_key *peer_protocol_key;
274 struct crypto_ec_key *reconfig_old_protocol_key;
275 struct wpabuf *req_msg;
276 struct wpabuf *resp_msg;
277 struct wpabuf *reconfig_req_msg;
278 struct wpabuf *reconfig_resp_msg;
279 /* Intersection of possible frequencies for initiating DPP
280 * Authentication exchange */
281 unsigned int freq[DPP_BOOTSTRAP_MAX_FREQ];
282 unsigned int num_freq, freq_idx;
283 unsigned int curr_freq;
284 unsigned int neg_freq;
285 unsigned int num_freq_iters;
286 size_t secret_len;
287 u8 Mx[DPP_MAX_SHARED_SECRET_LEN];
288 size_t Mx_len;
289 u8 Nx[DPP_MAX_SHARED_SECRET_LEN];
290 size_t Nx_len;
291 u8 Lx[DPP_MAX_SHARED_SECRET_LEN];
292 size_t Lx_len;
293 u8 k1[DPP_MAX_HASH_LEN];
294 u8 k2[DPP_MAX_HASH_LEN];
295 u8 ke[DPP_MAX_HASH_LEN];
296 u8 bk[DPP_MAX_HASH_LEN];
297 int initiator;
298 int waiting_auth_resp;
299 int waiting_auth_conf;
300 int auth_req_ack;
301 unsigned int auth_resp_tries;
302 u8 allowed_roles;
303 int configurator;
304 int remove_on_tx_status;
305 int connect_on_tx_status;
306 int waiting_conf_result;
307 int waiting_conn_status_result;
308 int auth_success;
309 bool reconfig_success;
310 struct wpabuf *conf_req;
311 const struct wpabuf *conf_resp; /* owned by GAS server */
312 struct wpabuf *conf_resp_tcp;
313 struct dpp_configuration *conf_ap;
314 struct dpp_configuration *conf2_ap;
315 struct dpp_configuration *conf_sta;
316 struct dpp_configuration *conf2_sta;
317 int provision_configurator;
318 struct dpp_configurator *conf;
319 struct dpp_config_obj {
320 char *connector; /* received signedConnector */
321 u8 ssid[SSID_MAX_LEN];
322 u8 ssid_len;
323 int ssid_charset;
324 char passphrase[64];
325 u8 psk[PMK_LEN];
326 int psk_set;
327 enum dpp_akm akm;
328 struct wpabuf *c_sign_key;
329 struct wpabuf *certbag;
330 struct wpabuf *certs;
331 struct wpabuf *cacert;
332 char *server_name;
333 struct wpabuf *pp_key;
334 } conf_obj[DPP_MAX_CONF_OBJ];
335 unsigned int num_conf_obj;
336 struct dpp_asymmetric_key *conf_key_pkg;
337 struct wpabuf *net_access_key;
338 os_time_t net_access_key_expiry;
339 int send_conn_status;
340 int conn_status_requested;
341 int akm_use_selector;
342 int configurator_set;
343 u8 transaction_id;
344 u8 *csrattrs;
345 size_t csrattrs_len;
346 bool waiting_csr;
347 struct wpabuf *csr;
348 struct wpabuf *priv_key; /* DER-encoded private key used for csr */
349 bool waiting_cert;
350 char *trusted_eap_server_name;
351 struct wpabuf *cacert;
352 struct wpabuf *certbag;
353 void *cert_resp_ctx;
354 void *gas_server_ctx;
355#ifdef CONFIG_TESTING_OPTIONS
356 char *config_obj_override;
357 char *discovery_override;
358 char *groups_override;
359 unsigned int ignore_netaccesskey_mismatch:1;
360#endif /* CONFIG_TESTING_OPTIONS */
361};
362
363struct dpp_configurator {
364 struct dl_list list;
365 unsigned int id;
366 int own;
367 struct crypto_ec_key *csign;
368 u8 kid_hash[SHA256_MAC_LEN];
369 char *kid;
370 const struct dpp_curve_params *curve;
371 char *connector; /* own Connector for reconfiguration */
372 struct crypto_ec_key *connector_key;
373 struct crypto_ec_key *pp_key;
374};
375
376struct dpp_introduction {
377 u8 pmkid[PMKID_LEN];
378 u8 pmk[PMK_LEN_MAX];
379 size_t pmk_len;
380 int peer_version;
381};
382
383struct dpp_relay_config {
384 const struct hostapd_ip_addr *ipaddr;
385 const u8 *pkhash;
386
387 void *msg_ctx;
388 void *cb_ctx;
389 void (*tx)(void *ctx, const u8 *addr, unsigned int freq, const u8 *msg,
390 size_t len);
391 void (*gas_resp_tx)(void *ctx, const u8 *addr, u8 dialog_token, int prot,
392 struct wpabuf *buf);
393};
394
395struct dpp_controller_config {
396 const char *configurator_params;
397 int tcp_port;
398 u8 allowed_roles;
399 int qr_mutual;
400 enum dpp_netrole netrole;
401 void *msg_ctx;
402 void *cb_ctx;
403 int (*process_conf_obj)(void *ctx, struct dpp_authentication *auth);
404};
405
406#ifdef CONFIG_TESTING_OPTIONS
407enum dpp_test_behavior {
408 DPP_TEST_DISABLED = 0,
409 DPP_TEST_AFTER_WRAPPED_DATA_AUTH_REQ = 1,
410 DPP_TEST_AFTER_WRAPPED_DATA_AUTH_RESP = 2,
411 DPP_TEST_AFTER_WRAPPED_DATA_AUTH_CONF = 3,
412 DPP_TEST_AFTER_WRAPPED_DATA_PKEX_CR_REQ = 4,
413 DPP_TEST_AFTER_WRAPPED_DATA_PKEX_CR_RESP = 5,
414 DPP_TEST_AFTER_WRAPPED_DATA_CONF_REQ = 6,
415 DPP_TEST_AFTER_WRAPPED_DATA_CONF_RESP = 7,
416 DPP_TEST_ZERO_I_CAPAB = 8,
417 DPP_TEST_ZERO_R_CAPAB = 9,
418 DPP_TEST_NO_R_BOOTSTRAP_KEY_HASH_AUTH_REQ = 10,
419 DPP_TEST_NO_I_BOOTSTRAP_KEY_HASH_AUTH_REQ = 11,
420 DPP_TEST_NO_I_PROTO_KEY_AUTH_REQ = 12,
421 DPP_TEST_NO_I_NONCE_AUTH_REQ = 13,
422 DPP_TEST_NO_I_CAPAB_AUTH_REQ = 14,
423 DPP_TEST_NO_WRAPPED_DATA_AUTH_REQ = 15,
424 DPP_TEST_NO_STATUS_AUTH_RESP = 16,
425 DPP_TEST_NO_R_BOOTSTRAP_KEY_HASH_AUTH_RESP = 17,
426 DPP_TEST_NO_I_BOOTSTRAP_KEY_HASH_AUTH_RESP = 18,
427 DPP_TEST_NO_R_PROTO_KEY_AUTH_RESP = 19,
428 DPP_TEST_NO_R_NONCE_AUTH_RESP = 20,
429 DPP_TEST_NO_I_NONCE_AUTH_RESP = 21,
430 DPP_TEST_NO_R_CAPAB_AUTH_RESP = 22,
431 DPP_TEST_NO_R_AUTH_AUTH_RESP = 23,
432 DPP_TEST_NO_WRAPPED_DATA_AUTH_RESP = 24,
433 DPP_TEST_NO_STATUS_AUTH_CONF = 25,
434 DPP_TEST_NO_R_BOOTSTRAP_KEY_HASH_AUTH_CONF = 26,
435 DPP_TEST_NO_I_BOOTSTRAP_KEY_HASH_AUTH_CONF = 27,
436 DPP_TEST_NO_I_AUTH_AUTH_CONF = 28,
437 DPP_TEST_NO_WRAPPED_DATA_AUTH_CONF = 29,
438 DPP_TEST_I_NONCE_MISMATCH_AUTH_RESP = 30,
439 DPP_TEST_INCOMPATIBLE_R_CAPAB_AUTH_RESP = 31,
440 DPP_TEST_R_AUTH_MISMATCH_AUTH_RESP = 32,
441 DPP_TEST_I_AUTH_MISMATCH_AUTH_CONF = 33,
442 DPP_TEST_NO_FINITE_CYCLIC_GROUP_PKEX_EXCHANGE_REQ = 34,
443 DPP_TEST_NO_ENCRYPTED_KEY_PKEX_EXCHANGE_REQ = 35,
444 DPP_TEST_NO_STATUS_PKEX_EXCHANGE_RESP = 36,
445 DPP_TEST_NO_ENCRYPTED_KEY_PKEX_EXCHANGE_RESP = 37,
446 DPP_TEST_NO_BOOTSTRAP_KEY_PKEX_CR_REQ = 38,
447 DPP_TEST_NO_I_AUTH_TAG_PKEX_CR_REQ = 39,
448 DPP_TEST_NO_WRAPPED_DATA_PKEX_CR_REQ = 40,
449 DPP_TEST_NO_BOOTSTRAP_KEY_PKEX_CR_RESP = 41,
450 DPP_TEST_NO_R_AUTH_TAG_PKEX_CR_RESP = 42,
451 DPP_TEST_NO_WRAPPED_DATA_PKEX_CR_RESP = 43,
452 DPP_TEST_INVALID_ENCRYPTED_KEY_PKEX_EXCHANGE_REQ = 44,
453 DPP_TEST_INVALID_ENCRYPTED_KEY_PKEX_EXCHANGE_RESP = 45,
454 DPP_TEST_INVALID_STATUS_PKEX_EXCHANGE_RESP = 46,
455 DPP_TEST_INVALID_BOOTSTRAP_KEY_PKEX_CR_REQ = 47,
456 DPP_TEST_INVALID_BOOTSTRAP_KEY_PKEX_CR_RESP = 48,
457 DPP_TEST_I_AUTH_TAG_MISMATCH_PKEX_CR_REQ = 49,
458 DPP_TEST_R_AUTH_TAG_MISMATCH_PKEX_CR_RESP = 50,
459 DPP_TEST_NO_E_NONCE_CONF_REQ = 51,
460 DPP_TEST_NO_CONFIG_ATTR_OBJ_CONF_REQ = 52,
461 DPP_TEST_NO_WRAPPED_DATA_CONF_REQ = 53,
462 DPP_TEST_NO_E_NONCE_CONF_RESP = 54,
463 DPP_TEST_NO_CONFIG_OBJ_CONF_RESP = 55,
464 DPP_TEST_NO_STATUS_CONF_RESP = 56,
465 DPP_TEST_NO_WRAPPED_DATA_CONF_RESP = 57,
466 DPP_TEST_INVALID_STATUS_CONF_RESP = 58,
467 DPP_TEST_E_NONCE_MISMATCH_CONF_RESP = 59,
468 DPP_TEST_NO_TRANSACTION_ID_PEER_DISC_REQ = 60,
469 DPP_TEST_NO_CONNECTOR_PEER_DISC_REQ = 61,
470 DPP_TEST_NO_TRANSACTION_ID_PEER_DISC_RESP = 62,
471 DPP_TEST_NO_STATUS_PEER_DISC_RESP = 63,
472 DPP_TEST_NO_CONNECTOR_PEER_DISC_RESP = 64,
473 DPP_TEST_AUTH_RESP_IN_PLACE_OF_CONF = 65,
474 DPP_TEST_INVALID_I_PROTO_KEY_AUTH_REQ = 66,
475 DPP_TEST_INVALID_R_PROTO_KEY_AUTH_RESP = 67,
476 DPP_TEST_INVALID_R_BOOTSTRAP_KEY_HASH_AUTH_REQ = 68,
477 DPP_TEST_INVALID_I_BOOTSTRAP_KEY_HASH_AUTH_REQ = 69,
478 DPP_TEST_INVALID_R_BOOTSTRAP_KEY_HASH_AUTH_RESP = 70,
479 DPP_TEST_INVALID_I_BOOTSTRAP_KEY_HASH_AUTH_RESP = 71,
480 DPP_TEST_INVALID_R_BOOTSTRAP_KEY_HASH_AUTH_CONF = 72,
481 DPP_TEST_INVALID_I_BOOTSTRAP_KEY_HASH_AUTH_CONF = 73,
482 DPP_TEST_INVALID_STATUS_AUTH_RESP = 74,
483 DPP_TEST_INVALID_STATUS_AUTH_CONF = 75,
484 DPP_TEST_INVALID_CONFIG_ATTR_OBJ_CONF_REQ = 76,
485 DPP_TEST_INVALID_TRANSACTION_ID_PEER_DISC_RESP = 77,
486 DPP_TEST_INVALID_STATUS_PEER_DISC_RESP = 78,
487 DPP_TEST_INVALID_CONNECTOR_PEER_DISC_RESP = 79,
488 DPP_TEST_INVALID_CONNECTOR_PEER_DISC_REQ = 80,
489 DPP_TEST_INVALID_I_NONCE_AUTH_REQ = 81,
490 DPP_TEST_INVALID_TRANSACTION_ID_PEER_DISC_REQ = 82,
491 DPP_TEST_INVALID_E_NONCE_CONF_REQ = 83,
492 DPP_TEST_STOP_AT_PKEX_EXCHANGE_RESP = 84,
493 DPP_TEST_STOP_AT_PKEX_CR_REQ = 85,
494 DPP_TEST_STOP_AT_PKEX_CR_RESP = 86,
495 DPP_TEST_STOP_AT_AUTH_REQ = 87,
496 DPP_TEST_STOP_AT_AUTH_RESP = 88,
497 DPP_TEST_STOP_AT_AUTH_CONF = 89,
498 DPP_TEST_STOP_AT_CONF_REQ = 90,
499 DPP_TEST_REJECT_CONFIG = 91,
500 DPP_TEST_NO_PROTOCOL_VERSION_PEER_DISC_REQ = 92,
501 DPP_TEST_NO_PROTOCOL_VERSION_PEER_DISC_RESP = 93,
502};
503
504extern enum dpp_test_behavior dpp_test;
505extern u8 dpp_pkex_own_mac_override[ETH_ALEN];
506extern u8 dpp_pkex_peer_mac_override[ETH_ALEN];
507extern u8 dpp_pkex_ephemeral_key_override[600];
508extern size_t dpp_pkex_ephemeral_key_override_len;
509extern u8 dpp_protocol_key_override[600];
510extern size_t dpp_protocol_key_override_len;
511extern u8 dpp_nonce_override[DPP_MAX_NONCE_LEN];
512extern size_t dpp_nonce_override_len;
513#endif /* CONFIG_TESTING_OPTIONS */
514
515void dpp_bootstrap_info_free(struct dpp_bootstrap_info *info);
516const char * dpp_bootstrap_type_txt(enum dpp_bootstrap_type type);
517int dpp_parse_uri_chan_list(struct dpp_bootstrap_info *bi,
518 const char *chan_list);
519int dpp_parse_uri_mac(struct dpp_bootstrap_info *bi, const char *mac);
520int dpp_parse_uri_info(struct dpp_bootstrap_info *bi, const char *info);
521int dpp_nfc_update_bi(struct dpp_bootstrap_info *own_bi,
522 struct dpp_bootstrap_info *peer_bi);
523struct dpp_authentication *
524dpp_alloc_auth(struct dpp_global *dpp, void *msg_ctx);
525struct hostapd_hw_modes;
526struct dpp_authentication * dpp_auth_init(struct dpp_global *dpp, void *msg_ctx,
527 struct dpp_bootstrap_info *peer_bi,
528 struct dpp_bootstrap_info *own_bi,
529 u8 dpp_allowed_roles,
530 unsigned int neg_freq,
531 struct hostapd_hw_modes *own_modes,
532 u16 num_modes);
533struct dpp_authentication *
534dpp_auth_req_rx(struct dpp_global *dpp, void *msg_ctx, u8 dpp_allowed_roles,
535 int qr_mutual, struct dpp_bootstrap_info *peer_bi,
536 struct dpp_bootstrap_info *own_bi,
537 unsigned int freq, const u8 *hdr, const u8 *attr_start,
538 size_t attr_len);
539struct wpabuf *
540dpp_auth_resp_rx(struct dpp_authentication *auth, const u8 *hdr,
541 const u8 *attr_start, size_t attr_len);
542struct wpabuf * dpp_build_conf_req(struct dpp_authentication *auth,
543 const char *json);
544struct wpabuf * dpp_build_conf_req_helper(struct dpp_authentication *auth,
545 const char *name,
546 enum dpp_netrole netrole,
547 const char *mud_url, int *opclasses);
548int dpp_auth_conf_rx(struct dpp_authentication *auth, const u8 *hdr,
549 const u8 *attr_start, size_t attr_len);
550int dpp_notify_new_qr_code(struct dpp_authentication *auth,
551 struct dpp_bootstrap_info *peer_bi);
552struct dpp_configuration * dpp_configuration_alloc(const char *type);
553int dpp_akm_psk(enum dpp_akm akm);
554int dpp_akm_sae(enum dpp_akm akm);
555int dpp_akm_legacy(enum dpp_akm akm);
556int dpp_akm_dpp(enum dpp_akm akm);
557int dpp_akm_ver2(enum dpp_akm akm);
558int dpp_configuration_valid(const struct dpp_configuration *conf);
559void dpp_configuration_free(struct dpp_configuration *conf);
560int dpp_set_configurator(struct dpp_authentication *auth, const char *cmd);
561void dpp_auth_deinit(struct dpp_authentication *auth);
562struct wpabuf *
563dpp_build_conf_resp(struct dpp_authentication *auth, const u8 *e_nonce,
564 u16 e_nonce_len, enum dpp_netrole netrole,
565 bool cert_req);
566struct wpabuf *
567dpp_conf_req_rx(struct dpp_authentication *auth, const u8 *attr_start,
568 size_t attr_len);
569int dpp_conf_resp_rx(struct dpp_authentication *auth,
570 const struct wpabuf *resp);
571enum dpp_status_error dpp_conf_result_rx(struct dpp_authentication *auth,
572 const u8 *hdr,
573 const u8 *attr_start, size_t attr_len);
574struct wpabuf * dpp_build_conf_result(struct dpp_authentication *auth,
575 enum dpp_status_error status);
576enum dpp_status_error dpp_conn_status_result_rx(struct dpp_authentication *auth,
577 const u8 *hdr,
578 const u8 *attr_start,
579 size_t attr_len,
580 u8 *ssid, size_t *ssid_len,
581 char **channel_list);
582struct wpabuf * dpp_build_conn_status_result(struct dpp_authentication *auth,
583 enum dpp_status_error result,
584 const u8 *ssid, size_t ssid_len,
585 const char *channel_list);
586struct wpabuf * dpp_alloc_msg(enum dpp_public_action_frame_type type,
587 size_t len);
588const u8 * dpp_get_attr(const u8 *buf, size_t len, u16 req_id, u16 *ret_len);
589int dpp_check_attrs(const u8 *buf, size_t len);
590int dpp_key_expired(const char *timestamp, os_time_t *expiry);
591const char * dpp_akm_str(enum dpp_akm akm);
592const char * dpp_akm_selector_str(enum dpp_akm akm);
593int dpp_configurator_get_key(const struct dpp_configurator *conf, char *buf,
594 size_t buflen);
595void dpp_configurator_free(struct dpp_configurator *conf);
596int dpp_configurator_own_config(struct dpp_authentication *auth,
597 const char *curve, int ap);
598enum dpp_status_error
599dpp_peer_intro(struct dpp_introduction *intro, const char *own_connector,
600 const u8 *net_access_key, size_t net_access_key_len,
601 const u8 *csign_key, size_t csign_key_len,
602 const u8 *peer_connector, size_t peer_connector_len,
603 os_time_t *expiry);
604int dpp_get_connector_version(const char *connector);
605struct dpp_pkex * dpp_pkex_init(void *msg_ctx, struct dpp_bootstrap_info *bi,
606 const u8 *own_mac,
607 const char *identifier, const char *code,
608 bool v2);
609struct dpp_pkex * dpp_pkex_rx_exchange_req(void *msg_ctx,
610 struct dpp_bootstrap_info *bi,
611 const u8 *own_mac,
612 const u8 *peer_mac,
613 const char *identifier,
614 const char *code,
615 const u8 *buf, size_t len, bool v2);
616struct wpabuf * dpp_pkex_rx_exchange_resp(struct dpp_pkex *pkex,
617 const u8 *peer_mac,
618 const u8 *buf, size_t len);
619struct wpabuf * dpp_pkex_rx_commit_reveal_req(struct dpp_pkex *pkex,
620 const u8 *hdr,
621 const u8 *buf, size_t len);
622int dpp_pkex_rx_commit_reveal_resp(struct dpp_pkex *pkex, const u8 *hdr,
623 const u8 *buf, size_t len);
624void dpp_pkex_free(struct dpp_pkex *pkex);
625
626char * dpp_corrupt_connector_signature(const char *connector);
627
628
629struct dpp_pfs {
630 struct crypto_ecdh *ecdh;
631 const struct dpp_curve_params *curve;
632 struct wpabuf *ie;
633 struct wpabuf *secret;
634};
635
636struct dpp_pfs * dpp_pfs_init(const u8 *net_access_key,
637 size_t net_access_key_len);
638int dpp_pfs_process(struct dpp_pfs *pfs, const u8 *peer_ie, size_t peer_ie_len);
639void dpp_pfs_free(struct dpp_pfs *pfs);
640
641struct wpabuf * dpp_build_csr(struct dpp_authentication *auth,
642 const char *name);
643int dpp_validate_csr(struct dpp_authentication *auth, const struct wpabuf *csr);
644
645struct dpp_bootstrap_info * dpp_add_qr_code(struct dpp_global *dpp,
646 const char *uri);
647struct dpp_bootstrap_info * dpp_add_nfc_uri(struct dpp_global *dpp,
648 const char *uri);
649int dpp_bootstrap_gen(struct dpp_global *dpp, const char *cmd);
650struct dpp_bootstrap_info *
651dpp_bootstrap_get_id(struct dpp_global *dpp, unsigned int id);
652int dpp_bootstrap_remove(struct dpp_global *dpp, const char *id);
653struct dpp_bootstrap_info *
654dpp_pkex_finish(struct dpp_global *dpp, struct dpp_pkex *pkex, const u8 *peer,
655 unsigned int freq);
656const char * dpp_bootstrap_get_uri(struct dpp_global *dpp, unsigned int id);
657int dpp_bootstrap_info(struct dpp_global *dpp, int id,
658 char *reply, int reply_size);
659int dpp_bootstrap_set(struct dpp_global *dpp, int id, const char *params);
660void dpp_bootstrap_find_pair(struct dpp_global *dpp, const u8 *i_bootstrap,
661 const u8 *r_bootstrap,
662 struct dpp_bootstrap_info **own_bi,
663 struct dpp_bootstrap_info **peer_bi);
664struct dpp_bootstrap_info * dpp_bootstrap_find_chirp(struct dpp_global *dpp,
665 const u8 *hash);
666int dpp_configurator_add(struct dpp_global *dpp, const char *cmd);
667int dpp_configurator_remove(struct dpp_global *dpp, const char *id);
668int dpp_configurator_get_key_id(struct dpp_global *dpp, unsigned int id,
669 char *buf, size_t buflen);
670int dpp_configurator_from_backup(struct dpp_global *dpp,
671 struct dpp_asymmetric_key *key);
672struct dpp_configurator * dpp_configurator_find_kid(struct dpp_global *dpp,
673 const u8 *kid);
674int dpp_relay_add_controller(struct dpp_global *dpp,
675 struct dpp_relay_config *config);
676int dpp_relay_rx_action(struct dpp_global *dpp, const u8 *src, const u8 *hdr,
677 const u8 *buf, size_t len, unsigned int freq,
678 const u8 *i_bootstrap, const u8 *r_bootstrap,
679 void *cb_ctx);
680int dpp_relay_rx_gas_req(struct dpp_global *dpp, const u8 *src, const u8 *data,
681 size_t data_len);
682int dpp_controller_start(struct dpp_global *dpp,
683 struct dpp_controller_config *config);
684void dpp_controller_stop(struct dpp_global *dpp);
685void dpp_controller_stop_for_ctx(struct dpp_global *dpp, void *cb_ctx);
686struct dpp_authentication * dpp_controller_get_auth(struct dpp_global *dpp,
687 unsigned int id);
688void dpp_controller_new_qr_code(struct dpp_global *dpp,
689 struct dpp_bootstrap_info *bi);
690int dpp_tcp_init(struct dpp_global *dpp, struct dpp_authentication *auth,
691 const struct hostapd_ip_addr *addr, int port,
692 const char *name, enum dpp_netrole netrole, void *msg_ctx,
693 void *cb_ctx,
694 int (*process_conf_obj)(void *ctx,
695 struct dpp_authentication *auth));
696
697struct wpabuf * dpp_build_presence_announcement(struct dpp_bootstrap_info *bi);
698void dpp_notify_chirp_received(void *msg_ctx, int id, const u8 *src,
699 unsigned int freq, const u8 *hash);
700
701struct dpp_global_config {
702 void *cb_ctx;
703 void (*remove_bi)(void *ctx, struct dpp_bootstrap_info *bi);
704};
705
706struct dpp_global * dpp_global_init(struct dpp_global_config *config);
707void dpp_global_clear(struct dpp_global *dpp);
708void dpp_global_deinit(struct dpp_global *dpp);
709
710/* dpp_reconfig.c */
711
712struct wpabuf * dpp_build_reconfig_announcement(const u8 *csign_key,
713 size_t csign_key_len,
714 const u8 *net_access_key,
715 size_t net_access_key_len,
716 struct dpp_reconfig_id *id);
717struct dpp_authentication *
718dpp_reconfig_init(struct dpp_global *dpp, void *msg_ctx,
719 struct dpp_configurator *conf, unsigned int freq, u16 group,
720 const u8 *a_nonce_attr, size_t a_nonce_len,
721 const u8 *e_id_attr, size_t e_id_len);
722struct dpp_authentication *
723dpp_reconfig_auth_req_rx(struct dpp_global *dpp, void *msg_ctx,
724 const char *own_connector,
725 const u8 *net_access_key, size_t net_access_key_len,
726 const u8 *csign_key, size_t csign_key_len,
727 unsigned int freq, const u8 *hdr,
728 const u8 *attr_start, size_t attr_len);
729struct wpabuf *
730dpp_reconfig_auth_resp_rx(struct dpp_authentication *auth, const u8 *hdr,
731 const u8 *attr_start, size_t attr_len);
732int dpp_reconfig_auth_conf_rx(struct dpp_authentication *auth, const u8 *hdr,
733 const u8 *attr_start, size_t attr_len);
734
735struct dpp_reconfig_id * dpp_gen_reconfig_id(const u8 *csign_key,
736 size_t csign_key_len,
737 const u8 *pp_key,
738 size_t pp_key_len);
739int dpp_update_reconfig_id(struct dpp_reconfig_id *id);
740void dpp_free_reconfig_id(struct dpp_reconfig_id *id);
741
742#endif /* CONFIG_DPP */
743#endif /* DPP_H */