|
1 /* |
|
2 * Copyright (c) 2007-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 * crypto plugins loader implementation |
|
16 * crypto spi state implementation |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 /** |
|
22 @file |
|
23 */ |
|
24 |
|
25 #include <cryptospi/cryptocharacteristics.h> |
|
26 #include <cryptospi/cryptospidef.h> |
|
27 #include "cryptospiutil.h" |
|
28 #include <cryptospi/extendedcharacteristics.h> |
|
29 |
|
30 |
|
31 using namespace CryptoSpi; |
|
32 |
|
33 |
|
34 // |
|
35 // Implementation of CCharacteristics |
|
36 // |
|
37 CCharacteristics::CCharacteristics() |
|
38 { |
|
39 } |
|
40 |
|
41 CCharacteristics::~CCharacteristics() |
|
42 { |
|
43 iCreatorName.Close(); |
|
44 iAlgorithmName.Close(); |
|
45 } |
|
46 |
|
47 void CCharacteristics::InternalizeL(RReadStream& aStream) |
|
48 { |
|
49 iInterfaceUid=aStream.ReadInt32L(); |
|
50 iAlgorithmUid=aStream.ReadInt32L(); |
|
51 iImplementationUid=aStream.ReadInt32L(); |
|
52 iCreatorName.CreateL(aStream, KMaxFileName); |
|
53 iIsFIPSApproved=aStream.ReadInt8L(); |
|
54 iIsHardwareSupported=aStream.ReadInt8L(); |
|
55 iMaxConcurrencySupported=aStream.ReadUint32L(); |
|
56 iAlgorithmName.CreateL(aStream, KMaxFileName); |
|
57 iLatency=aStream.ReadInt32L(); |
|
58 iThroughput=aStream.ReadInt32L(); |
|
59 } |
|
60 |
|
61 // |
|
62 // Implementation of CHashCharacteristics |
|
63 // |
|
64 CHashCharacteristics* CHashCharacteristics::NewL() |
|
65 { |
|
66 CHashCharacteristics* self=CHashCharacteristics::NewLC(); |
|
67 CleanupStack::Pop(self); |
|
68 return self; |
|
69 } |
|
70 |
|
71 CHashCharacteristics* CHashCharacteristics::NewLC() |
|
72 { |
|
73 CHashCharacteristics* self=new(ELeave) CHashCharacteristics(); |
|
74 CleanupStack::PushL(self); |
|
75 return self; |
|
76 } |
|
77 |
|
78 CHashCharacteristics::~CHashCharacteristics() |
|
79 { |
|
80 iSupportedOperationModes.Close(); |
|
81 } |
|
82 |
|
83 CHashCharacteristics::CHashCharacteristics() |
|
84 { |
|
85 } |
|
86 |
|
87 void CHashCharacteristics::InternalizeL(RReadStream& aStream) |
|
88 { |
|
89 CCharacteristics::InternalizeL(aStream); |
|
90 iBlockSize=aStream.ReadUint32L(); |
|
91 iOutputSize=aStream.ReadUint32L(); |
|
92 TUint32 count=aStream.ReadUint32L(); |
|
93 for (TUint i=0;i<count;i++) |
|
94 { |
|
95 TInt32 mode=aStream.ReadInt32L(); |
|
96 iSupportedOperationModes.AppendL(mode); |
|
97 } |
|
98 } |
|
99 |
|
100 TBool CHashCharacteristics::IsOperationModeSupported(TUid aOperationMode) const |
|
101 { |
|
102 // Sanity check to catch incorrect casts of characteristics classes |
|
103 ASSERT(iInterfaceUid == KHashInterface); |
|
104 |
|
105 TInt count(iSupportedOperationModes.Count()); |
|
106 TBool supported(EFalse); |
|
107 |
|
108 for (TInt i = 0; i < count; ++i) |
|
109 { |
|
110 if (iSupportedOperationModes[i] == aOperationMode.iUid) |
|
111 { |
|
112 supported = ETrue; |
|
113 break; |
|
114 } |
|
115 } |
|
116 |
|
117 return supported; |
|
118 } |
|
119 |
|
120 #ifdef SYMBIAN_SDP_IPSEC_VOIP_SUPPORT |
|
121 // |
|
122 // Implementation of CMacCharacteristics |
|
123 // |
|
124 CMacCharacteristics* CMacCharacteristics::NewL() |
|
125 { |
|
126 CMacCharacteristics* self=CMacCharacteristics::NewLC(); |
|
127 CleanupStack::Pop(self); |
|
128 return self; |
|
129 } |
|
130 |
|
131 CMacCharacteristics* CMacCharacteristics::NewLC() |
|
132 { |
|
133 CMacCharacteristics* self=new(ELeave) CMacCharacteristics(); |
|
134 CleanupStack::PushL(self); |
|
135 return self; |
|
136 } |
|
137 |
|
138 CMacCharacteristics::~CMacCharacteristics() |
|
139 { |
|
140 delete iAlgorithmChar; |
|
141 } |
|
142 |
|
143 CMacCharacteristics::CMacCharacteristics() |
|
144 { |
|
145 } |
|
146 |
|
147 void CMacCharacteristics::InternalizeL(RReadStream& aStream) |
|
148 { |
|
149 CCharacteristics::InternalizeL(aStream); |
|
150 iMacMode = aStream.ReadUint32L(); |
|
151 if(iMacMode == KHmacMode) |
|
152 { |
|
153 iAlgorithmChar = CHashCharacteristics::NewL(); |
|
154 } |
|
155 else if (iMacMode == KSymmetricCipherMode) |
|
156 { |
|
157 iAlgorithmChar = CSymmetricCipherCharacteristics::NewL(); |
|
158 } |
|
159 User::LeaveIfNull(iAlgorithmChar); |
|
160 iAlgorithmChar->InternalizeL(aStream); |
|
161 } |
|
162 #endif |
|
163 // |
|
164 // Implementation of CRandomCharacteristics |
|
165 // |
|
166 CRandomCharacteristics* CRandomCharacteristics::NewL() |
|
167 { |
|
168 CRandomCharacteristics* self=CRandomCharacteristics::NewLC(); |
|
169 CleanupStack::Pop(self); |
|
170 return self; |
|
171 } |
|
172 |
|
173 CRandomCharacteristics* CRandomCharacteristics::NewLC() |
|
174 { |
|
175 CRandomCharacteristics* self=new(ELeave) CRandomCharacteristics(); |
|
176 CleanupStack::PushL(self); |
|
177 return self; |
|
178 } |
|
179 |
|
180 CRandomCharacteristics::~CRandomCharacteristics() |
|
181 { |
|
182 } |
|
183 |
|
184 CRandomCharacteristics::CRandomCharacteristics() |
|
185 { |
|
186 } |
|
187 |
|
188 void CRandomCharacteristics::InternalizeL(RReadStream& aStream) |
|
189 { |
|
190 CCharacteristics::InternalizeL(aStream); |
|
191 iBlockingMode=aStream.ReadUint32L(); |
|
192 } |
|
193 |
|
194 // |
|
195 // Implementation of CSymmetricCipherCharacteristics |
|
196 // |
|
197 CSymmetricCipherCharacteristics* CSymmetricCipherCharacteristics::NewL() |
|
198 { |
|
199 CSymmetricCipherCharacteristics* self=CSymmetricCipherCharacteristics::NewLC(); |
|
200 CleanupStack::Pop(self); |
|
201 return self; |
|
202 } |
|
203 |
|
204 CSymmetricCipherCharacteristics* CSymmetricCipherCharacteristics::NewLC() |
|
205 { |
|
206 CSymmetricCipherCharacteristics* self=new(ELeave) CSymmetricCipherCharacteristics(); |
|
207 CleanupStack::PushL(self); |
|
208 return self; |
|
209 } |
|
210 |
|
211 CSymmetricCipherCharacteristics::~CSymmetricCipherCharacteristics() |
|
212 { |
|
213 iSupportedPaddingModes.Close(); |
|
214 iSupportedOperationModes.Close(); |
|
215 } |
|
216 |
|
217 CSymmetricCipherCharacteristics::CSymmetricCipherCharacteristics() |
|
218 { |
|
219 } |
|
220 |
|
221 void CSymmetricCipherCharacteristics::InternalizeL(RReadStream& aStream) |
|
222 { |
|
223 CCharacteristics::InternalizeL(aStream); |
|
224 iMaximumKeyLength=aStream.ReadUint32L(); |
|
225 iBlockSize=aStream.ReadUint32L(); |
|
226 TUint32 count=aStream.ReadUint32L(); |
|
227 for (TUint i=0;i<count;i++) |
|
228 { |
|
229 TInt32 mode=aStream.ReadInt32L(); |
|
230 iSupportedPaddingModes.AppendL(mode); |
|
231 } |
|
232 |
|
233 count=aStream.ReadUint32L(); |
|
234 for (TUint j=0;j<count;j++) |
|
235 { |
|
236 TInt32 mode=aStream.ReadInt32L(); |
|
237 iSupportedOperationModes.AppendL(mode); |
|
238 } |
|
239 iKeySupportMode=aStream.ReadInt32L(); |
|
240 } |
|
241 |
|
242 TBool CSymmetricCipherCharacteristics::IsOperationModeSupported(TUid aOperationMode) const |
|
243 { |
|
244 // Sanity check to catch incorrect casts of characteristics classes |
|
245 ASSERT(iInterfaceUid == KSymmetricCipherInterface); |
|
246 |
|
247 TBool supported(EFalse); |
|
248 TInt count(iSupportedOperationModes.Count()); |
|
249 |
|
250 for (TInt i = 0; i < count; ++i) |
|
251 { |
|
252 if (iSupportedOperationModes[i] == aOperationMode.iUid) |
|
253 { |
|
254 supported = ETrue; |
|
255 break; |
|
256 } |
|
257 } |
|
258 return supported; |
|
259 } |
|
260 |
|
261 TBool CSymmetricCipherCharacteristics::IsPaddingModeSupported(TUid aPaddingMode) const |
|
262 { |
|
263 // Sanity check to catch incorrect casts of characteristics classes |
|
264 ASSERT(iInterfaceUid == KSymmetricCipherInterface); |
|
265 |
|
266 TBool supported(EFalse); |
|
267 TInt count(iSupportedPaddingModes.Count()); |
|
268 |
|
269 for (TInt i = 0; i < count; ++i) |
|
270 { |
|
271 if (iSupportedPaddingModes[i] == aPaddingMode.iUid) |
|
272 { |
|
273 supported = ETrue; |
|
274 break; |
|
275 } |
|
276 } |
|
277 return supported; |
|
278 } |
|
279 |
|
280 // |
|
281 // Implementation of CAsymmetricCipherCharacteristics |
|
282 // |
|
283 CAsymmetricCipherCharacteristics* CAsymmetricCipherCharacteristics::NewL() |
|
284 { |
|
285 CAsymmetricCipherCharacteristics* self=CAsymmetricCipherCharacteristics::NewLC(); |
|
286 CleanupStack::Pop(self); |
|
287 return self; |
|
288 } |
|
289 |
|
290 CAsymmetricCipherCharacteristics* CAsymmetricCipherCharacteristics::NewLC() |
|
291 { |
|
292 CAsymmetricCipherCharacteristics* self=new(ELeave) CAsymmetricCipherCharacteristics(); |
|
293 CleanupStack::PushL(self); |
|
294 return self; |
|
295 } |
|
296 |
|
297 CAsymmetricCipherCharacteristics::~CAsymmetricCipherCharacteristics() |
|
298 { |
|
299 iSupportedPaddingModes.Close(); |
|
300 } |
|
301 |
|
302 CAsymmetricCipherCharacteristics::CAsymmetricCipherCharacteristics() |
|
303 { |
|
304 } |
|
305 |
|
306 void CAsymmetricCipherCharacteristics::InternalizeL(RReadStream& aStream) |
|
307 { |
|
308 CCharacteristics::InternalizeL(aStream); |
|
309 iMaximumKeyLength=aStream.ReadUint32L(); |
|
310 TUint32 count=aStream.ReadUint32L(); |
|
311 |
|
312 for (TUint i=0;i<count;i++) |
|
313 { |
|
314 TInt32 mode=aStream.ReadInt32L(); |
|
315 iSupportedPaddingModes.AppendL(mode); |
|
316 } |
|
317 iKeySupportMode=aStream.ReadInt32L(); |
|
318 } |
|
319 |
|
320 TBool CAsymmetricCipherCharacteristics::IsPaddingModeSupported(TUid aPaddingMode) const |
|
321 { |
|
322 // Sanity check to catch incorrect casts of characteristics classes |
|
323 ASSERT(iInterfaceUid == KAsymmetricCipherInterface); |
|
324 |
|
325 TBool supported(EFalse); |
|
326 TInt count(iSupportedPaddingModes.Count()); |
|
327 |
|
328 for (TInt i = 0; i < count; ++i) |
|
329 { |
|
330 if (iSupportedPaddingModes[i] == aPaddingMode.iUid) |
|
331 { |
|
332 supported = ETrue; |
|
333 break; |
|
334 } |
|
335 } |
|
336 return supported; |
|
337 } |
|
338 |
|
339 // |
|
340 // Implementation of CAsymmetricSignatureCharacteristics |
|
341 // |
|
342 CAsymmetricSignatureCharacteristics* CAsymmetricSignatureCharacteristics::NewL() |
|
343 { |
|
344 CAsymmetricSignatureCharacteristics* self=CAsymmetricSignatureCharacteristics::NewLC(); |
|
345 CleanupStack::Pop(self); |
|
346 return self; |
|
347 } |
|
348 |
|
349 CAsymmetricSignatureCharacteristics* CAsymmetricSignatureCharacteristics::NewLC() |
|
350 { |
|
351 CAsymmetricSignatureCharacteristics* self=new(ELeave) CAsymmetricSignatureCharacteristics(); |
|
352 CleanupStack::PushL(self); |
|
353 return self; |
|
354 } |
|
355 |
|
356 CAsymmetricSignatureCharacteristics::~CAsymmetricSignatureCharacteristics() |
|
357 { |
|
358 iSupportedPaddingModes.Close(); |
|
359 } |
|
360 |
|
361 CAsymmetricSignatureCharacteristics::CAsymmetricSignatureCharacteristics() |
|
362 { |
|
363 } |
|
364 |
|
365 void CAsymmetricSignatureCharacteristics::InternalizeL(RReadStream& aStream) |
|
366 { |
|
367 CCharacteristics::InternalizeL(aStream); |
|
368 iMaximumKeyLength=aStream.ReadUint32L(); |
|
369 TUint32 count=aStream.ReadUint32L(); |
|
370 for (TUint i=0;i<count;i++) |
|
371 { |
|
372 TInt32 mode=aStream.ReadInt32L(); |
|
373 iSupportedPaddingModes.AppendL(mode); |
|
374 } |
|
375 iKeySupportMode=aStream.ReadInt32L(); |
|
376 } |
|
377 |
|
378 TBool CAsymmetricSignatureCharacteristics::IsPaddingModeSupported(TUid aPaddingMode) const |
|
379 { |
|
380 // Sanity check to catch incorrect casts of characteristics classes |
|
381 ASSERT(iInterfaceUid == KSignerInterface || iInterfaceUid == KVerifierInterface); |
|
382 |
|
383 TBool supported(EFalse); |
|
384 TInt count(iSupportedPaddingModes.Count()); |
|
385 |
|
386 for (TInt i = 0; i < count; ++i) |
|
387 { |
|
388 if (iSupportedPaddingModes[i] == aPaddingMode.iUid) |
|
389 { |
|
390 supported = ETrue; |
|
391 break; |
|
392 } |
|
393 } |
|
394 return supported; |
|
395 } |
|
396 |
|
397 // |
|
398 // Implementation of CKeyAgreementCharacteristics |
|
399 // |
|
400 CKeyAgreementCharacteristics* CKeyAgreementCharacteristics::NewL() |
|
401 { |
|
402 CKeyAgreementCharacteristics* self=CKeyAgreementCharacteristics::NewLC(); |
|
403 CleanupStack::Pop(self); |
|
404 return self; |
|
405 } |
|
406 |
|
407 CKeyAgreementCharacteristics* CKeyAgreementCharacteristics::NewLC() |
|
408 { |
|
409 CKeyAgreementCharacteristics* self=new(ELeave) CKeyAgreementCharacteristics(); |
|
410 CleanupStack::PushL(self); |
|
411 return self; |
|
412 } |
|
413 |
|
414 CKeyAgreementCharacteristics::~CKeyAgreementCharacteristics() |
|
415 { |
|
416 } |
|
417 |
|
418 CKeyAgreementCharacteristics::CKeyAgreementCharacteristics() |
|
419 { |
|
420 } |
|
421 |
|
422 void CKeyAgreementCharacteristics::InternalizeL(RReadStream& aStream) |
|
423 { |
|
424 CCharacteristics::InternalizeL(aStream); |
|
425 } |
|
426 |
|
427 // |
|
428 // Implementation of CKeypairGeneratorCharacteristics |
|
429 // |
|
430 CKeypairGeneratorCharacteristics* CKeypairGeneratorCharacteristics::NewL() |
|
431 { |
|
432 CKeypairGeneratorCharacteristics* self=CKeypairGeneratorCharacteristics::NewLC(); |
|
433 CleanupStack::Pop(self); |
|
434 return self; |
|
435 } |
|
436 |
|
437 CKeypairGeneratorCharacteristics* CKeypairGeneratorCharacteristics::NewLC() |
|
438 { |
|
439 CKeypairGeneratorCharacteristics* self=new(ELeave) CKeypairGeneratorCharacteristics(); |
|
440 CleanupStack::PushL(self); |
|
441 return self; |
|
442 } |
|
443 |
|
444 CKeypairGeneratorCharacteristics::~CKeypairGeneratorCharacteristics() |
|
445 { |
|
446 } |
|
447 |
|
448 CKeypairGeneratorCharacteristics::CKeypairGeneratorCharacteristics() |
|
449 { |
|
450 } |
|
451 |
|
452 void CKeypairGeneratorCharacteristics::InternalizeL(RReadStream& aStream) |
|
453 { |
|
454 CCharacteristics::InternalizeL(aStream); |
|
455 iMaximumKeyLength=aStream.ReadUint32L(); |
|
456 } |
|
457 |
|
458 // |
|
459 // Implementation of CCharacteristicsAndPluginName |
|
460 // |
|
461 CCharacteristicsAndPluginName* CCharacteristicsAndPluginName::NewL(TInt32 aInterface) |
|
462 { |
|
463 CCharacteristicsAndPluginName* self=CCharacteristicsAndPluginName::NewLC(aInterface); |
|
464 CleanupStack::Pop(self); |
|
465 return self; |
|
466 } |
|
467 |
|
468 CCharacteristicsAndPluginName* CCharacteristicsAndPluginName::NewLC(TInt32 aInterface) |
|
469 { |
|
470 CCharacteristicsAndPluginName* self=new(ELeave) CCharacteristicsAndPluginName(); |
|
471 CleanupStack::PushL(self); |
|
472 self->ConstructL(aInterface); |
|
473 return self; |
|
474 } |
|
475 |
|
476 CCharacteristicsAndPluginName::CCharacteristicsAndPluginName() |
|
477 { |
|
478 } |
|
479 |
|
480 CCharacteristicsAndPluginName::~CCharacteristicsAndPluginName() |
|
481 { |
|
482 delete iCharacteristic; |
|
483 if (iExtendedCharacteristic) |
|
484 { |
|
485 delete iExtendedCharacteristic; |
|
486 } |
|
487 } |
|
488 |
|
489 void CCharacteristicsAndPluginName::ConstructL(TInt32 aInterface) |
|
490 { |
|
491 iCharacteristic=CryptoSpiUtil::CreateCharacteristicsL(aInterface); |
|
492 } |
|
493 |
|
494 void CCharacteristicsAndPluginName::InternalizeL(RReadStream& aStream) |
|
495 { |
|
496 iCharacteristic->InternalizeL(aStream); |
|
497 TInt index=aStream.ReadInt8L(); |
|
498 CryptoSpiUtil::DllIndexToName(index, iDllName); |
|
499 } |
|
500 |