Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 1 | /* |
| 2 | * DPP functionality shared between hostapd and wpa_supplicant |
| 3 | * Copyright (c) 2017, Qualcomm Atheros, Inc. |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 4 | * Copyright (c) 2018-2020, The Linux Foundation |
Hai Shalom | a20dcd7 | 2022-02-04 13:43:00 -0800 | [diff] [blame] | 5 | * Copyright (c) 2021-2022, Qualcomm Innovation Center, Inc. |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 6 | * |
| 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 Shalom | 021b0b5 | 2019-04-10 11:17:58 -0700 | [diff] [blame] | 14 | #ifdef CONFIG_DPP |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 15 | #include "utils/list.h" |
| 16 | #include "common/wpa_common.h" |
| 17 | #include "crypto/sha256.h" |
Hai Shalom | a20dcd7 | 2022-02-04 13:43:00 -0800 | [diff] [blame] | 18 | #include "crypto/crypto.h" |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 19 | |
Hai Shalom | 81f62d8 | 2019-07-22 12:10:00 -0700 | [diff] [blame] | 20 | struct hostapd_ip_addr; |
Hai Shalom | 021b0b5 | 2019-04-10 11:17:58 -0700 | [diff] [blame] | 21 | struct dpp_global; |
Hai Shalom | 4fbc08f | 2020-05-18 12:37:00 -0700 | [diff] [blame] | 22 | struct json_token; |
Hai Shalom | 899fcc7 | 2020-10-19 14:38:18 -0700 | [diff] [blame] | 23 | struct dpp_reconfig_id; |
Hai Shalom | 4fbc08f | 2020-05-18 12:37:00 -0700 | [diff] [blame] | 24 | |
| 25 | #ifdef CONFIG_TESTING_OPTIONS |
| 26 | #define DPP_VERSION (dpp_version_override) |
| 27 | extern int dpp_version_override; |
| 28 | #else /* CONFIG_TESTING_OPTIONS */ |
Hai Shalom | a20dcd7 | 2022-02-04 13:43:00 -0800 | [diff] [blame] | 29 | #ifdef CONFIG_DPP3 |
| 30 | #define DPP_VERSION 3 |
| 31 | #elif defined(CONFIG_DPP2) |
Hai Shalom | 4fbc08f | 2020-05-18 12:37:00 -0700 | [diff] [blame] | 32 | #define DPP_VERSION 2 |
| 33 | #else |
| 34 | #define DPP_VERSION 1 |
| 35 | #endif |
| 36 | #endif /* CONFIG_TESTING_OPTIONS */ |
Hai Shalom | 021b0b5 | 2019-04-10 11:17:58 -0700 | [diff] [blame] | 37 | |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 38 | #define DPP_HDR_LEN (4 + 2) /* OUI, OUI Type, Crypto Suite, DPP frame type */ |
Hai Shalom | 6084025 | 2021-02-19 19:02:11 -0800 | [diff] [blame] | 39 | #define DPP_TCP_PORT 8908 |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 40 | |
| 41 | enum 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 Shalom | a20dcd7 | 2022-02-04 13:43:00 -0800 | [diff] [blame] | 47 | DPP_PA_PKEX_V1_EXCHANGE_REQ = 7, |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 48 | DPP_PA_PKEX_EXCHANGE_RESP = 8, |
| 49 | DPP_PA_PKEX_COMMIT_REVEAL_REQ = 9, |
| 50 | DPP_PA_PKEX_COMMIT_REVEAL_RESP = 10, |
Hai Shalom | 021b0b5 | 2019-04-10 11:17:58 -0700 | [diff] [blame] | 51 | DPP_PA_CONFIGURATION_RESULT = 11, |
Hai Shalom | c356592 | 2019-10-28 11:58:20 -0700 | [diff] [blame] | 52 | DPP_PA_CONNECTION_STATUS_RESULT = 12, |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 53 | 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 Shalom | a20dcd7 | 2022-02-04 13:43:00 -0800 | [diff] [blame] | 58 | DPP_PA_PKEX_EXCHANGE_REQ = 18, |
Sunil Ravi | 89eba10 | 2022-09-13 21:04:37 -0700 | [diff] [blame^] | 59 | DPP_PA_PB_PRESENCE_ANNOUNCEMENT = 19, |
| 60 | DPP_PA_PB_PRESENCE_ANNOUNCEMENT_RESP = 20, |
| 61 | DPP_PA_PRIV_PEER_INTRO_QUERY = 21, |
| 62 | DPP_PA_PRIV_PEER_INTRO_NOTIFY = 22, |
| 63 | DPP_PA_PRIV_PEER_INTRO_UPDATE = 23, |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 64 | }; |
| 65 | |
| 66 | enum dpp_attribute_id { |
| 67 | DPP_ATTR_STATUS = 0x1000, |
| 68 | DPP_ATTR_I_BOOTSTRAP_KEY_HASH = 0x1001, |
| 69 | DPP_ATTR_R_BOOTSTRAP_KEY_HASH = 0x1002, |
| 70 | DPP_ATTR_I_PROTOCOL_KEY = 0x1003, |
| 71 | DPP_ATTR_WRAPPED_DATA = 0x1004, |
| 72 | DPP_ATTR_I_NONCE = 0x1005, |
| 73 | DPP_ATTR_I_CAPABILITIES = 0x1006, |
| 74 | DPP_ATTR_R_NONCE = 0x1007, |
| 75 | DPP_ATTR_R_CAPABILITIES = 0x1008, |
| 76 | DPP_ATTR_R_PROTOCOL_KEY = 0x1009, |
| 77 | DPP_ATTR_I_AUTH_TAG = 0x100A, |
| 78 | DPP_ATTR_R_AUTH_TAG = 0x100B, |
| 79 | DPP_ATTR_CONFIG_OBJ = 0x100C, |
| 80 | DPP_ATTR_CONNECTOR = 0x100D, |
| 81 | DPP_ATTR_CONFIG_ATTR_OBJ = 0x100E, |
| 82 | DPP_ATTR_BOOTSTRAP_KEY = 0x100F, |
| 83 | DPP_ATTR_OWN_NET_NK_HASH = 0x1011, |
| 84 | DPP_ATTR_FINITE_CYCLIC_GROUP = 0x1012, |
| 85 | DPP_ATTR_ENCRYPTED_KEY = 0x1013, |
| 86 | DPP_ATTR_ENROLLEE_NONCE = 0x1014, |
| 87 | DPP_ATTR_CODE_IDENTIFIER = 0x1015, |
| 88 | DPP_ATTR_TRANSACTION_ID = 0x1016, |
Roshan Pius | 3a1667e | 2018-07-03 15:17:14 -0700 | [diff] [blame] | 89 | DPP_ATTR_BOOTSTRAP_INFO = 0x1017, |
| 90 | DPP_ATTR_CHANNEL = 0x1018, |
Hai Shalom | 021b0b5 | 2019-04-10 11:17:58 -0700 | [diff] [blame] | 91 | DPP_ATTR_PROTOCOL_VERSION = 0x1019, |
| 92 | DPP_ATTR_ENVELOPED_DATA = 0x101A, |
Hai Shalom | c356592 | 2019-10-28 11:58:20 -0700 | [diff] [blame] | 93 | DPP_ATTR_SEND_CONN_STATUS = 0x101B, |
| 94 | DPP_ATTR_CONN_STATUS = 0x101C, |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 95 | DPP_ATTR_RECONFIG_FLAGS = 0x101D, |
| 96 | DPP_ATTR_C_SIGN_KEY_HASH = 0x101E, |
| 97 | DPP_ATTR_CSR_ATTR_REQ = 0x101F, |
Hai Shalom | 899fcc7 | 2020-10-19 14:38:18 -0700 | [diff] [blame] | 98 | DPP_ATTR_A_NONCE = 0x1020, |
| 99 | DPP_ATTR_E_PRIME_ID = 0x1021, |
| 100 | DPP_ATTR_CONFIGURATOR_NONCE = 0x1022, |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 101 | }; |
| 102 | |
| 103 | enum dpp_status_error { |
| 104 | DPP_STATUS_OK = 0, |
| 105 | DPP_STATUS_NOT_COMPATIBLE = 1, |
| 106 | DPP_STATUS_AUTH_FAILURE = 2, |
| 107 | DPP_STATUS_UNWRAP_FAILURE = 3, |
| 108 | DPP_STATUS_BAD_GROUP = 4, |
| 109 | DPP_STATUS_CONFIGURE_FAILURE = 5, |
| 110 | DPP_STATUS_RESPONSE_PENDING = 6, |
Roshan Pius | 3a1667e | 2018-07-03 15:17:14 -0700 | [diff] [blame] | 111 | DPP_STATUS_INVALID_CONNECTOR = 7, |
| 112 | DPP_STATUS_NO_MATCH = 8, |
Hai Shalom | 021b0b5 | 2019-04-10 11:17:58 -0700 | [diff] [blame] | 113 | DPP_STATUS_CONFIG_REJECTED = 9, |
Hai Shalom | c356592 | 2019-10-28 11:58:20 -0700 | [diff] [blame] | 114 | DPP_STATUS_NO_AP = 10, |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 115 | DPP_STATUS_CONFIGURE_PENDING = 11, |
| 116 | DPP_STATUS_CSR_NEEDED = 12, |
| 117 | DPP_STATUS_CSR_BAD = 13, |
Sunil Ravi | a04bd25 | 2022-05-02 22:54:18 -0700 | [diff] [blame] | 118 | DPP_STATUS_NEW_KEY_NEEDED = 14, |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 119 | }; |
| 120 | |
Hai Shalom | 4fbc08f | 2020-05-18 12:37:00 -0700 | [diff] [blame] | 121 | /* DPP Reconfig Flags object - connectorKey values */ |
| 122 | enum dpp_connector_key { |
| 123 | DPP_CONFIG_REUSEKEY = 0, |
| 124 | DPP_CONFIG_REPLACEKEY = 1, |
| 125 | }; |
| 126 | |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 127 | #define DPP_CAPAB_ENROLLEE BIT(0) |
| 128 | #define DPP_CAPAB_CONFIGURATOR BIT(1) |
| 129 | #define DPP_CAPAB_ROLE_MASK (BIT(0) | BIT(1)) |
| 130 | |
| 131 | #define DPP_BOOTSTRAP_MAX_FREQ 30 |
| 132 | #define DPP_MAX_NONCE_LEN 32 |
| 133 | #define DPP_MAX_HASH_LEN 64 |
| 134 | #define DPP_MAX_SHARED_SECRET_LEN 66 |
Hai Shalom | 899fcc7 | 2020-10-19 14:38:18 -0700 | [diff] [blame] | 135 | #define DPP_CP_LEN 64 |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 136 | |
| 137 | struct dpp_curve_params { |
| 138 | const char *name; |
| 139 | size_t hash_len; |
| 140 | size_t aes_siv_key_len; |
| 141 | size_t nonce_len; |
| 142 | size_t prime_len; |
| 143 | const char *jwk_crv; |
| 144 | u16 ike_group; |
| 145 | const char *jws_alg; |
| 146 | }; |
| 147 | |
| 148 | enum dpp_bootstrap_type { |
| 149 | DPP_BOOTSTRAP_QR_CODE, |
| 150 | DPP_BOOTSTRAP_PKEX, |
Ahmed ElArabawy | 0ff61c5 | 2019-12-26 12:38:39 -0800 | [diff] [blame] | 151 | DPP_BOOTSTRAP_NFC_URI, |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 152 | }; |
| 153 | |
Sunil Ravi | a04bd25 | 2022-05-02 22:54:18 -0700 | [diff] [blame] | 154 | enum dpp_bootstrap_supported_curves { |
| 155 | DPP_BOOTSTRAP_CURVE_P_256 = 0, |
| 156 | DPP_BOOTSTRAP_CURVE_P_384 = 1, |
| 157 | DPP_BOOTSTRAP_CURVE_P_521 = 2, |
| 158 | DPP_BOOTSTRAP_CURVE_BP_256 = 3, |
| 159 | DPP_BOOTSTRAP_CURVE_BP_384 = 4, |
| 160 | DPP_BOOTSTRAP_CURVE_BP_512 = 5, |
| 161 | }; |
| 162 | |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 163 | struct dpp_bootstrap_info { |
| 164 | struct dl_list list; |
| 165 | unsigned int id; |
| 166 | enum dpp_bootstrap_type type; |
| 167 | char *uri; |
| 168 | u8 mac_addr[ETH_ALEN]; |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 169 | char *chan; |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 170 | char *info; |
Sunil | 8cd6f4d | 2022-06-28 18:40:46 +0000 | [diff] [blame] | 171 | struct hostapd_ip_addr *host; |
| 172 | unsigned int port; |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 173 | char *pk; |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 174 | unsigned int freq[DPP_BOOTSTRAP_MAX_FREQ]; |
| 175 | unsigned int num_freq; |
Hai Shalom | 899fcc7 | 2020-10-19 14:38:18 -0700 | [diff] [blame] | 176 | bool channels_listed; |
Hai Shalom | 4fbc08f | 2020-05-18 12:37:00 -0700 | [diff] [blame] | 177 | u8 version; |
Sunil Ravi | a04bd25 | 2022-05-02 22:54:18 -0700 | [diff] [blame] | 178 | u8 supported_curves; /* enum dpp_bootstrap_supported_curves bitmap */ |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 179 | int own; |
Hai Shalom | a20dcd7 | 2022-02-04 13:43:00 -0800 | [diff] [blame] | 180 | struct crypto_ec_key *pubkey; |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 181 | u8 pubkey_hash[SHA256_MAC_LEN]; |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 182 | u8 pubkey_hash_chirp[SHA256_MAC_LEN]; |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 183 | const struct dpp_curve_params *curve; |
Roshan Pius | 3a1667e | 2018-07-03 15:17:14 -0700 | [diff] [blame] | 184 | unsigned int pkex_t; /* number of failures before dpp_pkex |
| 185 | * instantiation */ |
Hai Shalom | b755a2a | 2020-04-23 21:49:02 -0700 | [diff] [blame] | 186 | int nfc_negotiated; /* whether this has been used in NFC negotiated |
| 187 | * connection handover */ |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 188 | char *configurator_params; |
Sunil Ravi | 89eba10 | 2022-09-13 21:04:37 -0700 | [diff] [blame^] | 189 | u8 peer_pubkey_hash[SHA256_MAC_LEN]; /* for enforcing a specific |
| 190 | * peer bootstrapping key with |
| 191 | * PKEX */ |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 192 | }; |
| 193 | |
Roshan Pius | 3a1667e | 2018-07-03 15:17:14 -0700 | [diff] [blame] | 194 | #define PKEX_COUNTER_T_LIMIT 5 |
| 195 | |
Sunil Ravi | a04bd25 | 2022-05-02 22:54:18 -0700 | [diff] [blame] | 196 | enum dpp_pkex_ver { |
| 197 | PKEX_VER_AUTO, |
| 198 | PKEX_VER_ONLY_1, |
| 199 | PKEX_VER_ONLY_2, |
| 200 | }; |
| 201 | |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 202 | struct dpp_pkex { |
Roshan Pius | 3a1667e | 2018-07-03 15:17:14 -0700 | [diff] [blame] | 203 | void *msg_ctx; |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 204 | unsigned int initiator:1; |
| 205 | unsigned int exchange_done:1; |
Roshan Pius | 3a1667e | 2018-07-03 15:17:14 -0700 | [diff] [blame] | 206 | unsigned int failed:1; |
Hai Shalom | a20dcd7 | 2022-02-04 13:43:00 -0800 | [diff] [blame] | 207 | unsigned int v2:1; |
| 208 | unsigned int forced_ver:1; |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 209 | struct dpp_bootstrap_info *own_bi; |
| 210 | u8 own_mac[ETH_ALEN]; |
| 211 | u8 peer_mac[ETH_ALEN]; |
| 212 | char *identifier; |
| 213 | char *code; |
Sunil Ravi | 89eba10 | 2022-09-13 21:04:37 -0700 | [diff] [blame^] | 214 | size_t code_len; |
Hai Shalom | a20dcd7 | 2022-02-04 13:43:00 -0800 | [diff] [blame] | 215 | struct crypto_ec_key *x; |
| 216 | struct crypto_ec_key *y; |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 217 | u8 Mx[DPP_MAX_SHARED_SECRET_LEN]; |
| 218 | u8 Nx[DPP_MAX_SHARED_SECRET_LEN]; |
| 219 | u8 z[DPP_MAX_HASH_LEN]; |
Hai Shalom | a20dcd7 | 2022-02-04 13:43:00 -0800 | [diff] [blame] | 220 | struct crypto_ec_key *peer_bootstrap_key; |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 221 | struct wpabuf *exchange_req; |
| 222 | struct wpabuf *exchange_resp; |
Roshan Pius | 3a1667e | 2018-07-03 15:17:14 -0700 | [diff] [blame] | 223 | unsigned int t; /* number of failures on code use */ |
| 224 | unsigned int exch_req_wait_time; |
| 225 | unsigned int exch_req_tries; |
| 226 | unsigned int freq; |
Hai Shalom | a20dcd7 | 2022-02-04 13:43:00 -0800 | [diff] [blame] | 227 | u8 peer_version; |
Sunil Ravi | 89eba10 | 2022-09-13 21:04:37 -0700 | [diff] [blame^] | 228 | struct wpabuf *enc_key; |
Roshan Pius | 3a1667e | 2018-07-03 15:17:14 -0700 | [diff] [blame] | 229 | }; |
| 230 | |
| 231 | enum dpp_akm { |
| 232 | DPP_AKM_UNKNOWN, |
| 233 | DPP_AKM_DPP, |
| 234 | DPP_AKM_PSK, |
| 235 | DPP_AKM_SAE, |
Hai Shalom | 021b0b5 | 2019-04-10 11:17:58 -0700 | [diff] [blame] | 236 | DPP_AKM_PSK_SAE, |
| 237 | DPP_AKM_SAE_DPP, |
| 238 | DPP_AKM_PSK_SAE_DPP, |
Hai Shalom | 899fcc7 | 2020-10-19 14:38:18 -0700 | [diff] [blame] | 239 | DPP_AKM_DOT1X, |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 240 | }; |
| 241 | |
Hai Shalom | c356592 | 2019-10-28 11:58:20 -0700 | [diff] [blame] | 242 | enum dpp_netrole { |
| 243 | DPP_NETROLE_STA, |
| 244 | DPP_NETROLE_AP, |
Ahmed ElArabawy | 0ff61c5 | 2019-12-26 12:38:39 -0800 | [diff] [blame] | 245 | DPP_NETROLE_CONFIGURATOR, |
Hai Shalom | c356592 | 2019-10-28 11:58:20 -0700 | [diff] [blame] | 246 | }; |
| 247 | |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 248 | struct dpp_configuration { |
| 249 | u8 ssid[32]; |
| 250 | size_t ssid_len; |
Ahmed ElArabawy | 0ff61c5 | 2019-12-26 12:38:39 -0800 | [diff] [blame] | 251 | int ssid_charset; |
Roshan Pius | 3a1667e | 2018-07-03 15:17:14 -0700 | [diff] [blame] | 252 | enum dpp_akm akm; |
Hai Shalom | c356592 | 2019-10-28 11:58:20 -0700 | [diff] [blame] | 253 | enum dpp_netrole netrole; |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 254 | |
| 255 | /* For DPP configuration (connector) */ |
| 256 | os_time_t netaccesskey_expiry; |
| 257 | |
| 258 | /* TODO: groups */ |
Hai Shalom | ce48b4a | 2018-09-05 11:41:35 -0700 | [diff] [blame] | 259 | char *group_id; |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 260 | |
| 261 | /* For legacy configuration */ |
| 262 | char *passphrase; |
| 263 | u8 psk[32]; |
Hai Shalom | 021b0b5 | 2019-04-10 11:17:58 -0700 | [diff] [blame] | 264 | int psk_set; |
Hai Shalom | 899fcc7 | 2020-10-19 14:38:18 -0700 | [diff] [blame] | 265 | |
| 266 | char *csrattrs; |
Sunil Ravi | 89eba10 | 2022-09-13 21:04:37 -0700 | [diff] [blame^] | 267 | char *extra_name; |
| 268 | char *extra_value; |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 269 | }; |
| 270 | |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 271 | struct dpp_asymmetric_key { |
| 272 | struct dpp_asymmetric_key *next; |
Hai Shalom | a20dcd7 | 2022-02-04 13:43:00 -0800 | [diff] [blame] | 273 | struct crypto_ec_key *csign; |
| 274 | struct crypto_ec_key *pp_key; |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 275 | char *config_template; |
| 276 | char *connector_template; |
| 277 | }; |
| 278 | |
Hai Shalom | c356592 | 2019-10-28 11:58:20 -0700 | [diff] [blame] | 279 | #define DPP_MAX_CONF_OBJ 10 |
Hai Shalom | 0676811 | 2019-12-04 15:49:43 -0800 | [diff] [blame] | 280 | #define DPP_MAX_CHANNELS 32 |
Hai Shalom | c356592 | 2019-10-28 11:58:20 -0700 | [diff] [blame] | 281 | |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 282 | struct dpp_authentication { |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 283 | struct dpp_global *global; |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 284 | void *msg_ctx; |
Hai Shalom | 021b0b5 | 2019-04-10 11:17:58 -0700 | [diff] [blame] | 285 | u8 peer_version; |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 286 | const struct dpp_curve_params *curve; |
Sunil Ravi | a04bd25 | 2022-05-02 22:54:18 -0700 | [diff] [blame] | 287 | const struct dpp_curve_params *new_curve; |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 288 | struct dpp_bootstrap_info *peer_bi; |
| 289 | struct dpp_bootstrap_info *own_bi; |
Roshan Pius | 3a1667e | 2018-07-03 15:17:14 -0700 | [diff] [blame] | 290 | struct dpp_bootstrap_info *tmp_own_bi; |
Hai Shalom | 899fcc7 | 2020-10-19 14:38:18 -0700 | [diff] [blame] | 291 | struct dpp_bootstrap_info *tmp_peer_bi; |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 292 | u8 waiting_pubkey_hash[SHA256_MAC_LEN]; |
| 293 | int response_pending; |
Hai Shalom | 4fbc08f | 2020-05-18 12:37:00 -0700 | [diff] [blame] | 294 | int reconfig; |
| 295 | enum dpp_connector_key reconfig_connector_key; |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 296 | enum dpp_status_error auth_resp_status; |
Hai Shalom | 021b0b5 | 2019-04-10 11:17:58 -0700 | [diff] [blame] | 297 | enum dpp_status_error conf_resp_status; |
Hai Shalom | 899fcc7 | 2020-10-19 14:38:18 -0700 | [diff] [blame] | 298 | enum dpp_status_error force_conf_resp_status; |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 299 | u8 peer_mac_addr[ETH_ALEN]; |
| 300 | u8 i_nonce[DPP_MAX_NONCE_LEN]; |
| 301 | u8 r_nonce[DPP_MAX_NONCE_LEN]; |
| 302 | u8 e_nonce[DPP_MAX_NONCE_LEN]; |
Hai Shalom | 899fcc7 | 2020-10-19 14:38:18 -0700 | [diff] [blame] | 303 | u8 c_nonce[DPP_MAX_NONCE_LEN]; |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 304 | u8 i_capab; |
| 305 | u8 r_capab; |
Hai Shalom | 899fcc7 | 2020-10-19 14:38:18 -0700 | [diff] [blame] | 306 | enum dpp_netrole e_netrole; |
Hai Shalom | a20dcd7 | 2022-02-04 13:43:00 -0800 | [diff] [blame] | 307 | struct crypto_ec_key *own_protocol_key; |
| 308 | struct crypto_ec_key *peer_protocol_key; |
| 309 | struct crypto_ec_key *reconfig_old_protocol_key; |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 310 | struct wpabuf *req_msg; |
| 311 | struct wpabuf *resp_msg; |
Hai Shalom | 4fbc08f | 2020-05-18 12:37:00 -0700 | [diff] [blame] | 312 | struct wpabuf *reconfig_req_msg; |
| 313 | struct wpabuf *reconfig_resp_msg; |
Roshan Pius | 3a1667e | 2018-07-03 15:17:14 -0700 | [diff] [blame] | 314 | /* Intersection of possible frequencies for initiating DPP |
| 315 | * Authentication exchange */ |
| 316 | unsigned int freq[DPP_BOOTSTRAP_MAX_FREQ]; |
| 317 | unsigned int num_freq, freq_idx; |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 318 | unsigned int curr_freq; |
Roshan Pius | 3a1667e | 2018-07-03 15:17:14 -0700 | [diff] [blame] | 319 | unsigned int neg_freq; |
| 320 | unsigned int num_freq_iters; |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 321 | size_t secret_len; |
| 322 | u8 Mx[DPP_MAX_SHARED_SECRET_LEN]; |
Roshan Pius | 3a1667e | 2018-07-03 15:17:14 -0700 | [diff] [blame] | 323 | size_t Mx_len; |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 324 | u8 Nx[DPP_MAX_SHARED_SECRET_LEN]; |
Roshan Pius | 3a1667e | 2018-07-03 15:17:14 -0700 | [diff] [blame] | 325 | size_t Nx_len; |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 326 | u8 Lx[DPP_MAX_SHARED_SECRET_LEN]; |
Roshan Pius | 3a1667e | 2018-07-03 15:17:14 -0700 | [diff] [blame] | 327 | size_t Lx_len; |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 328 | u8 k1[DPP_MAX_HASH_LEN]; |
| 329 | u8 k2[DPP_MAX_HASH_LEN]; |
| 330 | u8 ke[DPP_MAX_HASH_LEN]; |
Hai Shalom | 4fbc08f | 2020-05-18 12:37:00 -0700 | [diff] [blame] | 331 | u8 bk[DPP_MAX_HASH_LEN]; |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 332 | int initiator; |
Roshan Pius | 3a1667e | 2018-07-03 15:17:14 -0700 | [diff] [blame] | 333 | int waiting_auth_resp; |
| 334 | int waiting_auth_conf; |
| 335 | int auth_req_ack; |
| 336 | unsigned int auth_resp_tries; |
| 337 | u8 allowed_roles; |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 338 | int configurator; |
| 339 | int remove_on_tx_status; |
Hai Shalom | 021b0b5 | 2019-04-10 11:17:58 -0700 | [diff] [blame] | 340 | int connect_on_tx_status; |
| 341 | int waiting_conf_result; |
Hai Shalom | c356592 | 2019-10-28 11:58:20 -0700 | [diff] [blame] | 342 | int waiting_conn_status_result; |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 343 | int auth_success; |
Hai Shalom | 4fbc08f | 2020-05-18 12:37:00 -0700 | [diff] [blame] | 344 | bool reconfig_success; |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 345 | struct wpabuf *conf_req; |
Roshan Pius | 3a1667e | 2018-07-03 15:17:14 -0700 | [diff] [blame] | 346 | const struct wpabuf *conf_resp; /* owned by GAS server */ |
Hai Shalom | 899fcc7 | 2020-10-19 14:38:18 -0700 | [diff] [blame] | 347 | struct wpabuf *conf_resp_tcp; |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 348 | struct dpp_configuration *conf_ap; |
Hai Shalom | c356592 | 2019-10-28 11:58:20 -0700 | [diff] [blame] | 349 | struct dpp_configuration *conf2_ap; |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 350 | struct dpp_configuration *conf_sta; |
Hai Shalom | c356592 | 2019-10-28 11:58:20 -0700 | [diff] [blame] | 351 | struct dpp_configuration *conf2_sta; |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 352 | int provision_configurator; |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 353 | struct dpp_configurator *conf; |
Hai Shalom | c356592 | 2019-10-28 11:58:20 -0700 | [diff] [blame] | 354 | struct dpp_config_obj { |
| 355 | char *connector; /* received signedConnector */ |
| 356 | u8 ssid[SSID_MAX_LEN]; |
| 357 | u8 ssid_len; |
Ahmed ElArabawy | 0ff61c5 | 2019-12-26 12:38:39 -0800 | [diff] [blame] | 358 | int ssid_charset; |
Hai Shalom | c356592 | 2019-10-28 11:58:20 -0700 | [diff] [blame] | 359 | char passphrase[64]; |
| 360 | u8 psk[PMK_LEN]; |
| 361 | int psk_set; |
| 362 | enum dpp_akm akm; |
| 363 | struct wpabuf *c_sign_key; |
Hai Shalom | 899fcc7 | 2020-10-19 14:38:18 -0700 | [diff] [blame] | 364 | struct wpabuf *certbag; |
| 365 | struct wpabuf *certs; |
| 366 | struct wpabuf *cacert; |
| 367 | char *server_name; |
| 368 | struct wpabuf *pp_key; |
Hai Shalom | c356592 | 2019-10-28 11:58:20 -0700 | [diff] [blame] | 369 | } conf_obj[DPP_MAX_CONF_OBJ]; |
| 370 | unsigned int num_conf_obj; |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 371 | struct dpp_asymmetric_key *conf_key_pkg; |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 372 | struct wpabuf *net_access_key; |
| 373 | os_time_t net_access_key_expiry; |
Hai Shalom | c356592 | 2019-10-28 11:58:20 -0700 | [diff] [blame] | 374 | int send_conn_status; |
| 375 | int conn_status_requested; |
| 376 | int akm_use_selector; |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 377 | int configurator_set; |
Hai Shalom | 4fbc08f | 2020-05-18 12:37:00 -0700 | [diff] [blame] | 378 | u8 transaction_id; |
Hai Shalom | 899fcc7 | 2020-10-19 14:38:18 -0700 | [diff] [blame] | 379 | u8 *csrattrs; |
| 380 | size_t csrattrs_len; |
| 381 | bool waiting_csr; |
| 382 | struct wpabuf *csr; |
| 383 | struct wpabuf *priv_key; /* DER-encoded private key used for csr */ |
| 384 | bool waiting_cert; |
| 385 | char *trusted_eap_server_name; |
| 386 | struct wpabuf *cacert; |
| 387 | struct wpabuf *certbag; |
Sunil Ravi | a04bd25 | 2022-05-02 22:54:18 -0700 | [diff] [blame] | 388 | bool waiting_new_key; |
| 389 | bool new_key_received; |
Hai Shalom | a20dcd7 | 2022-02-04 13:43:00 -0800 | [diff] [blame] | 390 | void *config_resp_ctx; |
Hai Shalom | 6084025 | 2021-02-19 19:02:11 -0800 | [diff] [blame] | 391 | void *gas_server_ctx; |
Hai Shalom | a20dcd7 | 2022-02-04 13:43:00 -0800 | [diff] [blame] | 392 | bool use_config_query; |
| 393 | bool waiting_config; |
| 394 | char *e_name; |
| 395 | char *e_mud_url; |
| 396 | int *e_band_support; |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 397 | #ifdef CONFIG_TESTING_OPTIONS |
| 398 | char *config_obj_override; |
| 399 | char *discovery_override; |
| 400 | char *groups_override; |
| 401 | unsigned int ignore_netaccesskey_mismatch:1; |
| 402 | #endif /* CONFIG_TESTING_OPTIONS */ |
Hai Shalom | 0676811 | 2019-12-04 15:49:43 -0800 | [diff] [blame] | 403 | unsigned short band_list[DPP_MAX_CHANNELS]; |
| 404 | int band_list_size; |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 405 | }; |
| 406 | |
| 407 | struct dpp_configurator { |
| 408 | struct dl_list list; |
| 409 | unsigned int id; |
| 410 | int own; |
Hai Shalom | a20dcd7 | 2022-02-04 13:43:00 -0800 | [diff] [blame] | 411 | struct crypto_ec_key *csign; |
Hai Shalom | 4fbc08f | 2020-05-18 12:37:00 -0700 | [diff] [blame] | 412 | u8 kid_hash[SHA256_MAC_LEN]; |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 413 | char *kid; |
| 414 | const struct dpp_curve_params *curve; |
Sunil Ravi | a04bd25 | 2022-05-02 22:54:18 -0700 | [diff] [blame] | 415 | const struct dpp_curve_params *net_access_key_curve; |
Hai Shalom | 4fbc08f | 2020-05-18 12:37:00 -0700 | [diff] [blame] | 416 | char *connector; /* own Connector for reconfiguration */ |
Hai Shalom | a20dcd7 | 2022-02-04 13:43:00 -0800 | [diff] [blame] | 417 | struct crypto_ec_key *connector_key; |
| 418 | struct crypto_ec_key *pp_key; |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 419 | }; |
| 420 | |
| 421 | struct dpp_introduction { |
| 422 | u8 pmkid[PMKID_LEN]; |
| 423 | u8 pmk[PMK_LEN_MAX]; |
| 424 | size_t pmk_len; |
Hai Shalom | a20dcd7 | 2022-02-04 13:43:00 -0800 | [diff] [blame] | 425 | int peer_version; |
Sunil Ravi | 89eba10 | 2022-09-13 21:04:37 -0700 | [diff] [blame^] | 426 | struct crypto_ec_key *peer_key; |
| 427 | enum hpke_kem_id kem_id; |
| 428 | enum hpke_kdf_id kdf_id; |
| 429 | enum hpke_aead_id aead_id; |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 430 | }; |
| 431 | |
Hai Shalom | 81f62d8 | 2019-07-22 12:10:00 -0700 | [diff] [blame] | 432 | struct dpp_relay_config { |
| 433 | const struct hostapd_ip_addr *ipaddr; |
| 434 | const u8 *pkhash; |
| 435 | |
Hai Shalom | 899fcc7 | 2020-10-19 14:38:18 -0700 | [diff] [blame] | 436 | void *msg_ctx; |
Hai Shalom | 81f62d8 | 2019-07-22 12:10:00 -0700 | [diff] [blame] | 437 | void *cb_ctx; |
| 438 | void (*tx)(void *ctx, const u8 *addr, unsigned int freq, const u8 *msg, |
| 439 | size_t len); |
| 440 | void (*gas_resp_tx)(void *ctx, const u8 *addr, u8 dialog_token, int prot, |
| 441 | struct wpabuf *buf); |
| 442 | }; |
| 443 | |
| 444 | struct dpp_controller_config { |
| 445 | const char *configurator_params; |
| 446 | int tcp_port; |
Hai Shalom | 4fbc08f | 2020-05-18 12:37:00 -0700 | [diff] [blame] | 447 | u8 allowed_roles; |
Hai Shalom | 899fcc7 | 2020-10-19 14:38:18 -0700 | [diff] [blame] | 448 | int qr_mutual; |
| 449 | enum dpp_netrole netrole; |
| 450 | void *msg_ctx; |
| 451 | void *cb_ctx; |
| 452 | int (*process_conf_obj)(void *ctx, struct dpp_authentication *auth); |
Hai Shalom | a20dcd7 | 2022-02-04 13:43:00 -0800 | [diff] [blame] | 453 | bool (*tcp_msg_sent)(void *ctx, struct dpp_authentication *auth); |
Hai Shalom | 81f62d8 | 2019-07-22 12:10:00 -0700 | [diff] [blame] | 454 | }; |
| 455 | |
Sunil Ravi | 89eba10 | 2022-09-13 21:04:37 -0700 | [diff] [blame^] | 456 | #define DPP_PB_INFO_COUNT 2 |
| 457 | |
| 458 | struct dpp_pb_info { |
| 459 | u8 hash[SHA256_MAC_LEN]; |
| 460 | struct os_reltime rx_time; |
| 461 | }; |
| 462 | |
Roshan Pius | 3a1667e | 2018-07-03 15:17:14 -0700 | [diff] [blame] | 463 | #ifdef CONFIG_TESTING_OPTIONS |
| 464 | enum dpp_test_behavior { |
| 465 | DPP_TEST_DISABLED = 0, |
| 466 | DPP_TEST_AFTER_WRAPPED_DATA_AUTH_REQ = 1, |
| 467 | DPP_TEST_AFTER_WRAPPED_DATA_AUTH_RESP = 2, |
| 468 | DPP_TEST_AFTER_WRAPPED_DATA_AUTH_CONF = 3, |
| 469 | DPP_TEST_AFTER_WRAPPED_DATA_PKEX_CR_REQ = 4, |
| 470 | DPP_TEST_AFTER_WRAPPED_DATA_PKEX_CR_RESP = 5, |
| 471 | DPP_TEST_AFTER_WRAPPED_DATA_CONF_REQ = 6, |
| 472 | DPP_TEST_AFTER_WRAPPED_DATA_CONF_RESP = 7, |
| 473 | DPP_TEST_ZERO_I_CAPAB = 8, |
| 474 | DPP_TEST_ZERO_R_CAPAB = 9, |
| 475 | DPP_TEST_NO_R_BOOTSTRAP_KEY_HASH_AUTH_REQ = 10, |
| 476 | DPP_TEST_NO_I_BOOTSTRAP_KEY_HASH_AUTH_REQ = 11, |
| 477 | DPP_TEST_NO_I_PROTO_KEY_AUTH_REQ = 12, |
| 478 | DPP_TEST_NO_I_NONCE_AUTH_REQ = 13, |
| 479 | DPP_TEST_NO_I_CAPAB_AUTH_REQ = 14, |
| 480 | DPP_TEST_NO_WRAPPED_DATA_AUTH_REQ = 15, |
| 481 | DPP_TEST_NO_STATUS_AUTH_RESP = 16, |
| 482 | DPP_TEST_NO_R_BOOTSTRAP_KEY_HASH_AUTH_RESP = 17, |
| 483 | DPP_TEST_NO_I_BOOTSTRAP_KEY_HASH_AUTH_RESP = 18, |
| 484 | DPP_TEST_NO_R_PROTO_KEY_AUTH_RESP = 19, |
| 485 | DPP_TEST_NO_R_NONCE_AUTH_RESP = 20, |
| 486 | DPP_TEST_NO_I_NONCE_AUTH_RESP = 21, |
| 487 | DPP_TEST_NO_R_CAPAB_AUTH_RESP = 22, |
| 488 | DPP_TEST_NO_R_AUTH_AUTH_RESP = 23, |
| 489 | DPP_TEST_NO_WRAPPED_DATA_AUTH_RESP = 24, |
| 490 | DPP_TEST_NO_STATUS_AUTH_CONF = 25, |
| 491 | DPP_TEST_NO_R_BOOTSTRAP_KEY_HASH_AUTH_CONF = 26, |
| 492 | DPP_TEST_NO_I_BOOTSTRAP_KEY_HASH_AUTH_CONF = 27, |
| 493 | DPP_TEST_NO_I_AUTH_AUTH_CONF = 28, |
| 494 | DPP_TEST_NO_WRAPPED_DATA_AUTH_CONF = 29, |
| 495 | DPP_TEST_I_NONCE_MISMATCH_AUTH_RESP = 30, |
| 496 | DPP_TEST_INCOMPATIBLE_R_CAPAB_AUTH_RESP = 31, |
| 497 | DPP_TEST_R_AUTH_MISMATCH_AUTH_RESP = 32, |
| 498 | DPP_TEST_I_AUTH_MISMATCH_AUTH_CONF = 33, |
| 499 | DPP_TEST_NO_FINITE_CYCLIC_GROUP_PKEX_EXCHANGE_REQ = 34, |
| 500 | DPP_TEST_NO_ENCRYPTED_KEY_PKEX_EXCHANGE_REQ = 35, |
| 501 | DPP_TEST_NO_STATUS_PKEX_EXCHANGE_RESP = 36, |
| 502 | DPP_TEST_NO_ENCRYPTED_KEY_PKEX_EXCHANGE_RESP = 37, |
| 503 | DPP_TEST_NO_BOOTSTRAP_KEY_PKEX_CR_REQ = 38, |
| 504 | DPP_TEST_NO_I_AUTH_TAG_PKEX_CR_REQ = 39, |
| 505 | DPP_TEST_NO_WRAPPED_DATA_PKEX_CR_REQ = 40, |
| 506 | DPP_TEST_NO_BOOTSTRAP_KEY_PKEX_CR_RESP = 41, |
| 507 | DPP_TEST_NO_R_AUTH_TAG_PKEX_CR_RESP = 42, |
| 508 | DPP_TEST_NO_WRAPPED_DATA_PKEX_CR_RESP = 43, |
| 509 | DPP_TEST_INVALID_ENCRYPTED_KEY_PKEX_EXCHANGE_REQ = 44, |
| 510 | DPP_TEST_INVALID_ENCRYPTED_KEY_PKEX_EXCHANGE_RESP = 45, |
| 511 | DPP_TEST_INVALID_STATUS_PKEX_EXCHANGE_RESP = 46, |
| 512 | DPP_TEST_INVALID_BOOTSTRAP_KEY_PKEX_CR_REQ = 47, |
| 513 | DPP_TEST_INVALID_BOOTSTRAP_KEY_PKEX_CR_RESP = 48, |
| 514 | DPP_TEST_I_AUTH_TAG_MISMATCH_PKEX_CR_REQ = 49, |
| 515 | DPP_TEST_R_AUTH_TAG_MISMATCH_PKEX_CR_RESP = 50, |
| 516 | DPP_TEST_NO_E_NONCE_CONF_REQ = 51, |
| 517 | DPP_TEST_NO_CONFIG_ATTR_OBJ_CONF_REQ = 52, |
| 518 | DPP_TEST_NO_WRAPPED_DATA_CONF_REQ = 53, |
| 519 | DPP_TEST_NO_E_NONCE_CONF_RESP = 54, |
| 520 | DPP_TEST_NO_CONFIG_OBJ_CONF_RESP = 55, |
| 521 | DPP_TEST_NO_STATUS_CONF_RESP = 56, |
| 522 | DPP_TEST_NO_WRAPPED_DATA_CONF_RESP = 57, |
| 523 | DPP_TEST_INVALID_STATUS_CONF_RESP = 58, |
| 524 | DPP_TEST_E_NONCE_MISMATCH_CONF_RESP = 59, |
| 525 | DPP_TEST_NO_TRANSACTION_ID_PEER_DISC_REQ = 60, |
| 526 | DPP_TEST_NO_CONNECTOR_PEER_DISC_REQ = 61, |
| 527 | DPP_TEST_NO_TRANSACTION_ID_PEER_DISC_RESP = 62, |
| 528 | DPP_TEST_NO_STATUS_PEER_DISC_RESP = 63, |
| 529 | DPP_TEST_NO_CONNECTOR_PEER_DISC_RESP = 64, |
| 530 | DPP_TEST_AUTH_RESP_IN_PLACE_OF_CONF = 65, |
| 531 | DPP_TEST_INVALID_I_PROTO_KEY_AUTH_REQ = 66, |
| 532 | DPP_TEST_INVALID_R_PROTO_KEY_AUTH_RESP = 67, |
| 533 | DPP_TEST_INVALID_R_BOOTSTRAP_KEY_HASH_AUTH_REQ = 68, |
| 534 | DPP_TEST_INVALID_I_BOOTSTRAP_KEY_HASH_AUTH_REQ = 69, |
| 535 | DPP_TEST_INVALID_R_BOOTSTRAP_KEY_HASH_AUTH_RESP = 70, |
| 536 | DPP_TEST_INVALID_I_BOOTSTRAP_KEY_HASH_AUTH_RESP = 71, |
| 537 | DPP_TEST_INVALID_R_BOOTSTRAP_KEY_HASH_AUTH_CONF = 72, |
| 538 | DPP_TEST_INVALID_I_BOOTSTRAP_KEY_HASH_AUTH_CONF = 73, |
| 539 | DPP_TEST_INVALID_STATUS_AUTH_RESP = 74, |
| 540 | DPP_TEST_INVALID_STATUS_AUTH_CONF = 75, |
| 541 | DPP_TEST_INVALID_CONFIG_ATTR_OBJ_CONF_REQ = 76, |
| 542 | DPP_TEST_INVALID_TRANSACTION_ID_PEER_DISC_RESP = 77, |
| 543 | DPP_TEST_INVALID_STATUS_PEER_DISC_RESP = 78, |
| 544 | DPP_TEST_INVALID_CONNECTOR_PEER_DISC_RESP = 79, |
| 545 | DPP_TEST_INVALID_CONNECTOR_PEER_DISC_REQ = 80, |
| 546 | DPP_TEST_INVALID_I_NONCE_AUTH_REQ = 81, |
| 547 | DPP_TEST_INVALID_TRANSACTION_ID_PEER_DISC_REQ = 82, |
| 548 | DPP_TEST_INVALID_E_NONCE_CONF_REQ = 83, |
| 549 | DPP_TEST_STOP_AT_PKEX_EXCHANGE_RESP = 84, |
| 550 | DPP_TEST_STOP_AT_PKEX_CR_REQ = 85, |
| 551 | DPP_TEST_STOP_AT_PKEX_CR_RESP = 86, |
| 552 | DPP_TEST_STOP_AT_AUTH_REQ = 87, |
| 553 | DPP_TEST_STOP_AT_AUTH_RESP = 88, |
| 554 | DPP_TEST_STOP_AT_AUTH_CONF = 89, |
| 555 | DPP_TEST_STOP_AT_CONF_REQ = 90, |
Hai Shalom | 021b0b5 | 2019-04-10 11:17:58 -0700 | [diff] [blame] | 556 | DPP_TEST_REJECT_CONFIG = 91, |
Hai Shalom | a20dcd7 | 2022-02-04 13:43:00 -0800 | [diff] [blame] | 557 | DPP_TEST_NO_PROTOCOL_VERSION_PEER_DISC_REQ = 92, |
| 558 | DPP_TEST_NO_PROTOCOL_VERSION_PEER_DISC_RESP = 93, |
| 559 | DPP_TEST_INVALID_PROTOCOL_VERSION_PEER_DISC_REQ = 94, |
| 560 | DPP_TEST_INVALID_PROTOCOL_VERSION_PEER_DISC_RESP = 95, |
Sunil Ravi | a04bd25 | 2022-05-02 22:54:18 -0700 | [diff] [blame] | 561 | DPP_TEST_INVALID_PROTOCOL_VERSION_RECONFIG_AUTH_REQ = 96, |
| 562 | DPP_TEST_NO_PROTOCOL_VERSION_RECONFIG_AUTH_REQ = 97, |
Sunil Ravi | 89eba10 | 2022-09-13 21:04:37 -0700 | [diff] [blame^] | 563 | DPP_TEST_INVALID_R_BOOTSTRAP_KEY_HASH_PB_REQ = 98, |
| 564 | DPP_TEST_INVALID_I_BOOTSTRAP_KEY_HASH_PB_RESP = 99, |
| 565 | DPP_TEST_INVALID_R_BOOTSTRAP_KEY_HASH_PB_RESP = 100, |
Roshan Pius | 3a1667e | 2018-07-03 15:17:14 -0700 | [diff] [blame] | 566 | }; |
| 567 | |
| 568 | extern enum dpp_test_behavior dpp_test; |
| 569 | extern u8 dpp_pkex_own_mac_override[ETH_ALEN]; |
| 570 | extern u8 dpp_pkex_peer_mac_override[ETH_ALEN]; |
| 571 | extern u8 dpp_pkex_ephemeral_key_override[600]; |
| 572 | extern size_t dpp_pkex_ephemeral_key_override_len; |
| 573 | extern u8 dpp_protocol_key_override[600]; |
| 574 | extern size_t dpp_protocol_key_override_len; |
| 575 | extern u8 dpp_nonce_override[DPP_MAX_NONCE_LEN]; |
| 576 | extern size_t dpp_nonce_override_len; |
| 577 | #endif /* CONFIG_TESTING_OPTIONS */ |
| 578 | |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 579 | void dpp_bootstrap_info_free(struct dpp_bootstrap_info *info); |
| 580 | const char * dpp_bootstrap_type_txt(enum dpp_bootstrap_type type); |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 581 | int dpp_parse_uri_chan_list(struct dpp_bootstrap_info *bi, |
| 582 | const char *chan_list); |
| 583 | int dpp_parse_uri_mac(struct dpp_bootstrap_info *bi, const char *mac); |
| 584 | int dpp_parse_uri_info(struct dpp_bootstrap_info *bi, const char *info); |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 585 | int dpp_nfc_update_bi(struct dpp_bootstrap_info *own_bi, |
| 586 | struct dpp_bootstrap_info *peer_bi); |
Hai Shalom | a20dcd7 | 2022-02-04 13:43:00 -0800 | [diff] [blame] | 587 | const char * dpp_netrole_str(enum dpp_netrole netrole); |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 588 | struct dpp_authentication * |
| 589 | dpp_alloc_auth(struct dpp_global *dpp, void *msg_ctx); |
Roshan Pius | 3a1667e | 2018-07-03 15:17:14 -0700 | [diff] [blame] | 590 | struct hostapd_hw_modes; |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 591 | struct dpp_authentication * dpp_auth_init(struct dpp_global *dpp, void *msg_ctx, |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 592 | struct dpp_bootstrap_info *peer_bi, |
| 593 | struct dpp_bootstrap_info *own_bi, |
Roshan Pius | 3a1667e | 2018-07-03 15:17:14 -0700 | [diff] [blame] | 594 | u8 dpp_allowed_roles, |
| 595 | unsigned int neg_freq, |
| 596 | struct hostapd_hw_modes *own_modes, |
| 597 | u16 num_modes); |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 598 | struct dpp_authentication * |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 599 | dpp_auth_req_rx(struct dpp_global *dpp, void *msg_ctx, u8 dpp_allowed_roles, |
| 600 | int qr_mutual, struct dpp_bootstrap_info *peer_bi, |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 601 | struct dpp_bootstrap_info *own_bi, |
| 602 | unsigned int freq, const u8 *hdr, const u8 *attr_start, |
Roshan Pius | 3a1667e | 2018-07-03 15:17:14 -0700 | [diff] [blame] | 603 | size_t attr_len); |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 604 | struct wpabuf * |
| 605 | dpp_auth_resp_rx(struct dpp_authentication *auth, const u8 *hdr, |
| 606 | const u8 *attr_start, size_t attr_len); |
| 607 | struct wpabuf * dpp_build_conf_req(struct dpp_authentication *auth, |
| 608 | const char *json); |
Hai Shalom | c356592 | 2019-10-28 11:58:20 -0700 | [diff] [blame] | 609 | struct wpabuf * dpp_build_conf_req_helper(struct dpp_authentication *auth, |
Ahmed ElArabawy | 0ff61c5 | 2019-12-26 12:38:39 -0800 | [diff] [blame] | 610 | const char *name, |
| 611 | enum dpp_netrole netrole, |
Sunil Ravi | 89eba10 | 2022-09-13 21:04:37 -0700 | [diff] [blame^] | 612 | const char *mud_url, int *opclasses, |
| 613 | const char *extra_name, |
| 614 | const char *extra_value); |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 615 | int dpp_auth_conf_rx(struct dpp_authentication *auth, const u8 *hdr, |
| 616 | const u8 *attr_start, size_t attr_len); |
| 617 | int dpp_notify_new_qr_code(struct dpp_authentication *auth, |
| 618 | struct dpp_bootstrap_info *peer_bi); |
Hai Shalom | a20dcd7 | 2022-02-04 13:43:00 -0800 | [diff] [blame] | 619 | void dpp_controller_pkex_add(struct dpp_global *dpp, |
| 620 | struct dpp_bootstrap_info *bi, |
| 621 | const char *code, const char *identifier); |
Sunil Ravi | 89eba10 | 2022-09-13 21:04:37 -0700 | [diff] [blame^] | 622 | bool dpp_controller_is_own_pkex_req(struct dpp_global *dpp, |
| 623 | const u8 *buf, size_t len); |
Hai Shalom | 021b0b5 | 2019-04-10 11:17:58 -0700 | [diff] [blame] | 624 | struct dpp_configuration * dpp_configuration_alloc(const char *type); |
| 625 | int dpp_akm_psk(enum dpp_akm akm); |
| 626 | int dpp_akm_sae(enum dpp_akm akm); |
| 627 | int dpp_akm_legacy(enum dpp_akm akm); |
| 628 | int dpp_akm_dpp(enum dpp_akm akm); |
| 629 | int dpp_akm_ver2(enum dpp_akm akm); |
| 630 | int dpp_configuration_valid(const struct dpp_configuration *conf); |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 631 | void dpp_configuration_free(struct dpp_configuration *conf); |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 632 | int dpp_set_configurator(struct dpp_authentication *auth, const char *cmd); |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 633 | void dpp_auth_deinit(struct dpp_authentication *auth); |
| 634 | struct wpabuf * |
Hai Shalom | 899fcc7 | 2020-10-19 14:38:18 -0700 | [diff] [blame] | 635 | dpp_build_conf_resp(struct dpp_authentication *auth, const u8 *e_nonce, |
| 636 | u16 e_nonce_len, enum dpp_netrole netrole, |
| 637 | bool cert_req); |
| 638 | struct wpabuf * |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 639 | dpp_conf_req_rx(struct dpp_authentication *auth, const u8 *attr_start, |
| 640 | size_t attr_len); |
| 641 | int dpp_conf_resp_rx(struct dpp_authentication *auth, |
| 642 | const struct wpabuf *resp); |
Hai Shalom | 021b0b5 | 2019-04-10 11:17:58 -0700 | [diff] [blame] | 643 | enum dpp_status_error dpp_conf_result_rx(struct dpp_authentication *auth, |
| 644 | const u8 *hdr, |
| 645 | const u8 *attr_start, size_t attr_len); |
| 646 | struct wpabuf * dpp_build_conf_result(struct dpp_authentication *auth, |
| 647 | enum dpp_status_error status); |
Hai Shalom | c356592 | 2019-10-28 11:58:20 -0700 | [diff] [blame] | 648 | enum dpp_status_error dpp_conn_status_result_rx(struct dpp_authentication *auth, |
| 649 | const u8 *hdr, |
| 650 | const u8 *attr_start, |
| 651 | size_t attr_len, |
| 652 | u8 *ssid, size_t *ssid_len, |
| 653 | char **channel_list); |
| 654 | struct wpabuf * dpp_build_conn_status_result(struct dpp_authentication *auth, |
| 655 | enum dpp_status_error result, |
| 656 | const u8 *ssid, size_t ssid_len, |
| 657 | const char *channel_list); |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 658 | struct wpabuf * dpp_alloc_msg(enum dpp_public_action_frame_type type, |
| 659 | size_t len); |
| 660 | const u8 * dpp_get_attr(const u8 *buf, size_t len, u16 req_id, u16 *ret_len); |
| 661 | int dpp_check_attrs(const u8 *buf, size_t len); |
| 662 | int dpp_key_expired(const char *timestamp, os_time_t *expiry); |
Roshan Pius | 3a1667e | 2018-07-03 15:17:14 -0700 | [diff] [blame] | 663 | const char * dpp_akm_str(enum dpp_akm akm); |
Hai Shalom | c356592 | 2019-10-28 11:58:20 -0700 | [diff] [blame] | 664 | const char * dpp_akm_selector_str(enum dpp_akm akm); |
Roshan Pius | 3a1667e | 2018-07-03 15:17:14 -0700 | [diff] [blame] | 665 | int dpp_configurator_get_key(const struct dpp_configurator *conf, char *buf, |
| 666 | size_t buflen); |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 667 | void dpp_configurator_free(struct dpp_configurator *conf); |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 668 | int dpp_configurator_own_config(struct dpp_authentication *auth, |
Roshan Pius | 3a1667e | 2018-07-03 15:17:14 -0700 | [diff] [blame] | 669 | const char *curve, int ap); |
| 670 | enum dpp_status_error |
| 671 | dpp_peer_intro(struct dpp_introduction *intro, const char *own_connector, |
| 672 | const u8 *net_access_key, size_t net_access_key_len, |
| 673 | const u8 *csign_key, size_t csign_key_len, |
| 674 | const u8 *peer_connector, size_t peer_connector_len, |
| 675 | os_time_t *expiry); |
Sunil Ravi | 89eba10 | 2022-09-13 21:04:37 -0700 | [diff] [blame^] | 676 | void dpp_peer_intro_deinit(struct dpp_introduction *intro); |
Hai Shalom | a20dcd7 | 2022-02-04 13:43:00 -0800 | [diff] [blame] | 677 | int dpp_get_connector_version(const char *connector); |
Roshan Pius | 3a1667e | 2018-07-03 15:17:14 -0700 | [diff] [blame] | 678 | struct dpp_pkex * dpp_pkex_init(void *msg_ctx, struct dpp_bootstrap_info *bi, |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 679 | const u8 *own_mac, |
Hai Shalom | a20dcd7 | 2022-02-04 13:43:00 -0800 | [diff] [blame] | 680 | const char *identifier, const char *code, |
Sunil Ravi | 89eba10 | 2022-09-13 21:04:37 -0700 | [diff] [blame^] | 681 | size_t code_len, bool v2); |
Roshan Pius | 3a1667e | 2018-07-03 15:17:14 -0700 | [diff] [blame] | 682 | struct dpp_pkex * dpp_pkex_rx_exchange_req(void *msg_ctx, |
| 683 | struct dpp_bootstrap_info *bi, |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 684 | const u8 *own_mac, |
| 685 | const u8 *peer_mac, |
| 686 | const char *identifier, |
Sunil Ravi | 89eba10 | 2022-09-13 21:04:37 -0700 | [diff] [blame^] | 687 | const char *code, size_t code_len, |
Hai Shalom | a20dcd7 | 2022-02-04 13:43:00 -0800 | [diff] [blame] | 688 | const u8 *buf, size_t len, bool v2); |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 689 | struct wpabuf * dpp_pkex_rx_exchange_resp(struct dpp_pkex *pkex, |
Roshan Pius | 3a1667e | 2018-07-03 15:17:14 -0700 | [diff] [blame] | 690 | const u8 *peer_mac, |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 691 | const u8 *buf, size_t len); |
| 692 | struct wpabuf * dpp_pkex_rx_commit_reveal_req(struct dpp_pkex *pkex, |
| 693 | const u8 *hdr, |
| 694 | const u8 *buf, size_t len); |
| 695 | int dpp_pkex_rx_commit_reveal_resp(struct dpp_pkex *pkex, const u8 *hdr, |
| 696 | const u8 *buf, size_t len); |
| 697 | void dpp_pkex_free(struct dpp_pkex *pkex); |
| 698 | |
Roshan Pius | 3a1667e | 2018-07-03 15:17:14 -0700 | [diff] [blame] | 699 | char * dpp_corrupt_connector_signature(const char *connector); |
| 700 | |
Hai Shalom | 021b0b5 | 2019-04-10 11:17:58 -0700 | [diff] [blame] | 701 | |
| 702 | struct dpp_pfs { |
| 703 | struct crypto_ecdh *ecdh; |
| 704 | const struct dpp_curve_params *curve; |
| 705 | struct wpabuf *ie; |
| 706 | struct wpabuf *secret; |
| 707 | }; |
| 708 | |
| 709 | struct dpp_pfs * dpp_pfs_init(const u8 *net_access_key, |
| 710 | size_t net_access_key_len); |
| 711 | int dpp_pfs_process(struct dpp_pfs *pfs, const u8 *peer_ie, size_t peer_ie_len); |
| 712 | void dpp_pfs_free(struct dpp_pfs *pfs); |
| 713 | |
Sunil Ravi | 89eba10 | 2022-09-13 21:04:37 -0700 | [diff] [blame^] | 714 | struct crypto_ec_key * dpp_set_keypair(const struct dpp_curve_params **curve, |
| 715 | const u8 *privkey, size_t privkey_len); |
| 716 | int dpp_hpke_suite(int iana_group, enum hpke_kem_id *kem_id, |
| 717 | enum hpke_kdf_id *kdf_id, enum hpke_aead_id *aead_id); |
| 718 | |
Hai Shalom | 899fcc7 | 2020-10-19 14:38:18 -0700 | [diff] [blame] | 719 | struct wpabuf * dpp_build_csr(struct dpp_authentication *auth, |
| 720 | const char *name); |
Hai Shalom | 899fcc7 | 2020-10-19 14:38:18 -0700 | [diff] [blame] | 721 | int dpp_validate_csr(struct dpp_authentication *auth, const struct wpabuf *csr); |
| 722 | |
Hai Shalom | 021b0b5 | 2019-04-10 11:17:58 -0700 | [diff] [blame] | 723 | struct dpp_bootstrap_info * dpp_add_qr_code(struct dpp_global *dpp, |
| 724 | const char *uri); |
Ahmed ElArabawy | 0ff61c5 | 2019-12-26 12:38:39 -0800 | [diff] [blame] | 725 | struct dpp_bootstrap_info * dpp_add_nfc_uri(struct dpp_global *dpp, |
| 726 | const char *uri); |
Hai Shalom | 021b0b5 | 2019-04-10 11:17:58 -0700 | [diff] [blame] | 727 | int dpp_bootstrap_gen(struct dpp_global *dpp, const char *cmd); |
| 728 | struct dpp_bootstrap_info * |
| 729 | dpp_bootstrap_get_id(struct dpp_global *dpp, unsigned int id); |
| 730 | int dpp_bootstrap_remove(struct dpp_global *dpp, const char *id); |
| 731 | struct dpp_bootstrap_info * |
| 732 | dpp_pkex_finish(struct dpp_global *dpp, struct dpp_pkex *pkex, const u8 *peer, |
| 733 | unsigned int freq); |
| 734 | const char * dpp_bootstrap_get_uri(struct dpp_global *dpp, unsigned int id); |
| 735 | int dpp_bootstrap_info(struct dpp_global *dpp, int id, |
| 736 | char *reply, int reply_size); |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 737 | int dpp_bootstrap_set(struct dpp_global *dpp, int id, const char *params); |
Hai Shalom | 021b0b5 | 2019-04-10 11:17:58 -0700 | [diff] [blame] | 738 | void dpp_bootstrap_find_pair(struct dpp_global *dpp, const u8 *i_bootstrap, |
| 739 | const u8 *r_bootstrap, |
| 740 | struct dpp_bootstrap_info **own_bi, |
| 741 | struct dpp_bootstrap_info **peer_bi); |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 742 | struct dpp_bootstrap_info * dpp_bootstrap_find_chirp(struct dpp_global *dpp, |
| 743 | const u8 *hash); |
Hai Shalom | 021b0b5 | 2019-04-10 11:17:58 -0700 | [diff] [blame] | 744 | int dpp_configurator_add(struct dpp_global *dpp, const char *cmd); |
Sunil Ravi | a04bd25 | 2022-05-02 22:54:18 -0700 | [diff] [blame] | 745 | int dpp_configurator_set(struct dpp_global *dpp, const char *cmd); |
Hai Shalom | 021b0b5 | 2019-04-10 11:17:58 -0700 | [diff] [blame] | 746 | int dpp_configurator_remove(struct dpp_global *dpp, const char *id); |
| 747 | int dpp_configurator_get_key_id(struct dpp_global *dpp, unsigned int id, |
| 748 | char *buf, size_t buflen); |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 749 | int dpp_configurator_from_backup(struct dpp_global *dpp, |
| 750 | struct dpp_asymmetric_key *key); |
Hai Shalom | 4fbc08f | 2020-05-18 12:37:00 -0700 | [diff] [blame] | 751 | struct dpp_configurator * dpp_configurator_find_kid(struct dpp_global *dpp, |
| 752 | const u8 *kid); |
Hai Shalom | 81f62d8 | 2019-07-22 12:10:00 -0700 | [diff] [blame] | 753 | int dpp_relay_add_controller(struct dpp_global *dpp, |
| 754 | struct dpp_relay_config *config); |
Sunil Ravi | 89eba10 | 2022-09-13 21:04:37 -0700 | [diff] [blame^] | 755 | void dpp_relay_remove_controller(struct dpp_global *dpp, |
| 756 | const struct hostapd_ip_addr *addr); |
| 757 | int dpp_relay_listen(struct dpp_global *dpp, int port, |
| 758 | struct dpp_relay_config *config); |
| 759 | void dpp_relay_stop_listen(struct dpp_global *dpp); |
Hai Shalom | 81f62d8 | 2019-07-22 12:10:00 -0700 | [diff] [blame] | 760 | int dpp_relay_rx_action(struct dpp_global *dpp, const u8 *src, const u8 *hdr, |
| 761 | const u8 *buf, size_t len, unsigned int freq, |
Hai Shalom | a20dcd7 | 2022-02-04 13:43:00 -0800 | [diff] [blame] | 762 | const u8 *i_bootstrap, const u8 *r_bootstrap, |
| 763 | void *cb_ctx); |
Hai Shalom | 81f62d8 | 2019-07-22 12:10:00 -0700 | [diff] [blame] | 764 | int dpp_relay_rx_gas_req(struct dpp_global *dpp, const u8 *src, const u8 *data, |
| 765 | size_t data_len); |
Sunil Ravi | 89eba10 | 2022-09-13 21:04:37 -0700 | [diff] [blame^] | 766 | bool dpp_relay_controller_available(struct dpp_global *dpp); |
Hai Shalom | 81f62d8 | 2019-07-22 12:10:00 -0700 | [diff] [blame] | 767 | int dpp_controller_start(struct dpp_global *dpp, |
| 768 | struct dpp_controller_config *config); |
Sunil Ravi | a04bd25 | 2022-05-02 22:54:18 -0700 | [diff] [blame] | 769 | int dpp_controller_set_params(struct dpp_global *dpp, |
| 770 | const char *configurator_params); |
Hai Shalom | 81f62d8 | 2019-07-22 12:10:00 -0700 | [diff] [blame] | 771 | void dpp_controller_stop(struct dpp_global *dpp); |
Hai Shalom | a20dcd7 | 2022-02-04 13:43:00 -0800 | [diff] [blame] | 772 | void dpp_controller_stop_for_ctx(struct dpp_global *dpp, void *cb_ctx); |
Hai Shalom | 899fcc7 | 2020-10-19 14:38:18 -0700 | [diff] [blame] | 773 | struct dpp_authentication * dpp_controller_get_auth(struct dpp_global *dpp, |
| 774 | unsigned int id); |
| 775 | void dpp_controller_new_qr_code(struct dpp_global *dpp, |
| 776 | struct dpp_bootstrap_info *bi); |
Hai Shalom | a20dcd7 | 2022-02-04 13:43:00 -0800 | [diff] [blame] | 777 | int dpp_tcp_pkex_init(struct dpp_global *dpp, struct dpp_pkex *pkex, |
| 778 | const struct hostapd_ip_addr *addr, int port, |
| 779 | void *msg_ctx, void *cb_ctx, |
| 780 | int (*pkex_done)(void *ctx, void *conn, |
| 781 | struct dpp_bootstrap_info *bi)); |
Hai Shalom | 81f62d8 | 2019-07-22 12:10:00 -0700 | [diff] [blame] | 782 | int dpp_tcp_init(struct dpp_global *dpp, struct dpp_authentication *auth, |
Hai Shalom | 899fcc7 | 2020-10-19 14:38:18 -0700 | [diff] [blame] | 783 | const struct hostapd_ip_addr *addr, int port, |
Sunil Ravi | 89eba10 | 2022-09-13 21:04:37 -0700 | [diff] [blame^] | 784 | const char *name, enum dpp_netrole netrole, |
| 785 | const char *mud_url, |
| 786 | const char *extra_conf_req_name, |
| 787 | const char *extra_conf_req_value, |
| 788 | void *msg_ctx, void *cb_ctx, |
Hai Shalom | 899fcc7 | 2020-10-19 14:38:18 -0700 | [diff] [blame] | 789 | int (*process_conf_obj)(void *ctx, |
Hai Shalom | a20dcd7 | 2022-02-04 13:43:00 -0800 | [diff] [blame] | 790 | struct dpp_authentication *auth), |
| 791 | bool (*tcp_msg_sent)(void *ctx, |
| 792 | struct dpp_authentication *auth)); |
| 793 | int dpp_tcp_auth(struct dpp_global *dpp, void *_conn, |
| 794 | struct dpp_authentication *auth, const char *name, |
Sunil Ravi | 89eba10 | 2022-09-13 21:04:37 -0700 | [diff] [blame^] | 795 | enum dpp_netrole netrole, const char *mud_url, |
| 796 | const char *extra_conf_req_name, |
| 797 | const char *extra_conf_req_value, |
Hai Shalom | a20dcd7 | 2022-02-04 13:43:00 -0800 | [diff] [blame] | 798 | int (*process_conf_obj)(void *ctx, |
| 799 | struct dpp_authentication *auth), |
| 800 | bool (*tcp_msg_sent)(void *ctx, |
| 801 | struct dpp_authentication *auth)); |
| 802 | bool dpp_tcp_conn_status_requested(struct dpp_global *dpp); |
| 803 | void dpp_tcp_send_conn_status(struct dpp_global *dpp, |
| 804 | enum dpp_status_error result, |
| 805 | const u8 *ssid, size_t ssid_len, |
| 806 | const char *channel_list); |
Hai Shalom | 899fcc7 | 2020-10-19 14:38:18 -0700 | [diff] [blame] | 807 | |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 808 | struct wpabuf * dpp_build_presence_announcement(struct dpp_bootstrap_info *bi); |
Hai Shalom | 899fcc7 | 2020-10-19 14:38:18 -0700 | [diff] [blame] | 809 | void dpp_notify_chirp_received(void *msg_ctx, int id, const u8 *src, |
| 810 | unsigned int freq, const u8 *hash); |
Hai Shalom | 81f62d8 | 2019-07-22 12:10:00 -0700 | [diff] [blame] | 811 | |
Sunil Ravi | 89eba10 | 2022-09-13 21:04:37 -0700 | [diff] [blame^] | 812 | struct wpabuf * dpp_build_pb_announcement(struct dpp_bootstrap_info *bi); |
| 813 | struct wpabuf * dpp_build_pb_announcement_resp(struct dpp_bootstrap_info *bi, |
| 814 | const u8 *e_hash, |
| 815 | const u8 *c_nonce, |
| 816 | size_t c_nonce_len); |
| 817 | |
Hai Shalom | 81f62d8 | 2019-07-22 12:10:00 -0700 | [diff] [blame] | 818 | struct dpp_global_config { |
Hai Shalom | 81f62d8 | 2019-07-22 12:10:00 -0700 | [diff] [blame] | 819 | void *cb_ctx; |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 820 | void (*remove_bi)(void *ctx, struct dpp_bootstrap_info *bi); |
Hai Shalom | 81f62d8 | 2019-07-22 12:10:00 -0700 | [diff] [blame] | 821 | }; |
| 822 | |
| 823 | struct dpp_global * dpp_global_init(struct dpp_global_config *config); |
Hai Shalom | 021b0b5 | 2019-04-10 11:17:58 -0700 | [diff] [blame] | 824 | void dpp_global_clear(struct dpp_global *dpp); |
| 825 | void dpp_global_deinit(struct dpp_global *dpp); |
| 826 | |
Hai Shalom | 4fbc08f | 2020-05-18 12:37:00 -0700 | [diff] [blame] | 827 | /* dpp_reconfig.c */ |
| 828 | |
| 829 | struct wpabuf * dpp_build_reconfig_announcement(const u8 *csign_key, |
Hai Shalom | 899fcc7 | 2020-10-19 14:38:18 -0700 | [diff] [blame] | 830 | size_t csign_key_len, |
| 831 | const u8 *net_access_key, |
| 832 | size_t net_access_key_len, |
| 833 | struct dpp_reconfig_id *id); |
Hai Shalom | 4fbc08f | 2020-05-18 12:37:00 -0700 | [diff] [blame] | 834 | struct dpp_authentication * |
| 835 | dpp_reconfig_init(struct dpp_global *dpp, void *msg_ctx, |
Hai Shalom | 899fcc7 | 2020-10-19 14:38:18 -0700 | [diff] [blame] | 836 | struct dpp_configurator *conf, unsigned int freq, u16 group, |
| 837 | const u8 *a_nonce_attr, size_t a_nonce_len, |
| 838 | const u8 *e_id_attr, size_t e_id_len); |
Hai Shalom | 4fbc08f | 2020-05-18 12:37:00 -0700 | [diff] [blame] | 839 | struct dpp_authentication * |
| 840 | dpp_reconfig_auth_req_rx(struct dpp_global *dpp, void *msg_ctx, |
| 841 | const char *own_connector, |
| 842 | const u8 *net_access_key, size_t net_access_key_len, |
| 843 | const u8 *csign_key, size_t csign_key_len, |
| 844 | unsigned int freq, const u8 *hdr, |
| 845 | const u8 *attr_start, size_t attr_len); |
| 846 | struct wpabuf * |
| 847 | dpp_reconfig_auth_resp_rx(struct dpp_authentication *auth, const u8 *hdr, |
| 848 | const u8 *attr_start, size_t attr_len); |
| 849 | int dpp_reconfig_auth_conf_rx(struct dpp_authentication *auth, const u8 *hdr, |
| 850 | const u8 *attr_start, size_t attr_len); |
| 851 | |
Hai Shalom | 899fcc7 | 2020-10-19 14:38:18 -0700 | [diff] [blame] | 852 | struct dpp_reconfig_id * dpp_gen_reconfig_id(const u8 *csign_key, |
| 853 | size_t csign_key_len, |
| 854 | const u8 *pp_key, |
| 855 | size_t pp_key_len); |
| 856 | int dpp_update_reconfig_id(struct dpp_reconfig_id *id); |
| 857 | void dpp_free_reconfig_id(struct dpp_reconfig_id *id); |
| 858 | |
Hai Shalom | 021b0b5 | 2019-04-10 11:17:58 -0700 | [diff] [blame] | 859 | #endif /* CONFIG_DPP */ |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 860 | #endif /* DPP_H */ |