Mercurial > trustbridge > nss-cmake-static
comparison nss/lib/ckfw/slot.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 * slot.c | |
7 * | |
8 * This file implements the NSSCKFWSlot type and methods. | |
9 */ | |
10 | |
11 #ifndef CK_T | |
12 #include "ck.h" | |
13 #endif /* CK_T */ | |
14 | |
15 /* | |
16 * NSSCKFWSlot | |
17 * | |
18 * -- create/destroy -- | |
19 * nssCKFWSlot_Create | |
20 * nssCKFWSlot_Destroy | |
21 * | |
22 * -- public accessors -- | |
23 * NSSCKFWSlot_GetMDSlot | |
24 * NSSCKFWSlot_GetFWInstance | |
25 * NSSCKFWSlot_GetMDInstance | |
26 * | |
27 * -- implement public accessors -- | |
28 * nssCKFWSlot_GetMDSlot | |
29 * nssCKFWSlot_GetFWInstance | |
30 * nssCKFWSlot_GetMDInstance | |
31 * | |
32 * -- private accessors -- | |
33 * nssCKFWSlot_GetSlotID | |
34 * nssCKFWSlot_ClearToken | |
35 * | |
36 * -- module fronts -- | |
37 * nssCKFWSlot_GetSlotDescription | |
38 * nssCKFWSlot_GetManufacturerID | |
39 * nssCKFWSlot_GetTokenPresent | |
40 * nssCKFWSlot_GetRemovableDevice | |
41 * nssCKFWSlot_GetHardwareSlot | |
42 * nssCKFWSlot_GetHardwareVersion | |
43 * nssCKFWSlot_GetFirmwareVersion | |
44 * nssCKFWSlot_InitToken | |
45 * nssCKFWSlot_GetToken | |
46 */ | |
47 | |
48 struct NSSCKFWSlotStr { | |
49 NSSCKFWMutex *mutex; | |
50 NSSCKMDSlot *mdSlot; | |
51 NSSCKFWInstance *fwInstance; | |
52 NSSCKMDInstance *mdInstance; | |
53 CK_SLOT_ID slotID; | |
54 | |
55 /* | |
56 * Everything above is set at creation time, and then not modified. | |
57 * The invariants the mutex protects are: | |
58 * | |
59 * 1) Each of the cached descriptions (versions, etc.) are in an | |
60 * internally consistant state. | |
61 * | |
62 * 2) The fwToken points to the token currently in the slot, and | |
63 * it is in a consistant state. | |
64 * | |
65 * Note that the calls accessing the cached descriptions will | |
66 * call the NSSCKMDSlot methods with the mutex locked. Those | |
67 * methods may then call the public NSSCKFWSlot routines. Those | |
68 * public routines only access the constant data above, so there's | |
69 * no problem. But be careful if you add to this object; mutexes | |
70 * are in general not reentrant, so don't create deadlock situations. | |
71 */ | |
72 | |
73 NSSUTF8 *slotDescription; | |
74 NSSUTF8 *manufacturerID; | |
75 CK_VERSION hardwareVersion; | |
76 CK_VERSION firmwareVersion; | |
77 NSSCKFWToken *fwToken; | |
78 }; | |
79 | |
80 #ifdef DEBUG | |
81 /* | |
82 * But first, the pointer-tracking stuff. | |
83 * | |
84 * NOTE: the pointer-tracking support in NSS/base currently relies | |
85 * upon NSPR's CallOnce support. That, however, relies upon NSPR's | |
86 * locking, which is tied into the runtime. We need a pointer-tracker | |
87 * implementation that uses the locks supplied through C_Initialize. | |
88 * That support, however, can be filled in later. So for now, I'll | |
89 * just do this routines as no-ops. | |
90 */ | |
91 | |
92 static CK_RV | |
93 slot_add_pointer | |
94 ( | |
95 const NSSCKFWSlot *fwSlot | |
96 ) | |
97 { | |
98 return CKR_OK; | |
99 } | |
100 | |
101 static CK_RV | |
102 slot_remove_pointer | |
103 ( | |
104 const NSSCKFWSlot *fwSlot | |
105 ) | |
106 { | |
107 return CKR_OK; | |
108 } | |
109 | |
110 NSS_IMPLEMENT CK_RV | |
111 nssCKFWSlot_verifyPointer | |
112 ( | |
113 const NSSCKFWSlot *fwSlot | |
114 ) | |
115 { | |
116 return CKR_OK; | |
117 } | |
118 | |
119 #endif /* DEBUG */ | |
120 | |
121 /* | |
122 * nssCKFWSlot_Create | |
123 * | |
124 */ | |
125 NSS_IMPLEMENT NSSCKFWSlot * | |
126 nssCKFWSlot_Create | |
127 ( | |
128 NSSCKFWInstance *fwInstance, | |
129 NSSCKMDSlot *mdSlot, | |
130 CK_SLOT_ID slotID, | |
131 CK_RV *pError | |
132 ) | |
133 { | |
134 NSSCKFWSlot *fwSlot; | |
135 NSSCKMDInstance *mdInstance; | |
136 NSSArena *arena; | |
137 | |
138 #ifdef NSSDEBUG | |
139 if (!pError) { | |
140 return (NSSCKFWSlot *)NULL; | |
141 } | |
142 | |
143 *pError = nssCKFWInstance_verifyPointer(fwInstance); | |
144 if( CKR_OK != *pError ) { | |
145 return (NSSCKFWSlot *)NULL; | |
146 } | |
147 #endif /* NSSDEBUG */ | |
148 | |
149 mdInstance = nssCKFWInstance_GetMDInstance(fwInstance); | |
150 if (!mdInstance) { | |
151 *pError = CKR_GENERAL_ERROR; | |
152 return (NSSCKFWSlot *)NULL; | |
153 } | |
154 | |
155 arena = nssCKFWInstance_GetArena(fwInstance, pError); | |
156 if (!arena) { | |
157 if( CKR_OK == *pError ) { | |
158 *pError = CKR_GENERAL_ERROR; | |
159 } | |
160 } | |
161 | |
162 fwSlot = nss_ZNEW(arena, NSSCKFWSlot); | |
163 if (!fwSlot) { | |
164 *pError = CKR_HOST_MEMORY; | |
165 return (NSSCKFWSlot *)NULL; | |
166 } | |
167 | |
168 fwSlot->mdSlot = mdSlot; | |
169 fwSlot->fwInstance = fwInstance; | |
170 fwSlot->mdInstance = mdInstance; | |
171 fwSlot->slotID = slotID; | |
172 | |
173 fwSlot->mutex = nssCKFWInstance_CreateMutex(fwInstance, arena, pError); | |
174 if (!fwSlot->mutex) { | |
175 if( CKR_OK == *pError ) { | |
176 *pError = CKR_GENERAL_ERROR; | |
177 } | |
178 (void)nss_ZFreeIf(fwSlot); | |
179 return (NSSCKFWSlot *)NULL; | |
180 } | |
181 | |
182 if (mdSlot->Initialize) { | |
183 *pError = CKR_OK; | |
184 *pError = mdSlot->Initialize(mdSlot, fwSlot, mdInstance, fwInstance); | |
185 if( CKR_OK != *pError ) { | |
186 (void)nssCKFWMutex_Destroy(fwSlot->mutex); | |
187 (void)nss_ZFreeIf(fwSlot); | |
188 return (NSSCKFWSlot *)NULL; | |
189 } | |
190 } | |
191 | |
192 #ifdef DEBUG | |
193 *pError = slot_add_pointer(fwSlot); | |
194 if( CKR_OK != *pError ) { | |
195 if (mdSlot->Destroy) { | |
196 mdSlot->Destroy(mdSlot, fwSlot, mdInstance, fwInstance); | |
197 } | |
198 | |
199 (void)nssCKFWMutex_Destroy(fwSlot->mutex); | |
200 (void)nss_ZFreeIf(fwSlot); | |
201 return (NSSCKFWSlot *)NULL; | |
202 } | |
203 #endif /* DEBUG */ | |
204 | |
205 return fwSlot; | |
206 } | |
207 | |
208 /* | |
209 * nssCKFWSlot_Destroy | |
210 * | |
211 */ | |
212 NSS_IMPLEMENT CK_RV | |
213 nssCKFWSlot_Destroy | |
214 ( | |
215 NSSCKFWSlot *fwSlot | |
216 ) | |
217 { | |
218 CK_RV error = CKR_OK; | |
219 | |
220 #ifdef NSSDEBUG | |
221 error = nssCKFWSlot_verifyPointer(fwSlot); | |
222 if( CKR_OK != error ) { | |
223 return error; | |
224 } | |
225 #endif /* NSSDEBUG */ | |
226 if (fwSlot->fwToken) { | |
227 nssCKFWToken_Destroy(fwSlot->fwToken); | |
228 } | |
229 | |
230 (void)nssCKFWMutex_Destroy(fwSlot->mutex); | |
231 | |
232 if (fwSlot->mdSlot->Destroy) { | |
233 fwSlot->mdSlot->Destroy(fwSlot->mdSlot, fwSlot, | |
234 fwSlot->mdInstance, fwSlot->fwInstance); | |
235 } | |
236 | |
237 #ifdef DEBUG | |
238 error = slot_remove_pointer(fwSlot); | |
239 #endif /* DEBUG */ | |
240 (void)nss_ZFreeIf(fwSlot); | |
241 return error; | |
242 } | |
243 | |
244 /* | |
245 * nssCKFWSlot_GetMDSlot | |
246 * | |
247 */ | |
248 NSS_IMPLEMENT NSSCKMDSlot * | |
249 nssCKFWSlot_GetMDSlot | |
250 ( | |
251 NSSCKFWSlot *fwSlot | |
252 ) | |
253 { | |
254 #ifdef NSSDEBUG | |
255 if( CKR_OK != nssCKFWSlot_verifyPointer(fwSlot) ) { | |
256 return (NSSCKMDSlot *)NULL; | |
257 } | |
258 #endif /* NSSDEBUG */ | |
259 | |
260 return fwSlot->mdSlot; | |
261 } | |
262 | |
263 /* | |
264 * nssCKFWSlot_GetFWInstance | |
265 * | |
266 */ | |
267 | |
268 NSS_IMPLEMENT NSSCKFWInstance * | |
269 nssCKFWSlot_GetFWInstance | |
270 ( | |
271 NSSCKFWSlot *fwSlot | |
272 ) | |
273 { | |
274 #ifdef NSSDEBUG | |
275 if( CKR_OK != nssCKFWSlot_verifyPointer(fwSlot) ) { | |
276 return (NSSCKFWInstance *)NULL; | |
277 } | |
278 #endif /* NSSDEBUG */ | |
279 | |
280 return fwSlot->fwInstance; | |
281 } | |
282 | |
283 /* | |
284 * nssCKFWSlot_GetMDInstance | |
285 * | |
286 */ | |
287 | |
288 NSS_IMPLEMENT NSSCKMDInstance * | |
289 nssCKFWSlot_GetMDInstance | |
290 ( | |
291 NSSCKFWSlot *fwSlot | |
292 ) | |
293 { | |
294 #ifdef NSSDEBUG | |
295 if( CKR_OK != nssCKFWSlot_verifyPointer(fwSlot) ) { | |
296 return (NSSCKMDInstance *)NULL; | |
297 } | |
298 #endif /* NSSDEBUG */ | |
299 | |
300 return fwSlot->mdInstance; | |
301 } | |
302 | |
303 /* | |
304 * nssCKFWSlot_GetSlotID | |
305 * | |
306 */ | |
307 NSS_IMPLEMENT CK_SLOT_ID | |
308 nssCKFWSlot_GetSlotID | |
309 ( | |
310 NSSCKFWSlot *fwSlot | |
311 ) | |
312 { | |
313 #ifdef NSSDEBUG | |
314 if( CKR_OK != nssCKFWSlot_verifyPointer(fwSlot) ) { | |
315 return (CK_SLOT_ID)0; | |
316 } | |
317 #endif /* NSSDEBUG */ | |
318 | |
319 return fwSlot->slotID; | |
320 } | |
321 | |
322 /* | |
323 * nssCKFWSlot_GetSlotDescription | |
324 * | |
325 */ | |
326 NSS_IMPLEMENT CK_RV | |
327 nssCKFWSlot_GetSlotDescription | |
328 ( | |
329 NSSCKFWSlot *fwSlot, | |
330 CK_CHAR slotDescription[64] | |
331 ) | |
332 { | |
333 CK_RV error = CKR_OK; | |
334 | |
335 #ifdef NSSDEBUG | |
336 if( (CK_CHAR_PTR)NULL == slotDescription ) { | |
337 return CKR_ARGUMENTS_BAD; | |
338 } | |
339 | |
340 error = nssCKFWSlot_verifyPointer(fwSlot); | |
341 if( CKR_OK != error ) { | |
342 return error; | |
343 } | |
344 #endif /* NSSDEBUG */ | |
345 | |
346 error = nssCKFWMutex_Lock(fwSlot->mutex); | |
347 if( CKR_OK != error ) { | |
348 return error; | |
349 } | |
350 | |
351 if (!fwSlot->slotDescription) { | |
352 if (fwSlot->mdSlot->GetSlotDescription) { | |
353 fwSlot->slotDescription = fwSlot->mdSlot->GetSlotDescription( | |
354 fwSlot->mdSlot, fwSlot, fwSlot->mdInstance, | |
355 fwSlot->fwInstance, &error); | |
356 if ((!fwSlot->slotDescription) && (CKR_OK != error)) { | |
357 goto done; | |
358 } | |
359 } else { | |
360 fwSlot->slotDescription = (NSSUTF8 *) ""; | |
361 } | |
362 } | |
363 | |
364 (void)nssUTF8_CopyIntoFixedBuffer(fwSlot->slotDescription, (char *)slotDescription, 64, ' '); | |
365 error = CKR_OK; | |
366 | |
367 done: | |
368 (void)nssCKFWMutex_Unlock(fwSlot->mutex); | |
369 return error; | |
370 } | |
371 | |
372 /* | |
373 * nssCKFWSlot_GetManufacturerID | |
374 * | |
375 */ | |
376 NSS_IMPLEMENT CK_RV | |
377 nssCKFWSlot_GetManufacturerID | |
378 ( | |
379 NSSCKFWSlot *fwSlot, | |
380 CK_CHAR manufacturerID[32] | |
381 ) | |
382 { | |
383 CK_RV error = CKR_OK; | |
384 | |
385 #ifdef NSSDEBUG | |
386 if( (CK_CHAR_PTR)NULL == manufacturerID ) { | |
387 return CKR_ARGUMENTS_BAD; | |
388 } | |
389 | |
390 error = nssCKFWSlot_verifyPointer(fwSlot); | |
391 if( CKR_OK != error ) { | |
392 return error; | |
393 } | |
394 #endif /* NSSDEBUG */ | |
395 | |
396 error = nssCKFWMutex_Lock(fwSlot->mutex); | |
397 if( CKR_OK != error ) { | |
398 return error; | |
399 } | |
400 | |
401 if (!fwSlot->manufacturerID) { | |
402 if (fwSlot->mdSlot->GetManufacturerID) { | |
403 fwSlot->manufacturerID = fwSlot->mdSlot->GetManufacturerID( | |
404 fwSlot->mdSlot, fwSlot, fwSlot->mdInstance, | |
405 fwSlot->fwInstance, &error); | |
406 if ((!fwSlot->manufacturerID) && (CKR_OK != error)) { | |
407 goto done; | |
408 } | |
409 } else { | |
410 fwSlot->manufacturerID = (NSSUTF8 *) ""; | |
411 } | |
412 } | |
413 | |
414 (void)nssUTF8_CopyIntoFixedBuffer(fwSlot->manufacturerID, (char *)manufacturerID, 32, ' '); | |
415 error = CKR_OK; | |
416 | |
417 done: | |
418 (void)nssCKFWMutex_Unlock(fwSlot->mutex); | |
419 return error; | |
420 } | |
421 | |
422 /* | |
423 * nssCKFWSlot_GetTokenPresent | |
424 * | |
425 */ | |
426 NSS_IMPLEMENT CK_BBOOL | |
427 nssCKFWSlot_GetTokenPresent | |
428 ( | |
429 NSSCKFWSlot *fwSlot | |
430 ) | |
431 { | |
432 #ifdef NSSDEBUG | |
433 if( CKR_OK != nssCKFWSlot_verifyPointer(fwSlot) ) { | |
434 return CK_FALSE; | |
435 } | |
436 #endif /* NSSDEBUG */ | |
437 | |
438 if (!fwSlot->mdSlot->GetTokenPresent) { | |
439 return CK_TRUE; | |
440 } | |
441 | |
442 return fwSlot->mdSlot->GetTokenPresent(fwSlot->mdSlot, fwSlot, | |
443 fwSlot->mdInstance, fwSlot->fwInstance); | |
444 } | |
445 | |
446 /* | |
447 * nssCKFWSlot_GetRemovableDevice | |
448 * | |
449 */ | |
450 NSS_IMPLEMENT CK_BBOOL | |
451 nssCKFWSlot_GetRemovableDevice | |
452 ( | |
453 NSSCKFWSlot *fwSlot | |
454 ) | |
455 { | |
456 #ifdef NSSDEBUG | |
457 if( CKR_OK != nssCKFWSlot_verifyPointer(fwSlot) ) { | |
458 return CK_FALSE; | |
459 } | |
460 #endif /* NSSDEBUG */ | |
461 | |
462 if (!fwSlot->mdSlot->GetRemovableDevice) { | |
463 return CK_FALSE; | |
464 } | |
465 | |
466 return fwSlot->mdSlot->GetRemovableDevice(fwSlot->mdSlot, fwSlot, | |
467 fwSlot->mdInstance, fwSlot->fwInstance); | |
468 } | |
469 | |
470 /* | |
471 * nssCKFWSlot_GetHardwareSlot | |
472 * | |
473 */ | |
474 NSS_IMPLEMENT CK_BBOOL | |
475 nssCKFWSlot_GetHardwareSlot | |
476 ( | |
477 NSSCKFWSlot *fwSlot | |
478 ) | |
479 { | |
480 #ifdef NSSDEBUG | |
481 if( CKR_OK != nssCKFWSlot_verifyPointer(fwSlot) ) { | |
482 return CK_FALSE; | |
483 } | |
484 #endif /* NSSDEBUG */ | |
485 | |
486 if (!fwSlot->mdSlot->GetHardwareSlot) { | |
487 return CK_FALSE; | |
488 } | |
489 | |
490 return fwSlot->mdSlot->GetHardwareSlot(fwSlot->mdSlot, fwSlot, | |
491 fwSlot->mdInstance, fwSlot->fwInstance); | |
492 } | |
493 | |
494 /* | |
495 * nssCKFWSlot_GetHardwareVersion | |
496 * | |
497 */ | |
498 NSS_IMPLEMENT CK_VERSION | |
499 nssCKFWSlot_GetHardwareVersion | |
500 ( | |
501 NSSCKFWSlot *fwSlot | |
502 ) | |
503 { | |
504 CK_VERSION rv; | |
505 | |
506 #ifdef NSSDEBUG | |
507 if( CKR_OK != nssCKFWSlot_verifyPointer(fwSlot) ) { | |
508 rv.major = rv.minor = 0; | |
509 return rv; | |
510 } | |
511 #endif /* NSSDEBUG */ | |
512 | |
513 if( CKR_OK != nssCKFWMutex_Lock(fwSlot->mutex) ) { | |
514 rv.major = rv.minor = 0; | |
515 return rv; | |
516 } | |
517 | |
518 if( (0 != fwSlot->hardwareVersion.major) || | |
519 (0 != fwSlot->hardwareVersion.minor) ) { | |
520 rv = fwSlot->hardwareVersion; | |
521 goto done; | |
522 } | |
523 | |
524 if (fwSlot->mdSlot->GetHardwareVersion) { | |
525 fwSlot->hardwareVersion = fwSlot->mdSlot->GetHardwareVersion( | |
526 fwSlot->mdSlot, fwSlot, fwSlot->mdInstance, fwSlot->fwInstance); | |
527 } else { | |
528 fwSlot->hardwareVersion.major = 0; | |
529 fwSlot->hardwareVersion.minor = 1; | |
530 } | |
531 | |
532 rv = fwSlot->hardwareVersion; | |
533 done: | |
534 (void)nssCKFWMutex_Unlock(fwSlot->mutex); | |
535 return rv; | |
536 } | |
537 | |
538 /* | |
539 * nssCKFWSlot_GetFirmwareVersion | |
540 * | |
541 */ | |
542 NSS_IMPLEMENT CK_VERSION | |
543 nssCKFWSlot_GetFirmwareVersion | |
544 ( | |
545 NSSCKFWSlot *fwSlot | |
546 ) | |
547 { | |
548 CK_VERSION rv; | |
549 | |
550 #ifdef NSSDEBUG | |
551 if( CKR_OK != nssCKFWSlot_verifyPointer(fwSlot) ) { | |
552 rv.major = rv.minor = 0; | |
553 return rv; | |
554 } | |
555 #endif /* NSSDEBUG */ | |
556 | |
557 if( CKR_OK != nssCKFWMutex_Lock(fwSlot->mutex) ) { | |
558 rv.major = rv.minor = 0; | |
559 return rv; | |
560 } | |
561 | |
562 if( (0 != fwSlot->firmwareVersion.major) || | |
563 (0 != fwSlot->firmwareVersion.minor) ) { | |
564 rv = fwSlot->firmwareVersion; | |
565 goto done; | |
566 } | |
567 | |
568 if (fwSlot->mdSlot->GetFirmwareVersion) { | |
569 fwSlot->firmwareVersion = fwSlot->mdSlot->GetFirmwareVersion( | |
570 fwSlot->mdSlot, fwSlot, fwSlot->mdInstance, fwSlot->fwInstance); | |
571 } else { | |
572 fwSlot->firmwareVersion.major = 0; | |
573 fwSlot->firmwareVersion.minor = 1; | |
574 } | |
575 | |
576 rv = fwSlot->firmwareVersion; | |
577 done: | |
578 (void)nssCKFWMutex_Unlock(fwSlot->mutex); | |
579 return rv; | |
580 } | |
581 | |
582 /* | |
583 * nssCKFWSlot_GetToken | |
584 * | |
585 */ | |
586 NSS_IMPLEMENT NSSCKFWToken * | |
587 nssCKFWSlot_GetToken | |
588 ( | |
589 NSSCKFWSlot *fwSlot, | |
590 CK_RV *pError | |
591 ) | |
592 { | |
593 NSSCKMDToken *mdToken; | |
594 NSSCKFWToken *fwToken; | |
595 | |
596 #ifdef NSSDEBUG | |
597 if (!pError) { | |
598 return (NSSCKFWToken *)NULL; | |
599 } | |
600 | |
601 *pError = nssCKFWSlot_verifyPointer(fwSlot); | |
602 if( CKR_OK != *pError ) { | |
603 return (NSSCKFWToken *)NULL; | |
604 } | |
605 #endif /* NSSDEBUG */ | |
606 | |
607 *pError = nssCKFWMutex_Lock(fwSlot->mutex); | |
608 if( CKR_OK != *pError ) { | |
609 return (NSSCKFWToken *)NULL; | |
610 } | |
611 | |
612 if (!fwSlot->fwToken) { | |
613 if (!fwSlot->mdSlot->GetToken) { | |
614 *pError = CKR_GENERAL_ERROR; | |
615 fwToken = (NSSCKFWToken *)NULL; | |
616 goto done; | |
617 } | |
618 | |
619 mdToken = fwSlot->mdSlot->GetToken(fwSlot->mdSlot, fwSlot, | |
620 fwSlot->mdInstance, fwSlot->fwInstance, pError); | |
621 if (!mdToken) { | |
622 if( CKR_OK == *pError ) { | |
623 *pError = CKR_GENERAL_ERROR; | |
624 } | |
625 return (NSSCKFWToken *)NULL; | |
626 } | |
627 | |
628 fwToken = nssCKFWToken_Create(fwSlot, mdToken, pError); | |
629 fwSlot->fwToken = fwToken; | |
630 } else { | |
631 fwToken = fwSlot->fwToken; | |
632 } | |
633 | |
634 done: | |
635 (void)nssCKFWMutex_Unlock(fwSlot->mutex); | |
636 return fwToken; | |
637 } | |
638 | |
639 /* | |
640 * nssCKFWSlot_ClearToken | |
641 * | |
642 */ | |
643 NSS_IMPLEMENT void | |
644 nssCKFWSlot_ClearToken | |
645 ( | |
646 NSSCKFWSlot *fwSlot | |
647 ) | |
648 { | |
649 #ifdef NSSDEBUG | |
650 if( CKR_OK != nssCKFWSlot_verifyPointer(fwSlot) ) { | |
651 return; | |
652 } | |
653 #endif /* NSSDEBUG */ | |
654 | |
655 if( CKR_OK != nssCKFWMutex_Lock(fwSlot->mutex) ) { | |
656 /* Now what? */ | |
657 return; | |
658 } | |
659 | |
660 fwSlot->fwToken = (NSSCKFWToken *)NULL; | |
661 (void)nssCKFWMutex_Unlock(fwSlot->mutex); | |
662 return; | |
663 } | |
664 | |
665 /* | |
666 * NSSCKFWSlot_GetMDSlot | |
667 * | |
668 */ | |
669 | |
670 NSS_IMPLEMENT NSSCKMDSlot * | |
671 NSSCKFWSlot_GetMDSlot | |
672 ( | |
673 NSSCKFWSlot *fwSlot | |
674 ) | |
675 { | |
676 #ifdef DEBUG | |
677 if( CKR_OK != nssCKFWSlot_verifyPointer(fwSlot) ) { | |
678 return (NSSCKMDSlot *)NULL; | |
679 } | |
680 #endif /* DEBUG */ | |
681 | |
682 return nssCKFWSlot_GetMDSlot(fwSlot); | |
683 } | |
684 | |
685 /* | |
686 * NSSCKFWSlot_GetFWInstance | |
687 * | |
688 */ | |
689 | |
690 NSS_IMPLEMENT NSSCKFWInstance * | |
691 NSSCKFWSlot_GetFWInstance | |
692 ( | |
693 NSSCKFWSlot *fwSlot | |
694 ) | |
695 { | |
696 #ifdef DEBUG | |
697 if( CKR_OK != nssCKFWSlot_verifyPointer(fwSlot) ) { | |
698 return (NSSCKFWInstance *)NULL; | |
699 } | |
700 #endif /* DEBUG */ | |
701 | |
702 return nssCKFWSlot_GetFWInstance(fwSlot); | |
703 } | |
704 | |
705 /* | |
706 * NSSCKFWSlot_GetMDInstance | |
707 * | |
708 */ | |
709 | |
710 NSS_IMPLEMENT NSSCKMDInstance * | |
711 NSSCKFWSlot_GetMDInstance | |
712 ( | |
713 NSSCKFWSlot *fwSlot | |
714 ) | |
715 { | |
716 #ifdef DEBUG | |
717 if( CKR_OK != nssCKFWSlot_verifyPointer(fwSlot) ) { | |
718 return (NSSCKMDInstance *)NULL; | |
719 } | |
720 #endif /* DEBUG */ | |
721 | |
722 return nssCKFWSlot_GetMDInstance(fwSlot); | |
723 } |