crypto/weakcrypto/source/hash/sha384and512.h
author hgs
Thu, 12 Aug 2010 21:07:10 +0530
changeset 90 8c545fea2798
parent 72 de46a57f75fb
permissions -rw-r--r--
201031_01
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
72
de46a57f75fb 201023_02
hgs
parents:
diff changeset
     1
/*
de46a57f75fb 201023_02
hgs
parents:
diff changeset
     2
* Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
de46a57f75fb 201023_02
hgs
parents:
diff changeset
     3
* All rights reserved.
de46a57f75fb 201023_02
hgs
parents:
diff changeset
     4
* This component and the accompanying materials are made available
de46a57f75fb 201023_02
hgs
parents:
diff changeset
     5
* under the terms of the License "Eclipse Public License v1.0"
de46a57f75fb 201023_02
hgs
parents:
diff changeset
     6
* which accompanies this distribution, and is available
de46a57f75fb 201023_02
hgs
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
de46a57f75fb 201023_02
hgs
parents:
diff changeset
     8
*
de46a57f75fb 201023_02
hgs
parents:
diff changeset
     9
* Initial Contributors:
de46a57f75fb 201023_02
hgs
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
de46a57f75fb 201023_02
hgs
parents:
diff changeset
    11
*
de46a57f75fb 201023_02
hgs
parents:
diff changeset
    12
* Contributors:
de46a57f75fb 201023_02
hgs
parents:
diff changeset
    13
*
de46a57f75fb 201023_02
hgs
parents:
diff changeset
    14
* Description: 
de46a57f75fb 201023_02
hgs
parents:
diff changeset
    15
*
de46a57f75fb 201023_02
hgs
parents:
diff changeset
    16
*/
de46a57f75fb 201023_02
hgs
parents:
diff changeset
    17
de46a57f75fb 201023_02
hgs
parents:
diff changeset
    18
de46a57f75fb 201023_02
hgs
parents:
diff changeset
    19
de46a57f75fb 201023_02
hgs
parents:
diff changeset
    20
de46a57f75fb 201023_02
hgs
parents:
diff changeset
    21
/**
de46a57f75fb 201023_02
hgs
parents:
diff changeset
    22
 @file
de46a57f75fb 201023_02
hgs
parents:
diff changeset
    23
 @internalComponent
de46a57f75fb 201023_02
hgs
parents:
diff changeset
    24
 @released
de46a57f75fb 201023_02
hgs
parents:
diff changeset
    25
*/
de46a57f75fb 201023_02
hgs
parents:
diff changeset
    26
de46a57f75fb 201023_02
hgs
parents:
diff changeset
    27
de46a57f75fb 201023_02
hgs
parents:
diff changeset
    28
#ifndef __CRYPTO_SHA384AND512_H_
de46a57f75fb 201023_02
hgs
parents:
diff changeset
    29
#define __CRYPTO_SHA384AND512_H_
de46a57f75fb 201023_02
hgs
parents:
diff changeset
    30
de46a57f75fb 201023_02
hgs
parents:
diff changeset
    31
de46a57f75fb 201023_02
hgs
parents:
diff changeset
    32
#include "shacommon.h"
de46a57f75fb 201023_02
hgs
parents:
diff changeset
    33
de46a57f75fb 201023_02
hgs
parents:
diff changeset
    34
const TInt KSHA512BlockSize	= 128;
de46a57f75fb 201023_02
hgs
parents:
diff changeset
    35
const TInt KSHA384HashSize	= 48;
de46a57f75fb 201023_02
hgs
parents:
diff changeset
    36
const TInt KSHA512HashSize	= 64;
de46a57f75fb 201023_02
hgs
parents:
diff changeset
    37
		
de46a57f75fb 201023_02
hgs
parents:
diff changeset
    38
NONSHARABLE_CLASS(CSHA384And512) : public CBase, public MSHA2Impl
de46a57f75fb 201023_02
hgs
parents:
diff changeset
    39
	{	
de46a57f75fb 201023_02
hgs
parents:
diff changeset
    40
public:
de46a57f75fb 201023_02
hgs
parents:
diff changeset
    41
	//NewL	
de46a57f75fb 201023_02
hgs
parents:
diff changeset
    42
	static CSHA384And512* NewL();
de46a57f75fb 201023_02
hgs
parents:
diff changeset
    43
	CSHA384And512(const CSHA384And512& aSHAImpl);
de46a57f75fb 201023_02
hgs
parents:
diff changeset
    44
	
de46a57f75fb 201023_02
hgs
parents:
diff changeset
    45
	//From MSHAImpl
de46a57f75fb 201023_02
hgs
parents:
diff changeset
    46
	virtual void Reset(const TAny* aValueArr);
de46a57f75fb 201023_02
hgs
parents:
diff changeset
    47
	virtual const TDesC8& Final(void);
de46a57f75fb 201023_02
hgs
parents:
diff changeset
    48
	virtual void Update(const TUint8* aData,TUint aLength);
de46a57f75fb 201023_02
hgs
parents:
diff changeset
    49
	virtual void StoreState();
de46a57f75fb 201023_02
hgs
parents:
diff changeset
    50
	virtual void RestoreState();
de46a57f75fb 201023_02
hgs
parents:
diff changeset
    51
de46a57f75fb 201023_02
hgs
parents:
diff changeset
    52
private:
de46a57f75fb 201023_02
hgs
parents:
diff changeset
    53
	//Constructors
de46a57f75fb 201023_02
hgs
parents:
diff changeset
    54
	CSHA384And512();
de46a57f75fb 201023_02
hgs
parents:
diff changeset
    55
de46a57f75fb 201023_02
hgs
parents:
diff changeset
    56
private:
de46a57f75fb 201023_02
hgs
parents:
diff changeset
    57
	// Private member functions
de46a57f75fb 201023_02
hgs
parents:
diff changeset
    58
	/**
de46a57f75fb 201023_02
hgs
parents:
diff changeset
    59
	 * @param aLength - Length of message added in bytes.
de46a57f75fb 201023_02
hgs
parents:
diff changeset
    60
	 */ 
de46a57f75fb 201023_02
hgs
parents:
diff changeset
    61
	inline void AddLength(const TUint64 aLength);
de46a57f75fb 201023_02
hgs
parents:
diff changeset
    62
	inline void CopyWordToHash(TUint64 aVal, TUint aIndex);
de46a57f75fb 201023_02
hgs
parents:
diff changeset
    63
	void Block();
de46a57f75fb 201023_02
hgs
parents:
diff changeset
    64
	void PadMessage();
de46a57f75fb 201023_02
hgs
parents:
diff changeset
    65
de46a57f75fb 201023_02
hgs
parents:
diff changeset
    66
private:
de46a57f75fb 201023_02
hgs
parents:
diff changeset
    67
	TBuf8<KSHA512HashSize> iHash;
de46a57f75fb 201023_02
hgs
parents:
diff changeset
    68
	TUint64 iA;
de46a57f75fb 201023_02
hgs
parents:
diff changeset
    69
	TUint64 iB;
de46a57f75fb 201023_02
hgs
parents:
diff changeset
    70
	TUint64 iC;
de46a57f75fb 201023_02
hgs
parents:
diff changeset
    71
	TUint64 iD;
de46a57f75fb 201023_02
hgs
parents:
diff changeset
    72
	TUint64 iE;
de46a57f75fb 201023_02
hgs
parents:
diff changeset
    73
	TUint64 iF;
de46a57f75fb 201023_02
hgs
parents:
diff changeset
    74
	TUint64 iG;
de46a57f75fb 201023_02
hgs
parents:
diff changeset
    75
	TUint64 iH;
de46a57f75fb 201023_02
hgs
parents:
diff changeset
    76
	TUint64 iData[KSHA512BlockSize];
de46a57f75fb 201023_02
hgs
parents:
diff changeset
    77
de46a57f75fb 201023_02
hgs
parents:
diff changeset
    78
	TUint64 iACopy;
de46a57f75fb 201023_02
hgs
parents:
diff changeset
    79
	TUint64 iBCopy;
de46a57f75fb 201023_02
hgs
parents:
diff changeset
    80
	TUint64 iCCopy;
de46a57f75fb 201023_02
hgs
parents:
diff changeset
    81
	TUint64 iDCopy;
de46a57f75fb 201023_02
hgs
parents:
diff changeset
    82
	TUint64 iECopy;
de46a57f75fb 201023_02
hgs
parents:
diff changeset
    83
	TUint64 iFCopy;
de46a57f75fb 201023_02
hgs
parents:
diff changeset
    84
	TUint64 iGCopy;
de46a57f75fb 201023_02
hgs
parents:
diff changeset
    85
	TUint64 iHCopy;
de46a57f75fb 201023_02
hgs
parents:
diff changeset
    86
	TUint64 iNlCopy;
de46a57f75fb 201023_02
hgs
parents:
diff changeset
    87
	TUint64 iNhCopy;
de46a57f75fb 201023_02
hgs
parents:
diff changeset
    88
	TUint	iBlockIndexCopy;
de46a57f75fb 201023_02
hgs
parents:
diff changeset
    89
	TUint64 iDataCopy[KSHA512BlockSize];
de46a57f75fb 201023_02
hgs
parents:
diff changeset
    90
	
de46a57f75fb 201023_02
hgs
parents:
diff changeset
    91
	TUint64 iNl; // Lower word of Message Length
de46a57f75fb 201023_02
hgs
parents:
diff changeset
    92
	TUint64 iNh; // Higher word of Message Length
de46a57f75fb 201023_02
hgs
parents:
diff changeset
    93
	TUint iBlockIndex; // Message Length in the current block
de46a57f75fb 201023_02
hgs
parents:
diff changeset
    94
	};
de46a57f75fb 201023_02
hgs
parents:
diff changeset
    95
de46a57f75fb 201023_02
hgs
parents:
diff changeset
    96
#endif // __CRYPTO_SHA384AND512_H_