os/security/cryptoservices/certificateandkeymgmt/tpkcs12intgrtn/inc/tpkcs12libteststep.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 /*
     2 * Copyright (c) 2005-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 * This contains the Teststep class which is used for verification of the pkcs12 file
    16 * and log the results
    17 *
    18 */
    19 
    20 
    21 /**
    22  @file 
    23  @internalTechnology
    24 */
    25  
    26 #ifndef __TPKCS12LIBTESTSTEP01_H__
    27 #define __TPKCS12LIBTESTSTEP01_H__
    28 
    29 // System Include
    30 #include <test/testexecutestepbase.h>
    31 
    32 //User Include
    33 #include "tpkcs12common.h"
    34 #include <pkcs12.h>
    35 
    36 const TInt KPositiveTest=1;
    37 const TInt KNegativeTest=0;
    38 const TInt KBagDataSecBufLen=10;
    39 const TInt KPrivacyPwdStrLen=17;
    40 const TInt KContentInfoBufLen=12;
    41 const TInt KPasswordKeyStrLen=15;
    42 const TInt KBagDataSectionStrLen=7;
    43 const TInt KContentInfoKeyStrLen=11;
    44 const TInt KAttributeBufLen=6;
    45 const TInt KAttributeKeyStrLen=4;
    46 const TInt KBagValBufLen=8;
    47 const TInt KBagValKeyStrLen=5;
    48 
    49 _LIT(KFriendlyNameOid,"1.2.840.113549.1.9.20");
    50 _LIT(KLocalKeyOid,"1.2.840.113549.1.9.21");
    51 _LIT(KMainSec,"main");
    52 _LIT(KAuthSafeSec,"authsafe");
    53 _LIT(KFilePath,"file");
    54 _LIT(KIntegrityMode,"integritymode");
    55 _LIT(KUnitTest,"unittest");
    56 _LIT(KUnitTestValue,"FALSE");
    57 _LIT(KPassword,"password");
    58 _LIT(KIntegrityPassword,"integritypassword");
    59 _LIT(KIntegrityValid,"integrity_valid");
    60 _LIT(KPublicIntegrity,"public");
    61 _LIT(KPrivacyPassword,"PrivacyPassword");
    62 _LIT(KExpectedResult,"ExpectedResult");
    63 _LIT(KVerifyIntgPass,"verifyintegritypassword");
    64 _LIT(KMacPresent,"MacPresent");
    65 _LIT(KMacValueDefault,"FALSE");
    66 _LIT(KMacTestValue,"True");
    67 _LIT(KContentInfoKey,"contentinfo");
    68 _LIT(KContentInfoNum,"numcontentinfos");
    69 _LIT(KBagDataSec,"BagData");
    70 _LIT(KBagType,"BagType");
    71 _LIT(KSafeBagsCount,"SafeBagsCount");
    72 _LIT(KContentInfoType,"ContentInfoType");
    73 _LIT(KBagAttributesKey,"attr");
    74 _LIT(KBagAttributesNum,"numattributes");
    75 _LIT(KBagAttributesID,"id");
    76 _LIT(KBagAttributeValuesNum,"numvalues");
    77 _LIT(KBagAttributeValue,"value");
    78 _LIT(KAlgorithm,"Algorithm");
    79 _LIT(KCertType,"CertType");
    80 _LIT(KContentInfoPwd,"ContentInfoPrivacyPassword");
    81 _LIT(KSafeBagPrivacyPwd,"safeBagprivacypassword");
    82 _LIT(KBagValue,"BagValue");
    83 _LIT(KEncBagValue,"EncodedBagValue");
    84 _LIT(KMac,"Mac");
    85 _LIT(KMacSalt,"MacSalt");
    86 _LIT(KIterationCount,"IterationCount");
    87 _LIT(KIntegrityPwd,"integritypassword");
    88 _LIT(KExpectedError,"ExpectedError");
    89 
    90 _LIT(KFriendlyName,"1.2.840.113549.1.9.20");
    91 _LIT(KLocalKey,"1.2.840.113549.1.9.21");
    92 
    93 
    94 /**
    95 This is a teststep class wherin all the verification for the pkcs12 file
    96 is done.
    97 */
    98 class CPKCS12LibTestStep : public CTestStep
    99 	{
   100 public:
   101 	CPKCS12LibTestStep ();
   102 	~CPKCS12LibTestStep();
   103 	//From CTestStep class
   104 	TVerdict doTestStepL();
   105 	
   106 private:
   107 	TBool ChkCIType(TDesC &aSecName,CSafeBagData &aBagData);
   108 	TBool ChkBagType(TDesC &aSecName,CSafeBagData &aBagData,TInt aBagId);
   109 	TBool ChkBagAttbutesL(TDesC &aSecName,CSafeBagData &aBagData);
   110 	TBool ChkAtrSecL(TDesC &aSec,CSafeBagData &aBagData,TInt aIndx);
   111 	TBool ChkAtrValL(TDesC &aSecName,CSafeBagData &aBagData,TInt aNumVal);
   112 	TBool ChkAlgId(TDesC &aSecName,CSafeBagData &aBagData);
   113 	TBool ChkCertId(TDesC &aSecName,CSafeBagData &aBagData);
   114 	TBool VerifyMainSecL();
   115 	TBool VerifyAuthSafe();
   116 	TBool ChkBagDataL(TInt aTotalsafebags,TInt aTotalbags);
   117 	TBool ChkSafeContsBagData(TDesC& aBagSec,CSafeContentBag &aSafeContntBagData);
   118 	TBool ChkBagValL(TDesC &aSecName,CSafeBagData &aBagData);
   119 	TBool ChkMacValueL();
   120 	TBool CompareFileDataL(TDesC &aPValue,TDesC8 &aBufferVal);
   121 	void ParsePrivacyPwdL();
   122 	TBool VerifyExpectedError(const TDesC &aSecName);
   123 	TBool ChkEncodedBagValL(TDesC &aSecName,CSafeBagData &aBagData);
   124 
   125 private:
   126 	/** privacy password of all the contentinfos in sequence if encrypted */
   127 	RPointerArray<TDesC>iPrivacyPassword ;
   128 	/** SafeBagData pointer */
   129 	CSafeBagData *iBagData;
   130 	/** positive or negative test */
   131 	TBool iExpectedResult;
   132 	/** flag for checking whether the verification function returns true or false */
   133 	TBool  iActualResult;
   134 	/** Unit test value */
   135 	TBool iUnitTest;
   136 	/** BagAttribute Value */
   137 	TInt iBagAttrNumVal;
   138 	/** Argument error. */
   139 	TInt iExpectedError;
   140 	/** ContentData is Set 0, if the contentData is absent. */
   141 	TInt iContentDataPresent;
   142 	/** PKCS12Parser object */
   143 	CPkcs12Parser *iParser;
   144 	/** File server object */
   145 	RFs iFileSession;
   146 	/** Set to True/False depending on the verification of the error. */ 
   147 	TBool iUnitTestContinueFlag;
   148 	
   149 	};
   150 
   151 /**
   152 This is a teststep class wherin all the OOM Test for the pkcs12 library
   153 is done.
   154 */
   155 class CTPKCS12OOMStep : public CTestStep
   156 	{
   157 public:
   158 	CTPKCS12OOMStep ();
   159 	~CTPKCS12OOMStep();
   160 	// From CTestStep class
   161 	TVerdict doTestStepPreambleL();
   162 	TVerdict doTestStepL();
   163 private:
   164 	HBufC8* ReadFileDataL(TPtrC tag);
   165 protected:
   166 	/** contains the data */
   167 	HBufC8*	iRawData;
   168 	/** contains the authsafe data */
   169 	HBufC8* iAuthSafeData;
   170 	/** File server object */
   171 	RFs		iFs;
   172 	};
   173 
   174 _LIT(KStep, "PKCS12LibTestStep");
   175 _LIT(KTPKCS12OOMStep,"PKCS12OOMTestStep");
   176 
   177 #endif