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