Update contrib.
2 * Copyright (c) 2007-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.
24 #include "plugincharschecker.h"
26 using namespace CryptoSpi;
28 CPluginCharsChecker::~CPluginCharsChecker()
32 CPluginCharsChecker::CPluginCharsChecker()
36 CPluginCharsChecker* CPluginCharsChecker::NewL()
38 CPluginCharsChecker* me = CPluginCharsChecker::NewLC();
39 CleanupStack::Pop(me);
43 CPluginCharsChecker* CPluginCharsChecker::NewLC()
45 CPluginCharsChecker* me = new(ELeave) CPluginCharsChecker();
46 CleanupStack::PushL(me);
51 TBool CPluginCharsChecker::checkCommonCharacteristics(const TCommonCharacteristics* aCharacteristics,
52 TVariantPtrC aInterfaceUid,
53 TVariantPtrC aAlgorithmUid,
54 TVariantPtrC aImplementationUid,
55 TVariantPtrC aCreatorName,
57 TBool aHardwareSupported,
58 TInt aMaxConcurrencySupported,
59 TVariantPtrC aAlgorithmName,
66 TRomLitC16 creatorName = *(aCharacteristics->iCreatorName);
67 TRomLitC16 algorithmName = *(aCharacteristics->iAlgorithmName);
69 if(!(aCharacteristics->iInterfaceUID == aInterfaceUid))
71 aErrorMessage.Set(_L("COMMON_INTERFACE_ID"));
75 if(!(aCharacteristics->iAlgorithmUID == aAlgorithmUid))
77 aErrorMessage.Set(_L("COMMON_ALGORITHM_ID"));
81 if(!(aCharacteristics->iImplementationUID == aImplementationUid))
83 aErrorMessage.Set(_L("COMMON_IMPLEMENTATION_ID"));
87 if(!(*creatorName == *(static_cast<TRomLitC16>(aCreatorName))))
89 aErrorMessage.Set(_L("COMMON_CREATOR_NAME"));
93 if(!(aCharacteristics->iIsFIPSApproved == aFIPSApproved))
95 aErrorMessage.Set(_L("COMMON_FIPS_APPROVED"));
99 if(!(aCharacteristics->iIsHardwareSupported == aHardwareSupported))
101 aErrorMessage.Set(_L("COMMON_HARDWARE_SUPPORTED"));
105 if(!(aCharacteristics->iMaxConcurrencySupported == aMaxConcurrencySupported))
107 aErrorMessage.Set(_L("COMMON_MAXIMUM_CONCURRENCY"));
111 if(!(*algorithmName == *(static_cast<TRomLitC16>(aAlgorithmName))))
113 aErrorMessage.Set(_L("COMMON_ALGORITHM_NAME"));
117 if(!(aCharacteristics->iLatency == aLatency))
119 aErrorMessage.Set(_L("COMMON_LATENCY"));
123 if(!(aCharacteristics->iThroughput == aThroughput))
125 aErrorMessage.Set(_L("COMMON_THROUGHPUT"));
133 TBool CPluginCharsChecker::checkSymmetricCharacteristics(const TSymmetricCipherCharacteristics* aCharacteristics,
134 TInt aSymmetricMaxKeyLength,
135 TInt aSymmetricBlockSize,
136 TVariantPtrC aSymmetricPaddingModes,
137 TInt aSymmetricPaddingModeNum,
138 TVariantPtrC aSymmetricOperationModes,
139 TInt aSymmetricOperationModeNum,
140 TInt aSymmetricKeySupportMode,
141 TPtrC& aErrorMessage)
143 TBool result = ETrue;
145 TInt32 supportedPaddingModes = *(aCharacteristics->iSupportedPaddingModes);
146 TInt32 supportedOperationModes = *(aCharacteristics->iSupportedOperationModes);
148 if(!(aCharacteristics->iMaximumKeyLength == aSymmetricMaxKeyLength))
150 aErrorMessage.Set(_L("SYMMETRIC_MAXIMUM_KEY_LENGTH"));
154 if(!(aCharacteristics->iBlockSize == aSymmetricBlockSize))
156 aErrorMessage.Set(_L("SYMMETRIC_BLOCK_SIZE"));
160 if(!(supportedPaddingModes == *(static_cast<const TInt32*>(aSymmetricPaddingModes))))
162 aErrorMessage.Set(_L("SYMMETRIC_SUPPORTED_PADDING_MODES"));
166 if(!(aCharacteristics->iPaddingModeNum == aSymmetricPaddingModeNum))
168 aErrorMessage.Set(_L("SYMMETRIC_PADDING_MODE_NUM"));
172 if(!(supportedOperationModes == *(static_cast<const TInt32*>(aSymmetricOperationModes))))
174 aErrorMessage.Set(_L("SYMMETRIC_OPERATION_MODES"));
178 if(!(aCharacteristics->iOperationModeNum == aSymmetricOperationModeNum))
180 aErrorMessage.Set(_L("SYMMETRIC_OPERATION_MODE_NUM"));
184 if(!(aCharacteristics->iKeySupportMode == aSymmetricKeySupportMode))
186 aErrorMessage.Set(_L("SYMMETRIC_KEY_SUPPORT_MODE"));
194 TBool CPluginCharsChecker::checkAsymmetricCharacteristics(const TAsymmetricCipherCharacteristics* aCharacteristics,
195 TInt aAsymmetricMaxKeyLength,
196 TVariantPtrC aAsymmetricPaddingModes,
197 TInt aAsymmetricPaddingModeNum,
198 TInt aAsymmetricKeySupportMode,
199 TPtrC& aErrorMessage)
201 TBool result = ETrue;
203 TInt32 supportedPaddingModes = *(aCharacteristics->iSupportedPaddingModes);
205 if(!(aCharacteristics->iMaximumKeyLength == aAsymmetricMaxKeyLength))
207 aErrorMessage.Set(_L("ASYMMETRIC_MAXIMUM_KEY_LENGTH"));
211 if(!(supportedPaddingModes == *(static_cast<const TInt32*>(aAsymmetricPaddingModes))))
213 aErrorMessage.Set(_L("ASYMMETRIC_SUPPORTED_PADDING_MODES"));
217 if(!(aCharacteristics->iPaddingModeNum == aAsymmetricPaddingModeNum))
219 aErrorMessage.Set(_L("ASYMMETRIC_PADDING_MODE_NUM"));
223 if(!(aCharacteristics->iKeySupportMode == aAsymmetricKeySupportMode))
225 aErrorMessage.Set(_L("ASYMMETRIC_KEY_SUPPORT_MODE"));
233 TBool CPluginCharsChecker::checkHashCharacteristics(const THashCharacteristics* aCharacteristics,
236 TVariantPtrC aHashOperationModes,
237 TInt aHashOperationModeNum,
238 TPtrC& aErrorMessage)
240 TBool result = ETrue;
242 TInt32 supportedOperationModes = *(aCharacteristics->iSupportedOperationModes);
244 if(!(aCharacteristics->iBlockSize == aBlockSize))
246 aErrorMessage.Set(_L("HASH_BLOCK_SIZE"));
250 if(!(aCharacteristics->iOutputSize == aOutputSize))
252 aErrorMessage.Set(_L("HASH_OUTPUT_SIZE"));
256 if(!(supportedOperationModes == *(static_cast<const TInt32*>(aHashOperationModes))))
258 aErrorMessage.Set(_L("HASH_SUPPORTED_OPERATION_MODES"));
262 if(!(aCharacteristics->iOperationModeNum == aHashOperationModeNum))
264 aErrorMessage.Set(_L("HASH_OPERATION_MODE_NUM"));
271 #ifdef SYMBIAN_SDP_IPSEC_VOIP_SUPPORT
272 TBool CPluginCharsChecker::checkMacCharacteristics(const TMacCharacteristics* aCharacteristics,
273 TVariantPtrC aMacMode,
274 TPtrC& aErrorMessage)
276 TBool result = ETrue;
278 if(!(aCharacteristics->iMacMode == aMacMode))
280 aErrorMessage.Set(_L("MAC_MODE"));
288 TBool CPluginCharsChecker::checkRandomCharacteristics(const TRandomCharacteristics* aCharacteristics,
289 TInt aRandomBlockingMode,
290 TPtrC& aErrorMessage)
292 TBool result = ETrue;
294 if(!(aCharacteristics->iBlockingMode == aRandomBlockingMode))
296 aErrorMessage.Set(_L("RANDOM_BLOCKING_MODE"));
304 TBool CPluginCharsChecker::checkAsymSignatureCharacteristics(const TAsymmetricSignatureCharacteristics* aCharacteristics,
305 TInt aAsymSignMaxKeyLength,
306 TVariantPtrC aAsymSignPaddingModes,
307 TInt aAsymSignPaddingModeNum,
308 TInt aAsymSignKeySupportMode,
309 TPtrC& aErrorMessage)
311 TBool result = ETrue;
313 TInt32 supportedPaddingModes = *(aCharacteristics->iSupportedPaddingModes);
315 if(!(aCharacteristics->iMaximumKeyLength == aAsymSignMaxKeyLength))
317 aErrorMessage.Set(_L("ASYMSIGN_MAXIMUM_KEY_LENGTH"));
321 if(!(supportedPaddingModes == *(static_cast<const TInt32*>(aAsymSignPaddingModes))))
323 aErrorMessage.Set(_L("ASYMSIGN_SUPPORTED_PADDING_MODES"));
327 if(!(aCharacteristics->iPaddingModeNum == aAsymSignPaddingModeNum))
329 aErrorMessage.Set(_L("ASYMSIGN_PADDING_MODE_NUM"));
333 if(!(aCharacteristics->iKeySupportMode == aAsymSignKeySupportMode))
335 aErrorMessage.Set(_L("ASYMSIGN_KEY_SUPPORT_MODE"));
342 TBool CPluginCharsChecker::checkAsymKeypairGenCharacteristics(const CryptoSpi::TAsymmetricKeypairGeneratorCharacteristics* aCharacteristics,
343 TInt aAsymKeypairGenMaxKeyLength,
344 TPtrC& aErrorMessage)
346 TBool result = ETrue;
348 if(!(aCharacteristics->iMaximumKeyLength == aAsymKeypairGenMaxKeyLength))
350 aErrorMessage.Set(_L("ASYMKEYPAIRGEN_MAX_KEY_LENGTH"));
357 TBool CPluginCharsChecker::checkSelectedPlugin(const TCharacteristics* aCharacteristics,
358 TVariantPtrC aAlgorithmUid,
359 TVariantPtrC aImplementationUid,
360 TPtrC& aErrorMessage)
362 TBool result = ETrue;
364 const TCommonCharacteristics* commonChars = static_cast<const TCommonCharacteristics*>(aCharacteristics);
366 if(!(commonChars->iAlgorithmUID == aAlgorithmUid))
368 aErrorMessage.Set(_L("COMMON_ALGORITHM_ID"));
372 if(!(commonChars->iImplementationUID == aImplementationUid))
374 aErrorMessage.Set(_L("COMMON_IMPLEMENTATION_ID"));