blob: 2526f4e4c124340442956a95c458a8f7c189f79f [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Sridhar Selvaraj05a07142017-07-18 11:51:34 +05302 * Copyright (c) 2011-2015, 2017 The Linux Foundation. All rights reserved.
Kiet Lam842dad02014-02-18 18:44:02 -08003 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
Gopichand Nakkala92f07d82013-01-08 21:16:34 -080020 */
Kiet Lam842dad02014-02-18 18:44:02 -080021
22/*
23 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
26 */
27
Gopichand Nakkala92f07d82013-01-08 21:16:34 -080028/*
Jeff Johnson295189b2012-06-20 16:38:30 -070029 *
Jeff Johnson295189b2012-06-20 16:38:30 -070030 * This file limSecurityUtils.h contains the utility definitions
31 * related to WEP encryption/decryption etc.
32 * Author: Chandra Modumudi
33 * Date: 02/13/02
34 * History:-
35 * Date Modified by Modification Information
36 * --------------------------------------------------------------------
37 */
38#ifndef __LIM_SECURITY_UTILS_H
39#define __LIM_SECURITY_UTILS_H
40#include "sirMacProtDef.h" //for tSirMacAuthFrameBody
41
Madan Mohan Koyyalamudia53c4dc2012-11-13 10:35:42 -080042#define LIM_ENCR_AUTH_BODY_LEN (sizeof(tSirMacAuthFrameBody) + \
Jeff Johnson295189b2012-06-20 16:38:30 -070043 SIR_MAC_WEP_IV_LENGTH + \
Madan Mohan Koyyalamudia53c4dc2012-11-13 10:35:42 -080044 SIR_MAC_WEP_ICV_LENGTH)
yeshwanth sriram guntukaccf694b2017-08-14 13:30:56 +053045
yeshwanth sriram guntuka97711052017-09-08 12:16:08 +053046#define LIM_ENCR_AUTH_BODY_LEN_SAP (SIR_MAC_SAP_AUTH_CHALLENGE_LENGTH + \
47 SIR_MAC_CHALLENGE_ID_LEN + \
48 SIR_MAC_AUTH_FRAME_INFO_LEN + \
49 SIR_MAC_WEP_IV_LENGTH + \
50 SIR_MAC_WEP_ICV_LENGTH)
51
yeshwanth sriram guntukaccf694b2017-08-14 13:30:56 +053052#define LIM_ENCR_AUTH_INFO_LEN (SIR_MAC_AUTH_FRAME_INFO_LEN +\
53 SIR_MAC_WEP_IV_LENGTH + \
54 SIR_MAC_WEP_ICV_LENGTH + \
55 SIR_MAC_CHALLENGE_ID_LEN)
56
Jeff Johnson295189b2012-06-20 16:38:30 -070057struct tLimPreAuthNode;
58
Jeff Johnson295189b2012-06-20 16:38:30 -070059tANI_U8 limIsAuthAlgoSupported(tpAniSirGlobal, tAniAuthType, tpPESession);
Jeff Johnson295189b2012-06-20 16:38:30 -070060
61// MAC based authentication related functions
62void limInitPreAuthList(tpAniSirGlobal);
63void limDeletePreAuthList(tpAniSirGlobal);
64struct tLimPreAuthNode *limSearchPreAuthList(tpAniSirGlobal, tSirMacAddr);
65void limAddPreAuthNode(tpAniSirGlobal, struct tLimPreAuthNode *);
66void limDeletePreAuthNode(tpAniSirGlobal, tSirMacAddr);
67void limReleasePreAuthNode(tpAniSirGlobal pMac, tpLimPreAuthNode pAuthNode);
68void limRestoreFromAuthState(tpAniSirGlobal,
69 tSirResultCodes, tANI_U16,tpPESession);
Edhar, Mahesh Kumar0d82c212015-02-03 17:47:16 +053070tANI_U8 limDeleteOpenAuthPreAuthNode(tpAniSirGlobal pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -070071
72// Encryption/Decryption related functions
73tCfgWepKeyEntry *limLookUpKeyMappings(tSirMacAddr);
Sridhar Selvaraj05a07142017-07-18 11:51:34 +053074void limComputeCrc32(tANI_U8 *, tANI_U8 *, tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070075void limRC4(tANI_U8 *, tANI_U8 *, tANI_U8 *, tANI_U32, tANI_U16);
76void limEncryptAuthFrame(tpAniSirGlobal, tANI_U8, tANI_U8 *, tANI_U8 *, tANI_U8 *, tANI_U32);
77tANI_U8 limDecryptAuthFrame(tpAniSirGlobal, tANI_U8 *, tANI_U8 *, tANI_U8 *, tANI_U32, tANI_U16);
78
79void limSendSetBssKeyReq( tpAniSirGlobal, tLimMlmSetKeysReq *,tpPESession );
80void limSendSetStaKeyReq( tpAniSirGlobal, tLimMlmSetKeysReq *, tANI_U16, tANI_U8,tpPESession);
81void limPostSmeSetKeysCnf( tpAniSirGlobal, tLimMlmSetKeysReq *, tLimMlmSetKeysCnf * );
82
83void limSendRemoveBssKeyReq(tpAniSirGlobal pMac, tLimMlmRemoveKeyReq * pMlmRemoveKeyReq,tpPESession);
84void limSendRemoveStaKeyReq(tpAniSirGlobal pMac, tLimMlmRemoveKeyReq * pMlmRemoveKeyReq, tANI_U16 staIdx,tpPESession);
Jeff Johnsone7245742012-09-05 17:12:55 -070085void limPostSmeRemoveKeyCnf(tpAniSirGlobal pMac, tpPESession psessionEntry, tLimMlmRemoveKeyReq * pMlmRemoveKeyReq, tLimMlmRemoveKeyCnf * mlmRemoveKeyCnf);
Jeff Johnson295189b2012-06-20 16:38:30 -070086
87#define PTAPS 0xedb88320
88
89static inline tANI_U32
90limCrcUpdate(tANI_U32 crc, tANI_U8 x)
91{
92
93 // Update CRC computation for 8 bits contained in x
94 //
95 tANI_U32 z;
96 tANI_U32 fb;
97 int i;
98
99 z = crc^x;
100 for (i=0; i<8; i++) {
101 fb = z & 1;
102 z >>= 1;
103 if (fb) z ^= PTAPS;
104 }
105 return z;
106}
107
108#endif /* __LIM_SECURITY_UTILS_H */