eap_fast_common.h 3.1 KB

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