blob: cb788ae46ee7816ff9f4e8ba9b705d1bcd984a1d [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 Shalom021b0b52019-04-10 11:17:58 -07004 * Copyright (c) 2018-2019, 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;
23
Dmitry Shmidtd2986c22017-10-23 14:22:09 -070024#define DPP_HDR_LEN (4 + 2) /* OUI, OUI Type, Crypto Suite, DPP frame type */
Hai Shalom81f62d82019-07-22 12:10:00 -070025#define DPP_TCP_PORT 7871
Dmitry Shmidtd2986c22017-10-23 14:22:09 -070026
27enum dpp_public_action_frame_type {
28 DPP_PA_AUTHENTICATION_REQ = 0,
29 DPP_PA_AUTHENTICATION_RESP = 1,
30 DPP_PA_AUTHENTICATION_CONF = 2,
31 DPP_PA_PEER_DISCOVERY_REQ = 5,
32 DPP_PA_PEER_DISCOVERY_RESP = 6,
33 DPP_PA_PKEX_EXCHANGE_REQ = 7,
34 DPP_PA_PKEX_EXCHANGE_RESP = 8,
35 DPP_PA_PKEX_COMMIT_REVEAL_REQ = 9,
36 DPP_PA_PKEX_COMMIT_REVEAL_RESP = 10,
Hai Shalom021b0b52019-04-10 11:17:58 -070037 DPP_PA_CONFIGURATION_RESULT = 11,
Hai Shalomc3565922019-10-28 11:58:20 -070038 DPP_PA_CONNECTION_STATUS_RESULT = 12,
Dmitry Shmidtd2986c22017-10-23 14:22:09 -070039};
40
41enum dpp_attribute_id {
42 DPP_ATTR_STATUS = 0x1000,
43 DPP_ATTR_I_BOOTSTRAP_KEY_HASH = 0x1001,
44 DPP_ATTR_R_BOOTSTRAP_KEY_HASH = 0x1002,
45 DPP_ATTR_I_PROTOCOL_KEY = 0x1003,
46 DPP_ATTR_WRAPPED_DATA = 0x1004,
47 DPP_ATTR_I_NONCE = 0x1005,
48 DPP_ATTR_I_CAPABILITIES = 0x1006,
49 DPP_ATTR_R_NONCE = 0x1007,
50 DPP_ATTR_R_CAPABILITIES = 0x1008,
51 DPP_ATTR_R_PROTOCOL_KEY = 0x1009,
52 DPP_ATTR_I_AUTH_TAG = 0x100A,
53 DPP_ATTR_R_AUTH_TAG = 0x100B,
54 DPP_ATTR_CONFIG_OBJ = 0x100C,
55 DPP_ATTR_CONNECTOR = 0x100D,
56 DPP_ATTR_CONFIG_ATTR_OBJ = 0x100E,
57 DPP_ATTR_BOOTSTRAP_KEY = 0x100F,
58 DPP_ATTR_OWN_NET_NK_HASH = 0x1011,
59 DPP_ATTR_FINITE_CYCLIC_GROUP = 0x1012,
60 DPP_ATTR_ENCRYPTED_KEY = 0x1013,
61 DPP_ATTR_ENROLLEE_NONCE = 0x1014,
62 DPP_ATTR_CODE_IDENTIFIER = 0x1015,
63 DPP_ATTR_TRANSACTION_ID = 0x1016,
Roshan Pius3a1667e2018-07-03 15:17:14 -070064 DPP_ATTR_BOOTSTRAP_INFO = 0x1017,
65 DPP_ATTR_CHANNEL = 0x1018,
Hai Shalom021b0b52019-04-10 11:17:58 -070066 DPP_ATTR_PROTOCOL_VERSION = 0x1019,
67 DPP_ATTR_ENVELOPED_DATA = 0x101A,
Hai Shalomc3565922019-10-28 11:58:20 -070068 DPP_ATTR_SEND_CONN_STATUS = 0x101B,
69 DPP_ATTR_CONN_STATUS = 0x101C,
Dmitry Shmidtd2986c22017-10-23 14:22:09 -070070};
71
72enum dpp_status_error {
73 DPP_STATUS_OK = 0,
74 DPP_STATUS_NOT_COMPATIBLE = 1,
75 DPP_STATUS_AUTH_FAILURE = 2,
76 DPP_STATUS_UNWRAP_FAILURE = 3,
77 DPP_STATUS_BAD_GROUP = 4,
78 DPP_STATUS_CONFIGURE_FAILURE = 5,
79 DPP_STATUS_RESPONSE_PENDING = 6,
Roshan Pius3a1667e2018-07-03 15:17:14 -070080 DPP_STATUS_INVALID_CONNECTOR = 7,
81 DPP_STATUS_NO_MATCH = 8,
Hai Shalom021b0b52019-04-10 11:17:58 -070082 DPP_STATUS_CONFIG_REJECTED = 9,
Hai Shalomc3565922019-10-28 11:58:20 -070083 DPP_STATUS_NO_AP = 10,
Dmitry Shmidtd2986c22017-10-23 14:22:09 -070084};
85
86#define DPP_CAPAB_ENROLLEE BIT(0)
87#define DPP_CAPAB_CONFIGURATOR BIT(1)
88#define DPP_CAPAB_ROLE_MASK (BIT(0) | BIT(1))
89
90#define DPP_BOOTSTRAP_MAX_FREQ 30
91#define DPP_MAX_NONCE_LEN 32
92#define DPP_MAX_HASH_LEN 64
93#define DPP_MAX_SHARED_SECRET_LEN 66
94
95struct dpp_curve_params {
96 const char *name;
97 size_t hash_len;
98 size_t aes_siv_key_len;
99 size_t nonce_len;
100 size_t prime_len;
101 const char *jwk_crv;
102 u16 ike_group;
103 const char *jws_alg;
104};
105
106enum dpp_bootstrap_type {
107 DPP_BOOTSTRAP_QR_CODE,
108 DPP_BOOTSTRAP_PKEX,
Ahmed ElArabawy0ff61c52019-12-26 12:38:39 -0800109 DPP_BOOTSTRAP_NFC_URI,
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700110};
111
112struct dpp_bootstrap_info {
113 struct dl_list list;
114 unsigned int id;
115 enum dpp_bootstrap_type type;
116 char *uri;
117 u8 mac_addr[ETH_ALEN];
118 char *info;
119 unsigned int freq[DPP_BOOTSTRAP_MAX_FREQ];
120 unsigned int num_freq;
121 int own;
122 EVP_PKEY *pubkey;
123 u8 pubkey_hash[SHA256_MAC_LEN];
124 const struct dpp_curve_params *curve;
Roshan Pius3a1667e2018-07-03 15:17:14 -0700125 unsigned int pkex_t; /* number of failures before dpp_pkex
126 * instantiation */
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700127};
128
Roshan Pius3a1667e2018-07-03 15:17:14 -0700129#define PKEX_COUNTER_T_LIMIT 5
130
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700131struct dpp_pkex {
Roshan Pius3a1667e2018-07-03 15:17:14 -0700132 void *msg_ctx;
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700133 unsigned int initiator:1;
134 unsigned int exchange_done:1;
Roshan Pius3a1667e2018-07-03 15:17:14 -0700135 unsigned int failed:1;
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700136 struct dpp_bootstrap_info *own_bi;
137 u8 own_mac[ETH_ALEN];
138 u8 peer_mac[ETH_ALEN];
139 char *identifier;
140 char *code;
141 EVP_PKEY *x;
142 EVP_PKEY *y;
143 u8 Mx[DPP_MAX_SHARED_SECRET_LEN];
144 u8 Nx[DPP_MAX_SHARED_SECRET_LEN];
145 u8 z[DPP_MAX_HASH_LEN];
146 EVP_PKEY *peer_bootstrap_key;
147 struct wpabuf *exchange_req;
148 struct wpabuf *exchange_resp;
Roshan Pius3a1667e2018-07-03 15:17:14 -0700149 unsigned int t; /* number of failures on code use */
150 unsigned int exch_req_wait_time;
151 unsigned int exch_req_tries;
152 unsigned int freq;
153};
154
155enum dpp_akm {
156 DPP_AKM_UNKNOWN,
157 DPP_AKM_DPP,
158 DPP_AKM_PSK,
159 DPP_AKM_SAE,
Hai Shalom021b0b52019-04-10 11:17:58 -0700160 DPP_AKM_PSK_SAE,
161 DPP_AKM_SAE_DPP,
162 DPP_AKM_PSK_SAE_DPP,
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700163};
164
Hai Shalomc3565922019-10-28 11:58:20 -0700165enum dpp_netrole {
166 DPP_NETROLE_STA,
167 DPP_NETROLE_AP,
Ahmed ElArabawy0ff61c52019-12-26 12:38:39 -0800168 DPP_NETROLE_CONFIGURATOR,
Hai Shalomc3565922019-10-28 11:58:20 -0700169};
170
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700171struct dpp_configuration {
172 u8 ssid[32];
173 size_t ssid_len;
Ahmed ElArabawy0ff61c52019-12-26 12:38:39 -0800174 int ssid_charset;
Roshan Pius3a1667e2018-07-03 15:17:14 -0700175 enum dpp_akm akm;
Hai Shalomc3565922019-10-28 11:58:20 -0700176 enum dpp_netrole netrole;
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700177
178 /* For DPP configuration (connector) */
179 os_time_t netaccesskey_expiry;
180
181 /* TODO: groups */
Hai Shalomce48b4a2018-09-05 11:41:35 -0700182 char *group_id;
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700183
184 /* For legacy configuration */
185 char *passphrase;
186 u8 psk[32];
Hai Shalom021b0b52019-04-10 11:17:58 -0700187 int psk_set;
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700188};
189
Hai Shalomc3565922019-10-28 11:58:20 -0700190#define DPP_MAX_CONF_OBJ 10
Hai Shalom06768112019-12-04 15:49:43 -0800191#define DPP_MAX_CHANNELS 32
Hai Shalomc3565922019-10-28 11:58:20 -0700192
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700193struct dpp_authentication {
194 void *msg_ctx;
Hai Shalom021b0b52019-04-10 11:17:58 -0700195 u8 peer_version;
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700196 const struct dpp_curve_params *curve;
197 struct dpp_bootstrap_info *peer_bi;
198 struct dpp_bootstrap_info *own_bi;
Roshan Pius3a1667e2018-07-03 15:17:14 -0700199 struct dpp_bootstrap_info *tmp_own_bi;
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700200 u8 waiting_pubkey_hash[SHA256_MAC_LEN];
201 int response_pending;
202 enum dpp_status_error auth_resp_status;
Hai Shalom021b0b52019-04-10 11:17:58 -0700203 enum dpp_status_error conf_resp_status;
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700204 u8 peer_mac_addr[ETH_ALEN];
205 u8 i_nonce[DPP_MAX_NONCE_LEN];
206 u8 r_nonce[DPP_MAX_NONCE_LEN];
207 u8 e_nonce[DPP_MAX_NONCE_LEN];
208 u8 i_capab;
209 u8 r_capab;
210 EVP_PKEY *own_protocol_key;
211 EVP_PKEY *peer_protocol_key;
212 struct wpabuf *req_msg;
213 struct wpabuf *resp_msg;
Roshan Pius3a1667e2018-07-03 15:17:14 -0700214 /* Intersection of possible frequencies for initiating DPP
215 * Authentication exchange */
216 unsigned int freq[DPP_BOOTSTRAP_MAX_FREQ];
217 unsigned int num_freq, freq_idx;
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700218 unsigned int curr_freq;
Roshan Pius3a1667e2018-07-03 15:17:14 -0700219 unsigned int neg_freq;
220 unsigned int num_freq_iters;
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700221 size_t secret_len;
222 u8 Mx[DPP_MAX_SHARED_SECRET_LEN];
Roshan Pius3a1667e2018-07-03 15:17:14 -0700223 size_t Mx_len;
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700224 u8 Nx[DPP_MAX_SHARED_SECRET_LEN];
Roshan Pius3a1667e2018-07-03 15:17:14 -0700225 size_t Nx_len;
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700226 u8 Lx[DPP_MAX_SHARED_SECRET_LEN];
Roshan Pius3a1667e2018-07-03 15:17:14 -0700227 size_t Lx_len;
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700228 u8 k1[DPP_MAX_HASH_LEN];
229 u8 k2[DPP_MAX_HASH_LEN];
230 u8 ke[DPP_MAX_HASH_LEN];
231 int initiator;
Roshan Pius3a1667e2018-07-03 15:17:14 -0700232 int waiting_auth_resp;
233 int waiting_auth_conf;
234 int auth_req_ack;
235 unsigned int auth_resp_tries;
236 u8 allowed_roles;
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700237 int configurator;
238 int remove_on_tx_status;
Hai Shalom021b0b52019-04-10 11:17:58 -0700239 int connect_on_tx_status;
240 int waiting_conf_result;
Hai Shalomc3565922019-10-28 11:58:20 -0700241 int waiting_conn_status_result;
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700242 int auth_success;
243 struct wpabuf *conf_req;
Roshan Pius3a1667e2018-07-03 15:17:14 -0700244 const struct wpabuf *conf_resp; /* owned by GAS server */
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700245 struct dpp_configuration *conf_ap;
Hai Shalomc3565922019-10-28 11:58:20 -0700246 struct dpp_configuration *conf2_ap;
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700247 struct dpp_configuration *conf_sta;
Hai Shalomc3565922019-10-28 11:58:20 -0700248 struct dpp_configuration *conf2_sta;
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700249 struct dpp_configurator *conf;
Hai Shalomc3565922019-10-28 11:58:20 -0700250 struct dpp_config_obj {
251 char *connector; /* received signedConnector */
252 u8 ssid[SSID_MAX_LEN];
253 u8 ssid_len;
Ahmed ElArabawy0ff61c52019-12-26 12:38:39 -0800254 int ssid_charset;
Hai Shalomc3565922019-10-28 11:58:20 -0700255 char passphrase[64];
256 u8 psk[PMK_LEN];
257 int psk_set;
258 enum dpp_akm akm;
259 struct wpabuf *c_sign_key;
260 } conf_obj[DPP_MAX_CONF_OBJ];
261 unsigned int num_conf_obj;
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700262 struct wpabuf *net_access_key;
263 os_time_t net_access_key_expiry;
Hai Shalomc3565922019-10-28 11:58:20 -0700264 int send_conn_status;
265 int conn_status_requested;
266 int akm_use_selector;
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700267#ifdef CONFIG_TESTING_OPTIONS
268 char *config_obj_override;
269 char *discovery_override;
270 char *groups_override;
271 unsigned int ignore_netaccesskey_mismatch:1;
272#endif /* CONFIG_TESTING_OPTIONS */
Hai Shalom06768112019-12-04 15:49:43 -0800273 unsigned short band_list[DPP_MAX_CHANNELS];
274 int band_list_size;
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700275};
276
277struct dpp_configurator {
278 struct dl_list list;
279 unsigned int id;
280 int own;
281 EVP_PKEY *csign;
282 char *kid;
283 const struct dpp_curve_params *curve;
284};
285
286struct dpp_introduction {
287 u8 pmkid[PMKID_LEN];
288 u8 pmk[PMK_LEN_MAX];
289 size_t pmk_len;
290};
291
Hai Shalom81f62d82019-07-22 12:10:00 -0700292struct dpp_relay_config {
293 const struct hostapd_ip_addr *ipaddr;
294 const u8 *pkhash;
295
296 void *cb_ctx;
297 void (*tx)(void *ctx, const u8 *addr, unsigned int freq, const u8 *msg,
298 size_t len);
299 void (*gas_resp_tx)(void *ctx, const u8 *addr, u8 dialog_token, int prot,
300 struct wpabuf *buf);
301};
302
303struct dpp_controller_config {
304 const char *configurator_params;
305 int tcp_port;
306};
307
Roshan Pius3a1667e2018-07-03 15:17:14 -0700308#ifdef CONFIG_TESTING_OPTIONS
309enum dpp_test_behavior {
310 DPP_TEST_DISABLED = 0,
311 DPP_TEST_AFTER_WRAPPED_DATA_AUTH_REQ = 1,
312 DPP_TEST_AFTER_WRAPPED_DATA_AUTH_RESP = 2,
313 DPP_TEST_AFTER_WRAPPED_DATA_AUTH_CONF = 3,
314 DPP_TEST_AFTER_WRAPPED_DATA_PKEX_CR_REQ = 4,
315 DPP_TEST_AFTER_WRAPPED_DATA_PKEX_CR_RESP = 5,
316 DPP_TEST_AFTER_WRAPPED_DATA_CONF_REQ = 6,
317 DPP_TEST_AFTER_WRAPPED_DATA_CONF_RESP = 7,
318 DPP_TEST_ZERO_I_CAPAB = 8,
319 DPP_TEST_ZERO_R_CAPAB = 9,
320 DPP_TEST_NO_R_BOOTSTRAP_KEY_HASH_AUTH_REQ = 10,
321 DPP_TEST_NO_I_BOOTSTRAP_KEY_HASH_AUTH_REQ = 11,
322 DPP_TEST_NO_I_PROTO_KEY_AUTH_REQ = 12,
323 DPP_TEST_NO_I_NONCE_AUTH_REQ = 13,
324 DPP_TEST_NO_I_CAPAB_AUTH_REQ = 14,
325 DPP_TEST_NO_WRAPPED_DATA_AUTH_REQ = 15,
326 DPP_TEST_NO_STATUS_AUTH_RESP = 16,
327 DPP_TEST_NO_R_BOOTSTRAP_KEY_HASH_AUTH_RESP = 17,
328 DPP_TEST_NO_I_BOOTSTRAP_KEY_HASH_AUTH_RESP = 18,
329 DPP_TEST_NO_R_PROTO_KEY_AUTH_RESP = 19,
330 DPP_TEST_NO_R_NONCE_AUTH_RESP = 20,
331 DPP_TEST_NO_I_NONCE_AUTH_RESP = 21,
332 DPP_TEST_NO_R_CAPAB_AUTH_RESP = 22,
333 DPP_TEST_NO_R_AUTH_AUTH_RESP = 23,
334 DPP_TEST_NO_WRAPPED_DATA_AUTH_RESP = 24,
335 DPP_TEST_NO_STATUS_AUTH_CONF = 25,
336 DPP_TEST_NO_R_BOOTSTRAP_KEY_HASH_AUTH_CONF = 26,
337 DPP_TEST_NO_I_BOOTSTRAP_KEY_HASH_AUTH_CONF = 27,
338 DPP_TEST_NO_I_AUTH_AUTH_CONF = 28,
339 DPP_TEST_NO_WRAPPED_DATA_AUTH_CONF = 29,
340 DPP_TEST_I_NONCE_MISMATCH_AUTH_RESP = 30,
341 DPP_TEST_INCOMPATIBLE_R_CAPAB_AUTH_RESP = 31,
342 DPP_TEST_R_AUTH_MISMATCH_AUTH_RESP = 32,
343 DPP_TEST_I_AUTH_MISMATCH_AUTH_CONF = 33,
344 DPP_TEST_NO_FINITE_CYCLIC_GROUP_PKEX_EXCHANGE_REQ = 34,
345 DPP_TEST_NO_ENCRYPTED_KEY_PKEX_EXCHANGE_REQ = 35,
346 DPP_TEST_NO_STATUS_PKEX_EXCHANGE_RESP = 36,
347 DPP_TEST_NO_ENCRYPTED_KEY_PKEX_EXCHANGE_RESP = 37,
348 DPP_TEST_NO_BOOTSTRAP_KEY_PKEX_CR_REQ = 38,
349 DPP_TEST_NO_I_AUTH_TAG_PKEX_CR_REQ = 39,
350 DPP_TEST_NO_WRAPPED_DATA_PKEX_CR_REQ = 40,
351 DPP_TEST_NO_BOOTSTRAP_KEY_PKEX_CR_RESP = 41,
352 DPP_TEST_NO_R_AUTH_TAG_PKEX_CR_RESP = 42,
353 DPP_TEST_NO_WRAPPED_DATA_PKEX_CR_RESP = 43,
354 DPP_TEST_INVALID_ENCRYPTED_KEY_PKEX_EXCHANGE_REQ = 44,
355 DPP_TEST_INVALID_ENCRYPTED_KEY_PKEX_EXCHANGE_RESP = 45,
356 DPP_TEST_INVALID_STATUS_PKEX_EXCHANGE_RESP = 46,
357 DPP_TEST_INVALID_BOOTSTRAP_KEY_PKEX_CR_REQ = 47,
358 DPP_TEST_INVALID_BOOTSTRAP_KEY_PKEX_CR_RESP = 48,
359 DPP_TEST_I_AUTH_TAG_MISMATCH_PKEX_CR_REQ = 49,
360 DPP_TEST_R_AUTH_TAG_MISMATCH_PKEX_CR_RESP = 50,
361 DPP_TEST_NO_E_NONCE_CONF_REQ = 51,
362 DPP_TEST_NO_CONFIG_ATTR_OBJ_CONF_REQ = 52,
363 DPP_TEST_NO_WRAPPED_DATA_CONF_REQ = 53,
364 DPP_TEST_NO_E_NONCE_CONF_RESP = 54,
365 DPP_TEST_NO_CONFIG_OBJ_CONF_RESP = 55,
366 DPP_TEST_NO_STATUS_CONF_RESP = 56,
367 DPP_TEST_NO_WRAPPED_DATA_CONF_RESP = 57,
368 DPP_TEST_INVALID_STATUS_CONF_RESP = 58,
369 DPP_TEST_E_NONCE_MISMATCH_CONF_RESP = 59,
370 DPP_TEST_NO_TRANSACTION_ID_PEER_DISC_REQ = 60,
371 DPP_TEST_NO_CONNECTOR_PEER_DISC_REQ = 61,
372 DPP_TEST_NO_TRANSACTION_ID_PEER_DISC_RESP = 62,
373 DPP_TEST_NO_STATUS_PEER_DISC_RESP = 63,
374 DPP_TEST_NO_CONNECTOR_PEER_DISC_RESP = 64,
375 DPP_TEST_AUTH_RESP_IN_PLACE_OF_CONF = 65,
376 DPP_TEST_INVALID_I_PROTO_KEY_AUTH_REQ = 66,
377 DPP_TEST_INVALID_R_PROTO_KEY_AUTH_RESP = 67,
378 DPP_TEST_INVALID_R_BOOTSTRAP_KEY_HASH_AUTH_REQ = 68,
379 DPP_TEST_INVALID_I_BOOTSTRAP_KEY_HASH_AUTH_REQ = 69,
380 DPP_TEST_INVALID_R_BOOTSTRAP_KEY_HASH_AUTH_RESP = 70,
381 DPP_TEST_INVALID_I_BOOTSTRAP_KEY_HASH_AUTH_RESP = 71,
382 DPP_TEST_INVALID_R_BOOTSTRAP_KEY_HASH_AUTH_CONF = 72,
383 DPP_TEST_INVALID_I_BOOTSTRAP_KEY_HASH_AUTH_CONF = 73,
384 DPP_TEST_INVALID_STATUS_AUTH_RESP = 74,
385 DPP_TEST_INVALID_STATUS_AUTH_CONF = 75,
386 DPP_TEST_INVALID_CONFIG_ATTR_OBJ_CONF_REQ = 76,
387 DPP_TEST_INVALID_TRANSACTION_ID_PEER_DISC_RESP = 77,
388 DPP_TEST_INVALID_STATUS_PEER_DISC_RESP = 78,
389 DPP_TEST_INVALID_CONNECTOR_PEER_DISC_RESP = 79,
390 DPP_TEST_INVALID_CONNECTOR_PEER_DISC_REQ = 80,
391 DPP_TEST_INVALID_I_NONCE_AUTH_REQ = 81,
392 DPP_TEST_INVALID_TRANSACTION_ID_PEER_DISC_REQ = 82,
393 DPP_TEST_INVALID_E_NONCE_CONF_REQ = 83,
394 DPP_TEST_STOP_AT_PKEX_EXCHANGE_RESP = 84,
395 DPP_TEST_STOP_AT_PKEX_CR_REQ = 85,
396 DPP_TEST_STOP_AT_PKEX_CR_RESP = 86,
397 DPP_TEST_STOP_AT_AUTH_REQ = 87,
398 DPP_TEST_STOP_AT_AUTH_RESP = 88,
399 DPP_TEST_STOP_AT_AUTH_CONF = 89,
400 DPP_TEST_STOP_AT_CONF_REQ = 90,
Hai Shalom021b0b52019-04-10 11:17:58 -0700401 DPP_TEST_REJECT_CONFIG = 91,
Roshan Pius3a1667e2018-07-03 15:17:14 -0700402};
403
404extern enum dpp_test_behavior dpp_test;
405extern u8 dpp_pkex_own_mac_override[ETH_ALEN];
406extern u8 dpp_pkex_peer_mac_override[ETH_ALEN];
407extern u8 dpp_pkex_ephemeral_key_override[600];
408extern size_t dpp_pkex_ephemeral_key_override_len;
409extern u8 dpp_protocol_key_override[600];
410extern size_t dpp_protocol_key_override_len;
411extern u8 dpp_nonce_override[DPP_MAX_NONCE_LEN];
412extern size_t dpp_nonce_override_len;
413#endif /* CONFIG_TESTING_OPTIONS */
414
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700415void dpp_bootstrap_info_free(struct dpp_bootstrap_info *info);
416const char * dpp_bootstrap_type_txt(enum dpp_bootstrap_type type);
417int dpp_bootstrap_key_hash(struct dpp_bootstrap_info *bi);
418int dpp_parse_uri_chan_list(struct dpp_bootstrap_info *bi,
419 const char *chan_list);
420int dpp_parse_uri_mac(struct dpp_bootstrap_info *bi, const char *mac);
421int dpp_parse_uri_info(struct dpp_bootstrap_info *bi, const char *info);
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700422char * dpp_keygen(struct dpp_bootstrap_info *bi, const char *curve,
423 const u8 *privkey, size_t privkey_len);
Roshan Pius3a1667e2018-07-03 15:17:14 -0700424struct hostapd_hw_modes;
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700425struct dpp_authentication * dpp_auth_init(void *msg_ctx,
426 struct dpp_bootstrap_info *peer_bi,
427 struct dpp_bootstrap_info *own_bi,
Roshan Pius3a1667e2018-07-03 15:17:14 -0700428 u8 dpp_allowed_roles,
429 unsigned int neg_freq,
430 struct hostapd_hw_modes *own_modes,
431 u16 num_modes);
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700432struct dpp_authentication *
433dpp_auth_req_rx(void *msg_ctx, u8 dpp_allowed_roles, int qr_mutual,
434 struct dpp_bootstrap_info *peer_bi,
435 struct dpp_bootstrap_info *own_bi,
436 unsigned int freq, const u8 *hdr, const u8 *attr_start,
Roshan Pius3a1667e2018-07-03 15:17:14 -0700437 size_t attr_len);
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700438struct wpabuf *
439dpp_auth_resp_rx(struct dpp_authentication *auth, const u8 *hdr,
440 const u8 *attr_start, size_t attr_len);
441struct wpabuf * dpp_build_conf_req(struct dpp_authentication *auth,
442 const char *json);
Hai Shalomc3565922019-10-28 11:58:20 -0700443struct wpabuf * dpp_build_conf_req_helper(struct dpp_authentication *auth,
Ahmed ElArabawy0ff61c52019-12-26 12:38:39 -0800444 const char *name,
445 enum dpp_netrole netrole,
Hai Shalomc3565922019-10-28 11:58:20 -0700446 const char *mud_url, int *opclasses);
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700447int dpp_auth_conf_rx(struct dpp_authentication *auth, const u8 *hdr,
448 const u8 *attr_start, size_t attr_len);
449int dpp_notify_new_qr_code(struct dpp_authentication *auth,
450 struct dpp_bootstrap_info *peer_bi);
Hai Shalom021b0b52019-04-10 11:17:58 -0700451struct dpp_configuration * dpp_configuration_alloc(const char *type);
452int dpp_akm_psk(enum dpp_akm akm);
453int dpp_akm_sae(enum dpp_akm akm);
454int dpp_akm_legacy(enum dpp_akm akm);
455int dpp_akm_dpp(enum dpp_akm akm);
456int dpp_akm_ver2(enum dpp_akm akm);
457int dpp_configuration_valid(const struct dpp_configuration *conf);
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700458void dpp_configuration_free(struct dpp_configuration *conf);
Hai Shalom021b0b52019-04-10 11:17:58 -0700459int dpp_set_configurator(struct dpp_global *dpp, void *msg_ctx,
460 struct dpp_authentication *auth,
461 const char *cmd);
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700462void dpp_auth_deinit(struct dpp_authentication *auth);
463struct wpabuf *
464dpp_conf_req_rx(struct dpp_authentication *auth, const u8 *attr_start,
465 size_t attr_len);
466int dpp_conf_resp_rx(struct dpp_authentication *auth,
467 const struct wpabuf *resp);
Hai Shalom021b0b52019-04-10 11:17:58 -0700468enum dpp_status_error dpp_conf_result_rx(struct dpp_authentication *auth,
469 const u8 *hdr,
470 const u8 *attr_start, size_t attr_len);
471struct wpabuf * dpp_build_conf_result(struct dpp_authentication *auth,
472 enum dpp_status_error status);
Hai Shalomc3565922019-10-28 11:58:20 -0700473enum dpp_status_error dpp_conn_status_result_rx(struct dpp_authentication *auth,
474 const u8 *hdr,
475 const u8 *attr_start,
476 size_t attr_len,
477 u8 *ssid, size_t *ssid_len,
478 char **channel_list);
479struct wpabuf * dpp_build_conn_status_result(struct dpp_authentication *auth,
480 enum dpp_status_error result,
481 const u8 *ssid, size_t ssid_len,
482 const char *channel_list);
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700483struct wpabuf * dpp_alloc_msg(enum dpp_public_action_frame_type type,
484 size_t len);
485const u8 * dpp_get_attr(const u8 *buf, size_t len, u16 req_id, u16 *ret_len);
486int dpp_check_attrs(const u8 *buf, size_t len);
487int dpp_key_expired(const char *timestamp, os_time_t *expiry);
Roshan Pius3a1667e2018-07-03 15:17:14 -0700488const char * dpp_akm_str(enum dpp_akm akm);
Hai Shalomc3565922019-10-28 11:58:20 -0700489const char * dpp_akm_selector_str(enum dpp_akm akm);
Roshan Pius3a1667e2018-07-03 15:17:14 -0700490int dpp_configurator_get_key(const struct dpp_configurator *conf, char *buf,
491 size_t buflen);
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700492void dpp_configurator_free(struct dpp_configurator *conf);
493struct dpp_configurator *
494dpp_keygen_configurator(const char *curve, const u8 *privkey,
495 size_t privkey_len);
496int dpp_configurator_own_config(struct dpp_authentication *auth,
Roshan Pius3a1667e2018-07-03 15:17:14 -0700497 const char *curve, int ap);
498enum dpp_status_error
499dpp_peer_intro(struct dpp_introduction *intro, const char *own_connector,
500 const u8 *net_access_key, size_t net_access_key_len,
501 const u8 *csign_key, size_t csign_key_len,
502 const u8 *peer_connector, size_t peer_connector_len,
503 os_time_t *expiry);
504struct dpp_pkex * dpp_pkex_init(void *msg_ctx, struct dpp_bootstrap_info *bi,
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700505 const u8 *own_mac,
506 const char *identifier,
507 const char *code);
Roshan Pius3a1667e2018-07-03 15:17:14 -0700508struct dpp_pkex * dpp_pkex_rx_exchange_req(void *msg_ctx,
509 struct dpp_bootstrap_info *bi,
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700510 const u8 *own_mac,
511 const u8 *peer_mac,
512 const char *identifier,
513 const char *code,
514 const u8 *buf, size_t len);
515struct wpabuf * dpp_pkex_rx_exchange_resp(struct dpp_pkex *pkex,
Roshan Pius3a1667e2018-07-03 15:17:14 -0700516 const u8 *peer_mac,
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700517 const u8 *buf, size_t len);
518struct wpabuf * dpp_pkex_rx_commit_reveal_req(struct dpp_pkex *pkex,
519 const u8 *hdr,
520 const u8 *buf, size_t len);
521int dpp_pkex_rx_commit_reveal_resp(struct dpp_pkex *pkex, const u8 *hdr,
522 const u8 *buf, size_t len);
523void dpp_pkex_free(struct dpp_pkex *pkex);
524
Roshan Pius3a1667e2018-07-03 15:17:14 -0700525char * dpp_corrupt_connector_signature(const char *connector);
526
Hai Shalom021b0b52019-04-10 11:17:58 -0700527
528struct dpp_pfs {
529 struct crypto_ecdh *ecdh;
530 const struct dpp_curve_params *curve;
531 struct wpabuf *ie;
532 struct wpabuf *secret;
533};
534
535struct dpp_pfs * dpp_pfs_init(const u8 *net_access_key,
536 size_t net_access_key_len);
537int dpp_pfs_process(struct dpp_pfs *pfs, const u8 *peer_ie, size_t peer_ie_len);
538void dpp_pfs_free(struct dpp_pfs *pfs);
539
540struct dpp_bootstrap_info * dpp_add_qr_code(struct dpp_global *dpp,
541 const char *uri);
Ahmed ElArabawy0ff61c52019-12-26 12:38:39 -0800542struct dpp_bootstrap_info * dpp_add_nfc_uri(struct dpp_global *dpp,
543 const char *uri);
Hai Shalom021b0b52019-04-10 11:17:58 -0700544int dpp_bootstrap_gen(struct dpp_global *dpp, const char *cmd);
545struct dpp_bootstrap_info *
546dpp_bootstrap_get_id(struct dpp_global *dpp, unsigned int id);
547int dpp_bootstrap_remove(struct dpp_global *dpp, const char *id);
548struct dpp_bootstrap_info *
549dpp_pkex_finish(struct dpp_global *dpp, struct dpp_pkex *pkex, const u8 *peer,
550 unsigned int freq);
551const char * dpp_bootstrap_get_uri(struct dpp_global *dpp, unsigned int id);
552int dpp_bootstrap_info(struct dpp_global *dpp, int id,
553 char *reply, int reply_size);
554void dpp_bootstrap_find_pair(struct dpp_global *dpp, const u8 *i_bootstrap,
555 const u8 *r_bootstrap,
556 struct dpp_bootstrap_info **own_bi,
557 struct dpp_bootstrap_info **peer_bi);
558int dpp_configurator_add(struct dpp_global *dpp, const char *cmd);
559int dpp_configurator_remove(struct dpp_global *dpp, const char *id);
560int dpp_configurator_get_key_id(struct dpp_global *dpp, unsigned int id,
561 char *buf, size_t buflen);
Hai Shalom81f62d82019-07-22 12:10:00 -0700562int dpp_relay_add_controller(struct dpp_global *dpp,
563 struct dpp_relay_config *config);
564int dpp_relay_rx_action(struct dpp_global *dpp, const u8 *src, const u8 *hdr,
565 const u8 *buf, size_t len, unsigned int freq,
566 const u8 *i_bootstrap, const u8 *r_bootstrap);
567int dpp_relay_rx_gas_req(struct dpp_global *dpp, const u8 *src, const u8 *data,
568 size_t data_len);
569int dpp_controller_start(struct dpp_global *dpp,
570 struct dpp_controller_config *config);
571void dpp_controller_stop(struct dpp_global *dpp);
572int dpp_tcp_init(struct dpp_global *dpp, struct dpp_authentication *auth,
573 const struct hostapd_ip_addr *addr, int port);
574
575struct dpp_global_config {
576 void *msg_ctx;
577 void *cb_ctx;
578 int (*process_conf_obj)(void *ctx, struct dpp_authentication *auth);
579};
580
581struct dpp_global * dpp_global_init(struct dpp_global_config *config);
Hai Shalom021b0b52019-04-10 11:17:58 -0700582void dpp_global_clear(struct dpp_global *dpp);
583void dpp_global_deinit(struct dpp_global *dpp);
584
585#endif /* CONFIG_DPP */
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700586#endif /* DPP_H */