Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 1 | /* |
| 2 | ************************************************************************* |
| 3 | * Ralink Tech Inc. |
| 4 | * 5F., No.36, Taiyuan St., Jhubei City, |
| 5 | * Hsinchu County 302, |
| 6 | * Taiwan, R.O.C. |
| 7 | * |
| 8 | * (c) Copyright 2002-2007, Ralink Technology, Inc. |
| 9 | * |
| 10 | * This program is free software; you can redistribute it and/or modify * |
| 11 | * it under the terms of the GNU General Public License as published by * |
| 12 | * the Free Software Foundation; either version 2 of the License, or * |
| 13 | * (at your option) any later version. * |
| 14 | * * |
| 15 | * This program is distributed in the hope that it will be useful, * |
| 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
| 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
| 18 | * GNU General Public License for more details. * |
| 19 | * * |
| 20 | * You should have received a copy of the GNU General Public License * |
| 21 | * along with this program; if not, write to the * |
| 22 | * Free Software Foundation, Inc., * |
| 23 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
| 24 | * * |
| 25 | ************************************************************************* |
| 26 | |
| 27 | Module Name: |
| 28 | wpa.h |
| 29 | |
| 30 | Abstract: |
| 31 | |
| 32 | Revision History: |
| 33 | Who When What |
| 34 | -------- ---------- ---------------------------------------------- |
| 35 | Name Date Modification logs |
| 36 | */ |
| 37 | |
| 38 | #ifndef __WPA_H__ |
| 39 | #define __WPA_H__ |
| 40 | |
Bartlomiej Zolnierkiewicz | cc27706 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 41 | /* EAPOL Key descripter frame format related length */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 42 | #define LEN_KEY_DESC_NONCE 32 |
| 43 | #define LEN_KEY_DESC_IV 16 |
| 44 | #define LEN_KEY_DESC_RSC 8 |
| 45 | #define LEN_KEY_DESC_ID 8 |
| 46 | #define LEN_KEY_DESC_REPLAY 8 |
| 47 | #define LEN_KEY_DESC_MIC 16 |
| 48 | |
Bartlomiej Zolnierkiewicz | cc27706 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 49 | /* The length is the EAPoL-Key frame except key data field. */ |
| 50 | /* Please refer to 802.11i-2004 ,Figure 43u in p.78 */ |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 51 | #define LEN_EAPOL_KEY_MSG (sizeof(struct rt_key_descripter) - MAX_LEN_OF_RSNIE) |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 52 | |
Bartlomiej Zolnierkiewicz | cc27706 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 53 | /* EAP Code Type. */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 54 | #define EAP_CODE_REQUEST 1 |
| 55 | #define EAP_CODE_RESPONSE 2 |
| 56 | #define EAP_CODE_SUCCESS 3 |
| 57 | #define EAP_CODE_FAILURE 4 |
| 58 | |
Bartlomiej Zolnierkiewicz | cc27706 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 59 | /* EAPOL frame Protocol Version */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 60 | #define EAPOL_VER 1 |
| 61 | #define EAPOL_VER2 2 |
| 62 | |
Bartlomiej Zolnierkiewicz | cc27706 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 63 | /* EAPOL-KEY Descriptor Type */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 64 | #define WPA1_KEY_DESC 0xfe |
| 65 | #define WPA2_KEY_DESC 0x02 |
| 66 | |
Bartlomiej Zolnierkiewicz | cc27706 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 67 | /* Key Descriptor Version of Key Information */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 68 | #define DESC_TYPE_TKIP 1 |
| 69 | #define DESC_TYPE_AES 2 |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 70 | |
| 71 | #define LEN_MSG1_2WAY 0x7f |
| 72 | #define MAX_LEN_OF_EAP_HS 256 |
| 73 | |
| 74 | #define LEN_MASTER_KEY 32 |
| 75 | |
Bartlomiej Zolnierkiewicz | cc27706 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 76 | /* EAPOL EK, MK */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 77 | #define LEN_EAP_EK 16 |
| 78 | #define LEN_EAP_MICK 16 |
| 79 | #define LEN_EAP_KEY ((LEN_EAP_EK)+(LEN_EAP_MICK)) |
Bartlomiej Zolnierkiewicz | cc27706 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 80 | /* TKIP key related */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 81 | #define LEN_PMKID 16 |
| 82 | #define LEN_TKIP_EK 16 |
| 83 | #define LEN_TKIP_RXMICK 8 |
| 84 | #define LEN_TKIP_TXMICK 8 |
| 85 | #define LEN_AES_EK 16 |
| 86 | #define LEN_AES_KEY LEN_AES_EK |
| 87 | #define LEN_TKIP_KEY ((LEN_TKIP_EK)+(LEN_TKIP_RXMICK)+(LEN_TKIP_TXMICK)) |
| 88 | #define TKIP_AP_TXMICK_OFFSET ((LEN_EAP_KEY)+(LEN_TKIP_EK)) |
| 89 | #define TKIP_AP_RXMICK_OFFSET (TKIP_AP_TXMICK_OFFSET+LEN_TKIP_TXMICK) |
| 90 | #define TKIP_GTK_LENGTH ((LEN_TKIP_EK)+(LEN_TKIP_RXMICK)+(LEN_TKIP_TXMICK)) |
| 91 | #define LEN_PTK ((LEN_EAP_KEY)+(LEN_TKIP_KEY)) |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 92 | #define MIN_LEN_OF_GTK 5 |
| 93 | #define LEN_PMK 32 |
| 94 | #define LEN_PMK_NAME 16 |
| 95 | #define LEN_NONCE 32 |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 96 | |
Bartlomiej Zolnierkiewicz | cc27706 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 97 | /* RSN IE Length definition */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 98 | #define MAX_LEN_OF_RSNIE 255 |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 99 | #define MIN_LEN_OF_RSNIE 8 |
| 100 | |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 101 | #define KEY_LIFETIME 3600 |
| 102 | |
Bartlomiej Zolnierkiewicz | cc27706 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 103 | /*EAP Packet Type */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 104 | #define EAPPacket 0 |
| 105 | #define EAPOLStart 1 |
| 106 | #define EAPOLLogoff 2 |
| 107 | #define EAPOLKey 3 |
| 108 | #define EAPOLASFAlert 4 |
| 109 | #define EAPTtypeMax 5 |
| 110 | |
| 111 | #define EAPOL_MSG_INVALID 0 |
| 112 | #define EAPOL_PAIR_MSG_1 1 |
| 113 | #define EAPOL_PAIR_MSG_2 2 |
| 114 | #define EAPOL_PAIR_MSG_3 3 |
| 115 | #define EAPOL_PAIR_MSG_4 4 |
| 116 | #define EAPOL_GROUP_MSG_1 5 |
| 117 | #define EAPOL_GROUP_MSG_2 6 |
| 118 | |
| 119 | #define PAIRWISEKEY 1 |
| 120 | #define GROUPKEY 0 |
| 121 | |
Bartlomiej Zolnierkiewicz | cc27706 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 122 | /* Retry timer counter initial value */ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 123 | #define PEER_MSG1_RETRY_TIMER_CTR 0 |
| 124 | #define PEER_MSG3_RETRY_TIMER_CTR 10 |
| 125 | #define GROUP_MSG1_RETRY_TIMER_CTR 20 |
| 126 | |
Bartlomiej Zolnierkiewicz | cc27706 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 127 | /*#ifdef CONFIG_AP_SUPPORT */ |
| 128 | /* WPA mechanism retry timer interval */ |
| 129 | #define PEER_MSG1_RETRY_EXEC_INTV 1000 /* 1 sec */ |
| 130 | #define PEER_MSG3_RETRY_EXEC_INTV 3000 /* 3 sec */ |
| 131 | #define GROUP_KEY_UPDATE_EXEC_INTV 1000 /* 1 sec */ |
| 132 | #define PEER_GROUP_KEY_UPDATE_INIV 2000 /* 2 sec */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 133 | |
Bartlomiej Zolnierkiewicz | cc27706 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 134 | #define ENQUEUE_EAPOL_START_TIMER 200 /* 200 ms */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 135 | |
Bartlomiej Zolnierkiewicz | cc27706 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 136 | /* group rekey interval */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 137 | #define TIME_REKEY 0 |
| 138 | #define PKT_REKEY 1 |
| 139 | #define DISABLE_REKEY 2 |
| 140 | #define MAX_REKEY 2 |
| 141 | |
| 142 | #define MAX_REKEY_INTER 0x3ffffff |
Bartlomiej Zolnierkiewicz | cc27706 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 143 | /*#endif // CONFIG_AP_SUPPORT // */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 144 | |
| 145 | #define GROUP_SUITE 0 |
| 146 | #define PAIRWISE_SUITE 1 |
| 147 | #define AKM_SUITE 2 |
| 148 | #define PMKID_LIST 3 |
| 149 | |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 150 | #define EAPOL_START_DISABLE 0 |
| 151 | #define EAPOL_START_PSK 1 |
| 152 | #define EAPOL_START_1X 2 |
| 153 | |
| 154 | #define MIX_CIPHER_WPA_TKIP_ON(x) (((x) & 0x08) != 0) |
| 155 | #define MIX_CIPHER_WPA_AES_ON(x) (((x) & 0x04) != 0) |
| 156 | #define MIX_CIPHER_WPA2_TKIP_ON(x) (((x) & 0x02) != 0) |
| 157 | #define MIX_CIPHER_WPA2_AES_ON(x) (((x) & 0x01) != 0) |
| 158 | |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 159 | #ifndef ROUND_UP |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 160 | #define ROUND_UP(__x, __y) \ |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 161 | (((unsigned long)((__x)+((__y)-1))) & ((unsigned long)~((__y)-1))) |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 162 | #endif |
| 163 | |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 164 | #define SET_u16_TO_ARRARY(_V, _LEN) \ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 165 | { \ |
| 166 | _V[0] = (_LEN & 0xFF00) >> 8; \ |
| 167 | _V[1] = (_LEN & 0xFF); \ |
| 168 | } |
| 169 | |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 170 | #define INC_u16_TO_ARRARY(_V, _LEN) \ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 171 | { \ |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 172 | u16 var_len; \ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 173 | \ |
| 174 | var_len = (_V[0]<<8) | (_V[1]); \ |
| 175 | var_len += _LEN; \ |
| 176 | \ |
| 177 | _V[0] = (var_len & 0xFF00) >> 8; \ |
| 178 | _V[1] = (var_len & 0xFF); \ |
| 179 | } |
| 180 | |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 181 | #define CONV_ARRARY_TO_u16(_V) ((_V[0]<<8) | (_V[1])) |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 182 | |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 183 | #define ADD_ONE_To_64BIT_VAR(_V) \ |
| 184 | { \ |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 185 | u8 cnt = LEN_KEY_DESC_REPLAY; \ |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 186 | do \ |
| 187 | { \ |
| 188 | cnt--; \ |
| 189 | _V[cnt]++; \ |
| 190 | if (cnt == 0) \ |
| 191 | break; \ |
| 192 | }while (_V[cnt] == 0); \ |
| 193 | } |
| 194 | |
| 195 | #define IS_WPA_CAPABILITY(a) (((a) >= Ndis802_11AuthModeWPA) && ((a) <= Ndis802_11AuthModeWPA1PSKWPA2PSK)) |
| 196 | |
Bartlomiej Zolnierkiewicz | cc27706 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 197 | /* EAPOL Key Information definition within Key descriptor format */ |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 198 | struct PACKED rt_key_info { |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 199 | u8 KeyMic:1; |
| 200 | u8 Secure:1; |
| 201 | u8 Error:1; |
| 202 | u8 Request:1; |
| 203 | u8 EKD_DL:1; /* EKD for AP; DL for STA */ |
| 204 | u8 Rsvd:3; |
| 205 | u8 KeyDescVer:3; |
| 206 | u8 KeyType:1; |
| 207 | u8 KeyIndex:2; |
| 208 | u8 Install:1; |
| 209 | u8 KeyAck:1; |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 210 | }; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 211 | |
Bartlomiej Zolnierkiewicz | cc27706 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 212 | /* EAPOL Key descriptor format */ |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 213 | struct PACKED rt_key_descripter { |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 214 | u8 Type; |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 215 | struct rt_key_info KeyInfo; |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 216 | u8 KeyLength[2]; |
| 217 | u8 ReplayCounter[LEN_KEY_DESC_REPLAY]; |
| 218 | u8 KeyNonce[LEN_KEY_DESC_NONCE]; |
| 219 | u8 KeyIv[LEN_KEY_DESC_IV]; |
| 220 | u8 KeyRsc[LEN_KEY_DESC_RSC]; |
| 221 | u8 KeyId[LEN_KEY_DESC_ID]; |
| 222 | u8 KeyMic[LEN_KEY_DESC_MIC]; |
| 223 | u8 KeyDataLen[2]; |
| 224 | u8 KeyData[MAX_LEN_OF_RSNIE]; |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 225 | }; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 226 | |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 227 | struct PACKED rt_eapol_packet { |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 228 | u8 ProVer; |
| 229 | u8 ProType; |
| 230 | u8 Body_Len[2]; |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 231 | struct rt_key_descripter KeyDesc; |
| 232 | }; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 233 | |
Bartlomiej Zolnierkiewicz | cc27706 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 234 | /*802.11i D10 page 83 */ |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 235 | struct PACKED rt_gtk_encap { |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 236 | u8 Kid:2; |
| 237 | u8 tx:1; |
| 238 | u8 rsv:5; |
| 239 | u8 rsv1; |
| 240 | u8 GTK[TKIP_GTK_LENGTH]; |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 241 | }; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 242 | |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 243 | struct PACKED rt_kde_encap { |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 244 | u8 Type; |
| 245 | u8 Len; |
| 246 | u8 OUI[3]; |
| 247 | u8 DataType; |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 248 | struct rt_gtk_encap GTKEncap; |
| 249 | }; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 250 | |
Bartlomiej Zolnierkiewicz | cc27706 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 251 | /* For WPA1 */ |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 252 | struct PACKED rt_rsnie { |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 253 | u8 oui[4]; |
| 254 | u16 version; |
| 255 | u8 mcast[4]; |
| 256 | u16 ucount; |
Bartlomiej Zolnierkiewicz | 52b81c8 | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 257 | struct PACKED { |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 258 | u8 oui[4]; |
Bartlomiej Zolnierkiewicz | 52b81c8 | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 259 | } ucast[1]; |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 260 | }; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 261 | |
Bartlomiej Zolnierkiewicz | cc27706 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 262 | /* For WPA2 */ |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 263 | struct PACKED rt_rsnie2 { |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 264 | u16 version; |
| 265 | u8 mcast[4]; |
| 266 | u16 ucount; |
Bartlomiej Zolnierkiewicz | 52b81c8 | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 267 | struct PACKED { |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 268 | u8 oui[4]; |
Bartlomiej Zolnierkiewicz | 52b81c8 | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 269 | } ucast[1]; |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 270 | }; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 271 | |
Bartlomiej Zolnierkiewicz | cc27706 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 272 | /* AKM Suite */ |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 273 | struct PACKED rt_rsnie_auth { |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 274 | u16 acount; |
Bartlomiej Zolnierkiewicz | 52b81c8 | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 275 | struct PACKED { |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 276 | u8 oui[4]; |
Bartlomiej Zolnierkiewicz | 52b81c8 | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 277 | } auth[1]; |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 278 | }; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 279 | |
Bartlomiej Zolnierkiewicz | 52b81c8 | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 280 | typedef union PACKED _RSN_CAPABILITIES { |
| 281 | struct PACKED { |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 282 | u16 PreAuth:1; |
| 283 | u16 No_Pairwise:1; |
| 284 | u16 PTKSA_R_Counter:2; |
| 285 | u16 GTKSA_R_Counter:2; |
| 286 | u16 Rsvd:10; |
Bartlomiej Zolnierkiewicz | 52b81c8 | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 287 | } field; |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 288 | u16 word; |
Bartlomiej Zolnierkiewicz | 52b81c8 | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 289 | } RSN_CAPABILITIES, *PRSN_CAPABILITIES; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 290 | |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 291 | struct PACKED rt_eap_hdr { |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 292 | u8 ProVer; |
| 293 | u8 ProType; |
| 294 | u8 Body_Len[2]; |
| 295 | u8 code; |
| 296 | u8 identifier; |
| 297 | u8 length[2]; /* including code and identifier, followed by length-2 octets of data */ |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 298 | }; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 299 | |
Bartlomiej Zolnierkiewicz | cc27706 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 300 | /* For supplicant state machine states. 802.11i Draft 4.1, p. 97 */ |
| 301 | /* We simplified it */ |
Bartlomiej Zolnierkiewicz | 52b81c8 | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 302 | typedef enum _WpaState { |
Bartlomiej Zolnierkiewicz | cc27706 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 303 | SS_NOTUSE, /* 0 */ |
| 304 | SS_START, /* 1 */ |
| 305 | SS_WAIT_MSG_3, /* 2 */ |
| 306 | SS_WAIT_GROUP, /* 3 */ |
| 307 | SS_FINISH, /* 4 */ |
| 308 | SS_KEYUPDATE, /* 5 */ |
Bartlomiej Zolnierkiewicz | 52b81c8 | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 309 | } WPA_STATE; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 310 | |
Bartlomiej Zolnierkiewicz | cc27706 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 311 | /* */ |
| 312 | /* The definition of the cipher combination */ |
| 313 | /* */ |
| 314 | /* bit3 bit2 bit1 bit0 */ |
| 315 | /* +------------+------------+ */ |
| 316 | /* | WPA | WPA2 | */ |
| 317 | /* +------+-----+------+-----+ */ |
| 318 | /* | TKIP | AES | TKIP | AES | */ |
| 319 | /* | 0 | 1 | 1 | 0 | -> 0x06 */ |
| 320 | /* | 0 | 1 | 1 | 1 | -> 0x07 */ |
| 321 | /* | 1 | 0 | 0 | 1 | -> 0x09 */ |
| 322 | /* | 1 | 0 | 1 | 1 | -> 0x0B */ |
| 323 | /* | 1 | 1 | 0 | 1 | -> 0x0D */ |
| 324 | /* | 1 | 1 | 1 | 0 | -> 0x0E */ |
| 325 | /* | 1 | 1 | 1 | 1 | -> 0x0F */ |
| 326 | /* +------+-----+------+-----+ */ |
| 327 | /* */ |
Bartlomiej Zolnierkiewicz | 52b81c8 | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 328 | typedef enum _WpaMixPairCipher { |
| 329 | MIX_CIPHER_NOTUSE = 0x00, |
Bartlomiej Zolnierkiewicz | cc27706 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 330 | WPA_NONE_WPA2_TKIPAES = 0x03, /* WPA2-TKIPAES */ |
Bartlomiej Zolnierkiewicz | 52b81c8 | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 331 | WPA_AES_WPA2_TKIP = 0x06, |
| 332 | WPA_AES_WPA2_TKIPAES = 0x07, |
| 333 | WPA_TKIP_WPA2_AES = 0x09, |
| 334 | WPA_TKIP_WPA2_TKIPAES = 0x0B, |
Bartlomiej Zolnierkiewicz | cc27706 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 335 | WPA_TKIPAES_WPA2_NONE = 0x0C, /* WPA-TKIPAES */ |
Bartlomiej Zolnierkiewicz | 52b81c8 | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 336 | WPA_TKIPAES_WPA2_AES = 0x0D, |
| 337 | WPA_TKIPAES_WPA2_TKIP = 0x0E, |
| 338 | WPA_TKIPAES_WPA2_TKIPAES = 0x0F, |
| 339 | } WPA_MIX_PAIR_CIPHER; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 340 | |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 341 | struct PACKED rt_rsn_ie_header { |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 342 | u8 Eid; |
| 343 | u8 Length; |
| 344 | u16 Version; /* Little endian format */ |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 345 | }; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 346 | |
Bartlomiej Zolnierkiewicz | cc27706 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 347 | /* Cipher suite selector types */ |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 348 | struct PACKED rt_cipher_suite_struct { |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 349 | u8 Oui[3]; |
| 350 | u8 Type; |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 351 | }; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 352 | |
Bartlomiej Zolnierkiewicz | cc27706 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 353 | /* Authentication and Key Management suite selector */ |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 354 | struct PACKED rt_akm_suite { |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 355 | u8 Oui[3]; |
| 356 | u8 Type; |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 357 | }; |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 358 | |
Bartlomiej Zolnierkiewicz | cc27706 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 359 | /* RSN capability */ |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 360 | struct PACKED rt_rsn_capability { |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 361 | u16 Rsv:10; |
| 362 | u16 GTKSAReplayCnt:2; |
| 363 | u16 PTKSAReplayCnt:2; |
| 364 | u16 NoPairwise:1; |
| 365 | u16 PreAuth:1; |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 366 | }; |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 367 | |
| 368 | /*======================================== |
| 369 | The prototype is defined in cmm_wpa.c |
| 370 | ========================================*/ |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 371 | BOOLEAN WpaMsgTypeSubst(u8 EAPType, int * MsgType); |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 372 | |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 373 | void PRF(u8 * key, |
| 374 | int key_len, |
| 375 | u8 * prefix, |
| 376 | int prefix_len, |
| 377 | u8 * data, int data_len, u8 * output, int len); |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 378 | |
Bartlomiej Zolnierkiewicz | 52b81c8 | 2009-12-11 12:23:14 -0800 | [diff] [blame] | 379 | int PasswordHash(char *password, |
| 380 | unsigned char *ssid, int ssidlength, unsigned char *output); |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 381 | |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 382 | u8 *GetSuiteFromRSNIE(u8 *rsnie, |
| 383 | u32 rsnie_len, u8 type, u8 * count); |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 384 | |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 385 | void WpaShowAllsuite(u8 *rsnie, u32 rsnie_len); |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 386 | |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 387 | void RTMPInsertRSNIE(u8 *pFrameBuf, |
| 388 | unsigned long *pFrameLen, |
| 389 | u8 *rsnie_ptr, |
| 390 | u8 rsnie_len, |
| 391 | u8 *pmkid_ptr, u8 pmkid_len); |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 392 | |
Greg Kroah-Hartman | 9198099 | 2008-10-28 14:48:09 -0700 | [diff] [blame] | 393 | #endif |