4 * @brief Interface eap_method_t.
9 * Copyright (C) 2006 Martin Willi
10 * Hochschule fuer Technik Rapperswil
12 * This program is free software; you can redistribute it and/or modify it
13 * under the terms of the GNU General Public License as published by the
14 * Free Software Foundation; either version 2 of the License, or (at your
15 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
19 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
26 typedef struct eap_method_t eap_method_t
;
27 typedef enum eap_role_t eap_role_t
;
28 typedef enum eap_type_t eap_type_t
;
29 typedef enum eap_code_t eap_code_t
;
32 #include <utils/identification.h>
33 #include <encoding/payloads/eap_payload.h>
36 * Role of an eap_method, SERVER or PEER (client)
45 * enum names for eap_role_t.
49 extern enum_name_t
*eap_role_names
;
52 * EAP types, defines the EAP method implementation
61 EAP_ONE_TIME_PASSWORD
= 5,
67 * enum names for eap_type_t.
71 extern enum_name_t
*eap_type_names
;
74 * EAP code, type of an EAP message
86 * enum names for eap_code_t.
90 extern enum_name_t
*eap_code_names
;
94 * @brief Interface of an EAP method for server and client side.
96 * An EAP method initiates an EAP exchange and processes requests and
97 * responses. An EAP method may need multiple exchanges before succeeding, and
98 * the eap_authentication may use multiple EAP methods to authenticate a peer.
99 * To accomplish these requirements, all EAP methods have their own
100 * implementation while the eap_authenticatior uses one or more of these
101 * EAP methods. Sending of EAP(SUCCESS/FAILURE) message is not the job
102 * of the method, the eap_authenticator does this.
103 * An EAP method may establish a MSK, this is used the complete the
104 * authentication. Even if a mutual EAP method is used, the traditional
105 * AUTH payloads are required. Only these include the nonces and messages from
106 * ike_sa_init and therefore prevent man in the middle attacks.
109 * - eap_method_create()
113 struct eap_method_t
{
116 * @brief Initiate the EAP exchange.
118 * initiate() is only useable for server implementations, as clients only
119 * reply to server requests.
120 * A eap_payload is created in "out" if result is NEED_MORE.
122 * @param this calling object
123 * @param out eap_payload to send to the client
125 * - NEED_MORE, if an other exchange is required
126 * - FAILED, if unable to create eap request payload
128 status_t (*initiate
) (eap_method_t
*this, eap_payload_t
**out
);
131 * @brief Process a received EAP message.
133 * A eap_payload is created in "out" if result is NEED_MORE.
135 * @param this calling object
136 * @param in eap_payload response received
137 * @param out created eap_payload to send
139 * - NEED_MORE, if an other exchange is required
140 * - FAILED, if EAP method failed
141 * - SUCCESS, if EAP method succeeded
143 status_t (*process
) (eap_method_t
*this, eap_payload_t
*in
,
144 eap_payload_t
**out
);
147 * @brief Get the EAP type implemented in this method.
149 * @param this calling object
150 * @return type of the EAP method
152 eap_type_t (*get_type
) (eap_method_t
*this);
155 * @brief Check if this EAP method authenticates the server.
157 * Some EAP methods provide mutual authentication and
158 * allow authentication using only EAP, if the peer supports it.
160 * @param this calling object
161 * @return TRUE if methods provides mutual authentication
163 bool (*is_mutual
) (eap_method_t
*this);
166 * @brief Get the MSK established by this EAP method.
168 * Not all EAP methods establish a shared secret.
170 * @param this calling object
171 * @param msk chunk receiving internal stored MSK
174 * - FAILED, if MSK not established (yet)
176 status_t (*get_msk
) (eap_method_t
*this, chunk_t
*msk
);
179 * @brief Destroys a eap_method_t object.
181 * @param this calling object
183 void (*destroy
) (eap_method_t
*this);
187 * @brief Creates an EAP method for a specific type and role.
189 * @param eap_type EAP type to use
190 * @param role role of the eap_method, server or peer
191 * @param server ID of acting server
192 * @param peer ID of involved peer (client)
193 * @return eap_method_t object
197 eap_method_t
*eap_method_create(eap_type_t eap_type
, eap_role_t role
,
198 identification_t
*server
, identification_t
*peer
);
201 * @brief (Re-)Load all EAP modules in the EAP modules directory.
203 * For security reasons, the directory and all it's modules must be owned
204 * by root and must not be writeable by someone else.
206 * @param dir directory of the EAP modules
210 void eap_method_load(char *directory
);
213 * @brief Unload all loaded EAP modules
217 void eap_method_unload();
220 * @brief Constructor definition for a pluggable EAP module.
222 * Each EAP module must define a constructor function which will return
223 * an initialized object with the methods defined in eap_method_t. The
224 * constructor must be named eap_create() and it's signature must be equal
225 * to that of eap_constructor_t.
226 * A module may implement only a single role. If it does not support the role
227 * requested, NULL should be returned. Multiple modules are allowed of the
228 * same EAP type to support seperate implementations of peer/server.
230 * @param role role the module will play, peer or server
231 * @param server ID of the server to use for credential lookup
232 * @param peer ID of the peer to use for credential lookup
233 * @return implementation of the eap_method_t interface
237 typedef eap_method_t
*(*eap_constructor_t
)(eap_role_t role
,
238 identification_t
*server
,
239 identification_t
*peer
);
241 #endif /* EAP_METHOD_H_ */