| Index: nss/lib/ckfw/instance.c
|
| diff --git a/nss/lib/ckfw/instance.c b/nss/lib/ckfw/instance.c
|
| index b8a5b25e17a3ae8ca1e778512f9fc7a980b0df15..f585eb58d1274d2e55ff0ed51c13fca1b7f96839 100644
|
| --- a/nss/lib/ckfw/instance.c
|
| +++ b/nss/lib/ckfw/instance.c
|
| @@ -33,7 +33,7 @@
|
| * nssCKFWInstance_MayCreatePthreads
|
| * nssCKFWInstance_CreateMutex
|
| * nssCKFWInstance_GetConfigurationData
|
| - * nssCKFWInstance_GetInitArgs
|
| + * nssCKFWInstance_GetInitArgs
|
| *
|
| * -- private accessors --
|
| * nssCKFWInstance_CreateSessionHandle
|
| @@ -60,52 +60,52 @@
|
| */
|
|
|
| struct NSSCKFWInstanceStr {
|
| - NSSCKFWMutex *mutex;
|
| - NSSArena *arena;
|
| - NSSCKMDInstance *mdInstance;
|
| - CK_C_INITIALIZE_ARGS_PTR pInitArgs;
|
| - CK_C_INITIALIZE_ARGS initArgs;
|
| - CryptokiLockingState LockingState;
|
| - CK_BBOOL mayCreatePthreads;
|
| - NSSUTF8 *configurationData;
|
| - CK_ULONG nSlots;
|
| - NSSCKFWSlot **fwSlotList;
|
| - NSSCKMDSlot **mdSlotList;
|
| - CK_BBOOL moduleHandlesSessionObjects;
|
| -
|
| - /*
|
| - * Everything above is set at creation time, and then not modified.
|
| - * The invariants the mutex protects are:
|
| - *
|
| - * 1) Each of the cached descriptions (versions, etc.) are in an
|
| - * internally consistant state.
|
| - *
|
| - * 2) The session handle hashes and count are consistant
|
| - *
|
| - * 3) The object handle hashes and count are consistant.
|
| - *
|
| - * I could use multiple locks, but let's wait to see if that's
|
| - * really necessary.
|
| - *
|
| - * Note that the calls accessing the cached descriptions will
|
| - * call the NSSCKMDInstance methods with the mutex locked. Those
|
| - * methods may then call the public NSSCKFWInstance routines.
|
| - * Those public routines only access the constant data above, so
|
| - * there's no problem. But be careful if you add to this object;
|
| - * mutexes are in general not reentrant, so don't create deadlock
|
| - * situations.
|
| - */
|
| -
|
| - CK_VERSION cryptokiVersion;
|
| - NSSUTF8 *manufacturerID;
|
| - NSSUTF8 *libraryDescription;
|
| - CK_VERSION libraryVersion;
|
| -
|
| - CK_ULONG lastSessionHandle;
|
| - nssCKFWHash *sessionHandleHash;
|
| -
|
| - CK_ULONG lastObjectHandle;
|
| - nssCKFWHash *objectHandleHash;
|
| + NSSCKFWMutex *mutex;
|
| + NSSArena *arena;
|
| + NSSCKMDInstance *mdInstance;
|
| + CK_C_INITIALIZE_ARGS_PTR pInitArgs;
|
| + CK_C_INITIALIZE_ARGS initArgs;
|
| + CryptokiLockingState LockingState;
|
| + CK_BBOOL mayCreatePthreads;
|
| + NSSUTF8 *configurationData;
|
| + CK_ULONG nSlots;
|
| + NSSCKFWSlot **fwSlotList;
|
| + NSSCKMDSlot **mdSlotList;
|
| + CK_BBOOL moduleHandlesSessionObjects;
|
| +
|
| + /*
|
| + * Everything above is set at creation time, and then not modified.
|
| + * The invariants the mutex protects are:
|
| + *
|
| + * 1) Each of the cached descriptions (versions, etc.) are in an
|
| + * internally consistant state.
|
| + *
|
| + * 2) The session handle hashes and count are consistant
|
| + *
|
| + * 3) The object handle hashes and count are consistant.
|
| + *
|
| + * I could use multiple locks, but let's wait to see if that's
|
| + * really necessary.
|
| + *
|
| + * Note that the calls accessing the cached descriptions will
|
| + * call the NSSCKMDInstance methods with the mutex locked. Those
|
| + * methods may then call the public NSSCKFWInstance routines.
|
| + * Those public routines only access the constant data above, so
|
| + * there's no problem. But be careful if you add to this object;
|
| + * mutexes are in general not reentrant, so don't create deadlock
|
| + * situations.
|
| + */
|
| +
|
| + CK_VERSION cryptokiVersion;
|
| + NSSUTF8 *manufacturerID;
|
| + NSSUTF8 *libraryDescription;
|
| + CK_VERSION libraryVersion;
|
| +
|
| + CK_ULONG lastSessionHandle;
|
| + nssCKFWHash *sessionHandleHash;
|
| +
|
| + CK_ULONG lastObjectHandle;
|
| + nssCKFWHash *objectHandleHash;
|
| };
|
|
|
| #ifdef DEBUG
|
| @@ -121,30 +121,24 @@ struct NSSCKFWInstanceStr {
|
| */
|
|
|
| static CK_RV
|
| -instance_add_pointer
|
| -(
|
| - const NSSCKFWInstance *fwInstance
|
| -)
|
| +instance_add_pointer(
|
| + const NSSCKFWInstance *fwInstance)
|
| {
|
| - return CKR_OK;
|
| + return CKR_OK;
|
| }
|
|
|
| static CK_RV
|
| -instance_remove_pointer
|
| -(
|
| - const NSSCKFWInstance *fwInstance
|
| -)
|
| +instance_remove_pointer(
|
| + const NSSCKFWInstance *fwInstance)
|
| {
|
| - return CKR_OK;
|
| + return CKR_OK;
|
| }
|
|
|
| NSS_IMPLEMENT CK_RV
|
| -nssCKFWInstance_verifyPointer
|
| -(
|
| - const NSSCKFWInstance *fwInstance
|
| -)
|
| +nssCKFWInstance_verifyPointer(
|
| + const NSSCKFWInstance *fwInstance)
|
| {
|
| - return CKR_OK;
|
| + return CKR_OK;
|
| }
|
|
|
| #endif /* DEBUG */
|
| @@ -154,191 +148,189 @@ nssCKFWInstance_verifyPointer
|
| *
|
| */
|
| NSS_IMPLEMENT NSSCKFWInstance *
|
| -nssCKFWInstance_Create
|
| -(
|
| - CK_C_INITIALIZE_ARGS_PTR pInitArgs,
|
| - CryptokiLockingState LockingState,
|
| - NSSCKMDInstance *mdInstance,
|
| - CK_RV *pError
|
| -)
|
| +nssCKFWInstance_Create(
|
| + CK_C_INITIALIZE_ARGS_PTR pInitArgs,
|
| + CryptokiLockingState LockingState,
|
| + NSSCKMDInstance *mdInstance,
|
| + CK_RV *pError)
|
| {
|
| - NSSCKFWInstance *fwInstance;
|
| - NSSArena *arena = (NSSArena *)NULL;
|
| - CK_ULONG i;
|
| - CK_BBOOL called_Initialize = CK_FALSE;
|
| + NSSCKFWInstance *fwInstance;
|
| + NSSArena *arena = (NSSArena *)NULL;
|
| + CK_ULONG i;
|
| + CK_BBOOL called_Initialize = CK_FALSE;
|
|
|
| #ifdef NSSDEBUG
|
| - if( (CK_RV)NULL == pError ) {
|
| - return (NSSCKFWInstance *)NULL;
|
| - }
|
| + if ((CK_RV)NULL == pError) {
|
| + return (NSSCKFWInstance *)NULL;
|
| + }
|
|
|
| - if (!mdInstance) {
|
| - *pError = CKR_ARGUMENTS_BAD;
|
| - return (NSSCKFWInstance *)NULL;
|
| - }
|
| + if (!mdInstance) {
|
| + *pError = CKR_ARGUMENTS_BAD;
|
| + return (NSSCKFWInstance *)NULL;
|
| + }
|
| #endif /* NSSDEBUG */
|
|
|
| - arena = NSSArena_Create();
|
| - if (!arena) {
|
| - *pError = CKR_HOST_MEMORY;
|
| - return (NSSCKFWInstance *)NULL;
|
| - }
|
| -
|
| - fwInstance = nss_ZNEW(arena, NSSCKFWInstance);
|
| - if (!fwInstance) {
|
| - goto nomem;
|
| - }
|
| -
|
| - fwInstance->arena = arena;
|
| - fwInstance->mdInstance = mdInstance;
|
| -
|
| - fwInstance->LockingState = LockingState;
|
| - if( (CK_C_INITIALIZE_ARGS_PTR)NULL != pInitArgs ) {
|
| - fwInstance->initArgs = *pInitArgs;
|
| - fwInstance->pInitArgs = &fwInstance->initArgs;
|
| - if( pInitArgs->flags & CKF_LIBRARY_CANT_CREATE_OS_THREADS ) {
|
| - fwInstance->mayCreatePthreads = CK_FALSE;
|
| + arena = NSSArena_Create();
|
| + if (!arena) {
|
| + *pError = CKR_HOST_MEMORY;
|
| + return (NSSCKFWInstance *)NULL;
|
| + }
|
| +
|
| + fwInstance = nss_ZNEW(arena, NSSCKFWInstance);
|
| + if (!fwInstance) {
|
| + goto nomem;
|
| + }
|
| +
|
| + fwInstance->arena = arena;
|
| + fwInstance->mdInstance = mdInstance;
|
| +
|
| + fwInstance->LockingState = LockingState;
|
| + if ((CK_C_INITIALIZE_ARGS_PTR)NULL != pInitArgs) {
|
| + fwInstance->initArgs = *pInitArgs;
|
| + fwInstance->pInitArgs = &fwInstance->initArgs;
|
| + if (pInitArgs->flags & CKF_LIBRARY_CANT_CREATE_OS_THREADS) {
|
| + fwInstance->mayCreatePthreads = CK_FALSE;
|
| + } else {
|
| + fwInstance->mayCreatePthreads = CK_TRUE;
|
| + }
|
| + fwInstance->configurationData = (NSSUTF8 *)(pInitArgs->pReserved);
|
| } else {
|
| - fwInstance->mayCreatePthreads = CK_TRUE;
|
| - }
|
| - fwInstance->configurationData = (NSSUTF8 *)(pInitArgs->pReserved);
|
| - } else {
|
| - fwInstance->mayCreatePthreads = CK_TRUE;
|
| - }
|
| -
|
| - fwInstance->mutex = nssCKFWMutex_Create(pInitArgs, LockingState, arena,
|
| - pError);
|
| - if (!fwInstance->mutex) {
|
| - if( CKR_OK == *pError ) {
|
| - *pError = CKR_GENERAL_ERROR;
|
| - }
|
| - goto loser;
|
| - }
|
| -
|
| - if (mdInstance->Initialize) {
|
| - *pError = mdInstance->Initialize(mdInstance, fwInstance, fwInstance->configurationData);
|
| - if( CKR_OK != *pError ) {
|
| - goto loser;
|
| - }
|
| -
|
| - called_Initialize = CK_TRUE;
|
| - }
|
| -
|
| - if (mdInstance->ModuleHandlesSessionObjects) {
|
| - fwInstance->moduleHandlesSessionObjects =
|
| - mdInstance->ModuleHandlesSessionObjects(mdInstance, fwInstance);
|
| - } else {
|
| - fwInstance->moduleHandlesSessionObjects = CK_FALSE;
|
| - }
|
| -
|
| - if (!mdInstance->GetNSlots) {
|
| - /* That routine is required */
|
| - *pError = CKR_GENERAL_ERROR;
|
| - goto loser;
|
| - }
|
| -
|
| - fwInstance->nSlots = mdInstance->GetNSlots(mdInstance, fwInstance, pError);
|
| - if( (CK_ULONG)0 == fwInstance->nSlots ) {
|
| - if( CKR_OK == *pError ) {
|
| - /* Zero is not a legitimate answer */
|
| - *pError = CKR_GENERAL_ERROR;
|
| - }
|
| - goto loser;
|
| - }
|
| -
|
| - fwInstance->fwSlotList = nss_ZNEWARRAY(arena, NSSCKFWSlot *, fwInstance->nSlots);
|
| - if( (NSSCKFWSlot **)NULL == fwInstance->fwSlotList ) {
|
| - goto nomem;
|
| - }
|
| -
|
| - fwInstance->mdSlotList = nss_ZNEWARRAY(arena, NSSCKMDSlot *, fwInstance->nSlots);
|
| - if( (NSSCKMDSlot **)NULL == fwInstance->mdSlotList ) {
|
| - goto nomem;
|
| - }
|
| -
|
| - fwInstance->sessionHandleHash = nssCKFWHash_Create(fwInstance,
|
| - fwInstance->arena, pError);
|
| - if (!fwInstance->sessionHandleHash) {
|
| - goto loser;
|
| - }
|
| -
|
| - fwInstance->objectHandleHash = nssCKFWHash_Create(fwInstance,
|
| - fwInstance->arena, pError);
|
| - if (!fwInstance->objectHandleHash) {
|
| - goto loser;
|
| - }
|
| -
|
| - if (!mdInstance->GetSlots) {
|
| - /* That routine is required */
|
| - *pError = CKR_GENERAL_ERROR;
|
| - goto loser;
|
| - }
|
| -
|
| - *pError = mdInstance->GetSlots(mdInstance, fwInstance, fwInstance->mdSlotList);
|
| - if( CKR_OK != *pError ) {
|
| - goto loser;
|
| - }
|
| -
|
| - for( i = 0; i < fwInstance->nSlots; i++ ) {
|
| - NSSCKMDSlot *mdSlot = fwInstance->mdSlotList[i];
|
| + fwInstance->mayCreatePthreads = CK_TRUE;
|
| + }
|
|
|
| - if (!mdSlot) {
|
| - *pError = CKR_GENERAL_ERROR;
|
| - goto loser;
|
| + fwInstance->mutex = nssCKFWMutex_Create(pInitArgs, LockingState, arena,
|
| + pError);
|
| + if (!fwInstance->mutex) {
|
| + if (CKR_OK == *pError) {
|
| + *pError = CKR_GENERAL_ERROR;
|
| + }
|
| + goto loser;
|
| + }
|
| +
|
| + if (mdInstance->Initialize) {
|
| + *pError = mdInstance->Initialize(mdInstance, fwInstance, fwInstance->configurationData);
|
| + if (CKR_OK != *pError) {
|
| + goto loser;
|
| + }
|
| +
|
| + called_Initialize = CK_TRUE;
|
| + }
|
| +
|
| + if (mdInstance->ModuleHandlesSessionObjects) {
|
| + fwInstance->moduleHandlesSessionObjects =
|
| + mdInstance->ModuleHandlesSessionObjects(mdInstance, fwInstance);
|
| + } else {
|
| + fwInstance->moduleHandlesSessionObjects = CK_FALSE;
|
| + }
|
| +
|
| + if (!mdInstance->GetNSlots) {
|
| + /* That routine is required */
|
| + *pError = CKR_GENERAL_ERROR;
|
| + goto loser;
|
| + }
|
| +
|
| + fwInstance->nSlots = mdInstance->GetNSlots(mdInstance, fwInstance, pError);
|
| + if ((CK_ULONG)0 == fwInstance->nSlots) {
|
| + if (CKR_OK == *pError) {
|
| + /* Zero is not a legitimate answer */
|
| + *pError = CKR_GENERAL_ERROR;
|
| + }
|
| + goto loser;
|
| }
|
|
|
| - fwInstance->fwSlotList[i] = nssCKFWSlot_Create(fwInstance, mdSlot, i, pError);
|
| - if( CKR_OK != *pError ) {
|
| - CK_ULONG j;
|
| + fwInstance->fwSlotList = nss_ZNEWARRAY(arena, NSSCKFWSlot *, fwInstance->nSlots);
|
| + if ((NSSCKFWSlot **)NULL == fwInstance->fwSlotList) {
|
| + goto nomem;
|
| + }
|
| +
|
| + fwInstance->mdSlotList = nss_ZNEWARRAY(arena, NSSCKMDSlot *, fwInstance->nSlots);
|
| + if ((NSSCKMDSlot **)NULL == fwInstance->mdSlotList) {
|
| + goto nomem;
|
| + }
|
|
|
| - for( j = 0; j < i; j++ ) {
|
| - (void)nssCKFWSlot_Destroy(fwInstance->fwSlotList[j]);
|
| - }
|
| + fwInstance->sessionHandleHash = nssCKFWHash_Create(fwInstance,
|
| + fwInstance->arena, pError);
|
| + if (!fwInstance->sessionHandleHash) {
|
| + goto loser;
|
| + }
|
|
|
| - for( j = i; j < fwInstance->nSlots; j++ ) {
|
| - NSSCKMDSlot *mds = fwInstance->mdSlotList[j];
|
| - if (mds->Destroy) {
|
| - mds->Destroy(mds, (NSSCKFWSlot *)NULL, mdInstance, fwInstance);
|
| + fwInstance->objectHandleHash = nssCKFWHash_Create(fwInstance,
|
| + fwInstance->arena, pError);
|
| + if (!fwInstance->objectHandleHash) {
|
| + goto loser;
|
| + }
|
| +
|
| + if (!mdInstance->GetSlots) {
|
| + /* That routine is required */
|
| + *pError = CKR_GENERAL_ERROR;
|
| + goto loser;
|
| + }
|
| +
|
| + *pError = mdInstance->GetSlots(mdInstance, fwInstance, fwInstance->mdSlotList);
|
| + if (CKR_OK != *pError) {
|
| + goto loser;
|
| + }
|
| +
|
| + for (i = 0; i < fwInstance->nSlots; i++) {
|
| + NSSCKMDSlot *mdSlot = fwInstance->mdSlotList[i];
|
| +
|
| + if (!mdSlot) {
|
| + *pError = CKR_GENERAL_ERROR;
|
| + goto loser;
|
| }
|
| - }
|
|
|
| - goto loser;
|
| + fwInstance->fwSlotList[i] = nssCKFWSlot_Create(fwInstance, mdSlot, i, pError);
|
| + if (CKR_OK != *pError) {
|
| + CK_ULONG j;
|
| +
|
| + for (j = 0; j < i; j++) {
|
| + (void)nssCKFWSlot_Destroy(fwInstance->fwSlotList[j]);
|
| + }
|
| +
|
| + for (j = i; j < fwInstance->nSlots; j++) {
|
| + NSSCKMDSlot *mds = fwInstance->mdSlotList[j];
|
| + if (mds->Destroy) {
|
| + mds->Destroy(mds, (NSSCKFWSlot *)NULL, mdInstance, fwInstance);
|
| + }
|
| + }
|
| +
|
| + goto loser;
|
| + }
|
| }
|
| - }
|
|
|
| #ifdef DEBUG
|
| - *pError = instance_add_pointer(fwInstance);
|
| - if( CKR_OK != *pError ) {
|
| - for( i = 0; i < fwInstance->nSlots; i++ ) {
|
| - (void)nssCKFWSlot_Destroy(fwInstance->fwSlotList[i]);
|
| - }
|
| -
|
| - goto loser;
|
| - }
|
| + *pError = instance_add_pointer(fwInstance);
|
| + if (CKR_OK != *pError) {
|
| + for (i = 0; i < fwInstance->nSlots; i++) {
|
| + (void)nssCKFWSlot_Destroy(fwInstance->fwSlotList[i]);
|
| + }
|
| +
|
| + goto loser;
|
| + }
|
| #endif /* DEBUG */
|
|
|
| - *pError = CKR_OK;
|
| - return fwInstance;
|
| + *pError = CKR_OK;
|
| + return fwInstance;
|
|
|
| - nomem:
|
| - *pError = CKR_HOST_MEMORY;
|
| - /*FALLTHROUGH*/
|
| - loser:
|
| +nomem:
|
| + *pError = CKR_HOST_MEMORY;
|
| + /*FALLTHROUGH*/
|
| +loser:
|
|
|
| - if( CK_TRUE == called_Initialize ) {
|
| - if (mdInstance->Finalize) {
|
| - mdInstance->Finalize(mdInstance, fwInstance);
|
| + if (CK_TRUE == called_Initialize) {
|
| + if (mdInstance->Finalize) {
|
| + mdInstance->Finalize(mdInstance, fwInstance);
|
| + }
|
| }
|
| - }
|
|
|
| - if (fwInstance && fwInstance->mutex) {
|
| - nssCKFWMutex_Destroy(fwInstance->mutex);
|
| - }
|
| + if (fwInstance && fwInstance->mutex) {
|
| + nssCKFWMutex_Destroy(fwInstance->mutex);
|
| + }
|
|
|
| - if (arena) {
|
| - (void)NSSArena_Destroy(arena);
|
| - }
|
| - return (NSSCKFWInstance *)NULL;
|
| + if (arena) {
|
| + (void)NSSArena_Destroy(arena);
|
| + }
|
| + return (NSSCKFWInstance *)NULL;
|
| }
|
|
|
| /*
|
| @@ -346,47 +338,45 @@ nssCKFWInstance_Create
|
| *
|
| */
|
| NSS_IMPLEMENT CK_RV
|
| -nssCKFWInstance_Destroy
|
| -(
|
| - NSSCKFWInstance *fwInstance
|
| -)
|
| +nssCKFWInstance_Destroy(
|
| + NSSCKFWInstance *fwInstance)
|
| {
|
| #ifdef NSSDEBUG
|
| - CK_RV error = CKR_OK;
|
| + CK_RV error = CKR_OK;
|
| #endif /* NSSDEBUG */
|
| - CK_ULONG i;
|
| + CK_ULONG i;
|
|
|
| #ifdef NSSDEBUG
|
| - error = nssCKFWInstance_verifyPointer(fwInstance);
|
| - if( CKR_OK != error ) {
|
| - return error;
|
| - }
|
| + error = nssCKFWInstance_verifyPointer(fwInstance);
|
| + if (CKR_OK != error) {
|
| + return error;
|
| + }
|
| #endif /* NSSDEBUG */
|
|
|
| - nssCKFWMutex_Destroy(fwInstance->mutex);
|
| + nssCKFWMutex_Destroy(fwInstance->mutex);
|
|
|
| - for( i = 0; i < fwInstance->nSlots; i++ ) {
|
| - (void)nssCKFWSlot_Destroy(fwInstance->fwSlotList[i]);
|
| - }
|
| + for (i = 0; i < fwInstance->nSlots; i++) {
|
| + (void)nssCKFWSlot_Destroy(fwInstance->fwSlotList[i]);
|
| + }
|
|
|
| - if (fwInstance->mdInstance->Finalize) {
|
| - fwInstance->mdInstance->Finalize(fwInstance->mdInstance, fwInstance);
|
| - }
|
| + if (fwInstance->mdInstance->Finalize) {
|
| + fwInstance->mdInstance->Finalize(fwInstance->mdInstance, fwInstance);
|
| + }
|
|
|
| - if (fwInstance->sessionHandleHash) {
|
| - nssCKFWHash_Destroy(fwInstance->sessionHandleHash);
|
| - }
|
| + if (fwInstance->sessionHandleHash) {
|
| + nssCKFWHash_Destroy(fwInstance->sessionHandleHash);
|
| + }
|
|
|
| - if (fwInstance->objectHandleHash) {
|
| - nssCKFWHash_Destroy(fwInstance->objectHandleHash);
|
| - }
|
| + if (fwInstance->objectHandleHash) {
|
| + nssCKFWHash_Destroy(fwInstance->objectHandleHash);
|
| + }
|
|
|
| #ifdef DEBUG
|
| - (void)instance_remove_pointer(fwInstance);
|
| + (void)instance_remove_pointer(fwInstance);
|
| #endif /* DEBUG */
|
|
|
| - (void)NSSArena_Destroy(fwInstance->arena);
|
| - return CKR_OK;
|
| + (void)NSSArena_Destroy(fwInstance->arena);
|
| + return CKR_OK;
|
| }
|
|
|
| /*
|
| @@ -394,18 +384,16 @@ nssCKFWInstance_Destroy
|
| *
|
| */
|
| NSS_IMPLEMENT NSSCKMDInstance *
|
| -nssCKFWInstance_GetMDInstance
|
| -(
|
| - NSSCKFWInstance *fwInstance
|
| -)
|
| +nssCKFWInstance_GetMDInstance(
|
| + NSSCKFWInstance *fwInstance)
|
| {
|
| #ifdef NSSDEBUG
|
| - if( CKR_OK != nssCKFWInstance_verifyPointer(fwInstance) ) {
|
| - return (NSSCKMDInstance *)NULL;
|
| - }
|
| + if (CKR_OK != nssCKFWInstance_verifyPointer(fwInstance)) {
|
| + return (NSSCKMDInstance *)NULL;
|
| + }
|
| #endif /* NSSDEBUG */
|
|
|
| - return fwInstance->mdInstance;
|
| + return fwInstance->mdInstance;
|
| }
|
|
|
| /*
|
| @@ -413,25 +401,23 @@ nssCKFWInstance_GetMDInstance
|
| *
|
| */
|
| NSS_IMPLEMENT NSSArena *
|
| -nssCKFWInstance_GetArena
|
| -(
|
| - NSSCKFWInstance *fwInstance,
|
| - CK_RV *pError
|
| -)
|
| +nssCKFWInstance_GetArena(
|
| + NSSCKFWInstance *fwInstance,
|
| + CK_RV *pError)
|
| {
|
| #ifdef NSSDEBUG
|
| - if (!pError) {
|
| - return (NSSArena *)NULL;
|
| - }
|
| -
|
| - *pError = nssCKFWInstance_verifyPointer(fwInstance);
|
| - if( CKR_OK != *pError ) {
|
| - return (NSSArena *)NULL;
|
| - }
|
| + if (!pError) {
|
| + return (NSSArena *)NULL;
|
| + }
|
| +
|
| + *pError = nssCKFWInstance_verifyPointer(fwInstance);
|
| + if (CKR_OK != *pError) {
|
| + return (NSSArena *)NULL;
|
| + }
|
| #endif /* NSSDEBUG */
|
|
|
| - *pError = CKR_OK;
|
| - return fwInstance->arena;
|
| + *pError = CKR_OK;
|
| + return fwInstance->arena;
|
| }
|
|
|
| /*
|
| @@ -439,18 +425,16 @@ nssCKFWInstance_GetArena
|
| *
|
| */
|
| NSS_IMPLEMENT CK_BBOOL
|
| -nssCKFWInstance_MayCreatePthreads
|
| -(
|
| - NSSCKFWInstance *fwInstance
|
| -)
|
| +nssCKFWInstance_MayCreatePthreads(
|
| + NSSCKFWInstance *fwInstance)
|
| {
|
| #ifdef NSSDEBUG
|
| - if( CKR_OK != nssCKFWInstance_verifyPointer(fwInstance) ) {
|
| - return CK_FALSE;
|
| - }
|
| + if (CKR_OK != nssCKFWInstance_verifyPointer(fwInstance)) {
|
| + return CK_FALSE;
|
| + }
|
| #endif /* NSSDEBUG */
|
|
|
| - return fwInstance->mayCreatePthreads;
|
| + return fwInstance->mayCreatePthreads;
|
| }
|
|
|
| /*
|
| @@ -458,37 +442,35 @@ nssCKFWInstance_MayCreatePthreads
|
| *
|
| */
|
| NSS_IMPLEMENT NSSCKFWMutex *
|
| -nssCKFWInstance_CreateMutex
|
| -(
|
| - NSSCKFWInstance *fwInstance,
|
| - NSSArena *arena,
|
| - CK_RV *pError
|
| -)
|
| +nssCKFWInstance_CreateMutex(
|
| + NSSCKFWInstance *fwInstance,
|
| + NSSArena *arena,
|
| + CK_RV *pError)
|
| {
|
| - NSSCKFWMutex *mutex;
|
| + NSSCKFWMutex *mutex;
|
|
|
| #ifdef NSSDEBUG
|
| - if (!pError) {
|
| - return (NSSCKFWMutex *)NULL;
|
| - }
|
| -
|
| - *pError = nssCKFWInstance_verifyPointer(fwInstance);
|
| - if( CKR_OK != *pError ) {
|
| - return (NSSCKFWMutex *)NULL;
|
| - }
|
| -#endif /* NSSDEBUG */
|
| + if (!pError) {
|
| + return (NSSCKFWMutex *)NULL;
|
| + }
|
|
|
| - mutex = nssCKFWMutex_Create(fwInstance->pInitArgs, fwInstance->LockingState,
|
| - arena, pError);
|
| - if (!mutex) {
|
| - if( CKR_OK == *pError ) {
|
| - *pError = CKR_GENERAL_ERROR;
|
| + *pError = nssCKFWInstance_verifyPointer(fwInstance);
|
| + if (CKR_OK != *pError) {
|
| + return (NSSCKFWMutex *)NULL;
|
| }
|
| +#endif /* NSSDEBUG */
|
|
|
| - return (NSSCKFWMutex *)NULL;
|
| - }
|
| + mutex = nssCKFWMutex_Create(fwInstance->pInitArgs, fwInstance->LockingState,
|
| + arena, pError);
|
| + if (!mutex) {
|
| + if (CKR_OK == *pError) {
|
| + *pError = CKR_GENERAL_ERROR;
|
| + }
|
| +
|
| + return (NSSCKFWMutex *)NULL;
|
| + }
|
|
|
| - return mutex;
|
| + return mutex;
|
| }
|
|
|
| /*
|
| @@ -496,18 +478,16 @@ nssCKFWInstance_CreateMutex
|
| *
|
| */
|
| NSS_IMPLEMENT NSSUTF8 *
|
| -nssCKFWInstance_GetConfigurationData
|
| -(
|
| - NSSCKFWInstance *fwInstance
|
| -)
|
| +nssCKFWInstance_GetConfigurationData(
|
| + NSSCKFWInstance *fwInstance)
|
| {
|
| #ifdef NSSDEBUG
|
| - if( CKR_OK != nssCKFWInstance_verifyPointer(fwInstance) ) {
|
| - return (NSSUTF8 *)NULL;
|
| - }
|
| + if (CKR_OK != nssCKFWInstance_verifyPointer(fwInstance)) {
|
| + return (NSSUTF8 *)NULL;
|
| + }
|
| #endif /* NSSDEBUG */
|
|
|
| - return fwInstance->configurationData;
|
| + return fwInstance->configurationData;
|
| }
|
|
|
| /*
|
| @@ -515,15 +495,13 @@ nssCKFWInstance_GetConfigurationData
|
| *
|
| */
|
| CK_C_INITIALIZE_ARGS_PTR
|
| -nssCKFWInstance_GetInitArgs
|
| -(
|
| - NSSCKFWInstance *fwInstance
|
| -)
|
| +nssCKFWInstance_GetInitArgs(
|
| + NSSCKFWInstance *fwInstance)
|
| {
|
| #ifdef NSSDEBUG
|
| - if( CKR_OK != nssCKFWInstance_verifyPointer(fwInstance) ) {
|
| - return (CK_C_INITIALIZE_ARGS_PTR)NULL;
|
| - }
|
| + if (CKR_OK != nssCKFWInstance_verifyPointer(fwInstance)) {
|
| + return (CK_C_INITIALIZE_ARGS_PTR)NULL;
|
| + }
|
| #endif /* NSSDEBUG */
|
|
|
| return fwInstance->pInitArgs;
|
| @@ -534,50 +512,48 @@ nssCKFWInstance_GetInitArgs
|
| *
|
| */
|
| NSS_IMPLEMENT CK_SESSION_HANDLE
|
| -nssCKFWInstance_CreateSessionHandle
|
| -(
|
| - NSSCKFWInstance *fwInstance,
|
| - NSSCKFWSession *fwSession,
|
| - CK_RV *pError
|
| -)
|
| +nssCKFWInstance_CreateSessionHandle(
|
| + NSSCKFWInstance *fwInstance,
|
| + NSSCKFWSession *fwSession,
|
| + CK_RV *pError)
|
| {
|
| - CK_SESSION_HANDLE hSession;
|
| + CK_SESSION_HANDLE hSession;
|
|
|
| #ifdef NSSDEBUG
|
| - if (!pError) {
|
| - return (CK_SESSION_HANDLE)0;
|
| - }
|
| -
|
| - *pError = nssCKFWInstance_verifyPointer(fwInstance);
|
| - if( CKR_OK != *pError ) {
|
| - return (CK_SESSION_HANDLE)0;
|
| - }
|
| + if (!pError) {
|
| + return (CK_SESSION_HANDLE)0;
|
| + }
|
| +
|
| + *pError = nssCKFWInstance_verifyPointer(fwInstance);
|
| + if (CKR_OK != *pError) {
|
| + return (CK_SESSION_HANDLE)0;
|
| + }
|
| #endif /* NSSDEBUG */
|
|
|
| - *pError = nssCKFWMutex_Lock(fwInstance->mutex);
|
| - if( CKR_OK != *pError ) {
|
| - return (CK_SESSION_HANDLE)0;
|
| - }
|
| -
|
| - hSession = ++(fwInstance->lastSessionHandle);
|
| -
|
| - /* Alan would say I should unlock for this call. */
|
| -
|
| - *pError = nssCKFWSession_SetHandle(fwSession, hSession);
|
| - if( CKR_OK != *pError ) {
|
| - goto done;
|
| - }
|
| -
|
| - *pError = nssCKFWHash_Add(fwInstance->sessionHandleHash,
|
| - (const void *)hSession, (const void *)fwSession);
|
| - if( CKR_OK != *pError ) {
|
| - hSession = (CK_SESSION_HANDLE)0;
|
| - goto done;
|
| - }
|
| -
|
| - done:
|
| - nssCKFWMutex_Unlock(fwInstance->mutex);
|
| - return hSession;
|
| + *pError = nssCKFWMutex_Lock(fwInstance->mutex);
|
| + if (CKR_OK != *pError) {
|
| + return (CK_SESSION_HANDLE)0;
|
| + }
|
| +
|
| + hSession = ++(fwInstance->lastSessionHandle);
|
| +
|
| + /* Alan would say I should unlock for this call. */
|
| +
|
| + *pError = nssCKFWSession_SetHandle(fwSession, hSession);
|
| + if (CKR_OK != *pError) {
|
| + goto done;
|
| + }
|
| +
|
| + *pError = nssCKFWHash_Add(fwInstance->sessionHandleHash,
|
| + (const void *)hSession, (const void *)fwSession);
|
| + if (CKR_OK != *pError) {
|
| + hSession = (CK_SESSION_HANDLE)0;
|
| + goto done;
|
| + }
|
| +
|
| +done:
|
| + nssCKFWMutex_Unlock(fwInstance->mutex);
|
| + return hSession;
|
| }
|
|
|
| /*
|
| @@ -585,32 +561,30 @@ nssCKFWInstance_CreateSessionHandle
|
| *
|
| */
|
| NSS_IMPLEMENT NSSCKFWSession *
|
| -nssCKFWInstance_ResolveSessionHandle
|
| -(
|
| - NSSCKFWInstance *fwInstance,
|
| - CK_SESSION_HANDLE hSession
|
| -)
|
| +nssCKFWInstance_ResolveSessionHandle(
|
| + NSSCKFWInstance *fwInstance,
|
| + CK_SESSION_HANDLE hSession)
|
| {
|
| - NSSCKFWSession *fwSession;
|
| + NSSCKFWSession *fwSession;
|
|
|
| #ifdef NSSDEBUG
|
| - if( CKR_OK != nssCKFWInstance_verifyPointer(fwInstance) ) {
|
| - return (NSSCKFWSession *)NULL;
|
| - }
|
| + if (CKR_OK != nssCKFWInstance_verifyPointer(fwInstance)) {
|
| + return (NSSCKFWSession *)NULL;
|
| + }
|
| #endif /* NSSDEBUG */
|
|
|
| - if( CKR_OK != nssCKFWMutex_Lock(fwInstance->mutex) ) {
|
| - return (NSSCKFWSession *)NULL;
|
| - }
|
| + if (CKR_OK != nssCKFWMutex_Lock(fwInstance->mutex)) {
|
| + return (NSSCKFWSession *)NULL;
|
| + }
|
|
|
| - fwSession = (NSSCKFWSession *)nssCKFWHash_Lookup(
|
| - fwInstance->sessionHandleHash, (const void *)hSession);
|
| + fwSession = (NSSCKFWSession *)nssCKFWHash_Lookup(
|
| + fwInstance->sessionHandleHash, (const void *)hSession);
|
|
|
| - /* Assert(hSession == nssCKFWSession_GetHandle(fwSession)) */
|
| + /* Assert(hSession == nssCKFWSession_GetHandle(fwSession)) */
|
|
|
| - (void)nssCKFWMutex_Unlock(fwInstance->mutex);
|
| + (void)nssCKFWMutex_Unlock(fwInstance->mutex);
|
|
|
| - return fwSession;
|
| + return fwSession;
|
| }
|
|
|
| /*
|
| @@ -618,34 +592,32 @@ nssCKFWInstance_ResolveSessionHandle
|
| *
|
| */
|
| NSS_IMPLEMENT void
|
| -nssCKFWInstance_DestroySessionHandle
|
| -(
|
| - NSSCKFWInstance *fwInstance,
|
| - CK_SESSION_HANDLE hSession
|
| -)
|
| +nssCKFWInstance_DestroySessionHandle(
|
| + NSSCKFWInstance *fwInstance,
|
| + CK_SESSION_HANDLE hSession)
|
| {
|
| - NSSCKFWSession *fwSession;
|
| + NSSCKFWSession *fwSession;
|
|
|
| #ifdef NSSDEBUG
|
| - if( CKR_OK != nssCKFWInstance_verifyPointer(fwInstance) ) {
|
| - return;
|
| - }
|
| + if (CKR_OK != nssCKFWInstance_verifyPointer(fwInstance)) {
|
| + return;
|
| + }
|
| #endif /* NSSDEBUG */
|
|
|
| - if( CKR_OK != nssCKFWMutex_Lock(fwInstance->mutex) ) {
|
| - return;
|
| - }
|
| + if (CKR_OK != nssCKFWMutex_Lock(fwInstance->mutex)) {
|
| + return;
|
| + }
|
|
|
| - fwSession = (NSSCKFWSession *)nssCKFWHash_Lookup(
|
| - fwInstance->sessionHandleHash, (const void *)hSession);
|
| - if (fwSession) {
|
| - nssCKFWHash_Remove(fwInstance->sessionHandleHash, (const void *)hSession);
|
| - nssCKFWSession_SetHandle(fwSession, (CK_SESSION_HANDLE)0);
|
| - }
|
| + fwSession = (NSSCKFWSession *)nssCKFWHash_Lookup(
|
| + fwInstance->sessionHandleHash, (const void *)hSession);
|
| + if (fwSession) {
|
| + nssCKFWHash_Remove(fwInstance->sessionHandleHash, (const void *)hSession);
|
| + nssCKFWSession_SetHandle(fwSession, (CK_SESSION_HANDLE)0);
|
| + }
|
|
|
| - (void)nssCKFWMutex_Unlock(fwInstance->mutex);
|
| + (void)nssCKFWMutex_Unlock(fwInstance->mutex);
|
|
|
| - return;
|
| + return;
|
| }
|
|
|
| /*
|
| @@ -653,24 +625,22 @@ nssCKFWInstance_DestroySessionHandle
|
| *
|
| */
|
| NSS_IMPLEMENT CK_SESSION_HANDLE
|
| -nssCKFWInstance_FindSessionHandle
|
| -(
|
| - NSSCKFWInstance *fwInstance,
|
| - NSSCKFWSession *fwSession
|
| -)
|
| +nssCKFWInstance_FindSessionHandle(
|
| + NSSCKFWInstance *fwInstance,
|
| + NSSCKFWSession *fwSession)
|
| {
|
| #ifdef NSSDEBUG
|
| - if( CKR_OK != nssCKFWInstance_verifyPointer(fwInstance) ) {
|
| - return (CK_SESSION_HANDLE)0;
|
| - }
|
| + if (CKR_OK != nssCKFWInstance_verifyPointer(fwInstance)) {
|
| + return (CK_SESSION_HANDLE)0;
|
| + }
|
|
|
| - if( CKR_OK != nssCKFWSession_verifyPointer(fwSession) ) {
|
| - return (CK_SESSION_HANDLE)0;
|
| - }
|
| + if (CKR_OK != nssCKFWSession_verifyPointer(fwSession)) {
|
| + return (CK_SESSION_HANDLE)0;
|
| + }
|
| #endif /* NSSDEBUG */
|
|
|
| - return nssCKFWSession_GetHandle(fwSession);
|
| - /* look it up and assert? */
|
| + return nssCKFWSession_GetHandle(fwSession);
|
| + /* look it up and assert? */
|
| }
|
|
|
| /*
|
| @@ -678,49 +648,47 @@ nssCKFWInstance_FindSessionHandle
|
| *
|
| */
|
| NSS_IMPLEMENT CK_OBJECT_HANDLE
|
| -nssCKFWInstance_CreateObjectHandle
|
| -(
|
| - NSSCKFWInstance *fwInstance,
|
| - NSSCKFWObject *fwObject,
|
| - CK_RV *pError
|
| -)
|
| +nssCKFWInstance_CreateObjectHandle(
|
| + NSSCKFWInstance *fwInstance,
|
| + NSSCKFWObject *fwObject,
|
| + CK_RV *pError)
|
| {
|
| - CK_OBJECT_HANDLE hObject;
|
| + CK_OBJECT_HANDLE hObject;
|
|
|
| #ifdef NSSDEBUG
|
| - if (!pError) {
|
| - return (CK_OBJECT_HANDLE)0;
|
| - }
|
| -
|
| - *pError = nssCKFWInstance_verifyPointer(fwInstance);
|
| - if( CKR_OK != *pError ) {
|
| - return (CK_OBJECT_HANDLE)0;
|
| - }
|
| + if (!pError) {
|
| + return (CK_OBJECT_HANDLE)0;
|
| + }
|
| +
|
| + *pError = nssCKFWInstance_verifyPointer(fwInstance);
|
| + if (CKR_OK != *pError) {
|
| + return (CK_OBJECT_HANDLE)0;
|
| + }
|
| #endif /* NSSDEBUG */
|
|
|
| - *pError = nssCKFWMutex_Lock(fwInstance->mutex);
|
| - if( CKR_OK != *pError ) {
|
| - return (CK_OBJECT_HANDLE)0;
|
| - }
|
| -
|
| - hObject = ++(fwInstance->lastObjectHandle);
|
| -
|
| - *pError = nssCKFWObject_SetHandle(fwObject, hObject);
|
| - if( CKR_OK != *pError ) {
|
| - hObject = (CK_OBJECT_HANDLE)0;
|
| - goto done;
|
| - }
|
| -
|
| - *pError = nssCKFWHash_Add(fwInstance->objectHandleHash,
|
| - (const void *)hObject, (const void *)fwObject);
|
| - if( CKR_OK != *pError ) {
|
| - hObject = (CK_OBJECT_HANDLE)0;
|
| - goto done;
|
| - }
|
| -
|
| - done:
|
| - (void)nssCKFWMutex_Unlock(fwInstance->mutex);
|
| - return hObject;
|
| + *pError = nssCKFWMutex_Lock(fwInstance->mutex);
|
| + if (CKR_OK != *pError) {
|
| + return (CK_OBJECT_HANDLE)0;
|
| + }
|
| +
|
| + hObject = ++(fwInstance->lastObjectHandle);
|
| +
|
| + *pError = nssCKFWObject_SetHandle(fwObject, hObject);
|
| + if (CKR_OK != *pError) {
|
| + hObject = (CK_OBJECT_HANDLE)0;
|
| + goto done;
|
| + }
|
| +
|
| + *pError = nssCKFWHash_Add(fwInstance->objectHandleHash,
|
| + (const void *)hObject, (const void *)fwObject);
|
| + if (CKR_OK != *pError) {
|
| + hObject = (CK_OBJECT_HANDLE)0;
|
| + goto done;
|
| + }
|
| +
|
| +done:
|
| + (void)nssCKFWMutex_Unlock(fwInstance->mutex);
|
| + return hObject;
|
| }
|
|
|
| /*
|
| @@ -728,31 +696,29 @@ nssCKFWInstance_CreateObjectHandle
|
| *
|
| */
|
| NSS_IMPLEMENT NSSCKFWObject *
|
| -nssCKFWInstance_ResolveObjectHandle
|
| -(
|
| - NSSCKFWInstance *fwInstance,
|
| - CK_OBJECT_HANDLE hObject
|
| -)
|
| +nssCKFWInstance_ResolveObjectHandle(
|
| + NSSCKFWInstance *fwInstance,
|
| + CK_OBJECT_HANDLE hObject)
|
| {
|
| - NSSCKFWObject *fwObject;
|
| + NSSCKFWObject *fwObject;
|
|
|
| #ifdef NSSDEBUG
|
| - if( CKR_OK != nssCKFWInstance_verifyPointer(fwInstance) ) {
|
| - return (NSSCKFWObject *)NULL;
|
| - }
|
| + if (CKR_OK != nssCKFWInstance_verifyPointer(fwInstance)) {
|
| + return (NSSCKFWObject *)NULL;
|
| + }
|
| #endif /* NSSDEBUG */
|
|
|
| - if( CKR_OK != nssCKFWMutex_Lock(fwInstance->mutex) ) {
|
| - return (NSSCKFWObject *)NULL;
|
| - }
|
| + if (CKR_OK != nssCKFWMutex_Lock(fwInstance->mutex)) {
|
| + return (NSSCKFWObject *)NULL;
|
| + }
|
|
|
| - fwObject = (NSSCKFWObject *)nssCKFWHash_Lookup(
|
| - fwInstance->objectHandleHash, (const void *)hObject);
|
| + fwObject = (NSSCKFWObject *)nssCKFWHash_Lookup(
|
| + fwInstance->objectHandleHash, (const void *)hObject);
|
|
|
| - /* Assert(hObject == nssCKFWObject_GetHandle(fwObject)) */
|
| + /* Assert(hObject == nssCKFWObject_GetHandle(fwObject)) */
|
|
|
| - (void)nssCKFWMutex_Unlock(fwInstance->mutex);
|
| - return fwObject;
|
| + (void)nssCKFWMutex_Unlock(fwInstance->mutex);
|
| + return fwObject;
|
| }
|
|
|
| /*
|
| @@ -760,46 +726,44 @@ nssCKFWInstance_ResolveObjectHandle
|
| *
|
| */
|
| NSS_IMPLEMENT CK_RV
|
| -nssCKFWInstance_ReassignObjectHandle
|
| -(
|
| - NSSCKFWInstance *fwInstance,
|
| - CK_OBJECT_HANDLE hObject,
|
| - NSSCKFWObject *fwObject
|
| -)
|
| +nssCKFWInstance_ReassignObjectHandle(
|
| + NSSCKFWInstance *fwInstance,
|
| + CK_OBJECT_HANDLE hObject,
|
| + NSSCKFWObject *fwObject)
|
| {
|
| - CK_RV error = CKR_OK;
|
| - NSSCKFWObject *oldObject;
|
| + CK_RV error = CKR_OK;
|
| + NSSCKFWObject *oldObject;
|
|
|
| #ifdef NSSDEBUG
|
| - error = nssCKFWInstance_verifyPointer(fwInstance);
|
| - if( CKR_OK != error ) {
|
| - return error;
|
| - }
|
| + error = nssCKFWInstance_verifyPointer(fwInstance);
|
| + if (CKR_OK != error) {
|
| + return error;
|
| + }
|
| #endif /* NSSDEBUG */
|
|
|
| - error = nssCKFWMutex_Lock(fwInstance->mutex);
|
| - if( CKR_OK != error ) {
|
| + error = nssCKFWMutex_Lock(fwInstance->mutex);
|
| + if (CKR_OK != error) {
|
| + return error;
|
| + }
|
| +
|
| + oldObject = (NSSCKFWObject *)nssCKFWHash_Lookup(
|
| + fwInstance->objectHandleHash, (const void *)hObject);
|
| + if (oldObject) {
|
| + /* Assert(hObject == nssCKFWObject_GetHandle(oldObject) */
|
| + (void)nssCKFWObject_SetHandle(oldObject, (CK_SESSION_HANDLE)0);
|
| + nssCKFWHash_Remove(fwInstance->objectHandleHash, (const void *)hObject);
|
| + }
|
| +
|
| + error = nssCKFWObject_SetHandle(fwObject, hObject);
|
| + if (CKR_OK != error) {
|
| + goto done;
|
| + }
|
| + error = nssCKFWHash_Add(fwInstance->objectHandleHash,
|
| + (const void *)hObject, (const void *)fwObject);
|
| +
|
| +done:
|
| + (void)nssCKFWMutex_Unlock(fwInstance->mutex);
|
| return error;
|
| - }
|
| -
|
| - oldObject = (NSSCKFWObject *)nssCKFWHash_Lookup(
|
| - fwInstance->objectHandleHash, (const void *)hObject);
|
| - if(oldObject) {
|
| - /* Assert(hObject == nssCKFWObject_GetHandle(oldObject) */
|
| - (void)nssCKFWObject_SetHandle(oldObject, (CK_SESSION_HANDLE)0);
|
| - nssCKFWHash_Remove(fwInstance->objectHandleHash, (const void *)hObject);
|
| - }
|
| -
|
| - error = nssCKFWObject_SetHandle(fwObject, hObject);
|
| - if( CKR_OK != error ) {
|
| - goto done;
|
| - }
|
| - error = nssCKFWHash_Add(fwInstance->objectHandleHash,
|
| - (const void *)hObject, (const void *)fwObject);
|
| -
|
| - done:
|
| - (void)nssCKFWMutex_Unlock(fwInstance->mutex);
|
| - return error;
|
| }
|
|
|
| /*
|
| @@ -807,34 +771,32 @@ nssCKFWInstance_ReassignObjectHandle
|
| *
|
| */
|
| NSS_IMPLEMENT void
|
| -nssCKFWInstance_DestroyObjectHandle
|
| -(
|
| - NSSCKFWInstance *fwInstance,
|
| - CK_OBJECT_HANDLE hObject
|
| -)
|
| +nssCKFWInstance_DestroyObjectHandle(
|
| + NSSCKFWInstance *fwInstance,
|
| + CK_OBJECT_HANDLE hObject)
|
| {
|
| - NSSCKFWObject *fwObject;
|
| + NSSCKFWObject *fwObject;
|
|
|
| #ifdef NSSDEBUG
|
| - if( CKR_OK != nssCKFWInstance_verifyPointer(fwInstance) ) {
|
| - return;
|
| - }
|
| + if (CKR_OK != nssCKFWInstance_verifyPointer(fwInstance)) {
|
| + return;
|
| + }
|
| #endif /* NSSDEBUG */
|
|
|
| - if( CKR_OK != nssCKFWMutex_Lock(fwInstance->mutex) ) {
|
| + if (CKR_OK != nssCKFWMutex_Lock(fwInstance->mutex)) {
|
| + return;
|
| + }
|
| +
|
| + fwObject = (NSSCKFWObject *)nssCKFWHash_Lookup(
|
| + fwInstance->objectHandleHash, (const void *)hObject);
|
| + if (fwObject) {
|
| + /* Assert(hObject = nssCKFWObject_GetHandle(fwObject)) */
|
| + nssCKFWHash_Remove(fwInstance->objectHandleHash, (const void *)hObject);
|
| + (void)nssCKFWObject_SetHandle(fwObject, (CK_SESSION_HANDLE)0);
|
| + }
|
| +
|
| + (void)nssCKFWMutex_Unlock(fwInstance->mutex);
|
| return;
|
| - }
|
| -
|
| - fwObject = (NSSCKFWObject *)nssCKFWHash_Lookup(
|
| - fwInstance->objectHandleHash, (const void *)hObject);
|
| - if (fwObject) {
|
| - /* Assert(hObject = nssCKFWObject_GetHandle(fwObject)) */
|
| - nssCKFWHash_Remove(fwInstance->objectHandleHash, (const void *)hObject);
|
| - (void)nssCKFWObject_SetHandle(fwObject, (CK_SESSION_HANDLE)0);
|
| - }
|
| -
|
| - (void)nssCKFWMutex_Unlock(fwInstance->mutex);
|
| - return;
|
| }
|
|
|
| /*
|
| @@ -842,23 +804,21 @@ nssCKFWInstance_DestroyObjectHandle
|
| *
|
| */
|
| NSS_IMPLEMENT CK_OBJECT_HANDLE
|
| -nssCKFWInstance_FindObjectHandle
|
| -(
|
| - NSSCKFWInstance *fwInstance,
|
| - NSSCKFWObject *fwObject
|
| -)
|
| +nssCKFWInstance_FindObjectHandle(
|
| + NSSCKFWInstance *fwInstance,
|
| + NSSCKFWObject *fwObject)
|
| {
|
| #ifdef NSSDEBUG
|
| - if( CKR_OK != nssCKFWInstance_verifyPointer(fwInstance) ) {
|
| - return (CK_OBJECT_HANDLE)0;
|
| - }
|
| + if (CKR_OK != nssCKFWInstance_verifyPointer(fwInstance)) {
|
| + return (CK_OBJECT_HANDLE)0;
|
| + }
|
|
|
| - if( CKR_OK != nssCKFWObject_verifyPointer(fwObject) ) {
|
| - return (CK_OBJECT_HANDLE)0;
|
| - }
|
| + if (CKR_OK != nssCKFWObject_verifyPointer(fwObject)) {
|
| + return (CK_OBJECT_HANDLE)0;
|
| + }
|
| #endif /* NSSDEBUG */
|
| -
|
| - return nssCKFWObject_GetHandle(fwObject);
|
| +
|
| + return nssCKFWObject_GetHandle(fwObject);
|
| }
|
|
|
| /*
|
| @@ -866,70 +826,66 @@ nssCKFWInstance_FindObjectHandle
|
| *
|
| */
|
| NSS_IMPLEMENT CK_ULONG
|
| -nssCKFWInstance_GetNSlots
|
| -(
|
| - NSSCKFWInstance *fwInstance,
|
| - CK_RV *pError
|
| -)
|
| +nssCKFWInstance_GetNSlots(
|
| + NSSCKFWInstance *fwInstance,
|
| + CK_RV *pError)
|
| {
|
| #ifdef NSSDEBUG
|
| - if (!pError) {
|
| - return (CK_ULONG)0;
|
| - }
|
| + if (!pError) {
|
| + return (CK_ULONG)0;
|
| + }
|
|
|
| - *pError = nssCKFWInstance_verifyPointer(fwInstance);
|
| - if( CKR_OK != *pError ) {
|
| - return (CK_ULONG)0;
|
| - }
|
| + *pError = nssCKFWInstance_verifyPointer(fwInstance);
|
| + if (CKR_OK != *pError) {
|
| + return (CK_ULONG)0;
|
| + }
|
| #endif /* NSSDEBUG */
|
|
|
| - *pError = CKR_OK;
|
| - return fwInstance->nSlots;
|
| -}
|
| + *pError = CKR_OK;
|
| + return fwInstance->nSlots;
|
| +}
|
|
|
| /*
|
| * nssCKFWInstance_GetCryptokiVersion
|
| *
|
| */
|
| NSS_IMPLEMENT CK_VERSION
|
| -nssCKFWInstance_GetCryptokiVersion
|
| -(
|
| - NSSCKFWInstance *fwInstance
|
| -)
|
| +nssCKFWInstance_GetCryptokiVersion(
|
| + NSSCKFWInstance *fwInstance)
|
| {
|
| - CK_VERSION rv;
|
| + CK_VERSION rv;
|
|
|
| #ifdef NSSDEBUG
|
| - if( CKR_OK != nssCKFWInstance_verifyPointer(fwInstance) ) {
|
| - rv.major = rv.minor = 0;
|
| - return rv;
|
| - }
|
| + if (CKR_OK != nssCKFWInstance_verifyPointer(fwInstance)) {
|
| + rv.major = rv.minor = 0;
|
| + return rv;
|
| + }
|
| #endif /* NSSDEBUG */
|
|
|
| - if( CKR_OK != nssCKFWMutex_Lock(fwInstance->mutex) ) {
|
| - rv.major = rv.minor = 0;
|
| - return rv;
|
| - }
|
| + if (CKR_OK != nssCKFWMutex_Lock(fwInstance->mutex)) {
|
| + rv.major = rv.minor = 0;
|
| + return rv;
|
| + }
|
| +
|
| + if ((0 != fwInstance->cryptokiVersion.major) ||
|
| + (0 != fwInstance->cryptokiVersion.minor)) {
|
| + rv = fwInstance->cryptokiVersion;
|
| + goto done;
|
| + }
|
| +
|
| + if (fwInstance->mdInstance->GetCryptokiVersion) {
|
| + fwInstance->cryptokiVersion = fwInstance->mdInstance->GetCryptokiVersion(
|
| + fwInstance->mdInstance, fwInstance);
|
| + } else {
|
| + fwInstance->cryptokiVersion.major = 2;
|
| + fwInstance->cryptokiVersion.minor = 1;
|
| + }
|
|
|
| - if( (0 != fwInstance->cryptokiVersion.major) ||
|
| - (0 != fwInstance->cryptokiVersion.minor) ) {
|
| rv = fwInstance->cryptokiVersion;
|
| - goto done;
|
| - }
|
| -
|
| - if (fwInstance->mdInstance->GetCryptokiVersion) {
|
| - fwInstance->cryptokiVersion = fwInstance->mdInstance->GetCryptokiVersion(
|
| - fwInstance->mdInstance, fwInstance);
|
| - } else {
|
| - fwInstance->cryptokiVersion.major = 2;
|
| - fwInstance->cryptokiVersion.minor = 1;
|
| - }
|
| -
|
| - rv = fwInstance->cryptokiVersion;
|
| -
|
| - done:
|
| - (void)nssCKFWMutex_Unlock(fwInstance->mutex);
|
| - return rv;
|
| +
|
| +done:
|
| + (void)nssCKFWMutex_Unlock(fwInstance->mutex);
|
| + return rv;
|
| }
|
|
|
| /*
|
| @@ -937,48 +893,46 @@ nssCKFWInstance_GetCryptokiVersion
|
| *
|
| */
|
| NSS_IMPLEMENT CK_RV
|
| -nssCKFWInstance_GetManufacturerID
|
| -(
|
| - NSSCKFWInstance *fwInstance,
|
| - CK_CHAR manufacturerID[32]
|
| -)
|
| +nssCKFWInstance_GetManufacturerID(
|
| + NSSCKFWInstance *fwInstance,
|
| + CK_CHAR manufacturerID[32])
|
| {
|
| - CK_RV error = CKR_OK;
|
| + CK_RV error = CKR_OK;
|
|
|
| #ifdef NSSDEBUG
|
| - if( (CK_CHAR_PTR)NULL == manufacturerID ) {
|
| - return CKR_ARGUMENTS_BAD;
|
| - }
|
| + if ((CK_CHAR_PTR)NULL == manufacturerID) {
|
| + return CKR_ARGUMENTS_BAD;
|
| + }
|
|
|
| - error = nssCKFWInstance_verifyPointer(fwInstance);
|
| - if( CKR_OK != error ) {
|
| - return error;
|
| - }
|
| + error = nssCKFWInstance_verifyPointer(fwInstance);
|
| + if (CKR_OK != error) {
|
| + return error;
|
| + }
|
| #endif /* NSSDEBUG */
|
|
|
| - error = nssCKFWMutex_Lock(fwInstance->mutex);
|
| - if( CKR_OK != error ) {
|
| - return error;
|
| - }
|
| + error = nssCKFWMutex_Lock(fwInstance->mutex);
|
| + if (CKR_OK != error) {
|
| + return error;
|
| + }
|
|
|
| - if (!fwInstance->manufacturerID) {
|
| - if (fwInstance->mdInstance->GetManufacturerID) {
|
| - fwInstance->manufacturerID = fwInstance->mdInstance->GetManufacturerID(
|
| - fwInstance->mdInstance, fwInstance, &error);
|
| - if ((!fwInstance->manufacturerID) && (CKR_OK != error)) {
|
| - goto done;
|
| - }
|
| - } else {
|
| - fwInstance->manufacturerID = (NSSUTF8 *) "";
|
| + if (!fwInstance->manufacturerID) {
|
| + if (fwInstance->mdInstance->GetManufacturerID) {
|
| + fwInstance->manufacturerID = fwInstance->mdInstance->GetManufacturerID(
|
| + fwInstance->mdInstance, fwInstance, &error);
|
| + if ((!fwInstance->manufacturerID) && (CKR_OK != error)) {
|
| + goto done;
|
| + }
|
| + } else {
|
| + fwInstance->manufacturerID = (NSSUTF8 *)"";
|
| + }
|
| }
|
| - }
|
|
|
| - (void)nssUTF8_CopyIntoFixedBuffer(fwInstance->manufacturerID, (char *)manufacturerID, 32, ' ');
|
| - error = CKR_OK;
|
| + (void)nssUTF8_CopyIntoFixedBuffer(fwInstance->manufacturerID, (char *)manufacturerID, 32, ' ');
|
| + error = CKR_OK;
|
|
|
| - done:
|
| - (void)nssCKFWMutex_Unlock(fwInstance->mutex);
|
| - return error;
|
| +done:
|
| + (void)nssCKFWMutex_Unlock(fwInstance->mutex);
|
| + return error;
|
| }
|
|
|
| /*
|
| @@ -986,19 +940,17 @@ nssCKFWInstance_GetManufacturerID
|
| *
|
| */
|
| NSS_IMPLEMENT CK_ULONG
|
| -nssCKFWInstance_GetFlags
|
| -(
|
| - NSSCKFWInstance *fwInstance
|
| -)
|
| +nssCKFWInstance_GetFlags(
|
| + NSSCKFWInstance *fwInstance)
|
| {
|
| #ifdef NSSDEBUG
|
| - if( CKR_OK != nssCKFWInstance_verifyPointer(fwInstance) ) {
|
| - return (CK_ULONG)0;
|
| - }
|
| + if (CKR_OK != nssCKFWInstance_verifyPointer(fwInstance)) {
|
| + return (CK_ULONG)0;
|
| + }
|
| #endif /* NSSDEBUG */
|
|
|
| - /* No "instance flags" are yet defined by Cryptoki. */
|
| - return (CK_ULONG)0;
|
| + /* No "instance flags" are yet defined by Cryptoki. */
|
| + return (CK_ULONG)0;
|
| }
|
|
|
| /*
|
| @@ -1006,48 +958,46 @@ nssCKFWInstance_GetFlags
|
| *
|
| */
|
| NSS_IMPLEMENT CK_RV
|
| -nssCKFWInstance_GetLibraryDescription
|
| -(
|
| - NSSCKFWInstance *fwInstance,
|
| - CK_CHAR libraryDescription[32]
|
| -)
|
| +nssCKFWInstance_GetLibraryDescription(
|
| + NSSCKFWInstance *fwInstance,
|
| + CK_CHAR libraryDescription[32])
|
| {
|
| - CK_RV error = CKR_OK;
|
| + CK_RV error = CKR_OK;
|
|
|
| #ifdef NSSDEBUG
|
| - if( (CK_CHAR_PTR)NULL == libraryDescription ) {
|
| - return CKR_ARGUMENTS_BAD;
|
| - }
|
| + if ((CK_CHAR_PTR)NULL == libraryDescription) {
|
| + return CKR_ARGUMENTS_BAD;
|
| + }
|
|
|
| - error = nssCKFWInstance_verifyPointer(fwInstance);
|
| - if( CKR_OK != error ) {
|
| - return error;
|
| - }
|
| + error = nssCKFWInstance_verifyPointer(fwInstance);
|
| + if (CKR_OK != error) {
|
| + return error;
|
| + }
|
| #endif /* NSSDEBUG */
|
|
|
| - error = nssCKFWMutex_Lock(fwInstance->mutex);
|
| - if( CKR_OK != error ) {
|
| - return error;
|
| - }
|
| + error = nssCKFWMutex_Lock(fwInstance->mutex);
|
| + if (CKR_OK != error) {
|
| + return error;
|
| + }
|
|
|
| - if (!fwInstance->libraryDescription) {
|
| - if (fwInstance->mdInstance->GetLibraryDescription) {
|
| - fwInstance->libraryDescription = fwInstance->mdInstance->GetLibraryDescription(
|
| - fwInstance->mdInstance, fwInstance, &error);
|
| - if ((!fwInstance->libraryDescription) && (CKR_OK != error)) {
|
| - goto done;
|
| - }
|
| - } else {
|
| - fwInstance->libraryDescription = (NSSUTF8 *) "";
|
| + if (!fwInstance->libraryDescription) {
|
| + if (fwInstance->mdInstance->GetLibraryDescription) {
|
| + fwInstance->libraryDescription = fwInstance->mdInstance->GetLibraryDescription(
|
| + fwInstance->mdInstance, fwInstance, &error);
|
| + if ((!fwInstance->libraryDescription) && (CKR_OK != error)) {
|
| + goto done;
|
| + }
|
| + } else {
|
| + fwInstance->libraryDescription = (NSSUTF8 *)"";
|
| + }
|
| }
|
| - }
|
|
|
| - (void)nssUTF8_CopyIntoFixedBuffer(fwInstance->libraryDescription, (char *)libraryDescription, 32, ' ');
|
| - error = CKR_OK;
|
| + (void)nssUTF8_CopyIntoFixedBuffer(fwInstance->libraryDescription, (char *)libraryDescription, 32, ' ');
|
| + error = CKR_OK;
|
|
|
| - done:
|
| - (void)nssCKFWMutex_Unlock(fwInstance->mutex);
|
| - return error;
|
| +done:
|
| + (void)nssCKFWMutex_Unlock(fwInstance->mutex);
|
| + return error;
|
| }
|
|
|
| /*
|
| @@ -1055,43 +1005,41 @@ nssCKFWInstance_GetLibraryDescription
|
| *
|
| */
|
| NSS_IMPLEMENT CK_VERSION
|
| -nssCKFWInstance_GetLibraryVersion
|
| -(
|
| - NSSCKFWInstance *fwInstance
|
| -)
|
| +nssCKFWInstance_GetLibraryVersion(
|
| + NSSCKFWInstance *fwInstance)
|
| {
|
| - CK_VERSION rv;
|
| + CK_VERSION rv;
|
|
|
| #ifdef NSSDEBUG
|
| - if( CKR_OK != nssCKFWInstance_verifyPointer(fwInstance) ) {
|
| - rv.major = rv.minor = 0;
|
| - return rv;
|
| - }
|
| + if (CKR_OK != nssCKFWInstance_verifyPointer(fwInstance)) {
|
| + rv.major = rv.minor = 0;
|
| + return rv;
|
| + }
|
| #endif /* NSSDEBUG */
|
|
|
| - if( CKR_OK != nssCKFWMutex_Lock(fwInstance->mutex) ) {
|
| - rv.major = rv.minor = 0;
|
| - return rv;
|
| - }
|
| + if (CKR_OK != nssCKFWMutex_Lock(fwInstance->mutex)) {
|
| + rv.major = rv.minor = 0;
|
| + return rv;
|
| + }
|
| +
|
| + if ((0 != fwInstance->libraryVersion.major) ||
|
| + (0 != fwInstance->libraryVersion.minor)) {
|
| + rv = fwInstance->libraryVersion;
|
| + goto done;
|
| + }
|
| +
|
| + if (fwInstance->mdInstance->GetLibraryVersion) {
|
| + fwInstance->libraryVersion = fwInstance->mdInstance->GetLibraryVersion(
|
| + fwInstance->mdInstance, fwInstance);
|
| + } else {
|
| + fwInstance->libraryVersion.major = 0;
|
| + fwInstance->libraryVersion.minor = 3;
|
| + }
|
|
|
| - if( (0 != fwInstance->libraryVersion.major) ||
|
| - (0 != fwInstance->libraryVersion.minor) ) {
|
| rv = fwInstance->libraryVersion;
|
| - goto done;
|
| - }
|
| -
|
| - if (fwInstance->mdInstance->GetLibraryVersion) {
|
| - fwInstance->libraryVersion = fwInstance->mdInstance->GetLibraryVersion(
|
| - fwInstance->mdInstance, fwInstance);
|
| - } else {
|
| - fwInstance->libraryVersion.major = 0;
|
| - fwInstance->libraryVersion.minor = 3;
|
| - }
|
| -
|
| - rv = fwInstance->libraryVersion;
|
| - done:
|
| - (void)nssCKFWMutex_Unlock(fwInstance->mutex);
|
| - return rv;
|
| +done:
|
| + (void)nssCKFWMutex_Unlock(fwInstance->mutex);
|
| + return rv;
|
| }
|
|
|
| /*
|
| @@ -1099,18 +1047,16 @@ nssCKFWInstance_GetLibraryVersion
|
| *
|
| */
|
| NSS_IMPLEMENT CK_BBOOL
|
| -nssCKFWInstance_GetModuleHandlesSessionObjects
|
| -(
|
| - NSSCKFWInstance *fwInstance
|
| -)
|
| +nssCKFWInstance_GetModuleHandlesSessionObjects(
|
| + NSSCKFWInstance *fwInstance)
|
| {
|
| #ifdef NSSDEBUG
|
| - if( CKR_OK != nssCKFWInstance_verifyPointer(fwInstance) ) {
|
| - return CK_FALSE;
|
| - }
|
| + if (CKR_OK != nssCKFWInstance_verifyPointer(fwInstance)) {
|
| + return CK_FALSE;
|
| + }
|
| #endif /* NSSDEBUG */
|
|
|
| - return fwInstance->moduleHandlesSessionObjects;
|
| + return fwInstance->moduleHandlesSessionObjects;
|
| }
|
|
|
| /*
|
| @@ -1118,24 +1064,22 @@ nssCKFWInstance_GetModuleHandlesSessionObjects
|
| *
|
| */
|
| NSS_IMPLEMENT NSSCKFWSlot **
|
| -nssCKFWInstance_GetSlots
|
| -(
|
| - NSSCKFWInstance *fwInstance,
|
| - CK_RV *pError
|
| -)
|
| +nssCKFWInstance_GetSlots(
|
| + NSSCKFWInstance *fwInstance,
|
| + CK_RV *pError)
|
| {
|
| #ifdef NSSDEBUG
|
| - if (!pError) {
|
| - return (NSSCKFWSlot **)NULL;
|
| - }
|
| -
|
| - *pError = nssCKFWInstance_verifyPointer(fwInstance);
|
| - if( CKR_OK != *pError ) {
|
| - return (NSSCKFWSlot **)NULL;
|
| - }
|
| + if (!pError) {
|
| + return (NSSCKFWSlot **)NULL;
|
| + }
|
| +
|
| + *pError = nssCKFWInstance_verifyPointer(fwInstance);
|
| + if (CKR_OK != *pError) {
|
| + return (NSSCKFWSlot **)NULL;
|
| + }
|
| #endif /* NSSDEBUG */
|
|
|
| - return fwInstance->fwSlotList;
|
| + return fwInstance->fwSlotList;
|
| }
|
|
|
| /*
|
| @@ -1143,72 +1087,69 @@ nssCKFWInstance_GetSlots
|
| *
|
| */
|
| NSS_IMPLEMENT NSSCKFWSlot *
|
| -nssCKFWInstance_WaitForSlotEvent
|
| -(
|
| - NSSCKFWInstance *fwInstance,
|
| - CK_BBOOL block,
|
| - CK_RV *pError
|
| -)
|
| +nssCKFWInstance_WaitForSlotEvent(
|
| + NSSCKFWInstance *fwInstance,
|
| + CK_BBOOL block,
|
| + CK_RV *pError)
|
| {
|
| - NSSCKFWSlot *fwSlot = (NSSCKFWSlot *)NULL;
|
| - NSSCKMDSlot *mdSlot;
|
| - CK_ULONG i, n;
|
| + NSSCKFWSlot *fwSlot = (NSSCKFWSlot *)NULL;
|
| + NSSCKMDSlot *mdSlot;
|
| + CK_ULONG i, n;
|
|
|
| #ifdef NSSDEBUG
|
| - if (!pError) {
|
| - return (NSSCKFWSlot *)NULL;
|
| - }
|
| -
|
| - *pError = nssCKFWInstance_verifyPointer(fwInstance);
|
| - if( CKR_OK != *pError ) {
|
| - return (NSSCKFWSlot *)NULL;
|
| - }
|
| -
|
| - switch( block ) {
|
| - case CK_TRUE:
|
| - case CK_FALSE:
|
| - break;
|
| - default:
|
| - *pError = CKR_ARGUMENTS_BAD;
|
| - return (NSSCKFWSlot *)NULL;
|
| - }
|
| + if (!pError) {
|
| + return (NSSCKFWSlot *)NULL;
|
| + }
|
| +
|
| + *pError = nssCKFWInstance_verifyPointer(fwInstance);
|
| + if (CKR_OK != *pError) {
|
| + return (NSSCKFWSlot *)NULL;
|
| + }
|
| +
|
| + switch (block) {
|
| + case CK_TRUE:
|
| + case CK_FALSE:
|
| + break;
|
| + default:
|
| + *pError = CKR_ARGUMENTS_BAD;
|
| + return (NSSCKFWSlot *)NULL;
|
| + }
|
| #endif /* NSSDEBUG */
|
|
|
| - if (!fwInstance->mdInstance->WaitForSlotEvent) {
|
| - *pError = CKR_NO_EVENT;
|
| - return (NSSCKFWSlot *)NULL;
|
| - }
|
| -
|
| - mdSlot = fwInstance->mdInstance->WaitForSlotEvent(
|
| - fwInstance->mdInstance,
|
| - fwInstance,
|
| - block,
|
| - pError
|
| - );
|
| -
|
| - if (!mdSlot) {
|
| - return (NSSCKFWSlot *)NULL;
|
| - }
|
| -
|
| - n = nssCKFWInstance_GetNSlots(fwInstance, pError);
|
| - if( ((CK_ULONG)0 == n) && (CKR_OK != *pError) ) {
|
| - return (NSSCKFWSlot *)NULL;
|
| - }
|
| -
|
| - for( i = 0; i < n; i++ ) {
|
| - if( fwInstance->mdSlotList[i] == mdSlot ) {
|
| - fwSlot = fwInstance->fwSlotList[i];
|
| - break;
|
| - }
|
| - }
|
| -
|
| - if (!fwSlot) {
|
| - /* Internal error */
|
| - *pError = CKR_GENERAL_ERROR;
|
| - return (NSSCKFWSlot *)NULL;
|
| - }
|
| -
|
| - return fwSlot;
|
| + if (!fwInstance->mdInstance->WaitForSlotEvent) {
|
| + *pError = CKR_NO_EVENT;
|
| + return (NSSCKFWSlot *)NULL;
|
| + }
|
| +
|
| + mdSlot = fwInstance->mdInstance->WaitForSlotEvent(
|
| + fwInstance->mdInstance,
|
| + fwInstance,
|
| + block,
|
| + pError);
|
| +
|
| + if (!mdSlot) {
|
| + return (NSSCKFWSlot *)NULL;
|
| + }
|
| +
|
| + n = nssCKFWInstance_GetNSlots(fwInstance, pError);
|
| + if (((CK_ULONG)0 == n) && (CKR_OK != *pError)) {
|
| + return (NSSCKFWSlot *)NULL;
|
| + }
|
| +
|
| + for (i = 0; i < n; i++) {
|
| + if (fwInstance->mdSlotList[i] == mdSlot) {
|
| + fwSlot = fwInstance->fwSlotList[i];
|
| + break;
|
| + }
|
| + }
|
| +
|
| + if (!fwSlot) {
|
| + /* Internal error */
|
| + *pError = CKR_GENERAL_ERROR;
|
| + return (NSSCKFWSlot *)NULL;
|
| + }
|
| +
|
| + return fwSlot;
|
| }
|
|
|
| /*
|
| @@ -1216,18 +1157,16 @@ nssCKFWInstance_WaitForSlotEvent
|
| *
|
| */
|
| NSS_IMPLEMENT NSSCKMDInstance *
|
| -NSSCKFWInstance_GetMDInstance
|
| -(
|
| - NSSCKFWInstance *fwInstance
|
| -)
|
| +NSSCKFWInstance_GetMDInstance(
|
| + NSSCKFWInstance *fwInstance)
|
| {
|
| #ifdef DEBUG
|
| - if( CKR_OK != nssCKFWInstance_verifyPointer(fwInstance) ) {
|
| - return (NSSCKMDInstance *)NULL;
|
| - }
|
| + if (CKR_OK != nssCKFWInstance_verifyPointer(fwInstance)) {
|
| + return (NSSCKMDInstance *)NULL;
|
| + }
|
| #endif /* DEBUG */
|
|
|
| - return nssCKFWInstance_GetMDInstance(fwInstance);
|
| + return nssCKFWInstance_GetMDInstance(fwInstance);
|
| }
|
|
|
| /*
|
| @@ -1235,24 +1174,22 @@ NSSCKFWInstance_GetMDInstance
|
| *
|
| */
|
| NSS_IMPLEMENT NSSArena *
|
| -NSSCKFWInstance_GetArena
|
| -(
|
| - NSSCKFWInstance *fwInstance,
|
| - CK_RV *pError
|
| -)
|
| +NSSCKFWInstance_GetArena(
|
| + NSSCKFWInstance *fwInstance,
|
| + CK_RV *pError)
|
| {
|
| #ifdef DEBUG
|
| - if (!pError) {
|
| - return (NSSArena *)NULL;
|
| - }
|
| -
|
| - *pError = nssCKFWInstance_verifyPointer(fwInstance);
|
| - if( CKR_OK != *pError ) {
|
| - return (NSSArena *)NULL;
|
| - }
|
| + if (!pError) {
|
| + return (NSSArena *)NULL;
|
| + }
|
| +
|
| + *pError = nssCKFWInstance_verifyPointer(fwInstance);
|
| + if (CKR_OK != *pError) {
|
| + return (NSSArena *)NULL;
|
| + }
|
| #endif /* DEBUG */
|
|
|
| - return nssCKFWInstance_GetArena(fwInstance, pError);
|
| + return nssCKFWInstance_GetArena(fwInstance, pError);
|
| }
|
|
|
| /*
|
| @@ -1260,18 +1197,16 @@ NSSCKFWInstance_GetArena
|
| *
|
| */
|
| NSS_IMPLEMENT CK_BBOOL
|
| -NSSCKFWInstance_MayCreatePthreads
|
| -(
|
| - NSSCKFWInstance *fwInstance
|
| -)
|
| +NSSCKFWInstance_MayCreatePthreads(
|
| + NSSCKFWInstance *fwInstance)
|
| {
|
| #ifdef DEBUG
|
| - if( CKR_OK != nssCKFWInstance_verifyPointer(fwInstance) ) {
|
| - return CK_FALSE;
|
| - }
|
| + if (CKR_OK != nssCKFWInstance_verifyPointer(fwInstance)) {
|
| + return CK_FALSE;
|
| + }
|
| #endif /* DEBUG */
|
|
|
| - return nssCKFWInstance_MayCreatePthreads(fwInstance);
|
| + return nssCKFWInstance_MayCreatePthreads(fwInstance);
|
| }
|
|
|
| /*
|
| @@ -1279,25 +1214,23 @@ NSSCKFWInstance_MayCreatePthreads
|
| *
|
| */
|
| NSS_IMPLEMENT NSSCKFWMutex *
|
| -NSSCKFWInstance_CreateMutex
|
| -(
|
| - NSSCKFWInstance *fwInstance,
|
| - NSSArena *arena,
|
| - CK_RV *pError
|
| -)
|
| +NSSCKFWInstance_CreateMutex(
|
| + NSSCKFWInstance *fwInstance,
|
| + NSSArena *arena,
|
| + CK_RV *pError)
|
| {
|
| #ifdef DEBUG
|
| - if (!pError) {
|
| - return (NSSCKFWMutex *)NULL;
|
| - }
|
| -
|
| - *pError = nssCKFWInstance_verifyPointer(fwInstance);
|
| - if( CKR_OK != *pError ) {
|
| - return (NSSCKFWMutex *)NULL;
|
| - }
|
| + if (!pError) {
|
| + return (NSSCKFWMutex *)NULL;
|
| + }
|
| +
|
| + *pError = nssCKFWInstance_verifyPointer(fwInstance);
|
| + if (CKR_OK != *pError) {
|
| + return (NSSCKFWMutex *)NULL;
|
| + }
|
| #endif /* DEBUG */
|
|
|
| - return nssCKFWInstance_CreateMutex(fwInstance, arena, pError);
|
| + return nssCKFWInstance_CreateMutex(fwInstance, arena, pError);
|
| }
|
|
|
| /*
|
| @@ -1305,18 +1238,16 @@ NSSCKFWInstance_CreateMutex
|
| *
|
| */
|
| NSS_IMPLEMENT NSSUTF8 *
|
| -NSSCKFWInstance_GetConfigurationData
|
| -(
|
| - NSSCKFWInstance *fwInstance
|
| -)
|
| +NSSCKFWInstance_GetConfigurationData(
|
| + NSSCKFWInstance *fwInstance)
|
| {
|
| #ifdef DEBUG
|
| - if( CKR_OK != nssCKFWInstance_verifyPointer(fwInstance) ) {
|
| - return (NSSUTF8 *)NULL;
|
| - }
|
| + if (CKR_OK != nssCKFWInstance_verifyPointer(fwInstance)) {
|
| + return (NSSUTF8 *)NULL;
|
| + }
|
| #endif /* DEBUG */
|
|
|
| - return nssCKFWInstance_GetConfigurationData(fwInstance);
|
| + return nssCKFWInstance_GetConfigurationData(fwInstance);
|
| }
|
|
|
| /*
|
| @@ -1324,17 +1255,14 @@ NSSCKFWInstance_GetConfigurationData
|
| *
|
| */
|
| NSS_IMPLEMENT CK_C_INITIALIZE_ARGS_PTR
|
| -NSSCKFWInstance_GetInitArgs
|
| -(
|
| - NSSCKFWInstance *fwInstance
|
| -)
|
| +NSSCKFWInstance_GetInitArgs(
|
| + NSSCKFWInstance *fwInstance)
|
| {
|
| #ifdef DEBUG
|
| - if( CKR_OK != nssCKFWInstance_verifyPointer(fwInstance) ) {
|
| - return (CK_C_INITIALIZE_ARGS_PTR)NULL;
|
| - }
|
| + if (CKR_OK != nssCKFWInstance_verifyPointer(fwInstance)) {
|
| + return (CK_C_INITIALIZE_ARGS_PTR)NULL;
|
| + }
|
| #endif /* DEBUG */
|
|
|
| - return nssCKFWInstance_GetInitArgs(fwInstance);
|
| + return nssCKFWInstance_GetInitArgs(fwInstance);
|
| }
|
| -
|
|
|