crypto/weakcrypto/source/hash/sha224and256.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_SHA224AND256_H_
de46a57f75fb 201023_02
hgs
parents:
diff changeset
    29
#define __CRYPTO_SHA224AND256_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 KSHA256BlockSize	= 64;
de46a57f75fb 201023_02
hgs
parents:
diff changeset
    35
const TInt KSHA224HashSize	= 28;
de46a57f75fb 201023_02
hgs
parents:
diff changeset
    36
const TInt KSHA256HashSize	= 32;
de46a57f75fb 201023_02
hgs
parents:
diff changeset
    37
		
de46a57f75fb 201023_02
hgs
parents:
diff changeset
    38
NONSHARABLE_CLASS(CSHA224And256) : 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 CSHA224And256* NewL();
de46a57f75fb 201023_02
hgs
parents:
diff changeset
    43
	CSHA224And256(const CSHA224And256& aSHAImpl);
de46a57f75fb 201023_02
hgs
parents:
diff changeset
    44
	
de46a57f75fb 201023_02
hgs
parents:
diff changeset
    45
	// Functions from MSHA2Impl
de46a57f75fb 201023_02
hgs
parents:
diff changeset
    46
	virtual void RestoreState();
de46a57f75fb 201023_02
hgs
parents:
diff changeset
    47
	virtual void StoreState();
de46a57f75fb 201023_02
hgs
parents:
diff changeset
    48
	virtual void Reset(const TAny*);
de46a57f75fb 201023_02
hgs
parents:
diff changeset
    49
	virtual void Update(const TUint8* aData,TUint aLength);
de46a57f75fb 201023_02
hgs
parents:
diff changeset
    50
	virtual const TDes8& Final(void);
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
	CSHA224And256();
de46a57f75fb 201023_02
hgs
parents:
diff changeset
    55
	inline void AddLength(const TUint aLength);
de46a57f75fb 201023_02
hgs
parents:
diff changeset
    56
	inline void CopyWordToHash(TUint aVal, TUint aIndex);
de46a57f75fb 201023_02
hgs
parents:
diff changeset
    57
	void Block();
de46a57f75fb 201023_02
hgs
parents:
diff changeset
    58
	void PadMessage();
de46a57f75fb 201023_02
hgs
parents:
diff changeset
    59
de46a57f75fb 201023_02
hgs
parents:
diff changeset
    60
private:
de46a57f75fb 201023_02
hgs
parents:
diff changeset
    61
	TBuf8<KSHA256HashSize> iHash;
de46a57f75fb 201023_02
hgs
parents:
diff changeset
    62
	TUint iA;
de46a57f75fb 201023_02
hgs
parents:
diff changeset
    63
	TUint iB;
de46a57f75fb 201023_02
hgs
parents:
diff changeset
    64
	TUint iC;
de46a57f75fb 201023_02
hgs
parents:
diff changeset
    65
	TUint iD;
de46a57f75fb 201023_02
hgs
parents:
diff changeset
    66
	TUint iE;
de46a57f75fb 201023_02
hgs
parents:
diff changeset
    67
	TUint iF;
de46a57f75fb 201023_02
hgs
parents:
diff changeset
    68
	TUint iG;
de46a57f75fb 201023_02
hgs
parents:
diff changeset
    69
	TUint iH;
de46a57f75fb 201023_02
hgs
parents:
diff changeset
    70
	TUint iData[KSHA256BlockSize];
de46a57f75fb 201023_02
hgs
parents:
diff changeset
    71
de46a57f75fb 201023_02
hgs
parents:
diff changeset
    72
	TUint iACopy;
de46a57f75fb 201023_02
hgs
parents:
diff changeset
    73
	TUint iBCopy;
de46a57f75fb 201023_02
hgs
parents:
diff changeset
    74
	TUint iCCopy;
de46a57f75fb 201023_02
hgs
parents:
diff changeset
    75
	TUint iDCopy;
de46a57f75fb 201023_02
hgs
parents:
diff changeset
    76
	TUint iECopy;
de46a57f75fb 201023_02
hgs
parents:
diff changeset
    77
	TUint iFCopy;
de46a57f75fb 201023_02
hgs
parents:
diff changeset
    78
	TUint iGCopy;
de46a57f75fb 201023_02
hgs
parents:
diff changeset
    79
	TUint iHCopy;
de46a57f75fb 201023_02
hgs
parents:
diff changeset
    80
	TUint iNlCopy;
de46a57f75fb 201023_02
hgs
parents:
diff changeset
    81
	TUint iNhCopy;	
de46a57f75fb 201023_02
hgs
parents:
diff changeset
    82
	TUint iDataCopy[KSHA256BlockSize];
de46a57f75fb 201023_02
hgs
parents:
diff changeset
    83
	
de46a57f75fb 201023_02
hgs
parents:
diff changeset
    84
	TUint iNl;
de46a57f75fb 201023_02
hgs
parents:
diff changeset
    85
	TUint64 iNh;
de46a57f75fb 201023_02
hgs
parents:
diff changeset
    86
	};
de46a57f75fb 201023_02
hgs
parents:
diff changeset
    87
de46a57f75fb 201023_02
hgs
parents:
diff changeset
    88
#endif // __CRYPTO_SHA224AND256_H_