sl@0
|
1 |
/*
|
sl@0
|
2 |
* Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
3 |
* All rights reserved.
|
sl@0
|
4 |
* This component and the accompanying materials are made available
|
sl@0
|
5 |
* under the terms of the License "Eclipse Public License v1.0"
|
sl@0
|
6 |
* which accompanies this distribution, and is available
|
sl@0
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
8 |
*
|
sl@0
|
9 |
* Initial Contributors:
|
sl@0
|
10 |
* Nokia Corporation - initial contribution.
|
sl@0
|
11 |
*
|
sl@0
|
12 |
* Contributors:
|
sl@0
|
13 |
*
|
sl@0
|
14 |
* Description:
|
sl@0
|
15 |
*
|
sl@0
|
16 |
*/
|
sl@0
|
17 |
|
sl@0
|
18 |
|
sl@0
|
19 |
/**
|
sl@0
|
20 |
@file
|
sl@0
|
21 |
@publishedAll
|
sl@0
|
22 |
@released
|
sl@0
|
23 |
*/
|
sl@0
|
24 |
|
sl@0
|
25 |
#ifndef __SIGNED_H__
|
sl@0
|
26 |
#define __SIGNED_H__
|
sl@0
|
27 |
|
sl@0
|
28 |
#include <e32base.h>
|
sl@0
|
29 |
#include <e32std.h>
|
sl@0
|
30 |
#include <s32std.h>
|
sl@0
|
31 |
#include <securitydefs.h>
|
sl@0
|
32 |
|
sl@0
|
33 |
class CRSAPublicKey;
|
sl@0
|
34 |
class CDSAPublicKey;
|
sl@0
|
35 |
class CDSASignature;
|
sl@0
|
36 |
class CDSAParameters;
|
sl@0
|
37 |
|
sl@0
|
38 |
/** Enumerates the identity of the algorithm.
|
sl@0
|
39 |
*
|
sl@0
|
40 |
*/
|
sl@0
|
41 |
enum TAlgorithmId
|
sl@0
|
42 |
{
|
sl@0
|
43 |
/** An RSA algorithm. */
|
sl@0
|
44 |
ERSA,
|
sl@0
|
45 |
/** A DSA algorithm. */
|
sl@0
|
46 |
EDSA,
|
sl@0
|
47 |
/** A DH algorithm. */
|
sl@0
|
48 |
EDH,
|
sl@0
|
49 |
/** A MD2 algorithm. */
|
sl@0
|
50 |
EMD2,
|
sl@0
|
51 |
/** A MD5 algorithm. */
|
sl@0
|
52 |
EMD5,
|
sl@0
|
53 |
/** A SHA-1 algorithm. */
|
sl@0
|
54 |
ESHA1,
|
sl@0
|
55 |
/** A SHA-224 algorithm. */
|
sl@0
|
56 |
ESHA224,
|
sl@0
|
57 |
/** A SHA-256 algorithm. */
|
sl@0
|
58 |
ESHA256,
|
sl@0
|
59 |
/** A SHA-384 algorithm. */
|
sl@0
|
60 |
ESHA384,
|
sl@0
|
61 |
/** A SHA-512 algorithm. */
|
sl@0
|
62 |
ESHA512
|
sl@0
|
63 |
};
|
sl@0
|
64 |
|
sl@0
|
65 |
class CValidityPeriod : public CBase
|
sl@0
|
66 |
/** The period for which the certificate is valid.
|
sl@0
|
67 |
*
|
sl@0
|
68 |
* @since v6.0 */
|
sl@0
|
69 |
{
|
sl@0
|
70 |
public:
|
sl@0
|
71 |
/** Tests whether the specified date and time is within the validity period.
|
sl@0
|
72 |
*
|
sl@0
|
73 |
* @param aTime The date and time to be tested.
|
sl@0
|
74 |
* @return ETrue, if the date and time is within the validity period;
|
sl@0
|
75 |
* EFalse, otherwise. */
|
sl@0
|
76 |
IMPORT_C TBool Valid(const TTime& aTime) const;
|
sl@0
|
77 |
|
sl@0
|
78 |
/** Gets the start of the validity period.
|
sl@0
|
79 |
*
|
sl@0
|
80 |
* @return The start date and time. */
|
sl@0
|
81 |
IMPORT_C const TTime& Start() const;
|
sl@0
|
82 |
|
sl@0
|
83 |
/** Gets the end of the validity period.
|
sl@0
|
84 |
*
|
sl@0
|
85 |
* @return The end date and time. */
|
sl@0
|
86 |
IMPORT_C const TTime& Finish() const;
|
sl@0
|
87 |
|
sl@0
|
88 |
/** Copy constructor.
|
sl@0
|
89 |
*
|
sl@0
|
90 |
* @param aValidityPeriod The validity period object to be copied. */
|
sl@0
|
91 |
IMPORT_C CValidityPeriod(const CValidityPeriod& aValidityPeriod);
|
sl@0
|
92 |
|
sl@0
|
93 |
protected:
|
sl@0
|
94 |
/** Default constructor. */
|
sl@0
|
95 |
IMPORT_C CValidityPeriod();
|
sl@0
|
96 |
|
sl@0
|
97 |
/** The start time of the validity period. */
|
sl@0
|
98 |
TTime iStart;
|
sl@0
|
99 |
|
sl@0
|
100 |
/** The end time of the validity period. */
|
sl@0
|
101 |
TTime iFinish;
|
sl@0
|
102 |
};
|
sl@0
|
103 |
|
sl@0
|
104 |
class CAlgorithmIdentifier : public CBase
|
sl@0
|
105 |
/** Contains an algorithm ID and any encoded parameters required by that algorithm.
|
sl@0
|
106 |
*
|
sl@0
|
107 |
* An object of this type creates and owns a heap descriptor to contain the encoded
|
sl@0
|
108 |
* parameters.
|
sl@0
|
109 |
*
|
sl@0
|
110 |
* @since v6.0 */
|
sl@0
|
111 |
{
|
sl@0
|
112 |
public:
|
sl@0
|
113 |
/** Creates a new algorithm ID object copied from an existing object.
|
sl@0
|
114 |
*
|
sl@0
|
115 |
* @param aAlgorithmIdentifier The algorithm ID object to be copied.
|
sl@0
|
116 |
* @return A pointer to the new algorithm ID object. */
|
sl@0
|
117 |
IMPORT_C static CAlgorithmIdentifier* NewL(const CAlgorithmIdentifier& aAlgorithmIdentifier);
|
sl@0
|
118 |
|
sl@0
|
119 |
/** Creates a new algorithm ID object copied from an existing object, and puts
|
sl@0
|
120 |
* a pointer to the new object onto the cleanup stack.
|
sl@0
|
121 |
*
|
sl@0
|
122 |
* @param aAlgorithmIdentifier The algorithm ID object to be copied.
|
sl@0
|
123 |
* @return A pointer to the new algorithm ID object. */
|
sl@0
|
124 |
IMPORT_C static CAlgorithmIdentifier* NewLC(const CAlgorithmIdentifier& aAlgorithmIdentifier);
|
sl@0
|
125 |
|
sl@0
|
126 |
/** Creates a new algorithm ID object.
|
sl@0
|
127 |
*
|
sl@0
|
128 |
* @param aAlgorithmId The algorithm ID.
|
sl@0
|
129 |
* @param aEncodedParams The encoded parameters.
|
sl@0
|
130 |
* @return A pointer to the new algorithm ID object. */
|
sl@0
|
131 |
IMPORT_C static CAlgorithmIdentifier* NewL(TAlgorithmId& aAlgorithmId, const TDesC8& aEncodedParams);
|
sl@0
|
132 |
|
sl@0
|
133 |
/** Creates a new algorithm ID object, and puts a pointer to the new object onto
|
sl@0
|
134 |
* the cleanup stack.
|
sl@0
|
135 |
*
|
sl@0
|
136 |
* @param aAlgorithmId The algorithm ID.
|
sl@0
|
137 |
* @param aEncodedParams The encoded parameters.
|
sl@0
|
138 |
* @return A pointer to the new algorithm ID object. */
|
sl@0
|
139 |
IMPORT_C static CAlgorithmIdentifier* NewLC(TAlgorithmId& aAlgorithmId, const TDesC8& aEncodedParams);
|
sl@0
|
140 |
|
sl@0
|
141 |
/** Tests whether this algorithm identifier object is equal to the specified algorithm
|
sl@0
|
142 |
* identifier object.
|
sl@0
|
143 |
*
|
sl@0
|
144 |
* @param aAlgorithmIdentifier The algorithm identifier object to be compared.
|
sl@0
|
145 |
* @return ETrue, if this algorithm identifier object is equal to the specified
|
sl@0
|
146 |
* algorithm identifier object; EFalse otherwise. */
|
sl@0
|
147 |
IMPORT_C TBool operator == (const CAlgorithmIdentifier& aAlgorithmIdentifier) const;
|
sl@0
|
148 |
|
sl@0
|
149 |
/** Gets the algorithm identifier.
|
sl@0
|
150 |
*
|
sl@0
|
151 |
* @return The algorithm identifier. */
|
sl@0
|
152 |
IMPORT_C TAlgorithmId Algorithm() const; //ID for the algorithm
|
sl@0
|
153 |
|
sl@0
|
154 |
/** Gets the encoded parameters for the algorithm identifier.
|
sl@0
|
155 |
*
|
sl@0
|
156 |
* Note that this object owns the heap descriptor that owns the encoded parameters.
|
sl@0
|
157 |
*
|
sl@0
|
158 |
* @return The encoded parameters. */
|
sl@0
|
159 |
IMPORT_C TPtrC8 EncodedParams() const; //the encoded parameters
|
sl@0
|
160 |
|
sl@0
|
161 |
/** Destructor.
|
sl@0
|
162 |
*
|
sl@0
|
163 |
* Frees all resources owned by the object. */
|
sl@0
|
164 |
IMPORT_C ~CAlgorithmIdentifier();
|
sl@0
|
165 |
|
sl@0
|
166 |
protected:
|
sl@0
|
167 |
/** Default constructor. */
|
sl@0
|
168 |
IMPORT_C CAlgorithmIdentifier();
|
sl@0
|
169 |
|
sl@0
|
170 |
/** Constructor taking the specified parameters.
|
sl@0
|
171 |
*
|
sl@0
|
172 |
* @param aAlgorithmId The algorithm ID. */
|
sl@0
|
173 |
IMPORT_C CAlgorithmIdentifier(TAlgorithmId& aAlgorithmId);
|
sl@0
|
174 |
|
sl@0
|
175 |
/** Second-phase constructor taking an existing algorithm identifier object.
|
sl@0
|
176 |
*
|
sl@0
|
177 |
* @param aAlgorithmIdentifier The algorithm identifier object. */
|
sl@0
|
178 |
IMPORT_C virtual void ConstructL(const CAlgorithmIdentifier& aAlgorithmIdentifier);
|
sl@0
|
179 |
|
sl@0
|
180 |
/** Second-phase constructor taking encoded parameters.
|
sl@0
|
181 |
*
|
sl@0
|
182 |
* @param aEncodedParams The encoded parameters. */
|
sl@0
|
183 |
IMPORT_C virtual void ConstructL(const TDesC8& aEncodedParams);
|
sl@0
|
184 |
|
sl@0
|
185 |
/** The algorithm ID. */
|
sl@0
|
186 |
TAlgorithmId iAlgorithmId;
|
sl@0
|
187 |
|
sl@0
|
188 |
/** The encoded parameters for the algorithm ID. */
|
sl@0
|
189 |
HBufC8* iEncodedParams;
|
sl@0
|
190 |
};
|
sl@0
|
191 |
|
sl@0
|
192 |
class CSigningAlgorithmIdentifier : public CBase
|
sl@0
|
193 |
/** Contains two CAlgorithmIdentifier objects for comparison purposes.
|
sl@0
|
194 |
*
|
sl@0
|
195 |
* Implements an equality operator.
|
sl@0
|
196 |
*
|
sl@0
|
197 |
* @since v6.0 */
|
sl@0
|
198 |
{
|
sl@0
|
199 |
public:
|
sl@0
|
200 |
/** Constructs a new Signing Algorithm Identifier object, copying an existing Signing
|
sl@0
|
201 |
* Algorithm Identifier object.
|
sl@0
|
202 |
*
|
sl@0
|
203 |
* @param aSigningAlgorithmIdentifier The Signing Algorithm Identifier object.
|
sl@0
|
204 |
* @return The new Signing Algorithm Identifier object. */
|
sl@0
|
205 |
IMPORT_C static CSigningAlgorithmIdentifier* NewL(const CSigningAlgorithmIdentifier& aSigningAlgorithmIdentifier);
|
sl@0
|
206 |
|
sl@0
|
207 |
/** Constructs a new Signing Algorithm Identifier object, copying an existing Signing
|
sl@0
|
208 |
* Algorithm Identifier object, and puts a pointer to it onto the cleanup stack.
|
sl@0
|
209 |
*
|
sl@0
|
210 |
* @param aSigningAlgorithmIdentifier The Signing Algorithm Identifier object.
|
sl@0
|
211 |
* @return The new Signing Algorithm Identifier object. */
|
sl@0
|
212 |
IMPORT_C static CSigningAlgorithmIdentifier* NewLC(const CSigningAlgorithmIdentifier& aSigningAlgorithmIdentifier);
|
sl@0
|
213 |
|
sl@0
|
214 |
/** Tests whether the Signing Algorithm Identifier object is equal to the specified
|
sl@0
|
215 |
* Signing Algorithm Identifier object.
|
sl@0
|
216 |
*
|
sl@0
|
217 |
* @param aSigningAlgorithmIdentifier The Signing Algorithm Identifier object to be compared.
|
sl@0
|
218 |
* @return ETrue, if this object's Signing Algorithm Identifier value
|
sl@0
|
219 |
* is equal to the specified Signing Algorithm Identifier
|
sl@0
|
220 |
* object's value; EFalse, otherwise. */
|
sl@0
|
221 |
IMPORT_C TBool operator == (const CSigningAlgorithmIdentifier& aSigningAlgorithmIdentifier) const;
|
sl@0
|
222 |
|
sl@0
|
223 |
/** Gets the signature ID of the asymmetric algorithm.
|
sl@0
|
224 |
*
|
sl@0
|
225 |
* @return The signature ID of the asymmetric algorithm. */
|
sl@0
|
226 |
IMPORT_C const CAlgorithmIdentifier& AsymmetricAlgorithm() const;
|
sl@0
|
227 |
|
sl@0
|
228 |
/** Gets the signature ID of the digest algorithm.
|
sl@0
|
229 |
*
|
sl@0
|
230 |
* @return The signature ID of the digest algorithm. */
|
sl@0
|
231 |
IMPORT_C const CAlgorithmIdentifier& DigestAlgorithm() const;
|
sl@0
|
232 |
|
sl@0
|
233 |
/** Destructor.
|
sl@0
|
234 |
*
|
sl@0
|
235 |
* Frees all resources owned by the object, prior to its destruction. */
|
sl@0
|
236 |
IMPORT_C ~CSigningAlgorithmIdentifier();
|
sl@0
|
237 |
|
sl@0
|
238 |
protected:
|
sl@0
|
239 |
/** Second-phase constructor.
|
sl@0
|
240 |
* @internalAll
|
sl@0
|
241 |
*/
|
sl@0
|
242 |
void ConstructL(const CSigningAlgorithmIdentifier& aSigningAlgorithmIdentifier);
|
sl@0
|
243 |
|
sl@0
|
244 |
/** The signature ID of the asymmetric algorithm. */
|
sl@0
|
245 |
CAlgorithmIdentifier* iAsymmetricAlgorithm;
|
sl@0
|
246 |
|
sl@0
|
247 |
/** The signature ID of the digest algorithm. */
|
sl@0
|
248 |
CAlgorithmIdentifier* iDigestAlgorithm;
|
sl@0
|
249 |
};
|
sl@0
|
250 |
|
sl@0
|
251 |
class CSubjectPublicKeyInfo : public CBase
|
sl@0
|
252 |
/** A base class for a container that holds information about a subject public key.
|
sl@0
|
253 |
*
|
sl@0
|
254 |
* It contains the algorithm ID, the encoded public key and the encoded parameters.
|
sl@0
|
255 |
*
|
sl@0
|
256 |
* @since v6.0
|
sl@0
|
257 |
*/
|
sl@0
|
258 |
//algorithm ID + encoded public key + encoded parameters
|
sl@0
|
259 |
{
|
sl@0
|
260 |
public:
|
sl@0
|
261 |
/** Creates a new subject public key object copied from an existing object.
|
sl@0
|
262 |
*
|
sl@0
|
263 |
* @param aSubjectPublicKeyInfo The subject public key object to be copied.
|
sl@0
|
264 |
* @return A pointer to the new public key object. */
|
sl@0
|
265 |
IMPORT_C static CSubjectPublicKeyInfo* NewL(const CSubjectPublicKeyInfo& aSubjectPublicKeyInfo);
|
sl@0
|
266 |
|
sl@0
|
267 |
/** Creates a new subject public key object copied from an existing object and
|
sl@0
|
268 |
* puts a pointer to the new object onto the cleanup stack.
|
sl@0
|
269 |
*
|
sl@0
|
270 |
* @param aSubjectPublicKeyInfo The subject public key object to be copied.
|
sl@0
|
271 |
* @return A pointer to the new public key object. */
|
sl@0
|
272 |
IMPORT_C static CSubjectPublicKeyInfo* NewLC(const CSubjectPublicKeyInfo& aSubjectPublicKeyInfo);
|
sl@0
|
273 |
|
sl@0
|
274 |
/** Gets the algorithm ID.
|
sl@0
|
275 |
*
|
sl@0
|
276 |
* @return The algorithm ID. */
|
sl@0
|
277 |
IMPORT_C TAlgorithmId AlgorithmId() const;
|
sl@0
|
278 |
|
sl@0
|
279 |
/** Gets the encoded parameters required by the algorithm.
|
sl@0
|
280 |
*
|
sl@0
|
281 |
* @return A non-modifiable pointer descriptor representing the encoded parameters. */
|
sl@0
|
282 |
IMPORT_C const TPtrC8 EncodedParams() const;
|
sl@0
|
283 |
|
sl@0
|
284 |
/** Gets the encoded public key data.
|
sl@0
|
285 |
*
|
sl@0
|
286 |
* @return A non-modifiable pointer descriptor representing the encoded public
|
sl@0
|
287 |
* key data. */
|
sl@0
|
288 |
IMPORT_C const TPtrC8 KeyData() const;
|
sl@0
|
289 |
|
sl@0
|
290 |
/** Destructor.
|
sl@0
|
291 |
*
|
sl@0
|
292 |
* Frees all resources owned by the object. */
|
sl@0
|
293 |
IMPORT_C ~CSubjectPublicKeyInfo();
|
sl@0
|
294 |
protected:
|
sl@0
|
295 |
/** Second-phase constructor.
|
sl@0
|
296 |
*
|
sl@0
|
297 |
* @param aSubjectPublicKeyInfo The subject public key object to be copied. */
|
sl@0
|
298 |
IMPORT_C virtual void ConstructL(const CSubjectPublicKeyInfo& aSubjectPublicKeyInfo);
|
sl@0
|
299 |
|
sl@0
|
300 |
/** The algorithm ID. */
|
sl@0
|
301 |
CAlgorithmIdentifier* iAlgId;
|
sl@0
|
302 |
|
sl@0
|
303 |
/** A heap descriptor representing the encoded key data. */
|
sl@0
|
304 |
HBufC8* iEncodedKeyData;
|
sl@0
|
305 |
};
|
sl@0
|
306 |
|
sl@0
|
307 |
class CRSASignatureResult : public CBase
|
sl@0
|
308 |
/** The RSA public key algorithm signature result.
|
sl@0
|
309 |
*
|
sl@0
|
310 |
* Derived classes:
|
sl@0
|
311 |
* @li CWTLSRSASignatureResult
|
sl@0
|
312 |
* @li CPKCS1SignatureResult.
|
sl@0
|
313 |
*
|
sl@0
|
314 |
* @see TKeyFactory::RSASignatureResultL()
|
sl@0
|
315 |
*
|
sl@0
|
316 |
* @since v6.0 */
|
sl@0
|
317 |
{
|
sl@0
|
318 |
public:
|
sl@0
|
319 |
/** Tests whether the signature result is valid.
|
sl@0
|
320 |
*
|
sl@0
|
321 |
* @param aResult The signature result.
|
sl@0
|
322 |
* @return ETrue if the signature result is valid, otherwise EFalse. */
|
sl@0
|
323 |
IMPORT_C virtual TBool VerifyL(const TDesC8& aResult) = 0;
|
sl@0
|
324 |
|
sl@0
|
325 |
/** Destructor.
|
sl@0
|
326 |
*
|
sl@0
|
327 |
* Frees all resources owned by the object. */
|
sl@0
|
328 |
IMPORT_C ~CRSASignatureResult();
|
sl@0
|
329 |
protected:
|
sl@0
|
330 |
/** Compares this RSA Signature Result object with the specified RSA Signature
|
sl@0
|
331 |
* Result object for equality.
|
sl@0
|
332 |
*
|
sl@0
|
333 |
* @param aResult The RSA Signature Result object to be compared.
|
sl@0
|
334 |
* @return ETrue, if they are the same; EFalse, otherwise. */
|
sl@0
|
335 |
IMPORT_C TBool operator == (const CRSASignatureResult& aResult) const;
|
sl@0
|
336 |
|
sl@0
|
337 |
/** The digest algorithm ID. */
|
sl@0
|
338 |
CAlgorithmIdentifier* iDigestAlgorithm;
|
sl@0
|
339 |
|
sl@0
|
340 |
/** A heap descriptor representing the digest algorithm. */
|
sl@0
|
341 |
HBufC8* iDigest;
|
sl@0
|
342 |
};
|
sl@0
|
343 |
|
sl@0
|
344 |
//signed object
|
sl@0
|
345 |
class TKeyFactory
|
sl@0
|
346 |
/** Constructs the public key objects used for signature verification from their
|
sl@0
|
347 |
* encoded binary form.
|
sl@0
|
348 |
*
|
sl@0
|
349 |
* @since v6.0 */
|
sl@0
|
350 |
{
|
sl@0
|
351 |
public:
|
sl@0
|
352 |
/** Gets the RSA public key.
|
sl@0
|
353 |
*
|
sl@0
|
354 |
* @param aEncoding A non-modifiable descriptor representing the entire encoding.
|
sl@0
|
355 |
* @return The RSA Public key. */
|
sl@0
|
356 |
virtual CRSAPublicKey* RSAPublicKeyL(const TDesC8& aEncoding) const = 0;
|
sl@0
|
357 |
|
sl@0
|
358 |
/** Gets the RSA signature result.
|
sl@0
|
359 |
*
|
sl@0
|
360 |
* @param aDigestAlgorithm The algorithm ID.
|
sl@0
|
361 |
* @param aDigest A non-modifiable descriptor representing the digest algorithm.
|
sl@0
|
362 |
* @return The RSA signature result. */
|
sl@0
|
363 |
virtual CRSASignatureResult* RSASignatureResultL(const CAlgorithmIdentifier& aDigestAlgorithm, TDesC8& aDigest) const = 0;
|
sl@0
|
364 |
|
sl@0
|
365 |
/** Gets the DSA public key.
|
sl@0
|
366 |
*
|
sl@0
|
367 |
* @param aParams The DSA parameters
|
sl@0
|
368 |
* @param aEncoding A non-modifiable descriptor representing the entire encoding.
|
sl@0
|
369 |
* @return The DSA public key. */
|
sl@0
|
370 |
virtual CDSAPublicKey* DSAPublicKeyL(const CDSAParameters& aParams, const TDesC8& aEncoding) const = 0;
|
sl@0
|
371 |
|
sl@0
|
372 |
/** Gets the digital DSA signature given an encoding key.
|
sl@0
|
373 |
*
|
sl@0
|
374 |
* @param aEncoding A non-modifiable descriptor representing the entire encoding.
|
sl@0
|
375 |
* @return The DSA signature. */
|
sl@0
|
376 |
virtual CDSASignature* DSASignatureL(const TDesC8& aEncoding) const = 0;
|
sl@0
|
377 |
|
sl@0
|
378 |
/** Gets the DSA parameters.
|
sl@0
|
379 |
*
|
sl@0
|
380 |
* @param aEncoding A non-modifiable descriptor representing the entire encoding.
|
sl@0
|
381 |
* @return The DSA parameters. */
|
sl@0
|
382 |
virtual CDSAParameters* DSAParametersL(const TDesC8& aEncoding) const = 0;
|
sl@0
|
383 |
// New function for TKeyFactory API
|
sl@0
|
384 |
virtual CDSAPublicKey* DSAPublicKeyL(const TDesC8& aParamsEncoding, const TDesC8& aEncoding) const = 0;
|
sl@0
|
385 |
};
|
sl@0
|
386 |
|
sl@0
|
387 |
class CSigningKeyParameters : public CBase
|
sl@0
|
388 |
/** Contains the parameter information required by some signing algorithms.
|
sl@0
|
389 |
*
|
sl@0
|
390 |
* The DSA signing algorithm needs parameters as well as a key. Currently, this
|
sl@0
|
391 |
* class only contains DSA parameters.
|
sl@0
|
392 |
*
|
sl@0
|
393 |
* @since v6.0 */
|
sl@0
|
394 |
{
|
sl@0
|
395 |
public:
|
sl@0
|
396 |
/** Creates a new signing key parameters object.
|
sl@0
|
397 |
*
|
sl@0
|
398 |
* @return A pointer to the new signing key parameters object. */
|
sl@0
|
399 |
IMPORT_C static CSigningKeyParameters* NewL();
|
sl@0
|
400 |
|
sl@0
|
401 |
/** Creates a new signing key parameters object and puts a pointer to the new object
|
sl@0
|
402 |
* onto the cleanup stack.
|
sl@0
|
403 |
*
|
sl@0
|
404 |
* @return A pointer to the new signing key parameters object. */
|
sl@0
|
405 |
IMPORT_C static CSigningKeyParameters* NewLC();
|
sl@0
|
406 |
|
sl@0
|
407 |
/** Creates a new signing key parameters object copied from an existing object.
|
sl@0
|
408 |
*
|
sl@0
|
409 |
* @param aParameters The signing key parameters object to be copied.
|
sl@0
|
410 |
* @return A pointer to the new parameters object. */
|
sl@0
|
411 |
IMPORT_C static CSigningKeyParameters* NewL(const CSigningKeyParameters& aParameters);
|
sl@0
|
412 |
|
sl@0
|
413 |
/** Creates a new signing key parameters object copied from an existing object
|
sl@0
|
414 |
* and puts a pointer to the new object onto the cleanup stack.
|
sl@0
|
415 |
*
|
sl@0
|
416 |
* @param aParameters The signing key parameters object to be copied.
|
sl@0
|
417 |
* @return A pointer to the new signing key parameters object. */
|
sl@0
|
418 |
IMPORT_C static CSigningKeyParameters* NewLC(const CSigningKeyParameters& aParameters);
|
sl@0
|
419 |
|
sl@0
|
420 |
/** Destructor.
|
sl@0
|
421 |
*
|
sl@0
|
422 |
* Frees all resources owned by the object. */
|
sl@0
|
423 |
IMPORT_C ~CSigningKeyParameters();
|
sl@0
|
424 |
|
sl@0
|
425 |
/** Sets the DSA parameters.
|
sl@0
|
426 |
*
|
sl@0
|
427 |
* @param aParams The DSA parameters. */
|
sl@0
|
428 |
IMPORT_C void SetDSAParamsL(const CDSAParameters& aParams);
|
sl@0
|
429 |
|
sl@0
|
430 |
/** Gets the DSA parameters.
|
sl@0
|
431 |
*
|
sl@0
|
432 |
* @return The DSA parameters.
|
sl@0
|
433 |
* @internalAll
|
sl@0
|
434 |
*/
|
sl@0
|
435 |
const CDSAParameters* DSAParams() const;
|
sl@0
|
436 |
private:
|
sl@0
|
437 |
CSigningKeyParameters();
|
sl@0
|
438 |
void ConstructL(const CSigningKeyParameters& aParameters);
|
sl@0
|
439 |
CDSAParameters* iDSAParams;
|
sl@0
|
440 |
};
|
sl@0
|
441 |
|
sl@0
|
442 |
|
sl@0
|
443 |
class CSignedObject : public CBase
|
sl@0
|
444 |
/** Base class for certificates.
|
sl@0
|
445 |
*
|
sl@0
|
446 |
* @since v6.0 */
|
sl@0
|
447 |
{
|
sl@0
|
448 |
public:
|
sl@0
|
449 |
/** Verifies a signature using the specified encoded key.
|
sl@0
|
450 |
*
|
sl@0
|
451 |
* @param aEncodedKey The encoded key.
|
sl@0
|
452 |
* @return ETrue if the signature is valid, otherwise EFalse. */
|
sl@0
|
453 |
IMPORT_C TBool VerifySignatureL(const TDesC8& aEncodedKey) const;
|
sl@0
|
454 |
|
sl@0
|
455 |
/** Verifies a signature using the specified encoded key and hash.
|
sl@0
|
456 |
*
|
sl@0
|
457 |
* @param aEncodedKey The encoded key.
|
sl@0
|
458 |
* @param aHash The hash of the data to be validated.
|
sl@0
|
459 |
* @return ETrue if the signature is valid, otherwise EFalse. */
|
sl@0
|
460 |
IMPORT_C TBool VerifySignatureL(const TDesC8& aEncodedKey, const TDesC8& aHash) const;
|
sl@0
|
461 |
|
sl@0
|
462 |
/** Gets the digital signature.
|
sl@0
|
463 |
*
|
sl@0
|
464 |
* @return A non-modifiable pointer descriptor representing the digital signature. */
|
sl@0
|
465 |
IMPORT_C const TPtrC8 Signature() const;
|
sl@0
|
466 |
|
sl@0
|
467 |
/** Gets the signed data.
|
sl@0
|
468 |
*
|
sl@0
|
469 |
* @return A non-modifiable pointer descriptor representing the signed data. */
|
sl@0
|
470 |
IMPORT_C virtual const TPtrC8 SignedDataL() const = 0;
|
sl@0
|
471 |
|
sl@0
|
472 |
/** Gets the fingerprint.
|
sl@0
|
473 |
*
|
sl@0
|
474 |
* The fingerprint returned is the SHA1 hash of the encoding of the entire object.
|
sl@0
|
475 |
*
|
sl@0
|
476 |
* @return A non-modifiable pointer descriptor representing the finger print. */
|
sl@0
|
477 |
IMPORT_C const TPtrC8 Fingerprint() const;
|
sl@0
|
478 |
|
sl@0
|
479 |
/** Gets the entire encoding.
|
sl@0
|
480 |
*
|
sl@0
|
481 |
* @return A non-modifiable pointer descriptor representing the entire encoding. */
|
sl@0
|
482 |
IMPORT_C const TPtrC8 Encoding() const;
|
sl@0
|
483 |
|
sl@0
|
484 |
/** Gets the signing algorithm ID used.
|
sl@0
|
485 |
*
|
sl@0
|
486 |
* @return The signing algorithm ID. */
|
sl@0
|
487 |
IMPORT_C const CSigningAlgorithmIdentifier& SigningAlgorithm() const;
|
sl@0
|
488 |
|
sl@0
|
489 |
/** Externalises the encoding of the entire object to a write stream.
|
sl@0
|
490 |
*
|
sl@0
|
491 |
* The fingerprint and the signed data can be regenerated after restoration.
|
sl@0
|
492 |
*
|
sl@0
|
493 |
* The presence of this function means that the standard templated operator<<()
|
sl@0
|
494 |
* can be used to externalise objects of this class.
|
sl@0
|
495 |
*
|
sl@0
|
496 |
* @param aStream Stream to which the object should be externalised. */
|
sl@0
|
497 |
IMPORT_C virtual void ExternalizeL(RWriteStream& aStream) const;
|
sl@0
|
498 |
|
sl@0
|
499 |
/** Internalises the encoded object from a read stream.
|
sl@0
|
500 |
|
sl@0
|
501 |
* The class makes use of a specification-specific parser class for extracting
|
sl@0
|
502 |
* the various elements, that is provided by a subclass of CSignedObject. For
|
sl@0
|
503 |
* this reason this function is pure virtual.
|
sl@0
|
504 |
*
|
sl@0
|
505 |
* The presence of this function means that the standard templated operator>>()
|
sl@0
|
506 |
* can be used to internalise objects of this class.
|
sl@0
|
507 |
*
|
sl@0
|
508 |
* @param aStream Stream from which the contents of the field should be internalised. */
|
sl@0
|
509 |
IMPORT_C virtual void InternalizeL(RReadStream& aStream) = 0;
|
sl@0
|
510 |
|
sl@0
|
511 |
/** Sets the signing key parameters.
|
sl@0
|
512 |
*
|
sl@0
|
513 |
* @param aParameters The signing key parameters. */
|
sl@0
|
514 |
IMPORT_C void SetParametersL(const CSigningKeyParameters& aParameters);
|
sl@0
|
515 |
|
sl@0
|
516 |
/** Gets the encoded data for the specified encoded data element, in the (to be
|
sl@0
|
517 |
* signed) tbsCertificate data structure, of the signed object.
|
sl@0
|
518 |
*
|
sl@0
|
519 |
* @param aIndex The encoded data element position in the tbsCertificate data
|
sl@0
|
520 |
* structure. See the enumeration: CX509Certificate::Anonymous.
|
sl@0
|
521 |
* @return The encoded data for the specified data element of the signed object. */
|
sl@0
|
522 |
IMPORT_C virtual const TPtrC8* DataElementEncoding(const TUint aIndex) const = 0;
|
sl@0
|
523 |
|
sl@0
|
524 |
/** Destructor.
|
sl@0
|
525 |
*
|
sl@0
|
526 |
* Frees all resources owned by the object. */
|
sl@0
|
527 |
IMPORT_C ~CSignedObject();
|
sl@0
|
528 |
|
sl@0
|
529 |
protected:
|
sl@0
|
530 |
/** Verifies a RSA signature using the specified encoded key.
|
sl@0
|
531 |
*
|
sl@0
|
532 |
* @param aEncodedKey The encoded key.
|
sl@0
|
533 |
* @return ETrue if the signature is valid, otherwise EFalse.
|
sl@0
|
534 |
* @internalAll
|
sl@0
|
535 |
*/
|
sl@0
|
536 |
TBool VerifyRSASignatureL(const TDesC8& aEncodedKey) const;
|
sl@0
|
537 |
|
sl@0
|
538 |
/** @internalAll */
|
sl@0
|
539 |
TBool VerifyRSASignatureL(const TDesC8& aEncodedKey, const TDesC8& aHash) const;
|
sl@0
|
540 |
|
sl@0
|
541 |
/** A pointer to a key factory object. */
|
sl@0
|
542 |
TKeyFactory* iKeyFactory;
|
sl@0
|
543 |
|
sl@0
|
544 |
/** A heap descriptor representing the entire encoding. */
|
sl@0
|
545 |
HBufC8* iEncoding;
|
sl@0
|
546 |
|
sl@0
|
547 |
/** The digital signature. */
|
sl@0
|
548 |
HBufC8* iSignature;
|
sl@0
|
549 |
|
sl@0
|
550 |
/** The fingerprint.
|
sl@0
|
551 |
*
|
sl@0
|
552 |
* The SHA1 hash of the encoding of the entire object. */
|
sl@0
|
553 |
HBufC8* iFingerprint;
|
sl@0
|
554 |
|
sl@0
|
555 |
/** The signing key parameters */
|
sl@0
|
556 |
CSigningKeyParameters* iParameters;
|
sl@0
|
557 |
|
sl@0
|
558 |
/** The signing algorithm ID. */
|
sl@0
|
559 |
CSigningAlgorithmIdentifier* iSigningAlgorithm;
|
sl@0
|
560 |
};
|
sl@0
|
561 |
|
sl@0
|
562 |
class CCertificate : public CSignedObject
|
sl@0
|
563 |
/** A data structure that binds a public key to a given individual.
|
sl@0
|
564 |
*
|
sl@0
|
565 |
* A certificate is a signed object, and adds a serial number, a validity period
|
sl@0
|
566 |
* and a subject public key.
|
sl@0
|
567 |
*
|
sl@0
|
568 |
* This is a base class for classes that implement certificates of particular types.
|
sl@0
|
569 |
*
|
sl@0
|
570 |
* @since v6.0 */
|
sl@0
|
571 |
{
|
sl@0
|
572 |
public:
|
sl@0
|
573 |
/** Destructor.
|
sl@0
|
574 |
*
|
sl@0
|
575 |
* Frees all resources owned by the object. */
|
sl@0
|
576 |
IMPORT_C ~CCertificate();
|
sl@0
|
577 |
|
sl@0
|
578 |
/** Gets the subject public key information.
|
sl@0
|
579 |
*
|
sl@0
|
580 |
* @return The subject public key information. */
|
sl@0
|
581 |
IMPORT_C const CSubjectPublicKeyInfo& PublicKey() const;
|
sl@0
|
582 |
|
sl@0
|
583 |
/** Gets the serial number.
|
sl@0
|
584 |
*
|
sl@0
|
585 |
* @return A non-modifiable pointer descriptor representing the serial number. */
|
sl@0
|
586 |
IMPORT_C const TPtrC8 SerialNumber() const;
|
sl@0
|
587 |
|
sl@0
|
588 |
/** Gets the validity period.
|
sl@0
|
589 |
*
|
sl@0
|
590 |
* @return The validity period. */
|
sl@0
|
591 |
IMPORT_C const CValidityPeriod& ValidityPeriod() const;
|
sl@0
|
592 |
|
sl@0
|
593 |
/** Tests whether a certificate is self-signed.
|
sl@0
|
594 |
*
|
sl@0
|
595 |
* @return ETrue, if it is self-signed; EFalse, otherwise. */
|
sl@0
|
596 |
IMPORT_C virtual TBool IsSelfSignedL() const = 0;
|
sl@0
|
597 |
|
sl@0
|
598 |
/** Gets the subject.
|
sl@0
|
599 |
*
|
sl@0
|
600 |
* @return A heap descriptor representing the subject. */
|
sl@0
|
601 |
IMPORT_C virtual HBufC* SubjectL() const = 0;
|
sl@0
|
602 |
|
sl@0
|
603 |
/** Gets the issuer.
|
sl@0
|
604 |
*
|
sl@0
|
605 |
* @return A heap descriptor representing the issuer. */
|
sl@0
|
606 |
IMPORT_C virtual HBufC* IssuerL() const = 0;
|
sl@0
|
607 |
|
sl@0
|
608 |
/** Gets the key identifier.
|
sl@0
|
609 |
*
|
sl@0
|
610 |
* @return The key identifier. */
|
sl@0
|
611 |
IMPORT_C virtual TKeyIdentifier KeyIdentifierL() const;
|
sl@0
|
612 |
|
sl@0
|
613 |
protected:
|
sl@0
|
614 |
/** The serial number. */
|
sl@0
|
615 |
HBufC8* iSerialNumber;
|
sl@0
|
616 |
|
sl@0
|
617 |
/** The validity period. */
|
sl@0
|
618 |
CValidityPeriod* iValidityPeriod;
|
sl@0
|
619 |
|
sl@0
|
620 |
/** The subject public key information. */
|
sl@0
|
621 |
CSubjectPublicKeyInfo* iSubjectPublicKeyInfo;
|
sl@0
|
622 |
};
|
sl@0
|
623 |
|
sl@0
|
624 |
#endif
|