OSDN Git Service

original
[gb-231r1-is01/Gingerbread_2.3.3_r1_IS01.git] / hardware / broadcom / wlan / bcm4329 / src / include / proto / eapol.h
1 /*
2  * 802.1x EAPOL definitions
3  *
4  * See
5  * IEEE Std 802.1X-2001
6  * IEEE 802.1X RADIUS Usage Guidelines
7  *
8  * Copyright (C) 2002 Broadcom Corporation
9  *
10  * $Id: eapol.h,v 9.18.260.1.2.1.6.6 2009/04/08 05:00:08 Exp $
11  */
12
13 #ifndef _eapol_h_
14 #define _eapol_h_
15
16 #ifndef _TYPEDEFS_H_
17 #include <typedefs.h>
18 #endif
19
20 /* This marks the start of a packed structure section. */
21 #include <packed_section_start.h>
22
23 #define AKW_BLOCK_LEN   8       /* The only def we need here */
24
25 /* EAPOL for 802.3/Ethernet */
26 typedef struct {
27         struct ether_header eth;        /* 802.3/Ethernet header */
28         unsigned char version;          /* EAPOL protocol version */
29         unsigned char type;             /* EAPOL type */
30         unsigned short length;          /* Length of body */
31         unsigned char body[1];          /* Body (optional) */
32 } eapol_header_t;
33
34 #define EAPOL_HEADER_LEN 18
35
36 /* EAPOL version */
37 #define WPA2_EAPOL_VERSION      2
38 #define WPA_EAPOL_VERSION       1
39 #define LEAP_EAPOL_VERSION      1
40 #define SES_EAPOL_VERSION       1
41
42 /* EAPOL types */
43 #define EAP_PACKET              0
44 #define EAPOL_START             1
45 #define EAPOL_LOGOFF            2
46 #define EAPOL_KEY               3
47 #define EAPOL_ASF               4
48
49 /* EAPOL-Key types */
50 #define EAPOL_RC4_KEY           1
51 #define EAPOL_WPA2_KEY          2       /* 802.11i/WPA2 */
52 #define EAPOL_WPA_KEY           254     /* WPA */
53
54 /* RC4 EAPOL-Key header field sizes */
55 #define EAPOL_KEY_REPLAY_LEN    8
56 #define EAPOL_KEY_IV_LEN        16
57 #define EAPOL_KEY_SIG_LEN       16
58
59 /* RC4 EAPOL-Key */
60 typedef BWL_PRE_PACKED_STRUCT struct {
61         unsigned char type;                     /* Key Descriptor Type */
62         unsigned short length;                  /* Key Length (unaligned) */
63         unsigned char replay[EAPOL_KEY_REPLAY_LEN];     /* Replay Counter */
64         unsigned char iv[EAPOL_KEY_IV_LEN];             /* Key IV */
65         unsigned char index;                            /* Key Flags & Index */
66         unsigned char signature[EAPOL_KEY_SIG_LEN];     /* Key Signature */
67         unsigned char key[1];                           /* Key (optional) */
68 } BWL_POST_PACKED_STRUCT eapol_key_header_t;
69
70 #define EAPOL_KEY_HEADER_LEN    44
71
72 /* RC4 EAPOL-Key flags */
73 #define EAPOL_KEY_FLAGS_MASK    0x80
74 #define EAPOL_KEY_BROADCAST     0
75 #define EAPOL_KEY_UNICAST       0x80
76
77 /* RC4 EAPOL-Key index */
78 #define EAPOL_KEY_INDEX_MASK    0x7f
79
80 /* WPA/802.11i/WPA2 EAPOL-Key header field sizes */
81 #define EAPOL_WPA_KEY_REPLAY_LEN        8
82 #define EAPOL_WPA_KEY_NONCE_LEN         32
83 #define EAPOL_WPA_KEY_IV_LEN            16
84 #define EAPOL_WPA_KEY_ID_LEN            8
85 #define EAPOL_WPA_KEY_RSC_LEN           8
86 #define EAPOL_WPA_KEY_MIC_LEN           16
87 #define EAPOL_WPA_KEY_DATA_LEN          (EAPOL_WPA_MAX_KEY_SIZE + AKW_BLOCK_LEN)
88 #define EAPOL_WPA_MAX_KEY_SIZE          32
89
90 /* WPA EAPOL-Key */
91 typedef BWL_PRE_PACKED_STRUCT struct {
92         unsigned char type;             /* Key Descriptor Type */
93         unsigned short key_info;        /* Key Information (unaligned) */
94         unsigned short key_len;         /* Key Length (unaligned) */
95         unsigned char replay[EAPOL_WPA_KEY_REPLAY_LEN]; /* Replay Counter */
96         unsigned char nonce[EAPOL_WPA_KEY_NONCE_LEN];   /* Nonce */
97         unsigned char iv[EAPOL_WPA_KEY_IV_LEN];         /* Key IV */
98         unsigned char rsc[EAPOL_WPA_KEY_RSC_LEN];       /* Key RSC */
99         unsigned char id[EAPOL_WPA_KEY_ID_LEN];         /* WPA:Key ID, 802.11i/WPA2: Reserved */
100         unsigned char mic[EAPOL_WPA_KEY_MIC_LEN];       /* Key MIC */
101         unsigned short data_len;                        /* Key Data Length */
102         unsigned char data[EAPOL_WPA_KEY_DATA_LEN];     /* Key data */
103 } BWL_POST_PACKED_STRUCT eapol_wpa_key_header_t;
104
105 #define EAPOL_WPA_KEY_LEN               95
106
107 /* WPA/802.11i/WPA2 KEY KEY_INFO bits */
108 #define WPA_KEY_DESC_V1         0x01
109 #define WPA_KEY_DESC_V2         0x02
110 #define WPA_KEY_PAIRWISE        0x08
111 #define WPA_KEY_INSTALL         0x40
112 #define WPA_KEY_ACK             0x80
113 #define WPA_KEY_MIC             0x100
114 #define WPA_KEY_SECURE          0x200
115 #define WPA_KEY_ERROR           0x400
116 #define WPA_KEY_REQ             0x800
117
118 /* WPA-only KEY KEY_INFO bits */
119 #define WPA_KEY_INDEX_0         0x00
120 #define WPA_KEY_INDEX_1         0x10
121 #define WPA_KEY_INDEX_2         0x20
122 #define WPA_KEY_INDEX_3         0x30
123 #define WPA_KEY_INDEX_MASK      0x30
124 #define WPA_KEY_INDEX_SHIFT     0x04
125
126 /* 802.11i/WPA2-only KEY KEY_INFO bits */
127 #define WPA_KEY_ENCRYPTED_DATA  0x1000
128
129 /* Key Data encapsulation */
130 typedef BWL_PRE_PACKED_STRUCT struct {
131         uint8 type;
132         uint8 length;
133         uint8 oui[3];
134         uint8 subtype;
135         uint8 data[1];
136 } BWL_POST_PACKED_STRUCT eapol_wpa2_encap_data_t;
137
138 #define EAPOL_WPA2_ENCAP_DATA_HDR_LEN   6
139
140 #define WPA2_KEY_DATA_SUBTYPE_GTK       1
141 #define WPA2_KEY_DATA_SUBTYPE_STAKEY    2
142 #define WPA2_KEY_DATA_SUBTYPE_MAC       3
143 #define WPA2_KEY_DATA_SUBTYPE_PMKID     4
144
145 /* GTK encapsulation */
146 typedef BWL_PRE_PACKED_STRUCT struct {
147         uint8   flags;
148         uint8   reserved;
149         uint8   gtk[EAPOL_WPA_MAX_KEY_SIZE];
150 } BWL_POST_PACKED_STRUCT eapol_wpa2_key_gtk_encap_t;
151
152 #define EAPOL_WPA2_KEY_GTK_ENCAP_HDR_LEN        2
153
154 #define WPA2_GTK_INDEX_MASK     0x03
155 #define WPA2_GTK_INDEX_SHIFT    0x00
156
157 #define WPA2_GTK_TRANSMIT       0x04
158
159 /* STAKey encapsulation */
160 typedef BWL_PRE_PACKED_STRUCT struct {
161         uint8   reserved[2];
162         uint8   mac[ETHER_ADDR_LEN];
163         uint8   stakey[EAPOL_WPA_MAX_KEY_SIZE];
164 } BWL_POST_PACKED_STRUCT eapol_wpa2_key_stakey_encap_t;
165
166 #define WPA2_KEY_DATA_PAD       0xdd
167
168
169 /* This marks the end of a packed structure section. */
170 #include <packed_section_end.h>
171
172 #endif /* _eapol_h_ */