xref: /freebsd/contrib/wpa/src/eap_server/eap.h (revision 40a8ac8f62b535d30349faf28cf47106b7041b83)
1 /*
2  * hostapd / EAP Full Authenticator state machine (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 
9 #ifndef EAP_H
10 #define EAP_H
11 
12 #include "common/defs.h"
13 #include "eap_common/eap_defs.h"
14 #include "eap_server/eap_methods.h"
15 #include "wpabuf.h"
16 
17 struct eap_sm;
18 
19 #define EAP_TTLS_AUTH_PAP 1
20 #define EAP_TTLS_AUTH_CHAP 2
21 #define EAP_TTLS_AUTH_MSCHAP 4
22 #define EAP_TTLS_AUTH_MSCHAPV2 8
23 
24 struct eap_user {
25 	struct {
26 		int vendor;
27 		u32 method;
28 	} methods[EAP_MAX_METHODS];
29 	u8 *password;
30 	size_t password_len;
31 	int password_hash; /* whether password is hashed with
32 			    * nt_password_hash() */
33 	int phase2;
34 	int force_version;
35 	int ttls_auth; /* bitfield of
36 			* EAP_TTLS_AUTH_{PAP,CHAP,MSCHAP,MSCHAPV2} */
37 };
38 
39 struct eap_eapol_interface {
40 	/* Lower layer to full authenticator variables */
41 	Boolean eapResp; /* shared with EAPOL Backend Authentication */
42 	struct wpabuf *eapRespData;
43 	Boolean portEnabled;
44 	int retransWhile;
45 	Boolean eapRestart; /* shared with EAPOL Authenticator PAE */
46 	int eapSRTT;
47 	int eapRTTVAR;
48 
49 	/* Full authenticator to lower layer variables */
50 	Boolean eapReq; /* shared with EAPOL Backend Authentication */
51 	Boolean eapNoReq; /* shared with EAPOL Backend Authentication */
52 	Boolean eapSuccess;
53 	Boolean eapFail;
54 	Boolean eapTimeout;
55 	struct wpabuf *eapReqData;
56 	u8 *eapKeyData;
57 	size_t eapKeyDataLen;
58 	Boolean eapKeyAvailable; /* called keyAvailable in IEEE 802.1X-2004 */
59 
60 	/* AAA interface to full authenticator variables */
61 	Boolean aaaEapReq;
62 	Boolean aaaEapNoReq;
63 	Boolean aaaSuccess;
64 	Boolean aaaFail;
65 	struct wpabuf *aaaEapReqData;
66 	u8 *aaaEapKeyData;
67 	size_t aaaEapKeyDataLen;
68 	Boolean aaaEapKeyAvailable;
69 	int aaaMethodTimeout;
70 
71 	/* Full authenticator to AAA interface variables */
72 	Boolean aaaEapResp;
73 	struct wpabuf *aaaEapRespData;
74 	/* aaaIdentity -> eap_get_identity() */
75 	Boolean aaaTimeout;
76 };
77 
78 struct eapol_callbacks {
79 	int (*get_eap_user)(void *ctx, const u8 *identity, size_t identity_len,
80 			    int phase2, struct eap_user *user);
81 	const char * (*get_eap_req_id_text)(void *ctx, size_t *len);
82 };
83 
84 struct eap_config {
85 	void *ssl_ctx;
86 	void *msg_ctx;
87 	void *eap_sim_db_priv;
88 	Boolean backend_auth;
89 	int eap_server;
90 	u16 pwd_group;
91 	u8 *pac_opaque_encr_key;
92 	u8 *eap_fast_a_id;
93 	size_t eap_fast_a_id_len;
94 	char *eap_fast_a_id_info;
95 	int eap_fast_prov;
96 	int pac_key_lifetime;
97 	int pac_key_refresh_time;
98 	int eap_sim_aka_result_ind;
99 	int tnc;
100 	struct wps_context *wps;
101 	const struct wpabuf *assoc_wps_ie;
102 	const struct wpabuf *assoc_p2p_ie;
103 	const u8 *peer_addr;
104 	int fragment_size;
105 
106 	int pbc_in_m1;
107 };
108 
109 
110 struct eap_sm * eap_server_sm_init(void *eapol_ctx,
111 				   struct eapol_callbacks *eapol_cb,
112 				   struct eap_config *eap_conf);
113 void eap_server_sm_deinit(struct eap_sm *sm);
114 int eap_server_sm_step(struct eap_sm *sm);
115 void eap_sm_notify_cached(struct eap_sm *sm);
116 void eap_sm_pending_cb(struct eap_sm *sm);
117 int eap_sm_method_pending(struct eap_sm *sm);
118 const u8 * eap_get_identity(struct eap_sm *sm, size_t *len);
119 struct eap_eapol_interface * eap_get_interface(struct eap_sm *sm);
120 void eap_server_clear_identity(struct eap_sm *sm);
121 
122 #endif /* EAP_H */
123