eap_i.h 5.9 KB

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