2 * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
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.
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.
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.
22 * Purpose: Implement functions for 802.11i Key management
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
43 #define AUTHENTICATOR_KEY 0x10000000
44 #define USE_KEYRSC 0x20000000
45 #define PAIRWISE_KEY 0x40000000
46 #define TRANSMIT_KEY 0x80000000
48 #define GROUP_KEY 0x00000000
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
56 typedef struct tagSKeyItem
59 unsigned long uKeyLength
;
60 unsigned char abyKey
[MAX_KEY_LEN
];
62 unsigned long dwTSC47_16
;
63 unsigned short wTSC15_0
;
64 unsigned char byCipherSuite
;
65 unsigned char byReserved0
;
66 unsigned long dwKeyIndex
;
68 } SKeyItem
, *PSKeyItem
; //64
70 typedef struct tagSKeyTable
72 unsigned char abyBSSID
[ETH_ALEN
]; //6
73 unsigned char byReserved0
[2]; //8
75 SKeyItem GroupKey
[MAX_GROUP_KEY
]; //64*5 = 320, 320+8=328
76 unsigned long dwGTKeyIndex
; // GroupTransmitKey Index
78 //2006-1116-01,<Modify> by NomadZhao
79 //unsigned short wKeyCtl;
82 unsigned short wKeyCtl
; // for address of wKeyCtl at align 4
84 unsigned char byReserved1
[6];
85 } SKeyTable
, *PSKeyTable
; //348
87 typedef struct tagSKeyManagement
89 SKeyTable KeyTable
[MAX_KEY_TABLE
];
90 } SKeyManagement
, *PSKeyManagement
;
92 /*--------------------- Export Types ------------------------------*/
94 /*--------------------- Export Macros ------------------------------*/
96 /*--------------------- Export Classes ----------------------------*/
98 /*--------------------- Export Variables --------------------------*/
100 /*--------------------- Export Functions --------------------------*/
102 void KeyvInitTable(PSKeyManagement pTable
, unsigned long dwIoBase
);
105 PSKeyManagement pTable
,
106 unsigned char *pbyBSSID
,
107 unsigned long dwKeyIndex
,
112 PSKeyManagement pTable
,
113 unsigned char *pbyBSSID
,
114 unsigned long dwKeyIndex
,
115 unsigned long uKeyLength
,
117 unsigned char *pbyKey
,
118 unsigned char byKeyDecMode
,
119 unsigned long dwIoBase
,
120 unsigned char byLocalID
123 bool KeybSetDefaultKey(
124 PSKeyManagement pTable
,
125 unsigned long dwKeyIndex
,
126 unsigned long uKeyLength
,
128 unsigned char *pbyKey
,
129 unsigned char byKeyDecMode
,
130 unsigned long dwIoBase
,
131 unsigned char byLocalID
135 PSKeyManagement pTable
,
136 unsigned char *pbyBSSID
,
137 unsigned long dwKeyIndex
,
138 unsigned long dwIoBase
141 bool KeybGetTransmitKey(
142 PSKeyManagement pTable
,
143 unsigned char *pbyBSSID
,
144 unsigned long dwKeyType
,
148 bool KeybCheckPairewiseKey(
149 PSKeyManagement pTable
,
153 bool KeybRemoveAllKey(
154 PSKeyManagement pTable
,
155 unsigned char *pbyBSSID
,
156 unsigned long dwIoBase
159 void KeyvRemoveWEPKey(
160 PSKeyManagement pTable
,
161 unsigned long dwKeyIndex
,
162 unsigned long dwIoBase
165 void KeyvRemoveAllWEPKey(
166 PSKeyManagement pTable
,
167 unsigned long dwIoBase
170 bool KeybSetAllGroupKey(
171 PSKeyManagement pTable
,
172 unsigned long dwKeyIndex
,
173 unsigned long uKeyLength
,
175 unsigned char *pbyKey
,
176 unsigned char byKeyDecMode
,
177 unsigned long dwIoBase
,
178 unsigned char byLocalID