Back to index

lightning-sunbird  0.9+nobinonly
instance.c
Go to the documentation of this file.
00001 /* ***** BEGIN LICENSE BLOCK *****
00002  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00003  *
00004  * The contents of this file are subject to the Mozilla Public License Version
00005  * 1.1 (the "License"); you may not use this file except in compliance with
00006  * the License. You may obtain a copy of the License at
00007  * http://www.mozilla.org/MPL/
00008  *
00009  * Software distributed under the License is distributed on an "AS IS" basis,
00010  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00011  * for the specific language governing rights and limitations under the
00012  * License.
00013  *
00014  * The Original Code is the Netscape security libraries.
00015  *
00016  * The Initial Developer of the Original Code is
00017  * Netscape Communications Corporation.
00018  * Portions created by the Initial Developer are Copyright (C) 1994-2000
00019  * the Initial Developer. All Rights Reserved.
00020  *
00021  * Contributor(s):
00022  *
00023  * Alternatively, the contents of this file may be used under the terms of
00024  * either the GNU General Public License Version 2 or later (the "GPL"), or
00025  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00026  * in which case the provisions of the GPL or the LGPL are applicable instead
00027  * of those above. If you wish to allow use of your version of this file only
00028  * under the terms of either the GPL or the LGPL, and not to allow others to
00029  * use your version of this file under the terms of the MPL, indicate your
00030  * decision by deleting the provisions above and replace them with the notice
00031  * and other provisions required by the GPL or the LGPL. If you do not delete
00032  * the provisions above, a recipient may use your version of this file under
00033  * the terms of any one of the MPL, the GPL or the LGPL.
00034  *
00035  * ***** END LICENSE BLOCK ***** */
00036 
00037 #ifdef DEBUG
00038 static const char CVS_ID[] = "@(#) $RCSfile: instance.c,v $ $Revision: 1.10 $ $Date: 2005/01/20 02:25:45 $";
00039 #endif /* DEBUG */
00040 
00041 /*
00042  * instance.c
00043  *
00044  * This file implements the NSSCKFWInstance type and methods.
00045  */
00046 
00047 #ifndef CK_T
00048 #include "ck.h"
00049 #endif /* CK_T */
00050 
00051 /*
00052  * NSSCKFWInstance
00053  *
00054  *  -- create/destroy --
00055  *  nssCKFWInstance_Create
00056  *  nssCKFWInstance_Destroy
00057  *
00058  *  -- public accessors --
00059  *  NSSCKFWInstance_GetMDInstance
00060  *  NSSCKFWInstance_GetArena
00061  *  NSSCKFWInstance_MayCreatePthreads
00062  *  NSSCKFWInstance_CreateMutex
00063  *  NSSCKFWInstance_GetConfigurationData
00064  *  NSSCKFWInstance_GetInitArgs
00065  *
00066  *  -- implement public accessors --
00067  *  nssCKFWInstance_GetMDInstance
00068  *  nssCKFWInstance_GetArena
00069  *  nssCKFWInstance_MayCreatePthreads
00070  *  nssCKFWInstance_CreateMutex
00071  *  nssCKFWInstance_GetConfigurationData
00072  *  nssCKFWInstance_GetInitArgs 
00073  *
00074  *  -- private accessors --
00075  *  nssCKFWInstance_CreateSessionHandle
00076  *  nssCKFWInstance_ResolveSessionHandle
00077  *  nssCKFWInstance_DestroySessionHandle
00078  *  nssCKFWInstance_FindSessionHandle
00079  *  nssCKFWInstance_CreateObjectHandle
00080  *  nssCKFWInstance_ResolveObjectHandle
00081  *  nssCKFWInstance_DestroyObjectHandle
00082  *
00083  *  -- module fronts --
00084  *  nssCKFWInstance_GetNSlots
00085  *  nssCKFWInstance_GetCryptokiVersion
00086  *  nssCKFWInstance_GetManufacturerID
00087  *  nssCKFWInstance_GetFlags
00088  *  nssCKFWInstance_GetLibraryDescription
00089  *  nssCKFWInstance_GetLibraryVersion
00090  *  nssCKFWInstance_GetModuleHandlesSessionObjects
00091  *  nssCKFWInstance_GetSlots
00092  *  nssCKFWInstance_WaitForSlotEvent
00093  *
00094  *  -- debugging versions only --
00095  *  nssCKFWInstance_verifyPointer
00096  */
00097 
00098 struct NSSCKFWInstanceStr {
00099   NSSCKFWMutex *mutex;
00100   NSSArena *arena;
00101   NSSCKMDInstance *mdInstance;
00102   CK_C_INITIALIZE_ARGS_PTR pInitArgs;
00103   CK_C_INITIALIZE_ARGS initArgs;
00104   CryptokiLockingState LockingState;
00105   CK_BBOOL mayCreatePthreads;
00106   NSSUTF8 *configurationData;
00107   CK_ULONG nSlots;
00108   NSSCKFWSlot **fwSlotList;
00109   NSSCKMDSlot **mdSlotList;
00110   CK_BBOOL moduleHandlesSessionObjects;
00111 
00112   /*
00113    * Everything above is set at creation time, and then not modified.
00114    * The invariants the mutex protects are:
00115    *
00116    *  1) Each of the cached descriptions (versions, etc.) are in an
00117    *     internally consistant state.
00118    *
00119    *  2) The session handle hashes and count are consistant
00120    *
00121    *  3) The object handle hashes and count are consistant.
00122    *
00123    * I could use multiple locks, but let's wait to see if that's 
00124    * really necessary.
00125    *
00126    * Note that the calls accessing the cached descriptions will 
00127    * call the NSSCKMDInstance methods with the mutex locked.  Those
00128    * methods may then call the public NSSCKFWInstance routines.
00129    * Those public routines only access the constant data above, so
00130    * there's no problem.  But be careful if you add to this object;
00131    * mutexes are in general not reentrant, so don't create deadlock
00132    * situations.
00133    */
00134 
00135   CK_VERSION cryptokiVersion;
00136   NSSUTF8 *manufacturerID;
00137   NSSUTF8 *libraryDescription;
00138   CK_VERSION libraryVersion;
00139 
00140   CK_ULONG lastSessionHandle;
00141   nssCKFWHash *sessionHandleHash;
00142 
00143   CK_ULONG lastObjectHandle;
00144   nssCKFWHash *objectHandleHash;
00145 };
00146 
00147 #ifdef DEBUG
00148 /*
00149  * But first, the pointer-tracking stuff.
00150  *
00151  * NOTE: the pointer-tracking support in NSS/base currently relies
00152  * upon NSPR's CallOnce support.  That, however, relies upon NSPR's
00153  * locking, which is tied into the runtime.  We need a pointer-tracker
00154  * implementation that uses the locks supplied through C_Initialize.
00155  * That support, however, can be filled in later.  So for now, I'll
00156  * just do this routines as no-ops.
00157  */
00158 
00159 static CK_RV
00160 instance_add_pointer
00161 (
00162   const NSSCKFWInstance *fwInstance
00163 )
00164 {
00165   return CKR_OK;
00166 }
00167 
00168 static CK_RV
00169 instance_remove_pointer
00170 (
00171   const NSSCKFWInstance *fwInstance
00172 )
00173 {
00174   return CKR_OK;
00175 }
00176 
00177 NSS_IMPLEMENT CK_RV
00178 nssCKFWInstance_verifyPointer
00179 (
00180   const NSSCKFWInstance *fwInstance
00181 )
00182 {
00183   return CKR_OK;
00184 }
00185 
00186 #endif /* DEBUG */
00187 
00188 /*
00189  * nssCKFWInstance_Create
00190  *
00191  */
00192 NSS_IMPLEMENT NSSCKFWInstance *
00193 nssCKFWInstance_Create
00194 (
00195   CK_C_INITIALIZE_ARGS_PTR pInitArgs,
00196   CryptokiLockingState LockingState,
00197   NSSCKMDInstance *mdInstance,
00198   CK_RV *pError
00199 )
00200 {
00201   NSSCKFWInstance *fwInstance;
00202   NSSArena *arena = (NSSArena *)NULL;
00203   CK_ULONG i;
00204   CK_BBOOL called_Initialize = CK_FALSE;
00205 
00206 #ifdef NSSDEBUG
00207   if( (CK_RV)NULL == pError ) {
00208     return (NSSCKFWInstance *)NULL;
00209   }
00210 
00211   if( (NSSCKMDInstance *)NULL == mdInstance ) {
00212     *pError = CKR_ARGUMENTS_BAD;
00213     return (NSSCKFWInstance *)NULL;
00214   }
00215 #endif /* NSSDEBUG */
00216 
00217   arena = NSSArena_Create();
00218   if( (NSSArena *)NULL == arena ) {
00219     *pError = CKR_HOST_MEMORY;
00220     return (NSSCKFWInstance *)NULL;
00221   }
00222 
00223   fwInstance = nss_ZNEW(arena, NSSCKFWInstance);
00224   if( (NSSCKFWInstance *)NULL == fwInstance ) {
00225     goto nomem;
00226   }
00227 
00228   fwInstance->arena = arena;
00229   fwInstance->mdInstance = mdInstance;
00230 
00231   fwInstance->LockingState = LockingState;
00232   if( (CK_C_INITIALIZE_ARGS_PTR)NULL != pInitArgs ) {
00233     fwInstance->initArgs = *pInitArgs;
00234     fwInstance->pInitArgs = &fwInstance->initArgs;
00235     if( pInitArgs->flags & CKF_LIBRARY_CANT_CREATE_OS_THREADS ) {
00236       fwInstance->mayCreatePthreads = CK_FALSE;
00237     } else {
00238       fwInstance->mayCreatePthreads = CK_TRUE;
00239     }
00240     fwInstance->configurationData = (NSSUTF8 *)(pInitArgs->pReserved);
00241   } else {
00242     fwInstance->mayCreatePthreads = CK_TRUE;
00243   }
00244 
00245   fwInstance->mutex = nssCKFWMutex_Create(pInitArgs, LockingState, arena,
00246                                           pError);
00247   if( (NSSCKFWMutex *)NULL == fwInstance->mutex ) {
00248     if( CKR_OK == *pError ) {
00249       *pError = CKR_GENERAL_ERROR;
00250     }
00251     goto loser;
00252   }
00253 
00254   if( (void *)NULL != (void *)mdInstance->Initialize ) {
00255     *pError = mdInstance->Initialize(mdInstance, fwInstance, fwInstance->configurationData);
00256     if( CKR_OK != *pError ) {
00257       goto loser;
00258     }
00259 
00260     called_Initialize = CK_TRUE;
00261   }
00262 
00263   if( (void *)NULL != (void *)mdInstance->ModuleHandlesSessionObjects ) {
00264     fwInstance->moduleHandlesSessionObjects = 
00265       mdInstance->ModuleHandlesSessionObjects(mdInstance, fwInstance);
00266   } else {
00267     fwInstance->moduleHandlesSessionObjects = CK_FALSE;
00268   }
00269 
00270   if( (void *)NULL == (void *)mdInstance->GetNSlots ) {
00271     /* That routine is required */
00272     *pError = CKR_GENERAL_ERROR;
00273     goto loser;
00274   }
00275 
00276   fwInstance->nSlots = mdInstance->GetNSlots(mdInstance, fwInstance, pError);
00277   if( (CK_ULONG)0 == fwInstance->nSlots ) {
00278     if( CKR_OK == *pError ) {
00279       /* Zero is not a legitimate answer */
00280       *pError = CKR_GENERAL_ERROR;
00281     }
00282     goto loser;
00283   }
00284 
00285   fwInstance->fwSlotList = nss_ZNEWARRAY(arena, NSSCKFWSlot *, fwInstance->nSlots);
00286   if( (NSSCKFWSlot **)NULL == fwInstance->fwSlotList ) {
00287     goto nomem;
00288   }
00289 
00290   fwInstance->mdSlotList = nss_ZNEWARRAY(arena, NSSCKMDSlot *, fwInstance->nSlots);
00291   if( (NSSCKMDSlot **)NULL == fwInstance->mdSlotList ) {
00292     goto nomem;
00293   }
00294 
00295   fwInstance->sessionHandleHash = nssCKFWHash_Create(fwInstance, 
00296     fwInstance->arena, pError);
00297   if( (nssCKFWHash *)NULL == fwInstance->sessionHandleHash ) {
00298     goto loser;
00299   }
00300 
00301   fwInstance->objectHandleHash = nssCKFWHash_Create(fwInstance,
00302     fwInstance->arena, pError);
00303   if( (nssCKFWHash *)NULL == fwInstance->objectHandleHash ) {
00304     goto loser;
00305   }
00306 
00307   if( (void *)NULL == (void *)mdInstance->GetSlots ) {
00308     /* That routine is required */
00309     *pError = CKR_GENERAL_ERROR;
00310     goto loser;
00311   }
00312 
00313   *pError = mdInstance->GetSlots(mdInstance, fwInstance, fwInstance->mdSlotList);
00314   if( CKR_OK != *pError ) {
00315     goto loser;
00316   }
00317 
00318   for( i = 0; i < fwInstance->nSlots; i++ ) {
00319     NSSCKMDSlot *mdSlot = fwInstance->mdSlotList[i];
00320 
00321     if( (NSSCKMDSlot *)NULL == mdSlot ) {
00322       *pError = CKR_GENERAL_ERROR;
00323       goto loser;
00324     }
00325 
00326     fwInstance->fwSlotList[i] = nssCKFWSlot_Create(fwInstance, mdSlot, i, pError);
00327     if( CKR_OK != *pError ) {
00328       CK_ULONG j;
00329 
00330       for( j = 0; j < i; j++ ) {
00331         (void)nssCKFWSlot_Destroy(fwInstance->fwSlotList[j]);
00332       }
00333 
00334       for( j = i; j < fwInstance->nSlots; j++ ) {
00335         NSSCKMDSlot *mds = fwInstance->mdSlotList[j];
00336         if( (void *)NULL != (void *)mds->Destroy ) {
00337           mds->Destroy(mds, (NSSCKFWSlot *)NULL, mdInstance, fwInstance);
00338         }
00339       }
00340 
00341       goto loser;
00342     }
00343   }
00344 
00345 #ifdef DEBUG
00346   *pError = instance_add_pointer(fwInstance);
00347   if( CKR_OK != *pError ) {
00348     for( i = 0; i < fwInstance->nSlots; i++ ) {
00349       (void)nssCKFWSlot_Destroy(fwInstance->fwSlotList[i]);
00350     }
00351     
00352     goto loser;
00353   }
00354 #endif /* DEBUG */
00355 
00356   *pError = CKR_OK;
00357   return fwInstance;
00358 
00359  nomem:
00360   *pError = CKR_HOST_MEMORY;
00361   /*FALLTHROUGH*/
00362  loser:
00363 
00364   if( CK_TRUE == called_Initialize ) {
00365     if( (void *)NULL != (void *)mdInstance->Finalize ) {
00366       mdInstance->Finalize(mdInstance, fwInstance);
00367     }
00368   }
00369 
00370   if (arena) {
00371     (void)NSSArena_Destroy(arena);
00372   }
00373   return (NSSCKFWInstance *)NULL;
00374 }
00375 
00376 /*
00377  * nssCKFWInstance_Destroy
00378  *
00379  */
00380 NSS_IMPLEMENT CK_RV
00381 nssCKFWInstance_Destroy
00382 (
00383   NSSCKFWInstance *fwInstance
00384 )
00385 {
00386 #ifdef NSSDEBUG
00387   CK_RV error = CKR_OK;
00388 #endif /* NSSDEBUG */
00389   CK_ULONG i;
00390 
00391 #ifdef NSSDEBUG
00392   error = nssCKFWInstance_verifyPointer(fwInstance);
00393   if( CKR_OK != error ) {
00394     return error;
00395   }
00396 #endif /* NSSDEBUG */
00397 
00398   nssCKFWMutex_Destroy(fwInstance->mutex);
00399 
00400   for( i = 0; i < fwInstance->nSlots; i++ ) {
00401     (void)nssCKFWSlot_Destroy(fwInstance->fwSlotList[i]);
00402   }
00403 
00404   if( (void *)NULL != (void *)fwInstance->mdInstance->Finalize ) {
00405     fwInstance->mdInstance->Finalize(fwInstance->mdInstance, fwInstance);
00406   }
00407 
00408   if (fwInstance->sessionHandleHash) {
00409      nssCKFWHash_Destroy(fwInstance->sessionHandleHash);
00410   }
00411 
00412   if (fwInstance->objectHandleHash) {
00413      nssCKFWHash_Destroy(fwInstance->objectHandleHash);
00414   }
00415 
00416 #ifdef DEBUG
00417   (void)instance_remove_pointer(fwInstance);
00418 #endif /* DEBUG */
00419 
00420   (void)NSSArena_Destroy(fwInstance->arena);
00421   return CKR_OK;
00422 }
00423 
00424 /*
00425  * nssCKFWInstance_GetMDInstance
00426  *
00427  */
00428 NSS_IMPLEMENT NSSCKMDInstance *
00429 nssCKFWInstance_GetMDInstance
00430 (
00431   NSSCKFWInstance *fwInstance
00432 )
00433 {
00434 #ifdef NSSDEBUG
00435   if( CKR_OK != nssCKFWInstance_verifyPointer(fwInstance) ) {
00436     return (NSSCKMDInstance *)NULL;
00437   }
00438 #endif /* NSSDEBUG */
00439 
00440   return fwInstance->mdInstance;
00441 }
00442 
00443 /*
00444  * nssCKFWInstance_GetArena
00445  *
00446  */
00447 NSS_IMPLEMENT NSSArena *
00448 nssCKFWInstance_GetArena
00449 (
00450   NSSCKFWInstance *fwInstance,
00451   CK_RV *pError
00452 )
00453 {
00454 #ifdef NSSDEBUG
00455   if( (CK_RV *)NULL == pError ) {
00456     return (NSSArena *)NULL;
00457   }
00458 
00459   *pError = nssCKFWInstance_verifyPointer(fwInstance);
00460   if( CKR_OK != *pError ) {
00461     return (NSSArena *)NULL;
00462   }
00463 #endif /* NSSDEBUG */
00464 
00465   *pError = CKR_OK;
00466   return fwInstance->arena;
00467 }
00468 
00469 /*
00470  * nssCKFWInstance_MayCreatePthreads
00471  *
00472  */
00473 NSS_IMPLEMENT CK_BBOOL
00474 nssCKFWInstance_MayCreatePthreads
00475 (
00476   NSSCKFWInstance *fwInstance
00477 )
00478 {
00479 #ifdef NSSDEBUG
00480   if( CKR_OK != nssCKFWInstance_verifyPointer(fwInstance) ) {
00481     return CK_FALSE;
00482   }
00483 #endif /* NSSDEBUG */
00484 
00485   return fwInstance->mayCreatePthreads;
00486 }
00487 
00488 /*
00489  * nssCKFWInstance_CreateMutex
00490  *
00491  */
00492 NSS_IMPLEMENT NSSCKFWMutex *
00493 nssCKFWInstance_CreateMutex
00494 (
00495   NSSCKFWInstance *fwInstance,
00496   NSSArena *arena,
00497   CK_RV *pError
00498 )
00499 {
00500   NSSCKFWMutex *mutex;
00501 
00502 #ifdef NSSDEBUG
00503   if( (CK_RV *)NULL == pError ) {
00504     return (NSSCKFWMutex *)NULL;
00505   }
00506 
00507   *pError = nssCKFWInstance_verifyPointer(fwInstance);
00508   if( CKR_OK != *pError ) {
00509     return (NSSCKFWMutex *)NULL;
00510   }
00511 #endif /* NSSDEBUG */
00512 
00513   mutex = nssCKFWMutex_Create(fwInstance->pInitArgs, fwInstance->LockingState,
00514                               arena, pError);
00515   if( (NSSCKFWMutex *)NULL == mutex ) {
00516     if( CKR_OK == *pError ) {
00517       *pError = CKR_GENERAL_ERROR;
00518     }
00519 
00520     return (NSSCKFWMutex *)NULL;
00521   }
00522 
00523   return mutex;
00524 }
00525 
00526 /*
00527  * nssCKFWInstance_GetConfigurationData
00528  *
00529  */
00530 NSS_IMPLEMENT NSSUTF8 *
00531 nssCKFWInstance_GetConfigurationData
00532 (
00533   NSSCKFWInstance *fwInstance
00534 )
00535 {
00536 #ifdef NSSDEBUG
00537   if( CKR_OK != nssCKFWInstance_verifyPointer(fwInstance) ) {
00538     return (NSSUTF8 *)NULL;
00539   }
00540 #endif /* NSSDEBUG */
00541 
00542   return fwInstance->configurationData;
00543 }
00544 
00545 /*
00546  * nssCKFWInstance_GetInitArgs
00547  *
00548  */
00549 CK_C_INITIALIZE_ARGS_PTR
00550 nssCKFWInstance_GetInitArgs
00551 (
00552   NSSCKFWInstance *fwInstance
00553 )
00554 {
00555 #ifdef NSSDEBUG
00556   if( CKR_OK != nssCKFWInstance_verifyPointer(fwInstance) ) {
00557     return (CK_C_INITIALIZE_ARGS_PTR)NULL;
00558   }
00559 #endif /* NSSDEBUG */
00560 
00561     return fwInstance->pInitArgs;
00562 }
00563 
00564 /*
00565  * nssCKFWInstance_CreateSessionHandle
00566  *
00567  */
00568 NSS_IMPLEMENT CK_SESSION_HANDLE
00569 nssCKFWInstance_CreateSessionHandle
00570 (
00571   NSSCKFWInstance *fwInstance,
00572   NSSCKFWSession *fwSession,
00573   CK_RV *pError
00574 )
00575 {
00576   CK_SESSION_HANDLE hSession;
00577 
00578 #ifdef NSSDEBUG
00579   if( (CK_RV *)NULL == pError ) {
00580     return (CK_SESSION_HANDLE)0;
00581   }
00582 
00583   *pError = nssCKFWInstance_verifyPointer(fwInstance);
00584   if( CKR_OK != *pError ) {
00585     return (CK_SESSION_HANDLE)0;
00586   }
00587 #endif /* NSSDEBUG */
00588 
00589   *pError = nssCKFWMutex_Lock(fwInstance->mutex);
00590   if( CKR_OK != *pError ) {
00591     return (CK_SESSION_HANDLE)0;
00592   }
00593 
00594   hSession = ++(fwInstance->lastSessionHandle);
00595 
00596   /* Alan would say I should unlock for this call. */
00597   
00598   *pError = nssCKFWSession_SetHandle(fwSession, hSession);
00599   if( CKR_OK != *pError ) {
00600     goto done;
00601   }
00602 
00603   *pError = nssCKFWHash_Add(fwInstance->sessionHandleHash, 
00604               (const void *)hSession, (const void *)fwSession);
00605   if( CKR_OK != *pError ) {
00606     hSession = (CK_SESSION_HANDLE)0;
00607     goto done;
00608   }
00609 
00610  done:
00611   nssCKFWMutex_Unlock(fwInstance->mutex);
00612   return hSession;
00613 }
00614 
00615 /*
00616  * nssCKFWInstance_ResolveSessionHandle
00617  *
00618  */
00619 NSS_IMPLEMENT NSSCKFWSession *
00620 nssCKFWInstance_ResolveSessionHandle
00621 (
00622   NSSCKFWInstance *fwInstance,
00623   CK_SESSION_HANDLE hSession
00624 )
00625 {
00626   NSSCKFWSession *fwSession;
00627 
00628 #ifdef NSSDEBUG
00629   if( CKR_OK != nssCKFWInstance_verifyPointer(fwInstance) ) {
00630     return (NSSCKFWSession *)NULL;
00631   }
00632 #endif /* NSSDEBUG */
00633 
00634   if( CKR_OK != nssCKFWMutex_Lock(fwInstance->mutex) ) {
00635     return (NSSCKFWSession *)NULL;
00636   }
00637 
00638   fwSession = (NSSCKFWSession *)nssCKFWHash_Lookup(
00639                 fwInstance->sessionHandleHash, (const void *)hSession);
00640 
00641   /* Assert(hSession == nssCKFWSession_GetHandle(fwSession)) */
00642 
00643   (void)nssCKFWMutex_Unlock(fwInstance->mutex);
00644 
00645   return fwSession;
00646 }
00647 
00648 /*
00649  * nssCKFWInstance_DestroySessionHandle
00650  *
00651  */
00652 NSS_IMPLEMENT void
00653 nssCKFWInstance_DestroySessionHandle
00654 (
00655   NSSCKFWInstance *fwInstance,
00656   CK_SESSION_HANDLE hSession
00657 )
00658 {
00659   NSSCKFWSession *fwSession;
00660 
00661 #ifdef NSSDEBUG
00662   if( CKR_OK != nssCKFWInstance_verifyPointer(fwInstance) ) {
00663     return;
00664   }
00665 #endif /* NSSDEBUG */
00666 
00667   if( CKR_OK != nssCKFWMutex_Lock(fwInstance->mutex) ) {
00668     return;
00669   }
00670 
00671   fwSession = (NSSCKFWSession *)nssCKFWHash_Lookup(
00672                 fwInstance->sessionHandleHash, (const void *)hSession);
00673 
00674   nssCKFWHash_Remove(fwInstance->sessionHandleHash, (const void *)hSession);
00675   nssCKFWSession_SetHandle(fwSession, (CK_SESSION_HANDLE)0);
00676 
00677   (void)nssCKFWMutex_Unlock(fwInstance->mutex);
00678 
00679   return;
00680 }
00681 
00682 /*
00683  * nssCKFWInstance_FindSessionHandle
00684  *
00685  */
00686 NSS_IMPLEMENT CK_SESSION_HANDLE
00687 nssCKFWInstance_FindSessionHandle
00688 (
00689   NSSCKFWInstance *fwInstance,
00690   NSSCKFWSession *fwSession
00691 )
00692 {
00693 #ifdef NSSDEBUG
00694   if( CKR_OK != nssCKFWInstance_verifyPointer(fwInstance) ) {
00695     return (CK_SESSION_HANDLE)0;
00696   }
00697 
00698   if( CKR_OK != nssCKFWSession_verifyPointer(fwSession) ) {
00699     return (CK_SESSION_HANDLE)0;
00700   }
00701 #endif /* NSSDEBUG */
00702 
00703   return nssCKFWSession_GetHandle(fwSession);
00704   /* look it up and assert? */
00705 }
00706 
00707 /*
00708  * nssCKFWInstance_CreateObjectHandle
00709  *
00710  */
00711 NSS_IMPLEMENT CK_OBJECT_HANDLE
00712 nssCKFWInstance_CreateObjectHandle
00713 (
00714   NSSCKFWInstance *fwInstance,
00715   NSSCKFWObject *fwObject,
00716   CK_RV *pError
00717 )
00718 {
00719   CK_OBJECT_HANDLE hObject;
00720 
00721 #ifdef NSSDEBUG
00722   if( (CK_RV *)NULL == pError ) {
00723     return (CK_OBJECT_HANDLE)0;
00724   }
00725 
00726   *pError = nssCKFWInstance_verifyPointer(fwInstance);
00727   if( CKR_OK != *pError ) {
00728     return (CK_OBJECT_HANDLE)0;
00729   }
00730 #endif /* NSSDEBUG */
00731 
00732   *pError = nssCKFWMutex_Lock(fwInstance->mutex);
00733   if( CKR_OK != *pError ) {
00734     return (CK_OBJECT_HANDLE)0;
00735   }
00736 
00737   hObject = ++(fwInstance->lastObjectHandle);
00738 
00739   *pError = nssCKFWObject_SetHandle(fwObject, hObject);
00740   if( CKR_OK != *pError ) {
00741     hObject = (CK_OBJECT_HANDLE)0;
00742     goto done;
00743   }
00744 
00745   *pError = nssCKFWHash_Add(fwInstance->objectHandleHash, 
00746               (const void *)hObject, (const void *)fwObject);
00747   if( CKR_OK != *pError ) {
00748     hObject = (CK_OBJECT_HANDLE)0;
00749     goto done;
00750   }
00751 
00752  done:
00753   (void)nssCKFWMutex_Unlock(fwInstance->mutex);
00754   return hObject;
00755 }
00756 
00757 /*
00758  * nssCKFWInstance_ResolveObjectHandle
00759  *
00760  */
00761 NSS_IMPLEMENT NSSCKFWObject *
00762 nssCKFWInstance_ResolveObjectHandle
00763 (
00764   NSSCKFWInstance *fwInstance,
00765   CK_OBJECT_HANDLE hObject
00766 )
00767 {
00768   NSSCKFWObject *fwObject;
00769 
00770 #ifdef NSSDEBUG
00771   if( CKR_OK != nssCKFWInstance_verifyPointer(fwInstance) ) {
00772     return (NSSCKFWObject *)NULL;
00773   }
00774 #endif /* NSSDEBUG */
00775 
00776   if( CKR_OK != nssCKFWMutex_Lock(fwInstance->mutex) ) {
00777     return (NSSCKFWObject *)NULL;
00778   }
00779 
00780   fwObject = (NSSCKFWObject *)nssCKFWHash_Lookup(
00781                 fwInstance->objectHandleHash, (const void *)hObject);
00782 
00783   /* Assert(hObject == nssCKFWObject_GetHandle(fwObject)) */
00784 
00785   (void)nssCKFWMutex_Unlock(fwInstance->mutex);
00786   return fwObject;
00787 }
00788 
00789 /*
00790  * nssCKFWInstance_ReassignObjectHandle
00791  *
00792  */
00793 NSS_IMPLEMENT CK_RV
00794 nssCKFWInstance_ReassignObjectHandle
00795 (
00796   NSSCKFWInstance *fwInstance,
00797   CK_OBJECT_HANDLE hObject,
00798   NSSCKFWObject *fwObject
00799 )
00800 {
00801   CK_RV error = CKR_OK;
00802   NSSCKFWObject *oldObject;
00803 
00804 #ifdef NSSDEBUG
00805   error = nssCKFWInstance_verifyPointer(fwInstance);
00806   if( CKR_OK != error ) {
00807     return error;
00808   }
00809 #endif /* NSSDEBUG */
00810 
00811   error = nssCKFWMutex_Lock(fwInstance->mutex);
00812   if( CKR_OK != error ) {
00813     return error;
00814   }
00815 
00816   oldObject = (NSSCKFWObject *)nssCKFWHash_Lookup(
00817                  fwInstance->objectHandleHash, (const void *)hObject);
00818   /* Assert(hObject == nssCKFWObject_GetHandle(oldObject) */
00819   (void)nssCKFWObject_SetHandle(oldObject, (CK_SESSION_HANDLE)0);
00820   nssCKFWHash_Remove(fwInstance->objectHandleHash, (const void *)hObject);
00821 
00822   error = nssCKFWObject_SetHandle(fwObject, hObject);
00823   if( CKR_OK != error ) {
00824     goto done;
00825   }
00826   error = nssCKFWHash_Add(fwInstance->objectHandleHash, 
00827             (const void *)hObject, (const void *)fwObject);
00828 
00829  done:
00830   (void)nssCKFWMutex_Unlock(fwInstance->mutex);
00831   return error;
00832 }
00833 
00834 /*
00835  * nssCKFWInstance_DestroyObjectHandle
00836  *
00837  */
00838 NSS_IMPLEMENT void
00839 nssCKFWInstance_DestroyObjectHandle
00840 (
00841   NSSCKFWInstance *fwInstance,
00842   CK_OBJECT_HANDLE hObject
00843 )
00844 {
00845   NSSCKFWObject *fwObject;
00846 
00847 #ifdef NSSDEBUG
00848   if( CKR_OK != nssCKFWInstance_verifyPointer(fwInstance) ) {
00849     return;
00850   }
00851 #endif /* NSSDEBUG */
00852 
00853   if( CKR_OK != nssCKFWMutex_Lock(fwInstance->mutex) ) {
00854     return;
00855   }
00856 
00857   fwObject = (NSSCKFWObject *)nssCKFWHash_Lookup(
00858                 fwInstance->objectHandleHash, (const void *)hObject);
00859   /* Assert(hObject = nssCKFWObject_GetHandle(fwObject)) */
00860   nssCKFWHash_Remove(fwInstance->objectHandleHash, (const void *)hObject);
00861   (void)nssCKFWObject_SetHandle(fwObject, (CK_SESSION_HANDLE)0);
00862 
00863   (void)nssCKFWMutex_Unlock(fwInstance->mutex);
00864   return;
00865 }
00866 
00867 /*
00868  * nssCKFWInstance_FindObjectHandle
00869  *
00870  */
00871 NSS_IMPLEMENT CK_OBJECT_HANDLE
00872 nssCKFWInstance_FindObjectHandle
00873 (
00874   NSSCKFWInstance *fwInstance,
00875   NSSCKFWObject *fwObject
00876 )
00877 {
00878 #ifdef NSSDEBUG
00879   if( CKR_OK != nssCKFWInstance_verifyPointer(fwInstance) ) {
00880     return (CK_OBJECT_HANDLE)0;
00881   }
00882 
00883   if( CKR_OK != nssCKFWObject_verifyPointer(fwObject) ) {
00884     return (CK_OBJECT_HANDLE)0;
00885   }
00886 #endif /* NSSDEBUG */
00887   
00888   return nssCKFWObject_GetHandle(fwObject);
00889 }
00890 
00891 /*
00892  * nssCKFWInstance_GetNSlots
00893  *
00894  */
00895 NSS_IMPLEMENT CK_ULONG
00896 nssCKFWInstance_GetNSlots
00897 (
00898   NSSCKFWInstance *fwInstance,
00899   CK_RV *pError
00900 )
00901 {
00902 #ifdef NSSDEBUG
00903   if( (CK_RV *)NULL == pError ) {
00904     return (CK_ULONG)0;
00905   }
00906 
00907   *pError = nssCKFWInstance_verifyPointer(fwInstance);
00908   if( CKR_OK != *pError ) {
00909     return (CK_ULONG)0;
00910   }
00911 #endif /* NSSDEBUG */
00912 
00913   *pError = CKR_OK;
00914   return fwInstance->nSlots;
00915 }  
00916 
00917 /*
00918  * nssCKFWInstance_GetCryptokiVersion
00919  *
00920  */
00921 NSS_IMPLEMENT CK_VERSION
00922 nssCKFWInstance_GetCryptokiVersion
00923 (
00924   NSSCKFWInstance *fwInstance
00925 )
00926 {
00927   CK_VERSION rv;
00928 
00929 #ifdef NSSDEBUG
00930   if( CKR_OK != nssCKFWInstance_verifyPointer(fwInstance) ) {
00931     rv.major = rv.minor = 0;
00932     return rv;
00933   }
00934 #endif /* NSSDEBUG */
00935 
00936   if( CKR_OK != nssCKFWMutex_Lock(fwInstance->mutex) ) {
00937     rv.major = rv.minor = 0;
00938     return rv;
00939   }
00940 
00941   if( (0 != fwInstance->cryptokiVersion.major) ||
00942       (0 != fwInstance->cryptokiVersion.minor) ) {
00943     rv = fwInstance->cryptokiVersion;
00944     goto done;
00945   }
00946 
00947   if( (void *)NULL != (void *)fwInstance->mdInstance->GetCryptokiVersion ) {
00948     fwInstance->cryptokiVersion = fwInstance->mdInstance->GetCryptokiVersion(
00949       fwInstance->mdInstance, fwInstance);
00950   } else {
00951     fwInstance->cryptokiVersion.major = 2;
00952     fwInstance->cryptokiVersion.minor = 1;
00953   }
00954 
00955   rv = fwInstance->cryptokiVersion;
00956 
00957  done:
00958   (void)nssCKFWMutex_Unlock(fwInstance->mutex);
00959   return rv;
00960 }
00961 
00962 /*
00963  * nssCKFWInstance_GetManufacturerID
00964  *
00965  */
00966 NSS_IMPLEMENT CK_RV
00967 nssCKFWInstance_GetManufacturerID
00968 (
00969   NSSCKFWInstance *fwInstance,
00970   CK_CHAR manufacturerID[32]
00971 )
00972 {
00973   CK_RV error = CKR_OK;
00974 
00975 #ifdef NSSDEBUG
00976   if( (CK_CHAR_PTR)NULL == manufacturerID ) {
00977     return CKR_ARGUMENTS_BAD;
00978   }
00979 
00980   error = nssCKFWInstance_verifyPointer(fwInstance);
00981   if( CKR_OK != error ) {
00982     return error;
00983   }
00984 #endif /* NSSDEBUG */
00985 
00986   error = nssCKFWMutex_Lock(fwInstance->mutex);
00987   if( CKR_OK != error ) {
00988     return error;
00989   }
00990 
00991   if( (NSSUTF8 *)NULL == fwInstance->manufacturerID ) {
00992     if( (void *)NULL != (void *)fwInstance->mdInstance->GetManufacturerID ) {
00993       fwInstance->manufacturerID = fwInstance->mdInstance->GetManufacturerID(
00994         fwInstance->mdInstance, fwInstance, &error);
00995       if( ((NSSUTF8 *)NULL == fwInstance->manufacturerID) && (CKR_OK != error) ) {
00996         goto done;
00997       }
00998     } else {
00999       fwInstance->manufacturerID = (NSSUTF8 *) "";
01000     }
01001   }
01002 
01003   (void)nssUTF8_CopyIntoFixedBuffer(fwInstance->manufacturerID, (char *)manufacturerID, 32, ' ');
01004   error = CKR_OK;
01005 
01006  done:
01007   (void)nssCKFWMutex_Unlock(fwInstance->mutex);
01008   return error;
01009 }
01010 
01011 /*
01012  * nssCKFWInstance_GetFlags
01013  *
01014  */
01015 NSS_IMPLEMENT CK_ULONG
01016 nssCKFWInstance_GetFlags
01017 (
01018   NSSCKFWInstance *fwInstance
01019 )
01020 {
01021 #ifdef NSSDEBUG
01022   if( CKR_OK != nssCKFWInstance_verifyPointer(fwInstance) ) {
01023     return (CK_ULONG)0;
01024   }
01025 #endif /* NSSDEBUG */
01026 
01027   /* No "instance flags" are yet defined by Cryptoki. */
01028   return (CK_ULONG)0;
01029 }
01030 
01031 /*
01032  * nssCKFWInstance_GetLibraryDescription
01033  *
01034  */
01035 NSS_IMPLEMENT CK_RV
01036 nssCKFWInstance_GetLibraryDescription
01037 (
01038   NSSCKFWInstance *fwInstance,
01039   CK_CHAR libraryDescription[32]
01040 )
01041 {
01042   CK_RV error = CKR_OK;
01043 
01044 #ifdef NSSDEBUG
01045   if( (CK_CHAR_PTR)NULL == libraryDescription ) {
01046     return CKR_ARGUMENTS_BAD;
01047   }
01048 
01049   error = nssCKFWInstance_verifyPointer(fwInstance);
01050   if( CKR_OK != error ) {
01051     return error;
01052   }
01053 #endif /* NSSDEBUG */
01054 
01055   error = nssCKFWMutex_Lock(fwInstance->mutex);
01056   if( CKR_OK != error ) {
01057     return error;
01058   }
01059 
01060   if( (NSSUTF8 *)NULL == fwInstance->libraryDescription ) {
01061     if( (void *)NULL != (void *)fwInstance->mdInstance->GetLibraryDescription ) {
01062       fwInstance->libraryDescription = fwInstance->mdInstance->GetLibraryDescription(
01063         fwInstance->mdInstance, fwInstance, &error);
01064       if( ((NSSUTF8 *)NULL == fwInstance->libraryDescription) && (CKR_OK != error) ) {
01065         goto done;
01066       }
01067     } else {
01068       fwInstance->libraryDescription = (NSSUTF8 *) "";
01069     }
01070   }
01071 
01072   (void)nssUTF8_CopyIntoFixedBuffer(fwInstance->libraryDescription, (char *)libraryDescription, 32, ' ');
01073   error = CKR_OK;
01074 
01075  done:
01076   (void)nssCKFWMutex_Unlock(fwInstance->mutex);
01077   return error;
01078 }
01079 
01080 /*
01081  * nssCKFWInstance_GetLibraryVersion
01082  *
01083  */
01084 NSS_IMPLEMENT CK_VERSION
01085 nssCKFWInstance_GetLibraryVersion
01086 (
01087   NSSCKFWInstance *fwInstance
01088 )
01089 {
01090   CK_VERSION rv;
01091 
01092 #ifdef NSSDEBUG
01093   if( CKR_OK != nssCKFWInstance_verifyPointer(fwInstance) ) {
01094     rv.major = rv.minor = 0;
01095     return rv;
01096   }
01097 #endif /* NSSDEBUG */
01098 
01099   if( CKR_OK != nssCKFWMutex_Lock(fwInstance->mutex) ) {
01100     rv.major = rv.minor = 0;
01101     return rv;
01102   }
01103 
01104   if( (0 != fwInstance->libraryVersion.major) ||
01105       (0 != fwInstance->libraryVersion.minor) ) {
01106     rv = fwInstance->libraryVersion;
01107     goto done;
01108   }
01109 
01110   if( (void *)NULL != (void *)fwInstance->mdInstance->GetLibraryVersion ) {
01111     fwInstance->libraryVersion = fwInstance->mdInstance->GetLibraryVersion(
01112       fwInstance->mdInstance, fwInstance);
01113   } else {
01114     fwInstance->libraryVersion.major = 0;
01115     fwInstance->libraryVersion.minor = 3;
01116   }
01117 
01118   rv = fwInstance->libraryVersion;
01119  done:
01120   (void)nssCKFWMutex_Unlock(fwInstance->mutex);
01121   return rv;
01122 }
01123 
01124 /*
01125  * nssCKFWInstance_GetModuleHandlesSessionObjects
01126  *
01127  */
01128 NSS_IMPLEMENT CK_BBOOL
01129 nssCKFWInstance_GetModuleHandlesSessionObjects
01130 (
01131   NSSCKFWInstance *fwInstance
01132 )
01133 {
01134 #ifdef NSSDEBUG
01135   if( CKR_OK != nssCKFWInstance_verifyPointer(fwInstance) ) {
01136     return CK_FALSE;
01137   }
01138 #endif /* NSSDEBUG */
01139 
01140   return fwInstance->moduleHandlesSessionObjects;
01141 }
01142 
01143 /*
01144  * nssCKFWInstance_GetSlots
01145  *
01146  */
01147 NSS_IMPLEMENT NSSCKFWSlot **
01148 nssCKFWInstance_GetSlots
01149 (
01150   NSSCKFWInstance *fwInstance,
01151   CK_RV *pError
01152 )
01153 {
01154 #ifdef NSSDEBUG
01155   if( (CK_RV *)NULL == pError ) {
01156     return (NSSCKFWSlot **)NULL;
01157   }
01158 
01159   *pError = nssCKFWInstance_verifyPointer(fwInstance);
01160   if( CKR_OK != *pError ) {
01161     return (NSSCKFWSlot **)NULL;
01162   }
01163 #endif /* NSSDEBUG */
01164 
01165   return fwInstance->fwSlotList;
01166 }
01167 
01168 /*
01169  * nssCKFWInstance_WaitForSlotEvent
01170  *
01171  */
01172 NSS_IMPLEMENT NSSCKFWSlot *
01173 nssCKFWInstance_WaitForSlotEvent
01174 (
01175   NSSCKFWInstance *fwInstance,
01176   CK_BBOOL block,
01177   CK_RV *pError
01178 )
01179 {
01180   NSSCKFWSlot *fwSlot = (NSSCKFWSlot *)NULL;
01181   NSSCKMDSlot *mdSlot;
01182   CK_ULONG i, n;
01183 
01184 #ifdef NSSDEBUG
01185   if( (CK_RV *)NULL == pError ) {
01186     return (NSSCKFWSlot *)NULL;
01187   }
01188 
01189   *pError = nssCKFWInstance_verifyPointer(fwInstance);
01190   if( CKR_OK != *pError ) {
01191     return (NSSCKFWSlot *)NULL;
01192   }
01193 
01194   switch( block ) {
01195   case CK_TRUE:
01196   case CK_FALSE:
01197     break;
01198   default:
01199     *pError = CKR_ARGUMENTS_BAD;
01200     return (NSSCKFWSlot *)NULL;
01201   }
01202 #endif /* NSSDEBUG */
01203 
01204   if( (void *)NULL == (void *)fwInstance->mdInstance->WaitForSlotEvent ) {
01205     *pError = CKR_NO_EVENT;
01206     return (NSSCKFWSlot *)NULL;
01207   }
01208 
01209   mdSlot = fwInstance->mdInstance->WaitForSlotEvent(
01210     fwInstance->mdInstance,
01211     fwInstance,
01212     block,
01213     pError
01214   );
01215 
01216   if( (NSSCKMDSlot *)NULL == mdSlot ) {
01217     return (NSSCKFWSlot *)NULL;
01218   }
01219 
01220   n = nssCKFWInstance_GetNSlots(fwInstance, pError);
01221   if( ((CK_ULONG)0 == n) && (CKR_OK != *pError) ) {
01222     return (NSSCKFWSlot *)NULL;
01223   }
01224 
01225   for( i = 0; i < n; i++ ) {
01226     if( fwInstance->mdSlotList[i] == mdSlot ) {
01227       fwSlot = fwInstance->fwSlotList[i];
01228       break;
01229     }
01230   }
01231 
01232   if( (NSSCKFWSlot *)NULL == fwSlot ) {
01233     /* Internal error */
01234     *pError = CKR_GENERAL_ERROR;
01235     return (NSSCKFWSlot *)NULL;
01236   }
01237 
01238   return fwSlot;
01239 }
01240 
01241 /*
01242  * NSSCKFWInstance_GetMDInstance
01243  *
01244  */
01245 NSS_IMPLEMENT NSSCKMDInstance *
01246 NSSCKFWInstance_GetMDInstance
01247 (
01248   NSSCKFWInstance *fwInstance
01249 )
01250 {
01251 #ifdef DEBUG
01252   if( CKR_OK != nssCKFWInstance_verifyPointer(fwInstance) ) {
01253     return (NSSCKMDInstance *)NULL;
01254   }
01255 #endif /* DEBUG */
01256 
01257   return nssCKFWInstance_GetMDInstance(fwInstance);
01258 }
01259 
01260 /*
01261  * NSSCKFWInstance_GetArena
01262  *
01263  */
01264 NSS_IMPLEMENT NSSArena *
01265 NSSCKFWInstance_GetArena
01266 (
01267   NSSCKFWInstance *fwInstance,
01268   CK_RV *pError
01269 )
01270 {
01271 #ifdef DEBUG
01272   if( (CK_RV *)NULL == pError ) {
01273     return (NSSArena *)NULL;
01274   }
01275 
01276   *pError = nssCKFWInstance_verifyPointer(fwInstance);
01277   if( CKR_OK != *pError ) {
01278     return (NSSArena *)NULL;
01279   }
01280 #endif /* DEBUG */
01281 
01282   return nssCKFWInstance_GetArena(fwInstance, pError);
01283 }
01284 
01285 /*
01286  * NSSCKFWInstance_MayCreatePthreads
01287  *
01288  */
01289 NSS_IMPLEMENT CK_BBOOL
01290 NSSCKFWInstance_MayCreatePthreads
01291 (
01292   NSSCKFWInstance *fwInstance
01293 )
01294 {
01295 #ifdef DEBUG
01296   if( CKR_OK != nssCKFWInstance_verifyPointer(fwInstance) ) {
01297     return CK_FALSE;
01298   }
01299 #endif /* DEBUG */
01300 
01301   return nssCKFWInstance_MayCreatePthreads(fwInstance);
01302 }
01303 
01304 /*
01305  * NSSCKFWInstance_CreateMutex
01306  *
01307  */
01308 NSS_IMPLEMENT NSSCKFWMutex *
01309 NSSCKFWInstance_CreateMutex
01310 (
01311   NSSCKFWInstance *fwInstance,
01312   NSSArena *arena,
01313   CK_RV *pError
01314 )
01315 {
01316 #ifdef DEBUG
01317   if( (CK_RV *)NULL == pError ) {
01318     return (NSSCKFWMutex *)NULL;
01319   }
01320 
01321   *pError = nssCKFWInstance_verifyPointer(fwInstance);
01322   if( CKR_OK != *pError ) {
01323     return (NSSCKFWMutex *)NULL;
01324   }
01325 #endif /* DEBUG */
01326 
01327   return nssCKFWInstance_CreateMutex(fwInstance, arena, pError);
01328 }
01329 
01330 /*
01331  * NSSCKFWInstance_GetConfigurationData
01332  *
01333  */
01334 NSS_IMPLEMENT NSSUTF8 *
01335 NSSCKFWInstance_GetConfigurationData
01336 (
01337   NSSCKFWInstance *fwInstance
01338 )
01339 {
01340 #ifdef DEBUG
01341   if( CKR_OK != nssCKFWInstance_verifyPointer(fwInstance) ) {
01342     return (NSSUTF8 *)NULL;
01343   }
01344 #endif /* DEBUG */
01345 
01346   return nssCKFWInstance_GetConfigurationData(fwInstance);
01347 }
01348 
01349 /*
01350  * NSSCKFWInstance_GetInitArgs
01351  *
01352  */
01353 NSS_IMPLEMENT CK_C_INITIALIZE_ARGS_PTR
01354 NSSCKFWInstance_GetInitArgs
01355 (
01356   NSSCKFWInstance *fwInstance
01357 )
01358 {
01359 #ifdef DEBUG
01360   if( CKR_OK != nssCKFWInstance_verifyPointer(fwInstance) ) {
01361     return (CK_C_INITIALIZE_ARGS_PTR)NULL;
01362   }
01363 #endif /* DEBUG */
01364 
01365   return nssCKFWInstance_GetInitArgs(fwInstance);
01366 }
01367