|
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(_GSMSIM_CORE_H_) |
|
22 #define _GSMSIM_CORE_H_ |
|
23 |
|
24 #include "eap_tools.h" |
|
25 #include "eap_am_export.h" |
|
26 #include "eap_base_type.h" |
|
27 #include "eap_variable_data.h" |
|
28 #include "eap_type_gsmsim_types.h" |
|
29 #include "eap_type_gsmsim_payloads.h" |
|
30 #include "eap_type_gsmsim_state.h" |
|
31 #include "abs_eap_base_timer.h" |
|
32 #include "abs_eap_am_type_gsmsim.h" |
|
33 #include "eap_master_session_key.h" |
|
34 |
|
35 |
|
36 class eap_type_gsmsim_MAC_attributes_c; |
|
37 class eap_am_type_gsmsim_c; |
|
38 class crypto_hmac_c; |
|
39 |
|
40 //#define USE_EAP_GSMSIM_VERIFY_STATES |
|
41 |
|
42 //-------------------------------------------------- |
|
43 |
|
44 |
|
45 /// This class is implementation of GSMSIM EAP-type. |
|
46 class EAP_EXPORT eap_type_gsmsim_c |
|
47 : public abs_eap_type_gsmsim_state_c |
|
48 , public abs_eap_am_type_gsmsim_c |
|
49 , public abs_eap_base_timer_c |
|
50 , public eap_base_type_c |
|
51 { |
|
52 private: |
|
53 //-------------------------------------------------- |
|
54 |
|
55 /// This is pointer to the tools class. |
|
56 abs_eap_am_tools_c * const m_am_tools; |
|
57 |
|
58 //-------------------------------------------------- |
|
59 |
|
60 #if !defined(NO_EAP_TYPE_GSMSIM_MESSAGE_STATE_CHECK) |
|
61 /// This attribute stores the valid GSMSIM states (eap_type_gsmsim_state_variable_e). |
|
62 /// Each eap_type_gsmsim_state_variable_parameters_c includes the valid |
|
63 /// GSMSIM messages within the state. |
|
64 eap_type_gsmsim_state_variable_parameters_c m_parameters[eap_type_gsmsim_state_last_value]; |
|
65 #endif //#if !defined(NO_EAP_TYPE_GSMSIM_MESSAGE_STATE_CHECK) |
|
66 |
|
67 /// This is the current state. |
|
68 eap_type_gsmsim_state_variable_e m_state; |
|
69 |
|
70 /// This is the saved previous state. On error case this is the state where continue. |
|
71 eap_type_gsmsim_state_variable_e m_saved_previous_state; |
|
72 |
|
73 /// This is network identity of the sent packet from this handler. |
|
74 eap_am_network_id_c m_send_network_id; |
|
75 |
|
76 /// This is the NONCE_MT. Client generates NONCE_MT and sends it to server |
|
77 /// within the EAP-Response/SIM/Start message. |
|
78 eap_variable_data_c m_nonce_mt; |
|
79 |
|
80 /// This is the NONCE_S. Server generates NONCE_S and sends it to client |
|
81 /// within the EAP-Request/SIM/Re-authentication message. |
|
82 eap_variable_data_c m_nonce_s; |
|
83 |
|
84 // - - - - - - - - - - - - - - - - - - - - |
|
85 |
|
86 /// Server sends IV to client within EAP-Request/SIM/Challenge message. |
|
87 /// The AT_IV payload is optional. |
|
88 gsmsim_variable_data_c m_IV; |
|
89 |
|
90 /// EAP-Request/SIM/Challenge message must be saved until n*Kc and n*SRES are get from SIM. |
|
91 eap_variable_data_c m_saved_EAP_packet; |
|
92 |
|
93 // - - - - - - - - - - - - - - - - - - - - |
|
94 |
|
95 /// XKEY = SHA1(n*Kc| NONCE_MT) |
|
96 eap_variable_data_c m_XKEY; |
|
97 |
|
98 /// K_encr is the first 16 octets of generated Key_block:s. |
|
99 eap_variable_data_c m_K_encr; |
|
100 |
|
101 /// K_aut is the 16 octets after K_encr of generated Key_block:s. |
|
102 eap_variable_data_c m_K_aut; |
|
103 |
|
104 /// m_master_session_key is the 20 octets after m_K_aut of generated Key_block:s. |
|
105 eap_master_session_key_c m_master_session_key; |
|
106 |
|
107 // - - - - - - - - - - - - - - - - - - - - |
|
108 |
|
109 /// This is the real IMSI. |
|
110 eap_variable_data_c m_IMSI; |
|
111 |
|
112 /// This is the pseudonym for IMSI. This is used only if server supports use of pseudonym. |
|
113 eap_variable_data_c m_pseudonym; |
|
114 |
|
115 /// This is the reauthentication identity. This is used only if server supports use of reauthentication identity. |
|
116 eap_variable_data_c m_reauthentication_identity; |
|
117 |
|
118 /// This is the automatic realm generated in AM of EAP-SIM. |
|
119 /// Note this could be invalid data when automatic realm is not used. |
|
120 /// The m_automatic_realm_read flag tells whether m_automatic_realm is read from AM of EAP-SIM. |
|
121 eap_variable_data_c m_automatic_realm; |
|
122 |
|
123 /// This flag tells whether automatic realm is read from AM of EAP-SIM. |
|
124 /// Note the data of m_automatic_realm could be invalid data when it is not used. |
|
125 bool m_automatic_realm_read; |
|
126 |
|
127 /// This is identity used in authentication. This is real IMSI or pseudonym. |
|
128 /// Pseudonym is used only if server supports use of pseudonym. |
|
129 eap_variable_data_c m_identity; |
|
130 |
|
131 /// This is the NAI. Format is "username@realm". |
|
132 eap_variable_data_c m_NAI; |
|
133 |
|
134 eap_variable_data_c m_n_rands; |
|
135 |
|
136 eap_variable_data_c m_n_sres; |
|
137 |
|
138 /// This variable stores the received GSMSIM version list. |
|
139 eap_variable_data_c m_gsmsim_version_list; |
|
140 |
|
141 #if defined(USE_EAP_TYPE_SERVER_GSMSIM) |
|
142 /// Here is stored the received triplets. |
|
143 eap_type_sim_triplet_array_c *m_triplets; |
|
144 #endif //#if defined(USE_EAP_TYPE_SERVER_GSMSIM) |
|
145 |
|
146 |
|
147 u32_t m_reauthentication_counter; |
|
148 |
|
149 gsmsim_payload_AT_type_e m_include_identity_to_start_response; |
|
150 |
|
151 /// Identity of this type is included in start response. |
|
152 gsmsim_payload_AT_type_e m_start_response_includes_identity; |
|
153 |
|
154 /// This flag indicates whether the EAP-Failure was received. |
|
155 /// On successfull authentication bogus EAP-Failure is ignored. |
|
156 bool m_failure_message_received; |
|
157 /// This flag indicated whether the authentication was successfull (true). |
|
158 bool m_authentication_finished_successfully; |
|
159 |
|
160 /// This variable stores the last used EAP-Identifier. |
|
161 /// Client will always send EAP-Response with this identifier. |
|
162 /// Server will always send EAP-Request with this identifier increased by one. |
|
163 /// Server increase this identifier after successfull packet send. |
|
164 u8_t m_last_eap_identifier; |
|
165 |
|
166 eap_gsmsim_version m_gsmsim_selected_version; |
|
167 |
|
168 eap_variable_data_c m_2_digit_mnc_map_of_mcc_of_imsi_array; |
|
169 |
|
170 eap_variable_data_c m_uma_automatic_realm_prefix; |
|
171 |
|
172 bool m_use_uma_profile; |
|
173 |
|
174 //-------------------------------------------------- |
|
175 |
|
176 /// This is pointer to adaptation module of GSMSIM EAP type. |
|
177 eap_am_type_gsmsim_c * const m_am_type_gsmsim; |
|
178 |
|
179 #if defined(_DEBUG) && defined(USE_EAP_GSMSIM_TEST_VECTORS) |
|
180 eap_variable_data_c m_nonce_mt_file; |
|
181 #endif //#if defined(_DEBUG) && defined(USE_EAP_GSMSIM_TEST_VECTORS) |
|
182 |
|
183 eap_variable_data_c m_manual_username; |
|
184 |
|
185 eap_variable_data_c m_manual_realm; |
|
186 |
|
187 /// This eap_gsmsim_version array is the supported GSMSIM version list. |
|
188 eap_gsmsim_version m_supported_versions[GSMSIM_LAST_VERSION]; |
|
189 |
|
190 /// This is offset in bytes of the EAP-type header in the packet buffer. |
|
191 /// Offset is described in abs_eap_base_type_c::get_header_offset(). |
|
192 u32_t m_gsmsim_header_offset; |
|
193 |
|
194 /// This is maximum transfer unit in bytes. |
|
195 /// MTU is described in abs_eap_base_type_c::get_header_offset(). |
|
196 u32_t m_MTU; |
|
197 |
|
198 /// This is length of the trailer in bytes. |
|
199 /// Trailer length is described in abs_eap_base_type_c::get_header_offset(). |
|
200 u32_t m_trailer_length; |
|
201 |
|
202 /// This is minimum count of RAND challenges accepted. |
|
203 u32_t m_minimum_rand_count; |
|
204 |
|
205 u32_t m_length_of_mnc; |
|
206 |
|
207 /// This stores the current authentication type. |
|
208 /// Look at the m_identity_type too. |
|
209 eap_gsmsim_authentication_type_e m_authentication_type; |
|
210 |
|
211 /// This stores the current identity type. |
|
212 /// NOTE there is one stupid case where m_identity_type is GSMSIM_IDENTITY_TYPE_RE_AUTH_ID |
|
213 /// and m_authentication_type is GSMSIM_AUTHENTICATION_TYPE_FULL_AUTH. |
|
214 /// Look at the Chapter "Fast Re-authentication Procedure when Counter is Too Small" |
|
215 /// in the EAP-SIM specification. |
|
216 /// Because of that illogical specification we need separate |
|
217 /// attributes for authentication type and identity type. |
|
218 eap_type_gsmsim_identity_type m_identity_type; |
|
219 |
|
220 /// This is the first client error. |
|
221 eap_gsmsim_client_error_code_e m_client_error_code; |
|
222 |
|
223 /// This is saved GSMSIM notificatoin code. |
|
224 /// If this value is eap_gsmsim_notification_none, no notification is stored. |
|
225 eap_gsmsim_notification_codes_e m_gsmsim_notification_code; |
|
226 |
|
227 u32_t m_failure_message_delay_time; |
|
228 |
|
229 /// This indicates whether this object was generated successfully. |
|
230 bool m_is_valid; |
|
231 |
|
232 /// This indicates whether this object is client (true) or server (false). |
|
233 /// In terms of EAP-protocol whether this network entity is EAP-supplicant (true) or EAP-authenticator (false). |
|
234 bool m_is_client; |
|
235 |
|
236 /// True value of this flag indicates the EAP-Success packet must be received |
|
237 /// in successfull authentication of clien. |
|
238 /// This value is configured with EAP_GSMSIM_wait_eap_success_packet. |
|
239 bool m_wait_eap_success_packet; |
|
240 |
|
241 /// True value of this flag indicates the identifier of the EAP-Response/Identity must be checked. |
|
242 /// This is not possible cases where identifier of the EAP-Request/Identity is generated by other network entities. |
|
243 bool m_check_identifier_of_eap_identity_response; |
|
244 |
|
245 |
|
246 /// True value means m_am_type_gsmsim is allocated within eap_type_gsmsim_c |
|
247 /// and m_am_type_gsmsim must be freed in destructor. |
|
248 bool m_free_am_type_gsmsim; |
|
249 |
|
250 #if defined(USE_EAP_TYPE_GSMSIM_OWN_RE_TRANSMISSION) |
|
251 /// True value means client responds to all re-transmitted EAP-SIM packets. |
|
252 /// False value means client does not respond to any re-transmitted EAP-SIM packets. |
|
253 bool m_client_responds_retransmitted_packets; |
|
254 #endif //#if defined(USE_EAP_TYPE_GSMSIM_OWN_RE_TRANSMISSION) |
|
255 |
|
256 /// True value means this is a test version of GSMSIM. |
|
257 bool m_gsmsim_test_version; |
|
258 |
|
259 /// True value means server refuses EAP-identity randomly. |
|
260 /// False value means does not refuse EAP-identity randomly. |
|
261 /// NOTE EAP_GSMSIM_test_version option must be true also. |
|
262 bool m_gsmsim_randomly_refuse_eap_identity; |
|
263 |
|
264 /// This flag forces check of NAI realm. Realm must be the same as given in EAP_GSMSIM_manual_realm configuration option. |
|
265 /// Default value is false, check is not done by default. |
|
266 bool m_check_nai_realm; |
|
267 |
|
268 /// This is for testing purposes. True value will cause failed test of re-authentication counter. |
|
269 bool m_fail_reauthentication_counter_check; |
|
270 |
|
271 /// True value of this flag allows acception of EAP-Response/Identity. |
|
272 /// False value does not accept EAP-Response/Identity. Instead identity is queried |
|
273 /// in EAP-Request/SIM/Start with AT_ANY_ID_REQ attribute. |
|
274 bool m_accept_eap_identity_response; |
|
275 |
|
276 /// True value of this flag returns random |
|
277 /// identity on EAP-Response/Identity. |
|
278 /// False value returns real identity |
|
279 /// (IMSI, pseudonym or re-authentication identity). |
|
280 bool m_use_random_identity_on_eap_identity_response; |
|
281 |
|
282 /// This flag is set true when shutdown() function is called. |
|
283 bool m_shutdown_was_called; |
|
284 |
|
285 /// This flag is set true when reset() function is called. |
|
286 /// This flag prevent multiple subsequent calls of rset() function. |
|
287 bool m_reset_was_called; |
|
288 |
|
289 /// This flag tells whether the client should check uniqueness of RANDs (true) or not (false). |
|
290 bool m_do_rand_uniqueness_check; |
|
291 |
|
292 /// This flag tells whether the pseudonym identity could be used (true) or not (false). |
|
293 bool m_use_pseudonym_identity; |
|
294 |
|
295 /// This flag tells whether the re-authentication identity could be used (true) or not (false). |
|
296 bool m_use_reauthentication_identity; |
|
297 |
|
298 /// This is set true when erroneus packet is received. |
|
299 bool m_erroneus_packet_received; |
|
300 |
|
301 /// This is set true when SIM notification packet is received. |
|
302 bool m_sim_notification_packet_received; |
|
303 |
|
304 /// This flag allows use of Windows RAS identity in EAP-Identity/Response. |
|
305 /// EAP-Request/Start will include identity query attribute. |
|
306 bool m_use_manual_username; |
|
307 |
|
308 /// Default value is false. That will cause use of automatic realm. |
|
309 /// If this is true then |
|
310 /// cf_str_EAP_GSMSIM_manual_realm is used as the realm. |
|
311 bool m_use_manual_realm; |
|
312 |
|
313 bool m_randomly_fail_successfull_authentication; |
|
314 |
|
315 bool m_allow_use_result_indication; |
|
316 |
|
317 bool m_use_result_indication; |
|
318 |
|
319 bool m_use_eap_expanded_type; |
|
320 |
|
321 //-------------------------------------------------- |
|
322 |
|
323 /** |
|
324 * This function stores the last encryption IV. In CBC-mode previous encrypted block is |
|
325 * used as a IV of next block. |
|
326 */ |
|
327 eap_status_e store_last_encryption_iv(const eap_variable_data_c * const encryption_IV); |
|
328 |
|
329 /** |
|
330 * This function selects best version from version list payload. |
|
331 */ |
|
332 EAP_FUNC_IMPORT eap_gsmsim_version select_version( |
|
333 const gsmsim_variable_data_c * const version_payload, |
|
334 bool * const includes_other_version_than_1); |
|
335 |
|
336 /** |
|
337 * This function returns string of the current state. This is for trace purposes. |
|
338 */ |
|
339 EAP_FUNC_IMPORT eap_const_string get_state_string() const; |
|
340 |
|
341 /** |
|
342 * This function returns string of the current state. This is for trace purposes. |
|
343 */ |
|
344 EAP_FUNC_IMPORT eap_const_string get_saved_previous_state_string() const; |
|
345 |
|
346 /** |
|
347 * This function sets the new state and notifies the lower layer of this change. |
|
348 */ |
|
349 void set_state(eap_type_gsmsim_state_variable_e state); |
|
350 |
|
351 #define GSMSIM_STATE_COUNT(array) (sizeof(array)/sizeof(array[0])) |
|
352 |
|
353 /** |
|
354 * This function checks the valid states. |
|
355 */ |
|
356 bool verify_states( |
|
357 const eap_type_gsmsim_state_variable_e * const valid_states, |
|
358 const u32_t count) const; |
|
359 |
|
360 |
|
361 #if !defined(NO_EAP_TYPE_GSMSIM_MESSAGE_STATE_CHECK) |
|
362 |
|
363 /** |
|
364 * This function checks the received GSMSIM subtype is valid in current state. |
|
365 * This is used for quick check. |
|
366 */ |
|
367 EAP_FUNC_IMPORT eap_status_e check_valid_state(gsmsim_subtype_e type); |
|
368 |
|
369 /** |
|
370 * This function returns the eap_type_gsmsim_state_variable_parameters_c object of current state. |
|
371 */ |
|
372 EAP_FUNC_IMPORT const eap_type_gsmsim_state_variable_parameters_c * get_state_variable(); |
|
373 |
|
374 #endif //#if !defined(NO_EAP_TYPE_GSMSIM_MESSAGE_STATE_CHECK) |
|
375 |
|
376 |
|
377 /** |
|
378 * This function saves the current m_state to m_saved_previous_state. |
|
379 * The saved state is restored in error case. |
|
380 */ |
|
381 EAP_FUNC_IMPORT void save_current_state(); |
|
382 |
|
383 /** |
|
384 * This function restores the saved state. |
|
385 */ |
|
386 EAP_FUNC_IMPORT void restore_saved_previous_state(); |
|
387 |
|
388 /** |
|
389 * This function stores identity. |
|
390 */ |
|
391 EAP_FUNC_IMPORT eap_status_e store_identity( |
|
392 const eap_variable_data_c * const IMSI_or_pseudonym, |
|
393 const bool IMSI_is_used); |
|
394 |
|
395 #if !defined(NO_EAP_TYPE_GSMSIM_MESSAGE_STATE_CHECK) |
|
396 /** |
|
397 * This function initializes the allowed messages within one specific state. |
|
398 */ |
|
399 EAP_FUNC_IMPORT void initialize_state( |
|
400 const eap_type_gsmsim_state_variable_e state, |
|
401 const bool must_be_initiator, |
|
402 const bool must_be_responder, |
|
403 const gsmsim_subtype_e type0, |
|
404 const gsmsim_subtype_e type1, |
|
405 const gsmsim_subtype_e type2, |
|
406 const gsmsim_subtype_e type3); |
|
407 #endif //#if !defined(NO_EAP_TYPE_GSMSIM_MESSAGE_STATE_CHECK) |
|
408 |
|
409 /** |
|
410 * This function expands key and seed data to key_length of expansion. |
|
411 * expansion_0 = prf(key, seed | 0) |
|
412 * expansion_i = prf(key, expansion_i-1 | seed | i), where i = 1, 2... |
|
413 */ |
|
414 EAP_FUNC_IMPORT eap_status_e data_exp( |
|
415 const u32_t key_length, |
|
416 eap_variable_data_c * const expansion, |
|
417 const eap_variable_data_c * const key, |
|
418 const eap_variable_data_c * const seed); |
|
419 |
|
420 /** |
|
421 * This function generates K_encr, K_aut and master_session_key. |
|
422 */ |
|
423 EAP_FUNC_IMPORT eap_status_e generate_shared_secred_keys( |
|
424 const u32_t key_length, |
|
425 const eap_variable_data_c * const n_Kc, |
|
426 const eap_variable_data_c * const n_sres, |
|
427 eap_variable_data_c * const XKEY, |
|
428 eap_variable_data_c * const K_encr, |
|
429 eap_variable_data_c * const K_aut, |
|
430 eap_variable_data_c * const master_session_key); |
|
431 |
|
432 |
|
433 /** |
|
434 * This function generates K_encr, K_aut and master_session_key. |
|
435 */ |
|
436 EAP_FUNC_IMPORT eap_status_e generate_reauth_shared_secred_keys( |
|
437 const u32_t key_length, |
|
438 const eap_variable_data_c * const orig_XKEY, |
|
439 const u32_t reauth_counter, |
|
440 const eap_variable_data_c * const reauth_identity, |
|
441 const eap_variable_data_c * const reauth_nonce_s, |
|
442 eap_variable_data_c * const master_session_key); |
|
443 |
|
444 #if defined(USE_EAP_TYPE_SERVER_GSMSIM) |
|
445 /** |
|
446 * This function stores pointer to the received triplet array. |
|
447 */ |
|
448 void set_triplets(eap_type_sim_triplet_array_c * const triplets); |
|
449 #endif //#if defined(USE_EAP_TYPE_SERVER_GSMSIM) |
|
450 |
|
451 /** |
|
452 * This function saves version list from version list payload. |
|
453 */ |
|
454 EAP_FUNC_IMPORT eap_status_e save_version( |
|
455 const u16_t * const payload_version_list, |
|
456 const u32_t version_count, |
|
457 const eap_gsmsim_version selected_version); |
|
458 |
|
459 /** |
|
460 * This function generates a new NAI from domain and IMSI. |
|
461 */ |
|
462 EAP_FUNC_IMPORT eap_status_e generate_nai( |
|
463 eap_variable_data_c * const new_nai, ///< This is the new generated NAI. |
|
464 const bool use_manual_default_realm, ///< When true uses realm parameter, when false generates automatic realm. |
|
465 const eap_variable_data_c * const realm, ///< This is the domain part of the NAI. |
|
466 const eap_variable_data_c * const id_IMSI_or_pseydonym, ///< This is IMSI or pseudonym. |
|
467 const bool id_is_imsi, ///< This parameter tells whether id_IMSI_or_pseydonym is IMSI (true) or pseudonym (false). |
|
468 const eap_variable_data_c * const IMSI, ///< This parameter must be IMSI always. |
|
469 const eap_variable_data_c * const automatic_realm, ///< This could be zero pointer if this is not used. |
|
470 const u32_t length_of_mnc |
|
471 ); |
|
472 |
|
473 /** |
|
474 * This function adds generic attribute payload to GSMSIM message. |
|
475 * @param gsmsim is pointer to EAP header including GSMSIM fields. |
|
476 * @param maximum_buffer_size is the maximum length of sent packet. |
|
477 * @param eap_header_size is length of EAP header. |
|
478 * See also gsmsim_header_c and eap_header_base_c. |
|
479 * @param data_offset is the offset of inserted payloads in GSMSIM EAP packet. |
|
480 * It is the value of GSMSIM sub-type data. |
|
481 * @param data_free is the remaining free GSMSIM data buffer size. |
|
482 * @param buffer_free is the remaining free packet buffer size. |
|
483 * @param buffer_offset is the offset from the begin of the packet buffer |
|
484 * to the end of the last data payload. |
|
485 * @param data_payload is the new payload to be added. |
|
486 * @param data_payload_type is the attribute payload type to be added. |
|
487 * |
|
488 * See also eap_type_gsmsim_c::update_payload_indexes(). |
|
489 * |
|
490 * Format of the payload is as follows: |
|
491 * @code |
|
492 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
|
493 * | AT type | Payload Length| Reserved | |
|
494 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
|
495 * | Any variable length payload | |
|
496 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
|
497 * @endcode |
|
498 */ |
|
499 EAP_FUNC_IMPORT eap_status_e add_variable_payload( |
|
500 gsmsim_header_c * const gsmsim, |
|
501 const u32_t maximum_buffer_size, |
|
502 const u32_t eap_header_size, |
|
503 u32_t * const data_offset, |
|
504 u32_t * const data_free, |
|
505 u32_t * const buffer_free, |
|
506 u32_t * const buffer_offset, |
|
507 const eap_variable_data_c * const data_payload, |
|
508 const gsmsim_payload_AT_type_e data_payload_type); |
|
509 |
|
510 |
|
511 /** |
|
512 * This function adds IMSI or pseudonym attribute payload to GSMSIM message. |
|
513 * @param gsmsim is pointer to EAP header including GSMSIM fields. |
|
514 * @param maximum_buffer_size is the maximum length of sent packet. |
|
515 * @param eap_header_size is length of EAP header. |
|
516 * See also gsmsim_header_c and eap_header_base_c. |
|
517 * @param data_offset is the offset of inserted payloads in GSMSIM EAP packet. |
|
518 * It is the value of GSMSIM sub-type data. |
|
519 * @param data_free is the remaining free GSMSIM data buffer size. |
|
520 * @param buffer_free is the remaining free packet buffer size. |
|
521 * @param buffer_offset is the offset from the begin of the packet buffer |
|
522 * to the end of the last data payload. |
|
523 * @param pseudonym_or_imsi is the IMSI or pseudonym payload to be added. |
|
524 * @param data_payload_type is the attribute payload type to be added. |
|
525 * |
|
526 * See also eap_type_gsmsim_c::update_payload_indexes(). |
|
527 * |
|
528 * Format of the payload is as follows: |
|
529 * @code |
|
530 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
|
531 * | AT_<type> | Length | Actual Pseudonym Length | |
|
532 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
|
533 * | | |
|
534 * | Pseudonym or IMSI | |
|
535 * | | |
|
536 * | | |
|
537 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
|
538 * @endcode |
|
539 */ |
|
540 EAP_FUNC_IMPORT eap_status_e add_pseudonym_or_imsi_payload( |
|
541 gsmsim_header_c * const gsmsim, |
|
542 const u32_t maximum_buffer_size, |
|
543 const u32_t eap_header_size, |
|
544 u32_t * const data_offset, |
|
545 u32_t * const data_free, |
|
546 u32_t * const buffer_free, |
|
547 u32_t * const buffer_offset, |
|
548 const eap_variable_data_c * const pseudonym_or_imsi, |
|
549 const gsmsim_payload_AT_type_e data_payload_type); |
|
550 |
|
551 |
|
552 /** |
|
553 * This function adds version list attribute payload to GSMSIM message. |
|
554 * @param gsmsim is pointer to EAP header including GSMSIM fields. |
|
555 * @param maximum_buffer_size is the maximum length of sent packet. |
|
556 * @param eap_header_size is length of EAP header. |
|
557 * See also gsmsim_header_c and eap_header_base_c. |
|
558 * @param data_offset is the offset of inserted payloads in GSMSIM EAP packet. |
|
559 * It is the value of GSMSIM sub-type data. |
|
560 * @param data_free is the remaining free GSMSIM data buffer size. |
|
561 * @param buffer_free is the remaining free packet buffer size. |
|
562 * @param buffer_offset is the offset from the begin of the packet buffer |
|
563 * to the end of the last data payload. |
|
564 * @param gsmsim_versions is the version list (actually array) payload to be added. |
|
565 * @param gsmsim_versions_count is the count versions in the array. |
|
566 * @param data_payload_type is the attribute payload type to be added. |
|
567 * |
|
568 * See also eap_type_gsmsim_c::update_payload_indexes(). |
|
569 * |
|
570 * Format of the payload is as follows: |
|
571 * @code |
|
572 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
|
573 * | AT_VERSION_L..| Length | Actual Version List Length | |
|
574 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
|
575 * | Supported Version 1 | Padding | |
|
576 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
|
577 * @endcode |
|
578 */ |
|
579 EAP_FUNC_IMPORT eap_status_e add_version_list( |
|
580 gsmsim_header_c * const gsmsim, |
|
581 const u32_t gsmsim_buffer_length, |
|
582 const u32_t eap_header_size, |
|
583 u32_t * const gsmsim_data_offset, |
|
584 u32_t * const gsmsim_data_free, |
|
585 u32_t * const packet_buffer_free, |
|
586 u32_t * const packet_buffer_offset, |
|
587 const eap_gsmsim_version *gsmsim_versions, |
|
588 const u32_t gsmsim_versions_count, |
|
589 const gsmsim_payload_AT_type_e data_payload_type); |
|
590 |
|
591 |
|
592 /** |
|
593 * This function adds selected version attribute payload to GSMSIM message. |
|
594 * @param gsmsim is pointer to EAP header including GSMSIM fields. |
|
595 * @param gsmsim_buffer_length is the maximum length of sent packet. |
|
596 * @param eap_header_size is length of EAP header. |
|
597 * See also gsmsim_header_c and eap_header_base_c. |
|
598 * @param gsmsim_data_offset is the offset of inserted payloads in GSMSIM EAP packet. |
|
599 * It is the value of GSMSIM sub-type data. |
|
600 * @param gsmsim_data_free is the remaining free GSMSIM data buffer size. |
|
601 * @param packet_buffer_free is the remaining free packet buffer size. |
|
602 * @param packet_buffer_offset is the offset from the begin of the packet buffer |
|
603 * to the end of the last data payload. |
|
604 * @param version is the selected GSMSIM version. |
|
605 * |
|
606 * See also eap_type_gsmsim_c::update_payload_indexes(). |
|
607 * |
|
608 * Format of the payload is as follows: |
|
609 * @code |
|
610 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
|
611 * |AT_SELECTED_...| Length = 1 | Notification Code | |
|
612 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
|
613 * @endcode |
|
614 */ |
|
615 EAP_FUNC_IMPORT eap_status_e add_version_payload( |
|
616 gsmsim_header_c * const gsmsim, |
|
617 const u32_t gsmsim_buffer_length, |
|
618 const u32_t eap_header_size, |
|
619 u32_t * const gsmsim_data_offset, |
|
620 u32_t * const gsmsim_data_free, |
|
621 u32_t * const packet_buffer_free, |
|
622 u32_t * const packet_buffer_offset, |
|
623 const eap_gsmsim_version version); |
|
624 |
|
625 /** |
|
626 * This function adds selected version attribute payload to GSMSIM message. |
|
627 * @param gsmsim is pointer to EAP header including GSMSIM fields. |
|
628 * @param gsmsim_buffer_length is the maximum length of sent packet. |
|
629 * @param eap_header_size is length of EAP header. |
|
630 * See also gsmsim_header_c and eap_header_base_c. |
|
631 * @param gsmsim_data_offset is the offset of inserted payloads in GSMSIM EAP packet. |
|
632 * It is the value of GSMSIM sub-type data. |
|
633 * @param gsmsim_data_free is the remaining free GSMSIM data buffer size. |
|
634 * @param packet_buffer_free is the remaining free packet buffer size. |
|
635 * @param packet_buffer_offset is the offset from the begin of the packet buffer |
|
636 * to the end of the last data payload. |
|
637 * @param counter is the re-authentication counter. |
|
638 * |
|
639 * See also eap_type_gsmsim_c::update_payload_indexes(). |
|
640 * |
|
641 * Format of the payload is as follows: |
|
642 * @code |
|
643 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
|
644 * |AT_COUNTER | Length = 1 | Counter | |
|
645 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
|
646 * @endcode |
|
647 */ |
|
648 EAP_FUNC_IMPORT eap_status_e add_counter_payload( |
|
649 gsmsim_header_c * const gsmsim, |
|
650 const u32_t gsmsim_buffer_length, |
|
651 const u32_t eap_header_size, |
|
652 u32_t * const gsmsim_data_offset, |
|
653 u32_t * const gsmsim_data_free, |
|
654 u32_t * const packet_buffer_free, |
|
655 u32_t * const packet_buffer_offset, |
|
656 u16_t counter); |
|
657 |
|
658 /** |
|
659 * This function adds simple attribute payload to GSMSIM message. |
|
660 * @param gsmsim is pointer to EAP header including GSMSIM fields. |
|
661 * @param gsmsim_buffer_length is the maximum length of sent packet. |
|
662 * @param eap_header_size is length of EAP header. |
|
663 * See also gsmsim_header_c and eap_header_base_c. |
|
664 * @param gsmsim_data_offset is the offset of inserted payloads in GSMSIM EAP packet. |
|
665 * It is the value of GSMSIM sub-type data. |
|
666 * @param gsmsim_data_free is the remaining free GSMSIM data buffer size. |
|
667 * @param packet_buffer_free is the remaining free packet buffer size. |
|
668 * @param packet_buffer_offset is the offset from the begin of the packet buffer |
|
669 * to the end of the last data payload. |
|
670 * @param data_payload_type is the type of simple payload. |
|
671 * |
|
672 * See also eap_type_gsmsim_c::update_payload_indexes(). |
|
673 * |
|
674 * Format of the payload is as follows: |
|
675 * @code |
|
676 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
|
677 * |AT_XXX | Length = 1 | Reserved | |
|
678 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
|
679 * @endcode |
|
680 */ |
|
681 EAP_FUNC_IMPORT eap_status_e add_simple_payload( |
|
682 gsmsim_header_c * const gsmsim, |
|
683 const u32_t gsmsim_buffer_length, |
|
684 const u32_t eap_header_size, |
|
685 u32_t * const gsmsim_data_offset, |
|
686 u32_t * const gsmsim_data_free, |
|
687 u32_t * const packet_buffer_free, |
|
688 u32_t * const packet_buffer_offset, |
|
689 const gsmsim_payload_AT_type_e data_payload_type); |
|
690 |
|
691 /** |
|
692 * This function adds Notification attribute payload to GSMSIM message. |
|
693 * @param gsmsim is pointer to EAP header including GSMSIM fields. |
|
694 * @param gsmsim_buffer_length is the maximum length of sent packet. |
|
695 * @param eap_header_size is length of EAP header. |
|
696 * See also gsmsim_header_c and eap_header_base_c. |
|
697 * @param gsmsim_data_offset is the offset of inserted payloads in GSMSIM EAP packet. |
|
698 * It is the value of GSMSIM sub-type data. |
|
699 * @param gsmsim_data_free is the remaining free GSMSIM data buffer size. |
|
700 * @param packet_buffer_free is the remaining free packet buffer size. |
|
701 * @param packet_buffer_offset is the offset from the begin of the packet buffer |
|
702 * to the end of the last data payload. |
|
703 * @param triplet_status is the notification. |
|
704 * |
|
705 * See also eap_type_gsmsim_c::update_payload_indexes(). |
|
706 * |
|
707 * Format of the payload is as follows: |
|
708 * @code |
|
709 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
|
710 * |AT_NOTIFICATION| Length = 1 | Notification Code | |
|
711 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
|
712 * @endcode |
|
713 */ |
|
714 EAP_FUNC_IMPORT eap_status_e add_notification_payload( |
|
715 gsmsim_header_c * const gsmsim, |
|
716 const u32_t gsmsim_buffer_length, |
|
717 const u32_t eap_header_size, |
|
718 u32_t * const gsmsim_data_offset, |
|
719 u32_t * const gsmsim_data_free, |
|
720 u32_t * const packet_buffer_free, |
|
721 u32_t * const packet_buffer_offset, |
|
722 const eap_gsmsim_notification_codes_e notification_code); |
|
723 |
|
724 /** |
|
725 * This function adds AT_CLIENT_ERROR_CODE attribute payload to GSMSIM message. |
|
726 * @param gsmsim is pointer to EAP header including GSMSIM fields. |
|
727 * @param gsmsim_buffer_length is the maximum length of sent packet. |
|
728 * @param eap_header_size is length of EAP header. |
|
729 * See also gsmsim_header_c and eap_header_base_c. |
|
730 * @param gsmsim_data_offset is the offset of inserted payloads in GSMSIM EAP packet. |
|
731 * It is the value of GSMSIM sub-type data. |
|
732 * @param gsmsim_data_free is the remaining free GSMSIM data buffer size. |
|
733 * @param packet_buffer_free is the remaining free packet buffer size. |
|
734 * @param packet_buffer_offset is the offset from the begin of the packet buffer |
|
735 * to the end of the last data payload. |
|
736 * @param client_error_code is the error code to be sent. |
|
737 * |
|
738 * See also eap_type_gsmsim_c::update_payload_indexes(). |
|
739 * |
|
740 * Format of the payload is as follows: |
|
741 * @code |
|
742 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
|
743 * |AT_CLIENT_ERR..| Length = 1 | Client Error Code | |
|
744 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
|
745 * @endcode |
|
746 */ |
|
747 EAP_FUNC_IMPORT eap_status_e add_client_error_payload( |
|
748 gsmsim_header_c * const gsmsim, |
|
749 const u32_t gsmsim_buffer_length, |
|
750 const u32_t eap_header_size, |
|
751 u32_t * const gsmsim_data_offset, |
|
752 u32_t * const gsmsim_data_free, |
|
753 u32_t * const packet_buffer_free, |
|
754 u32_t * const packet_buffer_offset, |
|
755 const eap_gsmsim_client_error_code_e client_error_code); |
|
756 |
|
757 |
|
758 /** |
|
759 * This function adds message authentication code (MAC) attribute payload to GSMSIM message. |
|
760 * This MAC is written later in the create_message_authentication_code() function. |
|
761 * MAC includes the whole EAP message. |
|
762 * @param gsmsim is pointer to EAP header including GSMSIM fields. |
|
763 * @param maximum_buffer_size is the maximum length of sent packet. |
|
764 * @param eap_header_size is length of EAP header. |
|
765 * See also gsmsim_header_c and eap_header_base_c. |
|
766 * @param data_offset is the offset of inserted payloads in GSMSIM EAP packet. |
|
767 * It is the value of GSMSIM sub-type data. |
|
768 * @param data_free is the remaining free GSMSIM data buffer size. |
|
769 * @param buffer_free is the remaining free packet buffer size. |
|
770 * @param buffer_offset is the offset from the begin of the packet buffer |
|
771 * to the end of the last data payload. |
|
772 * @param MAC_data is the start of the message authentication code (MAC) to be written. |
|
773 * @param MAC_data_length is the length of the message authentication code (MAC) to be written. |
|
774 * |
|
775 * See also eap_type_gsmsim_c::update_payload_indexes(). |
|
776 * |
|
777 * Format of the payload is as follows: |
|
778 * @code |
|
779 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
|
780 * | AT_MAC | Length | Reserved | |
|
781 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
|
782 * | MAC | |
|
783 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
|
784 * @endcode |
|
785 */ |
|
786 EAP_FUNC_IMPORT eap_status_e add_mac_payload( |
|
787 gsmsim_header_c * const gsmsim, |
|
788 const u32_t maximum_buffer_size, |
|
789 const u32_t eap_header_size, |
|
790 u32_t * const data_offset, |
|
791 u32_t * const data_free, |
|
792 u32_t * const buffer_free, |
|
793 u32_t * const buffer_offset, |
|
794 u8_t ** const MAC_data, |
|
795 u32_t * const MAC_data_length); |
|
796 |
|
797 /** |
|
798 * This function adds message authentication code (MAC) attribute payload to GSMSIM message. |
|
799 * This MAC is written later in the create_message_authentication_code() function. |
|
800 * @param gsmsim is pointer to EAP header including GSMSIM fields. |
|
801 * @param maximum_buffer_size is the maximum length of sent packet. |
|
802 * @param eap_header_size is length of EAP header. |
|
803 * See also gsmsim_header_c and eap_header_base_c. |
|
804 * @param data_offset is the offset of inserted payloads in GSMSIM EAP packet. |
|
805 * It is the value of GSMSIM sub-type data. |
|
806 * @param data_free is the remaining free GSMSIM data buffer size. |
|
807 * @param buffer_free is the remaining free packet buffer size. |
|
808 * @param buffer_offset is the offset from the begin of the packet buffer |
|
809 * to the end of the last data payload. |
|
810 * @param plaintext_length is the length of the plain text. Padding length is calculated from this. |
|
811 * |
|
812 * See also eap_type_gsmsim_c::update_payload_indexes(). |
|
813 * |
|
814 * Format of the payload is as follows: |
|
815 * @code |
|
816 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
|
817 * | AT_PADDING | Length | Padding set to zero | |
|
818 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
|
819 * | Zero or more padding octets. Padding octet is 0x00. | |
|
820 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
|
821 * @endcode |
|
822 */ |
|
823 EAP_FUNC_IMPORT eap_status_e add_padding_payload( |
|
824 gsmsim_header_c * const gsmsim_packet, |
|
825 const u32_t maximum_buffer_size, |
|
826 const u32_t eap_header_size, |
|
827 u32_t * const data_offset, |
|
828 u32_t * const data_free, |
|
829 u32_t * const buffer_free, |
|
830 u32_t * const buffer_offset, |
|
831 const u32_t plaintext_length); |
|
832 |
|
833 /** |
|
834 * This function verifies the message authentication code (MAC) is correct. |
|
835 * @see add_mac_payload(). |
|
836 */ |
|
837 EAP_FUNC_IMPORT eap_status_e check_message_authentication_code( |
|
838 const eap_variable_data_c * const authentication_key, |
|
839 gsmsim_payloads_c * const p_gsmsim_payloads, ///< This is pointer to all payloads of the received EAP packet. |
|
840 const gsmsim_header_c * const gsmsim_packet, |
|
841 const u32_t gsmsim_packet_length); |
|
842 |
|
843 /** |
|
844 * This function handles the received GSMSIM EAP packet. |
|
845 * |
|
846 * First is checked the valid massage is received in valid state. |
|
847 * See also eap_type_gsmsim_state_c::check_valid_state(). |
|
848 * |
|
849 * Second is parsed the payloads and checked syntax of the received GSMSIM EAP packet. |
|
850 * See also parse_gsmsim_packet(). |
|
851 * |
|
852 * Third is analysed the GSMSIM EAP packet. This includes the payload and values of each payload. |
|
853 * See also analyse_gsmsim_packet(). |
|
854 */ |
|
855 EAP_FUNC_IMPORT eap_status_e handle_gsmsim_packet( |
|
856 const eap_am_network_id_c * const receive_network_id, ///< This is the network identity of the received EAP packet. |
|
857 gsmsim_header_c * const gsmsim, ///< This is pointer to EAP header including GSMSIM fields. |
|
858 const u32_t gsmsim_length, ///< This is length of received GSMSIM EAP packet. |
|
859 gsmsim_payloads_c * const p_gsmsim_payloads ///< This is pointer to all payloads of the received EAP packet. |
|
860 ); |
|
861 |
|
862 /** |
|
863 * This function analyses the received GSMSIM EAP packet. |
|
864 * Each sub-type is handled in separate function. |
|
865 * @see Client messages are handled in handle_start_request_message() and handle_challenge_request_message(). |
|
866 * @see Server messages are handled in handle_start_response_message() and handle_challenge_response_message(). |
|
867 */ |
|
868 EAP_FUNC_IMPORT eap_status_e analyse_gsmsim_packet( |
|
869 const eap_am_network_id_c * const receive_network_id, ///< This is the network identity of the received EAP packet. |
|
870 gsmsim_header_c * const received_gsmsim, ///< This is pointer to EAP header including GSMSIM fields. |
|
871 const u32_t gsmsim_packet_length, ///< This is length of received GSMSIM EAP packet. |
|
872 gsmsim_payloads_c * const p_gsmsim_payloads ///< This is pointer to all payloads of the received EAP packet. |
|
873 ); |
|
874 |
|
875 /** |
|
876 * This function parses the payloads starting from specified payload (p_payload). |
|
877 * Function parses all payloads from the buffer. |
|
878 * Payloads are stored to p_gsmsim_payloads. |
|
879 * @return If the length of the buffer and sum of the length of all payloads does not match |
|
880 * function returns eap_status_header_corrupted. |
|
881 * Also error is returned when illegal payload attribute is recognised. |
|
882 */ |
|
883 EAP_FUNC_IMPORT eap_status_e parse_gsmsim_payload( |
|
884 const gsmsim_payload_AT_header_c * const p_payload, ///< This is the start of the buffer and the first parsed payload. |
|
885 u32_t * const buffer_length, ///< This is the length of the buffer. This must match with the length of all payloads. |
|
886 gsmsim_payloads_c * const p_gsmsim_payloads, ///< This is pointer to all payloads of the received EAP packet. |
|
887 const gsmsim_subtype_e subtype |
|
888 ); |
|
889 |
|
890 /** |
|
891 * This function checks the version list payload of the GSMSIM EAP packet is correct. |
|
892 */ |
|
893 EAP_FUNC_IMPORT eap_status_e check_version_list( |
|
894 const gsmsim_payload_AT_header_c * const payload, |
|
895 const u16_t version_list_length, |
|
896 u8_t * version_list, |
|
897 bool * const includes_other_version_than_1); |
|
898 |
|
899 /** |
|
900 * This function parses all payloads of the whole GSMSIM EAP packet. |
|
901 * Payloads are stored to p_gsmsim_payloads. |
|
902 * @see parse_gsmsim_payload(). |
|
903 */ |
|
904 EAP_FUNC_IMPORT eap_status_e parse_gsmsim_packet( |
|
905 gsmsim_header_c * const gsmsim, ///< This is pointer to EAP header including GSMSIM fields. |
|
906 const u32_t gsmsim_packet_length, ///< This is length of received GSMSIM EAP packet. |
|
907 gsmsim_payloads_c * const p_gsmsim_payloads ///< This is pointer to all payloads of the received EAP packet. |
|
908 ); |
|
909 |
|
910 /** |
|
911 * This function parses each payload attributes. |
|
912 * @return If payload attribute is illegal function returns eap_status_header_corrupted. |
|
913 * If payload attribute is unknown function returns eap_status_unsupported_gsmsim_payload. |
|
914 */ |
|
915 EAP_FUNC_IMPORT eap_status_e parse_generic_payload( |
|
916 const gsmsim_payload_AT_type_e current_payload, ///< This is the type of current payload attribute. |
|
917 const gsmsim_payload_AT_header_c * const payload, ///< This is the current parsed payload. |
|
918 gsmsim_payloads_c * const p_gsmsim_payloads, ///< This is pointer to all payloads of the received EAP packet. |
|
919 const gsmsim_subtype_e subtype); |
|
920 |
|
921 |
|
922 #if defined(USE_EAP_TYPE_SERVER_GSMSIM) |
|
923 /** |
|
924 * This function sends the EAP-Request/SIM/Re-authentication message. |
|
925 */ |
|
926 EAP_FUNC_IMPORT eap_status_e send_reauthentication_request_message( |
|
927 const eap_variable_data_c * const username, |
|
928 const bool pseudonym_decode_failed, |
|
929 const u8_t eap_identifier); |
|
930 #endif //#if defined(USE_EAP_TYPE_SERVER_GSMSIM) |
|
931 |
|
932 |
|
933 #if defined(USE_EAP_TYPE_SERVER_GSMSIM) |
|
934 /** |
|
935 * This function sends the EAP-Request/SIM/Start message. |
|
936 */ |
|
937 EAP_FUNC_IMPORT eap_status_e send_start_request_message( |
|
938 const bool pseudonym_decode_failed, ///< This identifies whether the pseudonym decode was failed (true). We must send a IMSI request. |
|
939 const u8_t eap_identifier ///< This is the EAP-Identifier used with this message. |
|
940 ); |
|
941 #endif //#if defined(USE_EAP_TYPE_SERVER_GSMSIM) |
|
942 |
|
943 |
|
944 /** |
|
945 * This function sends the EAP-Response/SIM/Start message. |
|
946 */ |
|
947 EAP_FUNC_IMPORT eap_status_e send_start_response_message( |
|
948 const eap_am_network_id_c * const receive_network_id, ///< This is the network identity of the received EAP packet. NOTE received. |
|
949 const u8_t received_eap_identifier, ///< This is the EAP-identifier of the received EAP-request message. |
|
950 const eap_gsmsim_version version, ///< This is the selected GSMSIM version. |
|
951 const gsmsim_payload_AT_type_e include_identity_to_start_response, ///< This is the queried identity type. |
|
952 const eap_variable_data_c * const automatic_realm, ///< This could be zero pointer if this is not used. |
|
953 const u32_t length_of_mnc |
|
954 ); |
|
955 |
|
956 /** |
|
957 * This function sends the EAP-Response/SIM/Notification message. |
|
958 */ |
|
959 EAP_FUNC_IMPORT eap_status_e send_gsmsim_notification_response( |
|
960 const eap_gsmsim_notification_codes_e notification_code, ///< This is the status of the failed triplet query. |
|
961 const bool add_at_counter_attribute |
|
962 ); |
|
963 |
|
964 /** |
|
965 * This function sends the EAP-Response/SIM/Client-Error message. |
|
966 */ |
|
967 EAP_FUNC_IMPORT eap_status_e send_gsmsim_client_error_response(); |
|
968 |
|
969 |
|
970 #if defined(USE_EAP_TYPE_SERVER_GSMSIM) |
|
971 /** |
|
972 * This function sends the EAP-Request/SIM/Challenge message. |
|
973 */ |
|
974 EAP_FUNC_IMPORT eap_status_e send_challenge_request_message( |
|
975 const u8_t eap_identifier ///< This is the EAP-Identifier used with this message. |
|
976 ); |
|
977 #endif //#if defined(USE_EAP_TYPE_SERVER_GSMSIM) |
|
978 |
|
979 |
|
980 /** |
|
981 * This function sends the EAP-Response/SIM/Challenge message. |
|
982 */ |
|
983 EAP_FUNC_IMPORT eap_status_e send_challenge_response_message( |
|
984 eap_variable_data_c * const K_aut); |
|
985 |
|
986 EAP_FUNC_IMPORT eap_status_e send_reauthentication_response_message( |
|
987 const eap_variable_data_c * const orig_XKEY, |
|
988 const eap_variable_data_c * const orig_K_aut, |
|
989 const eap_variable_data_c * const orig_K_encr, |
|
990 const eap_variable_data_c * const reauth_username, |
|
991 const eap_variable_data_c * const reauth_nonce_s, |
|
992 const u16_t reauth_counter, |
|
993 const u8_t eap_identifier, |
|
994 const bool include_at_counter_too_small); |
|
995 |
|
996 |
|
997 #if defined(USE_EAP_TYPE_SERVER_GSMSIM) |
|
998 /** |
|
999 * This function sends the EAP-Request/SIM/Notification message. |
|
1000 * Message includes the localizable notification string. |
|
1001 */ |
|
1002 EAP_FUNC_IMPORT eap_status_e send_gsmsim_notification_request( |
|
1003 const eap_gsmsim_notification_codes_e notification_code, ///< This is the status of the failed triplet query. |
|
1004 const bool add_at_counter_attribute |
|
1005 ); |
|
1006 #endif //#if defined(USE_EAP_TYPE_SERVER_GSMSIM) |
|
1007 |
|
1008 |
|
1009 /** |
|
1010 * This function encrypts the payload. |
|
1011 */ |
|
1012 EAP_FUNC_IMPORT eap_status_e encrypt_DATA_payload( |
|
1013 u8_t * const EAP_data, ///< This is pointer to the begin of the encrypted payload. |
|
1014 const u32_t cbc_aes_data_length, ///< This is the length of the encrypted payload. This must be aligned to AES block length. |
|
1015 const eap_variable_data_c * const IV, |
|
1016 const eap_variable_data_c * const encryption_key |
|
1017 ); |
|
1018 |
|
1019 |
|
1020 /** |
|
1021 * This function decrypts the payload. |
|
1022 * p_gsmsim_payloads->get_ENCR_DATA() points to the decrypted payload. |
|
1023 */ |
|
1024 EAP_FUNC_IMPORT eap_status_e decrypt_DATA_payload( |
|
1025 gsmsim_payloads_c * const p_gsmsim_payloads, ///< This is pointer to all payloads of the received EAP packet. |
|
1026 const eap_variable_data_c * const encryption_key |
|
1027 ); |
|
1028 |
|
1029 /** |
|
1030 * This function handles the received DATA payload attribute. |
|
1031 * The received encrypte payload have been decrypted before thiscall. |
|
1032 * p_gsmsim_payloads->get_ENCR_DATA() includes decrypted DATA payload. |
|
1033 */ |
|
1034 EAP_FUNC_IMPORT eap_status_e handle_DATA_payload( |
|
1035 const gsmsim_subtype_e subtype, |
|
1036 gsmsim_payloads_c * const p_gsmsim_payloads ///< This is pointer to all payloads of the received EAP packet. |
|
1037 ); |
|
1038 |
|
1039 //-------------------------------------------------- |
|
1040 |
|
1041 /** |
|
1042 * This function generate a new NONCE of nonce_size octets length. |
|
1043 */ |
|
1044 EAP_FUNC_IMPORT eap_status_e generate_nonce( |
|
1045 const u32_t nonce_size, |
|
1046 eap_variable_data_c * const nonce); |
|
1047 |
|
1048 /** |
|
1049 * This function returns the domain name. |
|
1050 */ |
|
1051 EAP_FUNC_IMPORT eap_variable_data_c * get_nai_realm(); |
|
1052 |
|
1053 /** |
|
1054 * This is the situation before the update_buffer_indexes() call. |
|
1055 * @code |
|
1056 * |
|
1057 * |<---------buffer_offset-------->|<----------buffer_free----------------->| |
|
1058 * | | | |
|
1059 * | +-----+---------------+--------------------+ | |
|
1060 * | | EAP | data | new payload | | |
|
1061 * | +-----+---------------+--------------------+ | |
|
1062 * | | | |
|
1063 * |<-offset->|<----MTU----------------------------------------------------->|<-trailer->| |
|
1064 * | | |
|
1065 * |<-----------------------maximum_buffer_size----------------------------------------->| |
|
1066 * |
|
1067 * @endcode |
|
1068 * |
|
1069 * This is the situation after the update_buffer_indexes() call. |
|
1070 * @code |
|
1071 * |
|
1072 * |<-----------------buffer_offset--------------------->|<---buffer_free--->| |
|
1073 * | | | |
|
1074 * | +-----+---------------+--------------------+ | |
|
1075 * | | EAP | data | new payload | | |
|
1076 * | +-----+---------------+--------------------+ | |
|
1077 * | | | |
|
1078 * |<-offset->|<----MTU----------------------------------------------------->|<-trailer->| |
|
1079 * | | |
|
1080 * |<-----------------------maximum_buffer_size----------------------------------------->| |
|
1081 * |
|
1082 * @endcode |
|
1083 * |
|
1084 * Note maximum_buffer_size could be larger than (m_gsmsim_header_offset + m_MTU + m_trailer_length). |
|
1085 */ |
|
1086 EAP_FUNC_IMPORT void update_buffer_indexes( |
|
1087 const u32_t maximum_buffer_size, |
|
1088 const u32_t payload_size, |
|
1089 u32_t * const buffer_offset, |
|
1090 u32_t * const buffer_free); |
|
1091 |
|
1092 /** |
|
1093 * This is the situation before the update_payload_indexes() call. |
|
1094 * @code |
|
1095 * |
|
1096 * |<---------buffer_offset-------->|<----------buffer_free----------------->| |
|
1097 * | | | |
|
1098 * | |<-data_offset->|<--------data_free--------------------->| |
|
1099 * | | | | |
|
1100 * | | |<---payload_size--->| | |
|
1101 * | | | | | |
|
1102 * | +-----+---------------+--------------------+ | |
|
1103 * | | EAP | data | new payload | | |
|
1104 * | +-----+---------------+--------------------+ | |
|
1105 * | | | |
|
1106 * |<-offset->|<----MTU----------------------------------------------------->|<-trailer->| |
|
1107 * | | |
|
1108 * |<-----------------------maximum_buffer_size----------------------------------------->| |
|
1109 * |
|
1110 * @endcode |
|
1111 * |
|
1112 * This is the situation after the update_payload_indexes() call. |
|
1113 * @code |
|
1114 * |
|
1115 * |<-----------------buffer_offset--------------------->|<---buffer_free--->| |
|
1116 * | | | |
|
1117 * | |<----------data_offset------------->|<----data_free---->| |
|
1118 * | | | | |
|
1119 * | | |<---payload_size--->| | |
|
1120 * | | | | | |
|
1121 * | +-----+---------------+--------------------+ | |
|
1122 * | | EAP | data | new payload | | |
|
1123 * | +-----+---------------+--------------------+ | |
|
1124 * | | | |
|
1125 * |<-offset->|<----MTU----------------------------------------------------->|<-trailer->| |
|
1126 * | | |
|
1127 * |<-----------------------maximum_buffer_size----------------------------------------->| |
|
1128 * |
|
1129 * @endcode |
|
1130 * |
|
1131 * Note maximum_buffer_size could be larger than (m_gsmsim_header_offset + m_MTU + m_trailer_length). |
|
1132 */ |
|
1133 EAP_FUNC_IMPORT void update_payload_indexes( |
|
1134 const u32_t maximum_buffer_size, |
|
1135 const u32_t eap_header_size, |
|
1136 const u32_t payload_size, |
|
1137 u32_t * const data_offset, |
|
1138 u32_t * const data_free, |
|
1139 u32_t * const buffer_offset, |
|
1140 u32_t * const buffer_free); |
|
1141 |
|
1142 /** |
|
1143 * This function queries the IMSI or saved pseudonym. IMSI is queried always. The optional |
|
1144 * pseudonym is returned if it has been received and it has been stored to GSMSIM AM. |
|
1145 * This function could be synchronous or asynchronous. Parameter must_be_synchronous could be |
|
1146 * used if only synchronous call is accepted. |
|
1147 * |
|
1148 * @return Successful syncronous call returns eap_status_ok. |
|
1149 * The process_SIM_IMSI() function must be called immediately. |
|
1150 * |
|
1151 * @return Successful asynchronous call returns eap_status_ok. |
|
1152 * This means call was indeed synchronous. |
|
1153 * The process_SIM_IMSI() function must be called immediately. |
|
1154 * |
|
1155 * @return Pending asynchronous call returns eap_status_pending_request. |
|
1156 * AM will complete this call later by complete_SIM_IMSI_or_pseudonym_or_reauthentication_id_query() call. |
|
1157 * |
|
1158 * @return Immediately comleted asynchronous call returns eap_status_completed_request. |
|
1159 * AM already called the complete_SIM_IMSI_or_pseudonym_or_reauthentication_id_query(). |
|
1160 * |
|
1161 * @return Other return values are errors. |
|
1162 */ |
|
1163 EAP_FUNC_IMPORT eap_status_e query_SIM_IMSI_or_pseudonym_or_reauthentication_id( |
|
1164 eap_variable_data_c * const IMSI, ///< Pointer to IMSI. Buffer for IMSI is allocated during the call. |
|
1165 eap_variable_data_c * const pseudonym_identity, ///< Pointer to pseudonym. Buffer for pseudonym is allocated during the call. |
|
1166 eap_variable_data_c * const reauthentication_identity, ///< Pointer to reauthentication_identity. Buffer for reauthentication_identity is allocated during the call. |
|
1167 eap_variable_data_c * const automatic_realm, ///< If this is not used, do not add any data to this parameter. |
|
1168 u32_t * const length_of_mnc, |
|
1169 const bool must_be_synchronous, ///< True value indicates only synchronous call is accepted. |
|
1170 const gsmsim_payload_AT_type_e required_identity, ///< This parameter indicated the type of identity required. |
|
1171 const eap_type_gsmsim_complete_e required_completion, ///< This parameter tells the required completion after this call is completed, if this is asyncronous. Use this value with abs_eap_am_type_gsmsim_c::complete_SIM_IMSI_or_pseudonym_or_reauthentication_id_query() function call. |
|
1172 const u8_t received_eap_identifier ///< This is the EAP-identifier of the received EAP-request message. Use this value with abs_eap_am_type_gsmsim_c::complete_SIM_IMSI_or_pseudonym_or_reauthentication_id_query() function call. |
|
1173 ); |
|
1174 |
|
1175 /** |
|
1176 * This function queries KC and SRES. Each of them could include multiple concatenated items. |
|
1177 * This function could be synchronous or asynchronous. |
|
1178 * |
|
1179 * @return Successful call returns eap_status_ok. |
|
1180 * This means call was indeed synchronous. |
|
1181 * The process_SIM_kc_sres() function must be called immediately. |
|
1182 * |
|
1183 * @return Pending asynchronous call returns eap_status_pending_request. |
|
1184 * AM will complete this call later by complete_SIM_kc_sres() call. |
|
1185 * |
|
1186 * @return Immediately comleted asynchronous call returns eap_status_completed_request. |
|
1187 * AM already called the complete_SIM_kc_sres(). |
|
1188 * |
|
1189 * @return Other return values are errors. |
|
1190 */ |
|
1191 EAP_FUNC_IMPORT eap_status_e query_SIM_kc_sres( |
|
1192 const eap_variable_data_c * const n_rands, ///< This includes concatenated n RAND as input. |
|
1193 eap_variable_data_c * const n_kc, ///< This includes concatenated n KC as output. |
|
1194 eap_variable_data_c * const n_sres ///< This includes concatenated n SRES as output. |
|
1195 ); |
|
1196 |
|
1197 |
|
1198 #if defined(USE_EAP_TYPE_SERVER_GSMSIM) |
|
1199 /** |
|
1200 * This function queries the triplets. The triplets are stored to handler->get_triplets(). |
|
1201 * This function could be synchronous or asynchronous. |
|
1202 * |
|
1203 * @return Successful call returns eap_status_ok. |
|
1204 * This means call was indeed synchronous. |
|
1205 * The send_challenge_request_message() function must be called immediately. |
|
1206 * |
|
1207 * @return Pending asynchronous call returns eap_status_pending_request. |
|
1208 * AM will complete this call later by complete_SIM_triplets() call. |
|
1209 * |
|
1210 * @return Immediately comleted asynchronous call returns eap_status_completed_request. |
|
1211 * AM already called the complete_SIM_triplets(). |
|
1212 * |
|
1213 * @return Other return values are errors. |
|
1214 */ |
|
1215 EAP_FUNC_IMPORT eap_status_e query_SIM_triplets( |
|
1216 eap_type_gsmsim_identity_type * const identity_type |
|
1217 ); |
|
1218 #endif //#if defined(USE_EAP_TYPE_SERVER_GSMSIM) |
|
1219 |
|
1220 |
|
1221 /** |
|
1222 * This function creates local copy of MAC_RAND and checks the received one match with local MAC_RAND. |
|
1223 * After succesfull MAC_RAND check function parses the GSMSIM payloads from saved GSMSIM EAP packet. |
|
1224 * This is because of the process_SIM_kc_sres() function could be called asynchronously and |
|
1225 * the received GSMSIM EAP packet is stored to handler->get_saved_EAP_packet(). |
|
1226 * Also encrypted payload (l_gsmsim_payloads.get_ENCR_DATA()) is handled here. |
|
1227 * This is the first place where we have the K_encr (handler->get_K_encr()) available. |
|
1228 * The decrpted DATA payload is handled immediately in handle_DATA_payload() function. |
|
1229 * Then function calculates MAC_SRES and sends EAP-Response/SIM/Challenge. |
|
1230 */ |
|
1231 EAP_FUNC_IMPORT eap_status_e process_SIM_kc_sres( |
|
1232 const eap_variable_data_c * const n_rand, ///< This includes concatenated n RAND. |
|
1233 const eap_variable_data_c * const n_kc, ///< This includes concatenated n KC. |
|
1234 const eap_variable_data_c * const n_sres ///< This includes concatenated n SRES. |
|
1235 ); |
|
1236 |
|
1237 /** |
|
1238 * This function selects whether to use pseudonym or IMSI. |
|
1239 * Function creates NAI and EAP-Response/Identity message. |
|
1240 * Message is sent immediately. |
|
1241 */ |
|
1242 EAP_FUNC_IMPORT eap_status_e process_SIM_IMSI( |
|
1243 const eap_variable_data_c * const IMSI, ///< This is the IMSI. |
|
1244 const eap_variable_data_c * const pseudonym ///< This is the pseudonym. |
|
1245 ); |
|
1246 |
|
1247 |
|
1248 #if defined(USE_EAP_TYPE_SERVER_GSMSIM) |
|
1249 /** |
|
1250 * This function adds RAND attribute payload to GSMSIM message. |
|
1251 * Payload includes one or more RANDs. |
|
1252 * @param gsmsim is pointer to EAP header including GSMSIM fields. |
|
1253 * @param maximum_buffer_size is the maximum length of sent packet. |
|
1254 * @param eap_header_size is length of EAP header. |
|
1255 * See also gsmsim_header_c and eap_header_base_c. |
|
1256 * @param data_offset is the offset of inserted payloads in GSMSIM EAP packet. |
|
1257 * It is the value of GSMSIM sub-type data. |
|
1258 * @param data_free is the remaining free GSMSIM data buffer size. |
|
1259 * @param buffer_free is the remaining free packet buffer size. |
|
1260 * @param buffer_offset is the offset from the begin of the packet buffer |
|
1261 * to the end of the last data payload. |
|
1262 * @param triplets includes all triplets used in this authentication session. |
|
1263 * See also eap_type_sim_triplet_array_c. |
|
1264 * |
|
1265 * See also eap_type_gsmsim_c::update_payload_indexes(). |
|
1266 * |
|
1267 * Format of the payload is as follows: |
|
1268 * @code |
|
1269 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
|
1270 * | AT_RAND | Length | Reserved | |
|
1271 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
|
1272 * | n*RAND ... |
|
1273 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
|
1274 * @endcode |
|
1275 */ |
|
1276 EAP_FUNC_IMPORT eap_status_e add_n_rand_payload( |
|
1277 gsmsim_header_c * const gsmsim, |
|
1278 const u32_t maximum_buffer_size, |
|
1279 const u32_t eap_header_size, |
|
1280 u32_t * const data_offset, |
|
1281 u32_t * const data_free, |
|
1282 u32_t * const buffer_free, |
|
1283 u32_t * const buffer_offset, |
|
1284 eap_type_sim_triplet_array_c * const triplets); |
|
1285 #endif //#if defined(USE_EAP_TYPE_SERVER_GSMSIM) |
|
1286 |
|
1287 |
|
1288 /** |
|
1289 * This function calculates the MAC_SRES. |
|
1290 */ |
|
1291 EAP_FUNC_IMPORT eap_status_e calculate_MAC_SRES( |
|
1292 eap_variable_data_c * const MAC_SRES, ///< This is the calculated MAC_SRES. |
|
1293 const eap_variable_data_c * const n_kc, ///< This includes concatenated n KC. |
|
1294 const eap_variable_data_c * const n_sres ///< This includes concatenated n SRES. |
|
1295 ); |
|
1296 |
|
1297 |
|
1298 #if defined(USE_EAP_TYPE_SERVER_GSMSIM) |
|
1299 /** |
|
1300 * This function reads the identity payload. Identity is stored to handler->get_identity(). |
|
1301 */ |
|
1302 EAP_FUNC_IMPORT eap_status_e parse_identity( |
|
1303 const u8_t * const identity, ///< This is pointer to received EAP-Identity buffer. |
|
1304 const u32_t identity_length ///< This is length of received EAP-Identity buffer. |
|
1305 //const u32_t eap_packet_length ///< This is length of received EAP-Identity buffer. |
|
1306 ); |
|
1307 #endif //#if defined(USE_EAP_TYPE_SERVER_GSMSIM) |
|
1308 |
|
1309 |
|
1310 EAP_FUNC_IMPORT eap_status_e handle_eap_identity_query( |
|
1311 const eap_am_network_id_c * const send_network_id, |
|
1312 eap_variable_data_c * const identity, |
|
1313 const u8_t eap_identifier, |
|
1314 const eap_variable_data_c * const IMSI, |
|
1315 const eap_variable_data_c * const pseudonym, |
|
1316 const eap_variable_data_c * const reauthentication_identity, |
|
1317 const eap_variable_data_c * const automatic_realm, ///< This could be zero pointer if this is not used. |
|
1318 const u32_t length_of_mnc, |
|
1319 const bool must_be_synchronous |
|
1320 ); |
|
1321 |
|
1322 |
|
1323 #if defined(USE_EAP_TYPE_SERVER_GSMSIM) |
|
1324 /** |
|
1325 * This function handles the received EAP-Response/Identity message. |
|
1326 * First function parses the identity. |
|
1327 * Function queries the AM (query_imsi_from_username()) whether the pseudonym |
|
1328 * is known or should it query peer the IMSI. |
|
1329 * Currently the query_imsi_from_username() is synchronous call. |
|
1330 * The send_start_request_message() function will send the EAP-Request/SIM/Start message. |
|
1331 */ |
|
1332 EAP_FUNC_IMPORT eap_status_e handle_identity_response_message( |
|
1333 eap_header_rd_c * const eap_header, ///< This is the received EAP-Identity packet, pointer points to the header. |
|
1334 const u32_t gsmsim_packet_length ///< This is length of received GSMSIM EAP packet. |
|
1335 ); |
|
1336 #endif //#if defined(USE_EAP_TYPE_SERVER_GSMSIM) |
|
1337 |
|
1338 |
|
1339 /** |
|
1340 * This function handles the received EAP-Request/SIM/Start message. |
|
1341 * Function checks the valid payloads and calls send_start_response_message() that sends EAP-Response/SIM/Start message. |
|
1342 */ |
|
1343 EAP_FUNC_IMPORT eap_status_e handle_start_request_message( |
|
1344 const eap_am_network_id_c * const receive_network_id, ///< This is the network identity of the received EAP packet. |
|
1345 gsmsim_header_c * const received_gsmsim, ///< This is pointer to EAP header including GSMSIM fields. |
|
1346 const u32_t gsmsim_packet_length, ///< This is length of received GSMSIM EAP packet. |
|
1347 gsmsim_payloads_c * const p_gsmsim_payloads ///< This is pointer to all payloads of the received EAP packet. |
|
1348 ); |
|
1349 |
|
1350 EAP_FUNC_IMPORT eap_status_e handle_gsmsim_notification_request_message_reauthentication( |
|
1351 const eap_am_network_id_c * const receive_network_id, |
|
1352 gsmsim_header_c * const received_gsmsim, |
|
1353 const u32_t gsmsim_packet_length, |
|
1354 gsmsim_payloads_c * const p_gsmsim_payloads); |
|
1355 |
|
1356 EAP_FUNC_IMPORT eap_status_e handle_gsmsim_notification_request_message_full_authentication( |
|
1357 const eap_am_network_id_c * const receive_network_id, |
|
1358 gsmsim_header_c * const received_gsmsim, |
|
1359 const u32_t gsmsim_packet_length, |
|
1360 gsmsim_payloads_c * const p_gsmsim_payloads); |
|
1361 |
|
1362 /** |
|
1363 * This function handles the received EAP-Request/SIM/Notification message. |
|
1364 * Function checks the valid payloads and calls send_notification_response_message() that sends EAP-Response/SIM/Notification message. |
|
1365 */ |
|
1366 EAP_FUNC_IMPORT eap_status_e handle_gsmsim_notification_request_message( |
|
1367 const eap_am_network_id_c * const receive_network_id, |
|
1368 gsmsim_header_c * const received_gsmsim, |
|
1369 const u32_t gsmsim_packet_length, |
|
1370 gsmsim_payloads_c * const p_gsmsim_payloads); |
|
1371 |
|
1372 /** |
|
1373 * This function handles the received EAP-Request/SIM/Challenge message. |
|
1374 * Function checks the valid payloads. The whole EAP-Request/SIM/Challenge message is |
|
1375 * saved to handler->get_saved_EAP_packet() if there is encrypted payload. |
|
1376 * This is because the MAC could be checked and payload dercypted later |
|
1377 * after n*Kc and n*SRES is get from SIM. |
|
1378 * Function calls query_SIM_kc_sres(). The query_SIM_kc_sres() function |
|
1379 * is completed using complete_SIM_kc_sres() function. The complete_SIM_kc_sres() |
|
1380 * function will call process_SIM_kc_sres(). |
|
1381 */ |
|
1382 EAP_FUNC_IMPORT eap_status_e handle_challenge_request_message( |
|
1383 const eap_am_network_id_c * const receive_network_id, ///< This is the network identity of the received EAP packet. |
|
1384 gsmsim_header_c * const received_gsmsim, ///< This is pointer to EAP header including GSMSIM fields. |
|
1385 const u32_t gsmsim_packet_length, ///< This is length of received GSMSIM EAP packet. |
|
1386 gsmsim_payloads_c * const p_gsmsim_payloads ///< This is pointer to all payloads of the received EAP packet. |
|
1387 ); |
|
1388 |
|
1389 /** |
|
1390 * This function handles the received EAP-Request/SIM/Re-authentication message. |
|
1391 * Function checks the valid payloads. The whole EAP-Request/SIM/Challenge message is |
|
1392 * saved to handler->get_saved_EAP_packet() if there is encrypted payload. |
|
1393 * This is because the MAC could be checked and payload dercypted later |
|
1394 * after n*Kc and n*SRES is get from SIM. |
|
1395 * Function calls query_SIM_kc_sres(). The query_SIM_kc_sres() function |
|
1396 * is completed using complete_SIM_kc_sres() function. The complete_SIM_kc_sres() |
|
1397 * function will call process_SIM_kc_sres(). |
|
1398 */ |
|
1399 EAP_FUNC_IMPORT eap_status_e handle_reauthentication_request_message( |
|
1400 const eap_am_network_id_c * const receive_network_id, |
|
1401 gsmsim_header_c * const received_gsmsim, |
|
1402 const u32_t gsmsim_packet_length, |
|
1403 gsmsim_payloads_c * const p_gsmsim_payloads); |
|
1404 |
|
1405 |
|
1406 #if defined(USE_EAP_TYPE_SERVER_GSMSIM) |
|
1407 EAP_FUNC_IMPORT eap_status_e check_challenge_response_message( |
|
1408 const eap_am_network_id_c * const receive_network_id, |
|
1409 gsmsim_header_c * const received_gsmsim, |
|
1410 const u32_t gsmsim_packet_length, |
|
1411 gsmsim_payloads_c * const p_gsmsim_payloads); |
|
1412 #endif //#if defined(USE_EAP_TYPE_SERVER_GSMSIM) |
|
1413 |
|
1414 |
|
1415 #if defined(USE_EAP_TYPE_SERVER_GSMSIM) |
|
1416 /** |
|
1417 * This function handles the received EAP-Response/SIM/Start message. |
|
1418 * Function checks the valid payloads. If IMSI is included it is copied to handler->get_IMSI(). |
|
1419 * Also the included NONCE_MT is copied to handler->get_NONCE_MT(). |
|
1420 * Function calls the query_SIM_triplets() of AM to get fresh triplets. |
|
1421 * The query_SIM_triplets() function is completed by AM using complete_SIM_triplets() function. |
|
1422 */ |
|
1423 EAP_FUNC_IMPORT eap_status_e handle_start_response_message( |
|
1424 gsmsim_header_c * const received_gsmsim, ///< This is pointer to EAP header including GSMSIM fields. |
|
1425 const u32_t gsmsim_packet_length, ///< This is length of received GSMSIM EAP packet. |
|
1426 gsmsim_payloads_c * const p_gsmsim_payloads ///< This is pointer to all payloads of the received EAP packet. |
|
1427 ); |
|
1428 #endif //#if defined(USE_EAP_TYPE_SERVER_GSMSIM) |
|
1429 |
|
1430 |
|
1431 #if defined(USE_EAP_TYPE_SERVER_GSMSIM) |
|
1432 EAP_FUNC_IMPORT eap_status_e handle_notification_response_message_reauthentication( |
|
1433 const eap_am_network_id_c * const receive_network_id, |
|
1434 gsmsim_header_c * const received_gsmsim, |
|
1435 const u32_t gsmsim_packet_length, |
|
1436 gsmsim_payloads_c * const p_gsmsim_payloads); |
|
1437 #endif //#if defined(USE_EAP_TYPE_SERVER_GSMSIM) |
|
1438 |
|
1439 |
|
1440 #if defined(USE_EAP_TYPE_SERVER_GSMSIM) |
|
1441 EAP_FUNC_IMPORT eap_status_e handle_notification_response_message_full_authentication( |
|
1442 const eap_am_network_id_c * const receive_network_id, |
|
1443 gsmsim_header_c * const received_gsmsim, |
|
1444 const u32_t gsmsim_packet_length, |
|
1445 gsmsim_payloads_c * const p_gsmsim_payloads); |
|
1446 #endif //#if defined(USE_EAP_TYPE_SERVER_GSMSIM) |
|
1447 |
|
1448 |
|
1449 #if defined(USE_EAP_TYPE_SERVER_GSMSIM) |
|
1450 /** |
|
1451 * This function handles the received EAP-Response/SIM/Notification message. |
|
1452 * Function checks the valid payloads. |
|
1453 */ |
|
1454 EAP_FUNC_IMPORT eap_status_e handle_notification_response_message( |
|
1455 const eap_am_network_id_c * const receive_network_id, |
|
1456 gsmsim_header_c * const received_gsmsim, |
|
1457 const u32_t gsmsim_packet_length, |
|
1458 gsmsim_payloads_c * const p_gsmsim_payloads); |
|
1459 #endif //#if defined(USE_EAP_TYPE_SERVER_GSMSIM) |
|
1460 |
|
1461 |
|
1462 #if defined(USE_EAP_TYPE_SERVER_GSMSIM) |
|
1463 /** |
|
1464 * This function handles the received EAP-Response/SIM/Challenge message. |
|
1465 * Function checks the valid payloads. The analyse_MAC_SRES_payload() function is |
|
1466 * called to check MAC_SRES. If it returns eap_status_success the authentication was succesfull |
|
1467 * and this function calls the send_eap_success() to send EAP-Success message. |
|
1468 */ |
|
1469 EAP_FUNC_IMPORT eap_status_e handle_challenge_response_message( |
|
1470 const eap_am_network_id_c * const receive_network_id, ///< This is the network identity of the received EAP packet. |
|
1471 gsmsim_header_c * const received_gsmsim, ///< This is pointer to EAP header including GSMSIM fields. |
|
1472 const u32_t gsmsim_packet_length, ///< This is length of received GSMSIM EAP packet. |
|
1473 gsmsim_payloads_c * const p_gsmsim_payloads ///< This is pointer to all payloads of the received EAP packet. |
|
1474 ); |
|
1475 #endif //#if defined(USE_EAP_TYPE_SERVER_GSMSIM) |
|
1476 |
|
1477 |
|
1478 #if defined(USE_EAP_TYPE_SERVER_GSMSIM) |
|
1479 EAP_FUNC_IMPORT eap_status_e handle_reauthentication_response_message( |
|
1480 const eap_am_network_id_c * const /* receive_network_id */, |
|
1481 gsmsim_header_c * const received_gsmsim, |
|
1482 const u32_t gsmsim_packet_length, |
|
1483 gsmsim_payloads_c * const p_gsmsim_payloads); |
|
1484 #endif //#if defined(USE_EAP_TYPE_SERVER_GSMSIM) |
|
1485 |
|
1486 |
|
1487 #if defined(USE_EAP_TYPE_SERVER_GSMSIM) |
|
1488 EAP_FUNC_IMPORT eap_status_e handle_client_error_response_message( |
|
1489 const eap_am_network_id_c * const /* receive_network_id */, |
|
1490 gsmsim_header_c * const received_gsmsim, |
|
1491 const u32_t gsmsim_packet_length, |
|
1492 gsmsim_payloads_c * const p_gsmsim_payloads); |
|
1493 #endif //#if defined(USE_EAP_TYPE_SERVER_GSMSIM) |
|
1494 |
|
1495 |
|
1496 /** |
|
1497 * This function sends and traces all messages. |
|
1498 */ |
|
1499 EAP_FUNC_IMPORT eap_status_e packet_send( |
|
1500 const eap_am_network_id_c * const network_id, |
|
1501 eap_buf_chain_wr_c * const sent_packet, |
|
1502 const u32_t header_offset, |
|
1503 const u32_t data_length, |
|
1504 const u32_t buffer_length); |
|
1505 |
|
1506 |
|
1507 #if defined(USE_EAP_TYPE_SERVER_GSMSIM) |
|
1508 /** |
|
1509 * This function chechs NAI. |
|
1510 */ |
|
1511 EAP_FUNC_IMPORT eap_status_e check_NAI( |
|
1512 const u8_t * const identity, |
|
1513 const u32_t identity_length, |
|
1514 const u8_t * const at_character); |
|
1515 #endif //#if defined(USE_EAP_TYPE_SERVER_GSMSIM) |
|
1516 |
|
1517 |
|
1518 #if defined(USE_EAP_TRACE) |
|
1519 |
|
1520 /** |
|
1521 * This function traces the EAP packet. |
|
1522 */ |
|
1523 EAP_FUNC_IMPORT void packet_trace( |
|
1524 eap_const_string prefix, |
|
1525 const eap_am_network_id_c * const receive_network_id, |
|
1526 eap_header_wr_c * const received_eap, |
|
1527 const u32_t eap_packet_length); |
|
1528 |
|
1529 #define EAP_GSMSIM_PACKET_TRACE(prefix, receive_network_id, received_eap, eap_packet_length) \ |
|
1530 packet_trace((prefix), (receive_network_id), (received_eap), (eap_packet_length)) |
|
1531 |
|
1532 #else |
|
1533 |
|
1534 #define EAP_GSMSIM_PACKET_TRACE(prefix, receive_network_id, received_eap, eap_packet_length) |
|
1535 |
|
1536 #endif //#if !defined(USE_EAP_TRACE) |
|
1537 |
|
1538 |
|
1539 /** |
|
1540 * This function finishes the successfull authentication. |
|
1541 * Generated keys are offered to lower layer. |
|
1542 * Connection handle is initialised. |
|
1543 */ |
|
1544 EAP_FUNC_IMPORT eap_status_e finish_successful_authentication( |
|
1545 const eap_am_network_id_c * const receive_network_id); |
|
1546 |
|
1547 /** |
|
1548 * This function sends a notification of possible failed authentication |
|
1549 * to lower layer. |
|
1550 */ |
|
1551 EAP_FUNC_IMPORT eap_status_e send_final_notification(); |
|
1552 |
|
1553 EAP_FUNC_IMPORT eap_status_e new_handler( |
|
1554 const eap_am_network_id_c * const receive_network_id, |
|
1555 const bool is_client_when_true); |
|
1556 |
|
1557 #if defined(USE_EAP_TYPE_SERVER_GSMSIM) |
|
1558 EAP_FUNC_IMPORT bool randomly_refuse_eap_identity(); |
|
1559 #endif //#if defined(USE_EAP_TYPE_SERVER_GSMSIM) |
|
1560 |
|
1561 EAP_FUNC_IMPORT eap_status_e check_rands( |
|
1562 const eap_variable_data_c * const n_rands |
|
1563 ); |
|
1564 |
|
1565 /** |
|
1566 * This function processes the GSMSIM packets. |
|
1567 */ |
|
1568 EAP_FUNC_IMPORT eap_status_e gsmsim_packet_process( |
|
1569 const eap_am_network_id_c * const receive_network_id, ///< This is the network identity of the received EAP packet. |
|
1570 gsmsim_header_c * const received_gsmsim, ///< This is pointer to EAP header including GSMSIM fields. |
|
1571 const u32_t gsmsim_packet_length, ///< This is length of received GSMSIM EAP packet. |
|
1572 const bool is_client_when_true ///< Indicates whether this is client (true) or server (false). |
|
1573 ); |
|
1574 |
|
1575 EAP_FUNC_IMPORT eap_status_e cancel_error_message_delay_timer(); |
|
1576 |
|
1577 EAP_FUNC_IMPORT eap_status_e set_error_message_delay_timer(); |
|
1578 |
|
1579 EAP_FUNC_IMPORT eap_status_e handle_error_packet(); |
|
1580 |
|
1581 /** |
|
1582 * This function initializes the error message. |
|
1583 */ |
|
1584 EAP_FUNC_IMPORT eap_status_e initialize_error_message( |
|
1585 const eap_status_e error_status |
|
1586 ); |
|
1587 |
|
1588 |
|
1589 #if defined(USE_EAP_TYPE_SERVER_GSMSIM) |
|
1590 EAP_FUNC_IMPORT eap_status_e handle_start_response_message_completion( |
|
1591 const u8_t next_eap_identifier, |
|
1592 const eap_status_e identity_status, |
|
1593 const eap_type_gsmsim_identity_type identity_type, |
|
1594 const bool identity_payload_was_included); |
|
1595 #endif //#if defined(USE_EAP_TYPE_SERVER_GSMSIM) |
|
1596 |
|
1597 |
|
1598 EAP_FUNC_IMPORT eap_status_e initialize_notification_message(); |
|
1599 |
|
1600 EAP_FUNC_IMPORT eap_status_e cancel_notification_message_delay_timer(); |
|
1601 |
|
1602 EAP_FUNC_IMPORT eap_status_e set_notification_message_delay_timer(); |
|
1603 |
|
1604 EAP_FUNC_IMPORT eap_status_e handle_notification_packet(); |
|
1605 |
|
1606 const bool get_gsmsim_notification_code_F_bit(const eap_gsmsim_notification_codes_e notification_code) |
|
1607 { |
|
1608 return ((notification_code & gsmsim_notification_code_bit_f) != 0); |
|
1609 } |
|
1610 |
|
1611 const bool get_gsmsim_notification_code_P_bit(const eap_gsmsim_notification_codes_e notification_code) |
|
1612 { |
|
1613 return ((notification_code & gsmsim_notification_code_bit_p) != 0); |
|
1614 } |
|
1615 |
|
1616 EAP_FUNC_IMPORT bool random_selection(); |
|
1617 |
|
1618 u32_t get_mnc_length(const u32_t mcc); |
|
1619 |
|
1620 eap_status_e create_uma_realm( |
|
1621 eap_variable_data_c * const automatic_realm, |
|
1622 const eap_variable_data_c * const IMSI, |
|
1623 const u32_t length_of_mnc); |
|
1624 |
|
1625 void set_start_response_includes_identity(gsmsim_payload_AT_type_e type); |
|
1626 |
|
1627 void set_identity_type(eap_type_gsmsim_identity_type type); |
|
1628 |
|
1629 //-------------------------------------------------- |
|
1630 protected: |
|
1631 //-------------------------------------------------- |
|
1632 |
|
1633 //-------------------------------------------------- |
|
1634 public: |
|
1635 //-------------------------------------------------- |
|
1636 |
|
1637 /** |
|
1638 * Destructor cancels all timers and deletes member attributes. |
|
1639 */ |
|
1640 EAP_FUNC_IMPORT virtual ~eap_type_gsmsim_c(); |
|
1641 |
|
1642 /** |
|
1643 * Constructor initializes all member attributes. |
|
1644 */ |
|
1645 EAP_FUNC_IMPORT eap_type_gsmsim_c( |
|
1646 abs_eap_am_tools_c * const tools, ///< This is pointer to the tools AM of current platform. |
|
1647 abs_eap_base_type_c * const partner, ///< This is back pointer to object which created this object. |
|
1648 eap_am_type_gsmsim_c * const am_type_gsmsim, ///< This is pointer to adaptation module of GSMSIM EAP type. |
|
1649 const bool free_am_type_gsmsim, ///< True value means m_am_type_gsmsim is allocated within eap_type_gsmsim_c and m_am_type_gsmsim must be freed in destructor. |
|
1650 const bool is_client_when_true, ///< Indicates whether this is client (true) or server (false). |
|
1651 const eap_am_network_id_c * const receive_network_id); |
|
1652 |
|
1653 EAP_FUNC_IMPORT static eap_const_string get_identity_string(const eap_type_gsmsim_identity_type identity_type); |
|
1654 |
|
1655 /** |
|
1656 * This function returns string of the state. This is for trace purposes. |
|
1657 * NOTE this is static member function. |
|
1658 */ |
|
1659 EAP_FUNC_IMPORT static eap_const_string get_state_string(eap_type_gsmsim_state_variable_e state); |
|
1660 |
|
1661 /** |
|
1662 * This function tells if the object is a client or a server.. |
|
1663 */ |
|
1664 EAP_FUNC_IMPORT bool get_is_client(); |
|
1665 |
|
1666 // This is commented in abs_eap_am_type_gsmsim_c::complete_SIM_IMSI_or_pseudonym_or_reauthentication_id_query(). |
|
1667 EAP_FUNC_IMPORT eap_status_e complete_SIM_IMSI_or_pseudonym_or_reauthentication_id_query( |
|
1668 const eap_variable_data_c * const IMSI, ///< This is the IMSI. |
|
1669 const eap_variable_data_c * const pseudonym, ///< This is the pseudonym. |
|
1670 const eap_variable_data_c * const reauthentication_identity, ///< This is the re-authentication identity. |
|
1671 const eap_variable_data_c * const automatic_realm, ///< This could be zero pointer if this is not used. |
|
1672 const u32_t length_of_mnc, |
|
1673 const eap_type_gsmsim_complete_e required_completion, ///< This parameter tells the required completion |
|
1674 const u8_t received_eap_identifier, ///< This parameter is the EAP-identifier of EAP-request |
|
1675 const eap_status_e completion_status |
|
1676 ); |
|
1677 |
|
1678 |
|
1679 #if defined(USE_EAP_TYPE_SERVER_GSMSIM) |
|
1680 // This is commented in abs_eap_am_type_gsmsim_c::complete_SIM_triplets(). |
|
1681 EAP_FUNC_IMPORT eap_status_e complete_SIM_triplets( |
|
1682 eap_type_sim_triplet_array_c * const triplets, ///< triplets includes all triplets used in this authentication session. |
|
1683 const eap_variable_data_c * const IMSI, ///< IMSI may be queried during query_SIM_triplets() function call. It must be copied to state. |
|
1684 const eap_gsmsim_triplet_status_e triplet_status, ///< This is the status of the failed triplet query. |
|
1685 const eap_type_gsmsim_identity_type type, ///< This is type of the identity. |
|
1686 const eap_status_e completion_status |
|
1687 ); |
|
1688 #endif //#if defined(USE_EAP_TYPE_SERVER_GSMSIM) |
|
1689 |
|
1690 |
|
1691 // This is commented in abs_eap_am_type_gsmsim_c::complete_SIM_kc_sres(). |
|
1692 EAP_FUNC_IMPORT eap_status_e complete_SIM_kc_sres( |
|
1693 const eap_variable_data_c * const n_rand, ///< This includes concatenated n RAND. |
|
1694 const eap_variable_data_c * const n_kc, ///< This includes concatenated n KC. |
|
1695 const eap_variable_data_c * const n_sres, ///< This includes concatenated n SRES. |
|
1696 const eap_status_e completion_status |
|
1697 ); |
|
1698 |
|
1699 |
|
1700 #if defined(USE_EAP_TYPE_SERVER_GSMSIM) |
|
1701 /** Client calls this function. |
|
1702 * This function IMSI and username to GSMSIM EAP type. |
|
1703 */ |
|
1704 EAP_FUNC_IMPORT eap_status_e handle_imsi_from_username( |
|
1705 const u8_t next_eap_identifier, |
|
1706 const eap_am_network_id_c * const network_id, |
|
1707 const eap_variable_data_c * const username, |
|
1708 const eap_variable_data_c * const imsi, ///< The result is stored to imsi parameter. |
|
1709 const eap_type_gsmsim_identity_type identity_type); |
|
1710 #endif //#if defined(USE_EAP_TYPE_SERVER_GSMSIM) |
|
1711 |
|
1712 |
|
1713 #if defined(USE_EAP_TYPE_SERVER_GSMSIM) |
|
1714 // This is commented in abs_eap_am_type_gsmsim_c::complete_imsi_from_username(). |
|
1715 EAP_FUNC_IMPORT eap_status_e complete_imsi_from_username( |
|
1716 const u8_t next_eap_identifier, |
|
1717 const eap_am_network_id_c * const network_id, |
|
1718 const eap_variable_data_c * const username, |
|
1719 const eap_variable_data_c * const imsi, ///< The result is stored to imsi parameter. |
|
1720 const eap_type_gsmsim_identity_type type, |
|
1721 const eap_status_e completion_status, |
|
1722 const eap_type_gsmsim_complete_e completion_action); |
|
1723 #endif //#if defined(USE_EAP_TYPE_SERVER_GSMSIM) |
|
1724 |
|
1725 |
|
1726 /** |
|
1727 * The partner class calls this function when EAP/GSMSIM packet is received. |
|
1728 * see also eap_base_type_c::packet_process(). |
|
1729 */ |
|
1730 EAP_FUNC_IMPORT eap_status_e packet_process( |
|
1731 const eap_am_network_id_c * const receive_network_id, ///< This is the network identity of the received EAP packet. |
|
1732 eap_header_wr_c * const eap, ///< This is pointer to EAP header and data. |
|
1733 const u32_t eap_packet_length ///< This is length of received EAP packet. |
|
1734 ); |
|
1735 |
|
1736 /** |
|
1737 * This function obtains header offset, MTU and trailer length. |
|
1738 * See also abs_eap_base_type_c::get_header_offset(). |
|
1739 */ |
|
1740 EAP_FUNC_IMPORT u32_t get_header_offset( |
|
1741 u32_t * const MTU, |
|
1742 u32_t * const trailer_length |
|
1743 ); |
|
1744 |
|
1745 /** |
|
1746 * This function creates a message authentication code (MAC) |
|
1747 */ |
|
1748 EAP_FUNC_IMPORT eap_status_e create_message_authentication_code( |
|
1749 eap_type_gsmsim_MAC_attributes_c *MAC_attributes, ///< This includes required parameters. |
|
1750 const gsmsim_subtype_e subtype, |
|
1751 const eap_code_value_e code, |
|
1752 const eap_variable_data_c * const authentication_key |
|
1753 ); |
|
1754 |
|
1755 /** |
|
1756 * This function adds addiditional data to MAC calculation. |
|
1757 */ |
|
1758 EAP_FUNC_IMPORT eap_status_e extra_message_authentication_code_bytes( |
|
1759 const gsmsim_subtype_e subtype, |
|
1760 const eap_code_value_e code, |
|
1761 crypto_hmac_c *hmac_sha1); |
|
1762 |
|
1763 // This is commented in abs_eap_base_timer_c::timer_delete_data(). |
|
1764 EAP_FUNC_IMPORT eap_status_e timer_expired( |
|
1765 const u32_t id, void *data |
|
1766 ); |
|
1767 |
|
1768 // This is commented in abs_eap_base_timer_c::timer_delete_data(). |
|
1769 EAP_FUNC_IMPORT eap_status_e timer_delete_data( |
|
1770 const u32_t id, void *data |
|
1771 ); |
|
1772 |
|
1773 // This is commented in eap_base_type_c::set_is_valid(). |
|
1774 EAP_FUNC_IMPORT void set_is_valid(); |
|
1775 |
|
1776 // This is commented in eap_base_type_c::get_is_valid(). |
|
1777 EAP_FUNC_IMPORT bool get_is_valid(); |
|
1778 |
|
1779 // This is commented in eap_base_type_c::configure(). |
|
1780 /** |
|
1781 * EAP-type GSMSIM reads configuration. |
|
1782 */ |
|
1783 EAP_FUNC_IMPORT eap_status_e configure(); |
|
1784 |
|
1785 // This is commented in eap_base_type_c::shutdown(). |
|
1786 /** |
|
1787 * The shutdown() function is called before the destructor of the |
|
1788 * object is executed. During the function call the object |
|
1789 * could shutdown the operations, for example cancel timers. |
|
1790 * Each derived class must define this function. |
|
1791 */ |
|
1792 EAP_FUNC_IMPORT eap_status_e shutdown(); |
|
1793 |
|
1794 /** |
|
1795 * The read_configure() function reads the configuration data identified |
|
1796 * by the field string of field_length bytes length. Adaptation module must direct |
|
1797 * the query to some persistent store. |
|
1798 * @param field is generic configure string idenfying the required configure data. |
|
1799 * @param field_length is length of the field string. |
|
1800 * @param data is pointer to existing eap_variable_data object. |
|
1801 */ |
|
1802 EAP_FUNC_IMPORT virtual eap_status_e read_configure( |
|
1803 const eap_configuration_field_c * const field, |
|
1804 eap_variable_data_c * const data |
|
1805 ); |
|
1806 |
|
1807 /** |
|
1808 * The write_configure() function writes the configuration data identified |
|
1809 * by the field string of field_length bytes length. Adaptation module must direct |
|
1810 * the action to some persistent store. |
|
1811 * @param field is generic configure string idenfying the required configure data. |
|
1812 * @param field_length is length of the field string. |
|
1813 * @param data is pointer to existing eap_variable_data object. |
|
1814 */ |
|
1815 EAP_FUNC_IMPORT virtual eap_status_e write_configure( |
|
1816 const eap_configuration_field_c * const field, |
|
1817 eap_variable_data_c * const data |
|
1818 ); |
|
1819 |
|
1820 // See abs_eap_base_type_c::state_notification(). |
|
1821 EAP_FUNC_IMPORT void state_notification( |
|
1822 const abs_eap_state_notification_c * const state |
|
1823 ); |
|
1824 |
|
1825 // This is commented in eap_base_type_c::query_eap_identity(). |
|
1826 EAP_FUNC_IMPORT eap_status_e query_eap_identity( |
|
1827 const bool must_be_synchronous, |
|
1828 eap_variable_data_c * const identity, |
|
1829 const eap_am_network_id_c * const receive_network_id, |
|
1830 const u8_t eap_identifier); |
|
1831 |
|
1832 // This is commented in eap_base_type_c::query_eap_identity(). |
|
1833 EAP_FUNC_IMPORT eap_status_e set_initial_eap_identifier( |
|
1834 const eap_am_network_id_c * const receive_network_id, |
|
1835 const u8_t initial_identifier); |
|
1836 |
|
1837 // This is commented in eap_base_type_c::eap_acknowledge(). |
|
1838 EAP_FUNC_IMPORT eap_status_e eap_acknowledge( |
|
1839 const eap_am_network_id_c * const receive_network_id); |
|
1840 |
|
1841 /** |
|
1842 * This function must reset the state of object to same as |
|
1843 * state was after the configure() function call. |
|
1844 * If object reset succeeds this function must return eap_status_ok. |
|
1845 * If object reset fails this function must return corresponding error status. |
|
1846 * @return This function returns the status of reset operation. |
|
1847 */ |
|
1848 EAP_FUNC_IMPORT eap_status_e reset(); |
|
1849 |
|
1850 // |
|
1851 EAP_FUNC_IMPORT eap_status_e set_timer( |
|
1852 abs_eap_base_timer_c * const p_initializer, |
|
1853 const u32_t p_id, |
|
1854 void * const p_data, |
|
1855 const u32_t p_time_ms); |
|
1856 |
|
1857 EAP_FUNC_IMPORT eap_status_e cancel_timer( |
|
1858 abs_eap_base_timer_c * const p_initializer, |
|
1859 const u32_t p_id); |
|
1860 |
|
1861 // |
|
1862 EAP_FUNC_IMPORT eap_status_e cancel_all_timers(); |
|
1863 |
|
1864 //-------------------------------------------------- |
|
1865 }; // class eap_type_gsmsim_c |
|
1866 |
|
1867 #endif //#if !defined(_GSMSIM_CORE_H_) |
|
1868 |
|
1869 //-------------------------------------------------- |
|
1870 |
|
1871 |
|
1872 |
|
1873 // End. |