os/security/crypto/weakcrypto/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 _DEBUG
    24 _LIT(KPerfEFormat, "\tPerformance (encryption) : %f us/iteration (%i iterations in %iL us)\r\n");
    25 _LIT(KPerfDFormat, "\tPerformance (decryption) : %f us/iteration (%i iterations in %iL us)\r\n");
    26 _LIT(KTotalFormat, "\tPerformance (total) : %f us/iteration (%i iterations in %iL us)\r\n");
    27 _LIT(KPerfThroughput, "\tThroughput (total): %f MB/s\r\n");
    28 _LIT(KPerfThroughputAfterSetup, "\tThroughput after setup: %f MB/s\r\n");
    29 _LIT(KPerfEncryptorCreate, "\tPerformance (encryptor create) : %f us/iteration (%i iterations in %iL us)\r\n");
    30 _LIT(KPerfDecryptorCreate, "\tPerformance (decryptor create) : %f us/iteration (%i iterations in %iL us)\r\n");
    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 _DEBUG
    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::NewLC(iKey->Des());
   234 			encryptor = CModeCBCEncryptor::NewL(the3DESencryptor, iIV->Des());
   235 
   236 			TTime startTime;
   237 			TTime endTime;
   238 			TTimeIntervalSeconds diff(0);
   239 			const TTimeIntervalSeconds iterationTime(iIterationTime);
   240 
   241 			iEncryptIterations = 0;
   242 			startTime.UniversalTime();	
   243 			while (diff < iterationTime)
   244 				{
   245 				iEncryptIterations++;
   246 				encryptor->Reset();
   247 				endTime.UniversalTime();
   248 				endTime.SecondsFrom(startTime, diff);
   249 				}
   250 			endTime.UniversalTime();
   251 			iEncryptorCreateTime = endTime.MicroSecondsFrom(startTime);
   252 
   253 			CleanupStack::Pop(1);
   254 			delete encryptor;				
   255 
   256 			the3DESdecryptor = C3DESDecryptor::NewLC(iKey->Des());
   257 			decryptor = CModeCBCDecryptor::NewL(the3DESdecryptor, iIV->Des());		
   258 
   259 			diff = 0;
   260 			iDecryptIterations = 0;
   261 			startTime.UniversalTime();	
   262 			while (diff < iterationTime)
   263 				{
   264 				decryptor->Reset();
   265 				iDecryptIterations++;
   266 				endTime.UniversalTime();
   267 				endTime.SecondsFrom(startTime, diff);
   268 				}
   269 			endTime.UniversalTime();
   270 			iDecryptorCreateTime = endTime.MicroSecondsFrom(startTime);
   271 			CleanupStack::Pop(1);
   272 			delete decryptor;
   273 
   274 			the3DESencryptor = C3DESEncryptor::NewLC(iKey->Des());
   275 			the3DESdecryptor = C3DESDecryptor::NewLC(iKey->Des());
   276 			
   277 			encryptor = CModeCBCEncryptor::NewL(the3DESencryptor, iIV->Des());
   278 			CleanupStack::PushL(encryptor);
   279 			decryptor = CModeCBCDecryptor::NewL(the3DESdecryptor, iIV->Des());		
   280 			CleanupStack::Pop(3);
   281 		}
   282 		break;
   283 		case (EAESECB):
   284 		{
   285 			TTime startTime;
   286 			TTime endTime;
   287 			TTimeIntervalSeconds diff(0);
   288 			const TTimeIntervalSeconds iterationTime(iIterationTime);
   289 
   290 			iEncryptIterations = 0;
   291 			encryptor = CAESEncryptor::NewL(iKey->Des());
   292 			startTime.UniversalTime();
   293 			while (diff < iterationTime)
   294 				{
   295 				iEncryptIterations++;
   296 				encryptor->Reset();
   297 				endTime.UniversalTime();
   298 				endTime.SecondsFrom(startTime, diff);
   299 				}
   300 			endTime.UniversalTime();
   301 			iEncryptorCreateTime = endTime.MicroSecondsFrom(startTime);
   302 			delete encryptor;
   303 
   304 			diff = 0;
   305 			iDecryptIterations = 0;
   306 			decryptor = CAESDecryptor::NewL(iKey->Des());
   307 			startTime.UniversalTime();
   308 			while (diff < iterationTime)
   309 				{
   310 				decryptor->Reset();
   311 				iDecryptIterations++;
   312 				endTime.UniversalTime();
   313 				endTime.SecondsFrom(startTime, diff);
   314 				}
   315 			endTime.UniversalTime();
   316 			iDecryptorCreateTime = endTime.MicroSecondsFrom(startTime);
   317 			delete decryptor;
   318 			
   319 			encryptor = CAESEncryptor::NewLC(iKey->Des());
   320 			decryptor = CAESDecryptor::NewL(iKey->Des());
   321 			CleanupStack::Pop(encryptor);
   322 		}
   323 		break;	
   324 		case (ERC2ECB):
   325 		{
   326 			TTime startTime;
   327 			TTime endTime;
   328 			TTimeIntervalSeconds diff(0);
   329 			const TTimeIntervalSeconds iterationTime(iIterationTime);
   330 
   331 			iEncryptIterations = 0;
   332 			encryptor = CRC2Encryptor::NewL(iKey->Des(), iEffectiveKeyLen);
   333 			startTime.UniversalTime();	
   334 			while (diff < iterationTime)
   335 				{
   336 				iEncryptIterations++;
   337 				encryptor->Reset();
   338 				endTime.UniversalTime();
   339 				endTime.SecondsFrom(startTime, diff);
   340 				}
   341 			endTime.UniversalTime();
   342 			iEncryptorCreateTime = endTime.MicroSecondsFrom(startTime);
   343 			delete encryptor;
   344 			
   345 			diff = 0;
   346 			decryptor = CRC2Decryptor::NewL(iKey->Des(), iEffectiveKeyLen);
   347 			iDecryptIterations = 0;
   348 			startTime.UniversalTime();	
   349 			while (diff < iterationTime)
   350 				{
   351 				decryptor->Reset();
   352 				iDecryptIterations++;
   353 				endTime.UniversalTime();
   354 				endTime.SecondsFrom(startTime, diff);
   355 				}
   356 			endTime.UniversalTime();
   357 			iDecryptorCreateTime = endTime.MicroSecondsFrom(startTime);
   358 			delete decryptor;
   359 
   360 			encryptor = CRC2Encryptor::NewLC(iKey->Des(), iEffectiveKeyLen);
   361 			decryptor = CRC2Decryptor::NewL(iKey->Des(), iEffectiveKeyLen);
   362 			CleanupStack::Pop(encryptor);
   363 		}
   364 		break;
   365 		case (ERC2CBC):
   366 		{
   367 			CBlockTransformation* theRC2encryptor = NULL;
   368 			CBlockTransformation* theRC2decryptor = NULL;
   369 
   370 			theRC2encryptor = CRC2Encryptor::NewLC(iKey->Des(), iEffectiveKeyLen);
   371 			encryptor = CModeCBCEncryptor::NewL(theRC2encryptor, iIV->Des());
   372 
   373 			TTime startTime;
   374 			TTime endTime;
   375 			TTimeIntervalSeconds diff(0);
   376 			const TTimeIntervalSeconds iterationTime(iIterationTime);
   377 
   378 			iEncryptIterations = 0;
   379 			startTime.UniversalTime();
   380 			while (diff < iterationTime)
   381 				{
   382 				iEncryptIterations++;
   383 				encryptor->Reset();
   384 				endTime.UniversalTime();
   385 				endTime.SecondsFrom(startTime, diff);
   386 				}
   387 			endTime.UniversalTime();
   388 			iEncryptorCreateTime = endTime.MicroSecondsFrom(startTime);
   389 			CleanupStack::Pop(1);
   390 			delete encryptor;
   391 
   392 			diff = 0;
   393 			iDecryptIterations = 0;
   394 			theRC2decryptor = CRC2Decryptor::NewLC(iKey->Des(), iEffectiveKeyLen);
   395 			decryptor = CModeCBCDecryptor::NewL(theRC2decryptor, iIV->Des());		
   396 			startTime.UniversalTime();
   397 			while (diff < iterationTime)
   398 				{
   399 				decryptor->Reset();
   400 				iDecryptIterations++;
   401 				endTime.UniversalTime();
   402 				endTime.SecondsFrom(startTime, diff);
   403 				}
   404 			endTime.UniversalTime();
   405 			iDecryptorCreateTime = endTime.MicroSecondsFrom(startTime);
   406 			CleanupStack::Pop(1);
   407 			delete decryptor;
   408 
   409 			theRC2encryptor = CRC2Encryptor::NewLC(iKey->Des(), iEffectiveKeyLen);
   410 			theRC2decryptor = CRC2Decryptor::NewLC(iKey->Des(), iEffectiveKeyLen);
   411 			
   412 			encryptor = CModeCBCEncryptor::NewL(theRC2encryptor, iIV->Des());
   413 			CleanupStack::PushL(encryptor);
   414 			decryptor = CModeCBCDecryptor::NewL(theRC2decryptor, iIV->Des());		
   415 			CleanupStack::Pop(3);
   416 		}
   417 		break;
   418 		case (ERC4):
   419 		{
   420 			iEncryptor = CARC4::NewL(*iKey);
   421 			TTime startTime;
   422 			TTime endTime;
   423 			TTimeIntervalSeconds diff(0);
   424 			const TTimeIntervalSeconds iterationTime(iIterationTime);
   425 
   426 			iEncryptIterations = 0;
   427 			startTime.UniversalTime();	
   428 			while (diff < iterationTime)
   429 				{
   430 				iEncryptIterations++;
   431 				iEncryptor->Reset();
   432 				endTime.UniversalTime();
   433 				endTime.SecondsFrom(startTime, diff);
   434 				}
   435 			endTime.UniversalTime();
   436 			iEncryptorCreateTime = endTime.MicroSecondsFrom(startTime);
   437 
   438 			diff = 0;			
   439 			iDecryptIterations = 0;
   440 			iDecryptor = CARC4::NewL(*iKey);
   441 			startTime.UniversalTime();	
   442 			while (diff < iterationTime)
   443 				{
   444 				iDecryptor->Reset();
   445 				iDecryptIterations++;
   446 				endTime.UniversalTime();
   447 				endTime.SecondsFrom(startTime, diff);
   448 				}
   449 			endTime.UniversalTime();
   450 			iDecryptorCreateTime = endTime.MicroSecondsFrom(startTime);
   451 		}
   452 		break;
   453 		case (ECipherNull):
   454 		{
   455 			iEncryptor = CNullCipher::NewL();
   456 			TTime startTime;
   457 			TTime endTime;
   458 			TTimeIntervalSeconds diff(0);
   459 			const TTimeIntervalSeconds iterationTime(iIterationTime);
   460 
   461 			iEncryptIterations = 0;
   462 			startTime.UniversalTime();	
   463 			while (diff < iterationTime)
   464 				{
   465 				iEncryptIterations++;
   466 				iEncryptor->Reset();
   467 				endTime.UniversalTime();
   468 				endTime.SecondsFrom(startTime, diff);
   469 				}
   470 			endTime.UniversalTime();
   471 			iEncryptorCreateTime = endTime.MicroSecondsFrom(startTime);
   472 			
   473 			diff = 0;
   474 			iDecryptIterations = 0;
   475 			iDecryptor = CNullCipher::NewL();
   476 			startTime.UniversalTime();	
   477 			while (diff < iterationTime)
   478 				{
   479 				iDecryptor->Reset();
   480 				iDecryptIterations++;
   481 				endTime.UniversalTime();
   482 				endTime.SecondsFrom(startTime, diff);
   483 				}
   484 			endTime.UniversalTime();
   485 			iDecryptorCreateTime = endTime.MicroSecondsFrom(startTime);
   486 		}
   487 		break;
   488 			
   489 		default:
   490 		{
   491 			ASSERT(0);
   492 			User::Leave(KErrNotSupported);
   493 		}
   494 	}
   495 	
   496 	if( encryptor && decryptor )
   497 		{
   498 		CleanupStack::PushL(encryptor);
   499 		CleanupStack::PushL(decryptor);
   500 		
   501 		CPaddingSSLv3* ePadding = CPaddingSSLv3::NewLC(encryptor->BlockSize());
   502 		iEncryptor = CBufferedEncryptor::NewL(encryptor, ePadding);	
   503 		CleanupStack::Pop(ePadding);	
   504 		
   505 		CPaddingSSLv3* dPadding = CPaddingSSLv3::NewLC(decryptor->BlockSize());
   506 		iDecryptor = CBufferedDecryptor::NewL(decryptor, dPadding);
   507 		CleanupStack::Pop(dPadding);
   508 		CleanupStack::Pop(decryptor);
   509 		CleanupStack::Pop(encryptor);
   510 		}
   511 
   512 	// clear the default input and output fields and fill with random data
   513 	// since for performance testing we do not care about validating
   514 	// correct output
   515 	delete iInput;	
   516 	iInput = NULL;
   517 	iInput = HBufC8::NewMaxL(iRandDataSize);
   518 	TPtr8 tempPtr = iInput->Des();
   519 	TRandom::Random(tempPtr);	
   520 	TBuf<128> tempbuf;
   521 	tempbuf.Format(KDataSize, (iInput->Length()));
   522 	iOut.writeString(tempbuf);	
   523 	delete iOutput;
   524 	iOutput = NULL;
   525 	iOutput = HBufC8::NewMaxL(iRandDataSize);
   526 	TPtr8 tempPtr2 = iOutput->Des();
   527 	TRandom::Random(tempPtr2);	
   528 		
   529 	iEResult = HBufC8::NewMaxL(iEncryptor->MaxOutputLength(iInput->Length()));
   530 	iDResult = HBufC8::NewMaxL(iDecryptor->MaxOutputLength(iEResult->Size()));
   531 #endif
   532 }
   533 
   534 void CPerformanceTest::DoPerformActionL()
   535 {
   536 	iResult = ETrue;
   537 #ifndef _DEBUG
   538 	TBuf<128> buf;
   539 	TReal rate = I64REAL(iEncryptorCreateTime.Int64()) / iEncryptIterations;
   540 	buf.Format(KPerfEncryptorCreate, rate, iEncryptIterations, iEncryptorCreateTime.Int64());
   541 	iOut.writeString(buf);
   542 
   543 	TTime startTime;
   544 	TTime endTime;
   545 	TTimeIntervalSeconds diff(0);
   546 	const TTimeIntervalSeconds iterationTime(iIterationTime);
   547 	
   548 	iEncryptIterations = 0;
   549 	startTime.UniversalTime();
   550 	while (diff < iterationTime)
   551 		{
   552 		TPtr8 iEResultTemp(iEResult->Des());
   553 		iEResultTemp.Zero();
   554 
   555 		iEncryptor->Process(*iInput, iEResultTemp);
   556 		iEncryptIterations++;
   557 		endTime.UniversalTime();
   558 		endTime.SecondsFrom(startTime, diff);
   559 		}
   560 	endTime.UniversalTime();
   561 
   562 	TTimeIntervalMicroSeconds time = endTime.MicroSecondsFrom(startTime);
   563 	rate = I64REAL(time.Int64()) / iEncryptIterations;
   564 	buf.Format(KPerfEFormat, rate, iEncryptIterations, time.Int64());
   565 	iOut.writeString(buf);
   566 
   567 	rate = (static_cast<TReal>(iEncryptIterations) * iInput->Size() * 1000 * 1000) / (I64REAL(time.Int64()) * 1024 * 1024);	// Throughput in MB/s
   568 	buf.FillZ();
   569 	buf.Zero();
   570 	buf.Format(KPerfThroughputAfterSetup, rate);
   571 	iOut.writeString(buf);
   572 
   573 	TInt64 totalEncryptTime = time.Int64();
   574 	totalEncryptTime+=iEncryptorCreateTime.Int64();
   575 	rate = I64REAL(totalEncryptTime) / iEncryptIterations;
   576 	buf.FillZ();
   577 	buf.Zero();
   578 	buf.Format(KTotalFormat, rate, iEncryptIterations, totalEncryptTime);
   579 	iOut.writeString(buf);
   580 
   581 	rate = (static_cast<TReal>(iEncryptIterations) * iInput->Size() * 1000 * 1000) / (I64REAL(totalEncryptTime) * 1024 * 1024);	// Throughput in MB/s
   582 	buf.Zero();
   583 	buf.Format(KPerfThroughput, rate);
   584 	iOut.writeString(buf);
   585 
   586 //	Test decryption
   587 	rate = I64REAL(iDecryptorCreateTime.Int64()) / iDecryptIterations;
   588 	buf.Format(KPerfDecryptorCreate, rate, iDecryptIterations, iDecryptorCreateTime.Int64());
   589 	iOut.writeString(buf);
   590 	
   591 	diff = 0;
   592 	iDecryptIterations = 0;
   593 	startTime.UniversalTime();	
   594 	while (diff < iterationTime)
   595 		{
   596 		TPtr8 iDResultTemp(iDResult->Des());
   597 		iDResultTemp.Zero();
   598 		iDecryptor->Process(*iOutput, iDResultTemp);
   599 		iDecryptIterations++;
   600 		endTime.UniversalTime();
   601 		endTime.SecondsFrom(startTime, diff);
   602 		}
   603 	endTime.UniversalTime();
   604 
   605 	time = endTime.MicroSecondsFrom(startTime);	
   606 	rate = I64REAL(time.Int64()) / iDecryptIterations;
   607 	buf.FillZ();
   608 	buf.Zero();
   609 	buf.Format(KPerfDFormat, rate, iDecryptIterations, time.Int64());
   610 	iOut.writeString(buf);
   611 
   612 	rate = (static_cast<TReal>(iDecryptIterations) * iInput->Size() * 1000 * 1000) / (I64REAL(time.Int64()) * 1024 * 1024);	// Throughput in MB/s
   613 	buf.Zero();
   614 	buf.Format(KPerfThroughputAfterSetup, rate);
   615 	iOut.writeString(buf);
   616 
   617 	TInt64 totalDecryptTime = time.Int64();
   618 	totalDecryptTime+=iDecryptorCreateTime.Int64();
   619 	rate = I64REAL(totalDecryptTime) / iDecryptIterations;
   620 	buf.FillZ();
   621 	buf.Zero();
   622 	buf.Format(KTotalFormat, rate, iDecryptIterations, totalDecryptTime);
   623 	iOut.writeString(buf);
   624 	
   625 	rate = (static_cast<TReal>(iDecryptIterations) * iInput->Size() * 1000 * 1000) / (I64REAL(totalDecryptTime) * 1024 * 1024);	// Throughput in MB/s
   626 	buf.Zero();
   627 	buf.Format(KPerfThroughput, rate);
   628 	iOut.writeString(buf);
   629 	
   630 #endif
   631 }
   632