os/security/cryptoservices/certificateandkeymgmt/tpkcs7/tcmsstep.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 /*
     2 * Copyright (c) 2006-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 *
    16 */
    17 
    18 
    19 /**
    20  @file 
    21  @internalTechnology
    22 */
    23 
    24 #ifndef TCMSSTEP_H
    25 #define TCMSSTEP_H
    26 
    27 #include <test/testexecutestepbase.h>
    28 #include "tpkcs7server.h"
    29 #include <x509cert.h>
    30 #include <cmssignerinfo.h>
    31 
    32 
    33 class CDecPKCS8Data;
    34 class MPKCS8DecodedKeyPairData;
    35 class CRSAPrivateKey;
    36 class CDSAPrivateKey;
    37 class CMessageDigest;
    38 class CASN1EncBase;
    39 class CCmsSignedObject;
    40 class CEncapsulatedContentInfo;
    41 class CCmsSignerInfo;
    42 
    43 
    44 /**
    45 The base class for testing CMS data types
    46 */
    47 class CTCmsBaseStep : public CTestStep
    48 	{
    49 public:
    50 	CTCmsBaseStep();
    51 	~CTCmsBaseStep();
    52 	TVerdict doTestStepL();
    53 	TVerdict doTestStepPreambleL();
    54 	
    55 protected:
    56 	HBufC8*	readFileL (TPtrC tag);
    57 	HBufC8* CreateDEREncodingLC(const CASN1EncBase& aEncoding);
    58 	void OutputResultToFileL(const TDesC8& aSignature);
    59 	TVerdict doOOMTestL();
    60 	virtual void doTestL() = 0;
    61 	TInt CovertContentDataTypeNameToDataType(const TDesC& aDataTypeName);
    62 	
    63 protected:
    64 	RFs	iFs;
    65 	HBufC8*	iDataContent;
    66 	TInt iExpectedDataType;
    67 	HBufC8* iExpectedEncoding;
    68 	TInt iExpectedResult;
    69 	TBool iIsOOMTest;		
    70 	};
    71 
    72 /**
    73 The class for testing CMS Content Info
    74 */
    75 class CTCmsContentInfoDecodingStep : public CTCmsBaseStep
    76 	{
    77 public:
    78 	CTCmsContentInfoDecodingStep();
    79 	~CTCmsContentInfoDecodingStep();
    80 	void doTestL();		
    81 	};
    82 
    83 /**
    84 The class for testing CMS data type
    85 */
    86 class CTCmsDataStep : public CTCmsBaseStep
    87 	{
    88 public:
    89 	CTCmsDataStep();
    90 	~CTCmsDataStep();
    91 	void doTestL();
    92 protected:
    93 	void DecodingAndCheckL(TDesC8& aRawData);
    94 	};
    95 
    96 /**
    97 The class for testing CMS data type Decoding
    98 */
    99 class CTCmsDataDecodingStep : public CTCmsDataStep
   100 	{
   101 public:
   102 	CTCmsDataDecodingStep();
   103 	~CTCmsDataDecodingStep();
   104 	void doTestL();
   105 	};
   106 
   107 /**
   108 The base class for testing CMS signed data and PKCS7 signed data
   109 encoding, decoding and validation. OOM test is configurable in this
   110 test base step
   111 */
   112 class CTSignedDataBaseStep : public CTCmsBaseStep
   113 	{
   114 public:
   115 	CTSignedDataBaseStep();
   116 	~CTSignedDataBaseStep();
   117 	TVerdict doTestStepPreambleL();
   118 	
   119 protected:
   120 	CMessageDigest* CreateHashLC(TAlgorithmId aAlgorithmId);
   121 	TInt CovertHashNameToAlgorithmId(const TDesC& aHashName);
   122 	TInt CovertCertificateNameToCertificateType(const TDesC& aCertificateName);
   123 	
   124 protected:	
   125 	RPointerArray<CDecPKCS8Data> iDecPKCS8Data;
   126 	RPointerArray<CX509Certificate> iCertificates;
   127 	RArray<TInt> iSignerInfoVersion;
   128 	RArray<TInt> iHashName;
   129 	RArray<TBool> iValidateResults;
   130 	RArray<TBool> iSignedAttributePresent;
   131 	RArray<TBool> iUnSignedAttributePresent;
   132 	TInt iContentType;
   133 	TBool iIsHashAvailable;
   134 	TBool iIsDetached;
   135 	TBool iTwoStepCreation;
   136 	TBool iRsaAlgorithm;
   137 	TBool iCertificateSetPresent;
   138 	TBool iCRLsSetPresent;
   139 	TInt iSignedDataVersion;
   140 	TInt iAlgorithmCount;
   141 	TInt iCertsCount;
   142 	TInt iSignerCount;
   143 	CX509Certificate* iRootCertificate;
   144 	CX509Certificate* iAdditionalCertificate;
   145 	TBool iNoCertSet;
   146 	TBool iValidateUsingUserCerts;
   147 	TBool iNoSigning;
   148 	TInt iAdditionalEncodedCertificateType;
   149 	HBufC8* iAdditionalEncodedCertificate;
   150 	TBool iNoValidationTest;
   151 	TBool iValidationDetachedWithoutInput;
   152 	};
   153 
   154 /**
   155 The class test encoding, decoding and validation of the CMS signed data object
   156 */
   157 class CTCmsSignedDataStep : public CTSignedDataBaseStep
   158 	{
   159 public:
   160 	CTCmsSignedDataStep();
   161 	~CTCmsSignedDataStep();
   162 	void doTestL();
   163 	
   164 protected:
   165 	void CheckAndValidateSignedDataL(TDesC8& aRawData);
   166 	void CheckSignedDataFieldsL(const CCmsSignedObject& aSignedData);
   167 	void CheckEncapsulatedContentFieldsL(const CEncapsulatedContentInfo& encapContentInfo);
   168 	void CheckAlgorithmSetFieldsL(const RPointerArray<CX509AlgorithmIdentifier>& aAlgorithms);
   169 	void CheckCertificateSetFieldsL(const CCmsSignedObject& aSignedData);
   170 	void CheckSignerInfoFieldsL(const RPointerArray<CCmsSignerInfo>& signerInfos);
   171 	};
   172 
   173 /**
   174 The class test decoding and validation of the CMS signed data object
   175 */
   176 class CTCmsSignedDataDecodingStep : public CTCmsSignedDataStep
   177 	{
   178 public:
   179 	CTCmsSignedDataDecodingStep();
   180 	~CTCmsSignedDataDecodingStep();
   181 	void doTestL();
   182 	};
   183 
   184 #endif //TCMSSTEP_H