|
1 /* |
|
2 * Copyright (c) 2001-2006 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the License "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: EAP and WLAN authentication protocols. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 #if !defined(_ABS_TLS_BASE_RECORD_H_) |
|
22 #define _ABS_TLS_BASE_RECORD_H_ |
|
23 |
|
24 #include "eap_header.h" |
|
25 #include "tls_peap_types.h" |
|
26 |
|
27 class eap_buf_chain_wr_c; |
|
28 class eap_variable_data_c; |
|
29 class abs_eap_state_notification_c; |
|
30 class abs_eap_base_timer_c; |
|
31 class abs_eap_base_type_c; |
|
32 class eap_base_type_c; |
|
33 class eap_network_id_selector_c; |
|
34 class eap_am_network_id_c; |
|
35 class eap_rogue_ap_entry_c; |
|
36 class eap_master_session_key_c; |
|
37 |
|
38 |
|
39 /// The class is the interface to partner class of the tls_base_record_c class. |
|
40 /// This declares the pure virtual member functions tls_base_record_c class could call. |
|
41 class EAP_EXPORT abs_tls_base_record_c |
|
42 { |
|
43 private: |
|
44 //-------------------------------------------------- |
|
45 |
|
46 //-------------------------------------------------- |
|
47 protected: |
|
48 //-------------------------------------------------- |
|
49 |
|
50 //-------------------------------------------------- |
|
51 public: |
|
52 //-------------------------------------------------- |
|
53 |
|
54 /** |
|
55 * The destructor of the abs_tls_base_record_c class does nothing special. |
|
56 */ |
|
57 virtual ~abs_tls_base_record_c() |
|
58 { |
|
59 } |
|
60 |
|
61 /** |
|
62 * The constructor of the abs_tls_base_record_c class does nothing special. |
|
63 */ |
|
64 abs_tls_base_record_c() |
|
65 { |
|
66 } |
|
67 |
|
68 /** |
|
69 * The derived class could send packets to partner class with this function. |
|
70 * @param network_id carries the addresses (network identity) and type of the packet. |
|
71 * @param sent_packet includes the buffer for the whole packet and initialized |
|
72 * TLS-packet in correct offset. |
|
73 * @param header_offset is offset of the TLS-header within the sent_packet. |
|
74 * @param data_length is length in bytes of the TLS-packet. |
|
75 * @param buffer_length is length in bytes of the whole packet buffer. |
|
76 */ |
|
77 virtual eap_status_e tls_peap_packet_send( |
|
78 eap_buf_chain_wr_c * const sent_packet, |
|
79 const u32_t header_offset, |
|
80 const u32_t data_length, |
|
81 const u32_t buffer_length, |
|
82 const bool includes_tls_handshake_message) = 0; |
|
83 |
|
84 /** |
|
85 * The get_header_offset() function obtains the header offset of TLS-packet. |
|
86 * @param MTU_length is pointer to variable to store the maximum transfer unit (MTU). |
|
87 * MTU is the maximum TLS-packet length in bytes |
|
88 * @param trailer_length is pointer to the variable to store length |
|
89 * of trailer needed by lower levels. |
|
90 * @return Function returns the offset of TLS-header. |
|
91 * |
|
92 * The needed buffer length is ((offset) + (TLS-packet length) + (trailer)) bytes. |
|
93 * Each layer adds the length of the header to offset. |
|
94 * Each layer removes the length of the header and trailer from MTU. |
|
95 * |
|
96 * Now some ascii graphics follows. |
|
97 * @code |
|
98 * |<-------------------------buffer length----------------------------------------->| |
|
99 * | | |
|
100 * | +-----+---------------------------------+ | |
|
101 * | | TLS | data | | |
|
102 * | +-----+---------------------------------+ | |
|
103 * |<----offset--------------->|<----MTU------------------------------>|<--trailer-->| |
|
104 * | | | | |
|
105 * | | | | |
|
106 * | +-----+---------------------------------------+ | |
|
107 * | | EAP | data | | |
|
108 * | +-----+---------------------------------------+ | |
|
109 * |<----offset--------->|<----MTU------------------------------------>|<--trailer-->| |
|
110 * | | | | |
|
111 * | +-------+---------------------------------------------+ | |
|
112 * | | EAPOL | data | | |
|
113 * | +-------+---------------------------------------------+ | |
|
114 * |<--offset--->|<----MTU-------------------------------------------->|<--trailer-->| |
|
115 * | | | | |
|
116 * +-------------+-----------------------------------------------------+-------------+ |
|
117 * | ETHERNET | data | trailer | |
|
118 * +-------------+-----------------------------------------------------+-------------+ |
|
119 * |<----MTU------------------------------------------------------------------------>| |
|
120 * @endcode |
|
121 * |
|
122 */ |
|
123 virtual u32_t get_header_offset( |
|
124 u32_t * const MTU_length, |
|
125 u32_t * const trailer_length) = 0; |
|
126 |
|
127 /** |
|
128 * This function restarts authentication to send_network_id. |
|
129 * @param receive_network_id is network identity of source. |
|
130 * @param is_client_when_true indicates whether this object should act as a client (true) |
|
131 * or server (false), in terms of EAP-protocol whether this network entity is EAP-supplicant (true) |
|
132 * or EAP-authenticator (false). |
|
133 * @param force_clean_restart causes authentication restart even the current authentication is on going. |
|
134 * @param from_timer indicates whether this was called from timer (true). |
|
135 */ |
|
136 virtual eap_status_e restart_authentication( |
|
137 const eap_am_network_id_c * const receive_network_id, |
|
138 const bool is_client_when_true, |
|
139 const bool force_clean_restart, |
|
140 const bool from_timer) = 0; |
|
141 |
|
142 /** |
|
143 * The set_tls_master_secret() function gives the generated master secret and random to lower level. |
|
144 * @param eap_tls_master_session_key is pointer to the buffer of EAP-TLS master session key. |
|
145 */ |
|
146 virtual eap_status_e set_tls_master_secret( |
|
147 const eap_variable_data_c * const eap_tls_master_session_key) = 0; |
|
148 |
|
149 /** |
|
150 * The read_configure() function reads the configuration data identified |
|
151 * by the field string of field_length bytes length. Adaptation module must direct |
|
152 * the query to some persistent store. |
|
153 * @param field is generic configure string idenfying the required configure data. |
|
154 * @param field_length is length of the field string. |
|
155 * @param data is pointer to existing eap_variable_data object. |
|
156 * |
|
157 * EAP-type should store it's parameters to an own database. The own database should be accessed |
|
158 * through adaptation module of EAP-type. See eap_am_type_tls_peap_simulator_c::type_configure_read. |
|
159 */ |
|
160 virtual eap_status_e read_configure( |
|
161 const eap_configuration_field_c * const field, |
|
162 eap_variable_data_c * const data) = 0; |
|
163 |
|
164 /** |
|
165 * The write_configure() function writes the configuration data identified |
|
166 * by the field string of field_length bytes length. Adaptation module must direct |
|
167 * the action to some persistent store. |
|
168 * @param field is generic configure string idenfying the required configure data. |
|
169 * @param field_length is length of the field string. |
|
170 * @param data is pointer to existing eap_variable_data object. |
|
171 * |
|
172 * EAP-type should store it's parameters to an own database. The own database should be accessed |
|
173 * through adaptation module of EAP-type. See eap_am_type_tls_peap_simulator_c::type_configure_write. |
|
174 */ |
|
175 virtual eap_status_e write_configure( |
|
176 const eap_configuration_field_c * const field, |
|
177 eap_variable_data_c * const data) = 0; |
|
178 |
|
179 /** |
|
180 * This is notification of internal state transition. |
|
181 * This is used for notifications, debugging and protocol testing. |
|
182 * The primal notifications are eap_state_variable_e::eap_state_authentication_finished_successfully |
|
183 * and eap_state_variable_e::eap_state_authentication_terminated_unsuccessfully. EAP-type MUST send these |
|
184 * two notifications to lower layer. |
|
185 * These two notifications are sent using EAP-protocol layer (eap_protocol_layer_e::eap_protocol_layer_eap). |
|
186 * See also eap_state_notification_c. |
|
187 */ |
|
188 virtual void state_notification( |
|
189 const abs_eap_state_notification_c * const state) = 0; |
|
190 |
|
191 /** |
|
192 * The set_timer() function initializes timer to be elapsed after p_time_ms milliseconds. |
|
193 * @param initializer is pointer to object which timer_expired() function will |
|
194 * be called after timer elapses. |
|
195 * @param id is identifier which will be returned in timer_expired() function. |
|
196 * The user selects and interprets the id for this timer. |
|
197 * @param data is pointer to any user selected data which will be returned in timer_expired() function. |
|
198 * |
|
199 * Adaptation module internally implements the timer. |
|
200 */ |
|
201 virtual eap_status_e set_timer( |
|
202 abs_eap_base_timer_c * const initializer, |
|
203 const u32_t id, |
|
204 void * const data, |
|
205 const u32_t p_time_ms) = 0; |
|
206 |
|
207 /** |
|
208 * The cancel_timer() function cancels the timer id initiated by initializer. |
|
209 * |
|
210 * Adaptation module internally implements the timer. |
|
211 */ |
|
212 virtual eap_status_e cancel_timer( |
|
213 abs_eap_base_timer_c * const initializer, |
|
214 const u32_t id) = 0; |
|
215 |
|
216 /** |
|
217 * The cancel_all_timers() function cancels all timers. |
|
218 * User should use this in termination of the stack before |
|
219 * the adaptation module of tools is deleted. |
|
220 * Preferred mode is to cancel each timer directly |
|
221 * using cancel_timer() function. |
|
222 * |
|
223 * Adaptation module internally implements the timer. |
|
224 */ |
|
225 virtual eap_status_e cancel_all_timers() = 0; |
|
226 |
|
227 /** |
|
228 * This is needed by PEAP type. |
|
229 * The load_module() function function indicates the lower level to |
|
230 * load new module of EAP-type. |
|
231 * @param type is the requested EAP-type. |
|
232 * @param partner is pointer to the caller object. |
|
233 * The partner of the new created EAP-type object is the caller object. |
|
234 * @param eap_type is a pointer to a pointer of EAP-type object. |
|
235 * Adaptation module sets eap_type pointer to created EAP-type object. |
|
236 * @param is_client_when_true parameter indicates whether the network entity should |
|
237 * act as a client (true) or server (false), in terms of EAP-protocol whether |
|
238 * this network entity is EAP-supplicant (true) or EAP-authenticator (false). |
|
239 */ |
|
240 virtual eap_status_e load_module( |
|
241 const eap_type_value_e type, |
|
242 const eap_type_value_e /* tunneling_type */, |
|
243 abs_eap_base_type_c * const partner, |
|
244 eap_base_type_c ** const eap_type, |
|
245 const bool is_client_when_true, |
|
246 const eap_am_network_id_c * const receive_network_id) = 0; |
|
247 |
|
248 /** |
|
249 * This is needed by PEAP type. |
|
250 * The unload_module() function unloads the module of a EAP-type. |
|
251 * @param type is the requested EAP-type. |
|
252 */ |
|
253 virtual eap_status_e unload_module(const eap_type_value_e type) = 0; |
|
254 |
|
255 /** |
|
256 * Note this function is just an example. Parameters will change later. |
|
257 * The packet_data_crypto_keys() function gives the generated keys to lower level. |
|
258 * After EAP-authentication has generated the keys it calls this function |
|
259 * to offer the keys to lower level. |
|
260 * @param master_session_key is pointer to the first byte of the master session key. |
|
261 * @param master_session_length is count of bytes in the master session key. |
|
262 */ |
|
263 virtual eap_status_e packet_data_crypto_keys( |
|
264 const eap_am_network_id_c * const send_network_id, |
|
265 const eap_master_session_key_c * const master_session_key |
|
266 ) = 0; |
|
267 |
|
268 /** |
|
269 * This is needed by PEAP type. |
|
270 * This function queries the validity of EAP-type. |
|
271 * Lower layer should return eap_status_ok if this EAP-type is supported. |
|
272 */ |
|
273 virtual eap_status_e check_is_valid_eap_type(const eap_type_value_e eap_type) = 0; |
|
274 |
|
275 /** |
|
276 * This function queries the list of supported EAP-types. |
|
277 * Lower layer should return eap_status_ok if this call succeeds. |
|
278 * @param eap_type_list will include the list of supported EAP-types. Each value in list |
|
279 * is type of u32_t and represent one supported EAP-type. List consists of subsequent u32_t type values. |
|
280 */ |
|
281 virtual eap_status_e get_eap_type_list( |
|
282 eap_array_c<eap_type_value_e> * const eap_type_list) = 0; |
|
283 |
|
284 /** |
|
285 * The set_session_timeout() function changes the session timeout timer to be elapsed after session_timeout_ms milliseconds. |
|
286 */ |
|
287 virtual eap_status_e set_session_timeout( |
|
288 const u32_t session_timeout_ms) = 0; |
|
289 |
|
290 virtual eap_status_e add_rogue_ap(eap_array_c<eap_rogue_ap_entry_c> & rogue_ap_list) = 0; |
|
291 |
|
292 virtual eap_status_e peap_tunnel_ready() = 0; |
|
293 |
|
294 virtual eap_status_e set_tls_session_type(const tls_session_type_e tls_session_type) = 0; |
|
295 |
|
296 //-------------------------------------------------- |
|
297 }; // class abs_tls_base_record_c |
|
298 |
|
299 #endif //#if !defined(_ABS_TLS_BASE_RECORD_H_) |
|
300 |
|
301 //-------------------------------------------------- |
|
302 |
|
303 |
|
304 |
|
305 // End. |