key.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. /*
  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. #ifndef __KEY_H__
  30. #define __KEY_H__
  31. #include "ttype.h"
  32. #include "tether.h"
  33. #include "80211mgr.h"
  34. /*--------------------- Export Definitions -------------------------*/
  35. #define MAX_GROUP_KEY 4
  36. #define MAX_KEY_TABLE 11
  37. #define MAX_KEY_LEN 32
  38. #define AES_KEY_LEN 16
  39. #define AUTHENTICATOR_KEY 0x10000000
  40. #define USE_KEYRSC 0x20000000
  41. #define PAIRWISE_KEY 0x40000000
  42. #define TRANSMIT_KEY 0x80000000
  43. #define GROUP_KEY 0x00000000
  44. #define KEY_CTL_WEP 0x00
  45. #define KEY_CTL_NONE 0x01
  46. #define KEY_CTL_TKIP 0x02
  47. #define KEY_CTL_CCMP 0x03
  48. #define KEY_CTL_INVALID 0xFF
  49. typedef struct tagSKeyItem
  50. {
  51. BOOL bKeyValid;
  52. unsigned long uKeyLength;
  53. BYTE abyKey[MAX_KEY_LEN];
  54. QWORD KeyRSC;
  55. DWORD dwTSC47_16;
  56. WORD wTSC15_0;
  57. BYTE byCipherSuite;
  58. BYTE byReserved0;
  59. DWORD dwKeyIndex;
  60. void *pvKeyTable;
  61. } SKeyItem, *PSKeyItem; //64
  62. typedef struct tagSKeyTable
  63. {
  64. BYTE abyBSSID[ETH_ALEN]; /* 6 */
  65. BYTE byReserved0[2]; //8
  66. SKeyItem PairwiseKey;
  67. SKeyItem GroupKey[MAX_GROUP_KEY]; //64*5 = 320, 320+8=328
  68. DWORD dwGTKeyIndex; // GroupTransmitKey Index
  69. BOOL bInUse;
  70. WORD wKeyCtl;
  71. BOOL bSoftWEP;
  72. BYTE byReserved1[6];
  73. } SKeyTable, *PSKeyTable; //352
  74. typedef struct tagSKeyManagement
  75. {
  76. SKeyTable KeyTable[MAX_KEY_TABLE];
  77. } SKeyManagement, *PSKeyManagement;
  78. /*--------------------- Export Types ------------------------------*/
  79. /*--------------------- Export Macros ------------------------------*/
  80. /*--------------------- Export Classes ----------------------------*/
  81. /*--------------------- Export Variables --------------------------*/
  82. /*--------------------- Export Functions --------------------------*/
  83. void KeyvInitTable(void *pDeviceHandler, PSKeyManagement pTable);
  84. BOOL KeybGetKey(PSKeyManagement pTable, PBYTE pbyBSSID, DWORD dwKeyIndex,
  85. PSKeyItem *pKey);
  86. BOOL KeybSetKey(
  87. void *pDeviceHandler,
  88. PSKeyManagement pTable,
  89. PBYTE pbyBSSID,
  90. DWORD dwKeyIndex,
  91. unsigned long uKeyLength,
  92. PQWORD pKeyRSC,
  93. PBYTE pbyKey,
  94. BYTE byKeyDecMode
  95. );
  96. BOOL KeybRemoveKey(
  97. void *pDeviceHandler,
  98. PSKeyManagement pTable,
  99. PBYTE pbyBSSID,
  100. DWORD dwKeyIndex
  101. );
  102. BOOL KeybRemoveAllKey(
  103. void *pDeviceHandler,
  104. PSKeyManagement pTable,
  105. PBYTE pbyBSSID
  106. );
  107. void KeyvRemoveWEPKey(
  108. void *pDeviceHandler,
  109. PSKeyManagement pTable,
  110. DWORD dwKeyIndex
  111. );
  112. void KeyvRemoveAllWEPKey(
  113. void *pDeviceHandler,
  114. PSKeyManagement pTable
  115. );
  116. BOOL KeybGetTransmitKey(PSKeyManagement pTable, PBYTE pbyBSSID, DWORD dwKeyType,
  117. PSKeyItem *pKey);
  118. BOOL KeybCheckPairewiseKey(PSKeyManagement pTable, PSKeyItem *pKey);
  119. BOOL KeybSetDefaultKey(
  120. void *pDeviceHandler,
  121. PSKeyManagement pTable,
  122. DWORD dwKeyIndex,
  123. unsigned long uKeyLength,
  124. PQWORD pKeyRSC,
  125. PBYTE pbyKey,
  126. BYTE byKeyDecMode
  127. );
  128. BOOL KeybSetAllGroupKey(
  129. void *pDeviceHandler,
  130. PSKeyManagement pTable,
  131. DWORD dwKeyIndex,
  132. unsigned long uKeyLength,
  133. PQWORD pKeyRSC,
  134. PBYTE pbyKey,
  135. BYTE byKeyDecMode
  136. );
  137. #endif /* __KEY_H__ */