Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

staging: vt6656: dead code remove old key functions

Signed-off-by: Malcolm Priestley <tvboxspy@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Malcolm Priestley and committed by
Greg Kroah-Hartman
93bf8a84 6d07a7e3

-768
-1
drivers/staging/vt6656/device.h
··· 635 635 NDIS_802_11_WEP_STATUS eEncryptionStatus; 636 636 int bTransmitKey; 637 637 NDIS_802_11_WEP_STATUS eOldEncryptionStatus; 638 - SKeyManagement sKey; 639 638 u32 dwIVCounter; 640 639 641 640 u8 abyPRNG[WLAN_WEPMAX_KEYLEN+3];
-694
drivers/staging/vt6656/key.c
··· 26 26 * Date: May 29, 2003 27 27 * 28 28 * Functions: 29 - * KeyvInitTable - Init Key management table 30 - * KeybGetKey - Get Key from table 31 - * KeybSetKey - Set Key to table 32 - * KeybRemoveKey - Remove Key from table 33 - * KeybGetTransmitKey - Get Transmit Key from table 34 29 * 35 30 * Revision History: 36 31 * 37 32 */ 38 33 39 34 #include "mac.h" 40 - #include "tmacro.h" 41 35 #include "key.h" 42 36 #include "usbpipe.h" 43 - 44 - static int msglevel =MSG_LEVEL_INFO; 45 - //static int msglevel =MSG_LEVEL_DEBUG; 46 - 47 - static void s_vCheckKeyTableValid(struct vnt_private *pDevice, 48 - PSKeyManagement pTable) 49 - { 50 - int i; 51 - u16 wLength = 0; 52 - u8 pbyData[MAX_KEY_TABLE]; 53 - 54 - for (i=0;i<MAX_KEY_TABLE;i++) { 55 - if ((pTable->KeyTable[i].bInUse == true) && 56 - (pTable->KeyTable[i].PairwiseKey.bKeyValid == false) && 57 - (pTable->KeyTable[i].GroupKey[0].bKeyValid == false) && 58 - (pTable->KeyTable[i].GroupKey[1].bKeyValid == false) && 59 - (pTable->KeyTable[i].GroupKey[2].bKeyValid == false) && 60 - (pTable->KeyTable[i].GroupKey[3].bKeyValid == false) 61 - ) { 62 - 63 - pTable->KeyTable[i].bInUse = false; 64 - pTable->KeyTable[i].wKeyCtl = 0; 65 - pTable->KeyTable[i].bSoftWEP = false; 66 - pbyData[wLength++] = (u8) i; 67 - } 68 - } 69 - 70 - if (wLength != 0) 71 - vnt_control_out(pDevice, MESSAGE_TYPE_CLRKEYENTRY, 72 - 0, 0, wLength, pbyData); 73 - 74 - } 75 - 76 - /* 77 - * Description: Init Key management table 78 - * 79 - * Parameters: 80 - * In: 81 - * pTable - Pointer to Key table 82 - * Out: 83 - * none 84 - * 85 - * Return Value: none 86 - * 87 - */ 88 - void KeyvInitTable(struct vnt_private *pDevice, PSKeyManagement pTable) 89 - { 90 - int i, jj; 91 - u8 pbyData[MAX_KEY_TABLE+1]; 92 - 93 - for (i=0;i<MAX_KEY_TABLE;i++) { 94 - pTable->KeyTable[i].bInUse = false; 95 - pTable->KeyTable[i].PairwiseKey.bKeyValid = false; 96 - pTable->KeyTable[i].PairwiseKey.pvKeyTable = 97 - (void *)&pTable->KeyTable[i]; 98 - for (jj=0; jj < MAX_GROUP_KEY; jj++) { 99 - pTable->KeyTable[i].GroupKey[jj].bKeyValid = false; 100 - pTable->KeyTable[i].GroupKey[jj].pvKeyTable = 101 - (void *) &(pTable->KeyTable[i]); 102 - } 103 - pTable->KeyTable[i].wKeyCtl = 0; 104 - pTable->KeyTable[i].dwGTKeyIndex = 0; 105 - pTable->KeyTable[i].bSoftWEP = false; 106 - pbyData[i] = (u8) i; 107 - } 108 - pbyData[i] = (u8) i; 109 - 110 - vnt_control_out(pDevice, MESSAGE_TYPE_CLRKEYENTRY, 111 - 0, 0, 11, pbyData); 112 - 113 - return; 114 - } 115 - 116 - /* 117 - * Description: Get Key from table 118 - * 119 - * Parameters: 120 - * In: 121 - * pTable - Pointer to Key table 122 - * pbyBSSID - BSSID of Key 123 - * dwKeyIndex - Key Index (0xFFFFFFFF means pairwise key) 124 - * Out: 125 - * pKey - Key return 126 - * 127 - * Return Value: true if found otherwise false 128 - * 129 - */ 130 - int KeybGetKey(PSKeyManagement pTable, u8 *pbyBSSID, u32 dwKeyIndex, 131 - PSKeyItem *pKey) 132 - { 133 - int i; 134 - 135 - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"KeybGetKey()\n"); 136 - 137 - *pKey = NULL; 138 - for (i=0;i<MAX_KEY_TABLE;i++) { 139 - if ((pTable->KeyTable[i].bInUse == true) && 140 - ether_addr_equal(pTable->KeyTable[i].abyBSSID, pbyBSSID)) { 141 - if (dwKeyIndex == 0xFFFFFFFF) { 142 - if (pTable->KeyTable[i].PairwiseKey.bKeyValid == true) { 143 - *pKey = &(pTable->KeyTable[i].PairwiseKey); 144 - return (true); 145 - } 146 - else { 147 - return (false); 148 - } 149 - } else if (dwKeyIndex < MAX_GROUP_KEY) { 150 - if (pTable->KeyTable[i].GroupKey[dwKeyIndex].bKeyValid == true) { 151 - *pKey = &(pTable->KeyTable[i].GroupKey[dwKeyIndex]); 152 - return (true); 153 - } 154 - else { 155 - return (false); 156 - } 157 - } 158 - else { 159 - return (false); 160 - } 161 - } 162 - } 163 - return (false); 164 - } 165 - 166 - /* 167 - * Description: Set Key to table 168 - * 169 - * Parameters: 170 - * In: 171 - * pTable - Pointer to Key table 172 - * pbyBSSID - BSSID of Key 173 - * dwKeyIndex - Key index (reference to NDIS DDK) 174 - * uKeyLength - Key length 175 - * KeyRSC - Key RSC 176 - * pbyKey - Pointer to key 177 - * Out: 178 - * none 179 - * 180 - * Return Value: true if success otherwise false 181 - * 182 - */ 183 - int KeybSetKey(struct vnt_private *pDevice, PSKeyManagement pTable, 184 - u8 *pbyBSSID, u32 dwKeyIndex, u32 uKeyLength, u64 *KeyRSC, u8 *pbyKey, 185 - u8 byKeyDecMode) 186 - { 187 - PSKeyItem pKey; 188 - int i, j, ii; 189 - u32 uKeyIdx; 190 - 191 - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO 192 - "Enter KeybSetKey: %X\n", dwKeyIndex); 193 - 194 - j = (MAX_KEY_TABLE-1); 195 - for (i=0;i<(MAX_KEY_TABLE-1);i++) { 196 - if ((pTable->KeyTable[i].bInUse == false) && 197 - (j == (MAX_KEY_TABLE-1))) { 198 - // found empty table 199 - j = i; 200 - } 201 - if ((pTable->KeyTable[i].bInUse == true) && 202 - ether_addr_equal(pTable->KeyTable[i].abyBSSID, pbyBSSID)) { 203 - // found table already exist 204 - if ((dwKeyIndex & PAIRWISE_KEY) != 0) { 205 - // Pairwise key 206 - pKey = &(pTable->KeyTable[i].PairwiseKey); 207 - pTable->KeyTable[i].wKeyCtl &= 0xFFF0; // clear pairwise key control filed 208 - pTable->KeyTable[i].wKeyCtl |= byKeyDecMode; 209 - uKeyIdx = 4; // use HW key entry 4 for pairwise key 210 - } else { 211 - // Group key 212 - if ((dwKeyIndex & 0x000000FF) >= MAX_GROUP_KEY) 213 - return (false); 214 - pKey = &(pTable->KeyTable[i].GroupKey[dwKeyIndex & 0x000000FF]); 215 - if ((dwKeyIndex & TRANSMIT_KEY) != 0) { 216 - // Group transmit key 217 - pTable->KeyTable[i].dwGTKeyIndex = dwKeyIndex; 218 - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO 219 - "Group transmit key(R)[%X]: %d\n", 220 - pTable->KeyTable[i].dwGTKeyIndex, i); 221 - } 222 - pTable->KeyTable[i].wKeyCtl &= 0xFF0F; // clear group key control filed 223 - pTable->KeyTable[i].wKeyCtl |= (byKeyDecMode << 4); 224 - pTable->KeyTable[i].wKeyCtl |= 0x0040; // use group key for group address 225 - uKeyIdx = (dwKeyIndex & 0x000000FF); 226 - } 227 - pTable->KeyTable[i].wKeyCtl |= 0x8000; // enable on-fly 228 - 229 - pKey->bKeyValid = true; 230 - pKey->uKeyLength = uKeyLength; 231 - pKey->dwKeyIndex = dwKeyIndex; 232 - pKey->byCipherSuite = byKeyDecMode; 233 - memcpy(pKey->abyKey, pbyKey, uKeyLength); 234 - if (byKeyDecMode == KEY_CTL_WEP) { 235 - if (uKeyLength == WLAN_WEP40_KEYLEN) 236 - pKey->abyKey[15] &= 0x7F; 237 - if (uKeyLength == WLAN_WEP104_KEYLEN) 238 - pKey->abyKey[15] |= 0x80; 239 - } 240 - 241 - vnt_mac_set_keyentry(pDevice, pTable->KeyTable[i].wKeyCtl, i, 242 - uKeyIdx, pbyBSSID, pKey->abyKey); 243 - 244 - if ((dwKeyIndex & USE_KEYRSC) == 0) 245 - pKey->KeyRSC = 0; /* RSC set by NIC */ 246 - else 247 - pKey->KeyRSC = *KeyRSC; 248 - 249 - pKey->dwTSC47_16 = 0; 250 - pKey->wTSC15_0 = 0; 251 - 252 - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"KeybSetKey(R): \n"); 253 - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->bKeyValid: %d\n ", pKey->bKeyValid); 254 - //DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->uKeyLength: %d\n ", pKey->uKeyLength); 255 - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->abyKey: "); 256 - for (ii = 0; ii < pKey->uKeyLength; ii++) { 257 - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%02x ", pKey->abyKey[ii]); 258 - } 259 - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"\n"); 260 - 261 - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->dwTSC47_16: %x\n ", 262 - pKey->dwTSC47_16); 263 - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->wTSC15_0: %x\n ", 264 - pKey->wTSC15_0); 265 - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->dwKeyIndex: %x\n ", 266 - pKey->dwKeyIndex); 267 - 268 - return (true); 269 - } 270 - } 271 - if (j < (MAX_KEY_TABLE-1)) { 272 - memcpy(pTable->KeyTable[j].abyBSSID, pbyBSSID, ETH_ALEN); 273 - pTable->KeyTable[j].bInUse = true; 274 - if ((dwKeyIndex & PAIRWISE_KEY) != 0) { 275 - // Pairwise key 276 - pKey = &(pTable->KeyTable[j].PairwiseKey); 277 - pTable->KeyTable[j].wKeyCtl &= 0xFFF0; // clear pairwise key control filed 278 - pTable->KeyTable[j].wKeyCtl |= byKeyDecMode; 279 - uKeyIdx = 4; // use HW key entry 4 for pairwise key 280 - } else { 281 - // Group key 282 - if ((dwKeyIndex & 0x000000FF) >= MAX_GROUP_KEY) 283 - return (false); 284 - pKey = &(pTable->KeyTable[j].GroupKey[dwKeyIndex & 0x000000FF]); 285 - if ((dwKeyIndex & TRANSMIT_KEY) != 0) { 286 - // Group transmit key 287 - pTable->KeyTable[j].dwGTKeyIndex = dwKeyIndex; 288 - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO 289 - "Group transmit key(N)[%X]: %d\n", 290 - pTable->KeyTable[j].dwGTKeyIndex, j); 291 - } 292 - pTable->KeyTable[j].wKeyCtl &= 0xFF0F; // clear group key control filed 293 - pTable->KeyTable[j].wKeyCtl |= (byKeyDecMode << 4); 294 - pTable->KeyTable[j].wKeyCtl |= 0x0040; // use group key for group address 295 - uKeyIdx = (dwKeyIndex & 0x000000FF); 296 - } 297 - pTable->KeyTable[j].wKeyCtl |= 0x8000; // enable on-fly 298 - 299 - pKey->bKeyValid = true; 300 - pKey->uKeyLength = uKeyLength; 301 - pKey->dwKeyIndex = dwKeyIndex; 302 - pKey->byCipherSuite = byKeyDecMode; 303 - memcpy(pKey->abyKey, pbyKey, uKeyLength); 304 - if (byKeyDecMode == KEY_CTL_WEP) { 305 - if (uKeyLength == WLAN_WEP40_KEYLEN) 306 - pKey->abyKey[15] &= 0x7F; 307 - if (uKeyLength == WLAN_WEP104_KEYLEN) 308 - pKey->abyKey[15] |= 0x80; 309 - } 310 - 311 - vnt_mac_set_keyentry(pDevice, pTable->KeyTable[j].wKeyCtl, j, uKeyIdx, 312 - pbyBSSID, pKey->abyKey); 313 - 314 - if ((dwKeyIndex & USE_KEYRSC) == 0) 315 - pKey->KeyRSC = 0; /* RSC set by NIC */ 316 - else 317 - pKey->KeyRSC = *KeyRSC; 318 - 319 - pKey->dwTSC47_16 = 0; 320 - pKey->wTSC15_0 = 0; 321 - 322 - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"KeybSetKey(N): \n"); 323 - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->bKeyValid: %d\n ", pKey->bKeyValid); 324 - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->uKeyLength: %d\n ", (int)pKey->uKeyLength); 325 - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->abyKey: "); 326 - for (ii = 0; ii < pKey->uKeyLength; ii++) { 327 - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%02x ", pKey->abyKey[ii]); 328 - } 329 - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"\n"); 330 - 331 - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->dwTSC47_16: %x\n ", 332 - pKey->dwTSC47_16); 333 - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->wTSC15_0: %x\n ", pKey->wTSC15_0); 334 - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->dwKeyIndex: %x\n ", 335 - pKey->dwKeyIndex); 336 - 337 - return (true); 338 - } 339 - return (false); 340 - } 341 - 342 - /* 343 - * Description: Remove Key from table 344 - * 345 - * Parameters: 346 - * In: 347 - * pTable - Pointer to Key table 348 - * pbyBSSID - BSSID of Key 349 - * dwKeyIndex - Key Index (reference to NDIS DDK) 350 - * Out: 351 - * none 352 - * 353 - * Return Value: true if success otherwise false 354 - * 355 - */ 356 - 357 - int KeybRemoveKey(struct vnt_private *pDevice, PSKeyManagement pTable, 358 - u8 *pbyBSSID, u32 dwKeyIndex) 359 - { 360 - int i; 361 - int bReturnValue = false; 362 - 363 - if (is_broadcast_ether_addr(pbyBSSID)) { 364 - // delete all keys 365 - if ((dwKeyIndex & PAIRWISE_KEY) != 0) { 366 - for (i=0;i<MAX_KEY_TABLE;i++) { 367 - pTable->KeyTable[i].PairwiseKey.bKeyValid = false; 368 - } 369 - bReturnValue = true; 370 - } 371 - else if ((dwKeyIndex & 0x000000FF) < MAX_GROUP_KEY) { 372 - for (i=0;i<MAX_KEY_TABLE;i++) { 373 - pTable->KeyTable[i].GroupKey[dwKeyIndex & 0x000000FF].bKeyValid = false; 374 - if ((dwKeyIndex & 0x7FFFFFFF) == (pTable->KeyTable[i].dwGTKeyIndex & 0x7FFFFFFF)) { 375 - // remove Group transmit key 376 - pTable->KeyTable[i].dwGTKeyIndex = 0; 377 - } 378 - } 379 - bReturnValue = true; 380 - } 381 - else { 382 - bReturnValue = false; 383 - } 384 - 385 - } else { 386 - for (i=0;i<MAX_KEY_TABLE;i++) { 387 - if ( (pTable->KeyTable[i].bInUse == true) && 388 - ether_addr_equal(pTable->KeyTable[i].abyBSSID, pbyBSSID)) { 389 - 390 - if ((dwKeyIndex & PAIRWISE_KEY) != 0) { 391 - pTable->KeyTable[i].PairwiseKey.bKeyValid = false; 392 - bReturnValue = true; 393 - break; 394 - } 395 - else if ((dwKeyIndex & 0x000000FF) < MAX_GROUP_KEY) { 396 - pTable->KeyTable[i].GroupKey[dwKeyIndex & 0x000000FF].bKeyValid = false; 397 - if ((dwKeyIndex & 0x7FFFFFFF) == (pTable->KeyTable[i].dwGTKeyIndex & 0x7FFFFFFF)) { 398 - // remove Group transmit key 399 - pTable->KeyTable[i].dwGTKeyIndex = 0; 400 - } 401 - bReturnValue = true; 402 - break; 403 - } 404 - else { 405 - bReturnValue = false; 406 - break; 407 - } 408 - } //pTable->KeyTable[i].bInUse == true 409 - } //for 410 - bReturnValue = true; 411 - } 412 - 413 - s_vCheckKeyTableValid(pDevice,pTable); 414 - return bReturnValue; 415 - 416 - } 417 - 418 - /* 419 - * Description: Remove Key from table 420 - * 421 - * Parameters: 422 - * In: 423 - * pTable - Pointer to Key table 424 - * pbyBSSID - BSSID of Key 425 - * Out: 426 - * none 427 - * 428 - * Return Value: true if success otherwise false 429 - * 430 - */ 431 - int KeybRemoveAllKey(struct vnt_private *pDevice, PSKeyManagement pTable, 432 - u8 *pbyBSSID) 433 - { 434 - int i, u; 435 - 436 - for (i=0;i<MAX_KEY_TABLE;i++) { 437 - if ((pTable->KeyTable[i].bInUse == true) && 438 - ether_addr_equal(pTable->KeyTable[i].abyBSSID, pbyBSSID)) { 439 - pTable->KeyTable[i].PairwiseKey.bKeyValid = false; 440 - for (u = 0; u < MAX_GROUP_KEY; u++) 441 - pTable->KeyTable[i].GroupKey[u].bKeyValid = false; 442 - 443 - pTable->KeyTable[i].dwGTKeyIndex = 0; 444 - s_vCheckKeyTableValid(pDevice, pTable); 445 - return (true); 446 - } 447 - } 448 - return (false); 449 - } 450 - 451 - /* 452 - * Description: Get Transmit Key from table 453 - * 454 - * Parameters: 455 - * In: 456 - * pTable - Pointer to Key table 457 - * pbyBSSID - BSSID of Key 458 - * Out: 459 - * pKey - Key return 460 - * 461 - * Return Value: true if found otherwise false 462 - * 463 - */ 464 - int KeybGetTransmitKey(PSKeyManagement pTable, u8 *pbyBSSID, u32 dwKeyType, 465 - PSKeyItem *pKey) 466 - { 467 - int i, ii; 468 - 469 - *pKey = NULL; 470 - 471 - for (i = 0; i < MAX_KEY_TABLE; i++) { 472 - if ((pTable->KeyTable[i].bInUse == true) && 473 - ether_addr_equal(pTable->KeyTable[i].abyBSSID, pbyBSSID)) { 474 - 475 - if (dwKeyType == PAIRWISE_KEY) { 476 - 477 - if (pTable->KeyTable[i].PairwiseKey.bKeyValid == true) { 478 - *pKey = &(pTable->KeyTable[i].PairwiseKey); 479 - 480 - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"KeybGetTransmitKey:"); 481 - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"PAIRWISE_KEY: KeyTable.abyBSSID: "); 482 - for (ii = 0; ii < 6; ii++) { 483 - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"%x ", pTable->KeyTable[i].abyBSSID[ii]); 484 - } 485 - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"\n"); 486 - 487 - return (true); 488 - } 489 - else { 490 - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"PairwiseKey.bKeyValid == false\n"); 491 - return (false); 492 - } 493 - } // End of Type == PAIRWISE 494 - else { 495 - if (pTable->KeyTable[i].dwGTKeyIndex == 0) { 496 - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ERROR: dwGTKeyIndex == 0 !!!\n"); 497 - return false; 498 - } 499 - if (pTable->KeyTable[i].GroupKey[(pTable->KeyTable[i].dwGTKeyIndex&0x000000FF)].bKeyValid == true) { 500 - *pKey = &(pTable->KeyTable[i].GroupKey[(pTable->KeyTable[i].dwGTKeyIndex&0x000000FF)]); 501 - 502 - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"KeybGetTransmitKey:"); 503 - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"GROUP_KEY: KeyTable.abyBSSID\n"); 504 - for (ii = 0; ii < 6; ii++) { 505 - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"%x ", pTable->KeyTable[i].abyBSSID[ii]); 506 - } 507 - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"\n"); 508 - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"dwGTKeyIndex: %X\n", 509 - pTable->KeyTable[i].dwGTKeyIndex); 510 - 511 - return (true); 512 - } 513 - else { 514 - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"GroupKey.bKeyValid == false\n"); 515 - return (false); 516 - } 517 - } // End of Type = GROUP 518 - } // BSSID match 519 - } 520 - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ERROR: NO Match BSSID !!! "); 521 - for (ii = 0; ii < 6; ii++) { 522 - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"%02x ", *(pbyBSSID+ii)); 523 - } 524 - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"\n"); 525 - return (false); 526 - } 527 - 528 - /* 529 - * Description: Set Key to table 530 - * 531 - * Parameters: 532 - * In: 533 - * pTable - Pointer to Key table 534 - * dwKeyIndex - Key index (reference to NDIS DDK) 535 - * uKeyLength - Key length 536 - * KeyRSC - Key RSC 537 - * pbyKey - Pointer to key 538 - * Out: 539 - * none 540 - * 541 - * Return Value: true if success otherwise false 542 - * 543 - */ 544 - 545 - int KeybSetDefaultKey(struct vnt_private *pDevice, PSKeyManagement pTable, 546 - u32 dwKeyIndex, u32 uKeyLength, u64 *KeyRSC, u8 *pbyKey, 547 - u8 byKeyDecMode) 548 - { 549 - int ii; 550 - PSKeyItem pKey; 551 - u32 uKeyIdx; 552 - 553 - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Enter KeybSetDefaultKey: %1x, %d\n", 554 - (int) dwKeyIndex, (int) uKeyLength); 555 - 556 - if ((dwKeyIndex & PAIRWISE_KEY) != 0) { // Pairwise key 557 - return (false); 558 - } else if ((dwKeyIndex & 0x000000FF) >= MAX_GROUP_KEY) { 559 - return (false); 560 - } 561 - 562 - if (uKeyLength > MAX_KEY_LEN) 563 - return false; 564 - 565 - pTable->KeyTable[MAX_KEY_TABLE-1].bInUse = true; 566 - for (ii = 0; ii < ETH_ALEN; ii++) 567 - pTable->KeyTable[MAX_KEY_TABLE-1].abyBSSID[ii] = 0xFF; 568 - 569 - // Group key 570 - pKey = &(pTable->KeyTable[MAX_KEY_TABLE-1].GroupKey[dwKeyIndex & 0x000000FF]); 571 - if ((dwKeyIndex & TRANSMIT_KEY) != 0) { 572 - // Group transmit key 573 - pTable->KeyTable[MAX_KEY_TABLE-1].dwGTKeyIndex = dwKeyIndex; 574 - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO 575 - "Group transmit key(R)[%X]: %d\n", 576 - pTable->KeyTable[MAX_KEY_TABLE-1].dwGTKeyIndex, 577 - MAX_KEY_TABLE-1); 578 - 579 - } 580 - pTable->KeyTable[MAX_KEY_TABLE-1].wKeyCtl &= 0x7F00; // clear all key control filed 581 - pTable->KeyTable[MAX_KEY_TABLE-1].wKeyCtl |= (byKeyDecMode << 4); 582 - pTable->KeyTable[MAX_KEY_TABLE-1].wKeyCtl |= (byKeyDecMode); 583 - pTable->KeyTable[MAX_KEY_TABLE-1].wKeyCtl |= 0x0044; // use group key for all address 584 - uKeyIdx = (dwKeyIndex & 0x000000FF); 585 - 586 - if ((uKeyLength == WLAN_WEP232_KEYLEN) && 587 - (byKeyDecMode == KEY_CTL_WEP)) { 588 - pTable->KeyTable[MAX_KEY_TABLE-1].wKeyCtl |= 0x4000; // disable on-fly disable address match 589 - pTable->KeyTable[MAX_KEY_TABLE-1].bSoftWEP = true; 590 - } else { 591 - if (pTable->KeyTable[MAX_KEY_TABLE-1].bSoftWEP == false) 592 - pTable->KeyTable[MAX_KEY_TABLE-1].wKeyCtl |= 0xC000; // enable on-fly disable address match 593 - } 594 - 595 - pKey->bKeyValid = true; 596 - pKey->uKeyLength = uKeyLength; 597 - pKey->dwKeyIndex = dwKeyIndex; 598 - pKey->byCipherSuite = byKeyDecMode; 599 - memcpy(pKey->abyKey, pbyKey, uKeyLength); 600 - if (byKeyDecMode == KEY_CTL_WEP) { 601 - if (uKeyLength == WLAN_WEP40_KEYLEN) 602 - pKey->abyKey[15] &= 0x7F; 603 - if (uKeyLength == WLAN_WEP104_KEYLEN) 604 - pKey->abyKey[15] |= 0x80; 605 - } 606 - 607 - vnt_mac_set_keyentry(pDevice, pTable->KeyTable[MAX_KEY_TABLE-1].wKeyCtl, 608 - MAX_KEY_TABLE-1, uKeyIdx, 609 - pTable->KeyTable[MAX_KEY_TABLE-1].abyBSSID, pKey->abyKey); 610 - 611 - if ((dwKeyIndex & USE_KEYRSC) == 0) 612 - pKey->KeyRSC = 0; /* RSC set by NIC */ 613 - else 614 - pKey->KeyRSC = *KeyRSC; 615 - 616 - pKey->dwTSC47_16 = 0; 617 - pKey->wTSC15_0 = 0; 618 - 619 - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"KeybSetKey(R): \n"); 620 - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->bKeyValid: %d\n", pKey->bKeyValid); 621 - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->uKeyLength: %d\n", (int)pKey->uKeyLength); 622 - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->abyKey: \n"); 623 - for (ii = 0; ii < pKey->uKeyLength; ii++) { 624 - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"%x", pKey->abyKey[ii]); 625 - } 626 - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"\n"); 627 - 628 - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->dwTSC47_16: %x\n", 629 - pKey->dwTSC47_16); 630 - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->wTSC15_0: %x\n", pKey->wTSC15_0); 631 - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->dwKeyIndex: %x\n", 632 - pKey->dwKeyIndex); 633 - 634 - return (true); 635 - } 636 - 637 - /* 638 - * Description: Set Key to table 639 - * 640 - * Parameters: 641 - * In: 642 - * pTable - Pointer to Key table 643 - * dwKeyIndex - Key index (reference to NDIS DDK) 644 - * uKeyLength - Key length 645 - * KeyRSC - Key RSC 646 - * pbyKey - Pointer to key 647 - * Out: 648 - * none 649 - * 650 - * Return Value: true if success otherwise false 651 - * 652 - */ 653 - 654 - int KeybSetAllGroupKey(struct vnt_private *pDevice, PSKeyManagement pTable, 655 - u32 dwKeyIndex, u32 uKeyLength, u64 *KeyRSC, u8 *pbyKey, 656 - u8 byKeyDecMode) 657 - { 658 - int i, ii; 659 - PSKeyItem pKey; 660 - u32 uKeyIdx; 661 - 662 - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Enter KeybSetAllGroupKey: %X\n", 663 - dwKeyIndex); 664 - 665 - if ((dwKeyIndex & PAIRWISE_KEY) != 0) { // Pairwise key 666 - return (false); 667 - } else if ((dwKeyIndex & 0x000000FF) >= MAX_GROUP_KEY) { 668 - return (false); 669 - } 670 - 671 - for (i=0; i < MAX_KEY_TABLE-1; i++) { 672 - if (pTable->KeyTable[i].bInUse == true) { 673 - // found table already exist 674 - // Group key 675 - pKey = &(pTable->KeyTable[i].GroupKey[dwKeyIndex & 0x000000FF]); 676 - if ((dwKeyIndex & TRANSMIT_KEY) != 0) { 677 - // Group transmit key 678 - pTable->KeyTable[i].dwGTKeyIndex = dwKeyIndex; 679 - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO 680 - "Group transmit key(R)[%X]: %d\n", 681 - pTable->KeyTable[i].dwGTKeyIndex, i); 682 - 683 - } 684 - pTable->KeyTable[i].wKeyCtl &= 0xFF0F; // clear group key control filed 685 - pTable->KeyTable[i].wKeyCtl |= (byKeyDecMode << 4); 686 - pTable->KeyTable[i].wKeyCtl |= 0x0040; // use group key for group address 687 - uKeyIdx = (dwKeyIndex & 0x000000FF); 688 - 689 - pTable->KeyTable[i].wKeyCtl |= 0x8000; // enable on-fly 690 - 691 - pKey->bKeyValid = true; 692 - pKey->uKeyLength = uKeyLength; 693 - pKey->dwKeyIndex = dwKeyIndex; 694 - pKey->byCipherSuite = byKeyDecMode; 695 - memcpy(pKey->abyKey, pbyKey, uKeyLength); 696 - if (byKeyDecMode == KEY_CTL_WEP) { 697 - if (uKeyLength == WLAN_WEP40_KEYLEN) 698 - pKey->abyKey[15] &= 0x7F; 699 - if (uKeyLength == WLAN_WEP104_KEYLEN) 700 - pKey->abyKey[15] |= 0x80; 701 - } 702 - 703 - vnt_mac_set_keyentry(pDevice, pTable->KeyTable[i].wKeyCtl, i, 704 - uKeyIdx, pTable->KeyTable[i].abyBSSID, pKey->abyKey); 705 - 706 - if ((dwKeyIndex & USE_KEYRSC) == 0) 707 - pKey->KeyRSC = 0; /* RSC set by NIC */ 708 - else 709 - pKey->KeyRSC = *KeyRSC; 710 - 711 - pKey->dwTSC47_16 = 0; 712 - pKey->wTSC15_0 = 0; 713 - 714 - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"KeybSetKey(R): \n"); 715 - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->bKeyValid: %d\n ", pKey->bKeyValid); 716 - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->uKeyLength: %d\n ", (int)pKey->uKeyLength); 717 - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->abyKey: "); 718 - for (ii = 0; ii < pKey->uKeyLength; ii++) { 719 - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"%02x ", pKey->abyKey[ii]); 720 - } 721 - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"\n"); 722 - 723 - //DBG_PRN_GRP12(("pKey->dwTSC47_16: %lX\n ", pKey->dwTSC47_16)); 724 - //DBG_PRN_GRP12(("pKey->wTSC15_0: %X\n ", pKey->wTSC15_0)); 725 - //DBG_PRN_GRP12(("pKey->dwKeyIndex: %lX\n ", pKey->dwKeyIndex)); 726 - 727 - } // (pTable->KeyTable[i].bInUse == true) 728 - } 729 - return (true); 730 - } 731 37 732 38 int vnt_key_init_table(struct vnt_private *priv) 733 39 {
-69
drivers/staging/vt6656/key.h
··· 32 32 33 33 #include "device.h" 34 34 35 - #define MAX_GROUP_KEY 4 36 35 #define MAX_KEY_TABLE 11 37 - #define MAX_KEY_LEN 32 38 - #define AES_KEY_LEN 16 39 - 40 - #define AUTHENTICATOR_KEY 0x10000000 41 - #define USE_KEYRSC 0x20000000 42 - #define PAIRWISE_KEY 0x40000000 43 - #define TRANSMIT_KEY 0x80000000 44 - 45 - #define GROUP_KEY 0x00000000 46 36 47 37 #define KEY_CTL_WEP 0x00 48 38 #define KEY_CTL_NONE 0x01 49 39 #define KEY_CTL_TKIP 0x02 50 40 #define KEY_CTL_CCMP 0x03 51 - #define KEY_CTL_INVALID 0xFF 52 41 53 42 #define VNT_KEY_DEFAULTKEY 0x1 54 43 #define VNT_KEY_GROUP_ADDRESS 0x2 ··· 46 57 #define VNT_KEY_PAIRWISE 0x00 47 58 #define VNT_KEY_ONFLY 0x8000 48 59 #define VNT_KEY_ONFLY_ALL 0x4000 49 - 50 - typedef struct tagSKeyItem 51 - { 52 - bool bKeyValid; 53 - u32 uKeyLength; 54 - u8 abyKey[MAX_KEY_LEN]; 55 - u64 KeyRSC; 56 - u32 dwTSC47_16; 57 - u16 wTSC15_0; 58 - u8 byCipherSuite; 59 - u8 byReserved0; 60 - u32 dwKeyIndex; 61 - void *pvKeyTable; 62 - } SKeyItem, *PSKeyItem; //64 63 - 64 - typedef struct tagSKeyTable 65 - { 66 - u8 abyBSSID[ETH_ALEN]; /* 6 */ 67 - u8 byReserved0[2]; //8 68 - SKeyItem PairwiseKey; 69 - SKeyItem GroupKey[MAX_GROUP_KEY]; //64*5 = 320, 320+8=328 70 - u32 dwGTKeyIndex; // GroupTransmitKey Index 71 - bool bInUse; 72 - u16 wKeyCtl; 73 - bool bSoftWEP; 74 - u8 byReserved1[6]; 75 - } SKeyTable, *PSKeyTable; //352 76 - 77 - typedef struct tagSKeyManagement 78 - { 79 - SKeyTable KeyTable[MAX_KEY_TABLE]; 80 - } SKeyManagement, *PSKeyManagement; 81 - 82 - void KeyvInitTable(struct vnt_private *, PSKeyManagement pTable); 83 - 84 - int KeybGetKey(PSKeyManagement pTable, u8 *pbyBSSID, u32 dwKeyIndex, 85 - PSKeyItem *pKey); 86 - 87 - int KeybSetKey(struct vnt_private *, PSKeyManagement pTable, u8 *pbyBSSID, 88 - u32 dwKeyIndex, u32 uKeyLength, u64 *KeyRSC, u8 *pbyKey, 89 - u8 byKeyDecMode); 90 - 91 - int KeybRemoveKey(struct vnt_private *, PSKeyManagement pTable, 92 - u8 *pbyBSSID, u32 dwKeyIndex); 93 - 94 - int KeybRemoveAllKey(struct vnt_private *, PSKeyManagement pTable, 95 - u8 *pbyBSSID); 96 - 97 - int KeybGetTransmitKey(PSKeyManagement pTable, u8 *pbyBSSID, u32 dwKeyType, 98 - PSKeyItem *pKey); 99 - 100 - int KeybSetDefaultKey(struct vnt_private *, PSKeyManagement pTable, 101 - u32 dwKeyIndex, u32 uKeyLength, u64 *KeyRSC, u8 *pbyKey, 102 - u8 byKeyDecMode); 103 - 104 - int KeybSetAllGroupKey(struct vnt_private *, PSKeyManagement pTable, 105 - u32 dwKeyIndex, u32 uKeyLength, u64 *KeyRSC, u8 *pbyKey, 106 - u8 byKeyDecMode); 107 60 108 61 int vnt_key_init_table(struct vnt_private *); 109 62
-4
drivers/staging/vt6656/wcmd.c
··· 139 139 } 140 140 break; 141 141 142 - case WLAN_CMD_REMOVE_ALLKEY_START: 143 - KeybRemoveAllKey(pDevice, &(pDevice->sKey), pDevice->abyBSSID); 144 - break; 145 - 146 142 case WLAN_CMD_MAC_DISPOWERSAVING_START: 147 143 vnt_control_in_u8(pDevice, MESSAGE_REQUEST_MACREG, MAC_REG_PSCTL, &byData); 148 144 if ((byData & PSCTL_PS) != 0) {