xref: /OK3568_Linux_fs/kernel/drivers/net/wireless/rockchip_wlan/mvl88w8977/mlan/esa/authenticator.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /** @file authenticator.h
2  *
3  *  @brief This file contains the data structure for authenticator and supplicant.
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 _AUTHENTICATOR_H
26 #define _AUTHENTICATOR_H
27 
28 #include "wltypes.h"
29 #include "IEEE_types.h"
30 #include "wl_mib_rom.h"
31 #include "KeyApiStaDefs.h"
32 #include "keyApiStaTypes.h"
33 #include "keyCommonDef.h"
34 #include "keyMgmtApTypes.h"
35 #include "pmkCache_rom.h"
36 
37 #include "hostsa_def.h"
38 
39 extern const uint8 wpa_oui02[4];	/* WPA TKIP */
40 extern const uint8 wpa_oui04[4];	/* WPA AES */
41 extern const uint8 wpa_oui01[4];	/* WPA WEP-40 */
42 extern const uint8 wpa_oui05[4];	/* WPA WEP-104 */
43 extern const uint8 wpa_oui_none[4];	/* WPA NONE */
44 
45 extern const uint8 wpa2_oui02[4];	/* WPA2 TKIP */
46 extern const uint8 wpa2_oui04[4];	/* WPA2 AES */
47 extern const uint8 wpa2_oui01[4];	/* WPA2 WEP-40 */
48 extern const uint8 wpa2_oui05[4];	/* WPA2 WEP-104 */
49 
50 extern const uint8 wpa_oui[3];
51 extern const uint8 kde_oui[3];
52 
53 typedef enum {
54 	NO_MIC_FAILURE,
55 	FIRST_MIC_FAIL_IN_60_SEC,
56 	SECOND_MIC_FAIL_IN_60_SEC
57 } MIC_Fail_State_e;
58 
59 typedef struct {
60 	MIC_Fail_State_e status;
61 	BOOLEAN MICCounterMeasureEnabled;
62 	UINT32 disableStaAsso;
63 } MIC_Error_t;
64 
65 typedef struct {
66 	UINT8 TKIPICVErrors;
67 	UINT8 TKIPLocalMICFailures;
68 	UINT8 TKIPCounterMeasuresInvoked;
69 
70 } customMIB_RSNStats_t;
71 
72 typedef struct {
73 	UINT8 kck[16];		/* PTK_KCK = L(PTK,   0, 128); */
74 	UINT8 kek[16];		/* PTK_KEK = L(PTK, 128, 128); */
75 	UINT8 tk[16];		/* PTK_TK  = L(PTK, 256, 128); */
76 
77 } CcmPtk_t;
78 
79 typedef struct {
80 	UINT8 kck[16];		/* PTK_KCK = L(PTK,   0, 128); */
81 	UINT8 kek[16];		/* PTK_KEK = L(PTK, 128, 128); */
82 	UINT8 tk[16];		/* PTK_TK  = L(PTK, 256, 128); */
83 	UINT8 rxMicKey[8];
84 	UINT8 txMicKey[8];
85 
86 } TkipPtk_t;
87 
88 typedef struct {
89 	MIC_Error_t apMicError;
90 	t_void *apMicTimer;
91 
92 	UINT32 ageOutCnt;
93 	UINT32 stateInfo;
94 	//key mgmt data
95 	apKeyMgmtInfoSta_t keyMgmtInfo;
96 
97 	t_u8 RSNEnabled;
98 	UINT16 deauthReason;
99 
100 	UINT8 txPauseState;
101 	//RateChangeInfo[] is used by MAC HW to decide the start TX rate.
102 	//It should be placed in SQ. If staData_t is placed in ITCM/DTCM then put
103 	//staRateTable in SQ and use a pointer here
104 	//staRateTable RateChangeInfo;
105 	UINT16 stickyTimCount;
106 	BOOLEAN stickyTimEnabled;
107 
108 #ifdef DOT11W
109 	/* Peer STA PMF capability */
110 	BOOLEAN peerPMFCapable;
111 #endif
112 
113 } staData_t;
114 /**connectioninfo*/
115 typedef struct _cm_Connection {
116     /**Hand shake timer*/
117 	t_void *HskTimer;
118     /** Timer set flag */
119 	t_u8 timer_is_set;
120     /** authenticator Private pointer */
121 	t_void *priv;
122 	t_u8 mac_addr[MLAN_MAC_ADDR_LENGTH];
123     /**sta data for authenticator*/
124 	staData_t staData;
125     /**handshake data*/
126 	eapolHskData_t hskData;
127 } cm_Connection;
128 
129 typedef struct {
130 	IEEEtypes_CapInfo_t CapInfo;
131 	UINT32 AssocStationsCnt;
132 
133 	BOOLEAN updatePassPhrase;
134 
135 	KeyData_t grpKeyData;
136 	UINT8 GNonce[32];
137 
138 	/* Following two variables contain that multiple of BI which is just
139 	 ** greater than user configured ageout time in normal and PS mode. These
140 	 ** variables get updated at bss_start, and then are used whenever FW
141 	 ** resets STA age.
142 	 */
143 	UINT32 staAgeOutBcnCnt;
144 	UINT32 psStaAgeOutBcnCnt;
145 
146 	// Store group rekey time as a multiple of beacon interval.
147 	UINT32 grpRekeyCntConfigured;
148 	UINT32 grpRekeyCntRemaining;
149 
150 } BssData_t;
151 
152 typedef struct {
153 	UINT16 keyExchange:1;
154 	UINT16 authenticate:1;
155 	UINT16 reserved:14;
156 } Operation_t;
157 
158 typedef struct {
159 	Cipher_t mcstCipher;
160 	UINT8 mcstCipherCount;
161 
162 	Cipher_t wpaUcstCipher;
163 	UINT8 wpaUcstCipherCount;
164 
165 	Cipher_t wpa2UcstCipher;
166 	UINT8 wpa2UcstCipherCount;
167 
168 	UINT16 AuthKey;
169 	UINT16 AuthKeyCount;
170 	Operation_t Akmp;
171 	UINT32 GrpReKeyTime;
172 	UINT8 PSKPassPhrase[PSK_PASS_PHRASE_LEN_MAX];
173 	UINT8 PSKPassPhraseLen;
174 	UINT8 PSKValue[PMK_LEN_MAX];
175 	UINT8 MaxPwsHskRetries;
176 	UINT8 MaxGrpHskRetries;
177 	UINT32 PwsHskTimeOut;
178 	UINT32 GrpHskTimeOut;
179 	UINT8 RSNReplayProtEn;	/* RSN Replay Attack Protection flag */
180 } apRsnConfig_t;
181 
182 typedef struct {
183 	UINT8 ieSet;
184 	UINT8 version;
185 /*  UINT8      akmCnt     ;  */
186 	UINT8 akmTypes;
187 /*  UINT8      uCastCnt   ;  */
188 	UINT8 uCastTypes;
189 	UINT8 mCastTypes;
190 	UINT8 capInfo;
191 } wapi_ie_cfg_t;
192 
193 typedef struct {
194 	/* The This section only used for initialization of the connPtr */
195 	IEEEtypes_SsId_t SsId;
196 	IEEEtypes_Len_t SsIdLen;
197 	// odd-sized ele clubbed together to keep even alignment
198 	IEEEtypes_DtimPeriod_t DtimPeriod;
199 	IEEEtypes_BcnInterval_t BcnPeriod;
200 
201 	IEEEtypes_MacAddr_t BssId;
202 	UINT16 RtsThresh;
203 	UINT16 FragThresh;
204 	UINT8 ShortRetryLim;
205 	UINT8 LongRetryLim;
206 
207 	// Used in MBSS mode for software beacon suppression
208 	UINT8 MbssBcnIntFac;
209 	UINT8 MbssCurBcnIntCnt;
210 	UINT16 Reserved;
211 } CommonMlmeData_t;
212 
213 typedef struct {
214 	IEEEtypes_SsId_t SsId;
215 	IEEEtypes_Len_t SsIdLen;
216 
217 	UINT8 wpa_ie[MAX_IE_SIZE];
218 	UINT16 wpa_ielen;
219 	UINT8 rsn_ie[MAX_IE_SIZE];
220 	UINT16 rsn_ielen;
221 	UINT32 StaAgeOutTime;
222 	UINT32 PsStaAgeOutTime;
223 
224 	/* If the BssAddr field is not aligned on word boundary the hal
225 	   functions which update mac registers are unsafe for non-word
226 	   aligned pointers. Avoid direct use of the pointer to BssId
227 	   field in the hal functions */
228 	/*  this field is no longer used and we use mibOpdata_p->StaMacAddr
229 	   in its place now */
230 	IEEEtypes_MacAddr_t EepromMacAddr_defunct;
231 	IEEEtypes_DataRate_t OpRateSet[IEEEtypes_MAX_DATA_RATES_G];
232 
233 	// odd-sized ele clubbed together to keep even alignment
234 	UINT8 AuthType;
235 	UINT8 TxPowerLevel;
236 	IEEEtypes_DataRate_t TxDataRate;
237 	IEEEtypes_DataRate_t TxMCBCDataRate;
238 	UINT8 MaxStaSupported;
239 
240 	SecurityMode_t SecType;
241 	UINT8 Padding1[1];	//****** Use this for adding new members *******
242 	BOOLEAN apWmmEn;
243 	IEEEtypes_WMM_ParamElement_t apWmmParamSet;
244 
245 	BOOLEAN ap11nEn;
246 
247 	cipher_key_buf_t *pWepKeyBuf;
248 	cipher_key_buf_t *pGtkKeyBuf;
249 	UINT8 ScanChanCount;
250 	UINT8 AclStaCnt;
251 
252 	UINT8 Padding3[1];	//****** Use this for adding new members *******
253 	apRsnConfig_t RsnConfig;
254 	BOOLEAN apWmmPsEn;
255 	channelInfo_t ScanChanList[IEEEtypes_MAX_CHANNELS];	/* Channels to scan */
256 	CommonMlmeData_t comData;
257 	IEEEtypes_OBSS_ScanParam_t ObssScanParam;
258 
259 	cipher_key_buf_t *piGtkKeyBuf;
260 	UINT32 mgmtFrameSubtypeFwdEn;
261 	UINT8 Ht2040CoexEn;	// Enable/Disable 2040 Coex feature in uAP
262 
263 	UINT8 Padding4[1];	//****** Use this for adding new members *******
264 
265 	wapi_ie_cfg_t wapiCfg;
266 	IEEEtypes_ExtCapability_t ExtCap;
267 	UINT8 Padding6[1];	//****** Use this for adding new members *******
268 } BssConfig_t;
269 
270 typedef struct {
271 	BssConfig_t bssConfig;
272 	BssData_t bssData;
273 } apInfo_t;
274 #ifdef DRV_EMBEDDED_SUPPLICANT
275 typedef struct {
276 	/* This structure is ROM'd */
277 
278 	UINT8 RSNEnabled:1;	/* WPA, WPA2 */
279 	UINT8 pmkidValid:1;	/* PMKID valid */
280 	UINT8 rsnCapValid:1;
281 	UINT8 grpMgmtCipherValid:1;
282 	UINT8 rsvd:4;		/* rsvd */
283 
284 	SecurityMode_t wpaType;
285 	Cipher_t mcstCipher;
286 	Cipher_t ucstCipher;
287 	AkmSuite_t AKM;
288 	UINT8 PMKID[16];
289 
290 	IEEEtypes_RSNCapability_t rsnCap;
291 
292 	Cipher_t grpMgmtCipher;
293 
294 } RSNConfig_t;
295 
296 typedef struct {
297 	UINT8 ANonce[NONCE_SIZE];
298 	UINT8 SNonce[NONCE_SIZE];
299 	UINT8 EAPOL_MIC_Key[EAPOL_MIC_KEY_SIZE];
300 	UINT8 EAPOL_Encr_Key[EAPOL_ENCR_KEY_SIZE];
301 	UINT32 apCounterLo;	/* last valid replay counter from authenticator */
302 	UINT32 apCounterHi;
303 	UINT32 apCounterZeroDone;	/* have we processed replay == 0? */
304 	UINT32 staCounterLo;	/* counter used in request EAPOL frames */
305 	UINT32 staCounterHi;
306 
307 	BOOLEAN RSNDataTrafficEnabled;	/* Enabled after 4way handshake */
308 	BOOLEAN RSNSecured;	/* Enabled after group key is established */
309 	BOOLEAN pwkHandshakeComplete;
310 	cipher_key_t *pRxDecryptKey;
311 
312 	KeyData_t PWKey;
313 	KeyData_t GRKey;
314 
315 	KeyData_t newPWKey;
316 
317 	MIC_Error_t sta_MIC_Error;
318 	t_void *rsnTimer;
319 	t_void *micTimer;
320 	t_void *deauthDelayTimer;	/* hacked in to delay the deauth */
321 
322 	//phostsa_private psapriv;
323 
324 	KeyData_t IGtk;
325 
326 } keyMgmtInfoSta_t;
327 
328 typedef struct supplicantData {
329 	BOOLEAN inUse;
330 	BOOLEAN suppInitialized;
331 	IEEEtypes_SsIdElement_t hashSsId;
332 	IEEEtypes_MacAddr_t localBssid;
333 	IEEEtypes_MacAddr_t localStaAddr;
334 	customMIB_RSNStats_t customMIB_RSNStats;
335 	RSNConfig_t customMIB_RSNConfig;
336 	keyMgmtInfoSta_t keyMgmtInfoSta;
337 	SecurityParams_t currParams;
338 	UINT8 wpa_rsn_ie[MAX_IE_SIZE];
339 } supplicantData_t;
340 #endif
341 
342 /** supplicant/authenticator private structure */
343 typedef struct _hostsa_private {
344     /** pmlan_private */
345 	t_void *pmlan_private;
346     /** pmlan_adapter */
347 	t_void *pmlan_adapter;
348     /** Utility functions table */
349 	hostsa_util_fns util_fns;
350     /** MLAN APIs table */
351 	hostsa_mlan_fns mlan_fns;
352    /**apinf_t*/
353 	apInfo_t apinfo;
354    /**group rekey timer*/
355 	t_void *GrpRekeytimer;
356    /**Group rekey timer set flag*/
357 	t_u8 GrpRekeyTimerIsSet;
358    /**local mac address*/
359 	t_u8 curr_addr[MLAN_MAC_ADDR_LENGTH];
360 #ifdef DRV_EMBEDDED_SUPPLICANT
361    /**supplicant data*/
362 	supplicantData_t *suppData;
363 #endif
364 	/* GTK installed status */
365 	t_u8 gtk_installed;
366 } hostsa_private, *phostsa_private;
367 #endif
368