epoc32/include/cryptospi/cryptoparams.h
branchSymbian3
changeset 4 837f303aceeb
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/epoc32/include/cryptospi/cryptoparams.h	Wed Mar 31 12:33:34 2010 +0100
     1.3 @@ -0,0 +1,395 @@
     1.4 +/*
     1.5 +* Copyright (c) 2006-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 +* crypto parameters interface
    1.19 +*
    1.20 +*/
    1.21 +
    1.22 +
    1.23 +/**
    1.24 + @file
    1.25 + @publishedAll
    1.26 + @released 
    1.27 +*/
    1.28 +
    1.29 +#ifndef __CRYPTOPARAMS_H__
    1.30 +#define __CRYPTOPARAMS_H__
    1.31 +
    1.32 +#include <bigint.h>
    1.33 +
    1.34 +namespace CryptoSpi
    1.35 +	{
    1.36 +	/**
    1.37 +	Abstract base class for generic crypto parameters to enable plug-in 
    1.38 +	specific parameters and the externalisation of plug-ins. The type
    1.39 +	of the sub-class is identified by the GetType method.
    1.40 +
    1.41 +	All sub-class contain copies of (instead of references to) the 
    1.42 +	supplied values.
    1.43 +	*/
    1.44 +	NONSHARABLE_CLASS(CCryptoParam) : public CBase
    1.45 +		{
    1.46 +	public:
    1.47 +
    1.48 +		/**
    1.49 +		The definition of the data type of the embedded value. 
    1.50 +		Other data types may be added in future so applications 
    1.51 +		should not panic if the type is not recognised.
    1.52 +		*/
    1.53 +		enum TParamType
    1.54 +			{
    1.55 +			/** 
    1.56 +			RCryptoIntParam 
    1.57 +			*/
    1.58 +			EInt = 1,
    1.59 +			/** 
    1.60 +			RCryptoBigIntParam 
    1.61 +			*/
    1.62 +			EBigInt = 2,
    1.63 +			/** 
    1.64 +			RCryptoDesC8Param 
    1.65 +			*/
    1.66 +			EDesC8 = 3,
    1.67 +			/** 
    1.68 +			RCryptoDesC16Param 
    1.69 +			*/
    1.70 +			EDesC16 = 4,
    1.71 +			};
    1.72 +				
    1.73 +		/**
    1.74 +		Returns the data type of the crypto parameter
    1.75 +		@return The data type of the crypto parameter
    1.76 +		*/
    1.77 +		IMPORT_C TInt Type() const;
    1.78 +		
    1.79 +		/**
    1.80 +		Returns the Uid of the crypto parameter
    1.81 +		@return The Uid of the crypto parameter
    1.82 +		*/
    1.83 +		IMPORT_C TUid Uid() const;
    1.84 +		
    1.85 +		/** 
    1.86 +		Destructor 
    1.87 +		*/
    1.88 +		IMPORT_C ~CCryptoParam();
    1.89 +		
    1.90 +	protected:
    1.91 +		/**
    1.92 +		 * @internalComponent
    1.93 +		 * 
    1.94 +		 * Constructor 
    1.95 +		 * @param aType	The data type identifier for the sub-class.
    1.96 +		 * @param aUid	The Uid of the cryptoparam
    1.97 +		 */
    1.98 +		CCryptoParam(TParamType aType, TUid aUid);
    1.99 +
   1.100 +	protected:
   1.101 +		/**
   1.102 +		The data type of the embedded value
   1.103 +		*/
   1.104 +		TParamType iType;
   1.105 +		
   1.106 +		/**
   1.107 +		The Uid of the crypto parameter
   1.108 +		*/
   1.109 +		TUid iUid;
   1.110 +		};
   1.111 +
   1.112 +	/**
   1.113 +	CryptoParam class that wraps a TInt
   1.114 +	*/
   1.115 +	NONSHARABLE_CLASS(CCryptoIntParam) : public CCryptoParam
   1.116 +		{
   1.117 +	public: 
   1.118 +		/**
   1.119 +		Factory method for allocating a new CCryptoIntParam object
   1.120 +		that contains a copy of the supplied TInt
   1.121 +		@param aValue The TInt to be wrapped (copied)
   1.122 +		@param aUid The UID of the CryptoParam
   1.123 +		@return A pointer to a CCryptoIntParam instance
   1.124 +		*/
   1.125 +		IMPORT_C static CCryptoIntParam* NewL(TInt aValue, TUid aUid);
   1.126 +
   1.127 +		/**
   1.128 +		Factory method for allocating a new CCryptoIntParam object
   1.129 +		that contains a copy of the supplied TInt
   1.130 +		Leaves the pointer of the CryptoParam on the cleanup stack
   1.131 +		@param aValue The TInt to be wrapped (copied)
   1.132 +		@param aUid The UID of the CryptoParam
   1.133 +		@return A pointer to a CCryptoIntParam instance
   1.134 +		*/
   1.135 +		IMPORT_C static CCryptoIntParam* NewLC(TInt aValue, TUid aUid);
   1.136 +
   1.137 +		/**
   1.138 +		Returns the embedded value.
   1.139 +		@return The embedded integer
   1.140 +		*/
   1.141 +		IMPORT_C TInt Value() const;
   1.142 +
   1.143 +		/**
   1.144 +		Destructor
   1.145 +		*/
   1.146 +		IMPORT_C ~CCryptoIntParam();
   1.147 +		
   1.148 +	private:
   1.149 +		/**
   1.150 +		Constructor
   1.151 +		@param aValue The integer to wrap
   1.152 +		@param aUid	The UID of the crypto parameter
   1.153 +		*/		
   1.154 +		CCryptoIntParam(TInt aValue, TUid aUid);
   1.155 +
   1.156 +	private:
   1.157 +		/** 
   1.158 +		The embedded value 
   1.159 +		*/
   1.160 +		TInt iValue;
   1.161 +		};
   1.162 +
   1.163 +	/**
   1.164 +	Crypto param class the wraps an RInteger
   1.165 +	 */
   1.166 +	NONSHARABLE_CLASS(CCryptoBigIntParam) : public CCryptoParam
   1.167 +		{
   1.168 +	public: 
   1.169 +		/**
   1.170 +		Factory method for allocating a new CCryptoBigIntParam object
   1.171 +		that contains a copy of the supplied TInteger object.
   1.172 +		@param aValue	The TInteger to be wrapped (copied)
   1.173 +		@param aUid	The UID of the CryptoParam
   1.174 +		@return A pointer to a CCryptoBigIntParam instance
   1.175 +		*/
   1.176 +		IMPORT_C static CCryptoBigIntParam* NewL(const TInteger& aValue, TUid aUid);
   1.177 +		
   1.178 +		/**
   1.179 +		Factory method for allocating a new CCryptoBigIntParam object
   1.180 +		that contains a copy of the supplied TInteger object.
   1.181 +		Leaves the pointer of the CryptoParam onto the cleanup stack.
   1.182 +		@param aValue	The TInteger to be wrapped (copied)
   1.183 +		@param aUid	The UID of the CryptoParam
   1.184 +		@return A pointer to a CCryptoBigIntParam instance
   1.185 +		*/		
   1.186 +		IMPORT_C static CCryptoBigIntParam* NewLC(const TInteger& aValue, TUid aUid);
   1.187 +
   1.188 +		/**
   1.189 +		Returns the embedded value.
   1.190 +		@return A reference to the embedded TInteger
   1.191 +		*/
   1.192 +		IMPORT_C const TInteger& Value() const;
   1.193 +
   1.194 +		/** 
   1.195 +		Destructor 
   1.196 +		*/
   1.197 +		IMPORT_C ~CCryptoBigIntParam();
   1.198 +		
   1.199 +	private:
   1.200 +		/**
   1.201 +		Constructor
   1.202 +		*/
   1.203 +		CCryptoBigIntParam();
   1.204 +		
   1.205 +		/**
   1.206 +		Constructor
   1.207 +		@param aUid	The UID of the crypto parameter
   1.208 +		*/				
   1.209 +		CCryptoBigIntParam(TUid aUid);
   1.210 +		
   1.211 +		/**
   1.212 +		Second Phase Constructor
   1.213 +		@param aValue	The TInteger to wrap
   1.214 +		*/		
   1.215 +		void ConstructL(const TInteger& aValue);
   1.216 +	
   1.217 +	private:
   1.218 +		/**
   1.219 +		The copied RInteger
   1.220 +		*/
   1.221 +		RInteger iValue;
   1.222 +		};
   1.223 +	
   1.224 +	/**
   1.225 +	Crypto param class that wraps an 8-bit constant descriptor
   1.226 +	*/
   1.227 +	NONSHARABLE_CLASS(CCryptoDesC8Param) : public CCryptoParam
   1.228 +		{
   1.229 +	public:
   1.230 +		/**
   1.231 +		Factory method for allocating a new CCryptoDesC8Param object
   1.232 +		that contains a copy of the supplied RInteger object.
   1.233 +		@param aValue The TDesC* to be wrapped (copied)
   1.234 +		@param aUid	The Uid of the CryptoParam
   1.235 +		@return A pointer to a CCryptoDesC8Param instance
   1.236 +		*/
   1.237 +		IMPORT_C static CCryptoDesC8Param* NewL(const TDesC8& aValue, TUid aUid);
   1.238 +
   1.239 +		/**
   1.240 +		Factory method for allocating a new CCryptoDesC8Param object
   1.241 +		that contains a copy of the supplied RInteger object.
   1.242 +		Leaves the pointer of the CryptoParam on the cleanup stack
   1.243 +		@param aValue The TDesC* to be wrapped (copied)
   1.244 +		@param aUid	The Uid of the CryptoParam
   1.245 +		@return A pointer to a CCryptoDesC8Param instance
   1.246 +		*/
   1.247 +		IMPORT_C static CCryptoDesC8Param* NewLC(const TDesC8& aValue, TUid aUid);
   1.248 +
   1.249 +		/**
   1.250 +		Returns the embedded value.
   1.251 +		@return A reference to the embedded TDesC8
   1.252 +		*/
   1.253 +		IMPORT_C const TDesC8& Value() const;
   1.254 +
   1.255 +		/**
   1.256 +		Destructor
   1.257 +		*/
   1.258 +		IMPORT_C ~CCryptoDesC8Param();
   1.259 +		
   1.260 +	private:
   1.261 +		/**
   1.262 +		Constructor
   1.263 +		*/
   1.264 +		CCryptoDesC8Param();
   1.265 +		
   1.266 +		/**
   1.267 +		Constructor
   1.268 +		@param aUid	The UID of the crypto parameter
   1.269 +		*/						
   1.270 +		CCryptoDesC8Param(TUid aUid);
   1.271 +
   1.272 +		/**
   1.273 +		Second Phase Constructor
   1.274 +		@param aValue The DesC8 to wrap
   1.275 +		*/				
   1.276 +		void ConstructL(const TDesC8& aValue);
   1.277 +	
   1.278 +	private:
   1.279 +		/**
   1.280 +		The copied descriptor
   1.281 +		*/		
   1.282 +		HBufC8* iValue;
   1.283 +		};
   1.284 +
   1.285 +	/**
   1.286 +	Crypto param class that wraps an 16-bit constant descriptor
   1.287 +	*/
   1.288 +	NONSHARABLE_CLASS(CCryptoDesC16Param) : public CCryptoParam
   1.289 +		{
   1.290 +	public:
   1.291 +		/**
   1.292 +		Factory method for allocating a new CCryptoDesC8Param object
   1.293 +		that contains a copy of the supplied RInteger object.
   1.294 +		@param aValue The TDesC* to be wrapped (copied)
   1.295 +		@param aUid	The Uid of the CryptoParam
   1.296 +		@return A pointer to a CCryptoDesC8Param instance
   1.297 +		*/
   1.298 +		IMPORT_C static CCryptoDesC16Param* NewL(const TDesC16& aValue, TUid aUid);
   1.299 +
   1.300 +		/**
   1.301 +		Factory method for allocating a new CCryptoDesC16Param object
   1.302 +		that contains a copy of the supplied RInteger object.
   1.303 +		Leaves the pointer of the CryptoParam on the cleanup stack
   1.304 +		@param aValue The TDesC* to be wrapped (copied)
   1.305 +		@param aUid	The Uid of the CryptoParam
   1.306 +		@return A pointer to a CCryptoDesC16Param instance
   1.307 +		*/
   1.308 +		IMPORT_C static CCryptoDesC16Param* NewLC(const TDesC16& aValue, TUid aUid);
   1.309 +
   1.310 +		/**
   1.311 +		Returns the embedded value.
   1.312 +		@return A reference to the embedded TDesC16
   1.313 +		*/
   1.314 +		IMPORT_C const TDesC16& Value() const;
   1.315 +
   1.316 +		/**
   1.317 +		Destructor
   1.318 +		*/
   1.319 +		IMPORT_C ~CCryptoDesC16Param();
   1.320 +		
   1.321 +	private:
   1.322 +		/**
   1.323 +		Constructor
   1.324 +		*/
   1.325 +		CCryptoDesC16Param();
   1.326 +		
   1.327 +		/**
   1.328 +		Constructor
   1.329 +		@param aUid	The UID of the crypto parameter
   1.330 +		*/						
   1.331 +		CCryptoDesC16Param(TUid aUid);
   1.332 +
   1.333 +		/**
   1.334 +		Second Phase Constructor
   1.335 +		@param aValue The DesC16 to wrap
   1.336 +		*/				
   1.337 +		void ConstructL(const TDesC16& aValue);
   1.338 +	
   1.339 +	private:
   1.340 +		/**
   1.341 +		The copied descriptor
   1.342 +		*/		
   1.343 +		HBufC16* iValue;
   1.344 +		};
   1.345 +		
   1.346 +	NONSHARABLE_CLASS(CCryptoParams) : public CBase
   1.347 +		{
   1.348 +	public:
   1.349 +		IMPORT_C static CCryptoParams* NewL(void);
   1.350 +		IMPORT_C static CCryptoParams* NewLC(void);
   1.351 +
   1.352 +		/**
   1.353 +		 * Various adding methods (CCryptoParams takes a copy)
   1.354 +		 */		
   1.355 +		IMPORT_C void AddL(const TInteger& aParam, TUid aUid);
   1.356 +		IMPORT_C void AddL(const TInt aParam, TUid aUid);
   1.357 +		IMPORT_C void AddL(const TDesC8& aParam, TUid aUid);
   1.358 +		IMPORT_C void AddL(const TDesC16& aParam, TUid aUid);
   1.359 +
   1.360 +		/**
   1.361 +		 * Various retrieving methods
   1.362 +		 */
   1.363 +		IMPORT_C const TInteger& GetBigIntL(TUid aUid) const;
   1.364 +		IMPORT_C TInt GetTIntL(TUid aUid) const;
   1.365 +		IMPORT_C const TDesC8& GetTDesC8L(TUid aUid) const;
   1.366 +		IMPORT_C const TDesC16& GetTDesC16L(TUid aUid) const;
   1.367 +		IMPORT_C const RPointerArray<CCryptoParam>& GetParams() const;
   1.368 +
   1.369 +		/// Queries if a parameter with the specified uid is present
   1.370 +		IMPORT_C TBool IsPresent(TUid aUid) const;
   1.371 +
   1.372 +		/// Return the count of parameters present
   1.373 +		IMPORT_C TInt Count(void) const;
   1.374 +
   1.375 +		/// Copy the passed CCryptoParams
   1.376 +		IMPORT_C CCryptoParams& CopyL(const CCryptoParams& aParams);
   1.377 +
   1.378 +		/// Destructor
   1.379 +		IMPORT_C virtual ~CCryptoParams();
   1.380 +
   1.381 +	protected:
   1.382 +		/** @internalComponent */
   1.383 +		CCryptoParams();
   1.384 +
   1.385 +		/** @internalComponent */
   1.386 +		void ConstructL(void);
   1.387 +		/** @internalComponent */
   1.388 +		CCryptoParam* GetCryptoParam(TUid aUid) const;
   1.389 +		/** @internalComponent */ 
   1.390 +		CCryptoParam* GetCryptoParamL(TUid aUid) const;
   1.391 +
   1.392 +	private:
   1.393 +		RPointerArray<CCryptoParam> iParams;
   1.394 +		};
   1.395 +	} //End of namespace
   1.396 +
   1.397 +#endif // __CRYPTOPARAMS_H__
   1.398 +