|
1 /* |
|
2 * Copyright (c) 2006-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 * Rule-based plugin selector implementation |
|
16 * Rule-based plugin selector implementation |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 /** |
|
22 @file |
|
23 */ |
|
24 |
|
25 #include <cryptospi/ruleselector.h> |
|
26 #include <cryptospi/cryptoparams.h> |
|
27 #include "cryptospiutil.h" |
|
28 #include <cryptospi/cryptohashapi.h> |
|
29 #include <cryptospi/cryptorandomapi.h> |
|
30 #include "cryptosymmetriccipherapi.h" |
|
31 #include "cryptoasymmetriccipherapi.h" |
|
32 #include "cryptosignatureapi.h" |
|
33 #include "cryptokeyagreementapi.h" |
|
34 #include "cryptokeypairgeneratorapi.h" |
|
35 #include <cryptospi/pluginentrydef.h> |
|
36 #include <cryptospi/hashplugin.h> |
|
37 #include <cryptospi/randomplugin.h> |
|
38 #include "symmetriccipherplugin.h" |
|
39 #include "asymmetriccipherplugin.h" |
|
40 #include "signerplugin.h" |
|
41 #include "verifierplugin.h" |
|
42 #include "keyagreementplugin.h" |
|
43 #include "keypairgeneratorplugin.h" |
|
44 #include <cryptospi/cryptospidef.h> |
|
45 #include "cryptospiproperty.h" |
|
46 #include "rulecharacteristics.h" |
|
47 |
|
48 #ifdef SYMBIAN_SDP_IPSEC_VOIP_SUPPORT |
|
49 #include <cryptospi/cryptomacapi.h> |
|
50 #include <cryptospi/macplugin.h> |
|
51 #endif |
|
52 |
|
53 using namespace CryptoSpi; |
|
54 |
|
55 // |
|
56 // Implementation of a single selection rule content |
|
57 // |
|
58 |
|
59 EXPORT_C CSelectionRuleContent* CSelectionRuleContent::NewL(TUid aInterfaceScope, |
|
60 TUid aAlgorithmScope, |
|
61 CCryptoParam* aCharacteristicValue, |
|
62 TRuleOperator aOperator, |
|
63 TBool aIsOptional) |
|
64 { |
|
65 CSelectionRuleContent* self=new (ELeave) CSelectionRuleContent(aInterfaceScope, |
|
66 aAlgorithmScope, |
|
67 aCharacteristicValue, |
|
68 aOperator, |
|
69 aIsOptional); |
|
70 return self; |
|
71 } |
|
72 |
|
73 EXPORT_C CSelectionRuleContent::~CSelectionRuleContent() |
|
74 { |
|
75 delete iCharacteristicValue; |
|
76 } |
|
77 |
|
78 CSelectionRuleContent::CSelectionRuleContent(TUid aInterfaceScope, |
|
79 TUid aAlgorithmScope, |
|
80 CCryptoParam* aCharacteristicValue, |
|
81 TRuleOperator aOperator, |
|
82 TBool aIsOptional) |
|
83 :iInterfaceScope(aInterfaceScope), |
|
84 iAlgorithmScope(aAlgorithmScope), |
|
85 iCharacteristicValue(aCharacteristicValue), |
|
86 iOperator(aOperator), |
|
87 iIsOptional(aIsOptional) |
|
88 { |
|
89 } |
|
90 |
|
91 TUid CSelectionRuleContent::GetInterfaceScope() |
|
92 { |
|
93 return iInterfaceScope; |
|
94 } |
|
95 |
|
96 TUid CSelectionRuleContent::GetAlgorithmScope() |
|
97 { |
|
98 return iAlgorithmScope; |
|
99 } |
|
100 |
|
101 TInt CSelectionRuleContent::GetOperator() |
|
102 { |
|
103 return iOperator; |
|
104 } |
|
105 |
|
106 const CCryptoParam* CSelectionRuleContent::GetCharacteristicValue() |
|
107 { |
|
108 return iCharacteristicValue; |
|
109 } |
|
110 |
|
111 TBool CSelectionRuleContent::IsOptionalRule() |
|
112 { |
|
113 return iIsOptional; |
|
114 } |
|
115 |
|
116 |
|
117 // |
|
118 // Impplemetation of selection rule |
|
119 // |
|
120 |
|
121 EXPORT_C CSelectionRules* CSelectionRules::NewL() |
|
122 { |
|
123 CSelectionRules* self=new (ELeave) CSelectionRules(); |
|
124 return self; |
|
125 } |
|
126 |
|
127 |
|
128 EXPORT_C CSelectionRules::~CSelectionRules() |
|
129 { |
|
130 iRules.ResetAndDestroy(); |
|
131 } |
|
132 |
|
133 EXPORT_C void CSelectionRules::AddSelectionRuleL(CSelectionRuleContent* aSelectionRule) |
|
134 { |
|
135 TUid charUid = aSelectionRule->GetCharacteristicValue()->Uid(); |
|
136 TInt operator_r = aSelectionRule->GetOperator(); |
|
137 TInt type = aSelectionRule->GetCharacteristicValue()->Type(); |
|
138 |
|
139 switch (charUid.iUid) |
|
140 { |
|
141 case KInterfaceType: |
|
142 case KAlgorithmType: |
|
143 case KImplementationType: |
|
144 { |
|
145 if (type != CCryptoParam::EInt) |
|
146 { |
|
147 User::Leave(KErrArgument); |
|
148 } |
|
149 |
|
150 if (operator_r != EOpEqual && |
|
151 operator_r != EOpNotEqual) |
|
152 { |
|
153 User::Leave(KErrArgument); |
|
154 } |
|
155 |
|
156 break; |
|
157 } |
|
158 |
|
159 case KCreatorNameType: |
|
160 { |
|
161 if (type != CCryptoParam::EDesC16) |
|
162 { |
|
163 User::Leave(KErrArgument); |
|
164 } |
|
165 |
|
166 if (operator_r != EOpAscendingSort && |
|
167 operator_r != EOpDescendingSort && |
|
168 operator_r != EOpEqual && |
|
169 operator_r != EOpNotEqual) |
|
170 { |
|
171 User::Leave(KErrArgument); |
|
172 } |
|
173 |
|
174 break; |
|
175 } |
|
176 |
|
177 case KIsFIPSApprovedType: |
|
178 case KIsHardwareSupportedType: |
|
179 { |
|
180 if (type != CCryptoParam::EInt) |
|
181 { |
|
182 User::Leave(KErrArgument); |
|
183 } |
|
184 |
|
185 if (operator_r != EOpEqual && |
|
186 operator_r != EOpNotEqual) |
|
187 { |
|
188 User::Leave(KErrArgument); |
|
189 } |
|
190 |
|
191 break; |
|
192 } |
|
193 |
|
194 case KMaxConcurrencySupportedType: |
|
195 case KLatencyType: |
|
196 case KThroughputType: |
|
197 { |
|
198 if (type != CCryptoParam::EInt) |
|
199 { |
|
200 User::Leave(KErrArgument); |
|
201 } |
|
202 |
|
203 break; |
|
204 } |
|
205 |
|
206 default: |
|
207 { |
|
208 break; |
|
209 } |
|
210 }//switch (charUid.iUid) |
|
211 |
|
212 iRules.AppendL(aSelectionRule); |
|
213 } |
|
214 |
|
215 CSelectionRules::CSelectionRules() |
|
216 { |
|
217 } |
|
218 |
|
219 RPointerArray<CSelectionRuleContent>& CSelectionRules::GetSelectionRules() |
|
220 { |
|
221 return iRules; |
|
222 } |
|
223 |
|
224 |
|
225 // |
|
226 // Implementation of plugin selector |
|
227 // |
|
228 |
|
229 EXPORT_C CRuleSelector* CRuleSelector::NewL(CSelectionRules* aRules) |
|
230 { |
|
231 CRuleSelector* self = CRuleSelector::NewLC(aRules); |
|
232 CleanupStack::Pop(self); |
|
233 return self; |
|
234 } |
|
235 |
|
236 EXPORT_C CRuleSelector* CRuleSelector::NewLC(CSelectionRules* aRules) |
|
237 { |
|
238 CRuleSelector* self=new (ELeave) CRuleSelector(); |
|
239 CleanupStack::PushL(self); |
|
240 self->ConstructL(aRules); |
|
241 |
|
242 return self; |
|
243 } |
|
244 |
|
245 EXPORT_C CRuleSelector::~CRuleSelector() |
|
246 { |
|
247 delete iSelectionRules; |
|
248 |
|
249 TInt interfaceCount = sizeof(KInterfacesUids)/sizeof(KInterfacesUids[0]); |
|
250 |
|
251 //Loop through each Interface |
|
252 for (TInt i = 0; i < interfaceCount; ++i) |
|
253 { |
|
254 RPointerArray<CRulesCharacteristicsAndPluginName>** listA = iSelectedInterfaceCharacteristics_MapA.Find(KInterfacesUids[i].iUid); |
|
255 RPointerArray<CRulesCharacteristicsAndPluginName>** listB = iSelectedInterfaceCharacteristics_MapB.Find(KInterfacesUids[i].iUid); |
|
256 |
|
257 if (listA) |
|
258 { |
|
259 (*listA)->ResetAndDestroy(); |
|
260 delete *listA; |
|
261 } |
|
262 |
|
263 if (listB) |
|
264 { |
|
265 (*listB)->ResetAndDestroy(); |
|
266 delete *listB; |
|
267 } |
|
268 } |
|
269 |
|
270 iSelectedInterfaceCharacteristics_MapA.Close(); |
|
271 iSelectedInterfaceCharacteristics_MapB.Close(); |
|
272 |
|
273 iNextTryCharacteristicsIndex.Close(); |
|
274 |
|
275 //Unload the plugin DLLs and release the array |
|
276 TInt dllCount=iPluginDllList.Count(); |
|
277 for (TInt j=0;j<dllCount;j++) |
|
278 { |
|
279 iPluginDllList[j].Close(); |
|
280 } |
|
281 |
|
282 iPluginDllList.Close(); |
|
283 } |
|
284 |
|
285 CRuleSelector::CRuleSelector(): |
|
286 iUseMapAToFilter(ETrue), |
|
287 iToggleUseMap(ETrue) |
|
288 { |
|
289 } |
|
290 |
|
291 void CRuleSelector::ConstructL(CSelectionRules* aRules) |
|
292 { |
|
293 ConstructMapAL(); |
|
294 TInt interfaceCount = sizeof(KInterfacesUids)/sizeof(KInterfacesUids[0]); |
|
295 |
|
296 //Init the next index to try records |
|
297 for (TInt i=0;i < interfaceCount;i++) |
|
298 { |
|
299 iNextTryCharacteristicsIndex.InsertL(KInterfacesUids[i].iUid, 0); |
|
300 } |
|
301 |
|
302 //Build iSelectedInterfaceCharacteristicsMap according to the rules applied |
|
303 PerformFilterL(aRules); |
|
304 |
|
305 if (iUseMapAToFilter) |
|
306 { |
|
307 //NOTE: After each filtering, it will toggle the iUseMapAToFilter for next process |
|
308 |
|
309 //Set iActiveInterfaceCharacteristics_Map to use iSelectedInterfaceCharacteristicsMap |
|
310 iActiveInterfaceCharacteristics_Map = &iSelectedInterfaceCharacteristics_MapA; |
|
311 } |
|
312 else |
|
313 { |
|
314 //Set iActiveInterfaceCharacteristics_Map to use iSelectedInterfaceCharacteristics_MapB |
|
315 iActiveInterfaceCharacteristics_Map = &iSelectedInterfaceCharacteristics_MapB; |
|
316 } |
|
317 |
|
318 iSelectionRules = aRules; |
|
319 } |
|
320 |
|
321 void CRuleSelector::CreateHashL(CHash*& aHash, |
|
322 TUid aAlgorithmUid, |
|
323 TUid aOperationMode, |
|
324 const CKey* aKey, |
|
325 const CCryptoParams* aAlgorithmParams) |
|
326 { |
|
327 TInt found=KErrNone; |
|
328 TInt ret=KErrNone; |
|
329 |
|
330 SetSearchRecord(KHashInterfaceUid, 0); |
|
331 |
|
332 do |
|
333 { |
|
334 TUid implUid={0}; |
|
335 TFileName fileName; |
|
336 found=FindPlugin(KHashInterfaceUid, aAlgorithmUid, implUid, fileName); |
|
337 |
|
338 if (found==KErrNone) |
|
339 { |
|
340 //Load the dll and make the handle be sharable in the process |
|
341 RLibrary sharedLib; |
|
342 CryptoSpiUtil::LoadPluginDllLC(sharedLib, fileName); |
|
343 |
|
344 //look for the entry point |
|
345 CreateHashFuncL func=(CreateHashFuncL)sharedLib.Lookup(ECreateHashOrdinal); |
|
346 |
|
347 if (func) |
|
348 { |
|
349 //create the plugin |
|
350 MHash* hashPlugin=NULL; |
|
351 TRAP(ret, (func)(hashPlugin, implUid, aOperationMode, aKey, aAlgorithmParams)) |
|
352 if (ret!=KErrNone) |
|
353 { |
|
354 if (ret==KErrNoMemory) |
|
355 { |
|
356 User::Leave(ret); |
|
357 } |
|
358 CleanupStack::PopAndDestroy(&sharedLib); //sharedLib |
|
359 } |
|
360 else |
|
361 { |
|
362 CleanupClosePushL(*hashPlugin); |
|
363 aHash=CHash::NewL(hashPlugin, sharedLib.Handle()); |
|
364 CleanupStack::Pop(2, &sharedLib); //hashPlugin, sharedLib |
|
365 break; |
|
366 } |
|
367 } |
|
368 else |
|
369 { |
|
370 CleanupStack::PopAndDestroy(&sharedLib); //sharedLib |
|
371 } |
|
372 |
|
373 } |
|
374 } |
|
375 while (found!=KErrNotFound); |
|
376 |
|
377 User::LeaveIfError(ret); |
|
378 if (found!=KErrNone) |
|
379 { |
|
380 User::Leave(KErrNotSupported); |
|
381 } |
|
382 } |
|
383 |
|
384 #ifdef SYMBIAN_SDP_IPSEC_VOIP_SUPPORT |
|
385 |
|
386 void CRuleSelector::CreateHashL(CHash*& aHash, |
|
387 TUid aAlgorithmUid, |
|
388 const CCryptoParams* aAlgorithmParams) |
|
389 { |
|
390 TInt found=KErrNone; |
|
391 TInt ret=KErrNone; |
|
392 |
|
393 SetSearchRecord(KHashInterfaceUid, 0); |
|
394 |
|
395 do |
|
396 { |
|
397 TUid implUid={0}; |
|
398 TFileName fileName; |
|
399 found=FindPlugin(KHashInterfaceUid, aAlgorithmUid, implUid, fileName); |
|
400 |
|
401 if (found==KErrNone) |
|
402 { |
|
403 //Load the dll and make the handle be sharable in the process |
|
404 RLibrary sharedLib; |
|
405 CryptoSpiUtil::LoadPluginDllLC(sharedLib, fileName); |
|
406 |
|
407 //look for the entry point |
|
408 CreateHashFuncLv2 func=(CreateHashFuncLv2)sharedLib.Lookup(ECreateHashOrdinalv2); |
|
409 |
|
410 if (func) |
|
411 { |
|
412 //create the plugin |
|
413 MHash* hashPlugin=NULL; |
|
414 TRAP(ret, (func)(hashPlugin, implUid, aAlgorithmParams)) |
|
415 if (ret!=KErrNone) |
|
416 { |
|
417 if (ret==KErrNoMemory) |
|
418 { |
|
419 User::Leave(ret); |
|
420 } |
|
421 CleanupStack::PopAndDestroy(&sharedLib); //sharedLib |
|
422 } |
|
423 else |
|
424 { |
|
425 CleanupClosePushL(*hashPlugin); |
|
426 aHash=CHash::NewL(hashPlugin, sharedLib.Handle()); |
|
427 CleanupStack::Pop(2, &sharedLib); //hashPlugin, sharedLib |
|
428 break; |
|
429 } |
|
430 } |
|
431 else |
|
432 { |
|
433 CleanupStack::PopAndDestroy(&sharedLib); //sharedLib |
|
434 } |
|
435 |
|
436 } |
|
437 } |
|
438 while (found!=KErrNotFound); |
|
439 |
|
440 User::LeaveIfError(ret); |
|
441 if (found!=KErrNone) |
|
442 { |
|
443 User::Leave(KErrNotSupported); |
|
444 } |
|
445 } |
|
446 |
|
447 void CRuleSelector::CreateMacL(CMac*& aMac, const TUid aAlgorithmUid, const CKey& aKey, const CCryptoParams* aAlgorithmParams) |
|
448 { |
|
449 TInt found=KErrNone; |
|
450 TInt ret=KErrNone; |
|
451 |
|
452 /** |
|
453 * Reset the search record for the mentioned interface, so that search can start from |
|
454 * index 0. |
|
455 */ |
|
456 SetSearchRecord(KMacInterfaceUid, 0); |
|
457 |
|
458 /** |
|
459 * The following do-while block is a serach mechanism for the right algorithm implementation. |
|
460 * The block logic assumes the case when a user may define a very abstract level rule for |
|
461 * which there is several matches within an interface and across the interfaces meeting the |
|
462 * rule (both intra and inter interface match). |
|
463 * The block logic has support to counter attack the ambiguity passed on by the |
|
464 * user application when defining the rules for the rule based selector. |
|
465 */ |
|
466 do |
|
467 { |
|
468 TUid implUid={0}; |
|
469 TFileName fileName; |
|
470 |
|
471 /** |
|
472 * Here 'aAlgorithmUid' can be Hash Based or Cipher Based. |
|
473 * KAlgorithmCipherAesXcbcMac96, KAlgorithmCipherAesXcbcPrf128, KAlgorithmHashMd2 |
|
474 * etc... |
|
475 */ |
|
476 found=FindPlugin(KMacInterfaceUid, aAlgorithmUid, implUid, fileName); |
|
477 |
|
478 if (found==KErrNone) |
|
479 { |
|
480 //Load the dll and make the handle be sharable in the process |
|
481 RLibrary sharedLib; |
|
482 CryptoSpiUtil::LoadPluginDllLC(sharedLib, fileName); |
|
483 |
|
484 //look for the entry point in the plugin-dll. |
|
485 CreateMacFuncL func=(CreateMacFuncL)sharedLib.Lookup(ECreateMacOrdinal); |
|
486 |
|
487 if (func) |
|
488 { |
|
489 /** |
|
490 * The abstract base class interface to which the MAC implementation |
|
491 * will be plugged in. |
|
492 */ |
|
493 MMac* macPlugin=NULL; |
|
494 |
|
495 /** |
|
496 * Here 'implUid' will contain the implementation of the Hash Based or |
|
497 * Cipher Base algorithm (aAlgorithmUid) chosen by rule based selector. |
|
498 * One Algorithm can have various implementations provided by different vendors. |
|
499 * The choice of selection of the implementation will be dependent on the rule defined |
|
500 * by the user application which is passed to the rule based selector when initializing. |
|
501 * |
|
502 * KCryptoPluginMacAesXcbcMac96, KCryptoPluginMacAesXcbcPrf128, KCryptoPluginMacHashMd2 |
|
503 * etc... |
|
504 */ |
|
505 TRAP(ret, (func)(macPlugin, implUid, aKey, aAlgorithmParams)) |
|
506 |
|
507 if (ret!=KErrNone) |
|
508 { |
|
509 if (ret==KErrNoMemory) |
|
510 { |
|
511 User::Leave(ret); |
|
512 } |
|
513 CleanupStack::PopAndDestroy(&sharedLib); //sharedLib |
|
514 } |
|
515 else |
|
516 { |
|
517 CleanupClosePushL(*macPlugin); |
|
518 |
|
519 /** |
|
520 * Here an empty 'aMac' pointer delegated by the user application to the |
|
521 * CryptoSpi Framework is filled by the rule based selector. |
|
522 * Rule Based selector is part of the framework. |
|
523 */ |
|
524 |
|
525 aMac=CMac::NewL(macPlugin, sharedLib.Handle()); |
|
526 CleanupStack::Pop(2, &sharedLib); //macPlugin, sharedLib |
|
527 break; |
|
528 } |
|
529 } |
|
530 else |
|
531 { |
|
532 CleanupStack::PopAndDestroy(&sharedLib); //sharedLib |
|
533 } |
|
534 |
|
535 } |
|
536 } |
|
537 while (found!=KErrNotFound); |
|
538 |
|
539 User::LeaveIfError(ret); |
|
540 if (found!=KErrNone) |
|
541 { |
|
542 User::Leave(KErrNotSupported); |
|
543 } |
|
544 } |
|
545 |
|
546 #endif |
|
547 |
|
548 void CRuleSelector::CreateRandomL(CRandom*& aRandom, |
|
549 TUid aAlgorithmUid, |
|
550 const CCryptoParams* aAlgorithmParams) |
|
551 { |
|
552 TInt found=KErrNone; |
|
553 TInt ret=KErrNone; |
|
554 |
|
555 SetSearchRecord(KRandomInterfaceUid, 0); |
|
556 |
|
557 do |
|
558 { |
|
559 TFileName fileName; |
|
560 TUid implUid={0}; |
|
561 found=FindPlugin(KRandomInterfaceUid, aAlgorithmUid, implUid, fileName); |
|
562 |
|
563 |
|
564 if (found==KErrNone) |
|
565 { |
|
566 //Load the dll and make the handle be sharable in the process |
|
567 RLibrary sharedLib; |
|
568 CryptoSpiUtil::LoadPluginDllLC(sharedLib, fileName); |
|
569 |
|
570 //look for the entry point |
|
571 CreateRandomFuncL func=(CreateRandomFuncL)sharedLib.Lookup(ECreateRandomOrdinal); |
|
572 |
|
573 if (func) |
|
574 { |
|
575 //create the plugin |
|
576 MRandom* randomPlugin=NULL; |
|
577 TRAP(ret, (func)(randomPlugin, implUid, aAlgorithmParams)) |
|
578 if (ret!=KErrNone) |
|
579 { |
|
580 if (ret==KErrNoMemory) |
|
581 { |
|
582 User::Leave(ret); |
|
583 } |
|
584 CleanupStack::PopAndDestroy(&sharedLib); //sharedLib |
|
585 } |
|
586 else |
|
587 { |
|
588 CleanupClosePushL(*randomPlugin); |
|
589 aRandom=CRandom::NewL(randomPlugin, sharedLib.Handle()); |
|
590 CleanupStack::Pop(2, &sharedLib); //randomPlugin, sharedLib |
|
591 break; |
|
592 } |
|
593 } |
|
594 else |
|
595 { |
|
596 CleanupStack::PopAndDestroy(&sharedLib); //sharedLib |
|
597 } |
|
598 } |
|
599 } |
|
600 while (found!=KErrNotFound); |
|
601 |
|
602 User::LeaveIfError(ret); |
|
603 if (found!=KErrNone) |
|
604 { |
|
605 User::Leave(KErrNotSupported); |
|
606 } |
|
607 } |
|
608 |
|
609 void CRuleSelector::CreateSymmetricCipherL(CSymmetricCipher*& aCipher, |
|
610 TUid aAlgorithmUid, |
|
611 const CKey& aKey, |
|
612 TUid aCryptoMode, |
|
613 TUid aOperationMode, |
|
614 TUid aPaddingMode, |
|
615 const CCryptoParams* aAlgorithmParams) |
|
616 |
|
617 { |
|
618 TInt found=KErrNone; |
|
619 TInt ret=KErrNone; |
|
620 |
|
621 SetSearchRecord(KSymmetricCipherInterfaceUid, 0); |
|
622 |
|
623 do |
|
624 { |
|
625 TFileName fileName; |
|
626 TUid implUid={0}; |
|
627 found=FindPlugin(KSymmetricCipherInterfaceUid, aAlgorithmUid, implUid, fileName); |
|
628 |
|
629 if (found==KErrNone) |
|
630 { |
|
631 //Load the dll and make the handle be sharable in the process |
|
632 RLibrary sharedLib; |
|
633 CryptoSpiUtil::LoadPluginDllLC(sharedLib, fileName); |
|
634 |
|
635 //look for the entry point |
|
636 CreateSymmetricCipherFuncL func=(CreateSymmetricCipherFuncL)sharedLib.Lookup(ECreateSymmetricCipherOrdinal); |
|
637 |
|
638 if (func) |
|
639 { |
|
640 //create the plugin |
|
641 MSymmetricCipher* cipherPlugin=NULL; |
|
642 TRAP(ret, (func)(cipherPlugin, implUid, aKey, aCryptoMode, aOperationMode, aPaddingMode, aAlgorithmParams)) |
|
643 if (ret!=KErrNone) |
|
644 { |
|
645 if (ret==KErrNoMemory) |
|
646 { |
|
647 User::Leave(ret); |
|
648 } |
|
649 CleanupStack::PopAndDestroy(&sharedLib); //sharedLib |
|
650 } |
|
651 else |
|
652 { |
|
653 CleanupClosePushL(*cipherPlugin); |
|
654 aCipher=CSymmetricCipher::NewL(cipherPlugin, sharedLib.Handle()); |
|
655 CleanupStack::Pop(2, &sharedLib); //cipherPlugin, sharedLib |
|
656 break; |
|
657 } |
|
658 } |
|
659 else |
|
660 { |
|
661 CleanupStack::PopAndDestroy(&sharedLib); //sharedLib |
|
662 } |
|
663 } |
|
664 } |
|
665 while (found!=KErrNotFound); |
|
666 |
|
667 User::LeaveIfError(ret); |
|
668 if (found!=KErrNone) |
|
669 { |
|
670 User::Leave(KErrNotSupported); |
|
671 } |
|
672 } |
|
673 |
|
674 void CRuleSelector::CreateAsymmetricCipherL(CAsymmetricCipher*& aCipher, |
|
675 TUid aAlgorithmUid, |
|
676 const CKey& aKey, |
|
677 TUid aCryptoMode, |
|
678 TUid aPaddingMode, |
|
679 const CCryptoParams* aAlgorithmParams) |
|
680 { |
|
681 TInt found=KErrNone; |
|
682 TInt ret=KErrNone; |
|
683 |
|
684 SetSearchRecord(KAsymmetricCipherInterfaceUid, 0); |
|
685 |
|
686 do |
|
687 { |
|
688 TFileName fileName; |
|
689 TUid implUid={0}; |
|
690 found=FindPlugin(KAsymmetricCipherInterfaceUid, aAlgorithmUid, implUid, fileName); |
|
691 |
|
692 if (found==KErrNone) |
|
693 { |
|
694 //Load the dll and make the handle be sharable in the process |
|
695 RLibrary sharedLib; |
|
696 CryptoSpiUtil::LoadPluginDllLC(sharedLib, fileName); |
|
697 |
|
698 //look for the entry point |
|
699 CreateAsymmetricCipherFuncL func=(CreateAsymmetricCipherFuncL)sharedLib.Lookup(ECreateAsymmetricCipherOrdinal); |
|
700 |
|
701 if (func) |
|
702 { |
|
703 //create the plugin |
|
704 MAsymmetricCipher* cipherPlugin=NULL; |
|
705 TRAP(ret, (func)(cipherPlugin, implUid, aKey, aCryptoMode, aPaddingMode, aAlgorithmParams)) |
|
706 if (ret!=KErrNone) |
|
707 { |
|
708 if (ret==KErrNoMemory) |
|
709 { |
|
710 User::Leave(ret); |
|
711 } |
|
712 CleanupStack::PopAndDestroy(&sharedLib); //sharedLib |
|
713 } |
|
714 else |
|
715 { |
|
716 CleanupClosePushL(*cipherPlugin); |
|
717 aCipher=CAsymmetricCipher::NewL(cipherPlugin, sharedLib.Handle()); |
|
718 CleanupStack::Pop(2, &sharedLib); //cipherPlugin, sharedLib |
|
719 break; |
|
720 } |
|
721 } |
|
722 else |
|
723 { |
|
724 CleanupStack::PopAndDestroy(&sharedLib); //sharedLib |
|
725 } |
|
726 } |
|
727 } |
|
728 while (found!=KErrNotFound); |
|
729 |
|
730 User::LeaveIfError(ret); |
|
731 if (found!=KErrNone) |
|
732 { |
|
733 User::Leave(KErrNotSupported); |
|
734 } |
|
735 } |
|
736 |
|
737 void CRuleSelector::CreateSignerL(CSigner*& aSigner, |
|
738 TUid aAlgorithmUid, |
|
739 const CKey& aKey, |
|
740 TUid aPaddingMode, |
|
741 const CCryptoParams* aAlgorithmParams) |
|
742 { |
|
743 TInt found=KErrNone; |
|
744 TInt ret=KErrNone; |
|
745 |
|
746 SetSearchRecord(KSignerInterfaceUid, 0); |
|
747 |
|
748 do |
|
749 { |
|
750 TFileName fileName; |
|
751 TUid implUid={0}; |
|
752 found=FindPlugin(KSignerInterfaceUid, aAlgorithmUid, implUid, fileName); |
|
753 |
|
754 if (found==KErrNone) |
|
755 { |
|
756 //Load the dll and make the handle be sharable in the process |
|
757 RLibrary sharedLib; |
|
758 CryptoSpiUtil::LoadPluginDllLC(sharedLib, fileName); |
|
759 |
|
760 //look for the entry point |
|
761 CreateSignerFuncL func=(CreateSignerFuncL)sharedLib.Lookup(ECreateSignerOrdinal); |
|
762 if (func) |
|
763 { |
|
764 //create the plugin |
|
765 MSigner* plugin=NULL; |
|
766 TRAP(ret, (func)(plugin, implUid, aKey, aPaddingMode, aAlgorithmParams)) |
|
767 if (ret!=KErrNone) |
|
768 { |
|
769 if (ret==KErrNoMemory) |
|
770 { |
|
771 User::Leave(ret); |
|
772 } |
|
773 CleanupStack::PopAndDestroy(&sharedLib); //sharedLib |
|
774 } |
|
775 else |
|
776 { |
|
777 CleanupClosePushL(*plugin); |
|
778 aSigner=CSigner::NewL(plugin, sharedLib.Handle()); |
|
779 CleanupStack::Pop(2, &sharedLib); //plugin, sharedLib |
|
780 break; |
|
781 } |
|
782 } |
|
783 else |
|
784 { |
|
785 CleanupStack::PopAndDestroy(&sharedLib); //sharedLib |
|
786 } |
|
787 } |
|
788 } |
|
789 while (found!=KErrNotFound); |
|
790 |
|
791 User::LeaveIfError(ret); |
|
792 if (found!=KErrNone) |
|
793 { |
|
794 User::Leave(KErrNotSupported); |
|
795 } |
|
796 } |
|
797 |
|
798 void CRuleSelector::CreateVerifierL(CVerifier*& aVerifier, |
|
799 TUid aAlgorithmUid, |
|
800 const CKey& aKey, |
|
801 TUid aPaddingMode, |
|
802 const CCryptoParams* aAlgorithmParams) |
|
803 { |
|
804 TInt found=KErrNone; |
|
805 TInt ret=KErrNone; |
|
806 |
|
807 SetSearchRecord(KVerifierInterfaceUid, 0); |
|
808 |
|
809 do |
|
810 { |
|
811 TFileName fileName; |
|
812 TUid implUid={0}; |
|
813 found=FindPlugin(KVerifierInterfaceUid, aAlgorithmUid, implUid, fileName); |
|
814 |
|
815 if (found==KErrNone) |
|
816 { |
|
817 //Load the dll and make the handle be sharable in the process |
|
818 RLibrary sharedLib; |
|
819 CryptoSpiUtil::LoadPluginDllLC(sharedLib, fileName); |
|
820 |
|
821 //look for the entry point |
|
822 CreateVerifierFuncL func=(CreateVerifierFuncL)sharedLib.Lookup(ECreateVerifierOrdinal); |
|
823 |
|
824 if (func) |
|
825 { |
|
826 //create the plugin |
|
827 MVerifier* plugin=NULL; |
|
828 TRAP(ret, (func)(plugin, implUid, aKey, aPaddingMode, aAlgorithmParams)) |
|
829 if (ret!=KErrNone) |
|
830 { |
|
831 if (ret==KErrNoMemory) |
|
832 { |
|
833 User::Leave(ret); |
|
834 } |
|
835 CleanupStack::PopAndDestroy(&sharedLib); //sharedLib |
|
836 } |
|
837 else |
|
838 { |
|
839 CleanupClosePushL(*plugin); |
|
840 aVerifier=CVerifier::NewL(plugin, sharedLib.Handle()); |
|
841 CleanupStack::Pop(2, &sharedLib); //plugin, sharedLib |
|
842 break; |
|
843 } |
|
844 } |
|
845 else |
|
846 { |
|
847 CleanupStack::PopAndDestroy(&sharedLib); //sharedLib |
|
848 } |
|
849 } |
|
850 } |
|
851 while (found!=KErrNotFound); |
|
852 |
|
853 User::LeaveIfError(ret); |
|
854 if (found!=KErrNone) |
|
855 { |
|
856 User::Leave(KErrNotSupported); |
|
857 } |
|
858 } |
|
859 |
|
860 void CRuleSelector::CreateKeyPairGeneratorL(CKeyPairGenerator*& aKeyPairGenerator, |
|
861 TUid aAlgorithmUid, |
|
862 const CCryptoParams* aAlgorithmParams) |
|
863 { |
|
864 TInt found=KErrNone; |
|
865 TInt ret=KErrNone; |
|
866 |
|
867 SetSearchRecord(KKeypairGeneratorInterfaceUid, 0); |
|
868 |
|
869 do |
|
870 { |
|
871 TFileName fileName; |
|
872 TUid implUid={0}; |
|
873 found=FindPlugin(KKeypairGeneratorInterfaceUid, aAlgorithmUid, implUid, fileName); |
|
874 if (found==KErrNone) |
|
875 { |
|
876 //Load the dll and make the handle be sharable in the process |
|
877 RLibrary sharedLib; |
|
878 CryptoSpiUtil::LoadPluginDllLC(sharedLib, fileName); |
|
879 |
|
880 //look for the entry point |
|
881 CreateKeyPairGeneratorFuncL func=(CreateKeyPairGeneratorFuncL)sharedLib.Lookup(ECreateKeyPairGeneratorOrdinal); |
|
882 if (func) |
|
883 { |
|
884 //create the plugin |
|
885 MKeyPairGenerator* plugin=NULL; |
|
886 TRAP(ret, (func)(plugin, implUid, aAlgorithmParams)) |
|
887 if (ret!=KErrNone) |
|
888 { |
|
889 if (ret==KErrNoMemory) |
|
890 { |
|
891 User::Leave(ret); |
|
892 } |
|
893 CleanupStack::PopAndDestroy(&sharedLib); //sharedLib |
|
894 } |
|
895 else |
|
896 { |
|
897 CleanupClosePushL(*plugin); |
|
898 aKeyPairGenerator=CKeyPairGenerator::NewL(plugin, sharedLib.Handle()); |
|
899 CleanupStack::Pop(2, &sharedLib); //plugin, sharedLib |
|
900 break; |
|
901 } |
|
902 } |
|
903 else |
|
904 { |
|
905 CleanupStack::PopAndDestroy(&sharedLib); //sharedLib |
|
906 } |
|
907 } |
|
908 } |
|
909 while (found!=KErrNotFound); |
|
910 |
|
911 User::LeaveIfError(ret); |
|
912 if (found!=KErrNone) |
|
913 { |
|
914 User::Leave(KErrNotSupported); |
|
915 } |
|
916 } |
|
917 |
|
918 void CRuleSelector::CreateKeyAgreementL(CKeyAgreement*& aKeyAgreement, |
|
919 TUid aAlgorithmUid, |
|
920 const CKey& aPrivateKey, |
|
921 const CCryptoParams* aAlgorithmParams) |
|
922 { |
|
923 TInt found=KErrNone; |
|
924 TInt ret=KErrNone; |
|
925 |
|
926 SetSearchRecord(KKeyAgreementInterfaceUid, 0); |
|
927 |
|
928 do |
|
929 { |
|
930 TFileName fileName; |
|
931 TUid implUid={0}; |
|
932 found=FindPlugin(KKeyAgreementInterfaceUid, aAlgorithmUid, implUid, fileName); |
|
933 if (found==KErrNone) |
|
934 { |
|
935 //Load the dll and make the handle be sharable in the process |
|
936 RLibrary sharedLib; |
|
937 CryptoSpiUtil::LoadPluginDllLC(sharedLib, fileName); |
|
938 |
|
939 //look for the entry point |
|
940 CreateKeyAgreementFuncL func=(CreateKeyAgreementFuncL)sharedLib.Lookup(ECreateKeyAgreementOrdinal); |
|
941 if (func) |
|
942 { |
|
943 //create the plugin |
|
944 MKeyAgreement* plugin=NULL; |
|
945 TRAP(ret, (func)(plugin, implUid, aPrivateKey, aAlgorithmParams)) |
|
946 if (ret!=KErrNone) |
|
947 { |
|
948 if (ret==KErrNoMemory) |
|
949 { |
|
950 User::Leave(ret); |
|
951 } |
|
952 CleanupStack::PopAndDestroy(&sharedLib); //sharedLib |
|
953 } |
|
954 else |
|
955 { |
|
956 CleanupClosePushL(*plugin); |
|
957 aKeyAgreement=CKeyAgreement::NewL(plugin, sharedLib.Handle()); |
|
958 CleanupStack::Pop(2, &sharedLib); //plugin, sharedLib |
|
959 break; |
|
960 } |
|
961 } |
|
962 else |
|
963 { |
|
964 CleanupStack::PopAndDestroy(&sharedLib); //sharedLib |
|
965 } |
|
966 } |
|
967 } |
|
968 while (found!=KErrNotFound); |
|
969 |
|
970 User::LeaveIfError(ret); |
|
971 if (found!=KErrNone) |
|
972 { |
|
973 User::Leave(KErrNotSupported); |
|
974 } |
|
975 } |
|
976 |
|
977 void CRuleSelector::PerformFilterL(CSelectionRules* aRules) |
|
978 { |
|
979 const RPointerArray<CSelectionRuleContent>& rules = aRules->GetSelectionRules(); |
|
980 const RHashMap<TInt32, RPointerArray<CRulesCharacteristicsAndPluginName>*>* interfaceCharMap = NULL; |
|
981 TInt rCount = rules.Count(); |
|
982 |
|
983 //Iterate through each rule |
|
984 for (TInt r = 0; r < rCount; ++r) |
|
985 { |
|
986 if (iUseMapAToFilter) |
|
987 { |
|
988 interfaceCharMap = &iSelectedInterfaceCharacteristics_MapA; |
|
989 } |
|
990 else |
|
991 { |
|
992 interfaceCharMap = &iSelectedInterfaceCharacteristics_MapB; |
|
993 } |
|
994 |
|
995 TInt32 interfaceScope = rules[r]->GetInterfaceScope().iUid; |
|
996 TInt interfaceCount = sizeof(KInterfacesUids)/sizeof(KInterfacesUids[0]); |
|
997 TInt operator_r = rules[r]->GetOperator(); |
|
998 |
|
999 if (operator_r == EOpAscendingSort || operator_r == EOpDescendingSort) |
|
1000 { |
|
1001 /** |
|
1002 This is use to indicate don't alternate the map for this rule filtering |
|
1003 */ |
|
1004 iToggleUseMap = EFalse; |
|
1005 } |
|
1006 |
|
1007 for (TInt i = 0; i < interfaceCount; ++i) |
|
1008 { |
|
1009 //Loop through each Interface |
|
1010 |
|
1011 TInt lastPreference =0; //Indicate the list position of the last algorithm that met the rules |
|
1012 RPointerArray<CRulesCharacteristicsAndPluginName>* const* list = interfaceCharMap->Find(KInterfacesUids[i].iUid); |
|
1013 |
|
1014 if (list) |
|
1015 { |
|
1016 while ((*list)->Count()) |
|
1017 { |
|
1018 //Loop through each algorithm's characteristics list |
|
1019 |
|
1020 if (interfaceScope == 0) |
|
1021 { |
|
1022 PerformAlgorithmFilterL(KInterfacesUids[i].iUid, **list, |
|
1023 rules[r], lastPreference); |
|
1024 }//if (interfaceScope == 0) |
|
1025 else |
|
1026 { |
|
1027 //This is an Interface rule |
|
1028 |
|
1029 if (interfaceScope == KInterfacesUids[i].iUid) |
|
1030 { |
|
1031 PerformAlgorithmFilterL(KInterfacesUids[i].iUid, **list, |
|
1032 rules[r], lastPreference); |
|
1033 } |
|
1034 else |
|
1035 { |
|
1036 //Not within the specified interfaceScope, just build it to the |
|
1037 //end of iSelectedInterfaceCharacteristicsMap |
|
1038 AddOptionalToCharListL(KInterfacesUids[i].iUid, *(**list)[0]); |
|
1039 } |
|
1040 } |
|
1041 |
|
1042 if (!iToggleUseMap) |
|
1043 { |
|
1044 //Just sorted the list, so skip the rest of the algorithms and |
|
1045 //continue with next interface list |
|
1046 break; |
|
1047 } |
|
1048 |
|
1049 //Remove from source list". As it has either been deleted or transfered to the new list. |
|
1050 (*list)->Remove(0); |
|
1051 |
|
1052 }//while ((*list)->Count()) |
|
1053 } //if (list) |
|
1054 else |
|
1055 { |
|
1056 //No CCharacteristicDllIndexList found!!!! |
|
1057 //It is possible; KKeyGeneratorInterfaceUid is currently not in used. |
|
1058 //Do nothing |
|
1059 } |
|
1060 }//for (TInt i = 0; i < NumberOfIntefaces; ++i) |
|
1061 |
|
1062 if (iToggleUseMap) |
|
1063 { |
|
1064 if (iUseMapAToFilter) |
|
1065 { |
|
1066 //Toggle to use iSelectedInterfaceCharacteristics_MapB on next round |
|
1067 iUseMapAToFilter = EFalse; |
|
1068 TInt interfaceCount = sizeof(KInterfacesUids)/sizeof(KInterfacesUids[0]); |
|
1069 |
|
1070 //Destroy the characteristic map and lists for the next filtering process |
|
1071 for (TInt i = 0; i < interfaceCount; ++i) |
|
1072 { |
|
1073 RPointerArray<CRulesCharacteristicsAndPluginName>** listA = iSelectedInterfaceCharacteristics_MapA.Find(KInterfacesUids[i].iUid); |
|
1074 |
|
1075 if (listA) |
|
1076 { |
|
1077 (*listA)->ResetAndDestroy(); |
|
1078 delete *listA; |
|
1079 } |
|
1080 } |
|
1081 |
|
1082 iSelectedInterfaceCharacteristics_MapA.Close(); |
|
1083 } |
|
1084 else |
|
1085 { |
|
1086 //Toggle to use iSelectedInterfaceCharacteristicsMap on next round |
|
1087 iUseMapAToFilter = ETrue; |
|
1088 TInt interfaceCount = sizeof(KInterfacesUids)/sizeof(KInterfacesUids[0]); |
|
1089 |
|
1090 //Destroy the characteristic map and lists for the next filtering process |
|
1091 for (TInt i = 0; i < interfaceCount; ++i) |
|
1092 { |
|
1093 RPointerArray<CRulesCharacteristicsAndPluginName>** listB = iSelectedInterfaceCharacteristics_MapB.Find(KInterfacesUids[i].iUid); |
|
1094 |
|
1095 if (listB) |
|
1096 { |
|
1097 (*listB)->ResetAndDestroy(); |
|
1098 delete *listB; |
|
1099 } |
|
1100 } |
|
1101 |
|
1102 iSelectedInterfaceCharacteristics_MapB.Close(); |
|
1103 } |
|
1104 } |
|
1105 else |
|
1106 { |
|
1107 //Just finished sorting, reuse the same map for next round |
|
1108 //reset iToggleUseMap for next round |
|
1109 iToggleUseMap = ETrue; |
|
1110 } |
|
1111 }//for (TInt r = 0; r < rules.Count(); ++r) |
|
1112 } |
|
1113 |
|
1114 void CRuleSelector::PerformAlgorithmFilterL(TInt32 aInterfaceUid, RPointerArray<CRulesCharacteristicsAndPluginName>& aCharacteristicsDLL, |
|
1115 CSelectionRuleContent* aRules, TInt& aLastPreference) |
|
1116 { |
|
1117 if (aRules->GetAlgorithmScope().iUid == 0) |
|
1118 { |
|
1119 if (EFalse == FilterCommonCharacteristicsL(aInterfaceUid, aCharacteristicsDLL, |
|
1120 aRules, aLastPreference)) |
|
1121 { |
|
1122 //NOT FOUND! Need to go through each non-common characteristics |
|
1123 if (EFalse == FilterNonCommonCharacteristicsL(aInterfaceUid, aCharacteristicsDLL, |
|
1124 aRules, aLastPreference)) |
|
1125 { |
|
1126 if (EFalse == FilterExtendedCharacteristicsL(aInterfaceUid, aCharacteristicsDLL, |
|
1127 aRules, aLastPreference)) |
|
1128 { |
|
1129 //Try adding it as optional |
|
1130 TryAddToOptionalCharListL(aInterfaceUid, *(aCharacteristicsDLL[0]), aRules); |
|
1131 } |
|
1132 } |
|
1133 } |
|
1134 } |
|
1135 else |
|
1136 { |
|
1137 //This is an Algorithm rule |
|
1138 const CCharacteristics* cmn(aCharacteristicsDLL[0]->iCharacteristic); |
|
1139 |
|
1140 if (aRules->GetAlgorithmScope().iUid == cmn->iAlgorithmUid) |
|
1141 { |
|
1142 //Matches the algorithmScope |
|
1143 if (EFalse == FilterCommonCharacteristicsL(aInterfaceUid, aCharacteristicsDLL, |
|
1144 aRules, aLastPreference)) |
|
1145 { |
|
1146 //NOT FOUND! Need to go through each non-common characteristics |
|
1147 if (EFalse == FilterNonCommonCharacteristicsL(aInterfaceUid, aCharacteristicsDLL, |
|
1148 aRules, aLastPreference)) |
|
1149 { |
|
1150 if (EFalse == FilterExtendedCharacteristicsL(aInterfaceUid, aCharacteristicsDLL, |
|
1151 aRules, aLastPreference)) |
|
1152 { |
|
1153 //Try adding it as optional |
|
1154 TryAddToOptionalCharListL(aInterfaceUid, *(aCharacteristicsDLL[0]), aRules); |
|
1155 } |
|
1156 } |
|
1157 } |
|
1158 } |
|
1159 else |
|
1160 { |
|
1161 //Not within the algorithmScope, just build it to the end of |
|
1162 //iSelectedInterfaceCharacteristicsMap |
|
1163 AddOptionalToCharListL(aInterfaceUid, *(aCharacteristicsDLL[0])); |
|
1164 } |
|
1165 } |
|
1166 } |
|
1167 |
|
1168 TBool CRuleSelector::FilterCommonCharacteristicsL(TInt32 aInterfaceUid, RPointerArray<CRulesCharacteristicsAndPluginName>& aCharacteristicsDLL, |
|
1169 CSelectionRuleContent* aRules, TInt& aLastPreference) |
|
1170 { |
|
1171 const CCharacteristics* cmn(aCharacteristicsDLL[0]->iCharacteristic); |
|
1172 const CCryptoParam* charValue = aRules->GetCharacteristicValue(); |
|
1173 |
|
1174 switch (charValue->Uid().iUid) |
|
1175 { |
|
1176 case KInterfaceType: |
|
1177 { |
|
1178 FilterTInt32L(aInterfaceUid, *(aCharacteristicsDLL[0]), |
|
1179 aRules, aLastPreference, cmn->iInterfaceUid); |
|
1180 break; |
|
1181 } |
|
1182 |
|
1183 case KAlgorithmType: |
|
1184 { |
|
1185 FilterTInt32L(aInterfaceUid, *(aCharacteristicsDLL[0]), |
|
1186 aRules, aLastPreference, cmn->iAlgorithmUid); |
|
1187 break; |
|
1188 } |
|
1189 |
|
1190 case KImplementationType: |
|
1191 { |
|
1192 FilterTInt32L(aInterfaceUid, *(aCharacteristicsDLL[0]), |
|
1193 aRules, aLastPreference, cmn->iImplementationUid); |
|
1194 break; |
|
1195 } |
|
1196 |
|
1197 case KCreatorNameType: |
|
1198 { |
|
1199 FilterCreatorNameL(aInterfaceUid, aCharacteristicsDLL, |
|
1200 aRules, aLastPreference); |
|
1201 break; |
|
1202 } |
|
1203 |
|
1204 case KIsFIPSApprovedType: |
|
1205 { |
|
1206 FilterTBoolL(aInterfaceUid, *(aCharacteristicsDLL[0]), |
|
1207 aRules, aLastPreference, cmn->iIsFIPSApproved); |
|
1208 break; |
|
1209 } |
|
1210 |
|
1211 case KIsHardwareSupportedType: |
|
1212 { |
|
1213 FilterTBoolL(aInterfaceUid, *(aCharacteristicsDLL[0]), |
|
1214 aRules, aLastPreference, cmn->iIsHardwareSupported); |
|
1215 break; |
|
1216 } |
|
1217 |
|
1218 case KMaxConcurrencySupportedType: |
|
1219 { |
|
1220 FilterTIntL(aInterfaceUid, aCharacteristicsDLL, |
|
1221 aRules, aLastPreference, cmn->iMaxConcurrencySupported); |
|
1222 break; |
|
1223 } |
|
1224 |
|
1225 case KLatencyType: |
|
1226 { |
|
1227 FilterTIntL(aInterfaceUid, aCharacteristicsDLL, |
|
1228 aRules, aLastPreference, cmn->iLatency); |
|
1229 break; |
|
1230 } |
|
1231 |
|
1232 case KThroughputType: |
|
1233 { |
|
1234 FilterTIntL(aInterfaceUid, aCharacteristicsDLL, |
|
1235 aRules, aLastPreference, cmn->iThroughput); |
|
1236 break; |
|
1237 } |
|
1238 |
|
1239 default: |
|
1240 { |
|
1241 //This is not a Common Characteristic |
|
1242 return EFalse; |
|
1243 } |
|
1244 } //switch (charValue->Uid().iUid) |
|
1245 |
|
1246 return ETrue; |
|
1247 } |
|
1248 |
|
1249 TBool CRuleSelector::FilterNonCommonCharacteristicsL(TInt32 aInterfaceUid, RPointerArray<CRulesCharacteristicsAndPluginName>& aCharacteristicsDLL, |
|
1250 CSelectionRuleContent* aRules, TInt& aLastPreference) |
|
1251 { |
|
1252 const CCryptoParam* ruleCharValue = aRules->GetCharacteristicValue(); |
|
1253 |
|
1254 switch (ruleCharValue->Uid().iUid) |
|
1255 { |
|
1256 case KBlockSizeType: |
|
1257 { |
|
1258 switch (aInterfaceUid) |
|
1259 { |
|
1260 case KHashInterface: |
|
1261 case KAsyncHashInterface: |
|
1262 { |
|
1263 const CHashCharacteristics* charsPtr(static_cast<const CHashCharacteristics*>( |
|
1264 aCharacteristicsDLL[0]->iCharacteristic)); |
|
1265 |
|
1266 FilterTIntL(aInterfaceUid, aCharacteristicsDLL, |
|
1267 aRules, aLastPreference, charsPtr->iBlockSize); |
|
1268 |
|
1269 return ETrue; |
|
1270 } |
|
1271 case KSymmetricCipherInterface: |
|
1272 case KAsyncSymmetricCipherInterface: |
|
1273 { |
|
1274 const CSymmetricCipherCharacteristics* charsPtr(static_cast<const CSymmetricCipherCharacteristics*>( |
|
1275 aCharacteristicsDLL[0]->iCharacteristic)); |
|
1276 |
|
1277 FilterTIntL(aInterfaceUid, aCharacteristicsDLL, |
|
1278 aRules, aLastPreference, charsPtr->iBlockSize); |
|
1279 |
|
1280 return ETrue; |
|
1281 } |
|
1282 |
|
1283 default: |
|
1284 { |
|
1285 break; |
|
1286 } |
|
1287 }//switch (aInterfaceUid) |
|
1288 |
|
1289 break; |
|
1290 } |
|
1291 |
|
1292 case KOutputSizeType: |
|
1293 { |
|
1294 switch (aInterfaceUid) |
|
1295 { |
|
1296 case KHashInterface: |
|
1297 case KAsyncHashInterface: |
|
1298 { |
|
1299 const CHashCharacteristics* charsPtr(static_cast<const CHashCharacteristics*>( |
|
1300 aCharacteristicsDLL[0]->iCharacteristic)); |
|
1301 |
|
1302 FilterTIntL(aInterfaceUid, aCharacteristicsDLL, |
|
1303 aRules, aLastPreference, charsPtr->iOutputSize); |
|
1304 |
|
1305 return ETrue; |
|
1306 } |
|
1307 |
|
1308 default: |
|
1309 { |
|
1310 break; |
|
1311 } |
|
1312 }//switch (aInterfaceUid) |
|
1313 |
|
1314 break; |
|
1315 } |
|
1316 |
|
1317 case KSupportedOperationModesType: |
|
1318 { |
|
1319 switch (aInterfaceUid) |
|
1320 { |
|
1321 case KHashInterface: |
|
1322 case KAsyncHashInterface: |
|
1323 { |
|
1324 const CHashCharacteristics* charsPtr(static_cast<const CHashCharacteristics*>( |
|
1325 aCharacteristicsDLL[0]->iCharacteristic)); |
|
1326 |
|
1327 TUid uid = { ((CCryptoIntParam*)ruleCharValue)->Value() }; |
|
1328 |
|
1329 TBool supported = charsPtr->IsOperationModeSupported(uid); |
|
1330 |
|
1331 FilterMultiTInt32L(aInterfaceUid, *(aCharacteristicsDLL[0]), aRules, |
|
1332 aLastPreference, supported); |
|
1333 |
|
1334 return ETrue; |
|
1335 } |
|
1336 |
|
1337 case KSymmetricCipherInterface: |
|
1338 case KAsyncSymmetricCipherInterface: |
|
1339 { |
|
1340 const CSymmetricCipherCharacteristics* charsPtr(static_cast<const CSymmetricCipherCharacteristics*>( |
|
1341 aCharacteristicsDLL[0]->iCharacteristic)); |
|
1342 |
|
1343 TUid uid = { ((CCryptoIntParam*)ruleCharValue)->Value() }; |
|
1344 |
|
1345 TBool supported = charsPtr->IsOperationModeSupported(uid); |
|
1346 |
|
1347 FilterMultiTInt32L(aInterfaceUid, *(aCharacteristicsDLL[0]), aRules, |
|
1348 aLastPreference, supported); |
|
1349 |
|
1350 return ETrue; |
|
1351 } |
|
1352 |
|
1353 default: |
|
1354 { |
|
1355 break; |
|
1356 } |
|
1357 }//switch (aInterfaceUid) |
|
1358 |
|
1359 break; |
|
1360 } |
|
1361 |
|
1362 case KBlockingModeType: |
|
1363 { |
|
1364 switch (aInterfaceUid) |
|
1365 { |
|
1366 case KRandomInterface: |
|
1367 case KAsyncRandomInterface: |
|
1368 { |
|
1369 const CRandomCharacteristics* charsPtr(static_cast<const CRandomCharacteristics*>( |
|
1370 aCharacteristicsDLL[0]->iCharacteristic)); |
|
1371 |
|
1372 FilterTIntL(aInterfaceUid, aCharacteristicsDLL, |
|
1373 aRules, aLastPreference, charsPtr->iBlockingMode); |
|
1374 |
|
1375 return ETrue; |
|
1376 } |
|
1377 |
|
1378 default: |
|
1379 { |
|
1380 break; |
|
1381 } |
|
1382 }//switch (aInterfaceUid) |
|
1383 |
|
1384 break; |
|
1385 } |
|
1386 |
|
1387 case KMaximumKeyLengthType: |
|
1388 { |
|
1389 switch (aInterfaceUid) |
|
1390 { |
|
1391 case KSymmetricCipherInterface: |
|
1392 case KAsyncSymmetricCipherInterface: |
|
1393 { |
|
1394 const CSymmetricCipherCharacteristics* charsPtr(static_cast<const CSymmetricCipherCharacteristics*>( |
|
1395 aCharacteristicsDLL[0]->iCharacteristic)); |
|
1396 |
|
1397 FilterTIntL(aInterfaceUid, aCharacteristicsDLL, |
|
1398 aRules, aLastPreference, charsPtr->iMaximumKeyLength); |
|
1399 |
|
1400 return ETrue; |
|
1401 } |
|
1402 |
|
1403 case KAsymmetricCipherInterface: |
|
1404 case KAsyncAsymmetricCipherInterface: |
|
1405 { |
|
1406 const CAsymmetricCipherCharacteristics* charsPtr(static_cast<const CAsymmetricCipherCharacteristics*>( |
|
1407 aCharacteristicsDLL[0]->iCharacteristic)); |
|
1408 |
|
1409 FilterTIntL(aInterfaceUid, aCharacteristicsDLL, |
|
1410 aRules, aLastPreference, charsPtr->iMaximumKeyLength); |
|
1411 |
|
1412 return ETrue; |
|
1413 } |
|
1414 |
|
1415 case KSignerInterface: |
|
1416 case KAsyncSignerInterface: |
|
1417 case KVerifierInterface: |
|
1418 case KAsyncVerifierInterface: |
|
1419 { |
|
1420 const CAsymmetricSignatureCharacteristics* charsPtr(static_cast<const CAsymmetricSignatureCharacteristics*>( |
|
1421 aCharacteristicsDLL[0]->iCharacteristic)); |
|
1422 |
|
1423 FilterTIntL(aInterfaceUid, aCharacteristicsDLL, |
|
1424 aRules, aLastPreference, charsPtr->iMaximumKeyLength); |
|
1425 |
|
1426 return ETrue; |
|
1427 } |
|
1428 |
|
1429 case KKeypairGeneratorInterface: |
|
1430 case KAsyncKeypairGeneratorInterface: |
|
1431 { |
|
1432 const CKeypairGeneratorCharacteristics* charsPtr(static_cast<const CKeypairGeneratorCharacteristics*>( |
|
1433 aCharacteristicsDLL[0]->iCharacteristic)); |
|
1434 |
|
1435 FilterTIntL(aInterfaceUid, aCharacteristicsDLL, |
|
1436 aRules, aLastPreference, charsPtr->iMaximumKeyLength); |
|
1437 |
|
1438 return ETrue; |
|
1439 } |
|
1440 |
|
1441 default: |
|
1442 { |
|
1443 break; |
|
1444 } |
|
1445 }//switch (aInterfaceUid) |
|
1446 |
|
1447 break; |
|
1448 } |
|
1449 |
|
1450 case KSupportedPaddingModesType: |
|
1451 { |
|
1452 switch (aInterfaceUid) |
|
1453 { |
|
1454 case KSymmetricCipherInterface: |
|
1455 case KAsyncSymmetricCipherInterface: |
|
1456 { |
|
1457 const CSymmetricCipherCharacteristics* charsPtr(static_cast<const CSymmetricCipherCharacteristics*>( |
|
1458 aCharacteristicsDLL[0]->iCharacteristic)); |
|
1459 |
|
1460 TUid uid = { ((CCryptoIntParam*)ruleCharValue)->Value() }; |
|
1461 |
|
1462 TBool supported = charsPtr->IsPaddingModeSupported(uid); |
|
1463 |
|
1464 FilterMultiTInt32L(aInterfaceUid, *(aCharacteristicsDLL[0]), aRules, |
|
1465 aLastPreference, supported); |
|
1466 |
|
1467 return ETrue; |
|
1468 } |
|
1469 |
|
1470 |
|
1471 case KAsymmetricCipherInterface: |
|
1472 case KAsyncAsymmetricCipherInterface: |
|
1473 { |
|
1474 const CAsymmetricCipherCharacteristics* charsPtr(static_cast<const CAsymmetricCipherCharacteristics*>( |
|
1475 aCharacteristicsDLL[0]->iCharacteristic)); |
|
1476 |
|
1477 TUid uid = { ((CCryptoIntParam*)ruleCharValue)->Value() }; |
|
1478 |
|
1479 TBool supported = charsPtr->IsPaddingModeSupported(uid); |
|
1480 |
|
1481 FilterMultiTInt32L(aInterfaceUid, *(aCharacteristicsDLL[0]), aRules, |
|
1482 aLastPreference, supported); |
|
1483 |
|
1484 return ETrue; |
|
1485 } |
|
1486 |
|
1487 case KSignerInterface: |
|
1488 case KAsyncSignerInterface: |
|
1489 case KVerifierInterface: |
|
1490 case KAsyncVerifierInterface: |
|
1491 { |
|
1492 const CAsymmetricSignatureCharacteristics* charsPtr(static_cast<const CAsymmetricSignatureCharacteristics*>( |
|
1493 aCharacteristicsDLL[0]->iCharacteristic)); |
|
1494 |
|
1495 TUid uid = { ((CCryptoIntParam*)ruleCharValue)->Value() }; |
|
1496 |
|
1497 TBool supported = charsPtr->IsPaddingModeSupported(uid); |
|
1498 |
|
1499 FilterMultiTInt32L(aInterfaceUid, *(aCharacteristicsDLL[0]), aRules, |
|
1500 aLastPreference, supported); |
|
1501 |
|
1502 return ETrue; |
|
1503 } |
|
1504 |
|
1505 default: |
|
1506 { |
|
1507 break; |
|
1508 } |
|
1509 }//switch (aInterfaceUid) |
|
1510 |
|
1511 break; |
|
1512 } |
|
1513 |
|
1514 case KKeySupportModeType: |
|
1515 { |
|
1516 switch (aInterfaceUid) |
|
1517 { |
|
1518 case KSymmetricCipherInterface: |
|
1519 case KAsyncSymmetricCipherInterface: |
|
1520 { |
|
1521 const CSymmetricCipherCharacteristics* charsPtr(static_cast<const CSymmetricCipherCharacteristics*>( |
|
1522 aCharacteristicsDLL[0]->iCharacteristic)); |
|
1523 |
|
1524 FilterTIntL(aInterfaceUid, aCharacteristicsDLL, |
|
1525 aRules, aLastPreference, charsPtr->iKeySupportMode); |
|
1526 |
|
1527 return ETrue; |
|
1528 } |
|
1529 |
|
1530 case KAsymmetricCipherInterface: |
|
1531 case KAsyncAsymmetricCipherInterface: |
|
1532 { |
|
1533 const CAsymmetricCipherCharacteristics* charsPtr(static_cast<const CAsymmetricCipherCharacteristics*>( |
|
1534 aCharacteristicsDLL[0]->iCharacteristic)); |
|
1535 |
|
1536 FilterTIntL(aInterfaceUid, aCharacteristicsDLL, |
|
1537 aRules, aLastPreference, charsPtr->iKeySupportMode); |
|
1538 |
|
1539 return ETrue; |
|
1540 } |
|
1541 |
|
1542 case KSignerInterface: |
|
1543 case KAsyncSignerInterface: |
|
1544 case KVerifierInterface: |
|
1545 case KAsyncVerifierInterface: |
|
1546 { |
|
1547 const CAsymmetricSignatureCharacteristics* charsPtr(static_cast<const CAsymmetricSignatureCharacteristics*>( |
|
1548 aCharacteristicsDLL[0]->iCharacteristic)); |
|
1549 |
|
1550 FilterTIntL(aInterfaceUid, aCharacteristicsDLL, |
|
1551 aRules, aLastPreference, charsPtr->iKeySupportMode); |
|
1552 |
|
1553 return ETrue; |
|
1554 } |
|
1555 |
|
1556 default: |
|
1557 { |
|
1558 break; |
|
1559 } |
|
1560 }//switch (aInterfaceUid) |
|
1561 |
|
1562 break; |
|
1563 } |
|
1564 #ifdef SYMBIAN_SDP_IPSEC_VOIP_SUPPORT |
|
1565 case KMacModeType: |
|
1566 { |
|
1567 const CMacCharacteristics* charsPtr(static_cast<const CMacCharacteristics*>(aCharacteristicsDLL[0]->iCharacteristic)); |
|
1568 // The following method implements the rule for MAC interface's 'iMacMode' characteristics |
|
1569 FilterTInt32L(aInterfaceUid, *(aCharacteristicsDLL[0]), aRules, aLastPreference, charsPtr->iMacMode); |
|
1570 return ETrue; |
|
1571 } |
|
1572 #endif |
|
1573 default: |
|
1574 { |
|
1575 return EFalse; |
|
1576 } |
|
1577 }//switch (ruleCharValue->Uid().iUid) |
|
1578 |
|
1579 //Try adding it as optional |
|
1580 TryAddToOptionalCharListL(aInterfaceUid, *(aCharacteristicsDLL[0]), aRules); |
|
1581 |
|
1582 return ETrue; |
|
1583 } |
|
1584 |
|
1585 TBool CRuleSelector::FilterExtendedCharacteristicsL(TInt32 aInterfaceUid, RPointerArray<CRulesCharacteristicsAndPluginName>& aCharacteristicsDLL, |
|
1586 CSelectionRuleContent* aRules, TInt& aLastPreference) |
|
1587 { |
|
1588 //Load all the plugins |
|
1589 LoadPluginsL(); |
|
1590 |
|
1591 //Look for the dll name |
|
1592 TInt pluginCount = iPluginDllList.Count(); |
|
1593 TInt i=0; |
|
1594 |
|
1595 for (i=0;i<pluginCount;i++) |
|
1596 { |
|
1597 TInt pos = iPluginDllList[i].FileName().LocateReverseF('\\'); |
|
1598 TFileName dllFile = iPluginDllList[i].FileName().Right(pos+3); |
|
1599 |
|
1600 if (dllFile.CompareF(aCharacteristicsDLL[0]->iDllName) == 0) |
|
1601 { |
|
1602 break; |
|
1603 } |
|
1604 } |
|
1605 |
|
1606 //we should always find the dll |
|
1607 ASSERT(i<pluginCount); |
|
1608 |
|
1609 //Try to get entry point of the extended characteristic function |
|
1610 GetExtendedCharacteristicsFuncL getExtendedCharFuncL = (GetExtendedCharacteristicsFuncL)iPluginDllList[i].Lookup(EGetExtendedCharacteristicOrdinal); |
|
1611 |
|
1612 const CCharacteristics* cmn(aCharacteristicsDLL[0]->iCharacteristic); |
|
1613 TUid implUid={cmn->iImplementationUid}; |
|
1614 |
|
1615 //Retrieve the extended characteristics |
|
1616 CExtendedCharacteristics* extendedChar=NULL; |
|
1617 |
|
1618 (getExtendedCharFuncL)(implUid, extendedChar); |
|
1619 |
|
1620 |
|
1621 if (extendedChar) |
|
1622 { |
|
1623 CleanupStack::PushL(extendedChar); |
|
1624 const CCryptoParam* ruleCharValue = aRules->GetCharacteristicValue(); |
|
1625 |
|
1626 switch (ruleCharValue->Type()) |
|
1627 { |
|
1628 case CCryptoParam::EInt: |
|
1629 { |
|
1630 TInt charValue = 0; |
|
1631 |
|
1632 TRAPD(err, charValue = extendedChar->GetTIntCharacteristicL(ruleCharValue->Uid())); |
|
1633 |
|
1634 if (err) |
|
1635 { |
|
1636 //Not found |
|
1637 CleanupStack::PopAndDestroy(extendedChar); |
|
1638 return EFalse; |
|
1639 } |
|
1640 |
|
1641 TInt operator_r = aRules->GetOperator(); |
|
1642 |
|
1643 if (operator_r == EOpAscendingSort || operator_r == EOpDescendingSort) |
|
1644 { |
|
1645 TInt intCount = aCharacteristicsDLL.Count(); |
|
1646 |
|
1647 //Fill the array with the extended characteristic value |
|
1648 for (TInt i = 0; i < intCount; ++i) |
|
1649 { |
|
1650 TUid implimentationUid = { aCharacteristicsDLL[i]->iCharacteristic->iImplementationUid }; |
|
1651 CExtendedCharacteristics* extChar = NULL; |
|
1652 TInt intI=0; |
|
1653 |
|
1654 for (intI = 0; intI < pluginCount; intI++) |
|
1655 { |
|
1656 TInt pos = iPluginDllList[intI].FileName().LocateReverseF('\\'); |
|
1657 TFileName dllFile = iPluginDllList[intI].FileName().Right(pos+3); |
|
1658 |
|
1659 if (dllFile.CompareF(aCharacteristicsDLL[i]->iDllName) == 0) |
|
1660 { |
|
1661 break; |
|
1662 } |
|
1663 } |
|
1664 |
|
1665 //we should always find the dll |
|
1666 ASSERT(intI < pluginCount); |
|
1667 |
|
1668 //Try to get entry point of the extended characteristic function |
|
1669 GetExtendedCharacteristicsFuncL intGetExtendedCharFuncL = (GetExtendedCharacteristicsFuncL)iPluginDllList[intI].Lookup(EGetExtendedCharacteristicOrdinal); |
|
1670 |
|
1671 (intGetExtendedCharFuncL)(implimentationUid, extChar); |
|
1672 |
|
1673 //Make sure the extChar contains the characteristic it is trying to sort. |
|
1674 //As RArray::Sort() could not handle Leave, we need to leave here. |
|
1675 extChar->GetTIntCharacteristicL(ruleCharValue->Uid()); |
|
1676 aCharacteristicsDLL[i]->iExtendedCharacteristic = extChar; |
|
1677 aCharacteristicsDLL[i]->iSortUid = ruleCharValue->Uid().iUid; |
|
1678 } |
|
1679 } |
|
1680 |
|
1681 FilterTIntL(aInterfaceUid, aCharacteristicsDLL, |
|
1682 aRules, aLastPreference, charValue); |
|
1683 |
|
1684 CleanupStack::PopAndDestroy(extendedChar); |
|
1685 return ETrue; |
|
1686 } |
|
1687 |
|
1688 case CCryptoParam::EDesC8: |
|
1689 { |
|
1690 const TDesC8* charValue = NULL; |
|
1691 |
|
1692 TRAPD(err, charValue = &(extendedChar->GetTDesC8CharacteristicL(ruleCharValue->Uid()))); |
|
1693 |
|
1694 if (err) |
|
1695 { |
|
1696 //Not found |
|
1697 CleanupStack::PopAndDestroy(extendedChar); |
|
1698 return EFalse; |
|
1699 } |
|
1700 |
|
1701 TInt operator_r = aRules->GetOperator(); |
|
1702 |
|
1703 if (operator_r == EOpAscendingSort || operator_r == EOpDescendingSort) |
|
1704 { |
|
1705 TInt desCount = aCharacteristicsDLL.Count(); |
|
1706 |
|
1707 //Fill the array with the extended characteristic value |
|
1708 for (TInt i = 0; i < desCount; ++i) |
|
1709 { |
|
1710 TUid implimentationUid = { aCharacteristicsDLL[i]->iCharacteristic->iImplementationUid }; |
|
1711 CExtendedCharacteristics* extChar; |
|
1712 TInt desI=0; |
|
1713 |
|
1714 for (desI = 0; desI < pluginCount; desI++) |
|
1715 { |
|
1716 TInt pos = iPluginDllList[desI].FileName().LocateReverseF('\\'); |
|
1717 TFileName dllFile = iPluginDllList[desI].FileName().Right(pos+3); |
|
1718 |
|
1719 if (dllFile.CompareF(aCharacteristicsDLL[i]->iDllName) == 0) |
|
1720 { |
|
1721 break; |
|
1722 } |
|
1723 } |
|
1724 |
|
1725 //we should always find the dll |
|
1726 ASSERT(desI < pluginCount); |
|
1727 |
|
1728 //Try to get entry point of the extended characteristic function |
|
1729 GetExtendedCharacteristicsFuncL desGetExtendedCharFuncL = (GetExtendedCharacteristicsFuncL)iPluginDllList[desI].Lookup(EGetExtendedCharacteristicOrdinal); |
|
1730 |
|
1731 (desGetExtendedCharFuncL)(implimentationUid, extChar); |
|
1732 |
|
1733 //Make sure the extChar contains the characteristic it is trying to sort. |
|
1734 //As RArray::Sort() could not handle Leave, we need to leave here. |
|
1735 extChar->GetTDesC8CharacteristicL(ruleCharValue->Uid()); |
|
1736 aCharacteristicsDLL[i]->iExtendedCharacteristic = extChar; |
|
1737 aCharacteristicsDLL[i]->iSortUid = ruleCharValue->Uid().iUid; |
|
1738 } |
|
1739 } |
|
1740 |
|
1741 FilterExtendedTDesC8L(aInterfaceUid, aCharacteristicsDLL, aRules, aLastPreference, *charValue); |
|
1742 CleanupStack::PopAndDestroy(extendedChar); |
|
1743 return ETrue; |
|
1744 } |
|
1745 |
|
1746 default: |
|
1747 { |
|
1748 CleanupStack::PopAndDestroy(extendedChar); |
|
1749 return EFalse; |
|
1750 } |
|
1751 } |
|
1752 } |
|
1753 |
|
1754 return EFalse; |
|
1755 } |
|
1756 |
|
1757 void CRuleSelector::FilterTInt32L(TInt32 aInterfaceUid, CRulesCharacteristicsAndPluginName& aCharacteristics, |
|
1758 CSelectionRuleContent* aRules, TInt& aLastPreference, TInt32 aCharValue) |
|
1759 { |
|
1760 const CCryptoParam* charValue = aRules->GetCharacteristicValue(); |
|
1761 TInt operator_r = aRules->GetOperator(); |
|
1762 |
|
1763 if (operator_r == EOpEqual) |
|
1764 { |
|
1765 if (aCharValue == ((CCryptoIntParam*)charValue)->Value()) |
|
1766 { |
|
1767 // |
|
1768 //Met the rule and build it into iSelectedInterfaceCharacteristicsMap |
|
1769 // |
|
1770 |
|
1771 AddToCharListL(aInterfaceUid, aCharacteristics, aLastPreference); |
|
1772 return; |
|
1773 } |
|
1774 } |
|
1775 else |
|
1776 if (operator_r == EOpNotEqual) |
|
1777 { |
|
1778 if (aCharValue != ((CCryptoIntParam*)charValue)->Value()) |
|
1779 { |
|
1780 // |
|
1781 //Met the rule and build it into iSelectedInterfaceCharacteristicsMap |
|
1782 // |
|
1783 |
|
1784 AddToCharListL(aInterfaceUid, aCharacteristics, aLastPreference); |
|
1785 return; |
|
1786 } |
|
1787 } |
|
1788 else |
|
1789 { |
|
1790 delete &aCharacteristics; |
|
1791 return; |
|
1792 } |
|
1793 |
|
1794 //Try adding it as optional |
|
1795 TryAddToOptionalCharListL(aInterfaceUid, aCharacteristics, aRules); |
|
1796 } |
|
1797 |
|
1798 void CRuleSelector::FilterMultiTInt32L(TInt32 aInterfaceUid, CRulesCharacteristicsAndPluginName& aCharacteristicsDLL, |
|
1799 CSelectionRuleContent* aRules, TInt& aLastPreference, |
|
1800 TBool aSupport) |
|
1801 { |
|
1802 TInt operator_r = aRules->GetOperator(); |
|
1803 |
|
1804 if (operator_r == EOpEqual) |
|
1805 { |
|
1806 if (aSupport) |
|
1807 { |
|
1808 // |
|
1809 //The array of TInt32 contain the required element, so build it into |
|
1810 //iSelectedInterfaceCharacteristicsMap |
|
1811 // |
|
1812 |
|
1813 AddToCharListL(aInterfaceUid, aCharacteristicsDLL, aLastPreference); |
|
1814 |
|
1815 return; |
|
1816 } |
|
1817 } |
|
1818 else |
|
1819 if (operator_r == EOpNotEqual) |
|
1820 { |
|
1821 if (!aSupport) |
|
1822 { |
|
1823 // |
|
1824 //The array of TInt32 does not contain the specified element, so |
|
1825 //build it into iSelectedInterfaceCharacteristicsMap |
|
1826 // |
|
1827 |
|
1828 AddToCharListL(aInterfaceUid, aCharacteristicsDLL, aLastPreference); |
|
1829 return; |
|
1830 } |
|
1831 } |
|
1832 else |
|
1833 { |
|
1834 delete &aCharacteristicsDLL; |
|
1835 return; |
|
1836 } |
|
1837 |
|
1838 //Try adding it as optional |
|
1839 TryAddToOptionalCharListL(aInterfaceUid, aCharacteristicsDLL, aRules); |
|
1840 } |
|
1841 |
|
1842 TInt CRuleSelector::AscendCreatorName(const CRulesCharacteristicsAndPluginName& aLeft, const CRulesCharacteristicsAndPluginName& aRight) |
|
1843 { |
|
1844 const CCharacteristics* charLeft(aLeft.iCharacteristic); |
|
1845 const CCharacteristics* charRight(aRight.iCharacteristic); |
|
1846 |
|
1847 return charLeft->iCreatorName.CompareC(charRight->iCreatorName); |
|
1848 } |
|
1849 |
|
1850 TInt CRuleSelector::DescendCreatorName(const CRulesCharacteristicsAndPluginName& aLeft, const CRulesCharacteristicsAndPluginName& aRight) |
|
1851 { |
|
1852 const CCharacteristics* charLeft(aLeft.iCharacteristic); |
|
1853 const CCharacteristics* charRight(aRight.iCharacteristic); |
|
1854 |
|
1855 return charRight->iCreatorName.CompareC(charLeft->iCreatorName); |
|
1856 } |
|
1857 |
|
1858 TInt CRuleSelector::AscendMaxConcurrencySupported(const CRulesCharacteristicsAndPluginName& aLeft, const CRulesCharacteristicsAndPluginName& aRight) |
|
1859 { |
|
1860 const CCharacteristics* charLeft(aLeft.iCharacteristic); |
|
1861 const CCharacteristics* charRight(aRight.iCharacteristic); |
|
1862 |
|
1863 return (charLeft->iMaxConcurrencySupported) - (charRight->iMaxConcurrencySupported); |
|
1864 } |
|
1865 |
|
1866 TInt CRuleSelector::DescendMaxConcurrencySupported(const CRulesCharacteristicsAndPluginName& aLeft, const CRulesCharacteristicsAndPluginName& aRight) |
|
1867 { |
|
1868 const CCharacteristics* charLeft(aLeft.iCharacteristic); |
|
1869 const CCharacteristics* charRight(aRight.iCharacteristic); |
|
1870 |
|
1871 return (charRight->iMaxConcurrencySupported) - (charLeft->iMaxConcurrencySupported); |
|
1872 } |
|
1873 |
|
1874 TInt CRuleSelector::AscendLatency(const CRulesCharacteristicsAndPluginName& aLeft, const CRulesCharacteristicsAndPluginName& aRight) |
|
1875 { |
|
1876 const CCharacteristics* charLeft(aLeft.iCharacteristic); |
|
1877 const CCharacteristics* charRight(aRight.iCharacteristic); |
|
1878 |
|
1879 return (charLeft->iLatency) - (charRight->iLatency); |
|
1880 } |
|
1881 |
|
1882 TInt CRuleSelector::DescendLatency(const CRulesCharacteristicsAndPluginName& aLeft, const CRulesCharacteristicsAndPluginName& aRight) |
|
1883 { |
|
1884 const CCharacteristics* charLeft(aLeft.iCharacteristic); |
|
1885 const CCharacteristics* charRight(aRight.iCharacteristic); |
|
1886 |
|
1887 return (charRight->iLatency) - (charLeft->iLatency); |
|
1888 } |
|
1889 |
|
1890 TInt CRuleSelector::AscendThroughput(const CRulesCharacteristicsAndPluginName& aLeft, const CRulesCharacteristicsAndPluginName& aRight) |
|
1891 { |
|
1892 const CCharacteristics* charLeft(aLeft.iCharacteristic); |
|
1893 const CCharacteristics* charRight(aRight.iCharacteristic); |
|
1894 |
|
1895 return (charLeft->iThroughput) - (charRight->iThroughput); |
|
1896 } |
|
1897 |
|
1898 TInt CRuleSelector::DescendThroughput(const CRulesCharacteristicsAndPluginName& aLeft, const CRulesCharacteristicsAndPluginName& aRight) |
|
1899 { |
|
1900 const CCharacteristics* charLeft(aLeft.iCharacteristic); |
|
1901 const CCharacteristics* charRight(aRight.iCharacteristic); |
|
1902 |
|
1903 return (charRight->iThroughput) - (charLeft->iThroughput); |
|
1904 } |
|
1905 |
|
1906 TInt CRuleSelector::AscendHashBlockSize(const CRulesCharacteristicsAndPluginName& aLeft, const CRulesCharacteristicsAndPluginName& aRight) |
|
1907 { |
|
1908 const CHashCharacteristics* charLeft(static_cast<const CHashCharacteristics*>(aLeft.iCharacteristic)); |
|
1909 const CHashCharacteristics* charRight(static_cast<const CHashCharacteristics*>(aRight.iCharacteristic)); |
|
1910 |
|
1911 return (charLeft->iBlockSize) - (charRight->iBlockSize); |
|
1912 } |
|
1913 |
|
1914 TInt CRuleSelector::DescendHashBlockSize(const CRulesCharacteristicsAndPluginName& aLeft, const CRulesCharacteristicsAndPluginName& aRight) |
|
1915 { |
|
1916 const CHashCharacteristics* charLeft(static_cast<const CHashCharacteristics*>(aLeft.iCharacteristic)); |
|
1917 const CHashCharacteristics* charRight(static_cast<const CHashCharacteristics*>(aRight.iCharacteristic)); |
|
1918 |
|
1919 return (charRight->iBlockSize) - (charLeft->iBlockSize); |
|
1920 } |
|
1921 |
|
1922 TInt CRuleSelector::AscendSymmetricCipherBlockSize(const CRulesCharacteristicsAndPluginName& aLeft, const CRulesCharacteristicsAndPluginName& aRight) |
|
1923 { |
|
1924 const CSymmetricCipherCharacteristics* charLeft(static_cast<const CSymmetricCipherCharacteristics*>(aLeft.iCharacteristic)); |
|
1925 const CSymmetricCipherCharacteristics* charRight(static_cast<const CSymmetricCipherCharacteristics*>(aRight.iCharacteristic)); |
|
1926 |
|
1927 return (charLeft->iBlockSize) - (charRight->iBlockSize); |
|
1928 } |
|
1929 |
|
1930 TInt CRuleSelector::DescendSymmetricCipherBlockSize(const CRulesCharacteristicsAndPluginName& aLeft, const CRulesCharacteristicsAndPluginName& aRight) |
|
1931 { |
|
1932 const CSymmetricCipherCharacteristics* charLeft(static_cast<const CSymmetricCipherCharacteristics*>(aLeft.iCharacteristic)); |
|
1933 const CSymmetricCipherCharacteristics* charRight(static_cast<const CSymmetricCipherCharacteristics*>(aRight.iCharacteristic)); |
|
1934 |
|
1935 return (charRight->iBlockSize) - (charLeft->iBlockSize); |
|
1936 } |
|
1937 |
|
1938 TInt CRuleSelector::AscendHashOutputSize(const CRulesCharacteristicsAndPluginName& aLeft, const CRulesCharacteristicsAndPluginName& aRight) |
|
1939 { |
|
1940 const CHashCharacteristics* charLeft(static_cast<const CHashCharacteristics*>(aLeft.iCharacteristic)); |
|
1941 const CHashCharacteristics* charRight(static_cast<const CHashCharacteristics*>(aRight.iCharacteristic)); |
|
1942 |
|
1943 return (charLeft->iOutputSize) - (charRight->iOutputSize); |
|
1944 } |
|
1945 |
|
1946 TInt CRuleSelector::DescendHashOutputSize(const CRulesCharacteristicsAndPluginName& aLeft, const CRulesCharacteristicsAndPluginName& aRight) |
|
1947 { |
|
1948 const CHashCharacteristics* charLeft(static_cast<const CHashCharacteristics*>(aLeft.iCharacteristic)); |
|
1949 const CHashCharacteristics* charRight(static_cast<const CHashCharacteristics*>(aRight.iCharacteristic)); |
|
1950 |
|
1951 return (charRight->iOutputSize) - (charLeft->iOutputSize); |
|
1952 } |
|
1953 |
|
1954 TInt CRuleSelector::AscendRandomBlockingMode(const CRulesCharacteristicsAndPluginName& aLeft, const CRulesCharacteristicsAndPluginName& aRight) |
|
1955 { |
|
1956 const CRandomCharacteristics* charLeft(static_cast<const CRandomCharacteristics*>(aLeft.iCharacteristic)); |
|
1957 const CRandomCharacteristics* charRight(static_cast<const CRandomCharacteristics*>(aRight.iCharacteristic)); |
|
1958 |
|
1959 return (charLeft->iBlockingMode) - (charRight->iBlockingMode); |
|
1960 } |
|
1961 |
|
1962 TInt CRuleSelector::DescendRandomBlockingMode(const CRulesCharacteristicsAndPluginName& aLeft, const CRulesCharacteristicsAndPluginName& aRight) |
|
1963 { |
|
1964 const CRandomCharacteristics* charLeft(static_cast<const CRandomCharacteristics*>(aLeft.iCharacteristic)); |
|
1965 const CRandomCharacteristics* charRight(static_cast<const CRandomCharacteristics*>(aRight.iCharacteristic)); |
|
1966 |
|
1967 return (charRight->iBlockingMode) - (charLeft->iBlockingMode); |
|
1968 } |
|
1969 |
|
1970 TInt CRuleSelector::AscendSymmetricCipherKeyLength(const CRulesCharacteristicsAndPluginName& aLeft, const CRulesCharacteristicsAndPluginName& aRight) |
|
1971 { |
|
1972 const CSymmetricCipherCharacteristics* charLeft(static_cast<const CSymmetricCipherCharacteristics*>(aLeft.iCharacteristic)); |
|
1973 const CSymmetricCipherCharacteristics* charRight(static_cast<const CSymmetricCipherCharacteristics*>(aRight.iCharacteristic)); |
|
1974 |
|
1975 return (charLeft->iMaximumKeyLength) - (charRight->iMaximumKeyLength); |
|
1976 } |
|
1977 |
|
1978 TInt CRuleSelector::DescendSymmetricCipherKeyLength(const CRulesCharacteristicsAndPluginName& aLeft, const CRulesCharacteristicsAndPluginName& aRight) |
|
1979 { |
|
1980 const CSymmetricCipherCharacteristics* charLeft(static_cast<const CSymmetricCipherCharacteristics*>(aLeft.iCharacteristic)); |
|
1981 const CSymmetricCipherCharacteristics* charRight(static_cast<const CSymmetricCipherCharacteristics*>(aRight.iCharacteristic)); |
|
1982 |
|
1983 return (charRight->iMaximumKeyLength) - (charLeft->iMaximumKeyLength); |
|
1984 } |
|
1985 |
|
1986 TInt CRuleSelector::AscendAsymmetricCipherKeyLength(const CRulesCharacteristicsAndPluginName& aLeft, const CRulesCharacteristicsAndPluginName& aRight) |
|
1987 { |
|
1988 const CAsymmetricCipherCharacteristics* charLeft(static_cast<const CAsymmetricCipherCharacteristics*>(aLeft.iCharacteristic)); |
|
1989 const CAsymmetricCipherCharacteristics* charRight(static_cast<const CAsymmetricCipherCharacteristics*>(aRight.iCharacteristic)); |
|
1990 |
|
1991 return (charLeft->iMaximumKeyLength) - (charRight->iMaximumKeyLength); |
|
1992 } |
|
1993 |
|
1994 TInt CRuleSelector::DescendAsymmetricCipherKeyLength(const CRulesCharacteristicsAndPluginName& aLeft, const CRulesCharacteristicsAndPluginName& aRight) |
|
1995 { |
|
1996 const CAsymmetricCipherCharacteristics* charLeft(static_cast<const CAsymmetricCipherCharacteristics*>(aLeft.iCharacteristic)); |
|
1997 const CAsymmetricCipherCharacteristics* charRight(static_cast<const CAsymmetricCipherCharacteristics*>(aRight.iCharacteristic)); |
|
1998 |
|
1999 return (charRight->iMaximumKeyLength) - (charLeft->iMaximumKeyLength); |
|
2000 } |
|
2001 |
|
2002 TInt CRuleSelector::AscendAsymmetricSignatureKeyLength(const CRulesCharacteristicsAndPluginName& aLeft, const CRulesCharacteristicsAndPluginName& aRight) |
|
2003 { |
|
2004 const CAsymmetricSignatureCharacteristics* charLeft(static_cast<const CAsymmetricSignatureCharacteristics*>(aLeft.iCharacteristic)); |
|
2005 const CAsymmetricSignatureCharacteristics* charRight(static_cast<const CAsymmetricSignatureCharacteristics*>(aRight.iCharacteristic)); |
|
2006 |
|
2007 return (charLeft->iMaximumKeyLength) - (charRight->iMaximumKeyLength); |
|
2008 } |
|
2009 |
|
2010 TInt CRuleSelector::DescendAsymmetricSignatureKeyLength(const CRulesCharacteristicsAndPluginName& aLeft, const CRulesCharacteristicsAndPluginName& aRight) |
|
2011 { |
|
2012 const CAsymmetricSignatureCharacteristics* charLeft(static_cast<const CAsymmetricSignatureCharacteristics*>(aLeft.iCharacteristic)); |
|
2013 const CAsymmetricSignatureCharacteristics* charRight(static_cast<const CAsymmetricSignatureCharacteristics*>(aRight.iCharacteristic)); |
|
2014 |
|
2015 return (charRight->iMaximumKeyLength) - (charLeft->iMaximumKeyLength); |
|
2016 } |
|
2017 |
|
2018 TInt CRuleSelector::AscendSymmetricCipherKeySupport(const CRulesCharacteristicsAndPluginName& aLeft, const CRulesCharacteristicsAndPluginName& aRight) |
|
2019 { |
|
2020 const CSymmetricCipherCharacteristics* cmnLeft(static_cast<const CSymmetricCipherCharacteristics*>(aLeft.iCharacteristic)); |
|
2021 const CSymmetricCipherCharacteristics* cmnRight(static_cast<const CSymmetricCipherCharacteristics*>(aRight.iCharacteristic)); |
|
2022 |
|
2023 return (cmnLeft->iKeySupportMode) - (cmnRight->iKeySupportMode); |
|
2024 } |
|
2025 |
|
2026 TInt CRuleSelector::DescendSymmetricCipherKeySupport(const CRulesCharacteristicsAndPluginName& aLeft, const CRulesCharacteristicsAndPluginName& aRight) |
|
2027 { |
|
2028 const CSymmetricCipherCharacteristics* cmnLeft(static_cast<const CSymmetricCipherCharacteristics*>(aLeft.iCharacteristic)); |
|
2029 const CSymmetricCipherCharacteristics* cmnRight(static_cast<const CSymmetricCipherCharacteristics*>(aRight.iCharacteristic)); |
|
2030 |
|
2031 return (cmnRight->iKeySupportMode) - (cmnLeft->iKeySupportMode); |
|
2032 } |
|
2033 |
|
2034 TInt CRuleSelector::AscendAsymmetricCipherKeySupport(const CRulesCharacteristicsAndPluginName& aLeft, const CRulesCharacteristicsAndPluginName& aRight) |
|
2035 { |
|
2036 const CAsymmetricCipherCharacteristics* cmnLeft(static_cast<const CAsymmetricCipherCharacteristics*>(aLeft.iCharacteristic)); |
|
2037 const CAsymmetricCipherCharacteristics* cmnRight(static_cast<const CAsymmetricCipherCharacteristics*>(aRight.iCharacteristic)); |
|
2038 |
|
2039 return (cmnLeft->iKeySupportMode) - (cmnRight->iKeySupportMode); |
|
2040 } |
|
2041 |
|
2042 TInt CRuleSelector::DescendAsymmetricCipherKeySupport(const CRulesCharacteristicsAndPluginName& aLeft, const CRulesCharacteristicsAndPluginName& aRight) |
|
2043 { |
|
2044 const CAsymmetricCipherCharacteristics* cmnLeft(static_cast<const CAsymmetricCipherCharacteristics*>(aLeft.iCharacteristic)); |
|
2045 const CAsymmetricCipherCharacteristics* cmnRight(static_cast<const CAsymmetricCipherCharacteristics*>(aRight.iCharacteristic)); |
|
2046 |
|
2047 return (cmnRight->iKeySupportMode) - (cmnLeft->iKeySupportMode); |
|
2048 } |
|
2049 |
|
2050 TInt CRuleSelector::AscendAsymmetricSignatureKeySupport(const CRulesCharacteristicsAndPluginName& aLeft, const CRulesCharacteristicsAndPluginName& aRight) |
|
2051 { |
|
2052 const CAsymmetricSignatureCharacteristics* cmnLeft(static_cast<const CAsymmetricSignatureCharacteristics*>(aLeft.iCharacteristic)); |
|
2053 const CAsymmetricSignatureCharacteristics* cmnRight(static_cast<const CAsymmetricSignatureCharacteristics*>(aRight.iCharacteristic)); |
|
2054 |
|
2055 return (cmnLeft->iKeySupportMode) - (cmnRight->iKeySupportMode); |
|
2056 } |
|
2057 |
|
2058 TInt CRuleSelector::DescendAsymmetricSignatureKeySupport(const CRulesCharacteristicsAndPluginName& aLeft, const CRulesCharacteristicsAndPluginName& aRight) |
|
2059 { |
|
2060 const CAsymmetricSignatureCharacteristics* cmnLeft(static_cast<const CAsymmetricSignatureCharacteristics*>(aLeft.iCharacteristic)); |
|
2061 const CAsymmetricSignatureCharacteristics* cmnRight(static_cast<const CAsymmetricSignatureCharacteristics*>(aRight.iCharacteristic)); |
|
2062 |
|
2063 return (cmnRight->iKeySupportMode) - (cmnLeft->iKeySupportMode); |
|
2064 } |
|
2065 |
|
2066 TInt CRuleSelector::AscendAsymmetricKeypairGeneratorKeyLength(const CRulesCharacteristicsAndPluginName& aLeft, const CRulesCharacteristicsAndPluginName& aRight) |
|
2067 { |
|
2068 const CKeypairGeneratorCharacteristics* charLeft(static_cast<const CKeypairGeneratorCharacteristics*>(aLeft.iCharacteristic)); |
|
2069 const CKeypairGeneratorCharacteristics* charRight(static_cast<const CKeypairGeneratorCharacteristics*>(aRight.iCharacteristic)); |
|
2070 |
|
2071 return (charLeft->iMaximumKeyLength) - (charRight->iMaximumKeyLength); |
|
2072 } |
|
2073 |
|
2074 TInt CRuleSelector::DescendAsymmetricKeypairGeneratorKeyLength(const CRulesCharacteristicsAndPluginName& aLeft, const CRulesCharacteristicsAndPluginName& aRight) |
|
2075 { |
|
2076 const CKeypairGeneratorCharacteristics* charLeft(static_cast<const CKeypairGeneratorCharacteristics*>(aLeft.iCharacteristic)); |
|
2077 const CKeypairGeneratorCharacteristics* charRight(static_cast<const CKeypairGeneratorCharacteristics*>(aRight.iCharacteristic)); |
|
2078 |
|
2079 return (charRight->iMaximumKeyLength) - (charLeft->iMaximumKeyLength); |
|
2080 } |
|
2081 |
|
2082 void CRuleSelector::FilterCreatorNameL(TInt32 aInterfaceUid, RPointerArray<CRulesCharacteristicsAndPluginName>& aCharacteristicsDLL, |
|
2083 CSelectionRuleContent* aRules, TInt& aLastPreference) |
|
2084 { |
|
2085 TInt operator_r = aRules->GetOperator(); |
|
2086 |
|
2087 if (operator_r == EOpEqual) |
|
2088 { |
|
2089 const CCharacteristics* cmn(aCharacteristicsDLL[0]->iCharacteristic); |
|
2090 |
|
2091 const CCryptoDesC16Param* charValue = static_cast<const CCryptoDesC16Param*>(aRules->GetCharacteristicValue()); |
|
2092 |
|
2093 if (cmn->iCreatorName.Compare(charValue->Value()) == 0) |
|
2094 { |
|
2095 AddToCharListL(aInterfaceUid, *(aCharacteristicsDLL[0]), aLastPreference); |
|
2096 return; |
|
2097 } |
|
2098 } |
|
2099 else |
|
2100 if (operator_r == EOpNotEqual) |
|
2101 { |
|
2102 const CCharacteristics* cmn(aCharacteristicsDLL[0]->iCharacteristic); |
|
2103 |
|
2104 const CCryptoDesC16Param* charValue = static_cast<const CCryptoDesC16Param*>(aRules->GetCharacteristicValue()); |
|
2105 |
|
2106 if (cmn->iCreatorName.Compare(charValue->Value())) |
|
2107 { |
|
2108 AddToCharListL(aInterfaceUid, *(aCharacteristicsDLL[0]), aLastPreference); |
|
2109 return; |
|
2110 } |
|
2111 } |
|
2112 else |
|
2113 if (operator_r == EOpAscendingSort) |
|
2114 { |
|
2115 const TLinearOrder<CRulesCharacteristicsAndPluginName> sortOrder(AscendCreatorName); |
|
2116 |
|
2117 aCharacteristicsDLL.Sort(sortOrder); |
|
2118 |
|
2119 return; |
|
2120 } |
|
2121 else |
|
2122 if (operator_r == EOpDescendingSort) |
|
2123 { |
|
2124 const TLinearOrder<CRulesCharacteristicsAndPluginName> sortOrder(DescendCreatorName); |
|
2125 |
|
2126 aCharacteristicsDLL.Sort(sortOrder); |
|
2127 |
|
2128 return; |
|
2129 } |
|
2130 else |
|
2131 { |
|
2132 //Delete this CRulesCharacteristicsAndPluginName |
|
2133 delete aCharacteristicsDLL[0]; |
|
2134 return; |
|
2135 } |
|
2136 |
|
2137 //Try adding it as optional |
|
2138 TryAddToOptionalCharListL(aInterfaceUid, *(aCharacteristicsDLL[0]), aRules); |
|
2139 } |
|
2140 |
|
2141 void CRuleSelector::FilterExtendedTDesC8L(TInt32 aInterfaceUid, RPointerArray<CRulesCharacteristicsAndPluginName>& aCharacteristicsDLL, |
|
2142 CSelectionRuleContent* aRules, TInt& aLastPreference, const TDesC8& aCharValue) |
|
2143 { |
|
2144 TInt operator_r = aRules->GetOperator(); |
|
2145 |
|
2146 if (operator_r == EOpEqual) |
|
2147 { |
|
2148 const CCryptoDesC8Param* charValue = static_cast<const CCryptoDesC8Param*>(aRules->GetCharacteristicValue()); |
|
2149 |
|
2150 if (aCharValue.Compare(charValue->Value()) == 0) |
|
2151 { |
|
2152 AddToCharListL(aInterfaceUid, *(aCharacteristicsDLL[0]), aLastPreference); |
|
2153 return; |
|
2154 } |
|
2155 } |
|
2156 else |
|
2157 if (operator_r == EOpNotEqual) |
|
2158 { |
|
2159 const CCryptoDesC8Param* charValue = static_cast<const CCryptoDesC8Param*>(aRules->GetCharacteristicValue()); |
|
2160 |
|
2161 if (aCharValue.Compare(charValue->Value())) |
|
2162 { |
|
2163 AddToCharListL(aInterfaceUid, *(aCharacteristicsDLL[0]), aLastPreference); |
|
2164 return; |
|
2165 } |
|
2166 } |
|
2167 else |
|
2168 if (operator_r == EOpAscendingSort) |
|
2169 { |
|
2170 const TLinearOrder<CRulesCharacteristicsAndPluginName> sortOrder(AscendExtendedTDesC8L); |
|
2171 |
|
2172 aCharacteristicsDLL.Sort(sortOrder); |
|
2173 |
|
2174 TInt count = aCharacteristicsDLL.Count(); |
|
2175 |
|
2176 //Clean up the array's extended characteristic value |
|
2177 for (TInt i = 0; i < count; ++i) |
|
2178 { |
|
2179 delete aCharacteristicsDLL[i]->iExtendedCharacteristic; |
|
2180 aCharacteristicsDLL[i]->iExtendedCharacteristic = NULL; |
|
2181 } |
|
2182 |
|
2183 return; |
|
2184 } |
|
2185 else |
|
2186 if (operator_r == EOpDescendingSort) |
|
2187 { |
|
2188 const TLinearOrder<CRulesCharacteristicsAndPluginName> sortOrder(DescendExtendedTDesC8L); |
|
2189 |
|
2190 aCharacteristicsDLL.Sort(sortOrder); |
|
2191 |
|
2192 TInt count = aCharacteristicsDLL.Count(); |
|
2193 |
|
2194 //Clean up the array's extended characteristic value |
|
2195 for (TInt i = 0; i < count; ++i) |
|
2196 { |
|
2197 delete aCharacteristicsDLL[i]->iExtendedCharacteristic; |
|
2198 aCharacteristicsDLL[i]->iExtendedCharacteristic = NULL; |
|
2199 } |
|
2200 |
|
2201 return; |
|
2202 } |
|
2203 else |
|
2204 { |
|
2205 delete aCharacteristicsDLL[0]; |
|
2206 return; |
|
2207 } |
|
2208 |
|
2209 //Try adding it as optional |
|
2210 TryAddToOptionalCharListL(aInterfaceUid, *(aCharacteristicsDLL[0]), aRules); |
|
2211 } |
|
2212 |
|
2213 void CRuleSelector::FilterTBoolL(TInt32 aInterfaceUid, CRulesCharacteristicsAndPluginName& aCharacteristics, |
|
2214 CSelectionRuleContent* aRules, TInt& aLastPreference, TBool aCharValue) |
|
2215 { |
|
2216 const CCryptoParam* charValue = aRules->GetCharacteristicValue(); |
|
2217 TInt operator_r = aRules->GetOperator(); |
|
2218 |
|
2219 if (operator_r == EOpEqual) |
|
2220 { |
|
2221 if (aCharValue == ((CCryptoIntParam*)charValue)->Value()) |
|
2222 { |
|
2223 // |
|
2224 //Met the rule and build it into iSelectedInterfaceCharacteristicsMap |
|
2225 // |
|
2226 |
|
2227 AddToCharListL(aInterfaceUid, aCharacteristics, aLastPreference); |
|
2228 return; |
|
2229 } |
|
2230 } |
|
2231 else |
|
2232 if (operator_r == EOpNotEqual) |
|
2233 { |
|
2234 if (aCharValue != ((CCryptoIntParam*)charValue)->Value()) |
|
2235 { |
|
2236 // |
|
2237 //Met the rule and build it into iSelectedInterfaceCharacteristicsMap |
|
2238 // |
|
2239 |
|
2240 AddToCharListL(aInterfaceUid, aCharacteristics, aLastPreference); |
|
2241 return; |
|
2242 } |
|
2243 } |
|
2244 else |
|
2245 { |
|
2246 delete &aCharacteristics; |
|
2247 return; |
|
2248 } |
|
2249 |
|
2250 //Try adding it as optional |
|
2251 TryAddToOptionalCharListL(aInterfaceUid, aCharacteristics, aRules); |
|
2252 } |
|
2253 |
|
2254 void CRuleSelector::FilterTIntL(TInt32 aInterfaceUid, RPointerArray<CRulesCharacteristicsAndPluginName>& aCharacteristicsDLL, |
|
2255 CSelectionRuleContent* aRules, TInt& aLastPreference, TInt aCharValue) |
|
2256 { |
|
2257 const CCryptoParam* ruleCharValue = aRules->GetCharacteristicValue(); |
|
2258 TInt operator_r = aRules->GetOperator(); |
|
2259 |
|
2260 if (operator_r == EOpEqual) |
|
2261 { |
|
2262 if (aCharValue == ((CCryptoIntParam*)ruleCharValue)->Value()) |
|
2263 { |
|
2264 // |
|
2265 //Met the rule and build it into iSelectedInterfaceCharacteristicsMap |
|
2266 // |
|
2267 |
|
2268 AddToCharListL(aInterfaceUid, *(aCharacteristicsDLL[0]), aLastPreference); |
|
2269 return; |
|
2270 } |
|
2271 } |
|
2272 else |
|
2273 if (operator_r == EOpNotEqual) |
|
2274 { |
|
2275 if (aCharValue != ((CCryptoIntParam*)ruleCharValue)->Value()) |
|
2276 { |
|
2277 // |
|
2278 //Met the rule and build it into iSelectedInterfaceCharacteristicsMap |
|
2279 // |
|
2280 |
|
2281 AddToCharListL(aInterfaceUid, *(aCharacteristicsDLL[0]), aLastPreference); |
|
2282 return; |
|
2283 } |
|
2284 } |
|
2285 else |
|
2286 if (operator_r == EOpGreaterThan) |
|
2287 { |
|
2288 if (aCharValue > ((CCryptoIntParam*)ruleCharValue)->Value()) |
|
2289 { |
|
2290 // |
|
2291 //Met the rule and build it into iSelectedInterfaceCharacteristicsMap |
|
2292 // |
|
2293 |
|
2294 AddToCharListL(aInterfaceUid, *(aCharacteristicsDLL[0]), aLastPreference); |
|
2295 return; |
|
2296 } |
|
2297 } |
|
2298 else |
|
2299 if (operator_r == EOpLessThan) |
|
2300 { |
|
2301 if (aCharValue < ((CCryptoIntParam*)ruleCharValue)->Value()) |
|
2302 { |
|
2303 // |
|
2304 //Met the rule and build it into iSelectedInterfaceCharacteristicsMap |
|
2305 // |
|
2306 |
|
2307 AddToCharListL(aInterfaceUid, *(aCharacteristicsDLL[0]), aLastPreference); |
|
2308 return; |
|
2309 } |
|
2310 } |
|
2311 else |
|
2312 if (operator_r == EOpGreaterThanOrEqual) |
|
2313 { |
|
2314 if (aCharValue >= ((CCryptoIntParam*)ruleCharValue)->Value()) |
|
2315 { |
|
2316 // |
|
2317 //Met the rule and build it into iSelectedInterfaceCharacteristicsMap |
|
2318 // |
|
2319 |
|
2320 AddToCharListL(aInterfaceUid, *(aCharacteristicsDLL[0]), aLastPreference); |
|
2321 return; |
|
2322 } |
|
2323 } |
|
2324 else |
|
2325 if (operator_r == EOpLessThanOrEqual) |
|
2326 { |
|
2327 if (aCharValue <= ((CCryptoIntParam*)ruleCharValue)->Value()) |
|
2328 { |
|
2329 // |
|
2330 //Met the rule and build it into iSelectedInterfaceCharacteristicsMap |
|
2331 // |
|
2332 |
|
2333 AddToCharListL(aInterfaceUid, *(aCharacteristicsDLL[0]), aLastPreference); |
|
2334 return; |
|
2335 } |
|
2336 } |
|
2337 else |
|
2338 if (operator_r == EOpAscendingSort) |
|
2339 { |
|
2340 switch (ruleCharValue->Uid().iUid) |
|
2341 { |
|
2342 case KMaxConcurrencySupportedType: |
|
2343 { |
|
2344 const TLinearOrder<CRulesCharacteristicsAndPluginName> sortOrder(AscendMaxConcurrencySupported); |
|
2345 |
|
2346 aCharacteristicsDLL.Sort(sortOrder); |
|
2347 break; |
|
2348 } |
|
2349 |
|
2350 case KLatencyType: |
|
2351 { |
|
2352 const TLinearOrder<CRulesCharacteristicsAndPluginName> sortOrder(AscendLatency); |
|
2353 |
|
2354 aCharacteristicsDLL.Sort(sortOrder); |
|
2355 break; |
|
2356 } |
|
2357 |
|
2358 case KThroughputType: |
|
2359 { |
|
2360 const TLinearOrder<CRulesCharacteristicsAndPluginName> sortOrder(AscendThroughput); |
|
2361 |
|
2362 aCharacteristicsDLL.Sort(sortOrder); |
|
2363 break; |
|
2364 } |
|
2365 |
|
2366 case KBlockSizeType: |
|
2367 { |
|
2368 if (aInterfaceUid == KHashInterface || aInterfaceUid == KAsyncHashInterface) |
|
2369 { |
|
2370 const TLinearOrder<CRulesCharacteristicsAndPluginName> sortOrder(AscendHashBlockSize); |
|
2371 |
|
2372 aCharacteristicsDLL.Sort(sortOrder); |
|
2373 } |
|
2374 else if (aInterfaceUid == KSymmetricCipherInterface || aInterfaceUid == KAsyncSymmetricCipherInterface) |
|
2375 { |
|
2376 const TLinearOrder<CRulesCharacteristicsAndPluginName> sortOrder(AscendSymmetricCipherBlockSize); |
|
2377 |
|
2378 aCharacteristicsDLL.Sort(sortOrder); |
|
2379 } |
|
2380 else |
|
2381 { |
|
2382 //Characteristic not supported |
|
2383 User::Leave(KErrNotSupported); |
|
2384 } |
|
2385 |
|
2386 break; |
|
2387 } |
|
2388 |
|
2389 case KOutputSizeType: |
|
2390 { |
|
2391 const TLinearOrder<CRulesCharacteristicsAndPluginName> sortOrder(AscendHashOutputSize); |
|
2392 |
|
2393 aCharacteristicsDLL.Sort(sortOrder); |
|
2394 break; |
|
2395 } |
|
2396 |
|
2397 case KBlockingModeType: |
|
2398 { |
|
2399 const TLinearOrder<CRulesCharacteristicsAndPluginName> sortOrder(AscendRandomBlockingMode); |
|
2400 |
|
2401 aCharacteristicsDLL.Sort(sortOrder); |
|
2402 break; |
|
2403 } |
|
2404 |
|
2405 case KMaximumKeyLengthType: |
|
2406 { |
|
2407 if (aInterfaceUid == KSymmetricCipherInterface || aInterfaceUid == KAsyncSymmetricCipherInterface) |
|
2408 { |
|
2409 const TLinearOrder<CRulesCharacteristicsAndPluginName> sortOrder(AscendSymmetricCipherKeyLength); |
|
2410 |
|
2411 aCharacteristicsDLL.Sort(sortOrder); |
|
2412 } |
|
2413 else if (aInterfaceUid == KAsymmetricCipherInterface || aInterfaceUid == KAsyncAsymmetricCipherInterface) |
|
2414 { |
|
2415 const TLinearOrder<CRulesCharacteristicsAndPluginName> sortOrder(AscendAsymmetricCipherKeyLength); |
|
2416 |
|
2417 aCharacteristicsDLL.Sort(sortOrder); |
|
2418 } |
|
2419 else if (aInterfaceUid == KSignerInterface || aInterfaceUid == KAsyncSignerInterface || |
|
2420 aInterfaceUid == KVerifierInterface || aInterfaceUid == KVerifierInterface ) |
|
2421 { |
|
2422 const TLinearOrder<CRulesCharacteristicsAndPluginName> sortOrder(AscendAsymmetricSignatureKeyLength); |
|
2423 |
|
2424 aCharacteristicsDLL.Sort(sortOrder); |
|
2425 } |
|
2426 else if (aInterfaceUid == KKeypairGeneratorInterface || |
|
2427 aInterfaceUid == KAsyncKeypairGeneratorInterface) |
|
2428 { |
|
2429 const TLinearOrder<CRulesCharacteristicsAndPluginName> sortOrder(AscendAsymmetricKeypairGeneratorKeyLength); |
|
2430 |
|
2431 aCharacteristicsDLL.Sort(sortOrder); |
|
2432 } |
|
2433 else |
|
2434 { |
|
2435 //Characteristic not supported |
|
2436 User::Leave(KErrNotSupported); |
|
2437 } |
|
2438 |
|
2439 break; |
|
2440 } |
|
2441 |
|
2442 case KKeySupportModeType: |
|
2443 { |
|
2444 if (aInterfaceUid == KSymmetricCipherInterface || aInterfaceUid == KAsyncSymmetricCipherInterface) |
|
2445 { |
|
2446 const TLinearOrder<CRulesCharacteristicsAndPluginName> sortOrder(AscendSymmetricCipherKeySupport); |
|
2447 |
|
2448 aCharacteristicsDLL.Sort(sortOrder); |
|
2449 } |
|
2450 else if (aInterfaceUid == KAsymmetricCipherInterface || aInterfaceUid == KAsyncAsymmetricCipherInterface) |
|
2451 { |
|
2452 const TLinearOrder<CRulesCharacteristicsAndPluginName> sortOrder(AscendAsymmetricCipherKeySupport); |
|
2453 |
|
2454 aCharacteristicsDLL.Sort(sortOrder); |
|
2455 } |
|
2456 else if (aInterfaceUid == KSignerInterface || aInterfaceUid == KAsyncSignerInterface || |
|
2457 aInterfaceUid == KVerifierInterface || aInterfaceUid == KVerifierInterface ) |
|
2458 { |
|
2459 const TLinearOrder<CRulesCharacteristicsAndPluginName> sortOrder(AscendAsymmetricSignatureKeySupport); |
|
2460 |
|
2461 aCharacteristicsDLL.Sort(sortOrder); |
|
2462 } |
|
2463 else |
|
2464 { |
|
2465 //Characteristic not supported |
|
2466 User::Leave(KErrNotSupported); |
|
2467 } |
|
2468 |
|
2469 break; |
|
2470 } |
|
2471 |
|
2472 default: |
|
2473 { |
|
2474 //Must be an Extended Characteristic |
|
2475 |
|
2476 const TLinearOrder<CRulesCharacteristicsAndPluginName> sortOrder(AscendExtendedCharacteristicL); |
|
2477 |
|
2478 aCharacteristicsDLL.Sort(sortOrder); |
|
2479 |
|
2480 TInt count = aCharacteristicsDLL.Count(); |
|
2481 |
|
2482 //Clean up the array's extended characteristic value |
|
2483 for (TInt i = 0; i < count; ++i) |
|
2484 { |
|
2485 delete aCharacteristicsDLL[i]->iExtendedCharacteristic; |
|
2486 aCharacteristicsDLL[i]->iExtendedCharacteristic = NULL; |
|
2487 } |
|
2488 } |
|
2489 }//switch (ruleCharValue->Uid().iUid) |
|
2490 |
|
2491 return; |
|
2492 } |
|
2493 else |
|
2494 if (operator_r == EOpDescendingSort) |
|
2495 { |
|
2496 switch (ruleCharValue->Uid().iUid) |
|
2497 { |
|
2498 case KMaxConcurrencySupportedType: |
|
2499 { |
|
2500 const TLinearOrder<CRulesCharacteristicsAndPluginName> sortOrder(DescendMaxConcurrencySupported); |
|
2501 |
|
2502 aCharacteristicsDLL.Sort(sortOrder); |
|
2503 break; |
|
2504 } |
|
2505 |
|
2506 case KLatencyType: |
|
2507 { |
|
2508 const TLinearOrder<CRulesCharacteristicsAndPluginName> sortOrder(DescendLatency); |
|
2509 |
|
2510 aCharacteristicsDLL.Sort(sortOrder); |
|
2511 break; |
|
2512 } |
|
2513 |
|
2514 case KThroughputType: |
|
2515 { |
|
2516 const TLinearOrder<CRulesCharacteristicsAndPluginName> sortOrder(DescendThroughput); |
|
2517 |
|
2518 aCharacteristicsDLL.Sort(sortOrder); |
|
2519 break; |
|
2520 } |
|
2521 |
|
2522 case KBlockSizeType: |
|
2523 { |
|
2524 if (aInterfaceUid == KHashInterface || aInterfaceUid == KAsyncHashInterface) |
|
2525 { |
|
2526 const TLinearOrder<CRulesCharacteristicsAndPluginName> sortOrder(DescendHashBlockSize); |
|
2527 |
|
2528 aCharacteristicsDLL.Sort(sortOrder); |
|
2529 } |
|
2530 else if (aInterfaceUid == KSymmetricCipherInterface || aInterfaceUid == KAsyncSymmetricCipherInterface) |
|
2531 { |
|
2532 const TLinearOrder<CRulesCharacteristicsAndPluginName> sortOrder(DescendSymmetricCipherBlockSize); |
|
2533 |
|
2534 aCharacteristicsDLL.Sort(sortOrder); |
|
2535 } |
|
2536 else |
|
2537 { |
|
2538 //Characteristic not supported |
|
2539 User::Leave(KErrNotSupported); |
|
2540 } |
|
2541 |
|
2542 break; |
|
2543 } |
|
2544 |
|
2545 case KOutputSizeType: |
|
2546 { |
|
2547 const TLinearOrder<CRulesCharacteristicsAndPluginName> sortOrder(DescendHashOutputSize); |
|
2548 |
|
2549 aCharacteristicsDLL.Sort(sortOrder); |
|
2550 break; |
|
2551 } |
|
2552 |
|
2553 case KBlockingModeType: |
|
2554 { |
|
2555 const TLinearOrder<CRulesCharacteristicsAndPluginName> sortOrder(DescendRandomBlockingMode); |
|
2556 |
|
2557 aCharacteristicsDLL.Sort(sortOrder); |
|
2558 break; |
|
2559 } |
|
2560 |
|
2561 case KMaximumKeyLengthType: |
|
2562 { |
|
2563 if (aInterfaceUid == KSymmetricCipherInterface || aInterfaceUid == KAsyncSymmetricCipherInterface) |
|
2564 { |
|
2565 const TLinearOrder<CRulesCharacteristicsAndPluginName> sortOrder(DescendSymmetricCipherKeyLength); |
|
2566 |
|
2567 aCharacteristicsDLL.Sort(sortOrder); |
|
2568 } |
|
2569 else if (aInterfaceUid == KAsymmetricCipherInterface || aInterfaceUid == KAsyncAsymmetricCipherInterface) |
|
2570 { |
|
2571 const TLinearOrder<CRulesCharacteristicsAndPluginName> sortOrder(DescendAsymmetricCipherKeyLength); |
|
2572 |
|
2573 aCharacteristicsDLL.Sort(sortOrder); |
|
2574 } |
|
2575 else if (aInterfaceUid == KSignerInterface || aInterfaceUid == KAsyncSignerInterface || |
|
2576 aInterfaceUid == KVerifierInterface || aInterfaceUid == KVerifierInterface ) |
|
2577 { |
|
2578 const TLinearOrder<CRulesCharacteristicsAndPluginName> sortOrder(DescendAsymmetricSignatureKeyLength); |
|
2579 |
|
2580 aCharacteristicsDLL.Sort(sortOrder); |
|
2581 } |
|
2582 else if (aInterfaceUid == KKeypairGeneratorInterface || |
|
2583 aInterfaceUid == KAsyncKeypairGeneratorInterface) |
|
2584 { |
|
2585 const TLinearOrder<CRulesCharacteristicsAndPluginName> sortOrder(DescendAsymmetricKeypairGeneratorKeyLength); |
|
2586 |
|
2587 aCharacteristicsDLL.Sort(sortOrder); |
|
2588 } |
|
2589 else |
|
2590 { |
|
2591 //Characteristic not supported |
|
2592 User::Leave(KErrNotSupported); |
|
2593 } |
|
2594 |
|
2595 break; |
|
2596 } |
|
2597 |
|
2598 case KKeySupportModeType: |
|
2599 { |
|
2600 if (aInterfaceUid == KSymmetricCipherInterface || aInterfaceUid == KAsyncSymmetricCipherInterface) |
|
2601 { |
|
2602 const TLinearOrder<CRulesCharacteristicsAndPluginName> sortOrder(DescendSymmetricCipherKeySupport); |
|
2603 |
|
2604 aCharacteristicsDLL.Sort(sortOrder); |
|
2605 } |
|
2606 else if (aInterfaceUid == KAsymmetricCipherInterface || aInterfaceUid == KAsyncAsymmetricCipherInterface) |
|
2607 { |
|
2608 const TLinearOrder<CRulesCharacteristicsAndPluginName> sortOrder(DescendAsymmetricCipherKeySupport); |
|
2609 |
|
2610 aCharacteristicsDLL.Sort(sortOrder); |
|
2611 } |
|
2612 else if (aInterfaceUid == KSignerInterface || aInterfaceUid == KAsyncSignerInterface || |
|
2613 aInterfaceUid == KVerifierInterface || aInterfaceUid == KVerifierInterface ) |
|
2614 { |
|
2615 const TLinearOrder<CRulesCharacteristicsAndPluginName> sortOrder(DescendAsymmetricSignatureKeySupport); |
|
2616 |
|
2617 aCharacteristicsDLL.Sort(sortOrder); |
|
2618 } |
|
2619 else |
|
2620 { |
|
2621 //Characteristic not supported |
|
2622 User::Leave(KErrNotSupported); |
|
2623 } |
|
2624 |
|
2625 break; |
|
2626 } |
|
2627 |
|
2628 default: |
|
2629 { |
|
2630 //Must be an Extended Characteristic |
|
2631 |
|
2632 const TLinearOrder<CRulesCharacteristicsAndPluginName> sortOrder(DescendExtendedCharacteristicL); |
|
2633 |
|
2634 aCharacteristicsDLL.Sort(sortOrder); |
|
2635 |
|
2636 TInt count = aCharacteristicsDLL.Count(); |
|
2637 |
|
2638 //Clean up the array's extended characteristic value |
|
2639 for (TInt i = 0; i < count; ++i) |
|
2640 { |
|
2641 delete aCharacteristicsDLL[i]->iExtendedCharacteristic; |
|
2642 aCharacteristicsDLL[i]->iExtendedCharacteristic = NULL; |
|
2643 } |
|
2644 } |
|
2645 } |
|
2646 |
|
2647 return; |
|
2648 } |
|
2649 |
|
2650 //Try adding it as optional |
|
2651 TryAddToOptionalCharListL(aInterfaceUid, *(aCharacteristicsDLL[0]), aRules); |
|
2652 } |
|
2653 |
|
2654 |
|
2655 void CRuleSelector::TryAddToOptionalCharListL(TInt32 aInterfaceUid, CRulesCharacteristicsAndPluginName& aCharacteristics, |
|
2656 CSelectionRuleContent* aRules) |
|
2657 { |
|
2658 if (iToggleUseMap) |
|
2659 { |
|
2660 //Only if we are not sorting the list |
|
2661 if (aRules->IsOptionalRule()) |
|
2662 { |
|
2663 //Optional: Build it to the end of iSelectedInterfaceCharacteristicsMap |
|
2664 AddOptionalToCharListL(aInterfaceUid, aCharacteristics); |
|
2665 } |
|
2666 else |
|
2667 { |
|
2668 delete &aCharacteristics; |
|
2669 } |
|
2670 } |
|
2671 } |
|
2672 |
|
2673 void CRuleSelector::AddToCharListL(TInt32 aInterfaceUid, CRulesCharacteristicsAndPluginName& aCharacteristics, TInt& aLastPreference) |
|
2674 { |
|
2675 RPointerArray<CRulesCharacteristicsAndPluginName>** charsListPtr = NULL; |
|
2676 RPointerArray<CRulesCharacteristicsAndPluginName>* charsList=NULL; |
|
2677 |
|
2678 if (iUseMapAToFilter) |
|
2679 { |
|
2680 charsListPtr = iSelectedInterfaceCharacteristics_MapB.Find(aInterfaceUid); |
|
2681 } |
|
2682 else |
|
2683 { |
|
2684 charsListPtr = iSelectedInterfaceCharacteristics_MapA.Find(aInterfaceUid); |
|
2685 } |
|
2686 |
|
2687 //create new one if it is not in the map |
|
2688 if (!charsListPtr) |
|
2689 { |
|
2690 RPointerArray<CRulesCharacteristicsAndPluginName>* newCharsList = new(ELeave) RPointerArray<CRulesCharacteristicsAndPluginName>; |
|
2691 |
|
2692 charsList = newCharsList; |
|
2693 |
|
2694 if (iUseMapAToFilter) |
|
2695 { |
|
2696 iSelectedInterfaceCharacteristics_MapB.InsertL(aInterfaceUid, newCharsList); |
|
2697 } |
|
2698 else |
|
2699 { |
|
2700 iSelectedInterfaceCharacteristics_MapA.InsertL(aInterfaceUid, newCharsList); |
|
2701 } |
|
2702 } |
|
2703 else |
|
2704 { |
|
2705 //Use the existing one. |
|
2706 charsList = *charsListPtr; |
|
2707 } |
|
2708 |
|
2709 //Check the insert possition is greater than the number of objects currently in the array |
|
2710 if (charsList->Count() > aLastPreference) |
|
2711 { |
|
2712 charsList->InsertL(&aCharacteristics, aLastPreference); |
|
2713 } |
|
2714 else |
|
2715 { |
|
2716 charsList->AppendL(&aCharacteristics); |
|
2717 } |
|
2718 |
|
2719 aLastPreference++; |
|
2720 } |
|
2721 |
|
2722 void CRuleSelector::AddOptionalToCharListL(TInt32 aInterfaceUid, CRulesCharacteristicsAndPluginName& aCharacteristics) |
|
2723 { |
|
2724 if(iToggleUseMap) |
|
2725 { |
|
2726 RPointerArray<CRulesCharacteristicsAndPluginName>** charsListPtr = NULL; |
|
2727 RPointerArray<CRulesCharacteristicsAndPluginName>* charsList=NULL; |
|
2728 |
|
2729 if (iUseMapAToFilter) |
|
2730 { |
|
2731 charsListPtr = iSelectedInterfaceCharacteristics_MapB.Find(aInterfaceUid); |
|
2732 } |
|
2733 else |
|
2734 { |
|
2735 charsListPtr = iSelectedInterfaceCharacteristics_MapA.Find(aInterfaceUid); |
|
2736 } |
|
2737 |
|
2738 //create new one if it is not in the map |
|
2739 if (!charsListPtr) |
|
2740 { |
|
2741 RPointerArray<CRulesCharacteristicsAndPluginName>* newCharsList = new(ELeave) RPointerArray<CRulesCharacteristicsAndPluginName>; |
|
2742 |
|
2743 charsList = newCharsList; |
|
2744 |
|
2745 if (iUseMapAToFilter) |
|
2746 { |
|
2747 iSelectedInterfaceCharacteristics_MapB.InsertL(aInterfaceUid, newCharsList); |
|
2748 } |
|
2749 else |
|
2750 { |
|
2751 iSelectedInterfaceCharacteristics_MapA.InsertL(aInterfaceUid, newCharsList); |
|
2752 } |
|
2753 } |
|
2754 else |
|
2755 { |
|
2756 //Use the existing one. |
|
2757 charsList = *charsListPtr; |
|
2758 } |
|
2759 |
|
2760 //Add it to the end of the list |
|
2761 charsList->AppendL(&aCharacteristics); |
|
2762 } |
|
2763 } |
|
2764 |
|
2765 void CRuleSelector::ConstructMapAL() |
|
2766 { |
|
2767 TInt interfaceCount = sizeof(KInterfacesUids)/sizeof(KInterfacesUids[0]); |
|
2768 |
|
2769 for (TInt i = 0; i < interfaceCount; ++i) |
|
2770 { |
|
2771 RPointerArray<CRulesCharacteristicsAndPluginName>* characteristicsLists = new(ELeave) RPointerArray<CRulesCharacteristicsAndPluginName>; |
|
2772 |
|
2773 |
|
2774 CryptoSpiUtil::RetrieveCharacteristicsL(KInterfacesUids[i].iUid, *characteristicsLists); |
|
2775 iSelectedInterfaceCharacteristics_MapA.InsertL(KInterfacesUids[i].iUid, characteristicsLists); |
|
2776 } |
|
2777 } |
|
2778 |
|
2779 TInt CRuleSelector::FindPlugin(TUid aInterfaceUid, TUid aAlgorithmUid, TUid& aImplementationId, TFileName& aDllName) |
|
2780 { |
|
2781 TInt ret=KErrNone; |
|
2782 |
|
2783 /** |
|
2784 * 'iActiveInterfaceCharacteristics_Map' contains the sorted out interface's |
|
2785 * characteristics/plugins according to the rule defined by user application. |
|
2786 * We collect all the interface's characteristics in 'list'. |
|
2787 */ |
|
2788 RPointerArray<CRulesCharacteristicsAndPluginName>* const* list=iActiveInterfaceCharacteristics_Map->Find(aInterfaceUid.iUid); |
|
2789 |
|
2790 if (list) |
|
2791 { |
|
2792 /** |
|
2793 * Fetches the index which was set on last successful plugin search so |
|
2794 * as to start the search for a different algorithm implementation/plugin. |
|
2795 * The index was set by calling |
|
2796 * SetSearchRecord(aInterfaceUid, index_to_start_for_next_serach) |
|
2797 */ |
|
2798 |
|
2799 TInt* nextCharToTryPtr=iNextTryCharacteristicsIndex.Find(aInterfaceUid.iUid); |
|
2800 TInt nextCharToTry=0; |
|
2801 |
|
2802 if (nextCharToTryPtr) |
|
2803 { |
|
2804 nextCharToTry=*nextCharToTryPtr; |
|
2805 } |
|
2806 |
|
2807 TInt count=(**list).Count(); |
|
2808 TBool found=EFalse; |
|
2809 TInt i=0; |
|
2810 |
|
2811 for (i=nextCharToTry;i<count;i++) |
|
2812 { |
|
2813 const CCharacteristics* cmn((**list)[i]->iCharacteristic); |
|
2814 |
|
2815 /** |
|
2816 * A plugin symbolizes an algorithm's implementation. It has characteristics of its own. |
|
2817 * There can be several plugins dlls (i.e. dll which contains several plugins) which can contain |
|
2818 * algorithm implementations. It is therefore desirable for the CryptoSpi framework to define |
|
2819 * a mechanism using which a user appication can select the desired implementation by |
|
2820 * using the Rules. |
|
2821 * The Rules are defined on the interafce level or at algorithm level. |
|
2822 * There can be a certain ambiguity when defining a Rule. |
|
2823 * ex: Interace : KHashInterface |
|
2824 * ex: Algorithm Rule: may be on block size, output size, etc... |
|
2825 * By sorting using these rules, an Interface of the framework can have several plugins |
|
2826 * stored in the 'iActiveInterfaceCharacteristics_Map'. The first match of 'algorithmUid' |
|
2827 * will fetch that plugin. |
|
2828 */ |
|
2829 |
|
2830 if (aAlgorithmUid.iUid == cmn->iAlgorithmUid) |
|
2831 { |
|
2832 aImplementationId.iUid = cmn->iImplementationUid; |
|
2833 aDllName = (**list)[i]->iDllName; |
|
2834 found=ETrue; |
|
2835 break; |
|
2836 } |
|
2837 } |
|
2838 |
|
2839 if (!found) |
|
2840 { |
|
2841 /** |
|
2842 * If algorithm implementation not found then we do not set the index |
|
2843 * This means the user can specify some rules which can behave as a |
|
2844 * threshold value. Numerous plugins can be selected which pass this threshold |
|
2845 * value. But if the specific algorithm UID desired doesn't match then we |
|
2846 * return with 'KErrNotFound'. |
|
2847 * ex: User can specify Block Size > 64 for which there can be several matches |
|
2848 * under a Hash Interface like MD2, MD5, etc. But if the user later want MD5 and |
|
2849 * if there is no match, then we return with 'KErrNotFound'. |
|
2850 */ |
|
2851 ret=KErrNotFound; |
|
2852 } |
|
2853 else |
|
2854 { |
|
2855 /** |
|
2856 * This will set the index for a particular 'aInterfaceUid'. |
|
2857 * Next time the same interface is visited, the search will |
|
2858 * start from this index. |
|
2859 */ |
|
2860 SetSearchRecord(aInterfaceUid, i+1); |
|
2861 } |
|
2862 } |
|
2863 else |
|
2864 { |
|
2865 /** |
|
2866 * This can be a case when the all the plugins for that interface |
|
2867 * don't fullfill the criteria set by the user application by |
|
2868 * defining the rule for the rule based selector. |
|
2869 */ |
|
2870 return KErrNotFound; |
|
2871 } |
|
2872 |
|
2873 return ret; |
|
2874 } |
|
2875 |
|
2876 void CRuleSelector::SetSearchRecord(TUid aInterfaceUid, TInt aValue) |
|
2877 { |
|
2878 TInt* value=iNextTryCharacteristicsIndex.Find(aInterfaceUid.iUid); |
|
2879 |
|
2880 if (value) |
|
2881 { |
|
2882 *value=aValue; |
|
2883 } |
|
2884 } |
|
2885 |
|
2886 void CRuleSelector::LoadPluginsL() |
|
2887 { |
|
2888 if (iPluginDllList.Count() == 0) |
|
2889 { |
|
2890 //Load all the plugins, if it hasn't done before |
|
2891 for (TInt dllIndex=0; ; ++dllIndex) |
|
2892 { |
|
2893 TFileName filename; |
|
2894 |
|
2895 if (CryptoSpiUtil::DllIndexToName(dllIndex, filename) == KErrNotFound) |
|
2896 { |
|
2897 return; |
|
2898 } |
|
2899 |
|
2900 //Load... |
|
2901 RLibrary lib; |
|
2902 CryptoSpiUtil::LoadPluginDllLC(lib, filename); |
|
2903 iPluginDllList.AppendL(lib); |
|
2904 CleanupStack::Pop(&lib); |
|
2905 } |
|
2906 } |
|
2907 } |
|
2908 |
|
2909 // |
|
2910 // Implementation of CRulesCharacteristicsAndPluginName |
|
2911 // |
|
2912 CRulesCharacteristicsAndPluginName* CRulesCharacteristicsAndPluginName::NewLC(TInt32 aInterface) |
|
2913 { |
|
2914 CRulesCharacteristicsAndPluginName* self=new(ELeave) CRulesCharacteristicsAndPluginName(); |
|
2915 CleanupStack::PushL(self); |
|
2916 self->ConstructL(aInterface); |
|
2917 return self; |
|
2918 } |
|
2919 |
|
2920 CRulesCharacteristicsAndPluginName::CRulesCharacteristicsAndPluginName() |
|
2921 { |
|
2922 } |
|
2923 |
|
2924 void CRulesCharacteristicsAndPluginName::ConstructL(TInt32 aInterface) |
|
2925 { |
|
2926 CCharacteristicsAndPluginName::ConstructL(aInterface); |
|
2927 } |
|
2928 |
|
2929 CRulesCharacteristicsAndPluginName::~CRulesCharacteristicsAndPluginName() |
|
2930 { |
|
2931 } |
|
2932 |
|
2933 TInt CRuleSelector::AscendExtendedCharacteristicL(const CRulesCharacteristicsAndPluginName& aLeft, const CRulesCharacteristicsAndPluginName& aRight) |
|
2934 { |
|
2935 CExtendedCharacteristics* extCharLeft = aLeft.iExtendedCharacteristic; |
|
2936 TUid leftUid = {aLeft.iSortUid}; |
|
2937 TInt leftInt = extCharLeft->GetTIntCharacteristicL(leftUid); |
|
2938 CExtendedCharacteristics* extCharRight = aRight.iExtendedCharacteristic; |
|
2939 TUid rightUid = {aRight.iSortUid}; |
|
2940 TInt rightInt = extCharRight->GetTIntCharacteristicL(rightUid); |
|
2941 |
|
2942 return (leftInt - rightInt); |
|
2943 } |
|
2944 |
|
2945 TInt CRuleSelector::DescendExtendedCharacteristicL(const CRulesCharacteristicsAndPluginName& aLeft, const CRulesCharacteristicsAndPluginName& aRight) |
|
2946 { |
|
2947 CExtendedCharacteristics* extCharLeft = aLeft.iExtendedCharacteristic; |
|
2948 TUid leftUid = {aLeft.iSortUid}; |
|
2949 TInt leftInt = extCharLeft->GetTIntCharacteristicL(leftUid); |
|
2950 CExtendedCharacteristics* extCharRight = aRight.iExtendedCharacteristic; |
|
2951 TUid rightUid = {aRight.iSortUid}; |
|
2952 TInt rightInt = extCharRight->GetTIntCharacteristicL(rightUid); |
|
2953 |
|
2954 return (rightInt - leftInt); |
|
2955 } |
|
2956 |
|
2957 TInt CRuleSelector::AscendExtendedTDesC8L(const CRulesCharacteristicsAndPluginName& aLeft, const CRulesCharacteristicsAndPluginName& aRight) |
|
2958 { |
|
2959 CExtendedCharacteristics* extCharLeft = aLeft.iExtendedCharacteristic; |
|
2960 TUid leftUid = {aLeft.iSortUid}; |
|
2961 const TDesC8& leftDes = extCharLeft->GetTDesC8CharacteristicL(leftUid); |
|
2962 CExtendedCharacteristics* extCharRight = aRight.iExtendedCharacteristic; |
|
2963 TUid rightUid = {aRight.iSortUid}; |
|
2964 const TDesC8& rightDes = extCharRight->GetTDesC8CharacteristicL(rightUid); |
|
2965 |
|
2966 return leftDes.CompareC(rightDes); |
|
2967 } |
|
2968 |
|
2969 TInt CRuleSelector::DescendExtendedTDesC8L(const CRulesCharacteristicsAndPluginName& aLeft, const CRulesCharacteristicsAndPluginName& aRight) |
|
2970 { |
|
2971 CExtendedCharacteristics* extCharLeft = aLeft.iExtendedCharacteristic; |
|
2972 TUid leftUid = {aLeft.iSortUid}; |
|
2973 const TDesC8& leftDes = extCharLeft->GetTDesC8CharacteristicL(leftUid); |
|
2974 CExtendedCharacteristics* extCharRight = aRight.iExtendedCharacteristic; |
|
2975 TUid rightUid = {aRight.iSortUid}; |
|
2976 const TDesC8& rightDes = extCharRight->GetTDesC8CharacteristicL(rightUid); |
|
2977 |
|
2978 return rightDes.CompareC(leftDes); |
|
2979 } |
|
2980 |
|
2981 // Methods which are not supported and non exported can be excluded from the coverage. |
|
2982 #ifdef _BullseyeCoverage |
|
2983 #pragma suppress_warnings on |
|
2984 #pragma BullseyeCoverage off |
|
2985 #pragma suppress_warnings off |
|
2986 #endif |
|
2987 |
|
2988 void CRuleSelector::CreateAsyncHashL(CAsyncHash*& /*aHash*/, |
|
2989 TUid /*aAlgorithmUid*/, |
|
2990 TUid /*aOperationMode*/, |
|
2991 const CKey* /*aKey*/, |
|
2992 const CCryptoParams* /*aAlgorithmParams*/) |
|
2993 { |
|
2994 User::Leave(KErrNotSupported); |
|
2995 } |
|
2996 |
|
2997 #ifdef SYMBIAN_SDP_IPSEC_VOIP_SUPPORT |
|
2998 |
|
2999 void CRuleSelector::CreateAsyncHashL(CAsyncHash*& /*aHash*/, |
|
3000 TUid /*aAlgorithmUid*/, |
|
3001 const CCryptoParams* /*aAlgorithmParams*/) |
|
3002 { |
|
3003 User::Leave(KErrNotSupported); |
|
3004 } |
|
3005 |
|
3006 void CRuleSelector::CreateAsyncMacL(CAsyncMac*& /*aMac*/, |
|
3007 const TUid /*aAlgorithmUid*/, |
|
3008 const CKey& /*aKey*/, |
|
3009 const CCryptoParams* /*aAlgorithmParams*/) |
|
3010 { |
|
3011 User::Leave(KErrNotSupported); |
|
3012 } |
|
3013 |
|
3014 #endif |
|
3015 |
|
3016 void CRuleSelector::CreateAsyncRandomL(CAsyncRandom*& /*aRandom*/, |
|
3017 TUid /*aAlgorithmUid*/, |
|
3018 const CCryptoParams* /*aAlgorithmParams*/) |
|
3019 |
|
3020 { |
|
3021 User::Leave(KErrNotSupported); |
|
3022 } |
|
3023 |
|
3024 void CRuleSelector::CreateAsyncSymmetricCipherL(CAsyncSymmetricCipher*& /*aCipher*/, |
|
3025 TUid /*aAlgorithmUid*/, |
|
3026 const CKey& /*aKey*/, |
|
3027 TUid /*aCryptoMode*/, |
|
3028 TUid /*aOperationMode*/, |
|
3029 TUid /*aPaddingMode*/, |
|
3030 const CCryptoParams* /*aAlgorithmParams*/) |
|
3031 |
|
3032 { |
|
3033 User::Leave(KErrNotSupported); |
|
3034 } |
|
3035 |
|
3036 void CRuleSelector::CreateAsyncAsymmetricCipherL(CAsyncAsymmetricCipher*& /*aCipher*/, |
|
3037 TUid /*aAlgorithmUid*/, |
|
3038 const CKey& /*aKey*/, |
|
3039 TUid /*aCryptoMode*/, |
|
3040 TUid /*aPaddingMode*/, |
|
3041 const CCryptoParams* /*aAlgorithmParams*/) |
|
3042 { |
|
3043 User::Leave(KErrNotSupported); |
|
3044 } |
|
3045 |
|
3046 void CRuleSelector::CreateAsyncSignerL(CAsyncSigner*& /*aSigner*/, |
|
3047 TUid /*aAlgorithmUid*/, |
|
3048 const CKey& /*aKey*/, |
|
3049 TUid /*aPaddingMode*/, |
|
3050 const CCryptoParams* /*aAlgorithmParams*/) |
|
3051 { |
|
3052 User::Leave(KErrNotSupported); |
|
3053 } |
|
3054 |
|
3055 void CRuleSelector::CreateAsyncVerifierL(CAsyncVerifier*& /*aVerifier*/, |
|
3056 TUid /*aAlgorithmUid*/, |
|
3057 const CKey& /*aKey*/, |
|
3058 TUid /*aPaddingMode*/, |
|
3059 const CCryptoParams* /*aAlgorithmParams*/) |
|
3060 { |
|
3061 User::Leave(KErrNotSupported); |
|
3062 } |
|
3063 |
|
3064 void CRuleSelector::CreateAsyncKeyPairGeneratorL(CAsyncKeyPairGenerator*& /*aKeyPairGenerator*/, |
|
3065 TUid /*aAlgorithmUid*/, |
|
3066 const CCryptoParams* /*aAlgorithmParams*/) |
|
3067 { |
|
3068 User::Leave(KErrNotSupported); |
|
3069 } |
|
3070 |
|
3071 void CRuleSelector::CreateAsyncKeyAgreementL(CAsyncKeyAgreement*& /*aKeyAgreement*/, |
|
3072 TUid /*aAlgorithmUid*/, |
|
3073 const CKey& /*aPrivateKey*/, |
|
3074 const CCryptoParams* /*aAlgorithmParams*/) |
|
3075 { |
|
3076 User::Leave(KErrNotSupported); |
|
3077 } |
|
3078 |
|
3079 CRulesCharacteristicsAndPluginName* CRulesCharacteristicsAndPluginName::NewL(TInt32 aInterface) |
|
3080 { |
|
3081 CRulesCharacteristicsAndPluginName* self=CRulesCharacteristicsAndPluginName::NewLC(aInterface); |
|
3082 CleanupStack::Pop(self); |
|
3083 return self; |
|
3084 } |