os/security/cryptoservices/certificateandkeymgmt/tpkcs10/tcertrequeststep.h
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/security/cryptoservices/certificateandkeymgmt/tpkcs10/tcertrequeststep.h	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,167 @@
     1.4 +/*
     1.5 +* Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.6 +* All rights reserved.
     1.7 +* This component and the accompanying materials are made available
     1.8 +* under the terms of the License "Eclipse Public License v1.0"
     1.9 +* which accompanies this distribution, and is available
    1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.11 +*
    1.12 +* Initial Contributors:
    1.13 +* Nokia Corporation - initial contribution.
    1.14 +*
    1.15 +* Contributors:
    1.16 +*
    1.17 +* Description: 
    1.18 +* Declares test step classes for positive cases of PKCS#10 tests.
    1.19 +*
    1.20 +*/
    1.21 +
    1.22 +
    1.23 +/**
    1.24 + @file
    1.25 + @internalTechnology
    1.26 +*/
    1.27 +
    1.28 +#include <f32file.h> 
    1.29 +#include <x500dn.h>
    1.30 +#include <x509keys.h>
    1.31 +#include <pkcs10.h>  
    1.32 +#include <pkcs10attr.h> 
    1.33 +#include <pkcs9attr.h>
    1.34 +#include <unifiedkeystore.h>
    1.35 +#include <asn1dec.h>
    1.36 +#include <asn1enc.h>
    1.37 +#include <hash.h>
    1.38 +#include <e32const.h>
    1.39 +
    1.40 +#if (!defined __CERTIFICATEREQUEST_STEP_H__)
    1.41 +#define __CERTIFICATEREQUEST_STEP_H__
    1.42 +#include <test/testexecutestepbase.h>
    1.43 +#include "tpkcs10stepbasev2.h"
    1.44 +
    1.45 +_LIT(KCertificateRequestStep,"PKCS10CertRequest");
    1.46 +
    1.47 +// forward declarations:
    1.48 +class CCertificateRequestStep;
    1.49 +
    1.50 +class CPKCS10TesterActive : public CActive
    1.51 +	{
    1.52 +public:
    1.53 +	CPKCS10TesterActive( CTestExecuteLogger& aLogger );
    1.54 +	~CPKCS10TesterActive();
    1.55 +
    1.56 +	TVerdict doActiveCertRequestL(CCertificateRequestStep* aStep);
    1.57 +	
    1.58 +	//Active
    1.59 +	void DoCancel()	{return; };
    1.60 +	void RunL();
    1.61 +	virtual TInt RunError(TInt aError);
    1.62 +	// Generic
    1.63 +	
    1.64 +	void 					AddGenericAttributesL();
    1.65 +	void 					AddChallengePasswordL();
    1.66 +	void 					AddV3ExtensionsL();
    1.67 +	void					DeleteAllKeysL();
    1.68 +	CX500DistinguishedName* MakeDistinguishedNameL();
    1.69 +	TVerdict 				verifyCertReqEncodingL();
    1.70 +	TBool 					CompareRequestToOPENSSLReqL();
    1.71 +    public:
    1.72 +
    1.73 +	CTestExecuteLogger& Logger(){return iLogger;}
    1.74 +	//Log buffer
    1.75 +	TBuf<150> iLogInfo;
    1.76 +    CTestExecuteLogger& iLogger;
    1.77 +    CCertificateRequestStep* 	iStepPointer;	
    1.78 +    CUnifiedKeyStore*			iKeyStore;
    1.79 + 	HBufC8*						iKeyData;
    1.80 + 	CCTKeyInfo*					iKeyInfo;
    1.81 + 	CPKCS10Request*        		iCertRequest;
    1.82 + 	CX500DistinguishedName*		iDN;
    1.83 + 	CPKCS10Attributes*     		iAttrCollection;
    1.84 +    CPKCS9ExtensionRequestAttr* iV3ExtensionsCollection;
    1.85 +	TInt   						iError;	
    1.86 +	HBufC8*				        iOutputASN1Encoding;
    1.87 +	HBufC8*				        iSecondOutputASN1Encoding;
    1.88 +	TVerdict                    iTestSuccess;
    1.89 +	RMPointerArray<CCTKeyInfo>	iKeys;
    1.90 +   	TCTKeyAttributeFilter		iKeyFilter;
    1.91 +	TInt						iRunError;
    1.92 +   
    1.93 +  
    1.94 +     RFs iFs;
    1.95 +            
    1.96 +	     enum EState
    1.97 +		{
    1.98 +			EIdle,
    1.99 +			// Delete all keys
   1.100 +			EDeleteAllInit,
   1.101 +			EDeleteAllDelete,
   1.102 +
   1.103 +			// Main test
   1.104 +			EInitKeyStore,
   1.105 +			EKeyPolicy,
   1.106 +			EImportKey,
   1.107 +			EGenerateCertRequest,
   1.108 +			EGenerateSecondCertRequest,	
   1.109 +			EDeleteKey
   1.110 +		};  
   1.111 +     
   1.112 +     EState					iState;
   1.113 +    
   1.114 +	} ;
   1.115 +	
   1.116 +class CCertificateRequestStep : public CTPKCS10StepBase
   1.117 +	{                                  
   1.118 +public:
   1.119 +	CCertificateRequestStep();
   1.120 +	~CCertificateRequestStep();
   1.121 +	virtual TVerdict doTestStepPreambleL(); 
   1.122 +	virtual TVerdict doTestStepL();
   1.123 +	virtual TVerdict doTestStepPostambleL(); 
   1.124 + 	virtual TVerdict doOOMTestL();
   1.125 +	virtual void doTestL();
   1.126 +	
   1.127 +	TAlgorithmId ConvertNameToDigestId(const TDesC& aHashName);
   1.128 +	TInt ConvertNameToEKeyAlgorithm(const TDesC& aName);
   1.129 +	void OutputEncodingToFileL(const TDesC8& aEncoding);
   1.130 + 	TBool IsMatchingEncodingL(CASN1EncBase* aASN1Enc1, CASN1EncBase* aASN1Enc2);
   1.131 +
   1.132 +public:
   1.133 +    RFs	  iFs;
   1.134 +    TBool iOOMCondition;
   1.135 +	TInt  iExpectedError;
   1.136 +	TPtrC iDN_country;
   1.137 +	TPtrC iDN_state;
   1.138 +	TPtrC iDN_locality; 
   1.139 +	TPtrC iDN_organization;
   1.140 +	TPtrC iDN_unit;
   1.141 +	TPtrC iDN_common;
   1.142 +	TPtrC iDN_email;
   1.143 +	TPtrC iPrivateKey;
   1.144 +	TPtrC iOPENSSLCertReq;
   1.145 +	TPtrC iKeyAlg;
   1.146 +	TPtrC iChallengePassword;
   1.147 +	TPtrC iDigestAlg;
   1.148 +	TInt  iElemCertReqCount;
   1.149 +	TInt  iElemCertInfoCount;
   1.150 +	TInt  iCertReqVer;
   1.151 +	TInt  iElemSubPubKeytInfoCount;
   1.152 +	TInt  iElemKeyAlgIdenCount;
   1.153 +    TInt  iElemSigAlgIdenCount;
   1.154 +    TInt  iAttribute_count;
   1.155 +    CPKCS10TesterActive* 		iActiveObjTest;
   1.156 +    CActiveScheduler* 			iSched;
   1.157 +	RArray<TPtrC> 				iArrayGenAttrOID;
   1.158 +	RArray<TPtrC> 				iArrayGenAttrValue;	
   1.159 +	RArray<TPtrC> 				iArrayV3AttrOID;
   1.160 +	RArray<TBool> 				iArrayV3AttrCritical;
   1.161 +	RArray<TPtrC> 				iArrayV3AttrValue;
   1.162 +
   1.163 +	TBool 						iGenerateSecondRequest;
   1.164 +	TBool 						iRepopulateDataRequest;
   1.165 +	TInt   						iError;	
   1.166 +	
   1.167 +	};
   1.168 +
   1.169 +
   1.170 +#endif