1e5b75505Sopenharmony_ci/* 2e5b75505Sopenharmony_ci * DPP functionality shared between hostapd and wpa_supplicant 3e5b75505Sopenharmony_ci * Copyright (c) 2017, Qualcomm Atheros, Inc. 4e5b75505Sopenharmony_ci * Copyright (c) 2018-2019, The Linux Foundation 5e5b75505Sopenharmony_ci * 6e5b75505Sopenharmony_ci * This software may be distributed under the terms of the BSD license. 7e5b75505Sopenharmony_ci * See README for more details. 8e5b75505Sopenharmony_ci */ 9e5b75505Sopenharmony_ci 10e5b75505Sopenharmony_ci#ifndef DPP_H 11e5b75505Sopenharmony_ci#define DPP_H 12e5b75505Sopenharmony_ci 13e5b75505Sopenharmony_ci#ifdef CONFIG_DPP 14e5b75505Sopenharmony_ci#include <openssl/x509.h> 15e5b75505Sopenharmony_ci 16e5b75505Sopenharmony_ci#include "utils/list.h" 17e5b75505Sopenharmony_ci#include "common/wpa_common.h" 18e5b75505Sopenharmony_ci#include "crypto/sha256.h" 19e5b75505Sopenharmony_ci 20e5b75505Sopenharmony_cistruct crypto_ecdh; 21e5b75505Sopenharmony_cistruct hostapd_ip_addr; 22e5b75505Sopenharmony_cistruct dpp_global; 23e5b75505Sopenharmony_ci 24e5b75505Sopenharmony_ci#define DPP_HDR_LEN (4 + 2) /* OUI, OUI Type, Crypto Suite, DPP frame type */ 25e5b75505Sopenharmony_ci#define DPP_TCP_PORT 7871 26e5b75505Sopenharmony_ci 27e5b75505Sopenharmony_cienum dpp_public_action_frame_type { 28e5b75505Sopenharmony_ci DPP_PA_AUTHENTICATION_REQ = 0, 29e5b75505Sopenharmony_ci DPP_PA_AUTHENTICATION_RESP = 1, 30e5b75505Sopenharmony_ci DPP_PA_AUTHENTICATION_CONF = 2, 31e5b75505Sopenharmony_ci DPP_PA_PEER_DISCOVERY_REQ = 5, 32e5b75505Sopenharmony_ci DPP_PA_PEER_DISCOVERY_RESP = 6, 33e5b75505Sopenharmony_ci DPP_PA_PKEX_EXCHANGE_REQ = 7, 34e5b75505Sopenharmony_ci DPP_PA_PKEX_EXCHANGE_RESP = 8, 35e5b75505Sopenharmony_ci DPP_PA_PKEX_COMMIT_REVEAL_REQ = 9, 36e5b75505Sopenharmony_ci DPP_PA_PKEX_COMMIT_REVEAL_RESP = 10, 37e5b75505Sopenharmony_ci DPP_PA_CONFIGURATION_RESULT = 11, 38e5b75505Sopenharmony_ci}; 39e5b75505Sopenharmony_ci 40e5b75505Sopenharmony_cienum dpp_attribute_id { 41e5b75505Sopenharmony_ci DPP_ATTR_STATUS = 0x1000, 42e5b75505Sopenharmony_ci DPP_ATTR_I_BOOTSTRAP_KEY_HASH = 0x1001, 43e5b75505Sopenharmony_ci DPP_ATTR_R_BOOTSTRAP_KEY_HASH = 0x1002, 44e5b75505Sopenharmony_ci DPP_ATTR_I_PROTOCOL_KEY = 0x1003, 45e5b75505Sopenharmony_ci DPP_ATTR_WRAPPED_DATA = 0x1004, 46e5b75505Sopenharmony_ci DPP_ATTR_I_NONCE = 0x1005, 47e5b75505Sopenharmony_ci DPP_ATTR_I_CAPABILITIES = 0x1006, 48e5b75505Sopenharmony_ci DPP_ATTR_R_NONCE = 0x1007, 49e5b75505Sopenharmony_ci DPP_ATTR_R_CAPABILITIES = 0x1008, 50e5b75505Sopenharmony_ci DPP_ATTR_R_PROTOCOL_KEY = 0x1009, 51e5b75505Sopenharmony_ci DPP_ATTR_I_AUTH_TAG = 0x100A, 52e5b75505Sopenharmony_ci DPP_ATTR_R_AUTH_TAG = 0x100B, 53e5b75505Sopenharmony_ci DPP_ATTR_CONFIG_OBJ = 0x100C, 54e5b75505Sopenharmony_ci DPP_ATTR_CONNECTOR = 0x100D, 55e5b75505Sopenharmony_ci DPP_ATTR_CONFIG_ATTR_OBJ = 0x100E, 56e5b75505Sopenharmony_ci DPP_ATTR_BOOTSTRAP_KEY = 0x100F, 57e5b75505Sopenharmony_ci DPP_ATTR_OWN_NET_NK_HASH = 0x1011, 58e5b75505Sopenharmony_ci DPP_ATTR_FINITE_CYCLIC_GROUP = 0x1012, 59e5b75505Sopenharmony_ci DPP_ATTR_ENCRYPTED_KEY = 0x1013, 60e5b75505Sopenharmony_ci DPP_ATTR_ENROLLEE_NONCE = 0x1014, 61e5b75505Sopenharmony_ci DPP_ATTR_CODE_IDENTIFIER = 0x1015, 62e5b75505Sopenharmony_ci DPP_ATTR_TRANSACTION_ID = 0x1016, 63e5b75505Sopenharmony_ci DPP_ATTR_BOOTSTRAP_INFO = 0x1017, 64e5b75505Sopenharmony_ci DPP_ATTR_CHANNEL = 0x1018, 65e5b75505Sopenharmony_ci DPP_ATTR_PROTOCOL_VERSION = 0x1019, 66e5b75505Sopenharmony_ci DPP_ATTR_ENVELOPED_DATA = 0x101A, 67e5b75505Sopenharmony_ci}; 68e5b75505Sopenharmony_ci 69e5b75505Sopenharmony_cienum dpp_status_error { 70e5b75505Sopenharmony_ci DPP_STATUS_OK = 0, 71e5b75505Sopenharmony_ci DPP_STATUS_NOT_COMPATIBLE = 1, 72e5b75505Sopenharmony_ci DPP_STATUS_AUTH_FAILURE = 2, 73e5b75505Sopenharmony_ci DPP_STATUS_UNWRAP_FAILURE = 3, 74e5b75505Sopenharmony_ci DPP_STATUS_BAD_GROUP = 4, 75e5b75505Sopenharmony_ci DPP_STATUS_CONFIGURE_FAILURE = 5, 76e5b75505Sopenharmony_ci DPP_STATUS_RESPONSE_PENDING = 6, 77e5b75505Sopenharmony_ci DPP_STATUS_INVALID_CONNECTOR = 7, 78e5b75505Sopenharmony_ci DPP_STATUS_NO_MATCH = 8, 79e5b75505Sopenharmony_ci DPP_STATUS_CONFIG_REJECTED = 9, 80e5b75505Sopenharmony_ci}; 81e5b75505Sopenharmony_ci 82e5b75505Sopenharmony_ci#define DPP_CAPAB_ENROLLEE BIT(0) 83e5b75505Sopenharmony_ci#define DPP_CAPAB_CONFIGURATOR BIT(1) 84e5b75505Sopenharmony_ci#define DPP_CAPAB_ROLE_MASK (BIT(0) | BIT(1)) 85e5b75505Sopenharmony_ci 86e5b75505Sopenharmony_ci#define DPP_BOOTSTRAP_MAX_FREQ 30 87e5b75505Sopenharmony_ci#define DPP_MAX_NONCE_LEN 32 88e5b75505Sopenharmony_ci#define DPP_MAX_HASH_LEN 64 89e5b75505Sopenharmony_ci#define DPP_MAX_SHARED_SECRET_LEN 66 90e5b75505Sopenharmony_ci 91e5b75505Sopenharmony_cistruct dpp_curve_params { 92e5b75505Sopenharmony_ci const char *name; 93e5b75505Sopenharmony_ci size_t hash_len; 94e5b75505Sopenharmony_ci size_t aes_siv_key_len; 95e5b75505Sopenharmony_ci size_t nonce_len; 96e5b75505Sopenharmony_ci size_t prime_len; 97e5b75505Sopenharmony_ci const char *jwk_crv; 98e5b75505Sopenharmony_ci u16 ike_group; 99e5b75505Sopenharmony_ci const char *jws_alg; 100e5b75505Sopenharmony_ci}; 101e5b75505Sopenharmony_ci 102e5b75505Sopenharmony_cienum dpp_bootstrap_type { 103e5b75505Sopenharmony_ci DPP_BOOTSTRAP_QR_CODE, 104e5b75505Sopenharmony_ci DPP_BOOTSTRAP_PKEX, 105e5b75505Sopenharmony_ci}; 106e5b75505Sopenharmony_ci 107e5b75505Sopenharmony_cistruct dpp_bootstrap_info { 108e5b75505Sopenharmony_ci struct dl_list list; 109e5b75505Sopenharmony_ci unsigned int id; 110e5b75505Sopenharmony_ci enum dpp_bootstrap_type type; 111e5b75505Sopenharmony_ci char *uri; 112e5b75505Sopenharmony_ci u8 mac_addr[ETH_ALEN]; 113e5b75505Sopenharmony_ci char *info; 114e5b75505Sopenharmony_ci unsigned int freq[DPP_BOOTSTRAP_MAX_FREQ]; 115e5b75505Sopenharmony_ci unsigned int num_freq; 116e5b75505Sopenharmony_ci int own; 117e5b75505Sopenharmony_ci EVP_PKEY *pubkey; 118e5b75505Sopenharmony_ci u8 pubkey_hash[SHA256_MAC_LEN]; 119e5b75505Sopenharmony_ci const struct dpp_curve_params *curve; 120e5b75505Sopenharmony_ci unsigned int pkex_t; /* number of failures before dpp_pkex 121e5b75505Sopenharmony_ci * instantiation */ 122e5b75505Sopenharmony_ci}; 123e5b75505Sopenharmony_ci 124e5b75505Sopenharmony_ci#define PKEX_COUNTER_T_LIMIT 5 125e5b75505Sopenharmony_ci 126e5b75505Sopenharmony_cistruct dpp_pkex { 127e5b75505Sopenharmony_ci void *msg_ctx; 128e5b75505Sopenharmony_ci unsigned int initiator:1; 129e5b75505Sopenharmony_ci unsigned int exchange_done:1; 130e5b75505Sopenharmony_ci unsigned int failed:1; 131e5b75505Sopenharmony_ci struct dpp_bootstrap_info *own_bi; 132e5b75505Sopenharmony_ci u8 own_mac[ETH_ALEN]; 133e5b75505Sopenharmony_ci u8 peer_mac[ETH_ALEN]; 134e5b75505Sopenharmony_ci char *identifier; 135e5b75505Sopenharmony_ci char *code; 136e5b75505Sopenharmony_ci EVP_PKEY *x; 137e5b75505Sopenharmony_ci EVP_PKEY *y; 138e5b75505Sopenharmony_ci u8 Mx[DPP_MAX_SHARED_SECRET_LEN]; 139e5b75505Sopenharmony_ci u8 Nx[DPP_MAX_SHARED_SECRET_LEN]; 140e5b75505Sopenharmony_ci u8 z[DPP_MAX_HASH_LEN]; 141e5b75505Sopenharmony_ci EVP_PKEY *peer_bootstrap_key; 142e5b75505Sopenharmony_ci struct wpabuf *exchange_req; 143e5b75505Sopenharmony_ci struct wpabuf *exchange_resp; 144e5b75505Sopenharmony_ci unsigned int t; /* number of failures on code use */ 145e5b75505Sopenharmony_ci unsigned int exch_req_wait_time; 146e5b75505Sopenharmony_ci unsigned int exch_req_tries; 147e5b75505Sopenharmony_ci unsigned int freq; 148e5b75505Sopenharmony_ci}; 149e5b75505Sopenharmony_ci 150e5b75505Sopenharmony_cienum dpp_akm { 151e5b75505Sopenharmony_ci DPP_AKM_UNKNOWN, 152e5b75505Sopenharmony_ci DPP_AKM_DPP, 153e5b75505Sopenharmony_ci DPP_AKM_PSK, 154e5b75505Sopenharmony_ci DPP_AKM_SAE, 155e5b75505Sopenharmony_ci DPP_AKM_PSK_SAE, 156e5b75505Sopenharmony_ci DPP_AKM_SAE_DPP, 157e5b75505Sopenharmony_ci DPP_AKM_PSK_SAE_DPP, 158e5b75505Sopenharmony_ci}; 159e5b75505Sopenharmony_ci 160e5b75505Sopenharmony_cistruct dpp_configuration { 161e5b75505Sopenharmony_ci u8 ssid[32]; 162e5b75505Sopenharmony_ci size_t ssid_len; 163e5b75505Sopenharmony_ci enum dpp_akm akm; 164e5b75505Sopenharmony_ci 165e5b75505Sopenharmony_ci /* For DPP configuration (connector) */ 166e5b75505Sopenharmony_ci os_time_t netaccesskey_expiry; 167e5b75505Sopenharmony_ci 168e5b75505Sopenharmony_ci /* TODO: groups */ 169e5b75505Sopenharmony_ci char *group_id; 170e5b75505Sopenharmony_ci 171e5b75505Sopenharmony_ci /* For legacy configuration */ 172e5b75505Sopenharmony_ci char *passphrase; 173e5b75505Sopenharmony_ci u8 psk[32]; 174e5b75505Sopenharmony_ci int psk_set; 175e5b75505Sopenharmony_ci}; 176e5b75505Sopenharmony_ci 177e5b75505Sopenharmony_cistruct dpp_authentication { 178e5b75505Sopenharmony_ci void *msg_ctx; 179e5b75505Sopenharmony_ci u8 peer_version; 180e5b75505Sopenharmony_ci const struct dpp_curve_params *curve; 181e5b75505Sopenharmony_ci struct dpp_bootstrap_info *peer_bi; 182e5b75505Sopenharmony_ci struct dpp_bootstrap_info *own_bi; 183e5b75505Sopenharmony_ci struct dpp_bootstrap_info *tmp_own_bi; 184e5b75505Sopenharmony_ci u8 waiting_pubkey_hash[SHA256_MAC_LEN]; 185e5b75505Sopenharmony_ci int response_pending; 186e5b75505Sopenharmony_ci enum dpp_status_error auth_resp_status; 187e5b75505Sopenharmony_ci enum dpp_status_error conf_resp_status; 188e5b75505Sopenharmony_ci u8 peer_mac_addr[ETH_ALEN]; 189e5b75505Sopenharmony_ci u8 i_nonce[DPP_MAX_NONCE_LEN]; 190e5b75505Sopenharmony_ci u8 r_nonce[DPP_MAX_NONCE_LEN]; 191e5b75505Sopenharmony_ci u8 e_nonce[DPP_MAX_NONCE_LEN]; 192e5b75505Sopenharmony_ci u8 i_capab; 193e5b75505Sopenharmony_ci u8 r_capab; 194e5b75505Sopenharmony_ci EVP_PKEY *own_protocol_key; 195e5b75505Sopenharmony_ci EVP_PKEY *peer_protocol_key; 196e5b75505Sopenharmony_ci struct wpabuf *req_msg; 197e5b75505Sopenharmony_ci struct wpabuf *resp_msg; 198e5b75505Sopenharmony_ci /* Intersection of possible frequencies for initiating DPP 199e5b75505Sopenharmony_ci * Authentication exchange */ 200e5b75505Sopenharmony_ci unsigned int freq[DPP_BOOTSTRAP_MAX_FREQ]; 201e5b75505Sopenharmony_ci unsigned int num_freq, freq_idx; 202e5b75505Sopenharmony_ci unsigned int curr_freq; 203e5b75505Sopenharmony_ci unsigned int neg_freq; 204e5b75505Sopenharmony_ci unsigned int num_freq_iters; 205e5b75505Sopenharmony_ci size_t secret_len; 206e5b75505Sopenharmony_ci u8 Mx[DPP_MAX_SHARED_SECRET_LEN]; 207e5b75505Sopenharmony_ci size_t Mx_len; 208e5b75505Sopenharmony_ci u8 Nx[DPP_MAX_SHARED_SECRET_LEN]; 209e5b75505Sopenharmony_ci size_t Nx_len; 210e5b75505Sopenharmony_ci u8 Lx[DPP_MAX_SHARED_SECRET_LEN]; 211e5b75505Sopenharmony_ci size_t Lx_len; 212e5b75505Sopenharmony_ci u8 k1[DPP_MAX_HASH_LEN]; 213e5b75505Sopenharmony_ci u8 k2[DPP_MAX_HASH_LEN]; 214e5b75505Sopenharmony_ci u8 ke[DPP_MAX_HASH_LEN]; 215e5b75505Sopenharmony_ci int initiator; 216e5b75505Sopenharmony_ci int waiting_auth_resp; 217e5b75505Sopenharmony_ci int waiting_auth_conf; 218e5b75505Sopenharmony_ci int auth_req_ack; 219e5b75505Sopenharmony_ci unsigned int auth_resp_tries; 220e5b75505Sopenharmony_ci u8 allowed_roles; 221e5b75505Sopenharmony_ci int configurator; 222e5b75505Sopenharmony_ci int remove_on_tx_status; 223e5b75505Sopenharmony_ci int connect_on_tx_status; 224e5b75505Sopenharmony_ci int waiting_conf_result; 225e5b75505Sopenharmony_ci int auth_success; 226e5b75505Sopenharmony_ci struct wpabuf *conf_req; 227e5b75505Sopenharmony_ci const struct wpabuf *conf_resp; /* owned by GAS server */ 228e5b75505Sopenharmony_ci struct dpp_configuration *conf_ap; 229e5b75505Sopenharmony_ci struct dpp_configuration *conf_sta; 230e5b75505Sopenharmony_ci struct dpp_configurator *conf; 231e5b75505Sopenharmony_ci char *connector; /* received signedConnector */ 232e5b75505Sopenharmony_ci u8 ssid[SSID_MAX_LEN]; 233e5b75505Sopenharmony_ci u8 ssid_len; 234e5b75505Sopenharmony_ci char passphrase[64]; 235e5b75505Sopenharmony_ci u8 psk[PMK_LEN]; 236e5b75505Sopenharmony_ci int psk_set; 237e5b75505Sopenharmony_ci enum dpp_akm akm; 238e5b75505Sopenharmony_ci struct wpabuf *net_access_key; 239e5b75505Sopenharmony_ci os_time_t net_access_key_expiry; 240e5b75505Sopenharmony_ci struct wpabuf *c_sign_key; 241e5b75505Sopenharmony_ci#ifdef CONFIG_TESTING_OPTIONS 242e5b75505Sopenharmony_ci char *config_obj_override; 243e5b75505Sopenharmony_ci char *discovery_override; 244e5b75505Sopenharmony_ci char *groups_override; 245e5b75505Sopenharmony_ci unsigned int ignore_netaccesskey_mismatch:1; 246e5b75505Sopenharmony_ci#endif /* CONFIG_TESTING_OPTIONS */ 247e5b75505Sopenharmony_ci}; 248e5b75505Sopenharmony_ci 249e5b75505Sopenharmony_cistruct dpp_configurator { 250e5b75505Sopenharmony_ci struct dl_list list; 251e5b75505Sopenharmony_ci unsigned int id; 252e5b75505Sopenharmony_ci int own; 253e5b75505Sopenharmony_ci EVP_PKEY *csign; 254e5b75505Sopenharmony_ci char *kid; 255e5b75505Sopenharmony_ci const struct dpp_curve_params *curve; 256e5b75505Sopenharmony_ci}; 257e5b75505Sopenharmony_ci 258e5b75505Sopenharmony_cistruct dpp_introduction { 259e5b75505Sopenharmony_ci u8 pmkid[PMKID_LEN]; 260e5b75505Sopenharmony_ci u8 pmk[PMK_LEN_MAX]; 261e5b75505Sopenharmony_ci size_t pmk_len; 262e5b75505Sopenharmony_ci}; 263e5b75505Sopenharmony_ci 264e5b75505Sopenharmony_cistruct dpp_relay_config { 265e5b75505Sopenharmony_ci const struct hostapd_ip_addr *ipaddr; 266e5b75505Sopenharmony_ci const u8 *pkhash; 267e5b75505Sopenharmony_ci 268e5b75505Sopenharmony_ci void *cb_ctx; 269e5b75505Sopenharmony_ci void (*tx)(void *ctx, const u8 *addr, unsigned int freq, const u8 *msg, 270e5b75505Sopenharmony_ci size_t len); 271e5b75505Sopenharmony_ci void (*gas_resp_tx)(void *ctx, const u8 *addr, u8 dialog_token, int prot, 272e5b75505Sopenharmony_ci struct wpabuf *buf); 273e5b75505Sopenharmony_ci}; 274e5b75505Sopenharmony_ci 275e5b75505Sopenharmony_cistruct dpp_controller_config { 276e5b75505Sopenharmony_ci const char *configurator_params; 277e5b75505Sopenharmony_ci int tcp_port; 278e5b75505Sopenharmony_ci}; 279e5b75505Sopenharmony_ci 280e5b75505Sopenharmony_ci#ifdef CONFIG_TESTING_OPTIONS 281e5b75505Sopenharmony_cienum dpp_test_behavior { 282e5b75505Sopenharmony_ci DPP_TEST_DISABLED = 0, 283e5b75505Sopenharmony_ci DPP_TEST_AFTER_WRAPPED_DATA_AUTH_REQ = 1, 284e5b75505Sopenharmony_ci DPP_TEST_AFTER_WRAPPED_DATA_AUTH_RESP = 2, 285e5b75505Sopenharmony_ci DPP_TEST_AFTER_WRAPPED_DATA_AUTH_CONF = 3, 286e5b75505Sopenharmony_ci DPP_TEST_AFTER_WRAPPED_DATA_PKEX_CR_REQ = 4, 287e5b75505Sopenharmony_ci DPP_TEST_AFTER_WRAPPED_DATA_PKEX_CR_RESP = 5, 288e5b75505Sopenharmony_ci DPP_TEST_AFTER_WRAPPED_DATA_CONF_REQ = 6, 289e5b75505Sopenharmony_ci DPP_TEST_AFTER_WRAPPED_DATA_CONF_RESP = 7, 290e5b75505Sopenharmony_ci DPP_TEST_ZERO_I_CAPAB = 8, 291e5b75505Sopenharmony_ci DPP_TEST_ZERO_R_CAPAB = 9, 292e5b75505Sopenharmony_ci DPP_TEST_NO_R_BOOTSTRAP_KEY_HASH_AUTH_REQ = 10, 293e5b75505Sopenharmony_ci DPP_TEST_NO_I_BOOTSTRAP_KEY_HASH_AUTH_REQ = 11, 294e5b75505Sopenharmony_ci DPP_TEST_NO_I_PROTO_KEY_AUTH_REQ = 12, 295e5b75505Sopenharmony_ci DPP_TEST_NO_I_NONCE_AUTH_REQ = 13, 296e5b75505Sopenharmony_ci DPP_TEST_NO_I_CAPAB_AUTH_REQ = 14, 297e5b75505Sopenharmony_ci DPP_TEST_NO_WRAPPED_DATA_AUTH_REQ = 15, 298e5b75505Sopenharmony_ci DPP_TEST_NO_STATUS_AUTH_RESP = 16, 299e5b75505Sopenharmony_ci DPP_TEST_NO_R_BOOTSTRAP_KEY_HASH_AUTH_RESP = 17, 300e5b75505Sopenharmony_ci DPP_TEST_NO_I_BOOTSTRAP_KEY_HASH_AUTH_RESP = 18, 301e5b75505Sopenharmony_ci DPP_TEST_NO_R_PROTO_KEY_AUTH_RESP = 19, 302e5b75505Sopenharmony_ci DPP_TEST_NO_R_NONCE_AUTH_RESP = 20, 303e5b75505Sopenharmony_ci DPP_TEST_NO_I_NONCE_AUTH_RESP = 21, 304e5b75505Sopenharmony_ci DPP_TEST_NO_R_CAPAB_AUTH_RESP = 22, 305e5b75505Sopenharmony_ci DPP_TEST_NO_R_AUTH_AUTH_RESP = 23, 306e5b75505Sopenharmony_ci DPP_TEST_NO_WRAPPED_DATA_AUTH_RESP = 24, 307e5b75505Sopenharmony_ci DPP_TEST_NO_STATUS_AUTH_CONF = 25, 308e5b75505Sopenharmony_ci DPP_TEST_NO_R_BOOTSTRAP_KEY_HASH_AUTH_CONF = 26, 309e5b75505Sopenharmony_ci DPP_TEST_NO_I_BOOTSTRAP_KEY_HASH_AUTH_CONF = 27, 310e5b75505Sopenharmony_ci DPP_TEST_NO_I_AUTH_AUTH_CONF = 28, 311e5b75505Sopenharmony_ci DPP_TEST_NO_WRAPPED_DATA_AUTH_CONF = 29, 312e5b75505Sopenharmony_ci DPP_TEST_I_NONCE_MISMATCH_AUTH_RESP = 30, 313e5b75505Sopenharmony_ci DPP_TEST_INCOMPATIBLE_R_CAPAB_AUTH_RESP = 31, 314e5b75505Sopenharmony_ci DPP_TEST_R_AUTH_MISMATCH_AUTH_RESP = 32, 315e5b75505Sopenharmony_ci DPP_TEST_I_AUTH_MISMATCH_AUTH_CONF = 33, 316e5b75505Sopenharmony_ci DPP_TEST_NO_FINITE_CYCLIC_GROUP_PKEX_EXCHANGE_REQ = 34, 317e5b75505Sopenharmony_ci DPP_TEST_NO_ENCRYPTED_KEY_PKEX_EXCHANGE_REQ = 35, 318e5b75505Sopenharmony_ci DPP_TEST_NO_STATUS_PKEX_EXCHANGE_RESP = 36, 319e5b75505Sopenharmony_ci DPP_TEST_NO_ENCRYPTED_KEY_PKEX_EXCHANGE_RESP = 37, 320e5b75505Sopenharmony_ci DPP_TEST_NO_BOOTSTRAP_KEY_PKEX_CR_REQ = 38, 321e5b75505Sopenharmony_ci DPP_TEST_NO_I_AUTH_TAG_PKEX_CR_REQ = 39, 322e5b75505Sopenharmony_ci DPP_TEST_NO_WRAPPED_DATA_PKEX_CR_REQ = 40, 323e5b75505Sopenharmony_ci DPP_TEST_NO_BOOTSTRAP_KEY_PKEX_CR_RESP = 41, 324e5b75505Sopenharmony_ci DPP_TEST_NO_R_AUTH_TAG_PKEX_CR_RESP = 42, 325e5b75505Sopenharmony_ci DPP_TEST_NO_WRAPPED_DATA_PKEX_CR_RESP = 43, 326e5b75505Sopenharmony_ci DPP_TEST_INVALID_ENCRYPTED_KEY_PKEX_EXCHANGE_REQ = 44, 327e5b75505Sopenharmony_ci DPP_TEST_INVALID_ENCRYPTED_KEY_PKEX_EXCHANGE_RESP = 45, 328e5b75505Sopenharmony_ci DPP_TEST_INVALID_STATUS_PKEX_EXCHANGE_RESP = 46, 329e5b75505Sopenharmony_ci DPP_TEST_INVALID_BOOTSTRAP_KEY_PKEX_CR_REQ = 47, 330e5b75505Sopenharmony_ci DPP_TEST_INVALID_BOOTSTRAP_KEY_PKEX_CR_RESP = 48, 331e5b75505Sopenharmony_ci DPP_TEST_I_AUTH_TAG_MISMATCH_PKEX_CR_REQ = 49, 332e5b75505Sopenharmony_ci DPP_TEST_R_AUTH_TAG_MISMATCH_PKEX_CR_RESP = 50, 333e5b75505Sopenharmony_ci DPP_TEST_NO_E_NONCE_CONF_REQ = 51, 334e5b75505Sopenharmony_ci DPP_TEST_NO_CONFIG_ATTR_OBJ_CONF_REQ = 52, 335e5b75505Sopenharmony_ci DPP_TEST_NO_WRAPPED_DATA_CONF_REQ = 53, 336e5b75505Sopenharmony_ci DPP_TEST_NO_E_NONCE_CONF_RESP = 54, 337e5b75505Sopenharmony_ci DPP_TEST_NO_CONFIG_OBJ_CONF_RESP = 55, 338e5b75505Sopenharmony_ci DPP_TEST_NO_STATUS_CONF_RESP = 56, 339e5b75505Sopenharmony_ci DPP_TEST_NO_WRAPPED_DATA_CONF_RESP = 57, 340e5b75505Sopenharmony_ci DPP_TEST_INVALID_STATUS_CONF_RESP = 58, 341e5b75505Sopenharmony_ci DPP_TEST_E_NONCE_MISMATCH_CONF_RESP = 59, 342e5b75505Sopenharmony_ci DPP_TEST_NO_TRANSACTION_ID_PEER_DISC_REQ = 60, 343e5b75505Sopenharmony_ci DPP_TEST_NO_CONNECTOR_PEER_DISC_REQ = 61, 344e5b75505Sopenharmony_ci DPP_TEST_NO_TRANSACTION_ID_PEER_DISC_RESP = 62, 345e5b75505Sopenharmony_ci DPP_TEST_NO_STATUS_PEER_DISC_RESP = 63, 346e5b75505Sopenharmony_ci DPP_TEST_NO_CONNECTOR_PEER_DISC_RESP = 64, 347e5b75505Sopenharmony_ci DPP_TEST_AUTH_RESP_IN_PLACE_OF_CONF = 65, 348e5b75505Sopenharmony_ci DPP_TEST_INVALID_I_PROTO_KEY_AUTH_REQ = 66, 349e5b75505Sopenharmony_ci DPP_TEST_INVALID_R_PROTO_KEY_AUTH_RESP = 67, 350e5b75505Sopenharmony_ci DPP_TEST_INVALID_R_BOOTSTRAP_KEY_HASH_AUTH_REQ = 68, 351e5b75505Sopenharmony_ci DPP_TEST_INVALID_I_BOOTSTRAP_KEY_HASH_AUTH_REQ = 69, 352e5b75505Sopenharmony_ci DPP_TEST_INVALID_R_BOOTSTRAP_KEY_HASH_AUTH_RESP = 70, 353e5b75505Sopenharmony_ci DPP_TEST_INVALID_I_BOOTSTRAP_KEY_HASH_AUTH_RESP = 71, 354e5b75505Sopenharmony_ci DPP_TEST_INVALID_R_BOOTSTRAP_KEY_HASH_AUTH_CONF = 72, 355e5b75505Sopenharmony_ci DPP_TEST_INVALID_I_BOOTSTRAP_KEY_HASH_AUTH_CONF = 73, 356e5b75505Sopenharmony_ci DPP_TEST_INVALID_STATUS_AUTH_RESP = 74, 357e5b75505Sopenharmony_ci DPP_TEST_INVALID_STATUS_AUTH_CONF = 75, 358e5b75505Sopenharmony_ci DPP_TEST_INVALID_CONFIG_ATTR_OBJ_CONF_REQ = 76, 359e5b75505Sopenharmony_ci DPP_TEST_INVALID_TRANSACTION_ID_PEER_DISC_RESP = 77, 360e5b75505Sopenharmony_ci DPP_TEST_INVALID_STATUS_PEER_DISC_RESP = 78, 361e5b75505Sopenharmony_ci DPP_TEST_INVALID_CONNECTOR_PEER_DISC_RESP = 79, 362e5b75505Sopenharmony_ci DPP_TEST_INVALID_CONNECTOR_PEER_DISC_REQ = 80, 363e5b75505Sopenharmony_ci DPP_TEST_INVALID_I_NONCE_AUTH_REQ = 81, 364e5b75505Sopenharmony_ci DPP_TEST_INVALID_TRANSACTION_ID_PEER_DISC_REQ = 82, 365e5b75505Sopenharmony_ci DPP_TEST_INVALID_E_NONCE_CONF_REQ = 83, 366e5b75505Sopenharmony_ci DPP_TEST_STOP_AT_PKEX_EXCHANGE_RESP = 84, 367e5b75505Sopenharmony_ci DPP_TEST_STOP_AT_PKEX_CR_REQ = 85, 368e5b75505Sopenharmony_ci DPP_TEST_STOP_AT_PKEX_CR_RESP = 86, 369e5b75505Sopenharmony_ci DPP_TEST_STOP_AT_AUTH_REQ = 87, 370e5b75505Sopenharmony_ci DPP_TEST_STOP_AT_AUTH_RESP = 88, 371e5b75505Sopenharmony_ci DPP_TEST_STOP_AT_AUTH_CONF = 89, 372e5b75505Sopenharmony_ci DPP_TEST_STOP_AT_CONF_REQ = 90, 373e5b75505Sopenharmony_ci DPP_TEST_REJECT_CONFIG = 91, 374e5b75505Sopenharmony_ci}; 375e5b75505Sopenharmony_ci 376e5b75505Sopenharmony_ciextern enum dpp_test_behavior dpp_test; 377e5b75505Sopenharmony_ciextern u8 dpp_pkex_own_mac_override[ETH_ALEN]; 378e5b75505Sopenharmony_ciextern u8 dpp_pkex_peer_mac_override[ETH_ALEN]; 379e5b75505Sopenharmony_ciextern u8 dpp_pkex_ephemeral_key_override[600]; 380e5b75505Sopenharmony_ciextern size_t dpp_pkex_ephemeral_key_override_len; 381e5b75505Sopenharmony_ciextern u8 dpp_protocol_key_override[600]; 382e5b75505Sopenharmony_ciextern size_t dpp_protocol_key_override_len; 383e5b75505Sopenharmony_ciextern u8 dpp_nonce_override[DPP_MAX_NONCE_LEN]; 384e5b75505Sopenharmony_ciextern size_t dpp_nonce_override_len; 385e5b75505Sopenharmony_ci#endif /* CONFIG_TESTING_OPTIONS */ 386e5b75505Sopenharmony_ci 387e5b75505Sopenharmony_civoid dpp_bootstrap_info_free(struct dpp_bootstrap_info *info); 388e5b75505Sopenharmony_ciconst char * dpp_bootstrap_type_txt(enum dpp_bootstrap_type type); 389e5b75505Sopenharmony_ciint dpp_bootstrap_key_hash(struct dpp_bootstrap_info *bi); 390e5b75505Sopenharmony_ciint dpp_parse_uri_chan_list(struct dpp_bootstrap_info *bi, 391e5b75505Sopenharmony_ci const char *chan_list); 392e5b75505Sopenharmony_ciint dpp_parse_uri_mac(struct dpp_bootstrap_info *bi, const char *mac); 393e5b75505Sopenharmony_ciint dpp_parse_uri_info(struct dpp_bootstrap_info *bi, const char *info); 394e5b75505Sopenharmony_cistruct dpp_bootstrap_info * dpp_parse_qr_code(const char *uri); 395e5b75505Sopenharmony_cichar * dpp_keygen(struct dpp_bootstrap_info *bi, const char *curve, 396e5b75505Sopenharmony_ci const u8 *privkey, size_t privkey_len); 397e5b75505Sopenharmony_cistruct hostapd_hw_modes; 398e5b75505Sopenharmony_cistruct dpp_authentication * dpp_auth_init(void *msg_ctx, 399e5b75505Sopenharmony_ci struct dpp_bootstrap_info *peer_bi, 400e5b75505Sopenharmony_ci struct dpp_bootstrap_info *own_bi, 401e5b75505Sopenharmony_ci u8 dpp_allowed_roles, 402e5b75505Sopenharmony_ci unsigned int neg_freq, 403e5b75505Sopenharmony_ci struct hostapd_hw_modes *own_modes, 404e5b75505Sopenharmony_ci u16 num_modes); 405e5b75505Sopenharmony_cistruct dpp_authentication * 406e5b75505Sopenharmony_cidpp_auth_req_rx(void *msg_ctx, u8 dpp_allowed_roles, int qr_mutual, 407e5b75505Sopenharmony_ci struct dpp_bootstrap_info *peer_bi, 408e5b75505Sopenharmony_ci struct dpp_bootstrap_info *own_bi, 409e5b75505Sopenharmony_ci unsigned int freq, const u8 *hdr, const u8 *attr_start, 410e5b75505Sopenharmony_ci size_t attr_len); 411e5b75505Sopenharmony_cistruct wpabuf * 412e5b75505Sopenharmony_cidpp_auth_resp_rx(struct dpp_authentication *auth, const u8 *hdr, 413e5b75505Sopenharmony_ci const u8 *attr_start, size_t attr_len); 414e5b75505Sopenharmony_cistruct wpabuf * dpp_build_conf_req(struct dpp_authentication *auth, 415e5b75505Sopenharmony_ci const char *json); 416e5b75505Sopenharmony_ciint dpp_auth_conf_rx(struct dpp_authentication *auth, const u8 *hdr, 417e5b75505Sopenharmony_ci const u8 *attr_start, size_t attr_len); 418e5b75505Sopenharmony_ciint dpp_notify_new_qr_code(struct dpp_authentication *auth, 419e5b75505Sopenharmony_ci struct dpp_bootstrap_info *peer_bi); 420e5b75505Sopenharmony_cistruct dpp_configuration * dpp_configuration_alloc(const char *type); 421e5b75505Sopenharmony_ciint dpp_akm_psk(enum dpp_akm akm); 422e5b75505Sopenharmony_ciint dpp_akm_sae(enum dpp_akm akm); 423e5b75505Sopenharmony_ciint dpp_akm_legacy(enum dpp_akm akm); 424e5b75505Sopenharmony_ciint dpp_akm_dpp(enum dpp_akm akm); 425e5b75505Sopenharmony_ciint dpp_akm_ver2(enum dpp_akm akm); 426e5b75505Sopenharmony_ciint dpp_configuration_valid(const struct dpp_configuration *conf); 427e5b75505Sopenharmony_civoid dpp_configuration_free(struct dpp_configuration *conf); 428e5b75505Sopenharmony_ciint dpp_set_configurator(struct dpp_global *dpp, void *msg_ctx, 429e5b75505Sopenharmony_ci struct dpp_authentication *auth, 430e5b75505Sopenharmony_ci const char *cmd); 431e5b75505Sopenharmony_civoid dpp_auth_deinit(struct dpp_authentication *auth); 432e5b75505Sopenharmony_cistruct wpabuf * 433e5b75505Sopenharmony_cidpp_conf_req_rx(struct dpp_authentication *auth, const u8 *attr_start, 434e5b75505Sopenharmony_ci size_t attr_len); 435e5b75505Sopenharmony_ciint dpp_conf_resp_rx(struct dpp_authentication *auth, 436e5b75505Sopenharmony_ci const struct wpabuf *resp); 437e5b75505Sopenharmony_cienum dpp_status_error dpp_conf_result_rx(struct dpp_authentication *auth, 438e5b75505Sopenharmony_ci const u8 *hdr, 439e5b75505Sopenharmony_ci const u8 *attr_start, size_t attr_len); 440e5b75505Sopenharmony_cistruct wpabuf * dpp_build_conf_result(struct dpp_authentication *auth, 441e5b75505Sopenharmony_ci enum dpp_status_error status); 442e5b75505Sopenharmony_cistruct wpabuf * dpp_alloc_msg(enum dpp_public_action_frame_type type, 443e5b75505Sopenharmony_ci size_t len); 444e5b75505Sopenharmony_ciconst u8 * dpp_get_attr(const u8 *buf, size_t len, u16 req_id, u16 *ret_len); 445e5b75505Sopenharmony_ciint dpp_check_attrs(const u8 *buf, size_t len); 446e5b75505Sopenharmony_ciint dpp_key_expired(const char *timestamp, os_time_t *expiry); 447e5b75505Sopenharmony_ciconst char * dpp_akm_str(enum dpp_akm akm); 448e5b75505Sopenharmony_ciint dpp_configurator_get_key(const struct dpp_configurator *conf, char *buf, 449e5b75505Sopenharmony_ci size_t buflen); 450e5b75505Sopenharmony_civoid dpp_configurator_free(struct dpp_configurator *conf); 451e5b75505Sopenharmony_cistruct dpp_configurator * 452e5b75505Sopenharmony_cidpp_keygen_configurator(const char *curve, const u8 *privkey, 453e5b75505Sopenharmony_ci size_t privkey_len); 454e5b75505Sopenharmony_ciint dpp_configurator_own_config(struct dpp_authentication *auth, 455e5b75505Sopenharmony_ci const char *curve, int ap); 456e5b75505Sopenharmony_cienum dpp_status_error 457e5b75505Sopenharmony_cidpp_peer_intro(struct dpp_introduction *intro, const char *own_connector, 458e5b75505Sopenharmony_ci const u8 *net_access_key, size_t net_access_key_len, 459e5b75505Sopenharmony_ci const u8 *csign_key, size_t csign_key_len, 460e5b75505Sopenharmony_ci const u8 *peer_connector, size_t peer_connector_len, 461e5b75505Sopenharmony_ci os_time_t *expiry); 462e5b75505Sopenharmony_cistruct dpp_pkex * dpp_pkex_init(void *msg_ctx, struct dpp_bootstrap_info *bi, 463e5b75505Sopenharmony_ci const u8 *own_mac, 464e5b75505Sopenharmony_ci const char *identifier, 465e5b75505Sopenharmony_ci const char *code); 466e5b75505Sopenharmony_cistruct dpp_pkex * dpp_pkex_rx_exchange_req(void *msg_ctx, 467e5b75505Sopenharmony_ci struct dpp_bootstrap_info *bi, 468e5b75505Sopenharmony_ci const u8 *own_mac, 469e5b75505Sopenharmony_ci const u8 *peer_mac, 470e5b75505Sopenharmony_ci const char *identifier, 471e5b75505Sopenharmony_ci const char *code, 472e5b75505Sopenharmony_ci const u8 *buf, size_t len); 473e5b75505Sopenharmony_cistruct wpabuf * dpp_pkex_rx_exchange_resp(struct dpp_pkex *pkex, 474e5b75505Sopenharmony_ci const u8 *peer_mac, 475e5b75505Sopenharmony_ci const u8 *buf, size_t len); 476e5b75505Sopenharmony_cistruct wpabuf * dpp_pkex_rx_commit_reveal_req(struct dpp_pkex *pkex, 477e5b75505Sopenharmony_ci const u8 *hdr, 478e5b75505Sopenharmony_ci const u8 *buf, size_t len); 479e5b75505Sopenharmony_ciint dpp_pkex_rx_commit_reveal_resp(struct dpp_pkex *pkex, const u8 *hdr, 480e5b75505Sopenharmony_ci const u8 *buf, size_t len); 481e5b75505Sopenharmony_civoid dpp_pkex_free(struct dpp_pkex *pkex); 482e5b75505Sopenharmony_ci 483e5b75505Sopenharmony_cichar * dpp_corrupt_connector_signature(const char *connector); 484e5b75505Sopenharmony_ci 485e5b75505Sopenharmony_ci 486e5b75505Sopenharmony_cistruct dpp_pfs { 487e5b75505Sopenharmony_ci struct crypto_ecdh *ecdh; 488e5b75505Sopenharmony_ci const struct dpp_curve_params *curve; 489e5b75505Sopenharmony_ci struct wpabuf *ie; 490e5b75505Sopenharmony_ci struct wpabuf *secret; 491e5b75505Sopenharmony_ci}; 492e5b75505Sopenharmony_ci 493e5b75505Sopenharmony_cistruct dpp_pfs * dpp_pfs_init(const u8 *net_access_key, 494e5b75505Sopenharmony_ci size_t net_access_key_len); 495e5b75505Sopenharmony_ciint dpp_pfs_process(struct dpp_pfs *pfs, const u8 *peer_ie, size_t peer_ie_len); 496e5b75505Sopenharmony_civoid dpp_pfs_free(struct dpp_pfs *pfs); 497e5b75505Sopenharmony_ci 498e5b75505Sopenharmony_cistruct dpp_bootstrap_info * dpp_add_qr_code(struct dpp_global *dpp, 499e5b75505Sopenharmony_ci const char *uri); 500e5b75505Sopenharmony_ciint dpp_bootstrap_gen(struct dpp_global *dpp, const char *cmd); 501e5b75505Sopenharmony_cistruct dpp_bootstrap_info * 502e5b75505Sopenharmony_cidpp_bootstrap_get_id(struct dpp_global *dpp, unsigned int id); 503e5b75505Sopenharmony_ciint dpp_bootstrap_remove(struct dpp_global *dpp, const char *id); 504e5b75505Sopenharmony_cistruct dpp_bootstrap_info * 505e5b75505Sopenharmony_cidpp_pkex_finish(struct dpp_global *dpp, struct dpp_pkex *pkex, const u8 *peer, 506e5b75505Sopenharmony_ci unsigned int freq); 507e5b75505Sopenharmony_ciconst char * dpp_bootstrap_get_uri(struct dpp_global *dpp, unsigned int id); 508e5b75505Sopenharmony_ciint dpp_bootstrap_info(struct dpp_global *dpp, int id, 509e5b75505Sopenharmony_ci char *reply, int reply_size); 510e5b75505Sopenharmony_civoid dpp_bootstrap_find_pair(struct dpp_global *dpp, const u8 *i_bootstrap, 511e5b75505Sopenharmony_ci const u8 *r_bootstrap, 512e5b75505Sopenharmony_ci struct dpp_bootstrap_info **own_bi, 513e5b75505Sopenharmony_ci struct dpp_bootstrap_info **peer_bi); 514e5b75505Sopenharmony_ciint dpp_configurator_add(struct dpp_global *dpp, const char *cmd); 515e5b75505Sopenharmony_ciint dpp_configurator_remove(struct dpp_global *dpp, const char *id); 516e5b75505Sopenharmony_ciint dpp_configurator_get_key_id(struct dpp_global *dpp, unsigned int id, 517e5b75505Sopenharmony_ci char *buf, size_t buflen); 518e5b75505Sopenharmony_ciint dpp_relay_add_controller(struct dpp_global *dpp, 519e5b75505Sopenharmony_ci struct dpp_relay_config *config); 520e5b75505Sopenharmony_ciint dpp_relay_rx_action(struct dpp_global *dpp, const u8 *src, const u8 *hdr, 521e5b75505Sopenharmony_ci const u8 *buf, size_t len, unsigned int freq, 522e5b75505Sopenharmony_ci const u8 *i_bootstrap, const u8 *r_bootstrap); 523e5b75505Sopenharmony_ciint dpp_relay_rx_gas_req(struct dpp_global *dpp, const u8 *src, const u8 *data, 524e5b75505Sopenharmony_ci size_t data_len); 525e5b75505Sopenharmony_ciint dpp_controller_start(struct dpp_global *dpp, 526e5b75505Sopenharmony_ci struct dpp_controller_config *config); 527e5b75505Sopenharmony_civoid dpp_controller_stop(struct dpp_global *dpp); 528e5b75505Sopenharmony_ciint dpp_tcp_init(struct dpp_global *dpp, struct dpp_authentication *auth, 529e5b75505Sopenharmony_ci const struct hostapd_ip_addr *addr, int port); 530e5b75505Sopenharmony_ci 531e5b75505Sopenharmony_cistruct dpp_global_config { 532e5b75505Sopenharmony_ci void *msg_ctx; 533e5b75505Sopenharmony_ci void *cb_ctx; 534e5b75505Sopenharmony_ci int (*process_conf_obj)(void *ctx, struct dpp_authentication *auth); 535e5b75505Sopenharmony_ci}; 536e5b75505Sopenharmony_ci 537e5b75505Sopenharmony_cistruct dpp_global * dpp_global_init(struct dpp_global_config *config); 538e5b75505Sopenharmony_civoid dpp_global_clear(struct dpp_global *dpp); 539e5b75505Sopenharmony_civoid dpp_global_deinit(struct dpp_global *dpp); 540e5b75505Sopenharmony_ci 541e5b75505Sopenharmony_ci#endif /* CONFIG_DPP */ 542e5b75505Sopenharmony_ci#endif /* DPP_H */ 543