|
1 /* |
|
2 * Copyright (c) 2002 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: ?Description |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef CCMSSignerInfo_H |
|
21 #define CCMSSignerInfo_H |
|
22 |
|
23 // INCLUDES |
|
24 #include "CCMSSequence.h" |
|
25 #include "CCMSIssuerAndSerialNumber.h" |
|
26 #include "CCMSAttribute.h" |
|
27 #include "CCMSX509AlgorithmIdentifier.h" |
|
28 #include "CCMSX509Certificate.h" |
|
29 |
|
30 #include <badesca.h> |
|
31 |
|
32 // FORWARD DECLARATIONS |
|
33 class CASN1EncBase; |
|
34 // Extension |
|
35 class MCMSSignerInfoExtension; |
|
36 |
|
37 |
|
38 // CLASS DECLARATION |
|
39 /** |
|
40 * SignerInfo module |
|
41 * |
|
42 * SignerInfo ::= SEQUENCE { |
|
43 * version CMSVersion, |
|
44 * sid SignerIdentifier, |
|
45 * digestAlgorithm DigestAlgorithmIdentifier, |
|
46 * signedAttrs [0] IMPLICIT SignedAttributes OPTIONAL, |
|
47 * signatureAlgorithm SignatureAlgorithmIdentifier, |
|
48 * signature SignatureValue, |
|
49 * unsignedAttrs [1] IMPLICIT UnsignedAttributes OPTIONAL } |
|
50 * |
|
51 * SignerIdentifier ::= CHOICE { |
|
52 * issuerAndSerialNumber IssuerAndSerialNumber, |
|
53 * subjectKeyIdentifier [0] SubjectKeyIdentifier } |
|
54 * |
|
55 * @lib cms.lib |
|
56 * @since 2.8 |
|
57 */ |
|
58 class CCMSSignerInfo : public CCMSSequence |
|
59 { |
|
60 private: |
|
61 /* |
|
62 * Container for signer info data |
|
63 */ |
|
64 NONSHARABLE_CLASS( CSignerInfoData ) : public CBase |
|
65 { |
|
66 public: // Destructor |
|
67 ~CSignerInfoData(); |
|
68 public: // data |
|
69 // version |
|
70 TInt iVersion; |
|
71 |
|
72 // Issuer and serial, owned |
|
73 CCMSIssuerAndSerialNumber* iIssuerAndSerial; |
|
74 |
|
75 // Subject Key ID, owned |
|
76 HBufC8* iSubjectKeyIdentifier; |
|
77 |
|
78 // Signed attributes, owned |
|
79 CArrayPtrFlat<CCMSAttribute>* iSignedAttributes; |
|
80 // Unsigned attribute, owned |
|
81 CArrayPtrFlat<CCMSAttribute>* iUnsignedAttributes; |
|
82 |
|
83 // Digested algorithm identifier, owned |
|
84 CCMSX509AlgorithmIdentifier* iDigestAI; |
|
85 // Signature algorithm identifier, owned |
|
86 CCMSX509AlgorithmIdentifier* iSignatureAI; |
|
87 |
|
88 // Signature value, owned |
|
89 HBufC8* iSignatureValue; |
|
90 }; |
|
91 |
|
92 public: // Constructors and destructor |
|
93 /** |
|
94 * Two-phased constructor. |
|
95 * NOTE: Encrypt will leave with KErrBadDescriptor if |
|
96 * valid Attribute Type has not setted. |
|
97 */ |
|
98 IMPORT_C static CCMSSignerInfo* NewL(); |
|
99 |
|
100 /** |
|
101 * Two-phased constructor. |
|
102 * Takes copy of the both type and values. |
|
103 * @param aCertificate Used certificate |
|
104 * @param aMessageDigest Message Digest value |
|
105 */ |
|
106 IMPORT_C static CCMSSignerInfo* NewL( const CCMSX509Certificate& aCertificate, |
|
107 const TDesC8& aMessageDigest ); |
|
108 |
|
109 /** |
|
110 * Two-phased constructor. |
|
111 * Takes copy of the both type and values. |
|
112 * @param aCertificateUrl Used certificate url |
|
113 * @param aSubjectKeyID Subject Key ID |
|
114 * @param aMessageDigest Message Digest value |
|
115 */ |
|
116 IMPORT_C static CCMSSignerInfo* NewL( const TDesC8& aCertificateUrl, |
|
117 const TDesC8& aSubjectKeyID, |
|
118 const TDesC8& aMessageDigest ); |
|
119 /** |
|
120 * Destructor. |
|
121 */ |
|
122 virtual ~CCMSSignerInfo(); |
|
123 |
|
124 public: // New functions |
|
125 |
|
126 /** |
|
127 * Getter for Version |
|
128 * @since 2,8 |
|
129 * @return Version number (1 or 3) |
|
130 */ |
|
131 IMPORT_C TInt CMSVersion() const; |
|
132 |
|
133 /** |
|
134 * Getter for IssuerAndSerialNumber |
|
135 * This will be present when normal certificate is used |
|
136 * @since 2,8 |
|
137 * @return IssuerAndSerialNumber or NULL if not present |
|
138 */ |
|
139 IMPORT_C const CCMSIssuerAndSerialNumber* IssuerAndSerialNumber() const; |
|
140 |
|
141 /** |
|
142 * Getter for SubjectKeyIdentifier |
|
143 * This will be present only if certificate url is used |
|
144 * @since 2,8 |
|
145 * @return SubjectKeyIdentifier or NULL if not present |
|
146 */ |
|
147 IMPORT_C const TDesC8* SubjectKeyIdentifier() const; |
|
148 |
|
149 /** |
|
150 * Getter for DigestAlgorithmIdentifier |
|
151 * Default value is SHA-1 |
|
152 * @since 2,8 |
|
153 * @return DigestAlgorithmIdentifier in CX509AlgorithmIdentifier instance |
|
154 */ |
|
155 IMPORT_C const CCMSX509AlgorithmIdentifier& DigestAlgorithmIdentifier() const; |
|
156 |
|
157 /** |
|
158 * Getter for SignedAttributes |
|
159 * @since 2,8 |
|
160 * @return SignedAttributes in pointer array |
|
161 */ |
|
162 IMPORT_C const CArrayPtrFlat<CCMSAttribute>& SignedAttributes() const; |
|
163 |
|
164 /** |
|
165 * Gets signedAttributes in encoded form, with SET OF tag instead of [0]. |
|
166 * This data is supposed to be signed. |
|
167 * since 3.0 |
|
168 * @return encoded form of signedAttributes, NULL if there are no signedAttributes |
|
169 */ |
|
170 IMPORT_C HBufC8* SignedAttributesEncodedL() const; |
|
171 |
|
172 /** |
|
173 * Getter for SignatureAlgorithmIdentifier |
|
174 * Default value is RSA |
|
175 * @since 2,8 |
|
176 * @return SignatureAlgorithmIdentifier in CX509AlgorithmIdentifier instance |
|
177 */ |
|
178 IMPORT_C const CCMSX509AlgorithmIdentifier& SignatureAlgorithmIdentifier() const; |
|
179 |
|
180 /** |
|
181 * Getter for SignatureValue |
|
182 * @since 2,8 |
|
183 * @return SignatureValue in TDesC8 reference |
|
184 */ |
|
185 IMPORT_C const TDesC8& SignatureValue() const; |
|
186 |
|
187 /** |
|
188 * Getter for UnsignedAttributes |
|
189 * |
|
190 * @since 2,8 |
|
191 * @return UnsignedAttributes in array |
|
192 */ |
|
193 IMPORT_C const CArrayPtrFlat<CCMSAttribute>& UnsignedAttributes() const; |
|
194 |
|
195 /** |
|
196 * Setter for Certificate |
|
197 * |
|
198 * @since 2,8 |
|
199 * @param aCertificate certificate to be set |
|
200 */ |
|
201 IMPORT_C void SetCertificateL( const CCMSX509Certificate& aCertificate ); |
|
202 |
|
203 /** |
|
204 * Getter for SubjectKeyIdentifier |
|
205 * @since 2,8 |
|
206 * @param aCertificateUrl certificate url to be set |
|
207 * @param aSubjectKeyIdentifier SubjectKeyIdentifier to be set |
|
208 */ |
|
209 IMPORT_C void SetCertificateUrlL( const TDesC8& aCertificateUrl, |
|
210 const TDesC8& aSubjectKeyIdentifier ); |
|
211 |
|
212 /** |
|
213 * Setter for DigestAlgorithmIdentifier |
|
214 * Transfers ownership |
|
215 * @since 2,8 |
|
216 * @param aDigestAI Digest algorithm identifier to be set |
|
217 */ |
|
218 IMPORT_C void SetDigestAlgorithmIdentifier( |
|
219 CCMSX509AlgorithmIdentifier& aDigestAI ); |
|
220 |
|
221 /** |
|
222 * Setter for SignatureAlgorithmIdentifier |
|
223 * Transfers ownership |
|
224 * @since 2,8 |
|
225 * @param aSignatureAI Signature algorithm identifier to be set |
|
226 */ |
|
227 IMPORT_C void SetSignatureAlgorithmIdentifier( |
|
228 CCMSX509AlgorithmIdentifier& aSignatureAI ); |
|
229 |
|
230 /** |
|
231 * Setter for SignatureValue |
|
232 * @since 2,8 |
|
233 * @param aSignatureValue Signature value to be set |
|
234 */ |
|
235 IMPORT_C void SetSignatureValueL( const TDesC8& aSignatureValue ); |
|
236 |
|
237 |
|
238 /** |
|
239 * Setter for Signed attributes |
|
240 * Support for ContentType, MessageDigest, |
|
241 * SigningTime and SigningCert |
|
242 * If some of the parameters are not wanted to add use KNullDesC or |
|
243 * KNullDesC8 |
|
244 * @since 2,8 |
|
245 * @param aContentType ContentType in OID form, e.g. "1.2.840.113549.1.7.1" |
|
246 * @param aMessageDigest Message Digest |
|
247 * @param aSigningTime In most cases current time |
|
248 * @param aCertHash Certificate hash |
|
249 */ |
|
250 IMPORT_C void SetSignedAttributesL( const TDesC& aContentType, |
|
251 const TDesC8& aMessageDigest, |
|
252 const TTime& aSigningTime, |
|
253 const TDesC8* aCertHash ); |
|
254 /** |
|
255 * Setter for Unsigned attributes |
|
256 * Transfers ownership |
|
257 * @since 2,8 |
|
258 * @param aUnsignedAttributes Array of attributes, |
|
259 * to be set in unsigned attributes. |
|
260 */ |
|
261 IMPORT_C void SetUnsignedAttributesL( CArrayPtrFlat<CCMSAttribute>& |
|
262 aUnsignedAttributes ); |
|
263 |
|
264 public: // Functions from base classes |
|
265 |
|
266 /** |
|
267 * From MCMSModule |
|
268 * @since 2.8 |
|
269 * @param aRawData raw-data to be parsed in this instance |
|
270 */ |
|
271 void DecodeL( const TDesC8& aRawData ); |
|
272 |
|
273 /** |
|
274 * From MCMSModule |
|
275 * @since 2.8 |
|
276 * @return Returns ASN1 encoder and leaves it in CleanupStack |
|
277 */ |
|
278 CASN1EncBase* EncoderLC() const; |
|
279 |
|
280 protected: // New functions |
|
281 |
|
282 /** |
|
283 * Protected construction to allow derivation |
|
284 */ |
|
285 IMPORT_C void ConstructL( const TDesC8& aCertificateUrl, |
|
286 const TDesC8& aSubjectKeyID, |
|
287 const TDesC8& aMessageDigest ); |
|
288 |
|
289 /** |
|
290 * Protected construction to allow derivation |
|
291 */ |
|
292 IMPORT_C void ConstructL( const CCMSX509Certificate& aCertificate, |
|
293 const TDesC8& aMessageDigest ); |
|
294 /** |
|
295 * C++ default constructor. |
|
296 */ |
|
297 IMPORT_C CCMSSignerInfo(); |
|
298 |
|
299 /** |
|
300 * Default construction |
|
301 */ |
|
302 virtual void BaseConstructL( const TDesC8& aMessageDigest ); |
|
303 |
|
304 private: // New functions |
|
305 |
|
306 /** |
|
307 * Decodes attributes to array |
|
308 */ |
|
309 void DecodeAttributesL( const TDesC8& aRawData, |
|
310 CArrayPtrFlat<CCMSAttribute>* aAttributes ); |
|
311 |
|
312 /** |
|
313 * Creates certificate url attribute |
|
314 */ |
|
315 CCMSAttribute* CreateCertificateUrlLC( const TDesC8& aCertificateUrl ); |
|
316 |
|
317 private: // Data |
|
318 // contains all members, owned |
|
319 CSignerInfoData* iData; |
|
320 |
|
321 // Reserved for extensions |
|
322 MCMSSignerInfoExtension* iReserved; |
|
323 }; |
|
324 |
|
325 #endif // CCMSSignerInfo_H |
|
326 |
|
327 // End of File |