First public contribution.
2 * Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
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".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
19 #ifndef __FSMARSHALLER_H__
20 #define __FSMARSHALLER_H__
24 #include <ct/rmpointerarray.h>
30 * Marshalling and unmarshalling utils for the filetokens server This is used by
31 * both client and server dlls.
41 class CPBEncryptParms;
50 class TCertificateAppInfo;
51 class CCertAttributeFilter;
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*) \
57 return Externalize::Function(); \
60 // Serialization for bigints, used in server
63 * Maximum size of integer to decode - keys are limited to 2048 bits, so nothing
64 * we pass around should be bigger than this.
66 const TInt KMaxIntegerSize = 256;
69 * Maximum size in bytes of serialised representations, given the limit on key
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
77 // enum for handling panics
79 enum KTokenMarshallerPanics
85 EXTERNALIZE_FUNCTION(TInteger)
86 IMPORT_C void ExternalizeL(const TInteger& aIn, RWriteStream& aOut);
87 IMPORT_C void CreateLC(RReadStream& aIn, RInteger& aOut);
89 /** Marshals data over the IPC boundary between filetokens client and server. */
90 class TokenDataMarshaller
94 IMPORT_C static void ReadL(const TDesC8& aIn, RArray<TUid>& aOut);
96 IMPORT_C static TInt Size(const CKeyInfoBase& aIn);
97 IMPORT_C static void Write(const CKeyInfoBase& aIn, TDes8& aOut);
99 IMPORT_C static TInt Size(const RArray<TUid>& aIn);
100 IMPORT_C static void Write(const RArray<TUid>& aIn, TDes8& aOut);
102 IMPORT_C static TInt Size(const MCertInfo& aIn);
103 IMPORT_C static void Write(const MCertInfo& aIn, TDes8& aOut);
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);
110 IMPORT_C static void ReadL(const TDesC8& aIn, CDSASignature*& aOut);
111 IMPORT_C static void ReadL(const TDesC8& aIn, CRSASignature*& aOut);
113 IMPORT_C static TInt Size(const CPBEncryptParms& aIn);
114 IMPORT_C static void Write(const CPBEncryptParms& aIn, TDes8& aOut);
116 IMPORT_C static TInt Size(const CDHParams& aIn);
117 IMPORT_C static void WriteL(const CDHParams& aIn, TDes8& aOut);
119 IMPORT_C static TInt Size(const CDHPublicKey& aIn);
120 IMPORT_C static void WriteL(const CDHPublicKey& aIn, TDes8& aOut);
122 IMPORT_C static void ReadL(const TDesC8& aIn, RInteger& aInteger);
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);
127 IMPORT_C static void ReadL(const TDesC8& aIn, RArray<TCertificateAppInfo>& aOut);
129 IMPORT_C static TInt Size(const CCertAttributeFilter& aIn);
130 IMPORT_C static void WriteL(const CCertAttributeFilter& aIn, TDes8& aOut);
134 IMPORT_C static void ReadL(const TDesC8& aIn, CKeyInfo*& aOut);
136 IMPORT_C static void ReadL(const TDesC8& aIn, CPBEncryptParms*& aOut);
138 IMPORT_C static TInt Size(const RPointerArray<CKeyInfo>& aIn);
139 IMPORT_C static void Write(const RPointerArray<CKeyInfo>& aIn, TDes8& aOut);
141 IMPORT_C static TInt Size(const CDSASignature& aIn);
142 IMPORT_C static void WriteL(const CDSASignature& aIn, TDes8& aOut);
144 IMPORT_C static TInt Size(const CRSASignature& aIn);
145 IMPORT_C static void WriteL(const CRSASignature& aIn, TDes8& aOut);
147 IMPORT_C static void ReadL(const TDesC8& aIn, CDHParams*& aOut);
148 IMPORT_C static void ReadL(const TDesC8& aIn, CDHPublicKey*& aOut);
150 IMPORT_C static TInt Size(const TInteger& aIn);
151 IMPORT_C static void WriteL(const TInteger& aIn, TDes8& aOut);
153 IMPORT_C static void ReadL(const TDesC8& aIn, CCertInfo*& aOut);
155 IMPORT_C static TInt Size(const RPointerArray<CCertInfo>& aIn);
156 IMPORT_C static void Write(const RPointerArray<CCertInfo>& aIn, TDes8& aOut);
158 IMPORT_C static TInt Size(const RArray<TCertificateAppInfo>& aIn);
159 IMPORT_C static void Write(const RArray<TCertificateAppInfo>& aIn, TDes8& aOut);
161 IMPORT_C static void ReadL(const TDesC8& aIn, CCertAttributeFilter*& aOut);