os/security/crypto/weakcryptospi/test/tsymmetric/tperformancetest.cpp
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 #include "tperformancetest.h"
    20 #include "symmetric.h"
    21 #include "t_output.h"
    22 
    23 #ifndef _FOO
    24 _LIT(KPerfEFormat, "\tPerformance(encryption)\t%f");
    25 _LIT(KPerfDFormat, "\tPerformance(decryption)\t%f");
    26 _LIT(KTotalFormat, "\tPerformance(total)\t%f");
    27 _LIT(KPerfThroughput, "\tThroughput (total)\t%f");
    28 _LIT(KPerfThroughputAfterSetup, "\tThroughput after setup\t%f");
    29 _LIT(KPerfEncryptorCreate, "\tPerformance(encryptor create)\t%f");
    30 _LIT(KPerfDecryptorCreate, "\tPerformance(decryptor create)\t%f");
    31 //_LIT(KDataSize,"\tData input size : %i B\r\n");
    32 #endif
    33 
    34 CTestAction* CPerformanceTest::NewL(RFs& aFs,
    35 									   CConsoleBase& aConsole,
    36 									   Output& aOut, 
    37 									   const TTestActionSpec& aTestActionSpec)
    38 	{
    39 	CTestAction* self = CPerformanceTest::NewLC(aFs, aConsole,
    40 		aOut, aTestActionSpec);
    41 	CleanupStack::Pop();
    42 	return self;
    43 	}
    44 
    45 CTestAction* CPerformanceTest::NewLC(RFs& aFs,
    46 										CConsoleBase& aConsole,
    47 										Output& aOut, 
    48 										const TTestActionSpec& aTestActionSpec)
    49 	{
    50 	CPerformanceTest* self = new(ELeave) CPerformanceTest(aFs, aConsole, aOut);
    51 	CleanupStack::PushL(self);
    52 	self->ConstructL(aTestActionSpec);
    53 	return self;
    54 	}
    55 
    56 CPerformanceTest::~CPerformanceTest()
    57 {
    58 	delete iEncryptor;
    59 	delete iDecryptor;
    60 }
    61 
    62 CPerformanceTest::CPerformanceTest(RFs& aFs, 
    63 								 CConsoleBase& aConsole,
    64 								 Output& aOut)
    65 								 
    66 : CCryptoTestAction(aFs, aConsole, aOut)
    67 {}
    68 
    69 void CPerformanceTest::DoPerformPrerequisiteL()
    70 {
    71 #ifndef _FOO
    72 	TInt err = KErrNone;
    73 	TInt pos = 0;
    74 	TPtrC8 vector = Input::ParseElement(*iBody, KVectorStart, KVectorEnd, pos, err);
    75 
    76 	DoInputParseL(vector);
    77 
    78 	CBlockTransformation* encryptor = 0;
    79 	CBlockTransformation* decryptor = 0;
    80 
    81 	switch (iCipherType)
    82 	{
    83 		case (EDESECB):
    84 		{//	Time the length of time it takes to set up the key schedule,
    85 		//	save it and add to encrypt time, to be consistent with old API
    86 		//	for comparison purposes (old API does both set up and encrypt/decrypt
    87 		//	in a single operation).
    88 			TTime startTime;
    89 			TTime endTime;
    90 			TTimeIntervalSeconds diff(0);
    91 			const TTimeIntervalSeconds iterationTime(iIterationTime);
    92 			
    93 			encryptor = CDESEncryptor::NewL(iKey->Des());
    94 			iEncryptIterations = 0;
    95 			startTime.UniversalTime();	
    96 			while (diff < iterationTime)
    97 				{
    98 				encryptor->Reset();
    99 				iEncryptIterations++;
   100 				endTime.UniversalTime();
   101 				endTime.SecondsFrom(startTime, diff);
   102 				}
   103 			endTime.UniversalTime();
   104 			iEncryptorCreateTime = endTime.MicroSecondsFrom(startTime);
   105 
   106 			delete encryptor;
   107 			
   108 			decryptor = CDESDecryptor::NewL(iKey->Des());
   109 			
   110 			diff = 0;
   111 			iDecryptIterations = 0;
   112 			startTime.UniversalTime();	
   113 			while (diff < iterationTime)
   114 				{
   115 				decryptor->Reset();
   116 				iDecryptIterations++;
   117 				endTime.UniversalTime();
   118 				endTime.SecondsFrom(startTime, diff);
   119 				}
   120 			endTime.UniversalTime();
   121 			iDecryptorCreateTime = endTime.MicroSecondsFrom(startTime);
   122 
   123 			delete decryptor;
   124 
   125 			encryptor = CDESEncryptor::NewLC(iKey->Des());
   126 			decryptor = CDESDecryptor::NewL(iKey->Des());
   127 			CleanupStack::Pop(encryptor);
   128 		}
   129 		break;
   130 		case(EDESCBC):
   131 		{
   132 			CBlockTransformation* desEncryptor = NULL;
   133 			CBlockTransformation* desDecryptor = NULL;
   134 
   135 			desEncryptor = CDESEncryptor::NewLC(iKey->Des());								
   136 			encryptor = CModeCBCEncryptor::NewL(desEncryptor, iIV->Des());				
   137 			
   138 			TTime startTime;
   139 			TTime endTime;
   140 			TTimeIntervalSeconds diff(0);
   141 			const TTimeIntervalSeconds iterationTime(iIterationTime);
   142 
   143 			iEncryptIterations = 0;
   144 			startTime.UniversalTime();
   145 			while (diff < iterationTime)
   146 				{
   147 				iEncryptIterations++;
   148 				encryptor->Reset();
   149 				endTime.UniversalTime();
   150 				endTime.SecondsFrom(startTime, diff);
   151 				}
   152 			endTime.UniversalTime();
   153 			iEncryptorCreateTime = endTime.MicroSecondsFrom(startTime);
   154 
   155 			CleanupStack::Pop(1);
   156 			delete encryptor;
   157 
   158 			desDecryptor = CDESDecryptor::NewLC(iKey->Des());
   159 			decryptor = CModeCBCDecryptor::NewL(desDecryptor, iIV->Des());
   160 			
   161 			diff = 0;
   162 			iDecryptIterations = 0;
   163 			startTime.UniversalTime();
   164 			while (diff < iterationTime)
   165 				{
   166 				decryptor->Reset();
   167 				iDecryptIterations++;
   168 				endTime.UniversalTime();
   169 				endTime.SecondsFrom(startTime, diff);
   170 				}
   171 			endTime.UniversalTime();
   172 			iDecryptorCreateTime = endTime.MicroSecondsFrom(startTime);
   173 
   174 			CleanupStack::Pop(1);
   175 			delete decryptor;				
   176 
   177 			desEncryptor = CDESEncryptor::NewLC(iKey->Des());
   178 			desDecryptor = CDESDecryptor::NewLC(iKey->Des());
   179 			
   180 			encryptor = CModeCBCEncryptor::NewL(desEncryptor, iIV->Des());
   181 			CleanupStack::PushL(encryptor);
   182 			decryptor = CModeCBCDecryptor::NewL(desDecryptor, iIV->Des());					
   183 			CleanupStack::Pop(3);
   184 		}
   185 		break;
   186 		case (E3DESECB):
   187 		{
   188 			encryptor = C3DESEncryptor::NewL(iKey->Des());
   189 			TTime startTime;
   190 			TTime endTime;
   191 			TTimeIntervalSeconds diff(0);
   192 			const TTimeIntervalSeconds iterationTime(iIterationTime);
   193 
   194 			iEncryptIterations = 0;
   195 			startTime.UniversalTime();	
   196 			while (diff < iterationTime)
   197 				{
   198 				iEncryptIterations++;
   199 				encryptor->Reset();
   200 				endTime.UniversalTime();
   201 				endTime.SecondsFrom(startTime, diff);
   202 				}
   203 			endTime.UniversalTime();
   204 			iEncryptorCreateTime = endTime.MicroSecondsFrom(startTime);
   205 
   206 			delete encryptor;
   207 
   208 			diff = 0;
   209 			iDecryptIterations = 0;
   210 			decryptor = C3DESDecryptor::NewL(iKey->Des());
   211 			startTime.UniversalTime();	
   212 			while (diff < iterationTime)
   213 				{
   214 				decryptor->Reset();
   215 				iDecryptIterations++;
   216 				endTime.UniversalTime();
   217 				endTime.SecondsFrom(startTime, diff);
   218 				}
   219 			endTime.UniversalTime();
   220 			iDecryptorCreateTime = endTime.MicroSecondsFrom(startTime);
   221 			delete decryptor;
   222 
   223 			encryptor = C3DESEncryptor::NewLC(iKey->Des());
   224 			decryptor = C3DESDecryptor::NewL(iKey->Des());
   225 			CleanupStack::Pop(encryptor);
   226 		}
   227 		break;
   228 		case (E3DESCBC):
   229 		{
   230 			CBlockTransformation* the3DESencryptor = NULL;
   231 			CBlockTransformation* the3DESdecryptor = NULL;
   232 
   233 			the3DESencryptor = C3DESEncryptor::NewL(iKey->Des());
   234 			CleanupStack::PushL(the3DESencryptor);
   235 			encryptor = CModeCBCEncryptor::NewL(the3DESencryptor, iIV->Des());
   236 
   237 			TTime startTime;
   238 			TTime endTime;
   239 			TTimeIntervalSeconds diff(0);
   240 			const TTimeIntervalSeconds iterationTime(iIterationTime);
   241 
   242 			iEncryptIterations = 0;
   243 			startTime.UniversalTime();	
   244 			while (diff < iterationTime)
   245 				{
   246 				iEncryptIterations++;
   247 				encryptor->Reset();
   248 				endTime.UniversalTime();
   249 				endTime.SecondsFrom(startTime, diff);
   250 				}
   251 			endTime.UniversalTime();
   252 			iEncryptorCreateTime = endTime.MicroSecondsFrom(startTime);
   253 
   254 			CleanupStack::Pop(1);
   255 			delete encryptor;				
   256 
   257 			the3DESdecryptor = C3DESDecryptor::NewLC(iKey->Des());
   258 			decryptor = CModeCBCDecryptor::NewL(the3DESdecryptor, iIV->Des());		
   259 
   260 			diff = 0;
   261 			iDecryptIterations = 0;
   262 			startTime.UniversalTime();	
   263 			while (diff < iterationTime)
   264 				{
   265 				decryptor->Reset();
   266 				iDecryptIterations++;
   267 				endTime.UniversalTime();
   268 				endTime.SecondsFrom(startTime, diff);
   269 				}
   270 			endTime.UniversalTime();
   271 			iDecryptorCreateTime = endTime.MicroSecondsFrom(startTime);
   272 			CleanupStack::Pop(1);
   273 			delete decryptor;
   274 
   275 			the3DESencryptor = C3DESEncryptor::NewLC(iKey->Des());
   276 			the3DESdecryptor = C3DESDecryptor::NewLC(iKey->Des());
   277 			
   278 			encryptor = CModeCBCEncryptor::NewL(the3DESencryptor, iIV->Des());
   279 			CleanupStack::PushL(encryptor);
   280 			decryptor = CModeCBCDecryptor::NewL(the3DESdecryptor, iIV->Des());		
   281 			CleanupStack::Pop(3);
   282 		}
   283 		break;
   284 		case (EAESECB):
   285 		{
   286 			TTime startTime;
   287 			TTime endTime;
   288 			TTimeIntervalSeconds diff(0);
   289 			const TTimeIntervalSeconds iterationTime(iIterationTime);
   290 
   291 			iEncryptIterations = 0;
   292 			encryptor = CAESEncryptor::NewL(iKey->Des());
   293 			startTime.UniversalTime();
   294 			while (diff < iterationTime)
   295 				{
   296 				iEncryptIterations++;
   297 				encryptor->Reset();
   298 				endTime.UniversalTime();
   299 				endTime.SecondsFrom(startTime, diff);
   300 				}
   301 			endTime.UniversalTime();
   302 			iEncryptorCreateTime = endTime.MicroSecondsFrom(startTime);
   303 			delete encryptor;
   304 
   305 			diff = 0;
   306 			iDecryptIterations = 0;
   307 			decryptor = CAESDecryptor::NewL(iKey->Des());
   308 			startTime.UniversalTime();
   309 			while (diff < iterationTime)
   310 				{
   311 				decryptor->Reset();
   312 				iDecryptIterations++;
   313 				endTime.UniversalTime();
   314 				endTime.SecondsFrom(startTime, diff);
   315 				}
   316 			endTime.UniversalTime();
   317 			iDecryptorCreateTime = endTime.MicroSecondsFrom(startTime);
   318 			delete decryptor;
   319 			
   320 			encryptor = CAESEncryptor::NewLC(iKey->Des());
   321 			decryptor = CAESDecryptor::NewL(iKey->Des());
   322 			CleanupStack::Pop(encryptor);
   323 		}
   324 		break;	
   325 		case (ERC2ECB):
   326 		{
   327 			TTime startTime;
   328 			TTime endTime;
   329 			TTimeIntervalSeconds diff(0);
   330 			const TTimeIntervalSeconds iterationTime(iIterationTime);
   331 
   332 			iEncryptIterations = 0;
   333 			encryptor = CRC2Encryptor::NewL(iKey->Des(), iEffectiveKeyLen);
   334 			startTime.UniversalTime();	
   335 			while (diff < iterationTime)
   336 				{
   337 				iEncryptIterations++;
   338 				encryptor->Reset();
   339 				endTime.UniversalTime();
   340 				endTime.SecondsFrom(startTime, diff);
   341 				}
   342 			endTime.UniversalTime();
   343 			iEncryptorCreateTime = endTime.MicroSecondsFrom(startTime);
   344 			delete encryptor;
   345 			
   346 			diff = 0;
   347 			decryptor = CRC2Decryptor::NewL(iKey->Des(), iEffectiveKeyLen);
   348 			iDecryptIterations = 0;
   349 			startTime.UniversalTime();	
   350 			while (diff < iterationTime)
   351 				{
   352 				decryptor->Reset();
   353 				iDecryptIterations++;
   354 				endTime.UniversalTime();
   355 				endTime.SecondsFrom(startTime, diff);
   356 				}
   357 			endTime.UniversalTime();
   358 			iDecryptorCreateTime = endTime.MicroSecondsFrom(startTime);
   359 			delete decryptor;
   360 
   361 			encryptor = CRC2Encryptor::NewLC(iKey->Des(), iEffectiveKeyLen);
   362 			decryptor = CRC2Decryptor::NewL(iKey->Des(), iEffectiveKeyLen);
   363 			CleanupStack::Pop(encryptor);
   364 		}
   365 		break;
   366 		case (ERC2CBC):
   367 		{
   368 			CBlockTransformation* theRC2encryptor = NULL;
   369 			CBlockTransformation* theRC2decryptor = NULL;
   370 
   371 			theRC2encryptor = CRC2Encryptor::NewLC(iKey->Des(), iEffectiveKeyLen);
   372 			encryptor = CModeCBCEncryptor::NewL(theRC2encryptor, iIV->Des());
   373 
   374 			TTime startTime;
   375 			TTime endTime;
   376 			TTimeIntervalSeconds diff(0);
   377 			const TTimeIntervalSeconds iterationTime(iIterationTime);
   378 
   379 			iEncryptIterations = 0;
   380 			startTime.UniversalTime();
   381 			while (diff < iterationTime)
   382 				{
   383 				iEncryptIterations++;
   384 				encryptor->Reset();
   385 				endTime.UniversalTime();
   386 				endTime.SecondsFrom(startTime, diff);
   387 				}
   388 			endTime.UniversalTime();
   389 			iEncryptorCreateTime = endTime.MicroSecondsFrom(startTime);
   390 			CleanupStack::Pop(1);
   391 			delete encryptor;
   392 
   393 			diff = 0;
   394 			iDecryptIterations = 0;
   395 			theRC2decryptor = CRC2Decryptor::NewLC(iKey->Des(), iEffectiveKeyLen);
   396 			decryptor = CModeCBCDecryptor::NewL(theRC2decryptor, iIV->Des());		
   397 			startTime.UniversalTime();
   398 			while (diff < iterationTime)
   399 				{
   400 				decryptor->Reset();
   401 				iDecryptIterations++;
   402 				endTime.UniversalTime();
   403 				endTime.SecondsFrom(startTime, diff);
   404 				}
   405 			endTime.UniversalTime();
   406 			iDecryptorCreateTime = endTime.MicroSecondsFrom(startTime);
   407 			CleanupStack::Pop(1);
   408 			delete decryptor;
   409 
   410 			theRC2encryptor = CRC2Encryptor::NewLC(iKey->Des(), iEffectiveKeyLen);
   411 			theRC2decryptor = CRC2Decryptor::NewLC(iKey->Des(), iEffectiveKeyLen);
   412 			
   413 			encryptor = CModeCBCEncryptor::NewL(theRC2encryptor, iIV->Des());
   414 			CleanupStack::PushL(encryptor);
   415 			decryptor = CModeCBCDecryptor::NewL(theRC2decryptor, iIV->Des());		
   416 			CleanupStack::Pop(3);
   417 		}
   418 		break;
   419 		case (ERC4):
   420 		{
   421 			iEncryptor = CARC4::NewL(*iKey);
   422 			TTime startTime;
   423 			TTime endTime;
   424 			TTimeIntervalSeconds diff(0);
   425 			const TTimeIntervalSeconds iterationTime(iIterationTime);
   426 
   427 			iEncryptIterations = 0;
   428 			startTime.UniversalTime();	
   429 			while (diff < iterationTime)
   430 				{
   431 				iEncryptIterations++;
   432 				iEncryptor->Reset();
   433 				endTime.UniversalTime();
   434 				endTime.SecondsFrom(startTime, diff);
   435 				}
   436 			endTime.UniversalTime();
   437 			iEncryptorCreateTime = endTime.MicroSecondsFrom(startTime);
   438 
   439 			diff = 0;			
   440 			iDecryptIterations = 0;
   441 			iDecryptor = CARC4::NewL(*iKey);
   442 			startTime.UniversalTime();	
   443 			while (diff < iterationTime)
   444 				{
   445 				iDecryptor->Reset();
   446 				iDecryptIterations++;
   447 				endTime.UniversalTime();
   448 				endTime.SecondsFrom(startTime, diff);
   449 				}
   450 			endTime.UniversalTime();
   451 			iDecryptorCreateTime = endTime.MicroSecondsFrom(startTime);
   452 		}
   453 		break;
   454 		case (ECipherNull):
   455 		{
   456 			iEncryptor = CNullCipher::NewL();
   457 			TTime startTime;
   458 			TTime endTime;
   459 			TTimeIntervalSeconds diff(0);
   460 			const TTimeIntervalSeconds iterationTime(iIterationTime);
   461 
   462 			iEncryptIterations = 0;
   463 			startTime.UniversalTime();	
   464 			while (diff < iterationTime)
   465 				{
   466 				iEncryptIterations++;
   467 				iEncryptor->Reset();
   468 				endTime.UniversalTime();
   469 				endTime.SecondsFrom(startTime, diff);
   470 				}
   471 			endTime.UniversalTime();
   472 			iEncryptorCreateTime = endTime.MicroSecondsFrom(startTime);
   473 			
   474 			diff = 0;
   475 			iDecryptIterations = 0;
   476 			iDecryptor = CNullCipher::NewL();
   477 			startTime.UniversalTime();	
   478 			while (diff < iterationTime)
   479 				{
   480 				iDecryptor->Reset();
   481 				iDecryptIterations++;
   482 				endTime.UniversalTime();
   483 				endTime.SecondsFrom(startTime, diff);
   484 				}
   485 			endTime.UniversalTime();
   486 			iDecryptorCreateTime = endTime.MicroSecondsFrom(startTime);
   487 		}
   488 		break;
   489 			
   490 		default:
   491 		{
   492 			ASSERT(0);
   493 			User::Leave(KErrNotSupported);
   494 		}
   495 	}
   496 	
   497 	if( encryptor && decryptor )
   498 		{
   499 		CleanupStack::PushL(encryptor);
   500 		CleanupStack::PushL(decryptor);
   501 		
   502 		CPaddingSSLv3* ePadding = CPaddingSSLv3::NewLC(encryptor->BlockSize());
   503 		iEncryptor = CBufferedEncryptor::NewL(encryptor, ePadding);	
   504 		CleanupStack::Pop(ePadding);	
   505 		
   506 		CPaddingSSLv3* dPadding = CPaddingSSLv3::NewLC(decryptor->BlockSize());
   507 		iDecryptor = CBufferedDecryptor::NewL(decryptor, dPadding);
   508 		CleanupStack::Pop(dPadding);
   509 		CleanupStack::Pop(decryptor);
   510 		CleanupStack::Pop(encryptor);
   511 		}
   512 
   513 	// clear the default input and output fields and fill with random data
   514 	// since for performance testing we do not care about validating
   515 	// correct output
   516 	delete iInput;	
   517 	iInput = NULL;
   518 	iInput = HBufC8::NewMaxL(iRandDataSize);
   519 	TPtr8 tempPtr = iInput->Des();
   520 	TRandom::Random(tempPtr);	
   521 	TBuf<128> tempbuf;
   522 	//tempbuf.Format(KDataSize, (iInput->Length()));
   523 	iOut.writeString(tempbuf);	
   524 	delete iOutput;
   525 	iOutput = NULL;
   526 	iOutput = HBufC8::NewMaxL(iRandDataSize);
   527 	TPtr8 tempPtr2 = iOutput->Des();
   528 	TRandom::Random(tempPtr2);	
   529 		
   530 	iEResult = HBufC8::NewMaxL(iEncryptor->MaxOutputLength(iInput->Length()));
   531 	iDResult = HBufC8::NewMaxL(iDecryptor->MaxOutputLength(iEResult->Size()));
   532 #endif
   533 }
   534 
   535 void CPerformanceTest::DoPerformActionL()
   536 {
   537 	iResult = ETrue;
   538 #ifndef _FOO
   539 	TBuf<128> buf;
   540 	TReal rate = I64REAL(iEncryptorCreateTime.Int64()) / iEncryptIterations;
   541 	buf.Format(KPerfEncryptorCreate, rate, iEncryptIterations, iEncryptorCreateTime.Int64());
   542 	iOut.writeString(buf);
   543 
   544 	TTime startTime;
   545 	TTime endTime;
   546 	TTimeIntervalSeconds diff(0);
   547 	const TTimeIntervalSeconds iterationTime(iIterationTime);
   548 	
   549 	iEncryptIterations = 0;
   550 	startTime.UniversalTime();
   551 	while (diff < iterationTime)
   552 		{
   553 		TPtr8 iEResultTemp(iEResult->Des());
   554 		iEResultTemp.Zero();
   555 
   556 		iEncryptor->Process(*iInput, iEResultTemp);
   557 		iEncryptIterations++;
   558 		endTime.UniversalTime();
   559 		endTime.SecondsFrom(startTime, diff);
   560 		}
   561 	endTime.UniversalTime();
   562 
   563 	TTimeIntervalMicroSeconds time = endTime.MicroSecondsFrom(startTime);
   564 	rate = I64REAL(time.Int64()) / iEncryptIterations;
   565 	buf.Format(KPerfEFormat, rate, iEncryptIterations, time.Int64());
   566 	iOut.writeString(buf);
   567 
   568 	rate = (static_cast<TReal>(iEncryptIterations) * iInput->Size() * 1000 * 1000) / (I64REAL(time.Int64()) * 1024 * 1024);	// Throughput in MB/s
   569 	buf.FillZ();
   570 	buf.Zero();
   571 	buf.Format(KPerfThroughputAfterSetup, rate);
   572 	iOut.writeString(buf);
   573 
   574 	TInt64 totalEncryptTime = time.Int64();
   575 	totalEncryptTime+=iEncryptorCreateTime.Int64();
   576 	rate = I64REAL(totalEncryptTime) / iEncryptIterations;
   577 	buf.FillZ();
   578 	buf.Zero();
   579 	buf.Format(KTotalFormat, rate, iEncryptIterations, totalEncryptTime);
   580 	iOut.writeString(buf);
   581 	rate = (static_cast<TReal>(iEncryptIterations) * iInput->Size() * 1000 * 1000) / (I64REAL(totalEncryptTime) * 1024 * 1024);	// Throughput in MB/s
   582 	buf.FillZ();
   583 	buf.Zero();
   584 	buf.Format(KPerfThroughput, rate);
   585 	iOut.writeString(buf);
   586 
   587 //	Test decryption
   588 	rate = I64REAL(iDecryptorCreateTime.Int64()) / iDecryptIterations;
   589 	buf.Format(KPerfDecryptorCreate, rate, iDecryptIterations, iDecryptorCreateTime.Int64());
   590 	iOut.writeString(buf);
   591 	
   592 	diff = 0;
   593 	iDecryptIterations = 0;
   594 	startTime.UniversalTime();	
   595 	while (diff < iterationTime)
   596 		{
   597 		TPtr8 iDResultTemp(iDResult->Des());
   598 		iDResultTemp.Zero();
   599 		iDecryptor->Process(*iOutput, iDResultTemp);
   600 		iDecryptIterations++;
   601 		endTime.UniversalTime();
   602 		endTime.SecondsFrom(startTime, diff);
   603 		}
   604 	endTime.UniversalTime();
   605 
   606 	time = endTime.MicroSecondsFrom(startTime);	
   607 	rate = I64REAL(time.Int64()) / iDecryptIterations;
   608 	buf.FillZ();
   609 	buf.Zero();
   610 	buf.Format(KPerfDFormat, rate, iDecryptIterations, time.Int64());
   611 	iOut.writeString(buf);
   612 
   613 	rate = (static_cast<TReal>(iDecryptIterations) * iInput->Size() * 1000 * 1000) / (I64REAL(time.Int64()) * 1024 * 1024);	// Throughput in MB/s
   614 	buf.FillZ();
   615 	buf.Zero();
   616 	buf.Format(KPerfThroughputAfterSetup, rate);
   617 	iOut.writeString(buf);
   618 
   619 	TInt64 totalDecryptTime = time.Int64();
   620 	totalDecryptTime+=iDecryptorCreateTime.Int64();
   621 	rate = I64REAL(totalDecryptTime) / iDecryptIterations;
   622 	buf.FillZ();
   623 	buf.Zero();
   624 	buf.Format(KTotalFormat, rate, iDecryptIterations, totalDecryptTime);
   625 	iOut.writeString(buf);
   626 	
   627 	rate = (static_cast<TReal>(iDecryptIterations) * iInput->Size() * 1000 * 1000) / (I64REAL(totalDecryptTime) * 1024 * 1024);	// Throughput in MB/s
   628 	buf.FillZ();
   629 	buf.Zero();
   630 	buf.Format(KPerfThroughput, rate);
   631 	iOut.writeString(buf);
   632 	
   633 #endif
   634 }
   635