eapol_common.h revision 337817
1117521Snjl/*
2131440Smarks * EAPOL definitions shared between hostapd and wpa_supplicant
3131440Smarks * Copyright (c) 2002-2007, Jouni Malinen <j@w1.fi>
4131440Smarks *
5131440Smarks * This software may be distributed under the terms of the BSD license.
6131440Smarks * See README for more details.
7131440Smarks */
8131440Smarks
9131440Smarks#ifndef EAPOL_COMMON_H
10131440Smarks#define EAPOL_COMMON_H
11131440Smarks
12131440Smarks/* IEEE Std 802.1X-2004 */
13131440Smarks
14131440Smarks#ifdef _MSC_VER
15131440Smarks#pragma pack(push, 1)
16131440Smarks#endif /* _MSC_VER */
17131440Smarks
18131440Smarksstruct ieee802_1x_hdr {
19131440Smarks	u8 version;
20131440Smarks	u8 type;
21131440Smarks	be16 length;
22131440Smarks	/* followed by length octets of data */
23131440Smarks} STRUCT_PACKED;
24131440Smarks
25131440Smarksstruct ieee8023_hdr {
26131440Smarks	u8 dest[ETH_ALEN];
27131440Smarks	u8 src[ETH_ALEN];
28131440Smarks	be16 ethertype;
29131440Smarks} STRUCT_PACKED;
30131440Smarks
31131440Smarks#ifdef _MSC_VER
32131440Smarks#pragma pack(pop)
33131440Smarks#endif /* _MSC_VER */
34131440Smarks
35131440Smarks#ifdef CONFIG_MACSEC
36131440Smarks#define EAPOL_VERSION 3
37131440Smarks#else /* CONFIG_MACSEC */
38131440Smarks#define EAPOL_VERSION 2
39131440Smarks#endif /* CONFIG_MACSEC */
40131440Smarks
41131440Smarksenum { IEEE802_1X_TYPE_EAP_PACKET = 0,
42131440Smarks       IEEE802_1X_TYPE_EAPOL_START = 1,
43131440Smarks       IEEE802_1X_TYPE_EAPOL_LOGOFF = 2,
44131440Smarks       IEEE802_1X_TYPE_EAPOL_KEY = 3,
45131440Smarks       IEEE802_1X_TYPE_EAPOL_ENCAPSULATED_ASF_ALERT = 4,
46131440Smarks       IEEE802_1X_TYPE_EAPOL_MKA = 5,
47131440Smarks};
48131440Smarks
49129684Snjlenum { EAPOL_KEY_TYPE_RC4 = 1, EAPOL_KEY_TYPE_RSN = 2,
50129684Snjl       EAPOL_KEY_TYPE_WPA = 254 };
51129684Snjl
52129684Snjl
53129684Snjl#define IEEE8021X_REPLAY_COUNTER_LEN 8
54129684Snjl#define IEEE8021X_KEY_SIGN_LEN 16
55129684Snjl#define IEEE8021X_KEY_IV_LEN 16
56129684Snjl
57129684Snjl#define IEEE8021X_KEY_INDEX_FLAG 0x80
58129684Snjl#define IEEE8021X_KEY_INDEX_MASK 0x03
59129684Snjl
60129684Snjl#ifdef _MSC_VER
61129684Snjl#pragma pack(push, 1)
62129684Snjl#endif /* _MSC_VER */
63129684Snjl
64129684Snjlstruct ieee802_1x_eapol_key {
65129684Snjl	u8 type;
66129684Snjl	/* Note: key_length is unaligned */
67129684Snjl	u8 key_length[2];
68129684Snjl	/* does not repeat within the life of the keying material used to
69129684Snjl	 * encrypt the Key field; 64-bit NTP timestamp MAY be used here */
70129684Snjl	u8 replay_counter[IEEE8021X_REPLAY_COUNTER_LEN];
71129684Snjl	u8 key_iv[IEEE8021X_KEY_IV_LEN]; /* cryptographically random number */
72129684Snjl	u8 key_index; /* key flag in the most significant bit:
73129684Snjl		       * 0 = broadcast (default key),
74129684Snjl		       * 1 = unicast (key mapping key); key index is in the
75129684Snjl		       * 7 least significant bits */
76129684Snjl	/* HMAC-MD5 message integrity check computed with MS-MPPE-Send-Key as
77129684Snjl	 * the key */
78129684Snjl	u8 key_signature[IEEE8021X_KEY_SIGN_LEN];
79129684Snjl
80129684Snjl	/* followed by key: if packet body length = 44 + key length, then the
81129684Snjl	 * key field (of key_length bytes) contains the key in encrypted form;
82129684Snjl	 * if packet body length = 44, key field is absent and key_length
83129684Snjl	 * represents the number of least significant octets from
84129684Snjl	 * MS-MPPE-Send-Key attribute to be used as the keying material;
85129684Snjl	 * RC4 key used in encryption = Key-IV + MS-MPPE-Recv-Key */
86129684Snjl} STRUCT_PACKED;
87129684Snjl
88129684Snjl#ifdef _MSC_VER
89129684Snjl#pragma pack(pop)
90129684Snjl#endif /* _MSC_VER */
91129684Snjl
92129684Snjl#endif /* EAPOL_COMMON_H */
93129684Snjl