First public contribution.
2 * Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
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".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
25 #ifndef CMSSIGNERINFO_H
26 #define CMSSIGNERINFO_H
30 class CX509AlgorithmIdentifier;
31 class CPKCS7IssuerAndSerialNumber;
32 class CCmsSignerIdentifier;
33 class CASN1EncSequence;
34 class CX509Certificate;
38 class CASN1EncOctetString;
43 Represents CMS signer information as defined in RFC2630.
44 SignedAttributes and UnsignedAttributes are not supported.
46 class CCmsSignerInfo : public CBase
53 Creates a CMS signer info object as defined in RFC2630.
54 @param aDataToBeSigned The data content or its hash to be signed.
55 @param aIsHash Indicates whether the first parameter is a hash.
56 @param aKey The DSA private key used to sign.
57 @param aSignerIdentifier The signer identifier. Ownership of
58 the signer identifier is taken by this newly created signer info object.
59 If construction fails, ownership is not transferred. The user
60 needs to push aSignerIdentifier onto the cleanup stack before calling this
61 method, and pop it off the cleanup stack after successful construction.
62 @param aDigestAlgorithm The digest algorithm used to create the hash.
63 Ownership of the digest algorithm instance is taken by
64 this newly created signer info object. If construction fails, ownership
65 is not transferred. The user needs to push aDigestAlgorithm onto the cleanup stack before
66 calling this method and pop it off the cleanup stack after successful construction.
67 @param aSignatureAlgorithm The signature algorithm to create the signature.
68 Ownership of the signature algorithm instance is taken by this
69 newly created signer info object. If construction fails, ownership is not transferred.
70 The user needs to push aDigestAlgorithm onto the cleanup stack before calling this
71 method and pop it off the cleanup stack after successful construction.
72 @return The fully constructed object.
74 static CCmsSignerInfo* NewL(const TDesC8& aDataToBeSigned,
76 const CDSAPrivateKey& aKey,
77 CCmsSignerIdentifier* aSignerIdentifier,
78 CX509AlgorithmIdentifier* aDigestAlgorithm,
79 CX509AlgorithmIdentifier* aSignatureAlgorithm);
83 Creates a CMS signer info object as defined in RFC2630
84 and leaves it on the cleanup stack.
85 @param aDataToBeSigned The data content or its hash to be signed.
86 @param aIsHash Indicates whether the first parameter is a hash.
87 @param aKey The DSA private key used to sign.
88 @param aSignerIdentifier The signer identifier. Ownership of
89 the signer identifier is taken by this newly created signer info object.
90 If construction fails, ownership is not transferred. The user
91 needs to push aSignerIdentifier onto the cleanup stack before calling this
92 method, and pop it off the cleanup stack after successful construction.
93 @param aDigestAlgorithm The digest algorithm used to create the hash.
94 Ownership of the digest algorithm instance is taken by
95 this newly created signer info object. If construction fails, ownership
96 is not transferred. The user needs to push aDigestAlgorithm onto the cleanup stack before
97 calling this method and pop it off the cleanup stack after successful construction.
98 @param aSignatureAlgorithm The signature algorithm to create the signature.
99 Ownership of the signature algorithm instance is taken by this
100 newly created signer info object. If construction fails, ownership is not transferred.
101 The user needs to push aDigestAlgorithm onto the cleanup stack before calling this
102 method and pop it off the cleanup stack after successful construction.
103 @return The fully constructed object.
105 static CCmsSignerInfo* NewLC(const TDesC8& aDataToBeSigned,
107 const CDSAPrivateKey& aKey,
108 CCmsSignerIdentifier* aSignerIdentifier,
109 CX509AlgorithmIdentifier* aDigestAlgorithm,
110 CX509AlgorithmIdentifier* aSignatureAlgorithm);
114 Creates a CMS signer info object as defined in RFC2630.
115 @param aDataToBeSigned The data content or its hash to be signed.
116 @param aIsHash Indicates whether the first parameter is a hash.
117 @param aKey The RSA private key used to sign.
118 @param aSignerIdentifier The signer identifier. Ownership of
119 the signer identifier is taken by this newly created signer info object.
120 If construction fails, ownership is not transferred. The user
121 needs to push aSignerIdentifier onto the cleanup stack before calling this
122 method, and pop it off the cleanup stack after successful construction.
123 @param aDigestAlgorithm The digest algorithm used to create the hash.
124 Ownership of the digest algorithm instance is taken by
125 this newly created signer info object. If construction fails, ownership
126 is not transferred. The user needs to push aDigestAlgorithm onto the cleanup stack before
127 calling this method and pop it off the cleanup stack after successful construction.
128 @param aSignatureAlgorithm The signature algorithm to create the signature.
129 Ownership of the signature algorithm instance is taken by this
130 newly created signer info object. If construction fails, ownership is not transferred.
131 The user needs to push aDigestAlgorithm onto the cleanup stack before calling this
132 method and pop it off the cleanup stack after successful construction.
133 @return The fully constructed object.
135 static CCmsSignerInfo* NewL(const TDesC8& aDataToBeSigned,
137 const CRSAPrivateKey& aKey,
138 CCmsSignerIdentifier* aSignerIdentifier,
139 CX509AlgorithmIdentifier* aDigestAlgorithm,
140 CX509AlgorithmIdentifier* aSignatureAlgorithm);
144 Creates a CMS signer info object as defined in RFC2630
145 and leaves it on the cleanup stack.
146 @param aDataToBeSigned The data content or its hash to be signed.
147 @param aIsHash Indicates whether the first parameter is a hash.
148 @param aKey The RSA private key used to sign.
149 @param aSignerIdentifier The signer identifier. Ownership of
150 the signer identifier is taken by this newly created signer info object.
151 If construction fails, ownership is not transferred. The user
152 needs to push aSignerIdentifier onto the cleanup stack before calling this
153 method, and pop it off the cleanup stack after successful construction.
154 @param aDigestAlgorithm The digest algorithm used to create the hash.
155 Ownership of the digest algorithm instance is taken by
156 this newly created signer info object. If construction fails, ownership
157 is not transferred. The user needs to push aDigestAlgorithm onto the cleanup stack before
158 calling this method and pop it off the cleanup stack after successful construction.
159 @param aSignatureAlgorithm The signature algorithm to create the signature.
160 Ownership of the signature algorithm instance is taken by this
161 newly created signer info object. If construction fails, ownership is not transferred.
162 The user needs to push aDigestAlgorithm onto the cleanup stack before calling this
163 method and pop it off the cleanup stack after successful construction.
164 @return The fully constructed object.
166 static CCmsSignerInfo* NewLC(const TDesC8& aDataToBeSigned,
168 const CRSAPrivateKey& aKey,
169 CCmsSignerIdentifier* aSignerIdentifier,
170 CX509AlgorithmIdentifier* aDigestAlgorithm,
171 CX509AlgorithmIdentifier* aSignatureAlgorithm);
176 Creates a CMS signer info object as defined in RFC2630.
177 @param aRawData the encoded signer info.
178 @return The fully constructed object.
180 static CCmsSignerInfo* NewL(const TDesC8& aRawData);
185 Creates a CMS signer info object as defined in RFC2630
186 and leaves it on the cleanup stack.
187 @param aRawData The encoded signer info.
188 @return The fully constructed object.
190 static CCmsSignerInfo* NewLC(const TDesC8& aRawData);
191 virtual ~CCmsSignerInfo();
194 Returns the version of the CMS signer info object.
195 @return The version of the CMS signer info object.
197 IMPORT_C TInt Version() const;
200 Returns whether signed attributes are present or not.
201 @return Boolean indicating whether signed attributes are present or not.
203 IMPORT_C TBool IsSignedAttributesPresent() const;
206 Returns whether unsigned attributes are present or not.
207 @return Boolean indicating whether unsigned attributes are present or not.
209 IMPORT_C TBool IsUnsignedAttributesPresent() const;
212 Returns the digest algorithm identifier.
213 @return The digest algorithm identifier reference.
215 IMPORT_C const CX509AlgorithmIdentifier& DigestAlgorithm() const;
218 Returns the signature algorithm identifier.
219 @return The signature algorithm identifier reference.
221 IMPORT_C const CX509AlgorithmIdentifier& SignatureAlgorithm() const;
224 Returns the signature value.
225 @return The signature value.
227 IMPORT_C const TPtrC8 SignatureValue() const;
230 Returns the signer identifier.
231 @return the signer identifier reference.
233 IMPORT_C const CCmsSignerIdentifier& SignerIdentifier() const;
238 Creates the ASN.1 sequence of this CMS signed object and leaves it on the cleanup stack.
239 @return ASN.1 sequence of this object.
241 CASN1EncSequence* EncodeASN1DERLC() const;
252 second phase constructor
253 @param aDataToBeSigned the data or its hash
254 @param aIsHash a flag to represent if the first paramter is hash or data content
255 @param aKey the DSA private key used to create the signature.
256 @param aSignerIdentifier the signer identifier.
257 @param aDigestAlgorithm the digest algorithm used to create hash.
258 @param aSignatureAlgorithm the signature alogorithm to create signature
260 void ConstructL(const TDesC8& aDataToBeSigned,
262 const CDSAPrivateKey& aKey,
263 CCmsSignerIdentifier* aSignerIdentifier,
264 CX509AlgorithmIdentifier* aDigestAlgorithm,
265 CX509AlgorithmIdentifier* aSignatureAlgorithm);
268 second phase constructor
269 @param aDataToBeSigned the data or its hash
270 @param aIsHash a flag to represent if the first paramter is hash or data content
271 @param aKey the RSA private key used to create the signature.
272 @param aSignerIdentifier the signer identifier.
273 @param aDigestAlgorithm the digest algorithm used to create hash.
274 @param aSignatureAlgorithm the signature alogorithm to create signature.
276 void ConstructL(const TDesC8& aDataToBeSigned,
278 const CRSAPrivateKey& aKey,
279 CCmsSignerIdentifier* aSignerIdentifier,
280 CX509AlgorithmIdentifier* aDigestAlgorithm,
281 CX509AlgorithmIdentifier* aSignatureAlgorithm);
284 Second phase constructor
285 @param aRawData the encoded the CMS content info
287 void ConstructL(const TDesC8& aRawData);
290 Encode the signer identifier
291 @return encoding of the signer identifier
293 CASN1EncBase* EncodeSignerIdentifierLC() const;
297 @param aRawData the encoded signature
299 void DecodeEncryptedDigestL(const TDesC8& aRawData);
302 Decode the signer identifier
303 @param aRawData the encoded signer identifier
305 void DecodeSignerIdentifierL(const TDesC8& aRawData);
309 Represents if the Signed Attribute is present
311 TBool iSignedAttributesPresent;
314 Represents if the Unsigned Attribute is present
316 TBool iUnsignedAttributesPresent;
319 The version of the signer info
324 the signer identifier
326 CCmsSignerIdentifier* iSignerIdentifier;
329 The digest algorithm identifier
331 CX509AlgorithmIdentifier* iDigestAlgorithm;
333 The signature algorithm identifier
335 CX509AlgorithmIdentifier* iSignatureAlgorithm;
340 HBufC8* iSignatureValue;