OpenWrt packages
Sign in or create your account | Project List | Help
OpenWrt packages Git Source Tree
Root/
1 | /* |
2 | * |
3 | * eap_packet.h |
4 | * $Id: eap_packet.h 991 2009-09-14 01:38:58Z sekine $ |
5 | * |
6 | */ |
7 | #ifndef EAP_PACKET_H |
8 | #define EAP_PACKET_H |
9 | |
10 | #define WBIT(n) (1 << (n)) |
11 | |
12 | #ifndef ETH_ALEN |
13 | #define ETH_ALEN 6 |
14 | #endif |
15 | |
16 | struct ether_hdr { |
17 | unsigned char h_dest[ETH_ALEN]; /* destination eth addr */ |
18 | unsigned char h_source[ETH_ALEN]; /* source ether addr */ |
19 | unsigned char h_dest_snap; |
20 | unsigned char h_source_snap; |
21 | unsigned char h_command; |
22 | unsigned char h_vendor_id[3]; |
23 | unsigned short h_proto; /* packet type ID field */ |
24 | #define ETHER_PROTOCOL_TYPE_EAP 0x888e |
25 | #define ETHER_PROTOCOL_TYPE_IP 0x0800 |
26 | #define ETHER_PROTOCOL_TYPE_ARP 0x0806 |
27 | /* followed by length octets of data */ |
28 | } __attribute__ ((packed)); |
29 | |
30 | struct ieee802_1x_hdr { |
31 | unsigned char version; |
32 | unsigned char type; |
33 | unsigned short length; |
34 | /* followed by length octets of data */ |
35 | } __attribute__ ((packed)); |
36 | |
37 | #define EAPOL_VERSION 2 |
38 | |
39 | enum { IEEE802_1X_TYPE_EAP_PACKET = 0, |
40 | IEEE802_1X_TYPE_EAPOL_START = 1, |
41 | IEEE802_1X_TYPE_EAPOL_LOGOFF = 2, |
42 | IEEE802_1X_TYPE_EAPOL_KEY = 3, |
43 | IEEE802_1X_TYPE_EAPOL_ENCAPSULATED_ASF_ALERT = 4 |
44 | }; |
45 | |
46 | enum { EAPOL_KEY_TYPE_RC4 = 1, EAPOL_KEY_TYPE_RSN = 2, |
47 | EAPOL_KEY_TYPE_WPA = 254 }; |
48 | |
49 | |
50 | #define IEEE8021X_REPLAY_COUNTER_LEN 8 |
51 | #define IEEE8021X_KEY_SIGN_LEN 16 |
52 | #define IEEE8021X_KEY_IV_LEN 16 |
53 | |
54 | #define IEEE8021X_KEY_INDEX_FLAG 0x80 |
55 | #define IEEE8021X_KEY_INDEX_MASK 0x03 |
56 | |
57 | struct ieee802_1x_eapol_key { |
58 | unsigned char type; |
59 | unsigned short key_length; |
60 | /* does not repeat within the life of the keying material used to |
61 | * encrypt the Key field; 64-bit NTP timestamp MAY be used here */ |
62 | unsigned char replay_counter[IEEE8021X_REPLAY_COUNTER_LEN]; |
63 | unsigned char key_iv[IEEE8021X_KEY_IV_LEN]; /* cryptographically random number */ |
64 | unsigned char key_index; /* key flag in the most significant bit: |
65 | * 0 = broadcast (default key), |
66 | * 1 = unicast (key mapping key); key index is in the |
67 | * 7 least significant bits */ |
68 | /* HMAC-MD5 message integrity check computed with MS-MPPE-Send-Key as |
69 | * the key */ |
70 | unsigned char key_signature[IEEE8021X_KEY_SIGN_LEN]; |
71 | |
72 | /* followed by key: if packet body length = 44 + key length, then the |
73 | * key field (of key_length bytes) contains the key in encrypted form; |
74 | * if packet body length = 44, key field is absent and key_length |
75 | * represents the number of least significant octets from |
76 | * MS-MPPE-Send-Key attribute to be used as the keying material; |
77 | * RC4 key used in encryption = Key-IV + MS-MPPE-Recv-Key */ |
78 | } __attribute__ ((packed)); |
79 | |
80 | |
81 | #define WPA_NONCE_LEN 32 |
82 | #define WPA_REPLAY_COUNTER_LEN 8 |
83 | |
84 | struct wpa_eapol_key { |
85 | unsigned char type; |
86 | unsigned short key_info; |
87 | unsigned short key_length; |
88 | unsigned char replay_counter[WPA_REPLAY_COUNTER_LEN]; |
89 | unsigned char key_nonce[WPA_NONCE_LEN]; |
90 | unsigned char key_iv[16]; |
91 | unsigned char key_rsc[8]; |
92 | unsigned char key_id[8]; /* Reserved in IEEE 802.11i/RSN */ |
93 | unsigned char key_mic[16]; |
94 | unsigned short key_data_length; |
95 | /* followed by key_data_length bytes of key_data */ |
96 | } __attribute__ ((packed)); |
97 | |
98 | #define WPA_KEY_INFO_TYPE_MASK (WBIT(0) | WBIT(1) | WBIT(2)) |
99 | #define WPA_KEY_INFO_TYPE_HMAC_MD5_RC4 WBIT(0) |
100 | #define WPA_KEY_INFO_TYPE_HMAC_SHA1_AES WBIT(1) |
101 | #define WPA_KEY_INFO_KEY_TYPE WBIT(3) /* 1 = Pairwise, 0 = Group key */ |
102 | /* bit4..5 is used in WPA, but is reserved in IEEE 802.11i/RSN */ |
103 | #define WPA_KEY_INFO_KEY_INDEX_MASK (WBIT(4) | WBIT(5)) |
104 | #define WPA_KEY_INFO_KEY_INDEX_SHIFT 4 |
105 | #define WPA_KEY_INFO_INSTALL WBIT(6) /* pairwise */ |
106 | #define WPA_KEY_INFO_TXRX WBIT(6) /* group */ |
107 | #define WPA_KEY_INFO_ACK WBIT(7) |
108 | #define WPA_KEY_INFO_MIC WBIT(8) |
109 | #define WPA_KEY_INFO_SECURE WBIT(9) |
110 | #define WPA_KEY_INFO_ERROR WBIT(10) |
111 | #define WPA_KEY_INFO_REQUEST WBIT(11) |
112 | #define WPA_KEY_INFO_ENCR_KEY_DATA WBIT(12) /* IEEE 802.11i/RSN only */ |
113 | |
114 | #define WPA_CAPABILITY_PREAUTH WBIT(0) |
115 | |
116 | #define GENERIC_INFO_ELEM 0xdd |
117 | #define RSN_INFO_ELEM 0x30 |
118 | |
119 | enum { |
120 | REASON_UNSPECIFIED = 1, |
121 | REASON_DEAUTH_LEAVING = 3, |
122 | REASON_INVALID_IE = 13, |
123 | REASON_MICHAEL_MIC_FAILURE = 14, |
124 | REASON_4WAY_HANDSHAKE_TIMEOUT = 15, |
125 | REASON_GROUP_KEY_UPDATE_TIMEOUT = 16, |
126 | REASON_IE_IN_4WAY_DIFFERS = 17, |
127 | REASON_GROUP_CIPHER_NOT_VALID = 18, |
128 | REASON_PAIRWISE_CIPHER_NOT_VALID = 19, |
129 | REASON_AKMP_NOT_VALID = 20, |
130 | REASON_UNSUPPORTED_RSN_IE_VERSION = 21, |
131 | REASON_INVALID_RSN_IE_CAPAB = 22, |
132 | REASON_IEEE_802_1X_AUTH_FAILED = 23, |
133 | REASON_CIPHER_SUITE_REJECTED = 24 |
134 | }; |
135 | |
136 | #endif /* EAP_PACKET_H */ |
137 |