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 definitions 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 WLAN_CRYPTO_KEY_MGMT_SAE_EXT_KEY = 27, 262 /** Keep WLAN_CRYPTO_KEY_MGMT_MAX at the end. */ 263 WLAN_CRYPTO_KEY_MGMT_MAX, 264 } wlan_crypto_key_mgmt; 265 266 enum wlan_crypto_key_type { 267 WLAN_CRYPTO_KEY_TYPE_UNICAST, 268 WLAN_CRYPTO_KEY_TYPE_GROUP, 269 }; 270 271 #define IS_WEP_CIPHER(_c) ((_c == WLAN_CRYPTO_CIPHER_WEP) || \ 272 (_c == WLAN_CRYPTO_CIPHER_WEP_40) || \ 273 (_c == WLAN_CRYPTO_CIPHER_WEP_104)) 274 275 #define DEFAULT_KEYMGMT_6G_MASK 0xFFFFFFFF 276 277 /* AKM wlan_crypto_key_mgmt 1, 6, 8, 25 and 26 are not allowed. */ 278 #define ALLOWED_KEYMGMT_6G_MASK 0x09FFFEBD 279 280 /* 281 * enum fils_erp_cryptosuite: this enum defines the cryptosuites used 282 * to calculate auth tag and auth tag length as defined by RFC 6696 5.3.1 283 * @HMAC_SHA256_64: sha256 with auth tag len as 64 bits 284 * @HMAC_SHA256_128: sha256 with auth tag len as 128 bits 285 * @HMAC_SHA256_256: sha256 with auth tag len as 256 bits 286 */ 287 enum fils_erp_cryptosuite { 288 INVALID_CRYPTO = 0, /* reserved */ 289 HMAC_SHA256_64, 290 HMAC_SHA256_128, 291 HMAC_SHA256_256, 292 }; 293 294 /** 295 * struct mobility_domain_params - structure containing 296 * mobility domain info 297 * @mdie_present: mobility domain present or not 298 * @mobility_domain: mobility domain 299 */ 300 struct mobility_domain_params { 301 uint8_t mdie_present; 302 uint16_t mobility_domain; 303 }; 304 305 /** 306 * struct wlan_crypto_pmksa - structure of crypto to contain pmkid 307 * @bssid: bssid for which pmkid is saved 308 * @pmkid: pmkid info 309 * @pmk: pmk info 310 * @pmk_len: pmk len 311 * @ssid_len: ssid length 312 * @ssid: ssid information 313 * @cache_id: cache id 314 * @pmk_lifetime: Duration in seconds for which the pmk is valid 315 * @pmk_lifetime_threshold: Percentage of pmk lifetime within which 316 * full authentication is expected to avoid disconnection. 317 * @pmk_entry_ts: System timestamp at which the PMK entry was created. 318 * @single_pmk_supported: SAE single pmk supported BSS 319 * @mdid: structure to contain mobility domain parameters 320 */ 321 struct wlan_crypto_pmksa { 322 struct qdf_mac_addr bssid; 323 uint8_t pmkid[PMKID_LEN]; 324 uint8_t pmk[MAX_PMK_LEN]; 325 uint8_t pmk_len; 326 uint8_t ssid_len; 327 uint8_t ssid[WLAN_SSID_MAX_LEN]; 328 uint8_t cache_id[WLAN_CACHE_ID_LEN]; 329 uint32_t pmk_lifetime; 330 uint8_t pmk_lifetime_threshold; 331 qdf_time_t pmk_entry_ts; 332 #if defined(WLAN_SAE_SINGLE_PMK) && defined(WLAN_FEATURE_ROAM_OFFLOAD) 333 bool single_pmk_supported; 334 #endif 335 struct mobility_domain_params mdid; 336 }; 337 338 #ifdef WLAN_ADAPTIVE_11R 339 /** 340 * struct wlan_crypto_pmksa - structure to store AKM(s) present in RSN IE of 341 * Beacon/Probe response 342 * @key_mgmt: AKM(s) present in RSN IE of Beacon/Probe response 343 */ 344 struct key_mgmt_list { 345 uint32_t key_mgmt; 346 }; 347 #endif 348 349 /** 350 * struct wlan_crypto_params - holds crypto params 351 * @authmodeset: authentication mode 352 * @ucastcipherset: unicast ciphers 353 * @mcastcipherset: multicast cipher 354 * @mgmtcipherset: mgmt cipher 355 * @cipher_caps: cipher capability 356 * @key_mgmt: key mgmt 357 * @pmksa: pmksa 358 * @rsn_caps: rsn_capability 359 * @akm_list: order of AKM present in RSN IE of Beacon/Probe response 360 * 361 * This structure holds crypto params for peer or vdev 362 */ 363 struct wlan_crypto_params { 364 uint32_t authmodeset; 365 uint32_t ucastcipherset; 366 uint32_t mcastcipherset; 367 uint32_t mgmtcipherset; 368 uint32_t cipher_caps; 369 uint32_t key_mgmt; 370 struct wlan_crypto_pmksa *pmksa[WLAN_CRYPTO_MAX_PMKID]; 371 uint16_t rsn_caps; 372 #ifdef WLAN_ADAPTIVE_11R 373 struct key_mgmt_list akm_list[WLAN_CRYPTO_KEY_MGMT_MAX]; 374 #endif 375 }; 376 377 /** 378 * struct wlan_crypto_ltf_keyseed_data - LTF keyseed parameters 379 * @vdev_id: Vdev id 380 * @peer_mac_addr: Peer mac address 381 * @src_mac_addr: Source mac address 382 * @rsn_authmode: Cipher suite 383 * @key_seed: Secure LTF key seed 384 * @key_seed_len: Key seed length 385 */ 386 struct wlan_crypto_ltf_keyseed_data { 387 uint8_t vdev_id; 388 struct qdf_mac_addr peer_mac_addr; 389 struct qdf_mac_addr src_mac_addr; 390 uint8_t rsn_authmode; 391 uint8_t key_seed[WLAN_MAX_SECURE_LTF_KEYSEED_LEN]; 392 uint16_t key_seed_len; 393 }; 394 395 typedef enum wlan_crypto_param_type { 396 WLAN_CRYPTO_PARAM_AUTH_MODE, 397 WLAN_CRYPTO_PARAM_UCAST_CIPHER, 398 WLAN_CRYPTO_PARAM_MCAST_CIPHER, 399 WLAN_CRYPTO_PARAM_MGMT_CIPHER, 400 WLAN_CRYPTO_PARAM_CIPHER_CAP, 401 WLAN_CRYPTO_PARAM_RSN_CAP, 402 WLAN_CRYPTO_PARAM_KEY_MGMT, 403 WLAN_CRYPTO_PARAM_PMKSA, 404 } wlan_crypto_param_type; 405 406 /** 407 * struct wlan_crypto_key - key structure 408 * @keylen: length of the key 409 * @valid: is key valid or not 410 * @flags: key flags 411 * @keyix: key id 412 * @cipher_type: cipher type being used for this key 413 * @key_type: unicast or broadcast key 414 * @mac_addr: MAC address of the peer 415 * @src_addr: Source mac address associated with the key 416 * @cipher_table: table which stores cipher related info 417 * @private: private pointer to save cipher context 418 * @keylock: spin lock 419 * @recviv: WAPI key receive sequence counter 420 * @txiv: WAPI key transmit sequence counter 421 * @keytsc: key transmit sequence counter 422 * @keyrsc: key receive sequence counter 423 * @keyrsc_suspect: key receive sequence counter under 424 * suspect when pN jump is detected 425 * @keyglobal: key receive global sequence counter used with suspect 426 * @keyval: key value buffer 427 * 428 * This key structure to key related details. 429 */ 430 struct wlan_crypto_key { 431 uint8_t keylen; 432 bool valid; 433 uint16_t flags; 434 uint16_t keyix; 435 enum wlan_crypto_cipher_type cipher_type; 436 enum wlan_crypto_key_type key_type; 437 uint8_t macaddr[QDF_MAC_ADDR_SIZE]; 438 struct qdf_mac_addr src_addr; 439 void *cipher_table; 440 void *private; 441 qdf_spinlock_t keylock; 442 uint8_t recviv[WLAN_CRYPTO_WAPI_IV_SIZE]; 443 uint8_t txiv[WLAN_CRYPTO_WAPI_IV_SIZE]; 444 uint64_t keytsc; 445 uint64_t keyrsc[WLAN_CRYPTO_TID_SIZE]; 446 uint64_t keyrsc_suspect[WLAN_CRYPTO_TID_SIZE]; 447 uint64_t keyglobal; 448 uint8_t keyval[WLAN_CRYPTO_KEYBUF_SIZE 449 + WLAN_CRYPTO_MICBUF_SIZE]; 450 #define txmic (keyval + WLAN_CRYPTO_KEYBUF_SIZE \ 451 + WLAN_CRYPTO_TXMIC_OFFSET) 452 #define rxmic (keyval + WLAN_CRYPTO_KEYBUF_SIZE \ 453 + WLAN_CRYPTO_RXMIC_OFFSET) 454 }; 455 456 /** 457 * struct wlan_crypto_req_key - key request structure 458 * @type: key/cipher type 459 * @pad: padding member 460 * @keyix: key index 461 * @keylen: length of the key value 462 * @flags: key flags 463 * @macaddr: macaddr of the key 464 * @keyrsc: key receive sequence counter 465 * @keytsc: key transmit sequence counter 466 * @keydata: key value 467 * @txiv: wapi key tx iv 468 * @rxiv: wapi key rx iv 469 * @filsaad: FILS AEAD data 470 * 471 * Key request structure used for setkey, getkey or delkey 472 */ 473 struct wlan_crypto_req_key { 474 uint8_t type; 475 uint8_t pad; 476 uint16_t keyix; 477 uint8_t keylen; 478 uint16_t flags; 479 uint8_t macaddr[QDF_MAC_ADDR_SIZE]; 480 uint64_t keyrsc; 481 uint64_t keytsc; 482 uint8_t keydata[WLAN_CRYPTO_KEYBUF_SIZE + WLAN_CRYPTO_MICBUF_SIZE]; 483 uint8_t txiv[WLAN_CRYPTO_WAPI_IV_SIZE]; 484 uint8_t recviv[WLAN_CRYPTO_WAPI_IV_SIZE]; 485 #ifdef WLAN_CRYPTO_SUPPORT_FILS 486 struct wlan_crypto_fils_aad_key filsaad; 487 #endif 488 }; 489 490 /** 491 * struct wlan_lmac_if_crypto_tx_ops - structure of crypto function 492 * pointers 493 * @allockey: function pointer to alloc key in hw 494 * @setkey: function pointer to setkey in hw 495 * @delkey: function pointer to delkey in hw 496 * @defaultkey: function pointer to set default key 497 * @set_key: converged function pointer to set key in hw 498 * @getpn: function pointer to get current pn value of peer 499 * @set_ltf_keyseed: Set LTF keyseed 500 * @set_vdev_param: Set the vdev crypto parameter 501 * @register_events: function pointer to register wmi event handler 502 * @deregister_events: function pointer to deregister wmi event handler 503 */ 504 505 struct wlan_lmac_if_crypto_tx_ops { 506 QDF_STATUS (*allockey)(struct wlan_objmgr_vdev *vdev, 507 struct wlan_crypto_key *key, 508 uint8_t *macaddr, uint32_t key_type); 509 QDF_STATUS (*setkey)(struct wlan_objmgr_vdev *vdev, 510 struct wlan_crypto_key *key, 511 uint8_t *macaddr, uint32_t key_type); 512 QDF_STATUS (*delkey)(struct wlan_objmgr_vdev *vdev, 513 struct wlan_crypto_key *key, 514 uint8_t *macaddr, uint32_t key_type); 515 QDF_STATUS (*defaultkey)(struct wlan_objmgr_vdev *vdev, 516 uint8_t keyix, uint8_t *macaddr); 517 QDF_STATUS (*set_key)(struct wlan_objmgr_vdev *vdev, 518 struct wlan_crypto_key *key, 519 enum wlan_crypto_key_type key_type); 520 QDF_STATUS(*getpn)(struct wlan_objmgr_vdev *vdev, 521 uint8_t *macaddr, uint8_t keyix, uint32_t key_type); 522 QDF_STATUS (*set_ltf_keyseed)(struct wlan_objmgr_psoc *psoc, 523 struct wlan_crypto_ltf_keyseed_data *ks); 524 QDF_STATUS (*set_vdev_param)(struct wlan_objmgr_psoc *psoc, 525 uint32_t vdev_id, uint32_t param_id, 526 uint32_t param_value); 527 QDF_STATUS (*register_events)(struct wlan_objmgr_psoc *psoc); 528 QDF_STATUS (*deregister_events)(struct wlan_objmgr_psoc *psoc); 529 }; 530 531 /** 532 * struct wlan_lmac_if_crypto_rx_ops - structure of crypto rx function 533 * pointers 534 * @encap: function pointer to encap tx frame 535 * @decap: function pointer to decap rx frame in hw 536 * @enmic: function pointer to enmic tx frame 537 * @demic: function pointer to demic rx frame 538 * @get_rxpn: function pointer to get current Rx pn value of peer 539 */ 540 541 struct wlan_lmac_if_crypto_rx_ops { 542 QDF_STATUS(*crypto_encap)(struct wlan_objmgr_vdev *vdev, 543 qdf_nbuf_t wbuf, uint8_t *macaddr, 544 uint8_t encapdone); 545 QDF_STATUS(*crypto_decap)(struct wlan_objmgr_vdev *vdev, 546 qdf_nbuf_t wbuf, uint8_t *macaddr, 547 uint8_t tid); 548 QDF_STATUS(*crypto_enmic)(struct wlan_objmgr_vdev *vdev, 549 qdf_nbuf_t wbuf, uint8_t *macaddr, 550 uint8_t encapdone); 551 QDF_STATUS(*crypto_demic)(struct wlan_objmgr_vdev *vdev, 552 qdf_nbuf_t wbuf, uint8_t *macaddr, 553 uint8_t tid, uint8_t keyid); 554 QDF_STATUS(*set_peer_wep_keys)(struct wlan_objmgr_vdev *vdev, 555 struct wlan_objmgr_peer *peer); 556 QDF_STATUS (*get_rxpn)(struct wlan_objmgr_vdev *vdev, 557 uint8_t *macaddr, uint16_t keyix); 558 }; 559 560 #define WLAN_CRYPTO_RX_OPS_ENCAP(crypto_rx_ops) \ 561 (crypto_rx_ops->crypto_encap) 562 #define WLAN_CRYPTO_RX_OPS_DECAP(crypto_rx_ops) \ 563 (crypto_rx_ops->crypto_decap) 564 #define WLAN_CRYPTO_RX_OPS_ENMIC(crypto_rx_ops) \ 565 (crypto_rx_ops->crypto_enmic) 566 #define WLAN_CRYPTO_RX_OPS_DEMIC(crypto_rx_ops) \ 567 (crypto_rx_ops->crypto_demic) 568 #define WLAN_CRYPTO_RX_OPS_SET_PEER_WEP_KEYS(crypto_rx_ops) \ 569 (crypto_rx_ops->set_peer_wep_keys) 570 #define WLAN_CRYPTO_RX_OPS_GET_RXPN(crypto_rx_ops) \ 571 ((crypto_rx_ops)->get_rxpn) 572 573 #define WLAN_CRYPTO_IS_WPA_WPA2(akm) \ 574 (QDF_HAS_PARAM(akm, WLAN_CRYPTO_KEY_MGMT_IEEE8021X) || \ 575 QDF_HAS_PARAM(akm, WLAN_CRYPTO_KEY_MGMT_PSK) || \ 576 QDF_HAS_PARAM(akm, WLAN_CRYPTO_KEY_MGMT_FT_IEEE8021X) || \ 577 QDF_HAS_PARAM(akm, WLAN_CRYPTO_KEY_MGMT_FT_PSK) || \ 578 QDF_HAS_PARAM(akm, WLAN_CRYPTO_KEY_MGMT_IEEE8021X_SHA256) || \ 579 QDF_HAS_PARAM(akm, WLAN_CRYPTO_KEY_MGMT_PSK_SHA256) || \ 580 QDF_HAS_PARAM(akm, WLAN_CRYPTO_KEY_MGMT_WPS) || \ 581 QDF_HAS_PARAM(akm, WLAN_CRYPTO_KEY_MGMT_WAPI_PSK) || \ 582 QDF_HAS_PARAM(akm, WLAN_CRYPTO_KEY_MGMT_WAPI_CERT) || \ 583 QDF_HAS_PARAM(akm, WLAN_CRYPTO_KEY_MGMT_CCKM) || \ 584 QDF_HAS_PARAM(akm, WLAN_CRYPTO_KEY_MGMT_OSEN) || \ 585 QDF_HAS_PARAM(akm, WLAN_CRYPTO_KEY_MGMT_IEEE8021X_SUITE_B) || \ 586 QDF_HAS_PARAM(akm, WLAN_CRYPTO_KEY_MGMT_FILS_SHA256) || \ 587 QDF_HAS_PARAM(akm, WLAN_CRYPTO_KEY_MGMT_FILS_SHA384) || \ 588 QDF_HAS_PARAM(akm, WLAN_CRYPTO_KEY_MGMT_FT_FILS_SHA256) || \ 589 QDF_HAS_PARAM(akm, WLAN_CRYPTO_KEY_MGMT_FT_FILS_SHA384) || \ 590 QDF_HAS_PARAM(akm, WLAN_CRYPTO_KEY_MGMT_FT_PSK_SHA384) || \ 591 QDF_HAS_PARAM(akm, WLAN_CRYPTO_KEY_MGMT_PSK_SHA384)) 592 593 #endif /* end of _WLAN_CRYPTO_GLOBAL_DEF_H_ */ 594