eap.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. /*
  2. * hostapd / EAP Full Authenticator state machine (RFC 4137)
  3. * Copyright (c) 2004-2014, 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_H
  9. #define EAP_H
  10. #include "common/defs.h"
  11. #include "utils/list.h"
  12. #include "eap_common/eap_defs.h"
  13. #include "eap_server/eap_methods.h"
  14. #include "wpabuf.h"
  15. struct eap_sm;
  16. #define EAP_TTLS_AUTH_PAP 1
  17. #define EAP_TTLS_AUTH_CHAP 2
  18. #define EAP_TTLS_AUTH_MSCHAP 4
  19. #define EAP_TTLS_AUTH_MSCHAPV2 8
  20. struct eap_user {
  21. struct {
  22. int vendor;
  23. u32 method;
  24. } methods[EAP_MAX_METHODS];
  25. u8 *password;
  26. size_t password_len;
  27. int password_hash; /* whether password is hashed with
  28. * nt_password_hash() */
  29. int phase2;
  30. int force_version;
  31. unsigned int remediation:1;
  32. unsigned int macacl:1;
  33. int ttls_auth; /* bitfield of
  34. * EAP_TTLS_AUTH_{PAP,CHAP,MSCHAP,MSCHAPV2} */
  35. struct hostapd_radius_attr *accept_attr;
  36. };
  37. struct eap_eapol_interface {
  38. /* Lower layer to full authenticator variables */
  39. Boolean eapResp; /* shared with EAPOL Backend Authentication */
  40. struct wpabuf *eapRespData;
  41. Boolean portEnabled;
  42. int retransWhile;
  43. Boolean eapRestart; /* shared with EAPOL Authenticator PAE */
  44. int eapSRTT;
  45. int eapRTTVAR;
  46. /* Full authenticator to lower layer variables */
  47. Boolean eapReq; /* shared with EAPOL Backend Authentication */
  48. Boolean eapNoReq; /* shared with EAPOL Backend Authentication */
  49. Boolean eapSuccess;
  50. Boolean eapFail;
  51. Boolean eapTimeout;
  52. struct wpabuf *eapReqData;
  53. u8 *eapKeyData;
  54. size_t eapKeyDataLen;
  55. u8 *eapSessionId;
  56. size_t eapSessionIdLen;
  57. Boolean eapKeyAvailable; /* called keyAvailable in IEEE 802.1X-2004 */
  58. /* AAA interface to full authenticator variables */
  59. Boolean aaaEapReq;
  60. Boolean aaaEapNoReq;
  61. Boolean aaaSuccess;
  62. Boolean aaaFail;
  63. struct wpabuf *aaaEapReqData;
  64. u8 *aaaEapKeyData;
  65. size_t aaaEapKeyDataLen;
  66. Boolean aaaEapKeyAvailable;
  67. int aaaMethodTimeout;
  68. /* Full authenticator to AAA interface variables */
  69. Boolean aaaEapResp;
  70. struct wpabuf *aaaEapRespData;
  71. /* aaaIdentity -> eap_get_identity() */
  72. Boolean aaaTimeout;
  73. };
  74. struct eap_server_erp_key {
  75. struct dl_list list;
  76. size_t rRK_len;
  77. size_t rIK_len;
  78. u8 rRK[ERP_MAX_KEY_LEN];
  79. u8 rIK[ERP_MAX_KEY_LEN];
  80. u32 recv_seq;
  81. u8 cryptosuite;
  82. char keyname_nai[];
  83. };
  84. struct eapol_callbacks {
  85. int (*get_eap_user)(void *ctx, const u8 *identity, size_t identity_len,
  86. int phase2, struct eap_user *user);
  87. const char * (*get_eap_req_id_text)(void *ctx, size_t *len);
  88. void (*log_msg)(void *ctx, const char *msg);
  89. int (*get_erp_send_reauth_start)(void *ctx);
  90. const char * (*get_erp_domain)(void *ctx);
  91. struct eap_server_erp_key * (*erp_get_key)(void *ctx,
  92. const char *keyname);
  93. int (*erp_add_key)(void *ctx, struct eap_server_erp_key *erp);
  94. };
  95. struct eap_config {
  96. void *ssl_ctx;
  97. void *msg_ctx;
  98. void *eap_sim_db_priv;
  99. Boolean backend_auth;
  100. int eap_server;
  101. u16 pwd_group;
  102. u8 *pac_opaque_encr_key;
  103. u8 *eap_fast_a_id;
  104. size_t eap_fast_a_id_len;
  105. char *eap_fast_a_id_info;
  106. int eap_fast_prov;
  107. int pac_key_lifetime;
  108. int pac_key_refresh_time;
  109. int eap_sim_aka_result_ind;
  110. int tnc;
  111. struct wps_context *wps;
  112. const struct wpabuf *assoc_wps_ie;
  113. const struct wpabuf *assoc_p2p_ie;
  114. const u8 *peer_addr;
  115. int fragment_size;
  116. int pbc_in_m1;
  117. const u8 *server_id;
  118. size_t server_id_len;
  119. int erp;
  120. unsigned int tls_session_lifetime;
  121. unsigned int tls_flags;
  122. #ifdef CONFIG_TESTING_OPTIONS
  123. u32 tls_test_flags;
  124. #endif /* CONFIG_TESTING_OPTIONS */
  125. };
  126. struct eap_sm * eap_server_sm_init(void *eapol_ctx,
  127. const struct eapol_callbacks *eapol_cb,
  128. struct eap_config *eap_conf);
  129. void eap_server_sm_deinit(struct eap_sm *sm);
  130. int eap_server_sm_step(struct eap_sm *sm);
  131. void eap_sm_notify_cached(struct eap_sm *sm);
  132. void eap_sm_pending_cb(struct eap_sm *sm);
  133. int eap_sm_method_pending(struct eap_sm *sm);
  134. const u8 * eap_get_identity(struct eap_sm *sm, size_t *len);
  135. struct eap_eapol_interface * eap_get_interface(struct eap_sm *sm);
  136. void eap_server_clear_identity(struct eap_sm *sm);
  137. void eap_server_mschap_rx_callback(struct eap_sm *sm, const char *source,
  138. const u8 *username, size_t username_len,
  139. const u8 *challenge, const u8 *response);
  140. void eap_erp_update_identity(struct eap_sm *sm, const u8 *eap, size_t len);
  141. #endif /* EAP_H */