1 /* 2 * Copyright (c) 2017-2018 The Linux Foundation. All rights reserved. 3 * 4 * Permission to use, copy, modify, and/or distribute this software for 5 * any purpose with or without fee is hereby granted, provided that the 6 * above copyright notice and this permission notice appear in all 7 * copies. 8 * 9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 10 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 11 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 12 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL 13 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR 14 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 15 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 16 * PERFORMANCE OF THIS SOFTWARE. 17 */ 18 19 /** 20 * DOC: Private definations for handling crypto params 21 */ 22 #ifndef _WLAN_CRYPTO_DEF_I_H_ 23 #define _WLAN_CRYPTO_DEF_I_H_ 24 25 #include "wlan_crypto_aes_i.h" 26 27 /* IEEE 802.11 defines */ 28 #define WLAN_FC_PVER 0x0003 29 #define WLAN_FC_TODS 0x0100 30 #define WLAN_FC_FROMDS 0x0200 31 #define WLAN_FC_MOREFRAG 0x0400 32 #define WLAN_FC_RETRY 0x0800 33 #define WLAN_FC_PWRMGT 0x1000 34 #define WLAN_FC_MOREDATA 0x2000 35 #define WLAN_FC_ISWEP 0x4000 36 #define WLAN_FC_ORDER 0x8000 37 38 #define WLAN_FC_GET_TYPE(fc) (((fc) & 0x000c) >> 2) 39 #define WLAN_FC_GET_STYPE(fc) (((fc) & 0x00f0) >> 4) 40 41 #define WLAN_INVALID_MGMT_SEQ 0xffff 42 #define WLAN_SEQ_MASK 0x0fff 43 #define WLAN_QOS_TID_MASK 0x00ff 44 #define WLAN_GET_SEQ_FRAG(seq) ((seq) & (BIT(3) | BIT(2) | BIT(1) | BIT(0))) 45 #define WLAN_GET_SEQ_SEQ(seq) \ 46 (((seq) & (~(BIT(3) | BIT(2) | BIT(1) | BIT(0)))) >> 4) 47 48 #define WLAN_FC_TYPE_MGMT 0 49 #define WLAN_FC_TYPE_CTRL 1 50 #define WLAN_FC_TYPE_DATA 2 51 52 /* management */ 53 #define WLAN_FC_STYPE_ASSOC_REQ 0 54 #define WLAN_FC_STYPE_ASSOC_RESP 1 55 #define WLAN_FC_STYPE_REASSOC_REQ 2 56 #define WLAN_FC_STYPE_REASSOC_RESP 3 57 #define WLAN_FC_STYPE_PROBE_REQ 4 58 #define WLAN_FC_STYPE_PROBE_RESP 5 59 #define WLAN_FC_STYPE_BEACON 8 60 #define WLAN_FC_STYPE_ATIM 9 61 #define WLAN_FC_STYPE_DISASSOC 10 62 #define WLAN_FC_STYPE_AUTH 11 63 #define WLAN_FC_STYPE_DEAUTH 12 64 #define WLAN_FC_STYPE_ACTION 13 65 66 /* control */ 67 #define WLAN_FC_STYPE_PSPOLL 10 68 #define WLAN_FC_STYPE_RTS 11 69 #define WLAN_FC_STYPE_CTS 12 70 #define WLAN_FC_STYPE_ACK 13 71 #define WLAN_FC_STYPE_CFEND 14 72 #define WLAN_FC_STYPE_CFENDACK 15 73 74 /* data */ 75 #define WLAN_FC_STYPE_DATA 0 76 #define WLAN_FC_STYPE_DATA_CFACK 1 77 #define WLAN_FC_STYPE_DATA_CFPOLL 2 78 #define WLAN_FC_STYPE_DATA_CFACKPOLL 3 79 #define WLAN_FC_STYPE_NULLFUNC 4 80 #define WLAN_FC_STYPE_CFACK 5 81 #define WLAN_FC_STYPE_CFPOLL 6 82 #define WLAN_FC_STYPE_CFACKPOLL 7 83 #define WLAN_FC_STYPE_QOS_DATA 8 84 #define WLAN_FC_STYPE_QOS_DATA_CFACK 9 85 #define WLAN_FC_STYPE_QOS_DATA_CFPOLL 10 86 #define WLAN_FC_STYPE_QOS_DATA_CFACKPOLL 11 87 #define WLAN_FC_STYPE_QOS_NULL 12 88 #define WLAN_FC_STYPE_QOS_CFPOLL 14 89 #define WLAN_FC_STYPE_QOS_CFACKPOLL 15 90 91 #define WLAN_TID_SIZE 17 92 #define WLAN_NONQOS_SEQ 16 93 94 /* Macros for handling unaligned memory accesses */ 95 96 static inline uint16_t wlan_crypto_get_be16(const uint8_t *a) 97 { 98 return (a[0] << 8) | a[1]; 99 } 100 101 static inline void wlan_crypto_put_be16(uint8_t *a, uint16_t val) 102 { 103 a[0] = val >> 8; 104 a[1] = val & 0xff; 105 } 106 107 static inline uint16_t wlan_crypto_get_le16(const uint8_t *a) 108 { 109 return (a[1] << 8) | a[0]; 110 } 111 112 static inline void wlan_crypto_put_le16(uint8_t *a, uint16_t val) 113 { 114 a[1] = val >> 8; 115 a[0] = val & 0xff; 116 } 117 118 static inline uint32_t wlan_crypto_get_be32(const uint8_t *a) 119 { 120 return ((u32) a[0] << 24) | (a[1] << 16) | (a[2] << 8) | a[3]; 121 } 122 123 static inline void wlan_crypto_put_be32(uint8_t *a, uint32_t val) 124 { 125 a[0] = (val >> 24) & 0xff; 126 a[1] = (val >> 16) & 0xff; 127 a[2] = (val >> 8) & 0xff; 128 a[3] = val & 0xff; 129 } 130 131 static inline uint32_t wlan_crypto_get_le32(const uint8_t *a) 132 { 133 return ((u32) a[3] << 24) | (a[2] << 16) | (a[1] << 8) | a[0]; 134 } 135 136 static inline void wlan_crypto_put_le32(uint8_t *a, uint32_t val) 137 { 138 a[3] = (val >> 24) & 0xff; 139 a[2] = (val >> 16) & 0xff; 140 a[1] = (val >> 8) & 0xff; 141 a[0] = val & 0xff; 142 } 143 144 static inline void wlan_crypto_put_be64(u8 *a, u64 val) 145 { 146 a[0] = val >> 56; 147 a[1] = val >> 48; 148 a[2] = val >> 40; 149 a[3] = val >> 32; 150 a[4] = val >> 24; 151 a[5] = val >> 16; 152 a[6] = val >> 8; 153 a[7] = val & 0xff; 154 } 155 156 #define WLAN_CRYPTO_TX_OPS_ALLOCKEY(psoc) \ 157 (psoc->soc_cb.tx_ops.crypto_tx_ops.allockey) 158 #define WLAN_CRYPTO_TX_OPS_SETKEY(psoc) \ 159 (psoc->soc_cb.tx_ops.crypto_tx_ops.setkey) 160 #define WLAN_CRYPTO_TX_OPS_DELKEY(psoc) \ 161 (psoc->soc_cb.tx_ops.crypto_tx_ops.delkey) 162 #define WLAN_CRYPTO_TX_OPS_DEFAULTKEY(psoc) \ 163 (psoc->soc_cb.tx_ops.crypto_tx_ops.defaultkey) 164 165 /* unalligned little endian access */ 166 #ifndef LE_READ_2 167 #define LE_READ_2(p) \ 168 ((uint16_t) \ 169 ((((const uint8_t *)(p))[0]) | \ 170 (((const uint8_t *)(p))[1] << 8))) 171 #endif 172 173 #ifndef LE_READ_4 174 #define LE_READ_4(p) \ 175 ((uint32_t) \ 176 ((((const uint8_t *)(p))[0]) | \ 177 (((const uint8_t *)(p))[1] << 8) | \ 178 (((const uint8_t *)(p))[2] << 16) | \ 179 (((const uint8_t *)(p))[3] << 24))) 180 #endif 181 182 #ifndef BE_READ_4 183 #define BE_READ_4(p) \ 184 ((uint32_t) \ 185 ((((const uint8_t *)(p))[0] << 24) | \ 186 (((const uint8_t *)(p))[1] << 16) | \ 187 (((const uint8_t *)(p))[2] << 8) | \ 188 (((const uint8_t *)(p))[3]))) 189 #endif 190 191 #ifndef READ_6 192 #define READ_6(b0, b1, b2, b3, b4, b5) ({ \ 193 uint32_t iv32 = (b0 << 0) | (b1 << 8) | (b2 << 16) | (b3 << 24);\ 194 uint16_t iv16 = (b4 << 0) | (b5 << 8);\ 195 (((uint64_t)iv16) << 32) | iv32;\ 196 }) 197 #endif 198 199 #define OUI_SIZE (4) 200 #define WLAN_CRYPTO_ADDSHORT(frm, v) \ 201 do {frm[0] = (v) & 0xff; frm[1] = (v) >> 8; frm += 2; } while (0) 202 203 #define WLAN_CRYPTO_ADDSELECTOR(frm, sel) \ 204 do { \ 205 uint32_t value = sel;\ 206 qdf_mem_copy(frm, (uint8_t *)&value, OUI_SIZE); \ 207 frm += OUI_SIZE; } while (0) 208 209 #define WLAN_CRYPTO_SELECTOR(a, b, c, d) \ 210 ((((uint32_t) (a)) << 24) | \ 211 (((uint32_t) (b)) << 16) | \ 212 (((uint32_t) (c)) << 8) | \ 213 (uint32_t) (d)) 214 215 #define WPA_TYPE_OUI WLAN_WPA_SEL(WLAN_WPA_OUI_TYPE) 216 217 #define WLAN_CRYPTO_WAPI_IE_LEN 20 218 #define WLAN_CRYPTO_WAPI_SMS4_CIPHER 0x01 219 220 #define WPA_AUTH_KEY_MGMT_NONE WLAN_WPA_SEL(WLAN_ASE_NONE) 221 #define WPA_AUTH_KEY_MGMT_UNSPEC_802_1X WLAN_WPA_SEL(WLAN_ASE_8021X_UNSPEC) 222 #define WPA_AUTH_KEY_MGMT_PSK_OVER_802_1X \ 223 WLAN_WPA_SEL(WLAN_ASE_8021X_PSK) 224 #define WPA_AUTH_KEY_MGMT_CCKM WLAN_WPA_CCKM_AKM 225 226 #define WPA_CIPHER_SUITE_NONE WLAN_WPA_SEL(WLAN_CSE_NONE) 227 #define WPA_CIPHER_SUITE_WEP40 WLAN_WPA_SEL(WLAN_CSE_WEP40) 228 #define WPA_CIPHER_SUITE_WEP104 WLAN_WPA_SEL(WLAN_CSE_WEP104) 229 #define WPA_CIPHER_SUITE_TKIP WLAN_WPA_SEL(WLAN_CSE_TKIP) 230 #define WPA_CIPHER_SUITE_CCMP WLAN_WPA_SEL(WLAN_CSE_CCMP) 231 232 #define RSN_AUTH_KEY_MGMT_NONE WLAN_RSN_SEL(0) 233 #define RSN_AUTH_KEY_MGMT_UNSPEC_802_1X WLAN_RSN_SEL(1) 234 #define RSN_AUTH_KEY_MGMT_PSK_OVER_802_1X\ 235 WLAN_RSN_SEL(2) 236 #define RSN_AUTH_KEY_MGMT_FT_802_1X WLAN_RSN_SEL(3) 237 #define RSN_AUTH_KEY_MGMT_FT_PSK WLAN_RSN_SEL(4) 238 #define RSN_AUTH_KEY_MGMT_802_1X_SHA256\ 239 WLAN_RSN_SEL(5) 240 #define RSN_AUTH_KEY_MGMT_PSK_SHA256 WLAN_RSN_SEL(6) 241 #define RSN_AUTH_KEY_MGMT_WPS WLAN_RSN_SEL(7) 242 #define RSN_AUTH_KEY_MGMT_SAE WLAN_RSN_SEL(8) 243 #define RSN_AUTH_KEY_MGMT_FT_SAE WLAN_RSN_SEL(9) 244 #define RSN_AUTH_KEY_MGMT_802_1X_SUITE_B\ 245 WLAN_RSN_SEL(11) 246 #define RSN_AUTH_KEY_MGMT_802_1X_SUITE_B_192\ 247 WLAN_RSN_SEL(12) 248 #define RSN_AUTH_KEY_MGMT_FT_802_1X_SUITE_B_192\ 249 WLAN_RSN_SEL(13) 250 251 #define RSN_AUTH_KEY_MGMT_CCKM WLAN_RSN_CCKM_AKM 252 #define RSN_AUTH_KEY_MGMT_OSEN (0x019a6f50) 253 254 #define RSN_CIPHER_SUITE_NONE WLAN_RSN_SEL(WLAN_CSE_NONE) 255 #define RSN_CIPHER_SUITE_WEP40 WLAN_RSN_SEL(WLAN_CSE_WEP40) 256 #define RSN_CIPHER_SUITE_TKIP WLAN_RSN_SEL(WLAN_CSE_TKIP) 257 #define RSN_CIPHER_SUITE_WEP104 WLAN_RSN_SEL(WLAN_CSE_WEP104) 258 #define RSN_CIPHER_SUITE_CCMP WLAN_RSN_SEL(WLAN_CSE_CCMP) 259 #define RSN_CIPHER_SUITE_AES_CMAC WLAN_RSN_SEL(WLAN_CSE_AES_CMAC) 260 #define RSN_CIPHER_SUITE_GCMP WLAN_RSN_SEL(WLAN_CSE_GCMP_128) 261 #define RSN_CIPHER_SUITE_GCMP_256 WLAN_RSN_SEL(WLAN_CSE_GCMP_256) 262 #define RSN_CIPHER_SUITE_CCMP_256 WLAN_RSN_SEL(WLAN_CSE_CCMP_256) 263 #define RSN_CIPHER_SUITE_BIP_GMAC_128 WLAN_RSN_SEL(WLAN_CSE_BIP_GMAC_128) 264 #define RSN_CIPHER_SUITE_BIP_GMAC_256 WLAN_RSN_SEL(WLAN_CSE_BIP_GMAC_256) 265 #define RSN_CIPHER_SUITE_BIP_CMAC_256 WLAN_RSN_SEL(WLAN_CSE_BIP_CMAC_256) 266 267 #define RESET_PARAM(__param) ((__param) = 0) 268 #define SET_PARAM(__param, __val) ((__param) |= (1<<(__val))) 269 #define HAS_PARAM(__param, __val) ((__param) & (1<<(__val))) 270 #define CLEAR_PARAM(__param, __val) ((__param) &= ((~1) << (__val))) 271 272 273 #define RESET_AUTHMODE(_param) ((_param)->authmodeset = 0) 274 #define SET_AUTHMODE(_param, _mode) ((_param)->authmodeset |= (1<<(_mode))) 275 #define HAS_AUTHMODE(_param, _mode) ((_param)->authmodeset & (1<<(_mode))) 276 277 #define AUTH_IS_OPEN(_param) HAS_AUTHMODE((_param), WLAN_CRYPTO_AUTH_OPEN) 278 #define AUTH_IS_SHARED_KEY(_param) \ 279 HAS_AUTHMODE((_param), WLAN_CRYPTO_AUTH_SHARED) 280 #define AUTH_IS_8021X(_param) HAS_AUTHMODE((_param), WLAN_CRYPTO_AUTH_8021X) 281 #define AUTH_IS_WPA(_param) HAS_AUTHMODE((_param), WLAN_CRYPTO_AUTH_WPA) 282 #define AUTH_IS_RSNA(_param) HAS_AUTHMODE((_param), WLAN_CRYPTO_AUTH_RSNA) 283 #define AUTH_IS_CCKM(_param) HAS_AUTHMODE((_param), WLAN_CRYPTO_AUTH_CCKM) 284 #define AUTH_IS_WAI(_param) HAS_AUTHMODE((_param), WLAN_CRYPTO_AUTH_WAPI) 285 #define AUTH_IS_WPA2(_param) AUTH_IS_RSNA(_param) 286 287 #define AUTH_MATCH(_param1, _param2) \ 288 (((_param1)->authmodeset & (_param2)->authmodeset) != 0) 289 290 291 #define RESET_UCAST_CIPHERS(_param) ((_param)->ucastcipherset = 0) 292 #define SET_UCAST_CIPHER(_param, _c) ((_param)->ucastcipherset |= (1<<(_c))) 293 #define HAS_UCAST_CIPHER(_param, _c) ((_param)->ucastcipherset & (1<<(_c))) 294 295 #define UCIPHER_IS_CLEAR(_param) \ 296 HAS_UCAST_CIPHER((_param), WLAN_CRYPTO_CIPHER_NONE) 297 #define UCIPHER_IS_WEP(_param) \ 298 HAS_UCAST_CIPHER((_param), WLAN_CRYPTO_CIPHER_WEP) 299 #define UCIPHER_IS_TKIP(_param) \ 300 HAS_UCAST_CIPHER((_param), WLAN_CRYPTO_CIPHER_TKIP) 301 #define UCIPHER_IS_CCMP128(_param) \ 302 HAS_UCAST_CIPHER((_param), WLAN_CRYPTO_CIPHER_AES_CCM) 303 #define UCIPHER_IS_CCMP256(_param) \ 304 HAS_UCAST_CIPHER((_param), WLAN_CRYPTO_CIPHER_AES_CCM_256) 305 #define UCIPHER_IS_GCMP128(_param) \ 306 HAS_UCAST_CIPHER((_param), WLAN_CRYPTO_CIPHER_AES_GCM) 307 #define UCIPHER_IS_GCMP256(_param) \ 308 HAS_UCAST_CIPHER((_param), WLAN_CRYPTO_CIPHER_AES_GCM_256) 309 #define UCIPHER_IS_SMS4(_param) \ 310 HAS_UCAST_CIPHER((_param), WLAN_CRYPTO_CIPHER_WAPI_SMS4) 311 312 #define RESET_MCAST_CIPHERS(_param) ((_param)->mcastcipherset = 0) 313 #define SET_MCAST_CIPHER(_param, _c) ((_param)->mcastcipherset |= (1<<(_c))) 314 #define HAS_MCAST_CIPHER(_param, _c) ((_param)->mcastcipherset & (1<<(_c))) 315 #define HAS_ANY_MCAST_CIPHER(_param) ((_param)->mcastcipherset) 316 #define CLEAR_MCAST_CIPHER(_param, _c) \ 317 ((_param)->mcastcipherset &= (~(1)<<(_c))) 318 319 #define MCIPHER_IS_CLEAR(_param) \ 320 HAS_MCAST_CIPHER((_param), WLAN_CRYPTO_CIPHER_NONE) 321 #define MCIPHER_IS_WEP(_param) \ 322 HAS_MCAST_CIPHER((_param), WLAN_CRYPTO_CIPHER_WEP) 323 #define MCIPHER_IS_TKIP(_param) \ 324 HAS_MCAST_CIPHER((_param), WLAN_CRYPTO_CIPHER_TKIP) 325 #define MCIPHER_IS_CCMP128(_param) \ 326 HAS_MCAST_CIPHER((_param), WLAN_CRYPTO_CIPHER_AES_CCM) 327 #define MCIPHER_IS_CCMP256(_param) \ 328 HAS_MCAST_CIPHER((_param), WLAN_CRYPTO_CIPHER_AES_CCM_256) 329 #define MCIPHER_IS_GCMP128(_param) \ 330 HAS_MCAST_CIPHER((_param), WLAN_CRYPTO_CIPHER_AES_GCM) 331 #define MCIPHER_IS_GCMP256(_param) \ 332 HAS_MCAST_CIPHER((_param), WLAN_CRYPTO_CIPHER_AES_GCM_256) 333 #define MCIPHER_IS_SMS4(_param) \ 334 HAS_MCAST_CIPHER((_param), WLAN_CRYPTO_CIPHER_WAPI_SMS4) 335 336 #define RESET_MGMT_CIPHERS(_param) ((_param)->mgmtcipherset = 0) 337 #define SET_MGMT_CIPHER(_param, _c) ((_param)->mgmtcipherset |= (1<<(_c))) 338 #define HAS_MGMT_CIPHER(_param, _c) ((_param)->mgmtcipherset & (1<<(_c))) 339 #define IS_MGMT_CIPHER(_c) ((_c == WLAN_CRYPTO_CIPHER_AES_CMAC) || \ 340 (_c == WLAN_CRYPTO_CIPHER_AES_CMAC_256) || \ 341 (_c == WLAN_CRYPTO_CIPHER_AES_GMAC) || \ 342 (_c == WLAN_CRYPTO_CIPHER_AES_GMAC_256)) 343 344 #define IS_FILS_CIPHER(_c) ((_c) == WLAN_CRYPTO_CIPHER_FILS_AEAD) 345 346 #define MGMT_CIPHER_IS_CMAC(_param) \ 347 HAS_MGMT_CIPHER((_param), WLAN_CRYPTO_CIPHER_AES_CMAC) 348 #define MGMT_CIPHER_IS_CMAC256(_param) \ 349 HAS_MGMT_CIPHER((_param), WLAN_CRYPTO_CIPHER_AES_CMAC_256) 350 #define MGMT_CIPHER_IS_GMAC(_param) \ 351 HAS_MGMT_CIPHER((_param), WLAN_CRYPTO_CIPHER_AES_GMAC) 352 #define MGMT_CIPHER_IS_GMAC256(_param) \ 353 HAS_MGMT_CIPHER((_param), WLAN_CRYPTO_CIPHER_AES_GMAC_256) 354 355 #define RESET_KEY_MGMT(_param) ((_param)->key_mgmt = 0) 356 #define SET_KEY_MGMT(_param, _c) ((_param)->key_mgmt |= (1<<(_c))) 357 #define HAS_KEY_MGMT(_param, _c) ((_param)->key_mgmt & (1<<(_c))) 358 359 #define UCAST_CIPHER_MATCH(_param1, _param2) \ 360 (((_param1)->ucastcipherset & (_param2)->ucastcipherset) != 0) 361 362 #define MCAST_CIPHER_MATCH(_param1, _param2) \ 363 (((_param1)->mcastcipherset & (_param2)->mcastcipherset) != 0) 364 365 #define MGMT_CIPHER_MATCH(_param1, _param2) \ 366 (((_param1)->mgmtcipherset & (_param2)->mgmtcipherset) != 0) 367 368 #define KEY_MGMTSET_MATCH(_param1, _param2) \ 369 (((_param1)->key_mgmt & (_param2)->key_mgmt) != 0 || \ 370 (!(_param1)->key_mgmt && !(_param2)->key_mgmt)) 371 372 #define RESET_CIPHER_CAP(_param) ((_param)->cipher_caps = 0) 373 #define SET_CIPHER_CAP(_param, _c) ((_param)->cipher_caps |= (1<<(_c))) 374 #define HAS_CIPHER_CAP(_param, _c) ((_param)->cipher_caps & (1<<(_c))) 375 #define HAS_ANY_CIPHER_CAP(_param) ((_param)->cipher_caps) 376 377 /** 378 * struct wlan_crypto_mmie - MMIE IE 379 * @element_id: element id 380 * @length: length of the ie 381 * @key_id: igtk key_id used 382 * @sequence_number: igtk PN number 383 * @mic: MIC for the frame 384 * 385 * This structure represents Management MIC information element (IEEE 802.11w) 386 */ 387 struct wlan_crypto_mmie { 388 uint8_t element_id; 389 uint8_t length; 390 uint16_t key_id; 391 uint8_t sequence_number[6]; 392 uint8_t mic[16]; 393 } __packed; 394 395 /** 396 * struct wlan_crypto_comp_priv - crypto component private structure 397 * @crypto_params: crypto params for the peer 398 * @key: key buffers for this peer 399 * @igtk_key: igtk key buffer for this peer 400 * @igtk_key_type: igtk key type 401 * @def_tx_keyid: default key used for this peer 402 * @def_igtk_tx_keyid default igtk key used for this peer 403 * @fils_aead_set fils params for this peer 404 * 405 */ 406 struct wlan_crypto_comp_priv { 407 struct wlan_crypto_params crypto_params; 408 struct wlan_crypto_key *key[WLAN_CRYPTO_MAXKEYIDX]; 409 struct wlan_crypto_key *igtk_key[WLAN_CRYPTO_MAXIGTKKEYIDX]; 410 uint32_t igtk_key_type; 411 uint8_t def_tx_keyid; 412 uint8_t def_igtk_tx_keyid; 413 uint8_t fils_aead_set; 414 }; 415 416 /** 417 * struct wlan_crypto_cipher - crypto cipher table 418 * @cipher_name: printable name 419 * @cipher: cipher type WLAN_CRYPTO_CIPHER_* 420 * @header: size of privacy header (bytes) 421 * @trailer: size of privacy trailer (bytes) 422 * @miclen: size of mic trailer (bytes) 423 * @keylen: max key length 424 * @setkey: function pointer for setkey 425 * @encap: function pointer for encap 426 * @decap: function pointer for decap 427 * @enmic: function pointer for enmic 428 * @demic: function pointer for demic 429 * 430 */ 431 struct wlan_crypto_cipher { 432 const char *cipher_name; 433 wlan_crypto_cipher_type cipher; 434 const uint8_t header; 435 const uint8_t trailer; 436 const uint8_t miclen; 437 const uint32_t keylen; 438 QDF_STATUS(*setkey)(struct wlan_crypto_key *); 439 QDF_STATUS(*encap)(struct wlan_crypto_key *, 440 qdf_nbuf_t, uint8_t, uint8_t); 441 QDF_STATUS(*decap)(struct wlan_crypto_key *, 442 qdf_nbuf_t, uint8_t, uint8_t); 443 QDF_STATUS(*enmic)(struct wlan_crypto_key *, 444 qdf_nbuf_t, uint8_t, uint8_t); 445 QDF_STATUS(*demic)(struct wlan_crypto_key *, 446 qdf_nbuf_t, uint8_t, uint8_t); 447 }; 448 449 450 /** 451 * wlan_crypto_is_data_protected - check is frame is protected or not 452 * @data: frame 453 * 454 * This function check is frame is protected or not 455 * 456 * Return: TRUE/FALSE 457 */ 458 static inline bool wlan_crypto_is_data_protected(const void *data) 459 { 460 const struct ieee80211_hdr *hdr = (const struct ieee80211_hdr *)data; 461 462 if (hdr->frame_control & WLAN_FC_ISWEP) 463 return true; 464 else 465 return false; 466 } 467 468 /** 469 * ieee80211_hdrsize - calculate frame header size 470 * @data: frame 471 * 472 * This function calculate frame header size 473 * 474 * Return: header size of the frame 475 */ 476 static inline int ieee80211_hdrsize(const void *data) 477 { 478 const struct ieee80211_hdr *hdr = (const struct ieee80211_hdr *)data; 479 int16_t size = sizeof(struct ieee80211_hdr); 480 481 if ((hdr->frame_control & (WLAN_FC_TODS | WLAN_FC_FROMDS)) 482 == (WLAN_FC_TODS | WLAN_FC_FROMDS)) { 483 size += WLAN_ALEN; 484 } 485 486 if (((WLAN_FC_GET_STYPE(hdr->frame_control) 487 == WLAN_FC_STYPE_QOS_DATA))) { 488 size += sizeof(uint16_t); 489 /* Qos frame with Order bit set indicates an HTC frame */ 490 if (hdr->frame_control & WLAN_FC_ORDER) 491 size += (sizeof(uint8_t)*4); 492 } 493 return size; 494 } 495 496 /** 497 * wlan_get_tid - get tid of the frame 498 * @data: frame 499 * 500 * This function get tid of the frame 501 * 502 * Return: tid of the frame 503 */ 504 static inline int wlan_get_tid(const void *data) 505 { 506 const struct ieee80211_hdr *hdr = (const struct ieee80211_hdr *)data; 507 508 if (((WLAN_FC_GET_STYPE(hdr->frame_control) 509 == WLAN_FC_STYPE_QOS_DATA))) { 510 if ((hdr->frame_control & (WLAN_FC_TODS | WLAN_FC_FROMDS)) 511 == (WLAN_FC_TODS | WLAN_FC_FROMDS)) { 512 return ((struct ieee80211_hdr_qos_addr4 *)data)->qos 513 & WLAN_QOS_TID_MASK; 514 } else { 515 return ((struct ieee80211_hdr_qos *)data)->qos 516 & WLAN_QOS_TID_MASK; 517 } 518 } else 519 return WLAN_NONQOS_SEQ; 520 } 521 #endif /* end of _WLAN_CRYPTO_DEF_I_H_ */ 522