xref: /dflybsd-src/contrib/wpa_supplicant/src/common/eapol_common.h (revision 3a84a4273475ed07d0ab1c2dfeffdfedef35d9cd)
16d49e1aeSJan Lentfer /*
26d49e1aeSJan Lentfer  * EAPOL definitions shared between hostapd and wpa_supplicant
36d49e1aeSJan Lentfer  * Copyright (c) 2002-2007, Jouni Malinen <j@w1.fi>
46d49e1aeSJan Lentfer  *
53ff40c12SJohn Marino  * This software may be distributed under the terms of the BSD license.
63ff40c12SJohn Marino  * See README for more details.
76d49e1aeSJan Lentfer  */
86d49e1aeSJan Lentfer 
96d49e1aeSJan Lentfer #ifndef EAPOL_COMMON_H
106d49e1aeSJan Lentfer #define EAPOL_COMMON_H
116d49e1aeSJan Lentfer 
126d49e1aeSJan Lentfer /* IEEE Std 802.1X-2004 */
136d49e1aeSJan Lentfer 
146d49e1aeSJan Lentfer #ifdef _MSC_VER
156d49e1aeSJan Lentfer #pragma pack(push, 1)
166d49e1aeSJan Lentfer #endif /* _MSC_VER */
176d49e1aeSJan Lentfer 
186d49e1aeSJan Lentfer struct ieee802_1x_hdr {
196d49e1aeSJan Lentfer 	u8 version;
206d49e1aeSJan Lentfer 	u8 type;
216d49e1aeSJan Lentfer 	be16 length;
226d49e1aeSJan Lentfer 	/* followed by length octets of data */
236d49e1aeSJan Lentfer } STRUCT_PACKED;
246d49e1aeSJan Lentfer 
25*a1157835SDaniel Fojt struct ieee8023_hdr {
26*a1157835SDaniel Fojt 	u8 dest[ETH_ALEN];
27*a1157835SDaniel Fojt 	u8 src[ETH_ALEN];
28*a1157835SDaniel Fojt 	be16 ethertype;
29*a1157835SDaniel Fojt } STRUCT_PACKED;
30*a1157835SDaniel Fojt 
316d49e1aeSJan Lentfer #ifdef _MSC_VER
326d49e1aeSJan Lentfer #pragma pack(pop)
336d49e1aeSJan Lentfer #endif /* _MSC_VER */
346d49e1aeSJan Lentfer 
35*a1157835SDaniel Fojt #ifdef CONFIG_MACSEC
36*a1157835SDaniel Fojt #define EAPOL_VERSION 3
37*a1157835SDaniel Fojt #else /* CONFIG_MACSEC */
386d49e1aeSJan Lentfer #define EAPOL_VERSION 2
39*a1157835SDaniel Fojt #endif /* CONFIG_MACSEC */
406d49e1aeSJan Lentfer 
416d49e1aeSJan Lentfer enum { IEEE802_1X_TYPE_EAP_PACKET = 0,
426d49e1aeSJan Lentfer        IEEE802_1X_TYPE_EAPOL_START = 1,
436d49e1aeSJan Lentfer        IEEE802_1X_TYPE_EAPOL_LOGOFF = 2,
446d49e1aeSJan Lentfer        IEEE802_1X_TYPE_EAPOL_KEY = 3,
45*a1157835SDaniel Fojt        IEEE802_1X_TYPE_EAPOL_ENCAPSULATED_ASF_ALERT = 4,
46*a1157835SDaniel Fojt        IEEE802_1X_TYPE_EAPOL_MKA = 5,
476d49e1aeSJan Lentfer };
486d49e1aeSJan Lentfer 
496d49e1aeSJan Lentfer enum { EAPOL_KEY_TYPE_RC4 = 1, EAPOL_KEY_TYPE_RSN = 2,
506d49e1aeSJan Lentfer        EAPOL_KEY_TYPE_WPA = 254 };
516d49e1aeSJan Lentfer 
523ff40c12SJohn Marino 
533ff40c12SJohn Marino #define IEEE8021X_REPLAY_COUNTER_LEN 8
543ff40c12SJohn Marino #define IEEE8021X_KEY_SIGN_LEN 16
553ff40c12SJohn Marino #define IEEE8021X_KEY_IV_LEN 16
563ff40c12SJohn Marino 
573ff40c12SJohn Marino #define IEEE8021X_KEY_INDEX_FLAG 0x80
583ff40c12SJohn Marino #define IEEE8021X_KEY_INDEX_MASK 0x03
593ff40c12SJohn Marino 
603ff40c12SJohn Marino #ifdef _MSC_VER
613ff40c12SJohn Marino #pragma pack(push, 1)
623ff40c12SJohn Marino #endif /* _MSC_VER */
633ff40c12SJohn Marino 
643ff40c12SJohn Marino struct ieee802_1x_eapol_key {
653ff40c12SJohn Marino 	u8 type;
663ff40c12SJohn Marino 	/* Note: key_length is unaligned */
673ff40c12SJohn Marino 	u8 key_length[2];
683ff40c12SJohn Marino 	/* does not repeat within the life of the keying material used to
693ff40c12SJohn Marino 	 * encrypt the Key field; 64-bit NTP timestamp MAY be used here */
703ff40c12SJohn Marino 	u8 replay_counter[IEEE8021X_REPLAY_COUNTER_LEN];
713ff40c12SJohn Marino 	u8 key_iv[IEEE8021X_KEY_IV_LEN]; /* cryptographically random number */
723ff40c12SJohn Marino 	u8 key_index; /* key flag in the most significant bit:
733ff40c12SJohn Marino 		       * 0 = broadcast (default key),
743ff40c12SJohn Marino 		       * 1 = unicast (key mapping key); key index is in the
753ff40c12SJohn Marino 		       * 7 least significant bits */
763ff40c12SJohn Marino 	/* HMAC-MD5 message integrity check computed with MS-MPPE-Send-Key as
773ff40c12SJohn Marino 	 * the key */
783ff40c12SJohn Marino 	u8 key_signature[IEEE8021X_KEY_SIGN_LEN];
793ff40c12SJohn Marino 
803ff40c12SJohn Marino 	/* followed by key: if packet body length = 44 + key length, then the
813ff40c12SJohn Marino 	 * key field (of key_length bytes) contains the key in encrypted form;
823ff40c12SJohn Marino 	 * if packet body length = 44, key field is absent and key_length
833ff40c12SJohn Marino 	 * represents the number of least significant octets from
843ff40c12SJohn Marino 	 * MS-MPPE-Send-Key attribute to be used as the keying material;
853ff40c12SJohn Marino 	 * RC4 key used in encryption = Key-IV + MS-MPPE-Recv-Key */
863ff40c12SJohn Marino } STRUCT_PACKED;
873ff40c12SJohn Marino 
883ff40c12SJohn Marino #ifdef _MSC_VER
893ff40c12SJohn Marino #pragma pack(pop)
903ff40c12SJohn Marino #endif /* _MSC_VER */
913ff40c12SJohn Marino 
926d49e1aeSJan Lentfer #endif /* EAPOL_COMMON_H */
93