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
80 unsigned short wKeyCtl
; // for address of wKeyCtl at align 4
82 unsigned char byReserved1
[6];
83 } SKeyTable
, *PSKeyTable
; //348
85 typedef struct tagSKeyManagement
87 SKeyTable KeyTable
[MAX_KEY_TABLE
];
88 } SKeyManagement
, *PSKeyManagement
;
90 /*--------------------- Export Types ------------------------------*/
92 /*--------------------- Export Macros ------------------------------*/
94 /*--------------------- Export Classes ----------------------------*/
96 /*--------------------- Export Variables --------------------------*/
98 /*--------------------- Export Functions --------------------------*/
100 void KeyvInitTable(PSKeyManagement pTable
, unsigned long dwIoBase
);
103 PSKeyManagement pTable
,
104 unsigned char *pbyBSSID
,
105 unsigned long dwKeyIndex
,
110 PSKeyManagement pTable
,
111 unsigned char *pbyBSSID
,
112 unsigned long dwKeyIndex
,
113 unsigned long uKeyLength
,
115 unsigned char *pbyKey
,
116 unsigned char byKeyDecMode
,
117 unsigned long dwIoBase
,
118 unsigned char byLocalID
121 bool KeybSetDefaultKey(
122 PSKeyManagement pTable
,
123 unsigned long dwKeyIndex
,
124 unsigned long uKeyLength
,
126 unsigned char *pbyKey
,
127 unsigned char byKeyDecMode
,
128 unsigned long dwIoBase
,
129 unsigned char byLocalID
133 PSKeyManagement pTable
,
134 unsigned char *pbyBSSID
,
135 unsigned long dwKeyIndex
,
136 unsigned long dwIoBase
139 bool KeybGetTransmitKey(
140 PSKeyManagement pTable
,
141 unsigned char *pbyBSSID
,
142 unsigned long dwKeyType
,
146 bool KeybCheckPairewiseKey(
147 PSKeyManagement pTable
,
151 bool KeybRemoveAllKey(
152 PSKeyManagement pTable
,
153 unsigned char *pbyBSSID
,
154 unsigned long dwIoBase
157 void KeyvRemoveWEPKey(
158 PSKeyManagement pTable
,
159 unsigned long dwKeyIndex
,
160 unsigned long dwIoBase
163 void KeyvRemoveAllWEPKey(
164 PSKeyManagement pTable
,
165 unsigned long dwIoBase
168 bool KeybSetAllGroupKey(
169 PSKeyManagement pTable
,
170 unsigned long dwKeyIndex
,
171 unsigned long uKeyLength
,
173 unsigned char *pbyKey
,
174 unsigned char byKeyDecMode
,
175 unsigned long dwIoBase
,
176 unsigned char byLocalID