eap_i.h 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. /*
  2. * hostapd / EAP Authenticator state machine internal structures (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_I_H
  9. #define EAP_I_H
  10. #include "wpabuf.h"
  11. #include "eap_server/eap.h"
  12. #include "eap_common/eap_common.h"
  13. /* RFC 4137 - EAP Standalone Authenticator */
  14. /**
  15. * struct eap_method - EAP method interface
  16. * This structure defines the EAP method interface. Each method will need to
  17. * register its own EAP type, EAP name, and set of function pointers for method
  18. * specific operations. This interface is based on section 5.4 of RFC 4137.
  19. */
  20. struct eap_method {
  21. int vendor;
  22. EapType method;
  23. const char *name;
  24. void * (*init)(struct eap_sm *sm);
  25. void * (*initPickUp)(struct eap_sm *sm);
  26. void (*reset)(struct eap_sm *sm, void *priv);
  27. struct wpabuf * (*buildReq)(struct eap_sm *sm, void *priv, u8 id);
  28. int (*getTimeout)(struct eap_sm *sm, void *priv);
  29. Boolean (*check)(struct eap_sm *sm, void *priv,
  30. struct wpabuf *respData);
  31. void (*process)(struct eap_sm *sm, void *priv,
  32. struct wpabuf *respData);
  33. Boolean (*isDone)(struct eap_sm *sm, void *priv);
  34. u8 * (*getKey)(struct eap_sm *sm, void *priv, size_t *len);
  35. /* isSuccess is not specified in draft-ietf-eap-statemachine-05.txt,
  36. * but it is useful in implementing Policy.getDecision() */
  37. Boolean (*isSuccess)(struct eap_sm *sm, void *priv);
  38. /**
  39. * free - Free EAP method data
  40. * @method: Pointer to the method data registered with
  41. * eap_server_method_register().
  42. *
  43. * This function will be called when the EAP method is being
  44. * unregistered. If the EAP method allocated resources during
  45. * registration (e.g., allocated struct eap_method), they should be
  46. * freed in this function. No other method functions will be called
  47. * after this call. If this function is not defined (i.e., function
  48. * pointer is %NULL), a default handler is used to release the method
  49. * data with free(method). This is suitable for most cases.
  50. */
  51. void (*free)(struct eap_method *method);
  52. #define EAP_SERVER_METHOD_INTERFACE_VERSION 1
  53. /**
  54. * version - Version of the EAP server method interface
  55. *
  56. * The EAP server method implementation should set this variable to
  57. * EAP_SERVER_METHOD_INTERFACE_VERSION. This is used to verify that the
  58. * EAP method is using supported API version when using dynamically
  59. * loadable EAP methods.
  60. */
  61. int version;
  62. /**
  63. * next - Pointer to the next EAP method
  64. *
  65. * This variable is used internally in the EAP method registration code
  66. * to create a linked list of registered EAP methods.
  67. */
  68. struct eap_method *next;
  69. /**
  70. * get_emsk - Get EAP method specific keying extended material (EMSK)
  71. * @sm: Pointer to EAP state machine allocated with eap_sm_init()
  72. * @priv: Pointer to private EAP method data from eap_method::init()
  73. * @len: Pointer to a variable to store EMSK length
  74. * Returns: EMSK or %NULL if not available
  75. *
  76. * This function can be used to get the extended keying material from
  77. * the EAP method. The key may already be stored in the method-specific
  78. * private data or this function may derive the key.
  79. */
  80. u8 * (*get_emsk)(struct eap_sm *sm, void *priv, size_t *len);
  81. /**
  82. * getSessionId - Get EAP method specific Session-Id
  83. * @sm: Pointer to EAP state machine allocated with eap_server_sm_init()
  84. * @priv: Pointer to private EAP method data from eap_method::init()
  85. * @len: Pointer to a variable to store Session-Id length
  86. * Returns: Session-Id or %NULL if not available
  87. *
  88. * This function can be used to get the Session-Id from the EAP method.
  89. * The Session-Id may already be stored in the method-specific private
  90. * data or this function may derive the Session-Id.
  91. */
  92. u8 * (*getSessionId)(struct eap_sm *sm, void *priv, size_t *len);
  93. };
  94. /**
  95. * struct eap_sm - EAP server state machine data
  96. */
  97. struct eap_sm {
  98. enum {
  99. EAP_DISABLED, EAP_INITIALIZE, EAP_IDLE, EAP_RECEIVED,
  100. EAP_INTEGRITY_CHECK, EAP_METHOD_RESPONSE, EAP_METHOD_REQUEST,
  101. EAP_PROPOSE_METHOD, EAP_SELECT_ACTION, EAP_SEND_REQUEST,
  102. EAP_DISCARD, EAP_NAK, EAP_RETRANSMIT, EAP_SUCCESS, EAP_FAILURE,
  103. EAP_TIMEOUT_FAILURE, EAP_PICK_UP_METHOD,
  104. EAP_INITIALIZE_PASSTHROUGH, EAP_IDLE2, EAP_RETRANSMIT2,
  105. EAP_RECEIVED2, EAP_DISCARD2, EAP_SEND_REQUEST2,
  106. EAP_AAA_REQUEST, EAP_AAA_RESPONSE, EAP_AAA_IDLE,
  107. EAP_TIMEOUT_FAILURE2, EAP_FAILURE2, EAP_SUCCESS2,
  108. EAP_INITIATE_REAUTH_START, EAP_INITIATE_RECEIVED
  109. } EAP_state;
  110. /* Constants */
  111. int MaxRetrans;
  112. struct eap_eapol_interface eap_if;
  113. /* Full authenticator state machine local variables */
  114. /* Long-term (maintained between packets) */
  115. EapType currentMethod;
  116. int currentId;
  117. enum {
  118. METHOD_PROPOSED, METHOD_CONTINUE, METHOD_END
  119. } methodState;
  120. int retransCount;
  121. struct wpabuf *lastReqData;
  122. int methodTimeout;
  123. /* Short-term (not maintained between packets) */
  124. Boolean rxResp;
  125. Boolean rxInitiate;
  126. int respId;
  127. EapType respMethod;
  128. int respVendor;
  129. u32 respVendorMethod;
  130. Boolean ignore;
  131. enum {
  132. DECISION_SUCCESS, DECISION_FAILURE, DECISION_CONTINUE,
  133. DECISION_PASSTHROUGH, DECISION_INITIATE_REAUTH_START
  134. } decision;
  135. /* Miscellaneous variables */
  136. const struct eap_method *m; /* selected EAP method */
  137. /* not defined in RFC 4137 */
  138. Boolean changed;
  139. void *eapol_ctx, *msg_ctx;
  140. const struct eapol_callbacks *eapol_cb;
  141. void *eap_method_priv;
  142. u8 *identity;
  143. size_t identity_len;
  144. /* Whether Phase 2 method should validate identity match */
  145. int require_identity_match;
  146. int lastId; /* Identifier used in the last EAP-Packet */
  147. struct eap_user *user;
  148. int user_eap_method_index;
  149. int init_phase2;
  150. void *ssl_ctx;
  151. struct eap_sim_db_data *eap_sim_db_priv;
  152. Boolean backend_auth;
  153. Boolean update_user;
  154. int eap_server;
  155. int num_rounds;
  156. enum {
  157. METHOD_PENDING_NONE, METHOD_PENDING_WAIT, METHOD_PENDING_CONT
  158. } method_pending;
  159. u8 *auth_challenge;
  160. u8 *peer_challenge;
  161. u8 *pac_opaque_encr_key;
  162. u8 *eap_fast_a_id;
  163. size_t eap_fast_a_id_len;
  164. char *eap_fast_a_id_info;
  165. enum {
  166. NO_PROV, ANON_PROV, AUTH_PROV, BOTH_PROV
  167. } eap_fast_prov;
  168. int pac_key_lifetime;
  169. int pac_key_refresh_time;
  170. int eap_sim_aka_result_ind;
  171. int tnc;
  172. u16 pwd_group;
  173. struct wps_context *wps;
  174. struct wpabuf *assoc_wps_ie;
  175. struct wpabuf *assoc_p2p_ie;
  176. Boolean start_reauth;
  177. u8 peer_addr[ETH_ALEN];
  178. /* Fragmentation size for EAP method init() handler */
  179. int fragment_size;
  180. int pbc_in_m1;
  181. const u8 *server_id;
  182. size_t server_id_len;
  183. Boolean initiate_reauth_start_sent;
  184. Boolean try_initiate_reauth;
  185. int erp;
  186. unsigned int tls_session_lifetime;
  187. #ifdef CONFIG_TESTING_OPTIONS
  188. u32 tls_test_flags;
  189. #endif /* CONFIG_TESTING_OPTIONS */
  190. };
  191. int eap_user_get(struct eap_sm *sm, const u8 *identity, size_t identity_len,
  192. int phase2);
  193. void eap_log_msg(struct eap_sm *sm, const char *fmt, ...)
  194. PRINTF_FORMAT(2, 3);
  195. void eap_sm_process_nak(struct eap_sm *sm, const u8 *nak_list, size_t len);
  196. #endif /* EAP_I_H */