sl@0: /* sl@0: * Copyright (c) 2007-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: * sl@0: */ 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: sl@0: #ifndef __CRYPTOAPI_SOFTWARESHA384AND512IMPL_H_ sl@0: #define __CRYPTOAPI_SOFTWARESHA384AND512IMPL_H_ sl@0: sl@0: sl@0: #include "softwarehashbase.h" sl@0: #include "shacommon.h" sl@0: sl@0: namespace SoftwareCrypto sl@0: { sl@0: using namespace CryptoSpi; sl@0: sl@0: const TInt KSHA512BlockSize = 128; sl@0: const TInt KSHA384HashSize = 48; sl@0: const TInt KSHA512HashSize = 64; sl@0: sl@0: NONSHARABLE_CLASS(CSHA384And512Impl) : public CBase, public MSHA2Impl sl@0: { sl@0: public: sl@0: //NewL sl@0: static CSHA384And512Impl* NewL(TInt aHashSize = KSHA512HashSize); sl@0: CSHA384And512Impl(const CSHA384And512Impl& aSHA512Impl); sl@0: sl@0: //From MSHAImpl sl@0: virtual void Reset(const TAny* aValueArr); sl@0: virtual const TDesC8& Final(void); sl@0: virtual void Update(const TUint8* aData,TUint aLength); sl@0: virtual void StoreState(); sl@0: virtual void RestoreState(); sl@0: sl@0: private: sl@0: //Constructors sl@0: CSHA384And512Impl(TInt aHashSize); sl@0: sl@0: private: sl@0: // Private member functions sl@0: /** sl@0: * @param aLength - Length of message added in bytes. sl@0: */ sl@0: inline void AddLength(const TUint64 aLength); sl@0: inline void CopyWordToHash(TUint64 aVal, TUint aIndex); sl@0: void Block(); sl@0: void PadMessage(); sl@0: sl@0: private: sl@0: TBuf8 iHash; sl@0: TUint64 iA; sl@0: TUint64 iB; sl@0: TUint64 iC; sl@0: TUint64 iD; sl@0: TUint64 iE; sl@0: TUint64 iF; sl@0: TUint64 iG; sl@0: TUint64 iH; sl@0: TUint64 iData[KSHA512BlockSize]; sl@0: sl@0: TUint64 iACopy; sl@0: TUint64 iBCopy; sl@0: TUint64 iCCopy; sl@0: TUint64 iDCopy; sl@0: TUint64 iECopy; sl@0: TUint64 iFCopy; sl@0: TUint64 iGCopy; sl@0: TUint64 iHCopy; sl@0: TUint64 iNlCopy; sl@0: TUint64 iNhCopy; sl@0: TUint iBlockIndexCopy; sl@0: TUint64 iDataCopy[KSHA512BlockSize]; sl@0: sl@0: TUint64 iNl; // Lower word of Message Length sl@0: TUint64 iNh; // Higher word of Message Length sl@0: TUint iBlockIndex; // Message Length in the current block sl@0: }; sl@0: } sl@0: sl@0: #endif // __CRYPTOAPI_SOFTWARESHA384AND512IMPL_H_