blob: 6e397c3de16dbdbbb062fc5c0cf806ab9666c4d0 [file] [log] [blame]
Dmitry Shmidtd2986c22017-10-23 14:22:09 -07001/*
2 * DPP functionality shared between hostapd and wpa_supplicant
3 * Copyright (c) 2017, Qualcomm Atheros, Inc.
Hai Shalomfdcde762020-04-02 11:19:20 -07004 * Copyright (c) 2018-2020, The Linux Foundation
Dmitry Shmidtd2986c22017-10-23 14:22:09 -07005 *
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
Hai Shalom021b0b52019-04-10 11:17:58 -070013#ifdef CONFIG_DPP
Dmitry Shmidtd2986c22017-10-23 14:22:09 -070014#include <openssl/x509.h>
15
16#include "utils/list.h"
17#include "common/wpa_common.h"
18#include "crypto/sha256.h"
19
Hai Shalom021b0b52019-04-10 11:17:58 -070020struct crypto_ecdh;
Hai Shalom81f62d82019-07-22 12:10:00 -070021struct hostapd_ip_addr;
Hai Shalom021b0b52019-04-10 11:17:58 -070022struct dpp_global;
Hai Shalom4fbc08f2020-05-18 12:37:00 -070023struct json_token;
Hai Shalom899fcc72020-10-19 14:38:18 -070024struct dpp_reconfig_id;
Hai Shalom4fbc08f2020-05-18 12:37:00 -070025
26#ifdef CONFIG_TESTING_OPTIONS
27#define DPP_VERSION (dpp_version_override)
28extern int dpp_version_override;
29#else /* CONFIG_TESTING_OPTIONS */
30#ifdef CONFIG_DPP2
31#define DPP_VERSION 2
32#else
33#define DPP_VERSION 1
34#endif
35#endif /* CONFIG_TESTING_OPTIONS */
Hai Shalom021b0b52019-04-10 11:17:58 -070036
Dmitry Shmidtd2986c22017-10-23 14:22:09 -070037#define DPP_HDR_LEN (4 + 2) /* OUI, OUI Type, Crypto Suite, DPP frame type */
Hai Shalom60840252021-02-19 19:02:11 -080038#define DPP_TCP_PORT 8908
Dmitry Shmidtd2986c22017-10-23 14:22:09 -070039
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_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,
Hai Shalom021b0b52019-04-10 11:17:58 -070050 DPP_PA_CONFIGURATION_RESULT = 11,
Hai Shalomc3565922019-10-28 11:58:20 -070051 DPP_PA_CONNECTION_STATUS_RESULT = 12,
Hai Shalomfdcde762020-04-02 11:19:20 -070052 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,
Dmitry Shmidtd2986c22017-10-23 14:22:09 -070057};
58
59enum dpp_attribute_id {
60 DPP_ATTR_STATUS = 0x1000,
61 DPP_ATTR_I_BOOTSTRAP_KEY_HASH = 0x1001,
62 DPP_ATTR_R_BOOTSTRAP_KEY_HASH = 0x1002,
63 DPP_ATTR_I_PROTOCOL_KEY = 0x1003,
64 DPP_ATTR_WRAPPED_DATA = 0x1004,
65 DPP_ATTR_I_NONCE = 0x1005,
66 DPP_ATTR_I_CAPABILITIES = 0x1006,
67 DPP_ATTR_R_NONCE = 0x1007,
68 DPP_ATTR_R_CAPABILITIES = 0x1008,
69 DPP_ATTR_R_PROTOCOL_KEY = 0x1009,
70 DPP_ATTR_I_AUTH_TAG = 0x100A,
71 DPP_ATTR_R_AUTH_TAG = 0x100B,
72 DPP_ATTR_CONFIG_OBJ = 0x100C,
73 DPP_ATTR_CONNECTOR = 0x100D,
74 DPP_ATTR_CONFIG_ATTR_OBJ = 0x100E,
75 DPP_ATTR_BOOTSTRAP_KEY = 0x100F,
76 DPP_ATTR_OWN_NET_NK_HASH = 0x1011,
77 DPP_ATTR_FINITE_CYCLIC_GROUP = 0x1012,
78 DPP_ATTR_ENCRYPTED_KEY = 0x1013,
79 DPP_ATTR_ENROLLEE_NONCE = 0x1014,
80 DPP_ATTR_CODE_IDENTIFIER = 0x1015,
81 DPP_ATTR_TRANSACTION_ID = 0x1016,
Roshan Pius3a1667e2018-07-03 15:17:14 -070082 DPP_ATTR_BOOTSTRAP_INFO = 0x1017,
83 DPP_ATTR_CHANNEL = 0x1018,
Hai Shalom021b0b52019-04-10 11:17:58 -070084 DPP_ATTR_PROTOCOL_VERSION = 0x1019,
85 DPP_ATTR_ENVELOPED_DATA = 0x101A,
Hai Shalomc3565922019-10-28 11:58:20 -070086 DPP_ATTR_SEND_CONN_STATUS = 0x101B,
87 DPP_ATTR_CONN_STATUS = 0x101C,
Hai Shalomfdcde762020-04-02 11:19:20 -070088 DPP_ATTR_RECONFIG_FLAGS = 0x101D,
89 DPP_ATTR_C_SIGN_KEY_HASH = 0x101E,
90 DPP_ATTR_CSR_ATTR_REQ = 0x101F,
Hai Shalom899fcc72020-10-19 14:38:18 -070091 DPP_ATTR_A_NONCE = 0x1020,
92 DPP_ATTR_E_PRIME_ID = 0x1021,
93 DPP_ATTR_CONFIGURATOR_NONCE = 0x1022,
Dmitry Shmidtd2986c22017-10-23 14:22:09 -070094};
95
96enum dpp_status_error {
97 DPP_STATUS_OK = 0,
98 DPP_STATUS_NOT_COMPATIBLE = 1,
99 DPP_STATUS_AUTH_FAILURE = 2,
100 DPP_STATUS_UNWRAP_FAILURE = 3,
101 DPP_STATUS_BAD_GROUP = 4,
102 DPP_STATUS_CONFIGURE_FAILURE = 5,
103 DPP_STATUS_RESPONSE_PENDING = 6,
Roshan Pius3a1667e2018-07-03 15:17:14 -0700104 DPP_STATUS_INVALID_CONNECTOR = 7,
105 DPP_STATUS_NO_MATCH = 8,
Hai Shalom021b0b52019-04-10 11:17:58 -0700106 DPP_STATUS_CONFIG_REJECTED = 9,
Hai Shalomc3565922019-10-28 11:58:20 -0700107 DPP_STATUS_NO_AP = 10,
Hai Shalomfdcde762020-04-02 11:19:20 -0700108 DPP_STATUS_CONFIGURE_PENDING = 11,
109 DPP_STATUS_CSR_NEEDED = 12,
110 DPP_STATUS_CSR_BAD = 13,
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700111};
112
Hai Shalom4fbc08f2020-05-18 12:37:00 -0700113/* DPP Reconfig Flags object - connectorKey values */
114enum dpp_connector_key {
115 DPP_CONFIG_REUSEKEY = 0,
116 DPP_CONFIG_REPLACEKEY = 1,
117};
118
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700119#define DPP_CAPAB_ENROLLEE BIT(0)
120#define DPP_CAPAB_CONFIGURATOR BIT(1)
121#define DPP_CAPAB_ROLE_MASK (BIT(0) | BIT(1))
122
123#define DPP_BOOTSTRAP_MAX_FREQ 30
124#define DPP_MAX_NONCE_LEN 32
125#define DPP_MAX_HASH_LEN 64
126#define DPP_MAX_SHARED_SECRET_LEN 66
Hai Shalom899fcc72020-10-19 14:38:18 -0700127#define DPP_CP_LEN 64
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700128
129struct dpp_curve_params {
130 const char *name;
131 size_t hash_len;
132 size_t aes_siv_key_len;
133 size_t nonce_len;
134 size_t prime_len;
135 const char *jwk_crv;
136 u16 ike_group;
137 const char *jws_alg;
138};
139
140enum dpp_bootstrap_type {
141 DPP_BOOTSTRAP_QR_CODE,
142 DPP_BOOTSTRAP_PKEX,
Ahmed ElArabawy0ff61c52019-12-26 12:38:39 -0800143 DPP_BOOTSTRAP_NFC_URI,
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700144};
145
146struct dpp_bootstrap_info {
147 struct dl_list list;
148 unsigned int id;
149 enum dpp_bootstrap_type type;
150 char *uri;
151 u8 mac_addr[ETH_ALEN];
Hai Shalomfdcde762020-04-02 11:19:20 -0700152 char *chan;
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700153 char *info;
Hai Shalomfdcde762020-04-02 11:19:20 -0700154 char *pk;
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700155 unsigned int freq[DPP_BOOTSTRAP_MAX_FREQ];
156 unsigned int num_freq;
Hai Shalom899fcc72020-10-19 14:38:18 -0700157 bool channels_listed;
Hai Shalom4fbc08f2020-05-18 12:37:00 -0700158 u8 version;
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700159 int own;
160 EVP_PKEY *pubkey;
161 u8 pubkey_hash[SHA256_MAC_LEN];
Hai Shalomfdcde762020-04-02 11:19:20 -0700162 u8 pubkey_hash_chirp[SHA256_MAC_LEN];
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700163 const struct dpp_curve_params *curve;
Roshan Pius3a1667e2018-07-03 15:17:14 -0700164 unsigned int pkex_t; /* number of failures before dpp_pkex
165 * instantiation */
Hai Shalomb755a2a2020-04-23 21:49:02 -0700166 int nfc_negotiated; /* whether this has been used in NFC negotiated
167 * connection handover */
Hai Shalomfdcde762020-04-02 11:19:20 -0700168 char *configurator_params;
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700169};
170
Roshan Pius3a1667e2018-07-03 15:17:14 -0700171#define PKEX_COUNTER_T_LIMIT 5
172
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700173struct dpp_pkex {
Roshan Pius3a1667e2018-07-03 15:17:14 -0700174 void *msg_ctx;
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700175 unsigned int initiator:1;
176 unsigned int exchange_done:1;
Roshan Pius3a1667e2018-07-03 15:17:14 -0700177 unsigned int failed:1;
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700178 struct dpp_bootstrap_info *own_bi;
179 u8 own_mac[ETH_ALEN];
180 u8 peer_mac[ETH_ALEN];
181 char *identifier;
182 char *code;
183 EVP_PKEY *x;
184 EVP_PKEY *y;
185 u8 Mx[DPP_MAX_SHARED_SECRET_LEN];
186 u8 Nx[DPP_MAX_SHARED_SECRET_LEN];
187 u8 z[DPP_MAX_HASH_LEN];
188 EVP_PKEY *peer_bootstrap_key;
189 struct wpabuf *exchange_req;
190 struct wpabuf *exchange_resp;
Roshan Pius3a1667e2018-07-03 15:17:14 -0700191 unsigned int t; /* number of failures on code use */
192 unsigned int exch_req_wait_time;
193 unsigned int exch_req_tries;
194 unsigned int freq;
195};
196
197enum dpp_akm {
198 DPP_AKM_UNKNOWN,
199 DPP_AKM_DPP,
200 DPP_AKM_PSK,
201 DPP_AKM_SAE,
Hai Shalom021b0b52019-04-10 11:17:58 -0700202 DPP_AKM_PSK_SAE,
203 DPP_AKM_SAE_DPP,
204 DPP_AKM_PSK_SAE_DPP,
Hai Shalom899fcc72020-10-19 14:38:18 -0700205 DPP_AKM_DOT1X,
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700206};
207
Hai Shalomc3565922019-10-28 11:58:20 -0700208enum dpp_netrole {
209 DPP_NETROLE_STA,
210 DPP_NETROLE_AP,
Ahmed ElArabawy0ff61c52019-12-26 12:38:39 -0800211 DPP_NETROLE_CONFIGURATOR,
Hai Shalomc3565922019-10-28 11:58:20 -0700212};
213
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700214struct dpp_configuration {
215 u8 ssid[32];
216 size_t ssid_len;
Ahmed ElArabawy0ff61c52019-12-26 12:38:39 -0800217 int ssid_charset;
Roshan Pius3a1667e2018-07-03 15:17:14 -0700218 enum dpp_akm akm;
Hai Shalomc3565922019-10-28 11:58:20 -0700219 enum dpp_netrole netrole;
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700220
221 /* For DPP configuration (connector) */
222 os_time_t netaccesskey_expiry;
223
224 /* TODO: groups */
Hai Shalomce48b4a2018-09-05 11:41:35 -0700225 char *group_id;
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700226
227 /* For legacy configuration */
228 char *passphrase;
229 u8 psk[32];
Hai Shalom021b0b52019-04-10 11:17:58 -0700230 int psk_set;
Hai Shalom899fcc72020-10-19 14:38:18 -0700231
232 char *csrattrs;
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700233};
234
Hai Shalomfdcde762020-04-02 11:19:20 -0700235struct dpp_asymmetric_key {
236 struct dpp_asymmetric_key *next;
237 EVP_PKEY *csign;
Hai Shalom899fcc72020-10-19 14:38:18 -0700238 EVP_PKEY *pp_key;
Hai Shalomfdcde762020-04-02 11:19:20 -0700239 char *config_template;
240 char *connector_template;
241};
242
Hai Shalomc3565922019-10-28 11:58:20 -0700243#define DPP_MAX_CONF_OBJ 10
Hai Shalom06768112019-12-04 15:49:43 -0800244#define DPP_MAX_CHANNELS 32
Hai Shalomc3565922019-10-28 11:58:20 -0700245
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700246struct dpp_authentication {
Hai Shalomfdcde762020-04-02 11:19:20 -0700247 struct dpp_global *global;
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700248 void *msg_ctx;
Hai Shalom021b0b52019-04-10 11:17:58 -0700249 u8 peer_version;
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700250 const struct dpp_curve_params *curve;
251 struct dpp_bootstrap_info *peer_bi;
252 struct dpp_bootstrap_info *own_bi;
Roshan Pius3a1667e2018-07-03 15:17:14 -0700253 struct dpp_bootstrap_info *tmp_own_bi;
Hai Shalom899fcc72020-10-19 14:38:18 -0700254 struct dpp_bootstrap_info *tmp_peer_bi;
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700255 u8 waiting_pubkey_hash[SHA256_MAC_LEN];
256 int response_pending;
Hai Shalom4fbc08f2020-05-18 12:37:00 -0700257 int reconfig;
258 enum dpp_connector_key reconfig_connector_key;
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700259 enum dpp_status_error auth_resp_status;
Hai Shalom021b0b52019-04-10 11:17:58 -0700260 enum dpp_status_error conf_resp_status;
Hai Shalom899fcc72020-10-19 14:38:18 -0700261 enum dpp_status_error force_conf_resp_status;
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700262 u8 peer_mac_addr[ETH_ALEN];
263 u8 i_nonce[DPP_MAX_NONCE_LEN];
264 u8 r_nonce[DPP_MAX_NONCE_LEN];
265 u8 e_nonce[DPP_MAX_NONCE_LEN];
Hai Shalom899fcc72020-10-19 14:38:18 -0700266 u8 c_nonce[DPP_MAX_NONCE_LEN];
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700267 u8 i_capab;
268 u8 r_capab;
Hai Shalom899fcc72020-10-19 14:38:18 -0700269 enum dpp_netrole e_netrole;
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700270 EVP_PKEY *own_protocol_key;
271 EVP_PKEY *peer_protocol_key;
Hai Shalom4fbc08f2020-05-18 12:37:00 -0700272 EVP_PKEY *reconfig_old_protocol_key;
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700273 struct wpabuf *req_msg;
274 struct wpabuf *resp_msg;
Hai Shalom4fbc08f2020-05-18 12:37:00 -0700275 struct wpabuf *reconfig_req_msg;
276 struct wpabuf *reconfig_resp_msg;
Roshan Pius3a1667e2018-07-03 15:17:14 -0700277 /* Intersection of possible frequencies for initiating DPP
278 * Authentication exchange */
279 unsigned int freq[DPP_BOOTSTRAP_MAX_FREQ];
280 unsigned int num_freq, freq_idx;
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700281 unsigned int curr_freq;
Roshan Pius3a1667e2018-07-03 15:17:14 -0700282 unsigned int neg_freq;
283 unsigned int num_freq_iters;
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700284 size_t secret_len;
285 u8 Mx[DPP_MAX_SHARED_SECRET_LEN];
Roshan Pius3a1667e2018-07-03 15:17:14 -0700286 size_t Mx_len;
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700287 u8 Nx[DPP_MAX_SHARED_SECRET_LEN];
Roshan Pius3a1667e2018-07-03 15:17:14 -0700288 size_t Nx_len;
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700289 u8 Lx[DPP_MAX_SHARED_SECRET_LEN];
Roshan Pius3a1667e2018-07-03 15:17:14 -0700290 size_t Lx_len;
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700291 u8 k1[DPP_MAX_HASH_LEN];
292 u8 k2[DPP_MAX_HASH_LEN];
293 u8 ke[DPP_MAX_HASH_LEN];
Hai Shalom4fbc08f2020-05-18 12:37:00 -0700294 u8 bk[DPP_MAX_HASH_LEN];
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700295 int initiator;
Roshan Pius3a1667e2018-07-03 15:17:14 -0700296 int waiting_auth_resp;
297 int waiting_auth_conf;
298 int auth_req_ack;
299 unsigned int auth_resp_tries;
300 u8 allowed_roles;
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700301 int configurator;
302 int remove_on_tx_status;
Hai Shalom021b0b52019-04-10 11:17:58 -0700303 int connect_on_tx_status;
304 int waiting_conf_result;
Hai Shalomc3565922019-10-28 11:58:20 -0700305 int waiting_conn_status_result;
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700306 int auth_success;
Hai Shalom4fbc08f2020-05-18 12:37:00 -0700307 bool reconfig_success;
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700308 struct wpabuf *conf_req;
Roshan Pius3a1667e2018-07-03 15:17:14 -0700309 const struct wpabuf *conf_resp; /* owned by GAS server */
Hai Shalom899fcc72020-10-19 14:38:18 -0700310 struct wpabuf *conf_resp_tcp;
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700311 struct dpp_configuration *conf_ap;
Hai Shalomc3565922019-10-28 11:58:20 -0700312 struct dpp_configuration *conf2_ap;
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700313 struct dpp_configuration *conf_sta;
Hai Shalomc3565922019-10-28 11:58:20 -0700314 struct dpp_configuration *conf2_sta;
Hai Shalomfdcde762020-04-02 11:19:20 -0700315 int provision_configurator;
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700316 struct dpp_configurator *conf;
Hai Shalomc3565922019-10-28 11:58:20 -0700317 struct dpp_config_obj {
318 char *connector; /* received signedConnector */
319 u8 ssid[SSID_MAX_LEN];
320 u8 ssid_len;
Ahmed ElArabawy0ff61c52019-12-26 12:38:39 -0800321 int ssid_charset;
Hai Shalomc3565922019-10-28 11:58:20 -0700322 char passphrase[64];
323 u8 psk[PMK_LEN];
324 int psk_set;
325 enum dpp_akm akm;
326 struct wpabuf *c_sign_key;
Hai Shalom899fcc72020-10-19 14:38:18 -0700327 struct wpabuf *certbag;
328 struct wpabuf *certs;
329 struct wpabuf *cacert;
330 char *server_name;
331 struct wpabuf *pp_key;
Hai Shalomc3565922019-10-28 11:58:20 -0700332 } conf_obj[DPP_MAX_CONF_OBJ];
333 unsigned int num_conf_obj;
Hai Shalomfdcde762020-04-02 11:19:20 -0700334 struct dpp_asymmetric_key *conf_key_pkg;
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700335 struct wpabuf *net_access_key;
336 os_time_t net_access_key_expiry;
Hai Shalomc3565922019-10-28 11:58:20 -0700337 int send_conn_status;
338 int conn_status_requested;
339 int akm_use_selector;
Hai Shalomfdcde762020-04-02 11:19:20 -0700340 int configurator_set;
Hai Shalom4fbc08f2020-05-18 12:37:00 -0700341 u8 transaction_id;
Hai Shalom899fcc72020-10-19 14:38:18 -0700342 u8 *csrattrs;
343 size_t csrattrs_len;
344 bool waiting_csr;
345 struct wpabuf *csr;
346 struct wpabuf *priv_key; /* DER-encoded private key used for csr */
347 bool waiting_cert;
348 char *trusted_eap_server_name;
349 struct wpabuf *cacert;
350 struct wpabuf *certbag;
351 void *cert_resp_ctx;
Hai Shalom60840252021-02-19 19:02:11 -0800352 void *gas_server_ctx;
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700353#ifdef CONFIG_TESTING_OPTIONS
354 char *config_obj_override;
355 char *discovery_override;
356 char *groups_override;
357 unsigned int ignore_netaccesskey_mismatch:1;
358#endif /* CONFIG_TESTING_OPTIONS */
Hai Shalom06768112019-12-04 15:49:43 -0800359 unsigned short band_list[DPP_MAX_CHANNELS];
360 int band_list_size;
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700361};
362
363struct dpp_configurator {
364 struct dl_list list;
365 unsigned int id;
366 int own;
367 EVP_PKEY *csign;
Hai Shalom4fbc08f2020-05-18 12:37:00 -0700368 u8 kid_hash[SHA256_MAC_LEN];
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700369 char *kid;
370 const struct dpp_curve_params *curve;
Hai Shalom4fbc08f2020-05-18 12:37:00 -0700371 char *connector; /* own Connector for reconfiguration */
372 EVP_PKEY *connector_key;
Hai Shalom899fcc72020-10-19 14:38:18 -0700373 EVP_PKEY *pp_key;
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700374};
375
376struct dpp_introduction {
377 u8 pmkid[PMKID_LEN];
378 u8 pmk[PMK_LEN_MAX];
379 size_t pmk_len;
380};
381
Hai Shalom81f62d82019-07-22 12:10:00 -0700382struct dpp_relay_config {
383 const struct hostapd_ip_addr *ipaddr;
384 const u8 *pkhash;
385
Hai Shalom899fcc72020-10-19 14:38:18 -0700386 void *msg_ctx;
Hai Shalom81f62d82019-07-22 12:10:00 -0700387 void *cb_ctx;
388 void (*tx)(void *ctx, const u8 *addr, unsigned int freq, const u8 *msg,
389 size_t len);
390 void (*gas_resp_tx)(void *ctx, const u8 *addr, u8 dialog_token, int prot,
391 struct wpabuf *buf);
392};
393
394struct dpp_controller_config {
395 const char *configurator_params;
396 int tcp_port;
Hai Shalom4fbc08f2020-05-18 12:37:00 -0700397 u8 allowed_roles;
Hai Shalom899fcc72020-10-19 14:38:18 -0700398 int qr_mutual;
399 enum dpp_netrole netrole;
400 void *msg_ctx;
401 void *cb_ctx;
402 int (*process_conf_obj)(void *ctx, struct dpp_authentication *auth);
Hai Shalom81f62d82019-07-22 12:10:00 -0700403};
404
Roshan Pius3a1667e2018-07-03 15:17:14 -0700405#ifdef CONFIG_TESTING_OPTIONS
406enum dpp_test_behavior {
407 DPP_TEST_DISABLED = 0,
408 DPP_TEST_AFTER_WRAPPED_DATA_AUTH_REQ = 1,
409 DPP_TEST_AFTER_WRAPPED_DATA_AUTH_RESP = 2,
410 DPP_TEST_AFTER_WRAPPED_DATA_AUTH_CONF = 3,
411 DPP_TEST_AFTER_WRAPPED_DATA_PKEX_CR_REQ = 4,
412 DPP_TEST_AFTER_WRAPPED_DATA_PKEX_CR_RESP = 5,
413 DPP_TEST_AFTER_WRAPPED_DATA_CONF_REQ = 6,
414 DPP_TEST_AFTER_WRAPPED_DATA_CONF_RESP = 7,
415 DPP_TEST_ZERO_I_CAPAB = 8,
416 DPP_TEST_ZERO_R_CAPAB = 9,
417 DPP_TEST_NO_R_BOOTSTRAP_KEY_HASH_AUTH_REQ = 10,
418 DPP_TEST_NO_I_BOOTSTRAP_KEY_HASH_AUTH_REQ = 11,
419 DPP_TEST_NO_I_PROTO_KEY_AUTH_REQ = 12,
420 DPP_TEST_NO_I_NONCE_AUTH_REQ = 13,
421 DPP_TEST_NO_I_CAPAB_AUTH_REQ = 14,
422 DPP_TEST_NO_WRAPPED_DATA_AUTH_REQ = 15,
423 DPP_TEST_NO_STATUS_AUTH_RESP = 16,
424 DPP_TEST_NO_R_BOOTSTRAP_KEY_HASH_AUTH_RESP = 17,
425 DPP_TEST_NO_I_BOOTSTRAP_KEY_HASH_AUTH_RESP = 18,
426 DPP_TEST_NO_R_PROTO_KEY_AUTH_RESP = 19,
427 DPP_TEST_NO_R_NONCE_AUTH_RESP = 20,
428 DPP_TEST_NO_I_NONCE_AUTH_RESP = 21,
429 DPP_TEST_NO_R_CAPAB_AUTH_RESP = 22,
430 DPP_TEST_NO_R_AUTH_AUTH_RESP = 23,
431 DPP_TEST_NO_WRAPPED_DATA_AUTH_RESP = 24,
432 DPP_TEST_NO_STATUS_AUTH_CONF = 25,
433 DPP_TEST_NO_R_BOOTSTRAP_KEY_HASH_AUTH_CONF = 26,
434 DPP_TEST_NO_I_BOOTSTRAP_KEY_HASH_AUTH_CONF = 27,
435 DPP_TEST_NO_I_AUTH_AUTH_CONF = 28,
436 DPP_TEST_NO_WRAPPED_DATA_AUTH_CONF = 29,
437 DPP_TEST_I_NONCE_MISMATCH_AUTH_RESP = 30,
438 DPP_TEST_INCOMPATIBLE_R_CAPAB_AUTH_RESP = 31,
439 DPP_TEST_R_AUTH_MISMATCH_AUTH_RESP = 32,
440 DPP_TEST_I_AUTH_MISMATCH_AUTH_CONF = 33,
441 DPP_TEST_NO_FINITE_CYCLIC_GROUP_PKEX_EXCHANGE_REQ = 34,
442 DPP_TEST_NO_ENCRYPTED_KEY_PKEX_EXCHANGE_REQ = 35,
443 DPP_TEST_NO_STATUS_PKEX_EXCHANGE_RESP = 36,
444 DPP_TEST_NO_ENCRYPTED_KEY_PKEX_EXCHANGE_RESP = 37,
445 DPP_TEST_NO_BOOTSTRAP_KEY_PKEX_CR_REQ = 38,
446 DPP_TEST_NO_I_AUTH_TAG_PKEX_CR_REQ = 39,
447 DPP_TEST_NO_WRAPPED_DATA_PKEX_CR_REQ = 40,
448 DPP_TEST_NO_BOOTSTRAP_KEY_PKEX_CR_RESP = 41,
449 DPP_TEST_NO_R_AUTH_TAG_PKEX_CR_RESP = 42,
450 DPP_TEST_NO_WRAPPED_DATA_PKEX_CR_RESP = 43,
451 DPP_TEST_INVALID_ENCRYPTED_KEY_PKEX_EXCHANGE_REQ = 44,
452 DPP_TEST_INVALID_ENCRYPTED_KEY_PKEX_EXCHANGE_RESP = 45,
453 DPP_TEST_INVALID_STATUS_PKEX_EXCHANGE_RESP = 46,
454 DPP_TEST_INVALID_BOOTSTRAP_KEY_PKEX_CR_REQ = 47,
455 DPP_TEST_INVALID_BOOTSTRAP_KEY_PKEX_CR_RESP = 48,
456 DPP_TEST_I_AUTH_TAG_MISMATCH_PKEX_CR_REQ = 49,
457 DPP_TEST_R_AUTH_TAG_MISMATCH_PKEX_CR_RESP = 50,
458 DPP_TEST_NO_E_NONCE_CONF_REQ = 51,
459 DPP_TEST_NO_CONFIG_ATTR_OBJ_CONF_REQ = 52,
460 DPP_TEST_NO_WRAPPED_DATA_CONF_REQ = 53,
461 DPP_TEST_NO_E_NONCE_CONF_RESP = 54,
462 DPP_TEST_NO_CONFIG_OBJ_CONF_RESP = 55,
463 DPP_TEST_NO_STATUS_CONF_RESP = 56,
464 DPP_TEST_NO_WRAPPED_DATA_CONF_RESP = 57,
465 DPP_TEST_INVALID_STATUS_CONF_RESP = 58,
466 DPP_TEST_E_NONCE_MISMATCH_CONF_RESP = 59,
467 DPP_TEST_NO_TRANSACTION_ID_PEER_DISC_REQ = 60,
468 DPP_TEST_NO_CONNECTOR_PEER_DISC_REQ = 61,
469 DPP_TEST_NO_TRANSACTION_ID_PEER_DISC_RESP = 62,
470 DPP_TEST_NO_STATUS_PEER_DISC_RESP = 63,
471 DPP_TEST_NO_CONNECTOR_PEER_DISC_RESP = 64,
472 DPP_TEST_AUTH_RESP_IN_PLACE_OF_CONF = 65,
473 DPP_TEST_INVALID_I_PROTO_KEY_AUTH_REQ = 66,
474 DPP_TEST_INVALID_R_PROTO_KEY_AUTH_RESP = 67,
475 DPP_TEST_INVALID_R_BOOTSTRAP_KEY_HASH_AUTH_REQ = 68,
476 DPP_TEST_INVALID_I_BOOTSTRAP_KEY_HASH_AUTH_REQ = 69,
477 DPP_TEST_INVALID_R_BOOTSTRAP_KEY_HASH_AUTH_RESP = 70,
478 DPP_TEST_INVALID_I_BOOTSTRAP_KEY_HASH_AUTH_RESP = 71,
479 DPP_TEST_INVALID_R_BOOTSTRAP_KEY_HASH_AUTH_CONF = 72,
480 DPP_TEST_INVALID_I_BOOTSTRAP_KEY_HASH_AUTH_CONF = 73,
481 DPP_TEST_INVALID_STATUS_AUTH_RESP = 74,
482 DPP_TEST_INVALID_STATUS_AUTH_CONF = 75,
483 DPP_TEST_INVALID_CONFIG_ATTR_OBJ_CONF_REQ = 76,
484 DPP_TEST_INVALID_TRANSACTION_ID_PEER_DISC_RESP = 77,
485 DPP_TEST_INVALID_STATUS_PEER_DISC_RESP = 78,
486 DPP_TEST_INVALID_CONNECTOR_PEER_DISC_RESP = 79,
487 DPP_TEST_INVALID_CONNECTOR_PEER_DISC_REQ = 80,
488 DPP_TEST_INVALID_I_NONCE_AUTH_REQ = 81,
489 DPP_TEST_INVALID_TRANSACTION_ID_PEER_DISC_REQ = 82,
490 DPP_TEST_INVALID_E_NONCE_CONF_REQ = 83,
491 DPP_TEST_STOP_AT_PKEX_EXCHANGE_RESP = 84,
492 DPP_TEST_STOP_AT_PKEX_CR_REQ = 85,
493 DPP_TEST_STOP_AT_PKEX_CR_RESP = 86,
494 DPP_TEST_STOP_AT_AUTH_REQ = 87,
495 DPP_TEST_STOP_AT_AUTH_RESP = 88,
496 DPP_TEST_STOP_AT_AUTH_CONF = 89,
497 DPP_TEST_STOP_AT_CONF_REQ = 90,
Hai Shalom021b0b52019-04-10 11:17:58 -0700498 DPP_TEST_REJECT_CONFIG = 91,
Roshan Pius3a1667e2018-07-03 15:17:14 -0700499};
500
501extern enum dpp_test_behavior dpp_test;
502extern u8 dpp_pkex_own_mac_override[ETH_ALEN];
503extern u8 dpp_pkex_peer_mac_override[ETH_ALEN];
504extern u8 dpp_pkex_ephemeral_key_override[600];
505extern size_t dpp_pkex_ephemeral_key_override_len;
506extern u8 dpp_protocol_key_override[600];
507extern size_t dpp_protocol_key_override_len;
508extern u8 dpp_nonce_override[DPP_MAX_NONCE_LEN];
509extern size_t dpp_nonce_override_len;
510#endif /* CONFIG_TESTING_OPTIONS */
511
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700512void dpp_bootstrap_info_free(struct dpp_bootstrap_info *info);
513const char * dpp_bootstrap_type_txt(enum dpp_bootstrap_type type);
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700514int dpp_parse_uri_chan_list(struct dpp_bootstrap_info *bi,
515 const char *chan_list);
516int dpp_parse_uri_mac(struct dpp_bootstrap_info *bi, const char *mac);
517int dpp_parse_uri_info(struct dpp_bootstrap_info *bi, const char *info);
Hai Shalomfdcde762020-04-02 11:19:20 -0700518int dpp_nfc_update_bi(struct dpp_bootstrap_info *own_bi,
519 struct dpp_bootstrap_info *peer_bi);
520struct dpp_authentication *
521dpp_alloc_auth(struct dpp_global *dpp, void *msg_ctx);
Roshan Pius3a1667e2018-07-03 15:17:14 -0700522struct hostapd_hw_modes;
Hai Shalomfdcde762020-04-02 11:19:20 -0700523struct dpp_authentication * dpp_auth_init(struct dpp_global *dpp, void *msg_ctx,
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700524 struct dpp_bootstrap_info *peer_bi,
525 struct dpp_bootstrap_info *own_bi,
Roshan Pius3a1667e2018-07-03 15:17:14 -0700526 u8 dpp_allowed_roles,
527 unsigned int neg_freq,
528 struct hostapd_hw_modes *own_modes,
529 u16 num_modes);
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700530struct dpp_authentication *
Hai Shalomfdcde762020-04-02 11:19:20 -0700531dpp_auth_req_rx(struct dpp_global *dpp, void *msg_ctx, u8 dpp_allowed_roles,
532 int qr_mutual, struct dpp_bootstrap_info *peer_bi,
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700533 struct dpp_bootstrap_info *own_bi,
534 unsigned int freq, const u8 *hdr, const u8 *attr_start,
Roshan Pius3a1667e2018-07-03 15:17:14 -0700535 size_t attr_len);
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700536struct wpabuf *
537dpp_auth_resp_rx(struct dpp_authentication *auth, const u8 *hdr,
538 const u8 *attr_start, size_t attr_len);
539struct wpabuf * dpp_build_conf_req(struct dpp_authentication *auth,
540 const char *json);
Hai Shalomc3565922019-10-28 11:58:20 -0700541struct wpabuf * dpp_build_conf_req_helper(struct dpp_authentication *auth,
Ahmed ElArabawy0ff61c52019-12-26 12:38:39 -0800542 const char *name,
543 enum dpp_netrole netrole,
Hai Shalomc3565922019-10-28 11:58:20 -0700544 const char *mud_url, int *opclasses);
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700545int dpp_auth_conf_rx(struct dpp_authentication *auth, const u8 *hdr,
546 const u8 *attr_start, size_t attr_len);
547int dpp_notify_new_qr_code(struct dpp_authentication *auth,
548 struct dpp_bootstrap_info *peer_bi);
Hai Shalom021b0b52019-04-10 11:17:58 -0700549struct dpp_configuration * dpp_configuration_alloc(const char *type);
550int dpp_akm_psk(enum dpp_akm akm);
551int dpp_akm_sae(enum dpp_akm akm);
552int dpp_akm_legacy(enum dpp_akm akm);
553int dpp_akm_dpp(enum dpp_akm akm);
554int dpp_akm_ver2(enum dpp_akm akm);
555int dpp_configuration_valid(const struct dpp_configuration *conf);
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700556void dpp_configuration_free(struct dpp_configuration *conf);
Hai Shalomfdcde762020-04-02 11:19:20 -0700557int dpp_set_configurator(struct dpp_authentication *auth, const char *cmd);
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700558void dpp_auth_deinit(struct dpp_authentication *auth);
559struct wpabuf *
Hai Shalom899fcc72020-10-19 14:38:18 -0700560dpp_build_conf_resp(struct dpp_authentication *auth, const u8 *e_nonce,
561 u16 e_nonce_len, enum dpp_netrole netrole,
562 bool cert_req);
563struct wpabuf *
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700564dpp_conf_req_rx(struct dpp_authentication *auth, const u8 *attr_start,
565 size_t attr_len);
566int dpp_conf_resp_rx(struct dpp_authentication *auth,
567 const struct wpabuf *resp);
Hai Shalom021b0b52019-04-10 11:17:58 -0700568enum dpp_status_error dpp_conf_result_rx(struct dpp_authentication *auth,
569 const u8 *hdr,
570 const u8 *attr_start, size_t attr_len);
571struct wpabuf * dpp_build_conf_result(struct dpp_authentication *auth,
572 enum dpp_status_error status);
Hai Shalomc3565922019-10-28 11:58:20 -0700573enum dpp_status_error dpp_conn_status_result_rx(struct dpp_authentication *auth,
574 const u8 *hdr,
575 const u8 *attr_start,
576 size_t attr_len,
577 u8 *ssid, size_t *ssid_len,
578 char **channel_list);
579struct wpabuf * dpp_build_conn_status_result(struct dpp_authentication *auth,
580 enum dpp_status_error result,
581 const u8 *ssid, size_t ssid_len,
582 const char *channel_list);
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700583struct wpabuf * dpp_alloc_msg(enum dpp_public_action_frame_type type,
584 size_t len);
585const u8 * dpp_get_attr(const u8 *buf, size_t len, u16 req_id, u16 *ret_len);
586int dpp_check_attrs(const u8 *buf, size_t len);
587int dpp_key_expired(const char *timestamp, os_time_t *expiry);
Roshan Pius3a1667e2018-07-03 15:17:14 -0700588const char * dpp_akm_str(enum dpp_akm akm);
Hai Shalomc3565922019-10-28 11:58:20 -0700589const char * dpp_akm_selector_str(enum dpp_akm akm);
Roshan Pius3a1667e2018-07-03 15:17:14 -0700590int dpp_configurator_get_key(const struct dpp_configurator *conf, char *buf,
591 size_t buflen);
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700592void dpp_configurator_free(struct dpp_configurator *conf);
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700593int dpp_configurator_own_config(struct dpp_authentication *auth,
Roshan Pius3a1667e2018-07-03 15:17:14 -0700594 const char *curve, int ap);
595enum dpp_status_error
596dpp_peer_intro(struct dpp_introduction *intro, const char *own_connector,
597 const u8 *net_access_key, size_t net_access_key_len,
598 const u8 *csign_key, size_t csign_key_len,
599 const u8 *peer_connector, size_t peer_connector_len,
600 os_time_t *expiry);
601struct dpp_pkex * dpp_pkex_init(void *msg_ctx, struct dpp_bootstrap_info *bi,
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700602 const u8 *own_mac,
603 const char *identifier,
604 const char *code);
Roshan Pius3a1667e2018-07-03 15:17:14 -0700605struct dpp_pkex * dpp_pkex_rx_exchange_req(void *msg_ctx,
606 struct dpp_bootstrap_info *bi,
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700607 const u8 *own_mac,
608 const u8 *peer_mac,
609 const char *identifier,
610 const char *code,
611 const u8 *buf, size_t len);
612struct wpabuf * dpp_pkex_rx_exchange_resp(struct dpp_pkex *pkex,
Roshan Pius3a1667e2018-07-03 15:17:14 -0700613 const u8 *peer_mac,
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700614 const u8 *buf, size_t len);
615struct wpabuf * dpp_pkex_rx_commit_reveal_req(struct dpp_pkex *pkex,
616 const u8 *hdr,
617 const u8 *buf, size_t len);
618int dpp_pkex_rx_commit_reveal_resp(struct dpp_pkex *pkex, const u8 *hdr,
619 const u8 *buf, size_t len);
620void dpp_pkex_free(struct dpp_pkex *pkex);
621
Roshan Pius3a1667e2018-07-03 15:17:14 -0700622char * dpp_corrupt_connector_signature(const char *connector);
623
Hai Shalom021b0b52019-04-10 11:17:58 -0700624
625struct dpp_pfs {
626 struct crypto_ecdh *ecdh;
627 const struct dpp_curve_params *curve;
628 struct wpabuf *ie;
629 struct wpabuf *secret;
630};
631
632struct dpp_pfs * dpp_pfs_init(const u8 *net_access_key,
633 size_t net_access_key_len);
634int dpp_pfs_process(struct dpp_pfs *pfs, const u8 *peer_ie, size_t peer_ie_len);
635void dpp_pfs_free(struct dpp_pfs *pfs);
636
Hai Shalom899fcc72020-10-19 14:38:18 -0700637struct wpabuf * dpp_build_csr(struct dpp_authentication *auth,
638 const char *name);
639struct wpabuf * dpp_pkcs7_certs(const struct wpabuf *pkcs7);
640int dpp_validate_csr(struct dpp_authentication *auth, const struct wpabuf *csr);
641
Hai Shalom021b0b52019-04-10 11:17:58 -0700642struct dpp_bootstrap_info * dpp_add_qr_code(struct dpp_global *dpp,
643 const char *uri);
Ahmed ElArabawy0ff61c52019-12-26 12:38:39 -0800644struct dpp_bootstrap_info * dpp_add_nfc_uri(struct dpp_global *dpp,
645 const char *uri);
Hai Shalom021b0b52019-04-10 11:17:58 -0700646int dpp_bootstrap_gen(struct dpp_global *dpp, const char *cmd);
647struct dpp_bootstrap_info *
648dpp_bootstrap_get_id(struct dpp_global *dpp, unsigned int id);
649int dpp_bootstrap_remove(struct dpp_global *dpp, const char *id);
650struct dpp_bootstrap_info *
651dpp_pkex_finish(struct dpp_global *dpp, struct dpp_pkex *pkex, const u8 *peer,
652 unsigned int freq);
653const char * dpp_bootstrap_get_uri(struct dpp_global *dpp, unsigned int id);
654int dpp_bootstrap_info(struct dpp_global *dpp, int id,
655 char *reply, int reply_size);
Hai Shalomfdcde762020-04-02 11:19:20 -0700656int dpp_bootstrap_set(struct dpp_global *dpp, int id, const char *params);
Hai Shalom021b0b52019-04-10 11:17:58 -0700657void dpp_bootstrap_find_pair(struct dpp_global *dpp, const u8 *i_bootstrap,
658 const u8 *r_bootstrap,
659 struct dpp_bootstrap_info **own_bi,
660 struct dpp_bootstrap_info **peer_bi);
Hai Shalomfdcde762020-04-02 11:19:20 -0700661struct dpp_bootstrap_info * dpp_bootstrap_find_chirp(struct dpp_global *dpp,
662 const u8 *hash);
Hai Shalom021b0b52019-04-10 11:17:58 -0700663int dpp_configurator_add(struct dpp_global *dpp, const char *cmd);
664int dpp_configurator_remove(struct dpp_global *dpp, const char *id);
665int dpp_configurator_get_key_id(struct dpp_global *dpp, unsigned int id,
666 char *buf, size_t buflen);
Hai Shalomfdcde762020-04-02 11:19:20 -0700667int dpp_configurator_from_backup(struct dpp_global *dpp,
668 struct dpp_asymmetric_key *key);
Hai Shalom4fbc08f2020-05-18 12:37:00 -0700669struct dpp_configurator * dpp_configurator_find_kid(struct dpp_global *dpp,
670 const u8 *kid);
Hai Shalom81f62d82019-07-22 12:10:00 -0700671int dpp_relay_add_controller(struct dpp_global *dpp,
672 struct dpp_relay_config *config);
673int dpp_relay_rx_action(struct dpp_global *dpp, const u8 *src, const u8 *hdr,
674 const u8 *buf, size_t len, unsigned int freq,
675 const u8 *i_bootstrap, const u8 *r_bootstrap);
676int dpp_relay_rx_gas_req(struct dpp_global *dpp, const u8 *src, const u8 *data,
677 size_t data_len);
678int dpp_controller_start(struct dpp_global *dpp,
679 struct dpp_controller_config *config);
680void dpp_controller_stop(struct dpp_global *dpp);
Hai Shalom899fcc72020-10-19 14:38:18 -0700681struct dpp_authentication * dpp_controller_get_auth(struct dpp_global *dpp,
682 unsigned int id);
683void dpp_controller_new_qr_code(struct dpp_global *dpp,
684 struct dpp_bootstrap_info *bi);
Hai Shalom81f62d82019-07-22 12:10:00 -0700685int dpp_tcp_init(struct dpp_global *dpp, struct dpp_authentication *auth,
Hai Shalom899fcc72020-10-19 14:38:18 -0700686 const struct hostapd_ip_addr *addr, int port,
687 const char *name, enum dpp_netrole netrole, void *msg_ctx,
688 void *cb_ctx,
689 int (*process_conf_obj)(void *ctx,
690 struct dpp_authentication *auth));
691
Hai Shalomfdcde762020-04-02 11:19:20 -0700692struct wpabuf * dpp_build_presence_announcement(struct dpp_bootstrap_info *bi);
Hai Shalom899fcc72020-10-19 14:38:18 -0700693void dpp_notify_chirp_received(void *msg_ctx, int id, const u8 *src,
694 unsigned int freq, const u8 *hash);
Hai Shalom81f62d82019-07-22 12:10:00 -0700695
696struct dpp_global_config {
Hai Shalom81f62d82019-07-22 12:10:00 -0700697 void *cb_ctx;
Hai Shalomfdcde762020-04-02 11:19:20 -0700698 void (*remove_bi)(void *ctx, struct dpp_bootstrap_info *bi);
Hai Shalom81f62d82019-07-22 12:10:00 -0700699};
700
701struct dpp_global * dpp_global_init(struct dpp_global_config *config);
Hai Shalom021b0b52019-04-10 11:17:58 -0700702void dpp_global_clear(struct dpp_global *dpp);
703void dpp_global_deinit(struct dpp_global *dpp);
704
Hai Shalom4fbc08f2020-05-18 12:37:00 -0700705/* dpp_reconfig.c */
706
707struct wpabuf * dpp_build_reconfig_announcement(const u8 *csign_key,
Hai Shalom899fcc72020-10-19 14:38:18 -0700708 size_t csign_key_len,
709 const u8 *net_access_key,
710 size_t net_access_key_len,
711 struct dpp_reconfig_id *id);
Hai Shalom4fbc08f2020-05-18 12:37:00 -0700712struct dpp_authentication *
713dpp_reconfig_init(struct dpp_global *dpp, void *msg_ctx,
Hai Shalom899fcc72020-10-19 14:38:18 -0700714 struct dpp_configurator *conf, unsigned int freq, u16 group,
715 const u8 *a_nonce_attr, size_t a_nonce_len,
716 const u8 *e_id_attr, size_t e_id_len);
Hai Shalom4fbc08f2020-05-18 12:37:00 -0700717struct dpp_authentication *
718dpp_reconfig_auth_req_rx(struct dpp_global *dpp, void *msg_ctx,
719 const char *own_connector,
720 const u8 *net_access_key, size_t net_access_key_len,
721 const u8 *csign_key, size_t csign_key_len,
722 unsigned int freq, const u8 *hdr,
723 const u8 *attr_start, size_t attr_len);
724struct wpabuf *
725dpp_reconfig_auth_resp_rx(struct dpp_authentication *auth, const u8 *hdr,
726 const u8 *attr_start, size_t attr_len);
727int dpp_reconfig_auth_conf_rx(struct dpp_authentication *auth, const u8 *hdr,
728 const u8 *attr_start, size_t attr_len);
729
Hai Shalom899fcc72020-10-19 14:38:18 -0700730struct dpp_reconfig_id * dpp_gen_reconfig_id(const u8 *csign_key,
731 size_t csign_key_len,
732 const u8 *pp_key,
733 size_t pp_key_len);
734int dpp_update_reconfig_id(struct dpp_reconfig_id *id);
735void dpp_free_reconfig_id(struct dpp_reconfig_id *id);
736
Hai Shalom021b0b52019-04-10 11:17:58 -0700737#endif /* CONFIG_DPP */
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700738#endif /* DPP_H */