eap_i.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  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. /**
  83. * struct eap_sm - EAP server state machine data
  84. */
  85. struct eap_sm {
  86. enum {
  87. EAP_DISABLED, EAP_INITIALIZE, EAP_IDLE, EAP_RECEIVED,
  88. EAP_INTEGRITY_CHECK, EAP_METHOD_RESPONSE, EAP_METHOD_REQUEST,
  89. EAP_PROPOSE_METHOD, EAP_SELECT_ACTION, EAP_SEND_REQUEST,
  90. EAP_DISCARD, EAP_NAK, EAP_RETRANSMIT, EAP_SUCCESS, EAP_FAILURE,
  91. EAP_TIMEOUT_FAILURE, EAP_PICK_UP_METHOD,
  92. EAP_INITIALIZE_PASSTHROUGH, EAP_IDLE2, EAP_RETRANSMIT2,
  93. EAP_RECEIVED2, EAP_DISCARD2, EAP_SEND_REQUEST2,
  94. EAP_AAA_REQUEST, EAP_AAA_RESPONSE, EAP_AAA_IDLE,
  95. EAP_TIMEOUT_FAILURE2, EAP_FAILURE2, EAP_SUCCESS2
  96. } EAP_state;
  97. /* Constants */
  98. int MaxRetrans;
  99. struct eap_eapol_interface eap_if;
  100. /* Full authenticator state machine local variables */
  101. /* Long-term (maintained between packets) */
  102. EapType currentMethod;
  103. int currentId;
  104. enum {
  105. METHOD_PROPOSED, METHOD_CONTINUE, METHOD_END
  106. } methodState;
  107. int retransCount;
  108. struct wpabuf *lastReqData;
  109. int methodTimeout;
  110. /* Short-term (not maintained between packets) */
  111. Boolean rxResp;
  112. int respId;
  113. EapType respMethod;
  114. int respVendor;
  115. u32 respVendorMethod;
  116. Boolean ignore;
  117. enum {
  118. DECISION_SUCCESS, DECISION_FAILURE, DECISION_CONTINUE,
  119. DECISION_PASSTHROUGH
  120. } decision;
  121. /* Miscellaneous variables */
  122. const struct eap_method *m; /* selected EAP method */
  123. /* not defined in RFC 4137 */
  124. Boolean changed;
  125. void *eapol_ctx, *msg_ctx;
  126. struct eapol_callbacks *eapol_cb;
  127. void *eap_method_priv;
  128. u8 *identity;
  129. size_t identity_len;
  130. /* Whether Phase 2 method should validate identity match */
  131. int require_identity_match;
  132. int lastId; /* Identifier used in the last EAP-Packet */
  133. struct eap_user *user;
  134. int user_eap_method_index;
  135. int init_phase2;
  136. void *ssl_ctx;
  137. struct eap_sim_db_data *eap_sim_db_priv;
  138. Boolean backend_auth;
  139. Boolean update_user;
  140. int eap_server;
  141. int num_rounds;
  142. enum {
  143. METHOD_PENDING_NONE, METHOD_PENDING_WAIT, METHOD_PENDING_CONT
  144. } method_pending;
  145. u8 *auth_challenge;
  146. u8 *peer_challenge;
  147. u8 *pac_opaque_encr_key;
  148. u8 *eap_fast_a_id;
  149. size_t eap_fast_a_id_len;
  150. char *eap_fast_a_id_info;
  151. enum {
  152. NO_PROV, ANON_PROV, AUTH_PROV, BOTH_PROV
  153. } eap_fast_prov;
  154. int pac_key_lifetime;
  155. int pac_key_refresh_time;
  156. int eap_sim_aka_result_ind;
  157. int tnc;
  158. u16 pwd_group;
  159. struct wps_context *wps;
  160. struct wpabuf *assoc_wps_ie;
  161. struct wpabuf *assoc_p2p_ie;
  162. Boolean start_reauth;
  163. u8 peer_addr[ETH_ALEN];
  164. /* Fragmentation size for EAP method init() handler */
  165. int fragment_size;
  166. int pbc_in_m1;
  167. const u8 *server_id;
  168. size_t server_id_len;
  169. };
  170. int eap_user_get(struct eap_sm *sm, const u8 *identity, size_t identity_len,
  171. int phase2);
  172. void eap_sm_process_nak(struct eap_sm *sm, const u8 *nak_list, size_t len);
  173. #endif /* EAP_I_H */