eapol_common.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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. struct ieee8023_hdr {
  21. u8 dest[ETH_ALEN];
  22. u8 src[ETH_ALEN];
  23. be16 ethertype;
  24. } STRUCT_PACKED;
  25. #ifdef _MSC_VER
  26. #pragma pack(pop)
  27. #endif /* _MSC_VER */
  28. #ifdef CONFIG_MACSEC
  29. #define EAPOL_VERSION 3
  30. #else /* CONFIG_MACSEC */
  31. #define EAPOL_VERSION 2
  32. #endif /* CONFIG_MACSEC */
  33. enum { IEEE802_1X_TYPE_EAP_PACKET = 0,
  34. IEEE802_1X_TYPE_EAPOL_START = 1,
  35. IEEE802_1X_TYPE_EAPOL_LOGOFF = 2,
  36. IEEE802_1X_TYPE_EAPOL_KEY = 3,
  37. IEEE802_1X_TYPE_EAPOL_ENCAPSULATED_ASF_ALERT = 4,
  38. IEEE802_1X_TYPE_EAPOL_MKA = 5,
  39. };
  40. enum { EAPOL_KEY_TYPE_RC4 = 1, EAPOL_KEY_TYPE_RSN = 2,
  41. EAPOL_KEY_TYPE_WPA = 254 };
  42. #define IEEE8021X_REPLAY_COUNTER_LEN 8
  43. #define IEEE8021X_KEY_SIGN_LEN 16
  44. #define IEEE8021X_KEY_IV_LEN 16
  45. #define IEEE8021X_KEY_INDEX_FLAG 0x80
  46. #define IEEE8021X_KEY_INDEX_MASK 0x03
  47. #ifdef _MSC_VER
  48. #pragma pack(push, 1)
  49. #endif /* _MSC_VER */
  50. struct ieee802_1x_eapol_key {
  51. u8 type;
  52. /* Note: key_length is unaligned */
  53. u8 key_length[2];
  54. /* does not repeat within the life of the keying material used to
  55. * encrypt the Key field; 64-bit NTP timestamp MAY be used here */
  56. u8 replay_counter[IEEE8021X_REPLAY_COUNTER_LEN];
  57. u8 key_iv[IEEE8021X_KEY_IV_LEN]; /* cryptographically random number */
  58. u8 key_index; /* key flag in the most significant bit:
  59. * 0 = broadcast (default key),
  60. * 1 = unicast (key mapping key); key index is in the
  61. * 7 least significant bits */
  62. /* HMAC-MD5 message integrity check computed with MS-MPPE-Send-Key as
  63. * the key */
  64. u8 key_signature[IEEE8021X_KEY_SIGN_LEN];
  65. /* followed by key: if packet body length = 44 + key length, then the
  66. * key field (of key_length bytes) contains the key in encrypted form;
  67. * if packet body length = 44, key field is absent and key_length
  68. * represents the number of least significant octets from
  69. * MS-MPPE-Send-Key attribute to be used as the keying material;
  70. * RC4 key used in encryption = Key-IV + MS-MPPE-Recv-Key */
  71. } STRUCT_PACKED;
  72. #ifdef _MSC_VER
  73. #pragma pack(pop)
  74. #endif /* _MSC_VER */
  75. #endif /* EAPOL_COMMON_H */