os/security/crypto/weakcryptospi/test/dumpcryptoplugin/dumpprocessor.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-2009 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
*
sl@0
    16
*/
sl@0
    17
sl@0
    18
sl@0
    19
/**
sl@0
    20
 @file
sl@0
    21
 @internalComponent
sl@0
    22
*/
sl@0
    23
sl@0
    24
#include <cryptospi/cryptospidef.h>
sl@0
    25
#include <bacline.h>
sl@0
    26
#include <cryptospi/cryptocharacteristics.h>
sl@0
    27
#include <cryptospi/cryptospistateapi.h>
sl@0
    28
#include "dumpprocessor.h"
sl@0
    29
#include <cryptospi/cryptoparams.h>
sl@0
    30
#include <cryptospi/extendedcharacteristics.h>
sl@0
    31
#include <e32cons.h>
sl@0
    32
#include <f32file.h>
sl@0
    33
sl@0
    34
using namespace CryptoSpi;
sl@0
    35
sl@0
    36
//
sl@0
    37
//The name of characteristics log file
sl@0
    38
//
sl@0
    39
_LIT(KLogStartMessage, "DumpCryptoSpiTool");
sl@0
    40
const TInt KMaxLineLength = 1024;
sl@0
    41
_LIT8(KNewLine8, "\r\n");
sl@0
    42
sl@0
    43
//
sl@0
    44
//Characteristic Heads
sl@0
    45
//
sl@0
    46
_LIT(KLogHashCharacteristicHead, "[HashCharacteristic]");
sl@0
    47
_LIT(KLogRandomCharacteristicHead, "[RandomCharacteristic]");
sl@0
    48
_LIT(KLogSymmetricCipherCharacteristicHead, "[SymmetricCipherCharacteristic]");
sl@0
    49
_LIT(KLogAsymmetricCipherCharacteristicHead, "[AsymmetricCipherCharacteristic]");
sl@0
    50
_LIT(KLogSignerCharacteristicHead, "[SignerCharacteristic]");
sl@0
    51
_LIT(KLogVerifierCharacteristicHead, "[VerifierCharacteristic]");
sl@0
    52
_LIT(KLogKeyAgreementCharacteristicHead, "[KeyAgreementCharacteristic]");
sl@0
    53
_LIT(KLogKeypairGeneratorCharacteristicHead, "[KeypairGeneratorCharacteristic]");
sl@0
    54
_LIT(KLogUnknownCharacteristicHead, "[UnknownCharacteristic]");
sl@0
    55
sl@0
    56
//
sl@0
    57
//bool and unknow
sl@0
    58
//
sl@0
    59
_LIT(KLogBoolTrue, "True");
sl@0
    60
_LIT(KLogBoolFalse, "False");
sl@0
    61
_LIT(KLogUnknown, "Unknown");
sl@0
    62
sl@0
    63
//Common Characteristics
sl@0
    64
_LIT(KLogInterfaceName, "	InterfaceName = %S");
sl@0
    65
_LIT(KLogAlgorithmUid, "	AlgorithmUid = 0x%x");
sl@0
    66
_LIT(KLogImplementationUid, "	ImplementationUid = 0x%x");
sl@0
    67
_LIT(KLogCreatorName, "	CreatorName = %S");
sl@0
    68
_LIT(KLogFIPSApproved, "	FIPSApproved = %S");
sl@0
    69
_LIT(KLogHardwareImplementation, "	HardwareImplementation = %S");
sl@0
    70
_LIT(KLogAlgorithmName, "	AlgorithmName = %S");
sl@0
    71
_LIT(KLogMaxConcurrency, "	MaxConcurrency = %d");
sl@0
    72
_LIT(KLogLatency, "	Latency = %d");
sl@0
    73
_LIT(KLogThroughput, "	Throughput = %d");
sl@0
    74
sl@0
    75
//Hash Characteristics
sl@0
    76
_LIT(KLogBlockSize, "	BlockSize = %d");
sl@0
    77
_LIT(KLogOutputSize, "	OutputSize = %d");
sl@0
    78
sl@0
    79
//Random Characteristics
sl@0
    80
_LIT(KLogBlockMode, "	BlockMode = %d");
sl@0
    81
sl@0
    82
//Symmetric Cipher Characteristics
sl@0
    83
_LIT(KLogMaximumKeyLength, "	MaximumKeyLength = %d");
sl@0
    84
_LIT(KLogKeySupportMode, "	KeySupportMode = %d");
sl@0
    85
sl@0
    86
//Plugin Dll Name
sl@0
    87
_LIT(KDllName, "	PluginDllName = %S");
sl@0
    88
sl@0
    89
//Extended characteristics
sl@0
    90
_LIT(KLogExtendedCharacteristicInt, "	Ext[0x%x] = 0x%x");
sl@0
    91
_LIT(KLogExtendedCharacteristicDes, "	Ext[0x%x] = %S");
sl@0
    92
_LIT8(KLogExtendedCharacteristicDes8, "	Ext[0x%x] = %S");
sl@0
    93
sl@0
    94
//padding modes definitions	
sl@0
    95
_LIT(KLogPaddingModes1, "	SupportedPaddingModes_%d = %S");
sl@0
    96
_LIT(KLogPaddingModeNone, "NoneMode");
sl@0
    97
_LIT(KLogPaddingModeSSLv3, "SSLv3Mode");
sl@0
    98
_LIT(KLogPaddingModePKCS7, "PKCS7Mode");
sl@0
    99
_LIT(KLogPaddingModePkcs1_v1_5_Encryption, "Pkcs1_v1_5_EncryptionMode");
sl@0
   100
_LIT(KLogPaddingModePkcs1_v1_5_Signature, "Pkcs1_v1_5_SignatureMode");
sl@0
   101
sl@0
   102
//Symmetric cipher operation modes definitions
sl@0
   103
_LIT(KLogOperationModeNone, "NoneMode");
sl@0
   104
_LIT(KLogOperationModeECB, "ECBMode");
sl@0
   105
_LIT(KLogOperationModeCBC, "CBCMode");
sl@0
   106
_LIT(KLogOperationModeOFB, "OFBMode");
sl@0
   107
_LIT(KLogOperationModeCFB, "CFBMode");
sl@0
   108
_LIT(KLogOperationModeCTR, "CTRMode");
sl@0
   109
sl@0
   110
//Hash modes definitions
sl@0
   111
_LIT(KLogOperationModes1, "	SupportedOperationModes_%d = %S");
sl@0
   112
_LIT(KLogOperationModeHash, "HashMode");
sl@0
   113
_LIT(KLogOperationModeHmac, "HmacMode");
sl@0
   114
sl@0
   115
//Help text
sl@0
   116
_LIT(KUsage, "Usage: dumpcryptoplugin [switches] \n");
sl@0
   117
_LIT(KHelpInterface, "-interface/-i <interface name>	Dump characteristics for the interface, which can be\n");
sl@0
   118
_LIT(KHelpInterface1, "				hash,random,symcipher,asymcipher,signer,verifier,\n");
sl@0
   119
_LIT(KHelpInterface2, "				keypairgen,keyagree,asynchash,asyncrandom,asyncsymcipher\n");
sl@0
   120
_LIT(KHelpInterface3, "				asyncsigner,asyncverifier,asynckeypairgen,asynckeyagree.\n");
sl@0
   121
_LIT(KHelpAlgorithm, "-algorithm/-al <algorithm name>	Dump characteristics for the algorithm, which can be\n");
sl@0
   122
_LIT(KHelpAlgorithm1, "				md2,md4,md5,sha1,des,3des,rc2,aes,rc4,rsacipher,rsasigner\n");
sl@0
   123
_LIT(KHelpAlgorithm2, "				rsaverifier,rsakeypair,dsasigner,dsaverifier,dsakeypair\n");
sl@0
   124
_LIT(KHelpAlgorithm3, "				dhkeypair,dhkeyagree.\n");
sl@0
   125
_LIT(KHelpAll, "-all/-a				Dump all the characteristics of all the inplementations.\n");
sl@0
   126
_LIT(KHelpExtended, "-extended/-e			Dump the extended characteristics as well.\n");
sl@0
   127
_LIT(KHelpDll, "-dll/-d	<filename>		Only dump the characteristics for the given plugin Dll.\n");
sl@0
   128
_LIT(KHelpOutput, "-out/-o	<drive:><path><filename>Output file name.\n");
sl@0
   129
_LIT(KHelpHelp, "-help/-h			Help\n");
sl@0
   130
sl@0
   131
_LIT(KProgessStatus, "Progressing\n");
sl@0
   132
_LIT(KFileStatus, "Dump to %S");
sl@0
   133
_LIT(KInvalidArgument, "Invalid Argument:");
sl@0
   134
_LIT(KArgument, " %S");
sl@0
   135
sl@0
   136
sl@0
   137
//
sl@0
   138
//Implementation of CDumpToolParameters
sl@0
   139
//
sl@0
   140
CDumpToolParameters* CDumpToolParameters::NewLC()
sl@0
   141
	{
sl@0
   142
	CDumpToolParameters* self=new(ELeave) CDumpToolParameters();
sl@0
   143
	CleanupStack::PushL(self);
sl@0
   144
	return self;		
sl@0
   145
	}
sl@0
   146
	
sl@0
   147
CDumpToolParameters::~CDumpToolParameters()
sl@0
   148
	{
sl@0
   149
	iOptions.Close();
sl@0
   150
	iInvalidOptions.ResetAndDestroy();
sl@0
   151
	}
sl@0
   152
	
sl@0
   153
CDumpToolParameters::CDumpToolParameters()
sl@0
   154
	{
sl@0
   155
	}
sl@0
   156
sl@0
   157
TBool CDumpToolParameters::FindOption(TOption aOption) const
sl@0
   158
	{
sl@0
   159
	TBool found=EFalse;
sl@0
   160
	TInt count=iOptions.Count();
sl@0
   161
	for (TInt i=0;i<count;i++)
sl@0
   162
		{
sl@0
   163
		if (aOption==iOptions[i])
sl@0
   164
			{
sl@0
   165
			found=ETrue;
sl@0
   166
			break;	
sl@0
   167
			}
sl@0
   168
		}
sl@0
   169
	return found;
sl@0
   170
	}
sl@0
   171
	
sl@0
   172
//
sl@0
   173
//Implementation of CDumpToolProcessor
sl@0
   174
//
sl@0
   175
CDumpToolProcessor* CDumpToolProcessor::NewLC(const CDumpToolParameters& aParams, CConsoleBase* aConsole)
sl@0
   176
	{
sl@0
   177
	CDumpToolProcessor* self=new(ELeave) CDumpToolProcessor(aParams, aConsole);
sl@0
   178
	CleanupStack::PushL(self);
sl@0
   179
	self->ConstructL();
sl@0
   180
	return self;		
sl@0
   181
	}
sl@0
   182
sl@0
   183
CDumpToolProcessor::~CDumpToolProcessor()
sl@0
   184
	{
sl@0
   185
	iLogFile.Close();
sl@0
   186
	iFs.Close();
sl@0
   187
	iCharacters.ResetAndDestroy();	
sl@0
   188
	}
sl@0
   189
sl@0
   190
CDumpToolProcessor::CDumpToolProcessor(const CDumpToolParameters& aParams, CConsoleBase* aConsole)
sl@0
   191
: iInputParams(aParams), iConsole(aConsole)
sl@0
   192
	{
sl@0
   193
	}
sl@0
   194
sl@0
   195
void CDumpToolProcessor::ConstructL()
sl@0
   196
	{
sl@0
   197
	User::LeaveIfError(iFs.Connect());
sl@0
   198
		
sl@0
   199
	if (iInputParams.iDumpFileName.CompareF(KNullDesC)==0)
sl@0
   200
		{
sl@0
   201
		TUint driveCh(RFs::GetSystemDriveChar());
sl@0
   202
sl@0
   203
		_LIT(KDumpFileNameFmt, "%c:\\dumpcrypoplugin.txt");
sl@0
   204
		iDumpFileName.Format(KDumpFileNameFmt, driveCh);
sl@0
   205
		}
sl@0
   206
	else
sl@0
   207
		{
sl@0
   208
		TInt pos=iInputParams.iDumpFileName.LocateReverseF('\\');
sl@0
   209
		TFileName path=iInputParams.iDumpFileName.Left(pos+1);
sl@0
   210
		TInt ret=iFs.MkDirAll(path);
sl@0
   211
		if (ret!=KErrNone && ret!=KErrAlreadyExists)
sl@0
   212
			{
sl@0
   213
			User::LeaveIfError(ret);	
sl@0
   214
			}
sl@0
   215
		iDumpFileName=iInputParams.iDumpFileName;
sl@0
   216
		}
sl@0
   217
	
sl@0
   218
	User::LeaveIfError(iLogFile.Replace(iFs, iDumpFileName, EFileWrite | EFileShareExclusive));
sl@0
   219
	TBool extended=EFalse;
sl@0
   220
	if (iInputParams.FindOption(CDumpToolParameters::EOptionExtendedCharacteristic))
sl@0
   221
		{
sl@0
   222
		extended=ETrue;
sl@0
   223
		}
sl@0
   224
	CCryptoSpiStateApi::EnumerateCharacteristicsL(iCharacters, iInputParams.iInterface, extended);
sl@0
   225
	}
sl@0
   226
	
sl@0
   227
void CDumpToolProcessor::ProcessL()
sl@0
   228
	{
sl@0
   229
	if (iInputParams.FindOption(CDumpToolParameters::EOptionHelp))
sl@0
   230
		{
sl@0
   231
		DisplayHelp();
sl@0
   232
		return;	
sl@0
   233
		}
sl@0
   234
	
sl@0
   235
	if (iInputParams.iInvalidOptions.Count()!=0 )
sl@0
   236
		{
sl@0
   237
		DisplayInvalidOptions();
sl@0
   238
		return;
sl@0
   239
		}
sl@0
   240
	
sl@0
   241
	LogL(KLogStartMessage);
sl@0
   242
	TInt count=iCharacters.Count();
sl@0
   243
	iConsole->Printf(KProgessStatus);
sl@0
   244
	for (TInt i=0;i<count;i++)
sl@0
   245
		{
sl@0
   246
		if (iInputParams.iAlgorithm!=0 
sl@0
   247
			&& iInputParams.iAlgorithm!=iCharacters[i]->iCharacteristic->iAlgorithmUid)
sl@0
   248
			{
sl@0
   249
			continue;
sl@0
   250
			}
sl@0
   251
		
sl@0
   252
		if (iInputParams.iDllName.Compare(KNullDesC)!=0
sl@0
   253
			&&iInputParams.iDllName.Compare(iCharacters[i]->iDllName)!=0)
sl@0
   254
			{
sl@0
   255
			continue;
sl@0
   256
			}
sl@0
   257
		OutputCharcteristicsAndDllL(*iCharacters[i]);
sl@0
   258
		}
sl@0
   259
	iConsole->Printf(KFileStatus, &iDumpFileName);
sl@0
   260
	}
sl@0
   261
sl@0
   262
void CDumpToolProcessor::OutputCharacteristicHeadL(TInt32 aInterfaceUid)
sl@0
   263
	{
sl@0
   264
	LogL(KNewLine8);
sl@0
   265
	switch (aInterfaceUid)
sl@0
   266
		{
sl@0
   267
	case KHashInterface:
sl@0
   268
	case KAsyncHashInterface:
sl@0
   269
		LogL(KLogHashCharacteristicHead);
sl@0
   270
		break;
sl@0
   271
sl@0
   272
	case KRandomInterface:
sl@0
   273
	case KAsyncRandomInterface:
sl@0
   274
		LogL(KLogRandomCharacteristicHead);
sl@0
   275
		break;
sl@0
   276
		
sl@0
   277
	case KSymmetricCipherInterface:
sl@0
   278
	case KAsyncSymmetricCipherInterface:
sl@0
   279
		LogL(KLogSymmetricCipherCharacteristicHead);
sl@0
   280
		break;
sl@0
   281
		
sl@0
   282
	case KAsymmetricCipherInterface:
sl@0
   283
	case KAsyncAsymmetricCipherInterface:
sl@0
   284
		LogL(KLogAsymmetricCipherCharacteristicHead);
sl@0
   285
		break;
sl@0
   286
		
sl@0
   287
	case KSignerInterface:
sl@0
   288
	case KAsyncSignerInterface:
sl@0
   289
		LogL(KLogSignerCharacteristicHead);
sl@0
   290
		break;
sl@0
   291
		
sl@0
   292
	case KVerifierInterface:
sl@0
   293
	case KAsyncVerifierInterface:
sl@0
   294
		LogL(KLogVerifierCharacteristicHead);
sl@0
   295
		break;
sl@0
   296
		
sl@0
   297
	case KKeyAgreementInterface:
sl@0
   298
	case KAsyncKeyAgreementInterface:
sl@0
   299
		LogL(KLogKeyAgreementCharacteristicHead);
sl@0
   300
		break;
sl@0
   301
		
sl@0
   302
	case KKeypairGeneratorInterface:
sl@0
   303
	case KAsyncKeypairGeneratorInterface:
sl@0
   304
		LogL(KLogKeypairGeneratorCharacteristicHead);
sl@0
   305
		break;
sl@0
   306
		
sl@0
   307
	default:
sl@0
   308
		LogL(KLogUnknownCharacteristicHead);
sl@0
   309
		}
sl@0
   310
	}
sl@0
   311
sl@0
   312
sl@0
   313
void CDumpToolProcessor::OutputInterfaceNameL(TInt32 aInterfaceUid)
sl@0
   314
	{
sl@0
   315
	switch (aInterfaceUid)
sl@0
   316
		{
sl@0
   317
	case KHashInterface:
sl@0
   318
		LogL(KLogInterfaceName, &KHash);
sl@0
   319
		break;
sl@0
   320
		
sl@0
   321
	case KAsyncHashInterface:
sl@0
   322
		LogL(KLogInterfaceName, &KAsyncHash);
sl@0
   323
		break;
sl@0
   324
sl@0
   325
	case KRandomInterface:
sl@0
   326
		LogL(KLogInterfaceName, &KRandom);
sl@0
   327
		break;
sl@0
   328
	
sl@0
   329
	case KAsyncRandomInterface:
sl@0
   330
		LogL(KLogInterfaceName, &KAsyncRandom);
sl@0
   331
		break;
sl@0
   332
		
sl@0
   333
	case KSymmetricCipherInterface:
sl@0
   334
		LogL(KLogInterfaceName, &KSymmetricCipher);
sl@0
   335
		break;
sl@0
   336
	
sl@0
   337
	case KAsyncSymmetricCipherInterface:
sl@0
   338
		LogL(KLogInterfaceName, &KAsyncSymmetricCipher);
sl@0
   339
		break;
sl@0
   340
		
sl@0
   341
	case KAsymmetricCipherInterface:
sl@0
   342
		LogL(KLogInterfaceName, &KAsymmetricCipher);
sl@0
   343
		break;
sl@0
   344
	
sl@0
   345
	case KAsyncAsymmetricCipherInterface:
sl@0
   346
		LogL(KLogInterfaceName, &KAsyncAsymmetricCipher);
sl@0
   347
		break;
sl@0
   348
		
sl@0
   349
	case KSignerInterface:
sl@0
   350
		LogL(KLogInterfaceName, &KSigner);
sl@0
   351
		break;
sl@0
   352
	
sl@0
   353
	case KAsyncSignerInterface:
sl@0
   354
		LogL(KLogInterfaceName, &KAsyncSigner);
sl@0
   355
		break;
sl@0
   356
		
sl@0
   357
	case KVerifierInterface:
sl@0
   358
		LogL(KLogInterfaceName, &KVerifier);
sl@0
   359
		break;
sl@0
   360
	
sl@0
   361
	case KAsyncVerifierInterface:
sl@0
   362
		LogL(KLogInterfaceName, &KAsyncVerifier);
sl@0
   363
		break;
sl@0
   364
		
sl@0
   365
	case KKeyAgreementInterface:
sl@0
   366
		LogL(KLogInterfaceName, &KKeyAgreement);
sl@0
   367
		break;
sl@0
   368
	
sl@0
   369
	case KAsyncKeyAgreementInterface:
sl@0
   370
		LogL(KLogInterfaceName, &KAsyncKeyAgreement);
sl@0
   371
		break;
sl@0
   372
		
sl@0
   373
	case KKeypairGeneratorInterface:
sl@0
   374
		LogL(KLogInterfaceName, &KKeyPairGenerator);
sl@0
   375
		break;
sl@0
   376
	
sl@0
   377
	case KAsyncKeypairGeneratorInterface:
sl@0
   378
		LogL(KLogInterfaceName, &KAsyncKeyPairGenerator);
sl@0
   379
		break;
sl@0
   380
		
sl@0
   381
	default:
sl@0
   382
		LogL(KLogInterfaceName, &KLogUnknown);
sl@0
   383
		}		
sl@0
   384
	}
sl@0
   385
sl@0
   386
void CDumpToolProcessor::OutputAlgorithmNameL(TInt32 aAlgorithmUid)
sl@0
   387
	{
sl@0
   388
	switch (aAlgorithmUid)
sl@0
   389
		{
sl@0
   390
	case KAlgorithmHashMd2:
sl@0
   391
		LogL(KLogAlgorithmName, &KMd2);
sl@0
   392
		break;
sl@0
   393
	case KAlgorithmHashMd4:
sl@0
   394
		LogL(KLogAlgorithmName, &KMd4);
sl@0
   395
		break;		
sl@0
   396
	case KAlgorithmHashMd5:
sl@0
   397
		LogL(KLogAlgorithmName, &KMd5);
sl@0
   398
		break;
sl@0
   399
	case KAlgorithmHashSha1:
sl@0
   400
		LogL(KLogAlgorithmName, &KSha1);
sl@0
   401
		break;
sl@0
   402
	case KAlgorithmCipherDes:
sl@0
   403
		LogL(KLogAlgorithmName, &KDes);	
sl@0
   404
		break;
sl@0
   405
	case KAlgorithmCipher3Des:
sl@0
   406
		LogL(KLogAlgorithmName, &K3Des);	
sl@0
   407
		break;
sl@0
   408
	case KAlgorithmCipherRc2:
sl@0
   409
		LogL(KLogAlgorithmName, &KRC2);	
sl@0
   410
		break;
sl@0
   411
	case KAlgorithmCipherAes:
sl@0
   412
		LogL(KLogAlgorithmName, &KAes);	
sl@0
   413
		break;
sl@0
   414
	case KAlgorithmCipherArc4:
sl@0
   415
		LogL(KLogAlgorithmName, &KRC4);	
sl@0
   416
		break;
sl@0
   417
	case KAlgorithmCipherRsa:
sl@0
   418
		LogL(KLogAlgorithmName, &KRsaCipher);	
sl@0
   419
		break;
sl@0
   420
	case KAlgorithmSignerRsa:
sl@0
   421
		LogL(KLogAlgorithmName, &KRsaSigner);	
sl@0
   422
		break;
sl@0
   423
	case KAlgorithmVerifierRsa:
sl@0
   424
		LogL(KLogAlgorithmName, &KRsaVerifier);	
sl@0
   425
		break;
sl@0
   426
	case KAlgorithmRSAKeyPairGenerator:
sl@0
   427
		LogL(KLogAlgorithmName, &KRsaKeyPair);	
sl@0
   428
		break;
sl@0
   429
	case KAlgorithmSignerDsa:
sl@0
   430
		LogL(KLogAlgorithmName, &KDsaSigner);	
sl@0
   431
		break;
sl@0
   432
	case KAlgorithmVerifierDsa:
sl@0
   433
		LogL(KLogAlgorithmName, &KDsaVerifier);	
sl@0
   434
		break;
sl@0
   435
	case KAlgorithmDSAKeyPairGenerator:
sl@0
   436
		LogL(KLogAlgorithmName, &KDsaKeyPair);	
sl@0
   437
		break;
sl@0
   438
	case KAlgorithmDHKeyPairGenerator:
sl@0
   439
		LogL(KLogAlgorithmName, &KDhKeyPair);	
sl@0
   440
		break;
sl@0
   441
	case KAlgorithmKeyAgreementDH:
sl@0
   442
		LogL(KLogAlgorithmName, &KDhKeyAgreement);	
sl@0
   443
		break;
sl@0
   444
	default:;
sl@0
   445
		}
sl@0
   446
	}
sl@0
   447
sl@0
   448
void CDumpToolProcessor::OutputHashOperationModeL(TInt aIndex, TInt32 aOperationMode)
sl@0
   449
	{
sl@0
   450
	switch(aOperationMode)
sl@0
   451
		{
sl@0
   452
	case KHashMode:
sl@0
   453
		LogL(KLogOperationModes1, aIndex, &KLogOperationModeHash);
sl@0
   454
		break;
sl@0
   455
	case KHmacMode:
sl@0
   456
		LogL(KLogOperationModes1, aIndex, &KLogOperationModeHmac);
sl@0
   457
		break;
sl@0
   458
	default:;
sl@0
   459
		}
sl@0
   460
	}
sl@0
   461
sl@0
   462
void CDumpToolProcessor::OutputSymmetricOperationModeL(TInt aIndex, TInt32 aOperationMode)
sl@0
   463
	{
sl@0
   464
	switch(aOperationMode)
sl@0
   465
		{
sl@0
   466
	case KOperationModeNone:
sl@0
   467
		LogL(KLogOperationModes1, aIndex, &KLogOperationModeNone);
sl@0
   468
		break;
sl@0
   469
	case KOperationModeECB:
sl@0
   470
		LogL(KLogOperationModes1, aIndex, &KLogOperationModeECB);
sl@0
   471
		break;
sl@0
   472
	case KOperationModeCBC:
sl@0
   473
		LogL(KLogOperationModes1, aIndex, &KLogOperationModeCBC);
sl@0
   474
		break;
sl@0
   475
	case KOperationModeOFB:
sl@0
   476
		LogL(KLogOperationModes1, aIndex, &KLogOperationModeOFB);
sl@0
   477
		break;
sl@0
   478
	case KOperationModeCFB:
sl@0
   479
		LogL(KLogOperationModes1, aIndex, &KLogOperationModeCFB);
sl@0
   480
		break;
sl@0
   481
	case KOperationModeCTR:
sl@0
   482
		LogL(KLogOperationModes1, aIndex, &KLogOperationModeCTR);
sl@0
   483
		break;		
sl@0
   484
	default:;
sl@0
   485
		}	
sl@0
   486
	}
sl@0
   487
sl@0
   488
void CDumpToolProcessor::OutputPaddingModeL(TInt aIndex, TInt32 aPaddingMode)
sl@0
   489
	{
sl@0
   490
	switch(aPaddingMode)
sl@0
   491
		{
sl@0
   492
	case KPaddingModeNone:
sl@0
   493
		LogL(KLogPaddingModes1, aIndex, &KLogPaddingModeNone);
sl@0
   494
		break;
sl@0
   495
	case KPaddingModeSSLv3:
sl@0
   496
		LogL(KLogPaddingModes1, aIndex, &KLogPaddingModeSSLv3);
sl@0
   497
		break;
sl@0
   498
	case KPaddingModePKCS7:
sl@0
   499
		LogL(KLogPaddingModes1, aIndex, &KLogPaddingModePKCS7);
sl@0
   500
		break;
sl@0
   501
	case KPaddingModePkcs1_v1_5_Encryption:
sl@0
   502
		LogL(KLogPaddingModes1, aIndex, &KLogPaddingModePkcs1_v1_5_Encryption);
sl@0
   503
		break;
sl@0
   504
	case KPaddingModePkcs1_v1_5_Signature:
sl@0
   505
		LogL(KLogPaddingModes1, aIndex, &KLogPaddingModePkcs1_v1_5_Signature);
sl@0
   506
		break;
sl@0
   507
	default:;
sl@0
   508
		}		
sl@0
   509
	}
sl@0
   510
sl@0
   511
void CDumpToolProcessor::OutputSpecificCharacteristicL(const CCharacteristics& aCharacter)
sl@0
   512
	{
sl@0
   513
	switch (aCharacter.iInterfaceUid)
sl@0
   514
		{
sl@0
   515
	case KHashInterface:
sl@0
   516
	case KAsyncHashInterface:
sl@0
   517
		{
sl@0
   518
		const CHashCharacteristics& sCharacter=static_cast<const CHashCharacteristics&>(aCharacter);
sl@0
   519
		LogL(KLogBlockSize, sCharacter.iBlockSize);
sl@0
   520
		LogL(KLogOutputSize, sCharacter.iOutputSize);
sl@0
   521
		TInt count=sCharacter.iSupportedOperationModes.Count();
sl@0
   522
		for (TInt i=0;i<count;i++)
sl@0
   523
			{
sl@0
   524
			OutputHashOperationModeL(i, sCharacter.iSupportedOperationModes[i]);
sl@0
   525
			}			
sl@0
   526
		}
sl@0
   527
		break;
sl@0
   528
sl@0
   529
	case KRandomInterface:
sl@0
   530
	case KAsyncRandomInterface:
sl@0
   531
		{
sl@0
   532
		const CRandomCharacteristics& sCharacter=static_cast<const CRandomCharacteristics&>(aCharacter);
sl@0
   533
		LogL(KLogBlockMode, sCharacter.iBlockingMode);			
sl@0
   534
		}
sl@0
   535
		break;
sl@0
   536
		
sl@0
   537
	case KSymmetricCipherInterface:
sl@0
   538
	case KAsyncSymmetricCipherInterface:
sl@0
   539
		{
sl@0
   540
		const CSymmetricCipherCharacteristics& sCharacter=static_cast<const CSymmetricCipherCharacteristics&>(aCharacter);
sl@0
   541
		LogL(KLogMaximumKeyLength, sCharacter.iMaximumKeyLength);
sl@0
   542
		LogL(KLogBlockSize, sCharacter.iBlockSize);
sl@0
   543
		TInt count=sCharacter.iSupportedPaddingModes.Count();
sl@0
   544
		for (TInt i=0;i<count;i++)
sl@0
   545
			{
sl@0
   546
			OutputPaddingModeL(i, sCharacter.iSupportedPaddingModes[i]);
sl@0
   547
			}			
sl@0
   548
		count=sCharacter.iSupportedOperationModes.Count();
sl@0
   549
		for (TInt i=0;i<count;i++)
sl@0
   550
			{
sl@0
   551
			OutputSymmetricOperationModeL(i, sCharacter.iSupportedOperationModes[i]);
sl@0
   552
			}
sl@0
   553
		LogL(KLogKeySupportMode, sCharacter.iKeySupportMode);
sl@0
   554
		}
sl@0
   555
		break;
sl@0
   556
		
sl@0
   557
	case KAsymmetricCipherInterface:
sl@0
   558
	case KAsyncAsymmetricCipherInterface:
sl@0
   559
		{
sl@0
   560
		const CAsymmetricCipherCharacteristics& sCharacter=static_cast<const CAsymmetricCipherCharacteristics&>(aCharacter);
sl@0
   561
		LogL(KLogMaximumKeyLength, sCharacter.iMaximumKeyLength);
sl@0
   562
		TInt count=sCharacter.iSupportedPaddingModes.Count();
sl@0
   563
		for (TInt i=0;i<count;i++)
sl@0
   564
			{
sl@0
   565
			OutputPaddingModeL(i, sCharacter.iSupportedPaddingModes[i]);
sl@0
   566
			}			
sl@0
   567
		LogL(KLogKeySupportMode, sCharacter.iKeySupportMode);	
sl@0
   568
		}
sl@0
   569
		break;
sl@0
   570
		
sl@0
   571
	case KSignerInterface:
sl@0
   572
	case KAsyncSignerInterface:
sl@0
   573
	case KVerifierInterface:
sl@0
   574
	case KAsyncVerifierInterface:
sl@0
   575
		{
sl@0
   576
		const CAsymmetricSignatureCharacteristics& sCharacter=static_cast<const CAsymmetricSignatureCharacteristics&>(aCharacter);
sl@0
   577
		LogL(KLogMaximumKeyLength, sCharacter.iMaximumKeyLength);
sl@0
   578
		TInt count=sCharacter.iSupportedPaddingModes.Count();
sl@0
   579
		for (TInt i=0;i<count;i++)
sl@0
   580
			{
sl@0
   581
			OutputPaddingModeL(i, sCharacter.iSupportedPaddingModes[i]);
sl@0
   582
			}			
sl@0
   583
		LogL(KLogKeySupportMode, sCharacter.iKeySupportMode);	
sl@0
   584
		}	
sl@0
   585
		break;
sl@0
   586
		
sl@0
   587
	case KKeypairGeneratorInterface:
sl@0
   588
	case KAsyncKeypairGeneratorInterface:
sl@0
   589
		{
sl@0
   590
		const CKeypairGeneratorCharacteristics& sCharacter=static_cast<const CKeypairGeneratorCharacteristics&>(aCharacter);
sl@0
   591
		LogL(KLogMaximumKeyLength, sCharacter.iMaximumKeyLength);			
sl@0
   592
		}
sl@0
   593
		break;
sl@0
   594
		
sl@0
   595
	case KKeyAgreementInterface:
sl@0
   596
	case KAsyncKeyAgreementInterface:
sl@0
   597
	default:
sl@0
   598
		;
sl@0
   599
		}
sl@0
   600
	}
sl@0
   601
sl@0
   602
void CDumpToolProcessor::OutputExtendedCharacteristicL(const CExtendedCharacteristics& aCharacter)
sl@0
   603
	{
sl@0
   604
	CExtendedCharacteristics& character=const_cast<CExtendedCharacteristics&>(aCharacter);
sl@0
   605
	const CCryptoParams* params=character.ListExtendedCharacteristics();
sl@0
   606
	const RPointerArray<CCryptoParam>& list=params->GetParams();
sl@0
   607
	TInt count=list.Count();
sl@0
   608
	for (TInt i=0;i<count;i++)
sl@0
   609
		{
sl@0
   610
		TInt type=list[i]->Type();
sl@0
   611
		switch (type)
sl@0
   612
			{
sl@0
   613
		case CCryptoParam::EInt:
sl@0
   614
			LogL(KLogExtendedCharacteristicInt, list[i]->Uid().iUid, ((CCryptoIntParam*)list[i])->Value());
sl@0
   615
			break;
sl@0
   616
		case CCryptoParam::EBigInt:
sl@0
   617
			{
sl@0
   618
			const TInteger& bigInt=((CCryptoBigIntParam*)list[i])->Value();
sl@0
   619
			HBufC8* buf8=bigInt.BufferLC();
sl@0
   620
			LogL(KLogExtendedCharacteristicDes8, list[i]->Uid().iUid, buf8);
sl@0
   621
			CleanupStack::PopAndDestroy(buf8);				
sl@0
   622
			}
sl@0
   623
			break;
sl@0
   624
		case CCryptoParam::EDesC8:
sl@0
   625
			LogL(KLogExtendedCharacteristicDes8, list[i]->Uid().iUid, ((CCryptoIntParam*)list[i])->Value());
sl@0
   626
			break;
sl@0
   627
		case CCryptoParam::EDesC16:
sl@0
   628
			LogL(KLogExtendedCharacteristicDes, list[i]->Uid().iUid, ((CCryptoIntParam*)list[i])->Value());
sl@0
   629
			break;
sl@0
   630
		default:;
sl@0
   631
			}
sl@0
   632
		}
sl@0
   633
	}
sl@0
   634
sl@0
   635
void CDumpToolProcessor::OutputCharcteristicsAndDllL(const CCharacteristicsAndPluginName& aElement)
sl@0
   636
	{
sl@0
   637
	//Output Head
sl@0
   638
	OutputCharacteristicHeadL(aElement.iCharacteristic->iInterfaceUid);
sl@0
   639
	
sl@0
   640
	//Start of Common Characteristics output
sl@0
   641
	//Output Interface name
sl@0
   642
	OutputInterfaceNameL(aElement.iCharacteristic->iInterfaceUid);
sl@0
   643
	
sl@0
   644
	//Output Algorithm Uid
sl@0
   645
	LogL(KLogAlgorithmUid, aElement.iCharacteristic->iAlgorithmUid);
sl@0
   646
	
sl@0
   647
	//Output Implementation Uid
sl@0
   648
	LogL(KLogImplementationUid, aElement.iCharacteristic->iImplementationUid);
sl@0
   649
	
sl@0
   650
	//Output Creator's name
sl@0
   651
	TFileName name=aElement.iCharacteristic->iCreatorName;
sl@0
   652
	LogL(KLogCreatorName, &name);
sl@0
   653
	
sl@0
   654
	//Output FIPS Approved Flag
sl@0
   655
	if (aElement.iCharacteristic->iIsFIPSApproved)
sl@0
   656
		{
sl@0
   657
		LogL(KLogFIPSApproved, &KLogBoolTrue);
sl@0
   658
		}
sl@0
   659
	else
sl@0
   660
		{
sl@0
   661
		LogL(KLogFIPSApproved, &KLogBoolFalse);
sl@0
   662
		}
sl@0
   663
		
sl@0
   664
	//Output Hardware supported flag
sl@0
   665
	if (aElement.iCharacteristic->iIsHardwareSupported)
sl@0
   666
		{
sl@0
   667
		LogL(KLogHardwareImplementation, &KLogBoolTrue);			
sl@0
   668
		}
sl@0
   669
	else
sl@0
   670
		{
sl@0
   671
		LogL(KLogHardwareImplementation, &KLogBoolFalse);		
sl@0
   672
		}
sl@0
   673
		
sl@0
   674
	//Output Max concurrency supported
sl@0
   675
	LogL(KLogMaxConcurrency, aElement.iCharacteristic->iMaxConcurrencySupported);
sl@0
   676
	
sl@0
   677
	//Output Algorithm Name
sl@0
   678
	name=aElement.iCharacteristic->iAlgorithmName;
sl@0
   679
	LogL(KLogAlgorithmName, &name);
sl@0
   680
	
sl@0
   681
	//Output Latency
sl@0
   682
	LogL(KLogLatency, aElement.iCharacteristic->iLatency);
sl@0
   683
	
sl@0
   684
	//Output throughput
sl@0
   685
	LogL(KLogThroughput, aElement.iCharacteristic->iThroughput);
sl@0
   686
	//end of Common Characteristics output
sl@0
   687
	
sl@0
   688
	//Output Specific Characteristic
sl@0
   689
	OutputSpecificCharacteristicL(*aElement.iCharacteristic);
sl@0
   690
	
sl@0
   691
	//Output extended characteristics
sl@0
   692
	if (aElement.iExtendedCharacteristic)
sl@0
   693
		{
sl@0
   694
		OutputExtendedCharacteristicL(*aElement.iExtendedCharacteristic);
sl@0
   695
		}
sl@0
   696
	
sl@0
   697
	//Output the name of the plugin dll, which contains this implementation
sl@0
   698
	LogL(KDllName, &aElement.iDllName);	
sl@0
   699
	}
sl@0
   700
	
sl@0
   701
void CDumpToolProcessor::LogL(TRefByValue<const TDesC8> aFmt, ...)
sl@0
   702
	{
sl@0
   703
	TBuf8<KMaxLineLength> buf;
sl@0
   704
	VA_LIST args;
sl@0
   705
	VA_START(args, aFmt);
sl@0
   706
	buf.AppendFormatList(aFmt, args);
sl@0
   707
	VA_END(args);
sl@0
   708
sl@0
   709
	User::LeaveIfError(iLogFile.Write(buf));
sl@0
   710
	User::LeaveIfError(iLogFile.Write(KNewLine8));
sl@0
   711
	User::LeaveIfError(iLogFile.Flush());
sl@0
   712
	}
sl@0
   713
	
sl@0
   714
void CDumpToolProcessor::LogL(TRefByValue<const TDesC> aFmt, ...)
sl@0
   715
	{
sl@0
   716
	TBuf<KMaxLineLength> buf;
sl@0
   717
	VA_LIST args;
sl@0
   718
	VA_START(args, aFmt);
sl@0
   719
	buf.AppendFormatList(aFmt, args);
sl@0
   720
	VA_END(args);
sl@0
   721
sl@0
   722
	TBuf8<KMaxLineLength> buf8;
sl@0
   723
	buf8.Copy(buf);
sl@0
   724
	User::LeaveIfError(iLogFile.Write(buf8));
sl@0
   725
	User::LeaveIfError(iLogFile.Write(KNewLine8));
sl@0
   726
	User::LeaveIfError(iLogFile.Flush());
sl@0
   727
	}
sl@0
   728
sl@0
   729
/**
sl@0
   730
Display usage information
sl@0
   731
*/
sl@0
   732
void CDumpToolProcessor::DisplayHelp()
sl@0
   733
	{
sl@0
   734
	iConsole->Printf(KUsage);
sl@0
   735
	iConsole->Printf(KHelpInterface);
sl@0
   736
	iConsole->Printf(KHelpInterface1);
sl@0
   737
	iConsole->Printf(KHelpInterface2);
sl@0
   738
	iConsole->Printf(KHelpInterface3);
sl@0
   739
	iConsole->Printf(KHelpAlgorithm);
sl@0
   740
	iConsole->Printf(KHelpAlgorithm1);
sl@0
   741
	iConsole->Printf(KHelpAlgorithm2);
sl@0
   742
	iConsole->Printf(KHelpAlgorithm3);
sl@0
   743
	iConsole->Printf(KHelpAll);
sl@0
   744
	iConsole->Printf(KHelpExtended);
sl@0
   745
	iConsole->Printf(KHelpDll);
sl@0
   746
	iConsole->Printf(KHelpOutput);
sl@0
   747
	iConsole->Printf(KHelpHelp);
sl@0
   748
	iConsole->Printf(KNewLine);
sl@0
   749
	iConsole->Printf(KPressAnyKey);
sl@0
   750
	iConsole->Getch();
sl@0
   751
			
sl@0
   752
	}
sl@0
   753
sl@0
   754
sl@0
   755
void CDumpToolProcessor::DisplayInvalidOptions()
sl@0
   756
	{
sl@0
   757
	iConsole->Printf(KInvalidArgument);
sl@0
   758
	TInt count=iInputParams.iInvalidOptions.Count();
sl@0
   759
	for (TInt i=0;i<count;i++)
sl@0
   760
		{
sl@0
   761
		iConsole->Printf(KArgument, iInputParams.iInvalidOptions[i]);	
sl@0
   762
		}
sl@0
   763
	iConsole->Printf(KNewLine);
sl@0
   764
	iConsole->Printf(KPressAnyKey);
sl@0
   765
	iConsole->Getch();
sl@0
   766
	
sl@0
   767
	}
sl@0
   768
	
sl@0
   769
sl@0
   770