Update contrib.
2 * Copyright (c) 2009-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.
15 * Example CTestStep derived implementation
24 #include "dummyeccsignerloadstep.h"
26 #include <cryptospi/keypair.h>
27 #include <cryptospi/cryptosignatureapi.h>
28 #include <cryptospi/cryptokeypairgeneratorapi.h>
30 using namespace CryptoSpi;
33 CDummyEccSignerLoadStep::~CDummyEccSignerLoadStep()
37 CDummyEccSignerLoadStep::CDummyEccSignerLoadStep()
39 SetTestStepName(KDummyEccSignerLoadStep);
42 TVerdict CDummyEccSignerLoadStep::doTestStepPreambleL()
44 SetTestStepResult(EPass);
45 return TestStepResult();
49 TVerdict CDummyEccSignerLoadStep::doTestStepL()
51 INFO_PRINTF1(_L("*** Dummy Ecc Signer - Load ***"));
52 INFO_PRINTF2(_L("HEAP CELLS: %d"), User::CountAllocCells());
54 //Assume failure, unless all is successful
55 SetTestStepResult(EFail);
57 TVariantPtrC testVariant;
58 TVariantPtrC keyVariant;
60 if( !GetStringFromConfig(ConfigSection(),KConfigExchangeKey, keyVariant))
62 // Leave if there's any error.
63 ERR_PRINTF1(_L("*** FAIL: Problem in configuration file ***"));
64 User::Leave(KErrNotFound);
66 //Create an new CryptoParams object to encapsulate the key type and secret key string
67 CCryptoParams* keyParams = CCryptoParams::NewLC();
70 * Note that we are actually generating RSA keys in place
71 * of ECC keys here. The reason for that is we do not have
72 * a working ECC implementation. This test case just tests
73 * if dummyecc signer is getting loaded. This is getting
74 * tested since KEccSignerUid is being passed as input to
75 * CreateSignerL. Keys have no significance in this test
78 //Set the Key Parameters
79 keyParams->AddL(KKeyExponent, KRsaKeyParameterEUid);
80 keyParams->AddL(KRsaPrivateKeyStandard, KRsaKeyTypeUid);
82 // Create a Key Pair Generator implementation
83 INFO_PRINTF1(_L("Creating Key Pair Generator..."));
85 CKeyPairGenerator * keypairImpl = NULL;
86 TRAPD_LOG(err,CKeyPairGeneratorFactory::CreateKeyPairGeneratorL(keypairImpl,
87 KRSAKeyPairGeneratorUid,
91 ERR_PRINTF1(_L("*** FAIL: Failed to Create generator impl interface ***"));
92 CleanupStack::PopAndDestroy(keyParams);
95 CleanupStack::PushL(keypairImpl);
97 // Generate a Key Pair
98 INFO_PRINTF1(_L("Generating Key Pair..."));
100 CKeyPair* keyPair = NULL;
102 TRAP_LOG(err,keypairImpl->GenerateKeyPairL(1024,
107 ERR_PRINTF1(_L("*** FAIL: Failed to Create key pair ***"));
108 CleanupStack::PopAndDestroy(keypairImpl);
109 CleanupStack::PopAndDestroy(keyParams);
112 CleanupStack::PushL(keyPair);
114 // Creating Signer 1 with the necessary values from the ini file
115 INFO_PRINTF1(_L("Constructing Signer 1 (No Padding)..."));
116 CSigner * impl = NULL;
117 TRAP_LOG(err,CSignatureFactory::CreateSignerL(impl,
119 keyPair->PublicKey(),
123 CleanupStack::PushL(impl);
127 // This is a basic test for load positivity
129 INFO_PRINTF1(_L("PASS: Dummy ECC Signer - Positive Object Load"));
130 SetTestStepResult(EPass);
134 ERR_PRINTF2(_L("FAIL: Signer Object Construction Failure - %d"), err);
137 CleanupStack::PopAndDestroy(impl);
138 CleanupStack::PopAndDestroy(keyPair);
139 CleanupStack::PopAndDestroy(keypairImpl);
140 CleanupStack::PopAndDestroy(keyParams);
142 INFO_PRINTF2(_L("HEAP CELLS: %d"), User::CountAllocCells());
143 return TestStepResult();
148 TVerdict CDummyEccSignerLoadStep::doTestStepPostambleL()
150 return TestStepResult();