sl@0
|
1 |
/*
|
sl@0
|
2 |
* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
3 |
* All rights reserved.
|
sl@0
|
4 |
* This component and the accompanying materials are made available
|
sl@0
|
5 |
* under the terms of the License "Eclipse Public License v1.0"
|
sl@0
|
6 |
* which accompanies this distribution, and is available
|
sl@0
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
8 |
*
|
sl@0
|
9 |
* Initial Contributors:
|
sl@0
|
10 |
* Nokia Corporation - initial contribution.
|
sl@0
|
11 |
*
|
sl@0
|
12 |
* Contributors:
|
sl@0
|
13 |
*
|
sl@0
|
14 |
* Description:
|
sl@0
|
15 |
* MAC(message authentication code) plugin interface
|
sl@0
|
16 |
*
|
sl@0
|
17 |
*/
|
sl@0
|
18 |
|
sl@0
|
19 |
|
sl@0
|
20 |
/**
|
sl@0
|
21 |
@file
|
sl@0
|
22 |
@publishedPartner
|
sl@0
|
23 |
@released
|
sl@0
|
24 |
*/
|
sl@0
|
25 |
|
sl@0
|
26 |
#ifndef __MAC_PLUGIN_H
|
sl@0
|
27 |
#define __MAC_PLUGIN_H
|
sl@0
|
28 |
|
sl@0
|
29 |
#include <cryptospi/cryptoplugin.h>
|
sl@0
|
30 |
|
sl@0
|
31 |
namespace CryptoSpi
|
sl@0
|
32 |
{
|
sl@0
|
33 |
class CKey;
|
sl@0
|
34 |
|
sl@0
|
35 |
/**
|
sl@0
|
36 |
* The generic CryptoSPI MAC definition. This allow plug-ins
|
sl@0
|
37 |
* to implement extensible MAC functionality and to work with all
|
sl@0
|
38 |
* known existing hash based or symmetric cipher based MAC algorithms
|
sl@0
|
39 |
* for e.g. MD2, MD4, MD5, SHA-1, SHA-256, SHA-512, RIPEMD-160, etc. or
|
sl@0
|
40 |
* AES-XCBC-MAC-96, AES-XCBC-PRF-128 etc. respectively.
|
sl@0
|
41 |
*/
|
sl@0
|
42 |
class MMac : public MPlugin
|
sl@0
|
43 |
{
|
sl@0
|
44 |
public:
|
sl@0
|
45 |
|
sl@0
|
46 |
/**
|
sl@0
|
47 |
* Adds message to the internal representation of data for which the MAC value
|
sl@0
|
48 |
* needs to be evaluated and then returns a TPtrC8 of the finalised MAC value
|
sl@0
|
49 |
* of all the previously appended messages.
|
sl@0
|
50 |
*
|
sl@0
|
51 |
* @param aMessage The data for which MAC value is to be evaluated.
|
sl@0
|
52 |
* @return A descriptor pointer to the buffer containing the
|
sl@0
|
53 |
* resulting MAC value.
|
sl@0
|
54 |
* @leave ... Any of the crypto error codes defined in
|
sl@0
|
55 |
cryptospi_errs.h or any of the system-wide error codes.
|
sl@0
|
56 |
*/
|
sl@0
|
57 |
virtual TPtrC8 MacL(const TDesC8& aMessage) = 0;
|
sl@0
|
58 |
|
sl@0
|
59 |
/**
|
sl@0
|
60 |
* Adds data to the internal representation of messages for which the MAC value
|
sl@0
|
61 |
* needs to be evaluated.
|
sl@0
|
62 |
*
|
sl@0
|
63 |
* @param aMessage The data to be included in the MAC evaluation.
|
sl@0
|
64 |
* @leave ... Any of the crypto error codes defined in
|
sl@0
|
65 |
cryptospi_errs.h or any of the system-wide error codes.
|
sl@0
|
66 |
*/
|
sl@0
|
67 |
virtual void UpdateL(const TDesC8& aMessage) = 0;
|
sl@0
|
68 |
|
sl@0
|
69 |
/**
|
sl@0
|
70 |
* Produces a final MAC value from all the previous updates of data to be MACed.
|
sl@0
|
71 |
* It resets the MAC algorithm in a state similar to creating a new MAC instance
|
sl@0
|
72 |
* with the same underlying algorithm and supplied symmetric key.
|
sl@0
|
73 |
*
|
sl@0
|
74 |
* @param aMessage The data to be included in the MAC evaluation.
|
sl@0
|
75 |
* @return A descriptor pointer to the buffer containing the
|
sl@0
|
76 |
* resulting MAC value.
|
sl@0
|
77 |
* @leave ... Any of the crypto error codes defined in
|
sl@0
|
78 |
cryptospi_errs.h or any of the system-wide error codes.
|
sl@0
|
79 |
*/
|
sl@0
|
80 |
virtual TPtrC8 FinalL(const TDesC8& aMessage) = 0;
|
sl@0
|
81 |
|
sl@0
|
82 |
/**
|
sl@0
|
83 |
* This re-initialises the underlying MAC algorithm with a new symmetric key.
|
sl@0
|
84 |
* It resets the MAC algorithm in a state similar to creating a new MAC instance
|
sl@0
|
85 |
* with the same underlying algorithm but a new symmetric key.
|
sl@0
|
86 |
*
|
sl@0
|
87 |
* @param aKey Symmetric key for calculating message authentication code value.
|
sl@0
|
88 |
* @leave ... Any of the crypto error codes defined in
|
sl@0
|
89 |
cryptospi_errs.h or any of the system-wide error codes.
|
sl@0
|
90 |
*/
|
sl@0
|
91 |
virtual void ReInitialiseAndSetKeyL(const CKey& aKey) = 0;
|
sl@0
|
92 |
|
sl@0
|
93 |
/**
|
sl@0
|
94 |
* Creates a brand new reset MMac object containing no state
|
sl@0
|
95 |
* information from the current object.
|
sl@0
|
96 |
*
|
sl@0
|
97 |
* @return A pointer to the new reset MMac object
|
sl@0
|
98 |
* @leave ... Any of the crypto error codes defined in
|
sl@0
|
99 |
cryptospi_errs.h or any of the system-wide error codes.
|
sl@0
|
100 |
*/
|
sl@0
|
101 |
virtual MMac* ReplicateL() = 0;
|
sl@0
|
102 |
|
sl@0
|
103 |
/**
|
sl@0
|
104 |
* Creates a new MMac object with the exact same state as
|
sl@0
|
105 |
* the current object.
|
sl@0
|
106 |
* This function copies all internal state of the message digest.
|
sl@0
|
107 |
*
|
sl@0
|
108 |
* @return A pointer to the new MMac object
|
sl@0
|
109 |
* @leave ... Any of the crypto error codes defined in
|
sl@0
|
110 |
cryptospi_errs.h or any of the system-wide error codes.
|
sl@0
|
111 |
*/
|
sl@0
|
112 |
virtual MMac* CopyL() = 0;
|
sl@0
|
113 |
};
|
sl@0
|
114 |
|
sl@0
|
115 |
/**
|
sl@0
|
116 |
* Asynchronous MAC interface typically used by the plug-in implementations
|
sl@0
|
117 |
* that are based for dedicated crypto hardware.
|
sl@0
|
118 |
*/
|
sl@0
|
119 |
class MAsyncMac : public MPlugin
|
sl@0
|
120 |
{
|
sl@0
|
121 |
public:
|
sl@0
|
122 |
|
sl@0
|
123 |
/**
|
sl@0
|
124 |
* Adds message to the internal representation of data for which the MAC value,
|
sl@0
|
125 |
* needs to be evaluated and then returns a TPtrC8 of the finalised MAC value
|
sl@0
|
126 |
* of all the previously appended messages.
|
sl@0
|
127 |
*
|
sl@0
|
128 |
* @param aMessage The data for which MAC value is to be evaluated.
|
sl@0
|
129 |
* @param aStatus Holds the completion status of an asynchronous
|
sl@0
|
130 |
* request for MAC evaluation.
|
sl@0
|
131 |
* @return A descriptor pointer to the buffer containing the
|
sl@0
|
132 |
* resulting MAC value.
|
sl@0
|
133 |
* @leave ... Any of the crypto error codes defined in
|
sl@0
|
134 |
cryptospi_errs.h or any of the system-wide error codes.
|
sl@0
|
135 |
*/
|
sl@0
|
136 |
virtual TPtrC8 MacL(const TDesC8& aMessage, TRequestStatus& aStatus) = 0;
|
sl@0
|
137 |
|
sl@0
|
138 |
/**
|
sl@0
|
139 |
* Adds data to the internal representation of messages for which the MAC value
|
sl@0
|
140 |
* needs to be evaluated.
|
sl@0
|
141 |
*
|
sl@0
|
142 |
* @param aMessage The data to be included in the MAC evaluation.
|
sl@0
|
143 |
* @param aStatus Holds the completion status of an asynchronous
|
sl@0
|
144 |
* request for MAC evaluation.
|
sl@0
|
145 |
* @leave ... Any of the crypto error codes defined in
|
sl@0
|
146 |
cryptospi_errs.h or any of the system-wide error codes.
|
sl@0
|
147 |
*/
|
sl@0
|
148 |
virtual void UpdateL(const TDesC8& aMessage, TRequestStatus& aStatus) = 0;
|
sl@0
|
149 |
|
sl@0
|
150 |
/**
|
sl@0
|
151 |
* Produces a final MAC value from all the previous updates of data to be MACed.
|
sl@0
|
152 |
* It resets the MAC algorithm in a state similar to creating a new MAC instance
|
sl@0
|
153 |
* with the same underlying algorithm and supplied symmetric key.
|
sl@0
|
154 |
*
|
sl@0
|
155 |
* @param aMessage The data to be included in the MAC evaluation.
|
sl@0
|
156 |
* @param aStatus Holds the completion status of an asynchronous
|
sl@0
|
157 |
* request for MAC evaluation.
|
sl@0
|
158 |
* @return A descriptor pointer to the buffer containing the
|
sl@0
|
159 |
* resulting MAC value.
|
sl@0
|
160 |
* @leave ... Any of the crypto error codes defined in
|
sl@0
|
161 |
cryptospi_errs.h or any of the system-wide error codes.
|
sl@0
|
162 |
*/
|
sl@0
|
163 |
virtual TPtrC8 FinalL(const TDesC8& aMessage, TRequestStatus& aStatus) = 0;
|
sl@0
|
164 |
|
sl@0
|
165 |
/**
|
sl@0
|
166 |
* This re-initialises the underlying MAC algorithm with a new symmetric key.
|
sl@0
|
167 |
* It resets the MAC algorithm in a state similar to creating a new MAC instance
|
sl@0
|
168 |
* with the same underlying algorithm but a new symmetric key.
|
sl@0
|
169 |
*
|
sl@0
|
170 |
* @param aKey Symmetric key for calculating message authentication code value.
|
sl@0
|
171 |
* @param aStatus Holds the completion status of an asynchronous
|
sl@0
|
172 |
* request for MAC evaluation.
|
sl@0
|
173 |
* @leave ... Any of the crypto error codes defined in
|
sl@0
|
174 |
cryptospi_errs.h or any of the system-wide error codes.
|
sl@0
|
175 |
*/
|
sl@0
|
176 |
virtual void ReInitialiseAndSetKeyL(const CKey& aKey) = 0;
|
sl@0
|
177 |
|
sl@0
|
178 |
/**
|
sl@0
|
179 |
* Cancels an outstanding request from the client.
|
sl@0
|
180 |
*/
|
sl@0
|
181 |
virtual void Cancel() = 0;
|
sl@0
|
182 |
|
sl@0
|
183 |
/**
|
sl@0
|
184 |
* Creates a brand new reset MAsyncMac object containing no state
|
sl@0
|
185 |
* information from the current object.
|
sl@0
|
186 |
*
|
sl@0
|
187 |
* @return A pointer to the new reset MAsyncHash object
|
sl@0
|
188 |
* @leave ... Any of the crypto error codes defined in
|
sl@0
|
189 |
cryptospi_errs.h or any of the system-wide error codes.
|
sl@0
|
190 |
*/
|
sl@0
|
191 |
virtual MAsyncMac* ReplicateL() = 0;
|
sl@0
|
192 |
|
sl@0
|
193 |
/**
|
sl@0
|
194 |
* Creates a new MAsyncMac object with the exact same state as
|
sl@0
|
195 |
* the current object.
|
sl@0
|
196 |
* This function copies all internal state of the message digest.
|
sl@0
|
197 |
*
|
sl@0
|
198 |
* @return A pointer to the new MAsyncMac object
|
sl@0
|
199 |
* @leave ... Any of the crypto error codes defined in
|
sl@0
|
200 |
cryptospi_errs.h or any of the system-wide error codes.
|
sl@0
|
201 |
*/
|
sl@0
|
202 |
virtual MAsyncMac* CopyL() = 0;
|
sl@0
|
203 |
};
|
sl@0
|
204 |
}
|
sl@0
|
205 |
|
sl@0
|
206 |
#endif __MAC_PLUGIN_H
|