|
1 /* |
|
2 * Copyright (c) 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 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "dummyeccsignerimpl.h" |
|
20 #include "keys.h" |
|
21 #include "pluginconfig.h" |
|
22 #include "cryptospihai.h" |
|
23 |
|
24 using namespace DummyEccHwCrypto; |
|
25 using namespace CryptoSpiHai; |
|
26 |
|
27 const TInt KMaxSignerOutputLength = 50; |
|
28 const TInt KMaxSignerInputLength = 50; |
|
29 |
|
30 // CDummyECCSignerImpl |
|
31 CDummyECCSignerImpl* CDummyECCSignerImpl::NewL(const CKey& aKey, |
|
32 TUid aPaddingMode) |
|
33 { |
|
34 CDummyECCSignerImpl* self = |
|
35 CDummyECCSignerImpl::NewLC(aKey, aPaddingMode); |
|
36 CleanupStack::Pop(self); |
|
37 return self; |
|
38 } |
|
39 |
|
40 CDummyECCSignerImpl* CDummyECCSignerImpl::NewLC(const CKey& aKey, |
|
41 TUid aPaddingMode) |
|
42 { |
|
43 CDummyECCSignerImpl* self = |
|
44 new (ELeave) CDummyECCSignerImpl(aPaddingMode); |
|
45 CleanupStack::PushL(self); |
|
46 self->ConstructL(aKey); |
|
47 return self; |
|
48 } |
|
49 |
|
50 CDummyECCSignerImpl::CDummyECCSignerImpl(TUid aPaddingMode) : |
|
51 iPaddingMode(aPaddingMode) |
|
52 { |
|
53 } |
|
54 |
|
55 CDummyECCSignerImpl::~CDummyECCSignerImpl() |
|
56 { |
|
57 delete iKey; |
|
58 } |
|
59 |
|
60 void CDummyECCSignerImpl::ConstructL(const CKey& aKey) |
|
61 { |
|
62 SetKeyL(aKey); |
|
63 } |
|
64 |
|
65 // MPlugin Interface |
|
66 void CDummyECCSignerImpl::Close() |
|
67 { |
|
68 delete this; |
|
69 } |
|
70 void CDummyECCSignerImpl::Reset() |
|
71 { |
|
72 } |
|
73 void CDummyECCSignerImpl::GetCharacteristicsL( |
|
74 const TCharacteristics*& aPluginCharacteristics) |
|
75 { |
|
76 TInt numCiphers = sizeof(KSignerCharacteristics) |
|
77 / sizeof(TAsymmetricSignatureCharacteristics*); |
|
78 TInt32 implUid = ImplementationUid().iUid; |
|
79 for (TInt i = 0; i < numCiphers; ++i) |
|
80 { |
|
81 if (KSignerCharacteristics[i]->cmn.iImplementationUID == implUid) |
|
82 { |
|
83 aPluginCharacteristics = KSignerCharacteristics[i]; |
|
84 break; |
|
85 } |
|
86 } |
|
87 } |
|
88 |
|
89 const CExtendedCharacteristics* CDummyECCSignerImpl::GetExtendedCharacteristicsL() |
|
90 { |
|
91 // All Symbian software plug-ins have unlimited concurrency, cannot be reserved |
|
92 // for exclusive use and are not CERTIFIED to be standards compliant. |
|
93 return CExtendedCharacteristics::NewL(KMaxTInt, EFalse); |
|
94 } |
|
95 |
|
96 TAny* CDummyECCSignerImpl::GetExtension(TUid /* aExtensionId */) |
|
97 { |
|
98 return 0; |
|
99 } |
|
100 // End of MPlugin Interface |
|
101 |
|
102 // MSignatureBase Interface |
|
103 void CDummyECCSignerImpl::SetPaddingModeL(TUid /* aPaddingMode */) |
|
104 { |
|
105 User::Leave(KErrNotSupported); |
|
106 } |
|
107 |
|
108 void CDummyECCSignerImpl::SetKeyL(const CKey& aKey) |
|
109 { |
|
110 // delete any previous key and recreate the key |
|
111 delete iKey; |
|
112 iKey = NULL; |
|
113 iKey = CKey::NewL(aKey); |
|
114 } |
|
115 |
|
116 TInt CDummyECCSignerImpl::GetMaximumInputLengthL() const |
|
117 { |
|
118 return KMaxSignerInputLength; |
|
119 } |
|
120 |
|
121 TInt CDummyECCSignerImpl::GetMaximumOutputLengthL() const |
|
122 { |
|
123 return KMaxSignerOutputLength; |
|
124 } |
|
125 |
|
126 TUid CDummyECCSignerImpl::ImplementationUid() const |
|
127 { |
|
128 return KCryptoPluginEccSignerUid; |
|
129 } |
|
130 |
|
131 void CDummyECCSignerImpl::SignL(const TDesC8& aInput, |
|
132 CCryptoParams& aSignature) |
|
133 { |
|
134 if (iKey->IsPresent(KPassedHandleToKeyUid)) |
|
135 { |
|
136 const TInt keyHandle = iKey->GetTIntL(KPassedHandleToKeyUid); |
|
137 |
|
138 // Invoke the Spi HAI to perform the operation |
|
139 CCryptoSpiHai::SignL(keyHandle, aInput, aSignature); |
|
140 } |
|
141 else |
|
142 { |
|
143 User::Leave(KErrNotSupported); |
|
144 } |
|
145 } |
|
146 |
|
147 // End of file |