os/security/crypto/weakcryptospi/inc/asymmetrickeys.h
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/security/crypto/weakcryptospi/inc/asymmetrickeys.h	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,1128 @@
     1.4 +/*
     1.5 +* Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.6 +* All rights reserved.
     1.7 +* This component and the accompanying materials are made available
     1.8 +* under the terms of the License "Eclipse Public License v1.0"
     1.9 +* which accompanies this distribution, and is available
    1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.11 +*
    1.12 +* Initial Contributors:
    1.13 +* Nokia Corporation - initial contribution.
    1.14 +*
    1.15 +* Contributors:
    1.16 +*
    1.17 +* Description: 
    1.18 +* ** IMPORTANT ** API's in this file are published to 3rd party developers via the 
    1.19 +* Symbian website. Changes to these API's should be treated as PublishedAll API changes and the Security TA should be consulted.
    1.20 +* Asymmetric keys implementation
    1.21 +*
    1.22 +*/
    1.23 +
    1.24 +
    1.25 +/**
    1.26 + @file 
    1.27 + @publishedAll
    1.28 + @released 
    1.29 +*/
    1.30 + 
    1.31 +#ifndef __ASYMMETRICKEYS_H__
    1.32 +#define __ASYMMETRICKEYS_H__
    1.33 +
    1.34 +#include <e32base.h>
    1.35 +#include <random.h>
    1.36 +#include <bigint.h>
    1.37 +
    1.38 +/** 
    1.39 +* Defines the various ways of representing supported RSA private keys.
    1.40 +* 
    1.41 +*/
    1.42 +enum TRSAPrivateKeyType 
    1.43 +	{
    1.44 +	/** 
    1.45 +	 * Standard type of RSA private key
    1.46 +	 * 
    1.47 +	 * This consists of the modulus (n) and decryption exponent (d).
    1.48 +	 */
    1.49 +	EStandard,
    1.50 +	/** 
    1.51 +	 * CRT (Chinese Remainder Theorem) type of RSA private key
    1.52 +	 *
    1.53 +	 * This consists of the the first factor (p), the second factor (q), 
    1.54 +	 * the first factor's CRT exponent (dP), the second factor's CRT exponent (dQ),
    1.55 +	 * and the (first) CRT coefficient (qInv). The two factors, p and q, are the
    1.56 +	 * first two prime factors of the RSA modulus, n.
    1.57 +	 */
    1.58 +	EStandardCRT
    1.59 +	//We may support types like this in the future (currently these are a patent
    1.60 +	//minefield):
    1.61 +	//EMulti, //multi prime version of EStandard
    1.62 +	//EMultiCRT //multi prime version of EStandardCRT
    1.63 +	};
    1.64 +
    1.65 +/** 
    1.66 +* Concrete class representing the parameters common to both an RSA public and
    1.67 +* private key.
    1.68 +* 
    1.69 +* See ANSI X9.31 and RSA PKCS#1
    1.70 +*
    1.71 +*/
    1.72 +class CRSAParameters : public CBase
    1.73 +	{
    1.74 +public:
    1.75 +	/** 
    1.76 +	 * Gets the RSA parameter, n (the modulus)
    1.77 +	 *
    1.78 +	 * @return	The RSA parameter, n
    1.79 +	 */
    1.80 +	IMPORT_C const TInteger& N(void) const;
    1.81 +	
    1.82 +	/** Destructor */
    1.83 +	IMPORT_C virtual ~CRSAParameters(void);
    1.84 +protected:
    1.85 +	/** 
    1.86 +	 * Constructor 
    1.87 +	 *
    1.88 +	 * @param aN	The RSA parameter, n (the modulus)
    1.89 +	 */
    1.90 +	IMPORT_C CRSAParameters(RInteger& aN);
    1.91 +	
    1.92 +	/** Default constructor */
    1.93 +	IMPORT_C CRSAParameters(void);
    1.94 +protected:
    1.95 +	/** The RSA modulus, n, a positive integer */
    1.96 +	RInteger iN;
    1.97 +private:
    1.98 +	CRSAParameters(const CRSAParameters&);
    1.99 +	CRSAParameters& operator=(const CRSAParameters&);
   1.100 +	};
   1.101 +
   1.102 +/** 
   1.103 +* Representation of an RSA public key.  
   1.104 +* 
   1.105 +* An RSA public key is identified by its modulus (n) and its encryption exponent
   1.106 +* (e).
   1.107 +* 
   1.108 +*/
   1.109 +class CRSAPublicKey : public CRSAParameters
   1.110 +	{
   1.111 +public:
   1.112 +	/**
   1.113 +	 * Creates a new CRSAPublicKey object from a specified 
   1.114 +	 * modulus and encryption exponent.
   1.115 +	 * 
   1.116 +	 * @param aN	The RSA parameter, n (the modulus)
   1.117 +	 * @param aE	The RSA parameter, e (the encryption exponent)
   1.118 +	 * @return		A pointer to a new CRSAPublicKey object
   1.119 +	 *
   1.120 +	 * @leave KErrArgument	If either aN or aE are not positive integers,
   1.121 +	 *						and releases ownership. 
   1.122 +	 */
   1.123 +	IMPORT_C static CRSAPublicKey* NewL(RInteger& aN, RInteger& aE);
   1.124 +
   1.125 +	/**
   1.126 +	 * Creates a new CRSAPublicKey object from a specified 
   1.127 +	 * modulus and encryption exponent.
   1.128 +	 * 
   1.129 +	 * The returned pointer is put onto the cleanup stack.
   1.130 +	 * 
   1.131 +	 * @param aN	The RSA parameter, n (the modulus)
   1.132 +	 * @param aE	The RSA parameter, e (the encryption exponent)
   1.133 +	 * @return		A pointer to a new CRSAPublicKey object
   1.134 +	 * 
   1.135 +	 * @leave KErrArgument	If either aN or aE are not positive integers,
   1.136 +	 *	 					and releases ownership. 
   1.137 +	 */
   1.138 +	IMPORT_C static CRSAPublicKey* NewLC(RInteger& aN, RInteger& aE);
   1.139 +
   1.140 +	/** 
   1.141 +	 * Gets the RSA parameter, e (the encryption exponent)
   1.142 +	 *
   1.143 +	 * @return	The RSA parameter, e
   1.144 +	 */
   1.145 +	IMPORT_C const TInteger& E(void) const;
   1.146 +	
   1.147 +	/** Destructor */
   1.148 +	IMPORT_C virtual ~CRSAPublicKey(void);
   1.149 +protected:
   1.150 +	/**
   1.151 +	 * Constructor 
   1.152 +	 *
   1.153 +	 * @param aN	The RSA parameter, n (the modulus)
   1.154 +	 * @param aE	The RSA parameter, e (the encryption exponent)
   1.155 +	 */	
   1.156 +	IMPORT_C CRSAPublicKey(RInteger& aN, RInteger& aE);
   1.157 +	
   1.158 +	/** Default constructor */
   1.159 +	IMPORT_C CRSAPublicKey(void);
   1.160 +protected:
   1.161 +	/** The RSA encryption exponent, e */
   1.162 +	RInteger iE;
   1.163 +private:
   1.164 +	CRSAPublicKey(const CRSAPublicKey&);
   1.165 +	CRSAPublicKey& operator=(const CRSAPublicKey&);
   1.166 +	void ConstructL();
   1.167 +	};
   1.168 +
   1.169 +/** 
   1.170 +* Non-exported container class for the various ways of representing an RSA
   1.171 +* private key.
   1.172 +*
   1.173 +* To instantiate a representation of an RSA private key, find a
   1.174 +* subclass of this appropriate to your key type.  
   1.175 +*
   1.176 +*/
   1.177 +class CRSAPrivateKey : public CRSAParameters
   1.178 +	{
   1.179 +public:
   1.180 +	/**
   1.181 +	 * Constructor
   1.182 +	 * 
   1.183 +	 * @param aKeyType	The type of the RSA private key
   1.184 +	 * @param aN		The RSA parameter, n (the modulus)
   1.185 +	 * @internalAll 
   1.186 +	 */
   1.187 +	CRSAPrivateKey(const TRSAPrivateKeyType aKeyType, RInteger& aN);
   1.188 +public:
   1.189 +	/**
   1.190 +	 * Gets the type of RSA private key
   1.191 +	 *
   1.192 +	 * @return	The RSA private key type
   1.193 +	 */
   1.194 +	inline const TRSAPrivateKeyType PrivateKeyType() const {return (iKeyType);};
   1.195 +protected:
   1.196 +	/** The type of the RSA private key */
   1.197 +	const TRSAPrivateKeyType iKeyType;
   1.198 +private:
   1.199 +	CRSAPrivateKey(const CRSAPrivateKey&);
   1.200 +	CRSAPrivateKey& operator=(const CRSAPrivateKey&);
   1.201 +	};
   1.202 +
   1.203 +/** 
   1.204 +* The 'classical' representation of a RSA private key.
   1.205 +* 
   1.206 +* Such a private key is composed of a modulus (n) and a decryption exponent (d).
   1.207 +*   
   1.208 +*/
   1.209 +class CRSAPrivateKeyStandard : public CRSAPrivateKey
   1.210 +	{
   1.211 +public:
   1.212 +	/**
   1.213 +	 * Creates a new CRSAPrivateKeyStandard object from a specified 
   1.214 +	 * modulus and decryption exponent.
   1.215 +	 * 
   1.216 +	 * @param aN	The RSA parameter, n (the modulus)
   1.217 +	 * @param aD	The RSA parameter, d (the decryption exponent)
   1.218 +	 * @return		A pointer to a new CRSAPrivateKeyStandard object
   1.219 +	 * 
   1.220 +	 * @leave KErrArgument	If either aN or aD are not positive integers,
   1.221 +	 *	 					and releases ownership. 
   1.222 +	 */
   1.223 +	IMPORT_C static CRSAPrivateKeyStandard* NewL(RInteger& aN, RInteger& aD);
   1.224 +
   1.225 +	/**
   1.226 +	 * Creates a new CRSAPrivateKeyStandard object from a specified 
   1.227 +	 * modulus and decryption exponent.
   1.228 +	 * 
   1.229 +	 * The returned pointer is put onto the cleanup stack.
   1.230 +	 * 
   1.231 +	 * @param aN	The RSA parameter, n (the modulus)
   1.232 +	 * @param aD	The RSA parameter, d (the decryption exponent)
   1.233 +	 * @return		A pointer to a new CRSAPrivateKeyStandard object
   1.234 +	 * 
   1.235 +	 * @leave KErrArgument	If either aN or aD are not positive integers,
   1.236 +	 *	 					and releases ownership. 
   1.237 +	 */
   1.238 +	IMPORT_C static CRSAPrivateKeyStandard* NewLC(RInteger& aN, RInteger& aD);
   1.239 +
   1.240 +	/** 
   1.241 +	 * Gets the RSA parameter, d (the decryption exponent)
   1.242 +	 *
   1.243 +	 * @return	The RSA parameter, d
   1.244 +	 */
   1.245 +	IMPORT_C const TInteger& D(void) const;
   1.246 +
   1.247 +	/** Destructor */
   1.248 +	IMPORT_C virtual ~CRSAPrivateKeyStandard(void);
   1.249 +protected:
   1.250 +	/** 
   1.251 +	 * Constructor
   1.252 +	 * 
   1.253 +	 * @param aN	The RSA parameter, n (the modulus)
   1.254 +	 * @param aD	The RSA parameter, d (the decryption exponent)
   1.255 +	 */	 
   1.256 +	IMPORT_C CRSAPrivateKeyStandard(RInteger& aN, RInteger& aD);
   1.257 +protected:
   1.258 +	/** The RSA decryption exponent, d */
   1.259 +	RInteger iD;
   1.260 +private:
   1.261 +	CRSAPrivateKeyStandard(const CRSAPrivateKeyStandard&);
   1.262 +	CRSAPrivateKeyStandard& operator=(const CRSAPrivateKeyStandard&);
   1.263 +	void ConstructL();
   1.264 +	};
   1.265 +
   1.266 +/** 
   1.267 +* An alternate representation of an RSA private key providing significant
   1.268 +* speed enhancements through its use of the Chinese Remainder Theorem (CRT).
   1.269 +*
   1.270 +* Here, a private key is represented by a modulus (n), the two prime factors of
   1.271 +* the modulus (p, q), p's CRT exponent (dP), q's CRT exponent (dQ), and the CRT
   1.272 +* coefficient (qInv).  See PKCS#1 at http://www.rsasecurity.com/rsalabs/pkcs/
   1.273 +* for more information.
   1.274 +*
   1.275 +*/
   1.276 +class CRSAPrivateKeyCRT : public CRSAPrivateKey
   1.277 +	{
   1.278 +public:
   1.279 +	/**
   1.280 +	 * Creates a new CRSAPrivateKeyCRT object from a specified 
   1.281 +	 * modulus and decryption exponent.
   1.282 +	 * 
   1.283 +	 * @param iN	The RSA parameter, n (the modulus)
   1.284 +	 * @param aP	The RSA parameter, p (the first factor)
   1.285 +	 * @param aQ	The RSA parameter, q (the second factor)
   1.286 +	 * @param aDP	The RSA parameter, dP (the first factor's CRT exponent)
   1.287 +	 * @param aDQ	The RSA parameter, dQ (the second factor's CRT exponent)
   1.288 +	 * @param aQInv	The RSA parameter, qInv (the CRT coefficient)
   1.289 +	 * @return		A pointer to a new CRSAPrivateKeyCRT object
   1.290 +	 * 
   1.291 +	 * @leave KErrArgument	If any of the parameters are not positive integers,
   1.292 +	 *	 					and releases ownership. 
   1.293 +	 */
   1.294 +	IMPORT_C static CRSAPrivateKeyCRT* NewL(RInteger& iN, RInteger& aP, 
   1.295 +		RInteger& aQ, RInteger& aDP, RInteger& aDQ, RInteger& aQInv);
   1.296 +
   1.297 +	/**
   1.298 +	 * Creates a new CRSAPrivateKeyCRT object from a specified 
   1.299 +	 * modulus and decryption exponent.
   1.300 +	 * 
   1.301 +	 * The returned pointer is put onto the cleanup stack.
   1.302 +	 * 
   1.303 +	 * @param iN	The RSA parameter, n (the modulus)
   1.304 +	 * @param aP	The RSA parameter, p (the first factor)
   1.305 +	 * @param aQ	The RSA parameter, q (the second factor)
   1.306 +	 * @param aDP	The RSA parameter, dP (the first factor's CRT exponent)
   1.307 +	 * @param aDQ	The RSA parameter, dQ (the second factor's CRT exponent)
   1.308 +	 * @param aQInv	The RSA parameter, qInv (the CRT coefficient)
   1.309 +	 * @return		A pointer to a new CRSAPrivateKeyCRT object
   1.310 +	 * 
   1.311 +	 * @leave KErrArgument	If any of the parameters are not positive integers,
   1.312 +	 *	 					and releases ownership. 
   1.313 +	 */
   1.314 +	IMPORT_C static CRSAPrivateKeyCRT* NewLC(RInteger& iN, RInteger& aP, 
   1.315 +		RInteger& aQ, RInteger& aDP, RInteger& aDQ, RInteger& aQInv);
   1.316 +
   1.317 +	/** Destructor */
   1.318 +	IMPORT_C virtual ~CRSAPrivateKeyCRT(void);
   1.319 +	
   1.320 +	/**
   1.321 +	 * Gets the RSA parameter, p (the first factor) 
   1.322 +	 *
   1.323 +	 * @return	The first factor
   1.324 +	 */
   1.325 +	IMPORT_C const TInteger& P(void) const;
   1.326 +	
   1.327 +	/**
   1.328 +	 * Gets the RSA parameter, q (the second factor) 
   1.329 +	 *
   1.330 +	 * @return	The second factor
   1.331 +	 */
   1.332 +	IMPORT_C const TInteger& Q(void) const;
   1.333 +	
   1.334 +	/**
   1.335 +	 * Gets the RSA parameter, dP (the first factor's CRT exponent) 
   1.336 +	 *
   1.337 +	 * @return	The first factor's CRT exponent
   1.338 +	 */
   1.339 +	IMPORT_C const TInteger& DP(void) const;
   1.340 +	
   1.341 +	/**
   1.342 +	 * Gets the RSA parameter, dQ (the second factor's CRT exponent) 
   1.343 +	 *
   1.344 +	 * @return	The second factor's CRT exponent
   1.345 +	 */
   1.346 +	IMPORT_C const TInteger& DQ(void) const;
   1.347 +	
   1.348 +	/**
   1.349 +	 * Gets the RSA parameter, qInv (the CRT coefficient) 
   1.350 +	 *
   1.351 +	 * @return	The CRT coefficient
   1.352 +	 */
   1.353 +	IMPORT_C const TInteger& QInv(void) const;
   1.354 +protected:
   1.355 +	/**
   1.356 +	 * Constructor
   1.357 +	 * 
   1.358 +	 * @param aN	The RSA parameter, n (the modulus)
   1.359 +	 * @param aP	The RSA parameter, p (the first factor)
   1.360 +	 * @param aQ	The RSA parameter, q (the second factor)
   1.361 +	 * @param aDP	The RSA parameter, dP (the first factor's CRT exponent)
   1.362 +	 * @param aDQ	The RSA parameter, dQ (the second factor's CRT exponent)
   1.363 +	 * @param aQInv	The RSA parameter, qInv (the CRT coefficient)
   1.364 +	 */
   1.365 +	IMPORT_C CRSAPrivateKeyCRT(RInteger& aN, RInteger& aP, RInteger& aQ, 
   1.366 +		RInteger& aDP, RInteger& aDQ, RInteger& aQInv);
   1.367 +protected:
   1.368 +	/** The RSA parameter, p, which is the first factor */
   1.369 +	RInteger iP;
   1.370 +	/** The RSA parameter, q, which is the second factor */
   1.371 +	RInteger iQ;
   1.372 +	/** The RSA parameter, dP, which is the first factor's CRT exponent */
   1.373 +	RInteger iDP;
   1.374 +	/** The RSA parameter, dQ, which is the second factor's CRT exponent */
   1.375 +	RInteger iDQ;
   1.376 +	/** The RSA parameter, qInv, which is the CRT coefficient */
   1.377 +	RInteger iQInv;
   1.378 +private:
   1.379 +	CRSAPrivateKeyCRT(const CRSAPrivateKeyCRT&);
   1.380 +	CRSAPrivateKeyCRT& operator=(const CRSAPrivateKeyCRT&);
   1.381 +	void ConstructL();
   1.382 +	};
   1.383 +
   1.384 +/** 
   1.385 +* This class is capable of generating an RSA public/private key pair.
   1.386 +*
   1.387 +* By default, it generates 2 prime (standard) CRT private keys.
   1.388 +*
   1.389 +*/
   1.390 +class CRSAKeyPair : public CBase
   1.391 +	{
   1.392 +public:
   1.393 +	/**
   1.394 +	 * Creates a new RSA key pair
   1.395 +	 * 
   1.396 +	 * @param aModulusBits	The length of the modulus, n (in bits)
   1.397 +	 * @param aKeyType		The type of the RSA key
   1.398 +	 * @return				A pointer to a new CRSAKeyPair object
   1.399 +	 * 
   1.400 +	 * @leave KErrNotSupported	If the type of RSA key is not supported
   1.401 +	 */
   1.402 +	IMPORT_C static CRSAKeyPair* NewL(TUint aModulusBits, 
   1.403 +		TRSAPrivateKeyType aKeyType = EStandardCRT);
   1.404 +
   1.405 +	/**
   1.406 +	 * Creates a new RSA key pair
   1.407 +	 * 
   1.408 +	 * The returned pointer is put onto the cleanup stack.
   1.409 +	 * 
   1.410 +	 * @param aModulusBits	The length of the modulus, n (in bits)
   1.411 +	 * @param aKeyType		The type of the RSA key
   1.412 +	 * @return				A pointer to a new CRSAKeyPair object
   1.413 +	 * 
   1.414 +	 * @leave KErrNotSupported	If the type of RSA key is not supported
   1.415 +	 */
   1.416 +	IMPORT_C static CRSAKeyPair* NewLC(TUint aModulusBits, 
   1.417 +		TRSAPrivateKeyType aKeyType = EStandardCRT);
   1.418 +	
   1.419 +	/** 
   1.420 +	 * Gets the RSA public key
   1.421 +	 *
   1.422 +	 * @return	A CRSAPublicKey object
   1.423 +	 */
   1.424 +	IMPORT_C const CRSAPublicKey& PublicKey(void) const;
   1.425 +	
   1.426 +	/** 
   1.427 +	 * Gets the RSA private key
   1.428 +	 *
   1.429 +	 * @return	A CRSAPrivateKey object
   1.430 +	 */
   1.431 +	IMPORT_C const CRSAPrivateKey& PrivateKey(void) const;
   1.432 +	
   1.433 +	/** The destructor frees all resources owned by the object, prior to its destruction. */
   1.434 +	IMPORT_C virtual ~CRSAKeyPair(void);
   1.435 +protected:
   1.436 +	/** Default destructor */
   1.437 +	IMPORT_C CRSAKeyPair(void);
   1.438 +protected:
   1.439 +	/** The RSA public key */
   1.440 +	CRSAPublicKey* iPublic;
   1.441 +	/** The RSA private key */
   1.442 +	CRSAPrivateKey* iPrivate;
   1.443 +private:
   1.444 +	void ConstructL(TUint aModulusBits, TRSAPrivateKeyType aKeyType, 
   1.445 +		TUint aPublicExponent);
   1.446 +	CRSAKeyPair(const CRSAKeyPair&);
   1.447 +	CRSAKeyPair& operator=(const CRSAKeyPair&);
   1.448 +	};
   1.449 +
   1.450 +/** 
   1.451 +* Representation of the parameters used to generate the primes in a
   1.452 +* CDSAParameters object.
   1.453 +* 
   1.454 +* Given such a certificate, one can ensure that the DSA
   1.455 +* primes contained in CDSAParameters were generated correctly.
   1.456 +* 
   1.457 +* @see CDSAParameters::ValidatePrimesL() 
   1.458 +* 
   1.459 +*/
   1.460 +class CDSAPrimeCertificate : public CBase
   1.461 +	{
   1.462 +public:
   1.463 +	/** 
   1.464 +	 * Creates a new DSA prime certificate from a specified 
   1.465 +	 * seed and counter value.
   1.466 +	 * 
   1.467 +	 * @param aSeed		The seed from a DSA key generation process
   1.468 +	 * @param aCounter	The counter value from a DSA key generation process
   1.469 +	 * @return			A pointer to a new CDSAPrimeCertificate object
   1.470 +	 */
   1.471 +	IMPORT_C static CDSAPrimeCertificate* NewL(const TDesC8& aSeed, 
   1.472 +		TUint aCounter);
   1.473 +
   1.474 +	/** 
   1.475 +	 * Creates a new DSA prime certificate from a specified 
   1.476 +	 * seed and counter value.
   1.477 +	 *
   1.478 +	 * The returned pointer is put onto the cleanup stack.
   1.479 +	 * 
   1.480 +	 * @param aSeed		The seed from a DSA key generation process
   1.481 +	 * @param aCounter	The counter value from a DSA key generation process
   1.482 +	 * @return			A pointer to a new CDSAPrimeCertificate object
   1.483 +	 */
   1.484 +	IMPORT_C static CDSAPrimeCertificate* NewLC(const TDesC8& aSeed,
   1.485 +		TUint aCounter);
   1.486 +
   1.487 +	/**
   1.488 +	 * Gets the seed of the DSA prime certificate
   1.489 +	 *
   1.490 +	 * @return	The seed
   1.491 +	 */ 
   1.492 +	IMPORT_C const TDesC8& Seed(void) const;
   1.493 +	
   1.494 +	/**
   1.495 +	 * Gets the counter value of the DSA prime certificate
   1.496 +	 *
   1.497 +	 * @return	The counter's value
   1.498 +	 */
   1.499 +	IMPORT_C TUint Counter(void) const;
   1.500 +	
   1.501 +	/** Destructor */
   1.502 +	IMPORT_C virtual ~CDSAPrimeCertificate(void);
   1.503 +protected:
   1.504 +	/** 
   1.505 +	 * Constructor 
   1.506 +	 *
   1.507 +	 * @param aCounter	The DSA key generation counter
   1.508 +	 */
   1.509 +	IMPORT_C CDSAPrimeCertificate(TUint aCounter);
   1.510 +
   1.511 +	/** Default constructor */
   1.512 +	IMPORT_C CDSAPrimeCertificate(void);
   1.513 +	/** @internalAll */
   1.514 +	void ConstructL(const TDesC8& aSeed);
   1.515 +protected:
   1.516 +	/** The DSA key generation seed */
   1.517 +	const HBufC8* iSeed;
   1.518 +	/** The DSA key generation counter */
   1.519 +	TUint iCounter;
   1.520 +private:
   1.521 +	CDSAPrimeCertificate(const CDSAPrimeCertificate&);
   1.522 +	CDSAPrimeCertificate& operator=(const CDSAPrimeCertificate&);
   1.523 +	};
   1.524 +
   1.525 +/** 
   1.526 +* Concrete class representing the parameters common to both a DSA public and
   1.527 +* private key. 
   1.528 +*
   1.529 +* See FIPS 186-2, Digital Signature Standard
   1.530 +* 
   1.531 +*/
   1.532 +class CDSAParameters : public CBase
   1.533 +	{
   1.534 +public:
   1.535 +	/**
   1.536 +	 * Gets the DSA parameter, p (the prime)
   1.537 +	 * 
   1.538 +	 * @return	The DSA parameter, p
   1.539 +	 */
   1.540 +	IMPORT_C const TInteger& P(void) const;
   1.541 +
   1.542 +	/**
   1.543 +	 * Gets the DSA parameter, q (the subprime)
   1.544 +	 * 
   1.545 +	 * @return	The DSA parameter, q
   1.546 +	 */
   1.547 +	IMPORT_C const TInteger& Q(void) const;
   1.548 +
   1.549 +	/**
   1.550 +	 * Gets the DSA parameter, g (the base)
   1.551 +	 * 
   1.552 +	 * @return	The DSA parameter, g
   1.553 +	 */
   1.554 +	IMPORT_C const TInteger& G(void) const;
   1.555 +
   1.556 +	/**
   1.557 +	 * Validates the primes regenerated from a DSA prime certificate 
   1.558 +	 *
   1.559 +	 * @param aCert	The DSA prime certificate that contains the seed and 
   1.560 +	 *				counter value from a DSA key generation process
   1.561 +	 * @return		Whether or not the primes are valid	
   1.562 +	 */
   1.563 +	IMPORT_C TBool ValidatePrimesL(const CDSAPrimeCertificate& aCert) const;
   1.564 +
   1.565 +	/** 
   1.566 +	 * Whether or not the prime is of a valid length 
   1.567 +	 * 
   1.568 +	 * It is valid if the length of the prime modulus is between KMinPrimeLength
   1.569 +	 * and KMaxPrimeLength bits, and the prime is a multiple of KPrimeLengthMultiple. 
   1.570 +	 *
   1.571 +	 * @param aPrimeBits	The prime modulus
   1.572 +	 * @return				ETrue, if within the constraints; EFalse, otherwise.
   1.573 +	 */
   1.574 +	IMPORT_C static TBool ValidPrimeLength(TUint aPrimeBits);
   1.575 +	
   1.576 +	/** Destructor */
   1.577 +	IMPORT_C virtual ~CDSAParameters(void);
   1.578 +
   1.579 +	/** 
   1.580 +	 * Creates a new DSA parameters object from a specified 
   1.581 +	 * prime, subprime, and base.
   1.582 +	 * 
   1.583 +	 * @param aP	The DSA parameter, p (the prime)
   1.584 +	 * @param aQ	The DSA parameter, g (the subprime)
   1.585 +	 * @param aG	The DSA parameter, g (the base)
   1.586 +	 * @return		A pointer to a new CDSAParameters object
   1.587 +	 */
   1.588 +	IMPORT_C static CDSAParameters* NewL(RInteger& aP, RInteger& aQ, 
   1.589 +		RInteger& aG);
   1.590 +public:
   1.591 +	/** @internalAll */
   1.592 +	static TBool GeneratePrimesL(const TDesC8& aSeed, TUint& aCounter, 
   1.593 +		RInteger& aP, TUint aL, RInteger& aQ, TBool aUseInputCounter=EFalse);
   1.594 +protected:
   1.595 +	/** 
   1.596 +	 * Constructor
   1.597 +	 * 
   1.598 +	 * @param aP	The DSA parameter, p (the prime)
   1.599 +	 * @param aQ	The DSA parameter, g (the subprime)
   1.600 +	 * @param aG	The DSA parameter, g (the base)
   1.601 +	 */
   1.602 +	IMPORT_C CDSAParameters(RInteger& aP, RInteger& aQ, RInteger& aG);
   1.603 +	
   1.604 +	/** Default constructor */
   1.605 +	IMPORT_C CDSAParameters(void);
   1.606 +protected:
   1.607 +	/** 
   1.608 +	 * The DSA parameter, p (the prime).
   1.609 +	 * 
   1.610 +	 * A prime modulus whose length is between KMinPrimeLength and KMaxPrimeLength bits,
   1.611 +	 * and is a multiple of KPrimeLengthMultiple. 
   1.612 +	 */
   1.613 +	RInteger iP;
   1.614 +	
   1.615 +	/** 
   1.616 +	 * The DSA parameter, q (the subprime)
   1.617 +	 * 
   1.618 +	 * This is a 160-bit prime divisor of <code>p-1</code>. 
   1.619 +	 */
   1.620 +	RInteger iQ;
   1.621 +	
   1.622 +	/** 
   1.623 +	 * The DSA parameter, g (the base)
   1.624 +	 * 
   1.625 +	 * <code>g = h^((p-1)/q) mod p</code>,
   1.626 +	 * 
   1.627 +	 * where h is any integer less than <code>p-1</code> such that <code>g &gt; 1</code> 
   1.628 +	 */
   1.629 +	RInteger iG;
   1.630 +private:
   1.631 +	CDSAParameters(const CDSAParameters&);
   1.632 +	CDSAParameters& operator=(const CDSAParameters&);
   1.633 +	};
   1.634 +
   1.635 +/**
   1.636 +* Representation of a DSA public key.  
   1.637 +*
   1.638 +*/
   1.639 +class CDSAPublicKey : public CDSAParameters
   1.640 +	{
   1.641 +public:
   1.642 +	/** 
   1.643 +	 * Creates a new DSA public key object from a specified
   1.644 +	 * primes, base, and public key. 
   1.645 +	 * 
   1.646 +	 * @param aP	The DSA parameter, p (the prime)
   1.647 +	 * @param aQ	The DSA parameter, q (the subprime)
   1.648 +	 * @param aG	The DSA parameter, g (the base)
   1.649 +	 * @param aY	The DSA parameter, y (the public key)
   1.650 +	 * @return		A pointer to a new CDSAPublicKey object
   1.651 +	 */
   1.652 +	IMPORT_C static CDSAPublicKey* NewL(RInteger& aP, RInteger& aQ, 
   1.653 +		RInteger& aG, RInteger& aY);
   1.654 +
   1.655 +	/** 
   1.656 +	 * Creates a new DSA public key object from a specified
   1.657 +	 * primes, base, and public key. 
   1.658 +	 * 
   1.659 +	 * The returned pointer is put onto the cleanup stack.
   1.660 +	 * 
   1.661 +	 * @param aP	The DSA parameter, p (the prime)
   1.662 +	 * @param aQ	The DSA parameter, q (the subprime)
   1.663 +	 * @param aG	The DSA parameter, g (the base)
   1.664 +	 * @param aY	The DSA parameter, y (the public key)
   1.665 +	 * @return		A pointer to a new CDSAPublicKey object
   1.666 +	 */
   1.667 +	IMPORT_C static CDSAPublicKey* NewLC(RInteger& aP, RInteger& aQ, 
   1.668 +		RInteger& aG, RInteger& aY);
   1.669 +
   1.670 +	/**
   1.671 +	 * Gets the DSA parameter, y (the public key)
   1.672 +	 *
   1.673 +	 * @return	The DSA parameter, y
   1.674 +	 */
   1.675 +	IMPORT_C const TInteger& Y(void) const;
   1.676 +
   1.677 +	/** Destructor */
   1.678 +	IMPORT_C virtual ~CDSAPublicKey(void);
   1.679 +protected:
   1.680 +	/** 
   1.681 +	 * Constructor
   1.682 +	 * 
   1.683 +	 * @param aP	The DSA parameter, p (the prime)
   1.684 +	 * @param aQ	The DSA parameter, q (the subprime)
   1.685 +	 * @param aG	The DSA parameter, g (the base)
   1.686 +	 * @param aY	The DSA parameter, y (the public key)
   1.687 +	 */
   1.688 +	IMPORT_C CDSAPublicKey(RInteger& aP, RInteger& aQ, RInteger& aG, 
   1.689 +		RInteger& aY);
   1.690 +	
   1.691 +	/** Default constructor */
   1.692 +	IMPORT_C CDSAPublicKey(void);
   1.693 +protected:
   1.694 +	/** 
   1.695 +	 * The DSA parameter, y, which is the public key 
   1.696 +	 *
   1.697 +	 * <code>y = g^x mod p</code>
   1.698 +	 */
   1.699 +	RInteger iY;
   1.700 +private:
   1.701 +	CDSAPublicKey(const CDSAPublicKey&);
   1.702 +	CDSAPublicKey& operator=(const CDSAPublicKey&);
   1.703 +	};
   1.704 +
   1.705 +/** 
   1.706 +* Representation of a DSA private key.  
   1.707 +* 
   1.708 +*/
   1.709 +class CDSAPrivateKey : public CDSAParameters
   1.710 +	{
   1.711 +public:
   1.712 +	/** 
   1.713 +	 * Creates a new DSA private key object from a specified
   1.714 +	 * primes, base, and private key. 
   1.715 +	 * 
   1.716 +	 * @param aP	The DSA parameter, p (the prime)
   1.717 +	 * @param aQ	The DSA parameter, q (the subprime)
   1.718 +	 * @param aG	The DSA parameter, g (the base)
   1.719 +	 * @param aX	The DSA parameter, x (the private key)
   1.720 +	 * @return		A pointer to a new CDSAPrivateKey object
   1.721 +	 */
   1.722 +	IMPORT_C static CDSAPrivateKey* NewL(RInteger& aP, RInteger& aQ, 
   1.723 +		RInteger& aG, RInteger& aX);
   1.724 +
   1.725 +	/** 
   1.726 +	 * Creates a new DSA private key object from a specified
   1.727 +	 * primes, base, and private key. 
   1.728 +	 * 
   1.729 +	 * The returned pointer is put onto the cleanup stack.
   1.730 +	 * 
   1.731 +	 * @param aP	The DSA parameter, p (the prime)
   1.732 +	 * @param aQ	The DSA parameter, q (the subprime)
   1.733 +	 * @param aG	The DSA parameter, g (the base)
   1.734 +	 * @param aX	The DSA parameter, x (the private key)
   1.735 +	 * @return		A pointer to a new CDSAPrivateKey object
   1.736 +	 */
   1.737 +	IMPORT_C static CDSAPrivateKey* NewLC(RInteger& aP, RInteger& aQ, 
   1.738 +		RInteger& aG, RInteger& aX);
   1.739 +
   1.740 +	/**
   1.741 +	 * Gets the DSA parameter, x (the private key)
   1.742 +	 *
   1.743 +	 * @return	The DSA parameter, x
   1.744 +	 */
   1.745 +	IMPORT_C const TInteger& X(void) const;
   1.746 +
   1.747 +	/** Destructor */
   1.748 +	IMPORT_C virtual ~CDSAPrivateKey(void);
   1.749 +protected:
   1.750 +	/** 
   1.751 +	 * Constructor
   1.752 +	 * 
   1.753 +	 * @param aP	The DSA parameter, p (the prime)
   1.754 +	 * @param aQ	The DSA parameter, q (the subprime)
   1.755 +	 * @param aG	The DSA parameter, g (the base)
   1.756 +	 * @param aX	The DSA parameter, x (the private key)
   1.757 +	 */
   1.758 +	IMPORT_C CDSAPrivateKey(RInteger& aP, RInteger& aQ, RInteger& aG, 
   1.759 +		RInteger& aX);
   1.760 +		
   1.761 +	/** Default constructor */
   1.762 +	IMPORT_C CDSAPrivateKey(void);
   1.763 +protected:
   1.764 +	/** 
   1.765 +	 * The DSA parameter, x, which is the private key 
   1.766 +	 *
   1.767 +	 * A pseudorandomly generated integer whose value is between 0 and q.
   1.768 +	*/
   1.769 +	RInteger iX;
   1.770 +private:
   1.771 +	CDSAPrivateKey(const CDSAPrivateKey&);
   1.772 +	CDSAPrivateKey& operator=(const CDSAPrivateKey&);
   1.773 +	};
   1.774 +
   1.775 +/** 
   1.776 +* This class is capable of generating a DSA public/private key pair.
   1.777 +* 
   1.778 +*/
   1.779 +class CDSAKeyPair : public CBase
   1.780 +	{
   1.781 +public:
   1.782 +	/** 
   1.783 +	 * Creates a new DSA key pair and also a DSA prime certificate
   1.784 +	 * 
   1.785 +	 * @param aSize	The length (in bits) of the DSA parameter, p (the prime)
   1.786 +	 * @return		A pointer to a new CDSAKeyPair object
   1.787 +	 */
   1.788 +	IMPORT_C static CDSAKeyPair* NewL(TUint aSize);
   1.789 +
   1.790 +	/** 
   1.791 +	 * Creates a new DSA key pair and also a DSA prime certificate
   1.792 +	 * 
   1.793 +	 * The returned pointer is put onto the cleanup stack.
   1.794 +	 * 
   1.795 +	 * @param aSize	The length (in bits) of the DSA parameter, p (the prime)
   1.796 +	 * @return		A pointer to a new CDSAKeyPair object
   1.797 +	 */
   1.798 +	IMPORT_C static CDSAKeyPair* NewLC(TUint aSize);
   1.799 +	
   1.800 +	/** 
   1.801 +	 * Gets the DSA public key
   1.802 +	 *
   1.803 +	 * @return	The DSA public key object
   1.804 +	 */
   1.805 +	IMPORT_C const CDSAPublicKey& PublicKey(void) const;
   1.806 +	
   1.807 +	/** 
   1.808 +	 * Gets the DSA private key
   1.809 +	 *
   1.810 +	 * @return	The DSA private key object
   1.811 +	 */
   1.812 +	IMPORT_C const CDSAPrivateKey& PrivateKey(void) const;
   1.813 +	
   1.814 +	/** 
   1.815 +	 * Gets the DSA prime certificate (i.e., the seed and counter)
   1.816 +	 *
   1.817 +	 * @return	The DSA prime certificate object
   1.818 +	 */
   1.819 +	IMPORT_C const CDSAPrimeCertificate& PrimeCertificate(void) const;
   1.820 +	
   1.821 +	/** The destructor frees all resources owned by the object, prior to its destruction. */
   1.822 +	IMPORT_C virtual ~CDSAKeyPair(void);
   1.823 +protected:
   1.824 +	/** Default constructor */
   1.825 +	IMPORT_C CDSAKeyPair(void);
   1.826 +protected:
   1.827 +	/** The DSA public key */
   1.828 +	CDSAPublicKey* iPublic;
   1.829 +	/** The DSA private key */
   1.830 +	CDSAPrivateKey* iPrivate;
   1.831 +	/** The DSA prime certificate */
   1.832 +	CDSAPrimeCertificate* iPrimeCertificate;
   1.833 +private:
   1.834 +	void ConstructL(TUint aSize);
   1.835 +	CDSAKeyPair(const CDSAKeyPair&);
   1.836 +	CDSAKeyPair& operator=(const CDSAKeyPair&);
   1.837 +	};
   1.838 +
   1.839 +/** 
   1.840 +* Concrete class representing the parameters common to both 
   1.841 +* a Diffie-Hellman (DH) public and private key.  
   1.842 +* 
   1.843 +*/
   1.844 +class CDHParameters : public CBase
   1.845 +	{
   1.846 +public:
   1.847 +	/**
   1.848 +	 * Gets the DH parameter, n
   1.849 +	 *
   1.850 +	 * @return	An integer representing the DH parameter, n
   1.851 +	 */
   1.852 +	IMPORT_C const TInteger& N(void) const;
   1.853 +
   1.854 +	/**
   1.855 +	 * Gets the DH parameter, g
   1.856 +	 *
   1.857 +	 * @return	An integer representing the DH parameter, g
   1.858 +	 */
   1.859 +	IMPORT_C const TInteger& G(void) const;
   1.860 +	
   1.861 +	/** Destructor */
   1.862 +	IMPORT_C virtual ~CDHParameters(void);
   1.863 +protected:
   1.864 +	/** 
   1.865 +	 * Constructor
   1.866 +	 * 
   1.867 +	 * @param aN	The DH parameter, n
   1.868 +	 * @param aG	The DH parameter, g
   1.869 +	 */
   1.870 +	IMPORT_C CDHParameters(RInteger& aN, RInteger& aG);
   1.871 +	
   1.872 +	/** Default constructor */
   1.873 +	IMPORT_C CDHParameters(void);
   1.874 +protected:
   1.875 +	/**
   1.876 +	 * The DH parameter, n (a prime number)
   1.877 +	 * 
   1.878 +	 * <code>X = g^x mod n</code> (note the case sensitivity)
   1.879 +	 */
   1.880 +	RInteger iN;
   1.881 +	/** 
   1.882 +	 * The DH parameter, g (the generator) 
   1.883 +	 *
   1.884 +	 * <code>X = g^x mod n</code> (note the case sensitivity)
   1.885 +	 */
   1.886 +	RInteger iG;
   1.887 +private:
   1.888 +	CDHParameters(const CDHParameters&);
   1.889 +	CDHParameters& operator=(const CDHParameters&);
   1.890 +	};
   1.891 +
   1.892 +/** 
   1.893 +* Representation of a Diffie-Hellman (DH) public key.  
   1.894 +* 
   1.895 +*/
   1.896 +class CDHPublicKey : public CDHParameters
   1.897 +	{
   1.898 +public:
   1.899 +	/** 
   1.900 +	 * Creates a new DH public key from a specified 
   1.901 +	 * large prime, generator, and random large integer.
   1.902 +	 * 
   1.903 +	 * @param aN	The DH parameter, n (a large prime)
   1.904 +	 * @param aG	The DH parameter, g (the generator)
   1.905 +	 * @param aX	The DH value, X
   1.906 +	 * @return		A pointer to a new CDHPublicKey object
   1.907 +	 */
   1.908 +	IMPORT_C static CDHPublicKey* NewL(RInteger& aN, RInteger& aG, 
   1.909 +		RInteger& aX);
   1.910 +
   1.911 +	/** 
   1.912 +	 * Creates a new DH public key from a specified 
   1.913 +	 * large prime, generator, and random large integer.
   1.914 +	 *
   1.915 +	 * The returned pointer is put onto the cleanup stack.
   1.916 +	 * 
   1.917 +	 * @param aN	The DH parameter, n (a large prime)
   1.918 +	 * @param aG	The DH parameter, g (the generator)
   1.919 +	 * @param aX	The DH value, X
   1.920 +	 * @return		A pointer to a new CDHPublicKey object
   1.921 +	 */
   1.922 +	IMPORT_C static CDHPublicKey* NewLC(RInteger& aN, RInteger& aG, 
   1.923 +		RInteger& aX);
   1.924 +	
   1.925 +	/** 
   1.926 +	 * Gets the DH value, X
   1.927 +	 * 
   1.928 +	 * @return	The DH value, X
   1.929 +	 */	
   1.930 +	IMPORT_C const TInteger& X(void) const;
   1.931 +
   1.932 +	/** Destructor */
   1.933 +	IMPORT_C virtual ~CDHPublicKey(void);
   1.934 +protected:
   1.935 +	/** 
   1.936 +	 * Constructor
   1.937 +	 * 
   1.938 +	 * @param aN	The DH parameter, n (a large prime)
   1.939 +	 * @param aG	The DH parameter, g (the generator)
   1.940 +	 * @param aX	The DH value, X
   1.941 +	 */
   1.942 +	IMPORT_C CDHPublicKey(RInteger& aN, RInteger& aG, RInteger& aX);
   1.943 +
   1.944 +	/** Constructor */
   1.945 +	IMPORT_C CDHPublicKey(void);
   1.946 +protected:
   1.947 +	/** 
   1.948 +	 * The DH value, X
   1.949 +	 *
   1.950 +	 * <code>X = g^x mod n</code> (note the case sensitivity)
   1.951 +	 */
   1.952 +	RInteger iX;
   1.953 +private:
   1.954 +	CDHPublicKey(const CDHPublicKey&);
   1.955 +	CDHPublicKey& operator=(const CDHPublicKey&);
   1.956 +	};
   1.957 +
   1.958 +/** 
   1.959 +* Representation of a Diffie-Hellman (DH) private key.  
   1.960 +* 
   1.961 +*/
   1.962 +class CDHPrivateKey : public CDHParameters
   1.963 +	{
   1.964 +public:
   1.965 +	/** 
   1.966 +	 * Creates a new DH private key from a specified 
   1.967 +	 * large prime, generator, and random large integer.
   1.968 +	 * 
   1.969 +	 * @param aN	The DH parameter, n (a large prime)
   1.970 +	 * @param aG	The DH parameter, g (the generator)
   1.971 +	 * @param ax	The DH value, x (a random large integer)
   1.972 +	 * @return		A pointer to a new CDHPrivateKey object
   1.973 +	 */
   1.974 +	IMPORT_C static CDHPrivateKey* NewL(RInteger& aN, RInteger& aG, 
   1.975 +		RInteger& ax);
   1.976 +
   1.977 +	/** 
   1.978 +	 * Creates a new DH private key from a specified 
   1.979 +	 * large prime, generator, and random large integer.
   1.980 +	 *
   1.981 +	 * The returned pointer is put onto the cleanup stack.
   1.982 +	 * 
   1.983 +	 * @param aN	The DH parameter, n (a large prime)
   1.984 +	 * @param aG	The DH parameter, g (the generator)
   1.985 +	 * @param ax	The DH value, x (a random large integer)
   1.986 +	 * @return		A pointer to a new CDHPrivateKey object
   1.987 +	 */
   1.988 +	IMPORT_C static CDHPrivateKey* NewLC(RInteger& aN, RInteger& aG, 
   1.989 +		RInteger& ax);
   1.990 +	
   1.991 +	/** 
   1.992 +	 * Gets the DH value, x, which is a random large integer.
   1.993 +	 * 
   1.994 +	 * @return	The DH value, x
   1.995 +	 */	
   1.996 +	IMPORT_C const TInteger& x(void) const;
   1.997 +	
   1.998 +	/** Destructor */
   1.999 +	IMPORT_C virtual ~CDHPrivateKey(void);
  1.1000 +protected:
  1.1001 +	/** 
  1.1002 +	 * Constructor
  1.1003 +	 * 
  1.1004 +	 * @param aN	The DH parameter, n (a large prime)
  1.1005 +	 * @param aG	The DH parameter, g (the generator)
  1.1006 +	 * @param ax	The DH value, x (a random large integer)
  1.1007 +	 */
  1.1008 +	IMPORT_C CDHPrivateKey(RInteger& aN, RInteger& aG, RInteger& ax);
  1.1009 +	
  1.1010 +	/** Constructor */
  1.1011 +	IMPORT_C CDHPrivateKey(void);
  1.1012 +protected:
  1.1013 +	/** 
  1.1014 +	 * The DH value, x, which is a random large integer.
  1.1015 +	 *
  1.1016 +	 * <code>X = g^x mod n</code> (note the case sensitivity)
  1.1017 +	 */
  1.1018 +	RInteger ix;
  1.1019 +private:
  1.1020 +	CDHPrivateKey(const CDHPrivateKey&);
  1.1021 +	CDHPrivateKey& operator=(const CDHPrivateKey&);
  1.1022 +	};
  1.1023 +
  1.1024 +/** 
  1.1025 +* This class is capable of generating a Diffie-Hellman (DH) public/private key pair.
  1.1026 +* 
  1.1027 +*/
  1.1028 +class CDHKeyPair : public CBase
  1.1029 +	{
  1.1030 +public:
  1.1031 +	/**
  1.1032 +	 * Creates a new DH key pair from a random large integer,
  1.1033 +	 * and a specified large prime and generator.
  1.1034 +	 *
  1.1035 +	 * @param aN	The DH parameter, n (a large prime)
  1.1036 +	 * @param aG	The DH parameter, g (the generator)
  1.1037 +	 * @return		A pointer to a new CDHKeyPair object
  1.1038 +	 * 
  1.1039 +	 * @leave KErrArgument	If aG is out of bounds 
  1.1040 +	 */
  1.1041 +	IMPORT_C static CDHKeyPair* NewL(RInteger& aN, RInteger& aG);
  1.1042 +
  1.1043 +	/**
  1.1044 +	 * Creates a new DH key pair from a random large integer,
  1.1045 +	 * and a specified large prime and generator.
  1.1046 +	 *
  1.1047 +	 * The returned pointer is put onto the cleanup stack.
  1.1048 +	 *
  1.1049 +	 * @param aN	The DH parameter, n (a large prime)
  1.1050 +	 * @param aG	The DH parameter, g (the generator)
  1.1051 +	 * @return		A pointer to a new CDHKeyPair object
  1.1052 +	 * 
  1.1053 +	 * @leave KErrArgument	If aG is out of bounds 
  1.1054 +	 */
  1.1055 +	IMPORT_C static CDHKeyPair* NewLC(RInteger& aN, RInteger& aG);
  1.1056 +
  1.1057 +	/**
  1.1058 +	 * Creates a new DH key pair from a specified 
  1.1059 +	 * large prime, generator, and random large integer.
  1.1060 +	 *
  1.1061 +	 * @param aN	The DH parameter, n (a large prime)
  1.1062 +	 * @param aG	The DH parameter, g (the generator)
  1.1063 +	 * @param ax	The DH value, x (a random large integer)
  1.1064 +	 * @return		A pointer to a new CDHKeyPair object
  1.1065 +	 * 
  1.1066 +	 * @leave KErrArgument	If either aG or ax are out of bounds 
  1.1067 +	 */
  1.1068 +	IMPORT_C static CDHKeyPair* NewL(RInteger& aN, RInteger& aG, RInteger& ax);
  1.1069 +
  1.1070 +	/**
  1.1071 +	 * Creates a new DH key pair from a specified 
  1.1072 +	 * large prime, generator, and random large integer.
  1.1073 +	 *
  1.1074 +	 * The returned pointer is put onto the cleanup stack.
  1.1075 +	 *
  1.1076 +	 * @param aN	The DH parameter, n (a large prime)
  1.1077 +	 * @param aG	The DH parameter, g (the generator)
  1.1078 +	 * @param ax	The DH value, x (a random large integer)
  1.1079 +	 * @return		A pointer to a new CDHKeyPair object
  1.1080 +	 * 
  1.1081 +	 * @leave KErrArgument	If either aG or ax are out of bounds 
  1.1082 +	 */
  1.1083 +	IMPORT_C static CDHKeyPair* NewLC(RInteger& aN, RInteger& aG, RInteger& ax);
  1.1084 +
  1.1085 +	/**
  1.1086 +	 * Gets the DH public key
  1.1087 +	 *
  1.1088 +	 * @return	The DH public key
  1.1089 +	 */
  1.1090 +	IMPORT_C const CDHPublicKey& PublicKey(void) const;
  1.1091 +
  1.1092 +	/**
  1.1093 +	 * Gets the DH private key
  1.1094 +	 *
  1.1095 +	 * @return	The DH private key
  1.1096 +	 */
  1.1097 +	IMPORT_C const CDHPrivateKey& PrivateKey(void) const;
  1.1098 +	
  1.1099 +	/** The destructor frees all resources owned by the object, prior to its destruction. */
  1.1100 +	IMPORT_C virtual ~CDHKeyPair(void);
  1.1101 +protected:
  1.1102 +	/** Default constructor */
  1.1103 +	IMPORT_C CDHKeyPair(void);
  1.1104 +	
  1.1105 +	/** 
  1.1106 +	 * Constructor
  1.1107 +	 *
  1.1108 +	 * @param aN	The DH parameter, n (a large prime)
  1.1109 +	 * @param aG	The DH parameter, g (the generator)
  1.1110 +	 */
  1.1111 +	IMPORT_C void ConstructL(RInteger& aN, RInteger& aG);
  1.1112 +
  1.1113 +	/** 
  1.1114 +	 * Constructor
  1.1115 +	 *
  1.1116 +	 * @param aN	The DH parameter, n (a large prime)
  1.1117 +	 * @param aG	The DH parameter, g (the generator)
  1.1118 +	 * @param ax	The DH value, x (a random large integer)
  1.1119 +	 */
  1.1120 +	IMPORT_C void ConstructL(RInteger& aN, RInteger& aG, RInteger& ax);
  1.1121 +
  1.1122 +protected:	
  1.1123 +	/** The DH public key */
  1.1124 +	CDHPublicKey* iPublic;
  1.1125 +	/** The DH private key */
  1.1126 +	CDHPrivateKey* iPrivate;
  1.1127 +private:
  1.1128 +	CDHKeyPair(const CDHKeyPair&);
  1.1129 +	CDHKeyPair& operator=(const CDHKeyPair&);
  1.1130 +	};
  1.1131 +#endif	//	__ASYMMETRICKEYS_H__