sl@0: /* sl@0: * Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: * All rights reserved. sl@0: * This component and the accompanying materials are made available sl@0: * under the terms of the License "Eclipse Public License v1.0" sl@0: * which accompanies this distribution, and is available sl@0: * at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: * sl@0: * Initial Contributors: sl@0: * Nokia Corporation - initial contribution. sl@0: * sl@0: * Contributors: sl@0: * sl@0: * Description: sl@0: * Implements CKeyCreator sl@0: * sl@0: */ sl@0: sl@0: sl@0: /** sl@0: @file sl@0: @internalTechnology sl@0: */ sl@0: sl@0: #ifndef __CCREATEKEYASYNC_H__ sl@0: #define __CCREATEKEYASYNC_H__ sl@0: sl@0: #include "fsdatatypes.h" sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: sl@0: class CSimpleDHKey; sl@0: class CKeyCreatorData; sl@0: sl@0: //! Server side sl@0: //! Class to make key creation "asynchronous" by spinning off a thread sl@0: //! to make the synchronous call to the appropriate key creation function sl@0: //! The thread entry point is a static member of this class, which holds the sl@0: //! thread and thread parameter data too. When the key has been created, the sl@0: //! thread terminates using Rendezvous to notify the main thread. The created key sl@0: //! is returned through the CAsymmetricCipher member of CKeyCreatorData sl@0: class CKeyCreator : public CActive sl@0: { sl@0: public: sl@0: CKeyCreator(); sl@0: ~CKeyCreator(); sl@0: public: // Spin a thread to create an appropriate key, if successful, left on CleanupStack sl@0: void DoCreateKeyAsync(CKeyInfo::EKeyAlgorithm aAlgorithm, TInt aSize, TRequestStatus& aStatus); sl@0: public: sl@0: // JCS this needs improvement when new crypto api is reviewed sl@0: CRSAKeyPair* GetCreatedRSAKey(); sl@0: CDSAKeyPair* GetCreatedDSAKey(); sl@0: void GetCreatedDHKey(RInteger& aDHKey); sl@0: protected: sl@0: void DoCancel(); sl@0: void RunL(); sl@0: TInt RunError(TInt anError); sl@0: private: sl@0: static TInt CreatorThreadEntryPoint(TAny*); sl@0: private: sl@0: enum TAction {EIdle, EReadyToCreateKey, ECreatedKey}; sl@0: TAction iAction; sl@0: private: sl@0: TRequestStatus* iClientStatus; sl@0: RThread iCreatorThread; sl@0: private: sl@0: class CKeyCreatorData : public CBase sl@0: { sl@0: public: sl@0: CKeyCreatorData(CKeyInfo::EKeyAlgorithm aAlgorithm, TInt aSize); sl@0: ~CKeyCreatorData(); sl@0: public: // Don't bother hiding the data from myself sl@0: TInt iSize; sl@0: CKeyInfo::EKeyAlgorithm iKeyAlgorithm; sl@0: // Algorithm identified by iKeyAlgorithm sl@0: sl@0: union CreatedKey sl@0: { sl@0: CRSAKeyPair* iRSAKey; sl@0: CDSAKeyPair* iDSAKey; sl@0: CSimpleDHKey* iDHKey; sl@0: } iKey; sl@0: }; sl@0: sl@0: CKeyCreatorData* iCreateData; sl@0: }; sl@0: sl@0: #endif // __CCREATEKEYASYNC_H__