sl@0
|
1 |
/*
|
sl@0
|
2 |
* Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
3 |
* All rights reserved.
|
sl@0
|
4 |
* This component and the accompanying materials are made available
|
sl@0
|
5 |
* under the terms of the License "Eclipse Public License v1.0"
|
sl@0
|
6 |
* which accompanies this distribution, and is available
|
sl@0
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
8 |
*
|
sl@0
|
9 |
* Initial Contributors:
|
sl@0
|
10 |
* Nokia Corporation - initial contribution.
|
sl@0
|
11 |
*
|
sl@0
|
12 |
* Contributors:
|
sl@0
|
13 |
*
|
sl@0
|
14 |
* Description:
|
sl@0
|
15 |
*
|
sl@0
|
16 |
*/
|
sl@0
|
17 |
|
sl@0
|
18 |
|
sl@0
|
19 |
#include "unifiedkeystore.h"
|
sl@0
|
20 |
#include <ecom/ecom.h>
|
sl@0
|
21 |
#include <random.h>
|
sl@0
|
22 |
#include <pbedata.h>
|
sl@0
|
23 |
#include <asnpkcs.h>
|
sl@0
|
24 |
#include "mctcertappinterface.h"
|
sl@0
|
25 |
#include <mctkeystoreuids.h>
|
sl@0
|
26 |
|
sl@0
|
27 |
_LIT(KUnifiedKeyStore, "UnifiedKeyStore");
|
sl@0
|
28 |
|
sl@0
|
29 |
/////////////////////////////////////////////////////////////////////////////////////
|
sl@0
|
30 |
//CUnifiedKeyStore
|
sl@0
|
31 |
/////////////////////////////////////////////////////////////////////////////////////
|
sl@0
|
32 |
|
sl@0
|
33 |
EXPORT_C CUnifiedKeyStore* CUnifiedKeyStore::NewL(RFs& aFs)
|
sl@0
|
34 |
{
|
sl@0
|
35 |
CUnifiedKeyStore* self = CUnifiedKeyStore::NewLC(aFs);
|
sl@0
|
36 |
CleanupStack::Pop(self);
|
sl@0
|
37 |
return self;
|
sl@0
|
38 |
}
|
sl@0
|
39 |
|
sl@0
|
40 |
EXPORT_C CUnifiedKeyStore* CUnifiedKeyStore::NewLC(RFs& aFs)
|
sl@0
|
41 |
{
|
sl@0
|
42 |
CUnifiedKeyStore* self = new(ELeave) CUnifiedKeyStore(aFs);
|
sl@0
|
43 |
CleanupStack::PushL(self);
|
sl@0
|
44 |
self->ConstructL();
|
sl@0
|
45 |
return self;
|
sl@0
|
46 |
}
|
sl@0
|
47 |
|
sl@0
|
48 |
EXPORT_C CUnifiedKeyStore::~CUnifiedKeyStore()
|
sl@0
|
49 |
{
|
sl@0
|
50 |
Cancel();
|
sl@0
|
51 |
Cleanup();
|
sl@0
|
52 |
|
sl@0
|
53 |
iKeyStoresHolder.ResetAndDestroy();
|
sl@0
|
54 |
iKeyStoresHolder.Close();
|
sl@0
|
55 |
|
sl@0
|
56 |
REComSession::FinalClose();
|
sl@0
|
57 |
}
|
sl@0
|
58 |
|
sl@0
|
59 |
void CUnifiedKeyStore::DoInitializeL()
|
sl@0
|
60 |
{// We want the list of all token types that support a keystore interface
|
sl@0
|
61 |
RArray<TUid> uidArray;
|
sl@0
|
62 |
CleanupClosePushL(uidArray);
|
sl@0
|
63 |
|
sl@0
|
64 |
User::LeaveIfError(uidArray.Append(TUid::Uid(KInterfaceKeyStore)));
|
sl@0
|
65 |
|
sl@0
|
66 |
TCTFindTokenTypesByInterface filter(uidArray.Array());
|
sl@0
|
67 |
CCTTokenTypeInfo::ListL(iTokenTypes, filter);
|
sl@0
|
68 |
|
sl@0
|
69 |
CleanupStack::PopAndDestroy(); // uidArray
|
sl@0
|
70 |
}
|
sl@0
|
71 |
|
sl@0
|
72 |
EXPORT_C void CUnifiedKeyStore::Initialize(TRequestStatus& aStatus)
|
sl@0
|
73 |
{// The following assertion checks that we didn't call Initialize twice
|
sl@0
|
74 |
__ASSERT_DEBUG((iKeyStoresHolder.Count()==0), User::Panic(KUnifiedKeyStore, EUnexpectedInitialise));
|
sl@0
|
75 |
|
sl@0
|
76 |
TRAPD(err, DoInitializeL());
|
sl@0
|
77 |
if (err != KErrNone)
|
sl@0
|
78 |
{
|
sl@0
|
79 |
TRequestStatus* status = &aStatus;
|
sl@0
|
80 |
User::RequestComplete(status, err);
|
sl@0
|
81 |
return;
|
sl@0
|
82 |
}
|
sl@0
|
83 |
|
sl@0
|
84 |
iIndexTokenTypes = -1;
|
sl@0
|
85 |
StartAsyncOperation(EInitializeGetTokenList, aStatus);
|
sl@0
|
86 |
|
sl@0
|
87 |
SetActive();
|
sl@0
|
88 |
TRequestStatus* status = &iStatus;
|
sl@0
|
89 |
User::RequestComplete(status, KErrNone);
|
sl@0
|
90 |
}
|
sl@0
|
91 |
|
sl@0
|
92 |
EXPORT_C void CUnifiedKeyStore::CancelInitialize()
|
sl@0
|
93 |
{
|
sl@0
|
94 |
if (iState == EInitializeGetTokenList ||
|
sl@0
|
95 |
iState == EInitializeGetToken ||
|
sl@0
|
96 |
iState == EInitialiseGetKeyManagerInterface ||
|
sl@0
|
97 |
iState == EInitializeGetKeyUserInterface ||
|
sl@0
|
98 |
iState == EInitializeGetKeyUserInterfaceFinished ||
|
sl@0
|
99 |
iState == EInitializeFinished)
|
sl@0
|
100 |
{
|
sl@0
|
101 |
Cancel();
|
sl@0
|
102 |
}
|
sl@0
|
103 |
}
|
sl@0
|
104 |
|
sl@0
|
105 |
EXPORT_C void CUnifiedKeyStore::CreateKey(TInt aKeyStoreIndex, TKeyUsagePKCS15 aUsage,TUint aSize,
|
sl@0
|
106 |
const TDesC& aLabel, CCTKeyInfo::EKeyAlgorithm aAlgorithm,
|
sl@0
|
107 |
TInt aAccessType, TTime aStartDate, TTime aEndDate,
|
sl@0
|
108 |
CCTKeyInfo*& aKeyInfoOut, TRequestStatus& aStatus)
|
sl@0
|
109 |
{
|
sl@0
|
110 |
StartAsyncOperation(ECreateKey, aStatus);
|
sl@0
|
111 |
TRAPD(err, PrepareToCreateKeyL(aKeyStoreIndex, aUsage, aSize, aLabel, aAlgorithm, aAccessType,
|
sl@0
|
112 |
aStartDate, aEndDate, aStatus));
|
sl@0
|
113 |
if (KErrNone != err)
|
sl@0
|
114 |
{
|
sl@0
|
115 |
Complete(err);
|
sl@0
|
116 |
return;
|
sl@0
|
117 |
}
|
sl@0
|
118 |
|
sl@0
|
119 |
iKeyInfoOut = &aKeyInfoOut;
|
sl@0
|
120 |
aKeyInfoOut = NULL;
|
sl@0
|
121 |
iKeyStoreManager->CreateKey(iKeyInfo, iStatus);
|
sl@0
|
122 |
SetActive();
|
sl@0
|
123 |
}
|
sl@0
|
124 |
|
sl@0
|
125 |
EXPORT_C void CUnifiedKeyStore::CancelCreateKey()
|
sl@0
|
126 |
{
|
sl@0
|
127 |
if (iState == ECreateKey)
|
sl@0
|
128 |
{
|
sl@0
|
129 |
Cancel();
|
sl@0
|
130 |
}
|
sl@0
|
131 |
}
|
sl@0
|
132 |
|
sl@0
|
133 |
EXPORT_C void CUnifiedKeyStore::ImportKey(TInt aKeyStoreIndex, const TDesC8& aKeyData,
|
sl@0
|
134 |
TKeyUsagePKCS15 aUsage, const TDesC& aLabel,
|
sl@0
|
135 |
TInt aAccessType, TTime aStartDate, TTime aEndDate,
|
sl@0
|
136 |
CCTKeyInfo*& aKeyInfoOut, TRequestStatus& aStatus)
|
sl@0
|
137 |
{
|
sl@0
|
138 |
TBool isEncrypted = TASN1DecPKCS8::IsEncryptedPKCS8Data(aKeyData);
|
sl@0
|
139 |
StartAsyncOperation(isEncrypted ? EImportKeyEncrypted : EImportKey, aStatus);
|
sl@0
|
140 |
|
sl@0
|
141 |
ASSERT(!iKeyData);
|
sl@0
|
142 |
iKeyData = aKeyData.Alloc();
|
sl@0
|
143 |
if (!iKeyData) // OOM or some other catastrophe
|
sl@0
|
144 |
{
|
sl@0
|
145 |
Complete(KErrNoMemory);
|
sl@0
|
146 |
return;
|
sl@0
|
147 |
}
|
sl@0
|
148 |
|
sl@0
|
149 |
TRAPD(err, PrepareToCreateKeyL(aKeyStoreIndex, aUsage, 0, aLabel, CCTKeyInfo::EInvalidAlgorithm, aAccessType,
|
sl@0
|
150 |
aStartDate, aEndDate, aStatus));
|
sl@0
|
151 |
if (KErrNone != err)
|
sl@0
|
152 |
{
|
sl@0
|
153 |
Complete(err);
|
sl@0
|
154 |
return;
|
sl@0
|
155 |
}
|
sl@0
|
156 |
|
sl@0
|
157 |
iKeyInfoOut = &aKeyInfoOut;
|
sl@0
|
158 |
aKeyInfoOut = NULL;
|
sl@0
|
159 |
|
sl@0
|
160 |
if (isEncrypted)
|
sl@0
|
161 |
{
|
sl@0
|
162 |
iKeyStoreManager->ImportEncryptedKey(*iKeyData, iKeyInfo, iStatus);
|
sl@0
|
163 |
}
|
sl@0
|
164 |
else
|
sl@0
|
165 |
{
|
sl@0
|
166 |
iKeyStoreManager->ImportKey(*iKeyData, iKeyInfo, iStatus);
|
sl@0
|
167 |
}
|
sl@0
|
168 |
SetActive();
|
sl@0
|
169 |
}
|
sl@0
|
170 |
|
sl@0
|
171 |
EXPORT_C void CUnifiedKeyStore::CancelImportKey()
|
sl@0
|
172 |
{
|
sl@0
|
173 |
if (iState == EImportKey ||
|
sl@0
|
174 |
iState == EImportKeyEncrypted)
|
sl@0
|
175 |
{
|
sl@0
|
176 |
Cancel();
|
sl@0
|
177 |
}
|
sl@0
|
178 |
}
|
sl@0
|
179 |
|
sl@0
|
180 |
void CUnifiedKeyStore::PrepareToCreateKeyL( TInt aKeyStoreIndex,
|
sl@0
|
181 |
TKeyUsagePKCS15 aUsage, TUint aSize,
|
sl@0
|
182 |
const TDesC& aLabel,
|
sl@0
|
183 |
CCTKeyInfo::EKeyAlgorithm aAlgorithm,
|
sl@0
|
184 |
TInt aAccessType,
|
sl@0
|
185 |
TTime aStartTime, TTime aEndTime,
|
sl@0
|
186 |
TRequestStatus& aStatus)
|
sl@0
|
187 |
{
|
sl@0
|
188 |
ASSERT(!iKeyStoreManager);
|
sl@0
|
189 |
|
sl@0
|
190 |
// These values are filled in by the server when the key is created
|
sl@0
|
191 |
TKeyIdentifier keyID;
|
sl@0
|
192 |
keyID.MaxSize();
|
sl@0
|
193 |
keyID.FillZ(keyID.MaxSize());
|
sl@0
|
194 |
TInt keyHandle = 0;
|
sl@0
|
195 |
|
sl@0
|
196 |
// Get the secure ID of the current process
|
sl@0
|
197 |
RProcess thisProcess;
|
sl@0
|
198 |
User::LeaveIfError(thisProcess.Open(thisProcess.Id()));
|
sl@0
|
199 |
TSecureId creatorId = thisProcess.SecureId();
|
sl@0
|
200 |
thisProcess.Close();
|
sl@0
|
201 |
|
sl@0
|
202 |
// Default management policy: resict to creating process
|
sl@0
|
203 |
TSecurityPolicy managementPolicy(creatorId);
|
sl@0
|
204 |
|
sl@0
|
205 |
// Default use policy: also resict to creating process
|
sl@0
|
206 |
TSecurityPolicy usePolicy(creatorId);
|
sl@0
|
207 |
|
sl@0
|
208 |
HBufC* label = aLabel.AllocLC();
|
sl@0
|
209 |
|
sl@0
|
210 |
// Panics if keystore manager index invalid
|
sl@0
|
211 |
MCTKeyStoreManager& keystore = KeyStoreManager(aKeyStoreIndex);
|
sl@0
|
212 |
|
sl@0
|
213 |
iKeyInfo = CCTKeyInfo::NewL(keyID, aUsage, aSize, NULL, label, keystore.Token(),
|
sl@0
|
214 |
keyHandle, usePolicy, managementPolicy, aAlgorithm,
|
sl@0
|
215 |
aAccessType, ETrue, aStartTime, aEndTime);
|
sl@0
|
216 |
CleanupStack::Pop(label);
|
sl@0
|
217 |
|
sl@0
|
218 |
iKeyStoreManager = &keystore;
|
sl@0
|
219 |
iOriginalRequestStatus = &aStatus;
|
sl@0
|
220 |
aStatus = KRequestPending;
|
sl@0
|
221 |
}
|
sl@0
|
222 |
|
sl@0
|
223 |
// ************************************************************************
|
sl@0
|
224 |
// MKeyStore
|
sl@0
|
225 |
// ************************************************************************
|
sl@0
|
226 |
|
sl@0
|
227 |
void CUnifiedKeyStore::List(RMPointerArray<CCTKeyInfo>& aKeys,
|
sl@0
|
228 |
const TCTKeyAttributeFilter& aFilter,
|
sl@0
|
229 |
TRequestStatus& aStatus)
|
sl@0
|
230 |
{
|
sl@0
|
231 |
StartAsyncOperation(EList, aStatus);
|
sl@0
|
232 |
|
sl@0
|
233 |
iKeyInfos = &aKeys;
|
sl@0
|
234 |
|
sl@0
|
235 |
delete iFilter;
|
sl@0
|
236 |
iFilter = new TCTKeyAttributeFilter(aFilter);
|
sl@0
|
237 |
if (!iFilter)
|
sl@0
|
238 |
{
|
sl@0
|
239 |
Complete(KErrNoMemory);
|
sl@0
|
240 |
return;
|
sl@0
|
241 |
}
|
sl@0
|
242 |
|
sl@0
|
243 |
iIndex = -1;
|
sl@0
|
244 |
|
sl@0
|
245 |
SetActive();
|
sl@0
|
246 |
TRequestStatus* status = &iStatus;
|
sl@0
|
247 |
User::RequestComplete(status, KErrNone);
|
sl@0
|
248 |
}
|
sl@0
|
249 |
|
sl@0
|
250 |
void CUnifiedKeyStore::CancelList()
|
sl@0
|
251 |
{
|
sl@0
|
252 |
if (iState == EList)
|
sl@0
|
253 |
{
|
sl@0
|
254 |
Cancel();
|
sl@0
|
255 |
}
|
sl@0
|
256 |
}
|
sl@0
|
257 |
|
sl@0
|
258 |
void CUnifiedKeyStore::GetKeyInfo(TCTTokenObjectHandle aHandle,
|
sl@0
|
259 |
CCTKeyInfo*& aKeyInfo,
|
sl@0
|
260 |
TRequestStatus& aStatus)
|
sl@0
|
261 |
{
|
sl@0
|
262 |
StartAsyncOperation(EGetKeyInfo, aStatus);
|
sl@0
|
263 |
|
sl@0
|
264 |
ASSERT(!iKeyStore);
|
sl@0
|
265 |
iKeyStore = FindKeyStore(aHandle);
|
sl@0
|
266 |
if (!iKeyStore)
|
sl@0
|
267 |
{
|
sl@0
|
268 |
Complete(KErrNotFound);
|
sl@0
|
269 |
return;
|
sl@0
|
270 |
}
|
sl@0
|
271 |
|
sl@0
|
272 |
iKeyStore->GetKeyInfo(aHandle, aKeyInfo, iStatus);
|
sl@0
|
273 |
SetActive();
|
sl@0
|
274 |
}
|
sl@0
|
275 |
|
sl@0
|
276 |
void CUnifiedKeyStore::CancelGetKeyInfo()
|
sl@0
|
277 |
{
|
sl@0
|
278 |
if (iState == EGetKeyInfo)
|
sl@0
|
279 |
{
|
sl@0
|
280 |
Cancel();
|
sl@0
|
281 |
}
|
sl@0
|
282 |
}
|
sl@0
|
283 |
|
sl@0
|
284 |
// Implementation for most of the Open() method
|
sl@0
|
285 |
TBool CUnifiedKeyStore::DoOpen(const TCTTokenObjectHandle& aHandle,
|
sl@0
|
286 |
TRequestStatus& aStatus)
|
sl@0
|
287 |
{
|
sl@0
|
288 |
StartAsyncOperation(EOpen, aStatus);
|
sl@0
|
289 |
|
sl@0
|
290 |
ASSERT(!iKeyStore);
|
sl@0
|
291 |
iKeyStore = FindKeyStore(aHandle);
|
sl@0
|
292 |
if (!iKeyStore)
|
sl@0
|
293 |
{
|
sl@0
|
294 |
Complete(KErrNotFound);
|
sl@0
|
295 |
return EFalse;
|
sl@0
|
296 |
}
|
sl@0
|
297 |
|
sl@0
|
298 |
SetActive();
|
sl@0
|
299 |
return ETrue;
|
sl@0
|
300 |
}
|
sl@0
|
301 |
|
sl@0
|
302 |
void CUnifiedKeyStore::Open(const TCTTokenObjectHandle& aHandle,
|
sl@0
|
303 |
MRSASigner*& aSigner,
|
sl@0
|
304 |
TRequestStatus& aStatus)
|
sl@0
|
305 |
{
|
sl@0
|
306 |
if (DoOpen(aHandle, aStatus))
|
sl@0
|
307 |
{
|
sl@0
|
308 |
iKeyStore->Open(aHandle, aSigner, iStatus);
|
sl@0
|
309 |
}
|
sl@0
|
310 |
}
|
sl@0
|
311 |
|
sl@0
|
312 |
void CUnifiedKeyStore::Open(const TCTTokenObjectHandle& aHandle,
|
sl@0
|
313 |
MDSASigner*& aSigner,
|
sl@0
|
314 |
TRequestStatus& aStatus)
|
sl@0
|
315 |
{
|
sl@0
|
316 |
if (DoOpen(aHandle, aStatus))
|
sl@0
|
317 |
{
|
sl@0
|
318 |
iKeyStore->Open(aHandle, aSigner, iStatus);
|
sl@0
|
319 |
}
|
sl@0
|
320 |
}
|
sl@0
|
321 |
|
sl@0
|
322 |
void CUnifiedKeyStore::Open(const TCTTokenObjectHandle& aHandle,
|
sl@0
|
323 |
MCTDecryptor*& aDecryptor,
|
sl@0
|
324 |
TRequestStatus& aStatus)
|
sl@0
|
325 |
{
|
sl@0
|
326 |
if (DoOpen(aHandle, aStatus))
|
sl@0
|
327 |
{
|
sl@0
|
328 |
iKeyStore->Open(aHandle, aDecryptor, iStatus);
|
sl@0
|
329 |
}
|
sl@0
|
330 |
}
|
sl@0
|
331 |
|
sl@0
|
332 |
void CUnifiedKeyStore::Open(const TCTTokenObjectHandle& aHandle,
|
sl@0
|
333 |
MCTDH*& aDH, TRequestStatus& aStatus)
|
sl@0
|
334 |
{
|
sl@0
|
335 |
if (DoOpen(aHandle, aStatus))
|
sl@0
|
336 |
{
|
sl@0
|
337 |
iKeyStore->Open(aHandle, aDH, iStatus);
|
sl@0
|
338 |
}
|
sl@0
|
339 |
}
|
sl@0
|
340 |
|
sl@0
|
341 |
void CUnifiedKeyStore::CancelOpen()
|
sl@0
|
342 |
{
|
sl@0
|
343 |
if (iState == EOpen)
|
sl@0
|
344 |
{
|
sl@0
|
345 |
Cancel();
|
sl@0
|
346 |
}
|
sl@0
|
347 |
}
|
sl@0
|
348 |
|
sl@0
|
349 |
/** Returns the public key in DER-encoded ASN-1 */
|
sl@0
|
350 |
void CUnifiedKeyStore::ExportPublic(const TCTTokenObjectHandle& aHandle,
|
sl@0
|
351 |
HBufC8*& aPublicKey,
|
sl@0
|
352 |
TRequestStatus& aStatus)
|
sl@0
|
353 |
{
|
sl@0
|
354 |
StartAsyncOperation(EExportPublic, aStatus);
|
sl@0
|
355 |
|
sl@0
|
356 |
iKeyStore = FindKeyStore(aHandle);
|
sl@0
|
357 |
if (!iKeyStore)
|
sl@0
|
358 |
{
|
sl@0
|
359 |
Complete(KErrNotFound);
|
sl@0
|
360 |
return;
|
sl@0
|
361 |
}
|
sl@0
|
362 |
|
sl@0
|
363 |
iKeyStore->ExportPublic(aHandle, aPublicKey, iStatus);
|
sl@0
|
364 |
SetActive();
|
sl@0
|
365 |
}
|
sl@0
|
366 |
|
sl@0
|
367 |
void CUnifiedKeyStore::CancelExportPublic()
|
sl@0
|
368 |
{
|
sl@0
|
369 |
if (iState == EExportPublic)
|
sl@0
|
370 |
{
|
sl@0
|
371 |
Cancel();
|
sl@0
|
372 |
}
|
sl@0
|
373 |
}
|
sl@0
|
374 |
|
sl@0
|
375 |
#ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
|
sl@0
|
376 |
void CUnifiedKeyStore::Open(const TCTTokenObjectHandle& aHandle,
|
sl@0
|
377 |
CryptoSpi::CSigner*& aSigner,
|
sl@0
|
378 |
TRequestStatus& aStatus)
|
sl@0
|
379 |
{
|
sl@0
|
380 |
if (DoOpen(aHandle, aStatus))
|
sl@0
|
381 |
{
|
sl@0
|
382 |
iKeyStore->Open(aHandle, aSigner, iStatus);
|
sl@0
|
383 |
}
|
sl@0
|
384 |
}
|
sl@0
|
385 |
|
sl@0
|
386 |
void CUnifiedKeyStore::Open(const TCTTokenObjectHandle& aHandle,
|
sl@0
|
387 |
CryptoSpi:: CAsymmetricCipher*& asymmetricCipherObj,
|
sl@0
|
388 |
TRequestStatus& aStatus)
|
sl@0
|
389 |
{
|
sl@0
|
390 |
if (DoOpen(aHandle, aStatus))
|
sl@0
|
391 |
{
|
sl@0
|
392 |
iKeyStore->Open(aHandle, asymmetricCipherObj, iStatus);
|
sl@0
|
393 |
}
|
sl@0
|
394 |
}
|
sl@0
|
395 |
|
sl@0
|
396 |
void CUnifiedKeyStore::Decrypt(const TCTTokenObjectHandle& aHandle,
|
sl@0
|
397 |
const TDesC8& aCiphertext,
|
sl@0
|
398 |
HBufC8*& aPlaintextPtr,
|
sl@0
|
399 |
TRequestStatus& aStatus)
|
sl@0
|
400 |
{
|
sl@0
|
401 |
if (DoOpen(aHandle, aStatus))
|
sl@0
|
402 |
{
|
sl@0
|
403 |
iKeyStore->Decrypt(aHandle, aCiphertext, aPlaintextPtr, iStatus);
|
sl@0
|
404 |
}
|
sl@0
|
405 |
}
|
sl@0
|
406 |
|
sl@0
|
407 |
void CUnifiedKeyStore::Sign(const TCTTokenObjectHandle& aHandle,
|
sl@0
|
408 |
const TDesC8& aPlaintext,
|
sl@0
|
409 |
CryptoSpi::CCryptoParams*& aSignature,
|
sl@0
|
410 |
TRequestStatus& aStatus)
|
sl@0
|
411 |
{
|
sl@0
|
412 |
if (DoOpen(aHandle, aStatus))
|
sl@0
|
413 |
{
|
sl@0
|
414 |
iKeyStore->Sign(aHandle, aPlaintext, aSignature, iStatus);
|
sl@0
|
415 |
}
|
sl@0
|
416 |
}
|
sl@0
|
417 |
#endif //SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
|
sl@0
|
418 |
|
sl@0
|
419 |
// ************************************************************************
|
sl@0
|
420 |
// MKeyStoreManager
|
sl@0
|
421 |
// ************************************************************************
|
sl@0
|
422 |
|
sl@0
|
423 |
EXPORT_C void CUnifiedKeyStore::ExportKey(TCTTokenObjectHandle aHandle,
|
sl@0
|
424 |
HBufC8*& aKey, TRequestStatus& aStatus)
|
sl@0
|
425 |
{
|
sl@0
|
426 |
StartAsyncOperation(EExportKey, aStatus);
|
sl@0
|
427 |
|
sl@0
|
428 |
ASSERT(!iKeyStoreManager);
|
sl@0
|
429 |
iKeyStoreManager = FindKeyStoreManager(aHandle);
|
sl@0
|
430 |
if (!iKeyStoreManager)
|
sl@0
|
431 |
{
|
sl@0
|
432 |
Complete(KErrNotFound);
|
sl@0
|
433 |
return;
|
sl@0
|
434 |
}
|
sl@0
|
435 |
|
sl@0
|
436 |
iKeyStoreManager->ExportKey(aHandle, aKey, iStatus);
|
sl@0
|
437 |
SetActive();
|
sl@0
|
438 |
}
|
sl@0
|
439 |
|
sl@0
|
440 |
EXPORT_C void CUnifiedKeyStore::CancelExportKey()
|
sl@0
|
441 |
{
|
sl@0
|
442 |
if (iState == EExportKey)
|
sl@0
|
443 |
{
|
sl@0
|
444 |
Cancel();
|
sl@0
|
445 |
}
|
sl@0
|
446 |
}
|
sl@0
|
447 |
|
sl@0
|
448 |
EXPORT_C void CUnifiedKeyStore::ExportEncryptedKey(TCTTokenObjectHandle aHandle,
|
sl@0
|
449 |
const CPBEncryptParms& aEncryptParams,
|
sl@0
|
450 |
HBufC8*& aKey, TRequestStatus& aStatus)
|
sl@0
|
451 |
{
|
sl@0
|
452 |
StartAsyncOperation(EExportEncryptedKey, aStatus);
|
sl@0
|
453 |
|
sl@0
|
454 |
ASSERT(!iKeyStoreManager);
|
sl@0
|
455 |
iKeyStoreManager = FindKeyStoreManager(aHandle);
|
sl@0
|
456 |
if (!iKeyStoreManager)
|
sl@0
|
457 |
{
|
sl@0
|
458 |
Complete(KErrNotFound);
|
sl@0
|
459 |
return;
|
sl@0
|
460 |
}
|
sl@0
|
461 |
|
sl@0
|
462 |
iKeyStoreManager->ExportEncryptedKey(aHandle, aEncryptParams, aKey, iStatus);
|
sl@0
|
463 |
SetActive();
|
sl@0
|
464 |
}
|
sl@0
|
465 |
|
sl@0
|
466 |
EXPORT_C void CUnifiedKeyStore::CancelExportEncryptedKey()
|
sl@0
|
467 |
{
|
sl@0
|
468 |
if (iState == EExportEncryptedKey)
|
sl@0
|
469 |
{
|
sl@0
|
470 |
Cancel();
|
sl@0
|
471 |
}
|
sl@0
|
472 |
}
|
sl@0
|
473 |
|
sl@0
|
474 |
EXPORT_C void CUnifiedKeyStore::DeleteKey(TCTTokenObjectHandle aHandle,
|
sl@0
|
475 |
TRequestStatus& aStatus)
|
sl@0
|
476 |
{
|
sl@0
|
477 |
StartAsyncOperation(EDeleteKey, aStatus);
|
sl@0
|
478 |
|
sl@0
|
479 |
iKeyStoreManager = FindKeyStoreManager(aHandle);
|
sl@0
|
480 |
if (!iKeyStoreManager)
|
sl@0
|
481 |
{
|
sl@0
|
482 |
Complete(KErrNotFound);
|
sl@0
|
483 |
return;
|
sl@0
|
484 |
}
|
sl@0
|
485 |
|
sl@0
|
486 |
iKeyStoreManager->DeleteKey(aHandle, iStatus);
|
sl@0
|
487 |
SetActive();
|
sl@0
|
488 |
}
|
sl@0
|
489 |
|
sl@0
|
490 |
EXPORT_C void CUnifiedKeyStore::CancelDeleteKey()
|
sl@0
|
491 |
{
|
sl@0
|
492 |
if (iState == EDeleteKey)
|
sl@0
|
493 |
{
|
sl@0
|
494 |
Cancel();
|
sl@0
|
495 |
}
|
sl@0
|
496 |
}
|
sl@0
|
497 |
|
sl@0
|
498 |
EXPORT_C void CUnifiedKeyStore::SetUsePolicy(TCTTokenObjectHandle aHandle,
|
sl@0
|
499 |
const TSecurityPolicy& aPolicy,
|
sl@0
|
500 |
TRequestStatus& aStatus)
|
sl@0
|
501 |
{
|
sl@0
|
502 |
StartAsyncOperation(ESetUsePolicy, aStatus);
|
sl@0
|
503 |
|
sl@0
|
504 |
iKeyStoreManager = FindKeyStoreManager(aHandle);
|
sl@0
|
505 |
if (!iKeyStoreManager)
|
sl@0
|
506 |
{
|
sl@0
|
507 |
Complete(KErrNotFound);
|
sl@0
|
508 |
return;
|
sl@0
|
509 |
}
|
sl@0
|
510 |
|
sl@0
|
511 |
iKeyStoreManager->SetUsePolicy(aHandle, aPolicy, iStatus);
|
sl@0
|
512 |
SetActive();
|
sl@0
|
513 |
}
|
sl@0
|
514 |
|
sl@0
|
515 |
EXPORT_C void CUnifiedKeyStore::CancelSetUsePolicy()
|
sl@0
|
516 |
{
|
sl@0
|
517 |
if (iState == ESetUsePolicy)
|
sl@0
|
518 |
{
|
sl@0
|
519 |
Cancel();
|
sl@0
|
520 |
}
|
sl@0
|
521 |
}
|
sl@0
|
522 |
|
sl@0
|
523 |
EXPORT_C void CUnifiedKeyStore::SetManagementPolicy(TCTTokenObjectHandle aHandle,
|
sl@0
|
524 |
const TSecurityPolicy& aPolicy,
|
sl@0
|
525 |
TRequestStatus& aStatus)
|
sl@0
|
526 |
{
|
sl@0
|
527 |
StartAsyncOperation(ESetManagementPolicy, aStatus);
|
sl@0
|
528 |
|
sl@0
|
529 |
iKeyStoreManager = FindKeyStoreManager(aHandle);
|
sl@0
|
530 |
if (!iKeyStoreManager)
|
sl@0
|
531 |
{
|
sl@0
|
532 |
Complete(KErrNotFound);
|
sl@0
|
533 |
return;
|
sl@0
|
534 |
}
|
sl@0
|
535 |
|
sl@0
|
536 |
iKeyStoreManager->SetManagementPolicy(aHandle, aPolicy, iStatus);
|
sl@0
|
537 |
SetActive();
|
sl@0
|
538 |
}
|
sl@0
|
539 |
|
sl@0
|
540 |
EXPORT_C void CUnifiedKeyStore::CancelSetManagementPolicy()
|
sl@0
|
541 |
{
|
sl@0
|
542 |
if (iState == ESetManagementPolicy)
|
sl@0
|
543 |
{
|
sl@0
|
544 |
Cancel();
|
sl@0
|
545 |
}
|
sl@0
|
546 |
}
|
sl@0
|
547 |
|
sl@0
|
548 |
EXPORT_C void CUnifiedKeyStore::SetPassphraseTimeout(TInt aTimeout,
|
sl@0
|
549 |
TRequestStatus& aStatus)
|
sl@0
|
550 |
{
|
sl@0
|
551 |
StartAsyncOperation(ESetPassphraseTimeout, aStatus);
|
sl@0
|
552 |
|
sl@0
|
553 |
iIndex = -1;
|
sl@0
|
554 |
iNewTimeout = aTimeout;
|
sl@0
|
555 |
SetActive();
|
sl@0
|
556 |
|
sl@0
|
557 |
TRequestStatus* status = &iStatus;
|
sl@0
|
558 |
User::RequestComplete(status, KErrNone);
|
sl@0
|
559 |
}
|
sl@0
|
560 |
|
sl@0
|
561 |
EXPORT_C void CUnifiedKeyStore::CancelSetPassphraseTimeout()
|
sl@0
|
562 |
{
|
sl@0
|
563 |
if (iState == ESetPassphraseTimeout)
|
sl@0
|
564 |
{
|
sl@0
|
565 |
Cancel();
|
sl@0
|
566 |
}
|
sl@0
|
567 |
}
|
sl@0
|
568 |
|
sl@0
|
569 |
EXPORT_C void CUnifiedKeyStore::Relock(TRequestStatus& aStatus)
|
sl@0
|
570 |
{
|
sl@0
|
571 |
StartAsyncOperation(ERelock, aStatus);
|
sl@0
|
572 |
|
sl@0
|
573 |
iIndex = -1;
|
sl@0
|
574 |
SetActive();
|
sl@0
|
575 |
|
sl@0
|
576 |
TRequestStatus* status = &iStatus;
|
sl@0
|
577 |
User::RequestComplete(status, KErrNone);
|
sl@0
|
578 |
}
|
sl@0
|
579 |
|
sl@0
|
580 |
EXPORT_C void CUnifiedKeyStore::CancelRelock()
|
sl@0
|
581 |
{
|
sl@0
|
582 |
if (iState == ERelock)
|
sl@0
|
583 |
{
|
sl@0
|
584 |
Cancel();
|
sl@0
|
585 |
}
|
sl@0
|
586 |
}
|
sl@0
|
587 |
|
sl@0
|
588 |
// ************************************************************************
|
sl@0
|
589 |
// Other exports
|
sl@0
|
590 |
// ************************************************************************
|
sl@0
|
591 |
|
sl@0
|
592 |
EXPORT_C TInt CUnifiedKeyStore::KeyStoreCount() const
|
sl@0
|
593 |
{
|
sl@0
|
594 |
return (iKeyStoresHolder.Count());
|
sl@0
|
595 |
}
|
sl@0
|
596 |
|
sl@0
|
597 |
EXPORT_C MCTKeyStore& CUnifiedKeyStore::KeyStore(TInt aIndex)
|
sl@0
|
598 |
{
|
sl@0
|
599 |
__ASSERT_ALWAYS(aIndex >= 0 && aIndex < iKeyStoresHolder.Count(),
|
sl@0
|
600 |
User::Panic(KUnifiedKeyStore, EArrayAccessOutOfBounds));
|
sl@0
|
601 |
|
sl@0
|
602 |
MCTKeyStore* keyStore = static_cast<MCTKeyStore*>(iKeyStoresHolder[aIndex]->KeyStore());
|
sl@0
|
603 |
return (*keyStore);
|
sl@0
|
604 |
}
|
sl@0
|
605 |
|
sl@0
|
606 |
EXPORT_C TInt CUnifiedKeyStore::KeyStoreManagerCount() const
|
sl@0
|
607 |
{
|
sl@0
|
608 |
TInt result = 0;
|
sl@0
|
609 |
for (TInt i = 0 ; i < iKeyStoresHolder.Count() ; ++i)
|
sl@0
|
610 |
{
|
sl@0
|
611 |
if (iKeyStoresHolder[i]->IsKeyManager())
|
sl@0
|
612 |
{
|
sl@0
|
613 |
++result;
|
sl@0
|
614 |
}
|
sl@0
|
615 |
}
|
sl@0
|
616 |
return result;
|
sl@0
|
617 |
}
|
sl@0
|
618 |
|
sl@0
|
619 |
EXPORT_C MCTKeyStoreManager& CUnifiedKeyStore::KeyStoreManager(TInt aIndex)
|
sl@0
|
620 |
{
|
sl@0
|
621 |
__ASSERT_ALWAYS(aIndex >= 0, User::Panic(KUnifiedKeyStore, EArrayAccessOutOfBounds));
|
sl@0
|
622 |
TInt managerIndex = 0;
|
sl@0
|
623 |
MCTKeyStoreManager* result = NULL;
|
sl@0
|
624 |
for (TInt i = 0 ; i < iKeyStoresHolder.Count() ; ++i)
|
sl@0
|
625 |
{
|
sl@0
|
626 |
if (iKeyStoresHolder[i]->IsKeyManager())
|
sl@0
|
627 |
{
|
sl@0
|
628 |
if (managerIndex == aIndex)
|
sl@0
|
629 |
{
|
sl@0
|
630 |
result = static_cast<MCTKeyStoreManager*>(iKeyStoresHolder[i]->KeyStore());
|
sl@0
|
631 |
break;
|
sl@0
|
632 |
}
|
sl@0
|
633 |
++managerIndex;
|
sl@0
|
634 |
}
|
sl@0
|
635 |
}
|
sl@0
|
636 |
__ASSERT_ALWAYS(result != NULL, User::Panic(KUnifiedKeyStore, EArrayAccessOutOfBounds));
|
sl@0
|
637 |
return *result;
|
sl@0
|
638 |
}
|
sl@0
|
639 |
|
sl@0
|
640 |
#ifdef SYMBIAN_AUTH_SERVER
|
sl@0
|
641 |
|
sl@0
|
642 |
EXPORT_C void CUnifiedKeyStore::CreateKey( TInt aKeyStoreIndex, TKeyUsagePKCS15 aUsage,TUint aSize,
|
sl@0
|
643 |
const TDesC& aLabel, CCTKeyInfo::EKeyAlgorithm aAlgorithm,
|
sl@0
|
644 |
TInt aAccessType, TTime aStartDate, TTime aEndDate,
|
sl@0
|
645 |
const TDesC& aAuthenticationString, TInt aFreshness,
|
sl@0
|
646 |
CCTKeyInfo*& aKeyInfoOut, TRequestStatus& aStatus)
|
sl@0
|
647 |
{
|
sl@0
|
648 |
|
sl@0
|
649 |
StartAsyncOperation(ECreateKey, aStatus);
|
sl@0
|
650 |
TRAPD(err, PrepareToCreateKeyL(aKeyStoreIndex, aUsage, aSize, aLabel, aAlgorithm, aAccessType,
|
sl@0
|
651 |
aStartDate, aEndDate, aStatus));
|
sl@0
|
652 |
if (KErrNone != err)
|
sl@0
|
653 |
{
|
sl@0
|
654 |
Complete(err);
|
sl@0
|
655 |
return;
|
sl@0
|
656 |
}
|
sl@0
|
657 |
|
sl@0
|
658 |
iKeyInfoOut = &aKeyInfoOut;
|
sl@0
|
659 |
aKeyInfoOut = NULL;
|
sl@0
|
660 |
iKeyStoreManager->CreateKey(aAuthenticationString, aFreshness, iKeyInfo, iStatus);
|
sl@0
|
661 |
SetActive();
|
sl@0
|
662 |
|
sl@0
|
663 |
}
|
sl@0
|
664 |
|
sl@0
|
665 |
|
sl@0
|
666 |
EXPORT_C void CUnifiedKeyStore::ImportKey( TInt aKeyStoreIndex, const TDesC8& aKeyData,
|
sl@0
|
667 |
TKeyUsagePKCS15 aUsage, const TDesC& aLabel,
|
sl@0
|
668 |
TInt aAccessType, TTime aStartDate, TTime aEndDate,
|
sl@0
|
669 |
const TDesC& aAuthenticationString, TInt aFreshness,
|
sl@0
|
670 |
CCTKeyInfo*& aKeyInfoOut, TRequestStatus& aStatus)
|
sl@0
|
671 |
{
|
sl@0
|
672 |
TBool isEncrypted = TASN1DecPKCS8::IsEncryptedPKCS8Data(aKeyData);
|
sl@0
|
673 |
StartAsyncOperation(isEncrypted ? EImportKeyEncrypted : EImportKey, aStatus);
|
sl@0
|
674 |
|
sl@0
|
675 |
ASSERT(!iKeyData);
|
sl@0
|
676 |
iKeyData = aKeyData.Alloc();
|
sl@0
|
677 |
if (!iKeyData) // OOM or some other catastrophe
|
sl@0
|
678 |
{
|
sl@0
|
679 |
Complete(KErrNoMemory);
|
sl@0
|
680 |
return;
|
sl@0
|
681 |
}
|
sl@0
|
682 |
|
sl@0
|
683 |
TRAPD(err, PrepareToCreateKeyL(aKeyStoreIndex, aUsage, 0, aLabel, CCTKeyInfo::EInvalidAlgorithm, aAccessType,
|
sl@0
|
684 |
aStartDate, aEndDate, aStatus));
|
sl@0
|
685 |
if (KErrNone != err)
|
sl@0
|
686 |
{
|
sl@0
|
687 |
Complete(err);
|
sl@0
|
688 |
return;
|
sl@0
|
689 |
}
|
sl@0
|
690 |
|
sl@0
|
691 |
iKeyInfoOut = &aKeyInfoOut;
|
sl@0
|
692 |
aKeyInfoOut = NULL;
|
sl@0
|
693 |
|
sl@0
|
694 |
if (isEncrypted)
|
sl@0
|
695 |
{
|
sl@0
|
696 |
iKeyStoreManager->ImportEncryptedKey(*iKeyData, aAuthenticationString, aFreshness, iKeyInfo, iStatus);
|
sl@0
|
697 |
}
|
sl@0
|
698 |
else
|
sl@0
|
699 |
{
|
sl@0
|
700 |
iKeyStoreManager->ImportKey(*iKeyData, aAuthenticationString, aFreshness, iKeyInfo, iStatus);
|
sl@0
|
701 |
}
|
sl@0
|
702 |
SetActive();
|
sl@0
|
703 |
}
|
sl@0
|
704 |
|
sl@0
|
705 |
EXPORT_C void CUnifiedKeyStore::SetAuthenticationPolicy( const TCTTokenObjectHandle aHandle,
|
sl@0
|
706 |
const TDesC& aAuthenticationString,
|
sl@0
|
707 |
TInt aFreshness,
|
sl@0
|
708 |
TRequestStatus& aStatus)
|
sl@0
|
709 |
{
|
sl@0
|
710 |
StartAsyncOperation(ESetAuthenticationPolicy, aStatus);
|
sl@0
|
711 |
|
sl@0
|
712 |
ASSERT(!iKeyStoreManager);
|
sl@0
|
713 |
iKeyStoreManager = FindKeyStoreManager(aHandle);
|
sl@0
|
714 |
if (!iKeyStoreManager)
|
sl@0
|
715 |
{
|
sl@0
|
716 |
Complete(KErrNotFound);
|
sl@0
|
717 |
return;
|
sl@0
|
718 |
}
|
sl@0
|
719 |
|
sl@0
|
720 |
iKeyStoreManager->SetAuthenticationPolicy(aHandle, aAuthenticationString, aFreshness, iStatus);
|
sl@0
|
721 |
SetActive();
|
sl@0
|
722 |
|
sl@0
|
723 |
}
|
sl@0
|
724 |
|
sl@0
|
725 |
EXPORT_C void CUnifiedKeyStore::GetAuthenticationPolicy( const TCTTokenObjectHandle aHandle,
|
sl@0
|
726 |
HBufC*& aAuthenticationString,
|
sl@0
|
727 |
TInt& aFreshness,
|
sl@0
|
728 |
TRequestStatus& aStatus)
|
sl@0
|
729 |
{
|
sl@0
|
730 |
StartAsyncOperation(EGetAuthenticationPolicy, aStatus);
|
sl@0
|
731 |
|
sl@0
|
732 |
ASSERT(!iKeyStoreManager);
|
sl@0
|
733 |
iKeyStoreManager = FindKeyStoreManager(aHandle);
|
sl@0
|
734 |
if (!iKeyStoreManager)
|
sl@0
|
735 |
{
|
sl@0
|
736 |
Complete(KErrNotFound);
|
sl@0
|
737 |
return;
|
sl@0
|
738 |
}
|
sl@0
|
739 |
|
sl@0
|
740 |
iKeyStoreManager->GetAuthenticationPolicy(aHandle, aAuthenticationString, aFreshness, iStatus);
|
sl@0
|
741 |
SetActive();
|
sl@0
|
742 |
|
sl@0
|
743 |
}
|
sl@0
|
744 |
|
sl@0
|
745 |
#endif // SYMBIAN_AUTH_SERVER
|
sl@0
|
746 |
|
sl@0
|
747 |
CUnifiedKeyStore::CUnifiedKeyStore(RFs& aFs)
|
sl@0
|
748 |
: CActive(EPriorityNormal), iFs(aFs), iState(EIdle)
|
sl@0
|
749 |
{// Currently defaults to always try for key store manager interface
|
sl@0
|
750 |
// This may change (add parameter to NewL for required interface)
|
sl@0
|
751 |
iRequestUid.iUid = KInterfaceKeyStoreManager;
|
sl@0
|
752 |
CActiveScheduler::Add(this);
|
sl@0
|
753 |
}
|
sl@0
|
754 |
|
sl@0
|
755 |
void CUnifiedKeyStore::ConstructL()
|
sl@0
|
756 |
{}
|
sl@0
|
757 |
|
sl@0
|
758 |
void CUnifiedKeyStore::StartAsyncOperation(TState aState, TRequestStatus& aStatus)
|
sl@0
|
759 |
{
|
sl@0
|
760 |
ASSERT(iState == EIdle);
|
sl@0
|
761 |
ASSERT(iOriginalRequestStatus == NULL);
|
sl@0
|
762 |
iState = aState;
|
sl@0
|
763 |
iOriginalRequestStatus = &aStatus;
|
sl@0
|
764 |
aStatus = KRequestPending;
|
sl@0
|
765 |
}
|
sl@0
|
766 |
|
sl@0
|
767 |
MCTKeyStore* CUnifiedKeyStore::FindKeyStore(const TCTTokenObjectHandle& aHandle)
|
sl@0
|
768 |
{
|
sl@0
|
769 |
for (TInt index = 0 ; index < iKeyStoresHolder.Count() ; ++index)
|
sl@0
|
770 |
{
|
sl@0
|
771 |
MCTTokenInterface* store = iKeyStoresHolder[index]->KeyStore();
|
sl@0
|
772 |
ASSERT(store);
|
sl@0
|
773 |
if (store->Token().Handle() == aHandle.iTokenHandle)
|
sl@0
|
774 |
{
|
sl@0
|
775 |
return static_cast<MCTKeyStoreManager*>(store);
|
sl@0
|
776 |
}
|
sl@0
|
777 |
}
|
sl@0
|
778 |
return NULL;
|
sl@0
|
779 |
}
|
sl@0
|
780 |
|
sl@0
|
781 |
MCTKeyStoreManager* CUnifiedKeyStore::FindKeyStoreManager(const TCTTokenObjectHandle& aHandle)
|
sl@0
|
782 |
{
|
sl@0
|
783 |
for (TInt index = 0 ; index < iKeyStoresHolder.Count() ; ++index)
|
sl@0
|
784 |
{
|
sl@0
|
785 |
MCTTokenInterface* store = iKeyStoresHolder[index]->KeyStore();
|
sl@0
|
786 |
ASSERT(store);
|
sl@0
|
787 |
if (store->Token().Handle() == aHandle.iTokenHandle && iKeyStoresHolder[index]->IsKeyManager())
|
sl@0
|
788 |
{
|
sl@0
|
789 |
return static_cast<MCTKeyStoreManager*>(store);
|
sl@0
|
790 |
}
|
sl@0
|
791 |
}
|
sl@0
|
792 |
return NULL;
|
sl@0
|
793 |
}
|
sl@0
|
794 |
|
sl@0
|
795 |
void CUnifiedKeyStore::RunL()
|
sl@0
|
796 |
{
|
sl@0
|
797 |
if (EInitializeGetKeyUserInterfaceFinished != iState &&
|
sl@0
|
798 |
EInitializeGetKeyUserInterface != iState &&
|
sl@0
|
799 |
EInitializeGetToken != iState)
|
sl@0
|
800 |
{
|
sl@0
|
801 |
User::LeaveIfError(iStatus.Int());
|
sl@0
|
802 |
}
|
sl@0
|
803 |
|
sl@0
|
804 |
switch (iState)
|
sl@0
|
805 |
{
|
sl@0
|
806 |
case EInitializeGetTokenList:
|
sl@0
|
807 |
{// Try to get a list of Tokens for each of the Token Types
|
sl@0
|
808 |
iIndexTokenTypes++;
|
sl@0
|
809 |
if (iIndexTokenTypes < iTokenTypes.Count())
|
sl@0
|
810 |
{
|
sl@0
|
811 |
__ASSERT_DEBUG(!iTokenType, User::Panic(KUnifiedKeyStore, EArrayAccessOutOfBounds));
|
sl@0
|
812 |
iTokenType = MCTTokenType::NewL(*iTokenTypes[iIndexTokenTypes], iFs);
|
sl@0
|
813 |
__ASSERT_DEBUG(iTokens.Count()==0, User::Panic(KUnifiedKeyStore, ETokensArrayAlreadyInUse));
|
sl@0
|
814 |
iTokenType->List(iTokens, iStatus);
|
sl@0
|
815 |
iIndexTokens = -1;
|
sl@0
|
816 |
iState = EInitializeGetToken;
|
sl@0
|
817 |
}
|
sl@0
|
818 |
else
|
sl@0
|
819 |
{// We don't need the list of Token Types anymore
|
sl@0
|
820 |
iTokenTypes.ResetAndDestroy();
|
sl@0
|
821 |
iTokenTypes.Close();
|
sl@0
|
822 |
iState = EInitializeFinished;
|
sl@0
|
823 |
TRequestStatus* status = &iStatus;
|
sl@0
|
824 |
User::RequestComplete(status, KErrNone);
|
sl@0
|
825 |
}
|
sl@0
|
826 |
SetActive();
|
sl@0
|
827 |
break;
|
sl@0
|
828 |
}
|
sl@0
|
829 |
case EInitializeGetToken:
|
sl@0
|
830 |
{
|
sl@0
|
831 |
if (iStatus.Int() == KErrHardwareNotAvailable)
|
sl@0
|
832 |
{
|
sl@0
|
833 |
// If the hardware corresponding to this
|
sl@0
|
834 |
// TokenType has been removed then just skip it
|
sl@0
|
835 |
// but DO NOT leave!
|
sl@0
|
836 |
++iIndexTokens;
|
sl@0
|
837 |
iState = EInitializeGetToken;
|
sl@0
|
838 |
TRequestStatus* status = &iStatus;
|
sl@0
|
839 |
User::RequestComplete(status, KErrNone);
|
sl@0
|
840 |
}
|
sl@0
|
841 |
else
|
sl@0
|
842 |
{
|
sl@0
|
843 |
User::LeaveIfError(iStatus.Int());
|
sl@0
|
844 |
iIndexTokens++;
|
sl@0
|
845 |
|
sl@0
|
846 |
if (iIndexTokens < iTokens.Count())
|
sl@0
|
847 |
{
|
sl@0
|
848 |
iTokenType->OpenToken(*iTokens[iIndexTokens], iToken, iStatus);
|
sl@0
|
849 |
iRequestUid.iUid = KInterfaceKeyStoreManager;
|
sl@0
|
850 |
iState = EInitialiseGetKeyManagerInterface;
|
sl@0
|
851 |
}
|
sl@0
|
852 |
else
|
sl@0
|
853 |
{// Don't need the iTokenType anymore
|
sl@0
|
854 |
iTokenType->Release();
|
sl@0
|
855 |
iTokenType = 0;
|
sl@0
|
856 |
|
sl@0
|
857 |
iTokens.Close(); // Don't need the list of Tokens anymore
|
sl@0
|
858 |
iState = EInitializeGetTokenList;
|
sl@0
|
859 |
TRequestStatus* status = &iStatus;
|
sl@0
|
860 |
User::RequestComplete(status, KErrNone);
|
sl@0
|
861 |
}
|
sl@0
|
862 |
}
|
sl@0
|
863 |
SetActive();
|
sl@0
|
864 |
break;
|
sl@0
|
865 |
}
|
sl@0
|
866 |
case EInitialiseGetKeyManagerInterface:
|
sl@0
|
867 |
{// First try to get a manager interface to the store, if
|
sl@0
|
868 |
// unsuccessful, try once to get a user interface
|
sl@0
|
869 |
if (iToken)
|
sl@0
|
870 |
{
|
sl@0
|
871 |
iRequestUid.iUid = KInterfaceKeyStoreManager;
|
sl@0
|
872 |
iToken->GetInterface(iRequestUid, iTokenInterface, iStatus);
|
sl@0
|
873 |
iState = EInitializeGetKeyUserInterface;
|
sl@0
|
874 |
SetActive();
|
sl@0
|
875 |
}
|
sl@0
|
876 |
else
|
sl@0
|
877 |
{// No token
|
sl@0
|
878 |
User::Leave(KErrNotReady);
|
sl@0
|
879 |
}
|
sl@0
|
880 |
break;
|
sl@0
|
881 |
}
|
sl@0
|
882 |
case EInitializeGetKeyUserInterface:
|
sl@0
|
883 |
{// Did we get a manager interface?
|
sl@0
|
884 |
if (iStatus==KErrNoMemory)
|
sl@0
|
885 |
{
|
sl@0
|
886 |
User::Leave(KErrNoMemory);
|
sl@0
|
887 |
}
|
sl@0
|
888 |
|
sl@0
|
889 |
if (iRequestUid.iUid==KInterfaceKeyStoreManager)
|
sl@0
|
890 |
{
|
sl@0
|
891 |
if (KErrNone==iStatus.Int())
|
sl@0
|
892 |
{// Success! Store it and finish up
|
sl@0
|
893 |
CKeyStoreIF* keyStore = new (ELeave) CKeyStoreIF(iTokenInterface, ETrue);
|
sl@0
|
894 |
CleanupStack::PushL(keyStore);
|
sl@0
|
895 |
User::LeaveIfError(iKeyStoresHolder.Append(keyStore));
|
sl@0
|
896 |
CleanupStack::Pop(keyStore);
|
sl@0
|
897 |
|
sl@0
|
898 |
iTokenInterface = 0;
|
sl@0
|
899 |
iToken->Release();
|
sl@0
|
900 |
iToken = 0;
|
sl@0
|
901 |
iState = EInitializeGetToken;
|
sl@0
|
902 |
TRequestStatus* status = &iStatus;
|
sl@0
|
903 |
User::RequestComplete(status, KErrNone);
|
sl@0
|
904 |
}
|
sl@0
|
905 |
else
|
sl@0
|
906 |
{// No luck getting a manager, so try getting a user
|
sl@0
|
907 |
iRequestUid.iUid = KInterfaceKeyStore;
|
sl@0
|
908 |
iToken->GetInterface(iRequestUid, iTokenInterface, iStatus);
|
sl@0
|
909 |
iState = EInitializeGetKeyUserInterfaceFinished;
|
sl@0
|
910 |
}
|
sl@0
|
911 |
}
|
sl@0
|
912 |
else if (iRequestUid.iUid==KInterfaceKeyStore)
|
sl@0
|
913 |
{// We were trying for user IF
|
sl@0
|
914 |
if (iStatus==KErrNone)
|
sl@0
|
915 |
{
|
sl@0
|
916 |
if (iToken)
|
sl@0
|
917 |
{
|
sl@0
|
918 |
iRequestUid.iUid = KInterfaceKeyStore;
|
sl@0
|
919 |
iToken->GetInterface(iRequestUid, iTokenInterface, iStatus);
|
sl@0
|
920 |
iState = EInitializeGetKeyUserInterfaceFinished;
|
sl@0
|
921 |
}
|
sl@0
|
922 |
else
|
sl@0
|
923 |
{
|
sl@0
|
924 |
User::Leave(KErrNotReady);
|
sl@0
|
925 |
}
|
sl@0
|
926 |
}
|
sl@0
|
927 |
else
|
sl@0
|
928 |
{// Couldn't even get a user IF
|
sl@0
|
929 |
User::Leave(iStatus.Int());
|
sl@0
|
930 |
}
|
sl@0
|
931 |
}
|
sl@0
|
932 |
|
sl@0
|
933 |
SetActive();
|
sl@0
|
934 |
break;
|
sl@0
|
935 |
}
|
sl@0
|
936 |
case EInitializeGetKeyUserInterfaceFinished:
|
sl@0
|
937 |
{
|
sl@0
|
938 |
if (iStatus==KErrNone)
|
sl@0
|
939 |
{
|
sl@0
|
940 |
CKeyStoreIF* keyStore = new (ELeave) CKeyStoreIF(iTokenInterface, EFalse);
|
sl@0
|
941 |
CleanupStack::PushL(keyStore);
|
sl@0
|
942 |
User::LeaveIfError(iKeyStoresHolder.Append(keyStore));
|
sl@0
|
943 |
CleanupStack::Pop(keyStore);
|
sl@0
|
944 |
|
sl@0
|
945 |
iTokenInterface = 0;
|
sl@0
|
946 |
iToken->Release();
|
sl@0
|
947 |
iToken = 0;
|
sl@0
|
948 |
iState = EInitializeGetToken;
|
sl@0
|
949 |
TRequestStatus* status = &iStatus;
|
sl@0
|
950 |
User::RequestComplete(status, KErrNone);
|
sl@0
|
951 |
}
|
sl@0
|
952 |
else if (iStatus == KErrNoMemory)
|
sl@0
|
953 |
{
|
sl@0
|
954 |
User::Leave(KErrNoMemory);
|
sl@0
|
955 |
}
|
sl@0
|
956 |
else
|
sl@0
|
957 |
{
|
sl@0
|
958 |
iState = EInitializeGetToken;
|
sl@0
|
959 |
TRequestStatus* status = &iStatus;
|
sl@0
|
960 |
User::RequestComplete(status,iStatus.Int());
|
sl@0
|
961 |
}
|
sl@0
|
962 |
|
sl@0
|
963 |
SetActive();
|
sl@0
|
964 |
break;
|
sl@0
|
965 |
}
|
sl@0
|
966 |
case EInitializeFinished:
|
sl@0
|
967 |
Complete(KErrNone);
|
sl@0
|
968 |
break;
|
sl@0
|
969 |
|
sl@0
|
970 |
case EList:
|
sl@0
|
971 |
{// iIndex has been initialized in List function
|
sl@0
|
972 |
++iIndex;
|
sl@0
|
973 |
if (iIndex < iKeyStoresHolder.Count())
|
sl@0
|
974 |
{
|
sl@0
|
975 |
iKeyStore = static_cast<MCTKeyStore*>(iKeyStoresHolder[iIndex]->KeyStore());
|
sl@0
|
976 |
ASSERT(iKeyStore);
|
sl@0
|
977 |
iKeyStore->List(*iKeyInfos, *iFilter, iStatus);
|
sl@0
|
978 |
SetActive();
|
sl@0
|
979 |
}
|
sl@0
|
980 |
else
|
sl@0
|
981 |
{
|
sl@0
|
982 |
Complete(KErrNone);
|
sl@0
|
983 |
}
|
sl@0
|
984 |
break;
|
sl@0
|
985 |
}
|
sl@0
|
986 |
|
sl@0
|
987 |
case EGetKeyInfo:
|
sl@0
|
988 |
Complete(KErrNone);
|
sl@0
|
989 |
break;
|
sl@0
|
990 |
|
sl@0
|
991 |
case ECreateKey:
|
sl@0
|
992 |
*iKeyInfoOut = iKeyInfo;
|
sl@0
|
993 |
iKeyInfo = NULL; // Release ownership
|
sl@0
|
994 |
Complete(KErrNone);
|
sl@0
|
995 |
break;
|
sl@0
|
996 |
|
sl@0
|
997 |
case EImportKey:
|
sl@0
|
998 |
case EImportKeyEncrypted:
|
sl@0
|
999 |
*iKeyInfoOut = iKeyInfo;
|
sl@0
|
1000 |
iKeyInfo = NULL; // Release ownership
|
sl@0
|
1001 |
Complete(KErrNone);
|
sl@0
|
1002 |
break;
|
sl@0
|
1003 |
|
sl@0
|
1004 |
case EExportKey:
|
sl@0
|
1005 |
case EExportEncryptedKey:
|
sl@0
|
1006 |
Complete(KErrNone);
|
sl@0
|
1007 |
break;
|
sl@0
|
1008 |
|
sl@0
|
1009 |
case ERelock:
|
sl@0
|
1010 |
++iIndex;
|
sl@0
|
1011 |
|
sl@0
|
1012 |
// Find next key store manager
|
sl@0
|
1013 |
while (iIndex < iKeyStoresHolder.Count() && !iKeyStoresHolder[iIndex]->IsKeyManager())
|
sl@0
|
1014 |
++iIndex;
|
sl@0
|
1015 |
|
sl@0
|
1016 |
if (iIndex < iKeyStoresHolder.Count())
|
sl@0
|
1017 |
{
|
sl@0
|
1018 |
iKeyStoreManager = static_cast<MCTKeyStoreManager*>(iKeyStoresHolder[iIndex]->KeyStore());
|
sl@0
|
1019 |
ASSERT(iKeyStoreManager);
|
sl@0
|
1020 |
iKeyStoreManager->Relock(iStatus);
|
sl@0
|
1021 |
SetActive();
|
sl@0
|
1022 |
}
|
sl@0
|
1023 |
else
|
sl@0
|
1024 |
{
|
sl@0
|
1025 |
Complete(KErrNone);
|
sl@0
|
1026 |
}
|
sl@0
|
1027 |
break;
|
sl@0
|
1028 |
|
sl@0
|
1029 |
case ESetPassphraseTimeout:
|
sl@0
|
1030 |
++iIndex;
|
sl@0
|
1031 |
|
sl@0
|
1032 |
// Find next key store manager
|
sl@0
|
1033 |
while (iIndex < iKeyStoresHolder.Count() && !iKeyStoresHolder[iIndex]->IsKeyManager())
|
sl@0
|
1034 |
++iIndex;
|
sl@0
|
1035 |
|
sl@0
|
1036 |
if (iIndex < iKeyStoresHolder.Count())
|
sl@0
|
1037 |
{
|
sl@0
|
1038 |
iKeyStoreManager = static_cast<MCTKeyStoreManager*>(iKeyStoresHolder[iIndex]->KeyStore());
|
sl@0
|
1039 |
ASSERT(iKeyStoreManager);
|
sl@0
|
1040 |
iKeyStoreManager->SetPassphraseTimeout(iNewTimeout, iStatus);
|
sl@0
|
1041 |
SetActive();
|
sl@0
|
1042 |
}
|
sl@0
|
1043 |
else
|
sl@0
|
1044 |
{
|
sl@0
|
1045 |
Complete(KErrNone);
|
sl@0
|
1046 |
}
|
sl@0
|
1047 |
break;
|
sl@0
|
1048 |
|
sl@0
|
1049 |
case EOpen:
|
sl@0
|
1050 |
case EExportPublic:
|
sl@0
|
1051 |
case EDeleteKey:
|
sl@0
|
1052 |
case ESetUsePolicy:
|
sl@0
|
1053 |
case ESetManagementPolicy:
|
sl@0
|
1054 |
case EGetAuthenticationPolicy:
|
sl@0
|
1055 |
case ESetAuthenticationPolicy:
|
sl@0
|
1056 |
Complete(KErrNone);
|
sl@0
|
1057 |
break;
|
sl@0
|
1058 |
default:
|
sl@0
|
1059 |
User::Panic(KUnifiedKeyStore, EUnrecognisedState);
|
sl@0
|
1060 |
break;
|
sl@0
|
1061 |
}
|
sl@0
|
1062 |
}
|
sl@0
|
1063 |
|
sl@0
|
1064 |
TInt CUnifiedKeyStore::RunError(TInt aError)
|
sl@0
|
1065 |
{
|
sl@0
|
1066 |
Complete(aError);
|
sl@0
|
1067 |
return KErrNone;
|
sl@0
|
1068 |
}
|
sl@0
|
1069 |
|
sl@0
|
1070 |
void CUnifiedKeyStore::DoCancel()
|
sl@0
|
1071 |
{
|
sl@0
|
1072 |
// If the current state is the last state involved in handling a request, we
|
sl@0
|
1073 |
// check to see if we have already been completed - in this case we can
|
sl@0
|
1074 |
// simply complete the client with iStatus (this may be KErrNone). If we
|
sl@0
|
1075 |
// have not we cancel the outstanding request and pass the resulting iStatus
|
sl@0
|
1076 |
// back to the client - this too may indicate a successful completion if the
|
sl@0
|
1077 |
// cancel arrived after the request was executed.
|
sl@0
|
1078 |
//
|
sl@0
|
1079 |
// For more complex cases, where there are more states to go through before
|
sl@0
|
1080 |
// we finish servicing the client request, we cancel any outstanding
|
sl@0
|
1081 |
// request, and return KErrCancel to the client.
|
sl@0
|
1082 |
|
sl@0
|
1083 |
switch (iState)
|
sl@0
|
1084 |
{
|
sl@0
|
1085 |
case EInitializeFinished:
|
sl@0
|
1086 |
case EGetKeyInfo:
|
sl@0
|
1087 |
case ECreateKey:
|
sl@0
|
1088 |
case EImportKey:
|
sl@0
|
1089 |
case EImportKeyEncrypted:
|
sl@0
|
1090 |
case EExportKey:
|
sl@0
|
1091 |
case EExportEncryptedKey:
|
sl@0
|
1092 |
case EOpen:
|
sl@0
|
1093 |
case EExportPublic:
|
sl@0
|
1094 |
case EDeleteKey:
|
sl@0
|
1095 |
case ESetUsePolicy:
|
sl@0
|
1096 |
case ESetManagementPolicy:
|
sl@0
|
1097 |
if (iStatus == KRequestPending)
|
sl@0
|
1098 |
{
|
sl@0
|
1099 |
// Attempt to cancel outstanding request and pass status back to
|
sl@0
|
1100 |
// client
|
sl@0
|
1101 |
CancelOutstandingRequest();
|
sl@0
|
1102 |
Complete(iStatus.Int());
|
sl@0
|
1103 |
}
|
sl@0
|
1104 |
else
|
sl@0
|
1105 |
{
|
sl@0
|
1106 |
// We've already been completed - call RunL() to process results
|
sl@0
|
1107 |
// and complete client
|
sl@0
|
1108 |
TRAPD(err, RunL());
|
sl@0
|
1109 |
if (err != KErrNone)
|
sl@0
|
1110 |
{
|
sl@0
|
1111 |
RunError(err);
|
sl@0
|
1112 |
}
|
sl@0
|
1113 |
}
|
sl@0
|
1114 |
break;
|
sl@0
|
1115 |
|
sl@0
|
1116 |
default:
|
sl@0
|
1117 |
CancelOutstandingRequest();
|
sl@0
|
1118 |
Complete(KErrCancel);
|
sl@0
|
1119 |
break;
|
sl@0
|
1120 |
}
|
sl@0
|
1121 |
}
|
sl@0
|
1122 |
|
sl@0
|
1123 |
void CUnifiedKeyStore::CancelOutstandingRequest()
|
sl@0
|
1124 |
{
|
sl@0
|
1125 |
switch (iState)
|
sl@0
|
1126 |
{
|
sl@0
|
1127 |
case EInitializeGetTokenList:
|
sl@0
|
1128 |
case EInitializeGetToken:
|
sl@0
|
1129 |
case EInitialiseGetKeyManagerInterface:
|
sl@0
|
1130 |
case EInitializeGetKeyUserInterface:
|
sl@0
|
1131 |
case EInitializeGetKeyUserInterfaceFinished:
|
sl@0
|
1132 |
case EInitializeFinished:
|
sl@0
|
1133 |
// Don't have to cancel initialisation stuff - this happens when we
|
sl@0
|
1134 |
// release the objects in Cleanup().
|
sl@0
|
1135 |
iStatus = KErrCancel;
|
sl@0
|
1136 |
break;
|
sl@0
|
1137 |
|
sl@0
|
1138 |
case EList:
|
sl@0
|
1139 |
if (iKeyStore)
|
sl@0
|
1140 |
{
|
sl@0
|
1141 |
iKeyStore->CancelList();
|
sl@0
|
1142 |
}
|
sl@0
|
1143 |
break;
|
sl@0
|
1144 |
|
sl@0
|
1145 |
case EGetKeyInfo:
|
sl@0
|
1146 |
ASSERT(iKeyStore);
|
sl@0
|
1147 |
iKeyStore->CancelGetKeyInfo();
|
sl@0
|
1148 |
break;
|
sl@0
|
1149 |
|
sl@0
|
1150 |
case EOpen:
|
sl@0
|
1151 |
ASSERT(iKeyStore);
|
sl@0
|
1152 |
iKeyStore->CancelOpen();
|
sl@0
|
1153 |
break;
|
sl@0
|
1154 |
|
sl@0
|
1155 |
case EExportPublic:
|
sl@0
|
1156 |
ASSERT(iKeyStore);
|
sl@0
|
1157 |
iKeyStore->CancelExportPublic();
|
sl@0
|
1158 |
break;
|
sl@0
|
1159 |
|
sl@0
|
1160 |
case ECreateKey:
|
sl@0
|
1161 |
ASSERT(iKeyStoreManager);
|
sl@0
|
1162 |
iKeyStoreManager->CancelCreateKey();
|
sl@0
|
1163 |
break;
|
sl@0
|
1164 |
|
sl@0
|
1165 |
case EImportKey:
|
sl@0
|
1166 |
case EImportKeyEncrypted:
|
sl@0
|
1167 |
ASSERT(iKeyStoreManager);
|
sl@0
|
1168 |
iKeyStoreManager->CancelImportKey();
|
sl@0
|
1169 |
break;
|
sl@0
|
1170 |
|
sl@0
|
1171 |
case EExportKey:
|
sl@0
|
1172 |
case EExportEncryptedKey:
|
sl@0
|
1173 |
ASSERT(iKeyStoreManager);
|
sl@0
|
1174 |
iKeyStoreManager->CancelExportKey();
|
sl@0
|
1175 |
break;
|
sl@0
|
1176 |
|
sl@0
|
1177 |
case EDeleteKey:
|
sl@0
|
1178 |
ASSERT(iKeyStoreManager);
|
sl@0
|
1179 |
iKeyStoreManager->CancelDeleteKey();
|
sl@0
|
1180 |
break;
|
sl@0
|
1181 |
|
sl@0
|
1182 |
case ERelock:
|
sl@0
|
1183 |
ASSERT(iKeyStoreManager);
|
sl@0
|
1184 |
iKeyStoreManager->CancelRelock();
|
sl@0
|
1185 |
break;
|
sl@0
|
1186 |
|
sl@0
|
1187 |
case ESetPassphraseTimeout:
|
sl@0
|
1188 |
ASSERT(iKeyStoreManager);
|
sl@0
|
1189 |
iKeyStoreManager->CancelSetPassphraseTimeout();
|
sl@0
|
1190 |
break;
|
sl@0
|
1191 |
|
sl@0
|
1192 |
case ESetUsePolicy:
|
sl@0
|
1193 |
ASSERT(iKeyStoreManager);
|
sl@0
|
1194 |
iKeyStoreManager->CancelSetUsePolicy();
|
sl@0
|
1195 |
break;
|
sl@0
|
1196 |
|
sl@0
|
1197 |
case ESetManagementPolicy:
|
sl@0
|
1198 |
ASSERT(iKeyStoreManager);
|
sl@0
|
1199 |
iKeyStoreManager->CancelSetManagementPolicy();
|
sl@0
|
1200 |
break;
|
sl@0
|
1201 |
|
sl@0
|
1202 |
default:
|
sl@0
|
1203 |
User::Panic(KUnifiedKeyStore, EUnrecognisedState);
|
sl@0
|
1204 |
break;
|
sl@0
|
1205 |
}
|
sl@0
|
1206 |
}
|
sl@0
|
1207 |
|
sl@0
|
1208 |
|
sl@0
|
1209 |
void CUnifiedKeyStore::Complete(TInt aError)
|
sl@0
|
1210 |
{
|
sl@0
|
1211 |
Cleanup();
|
sl@0
|
1212 |
if (iOriginalRequestStatus)
|
sl@0
|
1213 |
{
|
sl@0
|
1214 |
User::RequestComplete(iOriginalRequestStatus, aError);
|
sl@0
|
1215 |
}
|
sl@0
|
1216 |
}
|
sl@0
|
1217 |
|
sl@0
|
1218 |
void CUnifiedKeyStore::Cleanup()
|
sl@0
|
1219 |
{
|
sl@0
|
1220 |
// If we have a key info, we want to release it
|
sl@0
|
1221 |
if (iKeyInfo)
|
sl@0
|
1222 |
{
|
sl@0
|
1223 |
iKeyInfo->Release();
|
sl@0
|
1224 |
iKeyInfo = NULL;
|
sl@0
|
1225 |
}
|
sl@0
|
1226 |
|
sl@0
|
1227 |
delete iKeyData;
|
sl@0
|
1228 |
iKeyData = NULL;
|
sl@0
|
1229 |
|
sl@0
|
1230 |
delete iFilter;
|
sl@0
|
1231 |
iFilter = NULL;
|
sl@0
|
1232 |
|
sl@0
|
1233 |
delete iPbeParams;
|
sl@0
|
1234 |
iPbeParams = NULL;
|
sl@0
|
1235 |
|
sl@0
|
1236 |
iTokenTypes.Close();
|
sl@0
|
1237 |
|
sl@0
|
1238 |
if (iTokenType)
|
sl@0
|
1239 |
{
|
sl@0
|
1240 |
iTokenType->Release();
|
sl@0
|
1241 |
iTokenType = 0;
|
sl@0
|
1242 |
}
|
sl@0
|
1243 |
|
sl@0
|
1244 |
iTokens.Close();
|
sl@0
|
1245 |
|
sl@0
|
1246 |
if (iToken)
|
sl@0
|
1247 |
{
|
sl@0
|
1248 |
iToken->Release();
|
sl@0
|
1249 |
iToken = 0;
|
sl@0
|
1250 |
}
|
sl@0
|
1251 |
|
sl@0
|
1252 |
if (iTokenInterface)
|
sl@0
|
1253 |
{
|
sl@0
|
1254 |
iTokenInterface->Release();
|
sl@0
|
1255 |
iTokenInterface = 0;
|
sl@0
|
1256 |
}
|
sl@0
|
1257 |
|
sl@0
|
1258 |
iKeyInfoOut = NULL;
|
sl@0
|
1259 |
iKeyStore = NULL;
|
sl@0
|
1260 |
iKeyStoreManager = NULL;
|
sl@0
|
1261 |
|
sl@0
|
1262 |
iState = EIdle;
|
sl@0
|
1263 |
}
|
sl@0
|
1264 |
|
sl@0
|
1265 |
CUnifiedKeyStore::CKeyStoreIF::CKeyStoreIF(MCTTokenInterface* aKeyStore, TBool aIsKeyManager)
|
sl@0
|
1266 |
: iKeyStore(aKeyStore), iIsKeyManager(aIsKeyManager)
|
sl@0
|
1267 |
{}
|
sl@0
|
1268 |
|
sl@0
|
1269 |
CUnifiedKeyStore::CKeyStoreIF::~CKeyStoreIF()
|
sl@0
|
1270 |
{
|
sl@0
|
1271 |
if (iKeyStore)
|
sl@0
|
1272 |
{
|
sl@0
|
1273 |
iKeyStore->Release();
|
sl@0
|
1274 |
iKeyStore = NULL;
|
sl@0
|
1275 |
}
|
sl@0
|
1276 |
}
|
sl@0
|
1277 |
|