os/security/crypto/weakcrypto/test/tsymmetric/cryptotestaction.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 /*
     2 * Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     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".
     8 *
     9 * Initial Contributors:
    10 * Nokia Corporation - initial contribution.
    11 *
    12 * Contributors:
    13 *
    14 * Description: 
    15 *
    16 */
    17 
    18 
    19 #ifndef __CRYPTOTESTACTION_H__
    20 #define __CRYPTOTESTACTION_H__
    21 
    22 #include "t_testaction.h"
    23 #include "t_input.h"
    24 
    25 _LIT8(KVectorStart, "<vector>");
    26 _LIT8(KVectorEnd, "</vector>");
    27 _LIT8(KIncrementalStart, "<incremental>");
    28 _LIT8(KIncrementalEnd, "</incremental>");
    29 _LIT8(KKeyStart, "<key>");
    30 _LIT8(KKeyEnd, "</key>");
    31 _LIT8(KInputStart, "<input>");
    32 _LIT8(KInputEnd, "</input>");
    33 _LIT8(KOutputStart, "<output>");
    34 _LIT8(KOutputEnd, "</output>");
    35 _LIT8(KCipherTypeStart, "<ciphertype>");
    36 _LIT8(KCipherTypeEnd, "</ciphertype>");
    37 _LIT8(KIVStart, "<iv>");
    38 _LIT8(KIVEnd, "</iv>");
    39 _LIT8(KMonteCarloStart, "<MonteCarlo>");
    40 _LIT8(KMonteCarloEnd, "</MonteCarlo>");
    41 _LIT8(KEffKeyLenStart, "<effectiveKeyLength>");
    42 _LIT8(KEffKeyLenEnd, "</effectiveKeyLength>");
    43 _LIT8(KIterationsStart, "<iterations>");
    44 _LIT8(KIterationsEnd, "</iterations>");
    45 _LIT8(KRandDataSizeStart, "<randDataSize>"); //Used specifically in performance tests where random data is used rather than specific input and output data pairs
    46 _LIT8(KRandDataSizeEnd, "</randDataSize>");  //Used specifically in performance tests where random data is used rather than specific input and output data pairs
    47 
    48 
    49 class CCryptoTestAction : public CTestAction
    50 {
    51 public:
    52 	CCryptoTestAction(RFs& aFs, CConsoleBase& aConsole, Output& aOut);
    53 	~CCryptoTestAction();
    54 public:
    55 	virtual void ConstructL(const TTestActionSpec& aTestActionSpec);
    56 	virtual void DoPerformPrerequisite(TRequestStatus& aStatus);
    57 	virtual void DoPerformPostrequisite(TRequestStatus& aStatus);
    58 	virtual void PerformAction(TRequestStatus& aStatus);
    59 	virtual void DoReportAction(void);
    60 	virtual void DoCheckResult(TInt);
    61 	virtual void Reset(){}
    62 protected:	
    63 	virtual void DoPerformPrerequisiteL() = 0;
    64 	virtual void DoPerformActionL() = 0;
    65 	virtual void DoPerformPostrequisiteL() {}
    66 protected:
    67 	void Hex(HBufC8& string);
    68 	void DoInputParseL(TDesC8& aScriptBuffer);
    69 protected:
    70 	enum TCipherType
    71 	{
    72 		EDESECB,
    73 		EDESCBC,
    74 		E3DESECB,
    75 		E3DESCBC,
    76 		EAESECB,
    77 		EAESCBC,
    78 		EAESMonteCarloEncryptECB,	//	These extra categories have been added
    79 		EAESMonteCarloDecryptECB,	//	because the Monte-Carlo tests have to be
    80 		EAESMonteCarloEncryptCBC,	//	split between encrypt and decrypt scripts 
    81 		EAESMonteCarloDecryptCBC,	//	(too big for test framework in one chunk)
    82 		ERC2ECB,
    83 		ERC2CBC,
    84 		ERC4,
    85 		ECipherNull
    86 	};
    87 protected:
    88 	RFs& iFs;
    89 	HBufC8* iBody;
    90 	HBufC8* iKey;
    91 	HBufC8* iInput;
    92 	HBufC8* iOutput;
    93 	HBufC8* iIV;
    94 	HBufC8* iEResult;
    95 	HBufC8* iDResult;
    96 	TInt iEffectiveKeyLen;
    97 	TInt iIterationTime;
    98 	TInt iEncryptIterations;
    99 	TInt iDecryptIterations;
   100 	TCipherType iCipherType;
   101 	TTimeIntervalMicroSeconds iEncryptorCreateTime;
   102 	TTimeIntervalMicroSeconds iDecryptorCreateTime;
   103 	TInt iExpectedWeakResult;
   104 	TInt iRandDataSize;
   105 };
   106 
   107 #endif	//	__CRYPTOTESTACTION_H__