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