sl@0: /* sl@0: * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: * All rights reserved. sl@0: * This component and the accompanying materials are made available sl@0: * under the terms of the License "Eclipse Public License v1.0" sl@0: * which accompanies this distribution, and is available sl@0: * at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: * sl@0: * Initial Contributors: sl@0: * Nokia Corporation - initial contribution. sl@0: * sl@0: * Contributors: sl@0: * sl@0: * Description: sl@0: * mac plugin implementation sl@0: * sl@0: */ sl@0: sl@0: sl@0: /** sl@0: @file sl@0: @internalComponent sl@0: @released sl@0: */ sl@0: sl@0: #ifndef __CRYPTOAPI_SOFTWAREMACIMPL_H__ sl@0: #define __CRYPTOAPI_SOFTWAREMACIMPL_H__ sl@0: sl@0: #include sl@0: #include "cryptosymmetriccipherapi.h" sl@0: #include "softwarehashbase.h" sl@0: #include "keys.h" sl@0: #include "cmacimpl.h" sl@0: #include "hmacimpl.h" sl@0: sl@0: sl@0: namespace SoftwareCrypto sl@0: { sl@0: using namespace CryptoSpi; sl@0: sl@0: NONSHARABLE_CLASS(CMacImpl) : public CBase, public MMac sl@0: { sl@0: public: sl@0: /** sl@0: * MAC implementation instance creation methods sl@0: */ sl@0: static CMacImpl* NewL(const CKey& aKey, sl@0: const TUid aImplementationId, sl@0: const CCryptoParams* aAlgorithmParams); sl@0: sl@0: /** sl@0: * Methods from MPlugin: Base class for all the plugins sl@0: */ sl@0: void GetCharacteristicsL(const TCharacteristics*& aPluginCharacteristics); sl@0: const CExtendedCharacteristics* GetExtendedCharacteristicsL(); sl@0: TAny* GetExtension(TUid aExtensionId); sl@0: void Reset(); sl@0: // this deletes the instance of this class. The method is called at the user side sl@0: // indirectly through the MPlugin pointer instance. sl@0: void Close(); sl@0: sl@0: /** sl@0: * From MMac: MAC interface (Software based) sl@0: */ sl@0: TPtrC8 MacL(const TDesC8& aMessage); sl@0: void UpdateL(const TDesC8& aMessage); sl@0: TPtrC8 FinalL(const TDesC8& aMessage); sl@0: void ReInitialiseAndSetKeyL(const CKey& aKey); sl@0: MMac* ReplicateL(); sl@0: MMac* CopyL(); sl@0: sl@0: private: sl@0: sl@0: /** sl@0: * Enumerators to recognize the type of algorithm used for MAC sl@0: */ sl@0: enum TMacBase {EHashBased, ECipherBased}; sl@0: sl@0: sl@0: /** sl@0: * Constructors and Destructors sl@0: */ sl@0: ~CMacImpl(); sl@0: CMacImpl(); sl@0: CMacImpl(const CMacImpl& aMacImpl); sl@0: sl@0: /** sl@0: * Initialize the 'iHmacImpl' and 'iCipherImpl' instances. sl@0: */ sl@0: void ConstructL(const CKey& aKey, const TUid aImplementationId,const CCryptoParams* aAlgorithmParams); sl@0: sl@0: /** sl@0: * This will return the Uid of the specific implementation sl@0: * used for the algorithm. sl@0: */ sl@0: TUid ImplementationUid() const; sl@0: sl@0: private: sl@0: TUid iImplementationUid; sl@0: TMacBase iBase; sl@0: CKey* iKey; sl@0: sl@0: /** sl@0: * The hash based MAC implementation. This is software based implementation. sl@0: */ sl@0: CHMacImpl* iHmacImpl; sl@0: sl@0: /** sl@0: * The symmetric cipher based MAC implementation. sl@0: */ sl@0: CCMacImpl* iCmacImpl; sl@0: }; sl@0: } sl@0: sl@0: #endif // __CRYPTOAPI_SOFTWAREMACIMPL_H__