networksecurity/tlsprovider/Test/src/TlsProviderStep6.cpp
changeset 0 af10295192d8
equal deleted inserted replaced
-1:000000000000 0:af10295192d8
       
     1 // Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #include "TlsProvTestStep.h"
       
    17 #include <test/testexecutelog.h>
       
    18 #include <hash.h>
       
    19 
       
    20 extern TInt ReadTestDataL( CTlsCryptoAttributes*& aTlsCryptoAttributes, HBufC8*& aSrvCert,
       
    21 				   CTlsProvStep*& aTestStepPtr);
       
    22 
       
    23 extern TInt ReadDataFromFiles( CTlsCryptoAttributes* aTlsCryptoAttributes, 
       
    24 						HBufC8*& aSrvCert);
       
    25 
       
    26 
       
    27 
       
    28 /*
       
    29 Mode:RC4 with weak encryption
       
    30 Protocol: TLS
       
    31 Tests covered:
       
    32 	1.Generation of weak keys are also being tested
       
    33 	2.MAC computations
       
    34 	3.Encryption
       
    35 	4.Decryption
       
    36 */
       
    37 TVerdict CTlsProvTestActive::TestProvider_6_0L( CTlsProvStep* aStep )
       
    38 	{
       
    39 
       
    40 	
       
    41 	CTLSProvider* PtrProvider = 0;
       
    42 	CTLSSession* PtrSession;
       
    43 	CTlsCryptoAttributes* PtrTlsCryptoAttributes;
       
    44 
       
    45 	INFO_PRINTF1(_L("1"));
       
    46 	InitProviderL(PtrProvider,PtrSession,PtrTlsCryptoAttributes,/*IsTls?*/ETrue,/*IsExport?*/ETrue,aStep);
       
    47 
       
    48 	//Want client authentication?
       
    49 	PtrTlsCryptoAttributes->iClientAuthenticate = EFalse;
       
    50 
       
    51 	//Any dialogs
       
    52 	PtrTlsCryptoAttributes->iDialogNonAttendedMode = ETrue;
       
    53 
       
    54 	//Required ciphersuite
       
    55 	TTLSCipherSuite	 CipherSuite;
       
    56 	CipherSuite.iHiByte = 0;
       
    57 	CipherSuite.iLoByte = 0x19;
       
    58 	PtrTlsCryptoAttributes->iCurrentCipherSuite = CipherSuite;
       
    59 	PtrTlsCryptoAttributes->iNegotiatedProtocol = KTLS1_0;	
       
    60 
       
    61 	
       
    62 	//dummy flag untuill the token panic is resolved
       
    63 	RFs fs;
       
    64 	RFile file;
       
    65 	fs.Connect();
       
    66 
       
    67 	TBuf8<800> boom;
       
    68 	file.Open(fs, 
       
    69 				aStep->iServerCertChain,  
       
    70 	 			EFileShareAny|EFileRead);
       
    71 	file.Read(boom);
       
    72 	
       
    73 	iStatus = KRequestPending;
       
    74 	CX509Certificate* serverCert;
       
    75 	HBufC8* servrc = boom.AllocL();
       
    76 	PtrProvider->VerifyServerCertificate(servrc->Des(), serverCert, iStatus);
       
    77 	SetActive();
       
    78 	CActiveScheduler::Start();
       
    79 	INFO_PRINTF1(_L("2"));
       
    80 
       
    81 	CipherSuite.iHiByte = 0;
       
    82 	CipherSuite.iLoByte = 0x19;
       
    83 	PtrTlsCryptoAttributes->iCurrentCipherSuite = CipherSuite;
       
    84 
       
    85 	iStatus = KRequestPending;		
       
    86 	PtrProvider->CreateL(PtrSession,iStatus);
       
    87 	SetActive();
       
    88 	CActiveScheduler::Start();
       
    89 	INFO_PRINTF1(_L("3"));
       
    90 
       
    91 
       
    92 	CipherSuite.iHiByte = 0;
       
    93 	CipherSuite.iLoByte = 3;
       
    94 	PtrTlsCryptoAttributes->iCurrentCipherSuite = CipherSuite;
       
    95 	
       
    96 	iStatus = KRequestPending;
       
    97 	HBufC8* clntkeyexchang;
       
    98 	if(!PtrSession)
       
    99    {
       
   100    	iLogInfo.Copy(_L("	6.1:  !PtrSession"));
       
   101 		return EFail;
       
   102    }
       
   103 
       
   104 
       
   105 	PtrSession->ClientKeyExchange(clntkeyexchang,iStatus);
       
   106 	SetActive();
       
   107 	CActiveScheduler::Start();
       
   108 	INFO_PRINTF1(_L("4"));
       
   109 
       
   110 	if(PtrSession)
       
   111    {
       
   112    	iLogInfo.Copy(_L("	6.1:  EncryptAndDecryptL"));
       
   113 		TVerdict ver = (EncryptAndDecryptL(PtrSession,aStep));
       
   114       delete PtrProvider;
       
   115       delete PtrSession;
       
   116       return ver;
       
   117    }
       
   118 	else
       
   119    {
       
   120       delete PtrProvider;
       
   121       delete PtrSession;
       
   122 		return EFail;
       
   123    }
       
   124 
       
   125 	}
       
   126 
       
   127 /*
       
   128 Mode:RC4 with weak encryption
       
   129 Protocol: SSL
       
   130 Tests covered:
       
   131 	1.Generation of weak keys are also being tested
       
   132 	2.MAC computations
       
   133 	3.Encryption
       
   134 	4.Decryption
       
   135 */
       
   136 
       
   137 TVerdict CTlsProvTestActive::TestProvider_6_1L( CTlsProvStep* aStep )
       
   138 	{
       
   139 	CTLSProvider* PtrProvider = 0;
       
   140 	CTLSSession* PtrSession;
       
   141 	CTlsCryptoAttributes* PtrTlsCryptoAttributes;
       
   142 
       
   143 	InitProviderL(PtrProvider,PtrSession,PtrTlsCryptoAttributes,/*IsTls?*/EFalse,/*IsExport?*/ETrue,aStep);
       
   144 
       
   145 	//Want client authentication?
       
   146 	PtrTlsCryptoAttributes->iClientAuthenticate = EFalse;
       
   147 
       
   148 	//Any dialogs
       
   149 	PtrTlsCryptoAttributes->iDialogNonAttendedMode = ETrue;
       
   150 
       
   151 	//Required ciphersuite
       
   152 	TTLSCipherSuite	 CipherSuite;
       
   153 	CipherSuite.iHiByte = 0;
       
   154 	CipherSuite.iLoByte = 3;
       
   155 	PtrTlsCryptoAttributes->iCurrentCipherSuite = CipherSuite;
       
   156 	PtrTlsCryptoAttributes->iNegotiatedProtocol = KSSL3_0;	
       
   157 
       
   158 	
       
   159 	//Init start
       
   160 	RFs fs;
       
   161 	RFile file;
       
   162 	fs.Connect();	
       
   163 	TBuf8<1000> boom;
       
   164 	file.Open(fs, 
       
   165 				aStep->iServerCertChain,  
       
   166 	 			EFileShareAny|EFileRead);
       
   167 	file.Read(boom);
       
   168 	
       
   169 	iStatus = KRequestPending;
       
   170 	CX509Certificate* serverCert;
       
   171 	HBufC8* servrc = boom.AllocL();
       
   172 	PtrProvider->VerifyServerCertificate(servrc->Des(), serverCert, iStatus);
       
   173 	SetActive();
       
   174 	CActiveScheduler::Start();
       
   175 
       
   176 	CipherSuite.iHiByte = 0;
       
   177 	CipherSuite.iLoByte = 0x19;
       
   178 	PtrTlsCryptoAttributes->iCurrentCipherSuite = CipherSuite;
       
   179 	//Init end
       
   180 
       
   181 
       
   182 
       
   183 
       
   184 	iStatus = KRequestPending;	
       
   185 	PtrProvider->CreateL(PtrSession,iStatus);
       
   186 	SetActive();
       
   187 	CActiveScheduler::Start();
       
   188 
       
   189 
       
   190 
       
   191 	//Init start
       
   192 	CipherSuite.iHiByte = 0;
       
   193 	CipherSuite.iLoByte = 3;
       
   194 	PtrTlsCryptoAttributes->iCurrentCipherSuite = CipherSuite;	
       
   195 	iStatus = KRequestPending;
       
   196 	HBufC8* clntkeyexchang;
       
   197 	if(!PtrSession)
       
   198    {
       
   199    	iLogInfo.Copy(_L("	6.1:  !PtrSession"));
       
   200 		return EFail;
       
   201    }
       
   202 	PtrSession->ClientKeyExchange(clntkeyexchang,iStatus);
       
   203 	SetActive();
       
   204 	CActiveScheduler::Start();
       
   205 	//Init end
       
   206 
       
   207 	TInt errr = iStatus.Int();
       
   208 
       
   209 	if(PtrSession && !errr)
       
   210    {
       
   211    	iLogInfo.Copy(_L("	6.1:  EncryptAndDecryptL"));
       
   212 		TVerdict ver = (EncryptAndDecryptL(PtrSession,aStep));
       
   213       delete PtrProvider;
       
   214       delete PtrSession;
       
   215       return ver;
       
   216    }
       
   217 	else
       
   218    {
       
   219    	iLogInfo.Format(_L("	6.1:  Fail %d"), errr);
       
   220       delete PtrProvider;
       
   221       delete PtrSession;
       
   222 		return EFail;
       
   223    }
       
   224 	}
       
   225 
       
   226 
       
   227 /*
       
   228 Mode:DES with strong encryption
       
   229 Protocol: TLS
       
   230 Tests covered:
       
   231 	1.MAC computations
       
   232 	2.Encryption
       
   233 	3.Decryption
       
   234 */
       
   235 TVerdict CTlsProvTestActive::TestProvider_6_2L( CTlsProvStep* aStep )
       
   236 	{
       
   237 	CTLSProvider* PtrProvider = 0;
       
   238 	CTLSSession* PtrSession;
       
   239 	CTlsCryptoAttributes* PtrTlsCryptoAttributes;
       
   240 
       
   241 	INFO_PRINTF1(_L("1"));
       
   242 	iLogInfo.Copy(_L("	6.2:  InitProviderL"));
       
   243 	InitProviderL(PtrProvider,PtrSession,PtrTlsCryptoAttributes,/*IsTls?*/ETrue,/*IsExport?*/EFalse,aStep);
       
   244 
       
   245 	//Want client authentication?
       
   246 	PtrTlsCryptoAttributes->iClientAuthenticate = EFalse;
       
   247 
       
   248 	//Any dialogs
       
   249 	PtrTlsCryptoAttributes->iDialogNonAttendedMode = ETrue;
       
   250 
       
   251 	//Required ciphersuite
       
   252 	TTLSCipherSuite	 CipherSuite;
       
   253 	CipherSuite.iHiByte = 0;
       
   254 	CipherSuite.iLoByte = 9;
       
   255 	PtrTlsCryptoAttributes->iCurrentCipherSuite = CipherSuite;
       
   256 	PtrTlsCryptoAttributes->iNegotiatedProtocol = KTLS1_0;	
       
   257 
       
   258 	
       
   259 	//Init start
       
   260 	RFs fs;
       
   261 	RFile file;
       
   262 	fs.Connect();	
       
   263 	TBuf8<1000> boom;
       
   264 	file.Open(fs, 
       
   265 				aStep->iServerCertChain,  
       
   266 	 			EFileShareAny|EFileRead);
       
   267 	file.Read(boom);
       
   268 	
       
   269 	iStatus = KRequestPending;
       
   270 	CX509Certificate* serverCert;
       
   271 	HBufC8* servrc = boom.AllocL();
       
   272 	PtrProvider->VerifyServerCertificate(servrc->Des(), serverCert, iStatus);
       
   273 	SetActive();
       
   274 	CActiveScheduler::Start();
       
   275 	iLogInfo.Copy(_L("	6.2:  IPtrProvider->VerifyServerCertificate"));
       
   276 	INFO_PRINTF1(_L("2"));
       
   277 
       
   278 	CipherSuite.iHiByte = 0;
       
   279 	CipherSuite.iLoByte = 0x19;
       
   280 	PtrTlsCryptoAttributes->iCurrentCipherSuite = CipherSuite;
       
   281 	//Init end
       
   282 
       
   283 
       
   284 
       
   285 	iStatus = KRequestPending;	
       
   286 	PtrProvider->CreateL(PtrSession,iStatus);
       
   287 	SetActive();
       
   288 	CActiveScheduler::Start();
       
   289 	INFO_PRINTF1(_L("3"));
       
   290 
       
   291 	iLogInfo.Copy(_L("	6.2:  IPtrProvider->CreateL"));
       
   292 
       
   293 	//Init start
       
   294 	CipherSuite.iHiByte = 0;
       
   295 	CipherSuite.iLoByte = 9;
       
   296 	PtrTlsCryptoAttributes->iCurrentCipherSuite = CipherSuite;	
       
   297 	iStatus = KRequestPending;
       
   298 	HBufC8* clntkeyexchang;
       
   299 	if(!PtrSession)
       
   300    {
       
   301 		iLogInfo.Copy(_L("	6.2:  !PtrSession"));
       
   302       delete PtrProvider;
       
   303 		return EFail;
       
   304    }
       
   305 	PtrSession->ClientKeyExchange(clntkeyexchang,iStatus);
       
   306 	SetActive();
       
   307 	CActiveScheduler::Start();
       
   308 	//Init end
       
   309 	INFO_PRINTF1(_L("4"));
       
   310 
       
   311 
       
   312 	if(PtrSession)
       
   313    {
       
   314    	INFO_PRINTF1(_L("5"));
       
   315    	iLogInfo.Copy(_L("	6.2:  EncryptAndDecryptL"));
       
   316 		TVerdict ver = (EncryptAndDecryptL(PtrSession,aStep));
       
   317       delete PtrProvider;
       
   318       delete PtrSession;
       
   319       return ver;
       
   320    }
       
   321 	else
       
   322    {
       
   323       delete PtrProvider;
       
   324 		return EFail;
       
   325    }
       
   326 
       
   327 	}
       
   328 
       
   329 
       
   330 /*
       
   331 Mode:DES with strong encryption
       
   332 Protocol: SSL
       
   333 Tests covered:
       
   334 	1.MAC computations
       
   335 	2.Encryption
       
   336 	3.Decryption
       
   337 */
       
   338 TVerdict CTlsProvTestActive::TestProvider_6_3L( CTlsProvStep* aStep )
       
   339 	{
       
   340 	CTLSProvider* PtrProvider = 0;
       
   341 	CTLSSession* PtrSession;
       
   342 	CTlsCryptoAttributes* PtrTlsCryptoAttributes;
       
   343 
       
   344 	INFO_PRINTF1(_L("1"));
       
   345 	iLogInfo.Copy(_L("	6.3:  InitProviderL"));
       
   346 	InitProviderL(PtrProvider,PtrSession,PtrTlsCryptoAttributes,/*IsTls?*/EFalse,/*IsExport?*/EFalse,aStep);
       
   347 
       
   348 	//Want client authentication?
       
   349 	PtrTlsCryptoAttributes->iClientAuthenticate = EFalse;
       
   350 
       
   351 	//Any dialogs
       
   352 	PtrTlsCryptoAttributes->iDialogNonAttendedMode = ETrue;
       
   353 
       
   354 	//Required ciphersuite
       
   355 	TTLSCipherSuite	 CipherSuite;
       
   356 	CipherSuite.iHiByte = 0;
       
   357 	CipherSuite.iLoByte = 9;
       
   358 	PtrTlsCryptoAttributes->iCurrentCipherSuite = CipherSuite;
       
   359 	PtrTlsCryptoAttributes->iNegotiatedProtocol = KSSL3_0;	
       
   360 
       
   361 	
       
   362 	//Init start
       
   363 	RFs fs;
       
   364 	RFile file;
       
   365 	fs.Connect();	
       
   366 	TBuf8<1000> boom;
       
   367 	file.Open(fs, 
       
   368 				aStep->iServerCertChain,  
       
   369 	 			EFileShareAny|EFileRead);
       
   370 	file.Read(boom);
       
   371 	
       
   372 	iStatus = KRequestPending;
       
   373 	CX509Certificate* serverCert;
       
   374 	HBufC8* servrc = boom.AllocL();
       
   375 	PtrProvider->VerifyServerCertificate(servrc->Des(), serverCert, iStatus);
       
   376 	SetActive();
       
   377 	CActiveScheduler::Start();
       
   378 	iLogInfo.Copy(_L("	6.3:  IPtrProvider->VerifyServerCertificate"));
       
   379 	INFO_PRINTF1(_L("2"));
       
   380 
       
   381 	CipherSuite.iHiByte = 0;
       
   382 	CipherSuite.iLoByte = 0x19;
       
   383 	PtrTlsCryptoAttributes->iCurrentCipherSuite = CipherSuite;
       
   384 	//Init end
       
   385 
       
   386 	iStatus = KRequestPending;	
       
   387 	PtrProvider->CreateL(PtrSession,iStatus);
       
   388 	SetActive();
       
   389 	CActiveScheduler::Start();
       
   390 
       
   391 	iLogInfo.Copy(_L("	6.3:  IPtrProvider->CreateL"));
       
   392 
       
   393 	//Init start
       
   394 	CipherSuite.iHiByte = 0;
       
   395 	CipherSuite.iLoByte = 9;
       
   396 	PtrTlsCryptoAttributes->iCurrentCipherSuite = CipherSuite;	
       
   397 	iStatus = KRequestPending;
       
   398 	HBufC8* clntkeyexchang;
       
   399 	INFO_PRINTF1(_L("3"));
       
   400 	if(!PtrSession)
       
   401    {
       
   402       delete PtrProvider;
       
   403 		iLogInfo.Copy(_L("	6.3:  !PtrSession"));
       
   404 		return EFail;
       
   405    }
       
   406 	PtrSession->ClientKeyExchange(clntkeyexchang,iStatus);
       
   407 	SetActive();
       
   408 	CActiveScheduler::Start();
       
   409 	//Init end
       
   410 
       
   411 
       
   412 	if(PtrSession)
       
   413    {
       
   414    	INFO_PRINTF1(_L("4"));
       
   415    	iLogInfo.Copy(_L("	6.3:  EncryptAndDecryptL"));
       
   416 		TVerdict ver = (EncryptAndDecryptL(PtrSession,aStep));
       
   417       delete PtrProvider;
       
   418       delete PtrSession;
       
   419       return ver;
       
   420    }
       
   421 	else
       
   422    {
       
   423       delete PtrProvider;
       
   424 		return EFail;
       
   425    }
       
   426 
       
   427 	}
       
   428 
       
   429 
       
   430 
       
   431 /*
       
   432 HELPER:
       
   433 The actual step thta does the encryption and decryption
       
   434 
       
   435 */
       
   436 TVerdict CTlsProvTestActive::EncryptAndDecryptL(CTLSSession* aPtrTlsSession, CTlsProvStep* /*aStep*/)
       
   437 	{
       
   438 	
       
   439 	RFs filesys;
       
   440 	filesys.Connect();
       
   441 	RFile fileTmp_t;
       
   442 	
       
   443 	TBuf8<1024> TempPrint;
       
   444 	TDriveUnit sysDrive (filesys.GetSystemDrive());
       
   445 	TDriveName sysDriveName (sysDrive.Name());
       
   446 	
       
   447 	TBuf<128> fileName (sysDriveName);
       
   448 	fileName.Append(_L("\\data\\ActualAppData.bin"));
       
   449 	
       
   450 	TInt result_t = fileTmp_t.Open(filesys, fileName, EFileRead);
       
   451 		
       
   452   	INFO_PRINTF1(_L("EncryptAndDecryptL 1"));
       
   453 	if(!result_t)
       
   454 		fileTmp_t.Read( TempPrint );
       
   455 	fileTmp_t.Close();	
       
   456 
       
   457 	
       
   458 	iStatus = KRequestPending;
       
   459 	HBufC8* Output = NULL;
       
   460 	TRecordProtocol RecType;
       
   461 	RecType= EHandshake;
       
   462 	TInt64 ASeqNumber = 0;
       
   463 	Output = HBufC8::NewL(TempPrint.Length() + 24);
       
   464 	aPtrTlsSession->EncryptL( 
       
   465 		TempPrint, 
       
   466 		Output, 
       
   467 		ASeqNumber,RecType) ;
       
   468 	
       
   469   	INFO_PRINTF1(_L("EncryptAndDecryptL 2"));
       
   470   	
       
   471   	fileName.Copy(sysDriveName);
       
   472   	fileName.Append(_L("\\data\\EncryptOutput.bin"));
       
   473 	
       
   474 	result_t = fileTmp_t.Open(filesys, fileName, EFileRead);
       
   475 	
       
   476 	TBuf8<1024> ActualOutput;	
       
   477 	if(!result_t)
       
   478 		fileTmp_t.Read(ActualOutput);
       
   479 	fileTmp_t.Close();
       
   480 	if(ActualOutput.Compare(Output->Des()) != 0)
       
   481 		return EFail;
       
   482 
       
   483 	//Test Decryption here
       
   484 
       
   485   	INFO_PRINTF1(_L("EncryptAndDecryptL 3"));
       
   486   	
       
   487   	fileName.Copy(sysDriveName);
       
   488   	fileName.Append(_L("\\data\\DecryptionInput.bin"));
       
   489 	
       
   490 	result_t = fileTmp_t.Open(filesys, fileName, EFileRead);
       
   491 	
       
   492 	if(!result_t)
       
   493 		fileTmp_t.Read( ActualOutput );
       
   494 	fileTmp_t.Close();
       
   495 
       
   496 
       
   497 	iStatus = KRequestPending;
       
   498 	HBufC8* OutputDe = NULL;
       
   499 	
       
   500 	RecType= EHandshake;
       
   501 	TInt64 ASeqNumberDe = 0;
       
   502 	OutputDe = HBufC8::NewL(ActualOutput.Length());
       
   503 	aPtrTlsSession->DecryptAndVerifyL( 
       
   504 		ActualOutput, 
       
   505 		OutputDe, 
       
   506 		ASeqNumberDe,RecType) ;
       
   507 
       
   508 	fileName.Copy (sysDriveName);
       
   509 	fileName.Append(_L("\\data\\DecryptionOutputNoMac.bin"));
       
   510 	
       
   511 	result_t = fileTmp_t.Open(filesys, fileName, EFileRead);
       
   512 	
       
   513 	if(!result_t)
       
   514 		fileTmp_t.Read(ActualOutput);
       
   515 	fileTmp_t.Close();
       
   516 	
       
   517   	INFO_PRINTF1(_L("EncryptAndDecryptL 4"));
       
   518 	if(ActualOutput.Compare(OutputDe->Des()) != 0)
       
   519    {
       
   520 	   iLogInfo.Copy(_L("	EncryptDecr Fail"));
       
   521 		return EFail;
       
   522    }
       
   523 	else
       
   524    {
       
   525 	   iLogInfo.Copy(_L("	EncryptDecr Success"));
       
   526 		return EPass;
       
   527    }
       
   528 	}
       
   529 
       
   530 /*
       
   531 HELPER:
       
   532 Initializes the TLSProvider
       
   533 */
       
   534 TVerdict CTlsProvTestActive::InitProviderL(CTLSProvider*& aPtrProvider,CTLSSession*& /*aPtrSession*/,
       
   535 									  CTlsCryptoAttributes*& aTlsCryptoAttributes,
       
   536 									  TBool aIsTls, TBool aIsExport,CTlsProvStep* aStep)
       
   537 	{
       
   538 	RArray<TTLSCipherSuite> UserCipherSuiteList;
       
   539 	if(!aPtrProvider)
       
   540 		aPtrProvider = CTLSProvider::ConnectL();
       
   541 
       
   542 	//Obtain the list of ciphersuites
       
   543 	iStatus = KRequestPending;
       
   544 	aPtrProvider->CipherSuitesL(UserCipherSuiteList,iStatus);	
       
   545 	SetActive();
       
   546 	CActiveScheduler::Start();
       
   547 
       
   548 	TInt SelectedCiphers = UserCipherSuiteList.Count();
       
   549 	if(SelectedCiphers != KSupportedCipherCount) 
       
   550 		{
       
   551 		return EFail;			
       
   552 		}
       
   553 
       
   554 	
       
   555 	aTlsCryptoAttributes = aPtrProvider->Attributes();
       
   556 	if(aIsTls)
       
   557 		ConfigureTLS(aIsExport,aStep);
       
   558 	else
       
   559 		ConfigureSSL(aIsExport,aStep);
       
   560 
       
   561 	HBufC8* SrvCertificate;
       
   562 	ReadTestDataL(aTlsCryptoAttributes, SrvCertificate,aStep);
       
   563 	delete SrvCertificate;
       
   564 	aTlsCryptoAttributes->iPublicKeyParams->iKeyType = ERsa;
       
   565 	UserCipherSuiteList.Reset();
       
   566 	return EPass;
       
   567 	
       
   568 	}
       
   569 
       
   570 
       
   571 /*
       
   572 HELPER:
       
   573 Configures the initialization data for TLS
       
   574 */
       
   575 void CTlsProvTestActive::ConfigureTLS(TBool aIsExport, CTlsProvStep* aStep)
       
   576 	{
       
   577 	if(aIsExport)
       
   578 		{
       
   579 		aStep->GetStringFromConfig(aStep->ConfigSection(),_L("TLSServerRndExport"),aStep->iServerRnd);
       
   580 		aStep->GetStringFromConfig(aStep->ConfigSection(),_L("TLSClientRndExport"),aStep->iClientRnd);
       
   581 		}
       
   582 	else
       
   583 		{
       
   584 		aStep->GetStringFromConfig(aStep->ConfigSection(),_L("TlsServerRnd"),aStep->iServerRnd);
       
   585 		aStep->GetStringFromConfig(aStep->ConfigSection(),_L("TlsClientRnd"),aStep->iClientRnd);
       
   586 		}
       
   587 	aStep->GetStringFromConfig(aStep->ConfigSection(),_L("TlsKeyParams1"),aStep->iKeyParam1);
       
   588 	aStep->GetStringFromConfig(aStep->ConfigSection(),_L("TlsKeyParams2"),aStep->iKeyParam2);
       
   589 	aStep->GetStringFromConfig(aStep->ConfigSection(),_L("TlsKeyParams3"),aStep->iKeyParam3);
       
   590 	aStep->GetStringFromConfig(aStep->ConfigSection(),_L("TlsServerCert"),aStep->iServerCertChain);	
       
   591 	}
       
   592 
       
   593 
       
   594 /*
       
   595 HELPER:
       
   596 Configures the initialization data for SSL
       
   597 */
       
   598 void CTlsProvTestActive::ConfigureSSL(TBool aIsExport, CTlsProvStep* aStep)
       
   599 	{
       
   600 	if(aIsExport)
       
   601 		{
       
   602 		aStep->GetStringFromConfig(aStep->ConfigSection(),_L("SSLServerRndExport"),aStep->iServerRnd);
       
   603 		aStep->GetStringFromConfig(aStep->ConfigSection(),_L("SSLClientRndExport"),aStep->iClientRnd);
       
   604 		}
       
   605 	else
       
   606 		{
       
   607 		aStep->GetStringFromConfig(aStep->ConfigSection(),_L("ServerRnd"),aStep->iServerRnd);
       
   608 		aStep->GetStringFromConfig(aStep->ConfigSection(),_L("ClientRnd"),aStep->iClientRnd);
       
   609 		}
       
   610 	aStep->GetStringFromConfig(aStep->ConfigSection(),_L("KeyParams1"),aStep->iKeyParam1);
       
   611 	aStep->GetStringFromConfig(aStep->ConfigSection(),_L("KeyParams2"),aStep->iKeyParam2);
       
   612 	aStep->GetStringFromConfig(aStep->ConfigSection(),_L("KeyParams3"),aStep->iKeyParam3);
       
   613 	aStep->GetStringFromConfig(aStep->ConfigSection(),_L("ServerCert"),aStep->iServerCertChain);
       
   614 	}