|
1 /* |
|
2 * Copyright (c) 2006-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 * plugin selector interface |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 /** |
|
21 @file |
|
22 @publishedAll |
|
23 @released |
|
24 */ |
|
25 |
|
26 #ifndef __CRYPTOAPI_PLUGINSELECTORBASE_H__ |
|
27 #define __CRYPTOAPI_PLUGINSELECTORBASE_H__ |
|
28 |
|
29 #include <e32base.h> |
|
30 |
|
31 |
|
32 namespace CryptoSpi |
|
33 { |
|
34 class CHash; |
|
35 class CRandom; |
|
36 class CSymmetricCipher; |
|
37 class CAsymmetricCipher; |
|
38 class CSigner; |
|
39 class CVerifier; |
|
40 class CKeyAgreement; |
|
41 class CKeyPairGenerator; |
|
42 class CAsyncHash; |
|
43 class CAsyncRandom; |
|
44 class CAsyncSymmetricCipher; |
|
45 class CAsyncAsymmetricCipher; |
|
46 class CAsyncSigner; |
|
47 class CAsyncVerifier; |
|
48 class CAsyncKeyAgreement; |
|
49 class CAsyncKeyPairGenerator; |
|
50 class CKey; |
|
51 class CCryptoParams; |
|
52 |
|
53 |
|
54 #ifdef SYMBIAN_SDP_IPSEC_VOIP_SUPPORT |
|
55 class CMac; |
|
56 class CAsyncMac; |
|
57 #endif |
|
58 |
|
59 /** |
|
60 Base class for the selectors |
|
61 */ |
|
62 class MPluginSelector |
|
63 { |
|
64 public: |
|
65 /** |
|
66 Destructor |
|
67 */ |
|
68 inline virtual ~MPluginSelector() = 0; |
|
69 |
|
70 /** |
|
71 * @deprecated |
|
72 * |
|
73 * Create a new instance of a hash object |
|
74 * |
|
75 * @param aHash The pointer to CHash |
|
76 * @param aAlgorithmUid The specific hash algorithm e.g. MD2, SHA1 |
|
77 * @param aOperationMode The operation mode of the hash e.g. Hash mode, Hmac mode |
|
78 * @param aKey The key for Hmac mode, which should be NULL in Hash mode |
|
79 * @param aAlgorithmParams The parameters that are specific to a particular |
|
80 * algorithm. This is for extendibility and will normally be null. |
|
81 * @leave KErrNone if successful; otherwise, a system wide error code. |
|
82 */ |
|
83 virtual void CreateHashL(CHash*& aHash, |
|
84 TUid aAlgorithmUid, |
|
85 TUid aOperationMode, |
|
86 const CKey* aKey, |
|
87 const CCryptoParams* aAlgorithmParams) = 0; |
|
88 |
|
89 /** |
|
90 Creates a new instance of a Random object. |
|
91 |
|
92 @param aRandom A reference to a pointer that should be set to point to the new CRandom object. |
|
93 @param aAlgorithmUid The algorithm to use |
|
94 @param aAlgorithmParams Parameters that are specific this algorithm. |
|
95 @leave KErrNone if successful; otherwise, a system wide error code. |
|
96 */ |
|
97 virtual void CreateRandomL(CRandom*& aRandom, |
|
98 TUid aAlgorithmUid, |
|
99 const CCryptoParams* aAlgorithmParams) = 0; |
|
100 |
|
101 /** |
|
102 Creates a new synchronous instance of a symmetric cipher |
|
103 |
|
104 @param aCipher A reference to a pointer that should be set to point to the new symmetric object. |
|
105 @param aAlgorithmUid The algorithm to use |
|
106 @param aKey The encryption/decryption key. |
|
107 @param aCryptoMode The Symmetric cipher mode. |
|
108 @param aOperationMode The Symmetric cipher operation mode. |
|
109 @param aPaddingMode The Symmetric cipher padding mode. |
|
110 @param aAlgorithmParams Parameters that are specific to a particular algorithm. This is for extendibility and will normally be null. |
|
111 @leave KErrNone if successful; otherwise, a system wide error code. |
|
112 */ |
|
113 virtual void CreateSymmetricCipherL(CSymmetricCipher*& aCipher, |
|
114 TUid aAlgorithmUid, |
|
115 const CKey& aKey, |
|
116 TUid aCryptoMode, |
|
117 TUid aOperationMode, |
|
118 TUid aPaddingMode, |
|
119 const CCryptoParams* aAlgorithmParams) = 0; |
|
120 |
|
121 /** |
|
122 Creates a new instance of an asymmetric cipher |
|
123 |
|
124 @param aCipher A reference to a pointer that should be set to point to the new asymmetric cipher object. |
|
125 @param aAlgorithmUid The asymmetric cipher algorithm to use (e.g. KRsaCipherUid) |
|
126 @param aKey The encryption/decryption key. |
|
127 @param aCryptoMode whether to encrypt or decrypt |
|
128 @param aPaddingMode The padding mode to use |
|
129 @param aAlgorithmParams Parameters that are specific to a particular algorithm. This is for extendibility and will normally be null. |
|
130 @leave KErrNone if successful; otherwise, a system wide error code. |
|
131 */ |
|
132 virtual void CreateAsymmetricCipherL(CAsymmetricCipher*& aCipher, |
|
133 TUid aAlgorithmUid, |
|
134 const CKey& aKey, |
|
135 TUid aCryptoMode, |
|
136 TUid aPaddingMode, |
|
137 const CCryptoParams* aAlgorithmParams) = 0; |
|
138 |
|
139 /** |
|
140 Creates a new instance of a synchronous signer. |
|
141 |
|
142 @param aSigner A reference to a pointer that should be set to point to the new signer object. |
|
143 @param aAlgorithmUid The algorithm to use. |
|
144 @param aKey The signing key. |
|
145 @param aPaddingMode The padding mode of the signer. |
|
146 @param aAlgorithmParams Parameters that are specific to a particular algorithm. This is for extendibility and will normally be null. |
|
147 @leave KErrNone if successful; otherwise, a system wide error code. |
|
148 */ |
|
149 virtual void CreateSignerL(CSigner*& aSigner, |
|
150 TUid aAlgorithmUid, |
|
151 const CKey& aKey, |
|
152 TUid aPaddingMode, |
|
153 const CCryptoParams* aAlgorithmParams) = 0; |
|
154 |
|
155 /** |
|
156 Creates a new instance of a verifier. |
|
157 |
|
158 @param aVerifier A reference to a pointer that should be set to point to the new verifier object. |
|
159 @param aAlgorithmUid The algorithm to use |
|
160 @param aKey The key to verify the signature with. |
|
161 @param aPaddingMode The padding mode of the signer. |
|
162 @param aAlgorithmParams Parameters that are specific to a particular algorithm. This is for extendibility and will normally be null. |
|
163 @leave KErrNone if successful; otherwise, a system wide error code. |
|
164 */ |
|
165 virtual void CreateVerifierL(CVerifier*& aVerifier, |
|
166 TUid aAlgorithmUid, |
|
167 const CKey& aKey, |
|
168 TUid aPaddingMode, |
|
169 const CCryptoParams* aAlgorithmParams) = 0; |
|
170 |
|
171 /** |
|
172 Creates a new instance of a key pair generator. |
|
173 |
|
174 @param aKeyPairGenerator A reference to a pointer that should be set to point to the new asymmetric key pair generator object. |
|
175 @param aKeyAlgorithmUid The algorithm UID |
|
176 @param aAlgorithmParams The parameters that are specific to a particular algorithm. This is for extendibility and will normally be null. |
|
177 @leave KErrNone if successful; otherwise, a system wide error code. |
|
178 */ |
|
179 virtual void CreateKeyPairGeneratorL(CKeyPairGenerator*& aKeyPairGenerator, |
|
180 TUid aKeyAlgorithmUid, |
|
181 const CCryptoParams* aAlgorithmParams) = 0; |
|
182 |
|
183 |
|
184 /** |
|
185 Creates a new instance of a key agreement system. |
|
186 |
|
187 @param aKeyAgreement A reference to a pointer that should be set to point to the new key agreement object. |
|
188 @param aAlgorithmUid The algorithm to use |
|
189 @param aPrivateKey The private key to combine with the other parties public key during the agreement. |
|
190 @param aAlgorithmParams The parameters that are specific to a particular algorithm. This is for extendibility and will normally be null. |
|
191 @leave KErrNone if successful; otherwise, a system wide error code. |
|
192 */ |
|
193 virtual void CreateKeyAgreementL(CKeyAgreement*& aKeyAgreement, |
|
194 TUid aAlgorithmUid, |
|
195 const CKey& aPrivateKey, |
|
196 const CCryptoParams* aAlgorithmParams) = 0; |
|
197 |
|
198 /** |
|
199 * @deprecated |
|
200 * |
|
201 * Create a new instance of a asynchronous hash object |
|
202 * |
|
203 * @param aHash The pointer to CHash |
|
204 * @param aAlgorithmUid The specific hash algorithm e.g. MD2, SHA1 |
|
205 * @param aOperationMode The operation mode of the hash e.g. Hash mode, Hmac mode |
|
206 * @param aKey The key for Hmac mode, which should be NULL in Hash mode |
|
207 * @param aAlgorithmParams The parameters that are specific to a particular |
|
208 * algorithm. This is for extendibility and will normally be null. |
|
209 * @leave KErrNone if successful; otherwise, a system wide error code. |
|
210 */ |
|
211 virtual void CreateAsyncHashL(CAsyncHash*& aHash, |
|
212 TUid aAlgorithmUid, |
|
213 TUid aOperationMode, |
|
214 const CKey* aKey, |
|
215 const CCryptoParams* aAlgorithmParams) = 0; |
|
216 /** |
|
217 Creates a new instance of a asynchronous random object. |
|
218 |
|
219 @param aRandom A reference to a pointer that should be set to point to the new CRandom object. |
|
220 @param aAlgorithmUid The algorithm to use |
|
221 @param aAlgorithmParams Parameters that are specific this algorithm. |
|
222 @leave KErrNone if successful; otherwise, a system wide error code. |
|
223 */ |
|
224 virtual void CreateAsyncRandomL(CAsyncRandom*& aRandom, |
|
225 TUid aAlgorithmUid, |
|
226 const CCryptoParams* aAlgorithmParams) = 0; |
|
227 /** |
|
228 Creates a new synchronous instance of a asynchronous symmetric cipher |
|
229 |
|
230 @param aCipher A reference to a pointer that should be set to point to the new symmetric object. |
|
231 @param aAlgorithmUid The algorithm to use |
|
232 @param aKey The encryption/decryption key. |
|
233 @param aCryptoMode The Symmetric cipher mode. |
|
234 @param aOperationMode The Symmetric cipher operation mode. |
|
235 @param aPaddingMode The Symmetric cipher padding mode. |
|
236 @param aAlgorithmParams Parameters that are specific to a particular algorithm. This is for extendibility and will normally be null. |
|
237 @leave KErrNone if successful; otherwise, a system wide error code. |
|
238 */ |
|
239 virtual void CreateAsyncSymmetricCipherL(CAsyncSymmetricCipher*& aCipher, |
|
240 TUid aAlgorithmUid, |
|
241 const CKey& aKey, |
|
242 TUid aCryptoMode, |
|
243 TUid aOperationMode, |
|
244 TUid aPaddingMode, |
|
245 const CCryptoParams* aAlgorithmParams) = 0; |
|
246 |
|
247 /** |
|
248 Creates a new instance of an asynchronous asymmetric cipher |
|
249 |
|
250 @param aCipher A reference to a pointer that should be set to point to the new asymmetric cipher object. |
|
251 @param aAlgorithmUid The asymmetric cipher algorithm to use (e.g. KRsaCipherUid) |
|
252 @param aKey The encryption/decryption key. |
|
253 @param aCryptoMode whether to encrypt or decrypt |
|
254 @param aPaddingMode The padding mode to use |
|
255 @param aAlgorithmParams Parameters that are specific to a particular algorithm. This is for extendibility and will normally be null. |
|
256 @leave KErrNone if successful; otherwise, a system wide error code. |
|
257 */ |
|
258 virtual void CreateAsyncAsymmetricCipherL(CAsyncAsymmetricCipher*& aCipher, |
|
259 TUid aAlgorithmUid, |
|
260 const CKey& aKey, |
|
261 TUid aCryptoMode, |
|
262 TUid aPaddingMode, |
|
263 const CCryptoParams* aAlgorithmParams) = 0; |
|
264 /** |
|
265 Creates a new instance of a asynchronous signer. |
|
266 |
|
267 @param aSigner A reference to a pointer that should be set to point to the new signer object. |
|
268 @param aAlgorithmUid The algorithm to use. |
|
269 @param aKey The signing key. |
|
270 @param aPaddingMode The padding mode of the signer. |
|
271 @param aAlgorithmParams Parameters that are specific to a particular algorithm. This is for extendibility and will normally be null. |
|
272 @leave KErrNone if successful; otherwise, a system wide error code. |
|
273 */ |
|
274 virtual void CreateAsyncSignerL(CAsyncSigner*& aSigner, |
|
275 TUid aAlgorithmUid, |
|
276 const CKey& aKey, |
|
277 TUid aPaddingMode, |
|
278 const CCryptoParams* aAlgorithmParams) = 0; |
|
279 /** |
|
280 Creates a new instance of a asynchronous verifier. |
|
281 |
|
282 @param aVerifier A reference to a pointer that should be set to point to the new verifier object. |
|
283 @param aAlgorithmUid The algorithm to use |
|
284 @param aKey The key to verify the signature with. |
|
285 @param aPaddingMode The padding mode of the signer. |
|
286 @param aAlgorithmParams Parameters that are specific to a particular algorithm. This is for extendibility and will normally be null. |
|
287 @leave KErrNone if successful; otherwise, a system wide error code. |
|
288 */ |
|
289 virtual void CreateAsyncVerifierL(CAsyncVerifier*& aVerifier, |
|
290 TUid aAlgorithmUid, |
|
291 const CKey& aKey, |
|
292 TUid aPaddingMode, |
|
293 const CCryptoParams* aAlgorithmParams) = 0; |
|
294 |
|
295 /** |
|
296 Creates a new instance of a asynchronous key pair generator. |
|
297 |
|
298 @param aKeyPairGenerator A reference to a pointer that should be set to point to the new asymmetric key pair generator object. |
|
299 @param aKeyAlgorithmUid The algorithm UID |
|
300 @param aAlgorithmParams The parameters that are specific to a particular algorithm. This is for extendibility and will normally be null. |
|
301 @leave KErrNone if successful; otherwise, a system wide error code. |
|
302 */ |
|
303 virtual void CreateAsyncKeyPairGeneratorL(CAsyncKeyPairGenerator*& aKeyPairGenerator, |
|
304 TUid aAlgorithmUid, |
|
305 const CCryptoParams* aAlgorithmParams) = 0; |
|
306 |
|
307 /** |
|
308 Creates a new instance of a asynchronous key agreement system. |
|
309 |
|
310 @param aKeyAgreement A reference to a pointer that should be set to point to the new key agreement object. |
|
311 @param aAlgorithmUid The algorithm to use |
|
312 @param aPrivateKey The private key to combine with the other parties public key during the agreement. |
|
313 @param aAlgorithmParams The parameters that are specific to a particular algorithm. This is for extendibility and will normally be null. |
|
314 @leave KErrNone if successful; otherwise, a system wide error code. |
|
315 */ |
|
316 virtual void CreateAsyncKeyAgreementL(CAsyncKeyAgreement*& aKeyAgreement, |
|
317 TUid aAlgorithmUid, |
|
318 const CKey& aPrivateKey, |
|
319 const CCryptoParams* aAlgorithmParams) = 0; |
|
320 |
|
321 #ifdef SYMBIAN_SDP_IPSEC_VOIP_SUPPORT |
|
322 |
|
323 /** |
|
324 * Create a CMac instance (for software based MAC plug-in dll implementation) |
|
325 * |
|
326 * @param aMac The pointer to CMac. This will be initialised with |
|
327 * the plug-in implementation of the desired MAC algorithm. |
|
328 * @param aAlgorithmUid The specific MAC algorithm desired for evaluation of MAC value. |
|
329 * e.g. MD2, SHA1 or AES-XCBC-MAC-96, AES-XCBC-PRF-128 |
|
330 * @param aKey Symmetric key for calculating message authentication code value. |
|
331 * @param aAlgorithmParams The parameters those are specific to a particular MAC algorithm. |
|
332 * This is for extendibility and will normally be null. |
|
333 * @leave KErrNone if successful; otherwise, leaves with a system wide error code. |
|
334 */ |
|
335 virtual void CreateMacL(CMac*& aMac, |
|
336 const TUid aAlgorithmUid, |
|
337 const CKey& aKey, |
|
338 const CCryptoParams* aAlgorithmParams) = 0; |
|
339 |
|
340 /** |
|
341 * Create a CAsyncMac instance (for hardware based MAC plug-in dll implementation) |
|
342 * |
|
343 * @param aMac The pointer to CMac. This will be initialised with |
|
344 * the plug-in implementation of the desired MAC algorithm. |
|
345 * @param aAlgorithmUid The specific MAC algorithm desired for evaluation of MAC value. |
|
346 * e.g. MD2, SHA1 or AES-XCBC-MAC-96, AES-XCBC-PRF-128 |
|
347 * @param aKey Symmetric key for calculating message authentication code value. |
|
348 * @param aAlgorithmParams The parameters those are specific to a particular MAC algorithm. |
|
349 * This is for extendibility and will normally be null. |
|
350 * @leave KErrNone if successful; otherwise, leaves with a system wide error code. |
|
351 */ |
|
352 virtual void CreateAsyncMacL(CAsyncMac*& aMac, |
|
353 const TUid aAlgorithmUid, |
|
354 const CKey& aKey, |
|
355 const CCryptoParams* aAlgorithmParams) = 0; |
|
356 |
|
357 /** |
|
358 * Create a CHash instance |
|
359 * |
|
360 * @param aHash The pointer to CHash |
|
361 * @param aAlgorithmUid The specific hash algorithm e.g. MD2, SHA1, MD4 |
|
362 * @param aAlgorithmParams The parameters that are specific to a particular |
|
363 * algorithm. This is for extendibility and will normally be null. |
|
364 * @leave KErrNone if successful; otherwise, a system wide error code. |
|
365 */ |
|
366 virtual void CreateHashL(CHash*& aHash, |
|
367 TUid aAlgorithmUid, |
|
368 const CCryptoParams* aAlgorithmParams) = 0; |
|
369 |
|
370 /** |
|
371 * Create a CAsyncHash instance |
|
372 * |
|
373 * @param aAsyncHash The pointer to CAsyncHash |
|
374 * @param aAlgorithmUid The specific hash algorithm e.g. MD2, SHA1, MD4 |
|
375 * @param aAlgorithmParams The parameters that are specific to a particular |
|
376 * algorithm. This is for extendibility and will normally be null. |
|
377 * @leave KErrNone if successful; otherwise, a system wide error code. |
|
378 */ |
|
379 virtual void CreateAsyncHashL(CAsyncHash*& aAsyncHash, |
|
380 TUid aAlgorithmUid, |
|
381 const CCryptoParams* aAlgorithmParams) = 0; |
|
382 |
|
383 #endif |
|
384 }; |
|
385 |
|
386 MPluginSelector::~MPluginSelector() |
|
387 { |
|
388 } |
|
389 } |
|
390 #endif //__CRYPTOAPI_PLUGINSELECTORBASE_H__ |
|
391 |
|
392 |