key.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  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. unsigned char abyKey[MAX_KEY_LEN];
  54. QWORD KeyRSC;
  55. unsigned long dwTSC47_16;
  56. unsigned short wTSC15_0;
  57. unsigned char byCipherSuite;
  58. unsigned char byReserved0;
  59. unsigned long dwKeyIndex;
  60. void *pvKeyTable;
  61. } SKeyItem, *PSKeyItem; //64
  62. typedef struct tagSKeyTable
  63. {
  64. unsigned char abyBSSID[ETH_ALEN]; //6
  65. unsigned char byReserved0[2]; //8
  66. SKeyItem PairwiseKey;
  67. SKeyItem GroupKey[MAX_GROUP_KEY]; //64*5 = 320, 320+8=328
  68. unsigned long dwGTKeyIndex; // GroupTransmitKey Index
  69. bool bInUse;
  70. //2006-1116-01,<Modify> by NomadZhao
  71. //unsigned short wKeyCtl;
  72. //bool bSoftWEP;
  73. bool bSoftWEP;
  74. unsigned short wKeyCtl; // for address of wKeyCtl at align 4
  75. unsigned char byReserved1[6];
  76. } SKeyTable, *PSKeyTable; //348
  77. typedef struct tagSKeyManagement
  78. {
  79. SKeyTable KeyTable[MAX_KEY_TABLE];
  80. } SKeyManagement, * PSKeyManagement;
  81. /*--------------------- Export Types ------------------------------*/
  82. /*--------------------- Export Macros ------------------------------*/
  83. /*--------------------- Export Classes ----------------------------*/
  84. /*--------------------- Export Variables --------------------------*/
  85. /*--------------------- Export Functions --------------------------*/
  86. void KeyvInitTable(PSKeyManagement pTable, unsigned long dwIoBase);
  87. bool KeybGetKey(
  88. PSKeyManagement pTable,
  89. unsigned char *pbyBSSID,
  90. unsigned long dwKeyIndex,
  91. PSKeyItem *pKey
  92. );
  93. bool KeybSetKey(
  94. PSKeyManagement pTable,
  95. unsigned char *pbyBSSID,
  96. unsigned long dwKeyIndex,
  97. unsigned long uKeyLength,
  98. PQWORD pKeyRSC,
  99. unsigned char *pbyKey,
  100. unsigned char byKeyDecMode,
  101. unsigned long dwIoBase,
  102. unsigned char byLocalID
  103. );
  104. bool KeybSetDefaultKey(
  105. PSKeyManagement pTable,
  106. unsigned long dwKeyIndex,
  107. unsigned long uKeyLength,
  108. PQWORD pKeyRSC,
  109. unsigned char *pbyKey,
  110. unsigned char byKeyDecMode,
  111. unsigned long dwIoBase,
  112. unsigned char byLocalID
  113. );
  114. bool KeybRemoveKey(
  115. PSKeyManagement pTable,
  116. unsigned char *pbyBSSID,
  117. unsigned long dwKeyIndex,
  118. unsigned long dwIoBase
  119. );
  120. bool KeybGetTransmitKey(
  121. PSKeyManagement pTable,
  122. unsigned char *pbyBSSID,
  123. unsigned long dwKeyType,
  124. PSKeyItem *pKey
  125. );
  126. bool KeybCheckPairewiseKey(
  127. PSKeyManagement pTable,
  128. PSKeyItem *pKey
  129. );
  130. bool KeybRemoveAllKey(
  131. PSKeyManagement pTable,
  132. unsigned char *pbyBSSID,
  133. unsigned long dwIoBase
  134. );
  135. void KeyvRemoveWEPKey(
  136. PSKeyManagement pTable,
  137. unsigned long dwKeyIndex,
  138. unsigned long dwIoBase
  139. );
  140. void KeyvRemoveAllWEPKey(
  141. PSKeyManagement pTable,
  142. unsigned long dwIoBase
  143. );
  144. bool KeybSetAllGroupKey (
  145. PSKeyManagement pTable,
  146. unsigned long dwKeyIndex,
  147. unsigned long uKeyLength,
  148. PQWORD pKeyRSC,
  149. unsigned char *pbyKey,
  150. unsigned char byKeyDecMode,
  151. unsigned long dwIoBase,
  152. unsigned char byLocalID
  153. );
  154. #endif // __KEY_H__