blob: fba41190891b8ff41fb6dfd9b3eb10db33ad9df4 [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
Hai Shaloma20dcd72022-02-04 13:43:00 -08005 * Copyright (c) 2021-2022, Qualcomm Innovation Center, Inc.
Dmitry Shmidtd2986c22017-10-23 14:22:09 -07006 *
7 * This software may be distributed under the terms of the BSD license.
8 * See README for more details.
9 */
10
11#ifndef DPP_H
12#define DPP_H
13
Hai Shalom021b0b52019-04-10 11:17:58 -070014#ifdef CONFIG_DPP
Dmitry Shmidtd2986c22017-10-23 14:22:09 -070015#include "utils/list.h"
16#include "common/wpa_common.h"
17#include "crypto/sha256.h"
Hai Shaloma20dcd72022-02-04 13:43:00 -080018#include "crypto/crypto.h"
Dmitry Shmidtd2986c22017-10-23 14:22:09 -070019
Hai Shalom81f62d82019-07-22 12:10:00 -070020struct hostapd_ip_addr;
Hai Shalom021b0b52019-04-10 11:17:58 -070021struct dpp_global;
Hai Shalom4fbc08f2020-05-18 12:37:00 -070022struct json_token;
Hai Shalom899fcc72020-10-19 14:38:18 -070023struct dpp_reconfig_id;
Hai Shalom4fbc08f2020-05-18 12:37:00 -070024
25#ifdef CONFIG_TESTING_OPTIONS
26#define DPP_VERSION (dpp_version_override)
27extern int dpp_version_override;
28#else /* CONFIG_TESTING_OPTIONS */
Hai Shaloma20dcd72022-02-04 13:43:00 -080029#ifdef CONFIG_DPP3
30#define DPP_VERSION 3
31#elif defined(CONFIG_DPP2)
Hai Shalom4fbc08f2020-05-18 12:37:00 -070032#define DPP_VERSION 2
33#else
34#define DPP_VERSION 1
35#endif
36#endif /* CONFIG_TESTING_OPTIONS */
Hai Shalom021b0b52019-04-10 11:17:58 -070037
Dmitry Shmidtd2986c22017-10-23 14:22:09 -070038#define DPP_HDR_LEN (4 + 2) /* OUI, OUI Type, Crypto Suite, DPP frame type */
Hai Shalom60840252021-02-19 19:02:11 -080039#define DPP_TCP_PORT 8908
Dmitry Shmidtd2986c22017-10-23 14:22:09 -070040
41enum dpp_public_action_frame_type {
42 DPP_PA_AUTHENTICATION_REQ = 0,
43 DPP_PA_AUTHENTICATION_RESP = 1,
44 DPP_PA_AUTHENTICATION_CONF = 2,
45 DPP_PA_PEER_DISCOVERY_REQ = 5,
46 DPP_PA_PEER_DISCOVERY_RESP = 6,
Hai Shaloma20dcd72022-02-04 13:43:00 -080047 DPP_PA_PKEX_V1_EXCHANGE_REQ = 7,
Dmitry Shmidtd2986c22017-10-23 14:22:09 -070048 DPP_PA_PKEX_EXCHANGE_RESP = 8,
49 DPP_PA_PKEX_COMMIT_REVEAL_REQ = 9,
50 DPP_PA_PKEX_COMMIT_REVEAL_RESP = 10,
Hai Shalom021b0b52019-04-10 11:17:58 -070051 DPP_PA_CONFIGURATION_RESULT = 11,
Hai Shalomc3565922019-10-28 11:58:20 -070052 DPP_PA_CONNECTION_STATUS_RESULT = 12,
Hai Shalomfdcde762020-04-02 11:19:20 -070053 DPP_PA_PRESENCE_ANNOUNCEMENT = 13,
54 DPP_PA_RECONFIG_ANNOUNCEMENT = 14,
55 DPP_PA_RECONFIG_AUTH_REQ = 15,
56 DPP_PA_RECONFIG_AUTH_RESP = 16,
57 DPP_PA_RECONFIG_AUTH_CONF = 17,
Hai Shaloma20dcd72022-02-04 13:43:00 -080058 DPP_PA_PKEX_EXCHANGE_REQ = 18,
Dmitry Shmidtd2986c22017-10-23 14:22:09 -070059};
60
61enum dpp_attribute_id {
62 DPP_ATTR_STATUS = 0x1000,
63 DPP_ATTR_I_BOOTSTRAP_KEY_HASH = 0x1001,
64 DPP_ATTR_R_BOOTSTRAP_KEY_HASH = 0x1002,
65 DPP_ATTR_I_PROTOCOL_KEY = 0x1003,
66 DPP_ATTR_WRAPPED_DATA = 0x1004,
67 DPP_ATTR_I_NONCE = 0x1005,
68 DPP_ATTR_I_CAPABILITIES = 0x1006,
69 DPP_ATTR_R_NONCE = 0x1007,
70 DPP_ATTR_R_CAPABILITIES = 0x1008,
71 DPP_ATTR_R_PROTOCOL_KEY = 0x1009,
72 DPP_ATTR_I_AUTH_TAG = 0x100A,
73 DPP_ATTR_R_AUTH_TAG = 0x100B,
74 DPP_ATTR_CONFIG_OBJ = 0x100C,
75 DPP_ATTR_CONNECTOR = 0x100D,
76 DPP_ATTR_CONFIG_ATTR_OBJ = 0x100E,
77 DPP_ATTR_BOOTSTRAP_KEY = 0x100F,
78 DPP_ATTR_OWN_NET_NK_HASH = 0x1011,
79 DPP_ATTR_FINITE_CYCLIC_GROUP = 0x1012,
80 DPP_ATTR_ENCRYPTED_KEY = 0x1013,
81 DPP_ATTR_ENROLLEE_NONCE = 0x1014,
82 DPP_ATTR_CODE_IDENTIFIER = 0x1015,
83 DPP_ATTR_TRANSACTION_ID = 0x1016,
Roshan Pius3a1667e2018-07-03 15:17:14 -070084 DPP_ATTR_BOOTSTRAP_INFO = 0x1017,
85 DPP_ATTR_CHANNEL = 0x1018,
Hai Shalom021b0b52019-04-10 11:17:58 -070086 DPP_ATTR_PROTOCOL_VERSION = 0x1019,
87 DPP_ATTR_ENVELOPED_DATA = 0x101A,
Hai Shalomc3565922019-10-28 11:58:20 -070088 DPP_ATTR_SEND_CONN_STATUS = 0x101B,
89 DPP_ATTR_CONN_STATUS = 0x101C,
Hai Shalomfdcde762020-04-02 11:19:20 -070090 DPP_ATTR_RECONFIG_FLAGS = 0x101D,
91 DPP_ATTR_C_SIGN_KEY_HASH = 0x101E,
92 DPP_ATTR_CSR_ATTR_REQ = 0x101F,
Hai Shalom899fcc72020-10-19 14:38:18 -070093 DPP_ATTR_A_NONCE = 0x1020,
94 DPP_ATTR_E_PRIME_ID = 0x1021,
95 DPP_ATTR_CONFIGURATOR_NONCE = 0x1022,
Dmitry Shmidtd2986c22017-10-23 14:22:09 -070096};
97
98enum dpp_status_error {
99 DPP_STATUS_OK = 0,
100 DPP_STATUS_NOT_COMPATIBLE = 1,
101 DPP_STATUS_AUTH_FAILURE = 2,
102 DPP_STATUS_UNWRAP_FAILURE = 3,
103 DPP_STATUS_BAD_GROUP = 4,
104 DPP_STATUS_CONFIGURE_FAILURE = 5,
105 DPP_STATUS_RESPONSE_PENDING = 6,
Roshan Pius3a1667e2018-07-03 15:17:14 -0700106 DPP_STATUS_INVALID_CONNECTOR = 7,
107 DPP_STATUS_NO_MATCH = 8,
Hai Shalom021b0b52019-04-10 11:17:58 -0700108 DPP_STATUS_CONFIG_REJECTED = 9,
Hai Shalomc3565922019-10-28 11:58:20 -0700109 DPP_STATUS_NO_AP = 10,
Hai Shalomfdcde762020-04-02 11:19:20 -0700110 DPP_STATUS_CONFIGURE_PENDING = 11,
111 DPP_STATUS_CSR_NEEDED = 12,
112 DPP_STATUS_CSR_BAD = 13,
Sunil Ravia04bd252022-05-02 22:54:18 -0700113 DPP_STATUS_NEW_KEY_NEEDED = 14,
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700114};
115
Hai Shalom4fbc08f2020-05-18 12:37:00 -0700116/* DPP Reconfig Flags object - connectorKey values */
117enum dpp_connector_key {
118 DPP_CONFIG_REUSEKEY = 0,
119 DPP_CONFIG_REPLACEKEY = 1,
120};
121
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700122#define DPP_CAPAB_ENROLLEE BIT(0)
123#define DPP_CAPAB_CONFIGURATOR BIT(1)
124#define DPP_CAPAB_ROLE_MASK (BIT(0) | BIT(1))
125
126#define DPP_BOOTSTRAP_MAX_FREQ 30
127#define DPP_MAX_NONCE_LEN 32
128#define DPP_MAX_HASH_LEN 64
129#define DPP_MAX_SHARED_SECRET_LEN 66
Hai Shalom899fcc72020-10-19 14:38:18 -0700130#define DPP_CP_LEN 64
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700131
132struct dpp_curve_params {
133 const char *name;
134 size_t hash_len;
135 size_t aes_siv_key_len;
136 size_t nonce_len;
137 size_t prime_len;
138 const char *jwk_crv;
139 u16 ike_group;
140 const char *jws_alg;
141};
142
143enum dpp_bootstrap_type {
144 DPP_BOOTSTRAP_QR_CODE,
145 DPP_BOOTSTRAP_PKEX,
Ahmed ElArabawy0ff61c52019-12-26 12:38:39 -0800146 DPP_BOOTSTRAP_NFC_URI,
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700147};
148
Sunil Ravia04bd252022-05-02 22:54:18 -0700149enum dpp_bootstrap_supported_curves {
150 DPP_BOOTSTRAP_CURVE_P_256 = 0,
151 DPP_BOOTSTRAP_CURVE_P_384 = 1,
152 DPP_BOOTSTRAP_CURVE_P_521 = 2,
153 DPP_BOOTSTRAP_CURVE_BP_256 = 3,
154 DPP_BOOTSTRAP_CURVE_BP_384 = 4,
155 DPP_BOOTSTRAP_CURVE_BP_512 = 5,
156};
157
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700158struct dpp_bootstrap_info {
159 struct dl_list list;
160 unsigned int id;
161 enum dpp_bootstrap_type type;
162 char *uri;
163 u8 mac_addr[ETH_ALEN];
Hai Shalomfdcde762020-04-02 11:19:20 -0700164 char *chan;
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700165 char *info;
Hai Shalomfdcde762020-04-02 11:19:20 -0700166 char *pk;
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700167 unsigned int freq[DPP_BOOTSTRAP_MAX_FREQ];
168 unsigned int num_freq;
Hai Shalom899fcc72020-10-19 14:38:18 -0700169 bool channels_listed;
Hai Shalom4fbc08f2020-05-18 12:37:00 -0700170 u8 version;
Sunil Ravia04bd252022-05-02 22:54:18 -0700171 u8 supported_curves; /* enum dpp_bootstrap_supported_curves bitmap */
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700172 int own;
Hai Shaloma20dcd72022-02-04 13:43:00 -0800173 struct crypto_ec_key *pubkey;
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700174 u8 pubkey_hash[SHA256_MAC_LEN];
Hai Shalomfdcde762020-04-02 11:19:20 -0700175 u8 pubkey_hash_chirp[SHA256_MAC_LEN];
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700176 const struct dpp_curve_params *curve;
Roshan Pius3a1667e2018-07-03 15:17:14 -0700177 unsigned int pkex_t; /* number of failures before dpp_pkex
178 * instantiation */
Hai Shalomb755a2a2020-04-23 21:49:02 -0700179 int nfc_negotiated; /* whether this has been used in NFC negotiated
180 * connection handover */
Hai Shalomfdcde762020-04-02 11:19:20 -0700181 char *configurator_params;
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700182};
183
Roshan Pius3a1667e2018-07-03 15:17:14 -0700184#define PKEX_COUNTER_T_LIMIT 5
185
Sunil Ravia04bd252022-05-02 22:54:18 -0700186enum dpp_pkex_ver {
187 PKEX_VER_AUTO,
188 PKEX_VER_ONLY_1,
189 PKEX_VER_ONLY_2,
190};
191
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700192struct dpp_pkex {
Roshan Pius3a1667e2018-07-03 15:17:14 -0700193 void *msg_ctx;
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700194 unsigned int initiator:1;
195 unsigned int exchange_done:1;
Roshan Pius3a1667e2018-07-03 15:17:14 -0700196 unsigned int failed:1;
Hai Shaloma20dcd72022-02-04 13:43:00 -0800197 unsigned int v2:1;
198 unsigned int forced_ver:1;
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700199 struct dpp_bootstrap_info *own_bi;
200 u8 own_mac[ETH_ALEN];
201 u8 peer_mac[ETH_ALEN];
202 char *identifier;
203 char *code;
Hai Shaloma20dcd72022-02-04 13:43:00 -0800204 struct crypto_ec_key *x;
205 struct crypto_ec_key *y;
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700206 u8 Mx[DPP_MAX_SHARED_SECRET_LEN];
207 u8 Nx[DPP_MAX_SHARED_SECRET_LEN];
208 u8 z[DPP_MAX_HASH_LEN];
Hai Shaloma20dcd72022-02-04 13:43:00 -0800209 struct crypto_ec_key *peer_bootstrap_key;
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700210 struct wpabuf *exchange_req;
211 struct wpabuf *exchange_resp;
Roshan Pius3a1667e2018-07-03 15:17:14 -0700212 unsigned int t; /* number of failures on code use */
213 unsigned int exch_req_wait_time;
214 unsigned int exch_req_tries;
215 unsigned int freq;
Hai Shaloma20dcd72022-02-04 13:43:00 -0800216 u8 peer_version;
Roshan Pius3a1667e2018-07-03 15:17:14 -0700217};
218
219enum dpp_akm {
220 DPP_AKM_UNKNOWN,
221 DPP_AKM_DPP,
222 DPP_AKM_PSK,
223 DPP_AKM_SAE,
Hai Shalom021b0b52019-04-10 11:17:58 -0700224 DPP_AKM_PSK_SAE,
225 DPP_AKM_SAE_DPP,
226 DPP_AKM_PSK_SAE_DPP,
Hai Shalom899fcc72020-10-19 14:38:18 -0700227 DPP_AKM_DOT1X,
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700228};
229
Hai Shalomc3565922019-10-28 11:58:20 -0700230enum dpp_netrole {
231 DPP_NETROLE_STA,
232 DPP_NETROLE_AP,
Ahmed ElArabawy0ff61c52019-12-26 12:38:39 -0800233 DPP_NETROLE_CONFIGURATOR,
Hai Shalomc3565922019-10-28 11:58:20 -0700234};
235
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700236struct dpp_configuration {
237 u8 ssid[32];
238 size_t ssid_len;
Ahmed ElArabawy0ff61c52019-12-26 12:38:39 -0800239 int ssid_charset;
Roshan Pius3a1667e2018-07-03 15:17:14 -0700240 enum dpp_akm akm;
Hai Shalomc3565922019-10-28 11:58:20 -0700241 enum dpp_netrole netrole;
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700242
243 /* For DPP configuration (connector) */
244 os_time_t netaccesskey_expiry;
245
246 /* TODO: groups */
Hai Shalomce48b4a2018-09-05 11:41:35 -0700247 char *group_id;
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700248
249 /* For legacy configuration */
250 char *passphrase;
251 u8 psk[32];
Hai Shalom021b0b52019-04-10 11:17:58 -0700252 int psk_set;
Hai Shalom899fcc72020-10-19 14:38:18 -0700253
254 char *csrattrs;
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700255};
256
Hai Shalomfdcde762020-04-02 11:19:20 -0700257struct dpp_asymmetric_key {
258 struct dpp_asymmetric_key *next;
Hai Shaloma20dcd72022-02-04 13:43:00 -0800259 struct crypto_ec_key *csign;
260 struct crypto_ec_key *pp_key;
Hai Shalomfdcde762020-04-02 11:19:20 -0700261 char *config_template;
262 char *connector_template;
263};
264
Hai Shalomc3565922019-10-28 11:58:20 -0700265#define DPP_MAX_CONF_OBJ 10
Hai Shalom06768112019-12-04 15:49:43 -0800266#define DPP_MAX_CHANNELS 32
Hai Shalomc3565922019-10-28 11:58:20 -0700267
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700268struct dpp_authentication {
Hai Shalomfdcde762020-04-02 11:19:20 -0700269 struct dpp_global *global;
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700270 void *msg_ctx;
Hai Shalom021b0b52019-04-10 11:17:58 -0700271 u8 peer_version;
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700272 const struct dpp_curve_params *curve;
Sunil Ravia04bd252022-05-02 22:54:18 -0700273 const struct dpp_curve_params *new_curve;
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700274 struct dpp_bootstrap_info *peer_bi;
275 struct dpp_bootstrap_info *own_bi;
Roshan Pius3a1667e2018-07-03 15:17:14 -0700276 struct dpp_bootstrap_info *tmp_own_bi;
Hai Shalom899fcc72020-10-19 14:38:18 -0700277 struct dpp_bootstrap_info *tmp_peer_bi;
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700278 u8 waiting_pubkey_hash[SHA256_MAC_LEN];
279 int response_pending;
Hai Shalom4fbc08f2020-05-18 12:37:00 -0700280 int reconfig;
281 enum dpp_connector_key reconfig_connector_key;
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700282 enum dpp_status_error auth_resp_status;
Hai Shalom021b0b52019-04-10 11:17:58 -0700283 enum dpp_status_error conf_resp_status;
Hai Shalom899fcc72020-10-19 14:38:18 -0700284 enum dpp_status_error force_conf_resp_status;
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700285 u8 peer_mac_addr[ETH_ALEN];
286 u8 i_nonce[DPP_MAX_NONCE_LEN];
287 u8 r_nonce[DPP_MAX_NONCE_LEN];
288 u8 e_nonce[DPP_MAX_NONCE_LEN];
Hai Shalom899fcc72020-10-19 14:38:18 -0700289 u8 c_nonce[DPP_MAX_NONCE_LEN];
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700290 u8 i_capab;
291 u8 r_capab;
Hai Shalom899fcc72020-10-19 14:38:18 -0700292 enum dpp_netrole e_netrole;
Hai Shaloma20dcd72022-02-04 13:43:00 -0800293 struct crypto_ec_key *own_protocol_key;
294 struct crypto_ec_key *peer_protocol_key;
295 struct crypto_ec_key *reconfig_old_protocol_key;
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700296 struct wpabuf *req_msg;
297 struct wpabuf *resp_msg;
Hai Shalom4fbc08f2020-05-18 12:37:00 -0700298 struct wpabuf *reconfig_req_msg;
299 struct wpabuf *reconfig_resp_msg;
Roshan Pius3a1667e2018-07-03 15:17:14 -0700300 /* Intersection of possible frequencies for initiating DPP
301 * Authentication exchange */
302 unsigned int freq[DPP_BOOTSTRAP_MAX_FREQ];
303 unsigned int num_freq, freq_idx;
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700304 unsigned int curr_freq;
Roshan Pius3a1667e2018-07-03 15:17:14 -0700305 unsigned int neg_freq;
306 unsigned int num_freq_iters;
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700307 size_t secret_len;
308 u8 Mx[DPP_MAX_SHARED_SECRET_LEN];
Roshan Pius3a1667e2018-07-03 15:17:14 -0700309 size_t Mx_len;
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700310 u8 Nx[DPP_MAX_SHARED_SECRET_LEN];
Roshan Pius3a1667e2018-07-03 15:17:14 -0700311 size_t Nx_len;
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700312 u8 Lx[DPP_MAX_SHARED_SECRET_LEN];
Roshan Pius3a1667e2018-07-03 15:17:14 -0700313 size_t Lx_len;
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700314 u8 k1[DPP_MAX_HASH_LEN];
315 u8 k2[DPP_MAX_HASH_LEN];
316 u8 ke[DPP_MAX_HASH_LEN];
Hai Shalom4fbc08f2020-05-18 12:37:00 -0700317 u8 bk[DPP_MAX_HASH_LEN];
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700318 int initiator;
Roshan Pius3a1667e2018-07-03 15:17:14 -0700319 int waiting_auth_resp;
320 int waiting_auth_conf;
321 int auth_req_ack;
322 unsigned int auth_resp_tries;
323 u8 allowed_roles;
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700324 int configurator;
325 int remove_on_tx_status;
Hai Shalom021b0b52019-04-10 11:17:58 -0700326 int connect_on_tx_status;
327 int waiting_conf_result;
Hai Shalomc3565922019-10-28 11:58:20 -0700328 int waiting_conn_status_result;
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700329 int auth_success;
Hai Shalom4fbc08f2020-05-18 12:37:00 -0700330 bool reconfig_success;
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700331 struct wpabuf *conf_req;
Roshan Pius3a1667e2018-07-03 15:17:14 -0700332 const struct wpabuf *conf_resp; /* owned by GAS server */
Hai Shalom899fcc72020-10-19 14:38:18 -0700333 struct wpabuf *conf_resp_tcp;
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700334 struct dpp_configuration *conf_ap;
Hai Shalomc3565922019-10-28 11:58:20 -0700335 struct dpp_configuration *conf2_ap;
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700336 struct dpp_configuration *conf_sta;
Hai Shalomc3565922019-10-28 11:58:20 -0700337 struct dpp_configuration *conf2_sta;
Hai Shalomfdcde762020-04-02 11:19:20 -0700338 int provision_configurator;
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700339 struct dpp_configurator *conf;
Hai Shalomc3565922019-10-28 11:58:20 -0700340 struct dpp_config_obj {
341 char *connector; /* received signedConnector */
342 u8 ssid[SSID_MAX_LEN];
343 u8 ssid_len;
Ahmed ElArabawy0ff61c52019-12-26 12:38:39 -0800344 int ssid_charset;
Hai Shalomc3565922019-10-28 11:58:20 -0700345 char passphrase[64];
346 u8 psk[PMK_LEN];
347 int psk_set;
348 enum dpp_akm akm;
349 struct wpabuf *c_sign_key;
Hai Shalom899fcc72020-10-19 14:38:18 -0700350 struct wpabuf *certbag;
351 struct wpabuf *certs;
352 struct wpabuf *cacert;
353 char *server_name;
354 struct wpabuf *pp_key;
Hai Shalomc3565922019-10-28 11:58:20 -0700355 } conf_obj[DPP_MAX_CONF_OBJ];
356 unsigned int num_conf_obj;
Hai Shalomfdcde762020-04-02 11:19:20 -0700357 struct dpp_asymmetric_key *conf_key_pkg;
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700358 struct wpabuf *net_access_key;
359 os_time_t net_access_key_expiry;
Hai Shalomc3565922019-10-28 11:58:20 -0700360 int send_conn_status;
361 int conn_status_requested;
362 int akm_use_selector;
Hai Shalomfdcde762020-04-02 11:19:20 -0700363 int configurator_set;
Hai Shalom4fbc08f2020-05-18 12:37:00 -0700364 u8 transaction_id;
Hai Shalom899fcc72020-10-19 14:38:18 -0700365 u8 *csrattrs;
366 size_t csrattrs_len;
367 bool waiting_csr;
368 struct wpabuf *csr;
369 struct wpabuf *priv_key; /* DER-encoded private key used for csr */
370 bool waiting_cert;
371 char *trusted_eap_server_name;
372 struct wpabuf *cacert;
373 struct wpabuf *certbag;
Sunil Ravia04bd252022-05-02 22:54:18 -0700374 bool waiting_new_key;
375 bool new_key_received;
Hai Shaloma20dcd72022-02-04 13:43:00 -0800376 void *config_resp_ctx;
Hai Shalom60840252021-02-19 19:02:11 -0800377 void *gas_server_ctx;
Hai Shaloma20dcd72022-02-04 13:43:00 -0800378 bool use_config_query;
379 bool waiting_config;
380 char *e_name;
381 char *e_mud_url;
382 int *e_band_support;
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700383#ifdef CONFIG_TESTING_OPTIONS
384 char *config_obj_override;
385 char *discovery_override;
386 char *groups_override;
387 unsigned int ignore_netaccesskey_mismatch:1;
388#endif /* CONFIG_TESTING_OPTIONS */
Hai Shalom06768112019-12-04 15:49:43 -0800389 unsigned short band_list[DPP_MAX_CHANNELS];
390 int band_list_size;
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700391};
392
393struct dpp_configurator {
394 struct dl_list list;
395 unsigned int id;
396 int own;
Hai Shaloma20dcd72022-02-04 13:43:00 -0800397 struct crypto_ec_key *csign;
Hai Shalom4fbc08f2020-05-18 12:37:00 -0700398 u8 kid_hash[SHA256_MAC_LEN];
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700399 char *kid;
400 const struct dpp_curve_params *curve;
Sunil Ravia04bd252022-05-02 22:54:18 -0700401 const struct dpp_curve_params *net_access_key_curve;
Hai Shalom4fbc08f2020-05-18 12:37:00 -0700402 char *connector; /* own Connector for reconfiguration */
Hai Shaloma20dcd72022-02-04 13:43:00 -0800403 struct crypto_ec_key *connector_key;
404 struct crypto_ec_key *pp_key;
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700405};
406
407struct dpp_introduction {
408 u8 pmkid[PMKID_LEN];
409 u8 pmk[PMK_LEN_MAX];
410 size_t pmk_len;
Hai Shaloma20dcd72022-02-04 13:43:00 -0800411 int peer_version;
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700412};
413
Hai Shalom81f62d82019-07-22 12:10:00 -0700414struct dpp_relay_config {
415 const struct hostapd_ip_addr *ipaddr;
416 const u8 *pkhash;
417
Hai Shalom899fcc72020-10-19 14:38:18 -0700418 void *msg_ctx;
Hai Shalom81f62d82019-07-22 12:10:00 -0700419 void *cb_ctx;
420 void (*tx)(void *ctx, const u8 *addr, unsigned int freq, const u8 *msg,
421 size_t len);
422 void (*gas_resp_tx)(void *ctx, const u8 *addr, u8 dialog_token, int prot,
423 struct wpabuf *buf);
424};
425
426struct dpp_controller_config {
427 const char *configurator_params;
428 int tcp_port;
Hai Shalom4fbc08f2020-05-18 12:37:00 -0700429 u8 allowed_roles;
Hai Shalom899fcc72020-10-19 14:38:18 -0700430 int qr_mutual;
431 enum dpp_netrole netrole;
432 void *msg_ctx;
433 void *cb_ctx;
434 int (*process_conf_obj)(void *ctx, struct dpp_authentication *auth);
Hai Shaloma20dcd72022-02-04 13:43:00 -0800435 bool (*tcp_msg_sent)(void *ctx, struct dpp_authentication *auth);
Hai Shalom81f62d82019-07-22 12:10:00 -0700436};
437
Roshan Pius3a1667e2018-07-03 15:17:14 -0700438#ifdef CONFIG_TESTING_OPTIONS
439enum dpp_test_behavior {
440 DPP_TEST_DISABLED = 0,
441 DPP_TEST_AFTER_WRAPPED_DATA_AUTH_REQ = 1,
442 DPP_TEST_AFTER_WRAPPED_DATA_AUTH_RESP = 2,
443 DPP_TEST_AFTER_WRAPPED_DATA_AUTH_CONF = 3,
444 DPP_TEST_AFTER_WRAPPED_DATA_PKEX_CR_REQ = 4,
445 DPP_TEST_AFTER_WRAPPED_DATA_PKEX_CR_RESP = 5,
446 DPP_TEST_AFTER_WRAPPED_DATA_CONF_REQ = 6,
447 DPP_TEST_AFTER_WRAPPED_DATA_CONF_RESP = 7,
448 DPP_TEST_ZERO_I_CAPAB = 8,
449 DPP_TEST_ZERO_R_CAPAB = 9,
450 DPP_TEST_NO_R_BOOTSTRAP_KEY_HASH_AUTH_REQ = 10,
451 DPP_TEST_NO_I_BOOTSTRAP_KEY_HASH_AUTH_REQ = 11,
452 DPP_TEST_NO_I_PROTO_KEY_AUTH_REQ = 12,
453 DPP_TEST_NO_I_NONCE_AUTH_REQ = 13,
454 DPP_TEST_NO_I_CAPAB_AUTH_REQ = 14,
455 DPP_TEST_NO_WRAPPED_DATA_AUTH_REQ = 15,
456 DPP_TEST_NO_STATUS_AUTH_RESP = 16,
457 DPP_TEST_NO_R_BOOTSTRAP_KEY_HASH_AUTH_RESP = 17,
458 DPP_TEST_NO_I_BOOTSTRAP_KEY_HASH_AUTH_RESP = 18,
459 DPP_TEST_NO_R_PROTO_KEY_AUTH_RESP = 19,
460 DPP_TEST_NO_R_NONCE_AUTH_RESP = 20,
461 DPP_TEST_NO_I_NONCE_AUTH_RESP = 21,
462 DPP_TEST_NO_R_CAPAB_AUTH_RESP = 22,
463 DPP_TEST_NO_R_AUTH_AUTH_RESP = 23,
464 DPP_TEST_NO_WRAPPED_DATA_AUTH_RESP = 24,
465 DPP_TEST_NO_STATUS_AUTH_CONF = 25,
466 DPP_TEST_NO_R_BOOTSTRAP_KEY_HASH_AUTH_CONF = 26,
467 DPP_TEST_NO_I_BOOTSTRAP_KEY_HASH_AUTH_CONF = 27,
468 DPP_TEST_NO_I_AUTH_AUTH_CONF = 28,
469 DPP_TEST_NO_WRAPPED_DATA_AUTH_CONF = 29,
470 DPP_TEST_I_NONCE_MISMATCH_AUTH_RESP = 30,
471 DPP_TEST_INCOMPATIBLE_R_CAPAB_AUTH_RESP = 31,
472 DPP_TEST_R_AUTH_MISMATCH_AUTH_RESP = 32,
473 DPP_TEST_I_AUTH_MISMATCH_AUTH_CONF = 33,
474 DPP_TEST_NO_FINITE_CYCLIC_GROUP_PKEX_EXCHANGE_REQ = 34,
475 DPP_TEST_NO_ENCRYPTED_KEY_PKEX_EXCHANGE_REQ = 35,
476 DPP_TEST_NO_STATUS_PKEX_EXCHANGE_RESP = 36,
477 DPP_TEST_NO_ENCRYPTED_KEY_PKEX_EXCHANGE_RESP = 37,
478 DPP_TEST_NO_BOOTSTRAP_KEY_PKEX_CR_REQ = 38,
479 DPP_TEST_NO_I_AUTH_TAG_PKEX_CR_REQ = 39,
480 DPP_TEST_NO_WRAPPED_DATA_PKEX_CR_REQ = 40,
481 DPP_TEST_NO_BOOTSTRAP_KEY_PKEX_CR_RESP = 41,
482 DPP_TEST_NO_R_AUTH_TAG_PKEX_CR_RESP = 42,
483 DPP_TEST_NO_WRAPPED_DATA_PKEX_CR_RESP = 43,
484 DPP_TEST_INVALID_ENCRYPTED_KEY_PKEX_EXCHANGE_REQ = 44,
485 DPP_TEST_INVALID_ENCRYPTED_KEY_PKEX_EXCHANGE_RESP = 45,
486 DPP_TEST_INVALID_STATUS_PKEX_EXCHANGE_RESP = 46,
487 DPP_TEST_INVALID_BOOTSTRAP_KEY_PKEX_CR_REQ = 47,
488 DPP_TEST_INVALID_BOOTSTRAP_KEY_PKEX_CR_RESP = 48,
489 DPP_TEST_I_AUTH_TAG_MISMATCH_PKEX_CR_REQ = 49,
490 DPP_TEST_R_AUTH_TAG_MISMATCH_PKEX_CR_RESP = 50,
491 DPP_TEST_NO_E_NONCE_CONF_REQ = 51,
492 DPP_TEST_NO_CONFIG_ATTR_OBJ_CONF_REQ = 52,
493 DPP_TEST_NO_WRAPPED_DATA_CONF_REQ = 53,
494 DPP_TEST_NO_E_NONCE_CONF_RESP = 54,
495 DPP_TEST_NO_CONFIG_OBJ_CONF_RESP = 55,
496 DPP_TEST_NO_STATUS_CONF_RESP = 56,
497 DPP_TEST_NO_WRAPPED_DATA_CONF_RESP = 57,
498 DPP_TEST_INVALID_STATUS_CONF_RESP = 58,
499 DPP_TEST_E_NONCE_MISMATCH_CONF_RESP = 59,
500 DPP_TEST_NO_TRANSACTION_ID_PEER_DISC_REQ = 60,
501 DPP_TEST_NO_CONNECTOR_PEER_DISC_REQ = 61,
502 DPP_TEST_NO_TRANSACTION_ID_PEER_DISC_RESP = 62,
503 DPP_TEST_NO_STATUS_PEER_DISC_RESP = 63,
504 DPP_TEST_NO_CONNECTOR_PEER_DISC_RESP = 64,
505 DPP_TEST_AUTH_RESP_IN_PLACE_OF_CONF = 65,
506 DPP_TEST_INVALID_I_PROTO_KEY_AUTH_REQ = 66,
507 DPP_TEST_INVALID_R_PROTO_KEY_AUTH_RESP = 67,
508 DPP_TEST_INVALID_R_BOOTSTRAP_KEY_HASH_AUTH_REQ = 68,
509 DPP_TEST_INVALID_I_BOOTSTRAP_KEY_HASH_AUTH_REQ = 69,
510 DPP_TEST_INVALID_R_BOOTSTRAP_KEY_HASH_AUTH_RESP = 70,
511 DPP_TEST_INVALID_I_BOOTSTRAP_KEY_HASH_AUTH_RESP = 71,
512 DPP_TEST_INVALID_R_BOOTSTRAP_KEY_HASH_AUTH_CONF = 72,
513 DPP_TEST_INVALID_I_BOOTSTRAP_KEY_HASH_AUTH_CONF = 73,
514 DPP_TEST_INVALID_STATUS_AUTH_RESP = 74,
515 DPP_TEST_INVALID_STATUS_AUTH_CONF = 75,
516 DPP_TEST_INVALID_CONFIG_ATTR_OBJ_CONF_REQ = 76,
517 DPP_TEST_INVALID_TRANSACTION_ID_PEER_DISC_RESP = 77,
518 DPP_TEST_INVALID_STATUS_PEER_DISC_RESP = 78,
519 DPP_TEST_INVALID_CONNECTOR_PEER_DISC_RESP = 79,
520 DPP_TEST_INVALID_CONNECTOR_PEER_DISC_REQ = 80,
521 DPP_TEST_INVALID_I_NONCE_AUTH_REQ = 81,
522 DPP_TEST_INVALID_TRANSACTION_ID_PEER_DISC_REQ = 82,
523 DPP_TEST_INVALID_E_NONCE_CONF_REQ = 83,
524 DPP_TEST_STOP_AT_PKEX_EXCHANGE_RESP = 84,
525 DPP_TEST_STOP_AT_PKEX_CR_REQ = 85,
526 DPP_TEST_STOP_AT_PKEX_CR_RESP = 86,
527 DPP_TEST_STOP_AT_AUTH_REQ = 87,
528 DPP_TEST_STOP_AT_AUTH_RESP = 88,
529 DPP_TEST_STOP_AT_AUTH_CONF = 89,
530 DPP_TEST_STOP_AT_CONF_REQ = 90,
Hai Shalom021b0b52019-04-10 11:17:58 -0700531 DPP_TEST_REJECT_CONFIG = 91,
Hai Shaloma20dcd72022-02-04 13:43:00 -0800532 DPP_TEST_NO_PROTOCOL_VERSION_PEER_DISC_REQ = 92,
533 DPP_TEST_NO_PROTOCOL_VERSION_PEER_DISC_RESP = 93,
534 DPP_TEST_INVALID_PROTOCOL_VERSION_PEER_DISC_REQ = 94,
535 DPP_TEST_INVALID_PROTOCOL_VERSION_PEER_DISC_RESP = 95,
Sunil Ravia04bd252022-05-02 22:54:18 -0700536 DPP_TEST_INVALID_PROTOCOL_VERSION_RECONFIG_AUTH_REQ = 96,
537 DPP_TEST_NO_PROTOCOL_VERSION_RECONFIG_AUTH_REQ = 97,
Roshan Pius3a1667e2018-07-03 15:17:14 -0700538};
539
540extern enum dpp_test_behavior dpp_test;
541extern u8 dpp_pkex_own_mac_override[ETH_ALEN];
542extern u8 dpp_pkex_peer_mac_override[ETH_ALEN];
543extern u8 dpp_pkex_ephemeral_key_override[600];
544extern size_t dpp_pkex_ephemeral_key_override_len;
545extern u8 dpp_protocol_key_override[600];
546extern size_t dpp_protocol_key_override_len;
547extern u8 dpp_nonce_override[DPP_MAX_NONCE_LEN];
548extern size_t dpp_nonce_override_len;
549#endif /* CONFIG_TESTING_OPTIONS */
550
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700551void dpp_bootstrap_info_free(struct dpp_bootstrap_info *info);
552const char * dpp_bootstrap_type_txt(enum dpp_bootstrap_type type);
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700553int dpp_parse_uri_chan_list(struct dpp_bootstrap_info *bi,
554 const char *chan_list);
555int dpp_parse_uri_mac(struct dpp_bootstrap_info *bi, const char *mac);
556int dpp_parse_uri_info(struct dpp_bootstrap_info *bi, const char *info);
Hai Shalomfdcde762020-04-02 11:19:20 -0700557int dpp_nfc_update_bi(struct dpp_bootstrap_info *own_bi,
558 struct dpp_bootstrap_info *peer_bi);
Hai Shaloma20dcd72022-02-04 13:43:00 -0800559const char * dpp_netrole_str(enum dpp_netrole netrole);
Hai Shalomfdcde762020-04-02 11:19:20 -0700560struct dpp_authentication *
561dpp_alloc_auth(struct dpp_global *dpp, void *msg_ctx);
Roshan Pius3a1667e2018-07-03 15:17:14 -0700562struct hostapd_hw_modes;
Hai Shalomfdcde762020-04-02 11:19:20 -0700563struct dpp_authentication * dpp_auth_init(struct dpp_global *dpp, void *msg_ctx,
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700564 struct dpp_bootstrap_info *peer_bi,
565 struct dpp_bootstrap_info *own_bi,
Roshan Pius3a1667e2018-07-03 15:17:14 -0700566 u8 dpp_allowed_roles,
567 unsigned int neg_freq,
568 struct hostapd_hw_modes *own_modes,
569 u16 num_modes);
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700570struct dpp_authentication *
Hai Shalomfdcde762020-04-02 11:19:20 -0700571dpp_auth_req_rx(struct dpp_global *dpp, void *msg_ctx, u8 dpp_allowed_roles,
572 int qr_mutual, struct dpp_bootstrap_info *peer_bi,
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700573 struct dpp_bootstrap_info *own_bi,
574 unsigned int freq, const u8 *hdr, const u8 *attr_start,
Roshan Pius3a1667e2018-07-03 15:17:14 -0700575 size_t attr_len);
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700576struct wpabuf *
577dpp_auth_resp_rx(struct dpp_authentication *auth, const u8 *hdr,
578 const u8 *attr_start, size_t attr_len);
579struct wpabuf * dpp_build_conf_req(struct dpp_authentication *auth,
580 const char *json);
Hai Shalomc3565922019-10-28 11:58:20 -0700581struct wpabuf * dpp_build_conf_req_helper(struct dpp_authentication *auth,
Ahmed ElArabawy0ff61c52019-12-26 12:38:39 -0800582 const char *name,
583 enum dpp_netrole netrole,
Hai Shalomc3565922019-10-28 11:58:20 -0700584 const char *mud_url, int *opclasses);
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700585int dpp_auth_conf_rx(struct dpp_authentication *auth, const u8 *hdr,
586 const u8 *attr_start, size_t attr_len);
587int dpp_notify_new_qr_code(struct dpp_authentication *auth,
588 struct dpp_bootstrap_info *peer_bi);
Hai Shaloma20dcd72022-02-04 13:43:00 -0800589void dpp_controller_pkex_add(struct dpp_global *dpp,
590 struct dpp_bootstrap_info *bi,
591 const char *code, const char *identifier);
Hai Shalom021b0b52019-04-10 11:17:58 -0700592struct dpp_configuration * dpp_configuration_alloc(const char *type);
593int dpp_akm_psk(enum dpp_akm akm);
594int dpp_akm_sae(enum dpp_akm akm);
595int dpp_akm_legacy(enum dpp_akm akm);
596int dpp_akm_dpp(enum dpp_akm akm);
597int dpp_akm_ver2(enum dpp_akm akm);
598int dpp_configuration_valid(const struct dpp_configuration *conf);
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700599void dpp_configuration_free(struct dpp_configuration *conf);
Hai Shalomfdcde762020-04-02 11:19:20 -0700600int dpp_set_configurator(struct dpp_authentication *auth, const char *cmd);
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700601void dpp_auth_deinit(struct dpp_authentication *auth);
602struct wpabuf *
Hai Shalom899fcc72020-10-19 14:38:18 -0700603dpp_build_conf_resp(struct dpp_authentication *auth, const u8 *e_nonce,
604 u16 e_nonce_len, enum dpp_netrole netrole,
605 bool cert_req);
606struct wpabuf *
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700607dpp_conf_req_rx(struct dpp_authentication *auth, const u8 *attr_start,
608 size_t attr_len);
609int dpp_conf_resp_rx(struct dpp_authentication *auth,
610 const struct wpabuf *resp);
Hai Shalom021b0b52019-04-10 11:17:58 -0700611enum dpp_status_error dpp_conf_result_rx(struct dpp_authentication *auth,
612 const u8 *hdr,
613 const u8 *attr_start, size_t attr_len);
614struct wpabuf * dpp_build_conf_result(struct dpp_authentication *auth,
615 enum dpp_status_error status);
Hai Shalomc3565922019-10-28 11:58:20 -0700616enum dpp_status_error dpp_conn_status_result_rx(struct dpp_authentication *auth,
617 const u8 *hdr,
618 const u8 *attr_start,
619 size_t attr_len,
620 u8 *ssid, size_t *ssid_len,
621 char **channel_list);
622struct wpabuf * dpp_build_conn_status_result(struct dpp_authentication *auth,
623 enum dpp_status_error result,
624 const u8 *ssid, size_t ssid_len,
625 const char *channel_list);
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700626struct wpabuf * dpp_alloc_msg(enum dpp_public_action_frame_type type,
627 size_t len);
628const u8 * dpp_get_attr(const u8 *buf, size_t len, u16 req_id, u16 *ret_len);
629int dpp_check_attrs(const u8 *buf, size_t len);
630int dpp_key_expired(const char *timestamp, os_time_t *expiry);
Roshan Pius3a1667e2018-07-03 15:17:14 -0700631const char * dpp_akm_str(enum dpp_akm akm);
Hai Shalomc3565922019-10-28 11:58:20 -0700632const char * dpp_akm_selector_str(enum dpp_akm akm);
Roshan Pius3a1667e2018-07-03 15:17:14 -0700633int dpp_configurator_get_key(const struct dpp_configurator *conf, char *buf,
634 size_t buflen);
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700635void dpp_configurator_free(struct dpp_configurator *conf);
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700636int dpp_configurator_own_config(struct dpp_authentication *auth,
Roshan Pius3a1667e2018-07-03 15:17:14 -0700637 const char *curve, int ap);
638enum dpp_status_error
639dpp_peer_intro(struct dpp_introduction *intro, const char *own_connector,
640 const u8 *net_access_key, size_t net_access_key_len,
641 const u8 *csign_key, size_t csign_key_len,
642 const u8 *peer_connector, size_t peer_connector_len,
643 os_time_t *expiry);
Hai Shaloma20dcd72022-02-04 13:43:00 -0800644int dpp_get_connector_version(const char *connector);
Roshan Pius3a1667e2018-07-03 15:17:14 -0700645struct dpp_pkex * dpp_pkex_init(void *msg_ctx, struct dpp_bootstrap_info *bi,
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700646 const u8 *own_mac,
Hai Shaloma20dcd72022-02-04 13:43:00 -0800647 const char *identifier, const char *code,
648 bool v2);
Roshan Pius3a1667e2018-07-03 15:17:14 -0700649struct dpp_pkex * dpp_pkex_rx_exchange_req(void *msg_ctx,
650 struct dpp_bootstrap_info *bi,
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700651 const u8 *own_mac,
652 const u8 *peer_mac,
653 const char *identifier,
654 const char *code,
Hai Shaloma20dcd72022-02-04 13:43:00 -0800655 const u8 *buf, size_t len, bool v2);
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700656struct wpabuf * dpp_pkex_rx_exchange_resp(struct dpp_pkex *pkex,
Roshan Pius3a1667e2018-07-03 15:17:14 -0700657 const u8 *peer_mac,
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700658 const u8 *buf, size_t len);
659struct wpabuf * dpp_pkex_rx_commit_reveal_req(struct dpp_pkex *pkex,
660 const u8 *hdr,
661 const u8 *buf, size_t len);
662int dpp_pkex_rx_commit_reveal_resp(struct dpp_pkex *pkex, const u8 *hdr,
663 const u8 *buf, size_t len);
664void dpp_pkex_free(struct dpp_pkex *pkex);
665
Roshan Pius3a1667e2018-07-03 15:17:14 -0700666char * dpp_corrupt_connector_signature(const char *connector);
667
Hai Shalom021b0b52019-04-10 11:17:58 -0700668
669struct dpp_pfs {
670 struct crypto_ecdh *ecdh;
671 const struct dpp_curve_params *curve;
672 struct wpabuf *ie;
673 struct wpabuf *secret;
674};
675
676struct dpp_pfs * dpp_pfs_init(const u8 *net_access_key,
677 size_t net_access_key_len);
678int dpp_pfs_process(struct dpp_pfs *pfs, const u8 *peer_ie, size_t peer_ie_len);
679void dpp_pfs_free(struct dpp_pfs *pfs);
680
Hai Shalom899fcc72020-10-19 14:38:18 -0700681struct wpabuf * dpp_build_csr(struct dpp_authentication *auth,
682 const char *name);
Hai Shalom899fcc72020-10-19 14:38:18 -0700683int dpp_validate_csr(struct dpp_authentication *auth, const struct wpabuf *csr);
684
Hai Shalom021b0b52019-04-10 11:17:58 -0700685struct dpp_bootstrap_info * dpp_add_qr_code(struct dpp_global *dpp,
686 const char *uri);
Ahmed ElArabawy0ff61c52019-12-26 12:38:39 -0800687struct dpp_bootstrap_info * dpp_add_nfc_uri(struct dpp_global *dpp,
688 const char *uri);
Hai Shalom021b0b52019-04-10 11:17:58 -0700689int dpp_bootstrap_gen(struct dpp_global *dpp, const char *cmd);
690struct dpp_bootstrap_info *
691dpp_bootstrap_get_id(struct dpp_global *dpp, unsigned int id);
692int dpp_bootstrap_remove(struct dpp_global *dpp, const char *id);
693struct dpp_bootstrap_info *
694dpp_pkex_finish(struct dpp_global *dpp, struct dpp_pkex *pkex, const u8 *peer,
695 unsigned int freq);
696const char * dpp_bootstrap_get_uri(struct dpp_global *dpp, unsigned int id);
697int dpp_bootstrap_info(struct dpp_global *dpp, int id,
698 char *reply, int reply_size);
Hai Shalomfdcde762020-04-02 11:19:20 -0700699int dpp_bootstrap_set(struct dpp_global *dpp, int id, const char *params);
Hai Shalom021b0b52019-04-10 11:17:58 -0700700void dpp_bootstrap_find_pair(struct dpp_global *dpp, const u8 *i_bootstrap,
701 const u8 *r_bootstrap,
702 struct dpp_bootstrap_info **own_bi,
703 struct dpp_bootstrap_info **peer_bi);
Hai Shalomfdcde762020-04-02 11:19:20 -0700704struct dpp_bootstrap_info * dpp_bootstrap_find_chirp(struct dpp_global *dpp,
705 const u8 *hash);
Hai Shalom021b0b52019-04-10 11:17:58 -0700706int dpp_configurator_add(struct dpp_global *dpp, const char *cmd);
Sunil Ravia04bd252022-05-02 22:54:18 -0700707int dpp_configurator_set(struct dpp_global *dpp, const char *cmd);
Hai Shalom021b0b52019-04-10 11:17:58 -0700708int dpp_configurator_remove(struct dpp_global *dpp, const char *id);
709int dpp_configurator_get_key_id(struct dpp_global *dpp, unsigned int id,
710 char *buf, size_t buflen);
Hai Shalomfdcde762020-04-02 11:19:20 -0700711int dpp_configurator_from_backup(struct dpp_global *dpp,
712 struct dpp_asymmetric_key *key);
Hai Shalom4fbc08f2020-05-18 12:37:00 -0700713struct dpp_configurator * dpp_configurator_find_kid(struct dpp_global *dpp,
714 const u8 *kid);
Hai Shalom81f62d82019-07-22 12:10:00 -0700715int dpp_relay_add_controller(struct dpp_global *dpp,
716 struct dpp_relay_config *config);
717int dpp_relay_rx_action(struct dpp_global *dpp, const u8 *src, const u8 *hdr,
718 const u8 *buf, size_t len, unsigned int freq,
Hai Shaloma20dcd72022-02-04 13:43:00 -0800719 const u8 *i_bootstrap, const u8 *r_bootstrap,
720 void *cb_ctx);
Hai Shalom81f62d82019-07-22 12:10:00 -0700721int dpp_relay_rx_gas_req(struct dpp_global *dpp, const u8 *src, const u8 *data,
722 size_t data_len);
723int dpp_controller_start(struct dpp_global *dpp,
724 struct dpp_controller_config *config);
Sunil Ravia04bd252022-05-02 22:54:18 -0700725int dpp_controller_set_params(struct dpp_global *dpp,
726 const char *configurator_params);
Hai Shalom81f62d82019-07-22 12:10:00 -0700727void dpp_controller_stop(struct dpp_global *dpp);
Hai Shaloma20dcd72022-02-04 13:43:00 -0800728void dpp_controller_stop_for_ctx(struct dpp_global *dpp, void *cb_ctx);
Hai Shalom899fcc72020-10-19 14:38:18 -0700729struct dpp_authentication * dpp_controller_get_auth(struct dpp_global *dpp,
730 unsigned int id);
731void dpp_controller_new_qr_code(struct dpp_global *dpp,
732 struct dpp_bootstrap_info *bi);
Hai Shaloma20dcd72022-02-04 13:43:00 -0800733int dpp_tcp_pkex_init(struct dpp_global *dpp, struct dpp_pkex *pkex,
734 const struct hostapd_ip_addr *addr, int port,
735 void *msg_ctx, void *cb_ctx,
736 int (*pkex_done)(void *ctx, void *conn,
737 struct dpp_bootstrap_info *bi));
Hai Shalom81f62d82019-07-22 12:10:00 -0700738int dpp_tcp_init(struct dpp_global *dpp, struct dpp_authentication *auth,
Hai Shalom899fcc72020-10-19 14:38:18 -0700739 const struct hostapd_ip_addr *addr, int port,
740 const char *name, enum dpp_netrole netrole, void *msg_ctx,
741 void *cb_ctx,
742 int (*process_conf_obj)(void *ctx,
Hai Shaloma20dcd72022-02-04 13:43:00 -0800743 struct dpp_authentication *auth),
744 bool (*tcp_msg_sent)(void *ctx,
745 struct dpp_authentication *auth));
746int dpp_tcp_auth(struct dpp_global *dpp, void *_conn,
747 struct dpp_authentication *auth, const char *name,
748 enum dpp_netrole netrole,
749 int (*process_conf_obj)(void *ctx,
750 struct dpp_authentication *auth),
751 bool (*tcp_msg_sent)(void *ctx,
752 struct dpp_authentication *auth));
753bool dpp_tcp_conn_status_requested(struct dpp_global *dpp);
754void dpp_tcp_send_conn_status(struct dpp_global *dpp,
755 enum dpp_status_error result,
756 const u8 *ssid, size_t ssid_len,
757 const char *channel_list);
Hai Shalom899fcc72020-10-19 14:38:18 -0700758
Hai Shalomfdcde762020-04-02 11:19:20 -0700759struct wpabuf * dpp_build_presence_announcement(struct dpp_bootstrap_info *bi);
Hai Shalom899fcc72020-10-19 14:38:18 -0700760void dpp_notify_chirp_received(void *msg_ctx, int id, const u8 *src,
761 unsigned int freq, const u8 *hash);
Hai Shalom81f62d82019-07-22 12:10:00 -0700762
763struct dpp_global_config {
Hai Shalom81f62d82019-07-22 12:10:00 -0700764 void *cb_ctx;
Hai Shalomfdcde762020-04-02 11:19:20 -0700765 void (*remove_bi)(void *ctx, struct dpp_bootstrap_info *bi);
Hai Shalom81f62d82019-07-22 12:10:00 -0700766};
767
768struct dpp_global * dpp_global_init(struct dpp_global_config *config);
Hai Shalom021b0b52019-04-10 11:17:58 -0700769void dpp_global_clear(struct dpp_global *dpp);
770void dpp_global_deinit(struct dpp_global *dpp);
771
Hai Shalom4fbc08f2020-05-18 12:37:00 -0700772/* dpp_reconfig.c */
773
774struct wpabuf * dpp_build_reconfig_announcement(const u8 *csign_key,
Hai Shalom899fcc72020-10-19 14:38:18 -0700775 size_t csign_key_len,
776 const u8 *net_access_key,
777 size_t net_access_key_len,
778 struct dpp_reconfig_id *id);
Hai Shalom4fbc08f2020-05-18 12:37:00 -0700779struct dpp_authentication *
780dpp_reconfig_init(struct dpp_global *dpp, void *msg_ctx,
Hai Shalom899fcc72020-10-19 14:38:18 -0700781 struct dpp_configurator *conf, unsigned int freq, u16 group,
782 const u8 *a_nonce_attr, size_t a_nonce_len,
783 const u8 *e_id_attr, size_t e_id_len);
Hai Shalom4fbc08f2020-05-18 12:37:00 -0700784struct dpp_authentication *
785dpp_reconfig_auth_req_rx(struct dpp_global *dpp, void *msg_ctx,
786 const char *own_connector,
787 const u8 *net_access_key, size_t net_access_key_len,
788 const u8 *csign_key, size_t csign_key_len,
789 unsigned int freq, const u8 *hdr,
790 const u8 *attr_start, size_t attr_len);
791struct wpabuf *
792dpp_reconfig_auth_resp_rx(struct dpp_authentication *auth, const u8 *hdr,
793 const u8 *attr_start, size_t attr_len);
794int dpp_reconfig_auth_conf_rx(struct dpp_authentication *auth, const u8 *hdr,
795 const u8 *attr_start, size_t attr_len);
796
Hai Shalom899fcc72020-10-19 14:38:18 -0700797struct dpp_reconfig_id * dpp_gen_reconfig_id(const u8 *csign_key,
798 size_t csign_key_len,
799 const u8 *pp_key,
800 size_t pp_key_len);
801int dpp_update_reconfig_id(struct dpp_reconfig_id *id);
802void dpp_free_reconfig_id(struct dpp_reconfig_id *id);
803
Hai Shalom021b0b52019-04-10 11:17:58 -0700804#endif /* CONFIG_DPP */
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700805#endif /* DPP_H */