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