25 |
25 |
26 #include "SCPConfiguration.h" |
26 #include "SCPConfiguration.h" |
27 #include "SCPServer.h" |
27 #include "SCPServer.h" |
28 #include <featmgr.h> |
28 #include <featmgr.h> |
29 |
29 |
|
30 #include <dmencryptionutil.h> |
30 // ================= MEMBER FUNCTIONS ======================= |
31 // ================= MEMBER FUNCTIONS ======================= |
31 |
32 |
32 |
33 |
33 // C++ default constructor can NOT contain any code, that |
34 // C++ default constructor can NOT contain any code, that |
34 // might leave. |
35 // might leave. |
80 if( errf != KErrNone ) |
81 if( errf != KErrNone ) |
81 { |
82 { |
82 User::Leave(errf); |
83 User::Leave(errf); |
83 } |
84 } |
84 TInt result = KErrNone; |
85 TInt result = KErrNone; |
85 |
86 TAny* KParameters[KTotalParamIDs]; |
86 TAny* KParameters[7]; |
87 TInt KParamIDs[KTotalParamIDs]; |
87 TInt KParamIDs[7]; |
88 TSCPParamType KSCPParamTypes[KTotalParamIDs]; |
88 TSCPParamType KSCPParamTypes[7]; |
|
89 TInt KNumParams; |
89 TInt KNumParams; |
90 |
90 |
91 |
91 |
92 if(FeatureManager::FeatureSupported(KFeatureIdSapDeviceLockEnhancements)) |
92 if(FeatureManager::FeatureSupported(KFeatureIdSapDeviceLockEnhancements)) |
93 { |
93 { |
170 CleanupStack::PopAndDestroy( params ); |
176 CleanupStack::PopAndDestroy( params ); |
171 |
177 |
172 // Decrypt the ISA security code |
178 // Decrypt the ISA security code |
173 TSCPSecCode cryptBuf; |
179 TSCPSecCode cryptBuf; |
174 cryptBuf.Copy( iSecCode ); |
180 cryptBuf.Copy( iSecCode ); |
175 TransformStringL( EFalse, cryptBuf, iSecCode ); |
181 Dprint( (_L("--> TSCPConfiguration::ReadSetupL NativeTransform iCryptoCode= %S "), &iCryptoCode )); |
|
182 if(EFalse == NativeTransform(EFalse, iCryptoCode, iSecCode)) |
|
183 { |
|
184 Dprint( (_L("--> TSCPConfiguration::ReadSetupL NativeTransform returned false") )); |
|
185 // If ECOM decrypt fails after modifying iSecCode. |
|
186 iSecCode.Copy(cryptBuf); |
|
187 TransformStringL( EFalse, cryptBuf, iSecCode ); |
|
188 } |
|
189 else |
|
190 { |
|
191 Dprint( (_L("--> TSCPConfiguration::ReadSetupL NativeTransform returned true") )); |
|
192 Dprint( (_L("--> TSCPConfiguration::ReadSetupL NativeTransform iCryptoCode= %S "), &iCryptoCode )); |
|
193 //Dummy code to be written of KSCPCodeMaxLen size, if plugin exist. |
|
194 // Dprint((_L("iSecCode.Copy(iCryptoCode.Ptr(), KSCPCodeMaxLen);"))); |
|
195 // iSecCode.Copy(iCryptoCode.Ptr(), KSCPCodeMaxLen); |
|
196 } |
176 iSecCode.SetLength( KSCPCodeMaxLen ); // Remove the suffix |
197 iSecCode.SetLength( KSCPCodeMaxLen ); // Remove the suffix |
177 |
198 |
178 FeatureManager::UnInitializeLib(); |
199 FeatureManager::UnInitializeLib(); |
179 return result; |
200 return result; |
180 } |
201 } |
243 |
264 |
244 // Encrypt the ISA security code |
265 // Encrypt the ISA security code |
245 TSCPSecCode cryptBuf; |
266 TSCPSecCode cryptBuf; |
246 cryptBuf.Copy( iSecCode ); |
267 cryptBuf.Copy( iSecCode ); |
247 cryptBuf.Append( KSCPCryptSuffix ); // 5 chars for the code + suffix |
268 cryptBuf.Append( KSCPCryptSuffix ); // 5 chars for the code + suffix |
248 TransformStringL( ETrue, cryptBuf, iSecCode ); |
269 if(EFalse == NativeTransform(ETrue, cryptBuf, iCryptoCode)) |
249 |
270 { |
|
271 cryptBuf.FillZ(); |
|
272 cryptBuf.Zero(); |
|
273 cryptBuf.Copy( iSecCode ); |
|
274 cryptBuf.Append( KSCPCryptSuffix ); // 5 chars for the code + suffix |
|
275 Dprint( (_L("--> TSCPConfiguration::WriteSetupL NativeTransform returned false") )); |
|
276 TransformStringL( ETrue, cryptBuf, iSecCode ); |
|
277 |
|
278 } |
|
279 else |
|
280 { |
|
281 iSecCode.FillZ(); |
|
282 iSecCode.Zero(); |
|
283 |
|
284 Dprint( (_L("--> TSCPConfiguration::WriteSetupL NativeTransform returned true") )); |
|
285 Dprint( (_L("--> TSCPConfiguration::WriteSetupL NativeTransform iCryptoCode= %S "), &iCryptoCode )); |
|
286 } |
250 TInt ret = KErrNone; |
287 TInt ret = KErrNone; |
251 for ( TInt i = 0; i < KNumParams; i++ ) |
288 for ( TInt i = 0; i < KNumParams; i++ ) |
252 { |
289 { |
253 // Set the value according to the type |
290 // Set the value according to the type |
254 switch ( KSCPParamTypes[i] ) |
291 switch ( KSCPParamTypes[i] ) |
395 |
438 |
396 #ifdef UNICODE |
439 #ifdef UNICODE |
397 aOutput.SetLength( outputData.Length() / 2 ); |
440 aOutput.SetLength( outputData.Length() / 2 ); |
398 #endif // UNICODE |
441 #endif // UNICODE |
399 } |
442 } |
400 |
443 // --------------------------------------------------------- |
401 |
444 // TSCPConfiguration::NativeTransform (TBool aEncrypt, TDes& aInput, TDes& aOutput) |
|
445 // Transforms the given aInput buffer using the plugin Encryption/Decryption, |
|
446 // and stores the result to aOutput |
|
447 // |
|
448 // Status : New |
|
449 // --------------------------------------------------------- |
|
450 // |
|
451 TBool TSCPConfiguration::NativeTransform (TBool aEncrypt, TDes& aInput, TDes& aOutput) |
|
452 { |
|
453 Dprint( (_L("--> TSCPConfiguration::NativeTransform()") )); |
|
454 TInt err(KErrNone); |
|
455 TBool result(ETrue); |
|
456 |
|
457 |
|
458 CDMEncryptionUtil* eUtil; |
|
459 Dprint( (_L("TSCPConfiguration::NativeTransform(), calling TRAP(err, eUtil = CDMEncryptionUtil::NewL()); ") )); |
|
460 |
|
461 TRAP(err, eUtil = CDMEncryptionUtil::NewL()); |
|
462 Dprint( (_L("TSCPConfiguration::NativeTransform(), after TRAP(err, eUtil = CDMEncryptionUtil::NewL()); err= %d"), err )); |
|
463 if(err) |
|
464 { |
|
465 result = EFalse; |
|
466 return result; |
|
467 } |
|
468 CleanupStack::PushL(eUtil); |
|
469 if(aEncrypt) |
|
470 { |
|
471 Dprint( (_L(" TSCPConfiguration::NativeTransform()Encrypting...") )); |
|
472 TRAP(err, eUtil->EncryptL( aInput, aOutput)); |
|
473 Dprint( (_L("TSCPConfiguration::NativeTransform(), after Encrypting err= %d"), err )); |
|
474 } |
|
475 else |
|
476 { |
|
477 Dprint( (_L(" TSCPConfiguration::NativeTransform()Decrypting...") )); |
|
478 TRAP(err, eUtil->DecryptL( aInput, aOutput)); |
|
479 Dprint( (_L("TSCPConfiguration::NativeTransform(), after Decrypting err= %d"), err )); |
|
480 } |
|
481 CleanupStack::PopAndDestroy(); //eUtil |
|
482 if(err) |
|
483 { |
|
484 Dprint( (_L(" TSCPConfiguration::NativeTransform() CDMEncryptionUtil::ListImplementationsL failed") )); |
|
485 result = EFalse; |
|
486 } |
|
487 else |
|
488 { |
|
489 Dprint( (_L(" TSCPConfiguration::NativeTransform() CDMEncryptionUtil::ListImplementationsL success") )); |
|
490 result = ETrue; |
|
491 } |
|
492 |
|
493 Dprint( (_L("TSCPConfiguration::NativeTransform(): result = %d"), result )); |
|
494 Dprint( (_L("<-- TSCPConfiguration::NativeTransform()") )); |
|
495 return result; |
|
496 } |
402 |
497 |
403 // End of File |
498 // End of File |
404 |
499 |