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