|
1 /* |
|
2 * Copyright (c) 2001-2006 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the License "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: EAP and WLAN authentication protocols. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // This is enumeration of EAPOL source code. |
|
20 #if defined(USE_EAP_MINIMUM_RELEASE_TRACES) |
|
21 #undef EAP_FILE_NUMBER_ENUM |
|
22 #define EAP_FILE_NUMBER_ENUM 388 |
|
23 #undef EAP_FILE_NUMBER_DATE |
|
24 #define EAP_FILE_NUMBER_DATE 1127594498 |
|
25 #endif //#if defined(USE_EAP_MINIMUM_RELEASE_TRACES) |
|
26 |
|
27 |
|
28 #include "eap_am_memory.h" |
|
29 #include "eap_tools.h" |
|
30 #include "eap_am_type_tls_peap_symbian.h" |
|
31 #include "abs_eap_am_crypto.h" |
|
32 #include "abs_eap_am_mutex.h" |
|
33 #include "eap_crypto_api.h" |
|
34 #include "abs_eap_base_type.h" |
|
35 #include "eap_type_tls_peap_types.h" |
|
36 #include "eap_am_tools_symbian.h" |
|
37 #include "abs_tls_am_services.h" |
|
38 #include "eap_base_type.h" |
|
39 #include "eap_array_algorithms.h" |
|
40 |
|
41 #include "EapTlsPeapUtils.h" |
|
42 #include "EapTlsPeapDbDefaults.h" |
|
43 #include "EapTlsPeapDbParameterNames.h" |
|
44 #include "EapTlsPeapCertInterface.h" |
|
45 |
|
46 #include <x509cert.h> |
|
47 #include <x509keys.h> |
|
48 #include "eap_am_dh_primes.h" |
|
49 #include <asn1dec.h> |
|
50 #include <asn1enc.h> |
|
51 #include "EapTlsPeapTimerValues.h" |
|
52 #include "eap_state_notification.h" |
|
53 #include "eap_am_trace_symbian.h" |
|
54 #include "eap_automatic_variable.h" |
|
55 |
|
56 #if defined(USE_FAST_EAP_TYPE) |
|
57 #include "abs_tls_am_application_eap_fast.h" |
|
58 #include "eap_fast_strings.h" |
|
59 #include "eap_fast_tlv_payloads.h" |
|
60 //#include "eap_am_async_wait_symbian.h" |
|
61 #include "EapFastActive.h" |
|
62 #include "eap_tlv_header.h" |
|
63 #include "eap_tlv_message_data.h" |
|
64 #endif |
|
65 |
|
66 #include "eap_ttls_pap_active.h" |
|
67 |
|
68 #ifdef USE_PAC_STORE |
|
69 #include "pac_store_db_symbian.h" |
|
70 #include <f32file.h> |
|
71 #endif |
|
72 |
|
73 #ifdef USE_EAP_EXPANDED_TYPES |
|
74 #include "eap_header_string.h" |
|
75 #endif //#ifdef USE_EAP_EXPANDED_TYPES |
|
76 |
|
77 #if defined(USE_EAP_CONFIGURATION_TO_SKIP_USER_INTERACTIONS) |
|
78 #include "eap_config.h" |
|
79 #include "eap_file_config.h" |
|
80 #include "eap_am_file_input_symbian.h" |
|
81 #endif |
|
82 |
|
83 const TUint KMaxSqlQueryLength = 512; |
|
84 const TUint KMaxDBFieldNameLength = 255; |
|
85 const TUint KDSASignatureLength = 40; |
|
86 const TInt KDefaultColumnInView_One = 1; // For DB view. |
|
87 const TInt KMicroSecsInASecond = 1000000; // 1000000 micro seconds is 1 second. |
|
88 |
|
89 /** |
|
90 * Length of the MAC address |
|
91 */ |
|
92 #ifdef USE_FAST_EAP_TYPE |
|
93 const TUint8 KMacAddressLength = 6; |
|
94 #endif |
|
95 //-------------------------------------------------- |
|
96 |
|
97 eap_am_type_tls_peap_symbian_c::eap_am_type_tls_peap_symbian_c( |
|
98 abs_eap_am_tools_c * const aTools, |
|
99 abs_eap_base_type_c * const aPartner, |
|
100 const TIndexType aIndexType, |
|
101 const TInt aIndex, |
|
102 const eap_type_value_e aTunnelingType, |
|
103 const eap_type_value_e aEapType, |
|
104 const bool aIsClient, |
|
105 const eap_am_network_id_c * const receive_network_id) |
|
106 : CActive(CActive::EPriorityStandard) |
|
107 , m_index_type(aIndexType) |
|
108 , m_index(aIndex) |
|
109 , m_tunneling_type(aTunnelingType) |
|
110 , m_partner(aPartner) |
|
111 , m_am_tools(static_cast<eap_am_tools_symbian_c*> (aTools)) |
|
112 , m_tls_am_partner(0) |
|
113 #if defined(USE_FAST_EAP_TYPE) |
|
114 , m_tls_application(0) |
|
115 //, iWaitNoteCancelled( EFalse ) |
|
116 , iEapFastActiveWaitNote( NULL ) |
|
117 , iEapFastActiveNotes( NULL ) |
|
118 #endif //#if defined(USE_FAST_EAP_TYPE) |
|
119 , m_is_valid(false) |
|
120 , m_is_client(aIsClient) |
|
121 , m_current_eap_type(aEapType) |
|
122 , m_max_count_of_session_resumes(0ul) |
|
123 , m_cipher_suite(tls_cipher_suites_TLS_DHE_DSS_WITH_3DES_EDE_CBC_SHA) |
|
124 , m_ca_certificate(0) |
|
125 , m_own_certificate(0) |
|
126 , m_peer_certificate(0) |
|
127 , m_cert_if(0) |
|
128 , m_receive_network_id(aTools) |
|
129 , m_eap_identifier(0u) |
|
130 , m_subject_key_id(0) |
|
131 , m_allowed_user_certs(1) |
|
132 , m_allowed_server_certs(1) |
|
133 , m_peer_public_key(aTools) |
|
134 , m_param_p(aTools) |
|
135 , m_param_q(aTools) |
|
136 , m_param_g(aTools) |
|
137 , m_shutdown_was_called(false) |
|
138 , m_identity_info(0) |
|
139 , m_tunneled_type(eap_type_none) |
|
140 , m_verify_certificate_realm(true) |
|
141 , m_allow_subdomain_matching(false) |
|
142 , m_latest_alert_description(tls_alert_description_none) |
|
143 , m_use_manual_username(false) |
|
144 , m_manual_username(aTools) |
|
145 , m_use_manual_realm(false) |
|
146 , m_manual_realm(aTools) |
|
147 , m_tls_peap_server_authenticates_client_policy_flag(true) |
|
148 , m_configured(false) |
|
149 , m_max_session_time(0) |
|
150 #if defined(USE_EAP_TLS_SESSION_TICKET) |
|
151 , m_use_session_ticket(false) |
|
152 #endif //#if defined(USE_EAP_TLS_SESSION_TICKET) |
|
153 |
|
154 #if defined(USE_FAST_EAP_TYPE) |
|
155 , m_received_tunnel_pac_in_session_ticket(0) |
|
156 , m_received_user_authorization_pac_in_session_ticket(0) |
|
157 , m_saved_pac_type(eap_fast_pac_type_none) |
|
158 , m_completion_operation(eap_fast_completion_operation_none) |
|
159 //, m_new_pac_tlv(aTools) |
|
160 , m_verification_status(eap_status_process_general_error) |
|
161 , m_pac_type(eap_fast_pac_type_none) |
|
162 , m_PAC_store_password(aTools) |
|
163 //, m_PAC_store_device_seed(aTools) |
|
164 , m_imported_PAC_data_password(aTools) |
|
165 , m_PAC_store_path(aTools) |
|
166 , m_EAP_FAST_IAP_reference(aTools) |
|
167 , m_EAP_FAST_Group_reference(aTools) |
|
168 , m_EAP_FAST_import_path(aTools) |
|
169 , m_eap_fast_completion_status(eap_status_process_general_error) |
|
170 , m_eap_fast_pac_store_pending_operation(eap_fast_pac_store_pending_operation_none) |
|
171 , m_references_and_data_blocks(aTools) |
|
172 , m_new_references_and_data_blocks(aTools) |
|
173 , m_ready_references_and_data_blocks(aTools) |
|
174 , m_serv_unauth_prov_mode(false) |
|
175 , m_serv_auth_prov_mode(false) |
|
176 , m_is_notifier_connected(false) |
|
177 , m_notifier_data_to_user(NULL) |
|
178 , m_notifier_data_pckg_to_user(NULL) |
|
179 , m_notifier_data_from_user(NULL) |
|
180 , m_notifier_data_pckg_from_user(NULL) |
|
181 , m_completed_with_zero(false) |
|
182 , m_verificationStatus(false) |
|
183 , m_data_reference(m_am_tools) |
|
184 , m_notifier_complete(false) |
|
185 , m_userResponse(m_am_tools) |
|
186 , m_both_completed(0) |
|
187 , m_both_asked(0) |
|
188 #endif //#if defined(USE_FAST_EAP_TYPE) |
|
189 |
|
190 #ifdef USE_PAC_STORE |
|
191 ,iPacStoreDb(NULL) |
|
192 #endif |
|
193 |
|
194 #ifdef USE_EAP_CONFIGURATION_TO_SKIP_USER_INTERACTIONS |
|
195 , m_skip_user_interactions(false) |
|
196 , m_fileconfig(0) |
|
197 #endif |
|
198 |
|
199 |
|
200 |
|
201 , iEapTtlsPapMaxSessionConfigTime( 0 ) |
|
202 , iEapTtlsPapActive( NULL ) |
|
203 |
|
204 { |
|
205 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
206 |
|
207 #ifdef USE_EAP_EXPANDED_TYPES |
|
208 |
|
209 m_tunneling_vendor_type = m_tunneling_type.get_vendor_type(); |
|
210 m_current_eap_vendor_type = m_current_eap_type.get_vendor_type(); |
|
211 |
|
212 #else |
|
213 |
|
214 m_tunneling_vendor_type = static_cast<TUint>(m_tunneling_type); |
|
215 m_current_eap_vendor_type = static_cast<TUint>(m_current_eap_type); |
|
216 |
|
217 #endif //#ifdef USE_EAP_EXPANDED_TYPES |
|
218 |
|
219 // Set the database table name based on the type |
|
220 switch (m_current_eap_vendor_type) |
|
221 { |
|
222 case eap_type_tls: |
|
223 m_db_table_name = KTlsDatabaseTableName; |
|
224 m_db_user_cert_table_name = KTlsAllowedUserCertsDatabaseTableName; |
|
225 m_db_ca_cert_table_name = KTlsAllowedCACertsDatabaseTableName; |
|
226 m_db_cipher_suite_table_name = KTlsAllowedCipherSuitesDatabaseTableName; |
|
227 m_db_name = KTlsDatabaseName; |
|
228 break; |
|
229 |
|
230 case eap_type_peap: |
|
231 m_db_table_name = KPeapDatabaseTableName; |
|
232 m_db_user_cert_table_name = KPeapAllowedUserCertsDatabaseTableName; |
|
233 m_db_ca_cert_table_name = KPeapAllowedCACertsDatabaseTableName; |
|
234 m_db_cipher_suite_table_name = KPeapAllowedCipherSuitesDatabaseTableName; |
|
235 m_db_name = KPeapDatabaseName; |
|
236 break; |
|
237 |
|
238 case eap_type_ttls_plain_pap: |
|
239 // use the same case as for eap_type_ttls; |
|
240 // break is not needed |
|
241 |
|
242 case eap_type_ttls: |
|
243 m_db_table_name = KTtlsDatabaseTableName; |
|
244 m_db_user_cert_table_name = KTtlsAllowedUserCertsDatabaseTableName; |
|
245 m_db_ca_cert_table_name = KTtlsAllowedCACertsDatabaseTableName; |
|
246 m_db_cipher_suite_table_name = KTtlsAllowedCipherSuitesDatabaseTableName; |
|
247 m_db_name = KTtlsDatabaseName; |
|
248 break; |
|
249 |
|
250 #if defined (USE_FAST_EAP_TYPE) |
|
251 case eap_type_fast: |
|
252 m_db_table_name = KFastGeneralSettingsDBTableName; // General settings |
|
253 m_db_fast_special_table_name = KFastSpecialSettingsDBTableName; // Special settings for only FAST |
|
254 m_db_user_cert_table_name = KFastAllowedUserCertsDatabaseTableName; |
|
255 m_db_ca_cert_table_name = KFastAllowedCACertsDatabaseTableName; |
|
256 m_db_cipher_suite_table_name = KFastAllowedCipherSuitesDatabaseTableName; |
|
257 m_db_name = KFastDatabaseName; |
|
258 break; |
|
259 #endif // #if defined (USE_FAST_EAP_TYPE) |
|
260 default: |
|
261 { |
|
262 // Unsupported type |
|
263 // Should never happen |
|
264 EAP_TRACE_ERROR(m_am_tools, |
|
265 TRACE_FLAGS_DEFAULT, ( |
|
266 EAPL("Unsupported EAP type, m_current_eap_vendor_type=%d \n"), |
|
267 m_current_eap_vendor_type)); |
|
268 |
|
269 return; |
|
270 } |
|
271 } |
|
272 |
|
273 if (receive_network_id != 0 |
|
274 && receive_network_id->get_is_valid_data() == true) |
|
275 { |
|
276 eap_status_e status = m_receive_network_id.set_copy_of_network_id( |
|
277 receive_network_id); |
|
278 if (status != eap_status_ok) |
|
279 { |
|
280 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
281 (void)EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error); |
|
282 return; |
|
283 } |
|
284 } |
|
285 |
|
286 set_is_valid(); |
|
287 |
|
288 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
289 } |
|
290 |
|
291 //-------------------------------------------------- |
|
292 |
|
293 // |
|
294 eap_am_type_tls_peap_symbian_c* eap_am_type_tls_peap_symbian_c::NewL( |
|
295 abs_eap_am_tools_c * const aTools, |
|
296 abs_eap_base_type_c * const aPartner, |
|
297 const TIndexType aIndexType, |
|
298 const TInt aIndex, |
|
299 const eap_type_value_e aTunnelingType, |
|
300 const eap_type_value_e aEapType, |
|
301 const bool aIsClient, |
|
302 const eap_am_network_id_c * const receive_network_id) |
|
303 { |
|
304 if (aEapType != eap_type_tls |
|
305 && aEapType != eap_type_peap |
|
306 #if defined(USE_TTLS_EAP_TYPE) |
|
307 && aEapType != eap_type_ttls |
|
308 #endif // #if defined(USE_TTLS_EAP_TYPE) |
|
309 |
|
310 && aEapType != eap_type_ttls_plain_pap |
|
311 |
|
312 #if defined (USE_FAST_EAP_TYPE) |
|
313 && aEapType != eap_type_fast |
|
314 #endif // #if defined (USE_FAST_EAP_TYPE) |
|
315 ) |
|
316 { |
|
317 User::Leave(KErrNotSupported); |
|
318 } |
|
319 |
|
320 eap_am_type_tls_peap_symbian_c* self = new(ELeave) eap_am_type_tls_peap_symbian_c( |
|
321 aTools, |
|
322 aPartner, |
|
323 aIndexType, |
|
324 aIndex, |
|
325 aTunnelingType, |
|
326 aEapType, |
|
327 aIsClient, |
|
328 receive_network_id); |
|
329 |
|
330 CleanupStack::PushL(self); |
|
331 |
|
332 if (self->get_is_valid() != true) |
|
333 { |
|
334 User::Leave(KErrGeneral); |
|
335 } |
|
336 |
|
337 self->ConstructL(); |
|
338 |
|
339 CleanupStack::Pop(); |
|
340 return self; |
|
341 } |
|
342 |
|
343 //-------------------------------------------------- |
|
344 |
|
345 // |
|
346 void eap_am_type_tls_peap_symbian_c::ConstructL() |
|
347 { |
|
348 // Open/create database |
|
349 EapTlsPeapUtils::OpenDatabaseL(m_database, m_session, m_index_type, m_index, m_tunneling_type, m_current_eap_type); |
|
350 |
|
351 m_cert_if = CEapTlsPeapCertInterface::NewL(m_am_tools, this); |
|
352 |
|
353 CActiveScheduler::Add(this); |
|
354 |
|
355 // Create and open PAC store (only for EAP-FAST at the moment) |
|
356 #ifdef USE_PAC_STORE |
|
357 #ifdef USE_FAST_EAP_TYPE |
|
358 |
|
359 if(m_current_eap_type == eap_type_fast && iPacStoreDb == NULL) |
|
360 { |
|
361 iPacStoreDb = CPacStoreDatabase::NewL( this ); |
|
362 User::LeaveIfNull(iPacStoreDb); |
|
363 |
|
364 EAP_TRACE_DEBUG_SYMBIAN( |
|
365 (_L("eap_am_type_tls_peap_symbian_c::ConstructL Created PAC store"))); |
|
366 |
|
367 iPacStoreDb->OpenPacStoreL(); |
|
368 |
|
369 EAP_TRACE_DEBUG_SYMBIAN( |
|
370 (_L("eap_am_type_tls_peap_symbian_c::ConstructL Opened PAC store"))); |
|
371 } |
|
372 m_info_array.Reset(); |
|
373 |
|
374 #endif // End: #ifdef USE_FAST_EAP_TYPE |
|
375 #endif // End: #ifdef USE_PAC_STORE |
|
376 |
|
377 #ifdef USE_FAST_EAP_TYPE |
|
378 |
|
379 if(m_current_eap_type == eap_type_fast) |
|
380 { |
|
381 m_notifier_data_to_user = new(ELeave) TEapFastNotifierStruct; |
|
382 m_notifier_data_pckg_to_user = new(ELeave) TPckg<TEapFastNotifierStruct> (*m_notifier_data_to_user); |
|
383 |
|
384 EAP_TRACE_DATA_DEBUG( |
|
385 m_am_tools, |
|
386 TRACE_FLAGS_DEFAULT, |
|
387 (EAPL("eap_am_type_tls_peap_symbian_c::ConstructL m_notifier_data_pckg_to_user"), |
|
388 m_notifier_data_pckg_to_user->Ptr(), |
|
389 m_notifier_data_pckg_to_user->Size())); |
|
390 |
|
391 m_notifier_data_from_user = new(ELeave) TEapFastNotifierStruct; |
|
392 m_notifier_data_pckg_from_user = new(ELeave) TPckg<TEapFastNotifierStruct> (*m_notifier_data_from_user); |
|
393 } |
|
394 #endif // End: #ifdef USE_FAST_EAP_TYPE |
|
395 |
|
396 |
|
397 } |
|
398 |
|
399 //-------------------------------------------------- |
|
400 |
|
401 // |
|
402 |
|
403 EAP_FUNC_EXPORT eap_status_e eap_am_type_tls_peap_symbian_c::shutdown() |
|
404 { |
|
405 EAP_TRACE_DEBUG( |
|
406 m_am_tools, |
|
407 TRACE_FLAGS_DEFAULT, |
|
408 (EAPL("TLS: %s: function: eap_am_type_tls_peap_symbian_c::shutdown()\n"), |
|
409 (m_is_client == true ? "client": "server"))); |
|
410 |
|
411 if(IsActive()) |
|
412 { |
|
413 RDebug::Print( _L("eap_am_type_tls_peap_symbian_c::shutdown() cancelling active object") ); |
|
414 Cancel(); |
|
415 } |
|
416 |
|
417 else |
|
418 { |
|
419 if(m_cert_if->IsActive()) |
|
420 { |
|
421 m_cert_if->Cancel(); |
|
422 } |
|
423 } |
|
424 |
|
425 if ( iEapTtlsPapActive ) |
|
426 { |
|
427 if ( iEapTtlsPapActive->IsActive() ) |
|
428 { |
|
429 EAP_TRACE_DEBUG_SYMBIAN( |
|
430 ( _L( " eap_am_type_tls_peap_symbian_c::shutdown() \ |
|
431 Cancelling iEapTtlsPapActive." ) ) ); |
|
432 iEapTtlsPapActive->Cancel(); |
|
433 } |
|
434 EAP_TRACE_DEBUG_SYMBIAN( |
|
435 ( _L( " eap_am_type_tls_peap_symbian_c::shutdown() \ |
|
436 Deleting iEapTtlsPapActive." ) ) ); |
|
437 delete iEapTtlsPapActive; |
|
438 iEapTtlsPapActive = NULL; |
|
439 } |
|
440 |
|
441 #if defined(USE_FAST_EAP_TYPE) |
|
442 if( m_is_notifier_connected ) |
|
443 { |
|
444 EAP_TRACE_DEBUG_SYMBIAN( |
|
445 (_L(" eap_am_type_tls_peap_symbian_c::shutdown - calling m_notifier.CancelNotifier"))); |
|
446 if(IsActive()) |
|
447 { |
|
448 TInt error = m_notifier.CancelNotifier(KEapFastNotifierUid); |
|
449 EAP_TRACE_DEBUG_SYMBIAN( |
|
450 (_L("eap_am_type_tls_peap_symbian_c::shutdown - CancelNotifier=%d"), error)); |
|
451 } |
|
452 EAP_TRACE_DEBUG_SYMBIAN( |
|
453 (_L(" eap_am_type_securid_symbian_c::shutdown - calling m_notifier.Close()"))); |
|
454 |
|
455 m_notifier.Close(); // Call close only if it is connected. |
|
456 |
|
457 m_is_notifier_connected = false; |
|
458 |
|
459 } // End: if( m_is_notifier_connected ) |
|
460 |
|
461 if (m_partner != NULL) |
|
462 { |
|
463 EAP_TRACE_DEBUG_SYMBIAN( |
|
464 (_L(" eap_am_type_tls_peap_symbian_c::shutdown - Cancel timers ..."))); |
|
465 |
|
466 m_partner->cancel_timer( |
|
467 this, |
|
468 KRemoveIAPReferenceTimerID); |
|
469 |
|
470 m_partner->cancel_timer( |
|
471 this, |
|
472 KImportFileTimerID); |
|
473 |
|
474 m_partner->cancel_timer( |
|
475 this, |
|
476 KCompleteReadPacstoreTimerID); |
|
477 |
|
478 m_partner->cancel_timer( |
|
479 this, |
|
480 KHandleReadPacstoreTimerID); |
|
481 |
|
482 EAP_TRACE_DEBUG_SYMBIAN( |
|
483 (_L(" eap_am_type_tls_peap_symbian_c::shutdown - Timers canceled"))); |
|
484 } |
|
485 |
|
486 if ( iEapFastActiveWaitNote ) |
|
487 { |
|
488 if ( iEapFastActiveWaitNote->IsActive() ) |
|
489 { |
|
490 iEapFastActiveWaitNote->Cancel(); |
|
491 } |
|
492 delete iEapFastActiveWaitNote; |
|
493 iEapFastActiveWaitNote = NULL; |
|
494 } |
|
495 |
|
496 if ( iEapFastActiveNotes ) |
|
497 { |
|
498 if ( iEapFastActiveNotes->IsActive() ) |
|
499 { |
|
500 iEapFastActiveNotes->Cancel(); |
|
501 } |
|
502 delete iEapFastActiveNotes; |
|
503 iEapFastActiveNotes = NULL; |
|
504 } |
|
505 #endif // #if defined(USE_FAST_EAP_TYPE) |
|
506 |
|
507 |
|
508 m_allowed_server_certs.Reset(); |
|
509 m_allowed_ca_certs.Close(); |
|
510 m_allowed_cipher_suites.Close(); |
|
511 m_allowed_user_certs.Reset(); |
|
512 |
|
513 #ifdef USE_PAC_STORE |
|
514 #ifdef USE_FAST_EAP_TYPE |
|
515 |
|
516 if(m_current_eap_type == eap_type_fast && iPacStoreDb != NULL) |
|
517 { |
|
518 iPacStoreDb->Close(); |
|
519 } |
|
520 |
|
521 TInt count=0; |
|
522 while (count < m_info_array.Count()) |
|
523 { |
|
524 delete m_info_array[count].iData; |
|
525 delete m_info_array[count].iReference; |
|
526 } |
|
527 m_info_array.Reset(); |
|
528 |
|
529 EAP_TRACE_DEBUG_SYMBIAN( |
|
530 (_L(" eap_am_type_tls_peap_symbian_c::shutdown - Arrays cleared"))); |
|
531 |
|
532 #endif // End: #ifdef USE_FAST_EAP_TYPE |
|
533 #endif // End: #ifdef USE_PAC_STORE |
|
534 |
|
535 m_shutdown_was_called = true; |
|
536 |
|
537 #if defined(USE_EAP_CONFIGURATION_TO_SKIP_USER_INTERACTIONS) |
|
538 delete m_fileconfig; |
|
539 m_fileconfig = 0; |
|
540 #endif |
|
541 |
|
542 EAP_TRACE_DEBUG( |
|
543 m_am_tools, |
|
544 TRACE_FLAGS_DEFAULT, |
|
545 (EAPL("TLS: %s: function: eap_am_type_tls_peap_symbian_c::shutdown() returns\n"), |
|
546 (m_is_client == true ? "client": "server"))); |
|
547 |
|
548 return eap_status_ok; |
|
549 } |
|
550 |
|
551 |
|
552 //-------------------------------------------------- |
|
553 |
|
554 EAP_FUNC_EXPORT eap_am_type_tls_peap_symbian_c::~eap_am_type_tls_peap_symbian_c() |
|
555 { |
|
556 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
557 |
|
558 EAP_TRACE_RETURN_STRING(m_am_tools, "returns: eap_am_type_tls_peap_symbian_c::~eap_am_type_tls_peap_symbian_c()"); |
|
559 |
|
560 EAP_TRACE_DEBUG( |
|
561 m_am_tools, |
|
562 TRACE_FLAGS_DEFAULT, |
|
563 (EAPL("TLS: %s: function: eap_am_type_tls_peap_symbian_c::~eap_am_type_tls_peap_symbian_c()\n"), |
|
564 (m_is_client == true ? "client": "server"))); |
|
565 |
|
566 EAP_ASSERT(m_shutdown_was_called == true); |
|
567 |
|
568 m_database.Close(); |
|
569 m_session.Close(); |
|
570 |
|
571 #ifdef USE_FAST_EAP_TYPE |
|
572 |
|
573 if(m_current_eap_type == eap_type_fast) |
|
574 { |
|
575 delete m_notifier_data_to_user; |
|
576 delete m_notifier_data_pckg_to_user; |
|
577 |
|
578 delete m_notifier_data_from_user; |
|
579 delete m_notifier_data_pckg_from_user; |
|
580 } |
|
581 #endif // End: #ifdef USE_FAST_EAP_TYPE |
|
582 |
|
583 delete m_cert_if; |
|
584 |
|
585 delete m_ca_certificate; |
|
586 delete m_own_certificate; |
|
587 delete m_peer_certificate; |
|
588 delete m_identity_info; |
|
589 |
|
590 #ifdef USE_EAP_EXPANDED_TYPES |
|
591 |
|
592 m_enabled_tunneling_exp_eap_array.ResetAndDestroy(); |
|
593 m_disabled_tunneling_exp_eap_array.ResetAndDestroy(); |
|
594 |
|
595 EAP_TRACE_DEBUG( |
|
596 m_am_tools, |
|
597 TRACE_FLAGS_DEFAULT, |
|
598 (EAPL("eap_am_type_tls_peap_symbian_c::~eap_am_type_tls_peap_symbian_c() tunneling done.\n"))); |
|
599 |
|
600 #else |
|
601 |
|
602 m_iap_eap_array.ResetAndDestroy(); |
|
603 |
|
604 #endif // #ifdef USE_EAP_EXPANDED_TYPES |
|
605 |
|
606 #ifdef USE_PAC_STORE |
|
607 |
|
608 delete iPacStoreDb; |
|
609 |
|
610 #endif // End: #ifdef USE_PAC_STORE |
|
611 |
|
612 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
613 } |
|
614 //-------------------------------------------------- |
|
615 |
|
616 // |
|
617 |
|
618 void eap_am_type_tls_peap_symbian_c::RunL() |
|
619 { |
|
620 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
621 |
|
622 EAP_TRACE_DEBUG_SYMBIAN( |
|
623 (_L("eap_am_type_tls_peap_symbian_c::RunL - iStatus.Int()=%d, m_state=%d "), |
|
624 iStatus.Int() , m_state)); |
|
625 |
|
626 #ifdef USE_FAST_EAP_TYPE |
|
627 eap_status_e status(eap_status_ok); |
|
628 |
|
629 if (m_notifier_complete) |
|
630 { |
|
631 |
|
632 TRAPD(err, CompleteNotifierL());// Only for the notifiers. |
|
633 if (err != KErrNone) |
|
634 { |
|
635 EAP_TRACE_ERROR(m_am_tools, |
|
636 TRACE_FLAGS_DEFAULT, ( |
|
637 EAPL("eap_am_type_tls_peap_symbian_c::RunL LEAVE from CompleteNotifierL, Error =%d \n"), |
|
638 err)); |
|
639 } |
|
640 |
|
641 m_notifier_complete = EFalse; |
|
642 } |
|
643 |
|
644 if ( m_state == EPasswordCancel || |
|
645 m_state == EMasterkeyQuery || |
|
646 m_state == EPasswordQuery || |
|
647 m_state == EWrongPassword || |
|
648 m_state == EFilePasswordQuery ) |
|
649 { |
|
650 m_eap_fast_completion_status = m_partner->set_timer( |
|
651 this, |
|
652 KHandleReadPacstoreTimerID, |
|
653 &status, |
|
654 0); |
|
655 return; |
|
656 } |
|
657 if (m_state == ENone) |
|
658 { |
|
659 return; |
|
660 } |
|
661 |
|
662 #endif // #ifdef USE_FAST_EAP_TYPE |
|
663 |
|
664 if (iStatus.Int() != KErrNone) |
|
665 { |
|
666 // Notifier was cancelled or something went wrong |
|
667 EAP_TRACE_DEBUG( |
|
668 m_am_tools, |
|
669 TRACE_FLAGS_DEFAULT, |
|
670 (EAPL("ERROR: EAP-TLS: Certificate selection notifier was cancelled or failed, error=%d, m_state=%d.\n"), |
|
671 iStatus.Int(), |
|
672 m_state)); |
|
673 |
|
674 switch (m_state) |
|
675 { |
|
676 case EHandlingIdentityQuery: |
|
677 case EHandlingManualIdentityQuery: |
|
678 |
|
679 EAP_TRACE_DEBUG( |
|
680 m_am_tools, |
|
681 TRACE_FLAGS_DEFAULT, |
|
682 (EAPL("ERROR: EAP-TLS: Cannot read user certificate.\n"))); |
|
683 |
|
684 get_am_partner()->complete_eap_identity_query( |
|
685 0, // 0 because identity query failed |
|
686 &m_receive_network_id, |
|
687 m_eap_identifier, |
|
688 eap_status_process_general_error, |
|
689 false, |
|
690 0, |
|
691 false, |
|
692 0); |
|
693 return; |
|
694 |
|
695 case EHandlingChainQuery: |
|
696 // Notifier was cancelled or something went wrong |
|
697 get_tls_am_partner()->complete_query_certificate_chain( |
|
698 0, |
|
699 eap_status_process_general_error); |
|
700 return; |
|
701 default: |
|
702 return; |
|
703 } |
|
704 } |
|
705 |
|
706 if (m_state == EHandlingIdentityQuery |
|
707 || m_state == EHandlingChainQuery) |
|
708 { |
|
709 TUint index(0); |
|
710 if (m_selector_output.Length() > 0) |
|
711 { |
|
712 TPckg<TUint> data(index); |
|
713 data.Copy(m_selector_output); |
|
714 } |
|
715 else |
|
716 { |
|
717 // There is only one certificate. Use that. |
|
718 index = 0; |
|
719 } |
|
720 |
|
721 if(m_allowed_user_certs.Count() > 0) |
|
722 { |
|
723 m_own_certificate_info = m_allowed_user_certs[index]; |
|
724 } |
|
725 |
|
726 TBool retrieve_chain; |
|
727 |
|
728 if (m_state == EHandlingChainQuery) |
|
729 { |
|
730 retrieve_chain = true; |
|
731 } |
|
732 else |
|
733 { |
|
734 retrieve_chain = false; |
|
735 } |
|
736 |
|
737 TInt allowed_user_cert_count = m_allowed_user_certs.Count(); |
|
738 TInt err(KErrNone); |
|
739 |
|
740 if(allowed_user_cert_count > 0) |
|
741 { |
|
742 TRAP(err, m_cert_if->ReadCertificateL(m_allowed_user_certs[index], retrieve_chain)); |
|
743 } |
|
744 if (err != KErrNone || allowed_user_cert_count <= 0) |
|
745 { |
|
746 EAP_TRACE_ERROR( |
|
747 m_am_tools, |
|
748 TRACE_FLAGS_DEFAULT, |
|
749 (EAPL("ERROR: Certificate reading failed or no user cert, user cert count=%d\n"), |
|
750 allowed_user_cert_count)); |
|
751 |
|
752 switch (m_state) |
|
753 { |
|
754 case EHandlingIdentityQuery: |
|
755 EAP_TRACE_DEBUG( |
|
756 m_am_tools, |
|
757 TRACE_FLAGS_DEFAULT, |
|
758 (EAPL("ERROR: EAP-TLS: EHandlingIdentityQuery: Cannot read user certificate.\n"))); |
|
759 |
|
760 get_am_partner()->complete_eap_identity_query( |
|
761 0, // 0 because identity query failed |
|
762 &m_receive_network_id, |
|
763 m_eap_identifier, |
|
764 eap_status_process_general_error, |
|
765 false, |
|
766 0, |
|
767 false, |
|
768 0); |
|
769 return; |
|
770 |
|
771 case EHandlingChainQuery: |
|
772 // Notifier was cancelled or something went wrong |
|
773 get_tls_am_partner()->complete_query_certificate_chain( |
|
774 0, |
|
775 eap_status_process_general_error); |
|
776 return; |
|
777 default: |
|
778 return; |
|
779 } |
|
780 } |
|
781 } |
|
782 else if (m_state == EHandlingManualIdentityQuery) |
|
783 { |
|
784 // Convert to 8-bit text |
|
785 TBuf8<KIdentityFieldLength> buf; |
|
786 buf.Copy(m_identity_info->iUsername); |
|
787 |
|
788 eap_status_e status = m_manual_username.set_copy_of_buffer( |
|
789 buf.Ptr(), |
|
790 buf.Size()); |
|
791 |
|
792 if (status != eap_status_ok) |
|
793 { |
|
794 EAP_TRACE_DEBUG( |
|
795 m_am_tools, |
|
796 TRACE_FLAGS_DEFAULT, |
|
797 (EAPL("ERROR: EAP-TLS: EHandlingIdentityQuery: Cannot read manual username.\n"))); |
|
798 |
|
799 get_am_partner()->complete_eap_identity_query( |
|
800 0, // 0 because identity query failed |
|
801 &m_receive_network_id, |
|
802 m_eap_identifier, |
|
803 status, |
|
804 false, |
|
805 0, |
|
806 false, |
|
807 0); |
|
808 } |
|
809 |
|
810 buf.Copy(m_identity_info->iRealm); |
|
811 status = m_manual_realm.set_copy_of_buffer( |
|
812 buf.Ptr(), |
|
813 buf.Size()); |
|
814 |
|
815 if (status != eap_status_ok) |
|
816 { |
|
817 EAP_TRACE_DEBUG( |
|
818 m_am_tools, |
|
819 TRACE_FLAGS_DEFAULT, |
|
820 (EAPL("ERROR: EAP-TLS: EHandlingIdentityQuery: Cannot read manual realm.\n"))); |
|
821 |
|
822 get_am_partner()->complete_eap_identity_query( |
|
823 0, // 0 because identity query failed |
|
824 &m_receive_network_id, |
|
825 m_eap_identifier, |
|
826 status, |
|
827 false, |
|
828 0, |
|
829 false, |
|
830 0); |
|
831 } |
|
832 |
|
833 // This must be true |
|
834 m_use_manual_realm = true; |
|
835 |
|
836 if (m_identity_info->iUseManualUsername) |
|
837 { |
|
838 m_use_manual_username = true; |
|
839 } |
|
840 else |
|
841 { |
|
842 m_use_manual_username = false; |
|
843 } |
|
844 |
|
845 |
|
846 get_am_partner()->complete_eap_identity_query( |
|
847 0, // 0 because identity query failed |
|
848 &m_receive_network_id, |
|
849 m_eap_identifier, |
|
850 eap_status_ok, |
|
851 m_use_manual_username, |
|
852 &m_manual_username, |
|
853 m_use_manual_realm, |
|
854 &m_manual_realm); |
|
855 |
|
856 TRAPD(err, SaveManualIdentityL( |
|
857 m_identity_info->iUseManualUsername, |
|
858 m_identity_info->iUsername, |
|
859 ETrue, |
|
860 m_identity_info->iRealm)); |
|
861 |
|
862 (void)EAP_STATUS_RETURN(m_am_tools, m_am_tools->convert_am_error_to_eapol_error(err)); |
|
863 |
|
864 // Ignore return value on purpose. It's not fatal if saving fails. |
|
865 |
|
866 delete m_identity_info; |
|
867 m_identity_info = 0; |
|
868 |
|
869 } |
|
870 |
|
871 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
872 } |
|
873 |
|
874 //-------------------------------------------------- |
|
875 |
|
876 // |
|
877 |
|
878 |
|
879 void eap_am_type_tls_peap_symbian_c::DoCancel() |
|
880 { |
|
881 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
882 |
|
883 RDebug::Print( _L("eap_am_type_tls_peap_symbian_c::DoCancel()\n") ); |
|
884 |
|
885 if(m_cert_if->IsActive()) |
|
886 { |
|
887 m_cert_if->Cancel(); |
|
888 } |
|
889 |
|
890 if ( iEapTtlsPapActive ) |
|
891 { |
|
892 if ( iEapTtlsPapActive->IsActive() ) |
|
893 { |
|
894 EAP_TRACE_DEBUG_SYMBIAN( |
|
895 ( _L( " eap_am_type_tls_peap_symbian_c::DoCancel() \ |
|
896 Cancelling iEapTtlsPapActive." ) ) ); |
|
897 iEapTtlsPapActive->Cancel(); |
|
898 } |
|
899 } |
|
900 |
|
901 #if defined(USE_FAST_EAP_TYPE) |
|
902 |
|
903 m_partner->cancel_timer( |
|
904 this, |
|
905 KRemoveIAPReferenceTimerID); |
|
906 |
|
907 m_partner->cancel_timer( |
|
908 this, |
|
909 KImportFileTimerID); |
|
910 |
|
911 m_partner->cancel_timer( |
|
912 this, |
|
913 KCompleteReadPacstoreTimerID); |
|
914 |
|
915 m_partner->cancel_timer( |
|
916 this, |
|
917 KHandleReadPacstoreTimerID); |
|
918 |
|
919 if( m_is_notifier_connected ) |
|
920 { |
|
921 EAP_TRACE_DEBUG_SYMBIAN( |
|
922 (_L(" eap_am_type_tls_peap_symbian_c::DoCancel - calling m_notifier.CancelNotifier"))); |
|
923 if(IsActive()) |
|
924 { |
|
925 TInt error = m_notifier.CancelNotifier(KEapFastNotifierUid); |
|
926 EAP_TRACE_DEBUG_SYMBIAN( |
|
927 (_L("eap_am_type_tls_peap_symbian_c::DoCancel:CancelNotifier=%d"), |
|
928 error)); |
|
929 } |
|
930 |
|
931 m_notifier.Close(); // Call close only if it is connected. |
|
932 |
|
933 m_is_notifier_connected = false; |
|
934 |
|
935 } // End: if( m_is_notifier_connected ) |
|
936 |
|
937 #endif // #if defined(USE_FAST_EAP_TYPE) |
|
938 |
|
939 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
940 } |
|
941 |
|
942 //-------------------------------------------------- |
|
943 |
|
944 // |
|
945 |
|
946 eap_status_e eap_am_type_tls_peap_symbian_c::SaveManualIdentityL( |
|
947 const TBool use_manual_username, |
|
948 TDesC& manual_username, |
|
949 const TBool use_manual_realm, |
|
950 TDesC& manual_realm) |
|
951 { |
|
952 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
953 |
|
954 // Validate length. |
|
955 if(manual_username.Length() > KMaxManualUsernameLengthInDB |
|
956 || manual_realm.Length() > KMaxManualRealmLengthInDB) |
|
957 { |
|
958 // Username or realm too long. Can not be stored in DB. |
|
959 EAP_TRACE_DEBUG_SYMBIAN((_L("eap_am_type_tls_peap_symbian_c::SaveManualIdentityL: Too long username or realm. Length: UN=%d, Realm=%d\n"), |
|
960 manual_username.Length(), manual_realm.Length())); |
|
961 |
|
962 User::Leave(KErrArgument); |
|
963 } |
|
964 |
|
965 HBufC* sqlbuf = HBufC::NewLC(KMaxSqlQueryLength); |
|
966 TPtr sqlStatement = sqlbuf->Des(); |
|
967 |
|
968 RDbView view; |
|
969 |
|
970 _LIT(KSQL, "SELECT * FROM %S WHERE %S=%d AND %S=%d AND %S=%d"); |
|
971 |
|
972 sqlStatement.Format(KSQL, &m_db_table_name, |
|
973 &KServiceType, m_index_type, &KServiceIndex, m_index, &KTunnelingType, m_tunneling_vendor_type); |
|
974 |
|
975 User::LeaveIfError(view.Prepare(m_database, TDbQuery(sqlStatement), TDbWindow::EUnlimited)); |
|
976 CleanupClosePushL(view); |
|
977 User::LeaveIfError(view.EvaluateAll()); |
|
978 |
|
979 // Get column set so we get the correct column numbers |
|
980 CDbColSet* colSet = view.ColSetL(); |
|
981 CleanupStack::PushL(colSet); |
|
982 |
|
983 view.FirstL(); |
|
984 |
|
985 view.UpdateL(); |
|
986 |
|
987 view.SetColL(colSet->ColNo(cf_str_EAP_TLS_PEAP_use_manual_realm_literal), static_cast<TUint>(use_manual_realm) ); |
|
988 |
|
989 view.SetColL(colSet->ColNo(cf_str_EAP_TLS_PEAP_manual_realm_literal), manual_realm); // realm |
|
990 |
|
991 view.SetColL(colSet->ColNo(cf_str_EAP_TLS_PEAP_use_manual_username_literal), static_cast<TUint>(use_manual_username) ); |
|
992 |
|
993 view.SetColL(colSet->ColNo(cf_str_EAP_TLS_PEAP_manual_username_literal), manual_username); |
|
994 |
|
995 view.PutL(); |
|
996 |
|
997 CleanupStack::PopAndDestroy(3); // colset, view, session |
|
998 |
|
999 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
1000 return EAP_STATUS_RETURN(m_am_tools, eap_status_ok); |
|
1001 } |
|
1002 |
|
1003 |
|
1004 //-------------------------------------------------- |
|
1005 |
|
1006 abs_eap_am_type_tls_peap_c * eap_am_type_tls_peap_symbian_c::get_am_partner() |
|
1007 { |
|
1008 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
1009 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
1010 return m_am_partner; |
|
1011 } |
|
1012 |
|
1013 //-------------------------------------------------- |
|
1014 |
|
1015 void eap_am_type_tls_peap_symbian_c::set_am_partner(abs_eap_am_type_tls_peap_c * const partner) |
|
1016 { |
|
1017 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
1018 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
1019 m_am_partner = partner; |
|
1020 } |
|
1021 |
|
1022 //-------------------------------------------------- |
|
1023 |
|
1024 EAP_FUNC_EXPORT abs_tls_am_services_c * eap_am_type_tls_peap_symbian_c::get_tls_am_partner() |
|
1025 { |
|
1026 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
1027 |
|
1028 EAP_ASSERT_ALWAYS(m_tls_am_partner != 0); |
|
1029 |
|
1030 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
1031 return m_tls_am_partner; |
|
1032 } |
|
1033 |
|
1034 //-------------------------------------------------- |
|
1035 |
|
1036 EAP_FUNC_EXPORT void eap_am_type_tls_peap_symbian_c::set_tls_am_partner(abs_tls_am_services_c * const tls_am_partner) |
|
1037 { |
|
1038 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
1039 |
|
1040 m_tls_am_partner = tls_am_partner; |
|
1041 |
|
1042 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
1043 } |
|
1044 |
|
1045 // --------------------------------------------------------- |
|
1046 // eap_am_type_tls_peap_symbian_c::SendErrorNotification() |
|
1047 // --------------------------------------------------------- |
|
1048 // |
|
1049 void eap_am_type_tls_peap_symbian_c::SendErrorNotification( |
|
1050 const eap_status_e aError ) |
|
1051 { |
|
1052 send_error_notification( aError ); |
|
1053 } |
|
1054 //-------------------------------------------------- |
|
1055 |
|
1056 #if defined(USE_FAST_EAP_TYPE) |
|
1057 |
|
1058 EAP_FUNC_EXPORT void eap_am_type_tls_peap_symbian_c::set_tls_application( |
|
1059 abs_tls_am_application_eap_fast_c * const tls_application) |
|
1060 { |
|
1061 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
1062 |
|
1063 m_tls_application = tls_application; |
|
1064 |
|
1065 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
1066 } |
|
1067 |
|
1068 |
|
1069 |
|
1070 |
|
1071 // --------------------------------------------------------- |
|
1072 // eap_am_type_tls_peap_symbian_c::IsProvisioningMode() |
|
1073 // --------------------------------------------------------- |
|
1074 // |
|
1075 TBool eap_am_type_tls_peap_symbian_c::IsProvisioningMode() |
|
1076 { |
|
1077 return ( m_provisioning_mode == |
|
1078 eap_fast_completion_operation_server_authenticated_provisioning_mode ) ? ETrue : EFalse; |
|
1079 } |
|
1080 |
|
1081 |
|
1082 // --------------------------------------------------------- |
|
1083 // eap_am_type_tls_peap_symbian_c::CompleteQueryUserPermissionForAid() |
|
1084 // --------------------------------------------------------- |
|
1085 // |
|
1086 eap_status_e |
|
1087 eap_am_type_tls_peap_symbian_c::CompleteQueryUserPermissionForAid( |
|
1088 EEapFastNotifierUserAction aUserAction ) |
|
1089 { |
|
1090 EAP_TRACE_DEBUG_SYMBIAN( |
|
1091 (_L("eap_am_type_tls_peap_symbian_c::CompleteQueryUserPermissionForAid"))); |
|
1092 if ( aUserAction == EEapFastNotifierUserActionOk ) |
|
1093 { |
|
1094 EAP_TRACE_DEBUG_SYMBIAN( |
|
1095 (_L("eap_am_type_tls_peap_symbian_c::CompleteQueryUserPermissionForAid eap_status_ok"))); |
|
1096 m_eap_fast_completion_status = m_tls_application-> |
|
1097 complete_query_user_permission_for_A_ID( |
|
1098 eap_status_ok, |
|
1099 m_pending_operation ); |
|
1100 } |
|
1101 else //if (userAction == EEapFastNotifierUserActionCancel) |
|
1102 { |
|
1103 EAP_TRACE_DEBUG_SYMBIAN( |
|
1104 _L("eap_am_type_tls_peap_symbian_c::CompleteQueryUserPermissionForAid eap_status_user_cancel_authentication")); |
|
1105 |
|
1106 // comlete query |
|
1107 m_eap_fast_completion_status = m_tls_application-> |
|
1108 complete_query_user_permission_for_A_ID( |
|
1109 eap_status_user_cancel_authentication, |
|
1110 m_pending_operation ); |
|
1111 } |
|
1112 return m_eap_fast_completion_status; |
|
1113 } |
|
1114 |
|
1115 |
|
1116 #endif //#if defined(USE_FAST_EAP_TYPE) |
|
1117 |
|
1118 //-------------------------------------------------- |
|
1119 |
|
1120 // |
|
1121 void eap_am_type_tls_peap_symbian_c::notify_configuration_error( |
|
1122 const eap_status_e configuration_status) |
|
1123 { |
|
1124 if (m_is_client == true) |
|
1125 { |
|
1126 EAP_UNREFERENCED_PARAMETER(configuration_status); // in release |
|
1127 |
|
1128 EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("EAP-TLS: Configuration error notification, %d.\n"), |
|
1129 configuration_status)); |
|
1130 |
|
1131 // Here we swap the addresses. |
|
1132 eap_am_network_id_c send_network_id(m_am_tools, |
|
1133 m_receive_network_id.get_destination_id(), |
|
1134 m_receive_network_id.get_source_id(), |
|
1135 m_receive_network_id.get_type()); |
|
1136 |
|
1137 // Send a notification that configuration is incorrect. |
|
1138 eap_state_notification_c notification( |
|
1139 m_am_tools, |
|
1140 &send_network_id, |
|
1141 m_is_client, |
|
1142 eap_state_notification_eap, |
|
1143 eap_protocol_layer_general, // This must be used with eap_general_state_configuration_error. |
|
1144 m_current_eap_type, |
|
1145 eap_state_none, |
|
1146 eap_general_state_configuration_error, |
|
1147 0, |
|
1148 false); |
|
1149 |
|
1150 notification.set_authentication_error(configuration_status); |
|
1151 |
|
1152 m_partner->state_notification(¬ification); |
|
1153 } |
|
1154 } |
|
1155 |
|
1156 //-------------------------------------------------- |
|
1157 |
|
1158 // |
|
1159 EAP_FUNC_EXPORT eap_status_e eap_am_type_tls_peap_symbian_c::configure() |
|
1160 { |
|
1161 eap_status_e status(eap_status_ok); |
|
1162 |
|
1163 EAP_TRACE_DEBUG( |
|
1164 m_am_tools, |
|
1165 TRACE_FLAGS_DEFAULT, |
|
1166 (EAPL("TLS: %s: function: eap_am_type_tls_peap_symbian_c::configure()\n"), |
|
1167 (m_is_client == true ? "client": "server"))); |
|
1168 |
|
1169 |
|
1170 |
|
1171 if (m_configured == true) |
|
1172 { |
|
1173 EAP_TRACE_DEBUG( |
|
1174 m_am_tools, |
|
1175 TRACE_FLAGS_DEFAULT, |
|
1176 (EAPL("TLS: %s: function: eap_am_type_tls_peap_symbian_c::configure(): Already configured.\n"), |
|
1177 (m_is_client == true ? "client": "server"))); |
|
1178 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
1179 return EAP_STATUS_RETURN(m_am_tools, eap_status_ok); |
|
1180 } |
|
1181 |
|
1182 //---------------------------------------------------------- |
|
1183 |
|
1184 { |
|
1185 TRAPD(err, EapTlsPeapUtils::ReadCertRowsToArrayL( |
|
1186 m_database, |
|
1187 m_am_tools, |
|
1188 m_db_user_cert_table_name, |
|
1189 m_index_type, |
|
1190 m_index, |
|
1191 m_tunneling_type, |
|
1192 m_allowed_user_certs)); |
|
1193 |
|
1194 if (err != KErrNone) |
|
1195 { |
|
1196 EAP_TRACE_ERROR(m_am_tools, |
|
1197 TRACE_FLAGS_DEFAULT, ( |
|
1198 EAPL("eap_am_type_tls_peap_symbian_c::configure - ReadCertRowsToArrayL, User cert, Error =%d \n"), |
|
1199 err)); |
|
1200 |
|
1201 // Convert the leave error code to EAPOL stack error code. |
|
1202 status = m_am_tools->convert_am_error_to_eapol_error(err); |
|
1203 return EAP_STATUS_RETURN(m_am_tools, status); |
|
1204 } |
|
1205 else |
|
1206 { |
|
1207 EAP_TRACE_DEBUG_SYMBIAN( |
|
1208 (_L("eap_am_type_tls_peap_symbian_c::configure, EapTlsPeapUtils::ReadCertRowsToArrayL success, m_allowed_user_certs count=%d"), |
|
1209 m_allowed_user_certs.Count())); |
|
1210 } |
|
1211 |
|
1212 TRAP(err, EapTlsPeapUtils::ReadCertRowsToArrayL( |
|
1213 m_database, |
|
1214 m_am_tools, |
|
1215 m_db_ca_cert_table_name, |
|
1216 m_index_type, |
|
1217 m_index, |
|
1218 m_tunneling_type, |
|
1219 m_allowed_ca_certs)); |
|
1220 if (err != KErrNone) |
|
1221 { |
|
1222 EAP_TRACE_ERROR(m_am_tools, |
|
1223 TRACE_FLAGS_DEFAULT, ( |
|
1224 EAPL("eap_am_type_tls_peap_symbian_c::configure - ReadCertRowsToArrayL, CA cert, Error =%d \n"), |
|
1225 err)); |
|
1226 |
|
1227 // Convert the leave error code to EAPOL stack error code. |
|
1228 status = m_am_tools->convert_am_error_to_eapol_error(err); |
|
1229 return EAP_STATUS_RETURN(m_am_tools, status); |
|
1230 } |
|
1231 else |
|
1232 { |
|
1233 EAP_TRACE_DEBUG_SYMBIAN( |
|
1234 (_L("eap_am_type_tls_peap_symbian_c::configure, EapTlsPeapUtils::ReadCertRowsToArrayL success, m_allowed_ca_certs count=%d"), |
|
1235 m_allowed_ca_certs.Count())); |
|
1236 } |
|
1237 |
|
1238 TRAP(err, EapTlsPeapUtils::ReadUintRowsToArrayL( |
|
1239 m_database, |
|
1240 m_am_tools, |
|
1241 m_db_cipher_suite_table_name, |
|
1242 KCipherSuite, |
|
1243 m_index_type, |
|
1244 m_index, |
|
1245 m_tunneling_type, |
|
1246 m_allowed_cipher_suites)); |
|
1247 if (err != KErrNone) |
|
1248 { |
|
1249 EAP_TRACE_ERROR(m_am_tools, |
|
1250 TRACE_FLAGS_DEFAULT, ( |
|
1251 EAPL("eap_am_type_tls_peap_symbian_c::configure - ReadUintRowsToArrayL, CipherSuit, Error =%d \n"), |
|
1252 err)); |
|
1253 |
|
1254 // Convert the leave error code to EAPOL stack error code. |
|
1255 status = m_am_tools->convert_am_error_to_eapol_error(err); |
|
1256 return EAP_STATUS_RETURN(m_am_tools, status); |
|
1257 } |
|
1258 } |
|
1259 |
|
1260 //---------------------------------------------------------- |
|
1261 |
|
1262 if (m_current_eap_type == eap_type_peap |
|
1263 #if defined(USE_TTLS_EAP_TYPE) |
|
1264 || m_current_eap_type == eap_type_ttls |
|
1265 #endif |
|
1266 |
|
1267 #if defined(USE_FAST_EAP_TYPE) |
|
1268 || m_current_eap_type == eap_type_fast |
|
1269 #endif |
|
1270 |
|
1271 |
|
1272 ) |
|
1273 { |
|
1274 #ifdef USE_EAP_EXPANDED_TYPES |
|
1275 |
|
1276 TRAPD(err, EapTlsPeapUtils::GetTunnelingExpandedEapDataL( |
|
1277 m_database, |
|
1278 m_am_tools, |
|
1279 m_enabled_tunneling_exp_eap_array, |
|
1280 m_disabled_tunneling_exp_eap_array, |
|
1281 m_index_type, |
|
1282 m_index, |
|
1283 m_tunneling_type, |
|
1284 m_current_eap_type)); |
|
1285 |
|
1286 #else |
|
1287 TRAPD(err, EapTlsPeapUtils::GetEapDataL( |
|
1288 m_database, |
|
1289 m_am_tools, |
|
1290 m_iap_eap_array, |
|
1291 m_index_type, |
|
1292 m_index, |
|
1293 m_tunneling_type, |
|
1294 m_current_eap_type)); |
|
1295 |
|
1296 #endif //#ifdef USE_EAP_EXPANDED_TYPES |
|
1297 |
|
1298 if (err != KErrNone) |
|
1299 { |
|
1300 EAP_TRACE_ERROR(m_am_tools, |
|
1301 TRACE_FLAGS_DEFAULT, ( |
|
1302 EAPL("eap_am_type_tls_peap_symbian_c::configure - GetEapDataL or GetTunnelingExpandedEapDataL, Error =%d \n"), |
|
1303 err)); |
|
1304 |
|
1305 // Convert the leave error code to EAPOL stack error code. |
|
1306 status = m_am_tools->convert_am_error_to_eapol_error(err); |
|
1307 return EAP_STATUS_RETURN(m_am_tools, status); |
|
1308 } |
|
1309 } |
|
1310 |
|
1311 //---------------------------------------------------------- |
|
1312 |
|
1313 { |
|
1314 eap_variable_data_c verify_certificate_realm(m_am_tools); |
|
1315 |
|
1316 eap_status_e status = type_configure_read( |
|
1317 cf_str_EAP_TLS_PEAP_verify_certificate_realm.get_field(), |
|
1318 &verify_certificate_realm); |
|
1319 if (status == eap_status_ok |
|
1320 && verify_certificate_realm.get_is_valid_data() == true |
|
1321 && verify_certificate_realm.get_data_length() == sizeof(u32_t) |
|
1322 && verify_certificate_realm.get_data(sizeof(u32_t)) != 0) |
|
1323 { |
|
1324 // OK |
|
1325 // This is optional value. |
|
1326 if (*(reinterpret_cast<u32_t *>( |
|
1327 verify_certificate_realm.get_data(sizeof(u32_t)))) == 1) |
|
1328 { |
|
1329 m_verify_certificate_realm = true; |
|
1330 } |
|
1331 else |
|
1332 { |
|
1333 m_verify_certificate_realm = false; |
|
1334 } |
|
1335 } |
|
1336 } |
|
1337 |
|
1338 //---------------------------------------------------------- |
|
1339 |
|
1340 { |
|
1341 eap_variable_data_c allow_subdomain_matching(m_am_tools); |
|
1342 |
|
1343 eap_status_e status = type_configure_read( |
|
1344 cf_str_EAP_TLS_PEAP_allow_subdomain_matching.get_field(), |
|
1345 &allow_subdomain_matching); |
|
1346 if (status == eap_status_ok |
|
1347 && allow_subdomain_matching.get_is_valid_data() == true |
|
1348 && allow_subdomain_matching.get_data_length() == sizeof(u32_t) |
|
1349 && allow_subdomain_matching.get_data(sizeof(u32_t)) != 0) |
|
1350 { |
|
1351 // OK |
|
1352 // This is optional value. |
|
1353 if (*(reinterpret_cast<u32_t *>( |
|
1354 allow_subdomain_matching.get_data(sizeof(u32_t)))) == 1) |
|
1355 { |
|
1356 m_allow_subdomain_matching = true; |
|
1357 } |
|
1358 else |
|
1359 { |
|
1360 m_allow_subdomain_matching = false; |
|
1361 } |
|
1362 } |
|
1363 } |
|
1364 |
|
1365 //---------------------------------------------------------- |
|
1366 |
|
1367 // This is only for server |
|
1368 { |
|
1369 eap_variable_data_c cipher_suite(m_am_tools); |
|
1370 |
|
1371 eap_status_e status = type_configure_read( |
|
1372 cf_str_EAP_TLS_PEAP_cipher_suite.get_field(), |
|
1373 &cipher_suite); |
|
1374 if (status == eap_status_ok |
|
1375 && cipher_suite.get_is_valid_data() == true |
|
1376 && cipher_suite.get_data_length() == sizeof(u32_t) |
|
1377 && cipher_suite.get_data(sizeof(u32_t)) != 0) |
|
1378 { |
|
1379 // OK |
|
1380 // This is optional value. |
|
1381 m_cipher_suite = (tls_cipher_suites_e)*reinterpret_cast<u32_t *>( |
|
1382 cipher_suite.get_data(sizeof(u32_t))); |
|
1383 } |
|
1384 } |
|
1385 |
|
1386 //---------------------------------------------------------- |
|
1387 |
|
1388 #ifndef USE_EAP_EXPANDED_TYPES // This is not needed it seems. Still keeping it for normal EAP types. |
|
1389 // Intention of this is to get tunneled EAP types, but m_tunneled_type is not used |
|
1390 // anywhere other than this place. |
|
1391 |
|
1392 if (m_current_eap_type == eap_type_peap |
|
1393 #if defined(USE_TTLS_EAP_TYPE) |
|
1394 || m_current_eap_type == eap_type_ttls |
|
1395 #endif // #if defined(USE_TTLS_EAP_TYPE) |
|
1396 |
|
1397 #if defined(USE_FAST_EAP_TYPE) |
|
1398 || m_current_eap_type == eap_type_fast |
|
1399 #endif |
|
1400 |
|
1401 |
|
1402 ) |
|
1403 { |
|
1404 eap_variable_data_c tunneled_type(m_am_tools); |
|
1405 |
|
1406 eap_status_e status = type_configure_read( |
|
1407 cf_str_PEAP_tunneled_eap_type_hex_data.get_field(), |
|
1408 &tunneled_type); |
|
1409 if (status == eap_status_illegal_configure_type) |
|
1410 { |
|
1411 status = m_partner->read_configure( |
|
1412 cf_str_PEAP_tunneled_eap_type_u32_t.get_field(), |
|
1413 &tunneled_type); |
|
1414 } |
|
1415 if (status != eap_status_ok) |
|
1416 { |
|
1417 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
1418 return EAP_STATUS_RETURN(m_am_tools, status); |
|
1419 } |
|
1420 else if (tunneled_type.get_is_valid_data() == true |
|
1421 && tunneled_type.get_data_length() == sizeof(u32_t) |
|
1422 && tunneled_type.get_data(sizeof(u32_t)) != 0) |
|
1423 { |
|
1424 m_tunneled_type = static_cast<eap_type_value_e>( |
|
1425 *reinterpret_cast<u32_t *>(tunneled_type.get_data(sizeof(u32_t)))); |
|
1426 } |
|
1427 else if (tunneled_type.get_data_length() |
|
1428 == eap_expanded_type_c::get_eap_expanded_type_size() |
|
1429 && tunneled_type.get_data(tunneled_type.get_data_length()) != 0) |
|
1430 { |
|
1431 eap_expanded_type_c eap_type(eap_type_none); |
|
1432 |
|
1433 status = eap_type.set_expanded_type_data( |
|
1434 m_am_tools, |
|
1435 &tunneled_type); |
|
1436 if (status != eap_status_ok) |
|
1437 { |
|
1438 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
1439 return EAP_STATUS_RETURN(m_am_tools, status); |
|
1440 } |
|
1441 |
|
1442 status = eap_type.get_type_data( |
|
1443 m_am_tools, |
|
1444 &m_tunneled_type); |
|
1445 if (status != eap_status_ok) |
|
1446 { |
|
1447 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
1448 return EAP_STATUS_RETURN(m_am_tools, status); |
|
1449 } |
|
1450 } |
|
1451 } |
|
1452 |
|
1453 #endif //#ifndef USE_EAP_EXPANDED_TYPES |
|
1454 |
|
1455 //---------------------------------------------------------- |
|
1456 |
|
1457 { |
|
1458 eap_variable_data_c use_manual_username(m_am_tools); |
|
1459 |
|
1460 eap_status_e status = type_configure_read( |
|
1461 cf_str_EAP_TLS_PEAP_use_manual_username.get_field(), |
|
1462 &use_manual_username); |
|
1463 if (status == eap_status_ok |
|
1464 && use_manual_username.get_is_valid_data() == true |
|
1465 && use_manual_username.get_data_length() == sizeof(u32_t) |
|
1466 && use_manual_username.get_data(sizeof(u32_t)) != 0) |
|
1467 { |
|
1468 // OK |
|
1469 // This is optional value. |
|
1470 if (*(reinterpret_cast<u32_t *>(use_manual_username.get_data(sizeof(u32_t)))) == 1) |
|
1471 { |
|
1472 m_use_manual_username = true; |
|
1473 } |
|
1474 else |
|
1475 { |
|
1476 m_use_manual_username = false; |
|
1477 } |
|
1478 } |
|
1479 } |
|
1480 |
|
1481 //---------------------------------------------------------- |
|
1482 |
|
1483 { |
|
1484 (void) type_configure_read( |
|
1485 cf_str_EAP_TLS_PEAP_manual_username.get_field(), |
|
1486 &m_manual_username); |
|
1487 // return value ignored on purpose (optional parameter) |
|
1488 } |
|
1489 |
|
1490 //---------------------------------------------------------- |
|
1491 |
|
1492 { |
|
1493 eap_variable_data_c use_manual_realm(m_am_tools); |
|
1494 |
|
1495 eap_status_e status = type_configure_read( |
|
1496 cf_str_EAP_TLS_PEAP_use_manual_realm.get_field(), |
|
1497 &use_manual_realm); |
|
1498 if (status == eap_status_ok |
|
1499 && use_manual_realm.get_is_valid_data() == true |
|
1500 && use_manual_realm.get_data_length() == sizeof(u32_t) |
|
1501 && use_manual_realm.get_data(sizeof(u32_t)) != 0) |
|
1502 { |
|
1503 // OK |
|
1504 // This is optional value. |
|
1505 if (*(reinterpret_cast<u32_t *>( |
|
1506 use_manual_realm.get_data(sizeof(u32_t)))) == 1) |
|
1507 { |
|
1508 m_use_manual_realm = true; |
|
1509 } |
|
1510 else |
|
1511 { |
|
1512 m_use_manual_realm = false; |
|
1513 } |
|
1514 } |
|
1515 } |
|
1516 |
|
1517 //---------------------------------------------------------- |
|
1518 |
|
1519 { |
|
1520 (void) type_configure_read( |
|
1521 cf_str_EAP_TLS_PEAP_manual_realm.get_field(), |
|
1522 &m_manual_realm); |
|
1523 // return value ignored on purpose (optional parameter) |
|
1524 } |
|
1525 |
|
1526 //---------------------------------------------------------- |
|
1527 |
|
1528 #if defined(USE_EAP_TLS_SESSION_TICKET) |
|
1529 { |
|
1530 eap_variable_data_c use_session_ticket(m_am_tools); |
|
1531 |
|
1532 eap_status_e status = m_partner->read_configure( |
|
1533 cf_str_EAP_TLS_PEAP_use_session_ticket.get_field(), |
|
1534 &use_session_ticket); |
|
1535 if (status == eap_status_ok |
|
1536 && use_session_ticket.get_is_valid_data() == true) |
|
1537 { |
|
1538 u32_t *use_manual_realm_flag = reinterpret_cast<u32_t *>( |
|
1539 use_session_ticket.get_data(sizeof(u32_t))); |
|
1540 if (use_manual_realm_flag != 0 |
|
1541 && *use_manual_realm_flag != 0) |
|
1542 { |
|
1543 m_use_session_ticket = true; |
|
1544 } |
|
1545 } |
|
1546 } |
|
1547 #endif //#if defined(USE_EAP_TLS_SESSION_TICKET) |
|
1548 |
|
1549 //---------------------------------------------------------- |
|
1550 |
|
1551 if (m_current_eap_type == eap_type_peap |
|
1552 #if defined(USE_TTLS_EAP_TYPE) |
|
1553 || m_current_eap_type == eap_type_ttls |
|
1554 #endif // #if defined(USE_TTLS_EAP_TYPE) |
|
1555 |
|
1556 #if defined(USE_FAST_EAP_TYPE) |
|
1557 || m_current_eap_type == eap_type_fast |
|
1558 #endif |
|
1559 |
|
1560 ) |
|
1561 { |
|
1562 m_tls_peap_server_authenticates_client_policy_flag = false; |
|
1563 } |
|
1564 |
|
1565 //---------------------------------------------------------- |
|
1566 |
|
1567 { |
|
1568 eap_variable_data_c server_authenticates_client(m_am_tools); |
|
1569 |
|
1570 status = type_configure_read( |
|
1571 cf_str_TLS_server_authenticates_client_policy_in_client.get_field(), |
|
1572 &server_authenticates_client); |
|
1573 if (status == eap_status_ok |
|
1574 && server_authenticates_client.get_is_valid_data() == true |
|
1575 && server_authenticates_client.get_data_length() == sizeof(u32_t) |
|
1576 && server_authenticates_client.get_data(sizeof(u32_t)) != 0) |
|
1577 { |
|
1578 // This is optional value. |
|
1579 u32_t *flag = reinterpret_cast<u32_t *>( |
|
1580 server_authenticates_client.get_data(sizeof(u32_t))); |
|
1581 if (flag != 0) |
|
1582 { |
|
1583 if (*flag == 0) |
|
1584 { |
|
1585 m_tls_peap_server_authenticates_client_policy_flag = false; |
|
1586 } |
|
1587 else |
|
1588 { |
|
1589 m_tls_peap_server_authenticates_client_policy_flag = true; |
|
1590 } |
|
1591 } |
|
1592 } |
|
1593 } |
|
1594 |
|
1595 //---------------------------------------------------------- |
|
1596 |
|
1597 { |
|
1598 // Read Maximum Session Validity Time from the config file |
|
1599 eap_variable_data_c sessionTimeFromFile(m_am_tools); |
|
1600 |
|
1601 eap_status_e status(eap_status_ok); |
|
1602 |
|
1603 switch (m_current_eap_vendor_type) |
|
1604 { |
|
1605 case eap_type_tls: |
|
1606 { |
|
1607 status = m_partner->read_configure( |
|
1608 cf_str_EAP_TLS_max_session_validity_time.get_field(), |
|
1609 &sessionTimeFromFile); |
|
1610 } |
|
1611 break; |
|
1612 |
|
1613 case eap_type_peap: |
|
1614 { |
|
1615 status = m_partner->read_configure( |
|
1616 cf_str_EAP_PEAP_max_session_validity_time.get_field(), |
|
1617 &sessionTimeFromFile); |
|
1618 } |
|
1619 break; |
|
1620 |
|
1621 case eap_type_ttls: |
|
1622 { |
|
1623 status = m_partner->read_configure( |
|
1624 cf_str_EAP_TTLS_max_session_validity_time.get_field(), |
|
1625 &sessionTimeFromFile); |
|
1626 } |
|
1627 break; |
|
1628 |
|
1629 case eap_type_ttls_plain_pap: |
|
1630 { |
|
1631 // read PAP session time |
|
1632 status = m_partner->read_configure( |
|
1633 cf_str_EAP_TLS_PEAP_ttls_pap_max_session_validity_time.get_field(), |
|
1634 &sessionTimeFromFile ); |
|
1635 } |
|
1636 break; |
|
1637 |
|
1638 #if defined(USE_FAST_EAP_TYPE) |
|
1639 case eap_type_fast: |
|
1640 { |
|
1641 status = m_partner->read_configure( |
|
1642 cf_str_EAP_FAST_max_session_validity_time.get_field(), |
|
1643 &sessionTimeFromFile); |
|
1644 } |
|
1645 break; |
|
1646 #endif |
|
1647 |
|
1648 default: |
|
1649 { |
|
1650 // Should never happen |
|
1651 EAP_TRACE_ERROR(m_am_tools, |
|
1652 TRACE_FLAGS_DEFAULT, ( |
|
1653 EAPL("eap_am_type_tls_peap_symbian_c::configure - Unsupported EAP type, m_current_eap_vendor_type=%d \n"), |
|
1654 m_current_eap_vendor_type)); |
|
1655 } |
|
1656 } |
|
1657 |
|
1658 // set m_max_session_time |
|
1659 if (status == eap_status_ok |
|
1660 && sessionTimeFromFile.get_is_valid_data() == true |
|
1661 && sessionTimeFromFile.get_data_length() == sizeof(u32_t)) |
|
1662 { |
|
1663 u32_t *session = reinterpret_cast<u32_t *>(sessionTimeFromFile.get_data()); |
|
1664 if (session != 0) |
|
1665 { |
|
1666 // Update the max session time (in micro seconds). |
|
1667 // configuration file saves the time in seconds. We have to convert it to micro seconds. |
|
1668 m_max_session_time = static_cast<TInt64>(*session) * static_cast<TInt64>(KMicroSecsInASecond); |
|
1669 } |
|
1670 } |
|
1671 // set max session time for protocol in tunnel; |
|
1672 // currently for PAP |
|
1673 if ( status == eap_status_ok && |
|
1674 sessionTimeFromFile.get_is_valid_data() == true && |
|
1675 sessionTimeFromFile.get_data_length() == sizeof( u32_t ) ) |
|
1676 |
|
1677 { |
|
1678 u32_t* session = reinterpret_cast<u32_t*>( sessionTimeFromFile.get_data() ); |
|
1679 if ( session != 0 ) |
|
1680 { |
|
1681 // Update the max session time (in micro seconds). |
|
1682 // configuration file saves the time in seconds. |
|
1683 // We have to convert it to micro seconds. |
|
1684 iEapTtlsPapMaxSessionConfigTime = static_cast<TInt64> |
|
1685 ( *session ) * static_cast<TInt64>( KMicroSecsInASecond ); |
|
1686 } |
|
1687 } |
|
1688 } |
|
1689 |
|
1690 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
|
1691 |
|
1692 #if defined(USE_FAST_EAP_TYPE) |
|
1693 |
|
1694 // Read UnAuthenticated provisioning mode from database. |
|
1695 // We need this only for EAP-FAST |
|
1696 |
|
1697 if(m_current_eap_type == eap_type_fast) |
|
1698 { |
|
1699 //---------------------------------------------------------- |
|
1700 { |
|
1701 eap_variable_data_c allow_serv_unauth_prov_mode(m_am_tools); |
|
1702 |
|
1703 eap_status_e status = type_configure_read( |
|
1704 cf_str_EAP_FAST_allow_server_unauthenticated_provisioning_mode_ADHP.get_field(), |
|
1705 &allow_serv_unauth_prov_mode); |
|
1706 if (status == eap_status_ok |
|
1707 && allow_serv_unauth_prov_mode.get_is_valid_data() == true |
|
1708 && allow_serv_unauth_prov_mode.get_data_length() == sizeof(u32_t) |
|
1709 && allow_serv_unauth_prov_mode.get_data(sizeof(u32_t)) != 0) |
|
1710 { |
|
1711 // OK |
|
1712 if (*(reinterpret_cast<u32_t *>( |
|
1713 allow_serv_unauth_prov_mode.get_data(sizeof(u32_t)))) == 1) |
|
1714 { |
|
1715 m_serv_unauth_prov_mode = true; |
|
1716 } |
|
1717 else |
|
1718 { |
|
1719 m_serv_unauth_prov_mode = false; |
|
1720 } |
|
1721 } |
|
1722 } |
|
1723 //---------------------------------------------------------- |
|
1724 { |
|
1725 eap_variable_data_c allow_serv_auth_prov_mode(m_am_tools); |
|
1726 |
|
1727 eap_status_e status = type_configure_read( |
|
1728 cf_str_EAP_FAST_allow_server_authenticated_provisioning_mode.get_field(), |
|
1729 &allow_serv_auth_prov_mode); |
|
1730 if (status == eap_status_ok |
|
1731 && allow_serv_auth_prov_mode.get_is_valid_data() == true |
|
1732 && allow_serv_auth_prov_mode.get_data_length() == sizeof(u32_t) |
|
1733 && allow_serv_auth_prov_mode.get_data(sizeof(u32_t)) != 0) |
|
1734 { |
|
1735 // OK |
|
1736 if (*(reinterpret_cast<u32_t *>( |
|
1737 allow_serv_auth_prov_mode.get_data(sizeof(u32_t)))) == 1) |
|
1738 { |
|
1739 m_serv_auth_prov_mode = true; |
|
1740 } |
|
1741 else |
|
1742 { |
|
1743 m_serv_auth_prov_mode = false; |
|
1744 } |
|
1745 } |
|
1746 } |
|
1747 //---------------------------------------------------------- |
|
1748 |
|
1749 } // End: if(m_current_eap_type == eap_type_fast) |
|
1750 |
|
1751 #endif // #if defined(USE_FAST_EAP_TYPE) |
|
1752 |
|
1753 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
|
1754 |
|
1755 status = eap_status_ok; |
|
1756 |
|
1757 if (m_allowed_ca_certs.Count() == 0) |
|
1758 { |
|
1759 // needed because of nonworking wrong settings |
|
1760 #if defined(USE_FAST_EAP_TYPE) |
|
1761 if(m_current_eap_type == eap_type_fast && |
|
1762 m_serv_auth_prov_mode != true) |
|
1763 { |
|
1764 // In the case of EAP-FAST, CA cert is must if m_serv_auth_prov_mode is TRUE. |
|
1765 status = eap_status_ok; |
|
1766 |
|
1767 EAP_TRACE_DEBUG(m_am_tools, |
|
1768 TRACE_FLAGS_DEFAULT, ( |
|
1769 EAPL("eap_am_type_tls_peap_symbian_c::configure - No CA certificate but exception for EAP-FAST as m_serv_auth_prov_mode is FALSE and for all m_serv_unauth_prov_mode \n"))); |
|
1770 } |
|
1771 else |
|
1772 #endif // #if defined(USE_FAST_EAP_TYPE) |
|
1773 { |
|
1774 EAP_TRACE_ERROR(m_am_tools, |
|
1775 TRACE_FLAGS_DEFAULT, ( |
|
1776 EAPL("eap_am_type_tls_peap_symbian_c::configure - Error - No CA certificate\n"))); |
|
1777 |
|
1778 // No root certificate selected. Cannot continue. |
|
1779 status = eap_status_ca_certificate_unknown; |
|
1780 send_error_notification(status); |
|
1781 } |
|
1782 } |
|
1783 |
|
1784 if(m_allowed_user_certs.Count() == 0) |
|
1785 { |
|
1786 #if defined(USE_FAST_EAP_TYPE) |
|
1787 if(m_current_eap_type == eap_type_fast) |
|
1788 { |
|
1789 m_use_manual_realm = true; |
|
1790 |
|
1791 if (m_use_manual_username == false) |
|
1792 { |
|
1793 TRAPD(err, status=ConfigureL()); |
|
1794 if (err != KErrNone) |
|
1795 { |
|
1796 EAP_TRACE_ERROR(m_am_tools, |
|
1797 TRACE_FLAGS_DEFAULT, ( |
|
1798 EAPL("eap_am_type_tls_peap_symbian_c::configure LEAVE from ConfigureL, Error =%d \n"), |
|
1799 err)); |
|
1800 } |
|
1801 } |
|
1802 } |
|
1803 #endif // #if defined(USE_FAST_EAP_TYPE) |
|
1804 } |
|
1805 if (m_tls_peap_server_authenticates_client_policy_flag == true |
|
1806 && m_allowed_user_certs.Count() == 0) |
|
1807 { |
|
1808 #if defined(USE_FAST_EAP_TYPE) |
|
1809 if (m_current_eap_type == eap_type_fast) |
|
1810 { |
|
1811 EAP_TRACE_DEBUG(m_am_tools, |
|
1812 TRACE_FLAGS_DEFAULT, |
|
1813 (EAPL("eap_am_type_tls_peap_symbian_c::configure - No USER certificate, but in eap_fast it's not mandatory\n"))); |
|
1814 |
|
1815 } |
|
1816 else |
|
1817 #endif // #if defined(USE_FAST_EAP_TYPE) |
|
1818 { |
|
1819 EAP_TRACE_ERROR(m_am_tools, |
|
1820 TRACE_FLAGS_DEFAULT, ( |
|
1821 EAPL("eap_am_type_tls_peap_symbian_c::configure - Error - No USER certificate\n"))); |
|
1822 |
|
1823 // No user certificate selected. Cannot continue. |
|
1824 status = eap_status_user_certificate_unknown; |
|
1825 send_error_notification(status); |
|
1826 } |
|
1827 } |
|
1828 |
|
1829 if (m_allowed_cipher_suites.Count() == 0) |
|
1830 { |
|
1831 EAP_TRACE_ERROR(m_am_tools, |
|
1832 TRACE_FLAGS_DEFAULT, ( |
|
1833 EAPL("eap_am_type_tls_peap_symbian_c::configure - Error - No cipher suit\n"))); |
|
1834 |
|
1835 // No sipher suites selected. Cannot continue. |
|
1836 status = eap_status_illegal_cipher_suite; |
|
1837 send_error_notification(status); |
|
1838 } |
|
1839 |
|
1840 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
|
1841 |
|
1842 if (status != eap_status_ok) |
|
1843 { |
|
1844 notify_configuration_error(status); |
|
1845 } |
|
1846 |
|
1847 m_configured = true; |
|
1848 |
|
1849 EAP_TRACE_DEBUG(m_am_tools, |
|
1850 TRACE_FLAGS_DEFAULT, |
|
1851 (EAPL("eap_am_type_tls_peap_symbian_c::configure - END \n"))); |
|
1852 |
|
1853 |
|
1854 return EAP_STATUS_RETURN(m_am_tools, status); |
|
1855 } |
|
1856 |
|
1857 //-------------------------------------------------- |
|
1858 #if defined(USE_FAST_EAP_TYPE) |
|
1859 |
|
1860 eap_status_e eap_am_type_tls_peap_symbian_c::ConfigureL() |
|
1861 { |
|
1862 |
|
1863 eap_status_e status(eap_status_ok); |
|
1864 |
|
1865 _LIT(KTempUserName, "EAP-FAST-"); |
|
1866 TBuf8<10> TempUserName; |
|
1867 |
|
1868 TempUserName.Copy(KTempUserName); |
|
1869 |
|
1870 HBufC8* buf = HBufC8::NewLC(KIdentityFieldLength); |
|
1871 TPtr8 bufPtr = buf->Des(); |
|
1872 |
|
1873 HBufC8* tempUserBuf8 = HBufC8::NewLC(KMacAddressLength); |
|
1874 TPtr8 tempUserBufPtr8 = tempUserBuf8->Des(); |
|
1875 |
|
1876 HBufC8* ConvertedtempUserBuf8 = HBufC8::NewLC(KMacAddressLength*2); |
|
1877 TPtr8 ConvertedtempUserBufPtr8 = ConvertedtempUserBuf8->Des(); |
|
1878 |
|
1879 if (m_receive_network_id.get_destination_length()>0) |
|
1880 { |
|
1881 tempUserBufPtr8.Copy(m_receive_network_id.get_destination(), m_receive_network_id.get_destination_length()); |
|
1882 |
|
1883 u32_t toBinaryPtr8SizeForTools = static_cast<u32_t>(KMacAddressLength*2); |
|
1884 u32_t fromTextPtr8SizeForTools = static_cast<u32_t>(tempUserBufPtr8.Size()); |
|
1885 |
|
1886 u8_t * toBinaryPtr8ForTools = const_cast<u8_t *>(ConvertedtempUserBuf8->Ptr()); |
|
1887 |
|
1888 EAP_TRACE_DEBUG_SYMBIAN( |
|
1889 (_L("eap_am_type_tls_peap_symbian_c::configure,Call convert_bytes_to_hex_ascii, toBinaryPtr8SizeForTools=%d"), |
|
1890 toBinaryPtr8SizeForTools)); |
|
1891 |
|
1892 // Convert hex to ascii string. |
|
1893 status = m_am_tools->convert_bytes_to_hex_ascii( |
|
1894 tempUserBufPtr8.Ptr(), |
|
1895 fromTextPtr8SizeForTools, |
|
1896 toBinaryPtr8ForTools, |
|
1897 &toBinaryPtr8SizeForTools); |
|
1898 |
|
1899 if(status != eap_status_ok) |
|
1900 { |
|
1901 EAP_TRACE_DEBUG_SYMBIAN( |
|
1902 (_L("eap_am_type_tls_peap_symbian_c::configure, Error in convert_hex_ascii_to_bytes. status=%d"), |
|
1903 status)); |
|
1904 |
|
1905 User::Leave(m_am_tools->convert_eapol_error_to_am_error(status)); |
|
1906 } |
|
1907 |
|
1908 ConvertedtempUserBufPtr8.SetLength(KMacAddressLength*2); |
|
1909 |
|
1910 EAP_TRACE_DATA_DEBUG( |
|
1911 m_am_tools, |
|
1912 TRACE_FLAGS_DEFAULT, |
|
1913 (EAPL("MAC"), |
|
1914 ConvertedtempUserBuf8->Ptr(), |
|
1915 ConvertedtempUserBuf8->Size())); |
|
1916 |
|
1917 EAP_TRACE_DEBUG( |
|
1918 m_am_tools, |
|
1919 TRACE_FLAGS_DEFAULT, |
|
1920 (EAPL("eap_am_type_tls_peap_symbian_c::config: user size = %d, MAC size= %d \n"), |
|
1921 TempUserName.Size(), ConvertedtempUserBuf8->Size())); |
|
1922 |
|
1923 bufPtr.Append(TempUserName.Ptr(), TempUserName.Size()); |
|
1924 bufPtr.Append(ConvertedtempUserBuf8->Ptr(),ConvertedtempUserBuf8->Size()); |
|
1925 |
|
1926 EAP_TRACE_DATA_DEBUG( |
|
1927 m_am_tools, |
|
1928 TRACE_FLAGS_DEFAULT, |
|
1929 (EAPL("UserName"), |
|
1930 bufPtr.Ptr(), |
|
1931 bufPtr.Size())); |
|
1932 |
|
1933 status = m_manual_username.set_copy_of_buffer( |
|
1934 bufPtr.Ptr(), |
|
1935 bufPtr.Size()); |
|
1936 } |
|
1937 EAP_TRACE_DEBUG( |
|
1938 m_am_tools, |
|
1939 TRACE_FLAGS_DEFAULT, |
|
1940 (EAPL("eap_am_type_tls_peap_symbian_c::config: UserName = %s \n"), |
|
1941 bufPtr.Ptr(), bufPtr.Size())); |
|
1942 |
|
1943 CleanupStack::PopAndDestroy(ConvertedtempUserBuf8); |
|
1944 CleanupStack::PopAndDestroy(tempUserBuf8); |
|
1945 CleanupStack::PopAndDestroy(buf); |
|
1946 |
|
1947 m_use_manual_username = true; |
|
1948 |
|
1949 return status; |
|
1950 } |
|
1951 |
|
1952 #endif // #if defined(USE_FAST_EAP_TYPE) |
|
1953 |
|
1954 //-------------------------------------------------- |
|
1955 |
|
1956 eap_status_e eap_am_type_tls_peap_symbian_c::reset() |
|
1957 { |
|
1958 |
|
1959 return EAP_STATUS_RETURN(m_am_tools, eap_status_ok); |
|
1960 } |
|
1961 |
|
1962 //-------------------------------------------------- |
|
1963 |
|
1964 // |
|
1965 |
|
1966 EAP_FUNC_EXPORT eap_status_e eap_am_type_tls_peap_symbian_c::authentication_finished( |
|
1967 const bool true_when_successful, |
|
1968 const tls_session_type_e tls_session_type) |
|
1969 { |
|
1970 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
1971 |
|
1972 eap_status_e status(eap_status_ok); |
|
1973 |
|
1974 TRAPD(err, authentication_finishedL(true_when_successful, tls_session_type)); |
|
1975 if (err != KErrNone) |
|
1976 { |
|
1977 EAP_TRACE_DEBUG(m_am_tools, |
|
1978 TRACE_FLAGS_DEFAULT, |
|
1979 (EAPL("eap_am_type_tls_peap_symbian_c::authentication_finished, TRAP ERROR=%d\n"), |
|
1980 err)); |
|
1981 |
|
1982 status = m_am_tools->convert_am_error_to_eapol_error(err); |
|
1983 send_error_notification(status); |
|
1984 } |
|
1985 |
|
1986 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
1987 return EAP_STATUS_RETURN(m_am_tools, status); |
|
1988 } |
|
1989 |
|
1990 void eap_am_type_tls_peap_symbian_c::authentication_finishedL( |
|
1991 const bool true_when_successful, |
|
1992 const tls_session_type_e tls_session_type) |
|
1993 { |
|
1994 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
1995 |
|
1996 if (m_is_client == false) |
|
1997 { |
|
1998 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
1999 return; |
|
2000 } |
|
2001 |
|
2002 // In EAP-FAST this could be called when provisioning is successfull. |
|
2003 // If there was provisioning, We have to toggle |
|
2004 // cf_str_EAP_FAST_allow_server_unauthenticated_provisioning_mode_ADHP_literal |
|
2005 |
|
2006 #if defined(USE_FAST_EAP_TYPE) |
|
2007 |
|
2008 if(m_current_eap_type == eap_type_fast && |
|
2009 m_serv_unauth_prov_mode == true) |
|
2010 { |
|
2011 EAP_TRACE_DEBUG_SYMBIAN( |
|
2012 (_L("eap_am_type_tls_peap_symbian_c::authentication_finishedL EAP-FAST Provisioning!"))); |
|
2013 |
|
2014 eap_variable_data_c unauthProvMode(m_am_tools); |
|
2015 unauthProvMode.set_copy_of_buffer( |
|
2016 &default_EAP_FAST_Unauth_Prov_Mode_Allowed, |
|
2017 sizeof(default_EAP_FAST_Unauth_Prov_Mode_Allowed)); |
|
2018 |
|
2019 EapTlsPeapUtils::SetEapSettingsDataL( |
|
2020 m_database, |
|
2021 m_index_type, |
|
2022 m_index, |
|
2023 m_tunneling_type, |
|
2024 m_current_eap_type, |
|
2025 cf_str_EAP_FAST_allow_server_unauthenticated_provisioning_mode_ADHP_literal, |
|
2026 &unauthProvMode); |
|
2027 |
|
2028 EAP_TRACE_DEBUG_SYMBIAN( |
|
2029 (_L("eap_am_type_tls_peap_symbian_c::authentication_finishedL Unauth Prov mode set to default (NO)!"))); |
|
2030 } |
|
2031 #endif |
|
2032 |
|
2033 // Store the authentication time if the full authentication is successful |
|
2034 if (true_when_successful == true |
|
2035 && tls_session_type == tls_session_type_full_authentication) |
|
2036 { |
|
2037 store_authentication_timeL(); |
|
2038 } |
|
2039 |
|
2040 if (m_latest_alert_description == tls_alert_description_certificate_expired) |
|
2041 { |
|
2042 send_error_notification(eap_status_certificate_expired); |
|
2043 } |
|
2044 else if (m_latest_alert_description == tls_alert_description_bad_certificate) |
|
2045 { |
|
2046 send_error_notification(eap_status_bad_certificate); |
|
2047 } |
|
2048 else if (m_latest_alert_description == tls_alert_description_unsupported_certificate) |
|
2049 { |
|
2050 send_error_notification(eap_status_unsupported_certificate); |
|
2051 } |
|
2052 else if (m_latest_alert_description == tls_alert_description_certificate_revoked) |
|
2053 { |
|
2054 send_error_notification(eap_status_certificate_revoked); |
|
2055 } |
|
2056 else if (m_latest_alert_description == tls_alert_description_certificate_unknown) |
|
2057 { |
|
2058 send_error_notification(eap_status_user_certificate_unknown); |
|
2059 } |
|
2060 else if(m_latest_alert_description != tls_alert_description_none) |
|
2061 { |
|
2062 // Send error notification any alert other than tls_alert_description_none. |
|
2063 send_error_notification(eap_status_process_general_error); |
|
2064 } |
|
2065 |
|
2066 if (true_when_successful == false) |
|
2067 { |
|
2068 ResetSessionIdL(); |
|
2069 } |
|
2070 |
|
2071 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
2072 } |
|
2073 |
|
2074 //-------------------------------------------------- |
|
2075 |
|
2076 EAP_FUNC_EXPORT eap_status_e eap_am_type_tls_peap_symbian_c::query_eap_identity( |
|
2077 eap_variable_data_c * const /*identity*/, |
|
2078 const eap_am_network_id_c * const /* receive_network_id */, |
|
2079 const u8_t eap_identifier, |
|
2080 bool * const /*use_manual_username*/, |
|
2081 eap_variable_data_c * const /*manual_username*/, |
|
2082 bool *const /*use_manual_realm*/, |
|
2083 eap_variable_data_c * const /*manual_realm*/) |
|
2084 { |
|
2085 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
2086 eap_status_e status(eap_status_pending_request); |
|
2087 |
|
2088 // Store parameters |
|
2089 m_eap_identifier = eap_identifier; |
|
2090 m_state = EHandlingIdentityQuery; |
|
2091 |
|
2092 // Get the own certificate only if it has already been retrieved |
|
2093 if (m_own_certificate == 0) |
|
2094 { |
|
2095 TRAPD(err, m_cert_if->GetMatchingCertificatesL( |
|
2096 m_allowed_user_certs, |
|
2097 EFalse, |
|
2098 0, |
|
2099 EFalse, |
|
2100 0, |
|
2101 ETrue, |
|
2102 m_allowed_cipher_suites)); |
|
2103 if (err != KErrNone) |
|
2104 { |
|
2105 status = m_am_tools->convert_am_error_to_eapol_error(err); |
|
2106 } |
|
2107 else |
|
2108 { |
|
2109 status = eap_status_pending_request; |
|
2110 } |
|
2111 } |
|
2112 else |
|
2113 { |
|
2114 RPointerArray<CX509Certificate> tmp; |
|
2115 if (tmp.Append(m_own_certificate) != KErrNone) |
|
2116 { |
|
2117 status = m_am_tools->convert_am_error_to_eapol_error(eap_status_allocation_error); |
|
2118 } |
|
2119 else |
|
2120 { |
|
2121 status = complete_read_own_certificate(tmp, eap_status_ok); |
|
2122 } |
|
2123 tmp.Reset(); |
|
2124 |
|
2125 } |
|
2126 |
|
2127 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
2128 return EAP_STATUS_RETURN(m_am_tools, status); |
|
2129 } |
|
2130 |
|
2131 |
|
2132 eap_status_e eap_am_type_tls_peap_symbian_c::complete_read_own_certificate( |
|
2133 const RPointerArray<CX509Certificate>& aCertChain, eap_status_e aStatus) |
|
2134 { |
|
2135 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
2136 eap_status_e status = eap_status_process_general_error; |
|
2137 |
|
2138 EAP_TRACE_DEBUG( |
|
2139 m_am_tools, |
|
2140 TRACE_FLAGS_DEFAULT, |
|
2141 (EAPL("eap_am_type_tls_peap_symbian_c::complete_read_own_certificate -start- cert chain count = %d, aStatus=%d\n"), |
|
2142 aCertChain.Count(), aStatus)); |
|
2143 |
|
2144 if (aStatus != eap_status_ok) |
|
2145 { |
|
2146 switch (m_state) |
|
2147 { |
|
2148 case EHandlingIdentityQuery: |
|
2149 |
|
2150 EAP_TRACE_DEBUG( |
|
2151 m_am_tools, |
|
2152 TRACE_FLAGS_DEFAULT, |
|
2153 (EAPL("ERROR: EAP-TLS: EHandlingIdentityQuery: Cannot read own certificate.\n"))); |
|
2154 |
|
2155 status = get_am_partner()->complete_eap_identity_query( |
|
2156 0, // 0 because identity query failed |
|
2157 &m_receive_network_id, |
|
2158 m_eap_identifier, |
|
2159 aStatus, |
|
2160 false, |
|
2161 0, |
|
2162 false, |
|
2163 0); |
|
2164 break; |
|
2165 |
|
2166 case EHandlingChainQuery: |
|
2167 status = get_tls_am_partner()->complete_query_certificate_chain(0, aStatus); |
|
2168 break; |
|
2169 |
|
2170 default: |
|
2171 // This should never happen |
|
2172 User::Panic(_L("EAPOL"), 1); |
|
2173 } |
|
2174 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
2175 return EAP_STATUS_RETURN(m_am_tools, status); |
|
2176 } |
|
2177 |
|
2178 // Handle errors - if certificate is 0 then an error has occurred. |
|
2179 if (aCertChain.Count() == 0) |
|
2180 { |
|
2181 switch (m_state) |
|
2182 { |
|
2183 case EHandlingIdentityQuery: |
|
2184 |
|
2185 EAP_TRACE_DEBUG( |
|
2186 m_am_tools, |
|
2187 TRACE_FLAGS_DEFAULT, |
|
2188 (EAPL("ERROR: Could not read own certificate.\n"))); |
|
2189 |
|
2190 status = get_am_partner()->complete_eap_identity_query( |
|
2191 0, // 0 because identity query failed |
|
2192 &m_receive_network_id, |
|
2193 m_eap_identifier, |
|
2194 eap_status_illegal_eap_identity, |
|
2195 false, |
|
2196 0, |
|
2197 false, |
|
2198 0); |
|
2199 break; |
|
2200 |
|
2201 case EHandlingChainQuery: |
|
2202 EAP_TRACE_ERROR(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("ERROR: Could not read own certificate.\n"))); |
|
2203 status = get_tls_am_partner()->complete_query_certificate_chain(0, eap_status_illegal_certificate); |
|
2204 break; |
|
2205 |
|
2206 default: |
|
2207 // This should never happen |
|
2208 User::Panic(_L("EAPOL"), 1); |
|
2209 } |
|
2210 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
2211 return EAP_STATUS_RETURN(m_am_tools, status); |
|
2212 } |
|
2213 |
|
2214 TBool aEqual = EFalse; |
|
2215 if (m_own_certificate != 0) |
|
2216 { |
|
2217 TRAPD(err1, aEqual = m_own_certificate->IsEqualL(*aCertChain[0])); |
|
2218 if (err1 != KErrNone) |
|
2219 { |
|
2220 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
2221 return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error); |
|
2222 } |
|
2223 } |
|
2224 |
|
2225 // Store certificate |
|
2226 if (m_own_certificate == 0 |
|
2227 || aEqual == EFalse) |
|
2228 { |
|
2229 delete m_own_certificate; |
|
2230 |
|
2231 // Create a copy of the certificate |
|
2232 TRAPD(err, m_own_certificate = CX509Certificate::NewL(*aCertChain[0])); |
|
2233 if (err != KErrNone) |
|
2234 { |
|
2235 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
2236 return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error); |
|
2237 } |
|
2238 } |
|
2239 |
|
2240 switch (m_state) |
|
2241 { |
|
2242 case EHandlingIdentityQuery: |
|
2243 { |
|
2244 eap_variable_data_c subjectIdentity(m_am_tools); |
|
2245 eap_variable_data_c IssuerIdentity(m_am_tools); |
|
2246 |
|
2247 TRAPD(err, get_identity_from_alternative_nameL(m_own_certificate, &subjectIdentity)); |
|
2248 if (err != KErrNone) |
|
2249 { |
|
2250 EAP_TRACE_DEBUG( |
|
2251 m_am_tools, |
|
2252 TRACE_FLAGS_DEFAULT, |
|
2253 (EAPL("Could not find identity in SubjectAltName field.\n"))); |
|
2254 |
|
2255 TRAPD(err, get_identities_from_distinguished_namesL(m_own_certificate, &subjectIdentity, &IssuerIdentity)); |
|
2256 if (err != KErrNone) |
|
2257 { |
|
2258 EAP_TRACE_DEBUG( |
|
2259 m_am_tools, |
|
2260 TRACE_FLAGS_DEFAULT, |
|
2261 (EAPL("ERROR: Could not find subject identity from certificate.\n"))); |
|
2262 |
|
2263 status = get_am_partner()->complete_eap_identity_query( |
|
2264 0, // 0 because identity query failed |
|
2265 &m_receive_network_id, |
|
2266 m_eap_identifier, |
|
2267 eap_status_illegal_eap_identity, |
|
2268 false, |
|
2269 0, |
|
2270 false, |
|
2271 0); |
|
2272 break; |
|
2273 } |
|
2274 else |
|
2275 { |
|
2276 EAP_TRACE_DEBUG( |
|
2277 m_am_tools, |
|
2278 TRACE_FLAGS_DEFAULT, |
|
2279 (EAPL("Found subject identity from certificate.\n"))); |
|
2280 } |
|
2281 } |
|
2282 else |
|
2283 { |
|
2284 EAP_TRACE_DEBUG( |
|
2285 m_am_tools, |
|
2286 TRACE_FLAGS_DEFAULT, |
|
2287 (EAPL("Found identity in SubjectAltName field.\n"))); |
|
2288 } |
|
2289 |
|
2290 // The completition function return a status value but there is no need to check them. |
|
2291 status = get_am_partner()->complete_eap_identity_query( |
|
2292 &subjectIdentity, |
|
2293 &m_receive_network_id, |
|
2294 m_eap_identifier, |
|
2295 eap_status_ok, |
|
2296 m_use_manual_username, |
|
2297 &m_manual_username, |
|
2298 m_use_manual_realm, |
|
2299 &m_manual_realm); |
|
2300 if (status == eap_status_ok |
|
2301 || status == eap_status_pending_request) |
|
2302 { |
|
2303 status = eap_status_completed_request; |
|
2304 } |
|
2305 } |
|
2306 break; |
|
2307 case EHandlingChainQuery: |
|
2308 { |
|
2309 eap_array_c<eap_variable_data_c> chain(m_am_tools); |
|
2310 |
|
2311 // Check if the certificate cipher suite is correct |
|
2312 const CSubjectPublicKeyInfo& pubkey = m_own_certificate->PublicKey(); |
|
2313 TAlgorithmId algorithm = pubkey.AlgorithmId(); |
|
2314 |
|
2315 if (EapTlsPeapUtils::CipherSuiteUseRSAKeys(m_cipher_suite) |
|
2316 && algorithm != ERSA) |
|
2317 { |
|
2318 EAP_TRACE_DEBUG( |
|
2319 m_am_tools, |
|
2320 TRACE_FLAGS_DEFAULT, |
|
2321 (EAPL("ERROR: Tried to use DSA certificate with RSA cipher suite.\n"))); |
|
2322 |
|
2323 send_error_notification(eap_status_illegal_cipher_suite); |
|
2324 |
|
2325 status = get_tls_am_partner()->complete_query_certificate_chain(0, eap_status_illegal_cipher_suite); |
|
2326 |
|
2327 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
2328 return EAP_STATUS_RETURN(m_am_tools, status); |
|
2329 } |
|
2330 |
|
2331 if (EapTlsPeapUtils::CipherSuiteUseDSAKeys(m_cipher_suite) |
|
2332 && algorithm != EDSA) |
|
2333 { |
|
2334 EAP_TRACE_DEBUG( |
|
2335 m_am_tools, |
|
2336 TRACE_FLAGS_DEFAULT, |
|
2337 (EAPL("ERROR: Tried to use RSA certificate with DSS cipher suite.\n"))); |
|
2338 |
|
2339 send_error_notification(eap_status_illegal_cipher_suite); |
|
2340 |
|
2341 status = get_tls_am_partner()->complete_query_certificate_chain(0, eap_status_illegal_cipher_suite); |
|
2342 |
|
2343 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
2344 return EAP_STATUS_RETURN(m_am_tools, status); |
|
2345 } |
|
2346 |
|
2347 // Add the chain certificates to eap_array_c |
|
2348 TInt i(0); |
|
2349 for (i = 0; i < aCertChain.Count(); i++) |
|
2350 { |
|
2351 eap_variable_data_c * cert = new eap_variable_data_c(m_am_tools); |
|
2352 if (cert == 0) |
|
2353 { |
|
2354 status = get_tls_am_partner()->complete_query_certificate_chain(0, eap_status_allocation_error); |
|
2355 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
2356 return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error); |
|
2357 } |
|
2358 |
|
2359 status = cert->set_buffer( |
|
2360 aCertChain[i]->Encoding().Ptr(), |
|
2361 aCertChain[i]->Encoding().Size(), |
|
2362 false, |
|
2363 false); |
|
2364 if (status != eap_status_ok) |
|
2365 { |
|
2366 delete cert; |
|
2367 status = get_tls_am_partner()->complete_query_certificate_chain(0, eap_status_process_general_error); |
|
2368 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
2369 return EAP_STATUS_RETURN(m_am_tools, status); |
|
2370 } |
|
2371 status = chain.add_object(cert, true); |
|
2372 if (status != eap_status_ok) |
|
2373 { |
|
2374 status = get_tls_am_partner()->complete_query_certificate_chain(0, eap_status_allocation_error); |
|
2375 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
2376 return EAP_STATUS_RETURN(m_am_tools, status); |
|
2377 } |
|
2378 } |
|
2379 // Complete query |
|
2380 status = get_tls_am_partner()->complete_query_certificate_chain(&chain, eap_status_ok); |
|
2381 } |
|
2382 break; |
|
2383 |
|
2384 default: |
|
2385 // This should never happen |
|
2386 User::Panic(_L("EAPOL"), 1); |
|
2387 } |
|
2388 |
|
2389 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
2390 return EAP_STATUS_RETURN(m_am_tools, status); |
|
2391 } |
|
2392 |
|
2393 eap_status_e eap_am_type_tls_peap_symbian_c::complete_read_ca_certificate( |
|
2394 const RPointerArray<CX509Certificate>& aCertChain, eap_status_e aStatus) |
|
2395 { |
|
2396 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
2397 |
|
2398 EAP_TRACE_DEBUG( |
|
2399 m_am_tools, |
|
2400 TRACE_FLAGS_DEFAULT, |
|
2401 (EAPL("eap_am_type_tls_peap_symbian_c::complete_read_ca_certificate. Cert Chain count=%d, aStatus=%d\n"), |
|
2402 aCertChain.Count(), aStatus)); |
|
2403 |
|
2404 if (aStatus != eap_status_ok) |
|
2405 { |
|
2406 switch (m_state) |
|
2407 { |
|
2408 case EHandlingIdentityQuery: |
|
2409 |
|
2410 EAP_TRACE_DEBUG( |
|
2411 m_am_tools, |
|
2412 TRACE_FLAGS_DEFAULT, |
|
2413 (EAPL("ERROR: Could not CA certificate.\n"))); |
|
2414 |
|
2415 get_am_partner()->complete_eap_identity_query( |
|
2416 0, // 0 because identity query failed |
|
2417 &m_receive_network_id, |
|
2418 m_eap_identifier, |
|
2419 aStatus, |
|
2420 false, |
|
2421 0, |
|
2422 false, |
|
2423 0); |
|
2424 |
|
2425 break; |
|
2426 |
|
2427 case EHandlingCipherSuiteQuery: |
|
2428 get_tls_am_partner()->complete_query_certificate_chain(0, aStatus); |
|
2429 break; |
|
2430 |
|
2431 default: |
|
2432 // This should never happen |
|
2433 User::Panic(_L("EAPOL"), 1); |
|
2434 } |
|
2435 |
|
2436 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
2437 return EAP_STATUS_RETURN(m_am_tools, eap_status_process_general_error); |
|
2438 } |
|
2439 |
|
2440 // Check the error case first |
|
2441 if (aCertChain.Count() == 0) |
|
2442 { |
|
2443 switch (m_state) |
|
2444 { |
|
2445 case EHandlingIdentityQuery: |
|
2446 |
|
2447 EAP_TRACE_DEBUG( |
|
2448 m_am_tools, |
|
2449 TRACE_FLAGS_DEFAULT, |
|
2450 (EAPL("ERROR: Could not read ca certificate.\n"))); |
|
2451 |
|
2452 get_am_partner()->complete_eap_identity_query( |
|
2453 0, // 0 because identity query failed |
|
2454 &m_receive_network_id, |
|
2455 m_eap_identifier, |
|
2456 eap_status_illegal_eap_identity, |
|
2457 false, |
|
2458 0, |
|
2459 false, |
|
2460 0); |
|
2461 |
|
2462 break; |
|
2463 |
|
2464 case EHandlingCipherSuiteQuery: |
|
2465 EAP_TRACE_DEBUG( |
|
2466 m_am_tools, |
|
2467 TRACE_FLAGS_DEFAULT, |
|
2468 (EAPL("ERROR: Could not read own certificate.\n"))); |
|
2469 get_tls_am_partner()->complete_query_certificate_chain(0, eap_status_illegal_certificate); |
|
2470 break; |
|
2471 |
|
2472 default: |
|
2473 // This should never happen |
|
2474 User::Panic(_L("EAPOL"), 1); |
|
2475 } |
|
2476 |
|
2477 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
2478 return EAP_STATUS_RETURN(m_am_tools, eap_status_process_general_error); |
|
2479 } |
|
2480 |
|
2481 // Store certificate |
|
2482 TBool aEqual = EFalse; |
|
2483 if (m_ca_certificate != 0) |
|
2484 { |
|
2485 TRAPD(err1, aEqual = m_ca_certificate->IsEqualL(*aCertChain[0])); |
|
2486 if (err1 != KErrNone) |
|
2487 { |
|
2488 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
2489 return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error); |
|
2490 } |
|
2491 } |
|
2492 |
|
2493 if (m_ca_certificate == 0 |
|
2494 || aEqual == EFalse) |
|
2495 { |
|
2496 delete m_ca_certificate; |
|
2497 |
|
2498 // Create a copy of the certificate |
|
2499 TRAPD(err, m_ca_certificate = CX509Certificate::NewL(*aCertChain[0])); |
|
2500 if (err != KErrNone) |
|
2501 { |
|
2502 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
2503 return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error); |
|
2504 } |
|
2505 } |
|
2506 |
|
2507 |
|
2508 switch (m_state) |
|
2509 { |
|
2510 case EHandlingIdentityQuery: |
|
2511 { |
|
2512 |
|
2513 // Get the realm from the CA certificate |
|
2514 eap_variable_data_c tmp(m_am_tools); |
|
2515 |
|
2516 eap_status_e status = get_realms_from_certificate( |
|
2517 m_ca_certificate, |
|
2518 &m_manual_realm, |
|
2519 &tmp); |
|
2520 if (status != eap_status_ok) |
|
2521 { |
|
2522 EAP_TRACE_DEBUG( |
|
2523 m_am_tools, |
|
2524 TRACE_FLAGS_DEFAULT, |
|
2525 (EAPL("ERROR: Could not read realms from ca certificate.\n"))); |
|
2526 |
|
2527 get_am_partner()->complete_eap_identity_query( |
|
2528 0, // 0 because identity query failed |
|
2529 &m_receive_network_id, |
|
2530 m_eap_identifier, |
|
2531 eap_status_illegal_eap_identity, |
|
2532 false, |
|
2533 0, |
|
2534 false, |
|
2535 0); |
|
2536 |
|
2537 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
2538 return EAP_STATUS_RETURN(m_am_tools, status); |
|
2539 } |
|
2540 |
|
2541 EAP_TRACE_DATA_DEBUG( |
|
2542 m_am_tools, |
|
2543 TRACE_FLAGS_DEFAULT, |
|
2544 (EAPL("Got realm from CA certificate"), |
|
2545 m_manual_realm.get_data(m_manual_realm.get_data_length()), |
|
2546 m_manual_realm.get_data_length())); |
|
2547 |
|
2548 get_am_partner()->complete_eap_identity_query( |
|
2549 0, // 0 because certificate query failed |
|
2550 &m_receive_network_id, |
|
2551 m_eap_identifier, |
|
2552 eap_status_ok, |
|
2553 m_use_manual_username, |
|
2554 &m_manual_username, |
|
2555 true, |
|
2556 &m_manual_realm); |
|
2557 } |
|
2558 break; |
|
2559 |
|
2560 case EHandlingCipherSuiteQuery: |
|
2561 { |
|
2562 |
|
2563 EAP_TRACE_DEBUG( |
|
2564 m_am_tools, |
|
2565 TRACE_FLAGS_DEFAULT, |
|
2566 (EAPL("Got CA certificate. Resume cipher suite selection.\n"))); |
|
2567 |
|
2568 query_cipher_suites_and_previous_session(); |
|
2569 } |
|
2570 break; |
|
2571 |
|
2572 default: |
|
2573 // This should never happen |
|
2574 User::Panic(_L("EAPOL"), 1); |
|
2575 |
|
2576 } |
|
2577 |
|
2578 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
2579 return EAP_STATUS_RETURN(m_am_tools, eap_status_ok); |
|
2580 } |
|
2581 |
|
2582 void eap_am_type_tls_peap_symbian_c::get_identities_from_distinguished_namesL( |
|
2583 const CX509Certificate * const aCertificate, |
|
2584 eap_variable_data_c * const aSubjectIdentity, |
|
2585 eap_variable_data_c * const aIssuerIdentity) |
|
2586 { |
|
2587 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
2588 |
|
2589 if (aSubjectIdentity == 0 |
|
2590 || aIssuerIdentity == 0 |
|
2591 || aCertificate == 0) |
|
2592 { |
|
2593 User::Leave(KErrArgument); |
|
2594 } |
|
2595 |
|
2596 TInt i(0); |
|
2597 HBufC *value = 0; |
|
2598 // Loop the distinguished name field and try to find common name |
|
2599 const CX500DistinguishedName& dn = aCertificate->SubjectName(); |
|
2600 |
|
2601 for (i = 0; i < dn.Count(); i++) |
|
2602 { |
|
2603 const CX520AttributeTypeAndValue& attribute = dn.Element(i); |
|
2604 |
|
2605 if (attribute.Type() == KX520CommonName) |
|
2606 { |
|
2607 value = attribute.ValueL(); |
|
2608 CleanupStack::PushL(value); |
|
2609 |
|
2610 // Convert to 8-bit text |
|
2611 HBufC8* tmp = HBufC8::NewLC(value->Length()); |
|
2612 |
|
2613 if (NULL == tmp) |
|
2614 { |
|
2615 User::Leave(KErrNoMemory); |
|
2616 } |
|
2617 |
|
2618 TPtr8 tmpptr = tmp->Des(); |
|
2619 tmpptr.Copy(*value); |
|
2620 |
|
2621 eap_status_e status = aSubjectIdentity->set_copy_of_buffer( |
|
2622 tmpptr.Ptr(), |
|
2623 tmpptr.Size()); |
|
2624 |
|
2625 if (status != eap_status_ok) |
|
2626 { |
|
2627 User::Leave(KErrNoMemory); |
|
2628 } |
|
2629 |
|
2630 EAP_TRACE_DATA_DEBUG( |
|
2631 m_am_tools, |
|
2632 TRACE_FLAGS_DEFAULT, |
|
2633 (EAPL("eap_am_type_tls_peap_symbian_c::get_identities_from_distinguished_namesL:SubjectIdentity:"), |
|
2634 tmpptr.Ptr(), |
|
2635 tmpptr.Size())); |
|
2636 |
|
2637 CleanupStack::PopAndDestroy(tmp); |
|
2638 CleanupStack::PopAndDestroy(value); |
|
2639 } |
|
2640 } |
|
2641 const CX500DistinguishedName& dn2 = aCertificate->IssuerName(); |
|
2642 |
|
2643 for (i = 0; i < dn2.Count(); i++) |
|
2644 { |
|
2645 const CX520AttributeTypeAndValue& attribute = dn2.Element(i); |
|
2646 |
|
2647 if (attribute.Type() == KX520CommonName) |
|
2648 { |
|
2649 value = attribute.ValueL(); |
|
2650 CleanupStack::PushL(value); |
|
2651 // Convert to 8-bit text |
|
2652 HBufC8* tmp = HBufC8::NewLC(value->Length()); |
|
2653 |
|
2654 if (NULL == tmp) |
|
2655 { |
|
2656 User::Leave(KErrNoMemory); |
|
2657 } |
|
2658 |
|
2659 TPtr8 tmpptr = tmp->Des(); |
|
2660 tmpptr.Copy(*value); |
|
2661 |
|
2662 eap_status_e status = aIssuerIdentity->set_copy_of_buffer( |
|
2663 tmpptr.Ptr(), |
|
2664 tmpptr.Size()); |
|
2665 |
|
2666 if (status != eap_status_ok) |
|
2667 { |
|
2668 User::Leave(KErrNoMemory); |
|
2669 } |
|
2670 |
|
2671 EAP_TRACE_DATA_DEBUG( |
|
2672 m_am_tools, |
|
2673 TRACE_FLAGS_DEFAULT, |
|
2674 (EAPL("eap_am_type_tls_peap_symbian_c::get_identities_from_distinguished_namesL:IssuerIdentity:"), |
|
2675 tmpptr.Ptr(), |
|
2676 tmpptr.Size())); |
|
2677 |
|
2678 CleanupStack::PopAndDestroy(tmp); |
|
2679 CleanupStack::PopAndDestroy(value); |
|
2680 } |
|
2681 } |
|
2682 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
2683 } |
|
2684 |
|
2685 void eap_am_type_tls_peap_symbian_c::get_identity_from_alternative_nameL( |
|
2686 const CX509Certificate * const aCertificate, |
|
2687 eap_variable_data_c * const aIdentity) |
|
2688 { |
|
2689 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
2690 /******************************************************************** |
|
2691 SubjectAltName ::= GeneralNames |
|
2692 |
|
2693 GeneralNames ::= SEQUENCE OF GeneralName |
|
2694 |
|
2695 GeneralName ::= CHOICE { |
|
2696 otherName [0] AnotherName, |
|
2697 rfc822Name [1] IA5String, |
|
2698 dNSName [2] IA5String, |
|
2699 x400Address [3] ANY, --ORAddress, |
|
2700 directoryName [4] Name, |
|
2701 ediPartyName [5] EDIPartyName, |
|
2702 uniformResourceIdentifier [6] IA5String, |
|
2703 iPAddress [7] OCTET STRING, |
|
2704 registeredID [8] OBJECT IDENTIFIER } |
|
2705 |
|
2706 -- AnotherName replaces OTHER-NAME ::= TYPE-IDENTIFIER, as |
|
2707 -- TYPE-IDENTIFIER is not supported in the '88 ASN.1 syntax |
|
2708 |
|
2709 AnotherName ::= SEQUENCE { |
|
2710 type OBJECT IDENTIFIER, |
|
2711 value [0] EXPLICIT ANY } --DEFINED BY type-id } |
|
2712 **********************************************************************/ |
|
2713 |
|
2714 const CX509CertExtension* ext = aCertificate->Extension(KSubjectAltName); |
|
2715 // Check if there is alternative name extension (Windows provided certificates usually do) |
|
2716 if (ext != 0) |
|
2717 { |
|
2718 // Start parsing the alt. name |
|
2719 TPtrC8 name = ext->Data(); |
|
2720 |
|
2721 EAP_TRACE_DATA_DEBUG( |
|
2722 m_am_tools, |
|
2723 TRACE_FLAGS_DEFAULT, |
|
2724 (EAPL("eap_am_type_tls_peap_symbian_c::get_identity_from_alternative_nameL: Alt Name from Cert extn:"), |
|
2725 name.Ptr(), |
|
2726 name.Size())); |
|
2727 |
|
2728 if(0 == name.Size()) |
|
2729 { |
|
2730 EAP_TRACE_DEBUG( |
|
2731 m_am_tools, |
|
2732 TRACE_FLAGS_DEFAULT, |
|
2733 (EAPL("ERROR:get_identity_from_alternative_nameL:No Alternative Name in cert extension\n"))); |
|
2734 |
|
2735 User::Leave(KErrNotFound); |
|
2736 } |
|
2737 |
|
2738 // Extension is inside an octet string |
|
2739 TASN1DecOctetString octetstring; |
|
2740 TInt pos(0); |
|
2741 HBufC8* pOct = octetstring.DecodeDERL(name, pos); |
|
2742 |
|
2743 if(NULL == pOct) |
|
2744 { |
|
2745 EAP_TRACE_DEBUG( |
|
2746 m_am_tools, |
|
2747 TRACE_FLAGS_DEFAULT, |
|
2748 (EAPL("ERROR:get_identity_from_alternative_nameL:No ASN1DecOctetString or DecodeDER failed\n"))); |
|
2749 |
|
2750 User::Leave(KErrNotFound); |
|
2751 } |
|
2752 |
|
2753 CleanupStack::PushL(pOct); |
|
2754 |
|
2755 // Then there is SEQUENCE |
|
2756 TASN1DecSequence seq; |
|
2757 pos = 0; |
|
2758 CArrayPtrFlat<TASN1DecGeneric>* pSeq = seq.DecodeDERLC(pOct->Des(), pos); |
|
2759 |
|
2760 if(0 == pSeq->Count()) |
|
2761 { |
|
2762 EAP_TRACE_DEBUG( |
|
2763 m_am_tools, |
|
2764 TRACE_FLAGS_DEFAULT, |
|
2765 (EAPL("ERROR:get_identity_from_alternative_nameL:No ASN1DecSequence or DecodeDER failed\n"))); |
|
2766 |
|
2767 User::Leave(KErrNotFound); |
|
2768 } |
|
2769 |
|
2770 // Get the first item in the sequence (ignore other possible items) |
|
2771 TASN1DecGeneric* gen; |
|
2772 gen = pSeq->At(0); |
|
2773 if (gen == 0) |
|
2774 { |
|
2775 EAP_TRACE_DEBUG( |
|
2776 m_am_tools, |
|
2777 TRACE_FLAGS_DEFAULT, |
|
2778 (EAPL("ERROR:get_identity_from_alternative_nameL:No ASN1DecGeneric\n"))); |
|
2779 |
|
2780 User::Leave(KErrNotFound); |
|
2781 } |
|
2782 if (gen->Tag() != 0) // Only parse otherName in the CHOICE at the moment. |
|
2783 { |
|
2784 EAP_TRACE_DEBUG( |
|
2785 m_am_tools, |
|
2786 TRACE_FLAGS_DEFAULT, |
|
2787 (EAPL("ERROR:get_identity_from_alternative_nameL:Some Tag in ASN1DecGeneric\n"))); |
|
2788 |
|
2789 User::Leave(KErrNotSupported); |
|
2790 } |
|
2791 |
|
2792 TPtrC8 pOtherName = gen->GetContentDER(); |
|
2793 |
|
2794 TASN1DecObjectIdentifier objid; |
|
2795 |
|
2796 pos = 0; |
|
2797 HBufC* objId = objid.DecodeDERL(pOtherName, pos); |
|
2798 |
|
2799 if(NULL == objId) |
|
2800 { |
|
2801 EAP_TRACE_DEBUG( |
|
2802 m_am_tools, |
|
2803 TRACE_FLAGS_DEFAULT, |
|
2804 (EAPL("ERROR:get_identity_from_alternative_name_L:No ASN1DecObjectIdentifier or DecodeDER failed\n"))); |
|
2805 |
|
2806 User::Leave(KErrNotFound); |
|
2807 } |
|
2808 |
|
2809 CleanupStack::PushL(objId); |
|
2810 |
|
2811 // http://asn1.elibel.tm.fr/oid/ |
|
2812 _LIT(KMSObjectId, "1.3.6.1.4.1.311.20.2.3"); |
|
2813 if (objId->Compare(KMSObjectId) != 0) |
|
2814 { |
|
2815 // Not supported object type |
|
2816 |
|
2817 EAP_TRACE_DEBUG( |
|
2818 m_am_tools, |
|
2819 TRACE_FLAGS_DEFAULT, |
|
2820 (EAPL("ERROR:get_identity_from_alternative_nameL:Not supported object type\n"))); |
|
2821 |
|
2822 User::Leave(KErrNotSupported); |
|
2823 } |
|
2824 |
|
2825 pos += 2; // Skip over explicit tag |
|
2826 |
|
2827 TASN1DecUTF8String utf8; |
|
2828 HBufC* utf8name = utf8.DecodeDERL(pOtherName, pos); |
|
2829 |
|
2830 if(NULL == utf8name) |
|
2831 { |
|
2832 EAP_TRACE_DEBUG( |
|
2833 m_am_tools, |
|
2834 TRACE_FLAGS_DEFAULT, |
|
2835 (EAPL("ERROR:get_identity_from_alternative_nameL:No ASN1DecUTF8String or DecodeDER failed\n"))); |
|
2836 |
|
2837 User::Leave(KErrNotFound); |
|
2838 } |
|
2839 |
|
2840 CleanupStack::PushL(utf8name); |
|
2841 |
|
2842 HBufC8* buf= HBufC8::NewLC(128); |
|
2843 if (NULL == buf) |
|
2844 { |
|
2845 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
2846 User::Leave(KErrNoMemory); |
|
2847 } |
|
2848 |
|
2849 TPtr8 nname = buf->Des(); |
|
2850 |
|
2851 nname.Copy(utf8name->Des()); |
|
2852 |
|
2853 eap_status_e status = aIdentity->set_copy_of_buffer( |
|
2854 nname.Ptr(), |
|
2855 nname.Size()); |
|
2856 if (status != eap_status_ok) |
|
2857 { |
|
2858 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
2859 User::Leave(KErrNoMemory); |
|
2860 } |
|
2861 |
|
2862 EAP_TRACE_DATA_DEBUG( |
|
2863 m_am_tools, |
|
2864 TRACE_FLAGS_DEFAULT, |
|
2865 (EAPL("eap_am_type_tls_peap_symbian_c::get_identity_from_alternative_nameL: Identity from Alt Name:"), |
|
2866 nname.Ptr(), |
|
2867 nname.Size())); |
|
2868 |
|
2869 CleanupStack::PopAndDestroy(5); |
|
2870 } |
|
2871 else |
|
2872 { |
|
2873 EAP_TRACE_DEBUG( |
|
2874 m_am_tools, |
|
2875 TRACE_FLAGS_DEFAULT, |
|
2876 (EAPL("get_identity_from_alternative_nameL:No X509 Cert Extension\n"))); |
|
2877 |
|
2878 User::Leave(KErrNotFound); |
|
2879 } |
|
2880 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
2881 } |
|
2882 |
|
2883 //-------------------------------------------------- |
|
2884 |
|
2885 // |
|
2886 //-------------------------------------------------- |
|
2887 |
|
2888 // |
|
2889 EAP_FUNC_EXPORT eap_status_e eap_am_type_tls_peap_symbian_c::timer_expired( |
|
2890 const u32_t id, void *data) |
|
2891 { |
|
2892 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
2893 EAP_UNREFERENCED_PARAMETER(id); // in release |
|
2894 EAP_UNREFERENCED_PARAMETER(data); // in release |
|
2895 |
|
2896 eap_status_e status = eap_status_ok; |
|
2897 |
|
2898 EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("TIMER: [0x%08x]->eap_am_type_tls_peap_symbian_c::timer_expired(id 0x%02x, data 0x%08x).\n"), |
|
2899 this, id, data)); |
|
2900 |
|
2901 #if defined(USE_FAST_EAP_TYPE) |
|
2902 |
|
2903 if(id == KHandleCompletePacstoreNokTimerID) |
|
2904 { |
|
2905 m_eap_fast_completion_status = eap_status_file_does_not_exist; |
|
2906 m_tls_application->complete_initialize_PAC_store( iCompletionOperation, iCompletion ); |
|
2907 return eap_status_ok; |
|
2908 } |
|
2909 if(id == KHandleCompletePacstoreOkTimerID) |
|
2910 { |
|
2911 m_eap_fast_completion_status = eap_status_ok; |
|
2912 m_tls_application->complete_initialize_PAC_store( iCompletionOperation, iCompletion ); |
|
2913 return eap_status_ok; |
|
2914 } |
|
2915 if (id == KRemoveIAPReferenceTimerID) |
|
2916 { |
|
2917 status = RemoveIAPReference(); |
|
2918 |
|
2919 } |
|
2920 if (id == KImportFileTimerID) |
|
2921 { |
|
2922 TRAPD(err, status = ImportFilesL()); |
|
2923 if (err != KErrNone) |
|
2924 { |
|
2925 EAP_TRACE_DEBUG(m_am_tools, |
|
2926 TRACE_FLAGS_DEFAULT, |
|
2927 (EAPL("eap_am_type_tls_peap_symbian_c::timer_expired - Leave From ImportFilesL %d\n"),err)); |
|
2928 } |
|
2929 } |
|
2930 |
|
2931 if (id == KCompleteReadPacstoreTimerID) |
|
2932 { |
|
2933 TRAPD(err, FinalCompleteReadPACStoreDataL(m_eap_fast_completion_status)); |
|
2934 if (err != KErrNone) |
|
2935 { |
|
2936 EAP_TRACE_DEBUG(m_am_tools, |
|
2937 TRACE_FLAGS_DEFAULT, |
|
2938 (EAPL("eap_am_type_tls_peap_symbian_c::timer_expired - Leave From FinalCompleteReadPACStoreDataL %d\n"),err)); |
|
2939 } |
|
2940 } |
|
2941 |
|
2942 if (id == KHandleReadPacstoreTimerID) |
|
2943 { |
|
2944 if (m_state == EPasswordCancel) |
|
2945 { |
|
2946 m_eap_fast_completion_status = eap_status_user_cancel_authentication; |
|
2947 EAP_TRACE_DEBUG(m_am_tools, |
|
2948 TRACE_FLAGS_DEFAULT, |
|
2949 (EAPL("eap_am_type_tls_peap_symbian_c::timer_expired - PW query Cancel\n"))); |
|
2950 |
|
2951 |
|
2952 status = m_partner->set_timer( |
|
2953 this, |
|
2954 KCompleteReadPacstoreTimerID, |
|
2955 0, |
|
2956 0); |
|
2957 return eap_status_ok; |
|
2958 } |
|
2959 if (m_state == EMasterkeyQuery && m_verificationStatus == EFalse) |
|
2960 { |
|
2961 if (m_userResponse.get_data_length()>0) |
|
2962 { |
|
2963 EAP_TRACE_DEBUG(m_am_tools, |
|
2964 TRACE_FLAGS_DEFAULT, |
|
2965 (EAPL("eap_am_type_tls_peap_symbian_c::timer_expired - Masterkey Create\n"))); |
|
2966 m_verificationStatus = ETrue; |
|
2967 TRAPD(err, m_eap_fast_completion_status=CreateMasterkeyL()); |
|
2968 if (err != KErrNone) |
|
2969 { |
|
2970 EAP_TRACE_DEBUG(m_am_tools, |
|
2971 TRACE_FLAGS_DEFAULT, |
|
2972 (EAPL("eap_am_type_tls_peap_symbian_c::timer_expired - Leave From CreateMasterkeyL %d\n"),err)); |
|
2973 } |
|
2974 } |
|
2975 else |
|
2976 { |
|
2977 EAP_TRACE_DEBUG(m_am_tools, |
|
2978 TRACE_FLAGS_DEFAULT, |
|
2979 (EAPL("eap_am_type_tls_peap_symbian_c::timer_expired - Masterkey, no data -> final complete for PW\n"))); |
|
2980 m_state = EWrongPassword; |
|
2981 m_verificationStatus = EFalse; |
|
2982 |
|
2983 status = m_partner->set_timer( |
|
2984 this, |
|
2985 KCompleteReadPacstoreTimerID, |
|
2986 0, |
|
2987 0); |
|
2988 |
|
2989 return status; |
|
2990 } |
|
2991 } |
|
2992 |
|
2993 if (m_state == EPasswordQuery || m_state == EWrongPassword || m_state == EMasterkeyQuery) |
|
2994 { |
|
2995 if (m_verificationStatus == EFalse) |
|
2996 { |
|
2997 TRAPD(err, status = PasswordQueryL()); |
|
2998 m_eap_fast_completion_status = m_am_tools->convert_am_error_to_eapol_error(status); |
|
2999 if (err != KErrNone) |
|
3000 { |
|
3001 EAP_TRACE_DEBUG(m_am_tools, |
|
3002 TRACE_FLAGS_DEFAULT, |
|
3003 (EAPL("eap_am_type_tls_peap_symbian_c::timer_expired - Leave From PasswordQueryL %d\n"),err)); |
|
3004 } |
|
3005 |
|
3006 if (m_eap_fast_completion_status != eap_status_ok) |
|
3007 { |
|
3008 EAP_TRACE_DEBUG(m_am_tools, |
|
3009 TRACE_FLAGS_DEFAULT, |
|
3010 (EAPL("eap_am_type_tls_peap_symbian_c::timer_expired - PW query NOK, final complete for PW\n"))); |
|
3011 |
|
3012 status = m_partner->set_timer( |
|
3013 this, |
|
3014 KCompleteReadPacstoreTimerID, |
|
3015 0, |
|
3016 0); |
|
3017 } |
|
3018 } |
|
3019 if (m_verificationStatus != EFalse) |
|
3020 { |
|
3021 TRAPD(err, CompletePasswordQueryL()); |
|
3022 if (err != KErrNone) |
|
3023 { |
|
3024 EAP_TRACE_DEBUG(m_am_tools, |
|
3025 TRACE_FLAGS_DEFAULT, |
|
3026 (EAPL("eap_am_type_tls_peap_symbian_c::timer_expired - Leave From CompletePasswordQueryL %d\n"),err)); |
|
3027 } |
|
3028 |
|
3029 EAP_TRACE_DEBUG( |
|
3030 m_am_tools, |
|
3031 TRACE_FLAGS_DEFAULT, |
|
3032 (EAPL("eap_am_type_tls_peap_symbian_c::timer_expired - Complete_password_query, m_both_completed=%d, m_both_asked=%d status=%d.\n"), |
|
3033 m_both_completed, |
|
3034 m_both_asked, |
|
3035 m_eap_fast_completion_status)); |
|
3036 if (m_both_completed == m_both_asked) |
|
3037 { |
|
3038 m_both_completed = 0; |
|
3039 m_both_asked = 0; |
|
3040 m_verificationStatus = EFalse; |
|
3041 |
|
3042 EAP_TRACE_DEBUG(m_am_tools, |
|
3043 TRACE_FLAGS_DEFAULT, |
|
3044 (EAPL("eap_am_type_tls_peap_symbian_c::timer_expired - All OK, final complete for PW\n"))); |
|
3045 status = m_partner->set_timer( |
|
3046 this, |
|
3047 KCompleteReadPacstoreTimerID, |
|
3048 0, |
|
3049 0); |
|
3050 return status; |
|
3051 } |
|
3052 } |
|
3053 } |
|
3054 |
|
3055 if (m_state == EFilePasswordQuery) |
|
3056 { |
|
3057 TRAPD( err, status = CompleteFilePasswordQueryL()); |
|
3058 if (err != KErrNone) |
|
3059 { |
|
3060 EAP_TRACE_DEBUG(m_am_tools, |
|
3061 TRACE_FLAGS_DEFAULT, |
|
3062 (EAPL("eap_am_type_tls_peap_symbian_c::timer_expired - Leave From CompleteFilePasswordQueryL %d\n"),err)); |
|
3063 } |
|
3064 |
|
3065 EAP_TRACE_DEBUG( |
|
3066 m_am_tools, |
|
3067 TRACE_FLAGS_DEFAULT, |
|
3068 (EAPL("eap_am_type_tls_peap_symbian_c::timer_expired - Complete_file_password_query, m_both_completed=%d, m_both_asked=%d status=%d.\n"), |
|
3069 m_both_completed, |
|
3070 m_both_asked, |
|
3071 status)); |
|
3072 if (status != eap_status_ok) |
|
3073 { |
|
3074 EAP_TRACE_DEBUG(m_am_tools, |
|
3075 TRACE_FLAGS_DEFAULT, |
|
3076 (EAPL("eap_am_type_tls_peap_symbian_c::timer_expired - PW query NOK, final complete for PW\n"))); |
|
3077 status = m_partner->set_timer( |
|
3078 this, |
|
3079 KCompleteReadPacstoreTimerID, |
|
3080 &status, |
|
3081 0); |
|
3082 return status; |
|
3083 } |
|
3084 if (m_both_completed == m_both_asked) |
|
3085 { |
|
3086 EAP_TRACE_DEBUG(m_am_tools, |
|
3087 TRACE_FLAGS_DEFAULT, |
|
3088 (EAPL("eap_am_type_tls_peap_symbian_c::timer_expired - All ok, final complete for PW\n"))); |
|
3089 m_both_completed = 0; |
|
3090 m_both_asked = 0; |
|
3091 status = m_partner->set_timer( |
|
3092 this, |
|
3093 KCompleteReadPacstoreTimerID, |
|
3094 &status, |
|
3095 0); |
|
3096 } |
|
3097 return status; |
|
3098 } |
|
3099 } |
|
3100 #endif //#if defined(USE_FAST_EAP_TYPE) |
|
3101 |
|
3102 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
3103 return EAP_STATUS_RETURN(m_am_tools, status); |
|
3104 } |
|
3105 |
|
3106 |
|
3107 //-------------------------------------------------- |
|
3108 |
|
3109 // |
|
3110 EAP_FUNC_EXPORT void eap_am_type_tls_peap_symbian_c::set_is_valid() |
|
3111 { |
|
3112 m_is_valid = true; |
|
3113 } |
|
3114 |
|
3115 //-------------------------------------------------- |
|
3116 |
|
3117 // |
|
3118 EAP_FUNC_EXPORT bool eap_am_type_tls_peap_symbian_c::get_is_valid() |
|
3119 { |
|
3120 return m_is_valid; |
|
3121 } |
|
3122 |
|
3123 //-------------------------------------------------- |
|
3124 |
|
3125 // |
|
3126 EAP_FUNC_EXPORT eap_status_e eap_am_type_tls_peap_symbian_c::timer_delete_data( |
|
3127 const u32_t id, void *data) |
|
3128 { |
|
3129 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
3130 EAP_UNREFERENCED_PARAMETER(id); // in release |
|
3131 EAP_UNREFERENCED_PARAMETER(data); // in release |
|
3132 |
|
3133 eap_status_e status = eap_status_ok; |
|
3134 |
|
3135 EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("TIMER: [0x%08x]->eap_am_type_tls_peap_symbian_c::timer_delete_data(id 0x%02x, data 0x%08x).\n"), |
|
3136 this, id, data)); |
|
3137 |
|
3138 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
3139 return EAP_STATUS_RETURN(m_am_tools, status); |
|
3140 } |
|
3141 |
|
3142 //-------------------------------------------------- |
|
3143 |
|
3144 // |
|
3145 EAP_FUNC_EXPORT eap_status_e eap_am_type_tls_peap_symbian_c::type_configure_read( |
|
3146 const eap_configuration_field_c * const field, |
|
3147 eap_variable_data_c * const data) |
|
3148 { |
|
3149 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
3150 EAP_ASSERT(data != NULL); |
|
3151 // Trap must be set here because the OS independent portion of EAP TLS |
|
3152 // that calls this function does not know anything about Symbian. |
|
3153 eap_status_e status(eap_status_ok); |
|
3154 |
|
3155 EAP_TRACE_DEBUG(m_am_tools, |
|
3156 TRACE_FLAGS_DEFAULT, |
|
3157 (EAPL("eap_am_type_tls_peap_symbian_c::type_configure_read - Start\n"))); |
|
3158 |
|
3159 if (m_current_eap_type == eap_type_peap |
|
3160 #if defined(USE_TTLS_EAP_TYPE) |
|
3161 || m_current_eap_type == eap_type_ttls |
|
3162 #endif // #if defined(USE_TTLS_EAP_TYPE) |
|
3163 #if defined(USE_FAST_EAP_TYPE) |
|
3164 || m_current_eap_type == eap_type_fast |
|
3165 #endif |
|
3166 |
|
3167 || m_current_eap_type == eap_type_ttls_plain_pap |
|
3168 |
|
3169 ) |
|
3170 { |
|
3171 // Check if the wanted parameter is default type |
|
3172 eap_variable_data_c wanted_field(m_am_tools); |
|
3173 eap_variable_data_c type_field(m_am_tools); |
|
3174 eap_variable_data_c type_field_server(m_am_tools); |
|
3175 |
|
3176 status = wanted_field.set_buffer( |
|
3177 field->get_field(), |
|
3178 field->get_field_length(), |
|
3179 false, |
|
3180 false); |
|
3181 if (status != eap_status_ok) |
|
3182 { |
|
3183 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
3184 return EAP_STATUS_RETURN(m_am_tools, status); |
|
3185 } |
|
3186 |
|
3187 status = type_field.set_buffer( |
|
3188 cf_str_PEAP_tunneled_eap_type_hex_data.get_field()->get_field(), |
|
3189 cf_str_PEAP_tunneled_eap_type_hex_data.get_field()->get_field_length(), |
|
3190 false, |
|
3191 false); |
|
3192 if (status != eap_status_ok) |
|
3193 { |
|
3194 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
3195 return EAP_STATUS_RETURN(m_am_tools, status); |
|
3196 } |
|
3197 |
|
3198 status = type_field_server.set_buffer( |
|
3199 cf_str_PEAP_server_tunneled_eap_type_hex_data.get_field()->get_field(), |
|
3200 cf_str_PEAP_server_tunneled_eap_type_hex_data.get_field()->get_field_length(), |
|
3201 false, |
|
3202 false); |
|
3203 if (status != eap_status_ok) |
|
3204 { |
|
3205 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
3206 return EAP_STATUS_RETURN(m_am_tools, status); |
|
3207 } |
|
3208 |
|
3209 if (!wanted_field.compare(&type_field_server)) |
|
3210 { |
|
3211 // Change the name of the parameter because Symbian AM does not have separate config |
|
3212 // for the server |
|
3213 status = wanted_field.set_buffer( |
|
3214 cf_str_PEAP_tunneled_eap_type_hex_data.get_field()->get_field(), |
|
3215 cf_str_PEAP_tunneled_eap_type_hex_data.get_field()->get_field_length(), |
|
3216 false, |
|
3217 false); |
|
3218 if (status != eap_status_ok) |
|
3219 { |
|
3220 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
3221 return EAP_STATUS_RETURN(m_am_tools, status); |
|
3222 } |
|
3223 } |
|
3224 |
|
3225 |
|
3226 if (!wanted_field.compare(&type_field)) |
|
3227 { |
|
3228 // We are asked to return cf_str_PEAP_tunneled_eap_type_hex_data |
|
3229 |
|
3230 #ifdef USE_EAP_EXPANDED_TYPES |
|
3231 |
|
3232 // We need to return here the next ENABLED tunneled EAP type we should try. |
|
3233 |
|
3234 if (0 == m_enabled_tunneling_exp_eap_array.Count()) |
|
3235 { |
|
3236 // No EAP types are ENABLED as tunneling type. |
|
3237 if (m_is_client) |
|
3238 { |
|
3239 EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("ERROR: No ENABLED encapsulated EAP types.\n"))); |
|
3240 } |
|
3241 |
|
3242 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
3243 return EAP_STATUS_RETURN(m_am_tools, eap_status_illegal_configure_field); |
|
3244 } |
|
3245 else |
|
3246 { |
|
3247 // Get the first enabled EAP type (tunneling). |
|
3248 |
|
3249 TBuf8<KExpandedEAPTypeSize> tmpExpEAP(m_enabled_tunneling_exp_eap_array[0]->iExpandedEAPType); //first item. |
|
3250 |
|
3251 EAP_TRACE_DATA_DEBUG( |
|
3252 m_am_tools, |
|
3253 TRACE_FLAGS_DEFAULT, |
|
3254 (EAPL("type_configure_read:Enabled expanded tunneling EAP type:"), |
|
3255 tmpExpEAP.Ptr(), |
|
3256 tmpExpEAP.Size())); |
|
3257 |
|
3258 status = data->set_copy_of_buffer(tmpExpEAP.Ptr(), KExpandedEAPTypeSize); |
|
3259 if (status != eap_status_ok) |
|
3260 { |
|
3261 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
3262 return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error); |
|
3263 } |
|
3264 |
|
3265 EAP_TRACE_DATA_DEBUG( |
|
3266 m_am_tools, |
|
3267 TRACE_FLAGS_DEFAULT, |
|
3268 (EAPL("EAP-PEAP or EAP-TTLS: Trying encapsulated EAP type:"), |
|
3269 tmpExpEAP.Ptr(), |
|
3270 tmpExpEAP.Size())); |
|
3271 } |
|
3272 |
|
3273 #else // For normal EAP types. |
|
3274 |
|
3275 // We need to return here the next tunneled EAP type we should try. |
|
3276 TInt i; |
|
3277 |
|
3278 for (i = 0; i < m_iap_eap_array.Count(); i++) |
|
3279 { |
|
3280 // Find the first enabled EAP type (highest priority) |
|
3281 TEap *eapType = m_iap_eap_array[i]; |
|
3282 if (eapType->Enabled == 1) |
|
3283 { |
|
3284 // Convert the string to integer |
|
3285 TLex8 tmp(eapType->UID); |
|
3286 TInt val(0); |
|
3287 tmp.Val(val); |
|
3288 status = data->set_copy_of_buffer(reinterpret_cast<u8_t *>(&val), sizeof(TUint)); |
|
3289 if (status != eap_status_ok) |
|
3290 { |
|
3291 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
3292 return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error); |
|
3293 } |
|
3294 EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("EAP-PEAP: Trying encapsulated EAP type: %d.\n"), val)); |
|
3295 break; |
|
3296 } |
|
3297 } |
|
3298 if (i == m_iap_eap_array.Count()) |
|
3299 { |
|
3300 // Not found |
|
3301 if (m_is_client) |
|
3302 { |
|
3303 EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("ERROR: No configured encapsulated EAP types.\n"))); |
|
3304 } |
|
3305 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
3306 return EAP_STATUS_RETURN(m_am_tools, eap_status_illegal_configure_field); |
|
3307 } |
|
3308 |
|
3309 #endif //#ifdef USE_EAP_EXPANDED_TYPES |
|
3310 |
|
3311 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
3312 return EAP_STATUS_RETURN(m_am_tools, status); |
|
3313 |
|
3314 } // End of if (!wanted_field.compare(&type_field)) |
|
3315 |
|
3316 #if !defined(USE_EAP_EXPANDED_TYPES) |
|
3317 |
|
3318 // cf_str_PEAP_accepted_tunneled_client_types_hex_data is available only for expaned EAP types. |
|
3319 // cf_str_PEAP_accepted_tunneled_client_types_u32array should be used otherwise. |
|
3320 // So for cf_str_PEAP_accepted_tunneled_client_types_hex_data and eap_configure_type_hex_data |
|
3321 // we should return eap_status_illegal_configure_field. |
|
3322 // This is needed only if USE_EAP_EXPANDED_TYPES is not defined. Otherwise the field |
|
3323 // cf_str_PEAP_accepted_tunneled_client_types_hex_data can be read from the database using |
|
3324 // type_configure_readL (let it fall through). |
|
3325 |
|
3326 eap_variable_data_c tunneled_type_field(m_am_tools); |
|
3327 |
|
3328 status = tunneled_type_field.set_buffer( |
|
3329 cf_str_PEAP_accepted_tunneled_client_types_hex_data.get_field()->get_field(), |
|
3330 cf_str_PEAP_accepted_tunneled_client_types_hex_data.get_field()->get_field_length(), |
|
3331 false, |
|
3332 false); |
|
3333 if (status != eap_status_ok) |
|
3334 { |
|
3335 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
3336 return EAP_STATUS_RETURN(m_am_tools, status); |
|
3337 } |
|
3338 |
|
3339 if (!wanted_field.compare(&tunneled_type_field)) |
|
3340 { |
|
3341 // Check if the type is eap_configure_type_hex_data. |
|
3342 |
|
3343 if( eap_configure_type_hex_data == field->get_type() ) |
|
3344 { |
|
3345 // This field is used only for exapanded EAP types. |
|
3346 return EAP_STATUS_RETURN(m_am_tools, eap_status_illegal_configure_type); |
|
3347 } |
|
3348 } |
|
3349 |
|
3350 #else // For expanded EAP type. |
|
3351 |
|
3352 // cf_str_PEAP_accepted_tunneled_client_types_u32array is available only for normal EAP types. |
|
3353 // So for cf_str_PEAP_accepted_tunneled_client_types_u32array and eap_configure_type_u32array |
|
3354 // we should return eap_status_illegal_configure_field. |
|
3355 |
|
3356 eap_variable_data_c tunneled_type_field(m_am_tools); |
|
3357 |
|
3358 status = tunneled_type_field.set_buffer( |
|
3359 cf_str_PEAP_accepted_tunneled_client_types_u32array.get_field()->get_field(), |
|
3360 cf_str_PEAP_accepted_tunneled_client_types_u32array.get_field()->get_field_length(), |
|
3361 false, |
|
3362 false); |
|
3363 if (status != eap_status_ok) |
|
3364 { |
|
3365 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
3366 return EAP_STATUS_RETURN(m_am_tools, status); |
|
3367 } |
|
3368 |
|
3369 if (!wanted_field.compare(&tunneled_type_field)) |
|
3370 { |
|
3371 // Check if the type is eap_configure_type_u32array. |
|
3372 |
|
3373 if( eap_configure_type_u32array == field->get_type() ) |
|
3374 { |
|
3375 // This field is used only for Normal EAP types. This is illegal here. |
|
3376 return EAP_STATUS_RETURN(m_am_tools, eap_status_illegal_configure_type); |
|
3377 } |
|
3378 } |
|
3379 |
|
3380 #endif // End of #if !defined(USE_EAP_EXPANDED_TYPES) |
|
3381 |
|
3382 } // End of if (m_current_eap_type == eap_type_peap |
|
3383 |
|
3384 TRAPD(err, type_configure_readL( |
|
3385 field->get_field(), |
|
3386 field->get_field_length(), |
|
3387 data)); |
|
3388 if (err != KErrNone) |
|
3389 { |
|
3390 status = m_am_tools->convert_am_error_to_eapol_error(err); |
|
3391 } |
|
3392 |
|
3393 m_am_tools->trace_configuration( |
|
3394 status, |
|
3395 field, |
|
3396 data); |
|
3397 |
|
3398 EAP_TRACE_DEBUG(m_am_tools, |
|
3399 TRACE_FLAGS_DEFAULT, |
|
3400 (EAPL("eap_am_type_tls_peap_symbian_c::type_configure_read - End\n"))); |
|
3401 |
|
3402 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
3403 return EAP_STATUS_RETURN(m_am_tools, status); |
|
3404 } |
|
3405 |
|
3406 //-------------------------------------------------- |
|
3407 void eap_am_type_tls_peap_symbian_c::type_configure_readL( |
|
3408 eap_config_string field, |
|
3409 const u32_t field_length, |
|
3410 eap_variable_data_c * const data) |
|
3411 { |
|
3412 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
3413 EAP_UNREFERENCED_PARAMETER(field_length); |
|
3414 |
|
3415 // Create a buffer for the ascii strings - initialised with the argument |
|
3416 HBufC8* asciibuf = HBufC8::NewLC(KMaxDBFieldNameLength); |
|
3417 TPtr8 asciiString = asciibuf->Des(); |
|
3418 asciiString.Copy(reinterpret_cast<const unsigned char *>(field)); |
|
3419 |
|
3420 EAP_TRACE_DATA_DEBUG(m_am_tools, |
|
3421 TRACE_FLAGS_DEFAULT, |
|
3422 (EAPL("eap_am_type_tls_peap_symbian_c::type_configure_readL: Reading field:"), |
|
3423 asciiString.Ptr(), |
|
3424 asciiString.Size())); |
|
3425 |
|
3426 // Buffer for unicode parameter |
|
3427 HBufC* unicodebuf = HBufC::NewLC(KMaxDBFieldNameLength); |
|
3428 TPtr unicodeString = unicodebuf->Des(); |
|
3429 |
|
3430 // Convert to unicode |
|
3431 unicodeString.Copy(asciiString); |
|
3432 |
|
3433 // Now do the database query |
|
3434 HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength); |
|
3435 TPtr sqlStatement = buf->Des(); |
|
3436 |
|
3437 _LIT(KSQLQueryRow, "SELECT %S FROM %S WHERE %S=%d AND %S=%d AND %S=%d"); |
|
3438 |
|
3439 #if defined(USE_FAST_EAP_TYPE) |
|
3440 |
|
3441 // Unlike other EAP types, EAP-FAST has some settings in special settings table |
|
3442 // (m_db_fast_special_table_name) |
|
3443 |
|
3444 if(m_current_eap_type == eap_type_fast |
|
3445 && ((unicodeString.Compare(cf_str_EAP_FAST_allow_server_authenticated_provisioning_mode_literal) == 0) |
|
3446 || (unicodeString.Compare(cf_str_EAP_FAST_allow_server_unauthenticated_provisioning_mode_ADHP_literal) == 0) |
|
3447 || (unicodeString.Compare(cf_str_EAP_FAST_warn_ADHP_no_PAC_literal) == 0) |
|
3448 || (unicodeString.Compare(cf_str_EAP_FAST_warn_ADHP_no_matching_PAC_literal) == 0) |
|
3449 || (unicodeString.Compare(cf_str_EAP_FAST_warn_ADHP_not_default_server_literal) == 0) |
|
3450 || (unicodeString.Compare(KFASTPACGroupImportReferenceCollection) == 0) |
|
3451 || (unicodeString.Compare(KFASTPACGroupDBReferenceCollection) == 0))) |
|
3452 { |
|
3453 if (unicodeString.Compare(cf_str_EAP_FAST_warn_ADHP_no_matching_PAC_literal) == 0) |
|
3454 { |
|
3455 unicodeString.Copy(KFASTWarnADHPNoMatchingPAC); |
|
3456 } |
|
3457 if (unicodeString.Compare(cf_str_EAP_FAST_warn_ADHP_no_PAC_literal) == 0) |
|
3458 { |
|
3459 unicodeString.Copy(KFASTWarnADHPNoPAC); |
|
3460 } |
|
3461 if (unicodeString.Compare(cf_str_EAP_FAST_warn_ADHP_not_default_server_literal) == 0) |
|
3462 { |
|
3463 unicodeString.Copy(KFASTWarnNotDefaultServer); |
|
3464 } |
|
3465 EAP_TRACE_DEBUG(m_am_tools, |
|
3466 TRACE_FLAGS_DEFAULT, |
|
3467 (EAPL("eap_am_type_tls_peap_symbian_c::type_configure_readL This field will be read from EAP-FAST's special table\n"))); |
|
3468 |
|
3469 sqlStatement.Format(KSQLQueryRow, &unicodeString, &m_db_fast_special_table_name, |
|
3470 &KServiceType, m_index_type, &KServiceIndex, m_index, &KTunnelingType, m_tunneling_vendor_type); |
|
3471 } |
|
3472 else |
|
3473 { |
|
3474 sqlStatement.Format(KSQLQueryRow, &unicodeString, &m_db_table_name, |
|
3475 &KServiceType, m_index_type, &KServiceIndex, m_index, &KTunnelingType, m_tunneling_vendor_type); |
|
3476 } |
|
3477 |
|
3478 #else |
|
3479 |
|
3480 sqlStatement.Format(KSQLQueryRow, &unicodeString, &m_db_table_name, |
|
3481 &KServiceType, m_index_type, &KServiceIndex, m_index, &KTunnelingType, m_tunneling_vendor_type); |
|
3482 |
|
3483 #endif // End: #if defined(USE_FAST_EAP_TYPE) |
|
3484 |
|
3485 RDbView view; |
|
3486 User::LeaveIfError(view.Prepare(m_database, TDbQuery(sqlStatement), TDbWindow::EUnlimited)); |
|
3487 CleanupClosePushL(view); |
|
3488 User::LeaveIfError(view.EvaluateAll()); |
|
3489 if (view.FirstL()) |
|
3490 { |
|
3491 eap_status_e status; |
|
3492 view.GetL(); |
|
3493 switch (view.ColType(KDefaultColumnInView_One)) |
|
3494 { |
|
3495 case EDbColText: |
|
3496 { |
|
3497 unicodeString = view.ColDes(KDefaultColumnInView_One); |
|
3498 // Convert to 8-bit |
|
3499 asciiString.Copy(unicodeString); |
|
3500 if (asciiString.Size() > 0) |
|
3501 { |
|
3502 status = data->set_copy_of_buffer(asciiString.Ptr(), asciiString.Size()); |
|
3503 if (status != eap_status_ok) |
|
3504 { |
|
3505 User::Leave(m_am_tools->convert_eapol_error_to_am_error(EAP_STATUS_RETURN(m_am_tools, status))); |
|
3506 } |
|
3507 } |
|
3508 else |
|
3509 { |
|
3510 status = data->init(0); |
|
3511 if (status != eap_status_ok) |
|
3512 { |
|
3513 User::Leave(m_am_tools->convert_eapol_error_to_am_error(EAP_STATUS_RETURN(m_am_tools, status))); |
|
3514 } |
|
3515 data->set_is_valid(); |
|
3516 break; |
|
3517 } |
|
3518 } |
|
3519 break; |
|
3520 case EDbColUint32: |
|
3521 { |
|
3522 TUint value; |
|
3523 value = view.ColUint32(KDefaultColumnInView_One); |
|
3524 status = data->set_copy_of_buffer(&value, sizeof(value)); |
|
3525 if (status != eap_status_ok) |
|
3526 { |
|
3527 User::Leave(m_am_tools->convert_eapol_error_to_am_error(EAP_STATUS_RETURN(m_am_tools, status))); |
|
3528 } |
|
3529 } |
|
3530 break; |
|
3531 |
|
3532 case EDbColBinary: |
|
3533 { |
|
3534 TPtrC8 value = view.ColDes8(KDefaultColumnInView_One); |
|
3535 status = data->set_copy_of_buffer(value.Ptr(), value.Length()); |
|
3536 if (status != eap_status_ok) |
|
3537 { |
|
3538 User::Leave(m_am_tools->convert_eapol_error_to_am_error(EAP_STATUS_RETURN(m_am_tools, status))); |
|
3539 } |
|
3540 } |
|
3541 break; |
|
3542 default: |
|
3543 EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("type_configure_readL: Unexpected column type.\n"))); |
|
3544 User::Leave(KErrGeneral); |
|
3545 break; |
|
3546 } |
|
3547 } |
|
3548 else |
|
3549 { |
|
3550 // Could not find parameter |
|
3551 EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("type_configure_readL: Could not find configuration parameter.\n"))); |
|
3552 User::Leave(KErrArgument); |
|
3553 } |
|
3554 |
|
3555 // Close database |
|
3556 CleanupStack::PopAndDestroy(4); // view |
|
3557 |
|
3558 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
3559 } |
|
3560 //-------------------------------------------------- |
|
3561 |
|
3562 // |
|
3563 |
|
3564 EAP_FUNC_EXPORT eap_status_e eap_am_type_tls_peap_symbian_c::type_configure_write( |
|
3565 const eap_configuration_field_c * const field, |
|
3566 eap_variable_data_c * const data) |
|
3567 { |
|
3568 // Here configuration data must be read from type spesific database. |
|
3569 |
|
3570 // NOTE: This is really just for simulation. |
|
3571 // Write is routed to partner object. |
|
3572 eap_status_e status = m_partner->write_configure( |
|
3573 field, |
|
3574 data); |
|
3575 return EAP_STATUS_RETURN(m_am_tools, status); |
|
3576 } |
|
3577 |
|
3578 //-------------------------------------------------- |
|
3579 |
|
3580 // |
|
3581 |
|
3582 void eap_am_type_tls_peap_symbian_c::WriteBinaryParamL( |
|
3583 eap_config_string field, |
|
3584 const u32_t field_length, |
|
3585 const eap_variable_data_c * const data) |
|
3586 { |
|
3587 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
3588 |
|
3589 // Form the insertion command |
|
3590 TPtrC8 p(reinterpret_cast<const unsigned char *>(field), field_length); |
|
3591 |
|
3592 HBufC* fieldbuf = HBufC::NewLC(KMaxDBFieldNameLength); |
|
3593 TPtr field_name = fieldbuf->Des(); |
|
3594 |
|
3595 field_name.Copy(p); |
|
3596 |
|
3597 HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength); |
|
3598 TPtr sqlStatement = buf->Des(); |
|
3599 |
|
3600 _LIT(KSQLInsert, "SELECT %s FROM %S WHERE %S=%d AND %S=%d AND %S=%d"); |
|
3601 sqlStatement.Format(KSQLInsert, field_name.PtrZ(), &m_db_table_name, |
|
3602 &KServiceType, m_index_type, &KServiceIndex, m_index, &KTunnelingType, m_tunneling_vendor_type); |
|
3603 // Evaluate view |
|
3604 RDbView view; |
|
3605 User::LeaveIfError(view.Prepare(m_database,TDbQuery(sqlStatement), TDbWindow::EUnlimited)); |
|
3606 CleanupClosePushL(view); |
|
3607 User::LeaveIfError(view.EvaluateAll()); |
|
3608 // Update the columns in the database |
|
3609 view.FirstL(); |
|
3610 |
|
3611 view.UpdateL(); |
|
3612 |
|
3613 if (data->get_is_valid_data() == true) |
|
3614 { |
|
3615 TPtrC8 data_ptr(data->get_data(data->get_data_length()), data->get_data_length()); |
|
3616 view.SetColL(KDefaultColumnInView_One, data_ptr); |
|
3617 } |
|
3618 else |
|
3619 { |
|
3620 view.SetColNullL(KDefaultColumnInView_One); |
|
3621 } |
|
3622 view.PutL(); |
|
3623 |
|
3624 // Close database |
|
3625 CleanupStack::PopAndDestroy(3); // view, 2 strings |
|
3626 |
|
3627 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
3628 } |
|
3629 |
|
3630 void eap_am_type_tls_peap_symbian_c::WriteIntParamL( |
|
3631 eap_config_string field, |
|
3632 const u32_t field_length, |
|
3633 eap_variable_data_c * const data) |
|
3634 { |
|
3635 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
3636 |
|
3637 TPtrC8 p(reinterpret_cast<const unsigned char *>(field), field_length); |
|
3638 |
|
3639 HBufC* fieldbuf = HBufC::NewLC(KMaxDBFieldNameLength); |
|
3640 TPtr field_name = fieldbuf->Des(); |
|
3641 |
|
3642 field_name.Copy(p); |
|
3643 |
|
3644 // Form the insertion command |
|
3645 HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength); |
|
3646 TPtr sqlStatement = buf->Des(); |
|
3647 |
|
3648 _LIT(KSQLInsert, "SELECT %s FROM %S WHERE %S=%d AND %S=%d AND %S=%d"); |
|
3649 sqlStatement.Format(KSQLInsert, field_name.PtrZ(), &m_db_table_name, |
|
3650 &KServiceType, m_index_type, &KServiceIndex, m_index, &KTunnelingType, m_tunneling_vendor_type); |
|
3651 |
|
3652 // Evaluate view |
|
3653 RDbView view; |
|
3654 User::LeaveIfError(view.Prepare(m_database,TDbQuery(sqlStatement), TDbWindow::EUnlimited)); |
|
3655 CleanupClosePushL(view); |
|
3656 User::LeaveIfError(view.EvaluateAll()); |
|
3657 |
|
3658 // Create pointers to the data |
|
3659 TPtrC8 data_ptr(data->get_data(data->get_data_length()), data->get_data_length()); |
|
3660 |
|
3661 // Convert the string to integer |
|
3662 const TInt val = *( reinterpret_cast<const TInt*>(data_ptr.Ptr()) ); |
|
3663 |
|
3664 // Update the columns in the database |
|
3665 view.FirstL(); |
|
3666 |
|
3667 view.UpdateL(); |
|
3668 |
|
3669 view.SetColL(KDefaultColumnInView_One, val); |
|
3670 view.PutL(); |
|
3671 |
|
3672 // Close database |
|
3673 CleanupStack::PopAndDestroy(3); // view, buf, 2nd buf |
|
3674 |
|
3675 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
3676 } |
|
3677 |
|
3678 void eap_am_type_tls_peap_symbian_c::WriteIntParamL( |
|
3679 eap_config_string field, |
|
3680 const u32_t field_length, |
|
3681 const u32_t value) |
|
3682 { |
|
3683 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
3684 |
|
3685 TPtrC8 p(reinterpret_cast<const unsigned char *>(field), field_length); |
|
3686 |
|
3687 HBufC* fieldbuf = HBufC::NewLC(KMaxDBFieldNameLength); |
|
3688 TPtr field_name = fieldbuf->Des(); |
|
3689 |
|
3690 field_name.Copy(p); |
|
3691 |
|
3692 // Form the insertion command |
|
3693 HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength); |
|
3694 TPtr sqlStatement = buf->Des(); |
|
3695 |
|
3696 _LIT(KSQLInsert, "SELECT %s FROM %S WHERE %S=%d AND %S=%d AND %S=%d"); |
|
3697 sqlStatement.Format(KSQLInsert, field_name.PtrZ(), &m_db_table_name, |
|
3698 &KServiceType, m_index_type, &KServiceIndex, m_index, &KTunnelingType, m_tunneling_vendor_type); |
|
3699 |
|
3700 // Evaluate view |
|
3701 RDbView view; |
|
3702 User::LeaveIfError(view.Prepare(m_database,TDbQuery(sqlStatement), TDbWindow::EUnlimited)); |
|
3703 CleanupClosePushL(view); |
|
3704 User::LeaveIfError(view.EvaluateAll()); |
|
3705 |
|
3706 // Update the columns in the database |
|
3707 view.FirstL(); |
|
3708 |
|
3709 view.UpdateL(); |
|
3710 |
|
3711 view.SetColL(KDefaultColumnInView_One, value); |
|
3712 view.PutL(); |
|
3713 |
|
3714 // Close database |
|
3715 CleanupStack::PopAndDestroy(3); // view, buf, 2nd buf |
|
3716 |
|
3717 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
3718 } |
|
3719 |
|
3720 //-------------------------------------------------- |
|
3721 |
|
3722 void eap_am_type_tls_peap_symbian_c::ResetSessionIdL() |
|
3723 { |
|
3724 eap_variable_data_c count_of_session_resumes(m_am_tools); |
|
3725 eap_variable_data_c session_id(m_am_tools); |
|
3726 eap_variable_data_c master_secret(m_am_tools); |
|
3727 |
|
3728 EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, |
|
3729 (EAPL("ResetSessionIdL - clearing session resume info.\n"))); |
|
3730 |
|
3731 { |
|
3732 session_id.reset(); |
|
3733 WriteBinaryParamL( |
|
3734 cf_str_EAP_TLS_PEAP_saved_session_id.get_field()->get_field(), |
|
3735 cf_str_EAP_TLS_PEAP_saved_session_id.get_field()->get_field_length(), |
|
3736 &session_id); |
|
3737 } |
|
3738 |
|
3739 { |
|
3740 master_secret.reset(); |
|
3741 WriteBinaryParamL( |
|
3742 cf_str_EAP_TLS_PEAP_saved_master_secret.get_field()->get_field(), |
|
3743 cf_str_EAP_TLS_PEAP_saved_master_secret.get_field()->get_field_length(), |
|
3744 &master_secret); |
|
3745 } |
|
3746 |
|
3747 { |
|
3748 WriteIntParamL( |
|
3749 cf_str_EAP_TLS_PEAP_saved_cipher_suite.get_field()->get_field(), |
|
3750 cf_str_EAP_TLS_PEAP_saved_cipher_suite.get_field()->get_field_length(), |
|
3751 tls_cipher_suites_TLS_NULL_WITH_NULL_NULL); |
|
3752 } |
|
3753 } |
|
3754 |
|
3755 //-------------------------------------------------- |
|
3756 |
|
3757 EAP_FUNC_EXPORT eap_status_e eap_am_type_tls_peap_symbian_c::alert_received( |
|
3758 const tls_alert_level_e alert_level, |
|
3759 const tls_alert_description_e alert_description) |
|
3760 { |
|
3761 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
3762 EAP_UNREFERENCED_PARAMETER(alert_description); // in release |
|
3763 EAP_UNREFERENCED_PARAMETER(alert_level); // in release |
|
3764 |
|
3765 eap_tls_trace_string_c tls_trace; |
|
3766 |
|
3767 EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("\n"))); |
|
3768 EAP_TRACE_DEBUG( |
|
3769 m_am_tools, |
|
3770 TRACE_FLAGS_DEFAULT, |
|
3771 (EAPL("ERROR: %s: message_function: alert_received(), level %d=%s, description %d=%s\n"), |
|
3772 (m_is_client == true ? "client": "server"), |
|
3773 alert_level, |
|
3774 tls_trace.get_alert_level_string(alert_level), |
|
3775 alert_description, |
|
3776 tls_trace.get_alert_description_string(alert_description))); |
|
3777 |
|
3778 // Store alert description so that it is possible to disallow certificates based |
|
3779 // on that information. |
|
3780 m_latest_alert_description = alert_description; |
|
3781 |
|
3782 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
3783 return EAP_STATUS_RETURN(m_am_tools, eap_status_ok); |
|
3784 } |
|
3785 |
|
3786 //-------------------------------------------------- |
|
3787 |
|
3788 |
|
3789 EAP_FUNC_EXPORT eap_status_e eap_am_type_tls_peap_symbian_c::query_cipher_suites_and_previous_session() |
|
3790 { |
|
3791 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
3792 |
|
3793 EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("\n"))); |
|
3794 EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("TLS: %s: function: query_cipher_suites_and_previous_session()\n"), |
|
3795 (m_is_client == true ? "client": "server"))); |
|
3796 |
|
3797 EAP_ASSERT_ALWAYS(m_is_client == true); |
|
3798 |
|
3799 eap_status_e status(eap_status_process_general_error); |
|
3800 |
|
3801 TAlgorithmId certAlgorithm(ERSA); |
|
3802 |
|
3803 bool select_all_cipher_suites = false; |
|
3804 |
|
3805 eap_variable_data_c session_id(m_am_tools); |
|
3806 eap_variable_data_c master_secret(m_am_tools); |
|
3807 tls_cipher_suites_e used_cipher_suite(tls_cipher_suites_TLS_NULL_WITH_NULL_NULL); |
|
3808 tls_session_type_e tls_session_type(tls_session_type_full_authentication); |
|
3809 |
|
3810 eap_array_c<u16_t> cipher_suites(m_am_tools); |
|
3811 |
|
3812 #if defined(USE_FAST_EAP_TYPE) |
|
3813 |
|
3814 if(m_current_eap_type == eap_type_fast && |
|
3815 m_serv_unauth_prov_mode == true) |
|
3816 { |
|
3817 EAP_TRACE_DEBUG(m_am_tools, |
|
3818 TRACE_FLAGS_DEFAULT, ( |
|
3819 EAPL("eap_am_type_tls_peap_symbian_c::query_cipher_suites_and_previous_session-Exception for EAP-FAST as m_serv_unauth_prov_mode is true \n"))); |
|
3820 |
|
3821 tls_session_type = tls_session_type_eap_fast_server_unauthenticated_provisioning_mode_ADHP; |
|
3822 |
|
3823 // This is the only cipher suite needed in this case. |
|
3824 { |
|
3825 u16_t *tmp_object = new u16_t; |
|
3826 if (tmp_object == 0) |
|
3827 { |
|
3828 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
3829 return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error); |
|
3830 } |
|
3831 *tmp_object = eap_htons(tls_cipher_suites_TLS_DH_anon_WITH_AES_128_CBC_SHA); |
|
3832 |
|
3833 status = cipher_suites.add_object(tmp_object, true); |
|
3834 if (status != eap_status_ok) |
|
3835 { |
|
3836 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
3837 return EAP_STATUS_RETURN(m_am_tools, status); |
|
3838 } |
|
3839 } |
|
3840 |
|
3841 |
|
3842 } |
|
3843 else |
|
3844 #endif // #if defined(USE_FAST_EAP_TYPE) |
|
3845 |
|
3846 { |
|
3847 // This is the normal case for all EAP types (for EAP-FAST with m_serv_unauth_prov_mode = false). |
|
3848 |
|
3849 if (m_own_certificate == 0 |
|
3850 && m_ca_certificate == 0) |
|
3851 { |
|
3852 // Since there is no user certificate and CA cert has not been read yet |
|
3853 // we need to read the CA cert. |
|
3854 EAP_TRACE_DEBUG( |
|
3855 m_am_tools, |
|
3856 TRACE_FLAGS_DEFAULT, |
|
3857 (EAPL("query_cipher_suites_and_previous_session(): No user or CA certificate. Read CA certificate.\n"))); |
|
3858 |
|
3859 if (m_allowed_ca_certs.Count() != 0) |
|
3860 { |
|
3861 #if defined(USE_FAST_EAP_TYPE) |
|
3862 |
|
3863 if(m_current_eap_type == eap_type_fast) |
|
3864 { |
|
3865 // Exception for EAP-FAST |
|
3866 |
|
3867 EAP_TRACE_DEBUG(m_am_tools, |
|
3868 TRACE_FLAGS_DEFAULT, ( |
|
3869 EAPL("eap_am_type_tls_peap_symbian_c::query_cipher_suites_and_previous_session - No CA certificate but exception for EAP-FAST\n"))); |
|
3870 } |
|
3871 else |
|
3872 #endif // #if defined(USE_FAST_EAP_TYPE) |
|
3873 { |
|
3874 m_state = EHandlingCipherSuiteQuery; |
|
3875 |
|
3876 TRAPD(err, m_cert_if->ReadCACertificateL(m_allowed_ca_certs[0])); |
|
3877 if (err != KErrNone) |
|
3878 { |
|
3879 // Error occurred. Just select all cipher suites. |
|
3880 select_all_cipher_suites = true; |
|
3881 } |
|
3882 else |
|
3883 { |
|
3884 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
3885 return EAP_STATUS_RETURN(m_am_tools, eap_status_pending_request); |
|
3886 } |
|
3887 } |
|
3888 } // End: if (m_allowed_ca_certs.Count() != 0) |
|
3889 } |
|
3890 else if (m_own_certificate != 0) |
|
3891 { |
|
3892 EAP_TRACE_DEBUG( |
|
3893 m_am_tools, |
|
3894 TRACE_FLAGS_DEFAULT, |
|
3895 (EAPL("Selecting cipher suites based on user certificate algorithm.\n"))); |
|
3896 |
|
3897 select_all_cipher_suites = false; |
|
3898 |
|
3899 const CSubjectPublicKeyInfo& public_key = m_own_certificate->PublicKey(); |
|
3900 |
|
3901 certAlgorithm = public_key.AlgorithmId(); |
|
3902 } |
|
3903 else |
|
3904 { |
|
3905 EAP_TRACE_DEBUG( |
|
3906 m_am_tools, |
|
3907 TRACE_FLAGS_DEFAULT, |
|
3908 (EAPL("Selecting cipher suites based on CA certificate algorithm.\n"))); |
|
3909 |
|
3910 select_all_cipher_suites = false; |
|
3911 |
|
3912 const CSubjectPublicKeyInfo& public_key = m_ca_certificate->PublicKey(); |
|
3913 |
|
3914 certAlgorithm = public_key.AlgorithmId(); |
|
3915 } |
|
3916 |
|
3917 // IF cipher suite is allowed |
|
3918 if (m_allowed_cipher_suites.Find(tls_cipher_suites_TLS_RSA_WITH_3DES_EDE_CBC_SHA) != KErrNotFound |
|
3919 // AND the algorithm matches the certificates algorithm |
|
3920 && (select_all_cipher_suites == true |
|
3921 || certAlgorithm == ERSA)) |
|
3922 // THEN add it to list. |
|
3923 { |
|
3924 u16_t *tmp_object = new u16_t; |
|
3925 if (tmp_object == 0) |
|
3926 { |
|
3927 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
3928 return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error); |
|
3929 } |
|
3930 *tmp_object = eap_htons(tls_cipher_suites_TLS_RSA_WITH_3DES_EDE_CBC_SHA); |
|
3931 |
|
3932 status = cipher_suites.add_object(tmp_object, true); |
|
3933 if (status != eap_status_ok) |
|
3934 { |
|
3935 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
3936 return EAP_STATUS_RETURN(m_am_tools, status); |
|
3937 } |
|
3938 } |
|
3939 if (m_allowed_cipher_suites.Find(tls_cipher_suites_TLS_RSA_WITH_AES_128_CBC_SHA) != KErrNotFound |
|
3940 // AND the algorithm matches the certificates algorithm |
|
3941 && (select_all_cipher_suites == true |
|
3942 || certAlgorithm == ERSA)) |
|
3943 // THEN add it to list. |
|
3944 { |
|
3945 u16_t *tmp_object = new u16_t; |
|
3946 if (tmp_object == 0) |
|
3947 { |
|
3948 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
3949 return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error); |
|
3950 } |
|
3951 *tmp_object = eap_htons(tls_cipher_suites_TLS_RSA_WITH_AES_128_CBC_SHA); |
|
3952 |
|
3953 status = cipher_suites.add_object(tmp_object, true); |
|
3954 if (status != eap_status_ok) |
|
3955 { |
|
3956 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
3957 return EAP_STATUS_RETURN(m_am_tools, status); |
|
3958 } |
|
3959 } |
|
3960 if (m_allowed_cipher_suites.Find(tls_cipher_suites_TLS_DHE_DSS_WITH_3DES_EDE_CBC_SHA) != KErrNotFound |
|
3961 // AND the algorithm matches the certificates algorithm |
|
3962 && (select_all_cipher_suites == true |
|
3963 || certAlgorithm == EDSA)) |
|
3964 // THEN add it to list. |
|
3965 { |
|
3966 u16_t *tmp_object = new u16_t; |
|
3967 if (tmp_object == 0) |
|
3968 { |
|
3969 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
3970 return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error); |
|
3971 } |
|
3972 *tmp_object = eap_htons(tls_cipher_suites_TLS_DHE_DSS_WITH_3DES_EDE_CBC_SHA); |
|
3973 |
|
3974 status = cipher_suites.add_object(tmp_object, true); |
|
3975 if (status != eap_status_ok) |
|
3976 { |
|
3977 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
3978 return EAP_STATUS_RETURN(m_am_tools, status); |
|
3979 } |
|
3980 } |
|
3981 if (m_allowed_cipher_suites.Find(tls_cipher_suites_TLS_DHE_DSS_WITH_AES_128_CBC_SHA) != KErrNotFound |
|
3982 // AND the algorithm matches the certificates algorithm |
|
3983 && (select_all_cipher_suites == true |
|
3984 || certAlgorithm == EDSA)) |
|
3985 // THEN add it to list. |
|
3986 { |
|
3987 u16_t *tmp_object = new u16_t; |
|
3988 if (tmp_object == 0) |
|
3989 { |
|
3990 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
3991 return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error); |
|
3992 } |
|
3993 *tmp_object = eap_htons(tls_cipher_suites_TLS_DHE_DSS_WITH_AES_128_CBC_SHA); |
|
3994 |
|
3995 status = cipher_suites.add_object(tmp_object, true); |
|
3996 if (status != eap_status_ok) |
|
3997 { |
|
3998 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
3999 return EAP_STATUS_RETURN(m_am_tools, status); |
|
4000 } |
|
4001 } |
|
4002 if (m_allowed_cipher_suites.Find(tls_cipher_suites_TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA) != KErrNotFound |
|
4003 // AND the algorithm matches the certificates algorithm |
|
4004 && (select_all_cipher_suites == true |
|
4005 || certAlgorithm == ERSA)) |
|
4006 // THEN add it to list. |
|
4007 { |
|
4008 u16_t *tmp_object = new u16_t; |
|
4009 if (tmp_object == 0) |
|
4010 { |
|
4011 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
4012 return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error); |
|
4013 } |
|
4014 *tmp_object = eap_htons(tls_cipher_suites_TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA); |
|
4015 |
|
4016 status = cipher_suites.add_object(tmp_object, true); |
|
4017 if (status != eap_status_ok) |
|
4018 { |
|
4019 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
4020 return EAP_STATUS_RETURN(m_am_tools, status); |
|
4021 } |
|
4022 } |
|
4023 if (m_allowed_cipher_suites.Find(tls_cipher_suites_TLS_DHE_RSA_WITH_AES_128_CBC_SHA) != KErrNotFound |
|
4024 // AND the algorithm matches the certificates algorithm |
|
4025 && (select_all_cipher_suites == true |
|
4026 || certAlgorithm == ERSA)) |
|
4027 // THEN add it to list. |
|
4028 { |
|
4029 u16_t *tmp_object = new u16_t; |
|
4030 if (tmp_object == 0) |
|
4031 { |
|
4032 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
4033 return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error); |
|
4034 } |
|
4035 *tmp_object = eap_htons(tls_cipher_suites_TLS_DHE_RSA_WITH_AES_128_CBC_SHA); |
|
4036 |
|
4037 status = cipher_suites.add_object(tmp_object, true); |
|
4038 if (status != eap_status_ok) |
|
4039 { |
|
4040 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
4041 return EAP_STATUS_RETURN(m_am_tools, status); |
|
4042 } |
|
4043 } |
|
4044 if (m_allowed_cipher_suites.Find(tls_cipher_suites_TLS_RSA_WITH_RC4_128_MD5) != KErrNotFound |
|
4045 // AND the algorithm matches the certificates algorithm |
|
4046 && (select_all_cipher_suites == true |
|
4047 || certAlgorithm == ERSA)) |
|
4048 // THEN add it to list. |
|
4049 { |
|
4050 u16_t *tmp_object = new u16_t; |
|
4051 if (tmp_object == 0) |
|
4052 { |
|
4053 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
4054 return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error); |
|
4055 } |
|
4056 *tmp_object = eap_htons(tls_cipher_suites_TLS_RSA_WITH_RC4_128_MD5); |
|
4057 |
|
4058 status = cipher_suites.add_object(tmp_object, true); |
|
4059 if (status != eap_status_ok) |
|
4060 { |
|
4061 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
4062 return EAP_STATUS_RETURN(m_am_tools, status); |
|
4063 } |
|
4064 } |
|
4065 if (m_allowed_cipher_suites.Find(tls_cipher_suites_TLS_RSA_WITH_RC4_128_SHA) != KErrNotFound |
|
4066 // AND the algorithm matches the certificates algorithm |
|
4067 && (select_all_cipher_suites == true |
|
4068 || certAlgorithm == ERSA)) |
|
4069 // THEN add it to list.) |
|
4070 { |
|
4071 u16_t *tmp_object = new u16_t; |
|
4072 if (tmp_object == 0) |
|
4073 { |
|
4074 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
4075 return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error); |
|
4076 } |
|
4077 *tmp_object = eap_htons(tls_cipher_suites_TLS_RSA_WITH_RC4_128_SHA); |
|
4078 |
|
4079 status = cipher_suites.add_object(tmp_object, true); |
|
4080 if (status != eap_status_ok) |
|
4081 { |
|
4082 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
4083 return EAP_STATUS_RETURN(m_am_tools, status); |
|
4084 } |
|
4085 } |
|
4086 |
|
4087 if (is_session_valid()) |
|
4088 { |
|
4089 EAP_TRACE_DEBUG( |
|
4090 m_am_tools, |
|
4091 TRACE_FLAGS_DEFAULT, |
|
4092 (EAPL("Trying to resume previous session as previous session is still valid\n"))); |
|
4093 |
|
4094 // OK, previous session will be restored. |
|
4095 |
|
4096 // Read database fields. |
|
4097 { |
|
4098 eap_status_e status = type_configure_read( |
|
4099 cf_str_EAP_TLS_PEAP_saved_session_id.get_field(), |
|
4100 &session_id); |
|
4101 if (status != eap_status_ok |
|
4102 || session_id.get_is_valid_data() == false) |
|
4103 { |
|
4104 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
4105 return EAP_STATUS_RETURN(m_am_tools, eap_status_illegal_configure_field); |
|
4106 } |
|
4107 } |
|
4108 |
|
4109 { |
|
4110 eap_status_e status = type_configure_read( |
|
4111 cf_str_EAP_TLS_PEAP_saved_master_secret.get_field(), |
|
4112 &master_secret); |
|
4113 if (status != eap_status_ok |
|
4114 || master_secret.get_is_valid_data() == false) |
|
4115 { |
|
4116 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
4117 return EAP_STATUS_RETURN(m_am_tools, eap_status_illegal_configure_field); |
|
4118 } |
|
4119 } |
|
4120 |
|
4121 { |
|
4122 eap_variable_data_c saved_cipher_suite(m_am_tools); |
|
4123 |
|
4124 eap_status_e status = type_configure_read( |
|
4125 cf_str_EAP_TLS_PEAP_saved_cipher_suite.get_field(), |
|
4126 &saved_cipher_suite); |
|
4127 if (status == eap_status_ok |
|
4128 && saved_cipher_suite.get_is_valid_data() == true |
|
4129 && saved_cipher_suite.get_data_length() == sizeof(u32_t) |
|
4130 && saved_cipher_suite.get_data(sizeof(u32_t)) != 0) |
|
4131 { |
|
4132 // OK |
|
4133 used_cipher_suite = static_cast<tls_cipher_suites_e>(*(reinterpret_cast<u32_t *>(saved_cipher_suite.get_data(sizeof(u32_t))))); |
|
4134 |
|
4135 u16_t tmp_object = eap_htons(static_cast<u16_t> (used_cipher_suite)); |
|
4136 |
|
4137 tls_session_type = tls_session_type_original_session_resumption; |
|
4138 |
|
4139 if( 0 > find_simple<u16_t>( &cipher_suites, |
|
4140 &tmp_object, |
|
4141 m_am_tools ) ) |
|
4142 { |
|
4143 EAP_TRACE_DEBUG( |
|
4144 m_am_tools, |
|
4145 TRACE_FLAGS_DEFAULT, |
|
4146 (EAPL("TLS: %s: cipher suite of the resumed session is NOT included in the cipher_suites list.\n"), |
|
4147 (m_is_client == true ? "client": "server"))); |
|
4148 |
|
4149 used_cipher_suite = tls_cipher_suites_TLS_NULL_WITH_NULL_NULL; |
|
4150 |
|
4151 master_secret.reset(); |
|
4152 |
|
4153 session_id.reset(); |
|
4154 } |
|
4155 } |
|
4156 } |
|
4157 } |
|
4158 |
|
4159 if(used_cipher_suite == tls_cipher_suites_TLS_NULL_WITH_NULL_NULL) |
|
4160 { |
|
4161 EAP_TRACE_DEBUG( |
|
4162 m_am_tools, |
|
4163 TRACE_FLAGS_DEFAULT, |
|
4164 (EAPL("TLS: %s: query_cipher_suites_and_previous_session(): creates new session.\n"), |
|
4165 (m_is_client == true ? "client": "server"))); |
|
4166 |
|
4167 TRAPD(err, ResetSessionIdL()); |
|
4168 if (err != KErrNone) |
|
4169 { |
|
4170 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
4171 return EAP_STATUS_RETURN(m_am_tools, eap_status_process_general_error); |
|
4172 } |
|
4173 |
|
4174 tls_session_type = tls_session_type_full_authentication; |
|
4175 } |
|
4176 |
|
4177 } // End : if(m_current_eap_type == eap_type_fast && |
|
4178 // m_serv_unauth_prov_mode == true) |
|
4179 |
|
4180 |
|
4181 // Compression methods. TLS supports only null compression at the moment. |
|
4182 eap_array_c<u8_t> compression_methods(m_am_tools); |
|
4183 { |
|
4184 u8_t *tmp_object = new u8_t; |
|
4185 if (tmp_object == 0) |
|
4186 { |
|
4187 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
4188 return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error); |
|
4189 } |
|
4190 *tmp_object = tls_compression_method_null; |
|
4191 status = compression_methods.add_object(tmp_object, true); |
|
4192 if (status != eap_status_ok) |
|
4193 { |
|
4194 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
4195 return EAP_STATUS_RETURN(m_am_tools, status); |
|
4196 } |
|
4197 } |
|
4198 |
|
4199 status = get_tls_am_partner()->complete_query_cipher_suites_and_previous_session( |
|
4200 tls_session_type, |
|
4201 &cipher_suites, |
|
4202 &compression_methods, |
|
4203 #if defined(USE_EAP_TLS_SESSION_TICKET) |
|
4204 0, |
|
4205 #endif // #if defined(USE_EAP_TLS_SESSION_TICKET) |
|
4206 &session_id, |
|
4207 &master_secret, |
|
4208 used_cipher_suite, |
|
4209 eap_status_ok); |
|
4210 if (status == eap_status_ok || |
|
4211 status == eap_status_pending_request) |
|
4212 { |
|
4213 status = eap_status_completed_request; |
|
4214 } |
|
4215 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
4216 return EAP_STATUS_RETURN(m_am_tools, status); |
|
4217 } |
|
4218 |
|
4219 //-------------------------------------------------- |
|
4220 |
|
4221 #if defined(USE_EAP_TLS_SESSION_TICKET) |
|
4222 |
|
4223 EAP_FUNC_EXPORT eap_status_e eap_am_type_tls_peap_symbian_c::query_new_session_ticket() |
|
4224 { |
|
4225 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
4226 |
|
4227 EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("\n"))); |
|
4228 EAP_TRACE_DEBUG( |
|
4229 m_am_tools, |
|
4230 TRACE_FLAGS_DEFAULT, |
|
4231 (EAPL("TLS: %s: message_function: query_new_session_ticket()\n"), |
|
4232 (m_is_client == true ? "client": "server"))); |
|
4233 |
|
4234 EAP_ASSERT_ALWAYS(m_is_client == false); |
|
4235 |
|
4236 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
4237 return EAP_STATUS_RETURN(m_am_tools, eap_status_ok); |
|
4238 } |
|
4239 |
|
4240 #endif //#if defined(USE_EAP_TLS_SESSION_TICKET) |
|
4241 |
|
4242 //-------------------------------------------------- |
|
4243 |
|
4244 EAP_FUNC_EXPORT eap_status_e eap_am_type_tls_peap_symbian_c::select_cipher_suite_and_check_session_id( |
|
4245 EAP_TEMPLATE_CONST eap_array_c<u16_t> * const cipher_suite_proposal, |
|
4246 const eap_variable_data_c * const session_id |
|
4247 #if defined(USE_EAP_TLS_SESSION_TICKET) |
|
4248 , const tls_extension_c * const /* session_ticket */ |
|
4249 #endif //#if defined(USE_EAP_TLS_SESSION_TICKET) |
|
4250 ) |
|
4251 { |
|
4252 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
4253 |
|
4254 EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("\n"))); |
|
4255 EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("TLS: %s: function: select_cipher_suite_and_check_session_id()\n"), |
|
4256 (m_is_client == true ? "client": "server"))); |
|
4257 |
|
4258 EAP_ASSERT_ALWAYS(m_is_client == false); |
|
4259 |
|
4260 eap_status_e status = eap_status_illegal_payload; |
|
4261 u16_t *tmp_object = 0; |
|
4262 |
|
4263 tls_session_type_e tls_session_type(tls_session_type_full_authentication); |
|
4264 |
|
4265 for (u32_t ind = 0; ind < cipher_suite_proposal->get_object_count(); ind++) |
|
4266 { |
|
4267 tmp_object = cipher_suite_proposal->get_object(ind); |
|
4268 if (tmp_object == 0) |
|
4269 { |
|
4270 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
4271 return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error); |
|
4272 } |
|
4273 |
|
4274 if (m_allowed_cipher_suites.Find(*tmp_object) != KErrNotFound) |
|
4275 { |
|
4276 // Read stored session id |
|
4277 eap_variable_data_c stored_session_id(m_am_tools); |
|
4278 eap_variable_data_c stored_master_secret(m_am_tools); |
|
4279 tls_cipher_suites_e stored_cipher_suite(tls_cipher_suites_TLS_NULL_WITH_NULL_NULL); |
|
4280 |
|
4281 eap_variable_data_c count_of_session_resumes(m_am_tools); |
|
4282 |
|
4283 { |
|
4284 status = type_configure_read( |
|
4285 cf_str_EAP_TLS_PEAP_saved_session_id.get_field(), |
|
4286 &stored_session_id); |
|
4287 if (status != eap_status_ok |
|
4288 || stored_session_id.get_is_valid_data() == false) |
|
4289 { |
|
4290 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
4291 return EAP_STATUS_RETURN(m_am_tools, eap_status_illegal_configure_field); |
|
4292 } |
|
4293 } |
|
4294 |
|
4295 if (session_id != 0 |
|
4296 && session_id->get_is_valid_data() == true |
|
4297 && session_id->compare(&stored_session_id) == 0 |
|
4298 && is_session_valid()) |
|
4299 { |
|
4300 // OK, previous session will be restored. |
|
4301 |
|
4302 // Read database fields. |
|
4303 { |
|
4304 eap_status_e status = type_configure_read( |
|
4305 cf_str_EAP_TLS_PEAP_saved_session_id.get_field(), |
|
4306 &stored_session_id); |
|
4307 if (status != eap_status_ok |
|
4308 || stored_session_id.get_is_valid_data() == false) |
|
4309 { |
|
4310 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
4311 return EAP_STATUS_RETURN(m_am_tools, eap_status_illegal_configure_field); |
|
4312 } |
|
4313 } |
|
4314 |
|
4315 { |
|
4316 eap_status_e status = type_configure_read( |
|
4317 cf_str_EAP_TLS_PEAP_saved_master_secret.get_field(), |
|
4318 &stored_master_secret); |
|
4319 if (status != eap_status_ok |
|
4320 || stored_master_secret.get_is_valid_data() == false) |
|
4321 { |
|
4322 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
4323 return EAP_STATUS_RETURN(m_am_tools, eap_status_illegal_configure_field); |
|
4324 } |
|
4325 } |
|
4326 |
|
4327 { |
|
4328 eap_variable_data_c saved_cipher_suite(m_am_tools); |
|
4329 |
|
4330 eap_status_e status = type_configure_read( |
|
4331 cf_str_EAP_TLS_PEAP_saved_cipher_suite.get_field(), |
|
4332 &saved_cipher_suite); |
|
4333 if (status == eap_status_ok |
|
4334 && saved_cipher_suite.get_is_valid_data() == true |
|
4335 && saved_cipher_suite.get_data_length() == sizeof(u32_t) |
|
4336 && saved_cipher_suite.get_data(sizeof(u32_t)) != 0) |
|
4337 { |
|
4338 // OK |
|
4339 |
|
4340 stored_cipher_suite = static_cast<tls_cipher_suites_e>(*(reinterpret_cast<u32_t *>(saved_cipher_suite.get_data(sizeof(u32_t))))); |
|
4341 } |
|
4342 else |
|
4343 { |
|
4344 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
4345 return EAP_STATUS_RETURN(m_am_tools, eap_status_illegal_configure_field); |
|
4346 } |
|
4347 } |
|
4348 |
|
4349 tls_session_type = tls_session_type_original_session_resumption; |
|
4350 |
|
4351 } |
|
4352 else |
|
4353 { |
|
4354 { |
|
4355 stored_session_id.reset(); |
|
4356 |
|
4357 TRAPD(err, WriteBinaryParamL( |
|
4358 cf_str_EAP_TLS_PEAP_saved_session_id.get_field()->get_field(), |
|
4359 cf_str_EAP_TLS_PEAP_saved_session_id.get_field()->get_field_length(), |
|
4360 &stored_session_id)); |
|
4361 if (err != KErrNone) |
|
4362 { |
|
4363 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
4364 return EAP_STATUS_RETURN(m_am_tools, eap_status_process_general_error); |
|
4365 } |
|
4366 } |
|
4367 |
|
4368 { |
|
4369 stored_master_secret.reset(); |
|
4370 |
|
4371 TRAPD(err, WriteBinaryParamL( |
|
4372 cf_str_EAP_TLS_PEAP_saved_master_secret.get_field()->get_field(), |
|
4373 cf_str_EAP_TLS_PEAP_saved_master_secret.get_field()->get_field_length(), |
|
4374 &stored_master_secret)); |
|
4375 if (err != KErrNone) |
|
4376 { |
|
4377 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
4378 return EAP_STATUS_RETURN(m_am_tools, eap_status_process_general_error); |
|
4379 } |
|
4380 } |
|
4381 |
|
4382 { |
|
4383 TRAPD(err, WriteIntParamL( |
|
4384 cf_str_EAP_TLS_PEAP_saved_cipher_suite.get_field()->get_field(), |
|
4385 cf_str_EAP_TLS_PEAP_saved_cipher_suite.get_field()->get_field_length(), |
|
4386 tls_cipher_suites_TLS_NULL_WITH_NULL_NULL)); |
|
4387 if (err != KErrNone) |
|
4388 { |
|
4389 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
4390 return EAP_STATUS_RETURN(m_am_tools, eap_status_process_general_error); |
|
4391 } |
|
4392 } |
|
4393 } |
|
4394 |
|
4395 if (stored_cipher_suite != tls_cipher_suites_TLS_NULL_WITH_NULL_NULL) |
|
4396 { |
|
4397 // We got saved cipher suite from previous session |
|
4398 m_cipher_suite = stored_cipher_suite; |
|
4399 } |
|
4400 else |
|
4401 { |
|
4402 // Use the first cipher suite the client offered |
|
4403 m_cipher_suite = static_cast<tls_cipher_suites_e>(*tmp_object); |
|
4404 } |
|
4405 |
|
4406 status = get_tls_am_partner()->complete_select_cipher_suite_and_check_session_id( |
|
4407 tls_session_type, |
|
4408 static_cast<u8_t>(m_cipher_suite), |
|
4409 &stored_session_id, |
|
4410 &stored_master_secret, |
|
4411 #if defined(USE_EAP_TLS_SESSION_TICKET) |
|
4412 0, |
|
4413 #endif // #if defined(USE_EAP_TLS_SESSION_TICKET) |
|
4414 eap_status_ok); |
|
4415 |
|
4416 break; |
|
4417 } |
|
4418 } // for() |
|
4419 |
|
4420 if (status == eap_status_ok || |
|
4421 status == eap_status_pending_request) |
|
4422 { |
|
4423 status = eap_status_completed_request; |
|
4424 } |
|
4425 |
|
4426 if (status != eap_status_completed_request) |
|
4427 { |
|
4428 // Could not find matching cipher suite |
|
4429 EAP_TRACE_ERROR(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("ERROR: Server: Could not find matching cipher suite in client's proposal.\n"))); |
|
4430 } |
|
4431 |
|
4432 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
4433 return EAP_STATUS_RETURN(m_am_tools, status); |
|
4434 } |
|
4435 |
|
4436 //-------------------------------------------------- |
|
4437 |
|
4438 EAP_FUNC_EXPORT eap_status_e eap_am_type_tls_peap_symbian_c::verify_certificate_chain( |
|
4439 EAP_TEMPLATE_CONST eap_array_c<eap_variable_data_c> * const certificate_chain, |
|
4440 const tls_cipher_suites_e required_cipher_suite) |
|
4441 { |
|
4442 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
4443 EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("\n"))); |
|
4444 EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("TLS: %s: message_function: verify_certificate_chain_and_query_public_key()\n"), |
|
4445 (m_is_client == true ? "client": "server"))); |
|
4446 |
|
4447 EAP_ASSERT_ALWAYS(certificate_chain->get_object_count() > 0); |
|
4448 |
|
4449 eap_status_e status(eap_status_ok); |
|
4450 |
|
4451 TRAPD(err, verify_certificate_chainL(certificate_chain, required_cipher_suite)); |
|
4452 if (err != KErrNone) |
|
4453 { |
|
4454 if (err == KErrArgument) |
|
4455 { |
|
4456 status = eap_status_illegal_certificate; |
|
4457 } |
|
4458 else |
|
4459 { |
|
4460 status = m_am_tools->convert_am_error_to_eapol_error(err); |
|
4461 } |
|
4462 } |
|
4463 |
|
4464 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
4465 return EAP_STATUS_RETURN(m_am_tools, status); |
|
4466 } |
|
4467 |
|
4468 void eap_am_type_tls_peap_symbian_c::verify_certificate_chainL( |
|
4469 EAP_TEMPLATE_CONST eap_array_c<eap_variable_data_c> * const certificate_chain, |
|
4470 const tls_cipher_suites_e required_cipher_suite) |
|
4471 { |
|
4472 EAP_TRACE_DEBUG(m_am_tools, |
|
4473 TRACE_FLAGS_DEFAULT, |
|
4474 (EAPL("eap_am_type_tls_peap_symbian_c::verify_certificate_chainL: Number of certificates in chain=%d\n"), |
|
4475 certificate_chain->get_object_count())); |
|
4476 |
|
4477 eap_status_e status(eap_status_process_general_error); |
|
4478 if (m_is_client) |
|
4479 { |
|
4480 m_cipher_suite = required_cipher_suite; |
|
4481 } |
|
4482 |
|
4483 // Verify that server certificate's realm matches with our identity realm |
|
4484 // If server does not verify client then we don't necessarily have a certificate |
|
4485 // and thus we cannot verify server here. |
|
4486 if (m_is_client |
|
4487 && m_verify_certificate_realm == true |
|
4488 && (m_own_certificate != 0 |
|
4489 || (m_use_manual_realm == true |
|
4490 && m_manual_realm.get_is_valid_data() == true))) |
|
4491 { |
|
4492 eap_variable_data_c client_subject_realm(m_am_tools); |
|
4493 eap_variable_data_c manual_client_subject_realm(m_am_tools); |
|
4494 eap_variable_data_c client_issuer_realm(m_am_tools); |
|
4495 |
|
4496 if (m_own_certificate != 0) |
|
4497 { |
|
4498 status = get_realms_from_certificate( |
|
4499 m_own_certificate, |
|
4500 &client_subject_realm, |
|
4501 &client_issuer_realm); |
|
4502 if (status != eap_status_ok) |
|
4503 { |
|
4504 // Could not find realms... Give up. |
|
4505 EAP_TRACE_ERROR(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("ERROR: EAP-TLS: Could not find realm from client certificate.\n"))); |
|
4506 User::Leave(KErrArgument); |
|
4507 } |
|
4508 } |
|
4509 else |
|
4510 { |
|
4511 status = client_subject_realm.init(0); |
|
4512 if (status != eap_status_ok) |
|
4513 { |
|
4514 User::Leave(m_am_tools->convert_eapol_error_to_am_error(EAP_STATUS_RETURN(m_am_tools, status))); |
|
4515 } |
|
4516 |
|
4517 client_subject_realm.set_is_valid(); |
|
4518 |
|
4519 status = client_issuer_realm.init(0); |
|
4520 if (status != eap_status_ok) |
|
4521 { |
|
4522 User::Leave(m_am_tools->convert_eapol_error_to_am_error(EAP_STATUS_RETURN(m_am_tools, status))); |
|
4523 } |
|
4524 |
|
4525 client_issuer_realm.set_is_valid(); |
|
4526 } |
|
4527 |
|
4528 if (m_use_manual_realm == true |
|
4529 && m_manual_realm.get_is_valid_data() == true) |
|
4530 { |
|
4531 status = manual_client_subject_realm.set_copy_of_buffer(&m_manual_realm); |
|
4532 if (status != eap_status_ok) |
|
4533 { |
|
4534 User::Leave(KErrNoMemory); |
|
4535 } |
|
4536 } |
|
4537 |
|
4538 eap_variable_data_c server_subject_realm(m_am_tools); |
|
4539 eap_variable_data_c server_issuer_realm(m_am_tools); |
|
4540 |
|
4541 eap_variable_data_c* cert; |
|
4542 cert = certificate_chain->get_object(0); |
|
4543 |
|
4544 if( cert == NULL ) |
|
4545 { |
|
4546 EAP_TRACE_ERROR( |
|
4547 m_am_tools, |
|
4548 TRACE_FLAGS_DEFAULT, |
|
4549 (EAPL("ERROR: EAP-TLS: No certs in certificate_chain\n"))); |
|
4550 |
|
4551 User::Leave(KErrArgument); |
|
4552 } |
|
4553 |
|
4554 TPtr8 ptr( |
|
4555 cert->get_data(cert->get_data_length()), |
|
4556 cert->get_data_length(), |
|
4557 cert->get_data_length()); |
|
4558 CX509Certificate* server_certificate = CX509Certificate::NewL(ptr); |
|
4559 |
|
4560 if( server_certificate == NULL ) |
|
4561 { |
|
4562 EAP_TRACE_ERROR( |
|
4563 m_am_tools, |
|
4564 TRACE_FLAGS_DEFAULT, |
|
4565 (EAPL("ERROR: EAP-TLS: No memory for server_certificate\n"))); |
|
4566 |
|
4567 User::Leave(KErrNoMemory); |
|
4568 } |
|
4569 |
|
4570 CleanupStack::PushL(server_certificate); |
|
4571 |
|
4572 status = get_realms_from_certificate( |
|
4573 server_certificate, |
|
4574 &server_subject_realm, |
|
4575 &server_issuer_realm); |
|
4576 if (status != eap_status_ok |
|
4577 || server_subject_realm.get_is_valid_data() == false |
|
4578 || server_issuer_realm.get_is_valid_data() == false) |
|
4579 { |
|
4580 // Could not find realms... Give up. |
|
4581 EAP_TRACE_ERROR(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("ERROR: EAP-TLS: Could not find realm from server certificate.\n"))); |
|
4582 User::Leave(KErrArgument); |
|
4583 } |
|
4584 CleanupStack::PopAndDestroy(server_certificate); |
|
4585 |
|
4586 if (client_subject_realm.get_is_valid_data() == true) |
|
4587 { |
|
4588 EAP_TRACE_DATA_DEBUG(m_am_tools, |
|
4589 TRACE_FLAGS_DEFAULT, (EAPL("Client subject realm:"), |
|
4590 client_subject_realm.get_data(client_subject_realm.get_data_length()), |
|
4591 client_subject_realm.get_data_length())); |
|
4592 } |
|
4593 else |
|
4594 { |
|
4595 EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("Client subject realm is empty.\n"))); |
|
4596 } |
|
4597 |
|
4598 if (manual_client_subject_realm.get_is_valid_data() == true) |
|
4599 { |
|
4600 EAP_TRACE_DATA_DEBUG(m_am_tools, |
|
4601 TRACE_FLAGS_DEFAULT, (EAPL("Client manual realm:"), |
|
4602 manual_client_subject_realm.get_data(manual_client_subject_realm.get_data_length()), |
|
4603 manual_client_subject_realm.get_data_length())); |
|
4604 } |
|
4605 else |
|
4606 { |
|
4607 EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("Client manual realm is empty.\n"))); |
|
4608 } |
|
4609 |
|
4610 EAP_TRACE_DATA_DEBUG(m_am_tools, |
|
4611 TRACE_FLAGS_DEFAULT, (EAPL("Server subject realm:"), |
|
4612 server_subject_realm.get_data(server_subject_realm.get_data_length()), |
|
4613 server_subject_realm.get_data_length())); |
|
4614 |
|
4615 EAP_TRACE_DATA_DEBUG(m_am_tools, |
|
4616 TRACE_FLAGS_DEFAULT, (EAPL("Server issuer realm:"), |
|
4617 server_issuer_realm.get_data(server_issuer_realm.get_data_length()), |
|
4618 server_issuer_realm.get_data_length())); |
|
4619 |
|
4620 // First check exact match with client subject realm and server subject and issuer realms |
|
4621 if (client_subject_realm.get_is_valid_data() == false |
|
4622 || (client_subject_realm.get_is_valid_data() == true |
|
4623 && client_subject_realm.compare(&server_subject_realm) != 0 |
|
4624 && client_subject_realm.compare(&server_issuer_realm) != 0)) |
|
4625 { |
|
4626 // Check if manual realm matches |
|
4627 if (manual_client_subject_realm.get_is_valid_data() == false |
|
4628 || (manual_client_subject_realm.get_is_valid_data() == true |
|
4629 && manual_client_subject_realm.compare(&server_subject_realm) != 0 |
|
4630 && manual_client_subject_realm.compare(&server_issuer_realm) != 0)) |
|
4631 { |
|
4632 // Realms did not match! Are we allowed to do relaxed subdomain checking? |
|
4633 if (m_allow_subdomain_matching == true) |
|
4634 { |
|
4635 |
|
4636 TPtr8 client_subject_ptr( |
|
4637 client_subject_realm.get_data(client_subject_realm.get_data_length()), |
|
4638 client_subject_realm.get_data_length(), |
|
4639 client_subject_realm.get_data_length()); |
|
4640 |
|
4641 TPtr8 server_subject_ptr( |
|
4642 server_subject_realm.get_data(server_subject_realm.get_data_length()), |
|
4643 server_subject_realm.get_data_length(), |
|
4644 server_subject_realm.get_data_length()); |
|
4645 |
|
4646 TPtr8 server_issuer_ptr( |
|
4647 server_issuer_realm.get_data(server_issuer_realm.get_data_length()), |
|
4648 server_issuer_realm.get_data_length(), |
|
4649 server_issuer_realm.get_data_length()); |
|
4650 |
|
4651 if (client_subject_ptr.Length() == 0 |
|
4652 || (server_subject_ptr.Find(client_subject_ptr) == KErrNotFound |
|
4653 && server_issuer_ptr.Find(client_subject_ptr) == KErrNotFound)) |
|
4654 { |
|
4655 // still not ok |
|
4656 |
|
4657 // One more test: subdomain matching with manual realm |
|
4658 if (manual_client_subject_realm.get_is_valid_data() == true) |
|
4659 { |
|
4660 TPtr8 manual_client_subject_ptr( |
|
4661 manual_client_subject_realm.get_data(manual_client_subject_realm.get_data_length()), |
|
4662 manual_client_subject_realm.get_data_length(), |
|
4663 manual_client_subject_realm.get_data_length()); |
|
4664 |
|
4665 if (manual_client_subject_ptr.Length() == 0 |
|
4666 || (server_subject_ptr.Find(manual_client_subject_ptr) == KErrNotFound |
|
4667 && server_issuer_ptr.Find(manual_client_subject_ptr) == KErrNotFound)) |
|
4668 { |
|
4669 EAP_TRACE_ERROR( |
|
4670 m_am_tools, |
|
4671 TRACE_FLAGS_DEFAULT, |
|
4672 (EAPL("ERROR: EAP-TLS: Client and server realms do not match.\n"))); |
|
4673 |
|
4674 send_error_notification(eap_status_realm_check_failed); |
|
4675 |
|
4676 User::Leave(KErrArgument); |
|
4677 } |
|
4678 } |
|
4679 else |
|
4680 { |
|
4681 EAP_TRACE_ERROR( |
|
4682 m_am_tools, |
|
4683 TRACE_FLAGS_DEFAULT, |
|
4684 (EAPL("ERROR: EAP-TLS: Client and server realms do not match.\n"))); |
|
4685 |
|
4686 send_error_notification(eap_status_realm_check_failed); |
|
4687 |
|
4688 User::Leave(KErrArgument); |
|
4689 } |
|
4690 } |
|
4691 } |
|
4692 else |
|
4693 { |
|
4694 EAP_TRACE_ERROR( |
|
4695 m_am_tools, |
|
4696 TRACE_FLAGS_DEFAULT, |
|
4697 (EAPL("ERROR: EAP-TLS: Client and server realms do not match.\n"))); |
|
4698 |
|
4699 send_error_notification(eap_status_realm_check_failed); |
|
4700 |
|
4701 User::Leave(KErrArgument); |
|
4702 } |
|
4703 } |
|
4704 } |
|
4705 EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("Server certificate realm verification OK.\n"))); |
|
4706 } |
|
4707 |
|
4708 HBufC8* chain = HBufC8::NewL(0); |
|
4709 HBufC8* temp; |
|
4710 eap_variable_data_c* cert; |
|
4711 |
|
4712 for (u32_t i = 0; i < certificate_chain->get_object_count(); i++) |
|
4713 { |
|
4714 cert = certificate_chain->get_object(i); |
|
4715 |
|
4716 if( cert == NULL ) |
|
4717 { |
|
4718 EAP_TRACE_ERROR( |
|
4719 m_am_tools, |
|
4720 TRACE_FLAGS_DEFAULT, |
|
4721 (EAPL("ERROR: EAP-TLS: Problem in certificate_chain\n"))); |
|
4722 |
|
4723 User::Leave(KErrArgument); |
|
4724 } |
|
4725 |
|
4726 #if defined(_DEBUG) || defined(DEBUG) |
|
4727 |
|
4728 TPtr8 certPtr( |
|
4729 cert->get_data(cert->get_data_length()), |
|
4730 cert->get_data_length(), |
|
4731 cert->get_data_length()); |
|
4732 CX509Certificate* x509Cert = CX509Certificate::NewL(certPtr); |
|
4733 |
|
4734 if( x509Cert != NULL ) |
|
4735 { |
|
4736 CleanupStack::PushL(x509Cert); |
|
4737 |
|
4738 TKeyIdentifier KeyIdentifier = x509Cert->KeyIdentifierL(); |
|
4739 |
|
4740 EAP_TRACE_DATA_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("Key identifier is"), |
|
4741 KeyIdentifier.Ptr(), |
|
4742 KeyIdentifier.Size())); |
|
4743 |
|
4744 // This is for subject key id. |
|
4745 const CX509CertExtension* certExt = x509Cert->Extension(KSubjectKeyId); |
|
4746 |
|
4747 if (certExt) |
|
4748 { |
|
4749 const CX509SubjectKeyIdExt* subKeyExt = CX509SubjectKeyIdExt::NewLC(certExt->Data()); |
|
4750 EAP_UNREFERENCED_PARAMETER(subKeyExt); |
|
4751 |
|
4752 EAP_TRACE_DATA_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("The Subject key Id is:"), |
|
4753 subKeyExt->KeyId().Ptr(), |
|
4754 subKeyExt->KeyId().Size())); |
|
4755 |
|
4756 CleanupStack::PopAndDestroy(); // subKeyExt |
|
4757 } |
|
4758 else |
|
4759 { |
|
4760 EAP_TRACE_ERROR(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("ERROR: verify_certificate_chainL - No extension for this certificate\n"))); |
|
4761 } |
|
4762 |
|
4763 CleanupStack::PopAndDestroy(x509Cert); |
|
4764 } |
|
4765 |
|
4766 #endif |
|
4767 |
|
4768 CleanupStack::PushL(chain); |
|
4769 temp = chain->ReAllocL(chain->Length() + cert->get_data_length()); |
|
4770 chain = temp; |
|
4771 TPtr8 ptr = chain->Des(); |
|
4772 ptr.Append(cert->get_data(cert->get_data_length()), cert->get_data_length()); |
|
4773 if (i == 0) |
|
4774 { |
|
4775 // This is the peer certificate. Save it. |
|
4776 if (m_peer_certificate != 0) |
|
4777 { |
|
4778 delete m_peer_certificate; |
|
4779 } |
|
4780 m_peer_certificate = CX509Certificate::NewL(ptr); |
|
4781 } |
|
4782 CleanupStack::Pop(); |
|
4783 } |
|
4784 CleanupStack::PushL(chain); |
|
4785 TPtr8 certChain = chain->Des(); |
|
4786 m_cert_if->ValidateChainL(certChain, m_allowed_ca_certs); |
|
4787 |
|
4788 CleanupStack::PopAndDestroy(); |
|
4789 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
4790 // This returns eap_status_pending_request |
|
4791 User::Leave(KErrCompletion); |
|
4792 |
|
4793 } |
|
4794 |
|
4795 |
|
4796 void eap_am_type_tls_peap_symbian_c::complete_validate_chain( |
|
4797 CPKIXValidationResult& aValidationResult, eap_status_e aStatus) |
|
4798 { |
|
4799 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
4800 |
|
4801 if(aStatus != eap_status_ok) |
|
4802 { |
|
4803 get_tls_am_partner()->complete_verify_certificate_chain(aStatus); |
|
4804 return; |
|
4805 } |
|
4806 |
|
4807 eap_status_e result; |
|
4808 if (aValidationResult.Error().iReason == EValidatedOK) |
|
4809 { |
|
4810 EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, |
|
4811 (EAPL("Certificate chain validation OK. Reason: %d\n"), |
|
4812 aValidationResult.Error().iReason)); |
|
4813 result = eap_status_ok; |
|
4814 } |
|
4815 else |
|
4816 { |
|
4817 if (aValidationResult.Error().iReason == EDateOutOfRange) |
|
4818 { |
|
4819 send_error_notification(eap_status_certificate_expired); |
|
4820 // Ignore error on purpose |
|
4821 } |
|
4822 else |
|
4823 { |
|
4824 send_error_notification(eap_status_illegal_certificate); |
|
4825 // Ignore error on purpose |
|
4826 } |
|
4827 |
|
4828 EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, |
|
4829 (EAPL("ERROR: Certificate chain validation FAILED. Reason: %d\n"), |
|
4830 aValidationResult.Error().iReason)); |
|
4831 |
|
4832 result = eap_status_illegal_certificate; |
|
4833 } |
|
4834 |
|
4835 // Copy the public key |
|
4836 const CSubjectPublicKeyInfo& publicKey = m_peer_certificate->PublicKey(); |
|
4837 TPtrC8 ptr = publicKey.KeyData(); |
|
4838 m_peer_public_key.reset(); |
|
4839 eap_status_e status = m_peer_public_key.set_copy_of_buffer(ptr.Ptr(), ptr.Length()); |
|
4840 if (status != eap_status_ok) |
|
4841 { |
|
4842 EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("ERROR: complete_validate_chain: could not allocate memory."))); |
|
4843 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
4844 return; |
|
4845 } |
|
4846 |
|
4847 get_tls_am_partner()->complete_verify_certificate_chain(result); |
|
4848 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
4849 } |
|
4850 |
|
4851 #if defined(USE_FAST_EAP_TYPE) |
|
4852 #if defined(USE_EAP_CONFIGURATION_TO_SKIP_USER_INTERACTIONS) |
|
4853 eap_status_e eap_am_type_tls_peap_symbian_c::ReadFileConfig() |
|
4854 { |
|
4855 eap_status_e status = eap_status_ok; |
|
4856 |
|
4857 eap_am_file_input_symbian_c * const fileio = new eap_am_file_input_symbian_c(m_am_tools); |
|
4858 |
|
4859 eap_automatic_variable_c<eap_am_file_input_symbian_c> automatic_fileio(m_am_tools, fileio); |
|
4860 |
|
4861 if (fileio != 0 |
|
4862 && fileio->get_is_valid() == true) |
|
4863 { |
|
4864 EAP_TRACE_DEBUG( |
|
4865 m_am_tools, |
|
4866 TRACE_FLAGS_DEFAULT, |
|
4867 (EAPL("Initialize file configuration.\n"))); |
|
4868 |
|
4869 eap_variable_data_c file_name_c_data(m_am_tools); |
|
4870 |
|
4871 { |
|
4872 #if defined(EAPOL_SYMBIAN_VERSION_7_0_s) |
|
4873 eap_const_string const FILECONFIG_FILENAME_C |
|
4874 = "c:\\system\\data\\eap.conf"; |
|
4875 #else |
|
4876 eap_const_string const FILECONFIG_FILENAME_C |
|
4877 = "c:\\private\\101F8EC5\\eap.conf"; |
|
4878 #endif |
|
4879 |
|
4880 status = file_name_c_data.set_copy_of_buffer( |
|
4881 FILECONFIG_FILENAME_C, |
|
4882 m_am_tools->strlen(FILECONFIG_FILENAME_C)); |
|
4883 if (status != eap_status_ok) |
|
4884 { |
|
4885 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
4886 return EAP_STATUS_RETURN(m_am_tools, status); |
|
4887 } |
|
4888 |
|
4889 status = file_name_c_data.add_end_null(); |
|
4890 if (status != eap_status_ok) |
|
4891 { |
|
4892 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
4893 return EAP_STATUS_RETURN(m_am_tools, status); |
|
4894 } |
|
4895 } |
|
4896 |
|
4897 eap_variable_data_c file_name_z_data(m_am_tools); |
|
4898 |
|
4899 { |
|
4900 #if defined(EAPOL_SYMBIAN_VERSION_7_0_s) |
|
4901 eap_const_string const FILECONFIG_FILENAME_Z |
|
4902 = "z:\\system\\data\\eap.conf"; |
|
4903 #else |
|
4904 eap_const_string const FILECONFIG_FILENAME_Z |
|
4905 = "z:\\private\\101F8EC5\\eap.conf"; |
|
4906 #endif |
|
4907 |
|
4908 status = file_name_z_data.set_copy_of_buffer( |
|
4909 FILECONFIG_FILENAME_Z, |
|
4910 m_am_tools->strlen(FILECONFIG_FILENAME_Z)); |
|
4911 if (status != eap_status_ok) |
|
4912 { |
|
4913 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
4914 return EAP_STATUS_RETURN(m_am_tools, status); |
|
4915 } |
|
4916 |
|
4917 status = file_name_z_data.add_end_null(); |
|
4918 if (status != eap_status_ok) |
|
4919 { |
|
4920 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
4921 return EAP_STATUS_RETURN(m_am_tools, status); |
|
4922 } |
|
4923 } |
|
4924 |
|
4925 |
|
4926 |
|
4927 if (status == eap_status_ok) |
|
4928 { |
|
4929 // First try open from C: disk. |
|
4930 status = fileio->file_open( |
|
4931 &file_name_c_data, |
|
4932 eap_file_io_direction_read); |
|
4933 if (status == eap_status_ok) |
|
4934 { |
|
4935 EAP_TRACE_DEBUG( |
|
4936 m_am_tools, |
|
4937 TRACE_FLAGS_DEFAULT, |
|
4938 (EAPL("Opens configure file %s\n"), |
|
4939 file_name_c_data.get_data(file_name_c_data.get_data_length()))); |
|
4940 } |
|
4941 else if (status != eap_status_ok) |
|
4942 { |
|
4943 // Second try open from Z: disk. |
|
4944 status = fileio->file_open( |
|
4945 &file_name_z_data, |
|
4946 eap_file_io_direction_read); |
|
4947 if (status == eap_status_ok) |
|
4948 { |
|
4949 EAP_TRACE_DEBUG( |
|
4950 m_am_tools, |
|
4951 TRACE_FLAGS_DEFAULT, |
|
4952 (EAPL("Opens configure file %s\n"), |
|
4953 file_name_z_data.get_data(file_name_z_data.get_data_length()))); |
|
4954 } |
|
4955 } |
|
4956 |
|
4957 if (status == eap_status_ok) |
|
4958 { |
|
4959 // Some of the files were opened. |
|
4960 |
|
4961 m_fileconfig = new eap_file_config_c(m_am_tools); |
|
4962 if (m_fileconfig != 0 |
|
4963 && m_fileconfig->get_is_valid() == true) |
|
4964 { |
|
4965 status = m_fileconfig->configure(fileio); |
|
4966 if (status != eap_status_ok) |
|
4967 { |
|
4968 EAP_TRACE_DEBUG( |
|
4969 m_am_tools, |
|
4970 TRACE_FLAGS_DEFAULT, |
|
4971 (EAPL("ERROR: Configure read from %s failed.\n"), |
|
4972 file_name_c_data.get_data(file_name_c_data.get_data_length()))); |
|
4973 } |
|
4974 else |
|
4975 { |
|
4976 EAP_TRACE_DEBUG( |
|
4977 m_am_tools, |
|
4978 TRACE_FLAGS_DEFAULT, |
|
4979 (EAPL("Configure read from %s\n"), |
|
4980 file_name_c_data.get_data(file_name_c_data.get_data_length()))); |
|
4981 } |
|
4982 } |
|
4983 else |
|
4984 { |
|
4985 // No file configuration. |
|
4986 delete m_fileconfig; |
|
4987 m_fileconfig = 0; |
|
4988 |
|
4989 EAP_TRACE_DEBUG( |
|
4990 m_am_tools, |
|
4991 TRACE_FLAGS_DEFAULT, |
|
4992 (EAPL("ERROR: Cannot create configure object for file %s\n"), |
|
4993 file_name_c_data.get_data(file_name_c_data.get_data_length()))); |
|
4994 } |
|
4995 } |
|
4996 else |
|
4997 { |
|
4998 EAP_TRACE_DEBUG( |
|
4999 m_am_tools, |
|
5000 TRACE_FLAGS_DEFAULT, |
|
5001 (EAPL("ERROR: Cannot open configure file neither %s nor %s\n"), |
|
5002 file_name_c_data.get_data(file_name_c_data.get_data_length()), |
|
5003 file_name_z_data.get_data(file_name_z_data.get_data_length()))); |
|
5004 } |
|
5005 } |
|
5006 } |
|
5007 else |
|
5008 { |
|
5009 EAP_TRACE_DEBUG( |
|
5010 m_am_tools, |
|
5011 TRACE_FLAGS_DEFAULT, |
|
5012 (EAPL("Skips file configuration.\n"))); |
|
5013 } |
|
5014 |
|
5015 eap_variable_data_c skip_user_interactions(m_am_tools); |
|
5016 |
|
5017 if (m_fileconfig != 0 |
|
5018 && m_fileconfig->get_is_valid() == true) |
|
5019 { |
|
5020 // Here we could try the final configuration option. |
|
5021 status = m_fileconfig->read_configure( |
|
5022 cf_str_EAP_skip_user_interactions_for_testing_purposes.get_field(), |
|
5023 &skip_user_interactions); |
|
5024 } |
|
5025 |
|
5026 if (status == eap_status_ok |
|
5027 && skip_user_interactions.get_is_valid_data() == true) |
|
5028 { |
|
5029 u32_t *skip_user_interactions_flag = reinterpret_cast<u32_t *>( |
|
5030 skip_user_interactions.get_data(sizeof(u32_t))); |
|
5031 if (skip_user_interactions_flag != 0) |
|
5032 { |
|
5033 if (*skip_user_interactions_flag != 0) |
|
5034 { |
|
5035 m_skip_user_interactions = true; |
|
5036 } |
|
5037 else |
|
5038 { |
|
5039 m_skip_user_interactions = false; |
|
5040 } |
|
5041 } |
|
5042 } |
|
5043 |
|
5044 iPacStoreDb->SkipUserActions (m_skip_user_interactions); |
|
5045 |
|
5046 return status; |
|
5047 } |
|
5048 #endif //#if defined(USE_EAP_CONFIGURATION_TO_SKIP_USER_INTERACTIONS) |
|
5049 #endif |
|
5050 |
|
5051 |
|
5052 //-------------------------------------------------- |
|
5053 |
|
5054 EAP_FUNC_EXPORT eap_status_e eap_am_type_tls_peap_symbian_c::query_certificate_chain( |
|
5055 EAP_TEMPLATE_CONST eap_array_c<eap_variable_data_c> * const certificate_authorities, |
|
5056 EAP_TEMPLATE_CONST eap_array_c<u8_t> * const certificate_types, |
|
5057 const tls_cipher_suites_e required_cipher_suite) |
|
5058 { |
|
5059 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
5060 |
|
5061 if (m_is_client) |
|
5062 { |
|
5063 m_cipher_suite = required_cipher_suite; |
|
5064 } |
|
5065 |
|
5066 eap_status_e status(eap_status_pending_request); |
|
5067 m_state = EHandlingChainQuery; |
|
5068 TInt err(KErrNone); |
|
5069 |
|
5070 if (m_is_client) |
|
5071 { |
|
5072 // Get the matching certificates |
|
5073 TRAPD(err, m_cert_if->GetMatchingCertificatesL( |
|
5074 m_allowed_user_certs, |
|
5075 ETrue, |
|
5076 certificate_authorities, |
|
5077 ETrue, |
|
5078 certificate_types, |
|
5079 ETrue, |
|
5080 m_allowed_cipher_suites)); |
|
5081 |
|
5082 (void)EAP_STATUS_RETURN(m_am_tools, m_am_tools->convert_am_error_to_eapol_error(err)); |
|
5083 } |
|
5084 else |
|
5085 { |
|
5086 // server |
|
5087 TRAPD(err, m_cert_if->GetMatchingCertificatesL( |
|
5088 m_allowed_user_certs, |
|
5089 EFalse, |
|
5090 0, |
|
5091 EFalse, |
|
5092 0, |
|
5093 ETrue, |
|
5094 m_allowed_cipher_suites)); |
|
5095 |
|
5096 if (err != KErrNone) |
|
5097 { |
|
5098 status = m_am_tools->convert_am_error_to_eapol_error(err); |
|
5099 } |
|
5100 } |
|
5101 |
|
5102 if (err == KErrNone) |
|
5103 { |
|
5104 status = eap_status_pending_request; |
|
5105 } |
|
5106 else |
|
5107 { |
|
5108 // Convert the leave error code to EAPOL stack error code. |
|
5109 status = m_am_tools->convert_am_error_to_eapol_error(err); |
|
5110 } |
|
5111 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
5112 return EAP_STATUS_RETURN(m_am_tools, status); |
|
5113 |
|
5114 } |
|
5115 |
|
5116 void eap_am_type_tls_peap_symbian_c::complete_get_matching_certificates( |
|
5117 CArrayFixFlat<SCertEntry>& aMatchingCerts, |
|
5118 eap_status_e aStatus) |
|
5119 { |
|
5120 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
5121 |
|
5122 EAP_UNREFERENCED_PARAMETER(aStatus); |
|
5123 |
|
5124 EAP_TRACE_DEBUG(m_am_tools, |
|
5125 TRACE_FLAGS_DEFAULT, |
|
5126 (EAPL("eap_am_type_tls_peap_symbian_c::complete_get_matching_certificates-Matching cert count after possible cert removal=%d, m_state=%d, aStatus=%d\n"), |
|
5127 aMatchingCerts.Count(), m_state, aStatus)); |
|
5128 |
|
5129 if (m_state == EHandlingIdentityQuery) |
|
5130 { |
|
5131 EAP_TRACE_DEBUG( |
|
5132 m_am_tools, |
|
5133 TRACE_FLAGS_DEFAULT, |
|
5134 (EAPL("eap_am_type_tls_peap_symbian_c::complete_get_matching_certificates(): EHandlingIdentityQuery\n"))); |
|
5135 |
|
5136 // Add found certs to allowed certificate list. |
|
5137 // This list is updated here because there might be certificates that have been removed. |
|
5138 m_allowed_user_certs.Reset(); |
|
5139 for (TInt i = 0; i < aMatchingCerts.Count(); i++) |
|
5140 { |
|
5141 TRAPD(err, m_allowed_user_certs.AppendL(aMatchingCerts[i])); |
|
5142 if (err != KErrNone) |
|
5143 { |
|
5144 EAP_TRACE_DEBUG( |
|
5145 m_am_tools, |
|
5146 TRACE_FLAGS_DEFAULT, |
|
5147 (EAPL("ERROR: eap_am_type_tls_peap_symbian_c::complete_get_matching_certificates -EHandlingIdentityQuery- Error=%d\n"), |
|
5148 err)); |
|
5149 |
|
5150 get_am_partner()->complete_eap_identity_query( |
|
5151 0, // 0 because identity query failed |
|
5152 &m_receive_network_id, |
|
5153 m_eap_identifier, |
|
5154 eap_status_allocation_error, |
|
5155 false, |
|
5156 0, |
|
5157 false, |
|
5158 0); |
|
5159 |
|
5160 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
5161 return; |
|
5162 } |
|
5163 } |
|
5164 |
|
5165 if (m_allowed_user_certs.Count() == 0) |
|
5166 { |
|
5167 // No allowed user certificates. |
|
5168 EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("EAP-TLS: No allowed user certificates configured.\n"))); |
|
5169 |
|
5170 if (m_tls_peap_server_authenticates_client_policy_flag == true) |
|
5171 { |
|
5172 // Certificate is really required |
|
5173 EAP_TRACE_DEBUG( |
|
5174 m_am_tools, |
|
5175 TRACE_FLAGS_DEFAULT, |
|
5176 (EAPL("ERROR: EAP-TLS: Could not find proper user certificate.\n"))); |
|
5177 |
|
5178 send_error_notification(eap_status_user_certificate_unknown); |
|
5179 |
|
5180 get_am_partner()->complete_eap_identity_query( |
|
5181 0, // 0 because identity query failed |
|
5182 &m_receive_network_id, |
|
5183 m_eap_identifier, |
|
5184 eap_status_illegal_certificate, |
|
5185 false, |
|
5186 0, |
|
5187 false, |
|
5188 0); |
|
5189 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
5190 return; |
|
5191 } |
|
5192 |
|
5193 if (m_use_manual_realm == false) |
|
5194 { |
|
5195 // Since there is no user certificate or manual realm configured |
|
5196 // the realm needs to be dig out from the CA certificate. |
|
5197 EAP_TRACE_DEBUG( |
|
5198 m_am_tools, |
|
5199 TRACE_FLAGS_DEFAULT, |
|
5200 (EAPL("eap_am_type_tls_peap_symbian_c: no manual realm - no user cert. Get realm from CA certificate.\n"))); |
|
5201 |
|
5202 TInt allowed_ca_cert_count = m_allowed_ca_certs.Count(); |
|
5203 TInt err(KErrNone); |
|
5204 |
|
5205 if(allowed_ca_cert_count > 0) |
|
5206 { |
|
5207 TRAP(err, m_cert_if->ReadCACertificateL(m_allowed_ca_certs[0])); |
|
5208 } |
|
5209 if (err != KErrNone || allowed_ca_cert_count <= 0) |
|
5210 { |
|
5211 EAP_TRACE_DEBUG( |
|
5212 m_am_tools, |
|
5213 TRACE_FLAGS_DEFAULT, |
|
5214 (EAPL("ERROR: EAP-TLS: Cannot read user certificate or No CA cert configured, CA cert count=%d.\n"), |
|
5215 allowed_ca_cert_count)); |
|
5216 |
|
5217 get_am_partner()->complete_eap_identity_query( |
|
5218 0, // 0 because identity query failed |
|
5219 &m_receive_network_id, |
|
5220 m_eap_identifier, |
|
5221 eap_status_illegal_certificate, |
|
5222 false, |
|
5223 0, |
|
5224 false, |
|
5225 0); |
|
5226 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
5227 return; |
|
5228 } |
|
5229 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
5230 return; |
|
5231 } |
|
5232 else |
|
5233 { |
|
5234 EAP_TRACE_DEBUG( |
|
5235 m_am_tools, |
|
5236 TRACE_FLAGS_DEFAULT, |
|
5237 (EAPL("EAP-TLS: Uses manual realm.\n"))); |
|
5238 |
|
5239 get_am_partner()->complete_eap_identity_query( |
|
5240 0, // 0 because certificate query failed |
|
5241 &m_receive_network_id, |
|
5242 m_eap_identifier, |
|
5243 eap_status_ok, |
|
5244 m_use_manual_username, |
|
5245 &m_manual_username, |
|
5246 m_use_manual_realm, |
|
5247 &m_manual_realm); |
|
5248 |
|
5249 } |
|
5250 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
5251 return; |
|
5252 } |
|
5253 |
|
5254 // Just complete (this selects the first certificate in the array) |
|
5255 m_selector_output.SetLength(0); |
|
5256 TRequestStatus* reqStatus = &iStatus; |
|
5257 User::RequestComplete(reqStatus, KErrNone); |
|
5258 SetActive(); |
|
5259 } |
|
5260 else if (m_state == EHandlingChainQuery) |
|
5261 { |
|
5262 |
|
5263 if (aMatchingCerts.Count() > 0) |
|
5264 { |
|
5265 m_allowed_user_certs.Reset(); |
|
5266 |
|
5267 for (TInt i = 0; i < aMatchingCerts.Count(); i++) |
|
5268 { |
|
5269 TRAPD(err, m_allowed_user_certs.AppendL(aMatchingCerts[i])); |
|
5270 if (err != KErrNone) |
|
5271 { |
|
5272 EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("eap_am_type_tls_peap_symbian_c::complete_get_matching_certificates -EHandlingChainQuery- Error=%d\n"), |
|
5273 err)); |
|
5274 |
|
5275 get_tls_am_partner()->complete_query_certificate_chain(0, eap_status_allocation_error); |
|
5276 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
5277 return; |
|
5278 } |
|
5279 } |
|
5280 } |
|
5281 |
|
5282 if (m_allowed_user_certs.Count() == 0) |
|
5283 { |
|
5284 // No matching or allowed certs and no pre-loaded cert. |
|
5285 // Could not find matching certificate |
|
5286 |
|
5287 EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("EAP-TLS: Could not find proper user certificate.\n"))); |
|
5288 |
|
5289 if (m_tls_peap_server_authenticates_client_policy_flag == true) |
|
5290 { |
|
5291 send_error_notification(eap_status_user_certificate_unknown); |
|
5292 } |
|
5293 |
|
5294 get_tls_am_partner()->complete_query_certificate_chain(0, eap_status_illegal_certificate); |
|
5295 |
|
5296 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
5297 return; |
|
5298 } |
|
5299 |
|
5300 // We got at least one allowed user cert. |
|
5301 // Just use the first allowed certificate |
|
5302 // Don't ask user. Just complete (this selects the first certificate in the array) |
|
5303 m_selector_output.SetLength(0); |
|
5304 TRequestStatus* reqStatus = &iStatus; |
|
5305 User::RequestComplete(reqStatus, KErrNone); |
|
5306 SetActive(); |
|
5307 |
|
5308 } |
|
5309 else |
|
5310 { |
|
5311 EAP_TRACE_ERROR(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("EAP-TLS: Illegal state in complete_get_matching_certs.\n"))); |
|
5312 } |
|
5313 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
5314 return; |
|
5315 } |
|
5316 |
|
5317 |
|
5318 EAP_FUNC_EXPORT eap_status_e eap_am_type_tls_peap_symbian_c::query_certificate_authorities_and_types() |
|
5319 { |
|
5320 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
5321 EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("\n"))); |
|
5322 EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("TLS: %s: message_function: query_certificate_authorities_and_types()\n"), |
|
5323 (m_is_client == true ? "client": "server"))); |
|
5324 |
|
5325 EAP_ASSERT_ALWAYS(!m_is_client); |
|
5326 |
|
5327 eap_status_e status; |
|
5328 eap_array_c<eap_variable_data_c> certificate_authorities(m_am_tools); |
|
5329 eap_variable_data_c ca_dn(m_am_tools); |
|
5330 |
|
5331 // TEST CODE: This is not a proper CA DN. |
|
5332 _LIT8(KTestCA, "ca.eapsim.foo"); |
|
5333 status = ca_dn.add_data(KTestCA().Ptr(), KTestCA().Size()); |
|
5334 if (status != eap_status_ok) |
|
5335 { |
|
5336 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
5337 return EAP_STATUS_RETURN(m_am_tools, status); |
|
5338 } |
|
5339 |
|
5340 status = certificate_authorities.add_object(&ca_dn, false); |
|
5341 if (status != eap_status_ok) |
|
5342 { |
|
5343 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
5344 return EAP_STATUS_RETURN(m_am_tools, status); |
|
5345 } |
|
5346 |
|
5347 |
|
5348 eap_array_c<u8_t> certificate_types(m_am_tools); |
|
5349 |
|
5350 { |
|
5351 u8_t * const dummy_certificate_type = new u8_t; |
|
5352 if (dummy_certificate_type == 0) |
|
5353 { |
|
5354 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
5355 return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error); |
|
5356 } |
|
5357 |
|
5358 *dummy_certificate_type = tls_certificate_type_rsa_sign; |
|
5359 |
|
5360 status = certificate_types.add_object(dummy_certificate_type, true); |
|
5361 if (status != eap_status_ok) |
|
5362 { |
|
5363 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
5364 return EAP_STATUS_RETURN(m_am_tools, status); |
|
5365 } |
|
5366 } |
|
5367 { |
|
5368 u8_t * const dummy_certificate_type = new u8_t; |
|
5369 if (dummy_certificate_type == 0) |
|
5370 { |
|
5371 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
5372 return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error); |
|
5373 } |
|
5374 |
|
5375 *dummy_certificate_type = tls_certificate_type_dss_sign; |
|
5376 |
|
5377 status = certificate_types.add_object(dummy_certificate_type, true); |
|
5378 if (status != eap_status_ok) |
|
5379 { |
|
5380 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
5381 return EAP_STATUS_RETURN(m_am_tools, status); |
|
5382 } |
|
5383 } |
|
5384 |
|
5385 |
|
5386 status = get_tls_am_partner()->complete_query_certificate_authorities_and_types( |
|
5387 &certificate_authorities, |
|
5388 &certificate_types, |
|
5389 eap_status_ok); |
|
5390 if (status == eap_status_ok || |
|
5391 status == eap_status_pending_request) |
|
5392 { |
|
5393 status = eap_status_completed_request; |
|
5394 } |
|
5395 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
5396 return EAP_STATUS_RETURN(m_am_tools, status); |
|
5397 } |
|
5398 |
|
5399 //-------------------------------------------------- |
|
5400 |
|
5401 EAP_FUNC_EXPORT eap_status_e eap_am_type_tls_peap_symbian_c::query_dh_parameters( |
|
5402 EAP_TEMPLATE_CONST eap_array_c<eap_variable_data_c> * const /*certificate_chain*/, |
|
5403 const tls_cipher_suites_e required_cipher_suite) |
|
5404 { |
|
5405 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
5406 |
|
5407 EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("\n"))); |
|
5408 EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("TLS: %s: message_function: query_dh_parameters()\n"), |
|
5409 (m_is_client == true ? "client": "server"))); |
|
5410 |
|
5411 eap_status_e status = eap_status_process_general_error; |
|
5412 |
|
5413 if (required_cipher_suite != m_cipher_suite) |
|
5414 { |
|
5415 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
5416 return EAP_STATUS_RETURN(m_am_tools, eap_status_illegal_cipher_suite); |
|
5417 } |
|
5418 |
|
5419 if (EapTlsPeapUtils::CipherSuiteIsEphemeralDHKeyExchange(m_cipher_suite)) |
|
5420 { |
|
5421 eap_variable_data_c dhe_prime(m_am_tools); |
|
5422 status = dhe_prime.set_copy_of_buffer(SAE_GROUP_PRIME, SAE_GROUP_PRIME_LENGTH); |
|
5423 if (status != eap_status_ok) |
|
5424 { |
|
5425 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
5426 return EAP_STATUS_RETURN(m_am_tools, status); |
|
5427 } |
|
5428 |
|
5429 eap_variable_data_c dhe_group_generator(m_am_tools); |
|
5430 |
|
5431 status = dhe_group_generator.set_copy_of_buffer(SAE_GROUP_GENERATOR, SAE_GROUP_GENERATOR_LENGTH); |
|
5432 if (status != eap_status_ok) |
|
5433 { |
|
5434 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
5435 return EAP_STATUS_RETURN(m_am_tools, status); |
|
5436 } |
|
5437 |
|
5438 status = get_tls_am_partner()->complete_query_dh_parameters( |
|
5439 &dhe_prime, |
|
5440 &dhe_group_generator, |
|
5441 eap_status_ok); |
|
5442 } |
|
5443 else |
|
5444 { |
|
5445 status = eap_status_not_supported; |
|
5446 } |
|
5447 |
|
5448 if (status == eap_status_ok || |
|
5449 status == eap_status_pending_request) |
|
5450 { |
|
5451 status = eap_status_completed_request; |
|
5452 } |
|
5453 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
5454 return EAP_STATUS_RETURN(m_am_tools, status); |
|
5455 } |
|
5456 |
|
5457 //-------------------------------------------------- |
|
5458 |
|
5459 EAP_FUNC_EXPORT eap_status_e eap_am_type_tls_peap_symbian_c::query_realm( |
|
5460 EAP_TEMPLATE_CONST eap_array_c<eap_variable_data_c> * const /*certificate_chain*/) |
|
5461 { |
|
5462 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
5463 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
5464 return EAP_STATUS_RETURN(m_am_tools, eap_status_not_supported); |
|
5465 } |
|
5466 |
|
5467 //-------------------------------------------------- |
|
5468 |
|
5469 eap_status_e eap_am_type_tls_peap_symbian_c::get_realms_from_certificate( |
|
5470 CX509Certificate* certificate, |
|
5471 eap_variable_data_c * const subject_realm, |
|
5472 eap_variable_data_c * const issuer_realm) |
|
5473 { |
|
5474 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
5475 eap_status_e status(eap_status_process_general_error); |
|
5476 _LIT8(KAt, "@"); |
|
5477 eap_variable_data_c subject_identity(m_am_tools); |
|
5478 eap_variable_data_c issuer_identity(m_am_tools); |
|
5479 |
|
5480 TInt offset = KErrNotFound; |
|
5481 |
|
5482 // SUBJECT |
|
5483 // Try alternative name first |
|
5484 TRAPD(err, get_identity_from_alternative_nameL(certificate, &subject_identity)); |
|
5485 if (err == KErrNone) |
|
5486 { |
|
5487 // Parse realm from identity |
|
5488 TPtr8 ptr( |
|
5489 subject_identity.get_data(subject_identity.get_data_length()), |
|
5490 subject_identity.get_data_length(), |
|
5491 subject_identity.get_data_length()); |
|
5492 |
|
5493 offset = ptr.Find(KAt); |
|
5494 } |
|
5495 |
|
5496 if (offset == KErrNotFound) |
|
5497 { |
|
5498 // Check DN |
|
5499 TRAPD(err, get_identities_from_distinguished_namesL(certificate, &subject_identity, &issuer_identity)); |
|
5500 if (err != KErrNone) |
|
5501 { |
|
5502 EAP_TRACE_ERROR(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("ERROR: EAP-TLS: Could not find realm from certificate.\n"))); |
|
5503 return EAP_STATUS_RETURN(m_am_tools, eap_status_illegal_certificate); |
|
5504 } |
|
5505 |
|
5506 // Parse realm from identity |
|
5507 TPtr8 ptr( |
|
5508 subject_identity.get_data(subject_identity.get_data_length()), |
|
5509 subject_identity.get_data_length(), |
|
5510 subject_identity.get_data_length()); |
|
5511 offset = ptr.Find(KAt); |
|
5512 // Don't worry if @ is not found. Then just use the whole CN as realm. |
|
5513 // It probably is the realm in CA certificates. |
|
5514 } |
|
5515 |
|
5516 TPtr8 ptr( |
|
5517 subject_identity.get_data(subject_identity.get_data_length()), |
|
5518 subject_identity.get_data_length(), |
|
5519 subject_identity.get_data_length()); |
|
5520 |
|
5521 status = subject_realm->set_copy_of_buffer((ptr.Mid(offset + 1)).Ptr(), ptr.Length() - offset - 1); |
|
5522 if (status != eap_status_ok) |
|
5523 { |
|
5524 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
5525 return EAP_STATUS_RETURN(m_am_tools, status); |
|
5526 } |
|
5527 |
|
5528 // ISSUER |
|
5529 // Check DN |
|
5530 TRAP(err, get_identities_from_distinguished_namesL(certificate, &subject_identity, &issuer_identity)); |
|
5531 if (err != KErrNone) |
|
5532 { |
|
5533 EAP_TRACE_ERROR(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("ERROR: EAP-TLS: Could not find realm from certificate.\n"))); |
|
5534 return EAP_STATUS_RETURN(m_am_tools, eap_status_illegal_certificate); |
|
5535 } |
|
5536 |
|
5537 // Parse realm from identity |
|
5538 TPtr8 ptr2( |
|
5539 issuer_identity.get_data(issuer_identity.get_data_length()), |
|
5540 issuer_identity.get_data_length(), |
|
5541 issuer_identity.get_data_length()); |
|
5542 |
|
5543 offset = ptr2.Find(KAt); |
|
5544 |
|
5545 status = issuer_realm->set_copy_of_buffer((ptr2.Mid(offset + 1)).Ptr(), ptr2.Length() - offset - 1); |
|
5546 if (status != eap_status_ok) |
|
5547 { |
|
5548 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
5549 return EAP_STATUS_RETURN(m_am_tools, status); |
|
5550 } |
|
5551 |
|
5552 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
5553 return EAP_STATUS_RETURN(m_am_tools, status); |
|
5554 } |
|
5555 |
|
5556 //-------------------------------------------------- |
|
5557 |
|
5558 |
|
5559 EAP_FUNC_EXPORT eap_status_e eap_am_type_tls_peap_symbian_c::save_tls_session( |
|
5560 const eap_variable_data_c * const session_id, |
|
5561 const eap_variable_data_c * const master_secret, |
|
5562 const tls_cipher_suites_e used_cipher_suite |
|
5563 #if defined(USE_EAP_TLS_SESSION_TICKET) |
|
5564 , const tls_extension_c * const new_session_ticket |
|
5565 #endif //#if defined(USE_EAP_TLS_SESSION_TICKET) |
|
5566 ) |
|
5567 { |
|
5568 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
5569 eap_status_e status = eap_status_ok; |
|
5570 |
|
5571 EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("TLS: %s: save_tls_session()\n"), |
|
5572 (m_is_client == true ? "client": "server"))); |
|
5573 |
|
5574 // Save current session. |
|
5575 if (session_id != 0 |
|
5576 && session_id->get_is_valid_data() == true |
|
5577 && master_secret != 0 |
|
5578 && master_secret->get_is_valid_data() == true) |
|
5579 { |
|
5580 // Send error if any of the parameters are too long. |
|
5581 if(session_id->get_data_length() > KMaxSessionIdLengthInDB |
|
5582 || master_secret->get_data_length() > KMaxMasterSecretLengthInDB) |
|
5583 { |
|
5584 // Some of the parameters are too long. Can't store them in DB. |
|
5585 |
|
5586 EAP_TRACE_DEBUG( |
|
5587 m_am_tools, |
|
5588 TRACE_FLAGS_DEFAULT, |
|
5589 (EAPL("eap_am_type_tls_peap_symbian_c::save_tls_session: ") |
|
5590 EAPL("Too long parameters. Length: session_id=%d, master_secret=%d \n"), |
|
5591 session_id->get_data_length(), master_secret->get_data_length())); |
|
5592 |
|
5593 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
5594 return EAP_STATUS_RETURN(m_am_tools, eap_status_illegal_parameter); |
|
5595 } |
|
5596 |
|
5597 { |
|
5598 TRAPD(err, WriteBinaryParamL( |
|
5599 cf_str_EAP_TLS_PEAP_saved_session_id.get_field()->get_field(), |
|
5600 cf_str_EAP_TLS_PEAP_saved_session_id.get_field()->get_field_length(), |
|
5601 session_id)); |
|
5602 if (err != KErrNone) |
|
5603 { |
|
5604 // Convert the leave error code to EAPOL stack error code. |
|
5605 status = m_am_tools->convert_am_error_to_eapol_error(err); |
|
5606 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
5607 return EAP_STATUS_RETURN(m_am_tools, status); |
|
5608 } |
|
5609 } |
|
5610 |
|
5611 { |
|
5612 TRAPD(err, WriteBinaryParamL( |
|
5613 cf_str_EAP_TLS_PEAP_saved_master_secret.get_field()->get_field(), |
|
5614 cf_str_EAP_TLS_PEAP_saved_master_secret.get_field()->get_field_length(), |
|
5615 master_secret)); |
|
5616 if (err != KErrNone) |
|
5617 { |
|
5618 // Convert the leave error code to EAPOL stack error code. |
|
5619 status = m_am_tools->convert_am_error_to_eapol_error(err); |
|
5620 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
5621 return EAP_STATUS_RETURN(m_am_tools, status); |
|
5622 } |
|
5623 } |
|
5624 |
|
5625 { |
|
5626 TRAPD(err, WriteIntParamL( |
|
5627 cf_str_EAP_TLS_PEAP_saved_cipher_suite.get_field()->get_field(), |
|
5628 cf_str_EAP_TLS_PEAP_saved_cipher_suite.get_field()->get_field_length(), |
|
5629 used_cipher_suite)); |
|
5630 if (err != KErrNone) |
|
5631 { |
|
5632 // Convert the leave error code to EAPOL stack error code. |
|
5633 status = m_am_tools->convert_am_error_to_eapol_error(err); |
|
5634 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
5635 return EAP_STATUS_RETURN(m_am_tools, status); |
|
5636 } |
|
5637 } |
|
5638 } |
|
5639 |
|
5640 #if defined(USE_EAP_TLS_SESSION_TICKET) |
|
5641 if (m_use_session_ticket == true |
|
5642 && new_session_ticket != 0) |
|
5643 { |
|
5644 // Save new session ticket. |
|
5645 } |
|
5646 #endif //#if defined(USE_EAP_TLS_SESSION_TICKET) |
|
5647 |
|
5648 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
5649 return EAP_STATUS_RETURN(m_am_tools, eap_status_ok); |
|
5650 } |
|
5651 //-------------------------------------------------- |
|
5652 //-------------------------------------------------- |
|
5653 |
|
5654 EAP_FUNC_EXPORT eap_status_e eap_am_type_tls_peap_symbian_c::rsa_encrypt_with_public_key( |
|
5655 const eap_variable_data_c * const premaster_secret) |
|
5656 { |
|
5657 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
5658 |
|
5659 EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("\n"))); |
|
5660 EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("TLS: %s: message_function: rsa_encrypt_with_public_key()\n"), |
|
5661 (m_is_client == true ? "client": "server"))); |
|
5662 |
|
5663 if (m_peer_public_key.get_is_valid_data() == false) |
|
5664 { |
|
5665 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
5666 return EAP_STATUS_RETURN(m_am_tools, eap_status_process_general_error); |
|
5667 } |
|
5668 |
|
5669 EAP_TRACE_DATA_DEBUG(m_am_tools, |
|
5670 TRACE_FLAGS_DEFAULT, (EAPL("TLS: rsa_encrypt_with_public_key() m_peer_public_key"), |
|
5671 m_peer_public_key.get_data(m_peer_public_key.get_data_length()), |
|
5672 m_peer_public_key.get_data_length())); |
|
5673 |
|
5674 |
|
5675 crypto_rsa_c rsa(m_am_tools); |
|
5676 |
|
5677 eap_variable_data_c encrypted_premaster_secret(m_am_tools); |
|
5678 |
|
5679 eap_status_e status = rsa.encrypt_with_public_key( |
|
5680 &m_peer_public_key, |
|
5681 premaster_secret, |
|
5682 &encrypted_premaster_secret); |
|
5683 |
|
5684 status = get_tls_am_partner()->complete_rsa_encrypt_with_public_key( |
|
5685 &encrypted_premaster_secret, |
|
5686 eap_status_ok); |
|
5687 if (status == eap_status_ok |
|
5688 || status == eap_status_pending_request) |
|
5689 { |
|
5690 status = eap_status_completed_request; |
|
5691 } |
|
5692 |
|
5693 |
|
5694 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
5695 return EAP_STATUS_RETURN(m_am_tools, status); |
|
5696 } |
|
5697 |
|
5698 //-------------------------------------------------- |
|
5699 |
|
5700 EAP_FUNC_EXPORT eap_status_e eap_am_type_tls_peap_symbian_c::rsa_decrypt_with_private_key( |
|
5701 const eap_variable_data_c * const encrypted_premaster_secret) |
|
5702 { |
|
5703 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
5704 |
|
5705 EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("\n"))); |
|
5706 EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("TLS: %s: message_function: rsa_decrypt_with_private_key()\n"), |
|
5707 (m_is_client == true ? "client": "server"))); |
|
5708 |
|
5709 eap_status_e status(eap_status_pending_request); |
|
5710 if (m_own_certificate == 0) |
|
5711 { |
|
5712 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
5713 return EAP_STATUS_RETURN(m_am_tools, eap_status_process_general_error); |
|
5714 } |
|
5715 |
|
5716 HBufC8* data = 0; |
|
5717 |
|
5718 TRAPD(err, data = HBufC8::NewL(encrypted_premaster_secret->get_data_length())); |
|
5719 if (err != KErrNone) |
|
5720 { |
|
5721 status = m_am_tools->convert_am_error_to_eapol_error(err); |
|
5722 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
5723 return EAP_STATUS_RETURN(m_am_tools, status); |
|
5724 } |
|
5725 |
|
5726 TPtr8 ptr = data->Des(); |
|
5727 |
|
5728 ptr.Copy(encrypted_premaster_secret->get_data(encrypted_premaster_secret->get_data_length()), |
|
5729 encrypted_premaster_secret->get_data_length()); |
|
5730 |
|
5731 TRAP(err, m_cert_if->DecryptL(m_own_certificate_info.iSubjectKeyId, *data)); |
|
5732 |
|
5733 if (err != KErrNone) |
|
5734 { |
|
5735 status = m_am_tools->convert_am_error_to_eapol_error(err); |
|
5736 } |
|
5737 else |
|
5738 { |
|
5739 status = eap_status_pending_request; |
|
5740 } |
|
5741 |
|
5742 delete data; |
|
5743 |
|
5744 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
5745 return EAP_STATUS_RETURN(m_am_tools, status); |
|
5746 } |
|
5747 |
|
5748 //-------------------------------------------------- |
|
5749 |
|
5750 void eap_am_type_tls_peap_symbian_c::complete_decrypt(TDes8& aData, eap_status_e aStatus) |
|
5751 { |
|
5752 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
5753 |
|
5754 if (aStatus != eap_status_ok) |
|
5755 { |
|
5756 EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("ERROR: eap_am_type_tls_peap_symbian_c::complete_decrypt, aStatus=%d\n"), |
|
5757 aStatus)); |
|
5758 |
|
5759 get_tls_am_partner()->complete_rsa_decrypt_with_private_key(0, aStatus); |
|
5760 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
5761 return; |
|
5762 } |
|
5763 |
|
5764 if (aData.Length() == 0) |
|
5765 { |
|
5766 EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("ERROR: Decrypt with private key failed.\n"))); |
|
5767 get_tls_am_partner()->complete_rsa_decrypt_with_private_key(0, eap_status_decryption_failure); |
|
5768 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
5769 return; |
|
5770 } |
|
5771 |
|
5772 eap_variable_data_c decrypted_data(m_am_tools); |
|
5773 eap_status_e status = decrypted_data.set_copy_of_buffer(aData.Ptr(), aData.Length()); |
|
5774 if (status != eap_status_ok) |
|
5775 { |
|
5776 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
5777 return; |
|
5778 } |
|
5779 |
|
5780 EAP_TRACE_DATA_DEBUG( |
|
5781 m_am_tools, |
|
5782 TRACE_FLAGS_DEFAULT, |
|
5783 (EAPL("TLS: rsa_decrypt_with_private_key() decrypted data"), |
|
5784 decrypted_data.get_data(decrypted_data.get_data_length()), |
|
5785 decrypted_data.get_data_length())); |
|
5786 |
|
5787 status = get_tls_am_partner()->complete_rsa_decrypt_with_private_key(&decrypted_data, eap_status_ok); |
|
5788 |
|
5789 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
5790 } |
|
5791 |
|
5792 //-------------------------------------------------- |
|
5793 EAP_FUNC_EXPORT eap_status_e eap_am_type_tls_peap_symbian_c::sign_with_private_key( |
|
5794 const eap_variable_data_c * const message_hash) |
|
5795 { |
|
5796 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
5797 |
|
5798 EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("\n"))); |
|
5799 EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("TLS: %s: message_function: sign_with_private_key()\n"), |
|
5800 (m_is_client == true ? "client": "server"))); |
|
5801 |
|
5802 eap_status_e status(eap_status_pending_request); |
|
5803 if (m_own_certificate == 0) |
|
5804 { |
|
5805 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
5806 return EAP_STATUS_RETURN(m_am_tools, eap_status_process_general_error); |
|
5807 } |
|
5808 |
|
5809 EAP_TRACE_DATA_DEBUG( |
|
5810 m_am_tools, |
|
5811 TRACE_FLAGS_DEFAULT, |
|
5812 (EAPL("TLS: sign_with_private_key() message_hash"), |
|
5813 message_hash->get_data(message_hash->get_data_length()), |
|
5814 message_hash->get_data_length())); |
|
5815 |
|
5816 |
|
5817 HBufC8* buf = 0; |
|
5818 TRAPD(err, buf = HBufC8::NewL(message_hash->get_data_length())) |
|
5819 if (err != KErrNone) |
|
5820 { |
|
5821 status = m_am_tools->convert_am_error_to_eapol_error(err); |
|
5822 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
5823 return EAP_STATUS_RETURN(m_am_tools, status); |
|
5824 } |
|
5825 |
|
5826 TPtr8 hash = buf->Des(); |
|
5827 |
|
5828 hash.Copy(message_hash->get_data(message_hash->get_data_length()), message_hash->get_data_length()); |
|
5829 |
|
5830 |
|
5831 // Calculate the signature length based on algorithm and public key lenght |
|
5832 TUint signature_length(0); |
|
5833 |
|
5834 const CSubjectPublicKeyInfo& public_key = m_own_certificate->PublicKey(); |
|
5835 |
|
5836 if (public_key.AlgorithmId() == EDSA) |
|
5837 { |
|
5838 // DSA signatures are always 40 bytes (320 bits) |
|
5839 signature_length = KDSASignatureLength; |
|
5840 } |
|
5841 else |
|
5842 { |
|
5843 // RSA signature is the same length as public key. |
|
5844 TPtrC8 public_key_data = public_key.KeyData(); |
|
5845 |
|
5846 // public_key_data actually has the asn.1 header so it is a few bytes longer |
|
5847 // than the actual signature. |
|
5848 signature_length = public_key_data.Size(); |
|
5849 } |
|
5850 |
|
5851 TRAP(err, m_cert_if->SignL(m_own_certificate_info.iSubjectKeyId, hash, signature_length)); |
|
5852 if (err != KErrNone) |
|
5853 { |
|
5854 status = m_am_tools->convert_am_error_to_eapol_error(err); |
|
5855 } |
|
5856 else |
|
5857 { |
|
5858 status = eap_status_pending_request; |
|
5859 } |
|
5860 |
|
5861 delete buf; |
|
5862 |
|
5863 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
5864 return EAP_STATUS_RETURN(m_am_tools, status); |
|
5865 |
|
5866 } |
|
5867 //-------------------------------------------------- |
|
5868 void eap_am_type_tls_peap_symbian_c::complete_sign( |
|
5869 const RInteger& aR, const RInteger& aS, eap_status_e aStatus) |
|
5870 { |
|
5871 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
5872 |
|
5873 if(aStatus != eap_status_ok) |
|
5874 { |
|
5875 get_tls_am_partner()->complete_sign_with_private_key(0, aStatus); |
|
5876 return; |
|
5877 } |
|
5878 |
|
5879 TRAPD(err, complete_signL(aR, aS, eap_status_ok)); |
|
5880 if (err != KErrNone) |
|
5881 { |
|
5882 EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("ERROR: complete_signL leaved.\n"))); |
|
5883 get_tls_am_partner()->complete_sign_with_private_key(0, m_am_tools->convert_am_error_to_eapol_error(err)); |
|
5884 } |
|
5885 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
5886 } |
|
5887 |
|
5888 void eap_am_type_tls_peap_symbian_c::complete_signL( |
|
5889 const RInteger& aR, const RInteger& aS, eap_status_e aStatus) |
|
5890 { |
|
5891 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
5892 |
|
5893 if(aStatus != eap_status_ok) |
|
5894 { |
|
5895 get_tls_am_partner()->complete_sign_with_private_key(0, aStatus); |
|
5896 return; |
|
5897 } |
|
5898 |
|
5899 EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("AM: Signing completed.\n"))); |
|
5900 |
|
5901 eap_variable_data_c signed_message_hash(m_am_tools); |
|
5902 eap_status_e status(eap_status_process_general_error); |
|
5903 |
|
5904 if (EapTlsPeapUtils::CipherSuiteUseDSAKeys(m_cipher_suite)) |
|
5905 { |
|
5906 CASN1EncSequence* sequence = CASN1EncSequence::NewLC(); |
|
5907 CASN1EncBigInt* enc_r = CASN1EncBigInt::NewLC(aR); |
|
5908 CASN1EncBigInt* enc_s = CASN1EncBigInt::NewLC(aS); |
|
5909 sequence->AddChildL(enc_r); |
|
5910 sequence->AddChildL(enc_s); |
|
5911 |
|
5912 HBufC8* buf = HBufC8::NewLC(sequence->LengthDER()); |
|
5913 TPtr8 tmp = buf->Des(); |
|
5914 |
|
5915 tmp.SetLength(sequence->LengthDER()); |
|
5916 TInt pos = 0; |
|
5917 sequence->WriteDERL(tmp, (TUint&) pos); |
|
5918 |
|
5919 status = signed_message_hash.set_copy_of_buffer(tmp.Ptr(), tmp.Length()); |
|
5920 if (status != eap_status_ok) |
|
5921 { |
|
5922 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
5923 return; |
|
5924 } |
|
5925 |
|
5926 CleanupStack::PopAndDestroy(); // buf |
|
5927 CleanupStack::Pop(2); // BigInts are deleted by the sequence |
|
5928 CleanupStack::PopAndDestroy(1); // Sequence |
|
5929 } |
|
5930 else if (EapTlsPeapUtils::CipherSuiteUseRSAKeys(m_cipher_suite)) |
|
5931 { |
|
5932 HBufC8* buf = aS.BufferLC(); |
|
5933 |
|
5934 // RSA signing. Just use the data as it is. |
|
5935 eap_status_e status = signed_message_hash.set_copy_of_buffer(buf->Ptr(), buf->Length()); |
|
5936 if (status != eap_status_ok) |
|
5937 { |
|
5938 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
5939 User::Leave(KErrNoMemory); |
|
5940 } |
|
5941 CleanupStack::PopAndDestroy(); // buf |
|
5942 } |
|
5943 else |
|
5944 { |
|
5945 EAP_TRACE_ERROR(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("ERROR: Unsupported cipher suite.\n"))); |
|
5946 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
5947 User::Leave(KErrNotSupported); |
|
5948 } |
|
5949 |
|
5950 EAP_TRACE_DATA_DEBUG( |
|
5951 m_am_tools, |
|
5952 TRACE_FLAGS_DEFAULT, |
|
5953 (EAPL("TLS: sign_with_private_key() signed_message_hash"), |
|
5954 signed_message_hash.get_data(signed_message_hash.get_data_length()), |
|
5955 signed_message_hash.get_data_length())); |
|
5956 |
|
5957 status = get_tls_am_partner()->complete_sign_with_private_key( |
|
5958 &signed_message_hash, |
|
5959 eap_status_ok); |
|
5960 |
|
5961 // Ignore return value on purpose |
|
5962 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
5963 } |
|
5964 |
|
5965 //-------------------------------------------------- |
|
5966 |
|
5967 EAP_FUNC_EXPORT eap_status_e eap_am_type_tls_peap_symbian_c::verify_with_public_key( |
|
5968 const eap_variable_data_c * const message_hash, |
|
5969 const eap_variable_data_c * const signed_message_hash) |
|
5970 { |
|
5971 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
5972 |
|
5973 EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("\n"))); |
|
5974 EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("TLS: %s: message_function: verify_with_public_key()\n"), |
|
5975 (m_is_client == true ? "client": "server"))); |
|
5976 |
|
5977 if (m_peer_public_key.get_is_valid_data() == false) |
|
5978 { |
|
5979 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
5980 return EAP_STATUS_RETURN(m_am_tools, eap_status_process_general_error); |
|
5981 } |
|
5982 |
|
5983 EAP_TRACE_DATA_DEBUG( |
|
5984 m_am_tools, |
|
5985 TRACE_FLAGS_DEFAULT, |
|
5986 (EAPL("TLS: verify_with_public_key() m_peer_public_key"), |
|
5987 m_peer_public_key.get_data(m_peer_public_key.get_data_length()), |
|
5988 m_peer_public_key.get_data_length())); |
|
5989 |
|
5990 EAP_TRACE_DATA_DEBUG( |
|
5991 m_am_tools, |
|
5992 TRACE_FLAGS_DEFAULT, |
|
5993 (EAPL("TLS: verify_with_public_key() message_hash"), |
|
5994 message_hash->get_data(message_hash->get_data_length()), |
|
5995 message_hash->get_data_length())); |
|
5996 |
|
5997 EAP_TRACE_DATA_DEBUG( |
|
5998 m_am_tools, |
|
5999 TRACE_FLAGS_DEFAULT, |
|
6000 (EAPL("TLS: verify_with_public_key() signed_message_hash"), |
|
6001 signed_message_hash->get_data(signed_message_hash->get_data_length()), |
|
6002 signed_message_hash->get_data_length())); |
|
6003 |
|
6004 eap_status_e status = eap_status_process_general_error; |
|
6005 |
|
6006 if (EapTlsPeapUtils::CipherSuiteUseDSAKeys(m_cipher_suite)) |
|
6007 { |
|
6008 TRAPD(err, read_dsa_parametersL()); |
|
6009 if (err != KErrNone) |
|
6010 { |
|
6011 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
6012 return EAP_STATUS_RETURN(m_am_tools, m_am_tools->convert_am_error_to_eapol_error(err)); |
|
6013 } |
|
6014 crypto_dsa_c dsa(m_am_tools); |
|
6015 |
|
6016 status = dsa.init(); |
|
6017 if (status != eap_status_ok) |
|
6018 { |
|
6019 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
6020 return EAP_STATUS_RETURN(m_am_tools, status); |
|
6021 } |
|
6022 |
|
6023 status = dsa.verify( |
|
6024 &m_peer_public_key, |
|
6025 &m_param_p, |
|
6026 &m_param_q, |
|
6027 &m_param_g, |
|
6028 message_hash, |
|
6029 signed_message_hash); |
|
6030 } |
|
6031 else if (EapTlsPeapUtils::CipherSuiteUseRSAKeys(m_cipher_suite)) |
|
6032 { |
|
6033 crypto_rsa_c rsa(m_am_tools); |
|
6034 |
|
6035 status = rsa.init(); |
|
6036 if (status != eap_status_ok) |
|
6037 { |
|
6038 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
6039 return EAP_STATUS_RETURN(m_am_tools, status); |
|
6040 } |
|
6041 |
|
6042 status = rsa.verify( |
|
6043 &m_peer_public_key, |
|
6044 message_hash, |
|
6045 signed_message_hash); |
|
6046 } |
|
6047 else |
|
6048 { |
|
6049 EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("ERROR: Signing with private key failed.\n"))); |
|
6050 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
6051 return EAP_STATUS_RETURN(m_am_tools, eap_status_not_supported); |
|
6052 } |
|
6053 |
|
6054 status = get_tls_am_partner()->complete_verify_with_public_key(status); |
|
6055 |
|
6056 if (status == eap_status_ok |
|
6057 || status == eap_status_pending_request) |
|
6058 { |
|
6059 status = eap_status_completed_request; |
|
6060 } |
|
6061 |
|
6062 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
6063 return EAP_STATUS_RETURN(m_am_tools, status); |
|
6064 } |
|
6065 |
|
6066 void eap_am_type_tls_peap_symbian_c::read_dsa_parametersL() |
|
6067 { |
|
6068 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
6069 if (m_peer_certificate == 0) |
|
6070 { |
|
6071 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
6072 User::Leave(KErrArgument); |
|
6073 } |
|
6074 // Peer cert is the first one |
|
6075 const CSubjectPublicKeyInfo& key = m_peer_certificate->PublicKey(); |
|
6076 const TPtrC8 params = key.EncodedParams(); |
|
6077 |
|
6078 CDSAParameters* dsaParams = CX509DSAPublicKey::DSAParametersL(params); |
|
6079 |
|
6080 CleanupStack::PushL(dsaParams); |
|
6081 |
|
6082 RInteger P = RInteger::NewL(dsaParams->P()); |
|
6083 CleanupStack::PushL(P); |
|
6084 RInteger Q = RInteger::NewL(dsaParams->Q()); |
|
6085 CleanupStack::PushL(Q); |
|
6086 RInteger G = RInteger::NewL(dsaParams->G()); |
|
6087 CleanupStack::PushL(G); |
|
6088 |
|
6089 HBufC8* buf = P.BufferLC(); |
|
6090 |
|
6091 // Copy the shared key |
|
6092 m_param_p.reset(); |
|
6093 eap_status_e status = m_param_p.set_copy_of_buffer(buf->Des().Ptr(), buf->Length()); |
|
6094 if (status != eap_status_ok) |
|
6095 { |
|
6096 User::Leave(KErrNoMemory); |
|
6097 } |
|
6098 |
|
6099 buf = Q.BufferLC(); |
|
6100 m_param_q.reset(); |
|
6101 status = m_param_q.set_copy_of_buffer(buf->Des().Ptr(), buf->Length()); |
|
6102 if (status != eap_status_ok) |
|
6103 { |
|
6104 User::Leave(KErrNoMemory); |
|
6105 } |
|
6106 |
|
6107 buf = G.BufferLC(); |
|
6108 m_param_g.reset(); |
|
6109 status = m_param_g.set_copy_of_buffer(buf->Des().Ptr(), buf->Length()); |
|
6110 if (status != eap_status_ok) |
|
6111 { |
|
6112 User::Leave(KErrNoMemory); |
|
6113 } |
|
6114 |
|
6115 CleanupStack::PopAndDestroy(7); |
|
6116 |
|
6117 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
6118 } |
|
6119 |
|
6120 //-------------------------------------------------- |
|
6121 // MODULE HANDLING FUNCTIONS |
|
6122 //-------------------------------------------------- |
|
6123 eap_status_e eap_am_type_tls_peap_symbian_c::load_module( |
|
6124 const eap_type_value_e /*type*/, |
|
6125 const eap_type_value_e /* tunneling_type */, |
|
6126 abs_eap_base_type_c * const /*partner*/, |
|
6127 eap_base_type_c ** const /*eap_type_if*/, |
|
6128 const bool /*is_client_when_true*/, |
|
6129 const eap_am_network_id_c * const /*receive_network_id*/) |
|
6130 { |
|
6131 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
6132 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
6133 return EAP_STATUS_RETURN(m_am_tools, eap_status_not_supported); |
|
6134 } |
|
6135 |
|
6136 //-------------------------------------------------- |
|
6137 |
|
6138 eap_status_e eap_am_type_tls_peap_symbian_c::check_is_valid_eap_type(const eap_type_value_e eap_type) |
|
6139 { |
|
6140 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
6141 |
|
6142 eap_status_e status(eap_status_illegal_eap_type); |
|
6143 |
|
6144 #ifdef USE_EAP_EXPANDED_TYPES |
|
6145 |
|
6146 EAP_TRACE_DEBUG(m_am_tools, |
|
6147 TRACE_FLAGS_DEFAULT, |
|
6148 (EAPL("eap_am_type_tls_peap_symbian_c::check_is_valid_eap_type:Given EAP vendor ID=%x, type=%x\n"), |
|
6149 eap_type.get_vendor_id(), eap_type.get_vendor_type())); |
|
6150 |
|
6151 for (TInt i = 0; i < m_enabled_tunneling_exp_eap_array.Count(); i++) |
|
6152 { |
|
6153 eap_expanded_type_c expEAPTmp; |
|
6154 |
|
6155 // This will read the expanded EAP from enabledEAPTypes[i]->iExpandedEAPType to expEAPTmp. |
|
6156 // This makes easy to get the vendor type. |
|
6157 eap_expanded_type_c::read_type( m_am_tools, |
|
6158 0, |
|
6159 m_enabled_tunneling_exp_eap_array[i]->iExpandedEAPType.Ptr(), |
|
6160 KExpandedEAPTypeSize, |
|
6161 &expEAPTmp); |
|
6162 |
|
6163 EAP_TRACE_DATA_DEBUG( |
|
6164 m_am_tools, |
|
6165 TRACE_FLAGS_DEFAULT, |
|
6166 (EAPL("check_is_valid_eap_type:Checking with EAP type:"), |
|
6167 m_enabled_tunneling_exp_eap_array[i]->iExpandedEAPType.Ptr(), |
|
6168 m_enabled_tunneling_exp_eap_array[i]->iExpandedEAPType.Size())); |
|
6169 |
|
6170 if (eap_type == expEAPTmp) |
|
6171 { |
|
6172 // This EAp type is one among the enabled ones. Hence a valid EAP type. |
|
6173 status = eap_status_ok; |
|
6174 break; |
|
6175 } |
|
6176 } |
|
6177 |
|
6178 #else // For normal EAP types. |
|
6179 |
|
6180 TEap *eapType = 0; |
|
6181 |
|
6182 TInt i(0); |
|
6183 |
|
6184 for (i = 0; i < m_iap_eap_array.Count(); i++) |
|
6185 { |
|
6186 // Try next EAP type |
|
6187 eapType = m_iap_eap_array[i]; |
|
6188 if (eapType->Enabled == 1) |
|
6189 { |
|
6190 // Convert the string to integer |
|
6191 TLex8 tmp(eapType->UID); |
|
6192 TInt val(0); |
|
6193 tmp.Val(val); |
|
6194 if (val == eap_type) |
|
6195 { |
|
6196 // Allowed |
|
6197 status = eap_status_ok; |
|
6198 break; |
|
6199 } |
|
6200 } |
|
6201 } |
|
6202 |
|
6203 #endif //#ifdef USE_EAP_EXPANDED_TYPES |
|
6204 |
|
6205 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
6206 |
|
6207 return EAP_STATUS_RETURN(m_am_tools, status); |
|
6208 } |
|
6209 |
|
6210 //-------------------------------------------------- |
|
6211 |
|
6212 EAP_FUNC_EXPORT eap_status_e eap_am_type_tls_peap_symbian_c::get_eap_type_list( |
|
6213 eap_array_c<eap_type_value_e> * const eap_type_list) |
|
6214 { |
|
6215 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
6216 |
|
6217 EAP_TRACE_DEBUG(m_am_tools, |
|
6218 TRACE_FLAGS_DEFAULT, |
|
6219 (EAPL("eap_am_type_tls_peap_symbian_c::get_eap_type_list - Start\n"))); |
|
6220 |
|
6221 eap_status_e status(eap_status_illegal_eap_type); |
|
6222 |
|
6223 #ifdef USE_EAP_EXPANDED_TYPES |
|
6224 |
|
6225 // We need to return only the EAP types available as enabled types. |
|
6226 // It means only the ones available in m_enabled_tunneling_exp_eap_array. |
|
6227 |
|
6228 for (TInt i = 0; i < m_enabled_tunneling_exp_eap_array.Count(); i++) |
|
6229 { |
|
6230 TBuf8<KExpandedEAPTypeSize> tmpExpEAP(m_enabled_tunneling_exp_eap_array[i]->iExpandedEAPType); |
|
6231 |
|
6232 EAP_TRACE_DEBUG( |
|
6233 m_am_tools, |
|
6234 TRACE_FLAGS_DEFAULT, |
|
6235 (EAPL("eap_am_type_tls_peap_symbian_c::get_eap_type_list:Enabled expanded EAP type at index=%d\n"), |
|
6236 i)); |
|
6237 |
|
6238 EAP_TRACE_DATA_DEBUG( |
|
6239 m_am_tools, |
|
6240 TRACE_FLAGS_DEFAULT, |
|
6241 (EAPL("Enabled expanded EAP type:"), |
|
6242 tmpExpEAP.Ptr(), |
|
6243 tmpExpEAP.Size())); |
|
6244 |
|
6245 // This is for one expanded EAP type (for the above one). |
|
6246 eap_type_value_e * expandedEAPType = new eap_type_value_e(); |
|
6247 |
|
6248 // Read the expanded EAP type details from an item in m_enabled_tunneling_exp_eap_array. |
|
6249 status = eap_type_value_e::read_type(m_am_tools, |
|
6250 0, |
|
6251 &tmpExpEAP, |
|
6252 tmpExpEAP.Length(), |
|
6253 expandedEAPType); |
|
6254 if (status != eap_status_ok) |
|
6255 { |
|
6256 delete expandedEAPType; |
|
6257 expandedEAPType = 0; |
|
6258 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
6259 return EAP_STATUS_RETURN(m_am_tools, status); |
|
6260 } |
|
6261 |
|
6262 // Add EAP-type to list. |
|
6263 status = eap_type_list->add_object(expandedEAPType, true); |
|
6264 if (status != eap_status_ok) |
|
6265 { |
|
6266 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
6267 return EAP_STATUS_RETURN(m_am_tools, status); |
|
6268 } |
|
6269 |
|
6270 eap_header_string_c eap_string; |
|
6271 EAP_UNREFERENCED_PARAMETER(eap_string); |
|
6272 |
|
6273 EAP_TRACE_DEBUG( |
|
6274 m_am_tools, |
|
6275 TRACE_FLAGS_DEFAULT, |
|
6276 (EAPL("get_eap_type_list():added EAP-type=0x%08x=%s\n"), |
|
6277 expandedEAPType->get_vendor_type(), |
|
6278 eap_string.get_eap_type_string(*expandedEAPType))); |
|
6279 |
|
6280 }// for() |
|
6281 |
|
6282 #else // for normal EAP types. |
|
6283 |
|
6284 TEap *eapType = 0; |
|
6285 |
|
6286 status = eap_type_list->reset(); |
|
6287 if (status != eap_status_ok) |
|
6288 { |
|
6289 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
6290 return EAP_STATUS_RETURN(m_am_tools, status); |
|
6291 } |
|
6292 |
|
6293 |
|
6294 for (TInt i = 0; i < m_iap_eap_array.Count(); i++) |
|
6295 { |
|
6296 // Check if type is enabled |
|
6297 eapType = m_iap_eap_array[i]; |
|
6298 if (eapType->Enabled == 1) |
|
6299 { |
|
6300 TLex8 tmp(eapType->UID); |
|
6301 TInt val(0); |
|
6302 tmp.Val(val); |
|
6303 |
|
6304 eap_type_value_e * const eap_type = new eap_type_value_e(static_cast<eap_type_ietf_values_e>(val)); |
|
6305 if (eap_type == 0) |
|
6306 { |
|
6307 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
6308 return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error); |
|
6309 } |
|
6310 |
|
6311 status = eap_type_list->add_object(eap_type, true); |
|
6312 if (status != eap_status_ok) |
|
6313 { |
|
6314 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
6315 return EAP_STATUS_RETURN(m_am_tools, status); |
|
6316 } |
|
6317 } |
|
6318 } // for() |
|
6319 |
|
6320 #endif // #ifdef USE_EAP_EXPANDED_TYPES |
|
6321 |
|
6322 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
6323 return eap_status_ok; |
|
6324 } |
|
6325 |
|
6326 eap_status_e eap_am_type_tls_peap_symbian_c::unload_module(const eap_type_value_e /*type*/) |
|
6327 { |
|
6328 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
6329 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
6330 return EAP_STATUS_RETURN(m_am_tools, eap_status_not_supported); |
|
6331 } |
|
6332 |
|
6333 |
|
6334 void eap_am_type_tls_peap_symbian_c::send_error_notification(const eap_status_e error) |
|
6335 { |
|
6336 EAP_TRACE_DEBUG(m_am_tools, |
|
6337 TRACE_FLAGS_DEFAULT, |
|
6338 (EAPL("eap_am_type_tls_peap_symbian_c::send_error_notification, error=%d\n"), |
|
6339 error)); |
|
6340 |
|
6341 eap_general_state_variable_e general_state_variable(eap_general_state_authentication_error); |
|
6342 |
|
6343 if (error == eap_status_user_cancel_authentication) |
|
6344 { |
|
6345 general_state_variable = eap_general_state_authentication_cancelled; |
|
6346 } |
|
6347 // Here we swap the addresses. |
|
6348 eap_am_network_id_c send_network_id(m_am_tools, |
|
6349 m_receive_network_id.get_destination_id(), |
|
6350 m_receive_network_id.get_source_id(), |
|
6351 m_receive_network_id.get_type()); |
|
6352 |
|
6353 // Notifies the lower level of an authentication error. |
|
6354 eap_state_notification_c notification( |
|
6355 m_am_tools, |
|
6356 &send_network_id, |
|
6357 m_is_client, |
|
6358 eap_state_notification_eap, |
|
6359 eap_protocol_layer_general, |
|
6360 m_current_eap_type, |
|
6361 eap_state_none, |
|
6362 general_state_variable, |
|
6363 0, |
|
6364 false); |
|
6365 |
|
6366 notification.set_authentication_error(error); |
|
6367 |
|
6368 m_partner->state_notification(¬ification); |
|
6369 } |
|
6370 |
|
6371 eap_status_e eap_am_type_tls_peap_symbian_c::show_certificate_selection_dialog() |
|
6372 { |
|
6373 return eap_status_ok; |
|
6374 } |
|
6375 |
|
6376 eap_status_e eap_am_type_tls_peap_symbian_c::show_manual_identity_dialog() |
|
6377 { |
|
6378 return eap_status_ok; |
|
6379 } |
|
6380 |
|
6381 //-------------------------------------------------- |
|
6382 // CANCELLATION FUNCTIONS |
|
6383 //-------------------------------------------------- |
|
6384 EAP_FUNC_EXPORT eap_status_e eap_am_type_tls_peap_symbian_c::cancel_identity_query() |
|
6385 { |
|
6386 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
6387 |
|
6388 EAP_TRACE_DEBUG( |
|
6389 m_am_tools, |
|
6390 TRACE_FLAGS_DEFAULT, |
|
6391 (EAPL("eap_am_type_tls_peap_symbian_c::cancel_identity_query()\n"))); |
|
6392 |
|
6393 m_cert_if->Cancel(); |
|
6394 |
|
6395 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
6396 return eap_status_ok; |
|
6397 } |
|
6398 |
|
6399 EAP_FUNC_EXPORT eap_status_e eap_am_type_tls_peap_symbian_c::cancel_query_cipher_suites_and_previous_session() |
|
6400 { |
|
6401 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
6402 |
|
6403 EAP_TRACE_DEBUG( |
|
6404 m_am_tools, |
|
6405 TRACE_FLAGS_DEFAULT, |
|
6406 (EAPL("eap_am_type_tls_peap_symbian_c::cancel_query_cipher_suites_and_previous_session()\n"))); |
|
6407 |
|
6408 // This is synchronous |
|
6409 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
6410 return EAP_STATUS_RETURN(m_am_tools, eap_status_ok); |
|
6411 } |
|
6412 |
|
6413 //-------------------------------------------------- |
|
6414 |
|
6415 EAP_FUNC_EXPORT eap_status_e eap_am_type_tls_peap_symbian_c::cancel_select_cipher_suite_and_check_session_id() |
|
6416 { |
|
6417 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
6418 |
|
6419 EAP_TRACE_DEBUG( |
|
6420 m_am_tools, |
|
6421 TRACE_FLAGS_DEFAULT, |
|
6422 (EAPL("eap_am_type_tls_peap_symbian_c::cancel_select_cipher_suite_and_check_session_id()\n"))); |
|
6423 |
|
6424 // This is synchronous |
|
6425 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
6426 return EAP_STATUS_RETURN(m_am_tools, eap_status_ok); |
|
6427 } |
|
6428 |
|
6429 //-------------------------------------------------- |
|
6430 |
|
6431 EAP_FUNC_EXPORT eap_status_e eap_am_type_tls_peap_symbian_c::cancel_verify_certificate_chain() |
|
6432 { |
|
6433 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
6434 |
|
6435 EAP_TRACE_DEBUG( |
|
6436 m_am_tools, |
|
6437 TRACE_FLAGS_DEFAULT, |
|
6438 (EAPL("eap_am_type_tls_peap_symbian_c::cancel_verify_certificate_chain()\n"))); |
|
6439 |
|
6440 m_cert_if->Cancel(); |
|
6441 |
|
6442 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
6443 return EAP_STATUS_RETURN(m_am_tools, eap_status_ok); |
|
6444 } |
|
6445 |
|
6446 //-------------------------------------------------- |
|
6447 |
|
6448 EAP_FUNC_EXPORT eap_status_e eap_am_type_tls_peap_symbian_c::cancel_query_certificate_chain() |
|
6449 { |
|
6450 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
6451 |
|
6452 EAP_TRACE_DEBUG( |
|
6453 m_am_tools, |
|
6454 TRACE_FLAGS_DEFAULT, |
|
6455 (EAPL("eap_am_type_tls_peap_symbian_c::cancel_query_certificate_chain()\n"))); |
|
6456 |
|
6457 m_cert_if->Cancel(); |
|
6458 |
|
6459 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
6460 return EAP_STATUS_RETURN(m_am_tools, eap_status_ok); |
|
6461 } |
|
6462 |
|
6463 //-------------------------------------------------- |
|
6464 |
|
6465 EAP_FUNC_EXPORT eap_status_e eap_am_type_tls_peap_symbian_c::cancel_query_certificate_authorities_and_types() |
|
6466 { |
|
6467 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
6468 |
|
6469 EAP_TRACE_DEBUG( |
|
6470 m_am_tools, |
|
6471 TRACE_FLAGS_DEFAULT, |
|
6472 (EAPL("eap_am_type_tls_peap_symbian_c::cancel_query_certificate_authorities_and_types()\n"))); |
|
6473 |
|
6474 // This is synchronous |
|
6475 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
6476 return EAP_STATUS_RETURN(m_am_tools, eap_status_ok); |
|
6477 } |
|
6478 |
|
6479 //-------------------------------------------------- |
|
6480 |
|
6481 EAP_FUNC_EXPORT eap_status_e eap_am_type_tls_peap_symbian_c::cancel_query_dh_parameters() |
|
6482 { |
|
6483 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
6484 |
|
6485 EAP_TRACE_DEBUG( |
|
6486 m_am_tools, |
|
6487 TRACE_FLAGS_DEFAULT, |
|
6488 (EAPL("eap_am_type_tls_peap_symbian_c::cancel_query_dh_parameters()\n"))); |
|
6489 |
|
6490 // This is synchronous |
|
6491 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
6492 return EAP_STATUS_RETURN(m_am_tools, eap_status_ok); |
|
6493 } |
|
6494 |
|
6495 //-------------------------------------------------- |
|
6496 |
|
6497 EAP_FUNC_EXPORT eap_status_e eap_am_type_tls_peap_symbian_c::cancel_query_dsa_parameters() |
|
6498 { |
|
6499 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
6500 |
|
6501 EAP_TRACE_DEBUG( |
|
6502 m_am_tools, |
|
6503 TRACE_FLAGS_DEFAULT, |
|
6504 (EAPL("eap_am_type_tls_peap_symbian_c::cancel_query_dsa_parameters()\n"))); |
|
6505 |
|
6506 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
6507 return EAP_STATUS_RETURN(m_am_tools, eap_status_not_supported); |
|
6508 } |
|
6509 |
|
6510 //-------------------------------------------------- |
|
6511 |
|
6512 EAP_FUNC_EXPORT eap_status_e eap_am_type_tls_peap_symbian_c::cancel_query_realm() |
|
6513 { |
|
6514 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
6515 |
|
6516 EAP_TRACE_DEBUG( |
|
6517 m_am_tools, |
|
6518 TRACE_FLAGS_DEFAULT, |
|
6519 (EAPL("eap_am_type_tls_peap_symbian_c::cancel_query_realm()\n"))); |
|
6520 |
|
6521 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
6522 return EAP_STATUS_RETURN(m_am_tools, eap_status_not_supported); |
|
6523 } |
|
6524 |
|
6525 //-------------------------------------------------- |
|
6526 |
|
6527 EAP_FUNC_EXPORT eap_status_e eap_am_type_tls_peap_symbian_c::cancel_rsa_encrypt_with_public_key() |
|
6528 { |
|
6529 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
6530 |
|
6531 EAP_TRACE_DEBUG( |
|
6532 m_am_tools, |
|
6533 TRACE_FLAGS_DEFAULT, |
|
6534 (EAPL("eap_am_type_tls_peap_symbian_c::cancel_rsa_encrypt_with_public_key()\n"))); |
|
6535 |
|
6536 // This is synchronous |
|
6537 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
6538 return EAP_STATUS_RETURN(m_am_tools, eap_status_ok); |
|
6539 } |
|
6540 |
|
6541 //-------------------------------------------------- |
|
6542 |
|
6543 EAP_FUNC_EXPORT eap_status_e eap_am_type_tls_peap_symbian_c::cancel_rsa_decrypt_with_private_key() |
|
6544 { |
|
6545 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
6546 |
|
6547 EAP_TRACE_DEBUG( |
|
6548 m_am_tools, |
|
6549 TRACE_FLAGS_DEFAULT, |
|
6550 (EAPL("eap_am_type_tls_peap_symbian_c::cancel_rsa_decrypt_with_private_key()\n"))); |
|
6551 |
|
6552 m_cert_if->Cancel(); |
|
6553 |
|
6554 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
6555 return EAP_STATUS_RETURN(m_am_tools, eap_status_ok); |
|
6556 } |
|
6557 |
|
6558 //-------------------------------------------------- |
|
6559 |
|
6560 EAP_FUNC_EXPORT eap_status_e eap_am_type_tls_peap_symbian_c::cancel_sign_with_private_key() |
|
6561 { |
|
6562 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
6563 |
|
6564 EAP_TRACE_DEBUG( |
|
6565 m_am_tools, |
|
6566 TRACE_FLAGS_DEFAULT, |
|
6567 (EAPL("eap_am_type_tls_peap_symbian_c::cancel_sign_with_private_key()\n"))); |
|
6568 |
|
6569 m_cert_if->CancelSignWithPrivateKey(); // Lets see if separate cancelling works. |
|
6570 |
|
6571 EAP_TRACE_DEBUG( |
|
6572 m_am_tools, |
|
6573 TRACE_FLAGS_DEFAULT, |
|
6574 (EAPL("eap_am_type_tls_peap_symbian_c::cancel_sign_with_private_key() returns\n"))); |
|
6575 |
|
6576 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
6577 return EAP_STATUS_RETURN(m_am_tools, eap_status_ok); |
|
6578 } |
|
6579 |
|
6580 //-------------------------------------------------- |
|
6581 |
|
6582 EAP_FUNC_EXPORT eap_status_e eap_am_type_tls_peap_symbian_c::cancel_verify_with_public_key() |
|
6583 { |
|
6584 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
6585 |
|
6586 EAP_TRACE_DEBUG( |
|
6587 m_am_tools, |
|
6588 TRACE_FLAGS_DEFAULT, |
|
6589 (EAPL("eap_am_type_tls_peap_symbian_c::cancel_verify_with_public_key()\n"))); |
|
6590 |
|
6591 // This is synchronous |
|
6592 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
6593 return EAP_STATUS_RETURN(m_am_tools, eap_status_ok); |
|
6594 } |
|
6595 |
|
6596 //-------------------------------------------------- |
|
6597 |
|
6598 bool eap_am_type_tls_peap_symbian_c::is_session_valid() |
|
6599 { |
|
6600 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
6601 |
|
6602 bool sessionValidity(false); |
|
6603 |
|
6604 TRAPD(err, sessionValidity = is_session_validL()); |
|
6605 if (err != KErrNone) |
|
6606 { |
|
6607 EAP_TRACE_ERROR(m_am_tools, |
|
6608 TRACE_FLAGS_DEFAULT, ( |
|
6609 EAPL("eap_am_type_tls_peap_symbian_c::is_session_valid - LEAVE - error=%d, Assuming session is invalid \n"), |
|
6610 err)); |
|
6611 |
|
6612 sessionValidity = false; |
|
6613 } |
|
6614 |
|
6615 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
6616 |
|
6617 return sessionValidity; |
|
6618 } |
|
6619 |
|
6620 //-------------------------------------------------- |
|
6621 |
|
6622 bool eap_am_type_tls_peap_symbian_c::is_session_validL() |
|
6623 { |
|
6624 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
6625 |
|
6626 EAP_TRACE_DEBUG(m_am_tools, |
|
6627 TRACE_FLAGS_DEFAULT, ( |
|
6628 EAPL("eap_am_type_tls_peap_symbian_c::is_session_valid - m_current_eap_vendor_type=%d \n"), |
|
6629 m_current_eap_vendor_type)); |
|
6630 |
|
6631 TPtrC maxSessionTimeString; |
|
6632 TPtrC lastFullAuthTimeString; |
|
6633 |
|
6634 switch (m_current_eap_vendor_type) |
|
6635 { |
|
6636 case eap_type_tls: |
|
6637 { |
|
6638 maxSessionTimeString.Set(cf_str_EAP_TLS_max_session_validity_time_literal); |
|
6639 lastFullAuthTimeString.Set(KTLSLastFullAuthTime); |
|
6640 } |
|
6641 break; |
|
6642 |
|
6643 case eap_type_peap: |
|
6644 { |
|
6645 maxSessionTimeString.Set(cf_str_EAP_PEAP_max_session_validity_time_literal); |
|
6646 lastFullAuthTimeString.Set(KPEAPLastFullAuthTime); |
|
6647 } |
|
6648 break; |
|
6649 |
|
6650 case eap_type_ttls: |
|
6651 { |
|
6652 maxSessionTimeString.Set(cf_str_EAP_TTLS_max_session_validity_time_literal); |
|
6653 lastFullAuthTimeString.Set(KTTLSLastFullAuthTime); |
|
6654 } |
|
6655 break; |
|
6656 |
|
6657 #if defined(USE_FAST_EAP_TYPE) |
|
6658 case eap_type_fast: |
|
6659 { |
|
6660 maxSessionTimeString.Set(cf_str_EAP_FAST_max_session_validity_time_literal); |
|
6661 lastFullAuthTimeString.Set(KFASTLastFullAuthTime); |
|
6662 } |
|
6663 break; |
|
6664 #endif |
|
6665 |
|
6666 case eap_type_ttls_plain_pap: |
|
6667 { |
|
6668 // we should not come here, ttls pap has its own |
|
6669 // method for checking session validity |
|
6670 EAP_TRACE_ERROR( m_am_tools, TRACE_FLAGS_DEFAULT, ( |
|
6671 EAPL( "ERROR: wrong eap type.\n" ) ) ); |
|
6672 return false; |
|
6673 } |
|
6674 |
|
6675 default: |
|
6676 { |
|
6677 // Should never happen |
|
6678 EAP_TRACE_ERROR(m_am_tools, |
|
6679 TRACE_FLAGS_DEFAULT, ( |
|
6680 EAPL("Unsupported EAP type, m_current_eap_vendor_type=%d \n"), |
|
6681 m_current_eap_vendor_type)); |
|
6682 |
|
6683 return false; // Treat this as Session invalid. |
|
6684 } |
|
6685 } |
|
6686 |
|
6687 HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength); |
|
6688 TPtr sqlStatement = buf->Des(); |
|
6689 |
|
6690 // Query all the relevant parameters |
|
6691 _LIT(KSQLQuery, "SELECT %S, %S FROM %S WHERE %S=%d AND %S=%d AND %S=%d"); |
|
6692 sqlStatement.Format(KSQLQuery, &maxSessionTimeString, &lastFullAuthTimeString, &m_db_table_name, |
|
6693 &KServiceType, m_index_type, |
|
6694 &KServiceIndex, m_index, &KTunnelingType, m_tunneling_vendor_type); |
|
6695 |
|
6696 RDbView view; |
|
6697 // Evaluate view |
|
6698 User::LeaveIfError(view.Prepare(m_database, TDbQuery(sqlStatement))); |
|
6699 CleanupClosePushL(view); |
|
6700 User::LeaveIfError(view.EvaluateAll()); |
|
6701 |
|
6702 // Get the first (and only) row |
|
6703 view.FirstL(); |
|
6704 view.GetL(); |
|
6705 |
|
6706 // Get column set so we get the correct column numbers |
|
6707 CDbColSet* colSet = view.ColSetL(); |
|
6708 CleanupStack::PushL(colSet); |
|
6709 |
|
6710 TInt64 maxSessionTime = view.ColInt64(colSet->ColNo(maxSessionTimeString)); |
|
6711 TInt64 fullAuthTime = view.ColInt64(colSet->ColNo(lastFullAuthTimeString)); |
|
6712 |
|
6713 CleanupStack::PopAndDestroy(colSet); // Delete colSet. |
|
6714 CleanupStack::PopAndDestroy(&view); // Close view. |
|
6715 CleanupStack::PopAndDestroy(buf); // Delete buf. |
|
6716 |
|
6717 // If the max session time from DB is zero then we use the |
|
6718 // one read from configuration file. |
|
6719 |
|
6720 if( maxSessionTime == 0) |
|
6721 { |
|
6722 EAP_TRACE_DEBUG(m_am_tools, |
|
6723 TRACE_FLAGS_DEFAULT, ( |
|
6724 EAPL("Session Validity - Using max session validity time from config file\n"))); |
|
6725 |
|
6726 maxSessionTime = m_max_session_time; // value from configuration file. |
|
6727 } |
|
6728 |
|
6729 // Get the current time. |
|
6730 TTime currentTime; |
|
6731 currentTime.UniversalTime(); |
|
6732 |
|
6733 TTime lastFullAuthTime(fullAuthTime); |
|
6734 |
|
6735 #if defined(_DEBUG) || defined(DEBUG) |
|
6736 |
|
6737 TDateTime currentDateTime = currentTime.DateTime(); |
|
6738 |
|
6739 TDateTime fullAuthDateTime = lastFullAuthTime.DateTime(); |
|
6740 |
|
6741 EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, |
|
6742 (EAPL("Session Validity - Current Time, %2d-%2d-%4d : %2d-%2d-%2d-%d\n"), |
|
6743 currentDateTime.Day()+1, currentDateTime.Month()+1, currentDateTime.Year(), currentDateTime.Hour(), |
|
6744 currentDateTime.Minute(), currentDateTime.Second(), currentDateTime.MicroSecond())); |
|
6745 |
|
6746 EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, |
|
6747 (EAPL("Session Validity - Last Full Auth Time, %2d-%2d-%4d : %2d-%2d-%2d-%d\n"), |
|
6748 fullAuthDateTime.Day()+1, fullAuthDateTime.Month()+1, fullAuthDateTime.Year(), fullAuthDateTime.Hour(), |
|
6749 fullAuthDateTime.Minute(), fullAuthDateTime.Second(), fullAuthDateTime.MicroSecond())); |
|
6750 |
|
6751 #endif |
|
6752 |
|
6753 TTimeIntervalMicroSeconds interval = currentTime.MicroSecondsFrom(lastFullAuthTime); |
|
6754 |
|
6755 EAP_TRACE_DATA_DEBUG( m_am_tools, TRACE_FLAGS_DEFAULT,(EAPL("eap_am_type_tls_peap_symbian_c::is_session_valid:interval in microseconds:"), |
|
6756 &(interval.Int64()), |
|
6757 sizeof(interval.Int64()) ) ); |
|
6758 |
|
6759 EAP_TRACE_DATA_DEBUG( m_am_tools, TRACE_FLAGS_DEFAULT,(EAPL("eap_am_type_tls_peap_symbian_c::is_session_valid:max session time in microseconds:"), |
|
6760 &(maxSessionTime), |
|
6761 sizeof(maxSessionTime) ) ); |
|
6762 |
|
6763 #if defined(_DEBUG) || defined(DEBUG) |
|
6764 |
|
6765 TTimeIntervalMinutes intervalMins; |
|
6766 TInt error = currentTime.MinutesFrom(lastFullAuthTime, intervalMins); |
|
6767 |
|
6768 if(error == KErrNone) |
|
6769 { |
|
6770 EAP_TRACE_DEBUG( |
|
6771 m_am_tools, |
|
6772 TRACE_FLAGS_DEFAULT, |
|
6773 (EAPL("eap_am_type_tls_peap_symbian_c::is_session_validL()") |
|
6774 EAPL("interval in Minutes =%d\n"), |
|
6775 intervalMins.Int())); |
|
6776 } |
|
6777 |
|
6778 #endif |
|
6779 |
|
6780 if( maxSessionTime >= interval.Int64() ) |
|
6781 { |
|
6782 EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("eap_am_type_tls_peap_symbian_c::is_session_valid - Session Valid \n"))); |
|
6783 |
|
6784 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
6785 |
|
6786 return true; |
|
6787 } |
|
6788 else |
|
6789 { |
|
6790 EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("eap_am_type_tls_peap_symbian_c::is_session_valid - Session NOT Valid \n"))); |
|
6791 |
|
6792 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
6793 |
|
6794 return false; |
|
6795 } |
|
6796 } |
|
6797 |
|
6798 //-------------------------------------------------- |
|
6799 |
|
6800 void eap_am_type_tls_peap_symbian_c::store_authentication_timeL() |
|
6801 { |
|
6802 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
6803 |
|
6804 EAP_TRACE_DEBUG(m_am_tools, |
|
6805 TRACE_FLAGS_DEFAULT, |
|
6806 (EAPL("eap_am_type_tls_peap_symbian_c::store_authentication_timeL, index type=%d, index=%d, tunneling type=%d, current eap type=%d\n"), |
|
6807 m_index_type, m_index, m_tunneling_vendor_type, m_current_eap_vendor_type)); |
|
6808 |
|
6809 TPtrC lastFullAuthTimeString; |
|
6810 |
|
6811 switch (m_current_eap_vendor_type) |
|
6812 { |
|
6813 case eap_type_tls: |
|
6814 { |
|
6815 lastFullAuthTimeString.Set(KTLSLastFullAuthTime); |
|
6816 } |
|
6817 break; |
|
6818 |
|
6819 case eap_type_peap: |
|
6820 { |
|
6821 lastFullAuthTimeString.Set(KPEAPLastFullAuthTime); |
|
6822 } |
|
6823 break; |
|
6824 |
|
6825 case eap_type_ttls: |
|
6826 { |
|
6827 lastFullAuthTimeString.Set(KTTLSLastFullAuthTime); |
|
6828 } |
|
6829 break; |
|
6830 |
|
6831 case eap_type_ttls_plain_pap: |
|
6832 { |
|
6833 lastFullAuthTimeString.Set( KTTLSPAPLastFullAuthTime ); |
|
6834 } |
|
6835 break; |
|
6836 |
|
6837 #if defined(USE_FAST_EAP_TYPE) |
|
6838 case eap_type_fast: |
|
6839 { |
|
6840 lastFullAuthTimeString.Set(KFASTLastFullAuthTime); |
|
6841 } |
|
6842 break; |
|
6843 #endif |
|
6844 |
|
6845 default: |
|
6846 { |
|
6847 // Should never happen |
|
6848 EAP_TRACE_ERROR(m_am_tools, |
|
6849 TRACE_FLAGS_DEFAULT, ( |
|
6850 EAPL("Unsupported EAP type, m_current_eap_vendor_type=%d \n"), |
|
6851 m_current_eap_vendor_type)); |
|
6852 |
|
6853 User::Leave(KErrNotSupported); |
|
6854 } |
|
6855 } |
|
6856 |
|
6857 HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength); |
|
6858 TPtr sqlStatement = buf->Des(); |
|
6859 |
|
6860 // Query all the relevant parameters |
|
6861 _LIT(KSQLQuery, "SELECT %S FROM %S WHERE %S=%d AND %S=%d AND %S=%d"); |
|
6862 sqlStatement.Format(KSQLQuery, &lastFullAuthTimeString, &m_db_table_name, |
|
6863 &KServiceType, m_index_type, |
|
6864 &KServiceIndex, m_index, &KTunnelingType, m_tunneling_vendor_type); |
|
6865 |
|
6866 RDbView view; |
|
6867 // Evaluate view |
|
6868 User::LeaveIfError(view.Prepare(m_database, TDbQuery(sqlStatement), TDbWindow::EUnlimited)); |
|
6869 CleanupClosePushL(view); |
|
6870 User::LeaveIfError(view.EvaluateAll()); |
|
6871 |
|
6872 // Get the first (and only) row for updation. |
|
6873 view.FirstL(); |
|
6874 view.UpdateL(); |
|
6875 |
|
6876 // Get column set so we get the correct column numbers |
|
6877 CDbColSet* colSet = view.ColSetL(); |
|
6878 CleanupStack::PushL(colSet); |
|
6879 |
|
6880 // Get the current universal time. |
|
6881 TTime currentTime; |
|
6882 currentTime.UniversalTime(); |
|
6883 |
|
6884 #if defined(_DEBUG) || defined(DEBUG) |
|
6885 |
|
6886 TDateTime currentDateTime = currentTime.DateTime(); |
|
6887 |
|
6888 EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, |
|
6889 (EAPL("eap_am_type_tls_peap_symbian_c::store_authentication_time, %2d-%2d-%4d : %2d-%2d-%2d-%d\n"), |
|
6890 currentDateTime.Day()+1, currentDateTime.Month()+1,currentDateTime.Year(), currentDateTime.Hour(), |
|
6891 currentDateTime.Minute(), currentDateTime.Second(), currentDateTime.MicroSecond())); |
|
6892 |
|
6893 #endif |
|
6894 |
|
6895 TInt64 fullAuthTime = currentTime.Int64(); |
|
6896 |
|
6897 view.SetColL(colSet->ColNo(lastFullAuthTimeString), fullAuthTime); |
|
6898 |
|
6899 view.PutL(); |
|
6900 |
|
6901 CleanupStack::PopAndDestroy(colSet); // Delete colSet. |
|
6902 CleanupStack::PopAndDestroy(&view); // Close view. |
|
6903 CleanupStack::PopAndDestroy(buf); // Delete buf. |
|
6904 |
|
6905 EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("eap_am_type_tls_peap_symbian_c::store_authentication_timeL - End \n"))); |
|
6906 |
|
6907 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
6908 } |
|
6909 |
|
6910 //-------------------------------------------------- |
|
6911 |
|
6912 EAP_FUNC_EXPORT void eap_am_type_tls_peap_symbian_c::set_peap_version( |
|
6913 const peap_version_e /* peap_version */, |
|
6914 const bool /* use_tppd_tls_peap */, |
|
6915 const bool /* use_tppd_peapv1_acknowledge_hack */) |
|
6916 { |
|
6917 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
6918 |
|
6919 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
6920 } |
|
6921 |
|
6922 #if defined(USE_FAST_EAP_TYPE) |
|
6923 |
|
6924 //-------------------------------------------------- |
|
6925 |
|
6926 EAP_FUNC_EXPORT eap_status_e eap_am_type_tls_peap_symbian_c::read_authority_identity(eap_variable_data_c * const /* authority_identity */) |
|
6927 { |
|
6928 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
6929 |
|
6930 EAP_TRACE_DEBUG( |
|
6931 m_am_tools, |
|
6932 TRACE_FLAGS_DEFAULT, |
|
6933 (EAPL("EAP-FAST: %s: crypto_function: eap_am_type_tls_peap_symbian_c::read_authority_identity(): ") |
|
6934 EAPL("this = 0x%08x\n"), |
|
6935 (m_is_client == true ? "client": "server"), |
|
6936 this)); |
|
6937 |
|
6938 |
|
6939 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
6940 return EAP_STATUS_RETURN(m_am_tools, eap_status_not_supported); |
|
6941 } |
|
6942 |
|
6943 //-------------------------------------------------- |
|
6944 |
|
6945 // This is commented in tls_am_application_eap_fast_c::query_pac_of_type(). |
|
6946 EAP_FUNC_EXPORT eap_status_e eap_am_type_tls_peap_symbian_c::query_pac_of_type( |
|
6947 const eap_fast_pac_type_e /* pac_type */) |
|
6948 |
|
6949 { |
|
6950 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
6951 |
|
6952 EAP_TRACE_DEBUG( |
|
6953 m_am_tools, |
|
6954 TRACE_FLAGS_DEFAULT, |
|
6955 (EAPL("EAP-FAST: %s: crypto_function: eap_am_type_tls_peap_symbian_c::query_pac_of_type(): ") |
|
6956 EAPL("this = 0x%08x\n"), |
|
6957 (m_is_client == true ? "client": "server"), |
|
6958 this)); |
|
6959 |
|
6960 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
6961 return EAP_STATUS_RETURN(m_am_tools, eap_status_not_supported); |
|
6962 } |
|
6963 |
|
6964 //-------------------------------------------------- |
|
6965 |
|
6966 #if defined(USE_EAP_CORE_SERVER) |
|
6967 /** |
|
6968 * This function call is always asyncronous. |
|
6969 * It will be completed always with complete_verify_pac() function call. |
|
6970 * Function verifies the received PAC is valid. |
|
6971 */ |
|
6972 EAP_FUNC_EXPORT eap_status_e eap_am_type_tls_peap_symbian_c::verify_pac(const eap_fast_variable_data_c * const /* tlv_pac */) |
|
6973 { |
|
6974 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
6975 |
|
6976 EAP_TRACE_DEBUG( |
|
6977 m_am_tools, |
|
6978 TRACE_FLAGS_DEFAULT, |
|
6979 (EAPL("EAP-FAST: %s: crypto_function: eap_am_type_tls_peap_symbian_c::verify_pac(): ") |
|
6980 EAPL("this = 0x%08x\n"), |
|
6981 (m_is_client == true ? "client": "server"), |
|
6982 this)); |
|
6983 |
|
6984 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
6985 return EAP_STATUS_RETURN(m_am_tools, eap_status_not_supported); |
|
6986 } |
|
6987 |
|
6988 #endif //#if defined(USE_EAP_CORE_SERVER) |
|
6989 //-------------------------------------------------- |
|
6990 |
|
6991 |
|
6992 // This is commented in eap_am_fast_pac_store_services_c::query_user_permission_for_A_ID(). |
|
6993 EAP_FUNC_EXPORT eap_status_e eap_am_type_tls_peap_symbian_c::query_user_permission_for_A_ID( |
|
6994 const eap_fast_pac_store_pending_operation_e in_pending_operation, |
|
6995 const eap_fast_variable_data_c * const in_pac_attribute_A_ID_info, |
|
6996 const eap_fast_variable_data_c * const in_pac_attribute_A_ID) |
|
6997 { |
|
6998 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
6999 |
|
7000 EAP_TRACE_DEBUG( |
|
7001 m_am_tools, |
|
7002 TRACE_FLAGS_DEFAULT, |
|
7003 (EAPL("EAP-FAST: %s: eap_am_type_tls_peap_symbian_c::query_user_permission_for_A_ID(): ") |
|
7004 EAPL("this = 0x%08x\n"), |
|
7005 (m_is_client == true ? "client": "server"), |
|
7006 this)); |
|
7007 |
|
7008 eap_status_e status(eap_status_ok); |
|
7009 |
|
7010 m_pending_operation = in_pending_operation; |
|
7011 |
|
7012 if (in_pac_attribute_A_ID_info->get_data_length()>0) |
|
7013 { |
|
7014 TRAPD(err, status = QueryUserPermissionForAIDL(in_pac_attribute_A_ID_info, in_pac_attribute_A_ID )); |
|
7015 if (err != KErrNone) |
|
7016 { |
|
7017 EAP_TRACE_DEBUG( |
|
7018 m_am_tools, |
|
7019 TRACE_FLAGS_DEFAULT, |
|
7020 (EAPL("EAP-FAST: eap_am_type_tls_peap_symbian_c::read_PAC_store_data() ERROR: LEAVE from QueryUserPermissionForAIDL error=%d"), |
|
7021 err)); |
|
7022 |
|
7023 m_eap_fast_completion_status = m_am_tools->convert_am_error_to_eapol_error(err); |
|
7024 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
7025 return EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status); |
|
7026 } |
|
7027 } |
|
7028 if (status == KErrNone) |
|
7029 { |
|
7030 m_eap_fast_completion_status = eap_status_pending_request; |
|
7031 } |
|
7032 else |
|
7033 { |
|
7034 m_eap_fast_completion_status = status; |
|
7035 } |
|
7036 |
|
7037 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
7038 return EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status); |
|
7039 } |
|
7040 |
|
7041 //-------------------------------------------------- |
|
7042 |
|
7043 eap_status_e eap_am_type_tls_peap_symbian_c::QueryUserPermissionForAIDL( |
|
7044 const eap_fast_variable_data_c * const in_pac_attribute_A_ID_info, |
|
7045 const eap_fast_variable_data_c * const in_pac_attribute_A_ID) |
|
7046 { |
|
7047 eap_status_e status(eap_status_ok); |
|
7048 |
|
7049 HBufC8* A_ID_info8 = HBufC8::NewLC((in_pac_attribute_A_ID_info->get_data_length())); |
|
7050 TPtr8 A_ID_infoPtr8 = A_ID_info8->Des(); |
|
7051 |
|
7052 HBufC* A_ID_info = HBufC::NewLC((in_pac_attribute_A_ID_info->get_data_length())); |
|
7053 TPtr A_ID_infoPtr = A_ID_info->Des(); |
|
7054 |
|
7055 HBufC8* A_ID = HBufC8::NewLC((in_pac_attribute_A_ID->get_data_length())); |
|
7056 TPtr8 A_IDPtr = A_ID->Des(); |
|
7057 |
|
7058 A_ID_infoPtr8.Copy(in_pac_attribute_A_ID_info->get_data(in_pac_attribute_A_ID_info->get_data_length()),in_pac_attribute_A_ID_info->get_data_length() ); |
|
7059 A_ID_infoPtr.Copy(A_ID_infoPtr8); |
|
7060 |
|
7061 A_IDPtr.Copy(in_pac_attribute_A_ID->get_data(in_pac_attribute_A_ID->get_data_length()),in_pac_attribute_A_ID->get_data_length() ); |
|
7062 |
|
7063 EAP_TRACE_DATA_DEBUG_SYMBIAN( |
|
7064 ("eap_am_type_tls_peap_symbian_c::query_user_permission_for_A_ID(): in_pac_attribute_A_ID_info", |
|
7065 (A_ID_infoPtr.Ptr()), |
|
7066 (in_pac_attribute_A_ID_info->get_data_length()))); |
|
7067 |
|
7068 EAP_TRACE_DATA_DEBUG_SYMBIAN( |
|
7069 ("eap_am_type_tls_peap_symbian_c::query_user_permission_for_A_ID(): in_pac_attribute_A_ID", |
|
7070 (A_IDPtr.Ptr()), |
|
7071 (in_pac_attribute_A_ID->get_data_length()))); |
|
7072 |
|
7073 if (A_ID_infoPtr.Size()>KMaxEapFastNotifierBufLength) |
|
7074 { |
|
7075 CleanupStack::PopAndDestroy(3); // A_ID, A_ID_info |
|
7076 status = m_am_tools->convert_am_error_to_eapol_error(KErrArgument); |
|
7077 |
|
7078 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
7079 return EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status); |
|
7080 } |
|
7081 |
|
7082 TBool startedOk = ETrue; |
|
7083 |
|
7084 if (!iEapFastActiveNotes) |
|
7085 { |
|
7086 TRAPD( err, iEapFastActiveNotes = CEapFastActive::NewL( this ) ); |
|
7087 |
|
7088 if ( err != KErrNone ) |
|
7089 { |
|
7090 status = eap_status_allocation_error; |
|
7091 } |
|
7092 } |
|
7093 if ( status == KErrNone ) |
|
7094 { |
|
7095 //update buffer |
|
7096 iEapFastActiveNotes->UpdateInputBuf( A_ID_infoPtr ); |
|
7097 // start query install dialog |
|
7098 // asynch. call, return immediately |
|
7099 startedOk = iEapFastActiveNotes->Start( |
|
7100 CEapFastActive::EEapFastActiveInstallPacQueryDialog ); |
|
7101 if ( startedOk == EFalse ) |
|
7102 { |
|
7103 status = eap_status_process_general_error; |
|
7104 } |
|
7105 } |
|
7106 else |
|
7107 { |
|
7108 status = eap_status_process_general_error; |
|
7109 } |
|
7110 |
|
7111 CleanupStack::PopAndDestroy(3); // A_ID, A_ID_info |
|
7112 |
|
7113 return status; |
|
7114 } |
|
7115 |
|
7116 |
|
7117 EAP_FUNC_EXPORT eap_status_e eap_am_type_tls_peap_symbian_c::read_PAC_store_data( |
|
7118 const eap_fast_pac_store_pending_operation_e in_pending_operation, |
|
7119 EAP_TEMPLATE_CONST eap_array_c<eap_fast_pac_store_data_c> * const in_references) |
|
7120 { |
|
7121 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
7122 |
|
7123 m_eap_fast_pac_store_pending_operation = in_pending_operation; |
|
7124 |
|
7125 EAP_TRACE_DEBUG( |
|
7126 m_am_tools, |
|
7127 TRACE_FLAGS_DEFAULT, |
|
7128 (EAPL("EAP-FAST: eap_am_type_tls_peap_symbian_c::read_PAC_store_data()\n"))); |
|
7129 |
|
7130 EAP_TRACE_RETURN_STRING(m_am_tools, "returns: eap_am_type_tls_peap_symbian_c::read_PAC_store_data()"); |
|
7131 |
|
7132 m_eap_fast_completion_status = eap_status_ok; |
|
7133 m_both_asked = 0; |
|
7134 m_both_completed = 0; |
|
7135 |
|
7136 TRAPD(error, ReadPACStoredataL(in_pending_operation, in_references)); |
|
7137 if(error != KErrNone) |
|
7138 { |
|
7139 EAP_TRACE_DEBUG( |
|
7140 m_am_tools, |
|
7141 TRACE_FLAGS_DEFAULT, |
|
7142 (EAPL("EAP-FAST: eap_am_type_tls_peap_symbian_c::read_PAC_store_data() ERROR: LEAVE from ReadPACStoredataL error=%d"), |
|
7143 error)); |
|
7144 |
|
7145 m_eap_fast_completion_status = m_am_tools->convert_am_error_to_eapol_error(error); |
|
7146 } |
|
7147 |
|
7148 // - - - - - - - - - - - - - - - - - - - - - - - - |
|
7149 |
|
7150 // Proceed with normal complete case. |
|
7151 |
|
7152 if(m_eap_fast_completion_status == eap_status_ok) |
|
7153 { |
|
7154 EAP_TRACE_DEBUG( |
|
7155 m_am_tools, |
|
7156 TRACE_FLAGS_DEFAULT, |
|
7157 (EAPL("EAP-FAST: eap_am_type_tls_peap_symbian_c::complete_read_PAC_store_data(), m_eap_fast_completion_status=%d\n"), |
|
7158 (m_is_client == true ? "client": "server"), m_eap_fast_completion_status)); |
|
7159 |
|
7160 eap_status_e status = m_tls_application->complete_read_PAC_store_data( |
|
7161 m_eap_fast_completion_status, |
|
7162 m_eap_fast_pac_store_pending_operation, |
|
7163 &m_references_and_data_blocks); // m_ready_references_and_data_blocks |
|
7164 } |
|
7165 else if (m_eap_fast_completion_status == eap_status_pending_request ) |
|
7166 { |
|
7167 |
|
7168 m_ready_references_and_data_blocks.reset(); |
|
7169 m_new_references_and_data_blocks.reset(); |
|
7170 } |
|
7171 else |
|
7172 { |
|
7173 EAP_TRACE_DEBUG( |
|
7174 m_am_tools, |
|
7175 TRACE_FLAGS_DEFAULT, |
|
7176 (EAPL("EAP-FAST: eap_am_type_tls_peap_symbian_c::read_PAC_store_data() ERROR =%d"), |
|
7177 m_eap_fast_completion_status)); |
|
7178 |
|
7179 m_references_and_data_blocks.reset(); |
|
7180 |
|
7181 m_eap_fast_completion_status = m_tls_application->complete_read_PAC_store_data( |
|
7182 m_eap_fast_completion_status, |
|
7183 m_eap_fast_pac_store_pending_operation, |
|
7184 &m_references_and_data_blocks); |
|
7185 |
|
7186 // ERROR. |
|
7187 (void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status); |
|
7188 } |
|
7189 |
|
7190 // - - - - - - - - - - - - - - - - - - - - - - - - |
|
7191 |
|
7192 EAP_TRACE_DEBUG_SYMBIAN( |
|
7193 (_L("eap_am_type_tls_peap_symbian_c::read_PAC_store_data-End, m_eap_fast_completion_status=%d"), |
|
7194 m_eap_fast_completion_status)); |
|
7195 |
|
7196 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
7197 return EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status); |
|
7198 } |
|
7199 |
|
7200 //-------------------------------------------------- |
|
7201 |
|
7202 void eap_am_type_tls_peap_symbian_c::ReadPACStoredataL( |
|
7203 const eap_fast_pac_store_pending_operation_e in_pending_operation, |
|
7204 EAP_TEMPLATE_CONST eap_array_c<eap_fast_pac_store_data_c> * const in_references) |
|
7205 { |
|
7206 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
7207 |
|
7208 EAP_TRACE_DEBUG( |
|
7209 m_am_tools, |
|
7210 TRACE_FLAGS_DEFAULT, |
|
7211 (EAPL("EAP-FAST: eap_am_type_tls_peap_symbian_c::ReadPACStoredataL() Start \n"))); |
|
7212 |
|
7213 EAP_TRACE_RETURN_STRING(m_am_tools, "returns: eap_am_type_tls_peap_symbian_c::ReadPACStoredataL()"); |
|
7214 |
|
7215 // - - - - - - - - - - - - - - - - - - - - - - - - |
|
7216 |
|
7217 m_eap_fast_completion_status = eap_status_ok; |
|
7218 |
|
7219 m_eap_fast_pac_store_pending_operation = in_pending_operation; |
|
7220 |
|
7221 (void) m_references_and_data_blocks.reset(); |
|
7222 |
|
7223 |
|
7224 for (u32_t ind = 0ul; ind < in_references->get_object_count(); ++ind) |
|
7225 { |
|
7226 const eap_fast_pac_store_data_c * const data_reference = in_references->get_object(ind); |
|
7227 |
|
7228 if (data_reference != 0 |
|
7229 && data_reference->get_is_valid() == true) |
|
7230 { |
|
7231 eap_pac_store_data_type_e pacStoreDataRefType = data_reference->get_type(); |
|
7232 |
|
7233 EAP_TRACE_DEBUG( |
|
7234 m_am_tools, |
|
7235 TRACE_FLAGS_DEFAULT, |
|
7236 (EAPL("ReadPACStoredataL(): data_reference type=%d=%s\n"), |
|
7237 pacStoreDataRefType, |
|
7238 eap_fast_tlv_header_string_c::get_fast_pac_store_data_string(pacStoreDataRefType))); |
|
7239 |
|
7240 EAP_TRACE_DATA_DEBUG_SYMBIAN( |
|
7241 ("ReadPACStoredataL(): data_reference reference:", |
|
7242 data_reference->get_reference()->get_data(data_reference->get_reference()->get_data_length()), |
|
7243 data_reference->get_reference()->get_data_length())); |
|
7244 |
|
7245 switch(pacStoreDataRefType) |
|
7246 { |
|
7247 case eap_pac_store_data_type_PAC_store_master_key: |
|
7248 { |
|
7249 // To read master key. |
|
7250 |
|
7251 eap_variable_data_c master_key(m_am_tools); |
|
7252 |
|
7253 #ifdef USE_PAC_STORE |
|
7254 // Get master key from PAC store DB. |
|
7255 GetPacStoreDbDataL( |
|
7256 pacStoreDataRefType, |
|
7257 &master_key); |
|
7258 |
|
7259 #endif // End: #ifdef USE_PAC_STORE |
|
7260 |
|
7261 // master_key should have the master key now. |
|
7262 // Doesn't matter even if there is no master key (master_key is empty). |
|
7263 // Proceed as normal case. |
|
7264 |
|
7265 eap_fast_pac_store_data_c * const new_data = new eap_fast_pac_store_data_c(m_am_tools); |
|
7266 |
|
7267 eap_automatic_variable_c<eap_fast_pac_store_data_c> automatic_new_data( |
|
7268 m_am_tools, new_data); |
|
7269 |
|
7270 if (new_data == 0) |
|
7271 { |
|
7272 m_eap_fast_completion_status = eap_status_allocation_error; |
|
7273 (void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status); |
|
7274 break; |
|
7275 } |
|
7276 |
|
7277 new_data->set_type(pacStoreDataRefType); |
|
7278 |
|
7279 // Set the reference. |
|
7280 m_eap_fast_completion_status = new_data->get_writable_reference()->set_copy_of_buffer(data_reference->get_reference()); |
|
7281 if (m_eap_fast_completion_status != eap_status_ok) |
|
7282 { |
|
7283 (void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status); |
|
7284 break; |
|
7285 } |
|
7286 |
|
7287 m_eap_fast_completion_status = new_data->get_writable_data()->set_copy_of_buffer(&master_key); |
|
7288 |
|
7289 if (m_eap_fast_completion_status != eap_status_ok) |
|
7290 { |
|
7291 (void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status); |
|
7292 break; |
|
7293 } |
|
7294 |
|
7295 automatic_new_data.do_not_free_variable(); |
|
7296 |
|
7297 m_eap_fast_completion_status = m_references_and_data_blocks.add_object(new_data, true); |
|
7298 if (m_eap_fast_completion_status != eap_status_ok) |
|
7299 { |
|
7300 (void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status); |
|
7301 break; |
|
7302 } |
|
7303 |
|
7304 EAP_TRACE_DATA_DEBUG_SYMBIAN( |
|
7305 ("eap_pac_store_data_type_PAC_store_master_key - added data", |
|
7306 (new_data->get_data())->get_data((new_data->get_data())->get_data_length()), |
|
7307 (new_data->get_data())->get_data_length())); |
|
7308 |
|
7309 break; |
|
7310 |
|
7311 } // End: case eap_pac_store_data_type_PAC_store_master_key: |
|
7312 |
|
7313 case eap_pac_store_data_type_reference_counter: |
|
7314 { |
|
7315 // To read reference counter. |
|
7316 |
|
7317 eap_variable_data_c reference_counter(m_am_tools); |
|
7318 |
|
7319 #ifdef USE_PAC_STORE |
|
7320 // Get reference counter from PAC store DB. |
|
7321 GetPacStoreDbDataL( |
|
7322 pacStoreDataRefType, |
|
7323 &reference_counter); |
|
7324 |
|
7325 #endif // End: #ifdef USE_PAC_STORE |
|
7326 |
|
7327 // reference_counter should have the reference counter now. |
|
7328 // Doesn't matter even if it is empty. Proceed as normal case. |
|
7329 |
|
7330 eap_fast_pac_store_data_c * const new_data = new eap_fast_pac_store_data_c(m_am_tools); |
|
7331 |
|
7332 eap_automatic_variable_c<eap_fast_pac_store_data_c> automatic_new_data( |
|
7333 m_am_tools, new_data); |
|
7334 |
|
7335 if (new_data == 0) |
|
7336 { |
|
7337 m_eap_fast_completion_status = eap_status_allocation_error; |
|
7338 (void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status); |
|
7339 break; |
|
7340 } |
|
7341 |
|
7342 new_data->set_type(pacStoreDataRefType); |
|
7343 |
|
7344 // Set the reference. |
|
7345 m_eap_fast_completion_status = new_data->get_writable_reference()->set_copy_of_buffer(data_reference->get_reference()); |
|
7346 if (m_eap_fast_completion_status != eap_status_ok) |
|
7347 { |
|
7348 (void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status); |
|
7349 break; |
|
7350 } |
|
7351 |
|
7352 |
|
7353 m_eap_fast_completion_status = new_data->get_writable_data()->set_copy_of_buffer(&reference_counter); |
|
7354 if (m_eap_fast_completion_status != eap_status_ok) |
|
7355 { |
|
7356 (void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status); |
|
7357 break; |
|
7358 } |
|
7359 |
|
7360 automatic_new_data.do_not_free_variable(); |
|
7361 |
|
7362 m_eap_fast_completion_status = m_references_and_data_blocks.add_object(new_data, true); |
|
7363 if (m_eap_fast_completion_status != eap_status_ok) |
|
7364 { |
|
7365 (void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status); |
|
7366 break; |
|
7367 } |
|
7368 |
|
7369 EAP_TRACE_DATA_DEBUG_SYMBIAN( |
|
7370 ("eap_pac_store_data_type_reference_counter - added data", |
|
7371 (new_data->get_data())->get_data((new_data->get_data())->get_data_length()), |
|
7372 (new_data->get_data())->get_data_length())); |
|
7373 |
|
7374 break; |
|
7375 |
|
7376 } // End: case eap_pac_store_data_type_reference_counter: |
|
7377 |
|
7378 case eap_pac_store_data_type_group_data: // Check the reference (the ref is data_reference->get_reference()) and provide only the value from groups table. |
|
7379 { |
|
7380 // To read a particular group data. |
|
7381 |
|
7382 eap_variable_data_c group_data(m_am_tools); |
|
7383 |
|
7384 #ifdef USE_PAC_STORE |
|
7385 // Get group data from PAC store DB, using the reference. |
|
7386 GetPacStoreDbDataL( |
|
7387 pacStoreDataRefType, |
|
7388 &group_data, |
|
7389 data_reference->get_reference()); |
|
7390 |
|
7391 #endif // End: #ifdef USE_PAC_STORE |
|
7392 |
|
7393 // group_data should have the value stored in PAC store now. |
|
7394 // Doesn't matter even if it is empty. Proceed as normal case. |
|
7395 |
|
7396 eap_fast_pac_store_data_c * const new_data = new eap_fast_pac_store_data_c(m_am_tools); |
|
7397 |
|
7398 eap_automatic_variable_c<eap_fast_pac_store_data_c> automatic_new_data( |
|
7399 m_am_tools, new_data); |
|
7400 |
|
7401 if (new_data == 0) |
|
7402 { |
|
7403 m_eap_fast_completion_status = eap_status_allocation_error; |
|
7404 (void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status); |
|
7405 break; |
|
7406 } |
|
7407 |
|
7408 new_data->set_type(pacStoreDataRefType); |
|
7409 |
|
7410 // Set the reference. |
|
7411 m_eap_fast_completion_status = new_data->get_writable_reference()->set_copy_of_buffer(data_reference->get_reference()); |
|
7412 if (m_eap_fast_completion_status != eap_status_ok) |
|
7413 { |
|
7414 (void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status); |
|
7415 break; |
|
7416 } |
|
7417 |
|
7418 m_eap_fast_completion_status = new_data->get_writable_data()->set_copy_of_buffer(&group_data); |
|
7419 if (m_eap_fast_completion_status != eap_status_ok) |
|
7420 { |
|
7421 (void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status); |
|
7422 break; |
|
7423 } |
|
7424 |
|
7425 automatic_new_data.do_not_free_variable(); |
|
7426 |
|
7427 m_eap_fast_completion_status = m_references_and_data_blocks.add_object(new_data, true); |
|
7428 if (m_eap_fast_completion_status != eap_status_ok) |
|
7429 { |
|
7430 (void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status); |
|
7431 break; |
|
7432 } |
|
7433 |
|
7434 EAP_TRACE_DATA_DEBUG_SYMBIAN( |
|
7435 ("eap_pac_store_data_type_group_data - added data", |
|
7436 (new_data->get_data())->get_data((new_data->get_data())->get_data_length()), |
|
7437 (new_data->get_data())->get_data_length())); |
|
7438 |
|
7439 break; |
|
7440 |
|
7441 } // End: case eap_pac_store_data_type_group_data: |
|
7442 |
|
7443 case eap_pac_store_data_type_A_ID_data: // Check the reference and provide only the value from AIDs table. |
|
7444 { |
|
7445 // To read a particular AID data. |
|
7446 |
|
7447 eap_variable_data_c aid_data(m_am_tools); |
|
7448 |
|
7449 #ifdef USE_PAC_STORE |
|
7450 // Get AID data from PAC store DB, using the reference. |
|
7451 GetPacStoreDbDataL( |
|
7452 pacStoreDataRefType, |
|
7453 &aid_data, |
|
7454 data_reference->get_reference()); |
|
7455 |
|
7456 #endif // End: #ifdef USE_PAC_STORE |
|
7457 |
|
7458 // aid_data should have the value stored in PAC store now. |
|
7459 // Doesn't matter even if it is empty. Proceed as normal case. |
|
7460 |
|
7461 eap_fast_pac_store_data_c * const new_data = new eap_fast_pac_store_data_c(m_am_tools); |
|
7462 |
|
7463 eap_automatic_variable_c<eap_fast_pac_store_data_c> automatic_new_data( |
|
7464 m_am_tools, new_data); |
|
7465 |
|
7466 if (new_data == 0) |
|
7467 { |
|
7468 m_eap_fast_completion_status = eap_status_allocation_error; |
|
7469 (void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status); |
|
7470 break; |
|
7471 } |
|
7472 |
|
7473 new_data->set_type(pacStoreDataRefType); |
|
7474 |
|
7475 // Set the reference. |
|
7476 m_eap_fast_completion_status = new_data->get_writable_reference()->set_copy_of_buffer(data_reference->get_reference()); |
|
7477 if (m_eap_fast_completion_status != eap_status_ok) |
|
7478 { |
|
7479 (void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status); |
|
7480 break; |
|
7481 } |
|
7482 |
|
7483 m_eap_fast_completion_status = new_data->get_writable_data()->set_copy_of_buffer(&aid_data); |
|
7484 if (m_eap_fast_completion_status != eap_status_ok) |
|
7485 { |
|
7486 (void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status); |
|
7487 break; |
|
7488 } |
|
7489 |
|
7490 automatic_new_data.do_not_free_variable(); |
|
7491 |
|
7492 m_eap_fast_completion_status = m_references_and_data_blocks.add_object(new_data, true); |
|
7493 if (m_eap_fast_completion_status != eap_status_ok) |
|
7494 { |
|
7495 (void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status); |
|
7496 break; |
|
7497 } |
|
7498 |
|
7499 EAP_TRACE_DATA_DEBUG_SYMBIAN( |
|
7500 ("eap_pac_store_data_type_A_ID_data - added data", |
|
7501 (new_data->get_data())->get_data((new_data->get_data())->get_data_length()), |
|
7502 (new_data->get_data())->get_data_length())); |
|
7503 |
|
7504 break; |
|
7505 |
|
7506 } // End: case eap_pac_store_data_type_A_ID_data: |
|
7507 |
|
7508 case eap_pac_store_data_type_PAC_data: // Check the reference and provide only the value from PACs table. |
|
7509 { |
|
7510 // To read a particular PAC data. |
|
7511 |
|
7512 eap_variable_data_c pac_data(m_am_tools); |
|
7513 |
|
7514 #ifdef USE_PAC_STORE |
|
7515 // Get PAC data from PAC store DB, using the reference. |
|
7516 GetPacStoreDbDataL( |
|
7517 pacStoreDataRefType, |
|
7518 &pac_data, |
|
7519 data_reference->get_reference()); |
|
7520 |
|
7521 #endif // End: #ifdef USE_PAC_STORE |
|
7522 |
|
7523 // pac_data should have the value stored in PAC store now. |
|
7524 // Doesn't matter even if it is empty. Proceed as normal case. |
|
7525 |
|
7526 eap_fast_pac_store_data_c * const new_data = new eap_fast_pac_store_data_c(m_am_tools); |
|
7527 |
|
7528 eap_automatic_variable_c<eap_fast_pac_store_data_c> automatic_new_data( |
|
7529 m_am_tools, new_data); |
|
7530 |
|
7531 if (new_data == 0) |
|
7532 { |
|
7533 m_eap_fast_completion_status = eap_status_allocation_error; |
|
7534 (void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status); |
|
7535 break; |
|
7536 } |
|
7537 |
|
7538 new_data->set_type(pacStoreDataRefType); |
|
7539 |
|
7540 // Set the reference. |
|
7541 m_eap_fast_completion_status = new_data->get_writable_reference()->set_copy_of_buffer(data_reference->get_reference()); |
|
7542 if (m_eap_fast_completion_status != eap_status_ok) |
|
7543 { |
|
7544 (void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status); |
|
7545 break; |
|
7546 } |
|
7547 |
|
7548 m_eap_fast_completion_status = new_data->get_writable_data()->set_copy_of_buffer(&pac_data); |
|
7549 if (m_eap_fast_completion_status != eap_status_ok) |
|
7550 { |
|
7551 (void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status); |
|
7552 break; |
|
7553 } |
|
7554 |
|
7555 automatic_new_data.do_not_free_variable(); |
|
7556 |
|
7557 m_eap_fast_completion_status = m_references_and_data_blocks.add_object(new_data, true); |
|
7558 if (m_eap_fast_completion_status != eap_status_ok) |
|
7559 { |
|
7560 (void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status); |
|
7561 break; |
|
7562 } |
|
7563 |
|
7564 EAP_TRACE_DATA_DEBUG_SYMBIAN( |
|
7565 ("eap_pac_store_data_type_PAC_data - added data", |
|
7566 (new_data->get_data())->get_data((new_data->get_data())->get_data_length()), |
|
7567 (new_data->get_data())->get_data_length())); |
|
7568 |
|
7569 break; |
|
7570 |
|
7571 } // End: case eap_pac_store_data_type_PAC_data: |
|
7572 |
|
7573 case eap_pac_store_data_type_group_info:// Provide all from groups table. Create data for one entry in the groups table. |
|
7574 case eap_pac_store_data_type_A_ID_info: // Provide all from AIDs table. Create data for one entry in the AIDs table. |
|
7575 case eap_pac_store_data_type_PAC_info:// Provide all from PACs table. Create data for one entry in the PACs table. |
|
7576 { |
|
7577 /** Read the items from DB here.*/ |
|
7578 TBuf<64> dbTableName; |
|
7579 eap_pac_store_data_type_e dataType = eap_pac_store_data_type_none; |
|
7580 |
|
7581 switch(pacStoreDataRefType) |
|
7582 { |
|
7583 case eap_pac_store_data_type_group_info: |
|
7584 { |
|
7585 dbTableName = KPacStoreGroupsTableName; |
|
7586 dataType = eap_pac_store_data_type_group_data; |
|
7587 break; |
|
7588 } |
|
7589 case eap_pac_store_data_type_A_ID_info: |
|
7590 { |
|
7591 dbTableName = KPacStoreAIDsTableName; |
|
7592 dataType = eap_pac_store_data_type_A_ID_data; |
|
7593 break; |
|
7594 } |
|
7595 case eap_pac_store_data_type_PAC_info: |
|
7596 { |
|
7597 dbTableName = KPacStorePACsTableName; |
|
7598 dataType = eap_pac_store_data_type_PAC_data; |
|
7599 break; |
|
7600 } |
|
7601 } |
|
7602 |
|
7603 TInt count = 0; |
|
7604 |
|
7605 m_info_array.Reset(); |
|
7606 |
|
7607 iPacStoreDb->GetPacStoreDataL(dbTableName, m_info_array); |
|
7608 |
|
7609 EAP_TRACE_DEBUG_SYMBIAN( |
|
7610 (_L("eap_am_type_tls_peap_symbian_c::ReadPACStoredataL:Number of entries in table %S=%d\n"), |
|
7611 &dbTableName, m_info_array.Count())); |
|
7612 |
|
7613 while (count < m_info_array.Count()) |
|
7614 { |
|
7615 TPtr8 infoDataPtr = m_info_array[count].iData->Des(); |
|
7616 TPtr8 infoRefPtr = m_info_array[count].iReference->Des(); |
|
7617 |
|
7618 EAP_TRACE_DATA_DEBUG_SYMBIAN( |
|
7619 ("eap_am_type_tls_peap_symbian_c::ReadPACStoredataL: BINARY value from PAC DB (reference)", |
|
7620 infoRefPtr.Ptr(), |
|
7621 infoRefPtr.Size())); |
|
7622 |
|
7623 EAP_TRACE_DATA_DEBUG_SYMBIAN( |
|
7624 ("eap_am_type_tls_peap_symbian_c::ReadPACStoredataL: BINARY value from PAC DB (value)", |
|
7625 infoDataPtr.Ptr(), |
|
7626 infoDataPtr.Size())); |
|
7627 |
|
7628 eap_fast_pac_store_data_c * const new_data = new eap_fast_pac_store_data_c(m_am_tools); |
|
7629 |
|
7630 eap_automatic_variable_c<eap_fast_pac_store_data_c> automatic_new_data( |
|
7631 m_am_tools, new_data); |
|
7632 |
|
7633 if (new_data == 0) |
|
7634 { |
|
7635 m_eap_fast_completion_status = eap_status_allocation_error; |
|
7636 (void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status); |
|
7637 break; |
|
7638 } |
|
7639 |
|
7640 new_data->set_type(dataType); |
|
7641 |
|
7642 // Set the reference. |
|
7643 m_eap_fast_completion_status = new_data->get_writable_reference()->set_copy_of_buffer(infoRefPtr.Ptr(), infoRefPtr.Size()); |
|
7644 if (m_eap_fast_completion_status != eap_status_ok) |
|
7645 { |
|
7646 (void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status); |
|
7647 delete m_info_array[count].iData; |
|
7648 delete m_info_array[count].iReference; |
|
7649 break; |
|
7650 } |
|
7651 |
|
7652 m_eap_fast_completion_status = new_data->get_writable_data()->set_copy_of_buffer(infoDataPtr.Ptr(),infoDataPtr.Size() ); |
|
7653 if (m_eap_fast_completion_status != eap_status_ok) |
|
7654 { |
|
7655 (void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status); |
|
7656 delete m_info_array[count].iData; |
|
7657 delete m_info_array[count].iReference; |
|
7658 break; |
|
7659 } |
|
7660 |
|
7661 automatic_new_data.do_not_free_variable(); |
|
7662 |
|
7663 m_eap_fast_completion_status = m_references_and_data_blocks.add_object(new_data, true); |
|
7664 if (m_eap_fast_completion_status != eap_status_ok) |
|
7665 { |
|
7666 (void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status); |
|
7667 delete m_info_array[count].iData; |
|
7668 delete m_info_array[count].iReference; |
|
7669 break; |
|
7670 } |
|
7671 |
|
7672 delete m_info_array[count].iData; |
|
7673 delete m_info_array[count].iReference; |
|
7674 |
|
7675 EAP_TRACE_DATA_DEBUG_SYMBIAN( |
|
7676 ("For GROUP, AID, PAC INFOs - added data", |
|
7677 (new_data->get_data())->get_data((new_data->get_data())->get_data_length()), |
|
7678 (new_data->get_data())->get_data_length())); |
|
7679 |
|
7680 count++; |
|
7681 } // End: while |
|
7682 |
|
7683 |
|
7684 if (m_eap_fast_completion_status != eap_status_ok) |
|
7685 { |
|
7686 (void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status); |
|
7687 break; |
|
7688 } |
|
7689 |
|
7690 break; |
|
7691 } // End: case eap_pac_store_data_type_group_info: |
|
7692 |
|
7693 case eap_pac_store_data_type_PAC_store_password: |
|
7694 { |
|
7695 // To read PAC store PW. |
|
7696 |
|
7697 #ifdef USE_PAC_STORE |
|
7698 // Get PAC store password |
|
7699 |
|
7700 // First check if there is some PW in PAC store DB. |
|
7701 GetPacStoreDbDataL( |
|
7702 pacStoreDataRefType, |
|
7703 &m_PAC_store_password); |
|
7704 |
|
7705 #endif // End: #ifdef USE_PAC_STORE |
|
7706 |
|
7707 if(m_PAC_store_password.get_data_length() == 0) |
|
7708 { |
|
7709 // Nothing in the PAC store DB. |
|
7710 |
|
7711 EAP_TRACE_DEBUG_SYMBIAN( |
|
7712 (_L("eap_am_type_tls_peap_symbian_c::ReadPACStoredataL: NO PW in PAC store. Try Notifier"))); |
|
7713 |
|
7714 |
|
7715 // Show the password query notifier to get the password. |
|
7716 |
|
7717 m_ready_references_array_index = ind; |
|
7718 |
|
7719 m_verificationStatus = EFalse; |
|
7720 |
|
7721 m_state = EPasswordQuery; |
|
7722 |
|
7723 m_pacStoreDataRefType = pacStoreDataRefType; |
|
7724 |
|
7725 m_data_reference.get_writable_reference()->set_copy_of_buffer(data_reference->get_reference()); |
|
7726 |
|
7727 m_both_asked++; |
|
7728 |
|
7729 if(iPacStoreDb->IsMasterKeyPresentL()) |
|
7730 { |
|
7731 m_eap_fast_completion_status = ShowNotifierItemAndGetResponse( |
|
7732 EEapFastNotifierPacStorePwQuery, ETrue ); |
|
7733 } |
|
7734 else |
|
7735 { |
|
7736 m_state = EMasterkeyQuery; |
|
7737 m_eap_fast_completion_status = ShowNotifierItemAndGetResponse( |
|
7738 EEapFastNotifierCreateMasterkeyQuery, ETrue ); |
|
7739 } |
|
7740 |
|
7741 break; |
|
7742 } |
|
7743 |
|
7744 eap_fast_pac_store_data_c * const new_data = new eap_fast_pac_store_data_c(m_am_tools); |
|
7745 |
|
7746 eap_automatic_variable_c<eap_fast_pac_store_data_c> automatic_new_data( |
|
7747 m_am_tools, new_data); |
|
7748 |
|
7749 if (new_data == 0) |
|
7750 { |
|
7751 m_eap_fast_completion_status = eap_status_allocation_error; |
|
7752 (void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status); |
|
7753 break; |
|
7754 } |
|
7755 |
|
7756 new_data->set_type(pacStoreDataRefType); |
|
7757 |
|
7758 // Set the reference. |
|
7759 m_eap_fast_completion_status = new_data->get_writable_reference()->set_copy_of_buffer(data_reference->get_reference()); |
|
7760 if (m_eap_fast_completion_status != eap_status_ok) |
|
7761 { |
|
7762 (void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status); |
|
7763 break; |
|
7764 } |
|
7765 |
|
7766 m_eap_fast_completion_status = new_data->get_writable_data()->set_copy_of_buffer(&m_PAC_store_password); |
|
7767 |
|
7768 if (m_eap_fast_completion_status != eap_status_ok) |
|
7769 { |
|
7770 (void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status); |
|
7771 break; |
|
7772 } |
|
7773 |
|
7774 automatic_new_data.do_not_free_variable(); |
|
7775 |
|
7776 m_eap_fast_completion_status = m_references_and_data_blocks.add_object(new_data, true); |
|
7777 if (m_eap_fast_completion_status != eap_status_ok) |
|
7778 { |
|
7779 (void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status); |
|
7780 break; |
|
7781 } |
|
7782 |
|
7783 EAP_TRACE_DATA_DEBUG_SYMBIAN( |
|
7784 ("eap_pac_store_data_type_PAC_store_password - added data", |
|
7785 (new_data->get_data())->get_data((new_data->get_data())->get_data_length()), |
|
7786 (new_data->get_data())->get_data_length())); |
|
7787 |
|
7788 m_eap_fast_completion_status = eap_status_pending_request; |
|
7789 |
|
7790 break; |
|
7791 |
|
7792 } // End: case eap_pac_store_data_type_PAC_store_password: |
|
7793 |
|
7794 case eap_pac_store_data_type_PAC_store_device_seed: |
|
7795 { |
|
7796 // To get the device seed. |
|
7797 |
|
7798 // Create a device seed. |
|
7799 |
|
7800 eap_variable_data_c m_PAC_store_device_seed(m_am_tools); |
|
7801 m_eap_fast_completion_status = m_PAC_store_device_seed.set_copy_of_buffer( |
|
7802 iPacStoreDb->GetSeed() ); |
|
7803 if ( m_eap_fast_completion_status != eap_status_ok ) |
|
7804 { |
|
7805 EAP_TRACE_DEBUG_SYMBIAN( |
|
7806 (_L("eap_am_type_tls_peap_symbian_c::ReadPACStoredataL: ERROR: seed data is not valid."))); |
|
7807 (void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status); |
|
7808 break; |
|
7809 } |
|
7810 |
|
7811 // continue normally |
|
7812 EAP_TRACE_DATA_DEBUG_SYMBIAN( |
|
7813 ("Device Seed", |
|
7814 m_PAC_store_device_seed.get_data(m_PAC_store_device_seed.get_data_length()), |
|
7815 m_PAC_store_device_seed.get_data_length())); |
|
7816 |
|
7817 eap_fast_pac_store_data_c * const new_data = new eap_fast_pac_store_data_c(m_am_tools); |
|
7818 |
|
7819 eap_automatic_variable_c<eap_fast_pac_store_data_c> automatic_new_data( |
|
7820 m_am_tools, new_data); |
|
7821 |
|
7822 if (new_data == 0) |
|
7823 { |
|
7824 m_eap_fast_completion_status = eap_status_allocation_error; |
|
7825 (void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status); |
|
7826 break; |
|
7827 } |
|
7828 |
|
7829 new_data->set_type(pacStoreDataRefType); |
|
7830 |
|
7831 // Set the reference. |
|
7832 m_eap_fast_completion_status = new_data->get_writable_reference()->set_copy_of_buffer(data_reference->get_reference()); |
|
7833 if (m_eap_fast_completion_status != eap_status_ok) |
|
7834 { |
|
7835 (void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status); |
|
7836 break; |
|
7837 } |
|
7838 |
|
7839 m_eap_fast_completion_status = new_data->get_writable_data()->set_copy_of_buffer(&m_PAC_store_device_seed); |
|
7840 |
|
7841 if (m_eap_fast_completion_status != eap_status_ok) |
|
7842 { |
|
7843 (void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status); |
|
7844 break; |
|
7845 } |
|
7846 |
|
7847 automatic_new_data.do_not_free_variable(); |
|
7848 |
|
7849 m_eap_fast_completion_status = m_references_and_data_blocks.add_object(new_data, true); |
|
7850 if (m_eap_fast_completion_status != eap_status_ok) |
|
7851 { |
|
7852 (void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status); |
|
7853 break; |
|
7854 } |
|
7855 |
|
7856 EAP_TRACE_DATA_DEBUG_SYMBIAN( |
|
7857 ("eap_pac_store_data_type_PAC_store_device_seed - added data", |
|
7858 (new_data->get_data())->get_data((new_data->get_data())->get_data_length()), |
|
7859 (new_data->get_data())->get_data_length())); |
|
7860 |
|
7861 break; |
|
7862 } // End: case eap_pac_store_data_type_PAC_store_device_seed: |
|
7863 |
|
7864 case eap_pac_store_data_type_PAC_store_IAP_reference: |
|
7865 { |
|
7866 // To get the IAP reference. |
|
7867 |
|
7868 eap_fast_pac_store_data_c * const new_data = new eap_fast_pac_store_data_c(m_am_tools); |
|
7869 |
|
7870 eap_automatic_variable_c<eap_fast_pac_store_data_c> automatic_new_data( |
|
7871 m_am_tools, new_data); |
|
7872 |
|
7873 if (new_data == 0) |
|
7874 { |
|
7875 m_eap_fast_completion_status = eap_status_allocation_error; |
|
7876 (void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status); |
|
7877 break; |
|
7878 } |
|
7879 |
|
7880 new_data->set_type(pacStoreDataRefType); |
|
7881 |
|
7882 // Set the reference. |
|
7883 m_eap_fast_completion_status = new_data->get_writable_reference()->set_copy_of_buffer(data_reference->get_reference()); |
|
7884 if (m_eap_fast_completion_status != eap_status_ok) |
|
7885 { |
|
7886 (void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status); |
|
7887 break; |
|
7888 } |
|
7889 |
|
7890 // Provide Service table id (m_index) and type (m_index_type) |
|
7891 // in the specified format. |
|
7892 |
|
7893 i32_t tmpIndex = static_cast<i32_t>(m_index); |
|
7894 i32_t tmpIndexType = static_cast<i32_t>(m_index_type); |
|
7895 |
|
7896 eap_variable_data_c tmp_EAP_FAST_IAP_reference(m_am_tools); |
|
7897 |
|
7898 // Copy the index and index type. The order of copying is important. |
|
7899 |
|
7900 m_eap_fast_completion_status = tmp_EAP_FAST_IAP_reference.set_copy_of_buffer(&tmpIndex,sizeof(i32_t)); |
|
7901 if (m_eap_fast_completion_status != eap_status_ok) |
|
7902 { |
|
7903 (void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status); |
|
7904 break; |
|
7905 } |
|
7906 |
|
7907 m_eap_fast_completion_status = tmp_EAP_FAST_IAP_reference.add_data(&tmpIndexType,sizeof(i32_t)); |
|
7908 if (m_eap_fast_completion_status != eap_status_ok) |
|
7909 { |
|
7910 (void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status); |
|
7911 break; |
|
7912 } |
|
7913 |
|
7914 if (tmp_EAP_FAST_IAP_reference.get_is_valid_data() == true) |
|
7915 { |
|
7916 m_eap_fast_completion_status = new_data->get_writable_data()->set_copy_of_buffer(&tmp_EAP_FAST_IAP_reference); |
|
7917 |
|
7918 if (m_eap_fast_completion_status != eap_status_ok) |
|
7919 { |
|
7920 (void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status); |
|
7921 break; |
|
7922 } |
|
7923 } |
|
7924 |
|
7925 automatic_new_data.do_not_free_variable(); |
|
7926 |
|
7927 m_eap_fast_completion_status = m_references_and_data_blocks.add_object(new_data, true); |
|
7928 if (m_eap_fast_completion_status != eap_status_ok) |
|
7929 { |
|
7930 (void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status); |
|
7931 break; |
|
7932 } |
|
7933 |
|
7934 EAP_TRACE_DATA_DEBUG_SYMBIAN( |
|
7935 ("eap_pac_store_data_type_PAC_store_IAP_reference - added data", |
|
7936 (new_data->get_data())->get_data((new_data->get_data())->get_data_length()), |
|
7937 (new_data->get_data())->get_data_length())); |
|
7938 |
|
7939 break; |
|
7940 |
|
7941 } // End : case eap_pac_store_data_type_PAC_store_IAP_reference: |
|
7942 |
|
7943 case eap_pac_store_data_type_PAC_store_group_reference: |
|
7944 { |
|
7945 // To get the PAC store group reference |
|
7946 // It is EAP_FAST_PAC_Group_DB_Reference_Collection in PAC store DB. |
|
7947 |
|
7948 eap_variable_data_c groupDbReferenceData(m_am_tools); |
|
7949 |
|
7950 EapTlsPeapUtils::GetEapSettingsDataL( |
|
7951 m_database, |
|
7952 m_index_type, |
|
7953 m_index, |
|
7954 m_tunneling_type, |
|
7955 m_current_eap_type, |
|
7956 KFASTPACGroupDBReferenceCollection, |
|
7957 &groupDbReferenceData); |
|
7958 |
|
7959 // groupDbReferenceData should have the value stored in PAC store DB. |
|
7960 // Doesn't matter even if it is empty. Proceed as normal case. |
|
7961 |
|
7962 EAP_TRACE_DATA_DEBUG_SYMBIAN( |
|
7963 ("PAC group ref from PAC store DB", |
|
7964 groupDbReferenceData.get_data(groupDbReferenceData.get_data_length()), |
|
7965 groupDbReferenceData.get_data_length())); |
|
7966 |
|
7967 eap_fast_pac_store_data_c * const new_data = new eap_fast_pac_store_data_c(m_am_tools); |
|
7968 |
|
7969 eap_automatic_variable_c<eap_fast_pac_store_data_c> automatic_new_data( |
|
7970 m_am_tools, new_data); |
|
7971 |
|
7972 if (new_data == 0) |
|
7973 { |
|
7974 m_eap_fast_completion_status = eap_status_allocation_error; |
|
7975 (void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status); |
|
7976 break; |
|
7977 } |
|
7978 |
|
7979 new_data->set_type(pacStoreDataRefType); |
|
7980 |
|
7981 // Set the reference. |
|
7982 m_eap_fast_completion_status = new_data->get_writable_reference()->set_copy_of_buffer(&groupDbReferenceData); |
|
7983 if (m_eap_fast_completion_status != eap_status_ok) |
|
7984 { |
|
7985 (void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status); |
|
7986 break; |
|
7987 } |
|
7988 |
|
7989 eap_variable_data_c group_data_2(m_am_tools); |
|
7990 |
|
7991 #ifdef USE_PAC_STORE |
|
7992 // Get group data from PAC store DB, using the reference. |
|
7993 GetPacStoreDbDataL( |
|
7994 eap_pac_store_data_type_group_data, |
|
7995 &group_data_2, |
|
7996 &groupDbReferenceData); |
|
7997 |
|
7998 #endif // End: #ifdef USE_PAC_STORE |
|
7999 |
|
8000 if ( group_data_2.get_data_length() == 0 ) |
|
8001 { |
|
8002 (void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status); |
|
8003 break; |
|
8004 } |
|
8005 |
|
8006 m_eap_fast_completion_status = new_data->get_writable_data()->set_copy_of_buffer(&group_data_2); |
|
8007 |
|
8008 if (m_eap_fast_completion_status != eap_status_ok) |
|
8009 { |
|
8010 (void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status); |
|
8011 break; |
|
8012 } |
|
8013 |
|
8014 automatic_new_data.do_not_free_variable(); |
|
8015 |
|
8016 m_eap_fast_completion_status = m_references_and_data_blocks.add_object(new_data, true); |
|
8017 if (m_eap_fast_completion_status != eap_status_ok) |
|
8018 { |
|
8019 (void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status); |
|
8020 break; |
|
8021 } |
|
8022 |
|
8023 EAP_TRACE_DATA_DEBUG_SYMBIAN( |
|
8024 ("eap_pac_store_data_type_PAC_store_group_reference - added data", |
|
8025 (new_data->get_data())->get_data((new_data->get_data())->get_data_length()), |
|
8026 (new_data->get_data())->get_data_length())); |
|
8027 |
|
8028 break; |
|
8029 |
|
8030 } // End: case eap_pac_store_data_type_PAC_store_group_reference: |
|
8031 |
|
8032 case eap_pac_store_data_type_PAC_file_password: |
|
8033 { |
|
8034 // To get the password for decrypting the PAC file. |
|
8035 |
|
8036 // Show the notifier to get the PAC file password. |
|
8037 |
|
8038 m_ready_references_array_index = ind; |
|
8039 |
|
8040 m_pacStoreDataRefType = pacStoreDataRefType; |
|
8041 |
|
8042 m_data_reference.get_writable_reference()->set_copy_of_buffer(data_reference->get_reference()); |
|
8043 |
|
8044 m_state = EFilePasswordQuery; |
|
8045 |
|
8046 m_both_asked++; |
|
8047 |
|
8048 m_eap_fast_completion_status = ShowNotifierItemAndGetResponse( |
|
8049 EEapFastNotifierPacFilePwQuery, ETrue ); |
|
8050 |
|
8051 if (m_eap_fast_completion_status != eap_status_ok) |
|
8052 { |
|
8053 (void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status); |
|
8054 break; |
|
8055 } |
|
8056 |
|
8057 break; |
|
8058 |
|
8059 } // End : case eap_pac_store_data_type_PAC_file_password: |
|
8060 |
|
8061 default: |
|
8062 { |
|
8063 // Unknown data query. |
|
8064 |
|
8065 EAP_TRACE_DEBUG_SYMBIAN( |
|
8066 (_L("eap_am_type_tls_peap_symbian_c::ReadPACStoredataL: ERROR: Unknown data type"))); |
|
8067 |
|
8068 m_eap_fast_completion_status = eap_status_not_found; |
|
8069 (void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status); |
|
8070 break; |
|
8071 } |
|
8072 |
|
8073 } // End: switch(pacStoreDataRefType) |
|
8074 } |
|
8075 } // for () |
|
8076 if (m_both_asked) |
|
8077 m_eap_fast_completion_status = eap_status_pending_request; |
|
8078 m_info_array.Reset(); |
|
8079 EAP_TRACE_DEBUG_SYMBIAN( |
|
8080 (_L("eap_am_type_tls_peap_symbian_c::ReadPACStoredataL-End, m_eap_fast_completion_status=%d"), |
|
8081 m_eap_fast_completion_status)); |
|
8082 |
|
8083 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
8084 return; |
|
8085 } |
|
8086 |
|
8087 |
|
8088 //-------------------------------------------------- |
|
8089 |
|
8090 // This is commented in eap_am_fast_pac_store_services_c::write_PAC_store_data(). |
|
8091 EAP_FUNC_EXPORT eap_status_e eap_am_type_tls_peap_symbian_c::write_PAC_store_data( |
|
8092 const bool /* when_true_must_be_synchronous_operation */, |
|
8093 const eap_fast_pac_store_pending_operation_e in_pending_operation, |
|
8094 EAP_TEMPLATE_CONST eap_array_c<eap_fast_pac_store_data_c> * const in_references_and_data_blocks) |
|
8095 { |
|
8096 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
8097 |
|
8098 EAP_TRACE_DEBUG( |
|
8099 m_am_tools, |
|
8100 TRACE_FLAGS_DEFAULT, |
|
8101 (EAPL("EAP-FAST: %s: eap_am_type_tls_peap_symbian_c::write_PAC_store_data(): ") |
|
8102 EAPL("this = 0x%08x\n"), |
|
8103 (m_is_client == true ? "client": "server"), |
|
8104 this)); |
|
8105 |
|
8106 m_eap_fast_pac_store_pending_operation = in_pending_operation; |
|
8107 TRAPD(error, WritePACStoreDataL(in_pending_operation, in_references_and_data_blocks)); |
|
8108 |
|
8109 if(error != KErrNone) |
|
8110 { |
|
8111 EAP_TRACE_DEBUG( |
|
8112 m_am_tools, |
|
8113 TRACE_FLAGS_DEFAULT, |
|
8114 (EAPL("EAP-FAST: eap_am_type_tls_peap_symbian_c::write_PAC_store_data() ERROR: LEAVE from WritePACStoreDataL error=%d"), |
|
8115 error)); |
|
8116 |
|
8117 m_eap_fast_completion_status = m_am_tools->convert_am_error_to_eapol_error(error); |
|
8118 } |
|
8119 |
|
8120 // - - - - - - - - - - - - - - - - - - - - - - - - |
|
8121 |
|
8122 // Proceed with normal complete case. |
|
8123 |
|
8124 eap_status_e status(eap_status_ok); |
|
8125 |
|
8126 EAP_TRACE_DEBUG( |
|
8127 m_am_tools, |
|
8128 TRACE_FLAGS_DEFAULT, |
|
8129 (EAPL("FAST: %s: direct_complete_function: WritePACStoreDataL(), m_eap_fast_completion_status=%d\n"), |
|
8130 (m_is_client == true ? "client": "server"), m_eap_fast_completion_status)); |
|
8131 |
|
8132 if (m_eap_fast_completion_status == eap_status_ok) |
|
8133 { |
|
8134 status = m_tls_application->complete_write_PAC_store_data( |
|
8135 m_eap_fast_completion_status, |
|
8136 m_eap_fast_pac_store_pending_operation); |
|
8137 } |
|
8138 else |
|
8139 { |
|
8140 status = m_tls_application->complete_write_PAC_store_data( |
|
8141 m_eap_fast_completion_status, |
|
8142 m_eap_fast_pac_store_pending_operation); |
|
8143 |
|
8144 // ERROR. |
|
8145 (void) EAP_STATUS_RETURN(m_am_tools, status); |
|
8146 } |
|
8147 |
|
8148 // - - - - - - - - - - - - - - - - - - - - - - - - |
|
8149 |
|
8150 EAP_TRACE_DEBUG_SYMBIAN( |
|
8151 (_L("eap_am_type_tls_peap_symbian_c::write_PAC_store_data-End, status=%d, m_eap_fast_completion_status=%d"), |
|
8152 status, m_eap_fast_completion_status)); |
|
8153 |
|
8154 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
8155 return EAP_STATUS_RETURN(m_am_tools, status); |
|
8156 } |
|
8157 |
|
8158 |
|
8159 //-------------------------------------------------- |
|
8160 |
|
8161 void eap_am_type_tls_peap_symbian_c::WritePACStoreDataL( |
|
8162 const eap_fast_pac_store_pending_operation_e in_pending_operation, |
|
8163 EAP_TEMPLATE_CONST eap_array_c<eap_fast_pac_store_data_c> * const in_references_and_data_blocks) |
|
8164 { |
|
8165 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
8166 |
|
8167 EAP_TRACE_DEBUG( |
|
8168 m_am_tools, |
|
8169 TRACE_FLAGS_DEFAULT, |
|
8170 (EAPL("EAP-FAST: eap_am_type_tls_peap_symbian_c::WritePACStoreDataL()\n"))); |
|
8171 |
|
8172 EAP_TRACE_RETURN_STRING(m_am_tools, "returns: eap_am_type_tls_peap_symbian_c::WritePACStoreDataL()"); |
|
8173 |
|
8174 // - - - - - - - - - - - - - - - - - - - - - - - - |
|
8175 |
|
8176 m_eap_fast_completion_status = eap_status_ok; |
|
8177 |
|
8178 m_eap_fast_pac_store_pending_operation = in_pending_operation; |
|
8179 |
|
8180 TBuf<KMaxDBFieldNameLength> pacStoreDBColName; |
|
8181 TBool writeToPacStore = EFalse; |
|
8182 |
|
8183 // - - - - - - - - - - - - - - - - - - - - - - - - |
|
8184 |
|
8185 for (u32_t ind = 0ul; ind < in_references_and_data_blocks->get_object_count(); ++ind) |
|
8186 { |
|
8187 const eap_fast_pac_store_data_c * const data_reference = in_references_and_data_blocks->get_object(ind); |
|
8188 if (data_reference != 0) |
|
8189 { |
|
8190 const eap_pac_store_data_type_e aPacStoreDataType = data_reference->get_type(); |
|
8191 |
|
8192 EAP_TRACE_DEBUG( |
|
8193 m_am_tools, |
|
8194 TRACE_FLAGS_DEFAULT, |
|
8195 (EAPL("EAP-FAST: eap_am_type_tls_peap_symbian_c::WritePACStoreDataL(): type %d=%s\n"), |
|
8196 data_reference->get_type(), |
|
8197 eap_fast_tlv_header_string_c::get_fast_pac_store_data_string(data_reference->get_type()))); |
|
8198 |
|
8199 EAP_TRACE_DATA_DEBUG_SYMBIAN( |
|
8200 ("WritePACStoreDataL(): data_reference data(value):", |
|
8201 data_reference->get_data()->get_data(data_reference->get_data()->get_data_length()), |
|
8202 data_reference->get_data()->get_data_length())); |
|
8203 |
|
8204 EAP_TRACE_DATA_DEBUG_SYMBIAN( |
|
8205 ("WritePACStoreDataL(): data_reference reference:", |
|
8206 data_reference->get_reference()->get_data(data_reference->get_reference()->get_data_length()), |
|
8207 data_reference->get_reference()->get_data_length())); |
|
8208 |
|
8209 EAP_TRACE_DEBUG_SYMBIAN( |
|
8210 (_L("eap_am_type_tls_peap_symbian_c::WritePACStoreDataL: change status=%d (0=eap_pac_store_data_change_status_none)"), |
|
8211 data_reference->get_change_status())); |
|
8212 |
|
8213 if (data_reference != 0 |
|
8214 && data_reference->get_is_valid() == true |
|
8215 && data_reference->get_type() != eap_pac_store_data_type_none |
|
8216 && data_reference->get_change_status() != eap_pac_store_data_change_status_none) |
|
8217 { |
|
8218 eap_fast_pac_store_data_c * const new_data = new eap_fast_pac_store_data_c(m_am_tools); |
|
8219 |
|
8220 eap_automatic_variable_c<eap_fast_pac_store_data_c> automatic_new_data( |
|
8221 m_am_tools, new_data); |
|
8222 |
|
8223 if (new_data == 0) |
|
8224 { |
|
8225 m_eap_fast_completion_status = eap_status_allocation_error; |
|
8226 break; |
|
8227 } |
|
8228 |
|
8229 |
|
8230 /* Get the data (or value) from the input */ |
|
8231 HBufC8* pacStoreDBColVal8 = HBufC8::NewLC(data_reference->get_data()->get_data_length()); |
|
8232 TPtr8 pacStoreDBColValPtr8 = pacStoreDBColVal8->Des(); |
|
8233 pacStoreDBColValPtr8.Copy(data_reference->get_data()->get_data(), |
|
8234 data_reference->get_data()->get_data_length()); |
|
8235 |
|
8236 EAP_TRACE_DATA_DEBUG_SYMBIAN( |
|
8237 ("write_PAC_store_dataL(): 8 bit VALUE from common:", |
|
8238 pacStoreDBColValPtr8.Ptr(), |
|
8239 pacStoreDBColValPtr8.Size())); |
|
8240 |
|
8241 /* Get the reference from the input */ |
|
8242 HBufC8* pacStoreDBColRef8 = HBufC8::NewLC(data_reference->get_reference()->get_data_length()); |
|
8243 TPtr8 pacStoreDBColRefPtr8 = pacStoreDBColRef8->Des(); |
|
8244 pacStoreDBColRefPtr8.Copy(data_reference->get_reference()->get_data(), |
|
8245 data_reference->get_reference()->get_data_length()); |
|
8246 |
|
8247 EAP_TRACE_DATA_DEBUG_SYMBIAN( |
|
8248 ("write_PAC_store_dataL(): 8 bit REFERENCE from common:", |
|
8249 pacStoreDBColRefPtr8.Ptr(), |
|
8250 pacStoreDBColRefPtr8.Size())); |
|
8251 |
|
8252 writeToPacStore = EFalse; |
|
8253 |
|
8254 TBool isNewEntry(EFalse); |
|
8255 if(data_reference->get_change_status() == eap_pac_store_data_change_status_new) |
|
8256 { |
|
8257 isNewEntry =ETrue; |
|
8258 } |
|
8259 else |
|
8260 { |
|
8261 isNewEntry =EFalse; |
|
8262 } |
|
8263 |
|
8264 switch(aPacStoreDataType) |
|
8265 { |
|
8266 case eap_pac_store_data_type_PAC_store_master_key: |
|
8267 { |
|
8268 pacStoreDBColName.Copy(KPacStoreMasterKey); |
|
8269 writeToPacStore = ETrue; |
|
8270 |
|
8271 // This can not be a new entry. Only modification possible for this. |
|
8272 // Some times common side provides this as new entry. |
|
8273 isNewEntry = EFalse; |
|
8274 |
|
8275 break; |
|
8276 } |
|
8277 case eap_pac_store_data_type_PAC_store_password: |
|
8278 { |
|
8279 //This is not saved anywhere. |
|
8280 break; |
|
8281 } |
|
8282 case eap_pac_store_data_type_PAC_store_device_seed: |
|
8283 { |
|
8284 //This is not saved anywhere. |
|
8285 break; |
|
8286 } |
|
8287 case eap_pac_store_data_type_PAC_store_IAP_reference: |
|
8288 { |
|
8289 //This is not saved anywhere. |
|
8290 break; |
|
8291 } |
|
8292 case eap_pac_store_data_type_PAC_store_group_reference: |
|
8293 { |
|
8294 // This should be saved in FAST special settings table in EAP DB, not in PAC store. |
|
8295 |
|
8296 EapTlsPeapUtils::SetEapSettingsDataL( |
|
8297 m_database, |
|
8298 m_index_type, |
|
8299 m_index, |
|
8300 m_tunneling_type, |
|
8301 m_current_eap_type, |
|
8302 KFASTPACGroupDBReferenceCollection, |
|
8303 data_reference->get_data()); |
|
8304 |
|
8305 writeToPacStore = EFalse; |
|
8306 |
|
8307 break; |
|
8308 } |
|
8309 case eap_pac_store_data_type_reference_counter: |
|
8310 { |
|
8311 pacStoreDBColName.Copy(KPacStoreReferenceCounter); |
|
8312 writeToPacStore = ETrue; |
|
8313 |
|
8314 // This can not be a new entry. Only modification possible for this. |
|
8315 // Some times common side provides this as new entry. |
|
8316 isNewEntry = EFalse; |
|
8317 |
|
8318 break; |
|
8319 } |
|
8320 case eap_pac_store_data_type_PAC_file_password: |
|
8321 { |
|
8322 //This is not saved anywhere. |
|
8323 break; |
|
8324 } |
|
8325 case eap_pac_store_data_type_group_info: |
|
8326 case eap_pac_store_data_type_A_ID_info: |
|
8327 case eap_pac_store_data_type_PAC_info: |
|
8328 { |
|
8329 //These are not saved, as such, anywhere. |
|
8330 break; |
|
8331 } |
|
8332 case eap_pac_store_data_type_group_data: |
|
8333 { |
|
8334 pacStoreDBColName.Copy(KPacStoreGroupValue); |
|
8335 writeToPacStore = ETrue; |
|
8336 break; |
|
8337 } |
|
8338 case eap_pac_store_data_type_A_ID_data: |
|
8339 { |
|
8340 pacStoreDBColName.Copy(KPacStoreAIDValue); |
|
8341 writeToPacStore = ETrue; |
|
8342 break; |
|
8343 } |
|
8344 case eap_pac_store_data_type_PAC_data: |
|
8345 { |
|
8346 pacStoreDBColName.Copy(KPacStorePACValue); |
|
8347 writeToPacStore = ETrue; |
|
8348 break; |
|
8349 } |
|
8350 default: |
|
8351 { |
|
8352 // Unknown data type. |
|
8353 |
|
8354 EAP_TRACE_DEBUG_SYMBIAN( |
|
8355 (_L("eap_am_type_tls_peap_symbian_c::WritePACStoreDataL: ERROR: Unknown data type"))); |
|
8356 |
|
8357 m_eap_fast_completion_status = eap_status_not_found; |
|
8358 (void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status); |
|
8359 break; |
|
8360 } |
|
8361 } // End : switch(aPacStoreDataType) |
|
8362 |
|
8363 if (writeToPacStore) |
|
8364 { |
|
8365 if(data_reference->get_change_status() == eap_pac_store_data_change_status_delete) |
|
8366 { |
|
8367 // We have to delete this entry from PAC store. |
|
8368 |
|
8369 iPacStoreDb->RemovePacStoreEntryL( |
|
8370 pacStoreDBColName, |
|
8371 pacStoreDBColValPtr8, |
|
8372 pacStoreDBColRefPtr8); |
|
8373 } |
|
8374 else |
|
8375 { |
|
8376 // Here the entry is either modified or a new entry. isNewEntry will have the correct value. |
|
8377 iPacStoreDb->SetPacStoreDataL( |
|
8378 pacStoreDBColName, |
|
8379 pacStoreDBColValPtr8, |
|
8380 pacStoreDBColRefPtr8, |
|
8381 isNewEntry); |
|
8382 } |
|
8383 |
|
8384 m_eap_fast_completion_status = eap_status_ok; |
|
8385 } |
|
8386 |
|
8387 if (m_eap_fast_completion_status != eap_status_ok) |
|
8388 { |
|
8389 break; |
|
8390 } |
|
8391 |
|
8392 CleanupStack::PopAndDestroy(2); // pacStoreDBColVal8 (pacStoreDBColValPtr8) and |
|
8393 // pacStoreDBColRef8 (pacStoreDBColRefPtr8). |
|
8394 |
|
8395 } |
|
8396 else if (data_reference != 0 |
|
8397 && data_reference->get_is_valid() == true |
|
8398 && data_reference->get_type() == eap_pac_store_data_type_none) |
|
8399 { |
|
8400 EAP_TRACE_DEBUG( |
|
8401 m_am_tools, |
|
8402 TRACE_FLAGS_DEFAULT, |
|
8403 (EAPL("ERROR: illegal reference 0x%08x: type %d\n"), |
|
8404 data_reference, |
|
8405 data_reference->get_type())); |
|
8406 |
|
8407 EAP_TRACE_DATA_DEBUG( |
|
8408 m_am_tools, |
|
8409 TRACE_FLAGS_DEFAULT, |
|
8410 (EAPL("ERROR: unknown reference"), |
|
8411 data_reference->get_reference()->get_data(), |
|
8412 data_reference->get_reference()->get_data_length())); |
|
8413 |
|
8414 EAP_TRACE_DATA_DEBUG( |
|
8415 m_am_tools, |
|
8416 TRACE_FLAGS_DEFAULT, |
|
8417 (EAPL("ERROR: unknown data"), |
|
8418 data_reference->get_data()->get_data(), |
|
8419 data_reference->get_data()->get_data_length())); |
|
8420 } |
|
8421 } |
|
8422 } // for () |
|
8423 |
|
8424 EAP_TRACE_DEBUG_SYMBIAN( |
|
8425 (_L("eap_am_type_tls_peap_symbian_c::WritePACStoreDataL-End, m_eap_fast_completion_status=%d"), |
|
8426 m_eap_fast_completion_status)); |
|
8427 |
|
8428 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
8429 } |
|
8430 |
|
8431 //-------------------------------------------------- |
|
8432 |
|
8433 // This is commented in eap_am_fast_pac_store_services_c::complete_add_imported_PAC_file(). |
|
8434 EAP_FUNC_EXPORT eap_status_e eap_am_type_tls_peap_symbian_c::complete_add_imported_PAC_file( |
|
8435 const eap_status_e /* in_completion_status */, |
|
8436 const eap_variable_data_c * const in_imported_PAC_filename, |
|
8437 const eap_variable_data_c * const out_used_group_reference) |
|
8438 { |
|
8439 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
8440 |
|
8441 EAP_TRACE_DEBUG( |
|
8442 m_am_tools, |
|
8443 TRACE_FLAGS_DEFAULT, |
|
8444 (EAPL("EAP-FAST: %s: eap_am_type_tls_peap_symbian_c::complete_add_imported_PAC_file(): ") |
|
8445 EAPL("this = 0x%08x\n"), |
|
8446 (m_is_client == true ? "client": "server"), |
|
8447 this)); |
|
8448 |
|
8449 m_eap_fast_completion_status = eap_status_ok; |
|
8450 |
|
8451 TRAPD(err, CompleteAddImportedPACFileL(in_imported_PAC_filename, out_used_group_reference)); |
|
8452 if (err != KErrNone) |
|
8453 { |
|
8454 EAP_TRACE_DEBUG( |
|
8455 m_am_tools, |
|
8456 TRACE_FLAGS_DEFAULT, |
|
8457 (EAPL("EAP-FAST: eap_am_type_tls_peap_symbian_c::read_PAC_store_data() ERROR: LEAVE from CompleteAddImportedPACFfileL error=%d"), |
|
8458 err)); |
|
8459 |
|
8460 m_eap_fast_completion_status = m_am_tools->convert_am_error_to_eapol_error(err); |
|
8461 } |
|
8462 |
|
8463 m_eap_fast_completion_status = m_partner->set_timer( |
|
8464 this, |
|
8465 KImportFileTimerID, // if nothing in db & remove_IAP_reference called already with 0 -> import |
|
8466 0, |
|
8467 1); |
|
8468 |
|
8469 if (m_eap_fast_completion_status != eap_status_ok) |
|
8470 { |
|
8471 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
8472 return EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status); |
|
8473 } |
|
8474 |
|
8475 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
8476 return EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status); |
|
8477 } |
|
8478 |
|
8479 void eap_am_type_tls_peap_symbian_c::CompleteAddImportedPACFileL( |
|
8480 const eap_variable_data_c * const in_imported_PAC_filename, |
|
8481 const eap_variable_data_c * const out_used_group_reference) |
|
8482 { |
|
8483 RFs aFs; |
|
8484 aFs.Connect( KFileServerDefaultMessageSlots ); |
|
8485 |
|
8486 HBufC8* buf = HBufC8::NewLC(in_imported_PAC_filename->get_data_length()); |
|
8487 TPtr8 bufPtr = buf->Des(); |
|
8488 |
|
8489 if (in_imported_PAC_filename->get_data_length() != 0) |
|
8490 { |
|
8491 bufPtr.Copy(in_imported_PAC_filename->get_data(), in_imported_PAC_filename->get_data_length()); |
|
8492 } |
|
8493 |
|
8494 eap_variable_data_c someVariableData(m_am_tools); |
|
8495 |
|
8496 EAP_TRACE_DEBUG_SYMBIAN( |
|
8497 (_L("eap_am_type_tls_peap_symbian_c::complete_add_imported_PAC_file: Get ImportReference from database"))); |
|
8498 |
|
8499 EapTlsPeapUtils::GetEapSettingsDataL( |
|
8500 m_database, |
|
8501 m_index_type, |
|
8502 m_index, |
|
8503 m_tunneling_type, |
|
8504 m_current_eap_type, |
|
8505 KFASTPACGroupImportReferenceCollection, |
|
8506 &someVariableData); |
|
8507 |
|
8508 HBufC8* ref = HBufC8::NewLC(someVariableData.get_data_length()); // must be defined to correct maxs dir length |
|
8509 TPtr8 refPtr = ref->Des(); |
|
8510 if (someVariableData.get_data_length() != 0) |
|
8511 { |
|
8512 refPtr.Copy(someVariableData.get_data(),someVariableData.get_data_length()); |
|
8513 |
|
8514 HBufC8* tempUserBuf8 = HBufC8::NewLC(someVariableData.get_data_length()); |
|
8515 TPtr8 tempUserBufPtr8 = tempUserBuf8->Des(); |
|
8516 |
|
8517 for (int i = 0; i< someVariableData.get_data_length();i++ ) |
|
8518 { |
|
8519 tempUserBufPtr8.Append(refPtr.Ptr()[i++]); |
|
8520 } |
|
8521 refPtr.Copy(tempUserBufPtr8); |
|
8522 CleanupStack::PopAndDestroy(tempUserBuf8); |
|
8523 |
|
8524 } |
|
8525 else |
|
8526 { |
|
8527 EAP_TRACE_DEBUG_SYMBIAN( |
|
8528 (_L("eap_am_type_tls_peap_symbian_c::complete_add_imported_PAC_file: NO ImportReference !!!!"))); |
|
8529 } |
|
8530 |
|
8531 EAP_TRACE_DEBUG_SYMBIAN( |
|
8532 (_L("eap_am_type_tls_peap_symbian_c::complete_add_imported_PAC_file: Set GroupDBReference to database"))); |
|
8533 |
|
8534 if (out_used_group_reference->get_data_length()>0 && someVariableData.get_data_length()>0) |
|
8535 { |
|
8536 someVariableData.set_copy_of_buffer(out_used_group_reference->get_data(), |
|
8537 out_used_group_reference->get_data_length()); |
|
8538 |
|
8539 EapTlsPeapUtils::SetEapSettingsDataL( |
|
8540 m_database, |
|
8541 m_index_type, |
|
8542 m_index, |
|
8543 m_tunneling_type, |
|
8544 m_current_eap_type, |
|
8545 KFASTPACGroupDBReferenceCollection, |
|
8546 &someVariableData); |
|
8547 |
|
8548 } |
|
8549 else |
|
8550 { |
|
8551 EAP_TRACE_DEBUG_SYMBIAN( |
|
8552 (_L("eap_am_type_tls_peap_symbian_c::complete_add_imported_PAC_file: NO GROUP REFERENCE !!!!"))); |
|
8553 |
|
8554 } |
|
8555 |
|
8556 HBufC* FilePath = HBufC::NewLC(KMaxFileName); // must be defined to correct maxs dir length |
|
8557 TPtr FilePathPtr = FilePath->Des(); |
|
8558 HBufC8* FilePath8 = HBufC8::NewLC(KMaxFileName); // must be defined to correct maxs dir length |
|
8559 TPtr8 FilePathPtr8 = FilePath8->Des(); |
|
8560 |
|
8561 _LIT8(KPacStoreSourceDir, "c:\\private\\101f8ec5\\PACGroup\\"); // in dir are dirs where from files are read |
|
8562 FilePathPtr8.Zero(); |
|
8563 FilePathPtr8.Append(KPacStoreSourceDir); |
|
8564 FilePathPtr8.Append(refPtr); |
|
8565 FilePathPtr8.Append(KSeparator); |
|
8566 FilePathPtr8.Append(bufPtr); |
|
8567 |
|
8568 FilePathPtr.Copy(FilePathPtr8); |
|
8569 |
|
8570 EAP_TRACE_DATA_DEBUG( |
|
8571 m_am_tools, |
|
8572 TRACE_FLAGS_DEFAULT, |
|
8573 (EAPL("eap_am_type_tls_peap_symbian_c::complete_add_imported_PAC_file: Delete File"), |
|
8574 FilePathPtr.Ptr(), |
|
8575 FilePathPtr.Size())); |
|
8576 |
|
8577 if(aFs.Delete(FilePathPtr)!= KErrNone) |
|
8578 { |
|
8579 EAP_TRACE_DATA_DEBUG( |
|
8580 m_am_tools, |
|
8581 TRACE_FLAGS_DEFAULT, |
|
8582 (EAPL("eap_am_type_tls_peap_symbian_c::complete_add_imported_PAC_file: Couldn't delete file"), |
|
8583 FilePathPtr.Ptr(), |
|
8584 FilePathPtr.Size())); |
|
8585 |
|
8586 |
|
8587 m_eap_fast_completion_status = eap_status_file_does_not_exist; |
|
8588 } |
|
8589 |
|
8590 CleanupStack::PopAndDestroy(FilePath8); |
|
8591 CleanupStack::PopAndDestroy(FilePath); |
|
8592 CleanupStack::PopAndDestroy(ref); |
|
8593 CleanupStack::PopAndDestroy(buf); |
|
8594 |
|
8595 } |
|
8596 |
|
8597 |
|
8598 // --------------------------------------------------------- |
|
8599 // eap_am_type_tls_peap_symbian_c::ContinueInitializePacStore() |
|
8600 // --------------------------------------------------------- |
|
8601 // |
|
8602 void eap_am_type_tls_peap_symbian_c::ContinueInitializePacStore() |
|
8603 |
|
8604 { |
|
8605 EAP_TRACE_DEBUG_SYMBIAN( |
|
8606 (_L("eap_am_type_tls_peap_symbian_c::ContinueInitializePacStore()"))); |
|
8607 |
|
8608 TRAPD(error, CheckPasswordTimeValidityL()); |
|
8609 |
|
8610 if(error != KErrNone) |
|
8611 { |
|
8612 EAP_TRACE_DEBUG( |
|
8613 m_am_tools, |
|
8614 TRACE_FLAGS_DEFAULT, |
|
8615 (EAPL("EAP-FAST: eap_am_type_tls_peap_symbian_c::ContinueInitializePacStore() ERROR: LEAVE from CheckPasswordTimeValidityL() error=%d"), |
|
8616 error)); |
|
8617 } |
|
8618 |
|
8619 EAP_TRACE_DEBUG( |
|
8620 m_am_tools, |
|
8621 TRACE_FLAGS_DEFAULT, |
|
8622 (EAPL("EAP-FAST: %s: eap_am_type_tls_peap_symbian_c::ContinueInitializePacStore(): ") |
|
8623 EAPL("this = 0x%08x\n"), |
|
8624 (m_is_client == true ? "client": "server"), |
|
8625 this)); |
|
8626 |
|
8627 m_eap_fast_completion_status = eap_status_ok; |
|
8628 |
|
8629 EAP_TRACE_DEBUG_SYMBIAN( |
|
8630 (_L("eap_am_type_tls_peap_symbian_c::ContinueInitializePacStore: Remove removed IAP references"))); |
|
8631 |
|
8632 m_eap_fast_completion_status = m_partner->set_timer( |
|
8633 this, |
|
8634 KRemoveIAPReferenceTimerID, |
|
8635 0, |
|
8636 1); |
|
8637 |
|
8638 } |
|
8639 |
|
8640 //-------------------------------------------------- |
|
8641 |
|
8642 // This is commented in eap_am_fast_pac_store_services_c::complete_remove_PAC(). |
|
8643 EAP_FUNC_EXPORT eap_status_e eap_am_type_tls_peap_symbian_c::complete_remove_PAC( |
|
8644 const eap_status_e /* completion_status */, |
|
8645 const eap_variable_data_c * const /* out_used_group_reference */) |
|
8646 { |
|
8647 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
8648 |
|
8649 EAP_TRACE_DEBUG( |
|
8650 m_am_tools, |
|
8651 TRACE_FLAGS_DEFAULT, |
|
8652 (EAPL("EAP-FAST: %s: crypto_function: eap_am_type_tls_peap_symbian_c::complete_remove_PAC(): ") |
|
8653 EAPL("this = 0x%08x\n"), |
|
8654 (m_is_client == true ? "client": "server"), |
|
8655 this)); |
|
8656 |
|
8657 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
8658 return EAP_STATUS_RETURN(m_am_tools, eap_status_not_supported); |
|
8659 } |
|
8660 |
|
8661 //-------------------------------------------------- |
|
8662 |
|
8663 // This is commented in eap_am_fast_pac_store_services_c::complete_remove_IAP_reference(). |
|
8664 EAP_FUNC_EXPORT eap_status_e eap_am_type_tls_peap_symbian_c::complete_remove_IAP_reference( |
|
8665 const eap_status_e completion_status) |
|
8666 { |
|
8667 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
8668 |
|
8669 EAP_TRACE_DEBUG( |
|
8670 m_am_tools, |
|
8671 TRACE_FLAGS_DEFAULT, |
|
8672 (EAPL("EAP-FAST: %s: crypto_function: eap_am_type_tls_peap_symbian_c::complete_remove_IAP_reference(): ") |
|
8673 EAPL("this = 0x%08x\n"), |
|
8674 (m_is_client == true ? "client": "server"), |
|
8675 this)); |
|
8676 |
|
8677 eap_variable_data_c aIapReference(m_am_tools); |
|
8678 if (aIapReference.get_is_valid() == false) |
|
8679 { |
|
8680 return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error); |
|
8681 } |
|
8682 |
|
8683 eap_variable_data_c aGroupReferenceCollection(m_am_tools); |
|
8684 if (aGroupReferenceCollection.get_is_valid() == false) |
|
8685 { |
|
8686 return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error); |
|
8687 } |
|
8688 |
|
8689 // delete previously removed entry |
|
8690 TRAPD(error, iPacStoreDb->RemoveTheFirstCleanupReferenceEntryL()); |
|
8691 |
|
8692 if(error != KErrNone) |
|
8693 { |
|
8694 EAP_UNREFERENCED_PARAMETER(completion_status); |
|
8695 EAP_TRACE_DEBUG( |
|
8696 m_am_tools, |
|
8697 TRACE_FLAGS_DEFAULT, |
|
8698 (EAPL("EAP-FAST: eap_am_type_tls_peap_symbian_c::complete_remove_IAP_reference() ERROR: LEAVE from RemoveTheFirstCleanupReferenceEntryL error=%d"), |
|
8699 error)); |
|
8700 |
|
8701 m_eap_fast_completion_status = m_am_tools->convert_am_error_to_eapol_error(error); |
|
8702 } |
|
8703 |
|
8704 TRAPD(error1, iPacStoreDb->GetTheFirstCleanupReferenceEntryL( |
|
8705 &aIapReference, |
|
8706 &aGroupReferenceCollection)); |
|
8707 |
|
8708 if(error1 != KErrNone) |
|
8709 { |
|
8710 EAP_TRACE_DEBUG( |
|
8711 m_am_tools, |
|
8712 TRACE_FLAGS_DEFAULT, |
|
8713 (EAPL("EAP-FAST: eap_am_type_tls_peap_symbian_c::complete_remove_IAP_reference() ERROR: LEAVE from GetTheFirstCleanupReferenceEntryL error=%d"), |
|
8714 error1)); |
|
8715 |
|
8716 m_eap_fast_completion_status = m_am_tools->convert_am_error_to_eapol_error(error1); |
|
8717 } |
|
8718 |
|
8719 if ((aIapReference.get_data_length() > 0) && !m_completed_with_zero) |
|
8720 { |
|
8721 m_eap_fast_completion_status = m_partner->set_timer( |
|
8722 this, |
|
8723 KRemoveIAPReferenceTimerID, |
|
8724 0, |
|
8725 1); |
|
8726 |
|
8727 if (m_eap_fast_completion_status != eap_status_ok) |
|
8728 { |
|
8729 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
8730 return EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status); |
|
8731 } |
|
8732 } |
|
8733 else if (m_completed_with_zero) |
|
8734 { |
|
8735 m_eap_fast_completion_status = m_partner->set_timer( |
|
8736 this, |
|
8737 KImportFileTimerID, // if nothing in db & remove_IAP_reference called already with 0 -> import |
|
8738 0, |
|
8739 1); |
|
8740 |
|
8741 if (m_eap_fast_completion_status != eap_status_ok) |
|
8742 { |
|
8743 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
8744 return EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status); |
|
8745 } |
|
8746 } |
|
8747 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
8748 return EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status); |
|
8749 } |
|
8750 |
|
8751 // This is commented in eap_am_fast_pac_store_services_c::cancel_PAC_store_operations(). |
|
8752 EAP_FUNC_EXPORT eap_status_e eap_am_type_tls_peap_symbian_c::cancel_PAC_store_operations() |
|
8753 { |
|
8754 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
8755 |
|
8756 EAP_TRACE_DEBUG( |
|
8757 m_am_tools, |
|
8758 TRACE_FLAGS_DEFAULT, |
|
8759 (EAPL("EAP-FAST: %s: crypto_function: eap_am_type_tls_peap_symbian_c::cancel_PAC_store_operations(): ") |
|
8760 EAPL("this = 0x%08x\n"), |
|
8761 (m_is_client == true ? "client": "server"), |
|
8762 this)); |
|
8763 |
|
8764 EAP_TRACE_RETURN_STRING(m_am_tools, "returns: eap_am_type_tls_peap_symbian_c::cancel_PAC_store_operations()"); |
|
8765 |
|
8766 if(iPacStoreDb) |
|
8767 iPacStoreDb->Cancel(); |
|
8768 |
|
8769 |
|
8770 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
8771 return EAP_STATUS_RETURN(m_am_tools, eap_status_ok); |
|
8772 } |
|
8773 |
|
8774 //-------------------------------------------------- |
|
8775 |
|
8776 |
|
8777 EAP_FUNC_EXPORT eap_status_e |
|
8778 eap_am_type_tls_peap_symbian_c::initialize_PAC_store( |
|
8779 const eap_fast_completion_operation_e aCompletionOperation, |
|
8780 const eap_fast_initialize_pac_store_completion_e aCompletion ) |
|
8781 { |
|
8782 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
8783 EAP_TRACE_DEBUG(m_am_tools, |
|
8784 TRACE_FLAGS_DEFAULT, |
|
8785 (EAPL("eap_am_type_tls_peap_symbian_c::initialize_PAC_store IN\n"))); |
|
8786 |
|
8787 iCompletionOperation = aCompletionOperation; |
|
8788 iCompletion = aCompletion; |
|
8789 |
|
8790 TRAPD( err, FixOldTableForPacStoreInitL() ); |
|
8791 if ( err != KErrNone ) |
|
8792 { |
|
8793 EAP_TRACE_DEBUG( m_am_tools, TRACE_FLAGS_DEFAULT, ( EAPL( |
|
8794 "ERROR: eap_am_type_tls_peap_symbian_c::initialize_PAC_store() \ |
|
8795 Failed to fix table.\n" ) ) ); |
|
8796 } |
|
8797 |
|
8798 if ( iPacStoreDb ) |
|
8799 { |
|
8800 |
|
8801 TBool isInitialized = EFalse; |
|
8802 TRAP( err, isInitialized = iPacStoreDb->IsInitializedL() ); |
|
8803 if ( err == KErrNone ) |
|
8804 { |
|
8805 if ( !isInitialized ) |
|
8806 { |
|
8807 EAP_TRACE_DEBUG_SYMBIAN( |
|
8808 (_L("eap_am_type_tls_peap_symbian_c::initialize_PAC_store(): PAC store initialized, erase memorystore"))); |
|
8809 m_tls_application->remove_cached_pac_store_data(); |
|
8810 TRAP( err, iPacStoreDb->SetPacStoreInitValueL( |
|
8811 CPacStoreDatabase::EPacStoreInitialized ) ); |
|
8812 if ( err != KErrNone ) |
|
8813 { |
|
8814 EAP_TRACE_DEBUG_SYMBIAN( |
|
8815 (_L("eap_am_type_tls_peap_symbian_c::initialize_PAC_store(): ERROR: Leave in SetPacStoreInitValueL()"))); |
|
8816 } |
|
8817 } |
|
8818 // asynch. call, return immediately |
|
8819 iPacStoreDb->CreateDeviceSeedAsynch(); |
|
8820 } |
|
8821 else |
|
8822 { |
|
8823 EAP_TRACE_DEBUG_SYMBIAN( ( _L( |
|
8824 "ERROR: eap_am_type_tls_peap_symbian_c::initialize_PAC_store(): Leave, IsInitializedL(), err=%d.\n"), |
|
8825 err ) ); |
|
8826 |
|
8827 return m_am_tools->convert_am_error_to_eapol_error(err); |
|
8828 } |
|
8829 } |
|
8830 |
|
8831 m_eap_fast_completion_status = eap_status_pending_request; |
|
8832 |
|
8833 EAP_TRACE_DEBUG(m_am_tools, |
|
8834 TRACE_FLAGS_DEFAULT, |
|
8835 (EAPL("eap_am_type_tls_peap_symbian_c::initialize_PAC_store() OUT\n"))); |
|
8836 |
|
8837 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
8838 return EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status); |
|
8839 } |
|
8840 |
|
8841 // --------------------------------------------------------------------------- |
|
8842 // eap_am_type_tls_peap_symbian_c::indicates_eap_fast_provisioning_starts |
|
8843 // --------------------------------------------------------------------------- |
|
8844 // |
|
8845 EAP_FUNC_EXPORT |
|
8846 eap_status_e eap_am_type_tls_peap_symbian_c::indicates_eap_fast_provisioning_starts( |
|
8847 const eap_fast_completion_operation_e provisioning_mode, |
|
8848 const eap_fast_pac_type_e pac_type ) |
|
8849 { |
|
8850 eap_status_e status( eap_status_ok ); |
|
8851 m_provisioning_mode = provisioning_mode; // save provis. mode |
|
8852 |
|
8853 TInt err = KErrNone; |
|
8854 if ( !iEapFastActiveWaitNote ) |
|
8855 { |
|
8856 TRAP( err, iEapFastActiveWaitNote = CEapFastActive::NewL( this ) ); |
|
8857 } |
|
8858 if ( !iEapFastActiveNotes ) |
|
8859 { |
|
8860 TRAP( err, iEapFastActiveNotes = CEapFastActive::NewL( this ) ); |
|
8861 } |
|
8862 if ( err != KErrNone ) |
|
8863 { |
|
8864 status = eap_status_allocation_error; |
|
8865 } |
|
8866 /** |
|
8867 * The note is started in a separate active object. |
|
8868 * When user cancels waiting note, |
|
8869 * SendErrorNotification( eap_status_user_cancel_authentication ) |
|
8870 * will be called in iEapFastActiveWaitNote->RunL(). |
|
8871 * Otherwise note is stopped using iEapFastActiveWaitNote.Start() method. |
|
8872 */ |
|
8873 TBool startedOk = ETrue; |
|
8874 |
|
8875 if ( pac_type == eap_fast_pac_type_tunnel_pac |
|
8876 && |
|
8877 provisioning_mode == |
|
8878 eap_fast_completion_operation_server_authenticated_provisioning_mode |
|
8879 && |
|
8880 status == eap_status_ok ) |
|
8881 { |
|
8882 EAP_TRACE_DEBUG_SYMBIAN( ( _L("eap_am_type_tls_peap_symbian_c:: \ |
|
8883 indicates_eap_fast_provisioning_starts Authenticated provisioning!"))); |
|
8884 startedOk = iEapFastActiveWaitNote->Start( |
|
8885 CEapFastActive::EEapFastActiveStartAuthProvWaitNote ); |
|
8886 } |
|
8887 else if ( |
|
8888 pac_type == eap_fast_pac_type_tunnel_pac |
|
8889 && |
|
8890 provisioning_mode == |
|
8891 eap_fast_completion_operation_server_unauthenticated_provisioning_mode_ADHP |
|
8892 && |
|
8893 status == eap_status_ok ) |
|
8894 { |
|
8895 EAP_TRACE_DEBUG_SYMBIAN( (_L("eap_am_type_tls_peap_symbian_c:: \ |
|
8896 indicates_eap_fast_provisioning_starts UnAuthenticated provisioning!"))); |
|
8897 startedOk = iEapFastActiveWaitNote->Start( |
|
8898 CEapFastActive::EEapFastActiveStartUnauthProvWaitNote ); |
|
8899 } |
|
8900 if ( startedOk == EFalse ) |
|
8901 { |
|
8902 status = eap_status_process_general_error; |
|
8903 } |
|
8904 if ( status != eap_status_ok ) |
|
8905 { |
|
8906 EAP_TRACE_DEBUG_SYMBIAN( (_L("eap_am_type_tls_peap_symbian_c:: \ |
|
8907 indicates_eap_fast_provisioning_starts ERROR: status=%d."), status ) ); |
|
8908 } |
|
8909 return status; |
|
8910 } |
|
8911 |
|
8912 // --------------------------------------------------------------------------- |
|
8913 // eap_am_type_tls_peap_symbian_c::indicates_eap_fast_provisioning_ends |
|
8914 // --------------------------------------------------------------------------- |
|
8915 // |
|
8916 EAP_FUNC_EXPORT |
|
8917 eap_status_e eap_am_type_tls_peap_symbian_c::indicates_eap_fast_provisioning_ends( |
|
8918 const bool provisioning_successfull, |
|
8919 const eap_fast_completion_operation_e provisioning_mode, |
|
8920 const eap_fast_pac_type_e pac_type ) |
|
8921 { |
|
8922 EAP_TRACE_DEBUG_SYMBIAN( (_L("eap_am_type_tls_peap_symbian_c:: \ |
|
8923 indicates_eap_fast_provisioning_ends()"))); |
|
8924 |
|
8925 EAP_UNREFERENCED_PARAMETER(provisioning_mode); |
|
8926 |
|
8927 eap_status_e status( eap_status_ok ); |
|
8928 |
|
8929 if ( pac_type == eap_fast_pac_type_tunnel_pac ) |
|
8930 { |
|
8931 // stop wait note; |
|
8932 if ( iEapFastActiveWaitNote ) |
|
8933 { |
|
8934 if ( iEapFastActiveWaitNote->IsActive() ) |
|
8935 { |
|
8936 iEapFastActiveWaitNote->Cancel(); |
|
8937 } |
|
8938 delete iEapFastActiveWaitNote; |
|
8939 iEapFastActiveWaitNote = NULL; |
|
8940 } |
|
8941 |
|
8942 if ( iEapFastActiveNotes ) |
|
8943 { |
|
8944 if( provisioning_successfull ) |
|
8945 { |
|
8946 // synch. call |
|
8947 iEapFastActiveNotes->Start( CEapFastActive:: |
|
8948 EEapFastActiveShowProvSuccessNote, ETrue ); |
|
8949 } |
|
8950 else |
|
8951 { |
|
8952 // synch. call |
|
8953 iEapFastActiveNotes->Start( CEapFastActive:: |
|
8954 EapFastActiveShowProvNotSuccessNote, ETrue ); |
|
8955 } |
|
8956 } |
|
8957 } // if ( pac_type == eap_fast_pac_type_tunnel_pac ) |
|
8958 |
|
8959 return status; |
|
8960 } |
|
8961 |
|
8962 #endif //#if defined(USE_FAST_EAP_TYPE) |
|
8963 |
|
8964 #ifdef USE_PAC_STORE |
|
8965 |
|
8966 void eap_am_type_tls_peap_symbian_c::GetPacStoreDbDataL( |
|
8967 const eap_pac_store_data_type_e aPacStoreDataType, |
|
8968 eap_variable_data_c * aPacStoreData, |
|
8969 const eap_variable_data_c * const aPacStoreReference /*=NULL*/) |
|
8970 { |
|
8971 EAP_TRACE_DEBUG_SYMBIAN( |
|
8972 (_L("eap_am_type_tls_peap_symbian_c::GetPacStoreDbDataL Start aPacStoreDataType=%d"), |
|
8973 aPacStoreDataType)); |
|
8974 |
|
8975 if(m_current_eap_type != eap_type_fast || iPacStoreDb == NULL) |
|
8976 { |
|
8977 EAP_TRACE_DEBUG_SYMBIAN( |
|
8978 (_L("eap_am_type_tls_peap_symbian_c::GetPacStoreDbDataL ERROR: Unknown EAP type or No PAC store DB!"))); |
|
8979 |
|
8980 // Can't proceed. |
|
8981 User::Leave(KErrNotSupported); |
|
8982 } |
|
8983 |
|
8984 TBuf<KMaxDBFieldNameLength> pacStoreDBColName; |
|
8985 HBufC8* pacStoreDBColValBuf8(NULL); |
|
8986 eap_status_e status(eap_status_ok); |
|
8987 TInt error(KErrNone); |
|
8988 TBuf<KDbMaxName> dbTableName; |
|
8989 HBufC8* aDbBinaryColumnValue(NULL); |
|
8990 |
|
8991 switch(aPacStoreDataType) |
|
8992 { |
|
8993 case eap_pac_store_data_type_PAC_store_master_key: |
|
8994 { |
|
8995 pacStoreDBColName.Copy(KPacStoreMasterKey); |
|
8996 pacStoreDBColValBuf8 = HBufC8::NewLC(KMaxMasterKeyLengthInDB); |
|
8997 break; |
|
8998 } |
|
8999 case eap_pac_store_data_type_PAC_store_password: |
|
9000 { |
|
9001 pacStoreDBColName.Copy(cf_str_EAP_FAST_PAC_store_password_literal); |
|
9002 pacStoreDBColValBuf8 = HBufC8::NewLC(KMaxPasswordLengthInDB); |
|
9003 break; |
|
9004 } |
|
9005 case eap_pac_store_data_type_PAC_store_device_seed: |
|
9006 { |
|
9007 // Not in PAC store. This should not be called. |
|
9008 |
|
9009 EAP_TRACE_DEBUG_SYMBIAN( |
|
9010 (_L("eap_am_type_tls_peap_symbian_c::GetPacStoreDbDataL ERROR: This is not in PAC store DB!"))); |
|
9011 |
|
9012 return; |
|
9013 } |
|
9014 case eap_pac_store_data_type_PAC_store_IAP_reference: |
|
9015 { |
|
9016 // Not in PAC store. This should not be called. |
|
9017 |
|
9018 EAP_TRACE_DEBUG_SYMBIAN( |
|
9019 (_L("eap_am_type_tls_peap_symbian_c::GetPacStoreDbDataL ERROR: This is not in PAC store DB!"))); |
|
9020 |
|
9021 return; |
|
9022 } |
|
9023 case eap_pac_store_data_type_PAC_store_group_reference: |
|
9024 { |
|
9025 // Not in PAC store. This should not be called. |
|
9026 |
|
9027 EAP_TRACE_DEBUG_SYMBIAN( |
|
9028 (_L("eap_am_type_tls_peap_symbian_c::GetPacStoreDbDataL ERROR: This is not in PAC store DB!"))); |
|
9029 |
|
9030 return; |
|
9031 } |
|
9032 case eap_pac_store_data_type_reference_counter: |
|
9033 { |
|
9034 pacStoreDBColName.Copy(KPacStoreReferenceCounter); |
|
9035 pacStoreDBColValBuf8 = HBufC8::NewLC(KMaxRefCounterLengthInDB); |
|
9036 break; |
|
9037 } |
|
9038 case eap_pac_store_data_type_PAC_file_password: |
|
9039 { |
|
9040 // Not in PAC store. This should not be called. |
|
9041 |
|
9042 EAP_TRACE_DEBUG_SYMBIAN( |
|
9043 (_L("eap_am_type_tls_peap_symbian_c::GetPacStoreDbDataL ERROR: This is not in PAC store DB!"))); |
|
9044 |
|
9045 return; |
|
9046 } |
|
9047 case eap_pac_store_data_type_group_info: |
|
9048 { |
|
9049 dbTableName = KPacStoreGroupsTableName; |
|
9050 break; |
|
9051 } |
|
9052 case eap_pac_store_data_type_A_ID_info: |
|
9053 { |
|
9054 dbTableName = KPacStoreAIDsTableName; |
|
9055 break; |
|
9056 } |
|
9057 case eap_pac_store_data_type_PAC_info: |
|
9058 { |
|
9059 dbTableName = KPacStorePACsTableName; |
|
9060 break; |
|
9061 } |
|
9062 case eap_pac_store_data_type_group_data: |
|
9063 { |
|
9064 // Memory for aDbBinaryColumnValue is allocated in CPacStoreDatabase::GetPacStoreDataL |
|
9065 pacStoreDBColName.Copy(KPacStoreGroupValue); |
|
9066 break; |
|
9067 } |
|
9068 case eap_pac_store_data_type_A_ID_data: |
|
9069 { |
|
9070 // Memory for aDbBinaryColumnValue is allocated in CPacStoreDatabase::GetPacStoreDataL |
|
9071 pacStoreDBColName.Copy(KPacStoreAIDValue); |
|
9072 break; |
|
9073 } |
|
9074 case eap_pac_store_data_type_PAC_data: |
|
9075 { |
|
9076 // Memory for aDbBinaryColumnValue is allocated in CPacStoreDatabase::GetPacStoreDataL |
|
9077 pacStoreDBColName.Copy(KPacStorePACValue); |
|
9078 break; |
|
9079 } |
|
9080 default: |
|
9081 { |
|
9082 break; |
|
9083 } |
|
9084 } // End : switch(aPacStoreDataType) |
|
9085 |
|
9086 switch(aPacStoreDataType) |
|
9087 { |
|
9088 case eap_pac_store_data_type_PAC_store_master_key: |
|
9089 case eap_pac_store_data_type_PAC_store_password: |
|
9090 case eap_pac_store_data_type_reference_counter: |
|
9091 { |
|
9092 TPtr8 pacStoreDBColValPtr8 = pacStoreDBColValBuf8->Des(); |
|
9093 |
|
9094 TRAPD( err, iPacStoreDb->GetPacStoreDataL(pacStoreDBColName, pacStoreDBColValPtr8) ); |
|
9095 if ( err ) |
|
9096 { |
|
9097 if(pacStoreDBColValBuf8 != NULL) |
|
9098 { |
|
9099 CleanupStack::PopAndDestroy(pacStoreDBColValBuf8); |
|
9100 pacStoreDBColValBuf8 = NULL; |
|
9101 User::Leave( err ); |
|
9102 } |
|
9103 } |
|
9104 |
|
9105 status = aPacStoreData->set_copy_of_buffer( |
|
9106 pacStoreDBColValPtr8.Ptr(), |
|
9107 pacStoreDBColValPtr8.Size()); |
|
9108 |
|
9109 error = m_am_tools->convert_eapol_error_to_am_error(status); |
|
9110 break; |
|
9111 } |
|
9112 case eap_pac_store_data_type_group_data: |
|
9113 case eap_pac_store_data_type_A_ID_data: |
|
9114 case eap_pac_store_data_type_PAC_data: |
|
9115 { |
|
9116 EAP_TRACE_DEBUG_SYMBIAN( |
|
9117 (_L("eap_am_type_tls_peap_symbian_c::GetPacStoreDbDataL: To get GROUP, PAC or AID data"))); |
|
9118 |
|
9119 |
|
9120 if(aPacStoreReference == NULL )//|| aPacStoreReference->get_data_length() <= 0) |
|
9121 { |
|
9122 EAP_TRACE_DEBUG_SYMBIAN( |
|
9123 (_L("eap_am_type_tls_peap_symbian_c::GetPacStoreDbDataL ERROR: Empty reference"))); |
|
9124 |
|
9125 // Can't proceed. |
|
9126 User::Leave(KErrArgument); |
|
9127 } |
|
9128 if ( aPacStoreReference->get_data_length() <= 0 ) |
|
9129 { |
|
9130 EAP_TRACE_DEBUG_SYMBIAN( |
|
9131 (_L("eap_am_type_tls_peap_symbian_c::GetPacStoreDbDataL reset aPacStoreData."))); |
|
9132 aPacStoreData->reset(); |
|
9133 break; |
|
9134 } |
|
9135 |
|
9136 |
|
9137 HBufC8 * reference8 = HBufC8::NewLC(aPacStoreReference->get_data_length()); |
|
9138 TPtr8 referencePtr8 = reference8->Des(); |
|
9139 |
|
9140 referencePtr8.Copy(aPacStoreReference->get_data(), |
|
9141 aPacStoreReference->get_data_length()); |
|
9142 |
|
9143 EAP_TRACE_DATA_DEBUG_SYMBIAN( |
|
9144 ("eap_am_type_tls_peap_symbian_c::GetPacStoreDbDataL: reference to DB", |
|
9145 referencePtr8.Ptr(), |
|
9146 referencePtr8.Size())); |
|
9147 |
|
9148 TPtr8 pacStoreDBColDataValPtr8(0,0); |
|
9149 |
|
9150 TRAPD( err, iPacStoreDb->GetPacStoreDataL(pacStoreDBColName, pacStoreDBColDataValPtr8, referencePtr8, &aDbBinaryColumnValue) ); |
|
9151 if ( err ) |
|
9152 { |
|
9153 CleanupStack::PopAndDestroy(1); // reference8. |
|
9154 if(pacStoreDBColValBuf8 != NULL) |
|
9155 { |
|
9156 CleanupStack::PopAndDestroy(pacStoreDBColValBuf8); |
|
9157 pacStoreDBColValBuf8 = NULL; |
|
9158 delete (aDbBinaryColumnValue); |
|
9159 User::Leave( err ); |
|
9160 } |
|
9161 } |
|
9162 |
|
9163 |
|
9164 CleanupStack::PopAndDestroy(1); // reference8. |
|
9165 |
|
9166 if (aDbBinaryColumnValue != NULL) |
|
9167 { |
|
9168 TPtr8 aDbBinaryColumnValuePtr = aDbBinaryColumnValue->Des(); |
|
9169 |
|
9170 EAP_TRACE_DEBUG_SYMBIAN( |
|
9171 (_L("eap_am_type_tls_peap_symbian_c::GetPacStoreDbDataL, data size=%d"), |
|
9172 aDbBinaryColumnValuePtr.Size())); |
|
9173 |
|
9174 if (aDbBinaryColumnValuePtr.Size() > 0) |
|
9175 { |
|
9176 status = aPacStoreData->set_copy_of_buffer( |
|
9177 aDbBinaryColumnValuePtr.Ptr(), |
|
9178 aDbBinaryColumnValuePtr.Size()); |
|
9179 } |
|
9180 else |
|
9181 { |
|
9182 EAP_TRACE_DEBUG_SYMBIAN( |
|
9183 (_L("eap_am_type_tls_peap_symbian_c::No data to fill !!"))); |
|
9184 |
|
9185 } |
|
9186 delete (aDbBinaryColumnValue); |
|
9187 } |
|
9188 else |
|
9189 { |
|
9190 EAP_TRACE_DEBUG_SYMBIAN( |
|
9191 (_L("eap_am_type_tls_peap_symbian_c::Data NULL !!"))); |
|
9192 } |
|
9193 |
|
9194 error = m_am_tools->convert_eapol_error_to_am_error(status); |
|
9195 |
|
9196 delete (pacStoreDBColDataValPtr8.Ptr()); |
|
9197 |
|
9198 break; |
|
9199 } |
|
9200 case eap_pac_store_data_type_group_info: |
|
9201 case eap_pac_store_data_type_A_ID_info: |
|
9202 case eap_pac_store_data_type_PAC_info: |
|
9203 { |
|
9204 |
|
9205 EAP_TRACE_DEBUG_SYMBIAN( |
|
9206 (_L("eap_am_type_tls_peap_symbian_c::GetPacStoreDbDataL:ERROR: Calls for INFOs should not come here !!!"))); |
|
9207 |
|
9208 break; |
|
9209 } |
|
9210 default: |
|
9211 { |
|
9212 EAP_TRACE_DEBUG_SYMBIAN( |
|
9213 (_L("eap_am_type_tls_peap_symbian_c::GetPacStoreDbDataL - UNSUPPORTED Column !!!"))); |
|
9214 |
|
9215 break; |
|
9216 } |
|
9217 }// End: switch(aPacStoreDataType) |
|
9218 |
|
9219 if(pacStoreDBColValBuf8 != NULL) |
|
9220 { |
|
9221 CleanupStack::PopAndDestroy(pacStoreDBColValBuf8); |
|
9222 } |
|
9223 |
|
9224 EAP_TRACE_DEBUG_SYMBIAN( |
|
9225 (_L("eap_am_type_tls_peap_symbian_c::GetPacStoreDbDataL-End"))); |
|
9226 |
|
9227 User::LeaveIfError(error); // This could be success or error. Does't matter. |
|
9228 } |
|
9229 |
|
9230 #endif // End: #ifdef USE_PAC_STORE |
|
9231 |
|
9232 //-------------------------------------------------- |
|
9233 |
|
9234 #if defined(USE_FAST_EAP_TYPE) |
|
9235 |
|
9236 eap_status_e eap_am_type_tls_peap_symbian_c::ShowNotifierItemAndGetResponse( |
|
9237 EEapFastNotifierUiItem aNotifierUiItem, TBool aSetActive ) |
|
9238 { |
|
9239 EAP_TRACE_DEBUG_SYMBIAN( |
|
9240 (_L("eap_am_type_tls_peap_symbian_c::ShowNotifierItem aNotifierUiItem=%d, ActiveStatus=%d "), |
|
9241 aNotifierUiItem, IsActive())); |
|
9242 |
|
9243 if ( aSetActive && IsActive() ) |
|
9244 { |
|
9245 EAP_TRACE_DEBUG_SYMBIAN( |
|
9246 (_L("ShowNotifierItemAndGetResponse: Already active when tried to show Notifier"))); |
|
9247 |
|
9248 return eap_status_device_busy; |
|
9249 } |
|
9250 |
|
9251 eap_status_e status( eap_status_ok ); |
|
9252 |
|
9253 if( !m_is_notifier_connected ) |
|
9254 { |
|
9255 TInt error = m_notifier.Connect(); |
|
9256 |
|
9257 EAP_TRACE_DEBUG_SYMBIAN( |
|
9258 (_L("eap_am_type_tls_peap_symbian_c::ShowNotifierItem - m_notifier.Connect() returned error=%d\n"), error)); |
|
9259 |
|
9260 if( error != KErrNone) |
|
9261 { |
|
9262 // Can not connect to notifier. |
|
9263 return m_am_tools->convert_am_error_to_eapol_error(error); |
|
9264 } |
|
9265 |
|
9266 m_is_notifier_connected = ETrue; // Got connectted to notifier. |
|
9267 } |
|
9268 |
|
9269 // Update the values needed for notifier. |
|
9270 m_notifier_data_to_user->iEapFastNotifierUiItem = aNotifierUiItem; |
|
9271 |
|
9272 EAP_TRACE_DEBUG_SYMBIAN( |
|
9273 (_L("m_notifier_data_pckg_to_user"), |
|
9274 m_notifier_data_pckg_to_user->Ptr(), |
|
9275 m_notifier_data_pckg_to_user->Size())); |
|
9276 |
|
9277 m_notifier_data_from_user->iEapFastNotifierBuffer.Delete(0,KMaxEapFastNotifierBufLength); |
|
9278 |
|
9279 EAP_TRACE_DEBUG_SYMBIAN( |
|
9280 (_L("eap_am_type_tls_peap_symbian_c::ShowNotifierItem - StartNotifierAndGetResponse"))); |
|
9281 |
|
9282 m_notifier.StartNotifierAndGetResponse( |
|
9283 iStatus, |
|
9284 KEapFastNotifierUid, |
|
9285 *m_notifier_data_pckg_to_user, |
|
9286 *m_notifier_data_pckg_from_user); |
|
9287 |
|
9288 if ( aSetActive ) |
|
9289 { |
|
9290 m_notifier_complete = ETrue; |
|
9291 SetActive(); |
|
9292 } |
|
9293 |
|
9294 EAP_TRACE_DEBUG_SYMBIAN( |
|
9295 (_L("eap_am_type_tls_peap_symbian_c::ShowNotifierItem - End"))); |
|
9296 |
|
9297 return status; |
|
9298 } |
|
9299 |
|
9300 //-------------------------------------------------- |
|
9301 |
|
9302 eap_status_e eap_am_type_tls_peap_symbian_c::RemoveIAPReference() |
|
9303 { |
|
9304 EAP_TRACE_DEBUG_SYMBIAN( |
|
9305 (_L("eap_am_type_tls_peap_symbian_c::RemoveIAPReference - Start"))); |
|
9306 m_eap_fast_completion_status = eap_status_ok; |
|
9307 |
|
9308 eap_variable_data_c aIapReference(m_am_tools); |
|
9309 if (aIapReference.get_is_valid() == false) |
|
9310 { |
|
9311 return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error); |
|
9312 } |
|
9313 |
|
9314 eap_variable_data_c aGroupReferenceCollection(m_am_tools); |
|
9315 if (aGroupReferenceCollection.get_is_valid() == false) |
|
9316 { |
|
9317 return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error); |
|
9318 } |
|
9319 |
|
9320 TRAPD(error, iPacStoreDb->GetTheFirstCleanupReferenceEntryL( |
|
9321 &aIapReference, |
|
9322 &aGroupReferenceCollection)); |
|
9323 |
|
9324 if(error != KErrNone) |
|
9325 { |
|
9326 EAP_TRACE_DEBUG( |
|
9327 m_am_tools, |
|
9328 TRACE_FLAGS_DEFAULT, |
|
9329 (EAPL("EAP-FAST: eap_am_type_tls_peap_symbian_c::RemoveIAPReference() ERROR: LEAVE from GetTheFirstCleanupReferenceEntryL error=%d"), |
|
9330 error)); |
|
9331 |
|
9332 m_eap_fast_completion_status = m_am_tools->convert_am_error_to_eapol_error(error); |
|
9333 } |
|
9334 |
|
9335 if (aIapReference.get_data_length() > 0) |
|
9336 { |
|
9337 eap_fast_pac_store_data_c * const group_reference_and_data = new eap_fast_pac_store_data_c(m_am_tools); |
|
9338 |
|
9339 |
|
9340 m_eap_fast_completion_status = group_reference_and_data->get_writable_data()->set_copy_of_buffer(aGroupReferenceCollection.get_data(), aGroupReferenceCollection.get_data_length()); |
|
9341 |
|
9342 if (aIapReference.get_data_length() > 0) |
|
9343 m_completed_with_zero = EFalse; |
|
9344 else |
|
9345 m_completed_with_zero = ETrue; |
|
9346 |
|
9347 |
|
9348 if (m_eap_fast_completion_status == eap_status_ok) |
|
9349 { |
|
9350 m_eap_fast_completion_status = m_tls_application->remove_IAP_reference( |
|
9351 &aIapReference, |
|
9352 group_reference_and_data); |
|
9353 } |
|
9354 } |
|
9355 else |
|
9356 { |
|
9357 m_eap_fast_completion_status = m_partner->set_timer( |
|
9358 this, |
|
9359 KImportFileTimerID, // if nothing in db, go right to file read |
|
9360 0, |
|
9361 1); |
|
9362 } |
|
9363 EAP_TRACE_DEBUG_SYMBIAN( |
|
9364 (_L("eap_am_type_tls_peap_symbian_c::RemoveIAPReference - End"))); |
|
9365 |
|
9366 return m_eap_fast_completion_status; |
|
9367 } |
|
9368 |
|
9369 eap_status_e eap_am_type_tls_peap_symbian_c::ImportFilesL() |
|
9370 { |
|
9371 |
|
9372 EAP_TRACE_DEBUG_SYMBIAN( |
|
9373 (_L("eap_am_type_tls_peap_symbian_c::ImportFilesL - Start"))); |
|
9374 |
|
9375 CDir* files; |
|
9376 |
|
9377 RFs aFs; |
|
9378 aFs.Connect( KFileServerDefaultMessageSlots ); |
|
9379 |
|
9380 m_eap_fast_completion_status = eap_status_pending_request; |
|
9381 |
|
9382 TBool aSuccess = EFalse; |
|
9383 |
|
9384 eap_variable_data_c ImportReference(m_am_tools); |
|
9385 |
|
9386 EAP_TRACE_DEBUG_SYMBIAN( |
|
9387 (_L("eap_am_type_tls_peap_symbian_c::ImportFilesL: Get ImportReference from database"))); |
|
9388 |
|
9389 EapTlsPeapUtils::GetEapSettingsDataL( |
|
9390 m_database, |
|
9391 m_index_type, |
|
9392 m_index, |
|
9393 m_tunneling_type, |
|
9394 m_current_eap_type, |
|
9395 KFASTPACGroupImportReferenceCollection, |
|
9396 &ImportReference); |
|
9397 |
|
9398 HBufC8* group_reference8 = HBufC8::NewLC(KMaxFileName); |
|
9399 TPtr8 group_referencePtr8 = group_reference8->Des(); |
|
9400 |
|
9401 EAP_TRACE_DATA_DEBUG( |
|
9402 m_am_tools, |
|
9403 TRACE_FLAGS_DEFAULT, |
|
9404 (EAPL("eap_am_type_tls_peap_symbian_c::ImportFilesL: ImportReference"), |
|
9405 ImportReference.get_data(), |
|
9406 ImportReference.get_data_length())); |
|
9407 |
|
9408 if (ImportReference.get_data_length() != 0) |
|
9409 { |
|
9410 group_referencePtr8.Copy(ImportReference.get_data(), ImportReference.get_data_length()); |
|
9411 EAP_TRACE_DATA_DEBUG( |
|
9412 m_am_tools, |
|
9413 TRACE_FLAGS_DEFAULT, |
|
9414 (EAPL("eap_am_type_tls_peap_symbian_c::ImportFilesL: Reference"), |
|
9415 group_referencePtr8.Ptr(), |
|
9416 group_referencePtr8.Size())); |
|
9417 |
|
9418 } |
|
9419 else |
|
9420 { |
|
9421 m_eap_fast_completion_status = m_partner->set_timer( |
|
9422 this, |
|
9423 KHandleCompletePacstoreOkTimerID, |
|
9424 &m_eap_fast_completion_status, |
|
9425 1); |
|
9426 |
|
9427 CleanupStack::PopAndDestroy(group_reference8); |
|
9428 |
|
9429 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
9430 return EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status); |
|
9431 } |
|
9432 |
|
9433 HBufC8* tempUserBuf8 = HBufC8::NewLC(ImportReference.get_data_length()); |
|
9434 TPtr8 tempUserBufPtr8 = tempUserBuf8->Des(); |
|
9435 for (int i = 0; i< ImportReference.get_data_length();i++ ) |
|
9436 { |
|
9437 tempUserBufPtr8.Append(group_referencePtr8.Ptr()[i++]); |
|
9438 } |
|
9439 group_referencePtr8.Copy(tempUserBufPtr8); |
|
9440 CleanupStack::PopAndDestroy(tempUserBuf8); |
|
9441 |
|
9442 EAP_TRACE_DATA_DEBUG( |
|
9443 m_am_tools, |
|
9444 TRACE_FLAGS_DEFAULT, |
|
9445 (EAPL("eap_am_type_tls_peap_symbian_c::ImportFilesL: Reformatted Reference"), |
|
9446 group_referencePtr8.Ptr(), |
|
9447 group_referencePtr8.Size())); |
|
9448 TInt fileCounter=0; |
|
9449 TBool directoryEmpty = false; |
|
9450 TBool directoryExists = true; |
|
9451 HBufC* buf2 = HBufC::NewLC(KMaxPath); |
|
9452 HBufC8* filename8 = HBufC8::NewLC(KMaxFileName); |
|
9453 TPtr FileNamePtr = buf2->Des(); |
|
9454 TUint filesize =0; |
|
9455 TPtr8 filenamePtr8 = filename8->Des(); |
|
9456 TBool badFile = false; |
|
9457 HBufC* Path = HBufC::NewLC(KMaxFileName); |
|
9458 TPtr PathPtr = Path->Des(); |
|
9459 HBufC8* Path8 = HBufC8::NewLC(KMaxFileName); |
|
9460 TPtr8 PathPtr8 = Path8->Des(); |
|
9461 HBufC8* readData = NULL; |
|
9462 TBool FileFound(EFalse); |
|
9463 |
|
9464 PathPtr8.Zero(); |
|
9465 PathPtr8.Append(KPacStoreSourceDir); |
|
9466 PathPtr8.Append(group_referencePtr8); |
|
9467 PathPtr8.Append(KSeparator); |
|
9468 EAP_TRACE_DATA_DEBUG( |
|
9469 m_am_tools, |
|
9470 TRACE_FLAGS_DEFAULT, |
|
9471 (EAPL("eap_am_type_tls_peap_symbian_c::ImportFilesL: Path8"), |
|
9472 PathPtr8.Ptr(), |
|
9473 PathPtr8.Size())); |
|
9474 PathPtr.Zero(); |
|
9475 PathPtr.Copy(PathPtr8); |
|
9476 |
|
9477 EAP_TRACE_DATA_DEBUG( |
|
9478 m_am_tools, |
|
9479 TRACE_FLAGS_DEFAULT, |
|
9480 (EAPL("eap_am_type_tls_peap_symbian_c::ImportFilesL: Path"), |
|
9481 PathPtr.Ptr(), |
|
9482 PathPtr.Size())); |
|
9483 |
|
9484 EAP_TRACE_DEBUG_SYMBIAN( |
|
9485 (_L("eap_am_type_tls_peap_symbian_c::ImportFilesL: Check directory availability"))); |
|
9486 |
|
9487 if (aFs.GetDir(PathPtr, KEntryAttNormal, ESortByName, files) == KErrNone) |
|
9488 { |
|
9489 EAP_TRACE_DEBUG_SYMBIAN( |
|
9490 (_L("eap_am_type_tls_peap_symbian_c::ImportFilesL: Files %d"), |
|
9491 files->Count())); |
|
9492 |
|
9493 while (!FileFound && (fileCounter < files->Count())) |
|
9494 { |
|
9495 directoryExists = true; |
|
9496 |
|
9497 EAP_TRACE_DEBUG_SYMBIAN( |
|
9498 (_L("eap_am_type_tls_peap_symbian_c::ImportFilesL: Get directory contents"))); |
|
9499 |
|
9500 directoryEmpty = false; |
|
9501 |
|
9502 while( fileCounter < files->Count() || (!FileFound)) |
|
9503 { |
|
9504 if (!((*files)[fileCounter].IsDir())) |
|
9505 { |
|
9506 filesize = (*files)[fileCounter].iSize; |
|
9507 EAP_TRACE_DEBUG_SYMBIAN( |
|
9508 (_L("eap_am_type_tls_peap_symbian_c::ImportFilesL: File size %d"), |
|
9509 filesize)); |
|
9510 filenamePtr8.Copy((*files)[fileCounter++].iName); |
|
9511 EAP_TRACE_DATA_DEBUG( |
|
9512 m_am_tools, |
|
9513 TRACE_FLAGS_DEFAULT, |
|
9514 (EAPL("eap_am_type_tls_peap_symbian_c::ImportFilesL: Filename"), |
|
9515 filenamePtr8.Ptr(), |
|
9516 filenamePtr8.Size())); |
|
9517 FileFound = ETrue; |
|
9518 } |
|
9519 else |
|
9520 { |
|
9521 fileCounter++; |
|
9522 } |
|
9523 } |
|
9524 |
|
9525 if (!FileFound) |
|
9526 { |
|
9527 EAP_TRACE_DEBUG_SYMBIAN( |
|
9528 (_L("eap_am_type_tls_peap_symbian_c::ImportFilesL: DirectoryEmpty"))); |
|
9529 directoryEmpty = true; |
|
9530 } |
|
9531 |
|
9532 if (directoryEmpty == true || directoryExists == false || FileFound == EFalse) |
|
9533 { |
|
9534 if (directoryExists) |
|
9535 { |
|
9536 EAP_TRACE_DEBUG_SYMBIAN( |
|
9537 (_L("eap_am_type_tls_peap_symbian_c::ImportFilesL: We would remove directory"))); |
|
9538 |
|
9539 { |
|
9540 m_eap_fast_completion_status = m_partner->set_timer( |
|
9541 this, |
|
9542 KHandleCompletePacstoreOkTimerID, |
|
9543 &m_eap_fast_completion_status, |
|
9544 1); |
|
9545 if (readData != NULL) |
|
9546 CleanupStack::PopAndDestroy(readData); |
|
9547 CleanupStack::PopAndDestroy(5); // Path, Path8, filename, buf2, group_reference8 |
|
9548 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
9549 return EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status); |
|
9550 } |
|
9551 } |
|
9552 } |
|
9553 else if(directoryEmpty == false && directoryExists == true && FileFound != EFalse) |
|
9554 { |
|
9555 PathPtr8.Zero(); |
|
9556 PathPtr8.Append(KPacStoreSourceDir); |
|
9557 PathPtr8.Append(group_referencePtr8); |
|
9558 PathPtr8.Append(KSeparator); |
|
9559 PathPtr8.Append(filenamePtr8); |
|
9560 EAP_TRACE_DATA_DEBUG( |
|
9561 m_am_tools, |
|
9562 TRACE_FLAGS_DEFAULT, |
|
9563 (EAPL("eap_am_type_tls_peap_symbian_c::ImportFilesL: Path8"), |
|
9564 PathPtr8.Ptr(), |
|
9565 PathPtr8.Size())); |
|
9566 PathPtr.Zero(); |
|
9567 PathPtr.Copy(PathPtr8); |
|
9568 |
|
9569 EAP_TRACE_DEBUG_SYMBIAN( |
|
9570 (_L("eap_am_type_tls_peap_symbian_c::ImportFilesL: Read file"))); |
|
9571 |
|
9572 RFile file; |
|
9573 if(file.Open(aFs, PathPtr, EFileRead)==KErrNone) |
|
9574 { |
|
9575 readData= HBufC8::NewLC(filesize); |
|
9576 TPtr8 readDataPtr = readData->Des(); |
|
9577 file.Read(readDataPtr); |
|
9578 file.Close(); |
|
9579 |
|
9580 EAP_TRACE_DEBUG_SYMBIAN( |
|
9581 (_L("eap_am_type_tls_peap_symbian_c::ImportFilesL: Copy data"))); |
|
9582 |
|
9583 eap_variable_data_c * const in_imported_PAC_data = new eap_variable_data_c(m_am_tools); |
|
9584 // eap_automatic_variable_c can be used in this block because no functions are leaving here. |
|
9585 eap_automatic_variable_c<eap_variable_data_c> automatic_in_imported_PAC_data(m_am_tools, in_imported_PAC_data); |
|
9586 if (in_imported_PAC_data == 0) |
|
9587 { |
|
9588 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
9589 return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error); |
|
9590 } |
|
9591 |
|
9592 m_eap_fast_completion_status = in_imported_PAC_data->set_copy_of_buffer(readDataPtr.Ptr(), readDataPtr.Size()); |
|
9593 |
|
9594 eap_fast_pac_store_data_c * const in_opt_group_reference_and_data = new eap_fast_pac_store_data_c(m_am_tools); |
|
9595 // eap_automatic_variable_c can be used in this block because no functions are leaving here. |
|
9596 eap_automatic_variable_c<eap_fast_pac_store_data_c> automatic_in_opt_group_reference_and_data(m_am_tools, in_opt_group_reference_and_data); |
|
9597 if (in_opt_group_reference_and_data == 0) |
|
9598 { |
|
9599 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
9600 return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error); |
|
9601 } |
|
9602 |
|
9603 in_opt_group_reference_and_data->get_writable_data()->set_copy_of_buffer(readDataPtr.Ptr(), readDataPtr.Size()); |
|
9604 |
|
9605 eap_variable_data_c * const in_imported_PAC_filename = new eap_variable_data_c(m_am_tools); |
|
9606 // eap_automatic_variable_c can be used in this block because no functions are leaving here. |
|
9607 eap_automatic_variable_c<eap_variable_data_c> automatic_in_imported_PAC_filename(m_am_tools, in_imported_PAC_filename); |
|
9608 if (in_imported_PAC_filename == 0) |
|
9609 { |
|
9610 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
9611 return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error); |
|
9612 } |
|
9613 |
|
9614 m_eap_fast_completion_status = in_imported_PAC_filename->set_copy_of_buffer(filenamePtr8.Ptr(), filenamePtr8.Size()); |
|
9615 |
|
9616 |
|
9617 eap_variable_data_c IAP_reference(m_am_tools); |
|
9618 if (IAP_reference.get_is_valid() == false) |
|
9619 { |
|
9620 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
9621 return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error); |
|
9622 } |
|
9623 |
|
9624 u32_t reference[] = {1ul, 2ul}; |
|
9625 |
|
9626 if (IAP_reference.get_data_length() != 0) |
|
9627 m_eap_fast_completion_status = IAP_reference.set_copy_of_buffer(reference, sizeof(reference)); |
|
9628 else |
|
9629 m_eap_fast_completion_status = IAP_reference.set_copy_of_buffer(EAP_FAST_ZERO_REFERENCE, sizeof(EAP_FAST_ZERO_REFERENCE)); |
|
9630 |
|
9631 EAP_TRACE_DEBUG_SYMBIAN( |
|
9632 (_L("eap_am_type_tls_peap_symbian_c::ImportFilesL: Complete operation"))); |
|
9633 |
|
9634 if (m_eap_fast_completion_status != eap_status_ok) |
|
9635 { |
|
9636 if (readData != NULL) |
|
9637 { |
|
9638 CleanupStack::PopAndDestroy(readData); |
|
9639 } |
|
9640 CleanupStack::PopAndDestroy(5); // filename, buf2, group_reference8, Path, path8 |
|
9641 delete files; |
|
9642 return EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status); |
|
9643 } |
|
9644 else |
|
9645 { |
|
9646 m_eap_fast_completion_status = m_tls_application->add_imported_PAC_file( |
|
9647 &IAP_reference, |
|
9648 in_opt_group_reference_and_data, |
|
9649 in_imported_PAC_data, |
|
9650 in_imported_PAC_filename); |
|
9651 aSuccess = ETrue; |
|
9652 } |
|
9653 } |
|
9654 } |
|
9655 else |
|
9656 { |
|
9657 badFile = true; |
|
9658 } |
|
9659 } |
|
9660 } |
|
9661 else |
|
9662 { |
|
9663 EAP_TRACE_DEBUG_SYMBIAN( |
|
9664 (_L("eap_am_type_tls_peap_symbian_c::ImportFilesL: No Directory"))); |
|
9665 directoryExists = false; |
|
9666 } |
|
9667 |
|
9668 if (readData != NULL) |
|
9669 { |
|
9670 CleanupStack::PopAndDestroy(readData); |
|
9671 } |
|
9672 CleanupStack::PopAndDestroy(5); // Path, filename8, buf2, Path8, group_reference8 |
|
9673 |
|
9674 EAP_TRACE_DEBUG_SYMBIAN( |
|
9675 (_L("eap_am_type_tls_peap_symbian_c::ImportFilesL: Operation failed or Complete"))); |
|
9676 |
|
9677 delete files; |
|
9678 |
|
9679 if (m_eap_fast_completion_status != eap_status_pending_request || aSuccess == EFalse) |
|
9680 { |
|
9681 if(badFile == true || directoryEmpty == true || directoryExists == false) |
|
9682 { |
|
9683 if (aSuccess == EFalse) |
|
9684 m_eap_fast_completion_status = eap_status_ok; |
|
9685 m_eap_fast_completion_status = m_partner->set_timer( |
|
9686 this, |
|
9687 KHandleCompletePacstoreNokTimerID, |
|
9688 &m_eap_fast_completion_status, |
|
9689 1); |
|
9690 } |
|
9691 else |
|
9692 { |
|
9693 m_eap_fast_completion_status = m_partner->set_timer( |
|
9694 this, |
|
9695 KHandleCompletePacstoreOkTimerID, |
|
9696 &m_eap_fast_completion_status, |
|
9697 1); |
|
9698 } |
|
9699 } |
|
9700 EAP_TRACE_DEBUG_SYMBIAN( |
|
9701 (_L("eap_am_type_tls_peap_symbian_c::ImportFilesL - End"))); |
|
9702 |
|
9703 return m_eap_fast_completion_status; |
|
9704 } |
|
9705 |
|
9706 // ---------------------------------------------------------------------------- |
|
9707 eap_status_e eap_am_type_tls_peap_symbian_c::PasswordQueryL() |
|
9708 { |
|
9709 |
|
9710 EAP_TRACE_DEBUG_SYMBIAN( |
|
9711 (_L("eap_am_type_tls_peap_symbian_c::PasswordQueryL"))); |
|
9712 |
|
9713 m_pacStorePWBuf8 = HBufC8::NewLC(m_userResponse.get_data_length()); |
|
9714 TPtr8 pacStorePWPtr8 = m_pacStorePWBuf8->Des(); |
|
9715 pacStorePWPtr8.Copy(m_userResponse.get_data(),m_userResponse.get_data_length() ); |
|
9716 m_PAC_store_password.set_copy_of_buffer(m_userResponse.get_data(), m_userResponse.get_data_length()); |
|
9717 EAP_TRACE_DATA_DEBUG_SYMBIAN( |
|
9718 ("eap_am_type_tls_peap_symbian_c::PasswordQueryL:PW used for masterkey verification (8bits)", |
|
9719 pacStorePWPtr8.Ptr(), |
|
9720 pacStorePWPtr8.Size())); |
|
9721 |
|
9722 |
|
9723 if (iPacStoreDb->IsMasterKeyPresentL() && pacStorePWPtr8.Size()>0 ) |
|
9724 m_verificationStatus = iPacStoreDb->IsMasterKeyAndPasswordMatchingL(pacStorePWPtr8); |
|
9725 |
|
9726 if ((pacStorePWPtr8.Size()==0 && (m_state == EPasswordQuery || m_state == EMasterkeyQuery )) |
|
9727 || m_userAction == EEapFastNotifierUserActionCancel || m_state == EPasswordCancel) |
|
9728 { |
|
9729 m_verificationStatus = EFalse; |
|
9730 m_state = EPasswordCancel; |
|
9731 CleanupStack::PopAndDestroy(m_pacStorePWBuf8); |
|
9732 |
|
9733 m_eap_fast_completion_status = m_partner->set_timer( |
|
9734 this, |
|
9735 KHandleReadPacstoreTimerID, |
|
9736 &m_eap_fast_completion_status, |
|
9737 0); |
|
9738 return m_eap_fast_completion_status; |
|
9739 } |
|
9740 |
|
9741 EAP_TRACE_DEBUG( |
|
9742 m_am_tools, |
|
9743 TRACE_FLAGS_DEFAULT, |
|
9744 (EAPL("EAP-FAST:eap_am_type_tls_peap_symbian_c::PasswordQueryL:State:%d Prev_State:%d verificationstatus:%d"), |
|
9745 m_state, |
|
9746 m_prev_state, |
|
9747 m_verificationStatus)); |
|
9748 |
|
9749 eap_status_e m_eap_fast_completion_status(eap_status_ok); |
|
9750 |
|
9751 if (m_state == EPasswordQuery) |
|
9752 { |
|
9753 m_state = EWrongPassword; |
|
9754 |
|
9755 if(m_verificationStatus == EFalse) |
|
9756 { |
|
9757 CleanupStack::PopAndDestroy(m_pacStorePWBuf8); |
|
9758 |
|
9759 m_eap_fast_completion_status = ShowNotifierItemAndGetResponse( |
|
9760 EEapFastNotifierWrongPacStorePwNote, ETrue ); |
|
9761 return m_eap_fast_completion_status; |
|
9762 |
|
9763 } |
|
9764 else |
|
9765 { |
|
9766 m_eap_fast_completion_status = m_partner->set_timer( |
|
9767 this, |
|
9768 KHandleReadPacstoreTimerID, |
|
9769 &m_eap_fast_completion_status, |
|
9770 0); |
|
9771 |
|
9772 CleanupStack::PopAndDestroy(m_pacStorePWBuf8); |
|
9773 return m_eap_fast_completion_status; |
|
9774 } |
|
9775 } |
|
9776 if (m_state == EWrongPassword) |
|
9777 { |
|
9778 m_state = EPasswordQuery; |
|
9779 |
|
9780 EAP_TRACE_DEBUG( |
|
9781 m_am_tools, |
|
9782 TRACE_FLAGS_DEFAULT, |
|
9783 (EAPL("EAP-FAST:eap_am_type_tls_peap_symbian_c::PasswordQueryL (first pw ?):State:%d Prev_State:%d verificationstatus:%d"), |
|
9784 m_state, |
|
9785 m_prev_state, |
|
9786 m_verificationStatus)); |
|
9787 pacStorePWPtr8.Zero(); |
|
9788 if (m_verificationStatus == EFalse) |
|
9789 m_eap_fast_completion_status = ShowNotifierItemAndGetResponse( |
|
9790 EEapFastNotifierPacStorePwQuery, ETrue ); |
|
9791 else |
|
9792 m_eap_fast_completion_status = m_partner->set_timer( |
|
9793 this, |
|
9794 KHandleReadPacstoreTimerID, |
|
9795 &m_eap_fast_completion_status, |
|
9796 0); |
|
9797 |
|
9798 CleanupStack::PopAndDestroy(m_pacStorePWBuf8); |
|
9799 return m_eap_fast_completion_status; |
|
9800 } |
|
9801 |
|
9802 if (m_PAC_store_password.get_data_length()>0 && m_state == EMasterkeyQuery) |
|
9803 { |
|
9804 |
|
9805 if ( m_verificationStatus != EFalse) |
|
9806 { |
|
9807 EAP_TRACE_DEBUG_SYMBIAN( |
|
9808 (_L("eap_am_type_tls_peap_symbian_c::PasswordQueryL - EMasterkeyQuery - OK"))); |
|
9809 } |
|
9810 else // temporary before masterkey creation is done dynamically !!! |
|
9811 { |
|
9812 m_eap_fast_completion_status = ShowNotifierItemAndGetResponse( |
|
9813 EEapFastNotifierCreateMasterkeyQuery, ETrue ); |
|
9814 |
|
9815 } |
|
9816 } |
|
9817 |
|
9818 CleanupStack::PopAndDestroy(m_pacStorePWBuf8); |
|
9819 |
|
9820 return m_eap_fast_completion_status; |
|
9821 } |
|
9822 |
|
9823 eap_status_e eap_am_type_tls_peap_symbian_c::CompletePasswordQueryL() |
|
9824 { |
|
9825 |
|
9826 EAP_TRACE_DEBUG_SYMBIAN( |
|
9827 (_L("eap_am_type_tls_peap_symbian_c::CompletePasswordQueryL"))); |
|
9828 |
|
9829 // m_PAC_store_password should have the PW now. Proceed as normal case. |
|
9830 |
|
9831 eap_fast_pac_store_data_c * const new_data = new eap_fast_pac_store_data_c(m_am_tools); |
|
9832 |
|
9833 eap_automatic_variable_c<eap_fast_pac_store_data_c> automatic_new_data( |
|
9834 m_am_tools, new_data); |
|
9835 |
|
9836 if (new_data == 0) |
|
9837 { |
|
9838 m_eap_fast_completion_status = eap_status_allocation_error; |
|
9839 (void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status); |
|
9840 return m_eap_fast_completion_status; |
|
9841 } |
|
9842 //eap_pac_store_data_type_PAC_store_password |
|
9843 EAP_TRACE_DEBUG( |
|
9844 m_am_tools, |
|
9845 TRACE_FLAGS_DEFAULT, |
|
9846 (EAPL("EAP-FAST: eap_am_type_tls_peap_symbian_c::CompletePasswordQueryL()Datatype=%d"), |
|
9847 m_pacStoreDataRefType)); |
|
9848 |
|
9849 EAP_TRACE_DEBUG( |
|
9850 m_am_tools, |
|
9851 TRACE_FLAGS_DEFAULT, |
|
9852 (EAPL("EAP-FAST: eap_am_type_tls_peap_symbian_c::CompletePasswordQueryL()Reference=%d"), |
|
9853 m_data_reference.get_reference()->get_data(m_data_reference.get_reference()->get_data_length()))); |
|
9854 |
|
9855 EAP_TRACE_DEBUG( |
|
9856 m_am_tools, |
|
9857 TRACE_FLAGS_DEFAULT, |
|
9858 (EAPL("EAP-FAST: eap_am_type_tls_peap_symbian_c::CompletePasswordQueryL()Data=%d"), |
|
9859 m_PAC_store_password.get_data(m_PAC_store_password.get_data_length()))); |
|
9860 |
|
9861 new_data->set_type(eap_pac_store_data_type_PAC_store_password); //m_pacStoreDataRefType |
|
9862 |
|
9863 // Set the reference. |
|
9864 m_eap_fast_completion_status = new_data->get_writable_reference()->set_copy_of_buffer(m_data_reference.get_reference()); |
|
9865 if (m_eap_fast_completion_status != eap_status_ok) |
|
9866 { |
|
9867 (void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status); |
|
9868 return m_eap_fast_completion_status; |
|
9869 } |
|
9870 |
|
9871 if(m_PAC_store_password.get_data_length() >0) |
|
9872 m_eap_fast_completion_status = new_data->get_writable_data()->set_copy_of_buffer(&m_PAC_store_password); |
|
9873 if (m_eap_fast_completion_status != eap_status_ok) |
|
9874 { |
|
9875 (void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status); |
|
9876 return m_eap_fast_completion_status; |
|
9877 } |
|
9878 |
|
9879 automatic_new_data.do_not_free_variable(); |
|
9880 |
|
9881 m_eap_fast_completion_status = m_new_references_and_data_blocks.add_object(new_data, true); // m_ready_references_and_data_blocks |
|
9882 |
|
9883 if (m_eap_fast_completion_status != eap_status_ok) |
|
9884 { |
|
9885 (void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status); |
|
9886 |
|
9887 EAP_TRACE_DATA_DEBUG_SYMBIAN( |
|
9888 ("EAP-FAST: eap_am_type_tls_peap_symbian_c::CompletePasswordQueryL eap_pac_store_data_type_PAC_store_password - added data", |
|
9889 (new_data->get_data())->get_data((new_data->get_data())->get_data_length()), |
|
9890 (new_data->get_data())->get_data_length())); |
|
9891 return m_eap_fast_completion_status; |
|
9892 } |
|
9893 |
|
9894 m_both_completed++; |
|
9895 |
|
9896 return m_eap_fast_completion_status; |
|
9897 } |
|
9898 |
|
9899 eap_status_e eap_am_type_tls_peap_symbian_c::FinalCompleteReadPACStoreDataL(eap_status_e status) |
|
9900 { |
|
9901 EAP_TRACE_DEBUG_SYMBIAN( |
|
9902 (_L("eap_am_type_tls_peap_symbian_c::FinalCompleteReadPACStoreDataL"))); |
|
9903 if (status == eap_status_ok && (m_new_references_and_data_blocks.get_object_count()>0)) |
|
9904 { |
|
9905 for (u32_t ind = 0ul; ind < m_ready_references_array_index; ++ind) |
|
9906 { |
|
9907 eap_fast_pac_store_data_c * const new_data = new eap_fast_pac_store_data_c(m_am_tools); |
|
9908 |
|
9909 eap_automatic_variable_c<eap_fast_pac_store_data_c> automatic_new_data( |
|
9910 m_am_tools, new_data); |
|
9911 |
|
9912 if (new_data == 0) |
|
9913 { |
|
9914 m_eap_fast_completion_status = eap_status_allocation_error; |
|
9915 (void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status); |
|
9916 |
|
9917 EAP_TRACE_DEBUG_SYMBIAN( |
|
9918 (_L("eap_am_type_tls_peap_symbian_c::FinalCompleteReadPACStoreDataL:status nok"))); |
|
9919 m_ready_references_and_data_blocks.reset(); |
|
9920 eap_status_e status = m_tls_application->complete_read_PAC_store_data( |
|
9921 m_eap_fast_completion_status, |
|
9922 m_eap_fast_pac_store_pending_operation, |
|
9923 &m_references_and_data_blocks); |
|
9924 |
|
9925 return status; |
|
9926 } |
|
9927 |
|
9928 new_data->set_type(m_references_and_data_blocks.get_object(ind)->get_type()); |
|
9929 |
|
9930 // Set the reference. |
|
9931 m_eap_fast_completion_status = new_data->get_writable_reference()->set_copy_of_buffer(m_references_and_data_blocks.get_object(ind)->get_reference()); |
|
9932 if (m_eap_fast_completion_status != eap_status_ok) |
|
9933 { |
|
9934 (void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status); |
|
9935 EAP_TRACE_DEBUG_SYMBIAN( |
|
9936 (_L("eap_am_type_tls_peap_symbian_c::FinalCompleteReadPACStoreDataL:status nok"))); |
|
9937 m_ready_references_and_data_blocks.reset(); |
|
9938 eap_status_e status = m_tls_application->complete_read_PAC_store_data( |
|
9939 m_eap_fast_completion_status, |
|
9940 m_eap_fast_pac_store_pending_operation, |
|
9941 &m_references_and_data_blocks); |
|
9942 |
|
9943 return status; |
|
9944 } |
|
9945 |
|
9946 m_eap_fast_completion_status = new_data->get_writable_data()->set_copy_of_buffer(m_references_and_data_blocks.get_object(ind)->get_data()); |
|
9947 if (m_eap_fast_completion_status != eap_status_ok) |
|
9948 { |
|
9949 (void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status); |
|
9950 EAP_TRACE_DEBUG_SYMBIAN( |
|
9951 (_L("eap_am_type_tls_peap_symbian_c::FinalCompleteReadPACStoreDataL:status nok"))); |
|
9952 m_ready_references_and_data_blocks.reset(); |
|
9953 eap_status_e status = m_tls_application->complete_read_PAC_store_data( |
|
9954 m_eap_fast_completion_status, |
|
9955 m_eap_fast_pac_store_pending_operation, |
|
9956 &m_references_and_data_blocks); |
|
9957 |
|
9958 return status; |
|
9959 } |
|
9960 |
|
9961 automatic_new_data.do_not_free_variable(); |
|
9962 |
|
9963 m_eap_fast_completion_status = m_ready_references_and_data_blocks.add_object(new_data, true); |
|
9964 if (m_eap_fast_completion_status != eap_status_ok) |
|
9965 { |
|
9966 (void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status); |
|
9967 EAP_TRACE_DEBUG_SYMBIAN( |
|
9968 (_L("eap_am_type_tls_peap_symbian_c::FinalCompleteReadPACStoreDataL:status nok"))); |
|
9969 m_ready_references_and_data_blocks.reset(); |
|
9970 eap_status_e status = m_tls_application->complete_read_PAC_store_data( |
|
9971 m_eap_fast_completion_status, |
|
9972 m_eap_fast_pac_store_pending_operation, |
|
9973 &m_references_and_data_blocks); |
|
9974 |
|
9975 return status; |
|
9976 } |
|
9977 |
|
9978 EAP_TRACE_DATA_DEBUG_SYMBIAN( |
|
9979 ("Final_complete_read_PAC_store_data - added original data", |
|
9980 (new_data->get_data())->get_data((new_data->get_data())->get_data_length()), |
|
9981 (new_data->get_data())->get_data_length())); |
|
9982 |
|
9983 } |
|
9984 |
|
9985 eap_fast_pac_store_data_c * const new_data = new eap_fast_pac_store_data_c(m_am_tools); |
|
9986 |
|
9987 eap_automatic_variable_c<eap_fast_pac_store_data_c> automatic_new_data( |
|
9988 m_am_tools, new_data); |
|
9989 |
|
9990 if (new_data == 0) |
|
9991 { |
|
9992 m_eap_fast_completion_status = eap_status_allocation_error; |
|
9993 (void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status); |
|
9994 EAP_TRACE_DEBUG_SYMBIAN( |
|
9995 (_L("eap_am_type_tls_peap_symbian_c::FinalCompleteReadPACStoreDataL:status nok"))); |
|
9996 m_ready_references_and_data_blocks.reset(); |
|
9997 eap_status_e status = m_tls_application->complete_read_PAC_store_data( |
|
9998 m_eap_fast_completion_status, |
|
9999 m_eap_fast_pac_store_pending_operation, |
|
10000 &m_references_and_data_blocks); |
|
10001 |
|
10002 return status; |
|
10003 } |
|
10004 |
|
10005 new_data->set_type(m_new_references_and_data_blocks.get_object(m_ready_references_array_index)->get_type()); |
|
10006 |
|
10007 // Set the reference. |
|
10008 m_eap_fast_completion_status = new_data->get_writable_reference()->set_copy_of_buffer(m_new_references_and_data_blocks.get_object(m_ready_references_array_index)->get_reference()); |
|
10009 if (m_eap_fast_completion_status != eap_status_ok) |
|
10010 { |
|
10011 (void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status); |
|
10012 EAP_TRACE_DEBUG_SYMBIAN( |
|
10013 (_L("eap_am_type_tls_peap_symbian_c::FinalCompleteReadPACStoreDataL:status nok"))); |
|
10014 m_ready_references_and_data_blocks.reset(); |
|
10015 eap_status_e status = m_tls_application->complete_read_PAC_store_data( |
|
10016 m_eap_fast_completion_status, |
|
10017 m_eap_fast_pac_store_pending_operation, |
|
10018 &m_references_and_data_blocks); |
|
10019 |
|
10020 return status; |
|
10021 } |
|
10022 |
|
10023 m_eap_fast_completion_status = new_data->get_writable_data()->set_copy_of_buffer(m_new_references_and_data_blocks.get_object(m_ready_references_array_index)->get_data()); |
|
10024 if (m_eap_fast_completion_status != eap_status_ok) |
|
10025 { |
|
10026 (void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status); |
|
10027 EAP_TRACE_DEBUG_SYMBIAN( |
|
10028 (_L("eap_am_type_tls_peap_symbian_c::FinalCompleteReadPACStoreDataL:status nok"))); |
|
10029 m_ready_references_and_data_blocks.reset(); |
|
10030 eap_status_e status = m_tls_application->complete_read_PAC_store_data( |
|
10031 m_eap_fast_completion_status, |
|
10032 m_eap_fast_pac_store_pending_operation, |
|
10033 &m_references_and_data_blocks); |
|
10034 |
|
10035 return status; |
|
10036 } |
|
10037 |
|
10038 automatic_new_data.do_not_free_variable(); |
|
10039 |
|
10040 m_eap_fast_completion_status = m_ready_references_and_data_blocks.add_object(new_data, true); |
|
10041 if (m_eap_fast_completion_status != eap_status_ok) |
|
10042 { |
|
10043 (void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status); |
|
10044 EAP_TRACE_DEBUG_SYMBIAN( |
|
10045 (_L("eap_am_type_tls_peap_symbian_c::FinalCompleteReadPACStoreDataL:status nok"))); |
|
10046 m_ready_references_and_data_blocks.reset(); |
|
10047 eap_status_e status = m_tls_application->complete_read_PAC_store_data( |
|
10048 m_eap_fast_completion_status, |
|
10049 m_eap_fast_pac_store_pending_operation, |
|
10050 &m_references_and_data_blocks); |
|
10051 |
|
10052 return status; |
|
10053 } |
|
10054 |
|
10055 EAP_TRACE_DATA_DEBUG_SYMBIAN( |
|
10056 ("eap_am_type_tls_peap_symbian_c::FinalCompleteReadPACStoreDataL - added extra data", |
|
10057 (new_data->get_data())->get_data((new_data->get_data())->get_data_length()), |
|
10058 (new_data->get_data())->get_data_length())); |
|
10059 |
|
10060 |
|
10061 for (u32_t ind = m_ready_references_array_index; ind < m_references_and_data_blocks.get_object_count(); ++ind) |
|
10062 { |
|
10063 eap_fast_pac_store_data_c * const new_data = new eap_fast_pac_store_data_c(m_am_tools); |
|
10064 |
|
10065 eap_automatic_variable_c<eap_fast_pac_store_data_c> automatic_new_data( |
|
10066 m_am_tools, new_data); |
|
10067 |
|
10068 if (new_data == 0) |
|
10069 { |
|
10070 m_eap_fast_completion_status = eap_status_allocation_error; |
|
10071 (void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status); |
|
10072 EAP_TRACE_DEBUG_SYMBIAN( |
|
10073 (_L("eap_am_type_tls_peap_symbian_c::FinalCompleteReadPACStoreDataL:status nok"))); |
|
10074 m_ready_references_and_data_blocks.reset(); |
|
10075 eap_status_e status = m_tls_application->complete_read_PAC_store_data( |
|
10076 m_eap_fast_completion_status, |
|
10077 m_eap_fast_pac_store_pending_operation, |
|
10078 &m_references_and_data_blocks); |
|
10079 |
|
10080 return status; |
|
10081 } |
|
10082 |
|
10083 new_data->set_type(m_references_and_data_blocks.get_object(ind)->get_type()); |
|
10084 |
|
10085 // Set the reference. |
|
10086 m_eap_fast_completion_status = new_data->get_writable_reference()->set_copy_of_buffer(m_references_and_data_blocks.get_object(ind)->get_reference()); |
|
10087 if (m_eap_fast_completion_status != eap_status_ok) |
|
10088 { |
|
10089 (void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status); |
|
10090 EAP_TRACE_DEBUG_SYMBIAN( |
|
10091 (_L("eap_am_type_tls_peap_symbian_c::FinalCompleteReadPACStoreDataL:status nok"))); |
|
10092 m_ready_references_and_data_blocks.reset(); |
|
10093 eap_status_e status = m_tls_application->complete_read_PAC_store_data( |
|
10094 m_eap_fast_completion_status, |
|
10095 m_eap_fast_pac_store_pending_operation, |
|
10096 &m_references_and_data_blocks); |
|
10097 |
|
10098 return status; |
|
10099 } |
|
10100 |
|
10101 m_eap_fast_completion_status = new_data->get_writable_data()->set_copy_of_buffer(m_references_and_data_blocks.get_object(ind)->get_data()); |
|
10102 if (m_eap_fast_completion_status != eap_status_ok) |
|
10103 { |
|
10104 (void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status); |
|
10105 EAP_TRACE_DEBUG_SYMBIAN( |
|
10106 (_L("eap_am_type_tls_peap_symbian_c::FinalCompleteReadPACStoreDataL:status nok"))); |
|
10107 m_ready_references_and_data_blocks.reset(); |
|
10108 eap_status_e status = m_tls_application->complete_read_PAC_store_data( |
|
10109 m_eap_fast_completion_status, |
|
10110 m_eap_fast_pac_store_pending_operation, |
|
10111 &m_references_and_data_blocks); |
|
10112 |
|
10113 return status; |
|
10114 } |
|
10115 |
|
10116 automatic_new_data.do_not_free_variable(); |
|
10117 |
|
10118 m_eap_fast_completion_status = m_ready_references_and_data_blocks.add_object(new_data, true); |
|
10119 if (m_eap_fast_completion_status != eap_status_ok) |
|
10120 { |
|
10121 (void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status); |
|
10122 EAP_TRACE_DEBUG_SYMBIAN( |
|
10123 (_L("eap_am_type_tls_peap_symbian_c::FinalCompleteReadPACStoreDataL:status nok"))); |
|
10124 m_ready_references_and_data_blocks.reset(); |
|
10125 eap_status_e status = m_tls_application->complete_read_PAC_store_data( |
|
10126 m_eap_fast_completion_status, |
|
10127 m_eap_fast_pac_store_pending_operation, |
|
10128 &m_references_and_data_blocks); |
|
10129 |
|
10130 return status; |
|
10131 } |
|
10132 |
|
10133 EAP_TRACE_DATA_DEBUG_SYMBIAN( |
|
10134 ("Final_complete_read_PAC_store_data - added original data", |
|
10135 (new_data->get_data())->get_data((new_data->get_data())->get_data_length()), |
|
10136 (new_data->get_data())->get_data_length())); |
|
10137 } |
|
10138 |
|
10139 if (status == eap_status_ok) |
|
10140 { |
|
10141 EAP_TRACE_DEBUG( |
|
10142 m_am_tools, |
|
10143 TRACE_FLAGS_DEFAULT, |
|
10144 (EAPL("EAP-FAST: eap_am_type_tls_peap_symbian_c::FinalCompleteReadPACStoreDataL: index=%d, original objects=%d, new=%d total=%d"), |
|
10145 m_ready_references_array_index, |
|
10146 m_references_and_data_blocks.get_object_count(), |
|
10147 m_new_references_and_data_blocks.get_object_count(), |
|
10148 m_ready_references_and_data_blocks.get_object_count())); |
|
10149 |
|
10150 |
|
10151 EAP_TRACE_DEBUG_SYMBIAN( |
|
10152 (_L("eap_am_type_tls_peap_symbian_c::FinalCompleteReadPACStoreDataL Reset unsent data"))); |
|
10153 |
|
10154 m_references_and_data_blocks.reset(); |
|
10155 m_new_references_and_data_blocks.reset(); |
|
10156 |
|
10157 EAP_TRACE_DEBUG_SYMBIAN( |
|
10158 (_L("eap_am_type_tls_peap_symbian_c::FinalCompleteReadPACStoreDataL Reset Done"))); |
|
10159 |
|
10160 eap_status_e status = m_tls_application->complete_read_PAC_store_data( |
|
10161 m_eap_fast_completion_status, |
|
10162 m_eap_fast_pac_store_pending_operation, |
|
10163 &m_ready_references_and_data_blocks); |
|
10164 } |
|
10165 else |
|
10166 { |
|
10167 EAP_TRACE_DEBUG_SYMBIAN( |
|
10168 (_L("eap_am_type_tls_peap_symbian_c::FinalCompleteReadPACStoreDataL:status nok"))); |
|
10169 m_eap_fast_completion_status = eap_status_user_cancel_authentication; |
|
10170 m_new_references_and_data_blocks.reset(); |
|
10171 m_ready_references_and_data_blocks.reset(); |
|
10172 eap_status_e status = m_tls_application->complete_read_PAC_store_data( |
|
10173 m_eap_fast_completion_status, |
|
10174 m_eap_fast_pac_store_pending_operation, |
|
10175 &m_references_and_data_blocks); |
|
10176 } |
|
10177 } |
|
10178 else |
|
10179 { |
|
10180 EAP_TRACE_DEBUG_SYMBIAN( |
|
10181 (_L("eap_am_type_tls_peap_symbian_c::FinalCompleteReadPACStoreDataL:status nok"))); |
|
10182 m_eap_fast_completion_status = eap_status_user_cancel_authentication; |
|
10183 m_new_references_and_data_blocks.reset(); |
|
10184 m_ready_references_and_data_blocks.reset(); |
|
10185 eap_status_e status = m_tls_application->complete_read_PAC_store_data( |
|
10186 m_eap_fast_completion_status, |
|
10187 m_eap_fast_pac_store_pending_operation, |
|
10188 &m_references_and_data_blocks); |
|
10189 } |
|
10190 |
|
10191 TRAPD(error, UpdatePasswordTimeL()); |
|
10192 |
|
10193 if(error != KErrNone) |
|
10194 { |
|
10195 EAP_TRACE_DEBUG( |
|
10196 m_am_tools, |
|
10197 TRACE_FLAGS_DEFAULT, |
|
10198 (EAPL("EAP-FAST: eap_am_type_tls_peap_symbian_c::FinalCompleteReadPACStoreDataL ERROR: LEAVE from UpdatePasswordTimeL() error=%d"), |
|
10199 error)); |
|
10200 } |
|
10201 return status; |
|
10202 } |
|
10203 |
|
10204 //-------------------------------------------------- |
|
10205 |
|
10206 eap_status_e eap_am_type_tls_peap_symbian_c::CompleteFilePasswordQueryL() |
|
10207 { |
|
10208 eap_fast_pac_store_data_c * const new_data = new eap_fast_pac_store_data_c(m_am_tools); |
|
10209 |
|
10210 eap_automatic_variable_c<eap_fast_pac_store_data_c> automatic_new_data( |
|
10211 m_am_tools, new_data); |
|
10212 |
|
10213 if (new_data == 0) |
|
10214 { |
|
10215 m_eap_fast_completion_status = eap_status_allocation_error; |
|
10216 (void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status); |
|
10217 return m_eap_fast_completion_status; |
|
10218 } |
|
10219 |
|
10220 |
|
10221 EAP_TRACE_DEBUG( |
|
10222 m_am_tools, |
|
10223 TRACE_FLAGS_DEFAULT, |
|
10224 (EAPL("EAP-FAST: eap_am_type_tls_peap_symbian_c::CompleteFilePasswordQueryL()Datatype=%d"), |
|
10225 m_pacStoreDataRefType)); |
|
10226 |
|
10227 new_data->set_type(eap_pac_store_data_type_PAC_file_password); //m_pacStoreDataRefType |
|
10228 |
|
10229 EAP_TRACE_DEBUG( |
|
10230 m_am_tools, |
|
10231 TRACE_FLAGS_DEFAULT, |
|
10232 (EAPL("EAP-FAST: eap_am_type_tls_peap_symbian_c::CompleteFilePasswordQueryL()Reference=%d"), |
|
10233 m_data_reference.get_reference()->get_data(m_data_reference.get_reference()->get_data_length()))); |
|
10234 |
|
10235 // Set the reference. |
|
10236 m_eap_fast_completion_status = new_data->get_writable_reference()->set_copy_of_buffer(m_data_reference.get_reference()); |
|
10237 |
|
10238 if (m_eap_fast_completion_status != eap_status_ok) |
|
10239 { |
|
10240 (void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status); |
|
10241 return m_eap_fast_completion_status; |
|
10242 } |
|
10243 m_eap_fast_completion_status = new_data->get_writable_data()->set_copy_of_buffer(&m_userResponse); |
|
10244 |
|
10245 if (m_eap_fast_completion_status != eap_status_ok) |
|
10246 { |
|
10247 (void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status); |
|
10248 return m_eap_fast_completion_status; |
|
10249 } |
|
10250 |
|
10251 automatic_new_data.do_not_free_variable(); |
|
10252 |
|
10253 |
|
10254 m_eap_fast_completion_status = m_new_references_and_data_blocks.add_object(new_data, true); // m_ready_references_and_data_blocks |
|
10255 if (m_eap_fast_completion_status != eap_status_ok) |
|
10256 { |
|
10257 (void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status); |
|
10258 return m_eap_fast_completion_status; |
|
10259 } |
|
10260 |
|
10261 EAP_TRACE_DATA_DEBUG_SYMBIAN( |
|
10262 ("EAP-FAST: eap_am_type_tls_peap_symbian_c::CompleteFilePasswordQueryL eap_pac_store_data_type_PAC_file_password - added data", |
|
10263 (new_data->get_data())->get_data((new_data->get_data())->get_data_length()), |
|
10264 (new_data->get_data())->get_data_length())); |
|
10265 |
|
10266 m_both_completed++; |
|
10267 return m_eap_fast_completion_status; |
|
10268 |
|
10269 } |
|
10270 |
|
10271 // --------------------------------------------------------- |
|
10272 // eap_am_type_tls_peap_symbian_c::CompleteNotifier |
|
10273 // --------------------------------------------------------- |
|
10274 // |
|
10275 eap_status_e eap_am_type_tls_peap_symbian_c::CompleteNotifierL() |
|
10276 { |
|
10277 eap_status_e status( eap_status_ok ); |
|
10278 switch ( m_state ) |
|
10279 { |
|
10280 case EPasswordCancel: |
|
10281 case EPasswordQuery: |
|
10282 case EWrongPassword: |
|
10283 case EFilePasswordQuery: |
|
10284 case EMasterkeyQuery: |
|
10285 { |
|
10286 EAP_TRACE_DEBUG_SYMBIAN( |
|
10287 (_L("m_notifier_data_pckg_from_user"), |
|
10288 m_notifier_data_pckg_from_user->Ptr(), |
|
10289 m_notifier_data_pckg_from_user->Size())); |
|
10290 if ( iStatus.Int() == KErrCancel ) |
|
10291 { |
|
10292 EAP_TRACE_DEBUG_SYMBIAN( |
|
10293 (_L("eap_am_type_tls_peap_symbian_c::CompleteNotifierL - User cancelled the notifier item"))); |
|
10294 m_userAction = EEapFastNotifierUserActionCancel; |
|
10295 } |
|
10296 else if( iStatus.Int() != KErrNone ) |
|
10297 { |
|
10298 EAP_TRACE_DEBUG_SYMBIAN( |
|
10299 (_L("eap_am_type_tls_peap_symbian_c::CompleteNotifierL - ERROR: Notifier error=%d"), |
|
10300 iStatus.Int())); |
|
10301 return m_am_tools->convert_am_error_to_eapol_error(iStatus.Int()); |
|
10302 } |
|
10303 EAP_TRACE_DEBUG_SYMBIAN( |
|
10304 (_L("CompleteNotifierL - Notifier return UiItem=%d, UserAction=%d"), |
|
10305 m_notifier_data_from_user->iEapFastNotifierUiItem, |
|
10306 m_notifier_data_from_user->iEapFastNotifierUserAction)); |
|
10307 |
|
10308 EAP_TRACE_DATA_DEBUG_SYMBIAN( |
|
10309 ("CompleteNotifierL:UserInput:", |
|
10310 m_notifier_data_from_user->iEapFastNotifierBuffer.Ptr(), |
|
10311 m_notifier_data_from_user->iEapFastNotifierBuffer.Size())); |
|
10312 |
|
10313 if ( m_notifier_data_from_user->iEapFastNotifierBuffer.Size() > 0 ) |
|
10314 { |
|
10315 HBufC8* notifier_data8 = HBufC8::NewLC(m_notifier_data_from_user->iEapFastNotifierBuffer.Size()); |
|
10316 TPtr8 notifier_dataPtr8 = notifier_data8->Des(); |
|
10317 |
|
10318 notifier_dataPtr8.Copy(m_notifier_data_from_user->iEapFastNotifierBuffer); // Unicode -> ascii. |
|
10319 EAP_TRACE_DEBUG_SYMBIAN( |
|
10320 (_L("eap_am_type_tls_peap_symbian_c::CompleteNotifierL ShowNotifierItem - Data copy done"))); |
|
10321 |
|
10322 EAP_TRACE_DATA_DEBUG_SYMBIAN( |
|
10323 ("eap_am_type_tls_peap_symbian_c::CompleteNotifierL ShowNotifierItem:PW from UI (8bits)", |
|
10324 notifier_dataPtr8.Ptr(), |
|
10325 notifier_dataPtr8.Size())); |
|
10326 |
|
10327 status = m_userResponse.set_copy_of_buffer( |
|
10328 notifier_dataPtr8.Ptr(), |
|
10329 notifier_dataPtr8.Size()); |
|
10330 |
|
10331 CleanupStack::PopAndDestroy( notifier_data8 ); |
|
10332 } |
|
10333 break; |
|
10334 } |
|
10335 default: |
|
10336 { |
|
10337 EAP_TRACE_DEBUG_SYMBIAN( |
|
10338 ( _L( "eap_am_type_tls_peap_symbian_c::CompleteNotifierL() m_state = %d not supported." ), |
|
10339 m_state ) ); |
|
10340 } |
|
10341 } |
|
10342 return status; |
|
10343 } |
|
10344 |
|
10345 //-------------------------------------------------- |
|
10346 |
|
10347 void eap_am_type_tls_peap_symbian_c::ConvertUnicodeToAsciiL(const TDesC16& aFromUnicode, TDes8& aToAscii) |
|
10348 { |
|
10349 EAP_TRACE_DATA_DEBUG_SYMBIAN( |
|
10350 ("eap_am_type_tls_peap_symbian_c::ConvertUnicodeToAsciiL:From TEXT", |
|
10351 aFromUnicode.Ptr(), |
|
10352 aFromUnicode.Size())); |
|
10353 |
|
10354 if(aFromUnicode.Length() <= 0) |
|
10355 { |
|
10356 EAP_TRACE_DEBUG_SYMBIAN( |
|
10357 (_L("eap_am_type_tls_peap_symbian_c::ConvertUnicodeToAsciiL: Return: NOTHING TO CONVERT"))); |
|
10358 |
|
10359 return; |
|
10360 } |
|
10361 |
|
10362 EAP_TRACE_DEBUG_SYMBIAN( |
|
10363 (_L("eap_am_type_tls_peap_symbian_c::ConvertUnicodeToAsciiL, aFromUnicode.Length=%d, aFromUnicode.Size=%d"), |
|
10364 aFromUnicode.Length(), aFromUnicode.Size())); |
|
10365 |
|
10366 // Convert from Unicode to ascii. |
|
10367 HBufC8* aFromUnicodeBuf8 = HBufC8::NewLC(aFromUnicode.Length()); // Half times size of source (or length) is enough here. |
|
10368 TPtr8 aFromUnicodePtr8 = aFromUnicodeBuf8->Des(); |
|
10369 |
|
10370 EAP_TRACE_DEBUG_SYMBIAN( |
|
10371 (_L("eap_am_type_tls_peap_symbian_c::ConvertUnicodeToAsciiL, aFromUnicodePtr8.Length=%d, aFromUnicodePtr8.Size=%d, aFromUnicodePtr8.MaxLength=%d, aFromUnicodePtr8.MaxSize=%d"), |
|
10372 aFromUnicodePtr8.Length(), aFromUnicodePtr8.Size(), aFromUnicodePtr8.MaxLength(), aFromUnicodePtr8.MaxSize())); |
|
10373 |
|
10374 aFromUnicodePtr8.Copy(aFromUnicode); // Unicode -> ascii. |
|
10375 |
|
10376 aToAscii = aFromUnicodePtr8; |
|
10377 |
|
10378 CleanupStack::PopAndDestroy(aFromUnicodeBuf8); // Delete aFromUnicodeBuf8. |
|
10379 |
|
10380 EAP_TRACE_DATA_DEBUG_SYMBIAN( |
|
10381 ("eap_am_type_tls_peap_symbian_c::ConvertUnicodeToAsciiL:To ASCII", |
|
10382 aToAscii.Ptr(), |
|
10383 aToAscii.Size())); |
|
10384 } |
|
10385 |
|
10386 |
|
10387 // --------------------------------------------------------- |
|
10388 // eap_am_type_tls_peap_symbian_c::CheckPasswordTimeValidityL() |
|
10389 // --------------------------------------------------------- |
|
10390 // |
|
10391 void eap_am_type_tls_peap_symbian_c::CheckPasswordTimeValidityL() |
|
10392 { |
|
10393 /* Check validity of password against timelimit */ |
|
10394 |
|
10395 EAP_TRACE_DEBUG(m_am_tools, |
|
10396 TRACE_FLAGS_DEFAULT, ( |
|
10397 EAPL("CheckPasswordTimeValidityL - Start\n"))); |
|
10398 |
|
10399 TInt64 maxSessionTime = 0; |
|
10400 TInt64 fullAuthTime = 0; |
|
10401 |
|
10402 // get max session time |
|
10403 HBufC* buf = HBufC::NewLC( KMaxSqlQueryLength ); |
|
10404 TPtr sqlStatement = buf->Des(); |
|
10405 _LIT( KSqlQuery, "SELECT %S FROM %S WHERE %S=%d AND %S=%d AND %S=%d" ); |
|
10406 sqlStatement.Format( |
|
10407 KSqlQuery, |
|
10408 &cf_str_EAP_FAST_max_session_validity_time_literal, |
|
10409 &KFastGeneralSettingsDBTableName, |
|
10410 &KServiceType, m_index_type, |
|
10411 &KServiceIndex, m_index, |
|
10412 &KTunnelingType, m_tunneling_vendor_type ); |
|
10413 TRAPD( err, maxSessionTime = ReadIntDbValueL( |
|
10414 m_database, |
|
10415 cf_str_EAP_FAST_max_session_validity_time_literal, |
|
10416 sqlStatement ) ); |
|
10417 if ( err != KErrNone ) |
|
10418 { |
|
10419 EAP_TRACE_DEBUG( m_am_tools, TRACE_FLAGS_DEFAULT, |
|
10420 ( EAPL( "ERROR: Leave happened trying to read max session time, \ |
|
10421 error=%d.\n" ), err ) ); |
|
10422 } |
|
10423 EAP_TRACE_DEBUG( m_am_tools, TRACE_FLAGS_DEFAULT, ( |
|
10424 EAPL("CheckPasswordTimeValidityL - maxSessionTime=%ld\n"), |
|
10425 maxSessionTime ) ); |
|
10426 |
|
10427 #ifdef USE_PAC_STORE |
|
10428 sqlStatement.Zero(); |
|
10429 if ( !iPacStoreDb ) |
|
10430 { |
|
10431 EAP_TRACE_DEBUG( m_am_tools, TRACE_FLAGS_DEFAULT, ( |
|
10432 EAPL("CheckPasswordTimeValidityL - iPacStoreDb is NULL.\n"))); |
|
10433 CleanupStack::PopAndDestroy( buf ); // Delete buf. |
|
10434 User::Leave( KErrArgument ); |
|
10435 } |
|
10436 _LIT( KSqlQuery1, "SELECT %S FROM %S" ); |
|
10437 sqlStatement.Format( |
|
10438 KSqlQuery1, |
|
10439 &KFASTLastPasswordIdentityTime, |
|
10440 &KPacStoreGeneralSettingsTableName ); |
|
10441 RDbNamedDatabase& db = iPacStoreDb->GetPacStoreDb(); |
|
10442 TRAP( err, fullAuthTime = ReadIntDbValueL( |
|
10443 db, |
|
10444 KFASTLastPasswordIdentityTime, |
|
10445 sqlStatement ) ); |
|
10446 if ( err == KErrNotFound ) // KFASTLastPasswordIdentityTime was not found |
|
10447 { |
|
10448 TRAP( err, FixOldTablesForPwdIdentityTimeL() ); |
|
10449 if ( err != KErrNone ) |
|
10450 { |
|
10451 EAP_TRACE_DEBUG( m_am_tools, TRACE_FLAGS_DEFAULT, ( EAPL( |
|
10452 "ERROR: eap_am_type_tls_peap_symbian_c::CheckPasswordTimeValidityL() \ |
|
10453 Leave happened trying to fix old table for pwd \ |
|
10454 identity time, error=%d.\n" ), err ) ); |
|
10455 User::Leave( err ); |
|
10456 } |
|
10457 TRAP( err, fullAuthTime = ReadIntDbValueL( |
|
10458 db, |
|
10459 KFASTLastPasswordIdentityTime, |
|
10460 sqlStatement ) ); |
|
10461 if ( err != KErrNone ) |
|
10462 { |
|
10463 EAP_TRACE_DEBUG( m_am_tools, TRACE_FLAGS_DEFAULT, ( EAPL( |
|
10464 "ERROR: eap_am_type_tls_peap_symbian_c::CheckPasswordTimeValidityL() \ |
|
10465 Leave happened trying to read full auth. time, \ |
|
10466 error=%d.\n" ), err ) ); |
|
10467 User::Leave( err ); |
|
10468 } |
|
10469 } |
|
10470 else if ( err != KErrNone ) |
|
10471 { |
|
10472 EAP_TRACE_DEBUG( m_am_tools, TRACE_FLAGS_DEFAULT, ( EAPL( |
|
10473 "ERROR: eap_am_type_tls_peap_symbian_c::CheckPasswordTimeValidityL() \ |
|
10474 Leave happened trying to read full auth. time, \ |
|
10475 error=%d.\n" ), err ) ); |
|
10476 User::Leave( err ); |
|
10477 } |
|
10478 #else |
|
10479 EAP_TRACE_DEBUG( m_am_tools, TRACE_FLAGS_DEFAULT, ( |
|
10480 EAPL("CheckPasswordTimeValidityL - PAC store is not used.\n"))); |
|
10481 CleanupStack::PopAndDestroy( buf ); // Delete buf. |
|
10482 User::Leave( KErrNotSupported ); |
|
10483 #endif |
|
10484 |
|
10485 EAP_TRACE_DEBUG( m_am_tools, TRACE_FLAGS_DEFAULT, |
|
10486 ( EAPL( "CheckPasswordTimeValidityL - fullAuthTime=%ld.\n" ), |
|
10487 fullAuthTime ) ); |
|
10488 |
|
10489 CleanupStack::PopAndDestroy( buf ); // Delete buf. |
|
10490 |
|
10491 // If the max session time from DB is zero then we use the |
|
10492 // one read from configuration file. |
|
10493 if( maxSessionTime == 0) |
|
10494 { |
|
10495 EAP_TRACE_DEBUG(m_am_tools, |
|
10496 TRACE_FLAGS_DEFAULT, ( |
|
10497 EAPL("CheckPasswordTimeValidityL - Using max session validity time from config file\n"))); |
|
10498 |
|
10499 maxSessionTime = m_max_session_time; // value from configuration file. |
|
10500 } |
|
10501 |
|
10502 // Get the current time. |
|
10503 EAP_TRACE_DEBUG(m_am_tools, |
|
10504 TRACE_FLAGS_DEFAULT, ( |
|
10505 EAPL("UpdatePasswordTimeL - Get time\n"))); |
|
10506 |
|
10507 TTime currentTime; |
|
10508 currentTime.UniversalTime(); |
|
10509 |
|
10510 TTime lastFullAuthTime(fullAuthTime); |
|
10511 |
|
10512 #if defined(_DEBUG) || defined(DEBUG) |
|
10513 |
|
10514 TDateTime currentDateTime = currentTime.DateTime(); |
|
10515 |
|
10516 TDateTime fullAuthDateTime = lastFullAuthTime.DateTime(); |
|
10517 |
|
10518 EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, |
|
10519 (EAPL("CheckPasswordTimeValidityL Session Validity - Current Time, %2d-%2d-%4d : %2d-%2d-%2d-%d\n"), |
|
10520 currentDateTime.Day()+1, currentDateTime.Month()+1, currentDateTime.Year(), currentDateTime.Hour(), |
|
10521 currentDateTime.Minute(), currentDateTime.Second(), currentDateTime.MicroSecond())); |
|
10522 |
|
10523 EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, |
|
10524 (EAPL("CheckPasswordTimeValidityL Session Validity - Last Full Auth Time, %2d-%2d-%4d : %2d-%2d-%2d-%d\n"), |
|
10525 fullAuthDateTime.Day()+1, fullAuthDateTime.Month()+1, fullAuthDateTime.Year(), fullAuthDateTime.Hour(), |
|
10526 fullAuthDateTime.Minute(), fullAuthDateTime.Second(), fullAuthDateTime.MicroSecond())); |
|
10527 |
|
10528 #endif |
|
10529 |
|
10530 TTimeIntervalMicroSeconds interval = currentTime.MicroSecondsFrom(lastFullAuthTime); |
|
10531 |
|
10532 EAP_TRACE_DATA_DEBUG( m_am_tools, TRACE_FLAGS_DEFAULT,(EAPL("eap_am_type_tls_peap_symbian_c::CheckPasswordTimeValidityL:interval in microseconds:"), |
|
10533 &(interval.Int64()), |
|
10534 sizeof(interval.Int64()) ) ); |
|
10535 |
|
10536 EAP_TRACE_DATA_DEBUG( m_am_tools, TRACE_FLAGS_DEFAULT,(EAPL("eap_am_type_tls_peap_symbian_c::CheckPasswordTimeValidityL:max session time in microseconds:"), |
|
10537 &(maxSessionTime), |
|
10538 sizeof(maxSessionTime) ) ); |
|
10539 |
|
10540 #if defined(_DEBUG) || defined(DEBUG) |
|
10541 |
|
10542 TTimeIntervalMinutes intervalMins; |
|
10543 TInt error = currentTime.MinutesFrom(lastFullAuthTime, intervalMins); |
|
10544 |
|
10545 if(error == KErrNone) |
|
10546 { |
|
10547 EAP_TRACE_DEBUG( |
|
10548 m_am_tools, |
|
10549 TRACE_FLAGS_DEFAULT, |
|
10550 (EAPL("eap_am_type_tls_peap_symbian_c::CheckPasswordTimeValidityL") |
|
10551 EAPL("interval in Minutes =%d\n"), |
|
10552 intervalMins.Int())); |
|
10553 } |
|
10554 |
|
10555 #endif |
|
10556 |
|
10557 if( maxSessionTime >= interval.Int64() ) |
|
10558 { |
|
10559 EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("eap_am_type_tls_peap_symbian_c::CheckPasswordTimeValidityL - Session Valid \n"))); |
|
10560 |
|
10561 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
10562 |
|
10563 /* do nothing */ |
|
10564 } |
|
10565 else |
|
10566 { |
|
10567 EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("eap_am_type_tls_peap_symbian_c::CheckPasswordTimeValidityL - Session NOT Valid \n"))); |
|
10568 |
|
10569 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
10570 |
|
10571 m_tls_application->remove_cached_pac_store_data(); |
|
10572 |
|
10573 TRAPD(error, UpdatePasswordTimeL()); |
|
10574 |
|
10575 if(error != KErrNone) |
|
10576 { |
|
10577 EAP_TRACE_DEBUG( |
|
10578 m_am_tools, |
|
10579 TRACE_FLAGS_DEFAULT, |
|
10580 (EAPL("EAP-FAST: eap_am_type_tls_peap_symbian_c::CheckPasswordTimeValidityL() ERROR: LEAVE from UpdatePasswordTimeL() error=%d"), |
|
10581 error)); |
|
10582 |
|
10583 } |
|
10584 } |
|
10585 |
|
10586 } // eap_am_type_tls_peap_symbian_c::CheckPasswordTimeValidityL() |
|
10587 |
|
10588 |
|
10589 // --------------------------------------------------------- |
|
10590 // eap_am_type_tls_peap_symbian_c::AlterTableL() |
|
10591 // --------------------------------------------------------- |
|
10592 // |
|
10593 void eap_am_type_tls_peap_symbian_c::AlterTableL( |
|
10594 RDbNamedDatabase& aDb, |
|
10595 TAlterTableCmd aCmd, |
|
10596 const TDesC& aTableName, |
|
10597 const TDesC& aColumnName, |
|
10598 const TDesC& aColumnDef ) |
|
10599 { |
|
10600 EAP_TRACE_DEBUG( m_am_tools, TRACE_FLAGS_DEFAULT, ( EAPL( |
|
10601 "eap_am_type_tls_peap_symbian_c::AlterTableL() IN\n" ) ) ); |
|
10602 |
|
10603 CDbColSet* colSet = aDb.ColSetL( aTableName ); |
|
10604 User::LeaveIfNull( colSet ); |
|
10605 CleanupStack::PushL( colSet ); |
|
10606 |
|
10607 EAP_TRACE_DEBUG_SYMBIAN( ( _L( |
|
10608 "eap_am_type_tls_peap_symbian_c::AlterTableL() \ |
|
10609 Number of columns in %S table is %d.\n" ), |
|
10610 &aTableName, colSet->Count() ) ); |
|
10611 |
|
10612 if ( aCmd == EAddColumn ) |
|
10613 { |
|
10614 // Check if there is a target column |
|
10615 if( colSet->ColNo( aColumnName ) != KDbNullColNo ) |
|
10616 { |
|
10617 EAP_TRACE_DEBUG_SYMBIAN( ( _L( |
|
10618 "eap_am_type_tls_peap_symbian_c::AlterTableL() \ |
|
10619 Column %S exists already in table %S.\n" ), |
|
10620 &aColumnName, &aTableName ) ); |
|
10621 CleanupStack::PopAndDestroy( colSet ); |
|
10622 return; |
|
10623 } |
|
10624 } |
|
10625 else |
|
10626 { |
|
10627 // Check if there is a target column |
|
10628 if( colSet->ColNo( aColumnName ) == KDbNullColNo ) |
|
10629 { |
|
10630 EAP_TRACE_DEBUG_SYMBIAN( ( _L( |
|
10631 "eap_am_type_tls_peap_symbian_c::AlterTableL() \ |
|
10632 Column %S does not exists already in table %S.\n" ), |
|
10633 &aColumnName, &aTableName ) ); |
|
10634 CleanupStack::PopAndDestroy( colSet ); |
|
10635 return; |
|
10636 } |
|
10637 } |
|
10638 |
|
10639 HBufC* buf = HBufC::NewLC( KMaxSqlQueryLength ); |
|
10640 TPtr sqlStatement = buf->Des(); |
|
10641 |
|
10642 _LIT( KSqlAddCol, "ALTER TABLE %S ADD %S %S" ); |
|
10643 _LIT( KSqlRemoveCol, "ALTER TABLE %S DROP %S" ); |
|
10644 |
|
10645 if ( aCmd == EAddColumn ) |
|
10646 { |
|
10647 sqlStatement.Format( KSqlAddCol, &aTableName, |
|
10648 &aColumnName, &aColumnDef ); |
|
10649 } |
|
10650 else |
|
10651 { |
|
10652 sqlStatement.Format( KSqlRemoveCol, &aTableName, |
|
10653 &aColumnName ); |
|
10654 } |
|
10655 |
|
10656 EAP_TRACE_DEBUG_SYMBIAN( ( _L( |
|
10657 "eap_am_type_tls_peap_symbian_c::AlterTableL(): sqlStatement=%S\n"), |
|
10658 &sqlStatement ) ); |
|
10659 |
|
10660 User::LeaveIfError( aDb.Execute( sqlStatement ) ); |
|
10661 CleanupStack::PopAndDestroy( buf ); |
|
10662 CleanupStack::PopAndDestroy( colSet ); |
|
10663 |
|
10664 CDbColSet* alteredColSet = aDb.ColSetL( aTableName ); |
|
10665 User::LeaveIfNull( alteredColSet ); |
|
10666 EAP_TRACE_DEBUG_SYMBIAN( ( _L( |
|
10667 "eap_am_type_tls_peap_symbian_c::AlterTableL() \ |
|
10668 Number of columns in %S table is %d.\n" ), |
|
10669 &aTableName, alteredColSet->Count() ) ); |
|
10670 delete alteredColSet; |
|
10671 |
|
10672 EAP_TRACE_DEBUG( m_am_tools, TRACE_FLAGS_DEFAULT, ( EAPL( |
|
10673 "eap_am_type_tls_peap_symbian_c::AlterTableL() OUT\n" ) ) ); |
|
10674 |
|
10675 } // eap_am_type_tls_peap_symbian_c::AlterTableL() |
|
10676 |
|
10677 |
|
10678 // --------------------------------------------------------- |
|
10679 // eap_am_type_tls_peap_symbian_c::FixOldTablesForPwdIdentityTimeL() |
|
10680 // --------------------------------------------------------- |
|
10681 // |
|
10682 void eap_am_type_tls_peap_symbian_c::FixOldTablesForPwdIdentityTimeL() |
|
10683 { |
|
10684 EAP_TRACE_DEBUG( m_am_tools, TRACE_FLAGS_DEFAULT, ( EAPL( |
|
10685 "eap_am_type_tls_peap_symbian_c::FixOldTablesForPwdIdentityTimeL() IN" ) ) ); |
|
10686 |
|
10687 // remove password identity time from fast table |
|
10688 _LIT( KColumnDef, "BIGINT" ); |
|
10689 AlterTableL( m_database, ERemoveColumn, KFastGeneralSettingsDBTableName, |
|
10690 KFASTLastPasswordIdentityTime ); |
|
10691 |
|
10692 // add password identity time to PAC store table |
|
10693 #ifdef USE_PAC_STORE |
|
10694 if ( !iPacStoreDb ) |
|
10695 { |
|
10696 EAP_TRACE_DEBUG( m_am_tools, TRACE_FLAGS_DEFAULT, ( EAPL( |
|
10697 "ERROR: eap_am_type_tls_peap_symbian_c::FixOldTablesForPwdIdentityTimeL() \ |
|
10698 iPacStoreDb is NULL.\n" ) ) ); |
|
10699 User::Leave( KErrArgument ); |
|
10700 } |
|
10701 RDbNamedDatabase& pacStoreDb = iPacStoreDb->GetPacStoreDb(); |
|
10702 AlterTableL( pacStoreDb, EAddColumn , KPacStoreGeneralSettingsTableName, |
|
10703 KFASTLastPasswordIdentityTime, KColumnDef ); |
|
10704 #else |
|
10705 EAP_TRACE_DEBUG( m_am_tools, TRACE_FLAGS_DEFAULT, ( EAPL( |
|
10706 "ERROR: eap_am_type_tls_peap_symbian_c::FixOldTablesForPwdIdentityTimeL() \ |
|
10707 PAC store is not used.\n" ) ) ); |
|
10708 User::Leave( KErrNotSupported ); |
|
10709 #endif |
|
10710 |
|
10711 // update password identity time |
|
10712 UpdatePasswordTimeL(); |
|
10713 EAP_TRACE_DEBUG( m_am_tools, TRACE_FLAGS_DEFAULT, ( EAPL( |
|
10714 "eap_am_type_tls_peap_symbian_c::FixOldTablesForPwdIdentityTimeL() OUT" ) ) ); |
|
10715 |
|
10716 } // eap_am_type_tls_peap_symbian_c::FixOldTablesForPwdIdentityTimeL() |
|
10717 |
|
10718 |
|
10719 // --------------------------------------------------------- |
|
10720 // eap_am_type_tls_peap_symbian_c::FixOldTableForPacStoreInitL() |
|
10721 // --------------------------------------------------------- |
|
10722 // |
|
10723 void eap_am_type_tls_peap_symbian_c::FixOldTableForPacStoreInitL() |
|
10724 { |
|
10725 EAP_TRACE_DEBUG( m_am_tools, TRACE_FLAGS_DEFAULT, ( EAPL( |
|
10726 "eap_am_type_tls_peap_symbian_c::FixOldTableForPacStoreInitL() IN\n" ) ) ); |
|
10727 |
|
10728 #ifdef USE_PAC_STORE |
|
10729 |
|
10730 if ( !iPacStoreDb ) |
|
10731 { |
|
10732 EAP_TRACE_DEBUG( m_am_tools, TRACE_FLAGS_DEFAULT, ( EAPL( |
|
10733 "ERROR: eap_am_type_tls_peap_symbian_c::FixOldTableForPacStoreInitL() \ |
|
10734 iPacStoreDb is NULL.\n" ) ) ); |
|
10735 User::Leave( KErrArgument ); |
|
10736 } |
|
10737 RDbNamedDatabase& pacStoreDb = iPacStoreDb->GetPacStoreDb(); |
|
10738 _LIT( KColumnDef, "UNSIGNED INTEGER" ); |
|
10739 AlterTableL( pacStoreDb, EAddColumn, KPacStoreGeneralSettingsTableName, |
|
10740 KPacStoreInitialized, KColumnDef ); |
|
10741 |
|
10742 #else |
|
10743 EAP_TRACE_DEBUG( m_am_tools, TRACE_FLAGS_DEFAULT, ( EAPL( |
|
10744 "ERROR: eap_am_type_tls_peap_symbian_c::FixOldTableForPacStoreInitL() \ |
|
10745 PAC store is not used.\n" ) ) ); |
|
10746 User::Leave( KErrNotSupported ); |
|
10747 #endif |
|
10748 |
|
10749 EAP_TRACE_DEBUG( m_am_tools, TRACE_FLAGS_DEFAULT, ( EAPL( |
|
10750 "eap_am_type_tls_peap_symbian_c::FixOldTableForPacStoreInitL() OUT\n" ) ) ); |
|
10751 |
|
10752 } // eap_am_type_tls_peap_symbian_c::FixOldTableForPacStoreInitL() |
|
10753 |
|
10754 |
|
10755 // --------------------------------------------------------- |
|
10756 // eap_am_type_tls_peap_symbian_c::ReadIntDbValue() |
|
10757 // --------------------------------------------------------- |
|
10758 // |
|
10759 TInt64 eap_am_type_tls_peap_symbian_c::ReadIntDbValueL( |
|
10760 RDbNamedDatabase& aDb, |
|
10761 const TDesC& aColumnName, |
|
10762 const TDesC& aSqlStatement ) |
|
10763 { |
|
10764 EAP_TRACE_DEBUG( m_am_tools, TRACE_FLAGS_DEFAULT, ( |
|
10765 EAPL( "eap_am_type_tls_peap_symbian_c::ReadIntDbValueL()\n" ) ) ); |
|
10766 TPtrC columnName; |
|
10767 columnName.Set( aColumnName ); |
|
10768 |
|
10769 RDbView view; |
|
10770 // Evaluate view |
|
10771 EAP_TRACE_DEBUG( m_am_tools, TRACE_FLAGS_DEFAULT, ( |
|
10772 EAPL( "ReadIntDbValue() prepare view\n" ) ) ); |
|
10773 User::LeaveIfError( view.Prepare( aDb, TDbQuery( |
|
10774 aSqlStatement ) ) ); |
|
10775 CleanupClosePushL( view ); |
|
10776 |
|
10777 EAP_TRACE_DEBUG( m_am_tools, TRACE_FLAGS_DEFAULT, ( |
|
10778 EAPL("ReadIntDbValue() evaluate view\n" ) ) ); |
|
10779 User::LeaveIfError( view.EvaluateAll() ); |
|
10780 // Get the first (and only) row |
|
10781 view.FirstL(); |
|
10782 view.GetL(); |
|
10783 // Get column set so we get the correct column numbers |
|
10784 CDbColSet* colSet = view.ColSetL(); |
|
10785 CleanupStack::PushL( colSet ); |
|
10786 TInt64 retVal = view.ColInt64( colSet->ColNo( columnName ) ); |
|
10787 |
|
10788 CleanupStack::PopAndDestroy( colSet ); // Delete colSet. |
|
10789 CleanupStack::PopAndDestroy( &view ); // Close view. |
|
10790 |
|
10791 return retVal; |
|
10792 } // eap_am_type_tls_peap_symbian_c::ReadIntDbValueL |
|
10793 |
|
10794 |
|
10795 // --------------------------------------------------------- |
|
10796 // eap_am_type_tls_peap_symbian_c::UpdatePasswordTimeL() |
|
10797 // --------------------------------------------------------- |
|
10798 // |
|
10799 void eap_am_type_tls_peap_symbian_c::UpdatePasswordTimeL() |
|
10800 { |
|
10801 /* update last password time */ |
|
10802 TPtrC lastFullPasswordTimeString; |
|
10803 |
|
10804 EAP_TRACE_DEBUG(m_am_tools, |
|
10805 TRACE_FLAGS_DEFAULT, ( |
|
10806 EAPL("UpdatePasswordTimeL - Start\n"))); |
|
10807 |
|
10808 lastFullPasswordTimeString.Set(KFASTLastPasswordIdentityTime); |
|
10809 |
|
10810 HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength); |
|
10811 TPtr sqlStatement = buf->Des(); |
|
10812 |
|
10813 EAP_TRACE_DEBUG(m_am_tools, |
|
10814 TRACE_FLAGS_DEFAULT, ( |
|
10815 EAPL("UpdatePasswordTimeL - prepare query\n"))); |
|
10816 // Query all the relevant parameters |
|
10817 _LIT(KSQLQuery, "SELECT %S FROM %S"); |
|
10818 sqlStatement.Format( KSQLQuery, &lastFullPasswordTimeString, |
|
10819 &KPacStoreGeneralSettingsTableName ); |
|
10820 |
|
10821 RDbView view; |
|
10822 // Evaluate view |
|
10823 EAP_TRACE_DEBUG(m_am_tools, |
|
10824 TRACE_FLAGS_DEFAULT, ( |
|
10825 EAPL("UpdatePasswordTimeL - prepare view\n"))); |
|
10826 |
|
10827 #ifdef USE_PAC_STORE |
|
10828 if ( !iPacStoreDb ) |
|
10829 { |
|
10830 EAP_TRACE_DEBUG( m_am_tools, TRACE_FLAGS_DEFAULT, ( |
|
10831 EAPL("CheckPasswordTimeValidityL - iPacStoreDb is NULL.\n"))); |
|
10832 CleanupStack::PopAndDestroy( buf ); // Delete buf. |
|
10833 User::Leave( KErrArgument ); |
|
10834 } |
|
10835 RDbNamedDatabase& db = iPacStoreDb->GetPacStoreDb(); |
|
10836 User::LeaveIfError( view.Prepare( db, TDbQuery( sqlStatement ), |
|
10837 TDbWindow::EUnlimited ) ); |
|
10838 CleanupClosePushL( view ); |
|
10839 #else |
|
10840 EAP_TRACE_DEBUG( m_am_tools, TRACE_FLAGS_DEFAULT, ( |
|
10841 EAPL("CheckPasswordTimeValidityL - PAC store is not used.\n"))); |
|
10842 CleanupStack::PopAndDestroy( buf ); // Delete buf. |
|
10843 User::Leave( KErrNotSupported ); |
|
10844 #endif |
|
10845 |
|
10846 EAP_TRACE_DEBUG(m_am_tools, |
|
10847 TRACE_FLAGS_DEFAULT, ( |
|
10848 EAPL("UpdatePasswordTimeL - evaluate view\n"))); |
|
10849 User::LeaveIfError(view.EvaluateAll()); |
|
10850 |
|
10851 // Get the first (and only) row for updation. |
|
10852 view.FirstL(); |
|
10853 view.UpdateL(); |
|
10854 |
|
10855 // Get column set so we get the correct column numbers |
|
10856 CDbColSet* colSet = view.ColSetL(); |
|
10857 CleanupStack::PushL(colSet); |
|
10858 |
|
10859 // Get the current universal time. |
|
10860 EAP_TRACE_DEBUG(m_am_tools, |
|
10861 TRACE_FLAGS_DEFAULT, ( |
|
10862 EAPL("UpdatePasswordTimeL - Get time\n"))); |
|
10863 TTime currentTime; |
|
10864 currentTime.UniversalTime(); |
|
10865 |
|
10866 |
|
10867 TDateTime currentDateTime = currentTime.DateTime(); |
|
10868 |
|
10869 EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, |
|
10870 (EAPL("eap_am_type_tls_peap_symbian_c::UpdatePasswordTimeL:store_authentication_time, %2d-%2d-%4d : %2d-%2d-%2d-%d\n"), |
|
10871 currentDateTime.Day()+1, currentDateTime.Month()+1,currentDateTime.Year(), currentDateTime.Hour(), |
|
10872 currentDateTime.Minute(), currentDateTime.Second(), currentDateTime.MicroSecond())); |
|
10873 |
|
10874 TInt64 fullAuthTime = currentTime.Int64(); |
|
10875 |
|
10876 view.SetColL(colSet->ColNo(lastFullPasswordTimeString), fullAuthTime); |
|
10877 |
|
10878 view.PutL(); |
|
10879 |
|
10880 CleanupStack::PopAndDestroy(colSet); // Delete colSet. |
|
10881 CleanupStack::PopAndDestroy(&view); // Close view. |
|
10882 CleanupStack::PopAndDestroy(buf); // Delete buf. |
|
10883 |
|
10884 /* update end */ |
|
10885 |
|
10886 } // eap_am_type_tls_peap_symbian_c::UpdatePasswordTimeL() |
|
10887 |
|
10888 |
|
10889 eap_status_e eap_am_type_tls_peap_symbian_c::CreateMasterkeyL() |
|
10890 { |
|
10891 HBufC8* password = HBufC8::NewLC(m_userResponse.get_data_length()); |
|
10892 TPtr8 passwordPtr = password->Des(); |
|
10893 m_PAC_store_password.set_copy_of_buffer(&m_userResponse); |
|
10894 passwordPtr.Copy(m_userResponse.get_data(), m_userResponse.get_data_length()); |
|
10895 m_eap_fast_completion_status = m_am_tools->convert_am_error_to_eapol_error(iPacStoreDb->CreateAndSaveMasterKeyL(passwordPtr)); |
|
10896 CleanupStack::PopAndDestroy(password); |
|
10897 return m_eap_fast_completion_status; |
|
10898 } |
|
10899 #endif //#if defined(USE_FAST_EAP_TYPE) |
|
10900 |
|
10901 |
|
10902 |
|
10903 // ================= TTLS-PAP public exported ======================= |
|
10904 |
|
10905 // ------------------------------------------------------------------------ |
|
10906 // eap_am_type_tls_peap_symbian_c::is_ttls_pap_session_valid() |
|
10907 // ------------------------------------------------------------------------ |
|
10908 // |
|
10909 EAP_FUNC_EXPORT |
|
10910 bool eap_am_type_tls_peap_symbian_c::is_ttls_pap_session_valid() |
|
10911 { |
|
10912 DEBUG( "eap_am_type_tls_peap_symbian_c::is_ttls_pap_session_valid()" ); |
|
10913 |
|
10914 TBool isValid = EFalse; |
|
10915 TInt err = KErrNone; |
|
10916 bool retVal = false; |
|
10917 |
|
10918 TRAP( err, isValid = IsTtlsPapSessionValidL() ); |
|
10919 if ( err != KErrNone ) |
|
10920 { |
|
10921 DEBUG1( "eap_am_type_tls_peap_symbian_c::is_ttls_pap_session_valid() ERROR: \ |
|
10922 Leave, err==%d.", err ); |
|
10923 retVal = false; |
|
10924 } |
|
10925 else |
|
10926 { |
|
10927 retVal = ( isValid ) ? true : false; |
|
10928 } |
|
10929 return retVal; |
|
10930 } |
|
10931 |
|
10932 // ------------------------------------------------------------------------ |
|
10933 // eap_am_type_tls_peap_symbian_c::query_ttls_pap_username_and_password() |
|
10934 // ------------------------------------------------------------------------ |
|
10935 // |
|
10936 EAP_FUNC_EXPORT eap_status_e |
|
10937 eap_am_type_tls_peap_symbian_c::query_ttls_pap_username_and_password( |
|
10938 const eap_variable_data_c * const aInSrvChallengeUtf8 ) |
|
10939 { |
|
10940 DEBUG( "eap_am_type_tls_peap_symbian_c::query_ttls_pap_username_and_password()" ); |
|
10941 |
|
10942 eap_status_e status( eap_status_pending_request ); |
|
10943 |
|
10944 if ( !iEapTtlsPapActive ) |
|
10945 { |
|
10946 TRAPD( err, iEapTtlsPapActive = CEapTtlsPapActive::NewL( |
|
10947 this, m_am_tools ) ); |
|
10948 if ( err != KErrNone ) |
|
10949 { |
|
10950 DEBUG1( "eap_am_type_tls_peap_symbian_c::query_ttls_pap_username_and_password() \ |
|
10951 ERROR: CEapTtlsPapActive::NewL(), err=%d.", err ); |
|
10952 return ConvertAmErrorToEapolError( err ); |
|
10953 } |
|
10954 } |
|
10955 if ( aInSrvChallengeUtf8 != NULL ) |
|
10956 { |
|
10957 iEapTtlsPapActive->UpdateSrvChallenge( *aInSrvChallengeUtf8 ); |
|
10958 } |
|
10959 TBool startedOk = iEapTtlsPapActive->Start( |
|
10960 CEapTtlsPapActive::EEapTtlsPapActiveQueryUserNameAndPassword ); |
|
10961 if ( !startedOk ) |
|
10962 { |
|
10963 status = eap_status_process_general_error; |
|
10964 } |
|
10965 if ( status != eap_status_pending_request ) |
|
10966 { |
|
10967 DEBUG( "eap_am_type_tls_peap_symbian_c::query_ttls_pap_username_and_password() \ |
|
10968 ERROR: status != eap_status_pending_request" ); |
|
10969 } |
|
10970 return status; |
|
10971 } |
|
10972 |
|
10973 // ================= TTLS-PAP public not exported ======================= |
|
10974 |
|
10975 // ------------------------------------------------------------------------ |
|
10976 // eap_am_type_tls_peap_symbian_c::verify_ttls_pap_username_and_password() |
|
10977 // ------------------------------------------------------------------------ |
|
10978 // |
|
10979 eap_status_e |
|
10980 eap_am_type_tls_peap_symbian_c::verify_ttls_pap_username_and_password( |
|
10981 const eap_variable_data_c * const /*aUserName*/, |
|
10982 const eap_variable_data_c * const /*aUserPassword*/ ) |
|
10983 { |
|
10984 DEBUG( "eap_am_type_tls_peap_symbian_c::verify_ttls_pap_username_and_password()" ); |
|
10985 return eap_status_not_supported; |
|
10986 } |
|
10987 |
|
10988 // ================= TTLS-PAP public new ======================= |
|
10989 |
|
10990 // ------------------------------------------------------------------------ |
|
10991 // eap_am_type_tls_peap_symbian_c::CompleteQueryTtlsPapUserNameAndPassword() |
|
10992 // ------------------------------------------------------------------------ |
|
10993 // |
|
10994 eap_status_e |
|
10995 eap_am_type_tls_peap_symbian_c::CompleteQueryTtlsPapUserNameAndPassword( |
|
10996 eap_status_e aStatus, |
|
10997 const TDesC8& aUserNameUtf8, |
|
10998 const TDesC8& aPasswordUtf8 ) |
|
10999 { |
|
11000 DEBUG( "eap_am_type_tls_peap_symbian_c::CompleteQueryTtlsPapUserNameAndPassword()" ); |
|
11001 |
|
11002 eap_status_e retStatus = aStatus; |
|
11003 eap_status_e tmpStatus = eap_status_ok; |
|
11004 |
|
11005 eap_variable_data_c userNameUtf8( m_am_tools ); |
|
11006 eap_variable_data_c passwordUtf8( m_am_tools ); |
|
11007 |
|
11008 tmpStatus = userNameUtf8.set_copy_of_buffer( |
|
11009 aUserNameUtf8.Ptr(), aUserNameUtf8.Length() ); |
|
11010 if ( tmpStatus != eap_status_ok && retStatus == eap_status_ok ) |
|
11011 { |
|
11012 retStatus = tmpStatus; |
|
11013 } |
|
11014 tmpStatus = passwordUtf8.set_copy_of_buffer( |
|
11015 aPasswordUtf8.Ptr(), aPasswordUtf8.Length() ); |
|
11016 if ( tmpStatus != eap_status_ok && retStatus == eap_status_ok ) |
|
11017 { |
|
11018 retStatus = tmpStatus; |
|
11019 } |
|
11020 if ( m_tls_am_partner == NULL ) |
|
11021 { |
|
11022 DEBUG( "eap_am_type_tls_peap_symbian_c::CompleteQueryTtlsPapUserNameAndPassword() \ |
|
11023 ERROR: m_tls_am_partner is NULL." ); |
|
11024 return eap_status_process_general_error; |
|
11025 } |
|
11026 retStatus = m_tls_am_partner-> |
|
11027 complete_query_ttls_pap_username_and_password( |
|
11028 &userNameUtf8, &passwordUtf8, retStatus ); |
|
11029 return retStatus; |
|
11030 } // eap_am_type_tls_peap_symbian_c::CompleteQueryTtlsPapUserNameAndPassword( |
|
11031 |
|
11032 |
|
11033 // ------------------------------------------------------------------------ |
|
11034 // eap_am_type_tls_peap_symbian_c::ConvertAmErrorToEapolError() |
|
11035 // ------------------------------------------------------------------------ |
|
11036 // |
|
11037 eap_status_e |
|
11038 eap_am_type_tls_peap_symbian_c::ConvertAmErrorToEapolError( TInt aErr ) |
|
11039 { |
|
11040 DEBUG( "eap_am_type_tls_peap_symbian_c::ConvertAmErrorToEapolError()" ); |
|
11041 if ( m_am_tools ) |
|
11042 { |
|
11043 return m_am_tools->convert_am_error_to_eapol_error( aErr ); |
|
11044 } |
|
11045 return eap_status_process_general_error; |
|
11046 } |
|
11047 |
|
11048 |
|
11049 // ------------------------------------------------------------------------ |
|
11050 // eap_am_type_tls_peap_symbian_c::ReadTtlsPapDbL() |
|
11051 // ------------------------------------------------------------------------ |
|
11052 // |
|
11053 //| EAP_TLS_PEAP_ttls_pap_password_prompt | UNSIGNED INTEGER | cf_str_EAP_TLS_PEAP_ttls_pap_password_prompt_literal |// |
|
11054 //| EAP_TLS_PEAP_ttls_pap_username | VARCHAR(253) | cf_str_EAP_TLS_PEAP_ttls_pap_username_literal |// |
|
11055 //| EAP_TLS_PEAP_ttls_pap_password | VARCHAR(128) | cf_str_EAP_TLS_PEAP_ttls_pap_password_literal |// |
|
11056 //| EAP_TLS_PEAP_ttls_pap_max_session_validity_time | BIGINT | cf_str_EAP_TLS_PEAP_ttls_pap_max_session_validity_time_literal |// |
|
11057 //| EAP_TLS_PEAP_ttls_pap_last_full_authentication_time | BIGINT | KTTLSPAPLastFullAuthTime |// |
|
11058 void eap_am_type_tls_peap_symbian_c::ReadTtlsPapDbL( |
|
11059 TTtlsPapDbInfo& aOutDbInfo ) |
|
11060 { |
|
11061 DEBUG( "eap_am_type_tls_peap_symbian_c::ReadTtlsPapDbL()" ); |
|
11062 |
|
11063 HBufC* buf = HBufC::NewLC( KMaxSqlQueryLength ); |
|
11064 TPtr sqlStatement = buf->Des(); |
|
11065 |
|
11066 // Query all the relevant parameters |
|
11067 _LIT( KSQLQuery, |
|
11068 "SELECT %S, %S, %S, %S, %S FROM %S WHERE %S=%d AND %S=%d AND %S=%d" ); |
|
11069 sqlStatement.Format( KSQLQuery, |
|
11070 &cf_str_EAP_TLS_PEAP_ttls_pap_password_prompt_literal, // select´ |
|
11071 &cf_str_EAP_TLS_PEAP_ttls_pap_username_literal, // select |
|
11072 &cf_str_EAP_TLS_PEAP_ttls_pap_password_literal, // select |
|
11073 &cf_str_EAP_TLS_PEAP_ttls_pap_max_session_validity_time_literal, // select |
|
11074 &KTTLSPAPLastFullAuthTime, // select |
|
11075 &KTtlsDatabaseTableName, // from |
|
11076 &KServiceType, m_index_type, // where %S=%d |
|
11077 &KServiceIndex, m_index, // where %S=%d |
|
11078 &KTunnelingType, eap_type_ttls ); // where %S=%d |
|
11079 |
|
11080 RDbView view; |
|
11081 // Evaluate view |
|
11082 User::LeaveIfError( view.Prepare( m_database, TDbQuery( sqlStatement ) ) ); |
|
11083 CleanupClosePushL( view ); |
|
11084 User::LeaveIfError( view.EvaluateAll() ); |
|
11085 |
|
11086 // Get the first (and only) row |
|
11087 if (view.FirstL()) |
|
11088 { |
|
11089 view.GetL(); |
|
11090 |
|
11091 // Get column set so we get the correct column numbers |
|
11092 CDbColSet* colSet = view.ColSetL(); |
|
11093 CleanupStack::PushL( colSet ); |
|
11094 |
|
11095 // columns reading |
|
11096 aOutDbInfo.iUsrPwdInfo.iPasswordPromptEnabled = view.ColUint( |
|
11097 colSet->ColNo( cf_str_EAP_TLS_PEAP_ttls_pap_password_prompt_literal ) ); |
|
11098 |
|
11099 aOutDbInfo.iUsrPwdInfo.iUserName = view.ColDes( |
|
11100 colSet->ColNo( cf_str_EAP_TLS_PEAP_ttls_pap_username_literal ) ); |
|
11101 |
|
11102 aOutDbInfo.iUsrPwdInfo.iPassword = view.ColDes( |
|
11103 colSet->ColNo( cf_str_EAP_TLS_PEAP_ttls_pap_password_literal ) ); |
|
11104 |
|
11105 aOutDbInfo.iMaxSessionTime = view.ColInt64( |
|
11106 colSet->ColNo( cf_str_EAP_TLS_PEAP_ttls_pap_max_session_validity_time_literal ) ); |
|
11107 |
|
11108 aOutDbInfo.iLastFullAuthTime = view.ColInt64( |
|
11109 colSet->ColNo( KTTLSPAPLastFullAuthTime ) ); |
|
11110 |
|
11111 CleanupStack::PopAndDestroy( colSet ); // Delete colSet. |
|
11112 } |
|
11113 CleanupStack::PopAndDestroy( &view ); // Close view. |
|
11114 CleanupStack::PopAndDestroy( buf ); // Delete buf. |
|
11115 |
|
11116 } // eap_am_type_tls_peap_symbian_c::ReadTtlsPapDbL() |
|
11117 |
|
11118 |
|
11119 // ------------------------------------------------------------------------ |
|
11120 // eap_am_type_tls_peap_symbian_c::WriteTtlsPapDbL() |
|
11121 // ------------------------------------------------------------------------ |
|
11122 // |
|
11123 //| EAP_TLS_PEAP_ttls_pap_password_prompt | UNSIGNED INTEGER | cf_str_EAP_TLS_PEAP_ttls_pap_password_prompt_literal |// |
|
11124 //| EAP_TLS_PEAP_ttls_pap_username | VARCHAR(253) | cf_str_EAP_TLS_PEAP_ttls_pap_username_literal |// |
|
11125 //| EAP_TLS_PEAP_ttls_pap_password | VARCHAR(128) | cf_str_EAP_TLS_PEAP_ttls_pap_password_literal |// |
|
11126 //| EAP_TLS_PEAP_ttls_pap_max_session_validity_time | BIGINT | cf_str_EAP_TLS_PEAP_ttls_pap_max_session_validity_time_literal |// |
|
11127 //| EAP_TLS_PEAP_ttls_pap_last_full_authentication_time | BIGINT | KTTLSPAPLastFullAuthTime |// |
|
11128 void eap_am_type_tls_peap_symbian_c::WriteTtlsPapDbL( |
|
11129 const TTtlsPapDbInfo& aInDbInfo ) |
|
11130 { |
|
11131 DEBUG( "eap_am_type_tls_peap_symbian_c::WriteTtlsPapDbL()" ); |
|
11132 |
|
11133 |
|
11134 HBufC* buf = HBufC::NewLC( KMaxSqlQueryLength ); |
|
11135 TPtr sqlStatement = buf->Des(); |
|
11136 |
|
11137 // Query all the relevant parameters |
|
11138 _LIT( KSQLQuery, |
|
11139 "SELECT %S, %S, %S, %S, %S FROM %S WHERE %S=%d AND %S=%d AND %S=%d" ); |
|
11140 sqlStatement.Format( KSQLQuery, |
|
11141 &cf_str_EAP_TLS_PEAP_ttls_pap_password_prompt_literal, // select´ |
|
11142 &cf_str_EAP_TLS_PEAP_ttls_pap_username_literal, // select |
|
11143 &cf_str_EAP_TLS_PEAP_ttls_pap_password_literal, // select |
|
11144 &cf_str_EAP_TLS_PEAP_ttls_pap_max_session_validity_time_literal, // select |
|
11145 &KTTLSPAPLastFullAuthTime, // select |
|
11146 &KTtlsDatabaseTableName, // from |
|
11147 &KServiceType, m_index_type, // where %S=%d |
|
11148 &KServiceIndex, m_index, // where %S=%d |
|
11149 &KTunnelingType, m_tunneling_vendor_type ); // where %S=%d |
|
11150 |
|
11151 RDbView view; |
|
11152 // Evaluate view |
|
11153 User::LeaveIfError( view.Prepare( m_database, TDbQuery( sqlStatement ) ) ); |
|
11154 CleanupClosePushL( view ); |
|
11155 User::LeaveIfError( view.EvaluateAll() ); |
|
11156 |
|
11157 // Get the first (and only) row |
|
11158 if (view.FirstL()) |
|
11159 { |
|
11160 view.UpdateL(); |
|
11161 |
|
11162 // Get column set so we get the correct column numbers |
|
11163 CDbColSet* colSet = view.ColSetL(); |
|
11164 CleanupStack::PushL( colSet ); |
|
11165 |
|
11166 // columns updating |
|
11167 view.SetColL( colSet->ColNo( |
|
11168 cf_str_EAP_TLS_PEAP_ttls_pap_password_prompt_literal ), |
|
11169 aInDbInfo.iUsrPwdInfo.iPasswordPromptEnabled ); |
|
11170 |
|
11171 view.SetColL( colSet->ColNo( |
|
11172 cf_str_EAP_TLS_PEAP_ttls_pap_username_literal ), |
|
11173 aInDbInfo.iUsrPwdInfo.iUserName ); |
|
11174 |
|
11175 view.SetColL( colSet->ColNo( |
|
11176 cf_str_EAP_TLS_PEAP_ttls_pap_password_literal ), |
|
11177 aInDbInfo.iUsrPwdInfo.iPassword ); |
|
11178 |
|
11179 view.SetColL( colSet->ColNo( |
|
11180 cf_str_EAP_TLS_PEAP_ttls_pap_max_session_validity_time_literal ), |
|
11181 aInDbInfo.iMaxSessionTime ); |
|
11182 |
|
11183 view.SetColL( colSet->ColNo( |
|
11184 KTTLSPAPLastFullAuthTime ), |
|
11185 aInDbInfo.iLastFullAuthTime ); |
|
11186 |
|
11187 view.PutL(); |
|
11188 |
|
11189 CleanupStack::PopAndDestroy( colSet ); // Delete colSet. |
|
11190 } |
|
11191 |
|
11192 CleanupStack::PopAndDestroy( &view ); // Close view. |
|
11193 CleanupStack::PopAndDestroy( buf ); // Delete buf. |
|
11194 |
|
11195 } // eap_am_type_tls_peap_symbian_c::WriteTtlsPapDbL() |
|
11196 |
|
11197 |
|
11198 // ------------------------------------------------------------------------ |
|
11199 // eap_am_type_tls_peap_symbian_c::SetTtlsPapColumnToNullL |
|
11200 // ------------------------------------------------------------------------ |
|
11201 // |
|
11202 void eap_am_type_tls_peap_symbian_c::SetTtlsPapColumnToNullL( const TDesC& aColName ) |
|
11203 { |
|
11204 DEBUG( "eap_am_type_tls_peap_symbian_c::SetColumnNullL()" ); |
|
11205 |
|
11206 HBufC* buf = HBufC::NewLC( KMaxSqlQueryLength ); |
|
11207 TPtr sqlStatement = buf->Des(); |
|
11208 |
|
11209 // Query all the relevant parameters |
|
11210 _LIT( KSQLQuery, |
|
11211 "SELECT %S FROM %S WHERE %S=%d AND %S=%d AND %S=%d" ); |
|
11212 sqlStatement.Format( KSQLQuery, |
|
11213 &aColName, // select´ |
|
11214 &KTtlsDatabaseTableName, // from |
|
11215 &KServiceType, m_index_type, // where %S=%d |
|
11216 &KServiceIndex, m_index, // where %S=%d |
|
11217 &KTunnelingType, m_tunneling_vendor_type ); // where %S=%d |
|
11218 |
|
11219 RDbView view; |
|
11220 // Evaluate view |
|
11221 User::LeaveIfError( view.Prepare( m_database, TDbQuery( sqlStatement ) ) ); |
|
11222 CleanupClosePushL( view ); |
|
11223 User::LeaveIfError( view.EvaluateAll() ); |
|
11224 |
|
11225 // Get the first (and only) row |
|
11226 if (view.FirstL()) |
|
11227 { |
|
11228 view.UpdateL(); |
|
11229 |
|
11230 // Get column set so we get the correct column numbers |
|
11231 CDbColSet* colSet = view.ColSetL(); |
|
11232 CleanupStack::PushL( colSet ); |
|
11233 |
|
11234 // set column to null |
|
11235 view.SetColNullL( colSet->ColNo( aColName ) ); |
|
11236 |
|
11237 view.PutL(); |
|
11238 |
|
11239 CleanupStack::PopAndDestroy( colSet ); // Delete colSet. |
|
11240 } |
|
11241 |
|
11242 CleanupStack::PopAndDestroy( &view ); // Close view. |
|
11243 CleanupStack::PopAndDestroy( buf ); // Delete buf. |
|
11244 |
|
11245 } // eap_am_type_tls_peap_symbian_c::SetTtlsPapColumnToNullL() |
|
11246 |
|
11247 |
|
11248 // ================= TTLS-PAP private ======================= |
|
11249 |
|
11250 // ------------------------------------------------------------------------ |
|
11251 // eap_am_type_tls_peap_symbian_c::IsTtlsPapSessionValidL() |
|
11252 // ------------------------------------------------------------------------ |
|
11253 // |
|
11254 TBool eap_am_type_tls_peap_symbian_c::IsTtlsPapSessionValidL() |
|
11255 { |
|
11256 DEBUG( "eap_am_type_tls_peap_symbian_c::IsTtlsPapSessionValidL()" ); |
|
11257 |
|
11258 TTtlsPapDbInfo dbInfo; |
|
11259 TInt err = KErrNone; |
|
11260 TBool retValue = EFalse; |
|
11261 |
|
11262 TRAP( err, ReadTtlsPapDbL( dbInfo ) ); |
|
11263 |
|
11264 if ( err != KErrNone ) |
|
11265 { |
|
11266 DEBUG1( "eap_am_type_tls_peap_symbian_c::IsTtlsPapSessionValidL() ERROR: \ |
|
11267 Leave happened, err=%d.", err ); |
|
11268 retValue = EFalse; |
|
11269 } |
|
11270 else |
|
11271 { |
|
11272 if ( dbInfo.iUsrPwdInfo.iPasswordPromptEnabled ) |
|
11273 { |
|
11274 // If the max session time from DB is zero then we use the |
|
11275 // one read from configuration file. |
|
11276 if( dbInfo.iMaxSessionTime == 0 ) |
|
11277 { |
|
11278 DEBUG( "eap_am_type_tls_peap_symbian_c::IsTtlsPapSessionValidL() \ |
|
11279 Using max TTLS PAP session validity time from config file." ); |
|
11280 |
|
11281 // use value from config file |
|
11282 dbInfo.iMaxSessionTime = iEapTtlsPapMaxSessionConfigTime; |
|
11283 } |
|
11284 |
|
11285 retValue = CheckTtlsPapSessionValidity( dbInfo.iMaxSessionTime, |
|
11286 dbInfo.iLastFullAuthTime ); |
|
11287 } |
|
11288 } |
|
11289 return retValue; |
|
11290 } // eap_am_type_tls_peap_symbian_c::IsTtlsPapSessionValidL() |
|
11291 |
|
11292 |
|
11293 // ------------------------------------------------------------------------ |
|
11294 // eap_am_type_tls_peap_symbian_c::CheckTtlsPapSessionValidity() |
|
11295 // ------------------------------------------------------------------------ |
|
11296 // |
|
11297 TBool eap_am_type_tls_peap_symbian_c::CheckTtlsPapSessionValidity( |
|
11298 const TInt64& aInMaxSessionTime, |
|
11299 const TInt64& aInLastFullAuthTime ) |
|
11300 { |
|
11301 DEBUG( "eap_am_type_tls_peap_symbian_c::CheckTtlsPapSessionValidity()" ); |
|
11302 |
|
11303 // Get the current time. |
|
11304 TTime currentTime; |
|
11305 currentTime.UniversalTime(); |
|
11306 |
|
11307 TTime lastFullAuthTime( aInLastFullAuthTime ); |
|
11308 |
|
11309 #if defined(_DEBUG) || defined(DEBUG) |
|
11310 |
|
11311 TDateTime currentDateTime = currentTime.DateTime(); |
|
11312 |
|
11313 TDateTime fullAuthDateTime = lastFullAuthTime.DateTime(); |
|
11314 |
|
11315 EAP_TRACE_DEBUG( m_am_tools, TRACE_FLAGS_DEFAULT, |
|
11316 ( EAPL( "Session Validity - Current Time, %2d-%2d-%4d : %2d-%2d-%2d-%d\n" ), |
|
11317 currentDateTime.Day()+1, currentDateTime.Month()+1, currentDateTime.Year(), |
|
11318 currentDateTime.Hour(), currentDateTime.Minute(), currentDateTime.Second(), |
|
11319 currentDateTime.MicroSecond() ) ); |
|
11320 |
|
11321 EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, |
|
11322 ( EAPL( "Session Validity - Last Full Auth Time, %2d-%2d-%4d : %2d-%2d-%2d-%d\n" ), |
|
11323 fullAuthDateTime.Day()+1, fullAuthDateTime.Month()+1, fullAuthDateTime.Year(), fullAuthDateTime.Hour(), |
|
11324 fullAuthDateTime.Minute(), fullAuthDateTime.Second(), fullAuthDateTime.MicroSecond())); |
|
11325 |
|
11326 #endif |
|
11327 |
|
11328 TTimeIntervalMicroSeconds interval = currentTime.MicroSecondsFrom(lastFullAuthTime); |
|
11329 |
|
11330 EAP_TRACE_DATA_DEBUG( m_am_tools, TRACE_FLAGS_DEFAULT, |
|
11331 ( EAPL( "eap_am_type_tls_peap_symbian_c::CheckTtlsPapSessionValidity:interval in microseconds:"), |
|
11332 &( interval.Int64() ), sizeof( interval.Int64() ) ) ); |
|
11333 |
|
11334 EAP_TRACE_DATA_DEBUG( m_am_tools, TRACE_FLAGS_DEFAULT, |
|
11335 ( EAPL( "eap_am_type_tls_peap_symbian_c::CheckTtlsPapSessionValidity:max session time in microseconds:"), |
|
11336 &( aInMaxSessionTime ), sizeof( aInMaxSessionTime ) ) ); |
|
11337 |
|
11338 #if defined(_DEBUG) || defined(DEBUG) |
|
11339 |
|
11340 TTimeIntervalMinutes intervalMins; |
|
11341 TInt error = currentTime.MinutesFrom(lastFullAuthTime, intervalMins); |
|
11342 |
|
11343 if(error == KErrNone) |
|
11344 { |
|
11345 EAP_TRACE_DEBUG( |
|
11346 m_am_tools, |
|
11347 TRACE_FLAGS_DEFAULT, |
|
11348 (EAPL("eap_am_type_tls_peap_symbian_c::CheckTtlsPapSessionValidity()") |
|
11349 EAPL("interval in Minutes =%d\n"), |
|
11350 intervalMins.Int())); |
|
11351 } |
|
11352 |
|
11353 #endif |
|
11354 |
|
11355 if( aInMaxSessionTime >= interval.Int64() ) |
|
11356 { |
|
11357 EAP_TRACE_DEBUG( m_am_tools, TRACE_FLAGS_DEFAULT, |
|
11358 ( EAPL( "eap_am_type_tls_peap_symbian_c::CheckTtlsPapSessionValidity - Session Valid \n" ) ) ); |
|
11359 EAP_TRACE_END( m_am_tools, TRACE_FLAGS_DEFAULT ); |
|
11360 |
|
11361 return ETrue; |
|
11362 } |
|
11363 else |
|
11364 { |
|
11365 EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, |
|
11366 ( EAPL( "eap_am_type_tls_peap_symbian_c::CheckTtlsPapSessionValidity - Session NOT Valid \n" ) ) ); |
|
11367 EAP_TRACE_END( m_am_tools, TRACE_FLAGS_DEFAULT ); |
|
11368 |
|
11369 return EFalse; |
|
11370 } |
|
11371 } // eap_am_type_tls_peap_symbian_c::CheckTtlsPapSessionValidity |
|
11372 |
|
11373 |
|
11374 // End of file. |