Update contrib.
2 * Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
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".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
15 * Rule-based plugin selector definition
26 #ifndef __CRYPTOAPI_RULESELECTOR_H__
27 #define __CRYPTOAPI_RULESELECTOR_H__
29 #include <cryptospi/pluginselectorbase.h>
30 #include <cryptospi/cryptocharacteristics.h>
31 #include <e32hashtab.h>
32 #include <cryptospi/cryptoparams.h>
34 #ifndef SYMBIAN_ENABLE_SPLIT_HEADERS
35 #include <rulecharacteristics.h>
42 The operators of the plugin selection rule
69 EOpGreaterThanOrEqual,
77 Ascending Sort of an characteristic
82 Descending Sort of an characteristic
87 The total number of operators
92 class CRulesCharacteristicsAndPluginName;
94 A single plugin selection rule definition
96 NONSHARABLE_CLASS(CSelectionRuleContent) : public CBase
100 Create a selection rule content instance; the supported characteristic uid's are
101 defined in plugincharacteristics.h; the supported operators are defined in ruleselector.h
102 @param aInterfaceScope The Interface scope of this rule
103 @param aAlgorithmScope The Algorithm scope of this rule
104 @param aCharacteristicValue The value of the rule of this characteristic
105 @param aOperator The operator of the rule
106 @param aIsOptional Whether this rule is optional or mandatory
107 @return A pointer to a CSelectionRuleContent instance
109 IMPORT_C static CSelectionRuleContent* NewL(TUid aInterfaceScope,
110 TUid aAlgorithmScope,
111 CCryptoParam* aCharacteristicValue,
112 TRuleOperator aOperator,
117 IMPORT_C ~CSelectionRuleContent();
122 * Get the Interface Scope of this rule
123 * @return the Interface Scope Uid of this rule
125 TUid GetInterfaceScope();
130 * Get the Algorithm Scope of this rule
131 * @return the Algorithm Scope Uid of this rule
133 TUid GetAlgorithmScope();
138 * Get the Rule operator
139 * @return The Rule operator
146 * Get the value of the rule of this characteristic
147 * @return The value of the rule of this characteristic
149 const CCryptoParam* GetCharacteristicValue();
154 * returns whether the rule is optional
155 * @return Whether the rule is optional
157 TBool IsOptionalRule();
163 CSelectionRuleContent(TUid aInterfaceScope,
164 TUid aAlgorithmScope,
165 CCryptoParam* aCharacteristicValue,
166 TRuleOperator aOperator,
170 The scopes of this rule
172 TUid iInterfaceScope;
173 TUid iAlgorithmScope;
176 The value of the rule of this characteristic
178 const CCryptoParam* iCharacteristicValue;
181 The Operator of the Characteristic
183 TRuleOperator iOperator;
186 if the rule on this characteristic is optional
193 Definition of rule-based plugin selection rules
195 NONSHARABLE_CLASS(CSelectionRules) : public CBase
199 create a Selection Rule instance which will hold the rules to filter the plugins
200 @return a pointer to a CSelectionRules instance
202 IMPORT_C static CSelectionRules* NewL();
207 IMPORT_C ~CSelectionRules();
210 Add a selection rule the this object
211 @param aSelectionRule The rule to be added
213 IMPORT_C void AddSelectionRuleL(CSelectionRuleContent* aSelectionRule);
218 * Get the selection rules
219 * @return The reference of the rules
221 RPointerArray<CSelectionRuleContent>& GetSelectionRules();
230 a group of plugin rules
232 RPointerArray<CSelectionRuleContent> iRules;
236 Selector apply the rule-based selection to find the plugin.
238 NONSHARABLE_CLASS(CRuleSelector) : public CBase, public MPluginSelector
242 NewL create the ruled-based selector
243 @param aRules The Rules to select the plugins
244 @return a pointer to a CRuleSelector instance
246 IMPORT_C static CRuleSelector* NewL(CSelectionRules* aRules);
247 IMPORT_C static CRuleSelector* NewLC(CSelectionRules* aRules);
252 IMPORT_C ~CRuleSelector();
257 * virtual function from MPluginSelector
259 virtual void CreateHashL(CHash*& aHash,
263 const CCryptoParams* aAlgorithmParams);
265 //virtual function from MPluginSelector
266 virtual void CreateRandomL(CRandom*& aRandom,
268 const CCryptoParams* aAlgorithmParams);
270 //virtual function from MPluginSelector
271 virtual void CreateSymmetricCipherL(CSymmetricCipher*& aCipher,
277 const CCryptoParams* aAlgorithmParams);
279 //virtual function from MPluginSelector
280 virtual void CreateAsymmetricCipherL(CAsymmetricCipher*& aCipher,
285 const CCryptoParams* aAlgorithmParams);
287 //virtual function from MPluginSelector
288 virtual void CreateSignerL(CSigner*& aSigner,
292 const CCryptoParams* aAlgorithmParams);
294 //virtual function from MPluginSelector
295 virtual void CreateVerifierL(CVerifier*& aVerifier,
299 const CCryptoParams* aAlgorithmParams);
301 //virtual function from MPluginSelector
302 virtual void CreateKeyPairGeneratorL(CKeyPairGenerator*& aKeyPairGenerator,
303 TUid aKeyAlgorithmUid,
304 const CCryptoParams* aAlgorithmParams);
306 //virtual function from MPluginSelector
307 virtual void CreateKeyAgreementL(CKeyAgreement*& aKeyAgreement,
309 const CKey& aPrivateKey,
310 const CCryptoParams* aAlgorithmParams);
315 * virtual function from MPluginSelector
317 virtual void CreateAsyncHashL(CAsyncHash*& aHash,
321 const CCryptoParams* aAlgorithmParams);
323 //virtual function from MPluginSelector
324 virtual void CreateAsyncRandomL(CAsyncRandom*& aRandom,
326 const CCryptoParams* aAlgorithmParams);
328 //virtual function from MPluginSelector
329 virtual void CreateAsyncSymmetricCipherL(CAsyncSymmetricCipher*& aCipher,
335 const CCryptoParams* aAlgorithmParams);
337 //virtual function from MPluginSelector
338 virtual void CreateAsyncAsymmetricCipherL(CAsyncAsymmetricCipher*& aCipher,
343 const CCryptoParams* aAlgorithmParams);
345 //virtual function from MPluginSelector
346 virtual void CreateAsyncSignerL(CAsyncSigner*& aSigner,
350 const CCryptoParams* aAlgorithmParams);
352 //virtual function from MPluginSelector
353 virtual void CreateAsyncVerifierL(CAsyncVerifier*& aVerifier,
357 const CCryptoParams* aAlgorithmParams);
359 //virtual function from MPluginSelector
360 virtual void CreateAsyncKeyPairGeneratorL(CAsyncKeyPairGenerator*& aKeyPairGenerator,
362 const CCryptoParams* aAlgorithmParams);
364 //virtual function from MPluginSelector
365 virtual void CreateAsyncKeyAgreementL(CAsyncKeyAgreement*& aKeyAgreement,
367 const CKey& aPrivateKey,
368 const CCryptoParams* aAlgorithmParams);
370 #ifdef SYMBIAN_SDP_IPSEC_VOIP_SUPPORT
372 //virtual function from MPluginSelector
373 virtual void CreateMacL(CMac*& aMac,
374 const TUid aAlgorithmUid,
376 const CCryptoParams* aAlgorithmParams);
378 //virtual function from MPluginSelector
379 virtual void CreateAsyncMacL(CAsyncMac*& aMac,
380 const TUid aAlgorithmUid,
382 const CCryptoParams* aAlgorithmParams);
384 //virtual function from MPluginSelector
385 virtual void CreateHashL(CHash*& aHash,
387 const CCryptoParams* aAlgorithmParams);
389 //virtual function from MPluginSelector
390 virtual void CreateAsyncHashL(CAsyncHash*& aHash,
392 const CCryptoParams* aAlgorithmParams);
396 /** @internalComponent */
397 static TInt AscendCreatorName(const CRulesCharacteristicsAndPluginName& aLeft, const CRulesCharacteristicsAndPluginName& aRight);
399 /** @internalComponent */
400 static TInt DescendCreatorName(const CRulesCharacteristicsAndPluginName& aLeft, const CRulesCharacteristicsAndPluginName& aRight);
402 /** @internalComponent */
403 static TInt AscendExtendedTDesC8L(const CRulesCharacteristicsAndPluginName& aLeft, const CRulesCharacteristicsAndPluginName& aRight);
405 /** @internalComponent */
406 static TInt DescendExtendedTDesC8L(const CRulesCharacteristicsAndPluginName& aLeft, const CRulesCharacteristicsAndPluginName& aRight);
408 /** @internalComponent */
409 static TInt AscendMaxConcurrencySupported(const CRulesCharacteristicsAndPluginName& aLeft, const CRulesCharacteristicsAndPluginName& aRight);
411 /** @internalComponent */
412 static TInt DescendMaxConcurrencySupported(const CRulesCharacteristicsAndPluginName& aLeft, const CRulesCharacteristicsAndPluginName& aRight);
414 /** @internalComponent */
415 static TInt AscendLatency(const CRulesCharacteristicsAndPluginName& aLeft, const CRulesCharacteristicsAndPluginName& aRight);
417 /** @internalComponent */
418 static TInt DescendLatency(const CRulesCharacteristicsAndPluginName& aLeft, const CRulesCharacteristicsAndPluginName& aRight);
420 /** @internalComponent */
421 static TInt AscendThroughput(const CRulesCharacteristicsAndPluginName& aLeft, const CRulesCharacteristicsAndPluginName& aRight);
423 /** @internalComponent */
424 static TInt DescendThroughput(const CRulesCharacteristicsAndPluginName& aLeft, const CRulesCharacteristicsAndPluginName& aRight);
426 /** @internalComponent */
427 static TInt AscendHashBlockSize(const CRulesCharacteristicsAndPluginName& aLeft, const CRulesCharacteristicsAndPluginName& aRight);
429 /** @internalComponent */
430 static TInt DescendHashBlockSize(const CRulesCharacteristicsAndPluginName& aLeft, const CRulesCharacteristicsAndPluginName& aRight);
432 /** @internalComponent */
433 static TInt AscendSymmetricCipherBlockSize(const CRulesCharacteristicsAndPluginName& aLeft, const CRulesCharacteristicsAndPluginName& aRight);
435 /** @internalComponent */
436 static TInt DescendSymmetricCipherBlockSize(const CRulesCharacteristicsAndPluginName& aLeft, const CRulesCharacteristicsAndPluginName& aRight);
438 /** @internalComponent */
439 static TInt AscendHashOutputSize(const CRulesCharacteristicsAndPluginName& aLeft, const CRulesCharacteristicsAndPluginName& aRight);
441 /** @internalComponent */
442 static TInt DescendHashOutputSize(const CRulesCharacteristicsAndPluginName& aLeft, const CRulesCharacteristicsAndPluginName& aRight);
444 /** @internalComponent */
445 static TInt AscendRandomBlockingMode(const CRulesCharacteristicsAndPluginName& aLeft, const CRulesCharacteristicsAndPluginName& aRight);
447 /** @internalComponent */
448 static TInt DescendRandomBlockingMode(const CRulesCharacteristicsAndPluginName& aLeft, const CRulesCharacteristicsAndPluginName& aRight);
450 /** @internalComponent */
451 static TInt AscendSymmetricCipherKeyLength(const CRulesCharacteristicsAndPluginName& aLeft, const CRulesCharacteristicsAndPluginName& aRight);
453 /** @internalComponent */
454 static TInt DescendSymmetricCipherKeyLength(const CRulesCharacteristicsAndPluginName& aLeft, const CRulesCharacteristicsAndPluginName& aRight);
456 /** @internalComponent */
457 static TInt AscendAsymmetricCipherKeyLength(const CRulesCharacteristicsAndPluginName& aLeft, const CRulesCharacteristicsAndPluginName& aRight);
459 /** @internalComponent */
460 static TInt DescendAsymmetricCipherKeyLength(const CRulesCharacteristicsAndPluginName& aLeft, const CRulesCharacteristicsAndPluginName& aRight);
462 /** @internalComponent */
463 static TInt AscendAsymmetricSignatureKeyLength(const CRulesCharacteristicsAndPluginName& aLeft, const CRulesCharacteristicsAndPluginName& aRight);
465 /** @internalComponent */
466 static TInt DescendAsymmetricSignatureKeyLength(const CRulesCharacteristicsAndPluginName& aLeft, const CRulesCharacteristicsAndPluginName& aRight);
468 /** @internalComponent */
469 static TInt AscendSymmetricCipherKeySupport(const CRulesCharacteristicsAndPluginName& aLeft, const CRulesCharacteristicsAndPluginName& aRight);
471 /** @internalComponent */
472 static TInt DescendSymmetricCipherKeySupport(const CRulesCharacteristicsAndPluginName& aLeft, const CRulesCharacteristicsAndPluginName& aRight);
474 /** @internalComponent */
475 static TInt AscendAsymmetricCipherKeySupport(const CRulesCharacteristicsAndPluginName& aLeft, const CRulesCharacteristicsAndPluginName& aRight);
477 /** @internalComponent */
478 static TInt DescendAsymmetricCipherKeySupport(const CRulesCharacteristicsAndPluginName& aLeft, const CRulesCharacteristicsAndPluginName& aRight);
480 /** @internalComponent */
481 static TInt AscendAsymmetricSignatureKeySupport(const CRulesCharacteristicsAndPluginName& aLeft, const CRulesCharacteristicsAndPluginName& aRight);
483 /** @internalComponent */
484 static TInt DescendAsymmetricSignatureKeySupport(const CRulesCharacteristicsAndPluginName& aLeft, const CRulesCharacteristicsAndPluginName& aRight);
486 /** @internalComponent */
487 static TInt AscendAsymmetricKeypairGeneratorKeyLength(const CRulesCharacteristicsAndPluginName& aLeft, const CRulesCharacteristicsAndPluginName& aRight);
489 /** @internalComponent */
490 static TInt DescendAsymmetricKeypairGeneratorKeyLength(const CRulesCharacteristicsAndPluginName& aLeft, const CRulesCharacteristicsAndPluginName& aRight);
492 /** @internalComponent */
493 static TInt AscendExtendedCharacteristicL(const CRulesCharacteristicsAndPluginName& aLeft, const CRulesCharacteristicsAndPluginName& aRight);
495 /** @internalComponent */
496 static TInt DescendExtendedCharacteristicL(const CRulesCharacteristicsAndPluginName& aLeft, const CRulesCharacteristicsAndPluginName& aRight);
502 @param aRules the Rules to select the plugins
507 Second Phase Constructor
509 void ConstructL(CSelectionRules* aRules);
511 void PerformFilterL(CSelectionRules* aRules);
513 void PerformAlgorithmFilterL(TInt32 aInterfaceUid, RPointerArray<CRulesCharacteristicsAndPluginName>& aCharacteristicsDLL,
514 CSelectionRuleContent* aRules, TInt& aLastPreference);
516 TBool FilterCommonCharacteristicsL(TInt32 aInterfaceUid, RPointerArray<CRulesCharacteristicsAndPluginName>& aCharacteristicsDLL,
517 CSelectionRuleContent* aRules, TInt& aLastPreference);
519 TBool FilterNonCommonCharacteristicsL(TInt32 aInterfaceUid, RPointerArray<CRulesCharacteristicsAndPluginName>& aCharacteristicsDLL,
520 CSelectionRuleContent* aRules, TInt& aLastPreference);
522 TBool FilterExtendedCharacteristicsL(TInt32 aInterfaceUid, RPointerArray<CRulesCharacteristicsAndPluginName>& aCharacteristicsDLL,
523 CSelectionRuleContent* aRules, TInt& aLastPreference);
525 void FilterTInt32L(TInt32 aInterfaceUid, CRulesCharacteristicsAndPluginName& aCharacteristics,
526 CSelectionRuleContent* aRules, TInt& aLastPreference, TInt32 aCharValue);
528 void FilterMultiTInt32L(TInt32 aInterfaceUid, CRulesCharacteristicsAndPluginName& aCharacteristicsDLL,
529 CSelectionRuleContent* aRules, TInt& aLastPreference,
532 void FilterCreatorNameL(TInt32 aInterfaceUid, RPointerArray<CRulesCharacteristicsAndPluginName>& aCharacteristicsDLL,
533 CSelectionRuleContent* aRules, TInt& aLastPreference);
535 void FilterExtendedTDesC8L(TInt32 aInterfaceUid, RPointerArray<CRulesCharacteristicsAndPluginName>& aCharacteristicsDLL,
536 CSelectionRuleContent* aRules, TInt& aLastPreference, const TDesC8& aCharValue);
538 void FilterTBoolL(TInt32 aInterfaceUid, CRulesCharacteristicsAndPluginName& aCharacteristics,
539 CSelectionRuleContent* aRules, TInt& aLastPreference, TBool aCharValue);
541 void FilterTIntL(TInt32 aInterfaceUid, RPointerArray<CRulesCharacteristicsAndPluginName>& aCharacteristicsDLL,
542 CSelectionRuleContent* aRules, TInt& aLastPreference, TInt aCharValue);
544 void TryAddToOptionalCharListL(TInt32 aInterfaceUid, CRulesCharacteristicsAndPluginName& aCharacteristics,
545 CSelectionRuleContent* aRules);
547 void AddToCharListL(TInt32 aInterfaceUid, CRulesCharacteristicsAndPluginName& aCharacteristics,
548 TInt& aLastPreference);
550 void AddOptionalToCharListL(TInt32 aInterfaceUid, CRulesCharacteristicsAndPluginName& aCharacteristics);
552 void ConstructMapAL();
554 void SetSearchRecord(TUid aInterfaceUid, TInt aValue);
557 Loads the crypto plugins
561 TInt FindPlugin(TUid aInterfaceUid, TUid aAlgorithmUid, TUid& aImplementationId, TFileName& aDllName);
564 The selection rules to filter the plugins
566 CSelectionRules* iSelectionRules;
569 Maps of the interface UID and the pointer of algorithm's characteristic array
570 They are used alternatively to filter from one array to the other
571 The final array will be set to iActiveInterfaceCharacteristics_Map for plugin lookup
573 RHashMap<TInt32, RPointerArray<CRulesCharacteristicsAndPluginName>*> iSelectedInterfaceCharacteristics_MapA;
574 RHashMap<TInt32, RPointerArray<CRulesCharacteristicsAndPluginName>*> iSelectedInterfaceCharacteristics_MapB;
577 Pointer of the active map of the interface UID and the characteristic list
579 const RHashMap<TInt32, RPointerArray<CRulesCharacteristicsAndPluginName>*>* iActiveInterfaceCharacteristics_Map;
582 Records the next index to try
584 RHashMap<TInt32, TInt> iNextTryCharacteristicsIndex;
587 To indicate whether to use iSelectedInterfaceCharacteristics_MapA
588 or iSelectedInterfaceCharacteristics_MapA to filter
590 TBool iUseMapAToFilter;
593 This is use to indicate whether to alternate the maps for next rule filtering or not
598 The plugin DLL list, which holds all the plugin DLLs
600 RArray<RLibrary> iPluginDllList;
604 #endif //__CRYPTOAPI_RULESELECTOR_H__