cryptoplugins/cryptospiplugins/source/softwarecrypto/sha224and256impl.h
changeset 19 cd501b96611d
child 33 cf642210ecb7
equal deleted inserted replaced
15:da2ae96f639b 19:cd501b96611d
       
     1 /*
       
     2 * Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the License "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 /**
       
    22  @file
       
    23  @internalComponent
       
    24  @released
       
    25 */
       
    26 
       
    27 
       
    28 #ifndef __CRYPTOAPI_SOFTWARESHA224AND256IMPL_H_
       
    29 #define __CRYPTOAPI_SOFTWARESHA224AND256IMPL_H_
       
    30 
       
    31 
       
    32 #include "softwarehashbase.h"
       
    33 #include "shacommon.h"
       
    34 
       
    35 namespace SoftwareCrypto
       
    36 	{
       
    37 	using namespace CryptoSpi;
       
    38 	
       
    39 	const TInt KSHA256BlockSize	= 64;
       
    40 	const TInt KSHA224HashSize	= 28;
       
    41 	const TInt KSHA256HashSize	= 32;
       
    42 			
       
    43 	NONSHARABLE_CLASS(CSHA224And256Impl) : public CBase, public MSHA2Impl
       
    44 		{	
       
    45 	public:
       
    46 		//NewL	
       
    47 		static CSHA224And256Impl* NewL();
       
    48 		CSHA224And256Impl(const CSHA224And256Impl& aSHA256Impl);
       
    49 		
       
    50 		// Functions from MSHA2Impl
       
    51 		virtual void RestoreState();
       
    52 		virtual void StoreState();
       
    53 		virtual void Reset(const TAny*);
       
    54 		virtual void Update(const TUint8* aData,TUint aLength);
       
    55 		virtual const TDes8& Final(void);
       
    56 	
       
    57 	private:
       
    58 		//Constructors
       
    59 		CSHA224And256Impl();
       
    60 		inline void AddLength(const TUint aLength);
       
    61 		inline void CopyWordToHash(TUint aVal, TUint aIndex);
       
    62 		void Block();
       
    63 		void PadMessage();
       
    64 
       
    65 	private:
       
    66 		TBuf8<KSHA256HashSize> iHash;
       
    67 		TUint iA;
       
    68 		TUint iB;
       
    69 		TUint iC;
       
    70 		TUint iD;
       
    71 		TUint iE;
       
    72 		TUint iF;
       
    73 		TUint iG;
       
    74 		TUint iH;
       
    75 		TUint iData[KSHA256BlockSize];
       
    76 
       
    77 		TUint iACopy;
       
    78 		TUint iBCopy;
       
    79 		TUint iCCopy;
       
    80 		TUint iDCopy;
       
    81 		TUint iECopy;
       
    82 		TUint iFCopy;
       
    83 		TUint iGCopy;
       
    84 		TUint iHCopy;
       
    85 		TUint iNlCopy;
       
    86 		TUint iNhCopy;	
       
    87 		TUint iDataCopy[KSHA256BlockSize];
       
    88 		
       
    89 		TUint iNl;
       
    90 		TUint64 iNh;
       
    91 		};
       
    92 	}
       
    93 
       
    94 #endif // __CRYPTOAPI_SOFTWARESHA224AND256IMPL_H_