crypto/weakcryptospi/test/dumpcryptoplugin/dumpprocessor.h
changeset 8 35751d3474b7
equal deleted inserted replaced
2:675a964f4eb5 8:35751d3474b7
       
     1 /*
       
     2 * Copyright (c) 2007-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 * definition of the dump processor classes
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 /**
       
    21  @file
       
    22  @internalComponent
       
    23  @released
       
    24 */
       
    25 
       
    26 #ifndef _DUMPPROCESSOR_H__
       
    27 #define _DUMPPROCESSOR_H__
       
    28 
       
    29 #include <e32base.h>
       
    30 #include <f32file.h>
       
    31 
       
    32 namespace CryptoSpi
       
    33 	{
       
    34 	//Interfaces Name
       
    35 	_LIT(KHash, "hash");
       
    36 	_LIT(KRandom, "random");
       
    37 	_LIT(KSymmetricCipher, "symcipher");
       
    38 	_LIT(KAsymmetricCipher, "asymcipher");
       
    39 	_LIT(KSigner, "signer");
       
    40 	_LIT(KVerifier, "verifier");
       
    41 	_LIT(KKeyPairGenerator, "keypairgen");
       
    42 	_LIT(KKeyAgreement, "keyagree");
       
    43 	_LIT(KAsyncHash, "asynchash");
       
    44 	_LIT(KAsyncRandom, "asyncrandom");
       
    45 	_LIT(KAsyncSymmetricCipher, "asyncsymcipher");
       
    46 	_LIT(KAsyncAsymmetricCipher, "asyncasymcipher");
       
    47 	_LIT(KAsyncSigner, "asyncsigner");
       
    48 	_LIT(KAsyncVerifier, "asyncverifier");
       
    49 	_LIT(KAsyncKeyPairGenerator, "asynckeypairgen");
       
    50 	_LIT(KAsyncKeyAgreement, "asynckeyagree");
       
    51 
       
    52 	//Algorithms Name
       
    53 	_LIT(KMd2, "md2");
       
    54 	_LIT(KMd4, "md4");
       
    55 	_LIT(KMd5, "md5");
       
    56 	_LIT(KSha1, "sha1");
       
    57 	_LIT(KDes, "des");
       
    58 	_LIT(K3Des, "3des");
       
    59 	_LIT(KRC2, "rc2");
       
    60 	_LIT(KAes, "aes");
       
    61 	_LIT(KRC4, "rc4");
       
    62 	_LIT(KRsaCipher, "rsacipher");
       
    63 	_LIT(KRsaSigner, "rsasigner");
       
    64 	_LIT(KRsaVerifier, "rsaverifier");
       
    65 	_LIT(KRsaKeyPair, "rsakeypair");
       
    66 	_LIT(KDsaSigner, "dsasigner");
       
    67 	_LIT(KDsaVerifier, "dsaverifier");
       
    68 	_LIT(KDsaKeyPair, "dsakeypair");
       
    69 	_LIT(KDhKeyPair, "dhkeypair");
       
    70 	_LIT(KDhKeyAgreement, "dhkeyagree");
       
    71 
       
    72 	_LIT(KNewLine, "\r\n");
       
    73 	_LIT(KPressAnyKey, "Press any key to quit... \n");
       
    74 	
       
    75 	class CCharacteristicsAndPluginName;
       
    76 	class CCharacteristics;
       
    77 	class CExtendedCharacteristics;
       
    78 	
       
    79 	/**
       
    80 	Class to store the command line parameters
       
    81 	*/
       
    82 	NONSHARABLE_CLASS(CDumpToolParameters) : public CBase
       
    83 		{
       
    84 	public:
       
    85 		/**
       
    86 		The options for the command line
       
    87 		*/
       
    88 		enum TOption
       
    89 			{
       
    90 			/**
       
    91 			Help option
       
    92 			*/
       
    93 			EOptionHelp=0,
       
    94 			/**
       
    95 			Option to dump the extended characteristics
       
    96 			*/			
       
    97 			EOptionExtendedCharacteristic
       
    98 			};	
       
    99 
       
   100 		/**
       
   101 		Create a CDumpToolParameters instance and leave it on the cleanup stack
       
   102 		@return the pointer to newly created instance
       
   103 		*/
       
   104 		static CDumpToolParameters* NewLC();
       
   105 		/**
       
   106 		Desctructor
       
   107 		*/		
       
   108 		~CDumpToolParameters();
       
   109 		/**
       
   110 		Look for the command line option
       
   111 		@return ETrue if found, otherwise EFalse
       
   112 		*/
       
   113 		TBool FindOption(TOption aOption) const;
       
   114 
       
   115 	private:
       
   116 		/**
       
   117 		Constructor
       
   118 		*/
       
   119 		CDumpToolParameters();
       
   120 
       
   121 	public:
       
   122 		/**
       
   123 		Command line list
       
   124 		*/
       
   125 		RArray<TInt> iOptions;
       
   126 		/**
       
   127 		The interface uid
       
   128 		*/
       
   129 		TInt32 iInterface;
       
   130 		/**
       
   131 		The algorithm uid
       
   132 		*/
       
   133 		TInt32 iAlgorithm;
       
   134 		/**
       
   135 		The dll name
       
   136 		*/
       
   137 		TFileName iDllName;
       
   138 		/**
       
   139 		Log file name
       
   140 		*/
       
   141 		TFileName iDumpFileName;
       
   142 		/**
       
   143 		Invalid options
       
   144 		*/
       
   145 		RPointerArray<HBufC> iInvalidOptions;
       
   146 		};
       
   147 	
       
   148 	/**
       
   149 	The class to retrieve the characteristics and extended characteristic,
       
   150 	and output them to the text file
       
   151 	*/
       
   152 	NONSHARABLE_CLASS(CDumpToolProcessor) : public CBase
       
   153 		{
       
   154 	public:
       
   155 		/**
       
   156 		Create a CDumpToolProcessor instance
       
   157 		@param aParams the input parameters
       
   158 		@param aConsole the console pointer
       
   159 		@return the pointer to the newly CDumpToolProcessor
       
   160 		*/
       
   161 		static CDumpToolProcessor* NewLC(const CDumpToolParameters& aParams, CConsoleBase* aConsole);
       
   162 		
       
   163 		/**
       
   164 		Destructor
       
   165 		*/
       
   166 		~CDumpToolProcessor();
       
   167 		
       
   168 		/**
       
   169 		Output the characteristics to the text file
       
   170 		*/
       
   171 		void ProcessL();
       
   172 		
       
   173 	private:
       
   174 		/**
       
   175 		Constructor
       
   176 		@param aParams the command line parameters reference
       
   177 		@param aConsole the console pointer
       
   178 		*/
       
   179 		CDumpToolProcessor(const CDumpToolParameters& aParams, CConsoleBase* aConsole);
       
   180 		
       
   181 		/**
       
   182 		2nd phase constructor
       
   183 		*/
       
   184 		void ConstructL();
       
   185 		
       
   186 		/**
       
   187 		Log the characteristics and dll name to the text file
       
   188 		@param aElement the characteristics and Dll index instance
       
   189 		*/
       
   190 		void OutputCharcteristicsAndDllL(const CCharacteristicsAndPluginName& aElement);
       
   191 		
       
   192 		/**
       
   193 		log the characteristics head
       
   194 		@param aInterfaceUid the interface uid
       
   195 		*/
       
   196 		void OutputCharacteristicHeadL(TInt32 aInterfaceUid);
       
   197 		
       
   198 		/**
       
   199 		Log the interface uid
       
   200 		@param aInterfaceUid the interface uid
       
   201 		*/
       
   202 		void OutputInterfaceNameL(TInt32 aInterfaceUid);
       
   203 
       
   204 		/**
       
   205 		Log the algorithm uid
       
   206 		@param aAlgorithmUid the algorithm uid
       
   207 		*/		
       
   208 		void OutputAlgorithmNameL(TInt32 aAlgorithmUid);
       
   209 
       
   210 		/**
       
   211 		Log the static characteristics
       
   212 		@param aCharacter the characteristic instance
       
   213 		*/		
       
   214 		void OutputSpecificCharacteristicL(const CCharacteristics& aCharacter);
       
   215 		
       
   216 		/**
       
   217 		Log the extended characteristics
       
   218 		@param aCharacter the extended characteristic reference
       
   219 		*/
       
   220 		void OutputExtendedCharacteristicL(const CExtendedCharacteristics& aCharacter);
       
   221 		
       
   222 		/**
       
   223 		Log the Hash operation mode
       
   224 		@param aIndex the index of the operation mode
       
   225 		@param aOperationMode the operation mode
       
   226 		*/
       
   227 		void OutputHashOperationModeL(TInt aIndex, TInt32 aOperationMode);
       
   228 		
       
   229 		/**
       
   230 		Log the symmetric operation mode
       
   231 		@param aIndex the index of the operation mode
       
   232 		@param aOperationMode the operation mode
       
   233 		*/		
       
   234 		void OutputSymmetricOperationModeL(TInt aIndex, TInt32 aOperationMode);
       
   235 		
       
   236 		/**
       
   237 		Log the padding mode
       
   238 		@param aIndex the index of the padding mode
       
   239 		@param aPaddingMode the padding mode
       
   240 		*/		
       
   241 		void OutputPaddingModeL(TInt aIndex, TInt32 aPaddingMode);
       
   242 		
       
   243 		/**
       
   244 		Log functions
       
   245 		*/
       
   246 		void LogL(TRefByValue<const TDesC8> aFmt, ...);
       
   247 		void LogL(TRefByValue<const TDesC> aFmt, ...);
       
   248 		
       
   249 		/**
       
   250 		Dispaly functions
       
   251 		*/
       
   252 		void DisplayHelp();
       
   253 		void DisplayInvalidOptions();
       
   254 	private:
       
   255 		/**
       
   256 		The reference of the input parameters
       
   257 		*/
       
   258 		const CDumpToolParameters& iInputParams;
       
   259 		/**
       
   260 		Array of the characteristics
       
   261 		*/
       
   262 		RPointerArray<CCharacteristicsAndPluginName> iCharacters;
       
   263 		/**
       
   264 		File Server Handle
       
   265 		*/
       
   266 		RFs iFs;
       
   267 		/**
       
   268 		Log file handle
       
   269 		*/
       
   270 		RFile iLogFile;
       
   271 		/**
       
   272 		Log file name
       
   273 		*/
       
   274 		TFileName iDumpFileName;
       
   275 		/**
       
   276 		Console
       
   277 		*/
       
   278 		CConsoleBase* iConsole;
       
   279 		};
       
   280 	}
       
   281 	
       
   282 #endif //_DUMPPROCESSOR_H__
       
   283 
       
   284 
       
   285