eap_fast_common.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /*
  2. * EAP-FAST definitions (RFC 4851)
  3. * Copyright (c) 2004-2008, 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 EAP_FAST_H
  9. #define EAP_FAST_H
  10. #define EAP_FAST_VERSION 1
  11. #define EAP_FAST_KEY_LEN 64
  12. #define EAP_FAST_SIMCK_LEN 40
  13. #define EAP_FAST_SKS_LEN 40
  14. #define EAP_FAST_CMK_LEN 20
  15. #define TLS_EXT_PAC_OPAQUE 35
  16. /*
  17. * RFC 5422: Section 4.2.1 - Formats for PAC TLV Attributes / Type Field
  18. * Note: bit 0x8000 (Mandatory) and bit 0x4000 (Reserved) are also defined
  19. * in the general PAC TLV format (Section 4.2).
  20. */
  21. #define PAC_TYPE_PAC_KEY 1
  22. #define PAC_TYPE_PAC_OPAQUE 2
  23. #define PAC_TYPE_CRED_LIFETIME 3
  24. #define PAC_TYPE_A_ID 4
  25. #define PAC_TYPE_I_ID 5
  26. /*
  27. * 6 was previous assigned for SERVER_PROTECTED_DATA, but
  28. * draft-cam-winget-eap-fast-provisioning-02.txt changed this to Reserved.
  29. */
  30. #define PAC_TYPE_A_ID_INFO 7
  31. #define PAC_TYPE_PAC_ACKNOWLEDGEMENT 8
  32. #define PAC_TYPE_PAC_INFO 9
  33. #define PAC_TYPE_PAC_TYPE 10
  34. #ifdef _MSC_VER
  35. #pragma pack(push, 1)
  36. #endif /* _MSC_VER */
  37. struct pac_tlv_hdr {
  38. be16 type;
  39. be16 len;
  40. } STRUCT_PACKED;
  41. #ifdef _MSC_VER
  42. #pragma pack(pop)
  43. #endif /* _MSC_VER */
  44. #define EAP_FAST_PAC_KEY_LEN 32
  45. /* RFC 5422: 4.2.6 PAC-Type TLV */
  46. #define PAC_TYPE_TUNNEL_PAC 1
  47. /* Application Specific Short Lived PACs (only in volatile storage) */
  48. /* User Authorization PAC */
  49. #define PAC_TYPE_USER_AUTHORIZATION 3
  50. /* Application Specific Long Lived PACs */
  51. /* Machine Authentication PAC */
  52. #define PAC_TYPE_MACHINE_AUTHENTICATION 2
  53. /*
  54. * RFC 5422:
  55. * Section 3.3 - Key Derivations Used in the EAP-FAST Provisioning Exchange
  56. */
  57. struct eap_fast_key_block_provisioning {
  58. /* Extra key material after TLS key_block */
  59. u8 session_key_seed[EAP_FAST_SKS_LEN];
  60. u8 server_challenge[16]; /* MSCHAPv2 ServerChallenge */
  61. u8 client_challenge[16]; /* MSCHAPv2 ClientChallenge */
  62. };
  63. struct wpabuf;
  64. struct tls_connection;
  65. struct eap_fast_tlv_parse {
  66. u8 *eap_payload_tlv;
  67. size_t eap_payload_tlv_len;
  68. struct eap_tlv_crypto_binding_tlv *crypto_binding;
  69. size_t crypto_binding_len;
  70. int iresult;
  71. int result;
  72. int request_action;
  73. u8 *pac;
  74. size_t pac_len;
  75. };
  76. void eap_fast_put_tlv_hdr(struct wpabuf *buf, u16 type, u16 len);
  77. void eap_fast_put_tlv(struct wpabuf *buf, u16 type, const void *data,
  78. u16 len);
  79. void eap_fast_put_tlv_buf(struct wpabuf *buf, u16 type,
  80. const struct wpabuf *data);
  81. struct wpabuf * eap_fast_tlv_eap_payload(struct wpabuf *buf);
  82. void eap_fast_derive_master_secret(const u8 *pac_key, const u8 *server_random,
  83. const u8 *client_random, u8 *master_secret);
  84. u8 * eap_fast_derive_key(void *ssl_ctx, struct tls_connection *conn,
  85. const char *label, size_t len);
  86. void eap_fast_derive_eap_msk(const u8 *simck, u8 *msk);
  87. void eap_fast_derive_eap_emsk(const u8 *simck, u8 *emsk);
  88. int eap_fast_parse_tlv(struct eap_fast_tlv_parse *tlv,
  89. int tlv_type, u8 *pos, size_t len);
  90. #endif /* EAP_FAST_H */