1 /** @file keyCommonDef.h 2 * 3 * @brief This file contains normal data type for key management 4 * 5 * Copyright (C) 2014-2017, Marvell International Ltd. 6 * 7 * This software file (the "File") is distributed by Marvell International 8 * Ltd. under the terms of the GNU General Public License Version 2, June 1991 9 * (the "License"). You may use, redistribute and/or modify this File in 10 * accordance with the terms and conditions of the License, a copy of which 11 * is available by writing to the Free Software Foundation, Inc., 12 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the 13 * worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. 14 * 15 * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE 16 * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE 17 * ARE EXPRESSLY DISCLAIMED. The License provides additional details about 18 * this warranty disclaimer. 19 */ 20 21 /****************************************************** 22 Change log: 23 03/07/2014: Initial version 24 ******************************************************/ 25 #ifndef _KEYMGMT_COMMON_H_ 26 #define _KEYMGMT_COMMON_H_ 27 28 #include "wltypes.h" 29 #include "IEEE_types.h" 30 #include "wl_mib_rom.h" 31 #include "KeyApiStaDefs.h" 32 33 #define NONCE_SIZE 32 34 #define EAPOL_MIC_KEY_SIZE 16 35 #define EAPOL_MIC_SIZE 16 36 #define EAPOL_ENCR_KEY_SIZE 16 37 #define MAC_ADDR_SIZE 6 38 #define TK_SIZE 16 39 #define HDR_8021x_LEN 4 40 #define KEYMGMTTIMEOUTVAL 10 41 #define TDLS_MIC_KEY_SIZE 16 42 43 #define EAPOL_PROTOCOL_V1 1 44 #define EAPOL_PROTOCOL_V2 2 45 46 #define UAP_HOSTCMD_KEYMGMT_EAP BIT0 47 #define UAP_HOSTCMD_KEYMGMT_PSK BIT1 48 #define UAP_HOSTCMD_KEYMGMT_NONE BIT2 49 #define UAP_HOSTCMD_KEYMGMT_PSK_SHA256 BIT8 50 51 #define UAP_HOSTCMD_CIPHER_WEP40 0x01 52 #define UAP_HOSTCMD_CIPHER_WEP104 0x02 53 #define UAP_HOSTCMD_CIPHER_TKIP 0x04 54 #define UAP_HOSTCMD_CIPHER_CCMP 0x08 55 #define UAP_HOSTCMD_CIPHER_MASK 0x0F 56 57 typedef struct { 58 UINT8 Key[TK_SIZE]; 59 UINT8 RxMICKey[8]; 60 UINT8 TxMICKey[8]; 61 UINT32 TxIV32; 62 UINT16 TxIV16; 63 UINT16 KeyIndex; 64 } KeyData_t; 65 66 #define MAX_WEP_KEYS 4 67 /* This structure is used in rom and existing fields should not be changed */ 68 /* This structure is already aligned and hence packing is not needed */ 69 70 typedef struct cipher_key_hdr_t { 71 IEEEtypes_MacAddr_t macAddr; 72 UINT8 keyDirection; 73 UINT8 keyType:4; 74 UINT8 version:4; 75 UINT16 keyLen; 76 UINT8 keyState; 77 UINT8 keyInfo; 78 } cipher_key_hdr_t; 79 80 /* This structure is used in rom and existing fields should not be changed */ 81 typedef struct tkip_aes_key_data_t { 82 // key material information (TKIP/AES/WEP) 83 UINT8 key[CRYPTO_KEY_LEN_MAX]; 84 UINT8 txMICKey[MIC_KEY_LEN_MAX]; 85 UINT8 rxMICKey[MIC_KEY_LEN_MAX]; 86 UINT32 hiReplayCounter32; //!< initialized by host 87 UINT16 loReplayCounter16; //!< initialized by host 88 UINT32 txIV32; //!< controlled by FW 89 UINT16 txIV16; //!< controlled by FW 90 UINT32 TKIPMicLeftValue; 91 UINT32 TKIPMicRightValue; 92 93 /* HW new design for 8682 only to support interleaving 94 * FW need to save these value and 95 * restore for next fragment 96 */ 97 UINT32 TKIPMicData0Value; 98 UINT32 TKIPMicData1Value; 99 UINT32 TKIPMicData2Value; 100 UINT8 keyIdx; 101 UINT8 reserved[3]; 102 103 } tkip_aes_key_data_t; 104 105 /* This structure is used in rom and existing fields should not be changed */ 106 typedef struct wep_key_data_t { 107 MIB_WEP_DEFAULT_KEYS WepDefaultKeys[MAX_WEP_KEYS]; 108 UINT8 default_key_idx; 109 UINT8 keyCfg; 110 UINT8 Reserved; 111 } wep_key_data_t; 112 113 /* This structure is used in rom and existing fields should not be changed */ 114 typedef struct { 115 UINT8 key_idx; 116 UINT8 mickey[WAPI_MIC_LEN]; 117 UINT8 rawkey[WAPI_KEY_LEN]; 118 } wapi_key_detail_t; 119 120 /* cipher_key_t -> tkip_aes is much bigger than wapi_key_data_t and 121 * since wapi_key_data_t is not used by ROM it is ok to change this size. */ 122 123 typedef struct { 124 wapi_key_detail_t key; 125 UINT8 pn_inc; 126 UINT8 TxPN[WAPI_PN_LEN]; 127 UINT8 RxPN[WAPI_PN_LEN]; 128 UINT8 *pLastKey; //keep the orig cipher_key_t pointer 129 } wapi_key_data_t; 130 131 typedef struct { 132 UINT8 ANonce[NONCE_SIZE]; 133 KeyData_t pwsKeyData; 134 } eapolHskData_t; 135 136 /* This structure is used in rom and existing fields should not be changed */ 137 typedef struct cipher_key_t { 138 cipher_key_hdr_t hdr; 139 140 union ckd { 141 tkip_aes_key_data_t tkip_aes; 142 wep_key_data_t wep; 143 wapi_key_data_t wapi; 144 eapolHskData_t hskData; 145 } ckd; 146 } cipher_key_t; 147 148 typedef MLAN_PACK_START struct { 149 UINT8 protocol_ver; 150 IEEEtypes_8021x_PacketType_e pckt_type; 151 UINT16 pckt_body_len; 152 } MLAN_PACK_END Hdr_8021x_t; 153 154 typedef MLAN_PACK_START struct { 155 /* don't change this order. It is set to match the 156 ** endianness of the message 157 */ 158 159 /* Byte 1 */ 160 UINT16 KeyMIC:1; /* Bit 8 */ 161 UINT16 Secure:1; /* Bit 9 */ 162 UINT16 Error:1; /* Bit 10 */ 163 UINT16 Request:1; /* Bit 11 */ 164 UINT16 EncryptedKeyData:1; /* Bit 12 */ 165 UINT16 Reserved:3; /* Bits 13-15 */ 166 167 /* Byte 0 */ 168 UINT16 KeyDescriptorVersion:3; /* Bits 0-2 */ 169 UINT16 KeyType:1; /* Bit 3 */ 170 UINT16 KeyIndex:2; /* Bits 4-5 */ 171 UINT16 Install:1; /* Bit 6 */ 172 UINT16 KeyAck:1; /* Bit 7 */ 173 174 } MLAN_PACK_END key_info_t; 175 176 #define KEY_DESCRIPTOR_HMAC_MD5_RC4 (1U << 0) 177 #define KEY_DESCRIPTOR_HMAC_SHA1_AES (1U << 1) 178 #define EAPOL_KeyMsg_Len (100) 179 /* WPA2 GTK IE */ 180 typedef MLAN_PACK_START struct { 181 UINT8 KeyID:2; 182 UINT8 Tx:1; 183 UINT8 rsvd:5; 184 UINT8 rsvd1; 185 UINT8 GTK[1]; 186 } MLAN_PACK_END GTK_KDE_t; 187 188 /* WPA2 Key Data */ 189 typedef MLAN_PACK_START struct { 190 UINT8 type; 191 UINT8 length; 192 UINT8 OUI[3]; 193 UINT8 dataType; 194 UINT8 data[1]; 195 } MLAN_PACK_END KDE_t; 196 197 typedef MLAN_PACK_START struct { 198 uint8 llc[3]; 199 uint8 snap_oui[3]; 200 uint16 snap_type; 201 } MLAN_PACK_END llc_snap_t; 202 203 typedef MLAN_PACK_START struct { 204 Hdr_8021x_t hdr_8021x; 205 UINT8 desc_type; 206 key_info_t key_info; 207 UINT16 key_length; 208 UINT32 replay_cnt[2]; 209 UINT8 key_nonce[NONCE_SIZE]; /*32 bytes */ 210 UINT8 EAPOL_key_IV[16]; 211 UINT8 key_RSC[8]; 212 UINT8 key_ID[8]; 213 UINT8 key_MIC[EAPOL_MIC_KEY_SIZE]; 214 UINT16 key_material_len; 215 UINT8 key_data[1]; 216 } MLAN_PACK_END EAPOL_KeyMsg_t; 217 218 typedef MLAN_PACK_START struct { 219 Hdr_8021x_t hdr_8021x; 220 IEEEtypes_8021x_CodeType_e code; 221 UINT8 identifier; 222 UINT16 length; 223 UINT8 data[1]; 224 } MLAN_PACK_END EAP_PacketMsg_t; 225 226 typedef MLAN_PACK_START struct { 227 ether_hdr_t ethHdr; 228 EAPOL_KeyMsg_t keyMsg; 229 } MLAN_PACK_END EAPOL_KeyMsg_Tx_t; 230 231 #endif 232