diff -r da2ae96f639b -r cd501b96611d cryptoplugins/cryptospiplugins/source/softwarecrypto/sha384and512impl.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cryptoplugins/cryptospiplugins/source/softwarecrypto/sha384and512impl.h Fri Nov 06 13:21:00 2009 +0200 @@ -0,0 +1,102 @@ +/* +* Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + +/** + @file + @internalComponent + @released +*/ + + +#ifndef __CRYPTOAPI_SOFTWARESHA384AND512IMPL_H_ +#define __CRYPTOAPI_SOFTWARESHA384AND512IMPL_H_ + + +#include "softwarehashbase.h" +#include "shacommon.h" + +namespace SoftwareCrypto + { + using namespace CryptoSpi; + + const TInt KSHA512BlockSize = 128; + const TInt KSHA384HashSize = 48; + const TInt KSHA512HashSize = 64; + + NONSHARABLE_CLASS(CSHA384And512Impl) : public CBase, public MSHA2Impl + { + public: + //NewL + static CSHA384And512Impl* NewL(TInt aHashSize = KSHA512HashSize); + CSHA384And512Impl(const CSHA384And512Impl& aSHA512Impl); + + //From MSHAImpl + virtual void Reset(const TAny* aValueArr); + virtual const TDesC8& Final(void); + virtual void Update(const TUint8* aData,TUint aLength); + virtual void StoreState(); + virtual void RestoreState(); + + private: + //Constructors + CSHA384And512Impl(TInt aHashSize); + + private: + // Private member functions + /** + * @param aLength - Length of message added in bytes. + */ + inline void AddLength(const TUint64 aLength); + inline void CopyWordToHash(TUint64 aVal, TUint aIndex); + void Block(); + void PadMessage(); + + private: + TBuf8 iHash; + TUint64 iA; + TUint64 iB; + TUint64 iC; + TUint64 iD; + TUint64 iE; + TUint64 iF; + TUint64 iG; + TUint64 iH; + TUint64 iData[KSHA512BlockSize]; + + TUint64 iACopy; + TUint64 iBCopy; + TUint64 iCCopy; + TUint64 iDCopy; + TUint64 iECopy; + TUint64 iFCopy; + TUint64 iGCopy; + TUint64 iHCopy; + TUint64 iNlCopy; + TUint64 iNhCopy; + TUint iBlockIndexCopy; + TUint64 iDataCopy[KSHA512BlockSize]; + + TUint64 iNl; // Lower word of Message Length + TUint64 iNh; // Higher word of Message Length + TUint iBlockIndex; // Message Length in the current block + }; + } + +#endif // __CRYPTOAPI_SOFTWARESHA384AND512IMPL_H_