|
1 In-house patch created to avoid the multiple declaration for log variable. |
|
2 This is necessary only when building the component with Solaris Studio. |
|
3 |
|
4 This patch is Solaris buildenv specific and may not be suitable for upstream. |
|
5 |
|
6 Other modifications were introduced to keep this in sync with upstream patches |
|
7 of the coolkey.cpp source file. |
|
8 |
|
9 For example, the addition of RSA, EC, or both mechanisms support the variance |
|
10 of different types of smart cards, where some cards support only EC, some only RSA. |
|
11 |
|
12 --- ORIGINAL/./src/coolkey/coolkey.cpp 2016-06-24 16:07:19.284028543 -0400 |
|
13 +++ ././src/coolkey/coolkey.cpp 2016-06-27 13:38:03.637785724 -0400 |
|
14 @@ -34,15 +34,19 @@ |
|
15 #include "cky_base.h" |
|
16 #include "params.h" |
|
17 |
|
18 -#define NULL 0 |
|
19 |
|
20 /* static module data -------------------------------- */ |
|
21 - |
|
22 -static Log *log = NULL; |
|
23 + |
|
24 +// XXX - Solaris studio compiler specific |
|
25 +// changed variable name from "log" to "mylog" as we need to |
|
26 +// avoid multiple declarations of a variable named "log" |
|
27 +static Log *mylog = NULL; |
|
28 |
|
29 static SlotList *slotList = NULL; |
|
30 |
|
31 -static OSLock finalizeLock(false); |
|
32 +static OSLock *finalizeLock = NULL; |
|
33 +#define FINALIZE_GETLOCK() if (finalizeLock) finalizeLock->getLock(); |
|
34 +#define FINALIZE_RELEASELOCK() if (finalizeLock) finalizeLock->releaseLock(); |
|
35 |
|
36 static CK_BBOOL initialized = FALSE; |
|
37 static CK_BBOOL finalizing = FALSE; |
|
38 @@ -68,11 +72,25 @@ |
|
39 /********************************************************************** |
|
40 ************************** MECHANISM TABLE *************************** |
|
41 **********************************************************************/ |
|
42 -static MechInfo |
|
43 -mechanismList[] = { |
|
44 + |
|
45 +static const MechInfo |
|
46 +rsaMechanismList[] = { |
|
47 {CKM_RSA_PKCS, { 1024, 4096, CKF_HW | CKF_SIGN | CKF_DECRYPT } } |
|
48 }; |
|
49 -static unsigned int numMechanisms = sizeof(mechanismList)/sizeof(MechInfo); |
|
50 + |
|
51 +static const MechInfo |
|
52 +ecMechanismList[] = { |
|
53 + {CKM_ECDSA,{256,521,CKF_HW | CKF_SIGN | CKF_EC_F_P}},{ CKM_ECDSA_SHA1, {256, 521, CKF_HW | CKF_SIGN | CKF_EC_F_P}},{ CKM_ECDH1_DERIVE,{256, 521, CKF_HW | CKF_DERIVE | CKF_EC_F_P} } |
|
54 +}; |
|
55 +static const MechInfo |
|
56 +allMechanismList[] = { |
|
57 + {CKM_RSA_PKCS, { 1024, 4096, CKF_HW | CKF_SIGN | CKF_DECRYPT } }, |
|
58 + {CKM_ECDSA,{256,521,CKF_HW | CKF_SIGN | CKF_EC_F_P}},{ CKM_ECDSA_SHA1, {256, 521, CKF_HW | CKF_SIGN | CKF_EC_F_P}},{ CKM_ECDH1_DERIVE,{256, 521, CKF_HW | CKF_DERIVE | CKF_EC_F_P} } |
|
59 +}; |
|
60 + |
|
61 +unsigned int numRSAMechanisms = sizeof(rsaMechanismList)/sizeof(MechInfo); |
|
62 +unsigned int numECMechanisms = sizeof(ecMechanismList)/sizeof(MechInfo); |
|
63 +unsigned int numAllMechanisms = sizeof(allMechanismList)/sizeof(MechInfo); |
|
64 |
|
65 /* ------------------------------------------------------------ */ |
|
66 |
|
67 @@ -86,11 +104,11 @@ |
|
68 for (i = 0; i < ulCount; ++i) { |
|
69 CK_ATTRIBUTE_PTR pT = pTemplate + i; |
|
70 if (pT->pValue && pT->ulValueLen == 4) { |
|
71 - log->log( |
|
72 + mylog->log( |
|
73 "template [%02lu] type: %04lx, pValue: %08lx, ulValueLen: %08lx, value: %lu\n", |
|
74 i, pT->type, pT->pValue, pT->ulValueLen, *(CK_ULONG_PTR)pT->pValue); |
|
75 } else |
|
76 - log->log("template [%02lu] type: %04lx, pValue: %08lx, ulValueLen: %08lx\n", |
|
77 + mylog->log("template [%02lu] type: %04lx, pValue: %08lx, ulValueLen: %08lx\n", |
|
78 i, pT->type, pT->pValue, pT->ulValueLen); |
|
79 } |
|
80 } |
|
81 @@ -101,7 +119,7 @@ |
|
82 #define NOTSUPPORTED(name, args) \ |
|
83 CK_RV name args \ |
|
84 { \ |
|
85 - log->log(#name " called (notSupported)\n"); \ |
|
86 + mylog->log(#name " called (notSupported)\n"); \ |
|
87 return CKR_FUNCTION_NOT_SUPPORTED; \ |
|
88 } |
|
89 |
|
90 @@ -112,11 +130,11 @@ |
|
91 return CKR_CRYPTOKI_NOT_INITIALIZED; \ |
|
92 } \ |
|
93 try { \ |
|
94 - log->log(#name " called\n"); \ |
|
95 + mylog->log(#name " called\n"); \ |
|
96 slotList->name2 use_args ; \ |
|
97 return CKR_OK; \ |
|
98 } catch(PKCS11Exception& e) { \ |
|
99 - e.log(log); \ |
|
100 + e.log(mylog); \ |
|
101 return e.getCRV(); \ |
|
102 } \ |
|
103 } |
|
104 @@ -164,7 +182,6 @@ |
|
105 NOTSUPPORTED(C_GenerateKeyPair, (CK_SESSION_HANDLE,CK_MECHANISM_PTR,CK_ATTRIBUTE_PTR,CK_ULONG,CK_ATTRIBUTE_PTR,CK_ULONG,CK_OBJECT_HANDLE_PTR,CK_OBJECT_HANDLE_PTR)) |
|
106 NOTSUPPORTED(C_WrapKey, (CK_SESSION_HANDLE,CK_MECHANISM_PTR,CK_OBJECT_HANDLE,CK_OBJECT_HANDLE,CK_BYTE_PTR,CK_ULONG_PTR)) |
|
107 NOTSUPPORTED(C_UnwrapKey, (CK_SESSION_HANDLE,CK_MECHANISM_PTR,CK_OBJECT_HANDLE,CK_BYTE_PTR,CK_ULONG,CK_ATTRIBUTE_PTR,CK_ULONG,CK_OBJECT_HANDLE_PTR)) |
|
108 -NOTSUPPORTED(C_DeriveKey, (CK_SESSION_HANDLE,CK_MECHANISM_PTR,CK_OBJECT_HANDLE,CK_ATTRIBUTE_PTR,CK_ULONG,CK_OBJECT_HANDLE_PTR)) |
|
109 NOTSUPPORTED(C_GetFunctionStatus, (CK_SESSION_HANDLE)) |
|
110 NOTSUPPORTED(C_CancelFunction, (CK_SESSION_HANDLE)) |
|
111 |
|
112 @@ -198,6 +215,10 @@ |
|
113 SUPPORTED(C_GenerateRandom, generateRandom, |
|
114 (CK_SESSION_HANDLE hSession ,CK_BYTE_PTR data,CK_ULONG dataLen), |
|
115 (hSession, data, dataLen)) |
|
116 +SUPPORTED(C_DeriveKey,derive, |
|
117 + (CK_SESSION_HANDLE hSession, CK_MECHANISM_PTR pMechanism, |
|
118 + CK_OBJECT_HANDLE hBaseKey, CK_ATTRIBUTE_PTR pTemplate, CK_ULONG ulAttributeCount, CK_OBJECT_HANDLE_PTR phKey ), |
|
119 + (hSession, pMechanism, hBaseKey, pTemplate, ulAttributeCount, phKey)) |
|
120 |
|
121 /* non-specialized functions supported with the slot directly */ |
|
122 |
|
123 @@ -208,11 +229,13 @@ |
|
124 if( initialized ) { |
|
125 return CKR_CRYPTOKI_ALREADY_INITIALIZED; |
|
126 } |
|
127 - if (!finalizeLock.isValid()) { |
|
128 + if (finalizeLock && !finalizeLock->isValid()) { |
|
129 return CKR_CANT_LOCK; |
|
130 } |
|
131 CK_C_INITIALIZE_ARGS* initArgs = (CK_C_INITIALIZE_ARGS*) pInitArgs; |
|
132 + OSLock::setThreadSafe(0); |
|
133 if( initArgs != NULL ) { |
|
134 + bool needThreads; |
|
135 /* work around a bug in NSS where the library parameters are only |
|
136 * send if locking is requested */ |
|
137 if (initArgs->LibraryParameters) { |
|
138 @@ -220,28 +243,38 @@ |
|
139 } else { |
|
140 Params::ClearParams(); |
|
141 } |
|
142 - if( (initArgs->flags & CKF_OS_LOCKING_OK) || initArgs->LockMutex ){ |
|
143 + needThreads = ((initArgs->flags & CKF_OS_LOCKING_OK) != 0); |
|
144 + OSLock::setThreadSafe(needThreads); |
|
145 + /* don't get a finalize lock unless someone initializes us asking |
|
146 + * us to use threads */ |
|
147 + if (needThreads && !finalizeLock) { |
|
148 + finalizeLock = new OSLock(true); |
|
149 + if (finalizeLock == NULL) return CKR_HOST_MEMORY; |
|
150 + } |
|
151 + /* only support OS LOCKING threads */ |
|
152 + if( ((initArgs->flags & CKF_OS_LOCKING_OK) == 0) |
|
153 + && initArgs->LockMutex ){ |
|
154 throw PKCS11Exception(CKR_CANT_LOCK); |
|
155 } |
|
156 } |
|
157 char * logFileName = getenv("COOL_KEY_LOG_FILE"); |
|
158 if (logFileName) { |
|
159 if (strcmp(logFileName,"SYSLOG") == 0) { |
|
160 - log = new SysLog(); |
|
161 + mylog = new SysLog(); |
|
162 } else { |
|
163 - log = new FileLog(logFileName); |
|
164 + mylog = new FileLog(logFileName); |
|
165 } |
|
166 } else { |
|
167 - log = new DummyLog(); |
|
168 + mylog = new DummyLog(); |
|
169 } |
|
170 - log->log("Initialize called, hello %d\n", 5); |
|
171 - CKY_SetName("coolkey"); |
|
172 - slotList = new SlotList(log); |
|
173 + mylog->log("Initialize called, hello %d\n", 5); |
|
174 + CKY_SetName((char *) "coolkey"); |
|
175 + slotList = new SlotList(mylog); |
|
176 initialized = TRUE; |
|
177 return CKR_OK; |
|
178 } catch(PKCS11Exception &e) { |
|
179 - if( log ) |
|
180 - e.log(log); |
|
181 + if( mylog ) |
|
182 + e.log(mylog); |
|
183 return e.getReturnValue(); |
|
184 } |
|
185 } |
|
186 @@ -254,14 +287,14 @@ |
|
187 } |
|
188 // XXX cleanup all data structures !!! |
|
189 //delete sessionManager; |
|
190 - log->log("Finalizing...\n"); |
|
191 + mylog->log("Finalizing...\n"); |
|
192 // don't race the setting of finalizing. If C_WaitEvent gets passed |
|
193 // the finalizing call first, we know it will set waitEvent before |
|
194 // we can get the lock, so we only need to protect setting finalizing |
|
195 // to true. |
|
196 - finalizeLock.getLock(); |
|
197 + FINALIZE_GETLOCK(); |
|
198 finalizing = TRUE; |
|
199 - finalizeLock.releaseLock(); |
|
200 + FINALIZE_RELEASELOCK(); |
|
201 if (waitEvent) { |
|
202 /* we're waiting on a slot event, shutdown first to allow |
|
203 * the wait function to complete before we pull the rug out. |
|
204 @@ -272,11 +305,11 @@ |
|
205 } |
|
206 } |
|
207 delete slotList; |
|
208 - delete log; |
|
209 - finalizeLock.getLock(); |
|
210 + delete mylog; |
|
211 + FINALIZE_GETLOCK(); |
|
212 finalizing = FALSE; |
|
213 initialized = FALSE; |
|
214 - finalizeLock.releaseLock(); |
|
215 + FINALIZE_RELEASELOCK(); |
|
216 return CKR_OK; |
|
217 } |
|
218 |
|
219 @@ -287,7 +320,7 @@ |
|
220 if( ! initialized ) { |
|
221 return CKR_CRYPTOKI_NOT_INITIALIZED; |
|
222 } |
|
223 - log->log("C_GetInfo called\n"); |
|
224 + mylog->log("C_GetInfo called\n"); |
|
225 ckInfo.manufacturerID[31] = ' '; |
|
226 ckInfo.libraryDescription[31] = ' '; |
|
227 *p = ckInfo; |
|
228 @@ -302,12 +335,12 @@ |
|
229 return CKR_CRYPTOKI_NOT_INITIALIZED; |
|
230 } |
|
231 try { |
|
232 - log->log("Called C_GetSlotInfo\n"); |
|
233 + mylog->log("Called C_GetSlotInfo\n"); |
|
234 slotList->validateSlotID(slotID); |
|
235 return slotList->getSlot( |
|
236 slotIDToIndex(slotID))->getSlotInfo(pSlotInfo); |
|
237 } catch( PKCS11Exception &excep ) { |
|
238 - excep.log(log); |
|
239 + excep.log(mylog); |
|
240 return excep.getCRV(); |
|
241 } |
|
242 } |
|
243 @@ -319,12 +352,12 @@ |
|
244 return CKR_CRYPTOKI_NOT_INITIALIZED; |
|
245 } |
|
246 try { |
|
247 - log->log("C_GetTokenInfo called\n"); |
|
248 + mylog->log("C_GetTokenInfo called\n"); |
|
249 slotList->validateSlotID(slotID); |
|
250 return slotList->getSlot( |
|
251 slotIDToIndex(slotID))->getTokenInfo(pTokenInfo); |
|
252 } catch( PKCS11Exception &excep ) { |
|
253 - excep.log(log); |
|
254 + excep.log(mylog); |
|
255 return excep.getCRV(); |
|
256 } |
|
257 } |
|
258 @@ -333,23 +366,47 @@ |
|
259 C_GetMechanismList(CK_SLOT_ID slotID, CK_MECHANISM_TYPE_PTR pMechanismList, |
|
260 CK_ULONG_PTR pulCount) |
|
261 { |
|
262 + |
|
263 + const MechInfo *mechanismList = NULL; |
|
264 + unsigned int numMechanisms = 0; |
|
265 + |
|
266 + |
|
267 if( ! initialized ) { |
|
268 return CKR_CRYPTOKI_NOT_INITIALIZED; |
|
269 } |
|
270 try { |
|
271 CK_RV rv = CKR_OK; |
|
272 |
|
273 - log->log("C_GetMechanismList called\n"); |
|
274 + mylog->log("C_GetMechanismList called\n"); |
|
275 if( pulCount == NULL ) { |
|
276 throw PKCS11Exception(CKR_ARGUMENTS_BAD); |
|
277 } |
|
278 |
|
279 slotList->validateSlotID(slotID); |
|
280 - if( ! slotList->getSlot( |
|
281 - slotIDToIndex(slotID))->isTokenPresent() ) { |
|
282 + |
|
283 + Slot *slot = slotList->getSlot(slotIDToIndex(slotID)); |
|
284 + |
|
285 + if( ! slot || ! slot->isTokenPresent() ) { |
|
286 return CKR_TOKEN_NOT_PRESENT; |
|
287 } |
|
288 |
|
289 + switch (slot->getAlgs()) { |
|
290 + case ALG_ECC|ALG_RSA: |
|
291 + mechanismList = allMechanismList; |
|
292 + numMechanisms = numAllMechanisms; |
|
293 + break; |
|
294 + case ALG_ECC: |
|
295 + mechanismList = ecMechanismList; |
|
296 + numMechanisms = numECMechanisms; |
|
297 + break; |
|
298 + case ALG_NONE: |
|
299 + case ALG_RSA: |
|
300 + default: |
|
301 + mechanismList = rsaMechanismList; |
|
302 + numMechanisms = numRSAMechanisms; |
|
303 + break; |
|
304 + } |
|
305 + |
|
306 if( pMechanismList != NULL ) { |
|
307 if( *pulCount < numMechanisms ) { |
|
308 rv = CKR_BUFFER_TOO_SMALL; |
|
309 @@ -362,11 +419,11 @@ |
|
310 |
|
311 *pulCount = numMechanisms; |
|
312 |
|
313 - log->log("C_GetMechanismList returning %d\n", rv); |
|
314 + mylog->log("C_GetMechanismList returning %d\n", rv); |
|
315 return rv; |
|
316 |
|
317 } catch(PKCS11Exception &excep ) { |
|
318 - excep.log(log); |
|
319 + excep.log(mylog); |
|
320 return excep.getCRV(); |
|
321 } |
|
322 |
|
323 @@ -376,30 +433,56 @@ |
|
324 C_GetMechanismInfo(CK_SLOT_ID slotID, CK_MECHANISM_TYPE type, |
|
325 CK_MECHANISM_INFO_PTR pInfo) |
|
326 { |
|
327 + const MechInfo *mechanismList = NULL; |
|
328 + unsigned int numMechanisms = 0; |
|
329 + |
|
330 if( ! initialized ) { |
|
331 return CKR_CRYPTOKI_NOT_INITIALIZED; |
|
332 } |
|
333 + |
|
334 + |
|
335 try { |
|
336 - log->log("C_GetMechanismInfo called\n"); |
|
337 + mylog->log("C_GetMechanismInfo called\n"); |
|
338 if( pInfo == NULL ) { |
|
339 throw PKCS11Exception(CKR_ARGUMENTS_BAD); |
|
340 } |
|
341 slotList->validateSlotID(slotID); |
|
342 - if( ! slotList->getSlot(slotIDToIndex(slotID))->isTokenPresent() ) { |
|
343 + |
|
344 + |
|
345 + Slot *slot = slotList->getSlot(slotIDToIndex(slotID)); |
|
346 + |
|
347 + if( ! slot || ! slot->isTokenPresent() ) { |
|
348 return CKR_TOKEN_NOT_PRESENT; |
|
349 } |
|
350 |
|
351 + switch (slot->getAlgs()) { |
|
352 + case ALG_ECC|ALG_RSA: |
|
353 + mechanismList = allMechanismList; |
|
354 + numMechanisms = numAllMechanisms; |
|
355 + break; |
|
356 + case ALG_ECC: |
|
357 + mechanismList = ecMechanismList; |
|
358 + numMechanisms = numECMechanisms; |
|
359 + break; |
|
360 + case ALG_NONE: |
|
361 + case ALG_RSA: |
|
362 + default: |
|
363 + mechanismList = rsaMechanismList; |
|
364 + numMechanisms = numRSAMechanisms; |
|
365 + break; |
|
366 + } |
|
367 + |
|
368 for(unsigned int i=0; i < numMechanisms; ++i ) { |
|
369 if( mechanismList[i].mech == type ) { |
|
370 *pInfo = mechanismList[i].info; |
|
371 - log->log("C_GetMechanismInfo got info about %d\n", type); |
|
372 + mylog->log("C_GetMechanismInfo got info about %d\n", type); |
|
373 return CKR_OK; |
|
374 } |
|
375 } |
|
376 - log->log("C_GetMechanismInfo failed to find info about %d\n", type); |
|
377 + mylog->log("C_GetMechanismInfo failed to find info about %d\n", type); |
|
378 return CKR_MECHANISM_INVALID; // mechanism not in the list |
|
379 } catch(PKCS11Exception &e) { |
|
380 - e.log(log); |
|
381 + e.log(mylog); |
|
382 return e.getCRV(); |
|
383 } |
|
384 } |
|
385 @@ -412,7 +495,7 @@ |
|
386 return CKR_CRYPTOKI_NOT_INITIALIZED; |
|
387 } |
|
388 try { |
|
389 - log->log("C_OpenSession called\n"); |
|
390 + mylog->log("C_OpenSession called\n"); |
|
391 slotList->validateSlotID(slotID); |
|
392 #ifdef LATER // the CSP isn't setting this bit right now. |
|
393 if( ! (flags & CKF_SERIAL_SESSION) ) { |
|
394 @@ -430,7 +513,7 @@ |
|
395 return CKR_OK; |
|
396 |
|
397 } catch(PKCS11Exception &e) { |
|
398 - e.log(log); |
|
399 + e.log(mylog); |
|
400 return e.getCRV(); |
|
401 } |
|
402 } |
|
403 @@ -442,13 +525,13 @@ |
|
404 return CKR_CRYPTOKI_NOT_INITIALIZED; |
|
405 } |
|
406 try { |
|
407 - log->log("C_CloseSession(0x%x) called\n", hSession); |
|
408 + mylog->log("C_CloseSession(0x%x) called\n", hSession); |
|
409 // !!!XXX Hack |
|
410 // If nothing else, we need to logout the token when all |
|
411 // its sessions are closed. |
|
412 return CKR_OK; |
|
413 } catch(PKCS11Exception &e) { |
|
414 - e.log(log); |
|
415 + e.log(mylog); |
|
416 return e.getCRV(); |
|
417 } |
|
418 } |
|
419 @@ -460,14 +543,14 @@ |
|
420 return CKR_CRYPTOKI_NOT_INITIALIZED; |
|
421 } |
|
422 try { |
|
423 - log->log("C_CloseAllSessions(0x%x) called\n", slotID); |
|
424 + mylog->log("C_CloseAllSessions(0x%x) called\n", slotID); |
|
425 slotList->validateSlotID(slotID); |
|
426 // !!!XXX Hack |
|
427 // If nothing else, we need to logout the token when all |
|
428 // its sessions are closed. |
|
429 return CKR_OK; |
|
430 } catch(PKCS11Exception &e) { |
|
431 - e.log(log); |
|
432 + e.log(mylog); |
|
433 return e.getCRV(); |
|
434 } |
|
435 } |
|
436 @@ -481,7 +564,7 @@ |
|
437 return CKR_CRYPTOKI_NOT_INITIALIZED; |
|
438 } |
|
439 try { |
|
440 - log->log("C_FindObjectsInit called, %lu templates\n", ulCount); |
|
441 + mylog->log("C_FindObjectsInit called, %lu templates\n", ulCount); |
|
442 dumpTemplates(pTemplate, ulCount); |
|
443 |
|
444 if( pTemplate == NULL && ulCount != 0 ) { |
|
445 @@ -490,7 +573,7 @@ |
|
446 slotList->findObjectsInit(hSession, pTemplate, ulCount); |
|
447 return CKR_OK; |
|
448 } catch(PKCS11Exception &e) { |
|
449 - e.log(log); |
|
450 + e.log(mylog); |
|
451 return e.getCRV(); |
|
452 } |
|
453 } |
|
454 @@ -504,22 +587,22 @@ |
|
455 return CKR_CRYPTOKI_NOT_INITIALIZED; |
|
456 } |
|
457 try { |
|
458 - log->log("C_FindObjects called, max objects = %lu\n", ulMaxObjectCount ); |
|
459 + mylog->log("C_FindObjects called, max objects = %lu\n", ulMaxObjectCount ); |
|
460 if( phObject == NULL && ulMaxObjectCount != 0 ) { |
|
461 throw PKCS11Exception(CKR_ARGUMENTS_BAD); |
|
462 } |
|
463 slotList->findObjects(hSession, phObject, ulMaxObjectCount, |
|
464 pulObjectCount); |
|
465 count = *pulObjectCount; |
|
466 - log->log("returned %lu objects:", count ); |
|
467 + mylog->log("returned %lu objects:", count ); |
|
468 CK_ULONG i; |
|
469 for (i = 0; i < count; ++i) { |
|
470 - log->log(" 0x%08lx", phObject[i]); |
|
471 + mylog->log(" 0x%08lx", phObject[i]); |
|
472 } |
|
473 - log->log("\n" ); |
|
474 + mylog->log("\n" ); |
|
475 return CKR_OK; |
|
476 } catch(PKCS11Exception &e) { |
|
477 - e.log(log); |
|
478 + e.log(mylog); |
|
479 return e.getCRV(); |
|
480 } |
|
481 } |
|
482 @@ -542,7 +625,7 @@ |
|
483 return CKR_CRYPTOKI_NOT_INITIALIZED; |
|
484 } |
|
485 try { |
|
486 - log->log("C_Login called\n"); |
|
487 + mylog->log("C_Login called\n"); |
|
488 if( userType != CKU_USER ) { |
|
489 throw PKCS11Exception(CKR_USER_TYPE_INVALID); |
|
490 } |
|
491 @@ -552,7 +635,7 @@ |
|
492 slotList->login(hSession, pPin, ulPinLen); |
|
493 return CKR_OK; |
|
494 } catch(PKCS11Exception &e) { |
|
495 - e.log(log); |
|
496 + e.log(mylog); |
|
497 return e.getCRV(); |
|
498 } |
|
499 } |
|
500 @@ -566,7 +649,7 @@ |
|
501 return CKR_CRYPTOKI_NOT_INITIALIZED; |
|
502 } |
|
503 try { |
|
504 - log->log("C_GetAttributeValue called, %lu templates for object 0x%08lx\n", ulCount, hObject); |
|
505 + mylog->log("C_GetAttributeValue called, %lu templates for object 0x%08lx\n", ulCount, hObject); |
|
506 dumpTemplates(pTemplate, ulCount); |
|
507 if( pTemplate == NULL && ulCount != 0 ) { |
|
508 throw PKCS11Exception(CKR_ARGUMENTS_BAD); |
|
509 @@ -576,7 +659,7 @@ |
|
510 return CKR_OK; |
|
511 } catch(PKCS11Exception& e) { |
|
512 CK_RV rv = e.getCRV(); |
|
513 - e.log(log); |
|
514 + e.log(mylog); |
|
515 if (rv == CKR_ATTRIBUTE_TYPE_INVALID || |
|
516 rv == CKR_BUFFER_TOO_SMALL) { |
|
517 dumpTemplates(pTemplate, ulCount); |
|
518 @@ -595,24 +678,24 @@ |
|
519 CK_RV |
|
520 C_WaitForSlotEvent(CK_FLAGS flags, CK_SLOT_ID_PTR pSlot, CK_VOID_PTR pReserved) |
|
521 { |
|
522 - finalizeLock.getLock(); |
|
523 + FINALIZE_GETLOCK(); |
|
524 if( ! initialized ) { |
|
525 - finalizeLock.releaseLock(); |
|
526 + FINALIZE_RELEASELOCK(); |
|
527 return CKR_CRYPTOKI_NOT_INITIALIZED; |
|
528 } |
|
529 if (finalizing) { |
|
530 - finalizeLock.releaseLock(); |
|
531 + FINALIZE_RELEASELOCK(); |
|
532 return CKR_CRYPTOKI_NOT_INITIALIZED; |
|
533 } |
|
534 waitEvent = TRUE; |
|
535 - finalizeLock.releaseLock(); |
|
536 + FINALIZE_RELEASELOCK(); |
|
537 try { |
|
538 - log->log("C_WaitForSlotEvent called\n"); |
|
539 + mylog->log("C_WaitForSlotEvent called\n"); |
|
540 slotList->waitForSlotEvent(flags, pSlot, pReserved); |
|
541 waitEvent = FALSE; |
|
542 return CKR_OK; |
|
543 } catch(PKCS11Exception& e) { |
|
544 - e.log(log); |
|
545 + e.log(mylog); |
|
546 waitEvent = FALSE; |
|
547 return e.getCRV(); |
|
548 } |