os/security/cryptoservices/filebasedcertificateandkeystores/Inc/fsmarshaller.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 /*
     2 * Copyright (c) 2004-2009 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 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".
     8 *
     9 * Initial Contributors:
    10 * Nokia Corporation - initial contribution.
    11 *
    12 * Contributors:
    13 *
    14 * Description: 
    15 *
    16 */
    17 
    18 
    19 #ifndef __FSMARSHALLER_H__
    20 #define __FSMARSHALLER_H__
    21 
    22 #include <e32std.h>
    23 #include <s32strm.h>
    24 #include <ct/rmpointerarray.h>
    25 
    26 /**
    27  * @file
    28  * @internalComponent
    29  *
    30  * Marshalling and unmarshalling utils for the filetokens server This is used by
    31  * both client and server dlls.
    32  */
    33 
    34 class MCTToken;
    35 class CKeyInfoBase;
    36 class CCTKeyInfo;
    37 class CKeyInfo;
    38 class MKeyInfoArray;
    39 class CDSASignature;
    40 class CRSASignature;
    41 class CPBEncryptParms;
    42 struct TDHParams;
    43 class CDHParams;
    44 class CDHPublicKey;
    45 class TInteger;
    46 class RInteger;
    47 class MCertInfo;
    48 class CCTCertInfo;
    49 class CCertInfo;
    50 class TCertificateAppInfo;
    51 class CCertAttributeFilter;
    52 
    53 /// A macro that marks a type as externalized by a global function
    54 #define EXTERNALIZE_FUNCTION(TYPE) \
    55 inline Externalize::Function Externalization(const TYPE*) \
    56 	{ \
    57 	return Externalize::Function(); \
    58 	}
    59 
    60 // Serialization for bigints, used in server
    61  
    62 /**
    63  * Maximum size of integer to decode - keys are limited to 2048 bits, so nothing
    64  * we pass around should be bigger than this.
    65  */
    66 const TInt KMaxIntegerSize = 256;
    67 
    68 /**
    69  * Maximum size in bytes of serialised representations, given the limit on key
    70  * size.
    71  */
    72 const TInt KMaxDSASignatureSize = 48;	// Two 160 bit integers
    73 const TInt KMaxRSASignatureSize = 516;	// One 4096 bit integer
    74 const TInt KMaxRSAPlaintextSize = 516;	// One 4096 bit integer
    75 const TInt KMaxDHAgreedKeySize = 516;	// One 4096 bit integer
    76 
    77 // enum for handling panics
    78 
    79 enum KTokenMarshallerPanics
    80 	{ 
    81 	ESerialisationPanic
    82 	};
    83 
    84 
    85 EXTERNALIZE_FUNCTION(TInteger)
    86 IMPORT_C void ExternalizeL(const TInteger& aIn, RWriteStream& aOut);
    87 IMPORT_C void CreateLC(RReadStream& aIn, RInteger& aOut);
    88 
    89 /**	Marshals data over the IPC boundary between filetokens client and server. */
    90 class TokenDataMarshaller
    91 	{
    92 	// Common
    93 public:
    94 	IMPORT_C static void ReadL(const TDesC8& aIn, RArray<TUid>& aOut);
    95 
    96 	IMPORT_C static TInt Size(const CKeyInfoBase& aIn);
    97 	IMPORT_C static void Write(const CKeyInfoBase& aIn, TDes8& aOut);
    98 
    99 	IMPORT_C static TInt Size(const RArray<TUid>& aIn);
   100 	IMPORT_C static void Write(const RArray<TUid>& aIn, TDes8& aOut);
   101 
   102 	IMPORT_C static TInt Size(const MCertInfo& aIn);
   103 	IMPORT_C static void Write(const MCertInfo& aIn, TDes8& aOut);
   104 
   105 	// Used by client 
   106 public:	
   107 	IMPORT_C static void ReadL(const TDesC8& aIn, MCTToken& aToken, MKeyInfoArray& aOut);
   108 	IMPORT_C static void ReadL(const TDesC8& aIn, MCTToken& aToken, CCTKeyInfo*& aOut);
   109 
   110 	IMPORT_C static void ReadL(const TDesC8& aIn, CDSASignature*& aOut);
   111 	IMPORT_C static void ReadL(const TDesC8& aIn, CRSASignature*& aOut);
   112 
   113 	IMPORT_C static TInt Size(const CPBEncryptParms& aIn);	
   114 	IMPORT_C static void Write(const CPBEncryptParms& aIn,  TDes8& aOut);
   115 
   116 	IMPORT_C static TInt Size(const CDHParams& aIn);
   117 	IMPORT_C static void WriteL(const CDHParams& aIn, TDes8& aOut);
   118 
   119 	IMPORT_C static TInt Size(const CDHPublicKey& aIn);
   120 	IMPORT_C static void WriteL(const CDHPublicKey& aIn, TDes8& aOut);
   121 
   122 	IMPORT_C static void ReadL(const TDesC8& aIn, RInteger& aInteger);
   123 
   124 	IMPORT_C static void ReadL(const TDesC8& aIn, MCTToken& aToken, RMPointerArray<CCTCertInfo>& aOut);
   125 	IMPORT_C static void ReadL(const TDesC8& aIn, MCTToken& aToken, CCTCertInfo*& aOut);
   126 
   127 	IMPORT_C static void ReadL(const TDesC8& aIn, RArray<TCertificateAppInfo>& aOut);
   128 
   129 	IMPORT_C static TInt Size(const CCertAttributeFilter& aIn);
   130 	IMPORT_C static void WriteL(const CCertAttributeFilter& aIn, TDes8& aOut);
   131 	
   132 	// Used by server
   133 public:
   134 	IMPORT_C static void ReadL(const TDesC8& aIn, CKeyInfo*& aOut);
   135 
   136 	IMPORT_C static void ReadL(const TDesC8& aIn, CPBEncryptParms*& aOut);
   137 
   138 	IMPORT_C static TInt Size(const RPointerArray<CKeyInfo>& aIn);
   139 	IMPORT_C static void Write(const RPointerArray<CKeyInfo>& aIn, TDes8& aOut);
   140 	
   141 	IMPORT_C static TInt Size(const CDSASignature& aIn);
   142 	IMPORT_C static void WriteL(const CDSASignature& aIn, TDes8& aOut);
   143 
   144 	IMPORT_C static TInt Size(const CRSASignature& aIn);
   145 	IMPORT_C static void WriteL(const CRSASignature& aIn, TDes8& aOut);
   146 
   147 	IMPORT_C static void ReadL(const TDesC8& aIn, CDHParams*& aOut);
   148 	IMPORT_C static void ReadL(const TDesC8& aIn, CDHPublicKey*& aOut);
   149 	
   150 	IMPORT_C static TInt Size(const TInteger& aIn);
   151 	IMPORT_C static void WriteL(const TInteger& aIn, TDes8& aOut);
   152 
   153 	IMPORT_C static void ReadL(const TDesC8& aIn, CCertInfo*& aOut);
   154 
   155 	IMPORT_C static TInt Size(const RPointerArray<CCertInfo>& aIn);
   156 	IMPORT_C static void Write(const RPointerArray<CCertInfo>& aIn, TDes8& aOut);
   157 
   158 	IMPORT_C static TInt Size(const RArray<TCertificateAppInfo>& aIn);   
   159 	IMPORT_C static void Write(const RArray<TCertificateAppInfo>& aIn, TDes8& aOut);
   160 
   161 	IMPORT_C static void ReadL(const TDesC8& aIn, CCertAttributeFilter*& aOut);
   162 	};
   163 
   164 #endif