sl@0: /* sl@0: * Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: * All rights reserved. sl@0: * This component and the accompanying materials are made available sl@0: * under the terms of the License "Eclipse Public License v1.0" sl@0: * which accompanies this distribution, and is available sl@0: * at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: * sl@0: * Initial Contributors: sl@0: * Nokia Corporation - initial contribution. sl@0: * sl@0: * Contributors: sl@0: * sl@0: * Description: sl@0: * sl@0: */ sl@0: sl@0: sl@0: #ifndef __FSMARSHALLER_H__ sl@0: #define __FSMARSHALLER_H__ sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: sl@0: /** sl@0: * @file sl@0: * @internalComponent sl@0: * sl@0: * Marshalling and unmarshalling utils for the filetokens server This is used by sl@0: * both client and server dlls. sl@0: */ sl@0: sl@0: class MCTToken; sl@0: class CKeyInfoBase; sl@0: class CCTKeyInfo; sl@0: class CKeyInfo; sl@0: class MKeyInfoArray; sl@0: class CDSASignature; sl@0: class CRSASignature; sl@0: class CPBEncryptParms; sl@0: struct TDHParams; sl@0: class CDHParams; sl@0: class CDHPublicKey; sl@0: class TInteger; sl@0: class RInteger; sl@0: class MCertInfo; sl@0: class CCTCertInfo; sl@0: class CCertInfo; sl@0: class TCertificateAppInfo; sl@0: class CCertAttributeFilter; sl@0: sl@0: /// A macro that marks a type as externalized by a global function sl@0: #define EXTERNALIZE_FUNCTION(TYPE) \ sl@0: inline Externalize::Function Externalization(const TYPE*) \ sl@0: { \ sl@0: return Externalize::Function(); \ sl@0: } sl@0: sl@0: // Serialization for bigints, used in server sl@0: sl@0: /** sl@0: * Maximum size of integer to decode - keys are limited to 2048 bits, so nothing sl@0: * we pass around should be bigger than this. sl@0: */ sl@0: const TInt KMaxIntegerSize = 256; sl@0: sl@0: /** sl@0: * Maximum size in bytes of serialised representations, given the limit on key sl@0: * size. sl@0: */ sl@0: const TInt KMaxDSASignatureSize = 48; // Two 160 bit integers sl@0: const TInt KMaxRSASignatureSize = 516; // One 4096 bit integer sl@0: const TInt KMaxRSAPlaintextSize = 516; // One 4096 bit integer sl@0: const TInt KMaxDHAgreedKeySize = 516; // One 4096 bit integer sl@0: sl@0: // enum for handling panics sl@0: sl@0: enum KTokenMarshallerPanics sl@0: { sl@0: ESerialisationPanic sl@0: }; sl@0: sl@0: sl@0: EXTERNALIZE_FUNCTION(TInteger) sl@0: IMPORT_C void ExternalizeL(const TInteger& aIn, RWriteStream& aOut); sl@0: IMPORT_C void CreateLC(RReadStream& aIn, RInteger& aOut); sl@0: sl@0: /** Marshals data over the IPC boundary between filetokens client and server. */ sl@0: class TokenDataMarshaller sl@0: { sl@0: // Common sl@0: public: sl@0: IMPORT_C static void ReadL(const TDesC8& aIn, RArray& aOut); sl@0: sl@0: IMPORT_C static TInt Size(const CKeyInfoBase& aIn); sl@0: IMPORT_C static void Write(const CKeyInfoBase& aIn, TDes8& aOut); sl@0: sl@0: IMPORT_C static TInt Size(const RArray& aIn); sl@0: IMPORT_C static void Write(const RArray& aIn, TDes8& aOut); sl@0: sl@0: IMPORT_C static TInt Size(const MCertInfo& aIn); sl@0: IMPORT_C static void Write(const MCertInfo& aIn, TDes8& aOut); sl@0: sl@0: // Used by client sl@0: public: sl@0: IMPORT_C static void ReadL(const TDesC8& aIn, MCTToken& aToken, MKeyInfoArray& aOut); sl@0: IMPORT_C static void ReadL(const TDesC8& aIn, MCTToken& aToken, CCTKeyInfo*& aOut); sl@0: sl@0: IMPORT_C static void ReadL(const TDesC8& aIn, CDSASignature*& aOut); sl@0: IMPORT_C static void ReadL(const TDesC8& aIn, CRSASignature*& aOut); sl@0: sl@0: IMPORT_C static TInt Size(const CPBEncryptParms& aIn); sl@0: IMPORT_C static void Write(const CPBEncryptParms& aIn, TDes8& aOut); sl@0: sl@0: IMPORT_C static TInt Size(const CDHParams& aIn); sl@0: IMPORT_C static void WriteL(const CDHParams& aIn, TDes8& aOut); sl@0: sl@0: IMPORT_C static TInt Size(const CDHPublicKey& aIn); sl@0: IMPORT_C static void WriteL(const CDHPublicKey& aIn, TDes8& aOut); sl@0: sl@0: IMPORT_C static void ReadL(const TDesC8& aIn, RInteger& aInteger); sl@0: sl@0: IMPORT_C static void ReadL(const TDesC8& aIn, MCTToken& aToken, RMPointerArray& aOut); sl@0: IMPORT_C static void ReadL(const TDesC8& aIn, MCTToken& aToken, CCTCertInfo*& aOut); sl@0: sl@0: IMPORT_C static void ReadL(const TDesC8& aIn, RArray& aOut); sl@0: sl@0: IMPORT_C static TInt Size(const CCertAttributeFilter& aIn); sl@0: IMPORT_C static void WriteL(const CCertAttributeFilter& aIn, TDes8& aOut); sl@0: sl@0: // Used by server sl@0: public: sl@0: IMPORT_C static void ReadL(const TDesC8& aIn, CKeyInfo*& aOut); sl@0: sl@0: IMPORT_C static void ReadL(const TDesC8& aIn, CPBEncryptParms*& aOut); sl@0: sl@0: IMPORT_C static TInt Size(const RPointerArray& aIn); sl@0: IMPORT_C static void Write(const RPointerArray& aIn, TDes8& aOut); sl@0: sl@0: IMPORT_C static TInt Size(const CDSASignature& aIn); sl@0: IMPORT_C static void WriteL(const CDSASignature& aIn, TDes8& aOut); sl@0: sl@0: IMPORT_C static TInt Size(const CRSASignature& aIn); sl@0: IMPORT_C static void WriteL(const CRSASignature& aIn, TDes8& aOut); sl@0: sl@0: IMPORT_C static void ReadL(const TDesC8& aIn, CDHParams*& aOut); sl@0: IMPORT_C static void ReadL(const TDesC8& aIn, CDHPublicKey*& aOut); sl@0: sl@0: IMPORT_C static TInt Size(const TInteger& aIn); sl@0: IMPORT_C static void WriteL(const TInteger& aIn, TDes8& aOut); sl@0: sl@0: IMPORT_C static void ReadL(const TDesC8& aIn, CCertInfo*& aOut); sl@0: sl@0: IMPORT_C static TInt Size(const RPointerArray& aIn); sl@0: IMPORT_C static void Write(const RPointerArray& aIn, TDes8& aOut); sl@0: sl@0: IMPORT_C static TInt Size(const RArray& aIn); sl@0: IMPORT_C static void Write(const RArray& aIn, TDes8& aOut); sl@0: sl@0: IMPORT_C static void ReadL(const TDesC8& aIn, CCertAttributeFilter*& aOut); sl@0: }; sl@0: sl@0: #endif