vpnengine/pkiservice/inc/pkiserviceclientservercommon.h
changeset 0 33413c0669b9
child 44 735de8341ce4
equal deleted inserted replaced
-1:000000000000 0:33413c0669b9
       
     1 /*
       
     2 * Copyright (c) 2007-2008 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:   Collects data type used by both client and server.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 #ifndef PKI_SERVICE_CLIENT_SERVER_COMMON_H
       
    22 #define PKI_SERVICE_CLIENT_SERVER_COMMON_H
       
    23 
       
    24 #include "pkidefs.h"
       
    25 
       
    26 static const TUid KPkiServiceUid3 = {0x101FAE07};
       
    27 _LIT(KPkiServerName,"!PKIserver");
       
    28 _LIT(KPkiServerImg,"pkiservice");
       
    29 
       
    30 
       
    31 const TInt KPkiMajorVersion = 1;
       
    32 const TInt KPkiMinorVersion = 0;
       
    33 const TInt KPkiBuildVersion = 0;
       
    34 
       
    35 
       
    36 const TInt KMyServerInitHeapSize=0x1000;        //  4KB
       
    37 const TInt KMyServerMaxHeapSize=0x1000000;      // 16MB
       
    38 const TInt KMyServerStackSize=0x2000;           //  8KB
       
    39 
       
    40 namespace PkiService
       
    41     {        
       
    42     enum TPkiServiceCommands
       
    43         { 
       
    44         ELogon,                             // 0
       
    45         EChangePassword,                    // 1
       
    46         ESignWithKeyId,                     // 2
       
    47         ESignWithCert,                      // 3
       
    48         EDecrypt,                           // 4
       
    49         EStoreKeypair,                      // 5            
       
    50         EGenerateKeypair,                   // 6
       
    51         ECancelPendingOperation,            // 7
       
    52         EGetRequiredBufferSize,             // 8
       
    53         EReadPublicKey,                     // 9
       
    54         EReadCertificate,                   // 10
       
    55         EStoreCertificate,                  // 11
       
    56         EAttachCertificate,                 // 12
       
    57         ERemoveKeypair,                     // 13
       
    58         ERemoveCertificate,                 // 14
       
    59         ECertCount,                         // 15
       
    60         EInitialize,                        // 16
       
    61         ESaveCertificateRequest,            // 17
       
    62         EReadCertificateRequest,            // 18
       
    63         EDeleteCertificateRequest,          // 19
       
    64         ESetTrust,                          // 20
       
    65         ETrusted,                           // 21
       
    66         EKeyCount,                          // 22
       
    67         EGetKeyList,                        // 23
       
    68     	EGetCertList,                       // 24
       
    69         ESetApplicability,                  // 25
       
    70         EApplications,                      // 26          
       
    71         EGetCertDetails,                    // 27
       
    72         ELogoff,                            // 28
       
    73         ECertReqCount,                      // 29
       
    74         EGetCertReqList,                    // 30
       
    75     	EGetKeyDetails,						// 31
       
    76     	EApplicableCertCount,				// 32
       
    77     	EGetApplicableCertList,				// 33
       
    78     	ESetCertStoreType,                  // 34
       
    79     	ESetKeyStoreType,                   // 35
       
    80     	ESetStoreType,                      // 36
       
    81     	EGetCertStoreType,					// 37
       
    82     	EGetKeyStoreType,					// 38
       
    83     	ESetInformational                   // 39
       
    84         };
       
    85     }
       
    86 
       
    87 
       
    88 
       
    89 const TInt KKeyUsageNotUsed = 0x5A5A5A5A;
       
    90 
       
    91 /**
       
    92 * Internal class. Not used by the API
       
    93 */
       
    94 
       
    95 class TSecurityObjectDescriptor
       
    96 {
       
    97     public:
       
    98         TSecurityObjectDescriptor()
       
    99         :iTrustedAuthority(), 
       
   100          iTrustedAuthorityUsed(EFalse),
       
   101          iIdentitySubjectName(),
       
   102          iIdentitySubjectNameUsed(EFalse),
       
   103          iIdentityRfc822Name(),
       
   104          iIdentityRfc822NameUsed(EFalse),
       
   105          iSerialNumber(),
       
   106          iSerialNumberUsed(EFalse),
       
   107          iSubjectKeyId(),
       
   108          iSubjectKeyIdUsed(EFalse),
       
   109          iOwnerType(EPKICACertificate),
       
   110          iOwnerTypeUsed(EFalse),
       
   111          iKeyUsage( (TPKIKeyUsage) 0),
       
   112          iKeyUsageDer(),
       
   113          iKeyUsageUsed(EFalse),
       
   114          iKeySize(0),
       
   115          iKeySizeUsed(EFalse),
       
   116          iKeyAlgorithm(EPKIInvalidAlgorithm),
       
   117          iKeyAlgorithmUsed(EFalse),
       
   118          iObjectSize(EFalse),
       
   119          iEncrypted(EFalse),
       
   120          iObjectName(),
       
   121          iObjectNameUsed(EFalse),
       
   122          iIsDeletable(EFalse),
       
   123          iIsDeletableUsed(EFalse)
       
   124             {};
       
   125             
       
   126         void SetSubjectKeyId(const TPKIKeyIdentifier &aKeyId)
       
   127             {
       
   128             if(aKeyId.Length() > 0)
       
   129                 {
       
   130                 iSubjectKeyId.Copy(aKeyId);
       
   131                 iSubjectKeyIdUsed = ETrue;
       
   132                 }
       
   133             else
       
   134                 {
       
   135                 iSubjectKeyIdUsed = EFalse;
       
   136                 }
       
   137             };
       
   138         void SetOwnerType(const TPKICertificateOwnerType aOwnerType) 
       
   139             {
       
   140             iOwnerType = aOwnerType;
       
   141             iOwnerTypeUsed = ETrue;
       
   142             };
       
   143         void SetKeyUsage(const TPKIKeyUsage aKeyUsage)      // Optional if only certificate is needed
       
   144             {
       
   145             if((TInt)aKeyUsage != KKeyUsageNotUsed)
       
   146                 {
       
   147                 iKeyUsage = aKeyUsage;
       
   148                 iKeyUsageUsed = ETrue;
       
   149                 }
       
   150             else
       
   151                 {
       
   152                 iKeyUsage = (TPKIKeyUsage)0;
       
   153                 iKeyUsageUsed = EFalse;
       
   154                 }
       
   155             };                          
       
   156         // Key usage is not defined in the filter, this will be checked separately
       
   157         void SetKeySize(const TUint aKeySize)
       
   158             {
       
   159             if(aKeySize != 0)
       
   160                 {
       
   161                 iKeySize = aKeySize;
       
   162                 iKeySizeUsed = ETrue;
       
   163                 }
       
   164             else
       
   165                 {
       
   166                 iKeySizeUsed = EFalse;
       
   167                 }
       
   168             };              // Optional if only certificate is needed
       
   169         void SetObjectName(const TDesC &aObjectName)
       
   170             {
       
   171             if(aObjectName.Length() > 0)
       
   172                 {
       
   173                 iObjectName.Copy(aObjectName);
       
   174                 iObjectNameUsed = ETrue;
       
   175                 }
       
   176             else
       
   177                 {
       
   178                 iObjectNameUsed = EFalse;
       
   179                 }
       
   180             };
       
   181         // Issuer and serial are not defined in the filter, these will be checked separately
       
   182         void SetTrustedAuthority(const TDesC8 &aTrustedAuthority)
       
   183                 {
       
   184                 if(aTrustedAuthority.Length() > 0)
       
   185                     {
       
   186                     iTrustedAuthority.Copy(aTrustedAuthority);
       
   187                     iTrustedAuthorityUsed = ETrue;
       
   188                     }
       
   189                 else
       
   190                     {
       
   191                     iTrustedAuthorityUsed = EFalse;
       
   192                     }
       
   193                 };
       
   194         void SetIdentitySubjectName(const TDesC8 &aIdentitySubjectName)
       
   195                 {
       
   196                     if(aIdentitySubjectName.Length() > 0)
       
   197                         {
       
   198                         iIdentitySubjectName.Copy(aIdentitySubjectName);
       
   199                         iIdentitySubjectNameUsed = ETrue;
       
   200                         }
       
   201                     else
       
   202                         {
       
   203                         iIdentitySubjectNameUsed = EFalse;
       
   204                         }
       
   205                 };
       
   206         void SetIdentityRfc822Name(const TDesC8 &aIdentityRfc822Name)
       
   207                 {
       
   208                     if(aIdentityRfc822Name.Length() > 0)
       
   209                         {
       
   210                         iIdentityRfc822Name.Copy(aIdentityRfc822Name);
       
   211                         iIdentityRfc822NameUsed = ETrue;
       
   212                         }
       
   213                     else
       
   214                         {
       
   215                         iIdentityRfc822NameUsed = EFalse;
       
   216                         }
       
   217                 };
       
   218         void SetSerialNumber(const TDesC8 &aSerialNumber)
       
   219             {
       
   220             if(aSerialNumber.Length() > 0)
       
   221                 {
       
   222                 iSerialNumber.Copy(aSerialNumber);
       
   223                 iSerialNumberUsed = ETrue;
       
   224                 }
       
   225             else
       
   226                 {
       
   227                 iSerialNumberUsed = EFalse;
       
   228                 }
       
   229             };
       
   230         void SetKeyAlgorithm(const TPKIKeyAlgorithm &aKeyAlgorithm) 
       
   231             {
       
   232             iKeyAlgorithm = aKeyAlgorithm;
       
   233             iKeyAlgorithmUsed = ETrue;
       
   234             };
       
   235 		void SetIsDeletable(const TUint &aIsDeletable) 
       
   236 		    {
       
   237 		    iIsDeletable = aIsDeletable;
       
   238 		    iIsDeletableUsed = ETrue;
       
   239 		    };
       
   240         void Reset()
       
   241             {
       
   242             iObjectNameUsed = EFalse;
       
   243             iTrustedAuthorityUsed = EFalse;
       
   244             iIdentitySubjectNameUsed = EFalse;
       
   245             iIdentityRfc822NameUsed = EFalse;
       
   246             iSubjectKeyIdUsed = EFalse;
       
   247             iOwnerTypeUsed = EFalse;
       
   248             iKeyUsageUsed = EFalse;
       
   249             iKeySizeUsed = EFalse;
       
   250             iKeyAlgorithmUsed = EFalse;
       
   251             };
       
   252         TSecurityObjectDescriptor& operator=(const TSecurityObjectDescriptor& aDesc)
       
   253             {
       
   254             if (this != &aDesc)
       
   255                 {
       
   256                 this->iObjectName = aDesc.iObjectName;
       
   257                 this->iObjectNameUsed = aDesc.iObjectNameUsed;
       
   258                 this->iTrustedAuthority = aDesc.iTrustedAuthority;
       
   259                 this->iTrustedAuthorityUsed = aDesc.iTrustedAuthorityUsed;
       
   260                 this->iIdentitySubjectName = aDesc.iIdentitySubjectName;
       
   261                 this->iIdentitySubjectNameUsed = aDesc.iIdentitySubjectNameUsed;
       
   262                 this->iIdentityRfc822Name = aDesc.iIdentityRfc822Name;
       
   263                 this->iIdentityRfc822NameUsed = aDesc.iIdentityRfc822NameUsed;
       
   264                 this->iSerialNumber = aDesc.iSerialNumber;
       
   265                 this->iSerialNumberUsed = aDesc.iSerialNumberUsed;
       
   266                 this->iSubjectKeyId = aDesc.iSubjectKeyId;      
       
   267                 this->iSubjectKeyIdUsed = aDesc.iSubjectKeyIdUsed;      
       
   268                 this->iOwnerType = aDesc.iOwnerType;            
       
   269                 this->iOwnerTypeUsed = aDesc.iOwnerTypeUsed;            
       
   270                 this->iKeyUsage = aDesc.iKeyUsage;          
       
   271                 this->iKeyUsageDer = aDesc.iKeyUsageDer;            
       
   272                 this->iKeyUsageUsed = aDesc.iKeyUsageUsed;          
       
   273                 this->iKeySize = aDesc.iKeySize;            
       
   274                 this->iKeySizeUsed = aDesc.iKeySizeUsed;            
       
   275                 this->iKeyAlgorithm = aDesc.iKeyAlgorithm;      
       
   276                 this->iKeyAlgorithmUsed = aDesc.iKeyAlgorithmUsed;
       
   277     			this->iIsDeletable = aDesc.iIsDeletable;      
       
   278     			this->iIsDeletableUsed = aDesc.iIsDeletableUsed;
       
   279                 }
       
   280             return *this;
       
   281             };
       
   282        
       
   283         // No get methods introduced, values are used directly!     
       
   284         TBuf8<KMaxX500DN>           iTrustedAuthority;          // Cert TrustedAuthority
       
   285         TBool                       iTrustedAuthorityUsed;
       
   286         TBuf8<KMaxX500DN>           iIdentitySubjectName;       // Identity subject name
       
   287         TBool                       iIdentitySubjectNameUsed;
       
   288         TBuf8<KMaxRfc822>           iIdentityRfc822Name;        // Identity subjectAltName rfc822 name
       
   289         TBool                       iIdentityRfc822NameUsed;
       
   290         TBuf8<KMaxSerial>           iSerialNumber;              // Serialnumber
       
   291         TBool                       iSerialNumberUsed;
       
   292         TPKIKeyIdentifier           iSubjectKeyId;              // SHA1 hash of the corresponding private key
       
   293         TBool                       iSubjectKeyIdUsed;
       
   294         TPKICertificateOwnerType    iOwnerType;                 // User, CA or peer. If user certificate, at least key usage must be set
       
   295         TBool                       iOwnerTypeUsed;
       
   296         TPKIKeyUsage                iKeyUsage;                  // Key usage flags
       
   297         TBuf8<KMaxUsageDer>         iKeyUsageDer;               // Der format flags
       
   298         TBool                       iKeyUsageUsed;
       
   299         TUint                       iKeySize;                   // Key size
       
   300         TBool                       iKeySizeUsed;
       
   301         TPKIKeyAlgorithm            iKeyAlgorithm;              // RSA, DSA
       
   302         TBool                       iKeyAlgorithmUsed;
       
   303 		TBool                       iObjectSize;                // Byte size of the referenced security object
       
   304         TBool                       iEncrypted;                 // Only used for passing aEncrypted parameter from client to server
       
   305 		TBuf<SHORT_FILENAME_LENGTH> iObjectName;
       
   306 		TBool                       iObjectNameUsed;    
       
   307 		TBool                       iIsDeletable;                //
       
   308 		TBool                       iIsDeletableUsed;
       
   309 };
       
   310 
       
   311 #endif // PKI_SERVICE_CLIENT_SERVER_COMMON_H