os/security/cryptoplugins/cryptospiplugins/source/softwarecrypto/hmacimpl.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.
     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 	/**
    37 	 * This is the maximum block size currently supported by HMAC implementation.
    38 	 */  
    39 	const TInt KMaxBlockSize = 128;		
    40 	
    41 	NONSHARABLE_CLASS(CHMacImpl) : public CBase, public MSoftwareHash
    42 		{		
    43 	public:
    44 		//NewL & NewLC
    45 		static CHMacImpl* NewL(MSoftwareHash* aHash);
    46 		static CHMacImpl* NewLC(MSoftwareHash* aHash);
    47 		static CHMacImpl* NewL(const CKey& aKey, MSoftwareHash* aHash);
    48 		static CHMacImpl* NewLC(const CKey& aKey, MSoftwareHash* aHash);
    49 
    50 		//From MPlugin
    51 		void Reset();
    52 		void Close();		
    53 		void GetCharacteristicsL(const TCharacteristics*& aPluginCharacteristics);		
    54 		const CExtendedCharacteristics* GetExtendedCharacteristicsL();
    55 		TAny* GetExtension(TUid aExtensionId);
    56 		
    57 		//From MHmac
    58 	    TPtrC8 Hash(const TDesC8& aMessage);
    59 	    void Update(const TDesC8& aMessage);
    60 		TPtrC8 Final(const TDesC8& aMessage);
    61 		void SetKeyL(const CKey& aKey);
    62 		void SetOperationModeL(TUid aOperationMode);
    63 		MHash* ReplicateL();		
    64 		MHash* CopyL();
    65 				
    66 	private:
    67 		//Constructors
    68 		CHMacImpl();
    69 		CHMacImpl(const CHMacImpl& aHMacImpl);
    70 		
    71 		//Destructor
    72 		~CHMacImpl();
    73 		void RestoreState();
    74 		void StoreState();
    75 		void ConstructL(const CKey& aKey, MSoftwareHash* aHash);
    76 		void ConstructL(MSoftwareHash* aHash);
    77 		void Initialise(const TDesC8& aKey);
    78 		void InitBlockSizeL();
    79 		
    80 	private:
    81 		TUid iImplementationUid;
    82 		MSoftwareHash* iDigest;
    83 		
    84 		TBuf8<KMaxBlockSize> iInnerPad;
    85 		TBuf8<KMaxBlockSize> iOuterPad;
    86 		TBuf8<KMaxBlockSize> iInnerPadCopy;
    87 		TBuf8<KMaxBlockSize> iOuterPadCopy;
    88 		
    89 		TInt iBlockSize;
    90 		};
    91 	}
    92 
    93 #endif // __CRYPTOAPI_SOFTWAREHMACIMPL_H__