os/security/cryptoservices/filebasedcertificateandkeystores/source/keystore/Server/CCreateKey.h
First public contribution.
2 * Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
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".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
15 * Implements CKeyCreator
25 #ifndef __CCREATEKEYASYNC_H__
26 #define __CCREATEKEYASYNC_H__
28 #include "fsdatatypes.h"
30 #include <mctkeystore.h>
31 #include <asymmetrickeys.h>
35 class CKeyCreatorData;
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
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);
52 // JCS this needs improvement when new crypto api is reviewed
53 CRSAKeyPair* GetCreatedRSAKey();
54 CDSAKeyPair* GetCreatedDSAKey();
55 void GetCreatedDHKey(RInteger& aDHKey);
59 TInt RunError(TInt anError);
61 static TInt CreatorThreadEntryPoint(TAny*);
63 enum TAction {EIdle, EReadyToCreateKey, ECreatedKey};
66 TRequestStatus* iClientStatus;
67 RThread iCreatorThread;
69 class CKeyCreatorData : public CBase
72 CKeyCreatorData(CKeyInfo::EKeyAlgorithm aAlgorithm, TInt aSize);
74 public: // Don't bother hiding the data from myself
76 CKeyInfo::EKeyAlgorithm iKeyAlgorithm;
77 // Algorithm identified by iKeyAlgorithm
87 CKeyCreatorData* iCreateData;
90 #endif // __CCREATEKEYASYNC_H__