os/security/crypto/weakcryptospi/test/tplugins/inc/md5impl.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     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(TUid aImplementationUid);
    43 		static CMD5Impl* NewLC(TUid aImplementationUid);
    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 		
    54 		//From MHash
    55 	    TPtrC8 Hash(const TDesC8& aMessage);
    56 	    void Update(const TDesC8& aMessage);
    57 		TPtrC8 Final(const TDesC8& aMessage);
    58 		MHash* ReplicateL();		
    59 		MHash* CopyL();
    60 		void SetKeyL(const CKey& aKey);
    61 		void SetOperationModeL(TUid aOperationMode);		
    62 		
    63 		//From MSoftwareHash
    64 		void RestoreState();
    65 		void StoreState();
    66 		
    67 	private:
    68 		//Constructors
    69 		CMD5Impl(TUid aImplementationUid);
    70 		CMD5Impl(const CMD5Impl& aCMD5Impl);
    71 		
    72 		//Destructor
    73 		~CMD5Impl();
    74 		
    75 		TUid ImplementationUid();
    76 		
    77 		void DoUpdate(const TUint8* aData,TUint aLength);
    78 		void DoFinal(void);
    79 		void Block();
    80 	
    81 	private:
    82 		
    83 		TUid iImplementationUid;	
    84 	
    85 		TBuf8<KMD5HashSize> iHash;
    86 
    87 		TUint iA;
    88 		TUint iB;
    89 		TUint iC;
    90 		TUint iD;
    91 		TUint iNl;
    92 		TUint iNh;
    93 		TUint iData[KMD5BlockSize];
    94 
    95 		TUint iACopy;
    96 		TUint iBCopy;
    97 		TUint iCCopy;
    98 		TUint iDCopy;
    99 		TUint iNlCopy;
   100 		TUint iNhCopy;
   101 		TUint iDataCopy[KMD5BlockSize];
   102 		CExtendedCharacteristics* iExtendedCharacteristics;
   103 		};
   104 	}
   105 
   106 #endif //  __CRYPTOAPI_SOFTWAREMD5IMPL_H__
   107