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