os/security/cryptoservices/filebasedcertificateandkeystores/test/ttesttools/ttesttoolengine.cpp
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/security/cryptoservices/filebasedcertificateandkeystores/test/ttesttools/ttesttoolengine.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,782 @@
1.4 +/*
1.5 +* Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
1.6 +* All rights reserved.
1.7 +* This component and the accompanying materials are made available
1.8 +* under the terms of the License "Eclipse Public License v1.0"
1.9 +* which accompanies this distribution, and is available
1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.11 +*
1.12 +* Initial Contributors:
1.13 +* Nokia Corporation - initial contribution.
1.14 +*
1.15 +* Contributors:
1.16 +*
1.17 +* Description:
1.18 +*
1.19 +*/
1.20 +
1.21 +
1.22 +#include "ttesttoolengine.h"
1.23 +#include <ccertattributefilter.h>
1.24 +#include <mctcertstore.h>
1.25 +#include <mctkeystore.h>
1.26 +
1.27 +const TInt swinstalluid = 268452523;
1.28 +const TInt swinstallocspuid = 268478646;
1.29 +const TInt midletinstalluid = 270506792;
1.30 +const TInt tlsuid = 268441661;
1.31 +const TInt tocspuid = 268477445;
1.32 +
1.33 +
1.34 +_LIT(KSWInstall, "SWInstall");
1.35 +_LIT(KSWInstallOCSP, "SWInstallOCSP");
1.36 +_LIT(KMidletInstall, "MidletInstall");
1.37 +_LIT(KTls, "SSL/TLS");
1.38 +_LIT(KTOcsp, "OCSP Test");
1.39 +
1.40 +_LIT(KCaType, "ca");
1.41 +_LIT(KUserType, "user");
1.42 +_LIT(KPeerType, "peer");
1.43 +
1.44 +
1.45 +/*static*/ CTestToolEngine* CTestToolEngine::NewLC()
1.46 + {
1.47 + CTestToolEngine* self = new (ELeave) CTestToolEngine();
1.48 + CleanupStack::PushL(self);
1.49 + self->ConstructL();
1.50 + return self;
1.51 + }
1.52 +
1.53 +CTestToolEngine::CTestToolEngine() : CActive(EPriorityNormal)
1.54 + {
1.55 + iStore = -1;
1.56 + iPolicy = EFalse;
1.57 + }
1.58 +
1.59 +CTestToolEngine::~CTestToolEngine()
1.60 + {
1.61 + Cancel();
1.62 +
1.63 + delete iCertStore;
1.64 + delete iKeyStore;
1.65 +
1.66 + delete iFilter;
1.67 + Cancel();
1.68 + iCertInfos.Close();
1.69 + iFsKeyStore.Close();
1.70 + iFs.Close();
1.71 + iUids.Reset();
1.72 + }
1.73 +
1.74 +void CTestToolEngine::ConstructL()
1.75 + {
1.76 + User::LeaveIfError(iFs.Connect());
1.77 +
1.78 + iCertStore = CUnifiedCertStore::NewL(iFs, ETrue);
1.79 +
1.80 + User::LeaveIfError(iFsKeyStore.Connect());
1.81 + iKeyStore = CUnifiedKeyStore::NewL(iFsKeyStore);
1.82 +
1.83 + // This filter will accept any certificates
1.84 + iFilter = CCertAttributeFilter::NewL();
1.85 +
1.86 + CActiveScheduler::Add(this);
1.87 + }
1.88 +
1.89 +void CTestToolEngine::RunL()
1.90 + {
1.91 + if (iStatus.Int() != KErrNone)
1.92 + {
1.93 + User::Leave(iStatus.Int());
1.94 + }
1.95 +
1.96 + switch (iState)
1.97 + {
1.98 + case EInitialiseKeyStore:
1.99 + {
1.100 + // Construct a catch-all filter!
1.101 + iKeyFilter.iKeyAlgorithm = CCTKeyInfo::EInvalidAlgorithm;
1.102 + iKeyFilter.iPolicyFilter = TCTKeyAttributeFilter::EAllKeys;
1.103 + iKeyFilter.iUsage = EPKCS15UsageAll;
1.104 + if (iStore != -1)
1.105 + {
1.106 + MCTKeyStore& chosen = iKeyStore->KeyStore(iStore);
1.107 + chosen.List(iKeys, iKeyFilter, iStatus);
1.108 + }
1.109 + else
1.110 + {
1.111 + iKeyStore->List(iKeys, iKeyFilter, iStatus);
1.112 + }
1.113 + if(iPolicy)
1.114 + {
1.115 + iState = EGetPolicy;
1.116 + }
1.117 + else if (iKeysListCount > 0)
1.118 + {
1.119 + iState = EDone;
1.120 + }
1.121 + else
1.122 + {
1.123 + iState = EFilterKey;
1.124 + }
1.125 + SetActive();
1.126 + }
1.127 + break;
1.128 + case EFilterKey:
1.129 + {
1.130 + TInt index = 0;
1.131 + if (iLabel1.Length())
1.132 + {
1.133 + iNumCert1 = FilterKeys(iKeys, iLabel1, index);
1.134 + }
1.135 + if (iLabel2.Length())
1.136 + {
1.137 + iNumCert2 = FilterKeys(iKeys, iLabel2, index);
1.138 + }
1.139 + CActiveScheduler::Stop();
1.140 + }
1.141 + break;
1.142 + case EInitialise:
1.143 + {
1.144 + if (iStore != -1)
1.145 + {
1.146 + MCTCertStore& chosen = iCertStore->CertStore(iStore);
1.147 + chosen.List(iCertInfos, *iFilter, iStatus);
1.148 + }
1.149 + else
1.150 + {
1.151 + iCertStore->List(iCertInfos, *iFilter, iStatus);
1.152 + }
1.153 +
1.154 + if(iAppsCount > 0)
1.155 + {
1.156 + iState = EGetApps;
1.157 + }
1.158 + else if (iGetTrust == 1)
1.159 + {
1.160 + iState = EGetTrust;
1.161 + }
1.162 + else if (iCertsCount > 0)
1.163 + {
1.164 + iState = EDone;
1.165 + }
1.166 + else
1.167 + {
1.168 + iState = EFilter;
1.169 + }
1.170 + SetActive();
1.171 + }
1.172 + break;
1.173 + case EGetPolicy:
1.174 + {
1.175 + FilterKeys(iKeys, iLabel1, iIndex);
1.176 + CActiveScheduler::Stop();
1.177 + }
1.178 + break;
1.179 + case EGetApps:
1.180 + {
1.181 + TInt index = 0;
1.182 + FilterCerts(iCertInfos, iLabel1, index);
1.183 + iCertStore->Applications(*iCertInfos[index], iUids, iStatus);
1.184 + CActiveScheduler::Stop();
1.185 + }
1.186 + break;
1.187 + case EGetTrust:
1.188 + {
1.189 + TInt index = 0;
1.190 + FilterCerts(iCertInfos, iLabel1, index);
1.191 + iCertStore->Trusted(*iCertInfos[index], iActualTrust, iStatus);
1.192 + CActiveScheduler::Stop();
1.193 + }
1.194 + break;
1.195 + case EFilter:
1.196 + {
1.197 + TInt index = 0;
1.198 + TBool filteronly = ETrue;
1.199 + if (iLabel1.Length())
1.200 + {
1.201 + iNumCert1 = FilterCerts(iCertInfos, iLabel1, index, filteronly);
1.202 + }
1.203 + if (iLabel2.Length())
1.204 + {
1.205 + iNumCert2 = FilterCerts(iCertInfos, iLabel2, index, filteronly);
1.206 + }
1.207 + CActiveScheduler::Stop();
1.208 + }
1.209 + break;
1.210 + case EDone:
1.211 + {
1.212 + CActiveScheduler::Stop();
1.213 + }
1.214 + break;
1.215 + default:
1.216 + {
1.217 + User::Panic(_L("Testtool Engine - Illegal state"), 0);
1.218 + }
1.219 + }
1.220 + }
1.221 +
1.222 +TInt CTestToolEngine::RunError(TInt /*aError*/)
1.223 + {
1.224 + CActiveScheduler::Stop();
1.225 +
1.226 + return KErrNone;
1.227 + }
1.228 +
1.229 +
1.230 +void CTestToolEngine::DoCancel()
1.231 + {
1.232 + //CActiveScheduler::Stop();
1.233 + }
1.234 +
1.235 +TVerdict CTestToolEngine::ListCerts(const TDesC& aLabel1, const TInt aExpectedNumLabel)
1.236 + {
1.237 + TVerdict returnValue = EPass;
1.238 + iLabel1.Set(aLabel1);
1.239 +
1.240 + Initilize();
1.241 + if (iNumCert1 != aExpectedNumLabel)
1.242 + {
1.243 + returnValue = EFail;
1.244 + }
1.245 + return returnValue;
1.246 + }
1.247 +
1.248 +
1.249 +TVerdict CTestToolEngine::ListCerts(const TDesC& aLabel1, const TDesC& aLabel2, const TInt aExpectedNumLabel)
1.250 + {
1.251 + TVerdict returnValue = EPass;
1.252 + iLabel1.Set(aLabel1);
1.253 + iLabel2.Set(aLabel2);
1.254 +
1.255 + Initilize();
1.256 + if (iNumCert1 != aExpectedNumLabel || iNumCert2 != aExpectedNumLabel)
1.257 + {
1.258 + returnValue = EFail;
1.259 + }
1.260 + return returnValue;
1.261 + }
1.262 +
1.263 +TVerdict CTestToolEngine::ListStore(RPointerArray<HBufC>& aCerts)
1.264 + {
1.265 + TVerdict returnValue = EPass;
1.266 + iCertsCount = aCerts.Count();
1.267 +
1.268 + Initilize();
1.269 +
1.270 + if (!CompareWithExpectedStore(aCerts))
1.271 + {
1.272 + returnValue = EFail;
1.273 + }
1.274 + return returnValue;
1.275 + }
1.276 +
1.277 +TVerdict CTestToolEngine::ListCerts(RPointerArray<HBufC>& aCerts)
1.278 + {
1.279 + TVerdict returnValue = EPass;
1.280 + iCertsCount = aCerts.Count();
1.281 +
1.282 + Initilize();
1.283 +
1.284 + if (!CompareWithExpectedCertificates(aCerts))
1.285 + {
1.286 + returnValue = EFail;
1.287 + }
1.288 + return returnValue;
1.289 + }
1.290 +
1.291 +TVerdict CTestToolEngine::ListCerts(RPointerArray<HBufC>& aCerts, const TDesC& aLabel)
1.292 + {
1.293 + TVerdict returnValue = EPass;
1.294 + iLabel1.Set(aLabel);
1.295 + iCertsCount = aCerts.Count();
1.296 +
1.297 + Initilize();
1.298 + TCertificateOwnerType owner;
1.299 + if (iLabel1.CompareF(KCaType) == KErrNone)
1.300 + {
1.301 + owner = ECACertificate;
1.302 + }
1.303 + else if (iLabel1.CompareF(KUserType) == KErrNone)
1.304 + {
1.305 + owner = EUserCertificate;
1.306 + }
1.307 + else if (iLabel1.CompareF(KPeerType) == KErrNone)
1.308 + {
1.309 + owner = EPeerCertificate;
1.310 + }
1.311 + FilterCerts(iCertInfos, owner);
1.312 + if (!CompareWithExpectedCertificates(aCerts))
1.313 + {
1.314 + returnValue = EFail;
1.315 + }
1.316 + return returnValue;
1.317 + }
1.318 +
1.319 +TVerdict CTestToolEngine::ListCerts(RPointerArray<HBufC>& aCerts, TInt aStore)
1.320 + {
1.321 + TVerdict returnValue = EPass;
1.322 + iStore = aStore;
1.323 + iCertsCount = aCerts.Count();
1.324 +
1.325 + Initilize();
1.326 + if (!CompareWithExpectedCertificates(aCerts))
1.327 + {
1.328 + returnValue = EFail;
1.329 + }
1.330 + return returnValue;
1.331 + }
1.332 +
1.333 +TVerdict CTestToolEngine::CheckApps(RPointerArray<HBufC>& aApps, const TDesC& aLabel)
1.334 + {
1.335 + TVerdict returnValue = EPass;
1.336 + iAppsCount = aApps.Count();
1.337 + iLabel1.Set(aLabel);
1.338 + Initilize();
1.339 + if (!VerifyApps(aApps))
1.340 + {
1.341 + returnValue = EFail;
1.342 + }
1.343 + return returnValue;
1.344 + }
1.345 +
1.346 +TVerdict CTestToolEngine::CheckTrust(const TDesC& aLabel,TBool aTrust)
1.347 + {
1.348 + TVerdict returnValue = EPass;
1.349 + iLabel1.Set(aLabel);
1.350 + iGetTrust = 1;
1.351 + Initilize();
1.352 + if (!VerifyTrust(aTrust))
1.353 + {
1.354 + returnValue = EFail;
1.355 + }
1.356 + return returnValue;
1.357 + }
1.358 +
1.359 +TVerdict CTestToolEngine::ListStoreKey(RPointerArray<HBufC>& aKeys)
1.360 + {
1.361 + TVerdict returnValue = EPass;
1.362 + iKeysListCount = aKeys.Count();
1.363 +
1.364 + KeyInitilize();
1.365 +
1.366 + if (!CompareWithExpectedStoreKey(aKeys))
1.367 + {
1.368 + returnValue = EFail;
1.369 + }
1.370 + return returnValue;
1.371 + }
1.372 +
1.373 +TVerdict CTestToolEngine::ListKeys(const TDesC& aLabel1, const TInt aExpectedNumLabel)
1.374 + {
1.375 + TVerdict returnValue = EPass;
1.376 + iLabel1.Set(aLabel1);
1.377 +
1.378 + KeyInitilize();
1.379 + if (iNumCert1 != aExpectedNumLabel)
1.380 + {
1.381 + returnValue = EFail;
1.382 + }
1.383 + return returnValue;
1.384 + }
1.385 +
1.386 +
1.387 +TVerdict CTestToolEngine::ListKeys(const TDesC& aLabel1, const TDesC& aLabel2, const TInt aExpectedNumLabel)
1.388 + {
1.389 + TVerdict returnValue = EPass;
1.390 + iLabel1.Set(aLabel1);
1.391 + iLabel2.Set(aLabel2);
1.392 +
1.393 + KeyInitilize();
1.394 + if (iNumCert1 != aExpectedNumLabel || iNumCert2 != aExpectedNumLabel)
1.395 + {
1.396 + returnValue = EFail;
1.397 + }
1.398 + return returnValue;
1.399 + }
1.400 +
1.401 +TVerdict CTestToolEngine::ListKeys(RPointerArray<HBufC>& aKeys, TInt aStore)
1.402 + {
1.403 + TVerdict returnValue = EPass;
1.404 + iStore = aStore;
1.405 + iKeysListCount = aKeys.Count();
1.406 +
1.407 + KeyInitilize();
1.408 + if (!CompareWithExpectedKeys(aKeys))
1.409 + {
1.410 + returnValue = EFail;
1.411 + }
1.412 + return returnValue;
1.413 + }
1.414 +
1.415 +
1.416 +TVerdict CTestToolEngine::ListKeys(RPointerArray<HBufC>& aKeys)
1.417 + {
1.418 + TVerdict returnValue = EPass;
1.419 + iKeysListCount = aKeys.Count();
1.420 +
1.421 + KeyInitilize();
1.422 +
1.423 + if (!CompareWithExpectedKeys(aKeys))
1.424 + {
1.425 + returnValue = EFail;
1.426 + }
1.427 + return returnValue;
1.428 + }
1.429 +
1.430 +TVerdict CTestToolEngine::GetPolicy(const TDesC& aLabel1, const TDesC& aLabel2, TInt aUser)
1.431 + {
1.432 + TVerdict returnValue = EPass;
1.433 + iLabel1.Set(aLabel1);
1.434 + iLabel2.Set(aLabel2);
1.435 + iPolicy = ETrue;
1.436 + KeyInitilize();
1.437 + VerifyPolicy(aUser);
1.438 +
1.439 + return returnValue;
1.440 + }
1.441 +
1.442 +void CTestToolEngine::Initilize()
1.443 + {
1.444 + iState = EInitialise;
1.445 + iCertStore->Initialize(iStatus);
1.446 + SetActive();
1.447 + CActiveScheduler::Start();
1.448 + }
1.449 +
1.450 +void CTestToolEngine::KeyInitilize()
1.451 + {
1.452 + iState = EInitialiseKeyStore;
1.453 + iKeyStore->Initialize(iStatus);
1.454 + SetActive();
1.455 + CActiveScheduler::Start();
1.456 + }
1.457 +
1.458 +TBool CTestToolEngine::VerifyApps(RPointerArray<HBufC>& aApps)
1.459 + {
1.460 + TInt uidsCount = iUids.Count();
1.461 + TInt appsCount = aApps.Count();
1.462 + TBool result = ETrue;
1.463 + if ( uidsCount != appsCount)
1.464 + {
1.465 + return EFalse;
1.466 + }
1.467 + for (TInt i = 0; i < uidsCount; i++)
1.468 + {
1.469 + if (iUids[i] == TUid::Uid(swinstalluid))
1.470 + {
1.471 + result = CheckAppForUid(KSWInstall, aApps);
1.472 + }
1.473 + else if (iUids[i] == TUid::Uid(swinstallocspuid))
1.474 + {
1.475 + result = CheckAppForUid(KSWInstallOCSP, aApps);
1.476 + }
1.477 + else if (iUids[i] == TUid::Uid(midletinstalluid))
1.478 + {
1.479 + result = CheckAppForUid(KMidletInstall, aApps);
1.480 + }
1.481 + else if (iUids[i] == TUid::Uid(tlsuid))
1.482 + {
1.483 + result = CheckAppForUid(KTls, aApps);
1.484 + }
1.485 + else if (iUids[i] == TUid::Uid(tocspuid))
1.486 + {
1.487 + result = CheckAppForUid(KTOcsp, aApps);
1.488 + }
1.489 + else
1.490 + {
1.491 + result = EFalse;
1.492 + }
1.493 + if (!result)
1.494 + {
1.495 + break;
1.496 + }
1.497 + }
1.498 + return result;
1.499 + }
1.500 +
1.501 +TBool CTestToolEngine::CheckAppForUid(const TDesC& aAppName, RPointerArray<HBufC>& aApps)
1.502 + {
1.503 + TBool result = EFalse;
1.504 + for (TInt i = 0; i < aApps.Count();i++)
1.505 + {
1.506 + if (aAppName.CompareF(*aApps[i]) == KErrNone)
1.507 + {
1.508 + result = ETrue;
1.509 + break;
1.510 + }
1.511 + else
1.512 + {
1.513 + result = EFalse;
1.514 + }
1.515 + }
1.516 + return result;
1.517 + }
1.518 +
1.519 +TBool CTestToolEngine::VerifyPolicy(TInt aUser)
1.520 + {
1.521 + TBool result = EFalse;
1.522 + _LIT(KCab, "WriteDeviceData");
1.523 + TLex lex(iLabel2);
1.524 + TUid secid;
1.525 + lex.Val(secid.iUid);
1.526 + TCompiledSecurityPolicy managementPolicy = iKeys[iIndex]->ManagementPolicy();
1.527 + TCompiledSecurityPolicy usePolicy = iKeys[iIndex]->UsePolicy();
1.528 + TUint32 mSecureid = managementPolicy.SecureId();
1.529 + TUint32 uSecureid = usePolicy.SecureId();
1.530 +
1.531 + if (aUser == 2)
1.532 + {
1.533 + if (mSecureid == 0xffffffff)
1.534 + {
1.535 + TCapability cab = managementPolicy.Capability(0);
1.536 + // currently only possible for keyowner other than secure id.
1.537 + if (cab == ECapabilityWriteDeviceData && iLabel2.CompareF(KCab) == KErrNone)
1.538 + {
1.539 + result = ETrue;
1.540 + }
1.541 + else
1.542 + {
1.543 + result = EFalse;
1.544 + }
1.545 + }
1.546 + else
1.547 + {
1.548 + TUid mSecureUid = TUid::Uid(mSecureid);
1.549 + if (mSecureUid == secid)
1.550 + {
1.551 + result = ETrue;
1.552 + }
1.553 + else
1.554 + {
1.555 + result = EFalse;
1.556 + }
1.557 + }
1.558 + }
1.559 + else if (aUser == 1)
1.560 + {
1.561 + if (uSecureid == 0xffffffff)
1.562 + {
1.563 + TSecurityPolicy::TType utype = usePolicy.Type();
1.564 + _LIT(KType, "ALL");
1.565 + // currently only possible for keyuser other than secure id
1.566 + if (utype == TSecurityPolicy::ETypePass && iLabel2.CompareF(KType) == KErrNone)
1.567 + {
1.568 + result = ETrue;
1.569 + }
1.570 + else
1.571 + {
1.572 + result = EFalse;
1.573 + }
1.574 + }
1.575 + else
1.576 + {
1.577 + TUid uSecureUid = TUid::Uid(uSecureid);
1.578 + if (uSecureUid == secid)
1.579 + {
1.580 + result = ETrue;
1.581 + }
1.582 + else
1.583 + {
1.584 + result = EFalse;
1.585 + }
1.586 + }
1.587 + }
1.588 + return result;
1.589 + }
1.590 +
1.591 +TInt CTestToolEngine::FilterCerts(RMPointerArray<CCTCertInfo>& aCertList,
1.592 + TDesC& aLabel, TInt& aIndex, TBool aFilterOnly)
1.593 + {
1.594 + TInt j = 0, count = 0;
1.595 + while (j < aCertList.Count())
1.596 + {
1.597 + if ( aCertList[j]->Label().MatchF(aLabel) != KErrNotFound)
1.598 + {
1.599 + count++;
1.600 + if (count == 1)
1.601 + {
1.602 + //first certificate to be selected for retreiving
1.603 + aIndex = j;
1.604 + }
1.605 + j++;
1.606 + }
1.607 + else
1.608 + {
1.609 + if (!aFilterOnly)
1.610 + {
1.611 + CCTCertInfo* tmp = aCertList[j];
1.612 + tmp->Release();
1.613 + aCertList.Remove(j);
1.614 + }
1.615 + else
1.616 + {
1.617 + j++;
1.618 + }
1.619 + }
1.620 + }
1.621 + return count;
1.622 + }
1.623 +
1.624 +void CTestToolEngine::FilterCerts(RMPointerArray<CCTCertInfo>& aCertList, TCertificateOwnerType& aOwnerType)
1.625 + {
1.626 + TInt j = 0;
1.627 + while (j < aCertList.Count())
1.628 + {
1.629 + if ( aCertList[j]->CertificateOwnerType() != aOwnerType)
1.630 + {
1.631 + CCTCertInfo* tmp = aCertList[j];
1.632 + tmp->Release();
1.633 + aCertList.Remove(j);
1.634 + }
1.635 + else
1.636 + {
1.637 + j++;
1.638 + }
1.639 + }
1.640 + }
1.641 +
1.642 +
1.643 +TInt CTestToolEngine::FilterKeys(RMPointerArray<CCTKeyInfo>& aKeyList,
1.644 + TDesC& aLabel, TInt& aIndex)
1.645 + {
1.646 + TInt j = 0, count = 0;
1.647 + while (j < aKeyList.Count())
1.648 + {
1.649 + if ( aKeyList[j]->Label().MatchF(aLabel) != KErrNotFound)
1.650 + {
1.651 + count++;
1.652 + if (count == 1)
1.653 + {
1.654 + //first key to be selected for retreiving
1.655 + aIndex = j;
1.656 + }
1.657 + j++;
1.658 + }
1.659 + else
1.660 + {
1.661 + j++;
1.662 + }
1.663 + }
1.664 + return count;
1.665 + }
1.666 +
1.667 +TBool CTestToolEngine::CompareWithExpectedCertificates(RPointerArray<HBufC>& aCerts)
1.668 + {
1.669 + if ( iCertInfos.Count() != aCerts.Count())
1.670 + {
1.671 + return EFalse;
1.672 + }
1.673 + for (TInt i = 0 ; i < iCertInfos.Count(); i++)
1.674 + {
1.675 + const TDesC& label = iCertInfos[i]->Label();
1.676 + TBool found = EFalse;
1.677 + for (TInt j = 0; j < aCerts.Count(); j++)
1.678 + {
1.679 + if (aCerts[j]->CompareF(label) == KErrNone)
1.680 + {
1.681 + found = ETrue;
1.682 + break;
1.683 + }
1.684 + }
1.685 + if (!found)
1.686 + {
1.687 + return EFalse;
1.688 + }
1.689 + }
1.690 + return ETrue;
1.691 + }
1.692 +
1.693 +
1.694 +TBool CTestToolEngine::CompareWithExpectedKeys(RPointerArray<HBufC>& aKeys)
1.695 + {
1.696 + if ( iKeys.Count() != iKeysListCount)
1.697 + {
1.698 + return EFalse;
1.699 + }
1.700 + for (TInt i = 0 ; i < iKeys.Count(); i++)
1.701 + {
1.702 + const TDesC& label = iKeys[i]->Label();
1.703 + TBool found = EFalse;
1.704 + for (TInt j = 0; j < iKeysListCount; j++)
1.705 + {
1.706 + if (aKeys[j]->CompareF(label) == KErrNone)
1.707 + {
1.708 + found = ETrue;
1.709 + break;
1.710 + }
1.711 + }
1.712 + if (!found)
1.713 + {
1.714 + return EFalse;
1.715 + }
1.716 + }
1.717 + return ETrue;
1.718 + }
1.719 +
1.720 +TBool CTestToolEngine::CompareWithExpectedStore(RPointerArray<HBufC>& aCerts)
1.721 + {
1.722 + TBool result = EFalse;
1.723 + TInt storeCount = iCertStore->CertStoreCount();
1.724 + for (TInt i = 0; i < storeCount ; i++)
1.725 + {
1.726 + result = EFalse;
1.727 + MCTToken& token = (iCertStore->CertStore(i)).Token();
1.728 + const TDesC& tmp = token.Label();
1.729 + for (TInt j = 0; j < aCerts.Count(); j++)
1.730 + {
1.731 + if (tmp.CompareF(*aCerts[j]) == KErrNone)
1.732 + {
1.733 + result = ETrue;
1.734 + break;
1.735 + }
1.736 + }
1.737 + if (!result)
1.738 + {
1.739 + break;
1.740 + }
1.741 + }
1.742 + return result;
1.743 + }
1.744 +
1.745 +
1.746 +TBool CTestToolEngine::CompareWithExpectedStoreKey(RPointerArray<HBufC>& aKeys)
1.747 + {
1.748 + TBool result = EFalse;
1.749 + TInt storeCount = iKeyStore->KeyStoreCount();
1.750 + for (TInt i = 0; i < storeCount ; i++)
1.751 + {
1.752 + result = EFalse;
1.753 + MCTToken& token = (iKeyStore->KeyStore(i)).Token();
1.754 + const TDesC& tmp = token.Label();
1.755 + for (TInt j = 0; j < aKeys.Count(); j++)
1.756 + {
1.757 + if (tmp.CompareF(*aKeys[j]) == KErrNone)
1.758 + {
1.759 + result = ETrue;
1.760 + break;
1.761 + }
1.762 + }
1.763 + if (!result)
1.764 + {
1.765 + break;
1.766 + }
1.767 + }
1.768 + return result;
1.769 + }
1.770 +
1.771 +
1.772 +
1.773 +TBool CTestToolEngine::VerifyTrust(TBool aTrust)
1.774 + {
1.775 + TBool result = EFalse;
1.776 + if (aTrust == iActualTrust)
1.777 + {
1.778 + result = ETrue;
1.779 + }
1.780 + else
1.781 + {
1.782 + result = EFalse;
1.783 + }
1.784 + return result;
1.785 + }