]> git.ipfire.org Git - thirdparty/hostap.git/blob - src/common/dpp.h
DPP: Received Configurator backup processing
[thirdparty/hostap.git] / src / common / dpp.h
1 /*
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 <openssl/x509.h>
15
16 #include "utils/list.h"
17 #include "common/wpa_common.h"
18 #include "crypto/sha256.h"
19
20 struct crypto_ecdh;
21 struct hostapd_ip_addr;
22 struct dpp_global;
23
24 #define DPP_HDR_LEN (4 + 2) /* OUI, OUI Type, Crypto Suite, DPP frame type */
25 #define DPP_TCP_PORT 7871
26
27 enum dpp_public_action_frame_type {
28 DPP_PA_AUTHENTICATION_REQ = 0,
29 DPP_PA_AUTHENTICATION_RESP = 1,
30 DPP_PA_AUTHENTICATION_CONF = 2,
31 DPP_PA_PEER_DISCOVERY_REQ = 5,
32 DPP_PA_PEER_DISCOVERY_RESP = 6,
33 DPP_PA_PKEX_EXCHANGE_REQ = 7,
34 DPP_PA_PKEX_EXCHANGE_RESP = 8,
35 DPP_PA_PKEX_COMMIT_REVEAL_REQ = 9,
36 DPP_PA_PKEX_COMMIT_REVEAL_RESP = 10,
37 DPP_PA_CONFIGURATION_RESULT = 11,
38 DPP_PA_CONNECTION_STATUS_RESULT = 12,
39 };
40
41 enum dpp_attribute_id {
42 DPP_ATTR_STATUS = 0x1000,
43 DPP_ATTR_I_BOOTSTRAP_KEY_HASH = 0x1001,
44 DPP_ATTR_R_BOOTSTRAP_KEY_HASH = 0x1002,
45 DPP_ATTR_I_PROTOCOL_KEY = 0x1003,
46 DPP_ATTR_WRAPPED_DATA = 0x1004,
47 DPP_ATTR_I_NONCE = 0x1005,
48 DPP_ATTR_I_CAPABILITIES = 0x1006,
49 DPP_ATTR_R_NONCE = 0x1007,
50 DPP_ATTR_R_CAPABILITIES = 0x1008,
51 DPP_ATTR_R_PROTOCOL_KEY = 0x1009,
52 DPP_ATTR_I_AUTH_TAG = 0x100A,
53 DPP_ATTR_R_AUTH_TAG = 0x100B,
54 DPP_ATTR_CONFIG_OBJ = 0x100C,
55 DPP_ATTR_CONNECTOR = 0x100D,
56 DPP_ATTR_CONFIG_ATTR_OBJ = 0x100E,
57 DPP_ATTR_BOOTSTRAP_KEY = 0x100F,
58 DPP_ATTR_OWN_NET_NK_HASH = 0x1011,
59 DPP_ATTR_FINITE_CYCLIC_GROUP = 0x1012,
60 DPP_ATTR_ENCRYPTED_KEY = 0x1013,
61 DPP_ATTR_ENROLLEE_NONCE = 0x1014,
62 DPP_ATTR_CODE_IDENTIFIER = 0x1015,
63 DPP_ATTR_TRANSACTION_ID = 0x1016,
64 DPP_ATTR_BOOTSTRAP_INFO = 0x1017,
65 DPP_ATTR_CHANNEL = 0x1018,
66 DPP_ATTR_PROTOCOL_VERSION = 0x1019,
67 DPP_ATTR_ENVELOPED_DATA = 0x101A,
68 DPP_ATTR_SEND_CONN_STATUS = 0x101B,
69 DPP_ATTR_CONN_STATUS = 0x101C,
70 };
71
72 enum dpp_status_error {
73 DPP_STATUS_OK = 0,
74 DPP_STATUS_NOT_COMPATIBLE = 1,
75 DPP_STATUS_AUTH_FAILURE = 2,
76 DPP_STATUS_UNWRAP_FAILURE = 3,
77 DPP_STATUS_BAD_GROUP = 4,
78 DPP_STATUS_CONFIGURE_FAILURE = 5,
79 DPP_STATUS_RESPONSE_PENDING = 6,
80 DPP_STATUS_INVALID_CONNECTOR = 7,
81 DPP_STATUS_NO_MATCH = 8,
82 DPP_STATUS_CONFIG_REJECTED = 9,
83 DPP_STATUS_NO_AP = 10,
84 };
85
86 #define DPP_CAPAB_ENROLLEE BIT(0)
87 #define DPP_CAPAB_CONFIGURATOR BIT(1)
88 #define DPP_CAPAB_ROLE_MASK (BIT(0) | BIT(1))
89
90 #define DPP_BOOTSTRAP_MAX_FREQ 30
91 #define DPP_MAX_NONCE_LEN 32
92 #define DPP_MAX_HASH_LEN 64
93 #define DPP_MAX_SHARED_SECRET_LEN 66
94
95 struct dpp_curve_params {
96 const char *name;
97 size_t hash_len;
98 size_t aes_siv_key_len;
99 size_t nonce_len;
100 size_t prime_len;
101 const char *jwk_crv;
102 u16 ike_group;
103 const char *jws_alg;
104 };
105
106 enum dpp_bootstrap_type {
107 DPP_BOOTSTRAP_QR_CODE,
108 DPP_BOOTSTRAP_PKEX,
109 DPP_BOOTSTRAP_NFC_URI,
110 };
111
112 struct dpp_bootstrap_info {
113 struct dl_list list;
114 unsigned int id;
115 enum dpp_bootstrap_type type;
116 char *uri;
117 u8 mac_addr[ETH_ALEN];
118 char *chan;
119 char *info;
120 char *pk;
121 unsigned int freq[DPP_BOOTSTRAP_MAX_FREQ];
122 unsigned int num_freq;
123 int own;
124 EVP_PKEY *pubkey;
125 u8 pubkey_hash[SHA256_MAC_LEN];
126 const struct dpp_curve_params *curve;
127 unsigned int pkex_t; /* number of failures before dpp_pkex
128 * instantiation */
129 };
130
131 #define PKEX_COUNTER_T_LIMIT 5
132
133 struct dpp_pkex {
134 void *msg_ctx;
135 unsigned int initiator:1;
136 unsigned int exchange_done:1;
137 unsigned int failed:1;
138 struct dpp_bootstrap_info *own_bi;
139 u8 own_mac[ETH_ALEN];
140 u8 peer_mac[ETH_ALEN];
141 char *identifier;
142 char *code;
143 EVP_PKEY *x;
144 EVP_PKEY *y;
145 u8 Mx[DPP_MAX_SHARED_SECRET_LEN];
146 u8 Nx[DPP_MAX_SHARED_SECRET_LEN];
147 u8 z[DPP_MAX_HASH_LEN];
148 EVP_PKEY *peer_bootstrap_key;
149 struct wpabuf *exchange_req;
150 struct wpabuf *exchange_resp;
151 unsigned int t; /* number of failures on code use */
152 unsigned int exch_req_wait_time;
153 unsigned int exch_req_tries;
154 unsigned int freq;
155 };
156
157 enum dpp_akm {
158 DPP_AKM_UNKNOWN,
159 DPP_AKM_DPP,
160 DPP_AKM_PSK,
161 DPP_AKM_SAE,
162 DPP_AKM_PSK_SAE,
163 DPP_AKM_SAE_DPP,
164 DPP_AKM_PSK_SAE_DPP,
165 };
166
167 enum dpp_netrole {
168 DPP_NETROLE_STA,
169 DPP_NETROLE_AP,
170 DPP_NETROLE_CONFIGURATOR,
171 };
172
173 struct dpp_configuration {
174 u8 ssid[32];
175 size_t ssid_len;
176 int ssid_charset;
177 enum dpp_akm akm;
178 enum dpp_netrole netrole;
179
180 /* For DPP configuration (connector) */
181 os_time_t netaccesskey_expiry;
182
183 /* TODO: groups */
184 char *group_id;
185
186 /* For legacy configuration */
187 char *passphrase;
188 u8 psk[32];
189 int psk_set;
190 };
191
192 struct dpp_asymmetric_key {
193 struct dpp_asymmetric_key *next;
194 EVP_PKEY *csign;
195 char *config_template;
196 char *connector_template;
197 };
198
199 #define DPP_MAX_CONF_OBJ 10
200
201 struct dpp_authentication {
202 void *msg_ctx;
203 u8 peer_version;
204 const struct dpp_curve_params *curve;
205 struct dpp_bootstrap_info *peer_bi;
206 struct dpp_bootstrap_info *own_bi;
207 struct dpp_bootstrap_info *tmp_own_bi;
208 u8 waiting_pubkey_hash[SHA256_MAC_LEN];
209 int response_pending;
210 enum dpp_status_error auth_resp_status;
211 enum dpp_status_error conf_resp_status;
212 u8 peer_mac_addr[ETH_ALEN];
213 u8 i_nonce[DPP_MAX_NONCE_LEN];
214 u8 r_nonce[DPP_MAX_NONCE_LEN];
215 u8 e_nonce[DPP_MAX_NONCE_LEN];
216 u8 i_capab;
217 u8 r_capab;
218 EVP_PKEY *own_protocol_key;
219 EVP_PKEY *peer_protocol_key;
220 struct wpabuf *req_msg;
221 struct wpabuf *resp_msg;
222 /* Intersection of possible frequencies for initiating DPP
223 * Authentication exchange */
224 unsigned int freq[DPP_BOOTSTRAP_MAX_FREQ];
225 unsigned int num_freq, freq_idx;
226 unsigned int curr_freq;
227 unsigned int neg_freq;
228 unsigned int num_freq_iters;
229 size_t secret_len;
230 u8 Mx[DPP_MAX_SHARED_SECRET_LEN];
231 size_t Mx_len;
232 u8 Nx[DPP_MAX_SHARED_SECRET_LEN];
233 size_t Nx_len;
234 u8 Lx[DPP_MAX_SHARED_SECRET_LEN];
235 size_t Lx_len;
236 u8 k1[DPP_MAX_HASH_LEN];
237 u8 k2[DPP_MAX_HASH_LEN];
238 u8 ke[DPP_MAX_HASH_LEN];
239 int initiator;
240 int waiting_auth_resp;
241 int waiting_auth_conf;
242 int auth_req_ack;
243 unsigned int auth_resp_tries;
244 u8 allowed_roles;
245 int configurator;
246 int remove_on_tx_status;
247 int connect_on_tx_status;
248 int waiting_conf_result;
249 int waiting_conn_status_result;
250 int auth_success;
251 struct wpabuf *conf_req;
252 const struct wpabuf *conf_resp; /* owned by GAS server */
253 struct dpp_configuration *conf_ap;
254 struct dpp_configuration *conf2_ap;
255 struct dpp_configuration *conf_sta;
256 struct dpp_configuration *conf2_sta;
257 struct dpp_configurator *conf;
258 struct dpp_config_obj {
259 char *connector; /* received signedConnector */
260 u8 ssid[SSID_MAX_LEN];
261 u8 ssid_len;
262 int ssid_charset;
263 char passphrase[64];
264 u8 psk[PMK_LEN];
265 int psk_set;
266 enum dpp_akm akm;
267 struct wpabuf *c_sign_key;
268 } conf_obj[DPP_MAX_CONF_OBJ];
269 unsigned int num_conf_obj;
270 struct dpp_asymmetric_key *conf_key_pkg;
271 struct wpabuf *net_access_key;
272 os_time_t net_access_key_expiry;
273 int send_conn_status;
274 int conn_status_requested;
275 int akm_use_selector;
276 #ifdef CONFIG_TESTING_OPTIONS
277 char *config_obj_override;
278 char *discovery_override;
279 char *groups_override;
280 unsigned int ignore_netaccesskey_mismatch:1;
281 #endif /* CONFIG_TESTING_OPTIONS */
282 };
283
284 struct dpp_configurator {
285 struct dl_list list;
286 unsigned int id;
287 int own;
288 EVP_PKEY *csign;
289 char *kid;
290 const struct dpp_curve_params *curve;
291 };
292
293 struct dpp_introduction {
294 u8 pmkid[PMKID_LEN];
295 u8 pmk[PMK_LEN_MAX];
296 size_t pmk_len;
297 };
298
299 struct dpp_relay_config {
300 const struct hostapd_ip_addr *ipaddr;
301 const u8 *pkhash;
302
303 void *cb_ctx;
304 void (*tx)(void *ctx, const u8 *addr, unsigned int freq, const u8 *msg,
305 size_t len);
306 void (*gas_resp_tx)(void *ctx, const u8 *addr, u8 dialog_token, int prot,
307 struct wpabuf *buf);
308 };
309
310 struct dpp_controller_config {
311 const char *configurator_params;
312 int tcp_port;
313 };
314
315 #ifdef CONFIG_TESTING_OPTIONS
316 enum dpp_test_behavior {
317 DPP_TEST_DISABLED = 0,
318 DPP_TEST_AFTER_WRAPPED_DATA_AUTH_REQ = 1,
319 DPP_TEST_AFTER_WRAPPED_DATA_AUTH_RESP = 2,
320 DPP_TEST_AFTER_WRAPPED_DATA_AUTH_CONF = 3,
321 DPP_TEST_AFTER_WRAPPED_DATA_PKEX_CR_REQ = 4,
322 DPP_TEST_AFTER_WRAPPED_DATA_PKEX_CR_RESP = 5,
323 DPP_TEST_AFTER_WRAPPED_DATA_CONF_REQ = 6,
324 DPP_TEST_AFTER_WRAPPED_DATA_CONF_RESP = 7,
325 DPP_TEST_ZERO_I_CAPAB = 8,
326 DPP_TEST_ZERO_R_CAPAB = 9,
327 DPP_TEST_NO_R_BOOTSTRAP_KEY_HASH_AUTH_REQ = 10,
328 DPP_TEST_NO_I_BOOTSTRAP_KEY_HASH_AUTH_REQ = 11,
329 DPP_TEST_NO_I_PROTO_KEY_AUTH_REQ = 12,
330 DPP_TEST_NO_I_NONCE_AUTH_REQ = 13,
331 DPP_TEST_NO_I_CAPAB_AUTH_REQ = 14,
332 DPP_TEST_NO_WRAPPED_DATA_AUTH_REQ = 15,
333 DPP_TEST_NO_STATUS_AUTH_RESP = 16,
334 DPP_TEST_NO_R_BOOTSTRAP_KEY_HASH_AUTH_RESP = 17,
335 DPP_TEST_NO_I_BOOTSTRAP_KEY_HASH_AUTH_RESP = 18,
336 DPP_TEST_NO_R_PROTO_KEY_AUTH_RESP = 19,
337 DPP_TEST_NO_R_NONCE_AUTH_RESP = 20,
338 DPP_TEST_NO_I_NONCE_AUTH_RESP = 21,
339 DPP_TEST_NO_R_CAPAB_AUTH_RESP = 22,
340 DPP_TEST_NO_R_AUTH_AUTH_RESP = 23,
341 DPP_TEST_NO_WRAPPED_DATA_AUTH_RESP = 24,
342 DPP_TEST_NO_STATUS_AUTH_CONF = 25,
343 DPP_TEST_NO_R_BOOTSTRAP_KEY_HASH_AUTH_CONF = 26,
344 DPP_TEST_NO_I_BOOTSTRAP_KEY_HASH_AUTH_CONF = 27,
345 DPP_TEST_NO_I_AUTH_AUTH_CONF = 28,
346 DPP_TEST_NO_WRAPPED_DATA_AUTH_CONF = 29,
347 DPP_TEST_I_NONCE_MISMATCH_AUTH_RESP = 30,
348 DPP_TEST_INCOMPATIBLE_R_CAPAB_AUTH_RESP = 31,
349 DPP_TEST_R_AUTH_MISMATCH_AUTH_RESP = 32,
350 DPP_TEST_I_AUTH_MISMATCH_AUTH_CONF = 33,
351 DPP_TEST_NO_FINITE_CYCLIC_GROUP_PKEX_EXCHANGE_REQ = 34,
352 DPP_TEST_NO_ENCRYPTED_KEY_PKEX_EXCHANGE_REQ = 35,
353 DPP_TEST_NO_STATUS_PKEX_EXCHANGE_RESP = 36,
354 DPP_TEST_NO_ENCRYPTED_KEY_PKEX_EXCHANGE_RESP = 37,
355 DPP_TEST_NO_BOOTSTRAP_KEY_PKEX_CR_REQ = 38,
356 DPP_TEST_NO_I_AUTH_TAG_PKEX_CR_REQ = 39,
357 DPP_TEST_NO_WRAPPED_DATA_PKEX_CR_REQ = 40,
358 DPP_TEST_NO_BOOTSTRAP_KEY_PKEX_CR_RESP = 41,
359 DPP_TEST_NO_R_AUTH_TAG_PKEX_CR_RESP = 42,
360 DPP_TEST_NO_WRAPPED_DATA_PKEX_CR_RESP = 43,
361 DPP_TEST_INVALID_ENCRYPTED_KEY_PKEX_EXCHANGE_REQ = 44,
362 DPP_TEST_INVALID_ENCRYPTED_KEY_PKEX_EXCHANGE_RESP = 45,
363 DPP_TEST_INVALID_STATUS_PKEX_EXCHANGE_RESP = 46,
364 DPP_TEST_INVALID_BOOTSTRAP_KEY_PKEX_CR_REQ = 47,
365 DPP_TEST_INVALID_BOOTSTRAP_KEY_PKEX_CR_RESP = 48,
366 DPP_TEST_I_AUTH_TAG_MISMATCH_PKEX_CR_REQ = 49,
367 DPP_TEST_R_AUTH_TAG_MISMATCH_PKEX_CR_RESP = 50,
368 DPP_TEST_NO_E_NONCE_CONF_REQ = 51,
369 DPP_TEST_NO_CONFIG_ATTR_OBJ_CONF_REQ = 52,
370 DPP_TEST_NO_WRAPPED_DATA_CONF_REQ = 53,
371 DPP_TEST_NO_E_NONCE_CONF_RESP = 54,
372 DPP_TEST_NO_CONFIG_OBJ_CONF_RESP = 55,
373 DPP_TEST_NO_STATUS_CONF_RESP = 56,
374 DPP_TEST_NO_WRAPPED_DATA_CONF_RESP = 57,
375 DPP_TEST_INVALID_STATUS_CONF_RESP = 58,
376 DPP_TEST_E_NONCE_MISMATCH_CONF_RESP = 59,
377 DPP_TEST_NO_TRANSACTION_ID_PEER_DISC_REQ = 60,
378 DPP_TEST_NO_CONNECTOR_PEER_DISC_REQ = 61,
379 DPP_TEST_NO_TRANSACTION_ID_PEER_DISC_RESP = 62,
380 DPP_TEST_NO_STATUS_PEER_DISC_RESP = 63,
381 DPP_TEST_NO_CONNECTOR_PEER_DISC_RESP = 64,
382 DPP_TEST_AUTH_RESP_IN_PLACE_OF_CONF = 65,
383 DPP_TEST_INVALID_I_PROTO_KEY_AUTH_REQ = 66,
384 DPP_TEST_INVALID_R_PROTO_KEY_AUTH_RESP = 67,
385 DPP_TEST_INVALID_R_BOOTSTRAP_KEY_HASH_AUTH_REQ = 68,
386 DPP_TEST_INVALID_I_BOOTSTRAP_KEY_HASH_AUTH_REQ = 69,
387 DPP_TEST_INVALID_R_BOOTSTRAP_KEY_HASH_AUTH_RESP = 70,
388 DPP_TEST_INVALID_I_BOOTSTRAP_KEY_HASH_AUTH_RESP = 71,
389 DPP_TEST_INVALID_R_BOOTSTRAP_KEY_HASH_AUTH_CONF = 72,
390 DPP_TEST_INVALID_I_BOOTSTRAP_KEY_HASH_AUTH_CONF = 73,
391 DPP_TEST_INVALID_STATUS_AUTH_RESP = 74,
392 DPP_TEST_INVALID_STATUS_AUTH_CONF = 75,
393 DPP_TEST_INVALID_CONFIG_ATTR_OBJ_CONF_REQ = 76,
394 DPP_TEST_INVALID_TRANSACTION_ID_PEER_DISC_RESP = 77,
395 DPP_TEST_INVALID_STATUS_PEER_DISC_RESP = 78,
396 DPP_TEST_INVALID_CONNECTOR_PEER_DISC_RESP = 79,
397 DPP_TEST_INVALID_CONNECTOR_PEER_DISC_REQ = 80,
398 DPP_TEST_INVALID_I_NONCE_AUTH_REQ = 81,
399 DPP_TEST_INVALID_TRANSACTION_ID_PEER_DISC_REQ = 82,
400 DPP_TEST_INVALID_E_NONCE_CONF_REQ = 83,
401 DPP_TEST_STOP_AT_PKEX_EXCHANGE_RESP = 84,
402 DPP_TEST_STOP_AT_PKEX_CR_REQ = 85,
403 DPP_TEST_STOP_AT_PKEX_CR_RESP = 86,
404 DPP_TEST_STOP_AT_AUTH_REQ = 87,
405 DPP_TEST_STOP_AT_AUTH_RESP = 88,
406 DPP_TEST_STOP_AT_AUTH_CONF = 89,
407 DPP_TEST_STOP_AT_CONF_REQ = 90,
408 DPP_TEST_REJECT_CONFIG = 91,
409 };
410
411 extern enum dpp_test_behavior dpp_test;
412 extern u8 dpp_pkex_own_mac_override[ETH_ALEN];
413 extern u8 dpp_pkex_peer_mac_override[ETH_ALEN];
414 extern u8 dpp_pkex_ephemeral_key_override[600];
415 extern size_t dpp_pkex_ephemeral_key_override_len;
416 extern u8 dpp_protocol_key_override[600];
417 extern size_t dpp_protocol_key_override_len;
418 extern u8 dpp_nonce_override[DPP_MAX_NONCE_LEN];
419 extern size_t dpp_nonce_override_len;
420 #endif /* CONFIG_TESTING_OPTIONS */
421
422 void dpp_bootstrap_info_free(struct dpp_bootstrap_info *info);
423 const char * dpp_bootstrap_type_txt(enum dpp_bootstrap_type type);
424 int dpp_bootstrap_key_hash(struct dpp_bootstrap_info *bi);
425 int dpp_parse_uri_chan_list(struct dpp_bootstrap_info *bi,
426 const char *chan_list);
427 int dpp_parse_uri_mac(struct dpp_bootstrap_info *bi, const char *mac);
428 int dpp_parse_uri_info(struct dpp_bootstrap_info *bi, const char *info);
429 int dpp_nfc_update_bi(struct dpp_bootstrap_info *own_bi,
430 struct dpp_bootstrap_info *peer_bi);
431 struct hostapd_hw_modes;
432 struct dpp_authentication * dpp_auth_init(void *msg_ctx,
433 struct dpp_bootstrap_info *peer_bi,
434 struct dpp_bootstrap_info *own_bi,
435 u8 dpp_allowed_roles,
436 unsigned int neg_freq,
437 struct hostapd_hw_modes *own_modes,
438 u16 num_modes);
439 struct dpp_authentication *
440 dpp_auth_req_rx(void *msg_ctx, u8 dpp_allowed_roles, int qr_mutual,
441 struct dpp_bootstrap_info *peer_bi,
442 struct dpp_bootstrap_info *own_bi,
443 unsigned int freq, const u8 *hdr, const u8 *attr_start,
444 size_t attr_len);
445 struct wpabuf *
446 dpp_auth_resp_rx(struct dpp_authentication *auth, const u8 *hdr,
447 const u8 *attr_start, size_t attr_len);
448 struct wpabuf * dpp_build_conf_req(struct dpp_authentication *auth,
449 const char *json);
450 struct wpabuf * dpp_build_conf_req_helper(struct dpp_authentication *auth,
451 const char *name,
452 enum dpp_netrole netrole,
453 const char *mud_url, int *opclasses);
454 int dpp_auth_conf_rx(struct dpp_authentication *auth, const u8 *hdr,
455 const u8 *attr_start, size_t attr_len);
456 int dpp_notify_new_qr_code(struct dpp_authentication *auth,
457 struct dpp_bootstrap_info *peer_bi);
458 struct dpp_configuration * dpp_configuration_alloc(const char *type);
459 int dpp_akm_psk(enum dpp_akm akm);
460 int dpp_akm_sae(enum dpp_akm akm);
461 int dpp_akm_legacy(enum dpp_akm akm);
462 int dpp_akm_dpp(enum dpp_akm akm);
463 int dpp_akm_ver2(enum dpp_akm akm);
464 int dpp_configuration_valid(const struct dpp_configuration *conf);
465 void dpp_configuration_free(struct dpp_configuration *conf);
466 int dpp_set_configurator(struct dpp_global *dpp, void *msg_ctx,
467 struct dpp_authentication *auth,
468 const char *cmd);
469 void dpp_auth_deinit(struct dpp_authentication *auth);
470 struct wpabuf *
471 dpp_conf_req_rx(struct dpp_authentication *auth, const u8 *attr_start,
472 size_t attr_len);
473 int dpp_conf_resp_rx(struct dpp_authentication *auth,
474 const struct wpabuf *resp);
475 enum dpp_status_error dpp_conf_result_rx(struct dpp_authentication *auth,
476 const u8 *hdr,
477 const u8 *attr_start, size_t attr_len);
478 struct wpabuf * dpp_build_conf_result(struct dpp_authentication *auth,
479 enum dpp_status_error status);
480 enum dpp_status_error dpp_conn_status_result_rx(struct dpp_authentication *auth,
481 const u8 *hdr,
482 const u8 *attr_start,
483 size_t attr_len,
484 u8 *ssid, size_t *ssid_len,
485 char **channel_list);
486 struct wpabuf * dpp_build_conn_status_result(struct dpp_authentication *auth,
487 enum dpp_status_error result,
488 const u8 *ssid, size_t ssid_len,
489 const char *channel_list);
490 struct wpabuf * dpp_alloc_msg(enum dpp_public_action_frame_type type,
491 size_t len);
492 const u8 * dpp_get_attr(const u8 *buf, size_t len, u16 req_id, u16 *ret_len);
493 int dpp_check_attrs(const u8 *buf, size_t len);
494 int dpp_key_expired(const char *timestamp, os_time_t *expiry);
495 const char * dpp_akm_str(enum dpp_akm akm);
496 const char * dpp_akm_selector_str(enum dpp_akm akm);
497 int dpp_configurator_get_key(const struct dpp_configurator *conf, char *buf,
498 size_t buflen);
499 void dpp_configurator_free(struct dpp_configurator *conf);
500 struct dpp_configurator *
501 dpp_keygen_configurator(const char *curve, const u8 *privkey,
502 size_t privkey_len);
503 int dpp_configurator_own_config(struct dpp_authentication *auth,
504 const char *curve, int ap);
505 enum dpp_status_error
506 dpp_peer_intro(struct dpp_introduction *intro, const char *own_connector,
507 const u8 *net_access_key, size_t net_access_key_len,
508 const u8 *csign_key, size_t csign_key_len,
509 const u8 *peer_connector, size_t peer_connector_len,
510 os_time_t *expiry);
511 struct dpp_pkex * dpp_pkex_init(void *msg_ctx, struct dpp_bootstrap_info *bi,
512 const u8 *own_mac,
513 const char *identifier,
514 const char *code);
515 struct dpp_pkex * dpp_pkex_rx_exchange_req(void *msg_ctx,
516 struct dpp_bootstrap_info *bi,
517 const u8 *own_mac,
518 const u8 *peer_mac,
519 const char *identifier,
520 const char *code,
521 const u8 *buf, size_t len);
522 struct wpabuf * dpp_pkex_rx_exchange_resp(struct dpp_pkex *pkex,
523 const u8 *peer_mac,
524 const u8 *buf, size_t len);
525 struct wpabuf * dpp_pkex_rx_commit_reveal_req(struct dpp_pkex *pkex,
526 const u8 *hdr,
527 const u8 *buf, size_t len);
528 int dpp_pkex_rx_commit_reveal_resp(struct dpp_pkex *pkex, const u8 *hdr,
529 const u8 *buf, size_t len);
530 void dpp_pkex_free(struct dpp_pkex *pkex);
531
532 char * dpp_corrupt_connector_signature(const char *connector);
533
534
535 struct dpp_pfs {
536 struct crypto_ecdh *ecdh;
537 const struct dpp_curve_params *curve;
538 struct wpabuf *ie;
539 struct wpabuf *secret;
540 };
541
542 struct dpp_pfs * dpp_pfs_init(const u8 *net_access_key,
543 size_t net_access_key_len);
544 int dpp_pfs_process(struct dpp_pfs *pfs, const u8 *peer_ie, size_t peer_ie_len);
545 void dpp_pfs_free(struct dpp_pfs *pfs);
546
547 struct dpp_bootstrap_info * dpp_add_qr_code(struct dpp_global *dpp,
548 const char *uri);
549 struct dpp_bootstrap_info * dpp_add_nfc_uri(struct dpp_global *dpp,
550 const char *uri);
551 int dpp_bootstrap_gen(struct dpp_global *dpp, const char *cmd);
552 struct dpp_bootstrap_info *
553 dpp_bootstrap_get_id(struct dpp_global *dpp, unsigned int id);
554 int dpp_bootstrap_remove(struct dpp_global *dpp, const char *id);
555 struct dpp_bootstrap_info *
556 dpp_pkex_finish(struct dpp_global *dpp, struct dpp_pkex *pkex, const u8 *peer,
557 unsigned int freq);
558 const char * dpp_bootstrap_get_uri(struct dpp_global *dpp, unsigned int id);
559 int dpp_bootstrap_info(struct dpp_global *dpp, int id,
560 char *reply, int reply_size);
561 void dpp_bootstrap_find_pair(struct dpp_global *dpp, const u8 *i_bootstrap,
562 const u8 *r_bootstrap,
563 struct dpp_bootstrap_info **own_bi,
564 struct dpp_bootstrap_info **peer_bi);
565 int dpp_configurator_add(struct dpp_global *dpp, const char *cmd);
566 int dpp_configurator_remove(struct dpp_global *dpp, const char *id);
567 int dpp_configurator_get_key_id(struct dpp_global *dpp, unsigned int id,
568 char *buf, size_t buflen);
569 int dpp_configurator_from_backup(struct dpp_global *dpp,
570 struct dpp_asymmetric_key *key);
571 int dpp_relay_add_controller(struct dpp_global *dpp,
572 struct dpp_relay_config *config);
573 int dpp_relay_rx_action(struct dpp_global *dpp, const u8 *src, const u8 *hdr,
574 const u8 *buf, size_t len, unsigned int freq,
575 const u8 *i_bootstrap, const u8 *r_bootstrap);
576 int dpp_relay_rx_gas_req(struct dpp_global *dpp, const u8 *src, const u8 *data,
577 size_t data_len);
578 int dpp_controller_start(struct dpp_global *dpp,
579 struct dpp_controller_config *config);
580 void dpp_controller_stop(struct dpp_global *dpp);
581 int dpp_tcp_init(struct dpp_global *dpp, struct dpp_authentication *auth,
582 const struct hostapd_ip_addr *addr, int port);
583
584 struct dpp_global_config {
585 void *msg_ctx;
586 void *cb_ctx;
587 int (*process_conf_obj)(void *ctx, struct dpp_authentication *auth);
588 };
589
590 struct dpp_global * dpp_global_init(struct dpp_global_config *config);
591 void dpp_global_clear(struct dpp_global *dpp);
592 void dpp_global_deinit(struct dpp_global *dpp);
593
594 #endif /* CONFIG_DPP */
595 #endif /* DPP_H */