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: * slot.c michael@0: * michael@0: * This file implements the NSSCKFWSlot 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: * NSSCKFWSlot michael@0: * michael@0: * -- create/destroy -- michael@0: * nssCKFWSlot_Create michael@0: * nssCKFWSlot_Destroy michael@0: * michael@0: * -- public accessors -- michael@0: * NSSCKFWSlot_GetMDSlot michael@0: * NSSCKFWSlot_GetFWInstance michael@0: * NSSCKFWSlot_GetMDInstance michael@0: * michael@0: * -- implement public accessors -- michael@0: * nssCKFWSlot_GetMDSlot michael@0: * nssCKFWSlot_GetFWInstance michael@0: * nssCKFWSlot_GetMDInstance michael@0: * michael@0: * -- private accessors -- michael@0: * nssCKFWSlot_GetSlotID michael@0: * nssCKFWSlot_ClearToken michael@0: * michael@0: * -- module fronts -- michael@0: * nssCKFWSlot_GetSlotDescription michael@0: * nssCKFWSlot_GetManufacturerID michael@0: * nssCKFWSlot_GetTokenPresent michael@0: * nssCKFWSlot_GetRemovableDevice michael@0: * nssCKFWSlot_GetHardwareSlot michael@0: * nssCKFWSlot_GetHardwareVersion michael@0: * nssCKFWSlot_GetFirmwareVersion michael@0: * nssCKFWSlot_InitToken michael@0: * nssCKFWSlot_GetToken michael@0: */ michael@0: michael@0: struct NSSCKFWSlotStr { michael@0: NSSCKFWMutex *mutex; michael@0: NSSCKMDSlot *mdSlot; michael@0: NSSCKFWInstance *fwInstance; michael@0: NSSCKMDInstance *mdInstance; michael@0: CK_SLOT_ID slotID; 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 fwToken points to the token currently in the slot, and michael@0: * it is in a consistant state. michael@0: * michael@0: * Note that the calls accessing the cached descriptions will michael@0: * call the NSSCKMDSlot methods with the mutex locked. Those michael@0: * methods may then call the public NSSCKFWSlot routines. Those michael@0: * public routines only access the constant data above, so there's michael@0: * no problem. But be careful if you add to this object; mutexes michael@0: * are in general not reentrant, so don't create deadlock situations. michael@0: */ michael@0: michael@0: NSSUTF8 *slotDescription; michael@0: NSSUTF8 *manufacturerID; michael@0: CK_VERSION hardwareVersion; michael@0: CK_VERSION firmwareVersion; michael@0: NSSCKFWToken *fwToken; 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: slot_add_pointer michael@0: ( michael@0: const NSSCKFWSlot *fwSlot michael@0: ) michael@0: { michael@0: return CKR_OK; michael@0: } michael@0: michael@0: static CK_RV michael@0: slot_remove_pointer michael@0: ( michael@0: const NSSCKFWSlot *fwSlot michael@0: ) michael@0: { michael@0: return CKR_OK; michael@0: } michael@0: michael@0: NSS_IMPLEMENT CK_RV michael@0: nssCKFWSlot_verifyPointer michael@0: ( michael@0: const NSSCKFWSlot *fwSlot michael@0: ) michael@0: { michael@0: return CKR_OK; michael@0: } michael@0: michael@0: #endif /* DEBUG */ michael@0: michael@0: /* michael@0: * nssCKFWSlot_Create michael@0: * michael@0: */ michael@0: NSS_IMPLEMENT NSSCKFWSlot * michael@0: nssCKFWSlot_Create michael@0: ( michael@0: NSSCKFWInstance *fwInstance, michael@0: NSSCKMDSlot *mdSlot, michael@0: CK_SLOT_ID slotID, michael@0: CK_RV *pError michael@0: ) michael@0: { michael@0: NSSCKFWSlot *fwSlot; michael@0: NSSCKMDInstance *mdInstance; michael@0: NSSArena *arena; 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: mdInstance = nssCKFWInstance_GetMDInstance(fwInstance); michael@0: if (!mdInstance) { michael@0: *pError = CKR_GENERAL_ERROR; michael@0: return (NSSCKFWSlot *)NULL; michael@0: } michael@0: michael@0: arena = nssCKFWInstance_GetArena(fwInstance, pError); michael@0: if (!arena) { michael@0: if( CKR_OK == *pError ) { michael@0: *pError = CKR_GENERAL_ERROR; michael@0: } michael@0: } michael@0: michael@0: fwSlot = nss_ZNEW(arena, NSSCKFWSlot); michael@0: if (!fwSlot) { michael@0: *pError = CKR_HOST_MEMORY; michael@0: return (NSSCKFWSlot *)NULL; michael@0: } michael@0: michael@0: fwSlot->mdSlot = mdSlot; michael@0: fwSlot->fwInstance = fwInstance; michael@0: fwSlot->mdInstance = mdInstance; michael@0: fwSlot->slotID = slotID; michael@0: michael@0: fwSlot->mutex = nssCKFWInstance_CreateMutex(fwInstance, arena, pError); michael@0: if (!fwSlot->mutex) { michael@0: if( CKR_OK == *pError ) { michael@0: *pError = CKR_GENERAL_ERROR; michael@0: } michael@0: (void)nss_ZFreeIf(fwSlot); michael@0: return (NSSCKFWSlot *)NULL; michael@0: } michael@0: michael@0: if (mdSlot->Initialize) { michael@0: *pError = CKR_OK; michael@0: *pError = mdSlot->Initialize(mdSlot, fwSlot, mdInstance, fwInstance); michael@0: if( CKR_OK != *pError ) { michael@0: (void)nssCKFWMutex_Destroy(fwSlot->mutex); michael@0: (void)nss_ZFreeIf(fwSlot); michael@0: return (NSSCKFWSlot *)NULL; michael@0: } michael@0: } michael@0: michael@0: #ifdef DEBUG michael@0: *pError = slot_add_pointer(fwSlot); michael@0: if( CKR_OK != *pError ) { michael@0: if (mdSlot->Destroy) { michael@0: mdSlot->Destroy(mdSlot, fwSlot, mdInstance, fwInstance); michael@0: } michael@0: michael@0: (void)nssCKFWMutex_Destroy(fwSlot->mutex); michael@0: (void)nss_ZFreeIf(fwSlot); michael@0: return (NSSCKFWSlot *)NULL; michael@0: } michael@0: #endif /* DEBUG */ michael@0: michael@0: return fwSlot; michael@0: } michael@0: michael@0: /* michael@0: * nssCKFWSlot_Destroy michael@0: * michael@0: */ michael@0: NSS_IMPLEMENT CK_RV michael@0: nssCKFWSlot_Destroy michael@0: ( michael@0: NSSCKFWSlot *fwSlot michael@0: ) michael@0: { michael@0: CK_RV error = CKR_OK; michael@0: michael@0: #ifdef NSSDEBUG michael@0: error = nssCKFWSlot_verifyPointer(fwSlot); michael@0: if( CKR_OK != error ) { michael@0: return error; michael@0: } michael@0: #endif /* NSSDEBUG */ michael@0: if (fwSlot->fwToken) { michael@0: nssCKFWToken_Destroy(fwSlot->fwToken); michael@0: } michael@0: michael@0: (void)nssCKFWMutex_Destroy(fwSlot->mutex); michael@0: michael@0: if (fwSlot->mdSlot->Destroy) { michael@0: fwSlot->mdSlot->Destroy(fwSlot->mdSlot, fwSlot, michael@0: fwSlot->mdInstance, fwSlot->fwInstance); michael@0: } michael@0: michael@0: #ifdef DEBUG michael@0: error = slot_remove_pointer(fwSlot); michael@0: #endif /* DEBUG */ michael@0: (void)nss_ZFreeIf(fwSlot); michael@0: return error; michael@0: } michael@0: michael@0: /* michael@0: * nssCKFWSlot_GetMDSlot michael@0: * michael@0: */ michael@0: NSS_IMPLEMENT NSSCKMDSlot * michael@0: nssCKFWSlot_GetMDSlot michael@0: ( michael@0: NSSCKFWSlot *fwSlot michael@0: ) michael@0: { michael@0: #ifdef NSSDEBUG michael@0: if( CKR_OK != nssCKFWSlot_verifyPointer(fwSlot) ) { michael@0: return (NSSCKMDSlot *)NULL; michael@0: } michael@0: #endif /* NSSDEBUG */ michael@0: michael@0: return fwSlot->mdSlot; michael@0: } michael@0: michael@0: /* michael@0: * nssCKFWSlot_GetFWInstance michael@0: * michael@0: */ michael@0: michael@0: NSS_IMPLEMENT NSSCKFWInstance * michael@0: nssCKFWSlot_GetFWInstance michael@0: ( michael@0: NSSCKFWSlot *fwSlot michael@0: ) michael@0: { michael@0: #ifdef NSSDEBUG michael@0: if( CKR_OK != nssCKFWSlot_verifyPointer(fwSlot) ) { michael@0: return (NSSCKFWInstance *)NULL; michael@0: } michael@0: #endif /* NSSDEBUG */ michael@0: michael@0: return fwSlot->fwInstance; michael@0: } michael@0: michael@0: /* michael@0: * nssCKFWSlot_GetMDInstance michael@0: * michael@0: */ michael@0: michael@0: NSS_IMPLEMENT NSSCKMDInstance * michael@0: nssCKFWSlot_GetMDInstance michael@0: ( michael@0: NSSCKFWSlot *fwSlot michael@0: ) michael@0: { michael@0: #ifdef NSSDEBUG michael@0: if( CKR_OK != nssCKFWSlot_verifyPointer(fwSlot) ) { michael@0: return (NSSCKMDInstance *)NULL; michael@0: } michael@0: #endif /* NSSDEBUG */ michael@0: michael@0: return fwSlot->mdInstance; michael@0: } michael@0: michael@0: /* michael@0: * nssCKFWSlot_GetSlotID michael@0: * michael@0: */ michael@0: NSS_IMPLEMENT CK_SLOT_ID michael@0: nssCKFWSlot_GetSlotID michael@0: ( michael@0: NSSCKFWSlot *fwSlot michael@0: ) michael@0: { michael@0: #ifdef NSSDEBUG michael@0: if( CKR_OK != nssCKFWSlot_verifyPointer(fwSlot) ) { michael@0: return (CK_SLOT_ID)0; michael@0: } michael@0: #endif /* NSSDEBUG */ michael@0: michael@0: return fwSlot->slotID; michael@0: } michael@0: michael@0: /* michael@0: * nssCKFWSlot_GetSlotDescription michael@0: * michael@0: */ michael@0: NSS_IMPLEMENT CK_RV michael@0: nssCKFWSlot_GetSlotDescription michael@0: ( michael@0: NSSCKFWSlot *fwSlot, michael@0: CK_CHAR slotDescription[64] michael@0: ) michael@0: { michael@0: CK_RV error = CKR_OK; michael@0: michael@0: #ifdef NSSDEBUG michael@0: if( (CK_CHAR_PTR)NULL == slotDescription ) { michael@0: return CKR_ARGUMENTS_BAD; michael@0: } michael@0: michael@0: error = nssCKFWSlot_verifyPointer(fwSlot); michael@0: if( CKR_OK != error ) { michael@0: return error; michael@0: } michael@0: #endif /* NSSDEBUG */ michael@0: michael@0: error = nssCKFWMutex_Lock(fwSlot->mutex); michael@0: if( CKR_OK != error ) { michael@0: return error; michael@0: } michael@0: michael@0: if (!fwSlot->slotDescription) { michael@0: if (fwSlot->mdSlot->GetSlotDescription) { michael@0: fwSlot->slotDescription = fwSlot->mdSlot->GetSlotDescription( michael@0: fwSlot->mdSlot, fwSlot, fwSlot->mdInstance, michael@0: fwSlot->fwInstance, &error); michael@0: if ((!fwSlot->slotDescription) && (CKR_OK != error)) { michael@0: goto done; michael@0: } michael@0: } else { michael@0: fwSlot->slotDescription = (NSSUTF8 *) ""; michael@0: } michael@0: } michael@0: michael@0: (void)nssUTF8_CopyIntoFixedBuffer(fwSlot->slotDescription, (char *)slotDescription, 64, ' '); michael@0: error = CKR_OK; michael@0: michael@0: done: michael@0: (void)nssCKFWMutex_Unlock(fwSlot->mutex); michael@0: return error; michael@0: } michael@0: michael@0: /* michael@0: * nssCKFWSlot_GetManufacturerID michael@0: * michael@0: */ michael@0: NSS_IMPLEMENT CK_RV michael@0: nssCKFWSlot_GetManufacturerID michael@0: ( michael@0: NSSCKFWSlot *fwSlot, 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 = nssCKFWSlot_verifyPointer(fwSlot); michael@0: if( CKR_OK != error ) { michael@0: return error; michael@0: } michael@0: #endif /* NSSDEBUG */ michael@0: michael@0: error = nssCKFWMutex_Lock(fwSlot->mutex); michael@0: if( CKR_OK != error ) { michael@0: return error; michael@0: } michael@0: michael@0: if (!fwSlot->manufacturerID) { michael@0: if (fwSlot->mdSlot->GetManufacturerID) { michael@0: fwSlot->manufacturerID = fwSlot->mdSlot->GetManufacturerID( michael@0: fwSlot->mdSlot, fwSlot, fwSlot->mdInstance, michael@0: fwSlot->fwInstance, &error); michael@0: if ((!fwSlot->manufacturerID) && (CKR_OK != error)) { michael@0: goto done; michael@0: } michael@0: } else { michael@0: fwSlot->manufacturerID = (NSSUTF8 *) ""; michael@0: } michael@0: } michael@0: michael@0: (void)nssUTF8_CopyIntoFixedBuffer(fwSlot->manufacturerID, (char *)manufacturerID, 32, ' '); michael@0: error = CKR_OK; michael@0: michael@0: done: michael@0: (void)nssCKFWMutex_Unlock(fwSlot->mutex); michael@0: return error; michael@0: } michael@0: michael@0: /* michael@0: * nssCKFWSlot_GetTokenPresent michael@0: * michael@0: */ michael@0: NSS_IMPLEMENT CK_BBOOL michael@0: nssCKFWSlot_GetTokenPresent michael@0: ( michael@0: NSSCKFWSlot *fwSlot michael@0: ) michael@0: { michael@0: #ifdef NSSDEBUG michael@0: if( CKR_OK != nssCKFWSlot_verifyPointer(fwSlot) ) { michael@0: return CK_FALSE; michael@0: } michael@0: #endif /* NSSDEBUG */ michael@0: michael@0: if (!fwSlot->mdSlot->GetTokenPresent) { michael@0: return CK_TRUE; michael@0: } michael@0: michael@0: return fwSlot->mdSlot->GetTokenPresent(fwSlot->mdSlot, fwSlot, michael@0: fwSlot->mdInstance, fwSlot->fwInstance); michael@0: } michael@0: michael@0: /* michael@0: * nssCKFWSlot_GetRemovableDevice michael@0: * michael@0: */ michael@0: NSS_IMPLEMENT CK_BBOOL michael@0: nssCKFWSlot_GetRemovableDevice michael@0: ( michael@0: NSSCKFWSlot *fwSlot michael@0: ) michael@0: { michael@0: #ifdef NSSDEBUG michael@0: if( CKR_OK != nssCKFWSlot_verifyPointer(fwSlot) ) { michael@0: return CK_FALSE; michael@0: } michael@0: #endif /* NSSDEBUG */ michael@0: michael@0: if (!fwSlot->mdSlot->GetRemovableDevice) { michael@0: return CK_FALSE; michael@0: } michael@0: michael@0: return fwSlot->mdSlot->GetRemovableDevice(fwSlot->mdSlot, fwSlot, michael@0: fwSlot->mdInstance, fwSlot->fwInstance); michael@0: } michael@0: michael@0: /* michael@0: * nssCKFWSlot_GetHardwareSlot michael@0: * michael@0: */ michael@0: NSS_IMPLEMENT CK_BBOOL michael@0: nssCKFWSlot_GetHardwareSlot michael@0: ( michael@0: NSSCKFWSlot *fwSlot michael@0: ) michael@0: { michael@0: #ifdef NSSDEBUG michael@0: if( CKR_OK != nssCKFWSlot_verifyPointer(fwSlot) ) { michael@0: return CK_FALSE; michael@0: } michael@0: #endif /* NSSDEBUG */ michael@0: michael@0: if (!fwSlot->mdSlot->GetHardwareSlot) { michael@0: return CK_FALSE; michael@0: } michael@0: michael@0: return fwSlot->mdSlot->GetHardwareSlot(fwSlot->mdSlot, fwSlot, michael@0: fwSlot->mdInstance, fwSlot->fwInstance); michael@0: } michael@0: michael@0: /* michael@0: * nssCKFWSlot_GetHardwareVersion michael@0: * michael@0: */ michael@0: NSS_IMPLEMENT CK_VERSION michael@0: nssCKFWSlot_GetHardwareVersion michael@0: ( michael@0: NSSCKFWSlot *fwSlot michael@0: ) michael@0: { michael@0: CK_VERSION rv; michael@0: michael@0: #ifdef NSSDEBUG michael@0: if( CKR_OK != nssCKFWSlot_verifyPointer(fwSlot) ) { 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(fwSlot->mutex) ) { michael@0: rv.major = rv.minor = 0; michael@0: return rv; michael@0: } michael@0: michael@0: if( (0 != fwSlot->hardwareVersion.major) || michael@0: (0 != fwSlot->hardwareVersion.minor) ) { michael@0: rv = fwSlot->hardwareVersion; michael@0: goto done; michael@0: } michael@0: michael@0: if (fwSlot->mdSlot->GetHardwareVersion) { michael@0: fwSlot->hardwareVersion = fwSlot->mdSlot->GetHardwareVersion( michael@0: fwSlot->mdSlot, fwSlot, fwSlot->mdInstance, fwSlot->fwInstance); michael@0: } else { michael@0: fwSlot->hardwareVersion.major = 0; michael@0: fwSlot->hardwareVersion.minor = 1; michael@0: } michael@0: michael@0: rv = fwSlot->hardwareVersion; michael@0: done: michael@0: (void)nssCKFWMutex_Unlock(fwSlot->mutex); michael@0: return rv; michael@0: } michael@0: michael@0: /* michael@0: * nssCKFWSlot_GetFirmwareVersion michael@0: * michael@0: */ michael@0: NSS_IMPLEMENT CK_VERSION michael@0: nssCKFWSlot_GetFirmwareVersion michael@0: ( michael@0: NSSCKFWSlot *fwSlot michael@0: ) michael@0: { michael@0: CK_VERSION rv; michael@0: michael@0: #ifdef NSSDEBUG michael@0: if( CKR_OK != nssCKFWSlot_verifyPointer(fwSlot) ) { 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(fwSlot->mutex) ) { michael@0: rv.major = rv.minor = 0; michael@0: return rv; michael@0: } michael@0: michael@0: if( (0 != fwSlot->firmwareVersion.major) || michael@0: (0 != fwSlot->firmwareVersion.minor) ) { michael@0: rv = fwSlot->firmwareVersion; michael@0: goto done; michael@0: } michael@0: michael@0: if (fwSlot->mdSlot->GetFirmwareVersion) { michael@0: fwSlot->firmwareVersion = fwSlot->mdSlot->GetFirmwareVersion( michael@0: fwSlot->mdSlot, fwSlot, fwSlot->mdInstance, fwSlot->fwInstance); michael@0: } else { michael@0: fwSlot->firmwareVersion.major = 0; michael@0: fwSlot->firmwareVersion.minor = 1; michael@0: } michael@0: michael@0: rv = fwSlot->firmwareVersion; michael@0: done: michael@0: (void)nssCKFWMutex_Unlock(fwSlot->mutex); michael@0: return rv; michael@0: } michael@0: michael@0: /* michael@0: * nssCKFWSlot_GetToken michael@0: * michael@0: */ michael@0: NSS_IMPLEMENT NSSCKFWToken * michael@0: nssCKFWSlot_GetToken michael@0: ( michael@0: NSSCKFWSlot *fwSlot, michael@0: CK_RV *pError michael@0: ) michael@0: { michael@0: NSSCKMDToken *mdToken; michael@0: NSSCKFWToken *fwToken; michael@0: michael@0: #ifdef NSSDEBUG michael@0: if (!pError) { michael@0: return (NSSCKFWToken *)NULL; michael@0: } michael@0: michael@0: *pError = nssCKFWSlot_verifyPointer(fwSlot); michael@0: if( CKR_OK != *pError ) { michael@0: return (NSSCKFWToken *)NULL; michael@0: } michael@0: #endif /* NSSDEBUG */ michael@0: michael@0: *pError = nssCKFWMutex_Lock(fwSlot->mutex); michael@0: if( CKR_OK != *pError ) { michael@0: return (NSSCKFWToken *)NULL; michael@0: } michael@0: michael@0: if (!fwSlot->fwToken) { michael@0: if (!fwSlot->mdSlot->GetToken) { michael@0: *pError = CKR_GENERAL_ERROR; michael@0: fwToken = (NSSCKFWToken *)NULL; michael@0: goto done; michael@0: } michael@0: michael@0: mdToken = fwSlot->mdSlot->GetToken(fwSlot->mdSlot, fwSlot, michael@0: fwSlot->mdInstance, fwSlot->fwInstance, pError); michael@0: if (!mdToken) { michael@0: if( CKR_OK == *pError ) { michael@0: *pError = CKR_GENERAL_ERROR; michael@0: } michael@0: return (NSSCKFWToken *)NULL; michael@0: } michael@0: michael@0: fwToken = nssCKFWToken_Create(fwSlot, mdToken, pError); michael@0: fwSlot->fwToken = fwToken; michael@0: } else { michael@0: fwToken = fwSlot->fwToken; michael@0: } michael@0: michael@0: done: michael@0: (void)nssCKFWMutex_Unlock(fwSlot->mutex); michael@0: return fwToken; michael@0: } michael@0: michael@0: /* michael@0: * nssCKFWSlot_ClearToken michael@0: * michael@0: */ michael@0: NSS_IMPLEMENT void michael@0: nssCKFWSlot_ClearToken michael@0: ( michael@0: NSSCKFWSlot *fwSlot michael@0: ) michael@0: { michael@0: #ifdef NSSDEBUG michael@0: if( CKR_OK != nssCKFWSlot_verifyPointer(fwSlot) ) { michael@0: return; michael@0: } michael@0: #endif /* NSSDEBUG */ michael@0: michael@0: if( CKR_OK != nssCKFWMutex_Lock(fwSlot->mutex) ) { michael@0: /* Now what? */ michael@0: return; michael@0: } michael@0: michael@0: fwSlot->fwToken = (NSSCKFWToken *)NULL; michael@0: (void)nssCKFWMutex_Unlock(fwSlot->mutex); michael@0: return; michael@0: } michael@0: michael@0: /* michael@0: * NSSCKFWSlot_GetMDSlot michael@0: * michael@0: */ michael@0: michael@0: NSS_IMPLEMENT NSSCKMDSlot * michael@0: NSSCKFWSlot_GetMDSlot michael@0: ( michael@0: NSSCKFWSlot *fwSlot michael@0: ) michael@0: { michael@0: #ifdef DEBUG michael@0: if( CKR_OK != nssCKFWSlot_verifyPointer(fwSlot) ) { michael@0: return (NSSCKMDSlot *)NULL; michael@0: } michael@0: #endif /* DEBUG */ michael@0: michael@0: return nssCKFWSlot_GetMDSlot(fwSlot); michael@0: } michael@0: michael@0: /* michael@0: * NSSCKFWSlot_GetFWInstance michael@0: * michael@0: */ michael@0: michael@0: NSS_IMPLEMENT NSSCKFWInstance * michael@0: NSSCKFWSlot_GetFWInstance michael@0: ( michael@0: NSSCKFWSlot *fwSlot michael@0: ) michael@0: { michael@0: #ifdef DEBUG michael@0: if( CKR_OK != nssCKFWSlot_verifyPointer(fwSlot) ) { michael@0: return (NSSCKFWInstance *)NULL; michael@0: } michael@0: #endif /* DEBUG */ michael@0: michael@0: return nssCKFWSlot_GetFWInstance(fwSlot); michael@0: } michael@0: michael@0: /* michael@0: * NSSCKFWSlot_GetMDInstance michael@0: * michael@0: */ michael@0: michael@0: NSS_IMPLEMENT NSSCKMDInstance * michael@0: NSSCKFWSlot_GetMDInstance michael@0: ( michael@0: NSSCKFWSlot *fwSlot michael@0: ) michael@0: { michael@0: #ifdef DEBUG michael@0: if( CKR_OK != nssCKFWSlot_verifyPointer(fwSlot) ) { michael@0: return (NSSCKMDInstance *)NULL; michael@0: } michael@0: #endif /* DEBUG */ michael@0: michael@0: return nssCKFWSlot_GetMDInstance(fwSlot); michael@0: }