Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 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 | |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 30 | #ifndef __KEY_H__ |
| 31 | #define __KEY_H__ |
| 32 | |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 33 | #include "ttype.h" |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 34 | #include "tether.h" |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 35 | #include "80211mgr.h" |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 36 | |
| 37 | /*--------------------- Export Definitions -------------------------*/ |
| 38 | #define MAX_GROUP_KEY 4 |
| 39 | #define MAX_KEY_TABLE 11 |
| 40 | #define MAX_KEY_LEN 32 |
| 41 | #define AES_KEY_LEN 16 |
| 42 | |
| 43 | |
| 44 | #define AUTHENTICATOR_KEY 0x10000000 |
| 45 | #define USE_KEYRSC 0x20000000 |
| 46 | #define PAIRWISE_KEY 0x40000000 |
| 47 | #define TRANSMIT_KEY 0x80000000 |
| 48 | |
| 49 | #define GROUP_KEY 0x00000000 |
| 50 | |
| 51 | #define KEY_CTL_WEP 0x00 |
| 52 | #define KEY_CTL_NONE 0x01 |
| 53 | #define KEY_CTL_TKIP 0x02 |
| 54 | #define KEY_CTL_CCMP 0x03 |
| 55 | #define KEY_CTL_INVALID 0xFF |
| 56 | |
| 57 | |
| 58 | typedef struct tagSKeyItem |
| 59 | { |
Charles Clément | 7b6a001 | 2010-08-01 17:15:50 +0200 | [diff] [blame] | 60 | bool bKeyValid; |
Charles Clément | e3fd16d | 2010-06-02 09:52:02 -0700 | [diff] [blame] | 61 | unsigned long uKeyLength; |
Charles Clément | 3fc9b58 | 2010-06-24 11:02:27 -0700 | [diff] [blame] | 62 | unsigned char abyKey[MAX_KEY_LEN]; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 63 | QWORD KeyRSC; |
Charles Clément | 0f4c60d | 2010-06-24 11:02:25 -0700 | [diff] [blame] | 64 | unsigned long dwTSC47_16; |
Charles Clément | 2986db5 | 2010-06-24 11:02:26 -0700 | [diff] [blame] | 65 | unsigned short wTSC15_0; |
Charles Clément | 3fc9b58 | 2010-06-24 11:02:27 -0700 | [diff] [blame] | 66 | unsigned char byCipherSuite; |
| 67 | unsigned char byReserved0; |
Charles Clément | 0f4c60d | 2010-06-24 11:02:25 -0700 | [diff] [blame] | 68 | unsigned long dwKeyIndex; |
Charles Clément | 830a619 | 2010-05-07 12:30:20 -0700 | [diff] [blame] | 69 | void *pvKeyTable; |
Jim Lieb | a884847 | 2009-08-12 14:54:07 -0700 | [diff] [blame] | 70 | } SKeyItem, *PSKeyItem; //64 |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 71 | |
| 72 | typedef struct tagSKeyTable |
| 73 | { |
Charles Clément | 3fc9b58 | 2010-06-24 11:02:27 -0700 | [diff] [blame] | 74 | unsigned char abyBSSID[ETH_ALEN]; //6 |
| 75 | unsigned char byReserved0[2]; //8 |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 76 | SKeyItem PairwiseKey; |
| 77 | SKeyItem GroupKey[MAX_GROUP_KEY]; //64*5 = 320, 320+8=328 |
Charles Clément | 0f4c60d | 2010-06-24 11:02:25 -0700 | [diff] [blame] | 78 | unsigned long dwGTKeyIndex; // GroupTransmitKey Index |
Charles Clément | 7b6a001 | 2010-08-01 17:15:50 +0200 | [diff] [blame] | 79 | bool bInUse; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 80 | //2006-1116-01,<Modify> by NomadZhao |
Charles Clément | 2986db5 | 2010-06-24 11:02:26 -0700 | [diff] [blame] | 81 | //unsigned short wKeyCtl; |
Charles Clément | 7b6a001 | 2010-08-01 17:15:50 +0200 | [diff] [blame] | 82 | //bool bSoftWEP; |
| 83 | bool bSoftWEP; |
Charles Clément | 2986db5 | 2010-06-24 11:02:26 -0700 | [diff] [blame] | 84 | unsigned short wKeyCtl; // for address of wKeyCtl at align 4 |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 85 | |
Charles Clément | 3fc9b58 | 2010-06-24 11:02:27 -0700 | [diff] [blame] | 86 | unsigned char byReserved1[6]; |
Jim Lieb | a884847 | 2009-08-12 14:54:07 -0700 | [diff] [blame] | 87 | } SKeyTable, *PSKeyTable; //348 |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 88 | |
| 89 | typedef struct tagSKeyManagement |
| 90 | { |
| 91 | SKeyTable KeyTable[MAX_KEY_TABLE]; |
Jim Lieb | a884847 | 2009-08-12 14:54:07 -0700 | [diff] [blame] | 92 | } SKeyManagement, * PSKeyManagement; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 93 | |
| 94 | /*--------------------- Export Types ------------------------------*/ |
| 95 | |
| 96 | /*--------------------- Export Macros ------------------------------*/ |
| 97 | |
| 98 | /*--------------------- Export Classes ----------------------------*/ |
| 99 | |
| 100 | /*--------------------- Export Variables --------------------------*/ |
| 101 | |
| 102 | /*--------------------- Export Functions --------------------------*/ |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 103 | |
Charles Clément | 412b2d0 | 2010-06-22 08:54:42 -0700 | [diff] [blame] | 104 | void KeyvInitTable(PSKeyManagement pTable, unsigned long dwIoBase); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 105 | |
Charles Clément | 7b6a001 | 2010-08-01 17:15:50 +0200 | [diff] [blame] | 106 | bool KeybGetKey( |
Charles Clément | 3a215e0 | 2010-05-12 20:54:39 -0700 | [diff] [blame] | 107 | PSKeyManagement pTable, |
Charles Clément | 2989e96 | 2010-06-05 15:13:47 -0700 | [diff] [blame] | 108 | unsigned char *pbyBSSID, |
Charles Clément | 0f4c60d | 2010-06-24 11:02:25 -0700 | [diff] [blame] | 109 | unsigned long dwKeyIndex, |
Charles Clément | 3cdec55 | 2010-05-12 20:54:40 -0700 | [diff] [blame] | 110 | PSKeyItem *pKey |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 111 | ); |
| 112 | |
Charles Clément | 7b6a001 | 2010-08-01 17:15:50 +0200 | [diff] [blame] | 113 | bool KeybSetKey( |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 114 | PSKeyManagement pTable, |
Charles Clément | 2989e96 | 2010-06-05 15:13:47 -0700 | [diff] [blame] | 115 | unsigned char *pbyBSSID, |
Charles Clément | 0f4c60d | 2010-06-24 11:02:25 -0700 | [diff] [blame] | 116 | unsigned long dwKeyIndex, |
Charles Clément | e3fd16d | 2010-06-02 09:52:02 -0700 | [diff] [blame] | 117 | unsigned long uKeyLength, |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 118 | PQWORD pKeyRSC, |
Charles Clément | 2989e96 | 2010-06-05 15:13:47 -0700 | [diff] [blame] | 119 | unsigned char *pbyKey, |
Charles Clément | 3fc9b58 | 2010-06-24 11:02:27 -0700 | [diff] [blame] | 120 | unsigned char byKeyDecMode, |
Charles Clément | 412b2d0 | 2010-06-22 08:54:42 -0700 | [diff] [blame] | 121 | unsigned long dwIoBase, |
Charles Clément | 3fc9b58 | 2010-06-24 11:02:27 -0700 | [diff] [blame] | 122 | unsigned char byLocalID |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 123 | ); |
| 124 | |
Charles Clément | 7b6a001 | 2010-08-01 17:15:50 +0200 | [diff] [blame] | 125 | bool KeybSetDefaultKey( |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 126 | PSKeyManagement pTable, |
Charles Clément | 0f4c60d | 2010-06-24 11:02:25 -0700 | [diff] [blame] | 127 | unsigned long dwKeyIndex, |
Charles Clément | e3fd16d | 2010-06-02 09:52:02 -0700 | [diff] [blame] | 128 | unsigned long uKeyLength, |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 129 | PQWORD pKeyRSC, |
Charles Clément | 2989e96 | 2010-06-05 15:13:47 -0700 | [diff] [blame] | 130 | unsigned char *pbyKey, |
Charles Clément | 3fc9b58 | 2010-06-24 11:02:27 -0700 | [diff] [blame] | 131 | unsigned char byKeyDecMode, |
Charles Clément | 412b2d0 | 2010-06-22 08:54:42 -0700 | [diff] [blame] | 132 | unsigned long dwIoBase, |
Charles Clément | 3fc9b58 | 2010-06-24 11:02:27 -0700 | [diff] [blame] | 133 | unsigned char byLocalID |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 134 | ); |
| 135 | |
Charles Clément | 7b6a001 | 2010-08-01 17:15:50 +0200 | [diff] [blame] | 136 | bool KeybRemoveKey( |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 137 | PSKeyManagement pTable, |
Charles Clément | 2989e96 | 2010-06-05 15:13:47 -0700 | [diff] [blame] | 138 | unsigned char *pbyBSSID, |
Charles Clément | 0f4c60d | 2010-06-24 11:02:25 -0700 | [diff] [blame] | 139 | unsigned long dwKeyIndex, |
Charles Clément | 412b2d0 | 2010-06-22 08:54:42 -0700 | [diff] [blame] | 140 | unsigned long dwIoBase |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 141 | ); |
| 142 | |
Charles Clément | 7b6a001 | 2010-08-01 17:15:50 +0200 | [diff] [blame] | 143 | bool KeybGetTransmitKey( |
Charles Clément | 3a215e0 | 2010-05-12 20:54:39 -0700 | [diff] [blame] | 144 | PSKeyManagement pTable, |
Charles Clément | 2989e96 | 2010-06-05 15:13:47 -0700 | [diff] [blame] | 145 | unsigned char *pbyBSSID, |
Charles Clément | 0f4c60d | 2010-06-24 11:02:25 -0700 | [diff] [blame] | 146 | unsigned long dwKeyType, |
Charles Clément | 3cdec55 | 2010-05-12 20:54:40 -0700 | [diff] [blame] | 147 | PSKeyItem *pKey |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 148 | ); |
| 149 | |
Charles Clément | 7b6a001 | 2010-08-01 17:15:50 +0200 | [diff] [blame] | 150 | bool KeybCheckPairewiseKey( |
Charles Clément | 3a215e0 | 2010-05-12 20:54:39 -0700 | [diff] [blame] | 151 | PSKeyManagement pTable, |
Charles Clément | 3cdec55 | 2010-05-12 20:54:40 -0700 | [diff] [blame] | 152 | PSKeyItem *pKey |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 153 | ); |
| 154 | |
Charles Clément | 7b6a001 | 2010-08-01 17:15:50 +0200 | [diff] [blame] | 155 | bool KeybRemoveAllKey( |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 156 | PSKeyManagement pTable, |
Charles Clément | 2989e96 | 2010-06-05 15:13:47 -0700 | [diff] [blame] | 157 | unsigned char *pbyBSSID, |
Charles Clément | 412b2d0 | 2010-06-22 08:54:42 -0700 | [diff] [blame] | 158 | unsigned long dwIoBase |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 159 | ); |
| 160 | |
Charles Clément | 6b35b7b | 2010-05-07 12:30:19 -0700 | [diff] [blame] | 161 | void KeyvRemoveWEPKey( |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 162 | PSKeyManagement pTable, |
Charles Clément | 0f4c60d | 2010-06-24 11:02:25 -0700 | [diff] [blame] | 163 | unsigned long dwKeyIndex, |
Charles Clément | 412b2d0 | 2010-06-22 08:54:42 -0700 | [diff] [blame] | 164 | unsigned long dwIoBase |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 165 | ); |
| 166 | |
Charles Clément | 6b35b7b | 2010-05-07 12:30:19 -0700 | [diff] [blame] | 167 | void KeyvRemoveAllWEPKey( |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 168 | PSKeyManagement pTable, |
Charles Clément | 412b2d0 | 2010-06-22 08:54:42 -0700 | [diff] [blame] | 169 | unsigned long dwIoBase |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 170 | ); |
| 171 | |
Charles Clément | 7b6a001 | 2010-08-01 17:15:50 +0200 | [diff] [blame] | 172 | bool KeybSetAllGroupKey ( |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 173 | PSKeyManagement pTable, |
Charles Clément | 0f4c60d | 2010-06-24 11:02:25 -0700 | [diff] [blame] | 174 | unsigned long dwKeyIndex, |
Charles Clément | e3fd16d | 2010-06-02 09:52:02 -0700 | [diff] [blame] | 175 | unsigned long uKeyLength, |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 176 | PQWORD pKeyRSC, |
Charles Clément | 2989e96 | 2010-06-05 15:13:47 -0700 | [diff] [blame] | 177 | unsigned char *pbyKey, |
Charles Clément | 3fc9b58 | 2010-06-24 11:02:27 -0700 | [diff] [blame] | 178 | unsigned char byKeyDecMode, |
Charles Clément | 412b2d0 | 2010-06-22 08:54:42 -0700 | [diff] [blame] | 179 | unsigned long dwIoBase, |
Charles Clément | 3fc9b58 | 2010-06-24 11:02:27 -0700 | [diff] [blame] | 180 | unsigned char byLocalID |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 181 | ); |
| 182 | |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 183 | #endif // __KEY_H__ |
| 184 | |