sl@0: /* sl@0: * Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: * All rights reserved. sl@0: * This component and the accompanying materials are made available sl@0: * under the terms of the License "Eclipse Public License v1.0" sl@0: * which accompanies this distribution, and is available sl@0: * at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: * sl@0: * Initial Contributors: sl@0: * Nokia Corporation - initial contribution. sl@0: * sl@0: * Contributors: sl@0: * sl@0: * Description: sl@0: * This contains the Teststep class which is used for verification of the pkcs12 file sl@0: * and log the results sl@0: * sl@0: */ sl@0: sl@0: sl@0: /** sl@0: @file sl@0: @internalTechnology sl@0: */ sl@0: sl@0: #ifndef __TPKCS12LIBTESTSTEP01_H__ sl@0: #define __TPKCS12LIBTESTSTEP01_H__ sl@0: sl@0: // System Include sl@0: #include sl@0: sl@0: //User Include sl@0: #include "tpkcs12common.h" sl@0: #include sl@0: sl@0: const TInt KPositiveTest=1; sl@0: const TInt KNegativeTest=0; sl@0: const TInt KBagDataSecBufLen=10; sl@0: const TInt KPrivacyPwdStrLen=17; sl@0: const TInt KContentInfoBufLen=12; sl@0: const TInt KPasswordKeyStrLen=15; sl@0: const TInt KBagDataSectionStrLen=7; sl@0: const TInt KContentInfoKeyStrLen=11; sl@0: const TInt KAttributeBufLen=6; sl@0: const TInt KAttributeKeyStrLen=4; sl@0: const TInt KBagValBufLen=8; sl@0: const TInt KBagValKeyStrLen=5; sl@0: sl@0: _LIT(KFriendlyNameOid,"1.2.840.113549.1.9.20"); sl@0: _LIT(KLocalKeyOid,"1.2.840.113549.1.9.21"); sl@0: _LIT(KMainSec,"main"); sl@0: _LIT(KAuthSafeSec,"authsafe"); sl@0: _LIT(KFilePath,"file"); sl@0: _LIT(KIntegrityMode,"integritymode"); sl@0: _LIT(KUnitTest,"unittest"); sl@0: _LIT(KUnitTestValue,"FALSE"); sl@0: _LIT(KPassword,"password"); sl@0: _LIT(KIntegrityPassword,"integritypassword"); sl@0: _LIT(KIntegrityValid,"integrity_valid"); sl@0: _LIT(KPublicIntegrity,"public"); sl@0: _LIT(KPrivacyPassword,"PrivacyPassword"); sl@0: _LIT(KExpectedResult,"ExpectedResult"); sl@0: _LIT(KVerifyIntgPass,"verifyintegritypassword"); sl@0: _LIT(KMacPresent,"MacPresent"); sl@0: _LIT(KMacValueDefault,"FALSE"); sl@0: _LIT(KMacTestValue,"True"); sl@0: _LIT(KContentInfoKey,"contentinfo"); sl@0: _LIT(KContentInfoNum,"numcontentinfos"); sl@0: _LIT(KBagDataSec,"BagData"); sl@0: _LIT(KBagType,"BagType"); sl@0: _LIT(KSafeBagsCount,"SafeBagsCount"); sl@0: _LIT(KContentInfoType,"ContentInfoType"); sl@0: _LIT(KBagAttributesKey,"attr"); sl@0: _LIT(KBagAttributesNum,"numattributes"); sl@0: _LIT(KBagAttributesID,"id"); sl@0: _LIT(KBagAttributeValuesNum,"numvalues"); sl@0: _LIT(KBagAttributeValue,"value"); sl@0: _LIT(KAlgorithm,"Algorithm"); sl@0: _LIT(KCertType,"CertType"); sl@0: _LIT(KContentInfoPwd,"ContentInfoPrivacyPassword"); sl@0: _LIT(KSafeBagPrivacyPwd,"safeBagprivacypassword"); sl@0: _LIT(KBagValue,"BagValue"); sl@0: _LIT(KEncBagValue,"EncodedBagValue"); sl@0: _LIT(KMac,"Mac"); sl@0: _LIT(KMacSalt,"MacSalt"); sl@0: _LIT(KIterationCount,"IterationCount"); sl@0: _LIT(KIntegrityPwd,"integritypassword"); sl@0: _LIT(KExpectedError,"ExpectedError"); sl@0: sl@0: _LIT(KFriendlyName,"1.2.840.113549.1.9.20"); sl@0: _LIT(KLocalKey,"1.2.840.113549.1.9.21"); sl@0: sl@0: sl@0: /** sl@0: This is a teststep class wherin all the verification for the pkcs12 file sl@0: is done. sl@0: */ sl@0: class CPKCS12LibTestStep : public CTestStep sl@0: { sl@0: public: sl@0: CPKCS12LibTestStep (); sl@0: ~CPKCS12LibTestStep(); sl@0: //From CTestStep class sl@0: TVerdict doTestStepL(); sl@0: sl@0: private: sl@0: TBool ChkCIType(TDesC &aSecName,CSafeBagData &aBagData); sl@0: TBool ChkBagType(TDesC &aSecName,CSafeBagData &aBagData,TInt aBagId); sl@0: TBool ChkBagAttbutesL(TDesC &aSecName,CSafeBagData &aBagData); sl@0: TBool ChkAtrSecL(TDesC &aSec,CSafeBagData &aBagData,TInt aIndx); sl@0: TBool ChkAtrValL(TDesC &aSecName,CSafeBagData &aBagData,TInt aNumVal); sl@0: TBool ChkAlgId(TDesC &aSecName,CSafeBagData &aBagData); sl@0: TBool ChkCertId(TDesC &aSecName,CSafeBagData &aBagData); sl@0: TBool VerifyMainSecL(); sl@0: TBool VerifyAuthSafe(); sl@0: TBool ChkBagDataL(TInt aTotalsafebags,TInt aTotalbags); sl@0: TBool ChkSafeContsBagData(TDesC& aBagSec,CSafeContentBag &aSafeContntBagData); sl@0: TBool ChkBagValL(TDesC &aSecName,CSafeBagData &aBagData); sl@0: TBool ChkMacValueL(); sl@0: TBool CompareFileDataL(TDesC &aPValue,TDesC8 &aBufferVal); sl@0: void ParsePrivacyPwdL(); sl@0: TBool VerifyExpectedError(const TDesC &aSecName); sl@0: TBool ChkEncodedBagValL(TDesC &aSecName,CSafeBagData &aBagData); sl@0: sl@0: private: sl@0: /** privacy password of all the contentinfos in sequence if encrypted */ sl@0: RPointerArrayiPrivacyPassword ; sl@0: /** SafeBagData pointer */ sl@0: CSafeBagData *iBagData; sl@0: /** positive or negative test */ sl@0: TBool iExpectedResult; sl@0: /** flag for checking whether the verification function returns true or false */ sl@0: TBool iActualResult; sl@0: /** Unit test value */ sl@0: TBool iUnitTest; sl@0: /** BagAttribute Value */ sl@0: TInt iBagAttrNumVal; sl@0: /** Argument error. */ sl@0: TInt iExpectedError; sl@0: /** ContentData is Set 0, if the contentData is absent. */ sl@0: TInt iContentDataPresent; sl@0: /** PKCS12Parser object */ sl@0: CPkcs12Parser *iParser; sl@0: /** File server object */ sl@0: RFs iFileSession; sl@0: /** Set to True/False depending on the verification of the error. */ sl@0: TBool iUnitTestContinueFlag; sl@0: sl@0: }; sl@0: sl@0: /** sl@0: This is a teststep class wherin all the OOM Test for the pkcs12 library sl@0: is done. sl@0: */ sl@0: class CTPKCS12OOMStep : public CTestStep sl@0: { sl@0: public: sl@0: CTPKCS12OOMStep (); sl@0: ~CTPKCS12OOMStep(); sl@0: // From CTestStep class sl@0: TVerdict doTestStepPreambleL(); sl@0: TVerdict doTestStepL(); sl@0: private: sl@0: HBufC8* ReadFileDataL(TPtrC tag); sl@0: protected: sl@0: /** contains the data */ sl@0: HBufC8* iRawData; sl@0: /** contains the authsafe data */ sl@0: HBufC8* iAuthSafeData; sl@0: /** File server object */ sl@0: RFs iFs; sl@0: }; sl@0: sl@0: _LIT(KStep, "PKCS12LibTestStep"); sl@0: _LIT(KTPKCS12OOMStep,"PKCS12OOMTestStep"); sl@0: sl@0: #endif