summaryrefslogtreecommitdiffstats
path: root/drivers/staging/vt6655/key.h
blob: 6b2dad331a5bc7a3f1e5ad7f0371c383a8e23a3a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
/*
 * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
 * All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 *
 * File: key.h
 *
 * Purpose: Implement functions for 802.11i Key management
 *
 * Author: Jerry Chen
 *
 * Date: May 29, 2003
 *
 */

#ifndef __KEY_H__
#define __KEY_H__

#include "ttype.h"
#include "tether.h"
#include "80211mgr.h"

/*---------------------  Export Definitions -------------------------*/
#define MAX_GROUP_KEY       4
#define MAX_KEY_TABLE       11
#define MAX_KEY_LEN         32
#define AES_KEY_LEN         16


#define AUTHENTICATOR_KEY   0x10000000
#define USE_KEYRSC          0x20000000
#define PAIRWISE_KEY        0x40000000
#define TRANSMIT_KEY        0x80000000

#define GROUP_KEY           0x00000000

#define KEY_CTL_WEP         0x00
#define KEY_CTL_NONE        0x01
#define KEY_CTL_TKIP        0x02
#define KEY_CTL_CCMP        0x03
#define KEY_CTL_INVALID     0xFF


typedef struct tagSKeyItem
{
    bool bKeyValid;
    unsigned long uKeyLength;
    unsigned char abyKey[MAX_KEY_LEN];
    QWORD       KeyRSC;
    unsigned long dwTSC47_16;
    unsigned short wTSC15_0;
    unsigned char byCipherSuite;
    unsigned char byReserved0;
    unsigned long dwKeyIndex;
    void *pvKeyTable;
} SKeyItem, *PSKeyItem; //64

typedef struct tagSKeyTable
{
    unsigned char abyBSSID[ETH_ALEN];  //6
    unsigned char byReserved0[2];              //8
    SKeyItem    PairwiseKey;
    SKeyItem    GroupKey[MAX_GROUP_KEY]; //64*5 = 320, 320+8=328
    unsigned long dwGTKeyIndex;            // GroupTransmitKey Index
    bool bInUse;
    //2006-1116-01,<Modify> by NomadZhao
    //unsigned short wKeyCtl;
    //bool bSoftWEP;
    bool bSoftWEP;
    unsigned short wKeyCtl;      // for address of wKeyCtl at align 4

    unsigned char byReserved1[6];
} SKeyTable, *PSKeyTable; //348

typedef struct tagSKeyManagement
{
    SKeyTable   KeyTable[MAX_KEY_TABLE];
} SKeyManagement, * PSKeyManagement;

/*---------------------  Export Types  ------------------------------*/

/*---------------------  Export Macros ------------------------------*/

/*---------------------  Export Classes  ----------------------------*/

/*---------------------  Export Variables  --------------------------*/

/*---------------------  Export Functions  --------------------------*/

void KeyvInitTable(PSKeyManagement pTable, unsigned long dwIoBase);

bool KeybGetKey(
    PSKeyManagement pTable,
    unsigned char *pbyBSSID,
    unsigned long dwKeyIndex,
    PSKeyItem       *pKey
    );

bool KeybSetKey(
    PSKeyManagement pTable,
    unsigned char *pbyBSSID,
    unsigned long dwKeyIndex,
    unsigned long uKeyLength,
    PQWORD          pKeyRSC,
    unsigned char *pbyKey,
    unsigned char byKeyDecMode,
    unsigned long dwIoBase,
    unsigned char byLocalID
    );

bool KeybSetDefaultKey(
    PSKeyManagement pTable,
    unsigned long dwKeyIndex,
    unsigned long uKeyLength,
    PQWORD          pKeyRSC,
    unsigned char *pbyKey,
    unsigned char byKeyDecMode,
    unsigned long dwIoBase,
    unsigned char byLocalID
    );

bool KeybRemoveKey(
    PSKeyManagement pTable,
    unsigned char *pbyBSSID,
    unsigned long dwKeyIndex,
    unsigned long dwIoBase
    );

bool KeybGetTransmitKey(
    PSKeyManagement pTable,
    unsigned char *pbyBSSID,
    unsigned long dwKeyType,
    PSKeyItem       *pKey
    );

bool KeybCheckPairewiseKey(
    PSKeyManagement pTable,
    PSKeyItem       *pKey
    );

bool KeybRemoveAllKey(
    PSKeyManagement pTable,
    unsigned char *pbyBSSID,
    unsigned long dwIoBase
    );

void KeyvRemoveWEPKey(
    PSKeyManagement pTable,
    unsigned long dwKeyIndex,
    unsigned long dwIoBase
    );

void KeyvRemoveAllWEPKey(
    PSKeyManagement pTable,
    unsigned long dwIoBase
    );

bool KeybSetAllGroupKey (
    PSKeyManagement pTable,
    unsigned long dwKeyIndex,
    unsigned long uKeyLength,
    PQWORD          pKeyRSC,
    unsigned char *pbyKey,
    unsigned char byKeyDecMode,
    unsigned long dwIoBase,
    unsigned char byLocalID
    );

#endif // __KEY_H__