os/security/cryptoplugins/cryptospiplugins/source/softwarecrypto/sha384and512impl.h
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/security/cryptoplugins/cryptospiplugins/source/softwarecrypto/sha384and512impl.h	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,102 @@
     1.4 +/*
     1.5 +* Copyright (c) 2007-2009 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 +*
    1.19 +*/
    1.20 +
    1.21 +
    1.22 +
    1.23 +
    1.24 +/**
    1.25 + @file
    1.26 + @internalComponent
    1.27 + @released
    1.28 +*/
    1.29 +
    1.30 +
    1.31 +#ifndef __CRYPTOAPI_SOFTWARESHA384AND512IMPL_H_
    1.32 +#define __CRYPTOAPI_SOFTWARESHA384AND512IMPL_H_
    1.33 +
    1.34 +
    1.35 +#include "softwarehashbase.h"
    1.36 +#include "shacommon.h"
    1.37 +
    1.38 +namespace SoftwareCrypto
    1.39 +	{
    1.40 +	using namespace CryptoSpi;
    1.41 +	
    1.42 +	const TInt KSHA512BlockSize	= 128;
    1.43 +	const TInt KSHA384HashSize	= 48;
    1.44 +	const TInt KSHA512HashSize	= 64;
    1.45 +			
    1.46 +	NONSHARABLE_CLASS(CSHA384And512Impl) : public CBase, public MSHA2Impl
    1.47 +		{	
    1.48 +	public:
    1.49 +		//NewL	
    1.50 +		static CSHA384And512Impl* NewL(TInt aHashSize = KSHA512HashSize);
    1.51 +		CSHA384And512Impl(const CSHA384And512Impl& aSHA512Impl);
    1.52 +		
    1.53 +		//From MSHAImpl
    1.54 +		virtual void Reset(const TAny* aValueArr);
    1.55 +		virtual const TDesC8& Final(void);
    1.56 +		virtual void Update(const TUint8* aData,TUint aLength);
    1.57 +		virtual void StoreState();
    1.58 +		virtual void RestoreState();
    1.59 +
    1.60 +	private:
    1.61 +		//Constructors
    1.62 +		CSHA384And512Impl(TInt aHashSize);
    1.63 +
    1.64 +	private:
    1.65 +		// Private member functions
    1.66 +		/**
    1.67 +		 * @param aLength - Length of message added in bytes.
    1.68 +		 */ 
    1.69 +		inline void AddLength(const TUint64 aLength);
    1.70 +		inline void CopyWordToHash(TUint64 aVal, TUint aIndex);
    1.71 +		void Block();
    1.72 +		void PadMessage();
    1.73 +
    1.74 +	private:
    1.75 +		TBuf8<KSHA512HashSize> iHash;
    1.76 +		TUint64 iA;
    1.77 +		TUint64 iB;
    1.78 +		TUint64 iC;
    1.79 +		TUint64 iD;
    1.80 +		TUint64 iE;
    1.81 +		TUint64 iF;
    1.82 +		TUint64 iG;
    1.83 +		TUint64 iH;
    1.84 +		TUint64 iData[KSHA512BlockSize];
    1.85 +
    1.86 +		TUint64 iACopy;
    1.87 +		TUint64 iBCopy;
    1.88 +		TUint64 iCCopy;
    1.89 +		TUint64 iDCopy;
    1.90 +		TUint64 iECopy;
    1.91 +		TUint64 iFCopy;
    1.92 +		TUint64 iGCopy;
    1.93 +		TUint64 iHCopy;
    1.94 +		TUint64 iNlCopy;
    1.95 +		TUint64 iNhCopy;
    1.96 +		TUint	iBlockIndexCopy;
    1.97 +		TUint64 iDataCopy[KSHA512BlockSize];
    1.98 +		
    1.99 +		TUint64 iNl; // Lower word of Message Length
   1.100 +		TUint64 iNh; // Higher word of Message Length
   1.101 +		TUint iBlockIndex; // Message Length in the current block
   1.102 +		};
   1.103 +	}
   1.104 +
   1.105 +#endif // __CRYPTOAPI_SOFTWARESHA384AND512IMPL_H_