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