os/security/crypto/weakcryptospi/test/tcryptospi/src/symmetriccipherpositiveobjectloadstep.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
/*
sl@0
     2
* Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     3
* All rights reserved.
sl@0
     4
* This component and the accompanying materials are made available
sl@0
     5
* under the terms of the License "Eclipse Public License v1.0"
sl@0
     6
* which accompanies this distribution, and is available
sl@0
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     8
*
sl@0
     9
* Initial Contributors:
sl@0
    10
* Nokia Corporation - initial contribution.
sl@0
    11
*
sl@0
    12
* Contributors:
sl@0
    13
*
sl@0
    14
* Description: 
sl@0
    15
* Example CTestStep derived implementation
sl@0
    16
*
sl@0
    17
*/
sl@0
    18
sl@0
    19
sl@0
    20
/**
sl@0
    21
 @file
sl@0
    22
 @internalTechnology
sl@0
    23
*/
sl@0
    24
#include "symmetriccipherpositiveobjectloadstep.h"
sl@0
    25
sl@0
    26
#include <cryptospi/cryptosymmetriccipherapi.h>
sl@0
    27
#include <cryptospi/keys.h>
sl@0
    28
#include "filereader.h"
sl@0
    29
sl@0
    30
using namespace CryptoSpi;
sl@0
    31
sl@0
    32
CSymmetricCipherPositiveObjectLoadStep::~CSymmetricCipherPositiveObjectLoadStep()
sl@0
    33
	{
sl@0
    34
	}
sl@0
    35
sl@0
    36
sl@0
    37
CSymmetricCipherPositiveObjectLoadStep::CSymmetricCipherPositiveObjectLoadStep()
sl@0
    38
	{
sl@0
    39
	SetTestStepName(KSymmetricCipherPositiveObjectLoadStep);
sl@0
    40
	}
sl@0
    41
sl@0
    42
sl@0
    43
TVerdict CSymmetricCipherPositiveObjectLoadStep::doTestStepPreambleL()
sl@0
    44
	{
sl@0
    45
	SetTestStepResult(EPass);
sl@0
    46
	return TestStepResult();
sl@0
    47
	}
sl@0
    48
sl@0
    49
sl@0
    50
TVerdict CSymmetricCipherPositiveObjectLoadStep::doTestStepL()
sl@0
    51
	{
sl@0
    52
sl@0
    53
	INFO_PRINTF1(_L("*** Symmetric Cipher - Positive Object Load ***"));
sl@0
    54
	INFO_PRINTF2(_L("HEAP CELLS: %d"), User::CountAllocCells());
sl@0
    55
	
sl@0
    56
  	if (TestStepResult()==EPass)
sl@0
    57
		{
sl@0
    58
		
sl@0
    59
		//Assume failure, unless all is successful
sl@0
    60
		SetTestStepResult(EFail);
sl@0
    61
		
sl@0
    62
		TVariantPtrC operationMode;
sl@0
    63
		
sl@0
    64
		TBool shouldLoad(EFalse);
sl@0
    65
sl@0
    66
		// Create a Symmetric Cipher with the values from the ini file	
sl@0
    67
		CryptoSpi::CSymmetricCipher * impl = NULL;	
sl@0
    68
			
sl@0
    69
		CKey* key = NULL;
sl@0
    70
		TRAPD(err, SetupCipherL(ETrue, EFalse, operationMode, impl, key));
sl@0
    71
sl@0
    72
sl@0
    73
		if(impl && err==KErrNone)
sl@0
    74
			{
sl@0
    75
			INFO_PRINTF1(_L("*** Symmetric Cipher - Positive Object Load: PASS ***"));
sl@0
    76
			delete impl;
sl@0
    77
			delete key;
sl@0
    78
			SetTestStepResult(EPass);
sl@0
    79
			}
sl@0
    80
		else if (!impl && err==KErrNotSupported && 
sl@0
    81
			     GetBoolFromConfig(ConfigSection(),_L("ShouldLoad"), shouldLoad) &&
sl@0
    82
			     shouldLoad == EFalse)
sl@0
    83
			{
sl@0
    84
			INFO_PRINTF1(_L("*** Symmetric Cipher - The object was not loaded which was expected ***"));
sl@0
    85
			INFO_PRINTF1(_L("*** Symmetric Cipher - Positive Object Load: PASS ***"));
sl@0
    86
			SetTestStepResult(EPass);
sl@0
    87
			}
sl@0
    88
		else
sl@0
    89
			{
sl@0
    90
			ERR_PRINTF2(_L("*** FAIL: Failed to Create Symmetric Cipher Object - %d ***"), err);
sl@0
    91
			SetTestStepResult(EFail);
sl@0
    92
			}	
sl@0
    93
		}
sl@0
    94
		
sl@0
    95
	INFO_PRINTF2(_L("HEAP CELLS: %d"), User::CountAllocCells());
sl@0
    96
sl@0
    97
	return TestStepResult();
sl@0
    98
	}
sl@0
    99
sl@0
   100
sl@0
   101
TVerdict CSymmetricCipherPositiveObjectLoadStep::doTestStepPostambleL()
sl@0
   102
	{
sl@0
   103
	return TestStepResult();
sl@0
   104
	}