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