|
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 // This is enumeration of EAPOL source code. |
|
20 #if defined(USE_EAP_MINIMUM_RELEASE_TRACES) |
|
21 #undef EAP_FILE_NUMBER_ENUM |
|
22 #define EAP_FILE_NUMBER_ENUM 62 |
|
23 #undef EAP_FILE_NUMBER_DATE |
|
24 #define EAP_FILE_NUMBER_DATE 1127594498 |
|
25 #endif //#if defined(USE_EAP_MINIMUM_RELEASE_TRACES) |
|
26 |
|
27 |
|
28 |
|
29 #include "eap_am_memory.h" |
|
30 #include "eap_variable_data.h" |
|
31 #include "eap_tools.h" |
|
32 #include "ethernet_core.h" |
|
33 #include "eapol_ethernet_header.h" |
|
34 #include "eap_buffer.h" |
|
35 #include "eapol_session_key.h" |
|
36 #include "eap_automatic_variable.h" |
|
37 |
|
38 |
|
39 //-------------------------------------------------- |
|
40 |
|
41 // |
|
42 EAP_FUNC_EXPORT ethernet_core_c::~ethernet_core_c() |
|
43 { |
|
44 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
45 |
|
46 EAP_TRACE_DEBUG( |
|
47 m_am_tools, |
|
48 TRACE_FLAGS_DEFAULT, |
|
49 (EAPL("ethernet_core_c::~ethernet_core_c(): this = 0x%08x\n"), |
|
50 this)); |
|
51 |
|
52 EAP_ASSERT(m_shutdown_was_called == true); |
|
53 |
|
54 delete m_eapol_core; |
|
55 |
|
56 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
57 } |
|
58 |
|
59 //-------------------------------------------------- |
|
60 |
|
61 #if defined(_WIN32) && !defined(__GNUC__) |
|
62 #pragma warning( disable : 4355 ) // 'this' : used in base member initializer list |
|
63 #endif |
|
64 |
|
65 // |
|
66 EAP_FUNC_EXPORT ethernet_core_c::ethernet_core_c( |
|
67 abs_eap_am_tools_c * const tools, |
|
68 abs_ethernet_core_c * const partner, |
|
69 const bool is_client_when_true) |
|
70 : m_partner(partner) |
|
71 , m_eapol_core(new eapol_core_c(tools, this, is_client_when_true)) |
|
72 , m_am_tools(tools) |
|
73 , m_is_client(is_client_when_true) |
|
74 , m_is_valid(false) |
|
75 , m_shutdown_was_called(false) |
|
76 { |
|
77 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
78 |
|
79 EAP_TRACE_DEBUG( |
|
80 m_am_tools, |
|
81 TRACE_FLAGS_DEFAULT, |
|
82 (EAPL("ethernet_core_c::ethernet_core_c(): %s, this = 0x%08x, compiled %s %s.\n"), |
|
83 (m_is_client == true) ? "client": "server", |
|
84 this, |
|
85 __DATE__, |
|
86 __TIME__)); |
|
87 |
|
88 if (m_eapol_core != 0 |
|
89 && m_eapol_core->get_is_valid() == true) |
|
90 { |
|
91 set_is_valid(); |
|
92 } |
|
93 |
|
94 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
95 } |
|
96 |
|
97 //-------------------------------------------------- |
|
98 |
|
99 // |
|
100 EAP_FUNC_EXPORT eap_base_type_c * ethernet_core_c::load_type(const eap_type_value_e /* type */) |
|
101 { |
|
102 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
103 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
104 return 0; |
|
105 } |
|
106 |
|
107 //-------------------------------------------------- |
|
108 |
|
109 // |
|
110 EAP_FUNC_EXPORT eap_status_e ethernet_core_c::packet_process( |
|
111 const eap_am_network_id_c * const /* receive_network_id */, |
|
112 eap_general_header_base_c * const packet_data, |
|
113 const u32_t packet_length) |
|
114 { |
|
115 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
116 eap_status_e status = eap_status_process_general_error; |
|
117 |
|
118 EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("####################################################################\n"))); |
|
119 |
|
120 if (m_eapol_core == 0) |
|
121 { |
|
122 EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("####################################################################\n"))); |
|
123 return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error); |
|
124 } |
|
125 |
|
126 if (packet_length < eapol_ethernet_header_rd_c::get_header_length()) |
|
127 { |
|
128 EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("####################################################################\n"))); |
|
129 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
130 return EAP_STATUS_RETURN(m_am_tools, eap_status_process_illegal_packet_error); |
|
131 } |
|
132 |
|
133 eapol_ethernet_header_wr_c eth_header( |
|
134 m_am_tools, |
|
135 packet_data->get_header_buffer(packet_data->get_header_buffer_length()), |
|
136 packet_data->get_header_buffer_length()); |
|
137 |
|
138 if (eth_header.get_is_valid() == false) |
|
139 { |
|
140 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
141 return EAP_STATUS_RETURN(m_am_tools, eap_status_process_illegal_packet_error); |
|
142 } |
|
143 |
|
144 if (packet_length < eth_header.get_data_length()) |
|
145 { |
|
146 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
147 return EAP_STATUS_RETURN(m_am_tools, eap_status_process_illegal_packet_error); |
|
148 } |
|
149 |
|
150 EAP_TRACE_ALWAYS( |
|
151 m_am_tools, |
|
152 TRACE_FLAGS_DEFAULT, |
|
153 (EAPL("-> ETHERNET: %s: type=0x%04x, packet_length 0x%04x\n"), |
|
154 (m_is_client == true) ? "client": "server", |
|
155 eth_header.get_type(), |
|
156 packet_length)); |
|
157 |
|
158 if (m_is_client == true) |
|
159 { |
|
160 EAP_TRACE_DATA_ALWAYS( |
|
161 m_am_tools, |
|
162 TRACE_FLAGS_ALWAYS|TRACE_FLAGS_DEFAULT, |
|
163 (EAPL("-> ETHERNET packet client"), |
|
164 eth_header.get_header_buffer(eth_header.get_header_buffer_length()), |
|
165 packet_length)); |
|
166 } |
|
167 else |
|
168 { |
|
169 EAP_TRACE_DATA_ALWAYS( |
|
170 m_am_tools, |
|
171 TRACE_FLAGS_ALWAYS|TRACE_FLAGS_DEFAULT, |
|
172 (EAPL("-> ETHERNET packet server"), |
|
173 eth_header.get_header_buffer(eth_header.get_header_buffer_length()), |
|
174 packet_length)); |
|
175 } |
|
176 |
|
177 if (eth_header.get_type() == eapol_ethernet_type_pae |
|
178 || eth_header.get_type() == eapol_ethernet_type_preauthentication) |
|
179 { |
|
180 eap_am_network_id_c receive_network_id( |
|
181 m_am_tools, |
|
182 eth_header.get_source(), |
|
183 eth_header.get_source_length(), |
|
184 eth_header.get_destination(), |
|
185 eth_header.get_destination_length(), |
|
186 eth_header.get_type(), |
|
187 false, |
|
188 false); |
|
189 |
|
190 eapol_header_wr_c eapol( |
|
191 m_am_tools, |
|
192 eth_header.get_eapol_header(), |
|
193 eth_header.get_data_length()); |
|
194 if (eapol.get_is_valid() == false) |
|
195 { |
|
196 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
197 return EAP_STATUS_RETURN(m_am_tools, eap_status_header_corrupted); |
|
198 } |
|
199 |
|
200 status = m_eapol_core->packet_process( |
|
201 &receive_network_id, |
|
202 &eapol, |
|
203 packet_length-eapol_ethernet_header_rd_c::get_header_length()); |
|
204 |
|
205 EAP_GENERAL_HEADER_COPY_ERROR_PARAMETERS(packet_data, &eapol); |
|
206 } |
|
207 else |
|
208 { |
|
209 EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("Not supported ethernet type 0x%04x\n"), eth_header.get_type())); |
|
210 status = eap_status_ethernet_type_not_supported; |
|
211 } |
|
212 |
|
213 EAP_TRACE_DEBUG( |
|
214 m_am_tools, |
|
215 TRACE_FLAGS_DEFAULT, |
|
216 (EAPL("####################################################################\n"))); |
|
217 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
218 return EAP_STATUS_RETURN(m_am_tools, status); |
|
219 } |
|
220 |
|
221 //-------------------------------------------------- |
|
222 |
|
223 |
|
224 // |
|
225 EAP_FUNC_EXPORT eap_status_e ethernet_core_c::packet_send( |
|
226 const eap_am_network_id_c * const send_network_id, |
|
227 eap_buf_chain_wr_c * const sent_packet, |
|
228 const u32_t header_offset, |
|
229 const u32_t data_length, |
|
230 const u32_t buffer_length) |
|
231 { |
|
232 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
233 |
|
234 EAP_ASSERT(header_offset < sent_packet->get_data_length()); |
|
235 EAP_ASSERT(data_length <= sent_packet->get_data_length()); |
|
236 EAP_ASSERT(sent_packet->get_data_length() <= buffer_length); |
|
237 |
|
238 if (send_network_id->get_is_valid_data() == false) |
|
239 { |
|
240 return EAP_STATUS_RETURN(m_am_tools, eap_status_illegal_parameter); |
|
241 } |
|
242 |
|
243 if (header_offset < eapol_ethernet_header_wr_c::get_header_length()) |
|
244 { |
|
245 EAP_TRACE_DEBUG( |
|
246 m_am_tools, |
|
247 TRACE_FLAGS_DEFAULT, |
|
248 (EAPL("packet_send: packet buffer corrupted.\n"))); |
|
249 return EAP_STATUS_RETURN(m_am_tools, eap_status_process_general_error); |
|
250 } |
|
251 |
|
252 eapol_ethernet_header_wr_c eth( |
|
253 m_am_tools, |
|
254 sent_packet->get_data_offset( |
|
255 header_offset-eapol_ethernet_header_wr_c::get_header_length(), |
|
256 eapol_ethernet_header_wr_c::get_header_length()), |
|
257 eapol_ethernet_header_wr_c::get_header_length()); |
|
258 |
|
259 if (eth.get_is_valid() == false) |
|
260 { |
|
261 EAP_TRACE_DEBUG( |
|
262 m_am_tools, |
|
263 TRACE_FLAGS_DEFAULT, |
|
264 (EAPL("packet_send: packet buffer corrupted.\n"))); |
|
265 return EAP_STATUS_RETURN(m_am_tools, eap_status_process_general_error); |
|
266 } |
|
267 |
|
268 |
|
269 eth.set_type(static_cast<eapol_ethernet_type_e>(send_network_id->get_type())); |
|
270 |
|
271 m_am_tools->memmove( |
|
272 eth.get_destination(), |
|
273 send_network_id->get_destination(), |
|
274 send_network_id->get_destination_length()); |
|
275 |
|
276 m_am_tools->memmove( |
|
277 eth.get_source(), |
|
278 send_network_id->get_source(), |
|
279 send_network_id->get_source_length()); |
|
280 |
|
281 |
|
282 EAP_TRACE_ALWAYS( |
|
283 m_am_tools, |
|
284 TRACE_FLAGS_DEFAULT, |
|
285 (EAPL("<- ETHERNET: %s: type=0x%04x, packet_length 0x%04x\n"), |
|
286 (m_is_client == true) ? "client": "server", |
|
287 eth.get_type(), |
|
288 data_length)); |
|
289 |
|
290 if (m_is_client == true) |
|
291 { |
|
292 EAP_TRACE_DATA_ALWAYS( |
|
293 m_am_tools, |
|
294 TRACE_FLAGS_ALWAYS|TRACE_FLAGS_DEFAULT, |
|
295 (EAPL("<- ETHERNET packet client"), |
|
296 eth.get_header_buffer(eth.get_header_buffer_length()), |
|
297 data_length+eapol_ethernet_header_wr_c::get_header_length())); |
|
298 } |
|
299 else |
|
300 { |
|
301 EAP_TRACE_DATA_ALWAYS( |
|
302 m_am_tools, |
|
303 TRACE_FLAGS_ALWAYS|TRACE_FLAGS_DEFAULT, |
|
304 (EAPL("<- ETHERNET packet server"), |
|
305 eth.get_header_buffer(eth.get_header_buffer_length()), |
|
306 data_length+eapol_ethernet_header_wr_c::get_header_length())); |
|
307 } |
|
308 |
|
309 sent_packet->set_is_client(m_is_client); |
|
310 |
|
311 eap_status_e status = m_partner->packet_send( |
|
312 send_network_id, |
|
313 sent_packet, |
|
314 header_offset-eapol_ethernet_header_wr_c::get_header_length(), |
|
315 data_length+eapol_ethernet_header_wr_c::get_header_length(), |
|
316 buffer_length); |
|
317 |
|
318 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
319 return EAP_STATUS_RETURN(m_am_tools, status); |
|
320 } |
|
321 |
|
322 //-------------------------------------------------- |
|
323 |
|
324 // |
|
325 EAP_FUNC_EXPORT u32_t ethernet_core_c::get_header_offset( |
|
326 u32_t * const MTU, |
|
327 u32_t * const trailer_length) |
|
328 { |
|
329 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
330 |
|
331 const u32_t offset = m_partner->get_header_offset(MTU, trailer_length); |
|
332 (*MTU) -= eapol_ethernet_header_wr_c::get_header_length(); |
|
333 |
|
334 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
335 return offset+eapol_ethernet_header_wr_c::get_header_length(); |
|
336 } |
|
337 |
|
338 //-------------------------------------------------- |
|
339 |
|
340 // |
|
341 EAP_FUNC_EXPORT eap_status_e ethernet_core_c::unload_module(const eap_type_value_e type) |
|
342 { |
|
343 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
344 const eap_status_e status = m_partner->unload_module(type); |
|
345 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
346 return EAP_STATUS_RETURN(m_am_tools, status); |
|
347 } |
|
348 |
|
349 //-------------------------------------------------- |
|
350 |
|
351 // |
|
352 EAP_FUNC_EXPORT eap_status_e ethernet_core_c::eap_acknowledge( |
|
353 const eap_am_network_id_c * const receive_network_id) |
|
354 { |
|
355 // Any Network Protocol packet is accepted as a success indication. |
|
356 // This is described in RFC 2284 "PPP Extensible Authentication Protocol (EAP)". |
|
357 |
|
358 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
359 |
|
360 if (m_eapol_core == 0) |
|
361 { |
|
362 return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error); |
|
363 } |
|
364 |
|
365 eap_status_e status = m_eapol_core->eap_acknowledge(receive_network_id); |
|
366 |
|
367 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
368 |
|
369 return EAP_STATUS_RETURN(m_am_tools, status); |
|
370 } |
|
371 |
|
372 //-------------------------------------------------- |
|
373 |
|
374 // |
|
375 EAP_FUNC_EXPORT eap_status_e ethernet_core_c::load_module( |
|
376 const eap_type_value_e type, |
|
377 const eap_type_value_e tunneling_type, |
|
378 abs_eap_base_type_c * const partner, |
|
379 eap_base_type_c ** const eap_type, |
|
380 const bool is_client_when_true, |
|
381 const eap_am_network_id_c * const receive_network_id) |
|
382 { |
|
383 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
384 |
|
385 EAP_ASSERT(m_am_tools->get_global_mutex()->get_is_reserved() == true); |
|
386 |
|
387 eap_status_e status = m_partner->load_module( |
|
388 type, |
|
389 tunneling_type, |
|
390 partner, |
|
391 eap_type, |
|
392 is_client_when_true, |
|
393 receive_network_id); |
|
394 |
|
395 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
396 return EAP_STATUS_RETURN(m_am_tools, status); |
|
397 } |
|
398 |
|
399 //-------------------------------------------------- |
|
400 |
|
401 // |
|
402 EAP_FUNC_EXPORT eap_status_e ethernet_core_c::start_authentication( |
|
403 const eap_am_network_id_c * const receive_network_id, |
|
404 const bool is_client_when_true) |
|
405 { |
|
406 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
407 |
|
408 if (m_eapol_core == 0) |
|
409 { |
|
410 return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error); |
|
411 } |
|
412 |
|
413 eap_status_e status = m_eapol_core->restart_authentication(receive_network_id, is_client_when_true, true); |
|
414 |
|
415 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
416 return EAP_STATUS_RETURN(m_am_tools, status); |
|
417 } |
|
418 |
|
419 //-------------------------------------------------- |
|
420 |
|
421 // |
|
422 EAP_FUNC_EXPORT eap_status_e ethernet_core_c::start_preauthentication( |
|
423 const eap_am_network_id_c * const receive_network_id, |
|
424 const eapol_key_authentication_type_e authentication_type) |
|
425 { |
|
426 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
427 |
|
428 EAP_TRACE_DEBUG( |
|
429 m_am_tools, |
|
430 TRACE_FLAGS_DEFAULT, |
|
431 (EAPL("ethernet_core_c::start_preauthentication()\n"))); |
|
432 |
|
433 if (m_eapol_core == 0) |
|
434 { |
|
435 return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error); |
|
436 } |
|
437 |
|
438 eap_status_e status = m_eapol_core->start_preauthentication(receive_network_id, authentication_type); |
|
439 |
|
440 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
441 return EAP_STATUS_RETURN(m_am_tools, status); |
|
442 } |
|
443 |
|
444 //-------------------------------------------------- |
|
445 |
|
446 // |
|
447 eap_status_e ethernet_core_c::read_reassociation_parameters( |
|
448 const eap_am_network_id_c * const old_receive_network_id, ///< source includes remote address, destination includes local address. |
|
449 const eap_am_network_id_c * const new_receive_network_id, ///< source includes remote address, destination includes local address. |
|
450 const eapol_key_authentication_type_e authentication_type, |
|
451 eap_variable_data_c * const PMKID, |
|
452 const eap_variable_data_c * const received_WPA_ie, |
|
453 const eap_variable_data_c * const sent_WPA_ie) |
|
454 { |
|
455 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
456 |
|
457 EAP_TRACE_DEBUG( |
|
458 m_am_tools, |
|
459 TRACE_FLAGS_DEFAULT, |
|
460 (EAPL("ethernet_core_c::read_reassociation_parameters()\n"))); |
|
461 |
|
462 if (m_eapol_core == 0) |
|
463 { |
|
464 return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error); |
|
465 } |
|
466 |
|
467 eap_status_e status = m_eapol_core->read_reassociation_parameters( |
|
468 old_receive_network_id, |
|
469 new_receive_network_id, |
|
470 authentication_type, |
|
471 PMKID, |
|
472 received_WPA_ie, |
|
473 sent_WPA_ie); |
|
474 |
|
475 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
476 return EAP_STATUS_RETURN(m_am_tools, status); |
|
477 } |
|
478 |
|
479 //-------------------------------------------------- |
|
480 |
|
481 // |
|
482 EAP_FUNC_EXPORT eap_status_e ethernet_core_c::start_reassociation( |
|
483 const eap_am_network_id_c * const receive_network_id, |
|
484 const eapol_key_authentication_type_e authentication_type, |
|
485 const eap_variable_data_c * const PMKID) |
|
486 { |
|
487 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
488 |
|
489 eap_status_e status = m_eapol_core->start_reassociation( |
|
490 receive_network_id, |
|
491 authentication_type, |
|
492 PMKID); |
|
493 |
|
494 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
495 return EAP_STATUS_RETURN(m_am_tools, status); |
|
496 } |
|
497 |
|
498 //-------------------------------------------------- |
|
499 |
|
500 // |
|
501 eap_status_e ethernet_core_c::complete_reassociation( |
|
502 const eapol_wlan_authentication_state_e reassociation_result, |
|
503 const eap_am_network_id_c * const receive_network_id, |
|
504 const eapol_key_authentication_type_e authentication_type, |
|
505 const eap_variable_data_c * const received_WPA_IE, // WLM must give only the WPA IE to EAPOL |
|
506 const eap_variable_data_c * const sent_WPA_IE, |
|
507 const eapol_RSNA_key_header_c::eapol_RSNA_cipher_e pairwise_key_cipher_suite, |
|
508 const eapol_RSNA_key_header_c::eapol_RSNA_cipher_e group_key_cipher_suite |
|
509 ) |
|
510 { |
|
511 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
512 |
|
513 eap_status_e status(eap_status_process_general_error); |
|
514 |
|
515 status = m_eapol_core->complete_reassociation( |
|
516 reassociation_result, |
|
517 receive_network_id, |
|
518 authentication_type, |
|
519 received_WPA_IE, |
|
520 sent_WPA_IE, |
|
521 pairwise_key_cipher_suite, |
|
522 group_key_cipher_suite); |
|
523 |
|
524 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
525 return EAP_STATUS_RETURN(m_am_tools, status); |
|
526 } |
|
527 |
|
528 //-------------------------------------------------- |
|
529 |
|
530 // |
|
531 EAP_FUNC_EXPORT eap_status_e ethernet_core_c::send_logoff( |
|
532 const eap_am_network_id_c * const receive_network_id) |
|
533 { |
|
534 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
535 |
|
536 if (m_eapol_core == 0) |
|
537 { |
|
538 return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error); |
|
539 } |
|
540 |
|
541 eap_status_e status = m_eapol_core->send_logoff(receive_network_id); |
|
542 |
|
543 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
544 return EAP_STATUS_RETURN(m_am_tools, status); |
|
545 } |
|
546 |
|
547 //-------------------------------------------------- |
|
548 |
|
549 // |
|
550 EAP_FUNC_EXPORT void ethernet_core_c::set_is_valid() |
|
551 { |
|
552 m_is_valid = true; |
|
553 } |
|
554 |
|
555 //-------------------------------------------------- |
|
556 |
|
557 // |
|
558 EAP_FUNC_EXPORT bool ethernet_core_c::get_is_valid() |
|
559 { |
|
560 return m_is_valid; |
|
561 } |
|
562 |
|
563 //-------------------------------------------------- |
|
564 |
|
565 // |
|
566 EAP_FUNC_EXPORT eap_status_e ethernet_core_c::configure() |
|
567 { |
|
568 EAP_TRACE_DEBUG( |
|
569 m_am_tools, |
|
570 TRACE_FLAGS_DEFAULT, |
|
571 (EAPL("ethernet_core_c::configure()\n"))); |
|
572 |
|
573 EAP_TRACE_RETURN_STRING(m_am_tools, "returns: ethernet_core_c::configure()"); |
|
574 |
|
575 eap_status_e status = m_eapol_core->configure(); |
|
576 |
|
577 return EAP_STATUS_RETURN(m_am_tools, status); |
|
578 } |
|
579 |
|
580 //-------------------------------------------------- |
|
581 |
|
582 // |
|
583 EAP_FUNC_EXPORT eap_status_e ethernet_core_c::shutdown() |
|
584 { |
|
585 EAP_TRACE_DEBUG( |
|
586 m_am_tools, |
|
587 TRACE_FLAGS_DEFAULT, |
|
588 (EAPL("%s: ethernet_core_c::shutdown(), m_shutdown_was_called=%d\n"), |
|
589 (m_is_client == true) ? "client": "server", |
|
590 m_shutdown_was_called)); |
|
591 |
|
592 if (m_shutdown_was_called == true) |
|
593 { |
|
594 // Shutdown function was called already. |
|
595 return EAP_STATUS_RETURN(m_am_tools, eap_status_ok); |
|
596 } |
|
597 m_shutdown_was_called = true; |
|
598 |
|
599 eap_status_e status(eap_status_ok); |
|
600 |
|
601 if (m_eapol_core != 0) |
|
602 { |
|
603 status = m_eapol_core->shutdown(); |
|
604 } |
|
605 |
|
606 return EAP_STATUS_RETURN(m_am_tools, status); |
|
607 } |
|
608 |
|
609 //-------------------------------------------------- |
|
610 |
|
611 EAP_FUNC_EXPORT eap_status_e ethernet_core_c::packet_data_session_key( |
|
612 const eap_am_network_id_c * const send_network_id, |
|
613 const eapol_session_key_c * const key) |
|
614 { |
|
615 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
616 |
|
617 if (key == 0 |
|
618 || key->get_is_valid() == false) |
|
619 { |
|
620 EAP_TRACE_DEBUG( |
|
621 m_am_tools, |
|
622 TRACE_FLAGS_DEFAULT, |
|
623 (EAPL("ERROR: ethernet_core_c::packet_data_session_key(), invalid key.\n"))); |
|
624 return EAP_STATUS_RETURN(m_am_tools, eap_status_key_error); |
|
625 } |
|
626 |
|
627 EAP_TRACE_DEBUG( |
|
628 m_am_tools, |
|
629 TRACE_FLAGS_DEFAULT, |
|
630 (EAPL("ethernet_core_c::packet_data_session_key(): key_type 0x%02x=%s, key_index %d\n"), |
|
631 key->get_key_type(), |
|
632 eapol_session_key_c::get_eapol_key_type_string(key->get_key_type()), |
|
633 key->get_key_index())); |
|
634 |
|
635 EAP_TRACE_DATA_DEBUG( |
|
636 m_am_tools, |
|
637 TRACE_FLAGS_DEFAULT, |
|
638 (EAPL("ethernet_core_c::packet_data_session_key():"), |
|
639 key->get_key()->get_data(key->get_key()->get_data_length()), |
|
640 key->get_key()->get_data_length())); |
|
641 |
|
642 const eap_status_e status = m_partner->packet_data_session_key( |
|
643 send_network_id, |
|
644 key); |
|
645 |
|
646 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
647 return EAP_STATUS_RETURN(m_am_tools, status); |
|
648 } |
|
649 |
|
650 //-------------------------------------------------- |
|
651 |
|
652 EAP_FUNC_EXPORT eap_status_e ethernet_core_c::read_configure( |
|
653 const eap_configuration_field_c * const field, |
|
654 eap_variable_data_c * const data) |
|
655 { |
|
656 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
657 const eap_status_e status = m_partner->read_configure(field, data); |
|
658 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
659 return EAP_STATUS_RETURN(m_am_tools, status); |
|
660 } |
|
661 |
|
662 //-------------------------------------------------- |
|
663 |
|
664 EAP_FUNC_EXPORT eap_status_e ethernet_core_c::write_configure( |
|
665 const eap_configuration_field_c * const field, |
|
666 eap_variable_data_c * const data) |
|
667 { |
|
668 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
669 const eap_status_e status = m_partner->write_configure(field, data); |
|
670 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
671 return EAP_STATUS_RETURN(m_am_tools, status); |
|
672 } |
|
673 |
|
674 //-------------------------------------------------- |
|
675 |
|
676 EAP_FUNC_EXPORT void ethernet_core_c::state_notification( |
|
677 const abs_eap_state_notification_c * const state) |
|
678 { |
|
679 m_partner->state_notification(state); |
|
680 } |
|
681 |
|
682 //-------------------------------------------------- |
|
683 |
|
684 // |
|
685 EAP_FUNC_EXPORT eap_status_e ethernet_core_c::set_timer( |
|
686 abs_eap_base_timer_c * const p_initializer, |
|
687 const u32_t p_id, |
|
688 void * const p_data, |
|
689 const u32_t p_time_ms) |
|
690 { |
|
691 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
692 |
|
693 EAP_ASSERT(m_am_tools->get_global_mutex()->get_is_reserved() == true); |
|
694 |
|
695 const eap_status_e status = m_partner->set_timer( |
|
696 p_initializer, |
|
697 p_id, |
|
698 p_data, |
|
699 p_time_ms); |
|
700 |
|
701 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
702 return EAP_STATUS_RETURN(m_am_tools, status); |
|
703 } |
|
704 |
|
705 //-------------------------------------------------- |
|
706 |
|
707 // |
|
708 EAP_FUNC_EXPORT eap_status_e ethernet_core_c::cancel_timer( |
|
709 abs_eap_base_timer_c * const p_initializer, |
|
710 const u32_t p_id) |
|
711 { |
|
712 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
713 |
|
714 EAP_ASSERT(m_am_tools->get_global_mutex()->get_is_reserved() == true); |
|
715 |
|
716 const eap_status_e status = m_partner->cancel_timer( |
|
717 p_initializer, |
|
718 p_id); |
|
719 |
|
720 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
721 return EAP_STATUS_RETURN(m_am_tools, status); |
|
722 } |
|
723 |
|
724 //-------------------------------------------------- |
|
725 |
|
726 // |
|
727 EAP_FUNC_EXPORT eap_status_e ethernet_core_c::cancel_all_timers() |
|
728 { |
|
729 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
730 |
|
731 EAP_ASSERT(m_am_tools->get_global_mutex()->get_is_reserved() == true); |
|
732 |
|
733 const eap_status_e status = m_partner->cancel_all_timers(); |
|
734 |
|
735 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
736 return EAP_STATUS_RETURN(m_am_tools, status); |
|
737 } |
|
738 |
|
739 //-------------------------------------------------- |
|
740 |
|
741 EAP_FUNC_EXPORT eap_status_e ethernet_core_c::check_is_valid_eap_type(const eap_type_value_e eap_type) |
|
742 { |
|
743 eap_status_e status = m_partner->check_is_valid_eap_type(eap_type); |
|
744 |
|
745 return EAP_STATUS_RETURN(m_am_tools, status); |
|
746 } |
|
747 |
|
748 //-------------------------------------------------- |
|
749 |
|
750 EAP_FUNC_EXPORT eap_status_e ethernet_core_c::get_eap_type_list( |
|
751 eap_array_c<eap_type_value_e> * const eap_type_list) |
|
752 { |
|
753 eap_status_e status = m_partner->get_eap_type_list(eap_type_list); |
|
754 |
|
755 return EAP_STATUS_RETURN(m_am_tools, status); |
|
756 } |
|
757 |
|
758 //-------------------------------------------------- |
|
759 |
|
760 // |
|
761 EAP_FUNC_EXPORT eap_status_e ethernet_core_c::cancel_all_authentication_sessions() |
|
762 { |
|
763 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
764 |
|
765 EAP_TRACE_DEBUG( |
|
766 m_am_tools, |
|
767 TRACE_FLAGS_DEFAULT, |
|
768 (EAPL("ethernet_core_c::cancel_all_authentication_sessions()\n"))); |
|
769 |
|
770 eap_status_e status = m_eapol_core->cancel_all_authentication_sessions(); |
|
771 |
|
772 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
773 return EAP_STATUS_RETURN(m_am_tools, status); |
|
774 } |
|
775 |
|
776 //-------------------------------------------------- |
|
777 |
|
778 #if defined(USE_EAPOL_KEY_STATE) |
|
779 |
|
780 // |
|
781 EAP_FUNC_EXPORT eap_status_e ethernet_core_c::check_pmksa_cache( |
|
782 eap_array_c<eap_am_network_id_c> * const bssid_sta_receive_network_ids, |
|
783 const eapol_key_authentication_type_e selected_eapol_key_authentication_type, |
|
784 const eapol_RSNA_key_header_c::eapol_RSNA_cipher_e pairwise_key_cipher_suite, |
|
785 const eapol_RSNA_key_header_c::eapol_RSNA_cipher_e group_key_cipher_suite |
|
786 ) |
|
787 { |
|
788 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
789 |
|
790 EAP_TRACE_DEBUG( |
|
791 m_am_tools, |
|
792 TRACE_FLAGS_DEFAULT, |
|
793 (EAPL("ethernet_core_c::check_pmksa_cache()\n"))); |
|
794 |
|
795 eap_status_e status = m_eapol_core->check_pmksa_cache( |
|
796 bssid_sta_receive_network_ids, |
|
797 selected_eapol_key_authentication_type, |
|
798 pairwise_key_cipher_suite, |
|
799 group_key_cipher_suite); |
|
800 |
|
801 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
802 return EAP_STATUS_RETURN(m_am_tools, status); |
|
803 } |
|
804 |
|
805 #endif // #if defined(USE_EAPOL_KEY_STATE) |
|
806 |
|
807 //-------------------------------------------------- |
|
808 |
|
809 #if defined(USE_EAPOL_KEY_STATE) |
|
810 /** |
|
811 * This function removes PMKSA from cache. |
|
812 * @param receive_network_id carries the MAC addresses. |
|
813 * MAC address of Authenticator should be in source address. |
|
814 * MAC address of Supplicant should be in destination address. |
|
815 */ |
|
816 EAP_FUNC_EXPORT eap_status_e ethernet_core_c::remove_pmksa_from_cache( |
|
817 const eap_am_network_id_c * const receive_network_id) |
|
818 { |
|
819 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
820 |
|
821 EAP_TRACE_DEBUG( |
|
822 m_am_tools, |
|
823 TRACE_FLAGS_DEFAULT, |
|
824 (EAPL("ethernet_core_c::remove_pmksa_from_cache()\n"))); |
|
825 |
|
826 eap_status_e status = m_eapol_core->remove_pmksa_from_cache( |
|
827 receive_network_id); |
|
828 |
|
829 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
830 return EAP_STATUS_RETURN(m_am_tools, status); |
|
831 } |
|
832 |
|
833 #endif // #if defined(USE_EAPOL_KEY_STATE) |
|
834 |
|
835 //-------------------------------------------------- |
|
836 |
|
837 #if defined(USE_EAPOL_KEY_STATE) && defined(USE_EAPOL_KEY_STATE_OPTIMIZED_4_WAY_HANDSHAKE) |
|
838 /** |
|
839 * Function creates a state for later use. This is for optimazing 4-Way Handshake. |
|
840 * @param receive_network_id carries the MAC addresses. |
|
841 * MAC address of Authenticator should be in source address. MAC address of |
|
842 * Supplicant should be in destination address. |
|
843 * @param authentication_type is the selected authentication type. |
|
844 */ |
|
845 EAP_FUNC_EXPORT eap_status_e ethernet_core_c::create_state( |
|
846 const eap_am_network_id_c * const receive_network_id, |
|
847 const eapol_key_authentication_type_e authentication_type |
|
848 ) |
|
849 { |
|
850 eap_status_e status = eap_status_process_general_error; |
|
851 |
|
852 EAP_ASSERT(m_am_tools->get_global_mutex()->get_is_reserved() == true); |
|
853 |
|
854 status = m_eapol_core->create_state( |
|
855 receive_network_id, |
|
856 authentication_type); |
|
857 |
|
858 return EAP_STATUS_RETURN(m_am_tools, status); |
|
859 } |
|
860 |
|
861 #endif //#if defined(USE_EAPOL_KEY_STATE) && defined(USE_EAPOL_KEY_STATE_OPTIMIZED_4_WAY_HANDSHAKE) |
|
862 |
|
863 //-------------------------------------------------- |
|
864 |
|
865 #if defined(USE_EAPOL_KEY_STATE) |
|
866 /** |
|
867 * @param receive_network_id carries the MAC addresses. |
|
868 * MAC address of Authenticator should be in source address. MAC address of Supplicant should be in destination address. |
|
869 * @param authenticator_RSNA_IE is RSN IE of authenticator. Authenticator sends this in Beacon or Probe message. |
|
870 * @param supplicant_RSNA_IE is RSN IE of supplicant. Supplicant sends this in (re)association request message. |
|
871 * @param eapol_pairwise_cipher is the selected pairwise cipher. |
|
872 * @param eapol_group_cipher is the selected group cipher. |
|
873 */ |
|
874 EAP_FUNC_EXPORT eap_status_e ethernet_core_c::association( |
|
875 const eap_am_network_id_c * const receive_network_id, |
|
876 const eapol_key_authentication_type_e authentication_type, |
|
877 const eap_variable_data_c * const authenticator_RSNA_IE, |
|
878 const eap_variable_data_c * const supplicant_RSNA_IE, |
|
879 const eapol_RSNA_key_header_c::eapol_RSNA_cipher_e eapol_pairwise_cipher, |
|
880 const eapol_RSNA_key_header_c::eapol_RSNA_cipher_e eapol_group_cipher, |
|
881 const eap_variable_data_c * const pre_shared_key |
|
882 ) |
|
883 { |
|
884 eap_status_e status = eap_status_process_general_error; |
|
885 |
|
886 EAP_ASSERT(m_am_tools->get_global_mutex()->get_is_reserved() == true); |
|
887 |
|
888 status = m_eapol_core->association( |
|
889 receive_network_id, |
|
890 authentication_type, |
|
891 authenticator_RSNA_IE, |
|
892 supplicant_RSNA_IE, |
|
893 eapol_pairwise_cipher, |
|
894 eapol_group_cipher, |
|
895 pre_shared_key); |
|
896 |
|
897 return EAP_STATUS_RETURN(m_am_tools, status); |
|
898 } |
|
899 |
|
900 #endif // #if defined(USE_EAPOL_KEY_STATE) |
|
901 |
|
902 //-------------------------------------------------- |
|
903 |
|
904 #if defined(USE_EAPOL_KEY_STATE) |
|
905 /** |
|
906 * @param receive_network_id carries the MAC addresses. |
|
907 * MAC address of Authenticator should be in source address. MAC address of Supplicant should be in destination address. |
|
908 */ |
|
909 EAP_FUNC_EXPORT eap_status_e ethernet_core_c::disassociation( |
|
910 const eap_am_network_id_c * const receive_network_id |
|
911 ) |
|
912 { |
|
913 eap_status_e status = eap_status_process_general_error; |
|
914 |
|
915 EAP_ASSERT(m_am_tools->get_global_mutex()->get_is_reserved() == true); |
|
916 |
|
917 status = m_eapol_core->disassociation( |
|
918 receive_network_id); |
|
919 |
|
920 return EAP_STATUS_RETURN(m_am_tools, status); |
|
921 } |
|
922 |
|
923 #endif //#if defined(USE_EAPOL_KEY_STATE) |
|
924 |
|
925 //-------------------------------------------------- |
|
926 |
|
927 EAP_FUNC_EXPORT eap_status_e ethernet_core_c::add_rogue_ap(eap_array_c<eap_rogue_ap_entry_c> & rogue_ap_list) |
|
928 { |
|
929 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
930 |
|
931 const eap_status_e status = m_partner->add_rogue_ap(rogue_ap_list); |
|
932 |
|
933 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
934 return EAP_STATUS_RETURN(m_am_tools, status); |
|
935 } |
|
936 |
|
937 //-------------------------------------------------- |
|
938 |
|
939 EAP_FUNC_EXPORT eap_status_e ethernet_core_c::tkip_mic_failure( |
|
940 const eap_am_network_id_c * const receive_network_id, |
|
941 const bool fatal_failure_when_true, |
|
942 const eapol_RSNA_key_header_c::eapol_tkip_mic_failure_type_e tkip_mic_failure_type) |
|
943 { |
|
944 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
945 |
|
946 const eap_status_e status = m_eapol_core->tkip_mic_failure( |
|
947 receive_network_id, |
|
948 fatal_failure_when_true, |
|
949 tkip_mic_failure_type); |
|
950 |
|
951 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
952 return EAP_STATUS_RETURN(m_am_tools, status); |
|
953 } |
|
954 |
|
955 //-------------------------------------------------- |
|
956 |
|
957 // End. |