os/security/cryptoplugins/cryptospiplugins/source/softwarecrypto/softwarehashbase.h
First public contribution.
2 * Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
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".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
15 * Software hash base definition
26 #ifndef __CRYPTOAPI_SOFTWAREHASHBASE_H__
27 #define __CRYPTOAPI_SOFTWAREHASHBASE_H__
29 #include <cryptospi/hashplugin.h>
32 namespace SoftwareCrypto
34 using namespace CryptoSpi;
36 Interfaces for Software Hash
38 class MSoftwareHash : public MHash
42 Restores the internal state of the message digest
43 to a previously stored state.
45 virtual void RestoreState() = 0;
48 Stores the internal state of the message digest.
50 virtual void StoreState() = 0;
54 Proxy class Software Hash and Hmac implementation
56 NONSHARABLE_CLASS(CSoftwareHash) : public MHash, public CBase
62 static CSoftwareHash* NewL(TUid aAlgorithm, TUid aOperationMode, const CKey* aKey);
63 static CSoftwareHash* NewLC(TUid aAlgorithm, TUid aOperationMode, const CKey* aKey);
64 static CSoftwareHash* NewL(TUid aAlgorithm);
75 void GetCharacteristicsL(const TCharacteristics*& aPluginCharacteristics);
76 const CExtendedCharacteristics* GetExtendedCharacteristicsL();
77 TAny* GetExtension(TUid aExtensionId);
81 TPtrC8 Hash(const TDesC8& aMessage);
82 void Update(const TDesC8& aMessage);
83 TPtrC8 Final(const TDesC8& aMessage);
86 void SetKeyL(const CKey& aKey);
87 void SetOperationModeL(TUid aOperationMode);
94 void ConstructL(TUid aAlgorithm, TUid aOperationMode, const CKey* aKey);
97 //get the active implementation
99 MSoftwareHash* Impl();
103 The Key for HMAC mode operation
108 The Uid for the operation mode
113 The hash implementation
115 MSoftwareHash* iHashImpl;
118 The Hmac implementation
120 MSoftwareHash* iHmacImpl;
123 GLDEF_C inline TUint CMD_R(TUint a,TUint s)
125 return (a<<s) | (a>>(32-s));
130 #endif // __CRYPTOAPI_SOFTWAREHASHBASE_H__