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