os/security/crypto/weakcryptospi/test/tplugins/inc/dsakeypairgenimpl.h
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/security/crypto/weakcryptospi/test/tplugins/inc/dsakeypairgenimpl.h	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,150 @@
     1.4 +/*
     1.5 +* Copyright (c) 2007-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 +*
    1.19 +*/
    1.20 +
    1.21 +
    1.22 +#ifndef __DSAKEYPAIRGENIMPL_H__
    1.23 +#define __DSAKEYPAIRGENIMPL_H__
    1.24 +
    1.25 +/**
    1.26 +@file 
    1.27 +@internalComponent
    1.28 +@released
    1.29 +*/
    1.30 +
    1.31 +#include <e32base.h>
    1.32 +#include <e32cmn.h>
    1.33 +#include "keypairgenimpl.h"
    1.34 +//#include <asymmetrickeys.h>
    1.35 +
    1.36 +/**
    1.37 + * Implementation of DSA key pair generation.
    1.38 + */
    1.39 +namespace SoftwareCrypto
    1.40 +	{
    1.41 +	NONSHARABLE_CLASS(CDSAPrimeCertificate) : public CBase
    1.42 +		{
    1.43 +	public:
    1.44 +		/** 
    1.45 +		Creates a new DSA prime certificate from a specified 
    1.46 +		seed and counter value.
    1.47 + 
    1.48 +		@param aSeed	The seed from a DSA key generation process
    1.49 +		@param aCounter	The counter value from a DSA key generation process
    1.50 +		@return			A pointer to a CDSAPrimeCertificate instance
    1.51 +		*/
    1.52 +		static CDSAPrimeCertificate* NewL(const TDesC8& aSeed, TUint aCounter);
    1.53 +
    1.54 +		/** 
    1.55 +		Creates a new DSA prime certificate from a specified 
    1.56 +		seed and counter value.
    1.57 +		
    1.58 +		The returned pointer is put onto the cleanup stack.
    1.59 +		
    1.60 +		@param aSeed		The seed from a DSA key generation process
    1.61 +		@param aCounter	The counter value from a DSA key generation process
    1.62 +		@return			A pointer to a CDSAPrimeCertificate instance
    1.63 +		*/
    1.64 +		static CDSAPrimeCertificate* NewLC(const TDesC8& aSeed, TUint aCounter);
    1.65 +
    1.66 +		/**
    1.67 +		Gets the seed of the DSA prime certificate
    1.68 +		@return	The seed
    1.69 +		*/
    1.70 +		const TDesC8& Seed() const;
    1.71 +		
    1.72 +		/**
    1.73 +		Gets the counter value of the DSA prime certificate
    1.74 +
    1.75 +		@return	The counter's value
    1.76 +		*/
    1.77 +		TUint Counter() const;
    1.78 +		
    1.79 +		/** 
    1.80 +		Destructor 
    1.81 +		*/
    1.82 +		~CDSAPrimeCertificate();
    1.83 +		
    1.84 +	protected:
    1.85 +		/** 
    1.86 +		Constructor
    1.87 +		@param aCounter	The DSA key generation counter
    1.88 +		*/
    1.89 +		CDSAPrimeCertificate(TUint aCounter);
    1.90 +
    1.91 +		/**
    1.92 +		Default constructor
    1.93 +		*/
    1.94 +		CDSAPrimeCertificate();
    1.95 +
    1.96 +		void ConstructL(const TDesC8& aSeed);
    1.97 +		
    1.98 +	protected:
    1.99 +		/** 
   1.100 +		The DSA key generation seed 
   1.101 +		*/
   1.102 +		const HBufC8* iSeed;
   1.103 +		/** 
   1.104 +		The DSA key generation counter 
   1.105 +		*/
   1.106 +		TUint iCounter;
   1.107 +	private:
   1.108 +		CDSAPrimeCertificate(const CDSAPrimeCertificate&);
   1.109 +		CDSAPrimeCertificate& operator=(const CDSAPrimeCertificate&);
   1.110 +		};
   1.111 +		
   1.112 +	NONSHARABLE_CLASS(CDSAKeyPairGenImpl) : public CKeyPairGenImpl
   1.113 +		{
   1.114 +	public:
   1.115 +	
   1.116 +		static CDSAKeyPairGenImpl* NewL();
   1.117 +		static CDSAKeyPairGenImpl* NewLC();
   1.118 +
   1.119 +		// from MPlugin
   1.120 +		void Reset();
   1.121 +
   1.122 +		// from MKeyPairGenerator
   1.123 +		void GenerateKeyPairL(TInt aKeySize, const CCryptoParams& aKeyParameters, CKeyPair*& aKeyPair);
   1.124 +		
   1.125 +		// Override CKeyPairGenImpl virtual functions
   1.126 +		TUid ImplementationUid() const;
   1.127 +		
   1.128 +		// Destructor
   1.129 +		~CDSAKeyPairGenImpl();
   1.130 +
   1.131 +		static TBool GeneratePrimesL(const TDesC8& aSeed,
   1.132 +									 TUint& aCounter, 
   1.133 +									 RInteger& aP, 
   1.134 +									 TUint aL, 
   1.135 +									 RInteger& aQ, 
   1.136 +									 TBool aUseInputCounter=EFalse);
   1.137 +									 
   1.138 +		static TBool ValidPrimeLength(TUint aPrimeBits);
   1.139 +		
   1.140 +	private:
   1.141 +		/**
   1.142 +		Constructor
   1.143 +		*/
   1.144 +		CDSAKeyPairGenImpl();
   1.145 +			
   1.146 +		/// second phase of construction
   1.147 +		void ConstructL();
   1.148 +		
   1.149 +		CDSAPrimeCertificate* iPrimeCertificate;
   1.150 +		};
   1.151 +	}
   1.152 +
   1.153 +#endif // __DSAKEYPAIRGENIMPL_H__