andre@0: /* This Source Code Form is subject to the terms of the Mozilla Public andre@0: * License, v. 2.0. If a copy of the MPL was not distributed with this andre@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ andre@0: andre@0: /* andre@0: * instance.c andre@0: * andre@0: * This file implements the NSSCKFWInstance type and methods. andre@0: */ andre@0: andre@0: #ifndef CK_T andre@0: #include "ck.h" andre@0: #endif /* CK_T */ andre@0: andre@0: /* andre@0: * NSSCKFWInstance andre@0: * andre@0: * -- create/destroy -- andre@0: * nssCKFWInstance_Create andre@0: * nssCKFWInstance_Destroy andre@0: * andre@0: * -- public accessors -- andre@0: * NSSCKFWInstance_GetMDInstance andre@0: * NSSCKFWInstance_GetArena andre@0: * NSSCKFWInstance_MayCreatePthreads andre@0: * NSSCKFWInstance_CreateMutex andre@0: * NSSCKFWInstance_GetConfigurationData andre@0: * NSSCKFWInstance_GetInitArgs andre@0: * andre@0: * -- implement public accessors -- andre@0: * nssCKFWInstance_GetMDInstance andre@0: * nssCKFWInstance_GetArena andre@0: * nssCKFWInstance_MayCreatePthreads andre@0: * nssCKFWInstance_CreateMutex andre@0: * nssCKFWInstance_GetConfigurationData andre@0: * nssCKFWInstance_GetInitArgs andre@0: * andre@0: * -- private accessors -- andre@0: * nssCKFWInstance_CreateSessionHandle andre@0: * nssCKFWInstance_ResolveSessionHandle andre@0: * nssCKFWInstance_DestroySessionHandle andre@0: * nssCKFWInstance_FindSessionHandle andre@0: * nssCKFWInstance_CreateObjectHandle andre@0: * nssCKFWInstance_ResolveObjectHandle andre@0: * nssCKFWInstance_DestroyObjectHandle andre@0: * andre@0: * -- module fronts -- andre@0: * nssCKFWInstance_GetNSlots andre@0: * nssCKFWInstance_GetCryptokiVersion andre@0: * nssCKFWInstance_GetManufacturerID andre@0: * nssCKFWInstance_GetFlags andre@0: * nssCKFWInstance_GetLibraryDescription andre@0: * nssCKFWInstance_GetLibraryVersion andre@0: * nssCKFWInstance_GetModuleHandlesSessionObjects andre@0: * nssCKFWInstance_GetSlots andre@0: * nssCKFWInstance_WaitForSlotEvent andre@0: * andre@0: * -- debugging versions only -- andre@0: * nssCKFWInstance_verifyPointer andre@0: */ andre@0: andre@0: struct NSSCKFWInstanceStr { andre@0: NSSCKFWMutex *mutex; andre@0: NSSArena *arena; andre@0: NSSCKMDInstance *mdInstance; andre@0: CK_C_INITIALIZE_ARGS_PTR pInitArgs; andre@0: CK_C_INITIALIZE_ARGS initArgs; andre@0: CryptokiLockingState LockingState; andre@0: CK_BBOOL mayCreatePthreads; andre@0: NSSUTF8 *configurationData; andre@0: CK_ULONG nSlots; andre@0: NSSCKFWSlot **fwSlotList; andre@0: NSSCKMDSlot **mdSlotList; andre@0: CK_BBOOL moduleHandlesSessionObjects; andre@0: andre@0: /* andre@0: * Everything above is set at creation time, and then not modified. andre@0: * The invariants the mutex protects are: andre@0: * andre@0: * 1) Each of the cached descriptions (versions, etc.) are in an andre@0: * internally consistant state. andre@0: * andre@0: * 2) The session handle hashes and count are consistant andre@0: * andre@0: * 3) The object handle hashes and count are consistant. andre@0: * andre@0: * I could use multiple locks, but let's wait to see if that's andre@0: * really necessary. andre@0: * andre@0: * Note that the calls accessing the cached descriptions will andre@0: * call the NSSCKMDInstance methods with the mutex locked. Those andre@0: * methods may then call the public NSSCKFWInstance routines. andre@0: * Those public routines only access the constant data above, so andre@0: * there's no problem. But be careful if you add to this object; andre@0: * mutexes are in general not reentrant, so don't create deadlock andre@0: * situations. andre@0: */ andre@0: andre@0: CK_VERSION cryptokiVersion; andre@0: NSSUTF8 *manufacturerID; andre@0: NSSUTF8 *libraryDescription; andre@0: CK_VERSION libraryVersion; andre@0: andre@0: CK_ULONG lastSessionHandle; andre@0: nssCKFWHash *sessionHandleHash; andre@0: andre@0: CK_ULONG lastObjectHandle; andre@0: nssCKFWHash *objectHandleHash; andre@0: }; andre@0: andre@0: #ifdef DEBUG andre@0: /* andre@0: * But first, the pointer-tracking stuff. andre@0: * andre@0: * NOTE: the pointer-tracking support in NSS/base currently relies andre@0: * upon NSPR's CallOnce support. That, however, relies upon NSPR's andre@0: * locking, which is tied into the runtime. We need a pointer-tracker andre@0: * implementation that uses the locks supplied through C_Initialize. andre@0: * That support, however, can be filled in later. So for now, I'll andre@0: * just do this routines as no-ops. andre@0: */ andre@0: andre@0: static CK_RV andre@0: instance_add_pointer andre@0: ( andre@0: const NSSCKFWInstance *fwInstance andre@0: ) andre@0: { andre@0: return CKR_OK; andre@0: } andre@0: andre@0: static CK_RV andre@0: instance_remove_pointer andre@0: ( andre@0: const NSSCKFWInstance *fwInstance andre@0: ) andre@0: { andre@0: return CKR_OK; andre@0: } andre@0: andre@0: NSS_IMPLEMENT CK_RV andre@0: nssCKFWInstance_verifyPointer andre@0: ( andre@0: const NSSCKFWInstance *fwInstance andre@0: ) andre@0: { andre@0: return CKR_OK; andre@0: } andre@0: andre@0: #endif /* DEBUG */ andre@0: andre@0: /* andre@0: * nssCKFWInstance_Create andre@0: * andre@0: */ andre@0: NSS_IMPLEMENT NSSCKFWInstance * andre@0: nssCKFWInstance_Create andre@0: ( andre@0: CK_C_INITIALIZE_ARGS_PTR pInitArgs, andre@0: CryptokiLockingState LockingState, andre@0: NSSCKMDInstance *mdInstance, andre@0: CK_RV *pError andre@0: ) andre@0: { andre@0: NSSCKFWInstance *fwInstance; andre@0: NSSArena *arena = (NSSArena *)NULL; andre@0: CK_ULONG i; andre@0: CK_BBOOL called_Initialize = CK_FALSE; andre@0: andre@0: #ifdef NSSDEBUG andre@0: if( (CK_RV)NULL == pError ) { andre@0: return (NSSCKFWInstance *)NULL; andre@0: } andre@0: andre@0: if (!mdInstance) { andre@0: *pError = CKR_ARGUMENTS_BAD; andre@0: return (NSSCKFWInstance *)NULL; andre@0: } andre@0: #endif /* NSSDEBUG */ andre@0: andre@0: arena = NSSArena_Create(); andre@0: if (!arena) { andre@0: *pError = CKR_HOST_MEMORY; andre@0: return (NSSCKFWInstance *)NULL; andre@0: } andre@0: andre@0: fwInstance = nss_ZNEW(arena, NSSCKFWInstance); andre@0: if (!fwInstance) { andre@0: goto nomem; andre@0: } andre@0: andre@0: fwInstance->arena = arena; andre@0: fwInstance->mdInstance = mdInstance; andre@0: andre@0: fwInstance->LockingState = LockingState; andre@0: if( (CK_C_INITIALIZE_ARGS_PTR)NULL != pInitArgs ) { andre@0: fwInstance->initArgs = *pInitArgs; andre@0: fwInstance->pInitArgs = &fwInstance->initArgs; andre@0: if( pInitArgs->flags & CKF_LIBRARY_CANT_CREATE_OS_THREADS ) { andre@0: fwInstance->mayCreatePthreads = CK_FALSE; andre@0: } else { andre@0: fwInstance->mayCreatePthreads = CK_TRUE; andre@0: } andre@0: fwInstance->configurationData = (NSSUTF8 *)(pInitArgs->pReserved); andre@0: } else { andre@0: fwInstance->mayCreatePthreads = CK_TRUE; andre@0: } andre@0: andre@0: fwInstance->mutex = nssCKFWMutex_Create(pInitArgs, LockingState, arena, andre@0: pError); andre@0: if (!fwInstance->mutex) { andre@0: if( CKR_OK == *pError ) { andre@0: *pError = CKR_GENERAL_ERROR; andre@0: } andre@0: goto loser; andre@0: } andre@0: andre@0: if (mdInstance->Initialize) { andre@0: *pError = mdInstance->Initialize(mdInstance, fwInstance, fwInstance->configurationData); andre@0: if( CKR_OK != *pError ) { andre@0: goto loser; andre@0: } andre@0: andre@0: called_Initialize = CK_TRUE; andre@0: } andre@0: andre@0: if (mdInstance->ModuleHandlesSessionObjects) { andre@0: fwInstance->moduleHandlesSessionObjects = andre@0: mdInstance->ModuleHandlesSessionObjects(mdInstance, fwInstance); andre@0: } else { andre@0: fwInstance->moduleHandlesSessionObjects = CK_FALSE; andre@0: } andre@0: andre@0: if (!mdInstance->GetNSlots) { andre@0: /* That routine is required */ andre@0: *pError = CKR_GENERAL_ERROR; andre@0: goto loser; andre@0: } andre@0: andre@0: fwInstance->nSlots = mdInstance->GetNSlots(mdInstance, fwInstance, pError); andre@0: if( (CK_ULONG)0 == fwInstance->nSlots ) { andre@0: if( CKR_OK == *pError ) { andre@0: /* Zero is not a legitimate answer */ andre@0: *pError = CKR_GENERAL_ERROR; andre@0: } andre@0: goto loser; andre@0: } andre@0: andre@0: fwInstance->fwSlotList = nss_ZNEWARRAY(arena, NSSCKFWSlot *, fwInstance->nSlots); andre@0: if( (NSSCKFWSlot **)NULL == fwInstance->fwSlotList ) { andre@0: goto nomem; andre@0: } andre@0: andre@0: fwInstance->mdSlotList = nss_ZNEWARRAY(arena, NSSCKMDSlot *, fwInstance->nSlots); andre@0: if( (NSSCKMDSlot **)NULL == fwInstance->mdSlotList ) { andre@0: goto nomem; andre@0: } andre@0: andre@0: fwInstance->sessionHandleHash = nssCKFWHash_Create(fwInstance, andre@0: fwInstance->arena, pError); andre@0: if (!fwInstance->sessionHandleHash) { andre@0: goto loser; andre@0: } andre@0: andre@0: fwInstance->objectHandleHash = nssCKFWHash_Create(fwInstance, andre@0: fwInstance->arena, pError); andre@0: if (!fwInstance->objectHandleHash) { andre@0: goto loser; andre@0: } andre@0: andre@0: if (!mdInstance->GetSlots) { andre@0: /* That routine is required */ andre@0: *pError = CKR_GENERAL_ERROR; andre@0: goto loser; andre@0: } andre@0: andre@0: *pError = mdInstance->GetSlots(mdInstance, fwInstance, fwInstance->mdSlotList); andre@0: if( CKR_OK != *pError ) { andre@0: goto loser; andre@0: } andre@0: andre@0: for( i = 0; i < fwInstance->nSlots; i++ ) { andre@0: NSSCKMDSlot *mdSlot = fwInstance->mdSlotList[i]; andre@0: andre@0: if (!mdSlot) { andre@0: *pError = CKR_GENERAL_ERROR; andre@0: goto loser; andre@0: } andre@0: andre@0: fwInstance->fwSlotList[i] = nssCKFWSlot_Create(fwInstance, mdSlot, i, pError); andre@0: if( CKR_OK != *pError ) { andre@0: CK_ULONG j; andre@0: andre@0: for( j = 0; j < i; j++ ) { andre@0: (void)nssCKFWSlot_Destroy(fwInstance->fwSlotList[j]); andre@0: } andre@0: andre@0: for( j = i; j < fwInstance->nSlots; j++ ) { andre@0: NSSCKMDSlot *mds = fwInstance->mdSlotList[j]; andre@0: if (mds->Destroy) { andre@0: mds->Destroy(mds, (NSSCKFWSlot *)NULL, mdInstance, fwInstance); andre@0: } andre@0: } andre@0: andre@0: goto loser; andre@0: } andre@0: } andre@0: andre@0: #ifdef DEBUG andre@0: *pError = instance_add_pointer(fwInstance); andre@0: if( CKR_OK != *pError ) { andre@0: for( i = 0; i < fwInstance->nSlots; i++ ) { andre@0: (void)nssCKFWSlot_Destroy(fwInstance->fwSlotList[i]); andre@0: } andre@0: andre@0: goto loser; andre@0: } andre@0: #endif /* DEBUG */ andre@0: andre@0: *pError = CKR_OK; andre@0: return fwInstance; andre@0: andre@0: nomem: andre@0: *pError = CKR_HOST_MEMORY; andre@0: /*FALLTHROUGH*/ andre@0: loser: andre@0: andre@0: if( CK_TRUE == called_Initialize ) { andre@0: if (mdInstance->Finalize) { andre@0: mdInstance->Finalize(mdInstance, fwInstance); andre@0: } andre@0: } andre@0: andre@0: if (fwInstance && fwInstance->mutex) { andre@0: nssCKFWMutex_Destroy(fwInstance->mutex); andre@0: } andre@0: andre@0: if (arena) { andre@0: (void)NSSArena_Destroy(arena); andre@0: } andre@0: return (NSSCKFWInstance *)NULL; andre@0: } andre@0: andre@0: /* andre@0: * nssCKFWInstance_Destroy andre@0: * andre@0: */ andre@0: NSS_IMPLEMENT CK_RV andre@0: nssCKFWInstance_Destroy andre@0: ( andre@0: NSSCKFWInstance *fwInstance andre@0: ) andre@0: { andre@0: #ifdef NSSDEBUG andre@0: CK_RV error = CKR_OK; andre@0: #endif /* NSSDEBUG */ andre@0: CK_ULONG i; andre@0: andre@0: #ifdef NSSDEBUG andre@0: error = nssCKFWInstance_verifyPointer(fwInstance); andre@0: if( CKR_OK != error ) { andre@0: return error; andre@0: } andre@0: #endif /* NSSDEBUG */ andre@0: andre@0: nssCKFWMutex_Destroy(fwInstance->mutex); andre@0: andre@0: for( i = 0; i < fwInstance->nSlots; i++ ) { andre@0: (void)nssCKFWSlot_Destroy(fwInstance->fwSlotList[i]); andre@0: } andre@0: andre@0: if (fwInstance->mdInstance->Finalize) { andre@0: fwInstance->mdInstance->Finalize(fwInstance->mdInstance, fwInstance); andre@0: } andre@0: andre@0: if (fwInstance->sessionHandleHash) { andre@0: nssCKFWHash_Destroy(fwInstance->sessionHandleHash); andre@0: } andre@0: andre@0: if (fwInstance->objectHandleHash) { andre@0: nssCKFWHash_Destroy(fwInstance->objectHandleHash); andre@0: } andre@0: andre@0: #ifdef DEBUG andre@0: (void)instance_remove_pointer(fwInstance); andre@0: #endif /* DEBUG */ andre@0: andre@0: (void)NSSArena_Destroy(fwInstance->arena); andre@0: return CKR_OK; andre@0: } andre@0: andre@0: /* andre@0: * nssCKFWInstance_GetMDInstance andre@0: * andre@0: */ andre@0: NSS_IMPLEMENT NSSCKMDInstance * andre@0: nssCKFWInstance_GetMDInstance andre@0: ( andre@0: NSSCKFWInstance *fwInstance andre@0: ) andre@0: { andre@0: #ifdef NSSDEBUG andre@0: if( CKR_OK != nssCKFWInstance_verifyPointer(fwInstance) ) { andre@0: return (NSSCKMDInstance *)NULL; andre@0: } andre@0: #endif /* NSSDEBUG */ andre@0: andre@0: return fwInstance->mdInstance; andre@0: } andre@0: andre@0: /* andre@0: * nssCKFWInstance_GetArena andre@0: * andre@0: */ andre@0: NSS_IMPLEMENT NSSArena * andre@0: nssCKFWInstance_GetArena andre@0: ( andre@0: NSSCKFWInstance *fwInstance, andre@0: CK_RV *pError andre@0: ) andre@0: { andre@0: #ifdef NSSDEBUG andre@0: if (!pError) { andre@0: return (NSSArena *)NULL; andre@0: } andre@0: andre@0: *pError = nssCKFWInstance_verifyPointer(fwInstance); andre@0: if( CKR_OK != *pError ) { andre@0: return (NSSArena *)NULL; andre@0: } andre@0: #endif /* NSSDEBUG */ andre@0: andre@0: *pError = CKR_OK; andre@0: return fwInstance->arena; andre@0: } andre@0: andre@0: /* andre@0: * nssCKFWInstance_MayCreatePthreads andre@0: * andre@0: */ andre@0: NSS_IMPLEMENT CK_BBOOL andre@0: nssCKFWInstance_MayCreatePthreads andre@0: ( andre@0: NSSCKFWInstance *fwInstance andre@0: ) andre@0: { andre@0: #ifdef NSSDEBUG andre@0: if( CKR_OK != nssCKFWInstance_verifyPointer(fwInstance) ) { andre@0: return CK_FALSE; andre@0: } andre@0: #endif /* NSSDEBUG */ andre@0: andre@0: return fwInstance->mayCreatePthreads; andre@0: } andre@0: andre@0: /* andre@0: * nssCKFWInstance_CreateMutex andre@0: * andre@0: */ andre@0: NSS_IMPLEMENT NSSCKFWMutex * andre@0: nssCKFWInstance_CreateMutex andre@0: ( andre@0: NSSCKFWInstance *fwInstance, andre@0: NSSArena *arena, andre@0: CK_RV *pError andre@0: ) andre@0: { andre@0: NSSCKFWMutex *mutex; andre@0: andre@0: #ifdef NSSDEBUG andre@0: if (!pError) { andre@0: return (NSSCKFWMutex *)NULL; andre@0: } andre@0: andre@0: *pError = nssCKFWInstance_verifyPointer(fwInstance); andre@0: if( CKR_OK != *pError ) { andre@0: return (NSSCKFWMutex *)NULL; andre@0: } andre@0: #endif /* NSSDEBUG */ andre@0: andre@0: mutex = nssCKFWMutex_Create(fwInstance->pInitArgs, fwInstance->LockingState, andre@0: arena, pError); andre@0: if (!mutex) { andre@0: if( CKR_OK == *pError ) { andre@0: *pError = CKR_GENERAL_ERROR; andre@0: } andre@0: andre@0: return (NSSCKFWMutex *)NULL; andre@0: } andre@0: andre@0: return mutex; andre@0: } andre@0: andre@0: /* andre@0: * nssCKFWInstance_GetConfigurationData andre@0: * andre@0: */ andre@0: NSS_IMPLEMENT NSSUTF8 * andre@0: nssCKFWInstance_GetConfigurationData andre@0: ( andre@0: NSSCKFWInstance *fwInstance andre@0: ) andre@0: { andre@0: #ifdef NSSDEBUG andre@0: if( CKR_OK != nssCKFWInstance_verifyPointer(fwInstance) ) { andre@0: return (NSSUTF8 *)NULL; andre@0: } andre@0: #endif /* NSSDEBUG */ andre@0: andre@0: return fwInstance->configurationData; andre@0: } andre@0: andre@0: /* andre@0: * nssCKFWInstance_GetInitArgs andre@0: * andre@0: */ andre@0: CK_C_INITIALIZE_ARGS_PTR andre@0: nssCKFWInstance_GetInitArgs andre@0: ( andre@0: NSSCKFWInstance *fwInstance andre@0: ) andre@0: { andre@0: #ifdef NSSDEBUG andre@0: if( CKR_OK != nssCKFWInstance_verifyPointer(fwInstance) ) { andre@0: return (CK_C_INITIALIZE_ARGS_PTR)NULL; andre@0: } andre@0: #endif /* NSSDEBUG */ andre@0: andre@0: return fwInstance->pInitArgs; andre@0: } andre@0: andre@0: /* andre@0: * nssCKFWInstance_CreateSessionHandle andre@0: * andre@0: */ andre@0: NSS_IMPLEMENT CK_SESSION_HANDLE andre@0: nssCKFWInstance_CreateSessionHandle andre@0: ( andre@0: NSSCKFWInstance *fwInstance, andre@0: NSSCKFWSession *fwSession, andre@0: CK_RV *pError andre@0: ) andre@0: { andre@0: CK_SESSION_HANDLE hSession; andre@0: andre@0: #ifdef NSSDEBUG andre@0: if (!pError) { andre@0: return (CK_SESSION_HANDLE)0; andre@0: } andre@0: andre@0: *pError = nssCKFWInstance_verifyPointer(fwInstance); andre@0: if( CKR_OK != *pError ) { andre@0: return (CK_SESSION_HANDLE)0; andre@0: } andre@0: #endif /* NSSDEBUG */ andre@0: andre@0: *pError = nssCKFWMutex_Lock(fwInstance->mutex); andre@0: if( CKR_OK != *pError ) { andre@0: return (CK_SESSION_HANDLE)0; andre@0: } andre@0: andre@0: hSession = ++(fwInstance->lastSessionHandle); andre@0: andre@0: /* Alan would say I should unlock for this call. */ andre@0: andre@0: *pError = nssCKFWSession_SetHandle(fwSession, hSession); andre@0: if( CKR_OK != *pError ) { andre@0: goto done; andre@0: } andre@0: andre@0: *pError = nssCKFWHash_Add(fwInstance->sessionHandleHash, andre@0: (const void *)hSession, (const void *)fwSession); andre@0: if( CKR_OK != *pError ) { andre@0: hSession = (CK_SESSION_HANDLE)0; andre@0: goto done; andre@0: } andre@0: andre@0: done: andre@0: nssCKFWMutex_Unlock(fwInstance->mutex); andre@0: return hSession; andre@0: } andre@0: andre@0: /* andre@0: * nssCKFWInstance_ResolveSessionHandle andre@0: * andre@0: */ andre@0: NSS_IMPLEMENT NSSCKFWSession * andre@0: nssCKFWInstance_ResolveSessionHandle andre@0: ( andre@0: NSSCKFWInstance *fwInstance, andre@0: CK_SESSION_HANDLE hSession andre@0: ) andre@0: { andre@0: NSSCKFWSession *fwSession; andre@0: andre@0: #ifdef NSSDEBUG andre@0: if( CKR_OK != nssCKFWInstance_verifyPointer(fwInstance) ) { andre@0: return (NSSCKFWSession *)NULL; andre@0: } andre@0: #endif /* NSSDEBUG */ andre@0: andre@0: if( CKR_OK != nssCKFWMutex_Lock(fwInstance->mutex) ) { andre@0: return (NSSCKFWSession *)NULL; andre@0: } andre@0: andre@0: fwSession = (NSSCKFWSession *)nssCKFWHash_Lookup( andre@0: fwInstance->sessionHandleHash, (const void *)hSession); andre@0: andre@0: /* Assert(hSession == nssCKFWSession_GetHandle(fwSession)) */ andre@0: andre@0: (void)nssCKFWMutex_Unlock(fwInstance->mutex); andre@0: andre@0: return fwSession; andre@0: } andre@0: andre@0: /* andre@0: * nssCKFWInstance_DestroySessionHandle andre@0: * andre@0: */ andre@0: NSS_IMPLEMENT void andre@0: nssCKFWInstance_DestroySessionHandle andre@0: ( andre@0: NSSCKFWInstance *fwInstance, andre@0: CK_SESSION_HANDLE hSession andre@0: ) andre@0: { andre@0: NSSCKFWSession *fwSession; andre@0: andre@0: #ifdef NSSDEBUG andre@0: if( CKR_OK != nssCKFWInstance_verifyPointer(fwInstance) ) { andre@0: return; andre@0: } andre@0: #endif /* NSSDEBUG */ andre@0: andre@0: if( CKR_OK != nssCKFWMutex_Lock(fwInstance->mutex) ) { andre@0: return; andre@0: } andre@0: andre@0: fwSession = (NSSCKFWSession *)nssCKFWHash_Lookup( andre@0: fwInstance->sessionHandleHash, (const void *)hSession); andre@0: if (fwSession) { andre@0: nssCKFWHash_Remove(fwInstance->sessionHandleHash, (const void *)hSession); andre@0: nssCKFWSession_SetHandle(fwSession, (CK_SESSION_HANDLE)0); andre@0: } andre@0: andre@0: (void)nssCKFWMutex_Unlock(fwInstance->mutex); andre@0: andre@0: return; andre@0: } andre@0: andre@0: /* andre@0: * nssCKFWInstance_FindSessionHandle andre@0: * andre@0: */ andre@0: NSS_IMPLEMENT CK_SESSION_HANDLE andre@0: nssCKFWInstance_FindSessionHandle andre@0: ( andre@0: NSSCKFWInstance *fwInstance, andre@0: NSSCKFWSession *fwSession andre@0: ) andre@0: { andre@0: #ifdef NSSDEBUG andre@0: if( CKR_OK != nssCKFWInstance_verifyPointer(fwInstance) ) { andre@0: return (CK_SESSION_HANDLE)0; andre@0: } andre@0: andre@0: if( CKR_OK != nssCKFWSession_verifyPointer(fwSession) ) { andre@0: return (CK_SESSION_HANDLE)0; andre@0: } andre@0: #endif /* NSSDEBUG */ andre@0: andre@0: return nssCKFWSession_GetHandle(fwSession); andre@0: /* look it up and assert? */ andre@0: } andre@0: andre@0: /* andre@0: * nssCKFWInstance_CreateObjectHandle andre@0: * andre@0: */ andre@0: NSS_IMPLEMENT CK_OBJECT_HANDLE andre@0: nssCKFWInstance_CreateObjectHandle andre@0: ( andre@0: NSSCKFWInstance *fwInstance, andre@0: NSSCKFWObject *fwObject, andre@0: CK_RV *pError andre@0: ) andre@0: { andre@0: CK_OBJECT_HANDLE hObject; andre@0: andre@0: #ifdef NSSDEBUG andre@0: if (!pError) { andre@0: return (CK_OBJECT_HANDLE)0; andre@0: } andre@0: andre@0: *pError = nssCKFWInstance_verifyPointer(fwInstance); andre@0: if( CKR_OK != *pError ) { andre@0: return (CK_OBJECT_HANDLE)0; andre@0: } andre@0: #endif /* NSSDEBUG */ andre@0: andre@0: *pError = nssCKFWMutex_Lock(fwInstance->mutex); andre@0: if( CKR_OK != *pError ) { andre@0: return (CK_OBJECT_HANDLE)0; andre@0: } andre@0: andre@0: hObject = ++(fwInstance->lastObjectHandle); andre@0: andre@0: *pError = nssCKFWObject_SetHandle(fwObject, hObject); andre@0: if( CKR_OK != *pError ) { andre@0: hObject = (CK_OBJECT_HANDLE)0; andre@0: goto done; andre@0: } andre@0: andre@0: *pError = nssCKFWHash_Add(fwInstance->objectHandleHash, andre@0: (const void *)hObject, (const void *)fwObject); andre@0: if( CKR_OK != *pError ) { andre@0: hObject = (CK_OBJECT_HANDLE)0; andre@0: goto done; andre@0: } andre@0: andre@0: done: andre@0: (void)nssCKFWMutex_Unlock(fwInstance->mutex); andre@0: return hObject; andre@0: } andre@0: andre@0: /* andre@0: * nssCKFWInstance_ResolveObjectHandle andre@0: * andre@0: */ andre@0: NSS_IMPLEMENT NSSCKFWObject * andre@0: nssCKFWInstance_ResolveObjectHandle andre@0: ( andre@0: NSSCKFWInstance *fwInstance, andre@0: CK_OBJECT_HANDLE hObject andre@0: ) andre@0: { andre@0: NSSCKFWObject *fwObject; andre@0: andre@0: #ifdef NSSDEBUG andre@0: if( CKR_OK != nssCKFWInstance_verifyPointer(fwInstance) ) { andre@0: return (NSSCKFWObject *)NULL; andre@0: } andre@0: #endif /* NSSDEBUG */ andre@0: andre@0: if( CKR_OK != nssCKFWMutex_Lock(fwInstance->mutex) ) { andre@0: return (NSSCKFWObject *)NULL; andre@0: } andre@0: andre@0: fwObject = (NSSCKFWObject *)nssCKFWHash_Lookup( andre@0: fwInstance->objectHandleHash, (const void *)hObject); andre@0: andre@0: /* Assert(hObject == nssCKFWObject_GetHandle(fwObject)) */ andre@0: andre@0: (void)nssCKFWMutex_Unlock(fwInstance->mutex); andre@0: return fwObject; andre@0: } andre@0: andre@0: /* andre@0: * nssCKFWInstance_ReassignObjectHandle andre@0: * andre@0: */ andre@0: NSS_IMPLEMENT CK_RV andre@0: nssCKFWInstance_ReassignObjectHandle andre@0: ( andre@0: NSSCKFWInstance *fwInstance, andre@0: CK_OBJECT_HANDLE hObject, andre@0: NSSCKFWObject *fwObject andre@0: ) andre@0: { andre@0: CK_RV error = CKR_OK; andre@0: NSSCKFWObject *oldObject; andre@0: andre@0: #ifdef NSSDEBUG andre@0: error = nssCKFWInstance_verifyPointer(fwInstance); andre@0: if( CKR_OK != error ) { andre@0: return error; andre@0: } andre@0: #endif /* NSSDEBUG */ andre@0: andre@0: error = nssCKFWMutex_Lock(fwInstance->mutex); andre@0: if( CKR_OK != error ) { andre@0: return error; andre@0: } andre@0: andre@0: oldObject = (NSSCKFWObject *)nssCKFWHash_Lookup( andre@0: fwInstance->objectHandleHash, (const void *)hObject); andre@0: if(oldObject) { andre@0: /* Assert(hObject == nssCKFWObject_GetHandle(oldObject) */ andre@0: (void)nssCKFWObject_SetHandle(oldObject, (CK_SESSION_HANDLE)0); andre@0: nssCKFWHash_Remove(fwInstance->objectHandleHash, (const void *)hObject); andre@0: } andre@0: andre@0: error = nssCKFWObject_SetHandle(fwObject, hObject); andre@0: if( CKR_OK != error ) { andre@0: goto done; andre@0: } andre@0: error = nssCKFWHash_Add(fwInstance->objectHandleHash, andre@0: (const void *)hObject, (const void *)fwObject); andre@0: andre@0: done: andre@0: (void)nssCKFWMutex_Unlock(fwInstance->mutex); andre@0: return error; andre@0: } andre@0: andre@0: /* andre@0: * nssCKFWInstance_DestroyObjectHandle andre@0: * andre@0: */ andre@0: NSS_IMPLEMENT void andre@0: nssCKFWInstance_DestroyObjectHandle andre@0: ( andre@0: NSSCKFWInstance *fwInstance, andre@0: CK_OBJECT_HANDLE hObject andre@0: ) andre@0: { andre@0: NSSCKFWObject *fwObject; andre@0: andre@0: #ifdef NSSDEBUG andre@0: if( CKR_OK != nssCKFWInstance_verifyPointer(fwInstance) ) { andre@0: return; andre@0: } andre@0: #endif /* NSSDEBUG */ andre@0: andre@0: if( CKR_OK != nssCKFWMutex_Lock(fwInstance->mutex) ) { andre@0: return; andre@0: } andre@0: andre@0: fwObject = (NSSCKFWObject *)nssCKFWHash_Lookup( andre@0: fwInstance->objectHandleHash, (const void *)hObject); andre@0: if (fwObject) { andre@0: /* Assert(hObject = nssCKFWObject_GetHandle(fwObject)) */ andre@0: nssCKFWHash_Remove(fwInstance->objectHandleHash, (const void *)hObject); andre@0: (void)nssCKFWObject_SetHandle(fwObject, (CK_SESSION_HANDLE)0); andre@0: } andre@0: andre@0: (void)nssCKFWMutex_Unlock(fwInstance->mutex); andre@0: return; andre@0: } andre@0: andre@0: /* andre@0: * nssCKFWInstance_FindObjectHandle andre@0: * andre@0: */ andre@0: NSS_IMPLEMENT CK_OBJECT_HANDLE andre@0: nssCKFWInstance_FindObjectHandle andre@0: ( andre@0: NSSCKFWInstance *fwInstance, andre@0: NSSCKFWObject *fwObject andre@0: ) andre@0: { andre@0: #ifdef NSSDEBUG andre@0: if( CKR_OK != nssCKFWInstance_verifyPointer(fwInstance) ) { andre@0: return (CK_OBJECT_HANDLE)0; andre@0: } andre@0: andre@0: if( CKR_OK != nssCKFWObject_verifyPointer(fwObject) ) { andre@0: return (CK_OBJECT_HANDLE)0; andre@0: } andre@0: #endif /* NSSDEBUG */ andre@0: andre@0: return nssCKFWObject_GetHandle(fwObject); andre@0: } andre@0: andre@0: /* andre@0: * nssCKFWInstance_GetNSlots andre@0: * andre@0: */ andre@0: NSS_IMPLEMENT CK_ULONG andre@0: nssCKFWInstance_GetNSlots andre@0: ( andre@0: NSSCKFWInstance *fwInstance, andre@0: CK_RV *pError andre@0: ) andre@0: { andre@0: #ifdef NSSDEBUG andre@0: if (!pError) { andre@0: return (CK_ULONG)0; andre@0: } andre@0: andre@0: *pError = nssCKFWInstance_verifyPointer(fwInstance); andre@0: if( CKR_OK != *pError ) { andre@0: return (CK_ULONG)0; andre@0: } andre@0: #endif /* NSSDEBUG */ andre@0: andre@0: *pError = CKR_OK; andre@0: return fwInstance->nSlots; andre@0: } andre@0: andre@0: /* andre@0: * nssCKFWInstance_GetCryptokiVersion andre@0: * andre@0: */ andre@0: NSS_IMPLEMENT CK_VERSION andre@0: nssCKFWInstance_GetCryptokiVersion andre@0: ( andre@0: NSSCKFWInstance *fwInstance andre@0: ) andre@0: { andre@0: CK_VERSION rv; andre@0: andre@0: #ifdef NSSDEBUG andre@0: if( CKR_OK != nssCKFWInstance_verifyPointer(fwInstance) ) { andre@0: rv.major = rv.minor = 0; andre@0: return rv; andre@0: } andre@0: #endif /* NSSDEBUG */ andre@0: andre@0: if( CKR_OK != nssCKFWMutex_Lock(fwInstance->mutex) ) { andre@0: rv.major = rv.minor = 0; andre@0: return rv; andre@0: } andre@0: andre@0: if( (0 != fwInstance->cryptokiVersion.major) || andre@0: (0 != fwInstance->cryptokiVersion.minor) ) { andre@0: rv = fwInstance->cryptokiVersion; andre@0: goto done; andre@0: } andre@0: andre@0: if (fwInstance->mdInstance->GetCryptokiVersion) { andre@0: fwInstance->cryptokiVersion = fwInstance->mdInstance->GetCryptokiVersion( andre@0: fwInstance->mdInstance, fwInstance); andre@0: } else { andre@0: fwInstance->cryptokiVersion.major = 2; andre@0: fwInstance->cryptokiVersion.minor = 1; andre@0: } andre@0: andre@0: rv = fwInstance->cryptokiVersion; andre@0: andre@0: done: andre@0: (void)nssCKFWMutex_Unlock(fwInstance->mutex); andre@0: return rv; andre@0: } andre@0: andre@0: /* andre@0: * nssCKFWInstance_GetManufacturerID andre@0: * andre@0: */ andre@0: NSS_IMPLEMENT CK_RV andre@0: nssCKFWInstance_GetManufacturerID andre@0: ( andre@0: NSSCKFWInstance *fwInstance, andre@0: CK_CHAR manufacturerID[32] andre@0: ) andre@0: { andre@0: CK_RV error = CKR_OK; andre@0: andre@0: #ifdef NSSDEBUG andre@0: if( (CK_CHAR_PTR)NULL == manufacturerID ) { andre@0: return CKR_ARGUMENTS_BAD; andre@0: } andre@0: andre@0: error = nssCKFWInstance_verifyPointer(fwInstance); andre@0: if( CKR_OK != error ) { andre@0: return error; andre@0: } andre@0: #endif /* NSSDEBUG */ andre@0: andre@0: error = nssCKFWMutex_Lock(fwInstance->mutex); andre@0: if( CKR_OK != error ) { andre@0: return error; andre@0: } andre@0: andre@0: if (!fwInstance->manufacturerID) { andre@0: if (fwInstance->mdInstance->GetManufacturerID) { andre@0: fwInstance->manufacturerID = fwInstance->mdInstance->GetManufacturerID( andre@0: fwInstance->mdInstance, fwInstance, &error); andre@0: if ((!fwInstance->manufacturerID) && (CKR_OK != error)) { andre@0: goto done; andre@0: } andre@0: } else { andre@0: fwInstance->manufacturerID = (NSSUTF8 *) ""; andre@0: } andre@0: } andre@0: andre@0: (void)nssUTF8_CopyIntoFixedBuffer(fwInstance->manufacturerID, (char *)manufacturerID, 32, ' '); andre@0: error = CKR_OK; andre@0: andre@0: done: andre@0: (void)nssCKFWMutex_Unlock(fwInstance->mutex); andre@0: return error; andre@0: } andre@0: andre@0: /* andre@0: * nssCKFWInstance_GetFlags andre@0: * andre@0: */ andre@0: NSS_IMPLEMENT CK_ULONG andre@0: nssCKFWInstance_GetFlags andre@0: ( andre@0: NSSCKFWInstance *fwInstance andre@0: ) andre@0: { andre@0: #ifdef NSSDEBUG andre@0: if( CKR_OK != nssCKFWInstance_verifyPointer(fwInstance) ) { andre@0: return (CK_ULONG)0; andre@0: } andre@0: #endif /* NSSDEBUG */ andre@0: andre@0: /* No "instance flags" are yet defined by Cryptoki. */ andre@0: return (CK_ULONG)0; andre@0: } andre@0: andre@0: /* andre@0: * nssCKFWInstance_GetLibraryDescription andre@0: * andre@0: */ andre@0: NSS_IMPLEMENT CK_RV andre@0: nssCKFWInstance_GetLibraryDescription andre@0: ( andre@0: NSSCKFWInstance *fwInstance, andre@0: CK_CHAR libraryDescription[32] andre@0: ) andre@0: { andre@0: CK_RV error = CKR_OK; andre@0: andre@0: #ifdef NSSDEBUG andre@0: if( (CK_CHAR_PTR)NULL == libraryDescription ) { andre@0: return CKR_ARGUMENTS_BAD; andre@0: } andre@0: andre@0: error = nssCKFWInstance_verifyPointer(fwInstance); andre@0: if( CKR_OK != error ) { andre@0: return error; andre@0: } andre@0: #endif /* NSSDEBUG */ andre@0: andre@0: error = nssCKFWMutex_Lock(fwInstance->mutex); andre@0: if( CKR_OK != error ) { andre@0: return error; andre@0: } andre@0: andre@0: if (!fwInstance->libraryDescription) { andre@0: if (fwInstance->mdInstance->GetLibraryDescription) { andre@0: fwInstance->libraryDescription = fwInstance->mdInstance->GetLibraryDescription( andre@0: fwInstance->mdInstance, fwInstance, &error); andre@0: if ((!fwInstance->libraryDescription) && (CKR_OK != error)) { andre@0: goto done; andre@0: } andre@0: } else { andre@0: fwInstance->libraryDescription = (NSSUTF8 *) ""; andre@0: } andre@0: } andre@0: andre@0: (void)nssUTF8_CopyIntoFixedBuffer(fwInstance->libraryDescription, (char *)libraryDescription, 32, ' '); andre@0: error = CKR_OK; andre@0: andre@0: done: andre@0: (void)nssCKFWMutex_Unlock(fwInstance->mutex); andre@0: return error; andre@0: } andre@0: andre@0: /* andre@0: * nssCKFWInstance_GetLibraryVersion andre@0: * andre@0: */ andre@0: NSS_IMPLEMENT CK_VERSION andre@0: nssCKFWInstance_GetLibraryVersion andre@0: ( andre@0: NSSCKFWInstance *fwInstance andre@0: ) andre@0: { andre@0: CK_VERSION rv; andre@0: andre@0: #ifdef NSSDEBUG andre@0: if( CKR_OK != nssCKFWInstance_verifyPointer(fwInstance) ) { andre@0: rv.major = rv.minor = 0; andre@0: return rv; andre@0: } andre@0: #endif /* NSSDEBUG */ andre@0: andre@0: if( CKR_OK != nssCKFWMutex_Lock(fwInstance->mutex) ) { andre@0: rv.major = rv.minor = 0; andre@0: return rv; andre@0: } andre@0: andre@0: if( (0 != fwInstance->libraryVersion.major) || andre@0: (0 != fwInstance->libraryVersion.minor) ) { andre@0: rv = fwInstance->libraryVersion; andre@0: goto done; andre@0: } andre@0: andre@0: if (fwInstance->mdInstance->GetLibraryVersion) { andre@0: fwInstance->libraryVersion = fwInstance->mdInstance->GetLibraryVersion( andre@0: fwInstance->mdInstance, fwInstance); andre@0: } else { andre@0: fwInstance->libraryVersion.major = 0; andre@0: fwInstance->libraryVersion.minor = 3; andre@0: } andre@0: andre@0: rv = fwInstance->libraryVersion; andre@0: done: andre@0: (void)nssCKFWMutex_Unlock(fwInstance->mutex); andre@0: return rv; andre@0: } andre@0: andre@0: /* andre@0: * nssCKFWInstance_GetModuleHandlesSessionObjects andre@0: * andre@0: */ andre@0: NSS_IMPLEMENT CK_BBOOL andre@0: nssCKFWInstance_GetModuleHandlesSessionObjects andre@0: ( andre@0: NSSCKFWInstance *fwInstance andre@0: ) andre@0: { andre@0: #ifdef NSSDEBUG andre@0: if( CKR_OK != nssCKFWInstance_verifyPointer(fwInstance) ) { andre@0: return CK_FALSE; andre@0: } andre@0: #endif /* NSSDEBUG */ andre@0: andre@0: return fwInstance->moduleHandlesSessionObjects; andre@0: } andre@0: andre@0: /* andre@0: * nssCKFWInstance_GetSlots andre@0: * andre@0: */ andre@0: NSS_IMPLEMENT NSSCKFWSlot ** andre@0: nssCKFWInstance_GetSlots andre@0: ( andre@0: NSSCKFWInstance *fwInstance, andre@0: CK_RV *pError andre@0: ) andre@0: { andre@0: #ifdef NSSDEBUG andre@0: if (!pError) { andre@0: return (NSSCKFWSlot **)NULL; andre@0: } andre@0: andre@0: *pError = nssCKFWInstance_verifyPointer(fwInstance); andre@0: if( CKR_OK != *pError ) { andre@0: return (NSSCKFWSlot **)NULL; andre@0: } andre@0: #endif /* NSSDEBUG */ andre@0: andre@0: return fwInstance->fwSlotList; andre@0: } andre@0: andre@0: /* andre@0: * nssCKFWInstance_WaitForSlotEvent andre@0: * andre@0: */ andre@0: NSS_IMPLEMENT NSSCKFWSlot * andre@0: nssCKFWInstance_WaitForSlotEvent andre@0: ( andre@0: NSSCKFWInstance *fwInstance, andre@0: CK_BBOOL block, andre@0: CK_RV *pError andre@0: ) andre@0: { andre@0: NSSCKFWSlot *fwSlot = (NSSCKFWSlot *)NULL; andre@0: NSSCKMDSlot *mdSlot; andre@0: CK_ULONG i, n; andre@0: andre@0: #ifdef NSSDEBUG andre@0: if (!pError) { andre@0: return (NSSCKFWSlot *)NULL; andre@0: } andre@0: andre@0: *pError = nssCKFWInstance_verifyPointer(fwInstance); andre@0: if( CKR_OK != *pError ) { andre@0: return (NSSCKFWSlot *)NULL; andre@0: } andre@0: andre@0: switch( block ) { andre@0: case CK_TRUE: andre@0: case CK_FALSE: andre@0: break; andre@0: default: andre@0: *pError = CKR_ARGUMENTS_BAD; andre@0: return (NSSCKFWSlot *)NULL; andre@0: } andre@0: #endif /* NSSDEBUG */ andre@0: andre@0: if (!fwInstance->mdInstance->WaitForSlotEvent) { andre@0: *pError = CKR_NO_EVENT; andre@0: return (NSSCKFWSlot *)NULL; andre@0: } andre@0: andre@0: mdSlot = fwInstance->mdInstance->WaitForSlotEvent( andre@0: fwInstance->mdInstance, andre@0: fwInstance, andre@0: block, andre@0: pError andre@0: ); andre@0: andre@0: if (!mdSlot) { andre@0: return (NSSCKFWSlot *)NULL; andre@0: } andre@0: andre@0: n = nssCKFWInstance_GetNSlots(fwInstance, pError); andre@0: if( ((CK_ULONG)0 == n) && (CKR_OK != *pError) ) { andre@0: return (NSSCKFWSlot *)NULL; andre@0: } andre@0: andre@0: for( i = 0; i < n; i++ ) { andre@0: if( fwInstance->mdSlotList[i] == mdSlot ) { andre@0: fwSlot = fwInstance->fwSlotList[i]; andre@0: break; andre@0: } andre@0: } andre@0: andre@0: if (!fwSlot) { andre@0: /* Internal error */ andre@0: *pError = CKR_GENERAL_ERROR; andre@0: return (NSSCKFWSlot *)NULL; andre@0: } andre@0: andre@0: return fwSlot; andre@0: } andre@0: andre@0: /* andre@0: * NSSCKFWInstance_GetMDInstance andre@0: * andre@0: */ andre@0: NSS_IMPLEMENT NSSCKMDInstance * andre@0: NSSCKFWInstance_GetMDInstance andre@0: ( andre@0: NSSCKFWInstance *fwInstance andre@0: ) andre@0: { andre@0: #ifdef DEBUG andre@0: if( CKR_OK != nssCKFWInstance_verifyPointer(fwInstance) ) { andre@0: return (NSSCKMDInstance *)NULL; andre@0: } andre@0: #endif /* DEBUG */ andre@0: andre@0: return nssCKFWInstance_GetMDInstance(fwInstance); andre@0: } andre@0: andre@0: /* andre@0: * NSSCKFWInstance_GetArena andre@0: * andre@0: */ andre@0: NSS_IMPLEMENT NSSArena * andre@0: NSSCKFWInstance_GetArena andre@0: ( andre@0: NSSCKFWInstance *fwInstance, andre@0: CK_RV *pError andre@0: ) andre@0: { andre@0: #ifdef DEBUG andre@0: if (!pError) { andre@0: return (NSSArena *)NULL; andre@0: } andre@0: andre@0: *pError = nssCKFWInstance_verifyPointer(fwInstance); andre@0: if( CKR_OK != *pError ) { andre@0: return (NSSArena *)NULL; andre@0: } andre@0: #endif /* DEBUG */ andre@0: andre@0: return nssCKFWInstance_GetArena(fwInstance, pError); andre@0: } andre@0: andre@0: /* andre@0: * NSSCKFWInstance_MayCreatePthreads andre@0: * andre@0: */ andre@0: NSS_IMPLEMENT CK_BBOOL andre@0: NSSCKFWInstance_MayCreatePthreads andre@0: ( andre@0: NSSCKFWInstance *fwInstance andre@0: ) andre@0: { andre@0: #ifdef DEBUG andre@0: if( CKR_OK != nssCKFWInstance_verifyPointer(fwInstance) ) { andre@0: return CK_FALSE; andre@0: } andre@0: #endif /* DEBUG */ andre@0: andre@0: return nssCKFWInstance_MayCreatePthreads(fwInstance); andre@0: } andre@0: andre@0: /* andre@0: * NSSCKFWInstance_CreateMutex andre@0: * andre@0: */ andre@0: NSS_IMPLEMENT NSSCKFWMutex * andre@0: NSSCKFWInstance_CreateMutex andre@0: ( andre@0: NSSCKFWInstance *fwInstance, andre@0: NSSArena *arena, andre@0: CK_RV *pError andre@0: ) andre@0: { andre@0: #ifdef DEBUG andre@0: if (!pError) { andre@0: return (NSSCKFWMutex *)NULL; andre@0: } andre@0: andre@0: *pError = nssCKFWInstance_verifyPointer(fwInstance); andre@0: if( CKR_OK != *pError ) { andre@0: return (NSSCKFWMutex *)NULL; andre@0: } andre@0: #endif /* DEBUG */ andre@0: andre@0: return nssCKFWInstance_CreateMutex(fwInstance, arena, pError); andre@0: } andre@0: andre@0: /* andre@0: * NSSCKFWInstance_GetConfigurationData andre@0: * andre@0: */ andre@0: NSS_IMPLEMENT NSSUTF8 * andre@0: NSSCKFWInstance_GetConfigurationData andre@0: ( andre@0: NSSCKFWInstance *fwInstance andre@0: ) andre@0: { andre@0: #ifdef DEBUG andre@0: if( CKR_OK != nssCKFWInstance_verifyPointer(fwInstance) ) { andre@0: return (NSSUTF8 *)NULL; andre@0: } andre@0: #endif /* DEBUG */ andre@0: andre@0: return nssCKFWInstance_GetConfigurationData(fwInstance); andre@0: } andre@0: andre@0: /* andre@0: * NSSCKFWInstance_GetInitArgs andre@0: * andre@0: */ andre@0: NSS_IMPLEMENT CK_C_INITIALIZE_ARGS_PTR andre@0: NSSCKFWInstance_GetInitArgs andre@0: ( andre@0: NSSCKFWInstance *fwInstance andre@0: ) andre@0: { andre@0: #ifdef DEBUG andre@0: if( CKR_OK != nssCKFWInstance_verifyPointer(fwInstance) ) { andre@0: return (CK_C_INITIALIZE_ARGS_PTR)NULL; andre@0: } andre@0: #endif /* DEBUG */ andre@0: andre@0: return nssCKFWInstance_GetInitArgs(fwInstance); andre@0: } andre@0: