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