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