blob: d965a25c409c106f92d48e26f2e148ad474913a6 [file] [log] [blame]
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -07001/*
2 * hostapd / EAP Full Authenticator state machine (RFC 4137)
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -08003 * Copyright (c) 2004-2014, Jouni Malinen <j@w1.fi>
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -07004 *
Dmitry Shmidtc5ec7f52012-03-06 16:33:24 -08005 * This software may be distributed under the terms of the BSD license.
6 * See README for more details.
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -07007 */
8
9#ifndef EAP_H
10#define EAP_H
11
12#include "common/defs.h"
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -080013#include "utils/list.h"
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070014#include "eap_common/eap_defs.h"
15#include "eap_server/eap_methods.h"
16#include "wpabuf.h"
17
18struct eap_sm;
19
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070020#define EAP_TTLS_AUTH_PAP 1
21#define EAP_TTLS_AUTH_CHAP 2
22#define EAP_TTLS_AUTH_MSCHAP 4
23#define EAP_TTLS_AUTH_MSCHAPV2 8
24
25struct eap_user {
26 struct {
27 int vendor;
28 u32 method;
29 } methods[EAP_MAX_METHODS];
30 u8 *password;
31 size_t password_len;
32 int password_hash; /* whether password is hashed with
33 * nt_password_hash() */
Roshan Pius3a1667e2018-07-03 15:17:14 -070034 u8 *salt;
35 size_t salt_len;
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070036 int phase2;
37 int force_version;
Dmitry Shmidtf21452a2014-02-26 10:55:25 -080038 unsigned int remediation:1;
Dmitry Shmidtdf5a7e42014-04-02 12:59:59 -070039 unsigned int macacl:1;
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070040 int ttls_auth; /* bitfield of
41 * EAP_TTLS_AUTH_{PAP,CHAP,MSCHAP,MSCHAPV2} */
Dmitry Shmidt818ea482014-03-10 13:15:21 -070042 struct hostapd_radius_attr *accept_attr;
Roshan Pius3a1667e2018-07-03 15:17:14 -070043 u32 t_c_timestamp;
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070044};
45
46struct eap_eapol_interface {
47 /* Lower layer to full authenticator variables */
Hai Shalomb755a2a2020-04-23 21:49:02 -070048 bool eapResp; /* shared with EAPOL Backend Authentication */
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070049 struct wpabuf *eapRespData;
Hai Shalomb755a2a2020-04-23 21:49:02 -070050 bool portEnabled;
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070051 int retransWhile;
Hai Shalomb755a2a2020-04-23 21:49:02 -070052 bool eapRestart; /* shared with EAPOL Authenticator PAE */
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070053 int eapSRTT;
54 int eapRTTVAR;
55
56 /* Full authenticator to lower layer variables */
Hai Shalomb755a2a2020-04-23 21:49:02 -070057 bool eapReq; /* shared with EAPOL Backend Authentication */
58 bool eapNoReq; /* shared with EAPOL Backend Authentication */
59 bool eapSuccess;
60 bool eapFail;
61 bool eapTimeout;
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070062 struct wpabuf *eapReqData;
63 u8 *eapKeyData;
64 size_t eapKeyDataLen;
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -080065 u8 *eapSessionId;
66 size_t eapSessionIdLen;
Hai Shalomb755a2a2020-04-23 21:49:02 -070067 bool eapKeyAvailable; /* called keyAvailable in IEEE 802.1X-2004 */
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070068
69 /* AAA interface to full authenticator variables */
Hai Shalomb755a2a2020-04-23 21:49:02 -070070 bool aaaEapReq;
71 bool aaaEapNoReq;
72 bool aaaSuccess;
73 bool aaaFail;
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070074 struct wpabuf *aaaEapReqData;
75 u8 *aaaEapKeyData;
76 size_t aaaEapKeyDataLen;
Hai Shalomb755a2a2020-04-23 21:49:02 -070077 bool aaaEapKeyAvailable;
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070078 int aaaMethodTimeout;
79
80 /* Full authenticator to AAA interface variables */
Hai Shalomb755a2a2020-04-23 21:49:02 -070081 bool aaaEapResp;
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070082 struct wpabuf *aaaEapRespData;
83 /* aaaIdentity -> eap_get_identity() */
Hai Shalomb755a2a2020-04-23 21:49:02 -070084 bool aaaTimeout;
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070085};
86
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -080087struct eap_server_erp_key {
88 struct dl_list list;
89 size_t rRK_len;
90 size_t rIK_len;
91 u8 rRK[ERP_MAX_KEY_LEN];
92 u8 rIK[ERP_MAX_KEY_LEN];
93 u32 recv_seq;
94 u8 cryptosuite;
95 char keyname_nai[];
96};
97
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070098struct eapol_callbacks {
99 int (*get_eap_user)(void *ctx, const u8 *identity, size_t identity_len,
100 int phase2, struct eap_user *user);
101 const char * (*get_eap_req_id_text)(void *ctx, size_t *len);
Dmitry Shmidt818ea482014-03-10 13:15:21 -0700102 void (*log_msg)(void *ctx, const char *msg);
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800103 int (*get_erp_send_reauth_start)(void *ctx);
104 const char * (*get_erp_domain)(void *ctx);
105 struct eap_server_erp_key * (*erp_get_key)(void *ctx,
106 const char *keyname);
107 int (*erp_add_key)(void *ctx, struct eap_server_erp_key *erp);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700108};
109
110struct eap_config {
Hai Shalomc3565922019-10-28 11:58:20 -0700111 /**
112 * ssl_ctx - TLS context
113 *
114 * This is passed to the EAP server implementation as a callback
115 * context for TLS operations.
116 */
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700117 void *ssl_ctx;
118 void *msg_ctx;
Hai Shalomc3565922019-10-28 11:58:20 -0700119
120 /**
121 * eap_sim_db_priv - EAP-SIM/AKA database context
122 *
123 * This is passed to the EAP-SIM/AKA server implementation as a
124 * callback context.
125 */
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700126 void *eap_sim_db_priv;
Sunil Ravia04bd252022-05-02 22:54:18 -0700127
128 struct crypto_rsa_key *imsi_privacy_key;
129
Hai Shalomb755a2a2020-04-23 21:49:02 -0700130 bool backend_auth;
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700131 int eap_server;
Hai Shalomc3565922019-10-28 11:58:20 -0700132
133 /**
134 * pwd_group - The D-H group assigned for EAP-pwd
135 *
136 * If EAP-pwd is not used it can be set to zero.
137 */
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700138 u16 pwd_group;
Hai Shalomc3565922019-10-28 11:58:20 -0700139
140 /**
141 * pac_opaque_encr_key - PAC-Opaque encryption key for EAP-FAST
142 *
143 * This parameter is used to set a key for EAP-FAST to encrypt the
144 * PAC-Opaque data. It can be set to %NULL if EAP-FAST is not used. If
145 * set, must point to a 16-octet key.
146 */
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700147 u8 *pac_opaque_encr_key;
Hai Shalomc3565922019-10-28 11:58:20 -0700148
149 /**
150 * eap_fast_a_id - EAP-FAST authority identity (A-ID)
151 *
152 * If EAP-FAST is not used, this can be set to %NULL. In theory, this
153 * is a variable length field, but due to some existing implementations
154 * requiring A-ID to be 16 octets in length, it is recommended to use
155 * that length for the field to provide interoperability with deployed
156 * peer implementations.
157 */
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700158 u8 *eap_fast_a_id;
Hai Shalomc3565922019-10-28 11:58:20 -0700159
160 /**
161 * eap_fast_a_id_len - Length of eap_fast_a_id buffer in octets
162 */
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700163 size_t eap_fast_a_id_len;
Hai Shalomc3565922019-10-28 11:58:20 -0700164 /**
165 * eap_fast_a_id_info - EAP-FAST authority identifier information
166 *
167 * This A-ID-Info contains a user-friendly name for the A-ID. For
168 * example, this could be the enterprise and server names in
169 * human-readable format. This field is encoded as UTF-8. If EAP-FAST
170 * is not used, this can be set to %NULL.
171 */
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700172 char *eap_fast_a_id_info;
Hai Shalomc3565922019-10-28 11:58:20 -0700173
174 /**
175 * eap_fast_prov - EAP-FAST provisioning modes
176 *
177 * 0 = provisioning disabled, 1 = only anonymous provisioning allowed,
178 * 2 = only authenticated provisioning allowed, 3 = both provisioning
179 * modes allowed.
180 */
181 enum {
182 NO_PROV, ANON_PROV, AUTH_PROV, BOTH_PROV
183 } eap_fast_prov;
184
185 /**
186 * pac_key_lifetime - EAP-FAST PAC-Key lifetime in seconds
187 *
188 * This is the hard limit on how long a provisioned PAC-Key can be
189 * used.
190 */
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700191 int pac_key_lifetime;
Hai Shalomc3565922019-10-28 11:58:20 -0700192
193 /**
194 * pac_key_refresh_time - EAP-FAST PAC-Key refresh time in seconds
195 *
196 * This is a soft limit on the PAC-Key. The server will automatically
197 * generate a new PAC-Key when this number of seconds (or fewer) of the
198 * lifetime remains.
199 */
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700200 int pac_key_refresh_time;
Hai Shalom81f62d82019-07-22 12:10:00 -0700201 int eap_teap_auth;
202 int eap_teap_pac_no_inner;
Hai Shalomc3565922019-10-28 11:58:20 -0700203 int eap_teap_separate_result;
204 enum eap_teap_id {
205 EAP_TEAP_ID_ALLOW_ANY = 0,
206 EAP_TEAP_ID_REQUIRE_USER = 1,
207 EAP_TEAP_ID_REQUIRE_MACHINE = 2,
208 EAP_TEAP_ID_REQUEST_USER_ACCEPT_MACHINE = 3,
209 EAP_TEAP_ID_REQUEST_MACHINE_ACCEPT_USER = 4,
210 EAP_TEAP_ID_REQUIRE_USER_AND_MACHINE = 5,
211 } eap_teap_id;
Sunil Ravi38ad1ed2023-01-17 23:58:31 +0000212 int eap_teap_method_sequence;
Hai Shalomc3565922019-10-28 11:58:20 -0700213
214 /**
215 * eap_sim_aka_result_ind - EAP-SIM/AKA protected success indication
216 *
217 * This controls whether the protected success/failure indication
218 * (AT_RESULT_IND) is used with EAP-SIM and EAP-AKA.
219 */
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700220 int eap_sim_aka_result_ind;
Hai Shalomc3565922019-10-28 11:58:20 -0700221 int eap_sim_id;
222
Sunil Ravi2a14cf12023-11-21 00:54:38 +0000223 /* Maximum number of fast re-authentications allowed after each full
224 * EAP-SIM/AKA authentication. */
225 int eap_sim_aka_fast_reauth_limit;
226
Hai Shalomc3565922019-10-28 11:58:20 -0700227 /**
228 * tnc - Trusted Network Connect (TNC)
229 *
230 * This controls whether TNC is enabled and will be required before the
231 * peer is allowed to connect. Note: This is only used with EAP-TTLS
232 * and EAP-FAST. If any other EAP method is enabled, the peer will be
233 * allowed to connect without TNC.
234 */
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700235 int tnc;
Hai Shalomc3565922019-10-28 11:58:20 -0700236
237 /**
238 * wps - Wi-Fi Protected Setup context
239 *
240 * If WPS is used with an external RADIUS server (which is quite
241 * unlikely configuration), this is used to provide a pointer to WPS
242 * context data. Normally, this can be set to %NULL.
243 */
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700244 struct wps_context *wps;
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700245 int fragment_size;
Jouni Malinen87fd2792011-05-16 18:35:42 +0300246
247 int pbc_in_m1;
Dmitry Shmidt34af3062013-07-11 10:46:32 -0700248
Hai Shalomc3565922019-10-28 11:58:20 -0700249 /**
250 * server_id - Server identity
251 */
252 u8 *server_id;
Dmitry Shmidt34af3062013-07-11 10:46:32 -0700253 size_t server_id_len;
Hai Shalomc3565922019-10-28 11:58:20 -0700254
255 /**
256 * erp - Whether EAP Re-authentication Protocol (ERP) is enabled
257 *
258 * This controls whether the authentication server derives ERP key
259 * hierarchy (rRK and rIK) from full EAP authentication and allows
260 * these keys to be used to perform ERP to derive rMSK instead of full
261 * EAP authentication to derive MSK.
262 */
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800263 int erp;
Dmitry Shmidtd80a4012015-11-05 16:35:40 -0800264 unsigned int tls_session_lifetime;
Dmitry Shmidtd2986c22017-10-23 14:22:09 -0700265 unsigned int tls_flags;
Dmitry Shmidt818ea482014-03-10 13:15:21 -0700266
Hai Shalomc3565922019-10-28 11:58:20 -0700267 unsigned int max_auth_rounds;
268 unsigned int max_auth_rounds_short;
Sunil Ravia04bd252022-05-02 22:54:18 -0700269
270#ifdef CONFIG_TESTING_OPTIONS
271 bool skip_prot_success;
272#endif /* CONFIG_TESTING_OPTIONS */
Hai Shalomc3565922019-10-28 11:58:20 -0700273};
274
275struct eap_session_data {
276 const struct wpabuf *assoc_wps_ie;
277 const struct wpabuf *assoc_p2p_ie;
278 const u8 *peer_addr;
Dmitry Shmidt818ea482014-03-10 13:15:21 -0700279#ifdef CONFIG_TESTING_OPTIONS
280 u32 tls_test_flags;
281#endif /* CONFIG_TESTING_OPTIONS */
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700282};
283
284
285struct eap_sm * eap_server_sm_init(void *eapol_ctx,
Dmitry Shmidt1d755d02015-04-28 10:34:29 -0700286 const struct eapol_callbacks *eapol_cb,
Hai Shalomc3565922019-10-28 11:58:20 -0700287 const struct eap_config *conf,
288 const struct eap_session_data *sess);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700289void eap_server_sm_deinit(struct eap_sm *sm);
290int eap_server_sm_step(struct eap_sm *sm);
291void eap_sm_notify_cached(struct eap_sm *sm);
292void eap_sm_pending_cb(struct eap_sm *sm);
293int eap_sm_method_pending(struct eap_sm *sm);
294const u8 * eap_get_identity(struct eap_sm *sm, size_t *len);
Hai Shalom39ba6fc2019-01-22 12:40:38 -0800295const char * eap_get_serial_num(struct eap_sm *sm);
Hai Shalom74f70d42019-02-11 14:42:39 -0800296const char * eap_get_method(struct eap_sm *sm);
297const char * eap_get_imsi(struct eap_sm *sm);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700298struct eap_eapol_interface * eap_get_interface(struct eap_sm *sm);
299void eap_server_clear_identity(struct eap_sm *sm);
Dmitry Shmidtaf9da312015-04-03 10:03:11 -0700300void eap_server_mschap_rx_callback(struct eap_sm *sm, const char *source,
301 const u8 *username, size_t username_len,
302 const u8 *challenge, const u8 *response);
Dmitry Shmidt9839ecd2016-11-07 11:05:47 -0800303void eap_erp_update_identity(struct eap_sm *sm, const u8 *eap, size_t len);
Hai Shalom021b0b52019-04-10 11:17:58 -0700304void eap_user_free(struct eap_user *user);
Hai Shalomc3565922019-10-28 11:58:20 -0700305void eap_server_config_free(struct eap_config *cfg);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700306
307#endif /* EAP_H */