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