|
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 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "cdummykeystoreclient.h" |
|
20 |
|
21 MCTTokenInterface* CDummyKeyStoreClient::NewKeyStoreInterfaceL(MCTToken& aToken) |
|
22 { |
|
23 // Destroyed by MCTTokenInterface::DoRelease() |
|
24 CDummyKeyStoreClient* me = new (ELeave) CDummyKeyStoreClient(aToken); |
|
25 CleanupStack::PushL(me); |
|
26 me->ConstructL(); |
|
27 CleanupStack::Pop(me); |
|
28 return (me); |
|
29 } |
|
30 |
|
31 CDummyKeyStoreClient::CDummyKeyStoreClient(MCTToken& aToken) |
|
32 : // Reference count starts at one as we're always created and returned by a GetInterface() call on the token |
|
33 iRefCount(1), |
|
34 iToken(aToken) |
|
35 { |
|
36 } |
|
37 |
|
38 void CDummyKeyStoreClient::ConstructL() |
|
39 { |
|
40 } |
|
41 |
|
42 CDummyKeyStoreClient::~CDummyKeyStoreClient() |
|
43 { |
|
44 } |
|
45 |
|
46 MCTToken& CDummyKeyStoreClient::Token() |
|
47 { |
|
48 return iToken; |
|
49 } |
|
50 |
|
51 void CDummyKeyStoreClient::AddRef() |
|
52 { |
|
53 ++iRefCount; |
|
54 |
|
55 iToken.AddRef(); |
|
56 } |
|
57 |
|
58 void CDummyKeyStoreClient::DoRelease() |
|
59 { |
|
60 --iRefCount; |
|
61 |
|
62 ASSERT(iRefCount >= 0); |
|
63 if (iRefCount == 0) |
|
64 { |
|
65 MCTTokenInterface::DoRelease(); |
|
66 } |
|
67 } |
|
68 |
|
69 void CDummyKeyStoreClient::ReleaseObject(const TCTTokenObjectHandle& /*aHandle*/) |
|
70 { |
|
71 } |
|
72 |
|
73 // ********************************************************************************* |
|
74 // MKeyStore |
|
75 // ********************************************************************************* |
|
76 void CDummyKeyStoreClient::List(RMPointerArray<CCTKeyInfo>& /*aKeys*/, const TCTKeyAttributeFilter& /*aFilter*/, TRequestStatus& aStatus) |
|
77 { |
|
78 TRequestStatus* status = &aStatus; |
|
79 User::RequestComplete(status, KErrNone); |
|
80 } |
|
81 |
|
82 void CDummyKeyStoreClient::CancelList() |
|
83 { |
|
84 // synchronous, nothing to do |
|
85 } |
|
86 |
|
87 void CDummyKeyStoreClient::GetKeyInfo(TCTTokenObjectHandle /*aHandle*/, CCTKeyInfo*& /*aInfo*/, |
|
88 TRequestStatus& aStatus) |
|
89 { |
|
90 TRequestStatus* status = &aStatus; |
|
91 User::RequestComplete(status, KErrNone); |
|
92 } |
|
93 |
|
94 void CDummyKeyStoreClient::CancelGetKeyInfo() |
|
95 { |
|
96 // synchronous, nothing to do |
|
97 } |
|
98 |
|
99 void CDummyKeyStoreClient::Open(const TCTTokenObjectHandle& /*aHandle*/, |
|
100 MRSASigner*& /*aSigner*/, |
|
101 TRequestStatus& aStatus) |
|
102 { |
|
103 TRequestStatus* status = &aStatus; |
|
104 User::RequestComplete(status, KErrNone); |
|
105 } |
|
106 |
|
107 void CDummyKeyStoreClient::Open(const TCTTokenObjectHandle& /*aHandle*/, |
|
108 MCTSigner<CDSASignature*>*& /*aSigner*/, |
|
109 TRequestStatus& aStatus) |
|
110 { |
|
111 TRequestStatus* status = &aStatus; |
|
112 User::RequestComplete(status, KErrNone); |
|
113 } |
|
114 |
|
115 void CDummyKeyStoreClient::Open(const TCTTokenObjectHandle& /*aHandle*/, |
|
116 MCTDecryptor*& /*aDecryptor*/, |
|
117 TRequestStatus& aStatus) |
|
118 { |
|
119 TRequestStatus* status = &aStatus; |
|
120 User::RequestComplete(status, KErrNone); |
|
121 } |
|
122 |
|
123 void CDummyKeyStoreClient::Open(const TCTTokenObjectHandle& /*aHandle*/, |
|
124 MCTDH*& /*aDH*/, TRequestStatus& aStatus) |
|
125 { |
|
126 TRequestStatus* status = &aStatus; |
|
127 User::RequestComplete(status, KErrNone); |
|
128 } |
|
129 |
|
130 void CDummyKeyStoreClient::CancelOpen() |
|
131 { |
|
132 // synchronous, nothing to do |
|
133 } |
|
134 |
|
135 /** Returns the public key in DER-encoded ASN-1 */ |
|
136 void CDummyKeyStoreClient::ExportPublic(const TCTTokenObjectHandle& /*aHandle*/, |
|
137 HBufC8*& /*aPublicKey*/, |
|
138 TRequestStatus& aStatus) |
|
139 { |
|
140 TRequestStatus* status = &aStatus; |
|
141 User::RequestComplete(status, KErrNone); |
|
142 } |
|
143 |
|
144 void CDummyKeyStoreClient::CancelExportPublic() |
|
145 { |
|
146 // synchronous, nothing to do |
|
147 } |
|
148 |
|
149 // ********************************************************************************* |
|
150 // MCTKeyStoreManager |
|
151 // ********************************************************************************* |
|
152 void CDummyKeyStoreClient::CreateKey(CCTKeyInfo*& /*aReturnedKey*/, TRequestStatus& aStatus) |
|
153 { |
|
154 TRequestStatus* status = &aStatus; |
|
155 User::RequestComplete(status, KErrNone); |
|
156 } |
|
157 |
|
158 void CDummyKeyStoreClient::CancelCreateKey() |
|
159 { |
|
160 } |
|
161 |
|
162 void CDummyKeyStoreClient::ImportKey(const TDesC8& /*aKey*/, CCTKeyInfo*& /*aReturnedKey*/, TRequestStatus& aStatus) |
|
163 { |
|
164 TRequestStatus* status = &aStatus; |
|
165 User::RequestComplete(status, KErrNone); |
|
166 //DoImportKey(EImportKey, aKey, aReturnedKey, aStatus); |
|
167 } |
|
168 |
|
169 void CDummyKeyStoreClient::CancelImportKey() |
|
170 { |
|
171 } |
|
172 |
|
173 void CDummyKeyStoreClient::ImportEncryptedKey(const TDesC8& /*aKey*/, CCTKeyInfo*& /*aReturnedKey*/, TRequestStatus& aStatus) |
|
174 { |
|
175 TRequestStatus* status = &aStatus; |
|
176 User::RequestComplete(status, KErrNone); |
|
177 //DoImportKey(EImportEncryptedKey, aKey, aReturnedKey, aStatus); |
|
178 } |
|
179 |
|
180 void CDummyKeyStoreClient::CancelImportEncryptedKey() |
|
181 { |
|
182 } |
|
183 |
|
184 void CDummyKeyStoreClient::ExportKey(TCTTokenObjectHandle /*aHandle*/, HBufC8*& /*aKey*/, TRequestStatus& aStatus) |
|
185 { |
|
186 TRequestStatus* status = &aStatus; |
|
187 User::RequestComplete(status, KErrNone); |
|
188 } |
|
189 |
|
190 void CDummyKeyStoreClient::CancelExportKey() |
|
191 { |
|
192 } |
|
193 |
|
194 void CDummyKeyStoreClient::ExportEncryptedKey(TCTTokenObjectHandle /*aHandle*/, const CPBEncryptParms& /*aParams*/, HBufC8*& /*aKey*/, TRequestStatus& aStatus) |
|
195 { |
|
196 TRequestStatus* status = &aStatus; |
|
197 User::RequestComplete(status, KErrNone); |
|
198 } |
|
199 |
|
200 void CDummyKeyStoreClient::CancelExportEncryptedKey() |
|
201 { |
|
202 } |
|
203 |
|
204 void CDummyKeyStoreClient::RepudiableDSASign(const TCTTokenObjectHandle& /*aHandle*/, |
|
205 const TDesC8& /*aDigest*/, |
|
206 CDSASignature*& /*aSignature*/, |
|
207 TRequestStatus& aStatus) |
|
208 { |
|
209 TRequestStatus* status = &aStatus; |
|
210 User::RequestComplete(status, KErrNone); |
|
211 } |
|
212 |
|
213 void CDummyKeyStoreClient::RepudiableRSASign(const TCTTokenObjectHandle& /*aHandle*/, |
|
214 const TDesC8& /*aDigest*/, |
|
215 CRSASignature*& /*aSignature*/, |
|
216 TRequestStatus& aStatus) |
|
217 { |
|
218 TRequestStatus* status = &aStatus; |
|
219 User::RequestComplete(status, KErrNone); |
|
220 } |
|
221 |
|
222 void CDummyKeyStoreClient::Decrypt(const TCTTokenObjectHandle& /*aHandle*/, |
|
223 const TDesC8& /*aCiphertext*/, |
|
224 TDes8& /*aDecryptedText*/, |
|
225 TRequestStatus& aStatus) |
|
226 { |
|
227 TRequestStatus* status = &aStatus; |
|
228 User::RequestComplete(status, KErrNone); |
|
229 } |
|
230 |
|
231 void CDummyKeyStoreClient::DHPublicKey(const TCTTokenObjectHandle& /*aHandle*/, const TInteger& /*aN*/, const TInteger& /*aG*/, |
|
232 CDHPublicKey*& /*aX*/, TRequestStatus& aStatus) |
|
233 { |
|
234 TRequestStatus* status = &aStatus; |
|
235 User::RequestComplete(status, KErrNone); |
|
236 } |
|
237 |
|
238 void CDummyKeyStoreClient::DHAgree(const TCTTokenObjectHandle& /*aHandle*/, const CDHPublicKey& /*iY*/, |
|
239 HBufC8*& /*aAgreedKey*/, TRequestStatus& aStatus) |
|
240 { |
|
241 TRequestStatus* status = &aStatus; |
|
242 User::RequestComplete(status, KErrNone); |
|
243 } |
|
244 |
|
245 void CDummyKeyStoreClient::DeleteKey(TCTTokenObjectHandle /*aHandle*/, TRequestStatus& aStatus) |
|
246 { |
|
247 TRequestStatus* status = &aStatus; |
|
248 User::RequestComplete(status, KErrNone); |
|
249 } |
|
250 |
|
251 void CDummyKeyStoreClient::CancelDeleteKey() |
|
252 { |
|
253 // synchronous, nothing to do |
|
254 } |
|
255 |
|
256 void CDummyKeyStoreClient::SetUsePolicy(TCTTokenObjectHandle /*aHandle*/, |
|
257 const TSecurityPolicy& /*aPolicy*/, |
|
258 TRequestStatus& aStatus) |
|
259 { |
|
260 TRequestStatus* status = &aStatus; |
|
261 User::RequestComplete(status, KErrNone); |
|
262 } |
|
263 |
|
264 void CDummyKeyStoreClient::CancelSetUsePolicy() |
|
265 { |
|
266 // synchronous, nothing to do |
|
267 } |
|
268 |
|
269 void CDummyKeyStoreClient::SetManagementPolicy(TCTTokenObjectHandle /*aHandle*/, |
|
270 const TSecurityPolicy& /*aPolicy*/, |
|
271 TRequestStatus& aStatus) |
|
272 { |
|
273 TRequestStatus* status = &aStatus; |
|
274 User::RequestComplete(status, KErrNone); |
|
275 } |
|
276 |
|
277 void CDummyKeyStoreClient::CancelSetManagementPolicy() |
|
278 { |
|
279 // synchronous, nothing to do |
|
280 } |
|
281 |
|
282 void CDummyKeyStoreClient::SetPassphraseTimeout(TInt /*aTimeout*/, TRequestStatus& aStatus) |
|
283 { |
|
284 TRequestStatus* status = &aStatus; |
|
285 User::RequestComplete(status, KErrNone); |
|
286 } |
|
287 |
|
288 void CDummyKeyStoreClient::CancelSetPassphraseTimeout() |
|
289 { |
|
290 // No point cancelling, not asynchronous |
|
291 } |
|
292 |
|
293 void CDummyKeyStoreClient::Relock(TRequestStatus& aStatus) |
|
294 { |
|
295 TRequestStatus* status = &aStatus; |
|
296 User::RequestComplete(status, KErrNone); |
|
297 } |
|
298 |
|
299 void CDummyKeyStoreClient::CancelRelock() |
|
300 { |
|
301 // No point cancelling, not asynchronous |
|
302 } |