MOXA linux-2.6.x / linux-2.6.9-uc0 from sdlinux-moxaart.tgz
[linux-2.6.9-moxart.git] / drivers / net / wireless / rtlink / wpa.h
blobc73babee2bc1501f2aa4df62cc61de9e9b7e3b7c
1 /*************************************************************************
2 * Ralink Tech Inc. *
3 * 4F, No. 2 Technology 5th Rd. *
4 * Science-based Industrial Park *
5 * Hsin-chu, Taiwan, R.O.C. *
6 * *
7 * (c) Copyright 2002, Ralink Technology, Inc. *
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 * This program is distributed in the hope that it will be useful, *
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
17 * GNU General Public License for more details. *
18 * *
19 * You should have received a copy of the GNU General Public License *
20 * along with this program; if not, write to the *
21 * Free Software Foundation, Inc., *
22 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
23 * *
24 *************************************************************************
27 Module Name:
28 wpa.h
30 Abstract:
32 Revision History:
33 Who When What
34 -------- ---------- ----------------------------------------------
35 Name Date Modification logs
38 #ifndef __WPA_H__
39 #define __WPA_H__
41 //Messages for the wpa state machine,
42 #define WPA_MACHINE_BASE 21
43 #define EAP_MSG_TYPE_EAPPacket 21
44 #define EAP_MSG_TYPE_EAPOLStart 22
45 #define EAP_MSG_TYPE_EAPOLLogoff 23
46 #define EAP_MSG_TYPE_EAPOLKey 24
47 #define EAP_MSG_TYPE_EAPOLASFAlert 25
48 #define MAX_WPA_PSK_MSG 5
50 // WpaPsk EAPOL Key descripter frame format related length
51 #define LEN_KEY_DESC_NONCE 32
52 #define LEN_KEY_DESC_IV 16
53 #define LEN_KEY_DESC_RSC 8
54 #define LEN_KEY_DESC_ID 8
55 #define LEN_KEY_DESC_REPLAY 8
56 #define LEN_KEY_DESC_MIC 16
58 //EPA VERSION
59 #define EAPOL_VER 1
60 #define DESC_TYPE_TKIP 1
61 #define DESC_TYPE_AES 2
62 #define RSN_KEY_DESC 0xfe
64 #define LEN_MASTER_KEY 32
66 // EAPOL EK, MK
67 #define LEN_EAP_EK 16
68 #define LEN_EAP_MICK 16
69 #define LEN_EAP_KEY ((LEN_EAP_EK)+(LEN_EAP_MICK))
70 // TKIP key related
71 #define LEN_TKIP_EK 16
72 #define LEN_TKIP_RXMICK 8
73 #define LEN_TKIP_TXMICK 8
74 #define LEN_AES_EK 16
75 #define LEN_AES_KEY LEN_AES_EK
76 #define LEN_TKIP_KEY ((LEN_TKIP_EK)+(LEN_TKIP_RXMICK)+(LEN_TKIP_TXMICK))
77 #define TKIP_AP_TXMICK_OFFSET ((LEN_EAP_KEY)+(LEN_TKIP_EK))
78 #define TKIP_AP_RXMICK_OFFSET (TKIP_AP_TXMICK_OFFSET+LEN_TKIP_TXMICK)
79 #define TKIP_GTK_LENGTH ((LEN_TKIP_EK)+(LEN_TKIP_RXMICK)+(LEN_TKIP_TXMICK))
80 #define LEN_PTK ((LEN_EAP_KEY)+(LEN_TKIP_KEY))
81 #define MAX_LEN_OF_RSNIE 48
83 //EAP Packet Type
84 #define EAPPacket 0
85 #define EAPOLStart 1
86 #define EAPOLLogoff 2
87 #define EAPOLKey 3
88 #define EAPOLASFAlert 4
89 #define EAPTtypeMax 5
91 #define EAPOL_MSG_INVALID 0
92 #define EAPOL_PAIR_MSG_1 1
93 #define EAPOL_PAIR_MSG_3 2
94 #define EAPOL_GROUP_MSG_1 3
96 // EAPOL Key Information definition within Key descriptor format
97 typedef struct PACKED _KEY_INFO
99 #ifdef BIG_ENDIAN
100 UCHAR KeyAck:1;
101 UCHAR Install:1;
102 UCHAR KeyIndex:2;
103 UCHAR KeyType:1;
104 UCHAR KeyDescVer:3;
105 UCHAR Rsvd:3;
106 UCHAR DL:1;
107 UCHAR Request:1;
108 UCHAR Error:1;
109 UCHAR Secure:1;
110 UCHAR KeyMic:1;
111 #else
112 UCHAR KeyMic:1;
113 UCHAR Secure:1;
114 UCHAR Error:1;
115 UCHAR Request:1;
116 UCHAR DL:1;
117 UCHAR Rsvd:3;
118 UCHAR KeyDescVer:3;
119 UCHAR KeyType:1;
120 UCHAR KeyIndex:2;
121 UCHAR Install:1;
122 UCHAR KeyAck:1;
123 #endif
124 } KEY_INFO, *PKEY_INFO;
126 // EAPOL Key descriptor format
127 typedef struct PACKED _KEY_DESCRIPTER
129 UCHAR Type;
130 KEY_INFO KeyInfo;
131 UCHAR KeyLength[2];
132 UCHAR ReplayCounter[LEN_KEY_DESC_REPLAY];
133 UCHAR KeyNonce[LEN_KEY_DESC_NONCE];
134 UCHAR KeyIv[LEN_KEY_DESC_IV];
135 UCHAR KeyRsc[LEN_KEY_DESC_RSC];
136 UCHAR KeyId[LEN_KEY_DESC_ID];
137 UCHAR KeyMic[LEN_KEY_DESC_MIC];
138 UCHAR KeyDataLen[2];
139 UCHAR KeyData[MAX_LEN_OF_RSNIE];
140 } KEY_DESCRIPTER, *PKEY_DESCRIPTER;
142 typedef struct PACKED _EAPOL_PACKET
144 UCHAR Version;
145 UCHAR Type;
146 UCHAR Len[2];
147 KEY_DESCRIPTER KeyDesc;
148 } EAPOL_PACKET, *PEAPOL_PACKET;
150 // For supplicant state machine states. 802.11i Draft 4.1, p. 97
151 // We simplified it
152 typedef enum _WpaState
154 SS_NOTUSE, // 0
155 SS_START, // 1
156 SS_WAIT_MSG_3, // 2
157 SS_WAIT_GROUP, // 3
158 SS_FINISH, // 4
159 SS_KEYUPDATE, // 5
160 } WPA_STATE;
162 #endif