TLS testing: Allow hostapd to be used as a TLS testing tool
[mech_eap.git] / src / eap_server / eap.h
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         unsigned int remediation:1;
36         int ttls_auth; /* bitfield of
37                         * EAP_TTLS_AUTH_{PAP,CHAP,MSCHAP,MSCHAPV2} */
38         struct hostapd_radius_attr *accept_attr;
39 };
40
41 struct eap_eapol_interface {
42         /* Lower layer to full authenticator variables */
43         Boolean eapResp; /* shared with EAPOL Backend Authentication */
44         struct wpabuf *eapRespData;
45         Boolean portEnabled;
46         int retransWhile;
47         Boolean eapRestart; /* shared with EAPOL Authenticator PAE */
48         int eapSRTT;
49         int eapRTTVAR;
50
51         /* Full authenticator to lower layer variables */
52         Boolean eapReq; /* shared with EAPOL Backend Authentication */
53         Boolean eapNoReq; /* shared with EAPOL Backend Authentication */
54         Boolean eapSuccess;
55         Boolean eapFail;
56         Boolean eapTimeout;
57         struct wpabuf *eapReqData;
58         u8 *eapKeyData;
59         size_t eapKeyDataLen;
60         Boolean eapKeyAvailable; /* called keyAvailable in IEEE 802.1X-2004 */
61
62         /* AAA interface to full authenticator variables */
63         Boolean aaaEapReq;
64         Boolean aaaEapNoReq;
65         Boolean aaaSuccess;
66         Boolean aaaFail;
67         struct wpabuf *aaaEapReqData;
68         u8 *aaaEapKeyData;
69         size_t aaaEapKeyDataLen;
70         Boolean aaaEapKeyAvailable;
71         int aaaMethodTimeout;
72
73         /* Full authenticator to AAA interface variables */
74         Boolean aaaEapResp;
75         struct wpabuf *aaaEapRespData;
76         /* aaaIdentity -> eap_get_identity() */
77         Boolean aaaTimeout;
78 };
79
80 struct eapol_callbacks {
81         int (*get_eap_user)(void *ctx, const u8 *identity, size_t identity_len,
82                             int phase2, struct eap_user *user);
83         const char * (*get_eap_req_id_text)(void *ctx, size_t *len);
84         void (*log_msg)(void *ctx, const char *msg);
85 };
86
87 struct eap_config {
88         void *ssl_ctx;
89         void *msg_ctx;
90         void *eap_sim_db_priv;
91         Boolean backend_auth;
92         int eap_server;
93         u16 pwd_group;
94         u8 *pac_opaque_encr_key;
95         u8 *eap_fast_a_id;
96         size_t eap_fast_a_id_len;
97         char *eap_fast_a_id_info;
98         int eap_fast_prov;
99         int pac_key_lifetime;
100         int pac_key_refresh_time;
101         int eap_sim_aka_result_ind;
102         int tnc;
103         struct wps_context *wps;
104         const struct wpabuf *assoc_wps_ie;
105         const struct wpabuf *assoc_p2p_ie;
106         const u8 *peer_addr;
107         int fragment_size;
108
109         int pbc_in_m1;
110
111         const u8 *server_id;
112         size_t server_id_len;
113
114 #ifdef CONFIG_TESTING_OPTIONS
115         u32 tls_test_flags;
116 #endif /* CONFIG_TESTING_OPTIONS */
117 };
118
119
120 struct eap_sm * eap_server_sm_init(void *eapol_ctx,
121                                    struct eapol_callbacks *eapol_cb,
122                                    struct eap_config *eap_conf);
123 void eap_server_sm_deinit(struct eap_sm *sm);
124 int eap_server_sm_step(struct eap_sm *sm);
125 void eap_sm_notify_cached(struct eap_sm *sm);
126 void eap_sm_pending_cb(struct eap_sm *sm);
127 int eap_sm_method_pending(struct eap_sm *sm);
128 const u8 * eap_get_identity(struct eap_sm *sm, size_t *len);
129 struct eap_eapol_interface * eap_get_interface(struct eap_sm *sm);
130 void eap_server_clear_identity(struct eap_sm *sm);
131
132 #endif /* EAP_H */