cryptoplugins/cryptospiplugins/source/softwarecrypto/md5impl.h
changeset 19 cd501b96611d
equal deleted inserted replaced
15:da2ae96f639b 19:cd501b96611d
       
     1 /*
       
     2 * Copyright (c) 2006-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 * Software md5 implementation
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 /**
       
    21  @file
       
    22  @internalComponent
       
    23  @released
       
    24 */
       
    25 
       
    26 #ifndef __CRYPTOAPI_SOFTWAREMD5IMPL_H__
       
    27 #define __CRYPTOAPI_SOFTWAREMD5IMPL_H__
       
    28 
       
    29 #include "softwarehashbase.h"
       
    30 
       
    31 namespace SoftwareCrypto
       
    32 	{
       
    33 	using namespace CryptoSpi;
       
    34 	
       
    35 	const TInt KMD5BlockSize = 16;
       
    36 	const TInt KMD5HashSize = 16;	
       
    37 	
       
    38 	NONSHARABLE_CLASS(CMD5Impl) : public CBase, public MSoftwareHash
       
    39 		{		
       
    40 	public:
       
    41 		//NewL & NewLC	
       
    42 		static CMD5Impl* NewL();
       
    43 		static CMD5Impl* NewLC();
       
    44 		
       
    45 		//From MPlugin
       
    46 		void Reset();
       
    47 		void Close();		
       
    48 		void GetCharacteristicsL(const TCharacteristics*& aPluginCharacteristics);		
       
    49 		static CExtendedCharacteristics* CreateExtendedCharacteristicsL();
       
    50 		const CExtendedCharacteristics* GetExtendedCharacteristicsL();
       
    51 		TAny* GetExtension(TUid aExtensionId);
       
    52 		
       
    53 		//From MHash
       
    54 	    TPtrC8 Hash(const TDesC8& aMessage);
       
    55 	    void Update(const TDesC8& aMessage);
       
    56 		TPtrC8 Final(const TDesC8& aMessage);
       
    57 		MHash* ReplicateL();		
       
    58 		MHash* CopyL();
       
    59 		void SetKeyL(const CKey& aKey);
       
    60 		void SetOperationModeL(TUid aOperationMode);		
       
    61 		
       
    62 		//From MSoftwareHash
       
    63 		void RestoreState();
       
    64 		void StoreState();
       
    65 		
       
    66 	private:
       
    67 		//Constructors
       
    68 		CMD5Impl();
       
    69 		CMD5Impl(const CMD5Impl& aCMD5Impl);
       
    70 		
       
    71 		//Destructor
       
    72 		~CMD5Impl();
       
    73 		
       
    74 		TUid ImplementationUid();
       
    75 		
       
    76 		void DoUpdate(const TUint8* aData,TUint aLength);
       
    77 		void DoFinal(void);
       
    78 		void Block();
       
    79 	
       
    80 	private:
       
    81 		TBuf8<KMD5HashSize> iHash;
       
    82 
       
    83 		TUint iA;
       
    84 		TUint iB;
       
    85 		TUint iC;
       
    86 		TUint iD;
       
    87 		TUint iNl;
       
    88 		TUint iNh;
       
    89 		TUint iData[KMD5BlockSize];
       
    90 
       
    91 		TUint iACopy;
       
    92 		TUint iBCopy;
       
    93 		TUint iCCopy;
       
    94 		TUint iDCopy;
       
    95 		TUint iNlCopy;
       
    96 		TUint iNhCopy;
       
    97 		TUint iDataCopy[KMD5BlockSize];
       
    98 		};
       
    99 	}
       
   100 
       
   101 #endif //  __CRYPTOAPI_SOFTWAREMD5IMPL_H__
       
   102