eap_psk_common.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /*
  2. * EAP server/peer: EAP-PSK shared routines
  3. * Copyright (c) 2004-2007, Jouni Malinen <j@w1.fi>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License version 2 as
  7. * published by the Free Software Foundation.
  8. *
  9. * Alternatively, this software may be distributed under the terms of BSD
  10. * license.
  11. *
  12. * See README and COPYING for more details.
  13. */
  14. #ifndef EAP_PSK_COMMON_H
  15. #define EAP_PSK_COMMON_H
  16. #define EAP_PSK_RAND_LEN 16
  17. #define EAP_PSK_MAC_LEN 16
  18. #define EAP_PSK_TEK_LEN 16
  19. #define EAP_PSK_PSK_LEN 16
  20. #define EAP_PSK_AK_LEN 16
  21. #define EAP_PSK_KDK_LEN 16
  22. #define EAP_PSK_R_FLAG_CONT 1
  23. #define EAP_PSK_R_FLAG_DONE_SUCCESS 2
  24. #define EAP_PSK_R_FLAG_DONE_FAILURE 3
  25. #define EAP_PSK_E_FLAG 0x20
  26. #define EAP_PSK_FLAGS_GET_T(flags) (((flags) & 0xc0) >> 6)
  27. #define EAP_PSK_FLAGS_SET_T(t) ((u8) (t) << 6)
  28. #ifdef _MSC_VER
  29. #pragma pack(push, 1)
  30. #endif /* _MSC_VER */
  31. /* EAP-PSK First Message (AS -> Supplicant) */
  32. struct eap_psk_hdr_1 {
  33. u8 flags;
  34. u8 rand_s[EAP_PSK_RAND_LEN];
  35. /* Followed by variable length ID_S */
  36. } STRUCT_PACKED;
  37. /* EAP-PSK Second Message (Supplicant -> AS) */
  38. struct eap_psk_hdr_2 {
  39. u8 flags;
  40. u8 rand_s[EAP_PSK_RAND_LEN];
  41. u8 rand_p[EAP_PSK_RAND_LEN];
  42. u8 mac_p[EAP_PSK_MAC_LEN];
  43. /* Followed by variable length ID_P */
  44. } STRUCT_PACKED;
  45. /* EAP-PSK Third Message (AS -> Supplicant) */
  46. struct eap_psk_hdr_3 {
  47. u8 flags;
  48. u8 rand_s[EAP_PSK_RAND_LEN];
  49. u8 mac_s[EAP_PSK_MAC_LEN];
  50. /* Followed by variable length PCHANNEL */
  51. } STRUCT_PACKED;
  52. /* EAP-PSK Fourth Message (Supplicant -> AS) */
  53. struct eap_psk_hdr_4 {
  54. u8 flags;
  55. u8 rand_s[EAP_PSK_RAND_LEN];
  56. /* Followed by variable length PCHANNEL */
  57. } STRUCT_PACKED;
  58. #ifdef _MSC_VER
  59. #pragma pack(pop)
  60. #endif /* _MSC_VER */
  61. int __must_check eap_psk_key_setup(const u8 *psk, u8 *ak, u8 *kdk);
  62. int __must_check eap_psk_derive_keys(const u8 *kdk, const u8 *rand_p, u8 *tek,
  63. u8 *msk, u8 *emsk);
  64. #endif /* EAP_PSK_COMMON_H */