cryptoservices/filebasedcertificateandkeystores/source/keystore/Server/CCreateKey.h
changeset 0 2c201484c85f
child 8 35751d3474b7
equal deleted inserted replaced
-1:000000000000 0:2c201484c85f
       
     1 /*
       
     2 * Copyright (c) 2004-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 * Implements CKeyCreator  
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 /**
       
    23  @file 
       
    24  @internalTechnology
       
    25 */
       
    26  
       
    27 #ifndef __CCREATEKEYASYNC_H__
       
    28 #define __CCREATEKEYASYNC_H__
       
    29 
       
    30 #include "fsdatatypes.h"
       
    31 #include <e32std.h>
       
    32 #include <mctkeystore.h>
       
    33 #include <asymmetrickeys.h>
       
    34 #include <bigint.h>
       
    35 
       
    36 class CSimpleDHKey;
       
    37 class CKeyCreatorData;
       
    38 
       
    39 //! Server side
       
    40 //!	Class to make key creation "asynchronous" by spinning off a thread
       
    41 //!	to make the synchronous call to the appropriate key creation function
       
    42 //!	The thread entry point is a static member of this class, which holds the 
       
    43 //! thread and thread parameter data too.  When the key has been created, the
       
    44 //! thread terminates using Rendezvous to notify the main thread.  The created key
       
    45 //! is returned through the CAsymmetricCipher member of CKeyCreatorData
       
    46 class CKeyCreator : public CActive
       
    47 {
       
    48 public:
       
    49 	CKeyCreator();
       
    50 	~CKeyCreator();
       
    51 public:	//	Spin a thread to create an appropriate key, if successful, left on CleanupStack
       
    52 	void DoCreateKeyAsyncL(CKeyInfo::EKeyAlgorithm aAlgorithm, TInt aSize, TRequestStatus& aStatus);
       
    53 public:
       
    54 //	JCS this needs improvement when new crypto api is reviewed
       
    55 	CRSAKeyPair* GetCreatedRSAKey();
       
    56 	CDSAKeyPair* GetCreatedDSAKey();
       
    57 	void GetCreatedDHKey(RInteger& aDHKey);
       
    58 protected:
       
    59 	void DoCancel();
       
    60 	void RunL();
       
    61 	TInt RunError(TInt anError);
       
    62 private:
       
    63 	static TInt CreatorThreadEntryPoint(TAny*);
       
    64 private:
       
    65 	enum TAction {EIdle, EReadyToCreateKey, ECreatedKey};
       
    66 	TAction iAction;
       
    67 private:
       
    68 	TRequestStatus* iClientStatus;
       
    69 	RThread iCreatorThread;
       
    70 private:
       
    71 	class CKeyCreatorData : public CBase
       
    72 	{
       
    73 	public:
       
    74 		CKeyCreatorData(CKeyInfo::EKeyAlgorithm aAlgorithm, TInt aSize);
       
    75 		~CKeyCreatorData();
       
    76 	public:	//	Don't bother hiding the data from myself
       
    77 		TInt iSize;
       
    78 		CKeyInfo::EKeyAlgorithm iKeyAlgorithm;
       
    79 	//	Algorithm identified by iKeyAlgorithm
       
    80 		
       
    81 		union CreatedKey
       
    82 		{
       
    83 			CRSAKeyPair* iRSAKey;
       
    84 			CDSAKeyPair* iDSAKey;
       
    85 			CSimpleDHKey* iDHKey;
       
    86 		}	iKey;
       
    87 	};
       
    88 	
       
    89 	CKeyCreatorData* iCreateData;
       
    90 };
       
    91 
       
    92 #endif	//	__CCREATEKEYASYNC_H__