eapol_common.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /*
  2. * EAPOL definitions shared between hostapd and wpa_supplicant
  3. * Copyright (c) 2002-2007, Jouni Malinen <j@w1.fi>
  4. *
  5. * This software may be distributed under the terms of the BSD license.
  6. * See README for more details.
  7. */
  8. #ifndef EAPOL_COMMON_H
  9. #define EAPOL_COMMON_H
  10. /* IEEE Std 802.1X-2004 */
  11. #ifdef _MSC_VER
  12. #pragma pack(push, 1)
  13. #endif /* _MSC_VER */
  14. struct ieee802_1x_hdr {
  15. u8 version;
  16. u8 type;
  17. be16 length;
  18. /* followed by length octets of data */
  19. } STRUCT_PACKED;
  20. #ifdef _MSC_VER
  21. #pragma pack(pop)
  22. #endif /* _MSC_VER */
  23. #define EAPOL_VERSION 2
  24. enum { IEEE802_1X_TYPE_EAP_PACKET = 0,
  25. IEEE802_1X_TYPE_EAPOL_START = 1,
  26. IEEE802_1X_TYPE_EAPOL_LOGOFF = 2,
  27. IEEE802_1X_TYPE_EAPOL_KEY = 3,
  28. IEEE802_1X_TYPE_EAPOL_ENCAPSULATED_ASF_ALERT = 4
  29. };
  30. enum { EAPOL_KEY_TYPE_RC4 = 1, EAPOL_KEY_TYPE_RSN = 2,
  31. EAPOL_KEY_TYPE_WPA = 254 };
  32. #define IEEE8021X_REPLAY_COUNTER_LEN 8
  33. #define IEEE8021X_KEY_SIGN_LEN 16
  34. #define IEEE8021X_KEY_IV_LEN 16
  35. #define IEEE8021X_KEY_INDEX_FLAG 0x80
  36. #define IEEE8021X_KEY_INDEX_MASK 0x03
  37. #ifdef _MSC_VER
  38. #pragma pack(push, 1)
  39. #endif /* _MSC_VER */
  40. struct ieee802_1x_eapol_key {
  41. u8 type;
  42. /* Note: key_length is unaligned */
  43. u8 key_length[2];
  44. /* does not repeat within the life of the keying material used to
  45. * encrypt the Key field; 64-bit NTP timestamp MAY be used here */
  46. u8 replay_counter[IEEE8021X_REPLAY_COUNTER_LEN];
  47. u8 key_iv[IEEE8021X_KEY_IV_LEN]; /* cryptographically random number */
  48. u8 key_index; /* key flag in the most significant bit:
  49. * 0 = broadcast (default key),
  50. * 1 = unicast (key mapping key); key index is in the
  51. * 7 least significant bits */
  52. /* HMAC-MD5 message integrity check computed with MS-MPPE-Send-Key as
  53. * the key */
  54. u8 key_signature[IEEE8021X_KEY_SIGN_LEN];
  55. /* followed by key: if packet body length = 44 + key length, then the
  56. * key field (of key_length bytes) contains the key in encrypted form;
  57. * if packet body length = 44, key field is absent and key_length
  58. * represents the number of least significant octets from
  59. * MS-MPPE-Send-Key attribute to be used as the keying material;
  60. * RC4 key used in encryption = Key-IV + MS-MPPE-Recv-Key */
  61. } STRUCT_PACKED;
  62. #ifdef _MSC_VER
  63. #pragma pack(pop)
  64. #endif /* _MSC_VER */
  65. #endif /* EAPOL_COMMON_H */