blob: 99a1ca718667d556839ea977a853961d227c7faf [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 Shalom81f62d82019-07-22 12:10:00 -070038#define DPP_TCP_PORT 7871
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;
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700352#ifdef CONFIG_TESTING_OPTIONS
353 char *config_obj_override;
354 char *discovery_override;
355 char *groups_override;
356 unsigned int ignore_netaccesskey_mismatch:1;
357#endif /* CONFIG_TESTING_OPTIONS */
Hai Shalom06768112019-12-04 15:49:43 -0800358 unsigned short band_list[DPP_MAX_CHANNELS];
359 int band_list_size;
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700360};
361
362struct dpp_configurator {
363 struct dl_list list;
364 unsigned int id;
365 int own;
366 EVP_PKEY *csign;
Hai Shalom4fbc08f2020-05-18 12:37:00 -0700367 u8 kid_hash[SHA256_MAC_LEN];
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700368 char *kid;
369 const struct dpp_curve_params *curve;
Hai Shalom4fbc08f2020-05-18 12:37:00 -0700370 char *connector; /* own Connector for reconfiguration */
371 EVP_PKEY *connector_key;
Hai Shalom899fcc72020-10-19 14:38:18 -0700372 EVP_PKEY *pp_key;
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700373};
374
375struct dpp_introduction {
376 u8 pmkid[PMKID_LEN];
377 u8 pmk[PMK_LEN_MAX];
378 size_t pmk_len;
379};
380
Hai Shalom81f62d82019-07-22 12:10:00 -0700381struct dpp_relay_config {
382 const struct hostapd_ip_addr *ipaddr;
383 const u8 *pkhash;
384
Hai Shalom899fcc72020-10-19 14:38:18 -0700385 void *msg_ctx;
Hai Shalom81f62d82019-07-22 12:10:00 -0700386 void *cb_ctx;
387 void (*tx)(void *ctx, const u8 *addr, unsigned int freq, const u8 *msg,
388 size_t len);
389 void (*gas_resp_tx)(void *ctx, const u8 *addr, u8 dialog_token, int prot,
390 struct wpabuf *buf);
391};
392
393struct dpp_controller_config {
394 const char *configurator_params;
395 int tcp_port;
Hai Shalom4fbc08f2020-05-18 12:37:00 -0700396 u8 allowed_roles;
Hai Shalom899fcc72020-10-19 14:38:18 -0700397 int qr_mutual;
398 enum dpp_netrole netrole;
399 void *msg_ctx;
400 void *cb_ctx;
401 int (*process_conf_obj)(void *ctx, struct dpp_authentication *auth);
Hai Shalom81f62d82019-07-22 12:10:00 -0700402};
403
Roshan Pius3a1667e2018-07-03 15:17:14 -0700404#ifdef CONFIG_TESTING_OPTIONS
405enum dpp_test_behavior {
406 DPP_TEST_DISABLED = 0,
407 DPP_TEST_AFTER_WRAPPED_DATA_AUTH_REQ = 1,
408 DPP_TEST_AFTER_WRAPPED_DATA_AUTH_RESP = 2,
409 DPP_TEST_AFTER_WRAPPED_DATA_AUTH_CONF = 3,
410 DPP_TEST_AFTER_WRAPPED_DATA_PKEX_CR_REQ = 4,
411 DPP_TEST_AFTER_WRAPPED_DATA_PKEX_CR_RESP = 5,
412 DPP_TEST_AFTER_WRAPPED_DATA_CONF_REQ = 6,
413 DPP_TEST_AFTER_WRAPPED_DATA_CONF_RESP = 7,
414 DPP_TEST_ZERO_I_CAPAB = 8,
415 DPP_TEST_ZERO_R_CAPAB = 9,
416 DPP_TEST_NO_R_BOOTSTRAP_KEY_HASH_AUTH_REQ = 10,
417 DPP_TEST_NO_I_BOOTSTRAP_KEY_HASH_AUTH_REQ = 11,
418 DPP_TEST_NO_I_PROTO_KEY_AUTH_REQ = 12,
419 DPP_TEST_NO_I_NONCE_AUTH_REQ = 13,
420 DPP_TEST_NO_I_CAPAB_AUTH_REQ = 14,
421 DPP_TEST_NO_WRAPPED_DATA_AUTH_REQ = 15,
422 DPP_TEST_NO_STATUS_AUTH_RESP = 16,
423 DPP_TEST_NO_R_BOOTSTRAP_KEY_HASH_AUTH_RESP = 17,
424 DPP_TEST_NO_I_BOOTSTRAP_KEY_HASH_AUTH_RESP = 18,
425 DPP_TEST_NO_R_PROTO_KEY_AUTH_RESP = 19,
426 DPP_TEST_NO_R_NONCE_AUTH_RESP = 20,
427 DPP_TEST_NO_I_NONCE_AUTH_RESP = 21,
428 DPP_TEST_NO_R_CAPAB_AUTH_RESP = 22,
429 DPP_TEST_NO_R_AUTH_AUTH_RESP = 23,
430 DPP_TEST_NO_WRAPPED_DATA_AUTH_RESP = 24,
431 DPP_TEST_NO_STATUS_AUTH_CONF = 25,
432 DPP_TEST_NO_R_BOOTSTRAP_KEY_HASH_AUTH_CONF = 26,
433 DPP_TEST_NO_I_BOOTSTRAP_KEY_HASH_AUTH_CONF = 27,
434 DPP_TEST_NO_I_AUTH_AUTH_CONF = 28,
435 DPP_TEST_NO_WRAPPED_DATA_AUTH_CONF = 29,
436 DPP_TEST_I_NONCE_MISMATCH_AUTH_RESP = 30,
437 DPP_TEST_INCOMPATIBLE_R_CAPAB_AUTH_RESP = 31,
438 DPP_TEST_R_AUTH_MISMATCH_AUTH_RESP = 32,
439 DPP_TEST_I_AUTH_MISMATCH_AUTH_CONF = 33,
440 DPP_TEST_NO_FINITE_CYCLIC_GROUP_PKEX_EXCHANGE_REQ = 34,
441 DPP_TEST_NO_ENCRYPTED_KEY_PKEX_EXCHANGE_REQ = 35,
442 DPP_TEST_NO_STATUS_PKEX_EXCHANGE_RESP = 36,
443 DPP_TEST_NO_ENCRYPTED_KEY_PKEX_EXCHANGE_RESP = 37,
444 DPP_TEST_NO_BOOTSTRAP_KEY_PKEX_CR_REQ = 38,
445 DPP_TEST_NO_I_AUTH_TAG_PKEX_CR_REQ = 39,
446 DPP_TEST_NO_WRAPPED_DATA_PKEX_CR_REQ = 40,
447 DPP_TEST_NO_BOOTSTRAP_KEY_PKEX_CR_RESP = 41,
448 DPP_TEST_NO_R_AUTH_TAG_PKEX_CR_RESP = 42,
449 DPP_TEST_NO_WRAPPED_DATA_PKEX_CR_RESP = 43,
450 DPP_TEST_INVALID_ENCRYPTED_KEY_PKEX_EXCHANGE_REQ = 44,
451 DPP_TEST_INVALID_ENCRYPTED_KEY_PKEX_EXCHANGE_RESP = 45,
452 DPP_TEST_INVALID_STATUS_PKEX_EXCHANGE_RESP = 46,
453 DPP_TEST_INVALID_BOOTSTRAP_KEY_PKEX_CR_REQ = 47,
454 DPP_TEST_INVALID_BOOTSTRAP_KEY_PKEX_CR_RESP = 48,
455 DPP_TEST_I_AUTH_TAG_MISMATCH_PKEX_CR_REQ = 49,
456 DPP_TEST_R_AUTH_TAG_MISMATCH_PKEX_CR_RESP = 50,
457 DPP_TEST_NO_E_NONCE_CONF_REQ = 51,
458 DPP_TEST_NO_CONFIG_ATTR_OBJ_CONF_REQ = 52,
459 DPP_TEST_NO_WRAPPED_DATA_CONF_REQ = 53,
460 DPP_TEST_NO_E_NONCE_CONF_RESP = 54,
461 DPP_TEST_NO_CONFIG_OBJ_CONF_RESP = 55,
462 DPP_TEST_NO_STATUS_CONF_RESP = 56,
463 DPP_TEST_NO_WRAPPED_DATA_CONF_RESP = 57,
464 DPP_TEST_INVALID_STATUS_CONF_RESP = 58,
465 DPP_TEST_E_NONCE_MISMATCH_CONF_RESP = 59,
466 DPP_TEST_NO_TRANSACTION_ID_PEER_DISC_REQ = 60,
467 DPP_TEST_NO_CONNECTOR_PEER_DISC_REQ = 61,
468 DPP_TEST_NO_TRANSACTION_ID_PEER_DISC_RESP = 62,
469 DPP_TEST_NO_STATUS_PEER_DISC_RESP = 63,
470 DPP_TEST_NO_CONNECTOR_PEER_DISC_RESP = 64,
471 DPP_TEST_AUTH_RESP_IN_PLACE_OF_CONF = 65,
472 DPP_TEST_INVALID_I_PROTO_KEY_AUTH_REQ = 66,
473 DPP_TEST_INVALID_R_PROTO_KEY_AUTH_RESP = 67,
474 DPP_TEST_INVALID_R_BOOTSTRAP_KEY_HASH_AUTH_REQ = 68,
475 DPP_TEST_INVALID_I_BOOTSTRAP_KEY_HASH_AUTH_REQ = 69,
476 DPP_TEST_INVALID_R_BOOTSTRAP_KEY_HASH_AUTH_RESP = 70,
477 DPP_TEST_INVALID_I_BOOTSTRAP_KEY_HASH_AUTH_RESP = 71,
478 DPP_TEST_INVALID_R_BOOTSTRAP_KEY_HASH_AUTH_CONF = 72,
479 DPP_TEST_INVALID_I_BOOTSTRAP_KEY_HASH_AUTH_CONF = 73,
480 DPP_TEST_INVALID_STATUS_AUTH_RESP = 74,
481 DPP_TEST_INVALID_STATUS_AUTH_CONF = 75,
482 DPP_TEST_INVALID_CONFIG_ATTR_OBJ_CONF_REQ = 76,
483 DPP_TEST_INVALID_TRANSACTION_ID_PEER_DISC_RESP = 77,
484 DPP_TEST_INVALID_STATUS_PEER_DISC_RESP = 78,
485 DPP_TEST_INVALID_CONNECTOR_PEER_DISC_RESP = 79,
486 DPP_TEST_INVALID_CONNECTOR_PEER_DISC_REQ = 80,
487 DPP_TEST_INVALID_I_NONCE_AUTH_REQ = 81,
488 DPP_TEST_INVALID_TRANSACTION_ID_PEER_DISC_REQ = 82,
489 DPP_TEST_INVALID_E_NONCE_CONF_REQ = 83,
490 DPP_TEST_STOP_AT_PKEX_EXCHANGE_RESP = 84,
491 DPP_TEST_STOP_AT_PKEX_CR_REQ = 85,
492 DPP_TEST_STOP_AT_PKEX_CR_RESP = 86,
493 DPP_TEST_STOP_AT_AUTH_REQ = 87,
494 DPP_TEST_STOP_AT_AUTH_RESP = 88,
495 DPP_TEST_STOP_AT_AUTH_CONF = 89,
496 DPP_TEST_STOP_AT_CONF_REQ = 90,
Hai Shalom021b0b52019-04-10 11:17:58 -0700497 DPP_TEST_REJECT_CONFIG = 91,
Roshan Pius3a1667e2018-07-03 15:17:14 -0700498};
499
500extern enum dpp_test_behavior dpp_test;
501extern u8 dpp_pkex_own_mac_override[ETH_ALEN];
502extern u8 dpp_pkex_peer_mac_override[ETH_ALEN];
503extern u8 dpp_pkex_ephemeral_key_override[600];
504extern size_t dpp_pkex_ephemeral_key_override_len;
505extern u8 dpp_protocol_key_override[600];
506extern size_t dpp_protocol_key_override_len;
507extern u8 dpp_nonce_override[DPP_MAX_NONCE_LEN];
508extern size_t dpp_nonce_override_len;
509#endif /* CONFIG_TESTING_OPTIONS */
510
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700511void dpp_bootstrap_info_free(struct dpp_bootstrap_info *info);
512const char * dpp_bootstrap_type_txt(enum dpp_bootstrap_type type);
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700513int dpp_parse_uri_chan_list(struct dpp_bootstrap_info *bi,
514 const char *chan_list);
515int dpp_parse_uri_mac(struct dpp_bootstrap_info *bi, const char *mac);
516int dpp_parse_uri_info(struct dpp_bootstrap_info *bi, const char *info);
Hai Shalomfdcde762020-04-02 11:19:20 -0700517int dpp_nfc_update_bi(struct dpp_bootstrap_info *own_bi,
518 struct dpp_bootstrap_info *peer_bi);
519struct dpp_authentication *
520dpp_alloc_auth(struct dpp_global *dpp, void *msg_ctx);
Roshan Pius3a1667e2018-07-03 15:17:14 -0700521struct hostapd_hw_modes;
Hai Shalomfdcde762020-04-02 11:19:20 -0700522struct dpp_authentication * dpp_auth_init(struct dpp_global *dpp, void *msg_ctx,
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700523 struct dpp_bootstrap_info *peer_bi,
524 struct dpp_bootstrap_info *own_bi,
Roshan Pius3a1667e2018-07-03 15:17:14 -0700525 u8 dpp_allowed_roles,
526 unsigned int neg_freq,
527 struct hostapd_hw_modes *own_modes,
528 u16 num_modes);
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700529struct dpp_authentication *
Hai Shalomfdcde762020-04-02 11:19:20 -0700530dpp_auth_req_rx(struct dpp_global *dpp, void *msg_ctx, u8 dpp_allowed_roles,
531 int qr_mutual, struct dpp_bootstrap_info *peer_bi,
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700532 struct dpp_bootstrap_info *own_bi,
533 unsigned int freq, const u8 *hdr, const u8 *attr_start,
Roshan Pius3a1667e2018-07-03 15:17:14 -0700534 size_t attr_len);
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700535struct wpabuf *
536dpp_auth_resp_rx(struct dpp_authentication *auth, const u8 *hdr,
537 const u8 *attr_start, size_t attr_len);
538struct wpabuf * dpp_build_conf_req(struct dpp_authentication *auth,
539 const char *json);
Hai Shalomc3565922019-10-28 11:58:20 -0700540struct wpabuf * dpp_build_conf_req_helper(struct dpp_authentication *auth,
Ahmed ElArabawy0ff61c52019-12-26 12:38:39 -0800541 const char *name,
542 enum dpp_netrole netrole,
Hai Shalomc3565922019-10-28 11:58:20 -0700543 const char *mud_url, int *opclasses);
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700544int dpp_auth_conf_rx(struct dpp_authentication *auth, const u8 *hdr,
545 const u8 *attr_start, size_t attr_len);
546int dpp_notify_new_qr_code(struct dpp_authentication *auth,
547 struct dpp_bootstrap_info *peer_bi);
Hai Shalom021b0b52019-04-10 11:17:58 -0700548struct dpp_configuration * dpp_configuration_alloc(const char *type);
549int dpp_akm_psk(enum dpp_akm akm);
550int dpp_akm_sae(enum dpp_akm akm);
551int dpp_akm_legacy(enum dpp_akm akm);
552int dpp_akm_dpp(enum dpp_akm akm);
553int dpp_akm_ver2(enum dpp_akm akm);
554int dpp_configuration_valid(const struct dpp_configuration *conf);
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700555void dpp_configuration_free(struct dpp_configuration *conf);
Hai Shalomfdcde762020-04-02 11:19:20 -0700556int dpp_set_configurator(struct dpp_authentication *auth, const char *cmd);
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700557void dpp_auth_deinit(struct dpp_authentication *auth);
558struct wpabuf *
Hai Shalom899fcc72020-10-19 14:38:18 -0700559dpp_build_conf_resp(struct dpp_authentication *auth, const u8 *e_nonce,
560 u16 e_nonce_len, enum dpp_netrole netrole,
561 bool cert_req);
562struct wpabuf *
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700563dpp_conf_req_rx(struct dpp_authentication *auth, const u8 *attr_start,
564 size_t attr_len);
565int dpp_conf_resp_rx(struct dpp_authentication *auth,
566 const struct wpabuf *resp);
Hai Shalom021b0b52019-04-10 11:17:58 -0700567enum dpp_status_error dpp_conf_result_rx(struct dpp_authentication *auth,
568 const u8 *hdr,
569 const u8 *attr_start, size_t attr_len);
570struct wpabuf * dpp_build_conf_result(struct dpp_authentication *auth,
571 enum dpp_status_error status);
Hai Shalomc3565922019-10-28 11:58:20 -0700572enum dpp_status_error dpp_conn_status_result_rx(struct dpp_authentication *auth,
573 const u8 *hdr,
574 const u8 *attr_start,
575 size_t attr_len,
576 u8 *ssid, size_t *ssid_len,
577 char **channel_list);
578struct wpabuf * dpp_build_conn_status_result(struct dpp_authentication *auth,
579 enum dpp_status_error result,
580 const u8 *ssid, size_t ssid_len,
581 const char *channel_list);
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700582struct wpabuf * dpp_alloc_msg(enum dpp_public_action_frame_type type,
583 size_t len);
584const u8 * dpp_get_attr(const u8 *buf, size_t len, u16 req_id, u16 *ret_len);
585int dpp_check_attrs(const u8 *buf, size_t len);
586int dpp_key_expired(const char *timestamp, os_time_t *expiry);
Roshan Pius3a1667e2018-07-03 15:17:14 -0700587const char * dpp_akm_str(enum dpp_akm akm);
Hai Shalomc3565922019-10-28 11:58:20 -0700588const char * dpp_akm_selector_str(enum dpp_akm akm);
Roshan Pius3a1667e2018-07-03 15:17:14 -0700589int dpp_configurator_get_key(const struct dpp_configurator *conf, char *buf,
590 size_t buflen);
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700591void dpp_configurator_free(struct dpp_configurator *conf);
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700592int dpp_configurator_own_config(struct dpp_authentication *auth,
Roshan Pius3a1667e2018-07-03 15:17:14 -0700593 const char *curve, int ap);
594enum dpp_status_error
595dpp_peer_intro(struct dpp_introduction *intro, const char *own_connector,
596 const u8 *net_access_key, size_t net_access_key_len,
597 const u8 *csign_key, size_t csign_key_len,
598 const u8 *peer_connector, size_t peer_connector_len,
599 os_time_t *expiry);
600struct dpp_pkex * dpp_pkex_init(void *msg_ctx, struct dpp_bootstrap_info *bi,
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700601 const u8 *own_mac,
602 const char *identifier,
603 const char *code);
Roshan Pius3a1667e2018-07-03 15:17:14 -0700604struct dpp_pkex * dpp_pkex_rx_exchange_req(void *msg_ctx,
605 struct dpp_bootstrap_info *bi,
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700606 const u8 *own_mac,
607 const u8 *peer_mac,
608 const char *identifier,
609 const char *code,
610 const u8 *buf, size_t len);
611struct wpabuf * dpp_pkex_rx_exchange_resp(struct dpp_pkex *pkex,
Roshan Pius3a1667e2018-07-03 15:17:14 -0700612 const u8 *peer_mac,
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700613 const u8 *buf, size_t len);
614struct wpabuf * dpp_pkex_rx_commit_reveal_req(struct dpp_pkex *pkex,
615 const u8 *hdr,
616 const u8 *buf, size_t len);
617int dpp_pkex_rx_commit_reveal_resp(struct dpp_pkex *pkex, const u8 *hdr,
618 const u8 *buf, size_t len);
619void dpp_pkex_free(struct dpp_pkex *pkex);
620
Roshan Pius3a1667e2018-07-03 15:17:14 -0700621char * dpp_corrupt_connector_signature(const char *connector);
622
Hai Shalom021b0b52019-04-10 11:17:58 -0700623
624struct dpp_pfs {
625 struct crypto_ecdh *ecdh;
626 const struct dpp_curve_params *curve;
627 struct wpabuf *ie;
628 struct wpabuf *secret;
629};
630
631struct dpp_pfs * dpp_pfs_init(const u8 *net_access_key,
632 size_t net_access_key_len);
633int dpp_pfs_process(struct dpp_pfs *pfs, const u8 *peer_ie, size_t peer_ie_len);
634void dpp_pfs_free(struct dpp_pfs *pfs);
635
Hai Shalom899fcc72020-10-19 14:38:18 -0700636struct wpabuf * dpp_build_csr(struct dpp_authentication *auth,
637 const char *name);
638struct wpabuf * dpp_pkcs7_certs(const struct wpabuf *pkcs7);
639int dpp_validate_csr(struct dpp_authentication *auth, const struct wpabuf *csr);
640
Hai Shalom021b0b52019-04-10 11:17:58 -0700641struct dpp_bootstrap_info * dpp_add_qr_code(struct dpp_global *dpp,
642 const char *uri);
Ahmed ElArabawy0ff61c52019-12-26 12:38:39 -0800643struct dpp_bootstrap_info * dpp_add_nfc_uri(struct dpp_global *dpp,
644 const char *uri);
Hai Shalom021b0b52019-04-10 11:17:58 -0700645int dpp_bootstrap_gen(struct dpp_global *dpp, const char *cmd);
646struct dpp_bootstrap_info *
647dpp_bootstrap_get_id(struct dpp_global *dpp, unsigned int id);
648int dpp_bootstrap_remove(struct dpp_global *dpp, const char *id);
649struct dpp_bootstrap_info *
650dpp_pkex_finish(struct dpp_global *dpp, struct dpp_pkex *pkex, const u8 *peer,
651 unsigned int freq);
652const char * dpp_bootstrap_get_uri(struct dpp_global *dpp, unsigned int id);
653int dpp_bootstrap_info(struct dpp_global *dpp, int id,
654 char *reply, int reply_size);
Hai Shalomfdcde762020-04-02 11:19:20 -0700655int dpp_bootstrap_set(struct dpp_global *dpp, int id, const char *params);
Hai Shalom021b0b52019-04-10 11:17:58 -0700656void dpp_bootstrap_find_pair(struct dpp_global *dpp, const u8 *i_bootstrap,
657 const u8 *r_bootstrap,
658 struct dpp_bootstrap_info **own_bi,
659 struct dpp_bootstrap_info **peer_bi);
Hai Shalomfdcde762020-04-02 11:19:20 -0700660struct dpp_bootstrap_info * dpp_bootstrap_find_chirp(struct dpp_global *dpp,
661 const u8 *hash);
Hai Shalom021b0b52019-04-10 11:17:58 -0700662int dpp_configurator_add(struct dpp_global *dpp, const char *cmd);
663int dpp_configurator_remove(struct dpp_global *dpp, const char *id);
664int dpp_configurator_get_key_id(struct dpp_global *dpp, unsigned int id,
665 char *buf, size_t buflen);
Hai Shalomfdcde762020-04-02 11:19:20 -0700666int dpp_configurator_from_backup(struct dpp_global *dpp,
667 struct dpp_asymmetric_key *key);
Hai Shalom4fbc08f2020-05-18 12:37:00 -0700668struct dpp_configurator * dpp_configurator_find_kid(struct dpp_global *dpp,
669 const u8 *kid);
Hai Shalom81f62d82019-07-22 12:10:00 -0700670int dpp_relay_add_controller(struct dpp_global *dpp,
671 struct dpp_relay_config *config);
672int dpp_relay_rx_action(struct dpp_global *dpp, const u8 *src, const u8 *hdr,
673 const u8 *buf, size_t len, unsigned int freq,
674 const u8 *i_bootstrap, const u8 *r_bootstrap);
675int dpp_relay_rx_gas_req(struct dpp_global *dpp, const u8 *src, const u8 *data,
676 size_t data_len);
677int dpp_controller_start(struct dpp_global *dpp,
678 struct dpp_controller_config *config);
679void dpp_controller_stop(struct dpp_global *dpp);
Hai Shalom899fcc72020-10-19 14:38:18 -0700680struct dpp_authentication * dpp_controller_get_auth(struct dpp_global *dpp,
681 unsigned int id);
682void dpp_controller_new_qr_code(struct dpp_global *dpp,
683 struct dpp_bootstrap_info *bi);
Hai Shalom81f62d82019-07-22 12:10:00 -0700684int dpp_tcp_init(struct dpp_global *dpp, struct dpp_authentication *auth,
Hai Shalom899fcc72020-10-19 14:38:18 -0700685 const struct hostapd_ip_addr *addr, int port,
686 const char *name, enum dpp_netrole netrole, void *msg_ctx,
687 void *cb_ctx,
688 int (*process_conf_obj)(void *ctx,
689 struct dpp_authentication *auth));
690
Hai Shalomfdcde762020-04-02 11:19:20 -0700691struct wpabuf * dpp_build_presence_announcement(struct dpp_bootstrap_info *bi);
Hai Shalom899fcc72020-10-19 14:38:18 -0700692void dpp_notify_chirp_received(void *msg_ctx, int id, const u8 *src,
693 unsigned int freq, const u8 *hash);
Hai Shalom81f62d82019-07-22 12:10:00 -0700694
695struct dpp_global_config {
Hai Shalom81f62d82019-07-22 12:10:00 -0700696 void *cb_ctx;
Hai Shalomfdcde762020-04-02 11:19:20 -0700697 void (*remove_bi)(void *ctx, struct dpp_bootstrap_info *bi);
Hai Shalom81f62d82019-07-22 12:10:00 -0700698};
699
700struct dpp_global * dpp_global_init(struct dpp_global_config *config);
Hai Shalom021b0b52019-04-10 11:17:58 -0700701void dpp_global_clear(struct dpp_global *dpp);
702void dpp_global_deinit(struct dpp_global *dpp);
703
Hai Shalom4fbc08f2020-05-18 12:37:00 -0700704/* dpp_reconfig.c */
705
706struct wpabuf * dpp_build_reconfig_announcement(const u8 *csign_key,
Hai Shalom899fcc72020-10-19 14:38:18 -0700707 size_t csign_key_len,
708 const u8 *net_access_key,
709 size_t net_access_key_len,
710 struct dpp_reconfig_id *id);
Hai Shalom4fbc08f2020-05-18 12:37:00 -0700711struct dpp_authentication *
712dpp_reconfig_init(struct dpp_global *dpp, void *msg_ctx,
Hai Shalom899fcc72020-10-19 14:38:18 -0700713 struct dpp_configurator *conf, unsigned int freq, u16 group,
714 const u8 *a_nonce_attr, size_t a_nonce_len,
715 const u8 *e_id_attr, size_t e_id_len);
Hai Shalom4fbc08f2020-05-18 12:37:00 -0700716struct dpp_authentication *
717dpp_reconfig_auth_req_rx(struct dpp_global *dpp, void *msg_ctx,
718 const char *own_connector,
719 const u8 *net_access_key, size_t net_access_key_len,
720 const u8 *csign_key, size_t csign_key_len,
721 unsigned int freq, const u8 *hdr,
722 const u8 *attr_start, size_t attr_len);
723struct wpabuf *
724dpp_reconfig_auth_resp_rx(struct dpp_authentication *auth, const u8 *hdr,
725 const u8 *attr_start, size_t attr_len);
726int dpp_reconfig_auth_conf_rx(struct dpp_authentication *auth, const u8 *hdr,
727 const u8 *attr_start, size_t attr_len);
728
Hai Shalom899fcc72020-10-19 14:38:18 -0700729struct dpp_reconfig_id * dpp_gen_reconfig_id(const u8 *csign_key,
730 size_t csign_key_len,
731 const u8 *pp_key,
732 size_t pp_key_len);
733int dpp_update_reconfig_id(struct dpp_reconfig_id *id);
734void dpp_free_reconfig_id(struct dpp_reconfig_id *id);
735
Hai Shalom021b0b52019-04-10 11:17:58 -0700736#endif /* CONFIG_DPP */
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700737#endif /* DPP_H */