1 /* 2 * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc. 3 * All rights reserved. 4 * 5 * This program is free software; you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation; either version 2 of the License, or 8 * (at your option) any later version. 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License along 16 * with this program; if not, write to the Free Software Foundation, Inc., 17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * 20 * File: key.h 21 * 22 * Purpose: Implement functions for 802.11i Key management 23 * 24 * Author: Jerry Chen 25 * 26 * Date: May 29, 2003 27 * 28 */ 29 30 #ifndef __KEY_H__ 31 #define __KEY_H__ 32 33 #include "ttype.h" 34 #include "tether.h" 35 #include "80211mgr.h" 36 37 /*--------------------- Export Definitions -------------------------*/ 38 #define MAX_GROUP_KEY 4 39 #define MAX_KEY_TABLE 11 40 #define MAX_KEY_LEN 32 41 #define AES_KEY_LEN 16 42 43 #define AUTHENTICATOR_KEY 0x10000000 44 #define USE_KEYRSC 0x20000000 45 #define PAIRWISE_KEY 0x40000000 46 #define TRANSMIT_KEY 0x80000000 47 48 #define GROUP_KEY 0x00000000 49 50 #define KEY_CTL_WEP 0x00 51 #define KEY_CTL_NONE 0x01 52 #define KEY_CTL_TKIP 0x02 53 #define KEY_CTL_CCMP 0x03 54 #define KEY_CTL_INVALID 0xFF 55 56 typedef struct tagSKeyItem 57 { 58 bool bKeyValid; 59 unsigned long uKeyLength; 60 unsigned char abyKey[MAX_KEY_LEN]; 61 QWORD KeyRSC; 62 unsigned long dwTSC47_16; 63 unsigned short wTSC15_0; 64 unsigned char byCipherSuite; 65 unsigned char byReserved0; 66 unsigned long dwKeyIndex; 67 void *pvKeyTable; 68 } SKeyItem, *PSKeyItem; //64 69 70 typedef struct tagSKeyTable 71 { 72 unsigned char abyBSSID[ETH_ALEN]; //6 73 unsigned char byReserved0[2]; //8 74 SKeyItem PairwiseKey; 75 SKeyItem GroupKey[MAX_GROUP_KEY]; //64*5 = 320, 320+8=328 76 unsigned long dwGTKeyIndex; // GroupTransmitKey Index 77 bool bInUse; 78 //2006-1116-01,<Modify> by NomadZhao 79 bool bSoftWEP; 80 unsigned short wKeyCtl; // for address of wKeyCtl at align 4 81 82 unsigned char byReserved1[6]; 83 } SKeyTable, *PSKeyTable; //348 84 85 typedef struct tagSKeyManagement 86 { 87 SKeyTable KeyTable[MAX_KEY_TABLE]; 88 } SKeyManagement, *PSKeyManagement; 89 90 /*--------------------- Export Types ------------------------------*/ 91 92 /*--------------------- Export Macros ------------------------------*/ 93 94 /*--------------------- Export Classes ----------------------------*/ 95 96 /*--------------------- Export Variables --------------------------*/ 97 98 /*--------------------- Export Functions --------------------------*/ 99 100 void KeyvInitTable(PSKeyManagement pTable, void __iomem *dwIoBase); 101 102 bool KeybGetKey( 103 PSKeyManagement pTable, 104 unsigned char *pbyBSSID, 105 unsigned long dwKeyIndex, 106 PSKeyItem *pKey 107 ); 108 109 bool KeybSetKey( 110 PSKeyManagement pTable, 111 unsigned char *pbyBSSID, 112 unsigned long dwKeyIndex, 113 unsigned long uKeyLength, 114 PQWORD pKeyRSC, 115 unsigned char *pbyKey, 116 unsigned char byKeyDecMode, 117 void __iomem *dwIoBase, 118 unsigned char byLocalID 119 ); 120 121 bool KeybSetDefaultKey( 122 PSKeyManagement pTable, 123 unsigned long dwKeyIndex, 124 unsigned long uKeyLength, 125 PQWORD pKeyRSC, 126 unsigned char *pbyKey, 127 unsigned char byKeyDecMode, 128 void __iomem *dwIoBase, 129 unsigned char byLocalID 130 ); 131 132 bool KeybRemoveKey( 133 PSKeyManagement pTable, 134 unsigned char *pbyBSSID, 135 unsigned long dwKeyIndex, 136 void __iomem *dwIoBase 137 ); 138 139 bool KeybGetTransmitKey( 140 PSKeyManagement pTable, 141 unsigned char *pbyBSSID, 142 unsigned long dwKeyType, 143 PSKeyItem *pKey 144 ); 145 146 bool KeybCheckPairewiseKey( 147 PSKeyManagement pTable, 148 PSKeyItem *pKey 149 ); 150 151 bool KeybRemoveAllKey( 152 PSKeyManagement pTable, 153 unsigned char *pbyBSSID, 154 void __iomem *dwIoBase 155 ); 156 157 void KeyvRemoveWEPKey( 158 PSKeyManagement pTable, 159 unsigned long dwKeyIndex, 160 void __iomem *dwIoBase 161 ); 162 163 void KeyvRemoveAllWEPKey( 164 PSKeyManagement pTable, 165 void __iomem *dwIoBase 166 ); 167 168 bool KeybSetAllGroupKey( 169 PSKeyManagement pTable, 170 unsigned long dwKeyIndex, 171 unsigned long uKeyLength, 172 PQWORD pKeyRSC, 173 unsigned char *pbyKey, 174 unsigned char byKeyDecMode, 175 void __iomem *dwIoBase, 176 unsigned char byLocalID 177 ); 178 179 #endif // __KEY_H__ 180