|
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(_EAP_AM_TYPE_GSMSIM_SYMBIAN_H_) |
|
22 #define _EAP_AM_TYPE_GSMSIM_SYMBIAN_H_ |
|
23 |
|
24 // INCLUDES |
|
25 #include <EapType.h> |
|
26 #include <d32dbms.h> |
|
27 #include "eap_tools.h" |
|
28 #include "eap_am_export.h" |
|
29 #include "abs_eap_base_type.h" |
|
30 #include "eap_am_type_gsmsim.h" |
|
31 #include "abs_eap_am_sim_algorithm.h" |
|
32 |
|
33 #if !defined (USE_EAP_GSMSIM_INTERFACE) |
|
34 // These are needed only for test environment ( Plugin tester). |
|
35 // Comment out USE_EAP_GSMSIM_INTERFACE in eapol.mmh for building for the test environment. |
|
36 #include "eap_am_sim_algorithm_nokia_test.h" |
|
37 #endif // #if !defined (USE_EAP_GSMSIM_INTERFACE) |
|
38 |
|
39 #include "eap_am_network_id.h" |
|
40 |
|
41 // FORWARD DECLARATIONS |
|
42 |
|
43 class CEapSimIsaInterface; |
|
44 class eap_am_tools_symbian_c; |
|
45 |
|
46 // CLASS DECLARATION |
|
47 |
|
48 /** |
|
49 * Class that implements the operating system dependent portion of EAP SIM protocol. |
|
50 * For Symbian OS. |
|
51 */ |
|
52 class EAP_EXPORT eap_am_type_gsmsim_symbian_c |
|
53 : public CBase, public eap_am_type_gsmsim_c |
|
54 { |
|
55 public: |
|
56 //-------------------------------------------------- |
|
57 |
|
58 static eap_am_type_gsmsim_symbian_c* NewL( |
|
59 abs_eap_am_tools_c * const aTools, |
|
60 abs_eap_base_type_c * const aPartner, |
|
61 const TIndexType aIndexType, |
|
62 const TInt aIndex, |
|
63 const eap_type_value_e aTunnelingType, |
|
64 const bool aIsClient, |
|
65 const eap_am_network_id_c * const receive_network_id); |
|
66 // |
|
67 EAP_FUNC_IMPORT virtual ~eap_am_type_gsmsim_symbian_c(); |
|
68 |
|
69 // |
|
70 EAP_FUNC_IMPORT eap_status_e configure(); |
|
71 |
|
72 // |
|
73 EAP_FUNC_IMPORT eap_status_e reset(); |
|
74 |
|
75 // |
|
76 EAP_FUNC_IMPORT eap_status_e shutdown(); |
|
77 |
|
78 #if defined(__WINS__) |
|
79 // |
|
80 EAP_FUNC_IMPORT eap_status_e query_SIM_imsi( |
|
81 u8_t * const imsi, const u32_t max_length, u32_t * const imsi_length); |
|
82 |
|
83 #endif //#if defined(__WINS__) |
|
84 |
|
85 // |
|
86 EAP_FUNC_IMPORT eap_status_e store_pseudonym_id( |
|
87 const eap_am_network_id_c * const network_id, |
|
88 const eap_variable_data_c * const pseudonym); |
|
89 |
|
90 // |
|
91 EAP_FUNC_IMPORT eap_status_e store_reauthentication_id( |
|
92 const eap_am_network_id_c * const network_id, |
|
93 const eap_variable_data_c * const reauthentication_identity); |
|
94 |
|
95 // |
|
96 EAP_FUNC_IMPORT eap_status_e query_SIM_IMSI_or_pseudonym_or_reauthentication_id( |
|
97 const bool must_be_synchronous, |
|
98 eap_variable_data_c * const IMSI, |
|
99 eap_variable_data_c * const pseudonym_identity, |
|
100 eap_variable_data_c * const reauthentication_identity, |
|
101 eap_variable_data_c * const automatic_realm, ///< If this is not used, do not add any data to this parameter. |
|
102 u32_t * const length_of_mnc, |
|
103 const gsmsim_payload_AT_type_e required_identity, |
|
104 const eap_type_gsmsim_complete_e required_completion, |
|
105 const u8_t received_eap_identifier |
|
106 ); |
|
107 |
|
108 // |
|
109 EAP_FUNC_IMPORT eap_status_e cancel_SIM_IMSI_or_pseudonym_or_reauthentication_id_query(); |
|
110 |
|
111 // |
|
112 EAP_FUNC_IMPORT eap_status_e query_SIM_kc_and_sres( |
|
113 const u8_t * const rand, |
|
114 u8_t * const kc, |
|
115 u8_t * const sres); |
|
116 |
|
117 // |
|
118 EAP_FUNC_IMPORT eap_status_e handle_gsmsim_notification(eap_gsmsim_notification_codes_e gsmsim_notification_code); |
|
119 |
|
120 |
|
121 #if defined(USE_EAP_TYPE_SERVER_GSMSIM) |
|
122 // |
|
123 EAP_FUNC_IMPORT eap_status_e query_SIM_triplets( |
|
124 const bool must_be_synchronous, |
|
125 const eap_variable_data_c * const username, |
|
126 eap_variable_data_c * const imsi, |
|
127 eap_type_sim_triplet_array_c * const triplets, |
|
128 eap_type_gsmsim_identity_type * const type); |
|
129 #endif //#if defined(USE_EAP_TYPE_SERVER_GSMSIM) |
|
130 |
|
131 |
|
132 #if defined(USE_EAP_TYPE_SERVER_GSMSIM) |
|
133 // |
|
134 EAP_FUNC_IMPORT eap_status_e cancel_SIM_triplets_query(); |
|
135 #endif //#if defined(USE_EAP_TYPE_SERVER_GSMSIM) |
|
136 |
|
137 // |
|
138 EAP_FUNC_IMPORT eap_status_e query_SIM_kc_sres( |
|
139 const bool must_be_synchronous, |
|
140 //const eap_variable_data_c * const imsi, |
|
141 const eap_variable_data_c * const n_rands, |
|
142 eap_variable_data_c * const n_kc, |
|
143 eap_variable_data_c * const n_sres); |
|
144 |
|
145 // |
|
146 EAP_FUNC_IMPORT eap_status_e cancel_SIM_kc_sres_query(); |
|
147 |
|
148 // |
|
149 EAP_FUNC_IMPORT eap_status_e generate_encryption_IV( |
|
150 eap_variable_data_c * const encryption_IV, |
|
151 const u32_t IV_length); |
|
152 |
|
153 // |
|
154 EAP_FUNC_IMPORT eap_status_e generate_pseudonym_id( |
|
155 const eap_am_network_id_c * const network_id, |
|
156 const eap_variable_data_c * const imsi, |
|
157 eap_variable_data_c * const pseudonym, |
|
158 const u32_t maximum_pseudonym_length); |
|
159 |
|
160 // |
|
161 EAP_FUNC_IMPORT eap_status_e generate_reauthentication_id( |
|
162 const eap_am_network_id_c * const network_id, |
|
163 const eap_variable_data_c * const imsi, |
|
164 eap_variable_data_c * const reauthentication_identity, |
|
165 const u32_t maximum_reauthentication_identity_length); |
|
166 |
|
167 // |
|
168 EAP_FUNC_IMPORT eap_status_e store_reauth_parameters( |
|
169 const eap_variable_data_c * const XKEY, |
|
170 const eap_variable_data_c * const K_aut, |
|
171 const eap_variable_data_c * const K_encr, |
|
172 const u32_t reauth_counter); |
|
173 |
|
174 // |
|
175 EAP_FUNC_IMPORT eap_status_e authentication_finished( |
|
176 const bool true_when_successfull, |
|
177 const eap_gsmsim_authentication_type_e authentication_type, |
|
178 const eap_type_gsmsim_identity_type identity_type); |
|
179 |
|
180 // |
|
181 EAP_FUNC_IMPORT eap_status_e query_reauth_parameters( |
|
182 eap_variable_data_c * const XKEY, |
|
183 eap_variable_data_c * const K_aut, |
|
184 eap_variable_data_c * const K_encr, |
|
185 u32_t * const reauth_counter); |
|
186 |
|
187 // |
|
188 EAP_FUNC_IMPORT eap_status_e increase_reauth_counter(); |
|
189 |
|
190 |
|
191 #if defined(USE_EAP_TYPE_SERVER_GSMSIM) |
|
192 // |
|
193 EAP_FUNC_IMPORT eap_status_e query_imsi_from_username( |
|
194 const bool must_be_synchronous, |
|
195 const u8_t next_eap_identifier, |
|
196 const eap_am_network_id_c * const network_id, |
|
197 const eap_variable_data_c * const username, |
|
198 eap_variable_data_c * const imsi, |
|
199 eap_type_gsmsim_identity_type * const type, |
|
200 const eap_type_gsmsim_complete_e completion_action); |
|
201 #endif //#if defined(USE_EAP_TYPE_SERVER_GSMSIM) |
|
202 |
|
203 |
|
204 // |
|
205 EAP_FUNC_IMPORT eap_status_e cancel_imsi_from_username_query(); |
|
206 |
|
207 // |
|
208 EAP_FUNC_IMPORT eap_status_e check_is_rand_unused(const eap_variable_data_c * const n_rands); |
|
209 |
|
210 EAP_FUNC_IMPORT eap_status_e set_rand_is_used(const eap_variable_data_c * const n_rands); |
|
211 |
|
212 EAP_FUNC_IMPORT void set_is_valid(); |
|
213 |
|
214 EAP_FUNC_IMPORT bool get_is_valid(); |
|
215 |
|
216 // |
|
217 EAP_FUNC_IMPORT eap_status_e type_configure_read( |
|
218 const eap_configuration_field_c * const field, |
|
219 eap_variable_data_c * const data); |
|
220 |
|
221 // |
|
222 EAP_FUNC_IMPORT eap_status_e type_configure_write( |
|
223 const eap_configuration_field_c * const field, |
|
224 eap_variable_data_c * const data); |
|
225 |
|
226 eap_status_e complete_SIM_imsi_L( |
|
227 const eap_variable_data_c * const IMSI, |
|
228 const eap_status_e completion_status); |
|
229 |
|
230 eap_status_e complete_SIM_kc_and_sres_L( |
|
231 TDesC8& aKc, |
|
232 TDesC8& aSRES, |
|
233 const eap_status_e completion_status); |
|
234 |
|
235 /** |
|
236 * Returns true if the full authenticated session is valid. |
|
237 * It finds the difference between current time and the |
|
238 * last full authentication time. If the difference is less than the |
|
239 * Maximum Session Validity Time, then session is valid, returns true. |
|
240 * Otherwise returns false. |
|
241 * Full authentication should be done if the session is not valid. |
|
242 */ |
|
243 bool is_session_valid(); |
|
244 |
|
245 |
|
246 //-------------------------------------------------- |
|
247 protected: |
|
248 //-------------------------------------------------- |
|
249 |
|
250 eap_am_type_gsmsim_symbian_c( |
|
251 abs_eap_am_tools_c * const tools, |
|
252 abs_eap_base_type_c * const partner, |
|
253 const TIndexType aIndexType, |
|
254 const TInt aIndex, |
|
255 const eap_type_value_e aTunnelingType, |
|
256 const bool aIsClient, |
|
257 const eap_am_network_id_c * const receive_network_id); |
|
258 |
|
259 void ConstructL(); |
|
260 |
|
261 //-------------------------------------------------- |
|
262 |
|
263 private: |
|
264 void type_configure_readL( |
|
265 eap_config_string field, |
|
266 const u32_t field_length, |
|
267 eap_variable_data_c * const data); |
|
268 |
|
269 void store_reauth_parametersL( |
|
270 const eap_variable_data_c * const XKEY, |
|
271 const eap_variable_data_c * const K_aut, |
|
272 const eap_variable_data_c * const K_encr, |
|
273 const u32_t reauth_counter); |
|
274 |
|
275 void query_reauth_parametersL( |
|
276 eap_variable_data_c * const reauth_XKEY, |
|
277 eap_variable_data_c * const reauth_K_aut, |
|
278 eap_variable_data_c * const reauth_K_encr, |
|
279 u32_t * const reauth_counter); |
|
280 |
|
281 void increase_reauth_counterL(); |
|
282 |
|
283 void store_pseudonym_idL( |
|
284 const eap_am_network_id_c * const /*network_id*/, |
|
285 const eap_variable_data_c * const pseudonym); |
|
286 |
|
287 void store_reauthentication_idL( |
|
288 const eap_am_network_id_c * const /*network_id*/, |
|
289 const eap_variable_data_c * const /* reauthentication_id */); |
|
290 |
|
291 void query_SIM_IMSI_or_pseudonym_or_reauthentication_idL( |
|
292 const bool must_be_synchronous, |
|
293 eap_variable_data_c * const IMSI, |
|
294 eap_variable_data_c * const pseudonym_identity, |
|
295 eap_variable_data_c * const reauthentication_identity, |
|
296 eap_variable_data_c * const automatic_realm, ///< If this is not used, do not add any data to this parameter. |
|
297 u32_t * const length_of_mnc, |
|
298 const gsmsim_payload_AT_type_e required_identity, |
|
299 const eap_type_gsmsim_complete_e required_completion, |
|
300 const u8_t received_eap_identifier); |
|
301 |
|
302 eap_status_e generate_identity( |
|
303 const eap_am_network_id_c * const /* network_id */, |
|
304 const eap_variable_data_c * const imsi, |
|
305 eap_variable_data_c * const identity, |
|
306 const u32_t maximum_identity_length); |
|
307 |
|
308 eap_status_e store_imsi(const eap_variable_data_c * const imsi); |
|
309 |
|
310 void store_imsiL(const eap_variable_data_c * const imsi); |
|
311 |
|
312 void send_error_notification(const eap_status_e error); |
|
313 |
|
314 |
|
315 #if defined(USE_EAP_SIM_RESET_RAND_DATABASES) |
|
316 |
|
317 eap_status_e reset_rand_check(); |
|
318 |
|
319 #endif //#if defined(USE_EAP_SIM_RESET_RAND_DATABASES) |
|
320 |
|
321 /** |
|
322 * Returns true if the full authenticated session is valid. |
|
323 * It finds the difference between current time and the |
|
324 * last full authentication time. If the difference is less than the |
|
325 * Maximum Session Validity Time, then session is valid, returns true. |
|
326 * Otherwise returns false. |
|
327 * Full authentication should be done if the session is not valid. |
|
328 */ |
|
329 bool is_session_validL(); |
|
330 |
|
331 /** |
|
332 * Stores current universal time as the the full authentication time |
|
333 * in the database. Returns KErrNone if storing succeeds. |
|
334 */ |
|
335 void store_authentication_timeL(); |
|
336 |
|
337 |
|
338 private: |
|
339 //-------------------------------------------------- |
|
340 RDbs m_session; |
|
341 |
|
342 RDbNamedDatabase m_database; |
|
343 |
|
344 eap_am_tools_symbian_c * const m_am_tools; |
|
345 |
|
346 abs_eap_base_type_c * const m_partner; |
|
347 |
|
348 eap_variable_data_c m_triplet_file; |
|
349 |
|
350 eap_variable_data_c m_nai_realm; |
|
351 |
|
352 TIndexType m_index_type; |
|
353 |
|
354 TInt m_index; |
|
355 |
|
356 eap_type_value_e m_tunneling_type; |
|
357 |
|
358 bool m_is_valid; |
|
359 |
|
360 bool m_is_client; |
|
361 |
|
362 CEapSimIsaInterface* m_isa_if; |
|
363 |
|
364 eap_variable_data_c m_stored_reauth_id; |
|
365 |
|
366 eap_variable_data_c m_stored_pseudonym; |
|
367 |
|
368 eap_variable_data_c m_previous_imsi; |
|
369 |
|
370 eap_type_gsmsim_complete_e m_stored_required_completion; |
|
371 |
|
372 u8_t m_stored_received_eap_identifier; |
|
373 |
|
374 bool m_shutdown_was_called; |
|
375 |
|
376 #if !defined (USE_EAP_GSMSIM_INTERFACE) |
|
377 eap_am_sim_algorithm_nokia_test_c m_sim_algorithm; |
|
378 #endif //#if !defined (USE_EAP_GSMSIM_INTERFACE) |
|
379 |
|
380 sim_algorithm_e m_simulator_sim_algorithm; |
|
381 |
|
382 eap_variable_data_c m_simulator_sim_ki; |
|
383 |
|
384 eap_variable_data_c m_copy_of_n_rands; |
|
385 |
|
386 eap_variable_data_c m_n_kc; |
|
387 |
|
388 eap_variable_data_c m_n_sres; |
|
389 |
|
390 eap_variable_data_c m_uma_automatic_realm_prefix; |
|
391 |
|
392 eap_am_network_id_c m_receive_network_id; |
|
393 |
|
394 TInt m_rands_handled; |
|
395 |
|
396 /// This flag tells whether the client should check uniqueness of RANDs (true) or not (false). |
|
397 bool m_do_rand_uniqueness_check; |
|
398 |
|
399 // This holds the max session time read from the configuration file. |
|
400 TInt64 m_max_session_time; |
|
401 |
|
402 // This is the vendor-type for tunneling EAP type. |
|
403 // Valid for both expanded and non-expanded EAP types. |
|
404 // This is used since m_tunneling_type can not be used in the same way |
|
405 // in expanded and non-expanded cases. |
|
406 // Unlike EAP type, Tunneling type is still non-expanded |
|
407 // for both cases especially for using in the EAP databases. |
|
408 u32_t m_tunneling_vendor_type; |
|
409 |
|
410 //-------------------------------------------------- |
|
411 }; // class eap_am_type_gsmsim_symbian_c |
|
412 |
|
413 |
|
414 #endif //#if !defined(_EAP_AM_TYPE_GSMSIM_SYMBIAN_H_) |
|
415 |
|
416 //-------------------------------------------------- |
|
417 |
|
418 |
|
419 |
|
420 // End of file |