]> git.ipfire.org Git - thirdparty/hostap.git/blame - src/common/dpp.h
DPP: Received Configurator backup processing
[thirdparty/hostap.git] / src / common / dpp.h
CommitLineData
be27e185
JM
1/*
2 * DPP functionality shared between hostapd and wpa_supplicant
3 * Copyright (c) 2017, Qualcomm Atheros, Inc.
2bbe6ad3 4 * Copyright (c) 2018-2020, The Linux Foundation
be27e185
JM
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
1326cb76 13#ifdef CONFIG_DPP
be27e185
JM
14#include <openssl/x509.h>
15
16#include "utils/list.h"
650a70a7 17#include "common/wpa_common.h"
be27e185
JM
18#include "crypto/sha256.h"
19
10ec6a5f 20struct crypto_ecdh;
88a78bdd 21struct hostapd_ip_addr;
87d8435c 22struct dpp_global;
10ec6a5f 23
dc4d271c 24#define DPP_HDR_LEN (4 + 2) /* OUI, OUI Type, Crypto Suite, DPP frame type */
88a78bdd 25#define DPP_TCP_PORT 7871
dc4d271c 26
30d27b04
JM
27enum 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,
22f90b32 37 DPP_PA_CONFIGURATION_RESULT = 11,
e501a2eb 38 DPP_PA_CONNECTION_STATUS_RESULT = 12,
30d27b04
JM
39};
40
41enum 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,
30d27b04
JM
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,
85fd8263 63 DPP_ATTR_TRANSACTION_ID = 0x1016,
d2709206
JM
64 DPP_ATTR_BOOTSTRAP_INFO = 0x1017,
65 DPP_ATTR_CHANNEL = 0x1018,
0b4a906d
JM
66 DPP_ATTR_PROTOCOL_VERSION = 0x1019,
67 DPP_ATTR_ENVELOPED_DATA = 0x101A,
e501a2eb
JM
68 DPP_ATTR_SEND_CONN_STATUS = 0x101B,
69 DPP_ATTR_CONN_STATUS = 0x101C,
30d27b04
JM
70};
71
72enum 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,
e85b6601
JM
80 DPP_STATUS_INVALID_CONNECTOR = 7,
81 DPP_STATUS_NO_MATCH = 8,
22f90b32 82 DPP_STATUS_CONFIG_REJECTED = 9,
e501a2eb 83 DPP_STATUS_NO_AP = 10,
30d27b04
JM
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
be27e185 90#define DPP_BOOTSTRAP_MAX_FREQ 30
30d27b04
JM
91#define DPP_MAX_NONCE_LEN 32
92#define DPP_MAX_HASH_LEN 64
93#define DPP_MAX_SHARED_SECRET_LEN 66
be27e185
JM
94
95struct 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;
500ed7f0 102 u16 ike_group;
31f03cb0 103 const char *jws_alg;
be27e185
JM
104};
105
106enum dpp_bootstrap_type {
107 DPP_BOOTSTRAP_QR_CODE,
500ed7f0 108 DPP_BOOTSTRAP_PKEX,
e780b4bf 109 DPP_BOOTSTRAP_NFC_URI,
be27e185
JM
110};
111
112struct 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];
2bbe6ad3 118 char *chan;
be27e185 119 char *info;
2bbe6ad3 120 char *pk;
be27e185
JM
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;
29ab69e4
JM
127 unsigned int pkex_t; /* number of failures before dpp_pkex
128 * instantiation */
be27e185
JM
129};
130
29ab69e4
JM
131#define PKEX_COUNTER_T_LIMIT 5
132
500ed7f0 133struct dpp_pkex {
219d4c9f 134 void *msg_ctx;
500ed7f0
JM
135 unsigned int initiator:1;
136 unsigned int exchange_done:1;
e0247e79 137 unsigned int failed:1;
500ed7f0
JM
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;
29ab69e4 151 unsigned int t; /* number of failures on code use */
00d2d13d
JM
152 unsigned int exch_req_wait_time;
153 unsigned int exch_req_tries;
154 unsigned int freq;
500ed7f0
JM
155};
156
5dd745b7
JM
157enum dpp_akm {
158 DPP_AKM_UNKNOWN,
159 DPP_AKM_DPP,
160 DPP_AKM_PSK,
161 DPP_AKM_SAE,
18015fc8
JM
162 DPP_AKM_PSK_SAE,
163 DPP_AKM_SAE_DPP,
164 DPP_AKM_PSK_SAE_DPP,
5dd745b7
JM
165};
166
99918e06
JM
167enum dpp_netrole {
168 DPP_NETROLE_STA,
169 DPP_NETROLE_AP,
5661ebd7 170 DPP_NETROLE_CONFIGURATOR,
99918e06
JM
171};
172
461d39af
JM
173struct dpp_configuration {
174 u8 ssid[32];
175 size_t ssid_len;
71e2848e 176 int ssid_charset;
e3a5882b 177 enum dpp_akm akm;
99918e06 178 enum dpp_netrole netrole;
461d39af
JM
179
180 /* For DPP configuration (connector) */
181 os_time_t netaccesskey_expiry;
182
a4bf0078 183 /* TODO: groups */
20f612d9 184 char *group_id;
461d39af
JM
185
186 /* For legacy configuration */
187 char *passphrase;
188 u8 psk[32];
9305c233 189 int psk_set;
461d39af
JM
190};
191
ea91ddb0
JM
192struct dpp_asymmetric_key {
193 struct dpp_asymmetric_key *next;
194 EVP_PKEY *csign;
195 char *config_template;
196 char *connector_template;
197};
198
52d469de
JM
199#define DPP_MAX_CONF_OBJ 10
200
30d27b04
JM
201struct dpp_authentication {
202 void *msg_ctx;
0b4a906d 203 u8 peer_version;
30d27b04
JM
204 const struct dpp_curve_params *curve;
205 struct dpp_bootstrap_info *peer_bi;
206 struct dpp_bootstrap_info *own_bi;
73f21929 207 struct dpp_bootstrap_info *tmp_own_bi;
30d27b04
JM
208 u8 waiting_pubkey_hash[SHA256_MAC_LEN];
209 int response_pending;
210 enum dpp_status_error auth_resp_status;
22f90b32 211 enum dpp_status_error conf_resp_status;
30d27b04
JM
212 u8 peer_mac_addr[ETH_ALEN];
213 u8 i_nonce[DPP_MAX_NONCE_LEN];
214 u8 r_nonce[DPP_MAX_NONCE_LEN];
461d39af 215 u8 e_nonce[DPP_MAX_NONCE_LEN];
30d27b04
JM
216 u8 i_capab;
217 u8 r_capab;
218 EVP_PKEY *own_protocol_key;
219 EVP_PKEY *peer_protocol_key;
dc4d271c
JM
220 struct wpabuf *req_msg;
221 struct wpabuf *resp_msg;
f97ace34
JM
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;
30d27b04 226 unsigned int curr_freq;
d2709206 227 unsigned int neg_freq;
f97ace34 228 unsigned int num_freq_iters;
30d27b04
JM
229 size_t secret_len;
230 u8 Mx[DPP_MAX_SHARED_SECRET_LEN];
630ea133 231 size_t Mx_len;
30d27b04 232 u8 Nx[DPP_MAX_SHARED_SECRET_LEN];
630ea133 233 size_t Nx_len;
30d27b04 234 u8 Lx[DPP_MAX_SHARED_SECRET_LEN];
630ea133 235 size_t Lx_len;
30d27b04
JM
236 u8 k1[DPP_MAX_HASH_LEN];
237 u8 k2[DPP_MAX_HASH_LEN];
238 u8 ke[DPP_MAX_HASH_LEN];
239 int initiator;
f97ace34 240 int waiting_auth_resp;
95b0104a 241 int waiting_auth_conf;
248264c6 242 int auth_req_ack;
95b0104a 243 unsigned int auth_resp_tries;
d1f08264 244 u8 allowed_roles;
30d27b04
JM
245 int configurator;
246 int remove_on_tx_status;
22f90b32
JM
247 int connect_on_tx_status;
248 int waiting_conf_result;
b10e01a7 249 int waiting_conn_status_result;
30d27b04 250 int auth_success;
461d39af 251 struct wpabuf *conf_req;
82feacce 252 const struct wpabuf *conf_resp; /* owned by GAS server */
461d39af 253 struct dpp_configuration *conf_ap;
7eb06a33 254 struct dpp_configuration *conf2_ap;
461d39af 255 struct dpp_configuration *conf_sta;
7eb06a33 256 struct dpp_configuration *conf2_sta;
461d39af 257 struct dpp_configurator *conf;
52d469de
JM
258 struct dpp_config_obj {
259 char *connector; /* received signedConnector */
260 u8 ssid[SSID_MAX_LEN];
261 u8 ssid_len;
57a63b13 262 int ssid_charset;
52d469de
JM
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;
ea91ddb0 270 struct dpp_asymmetric_key *conf_key_pkg;
461d39af
JM
271 struct wpabuf *net_access_key;
272 os_time_t net_access_key_expiry;
b10e01a7 273 int send_conn_status;
16ef233b 274 int conn_status_requested;
68fea960 275 int akm_use_selector;
461d39af
JM
276#ifdef CONFIG_TESTING_OPTIONS
277 char *config_obj_override;
278 char *discovery_override;
279 char *groups_override;
461d39af
JM
280 unsigned int ignore_netaccesskey_mismatch:1;
281#endif /* CONFIG_TESTING_OPTIONS */
282};
283
284struct 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;
30d27b04
JM
291};
292
650a70a7
JM
293struct dpp_introduction {
294 u8 pmkid[PMKID_LEN];
295 u8 pmk[PMK_LEN_MAX];
296 size_t pmk_len;
650a70a7
JM
297};
298
88a78bdd
JM
299struct 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
310struct dpp_controller_config {
311 const char *configurator_params;
312 int tcp_port;
313};
314
60239f60
JM
315#ifdef CONFIG_TESTING_OPTIONS
316enum 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,
0e7cb8c6
JM
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,
ce9acce0
JM
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,
f9c7d770
JM
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,
978bc3f2
JM
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,
61f9f27f
JM
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,
1cfcbd32
JM
361 DPP_TEST_INVALID_ENCRYPTED_KEY_PKEX_EXCHANGE_REQ = 44,
362 DPP_TEST_INVALID_ENCRYPTED_KEY_PKEX_EXCHANGE_RESP = 45,
f31ef96d 363 DPP_TEST_INVALID_STATUS_PKEX_EXCHANGE_RESP = 46,
89d0bf67
JM
364 DPP_TEST_INVALID_BOOTSTRAP_KEY_PKEX_CR_REQ = 47,
365 DPP_TEST_INVALID_BOOTSTRAP_KEY_PKEX_CR_RESP = 48,
7e0ebe21
JM
366 DPP_TEST_I_AUTH_TAG_MISMATCH_PKEX_CR_REQ = 49,
367 DPP_TEST_R_AUTH_TAG_MISMATCH_PKEX_CR_RESP = 50,
f411ad1b
JM
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,
af7f10fc
JM
375 DPP_TEST_INVALID_STATUS_CONF_RESP = 58,
376 DPP_TEST_E_NONCE_MISMATCH_CONF_RESP = 59,
a306ed5a
JM
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,
762fb4f0 382 DPP_TEST_AUTH_RESP_IN_PLACE_OF_CONF = 65,
b6b4226b
JM
383 DPP_TEST_INVALID_I_PROTO_KEY_AUTH_REQ = 66,
384 DPP_TEST_INVALID_R_PROTO_KEY_AUTH_RESP = 67,
65ecce87
JM
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,
3f35ec2d
JM
391 DPP_TEST_INVALID_STATUS_AUTH_RESP = 74,
392 DPP_TEST_INVALID_STATUS_AUTH_CONF = 75,
f9cf7d03 393 DPP_TEST_INVALID_CONFIG_ATTR_OBJ_CONF_REQ = 76,
4b8de0c9
JM
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,
a4446739 398 DPP_TEST_INVALID_I_NONCE_AUTH_REQ = 81,
55c6c858 399 DPP_TEST_INVALID_TRANSACTION_ID_PEER_DISC_REQ = 82,
f0a383a9 400 DPP_TEST_INVALID_E_NONCE_CONF_REQ = 83,
34603767
JM
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,
67b3bcc9 408 DPP_TEST_REJECT_CONFIG = 91,
60239f60
JM
409};
410
411extern enum dpp_test_behavior dpp_test;
2bdc47a9
JM
412extern u8 dpp_pkex_own_mac_override[ETH_ALEN];
413extern u8 dpp_pkex_peer_mac_override[ETH_ALEN];
acc555f9
JM
414extern u8 dpp_pkex_ephemeral_key_override[600];
415extern size_t dpp_pkex_ephemeral_key_override_len;
f5526975
JM
416extern u8 dpp_protocol_key_override[600];
417extern size_t dpp_protocol_key_override_len;
055cd397
JM
418extern u8 dpp_nonce_override[DPP_MAX_NONCE_LEN];
419extern size_t dpp_nonce_override_len;
60239f60
JM
420#endif /* CONFIG_TESTING_OPTIONS */
421
be27e185 422void dpp_bootstrap_info_free(struct dpp_bootstrap_info *info);
484788b8 423const char * dpp_bootstrap_type_txt(enum dpp_bootstrap_type type);
500ed7f0 424int dpp_bootstrap_key_hash(struct dpp_bootstrap_info *bi);
be27e185
JM
425int dpp_parse_uri_chan_list(struct dpp_bootstrap_info *bi,
426 const char *chan_list);
427int dpp_parse_uri_mac(struct dpp_bootstrap_info *bi, const char *mac);
428int dpp_parse_uri_info(struct dpp_bootstrap_info *bi, const char *info);
5e287724
JM
429int dpp_nfc_update_bi(struct dpp_bootstrap_info *own_bi,
430 struct dpp_bootstrap_info *peer_bi);
f97ace34 431struct hostapd_hw_modes;
30d27b04
JM
432struct dpp_authentication * dpp_auth_init(void *msg_ctx,
433 struct dpp_bootstrap_info *peer_bi,
434 struct dpp_bootstrap_info *own_bi,
d1f08264 435 u8 dpp_allowed_roles,
f97ace34
JM
436 unsigned int neg_freq,
437 struct hostapd_hw_modes *own_modes,
438 u16 num_modes);
30d27b04
JM
439struct dpp_authentication *
440dpp_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,
dc4d271c 443 unsigned int freq, const u8 *hdr, const u8 *attr_start,
27fefbbb 444 size_t attr_len);
30d27b04 445struct wpabuf *
dc4d271c
JM
446dpp_auth_resp_rx(struct dpp_authentication *auth, const u8 *hdr,
447 const u8 *attr_start, size_t attr_len);
461d39af
JM
448struct wpabuf * dpp_build_conf_req(struct dpp_authentication *auth,
449 const char *json);
5a5639b0 450struct wpabuf * dpp_build_conf_req_helper(struct dpp_authentication *auth,
74045744
JM
451 const char *name,
452 enum dpp_netrole netrole,
8f8c423a 453 const char *mud_url, int *opclasses);
dc4d271c
JM
454int dpp_auth_conf_rx(struct dpp_authentication *auth, const u8 *hdr,
455 const u8 *attr_start, size_t attr_len);
30d27b04
JM
456int dpp_notify_new_qr_code(struct dpp_authentication *auth,
457 struct dpp_bootstrap_info *peer_bi);
9305c233 458struct dpp_configuration * dpp_configuration_alloc(const char *type);
18015fc8
JM
459int dpp_akm_psk(enum dpp_akm akm);
460int dpp_akm_sae(enum dpp_akm akm);
461int dpp_akm_legacy(enum dpp_akm akm);
462int dpp_akm_dpp(enum dpp_akm akm);
463int dpp_akm_ver2(enum dpp_akm akm);
9305c233 464int dpp_configuration_valid(const struct dpp_configuration *conf);
461d39af 465void dpp_configuration_free(struct dpp_configuration *conf);
87d8435c
JM
466int dpp_set_configurator(struct dpp_global *dpp, void *msg_ctx,
467 struct dpp_authentication *auth,
468 const char *cmd);
30d27b04 469void dpp_auth_deinit(struct dpp_authentication *auth);
461d39af
JM
470struct wpabuf *
471dpp_conf_req_rx(struct dpp_authentication *auth, const u8 *attr_start,
472 size_t attr_len);
473int dpp_conf_resp_rx(struct dpp_authentication *auth,
474 const struct wpabuf *resp);
22f90b32
JM
475enum dpp_status_error dpp_conf_result_rx(struct dpp_authentication *auth,
476 const u8 *hdr,
477 const u8 *attr_start, size_t attr_len);
478struct wpabuf * dpp_build_conf_result(struct dpp_authentication *auth,
479 enum dpp_status_error status);
b10e01a7
JM
480enum 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);
16ef233b
JM
486struct 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);
30d27b04
JM
490struct wpabuf * dpp_alloc_msg(enum dpp_public_action_frame_type type,
491 size_t len);
492const u8 * dpp_get_attr(const u8 *buf, size_t len, u16 req_id, u16 *ret_len);
493int dpp_check_attrs(const u8 *buf, size_t len);
461d39af 494int dpp_key_expired(const char *timestamp, os_time_t *expiry);
5dd745b7 495const char * dpp_akm_str(enum dpp_akm akm);
68fea960 496const char * dpp_akm_selector_str(enum dpp_akm akm);
8179ae3a
PK
497int dpp_configurator_get_key(const struct dpp_configurator *conf, char *buf,
498 size_t buflen);
461d39af
JM
499void dpp_configurator_free(struct dpp_configurator *conf);
500struct dpp_configurator *
501dpp_keygen_configurator(const char *curve, const u8 *privkey,
502 size_t privkey_len);
f522bb23 503int dpp_configurator_own_config(struct dpp_authentication *auth,
a2588be8 504 const char *curve, int ap);
e85b6601
JM
505enum dpp_status_error
506dpp_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);
219d4c9f 511struct dpp_pkex * dpp_pkex_init(void *msg_ctx, struct dpp_bootstrap_info *bi,
500ed7f0
JM
512 const u8 *own_mac,
513 const char *identifier,
514 const char *code);
219d4c9f
JM
515struct dpp_pkex * dpp_pkex_rx_exchange_req(void *msg_ctx,
516 struct dpp_bootstrap_info *bi,
500ed7f0
JM
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);
522struct wpabuf * dpp_pkex_rx_exchange_resp(struct dpp_pkex *pkex,
af4103e5 523 const u8 *peer_mac,
500ed7f0
JM
524 const u8 *buf, size_t len);
525struct wpabuf * dpp_pkex_rx_commit_reveal_req(struct dpp_pkex *pkex,
4be5bc98 526 const u8 *hdr,
500ed7f0 527 const u8 *buf, size_t len);
4be5bc98 528int dpp_pkex_rx_commit_reveal_resp(struct dpp_pkex *pkex, const u8 *hdr,
500ed7f0
JM
529 const u8 *buf, size_t len);
530void dpp_pkex_free(struct dpp_pkex *pkex);
be27e185 531
4b8de0c9
JM
532char * dpp_corrupt_connector_signature(const char *connector);
533
10ec6a5f
JM
534
535struct dpp_pfs {
536 struct crypto_ecdh *ecdh;
537 const struct dpp_curve_params *curve;
538 struct wpabuf *ie;
539 struct wpabuf *secret;
540};
541
542struct dpp_pfs * dpp_pfs_init(const u8 *net_access_key,
543 size_t net_access_key_len);
544int dpp_pfs_process(struct dpp_pfs *pfs, const u8 *peer_ie, size_t peer_ie_len);
545void dpp_pfs_free(struct dpp_pfs *pfs);
546
87d8435c
JM
547struct dpp_bootstrap_info * dpp_add_qr_code(struct dpp_global *dpp,
548 const char *uri);
e780b4bf
JM
549struct dpp_bootstrap_info * dpp_add_nfc_uri(struct dpp_global *dpp,
550 const char *uri);
87d8435c
JM
551int dpp_bootstrap_gen(struct dpp_global *dpp, const char *cmd);
552struct dpp_bootstrap_info *
553dpp_bootstrap_get_id(struct dpp_global *dpp, unsigned int id);
554int dpp_bootstrap_remove(struct dpp_global *dpp, const char *id);
555struct dpp_bootstrap_info *
556dpp_pkex_finish(struct dpp_global *dpp, struct dpp_pkex *pkex, const u8 *peer,
557 unsigned int freq);
558const char * dpp_bootstrap_get_uri(struct dpp_global *dpp, unsigned int id);
559int dpp_bootstrap_info(struct dpp_global *dpp, int id,
560 char *reply, int reply_size);
561void 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);
565int dpp_configurator_add(struct dpp_global *dpp, const char *cmd);
566int dpp_configurator_remove(struct dpp_global *dpp, const char *id);
567int dpp_configurator_get_key_id(struct dpp_global *dpp, unsigned int id,
568 char *buf, size_t buflen);
7d9e3200
JM
569int dpp_configurator_from_backup(struct dpp_global *dpp,
570 struct dpp_asymmetric_key *key);
88a78bdd
JM
571int dpp_relay_add_controller(struct dpp_global *dpp,
572 struct dpp_relay_config *config);
573int 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);
576int dpp_relay_rx_gas_req(struct dpp_global *dpp, const u8 *src, const u8 *data,
577 size_t data_len);
578int dpp_controller_start(struct dpp_global *dpp,
579 struct dpp_controller_config *config);
580void dpp_controller_stop(struct dpp_global *dpp);
581int dpp_tcp_init(struct dpp_global *dpp, struct dpp_authentication *auth,
582 const struct hostapd_ip_addr *addr, int port);
2ed2b52f
JM
583
584struct dpp_global_config {
585 void *msg_ctx;
88a78bdd
JM
586 void *cb_ctx;
587 int (*process_conf_obj)(void *ctx, struct dpp_authentication *auth);
2ed2b52f
JM
588};
589
590struct dpp_global * dpp_global_init(struct dpp_global_config *config);
87d8435c
JM
591void dpp_global_clear(struct dpp_global *dpp);
592void dpp_global_deinit(struct dpp_global *dpp);
593
1326cb76 594#endif /* CONFIG_DPP */
be27e185 595#endif /* DPP_H */