blob: d773348b42c5bfb94e5ec58c1b3b9550c6916eff [file] [log] [blame]
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -07001/*
2 * EAPOL definitions shared between hostapd and wpa_supplicant
3 * Copyright (c) 2002-2007, Jouni Malinen <j@w1.fi>
4 *
Dmitry Shmidtc5ec7f52012-03-06 16:33:24 -08005 * This software may be distributed under the terms of the BSD license.
6 * See README for more details.
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -07007 */
8
9#ifndef EAPOL_COMMON_H
10#define EAPOL_COMMON_H
11
12/* IEEE Std 802.1X-2004 */
13
14#ifdef _MSC_VER
15#pragma pack(push, 1)
16#endif /* _MSC_VER */
17
18struct ieee802_1x_hdr {
19 u8 version;
20 u8 type;
21 be16 length;
22 /* followed by length octets of data */
23} STRUCT_PACKED;
24
Dmitry Shmidt5a1480c2014-05-12 09:46:02 -070025struct ieee8023_hdr {
26 u8 dest[ETH_ALEN];
27 u8 src[ETH_ALEN];
Dmitry Shmidt4ae50e62016-06-27 13:48:39 -070028 be16 ethertype;
Dmitry Shmidt5a1480c2014-05-12 09:46:02 -070029} STRUCT_PACKED;
30
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070031#ifdef _MSC_VER
32#pragma pack(pop)
33#endif /* _MSC_VER */
34
Dmitry Shmidt5a1480c2014-05-12 09:46:02 -070035#ifdef CONFIG_MACSEC
36#define EAPOL_VERSION 3
37#else /* CONFIG_MACSEC */
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070038#define EAPOL_VERSION 2
Dmitry Shmidt5a1480c2014-05-12 09:46:02 -070039#endif /* CONFIG_MACSEC */
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070040
41enum { IEEE802_1X_TYPE_EAP_PACKET = 0,
42 IEEE802_1X_TYPE_EAPOL_START = 1,
43 IEEE802_1X_TYPE_EAPOL_LOGOFF = 2,
44 IEEE802_1X_TYPE_EAPOL_KEY = 3,
Dmitry Shmidt5a1480c2014-05-12 09:46:02 -070045 IEEE802_1X_TYPE_EAPOL_ENCAPSULATED_ASF_ALERT = 4,
46 IEEE802_1X_TYPE_EAPOL_MKA = 5,
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070047};
48
49enum { EAPOL_KEY_TYPE_RC4 = 1, EAPOL_KEY_TYPE_RSN = 2,
50 EAPOL_KEY_TYPE_WPA = 254 };
51
Dmitry Shmidt61d9df32012-08-29 16:22:06 -070052
53#define IEEE8021X_REPLAY_COUNTER_LEN 8
54#define IEEE8021X_KEY_SIGN_LEN 16
55#define IEEE8021X_KEY_IV_LEN 16
56
57#define IEEE8021X_KEY_INDEX_FLAG 0x80
58#define IEEE8021X_KEY_INDEX_MASK 0x03
59
60#ifdef _MSC_VER
61#pragma pack(push, 1)
62#endif /* _MSC_VER */
63
64struct ieee802_1x_eapol_key {
65 u8 type;
66 /* Note: key_length is unaligned */
67 u8 key_length[2];
68 /* does not repeat within the life of the keying material used to
69 * encrypt the Key field; 64-bit NTP timestamp MAY be used here */
70 u8 replay_counter[IEEE8021X_REPLAY_COUNTER_LEN];
71 u8 key_iv[IEEE8021X_KEY_IV_LEN]; /* cryptographically random number */
72 u8 key_index; /* key flag in the most significant bit:
73 * 0 = broadcast (default key),
74 * 1 = unicast (key mapping key); key index is in the
75 * 7 least significant bits */
76 /* HMAC-MD5 message integrity check computed with MS-MPPE-Send-Key as
77 * the key */
78 u8 key_signature[IEEE8021X_KEY_SIGN_LEN];
79
80 /* followed by key: if packet body length = 44 + key length, then the
81 * key field (of key_length bytes) contains the key in encrypted form;
82 * if packet body length = 44, key field is absent and key_length
83 * represents the number of least significant octets from
84 * MS-MPPE-Send-Key attribute to be used as the keying material;
85 * RC4 key used in encryption = Key-IV + MS-MPPE-Recv-Key */
86} STRUCT_PACKED;
87
88#ifdef _MSC_VER
89#pragma pack(pop)
90#endif /* _MSC_VER */
91
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070092#endif /* EAPOL_COMMON_H */