sl@0: /* sl@0: * Copyright (c) 2006-2010 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: * Software hash base definition sl@0: * sl@0: */ sl@0: sl@0: sl@0: /** sl@0: @file sl@0: @internalComponent sl@0: @released sl@0: */ sl@0: sl@0: #ifndef __CRYPTOAPI_SOFTWAREHASHBASE_H__ sl@0: #define __CRYPTOAPI_SOFTWAREHASHBASE_H__ sl@0: sl@0: #include sl@0: #include sl@0: sl@0: namespace SoftwareCrypto sl@0: { sl@0: using namespace CryptoSpi; sl@0: /** sl@0: Interfaces for Software Hash sl@0: */ sl@0: class MSoftwareHash : public MHash sl@0: { sl@0: public: sl@0: /** sl@0: Restores the internal state of the message digest sl@0: to a previously stored state. sl@0: */ sl@0: virtual void RestoreState() = 0; sl@0: sl@0: /** sl@0: Stores the internal state of the message digest. sl@0: */ sl@0: virtual void StoreState() = 0; sl@0: }; sl@0: sl@0: /** sl@0: Proxy class Software Hash and Hmac implementation sl@0: */ sl@0: class CSoftwareHash : public MHash, public CBase sl@0: { sl@0: public: sl@0: // sl@0: //NewL & NewLC sl@0: // sl@0: static CSoftwareHash* NewL(TUid aAlgorithm, TUid aOperationMode, const CKey* aKey); sl@0: static CSoftwareHash* NewLC(TUid aAlgorithm, TUid aOperationMode, const CKey* aKey); sl@0: sl@0: #ifdef SYMBIAN_SDP_IPSEC_VOIP_SUPPORT sl@0: static CSoftwareHash* NewL(TUid aAlgorithm); sl@0: #endif sl@0: sl@0: // sl@0: // Destructor sl@0: // sl@0: ~CSoftwareHash(); sl@0: // sl@0: //From MPlugin sl@0: // sl@0: void Reset(); sl@0: void Close(); sl@0: void GetCharacteristicsL(const TCharacteristics*& aPluginCharacteristics); sl@0: const CExtendedCharacteristics* GetExtendedCharacteristicsL(); sl@0: TAny* GetExtension(TUid aExtensionId); sl@0: // sl@0: //From MHash sl@0: // sl@0: TPtrC8 Hash(const TDesC8& aMessage); sl@0: void Update(const TDesC8& aMessage); sl@0: TPtrC8 Final(const TDesC8& aMessage); sl@0: MHash* ReplicateL(); sl@0: MHash* CopyL(); sl@0: void SetKeyL(const CKey& aKey); sl@0: void SetOperationModeL(TUid aOperationMode); sl@0: sl@0: private: sl@0: // sl@0: //Constructor sl@0: // sl@0: CSoftwareHash(); sl@0: void ConstructL(TUid aAlgorithm, TUid aOperationMode, const CKey* aKey); sl@0: sl@0: // sl@0: //get the active implementation sl@0: // sl@0: MSoftwareHash* Impl(); sl@0: sl@0: private: sl@0: /** sl@0: The Key for HMAC mode operation sl@0: */ sl@0: CKey* iKey; sl@0: sl@0: /** sl@0: The Uid for the operation mode sl@0: */ sl@0: TUid iOperationMode; sl@0: sl@0: /** sl@0: The hash implementation sl@0: */ sl@0: MSoftwareHash* iHashImpl; sl@0: sl@0: /** sl@0: The Hmac implementation sl@0: */ sl@0: MSoftwareHash* iHmacImpl; sl@0: }; sl@0: sl@0: GLDEF_C inline TUint CMD_R(TUint a,TUint s) sl@0: { sl@0: return (a<>(32-s)); sl@0: } sl@0: } sl@0: sl@0: sl@0: #endif // __CRYPTOAPI_SOFTWAREHASHBASE_H__