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