os/security/crypto/weakcryptospi/test/tplugins/inc/softwarehashbase.h
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/security/crypto/weakcryptospi/test/tplugins/inc/softwarehashbase.h	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,133 @@
     1.4 +/*
     1.5 +* Copyright (c) 2006-2010 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 +* Software hash base definition
    1.19 +*
    1.20 +*/
    1.21 +
    1.22 +
    1.23 +/**
    1.24 + @file
    1.25 + @internalComponent
    1.26 + @released
    1.27 +*/
    1.28 +
    1.29 +#ifndef __CRYPTOAPI_SOFTWAREHASHBASE_H__
    1.30 +#define __CRYPTOAPI_SOFTWAREHASHBASE_H__
    1.31 +
    1.32 +#include <cryptospi/hashplugin.h>
    1.33 +#include <cryptospi/keys.h>
    1.34 +
    1.35 +namespace SoftwareCrypto
    1.36 +	{
    1.37 +	using namespace CryptoSpi;
    1.38 +	/**
    1.39 +	Interfaces for Software Hash
    1.40 +	*/
    1.41 +	class MSoftwareHash : public MHash
    1.42 +		{
    1.43 +	public:
    1.44 +		/**
    1.45 +		Restores the internal state of the message digest
    1.46 +		to a previously stored state.
    1.47 +		*/
    1.48 +		virtual void RestoreState() = 0;
    1.49 +
    1.50 +		/**
    1.51 +		Stores the internal state of the message digest.
    1.52 +		*/
    1.53 +		virtual void StoreState() = 0;
    1.54 +		};
    1.55 +			
    1.56 +	/**
    1.57 +	Proxy class Software Hash and Hmac implementation
    1.58 +	*/
    1.59 +	class CSoftwareHash : public MHash, public CBase
    1.60 +		{
    1.61 +	public:
    1.62 +		//
    1.63 +		//NewL & NewLC
    1.64 +		//
    1.65 +		static CSoftwareHash* NewL(TUid aAlgorithm, TUid aOperationMode, const CKey* aKey);
    1.66 +		static CSoftwareHash* NewLC(TUid aAlgorithm, TUid aOperationMode, const CKey* aKey);
    1.67 +
    1.68 +#ifdef SYMBIAN_SDP_IPSEC_VOIP_SUPPORT
    1.69 +		static CSoftwareHash* NewL(TUid aAlgorithm);
    1.70 +#endif
    1.71 +
    1.72 +		//
    1.73 +		// Destructor
    1.74 +		//
    1.75 +		~CSoftwareHash();
    1.76 +		//
    1.77 +		//From MPlugin
    1.78 +		//
    1.79 +		void Reset();
    1.80 +		void Close();		
    1.81 +		void GetCharacteristicsL(const TCharacteristics*& aPluginCharacteristics);		
    1.82 +		const CExtendedCharacteristics* GetExtendedCharacteristicsL();
    1.83 +		TAny* GetExtension(TUid aExtensionId);
    1.84 +		//
    1.85 +		//From MHash
    1.86 +		//
    1.87 +	    TPtrC8 Hash(const TDesC8& aMessage);
    1.88 +	    void Update(const TDesC8& aMessage);
    1.89 +		TPtrC8 Final(const TDesC8& aMessage);
    1.90 +		MHash* ReplicateL();		
    1.91 +		MHash* CopyL();
    1.92 +		void SetKeyL(const CKey& aKey);			
    1.93 +		void SetOperationModeL(TUid aOperationMode);
    1.94 +	
    1.95 +	private:
    1.96 +		//
    1.97 +		//Constructor
    1.98 +		// 
    1.99 +		CSoftwareHash();
   1.100 +		void ConstructL(TUid aAlgorithm, TUid aOperationMode, const CKey* aKey);
   1.101 +		
   1.102 +		//
   1.103 +		//get the active implementation
   1.104 +		//
   1.105 +		MSoftwareHash* Impl();
   1.106 +		
   1.107 +	private:
   1.108 +		/**
   1.109 +		The Key for HMAC mode operation
   1.110 +		*/
   1.111 +		CKey* iKey;
   1.112 +		
   1.113 +		/**
   1.114 +		The Uid for the operation mode
   1.115 +		*/
   1.116 +		TUid iOperationMode;
   1.117 +		
   1.118 +		/**
   1.119 +		The hash implementation
   1.120 +		*/
   1.121 +		MSoftwareHash* iHashImpl;
   1.122 +		
   1.123 +		/**
   1.124 +		The Hmac implementation
   1.125 +		*/
   1.126 +		MSoftwareHash* iHmacImpl;
   1.127 +		};
   1.128 +		
   1.129 +	GLDEF_C inline TUint CMD_R(TUint a,TUint s)
   1.130 +		{
   1.131 +		return (a<<s) | (a>>(32-s));
   1.132 +		}
   1.133 +	}
   1.134 +	
   1.135 +
   1.136 +#endif // __CRYPTOAPI_SOFTWAREHASHBASE_H__