crypto/weakcryptospi/test/tplugins/inc/hmacimpl.h
changeset 8 35751d3474b7
child 43 2f10d260163b
equal deleted inserted replaced
2:675a964f4eb5 8:35751d3474b7
       
     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 * hmac implementation
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 /**
       
    21  @file
       
    22  @internalComponent
       
    23  @released
       
    24 */
       
    25 
       
    26 #ifndef __CRYPTOAPI_SOFTWAREHMACIMPL_H__
       
    27 #define __CRYPTOAPI_SOFTWAREHMACIMPL_H__
       
    28 
       
    29 #include "softwarehashbase.h"
       
    30 #include "keys.h"
       
    31 
       
    32 namespace SoftwareCrypto
       
    33 	{
       
    34 	using namespace CryptoSpi;
       
    35 	
       
    36 	const TInt KHMacPad = 64;		
       
    37 	
       
    38 	NONSHARABLE_CLASS(CHMacImpl) : public CBase, public MSoftwareHash
       
    39 		{		
       
    40 	public:
       
    41 		//NewL & NewLC
       
    42 		static CHMacImpl* NewL(MSoftwareHash* aHash);
       
    43 		static CHMacImpl* NewLC(MSoftwareHash* aHash);
       
    44 		static CHMacImpl* NewL(const CKey& aKey, MSoftwareHash* aHash);
       
    45 		static CHMacImpl* NewLC(const CKey& aKey, MSoftwareHash* aHash);
       
    46 
       
    47 		//From MPlugin
       
    48 		void Reset();
       
    49 		void Close();		
       
    50 		void GetCharacteristicsL(const TCharacteristics*& aPluginCharacteristics);		
       
    51 		const CExtendedCharacteristics* GetExtendedCharacteristicsL();
       
    52 		TAny* GetExtension(TUid aExtensionId);
       
    53 		
       
    54 		//From MHmac
       
    55 	    TPtrC8 Hash(const TDesC8& aMessage);
       
    56 	    void Update(const TDesC8& aMessage);
       
    57 		TPtrC8 Final(const TDesC8& aMessage);
       
    58 		void SetKeyL(const CKey& aKey);
       
    59 		void SetOperationModeL(TUid aOperationMode);
       
    60 		MHash* ReplicateL();		
       
    61 		MHash* CopyL();
       
    62 				
       
    63 	private:
       
    64 		//Constructors
       
    65 		CHMacImpl();
       
    66 		CHMacImpl(const CHMacImpl& aHMacImpl);
       
    67 		
       
    68 		//Destructor
       
    69 		~CHMacImpl();
       
    70 		void RestoreState();
       
    71 		void StoreState();
       
    72 		void ConstructL(const CKey& aKey, MSoftwareHash* aHash);
       
    73 		void ConstructL(MSoftwareHash* aHash);
       
    74 		void Initialise(const TDesC8& aKey);
       
    75 		
       
    76 	private:
       
    77 		TUid iImplementationUid;
       
    78 		MSoftwareHash* iDigest;
       
    79 		TBuf8<KHMacPad> iInnerPad;
       
    80 		TBuf8<KHMacPad> iOuterPad;
       
    81 
       
    82 		TBuf8<KHMacPad> iInnerPadCopy;
       
    83 		TBuf8<KHMacPad> iOuterPadCopy;
       
    84 		};
       
    85 	}
       
    86 
       
    87 #endif // __CRYPTOAPI_SOFTWAREHMACIMPL_H__