|
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 * legacy plugin selector implementation |
|
16 * Legacy plugin selector implementation |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 /** |
|
22 @file |
|
23 */ |
|
24 #include "legacyselector.h" |
|
25 #include <cryptospi/plugincharacteristics.h> |
|
26 #include <cryptospi/cryptocharacteristics.h> |
|
27 #include "cryptospiproperty.h" |
|
28 #include <cryptospi/hashplugin.h> |
|
29 #include <cryptospi/randomplugin.h> |
|
30 #include "symmetriccipherplugin.h" |
|
31 #include "asymmetriccipherplugin.h" |
|
32 #include "signerplugin.h" |
|
33 #include "verifierplugin.h" |
|
34 #include "keyagreementplugin.h" |
|
35 #include "keypairgeneratorplugin.h" |
|
36 #include <cryptospi/cryptohashapi.h> |
|
37 #include <cryptospi/cryptorandomapi.h> |
|
38 #include "cryptosymmetriccipherapi.h" |
|
39 #include "cryptoasymmetriccipherapi.h" |
|
40 #include "cryptosignatureapi.h" |
|
41 #include "cryptokeyagreementapi.h" |
|
42 #include "cryptokeypairgeneratorapi.h" |
|
43 #include <cryptospi/pluginentrydef.h> |
|
44 #include "cryptospiutil.h" |
|
45 |
|
46 #ifdef SYMBIAN_SDP_IPSEC_VOIP_SUPPORT |
|
47 #include <cryptospi/macplugin.h> |
|
48 #include <cryptospi/cryptomacapi.h> |
|
49 #endif |
|
50 |
|
51 using namespace CryptoSpi; |
|
52 |
|
53 CLegacySelector* CLegacySelector::NewL() |
|
54 { |
|
55 CLegacySelector* self=CLegacySelector::NewLC(); |
|
56 CleanupStack::Pop(self); |
|
57 return self; |
|
58 } |
|
59 |
|
60 CLegacySelector* CLegacySelector::NewLC() |
|
61 { |
|
62 CLegacySelector* self=new(ELeave) CLegacySelector(); |
|
63 CleanupStack::PushL(self); |
|
64 return self; |
|
65 } |
|
66 CLegacySelector::CLegacySelector() |
|
67 { |
|
68 } |
|
69 |
|
70 CLegacySelector::~CLegacySelector() |
|
71 { |
|
72 iCharacteristicsAndDllIndex.ResetAndDestroy(); |
|
73 } |
|
74 |
|
75 void CLegacySelector::CreateHashL(CHash*& aHash, |
|
76 TUid aAlgorithmUid, |
|
77 TUid aOperationMode, |
|
78 const CKey* aKey, |
|
79 const CCryptoParams* aAlgorithmParams) |
|
80 { |
|
81 CryptoSpiUtil::RetrieveCharacteristicsL(KHashInterface, iCharacteristicsAndDllIndex); |
|
82 TInt found=KErrNone; |
|
83 TInt ret=KErrNone; |
|
84 do |
|
85 { |
|
86 TUid implUid={0}; |
|
87 TFileName fileName; |
|
88 found=FindPlugin(aAlgorithmUid, implUid, fileName); |
|
89 if (found==KErrNone) |
|
90 { |
|
91 //Load the dll and make the handle be sharable in the process |
|
92 RLibrary sharedLib; |
|
93 CryptoSpiUtil::LoadPluginDllLC(sharedLib, fileName); |
|
94 |
|
95 //look for the entry point |
|
96 CreateHashFuncL func=(CreateHashFuncL)sharedLib.Lookup(ECreateHashOrdinal); |
|
97 if (func) |
|
98 { |
|
99 //create the plugin |
|
100 MHash* hashPlugin=NULL; |
|
101 TRAP(ret, (func)(hashPlugin, implUid, aOperationMode, aKey, aAlgorithmParams)) |
|
102 if (ret!=KErrNone) |
|
103 { |
|
104 if (ret==KErrNoMemory) |
|
105 { |
|
106 User::Leave(ret); |
|
107 } |
|
108 CleanupStack::PopAndDestroy(&sharedLib); //sharedLib |
|
109 } |
|
110 else |
|
111 { |
|
112 CleanupClosePushL(*hashPlugin); |
|
113 aHash=CHash::NewL(hashPlugin, sharedLib.Handle()); |
|
114 CleanupStack::Pop(2, &sharedLib); //hashPlugin, sharedLib |
|
115 break; |
|
116 } |
|
117 } |
|
118 else |
|
119 { |
|
120 CleanupStack::PopAndDestroy(&sharedLib); //sharedLib |
|
121 } |
|
122 } |
|
123 } |
|
124 while (found!=KErrNotFound); |
|
125 |
|
126 User::LeaveIfError(ret); |
|
127 if (found!=KErrNone) |
|
128 { |
|
129 User::Leave(KErrNotSupported); |
|
130 } |
|
131 } |
|
132 |
|
133 #ifdef SYMBIAN_SDP_IPSEC_VOIP_SUPPORT |
|
134 |
|
135 void CLegacySelector::CreateHashL(CHash*& aHash, |
|
136 TUid aAlgorithmUid, |
|
137 const CCryptoParams* aAlgorithmParams) |
|
138 { |
|
139 CryptoSpiUtil::RetrieveCharacteristicsL(KHashInterface, iCharacteristicsAndDllIndex); |
|
140 TInt found=KErrNone; |
|
141 TInt ret=KErrNone; |
|
142 do |
|
143 { |
|
144 TUid implUid={0}; |
|
145 TFileName fileName; |
|
146 found=FindPlugin(aAlgorithmUid, implUid, fileName); |
|
147 if (found==KErrNone) |
|
148 { |
|
149 //Load the dll and make the handle be sharable in the process |
|
150 RLibrary sharedLib; |
|
151 CryptoSpiUtil::LoadPluginDllLC(sharedLib, fileName); |
|
152 |
|
153 //look for the entry point |
|
154 CreateHashFuncLv2 func=(CreateHashFuncLv2)sharedLib.Lookup(ECreateHashOrdinalv2); |
|
155 if (func) |
|
156 { |
|
157 //create the plugin |
|
158 MHash* hashPlugin=NULL; |
|
159 TRAP(ret, (func)(hashPlugin, implUid, aAlgorithmParams)) |
|
160 if (ret!=KErrNone) |
|
161 { |
|
162 if (ret==KErrNoMemory) |
|
163 { |
|
164 User::Leave(ret); |
|
165 } |
|
166 CleanupStack::PopAndDestroy(&sharedLib); //sharedLib |
|
167 } |
|
168 else |
|
169 { |
|
170 CleanupClosePushL(*hashPlugin); |
|
171 aHash=CHash::NewL(hashPlugin, sharedLib.Handle()); |
|
172 CleanupStack::Pop(2, &sharedLib); //hashPlugin, sharedLib |
|
173 break; |
|
174 } |
|
175 } |
|
176 else |
|
177 { |
|
178 CleanupStack::PopAndDestroy(&sharedLib); //sharedLib |
|
179 } |
|
180 } |
|
181 } |
|
182 while (found!=KErrNotFound); |
|
183 |
|
184 User::LeaveIfError(ret); |
|
185 if (found!=KErrNone) |
|
186 { |
|
187 User::Leave(KErrNotSupported); |
|
188 } |
|
189 } |
|
190 |
|
191 void CLegacySelector::CreateMacL(CMac*& aMac, |
|
192 TUid aAlgorithmUid, |
|
193 const CKey& aKey, |
|
194 const CCryptoParams* aAlgorithmParams) |
|
195 { |
|
196 CryptoSpiUtil::RetrieveCharacteristicsL(KMacInterface, iCharacteristicsAndDllIndex); |
|
197 TInt found=KErrNone; |
|
198 TInt ret=KErrNone; |
|
199 do |
|
200 { |
|
201 TUid implUid={0}; |
|
202 TFileName fileName; |
|
203 found=FindPlugin(aAlgorithmUid, implUid, fileName); |
|
204 if (found==KErrNone) |
|
205 { |
|
206 //Load the dll and make the handle be sharable in the process |
|
207 RLibrary sharedLib; |
|
208 CryptoSpiUtil::LoadPluginDllLC(sharedLib, fileName); |
|
209 |
|
210 //look for the entry point |
|
211 CreateMacFuncL func=(CreateMacFuncL)sharedLib.Lookup(ECreateMacOrdinal); |
|
212 if (func) |
|
213 { |
|
214 //create the plugin |
|
215 MMac* macPlugin=NULL; |
|
216 |
|
217 TRAP(ret, (func)(macPlugin, implUid, aKey, aAlgorithmParams)) |
|
218 if (ret!=KErrNone) |
|
219 { |
|
220 if (ret==KErrNoMemory) |
|
221 { |
|
222 User::Leave(ret); |
|
223 } |
|
224 CleanupStack::PopAndDestroy(&sharedLib); //sharedLib |
|
225 } |
|
226 else |
|
227 { |
|
228 CleanupClosePushL(*macPlugin); |
|
229 aMac=CMac::NewL(macPlugin, sharedLib.Handle()); |
|
230 CleanupStack::Pop(2, &sharedLib); //macPlugin, sharedLib |
|
231 break; |
|
232 } |
|
233 } |
|
234 else |
|
235 { |
|
236 CleanupStack::PopAndDestroy(&sharedLib); //sharedLib |
|
237 } |
|
238 } |
|
239 } |
|
240 while (found!=KErrNotFound); |
|
241 |
|
242 User::LeaveIfError(ret); |
|
243 if (found!=KErrNone) |
|
244 { |
|
245 User::Leave(KErrNotSupported); |
|
246 } |
|
247 } |
|
248 |
|
249 #endif |
|
250 |
|
251 void CLegacySelector::CreateRandomL(CRandom*& aRandom, |
|
252 TUid aAlgorithmUid, |
|
253 const CCryptoParams* aAlgorithmParams) |
|
254 { |
|
255 CryptoSpiUtil::RetrieveCharacteristicsL(KRandomInterface, iCharacteristicsAndDllIndex); |
|
256 TInt found=KErrNone; |
|
257 TInt ret=KErrNone; |
|
258 do |
|
259 { |
|
260 TFileName fileName; |
|
261 TUid implUid={0}; |
|
262 found=FindPlugin(aAlgorithmUid, implUid, fileName); |
|
263 if (found==KErrNone) |
|
264 { |
|
265 //Load the dll and make the handle be sharable in the process |
|
266 RLibrary sharedLib; |
|
267 CryptoSpiUtil::LoadPluginDllLC(sharedLib, fileName); |
|
268 |
|
269 //look for the entry point |
|
270 CreateRandomFuncL func=(CreateRandomFuncL)sharedLib.Lookup(ECreateRandomOrdinal); |
|
271 |
|
272 if (func) |
|
273 { |
|
274 //create the plugin |
|
275 MRandom* randomPlugin=NULL; |
|
276 TRAP(ret, (func)(randomPlugin, implUid, aAlgorithmParams)) |
|
277 if (ret!=KErrNone) |
|
278 { |
|
279 if (ret==KErrNoMemory) |
|
280 { |
|
281 User::Leave(ret); |
|
282 } |
|
283 CleanupStack::PopAndDestroy(&sharedLib); //sharedLib |
|
284 } |
|
285 else |
|
286 { |
|
287 CleanupClosePushL(*randomPlugin); |
|
288 aRandom=CRandom::NewL(randomPlugin, sharedLib.Handle()); |
|
289 CleanupStack::Pop(2, &sharedLib); //randomPlugin, sharedLib |
|
290 break; |
|
291 } |
|
292 } |
|
293 else |
|
294 { |
|
295 CleanupStack::PopAndDestroy(&sharedLib); //sharedLib |
|
296 } |
|
297 } |
|
298 } |
|
299 while (found!=KErrNotFound); |
|
300 |
|
301 User::LeaveIfError(ret); |
|
302 if (found!=KErrNone) |
|
303 { |
|
304 User::Leave(KErrNotSupported); |
|
305 } |
|
306 } |
|
307 |
|
308 void CLegacySelector::CreateSymmetricCipherL(CSymmetricCipher*& aCipher, |
|
309 TUid aAlgorithmUid, |
|
310 const CKey& aKey, |
|
311 TUid aCryptoMode, |
|
312 TUid aOperationMode, |
|
313 TUid aPaddingMode, |
|
314 const CCryptoParams* aAlgorithmParams) |
|
315 |
|
316 { |
|
317 CryptoSpiUtil::RetrieveCharacteristicsL(KSymmetricCipherInterface, iCharacteristicsAndDllIndex); |
|
318 TInt found=KErrNone; |
|
319 TInt ret=KErrNone; |
|
320 do |
|
321 { |
|
322 TFileName fileName; |
|
323 TUid implUid={0}; |
|
324 found=FindPlugin(aAlgorithmUid, implUid, fileName); |
|
325 if (found==KErrNone) |
|
326 { |
|
327 //Load the dll and make the handle be sharable in the process |
|
328 RLibrary sharedLib; |
|
329 CryptoSpiUtil::LoadPluginDllLC(sharedLib, fileName); |
|
330 |
|
331 //look for the entry point |
|
332 CreateSymmetricCipherFuncL func=(CreateSymmetricCipherFuncL)sharedLib.Lookup(ECreateSymmetricCipherOrdinal); |
|
333 if (func) |
|
334 { |
|
335 //create the plugin |
|
336 MSymmetricCipher* cipherPlugin=NULL; |
|
337 TRAP(ret, (func)(cipherPlugin, implUid, aKey, aCryptoMode, aOperationMode, aPaddingMode, aAlgorithmParams)) |
|
338 if (ret!=KErrNone) |
|
339 { |
|
340 if (ret==KErrNoMemory) |
|
341 { |
|
342 User::Leave(ret); |
|
343 } |
|
344 CleanupStack::PopAndDestroy(&sharedLib); //sharedLib |
|
345 } |
|
346 else |
|
347 { |
|
348 CleanupClosePushL(*cipherPlugin); |
|
349 aCipher=CSymmetricCipher::NewL(cipherPlugin, sharedLib.Handle()); |
|
350 CleanupStack::Pop(2, &sharedLib); //cipherPlugin, sharedLib |
|
351 break; |
|
352 } |
|
353 } |
|
354 else |
|
355 { |
|
356 CleanupStack::PopAndDestroy(&sharedLib); //sharedLib |
|
357 } |
|
358 } |
|
359 } |
|
360 while (found!=KErrNotFound); |
|
361 |
|
362 User::LeaveIfError(ret); |
|
363 if (found!=KErrNone) |
|
364 { |
|
365 User::Leave(KErrNotSupported); |
|
366 } |
|
367 } |
|
368 |
|
369 void CLegacySelector::CreateAsymmetricCipherL(CAsymmetricCipher*& aCipher, |
|
370 TUid aAlgorithmUid, |
|
371 const CKey& aKey, |
|
372 TUid aCryptoMode, |
|
373 TUid aPaddingMode, |
|
374 const CCryptoParams* aAlgorithmParams) |
|
375 { |
|
376 CryptoSpiUtil::RetrieveCharacteristicsL(KAsymmetricCipherInterface, iCharacteristicsAndDllIndex); |
|
377 TInt found=KErrNone; |
|
378 TInt ret=KErrNone; |
|
379 do |
|
380 { |
|
381 TFileName fileName; |
|
382 TUid implUid={0}; |
|
383 found=FindPlugin(aAlgorithmUid, implUid, fileName); |
|
384 if (found==KErrNone) |
|
385 { |
|
386 //Load the dll and make the handle be sharable in the process |
|
387 RLibrary sharedLib; |
|
388 CryptoSpiUtil::LoadPluginDllLC(sharedLib, fileName); |
|
389 |
|
390 //look for the entry point |
|
391 CreateAsymmetricCipherFuncL func=(CreateAsymmetricCipherFuncL)sharedLib.Lookup(ECreateAsymmetricCipherOrdinal); |
|
392 |
|
393 if (func) |
|
394 { |
|
395 //create the plugin |
|
396 MAsymmetricCipher* cipherPlugin=NULL; |
|
397 TRAP(ret, (func)(cipherPlugin, implUid, aKey, aCryptoMode, aPaddingMode, aAlgorithmParams)) |
|
398 if (ret!=KErrNone) |
|
399 { |
|
400 if (ret==KErrNoMemory) |
|
401 { |
|
402 User::Leave(ret); |
|
403 } |
|
404 CleanupStack::PopAndDestroy(&sharedLib); //sharedLib |
|
405 } |
|
406 else |
|
407 { |
|
408 CleanupClosePushL(*cipherPlugin); |
|
409 aCipher=CAsymmetricCipher::NewL(cipherPlugin, sharedLib.Handle()); |
|
410 CleanupStack::Pop(2, &sharedLib); //cipherPlugin, sharedLib |
|
411 break; |
|
412 } |
|
413 } |
|
414 else |
|
415 { |
|
416 CleanupStack::PopAndDestroy(&sharedLib); //sharedLib |
|
417 } |
|
418 } |
|
419 } |
|
420 while (found!=KErrNotFound); |
|
421 |
|
422 User::LeaveIfError(ret); |
|
423 if (found!=KErrNone) |
|
424 { |
|
425 User::Leave(KErrNotSupported); |
|
426 } |
|
427 } |
|
428 |
|
429 void CLegacySelector::CreateSignerL(CSigner*& aSigner, |
|
430 TUid aAlgorithmUid, |
|
431 const CKey& aKey, |
|
432 TUid aPaddingMode, |
|
433 const CCryptoParams* aAlgorithmParams) |
|
434 { |
|
435 CryptoSpiUtil::RetrieveCharacteristicsL(KSignerInterface, iCharacteristicsAndDllIndex); |
|
436 TInt found=KErrNone; |
|
437 TInt ret=KErrNone; |
|
438 do |
|
439 { |
|
440 TFileName fileName; |
|
441 TUid implUid={0}; |
|
442 found=FindPlugin(aAlgorithmUid, implUid, fileName); |
|
443 if (found==KErrNone) |
|
444 { |
|
445 //Load the dll and make the handle be sharable in the process |
|
446 RLibrary sharedLib; |
|
447 CryptoSpiUtil::LoadPluginDllLC(sharedLib, fileName); |
|
448 |
|
449 //look for the entry point |
|
450 CreateSignerFuncL func=(CreateSignerFuncL)sharedLib.Lookup(ECreateSignerOrdinal); |
|
451 if (func) |
|
452 { |
|
453 //create the plugin |
|
454 MSigner* plugin=NULL; |
|
455 TRAP(ret, (func)(plugin, implUid, aKey, aPaddingMode, aAlgorithmParams)) |
|
456 if (ret!=KErrNone) |
|
457 { |
|
458 if (ret==KErrNoMemory) |
|
459 { |
|
460 User::Leave(ret); |
|
461 } |
|
462 CleanupStack::PopAndDestroy(&sharedLib); //sharedLib |
|
463 } |
|
464 else |
|
465 { |
|
466 CleanupClosePushL(*plugin); |
|
467 aSigner=CSigner::NewL(plugin, sharedLib.Handle()); |
|
468 CleanupStack::Pop(2, &sharedLib); //plugin, sharedLib |
|
469 break; |
|
470 } |
|
471 } |
|
472 else |
|
473 { |
|
474 CleanupStack::PopAndDestroy(&sharedLib); //sharedLib |
|
475 } |
|
476 } |
|
477 } |
|
478 while (found!=KErrNotFound); |
|
479 |
|
480 User::LeaveIfError(ret); |
|
481 if (found!=KErrNone) |
|
482 { |
|
483 User::Leave(KErrNotSupported); |
|
484 } |
|
485 } |
|
486 |
|
487 void CLegacySelector::CreateVerifierL(CVerifier*& aVerifier, |
|
488 TUid aAlgorithmUid, |
|
489 const CKey& aKey, |
|
490 TUid aPaddingMode, |
|
491 const CCryptoParams* aAlgorithmParams) |
|
492 { |
|
493 CryptoSpiUtil::RetrieveCharacteristicsL(KVerifierInterface, iCharacteristicsAndDllIndex); |
|
494 TInt found=KErrNone; |
|
495 TInt ret=KErrNone; |
|
496 do |
|
497 { |
|
498 TFileName fileName; |
|
499 TUid implUid={0}; |
|
500 found=FindPlugin(aAlgorithmUid, implUid, fileName); |
|
501 if (found==KErrNone) |
|
502 { |
|
503 //Load the dll and make the handle be sharable in the process |
|
504 RLibrary sharedLib; |
|
505 CryptoSpiUtil::LoadPluginDllLC(sharedLib, fileName); |
|
506 |
|
507 //look for the entry point |
|
508 CreateVerifierFuncL func=(CreateVerifierFuncL)sharedLib.Lookup(ECreateVerifierOrdinal); |
|
509 if (func) |
|
510 { |
|
511 //create the plugin |
|
512 MVerifier* plugin=NULL; |
|
513 TRAP(ret, (func)(plugin, implUid, aKey, aPaddingMode, aAlgorithmParams)) |
|
514 if (ret!=KErrNone) |
|
515 { |
|
516 if (ret==KErrNoMemory) |
|
517 { |
|
518 User::Leave(ret); |
|
519 } |
|
520 CleanupStack::PopAndDestroy(&sharedLib); //sharedLib |
|
521 } |
|
522 else |
|
523 { |
|
524 CleanupClosePushL(*plugin); |
|
525 aVerifier=CVerifier::NewL(plugin, sharedLib.Handle()); |
|
526 CleanupStack::Pop(2, &sharedLib); //plugin, sharedLib |
|
527 break; |
|
528 } |
|
529 } |
|
530 else |
|
531 { |
|
532 CleanupStack::PopAndDestroy(&sharedLib); //sharedLib |
|
533 } |
|
534 } |
|
535 } |
|
536 while (found!=KErrNotFound); |
|
537 |
|
538 User::LeaveIfError(ret); |
|
539 if (found!=KErrNone) |
|
540 { |
|
541 User::Leave(KErrNotSupported); |
|
542 } |
|
543 } |
|
544 |
|
545 void CLegacySelector::CreateKeyPairGeneratorL(CKeyPairGenerator*& aKeyPairGenerator, |
|
546 TUid aAlgorithmUid, |
|
547 const CCryptoParams* aAlgorithmParams) |
|
548 { |
|
549 CryptoSpiUtil::RetrieveCharacteristicsL(KKeypairGeneratorInterface, iCharacteristicsAndDllIndex); |
|
550 TInt found=KErrNone; |
|
551 TInt ret=KErrNone; |
|
552 do |
|
553 { |
|
554 TFileName fileName; |
|
555 TUid implUid={0}; |
|
556 found=FindPlugin(aAlgorithmUid, implUid, fileName); |
|
557 if (found==KErrNone) |
|
558 { |
|
559 //Load the dll and make the handle be sharable in the process |
|
560 RLibrary sharedLib; |
|
561 CryptoSpiUtil::LoadPluginDllLC(sharedLib, fileName); |
|
562 |
|
563 //look for the entry point |
|
564 CreateKeyPairGeneratorFuncL func=(CreateKeyPairGeneratorFuncL)sharedLib.Lookup(ECreateKeyPairGeneratorOrdinal); |
|
565 if (func) |
|
566 { |
|
567 //create the plugin |
|
568 MKeyPairGenerator* plugin=NULL; |
|
569 TRAP(ret, (func)(plugin, implUid, aAlgorithmParams)) |
|
570 if (ret!=KErrNone) |
|
571 { |
|
572 if (ret==KErrNoMemory) |
|
573 { |
|
574 User::Leave(ret); |
|
575 } |
|
576 CleanupStack::PopAndDestroy(&sharedLib); //sharedLib |
|
577 } |
|
578 else |
|
579 { |
|
580 CleanupClosePushL(*plugin); |
|
581 aKeyPairGenerator=CKeyPairGenerator::NewL(plugin, sharedLib.Handle()); |
|
582 CleanupStack::Pop(2, &sharedLib); //plugin, sharedLib |
|
583 break; |
|
584 } |
|
585 } |
|
586 else |
|
587 { |
|
588 CleanupStack::PopAndDestroy(&sharedLib); //sharedLib |
|
589 } |
|
590 } |
|
591 } |
|
592 while (found!=KErrNotFound); |
|
593 |
|
594 User::LeaveIfError(ret); |
|
595 if (found!=KErrNone) |
|
596 { |
|
597 User::Leave(KErrNotSupported); |
|
598 } |
|
599 } |
|
600 |
|
601 void CLegacySelector::CreateKeyAgreementL(CKeyAgreement*& aKeyAgreement, |
|
602 TUid aAlgorithmUid, |
|
603 const CKey& aPrivateKey, |
|
604 const CCryptoParams* aAlgorithmParams) |
|
605 { |
|
606 CryptoSpiUtil::RetrieveCharacteristicsL(KKeyAgreementInterface, iCharacteristicsAndDllIndex); |
|
607 TInt found=KErrNone; |
|
608 TInt ret=KErrNone; |
|
609 do |
|
610 { |
|
611 TFileName fileName; |
|
612 TUid implUid={0}; |
|
613 found=FindPlugin(aAlgorithmUid, implUid, fileName); |
|
614 if (found==KErrNone) |
|
615 { |
|
616 //Load the dll and make the handle be sharable in the process |
|
617 RLibrary sharedLib; |
|
618 CryptoSpiUtil::LoadPluginDllLC(sharedLib, fileName); |
|
619 |
|
620 //look for the entry point |
|
621 CreateKeyAgreementFuncL func=(CreateKeyAgreementFuncL)sharedLib.Lookup(ECreateKeyAgreementOrdinal); |
|
622 if (func) |
|
623 { |
|
624 //create the plugin |
|
625 MKeyAgreement* plugin=NULL; |
|
626 TRAP(ret, (func)(plugin, implUid, aPrivateKey, aAlgorithmParams)) |
|
627 if (ret!=KErrNone) |
|
628 { |
|
629 if (ret==KErrNoMemory) |
|
630 { |
|
631 User::Leave(ret); |
|
632 } |
|
633 CleanupStack::PopAndDestroy(&sharedLib); //sharedLib |
|
634 } |
|
635 else |
|
636 { |
|
637 CleanupClosePushL(*plugin); |
|
638 aKeyAgreement=CKeyAgreement::NewL(plugin, sharedLib.Handle()); |
|
639 CleanupStack::Pop(2, &sharedLib); //plugin, sharedLib |
|
640 break; |
|
641 } |
|
642 } |
|
643 else |
|
644 { |
|
645 CleanupStack::PopAndDestroy(&sharedLib); //sharedLib |
|
646 } |
|
647 } |
|
648 } |
|
649 while (found!=KErrNotFound); |
|
650 |
|
651 User::LeaveIfError(ret); |
|
652 if (found!=KErrNone) |
|
653 { |
|
654 User::Leave(KErrNotSupported); |
|
655 } |
|
656 } |
|
657 |
|
658 TInt CLegacySelector::FindPlugin(TUid aAlgorithmUid, TUid& aImplementationUid, TFileName& aDllName) |
|
659 { |
|
660 TInt ret=KErrNone; |
|
661 TInt count=iCharacteristicsAndDllIndex.Count(); |
|
662 TBool found(EFalse); |
|
663 for (TInt i=iNextCharacteristic;i<count;i++) |
|
664 { |
|
665 if (aAlgorithmUid.iUid==iCharacteristicsAndDllIndex[i]->iCharacteristic->iAlgorithmUid) |
|
666 { |
|
667 aImplementationUid.iUid=iCharacteristicsAndDllIndex[i]->iCharacteristic->iImplementationUid; |
|
668 aDllName=iCharacteristicsAndDllIndex[i]->iDllName; |
|
669 found=ETrue; |
|
670 iNextCharacteristic=i+1; |
|
671 break; |
|
672 } |
|
673 } |
|
674 if (!found) |
|
675 { |
|
676 ret=KErrNotFound; |
|
677 } |
|
678 return ret; |
|
679 } |
|
680 |
|
681 |
|
682 // These are stub methods for asynchronous calls, which are |
|
683 // not implemented. Turn off the coverage for these methods. |
|
684 #ifdef _BullseyeCoverage |
|
685 #pragma suppress_warnings on |
|
686 #pragma BullseyeCoverage off |
|
687 #pragma suppress_warnings off |
|
688 #endif |
|
689 |
|
690 void CLegacySelector::CreateAsyncHashL(CAsyncHash*& /*aHash*/, |
|
691 TUid /*aAlgorithmUid*/, |
|
692 TUid /*aOperationMode*/, |
|
693 const CKey* /*aKey*/, |
|
694 const CCryptoParams* /*aAlgorithmParams*/) |
|
695 { |
|
696 User::Leave(KErrNotSupported); |
|
697 } |
|
698 |
|
699 #ifdef SYMBIAN_SDP_IPSEC_VOIP_SUPPORT |
|
700 |
|
701 void CLegacySelector::CreateAsyncHashL(CAsyncHash*& /*aHash*/, |
|
702 TUid /*aAlgorithmUid*/, |
|
703 const CCryptoParams* /*aAlgorithmParams*/) |
|
704 { |
|
705 User::Leave(KErrNotSupported); |
|
706 } |
|
707 |
|
708 |
|
709 void CLegacySelector::CreateAsyncMacL(CAsyncMac*& /*aMac*/, |
|
710 const TUid /*aAlgorithmUid*/, |
|
711 const CKey& /*aKey*/, |
|
712 const CCryptoParams* /*aAlgorithmParams*/) |
|
713 { |
|
714 User::Leave(KErrNotSupported); |
|
715 } |
|
716 |
|
717 #endif |
|
718 |
|
719 void CLegacySelector::CreateAsyncRandomL(CAsyncRandom*& /*aRandom*/, |
|
720 TUid /*aAlgorithmUid*/, |
|
721 const CCryptoParams* /*aAlgorithmParams*/) |
|
722 |
|
723 { |
|
724 User::Leave(KErrNotSupported); |
|
725 } |
|
726 |
|
727 void CLegacySelector::CreateAsyncSymmetricCipherL(CAsyncSymmetricCipher*& /*aCipher*/, |
|
728 TUid /*aAlgorithmUid*/, |
|
729 const CKey& /*aKey*/, |
|
730 TUid /*aCryptoMode*/, |
|
731 TUid /*aOperationMode*/, |
|
732 TUid /*aPaddingMode*/, |
|
733 const CCryptoParams* /*aAlgorithmParams*/) |
|
734 |
|
735 { |
|
736 User::Leave(KErrNotSupported); |
|
737 } |
|
738 |
|
739 void CLegacySelector::CreateAsyncAsymmetricCipherL(CAsyncAsymmetricCipher*& /*aCipher*/, |
|
740 TUid /*aAlgorithmUid*/, |
|
741 const CKey& /*aKey*/, |
|
742 TUid /*aCryptoMode*/, |
|
743 TUid /*aPaddingMode*/, |
|
744 const CCryptoParams* /*aAlgorithmParams*/) |
|
745 { |
|
746 User::Leave(KErrNotSupported); |
|
747 } |
|
748 |
|
749 |
|
750 void CLegacySelector::CreateAsyncSignerL(CAsyncSigner*& /*aSigner*/, |
|
751 TUid /*aAlgorithmUid*/, |
|
752 const CKey& /*aKey*/, |
|
753 TUid /*aPaddingMode*/, |
|
754 const CCryptoParams* /*aAlgorithmParams*/) |
|
755 { |
|
756 User::Leave(KErrNotSupported); |
|
757 } |
|
758 |
|
759 |
|
760 void CLegacySelector::CreateAsyncVerifierL(CAsyncVerifier*& /*aVerifier*/, |
|
761 TUid /*aAlgorithmUid*/, |
|
762 const CKey& /*aKey*/, |
|
763 TUid /*aPaddingMode*/, |
|
764 const CCryptoParams* /*aAlgorithmParams*/) |
|
765 { |
|
766 User::Leave(KErrNotSupported); |
|
767 } |
|
768 |
|
769 |
|
770 void CLegacySelector::CreateAsyncKeyPairGeneratorL(CAsyncKeyPairGenerator*& /*aKeyPairGenerator*/, |
|
771 TUid /*aAlgorithmUid*/, |
|
772 const CCryptoParams* /*aAlgorithmParams*/) |
|
773 { |
|
774 User::Leave(KErrNotSupported); |
|
775 } |
|
776 |
|
777 |
|
778 void CLegacySelector::CreateAsyncKeyAgreementL(CAsyncKeyAgreement*& /*aKeyAgreement*/, |
|
779 TUid /*aAlgorithmUid*/, |
|
780 const CKey& /*aPrivateKey*/, |
|
781 const CCryptoParams* /*aAlgorithmParams*/) |
|
782 { |
|
783 User::Leave(KErrNotSupported); |
|
784 } |
|
785 |