crypto/weakcryptospi/inc/spi/cryptokeypairgeneratorapi.h
changeset 8 35751d3474b7
child 33 cf642210ecb7
equal deleted inserted replaced
2:675a964f4eb5 8:35751d3474b7
       
     1 /*
       
     2 * Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the License "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 * crypto key pair generator application interface
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 /**
       
    21  @file
       
    22  @publishedPartner
       
    23  @released
       
    24 */
       
    25 
       
    26 #ifndef __CRYPTOAPI_KEYPAIRGENERATORAPI_H__
       
    27 #define __CRYPTOAPI_KEYPAIRGENERATORAPI_H__
       
    28 
       
    29 #include <cryptospi/cryptobaseapi.h>
       
    30 
       
    31 namespace CryptoSpi
       
    32 	{
       
    33 	class MKeyPairGenerator;
       
    34 	class MAsyncKeyPairGenerator;
       
    35 	class CCryptoParams;
       
    36 	class CKeyPair;
       
    37 	
       
    38 	/**
       
    39 	Synchronous Key pair generator, which wraps a synchronous Key pair generator plugin implementation
       
    40 	*/
       
    41 	NONSHARABLE_CLASS(CKeyPairGenerator) : public CCryptoBase
       
    42 		{
       
    43 	public:
       
    44 		/**
       
    45 		Create a CKeyPairGenerator instance from the given MKeyPairGenerator instance
       
    46 		@param aKeyPairGenerator The key pair generator plugin instance
       
    47 		@return A pointer to a CKeyPairGenerator instance
       
    48 		*/		
       
    49 		static CKeyPairGenerator* NewL(MKeyPairGenerator* aKeyPairGenerator, TInt aHandle);
       
    50 
       
    51 		/**
       
    52 		Generates a key pair
       
    53 		@param aKeySize 	The algorithm-specific metric in number of bits
       
    54 		@param aKeyParameters	The list of algorithm-specific parameters used by the generator to generate the key pair
       
    55 		@param aKeyPair	The generated key pair
       
    56 		*/
       
    57 		IMPORT_C void GenerateKeyPairL(TInt aKeySize, const CCryptoParams& aKeyParameters, CKeyPair*& aKeyPair);
       
    58 
       
    59 		/**
       
    60 		Destructor
       
    61 		*/
       
    62 		IMPORT_C ~CKeyPairGenerator();
       
    63 	
       
    64 	private:
       
    65 		
       
    66 		/**
       
    67 		Constructor
       
    68 		*/
       
    69 		CKeyPairGenerator(MKeyPairGenerator* aKeyPairGenerator, TInt aHandle);
       
    70 		};
       
    71 
       
    72 
       
    73 	/**
       
    74 	Asynchronous Key pair generator, which wraps a asynchronous Key pair generator plugin implementation
       
    75 	*/
       
    76 	NONSHARABLE_CLASS(CAsyncKeyPairGenerator) : public CCryptoBase
       
    77 		{
       
    78 	public:
       
    79 
       
    80 		/**
       
    81 		Create a CAsyncKeyPairGenerator instance from the given MAsyncKeyPairGenerator instance
       
    82 		@param aKeyPairGenerator	The aync key pair generator plugin instance
       
    83 		@return A pointer to a CAsyncKeyPairGenerator instance
       
    84 		*/
       
    85 		static CAsyncKeyPairGenerator* NewL(MAsyncKeyPairGenerator* aKeyPairGenerator, TInt aHandle);
       
    86 
       
    87 		/**
       
    88 		Destructor
       
    89 		*/
       
    90 		IMPORT_C ~CAsyncKeyPairGenerator();
       
    91 
       
    92 		/**
       
    93 		Generates a key pair
       
    94 		@param aKeySize	The algorithm-specific metric in number of bits
       
    95 		@param aKeyParameters	The list of algorithm-specific parameters used by the generator to generate the key pair
       
    96 		@param aKeyPair	The generated key pair
       
    97 		@param aRequestStatus
       
    98 		*/
       
    99 		IMPORT_C void GenerateKeyPairL(TInt aKeySize, const CCryptoParams& aKeyParameters, CKeyPair*& aKeyPair, TRequestStatus& aRequestStatus);
       
   100 
       
   101 		/**
       
   102 		Cancel the outstanding request
       
   103 		*/
       
   104 		IMPORT_C void Cancel();
       
   105 
       
   106 	private:
       
   107 
       
   108 		/**
       
   109 		Constructor
       
   110 		*/
       
   111 		CAsyncKeyPairGenerator(MAsyncKeyPairGenerator* aKeyPairGenerator, TInt aHandle);
       
   112 		};
       
   113 
       
   114 
       
   115 	/**
       
   116 	the Factory to create synchronous and asynchronous Key pair generator instances
       
   117 	*/
       
   118 	class CKeyPairGeneratorFactory
       
   119 		{
       
   120 	public:
       
   121 
       
   122 		/**
       
   123 		Creates a new instance of a key pair generator.
       
   124 
       
   125 		@param aKeyPairGenerator A reference to a pointer that should be set to point to the new asymmetric key pair generator object.
       
   126 		@param aKeyAlgorithmUid	The algorithm UID
       
   127 		@param aAlgorithmParams	The parameters that are specific to a particular algorithm. This is for extendibility and will normally be null.
       
   128 		@return KErrNone if successful; otherwise, a system wide error code.
       
   129 		*/
       
   130 		IMPORT_C static void CreateKeyPairGeneratorL(CKeyPairGenerator*& aKeyPairGenerator,
       
   131 													TUid aKeyAlgorithmUid,
       
   132 													const CCryptoParams* aAlgorithmParams);
       
   133 
       
   134 		/**
       
   135 		Creates a new asynchronous instance of a key pair generator.
       
   136 
       
   137 		@param aKeyPairGenerator A reference to a pointer that should be set to point to the new asymmetric key pair generator object.
       
   138 		@param aKeyAlgorithmUid	The algorithm UID
       
   139 		@param aAlgorithmParams	The parameters that are specific to a particular algorithm. This is for extendibility and will normally be null.
       
   140 		@return KErrNone if successful; otherwise, a system wide error code.
       
   141 		*/
       
   142 		IMPORT_C static void CreateAsyncKeyPairGeneratorL(CAsyncKeyPairGenerator*& aKeyPairGenerator,
       
   143 														TUid aKeyAlgorithmUid,
       
   144 														const CCryptoParams* aAlgorithmParams);
       
   145 		};
       
   146 	}
       
   147 
       
   148 #endif //__CRYPTOAPI_KEYPAIRGENERATORAPI_H__