epoc32/include/x509keys.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
* X.509 key classes and utility classes for key encoding/decoding.
williamr@2
    16
*
williamr@2
    17
*/
williamr@2
    18
williamr@2
    19
williamr@2
    20
/**
williamr@2
    21
 @file
williamr@4
    22
 @publishedAll
williamr@4
    23
 @released
williamr@2
    24
*/
williamr@2
    25
williamr@2
    26
#if !defined (__X509KEYS_H__)
williamr@2
    27
#define __X509KEYS_H__
williamr@2
    28
williamr@2
    29
#include <e32base.h>
williamr@2
    30
#include <e32std.h>
williamr@2
    31
#include <asymmetrickeys.h>
williamr@2
    32
#include <asymmetric.h>
williamr@2
    33
#include <hash.h>
williamr@2
    34
#include <bigint.h>
williamr@2
    35
#include <signed.h>
williamr@2
    36
williamr@2
    37
// Forward declarations
williamr@2
    38
class CASN1EncBase;
williamr@2
    39
class CASN1EncContainer;
williamr@2
    40
class CASN1EncSequence;
williamr@2
    41
class CASN1EncBitString;
williamr@2
    42
williamr@4
    43
williamr@4
    44
#ifndef SYMBIAN_ENABLE_SPLIT_HEADERS
williamr@4
    45
#include <x509keyencoder.h>
williamr@4
    46
#endif
williamr@4
    47
williamr@2
    48
class CX509RSAPublicKey : public CRSAPublicKey
williamr@2
    49
/** Adds the capability to decode DER-encoded RSA public keys.
williamr@2
    50
*
williamr@2
    51
* Adds a commitment to a specific encoding scheme allowing X.509 RSA public key 
williamr@2
    52
* superclasses to remain encoding-independent.
williamr@2
    53
*
williamr@2
    54
*
williamr@2
    55
* @since v6.0 
williamr@2
    56
*/
williamr@2
    57
	{
williamr@2
    58
public:
williamr@2
    59
	/** Creates a new RSA Public key object from the specified buffer containing the 
williamr@2
    60
	* encoded binary representation.
williamr@2
    61
	* 
williamr@2
    62
	* Initialises the object from its encoded binary form into an internal representation.
williamr@2
    63
	* 
williamr@2
    64
	* @param aBinaryData	The encoded binary representation.
williamr@2
    65
	* @return				A pointer to the new CX509RSAPublicKey object. */
williamr@2
    66
	IMPORT_C static CX509RSAPublicKey* NewL(const TDesC8& aBinaryData);
williamr@2
    67
	
williamr@2
    68
	/** Creates a new RSA Public Key object from the specified buffer containing the
williamr@2
    69
	* encoded binary representation, and puts a pointer to it onto the cleanup stack.
williamr@2
    70
	* 
williamr@2
    71
	* @param aBinaryData	The encoded binary representation.
williamr@2
    72
	* @return				A pointer to the new CX509RSAPublicKey object. */
williamr@2
    73
	IMPORT_C static CX509RSAPublicKey* NewLC(const TDesC8& aBinaryData);
williamr@2
    74
	
williamr@2
    75
	/** Creates a new RSA Public key object from the specified buffer containing the 
williamr@2
    76
	* encoded binary representation, starting at the specified offset.
williamr@2
    77
	* 
williamr@2
    78
	* @param aBinaryData	The encoded binary representation.
williamr@2
    79
	* @param aPos			The offset position from which to start decoding.
williamr@2
    80
	* @return				A pointer to the new CX509RSAPublicKey object. */
williamr@2
    81
	IMPORT_C static CX509RSAPublicKey* NewL(const TDesC8& aBinaryData, TInt& aPos);
williamr@2
    82
	
williamr@2
    83
	/** Creates a new RSA Public key object from the specified buffer containing the 
williamr@2
    84
	* encoded binary representation, starting at the specified offset, and puts 
williamr@2
    85
	* a pointer to it onto the cleanup stack.
williamr@2
    86
	* 
williamr@2
    87
	* @param aBinaryData	The encoded binary representation.
williamr@2
    88
	* @param aPos			The offset position from which to start decoding.
williamr@2
    89
	* @return				A pointer to the new CX509RSAPublicKey object. */
williamr@2
    90
	IMPORT_C static CX509RSAPublicKey* NewLC(const TDesC8& aBinaryData, TInt& aPos);
williamr@2
    91
private:
williamr@2
    92
	void ConstructL(const TDesC8& aBinaryData, TInt& aPos);
williamr@2
    93
	CX509RSAPublicKey();
williamr@2
    94
	};
williamr@2
    95
williamr@2
    96
class TASN1EncRSAPublicKey
williamr@2
    97
/**
williamr@2
    98
 * Class for encoding RSA public keys to ASN.1 encoding.
williamr@2
    99
 * 
williamr@2
   100
 * @since v8.0 
williamr@2
   101
 */
williamr@2
   102
	{
williamr@2
   103
public:
williamr@2
   104
	/** 
williamr@2
   105
	 * Encodes the supplied public key into buffer in DER format ASN.1:
williamr@2
   106
	 * @code
williamr@2
   107
	 * 		SEQUENCE-OF
williamr@2
   108
	 * 			INTEGER modulus
williamr@2
   109
	 * 			INTEGER exponent
williamr@2
   110
	 * @endcode
williamr@2
   111
	 * 
williamr@2
   112
	 * @param aKey	Key to encode.
williamr@2
   113
	 * @return		Allocated buffer containing DER encoding of
williamr@2
   114
	 *     			the supplied key aKey.
williamr@2
   115
	 */
williamr@2
   116
	IMPORT_C HBufC8* EncodeDERL(const CRSAPublicKey& aKey) const;
williamr@2
   117
	};
williamr@2
   118
williamr@2
   119
class TASN1DecRSAPublicKey
williamr@2
   120
/** 
williamr@2
   121
 * Class for decoding RSA public keys from ASN.1 DER encoding.
williamr@2
   122
 * 
williamr@2
   123
 * @since v8.0
williamr@2
   124
 */
williamr@2
   125
	{
williamr@2
   126
public:
williamr@2
   127
	/** 
williamr@2
   128
	 * Decodes an RSA key from the supplied buffer starting at the 
williamr@2
   129
	 * specified position.
williamr@2
   130
	 * 
williamr@2
   131
	 * @param aDER	Buffer containing DER ASN.1 encoding of the key.
williamr@2
   132
	 * @param aPos	Starting position in the buffer (updated on exit).
williamr@2
   133
	 * @return		A pointer to the new CRSAPublicKey object.
williamr@2
   134
	 */
williamr@2
   135
	IMPORT_C CRSAPublicKey* DecodeDERL(const TDesC8& aDER, TInt& aPos) const;
williamr@2
   136
	};
williamr@2
   137
williamr@2
   138
class TASN1DecRSAKeyPair
williamr@2
   139
/** 
williamr@2
   140
 * Class for decoding RSA key pairs from ASN.1 DER encoding.
williamr@2
   141
 * 
williamr@2
   142
 * @since v8.0
williamr@2
   143
 */
williamr@2
   144
	{
williamr@2
   145
public:
williamr@2
   146
	/**
williamr@2
   147
	 * Decodes an RSA key pair from buffer containing ASN.1 
williamr@2
   148
	 * DER-encoded private key. The encoding of a private key 
williamr@2
   149
	 * contains public key components as well.
williamr@2
   150
	 * 
williamr@2
   151
	 * @param aDER			DER-encoded private key.
williamr@2
   152
	 * @param aPos			Position in the buffer to start decoding 
williamr@2
   153
	 *     					(updated on exit).
williamr@2
   154
	 * @param aPublicKey	On return, the RSA public key object
williamr@2
   155
	 * @param aPrivateKey	On return, the RSA private key object
williamr@2
   156
	 * @param aKeyType		Key type, default is @c EStandardCRT
williamr@2
   157
	 */
williamr@2
   158
	IMPORT_C void DecodeDERL(const TDesC8& aDER, TInt& aPos, 
williamr@2
   159
								CRSAPublicKey*& aPublicKey,
williamr@2
   160
								CRSAPrivateKey*& aPrivateKey, 
williamr@2
   161
								TRSAPrivateKeyType aKeyType = EStandardCRT);
williamr@2
   162
	};
williamr@2
   163
williamr@2
   164
class CX509DSAPublicKey : public CDSAPublicKey
williamr@2
   165
/** Encapsulates the X.509 DSA public key.
williamr@2
   166
* 
williamr@2
   167
* Adds a commitment to a specific encoding scheme allowing superclasses to remain 
williamr@2
   168
* encoding-independent. 
williamr@2
   169
* 
williamr@2
   170
* @since v6.0 
williamr@2
   171
*/
williamr@2
   172
// DSA public key, params, signature.
williamr@2
   173
	{
williamr@2
   174
public:
williamr@2
   175
	/** Creates a new X.509 DSA public key object.
williamr@2
   176
	* 
williamr@2
   177
	* @param aParamsData	A non-modifiable descriptor representing the entire encoding.
williamr@2
   178
	* @param aBinaryData	The encoded binary representation.
williamr@2
   179
	* @return				A pointer to the new CX509DSAPublicKey object. */
williamr@2
   180
	IMPORT_C static CX509DSAPublicKey* NewL(const TDesC8& aParamsData, const TDesC8& aBinaryData);
williamr@2
   181
williamr@2
   182
	/** Creates a new X.509 DSA public key object, and puts a pointer to it onto the cleanup stack.
williamr@2
   183
	* 
williamr@2
   184
	* @param aParamsData	A non-modifiable descriptor representing the entire encoding.
williamr@2
   185
	* @param aBinaryData	The encoded binary representation.
williamr@2
   186
	* @return				A pointer to the new CX509DSAPublicKey object. */
williamr@2
   187
	IMPORT_C static CX509DSAPublicKey* NewLC(const TDesC8& aParamsData, const TDesC8& aBinaryData);
williamr@2
   188
	
williamr@2
   189
	/** Creates a new X.509 DSA public key object.
williamr@2
   190
	* 
williamr@2
   191
	* @param aParams		The DSA parameters.
williamr@2
   192
	* @param aBinaryData	The encoded binary representation. 
williamr@2
   193
	* @return 				A pointer to the new CX509DSAPublicKey object. */
williamr@2
   194
	IMPORT_C static CX509DSAPublicKey* NewL(const CDSAParameters& aParams, const TDesC8& aBinaryData);
williamr@2
   195
	
williamr@2
   196
	/** Creates a new X.509 DSA public key object, and puts a pointer to it onto the cleanup stack.
williamr@2
   197
	* 
williamr@2
   198
	* @param aParams		The DSA parameters.
williamr@2
   199
	* @param aBinaryData	The encoded binary representation. 
williamr@2
   200
	* @return 				A pointer to the new CX509DSAPublicKey object. */
williamr@2
   201
	IMPORT_C static CX509DSAPublicKey* NewLC(const CDSAParameters& aParams, const TDesC8& aBinaryData);
williamr@2
   202
	
williamr@2
   203
	/** Creates a new X.509 DSA public key object.
williamr@2
   204
	* 
williamr@2
   205
	* @param aParamsData	A non-modifiable descriptor representing the entire encoding.
williamr@2
   206
	* @param aBinaryData	The encoded binary representation.
williamr@2
   207
	* @param aPos			The position from which to start decoding.
williamr@2
   208
	* @return 				A pointer to the new CX509DSAPublicKey object. */
williamr@2
   209
	IMPORT_C static CX509DSAPublicKey* NewL(const TDesC8& aParamsData, const TDesC8& aBinaryData,TInt& aPos);
williamr@2
   210
	
williamr@2
   211
	/** Creates a new X.509 DSA public key object, and puts a pointer to it onto the cleanup stack.
williamr@2
   212
	* 
williamr@2
   213
	* @param aParamsData	A non-modifiable descriptor representing the entire encoding.	
williamr@2
   214
	* @param aBinaryData	The encoded binary representation.
williamr@2
   215
	* @param aPos			The position from which to start decoding.
williamr@2
   216
	* @return 				A pointer to the new CX509DSAPublicKey object. */
williamr@2
   217
	IMPORT_C static CX509DSAPublicKey* NewLC(const TDesC8& aParamsData, const TDesC8& aBinaryData, TInt& aPos);
williamr@2
   218
	
williamr@2
   219
	/** Creates a new X.509 DSA public key object.
williamr@2
   220
	* 
williamr@2
   221
	* @param aParams		The DSA parameters.
williamr@2
   222
	* @param aBinaryData	The encoded binary representation.
williamr@2
   223
	* @param aPos			The position from which to start decoding. 
williamr@2
   224
	* @return 				A pointer to the new CX509DSAPublicKey object. */
williamr@2
   225
	IMPORT_C static CX509DSAPublicKey* NewL(const CDSAParameters& aParams, const TDesC8& aBinaryData, TInt& aPos);
williamr@2
   226
	
williamr@2
   227
	/** Creates a new X.509 DSA public key object, and puts a pointer to it onto the cleanup stack.
williamr@2
   228
	* 
williamr@2
   229
	* @param aParams 		The DSA parameters.
williamr@2
   230
	* @param aBinaryData	The encoded binary representation.
williamr@2
   231
	* @param aPos			The position from which to start decoding. 
williamr@2
   232
	* @return				A pointer to the new CX509DSAPublicKey object. */
williamr@2
   233
	IMPORT_C static CX509DSAPublicKey* NewLC(const CDSAParameters& aParams, const TDesC8& aBinaryData, TInt& aPos);
williamr@2
   234
public:
williamr@2
   235
	/** Gets the DSA parameters from the encoding key.
williamr@2
   236
	* 
williamr@2
   237
	* @param aParamsData	A non-modifiable descriptor representing the entire encoding.
williamr@2
   238
	* @return 				The DSA parameters. */
williamr@2
   239
	IMPORT_C static CDSAParameters* DSAParametersL(const TDesC8& aParamsData);
williamr@2
   240
protected:
williamr@2
   241
	/** @internalComponent */
williamr@2
   242
	void ConstructL(const TDesC8& aParamsData, const TDesC8& aBinaryData, TInt& aPos);
williamr@2
   243
	/** @internalComponent */
williamr@2
   244
	void ConstructL(const CDSAParameters& aParams, const TDesC8& aBinaryData, TInt& aPos);
williamr@2
   245
	/** @internalComponent */
williamr@2
   246
	CX509DSAPublicKey();
williamr@2
   247
	};
williamr@2
   248
 
williamr@2
   249
class TASN1DecDSAKeyPair
williamr@2
   250
/** 
williamr@2
   251
 * Class for decoding DSA key pairs from ASN.1 DER encoding.
williamr@2
   252
 * 
williamr@2
   253
 * @since v8.0
williamr@2
   254
 */
williamr@2
   255
	{
williamr@2
   256
public:
williamr@2
   257
	/**
williamr@2
   258
	 * Decodes a DSA key pair from a buffer containing an ASN.1 
williamr@2
   259
	 * DER-encoded private key. 
williamr@2
   260
	 * 
williamr@2
   261
	 * The encoding of the private key contains public key components as well. 
williamr@2
   262
	 * 
williamr@2
   263
	 * The DER encoding has the following format:
williamr@2
   264
	 * @verbatim
williamr@2
   265
	 *     SEQUENCE-OF
williamr@2
   266
     *         INTEGER version (==0, ignored)
williamr@2
   267
	 *         INTEGER p (public prime)
williamr@2
   268
	 *         INTEGER q (160-bit public subprime, q | p-1)
williamr@2
   269
	 *         INTEGER g (public generator of subgroup)
williamr@2
   270
	 *         INTEGER x (private key)
williamr@2
   271
	 *         INTEGER y (public key y=g^x)
williamr@2
   272
	 * @endverbatim
williamr@2
   273
	 * 
williamr@2
   274
	 * @param aDER			DER-encoded private key.
williamr@2
   275
	 * @param aPos			Position in the buffer to start decoding 
williamr@2
   276
	 *		     			(updated on exit).
williamr@2
   277
	 * @param aPublicKey	On return, the DSA public key object
williamr@2
   278
	 * @param aPrivateKey	On return, the DSA private key object
williamr@2
   279
	 */
williamr@2
   280
	IMPORT_C void DecodeDERL(const TDesC8& aDER, TInt& aPos, 
williamr@2
   281
								CDSAPublicKey*& aPublicKey, CDSAPrivateKey*& aPrivateKey);
williamr@2
   282
	};
williamr@2
   283
williamr@2
   284
/**
williamr@2
   285
 * Class for encoding DSA public keys to ASN.1 encoding.
williamr@2
   286
 * 
williamr@2
   287
 * @since v8.0
williamr@2
   288
 */
williamr@2
   289
class TASN1EncDSAPublicKey
williamr@2
   290
	{
williamr@2
   291
public:
williamr@2
   292
	/** 
williamr@2
   293
	 * Encodes the supplied public key into a buffer in DER format.
williamr@2
   294
	 * 
williamr@2
   295
	 * Note that the encoding has the following format:
williamr@2
   296
	 * @code
williamr@2
   297
	 *     SEQUENCE-OF
williamr@2
   298
	 *         SEQUENCE-OF
williamr@2
   299
	 *             INTEGER p
williamr@2
   300
	 *             INTEGER q
williamr@2
   301
	 *             INTEGER g
williamr@2
   302
	 *         BIT STRING (encoded INTEGER public value)
williamr@2
   303
	 * @endcode
williamr@2
   304
	 * 
williamr@2
   305
	 * @param aKey	Key to encode.
williamr@2
   306
	 * @return		Sequence containing public key information.
williamr@2
   307
	 */
williamr@2
   308
	IMPORT_C CASN1EncSequence* EncodeDERL(const CDSAPublicKey& aKey) const;
williamr@2
   309
williamr@2
   310
	/**
williamr@2
   311
	 * Encodes DSA parameters into an ASN.1 encoding structure suitable for 
williamr@2
   312
	 * inclusion into other objects, like a PKCS#10 certificate request.
williamr@2
   313
	 *
williamr@2
   314
	 * Note that the encoding has the following form:
williamr@2
   315
	 * @code
williamr@2
   316
	 *     SEQUENCE-OF
williamr@2
   317
	 *         INTEGER p
williamr@2
   318
	 *         INTEGER q
williamr@2
   319
	 *         INTEGER g
williamr@2
   320
	 * @endcode
williamr@2
   321
	 *
williamr@2
   322
	 * @param aKey	DSA public key.
williamr@2
   323
	 * @return		ASN.1 encoding structure on the cleanup stack.
williamr@2
   324
	 */
williamr@2
   325
	IMPORT_C CASN1EncSequence* EncodeParamsLC(const CDSAPublicKey& aKey) const;
williamr@2
   326
williamr@2
   327
	/** 
williamr@2
   328
	 * Encodes a public key as a bit string.
williamr@2
   329
	 *
williamr@2
   330
	 * @param aKey 	DSA public key.
williamr@2
   331
	 * @return	ASN.1 bit string (public key). This is left on the cleanup stack.
williamr@2
   332
	 */
williamr@2
   333
williamr@2
   334
	IMPORT_C CASN1EncBitString* EncodePublicValueLC(const CDSAPublicKey& aKey) const;
williamr@2
   335
	};
williamr@2
   336
williamr@2
   337
class CX509DSASignature : public CDSASignature
williamr@2
   338
/** Encapsulates the X.509 DSA signature.
williamr@2
   339
* 
williamr@2
   340
* Adds a commitment to a specific encoding scheme allowing superclasses to remain 
williamr@2
   341
* encoding-independent. 
williamr@2
   342
* 
williamr@2
   343
* @since v6.0 */
williamr@2
   344
	{
williamr@2
   345
public:
williamr@2
   346
	/** Creates a new DSA Signature object from the specified buffer containing the 
williamr@2
   347
	* encoded binary representation.
williamr@2
   348
	* 
williamr@2
   349
	* @param aBinaryData	The encoded binary representation.
williamr@2
   350
	* @return				A pointer to the new CX509DSASignature object. */
williamr@2
   351
	IMPORT_C static CX509DSASignature* NewL(const TDesC8& aBinaryData);
williamr@2
   352
	
williamr@2
   353
	/** Creates a new DSA Signature object from the specified buffer containing the 
williamr@2
   354
	* encoded binary representation, and puts a pointer to it onto the cleanup stack.
williamr@2
   355
	* 
williamr@2
   356
	* @param aBinaryData	The encoded binary representation.
williamr@2
   357
	* @return				A pointer to the new CX509DSASignature object. */
williamr@2
   358
	IMPORT_C static CX509DSASignature* NewLC(const TDesC8& aBinaryData);
williamr@2
   359
	
williamr@2
   360
	/** Creates a new DSA Signature object from the specified buffer containing the 
williamr@2
   361
	* encoded binary representation, starting at the specified offset.
williamr@2
   362
	* 
williamr@2
   363
	* @param aBinaryData	The encoded binary representation.
williamr@2
   364
	* @param aPos			The offset position from which to start decoding.
williamr@2
   365
	* @return				A pointer to the new CX509DSASignature object. */
williamr@2
   366
	IMPORT_C static CX509DSASignature* NewL(const TDesC8& aBinaryData, TInt& aPos);
williamr@2
   367
	
williamr@2
   368
	/** Creates a new DSA Signature object from the specified buffer containing the 
williamr@2
   369
	* encoded binary representation, starting at the specified offset, and puts 
williamr@2
   370
	* a pointer to it onto the cleanup stack.
williamr@2
   371
	* 
williamr@2
   372
	* @param aBinaryData	The encoded binary representation.
williamr@2
   373
	* @param aPos			The offset position from which to start decoding.
williamr@2
   374
	* @return				A pointer to the new CX509DSASignature object. */
williamr@2
   375
	IMPORT_C static CX509DSASignature* NewLC(const TDesC8& aBinaryData, TInt& aPos);
williamr@2
   376
private:
williamr@2
   377
	void ConstructL(const TDesC8& aBinaryData, TInt& aPos);
williamr@2
   378
	CX509DSASignature();
williamr@2
   379
	};
williamr@2
   380
williamr@2
   381
class CX509DHPublicKey : public CDHPublicKey
williamr@2
   382
/** Provides clients with the information they need for Diffie-Hellman key exchange 
williamr@2
   383
* within a protocol. 
williamr@2
   384
* 
williamr@2
   385
* @since v6.0 */
williamr@2
   386
	{
williamr@2
   387
public:
williamr@2
   388
	/** Creates a new CX509DHPublicKey object from the specified buffer containing the encoded 
williamr@2
   389
	* binary representation.
williamr@2
   390
	* 
williamr@2
   391
	* @param aParamsData	A non-modifiable descriptor representing the entire encoding.
williamr@2
   392
	* @param aKeyData 		
williamr@2
   393
	* @return 				A pointer to the new CX509DHPublicKey object.*/
williamr@2
   394
	IMPORT_C static CX509DHPublicKey* NewL(const TDesC8& aParamsData, const TDesC8& aKeyData);
williamr@2
   395
williamr@2
   396
	/** Creates a new CX509DHPublicKey object from the specified buffer containing the encoded 
williamr@2
   397
	* binary representation, and puts a pointer to it onto the cleanup stack.
williamr@2
   398
	* 
williamr@2
   399
	* @param aParamsData	A non-modifiable descriptor representing the entire encoding.
williamr@2
   400
	* @param aKeyData 		
williamr@2
   401
	* @return 				A pointer to the new CX509DHPublicKey object.*/
williamr@2
   402
	IMPORT_C static CX509DHPublicKey* NewLC(const TDesC8& aParamsData, const TDesC8& aKeyData);
williamr@2
   403
public:
williamr@2
   404
	/** Destructor.
williamr@2
   405
	* 
williamr@2
   406
	* Frees all resources owned by the object, prior to its destruction. */
williamr@2
   407
	IMPORT_C virtual ~CX509DHPublicKey();
williamr@2
   408
protected:
williamr@2
   409
	/** @internalComponent */
williamr@2
   410
	CX509DHPublicKey();
williamr@2
   411
	/** @internalComponent */
williamr@2
   412
	void ConstructL(const TDesC8& aParamsData, const TDesC8& aKeyData);
williamr@2
   413
	};
williamr@2
   414
williamr@2
   415
class CX509DHKeyPair : public CDHKeyPair
williamr@2
   416
/** This class represents the Diffie-Hellman Key Pair.
williamr@2
   417
*
williamr@2
   418
* @since v8.0 */
williamr@2
   419
{
williamr@2
   420
public:
williamr@2
   421
	/** Creates a new DH key pair object from the specified buffer containing 
williamr@2
   422
	* the encoded binary representation .
williamr@2
   423
	*  
williamr@2
   424
	* @param aParamsData	A non-modifiable descriptor representing the entire encoding.
williamr@2
   425
	* @return				A pointer to the new CX509DHKeyPair object.
williamr@2
   426
	*/
williamr@2
   427
	IMPORT_C static CX509DHKeyPair* NewL(const TDesC8& aParamsData);
williamr@2
   428
williamr@2
   429
	/** Creates a new DH Key Pair object from the specified buffer containing the encoded binary  
williamr@2
   430
	* representation, and puts a pointer to it onto the cleanup stack.
williamr@2
   431
	*
williamr@2
   432
	* @param aParamsData	A non-modifiable descriptor representing the entire encoding.
williamr@2
   433
	* @return				A pointer to the new CX509DHKeyPair object.
williamr@2
   434
	*/
williamr@2
   435
	IMPORT_C static CX509DHKeyPair* NewLC(const TDesC8& aParamsData);
williamr@2
   436
public:
williamr@2
   437
williamr@2
   438
	/** Virtual Destructor.
williamr@2
   439
	* Frees all resources owned by the object, prior to its destruction. 
williamr@2
   440
	*
williamr@2
   441
	*/
williamr@2
   442
	IMPORT_C virtual ~CX509DHKeyPair();
williamr@2
   443
protected:
williamr@2
   444
	/** @internalComponent */
williamr@2
   445
	CX509DHKeyPair();
williamr@2
   446
	/** @internalComponent */
williamr@2
   447
	void ConstructL(const TDesC8& aParamsData);
williamr@2
   448
};
williamr@2
   449
williamr@2
   450
class CX509DHValidationParams : public CBase
williamr@2
   451
/** Validates Diffie-Hellman (DH) Domain parameters.
williamr@2
   452
* 
williamr@2
   453
* Provides access to the DH Validation Parameters, which are used to determine 
williamr@2
   454
* if the DH Public Key has been generated in conformance with the algorithm 
williamr@2
   455
* specified in ESDH (see RFC 2631). 
williamr@2
   456
* 
williamr@2
   457
* @since v6.0 */
williamr@2
   458
	{
williamr@2
   459
public:
williamr@2
   460
	/** Creates a new DH Validation parameters object from the specified buffer containing 
williamr@2
   461
	* the encoded binary representation.
williamr@2
   462
	* 
williamr@2
   463
	* @param aBinaryData	The encoded binary representation.
williamr@2
   464
	* @return				A pointer to the new CX509DHValidationParams object. */
williamr@2
   465
	IMPORT_C static CX509DHValidationParams* NewL(const TDesC8& aBinaryData);
williamr@2
   466
	
williamr@2
   467
	/** Creates a new DH Validation parameters object from the specified buffer containing 
williamr@2
   468
	* the encoded binary representation, and puts a pointer to it onto the cleanup stack.
williamr@2
   469
	* 
williamr@2
   470
	* @param aBinaryData	The encoded binary representation.
williamr@2
   471
	* @return				A pointer to the new CX509DHValidationParams object. */
williamr@2
   472
	IMPORT_C static CX509DHValidationParams* NewLC(const TDesC8& aBinaryData);
williamr@2
   473
	
williamr@2
   474
	/** Creates a new DH Validation parameters object from the specified buffer containing 
williamr@2
   475
	* the encoded binary representation, starting at the specified offset.
williamr@2
   476
	* 
williamr@2
   477
	* @param aBinaryData	The encoded binary representation.
williamr@2
   478
	* @param aPos			The offset position from which to start decoding.
williamr@2
   479
	* @return				A pointer to the new CX509DHValidationParams object. */
williamr@2
   480
	IMPORT_C static CX509DHValidationParams* NewL(const TDesC8& aBinaryData, TInt& aPos);
williamr@2
   481
	
williamr@2
   482
	/** Creates a new DH Validation parameters object from the specified buffer containing 
williamr@2
   483
	* the encoded binary representation, starting at the specified offset, and puts 
williamr@2
   484
	* a pointer to it onto the cleanup stack.
williamr@2
   485
	* 
williamr@2
   486
	* @param aBinaryData	The encoded binary representation.
williamr@2
   487
	* @param aPos			The offset position from which to start decoding.
williamr@2
   488
	* @return				A pointer to the new CX509DHValidationParams object. */
williamr@2
   489
	IMPORT_C static CX509DHValidationParams* NewLC(const TDesC8& aBinaryData, TInt& aPos);
williamr@2
   490
	
williamr@2
   491
	/** Gets a DSA prime generation seed.
williamr@2
   492
	* 
williamr@2
   493
	* @return	The bit string parameter used as the seed. */
williamr@2
   494
	IMPORT_C const TPtrC8 Seed() const;
williamr@2
   495
	
williamr@2
   496
	/** Gets the output from a DSA prime generation counter.
williamr@2
   497
	* 
williamr@2
   498
	* @return	The integer value output. */
williamr@2
   499
	IMPORT_C const TInteger& PGenCounter() const;
williamr@2
   500
	
williamr@2
   501
	/** Destructor.
williamr@2
   502
	* 
williamr@2
   503
	* Frees all resources owned by the object, prior to its destruction. */
williamr@2
   504
	virtual ~CX509DHValidationParams();
williamr@2
   505
protected:
williamr@2
   506
	/** @internalComponent */
williamr@2
   507
	CX509DHValidationParams();
williamr@2
   508
	/** @internalComponent */
williamr@2
   509
	void ConstructL(const TDesC8& aBinaryData, TInt& aPos);
williamr@2
   510
	HBufC8* iSeed;
williamr@2
   511
	RInteger iPGenCounter;
williamr@2
   512
	};
williamr@2
   513
williamr@2
   514
class CX509DHDomainParams : public CBase
williamr@2
   515
/** Encapsulates the compulsory Diffie-Hellman domain parameter values P and G 
williamr@2
   516
* (See RFC 2459). 
williamr@2
   517
* 
williamr@2
   518
* @since v6.0 */
williamr@2
   519
	{
williamr@2
   520
public:
williamr@2
   521
	/** Creates a new DH Domain parameters object from the specified buffer containing 
williamr@2
   522
	* the encoded binary representation.
williamr@2
   523
	* 
williamr@2
   524
	* @param aBinaryData	The encoded binary representation.
williamr@2
   525
	* @return				A pointer to the new CX509DHDomainParams object. */
williamr@2
   526
	IMPORT_C static CX509DHDomainParams* NewL(const TDesC8& aBinaryData);
williamr@2
   527
	
williamr@2
   528
	/** Creates a new DH Domain parameters object from the specified buffer containing 
williamr@2
   529
	* the encoded binary representation, and puts a pointer to it onto the cleanup stack.
williamr@2
   530
	* 
williamr@2
   531
	* @param aBinaryData	The encoded binary representation.
williamr@2
   532
	* @return				A pointer to the new CX509DHDomainParams object. */
williamr@2
   533
	IMPORT_C static CX509DHDomainParams* NewLC(const TDesC8& aBinaryData);
williamr@2
   534
	
williamr@2
   535
	/** Creates a new DH Domain parameters object from the specified buffer containing 
williamr@2
   536
	* the encoded binary representation, starting at the specified offset.
williamr@2
   537
	* 
williamr@2
   538
	* @param aBinaryData	The encoded binary representation.
williamr@2
   539
	* @param aPos			The offset position from which to start decoding.
williamr@2
   540
	* @return				A pointer to the new CX509DHDomainParams object. */
williamr@2
   541
	IMPORT_C static CX509DHDomainParams* NewL(const TDesC8& aBinaryData, TInt& aPos);
williamr@2
   542
	
williamr@2
   543
	/** Creates a new DH Domain parameters object from the specified buffer containing 
williamr@2
   544
	* the encoded binary representation, starting at the specified offset, and puts 
williamr@2
   545
	* a pointer to it onto the cleanup stack.
williamr@2
   546
	* 
williamr@2
   547
	* @param aBinaryData	The encoded binary representation.
williamr@2
   548
	* @param aPos			The offset position from which to start decoding.
williamr@2
   549
	* @return				A pointer to the new CX509DHDomainParams object. */
williamr@2
   550
	IMPORT_C static CX509DHDomainParams* NewLC(const TDesC8& aBinaryData, TInt& aPos);
williamr@2
   551
	
williamr@2
   552
	/** Gets the compulsory parameter value P.
williamr@2
   553
	* 
williamr@2
   554
	* @return	The compulsory parameter value P. */
williamr@2
   555
	IMPORT_C const TInteger& P() const;	
williamr@2
   556
	
williamr@2
   557
	/** Gets the compulsory parameter value G.
williamr@2
   558
	* 
williamr@2
   559
	* @return	The compulsory parameter value G. */
williamr@2
   560
	IMPORT_C const TInteger& G() const;	
williamr@2
   561
williamr@2
   562
//the next 3 members are optional, in which case NULL is returned
williamr@2
   563
//the returned objects remain the property of this object
williamr@2
   564
williamr@2
   565
//N.B. according to RFC 2459 the Q member is *not* optional, 
williamr@2
   566
//however it is not essential for doing DH, and empirical studies
williamr@2
   567
//suggest it doesn't get included much, so I'm relaxing the spec here
williamr@2
   568
//to permit DomainParams objects which contain no Q.
williamr@2
   569
williamr@2
   570
	/** Gets the optional value Q.
williamr@2
   571
	* 
williamr@2
   572
	* @return	The optional value Q. */
williamr@2
   573
	IMPORT_C const TInteger& Q() const;	
williamr@2
   574
	
williamr@2
   575
	/** Gets the optional value J.
williamr@2
   576
	* 
williamr@2
   577
	* @return	The optional value J. */
williamr@2
   578
	IMPORT_C const TInteger& J() const;									
williamr@2
   579
	
williamr@2
   580
	/** Gets the optional validation parameters.
williamr@2
   581
	* 
williamr@2
   582
	* @return	The optional validation parameters. */
williamr@2
   583
	IMPORT_C const CX509DHValidationParams* ValidationParams() const;
williamr@2
   584
	
williamr@2
   585
	/** Destructor.
williamr@2
   586
	* 
williamr@2
   587
	* Frees all resources owned by the object, prior to its destruction. */
williamr@2
   588
	virtual ~CX509DHDomainParams();
williamr@2
   589
protected:
williamr@2
   590
	/** @internalComponent */
williamr@2
   591
	CX509DHDomainParams();
williamr@2
   592
	/** @internalComponent */
williamr@2
   593
	void ConstructL(const TDesC8& aBinaryData, TInt& aPos);
williamr@2
   594
	RInteger iP;
williamr@2
   595
	RInteger iG;
williamr@2
   596
	RInteger iQ;
williamr@2
   597
	RInteger iJ;
williamr@2
   598
	CX509DHValidationParams* iValidationParams;
williamr@2
   599
	};
williamr@2
   600
williamr@2
   601
#endif