1 /* 2 * Copyright (c) 2017-2021 The Linux Foundation. All rights reserved. 3 * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. 4 * 5 * Permission to use, copy, modify, and/or distribute this software for 6 * any purpose with or without fee is hereby granted, provided that the 7 * above copyright notice and this permission notice appear in all 8 * copies. 9 * 10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 11 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 12 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 13 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL 14 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR 15 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 16 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 17 * PERFORMANCE OF THIS SOFTWARE. 18 */ 19 20 /** 21 * DOC: Public definations for crypto service 22 */ 23 24 #ifndef _WLAN_CRYPTO_GLOBAL_DEF_H_ 25 #define _WLAN_CRYPTO_GLOBAL_DEF_H_ 26 27 #include <wlan_cmn.h> 28 #ifdef WLAN_CRYPTO_SUPPORT_FILS 29 #include "wlan_crypto_fils_def.h" 30 #endif 31 #include <wlan_objmgr_cmn.h> 32 #include <wlan_cmn_ieee80211.h> 33 34 #define WLAN_CRYPTO_TID_SIZE (17) 35 #define WLAN_CRYPTO_RSC_SIZE (16) 36 #define WLAN_CRYPTO_KEYBUF_SIZE (32) 37 #define WLAN_CRYPTO_MICBUF_SIZE (16) 38 #define WLAN_CRYPTO_MIC_LEN (8) 39 #define WLAN_CRYPTO_IV_SIZE (16) 40 #define WLAN_CRYPTO_MIC256_LEN (16) 41 #define WLAN_CRYPTO_TXMIC_OFFSET (0) 42 #define WLAN_CRYPTO_RXMIC_OFFSET (WLAN_CRYPTO_TXMIC_OFFSET + \ 43 WLAN_CRYPTO_MIC_LEN) 44 #define WLAN_CRYPTO_WAPI_IV_SIZE (16) 45 #define WLAN_CRYPTO_CRC_LEN (4) 46 #define WLAN_CRYPTO_IV_LEN (3) 47 #define WLAN_CRYPTO_KEYID_LEN (1) 48 #define WLAN_CRYPTO_EXT_IV_LEN (4) 49 #define WLAN_CRYPTO_EXT_IV_BIT (0x20) 50 #define WLAN_CRYPTO_KEYIX_NONE ((uint16_t)-1) 51 #define WLAN_CRYPTO_MAXKEYIDX (4) 52 #define WLAN_CRYPTO_MAXIGTKKEYIDX (2) 53 #define WLAN_CRYPTO_MAXBIGTKKEYIDX (2) 54 #ifndef WLAN_CRYPTO_MAX_VLANKEYIX 55 #define WLAN_CRYPTO_MAX_VLANKEYIX WLAN_CRYPTO_MAXKEYIDX 56 #endif 57 #define WLAN_CRYPTO_MAX_PMKID (16) 58 59 /* 40 bit wep key len */ 60 #define WLAN_CRYPTO_KEY_WEP40_LEN (5) 61 /* 104 bit wep key len */ 62 #define WLAN_CRYPTO_KEY_WEP104_LEN (13) 63 /* 128 bit wep key len */ 64 #define WLAN_CRYPTO_KEY_WEP128_LEN (16) 65 66 #define WLAN_CRYPTO_KEY_TKIP_LEN (32) 67 #define WLAN_CRYPTO_KEY_CCMP_LEN (16) 68 #define WLAN_CRYPTO_KEY_CCMP_256_LEN (32) 69 #define WLAN_CRYPTO_KEY_GCMP_LEN (16) 70 #define WLAN_CRYPTO_KEY_GCMP_256_LEN (32) 71 #define WLAN_CRYPTO_KEY_WAPI_LEN (32) 72 #define WLAN_CRYPTO_KEY_GMAC_LEN (16) 73 #define WLAN_CRYPTO_KEY_GMAC_256_LEN (32) 74 #define WLAN_CRYPTO_WPI_SMS4_IVLEN (16) 75 #define WLAN_CRYPTO_WPI_SMS4_KIDLEN (1) 76 #define WLAN_CRYPTO_WPI_SMS4_PADLEN (1) 77 #define WLAN_CRYPTO_WPI_SMS4_MICLEN (16) 78 79 /* FILS definitions */ 80 #define WLAN_CRYPTO_FILS_OPTIONAL_DATA_LEN 3 81 #define WLAN_CRYPTO_FILS_RIK_LABEL "Re-authentication Integrity Key@ietf.org" 82 83 /* key used for xmit */ 84 #define WLAN_CRYPTO_KEY_XMIT (0x01) 85 /* key used for recv */ 86 #define WLAN_CRYPTO_KEY_RECV (0x02) 87 /* key used for WPA group operation */ 88 #define WLAN_CRYPTO_KEY_GROUP (0x04) 89 /* key also used for management frames */ 90 #define WLAN_CRYPTO_KEY_MFP (0x08) 91 /* host-based encryption */ 92 #define WLAN_CRYPTO_KEY_SWENCRYPT (0x10) 93 /* host-based enmic */ 94 #define WLAN_CRYPTO_KEY_SWENMIC (0x20) 95 /* do not remove unless OS commands us to do so */ 96 #define WLAN_CRYPTO_KEY_PERSISTENT (0x40) 97 /* per STA default key */ 98 #define WLAN_CRYPTO_KEY_DEFAULT (0x80) 99 /* host-based decryption */ 100 #define WLAN_CRYPTO_KEY_SWDECRYPT (0x100) 101 /* host-based demic */ 102 #define WLAN_CRYPTO_KEY_SWDEMIC (0x200) 103 /* get pn from fw for key */ 104 #define WLAN_CRYPTO_KEY_GET_PN (0x400) 105 106 #define WLAN_CRYPTO_KEY_SWCRYPT (WLAN_CRYPTO_KEY_SWENCRYPT \ 107 | WLAN_CRYPTO_KEY_SWDECRYPT) 108 109 #define WLAN_CRYPTO_KEY_SWMIC (WLAN_CRYPTO_KEY_SWENMIC \ 110 | WLAN_CRYPTO_KEY_SWDEMIC) 111 112 #if LINUX_VERSION_CODE < KERNEL_VERSION(4, 12, 0) 113 #define WLAN_AKM_SUITE_FT_8021X 0x000FAC03 114 #define WLAN_AKM_SUITE_FT_PSK 0x000FAC04 115 #endif 116 117 /* Maximum lifetime for a PMKID entry - 12 Hrs */ 118 #define WLAN_CRYPTO_MAX_PMKID_LIFETIME 43200 119 #define WLAN_CRYPTO_MAX_PMKID_LIFETIME_THRESHOLD 100 120 121 /* 122 * Cipher types 123 */ 124 typedef enum wlan_crypto_cipher_type { 125 WLAN_CRYPTO_CIPHER_WEP = 0, 126 WLAN_CRYPTO_CIPHER_TKIP = 1, 127 WLAN_CRYPTO_CIPHER_AES_OCB = 2, 128 WLAN_CRYPTO_CIPHER_AES_CCM = 3, 129 WLAN_CRYPTO_CIPHER_WAPI_SMS4 = 4, 130 WLAN_CRYPTO_CIPHER_CKIP = 5, 131 WLAN_CRYPTO_CIPHER_AES_CMAC = 6, 132 WLAN_CRYPTO_CIPHER_AES_CCM_256 = 7, 133 WLAN_CRYPTO_CIPHER_AES_CMAC_256 = 8, 134 WLAN_CRYPTO_CIPHER_AES_GCM = 9, 135 WLAN_CRYPTO_CIPHER_AES_GCM_256 = 10, 136 WLAN_CRYPTO_CIPHER_AES_GMAC = 11, 137 WLAN_CRYPTO_CIPHER_AES_GMAC_256 = 12, 138 WLAN_CRYPTO_CIPHER_WAPI_GCM4 = 13, 139 WLAN_CRYPTO_CIPHER_FILS_AEAD = 14, 140 WLAN_CRYPTO_CIPHER_WEP_40 = 15, 141 WLAN_CRYPTO_CIPHER_WEP_104 = 16, 142 WLAN_CRYPTO_CIPHER_NONE = 17, 143 WLAN_CRYPTO_CIPHER_MAX = (WLAN_CRYPTO_CIPHER_NONE + 1), 144 WLAN_CRYPTO_CIPHER_INVALID, 145 } wlan_crypto_cipher_type; 146 147 /* Auth types */ 148 typedef enum wlan_crypto_auth_mode { 149 WLAN_CRYPTO_AUTH_NONE = 0, 150 WLAN_CRYPTO_AUTH_OPEN = 1, 151 WLAN_CRYPTO_AUTH_SHARED = 2, 152 WLAN_CRYPTO_AUTH_8021X = 3, 153 WLAN_CRYPTO_AUTH_AUTO = 4, 154 WLAN_CRYPTO_AUTH_WPA = 5, 155 WLAN_CRYPTO_AUTH_RSNA = 6, 156 WLAN_CRYPTO_AUTH_CCKM = 7, 157 WLAN_CRYPTO_AUTH_WAPI = 8, 158 WLAN_CRYPTO_AUTH_SAE = 9, 159 WLAN_CRYPTO_AUTH_FILS_SK = 10, 160 /** Keep WLAN_CRYPTO_AUTH_MAX at the end. */ 161 WLAN_CRYPTO_AUTH_MAX, 162 } wlan_crypto_auth_mode; 163 164 /* crypto capabilities */ 165 typedef enum wlan_crypto_cap { 166 WLAN_CRYPTO_CAP_PRIVACY = 0, 167 WLAN_CRYPTO_CAP_WPA1 = 1, 168 WLAN_CRYPTO_CAP_WPA2 = 2, 169 WLAN_CRYPTO_CAP_WPA = 3, 170 WLAN_CRYPTO_CAP_AES = 4, 171 WLAN_CRYPTO_CAP_WEP = 5, 172 WLAN_CRYPTO_CAP_CKIP = 6, 173 WLAN_CRYPTO_CAP_TKIP_MIC = 7, 174 WLAN_CRYPTO_CAP_CCM256 = 8, 175 WLAN_CRYPTO_CAP_GCM = 9, 176 WLAN_CRYPTO_CAP_GCM_256 = 10, 177 WLAN_CRYPTO_CAP_WAPI_SMS4 = 11, 178 WLAN_CRYPTO_CAP_WAPI_GCM4 = 12, 179 WLAN_CRYPTO_CAP_KEY_MGMT_OFFLOAD = 13, 180 WLAN_CRYPTO_CAP_PMF_OFFLOAD = 14, 181 WLAN_CRYPTO_CAP_PN_TID_BASED = 15, 182 WLAN_CRYPTO_CAP_FILS_AEAD = 16, 183 } wlan_crypto_cap; 184 185 typedef enum wlan_crypto_rsn_cap { 186 WLAN_CRYPTO_RSN_CAP_PREAUTH = 0x01, 187 WLAN_CRYPTO_RSN_CAP_MFP_ENABLED = 0x80, 188 WLAN_CRYPTO_RSN_CAP_MFP_REQUIRED = 0x40, 189 WLAN_CRYPTO_RSN_CAP_OCV_SUPPORTED = 0x4000, 190 } wlan_crypto_rsn_cap; 191 192 /** 193 * wlan_crypto_rsnx_cap - RSNXE capabilities 194 * WLAN_CRYPTO_RSNX_CAP_PROTECTED_TWT: Protected TWT 195 * WLAN_CRYPTO_RSNX_CAP_SAE_H2E: SAE Hash to Element 196 * WLAN_CRYPTO_RSNX_CAP_SAE_PK: SAE PK 197 * WLAN_CRYPTO_RSNX_CAP_SECURE_LTF: Secure LTF 198 * WLAN_CRYPTO_RSNX_CAP_SECURE_RTT: Secure RTT 199 * WLAN_CRYPTO_RSNX_CAP_PROT_RANGE_NEG: Protected Range Negotiation 200 * WLAN_CRYPTO_RSNX_CAP_URNM_MFPR: Same as WLAN_CRYPTO_RSNX_CAP_PROT_RANGE_NEG 201 * and it's just a spec format. 202 * 203 * Definition: (IEEE Std 802.11-2020, 9.4.2.241, Table 9-780) 204 * The Extended RSN Capabilities field, except its first 4 bits, is a 205 * bit field indicating the extended RSN capabilities being advertised 206 * by the STA transmitting the element. The length of the Extended 207 * RSN Capabilities field is a variable n, in octets, as indicated by 208 * the first 4 bits in the field. 209 */ 210 enum wlan_crypto_rsnx_cap { 211 WLAN_CRYPTO_RSNX_CAP_PROTECTED_TWT = 0x10, 212 WLAN_CRYPTO_RSNX_CAP_SAE_H2E = 0x20, 213 WLAN_CRYPTO_RSNX_CAP_SAE_PK = 0x40, 214 WLAN_CRYPTO_RSNX_CAP_SECURE_LTF = 0x100, 215 WLAN_CRYPTO_RSNX_CAP_SECURE_RTT = 0x200, 216 WLAN_CRYPTO_RSNX_CAP_PROT_RANGE_NEG = 0x400, 217 WLAN_CRYPTO_RSNX_CAP_URNM_MFPR = WLAN_CRYPTO_RSNX_CAP_PROT_RANGE_NEG, 218 }; 219 220 /** 221 * wlan_crypto_vdev_pasn_caps - PASN peer related vdev 222 * crypto parameters 223 * @WLAN_CRYPTO_URNM_MFPR: URNM MFP required in RSNXE 224 * @WLAN_CRYPTO_MFPC: MFP capable bit from RSN IE 225 * @WLAN_CRYPTO_MFPR: MFP required from RSNIE 226 */ 227 enum wlan_crypto_vdev_pasn_caps { 228 WLAN_CRYPTO_URNM_MFPR = BIT(0), 229 WLAN_CRYPTO_MFPC = BIT(1), 230 WLAN_CRYPTO_MFPR = BIT(2), 231 }; 232 233 typedef enum wlan_crypto_key_mgmt { 234 WLAN_CRYPTO_KEY_MGMT_IEEE8021X = 0, 235 WLAN_CRYPTO_KEY_MGMT_PSK = 1, 236 WLAN_CRYPTO_KEY_MGMT_NONE = 2, 237 WLAN_CRYPTO_KEY_MGMT_IEEE8021X_NO_WPA = 3, 238 WLAN_CRYPTO_KEY_MGMT_WPA_NONE = 4, 239 WLAN_CRYPTO_KEY_MGMT_FT_IEEE8021X = 5, 240 WLAN_CRYPTO_KEY_MGMT_FT_PSK = 6, 241 WLAN_CRYPTO_KEY_MGMT_IEEE8021X_SHA256 = 7, 242 WLAN_CRYPTO_KEY_MGMT_PSK_SHA256 = 8, 243 WLAN_CRYPTO_KEY_MGMT_WPS = 9, 244 WLAN_CRYPTO_KEY_MGMT_SAE = 10, 245 WLAN_CRYPTO_KEY_MGMT_FT_SAE = 11, 246 WLAN_CRYPTO_KEY_MGMT_WAPI_PSK = 12, 247 WLAN_CRYPTO_KEY_MGMT_WAPI_CERT = 13, 248 WLAN_CRYPTO_KEY_MGMT_CCKM = 14, 249 WLAN_CRYPTO_KEY_MGMT_OSEN = 15, 250 WLAN_CRYPTO_KEY_MGMT_IEEE8021X_SUITE_B = 16, 251 WLAN_CRYPTO_KEY_MGMT_IEEE8021X_SUITE_B_192 = 17, 252 WLAN_CRYPTO_KEY_MGMT_FILS_SHA256 = 18, 253 WLAN_CRYPTO_KEY_MGMT_FILS_SHA384 = 19, 254 WLAN_CRYPTO_KEY_MGMT_FT_FILS_SHA256 = 20, 255 WLAN_CRYPTO_KEY_MGMT_FT_FILS_SHA384 = 21, 256 WLAN_CRYPTO_KEY_MGMT_OWE = 22, 257 WLAN_CRYPTO_KEY_MGMT_DPP = 23, 258 WLAN_CRYPTO_KEY_MGMT_FT_IEEE8021X_SHA384 = 24, 259 WLAN_CRYPTO_KEY_MGMT_FT_PSK_SHA384 = 25, 260 WLAN_CRYPTO_KEY_MGMT_PSK_SHA384 = 26, 261 /** Keep WLAN_CRYPTO_KEY_MGMT_MAX at the end. */ 262 WLAN_CRYPTO_KEY_MGMT_MAX, 263 } wlan_crypto_key_mgmt; 264 265 enum wlan_crypto_key_type { 266 WLAN_CRYPTO_KEY_TYPE_UNICAST, 267 WLAN_CRYPTO_KEY_TYPE_GROUP, 268 }; 269 270 #define IS_WEP_CIPHER(_c) ((_c == WLAN_CRYPTO_CIPHER_WEP) || \ 271 (_c == WLAN_CRYPTO_CIPHER_WEP_40) || \ 272 (_c == WLAN_CRYPTO_CIPHER_WEP_104)) 273 274 #define DEFAULT_KEYMGMT_6G_MASK 0xFFFFFFFF 275 276 /* AKM wlan_crypto_key_mgmt 1, 6, 8, 25 and 26 are not allowed. */ 277 #define ALLOWED_KEYMGMT_6G_MASK 0x01FFFEBD 278 279 /* 280 * enum fils_erp_cryptosuite: this enum defines the cryptosuites used 281 * to calculate auth tag and auth tag length as defined by RFC 6696 5.3.1 282 * @HMAC_SHA256_64: sha256 with auth tag len as 64 bits 283 * @HMAC_SHA256_128: sha256 with auth tag len as 128 bits 284 * @HMAC_SHA256_256: sha256 with auth tag len as 256 bits 285 */ 286 enum fils_erp_cryptosuite { 287 INVALID_CRYPTO = 0, /* reserved */ 288 HMAC_SHA256_64, 289 HMAC_SHA256_128, 290 HMAC_SHA256_256, 291 }; 292 293 /** 294 * struct mobility_domain_params - structure containing 295 * mobility domain info 296 * @mdie_present: mobility domain present or not 297 * @mobility_domain: mobility domain 298 */ 299 struct mobility_domain_params { 300 uint8_t mdie_present; 301 uint16_t mobility_domain; 302 }; 303 304 /** 305 * struct wlan_crypto_pmksa - structure of crypto to contain pmkid 306 * @bssid: bssid for which pmkid is saved 307 * @pmkid: pmkid info 308 * @pmk: pmk info 309 * @pmk_len: pmk len 310 * @ssid_len: ssid length 311 * @ssid: ssid information 312 * @cache_id: cache id 313 * @pmk_lifetime: Duration in seconds for which the pmk is valid 314 * @pmk_lifetime_threshold: Percentage of pmk liftime within which 315 * full authentication is expected to avoid disconnection. 316 * @pmk_entry_ts: System timestamp at which the PMK entry was created. 317 * @single_pmk_supported: SAE single pmk supported BSS 318 * @mdid: structure to contain mobility domain parameters 319 */ 320 struct wlan_crypto_pmksa { 321 struct qdf_mac_addr bssid; 322 uint8_t pmkid[PMKID_LEN]; 323 uint8_t pmk[MAX_PMK_LEN]; 324 uint8_t pmk_len; 325 uint8_t ssid_len; 326 uint8_t ssid[WLAN_SSID_MAX_LEN]; 327 uint8_t cache_id[WLAN_CACHE_ID_LEN]; 328 uint32_t pmk_lifetime; 329 uint8_t pmk_lifetime_threshold; 330 qdf_time_t pmk_entry_ts; 331 #if defined(WLAN_SAE_SINGLE_PMK) && defined(WLAN_FEATURE_ROAM_OFFLOAD) 332 bool single_pmk_supported; 333 #endif 334 struct mobility_domain_params mdid; 335 }; 336 337 #ifdef WLAN_ADAPTIVE_11R 338 /** 339 * struct wlan_crypto_pmksa - structure to store AKM(s) present in RSN IE of 340 * Beacon/Probe response 341 * @key_mgmt: AKM(s) present in RSN IE of Beacon/Probe response 342 */ 343 struct key_mgmt_list { 344 uint32_t key_mgmt; 345 }; 346 #endif 347 348 /** 349 * struct wlan_crypto_params - holds crypto params 350 * @authmodeset: authentication mode 351 * @ucastcipherset: unicast ciphers 352 * @mcastcipherset: multicast cipher 353 * @mgmtcipherset: mgmt cipher 354 * @cipher_caps: cipher capability 355 * @key_mgmt: key mgmt 356 * @pmksa: pmksa 357 * @rsn_caps: rsn_capability 358 * @akm_list: order of AKM present in RSN IE of Beacon/Probe response 359 * 360 * This structure holds crypto params for peer or vdev 361 */ 362 struct wlan_crypto_params { 363 uint32_t authmodeset; 364 uint32_t ucastcipherset; 365 uint32_t mcastcipherset; 366 uint32_t mgmtcipherset; 367 uint32_t cipher_caps; 368 uint32_t key_mgmt; 369 struct wlan_crypto_pmksa *pmksa[WLAN_CRYPTO_MAX_PMKID]; 370 uint16_t rsn_caps; 371 #ifdef WLAN_ADAPTIVE_11R 372 struct key_mgmt_list akm_list[WLAN_CRYPTO_KEY_MGMT_MAX]; 373 #endif 374 }; 375 376 /** 377 * struct wlan_crypto_ltf_keyseed_data - LTF keyseed parameters 378 * @vdev_id: Vdev id 379 * @peer_mac_addr: Peer mac address 380 * @src_mac_addr: Source mac address 381 * @rsn_authmode: Cipher suite 382 * @key_seed: Secure LTF key seed 383 * @key_seed_len: Key seed length 384 */ 385 struct wlan_crypto_ltf_keyseed_data { 386 uint8_t vdev_id; 387 struct qdf_mac_addr peer_mac_addr; 388 struct qdf_mac_addr src_mac_addr; 389 uint8_t rsn_authmode; 390 uint8_t key_seed[WLAN_MAX_SECURE_LTF_KEYSEED_LEN]; 391 uint16_t key_seed_len; 392 }; 393 394 typedef enum wlan_crypto_param_type { 395 WLAN_CRYPTO_PARAM_AUTH_MODE, 396 WLAN_CRYPTO_PARAM_UCAST_CIPHER, 397 WLAN_CRYPTO_PARAM_MCAST_CIPHER, 398 WLAN_CRYPTO_PARAM_MGMT_CIPHER, 399 WLAN_CRYPTO_PARAM_CIPHER_CAP, 400 WLAN_CRYPTO_PARAM_RSN_CAP, 401 WLAN_CRYPTO_PARAM_KEY_MGMT, 402 WLAN_CRYPTO_PARAM_PMKSA, 403 } wlan_crypto_param_type; 404 405 /** 406 * struct wlan_crypto_key - key structure 407 * @keylen: length of the key 408 * @valid: is key valid or not 409 * @flags: key flags 410 * @keyix: key id 411 * @cipher_type: cipher type being used for this key 412 * @mac_addr: MAC address of the peer 413 * @src_addr: Source mac address associated with the key 414 * @cipher_table: table which stores cipher related info 415 * @private: private pointer to save cipher context 416 * @keylock: spin lock 417 * @recviv: WAPI key receive sequence counter 418 * @txiv: WAPI key transmit sequence counter 419 * @keytsc: key transmit sequence counter 420 * @keyrsc: key receive sequence counter 421 * @keyrsc_suspect: key receive sequence counter under 422 * suspect when pN jump is detected 423 * @keyglobal: key receive global sequence counter used with suspect 424 * @keyval: key value buffer 425 * 426 * This key structure to key related details. 427 */ 428 struct wlan_crypto_key { 429 uint8_t keylen; 430 bool valid; 431 uint16_t flags; 432 uint16_t keyix; 433 enum wlan_crypto_cipher_type cipher_type; 434 uint8_t macaddr[QDF_MAC_ADDR_SIZE]; 435 struct qdf_mac_addr src_addr; 436 void *cipher_table; 437 void *private; 438 qdf_spinlock_t keylock; 439 uint8_t recviv[WLAN_CRYPTO_WAPI_IV_SIZE]; 440 uint8_t txiv[WLAN_CRYPTO_WAPI_IV_SIZE]; 441 uint64_t keytsc; 442 uint64_t keyrsc[WLAN_CRYPTO_TID_SIZE]; 443 uint64_t keyrsc_suspect[WLAN_CRYPTO_TID_SIZE]; 444 uint64_t keyglobal; 445 uint8_t keyval[WLAN_CRYPTO_KEYBUF_SIZE 446 + WLAN_CRYPTO_MICBUF_SIZE]; 447 #define txmic (keyval + WLAN_CRYPTO_KEYBUF_SIZE \ 448 + WLAN_CRYPTO_TXMIC_OFFSET) 449 #define rxmic (keyval + WLAN_CRYPTO_KEYBUF_SIZE \ 450 + WLAN_CRYPTO_RXMIC_OFFSET) 451 }; 452 453 /** 454 * struct wlan_crypto_req_key - key request structure 455 * @type: key/cipher type 456 * @pad: padding member 457 * @keyix: key index 458 * @keylen: length of the key value 459 * @flags: key flags 460 * @macaddr: macaddr of the key 461 * @keyrsc: key receive sequence counter 462 * @keytsc: key transmit sequence counter 463 * @keydata: key value 464 * @txiv: wapi key tx iv 465 * @rxiv: wapi key rx iv 466 * @filsaad: FILS AEAD data 467 * 468 * Key request structure used for setkey, getkey or delkey 469 */ 470 struct wlan_crypto_req_key { 471 uint8_t type; 472 uint8_t pad; 473 uint16_t keyix; 474 uint8_t keylen; 475 uint16_t flags; 476 uint8_t macaddr[QDF_MAC_ADDR_SIZE]; 477 uint64_t keyrsc; 478 uint64_t keytsc; 479 uint8_t keydata[WLAN_CRYPTO_KEYBUF_SIZE + WLAN_CRYPTO_MICBUF_SIZE]; 480 uint8_t txiv[WLAN_CRYPTO_WAPI_IV_SIZE]; 481 uint8_t recviv[WLAN_CRYPTO_WAPI_IV_SIZE]; 482 #ifdef WLAN_CRYPTO_SUPPORT_FILS 483 struct wlan_crypto_fils_aad_key filsaad; 484 #endif 485 }; 486 487 /** 488 * struct wlan_lmac_if_crypto_tx_ops - structure of crypto function 489 * pointers 490 * @allockey: function pointer to alloc key in hw 491 * @setkey: function pointer to setkey in hw 492 * @delkey: function pointer to delkey in hw 493 * @defaultkey: function pointer to set default key 494 * @set_key: converged function pointer to set key in hw 495 * @getpn: function pointer to get current pn value of peer 496 * @set_ltf_keyseed: Set LTF keyseed 497 * @set_vdev_param: Set the vdev crypto parameter 498 * @register_events: function pointer to register wmi event handler 499 * @deregister_events: function pointer to deregister wmi event handler 500 */ 501 502 struct wlan_lmac_if_crypto_tx_ops { 503 QDF_STATUS (*allockey)(struct wlan_objmgr_vdev *vdev, 504 struct wlan_crypto_key *key, 505 uint8_t *macaddr, uint32_t key_type); 506 QDF_STATUS (*setkey)(struct wlan_objmgr_vdev *vdev, 507 struct wlan_crypto_key *key, 508 uint8_t *macaddr, uint32_t key_type); 509 QDF_STATUS (*delkey)(struct wlan_objmgr_vdev *vdev, 510 struct wlan_crypto_key *key, 511 uint8_t *macaddr, uint32_t key_type); 512 QDF_STATUS (*defaultkey)(struct wlan_objmgr_vdev *vdev, 513 uint8_t keyix, uint8_t *macaddr); 514 QDF_STATUS (*set_key)(struct wlan_objmgr_vdev *vdev, 515 struct wlan_crypto_key *key, 516 enum wlan_crypto_key_type key_type); 517 QDF_STATUS(*getpn)(struct wlan_objmgr_vdev *vdev, 518 uint8_t *macaddr, uint32_t key_type); 519 QDF_STATUS (*set_ltf_keyseed)(struct wlan_objmgr_psoc *psoc, 520 struct wlan_crypto_ltf_keyseed_data *ks); 521 QDF_STATUS (*set_vdev_param)(struct wlan_objmgr_psoc *psoc, 522 uint32_t vdev_id, uint32_t param_id, 523 uint32_t param_value); 524 QDF_STATUS (*register_events)(struct wlan_objmgr_psoc *psoc); 525 QDF_STATUS (*deregister_events)(struct wlan_objmgr_psoc *psoc); 526 }; 527 528 /** 529 * struct wlan_lmac_if_crypto_rx_ops - structure of crypto rx function 530 * pointers 531 * @encap: function pointer to encap tx frame 532 * @decap: function pointer to decap rx frame in hw 533 * @enmic: function pointer to enmic tx frame 534 * @demic: function pointer to demic rx frame 535 * @get_rxpn: function pointer to get current Rx pn value of peer 536 */ 537 538 struct wlan_lmac_if_crypto_rx_ops { 539 QDF_STATUS(*crypto_encap)(struct wlan_objmgr_vdev *vdev, 540 qdf_nbuf_t wbuf, uint8_t *macaddr, 541 uint8_t encapdone); 542 QDF_STATUS(*crypto_decap)(struct wlan_objmgr_vdev *vdev, 543 qdf_nbuf_t wbuf, uint8_t *macaddr, 544 uint8_t tid); 545 QDF_STATUS(*crypto_enmic)(struct wlan_objmgr_vdev *vdev, 546 qdf_nbuf_t wbuf, uint8_t *macaddr, 547 uint8_t encapdone); 548 QDF_STATUS(*crypto_demic)(struct wlan_objmgr_vdev *vdev, 549 qdf_nbuf_t wbuf, uint8_t *macaddr, 550 uint8_t tid, uint8_t keyid); 551 QDF_STATUS(*set_peer_wep_keys)(struct wlan_objmgr_vdev *vdev, 552 struct wlan_objmgr_peer *peer); 553 QDF_STATUS (*get_rxpn)(struct wlan_objmgr_vdev *vdev, 554 uint8_t *macaddr, uint16_t keyix); 555 }; 556 557 #define WLAN_CRYPTO_RX_OPS_ENCAP(crypto_rx_ops) \ 558 (crypto_rx_ops->crypto_encap) 559 #define WLAN_CRYPTO_RX_OPS_DECAP(crypto_rx_ops) \ 560 (crypto_rx_ops->crypto_decap) 561 #define WLAN_CRYPTO_RX_OPS_ENMIC(crypto_rx_ops) \ 562 (crypto_rx_ops->crypto_enmic) 563 #define WLAN_CRYPTO_RX_OPS_DEMIC(crypto_rx_ops) \ 564 (crypto_rx_ops->crypto_demic) 565 #define WLAN_CRYPTO_RX_OPS_SET_PEER_WEP_KEYS(crypto_rx_ops) \ 566 (crypto_rx_ops->set_peer_wep_keys) 567 #define WLAN_CRYPTO_RX_OPS_GET_RXPN(crypto_rx_ops) \ 568 ((crypto_rx_ops)->get_rxpn) 569 570 #define WLAN_CRYPTO_IS_WPA_WPA2(akm) \ 571 (QDF_HAS_PARAM(akm, WLAN_CRYPTO_KEY_MGMT_IEEE8021X) || \ 572 QDF_HAS_PARAM(akm, WLAN_CRYPTO_KEY_MGMT_PSK) || \ 573 QDF_HAS_PARAM(akm, WLAN_CRYPTO_KEY_MGMT_FT_IEEE8021X) || \ 574 QDF_HAS_PARAM(akm, WLAN_CRYPTO_KEY_MGMT_FT_PSK) || \ 575 QDF_HAS_PARAM(akm, WLAN_CRYPTO_KEY_MGMT_IEEE8021X_SHA256) || \ 576 QDF_HAS_PARAM(akm, WLAN_CRYPTO_KEY_MGMT_PSK_SHA256) || \ 577 QDF_HAS_PARAM(akm, WLAN_CRYPTO_KEY_MGMT_WPS) || \ 578 QDF_HAS_PARAM(akm, WLAN_CRYPTO_KEY_MGMT_WAPI_PSK) || \ 579 QDF_HAS_PARAM(akm, WLAN_CRYPTO_KEY_MGMT_WAPI_CERT) || \ 580 QDF_HAS_PARAM(akm, WLAN_CRYPTO_KEY_MGMT_CCKM) || \ 581 QDF_HAS_PARAM(akm, WLAN_CRYPTO_KEY_MGMT_OSEN) || \ 582 QDF_HAS_PARAM(akm, WLAN_CRYPTO_KEY_MGMT_IEEE8021X_SUITE_B) || \ 583 QDF_HAS_PARAM(akm, WLAN_CRYPTO_KEY_MGMT_FILS_SHA256) || \ 584 QDF_HAS_PARAM(akm, WLAN_CRYPTO_KEY_MGMT_FILS_SHA384) || \ 585 QDF_HAS_PARAM(akm, WLAN_CRYPTO_KEY_MGMT_FT_FILS_SHA256) || \ 586 QDF_HAS_PARAM(akm, WLAN_CRYPTO_KEY_MGMT_FT_FILS_SHA384) || \ 587 QDF_HAS_PARAM(akm, WLAN_CRYPTO_KEY_MGMT_FT_PSK_SHA384) || \ 588 QDF_HAS_PARAM(akm, WLAN_CRYPTO_KEY_MGMT_PSK_SHA384)) 589 590 #endif /* end of _WLAN_CRYPTO_GLOBAL_DEF_H_ */ 591