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 "plugincharsrandomstep.h"
25 #include "plugincharschecker.h"
27 #include <cryptospi/cryptorandomapi.h>
29 using namespace CryptoSpi;
31 CPluginCharsRandomStep::~CPluginCharsRandomStep()
35 CPluginCharsRandomStep::CPluginCharsRandomStep()
37 SetTestStepName(KPluginCharsRandomStep);
40 TVerdict CPluginCharsRandomStep::doTestStepPreambleL()
42 SetTestStepResult(EPass);
43 return TestStepResult();
46 TVerdict CPluginCharsRandomStep::doTestStepL()
49 INFO_PRINTF1(_L("Plugin Characteristics - Random Chracteristics"));
50 INFO_PRINTF2(_L("HEAP CELLS: %d"), User::CountAllocCells());
52 if (TestStepResult()==EPass)
55 //Assume faliure, unless all is successful
56 SetTestStepResult(EFail);
58 TVariantPtrC algorithmUid;
60 //Each of the individual parameters required to create the Random object
61 //are read in from the specified INI configuration file
62 if(!GetStringFromConfig(ConfigSection(),KConfigAlgorithmUid,algorithmUid))
64 ERR_PRINTF1(_L("** .INI Error: Random Arguments Not Located **"));
65 SetTestStepResult(EFail);
69 CryptoSpi::CRandom* randomImpl = NULL;
71 TRAPD_LOG(err,CRandomFactory::CreateRandomL(randomImpl,
75 if(randomImpl && (err == KErrNone))
78 CleanupStack::PushL(randomImpl);
80 INFO_PRINTF1(_L("** Successfully Loaded Random Object **"));
82 //Define a pointer of type TCharacteristics in order to store the random
83 //object's characterisctics
84 const TCharacteristics* chars(NULL);
86 //Retrieve the characteristics for the random implementation object
87 TRAP_LOG(err, randomImpl->GetCharacteristicsL(chars));
89 //Static cast the characteristics to type TRandomCharacteristics
90 const TRandomCharacteristics* randomChars = static_cast<const TRandomCharacteristics*>(chars);
92 //Retrieve all the Common characteristics that are required for all test cases
93 TVariantPtrC exInterfaceUid;
94 TVariantPtrC exAlgorithmUid;
95 TVariantPtrC exImplementationUid;
96 TVariantPtrC exCreatorName;
98 TBool exHardwareSupported;
99 TInt exMaxConcurrencySupported;
100 TVariantPtrC exAlgorithmName;
104 //Retrieve all the Random characteristics that are required for all test cases
105 TInt exRandomBlockingMode;
107 if(!GetStringFromConfig(ConfigSection(),KConfigExInterfaceUid,exInterfaceUid) ||
108 !GetStringFromConfig(ConfigSection(),KConfigExAlgorithmUid,exAlgorithmUid) ||
109 !GetStringFromConfig(ConfigSection(),KConfigExImplementationUid,exImplementationUid) ||
110 !GetStringFromConfig(ConfigSection(),KConfigExCreatorName,exCreatorName) ||
111 !GetBoolFromConfig(ConfigSection(),KConfigExFIPSApproved,exFIPSApproved) ||
112 !GetBoolFromConfig(ConfigSection(),KConfigExHardwareSupport,exHardwareSupported) ||
113 !GetIntFromConfig(ConfigSection(),KConfigExMaxConcurrency,exMaxConcurrencySupported) ||
114 !GetStringFromConfig(ConfigSection(),KConfigExAlgorithmName,exAlgorithmName) ||
115 !GetIntFromConfig(ConfigSection(),KConfigExLatency,exLatency) ||
116 !GetIntFromConfig(ConfigSection(),KConfigExThroughput,exThroughput) ||
117 !GetIntFromConfig(ConfigSection(),KConfigExBlockingMode,exRandomBlockingMode))
119 ERR_PRINTF1(_L("** .INI Error: Expected Random/Common Characteristic Arguments Not Located **"));
120 SetTestStepResult(EFail);
124 INFO_PRINTF1(_L("** Checking Random/Common Characteristics.... **"));
126 CPluginCharsChecker* pluginCheck = CPluginCharsChecker::NewLC();
128 //Retrieve the Common Characteristics from TRandomCharacteristics
129 const TCommonCharacteristics* randomCommonChars = &randomChars->cmn;
133 //Perform Random/Common Characteristic Checks
134 if(pluginCheck->checkCommonCharacteristics(randomCommonChars,
141 exMaxConcurrencySupported,
146 pluginCheck->checkRandomCharacteristics(randomChars,
147 exRandomBlockingMode,
150 INFO_PRINTF1(_L("** PASS : Random/Common characteristics successfully match expected values **"));
151 SetTestStepResult(EPass);
155 ERR_PRINTF2(_L("** FAIL: Characteristic Mismatch - %S **"),&errorMessage);
158 CleanupStack::PopAndDestroy(pluginCheck);
161 CleanupStack::PopAndDestroy(randomImpl);
165 ERR_PRINTF1(_L("** Error: Loading Random Object **"));
171 INFO_PRINTF2(_L("HEAP CELLS: %d"), User::CountAllocCells());
172 return TestStepResult();
176 TVerdict CPluginCharsRandomStep::doTestStepPostambleL()
178 return TestStepResult();