|
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 137 |
|
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_tools.h" |
|
30 #include "eap_array.h" |
|
31 #include "tls_record_message.h" |
|
32 #include "eap_automatic_variable.h" |
|
33 |
|
34 |
|
35 /** @file */ |
|
36 |
|
37 //-------------------------------------------------- |
|
38 |
|
39 EAP_FUNC_EXPORT tls_record_message_c::~tls_record_message_c() |
|
40 { |
|
41 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
42 |
|
43 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
44 } |
|
45 |
|
46 //-------------------------------------------------- |
|
47 |
|
48 EAP_FUNC_EXPORT tls_record_message_c::tls_record_message_c( |
|
49 abs_eap_am_tools_c * const tools, |
|
50 abs_tls_message_hash_c * const message_hash, |
|
51 const bool is_client) |
|
52 : m_am_tools(tools) |
|
53 , m_message_hash(message_hash) |
|
54 , m_protocol(tls_record_protocol_none) |
|
55 , m_version(tls_version_illegal) |
|
56 , m_length(0ul) |
|
57 , m_tls_record_header_is_included(false) |
|
58 , m_record_message_data(tools) |
|
59 , m_analyse_index(0ul) |
|
60 , m_parsed_record(false) |
|
61 , m_cipher_suite_applied(false) |
|
62 , m_handshake_messages(tools) |
|
63 , m_change_cipher_spec_messages(tools) |
|
64 , m_alert_messages(tools) |
|
65 , m_application_data_messages(tools) |
|
66 , m_is_client(is_client) |
|
67 , m_is_valid(false) |
|
68 { |
|
69 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
70 |
|
71 set_is_valid(); |
|
72 |
|
73 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
74 } |
|
75 |
|
76 //-------------------------------------------------- |
|
77 |
|
78 EAP_FUNC_EXPORT void tls_record_message_c::set_is_valid() |
|
79 { |
|
80 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
81 |
|
82 m_is_valid = true; |
|
83 |
|
84 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
85 } |
|
86 |
|
87 //-------------------------------------------------- |
|
88 |
|
89 EAP_FUNC_EXPORT bool tls_record_message_c::get_is_valid() |
|
90 { |
|
91 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
92 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
93 return m_is_valid; |
|
94 } |
|
95 |
|
96 //-------------------------------------------------- |
|
97 |
|
98 EAP_FUNC_EXPORT u32_t tls_record_message_c::get_analyse_index() const |
|
99 { |
|
100 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
101 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
102 return m_analyse_index; |
|
103 } |
|
104 |
|
105 //-------------------------------------------------- |
|
106 |
|
107 EAP_FUNC_EXPORT void tls_record_message_c::save_analyse_index(const u32_t analyse_index) |
|
108 { |
|
109 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
110 |
|
111 m_analyse_index = analyse_index; |
|
112 |
|
113 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
114 } |
|
115 |
|
116 //-------------------------------------------------- |
|
117 |
|
118 EAP_FUNC_EXPORT bool tls_record_message_c::get_parsed_record() const |
|
119 { |
|
120 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
121 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
122 return m_parsed_record; |
|
123 } |
|
124 |
|
125 //-------------------------------------------------- |
|
126 |
|
127 EAP_FUNC_EXPORT void tls_record_message_c::set_parsed_record() |
|
128 { |
|
129 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
130 |
|
131 m_parsed_record = true; |
|
132 |
|
133 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
134 } |
|
135 |
|
136 //-------------------------------------------------- |
|
137 |
|
138 EAP_FUNC_EXPORT bool tls_record_message_c::get_tls_record_header_is_included() const |
|
139 { |
|
140 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
141 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
142 return m_tls_record_header_is_included; |
|
143 } |
|
144 |
|
145 //-------------------------------------------------- |
|
146 |
|
147 EAP_FUNC_EXPORT void tls_record_message_c::set_tls_record_header_is_included(const bool when_true_tls_record_header_is_included) |
|
148 { |
|
149 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
150 |
|
151 m_tls_record_header_is_included = when_true_tls_record_header_is_included; |
|
152 |
|
153 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
154 } |
|
155 |
|
156 //-------------------------------------------------- |
|
157 |
|
158 EAP_FUNC_EXPORT bool tls_record_message_c::get_cipher_suite_applied() const |
|
159 { |
|
160 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
161 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
162 return m_cipher_suite_applied; |
|
163 } |
|
164 |
|
165 //-------------------------------------------------- |
|
166 |
|
167 EAP_FUNC_EXPORT void tls_record_message_c::set_cipher_suite_applied() |
|
168 { |
|
169 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
170 |
|
171 m_cipher_suite_applied = true; |
|
172 |
|
173 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
174 } |
|
175 |
|
176 //-------------------------------------------------- |
|
177 |
|
178 EAP_FUNC_EXPORT eap_status_e tls_record_message_c::set_protocol(tls_record_protocol_e protocol) |
|
179 { |
|
180 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
181 |
|
182 m_protocol = protocol; |
|
183 |
|
184 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
185 return EAP_STATUS_RETURN(m_am_tools, eap_status_ok); |
|
186 } |
|
187 |
|
188 //-------------------------------------------------- |
|
189 |
|
190 EAP_FUNC_EXPORT eap_status_e tls_record_message_c::set_version( |
|
191 tls_version_e version) |
|
192 { |
|
193 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
194 |
|
195 m_version = version; |
|
196 |
|
197 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
198 return EAP_STATUS_RETURN(m_am_tools, eap_status_ok); |
|
199 } |
|
200 |
|
201 //-------------------------------------------------- |
|
202 |
|
203 EAP_FUNC_EXPORT eap_status_e tls_record_message_c::set_record_header_copy( |
|
204 const tls_record_header_c * const tls_record_header) |
|
205 { |
|
206 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
207 |
|
208 m_protocol = tls_record_header->get_protocol(); |
|
209 m_version = tls_record_header->get_version(); |
|
210 m_length = tls_record_header->get_data_length(); |
|
211 |
|
212 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
213 return EAP_STATUS_RETURN(m_am_tools, eap_status_ok); |
|
214 } |
|
215 |
|
216 //-------------------------------------------------- |
|
217 |
|
218 EAP_FUNC_EXPORT eap_status_e tls_record_message_c::set_record_message_data( |
|
219 void * const data, |
|
220 const u32_t data_length) |
|
221 { |
|
222 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
223 |
|
224 eap_status_e status = m_record_message_data.set_buffer(data, data_length, false, true); |
|
225 |
|
226 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
227 return EAP_STATUS_RETURN(m_am_tools, status); |
|
228 } |
|
229 |
|
230 //-------------------------------------------------- |
|
231 |
|
232 EAP_FUNC_EXPORT eap_variable_data_c * tls_record_message_c::get_record_message_data() |
|
233 { |
|
234 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
235 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
236 return &m_record_message_data; |
|
237 } |
|
238 |
|
239 //-------------------------------------------------- |
|
240 |
|
241 EAP_FUNC_EXPORT tls_record_protocol_e tls_record_message_c::get_protocol() const |
|
242 { |
|
243 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
244 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
245 return m_protocol; |
|
246 } |
|
247 |
|
248 //-------------------------------------------------- |
|
249 |
|
250 EAP_FUNC_EXPORT tls_version_e tls_record_message_c::get_version() const |
|
251 { |
|
252 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
253 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
254 return m_version; |
|
255 } |
|
256 |
|
257 //-------------------------------------------------- |
|
258 |
|
259 EAP_FUNC_EXPORT u32_t tls_record_message_c::get_data_length() const |
|
260 { |
|
261 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
262 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
263 return m_length; |
|
264 } |
|
265 |
|
266 //-------------------------------------------------- |
|
267 |
|
268 EAP_FUNC_EXPORT eap_status_e tls_record_message_c::add_data_length(const u32_t data_length) |
|
269 { |
|
270 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
271 |
|
272 if ((m_length + data_length) > tls_handshake_header_c::get_max_data_length()) |
|
273 { |
|
274 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
275 return EAP_STATUS_RETURN(m_am_tools, eap_status_too_long_message); |
|
276 } |
|
277 |
|
278 m_length += data_length; |
|
279 |
|
280 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
281 return EAP_STATUS_RETURN(m_am_tools, eap_status_ok); |
|
282 } |
|
283 |
|
284 //-------------------------------------------------- |
|
285 |
|
286 EAP_FUNC_EXPORT eap_status_e tls_record_message_c::add_handshake_message( |
|
287 tls_handshake_message_c * const handshake_message, |
|
288 const bool free_handshake_message) |
|
289 { |
|
290 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
291 |
|
292 eap_automatic_variable_c<tls_handshake_message_c> |
|
293 automatic_tls_handshake_message(m_am_tools, handshake_message); |
|
294 if (free_handshake_message == false) |
|
295 { |
|
296 automatic_tls_handshake_message.do_not_free_variable(); |
|
297 } |
|
298 |
|
299 if (handshake_message == 0 |
|
300 || handshake_message->get_is_valid() == false) |
|
301 { |
|
302 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
303 return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error); |
|
304 } |
|
305 |
|
306 if (get_protocol() != tls_record_protocol_handshake) |
|
307 { |
|
308 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
309 return EAP_STATUS_RETURN(m_am_tools, eap_status_wrong_protocol); |
|
310 } |
|
311 |
|
312 // Note the m_handshake_messages will free handshake_message, in all cases if free_handshake_message == true. |
|
313 automatic_tls_handshake_message.do_not_free_variable(); |
|
314 |
|
315 eap_status_e status = m_handshake_messages.add_object( |
|
316 handshake_message, |
|
317 free_handshake_message); |
|
318 |
|
319 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
320 return EAP_STATUS_RETURN(m_am_tools, status); |
|
321 } |
|
322 |
|
323 //-------------------------------------------------- |
|
324 |
|
325 EAP_FUNC_EXPORT eap_status_e tls_record_message_c::add_change_cipher_spec_message( |
|
326 tls_change_cipher_spec_message_c * const change_cipher_spec_message, |
|
327 const bool free_change_cipher_spec_message) |
|
328 { |
|
329 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
330 |
|
331 eap_automatic_variable_c<tls_change_cipher_spec_message_c> |
|
332 automatic_tls_handshake_message(m_am_tools, change_cipher_spec_message); |
|
333 if (free_change_cipher_spec_message == false) |
|
334 { |
|
335 automatic_tls_handshake_message.do_not_free_variable(); |
|
336 } |
|
337 |
|
338 if (change_cipher_spec_message == 0) |
|
339 { |
|
340 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
341 return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error); |
|
342 } |
|
343 |
|
344 if (get_protocol() != tls_record_protocol_change_cipher_spec) |
|
345 { |
|
346 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
347 return EAP_STATUS_RETURN(m_am_tools, eap_status_wrong_protocol); |
|
348 } |
|
349 |
|
350 // Note the m_change_cipher_spec_messages will free handshake_message, in all cases if free_change_cipher_spec_message == true. |
|
351 automatic_tls_handshake_message.do_not_free_variable(); |
|
352 |
|
353 eap_status_e status = m_change_cipher_spec_messages.add_object( |
|
354 change_cipher_spec_message, |
|
355 free_change_cipher_spec_message); |
|
356 |
|
357 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
358 return EAP_STATUS_RETURN(m_am_tools, status); |
|
359 } |
|
360 |
|
361 //-------------------------------------------------- |
|
362 |
|
363 EAP_FUNC_EXPORT eap_status_e tls_record_message_c::add_alert_message( |
|
364 tls_alert_message_c * const alert_message, |
|
365 const bool free_alert_message) |
|
366 { |
|
367 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
368 |
|
369 eap_automatic_variable_c<tls_alert_message_c> |
|
370 automatic_tls_handshake_message(m_am_tools, alert_message); |
|
371 if (free_alert_message == false) |
|
372 { |
|
373 automatic_tls_handshake_message.do_not_free_variable(); |
|
374 } |
|
375 |
|
376 if (alert_message == 0) |
|
377 { |
|
378 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
379 return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error); |
|
380 } |
|
381 |
|
382 if (get_protocol() != tls_record_protocol_alert) |
|
383 { |
|
384 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
385 return EAP_STATUS_RETURN(m_am_tools, eap_status_wrong_protocol); |
|
386 } |
|
387 |
|
388 // Note the m_alert_messages will free handshake_message, in all cases if free_alert_message == true. |
|
389 automatic_tls_handshake_message.do_not_free_variable(); |
|
390 |
|
391 eap_status_e status = m_alert_messages.add_object( |
|
392 alert_message, |
|
393 free_alert_message); |
|
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 EAP_FUNC_EXPORT eap_status_e tls_record_message_c::add_application_data_message( |
|
402 tls_application_data_message_c * const application_data_message, |
|
403 const bool free_application_data_message) |
|
404 { |
|
405 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
406 |
|
407 eap_automatic_variable_c<tls_application_data_message_c> |
|
408 automatic_tls_handshake_message(m_am_tools, application_data_message); |
|
409 if (free_application_data_message == false) |
|
410 { |
|
411 automatic_tls_handshake_message.do_not_free_variable(); |
|
412 } |
|
413 |
|
414 if (application_data_message == 0) |
|
415 { |
|
416 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
417 return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error); |
|
418 } |
|
419 |
|
420 if (get_protocol() != tls_record_protocol_application_data) |
|
421 { |
|
422 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
423 return EAP_STATUS_RETURN(m_am_tools, eap_status_wrong_protocol); |
|
424 } |
|
425 |
|
426 // Note the m_application_data_messages will free handshake_message, in all cases if free_application_data_message == true. |
|
427 automatic_tls_handshake_message.do_not_free_variable(); |
|
428 |
|
429 eap_status_e status = m_application_data_messages.add_object( |
|
430 application_data_message, |
|
431 free_application_data_message); |
|
432 |
|
433 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
434 return EAP_STATUS_RETURN(m_am_tools, status); |
|
435 } |
|
436 |
|
437 //-------------------------------------------------- |
|
438 |
|
439 EAP_FUNC_EXPORT eap_status_e tls_record_message_c::add_message_data() |
|
440 { |
|
441 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
442 |
|
443 eap_status_e status = eap_status_not_supported; |
|
444 |
|
445 u32_t offset_of_tmp_tls_record_header = m_record_message_data.get_data_length(); |
|
446 |
|
447 EAP_UNREFERENCED_PARAMETER(offset_of_tmp_tls_record_header); // Not referenced without assert. |
|
448 EAP_ASSERT(offset_of_tmp_tls_record_header == 0ul); |
|
449 |
|
450 |
|
451 u32_t record_data_length_start = m_record_message_data.get_data_length(); |
|
452 |
|
453 |
|
454 switch (get_protocol()) |
|
455 { |
|
456 case tls_record_protocol_change_cipher_spec: |
|
457 { |
|
458 u32_t ind; |
|
459 for (ind = 0ul; ind < m_change_cipher_spec_messages.get_object_count(); ind++) |
|
460 { |
|
461 tls_change_cipher_spec_message_c * const tls_change_cipher_spec_message |
|
462 = m_change_cipher_spec_messages.get_object(ind); |
|
463 if (tls_change_cipher_spec_message == 0 |
|
464 || tls_change_cipher_spec_message->get_is_valid() == false) |
|
465 { |
|
466 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
467 return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error); |
|
468 } |
|
469 |
|
470 status = tls_change_cipher_spec_message->add_message_data(&m_record_message_data); |
|
471 if (status != eap_status_ok) |
|
472 { |
|
473 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
474 return EAP_STATUS_RETURN(m_am_tools, status); |
|
475 } |
|
476 } |
|
477 } |
|
478 break; |
|
479 case tls_record_protocol_alert: |
|
480 { |
|
481 u32_t ind; |
|
482 for (ind = 0ul; ind < m_alert_messages.get_object_count(); ind++) |
|
483 { |
|
484 tls_alert_message_c * const tls_alert_message |
|
485 = m_alert_messages.get_object(ind); |
|
486 if (tls_alert_message == 0 |
|
487 || tls_alert_message->get_is_valid() == false) |
|
488 { |
|
489 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
490 return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error); |
|
491 } |
|
492 |
|
493 status = tls_alert_message->add_message_data(&m_record_message_data); |
|
494 if (status != eap_status_ok) |
|
495 { |
|
496 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
497 return EAP_STATUS_RETURN(m_am_tools, status); |
|
498 } |
|
499 } |
|
500 } |
|
501 break; |
|
502 case tls_record_protocol_handshake: |
|
503 { |
|
504 u32_t ind; |
|
505 for (ind = 0ul; ind < m_handshake_messages.get_object_count(); ind++) |
|
506 { |
|
507 tls_handshake_message_c * const tls_handshake_message = m_handshake_messages.get_object(ind); |
|
508 if (tls_handshake_message == 0 |
|
509 || tls_handshake_message->get_is_valid() == false) |
|
510 { |
|
511 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
512 return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error); |
|
513 } |
|
514 |
|
515 status = tls_handshake_message->add_message_data(&m_record_message_data); |
|
516 if (status != eap_status_ok) |
|
517 { |
|
518 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
519 return EAP_STATUS_RETURN(m_am_tools, status); |
|
520 } |
|
521 } |
|
522 } |
|
523 break; |
|
524 case tls_record_protocol_application_data: |
|
525 { |
|
526 u32_t ind; |
|
527 for (ind = 0ul; ind < m_application_data_messages.get_object_count(); ind++) |
|
528 { |
|
529 tls_application_data_message_c * const tls_application_data_message = m_application_data_messages.get_object(ind); |
|
530 if (tls_application_data_message == 0 |
|
531 || tls_application_data_message->get_is_valid() == false) |
|
532 { |
|
533 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
534 return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error); |
|
535 } |
|
536 |
|
537 status = tls_application_data_message->add_message_data(&m_record_message_data); |
|
538 if (status != eap_status_ok) |
|
539 { |
|
540 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
541 return EAP_STATUS_RETURN(m_am_tools, status); |
|
542 } |
|
543 } |
|
544 } |
|
545 break; |
|
546 default: |
|
547 break; |
|
548 } // switch() |
|
549 |
|
550 |
|
551 if (status == eap_status_ok) |
|
552 { |
|
553 u32_t record_data_length = m_record_message_data.get_data_length() - record_data_length_start; |
|
554 |
|
555 EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("record data length %d bytes.\n"), |
|
556 record_data_length)); |
|
557 |
|
558 status = add_data_length(record_data_length); |
|
559 if (status != eap_status_ok) |
|
560 { |
|
561 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
562 return EAP_STATUS_RETURN(m_am_tools, status); |
|
563 } |
|
564 } |
|
565 |
|
566 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
567 return EAP_STATUS_RETURN(m_am_tools, status); |
|
568 } |
|
569 |
|
570 //-------------------------------------------------- |
|
571 |
|
572 EAP_FUNC_EXPORT u32_t tls_record_message_c::get_handshake_count() const |
|
573 { |
|
574 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
575 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
576 return m_handshake_messages.get_object_count(); |
|
577 } |
|
578 |
|
579 //-------------------------------------------------- |
|
580 |
|
581 EAP_FUNC_EXPORT u32_t tls_record_message_c::get_change_cipher_spec_count() const |
|
582 { |
|
583 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
584 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
585 return m_change_cipher_spec_messages.get_object_count(); |
|
586 } |
|
587 |
|
588 //-------------------------------------------------- |
|
589 |
|
590 EAP_FUNC_EXPORT u32_t tls_record_message_c::get_alert_count() const |
|
591 { |
|
592 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
593 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
594 return m_alert_messages.get_object_count(); |
|
595 } |
|
596 |
|
597 //-------------------------------------------------- |
|
598 |
|
599 EAP_FUNC_EXPORT u32_t tls_record_message_c::get_application_data_count() const |
|
600 { |
|
601 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
602 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
603 return m_application_data_messages.get_object_count(); |
|
604 } |
|
605 |
|
606 //-------------------------------------------------- |
|
607 |
|
608 EAP_FUNC_EXPORT tls_handshake_message_c * tls_record_message_c::get_handshake( |
|
609 const u32_t index) EAP_TEMPLATE_CONST |
|
610 { |
|
611 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
612 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
613 return m_handshake_messages.get_object(index); |
|
614 } |
|
615 |
|
616 //-------------------------------------------------- |
|
617 |
|
618 EAP_FUNC_EXPORT const tls_change_cipher_spec_message_c * tls_record_message_c::get_change_cipher_spec( |
|
619 const u32_t index) const |
|
620 { |
|
621 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
622 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
623 return m_change_cipher_spec_messages.get_object(index); |
|
624 } |
|
625 |
|
626 //-------------------------------------------------- |
|
627 |
|
628 EAP_FUNC_EXPORT const tls_alert_message_c * tls_record_message_c::get_alert( |
|
629 const u32_t index) const |
|
630 { |
|
631 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
632 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
633 return m_alert_messages.get_object(index); |
|
634 } |
|
635 |
|
636 //-------------------------------------------------- |
|
637 |
|
638 EAP_FUNC_EXPORT tls_application_data_message_c * tls_record_message_c::get_application_data( |
|
639 const u32_t index) const |
|
640 { |
|
641 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
642 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
643 return m_application_data_messages.get_object(index); |
|
644 } |
|
645 |
|
646 //-------------------------------------------------- |
|
647 |
|
648 |
|
649 |
|
650 // End. |