cryptoservices/certificateandkeymgmt/tpkixcert/testspecs.cpp
changeset 0 2c201484c85f
child 8 35751d3474b7
equal deleted inserted replaced
-1:000000000000 0:2c201484c85f
       
     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 "testspecs.h"
       
    20 
       
    21 //test chain superclass
       
    22 CTestChain::CTestChain()
       
    23 	{
       
    24 	}
       
    25 
       
    26 CTestChain::~CTestChain()
       
    27 	{
       
    28 	delete iServerCerts;
       
    29 	delete iRootCerts;
       
    30 	delete iExtraCerts;
       
    31 	}
       
    32 
       
    33 void CTestChain::ConstructL()
       
    34 	{
       
    35 	iServerCerts = new(ELeave) CDesCArrayFlat (1);
       
    36 	iRootCerts = new(ELeave) CDesCArrayFlat (1);
       
    37 	iExtraCerts = new(ELeave) CDesCArrayFlat (1);
       
    38 	}
       
    39 
       
    40 //test build class		
       
    41 CTestChainBuild* CTestChainBuild::NewL()
       
    42 	{
       
    43 	CTestChainBuild* self = CTestChainBuild::NewLC();
       
    44 	CleanupStack::Pop();
       
    45 	return self;
       
    46 	}
       
    47 
       
    48 CTestChainBuild* CTestChainBuild::NewLC()
       
    49 	{
       
    50 	CTestChainBuild* self = new(ELeave) CTestChainBuild;
       
    51 	CleanupStack::PushL(self);
       
    52 	self->ConstructL();
       
    53 	return self;
       
    54 	}
       
    55 
       
    56 CTestChainBuild::~CTestChainBuild()
       
    57 	{
       
    58 	delete iCorrectChain;
       
    59 	}
       
    60 
       
    61 //test chain validate class
       
    62 CTestChainValidate* CTestChainValidate::NewL()
       
    63 	{
       
    64 	CTestChainValidate* self = CTestChainValidate::NewLC();
       
    65 	CleanupStack::Pop();
       
    66 	return self;
       
    67 	}
       
    68 
       
    69 CTestChainValidate* CTestChainValidate::NewLC()
       
    70 	{
       
    71 	CTestChainValidate* self = new(ELeave) CTestChainValidate;
       
    72 	CleanupStack::PushL(self);
       
    73 	self->ConstructL();
       
    74 	return self;
       
    75 	}
       
    76 
       
    77 void CTestChainValidate::ConstructL()
       
    78 	{
       
    79 	CTestChain::ConstructL();
       
    80 	iWarnings = new(ELeave)CArrayFixFlat<TValidationStatus> (1);
       
    81 	iPolicies = new(ELeave) CDesCArrayFlat (1);
       
    82 	}
       
    83 
       
    84 CTestChainValidate::~CTestChainValidate()
       
    85 	{
       
    86 	delete iError;
       
    87 	delete iWarnings;
       
    88 	delete iPolicies;
       
    89 	};
       
    90 
       
    91 //test specs
       
    92 TestSpec::TestSpec()
       
    93 	{
       
    94 	}
       
    95 
       
    96 CTestChainBuild* TestSpec::TestBuildSpec1()
       
    97 	{
       
    98 	CTestChainBuild* ret = CTestChainBuild::NewLC();
       
    99 	ret->iServerCerts->AppendL(KEE);
       
   100 	ret->iServerCerts->AppendL(KCA1);
       
   101 	ret->iServerCerts->AppendL(KCA2);
       
   102 	ret->iRootCerts->AppendL(KRoot);
       
   103 	const TPtrC name(KCorrectFile1);
       
   104 	ret->iCorrectChain = name.AllocL();
       
   105 	CleanupStack::Pop(); 
       
   106 	return ret;
       
   107 	}
       
   108 
       
   109 CTestChainBuild* TestSpec::TestBuildSpec2()
       
   110 	{
       
   111 	CTestChainBuild* ret = CTestChainBuild::NewLC();
       
   112 	ret->iServerCerts->AppendL(KEE);
       
   113 	ret->iServerCerts->AppendL(KCA2);
       
   114 	ret->iServerCerts->AppendL(KCA1);
       
   115 	ret->iRootCerts->AppendL(KRoot);
       
   116 	const TPtrC name(KCorrectFile1);
       
   117 	ret->iCorrectChain = name.AllocL();
       
   118 	CleanupStack::Pop(); 
       
   119 	return ret;
       
   120 	}
       
   121 
       
   122 CTestChainBuild* TestSpec::TestBuildSpec3()
       
   123 	{
       
   124 	CTestChainBuild* ret = CTestChainBuild::NewLC();
       
   125 	ret->iServerCerts->AppendL(KEE);
       
   126 	ret->iServerCerts->AppendL(KCA1);
       
   127 	ret->iExtraCerts->AppendL(KCA2);
       
   128 	ret->iRootCerts->AppendL(KRoot);
       
   129 	const TPtrC name(KCorrectFile1);
       
   130 	ret->iCorrectChain = name.AllocL();
       
   131 	CleanupStack::Pop(); 
       
   132 	return ret;
       
   133 	}
       
   134 
       
   135 CTestChainBuild* TestSpec::TestBuildSpec4()
       
   136 	{
       
   137 	CTestChainBuild* ret = CTestChainBuild::NewLC();
       
   138 	ret->iServerCerts->AppendL(KEE);
       
   139 	ret->iServerCerts->AppendL(KCA2);
       
   140 	ret->iExtraCerts->AppendL(KCA1);
       
   141 	ret->iRootCerts->AppendL(KRoot);
       
   142 	const TPtrC name(KCorrectFile1);
       
   143 	ret->iCorrectChain = name.AllocL();
       
   144 	CleanupStack::Pop(); 
       
   145 	return ret;
       
   146 	}
       
   147 
       
   148 CTestChainBuild* TestSpec::TestBuildSpec5()
       
   149 	{
       
   150 	CTestChainBuild* ret = CTestChainBuild::NewLC();
       
   151 	ret->iServerCerts->AppendL(KEE);
       
   152 	ret->iServerCerts->AppendL(KCA1);
       
   153 	ret->iServerCerts->AppendL(KCA2);
       
   154 	ret->iServerCerts->AppendL(KRoot);
       
   155 	ret->iRootCerts->AppendL(KRoot);
       
   156 	const TPtrC name(KCorrectFile1);
       
   157 	ret->iCorrectChain = name.AllocL();
       
   158 	CleanupStack::Pop(); 
       
   159 	return ret;
       
   160 	}
       
   161 
       
   162 CTestChainBuild* TestSpec::TestBuildSpec6()
       
   163 	{
       
   164 	CTestChainBuild* ret = CTestChainBuild::NewLC();
       
   165 	ret->iServerCerts->AppendL(KEE);
       
   166 	ret->iServerCerts->AppendL(KRoot);
       
   167 	ret->iServerCerts->AppendL(KCA2);
       
   168 	ret->iServerCerts->AppendL(KCA1);
       
   169 	ret->iRootCerts->AppendL(KRoot);
       
   170 	const TPtrC name(KCorrectFile1);
       
   171 	ret->iCorrectChain = name.AllocL();
       
   172 	CleanupStack::Pop(); 
       
   173 	return ret;
       
   174 	}
       
   175 
       
   176 CTestChainBuild* TestSpec::TestBuildSpec7()
       
   177 	{
       
   178 	CTestChainBuild* ret = CTestChainBuild::NewLC();
       
   179 	ret->iServerCerts->AppendL(KEE);
       
   180 	ret->iServerCerts->AppendL(KCA1);
       
   181 	ret->iServerCerts->AppendL(KCA2SameDN);
       
   182 	ret->iServerCerts->AppendL(KCA2);
       
   183 	ret->iRootCerts->AppendL(KRoot);
       
   184 	const TPtrC name(KCorrectFile1);
       
   185 	ret->iCorrectChain = name.AllocL();
       
   186 	CleanupStack::Pop(); 
       
   187 	return ret;
       
   188 	}
       
   189 
       
   190 CTestChainBuild* TestSpec::TestBuildSpec8()
       
   191 	{
       
   192 	CTestChainBuild* ret = CTestChainBuild::NewLC();
       
   193 	ret->iServerCerts->AppendL(KEE);
       
   194 	ret->iServerCerts->AppendL(KCA2SameDN);
       
   195 	ret->iServerCerts->AppendL(KCA1);
       
   196 	ret->iServerCerts->AppendL(KCA2);
       
   197 	ret->iRootCerts->AppendL(KRoot);
       
   198 	const TPtrC name(KCorrectFile1);
       
   199 	ret->iCorrectChain = name.AllocL();
       
   200 	CleanupStack::Pop(); 
       
   201 	return ret;
       
   202 	}
       
   203 
       
   204 CTestChainBuild* TestSpec::TestBuildSpec9()
       
   205 	{
       
   206 	CTestChainBuild* ret = CTestChainBuild::NewLC();
       
   207 	ret->iServerCerts->AppendL(KEE);
       
   208 	ret->iServerCerts->AppendL(KCA1);
       
   209 	ret->iServerCerts->AppendL(KCA2SameDN);
       
   210 	ret->iExtraCerts->AppendL(KCA2);
       
   211 	ret->iRootCerts->AppendL(KRoot);
       
   212 	const TPtrC name(KCorrectFile1);
       
   213 	ret->iCorrectChain = name.AllocL();
       
   214 	CleanupStack::Pop(); 
       
   215 	return ret;
       
   216 	}
       
   217 
       
   218 CTestChainBuild* TestSpec::TestBuildSpec10()
       
   219 	{
       
   220 	CTestChainBuild* ret = CTestChainBuild::NewLC();
       
   221 	ret->iServerCerts->AppendL(KEE);
       
   222 	ret->iServerCerts->AppendL(KCA1);
       
   223 	ret->iServerCerts->AppendL(KCA2);
       
   224 	ret->iExtraCerts->AppendL(KCA2SameDN);
       
   225 	ret->iRootCerts->AppendL(KRoot);
       
   226 	const TPtrC name(KCorrectFile1);
       
   227 	ret->iCorrectChain = name.AllocL();
       
   228 	CleanupStack::Pop(); 
       
   229 	return ret;
       
   230 	}
       
   231 
       
   232 CTestChainBuild* TestSpec::TestBuildSpec11()
       
   233 	{
       
   234 	CTestChainBuild* ret = CTestChainBuild::NewLC();
       
   235 	ret->iServerCerts->AppendL(KEE);
       
   236 	ret->iServerCerts->AppendL(KCA2);
       
   237 	ret->iServerCerts->AppendL(KCA1);
       
   238 	ret->iExtraCerts->AppendL(KCA1SameDN);
       
   239 	ret->iRootCerts->AppendL(KRoot);
       
   240 	const TPtrC name(KCorrectFile1);
       
   241 	ret->iCorrectChain = name.AllocL();
       
   242 	CleanupStack::Pop(); 
       
   243 	return ret;
       
   244 	}
       
   245 
       
   246 CTestChainBuild* TestSpec::TestBuildSpec12()
       
   247 	{
       
   248 	CTestChainBuild* ret = CTestChainBuild::NewLC();
       
   249 	ret->iServerCerts->AppendL(KEE);
       
   250 	ret->iServerCerts->AppendL(KCA2);
       
   251 	ret->iServerCerts->AppendL(KCA1SameDN);
       
   252 	ret->iExtraCerts->AppendL(KCA1);
       
   253 	ret->iRootCerts->AppendL(KRoot);
       
   254 	const TPtrC name(KCorrectFile1);
       
   255 	ret->iCorrectChain = name.AllocL();
       
   256 	CleanupStack::Pop(); 
       
   257 	return ret;
       
   258 	}
       
   259 
       
   260 //validate tests
       
   261 CTestChainValidate* TestSpec::TestValidateSpec1()
       
   262 	{
       
   263 	CTestChainValidate* ret = CTestChainValidate::NewLC();
       
   264 	ret->iServerCerts->AppendL(KFortezzaCA1EE1);
       
   265 	ret->iServerCerts->AppendL(KFortezzaPCA1);
       
   266 	ret->iServerCerts->AppendL(KFortezzaCA1);
       
   267 	ret->iRootCerts->AppendL(KFortezzaPAA1);
       
   268 	TValidationStatus* status = new(ELeave) TValidationStatus(EValidatedOK, 0);
       
   269 	ret->iError = status;
       
   270 	CleanupStack::Pop(); 
       
   271 	return ret;
       
   272 	}
       
   273 
       
   274 CTestChainValidate* TestSpec::TestValidateSpec2()
       
   275 	{
       
   276 	CTestChainValidate* ret = CTestChainValidate::NewLC();
       
   277 	ret->iServerCerts->AppendL(KFortezzaCA1EE2);
       
   278 	ret->iServerCerts->AppendL(KFortezzaPCA1);
       
   279 	ret->iServerCerts->AppendL(KFortezzaCA1);
       
   280 	ret->iRootCerts->AppendL(KFortezzaPAA1);
       
   281 	TValidationStatus* status = new(ELeave) TValidationStatus(EValidatedOK, 0);
       
   282 	ret->iError = status;
       
   283 	CleanupStack::Pop(); 
       
   284 	return ret;
       
   285 	}
       
   286 
       
   287 CTestChainValidate* TestSpec::TestValidateSpec3()
       
   288 	{
       
   289 	CTestChainValidate* ret = CTestChainValidate::NewLC();
       
   290 	ret->iServerCerts->AppendL(KFortezzaExpired);
       
   291 	ret->iServerCerts->AppendL(KFortezzaPCA1);
       
   292 	ret->iServerCerts->AppendL(KFortezzaCA1);
       
   293 	ret->iRootCerts->AppendL(KFortezzaPAA1);
       
   294 	TValidationStatus* status = new(ELeave) TValidationStatus(EDateOutOfRange, 0);
       
   295 	ret->iError = status;
       
   296 	CleanupStack::Pop(); 
       
   297 	return ret;
       
   298 	}
       
   299 
       
   300 CTestChainValidate* TestSpec::TestValidateSpec4()
       
   301 	{
       
   302 	CTestChainValidate* ret = CTestChainValidate::NewLC();
       
   303 	ret->iServerCerts->AppendL(KFortezzaFuture);
       
   304 	ret->iServerCerts->AppendL(KFortezzaPCA1);
       
   305 	ret->iServerCerts->AppendL(KFortezzaCA1);
       
   306 	ret->iRootCerts->AppendL(KFortezzaPAA1);
       
   307 	TValidationStatus* status = new(ELeave) TValidationStatus(EDateOutOfRange, 0);
       
   308 	ret->iError = status;
       
   309 	CleanupStack::Pop(); 
       
   310 	return ret;
       
   311 	}
       
   312 
       
   313 CTestChainValidate* TestSpec::TestValidateSpec5()
       
   314 	{
       
   315 	CTestChainValidate* ret = CTestChainValidate::NewLC();
       
   316 	ret->iServerCerts->AppendL(KFortezzaInvalidSig);
       
   317 	ret->iServerCerts->AppendL(KFortezzaPCA1);
       
   318 	ret->iServerCerts->AppendL(KFortezzaCA1);
       
   319 	ret->iRootCerts->AppendL(KFortezzaPAA1);
       
   320 	TValidationStatus* status = new(ELeave) TValidationStatus(ESignatureInvalid, 0);
       
   321 	ret->iError = status;
       
   322 	CleanupStack::Pop(); 
       
   323 	return ret;
       
   324 	}
       
   325 
       
   326 CTestChainValidate* TestSpec::TestValidateSpec6()
       
   327 	{
       
   328 	CTestChainValidate* ret = CTestChainValidate::NewLC();
       
   329 	ret->iServerCerts->AppendL(KFortezzaKeyCompromise);
       
   330 	ret->iServerCerts->AppendL(KFortezzaPCA1);
       
   331 	ret->iServerCerts->AppendL(KFortezzaCA1);
       
   332 	ret->iRootCerts->AppendL(KFortezzaPAA1);
       
   333 	TValidationStatus* status = new(ELeave) TValidationStatus(EValidatedOK, 0);
       
   334 	ret->iError = status;
       
   335 	CleanupStack::Pop(); 
       
   336 	return ret;
       
   337 	}
       
   338 
       
   339 CTestChainValidate* TestSpec::TestValidateSpec7()
       
   340 	{
       
   341 	CTestChainValidate* ret = CTestChainValidate::NewLC();
       
   342 	ret->iServerCerts->AppendL(KFortezzaBadSubjName2);
       
   343 	ret->iServerCerts->AppendL(KFortezzaPCA1);
       
   344 	ret->iServerCerts->AppendL(KFortezzaTestCA2);
       
   345 	ret->iRootCerts->AppendL(KFortezzaPAA1);
       
   346 	TValidationStatus* status = new(ELeave) TValidationStatus(ENameIsExcluded, 0);
       
   347 	ret->iError = status;
       
   348 	CleanupStack::Pop(); 
       
   349 	return ret;
       
   350 	}
       
   351 
       
   352 CTestChainValidate* TestSpec::TestValidateSpec8()
       
   353 	{
       
   354 	CTestChainValidate* ret = CTestChainValidate::NewLC();
       
   355 	ret->iServerCerts->AppendL(KFortezzaBadSubjName1);
       
   356 	ret->iServerCerts->AppendL(KFortezzaPCA1);
       
   357 	ret->iServerCerts->AppendL(KFortezzaTestCA2);
       
   358 	ret->iRootCerts->AppendL(KFortezzaPAA1);
       
   359 	TValidationStatus* status = new(ELeave) TValidationStatus(ENameNotPermitted, 0);
       
   360 	ret->iError = status;
       
   361 	CleanupStack::Pop(); 
       
   362 	return ret;
       
   363 	}
       
   364 
       
   365 //
       
   366 CTestChainValidate* TestSpec::TestValidateSpec9()
       
   367 	{
       
   368 	CTestChainValidate* ret = CTestChainValidate::NewLC();
       
   369 	ret->iServerCerts->AppendL(KFortezzaPathLen);
       
   370 	ret->iServerCerts->AppendL(KFortezzaPCA1);
       
   371 	ret->iServerCerts->AppendL(KFortezzaTestCA2);
       
   372 	ret->iServerCerts->AppendL(KFortezzaTestSubCA2);
       
   373 	ret->iRootCerts->AppendL(KFortezzaPAA1);
       
   374 	TValidationStatus* status = new(ELeave) TValidationStatus(EPathTooLong, 0);
       
   375 	ret->iError = status;
       
   376 	CleanupStack::Pop(); 
       
   377 	return ret;
       
   378 	}
       
   379 
       
   380 CTestChainValidate* TestSpec::TestValidateSpec10()
       
   381 	{
       
   382 	CTestChainValidate* ret = CTestChainValidate::NewLC();
       
   383 	ret->iServerCerts->AppendL(KFortezzaInvalidCAUser1);
       
   384 	ret->iServerCerts->AppendL(KFortezzaPCA1);
       
   385 	ret->iServerCerts->AppendL(KFortezzaBadCA1);
       
   386 	ret->iRootCerts->AppendL(KFortezzaPAA1);
       
   387 	TValidationStatus* status = new(ELeave) TValidationStatus(ENotCACert, 1);
       
   388 	ret->iError = status;
       
   389 	CleanupStack::Pop(); 
       
   390 	return ret;
       
   391 	}
       
   392 
       
   393 CTestChainValidate* TestSpec::TestValidateSpec11()
       
   394 	{
       
   395 	CTestChainValidate* ret = CTestChainValidate::NewLC();
       
   396 	ret->iServerCerts->AppendL(KFortezzaInvalidCAUser2);
       
   397 	ret->iServerCerts->AppendL(KFortezzaPCA1);
       
   398 	ret->iServerCerts->AppendL(KFortezzaBadCA2);
       
   399 	ret->iRootCerts->AppendL(KFortezzaPAA1);
       
   400 	TValidationStatus* status = new(ELeave) TValidationStatus(EBadKeyUsage, 1);
       
   401 	ret->iError = status;
       
   402 	CleanupStack::Pop(); 
       
   403 	return ret;
       
   404 	}
       
   405 
       
   406 CTestChainValidate* TestSpec::TestValidateSpec12()
       
   407 	{
       
   408 	CTestChainValidate* ret = CTestChainValidate::NewLC();
       
   409 	ret->iServerCerts->AppendL(KFortezzaCA2EE1);
       
   410 	ret->iServerCerts->AppendL(KFortezzaPCA2);
       
   411 	ret->iServerCerts->AppendL(KFortezzaCA2);
       
   412 	ret->iRootCerts->AppendL(KFortezzaPAA2);
       
   413 	TValidationStatus* status = new(ELeave) TValidationStatus(EValidatedOK, 0);
       
   414 	ret->iError = status;
       
   415 	CleanupStack::Pop(); 
       
   416 	return ret;
       
   417 	}
       
   418 
       
   419 CTestChainValidate* TestSpec::TestValidateSpec13()
       
   420 	{
       
   421 	CTestChainValidate* ret = CTestChainValidate::NewLC();
       
   422 	ret->iServerCerts->AppendL(KFortezzaCA2BadAltName);
       
   423 	ret->iServerCerts->AppendL(KFortezzaPCA2);
       
   424 	ret->iServerCerts->AppendL(KFortezzaCA2);
       
   425 	ret->iRootCerts->AppendL(KFortezzaPAA2);
       
   426 	TValidationStatus* status = new(ELeave) TValidationStatus(ENameIsExcluded, 0);
       
   427 	ret->iError = status;
       
   428 	CleanupStack::Pop(); 
       
   429 	return ret;
       
   430 	}
       
   431 
       
   432 CTestChainValidate* TestSpec::TestValidateSpec14()
       
   433 	{
       
   434 	CTestChainValidate* ret = CTestChainValidate::NewLC();
       
   435 	ret->iServerCerts->AppendL(KDashnet);
       
   436 	ret->iRootCerts->AppendL(KRSASSCA);
       
   437 	TValidationStatus* status = new(ELeave) TValidationStatus(EValidatedOK, 0);
       
   438 	ret->iError = status;
       
   439 	CleanupStack::Pop(); 
       
   440 	return ret;
       
   441 	}
       
   442 
       
   443 
       
   444 CTestChainValidate* TestSpec::TestValidateSpec15()
       
   445 	{
       
   446 	CTestChainValidate* ret = CTestChainValidate::NewLC();
       
   447 	ret->iServerCerts->AppendL(K3Do);
       
   448 	ret->iRootCerts->AppendL(KRSASSCA);
       
   449 	TValidationStatus* status = new(ELeave) TValidationStatus(EValidatedOK, 0);
       
   450 	ret->iError = status;
       
   451 	CleanupStack::Pop(); 
       
   452 	return ret;
       
   453 	}
       
   454 
       
   455 CTestChainValidate* TestSpec::TestValidateSpec16()
       
   456 	{
       
   457 	CTestChainValidate* ret = CTestChainValidate::NewLC();
       
   458 	ret->iServerCerts->AppendL(KDashnet);
       
   459 	ret->iRootCerts->AppendL(KRSASSCA_OLD);
       
   460 	TValidationStatus* status = new(ELeave) TValidationStatus(EDateOutOfRange, 0);
       
   461 	ret->iError = status;
       
   462 	CleanupStack::Pop(); 
       
   463 	return ret;
       
   464 	}
       
   465 
       
   466 CTestChainValidate* TestSpec::TestValidateSpec17()
       
   467 	{
       
   468 	CTestChainValidate* ret = CTestChainValidate::NewLC();
       
   469 	ret->iServerCerts->AppendL(K3Do);
       
   470 	ret->iRootCerts->AppendL(KRSASSCA_OLD);
       
   471 	TValidationStatus* status = new(ELeave) TValidationStatus(EDateOutOfRange, 0);
       
   472 	ret->iError = status;
       
   473 	CleanupStack::Pop(); 
       
   474 	return ret;
       
   475 	}
       
   476 
       
   477 CTestChainValidate* TestSpec::TestValidateSpec18()
       
   478 	{
       
   479 	CTestChainValidate* ret = CTestChainValidate::NewLC();
       
   480 	ret->iServerCerts->AppendL(KLloyds);
       
   481 	ret->iServerCerts->AppendL(KVSignServer3);
       
   482 	ret->iRootCerts->AppendL(KVSignCA3);
       
   483 	TValidationStatus* status = new(ELeave) TValidationStatus(EValidatedOK, 0);
       
   484 	ret->iError = status;
       
   485 	CleanupStack::Pop(); 
       
   486 	return ret;
       
   487 	}
       
   488 
       
   489 CTestChainValidate* TestSpec::TestValidateSpec19()
       
   490 	{
       
   491 	CTestChainValidate* ret = CTestChainValidate::NewLC();
       
   492 	ret->iServerCerts->AppendL(KRoot);
       
   493 	ret->iRootCerts->AppendL(KRoot);
       
   494 	TValidationStatus* status = new(ELeave) TValidationStatus(EValidatedOK, 0);
       
   495 	ret->iError = status;
       
   496 	CleanupStack::Pop(); 
       
   497 	return ret;
       
   498 	}
       
   499 
       
   500 CTestChainValidate* TestSpec::TestValidateSpec20()
       
   501 	{
       
   502 	CTestChainValidate* ret = CTestChainValidate::NewLC();
       
   503 	ret->iServerCerts->AppendL(KRoot);
       
   504 	ret->iRootCerts->AppendL(KVSignCA3);
       
   505 	TValidationStatus* status = new(ELeave) TValidationStatus(EChainHasNoRoot, 0);
       
   506 	ret->iError = status;
       
   507 	CleanupStack::Pop(); 
       
   508 	return ret;
       
   509 	}
       
   510 
       
   511 //n.b. this test should leave with KErrArgument
       
   512 CTestChainValidate* TestSpec::TestValidateSpec21()
       
   513 	{
       
   514 	CTestChainValidate* ret = CTestChainValidate::NewLC();
       
   515 	TValidationStatus* status = new(ELeave) TValidationStatus(EChainHasNoRoot, 0);
       
   516 	ret->iError = status;
       
   517 	CleanupStack::Pop(); 
       
   518 	return ret;
       
   519 	}
       
   520 
       
   521 CTestChainValidate* TestSpec::TestValidateSpec22()
       
   522 	{
       
   523 	CTestChainValidate* ret = CTestChainValidate::NewLC();
       
   524 	ret->iServerCerts->AppendL(KMedCA1EE1);
       
   525 	ret->iServerCerts->AppendL(KMedCA1);
       
   526 	ret->iRootCerts->AppendL(KMedRootCA);
       
   527 	TValidationStatus* status = new(ELeave) TValidationStatus(EValidatedOK, 0);
       
   528 	ret->iError = status;
       
   529 	CleanupStack::Pop(); 
       
   530 	return ret;
       
   531 	}
       
   532 
       
   533 CTestChainValidate* TestSpec::TestValidateSpec23()
       
   534 	{
       
   535 	CTestChainValidate* ret = CTestChainValidate::NewLC();
       
   536 	ret->iServerCerts->AppendL(KMedCA1EE2);
       
   537 	ret->iServerCerts->AppendL(KMedCA1);
       
   538 	ret->iRootCerts->AppendL(KMedRootCA);
       
   539 	TValidationStatus* status = new(ELeave) TValidationStatus(EValidatedOK, 0);
       
   540 	ret->iError = status;
       
   541 	CleanupStack::Pop(); 
       
   542 	return ret;
       
   543 	}
       
   544 
       
   545 //FINEID test cases
       
   546 CTestChainValidate* TestSpec::TestValidateSpec24()
       
   547 	{
       
   548 	CTestChainValidate* ret = CTestChainValidate::NewLC();
       
   549 	ret->iServerCerts->AppendL(KFINEIDLipponenSign);
       
   550 	ret->iRootCerts->AppendL(KFINEIDCitizenCA);
       
   551 	TValidationStatus* status = new(ELeave) TValidationStatus(EValidatedOK, 0);
       
   552 	ret->iError = status;
       
   553 	CleanupStack::Pop(); 
       
   554 	return ret;
       
   555 	}
       
   556 
       
   557 CTestChainValidate* TestSpec::TestValidateSpec25()
       
   558 	{
       
   559 	CTestChainValidate* ret = CTestChainValidate::NewLC();
       
   560 	ret->iServerCerts->AppendL(KFINEIDLipponenEncrypt);
       
   561 	ret->iRootCerts->AppendL(KFINEIDCitizenCA);
       
   562 	TValidationStatus* status = new(ELeave) TValidationStatus(EValidatedOK, 0);
       
   563 	ret->iError = status;
       
   564 	CleanupStack::Pop(); 
       
   565 	return ret;
       
   566 	}
       
   567 
       
   568 CTestChainValidate* TestSpec::TestValidateSpec26()
       
   569 	{
       
   570 	CTestChainValidate* ret = CTestChainValidate::NewLC();
       
   571 	ret->iServerCerts->AppendL(KFINEIDHelsinkiSign);
       
   572 	ret->iRootCerts->AppendL(KFINEIDTestCA3);
       
   573 	TValidationStatus* status = new(ELeave) TValidationStatus(EValidatedOK, 0);
       
   574 	ret->iError = status;
       
   575 	CleanupStack::Pop(); 
       
   576 	return ret;
       
   577 	}
       
   578 
       
   579 CTestChainValidate* TestSpec::TestValidateSpec27()
       
   580 	{
       
   581 	CTestChainValidate* ret = CTestChainValidate::NewLC();
       
   582 	ret->iServerCerts->AppendL(KFINEIDHelsinkiEncrypt);
       
   583 	ret->iRootCerts->AppendL(KFINEIDTestCA3);
       
   584 	TValidationStatus* status = new(ELeave) TValidationStatus(EValidatedOK, 0);
       
   585 	ret->iError = status;
       
   586 	CleanupStack::Pop(); 
       
   587 	return ret;
       
   588 	}
       
   589 
       
   590 //test warning generated when cert not self signed
       
   591 CTestChainValidate* TestSpec::TestValidateSpec28()
       
   592 	{
       
   593 	CTestChainValidate* ret = CTestChainValidate::NewLC();
       
   594 	ret->iServerCerts->AppendL(KLloyds);
       
   595 	ret->iRootCerts->AppendL(KVSignServer3);//not self signed
       
   596 	TValidationStatus* error = new(ELeave) TValidationStatus(EValidatedOK, 0);
       
   597 	TValidationStatus warning(ERootCertNotSelfSigned, 0);
       
   598 	ret->iError = error;
       
   599 	ret->iWarnings->AppendL(warning);
       
   600 	CleanupStack::Pop(); 
       
   601 	return ret;
       
   602 	}
       
   603 
       
   604 //test case with OpenSSL default certs
       
   605 CTestChainValidate* TestSpec::TestValidateSpec29()
       
   606 	{
       
   607 	CTestChainValidate* ret = CTestChainValidate::NewLC();
       
   608 	ret->iRootCerts->AppendL(KApacheRSARoot);
       
   609 	ret->iServerCerts->AppendL(KApacheRSAServer);
       
   610 	TValidationStatus* error = new(ELeave) TValidationStatus(EDateOutOfRange, 0);
       
   611 	ret->iError = error;
       
   612 	CleanupStack::Pop(); 
       
   613 	return ret;
       
   614 	}
       
   615 
       
   616 CTestChainValidate* TestSpec::TestValidateSpec30()
       
   617 	{
       
   618 	CTestChainValidate* ret = CTestChainValidate::NewLC();
       
   619 	ret->iRootCerts->AppendL(KApacheDSARoot);
       
   620 	ret->iServerCerts->AppendL(KApacheDSAServer);
       
   621 	TValidationStatus* error = new(ELeave) TValidationStatus(EDateOutOfRange, 0);
       
   622 	ret->iError = error;
       
   623 	CleanupStack::Pop(); 
       
   624 	return ret;
       
   625 	}
       
   626 
       
   627 //normal chain, supply policy in chain, should work
       
   628 CTestChainValidate* TestSpec::TestValidateSpec31()
       
   629 	{
       
   630 	CTestChainValidate* ret = CTestChainValidate::NewLC();
       
   631 	ret->iRootCerts->AppendL(KFortezzaPAA1);
       
   632 	ret->iServerCerts->AppendL(KFortezzaCA1EE1);
       
   633 	ret->iServerCerts->AppendL(KFortezzaCA1);
       
   634 	ret->iServerCerts->AppendL(KFortezzaPCA1);
       
   635 	ret->iPolicies->AppendL(KX22Policy);
       
   636 	TValidationStatus* error = new(ELeave) TValidationStatus(EValidatedOK, 0);
       
   637 	ret->iError = error;
       
   638 	CleanupStack::Pop(); 
       
   639 	return ret;
       
   640 	}
       
   641 
       
   642 //normal chain, supply policy not in chain, should fail
       
   643 CTestChainValidate* TestSpec::TestValidateSpec32()
       
   644 	{
       
   645 	CTestChainValidate* ret = CTestChainValidate::NewLC();
       
   646 	ret->iRootCerts->AppendL(KFortezzaPAA1);
       
   647 	ret->iServerCerts->AppendL(KFortezzaCA1EE1);
       
   648 	ret->iServerCerts->AppendL(KFortezzaCA1);
       
   649 	ret->iServerCerts->AppendL(KFortezzaPCA1);
       
   650 	ret->iPolicies->AppendL(KExtraBogusPolicy);
       
   651 	TValidationStatus* error = new(ELeave) TValidationStatus(ERequiredPolicyNotFound, 0);
       
   652 	ret->iError = error;
       
   653 	CleanupStack::Pop(); 
       
   654 	return ret;
       
   655 	}
       
   656 
       
   657 //chain with policy mapping, supply first policy, should work
       
   658 CTestChainValidate* TestSpec::TestValidateSpec33()
       
   659 	{
       
   660 	CTestChainValidate* ret = CTestChainValidate::NewLC();
       
   661 	ret->iRootCerts->AppendL(KFortezzaPAA1);
       
   662 	ret->iServerCerts->AppendL(KFortezzaCA2EE1);
       
   663 	ret->iServerCerts->AppendL(KFortezzaCA2);
       
   664 	ret->iServerCerts->AppendL(KFortezzaPCA2);
       
   665 	ret->iServerCerts->AppendL(KFortezzaX22RNCrossCert);
       
   666 	ret->iPolicies->AppendL(KX22Policy);
       
   667 	TValidationStatus* error = new(ELeave) TValidationStatus(EValidatedOK, 0);
       
   668 	ret->iError = error;
       
   669 	CleanupStack::Pop(); 
       
   670 	return ret;
       
   671 	}
       
   672 
       
   673 //chain with policy mapping, supply second policy, should work
       
   674 CTestChainValidate* TestSpec::TestValidateSpec34()
       
   675 	{
       
   676 	CTestChainValidate* ret = CTestChainValidate::NewLC();
       
   677 	ret->iRootCerts->AppendL(KFortezzaPAA1);
       
   678 	ret->iServerCerts->AppendL(KFortezzaCA2EE1);
       
   679 	ret->iServerCerts->AppendL(KFortezzaCA2);
       
   680 	ret->iServerCerts->AppendL(KFortezzaPCA2);
       
   681 	ret->iServerCerts->AppendL(KFortezzaX22RNCrossCert);
       
   682 	ret->iPolicies->AppendL(KRNPolicy);
       
   683 	TValidationStatus* error = new(ELeave) TValidationStatus(EValidatedOK, 0);
       
   684 	ret->iError = error;
       
   685 	CleanupStack::Pop(); 
       
   686 	return ret;
       
   687 	}
       
   688 
       
   689 //chain with policy mappng, supply different policy, should fail
       
   690 CTestChainValidate* TestSpec::TestValidateSpec35()
       
   691 	{
       
   692 	CTestChainValidate* ret = CTestChainValidate::NewLC();
       
   693 	ret->iRootCerts->AppendL(KFortezzaPAA1);
       
   694 	ret->iServerCerts->AppendL(KFortezzaCA2EE1);
       
   695 	ret->iServerCerts->AppendL(KFortezzaCA2);
       
   696 	ret->iServerCerts->AppendL(KFortezzaPCA2);
       
   697 	ret->iServerCerts->AppendL(KFortezzaX22RNCrossCert);
       
   698 	ret->iPolicies->AppendL(KExtraBogusPolicy);
       
   699 	TValidationStatus* error = new(ELeave) TValidationStatus(ERequiredPolicyNotFound, 0);
       
   700 	ret->iError = error;
       
   701 	CleanupStack::Pop(); 
       
   702 	return ret;
       
   703 	}