]> git.ipfire.org Git - thirdparty/hostap.git/blame - src/common/dpp.h
DPP: Use JSON token builder helpers
[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.
0b4a906d 4 * Copyright (c) 2018-2019, 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,
be27e185
JM
109};
110
111struct dpp_bootstrap_info {
112 struct dl_list list;
113 unsigned int id;
114 enum dpp_bootstrap_type type;
115 char *uri;
116 u8 mac_addr[ETH_ALEN];
117 char *info;
118 unsigned int freq[DPP_BOOTSTRAP_MAX_FREQ];
119 unsigned int num_freq;
120 int own;
121 EVP_PKEY *pubkey;
122 u8 pubkey_hash[SHA256_MAC_LEN];
123 const struct dpp_curve_params *curve;
29ab69e4
JM
124 unsigned int pkex_t; /* number of failures before dpp_pkex
125 * instantiation */
be27e185
JM
126};
127
29ab69e4
JM
128#define PKEX_COUNTER_T_LIMIT 5
129
500ed7f0 130struct dpp_pkex {
219d4c9f 131 void *msg_ctx;
500ed7f0
JM
132 unsigned int initiator:1;
133 unsigned int exchange_done:1;
e0247e79 134 unsigned int failed:1;
500ed7f0
JM
135 struct dpp_bootstrap_info *own_bi;
136 u8 own_mac[ETH_ALEN];
137 u8 peer_mac[ETH_ALEN];
138 char *identifier;
139 char *code;
140 EVP_PKEY *x;
141 EVP_PKEY *y;
142 u8 Mx[DPP_MAX_SHARED_SECRET_LEN];
143 u8 Nx[DPP_MAX_SHARED_SECRET_LEN];
144 u8 z[DPP_MAX_HASH_LEN];
145 EVP_PKEY *peer_bootstrap_key;
146 struct wpabuf *exchange_req;
147 struct wpabuf *exchange_resp;
29ab69e4 148 unsigned int t; /* number of failures on code use */
00d2d13d
JM
149 unsigned int exch_req_wait_time;
150 unsigned int exch_req_tries;
151 unsigned int freq;
500ed7f0
JM
152};
153
5dd745b7
JM
154enum dpp_akm {
155 DPP_AKM_UNKNOWN,
156 DPP_AKM_DPP,
157 DPP_AKM_PSK,
158 DPP_AKM_SAE,
18015fc8
JM
159 DPP_AKM_PSK_SAE,
160 DPP_AKM_SAE_DPP,
161 DPP_AKM_PSK_SAE_DPP,
5dd745b7
JM
162};
163
99918e06
JM
164enum dpp_netrole {
165 DPP_NETROLE_STA,
166 DPP_NETROLE_AP,
167};
168
461d39af
JM
169struct dpp_configuration {
170 u8 ssid[32];
171 size_t ssid_len;
e3a5882b 172 enum dpp_akm akm;
99918e06 173 enum dpp_netrole netrole;
461d39af
JM
174
175 /* For DPP configuration (connector) */
176 os_time_t netaccesskey_expiry;
177
a4bf0078 178 /* TODO: groups */
20f612d9 179 char *group_id;
461d39af
JM
180
181 /* For legacy configuration */
182 char *passphrase;
183 u8 psk[32];
9305c233 184 int psk_set;
461d39af
JM
185};
186
52d469de
JM
187#define DPP_MAX_CONF_OBJ 10
188
30d27b04
JM
189struct dpp_authentication {
190 void *msg_ctx;
0b4a906d 191 u8 peer_version;
30d27b04
JM
192 const struct dpp_curve_params *curve;
193 struct dpp_bootstrap_info *peer_bi;
194 struct dpp_bootstrap_info *own_bi;
73f21929 195 struct dpp_bootstrap_info *tmp_own_bi;
30d27b04
JM
196 u8 waiting_pubkey_hash[SHA256_MAC_LEN];
197 int response_pending;
198 enum dpp_status_error auth_resp_status;
22f90b32 199 enum dpp_status_error conf_resp_status;
30d27b04
JM
200 u8 peer_mac_addr[ETH_ALEN];
201 u8 i_nonce[DPP_MAX_NONCE_LEN];
202 u8 r_nonce[DPP_MAX_NONCE_LEN];
461d39af 203 u8 e_nonce[DPP_MAX_NONCE_LEN];
30d27b04
JM
204 u8 i_capab;
205 u8 r_capab;
206 EVP_PKEY *own_protocol_key;
207 EVP_PKEY *peer_protocol_key;
dc4d271c
JM
208 struct wpabuf *req_msg;
209 struct wpabuf *resp_msg;
f97ace34
JM
210 /* Intersection of possible frequencies for initiating DPP
211 * Authentication exchange */
212 unsigned int freq[DPP_BOOTSTRAP_MAX_FREQ];
213 unsigned int num_freq, freq_idx;
30d27b04 214 unsigned int curr_freq;
d2709206 215 unsigned int neg_freq;
f97ace34 216 unsigned int num_freq_iters;
30d27b04
JM
217 size_t secret_len;
218 u8 Mx[DPP_MAX_SHARED_SECRET_LEN];
630ea133 219 size_t Mx_len;
30d27b04 220 u8 Nx[DPP_MAX_SHARED_SECRET_LEN];
630ea133 221 size_t Nx_len;
30d27b04 222 u8 Lx[DPP_MAX_SHARED_SECRET_LEN];
630ea133 223 size_t Lx_len;
30d27b04
JM
224 u8 k1[DPP_MAX_HASH_LEN];
225 u8 k2[DPP_MAX_HASH_LEN];
226 u8 ke[DPP_MAX_HASH_LEN];
227 int initiator;
f97ace34 228 int waiting_auth_resp;
95b0104a 229 int waiting_auth_conf;
248264c6 230 int auth_req_ack;
95b0104a 231 unsigned int auth_resp_tries;
d1f08264 232 u8 allowed_roles;
30d27b04
JM
233 int configurator;
234 int remove_on_tx_status;
22f90b32
JM
235 int connect_on_tx_status;
236 int waiting_conf_result;
b10e01a7 237 int waiting_conn_status_result;
30d27b04 238 int auth_success;
461d39af 239 struct wpabuf *conf_req;
82feacce 240 const struct wpabuf *conf_resp; /* owned by GAS server */
461d39af 241 struct dpp_configuration *conf_ap;
7eb06a33 242 struct dpp_configuration *conf2_ap;
461d39af 243 struct dpp_configuration *conf_sta;
7eb06a33 244 struct dpp_configuration *conf2_sta;
461d39af 245 struct dpp_configurator *conf;
52d469de
JM
246 struct dpp_config_obj {
247 char *connector; /* received signedConnector */
248 u8 ssid[SSID_MAX_LEN];
249 u8 ssid_len;
250 char passphrase[64];
251 u8 psk[PMK_LEN];
252 int psk_set;
253 enum dpp_akm akm;
254 struct wpabuf *c_sign_key;
255 } conf_obj[DPP_MAX_CONF_OBJ];
256 unsigned int num_conf_obj;
461d39af
JM
257 struct wpabuf *net_access_key;
258 os_time_t net_access_key_expiry;
b10e01a7 259 int send_conn_status;
16ef233b 260 int conn_status_requested;
68fea960 261 int akm_use_selector;
461d39af
JM
262#ifdef CONFIG_TESTING_OPTIONS
263 char *config_obj_override;
264 char *discovery_override;
265 char *groups_override;
461d39af
JM
266 unsigned int ignore_netaccesskey_mismatch:1;
267#endif /* CONFIG_TESTING_OPTIONS */
268};
269
270struct dpp_configurator {
271 struct dl_list list;
272 unsigned int id;
273 int own;
274 EVP_PKEY *csign;
275 char *kid;
276 const struct dpp_curve_params *curve;
30d27b04
JM
277};
278
650a70a7
JM
279struct dpp_introduction {
280 u8 pmkid[PMKID_LEN];
281 u8 pmk[PMK_LEN_MAX];
282 size_t pmk_len;
650a70a7
JM
283};
284
88a78bdd
JM
285struct dpp_relay_config {
286 const struct hostapd_ip_addr *ipaddr;
287 const u8 *pkhash;
288
289 void *cb_ctx;
290 void (*tx)(void *ctx, const u8 *addr, unsigned int freq, const u8 *msg,
291 size_t len);
292 void (*gas_resp_tx)(void *ctx, const u8 *addr, u8 dialog_token, int prot,
293 struct wpabuf *buf);
294};
295
296struct dpp_controller_config {
297 const char *configurator_params;
298 int tcp_port;
299};
300
60239f60
JM
301#ifdef CONFIG_TESTING_OPTIONS
302enum dpp_test_behavior {
303 DPP_TEST_DISABLED = 0,
304 DPP_TEST_AFTER_WRAPPED_DATA_AUTH_REQ = 1,
305 DPP_TEST_AFTER_WRAPPED_DATA_AUTH_RESP = 2,
306 DPP_TEST_AFTER_WRAPPED_DATA_AUTH_CONF = 3,
307 DPP_TEST_AFTER_WRAPPED_DATA_PKEX_CR_REQ = 4,
308 DPP_TEST_AFTER_WRAPPED_DATA_PKEX_CR_RESP = 5,
309 DPP_TEST_AFTER_WRAPPED_DATA_CONF_REQ = 6,
310 DPP_TEST_AFTER_WRAPPED_DATA_CONF_RESP = 7,
311 DPP_TEST_ZERO_I_CAPAB = 8,
312 DPP_TEST_ZERO_R_CAPAB = 9,
0e7cb8c6
JM
313 DPP_TEST_NO_R_BOOTSTRAP_KEY_HASH_AUTH_REQ = 10,
314 DPP_TEST_NO_I_BOOTSTRAP_KEY_HASH_AUTH_REQ = 11,
315 DPP_TEST_NO_I_PROTO_KEY_AUTH_REQ = 12,
316 DPP_TEST_NO_I_NONCE_AUTH_REQ = 13,
317 DPP_TEST_NO_I_CAPAB_AUTH_REQ = 14,
318 DPP_TEST_NO_WRAPPED_DATA_AUTH_REQ = 15,
ce9acce0
JM
319 DPP_TEST_NO_STATUS_AUTH_RESP = 16,
320 DPP_TEST_NO_R_BOOTSTRAP_KEY_HASH_AUTH_RESP = 17,
321 DPP_TEST_NO_I_BOOTSTRAP_KEY_HASH_AUTH_RESP = 18,
322 DPP_TEST_NO_R_PROTO_KEY_AUTH_RESP = 19,
323 DPP_TEST_NO_R_NONCE_AUTH_RESP = 20,
324 DPP_TEST_NO_I_NONCE_AUTH_RESP = 21,
325 DPP_TEST_NO_R_CAPAB_AUTH_RESP = 22,
326 DPP_TEST_NO_R_AUTH_AUTH_RESP = 23,
327 DPP_TEST_NO_WRAPPED_DATA_AUTH_RESP = 24,
f9c7d770
JM
328 DPP_TEST_NO_STATUS_AUTH_CONF = 25,
329 DPP_TEST_NO_R_BOOTSTRAP_KEY_HASH_AUTH_CONF = 26,
330 DPP_TEST_NO_I_BOOTSTRAP_KEY_HASH_AUTH_CONF = 27,
331 DPP_TEST_NO_I_AUTH_AUTH_CONF = 28,
332 DPP_TEST_NO_WRAPPED_DATA_AUTH_CONF = 29,
978bc3f2
JM
333 DPP_TEST_I_NONCE_MISMATCH_AUTH_RESP = 30,
334 DPP_TEST_INCOMPATIBLE_R_CAPAB_AUTH_RESP = 31,
335 DPP_TEST_R_AUTH_MISMATCH_AUTH_RESP = 32,
336 DPP_TEST_I_AUTH_MISMATCH_AUTH_CONF = 33,
61f9f27f
JM
337 DPP_TEST_NO_FINITE_CYCLIC_GROUP_PKEX_EXCHANGE_REQ = 34,
338 DPP_TEST_NO_ENCRYPTED_KEY_PKEX_EXCHANGE_REQ = 35,
339 DPP_TEST_NO_STATUS_PKEX_EXCHANGE_RESP = 36,
340 DPP_TEST_NO_ENCRYPTED_KEY_PKEX_EXCHANGE_RESP = 37,
341 DPP_TEST_NO_BOOTSTRAP_KEY_PKEX_CR_REQ = 38,
342 DPP_TEST_NO_I_AUTH_TAG_PKEX_CR_REQ = 39,
343 DPP_TEST_NO_WRAPPED_DATA_PKEX_CR_REQ = 40,
344 DPP_TEST_NO_BOOTSTRAP_KEY_PKEX_CR_RESP = 41,
345 DPP_TEST_NO_R_AUTH_TAG_PKEX_CR_RESP = 42,
346 DPP_TEST_NO_WRAPPED_DATA_PKEX_CR_RESP = 43,
1cfcbd32
JM
347 DPP_TEST_INVALID_ENCRYPTED_KEY_PKEX_EXCHANGE_REQ = 44,
348 DPP_TEST_INVALID_ENCRYPTED_KEY_PKEX_EXCHANGE_RESP = 45,
f31ef96d 349 DPP_TEST_INVALID_STATUS_PKEX_EXCHANGE_RESP = 46,
89d0bf67
JM
350 DPP_TEST_INVALID_BOOTSTRAP_KEY_PKEX_CR_REQ = 47,
351 DPP_TEST_INVALID_BOOTSTRAP_KEY_PKEX_CR_RESP = 48,
7e0ebe21
JM
352 DPP_TEST_I_AUTH_TAG_MISMATCH_PKEX_CR_REQ = 49,
353 DPP_TEST_R_AUTH_TAG_MISMATCH_PKEX_CR_RESP = 50,
f411ad1b
JM
354 DPP_TEST_NO_E_NONCE_CONF_REQ = 51,
355 DPP_TEST_NO_CONFIG_ATTR_OBJ_CONF_REQ = 52,
356 DPP_TEST_NO_WRAPPED_DATA_CONF_REQ = 53,
357 DPP_TEST_NO_E_NONCE_CONF_RESP = 54,
358 DPP_TEST_NO_CONFIG_OBJ_CONF_RESP = 55,
359 DPP_TEST_NO_STATUS_CONF_RESP = 56,
360 DPP_TEST_NO_WRAPPED_DATA_CONF_RESP = 57,
af7f10fc
JM
361 DPP_TEST_INVALID_STATUS_CONF_RESP = 58,
362 DPP_TEST_E_NONCE_MISMATCH_CONF_RESP = 59,
a306ed5a
JM
363 DPP_TEST_NO_TRANSACTION_ID_PEER_DISC_REQ = 60,
364 DPP_TEST_NO_CONNECTOR_PEER_DISC_REQ = 61,
365 DPP_TEST_NO_TRANSACTION_ID_PEER_DISC_RESP = 62,
366 DPP_TEST_NO_STATUS_PEER_DISC_RESP = 63,
367 DPP_TEST_NO_CONNECTOR_PEER_DISC_RESP = 64,
762fb4f0 368 DPP_TEST_AUTH_RESP_IN_PLACE_OF_CONF = 65,
b6b4226b
JM
369 DPP_TEST_INVALID_I_PROTO_KEY_AUTH_REQ = 66,
370 DPP_TEST_INVALID_R_PROTO_KEY_AUTH_RESP = 67,
65ecce87
JM
371 DPP_TEST_INVALID_R_BOOTSTRAP_KEY_HASH_AUTH_REQ = 68,
372 DPP_TEST_INVALID_I_BOOTSTRAP_KEY_HASH_AUTH_REQ = 69,
373 DPP_TEST_INVALID_R_BOOTSTRAP_KEY_HASH_AUTH_RESP = 70,
374 DPP_TEST_INVALID_I_BOOTSTRAP_KEY_HASH_AUTH_RESP = 71,
375 DPP_TEST_INVALID_R_BOOTSTRAP_KEY_HASH_AUTH_CONF = 72,
376 DPP_TEST_INVALID_I_BOOTSTRAP_KEY_HASH_AUTH_CONF = 73,
3f35ec2d
JM
377 DPP_TEST_INVALID_STATUS_AUTH_RESP = 74,
378 DPP_TEST_INVALID_STATUS_AUTH_CONF = 75,
f9cf7d03 379 DPP_TEST_INVALID_CONFIG_ATTR_OBJ_CONF_REQ = 76,
4b8de0c9
JM
380 DPP_TEST_INVALID_TRANSACTION_ID_PEER_DISC_RESP = 77,
381 DPP_TEST_INVALID_STATUS_PEER_DISC_RESP = 78,
382 DPP_TEST_INVALID_CONNECTOR_PEER_DISC_RESP = 79,
383 DPP_TEST_INVALID_CONNECTOR_PEER_DISC_REQ = 80,
a4446739 384 DPP_TEST_INVALID_I_NONCE_AUTH_REQ = 81,
55c6c858 385 DPP_TEST_INVALID_TRANSACTION_ID_PEER_DISC_REQ = 82,
f0a383a9 386 DPP_TEST_INVALID_E_NONCE_CONF_REQ = 83,
34603767
JM
387 DPP_TEST_STOP_AT_PKEX_EXCHANGE_RESP = 84,
388 DPP_TEST_STOP_AT_PKEX_CR_REQ = 85,
389 DPP_TEST_STOP_AT_PKEX_CR_RESP = 86,
390 DPP_TEST_STOP_AT_AUTH_REQ = 87,
391 DPP_TEST_STOP_AT_AUTH_RESP = 88,
392 DPP_TEST_STOP_AT_AUTH_CONF = 89,
393 DPP_TEST_STOP_AT_CONF_REQ = 90,
67b3bcc9 394 DPP_TEST_REJECT_CONFIG = 91,
60239f60
JM
395};
396
397extern enum dpp_test_behavior dpp_test;
2bdc47a9
JM
398extern u8 dpp_pkex_own_mac_override[ETH_ALEN];
399extern u8 dpp_pkex_peer_mac_override[ETH_ALEN];
acc555f9
JM
400extern u8 dpp_pkex_ephemeral_key_override[600];
401extern size_t dpp_pkex_ephemeral_key_override_len;
f5526975
JM
402extern u8 dpp_protocol_key_override[600];
403extern size_t dpp_protocol_key_override_len;
055cd397
JM
404extern u8 dpp_nonce_override[DPP_MAX_NONCE_LEN];
405extern size_t dpp_nonce_override_len;
60239f60
JM
406#endif /* CONFIG_TESTING_OPTIONS */
407
be27e185 408void dpp_bootstrap_info_free(struct dpp_bootstrap_info *info);
484788b8 409const char * dpp_bootstrap_type_txt(enum dpp_bootstrap_type type);
500ed7f0 410int dpp_bootstrap_key_hash(struct dpp_bootstrap_info *bi);
be27e185
JM
411int dpp_parse_uri_chan_list(struct dpp_bootstrap_info *bi,
412 const char *chan_list);
413int dpp_parse_uri_mac(struct dpp_bootstrap_info *bi, const char *mac);
414int dpp_parse_uri_info(struct dpp_bootstrap_info *bi, const char *info);
415struct dpp_bootstrap_info * dpp_parse_qr_code(const char *uri);
416char * dpp_keygen(struct dpp_bootstrap_info *bi, const char *curve,
417 const u8 *privkey, size_t privkey_len);
f97ace34 418struct hostapd_hw_modes;
30d27b04
JM
419struct dpp_authentication * dpp_auth_init(void *msg_ctx,
420 struct dpp_bootstrap_info *peer_bi,
421 struct dpp_bootstrap_info *own_bi,
d1f08264 422 u8 dpp_allowed_roles,
f97ace34
JM
423 unsigned int neg_freq,
424 struct hostapd_hw_modes *own_modes,
425 u16 num_modes);
30d27b04
JM
426struct dpp_authentication *
427dpp_auth_req_rx(void *msg_ctx, u8 dpp_allowed_roles, int qr_mutual,
428 struct dpp_bootstrap_info *peer_bi,
429 struct dpp_bootstrap_info *own_bi,
dc4d271c 430 unsigned int freq, const u8 *hdr, const u8 *attr_start,
27fefbbb 431 size_t attr_len);
30d27b04 432struct wpabuf *
dc4d271c
JM
433dpp_auth_resp_rx(struct dpp_authentication *auth, const u8 *hdr,
434 const u8 *attr_start, size_t attr_len);
461d39af
JM
435struct wpabuf * dpp_build_conf_req(struct dpp_authentication *auth,
436 const char *json);
5a5639b0
JM
437struct wpabuf * dpp_build_conf_req_helper(struct dpp_authentication *auth,
438 const char *name, int netrole_ap,
8f8c423a 439 const char *mud_url, int *opclasses);
dc4d271c
JM
440int dpp_auth_conf_rx(struct dpp_authentication *auth, const u8 *hdr,
441 const u8 *attr_start, size_t attr_len);
30d27b04
JM
442int dpp_notify_new_qr_code(struct dpp_authentication *auth,
443 struct dpp_bootstrap_info *peer_bi);
9305c233 444struct dpp_configuration * dpp_configuration_alloc(const char *type);
18015fc8
JM
445int dpp_akm_psk(enum dpp_akm akm);
446int dpp_akm_sae(enum dpp_akm akm);
447int dpp_akm_legacy(enum dpp_akm akm);
448int dpp_akm_dpp(enum dpp_akm akm);
449int dpp_akm_ver2(enum dpp_akm akm);
9305c233 450int dpp_configuration_valid(const struct dpp_configuration *conf);
461d39af 451void dpp_configuration_free(struct dpp_configuration *conf);
87d8435c
JM
452int dpp_set_configurator(struct dpp_global *dpp, void *msg_ctx,
453 struct dpp_authentication *auth,
454 const char *cmd);
30d27b04 455void dpp_auth_deinit(struct dpp_authentication *auth);
461d39af
JM
456struct wpabuf *
457dpp_conf_req_rx(struct dpp_authentication *auth, const u8 *attr_start,
458 size_t attr_len);
459int dpp_conf_resp_rx(struct dpp_authentication *auth,
460 const struct wpabuf *resp);
22f90b32
JM
461enum dpp_status_error dpp_conf_result_rx(struct dpp_authentication *auth,
462 const u8 *hdr,
463 const u8 *attr_start, size_t attr_len);
464struct wpabuf * dpp_build_conf_result(struct dpp_authentication *auth,
465 enum dpp_status_error status);
b10e01a7
JM
466enum dpp_status_error dpp_conn_status_result_rx(struct dpp_authentication *auth,
467 const u8 *hdr,
468 const u8 *attr_start,
469 size_t attr_len,
470 u8 *ssid, size_t *ssid_len,
471 char **channel_list);
16ef233b
JM
472struct wpabuf * dpp_build_conn_status_result(struct dpp_authentication *auth,
473 enum dpp_status_error result,
474 const u8 *ssid, size_t ssid_len,
475 const char *channel_list);
30d27b04
JM
476struct wpabuf * dpp_alloc_msg(enum dpp_public_action_frame_type type,
477 size_t len);
478const u8 * dpp_get_attr(const u8 *buf, size_t len, u16 req_id, u16 *ret_len);
479int dpp_check_attrs(const u8 *buf, size_t len);
461d39af 480int dpp_key_expired(const char *timestamp, os_time_t *expiry);
5dd745b7 481const char * dpp_akm_str(enum dpp_akm akm);
68fea960 482const char * dpp_akm_selector_str(enum dpp_akm akm);
8179ae3a
PK
483int dpp_configurator_get_key(const struct dpp_configurator *conf, char *buf,
484 size_t buflen);
461d39af
JM
485void dpp_configurator_free(struct dpp_configurator *conf);
486struct dpp_configurator *
487dpp_keygen_configurator(const char *curve, const u8 *privkey,
488 size_t privkey_len);
f522bb23 489int dpp_configurator_own_config(struct dpp_authentication *auth,
a2588be8 490 const char *curve, int ap);
e85b6601
JM
491enum dpp_status_error
492dpp_peer_intro(struct dpp_introduction *intro, const char *own_connector,
493 const u8 *net_access_key, size_t net_access_key_len,
494 const u8 *csign_key, size_t csign_key_len,
495 const u8 *peer_connector, size_t peer_connector_len,
496 os_time_t *expiry);
219d4c9f 497struct dpp_pkex * dpp_pkex_init(void *msg_ctx, struct dpp_bootstrap_info *bi,
500ed7f0
JM
498 const u8 *own_mac,
499 const char *identifier,
500 const char *code);
219d4c9f
JM
501struct dpp_pkex * dpp_pkex_rx_exchange_req(void *msg_ctx,
502 struct dpp_bootstrap_info *bi,
500ed7f0
JM
503 const u8 *own_mac,
504 const u8 *peer_mac,
505 const char *identifier,
506 const char *code,
507 const u8 *buf, size_t len);
508struct wpabuf * dpp_pkex_rx_exchange_resp(struct dpp_pkex *pkex,
af4103e5 509 const u8 *peer_mac,
500ed7f0
JM
510 const u8 *buf, size_t len);
511struct wpabuf * dpp_pkex_rx_commit_reveal_req(struct dpp_pkex *pkex,
4be5bc98 512 const u8 *hdr,
500ed7f0 513 const u8 *buf, size_t len);
4be5bc98 514int dpp_pkex_rx_commit_reveal_resp(struct dpp_pkex *pkex, const u8 *hdr,
500ed7f0
JM
515 const u8 *buf, size_t len);
516void dpp_pkex_free(struct dpp_pkex *pkex);
be27e185 517
4b8de0c9
JM
518char * dpp_corrupt_connector_signature(const char *connector);
519
10ec6a5f
JM
520
521struct dpp_pfs {
522 struct crypto_ecdh *ecdh;
523 const struct dpp_curve_params *curve;
524 struct wpabuf *ie;
525 struct wpabuf *secret;
526};
527
528struct dpp_pfs * dpp_pfs_init(const u8 *net_access_key,
529 size_t net_access_key_len);
530int dpp_pfs_process(struct dpp_pfs *pfs, const u8 *peer_ie, size_t peer_ie_len);
531void dpp_pfs_free(struct dpp_pfs *pfs);
532
87d8435c
JM
533struct dpp_bootstrap_info * dpp_add_qr_code(struct dpp_global *dpp,
534 const char *uri);
535int dpp_bootstrap_gen(struct dpp_global *dpp, const char *cmd);
536struct dpp_bootstrap_info *
537dpp_bootstrap_get_id(struct dpp_global *dpp, unsigned int id);
538int dpp_bootstrap_remove(struct dpp_global *dpp, const char *id);
539struct dpp_bootstrap_info *
540dpp_pkex_finish(struct dpp_global *dpp, struct dpp_pkex *pkex, const u8 *peer,
541 unsigned int freq);
542const char * dpp_bootstrap_get_uri(struct dpp_global *dpp, unsigned int id);
543int dpp_bootstrap_info(struct dpp_global *dpp, int id,
544 char *reply, int reply_size);
545void dpp_bootstrap_find_pair(struct dpp_global *dpp, const u8 *i_bootstrap,
546 const u8 *r_bootstrap,
547 struct dpp_bootstrap_info **own_bi,
548 struct dpp_bootstrap_info **peer_bi);
549int dpp_configurator_add(struct dpp_global *dpp, const char *cmd);
550int dpp_configurator_remove(struct dpp_global *dpp, const char *id);
551int dpp_configurator_get_key_id(struct dpp_global *dpp, unsigned int id,
552 char *buf, size_t buflen);
88a78bdd
JM
553int dpp_relay_add_controller(struct dpp_global *dpp,
554 struct dpp_relay_config *config);
555int dpp_relay_rx_action(struct dpp_global *dpp, const u8 *src, const u8 *hdr,
556 const u8 *buf, size_t len, unsigned int freq,
557 const u8 *i_bootstrap, const u8 *r_bootstrap);
558int dpp_relay_rx_gas_req(struct dpp_global *dpp, const u8 *src, const u8 *data,
559 size_t data_len);
560int dpp_controller_start(struct dpp_global *dpp,
561 struct dpp_controller_config *config);
562void dpp_controller_stop(struct dpp_global *dpp);
563int dpp_tcp_init(struct dpp_global *dpp, struct dpp_authentication *auth,
564 const struct hostapd_ip_addr *addr, int port);
2ed2b52f
JM
565
566struct dpp_global_config {
567 void *msg_ctx;
88a78bdd
JM
568 void *cb_ctx;
569 int (*process_conf_obj)(void *ctx, struct dpp_authentication *auth);
2ed2b52f
JM
570};
571
572struct dpp_global * dpp_global_init(struct dpp_global_config *config);
87d8435c
JM
573void dpp_global_clear(struct dpp_global *dpp);
574void dpp_global_deinit(struct dpp_global *dpp);
575
1326cb76 576#endif /* CONFIG_DPP */
be27e185 577#endif /* DPP_H */