2009-04-25 14:30:44 +00:00
|
|
|
/*
|
|
|
|
* 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;
|
2010-06-02 16:52:02 +00:00
|
|
|
unsigned long uKeyLength;
|
2010-06-24 18:02:27 +00:00
|
|
|
unsigned char abyKey[MAX_KEY_LEN];
|
2009-04-25 14:30:44 +00:00
|
|
|
QWORD KeyRSC;
|
2010-06-24 18:02:25 +00:00
|
|
|
unsigned long dwTSC47_16;
|
2010-06-24 18:02:26 +00:00
|
|
|
unsigned short wTSC15_0;
|
2010-06-24 18:02:27 +00:00
|
|
|
unsigned char byCipherSuite;
|
|
|
|
unsigned char byReserved0;
|
2010-06-24 18:02:25 +00:00
|
|
|
unsigned long dwKeyIndex;
|
2010-05-07 19:30:20 +00:00
|
|
|
void *pvKeyTable;
|
2009-08-12 21:54:07 +00:00
|
|
|
} SKeyItem, *PSKeyItem; //64
|
2009-04-25 14:30:44 +00:00
|
|
|
|
|
|
|
typedef struct tagSKeyTable
|
|
|
|
{
|
2010-06-24 18:02:27 +00:00
|
|
|
unsigned char abyBSSID[ETH_ALEN]; //6
|
|
|
|
unsigned char byReserved0[2]; //8
|
2009-04-25 14:30:44 +00:00
|
|
|
SKeyItem PairwiseKey;
|
|
|
|
SKeyItem GroupKey[MAX_GROUP_KEY]; //64*5 = 320, 320+8=328
|
2010-06-24 18:02:25 +00:00
|
|
|
unsigned long dwGTKeyIndex; // GroupTransmitKey Index
|
2009-04-25 14:30:44 +00:00
|
|
|
BOOL bInUse;
|
|
|
|
//2006-1116-01,<Modify> by NomadZhao
|
2010-06-24 18:02:26 +00:00
|
|
|
//unsigned short wKeyCtl;
|
2009-04-25 14:30:44 +00:00
|
|
|
//BOOL bSoftWEP;
|
|
|
|
BOOL bSoftWEP;
|
2010-06-24 18:02:26 +00:00
|
|
|
unsigned short wKeyCtl; // for address of wKeyCtl at align 4
|
2009-04-25 14:30:44 +00:00
|
|
|
|
2010-06-24 18:02:27 +00:00
|
|
|
unsigned char byReserved1[6];
|
2009-08-12 21:54:07 +00:00
|
|
|
} SKeyTable, *PSKeyTable; //348
|
2009-04-25 14:30:44 +00:00
|
|
|
|
|
|
|
typedef struct tagSKeyManagement
|
|
|
|
{
|
|
|
|
SKeyTable KeyTable[MAX_KEY_TABLE];
|
2009-08-12 21:54:07 +00:00
|
|
|
} SKeyManagement, * PSKeyManagement;
|
2009-04-25 14:30:44 +00:00
|
|
|
|
|
|
|
/*--------------------- Export Types ------------------------------*/
|
|
|
|
|
|
|
|
/*--------------------- Export Macros ------------------------------*/
|
|
|
|
|
|
|
|
/*--------------------- Export Classes ----------------------------*/
|
|
|
|
|
|
|
|
/*--------------------- Export Variables --------------------------*/
|
|
|
|
|
|
|
|
/*--------------------- Export Functions --------------------------*/
|
|
|
|
|
2010-06-22 15:54:42 +00:00
|
|
|
void KeyvInitTable(PSKeyManagement pTable, unsigned long dwIoBase);
|
2009-04-25 14:30:44 +00:00
|
|
|
|
|
|
|
BOOL KeybGetKey(
|
2010-05-13 03:54:39 +00:00
|
|
|
PSKeyManagement pTable,
|
2010-06-05 22:13:47 +00:00
|
|
|
unsigned char *pbyBSSID,
|
2010-06-24 18:02:25 +00:00
|
|
|
unsigned long dwKeyIndex,
|
2010-05-13 03:54:40 +00:00
|
|
|
PSKeyItem *pKey
|
2009-04-25 14:30:44 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
BOOL KeybSetKey(
|
|
|
|
PSKeyManagement pTable,
|
2010-06-05 22:13:47 +00:00
|
|
|
unsigned char *pbyBSSID,
|
2010-06-24 18:02:25 +00:00
|
|
|
unsigned long dwKeyIndex,
|
2010-06-02 16:52:02 +00:00
|
|
|
unsigned long uKeyLength,
|
2009-04-25 14:30:44 +00:00
|
|
|
PQWORD pKeyRSC,
|
2010-06-05 22:13:47 +00:00
|
|
|
unsigned char *pbyKey,
|
2010-06-24 18:02:27 +00:00
|
|
|
unsigned char byKeyDecMode,
|
2010-06-22 15:54:42 +00:00
|
|
|
unsigned long dwIoBase,
|
2010-06-24 18:02:27 +00:00
|
|
|
unsigned char byLocalID
|
2009-04-25 14:30:44 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
BOOL KeybSetDefaultKey(
|
|
|
|
PSKeyManagement pTable,
|
2010-06-24 18:02:25 +00:00
|
|
|
unsigned long dwKeyIndex,
|
2010-06-02 16:52:02 +00:00
|
|
|
unsigned long uKeyLength,
|
2009-04-25 14:30:44 +00:00
|
|
|
PQWORD pKeyRSC,
|
2010-06-05 22:13:47 +00:00
|
|
|
unsigned char *pbyKey,
|
2010-06-24 18:02:27 +00:00
|
|
|
unsigned char byKeyDecMode,
|
2010-06-22 15:54:42 +00:00
|
|
|
unsigned long dwIoBase,
|
2010-06-24 18:02:27 +00:00
|
|
|
unsigned char byLocalID
|
2009-04-25 14:30:44 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
BOOL KeybRemoveKey(
|
|
|
|
PSKeyManagement pTable,
|
2010-06-05 22:13:47 +00:00
|
|
|
unsigned char *pbyBSSID,
|
2010-06-24 18:02:25 +00:00
|
|
|
unsigned long dwKeyIndex,
|
2010-06-22 15:54:42 +00:00
|
|
|
unsigned long dwIoBase
|
2009-04-25 14:30:44 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
BOOL KeybGetTransmitKey(
|
2010-05-13 03:54:39 +00:00
|
|
|
PSKeyManagement pTable,
|
2010-06-05 22:13:47 +00:00
|
|
|
unsigned char *pbyBSSID,
|
2010-06-24 18:02:25 +00:00
|
|
|
unsigned long dwKeyType,
|
2010-05-13 03:54:40 +00:00
|
|
|
PSKeyItem *pKey
|
2009-04-25 14:30:44 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
BOOL KeybCheckPairewiseKey(
|
2010-05-13 03:54:39 +00:00
|
|
|
PSKeyManagement pTable,
|
2010-05-13 03:54:40 +00:00
|
|
|
PSKeyItem *pKey
|
2009-04-25 14:30:44 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
BOOL KeybRemoveAllKey(
|
|
|
|
PSKeyManagement pTable,
|
2010-06-05 22:13:47 +00:00
|
|
|
unsigned char *pbyBSSID,
|
2010-06-22 15:54:42 +00:00
|
|
|
unsigned long dwIoBase
|
2009-04-25 14:30:44 +00:00
|
|
|
);
|
|
|
|
|
2010-05-07 19:30:19 +00:00
|
|
|
void KeyvRemoveWEPKey(
|
2009-04-25 14:30:44 +00:00
|
|
|
PSKeyManagement pTable,
|
2010-06-24 18:02:25 +00:00
|
|
|
unsigned long dwKeyIndex,
|
2010-06-22 15:54:42 +00:00
|
|
|
unsigned long dwIoBase
|
2009-04-25 14:30:44 +00:00
|
|
|
);
|
|
|
|
|
2010-05-07 19:30:19 +00:00
|
|
|
void KeyvRemoveAllWEPKey(
|
2009-04-25 14:30:44 +00:00
|
|
|
PSKeyManagement pTable,
|
2010-06-22 15:54:42 +00:00
|
|
|
unsigned long dwIoBase
|
2009-04-25 14:30:44 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
BOOL KeybSetAllGroupKey (
|
|
|
|
PSKeyManagement pTable,
|
2010-06-24 18:02:25 +00:00
|
|
|
unsigned long dwKeyIndex,
|
2010-06-02 16:52:02 +00:00
|
|
|
unsigned long uKeyLength,
|
2009-04-25 14:30:44 +00:00
|
|
|
PQWORD pKeyRSC,
|
2010-06-05 22:13:47 +00:00
|
|
|
unsigned char *pbyKey,
|
2010-06-24 18:02:27 +00:00
|
|
|
unsigned char byKeyDecMode,
|
2010-06-22 15:54:42 +00:00
|
|
|
unsigned long dwIoBase,
|
2010-06-24 18:02:27 +00:00
|
|
|
unsigned char byLocalID
|
2009-04-25 14:30:44 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
#endif // __KEY_H__
|
|
|
|
|