pkiutilities/DeviceToken/Inc/DevCertCreateKey.h
changeset 0 164170e6151a
equal deleted inserted replaced
-1:000000000000 0:164170e6151a
       
     1 /*
       
     2 * Copyright (c) 2006 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 "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:   The header file of DevCertCreateKey
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef __DEVCERTCREATEKEY_H__
       
    21 #define __DEVCERTCREATEKEY_H__
       
    22 
       
    23 #include <bigint.h>
       
    24 #include <e32std.h>
       
    25 #include <mctkeystore.h>
       
    26 #include <asymmetrickeys.h>
       
    27 #include "DevTokenDataTypes.h"
       
    28 
       
    29 class CSimpleDHKey;
       
    30 class CDevCertKeyCreatorData;
       
    31 
       
    32 _LIT(KCreateKeyName, "AsymmetricKeysCreator");
       
    33 
       
    34 /**
       
    35  *  class CDevCertKeyCreator
       
    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  *
       
    45  *  @lib 
       
    46  *  @since S60 v3.2
       
    47  */
       
    48 class CDevCertKeyCreator : public CActive
       
    49     {
       
    50     public:
       
    51         
       
    52         CDevCertKeyCreator();
       
    53         
       
    54         ~CDevCertKeyCreator();
       
    55         
       
    56     public: //  Spin a thread to create an appropriate key, if successful, left on CleanupStack
       
    57         
       
    58         void DoCreateKeyAsyncL(CDevTokenKeyInfo::EKeyAlgorithm aAlgorithm, TInt aSize, TRequestStatus& aStatus);
       
    59         
       
    60     public:
       
    61         
       
    62         //  JCS this needs improvement when new crypto api is reviewed
       
    63         CRSAKeyPair* GetCreatedRSAKey();
       
    64         
       
    65         CDSAKeyPair* GetCreatedDSAKey();
       
    66         
       
    67         void GetCreatedDHKey(RInteger& aDHKey);
       
    68         
       
    69     protected:
       
    70         
       
    71         void DoCancel();
       
    72         
       
    73         void RunL();
       
    74         
       
    75         TInt RunError(TInt anError);
       
    76         
       
    77     private:
       
    78         
       
    79         static TInt CreatorThreadEntryPoint(TAny*);
       
    80         
       
    81     private:
       
    82         
       
    83         enum TAction {EIdle, EReadyToCreateKey, ECreatedKey};
       
    84         
       
    85         TAction iAction;
       
    86     private:
       
    87         
       
    88         TRequestStatus* iClientStatus;
       
    89         
       
    90         RThread iCreatorThread;
       
    91         
       
    92     private:
       
    93         
       
    94         class CDevCertKeyCreatorData : public CBase
       
    95             {
       
    96             public:
       
    97         
       
    98                 CDevCertKeyCreatorData(CDevTokenKeyInfo::EKeyAlgorithm aAlgorithm, TInt aSize);
       
    99         
       
   100                 ~CDevCertKeyCreatorData();
       
   101                 
       
   102             public: //  Don't bother hiding the data from myself
       
   103         
       
   104                 TInt iSize;
       
   105         
       
   106                 //  Algorithm identified by iKeyAlgorithm
       
   107                 CDevTokenKeyInfo::EKeyAlgorithm iKeyAlgorithm;
       
   108 
       
   109             union CreatedKey
       
   110                 {
       
   111                 CRSAKeyPair* iRSAKey;
       
   112                 CDSAKeyPair* iDSAKey;
       
   113                 CSimpleDHKey* iDHKey;
       
   114                 } iKey;
       
   115             };
       
   116 
       
   117     CDevCertKeyCreatorData* iCreateData;
       
   118     };
       
   119 
       
   120 #endif  //  __DEVCERTCREATEKEY_H__
       
   121 
       
   122 //EOF
       
   123