1 /* 2 * DPP functionality shared between hostapd and wpa_supplicant 3 * Copyright (c) 2017, Qualcomm Atheros, Inc. 4 * Copyright (c) 2018-2020, The Linux Foundation 5 * 6 * This software may be distributed under the terms of the BSD license. 7 * See README for more details. 8 */ 9 10 #ifndef DPP_H 11 #define DPP_H 12 13 #ifdef CONFIG_DPP 14 #include <openssl/x509.h> 15 16 #include "utils/list.h" 17 #include "common/wpa_common.h" 18 #include "crypto/sha256.h" 19 20 struct crypto_ecdh; 21 struct hostapd_ip_addr; 22 struct dpp_global; 23 struct json_token; 24 struct dpp_reconfig_id; 25 26 #ifdef CONFIG_TESTING_OPTIONS 27 #define DPP_VERSION (dpp_version_override) 28 extern 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 */ 36 37 #define DPP_HDR_LEN (4 + 2) /* OUI, OUI Type, Crypto Suite, DPP frame type */ 38 #define DPP_TCP_PORT 8908 39 40 enum 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, 50 DPP_PA_CONFIGURATION_RESULT = 11, 51 DPP_PA_CONNECTION_STATUS_RESULT = 12, 52 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, 57 }; 58 59 enum 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, 82 DPP_ATTR_BOOTSTRAP_INFO = 0x1017, 83 DPP_ATTR_CHANNEL = 0x1018, 84 DPP_ATTR_PROTOCOL_VERSION = 0x1019, 85 DPP_ATTR_ENVELOPED_DATA = 0x101A, 86 DPP_ATTR_SEND_CONN_STATUS = 0x101B, 87 DPP_ATTR_CONN_STATUS = 0x101C, 88 DPP_ATTR_RECONFIG_FLAGS = 0x101D, 89 DPP_ATTR_C_SIGN_KEY_HASH = 0x101E, 90 DPP_ATTR_CSR_ATTR_REQ = 0x101F, 91 DPP_ATTR_A_NONCE = 0x1020, 92 DPP_ATTR_E_PRIME_ID = 0x1021, 93 DPP_ATTR_CONFIGURATOR_NONCE = 0x1022, 94 }; 95 96 enum 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, 104 DPP_STATUS_INVALID_CONNECTOR = 7, 105 DPP_STATUS_NO_MATCH = 8, 106 DPP_STATUS_CONFIG_REJECTED = 9, 107 DPP_STATUS_NO_AP = 10, 108 DPP_STATUS_CONFIGURE_PENDING = 11, 109 DPP_STATUS_CSR_NEEDED = 12, 110 DPP_STATUS_CSR_BAD = 13, 111 }; 112 113 /* DPP Reconfig Flags object - connectorKey values */ 114 enum dpp_connector_key { 115 DPP_CONFIG_REUSEKEY = 0, 116 DPP_CONFIG_REPLACEKEY = 1, 117 }; 118 119 #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 127 #define DPP_CP_LEN 64 128 129 struct 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 140 enum dpp_bootstrap_type { 141 DPP_BOOTSTRAP_QR_CODE, 142 DPP_BOOTSTRAP_PKEX, 143 DPP_BOOTSTRAP_NFC_URI, 144 }; 145 146 struct 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]; 152 char *chan; 153 char *info; 154 char *pk; 155 unsigned int freq[DPP_BOOTSTRAP_MAX_FREQ]; 156 unsigned int num_freq; 157 bool channels_listed; 158 u8 version; 159 int own; 160 EVP_PKEY *pubkey; 161 u8 pubkey_hash[SHA256_MAC_LEN]; 162 u8 pubkey_hash_chirp[SHA256_MAC_LEN]; 163 const struct dpp_curve_params *curve; 164 unsigned int pkex_t; /* number of failures before dpp_pkex 165 * instantiation */ 166 int nfc_negotiated; /* whether this has been used in NFC negotiated 167 * connection handover */ 168 char *configurator_params; 169 }; 170 171 #define PKEX_COUNTER_T_LIMIT 5 172 173 struct dpp_pkex { 174 void *msg_ctx; 175 unsigned int initiator:1; 176 unsigned int exchange_done:1; 177 unsigned int failed:1; 178 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; 191 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 197 enum dpp_akm { 198 DPP_AKM_UNKNOWN, 199 DPP_AKM_DPP, 200 DPP_AKM_PSK, 201 DPP_AKM_SAE, 202 DPP_AKM_PSK_SAE, 203 DPP_AKM_SAE_DPP, 204 DPP_AKM_PSK_SAE_DPP, 205 DPP_AKM_DOT1X, 206 }; 207 208 enum dpp_netrole { 209 DPP_NETROLE_STA, 210 DPP_NETROLE_AP, 211 DPP_NETROLE_CONFIGURATOR, 212 }; 213 214 struct dpp_configuration { 215 u8 ssid[32]; 216 size_t ssid_len; 217 int ssid_charset; 218 enum dpp_akm akm; 219 enum dpp_netrole netrole; 220 221 /* For DPP configuration (connector) */ 222 os_time_t netaccesskey_expiry; 223 224 /* TODO: groups */ 225 char *group_id; 226 227 /* For legacy configuration */ 228 char *passphrase; 229 u8 psk[32]; 230 int psk_set; 231 232 char *csrattrs; 233 }; 234 235 struct dpp_asymmetric_key { 236 struct dpp_asymmetric_key *next; 237 EVP_PKEY *csign; 238 EVP_PKEY *pp_key; 239 char *config_template; 240 char *connector_template; 241 }; 242 243 #define DPP_MAX_CONF_OBJ 10 244 245 struct dpp_authentication { 246 struct dpp_global *global; 247 void *msg_ctx; 248 u8 peer_version; 249 const struct dpp_curve_params *curve; 250 struct dpp_bootstrap_info *peer_bi; 251 struct dpp_bootstrap_info *own_bi; 252 struct dpp_bootstrap_info *tmp_own_bi; 253 struct dpp_bootstrap_info *tmp_peer_bi; 254 u8 waiting_pubkey_hash[SHA256_MAC_LEN]; 255 int response_pending; 256 int reconfig; 257 enum dpp_connector_key reconfig_connector_key; 258 enum dpp_status_error auth_resp_status; 259 enum dpp_status_error conf_resp_status; 260 enum dpp_status_error force_conf_resp_status; 261 u8 peer_mac_addr[ETH_ALEN]; 262 u8 i_nonce[DPP_MAX_NONCE_LEN]; 263 u8 r_nonce[DPP_MAX_NONCE_LEN]; 264 u8 e_nonce[DPP_MAX_NONCE_LEN]; 265 u8 c_nonce[DPP_MAX_NONCE_LEN]; 266 u8 i_capab; 267 u8 r_capab; 268 enum dpp_netrole e_netrole; 269 EVP_PKEY *own_protocol_key; 270 EVP_PKEY *peer_protocol_key; 271 EVP_PKEY *reconfig_old_protocol_key; 272 struct wpabuf *req_msg; 273 struct wpabuf *resp_msg; 274 struct wpabuf *reconfig_req_msg; 275 struct wpabuf *reconfig_resp_msg; 276 /* Intersection of possible frequencies for initiating DPP 277 * Authentication exchange */ 278 unsigned int freq[DPP_BOOTSTRAP_MAX_FREQ]; 279 unsigned int num_freq, freq_idx; 280 unsigned int curr_freq; 281 unsigned int neg_freq; 282 unsigned int num_freq_iters; 283 size_t secret_len; 284 u8 Mx[DPP_MAX_SHARED_SECRET_LEN]; 285 size_t Mx_len; 286 u8 Nx[DPP_MAX_SHARED_SECRET_LEN]; 287 size_t Nx_len; 288 u8 Lx[DPP_MAX_SHARED_SECRET_LEN]; 289 size_t Lx_len; 290 u8 k1[DPP_MAX_HASH_LEN]; 291 u8 k2[DPP_MAX_HASH_LEN]; 292 u8 ke[DPP_MAX_HASH_LEN]; 293 u8 bk[DPP_MAX_HASH_LEN]; 294 int initiator; 295 int waiting_auth_resp; 296 int waiting_auth_conf; 297 int auth_req_ack; 298 unsigned int auth_resp_tries; 299 u8 allowed_roles; 300 int configurator; 301 int remove_on_tx_status; 302 int connect_on_tx_status; 303 int waiting_conf_result; 304 int waiting_conn_status_result; 305 int auth_success; 306 bool reconfig_success; 307 struct wpabuf *conf_req; 308 const struct wpabuf *conf_resp; /* owned by GAS server */ 309 struct wpabuf *conf_resp_tcp; 310 struct dpp_configuration *conf_ap; 311 struct dpp_configuration *conf2_ap; 312 struct dpp_configuration *conf_sta; 313 struct dpp_configuration *conf2_sta; 314 int provision_configurator; 315 struct dpp_configurator *conf; 316 struct dpp_config_obj { 317 char *connector; /* received signedConnector */ 318 u8 ssid[SSID_MAX_LEN]; 319 u8 ssid_len; 320 int ssid_charset; 321 char passphrase[64]; 322 u8 psk[PMK_LEN]; 323 int psk_set; 324 enum dpp_akm akm; 325 struct wpabuf *c_sign_key; 326 struct wpabuf *certbag; 327 struct wpabuf *certs; 328 struct wpabuf *cacert; 329 char *server_name; 330 struct wpabuf *pp_key; 331 } conf_obj[DPP_MAX_CONF_OBJ]; 332 unsigned int num_conf_obj; 333 struct dpp_asymmetric_key *conf_key_pkg; 334 struct wpabuf *net_access_key; 335 os_time_t net_access_key_expiry; 336 int send_conn_status; 337 int conn_status_requested; 338 int akm_use_selector; 339 int configurator_set; 340 u8 transaction_id; 341 u8 *csrattrs; 342 size_t csrattrs_len; 343 bool waiting_csr; 344 struct wpabuf *csr; 345 struct wpabuf *priv_key; /* DER-encoded private key used for csr */ 346 bool waiting_cert; 347 char *trusted_eap_server_name; 348 struct wpabuf *cacert; 349 struct wpabuf *certbag; 350 void *cert_resp_ctx; 351 void *gas_server_ctx; 352 #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 */ 358 }; 359 360 struct dpp_configurator { 361 struct dl_list list; 362 unsigned int id; 363 int own; 364 EVP_PKEY *csign; 365 u8 kid_hash[SHA256_MAC_LEN]; 366 char *kid; 367 const struct dpp_curve_params *curve; 368 char *connector; /* own Connector for reconfiguration */ 369 EVP_PKEY *connector_key; 370 EVP_PKEY *pp_key; 371 }; 372 373 struct dpp_introduction { 374 u8 pmkid[PMKID_LEN]; 375 u8 pmk[PMK_LEN_MAX]; 376 size_t pmk_len; 377 }; 378 379 struct dpp_relay_config { 380 const struct hostapd_ip_addr *ipaddr; 381 const u8 *pkhash; 382 383 void *msg_ctx; 384 void *cb_ctx; 385 void (*tx)(void *ctx, const u8 *addr, unsigned int freq, const u8 *msg, 386 size_t len); 387 void (*gas_resp_tx)(void *ctx, const u8 *addr, u8 dialog_token, int prot, 388 struct wpabuf *buf); 389 }; 390 391 struct dpp_controller_config { 392 const char *configurator_params; 393 int tcp_port; 394 u8 allowed_roles; 395 int qr_mutual; 396 enum dpp_netrole netrole; 397 void *msg_ctx; 398 void *cb_ctx; 399 int (*process_conf_obj)(void *ctx, struct dpp_authentication *auth); 400 }; 401 402 #ifdef CONFIG_TESTING_OPTIONS 403 enum dpp_test_behavior { 404 DPP_TEST_DISABLED = 0, 405 DPP_TEST_AFTER_WRAPPED_DATA_AUTH_REQ = 1, 406 DPP_TEST_AFTER_WRAPPED_DATA_AUTH_RESP = 2, 407 DPP_TEST_AFTER_WRAPPED_DATA_AUTH_CONF = 3, 408 DPP_TEST_AFTER_WRAPPED_DATA_PKEX_CR_REQ = 4, 409 DPP_TEST_AFTER_WRAPPED_DATA_PKEX_CR_RESP = 5, 410 DPP_TEST_AFTER_WRAPPED_DATA_CONF_REQ = 6, 411 DPP_TEST_AFTER_WRAPPED_DATA_CONF_RESP = 7, 412 DPP_TEST_ZERO_I_CAPAB = 8, 413 DPP_TEST_ZERO_R_CAPAB = 9, 414 DPP_TEST_NO_R_BOOTSTRAP_KEY_HASH_AUTH_REQ = 10, 415 DPP_TEST_NO_I_BOOTSTRAP_KEY_HASH_AUTH_REQ = 11, 416 DPP_TEST_NO_I_PROTO_KEY_AUTH_REQ = 12, 417 DPP_TEST_NO_I_NONCE_AUTH_REQ = 13, 418 DPP_TEST_NO_I_CAPAB_AUTH_REQ = 14, 419 DPP_TEST_NO_WRAPPED_DATA_AUTH_REQ = 15, 420 DPP_TEST_NO_STATUS_AUTH_RESP = 16, 421 DPP_TEST_NO_R_BOOTSTRAP_KEY_HASH_AUTH_RESP = 17, 422 DPP_TEST_NO_I_BOOTSTRAP_KEY_HASH_AUTH_RESP = 18, 423 DPP_TEST_NO_R_PROTO_KEY_AUTH_RESP = 19, 424 DPP_TEST_NO_R_NONCE_AUTH_RESP = 20, 425 DPP_TEST_NO_I_NONCE_AUTH_RESP = 21, 426 DPP_TEST_NO_R_CAPAB_AUTH_RESP = 22, 427 DPP_TEST_NO_R_AUTH_AUTH_RESP = 23, 428 DPP_TEST_NO_WRAPPED_DATA_AUTH_RESP = 24, 429 DPP_TEST_NO_STATUS_AUTH_CONF = 25, 430 DPP_TEST_NO_R_BOOTSTRAP_KEY_HASH_AUTH_CONF = 26, 431 DPP_TEST_NO_I_BOOTSTRAP_KEY_HASH_AUTH_CONF = 27, 432 DPP_TEST_NO_I_AUTH_AUTH_CONF = 28, 433 DPP_TEST_NO_WRAPPED_DATA_AUTH_CONF = 29, 434 DPP_TEST_I_NONCE_MISMATCH_AUTH_RESP = 30, 435 DPP_TEST_INCOMPATIBLE_R_CAPAB_AUTH_RESP = 31, 436 DPP_TEST_R_AUTH_MISMATCH_AUTH_RESP = 32, 437 DPP_TEST_I_AUTH_MISMATCH_AUTH_CONF = 33, 438 DPP_TEST_NO_FINITE_CYCLIC_GROUP_PKEX_EXCHANGE_REQ = 34, 439 DPP_TEST_NO_ENCRYPTED_KEY_PKEX_EXCHANGE_REQ = 35, 440 DPP_TEST_NO_STATUS_PKEX_EXCHANGE_RESP = 36, 441 DPP_TEST_NO_ENCRYPTED_KEY_PKEX_EXCHANGE_RESP = 37, 442 DPP_TEST_NO_BOOTSTRAP_KEY_PKEX_CR_REQ = 38, 443 DPP_TEST_NO_I_AUTH_TAG_PKEX_CR_REQ = 39, 444 DPP_TEST_NO_WRAPPED_DATA_PKEX_CR_REQ = 40, 445 DPP_TEST_NO_BOOTSTRAP_KEY_PKEX_CR_RESP = 41, 446 DPP_TEST_NO_R_AUTH_TAG_PKEX_CR_RESP = 42, 447 DPP_TEST_NO_WRAPPED_DATA_PKEX_CR_RESP = 43, 448 DPP_TEST_INVALID_ENCRYPTED_KEY_PKEX_EXCHANGE_REQ = 44, 449 DPP_TEST_INVALID_ENCRYPTED_KEY_PKEX_EXCHANGE_RESP = 45, 450 DPP_TEST_INVALID_STATUS_PKEX_EXCHANGE_RESP = 46, 451 DPP_TEST_INVALID_BOOTSTRAP_KEY_PKEX_CR_REQ = 47, 452 DPP_TEST_INVALID_BOOTSTRAP_KEY_PKEX_CR_RESP = 48, 453 DPP_TEST_I_AUTH_TAG_MISMATCH_PKEX_CR_REQ = 49, 454 DPP_TEST_R_AUTH_TAG_MISMATCH_PKEX_CR_RESP = 50, 455 DPP_TEST_NO_E_NONCE_CONF_REQ = 51, 456 DPP_TEST_NO_CONFIG_ATTR_OBJ_CONF_REQ = 52, 457 DPP_TEST_NO_WRAPPED_DATA_CONF_REQ = 53, 458 DPP_TEST_NO_E_NONCE_CONF_RESP = 54, 459 DPP_TEST_NO_CONFIG_OBJ_CONF_RESP = 55, 460 DPP_TEST_NO_STATUS_CONF_RESP = 56, 461 DPP_TEST_NO_WRAPPED_DATA_CONF_RESP = 57, 462 DPP_TEST_INVALID_STATUS_CONF_RESP = 58, 463 DPP_TEST_E_NONCE_MISMATCH_CONF_RESP = 59, 464 DPP_TEST_NO_TRANSACTION_ID_PEER_DISC_REQ = 60, 465 DPP_TEST_NO_CONNECTOR_PEER_DISC_REQ = 61, 466 DPP_TEST_NO_TRANSACTION_ID_PEER_DISC_RESP = 62, 467 DPP_TEST_NO_STATUS_PEER_DISC_RESP = 63, 468 DPP_TEST_NO_CONNECTOR_PEER_DISC_RESP = 64, 469 DPP_TEST_AUTH_RESP_IN_PLACE_OF_CONF = 65, 470 DPP_TEST_INVALID_I_PROTO_KEY_AUTH_REQ = 66, 471 DPP_TEST_INVALID_R_PROTO_KEY_AUTH_RESP = 67, 472 DPP_TEST_INVALID_R_BOOTSTRAP_KEY_HASH_AUTH_REQ = 68, 473 DPP_TEST_INVALID_I_BOOTSTRAP_KEY_HASH_AUTH_REQ = 69, 474 DPP_TEST_INVALID_R_BOOTSTRAP_KEY_HASH_AUTH_RESP = 70, 475 DPP_TEST_INVALID_I_BOOTSTRAP_KEY_HASH_AUTH_RESP = 71, 476 DPP_TEST_INVALID_R_BOOTSTRAP_KEY_HASH_AUTH_CONF = 72, 477 DPP_TEST_INVALID_I_BOOTSTRAP_KEY_HASH_AUTH_CONF = 73, 478 DPP_TEST_INVALID_STATUS_AUTH_RESP = 74, 479 DPP_TEST_INVALID_STATUS_AUTH_CONF = 75, 480 DPP_TEST_INVALID_CONFIG_ATTR_OBJ_CONF_REQ = 76, 481 DPP_TEST_INVALID_TRANSACTION_ID_PEER_DISC_RESP = 77, 482 DPP_TEST_INVALID_STATUS_PEER_DISC_RESP = 78, 483 DPP_TEST_INVALID_CONNECTOR_PEER_DISC_RESP = 79, 484 DPP_TEST_INVALID_CONNECTOR_PEER_DISC_REQ = 80, 485 DPP_TEST_INVALID_I_NONCE_AUTH_REQ = 81, 486 DPP_TEST_INVALID_TRANSACTION_ID_PEER_DISC_REQ = 82, 487 DPP_TEST_INVALID_E_NONCE_CONF_REQ = 83, 488 DPP_TEST_STOP_AT_PKEX_EXCHANGE_RESP = 84, 489 DPP_TEST_STOP_AT_PKEX_CR_REQ = 85, 490 DPP_TEST_STOP_AT_PKEX_CR_RESP = 86, 491 DPP_TEST_STOP_AT_AUTH_REQ = 87, 492 DPP_TEST_STOP_AT_AUTH_RESP = 88, 493 DPP_TEST_STOP_AT_AUTH_CONF = 89, 494 DPP_TEST_STOP_AT_CONF_REQ = 90, 495 DPP_TEST_REJECT_CONFIG = 91, 496 }; 497 498 extern enum dpp_test_behavior dpp_test; 499 extern u8 dpp_pkex_own_mac_override[ETH_ALEN]; 500 extern u8 dpp_pkex_peer_mac_override[ETH_ALEN]; 501 extern u8 dpp_pkex_ephemeral_key_override[600]; 502 extern size_t dpp_pkex_ephemeral_key_override_len; 503 extern u8 dpp_protocol_key_override[600]; 504 extern size_t dpp_protocol_key_override_len; 505 extern u8 dpp_nonce_override[DPP_MAX_NONCE_LEN]; 506 extern size_t dpp_nonce_override_len; 507 #endif /* CONFIG_TESTING_OPTIONS */ 508 509 void dpp_bootstrap_info_free(struct dpp_bootstrap_info *info); 510 const char * dpp_bootstrap_type_txt(enum dpp_bootstrap_type type); 511 int dpp_parse_uri_chan_list(struct dpp_bootstrap_info *bi, 512 const char *chan_list); 513 int dpp_parse_uri_mac(struct dpp_bootstrap_info *bi, const char *mac); 514 int dpp_parse_uri_info(struct dpp_bootstrap_info *bi, const char *info); 515 int dpp_nfc_update_bi(struct dpp_bootstrap_info *own_bi, 516 struct dpp_bootstrap_info *peer_bi); 517 struct dpp_authentication * 518 dpp_alloc_auth(struct dpp_global *dpp, void *msg_ctx); 519 struct hostapd_hw_modes; 520 struct dpp_authentication * dpp_auth_init(struct dpp_global *dpp, void *msg_ctx, 521 struct dpp_bootstrap_info *peer_bi, 522 struct dpp_bootstrap_info *own_bi, 523 u8 dpp_allowed_roles, 524 unsigned int neg_freq, 525 struct hostapd_hw_modes *own_modes, 526 u16 num_modes); 527 struct dpp_authentication * 528 dpp_auth_req_rx(struct dpp_global *dpp, void *msg_ctx, u8 dpp_allowed_roles, 529 int qr_mutual, struct dpp_bootstrap_info *peer_bi, 530 struct dpp_bootstrap_info *own_bi, 531 unsigned int freq, const u8 *hdr, const u8 *attr_start, 532 size_t attr_len); 533 struct wpabuf * 534 dpp_auth_resp_rx(struct dpp_authentication *auth, const u8 *hdr, 535 const u8 *attr_start, size_t attr_len); 536 struct wpabuf * dpp_build_conf_req(struct dpp_authentication *auth, 537 const char *json); 538 struct wpabuf * dpp_build_conf_req_helper(struct dpp_authentication *auth, 539 const char *name, 540 enum dpp_netrole netrole, 541 const char *mud_url, int *opclasses); 542 int dpp_auth_conf_rx(struct dpp_authentication *auth, const u8 *hdr, 543 const u8 *attr_start, size_t attr_len); 544 int dpp_notify_new_qr_code(struct dpp_authentication *auth, 545 struct dpp_bootstrap_info *peer_bi); 546 struct dpp_configuration * dpp_configuration_alloc(const char *type); 547 int dpp_akm_psk(enum dpp_akm akm); 548 int dpp_akm_sae(enum dpp_akm akm); 549 int dpp_akm_legacy(enum dpp_akm akm); 550 int dpp_akm_dpp(enum dpp_akm akm); 551 int dpp_akm_ver2(enum dpp_akm akm); 552 int dpp_configuration_valid(const struct dpp_configuration *conf); 553 void dpp_configuration_free(struct dpp_configuration *conf); 554 int dpp_set_configurator(struct dpp_authentication *auth, const char *cmd); 555 void dpp_auth_deinit(struct dpp_authentication *auth); 556 struct wpabuf * 557 dpp_build_conf_resp(struct dpp_authentication *auth, const u8 *e_nonce, 558 u16 e_nonce_len, enum dpp_netrole netrole, 559 bool cert_req); 560 struct wpabuf * 561 dpp_conf_req_rx(struct dpp_authentication *auth, const u8 *attr_start, 562 size_t attr_len); 563 int dpp_conf_resp_rx(struct dpp_authentication *auth, 564 const struct wpabuf *resp); 565 enum dpp_status_error dpp_conf_result_rx(struct dpp_authentication *auth, 566 const u8 *hdr, 567 const u8 *attr_start, size_t attr_len); 568 struct wpabuf * dpp_build_conf_result(struct dpp_authentication *auth, 569 enum dpp_status_error status); 570 enum dpp_status_error dpp_conn_status_result_rx(struct dpp_authentication *auth, 571 const u8 *hdr, 572 const u8 *attr_start, 573 size_t attr_len, 574 u8 *ssid, size_t *ssid_len, 575 char **channel_list); 576 struct wpabuf * dpp_build_conn_status_result(struct dpp_authentication *auth, 577 enum dpp_status_error result, 578 const u8 *ssid, size_t ssid_len, 579 const char *channel_list); 580 struct wpabuf * dpp_alloc_msg(enum dpp_public_action_frame_type type, 581 size_t len); 582 const u8 * dpp_get_attr(const u8 *buf, size_t len, u16 req_id, u16 *ret_len); 583 int dpp_check_attrs(const u8 *buf, size_t len); 584 int dpp_key_expired(const char *timestamp, os_time_t *expiry); 585 const char * dpp_akm_str(enum dpp_akm akm); 586 const char * dpp_akm_selector_str(enum dpp_akm akm); 587 int dpp_configurator_get_key(const struct dpp_configurator *conf, char *buf, 588 size_t buflen); 589 void dpp_configurator_free(struct dpp_configurator *conf); 590 int dpp_configurator_own_config(struct dpp_authentication *auth, 591 const char *curve, int ap); 592 enum dpp_status_error 593 dpp_peer_intro(struct dpp_introduction *intro, const char *own_connector, 594 const u8 *net_access_key, size_t net_access_key_len, 595 const u8 *csign_key, size_t csign_key_len, 596 const u8 *peer_connector, size_t peer_connector_len, 597 os_time_t *expiry); 598 struct dpp_pkex * dpp_pkex_init(void *msg_ctx, struct dpp_bootstrap_info *bi, 599 const u8 *own_mac, 600 const char *identifier, 601 const char *code); 602 struct dpp_pkex * dpp_pkex_rx_exchange_req(void *msg_ctx, 603 struct dpp_bootstrap_info *bi, 604 const u8 *own_mac, 605 const u8 *peer_mac, 606 const char *identifier, 607 const char *code, 608 const u8 *buf, size_t len); 609 struct wpabuf * dpp_pkex_rx_exchange_resp(struct dpp_pkex *pkex, 610 const u8 *peer_mac, 611 const u8 *buf, size_t len); 612 struct wpabuf * dpp_pkex_rx_commit_reveal_req(struct dpp_pkex *pkex, 613 const u8 *hdr, 614 const u8 *buf, size_t len); 615 int dpp_pkex_rx_commit_reveal_resp(struct dpp_pkex *pkex, const u8 *hdr, 616 const u8 *buf, size_t len); 617 void dpp_pkex_free(struct dpp_pkex *pkex); 618 619 char * dpp_corrupt_connector_signature(const char *connector); 620 621 622 struct dpp_pfs { 623 struct crypto_ecdh *ecdh; 624 const struct dpp_curve_params *curve; 625 struct wpabuf *ie; 626 struct wpabuf *secret; 627 }; 628 629 struct dpp_pfs * dpp_pfs_init(const u8 *net_access_key, 630 size_t net_access_key_len); 631 int dpp_pfs_process(struct dpp_pfs *pfs, const u8 *peer_ie, size_t peer_ie_len); 632 void dpp_pfs_free(struct dpp_pfs *pfs); 633 634 struct wpabuf * dpp_build_csr(struct dpp_authentication *auth, 635 const char *name); 636 struct wpabuf * dpp_pkcs7_certs(const struct wpabuf *pkcs7); 637 int dpp_validate_csr(struct dpp_authentication *auth, const struct wpabuf *csr); 638 639 struct dpp_bootstrap_info * dpp_add_qr_code(struct dpp_global *dpp, 640 const char *uri); 641 struct dpp_bootstrap_info * dpp_add_nfc_uri(struct dpp_global *dpp, 642 const char *uri); 643 int dpp_bootstrap_gen(struct dpp_global *dpp, const char *cmd); 644 struct dpp_bootstrap_info * 645 dpp_bootstrap_get_id(struct dpp_global *dpp, unsigned int id); 646 int dpp_bootstrap_remove(struct dpp_global *dpp, const char *id); 647 struct dpp_bootstrap_info * 648 dpp_pkex_finish(struct dpp_global *dpp, struct dpp_pkex *pkex, const u8 *peer, 649 unsigned int freq); 650 const char * dpp_bootstrap_get_uri(struct dpp_global *dpp, unsigned int id); 651 int dpp_bootstrap_info(struct dpp_global *dpp, int id, 652 char *reply, int reply_size); 653 int dpp_bootstrap_set(struct dpp_global *dpp, int id, const char *params); 654 void dpp_bootstrap_find_pair(struct dpp_global *dpp, const u8 *i_bootstrap, 655 const u8 *r_bootstrap, 656 struct dpp_bootstrap_info **own_bi, 657 struct dpp_bootstrap_info **peer_bi); 658 struct dpp_bootstrap_info * dpp_bootstrap_find_chirp(struct dpp_global *dpp, 659 const u8 *hash); 660 int dpp_configurator_add(struct dpp_global *dpp, const char *cmd); 661 int dpp_configurator_remove(struct dpp_global *dpp, const char *id); 662 int dpp_configurator_get_key_id(struct dpp_global *dpp, unsigned int id, 663 char *buf, size_t buflen); 664 int dpp_configurator_from_backup(struct dpp_global *dpp, 665 struct dpp_asymmetric_key *key); 666 struct dpp_configurator * dpp_configurator_find_kid(struct dpp_global *dpp, 667 const u8 *kid); 668 int dpp_relay_add_controller(struct dpp_global *dpp, 669 struct dpp_relay_config *config); 670 int dpp_relay_rx_action(struct dpp_global *dpp, const u8 *src, const u8 *hdr, 671 const u8 *buf, size_t len, unsigned int freq, 672 const u8 *i_bootstrap, const u8 *r_bootstrap, 673 void *cb_ctx); 674 int dpp_relay_rx_gas_req(struct dpp_global *dpp, const u8 *src, const u8 *data, 675 size_t data_len); 676 int dpp_controller_start(struct dpp_global *dpp, 677 struct dpp_controller_config *config); 678 void dpp_controller_stop(struct dpp_global *dpp); 679 struct dpp_authentication * dpp_controller_get_auth(struct dpp_global *dpp, 680 unsigned int id); 681 void dpp_controller_new_qr_code(struct dpp_global *dpp, 682 struct dpp_bootstrap_info *bi); 683 int dpp_tcp_init(struct dpp_global *dpp, struct dpp_authentication *auth, 684 const struct hostapd_ip_addr *addr, int port, 685 const char *name, enum dpp_netrole netrole, void *msg_ctx, 686 void *cb_ctx, 687 int (*process_conf_obj)(void *ctx, 688 struct dpp_authentication *auth)); 689 690 struct wpabuf * dpp_build_presence_announcement(struct dpp_bootstrap_info *bi); 691 void dpp_notify_chirp_received(void *msg_ctx, int id, const u8 *src, 692 unsigned int freq, const u8 *hash); 693 694 struct dpp_global_config { 695 void *cb_ctx; 696 void (*remove_bi)(void *ctx, struct dpp_bootstrap_info *bi); 697 }; 698 699 struct dpp_global * dpp_global_init(struct dpp_global_config *config); 700 void dpp_global_clear(struct dpp_global *dpp); 701 void dpp_global_deinit(struct dpp_global *dpp); 702 703 /* dpp_reconfig.c */ 704 705 struct wpabuf * dpp_build_reconfig_announcement(const u8 *csign_key, 706 size_t csign_key_len, 707 const u8 *net_access_key, 708 size_t net_access_key_len, 709 struct dpp_reconfig_id *id); 710 struct dpp_authentication * 711 dpp_reconfig_init(struct dpp_global *dpp, void *msg_ctx, 712 struct dpp_configurator *conf, unsigned int freq, u16 group, 713 const u8 *a_nonce_attr, size_t a_nonce_len, 714 const u8 *e_id_attr, size_t e_id_len); 715 struct dpp_authentication * 716 dpp_reconfig_auth_req_rx(struct dpp_global *dpp, void *msg_ctx, 717 const char *own_connector, 718 const u8 *net_access_key, size_t net_access_key_len, 719 const u8 *csign_key, size_t csign_key_len, 720 unsigned int freq, const u8 *hdr, 721 const u8 *attr_start, size_t attr_len); 722 struct wpabuf * 723 dpp_reconfig_auth_resp_rx(struct dpp_authentication *auth, const u8 *hdr, 724 const u8 *attr_start, size_t attr_len); 725 int dpp_reconfig_auth_conf_rx(struct dpp_authentication *auth, const u8 *hdr, 726 const u8 *attr_start, size_t attr_len); 727 728 struct dpp_reconfig_id * dpp_gen_reconfig_id(const u8 *csign_key, 729 size_t csign_key_len, 730 const u8 *pp_key, 731 size_t pp_key_len); 732 int dpp_update_reconfig_id(struct dpp_reconfig_id *id); 733 void dpp_free_reconfig_id(struct dpp_reconfig_id *id); 734 735 #endif /* CONFIG_DPP */ 736 #endif /* DPP_H */ 737