sl@0: /* sl@0: * Copyright (c) 2006-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: * hmac implementation 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_SOFTWAREHMACIMPL_H__ sl@0: #define __CRYPTOAPI_SOFTWAREHMACIMPL_H__ sl@0: sl@0: #include "softwarehashbase.h" sl@0: #include "keys.h" sl@0: sl@0: namespace SoftwareCrypto sl@0: { sl@0: using namespace CryptoSpi; sl@0: sl@0: /** sl@0: * This is the maximum block size currently supported by HMAC implementation. sl@0: */ sl@0: const TInt KMaxBlockSize = 128; sl@0: sl@0: NONSHARABLE_CLASS(CHMacImpl) : public CBase, public MSoftwareHash sl@0: { sl@0: public: sl@0: //NewL & NewLC sl@0: static CHMacImpl* NewL(MSoftwareHash* aHash); sl@0: static CHMacImpl* NewLC(MSoftwareHash* aHash); sl@0: static CHMacImpl* NewL(const CKey& aKey, MSoftwareHash* aHash); sl@0: static CHMacImpl* NewLC(const CKey& aKey, MSoftwareHash* aHash); sl@0: sl@0: //From MPlugin 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 MHmac sl@0: TPtrC8 Hash(const TDesC8& aMessage); sl@0: void Update(const TDesC8& aMessage); sl@0: TPtrC8 Final(const TDesC8& aMessage); sl@0: void SetKeyL(const CKey& aKey); sl@0: void SetOperationModeL(TUid aOperationMode); sl@0: MHash* ReplicateL(); sl@0: MHash* CopyL(); sl@0: sl@0: private: sl@0: //Constructors sl@0: CHMacImpl(); sl@0: CHMacImpl(const CHMacImpl& aHMacImpl); sl@0: sl@0: //Destructor sl@0: ~CHMacImpl(); sl@0: void RestoreState(); sl@0: void StoreState(); sl@0: void ConstructL(const CKey& aKey, MSoftwareHash* aHash); sl@0: void ConstructL(MSoftwareHash* aHash); sl@0: void Initialise(const TDesC8& aKey); sl@0: void InitBlockSizeL(); sl@0: sl@0: private: sl@0: TUid iImplementationUid; sl@0: MSoftwareHash* iDigest; sl@0: sl@0: TBuf8 iInnerPad; sl@0: TBuf8 iOuterPad; sl@0: TBuf8 iInnerPadCopy; sl@0: TBuf8 iOuterPadCopy; sl@0: sl@0: TInt iBlockSize; sl@0: }; sl@0: } sl@0: sl@0: #endif // __CRYPTOAPI_SOFTWAREHMACIMPL_H__