]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
Share a single definition of EAPOL-Key structure for WEP keys
authorJouni Malinen <j@w1.fi>
Tue, 7 Aug 2012 18:27:01 +0000 (21:27 +0300)
committerJouni Malinen <j@w1.fi>
Tue, 7 Aug 2012 18:27:01 +0000 (21:27 +0300)
Signed-hostap: Jouni Malinen <j@w1.fi>

src/ap/ieee802_1x.c
src/ap/ieee802_1x.h
src/common/eapol_common.h
src/eapol_supp/eapol_supp_sm.c

index ef591a71e0794a42863ff6d7d46980b5bfa82f02..f76860ed4c3bd1bd44b5887e57dd6de5aa7c5087 100644 (file)
@@ -126,7 +126,7 @@ static void ieee802_1x_tx_key_one(struct hostapd_data *hapd,
        hdr = (struct ieee802_1x_hdr *) buf;
        key = (struct ieee802_1x_eapol_key *) (hdr + 1);
        key->type = EAPOL_KEY_TYPE_RC4;
-       key->key_length = htons(key_len);
+       WPA_PUT_BE16(key->key_length, key_len);
        wpa_get_ntp_timestamp(key->replay_counter);
 
        if (random_get_bytes(key->key_iv, sizeof(key->key_iv))) {
index 47d8c4b5553c4cb395a0420d102dc731507d8bc8..e1df94057de702fe794c362db2200dadd77f1a10 100644 (file)
@@ -17,38 +17,6 @@ struct hostapd_bss_config;
 struct hostapd_radius_attr;
 struct radius_msg;
 
-#ifdef _MSC_VER
-#pragma pack(push, 1)
-#endif /* _MSC_VER */
-
-/* RFC 3580, 4. RC4 EAPOL-Key Frame */
-
-struct ieee802_1x_eapol_key {
-       u8 type;
-       u16 key_length;
-       u8 replay_counter[8]; /* does not repeat within the life of the keying
-                              * material used to encrypt the Key field;
-                              * 64-bit NTP timestamp MAY be used here */
-       u8 key_iv[16]; /* cryptographically random number */
-       u8 key_index; /* key flag in the most significant bit:
-                      * 0 = broadcast (default key),
-                      * 1 = unicast (key mapping key); key index is in the
-                      * 7 least significant bits */
-       u8 key_signature[16]; /* HMAC-MD5 message integrity check computed with
-                              * MS-MPPE-Send-Key as the key */
-
-       /* followed by key: if packet body length = 44 + key length, then the
-        * key field (of key_length bytes) contains the key in encrypted form;
-        * if packet body length = 44, key field is absent and key_length
-        * represents the number of least significant octets from
-        * MS-MPPE-Send-Key attribute to be used as the keying material;
-        * RC4 key used in encryption = Key-IV + MS-MPPE-Recv-Key */
-} STRUCT_PACKED;
-
-#ifdef _MSC_VER
-#pragma pack(pop)
-#endif /* _MSC_VER */
-
 
 void ieee802_1x_receive(struct hostapd_data *hapd, const u8 *sa, const u8 *buf,
                        size_t len);
index 4e392e7cb68a636a697880852dfdaa6e26febcd8..4811f38aab36c354eb7b544e7d48e194baaaf65b 100644 (file)
@@ -38,4 +38,44 @@ enum { IEEE802_1X_TYPE_EAP_PACKET = 0,
 enum { EAPOL_KEY_TYPE_RC4 = 1, EAPOL_KEY_TYPE_RSN = 2,
        EAPOL_KEY_TYPE_WPA = 254 };
 
+
+#define IEEE8021X_REPLAY_COUNTER_LEN 8
+#define IEEE8021X_KEY_SIGN_LEN 16
+#define IEEE8021X_KEY_IV_LEN 16
+
+#define IEEE8021X_KEY_INDEX_FLAG 0x80
+#define IEEE8021X_KEY_INDEX_MASK 0x03
+
+#ifdef _MSC_VER
+#pragma pack(push, 1)
+#endif /* _MSC_VER */
+
+struct ieee802_1x_eapol_key {
+       u8 type;
+       /* Note: key_length is unaligned */
+       u8 key_length[2];
+       /* does not repeat within the life of the keying material used to
+        * encrypt the Key field; 64-bit NTP timestamp MAY be used here */
+       u8 replay_counter[IEEE8021X_REPLAY_COUNTER_LEN];
+       u8 key_iv[IEEE8021X_KEY_IV_LEN]; /* cryptographically random number */
+       u8 key_index; /* key flag in the most significant bit:
+                      * 0 = broadcast (default key),
+                      * 1 = unicast (key mapping key); key index is in the
+                      * 7 least significant bits */
+       /* HMAC-MD5 message integrity check computed with MS-MPPE-Send-Key as
+        * the key */
+       u8 key_signature[IEEE8021X_KEY_SIGN_LEN];
+
+       /* followed by key: if packet body length = 44 + key length, then the
+        * key field (of key_length bytes) contains the key in encrypted form;
+        * if packet body length = 44, key field is absent and key_length
+        * represents the number of least significant octets from
+        * MS-MPPE-Send-Key attribute to be used as the keying material;
+        * RC4 key used in encryption = Key-IV + MS-MPPE-Recv-Key */
+} STRUCT_PACKED;
+
+#ifdef _MSC_VER
+#pragma pack(pop)
+#endif /* _MSC_VER */
+
 #endif /* EAPOL_COMMON_H */
index 2a8ef1a68cb8b830568d77aba67a45040c5cb8ec..88398b308d9be09c2cb4f324ef98592ebcb74579 100644 (file)
@@ -139,46 +139,6 @@ struct eapol_sm {
 };
 
 
-#define IEEE8021X_REPLAY_COUNTER_LEN 8
-#define IEEE8021X_KEY_SIGN_LEN 16
-#define IEEE8021X_KEY_IV_LEN 16
-
-#define IEEE8021X_KEY_INDEX_FLAG 0x80
-#define IEEE8021X_KEY_INDEX_MASK 0x03
-
-#ifdef _MSC_VER
-#pragma pack(push, 1)
-#endif /* _MSC_VER */
-
-struct ieee802_1x_eapol_key {
-       u8 type;
-       /* Note: key_length is unaligned */
-       u8 key_length[2];
-       /* does not repeat within the life of the keying material used to
-        * encrypt the Key field; 64-bit NTP timestamp MAY be used here */
-       u8 replay_counter[IEEE8021X_REPLAY_COUNTER_LEN];
-       u8 key_iv[IEEE8021X_KEY_IV_LEN]; /* cryptographically random number */
-       u8 key_index; /* key flag in the most significant bit:
-                      * 0 = broadcast (default key),
-                      * 1 = unicast (key mapping key); key index is in the
-                      * 7 least significant bits */
-       /* HMAC-MD5 message integrity check computed with MS-MPPE-Send-Key as
-        * the key */
-       u8 key_signature[IEEE8021X_KEY_SIGN_LEN];
-
-       /* followed by key: if packet body length = 44 + key length, then the
-        * key field (of key_length bytes) contains the key in encrypted form;
-        * if packet body length = 44, key field is absent and key_length
-        * represents the number of least significant octets from
-        * MS-MPPE-Send-Key attribute to be used as the keying material;
-        * RC4 key used in encryption = Key-IV + MS-MPPE-Recv-Key */
-} STRUCT_PACKED;
-
-#ifdef _MSC_VER
-#pragma pack(pop)
-#endif /* _MSC_VER */
-
-
 static void eapol_sm_txLogoff(struct eapol_sm *sm);
 static void eapol_sm_txStart(struct eapol_sm *sm);
 static void eapol_sm_processKey(struct eapol_sm *sm);