blob: 6b2dad331a5bc7a3f1e5ad7f0371c383a8e23a3a [file] [log] [blame]
Forest Bond5449c682009-04-25 10:30:44 -04001/*
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
Forest Bond5449c682009-04-25 10:30:44 -040030#ifndef __KEY_H__
31#define __KEY_H__
32
Forest Bond5449c682009-04-25 10:30:44 -040033#include "ttype.h"
Forest Bond5449c682009-04-25 10:30:44 -040034#include "tether.h"
Forest Bond5449c682009-04-25 10:30:44 -040035#include "80211mgr.h"
Forest Bond5449c682009-04-25 10:30:44 -040036
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
44#define AUTHENTICATOR_KEY 0x10000000
45#define USE_KEYRSC 0x20000000
46#define PAIRWISE_KEY 0x40000000
47#define TRANSMIT_KEY 0x80000000
48
49#define GROUP_KEY 0x00000000
50
51#define KEY_CTL_WEP 0x00
52#define KEY_CTL_NONE 0x01
53#define KEY_CTL_TKIP 0x02
54#define KEY_CTL_CCMP 0x03
55#define KEY_CTL_INVALID 0xFF
56
57
58typedef struct tagSKeyItem
59{
Charles Clément7b6a0012010-08-01 17:15:50 +020060 bool bKeyValid;
Charles Clémente3fd16d2010-06-02 09:52:02 -070061 unsigned long uKeyLength;
Charles Clément3fc9b582010-06-24 11:02:27 -070062 unsigned char abyKey[MAX_KEY_LEN];
Forest Bond5449c682009-04-25 10:30:44 -040063 QWORD KeyRSC;
Charles Clément0f4c60d2010-06-24 11:02:25 -070064 unsigned long dwTSC47_16;
Charles Clément2986db52010-06-24 11:02:26 -070065 unsigned short wTSC15_0;
Charles Clément3fc9b582010-06-24 11:02:27 -070066 unsigned char byCipherSuite;
67 unsigned char byReserved0;
Charles Clément0f4c60d2010-06-24 11:02:25 -070068 unsigned long dwKeyIndex;
Charles Clément830a6192010-05-07 12:30:20 -070069 void *pvKeyTable;
Jim Lieba8848472009-08-12 14:54:07 -070070} SKeyItem, *PSKeyItem; //64
Forest Bond5449c682009-04-25 10:30:44 -040071
72typedef struct tagSKeyTable
73{
Charles Clément3fc9b582010-06-24 11:02:27 -070074 unsigned char abyBSSID[ETH_ALEN]; //6
75 unsigned char byReserved0[2]; //8
Forest Bond5449c682009-04-25 10:30:44 -040076 SKeyItem PairwiseKey;
77 SKeyItem GroupKey[MAX_GROUP_KEY]; //64*5 = 320, 320+8=328
Charles Clément0f4c60d2010-06-24 11:02:25 -070078 unsigned long dwGTKeyIndex; // GroupTransmitKey Index
Charles Clément7b6a0012010-08-01 17:15:50 +020079 bool bInUse;
Forest Bond5449c682009-04-25 10:30:44 -040080 //2006-1116-01,<Modify> by NomadZhao
Charles Clément2986db52010-06-24 11:02:26 -070081 //unsigned short wKeyCtl;
Charles Clément7b6a0012010-08-01 17:15:50 +020082 //bool bSoftWEP;
83 bool bSoftWEP;
Charles Clément2986db52010-06-24 11:02:26 -070084 unsigned short wKeyCtl; // for address of wKeyCtl at align 4
Forest Bond5449c682009-04-25 10:30:44 -040085
Charles Clément3fc9b582010-06-24 11:02:27 -070086 unsigned char byReserved1[6];
Jim Lieba8848472009-08-12 14:54:07 -070087} SKeyTable, *PSKeyTable; //348
Forest Bond5449c682009-04-25 10:30:44 -040088
89typedef struct tagSKeyManagement
90{
91 SKeyTable KeyTable[MAX_KEY_TABLE];
Jim Lieba8848472009-08-12 14:54:07 -070092} SKeyManagement, * PSKeyManagement;
Forest Bond5449c682009-04-25 10:30:44 -040093
94/*--------------------- Export Types ------------------------------*/
95
96/*--------------------- Export Macros ------------------------------*/
97
98/*--------------------- Export Classes ----------------------------*/
99
100/*--------------------- Export Variables --------------------------*/
101
102/*--------------------- Export Functions --------------------------*/
Forest Bond5449c682009-04-25 10:30:44 -0400103
Charles Clément412b2d02010-06-22 08:54:42 -0700104void KeyvInitTable(PSKeyManagement pTable, unsigned long dwIoBase);
Forest Bond5449c682009-04-25 10:30:44 -0400105
Charles Clément7b6a0012010-08-01 17:15:50 +0200106bool KeybGetKey(
Charles Clément3a215e02010-05-12 20:54:39 -0700107 PSKeyManagement pTable,
Charles Clément2989e962010-06-05 15:13:47 -0700108 unsigned char *pbyBSSID,
Charles Clément0f4c60d2010-06-24 11:02:25 -0700109 unsigned long dwKeyIndex,
Charles Clément3cdec552010-05-12 20:54:40 -0700110 PSKeyItem *pKey
Forest Bond5449c682009-04-25 10:30:44 -0400111 );
112
Charles Clément7b6a0012010-08-01 17:15:50 +0200113bool KeybSetKey(
Forest Bond5449c682009-04-25 10:30:44 -0400114 PSKeyManagement pTable,
Charles Clément2989e962010-06-05 15:13:47 -0700115 unsigned char *pbyBSSID,
Charles Clément0f4c60d2010-06-24 11:02:25 -0700116 unsigned long dwKeyIndex,
Charles Clémente3fd16d2010-06-02 09:52:02 -0700117 unsigned long uKeyLength,
Forest Bond5449c682009-04-25 10:30:44 -0400118 PQWORD pKeyRSC,
Charles Clément2989e962010-06-05 15:13:47 -0700119 unsigned char *pbyKey,
Charles Clément3fc9b582010-06-24 11:02:27 -0700120 unsigned char byKeyDecMode,
Charles Clément412b2d02010-06-22 08:54:42 -0700121 unsigned long dwIoBase,
Charles Clément3fc9b582010-06-24 11:02:27 -0700122 unsigned char byLocalID
Forest Bond5449c682009-04-25 10:30:44 -0400123 );
124
Charles Clément7b6a0012010-08-01 17:15:50 +0200125bool KeybSetDefaultKey(
Forest Bond5449c682009-04-25 10:30:44 -0400126 PSKeyManagement pTable,
Charles Clément0f4c60d2010-06-24 11:02:25 -0700127 unsigned long dwKeyIndex,
Charles Clémente3fd16d2010-06-02 09:52:02 -0700128 unsigned long uKeyLength,
Forest Bond5449c682009-04-25 10:30:44 -0400129 PQWORD pKeyRSC,
Charles Clément2989e962010-06-05 15:13:47 -0700130 unsigned char *pbyKey,
Charles Clément3fc9b582010-06-24 11:02:27 -0700131 unsigned char byKeyDecMode,
Charles Clément412b2d02010-06-22 08:54:42 -0700132 unsigned long dwIoBase,
Charles Clément3fc9b582010-06-24 11:02:27 -0700133 unsigned char byLocalID
Forest Bond5449c682009-04-25 10:30:44 -0400134 );
135
Charles Clément7b6a0012010-08-01 17:15:50 +0200136bool KeybRemoveKey(
Forest Bond5449c682009-04-25 10:30:44 -0400137 PSKeyManagement pTable,
Charles Clément2989e962010-06-05 15:13:47 -0700138 unsigned char *pbyBSSID,
Charles Clément0f4c60d2010-06-24 11:02:25 -0700139 unsigned long dwKeyIndex,
Charles Clément412b2d02010-06-22 08:54:42 -0700140 unsigned long dwIoBase
Forest Bond5449c682009-04-25 10:30:44 -0400141 );
142
Charles Clément7b6a0012010-08-01 17:15:50 +0200143bool KeybGetTransmitKey(
Charles Clément3a215e02010-05-12 20:54:39 -0700144 PSKeyManagement pTable,
Charles Clément2989e962010-06-05 15:13:47 -0700145 unsigned char *pbyBSSID,
Charles Clément0f4c60d2010-06-24 11:02:25 -0700146 unsigned long dwKeyType,
Charles Clément3cdec552010-05-12 20:54:40 -0700147 PSKeyItem *pKey
Forest Bond5449c682009-04-25 10:30:44 -0400148 );
149
Charles Clément7b6a0012010-08-01 17:15:50 +0200150bool KeybCheckPairewiseKey(
Charles Clément3a215e02010-05-12 20:54:39 -0700151 PSKeyManagement pTable,
Charles Clément3cdec552010-05-12 20:54:40 -0700152 PSKeyItem *pKey
Forest Bond5449c682009-04-25 10:30:44 -0400153 );
154
Charles Clément7b6a0012010-08-01 17:15:50 +0200155bool KeybRemoveAllKey(
Forest Bond5449c682009-04-25 10:30:44 -0400156 PSKeyManagement pTable,
Charles Clément2989e962010-06-05 15:13:47 -0700157 unsigned char *pbyBSSID,
Charles Clément412b2d02010-06-22 08:54:42 -0700158 unsigned long dwIoBase
Forest Bond5449c682009-04-25 10:30:44 -0400159 );
160
Charles Clément6b35b7b2010-05-07 12:30:19 -0700161void KeyvRemoveWEPKey(
Forest Bond5449c682009-04-25 10:30:44 -0400162 PSKeyManagement pTable,
Charles Clément0f4c60d2010-06-24 11:02:25 -0700163 unsigned long dwKeyIndex,
Charles Clément412b2d02010-06-22 08:54:42 -0700164 unsigned long dwIoBase
Forest Bond5449c682009-04-25 10:30:44 -0400165 );
166
Charles Clément6b35b7b2010-05-07 12:30:19 -0700167void KeyvRemoveAllWEPKey(
Forest Bond5449c682009-04-25 10:30:44 -0400168 PSKeyManagement pTable,
Charles Clément412b2d02010-06-22 08:54:42 -0700169 unsigned long dwIoBase
Forest Bond5449c682009-04-25 10:30:44 -0400170 );
171
Charles Clément7b6a0012010-08-01 17:15:50 +0200172bool KeybSetAllGroupKey (
Forest Bond5449c682009-04-25 10:30:44 -0400173 PSKeyManagement pTable,
Charles Clément0f4c60d2010-06-24 11:02:25 -0700174 unsigned long dwKeyIndex,
Charles Clémente3fd16d2010-06-02 09:52:02 -0700175 unsigned long uKeyLength,
Forest Bond5449c682009-04-25 10:30:44 -0400176 PQWORD pKeyRSC,
Charles Clément2989e962010-06-05 15:13:47 -0700177 unsigned char *pbyKey,
Charles Clément3fc9b582010-06-24 11:02:27 -0700178 unsigned char byKeyDecMode,
Charles Clément412b2d02010-06-22 08:54:42 -0700179 unsigned long dwIoBase,
Charles Clément3fc9b582010-06-24 11:02:27 -0700180 unsigned char byLocalID
Forest Bond5449c682009-04-25 10:30:44 -0400181 );
182
Forest Bond5449c682009-04-25 10:30:44 -0400183#endif // __KEY_H__
184