2009-06-13 05:38:31 -06: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.c
|
|
|
|
*
|
|
|
|
* Purpose: Implement functions for 802.11i Key management
|
|
|
|
*
|
|
|
|
* Author: Jerry Chen
|
|
|
|
*
|
|
|
|
* Date: May 29, 2003
|
|
|
|
*
|
|
|
|
* Functions:
|
|
|
|
* KeyvInitTable - Init Key management table
|
|
|
|
* KeybGetKey - Get Key from table
|
|
|
|
* KeybSetKey - Set Key to table
|
|
|
|
* KeybRemoveKey - Remove Key from table
|
|
|
|
* KeybGetTransmitKey - Get Transmit Key from table
|
|
|
|
*
|
|
|
|
* Revision History:
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2012-11-24 07:19:34 -07:00
|
|
|
#include "mac.h"
|
2009-06-13 05:38:31 -06:00
|
|
|
#include "tmacro.h"
|
|
|
|
#include "key.h"
|
|
|
|
#include "rndis.h"
|
|
|
|
#include "control.h"
|
|
|
|
|
|
|
|
static int msglevel =MSG_LEVEL_INFO;
|
|
|
|
//static int msglevel =MSG_LEVEL_DEBUG;
|
|
|
|
|
2012-12-10 15:12:07 -07:00
|
|
|
static void s_vCheckKeyTableValid(struct vnt_private *pDevice,
|
|
|
|
PSKeyManagement pTable)
|
2009-06-13 05:38:31 -06:00
|
|
|
{
|
2012-12-10 15:12:07 -07:00
|
|
|
int i;
|
|
|
|
u16 wLength = 0;
|
|
|
|
u8 pbyData[MAX_KEY_TABLE];
|
2009-06-13 05:38:31 -06:00
|
|
|
|
|
|
|
for (i=0;i<MAX_KEY_TABLE;i++) {
|
2013-02-12 18:36:30 -07:00
|
|
|
if ((pTable->KeyTable[i].bInUse == true) &&
|
2013-02-12 18:36:29 -07:00
|
|
|
(pTable->KeyTable[i].PairwiseKey.bKeyValid == false) &&
|
|
|
|
(pTable->KeyTable[i].GroupKey[0].bKeyValid == false) &&
|
|
|
|
(pTable->KeyTable[i].GroupKey[1].bKeyValid == false) &&
|
|
|
|
(pTable->KeyTable[i].GroupKey[2].bKeyValid == false) &&
|
|
|
|
(pTable->KeyTable[i].GroupKey[3].bKeyValid == false)
|
2009-06-13 05:38:31 -06:00
|
|
|
) {
|
|
|
|
|
2013-02-12 18:36:29 -07:00
|
|
|
pTable->KeyTable[i].bInUse = false;
|
2009-06-13 05:38:31 -06:00
|
|
|
pTable->KeyTable[i].wKeyCtl = 0;
|
2013-02-12 18:36:29 -07:00
|
|
|
pTable->KeyTable[i].bSoftWEP = false;
|
2013-02-25 18:32:51 -07:00
|
|
|
pbyData[wLength++] = (u8) i;
|
2009-06-13 05:38:31 -06:00
|
|
|
//MACvDisableKeyEntry(pDevice, i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ( wLength != 0 ) {
|
|
|
|
CONTROLnsRequestOut(pDevice,
|
|
|
|
MESSAGE_TYPE_CLRKEYENTRY,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
wLength,
|
|
|
|
pbyData
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Description: Init Key management table
|
|
|
|
*
|
|
|
|
* Parameters:
|
|
|
|
* In:
|
|
|
|
* pTable - Pointer to Key table
|
|
|
|
* Out:
|
|
|
|
* none
|
|
|
|
*
|
|
|
|
* Return Value: none
|
|
|
|
*
|
|
|
|
*/
|
2012-12-10 15:12:07 -07:00
|
|
|
void KeyvInitTable(struct vnt_private *pDevice, PSKeyManagement pTable)
|
2009-06-13 05:38:31 -06:00
|
|
|
{
|
2012-12-10 15:12:07 -07:00
|
|
|
int i, jj;
|
|
|
|
u8 pbyData[MAX_KEY_TABLE+1];
|
2009-06-13 05:38:31 -06:00
|
|
|
|
|
|
|
spin_lock_irq(&pDevice->lock);
|
|
|
|
for (i=0;i<MAX_KEY_TABLE;i++) {
|
2013-02-12 18:36:29 -07:00
|
|
|
pTable->KeyTable[i].bInUse = false;
|
|
|
|
pTable->KeyTable[i].PairwiseKey.bKeyValid = false;
|
2010-05-01 11:25:00 -06:00
|
|
|
pTable->KeyTable[i].PairwiseKey.pvKeyTable =
|
|
|
|
(void *)&pTable->KeyTable[i];
|
2009-06-13 05:38:31 -06:00
|
|
|
for (jj=0; jj < MAX_GROUP_KEY; jj++) {
|
2013-02-12 18:36:29 -07:00
|
|
|
pTable->KeyTable[i].GroupKey[jj].bKeyValid = false;
|
2010-05-01 11:25:00 -06:00
|
|
|
pTable->KeyTable[i].GroupKey[jj].pvKeyTable =
|
|
|
|
(void *) &(pTable->KeyTable[i]);
|
2009-06-13 05:38:31 -06:00
|
|
|
}
|
|
|
|
pTable->KeyTable[i].wKeyCtl = 0;
|
|
|
|
pTable->KeyTable[i].dwGTKeyIndex = 0;
|
2013-02-12 18:36:29 -07:00
|
|
|
pTable->KeyTable[i].bSoftWEP = false;
|
2013-02-25 18:32:51 -07:00
|
|
|
pbyData[i] = (u8) i;
|
2009-06-13 05:38:31 -06:00
|
|
|
}
|
2013-02-25 18:32:51 -07:00
|
|
|
pbyData[i] = (u8) i;
|
2009-06-13 05:38:31 -06:00
|
|
|
CONTROLnsRequestOut(pDevice,
|
|
|
|
MESSAGE_TYPE_CLRKEYENTRY,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
11,
|
|
|
|
pbyData
|
|
|
|
);
|
|
|
|
|
|
|
|
spin_unlock_irq(&pDevice->lock);
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Description: Get Key from table
|
|
|
|
*
|
|
|
|
* Parameters:
|
|
|
|
* In:
|
|
|
|
* pTable - Pointer to Key table
|
|
|
|
* pbyBSSID - BSSID of Key
|
|
|
|
* dwKeyIndex - Key Index (0xFFFFFFFF means pairwise key)
|
|
|
|
* Out:
|
|
|
|
* pKey - Key return
|
|
|
|
*
|
2013-02-12 18:36:30 -07:00
|
|
|
* Return Value: true if found otherwise false
|
2009-06-13 05:38:31 -06:00
|
|
|
*
|
|
|
|
*/
|
2012-12-10 15:12:07 -07:00
|
|
|
int KeybGetKey(PSKeyManagement pTable, u8 *pbyBSSID, u32 dwKeyIndex,
|
|
|
|
PSKeyItem *pKey)
|
2009-06-13 05:38:31 -06:00
|
|
|
{
|
2012-12-10 15:12:07 -07:00
|
|
|
int i;
|
2009-06-13 05:38:31 -06:00
|
|
|
|
2012-12-10 15:12:07 -07:00
|
|
|
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"KeybGetKey()\n");
|
2009-06-13 05:38:31 -06:00
|
|
|
|
|
|
|
*pKey = NULL;
|
|
|
|
for (i=0;i<MAX_KEY_TABLE;i++) {
|
2013-02-12 18:36:30 -07:00
|
|
|
if ((pTable->KeyTable[i].bInUse == true) &&
|
Staging: Convert uses of compare_ether_addr to ether_addr_equal
Preliminary to removing compare_ether_addr altogether:
Use the new bool function ether_addr_equal to add
some clarity and reduce the likelihood for misuse
of compare_ether_addr for sorting.
Additionally:
Used is_zero_ether_addr, removed now unused variable
Converted uses of &foo[0] to foo
Done via cocci script: (and a little typing)
$ cat compare_ether_addr.cocci
@@
expression a,b;
@@
- !compare_ether_addr(a, b)
+ ether_addr_equal(a, b)
@@
expression a,b;
@@
- compare_ether_addr(a, b)
+ !ether_addr_equal(a, b)
@@
expression a,b;
@@
- !ether_addr_equal(a, b) == 0
+ ether_addr_equal(a, b)
@@
expression a,b;
@@
- !ether_addr_equal(a, b) != 0
+ !ether_addr_equal(a, b)
@@
expression a,b;
@@
- ether_addr_equal(a, b) == 0
+ !ether_addr_equal(a, b)
@@
expression a,b;
@@
- ether_addr_equal(a, b) != 0
+ ether_addr_equal(a, b)
@@
expression a,b;
@@
- !!ether_addr_equal(a, b)
+ ether_addr_equal(a, b)
Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-09-01 13:15:47 -06:00
|
|
|
ether_addr_equal(pTable->KeyTable[i].abyBSSID, pbyBSSID)) {
|
2009-06-13 05:38:31 -06:00
|
|
|
if (dwKeyIndex == 0xFFFFFFFF) {
|
2013-02-12 18:36:30 -07:00
|
|
|
if (pTable->KeyTable[i].PairwiseKey.bKeyValid == true) {
|
2009-06-13 05:38:31 -06:00
|
|
|
*pKey = &(pTable->KeyTable[i].PairwiseKey);
|
2013-02-12 18:36:30 -07:00
|
|
|
return (true);
|
2009-06-13 05:38:31 -06:00
|
|
|
}
|
|
|
|
else {
|
2013-02-12 18:36:29 -07:00
|
|
|
return (false);
|
2009-06-13 05:38:31 -06:00
|
|
|
}
|
|
|
|
} else if (dwKeyIndex < MAX_GROUP_KEY) {
|
2013-02-12 18:36:30 -07:00
|
|
|
if (pTable->KeyTable[i].GroupKey[dwKeyIndex].bKeyValid == true) {
|
2009-06-13 05:38:31 -06:00
|
|
|
*pKey = &(pTable->KeyTable[i].GroupKey[dwKeyIndex]);
|
2013-02-12 18:36:30 -07:00
|
|
|
return (true);
|
2009-06-13 05:38:31 -06:00
|
|
|
}
|
|
|
|
else {
|
2013-02-12 18:36:29 -07:00
|
|
|
return (false);
|
2009-06-13 05:38:31 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2013-02-12 18:36:29 -07:00
|
|
|
return (false);
|
2009-06-13 05:38:31 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-02-12 18:36:29 -07:00
|
|
|
return (false);
|
2009-06-13 05:38:31 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Description: Set Key to table
|
|
|
|
*
|
|
|
|
* Parameters:
|
|
|
|
* In:
|
|
|
|
* pTable - Pointer to Key table
|
|
|
|
* pbyBSSID - BSSID of Key
|
|
|
|
* dwKeyIndex - Key index (reference to NDIS DDK)
|
|
|
|
* uKeyLength - Key length
|
|
|
|
* KeyRSC - Key RSC
|
|
|
|
* pbyKey - Pointer to key
|
|
|
|
* Out:
|
|
|
|
* none
|
|
|
|
*
|
2013-02-12 18:36:30 -07:00
|
|
|
* Return Value: true if success otherwise false
|
2009-06-13 05:38:31 -06:00
|
|
|
*
|
|
|
|
*/
|
2012-12-10 15:12:07 -07:00
|
|
|
int KeybSetKey(struct vnt_private *pDevice, PSKeyManagement pTable,
|
|
|
|
u8 *pbyBSSID, u32 dwKeyIndex, u32 uKeyLength, u64 *KeyRSC, u8 *pbyKey,
|
|
|
|
u8 byKeyDecMode)
|
2009-06-13 05:38:31 -06:00
|
|
|
{
|
2012-12-10 15:12:07 -07:00
|
|
|
PSKeyItem pKey;
|
|
|
|
int i, j, ii;
|
|
|
|
u32 uKeyIdx;
|
2009-06-13 05:38:31 -06:00
|
|
|
|
2012-11-11 08:45:52 -07:00
|
|
|
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO
|
|
|
|
"Enter KeybSetKey: %X\n", dwKeyIndex);
|
2009-06-13 05:38:31 -06:00
|
|
|
|
|
|
|
j = (MAX_KEY_TABLE-1);
|
|
|
|
for (i=0;i<(MAX_KEY_TABLE-1);i++) {
|
2013-02-12 18:36:29 -07:00
|
|
|
if ((pTable->KeyTable[i].bInUse == false) &&
|
2009-06-13 05:38:31 -06:00
|
|
|
(j == (MAX_KEY_TABLE-1))) {
|
|
|
|
// found empty table
|
|
|
|
j = i;
|
|
|
|
}
|
2013-02-12 18:36:30 -07:00
|
|
|
if ((pTable->KeyTable[i].bInUse == true) &&
|
Staging: Convert uses of compare_ether_addr to ether_addr_equal
Preliminary to removing compare_ether_addr altogether:
Use the new bool function ether_addr_equal to add
some clarity and reduce the likelihood for misuse
of compare_ether_addr for sorting.
Additionally:
Used is_zero_ether_addr, removed now unused variable
Converted uses of &foo[0] to foo
Done via cocci script: (and a little typing)
$ cat compare_ether_addr.cocci
@@
expression a,b;
@@
- !compare_ether_addr(a, b)
+ ether_addr_equal(a, b)
@@
expression a,b;
@@
- compare_ether_addr(a, b)
+ !ether_addr_equal(a, b)
@@
expression a,b;
@@
- !ether_addr_equal(a, b) == 0
+ ether_addr_equal(a, b)
@@
expression a,b;
@@
- !ether_addr_equal(a, b) != 0
+ !ether_addr_equal(a, b)
@@
expression a,b;
@@
- ether_addr_equal(a, b) == 0
+ !ether_addr_equal(a, b)
@@
expression a,b;
@@
- ether_addr_equal(a, b) != 0
+ ether_addr_equal(a, b)
@@
expression a,b;
@@
- !!ether_addr_equal(a, b)
+ ether_addr_equal(a, b)
Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-09-01 13:15:47 -06:00
|
|
|
ether_addr_equal(pTable->KeyTable[i].abyBSSID, pbyBSSID)) {
|
2009-06-13 05:38:31 -06:00
|
|
|
// found table already exist
|
|
|
|
if ((dwKeyIndex & PAIRWISE_KEY) != 0) {
|
|
|
|
// Pairwise key
|
|
|
|
pKey = &(pTable->KeyTable[i].PairwiseKey);
|
|
|
|
pTable->KeyTable[i].wKeyCtl &= 0xFFF0; // clear pairwise key control filed
|
|
|
|
pTable->KeyTable[i].wKeyCtl |= byKeyDecMode;
|
|
|
|
uKeyIdx = 4; // use HW key entry 4 for pairwise key
|
|
|
|
} else {
|
|
|
|
// Group key
|
|
|
|
if ((dwKeyIndex & 0x000000FF) >= MAX_GROUP_KEY)
|
2013-02-12 18:36:29 -07:00
|
|
|
return (false);
|
2009-06-13 05:38:31 -06:00
|
|
|
pKey = &(pTable->KeyTable[i].GroupKey[dwKeyIndex & 0x000000FF]);
|
|
|
|
if ((dwKeyIndex & TRANSMIT_KEY) != 0) {
|
|
|
|
// Group transmit key
|
|
|
|
pTable->KeyTable[i].dwGTKeyIndex = dwKeyIndex;
|
2012-11-11 08:45:52 -07:00
|
|
|
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO
|
|
|
|
"Group transmit key(R)[%X]: %d\n",
|
|
|
|
pTable->KeyTable[i].dwGTKeyIndex, i);
|
2009-06-13 05:38:31 -06:00
|
|
|
}
|
|
|
|
pTable->KeyTable[i].wKeyCtl &= 0xFF0F; // clear group key control filed
|
|
|
|
pTable->KeyTable[i].wKeyCtl |= (byKeyDecMode << 4);
|
|
|
|
pTable->KeyTable[i].wKeyCtl |= 0x0040; // use group key for group address
|
|
|
|
uKeyIdx = (dwKeyIndex & 0x000000FF);
|
|
|
|
}
|
|
|
|
pTable->KeyTable[i].wKeyCtl |= 0x8000; // enable on-fly
|
|
|
|
|
2013-02-12 18:36:30 -07:00
|
|
|
pKey->bKeyValid = true;
|
2009-06-13 05:38:31 -06:00
|
|
|
pKey->uKeyLength = uKeyLength;
|
|
|
|
pKey->dwKeyIndex = dwKeyIndex;
|
|
|
|
pKey->byCipherSuite = byKeyDecMode;
|
2009-08-12 15:54:11 -06:00
|
|
|
memcpy(pKey->abyKey, pbyKey, uKeyLength);
|
2009-06-13 05:38:31 -06:00
|
|
|
if (byKeyDecMode == KEY_CTL_WEP) {
|
|
|
|
if (uKeyLength == WLAN_WEP40_KEYLEN)
|
|
|
|
pKey->abyKey[15] &= 0x7F;
|
|
|
|
if (uKeyLength == WLAN_WEP104_KEYLEN)
|
|
|
|
pKey->abyKey[15] |= 0x80;
|
|
|
|
}
|
2013-02-25 18:32:53 -07:00
|
|
|
MACvSetKeyEntry(pDevice, pTable->KeyTable[i].wKeyCtl, i, uKeyIdx, pbyBSSID, (u32 *)pKey->abyKey);
|
2009-06-13 05:38:31 -06:00
|
|
|
|
2012-11-28 14:11:02 -07:00
|
|
|
if ((dwKeyIndex & USE_KEYRSC) == 0)
|
|
|
|
pKey->KeyRSC = 0; /* RSC set by NIC */
|
|
|
|
else
|
|
|
|
pKey->KeyRSC = *KeyRSC;
|
|
|
|
|
2009-06-13 05:38:31 -06:00
|
|
|
pKey->dwTSC47_16 = 0;
|
|
|
|
pKey->wTSC15_0 = 0;
|
|
|
|
|
|
|
|
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"KeybSetKey(R): \n");
|
|
|
|
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->bKeyValid: %d\n ", pKey->bKeyValid);
|
|
|
|
//DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->uKeyLength: %d\n ", pKey->uKeyLength);
|
|
|
|
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->abyKey: ");
|
|
|
|
for (ii = 0; ii < pKey->uKeyLength; ii++) {
|
|
|
|
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%02x ", pKey->abyKey[ii]);
|
|
|
|
}
|
|
|
|
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"\n");
|
|
|
|
|
2012-11-11 08:45:52 -07:00
|
|
|
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->dwTSC47_16: %x\n ",
|
|
|
|
pKey->dwTSC47_16);
|
|
|
|
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->wTSC15_0: %x\n ",
|
|
|
|
pKey->wTSC15_0);
|
|
|
|
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->dwKeyIndex: %x\n ",
|
|
|
|
pKey->dwKeyIndex);
|
2009-06-13 05:38:31 -06:00
|
|
|
|
2013-02-12 18:36:30 -07:00
|
|
|
return (true);
|
2009-06-13 05:38:31 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (j < (MAX_KEY_TABLE-1)) {
|
2010-04-13 18:54:48 -06:00
|
|
|
memcpy(pTable->KeyTable[j].abyBSSID, pbyBSSID, ETH_ALEN);
|
2013-02-12 18:36:30 -07:00
|
|
|
pTable->KeyTable[j].bInUse = true;
|
2009-06-13 05:38:31 -06:00
|
|
|
if ((dwKeyIndex & PAIRWISE_KEY) != 0) {
|
|
|
|
// Pairwise key
|
|
|
|
pKey = &(pTable->KeyTable[j].PairwiseKey);
|
|
|
|
pTable->KeyTable[j].wKeyCtl &= 0xFFF0; // clear pairwise key control filed
|
|
|
|
pTable->KeyTable[j].wKeyCtl |= byKeyDecMode;
|
|
|
|
uKeyIdx = 4; // use HW key entry 4 for pairwise key
|
|
|
|
} else {
|
|
|
|
// Group key
|
|
|
|
if ((dwKeyIndex & 0x000000FF) >= MAX_GROUP_KEY)
|
2013-02-12 18:36:29 -07:00
|
|
|
return (false);
|
2009-06-13 05:38:31 -06:00
|
|
|
pKey = &(pTable->KeyTable[j].GroupKey[dwKeyIndex & 0x000000FF]);
|
|
|
|
if ((dwKeyIndex & TRANSMIT_KEY) != 0) {
|
|
|
|
// Group transmit key
|
|
|
|
pTable->KeyTable[j].dwGTKeyIndex = dwKeyIndex;
|
2012-11-11 08:45:52 -07:00
|
|
|
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO
|
|
|
|
"Group transmit key(N)[%X]: %d\n",
|
|
|
|
pTable->KeyTable[j].dwGTKeyIndex, j);
|
2009-06-13 05:38:31 -06:00
|
|
|
}
|
|
|
|
pTable->KeyTable[j].wKeyCtl &= 0xFF0F; // clear group key control filed
|
|
|
|
pTable->KeyTable[j].wKeyCtl |= (byKeyDecMode << 4);
|
|
|
|
pTable->KeyTable[j].wKeyCtl |= 0x0040; // use group key for group address
|
|
|
|
uKeyIdx = (dwKeyIndex & 0x000000FF);
|
|
|
|
}
|
|
|
|
pTable->KeyTable[j].wKeyCtl |= 0x8000; // enable on-fly
|
|
|
|
|
2013-02-12 18:36:30 -07:00
|
|
|
pKey->bKeyValid = true;
|
2009-06-13 05:38:31 -06:00
|
|
|
pKey->uKeyLength = uKeyLength;
|
|
|
|
pKey->dwKeyIndex = dwKeyIndex;
|
|
|
|
pKey->byCipherSuite = byKeyDecMode;
|
2009-08-12 15:54:11 -06:00
|
|
|
memcpy(pKey->abyKey, pbyKey, uKeyLength);
|
2009-06-13 05:38:31 -06:00
|
|
|
if (byKeyDecMode == KEY_CTL_WEP) {
|
|
|
|
if (uKeyLength == WLAN_WEP40_KEYLEN)
|
|
|
|
pKey->abyKey[15] &= 0x7F;
|
|
|
|
if (uKeyLength == WLAN_WEP104_KEYLEN)
|
|
|
|
pKey->abyKey[15] |= 0x80;
|
|
|
|
}
|
2013-02-25 18:32:53 -07:00
|
|
|
MACvSetKeyEntry(pDevice, pTable->KeyTable[j].wKeyCtl, j, uKeyIdx, pbyBSSID, (u32 *)pKey->abyKey);
|
2009-06-13 05:38:31 -06:00
|
|
|
|
2012-11-28 14:11:02 -07:00
|
|
|
if ((dwKeyIndex & USE_KEYRSC) == 0)
|
|
|
|
pKey->KeyRSC = 0; /* RSC set by NIC */
|
|
|
|
else
|
|
|
|
pKey->KeyRSC = *KeyRSC;
|
|
|
|
|
2009-06-13 05:38:31 -06:00
|
|
|
pKey->dwTSC47_16 = 0;
|
|
|
|
pKey->wTSC15_0 = 0;
|
|
|
|
|
|
|
|
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"KeybSetKey(N): \n");
|
|
|
|
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->bKeyValid: %d\n ", pKey->bKeyValid);
|
|
|
|
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->uKeyLength: %d\n ", (int)pKey->uKeyLength);
|
|
|
|
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->abyKey: ");
|
|
|
|
for (ii = 0; ii < pKey->uKeyLength; ii++) {
|
|
|
|
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%02x ", pKey->abyKey[ii]);
|
|
|
|
}
|
|
|
|
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"\n");
|
|
|
|
|
2012-11-11 08:45:52 -07:00
|
|
|
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->dwTSC47_16: %x\n ",
|
|
|
|
pKey->dwTSC47_16);
|
2009-06-13 05:38:31 -06:00
|
|
|
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->wTSC15_0: %x\n ", pKey->wTSC15_0);
|
2012-11-11 08:45:52 -07:00
|
|
|
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->dwKeyIndex: %x\n ",
|
|
|
|
pKey->dwKeyIndex);
|
2009-06-13 05:38:31 -06:00
|
|
|
|
2013-02-12 18:36:30 -07:00
|
|
|
return (true);
|
2009-06-13 05:38:31 -06:00
|
|
|
}
|
2013-02-12 18:36:29 -07:00
|
|
|
return (false);
|
2009-06-13 05:38:31 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Description: Remove Key from table
|
|
|
|
*
|
|
|
|
* Parameters:
|
|
|
|
* In:
|
|
|
|
* pTable - Pointer to Key table
|
|
|
|
* pbyBSSID - BSSID of Key
|
|
|
|
* dwKeyIndex - Key Index (reference to NDIS DDK)
|
|
|
|
* Out:
|
|
|
|
* none
|
|
|
|
*
|
2013-02-12 18:36:30 -07:00
|
|
|
* Return Value: true if success otherwise false
|
2009-06-13 05:38:31 -06:00
|
|
|
*
|
|
|
|
*/
|
2012-12-10 15:12:07 -07:00
|
|
|
|
|
|
|
int KeybRemoveKey(struct vnt_private *pDevice, PSKeyManagement pTable,
|
|
|
|
u8 *pbyBSSID, u32 dwKeyIndex)
|
2009-06-13 05:38:31 -06:00
|
|
|
{
|
2012-12-10 15:12:07 -07:00
|
|
|
int i;
|
2013-02-12 18:36:29 -07:00
|
|
|
int bReturnValue = false;
|
2009-06-13 05:38:31 -06:00
|
|
|
|
2010-06-22 18:57:42 -06:00
|
|
|
if (is_broadcast_ether_addr(pbyBSSID)) {
|
2012-08-26 09:16:43 -06:00
|
|
|
// delete all keys
|
2009-06-13 05:38:31 -06:00
|
|
|
if ((dwKeyIndex & PAIRWISE_KEY) != 0) {
|
|
|
|
for (i=0;i<MAX_KEY_TABLE;i++) {
|
2013-02-12 18:36:29 -07:00
|
|
|
pTable->KeyTable[i].PairwiseKey.bKeyValid = false;
|
2009-06-13 05:38:31 -06:00
|
|
|
}
|
2013-02-12 18:36:30 -07:00
|
|
|
bReturnValue = true;
|
2009-06-13 05:38:31 -06:00
|
|
|
}
|
|
|
|
else if ((dwKeyIndex & 0x000000FF) < MAX_GROUP_KEY) {
|
|
|
|
for (i=0;i<MAX_KEY_TABLE;i++) {
|
2013-02-12 18:36:29 -07:00
|
|
|
pTable->KeyTable[i].GroupKey[dwKeyIndex & 0x000000FF].bKeyValid = false;
|
2009-06-13 05:38:31 -06:00
|
|
|
if ((dwKeyIndex & 0x7FFFFFFF) == (pTable->KeyTable[i].dwGTKeyIndex & 0x7FFFFFFF)) {
|
|
|
|
// remove Group transmit key
|
|
|
|
pTable->KeyTable[i].dwGTKeyIndex = 0;
|
|
|
|
}
|
|
|
|
}
|
2013-02-12 18:36:30 -07:00
|
|
|
bReturnValue = true;
|
2009-06-13 05:38:31 -06:00
|
|
|
}
|
|
|
|
else {
|
2013-02-12 18:36:29 -07:00
|
|
|
bReturnValue = false;
|
2009-06-13 05:38:31 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
for (i=0;i<MAX_KEY_TABLE;i++) {
|
2013-02-12 18:36:30 -07:00
|
|
|
if ( (pTable->KeyTable[i].bInUse == true) &&
|
Staging: Convert uses of compare_ether_addr to ether_addr_equal
Preliminary to removing compare_ether_addr altogether:
Use the new bool function ether_addr_equal to add
some clarity and reduce the likelihood for misuse
of compare_ether_addr for sorting.
Additionally:
Used is_zero_ether_addr, removed now unused variable
Converted uses of &foo[0] to foo
Done via cocci script: (and a little typing)
$ cat compare_ether_addr.cocci
@@
expression a,b;
@@
- !compare_ether_addr(a, b)
+ ether_addr_equal(a, b)
@@
expression a,b;
@@
- compare_ether_addr(a, b)
+ !ether_addr_equal(a, b)
@@
expression a,b;
@@
- !ether_addr_equal(a, b) == 0
+ ether_addr_equal(a, b)
@@
expression a,b;
@@
- !ether_addr_equal(a, b) != 0
+ !ether_addr_equal(a, b)
@@
expression a,b;
@@
- ether_addr_equal(a, b) == 0
+ !ether_addr_equal(a, b)
@@
expression a,b;
@@
- ether_addr_equal(a, b) != 0
+ ether_addr_equal(a, b)
@@
expression a,b;
@@
- !!ether_addr_equal(a, b)
+ ether_addr_equal(a, b)
Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-09-01 13:15:47 -06:00
|
|
|
ether_addr_equal(pTable->KeyTable[i].abyBSSID, pbyBSSID)) {
|
2009-06-13 05:38:31 -06:00
|
|
|
|
|
|
|
if ((dwKeyIndex & PAIRWISE_KEY) != 0) {
|
2013-02-12 18:36:29 -07:00
|
|
|
pTable->KeyTable[i].PairwiseKey.bKeyValid = false;
|
2013-02-12 18:36:30 -07:00
|
|
|
bReturnValue = true;
|
2009-06-13 05:38:31 -06:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
else if ((dwKeyIndex & 0x000000FF) < MAX_GROUP_KEY) {
|
2013-02-12 18:36:29 -07:00
|
|
|
pTable->KeyTable[i].GroupKey[dwKeyIndex & 0x000000FF].bKeyValid = false;
|
2009-06-13 05:38:31 -06:00
|
|
|
if ((dwKeyIndex & 0x7FFFFFFF) == (pTable->KeyTable[i].dwGTKeyIndex & 0x7FFFFFFF)) {
|
|
|
|
// remove Group transmit key
|
|
|
|
pTable->KeyTable[i].dwGTKeyIndex = 0;
|
|
|
|
}
|
2013-02-12 18:36:30 -07:00
|
|
|
bReturnValue = true;
|
2009-06-13 05:38:31 -06:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
else {
|
2013-02-12 18:36:29 -07:00
|
|
|
bReturnValue = false;
|
2009-06-13 05:38:31 -06:00
|
|
|
break;
|
|
|
|
}
|
2013-02-12 18:36:30 -07:00
|
|
|
} //pTable->KeyTable[i].bInUse == true
|
2009-06-13 05:38:31 -06:00
|
|
|
} //for
|
2013-02-12 18:36:30 -07:00
|
|
|
bReturnValue = true;
|
2009-06-13 05:38:31 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
s_vCheckKeyTableValid(pDevice,pTable);
|
|
|
|
return bReturnValue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Description: Remove Key from table
|
|
|
|
*
|
|
|
|
* Parameters:
|
|
|
|
* In:
|
|
|
|
* pTable - Pointer to Key table
|
|
|
|
* pbyBSSID - BSSID of Key
|
|
|
|
* Out:
|
|
|
|
* none
|
|
|
|
*
|
2013-02-12 18:36:30 -07:00
|
|
|
* Return Value: true if success otherwise false
|
2009-06-13 05:38:31 -06:00
|
|
|
*
|
|
|
|
*/
|
2012-12-10 15:12:07 -07:00
|
|
|
int KeybRemoveAllKey(struct vnt_private *pDevice, PSKeyManagement pTable,
|
|
|
|
u8 *pbyBSSID)
|
2009-06-13 05:38:31 -06:00
|
|
|
{
|
2012-12-10 15:12:07 -07:00
|
|
|
int i, u;
|
2009-06-13 05:38:31 -06:00
|
|
|
|
|
|
|
for (i=0;i<MAX_KEY_TABLE;i++) {
|
2013-02-12 18:36:30 -07:00
|
|
|
if ((pTable->KeyTable[i].bInUse == true) &&
|
Staging: Convert uses of compare_ether_addr to ether_addr_equal
Preliminary to removing compare_ether_addr altogether:
Use the new bool function ether_addr_equal to add
some clarity and reduce the likelihood for misuse
of compare_ether_addr for sorting.
Additionally:
Used is_zero_ether_addr, removed now unused variable
Converted uses of &foo[0] to foo
Done via cocci script: (and a little typing)
$ cat compare_ether_addr.cocci
@@
expression a,b;
@@
- !compare_ether_addr(a, b)
+ ether_addr_equal(a, b)
@@
expression a,b;
@@
- compare_ether_addr(a, b)
+ !ether_addr_equal(a, b)
@@
expression a,b;
@@
- !ether_addr_equal(a, b) == 0
+ ether_addr_equal(a, b)
@@
expression a,b;
@@
- !ether_addr_equal(a, b) != 0
+ !ether_addr_equal(a, b)
@@
expression a,b;
@@
- ether_addr_equal(a, b) == 0
+ !ether_addr_equal(a, b)
@@
expression a,b;
@@
- ether_addr_equal(a, b) != 0
+ ether_addr_equal(a, b)
@@
expression a,b;
@@
- !!ether_addr_equal(a, b)
+ ether_addr_equal(a, b)
Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-09-01 13:15:47 -06:00
|
|
|
ether_addr_equal(pTable->KeyTable[i].abyBSSID, pbyBSSID)) {
|
2013-02-12 18:36:29 -07:00
|
|
|
pTable->KeyTable[i].PairwiseKey.bKeyValid = false;
|
2010-05-19 20:50:00 -06:00
|
|
|
for (u = 0; u < MAX_GROUP_KEY; u++)
|
2013-02-12 18:36:29 -07:00
|
|
|
pTable->KeyTable[i].GroupKey[u].bKeyValid = false;
|
2010-05-19 20:50:00 -06:00
|
|
|
|
2009-06-13 05:38:31 -06:00
|
|
|
pTable->KeyTable[i].dwGTKeyIndex = 0;
|
|
|
|
s_vCheckKeyTableValid(pDevice, pTable);
|
2013-02-12 18:36:30 -07:00
|
|
|
return (true);
|
2009-06-13 05:38:31 -06:00
|
|
|
}
|
|
|
|
}
|
2013-02-12 18:36:29 -07:00
|
|
|
return (false);
|
2009-06-13 05:38:31 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Description: Get Transmit Key from table
|
|
|
|
*
|
|
|
|
* Parameters:
|
|
|
|
* In:
|
|
|
|
* pTable - Pointer to Key table
|
|
|
|
* pbyBSSID - BSSID of Key
|
|
|
|
* Out:
|
|
|
|
* pKey - Key return
|
|
|
|
*
|
2013-02-12 18:36:30 -07:00
|
|
|
* Return Value: true if found otherwise false
|
2009-06-13 05:38:31 -06:00
|
|
|
*
|
|
|
|
*/
|
2012-12-10 15:12:07 -07:00
|
|
|
int KeybGetTransmitKey(PSKeyManagement pTable, u8 *pbyBSSID, u32 dwKeyType,
|
|
|
|
PSKeyItem *pKey)
|
2009-06-13 05:38:31 -06:00
|
|
|
{
|
2012-12-10 15:12:07 -07:00
|
|
|
int i, ii;
|
|
|
|
|
|
|
|
*pKey = NULL;
|
2009-06-13 05:38:31 -06:00
|
|
|
|
2010-08-06 09:21:38 -06:00
|
|
|
for (i = 0; i < MAX_KEY_TABLE; i++) {
|
2013-02-12 18:36:30 -07:00
|
|
|
if ((pTable->KeyTable[i].bInUse == true) &&
|
Staging: Convert uses of compare_ether_addr to ether_addr_equal
Preliminary to removing compare_ether_addr altogether:
Use the new bool function ether_addr_equal to add
some clarity and reduce the likelihood for misuse
of compare_ether_addr for sorting.
Additionally:
Used is_zero_ether_addr, removed now unused variable
Converted uses of &foo[0] to foo
Done via cocci script: (and a little typing)
$ cat compare_ether_addr.cocci
@@
expression a,b;
@@
- !compare_ether_addr(a, b)
+ ether_addr_equal(a, b)
@@
expression a,b;
@@
- compare_ether_addr(a, b)
+ !ether_addr_equal(a, b)
@@
expression a,b;
@@
- !ether_addr_equal(a, b) == 0
+ ether_addr_equal(a, b)
@@
expression a,b;
@@
- !ether_addr_equal(a, b) != 0
+ !ether_addr_equal(a, b)
@@
expression a,b;
@@
- ether_addr_equal(a, b) == 0
+ !ether_addr_equal(a, b)
@@
expression a,b;
@@
- ether_addr_equal(a, b) != 0
+ ether_addr_equal(a, b)
@@
expression a,b;
@@
- !!ether_addr_equal(a, b)
+ ether_addr_equal(a, b)
Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-09-01 13:15:47 -06:00
|
|
|
ether_addr_equal(pTable->KeyTable[i].abyBSSID, pbyBSSID)) {
|
2009-06-13 05:38:31 -06:00
|
|
|
|
|
|
|
if (dwKeyType == PAIRWISE_KEY) {
|
|
|
|
|
2013-02-12 18:36:30 -07:00
|
|
|
if (pTable->KeyTable[i].PairwiseKey.bKeyValid == true) {
|
2009-06-13 05:38:31 -06:00
|
|
|
*pKey = &(pTable->KeyTable[i].PairwiseKey);
|
|
|
|
|
|
|
|
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"KeybGetTransmitKey:");
|
|
|
|
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"PAIRWISE_KEY: KeyTable.abyBSSID: ");
|
|
|
|
for (ii = 0; ii < 6; ii++) {
|
|
|
|
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"%x ", pTable->KeyTable[i].abyBSSID[ii]);
|
|
|
|
}
|
|
|
|
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"\n");
|
|
|
|
|
2013-02-12 18:36:30 -07:00
|
|
|
return (true);
|
2009-06-13 05:38:31 -06:00
|
|
|
}
|
|
|
|
else {
|
2013-02-12 18:36:29 -07:00
|
|
|
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"PairwiseKey.bKeyValid == false\n");
|
|
|
|
return (false);
|
2009-06-13 05:38:31 -06:00
|
|
|
}
|
|
|
|
} // End of Type == PAIRWISE
|
|
|
|
else {
|
|
|
|
if (pTable->KeyTable[i].dwGTKeyIndex == 0) {
|
|
|
|
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ERROR: dwGTKeyIndex == 0 !!!\n");
|
2013-02-12 18:36:29 -07:00
|
|
|
return false;
|
2009-06-13 05:38:31 -06:00
|
|
|
}
|
2013-02-12 18:36:30 -07:00
|
|
|
if (pTable->KeyTable[i].GroupKey[(pTable->KeyTable[i].dwGTKeyIndex&0x000000FF)].bKeyValid == true) {
|
2009-06-13 05:38:31 -06:00
|
|
|
*pKey = &(pTable->KeyTable[i].GroupKey[(pTable->KeyTable[i].dwGTKeyIndex&0x000000FF)]);
|
|
|
|
|
|
|
|
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"KeybGetTransmitKey:");
|
|
|
|
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"GROUP_KEY: KeyTable.abyBSSID\n");
|
|
|
|
for (ii = 0; ii < 6; ii++) {
|
|
|
|
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"%x ", pTable->KeyTable[i].abyBSSID[ii]);
|
|
|
|
}
|
|
|
|
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"\n");
|
2012-11-11 08:45:52 -07:00
|
|
|
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"dwGTKeyIndex: %X\n",
|
|
|
|
pTable->KeyTable[i].dwGTKeyIndex);
|
2009-06-13 05:38:31 -06:00
|
|
|
|
2013-02-12 18:36:30 -07:00
|
|
|
return (true);
|
2009-06-13 05:38:31 -06:00
|
|
|
}
|
|
|
|
else {
|
2013-02-12 18:36:29 -07:00
|
|
|
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"GroupKey.bKeyValid == false\n");
|
|
|
|
return (false);
|
2009-06-13 05:38:31 -06:00
|
|
|
}
|
|
|
|
} // End of Type = GROUP
|
|
|
|
} // BSSID match
|
|
|
|
}
|
|
|
|
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ERROR: NO Match BSSID !!! ");
|
|
|
|
for (ii = 0; ii < 6; ii++) {
|
|
|
|
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"%02x ", *(pbyBSSID+ii));
|
|
|
|
}
|
|
|
|
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"\n");
|
2013-02-12 18:36:29 -07:00
|
|
|
return (false);
|
2009-06-13 05:38:31 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Description: Set Key to table
|
|
|
|
*
|
|
|
|
* Parameters:
|
|
|
|
* In:
|
|
|
|
* pTable - Pointer to Key table
|
|
|
|
* dwKeyIndex - Key index (reference to NDIS DDK)
|
|
|
|
* uKeyLength - Key length
|
|
|
|
* KeyRSC - Key RSC
|
|
|
|
* pbyKey - Pointer to key
|
|
|
|
* Out:
|
|
|
|
* none
|
|
|
|
*
|
2013-02-12 18:36:30 -07:00
|
|
|
* Return Value: true if success otherwise false
|
2009-06-13 05:38:31 -06:00
|
|
|
*
|
|
|
|
*/
|
2012-12-10 15:12:07 -07:00
|
|
|
|
|
|
|
int KeybSetDefaultKey(struct vnt_private *pDevice, PSKeyManagement pTable,
|
|
|
|
u32 dwKeyIndex, u32 uKeyLength, u64 *KeyRSC, u8 *pbyKey,
|
|
|
|
u8 byKeyDecMode)
|
2009-06-13 05:38:31 -06:00
|
|
|
{
|
2012-12-10 15:12:07 -07:00
|
|
|
int ii;
|
|
|
|
PSKeyItem pKey;
|
|
|
|
u32 uKeyIdx;
|
2009-06-13 05:38:31 -06:00
|
|
|
|
2010-05-17 18:34:01 -06:00
|
|
|
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Enter KeybSetDefaultKey: %1x, %d\n",
|
|
|
|
(int) dwKeyIndex, (int) uKeyLength);
|
2009-06-13 05:38:31 -06:00
|
|
|
|
|
|
|
if ((dwKeyIndex & PAIRWISE_KEY) != 0) { // Pairwise key
|
2013-02-12 18:36:29 -07:00
|
|
|
return (false);
|
2009-06-13 05:38:31 -06:00
|
|
|
} else if ((dwKeyIndex & 0x000000FF) >= MAX_GROUP_KEY) {
|
2013-02-12 18:36:29 -07:00
|
|
|
return (false);
|
2009-06-13 05:38:31 -06:00
|
|
|
}
|
|
|
|
|
2012-03-29 00:43:54 -06:00
|
|
|
if (uKeyLength > MAX_KEY_LEN)
|
|
|
|
return false;
|
|
|
|
|
2013-02-12 18:36:30 -07:00
|
|
|
pTable->KeyTable[MAX_KEY_TABLE-1].bInUse = true;
|
2010-04-13 18:54:48 -06:00
|
|
|
for (ii = 0; ii < ETH_ALEN; ii++)
|
2009-06-13 05:38:31 -06:00
|
|
|
pTable->KeyTable[MAX_KEY_TABLE-1].abyBSSID[ii] = 0xFF;
|
|
|
|
|
|
|
|
// Group key
|
|
|
|
pKey = &(pTable->KeyTable[MAX_KEY_TABLE-1].GroupKey[dwKeyIndex & 0x000000FF]);
|
|
|
|
if ((dwKeyIndex & TRANSMIT_KEY) != 0) {
|
|
|
|
// Group transmit key
|
|
|
|
pTable->KeyTable[MAX_KEY_TABLE-1].dwGTKeyIndex = dwKeyIndex;
|
2012-11-11 08:45:52 -07:00
|
|
|
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO
|
|
|
|
"Group transmit key(R)[%X]: %d\n",
|
|
|
|
pTable->KeyTable[MAX_KEY_TABLE-1].dwGTKeyIndex,
|
|
|
|
MAX_KEY_TABLE-1);
|
2009-06-13 05:38:31 -06:00
|
|
|
|
|
|
|
}
|
|
|
|
pTable->KeyTable[MAX_KEY_TABLE-1].wKeyCtl &= 0x7F00; // clear all key control filed
|
|
|
|
pTable->KeyTable[MAX_KEY_TABLE-1].wKeyCtl |= (byKeyDecMode << 4);
|
|
|
|
pTable->KeyTable[MAX_KEY_TABLE-1].wKeyCtl |= (byKeyDecMode);
|
|
|
|
pTable->KeyTable[MAX_KEY_TABLE-1].wKeyCtl |= 0x0044; // use group key for all address
|
|
|
|
uKeyIdx = (dwKeyIndex & 0x000000FF);
|
|
|
|
|
|
|
|
if ((uKeyLength == WLAN_WEP232_KEYLEN) &&
|
|
|
|
(byKeyDecMode == KEY_CTL_WEP)) {
|
|
|
|
pTable->KeyTable[MAX_KEY_TABLE-1].wKeyCtl |= 0x4000; // disable on-fly disable address match
|
2013-02-12 18:36:30 -07:00
|
|
|
pTable->KeyTable[MAX_KEY_TABLE-1].bSoftWEP = true;
|
2009-06-13 05:38:31 -06:00
|
|
|
} else {
|
2013-02-12 18:36:29 -07:00
|
|
|
if (pTable->KeyTable[MAX_KEY_TABLE-1].bSoftWEP == false)
|
2009-06-13 05:38:31 -06:00
|
|
|
pTable->KeyTable[MAX_KEY_TABLE-1].wKeyCtl |= 0xC000; // enable on-fly disable address match
|
|
|
|
}
|
|
|
|
|
2013-02-12 18:36:30 -07:00
|
|
|
pKey->bKeyValid = true;
|
2009-06-13 05:38:31 -06:00
|
|
|
pKey->uKeyLength = uKeyLength;
|
|
|
|
pKey->dwKeyIndex = dwKeyIndex;
|
|
|
|
pKey->byCipherSuite = byKeyDecMode;
|
2009-08-12 15:54:11 -06:00
|
|
|
memcpy(pKey->abyKey, pbyKey, uKeyLength);
|
2009-06-13 05:38:31 -06:00
|
|
|
if (byKeyDecMode == KEY_CTL_WEP) {
|
|
|
|
if (uKeyLength == WLAN_WEP40_KEYLEN)
|
|
|
|
pKey->abyKey[15] &= 0x7F;
|
|
|
|
if (uKeyLength == WLAN_WEP104_KEYLEN)
|
|
|
|
pKey->abyKey[15] |= 0x80;
|
|
|
|
}
|
|
|
|
|
2013-02-25 18:32:53 -07:00
|
|
|
MACvSetKeyEntry(pDevice, pTable->KeyTable[MAX_KEY_TABLE-1].wKeyCtl, MAX_KEY_TABLE-1, uKeyIdx, pTable->KeyTable[MAX_KEY_TABLE-1].abyBSSID, (u32 *) pKey->abyKey);
|
2009-06-13 05:38:31 -06:00
|
|
|
|
2012-11-28 14:11:02 -07:00
|
|
|
if ((dwKeyIndex & USE_KEYRSC) == 0)
|
|
|
|
pKey->KeyRSC = 0; /* RSC set by NIC */
|
|
|
|
else
|
|
|
|
pKey->KeyRSC = *KeyRSC;
|
|
|
|
|
2009-06-13 05:38:31 -06:00
|
|
|
pKey->dwTSC47_16 = 0;
|
|
|
|
pKey->wTSC15_0 = 0;
|
|
|
|
|
|
|
|
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"KeybSetKey(R): \n");
|
|
|
|
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->bKeyValid: %d\n", pKey->bKeyValid);
|
|
|
|
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->uKeyLength: %d\n", (int)pKey->uKeyLength);
|
|
|
|
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->abyKey: \n");
|
|
|
|
for (ii = 0; ii < pKey->uKeyLength; ii++) {
|
|
|
|
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"%x", pKey->abyKey[ii]);
|
|
|
|
}
|
|
|
|
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"\n");
|
|
|
|
|
2012-11-11 08:45:52 -07:00
|
|
|
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->dwTSC47_16: %x\n",
|
|
|
|
pKey->dwTSC47_16);
|
2009-06-13 05:38:31 -06:00
|
|
|
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->wTSC15_0: %x\n", pKey->wTSC15_0);
|
2012-11-11 08:45:52 -07:00
|
|
|
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->dwKeyIndex: %x\n",
|
|
|
|
pKey->dwKeyIndex);
|
2009-06-13 05:38:31 -06:00
|
|
|
|
2013-02-12 18:36:30 -07:00
|
|
|
return (true);
|
2009-06-13 05:38:31 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Description: Set Key to table
|
|
|
|
*
|
|
|
|
* Parameters:
|
|
|
|
* In:
|
|
|
|
* pTable - Pointer to Key table
|
|
|
|
* dwKeyIndex - Key index (reference to NDIS DDK)
|
|
|
|
* uKeyLength - Key length
|
|
|
|
* KeyRSC - Key RSC
|
|
|
|
* pbyKey - Pointer to key
|
|
|
|
* Out:
|
|
|
|
* none
|
|
|
|
*
|
2013-02-12 18:36:30 -07:00
|
|
|
* Return Value: true if success otherwise false
|
2009-06-13 05:38:31 -06:00
|
|
|
*
|
|
|
|
*/
|
2012-12-10 15:12:07 -07:00
|
|
|
|
|
|
|
int KeybSetAllGroupKey(struct vnt_private *pDevice, PSKeyManagement pTable,
|
|
|
|
u32 dwKeyIndex, u32 uKeyLength, u64 *KeyRSC, u8 *pbyKey,
|
|
|
|
u8 byKeyDecMode)
|
2009-06-13 05:38:31 -06:00
|
|
|
{
|
2012-12-10 15:12:07 -07:00
|
|
|
int i, ii;
|
|
|
|
PSKeyItem pKey;
|
|
|
|
u32 uKeyIdx;
|
2009-06-13 05:38:31 -06:00
|
|
|
|
2012-11-11 08:45:52 -07:00
|
|
|
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Enter KeybSetAllGroupKey: %X\n",
|
|
|
|
dwKeyIndex);
|
2009-06-13 05:38:31 -06:00
|
|
|
|
|
|
|
if ((dwKeyIndex & PAIRWISE_KEY) != 0) { // Pairwise key
|
2013-02-12 18:36:29 -07:00
|
|
|
return (false);
|
2009-06-13 05:38:31 -06:00
|
|
|
} else if ((dwKeyIndex & 0x000000FF) >= MAX_GROUP_KEY) {
|
2013-02-12 18:36:29 -07:00
|
|
|
return (false);
|
2009-06-13 05:38:31 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
for (i=0; i < MAX_KEY_TABLE-1; i++) {
|
2013-02-12 18:36:30 -07:00
|
|
|
if (pTable->KeyTable[i].bInUse == true) {
|
2009-06-13 05:38:31 -06:00
|
|
|
// found table already exist
|
|
|
|
// Group key
|
|
|
|
pKey = &(pTable->KeyTable[i].GroupKey[dwKeyIndex & 0x000000FF]);
|
|
|
|
if ((dwKeyIndex & TRANSMIT_KEY) != 0) {
|
|
|
|
// Group transmit key
|
|
|
|
pTable->KeyTable[i].dwGTKeyIndex = dwKeyIndex;
|
2012-11-11 08:45:52 -07:00
|
|
|
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO
|
|
|
|
"Group transmit key(R)[%X]: %d\n",
|
|
|
|
pTable->KeyTable[i].dwGTKeyIndex, i);
|
2009-06-13 05:38:31 -06:00
|
|
|
|
|
|
|
}
|
|
|
|
pTable->KeyTable[i].wKeyCtl &= 0xFF0F; // clear group key control filed
|
|
|
|
pTable->KeyTable[i].wKeyCtl |= (byKeyDecMode << 4);
|
|
|
|
pTable->KeyTable[i].wKeyCtl |= 0x0040; // use group key for group address
|
|
|
|
uKeyIdx = (dwKeyIndex & 0x000000FF);
|
|
|
|
|
|
|
|
pTable->KeyTable[i].wKeyCtl |= 0x8000; // enable on-fly
|
|
|
|
|
2013-02-12 18:36:30 -07:00
|
|
|
pKey->bKeyValid = true;
|
2009-06-13 05:38:31 -06:00
|
|
|
pKey->uKeyLength = uKeyLength;
|
|
|
|
pKey->dwKeyIndex = dwKeyIndex;
|
|
|
|
pKey->byCipherSuite = byKeyDecMode;
|
2009-08-12 15:54:11 -06:00
|
|
|
memcpy(pKey->abyKey, pbyKey, uKeyLength);
|
2009-06-13 05:38:31 -06:00
|
|
|
if (byKeyDecMode == KEY_CTL_WEP) {
|
|
|
|
if (uKeyLength == WLAN_WEP40_KEYLEN)
|
|
|
|
pKey->abyKey[15] &= 0x7F;
|
|
|
|
if (uKeyLength == WLAN_WEP104_KEYLEN)
|
|
|
|
pKey->abyKey[15] |= 0x80;
|
|
|
|
}
|
|
|
|
|
2013-02-25 18:32:53 -07:00
|
|
|
MACvSetKeyEntry(pDevice, pTable->KeyTable[i].wKeyCtl, i, uKeyIdx, pTable->KeyTable[i].abyBSSID, (u32 *) pKey->abyKey);
|
2009-06-13 05:38:31 -06:00
|
|
|
|
2012-11-28 14:11:02 -07:00
|
|
|
if ((dwKeyIndex & USE_KEYRSC) == 0)
|
|
|
|
pKey->KeyRSC = 0; /* RSC set by NIC */
|
|
|
|
else
|
|
|
|
pKey->KeyRSC = *KeyRSC;
|
|
|
|
|
2009-06-13 05:38:31 -06:00
|
|
|
pKey->dwTSC47_16 = 0;
|
|
|
|
pKey->wTSC15_0 = 0;
|
|
|
|
|
|
|
|
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"KeybSetKey(R): \n");
|
|
|
|
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->bKeyValid: %d\n ", pKey->bKeyValid);
|
|
|
|
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->uKeyLength: %d\n ", (int)pKey->uKeyLength);
|
|
|
|
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->abyKey: ");
|
|
|
|
for (ii = 0; ii < pKey->uKeyLength; ii++) {
|
|
|
|
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"%02x ", pKey->abyKey[ii]);
|
|
|
|
}
|
|
|
|
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"\n");
|
|
|
|
|
|
|
|
//DBG_PRN_GRP12(("pKey->dwTSC47_16: %lX\n ", pKey->dwTSC47_16));
|
|
|
|
//DBG_PRN_GRP12(("pKey->wTSC15_0: %X\n ", pKey->wTSC15_0));
|
|
|
|
//DBG_PRN_GRP12(("pKey->dwKeyIndex: %lX\n ", pKey->dwKeyIndex));
|
|
|
|
|
2013-02-12 18:36:30 -07:00
|
|
|
} // (pTable->KeyTable[i].bInUse == true)
|
2009-06-13 05:38:31 -06:00
|
|
|
}
|
2013-02-12 18:36:30 -07:00
|
|
|
return (true);
|
2009-06-13 05:38:31 -06:00
|
|
|
}
|