os/security/cryptoservices/filebasedcertificateandkeystores/source/keystore/Server/CCreateKey.h
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/security/cryptoservices/filebasedcertificateandkeystores/source/keystore/Server/CCreateKey.h	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,90 @@
     1.4 +/*
     1.5 +* Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.6 +* All rights reserved.
     1.7 +* This component and the accompanying materials are made available
     1.8 +* under the terms of the License "Eclipse Public License v1.0"
     1.9 +* which accompanies this distribution, and is available
    1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.11 +*
    1.12 +* Initial Contributors:
    1.13 +* Nokia Corporation - initial contribution.
    1.14 +*
    1.15 +* Contributors:
    1.16 +*
    1.17 +* Description: 
    1.18 +* Implements CKeyCreator  
    1.19 +*
    1.20 +*/
    1.21 +
    1.22 +
    1.23 +/**
    1.24 + @file 
    1.25 + @internalTechnology
    1.26 +*/
    1.27 + 
    1.28 +#ifndef __CCREATEKEYASYNC_H__
    1.29 +#define __CCREATEKEYASYNC_H__
    1.30 +
    1.31 +#include "fsdatatypes.h"
    1.32 +#include <e32std.h>
    1.33 +#include <mctkeystore.h>
    1.34 +#include <asymmetrickeys.h>
    1.35 +#include <bigint.h>
    1.36 +
    1.37 +class CSimpleDHKey;
    1.38 +class CKeyCreatorData;
    1.39 +
    1.40 +//! Server side
    1.41 +//!	Class to make key creation "asynchronous" by spinning off a thread
    1.42 +//!	to make the synchronous call to the appropriate key creation function
    1.43 +//!	The thread entry point is a static member of this class, which holds the 
    1.44 +//! thread and thread parameter data too.  When the key has been created, the
    1.45 +//! thread terminates using Rendezvous to notify the main thread.  The created key
    1.46 +//! is returned through the CAsymmetricCipher member of CKeyCreatorData
    1.47 +class CKeyCreator : public CActive
    1.48 +{
    1.49 +public:
    1.50 +	CKeyCreator();
    1.51 +	~CKeyCreator();
    1.52 +public:	//	Spin a thread to create an appropriate key, if successful, left on CleanupStack
    1.53 +	void DoCreateKeyAsync(CKeyInfo::EKeyAlgorithm aAlgorithm, TInt aSize, TRequestStatus& aStatus);
    1.54 +public:
    1.55 +//	JCS this needs improvement when new crypto api is reviewed
    1.56 +	CRSAKeyPair* GetCreatedRSAKey();
    1.57 +	CDSAKeyPair* GetCreatedDSAKey();
    1.58 +	void GetCreatedDHKey(RInteger& aDHKey);
    1.59 +protected:
    1.60 +	void DoCancel();
    1.61 +	void RunL();
    1.62 +	TInt RunError(TInt anError);
    1.63 +private:
    1.64 +	static TInt CreatorThreadEntryPoint(TAny*);
    1.65 +private:
    1.66 +	enum TAction {EIdle, EReadyToCreateKey, ECreatedKey};
    1.67 +	TAction iAction;
    1.68 +private:
    1.69 +	TRequestStatus* iClientStatus;
    1.70 +	RThread iCreatorThread;
    1.71 +private:
    1.72 +	class CKeyCreatorData : public CBase
    1.73 +	{
    1.74 +	public:
    1.75 +		CKeyCreatorData(CKeyInfo::EKeyAlgorithm aAlgorithm, TInt aSize);
    1.76 +		~CKeyCreatorData();
    1.77 +	public:	//	Don't bother hiding the data from myself
    1.78 +		TInt iSize;
    1.79 +		CKeyInfo::EKeyAlgorithm iKeyAlgorithm;
    1.80 +	//	Algorithm identified by iKeyAlgorithm
    1.81 +		
    1.82 +		union CreatedKey
    1.83 +		{
    1.84 +			CRSAKeyPair* iRSAKey;
    1.85 +			CDSAKeyPair* iDSAKey;
    1.86 +			CSimpleDHKey* iDHKey;
    1.87 +		}	iKey;
    1.88 +	};
    1.89 +	
    1.90 +	CKeyCreatorData* iCreateData;
    1.91 +};
    1.92 +
    1.93 +#endif	//	__CCREATEKEYASYNC_H__