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 "dummyecccipherloadstep.h"
26 #include <cryptospi/cryptoasymmetriccipherapi.h>
27 #include <cryptospi/cryptokeypairgeneratorapi.h>
28 #include <cryptospi/keypair.h>
29 #include "filereader.h"
31 using namespace CryptoSpi;
33 CDummyEccCipherLoadStep::~CDummyEccCipherLoadStep()
38 CDummyEccCipherLoadStep::CDummyEccCipherLoadStep()
40 SetTestStepName(KDummyEccCipherLoadStep);
44 TVerdict CDummyEccCipherLoadStep::doTestStepPreambleL()
46 SetTestStepResult(EPass);
47 return TestStepResult();
51 TVerdict CDummyEccCipherLoadStep::doTestStepL()
54 INFO_PRINTF1(_L("*** Dummy Ecc Cipher - Load ***"));
55 INFO_PRINTF2(_L("HEAP CELLS: %d"), User::CountAllocCells());
57 //Assume failure, unless all is successful
58 SetTestStepResult(EFail);
60 TVariantPtrC algorithm;
61 TVariantPtrC paddingMode;
63 if(!GetStringFromConfig(ConfigSection(),KConfigAlgorithmUid, algorithm) ||
64 !GetStringFromConfig(ConfigSection(),KConfigPaddingMode, paddingMode ))
66 ERR_PRINTF1(_L("*** FAIL: Algorithm id or padding mode is missing ***"));
67 User::Leave(KErrNotFound);
69 INFO_PRINTF1(_L("Generating dummy ECC keys"));
72 * Note that we are actually generating RSA keys in place
73 * of ECC keys here. The reason for that is we do not have
74 * a working ECC implementation. This test case just tests
75 * if dummyecc cipher is getting loaded. This is being
76 * tested since algorithm is set to KAlgorithmCipherEcc.
77 * Keys have no significance in this test case.
79 CCryptoParams* keyParams = CCryptoParams::NewLC();
80 keyParams->AddL(KKeyExponent, KRsaKeyParameterEUid);
81 keyParams->AddL(KRsaPrivateKeyStandard, KRsaKeyTypeUid);
83 //Create Key Pair Generator Objects
84 CKeyPairGenerator * keypairImpl = NULL;
86 // create a key pair generator implementation interface
87 TRAPD_LOG(err,CKeyPairGeneratorFactory::CreateKeyPairGeneratorL(
89 KRSAKeyPairGeneratorUid,
93 ERR_PRINTF1(_L("*** FAIL: Failed to Create generator impl interface ***"));
94 CleanupStack::PopAndDestroy(keyParams);
97 CleanupStack::PushL(keypairImpl);
100 CKeyPair* keyPair = NULL;
101 TRAP_LOG(err,keypairImpl->GenerateKeyPairL(1024, *keyParams, keyPair));
104 ERR_PRINTF1(_L("*** FAIL: Failed to Create key pair ***"));
105 CleanupStack::PopAndDestroy(keypairImpl);
106 CleanupStack::PopAndDestroy(keyParams);
109 CleanupStack::PushL(keyPair);
111 //*****************************************************
113 INFO_PRINTF1(_L("Creating Dummy ECC Cipher Object..."));
115 CryptoSpi::CAsymmetricCipher * impl = NULL;
117 TRAP(err,CAsymmetricCipherFactory::CreateAsymmetricCipherL
121 keyPair->PrivateKey(),
122 KCryptoModeDecryptUid,
129 INFO_PRINTF1(_L("*** Dummy Ecc Cipher - Load: PASS ***"));
130 SetTestStepResult(EPass);
134 ERR_PRINTF2(_L("*** FAIL: Failed to Create dummy Ecc Cipher Object - %d ***"), err);
137 CleanupStack::PopAndDestroy(keyPair);
138 CleanupStack::PopAndDestroy(keypairImpl);
139 CleanupStack::PopAndDestroy(keyParams);
141 INFO_PRINTF2(_L("HEAP CELLS: %d"), User::CountAllocCells());
143 return TestStepResult();
148 TVerdict CDummyEccCipherLoadStep::doTestStepPostambleL()
150 return TestStepResult();