os/security/cryptoservices/filebasedcertificateandkeystores/Inc/fsmarshaller.h
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/security/cryptoservices/filebasedcertificateandkeystores/Inc/fsmarshaller.h	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,164 @@
     1.4 +/*
     1.5 +* Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.6 +* All rights reserved.
     1.7 +* This component and the accompanying materials are made available
     1.8 +* under the terms of the License "Eclipse Public License v1.0"
     1.9 +* which accompanies this distribution, and is available
    1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.11 +*
    1.12 +* Initial Contributors:
    1.13 +* Nokia Corporation - initial contribution.
    1.14 +*
    1.15 +* Contributors:
    1.16 +*
    1.17 +* Description: 
    1.18 +*
    1.19 +*/
    1.20 +
    1.21 +
    1.22 +#ifndef __FSMARSHALLER_H__
    1.23 +#define __FSMARSHALLER_H__
    1.24 +
    1.25 +#include <e32std.h>
    1.26 +#include <s32strm.h>
    1.27 +#include <ct/rmpointerarray.h>
    1.28 +
    1.29 +/**
    1.30 + * @file
    1.31 + * @internalComponent
    1.32 + *
    1.33 + * Marshalling and unmarshalling utils for the filetokens server This is used by
    1.34 + * both client and server dlls.
    1.35 + */
    1.36 +
    1.37 +class MCTToken;
    1.38 +class CKeyInfoBase;
    1.39 +class CCTKeyInfo;
    1.40 +class CKeyInfo;
    1.41 +class MKeyInfoArray;
    1.42 +class CDSASignature;
    1.43 +class CRSASignature;
    1.44 +class CPBEncryptParms;
    1.45 +struct TDHParams;
    1.46 +class CDHParams;
    1.47 +class CDHPublicKey;
    1.48 +class TInteger;
    1.49 +class RInteger;
    1.50 +class MCertInfo;
    1.51 +class CCTCertInfo;
    1.52 +class CCertInfo;
    1.53 +class TCertificateAppInfo;
    1.54 +class CCertAttributeFilter;
    1.55 +
    1.56 +/// A macro that marks a type as externalized by a global function
    1.57 +#define EXTERNALIZE_FUNCTION(TYPE) \
    1.58 +inline Externalize::Function Externalization(const TYPE*) \
    1.59 +	{ \
    1.60 +	return Externalize::Function(); \
    1.61 +	}
    1.62 +
    1.63 +// Serialization for bigints, used in server
    1.64 + 
    1.65 +/**
    1.66 + * Maximum size of integer to decode - keys are limited to 2048 bits, so nothing
    1.67 + * we pass around should be bigger than this.
    1.68 + */
    1.69 +const TInt KMaxIntegerSize = 256;
    1.70 +
    1.71 +/**
    1.72 + * Maximum size in bytes of serialised representations, given the limit on key
    1.73 + * size.
    1.74 + */
    1.75 +const TInt KMaxDSASignatureSize = 48;	// Two 160 bit integers
    1.76 +const TInt KMaxRSASignatureSize = 516;	// One 4096 bit integer
    1.77 +const TInt KMaxRSAPlaintextSize = 516;	// One 4096 bit integer
    1.78 +const TInt KMaxDHAgreedKeySize = 516;	// One 4096 bit integer
    1.79 +
    1.80 +// enum for handling panics
    1.81 +
    1.82 +enum KTokenMarshallerPanics
    1.83 +	{ 
    1.84 +	ESerialisationPanic
    1.85 +	};
    1.86 +
    1.87 +
    1.88 +EXTERNALIZE_FUNCTION(TInteger)
    1.89 +IMPORT_C void ExternalizeL(const TInteger& aIn, RWriteStream& aOut);
    1.90 +IMPORT_C void CreateLC(RReadStream& aIn, RInteger& aOut);
    1.91 +
    1.92 +/**	Marshals data over the IPC boundary between filetokens client and server. */
    1.93 +class TokenDataMarshaller
    1.94 +	{
    1.95 +	// Common
    1.96 +public:
    1.97 +	IMPORT_C static void ReadL(const TDesC8& aIn, RArray<TUid>& aOut);
    1.98 +
    1.99 +	IMPORT_C static TInt Size(const CKeyInfoBase& aIn);
   1.100 +	IMPORT_C static void Write(const CKeyInfoBase& aIn, TDes8& aOut);
   1.101 +
   1.102 +	IMPORT_C static TInt Size(const RArray<TUid>& aIn);
   1.103 +	IMPORT_C static void Write(const RArray<TUid>& aIn, TDes8& aOut);
   1.104 +
   1.105 +	IMPORT_C static TInt Size(const MCertInfo& aIn);
   1.106 +	IMPORT_C static void Write(const MCertInfo& aIn, TDes8& aOut);
   1.107 +
   1.108 +	// Used by client 
   1.109 +public:	
   1.110 +	IMPORT_C static void ReadL(const TDesC8& aIn, MCTToken& aToken, MKeyInfoArray& aOut);
   1.111 +	IMPORT_C static void ReadL(const TDesC8& aIn, MCTToken& aToken, CCTKeyInfo*& aOut);
   1.112 +
   1.113 +	IMPORT_C static void ReadL(const TDesC8& aIn, CDSASignature*& aOut);
   1.114 +	IMPORT_C static void ReadL(const TDesC8& aIn, CRSASignature*& aOut);
   1.115 +
   1.116 +	IMPORT_C static TInt Size(const CPBEncryptParms& aIn);	
   1.117 +	IMPORT_C static void Write(const CPBEncryptParms& aIn,  TDes8& aOut);
   1.118 +
   1.119 +	IMPORT_C static TInt Size(const CDHParams& aIn);
   1.120 +	IMPORT_C static void WriteL(const CDHParams& aIn, TDes8& aOut);
   1.121 +
   1.122 +	IMPORT_C static TInt Size(const CDHPublicKey& aIn);
   1.123 +	IMPORT_C static void WriteL(const CDHPublicKey& aIn, TDes8& aOut);
   1.124 +
   1.125 +	IMPORT_C static void ReadL(const TDesC8& aIn, RInteger& aInteger);
   1.126 +
   1.127 +	IMPORT_C static void ReadL(const TDesC8& aIn, MCTToken& aToken, RMPointerArray<CCTCertInfo>& aOut);
   1.128 +	IMPORT_C static void ReadL(const TDesC8& aIn, MCTToken& aToken, CCTCertInfo*& aOut);
   1.129 +
   1.130 +	IMPORT_C static void ReadL(const TDesC8& aIn, RArray<TCertificateAppInfo>& aOut);
   1.131 +
   1.132 +	IMPORT_C static TInt Size(const CCertAttributeFilter& aIn);
   1.133 +	IMPORT_C static void WriteL(const CCertAttributeFilter& aIn, TDes8& aOut);
   1.134 +	
   1.135 +	// Used by server
   1.136 +public:
   1.137 +	IMPORT_C static void ReadL(const TDesC8& aIn, CKeyInfo*& aOut);
   1.138 +
   1.139 +	IMPORT_C static void ReadL(const TDesC8& aIn, CPBEncryptParms*& aOut);
   1.140 +
   1.141 +	IMPORT_C static TInt Size(const RPointerArray<CKeyInfo>& aIn);
   1.142 +	IMPORT_C static void Write(const RPointerArray<CKeyInfo>& aIn, TDes8& aOut);
   1.143 +	
   1.144 +	IMPORT_C static TInt Size(const CDSASignature& aIn);
   1.145 +	IMPORT_C static void WriteL(const CDSASignature& aIn, TDes8& aOut);
   1.146 +
   1.147 +	IMPORT_C static TInt Size(const CRSASignature& aIn);
   1.148 +	IMPORT_C static void WriteL(const CRSASignature& aIn, TDes8& aOut);
   1.149 +
   1.150 +	IMPORT_C static void ReadL(const TDesC8& aIn, CDHParams*& aOut);
   1.151 +	IMPORT_C static void ReadL(const TDesC8& aIn, CDHPublicKey*& aOut);
   1.152 +	
   1.153 +	IMPORT_C static TInt Size(const TInteger& aIn);
   1.154 +	IMPORT_C static void WriteL(const TInteger& aIn, TDes8& aOut);
   1.155 +
   1.156 +	IMPORT_C static void ReadL(const TDesC8& aIn, CCertInfo*& aOut);
   1.157 +
   1.158 +	IMPORT_C static TInt Size(const RPointerArray<CCertInfo>& aIn);
   1.159 +	IMPORT_C static void Write(const RPointerArray<CCertInfo>& aIn, TDes8& aOut);
   1.160 +
   1.161 +	IMPORT_C static TInt Size(const RArray<TCertificateAppInfo>& aIn);   
   1.162 +	IMPORT_C static void Write(const RArray<TCertificateAppInfo>& aIn, TDes8& aOut);
   1.163 +
   1.164 +	IMPORT_C static void ReadL(const TDesC8& aIn, CCertAttributeFilter*& aOut);
   1.165 +	};
   1.166 +
   1.167 +#endif