os/security/crypto/weakcryptospi/test/tplugins/inc/macimpl.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 /*
     2 * Copyright (c) 2008-2010 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 * mac plugin implementation
    16 *
    17 */
    18 
    19 
    20 /**
    21  @file
    22  @internalComponent
    23  @released
    24 */
    25 
    26 #ifndef __CRYPTOAPI_SOFTWAREMACIMPL_H__
    27 #define __CRYPTOAPI_SOFTWAREMACIMPL_H__
    28 
    29 #include <cryptospi/macplugin.h>
    30 #include <cryptospi/cryptosymmetriccipherapi.h>
    31 #include "softwarehashbase.h"
    32 #include <cryptospi/keys.h>
    33 #include "cmacimpl.h"
    34 #include "hmacimpl.h"
    35 
    36 
    37 namespace SoftwareCrypto
    38 	{
    39 	using namespace CryptoSpi;
    40 	
    41 	/**
    42 	Interfaces for Software Hash
    43 	*/
    44     	
    45 	NONSHARABLE_CLASS(CMacImpl) : public CBase, public MMac  
    46 		{		
    47 	public:
    48 		/**
    49 		 * MAC implementation instance creation methods
    50 		 */
    51 		static CMacImpl* NewL(const CKey& aKey,
    52 				              const TUid aImplementationId,
    53 				              const CCryptoParams* aAlgorithmParams);
    54 
    55 		/**
    56 		 * Methods from MPlugin: Base class for all the plugins
    57 		 */
    58 		void GetCharacteristicsL(const TCharacteristics*& aPluginCharacteristics);	
    59 		const CExtendedCharacteristics* GetExtendedCharacteristicsL();
    60 		TAny* GetExtension(TUid aExtensionId);
    61 		void Reset();
    62 		// this deletes the instance of this class. The method is called at the user side
    63 		// indirectly through the MPlugin pointer instance.
    64 		void Close();		
    65 		
    66 		/**
    67 		 *  From MMac: MAC interface (Software based)
    68 		 */
    69 	    TPtrC8 MacL(const TDesC8& aMessage);
    70         void UpdateL(const TDesC8& aMessage);
    71         TPtrC8 FinalL(const TDesC8& aMessage);
    72 		void ReInitialiseAndSetKeyL(const CKey& aKey);    
    73 		MMac* ReplicateL();
    74 		MMac* CopyL();
    75 	
    76 	private:
    77 	
    78 		/**
    79 		 *  Enumerators to recognize the type of algorithm used for MAC
    80 		 */
    81 		enum TMacBase {EHashBased, ECipherBased};
    82 
    83 
    84 		/**
    85 		 * Constructors and Destructors
    86 		 */
    87 		~CMacImpl();
    88     	CMacImpl();
    89 		CMacImpl(const CMacImpl& aMacImpl);
    90 		
    91 		/**
    92 		 * Initialize the 'iHmacImpl' and 'iCipherImpl' instances.
    93 		 */
    94 		void ConstructL(const CKey& aKey, const TUid aImplementationId,const CCryptoParams* aAlgorithmParams);
    95 		
    96 		/**
    97 		 * This will return the Uid of the specific implementation
    98 		 * used for the algorithm.
    99 		 */
   100 		TUid ImplementationUid() const;
   101 	
   102 	private:			
   103 		TUid iImplementationUid;
   104 		TMacBase iBase;
   105 		CKey* iKey;
   106 		
   107 		/**
   108 		 * The hash based MAC implementation. This is software based implementation.
   109 		 */
   110 		CHMacImpl* iHmacImpl;
   111 	
   112 		/**
   113 		 * The symmetric cipher based MAC implementation.
   114 		 */
   115 		CCMacImpl* iCmacImpl;
   116 		};
   117 	}
   118 
   119 #endif // __CRYPTOAPI_SOFTWAREMACIMPL_H__