tizen 2.4 release
[profile/mobile/platform/kernel/linux-3.10-sc7730.git] / drivers / staging / vt6655 / key.h
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         //unsigned short wKeyCtl;
80         //bool bSoftWEP;
81         bool bSoftWEP;
82         unsigned short wKeyCtl;      // for address of wKeyCtl at align 4
83
84         unsigned char byReserved1[6];
85 } SKeyTable, *PSKeyTable; //348
86
87 typedef struct tagSKeyManagement
88 {
89         SKeyTable   KeyTable[MAX_KEY_TABLE];
90 } SKeyManagement, *PSKeyManagement;
91
92 /*---------------------  Export Types  ------------------------------*/
93
94 /*---------------------  Export Macros ------------------------------*/
95
96 /*---------------------  Export Classes  ----------------------------*/
97
98 /*---------------------  Export Variables  --------------------------*/
99
100 /*---------------------  Export Functions  --------------------------*/
101
102 void KeyvInitTable(PSKeyManagement pTable, unsigned long dwIoBase);
103
104 bool KeybGetKey(
105         PSKeyManagement pTable,
106         unsigned char *pbyBSSID,
107         unsigned long dwKeyIndex,
108         PSKeyItem       *pKey
109 );
110
111 bool KeybSetKey(
112         PSKeyManagement pTable,
113         unsigned char *pbyBSSID,
114         unsigned long dwKeyIndex,
115         unsigned long uKeyLength,
116         PQWORD          pKeyRSC,
117         unsigned char *pbyKey,
118         unsigned char byKeyDecMode,
119         unsigned long dwIoBase,
120         unsigned char byLocalID
121 );
122
123 bool KeybSetDefaultKey(
124         PSKeyManagement pTable,
125         unsigned long dwKeyIndex,
126         unsigned long uKeyLength,
127         PQWORD          pKeyRSC,
128         unsigned char *pbyKey,
129         unsigned char byKeyDecMode,
130         unsigned long dwIoBase,
131         unsigned char byLocalID
132 );
133
134 bool KeybRemoveKey(
135         PSKeyManagement pTable,
136         unsigned char *pbyBSSID,
137         unsigned long dwKeyIndex,
138         unsigned long dwIoBase
139 );
140
141 bool KeybGetTransmitKey(
142         PSKeyManagement pTable,
143         unsigned char *pbyBSSID,
144         unsigned long dwKeyType,
145         PSKeyItem       *pKey
146 );
147
148 bool KeybCheckPairewiseKey(
149         PSKeyManagement pTable,
150         PSKeyItem       *pKey
151 );
152
153 bool KeybRemoveAllKey(
154         PSKeyManagement pTable,
155         unsigned char *pbyBSSID,
156         unsigned long dwIoBase
157 );
158
159 void KeyvRemoveWEPKey(
160         PSKeyManagement pTable,
161         unsigned long dwKeyIndex,
162         unsigned long dwIoBase
163 );
164
165 void KeyvRemoveAllWEPKey(
166         PSKeyManagement pTable,
167         unsigned long dwIoBase
168 );
169
170 bool KeybSetAllGroupKey(
171         PSKeyManagement pTable,
172         unsigned long dwKeyIndex,
173         unsigned long uKeyLength,
174         PQWORD          pKeyRSC,
175         unsigned char *pbyKey,
176         unsigned char byKeyDecMode,
177         unsigned long dwIoBase,
178         unsigned char byLocalID
179 );
180
181 #endif // __KEY_H__