os/security/cryptoplugins/cryptospiplugins/source/softwarecrypto/dsakeypairgenimpl.h
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
/*
sl@0
     2
* Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     3
* All rights reserved.
sl@0
     4
* This component and the accompanying materials are made available
sl@0
     5
* under the terms of the License "Eclipse Public License v1.0"
sl@0
     6
* which accompanies this distribution, and is available
sl@0
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     8
*
sl@0
     9
* Initial Contributors:
sl@0
    10
* Nokia Corporation - initial contribution.
sl@0
    11
*
sl@0
    12
* Contributors:
sl@0
    13
*
sl@0
    14
* Description: 
sl@0
    15
*
sl@0
    16
*/
sl@0
    17
sl@0
    18
sl@0
    19
#ifndef __DSAKEYPAIRGENIMPL_H__
sl@0
    20
#define __DSAKEYPAIRGENIMPL_H__
sl@0
    21
sl@0
    22
/**
sl@0
    23
@file 
sl@0
    24
@internalComponent
sl@0
    25
@released
sl@0
    26
*/
sl@0
    27
sl@0
    28
#include <e32base.h>
sl@0
    29
#include <e32cmn.h>
sl@0
    30
#include "keypairgenimpl.h"
sl@0
    31
//#include <asymmetrickeys.h>
sl@0
    32
sl@0
    33
/**
sl@0
    34
 * Implementation of DSA key pair generation.
sl@0
    35
 */
sl@0
    36
namespace SoftwareCrypto
sl@0
    37
	{
sl@0
    38
	NONSHARABLE_CLASS(CDSAPrimeCertificate) : public CBase
sl@0
    39
		{
sl@0
    40
	public:
sl@0
    41
		/** 
sl@0
    42
		Creates a new DSA prime certificate from a specified 
sl@0
    43
		seed and counter value.
sl@0
    44
 
sl@0
    45
		@param aSeed	The seed from a DSA key generation process
sl@0
    46
		@param aCounter	The counter value from a DSA key generation process
sl@0
    47
		@return			A pointer to a CDSAPrimeCertificate instance
sl@0
    48
		*/
sl@0
    49
		static CDSAPrimeCertificate* NewL(const TDesC8& aSeed, TUint aCounter);
sl@0
    50
sl@0
    51
		/** 
sl@0
    52
		Creates a new DSA prime certificate from a specified 
sl@0
    53
		seed and counter value.
sl@0
    54
		
sl@0
    55
		The returned pointer is put onto the cleanup stack.
sl@0
    56
		
sl@0
    57
		@param aSeed		The seed from a DSA key generation process
sl@0
    58
		@param aCounter	The counter value from a DSA key generation process
sl@0
    59
		@return			A pointer to a CDSAPrimeCertificate instance
sl@0
    60
		*/
sl@0
    61
		static CDSAPrimeCertificate* NewLC(const TDesC8& aSeed, TUint aCounter);
sl@0
    62
sl@0
    63
		/**
sl@0
    64
		Gets the seed of the DSA prime certificate
sl@0
    65
		@return	The seed
sl@0
    66
		*/
sl@0
    67
		const TDesC8& Seed() const;
sl@0
    68
		
sl@0
    69
		/**
sl@0
    70
		Gets the counter value of the DSA prime certificate
sl@0
    71
sl@0
    72
		@return	The counter's value
sl@0
    73
		*/
sl@0
    74
		TUint Counter() const;
sl@0
    75
		
sl@0
    76
		/** 
sl@0
    77
		Destructor 
sl@0
    78
		*/
sl@0
    79
		~CDSAPrimeCertificate();
sl@0
    80
		
sl@0
    81
	protected:
sl@0
    82
		/** 
sl@0
    83
		Constructor
sl@0
    84
		@param aCounter	The DSA key generation counter
sl@0
    85
		*/
sl@0
    86
		CDSAPrimeCertificate(TUint aCounter);
sl@0
    87
sl@0
    88
		/**
sl@0
    89
		Default constructor
sl@0
    90
		*/
sl@0
    91
		CDSAPrimeCertificate();
sl@0
    92
sl@0
    93
		void ConstructL(const TDesC8& aSeed);
sl@0
    94
		
sl@0
    95
	protected:
sl@0
    96
		/** 
sl@0
    97
		The DSA key generation seed 
sl@0
    98
		*/
sl@0
    99
		const HBufC8* iSeed;
sl@0
   100
		/** 
sl@0
   101
		The DSA key generation counter 
sl@0
   102
		*/
sl@0
   103
		TUint iCounter;
sl@0
   104
	private:
sl@0
   105
		CDSAPrimeCertificate(const CDSAPrimeCertificate&);
sl@0
   106
		CDSAPrimeCertificate& operator=(const CDSAPrimeCertificate&);
sl@0
   107
		};
sl@0
   108
		
sl@0
   109
	NONSHARABLE_CLASS(CDSAKeyPairGenImpl) : public CKeyPairGenImpl
sl@0
   110
		{
sl@0
   111
	public:
sl@0
   112
	
sl@0
   113
		static CDSAKeyPairGenImpl* NewL();
sl@0
   114
		static CDSAKeyPairGenImpl* NewLC();
sl@0
   115
sl@0
   116
		// from MPlugin
sl@0
   117
		void Reset();
sl@0
   118
sl@0
   119
		// from MKeyPairGenerator
sl@0
   120
		void GenerateKeyPairL(TInt aKeySize, const CCryptoParams& aKeyParameters, CKeyPair*& aKeyPair);
sl@0
   121
		
sl@0
   122
		// Override CKeyPairGenImpl virtual functions
sl@0
   123
		TUid ImplementationUid() const;
sl@0
   124
		
sl@0
   125
		const CExtendedCharacteristics* GetExtendedCharacteristicsL();
sl@0
   126
		static CExtendedCharacteristics* CreateExtendedCharacteristicsL();
sl@0
   127
		
sl@0
   128
		// Destructor
sl@0
   129
		~CDSAKeyPairGenImpl();
sl@0
   130
sl@0
   131
		static TBool GeneratePrimesL(const TDesC8& aSeed,
sl@0
   132
									 TUint& aCounter, 
sl@0
   133
									 RInteger& aP, 
sl@0
   134
									 TUint aL, 
sl@0
   135
									 RInteger& aQ, 
sl@0
   136
									 TBool aUseInputCounter=EFalse);
sl@0
   137
									 
sl@0
   138
		static TBool ValidPrimeLength(TUint aPrimeBits);
sl@0
   139
		
sl@0
   140
	private:
sl@0
   141
		/**
sl@0
   142
		Constructor
sl@0
   143
		*/
sl@0
   144
		CDSAKeyPairGenImpl();
sl@0
   145
			
sl@0
   146
		/// second phase of construction
sl@0
   147
		void ConstructL();
sl@0
   148
		
sl@0
   149
		CDSAPrimeCertificate* iPrimeCertificate;
sl@0
   150
		};
sl@0
   151
	}
sl@0
   152
sl@0
   153
#endif // __DSAKEYPAIRGENIMPL_H__