|
1 /* |
|
2 * Copyright (c) 2004 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 "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: CMS AuthenticatedData type |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef CCMSAuthenticatedData_H |
|
21 #define CCMSAuthenticatedData_H |
|
22 |
|
23 // INCLUDES |
|
24 #include "CCMSSequence.h" |
|
25 #include "CCMSEncapsulatedContentInfo.h" |
|
26 #include "CCMSX509AlgorithmIdentifier.h" |
|
27 #include <badesca.h> |
|
28 |
|
29 // FORWARD DECLARATIONS |
|
30 // Extension |
|
31 |
|
32 class MCMSAuthenticatedDataExtension; |
|
33 class CCMSOriginatorInfo; |
|
34 class CCMSRecipientInfo; |
|
35 class CCMSAttribute; |
|
36 class CCMSCertificateChoices; |
|
37 class CCMSX509CertificateList; |
|
38 |
|
39 // CLASS DECLARATION |
|
40 /** |
|
41 * AuthenticatedData type module |
|
42 * |
|
43 * ASN.1 Definition: |
|
44 * |
|
45 * AuthenticatedData ::= SEQUENCE { |
|
46 * version CMSVersion, |
|
47 * originatorInfo [0] IMPLICIT OriginatorInfo OPTIONAL, |
|
48 * recipientInfos RecipientInfos, |
|
49 * macAlgorithm MessageAuthenticationCodeAlgorithm, |
|
50 * digestAlgorithm [1] DigestAlgorithmIdentifier OPTIONAL, |
|
51 * encapContentInfo EncapsulatedContentInfo, |
|
52 * authenticatedAttributes [2] IMPLICIT AuthAttributes OPTIONAL, |
|
53 * mac MessageAuthenticationCode, |
|
54 * unauthenticatedAttributes [3] IMPLICIT UnauthAttributes OPTIONAL } |
|
55 * |
|
56 * AuthAttributes ::= SET SIZE (1..MAX) OF Attribute |
|
57 * UnauthAttributes ::= SET SIZE (1..MAX) OF Attribute |
|
58 * |
|
59 * RecipientInfos ::= SET OF RecipientInfo |
|
60 * |
|
61 * MessageAuthenticationCode ::= OCTET STRING |
|
62 * |
|
63 * MessageAuthenticationCodeAlgorithm ::= AlgorithmIdentifier |
|
64 * DigestAlgorithmIdentifier ::= AlgorithmIdentifier |
|
65 * |
|
66 * @lib cms.lib |
|
67 * @since 3.0 |
|
68 */ |
|
69 class CCMSAuthenticatedData : public CCMSSequence |
|
70 { |
|
71 private: |
|
72 /** |
|
73 * Container for the actual data |
|
74 */ |
|
75 NONSHARABLE_CLASS( CAuthenticatedDataData ) : public CBase |
|
76 { |
|
77 public: // destructor |
|
78 ~CAuthenticatedDataData(); |
|
79 |
|
80 public: // data |
|
81 // version |
|
82 TInt iVersion; |
|
83 |
|
84 // originatorInfo, owned |
|
85 CCMSOriginatorInfo* iOriginatorInfo; |
|
86 |
|
87 // recipientInfos, owned |
|
88 CArrayPtr< CCMSRecipientInfo >* iRecipientInfos; |
|
89 |
|
90 // macAlgorithm, owned |
|
91 CCMSX509AlgorithmIdentifier* iMacAlgorithm; |
|
92 |
|
93 // digestAlgorithm, owned |
|
94 CCMSX509AlgorithmIdentifier* iDigestAlgorithm; |
|
95 |
|
96 // encapContentInfo, owned |
|
97 CCMSEncapsulatedContentInfo* iEncapContentInfo; |
|
98 |
|
99 // authenticatedAttributes, owned |
|
100 CArrayPtr< CCMSAttribute >* iAuthenticatedAttributes; |
|
101 |
|
102 // mac, owned |
|
103 HBufC8* iMac; |
|
104 |
|
105 // unauthenticatedAttributes, owned |
|
106 CArrayPtr< CCMSAttribute >* iUnauthenticatedAttributes; |
|
107 |
|
108 }; |
|
109 |
|
110 public: // Constructors and destructor |
|
111 /** |
|
112 * Two-phased constructor. |
|
113 * NOTE: Encrypt will leave with KErrArgument if |
|
114 * valid parameters are not set. |
|
115 */ |
|
116 IMPORT_C static CCMSAuthenticatedData* NewLC(); |
|
117 |
|
118 /** |
|
119 * Two-phased constructor. |
|
120 * Takes ownership of all parameters, except aMac which is copied. |
|
121 * Leaves newly created instance in CleanupStack |
|
122 */ |
|
123 IMPORT_C static CCMSAuthenticatedData* NewLC( |
|
124 CArrayPtr< CCMSRecipientInfo >* aRecipientInfos, |
|
125 CCMSX509AlgorithmIdentifier* aMacAlgorithm, |
|
126 CCMSEncapsulatedContentInfo* aEncapContentInfo, |
|
127 const TDesC8& aMac ); |
|
128 |
|
129 /** |
|
130 * Destructor. |
|
131 */ |
|
132 virtual ~CCMSAuthenticatedData(); |
|
133 |
|
134 public: // New functions |
|
135 /** |
|
136 * Getter for version |
|
137 * @since 3.0 |
|
138 * @return CMSVersion |
|
139 */ |
|
140 IMPORT_C TInt Version() const; |
|
141 |
|
142 /** |
|
143 * Getter for originatorInfo |
|
144 * @since 3.0 |
|
145 * @return OriginatorInfo or NULL |
|
146 */ |
|
147 IMPORT_C const CCMSOriginatorInfo* OriginatorInfo() const; |
|
148 |
|
149 /** |
|
150 * Getter for recipientInfos. |
|
151 * @since 3.0 |
|
152 * @return array of RecipientInfos |
|
153 */ |
|
154 IMPORT_C const CArrayPtr< CCMSRecipientInfo >& RecipientInfos() const; |
|
155 |
|
156 /** |
|
157 * Getter for macAlgorithm. |
|
158 * @since 3.0 |
|
159 * @return MessageAuthenticationCodeAlgorithm |
|
160 */ |
|
161 IMPORT_C const CCMSX509AlgorithmIdentifier& MacAlgorithm() const; |
|
162 |
|
163 /** |
|
164 * Getter for digestAlgorithm |
|
165 * @since 3.0 |
|
166 * @return DigestAlgorithmIdentifier or NULL |
|
167 */ |
|
168 IMPORT_C const CCMSX509AlgorithmIdentifier* DigestAlgorithm() const; |
|
169 |
|
170 /** |
|
171 * Getter for encapContentInfo |
|
172 * @since 3.0 |
|
173 * @return EncapsulatedContentInfo |
|
174 */ |
|
175 IMPORT_C const CCMSEncapsulatedContentInfo& EncapContentInfo() const; |
|
176 |
|
177 /** |
|
178 * Getter for authenticatedAttributes |
|
179 * @since 3.0 |
|
180 * @return array of Attributes or NULL |
|
181 */ |
|
182 IMPORT_C const CArrayPtr< CCMSAttribute >* |
|
183 AuthenticatedAttributes() const; |
|
184 |
|
185 /** |
|
186 * Getter for mac |
|
187 * @since 3.0 |
|
188 * @return MessageAuthenticationCode |
|
189 */ |
|
190 IMPORT_C const TDesC8& Mac() const; |
|
191 |
|
192 /** |
|
193 * Getter for unauthenticatedAttributes |
|
194 * @since 3.0 |
|
195 * @return array of Attributes or NULL |
|
196 */ |
|
197 IMPORT_C const CArrayPtr< CCMSAttribute >* |
|
198 UnauthenticatedAttributes() const; |
|
199 |
|
200 /** |
|
201 * Setter for version. Default value is 0. |
|
202 * @since 3.0 |
|
203 * @param aVersion CMSVersion value |
|
204 */ |
|
205 IMPORT_C void SetVersion( TInt aVersion ); |
|
206 |
|
207 /** |
|
208 * Setter for originatorInfo. Takes ownership. |
|
209 * @since 3.0 |
|
210 * @param aOriginatorInfo OriginatorInfo |
|
211 */ |
|
212 IMPORT_C void SetOriginatorInfoL( |
|
213 CCMSOriginatorInfo* aOriginatorInfo ); |
|
214 |
|
215 /** |
|
216 * Setter for recipientInfos. Takes ownership. |
|
217 * @since 3.0 |
|
218 * @param aRecipientInfos array of RecipientInfos. There must |
|
219 * be at least one element in the array, otherwise thois |
|
220 * method will leave with KErrArgument |
|
221 */ |
|
222 IMPORT_C void SetRecipientInfosL( |
|
223 CArrayPtr< CCMSRecipientInfo >* aRecipientInfos ); |
|
224 |
|
225 /** |
|
226 * Setter for macAlgorithm. Takes ownership. |
|
227 * @since 3.0 |
|
228 * @param aMacAlgorithm MessageAuthenticationCodeAlgorithm. If |
|
229 * this parameter is null, this method leaves with KErrArgument. |
|
230 */ |
|
231 IMPORT_C void SetMacAlgorithmL( |
|
232 CCMSX509AlgorithmIdentifier* aMacAlgorithm ); |
|
233 |
|
234 /** |
|
235 * Setter for digestAlgorithm. Takes ownership. |
|
236 * @since 3.0 |
|
237 * @param aDigestAlgorithm DigestAlgorithmIdentifier |
|
238 */ |
|
239 IMPORT_C void SetDigestAlgorithmL( |
|
240 CCMSX509AlgorithmIdentifier* aDigestAlgorithm ); |
|
241 |
|
242 |
|
243 /** |
|
244 * Setter for encapContentInfo. Takes ownership. |
|
245 * @since 3.0 |
|
246 * @param aEncapContentInfo EncapsulatedContentInfo. If this |
|
247 * parameter is NULL, this method will leave with KErrArgument. |
|
248 */ |
|
249 IMPORT_C void SetEncapContentInfoL( |
|
250 CCMSEncapsulatedContentInfo* aEncapContentInfo ); |
|
251 |
|
252 /** |
|
253 * Setter for authenticatedAttributes. Takes ownership. |
|
254 * @since 3.0 |
|
255 * @param aAuthenticatedAttributes array of attributes. |
|
256 */ |
|
257 IMPORT_C void SetAuthenticatedAttributesL( |
|
258 CArrayPtr< CCMSAttribute >* aAuthenticatedAttributes ); |
|
259 |
|
260 /** |
|
261 * Setter for mac. Creates a copy. |
|
262 * @since 3.0 |
|
263 * @param aMac MessageAuthenticationCode |
|
264 */ |
|
265 IMPORT_C void SetMacL( const TDesC8& aMac ); |
|
266 |
|
267 /** |
|
268 * Setter for unauthenticatedAttributes. Takes ownership. |
|
269 * @since 3.0 |
|
270 * @param aUnuthenticatedAttributes array of attributes. |
|
271 */ |
|
272 IMPORT_C void SetUnauthenticatedAttributesL( |
|
273 CArrayPtr< CCMSAttribute >* aUnauthenticatedAttributes ); |
|
274 |
|
275 public: // Functions from base classes |
|
276 |
|
277 /** |
|
278 * From MCMSModule |
|
279 * @since 3.0 |
|
280 * @param aRawData raw-data to be parsed in this instance |
|
281 */ |
|
282 void DecodeL( const TDesC8& aRawData ); |
|
283 |
|
284 /** |
|
285 * From MCMSModule |
|
286 * @since 3.0 |
|
287 * @return Returns ASN1 encoder and leaves it in CleanupStack |
|
288 */ |
|
289 CASN1EncBase* EncoderLC() const; |
|
290 |
|
291 protected: // New functions |
|
292 |
|
293 /** |
|
294 * Protected construction to allow derivation |
|
295 */ |
|
296 IMPORT_C void ConstructL(); |
|
297 |
|
298 /** |
|
299 * Protected construction to allow derivation |
|
300 */ |
|
301 IMPORT_C void ConstructL( |
|
302 CArrayPtr< CCMSRecipientInfo >* aRecipientInfos, |
|
303 CCMSX509AlgorithmIdentifier* aMacAlgorithm, |
|
304 CCMSEncapsulatedContentInfo* aEncapContentInfo, |
|
305 const TDesC8& aMac ); |
|
306 |
|
307 /** |
|
308 * C++ default constructor. |
|
309 */ |
|
310 IMPORT_C CCMSAuthenticatedData(); |
|
311 |
|
312 private: // New functions |
|
313 |
|
314 /** |
|
315 * Decodes an attribute sequence. |
|
316 */ |
|
317 CArrayPtrFlat< CCMSAttribute >* DecodeAttributesL( |
|
318 TASN1DecGeneric* aAttributesDec ); |
|
319 |
|
320 private: // Data |
|
321 // Contains the actual data, ownedw |
|
322 CAuthenticatedDataData* iData; |
|
323 |
|
324 // Reserved for extensions |
|
325 MCMSAuthenticatedDataExtension* iReserved; |
|
326 |
|
327 }; |
|
328 |
|
329 #endif // CCMSAuthenticatedData_H |
|
330 |
|
331 // End of File |