cryptoservices/certificateandkeymgmt/tpkcs10/tcertrequeststep.h
changeset 0 2c201484c85f
child 8 35751d3474b7
equal deleted inserted replaced
-1:000000000000 0:2c201484c85f
       
     1 /*
       
     2 * Copyright (c) 2007-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 * Declares test step classes for positive cases of PKCS#10 tests.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 /**
       
    23  @file
       
    24  @internalTechnology
       
    25 */
       
    26 
       
    27 #include <f32file.h> 
       
    28 #include <x500dn.h>
       
    29 #include <x509keys.h>
       
    30 #include <pkcs10.h>  
       
    31 #include <pkcs10attr.h> 
       
    32 #include <pkcs9attr.h>
       
    33 #include <unifiedkeystore.h>
       
    34 #include <asn1dec.h>
       
    35 #include <asn1enc.h>
       
    36 #include <hash.h>
       
    37 #include <e32const.h>
       
    38 
       
    39 #if (!defined __CERTIFICATEREQUEST_STEP_H__)
       
    40 #define __CERTIFICATEREQUEST_STEP_H__
       
    41 #include <testexecutestepbase.h>
       
    42 #include "tpkcs10stepbasev2.h"
       
    43 
       
    44 _LIT(KCertificateRequestStep,"PKCS10CertRequest");
       
    45 
       
    46 // forward declarations:
       
    47 class CCertificateRequestStep;
       
    48 
       
    49 class CPKCS10TesterActive : public CActive
       
    50 	{
       
    51 public:
       
    52 	CPKCS10TesterActive( CTestExecuteLogger& aLogger );
       
    53 	~CPKCS10TesterActive();
       
    54 
       
    55 	TVerdict doActiveCertRequestL(CCertificateRequestStep* aStep);
       
    56 	
       
    57 	//Active
       
    58 	void DoCancel()	{return; };
       
    59 	void RunL();
       
    60 	virtual TInt RunError(TInt aError);
       
    61 	// Generic
       
    62 	
       
    63 	void 					AddGenericAttributesL();
       
    64 	void 					AddChallengePasswordL();
       
    65 	void 					AddV3ExtensionsL();
       
    66 	void					DeleteAllKeysL();
       
    67 	CX500DistinguishedName* MakeDistinguishedNameL();
       
    68 	TVerdict 				verifyCertReqEncodingL();
       
    69 	TBool 					CompareRequestToOPENSSLReqL();
       
    70     public:
       
    71 
       
    72 	CTestExecuteLogger& Logger(){return iLogger;}
       
    73 	//Log buffer
       
    74 	TBuf<150> iLogInfo;
       
    75     CTestExecuteLogger& iLogger;
       
    76     CCertificateRequestStep* 	iStepPointer;	
       
    77     CUnifiedKeyStore*			iKeyStore;
       
    78  	HBufC8*						iKeyData;
       
    79  	CCTKeyInfo*					iKeyInfo;
       
    80  	CPKCS10Request*        		iCertRequest;
       
    81  	CX500DistinguishedName*		iDN;
       
    82  	CPKCS10Attributes*     		iAttrCollection;
       
    83     CPKCS9ExtensionRequestAttr* iV3ExtensionsCollection;
       
    84 	TInt   						iError;	
       
    85 	HBufC8*				        iOutputASN1Encoding;
       
    86 	HBufC8*				        iSecondOutputASN1Encoding;
       
    87 	TVerdict                    iTestSuccess;
       
    88 	RMPointerArray<CCTKeyInfo>	iKeys;
       
    89    	TCTKeyAttributeFilter		iKeyFilter;
       
    90 	TInt						iRunError;
       
    91    
       
    92   
       
    93      RFs iFs;
       
    94             
       
    95 	     enum EState
       
    96 		{
       
    97 			EIdle,
       
    98 			// Delete all keys
       
    99 			EDeleteAllInit,
       
   100 			EDeleteAllDelete,
       
   101 
       
   102 			// Main test
       
   103 			EInitKeyStore,
       
   104 			EKeyPolicy,
       
   105 			EImportKey,
       
   106 			EGenerateCertRequest,
       
   107 			EGenerateSecondCertRequest,	
       
   108 			EDeleteKey
       
   109 		};  
       
   110      
       
   111      EState					iState;
       
   112     
       
   113 	} ;
       
   114 	
       
   115 class CCertificateRequestStep : public CTPKCS10StepBase
       
   116 	{                                  
       
   117 public:
       
   118 	CCertificateRequestStep();
       
   119 	~CCertificateRequestStep();
       
   120 	virtual TVerdict doTestStepPreambleL(); 
       
   121 	virtual TVerdict doTestStepL();
       
   122 	virtual TVerdict doTestStepPostambleL(); 
       
   123  	virtual TVerdict doOOMTestL();
       
   124 	virtual void doTestL();
       
   125 	
       
   126 	TAlgorithmId ConvertNameToDigestId(const TDesC& aHashName);
       
   127 	TInt ConvertNameToEKeyAlgorithm(const TDesC& aName);
       
   128 	void OutputEncodingToFileL(const TDesC8& aEncoding);
       
   129  	TBool IsMatchingEncodingL(CASN1EncBase* aASN1Enc1, CASN1EncBase* aASN1Enc2);
       
   130 
       
   131 public:
       
   132     RFs	  iFs;
       
   133     TBool iOOMCondition;
       
   134 	TInt  iExpectedError;
       
   135 	TPtrC iDN_country;
       
   136 	TPtrC iDN_state;
       
   137 	TPtrC iDN_locality; 
       
   138 	TPtrC iDN_organization;
       
   139 	TPtrC iDN_unit;
       
   140 	TPtrC iDN_common;
       
   141 	TPtrC iDN_email;
       
   142 	TPtrC iPrivateKey;
       
   143 	TPtrC iOPENSSLCertReq;
       
   144 	TPtrC iKeyAlg;
       
   145 	TPtrC iChallengePassword;
       
   146 	TPtrC iDigestAlg;
       
   147 	TInt  iElemCertReqCount;
       
   148 	TInt  iElemCertInfoCount;
       
   149 	TInt  iCertReqVer;
       
   150 	TInt  iElemSubPubKeytInfoCount;
       
   151 	TInt  iElemKeyAlgIdenCount;
       
   152     TInt  iElemSigAlgIdenCount;
       
   153     TInt  iAttribute_count;
       
   154     CPKCS10TesterActive* 		iActiveObjTest;
       
   155     CActiveScheduler* 			iSched;
       
   156 	RArray<TPtrC> 				iArrayGenAttrOID;
       
   157 	RArray<TPtrC> 				iArrayGenAttrValue;	
       
   158 	RArray<TPtrC> 				iArrayV3AttrOID;
       
   159 	RArray<TBool> 				iArrayV3AttrCritical;
       
   160 	RArray<TPtrC> 				iArrayV3AttrValue;
       
   161 
       
   162 	TBool 						iGenerateSecondRequest;
       
   163 	TBool 						iRepopulateDataRequest;
       
   164 	TInt   						iError;	
       
   165 	
       
   166 	};
       
   167 
       
   168 
       
   169 #endif