crypto/weakcrypto/source/hash/sha384and512.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_SHA384AND512_H_
       
    29 #define __CRYPTO_SHA384AND512_H_
       
    30 
       
    31 
       
    32 #include "shacommon.h"
       
    33 
       
    34 const TInt KSHA512BlockSize	= 128;
       
    35 const TInt KSHA384HashSize	= 48;
       
    36 const TInt KSHA512HashSize	= 64;
       
    37 		
       
    38 NONSHARABLE_CLASS(CSHA384And512) : public CBase, public MSHA2Impl
       
    39 	{	
       
    40 public:
       
    41 	//NewL	
       
    42 	static CSHA384And512* NewL();
       
    43 	CSHA384And512(const CSHA384And512& aSHAImpl);
       
    44 	
       
    45 	//From MSHAImpl
       
    46 	virtual void Reset(const TAny* aValueArr);
       
    47 	virtual const TDesC8& Final(void);
       
    48 	virtual void Update(const TUint8* aData,TUint aLength);
       
    49 	virtual void StoreState();
       
    50 	virtual void RestoreState();
       
    51 
       
    52 private:
       
    53 	//Constructors
       
    54 	CSHA384And512();
       
    55 
       
    56 private:
       
    57 	// Private member functions
       
    58 	/**
       
    59 	 * @param aLength - Length of message added in bytes.
       
    60 	 */ 
       
    61 	inline void AddLength(const TUint64 aLength);
       
    62 	inline void CopyWordToHash(TUint64 aVal, TUint aIndex);
       
    63 	void Block();
       
    64 	void PadMessage();
       
    65 
       
    66 private:
       
    67 	TBuf8<KSHA512HashSize> iHash;
       
    68 	TUint64 iA;
       
    69 	TUint64 iB;
       
    70 	TUint64 iC;
       
    71 	TUint64 iD;
       
    72 	TUint64 iE;
       
    73 	TUint64 iF;
       
    74 	TUint64 iG;
       
    75 	TUint64 iH;
       
    76 	TUint64 iData[KSHA512BlockSize];
       
    77 
       
    78 	TUint64 iACopy;
       
    79 	TUint64 iBCopy;
       
    80 	TUint64 iCCopy;
       
    81 	TUint64 iDCopy;
       
    82 	TUint64 iECopy;
       
    83 	TUint64 iFCopy;
       
    84 	TUint64 iGCopy;
       
    85 	TUint64 iHCopy;
       
    86 	TUint64 iNlCopy;
       
    87 	TUint64 iNhCopy;
       
    88 	TUint	iBlockIndexCopy;
       
    89 	TUint64 iDataCopy[KSHA512BlockSize];
       
    90 	
       
    91 	TUint64 iNl; // Lower word of Message Length
       
    92 	TUint64 iNh; // Higher word of Message Length
       
    93 	TUint iBlockIndex; // Message Length in the current block
       
    94 	};
       
    95 
       
    96 #endif // __CRYPTO_SHA384AND512_H_