eap.h 3.3 KB

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