Add HAMMER support to the installer
[dragonfly.git] / contrib / hostapd-0.5.8 / eap_i.h
1 /*
2  * hostapd / EAP Authenticator state machine internal structures (RFC 4137)
3  * Copyright (c) 2004-2005, 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
15 #ifndef EAP_I_H
16 #define EAP_I_H
17
18 #include "eap.h"
19
20 /* RFC 4137 - EAP Standalone Authenticator */
21
22 /**
23  * struct eap_method - EAP method interface
24  * This structure defines the EAP method interface. Each method will need to
25  * register its own EAP type, EAP name, and set of function pointers for method
26  * specific operations. This interface is based on section 5.4 of RFC 4137.
27  */
28 struct eap_method {
29         int vendor;
30         EapType method;
31         const char *name;
32
33         void * (*init)(struct eap_sm *sm);
34         void * (*initPickUp)(struct eap_sm *sm);
35         void (*reset)(struct eap_sm *sm, void *priv);
36
37         u8 * (*buildReq)(struct eap_sm *sm, void *priv, int id,
38                          size_t *reqDataLen);
39         int (*getTimeout)(struct eap_sm *sm, void *priv);
40         Boolean (*check)(struct eap_sm *sm, void *priv,
41                          u8 *respData, size_t respDataLen);
42         void (*process)(struct eap_sm *sm, void *priv,
43                         u8 *respData, size_t respDataLen);
44         Boolean (*isDone)(struct eap_sm *sm, void *priv);
45         u8 * (*getKey)(struct eap_sm *sm, void *priv, size_t *len);
46         /* isSuccess is not specified in draft-ietf-eap-statemachine-05.txt,
47          * but it is useful in implementing Policy.getDecision() */
48         Boolean (*isSuccess)(struct eap_sm *sm, void *priv);
49
50         /**
51          * free - Free EAP method data
52          * @method: Pointer to the method data registered with
53          * eap_server_method_register().
54          *
55          * This function will be called when the EAP method is being
56          * unregistered. If the EAP method allocated resources during
57          * registration (e.g., allocated struct eap_method), they should be
58          * freed in this function. No other method functions will be called
59          * after this call. If this function is not defined (i.e., function
60          * pointer is %NULL), a default handler is used to release the method
61          * data with free(method). This is suitable for most cases.
62          */
63         void (*free)(struct eap_method *method);
64
65 #define EAP_SERVER_METHOD_INTERFACE_VERSION 1
66         /**
67          * version - Version of the EAP server method interface
68          *
69          * The EAP server method implementation should set this variable to
70          * EAP_SERVER_METHOD_INTERFACE_VERSION. This is used to verify that the
71          * EAP method is using supported API version when using dynamically
72          * loadable EAP methods.
73          */
74         int version;
75
76         /**
77          * next - Pointer to the next EAP method
78          *
79          * This variable is used internally in the EAP method registration code
80          * to create a linked list of registered EAP methods.
81          */
82         struct eap_method *next;
83
84         /**
85          * get_emsk - Get EAP method specific keying extended material (EMSK)
86          * @sm: Pointer to EAP state machine allocated with eap_sm_init()
87          * @priv: Pointer to private EAP method data from eap_method::init()
88          * @len: Pointer to a variable to store EMSK length
89          * Returns: EMSK or %NULL if not available
90          *
91          * This function can be used to get the extended keying material from
92          * the EAP method. The key may already be stored in the method-specific
93          * private data or this function may derive the key.
94          */
95         u8 * (*get_emsk)(struct eap_sm *sm, void *priv, size_t *len);
96 };
97
98 /**
99  * struct eap_sm - EAP server state machine data
100  */
101 struct eap_sm {
102         enum {
103                 EAP_DISABLED, EAP_INITIALIZE, EAP_IDLE, EAP_RECEIVED,
104                 EAP_INTEGRITY_CHECK, EAP_METHOD_RESPONSE, EAP_METHOD_REQUEST,
105                 EAP_PROPOSE_METHOD, EAP_SELECT_ACTION, EAP_SEND_REQUEST,
106                 EAP_DISCARD, EAP_NAK, EAP_RETRANSMIT, EAP_SUCCESS, EAP_FAILURE,
107                 EAP_TIMEOUT_FAILURE, EAP_PICK_UP_METHOD
108         } EAP_state;
109
110         /* Constants */
111         int MaxRetrans;
112
113         /* Lower layer to standalone authenticator variables */
114         /* eapResp: eapol_sm->be_auth.eapResp */
115         /* portEnabled: eapol_sm->portEnabled */
116         /* eapRestart: eapol_sm->auth_pae.eapRestart */
117         u8 *eapRespData;
118         size_t eapRespDataLen;
119         int retransWhile;
120         int eapSRTT;
121         int eapRTTVAR;
122
123         /* Standalone authenticator to lower layer variables */
124         /* eapReq: eapol_sm->be_auth.eapReq */
125         /* eapNoReq: eapol_sm->be_auth.eapNoReq */
126         /* eapSuccess: eapol_sm->eapSuccess */
127         /* eapFail: eapol_sm->eapFail */
128         /* eapTimeout: eapol_sm->eapTimeout */
129         u8 *eapReqData;
130         size_t eapReqDataLen;
131         u8 *eapKeyData; /* also eapKeyAvailable (boolean) */
132         size_t eapKeyDataLen;
133
134         /* Standalone authenticator state machine local variables */
135
136         /* Long-term (maintained betwen packets) */
137         EapType currentMethod;
138         int currentId;
139         enum {
140                 METHOD_PROPOSED, METHOD_CONTINUE, METHOD_END
141         } methodState;
142         int retransCount;
143         u8 *lastReqData;
144         size_t lastReqDataLen;
145         int methodTimeout;
146
147         /* Short-term (not maintained between packets) */
148         Boolean rxResp;
149         int respId;
150         EapType respMethod;
151         int respVendor;
152         u32 respVendorMethod;
153         Boolean ignore;
154         enum {
155                 DECISION_SUCCESS, DECISION_FAILURE, DECISION_CONTINUE
156         } decision;
157
158         /* Miscellaneous variables */
159         const struct eap_method *m; /* selected EAP method */
160         /* not defined in draft-ietf-eap-statemachine-02 */
161         Boolean changed;
162         void *eapol_ctx, *msg_ctx;
163         struct eapol_callbacks *eapol_cb;
164         void *eap_method_priv;
165         u8 *identity;
166         size_t identity_len;
167         int lastId; /* Identifier used in the last EAP-Packet */
168         struct eap_user *user;
169         int user_eap_method_index;
170         int init_phase2;
171         void *ssl_ctx;
172         enum { TLV_REQ_NONE, TLV_REQ_SUCCESS, TLV_REQ_FAILURE } tlv_request;
173         void *eap_sim_db_priv;
174         Boolean backend_auth;
175         Boolean update_user;
176
177         int num_rounds;
178         enum {
179                 METHOD_PENDING_NONE, METHOD_PENDING_WAIT, METHOD_PENDING_CONT
180         } method_pending;
181 };
182
183 int eap_user_get(struct eap_sm *sm, const u8 *identity, size_t identity_len,
184                  int phase2);
185 void eap_sm_process_nak(struct eap_sm *sm, u8 *nak_list, size_t len);
186 const u8 * eap_hdr_validate(int vendor, EapType eap_type,
187                             const u8 *msg, size_t msglen, size_t *plen);
188 struct eap_hdr * eap_msg_alloc(int vendor, EapType type, size_t *len,
189                                size_t payload_len, u8 code, u8 identifier,
190                                u8 **payload);
191
192 #endif /* EAP_I_H */