xref: /dflybsd-src/contrib/wpa_supplicant/src/radius/radius_server.h (revision 3a84a4273475ed07d0ab1c2dfeffdfedef35d9cd)
16d49e1aeSJan Lentfer /*
23ff40c12SJohn Marino  * RADIUS authentication server
33ff40c12SJohn Marino  * Copyright (c) 2005-2009, 2011, Jouni Malinen <j@w1.fi>
46d49e1aeSJan Lentfer  *
53ff40c12SJohn Marino  * This software may be distributed under the terms of the BSD license.
63ff40c12SJohn Marino  * See README for more details.
76d49e1aeSJan Lentfer  */
86d49e1aeSJan Lentfer 
96d49e1aeSJan Lentfer #ifndef RADIUS_SERVER_H
106d49e1aeSJan Lentfer #define RADIUS_SERVER_H
116d49e1aeSJan Lentfer 
126d49e1aeSJan Lentfer struct radius_server_data;
136d49e1aeSJan Lentfer struct eap_user;
146d49e1aeSJan Lentfer 
153ff40c12SJohn Marino /**
163ff40c12SJohn Marino  * struct radius_server_conf - RADIUS server configuration
173ff40c12SJohn Marino  */
186d49e1aeSJan Lentfer struct radius_server_conf {
193ff40c12SJohn Marino 	/**
203ff40c12SJohn Marino 	 * auth_port - UDP port to listen to as an authentication server
213ff40c12SJohn Marino 	 */
226d49e1aeSJan Lentfer 	int auth_port;
233ff40c12SJohn Marino 
243ff40c12SJohn Marino 	/**
25*a1157835SDaniel Fojt 	 * acct_port - UDP port to listen to as an accounting server
26*a1157835SDaniel Fojt 	 */
27*a1157835SDaniel Fojt 	int acct_port;
28*a1157835SDaniel Fojt 
29*a1157835SDaniel Fojt 	/**
303ff40c12SJohn Marino 	 * client_file - RADIUS client configuration file
313ff40c12SJohn Marino 	 *
323ff40c12SJohn Marino 	 * This file contains the RADIUS clients and the shared secret to be
333ff40c12SJohn Marino 	 * used with them in a format where each client is on its own line. The
343ff40c12SJohn Marino 	 * first item on the line is the IPv4 or IPv6 address of the client
353ff40c12SJohn Marino 	 * with an optional address mask to allow full network to be specified
363ff40c12SJohn Marino 	 * (e.g., 192.168.1.2 or 192.168.1.0/24). This is followed by white
373ff40c12SJohn Marino 	 * space (space or tabulator) and the shared secret. Lines starting
383ff40c12SJohn Marino 	 * with '#' are skipped and can be used as comments.
393ff40c12SJohn Marino 	 */
406d49e1aeSJan Lentfer 	char *client_file;
413ff40c12SJohn Marino 
423ff40c12SJohn Marino 	/**
43*a1157835SDaniel Fojt 	 * sqlite_file - SQLite database for storing debug log information
44*a1157835SDaniel Fojt 	 */
45*a1157835SDaniel Fojt 	const char *sqlite_file;
46*a1157835SDaniel Fojt 
47*a1157835SDaniel Fojt 	/**
483ff40c12SJohn Marino 	 * conf_ctx - Context pointer for callbacks
493ff40c12SJohn Marino 	 *
503ff40c12SJohn Marino 	 * This is used as the ctx argument in get_eap_user() calls.
513ff40c12SJohn Marino 	 */
526d49e1aeSJan Lentfer 	void *conf_ctx;
533ff40c12SJohn Marino 
543ff40c12SJohn Marino 	/**
553ff40c12SJohn Marino 	 * eap_sim_db_priv - EAP-SIM/AKA database context
563ff40c12SJohn Marino 	 *
573ff40c12SJohn Marino 	 * This is passed to the EAP-SIM/AKA server implementation as a
583ff40c12SJohn Marino 	 * callback context.
593ff40c12SJohn Marino 	 */
606d49e1aeSJan Lentfer 	void *eap_sim_db_priv;
613ff40c12SJohn Marino 
623ff40c12SJohn Marino 	/**
633ff40c12SJohn Marino 	 * ssl_ctx - TLS context
643ff40c12SJohn Marino 	 *
653ff40c12SJohn Marino 	 * This is passed to the EAP server implementation as a callback
663ff40c12SJohn Marino 	 * context for TLS operations.
673ff40c12SJohn Marino 	 */
686d49e1aeSJan Lentfer 	void *ssl_ctx;
693ff40c12SJohn Marino 
703ff40c12SJohn Marino 	/**
713ff40c12SJohn Marino 	 * pac_opaque_encr_key - PAC-Opaque encryption key for EAP-FAST
723ff40c12SJohn Marino 	 *
733ff40c12SJohn Marino 	 * This parameter is used to set a key for EAP-FAST to encrypt the
743ff40c12SJohn Marino 	 * PAC-Opaque data. It can be set to %NULL if EAP-FAST is not used. If
753ff40c12SJohn Marino 	 * set, must point to a 16-octet key.
763ff40c12SJohn Marino 	 */
776d49e1aeSJan Lentfer 	u8 *pac_opaque_encr_key;
783ff40c12SJohn Marino 
793ff40c12SJohn Marino 	/**
803ff40c12SJohn Marino 	 * eap_fast_a_id - EAP-FAST authority identity (A-ID)
813ff40c12SJohn Marino 	 *
823ff40c12SJohn Marino 	 * If EAP-FAST is not used, this can be set to %NULL. In theory, this
833ff40c12SJohn Marino 	 * is a variable length field, but due to some existing implementations
843ff40c12SJohn Marino 	 * requiring A-ID to be 16 octets in length, it is recommended to use
853ff40c12SJohn Marino 	 * that length for the field to provide interoperability with deployed
863ff40c12SJohn Marino 	 * peer implementations.
873ff40c12SJohn Marino 	 */
886d49e1aeSJan Lentfer 	u8 *eap_fast_a_id;
893ff40c12SJohn Marino 
903ff40c12SJohn Marino 	/**
913ff40c12SJohn Marino 	 * eap_fast_a_id_len - Length of eap_fast_a_id buffer in octets
923ff40c12SJohn Marino 	 */
936d49e1aeSJan Lentfer 	size_t eap_fast_a_id_len;
943ff40c12SJohn Marino 
953ff40c12SJohn Marino 	/**
963ff40c12SJohn Marino 	 * eap_fast_a_id_info - EAP-FAST authority identifier information
973ff40c12SJohn Marino 	 *
983ff40c12SJohn Marino 	 * This A-ID-Info contains a user-friendly name for the A-ID. For
993ff40c12SJohn Marino 	 * example, this could be the enterprise and server names in
1003ff40c12SJohn Marino 	 * human-readable format. This field is encoded as UTF-8. If EAP-FAST
1013ff40c12SJohn Marino 	 * is not used, this can be set to %NULL.
1023ff40c12SJohn Marino 	 */
1036d49e1aeSJan Lentfer 	char *eap_fast_a_id_info;
1043ff40c12SJohn Marino 
1053ff40c12SJohn Marino 	/**
1063ff40c12SJohn Marino 	 * eap_fast_prov - EAP-FAST provisioning modes
1073ff40c12SJohn Marino 	 *
1083ff40c12SJohn Marino 	 * 0 = provisioning disabled, 1 = only anonymous provisioning allowed,
1093ff40c12SJohn Marino 	 * 2 = only authenticated provisioning allowed, 3 = both provisioning
1103ff40c12SJohn Marino 	 * modes allowed.
1113ff40c12SJohn Marino 	 */
1126d49e1aeSJan Lentfer 	int eap_fast_prov;
1133ff40c12SJohn Marino 
1143ff40c12SJohn Marino 	/**
1153ff40c12SJohn Marino 	 * pac_key_lifetime - EAP-FAST PAC-Key lifetime in seconds
1163ff40c12SJohn Marino 	 *
1173ff40c12SJohn Marino 	 * This is the hard limit on how long a provisioned PAC-Key can be
1183ff40c12SJohn Marino 	 * used.
1193ff40c12SJohn Marino 	 */
1206d49e1aeSJan Lentfer 	int pac_key_lifetime;
1213ff40c12SJohn Marino 
1223ff40c12SJohn Marino 	/**
1233ff40c12SJohn Marino 	 * pac_key_refresh_time - EAP-FAST PAC-Key refresh time in seconds
1243ff40c12SJohn Marino 	 *
1253ff40c12SJohn Marino 	 * This is a soft limit on the PAC-Key. The server will automatically
1263ff40c12SJohn Marino 	 * generate a new PAC-Key when this number of seconds (or fewer) of the
1273ff40c12SJohn Marino 	 * lifetime remains.
1283ff40c12SJohn Marino 	 */
1296d49e1aeSJan Lentfer 	int pac_key_refresh_time;
1303ff40c12SJohn Marino 
131*a1157835SDaniel Fojt 	int eap_teap_auth;
132*a1157835SDaniel Fojt 	int eap_teap_pac_no_inner;
133*a1157835SDaniel Fojt 
1343ff40c12SJohn Marino 	/**
1353ff40c12SJohn Marino 	 * eap_sim_aka_result_ind - EAP-SIM/AKA protected success indication
1363ff40c12SJohn Marino 	 *
1373ff40c12SJohn Marino 	 * This controls whether the protected success/failure indication
1383ff40c12SJohn Marino 	 * (AT_RESULT_IND) is used with EAP-SIM and EAP-AKA.
1393ff40c12SJohn Marino 	 */
1406d49e1aeSJan Lentfer 	int eap_sim_aka_result_ind;
1413ff40c12SJohn Marino 
142*a1157835SDaniel Fojt 	int eap_sim_id;
143*a1157835SDaniel Fojt 
1443ff40c12SJohn Marino 	/**
1453ff40c12SJohn Marino 	 * tnc - Trusted Network Connect (TNC)
1463ff40c12SJohn Marino 	 *
1473ff40c12SJohn Marino 	 * This controls whether TNC is enabled and will be required before the
1483ff40c12SJohn Marino 	 * peer is allowed to connect. Note: This is only used with EAP-TTLS
1493ff40c12SJohn Marino 	 * and EAP-FAST. If any other EAP method is enabled, the peer will be
1503ff40c12SJohn Marino 	 * allowed to connect without TNC.
1513ff40c12SJohn Marino 	 */
1526d49e1aeSJan Lentfer 	int tnc;
1533ff40c12SJohn Marino 
1543ff40c12SJohn Marino 	/**
1553ff40c12SJohn Marino 	 * pwd_group - EAP-pwd D-H group
1563ff40c12SJohn Marino 	 *
1573ff40c12SJohn Marino 	 * This is used to select which D-H group to use with EAP-pwd.
1583ff40c12SJohn Marino 	 */
1593ff40c12SJohn Marino 	u16 pwd_group;
1603ff40c12SJohn Marino 
1613ff40c12SJohn Marino 	/**
1623ff40c12SJohn Marino 	 * server_id - Server identity
1633ff40c12SJohn Marino 	 */
1643ff40c12SJohn Marino 	const char *server_id;
1653ff40c12SJohn Marino 
1663ff40c12SJohn Marino 	/**
167*a1157835SDaniel Fojt 	 * erp - Whether EAP Re-authentication Protocol (ERP) is enabled
168*a1157835SDaniel Fojt 	 *
169*a1157835SDaniel Fojt 	 * This controls whether the authentication server derives ERP key
170*a1157835SDaniel Fojt 	 * hierarchy (rRK and rIK) from full EAP authentication and allows
171*a1157835SDaniel Fojt 	 * these keys to be used to perform ERP to derive rMSK instead of full
172*a1157835SDaniel Fojt 	 * EAP authentication to derive MSK.
173*a1157835SDaniel Fojt 	 */
174*a1157835SDaniel Fojt 	int erp;
175*a1157835SDaniel Fojt 
176*a1157835SDaniel Fojt 	const char *erp_domain;
177*a1157835SDaniel Fojt 
178*a1157835SDaniel Fojt 	unsigned int tls_session_lifetime;
179*a1157835SDaniel Fojt 
180*a1157835SDaniel Fojt 	unsigned int tls_flags;
181*a1157835SDaniel Fojt 
182*a1157835SDaniel Fojt 	/**
1833ff40c12SJohn Marino 	 * wps - Wi-Fi Protected Setup context
1843ff40c12SJohn Marino 	 *
1853ff40c12SJohn Marino 	 * If WPS is used with an external RADIUS server (which is quite
1863ff40c12SJohn Marino 	 * unlikely configuration), this is used to provide a pointer to WPS
1873ff40c12SJohn Marino 	 * context data. Normally, this can be set to %NULL.
1883ff40c12SJohn Marino 	 */
1896d49e1aeSJan Lentfer 	struct wps_context *wps;
1903ff40c12SJohn Marino 
1913ff40c12SJohn Marino 	/**
1923ff40c12SJohn Marino 	 * ipv6 - Whether to enable IPv6 support in the RADIUS server
1933ff40c12SJohn Marino 	 */
1946d49e1aeSJan Lentfer 	int ipv6;
1953ff40c12SJohn Marino 
1963ff40c12SJohn Marino 	/**
1973ff40c12SJohn Marino 	 * get_eap_user - Callback for fetching EAP user information
1983ff40c12SJohn Marino 	 * @ctx: Context data from conf_ctx
1993ff40c12SJohn Marino 	 * @identity: User identity
2003ff40c12SJohn Marino 	 * @identity_len: identity buffer length in octets
2013ff40c12SJohn Marino 	 * @phase2: Whether this is for Phase 2 identity
2023ff40c12SJohn Marino 	 * @user: Data structure for filling in the user information
2033ff40c12SJohn Marino 	 * Returns: 0 on success, -1 on failure
2043ff40c12SJohn Marino 	 *
2053ff40c12SJohn Marino 	 * This is used to fetch information from user database. The callback
2063ff40c12SJohn Marino 	 * will fill in information about allowed EAP methods and the user
2073ff40c12SJohn Marino 	 * password. The password field will be an allocated copy of the
2083ff40c12SJohn Marino 	 * password data and RADIUS server will free it after use.
2093ff40c12SJohn Marino 	 */
2106d49e1aeSJan Lentfer 	int (*get_eap_user)(void *ctx, const u8 *identity, size_t identity_len,
2116d49e1aeSJan Lentfer 			    int phase2, struct eap_user *user);
2123ff40c12SJohn Marino 
2133ff40c12SJohn Marino 	/**
2143ff40c12SJohn Marino 	 * eap_req_id_text - Optional data for EAP-Request/Identity
2153ff40c12SJohn Marino 	 *
2163ff40c12SJohn Marino 	 * This can be used to configure an optional, displayable message that
2173ff40c12SJohn Marino 	 * will be sent in EAP-Request/Identity. This string can contain an
2183ff40c12SJohn Marino 	 * ASCII-0 character (nul) to separate network infromation per RFC
2193ff40c12SJohn Marino 	 * 4284. The actual string length is explicit provided in
2203ff40c12SJohn Marino 	 * eap_req_id_text_len since nul character will not be used as a string
2213ff40c12SJohn Marino 	 * terminator.
2223ff40c12SJohn Marino 	 */
2236d49e1aeSJan Lentfer 	const char *eap_req_id_text;
2243ff40c12SJohn Marino 
2253ff40c12SJohn Marino 	/**
2263ff40c12SJohn Marino 	 * eap_req_id_text_len - Length of eap_req_id_text buffer in octets
2273ff40c12SJohn Marino 	 */
2286d49e1aeSJan Lentfer 	size_t eap_req_id_text_len;
2293ff40c12SJohn Marino 
2303ff40c12SJohn Marino 	/*
2313ff40c12SJohn Marino 	 * msg_ctx - Context data for wpa_msg() calls
2323ff40c12SJohn Marino 	 */
2333ff40c12SJohn Marino 	void *msg_ctx;
2343ff40c12SJohn Marino 
2353ff40c12SJohn Marino #ifdef CONFIG_RADIUS_TEST
2363ff40c12SJohn Marino 	const char *dump_msk_file;
2373ff40c12SJohn Marino #endif /* CONFIG_RADIUS_TEST */
238*a1157835SDaniel Fojt 
239*a1157835SDaniel Fojt 	char *subscr_remediation_url;
240*a1157835SDaniel Fojt 	u8 subscr_remediation_method;
241*a1157835SDaniel Fojt 	char *hs20_sim_provisioning_url;
242*a1157835SDaniel Fojt 
243*a1157835SDaniel Fojt 	char *t_c_server_url;
2446d49e1aeSJan Lentfer };
2456d49e1aeSJan Lentfer 
2466d49e1aeSJan Lentfer 
2476d49e1aeSJan Lentfer struct radius_server_data *
2486d49e1aeSJan Lentfer radius_server_init(struct radius_server_conf *conf);
2496d49e1aeSJan Lentfer 
250*a1157835SDaniel Fojt void radius_server_erp_flush(struct radius_server_data *data);
2516d49e1aeSJan Lentfer void radius_server_deinit(struct radius_server_data *data);
2526d49e1aeSJan Lentfer 
2536d49e1aeSJan Lentfer int radius_server_get_mib(struct radius_server_data *data, char *buf,
2546d49e1aeSJan Lentfer 			  size_t buflen);
2556d49e1aeSJan Lentfer 
2566d49e1aeSJan Lentfer void radius_server_eap_pending_cb(struct radius_server_data *data, void *ctx);
257*a1157835SDaniel Fojt int radius_server_dac_request(struct radius_server_data *data, const char *req);
2586d49e1aeSJan Lentfer 
2596d49e1aeSJan Lentfer #endif /* RADIUS_SERVER_H */
260