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