2 * Copyright (C) 2006 Martin Willi
3 * Hochschule fuer Technik Rapperswil
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19 * @defgroup eap_method eap_method
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)
43 * enum names for eap_role_t.
45 extern enum_name_t
*eap_role_names
;
48 * EAP types, defines the EAP method implementation
61 EAP_EXPERIMENTAL
= 255,
65 * enum names for eap_type_t.
67 extern enum_name_t
*eap_type_names
;
70 * EAP code, type of an EAP message
80 * enum names for eap_code_t.
82 extern enum_name_t
*eap_code_names
;
86 * Interface of an EAP method for server and client side.
88 * An EAP method initiates an EAP exchange and processes requests and
89 * responses. An EAP method may need multiple exchanges before succeeding, and
90 * the eap_authentication may use multiple EAP methods to authenticate a peer.
91 * To accomplish these requirements, all EAP methods have their own
92 * implementation while the eap_authenticatior uses one or more of these
93 * EAP methods. Sending of EAP(SUCCESS/FAILURE) message is not the job
94 * of the method, the eap_authenticator does this.
95 * An EAP method may establish a MSK, this is used the complete the
96 * authentication. Even if a mutual EAP method is used, the traditional
97 * AUTH payloads are required. Only these include the nonces and messages from
98 * ike_sa_init and therefore prevent man in the middle attacks.
99 * The EAP method must use an initial EAP identifier value != 0, as a preceding
100 * EAP-Identity exchange always uses identifier 0.
102 struct eap_method_t
{
105 * Initiate the EAP exchange.
107 * initiate() is only useable for server implementations, as clients only
108 * reply to server requests.
109 * A eap_payload is created in "out" if result is NEED_MORE.
111 * @param out eap_payload to send to the client
113 * - NEED_MORE, if an other exchange is required
114 * - FAILED, if unable to create eap request payload
116 status_t (*initiate
) (eap_method_t
*this, eap_payload_t
**out
);
119 * Process a received EAP message.
121 * A eap_payload is created in "out" if result is NEED_MORE.
123 * @param in eap_payload response received
124 * @param out created eap_payload to send
126 * - NEED_MORE, if an other exchange is required
127 * - FAILED, if EAP method failed
128 * - SUCCESS, if EAP method succeeded
130 status_t (*process
) (eap_method_t
*this, eap_payload_t
*in
,
131 eap_payload_t
**out
);
134 * Get the EAP type implemented in this method.
136 * @param vendor pointer receiving vendor identifier for type, 0 for none
137 * @return type of the EAP method
139 eap_type_t (*get_type
) (eap_method_t
*this, u_int32_t
*vendor
);
142 * Check if this EAP method authenticates the server.
144 * Some EAP methods provide mutual authentication and
145 * allow authentication using only EAP, if the peer supports it.
147 * @return TRUE if methods provides mutual authentication
149 bool (*is_mutual
) (eap_method_t
*this);
152 * Get the MSK established by this EAP method.
154 * Not all EAP methods establish a shared secret. For implementations of
155 * the EAP-Identity method, get_msk() returns the received identity.
157 * @param msk chunk receiving internal stored MSK
160 * - FAILED, if MSK not established (yet)
162 status_t (*get_msk
) (eap_method_t
*this, chunk_t
*msk
);
165 * Destroys a eap_method_t object.
167 void (*destroy
) (eap_method_t
*this);
171 * Constructor definition for a pluggable EAP method.
173 * Each EAP module must define a constructor function which will return
174 * an initialized object with the methods defined in eap_method_t.
175 * Constructors for server and peers are identical, to support both roles
176 * of a EAP method, a plugin needs register two constructors in the
178 * The passed identites are of type ID_EAP and valid only during the
179 * constructor invocation.
181 * @param server ID of the server to use for credential lookup
182 * @param peer ID of the peer to use for credential lookup
183 * @return implementation of the eap_method_t interface
185 typedef eap_method_t
*(*eap_constructor_t
)(identification_t
*server
,
186 identification_t
*peer
);
188 #endif /* EAP_METHOD_H_ @} */