OLD | NEW |
| (Empty) |
1 /* This Source Code Form is subject to the terms of the Mozilla Public | |
2 * License, v. 2.0. If a copy of the MPL was not distributed with this | |
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | |
4 | |
5 #ifdef DEBUG | |
6 static const char CVS_ID[] = "@(#) $RCSfile: instance.c,v $ $Revision: 1.14 $ $D
ate: 2012/04/25 14:49:28 $"; | |
7 #endif /* DEBUG */ | |
8 | |
9 /* | |
10 * instance.c | |
11 * | |
12 * This file implements the NSSCKFWInstance type and methods. | |
13 */ | |
14 | |
15 #ifndef CK_T | |
16 #include "ck.h" | |
17 #endif /* CK_T */ | |
18 | |
19 /* | |
20 * NSSCKFWInstance | |
21 * | |
22 * -- create/destroy -- | |
23 * nssCKFWInstance_Create | |
24 * nssCKFWInstance_Destroy | |
25 * | |
26 * -- public accessors -- | |
27 * NSSCKFWInstance_GetMDInstance | |
28 * NSSCKFWInstance_GetArena | |
29 * NSSCKFWInstance_MayCreatePthreads | |
30 * NSSCKFWInstance_CreateMutex | |
31 * NSSCKFWInstance_GetConfigurationData | |
32 * NSSCKFWInstance_GetInitArgs | |
33 * | |
34 * -- implement public accessors -- | |
35 * nssCKFWInstance_GetMDInstance | |
36 * nssCKFWInstance_GetArena | |
37 * nssCKFWInstance_MayCreatePthreads | |
38 * nssCKFWInstance_CreateMutex | |
39 * nssCKFWInstance_GetConfigurationData | |
40 * nssCKFWInstance_GetInitArgs | |
41 * | |
42 * -- private accessors -- | |
43 * nssCKFWInstance_CreateSessionHandle | |
44 * nssCKFWInstance_ResolveSessionHandle | |
45 * nssCKFWInstance_DestroySessionHandle | |
46 * nssCKFWInstance_FindSessionHandle | |
47 * nssCKFWInstance_CreateObjectHandle | |
48 * nssCKFWInstance_ResolveObjectHandle | |
49 * nssCKFWInstance_DestroyObjectHandle | |
50 * | |
51 * -- module fronts -- | |
52 * nssCKFWInstance_GetNSlots | |
53 * nssCKFWInstance_GetCryptokiVersion | |
54 * nssCKFWInstance_GetManufacturerID | |
55 * nssCKFWInstance_GetFlags | |
56 * nssCKFWInstance_GetLibraryDescription | |
57 * nssCKFWInstance_GetLibraryVersion | |
58 * nssCKFWInstance_GetModuleHandlesSessionObjects | |
59 * nssCKFWInstance_GetSlots | |
60 * nssCKFWInstance_WaitForSlotEvent | |
61 * | |
62 * -- debugging versions only -- | |
63 * nssCKFWInstance_verifyPointer | |
64 */ | |
65 | |
66 struct NSSCKFWInstanceStr { | |
67 NSSCKFWMutex *mutex; | |
68 NSSArena *arena; | |
69 NSSCKMDInstance *mdInstance; | |
70 CK_C_INITIALIZE_ARGS_PTR pInitArgs; | |
71 CK_C_INITIALIZE_ARGS initArgs; | |
72 CryptokiLockingState LockingState; | |
73 CK_BBOOL mayCreatePthreads; | |
74 NSSUTF8 *configurationData; | |
75 CK_ULONG nSlots; | |
76 NSSCKFWSlot **fwSlotList; | |
77 NSSCKMDSlot **mdSlotList; | |
78 CK_BBOOL moduleHandlesSessionObjects; | |
79 | |
80 /* | |
81 * Everything above is set at creation time, and then not modified. | |
82 * The invariants the mutex protects are: | |
83 * | |
84 * 1) Each of the cached descriptions (versions, etc.) are in an | |
85 * internally consistant state. | |
86 * | |
87 * 2) The session handle hashes and count are consistant | |
88 * | |
89 * 3) The object handle hashes and count are consistant. | |
90 * | |
91 * I could use multiple locks, but let's wait to see if that's | |
92 * really necessary. | |
93 * | |
94 * Note that the calls accessing the cached descriptions will | |
95 * call the NSSCKMDInstance methods with the mutex locked. Those | |
96 * methods may then call the public NSSCKFWInstance routines. | |
97 * Those public routines only access the constant data above, so | |
98 * there's no problem. But be careful if you add to this object; | |
99 * mutexes are in general not reentrant, so don't create deadlock | |
100 * situations. | |
101 */ | |
102 | |
103 CK_VERSION cryptokiVersion; | |
104 NSSUTF8 *manufacturerID; | |
105 NSSUTF8 *libraryDescription; | |
106 CK_VERSION libraryVersion; | |
107 | |
108 CK_ULONG lastSessionHandle; | |
109 nssCKFWHash *sessionHandleHash; | |
110 | |
111 CK_ULONG lastObjectHandle; | |
112 nssCKFWHash *objectHandleHash; | |
113 }; | |
114 | |
115 #ifdef DEBUG | |
116 /* | |
117 * But first, the pointer-tracking stuff. | |
118 * | |
119 * NOTE: the pointer-tracking support in NSS/base currently relies | |
120 * upon NSPR's CallOnce support. That, however, relies upon NSPR's | |
121 * locking, which is tied into the runtime. We need a pointer-tracker | |
122 * implementation that uses the locks supplied through C_Initialize. | |
123 * That support, however, can be filled in later. So for now, I'll | |
124 * just do this routines as no-ops. | |
125 */ | |
126 | |
127 static CK_RV | |
128 instance_add_pointer | |
129 ( | |
130 const NSSCKFWInstance *fwInstance | |
131 ) | |
132 { | |
133 return CKR_OK; | |
134 } | |
135 | |
136 static CK_RV | |
137 instance_remove_pointer | |
138 ( | |
139 const NSSCKFWInstance *fwInstance | |
140 ) | |
141 { | |
142 return CKR_OK; | |
143 } | |
144 | |
145 NSS_IMPLEMENT CK_RV | |
146 nssCKFWInstance_verifyPointer | |
147 ( | |
148 const NSSCKFWInstance *fwInstance | |
149 ) | |
150 { | |
151 return CKR_OK; | |
152 } | |
153 | |
154 #endif /* DEBUG */ | |
155 | |
156 /* | |
157 * nssCKFWInstance_Create | |
158 * | |
159 */ | |
160 NSS_IMPLEMENT NSSCKFWInstance * | |
161 nssCKFWInstance_Create | |
162 ( | |
163 CK_C_INITIALIZE_ARGS_PTR pInitArgs, | |
164 CryptokiLockingState LockingState, | |
165 NSSCKMDInstance *mdInstance, | |
166 CK_RV *pError | |
167 ) | |
168 { | |
169 NSSCKFWInstance *fwInstance; | |
170 NSSArena *arena = (NSSArena *)NULL; | |
171 CK_ULONG i; | |
172 CK_BBOOL called_Initialize = CK_FALSE; | |
173 | |
174 #ifdef NSSDEBUG | |
175 if( (CK_RV)NULL == pError ) { | |
176 return (NSSCKFWInstance *)NULL; | |
177 } | |
178 | |
179 if (!mdInstance) { | |
180 *pError = CKR_ARGUMENTS_BAD; | |
181 return (NSSCKFWInstance *)NULL; | |
182 } | |
183 #endif /* NSSDEBUG */ | |
184 | |
185 arena = NSSArena_Create(); | |
186 if (!arena) { | |
187 *pError = CKR_HOST_MEMORY; | |
188 return (NSSCKFWInstance *)NULL; | |
189 } | |
190 | |
191 fwInstance = nss_ZNEW(arena, NSSCKFWInstance); | |
192 if (!fwInstance) { | |
193 goto nomem; | |
194 } | |
195 | |
196 fwInstance->arena = arena; | |
197 fwInstance->mdInstance = mdInstance; | |
198 | |
199 fwInstance->LockingState = LockingState; | |
200 if( (CK_C_INITIALIZE_ARGS_PTR)NULL != pInitArgs ) { | |
201 fwInstance->initArgs = *pInitArgs; | |
202 fwInstance->pInitArgs = &fwInstance->initArgs; | |
203 if( pInitArgs->flags & CKF_LIBRARY_CANT_CREATE_OS_THREADS ) { | |
204 fwInstance->mayCreatePthreads = CK_FALSE; | |
205 } else { | |
206 fwInstance->mayCreatePthreads = CK_TRUE; | |
207 } | |
208 fwInstance->configurationData = (NSSUTF8 *)(pInitArgs->pReserved); | |
209 } else { | |
210 fwInstance->mayCreatePthreads = CK_TRUE; | |
211 } | |
212 | |
213 fwInstance->mutex = nssCKFWMutex_Create(pInitArgs, LockingState, arena, | |
214 pError); | |
215 if (!fwInstance->mutex) { | |
216 if( CKR_OK == *pError ) { | |
217 *pError = CKR_GENERAL_ERROR; | |
218 } | |
219 goto loser; | |
220 } | |
221 | |
222 if (mdInstance->Initialize) { | |
223 *pError = mdInstance->Initialize(mdInstance, fwInstance, fwInstance->configu
rationData); | |
224 if( CKR_OK != *pError ) { | |
225 goto loser; | |
226 } | |
227 | |
228 called_Initialize = CK_TRUE; | |
229 } | |
230 | |
231 if (mdInstance->ModuleHandlesSessionObjects) { | |
232 fwInstance->moduleHandlesSessionObjects = | |
233 mdInstance->ModuleHandlesSessionObjects(mdInstance, fwInstance); | |
234 } else { | |
235 fwInstance->moduleHandlesSessionObjects = CK_FALSE; | |
236 } | |
237 | |
238 if (!mdInstance->GetNSlots) { | |
239 /* That routine is required */ | |
240 *pError = CKR_GENERAL_ERROR; | |
241 goto loser; | |
242 } | |
243 | |
244 fwInstance->nSlots = mdInstance->GetNSlots(mdInstance, fwInstance, pError); | |
245 if( (CK_ULONG)0 == fwInstance->nSlots ) { | |
246 if( CKR_OK == *pError ) { | |
247 /* Zero is not a legitimate answer */ | |
248 *pError = CKR_GENERAL_ERROR; | |
249 } | |
250 goto loser; | |
251 } | |
252 | |
253 fwInstance->fwSlotList = nss_ZNEWARRAY(arena, NSSCKFWSlot *, fwInstance->nSlot
s); | |
254 if( (NSSCKFWSlot **)NULL == fwInstance->fwSlotList ) { | |
255 goto nomem; | |
256 } | |
257 | |
258 fwInstance->mdSlotList = nss_ZNEWARRAY(arena, NSSCKMDSlot *, fwInstance->nSlot
s); | |
259 if( (NSSCKMDSlot **)NULL == fwInstance->mdSlotList ) { | |
260 goto nomem; | |
261 } | |
262 | |
263 fwInstance->sessionHandleHash = nssCKFWHash_Create(fwInstance, | |
264 fwInstance->arena, pError); | |
265 if (!fwInstance->sessionHandleHash) { | |
266 goto loser; | |
267 } | |
268 | |
269 fwInstance->objectHandleHash = nssCKFWHash_Create(fwInstance, | |
270 fwInstance->arena, pError); | |
271 if (!fwInstance->objectHandleHash) { | |
272 goto loser; | |
273 } | |
274 | |
275 if (!mdInstance->GetSlots) { | |
276 /* That routine is required */ | |
277 *pError = CKR_GENERAL_ERROR; | |
278 goto loser; | |
279 } | |
280 | |
281 *pError = mdInstance->GetSlots(mdInstance, fwInstance, fwInstance->mdSlotList)
; | |
282 if( CKR_OK != *pError ) { | |
283 goto loser; | |
284 } | |
285 | |
286 for( i = 0; i < fwInstance->nSlots; i++ ) { | |
287 NSSCKMDSlot *mdSlot = fwInstance->mdSlotList[i]; | |
288 | |
289 if (!mdSlot) { | |
290 *pError = CKR_GENERAL_ERROR; | |
291 goto loser; | |
292 } | |
293 | |
294 fwInstance->fwSlotList[i] = nssCKFWSlot_Create(fwInstance, mdSlot, i, pError
); | |
295 if( CKR_OK != *pError ) { | |
296 CK_ULONG j; | |
297 | |
298 for( j = 0; j < i; j++ ) { | |
299 (void)nssCKFWSlot_Destroy(fwInstance->fwSlotList[j]); | |
300 } | |
301 | |
302 for( j = i; j < fwInstance->nSlots; j++ ) { | |
303 NSSCKMDSlot *mds = fwInstance->mdSlotList[j]; | |
304 if (mds->Destroy) { | |
305 mds->Destroy(mds, (NSSCKFWSlot *)NULL, mdInstance, fwInstance); | |
306 } | |
307 } | |
308 | |
309 goto loser; | |
310 } | |
311 } | |
312 | |
313 #ifdef DEBUG | |
314 *pError = instance_add_pointer(fwInstance); | |
315 if( CKR_OK != *pError ) { | |
316 for( i = 0; i < fwInstance->nSlots; i++ ) { | |
317 (void)nssCKFWSlot_Destroy(fwInstance->fwSlotList[i]); | |
318 } | |
319 | |
320 goto loser; | |
321 } | |
322 #endif /* DEBUG */ | |
323 | |
324 *pError = CKR_OK; | |
325 return fwInstance; | |
326 | |
327 nomem: | |
328 *pError = CKR_HOST_MEMORY; | |
329 /*FALLTHROUGH*/ | |
330 loser: | |
331 | |
332 if( CK_TRUE == called_Initialize ) { | |
333 if (mdInstance->Finalize) { | |
334 mdInstance->Finalize(mdInstance, fwInstance); | |
335 } | |
336 } | |
337 | |
338 if (fwInstance && fwInstance->mutex) { | |
339 nssCKFWMutex_Destroy(fwInstance->mutex); | |
340 } | |
341 | |
342 if (arena) { | |
343 (void)NSSArena_Destroy(arena); | |
344 } | |
345 return (NSSCKFWInstance *)NULL; | |
346 } | |
347 | |
348 /* | |
349 * nssCKFWInstance_Destroy | |
350 * | |
351 */ | |
352 NSS_IMPLEMENT CK_RV | |
353 nssCKFWInstance_Destroy | |
354 ( | |
355 NSSCKFWInstance *fwInstance | |
356 ) | |
357 { | |
358 #ifdef NSSDEBUG | |
359 CK_RV error = CKR_OK; | |
360 #endif /* NSSDEBUG */ | |
361 CK_ULONG i; | |
362 | |
363 #ifdef NSSDEBUG | |
364 error = nssCKFWInstance_verifyPointer(fwInstance); | |
365 if( CKR_OK != error ) { | |
366 return error; | |
367 } | |
368 #endif /* NSSDEBUG */ | |
369 | |
370 nssCKFWMutex_Destroy(fwInstance->mutex); | |
371 | |
372 for( i = 0; i < fwInstance->nSlots; i++ ) { | |
373 (void)nssCKFWSlot_Destroy(fwInstance->fwSlotList[i]); | |
374 } | |
375 | |
376 if (fwInstance->mdInstance->Finalize) { | |
377 fwInstance->mdInstance->Finalize(fwInstance->mdInstance, fwInstance); | |
378 } | |
379 | |
380 if (fwInstance->sessionHandleHash) { | |
381 nssCKFWHash_Destroy(fwInstance->sessionHandleHash); | |
382 } | |
383 | |
384 if (fwInstance->objectHandleHash) { | |
385 nssCKFWHash_Destroy(fwInstance->objectHandleHash); | |
386 } | |
387 | |
388 #ifdef DEBUG | |
389 (void)instance_remove_pointer(fwInstance); | |
390 #endif /* DEBUG */ | |
391 | |
392 (void)NSSArena_Destroy(fwInstance->arena); | |
393 return CKR_OK; | |
394 } | |
395 | |
396 /* | |
397 * nssCKFWInstance_GetMDInstance | |
398 * | |
399 */ | |
400 NSS_IMPLEMENT NSSCKMDInstance * | |
401 nssCKFWInstance_GetMDInstance | |
402 ( | |
403 NSSCKFWInstance *fwInstance | |
404 ) | |
405 { | |
406 #ifdef NSSDEBUG | |
407 if( CKR_OK != nssCKFWInstance_verifyPointer(fwInstance) ) { | |
408 return (NSSCKMDInstance *)NULL; | |
409 } | |
410 #endif /* NSSDEBUG */ | |
411 | |
412 return fwInstance->mdInstance; | |
413 } | |
414 | |
415 /* | |
416 * nssCKFWInstance_GetArena | |
417 * | |
418 */ | |
419 NSS_IMPLEMENT NSSArena * | |
420 nssCKFWInstance_GetArena | |
421 ( | |
422 NSSCKFWInstance *fwInstance, | |
423 CK_RV *pError | |
424 ) | |
425 { | |
426 #ifdef NSSDEBUG | |
427 if (!pError) { | |
428 return (NSSArena *)NULL; | |
429 } | |
430 | |
431 *pError = nssCKFWInstance_verifyPointer(fwInstance); | |
432 if( CKR_OK != *pError ) { | |
433 return (NSSArena *)NULL; | |
434 } | |
435 #endif /* NSSDEBUG */ | |
436 | |
437 *pError = CKR_OK; | |
438 return fwInstance->arena; | |
439 } | |
440 | |
441 /* | |
442 * nssCKFWInstance_MayCreatePthreads | |
443 * | |
444 */ | |
445 NSS_IMPLEMENT CK_BBOOL | |
446 nssCKFWInstance_MayCreatePthreads | |
447 ( | |
448 NSSCKFWInstance *fwInstance | |
449 ) | |
450 { | |
451 #ifdef NSSDEBUG | |
452 if( CKR_OK != nssCKFWInstance_verifyPointer(fwInstance) ) { | |
453 return CK_FALSE; | |
454 } | |
455 #endif /* NSSDEBUG */ | |
456 | |
457 return fwInstance->mayCreatePthreads; | |
458 } | |
459 | |
460 /* | |
461 * nssCKFWInstance_CreateMutex | |
462 * | |
463 */ | |
464 NSS_IMPLEMENT NSSCKFWMutex * | |
465 nssCKFWInstance_CreateMutex | |
466 ( | |
467 NSSCKFWInstance *fwInstance, | |
468 NSSArena *arena, | |
469 CK_RV *pError | |
470 ) | |
471 { | |
472 NSSCKFWMutex *mutex; | |
473 | |
474 #ifdef NSSDEBUG | |
475 if (!pError) { | |
476 return (NSSCKFWMutex *)NULL; | |
477 } | |
478 | |
479 *pError = nssCKFWInstance_verifyPointer(fwInstance); | |
480 if( CKR_OK != *pError ) { | |
481 return (NSSCKFWMutex *)NULL; | |
482 } | |
483 #endif /* NSSDEBUG */ | |
484 | |
485 mutex = nssCKFWMutex_Create(fwInstance->pInitArgs, fwInstance->LockingState, | |
486 arena, pError); | |
487 if (!mutex) { | |
488 if( CKR_OK == *pError ) { | |
489 *pError = CKR_GENERAL_ERROR; | |
490 } | |
491 | |
492 return (NSSCKFWMutex *)NULL; | |
493 } | |
494 | |
495 return mutex; | |
496 } | |
497 | |
498 /* | |
499 * nssCKFWInstance_GetConfigurationData | |
500 * | |
501 */ | |
502 NSS_IMPLEMENT NSSUTF8 * | |
503 nssCKFWInstance_GetConfigurationData | |
504 ( | |
505 NSSCKFWInstance *fwInstance | |
506 ) | |
507 { | |
508 #ifdef NSSDEBUG | |
509 if( CKR_OK != nssCKFWInstance_verifyPointer(fwInstance) ) { | |
510 return (NSSUTF8 *)NULL; | |
511 } | |
512 #endif /* NSSDEBUG */ | |
513 | |
514 return fwInstance->configurationData; | |
515 } | |
516 | |
517 /* | |
518 * nssCKFWInstance_GetInitArgs | |
519 * | |
520 */ | |
521 CK_C_INITIALIZE_ARGS_PTR | |
522 nssCKFWInstance_GetInitArgs | |
523 ( | |
524 NSSCKFWInstance *fwInstance | |
525 ) | |
526 { | |
527 #ifdef NSSDEBUG | |
528 if( CKR_OK != nssCKFWInstance_verifyPointer(fwInstance) ) { | |
529 return (CK_C_INITIALIZE_ARGS_PTR)NULL; | |
530 } | |
531 #endif /* NSSDEBUG */ | |
532 | |
533 return fwInstance->pInitArgs; | |
534 } | |
535 | |
536 /* | |
537 * nssCKFWInstance_CreateSessionHandle | |
538 * | |
539 */ | |
540 NSS_IMPLEMENT CK_SESSION_HANDLE | |
541 nssCKFWInstance_CreateSessionHandle | |
542 ( | |
543 NSSCKFWInstance *fwInstance, | |
544 NSSCKFWSession *fwSession, | |
545 CK_RV *pError | |
546 ) | |
547 { | |
548 CK_SESSION_HANDLE hSession; | |
549 | |
550 #ifdef NSSDEBUG | |
551 if (!pError) { | |
552 return (CK_SESSION_HANDLE)0; | |
553 } | |
554 | |
555 *pError = nssCKFWInstance_verifyPointer(fwInstance); | |
556 if( CKR_OK != *pError ) { | |
557 return (CK_SESSION_HANDLE)0; | |
558 } | |
559 #endif /* NSSDEBUG */ | |
560 | |
561 *pError = nssCKFWMutex_Lock(fwInstance->mutex); | |
562 if( CKR_OK != *pError ) { | |
563 return (CK_SESSION_HANDLE)0; | |
564 } | |
565 | |
566 hSession = ++(fwInstance->lastSessionHandle); | |
567 | |
568 /* Alan would say I should unlock for this call. */ | |
569 | |
570 *pError = nssCKFWSession_SetHandle(fwSession, hSession); | |
571 if( CKR_OK != *pError ) { | |
572 goto done; | |
573 } | |
574 | |
575 *pError = nssCKFWHash_Add(fwInstance->sessionHandleHash, | |
576 (const void *)hSession, (const void *)fwSession); | |
577 if( CKR_OK != *pError ) { | |
578 hSession = (CK_SESSION_HANDLE)0; | |
579 goto done; | |
580 } | |
581 | |
582 done: | |
583 nssCKFWMutex_Unlock(fwInstance->mutex); | |
584 return hSession; | |
585 } | |
586 | |
587 /* | |
588 * nssCKFWInstance_ResolveSessionHandle | |
589 * | |
590 */ | |
591 NSS_IMPLEMENT NSSCKFWSession * | |
592 nssCKFWInstance_ResolveSessionHandle | |
593 ( | |
594 NSSCKFWInstance *fwInstance, | |
595 CK_SESSION_HANDLE hSession | |
596 ) | |
597 { | |
598 NSSCKFWSession *fwSession; | |
599 | |
600 #ifdef NSSDEBUG | |
601 if( CKR_OK != nssCKFWInstance_verifyPointer(fwInstance) ) { | |
602 return (NSSCKFWSession *)NULL; | |
603 } | |
604 #endif /* NSSDEBUG */ | |
605 | |
606 if( CKR_OK != nssCKFWMutex_Lock(fwInstance->mutex) ) { | |
607 return (NSSCKFWSession *)NULL; | |
608 } | |
609 | |
610 fwSession = (NSSCKFWSession *)nssCKFWHash_Lookup( | |
611 fwInstance->sessionHandleHash, (const void *)hSession); | |
612 | |
613 /* Assert(hSession == nssCKFWSession_GetHandle(fwSession)) */ | |
614 | |
615 (void)nssCKFWMutex_Unlock(fwInstance->mutex); | |
616 | |
617 return fwSession; | |
618 } | |
619 | |
620 /* | |
621 * nssCKFWInstance_DestroySessionHandle | |
622 * | |
623 */ | |
624 NSS_IMPLEMENT void | |
625 nssCKFWInstance_DestroySessionHandle | |
626 ( | |
627 NSSCKFWInstance *fwInstance, | |
628 CK_SESSION_HANDLE hSession | |
629 ) | |
630 { | |
631 NSSCKFWSession *fwSession; | |
632 | |
633 #ifdef NSSDEBUG | |
634 if( CKR_OK != nssCKFWInstance_verifyPointer(fwInstance) ) { | |
635 return; | |
636 } | |
637 #endif /* NSSDEBUG */ | |
638 | |
639 if( CKR_OK != nssCKFWMutex_Lock(fwInstance->mutex) ) { | |
640 return; | |
641 } | |
642 | |
643 fwSession = (NSSCKFWSession *)nssCKFWHash_Lookup( | |
644 fwInstance->sessionHandleHash, (const void *)hSession); | |
645 if (fwSession) { | |
646 nssCKFWHash_Remove(fwInstance->sessionHandleHash, (const void *)hSession); | |
647 nssCKFWSession_SetHandle(fwSession, (CK_SESSION_HANDLE)0); | |
648 } | |
649 | |
650 (void)nssCKFWMutex_Unlock(fwInstance->mutex); | |
651 | |
652 return; | |
653 } | |
654 | |
655 /* | |
656 * nssCKFWInstance_FindSessionHandle | |
657 * | |
658 */ | |
659 NSS_IMPLEMENT CK_SESSION_HANDLE | |
660 nssCKFWInstance_FindSessionHandle | |
661 ( | |
662 NSSCKFWInstance *fwInstance, | |
663 NSSCKFWSession *fwSession | |
664 ) | |
665 { | |
666 #ifdef NSSDEBUG | |
667 if( CKR_OK != nssCKFWInstance_verifyPointer(fwInstance) ) { | |
668 return (CK_SESSION_HANDLE)0; | |
669 } | |
670 | |
671 if( CKR_OK != nssCKFWSession_verifyPointer(fwSession) ) { | |
672 return (CK_SESSION_HANDLE)0; | |
673 } | |
674 #endif /* NSSDEBUG */ | |
675 | |
676 return nssCKFWSession_GetHandle(fwSession); | |
677 /* look it up and assert? */ | |
678 } | |
679 | |
680 /* | |
681 * nssCKFWInstance_CreateObjectHandle | |
682 * | |
683 */ | |
684 NSS_IMPLEMENT CK_OBJECT_HANDLE | |
685 nssCKFWInstance_CreateObjectHandle | |
686 ( | |
687 NSSCKFWInstance *fwInstance, | |
688 NSSCKFWObject *fwObject, | |
689 CK_RV *pError | |
690 ) | |
691 { | |
692 CK_OBJECT_HANDLE hObject; | |
693 | |
694 #ifdef NSSDEBUG | |
695 if (!pError) { | |
696 return (CK_OBJECT_HANDLE)0; | |
697 } | |
698 | |
699 *pError = nssCKFWInstance_verifyPointer(fwInstance); | |
700 if( CKR_OK != *pError ) { | |
701 return (CK_OBJECT_HANDLE)0; | |
702 } | |
703 #endif /* NSSDEBUG */ | |
704 | |
705 *pError = nssCKFWMutex_Lock(fwInstance->mutex); | |
706 if( CKR_OK != *pError ) { | |
707 return (CK_OBJECT_HANDLE)0; | |
708 } | |
709 | |
710 hObject = ++(fwInstance->lastObjectHandle); | |
711 | |
712 *pError = nssCKFWObject_SetHandle(fwObject, hObject); | |
713 if( CKR_OK != *pError ) { | |
714 hObject = (CK_OBJECT_HANDLE)0; | |
715 goto done; | |
716 } | |
717 | |
718 *pError = nssCKFWHash_Add(fwInstance->objectHandleHash, | |
719 (const void *)hObject, (const void *)fwObject); | |
720 if( CKR_OK != *pError ) { | |
721 hObject = (CK_OBJECT_HANDLE)0; | |
722 goto done; | |
723 } | |
724 | |
725 done: | |
726 (void)nssCKFWMutex_Unlock(fwInstance->mutex); | |
727 return hObject; | |
728 } | |
729 | |
730 /* | |
731 * nssCKFWInstance_ResolveObjectHandle | |
732 * | |
733 */ | |
734 NSS_IMPLEMENT NSSCKFWObject * | |
735 nssCKFWInstance_ResolveObjectHandle | |
736 ( | |
737 NSSCKFWInstance *fwInstance, | |
738 CK_OBJECT_HANDLE hObject | |
739 ) | |
740 { | |
741 NSSCKFWObject *fwObject; | |
742 | |
743 #ifdef NSSDEBUG | |
744 if( CKR_OK != nssCKFWInstance_verifyPointer(fwInstance) ) { | |
745 return (NSSCKFWObject *)NULL; | |
746 } | |
747 #endif /* NSSDEBUG */ | |
748 | |
749 if( CKR_OK != nssCKFWMutex_Lock(fwInstance->mutex) ) { | |
750 return (NSSCKFWObject *)NULL; | |
751 } | |
752 | |
753 fwObject = (NSSCKFWObject *)nssCKFWHash_Lookup( | |
754 fwInstance->objectHandleHash, (const void *)hObject); | |
755 | |
756 /* Assert(hObject == nssCKFWObject_GetHandle(fwObject)) */ | |
757 | |
758 (void)nssCKFWMutex_Unlock(fwInstance->mutex); | |
759 return fwObject; | |
760 } | |
761 | |
762 /* | |
763 * nssCKFWInstance_ReassignObjectHandle | |
764 * | |
765 */ | |
766 NSS_IMPLEMENT CK_RV | |
767 nssCKFWInstance_ReassignObjectHandle | |
768 ( | |
769 NSSCKFWInstance *fwInstance, | |
770 CK_OBJECT_HANDLE hObject, | |
771 NSSCKFWObject *fwObject | |
772 ) | |
773 { | |
774 CK_RV error = CKR_OK; | |
775 NSSCKFWObject *oldObject; | |
776 | |
777 #ifdef NSSDEBUG | |
778 error = nssCKFWInstance_verifyPointer(fwInstance); | |
779 if( CKR_OK != error ) { | |
780 return error; | |
781 } | |
782 #endif /* NSSDEBUG */ | |
783 | |
784 error = nssCKFWMutex_Lock(fwInstance->mutex); | |
785 if( CKR_OK != error ) { | |
786 return error; | |
787 } | |
788 | |
789 oldObject = (NSSCKFWObject *)nssCKFWHash_Lookup( | |
790 fwInstance->objectHandleHash, (const void *)hObject); | |
791 if(oldObject) { | |
792 /* Assert(hObject == nssCKFWObject_GetHandle(oldObject) */ | |
793 (void)nssCKFWObject_SetHandle(oldObject, (CK_SESSION_HANDLE)0); | |
794 nssCKFWHash_Remove(fwInstance->objectHandleHash, (const void *)hObject); | |
795 } | |
796 | |
797 error = nssCKFWObject_SetHandle(fwObject, hObject); | |
798 if( CKR_OK != error ) { | |
799 goto done; | |
800 } | |
801 error = nssCKFWHash_Add(fwInstance->objectHandleHash, | |
802 (const void *)hObject, (const void *)fwObject); | |
803 | |
804 done: | |
805 (void)nssCKFWMutex_Unlock(fwInstance->mutex); | |
806 return error; | |
807 } | |
808 | |
809 /* | |
810 * nssCKFWInstance_DestroyObjectHandle | |
811 * | |
812 */ | |
813 NSS_IMPLEMENT void | |
814 nssCKFWInstance_DestroyObjectHandle | |
815 ( | |
816 NSSCKFWInstance *fwInstance, | |
817 CK_OBJECT_HANDLE hObject | |
818 ) | |
819 { | |
820 NSSCKFWObject *fwObject; | |
821 | |
822 #ifdef NSSDEBUG | |
823 if( CKR_OK != nssCKFWInstance_verifyPointer(fwInstance) ) { | |
824 return; | |
825 } | |
826 #endif /* NSSDEBUG */ | |
827 | |
828 if( CKR_OK != nssCKFWMutex_Lock(fwInstance->mutex) ) { | |
829 return; | |
830 } | |
831 | |
832 fwObject = (NSSCKFWObject *)nssCKFWHash_Lookup( | |
833 fwInstance->objectHandleHash, (const void *)hObject); | |
834 if (fwObject) { | |
835 /* Assert(hObject = nssCKFWObject_GetHandle(fwObject)) */ | |
836 nssCKFWHash_Remove(fwInstance->objectHandleHash, (const void *)hObject); | |
837 (void)nssCKFWObject_SetHandle(fwObject, (CK_SESSION_HANDLE)0); | |
838 } | |
839 | |
840 (void)nssCKFWMutex_Unlock(fwInstance->mutex); | |
841 return; | |
842 } | |
843 | |
844 /* | |
845 * nssCKFWInstance_FindObjectHandle | |
846 * | |
847 */ | |
848 NSS_IMPLEMENT CK_OBJECT_HANDLE | |
849 nssCKFWInstance_FindObjectHandle | |
850 ( | |
851 NSSCKFWInstance *fwInstance, | |
852 NSSCKFWObject *fwObject | |
853 ) | |
854 { | |
855 #ifdef NSSDEBUG | |
856 if( CKR_OK != nssCKFWInstance_verifyPointer(fwInstance) ) { | |
857 return (CK_OBJECT_HANDLE)0; | |
858 } | |
859 | |
860 if( CKR_OK != nssCKFWObject_verifyPointer(fwObject) ) { | |
861 return (CK_OBJECT_HANDLE)0; | |
862 } | |
863 #endif /* NSSDEBUG */ | |
864 | |
865 return nssCKFWObject_GetHandle(fwObject); | |
866 } | |
867 | |
868 /* | |
869 * nssCKFWInstance_GetNSlots | |
870 * | |
871 */ | |
872 NSS_IMPLEMENT CK_ULONG | |
873 nssCKFWInstance_GetNSlots | |
874 ( | |
875 NSSCKFWInstance *fwInstance, | |
876 CK_RV *pError | |
877 ) | |
878 { | |
879 #ifdef NSSDEBUG | |
880 if (!pError) { | |
881 return (CK_ULONG)0; | |
882 } | |
883 | |
884 *pError = nssCKFWInstance_verifyPointer(fwInstance); | |
885 if( CKR_OK != *pError ) { | |
886 return (CK_ULONG)0; | |
887 } | |
888 #endif /* NSSDEBUG */ | |
889 | |
890 *pError = CKR_OK; | |
891 return fwInstance->nSlots; | |
892 } | |
893 | |
894 /* | |
895 * nssCKFWInstance_GetCryptokiVersion | |
896 * | |
897 */ | |
898 NSS_IMPLEMENT CK_VERSION | |
899 nssCKFWInstance_GetCryptokiVersion | |
900 ( | |
901 NSSCKFWInstance *fwInstance | |
902 ) | |
903 { | |
904 CK_VERSION rv; | |
905 | |
906 #ifdef NSSDEBUG | |
907 if( CKR_OK != nssCKFWInstance_verifyPointer(fwInstance) ) { | |
908 rv.major = rv.minor = 0; | |
909 return rv; | |
910 } | |
911 #endif /* NSSDEBUG */ | |
912 | |
913 if( CKR_OK != nssCKFWMutex_Lock(fwInstance->mutex) ) { | |
914 rv.major = rv.minor = 0; | |
915 return rv; | |
916 } | |
917 | |
918 if( (0 != fwInstance->cryptokiVersion.major) || | |
919 (0 != fwInstance->cryptokiVersion.minor) ) { | |
920 rv = fwInstance->cryptokiVersion; | |
921 goto done; | |
922 } | |
923 | |
924 if (fwInstance->mdInstance->GetCryptokiVersion) { | |
925 fwInstance->cryptokiVersion = fwInstance->mdInstance->GetCryptokiVersion( | |
926 fwInstance->mdInstance, fwInstance); | |
927 } else { | |
928 fwInstance->cryptokiVersion.major = 2; | |
929 fwInstance->cryptokiVersion.minor = 1; | |
930 } | |
931 | |
932 rv = fwInstance->cryptokiVersion; | |
933 | |
934 done: | |
935 (void)nssCKFWMutex_Unlock(fwInstance->mutex); | |
936 return rv; | |
937 } | |
938 | |
939 /* | |
940 * nssCKFWInstance_GetManufacturerID | |
941 * | |
942 */ | |
943 NSS_IMPLEMENT CK_RV | |
944 nssCKFWInstance_GetManufacturerID | |
945 ( | |
946 NSSCKFWInstance *fwInstance, | |
947 CK_CHAR manufacturerID[32] | |
948 ) | |
949 { | |
950 CK_RV error = CKR_OK; | |
951 | |
952 #ifdef NSSDEBUG | |
953 if( (CK_CHAR_PTR)NULL == manufacturerID ) { | |
954 return CKR_ARGUMENTS_BAD; | |
955 } | |
956 | |
957 error = nssCKFWInstance_verifyPointer(fwInstance); | |
958 if( CKR_OK != error ) { | |
959 return error; | |
960 } | |
961 #endif /* NSSDEBUG */ | |
962 | |
963 error = nssCKFWMutex_Lock(fwInstance->mutex); | |
964 if( CKR_OK != error ) { | |
965 return error; | |
966 } | |
967 | |
968 if (!fwInstance->manufacturerID) { | |
969 if (fwInstance->mdInstance->GetManufacturerID) { | |
970 fwInstance->manufacturerID = fwInstance->mdInstance->GetManufacturerID( | |
971 fwInstance->mdInstance, fwInstance, &error); | |
972 if ((!fwInstance->manufacturerID) && (CKR_OK != error)) { | |
973 goto done; | |
974 } | |
975 } else { | |
976 fwInstance->manufacturerID = (NSSUTF8 *) ""; | |
977 } | |
978 } | |
979 | |
980 (void)nssUTF8_CopyIntoFixedBuffer(fwInstance->manufacturerID, (char *)manufact
urerID, 32, ' '); | |
981 error = CKR_OK; | |
982 | |
983 done: | |
984 (void)nssCKFWMutex_Unlock(fwInstance->mutex); | |
985 return error; | |
986 } | |
987 | |
988 /* | |
989 * nssCKFWInstance_GetFlags | |
990 * | |
991 */ | |
992 NSS_IMPLEMENT CK_ULONG | |
993 nssCKFWInstance_GetFlags | |
994 ( | |
995 NSSCKFWInstance *fwInstance | |
996 ) | |
997 { | |
998 #ifdef NSSDEBUG | |
999 if( CKR_OK != nssCKFWInstance_verifyPointer(fwInstance) ) { | |
1000 return (CK_ULONG)0; | |
1001 } | |
1002 #endif /* NSSDEBUG */ | |
1003 | |
1004 /* No "instance flags" are yet defined by Cryptoki. */ | |
1005 return (CK_ULONG)0; | |
1006 } | |
1007 | |
1008 /* | |
1009 * nssCKFWInstance_GetLibraryDescription | |
1010 * | |
1011 */ | |
1012 NSS_IMPLEMENT CK_RV | |
1013 nssCKFWInstance_GetLibraryDescription | |
1014 ( | |
1015 NSSCKFWInstance *fwInstance, | |
1016 CK_CHAR libraryDescription[32] | |
1017 ) | |
1018 { | |
1019 CK_RV error = CKR_OK; | |
1020 | |
1021 #ifdef NSSDEBUG | |
1022 if( (CK_CHAR_PTR)NULL == libraryDescription ) { | |
1023 return CKR_ARGUMENTS_BAD; | |
1024 } | |
1025 | |
1026 error = nssCKFWInstance_verifyPointer(fwInstance); | |
1027 if( CKR_OK != error ) { | |
1028 return error; | |
1029 } | |
1030 #endif /* NSSDEBUG */ | |
1031 | |
1032 error = nssCKFWMutex_Lock(fwInstance->mutex); | |
1033 if( CKR_OK != error ) { | |
1034 return error; | |
1035 } | |
1036 | |
1037 if (!fwInstance->libraryDescription) { | |
1038 if (fwInstance->mdInstance->GetLibraryDescription) { | |
1039 fwInstance->libraryDescription = fwInstance->mdInstance->GetLibraryDescrip
tion( | |
1040 fwInstance->mdInstance, fwInstance, &error); | |
1041 if ((!fwInstance->libraryDescription) && (CKR_OK != error)) { | |
1042 goto done; | |
1043 } | |
1044 } else { | |
1045 fwInstance->libraryDescription = (NSSUTF8 *) ""; | |
1046 } | |
1047 } | |
1048 | |
1049 (void)nssUTF8_CopyIntoFixedBuffer(fwInstance->libraryDescription, (char *)libr
aryDescription, 32, ' '); | |
1050 error = CKR_OK; | |
1051 | |
1052 done: | |
1053 (void)nssCKFWMutex_Unlock(fwInstance->mutex); | |
1054 return error; | |
1055 } | |
1056 | |
1057 /* | |
1058 * nssCKFWInstance_GetLibraryVersion | |
1059 * | |
1060 */ | |
1061 NSS_IMPLEMENT CK_VERSION | |
1062 nssCKFWInstance_GetLibraryVersion | |
1063 ( | |
1064 NSSCKFWInstance *fwInstance | |
1065 ) | |
1066 { | |
1067 CK_VERSION rv; | |
1068 | |
1069 #ifdef NSSDEBUG | |
1070 if( CKR_OK != nssCKFWInstance_verifyPointer(fwInstance) ) { | |
1071 rv.major = rv.minor = 0; | |
1072 return rv; | |
1073 } | |
1074 #endif /* NSSDEBUG */ | |
1075 | |
1076 if( CKR_OK != nssCKFWMutex_Lock(fwInstance->mutex) ) { | |
1077 rv.major = rv.minor = 0; | |
1078 return rv; | |
1079 } | |
1080 | |
1081 if( (0 != fwInstance->libraryVersion.major) || | |
1082 (0 != fwInstance->libraryVersion.minor) ) { | |
1083 rv = fwInstance->libraryVersion; | |
1084 goto done; | |
1085 } | |
1086 | |
1087 if (fwInstance->mdInstance->GetLibraryVersion) { | |
1088 fwInstance->libraryVersion = fwInstance->mdInstance->GetLibraryVersion( | |
1089 fwInstance->mdInstance, fwInstance); | |
1090 } else { | |
1091 fwInstance->libraryVersion.major = 0; | |
1092 fwInstance->libraryVersion.minor = 3; | |
1093 } | |
1094 | |
1095 rv = fwInstance->libraryVersion; | |
1096 done: | |
1097 (void)nssCKFWMutex_Unlock(fwInstance->mutex); | |
1098 return rv; | |
1099 } | |
1100 | |
1101 /* | |
1102 * nssCKFWInstance_GetModuleHandlesSessionObjects | |
1103 * | |
1104 */ | |
1105 NSS_IMPLEMENT CK_BBOOL | |
1106 nssCKFWInstance_GetModuleHandlesSessionObjects | |
1107 ( | |
1108 NSSCKFWInstance *fwInstance | |
1109 ) | |
1110 { | |
1111 #ifdef NSSDEBUG | |
1112 if( CKR_OK != nssCKFWInstance_verifyPointer(fwInstance) ) { | |
1113 return CK_FALSE; | |
1114 } | |
1115 #endif /* NSSDEBUG */ | |
1116 | |
1117 return fwInstance->moduleHandlesSessionObjects; | |
1118 } | |
1119 | |
1120 /* | |
1121 * nssCKFWInstance_GetSlots | |
1122 * | |
1123 */ | |
1124 NSS_IMPLEMENT NSSCKFWSlot ** | |
1125 nssCKFWInstance_GetSlots | |
1126 ( | |
1127 NSSCKFWInstance *fwInstance, | |
1128 CK_RV *pError | |
1129 ) | |
1130 { | |
1131 #ifdef NSSDEBUG | |
1132 if (!pError) { | |
1133 return (NSSCKFWSlot **)NULL; | |
1134 } | |
1135 | |
1136 *pError = nssCKFWInstance_verifyPointer(fwInstance); | |
1137 if( CKR_OK != *pError ) { | |
1138 return (NSSCKFWSlot **)NULL; | |
1139 } | |
1140 #endif /* NSSDEBUG */ | |
1141 | |
1142 return fwInstance->fwSlotList; | |
1143 } | |
1144 | |
1145 /* | |
1146 * nssCKFWInstance_WaitForSlotEvent | |
1147 * | |
1148 */ | |
1149 NSS_IMPLEMENT NSSCKFWSlot * | |
1150 nssCKFWInstance_WaitForSlotEvent | |
1151 ( | |
1152 NSSCKFWInstance *fwInstance, | |
1153 CK_BBOOL block, | |
1154 CK_RV *pError | |
1155 ) | |
1156 { | |
1157 NSSCKFWSlot *fwSlot = (NSSCKFWSlot *)NULL; | |
1158 NSSCKMDSlot *mdSlot; | |
1159 CK_ULONG i, n; | |
1160 | |
1161 #ifdef NSSDEBUG | |
1162 if (!pError) { | |
1163 return (NSSCKFWSlot *)NULL; | |
1164 } | |
1165 | |
1166 *pError = nssCKFWInstance_verifyPointer(fwInstance); | |
1167 if( CKR_OK != *pError ) { | |
1168 return (NSSCKFWSlot *)NULL; | |
1169 } | |
1170 | |
1171 switch( block ) { | |
1172 case CK_TRUE: | |
1173 case CK_FALSE: | |
1174 break; | |
1175 default: | |
1176 *pError = CKR_ARGUMENTS_BAD; | |
1177 return (NSSCKFWSlot *)NULL; | |
1178 } | |
1179 #endif /* NSSDEBUG */ | |
1180 | |
1181 if (!fwInstance->mdInstance->WaitForSlotEvent) { | |
1182 *pError = CKR_NO_EVENT; | |
1183 return (NSSCKFWSlot *)NULL; | |
1184 } | |
1185 | |
1186 mdSlot = fwInstance->mdInstance->WaitForSlotEvent( | |
1187 fwInstance->mdInstance, | |
1188 fwInstance, | |
1189 block, | |
1190 pError | |
1191 ); | |
1192 | |
1193 if (!mdSlot) { | |
1194 return (NSSCKFWSlot *)NULL; | |
1195 } | |
1196 | |
1197 n = nssCKFWInstance_GetNSlots(fwInstance, pError); | |
1198 if( ((CK_ULONG)0 == n) && (CKR_OK != *pError) ) { | |
1199 return (NSSCKFWSlot *)NULL; | |
1200 } | |
1201 | |
1202 for( i = 0; i < n; i++ ) { | |
1203 if( fwInstance->mdSlotList[i] == mdSlot ) { | |
1204 fwSlot = fwInstance->fwSlotList[i]; | |
1205 break; | |
1206 } | |
1207 } | |
1208 | |
1209 if (!fwSlot) { | |
1210 /* Internal error */ | |
1211 *pError = CKR_GENERAL_ERROR; | |
1212 return (NSSCKFWSlot *)NULL; | |
1213 } | |
1214 | |
1215 return fwSlot; | |
1216 } | |
1217 | |
1218 /* | |
1219 * NSSCKFWInstance_GetMDInstance | |
1220 * | |
1221 */ | |
1222 NSS_IMPLEMENT NSSCKMDInstance * | |
1223 NSSCKFWInstance_GetMDInstance | |
1224 ( | |
1225 NSSCKFWInstance *fwInstance | |
1226 ) | |
1227 { | |
1228 #ifdef DEBUG | |
1229 if( CKR_OK != nssCKFWInstance_verifyPointer(fwInstance) ) { | |
1230 return (NSSCKMDInstance *)NULL; | |
1231 } | |
1232 #endif /* DEBUG */ | |
1233 | |
1234 return nssCKFWInstance_GetMDInstance(fwInstance); | |
1235 } | |
1236 | |
1237 /* | |
1238 * NSSCKFWInstance_GetArena | |
1239 * | |
1240 */ | |
1241 NSS_IMPLEMENT NSSArena * | |
1242 NSSCKFWInstance_GetArena | |
1243 ( | |
1244 NSSCKFWInstance *fwInstance, | |
1245 CK_RV *pError | |
1246 ) | |
1247 { | |
1248 #ifdef DEBUG | |
1249 if (!pError) { | |
1250 return (NSSArena *)NULL; | |
1251 } | |
1252 | |
1253 *pError = nssCKFWInstance_verifyPointer(fwInstance); | |
1254 if( CKR_OK != *pError ) { | |
1255 return (NSSArena *)NULL; | |
1256 } | |
1257 #endif /* DEBUG */ | |
1258 | |
1259 return nssCKFWInstance_GetArena(fwInstance, pError); | |
1260 } | |
1261 | |
1262 /* | |
1263 * NSSCKFWInstance_MayCreatePthreads | |
1264 * | |
1265 */ | |
1266 NSS_IMPLEMENT CK_BBOOL | |
1267 NSSCKFWInstance_MayCreatePthreads | |
1268 ( | |
1269 NSSCKFWInstance *fwInstance | |
1270 ) | |
1271 { | |
1272 #ifdef DEBUG | |
1273 if( CKR_OK != nssCKFWInstance_verifyPointer(fwInstance) ) { | |
1274 return CK_FALSE; | |
1275 } | |
1276 #endif /* DEBUG */ | |
1277 | |
1278 return nssCKFWInstance_MayCreatePthreads(fwInstance); | |
1279 } | |
1280 | |
1281 /* | |
1282 * NSSCKFWInstance_CreateMutex | |
1283 * | |
1284 */ | |
1285 NSS_IMPLEMENT NSSCKFWMutex * | |
1286 NSSCKFWInstance_CreateMutex | |
1287 ( | |
1288 NSSCKFWInstance *fwInstance, | |
1289 NSSArena *arena, | |
1290 CK_RV *pError | |
1291 ) | |
1292 { | |
1293 #ifdef DEBUG | |
1294 if (!pError) { | |
1295 return (NSSCKFWMutex *)NULL; | |
1296 } | |
1297 | |
1298 *pError = nssCKFWInstance_verifyPointer(fwInstance); | |
1299 if( CKR_OK != *pError ) { | |
1300 return (NSSCKFWMutex *)NULL; | |
1301 } | |
1302 #endif /* DEBUG */ | |
1303 | |
1304 return nssCKFWInstance_CreateMutex(fwInstance, arena, pError); | |
1305 } | |
1306 | |
1307 /* | |
1308 * NSSCKFWInstance_GetConfigurationData | |
1309 * | |
1310 */ | |
1311 NSS_IMPLEMENT NSSUTF8 * | |
1312 NSSCKFWInstance_GetConfigurationData | |
1313 ( | |
1314 NSSCKFWInstance *fwInstance | |
1315 ) | |
1316 { | |
1317 #ifdef DEBUG | |
1318 if( CKR_OK != nssCKFWInstance_verifyPointer(fwInstance) ) { | |
1319 return (NSSUTF8 *)NULL; | |
1320 } | |
1321 #endif /* DEBUG */ | |
1322 | |
1323 return nssCKFWInstance_GetConfigurationData(fwInstance); | |
1324 } | |
1325 | |
1326 /* | |
1327 * NSSCKFWInstance_GetInitArgs | |
1328 * | |
1329 */ | |
1330 NSS_IMPLEMENT CK_C_INITIALIZE_ARGS_PTR | |
1331 NSSCKFWInstance_GetInitArgs | |
1332 ( | |
1333 NSSCKFWInstance *fwInstance | |
1334 ) | |
1335 { | |
1336 #ifdef DEBUG | |
1337 if( CKR_OK != nssCKFWInstance_verifyPointer(fwInstance) ) { | |
1338 return (CK_C_INITIALIZE_ARGS_PTR)NULL; | |
1339 } | |
1340 #endif /* DEBUG */ | |
1341 | |
1342 return nssCKFWInstance_GetInitArgs(fwInstance); | |
1343 } | |
1344 | |
OLD | NEW |