1 /* 2 * Copyright (c) 2017-2021 The Linux Foundation. All rights reserved. 3 * Copyright (c) 2022-2023 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 * enum 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_URNM_MFPR: Unassociated Range 200 * Negotiation and Measurement MFP Required 201 * 202 * Definition: (IEEE Std 802.11-2020, 9.4.2.241, Table 9-780) 203 * The Extended RSN Capabilities field, except its first 4 bits, is a 204 * bit field indicating the extended RSN capabilities being advertised 205 * by the STA transmitting the element. The length of the Extended 206 * RSN Capabilities field is a variable n, in octets, as indicated by 207 * the first 4 bits in the field. 208 */ 209 enum wlan_crypto_rsnx_cap { 210 WLAN_CRYPTO_RSNX_CAP_PROTECTED_TWT = 0x10, 211 WLAN_CRYPTO_RSNX_CAP_SAE_H2E = 0x20, 212 WLAN_CRYPTO_RSNX_CAP_SAE_PK = 0x40, 213 WLAN_CRYPTO_RSNX_CAP_SECURE_LTF = 0x100, 214 WLAN_CRYPTO_RSNX_CAP_SECURE_RTT = 0x200, 215 WLAN_CRYPTO_RSNX_CAP_URNM_MFPR = 0x8000, 216 }; 217 218 /** 219 * enum wlan_crypto_vdev_pasn_caps - PASN peer related vdev 220 * crypto parameters 221 * @WLAN_CRYPTO_URNM_MFPR: URNM MFP required in RSNXE 222 * @WLAN_CRYPTO_MFPC: MFP capable bit from RSN IE 223 * @WLAN_CRYPTO_MFPR: MFP required from RSNIE 224 */ 225 enum wlan_crypto_vdev_pasn_caps { 226 WLAN_CRYPTO_URNM_MFPR = BIT(0), 227 WLAN_CRYPTO_MFPC = BIT(1), 228 WLAN_CRYPTO_MFPR = BIT(2), 229 }; 230 231 typedef enum wlan_crypto_key_mgmt { 232 WLAN_CRYPTO_KEY_MGMT_IEEE8021X = 0, 233 WLAN_CRYPTO_KEY_MGMT_PSK = 1, 234 WLAN_CRYPTO_KEY_MGMT_NONE = 2, 235 WLAN_CRYPTO_KEY_MGMT_IEEE8021X_NO_WPA = 3, 236 WLAN_CRYPTO_KEY_MGMT_WPA_NONE = 4, 237 WLAN_CRYPTO_KEY_MGMT_FT_IEEE8021X = 5, 238 WLAN_CRYPTO_KEY_MGMT_FT_PSK = 6, 239 WLAN_CRYPTO_KEY_MGMT_IEEE8021X_SHA256 = 7, 240 WLAN_CRYPTO_KEY_MGMT_PSK_SHA256 = 8, 241 WLAN_CRYPTO_KEY_MGMT_WPS = 9, 242 WLAN_CRYPTO_KEY_MGMT_SAE = 10, 243 WLAN_CRYPTO_KEY_MGMT_FT_SAE = 11, 244 WLAN_CRYPTO_KEY_MGMT_WAPI_PSK = 12, 245 WLAN_CRYPTO_KEY_MGMT_WAPI_CERT = 13, 246 WLAN_CRYPTO_KEY_MGMT_CCKM = 14, 247 WLAN_CRYPTO_KEY_MGMT_OSEN = 15, 248 WLAN_CRYPTO_KEY_MGMT_IEEE8021X_SUITE_B = 16, 249 WLAN_CRYPTO_KEY_MGMT_IEEE8021X_SUITE_B_192 = 17, 250 WLAN_CRYPTO_KEY_MGMT_FILS_SHA256 = 18, 251 WLAN_CRYPTO_KEY_MGMT_FILS_SHA384 = 19, 252 WLAN_CRYPTO_KEY_MGMT_FT_FILS_SHA256 = 20, 253 WLAN_CRYPTO_KEY_MGMT_FT_FILS_SHA384 = 21, 254 WLAN_CRYPTO_KEY_MGMT_OWE = 22, 255 WLAN_CRYPTO_KEY_MGMT_DPP = 23, 256 WLAN_CRYPTO_KEY_MGMT_FT_IEEE8021X_SHA384 = 24, 257 WLAN_CRYPTO_KEY_MGMT_FT_PSK_SHA384 = 25, 258 WLAN_CRYPTO_KEY_MGMT_PSK_SHA384 = 26, 259 WLAN_CRYPTO_KEY_MGMT_SAE_EXT_KEY = 27, 260 /** Keep WLAN_CRYPTO_KEY_MGMT_MAX at the end. */ 261 WLAN_CRYPTO_KEY_MGMT_MAX, 262 } wlan_crypto_key_mgmt; 263 264 enum wlan_crypto_key_type { 265 WLAN_CRYPTO_KEY_TYPE_UNICAST, 266 WLAN_CRYPTO_KEY_TYPE_GROUP, 267 }; 268 269 #define IS_WEP_CIPHER(_c) ((_c == WLAN_CRYPTO_CIPHER_WEP) || \ 270 (_c == WLAN_CRYPTO_CIPHER_WEP_40) || \ 271 (_c == WLAN_CRYPTO_CIPHER_WEP_104)) 272 273 #define DEFAULT_KEYMGMT_6G_MASK 0xFFFFFFFF 274 275 /* AKM wlan_crypto_key_mgmt 1, 6, 8, 25 and 26 are not allowed. */ 276 #define ALLOWED_KEYMGMT_6G_MASK 0x09FFFEBD 277 278 /* 279 * enum fils_erp_cryptosuite: this enum defines the cryptosuites used 280 * to calculate auth tag and auth tag length as defined by RFC 6696 5.3.1 281 * @HMAC_SHA256_64: sha256 with auth tag len as 64 bits 282 * @HMAC_SHA256_128: sha256 with auth tag len as 128 bits 283 * @HMAC_SHA256_256: sha256 with auth tag len as 256 bits 284 */ 285 enum fils_erp_cryptosuite { 286 INVALID_CRYPTO = 0, /* reserved */ 287 HMAC_SHA256_64, 288 HMAC_SHA256_128, 289 HMAC_SHA256_256, 290 }; 291 292 /** 293 * struct mobility_domain_params - structure containing 294 * mobility domain info 295 * @mdie_present: mobility domain present or not 296 * @mobility_domain: mobility domain 297 */ 298 struct mobility_domain_params { 299 uint8_t mdie_present; 300 uint16_t mobility_domain; 301 }; 302 303 /** 304 * struct wlan_crypto_pmksa - structure of crypto to contain pmkid 305 * @bssid: bssid for which pmkid is saved 306 * @pmkid: pmkid info 307 * @pmk: pmk info 308 * @pmk_len: pmk len 309 * @ssid_len: ssid length 310 * @ssid: ssid information 311 * @cache_id: cache id 312 * @pmk_lifetime: Duration in seconds for which the pmk is valid 313 * @pmk_lifetime_threshold: Percentage of pmk lifetime within which 314 * full authentication is expected to avoid disconnection. 315 * @pmk_entry_ts: System timestamp at which the PMK entry was created. 316 * @single_pmk_supported: SAE single pmk supported BSS 317 * @mdid: structure to contain mobility domain parameters 318 */ 319 struct wlan_crypto_pmksa { 320 struct qdf_mac_addr bssid; 321 uint8_t pmkid[PMKID_LEN]; 322 uint8_t pmk[MAX_PMK_LEN]; 323 uint8_t pmk_len; 324 uint8_t ssid_len; 325 uint8_t ssid[WLAN_SSID_MAX_LEN]; 326 uint8_t cache_id[WLAN_CACHE_ID_LEN]; 327 uint32_t pmk_lifetime; 328 uint8_t pmk_lifetime_threshold; 329 qdf_time_t pmk_entry_ts; 330 #if defined(WLAN_SAE_SINGLE_PMK) && defined(WLAN_FEATURE_ROAM_OFFLOAD) 331 bool single_pmk_supported; 332 #endif 333 struct mobility_domain_params mdid; 334 }; 335 336 #ifdef WLAN_ADAPTIVE_11R 337 /** 338 * struct key_mgmt_list - structure to store AKM(s) present in RSN IE of 339 * Beacon/Probe response 340 * @key_mgmt: AKM(s) present in RSN IE of Beacon/Probe response 341 */ 342 struct key_mgmt_list { 343 uint32_t key_mgmt; 344 }; 345 #endif 346 347 /** 348 * struct wlan_crypto_params - holds crypto params 349 * @authmodeset: authentication mode 350 * @ucastcipherset: unicast ciphers 351 * @mcastcipherset: multicast cipher 352 * @mgmtcipherset: mgmt cipher 353 * @cipher_caps: cipher capability 354 * @key_mgmt: key mgmt 355 * @pmksa: pmksa 356 * @rsn_caps: rsn_capability 357 * @akm_list: order of AKM present in RSN IE of Beacon/Probe response 358 * 359 * This structure holds crypto params for peer or vdev 360 */ 361 struct wlan_crypto_params { 362 uint32_t authmodeset; 363 uint32_t ucastcipherset; 364 uint32_t mcastcipherset; 365 uint32_t mgmtcipherset; 366 uint32_t cipher_caps; 367 uint32_t key_mgmt; 368 struct wlan_crypto_pmksa *pmksa[WLAN_CRYPTO_MAX_PMKID]; 369 uint16_t rsn_caps; 370 #ifdef WLAN_ADAPTIVE_11R 371 struct key_mgmt_list akm_list[WLAN_CRYPTO_KEY_MGMT_MAX]; 372 #endif 373 }; 374 375 /** 376 * struct wlan_crypto_ltf_keyseed_data - LTF keyseed parameters 377 * @vdev_id: Vdev id 378 * @peer_mac_addr: Peer mac address 379 * @src_mac_addr: Source mac address 380 * @rsn_authmode: Cipher suite 381 * @key_seed: Secure LTF key seed 382 * @key_seed_len: Key seed length 383 */ 384 struct wlan_crypto_ltf_keyseed_data { 385 uint8_t vdev_id; 386 struct qdf_mac_addr peer_mac_addr; 387 struct qdf_mac_addr src_mac_addr; 388 uint8_t rsn_authmode; 389 uint8_t key_seed[WLAN_MAX_SECURE_LTF_KEYSEED_LEN]; 390 uint16_t key_seed_len; 391 }; 392 393 typedef enum wlan_crypto_param_type { 394 WLAN_CRYPTO_PARAM_AUTH_MODE, 395 WLAN_CRYPTO_PARAM_UCAST_CIPHER, 396 WLAN_CRYPTO_PARAM_MCAST_CIPHER, 397 WLAN_CRYPTO_PARAM_MGMT_CIPHER, 398 WLAN_CRYPTO_PARAM_CIPHER_CAP, 399 WLAN_CRYPTO_PARAM_RSN_CAP, 400 WLAN_CRYPTO_PARAM_KEY_MGMT, 401 WLAN_CRYPTO_PARAM_PMKSA, 402 } wlan_crypto_param_type; 403 404 /** 405 * struct wlan_crypto_key - key structure 406 * @keylen: length of the key 407 * @valid: is key valid or not 408 * @flags: key flags 409 * @keyix: key id 410 * @cipher_type: cipher type being used for this key 411 * @key_type: unicast or broadcast key 412 * @macaddr: 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 enum wlan_crypto_key_type key_type; 435 uint8_t macaddr[QDF_MAC_ADDR_SIZE]; 436 struct qdf_mac_addr src_addr; 437 void *cipher_table; 438 void *private; 439 qdf_spinlock_t keylock; 440 uint8_t recviv[WLAN_CRYPTO_WAPI_IV_SIZE]; 441 uint8_t txiv[WLAN_CRYPTO_WAPI_IV_SIZE]; 442 uint64_t keytsc; 443 uint64_t keyrsc[WLAN_CRYPTO_TID_SIZE]; 444 uint64_t keyrsc_suspect[WLAN_CRYPTO_TID_SIZE]; 445 uint64_t keyglobal; 446 uint8_t keyval[WLAN_CRYPTO_KEYBUF_SIZE 447 + WLAN_CRYPTO_MICBUF_SIZE]; 448 #define txmic (keyval + WLAN_CRYPTO_KEYBUF_SIZE \ 449 + WLAN_CRYPTO_TXMIC_OFFSET) 450 #define rxmic (keyval + WLAN_CRYPTO_KEYBUF_SIZE \ 451 + WLAN_CRYPTO_RXMIC_OFFSET) 452 }; 453 454 /** 455 * struct wlan_crypto_req_key - key request structure 456 * @type: key/cipher type 457 * @pad: padding member 458 * @keyix: key index 459 * @keylen: length of the key value 460 * @flags: key flags 461 * @macaddr: macaddr of the key 462 * @keyrsc: key receive sequence counter 463 * @keytsc: key transmit sequence counter 464 * @keydata: key value 465 * @txiv: wapi key tx iv 466 * @recviv: wapi key rx iv 467 * @filsaad: FILS AEAD data 468 * 469 * Key request structure used for setkey, getkey or delkey 470 */ 471 struct wlan_crypto_req_key { 472 uint8_t type; 473 uint8_t pad; 474 uint16_t keyix; 475 uint8_t keylen; 476 uint16_t flags; 477 uint8_t macaddr[QDF_MAC_ADDR_SIZE]; 478 uint64_t keyrsc; 479 uint64_t keytsc; 480 uint8_t keydata[WLAN_CRYPTO_KEYBUF_SIZE + WLAN_CRYPTO_MICBUF_SIZE]; 481 uint8_t txiv[WLAN_CRYPTO_WAPI_IV_SIZE]; 482 uint8_t recviv[WLAN_CRYPTO_WAPI_IV_SIZE]; 483 #ifdef WLAN_CRYPTO_SUPPORT_FILS 484 struct wlan_crypto_fils_aad_key filsaad; 485 #endif 486 }; 487 488 /** 489 * struct wlan_lmac_if_crypto_tx_ops - structure of crypto function 490 * pointers 491 * @allockey: function pointer to alloc key in hw 492 * @setkey: function pointer to setkey in hw 493 * @delkey: function pointer to delkey in hw 494 * @defaultkey: function pointer to set default key 495 * @set_key: converged function pointer to set key in hw 496 * @getpn: function pointer to get current pn value of peer 497 * @set_ltf_keyseed: Set LTF keyseed 498 * @set_vdev_param: Set the vdev crypto parameter 499 * @register_events: function pointer to register wmi event handler 500 * @deregister_events: function pointer to deregister wmi event handler 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, uint8_t keyix, 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 * @crypto_encap: function pointer to encap tx frame 532 * @crypto_decap: function pointer to decap rx frame in hw 533 * @crypto_enmic: function pointer to enmic tx frame 534 * @crypto_demic: function pointer to demic rx frame 535 * @set_peer_wep_keys: function pointer to set WEP keys 536 * @get_rxpn: function pointer to get current Rx pn value of peer 537 */ 538 539 struct wlan_lmac_if_crypto_rx_ops { 540 QDF_STATUS(*crypto_encap)(struct wlan_objmgr_vdev *vdev, 541 qdf_nbuf_t wbuf, uint8_t *macaddr, 542 uint8_t encapdone); 543 QDF_STATUS(*crypto_decap)(struct wlan_objmgr_vdev *vdev, 544 qdf_nbuf_t wbuf, uint8_t *macaddr, 545 uint8_t tid); 546 QDF_STATUS(*crypto_enmic)(struct wlan_objmgr_vdev *vdev, 547 qdf_nbuf_t wbuf, uint8_t *macaddr, 548 uint8_t encapdone); 549 QDF_STATUS(*crypto_demic)(struct wlan_objmgr_vdev *vdev, 550 qdf_nbuf_t wbuf, uint8_t *macaddr, 551 uint8_t tid, uint8_t keyid); 552 QDF_STATUS(*set_peer_wep_keys)(struct wlan_objmgr_vdev *vdev, 553 struct wlan_objmgr_peer *peer); 554 QDF_STATUS (*get_rxpn)(struct wlan_objmgr_vdev *vdev, 555 uint8_t *macaddr, uint16_t keyix); 556 }; 557 558 #define WLAN_CRYPTO_RX_OPS_ENCAP(crypto_rx_ops) \ 559 (crypto_rx_ops->crypto_encap) 560 #define WLAN_CRYPTO_RX_OPS_DECAP(crypto_rx_ops) \ 561 (crypto_rx_ops->crypto_decap) 562 #define WLAN_CRYPTO_RX_OPS_ENMIC(crypto_rx_ops) \ 563 (crypto_rx_ops->crypto_enmic) 564 #define WLAN_CRYPTO_RX_OPS_DEMIC(crypto_rx_ops) \ 565 (crypto_rx_ops->crypto_demic) 566 #define WLAN_CRYPTO_RX_OPS_SET_PEER_WEP_KEYS(crypto_rx_ops) \ 567 (crypto_rx_ops->set_peer_wep_keys) 568 #define WLAN_CRYPTO_RX_OPS_GET_RXPN(crypto_rx_ops) \ 569 ((crypto_rx_ops)->get_rxpn) 570 571 #define WLAN_CRYPTO_IS_WPA_WPA2(akm) \ 572 (QDF_HAS_PARAM(akm, WLAN_CRYPTO_KEY_MGMT_IEEE8021X) || \ 573 QDF_HAS_PARAM(akm, WLAN_CRYPTO_KEY_MGMT_PSK) || \ 574 QDF_HAS_PARAM(akm, WLAN_CRYPTO_KEY_MGMT_FT_IEEE8021X) || \ 575 QDF_HAS_PARAM(akm, WLAN_CRYPTO_KEY_MGMT_FT_PSK) || \ 576 QDF_HAS_PARAM(akm, WLAN_CRYPTO_KEY_MGMT_IEEE8021X_SHA256) || \ 577 QDF_HAS_PARAM(akm, WLAN_CRYPTO_KEY_MGMT_PSK_SHA256) || \ 578 QDF_HAS_PARAM(akm, WLAN_CRYPTO_KEY_MGMT_WPS) || \ 579 QDF_HAS_PARAM(akm, WLAN_CRYPTO_KEY_MGMT_WAPI_PSK) || \ 580 QDF_HAS_PARAM(akm, WLAN_CRYPTO_KEY_MGMT_WAPI_CERT) || \ 581 QDF_HAS_PARAM(akm, WLAN_CRYPTO_KEY_MGMT_CCKM) || \ 582 QDF_HAS_PARAM(akm, WLAN_CRYPTO_KEY_MGMT_OSEN) || \ 583 QDF_HAS_PARAM(akm, WLAN_CRYPTO_KEY_MGMT_IEEE8021X_SUITE_B) || \ 584 QDF_HAS_PARAM(akm, WLAN_CRYPTO_KEY_MGMT_FILS_SHA256) || \ 585 QDF_HAS_PARAM(akm, WLAN_CRYPTO_KEY_MGMT_FILS_SHA384) || \ 586 QDF_HAS_PARAM(akm, WLAN_CRYPTO_KEY_MGMT_FT_FILS_SHA256) || \ 587 QDF_HAS_PARAM(akm, WLAN_CRYPTO_KEY_MGMT_FT_FILS_SHA384) || \ 588 QDF_HAS_PARAM(akm, WLAN_CRYPTO_KEY_MGMT_FT_PSK_SHA384) || \ 589 QDF_HAS_PARAM(akm, WLAN_CRYPTO_KEY_MGMT_PSK_SHA384)) 590 591 #endif /* end of _WLAN_CRYPTO_GLOBAL_DEF_H_ */ 592