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 56typedef struct tagSKeyItem { 57 bool bKeyValid; 58 unsigned long uKeyLength; 59 unsigned char abyKey[MAX_KEY_LEN]; 60 u64 KeyRSC; 61 unsigned long dwTSC47_16; 62 unsigned short wTSC15_0; 63 unsigned char byCipherSuite; 64 unsigned char byReserved0; 65 unsigned long dwKeyIndex; 66 void *pvKeyTable; 67} SKeyItem, *PSKeyItem; //64 68 69typedef struct tagSKeyTable { 70 unsigned char abyBSSID[ETH_ALEN]; //6 71 unsigned char byReserved0[2]; //8 72 SKeyItem PairwiseKey; 73 SKeyItem GroupKey[MAX_GROUP_KEY]; //64*5 = 320, 320+8=328 74 unsigned long dwGTKeyIndex; // GroupTransmitKey Index 75 bool bInUse; 76 //2006-1116-01,<Modify> by NomadZhao 77 bool bSoftWEP; 78 unsigned short wKeyCtl; // for address of wKeyCtl at align 4 79 80 unsigned char byReserved1[6]; 81} SKeyTable, *PSKeyTable; //348 82 83typedef struct tagSKeyManagement { 84 SKeyTable KeyTable[MAX_KEY_TABLE]; 85} SKeyManagement, *PSKeyManagement; 86 87/*--------------------- Export Types ------------------------------*/ 88 89/*--------------------- Export Macros ------------------------------*/ 90 91/*--------------------- Export Classes ----------------------------*/ 92 93/*--------------------- Export Variables --------------------------*/ 94 95/*--------------------- Export Functions --------------------------*/ 96 97void KeyvInitTable(PSKeyManagement pTable, void __iomem *dwIoBase); 98 99bool KeybGetKey( 100 PSKeyManagement pTable, 101 unsigned char *pbyBSSID, 102 unsigned long dwKeyIndex, 103 PSKeyItem *pKey 104); 105 106bool KeybSetKey( 107 PSKeyManagement pTable, 108 unsigned char *pbyBSSID, 109 unsigned long dwKeyIndex, 110 unsigned long uKeyLength, 111 u64 *pKeyRSC, 112 unsigned char *pbyKey, 113 unsigned char byKeyDecMode, 114 void __iomem *dwIoBase, 115 unsigned char byLocalID 116); 117 118bool KeybSetDefaultKey( 119 PSKeyManagement pTable, 120 unsigned long dwKeyIndex, 121 unsigned long uKeyLength, 122 u64 *pKeyRSC, 123 unsigned char *pbyKey, 124 unsigned char byKeyDecMode, 125 void __iomem *dwIoBase, 126 unsigned char byLocalID 127); 128 129bool KeybRemoveKey( 130 PSKeyManagement pTable, 131 unsigned char *pbyBSSID, 132 unsigned long dwKeyIndex, 133 void __iomem *dwIoBase 134); 135 136bool KeybGetTransmitKey( 137 PSKeyManagement pTable, 138 unsigned char *pbyBSSID, 139 unsigned long dwKeyType, 140 PSKeyItem *pKey 141); 142 143bool KeybCheckPairewiseKey( 144 PSKeyManagement pTable, 145 PSKeyItem *pKey 146); 147 148bool KeybRemoveAllKey( 149 PSKeyManagement pTable, 150 unsigned char *pbyBSSID, 151 void __iomem *dwIoBase 152); 153 154void KeyvRemoveWEPKey( 155 PSKeyManagement pTable, 156 unsigned long dwKeyIndex, 157 void __iomem *dwIoBase 158); 159 160void KeyvRemoveAllWEPKey( 161 PSKeyManagement pTable, 162 void __iomem *dwIoBase 163); 164 165bool KeybSetAllGroupKey( 166 PSKeyManagement pTable, 167 unsigned long dwKeyIndex, 168 unsigned long uKeyLength, 169 u64 *pKeyRSC, 170 unsigned char *pbyKey, 171 unsigned char byKeyDecMode, 172 void __iomem *dwIoBase, 173 unsigned char byLocalID 174); 175 176#endif // __KEY_H__ 177