hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
/** @file keyMgntsta_rom.h
 *
 *  @brief This file contains key management function for sta
 *
 * Copyright (C) 2014-2017, Marvell International Ltd.
 *
 * This software file (the "File") is distributed by Marvell International
 * Ltd. under the terms of the GNU General Public License Version 2, June 1991
 * (the "License").  You may use, redistribute and/or modify this File in
 * accordance with the terms and conditions of the License, a copy of which
 * is available by writing to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
 * worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
 *
 * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
 * ARE EXPRESSLY DISCLAIMED.  The License provides additional details about
 * this warranty disclaimer.
 */
 
/******************************************************
Change log:
    03/07/2014: Initial version
******************************************************/
#ifndef _KEY_MGMT_STA_ROM_H_
#define _KEY_MGMT_STA_ROM_H_
 
#include "keyCommonDef.h"
#include "KeyApiStaDefs.h"
#include "IEEE_types.h"
#include "keyApiStaTypes.h"
//#include "keyMgmtStaHostTypes.h"
#include "authenticator.h"
#include "keyMgmtApStaCommon.h"
 
/* Timer ID passed back to the caller when starting a timer. */
typedef UINT32 MicroTimerId_t;
 
/* Callback function registered when starting a timer */
typedef void (*MicroTimerCallback_t) (MicroTimerId_t, UINT32);
#define PMKID_LEN 16
 
extern void updateApReplayCounter(phostsa_private priv,
                 keyMgmtInfoSta_t *pKeyMgmtStaInfo,
                 UINT8 *pRxReplayCount);
 
extern KDE_t *parseKeyKDE(phostsa_private priv,
             IEEEtypes_InfoElementHdr_t *pIe);
 
extern void supplicantGenerateSha1Pmkid(phostsa_private priv, UINT8 *pPMK,
                   IEEEtypes_MacAddr_t *pBssid,
                   IEEEtypes_MacAddr_t *pSta,
                   UINT8 *pPMKID);
 
extern void FillKeyMaterialStruct_internal(phostsa_private priv,
                      key_MgtMaterial_t *p_keyMgtData,
                      UINT16 key_len, UINT8 isPairwise,
                      KeyData_t *pKey);
 
extern BOOLEAN (*supplicantSetAssocRsn_internal_hook) (RSNConfig_t *pRsnConfig,
                              SecurityParams_t
                              *pSecurityParams,
                              SecurityMode_t wpaType,
                              Cipher_t *pMcstCipher,
                              Cipher_t *pUcstCipher,
                              AkmSuite_t *pAkm,
                              IEEEtypes_RSNCapability_t
                              *pRsnCap,
                              Cipher_t
                              *pGrpMgmtCipher);
 
extern void supplicantSetAssocRsn_internal(phostsa_private priv,
                      RSNConfig_t *pRsnConfig,
                      SecurityParams_t *pSecurityParams,
                      SecurityMode_t wpaType,
                      Cipher_t *pMcstCipher,
                      Cipher_t *pUcstCipher,
                      AkmSuite_t *pAkm,
                      IEEEtypes_RSNCapability_t *pRsnCap,
                      Cipher_t *pGrpMgmtCipher);
#if 0
extern BOOLEAN (*keyMgmtFormatWpaRsnIe_internal_hook) (RSNConfig_t *pRsnConfig,
                              UINT8 *pos,
                              IEEEtypes_MacAddr_t
                              *pBssid,
                              IEEEtypes_MacAddr_t
                              *pStaAddr, UINT8 *pPmkid,
                              BOOLEAN addPmkid,
                              UINT16 *ptr_val);
#endif
extern UINT16 keyMgmtFormatWpaRsnIe_internal(phostsa_private priv,
                        RSNConfig_t *pRsnConfig,
                        UINT8 *pos,
                        IEEEtypes_MacAddr_t *pBssid,
                        IEEEtypes_MacAddr_t *pStaAddr,
                        UINT8 *pPmkid, BOOLEAN addPmkid);
#if 0
extern BOOLEAN (*install_wpa_none_keys_internal_hook) (key_MgtMaterial_t
                              *p_keyMgtData,
                              UINT8 *pPMK, UINT8 type,
                              UINT8 unicast);
#endif
extern void install_wpa_none_keys_internal(phostsa_private priv,
                      key_MgtMaterial_t *p_keyMgtData,
                      UINT8 *pPMK, UINT8 type,
                      UINT8 unicast);
#if 0
extern BOOLEAN (*keyMgmtGetKeySize_internal_hook) (RSNConfig_t *pRsnConfig,
                          UINT8 isPairwise,
                          UINT16 *ptr_val);
#endif
extern UINT16 keyMgmtGetKeySize_internal(RSNConfig_t *pRsnConfig,
                    UINT8 isPairwise);
extern BOOLEAN supplicantAkmIsWpaWpa2(phostsa_private priv, AkmSuite_t *pAkm);
extern BOOLEAN supplicantAkmIsWpaWpa2Psk(phostsa_private priv,
                    AkmSuite_t *pAkm);
extern BOOLEAN supplicantAkmUsesKdf(phostsa_private priv, AkmSuite_t *pAkm);
#if 0
extern
BOOLEAN (*parseKeyKDE_DataType_hook) (UINT8 *pData,
                     SINT32 dataLen,
                     IEEEtypes_KDEDataType_e KDEDataType,
                     UINT32 *ptr_val);
#endif
extern KDE_t *parseKeyKDE_DataType(phostsa_private priv, UINT8 *pData,
                  SINT32 dataLen,
                  IEEEtypes_KDEDataType_e KDEDataType);
#if 0
extern BOOLEAN (*parseKeyDataGTK_hook) (UINT8 *pKey,
                   UINT16 len,
                   KeyData_t *pGRKey, UINT32 *ptr_val);
#endif
extern KDE_t *parseKeyDataGTK(phostsa_private priv, UINT8 *pKey, UINT16 len,
                 KeyData_t *pGRKey);
 
extern BOOLEAN IsEAPOL_MICValid(phostsa_private priv, EAPOL_KeyMsg_t *pKeyMsg,
               UINT8 *pMICKey);
#if 0
extern BOOLEAN (*KeyMgmtSta_ApplyKEK_hook) (EAPOL_KeyMsg_t *pKeyMsg,
                       KeyData_t *pGRKey,
                       UINT8 *EAPOL_Encr_Key);
#endif
extern void KeyMgmtSta_ApplyKEK(phostsa_private priv, EAPOL_KeyMsg_t *pKeyMsg,
               KeyData_t *pGRKey, UINT8 *EAPOL_Encr_Key);
#if 0
extern
BOOLEAN (*KeyMgmtSta_IsRxEAPOLValid_hook) (keyMgmtInfoSta_t *pKeyMgmtInfoSta,
                      EAPOL_KeyMsg_t *pKeyMsg,
                      BOOLEAN *ptr_val);
#endif
extern BOOLEAN KeyMgmtSta_IsRxEAPOLValid(phostsa_private priv,
                    keyMgmtInfoSta_t *pKeyMgmtInfoSta,
                    EAPOL_KeyMsg_t *pKeyMsg);
extern void KeyMgmtSta_PrepareEAPOLFrame(phostsa_private priv,
                    EAPOL_KeyMsg_Tx_t *pTxEapol,
                    EAPOL_KeyMsg_t *pRxEapol, t_u8 *da,
                    t_u8 *sa, UINT8 *pSNonce);
extern UINT16 KeyMgmtSta_PopulateEAPOLLengthMic(phostsa_private priv,
                       EAPOL_KeyMsg_Tx_t *pTxEapol,
                       UINT8 *pEAPOLMICKey,
                       UINT8 eapolProtocolVersion,
                       UINT8 forceKeyDescVersion);
extern
void KeyMgmtSta_PrepareEAPOLMicErrFrame(phostsa_private priv,
                   EAPOL_KeyMsg_Tx_t *pTxEapol,
                   BOOLEAN isUnicast,
                   IEEEtypes_MacAddr_t *da,
                   IEEEtypes_MacAddr_t *sa,
                   keyMgmtInfoSta_t *pKeyMgmtInfoSta);
 
extern BOOLEAN supplicantAkmWpa2Ft(phostsa_private priv, AkmSuite_t *pAkm);
 
extern BOOLEAN supplicantAkmUsesSha256Pmkid(phostsa_private priv,
                       AkmSuite_t *pAkm);
 
extern void supplicantGenerateSha256Pmkid(phostsa_private priv, UINT8 *pPMK,
                     IEEEtypes_MacAddr_t *pBssid,
                     IEEEtypes_MacAddr_t *pSta,
                     UINT8 *pPMKID);
 
extern BOOLEAN supplicantGetPmkid(phostsa_private priv,
                 IEEEtypes_MacAddr_t *pBssid,
                 IEEEtypes_MacAddr_t *pStaAddr,
                 AkmSuite_t *pAkm, UINT8 *pPMKID);
 
extern void KeyMgmt_DerivePTK(phostsa_private priv, UINT8 *pAddr1,
                 UINT8 *pAddr2,
                 UINT8 *pNonce1,
                 UINT8 *pNonce2,
                 UINT8 *pPTK, UINT8 *pPMK, BOOLEAN use_kdf);
 
extern void SetEAPOLKeyDescTypeVersion(EAPOL_KeyMsg_Tx_t *pTxEapol,
                      BOOLEAN isWPA2,
                      BOOLEAN isKDF, BOOLEAN nonTKIP);
 
extern void KeyMgmtResetCounter(keyMgmtInfoSta_t *pKeyMgmtInfo);
 
extern void keyMgmtSta_StartSession_internal(phostsa_private priv,
                        keyMgmtInfoSta_t *pKeyMgmtInfoSta,
                        //MicroTimerCallback_t callback,
                        UINT32 expiry, UINT8 flags);
 
extern void KeyMgmtSta_handleMICDeauthTimer(keyMgmtInfoSta_t *pKeyMgmtInfoSta,
                       MicroTimerCallback_t callback,
                       UINT32 expiry, UINT8 flags);
 
extern void KeyMgmtSta_handleMICErr(MIC_Fail_State_e state,
                   keyMgmtInfoSta_t *pKeyMgmtInfoSta,
                   MicroTimerCallback_t callback, UINT8 flags);
 
extern void DeauthDelayTimerExp_Sta(t_void *context);
extern void keyMgmtStaRsnSecuredTimeoutHandler(t_void *context);
extern void keyMgmtSendDeauth2Peer(phostsa_private priv, UINT16 reason);
extern void supplicantGenerateRand(hostsa_private *priv, UINT8 *dataOut,
                  UINT32 length);
 
extern EAPOL_KeyMsg_t *GetKeyMsgNonceFromEAPOL(phostsa_private priv,
                          mlan_buffer *pmbuf,
                          keyMgmtInfoSta_t
                          *pKeyMgmtInfoSta);
 
extern EAPOL_KeyMsg_t *ProcessRxEAPOL_PwkMsg3(phostsa_private priv,
                         mlan_buffer *pmbuf,
                         keyMgmtInfoSta_t
                         *pKeyMgmtInfoSta);
 
extern EAPOL_KeyMsg_t *ProcessRxEAPOL_GrpMsg1(phostsa_private priv,
                         mlan_buffer *pmbuf,
                         keyMgmtInfoSta_t
                         *pKeyMgmtInfoSta);
 
extern void KeyMgmtSta_InitSession(phostsa_private priv,
                  keyMgmtInfoSta_t *pKeyMgmtInfoSta);
 
extern void supplicantParseMcstCipher(phostsa_private priv,
                     Cipher_t *pMcstCipherOut,
                     UINT8 *pGrpKeyCipher);
 
extern void supplicantParseUcstCipher(phostsa_private priv,
                     Cipher_t *pUcstCipherOut, UINT8 pwsKeyCnt,
                     UINT8 *pPwsKeyCipherList);
 
#endif