crypto/weakcrypto/source/hash/sha224and256.h
changeset 71 dd83586b62d6
equal deleted inserted replaced
66:8873e6835f7b 71:dd83586b62d6
       
     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 __CRYPTO_SHA224AND256_H_
       
    29 #define __CRYPTO_SHA224AND256_H_
       
    30 
       
    31 
       
    32 #include "shacommon.h"
       
    33 
       
    34 const TInt KSHA256BlockSize	= 64;
       
    35 const TInt KSHA224HashSize	= 28;
       
    36 const TInt KSHA256HashSize	= 32;
       
    37 		
       
    38 NONSHARABLE_CLASS(CSHA224And256) : public CBase, public MSHA2Impl
       
    39 	{	
       
    40 public:
       
    41 	//NewL	
       
    42 	static CSHA224And256* NewL();
       
    43 	CSHA224And256(const CSHA224And256& aSHAImpl);
       
    44 	
       
    45 	// Functions from MSHA2Impl
       
    46 	virtual void RestoreState();
       
    47 	virtual void StoreState();
       
    48 	virtual void Reset(const TAny*);
       
    49 	virtual void Update(const TUint8* aData,TUint aLength);
       
    50 	virtual const TDes8& Final(void);
       
    51 
       
    52 private:
       
    53 	//Constructors
       
    54 	CSHA224And256();
       
    55 	inline void AddLength(const TUint aLength);
       
    56 	inline void CopyWordToHash(TUint aVal, TUint aIndex);
       
    57 	void Block();
       
    58 	void PadMessage();
       
    59 
       
    60 private:
       
    61 	TBuf8<KSHA256HashSize> iHash;
       
    62 	TUint iA;
       
    63 	TUint iB;
       
    64 	TUint iC;
       
    65 	TUint iD;
       
    66 	TUint iE;
       
    67 	TUint iF;
       
    68 	TUint iG;
       
    69 	TUint iH;
       
    70 	TUint iData[KSHA256BlockSize];
       
    71 
       
    72 	TUint iACopy;
       
    73 	TUint iBCopy;
       
    74 	TUint iCCopy;
       
    75 	TUint iDCopy;
       
    76 	TUint iECopy;
       
    77 	TUint iFCopy;
       
    78 	TUint iGCopy;
       
    79 	TUint iHCopy;
       
    80 	TUint iNlCopy;
       
    81 	TUint iNhCopy;	
       
    82 	TUint iDataCopy[KSHA256BlockSize];
       
    83 	
       
    84 	TUint iNl;
       
    85 	TUint64 iNh;
       
    86 	};
       
    87 
       
    88 #endif // __CRYPTO_SHA224AND256_H_