pkiutilities/DeviceToken/Inc/DevCertKeyStoreServer.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 DevCertKeyStoreServer
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef __DEVCERTKEYSTORESERVER_H__
       
    21 #define __DEVCERTKEYSTORESERVER_H__
       
    22 
       
    23 #include <mctkeystoremanager.h>
       
    24 #include <s32file.h>
       
    25 #include <secdlg.h>
       
    26 
       
    27 class CDecPKCS8Data;
       
    28 class CDevCertRSARepudiableSigner;
       
    29 class CDevCertDSARepudiableSigner;
       
    30 class CDevCertRSADecryptor;
       
    31 class CDevCertDHAgreement;
       
    32 class CDevCertKeyCreator;
       
    33 class CDevCertKeyData;
       
    34 class CDevCertKeyDataManager;
       
    35 class CDevCertOpenedKeySrv;
       
    36 class CDevTokenKeyInfo;
       
    37 class CDevCertKeyStoreSession;
       
    38 class CDevCertKeyStoreConduit;
       
    39 
       
    40 /** 
       
    41  * Server side implementation of keystore interfaces as an active object.
       
    42  * 
       
    43  *  @lib 
       
    44  *  @since S60 v3.2
       
    45  */
       
    46 class CDevCertKeyStoreServer : public CActive
       
    47     {
       
    48     public:
       
    49         
       
    50         static CDevCertKeyStoreServer* NewL();
       
    51         
       
    52         virtual ~CDevCertKeyStoreServer();
       
    53         
       
    54         CDevCertKeyStoreSession* CreateSessionL();
       
    55         
       
    56         void RemoveSession(CDevCertKeyStoreSession& aSession);
       
    57         
       
    58         void ServiceRequestL(const RMessage2& aMessage, CDevCertKeyStoreSession& aSession);
       
    59     
       
    60     public:
       
    61         
       
    62         // For MKeyStore
       
    63         void ListL(const TCTKeyAttributeFilter& aFilter, RPointerArray<CDevTokenKeyInfo>& aKeys);
       
    64         
       
    65         void GetKeyInfoL(TInt aObjectId, CDevTokenKeyInfo*& aInfo);
       
    66         
       
    67         CDevCertOpenedKeySrv* OpenKeyL(TInt aHandle, TUid aOpenedKeyType);
       
    68         
       
    69         void ExportPublicL(TInt aObjectId, TDes8& aOut);
       
    70         
       
    71         TInt GetKeyLengthL(TInt aObjectId);
       
    72     
       
    73     public:
       
    74         
       
    75         // For MCTKeyStoreManager
       
    76         void CreateKey(CDevTokenKeyInfo& aReturnedKey, TRequestStatus& aStatus);
       
    77         
       
    78         void CancelCreateKey();
       
    79         
       
    80         void ImportKey(const TDesC8& aKey, CDevTokenKeyInfo& aReturnedKey, TBool aIsEncrypted,TRequestStatus& aStatus);
       
    81         
       
    82         void CancelImportKey();
       
    83         
       
    84         void ExportKey(TInt aObjectId, const TPtr8& aKey, TRequestStatus& aStatus); 
       
    85         
       
    86         void CancelExportKey();
       
    87         
       
    88         void DeleteKeyL(TInt aObjectId);
       
    89         
       
    90         void SetUsePolicyL(TInt aObjectId, const TSecurityPolicy& aPolicy);
       
    91         
       
    92         void SetManagementPolicyL(TInt aObjectId, const TSecurityPolicy& aPolicy);
       
    93 
       
    94     private:
       
    95         
       
    96         CDevCertKeyStoreServer();
       
    97         
       
    98         void ConstructL();
       
    99     
       
   100     private:
       
   101         
       
   102         //  From CActive
       
   103         void RunL();
       
   104         
       
   105         TInt RunError(TInt aError);
       
   106         
       
   107         void DoCancel();
       
   108     
       
   109     private:
       
   110         
       
   111         enum ECurrentAction
       
   112             {
       
   113             EIdle,
       
   114             EImportOpenPrivateStream,
       
   115             ECreateKeyCreate,
       
   116             ECreateKeyFinal,
       
   117             EImportKey, 
       
   118             EExportKey,
       
   119             EKeyCreated
       
   120             };
       
   121 
       
   122         /**
       
   123         * The operations that can create a new key, used by CheckKeyAttributes.
       
   124         */
       
   125         enum TNewKeyOperation
       
   126             {
       
   127             ENewKeyCreate,
       
   128             ENewKeyImportPlaintext
       
   129             };
       
   130 
       
   131     private:
       
   132     
       
   133         CDevCertKeyStoreServer(const CDevCertKeyStoreServer&);      //  No copying
       
   134     
       
   135         CDevCertKeyStoreServer& operator=(const CDevCertKeyStoreServer&); //  No copying
       
   136     
       
   137     private:
       
   138 
       
   139         TInt CheckKeyAttributes(CDevTokenKeyInfo& aKey, TNewKeyOperation aOp);
       
   140         
       
   141         TInt CheckKeyAlgorithmAndSize(CDevTokenKeyInfo& aKey);
       
   142         
       
   143         void DoCreateKeyL();
       
   144         
       
   145         void DoStoreKeyL();
       
   146         
       
   147         void DoImportKeyL();
       
   148         
       
   149         void DoExportKeyL(TInt aObjectId, const TPtr8& aKey, TRequestStatus& aStatus);
       
   150         
       
   151         void CompleteKeyExportL();
       
   152         
       
   153         void OpenPrivateStream();
       
   154 
       
   155     private:
       
   156     
       
   157         void PKCS8ToKeyL(CDecPKCS8Data* aPKCS8Data);
       
   158         
       
   159         TBool KeyMatchesFilterL(const CDevTokenKeyInfo& aInfo,
       
   160         
       
   161         const TCTKeyAttributeFilter& aFilter);
       
   162     
       
   163     private:
       
   164         
       
   165         CDevCertKeyDataManager* iKeyDataManager;
       
   166         
       
   167         CDevCertKeyStoreConduit* iConduit;
       
   168         
       
   169         RPointerArray<CDevCertKeyStoreSession> iSessions;
       
   170         
       
   171         const RMessage2* iMessage;    //The request currently being processed, not owned by us
       
   172         
       
   173         CDevCertKeyStoreSession* iSession;      // The session of the request being processed, not owned through here
       
   174         
       
   175         TRequestStatus* iCallerRequest;
       
   176         
       
   177         ECurrentAction iAction;
       
   178     
       
   179     private:
       
   180         
       
   181         CDevTokenKeyInfo* iKeyInfo;
       
   182         
       
   183         CDevCertKeyCreator* iKeyCreator;
       
   184 
       
   185         TPtr8 iExportBuf;
       
   186 
       
   187         TInt iObjectId;
       
   188     
       
   189         TPtrC8 iPKCS8Data;
       
   190         
       
   191         TBool iImportingEncryptedKey;
       
   192         
       
   193         TPINValue iPassword;
       
   194         
       
   195         const CDevCertKeyData* iKeyData;
       
   196     };
       
   197 
       
   198 #endif  //  __CDevCertKeyStoreServer_H__
       
   199 
       
   200 //EOF
       
   201