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