Update contrib.
2 * Copyright (c) 2007-2010 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 "plugincharshashstep.h"
25 #include "plugincharschecker.h"
27 #include <cryptospi/cryptohashapi.h>
28 #include <cryptospi/keys.h>
30 using namespace CryptoSpi;
32 CPluginCharsHashStep::~CPluginCharsHashStep()
36 CPluginCharsHashStep::CPluginCharsHashStep()
38 SetTestStepName(KPluginCharsHashStep);
41 TVerdict CPluginCharsHashStep::doTestStepPreambleL()
43 SetTestStepResult(EPass);
44 return TestStepResult();
47 TVerdict CPluginCharsHashStep::doTestStepL()
50 INFO_PRINTF1(_L("Plugin Characteristics - Hash Chracteristics"));
51 INFO_PRINTF2(_L("HEAP CELLS: %d"), User::CountAllocCells());
53 if (TestStepResult()==EPass)
56 //Assume faliure, unless all is successful
57 SetTestStepResult(EFail);
59 TVariantPtrC algorithmUid;
60 TVariantPtrC operationMode;
61 TVariantPtrC invalidOperationMode;
63 //Each of the individual parameters required to create the Hash object
64 //are read in from the specified INI configuration file
65 if(!GetStringFromConfig(ConfigSection(),KConfigAlgorithmUid,algorithmUid) ||
66 !GetStringFromConfig(ConfigSection(),KConfigOperationMode,operationMode) ||
67 !GetStringFromConfig(ConfigSection(),KConfigInvalidOperationMode,invalidOperationMode))
69 ERR_PRINTF1(_L("** .INI Error: Hash Arguments Not Located **"));
70 SetTestStepResult(EFail);
74 CHash* hashImpl = NULL;
76 TRAPD_LOG(err,CHashFactory::CreateHashL(hashImpl,
82 if(hashImpl && (err == KErrNone))
84 CleanupStack::PushL(hashImpl);
86 INFO_PRINTF1(_L("** Successfully Loaded Hash Object **"));
88 //Define a pointer of type TCharacteristics in order to store the hash
89 //cryptographic object's characterisctics
90 const TCharacteristics* chars(NULL);
92 //Retrieve the characteristics for the hash implementation object
93 TRAP_LOG(err, hashImpl->GetCharacteristicsL(chars));
95 //Static cast the characteristics to type THashCharacteristics
96 const THashCharacteristics* hashChars = static_cast<const THashCharacteristics*>(chars);
98 //Retrieve all the Common characteristics that are required for all test cases
99 TVariantPtrC exInterfaceUid;
100 TVariantPtrC exAlgorithmUid;
101 TVariantPtrC exImplementationUid;
102 TVariantPtrC exCreatorName;
103 TBool exFIPSApproved;
104 TBool exHardwareSupported;
105 TInt exMaxConcurrencySupported;
106 TVariantPtrC exAlgorithmName;
110 //Retrieve all the Hash characteristics that are required for all test cases
111 TInt exHashBlockSize;
112 TInt exHashOutputSize;
113 TVariantPtrC exHashOperationModes;
114 TInt exHashOperationModeNum;
116 if(!GetStringFromConfig(ConfigSection(),KConfigExInterfaceUid,exInterfaceUid) ||
117 !GetStringFromConfig(ConfigSection(),KConfigExAlgorithmUid,exAlgorithmUid) ||
118 !GetStringFromConfig(ConfigSection(),KConfigExImplementationUid,exImplementationUid) ||
119 !GetStringFromConfig(ConfigSection(),KConfigExCreatorName,exCreatorName) ||
120 !GetBoolFromConfig(ConfigSection(),KConfigExFIPSApproved,exFIPSApproved) ||
121 !GetBoolFromConfig(ConfigSection(),KConfigExHardwareSupport,exHardwareSupported) ||
122 !GetIntFromConfig(ConfigSection(),KConfigExMaxConcurrency,exMaxConcurrencySupported) ||
123 !GetStringFromConfig(ConfigSection(),KConfigExAlgorithmName,exAlgorithmName) ||
124 !GetIntFromConfig(ConfigSection(),KConfigExLatency,exLatency) ||
125 !GetIntFromConfig(ConfigSection(),KConfigExThroughput,exThroughput) ||
126 !GetIntFromConfig(ConfigSection(),KConfigExBlockSize,exHashBlockSize) ||
127 !GetIntFromConfig(ConfigSection(),KConfigExOutputSize,exHashOutputSize) ||
128 !GetStringFromConfig(ConfigSection(),KConfigExOperationModes,exHashOperationModes) ||
129 !GetIntFromConfig(ConfigSection(),KConfigExOperationModeNum,exHashOperationModeNum))
131 ERR_PRINTF1(_L("** .INI Error: Expected Hash/Common Characteristic Arguments Not Located **"));
132 SetTestStepResult(EFail);
136 INFO_PRINTF1(_L("** Checking Hash/Common Characteristics.... **"));
138 CPluginCharsChecker* pluginCheck = CPluginCharsChecker::NewLC();
140 //Retrieve the Common Characteristics from THashCharacteristics
141 const TCommonCharacteristics* hashCommonChars = &hashChars->cmn;
145 //Perform Hash/Common Characteristic Checks
146 if(pluginCheck->checkCommonCharacteristics(hashCommonChars,
153 exMaxConcurrencySupported,
158 pluginCheck->checkHashCharacteristics(hashChars,
161 exHashOperationModes,
162 exHashOperationModeNum,
165 INFO_PRINTF1(_L("Hash/Common characteristics successfully match expected values..."));
167 if(hashChars->IsOperationModeSupported(operationMode) && !hashChars->IsOperationModeSupported(invalidOperationMode))
170 INFO_PRINTF1(_L("Successful Operation Mode Supported Tests...."));
172 INFO_PRINTF1(_L("** PASS: Hash/Common Characteristics Tests Successful **"));
174 SetTestStepResult(EPass);
178 ERR_PRINTF1(_L("** FAIL: Unexpected 'Operation' Mode Supported Results"));
183 ERR_PRINTF2(_L("** FAIL: Characteristic Mismatch - %S **"),&errorMessage);
186 CleanupStack::PopAndDestroy(pluginCheck);
189 CleanupStack::PopAndDestroy(hashImpl);
193 ERR_PRINTF1(_L("** Error: Loading Hash Object **"));
199 INFO_PRINTF2(_L("HEAP CELLS: %d"), User::CountAllocCells());
200 return TestStepResult();
203 TVerdict CPluginCharsHashStep::doTestStepPostambleL()
205 return TestStepResult();