|
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 DevTokenMarshaller |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef __DEVTOKENMARSHALLER_H__ |
|
21 #define __DEVTOKENMARSHALLER_H__ |
|
22 |
|
23 #include <e32std.h> |
|
24 #include <s32strm.h> |
|
25 #include <ct/rmpointerarray.h> |
|
26 |
|
27 /** |
|
28 * Marshalling and unmarshalling utils for the filetokens server This is used by |
|
29 * both client and server dlls. |
|
30 */ |
|
31 |
|
32 class MCTToken; |
|
33 class CKeyInfoBase; |
|
34 class CCTKeyInfo; |
|
35 class CDevTokenKeyInfo; |
|
36 class MDevTokenKeyInfoArray; |
|
37 class CDSASignature; |
|
38 class CRSASignature; |
|
39 struct TDHParams; |
|
40 class CDevTokenDHParams; |
|
41 class CDHPublicKey; |
|
42 class TInteger; |
|
43 class RInteger; |
|
44 class MCertInfo; |
|
45 class CCTCertInfo; |
|
46 class CDevTokenCertInfo; |
|
47 class TCertificateAppInfo; |
|
48 class CCertAttributeFilter; |
|
49 class MKeyEncryptor; |
|
50 |
|
51 // A macro that marks a type as externalized by a global function |
|
52 #define EXTERNALIZE_FUNCTION(TYPE) \ |
|
53 inline Externalize::Function Externalization(const TYPE*) \ |
|
54 { \ |
|
55 return Externalize::Function(); \ |
|
56 } |
|
57 |
|
58 // Serialization for bigints, used in server |
|
59 |
|
60 // Maximum size of integer to decode - keys are limited to 2048 bits, so nothing |
|
61 // we pass around should be bigger than this. |
|
62 |
|
63 // Add 48 bytes on top of 256 bytes ( 2048 bits ) for |
|
64 // Size of info data which is added to encrypt output. |
|
65 // padding 16 bytes + salt 32 bytes = 48. |
|
66 const TInt KMaxIntegerSize = 304; |
|
67 const TInt KMaxSiteName = 100; |
|
68 |
|
69 // Maximum size in bytes of serialised representations, given the limit on key |
|
70 // size. |
|
71 const TInt KMaxDSASignatureSize = 48; // Two 160 bit integers |
|
72 const TInt KMaxRSASignatureSize = 516; // One 4096 bit integer |
|
73 const TInt KMaxRSAPlaintextSize = 516; // One 4096 bit integer |
|
74 const TInt KMaxDHAgreedKeySize = 516; // One 4096 bit integer |
|
75 |
|
76 // enum for handling panics |
|
77 enum KTokenMarshallerPanics |
|
78 { |
|
79 ESerialisationPanic |
|
80 }; |
|
81 |
|
82 |
|
83 EXTERNALIZE_FUNCTION(TInteger) |
|
84 |
|
85 IMPORT_C void ExternalizeL(const TInteger& aIn, RWriteStream& aOut); |
|
86 |
|
87 IMPORT_C void CreateLC(RReadStream& aIn, RInteger& aOut); |
|
88 |
|
89 /** |
|
90 * Decrypted the content and create the object. |
|
91 * |
|
92 * @lib DevTokenShared.dll |
|
93 * @since S60 v3.2 |
|
94 */ |
|
95 IMPORT_C void DecryptAndCreateLC(RReadStream& aIn, RInteger& aOut, MKeyEncryptor* aEncryptor); |
|
96 |
|
97 /** |
|
98 * encrypted the content and store. |
|
99 * |
|
100 * @lib DevTokenShared.dll |
|
101 * @since S60 v3.2 |
|
102 */ |
|
103 |
|
104 IMPORT_C void EncryptAndStoreL(const TInteger& aIn, RWriteStream& aOut, MKeyEncryptor* aEncryptor ); |
|
105 |
|
106 |
|
107 /** |
|
108 * Marshals data over the IPC boundary between filetokens client and server. |
|
109 * |
|
110 * @lib DevTokenShared.dll |
|
111 * @since S60 v3.2 |
|
112 */ |
|
113 class DevTokenDataMarshaller |
|
114 { |
|
115 // Common |
|
116 public: |
|
117 IMPORT_C static void ReadL(const TDesC8& aIn, RArray<TUid>& aOut); |
|
118 |
|
119 IMPORT_C static TInt Size(const CKeyInfoBase& aIn); |
|
120 |
|
121 IMPORT_C static void Write(const CKeyInfoBase& aIn, TDes8& aOut); |
|
122 |
|
123 IMPORT_C static TInt Size(const RArray<TUid>& aIn); |
|
124 |
|
125 IMPORT_C static void Write(const RArray<TUid>& aIn, TDes8& aOut); |
|
126 |
|
127 IMPORT_C static TInt Size(const MCertInfo& aIn); |
|
128 |
|
129 IMPORT_C static void Write(const MCertInfo& aIn, TDes8& aOut); |
|
130 |
|
131 // Used by client |
|
132 public: |
|
133 |
|
134 IMPORT_C static void ReadL(const TDesC8& aIn, MCTToken& aToken, MDevTokenKeyInfoArray& aOut); |
|
135 |
|
136 IMPORT_C static void ReadL(const TDesC8& aIn, MCTToken& aToken, CCTKeyInfo*& aOut); |
|
137 |
|
138 IMPORT_C static void ReadL(const TDesC8& aIn, CDSASignature*& aOut); |
|
139 |
|
140 IMPORT_C static void ReadL(const TDesC8& aIn, CRSASignature*& aOut); |
|
141 |
|
142 IMPORT_C static TInt Size(const CDevTokenDHParams& aIn); |
|
143 |
|
144 IMPORT_C static void WriteL(const CDevTokenDHParams& aIn, TDes8& aOut); |
|
145 |
|
146 IMPORT_C static TInt Size(const CDHPublicKey& aIn); |
|
147 |
|
148 IMPORT_C static void WriteL(const CDHPublicKey& aIn, TDes8& aOut); |
|
149 |
|
150 IMPORT_C static void ReadL(const TDesC8& aIn, RInteger& aInteger); |
|
151 |
|
152 IMPORT_C static void ReadL(const TDesC8& aIn, MCTToken& aToken, RMPointerArray<CCTCertInfo>& aOut); |
|
153 |
|
154 IMPORT_C static void ReadL(const TDesC8& aIn, MCTToken& aToken, CCTCertInfo*& aOut); |
|
155 |
|
156 IMPORT_C static void ReadL(const TDesC8& aIn, RArray<TCertificateAppInfo>& aOut); |
|
157 |
|
158 IMPORT_C static TInt Size(const CCertAttributeFilter& aIn); |
|
159 |
|
160 IMPORT_C static void WriteL(const CCertAttributeFilter& aIn, TDes8& aOut); |
|
161 |
|
162 IMPORT_C static void ReadL(const TDesC8& aIn, RPointerArray<HBufC>& aOut); |
|
163 |
|
164 IMPORT_C static TInt Size(const RPointerArray<HBufC>& aIn); |
|
165 |
|
166 IMPORT_C static void Write(const RPointerArray<HBufC>& aIn, TDes8& aOut ); |
|
167 |
|
168 // Used by server |
|
169 public: |
|
170 |
|
171 IMPORT_C static void ReadL(const TDesC8& aIn, CDevTokenKeyInfo*& aOut); |
|
172 |
|
173 IMPORT_C static TInt Size(const RPointerArray<CDevTokenKeyInfo>& aIn); |
|
174 |
|
175 IMPORT_C static void Write(const RPointerArray<CDevTokenKeyInfo>& aIn, TDes8& aOut); |
|
176 |
|
177 IMPORT_C static TInt Size(const CDSASignature& aIn); |
|
178 |
|
179 IMPORT_C static void WriteL(const CDSASignature& aIn, TDes8& aOut); |
|
180 |
|
181 IMPORT_C static TInt Size(const CRSASignature& aIn); |
|
182 |
|
183 IMPORT_C static void WriteL(const CRSASignature& aIn, TDes8& aOut); |
|
184 |
|
185 IMPORT_C static void ReadL(const TDesC8& aIn, CDevTokenDHParams*& aOut); |
|
186 |
|
187 IMPORT_C static void ReadL(const TDesC8& aIn, CDHPublicKey*& aOut); |
|
188 |
|
189 IMPORT_C static TInt Size(const TInteger& aIn); |
|
190 |
|
191 IMPORT_C static void WriteL(const TInteger& aIn, TDes8& aOut); |
|
192 |
|
193 IMPORT_C static void ReadL(const TDesC8& aIn, CDevTokenCertInfo*& aOut); |
|
194 |
|
195 IMPORT_C static TInt Size(const RPointerArray<CDevTokenCertInfo>& aIn); |
|
196 |
|
197 IMPORT_C static void Write(const RPointerArray<CDevTokenCertInfo>& aIn, TDes8& aOut); |
|
198 |
|
199 IMPORT_C static TInt Size(const RArray<TCertificateAppInfo>& aIn); |
|
200 |
|
201 IMPORT_C static void Write(const RArray<TCertificateAppInfo>& aIn, TDes8& aOut); |
|
202 |
|
203 IMPORT_C static void ReadL(const TDesC8& aIn, CCertAttributeFilter*& aOut); |
|
204 }; |
|
205 |
|
206 #endif //__DEVTOKENMARSHALLER_H__ |
|
207 |
|
208 //EOF |
|
209 |