sl@0: /* sl@0: * Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies). sl@0: * All rights reserved. sl@0: * This component and the accompanying materials are made available sl@0: * under the terms of the License "Eclipse Public License v1.0" sl@0: * which accompanies this distribution, and is available sl@0: * at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: * sl@0: * Initial Contributors: sl@0: * Nokia Corporation - initial contribution. sl@0: * sl@0: * Contributors: sl@0: * sl@0: * Description: sl@0: * sl@0: */ sl@0: sl@0: sl@0: /** sl@0: @file sl@0: @internalTechnology sl@0: */ sl@0: sl@0: #include "plugincharsasymkeypairstep.h" sl@0: #include "plugincharschecker.h" sl@0: sl@0: #include sl@0: #include sl@0: sl@0: using namespace CryptoSpi; sl@0: sl@0: CPluginCharsAsymKeyPairStep::~CPluginCharsAsymKeyPairStep() sl@0: { sl@0: } sl@0: sl@0: CPluginCharsAsymKeyPairStep::CPluginCharsAsymKeyPairStep() sl@0: { sl@0: SetTestStepName(KPluginCharsAsymKeyPairStep); sl@0: } sl@0: sl@0: TVerdict CPluginCharsAsymKeyPairStep::doTestStepPreambleL() sl@0: { sl@0: SetTestStepResult(EPass); sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: TVerdict CPluginCharsAsymKeyPairStep::doTestStepL() sl@0: { sl@0: sl@0: INFO_PRINTF1(_L("Plugin Characteristics - Asymmetric Key Pair Generator Chracteristics")); sl@0: INFO_PRINTF2(_L("HEAP CELLS: %d"), User::CountAllocCells()); sl@0: sl@0: if (TestStepResult()==EPass) sl@0: { sl@0: sl@0: //Assume faliure, unless all is successful sl@0: SetTestStepResult(EFail); sl@0: sl@0: TVariantPtrC algorithmUid; sl@0: sl@0: //Each of the individual parameters required to create the Asymmetric Key Pair Generator object sl@0: //are read in from the specified INI configuration file sl@0: if(!GetStringFromConfig(ConfigSection(),KConfigAlgorithmUid,algorithmUid)) sl@0: { sl@0: ERR_PRINTF1(_L("** .INI Error: Asymmetric Key Pair Generator Cipher Arguments Not Located **")); sl@0: SetTestStepResult(EFail); sl@0: } sl@0: else sl@0: { sl@0: CCryptoParams* keyParams = CCryptoParams::NewLC(); sl@0: sl@0: //Create Key Pair Generator Object sl@0: CKeyPairGenerator* keyPairGenImpl = NULL; sl@0: sl@0: //Create a Asymmetric Key Pair Generator Implementation sl@0: TRAPD(err,CKeyPairGeneratorFactory::CreateKeyPairGeneratorL(keyPairGenImpl, sl@0: algorithmUid, sl@0: keyParams)); sl@0: sl@0: if(keyPairGenImpl && (err == KErrNone)) sl@0: { sl@0: sl@0: CleanupStack::PushL(keyPairGenImpl); sl@0: sl@0: INFO_PRINTF1(_L("** Successfully Loaded Asymmetric Key Pair Generator Object **")); sl@0: sl@0: //Define a pointer of type TCharacteristics in order to store the asymmetric key pair generator sl@0: //object's characterisctics sl@0: const TCharacteristics* chars(NULL); sl@0: sl@0: //Retrieve the characteristics for the asymmetric key pair generator implementation object sl@0: keyPairGenImpl->GetCharacteristicsL(chars); sl@0: sl@0: //Static cast the characteristics to type TKeyAgreementCharacteristics sl@0: const TAsymmetricKeypairGeneratorCharacteristics* asymkeypairgenChars = static_cast(chars); sl@0: sl@0: //Retrieve all the Common characteristics that are required for the test sl@0: TVariantPtrC exInterfaceUid; sl@0: TVariantPtrC exAlgorithmUid; sl@0: TVariantPtrC exImplementationUid; sl@0: TVariantPtrC exCreatorName; sl@0: TBool exFIPSApproved; sl@0: TBool exHardwareSupported; sl@0: TInt exMaxConcurrencySupported; sl@0: TVariantPtrC exAlgorithmName; sl@0: TInt exLatency; sl@0: TInt exThroughput; sl@0: sl@0: //Retrieve all the Asymmetric Key Pair Generator characteristics that are required for the test sl@0: TInt exAsymKeyPairMaxKeyLength; sl@0: sl@0: if(!GetStringFromConfig(ConfigSection(),KConfigExInterfaceUid,exInterfaceUid) || sl@0: !GetStringFromConfig(ConfigSection(),KConfigExAlgorithmUid,exAlgorithmUid) || sl@0: !GetStringFromConfig(ConfigSection(),KConfigExImplementationUid,exImplementationUid) || sl@0: !GetStringFromConfig(ConfigSection(),KConfigExCreatorName,exCreatorName) || sl@0: !GetBoolFromConfig(ConfigSection(),KConfigExFIPSApproved,exFIPSApproved) || sl@0: !GetBoolFromConfig(ConfigSection(),KConfigExHardwareSupport,exHardwareSupported) || sl@0: !GetIntFromConfig(ConfigSection(),KConfigExMaxConcurrency,exMaxConcurrencySupported) || sl@0: !GetStringFromConfig(ConfigSection(),KConfigExAlgorithmName,exAlgorithmName) || sl@0: !GetIntFromConfig(ConfigSection(),KConfigExLatency,exLatency) || sl@0: !GetIntFromConfig(ConfigSection(),KConfigExThroughput,exThroughput) || sl@0: !GetIntFromConfig(ConfigSection(),KConfigExMaxKeyLength,exAsymKeyPairMaxKeyLength)) sl@0: { sl@0: ERR_PRINTF1(_L("** .INI Error: Expected Asymmetric Key Pair Generator/Common Characteristics Not Located **")); sl@0: SetTestStepResult(EFail); sl@0: } sl@0: else sl@0: { sl@0: sl@0: INFO_PRINTF1(_L("** Checking Asymmetric Key Pair Generator/Common Characteristics.... **")); sl@0: sl@0: CPluginCharsChecker* pluginCheck = CPluginCharsChecker::NewLC(); sl@0: sl@0: //Retrieve the Common Characteristics from TAsymmetricKeypairGeneratorCharacteristics sl@0: const TCommonCharacteristics* asymkeypairgenCommonChars = &asymkeypairgenChars->cmn; sl@0: sl@0: TPtrC errorMessage; sl@0: sl@0: //Perform Key Agreement/Common Characteristic Checks sl@0: if(pluginCheck->checkCommonCharacteristics(asymkeypairgenCommonChars, sl@0: exInterfaceUid, sl@0: exAlgorithmUid, sl@0: exImplementationUid, sl@0: exCreatorName, sl@0: exFIPSApproved, sl@0: exHardwareSupported, sl@0: exMaxConcurrencySupported, sl@0: exAlgorithmName, sl@0: exLatency, sl@0: exThroughput, sl@0: errorMessage) && sl@0: pluginCheck->checkAsymKeypairGenCharacteristics(asymkeypairgenChars, sl@0: exAsymKeyPairMaxKeyLength, sl@0: errorMessage)) sl@0: { sl@0: INFO_PRINTF1(_L("** PASS : Asymmetric Key Pair Generator/Common characteristics successfully match expected values **")); sl@0: SetTestStepResult(EPass); sl@0: } sl@0: else sl@0: { sl@0: ERR_PRINTF2(_L("** FAIL: Characteristic Mismatch - %S **"),&errorMessage); sl@0: } sl@0: sl@0: CleanupStack::PopAndDestroy(pluginCheck); sl@0: } sl@0: sl@0: CleanupStack::PopAndDestroy(keyPairGenImpl); sl@0: } sl@0: else sl@0: { sl@0: ERR_PRINTF2(_L("*** FAIL: Failed to Create Asymmetric Key Pair Generator Object - %d ***"), err); sl@0: } sl@0: sl@0: CleanupStack::PopAndDestroy(keyParams); sl@0: } sl@0: sl@0: } sl@0: sl@0: INFO_PRINTF2(_L("HEAP CELLS: %d"), User::CountAllocCells()); sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: TVerdict CPluginCharsAsymKeyPairStep::doTestStepPostambleL() sl@0: { sl@0: return TestStepResult(); sl@0: }