|
1 /* |
|
2 * Copyright (c) 2007-2009 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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "ttesttoolengine.h" |
|
20 #include <ccertattributefilter.h> |
|
21 #include <mctcertstore.h> |
|
22 #include <mctkeystore.h> |
|
23 |
|
24 const TInt swinstalluid = 268452523; |
|
25 const TInt swinstallocspuid = 268478646; |
|
26 const TInt midletinstalluid = 270506792; |
|
27 const TInt tlsuid = 268441661; |
|
28 const TInt tocspuid = 268477445; |
|
29 |
|
30 |
|
31 _LIT(KSWInstall, "SWInstall"); |
|
32 _LIT(KSWInstallOCSP, "SWInstallOCSP"); |
|
33 _LIT(KMidletInstall, "MidletInstall"); |
|
34 _LIT(KTls, "SSL/TLS"); |
|
35 _LIT(KTOcsp, "OCSP Test"); |
|
36 |
|
37 _LIT(KCaType, "ca"); |
|
38 _LIT(KUserType, "user"); |
|
39 _LIT(KPeerType, "peer"); |
|
40 |
|
41 |
|
42 /*static*/ CTestToolEngine* CTestToolEngine::NewLC() |
|
43 { |
|
44 CTestToolEngine* self = new (ELeave) CTestToolEngine(); |
|
45 CleanupStack::PushL(self); |
|
46 self->ConstructL(); |
|
47 return self; |
|
48 } |
|
49 |
|
50 CTestToolEngine::CTestToolEngine() : CActive(EPriorityNormal) |
|
51 { |
|
52 iStore = -1; |
|
53 iPolicy = EFalse; |
|
54 } |
|
55 |
|
56 CTestToolEngine::~CTestToolEngine() |
|
57 { |
|
58 Cancel(); |
|
59 |
|
60 delete iCertStore; |
|
61 delete iKeyStore; |
|
62 |
|
63 delete iFilter; |
|
64 Cancel(); |
|
65 iCertInfos.Close(); |
|
66 iFsKeyStore.Close(); |
|
67 iFs.Close(); |
|
68 iUids.Reset(); |
|
69 } |
|
70 |
|
71 void CTestToolEngine::ConstructL() |
|
72 { |
|
73 User::LeaveIfError(iFs.Connect()); |
|
74 |
|
75 iCertStore = CUnifiedCertStore::NewL(iFs, ETrue); |
|
76 |
|
77 User::LeaveIfError(iFsKeyStore.Connect()); |
|
78 iKeyStore = CUnifiedKeyStore::NewL(iFsKeyStore); |
|
79 |
|
80 // This filter will accept any certificates |
|
81 iFilter = CCertAttributeFilter::NewL(); |
|
82 |
|
83 CActiveScheduler::Add(this); |
|
84 } |
|
85 |
|
86 void CTestToolEngine::RunL() |
|
87 { |
|
88 if (iStatus.Int() != KErrNone) |
|
89 { |
|
90 User::Leave(iStatus.Int()); |
|
91 } |
|
92 |
|
93 switch (iState) |
|
94 { |
|
95 case EInitialiseKeyStore: |
|
96 { |
|
97 // Construct a catch-all filter! |
|
98 iKeyFilter.iKeyAlgorithm = CCTKeyInfo::EInvalidAlgorithm; |
|
99 iKeyFilter.iPolicyFilter = TCTKeyAttributeFilter::EAllKeys; |
|
100 iKeyFilter.iUsage = EPKCS15UsageAll; |
|
101 if (iStore != -1) |
|
102 { |
|
103 MCTKeyStore& chosen = iKeyStore->KeyStore(iStore); |
|
104 chosen.List(iKeys, iKeyFilter, iStatus); |
|
105 } |
|
106 else |
|
107 { |
|
108 iKeyStore->List(iKeys, iKeyFilter, iStatus); |
|
109 } |
|
110 if(iPolicy) |
|
111 { |
|
112 iState = EGetPolicy; |
|
113 } |
|
114 else if (iKeysListCount > 0) |
|
115 { |
|
116 iState = EDone; |
|
117 } |
|
118 else |
|
119 { |
|
120 iState = EFilterKey; |
|
121 } |
|
122 SetActive(); |
|
123 } |
|
124 break; |
|
125 case EFilterKey: |
|
126 { |
|
127 TInt index = 0; |
|
128 if (iLabel1.Length()) |
|
129 { |
|
130 iNumCert1 = FilterKeys(iKeys, iLabel1, index); |
|
131 } |
|
132 if (iLabel2.Length()) |
|
133 { |
|
134 iNumCert2 = FilterKeys(iKeys, iLabel2, index); |
|
135 } |
|
136 CActiveScheduler::Stop(); |
|
137 } |
|
138 break; |
|
139 case EInitialise: |
|
140 { |
|
141 if (iStore != -1) |
|
142 { |
|
143 MCTCertStore& chosen = iCertStore->CertStore(iStore); |
|
144 chosen.List(iCertInfos, *iFilter, iStatus); |
|
145 } |
|
146 else |
|
147 { |
|
148 iCertStore->List(iCertInfos, *iFilter, iStatus); |
|
149 } |
|
150 |
|
151 if(iAppsCount > 0) |
|
152 { |
|
153 iState = EGetApps; |
|
154 } |
|
155 else if (iGetTrust == 1) |
|
156 { |
|
157 iState = EGetTrust; |
|
158 } |
|
159 else if (iCertsCount > 0) |
|
160 { |
|
161 iState = EDone; |
|
162 } |
|
163 else |
|
164 { |
|
165 iState = EFilter; |
|
166 } |
|
167 SetActive(); |
|
168 } |
|
169 break; |
|
170 case EGetPolicy: |
|
171 { |
|
172 FilterKeys(iKeys, iLabel1, iIndex); |
|
173 CActiveScheduler::Stop(); |
|
174 } |
|
175 break; |
|
176 case EGetApps: |
|
177 { |
|
178 TInt index = 0; |
|
179 FilterCerts(iCertInfos, iLabel1, index); |
|
180 iCertStore->Applications(*iCertInfos[index], iUids, iStatus); |
|
181 CActiveScheduler::Stop(); |
|
182 } |
|
183 break; |
|
184 case EGetTrust: |
|
185 { |
|
186 TInt index = 0; |
|
187 FilterCerts(iCertInfos, iLabel1, index); |
|
188 iCertStore->Trusted(*iCertInfos[index], iActualTrust, iStatus); |
|
189 CActiveScheduler::Stop(); |
|
190 } |
|
191 break; |
|
192 case EFilter: |
|
193 { |
|
194 TInt index = 0; |
|
195 TBool filteronly = ETrue; |
|
196 if (iLabel1.Length()) |
|
197 { |
|
198 iNumCert1 = FilterCerts(iCertInfos, iLabel1, index, filteronly); |
|
199 } |
|
200 if (iLabel2.Length()) |
|
201 { |
|
202 iNumCert2 = FilterCerts(iCertInfos, iLabel2, index, filteronly); |
|
203 } |
|
204 CActiveScheduler::Stop(); |
|
205 } |
|
206 break; |
|
207 case EDone: |
|
208 { |
|
209 CActiveScheduler::Stop(); |
|
210 } |
|
211 break; |
|
212 default: |
|
213 { |
|
214 User::Panic(_L("Testtool Engine - Illegal state"), 0); |
|
215 } |
|
216 } |
|
217 } |
|
218 |
|
219 TInt CTestToolEngine::RunError(TInt /*aError*/) |
|
220 { |
|
221 CActiveScheduler::Stop(); |
|
222 |
|
223 return KErrNone; |
|
224 } |
|
225 |
|
226 |
|
227 void CTestToolEngine::DoCancel() |
|
228 { |
|
229 //CActiveScheduler::Stop(); |
|
230 } |
|
231 |
|
232 TVerdict CTestToolEngine::ListCerts(const TDesC& aLabel1, const TInt aExpectedNumLabel) |
|
233 { |
|
234 TVerdict returnValue = EPass; |
|
235 iLabel1.Set(aLabel1); |
|
236 |
|
237 Initilize(); |
|
238 if (iNumCert1 != aExpectedNumLabel) |
|
239 { |
|
240 returnValue = EFail; |
|
241 } |
|
242 return returnValue; |
|
243 } |
|
244 |
|
245 |
|
246 TVerdict CTestToolEngine::ListCerts(const TDesC& aLabel1, const TDesC& aLabel2, const TInt aExpectedNumLabel) |
|
247 { |
|
248 TVerdict returnValue = EPass; |
|
249 iLabel1.Set(aLabel1); |
|
250 iLabel2.Set(aLabel2); |
|
251 |
|
252 Initilize(); |
|
253 if (iNumCert1 != aExpectedNumLabel || iNumCert2 != aExpectedNumLabel) |
|
254 { |
|
255 returnValue = EFail; |
|
256 } |
|
257 return returnValue; |
|
258 } |
|
259 |
|
260 TVerdict CTestToolEngine::ListStore(RPointerArray<HBufC>& aCerts) |
|
261 { |
|
262 TVerdict returnValue = EPass; |
|
263 iCertsCount = aCerts.Count(); |
|
264 |
|
265 Initilize(); |
|
266 |
|
267 if (!CompareWithExpectedStore(aCerts)) |
|
268 { |
|
269 returnValue = EFail; |
|
270 } |
|
271 return returnValue; |
|
272 } |
|
273 |
|
274 TVerdict CTestToolEngine::ListCerts(RPointerArray<HBufC>& aCerts) |
|
275 { |
|
276 TVerdict returnValue = EPass; |
|
277 iCertsCount = aCerts.Count(); |
|
278 |
|
279 Initilize(); |
|
280 |
|
281 if (!CompareWithExpectedCertificates(aCerts)) |
|
282 { |
|
283 returnValue = EFail; |
|
284 } |
|
285 return returnValue; |
|
286 } |
|
287 |
|
288 TVerdict CTestToolEngine::ListCerts(RPointerArray<HBufC>& aCerts, const TDesC& aLabel) |
|
289 { |
|
290 TVerdict returnValue = EPass; |
|
291 iLabel1.Set(aLabel); |
|
292 iCertsCount = aCerts.Count(); |
|
293 |
|
294 Initilize(); |
|
295 TCertificateOwnerType owner; |
|
296 if (iLabel1.CompareF(KCaType) == KErrNone) |
|
297 { |
|
298 owner = ECACertificate; |
|
299 } |
|
300 else if (iLabel1.CompareF(KUserType) == KErrNone) |
|
301 { |
|
302 owner = EUserCertificate; |
|
303 } |
|
304 else if (iLabel1.CompareF(KPeerType) == KErrNone) |
|
305 { |
|
306 owner = EPeerCertificate; |
|
307 } |
|
308 FilterCerts(iCertInfos, owner); |
|
309 if (!CompareWithExpectedCertificates(aCerts)) |
|
310 { |
|
311 returnValue = EFail; |
|
312 } |
|
313 return returnValue; |
|
314 } |
|
315 |
|
316 TVerdict CTestToolEngine::ListCerts(RPointerArray<HBufC>& aCerts, TInt aStore) |
|
317 { |
|
318 TVerdict returnValue = EPass; |
|
319 iStore = aStore; |
|
320 iCertsCount = aCerts.Count(); |
|
321 |
|
322 Initilize(); |
|
323 if (!CompareWithExpectedCertificates(aCerts)) |
|
324 { |
|
325 returnValue = EFail; |
|
326 } |
|
327 return returnValue; |
|
328 } |
|
329 |
|
330 TVerdict CTestToolEngine::CheckApps(RPointerArray<HBufC>& aApps, const TDesC& aLabel) |
|
331 { |
|
332 TVerdict returnValue = EPass; |
|
333 iAppsCount = aApps.Count(); |
|
334 iLabel1.Set(aLabel); |
|
335 Initilize(); |
|
336 if (!VerifyApps(aApps)) |
|
337 { |
|
338 returnValue = EFail; |
|
339 } |
|
340 return returnValue; |
|
341 } |
|
342 |
|
343 TVerdict CTestToolEngine::CheckTrust(const TDesC& aLabel,TBool aTrust) |
|
344 { |
|
345 TVerdict returnValue = EPass; |
|
346 iLabel1.Set(aLabel); |
|
347 iGetTrust = 1; |
|
348 Initilize(); |
|
349 if (!VerifyTrust(aTrust)) |
|
350 { |
|
351 returnValue = EFail; |
|
352 } |
|
353 return returnValue; |
|
354 } |
|
355 |
|
356 TVerdict CTestToolEngine::ListStoreKey(RPointerArray<HBufC>& aKeys) |
|
357 { |
|
358 TVerdict returnValue = EPass; |
|
359 iKeysListCount = aKeys.Count(); |
|
360 |
|
361 KeyInitilize(); |
|
362 |
|
363 if (!CompareWithExpectedStoreKey(aKeys)) |
|
364 { |
|
365 returnValue = EFail; |
|
366 } |
|
367 return returnValue; |
|
368 } |
|
369 |
|
370 TVerdict CTestToolEngine::ListKeys(const TDesC& aLabel1, const TInt aExpectedNumLabel) |
|
371 { |
|
372 TVerdict returnValue = EPass; |
|
373 iLabel1.Set(aLabel1); |
|
374 |
|
375 KeyInitilize(); |
|
376 if (iNumCert1 != aExpectedNumLabel) |
|
377 { |
|
378 returnValue = EFail; |
|
379 } |
|
380 return returnValue; |
|
381 } |
|
382 |
|
383 |
|
384 TVerdict CTestToolEngine::ListKeys(const TDesC& aLabel1, const TDesC& aLabel2, const TInt aExpectedNumLabel) |
|
385 { |
|
386 TVerdict returnValue = EPass; |
|
387 iLabel1.Set(aLabel1); |
|
388 iLabel2.Set(aLabel2); |
|
389 |
|
390 KeyInitilize(); |
|
391 if (iNumCert1 != aExpectedNumLabel || iNumCert2 != aExpectedNumLabel) |
|
392 { |
|
393 returnValue = EFail; |
|
394 } |
|
395 return returnValue; |
|
396 } |
|
397 |
|
398 TVerdict CTestToolEngine::ListKeys(RPointerArray<HBufC>& aKeys, TInt aStore) |
|
399 { |
|
400 TVerdict returnValue = EPass; |
|
401 iStore = aStore; |
|
402 iKeysListCount = aKeys.Count(); |
|
403 |
|
404 KeyInitilize(); |
|
405 if (!CompareWithExpectedKeys(aKeys)) |
|
406 { |
|
407 returnValue = EFail; |
|
408 } |
|
409 return returnValue; |
|
410 } |
|
411 |
|
412 |
|
413 TVerdict CTestToolEngine::ListKeys(RPointerArray<HBufC>& aKeys) |
|
414 { |
|
415 TVerdict returnValue = EPass; |
|
416 iKeysListCount = aKeys.Count(); |
|
417 |
|
418 KeyInitilize(); |
|
419 |
|
420 if (!CompareWithExpectedKeys(aKeys)) |
|
421 { |
|
422 returnValue = EFail; |
|
423 } |
|
424 return returnValue; |
|
425 } |
|
426 |
|
427 TVerdict CTestToolEngine::GetPolicy(const TDesC& aLabel1, const TDesC& aLabel2, TInt aUser) |
|
428 { |
|
429 TVerdict returnValue = EPass; |
|
430 iLabel1.Set(aLabel1); |
|
431 iLabel2.Set(aLabel2); |
|
432 iPolicy = ETrue; |
|
433 KeyInitilize(); |
|
434 VerifyPolicy(aUser); |
|
435 |
|
436 return returnValue; |
|
437 } |
|
438 |
|
439 void CTestToolEngine::Initilize() |
|
440 { |
|
441 iState = EInitialise; |
|
442 iCertStore->Initialize(iStatus); |
|
443 SetActive(); |
|
444 CActiveScheduler::Start(); |
|
445 } |
|
446 |
|
447 void CTestToolEngine::KeyInitilize() |
|
448 { |
|
449 iState = EInitialiseKeyStore; |
|
450 iKeyStore->Initialize(iStatus); |
|
451 SetActive(); |
|
452 CActiveScheduler::Start(); |
|
453 } |
|
454 |
|
455 TBool CTestToolEngine::VerifyApps(RPointerArray<HBufC>& aApps) |
|
456 { |
|
457 TInt uidsCount = iUids.Count(); |
|
458 TInt appsCount = aApps.Count(); |
|
459 TBool result = ETrue; |
|
460 if ( uidsCount != appsCount) |
|
461 { |
|
462 return EFalse; |
|
463 } |
|
464 for (TInt i = 0; i < uidsCount; i++) |
|
465 { |
|
466 if (iUids[i] == TUid::Uid(swinstalluid)) |
|
467 { |
|
468 result = CheckAppForUid(KSWInstall, aApps); |
|
469 } |
|
470 else if (iUids[i] == TUid::Uid(swinstallocspuid)) |
|
471 { |
|
472 result = CheckAppForUid(KSWInstallOCSP, aApps); |
|
473 } |
|
474 else if (iUids[i] == TUid::Uid(midletinstalluid)) |
|
475 { |
|
476 result = CheckAppForUid(KMidletInstall, aApps); |
|
477 } |
|
478 else if (iUids[i] == TUid::Uid(tlsuid)) |
|
479 { |
|
480 result = CheckAppForUid(KTls, aApps); |
|
481 } |
|
482 else if (iUids[i] == TUid::Uid(tocspuid)) |
|
483 { |
|
484 result = CheckAppForUid(KTOcsp, aApps); |
|
485 } |
|
486 else |
|
487 { |
|
488 result = EFalse; |
|
489 } |
|
490 if (!result) |
|
491 { |
|
492 break; |
|
493 } |
|
494 } |
|
495 return result; |
|
496 } |
|
497 |
|
498 TBool CTestToolEngine::CheckAppForUid(const TDesC& aAppName, RPointerArray<HBufC>& aApps) |
|
499 { |
|
500 TBool result = EFalse; |
|
501 for (TInt i = 0; i < aApps.Count();i++) |
|
502 { |
|
503 if (aAppName.CompareF(*aApps[i]) == KErrNone) |
|
504 { |
|
505 result = ETrue; |
|
506 break; |
|
507 } |
|
508 else |
|
509 { |
|
510 result = EFalse; |
|
511 } |
|
512 } |
|
513 return result; |
|
514 } |
|
515 |
|
516 TBool CTestToolEngine::VerifyPolicy(TInt aUser) |
|
517 { |
|
518 TBool result = EFalse; |
|
519 _LIT(KCab, "WriteDeviceData"); |
|
520 TLex lex(iLabel2); |
|
521 TUid secid; |
|
522 lex.Val(secid.iUid); |
|
523 TCompiledSecurityPolicy managementPolicy = iKeys[iIndex]->ManagementPolicy(); |
|
524 TCompiledSecurityPolicy usePolicy = iKeys[iIndex]->UsePolicy(); |
|
525 TUint32 mSecureid = managementPolicy.SecureId(); |
|
526 TUint32 uSecureid = usePolicy.SecureId(); |
|
527 |
|
528 if (aUser == 2) |
|
529 { |
|
530 if (mSecureid == 0xffffffff) |
|
531 { |
|
532 TCapability cab = managementPolicy.Capability(0); |
|
533 // currently only possible for keyowner other than secure id. |
|
534 if (cab == ECapabilityWriteDeviceData && iLabel2.CompareF(KCab) == KErrNone) |
|
535 { |
|
536 result = ETrue; |
|
537 } |
|
538 else |
|
539 { |
|
540 result = EFalse; |
|
541 } |
|
542 } |
|
543 else |
|
544 { |
|
545 TUid mSecureUid = TUid::Uid(mSecureid); |
|
546 if (mSecureUid == secid) |
|
547 { |
|
548 result = ETrue; |
|
549 } |
|
550 else |
|
551 { |
|
552 result = EFalse; |
|
553 } |
|
554 } |
|
555 } |
|
556 else if (aUser == 1) |
|
557 { |
|
558 if (uSecureid == 0xffffffff) |
|
559 { |
|
560 TSecurityPolicy::TType utype = usePolicy.Type(); |
|
561 _LIT(KType, "ALL"); |
|
562 // currently only possible for keyuser other than secure id |
|
563 if (utype == TSecurityPolicy::ETypePass && iLabel2.CompareF(KType) == KErrNone) |
|
564 { |
|
565 result = ETrue; |
|
566 } |
|
567 else |
|
568 { |
|
569 result = EFalse; |
|
570 } |
|
571 } |
|
572 else |
|
573 { |
|
574 TUid uSecureUid = TUid::Uid(uSecureid); |
|
575 if (uSecureUid == secid) |
|
576 { |
|
577 result = ETrue; |
|
578 } |
|
579 else |
|
580 { |
|
581 result = EFalse; |
|
582 } |
|
583 } |
|
584 } |
|
585 return result; |
|
586 } |
|
587 |
|
588 TInt CTestToolEngine::FilterCerts(RMPointerArray<CCTCertInfo>& aCertList, |
|
589 TDesC& aLabel, TInt& aIndex, TBool aFilterOnly) |
|
590 { |
|
591 TInt j = 0, count = 0; |
|
592 while (j < aCertList.Count()) |
|
593 { |
|
594 if ( aCertList[j]->Label().MatchF(aLabel) != KErrNotFound) |
|
595 { |
|
596 count++; |
|
597 if (count == 1) |
|
598 { |
|
599 //first certificate to be selected for retreiving |
|
600 aIndex = j; |
|
601 } |
|
602 j++; |
|
603 } |
|
604 else |
|
605 { |
|
606 if (!aFilterOnly) |
|
607 { |
|
608 CCTCertInfo* tmp = aCertList[j]; |
|
609 tmp->Release(); |
|
610 aCertList.Remove(j); |
|
611 } |
|
612 else |
|
613 { |
|
614 j++; |
|
615 } |
|
616 } |
|
617 } |
|
618 return count; |
|
619 } |
|
620 |
|
621 void CTestToolEngine::FilterCerts(RMPointerArray<CCTCertInfo>& aCertList, TCertificateOwnerType& aOwnerType) |
|
622 { |
|
623 TInt j = 0; |
|
624 while (j < aCertList.Count()) |
|
625 { |
|
626 if ( aCertList[j]->CertificateOwnerType() != aOwnerType) |
|
627 { |
|
628 CCTCertInfo* tmp = aCertList[j]; |
|
629 tmp->Release(); |
|
630 aCertList.Remove(j); |
|
631 } |
|
632 else |
|
633 { |
|
634 j++; |
|
635 } |
|
636 } |
|
637 } |
|
638 |
|
639 |
|
640 TInt CTestToolEngine::FilterKeys(RMPointerArray<CCTKeyInfo>& aKeyList, |
|
641 TDesC& aLabel, TInt& aIndex) |
|
642 { |
|
643 TInt j = 0, count = 0; |
|
644 while (j < aKeyList.Count()) |
|
645 { |
|
646 if ( aKeyList[j]->Label().MatchF(aLabel) != KErrNotFound) |
|
647 { |
|
648 count++; |
|
649 if (count == 1) |
|
650 { |
|
651 //first key to be selected for retreiving |
|
652 aIndex = j; |
|
653 } |
|
654 j++; |
|
655 } |
|
656 else |
|
657 { |
|
658 j++; |
|
659 } |
|
660 } |
|
661 return count; |
|
662 } |
|
663 |
|
664 TBool CTestToolEngine::CompareWithExpectedCertificates(RPointerArray<HBufC>& aCerts) |
|
665 { |
|
666 if ( iCertInfos.Count() != aCerts.Count()) |
|
667 { |
|
668 return EFalse; |
|
669 } |
|
670 for (TInt i = 0 ; i < iCertInfos.Count(); i++) |
|
671 { |
|
672 const TDesC& label = iCertInfos[i]->Label(); |
|
673 TBool found = EFalse; |
|
674 for (TInt j = 0; j < aCerts.Count(); j++) |
|
675 { |
|
676 if (aCerts[j]->CompareF(label) == KErrNone) |
|
677 { |
|
678 found = ETrue; |
|
679 break; |
|
680 } |
|
681 } |
|
682 if (!found) |
|
683 { |
|
684 return EFalse; |
|
685 } |
|
686 } |
|
687 return ETrue; |
|
688 } |
|
689 |
|
690 |
|
691 TBool CTestToolEngine::CompareWithExpectedKeys(RPointerArray<HBufC>& aKeys) |
|
692 { |
|
693 if ( iKeys.Count() != iKeysListCount) |
|
694 { |
|
695 return EFalse; |
|
696 } |
|
697 for (TInt i = 0 ; i < iKeys.Count(); i++) |
|
698 { |
|
699 const TDesC& label = iKeys[i]->Label(); |
|
700 TBool found = EFalse; |
|
701 for (TInt j = 0; j < iKeysListCount; j++) |
|
702 { |
|
703 if (aKeys[j]->CompareF(label) == KErrNone) |
|
704 { |
|
705 found = ETrue; |
|
706 break; |
|
707 } |
|
708 } |
|
709 if (!found) |
|
710 { |
|
711 return EFalse; |
|
712 } |
|
713 } |
|
714 return ETrue; |
|
715 } |
|
716 |
|
717 TBool CTestToolEngine::CompareWithExpectedStore(RPointerArray<HBufC>& aCerts) |
|
718 { |
|
719 TBool result = EFalse; |
|
720 TInt storeCount = iCertStore->CertStoreCount(); |
|
721 for (TInt i = 0; i < storeCount ; i++) |
|
722 { |
|
723 result = EFalse; |
|
724 MCTToken& token = (iCertStore->CertStore(i)).Token(); |
|
725 const TDesC& tmp = token.Label(); |
|
726 for (TInt j = 0; j < aCerts.Count(); j++) |
|
727 { |
|
728 if (tmp.CompareF(*aCerts[j]) == KErrNone) |
|
729 { |
|
730 result = ETrue; |
|
731 break; |
|
732 } |
|
733 } |
|
734 if (!result) |
|
735 { |
|
736 break; |
|
737 } |
|
738 } |
|
739 return result; |
|
740 } |
|
741 |
|
742 |
|
743 TBool CTestToolEngine::CompareWithExpectedStoreKey(RPointerArray<HBufC>& aKeys) |
|
744 { |
|
745 TBool result = EFalse; |
|
746 TInt storeCount = iKeyStore->KeyStoreCount(); |
|
747 for (TInt i = 0; i < storeCount ; i++) |
|
748 { |
|
749 result = EFalse; |
|
750 MCTToken& token = (iKeyStore->KeyStore(i)).Token(); |
|
751 const TDesC& tmp = token.Label(); |
|
752 for (TInt j = 0; j < aKeys.Count(); j++) |
|
753 { |
|
754 if (tmp.CompareF(*aKeys[j]) == KErrNone) |
|
755 { |
|
756 result = ETrue; |
|
757 break; |
|
758 } |
|
759 } |
|
760 if (!result) |
|
761 { |
|
762 break; |
|
763 } |
|
764 } |
|
765 return result; |
|
766 } |
|
767 |
|
768 |
|
769 |
|
770 TBool CTestToolEngine::VerifyTrust(TBool aTrust) |
|
771 { |
|
772 TBool result = EFalse; |
|
773 if (aTrust == iActualTrust) |
|
774 { |
|
775 result = ETrue; |
|
776 } |
|
777 else |
|
778 { |
|
779 result = EFalse; |
|
780 } |
|
781 return result; |
|
782 } |