Back to index

lightning-sunbird  0.9+nobinonly
Functions
ckfw.h File Reference
#include "nssbaset.h"
#include "nssckt.h"
#include "nssckfwt.h"
#include "nssckmdt.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

NSS_EXTERN NSSCKFWInstance * nssCKFWInstance_Create (CK_C_INITIALIZE_ARGS_PTR pInitArgs, CryptokiLockingState LockingState, NSSCKMDInstance *mdInstance, CK_RV *pError)
NSS_EXTERN CK_RV nssCKFWInstance_Destroy (NSSCKFWInstance *fwInstance)
NSS_EXTERN NSSCKMDInstance * nssCKFWInstance_GetMDInstance (NSSCKFWInstance *fwInstance)
NSS_EXTERN NSSArena * nssCKFWInstance_GetArena (NSSCKFWInstance *fwInstance, CK_RV *pError)
NSS_EXTERN CK_BBOOL nssCKFWInstance_MayCreatePthreads (NSSCKFWInstance *fwInstance)
NSS_EXTERN NSSCKFWMutex * nssCKFWInstance_CreateMutex (NSSCKFWInstance *fwInstance, NSSArena *arena, CK_RV *pError)
NSS_EXTERN NSSUTF8nssCKFWInstance_GetConfigurationData (NSSCKFWInstance *fwInstance)
NSS_EXTERN CK_C_INITIALIZE_ARGS_PTR nssCKFWInstance_GetInitArgs (NSSCKFWInstance *fwInstance)
NSS_EXTERN CK_SESSION_HANDLE nssCKFWInstance_CreateSessionHandle (NSSCKFWInstance *fwInstance, NSSCKFWSession *fwSession, CK_RV *pError)
NSS_EXTERN NSSCKFWSession * nssCKFWInstance_ResolveSessionHandle (NSSCKFWInstance *fwInstance, CK_SESSION_HANDLE hSession)
NSS_EXTERN void nssCKFWInstance_DestroySessionHandle (NSSCKFWInstance *fwInstance, CK_SESSION_HANDLE hSession)
NSS_EXTERN CK_SESSION_HANDLE nssCKFWInstance_FindSessionHandle (NSSCKFWInstance *fwInstance, NSSCKFWSession *fwSession)
NSS_EXTERN CK_OBJECT_HANDLE nssCKFWInstance_CreateObjectHandle (NSSCKFWInstance *fwInstance, NSSCKFWObject *fwObject, CK_RV *pError)
NSS_EXTERN NSSCKFWObject * nssCKFWInstance_ResolveObjectHandle (NSSCKFWInstance *fwInstance, CK_OBJECT_HANDLE hObject)
NSS_EXTERN CK_RV nssCKFWInstance_ReassignObjectHandle (NSSCKFWInstance *fwInstance, CK_OBJECT_HANDLE hObject, NSSCKFWObject *fwObject)
NSS_EXTERN void nssCKFWInstance_DestroyObjectHandle (NSSCKFWInstance *fwInstance, CK_OBJECT_HANDLE hObject)
NSS_EXTERN CK_OBJECT_HANDLE nssCKFWInstance_FindObjectHandle (NSSCKFWInstance *fwInstance, NSSCKFWObject *fwObject)
NSS_EXTERN CK_ULONG nssCKFWInstance_GetNSlots (NSSCKFWInstance *fwInstance, CK_RV *pError)
NSS_EXTERN CK_VERSION nssCKFWInstance_GetCryptokiVersion (NSSCKFWInstance *fwInstance)
NSS_EXTERN CK_RV nssCKFWInstance_GetManufacturerID (NSSCKFWInstance *fwInstance, CK_CHAR manufacturerID[32])
NSS_EXTERN CK_ULONG nssCKFWInstance_GetFlags (NSSCKFWInstance *fwInstance)
NSS_EXTERN CK_RV nssCKFWInstance_GetLibraryDescription (NSSCKFWInstance *fwInstance, CK_CHAR libraryDescription[32])
NSS_EXTERN CK_VERSION nssCKFWInstance_GetLibraryVersion (NSSCKFWInstance *fwInstance)
NSS_EXTERN CK_BBOOL nssCKFWInstance_GetModuleHandlesSessionObjects (NSSCKFWInstance *fwInstance)
NSS_EXTERN NSSCKFWSlot ** nssCKFWInstance_GetSlots (NSSCKFWInstance *fwInstance, CK_RV *pError)
NSS_EXTERN NSSCKFWSlot * nssCKFWInstance_WaitForSlotEvent (NSSCKFWInstance *fwInstance, CK_BBOOL block, CK_RV *pError)
NSS_EXTERN CK_RV nssCKFWInstance_verifyPointer (const NSSCKFWInstance *fwInstance)
NSS_EXTERN NSSCKFWSlot * nssCKFWSlot_Create (NSSCKFWInstance *fwInstance, NSSCKMDSlot *mdSlot, CK_SLOT_ID slotID, CK_RV *pError)
NSS_EXTERN CK_RV nssCKFWSlot_Destroy (NSSCKFWSlot *fwSlot)
NSS_EXTERN NSSCKMDSlot * nssCKFWSlot_GetMDSlot (NSSCKFWSlot *fwSlot)
NSS_EXTERN NSSCKFWInstance * nssCKFWSlot_GetFWInstance (NSSCKFWSlot *fwSlot)
NSS_EXTERN NSSCKMDInstance * nssCKFWSlot_GetMDInstance (NSSCKFWSlot *fwSlot)
NSS_EXTERN CK_SLOT_ID nssCKFWSlot_GetSlotID (NSSCKFWSlot *fwSlot)
NSS_EXTERN CK_RV nssCKFWSlot_GetSlotDescription (NSSCKFWSlot *fwSlot, CK_CHAR slotDescription[64])
NSS_EXTERN CK_RV nssCKFWSlot_GetManufacturerID (NSSCKFWSlot *fwSlot, CK_CHAR manufacturerID[32])
NSS_EXTERN CK_BBOOL nssCKFWSlot_GetTokenPresent (NSSCKFWSlot *fwSlot)
NSS_EXTERN CK_BBOOL nssCKFWSlot_GetRemovableDevice (NSSCKFWSlot *fwSlot)
NSS_EXTERN CK_BBOOL nssCKFWSlot_GetHardwareSlot (NSSCKFWSlot *fwSlot)
NSS_EXTERN CK_VERSION nssCKFWSlot_GetHardwareVersion (NSSCKFWSlot *fwSlot)
NSS_EXTERN CK_VERSION nssCKFWSlot_GetFirmwareVersion (NSSCKFWSlot *fwSlot)
NSS_EXTERN NSSCKFWToken * nssCKFWSlot_GetToken (NSSCKFWSlot *fwSlot, CK_RV *pError)
NSS_EXTERN void nssCKFWSlot_ClearToken (NSSCKFWSlot *fwSlot)
NSS_EXTERN NSSCKFWToken * nssCKFWToken_Create (NSSCKFWSlot *fwSlot, NSSCKMDToken *mdToken, CK_RV *pError)
NSS_EXTERN CK_RV nssCKFWToken_Destroy (NSSCKFWToken *fwToken)
NSS_EXTERN NSSCKMDToken * nssCKFWToken_GetMDToken (NSSCKFWToken *fwToken)
NSS_EXTERN NSSArena * nssCKFWToken_GetArena (NSSCKFWToken *fwToken, CK_RV *pError)
NSS_EXTERN NSSCKFWSlot * nssCKFWToken_GetFWSlot (NSSCKFWToken *fwToken)
NSS_EXTERN NSSCKMDSlot * nssCKFWToken_GetMDSlot (NSSCKFWToken *fwToken)
NSS_EXTERN CK_STATE nssCKFWToken_GetSessionState (NSSCKFWToken *fwToken)
NSS_EXTERN CK_RV nssCKFWToken_InitToken (NSSCKFWToken *fwToken, NSSItem *pin, NSSUTF8 *label)
NSS_EXTERN CK_RV nssCKFWToken_GetLabel (NSSCKFWToken *fwToken, CK_CHAR label[32])
NSS_EXTERN CK_RV nssCKFWToken_GetManufacturerID (NSSCKFWToken *fwToken, CK_CHAR manufacturerID[32])
NSS_EXTERN CK_RV nssCKFWToken_GetModel (NSSCKFWToken *fwToken, CK_CHAR model[16])
NSS_EXTERN CK_RV nssCKFWToken_GetSerialNumber (NSSCKFWToken *fwToken, CK_CHAR serialNumber[16])
NSS_EXTERN CK_BBOOL nssCKFWToken_GetHasRNG (NSSCKFWToken *fwToken)
NSS_EXTERN CK_BBOOL nssCKFWToken_GetIsWriteProtected (NSSCKFWToken *fwToken)
NSS_EXTERN CK_BBOOL nssCKFWToken_GetLoginRequired (NSSCKFWToken *fwToken)
NSS_EXTERN CK_BBOOL nssCKFWToken_GetUserPinInitialized (NSSCKFWToken *fwToken)
NSS_EXTERN CK_BBOOL nssCKFWToken_GetRestoreKeyNotNeeded (NSSCKFWToken *fwToken)
NSS_EXTERN CK_BBOOL nssCKFWToken_GetHasClockOnToken (NSSCKFWToken *fwToken)
NSS_EXTERN CK_BBOOL nssCKFWToken_GetHasProtectedAuthenticationPath (NSSCKFWToken *fwToken)
NSS_EXTERN CK_BBOOL nssCKFWToken_GetSupportsDualCryptoOperations (NSSCKFWToken *fwToken)
NSS_EXTERN CK_ULONG nssCKFWToken_GetMaxSessionCount (NSSCKFWToken *fwToken)
NSS_EXTERN CK_ULONG nssCKFWToken_GetMaxRwSessionCount (NSSCKFWToken *fwToken)
NSS_EXTERN CK_ULONG nssCKFWToken_GetMaxPinLen (NSSCKFWToken *fwToken)
NSS_EXTERN CK_ULONG nssCKFWToken_GetMinPinLen (NSSCKFWToken *fwToken)
NSS_EXTERN CK_ULONG nssCKFWToken_GetTotalPublicMemory (NSSCKFWToken *fwToken)
NSS_EXTERN CK_ULONG nssCKFWToken_GetFreePublicMemory (NSSCKFWToken *fwToken)
NSS_EXTERN CK_ULONG nssCKFWToken_GetTotalPrivateMemory (NSSCKFWToken *fwToken)
NSS_EXTERN CK_ULONG nssCKFWToken_GetFreePrivateMemory (NSSCKFWToken *fwToken)
NSS_EXTERN CK_VERSION nssCKFWToken_GetHardwareVersion (NSSCKFWToken *fwToken)
NSS_EXTERN CK_VERSION nssCKFWToken_GetFirmwareVersion (NSSCKFWToken *fwToken)
NSS_EXTERN CK_RV nssCKFWToken_GetUTCTime (NSSCKFWToken *fwToken, CK_CHAR utcTime[16])
NSS_EXTERN NSSCKFWSession * nssCKFWToken_OpenSession (NSSCKFWToken *fwToken, CK_BBOOL rw, CK_VOID_PTR pApplication, CK_NOTIFY Notify, CK_RV *pError)
NSS_EXTERN CK_ULONG nssCKFWToken_GetMechanismCount (NSSCKFWToken *fwToken)
NSS_EXTERN CK_RV nssCKFWToken_GetMechanismTypes (NSSCKFWToken *fwToken, CK_MECHANISM_TYPE types[])
NSS_EXTERN NSSCKFWMechanism * nssCKFWToken_GetMechanism (NSSCKFWToken *fwToken, CK_MECHANISM_TYPE which, CK_RV *pError)
NSS_EXTERN CK_RV nssCKFWToken_SetSessionState (NSSCKFWToken *fwToken, CK_STATE newState)
NSS_EXTERN CK_RV nssCKFWToken_RemoveSession (NSSCKFWToken *fwToken, NSSCKFWSession *fwSession)
NSS_EXTERN CK_RV nssCKFWToken_CloseAllSessions (NSSCKFWToken *fwToken)
NSS_EXTERN CK_ULONG nssCKFWToken_GetSessionCount (NSSCKFWToken *fwToken)
NSS_EXTERN CK_ULONG nssCKFWToken_GetRwSessionCount (NSSCKFWToken *fwToken)
NSS_EXTERN CK_ULONG nssCKFWToken_GetRoSessionCount (NSSCKFWToken *fwToken)
NSS_EXTERN nssCKFWHash * nssCKFWToken_GetSessionObjectHash (NSSCKFWToken *fwToken)
NSS_EXTERN nssCKFWHash * nssCKFWToken_GetMDObjectHash (NSSCKFWToken *fwToken)
NSS_EXTERN nssCKFWHash * nssCKFWToken_GetObjectHandleHash (NSSCKFWToken *fwToken)
NSS_EXTERN NSSCKFWMechanism * nssCKFWMechanism_Create (void)
NSS_EXTERN CK_RV nssCKFWMechanism_Destroy (NSSCKFWMechanism *fwMechanism)
NSS_EXTERN NSSCKMDMechanism * nssCKFWMechanism_GetMDMechanism (NSSCKFWMechanism *fwMechanism)
NSS_EXTERN NSSItem * nssCKFWMechanism_GetParameter (NSSCKFWMechanism *fwMechanism)
NSS_EXTERN CK_ULONG nssCKFWMechanism_GetMinKeySize (NSSCKFWMechanism *fwMechanism)
NSS_EXTERN CK_ULONG nssCKFWMechanism_GetMaxKeySize (NSSCKFWMechanism *fwMechanism)
NSS_EXTERN CK_BBOOL nssCKFWMechanism_GetInHardware (NSSCKFWMechanism *fwMechanism)
NSS_EXTERN NSSCKFWSession * nssCKFWSession_Create (NSSCKFWToken *fwToken, CK_BBOOL rw, CK_VOID_PTR pApplication, CK_NOTIFY Notify, CK_RV *pError)
NSS_EXTERN CK_RV nssCKFWSession_Destroy (NSSCKFWSession *fwSession, CK_BBOOL removeFromTokenHash)
NSS_EXTERN NSSCKMDSession * nssCKFWSession_GetMDSession (NSSCKFWSession *fwSession)
NSS_EXTERN NSSArena * nssCKFWSession_GetArena (NSSCKFWSession *fwSession, CK_RV *pError)
NSS_EXTERN CK_RV nssCKFWSession_CallNotification (NSSCKFWSession *fwSession, CK_NOTIFICATION event)
NSS_EXTERN CK_BBOOL nssCKFWSession_IsRWSession (NSSCKFWSession *fwSession)
NSS_EXTERN CK_BBOOL nssCKFWSession_IsSO (NSSCKFWSession *fwSession)
NSS_EXTERN NSSCKFWSlot * nssCKFWSession_GetFWSlot (NSSCKFWSession *fwSession)
NSS_EXTERN CK_STATE nssCKFWSession_GetSessionState (NSSCKFWSession *fwSession)
NSS_EXTERN CK_RV nssCKFWSession_SetFWFindObjects (NSSCKFWSession *fwSession, NSSCKFWFindObjects *fwFindObjects)
NSS_EXTERN NSSCKFWFindObjects * nssCKFWSession_GetFWFindObjects (NSSCKFWSession *fwSesssion, CK_RV *pError)
NSS_EXTERN CK_RV nssCKFWSession_SetMDSession (NSSCKFWSession *fwSession, NSSCKMDSession *mdSession)
NSS_EXTERN CK_RV nssCKFWSession_SetHandle (NSSCKFWSession *fwSession, CK_SESSION_HANDLE hSession)
NSS_EXTERN CK_SESSION_HANDLE nssCKFWSession_GetHandle (NSSCKFWSession *fwSession)
NSS_EXTERN CK_RV nssCKFWSession_RegisterSessionObject (NSSCKFWSession *fwSession, NSSCKFWObject *fwObject)
NSS_EXTERN CK_RV nssCKFWSession_DeregisterSessionObject (NSSCKFWSession *fwSession, NSSCKFWObject *fwObject)
NSS_EXTERN CK_ULONG nssCKFWSession_GetDeviceError (NSSCKFWSession *fwSession)
NSS_EXTERN CK_RV nssCKFWSession_Login (NSSCKFWSession *fwSession, CK_USER_TYPE userType, NSSItem *pin)
NSS_EXTERN CK_RV nssCKFWSession_Logout (NSSCKFWSession *fwSession)
NSS_EXTERN CK_RV nssCKFWSession_InitPIN (NSSCKFWSession *fwSession, NSSItem *pin)
NSS_EXTERN CK_RV nssCKFWSession_SetPIN (NSSCKFWSession *fwSession, NSSItem *newPin, NSSItem *oldPin)
NSS_EXTERN CK_ULONG nssCKFWSession_GetOperationStateLen (NSSCKFWSession *fwSession, CK_RV *pError)
NSS_EXTERN CK_RV nssCKFWSession_GetOperationState (NSSCKFWSession *fwSession, NSSItem *buffer)
NSS_EXTERN CK_RV nssCKFWSession_SetOperationState (NSSCKFWSession *fwSession, NSSItem *state, NSSCKFWObject *encryptionKey, NSSCKFWObject *authenticationKey)
NSS_EXTERN NSSCKFWObject * nssCKFWSession_CreateObject (NSSCKFWSession *fwSession, CK_ATTRIBUTE_PTR pTemplate, CK_ULONG ulAttributeCount, CK_RV *pError)
NSS_EXTERN NSSCKFWObject * nssCKFWSession_CopyObject (NSSCKFWSession *fwSession, NSSCKFWObject *object, CK_ATTRIBUTE_PTR pTemplate, CK_ULONG ulAttributeCount, CK_RV *pError)
NSS_EXTERN NSSCKFWFindObjects * nssCKFWSession_FindObjectsInit (NSSCKFWSession *fwSession, CK_ATTRIBUTE_PTR pTemplate, CK_ULONG ulAttributeCount, CK_RV *pError)
NSS_EXTERN CK_RV nssCKFWSession_SeedRandom (NSSCKFWSession *fwSession, NSSItem *seed)
NSS_EXTERN CK_RV nssCKFWSession_GetRandom (NSSCKFWSession *fwSession, NSSItem *buffer)
NSS_EXTERN NSSCKFWObject * nssCKFWObject_Create (NSSArena *arena, NSSCKMDObject *mdObject, NSSCKFWSession *fwSession, NSSCKFWToken *fwToken, NSSCKFWInstance *fwInstance, CK_RV *pError)
NSS_EXTERN void nssCKFWObject_Finalize (NSSCKFWObject *fwObject)
NSS_EXTERN void nssCKFWObject_Destroy (NSSCKFWObject *fwObject)
NSS_EXTERN NSSCKMDObject * nssCKFWObject_GetMDObject (NSSCKFWObject *fwObject)
NSS_EXTERN NSSArena * nssCKFWObject_GetArena (NSSCKFWObject *fwObject, CK_RV *pError)
NSS_EXTERN CK_RV nssCKFWObject_SetHandle (NSSCKFWObject *fwObject, CK_OBJECT_HANDLE hObject)
NSS_EXTERN CK_OBJECT_HANDLE nssCKFWObject_GetHandle (NSSCKFWObject *fwObject)
NSS_EXTERN CK_BBOOL nssCKFWObject_IsTokenObject (NSSCKFWObject *fwObject)
NSS_EXTERN CK_ULONG nssCKFWObject_GetAttributeCount (NSSCKFWObject *fwObject, CK_RV *pError)
NSS_EXTERN CK_RV nssCKFWObject_GetAttributeTypes (NSSCKFWObject *fwObject, CK_ATTRIBUTE_TYPE_PTR typeArray, CK_ULONG ulCount)
NSS_EXTERN CK_ULONG nssCKFWObject_GetAttributeSize (NSSCKFWObject *fwObject, CK_ATTRIBUTE_TYPE attribute, CK_RV *pError)
NSS_EXTERN NSSItem * nssCKFWObject_GetAttribute (NSSCKFWObject *fwObject, CK_ATTRIBUTE_TYPE attribute, NSSItem *itemOpt, NSSArena *arenaOpt, CK_RV *pError)
NSS_EXTERN CK_RV nssCKFWObject_SetAttribute (NSSCKFWObject *fwObject, CK_ATTRIBUTE_TYPE attribute, NSSItem *value)
NSS_EXTERN CK_ULONG nssCKFWObject_GetObjectSize (NSSCKFWObject *fwObject, CK_RV *pError)
NSS_EXTERN NSSCKFWFindObjects * nssCKFWFindObjects_Create (NSSCKFWSession *fwSession, NSSCKFWToken *fwToken, NSSCKFWInstance *fwInstance, NSSCKMDFindObjects *mdFindObjects1, NSSCKMDFindObjects *mdFindObjects2, CK_RV *pError)
NSS_EXTERN void nssCKFWFindObjects_Destroy (NSSCKFWFindObjects *fwFindObjects)
NSS_EXTERN NSSCKMDFindObjects * nssCKFWFindObjects_GetMDFindObjects (NSSCKFWFindObjects *fwFindObjects)
NSS_EXTERN NSSCKFWObject * nssCKFWFindObjects_Next (NSSCKFWFindObjects *fwFindObjects, NSSArena *arenaOpt, CK_RV *pError)
NSS_EXTERN NSSCKFWMutex * nssCKFWMutex_Create (CK_C_INITIALIZE_ARGS_PTR pInitArgs, CryptokiLockingState LockingState, NSSArena *arena, CK_RV *pError)
NSS_EXTERN CK_RV nssCKFWMutex_Destroy (NSSCKFWMutex *mutex)
NSS_EXTERN CK_RV nssCKFWMutex_Lock (NSSCKFWMutex *mutex)
NSS_EXTERN CK_RV nssCKFWMutex_Unlock (NSSCKFWMutex *mutex)

Function Documentation

NSS_EXTERN NSSCKFWFindObjects* nssCKFWFindObjects_Create ( NSSCKFWSession *  fwSession,
NSSCKFWToken *  fwToken,
NSSCKFWInstance *  fwInstance,
NSSCKMDFindObjects *  mdFindObjects1,
NSSCKMDFindObjects *  mdFindObjects2,
CK_RV pError 
)

Definition at line 131 of file find.c.

{
  NSSCKFWFindObjects *fwFindObjects = NULL;
  NSSCKMDSession *mdSession;
  NSSCKMDToken *mdToken;
  NSSCKMDInstance *mdInstance;

  mdSession = nssCKFWSession_GetMDSession(fwSession);
  mdToken = nssCKFWToken_GetMDToken(fwToken);
  mdInstance = nssCKFWInstance_GetMDInstance(fwInstance);

  fwFindObjects = nss_ZNEW(NULL, NSSCKFWFindObjects);
  if( (NSSCKFWFindObjects *)NULL == fwFindObjects ) {
    *pError = CKR_HOST_MEMORY;
    goto loser;
  }

  fwFindObjects->mdfo1 = mdFindObjects1;
  fwFindObjects->mdfo2 = mdFindObjects2;
  fwFindObjects->fwSession = fwSession;
  fwFindObjects->mdSession = mdSession;
  fwFindObjects->fwToken = fwToken;
  fwFindObjects->mdToken = mdToken;
  fwFindObjects->fwInstance = fwInstance;
  fwFindObjects->mdInstance = mdInstance;

  fwFindObjects->mutex = nssCKFWInstance_CreateMutex(fwInstance, NULL, pError);
  if( (NSSCKFWMutex *)NULL == fwFindObjects->mutex ) {
    goto loser;
  }

#ifdef DEBUG
  *pError = findObjects_add_pointer(fwFindObjects);
  if( CKR_OK != *pError ) {
    goto loser;
  }
#endif /* DEBUG */

  return fwFindObjects;

 loser:
  if( fwFindObjects ) {
    if( NULL != mdFindObjects1 ) {
      if( NULL != mdFindObjects1->Final ) {
        fwFindObjects->mdFindObjects = mdFindObjects1;
        mdFindObjects1->Final(mdFindObjects1, fwFindObjects, mdSession, 
          fwSession, mdToken, fwToken, mdInstance, fwInstance);
      }
    }

    if( NULL != mdFindObjects2 ) {
      if( NULL != mdFindObjects2->Final ) {
        fwFindObjects->mdFindObjects = mdFindObjects2;
        mdFindObjects2->Final(mdFindObjects2, fwFindObjects, mdSession, 
          fwSession, mdToken, fwToken, mdInstance, fwInstance);
      }
    }

    nss_ZFreeIf(fwFindObjects);
  }

  if( CKR_OK == *pError ) {
    *pError = CKR_GENERAL_ERROR;
  }

  return (NSSCKFWFindObjects *)NULL;
}

Here is the caller graph for this function:

NSS_EXTERN void nssCKFWFindObjects_Destroy ( NSSCKFWFindObjects *  fwFindObjects)

Definition at line 213 of file find.c.

{
#ifdef NSSDEBUG
  if( CKR_OK != nssCKFWFindObjects_verifyPointer(fwFindObjects) ) {
    return;
  }
#endif /* NSSDEBUG */

  (void)nssCKFWMutex_Destroy(fwFindObjects->mutex);

  if( (NSSCKMDFindObjects *)NULL != fwFindObjects->mdfo1 ) {
    if( (void *)NULL != (void *)fwFindObjects->mdfo1->Final ) {
      fwFindObjects->mdFindObjects = fwFindObjects->mdfo1;
      fwFindObjects->mdfo1->Final(fwFindObjects->mdfo1, fwFindObjects,
        fwFindObjects->mdSession, fwFindObjects->fwSession, 
        fwFindObjects->mdToken, fwFindObjects->fwToken,
        fwFindObjects->mdInstance, fwFindObjects->fwInstance);
    }
  }

  if( (NSSCKMDFindObjects *)NULL != fwFindObjects->mdfo2 ) {
    if( (void *)NULL != (void *)fwFindObjects->mdfo2->Final ) {
      fwFindObjects->mdFindObjects = fwFindObjects->mdfo2;
      fwFindObjects->mdfo2->Final(fwFindObjects->mdfo2, fwFindObjects,
        fwFindObjects->mdSession, fwFindObjects->fwSession, 
        fwFindObjects->mdToken, fwFindObjects->fwToken,
        fwFindObjects->mdInstance, fwFindObjects->fwInstance);
    }
  }

  nss_ZFreeIf(fwFindObjects);

#ifdef DEBUG
  (void)findObjects_remove_pointer(fwFindObjects);
#endif /* DEBUG */

  return;
}

Here is the caller graph for this function:

NSS_EXTERN NSSCKMDFindObjects* nssCKFWFindObjects_GetMDFindObjects ( NSSCKFWFindObjects *  fwFindObjects)

Definition at line 260 of file find.c.

{
#ifdef NSSDEBUG
  if( CKR_OK != nssCKFWFindObjects_verifyPointer(fwFindObjects) ) {
    return (NSSCKMDFindObjects *)NULL;
  }
#endif /* NSSDEBUG */

  return fwFindObjects->mdFindObjects;
}

Here is the caller graph for this function:

NSS_EXTERN NSSCKFWObject* nssCKFWFindObjects_Next ( NSSCKFWFindObjects *  fwFindObjects,
NSSArena *  arenaOpt,
CK_RV pError 
)

Definition at line 279 of file find.c.

{
  NSSCKMDObject *mdObject;
  NSSCKFWObject *fwObject = (NSSCKFWObject *)NULL;
  NSSArena *objArena;

#ifdef NSSDEBUG
  if( (CK_RV *)NULL == pError ) {
    return (NSSCKFWObject *)NULL;
  }

  *pError = nssCKFWFindObjects_verifyPointer(fwFindObjects);
  if( CKR_OK != *pError ) {
    return (NSSCKFWObject *)NULL;
  }
#endif /* NSSDEBUG */

  *pError = nssCKFWMutex_Lock(fwFindObjects->mutex);
  if( CKR_OK != *pError ) {
    return (NSSCKFWObject *)NULL;
  }

  if( (NSSCKMDFindObjects *)NULL != fwFindObjects->mdfo1 ) {
    if( (void *)NULL != (void *)fwFindObjects->mdfo1->Next ) {
      fwFindObjects->mdFindObjects = fwFindObjects->mdfo1;
      mdObject = fwFindObjects->mdfo1->Next(fwFindObjects->mdfo1,
        fwFindObjects, fwFindObjects->mdSession, fwFindObjects->fwSession,
        fwFindObjects->mdToken, fwFindObjects->fwToken, 
        fwFindObjects->mdInstance, fwFindObjects->fwInstance,
        arenaOpt, pError);
      if( (NSSCKMDObject *)NULL == mdObject ) {
        if( CKR_OK != *pError ) {
          goto done;
        }

        /* All done. */
        fwFindObjects->mdfo1->Final(fwFindObjects->mdfo1, fwFindObjects,
          fwFindObjects->mdSession, fwFindObjects->fwSession,
          fwFindObjects->mdToken, fwFindObjects->fwToken, 
          fwFindObjects->mdInstance, fwFindObjects->fwInstance);
        fwFindObjects->mdfo1 = (NSSCKMDFindObjects *)NULL;
      } else {
        goto wrap;
      }
    }
  }

  if( (NSSCKMDFindObjects *)NULL != fwFindObjects->mdfo2 ) {
    if( (void *)NULL != (void *)fwFindObjects->mdfo2->Next ) {
      fwFindObjects->mdFindObjects = fwFindObjects->mdfo2;
      mdObject = fwFindObjects->mdfo2->Next(fwFindObjects->mdfo2,
        fwFindObjects, fwFindObjects->mdSession, fwFindObjects->fwSession,
        fwFindObjects->mdToken, fwFindObjects->fwToken, 
        fwFindObjects->mdInstance, fwFindObjects->fwInstance,
        arenaOpt, pError);
      if( (NSSCKMDObject *)NULL == mdObject ) {
        if( CKR_OK != *pError ) {
          goto done;
        }

        /* All done. */
        fwFindObjects->mdfo2->Final(fwFindObjects->mdfo2, fwFindObjects,
          fwFindObjects->mdSession, fwFindObjects->fwSession,
          fwFindObjects->mdToken, fwFindObjects->fwToken, 
          fwFindObjects->mdInstance, fwFindObjects->fwInstance);
        fwFindObjects->mdfo2 = (NSSCKMDFindObjects *)NULL;
      } else {
        goto wrap;
      }
    }
  }
  
  /* No more objects */
  *pError = CKR_OK;
  goto done;

 wrap:
  /*
   * This is less than ideal-- we should determine if it's a token
   * object or a session object, and use the appropriate arena.
   * But that duplicates logic in nssCKFWObject_IsTokenObject.
   * Worry about that later.  For now, be conservative, and use
   * the token arena.
   */
  objArena = nssCKFWToken_GetArena(fwFindObjects->fwToken, pError);
  if( (NSSArena *)NULL == objArena ) {
    if( CKR_OK == *pError ) {
      *pError = CKR_HOST_MEMORY;
    }
    goto done;
  }

  fwObject = nssCKFWObject_Create(objArena, mdObject,
               fwFindObjects->fwSession, fwFindObjects->fwToken, 
               fwFindObjects->fwInstance, pError);
  if( (NSSCKFWObject *)NULL == fwObject ) {
    if( CKR_OK == *pError ) {
      *pError = CKR_GENERAL_ERROR;
    }
  }

 done:
  (void)nssCKFWMutex_Unlock(fwFindObjects->mutex);
  return fwObject;
}

Here is the caller graph for this function:

NSS_EXTERN NSSCKFWInstance* nssCKFWInstance_Create ( CK_C_INITIALIZE_ARGS_PTR  pInitArgs,
CryptokiLockingState  LockingState,
NSSCKMDInstance *  mdInstance,
CK_RV pError 
)

Definition at line 194 of file instance.c.

{
  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( (NSSCKMDInstance *)NULL == mdInstance ) {
    *pError = CKR_ARGUMENTS_BAD;
    return (NSSCKFWInstance *)NULL;
  }
#endif /* NSSDEBUG */

  arena = NSSArena_Create();
  if( (NSSArena *)NULL == arena ) {
    *pError = CKR_HOST_MEMORY;
    return (NSSCKFWInstance *)NULL;
  }

  fwInstance = nss_ZNEW(arena, NSSCKFWInstance);
  if( (NSSCKFWInstance *)NULL == 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->mutex = nssCKFWMutex_Create(pInitArgs, LockingState, arena,
                                          pError);
  if( (NSSCKFWMutex *)NULL == fwInstance->mutex ) {
    if( CKR_OK == *pError ) {
      *pError = CKR_GENERAL_ERROR;
    }
    goto loser;
  }

  if( (void *)NULL != (void *)mdInstance->Initialize ) {
    *pError = mdInstance->Initialize(mdInstance, fwInstance, fwInstance->configurationData);
    if( CKR_OK != *pError ) {
      goto loser;
    }

    called_Initialize = CK_TRUE;
  }

  if( (void *)NULL != (void *)mdInstance->ModuleHandlesSessionObjects ) {
    fwInstance->moduleHandlesSessionObjects = 
      mdInstance->ModuleHandlesSessionObjects(mdInstance, fwInstance);
  } else {
    fwInstance->moduleHandlesSessionObjects = CK_FALSE;
  }

  if( (void *)NULL == (void *)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( (nssCKFWHash *)NULL == fwInstance->sessionHandleHash ) {
    goto loser;
  }

  fwInstance->objectHandleHash = nssCKFWHash_Create(fwInstance,
    fwInstance->arena, pError);
  if( (nssCKFWHash *)NULL == fwInstance->objectHandleHash ) {
    goto loser;
  }

  if( (void *)NULL == (void *)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( (NSSCKMDSlot *)NULL == mdSlot ) {
      *pError = CKR_GENERAL_ERROR;
      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( (void *)NULL != (void *)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;
  }
#endif /* DEBUG */

  *pError = CKR_OK;
  return fwInstance;

 nomem:
  *pError = CKR_HOST_MEMORY;
  /*FALLTHROUGH*/
 loser:

  if( CK_TRUE == called_Initialize ) {
    if( (void *)NULL != (void *)mdInstance->Finalize ) {
      mdInstance->Finalize(mdInstance, fwInstance);
    }
  }

  if (arena) {
    (void)NSSArena_Destroy(arena);
  }
  return (NSSCKFWInstance *)NULL;
}

Here is the caller graph for this function:

NSS_EXTERN NSSCKFWMutex* nssCKFWInstance_CreateMutex ( NSSCKFWInstance *  fwInstance,
NSSArena *  arena,
CK_RV pError 
)

Definition at line 494 of file instance.c.

{
  NSSCKFWMutex *mutex;

#ifdef NSSDEBUG
  if( (CK_RV *)NULL == pError ) {
    return (NSSCKFWMutex *)NULL;
  }

  *pError = nssCKFWInstance_verifyPointer(fwInstance);
  if( CKR_OK != *pError ) {
    return (NSSCKFWMutex *)NULL;
  }
#endif /* NSSDEBUG */

  mutex = nssCKFWMutex_Create(fwInstance->pInitArgs, fwInstance->LockingState,
                              arena, pError);
  if( (NSSCKFWMutex *)NULL == mutex ) {
    if( CKR_OK == *pError ) {
      *pError = CKR_GENERAL_ERROR;
    }

    return (NSSCKFWMutex *)NULL;
  }

  return mutex;
}

Here is the caller graph for this function:

NSS_EXTERN CK_OBJECT_HANDLE nssCKFWInstance_CreateObjectHandle ( NSSCKFWInstance *  fwInstance,
NSSCKFWObject *  fwObject,
CK_RV pError 
)

Definition at line 713 of file instance.c.

{
  CK_OBJECT_HANDLE hObject;

#ifdef NSSDEBUG
  if( (CK_RV *)NULL == 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;
}

Here is the caller graph for this function:

NSS_EXTERN CK_SESSION_HANDLE nssCKFWInstance_CreateSessionHandle ( NSSCKFWInstance *  fwInstance,
NSSCKFWSession *  fwSession,
CK_RV pError 
)

Definition at line 570 of file instance.c.

{
  CK_SESSION_HANDLE hSession;

#ifdef NSSDEBUG
  if( (CK_RV *)NULL == 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;
}

Here is the caller graph for this function:

NSS_EXTERN CK_RV nssCKFWInstance_Destroy ( NSSCKFWInstance *  fwInstance)

Definition at line 382 of file instance.c.

{
#ifdef NSSDEBUG
  CK_RV error = CKR_OK;
#endif /* NSSDEBUG */
  CK_ULONG i;

#ifdef NSSDEBUG
  error = nssCKFWInstance_verifyPointer(fwInstance);
  if( CKR_OK != error ) {
    return error;
  }
#endif /* NSSDEBUG */

  nssCKFWMutex_Destroy(fwInstance->mutex);

  for( i = 0; i < fwInstance->nSlots; i++ ) {
    (void)nssCKFWSlot_Destroy(fwInstance->fwSlotList[i]);
  }

  if( (void *)NULL != (void *)fwInstance->mdInstance->Finalize ) {
    fwInstance->mdInstance->Finalize(fwInstance->mdInstance, fwInstance);
  }

  if (fwInstance->sessionHandleHash) {
     nssCKFWHash_Destroy(fwInstance->sessionHandleHash);
  }

  if (fwInstance->objectHandleHash) {
     nssCKFWHash_Destroy(fwInstance->objectHandleHash);
  }

#ifdef DEBUG
  (void)instance_remove_pointer(fwInstance);
#endif /* DEBUG */

  (void)NSSArena_Destroy(fwInstance->arena);
  return CKR_OK;
}

Here is the caller graph for this function:

NSS_EXTERN void nssCKFWInstance_DestroyObjectHandle ( NSSCKFWInstance *  fwInstance,
CK_OBJECT_HANDLE  hObject 
)

Definition at line 840 of file instance.c.

{
  NSSCKFWObject *fwObject;

#ifdef NSSDEBUG
  if( CKR_OK != nssCKFWInstance_verifyPointer(fwInstance) ) {
    return;
  }
#endif /* NSSDEBUG */

  if( CKR_OK != nssCKFWMutex_Lock(fwInstance->mutex) ) {
    return;
  }

  fwObject = (NSSCKFWObject *)nssCKFWHash_Lookup(
                fwInstance->objectHandleHash, (const void *)hObject);
  /* 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;
}

Here is the caller graph for this function:

NSS_EXTERN void nssCKFWInstance_DestroySessionHandle ( NSSCKFWInstance *  fwInstance,
CK_SESSION_HANDLE  hSession 
)

Definition at line 654 of file instance.c.

{
  NSSCKFWSession *fwSession;

#ifdef NSSDEBUG
  if( CKR_OK != nssCKFWInstance_verifyPointer(fwInstance) ) {
    return;
  }
#endif /* NSSDEBUG */

  if( CKR_OK != nssCKFWMutex_Lock(fwInstance->mutex) ) {
    return;
  }

  fwSession = (NSSCKFWSession *)nssCKFWHash_Lookup(
                fwInstance->sessionHandleHash, (const void *)hSession);

  nssCKFWHash_Remove(fwInstance->sessionHandleHash, (const void *)hSession);
  nssCKFWSession_SetHandle(fwSession, (CK_SESSION_HANDLE)0);

  (void)nssCKFWMutex_Unlock(fwInstance->mutex);

  return;
}

Here is the caller graph for this function:

NSS_EXTERN CK_OBJECT_HANDLE nssCKFWInstance_FindObjectHandle ( NSSCKFWInstance *  fwInstance,
NSSCKFWObject *  fwObject 
)

Definition at line 873 of file instance.c.

{
#ifdef NSSDEBUG
  if( CKR_OK != nssCKFWInstance_verifyPointer(fwInstance) ) {
    return (CK_OBJECT_HANDLE)0;
  }

  if( CKR_OK != nssCKFWObject_verifyPointer(fwObject) ) {
    return (CK_OBJECT_HANDLE)0;
  }
#endif /* NSSDEBUG */
  
  return nssCKFWObject_GetHandle(fwObject);
}

Here is the caller graph for this function:

NSS_EXTERN CK_SESSION_HANDLE nssCKFWInstance_FindSessionHandle ( NSSCKFWInstance *  fwInstance,
NSSCKFWSession *  fwSession 
)

Definition at line 688 of file instance.c.

{
#ifdef NSSDEBUG
  if( CKR_OK != nssCKFWInstance_verifyPointer(fwInstance) ) {
    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? */
}

Here is the caller graph for this function:

NSS_EXTERN NSSArena* nssCKFWInstance_GetArena ( NSSCKFWInstance *  fwInstance,
CK_RV pError 
)

Definition at line 449 of file instance.c.

{
#ifdef NSSDEBUG
  if( (CK_RV *)NULL == pError ) {
    return (NSSArena *)NULL;
  }

  *pError = nssCKFWInstance_verifyPointer(fwInstance);
  if( CKR_OK != *pError ) {
    return (NSSArena *)NULL;
  }
#endif /* NSSDEBUG */

  *pError = CKR_OK;
  return fwInstance->arena;
}

Here is the caller graph for this function:

NSS_EXTERN NSSUTF8* nssCKFWInstance_GetConfigurationData ( NSSCKFWInstance *  fwInstance)

Definition at line 532 of file instance.c.

{
#ifdef NSSDEBUG
  if( CKR_OK != nssCKFWInstance_verifyPointer(fwInstance) ) {
    return (NSSUTF8 *)NULL;
  }
#endif /* NSSDEBUG */

  return fwInstance->configurationData;
}

Here is the caller graph for this function:

NSS_EXTERN CK_VERSION nssCKFWInstance_GetCryptokiVersion ( NSSCKFWInstance *  fwInstance)

Definition at line 923 of file instance.c.

{
  CK_VERSION rv;

#ifdef NSSDEBUG
  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( (0 != fwInstance->cryptokiVersion.major) ||
      (0 != fwInstance->cryptokiVersion.minor) ) {
    rv = fwInstance->cryptokiVersion;
    goto done;
  }

  if( (void *)NULL != (void *)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;
}

Here is the caller graph for this function:

NSS_EXTERN CK_ULONG nssCKFWInstance_GetFlags ( NSSCKFWInstance *  fwInstance)

Definition at line 1017 of file instance.c.

{
#ifdef NSSDEBUG
  if( CKR_OK != nssCKFWInstance_verifyPointer(fwInstance) ) {
    return (CK_ULONG)0;
  }
#endif /* NSSDEBUG */

  /* No "instance flags" are yet defined by Cryptoki. */
  return (CK_ULONG)0;
}

Here is the caller graph for this function:

Definition at line 551 of file instance.c.

{
#ifdef NSSDEBUG
  if( CKR_OK != nssCKFWInstance_verifyPointer(fwInstance) ) {
    return (CK_C_INITIALIZE_ARGS_PTR)NULL;
  }
#endif /* NSSDEBUG */

    return fwInstance->pInitArgs;
}

Here is the caller graph for this function:

NSS_EXTERN CK_RV nssCKFWInstance_GetLibraryDescription ( NSSCKFWInstance *  fwInstance,
CK_CHAR  libraryDescription[32] 
)

Definition at line 1037 of file instance.c.

{
  CK_RV error = CKR_OK;

#ifdef NSSDEBUG
  if( (CK_CHAR_PTR)NULL == libraryDescription ) {
    return CKR_ARGUMENTS_BAD;
  }

  error = nssCKFWInstance_verifyPointer(fwInstance);
  if( CKR_OK != error ) {
    return error;
  }
#endif /* NSSDEBUG */

  error = nssCKFWMutex_Lock(fwInstance->mutex);
  if( CKR_OK != error ) {
    return error;
  }

  if( (NSSUTF8 *)NULL == fwInstance->libraryDescription ) {
    if( (void *)NULL != (void *)fwInstance->mdInstance->GetLibraryDescription ) {
      fwInstance->libraryDescription = fwInstance->mdInstance->GetLibraryDescription(
        fwInstance->mdInstance, fwInstance, &error);
      if( ((NSSUTF8 *)NULL == fwInstance->libraryDescription) && (CKR_OK != error) ) {
        goto done;
      }
    } else {
      fwInstance->libraryDescription = (NSSUTF8 *) "";
    }
  }

  (void)nssUTF8_CopyIntoFixedBuffer(fwInstance->libraryDescription, (char *)libraryDescription, 32, ' ');
  error = CKR_OK;

 done:
  (void)nssCKFWMutex_Unlock(fwInstance->mutex);
  return error;
}

Here is the caller graph for this function:

NSS_EXTERN CK_VERSION nssCKFWInstance_GetLibraryVersion ( NSSCKFWInstance *  fwInstance)

Definition at line 1086 of file instance.c.

{
  CK_VERSION rv;

#ifdef NSSDEBUG
  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( (0 != fwInstance->libraryVersion.major) ||
      (0 != fwInstance->libraryVersion.minor) ) {
    rv = fwInstance->libraryVersion;
    goto done;
  }

  if( (void *)NULL != (void *)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;
}

Here is the caller graph for this function:

NSS_EXTERN CK_RV nssCKFWInstance_GetManufacturerID ( NSSCKFWInstance *  fwInstance,
CK_CHAR  manufacturerID[32] 
)

Definition at line 968 of file instance.c.

{
  CK_RV error = CKR_OK;

#ifdef NSSDEBUG
  if( (CK_CHAR_PTR)NULL == manufacturerID ) {
    return CKR_ARGUMENTS_BAD;
  }

  error = nssCKFWInstance_verifyPointer(fwInstance);
  if( CKR_OK != error ) {
    return error;
  }
#endif /* NSSDEBUG */

  error = nssCKFWMutex_Lock(fwInstance->mutex);
  if( CKR_OK != error ) {
    return error;
  }

  if( (NSSUTF8 *)NULL == fwInstance->manufacturerID ) {
    if( (void *)NULL != (void *)fwInstance->mdInstance->GetManufacturerID ) {
      fwInstance->manufacturerID = fwInstance->mdInstance->GetManufacturerID(
        fwInstance->mdInstance, fwInstance, &error);
      if( ((NSSUTF8 *)NULL == fwInstance->manufacturerID) && (CKR_OK != error) ) {
        goto done;
      }
    } else {
      fwInstance->manufacturerID = (NSSUTF8 *) "";
    }
  }

  (void)nssUTF8_CopyIntoFixedBuffer(fwInstance->manufacturerID, (char *)manufacturerID, 32, ' ');
  error = CKR_OK;

 done:
  (void)nssCKFWMutex_Unlock(fwInstance->mutex);
  return error;
}

Here is the caller graph for this function:

NSS_EXTERN NSSCKMDInstance* nssCKFWInstance_GetMDInstance ( NSSCKFWInstance *  fwInstance)

Definition at line 430 of file instance.c.

{
#ifdef NSSDEBUG
  if( CKR_OK != nssCKFWInstance_verifyPointer(fwInstance) ) {
    return (NSSCKMDInstance *)NULL;
  }
#endif /* NSSDEBUG */

  return fwInstance->mdInstance;
}

Here is the caller graph for this function:

Definition at line 1130 of file instance.c.

{
#ifdef NSSDEBUG
  if( CKR_OK != nssCKFWInstance_verifyPointer(fwInstance) ) {
    return CK_FALSE;
  }
#endif /* NSSDEBUG */

  return fwInstance->moduleHandlesSessionObjects;
}

Here is the caller graph for this function:

NSS_EXTERN CK_ULONG nssCKFWInstance_GetNSlots ( NSSCKFWInstance *  fwInstance,
CK_RV pError 
)

Definition at line 897 of file instance.c.

{
#ifdef NSSDEBUG
  if( (CK_RV *)NULL == 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;
}  

Here is the caller graph for this function:

NSS_EXTERN NSSCKFWSlot** nssCKFWInstance_GetSlots ( NSSCKFWInstance *  fwInstance,
CK_RV pError 
)

Definition at line 1149 of file instance.c.

{
#ifdef NSSDEBUG
  if( (CK_RV *)NULL == pError ) {
    return (NSSCKFWSlot **)NULL;
  }

  *pError = nssCKFWInstance_verifyPointer(fwInstance);
  if( CKR_OK != *pError ) {
    return (NSSCKFWSlot **)NULL;
  }
#endif /* NSSDEBUG */

  return fwInstance->fwSlotList;
}

Here is the caller graph for this function:

NSS_EXTERN CK_BBOOL nssCKFWInstance_MayCreatePthreads ( NSSCKFWInstance *  fwInstance)

Definition at line 475 of file instance.c.

{
#ifdef NSSDEBUG
  if( CKR_OK != nssCKFWInstance_verifyPointer(fwInstance) ) {
    return CK_FALSE;
  }
#endif /* NSSDEBUG */

  return fwInstance->mayCreatePthreads;
}

Here is the caller graph for this function:

NSS_EXTERN CK_RV nssCKFWInstance_ReassignObjectHandle ( NSSCKFWInstance *  fwInstance,
CK_OBJECT_HANDLE  hObject,
NSSCKFWObject *  fwObject 
)

Definition at line 795 of file instance.c.

{
  CK_RV error = CKR_OK;
  NSSCKFWObject *oldObject;

#ifdef NSSDEBUG
  error = nssCKFWInstance_verifyPointer(fwInstance);
  if( CKR_OK != error ) {
    return error;
  }
#endif /* NSSDEBUG */

  error = nssCKFWMutex_Lock(fwInstance->mutex);
  if( CKR_OK != error ) {
    return error;
  }

  oldObject = (NSSCKFWObject *)nssCKFWHash_Lookup(
                 fwInstance->objectHandleHash, (const void *)hObject);
  /* 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;
}

Here is the caller graph for this function:

NSS_EXTERN NSSCKFWObject* nssCKFWInstance_ResolveObjectHandle ( NSSCKFWInstance *  fwInstance,
CK_OBJECT_HANDLE  hObject 
)

Definition at line 763 of file instance.c.

{
  NSSCKFWObject *fwObject;

#ifdef NSSDEBUG
  if( CKR_OK != nssCKFWInstance_verifyPointer(fwInstance) ) {
    return (NSSCKFWObject *)NULL;
  }
#endif /* NSSDEBUG */

  if( CKR_OK != nssCKFWMutex_Lock(fwInstance->mutex) ) {
    return (NSSCKFWObject *)NULL;
  }

  fwObject = (NSSCKFWObject *)nssCKFWHash_Lookup(
                fwInstance->objectHandleHash, (const void *)hObject);

  /* Assert(hObject == nssCKFWObject_GetHandle(fwObject)) */

  (void)nssCKFWMutex_Unlock(fwInstance->mutex);
  return fwObject;
}

Here is the caller graph for this function:

NSS_EXTERN NSSCKFWSession* nssCKFWInstance_ResolveSessionHandle ( NSSCKFWInstance *  fwInstance,
CK_SESSION_HANDLE  hSession 
)

Definition at line 621 of file instance.c.

{
  NSSCKFWSession *fwSession;

#ifdef NSSDEBUG
  if( CKR_OK != nssCKFWInstance_verifyPointer(fwInstance) ) {
    return (NSSCKFWSession *)NULL;
  }
#endif /* NSSDEBUG */

  if( CKR_OK != nssCKFWMutex_Lock(fwInstance->mutex) ) {
    return (NSSCKFWSession *)NULL;
  }

  fwSession = (NSSCKFWSession *)nssCKFWHash_Lookup(
                fwInstance->sessionHandleHash, (const void *)hSession);

  /* Assert(hSession == nssCKFWSession_GetHandle(fwSession)) */

  (void)nssCKFWMutex_Unlock(fwInstance->mutex);

  return fwSession;
}

Here is the caller graph for this function:

NSS_EXTERN CK_RV nssCKFWInstance_verifyPointer ( const NSSCKFWInstance *  fwInstance)

Here is the caller graph for this function:

NSS_EXTERN NSSCKFWSlot* nssCKFWInstance_WaitForSlotEvent ( NSSCKFWInstance *  fwInstance,
CK_BBOOL  block,
CK_RV pError 
)

Definition at line 1174 of file instance.c.

{
  NSSCKFWSlot *fwSlot = (NSSCKFWSlot *)NULL;
  NSSCKMDSlot *mdSlot;
  CK_ULONG i, n;

#ifdef NSSDEBUG
  if( (CK_RV *)NULL == 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( (void *)NULL == (void *)fwInstance->mdInstance->WaitForSlotEvent ) {
    *pError = CKR_NO_EVENT;
    return (NSSCKFWSlot *)NULL;
  }

  mdSlot = fwInstance->mdInstance->WaitForSlotEvent(
    fwInstance->mdInstance,
    fwInstance,
    block,
    pError
  );

  if( (NSSCKMDSlot *)NULL == 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( (NSSCKFWSlot *)NULL == fwSlot ) {
    /* Internal error */
    *pError = CKR_GENERAL_ERROR;
    return (NSSCKFWSlot *)NULL;
  }

  return fwSlot;
}

Here is the caller graph for this function:

NSS_EXTERN NSSCKFWMechanism* nssCKFWMechanism_Create ( void  )

Definition at line 82 of file mechanism.c.

{
  return (NSSCKFWMechanism *)NULL;
}
NSS_EXTERN CK_RV nssCKFWMechanism_Destroy ( NSSCKFWMechanism *  fwMechanism)

Definition at line 95 of file mechanism.c.

{
   return CKR_OK;
}
NSS_EXTERN CK_BBOOL nssCKFWMechanism_GetInHardware ( NSSCKFWMechanism *  fwMechanism)

Definition at line 162 of file mechanism.c.

{
    return PR_FALSE;
}

Here is the caller graph for this function:

NSS_EXTERN CK_ULONG nssCKFWMechanism_GetMaxKeySize ( NSSCKFWMechanism *  fwMechanism)

Definition at line 149 of file mechanism.c.

{
   return 0;
}

Here is the caller graph for this function:

NSS_EXTERN NSSCKMDMechanism* nssCKFWMechanism_GetMDMechanism ( NSSCKFWMechanism *  fwMechanism)

Definition at line 109 of file mechanism.c.

{
    return NULL;
}
NSS_EXTERN CK_ULONG nssCKFWMechanism_GetMinKeySize ( NSSCKFWMechanism *  fwMechanism)

Definition at line 136 of file mechanism.c.

{
    return 0;
}

Here is the caller graph for this function:

NSS_EXTERN NSSItem* nssCKFWMechanism_GetParameter ( NSSCKFWMechanism *  fwMechanism)

Definition at line 123 of file mechanism.c.

{
       return NULL;
}
NSS_EXTERN NSSCKFWMutex* nssCKFWMutex_Create ( CK_C_INITIALIZE_ARGS_PTR  pInitArgs,
CryptokiLockingState  LockingState,
NSSArena *  arena,
CK_RV pError 
)

Definition at line 129 of file mutex.c.

{
  NSSCKFWMutex *mutex;
  
  mutex = nss_ZNEW(arena, NSSCKFWMutex);
  if( (NSSCKFWMutex *)NULL == mutex ) {
    *pError = CKR_HOST_MEMORY;
    return (NSSCKFWMutex *)NULL;
  }
  *pError = CKR_OK;
  mutex->lock = NULL;
  if (LockingState == MultiThreaded) {
    mutex->lock = PR_NewLock();
    if (!mutex->lock) {
      *pError = CKR_HOST_MEMORY; /* we couldn't get the resource */
    }
  }
    
  if( CKR_OK != *pError ) {
    (void)nss_ZFreeIf(mutex);
    return (NSSCKFWMutex *)NULL;
  }

#ifdef DEBUG
  *pError = mutex_add_pointer(mutex);
  if( CKR_OK != *pError ) {
    if (mutex->lock) {
      PR_DestroyLock(mutex->lock);
    }
    (void)nss_ZFreeIf(mutex);
    return (NSSCKFWMutex *)NULL;
  }
#endif /* DEBUG */

  return mutex;
}  

Here is the caller graph for this function:

NSS_EXTERN CK_RV nssCKFWMutex_Destroy ( NSSCKFWMutex *  mutex)

Definition at line 177 of file mutex.c.

{
  CK_RV rv = CKR_OK;

#ifdef NSSDEBUG
  rv = nssCKFWMutex_verifyPointer(mutex);
  if( CKR_OK != rv ) {
    return rv;
  }
#endif /* NSSDEBUG */
 
  if (mutex->lock) {
    PR_DestroyLock(mutex->lock);
  } 

#ifdef DEBUG
  (void)mutex_remove_pointer(mutex);
#endif /* DEBUG */

  (void)nss_ZFreeIf(mutex);
  return rv;
}

Here is the caller graph for this function:

NSS_EXTERN CK_RV nssCKFWMutex_Lock ( NSSCKFWMutex *  mutex)

Definition at line 208 of file mutex.c.

{
#ifdef NSSDEBUG
  CK_RV rv = nssCKFWMutex_verifyPointer(mutex);
  if( CKR_OK != rv ) {
    return rv;
  }
#endif /* NSSDEBUG */
  if (mutex->lock) {
    PR_Lock(mutex->lock);
  }
  
  return CKR_OK;
}
NSS_EXTERN CK_RV nssCKFWMutex_Unlock ( NSSCKFWMutex *  mutex)

Definition at line 231 of file mutex.c.

{
  PRStatus nrv;
#ifdef NSSDEBUG
  CK_RV rv = nssCKFWMutex_verifyPointer(mutex);

  if( CKR_OK != rv ) {
    return rv;
  }
#endif /* NSSDEBUG */

  if (!mutex->lock) 
    return CKR_OK;

  nrv =  PR_Unlock(mutex->lock);

  /* if unlock fails, either we have a programming error, or we have
   * some sort of hardware failure... in either case return CKR_DEVICE_ERROR.
   */
  return nrv == PR_SUCCESS ? CKR_OK : CKR_DEVICE_ERROR;
}
NSS_EXTERN NSSCKFWObject* nssCKFWObject_Create ( NSSArena *  arena,
NSSCKMDObject *  mdObject,
NSSCKFWSession *  fwSession,
NSSCKFWToken *  fwToken,
NSSCKFWInstance *  fwInstance,
CK_RV pError 
)

Definition at line 149 of file object.c.

{
  NSSCKFWObject *fwObject;
  nssCKFWHash *mdObjectHash;

#ifdef NSSDEBUG
  if( (CK_RV *)NULL == pError ) {
    return (NSSCKFWObject *)NULL;
  }

  if( PR_SUCCESS != nssArena_verifyPointer(arena) ) {
    *pError = CKR_ARGUMENTS_BAD;
    return (NSSCKFWObject *)NULL;
  }
#endif /* NSSDEBUG */

  mdObjectHash = nssCKFWToken_GetMDObjectHash(fwToken);
  if( (nssCKFWHash *)NULL == mdObjectHash ) {
    *pError = CKR_GENERAL_ERROR;
    return (NSSCKFWObject *)NULL;
  }

  if( nssCKFWHash_Exists(mdObjectHash, mdObject) ) {
    fwObject = nssCKFWHash_Lookup(mdObjectHash, mdObject);
    return fwObject;
  }

  fwObject = nss_ZNEW(arena, NSSCKFWObject);
  if( (NSSCKFWObject *)NULL == fwObject ) {
    *pError = CKR_HOST_MEMORY;
    return (NSSCKFWObject *)NULL;
  }

  fwObject->arena = arena;
  fwObject->mdObject = mdObject;
  fwObject->fwSession = fwSession;

  if( (NSSCKFWSession *)NULL != fwSession ) {
    fwObject->mdSession = nssCKFWSession_GetMDSession(fwSession);
  }

  fwObject->fwToken = fwToken;

  if( (NSSCKFWToken *)NULL != fwToken ) {
    fwObject->mdToken = nssCKFWToken_GetMDToken(fwToken);
  }

  fwObject->fwInstance = fwInstance;
  fwObject->mdInstance = nssCKFWInstance_GetMDInstance(fwInstance);
  fwObject->mutex = nssCKFWInstance_CreateMutex(fwInstance, arena, pError);
  if( (NSSCKFWMutex *)NULL == fwObject->mutex ) {
    if( CKR_OK == *pError ) {
      *pError = CKR_GENERAL_ERROR;
    }
    return (NSSCKFWObject *)NULL;
  }

  *pError = nssCKFWHash_Add(mdObjectHash, mdObject, fwObject);
  if( CKR_OK != *pError ) {
    nss_ZFreeIf(fwObject);
    return (NSSCKFWObject *)NULL;
  }

#ifdef DEBUG
  *pError = object_add_pointer(fwObject);
  if( CKR_OK != *pError ) {
    nssCKFWHash_Remove(mdObjectHash, mdObject);
    nss_ZFreeIf(fwObject);
    return (NSSCKFWObject *)NULL;
  }
#endif /* DEBUG */

  *pError = CKR_OK;
  return fwObject;
}

Here is the caller graph for this function:

NSS_EXTERN void nssCKFWObject_Destroy ( NSSCKFWObject *  fwObject)

Definition at line 279 of file object.c.

{
  nssCKFWHash *mdObjectHash;

#ifdef NSSDEBUG
  if( CKR_OK != nssCKFWObject_verifyPointer(fwObject) ) {
    return;
  }
#endif /* NSSDEBUG */

  (void)nssCKFWMutex_Destroy(fwObject->mutex);

  if( (void *)NULL != (void *)fwObject->mdObject->Destroy ) {
    fwObject->mdObject->Destroy(fwObject->mdObject, fwObject,
      fwObject->mdSession, fwObject->fwSession, fwObject->mdToken,
      fwObject->fwToken, fwObject->mdInstance, fwObject->fwInstance);
  }

  mdObjectHash = nssCKFWToken_GetMDObjectHash(fwObject->fwToken);
  if( (nssCKFWHash *)NULL != mdObjectHash ) {
    nssCKFWHash_Remove(mdObjectHash, fwObject->mdObject);
  }

  nssCKFWSession_DeregisterSessionObject(fwObject->fwSession, fwObject);
  nss_ZFreeIf(fwObject);

#ifdef DEBUG
  (void)object_remove_pointer(fwObject);
#endif /* DEBUG */

  return;
}

Here is the caller graph for this function:

NSS_EXTERN void nssCKFWObject_Finalize ( NSSCKFWObject *  fwObject)

Definition at line 238 of file object.c.

{
  nssCKFWHash *mdObjectHash;

#ifdef NSSDEBUG
  if( CKR_OK != nssCKFWObject_verifyPointer(fwObject) ) {
    return;
  }
#endif /* NSSDEBUG */

  (void)nssCKFWMutex_Destroy(fwObject->mutex);

  if( (void *)NULL != (void *)fwObject->mdObject->Finalize ) {
    fwObject->mdObject->Finalize(fwObject->mdObject, fwObject,
      fwObject->mdSession, fwObject->fwSession, fwObject->mdToken,
      fwObject->fwToken, fwObject->mdInstance, fwObject->fwInstance);
  }

  mdObjectHash = nssCKFWToken_GetMDObjectHash(fwObject->fwToken);
  if( (nssCKFWHash *)NULL != mdObjectHash ) {
    nssCKFWHash_Remove(mdObjectHash, fwObject->mdObject);
  }

  nssCKFWSession_DeregisterSessionObject(fwObject->fwSession, fwObject);
  nss_ZFreeIf(fwObject);

#ifdef DEBUG
  (void)object_remove_pointer(fwObject);
#endif /* DEBUG */

  return;
}

Here is the caller graph for this function:

NSS_EXTERN NSSArena* nssCKFWObject_GetArena ( NSSCKFWObject *  fwObject,
CK_RV pError 
)

Definition at line 339 of file object.c.

{
#ifdef NSSDEBUG
  if( (CK_RV *)NULL == pError ) {
    return (NSSArena *)NULL;
  }

  *pError = nssCKFWObject_verifyPointer(fwObject);
  if( CKR_OK != *pError ) {
    return (NSSArena *)NULL;
  }
#endif /* NSSDEBUG */

  return fwObject->arena;
}

Here is the caller graph for this function:

NSS_EXTERN NSSItem* nssCKFWObject_GetAttribute ( NSSCKFWObject *  fwObject,
CK_ATTRIBUTE_TYPE  attribute,
NSSItem *  itemOpt,
NSSArena *  arenaOpt,
CK_RV pError 
)

Definition at line 595 of file object.c.

{
  NSSItem *rv = (NSSItem *)NULL;
  NSSCKFWItem mdItem;

#ifdef NSSDEBUG
  if( (CK_RV *)NULL == pError ) {
    return (NSSItem *)NULL;
  }

  *pError = nssCKFWObject_verifyPointer(fwObject);
  if( CKR_OK != *pError ) {
    return (NSSItem *)NULL;
  }
#endif /* NSSDEBUG */

  if( (void *)NULL == (void *)fwObject->mdObject->GetAttribute ) {
    *pError = CKR_GENERAL_ERROR;
    return (NSSItem *)NULL;
  }

  *pError = nssCKFWMutex_Lock(fwObject->mutex);
  if( CKR_OK != *pError ) {
    return (NSSItem *)NULL;
  }

  mdItem = fwObject->mdObject->GetAttribute(fwObject->mdObject, fwObject,
    fwObject->mdSession, fwObject->fwSession, fwObject->mdToken, 
    fwObject->fwToken, fwObject->mdInstance, fwObject->fwInstance,
    attribute, pError);

  if( (NSSItem *)NULL == mdItem.item ) {
    if( CKR_OK == *pError ) {
      *pError = CKR_GENERAL_ERROR;
    }

    goto done;
  }

  if( (NSSItem *)NULL == itemOpt ) {
    rv = nss_ZNEW(arenaOpt, NSSItem);
    if( (NSSItem *)NULL == rv ) {
      *pError = CKR_HOST_MEMORY;
      goto done;
    }
  } else {
    rv = itemOpt;
  }

  if( (void *)NULL == rv->data ) {
    rv->size = mdItem.item->size;
    rv->data = nss_ZAlloc(arenaOpt, rv->size);
    if( (void *)NULL == rv->data ) {
      *pError = CKR_HOST_MEMORY;
      if( (NSSItem *)NULL == itemOpt ) {
        nss_ZFreeIf(rv);
      }
      rv = (NSSItem *)NULL;
      goto done;
    }
  } else {
    if( rv->size >= mdItem.item->size ) {
      rv->size = mdItem.item->size;
    } else {
      *pError = CKR_BUFFER_TOO_SMALL;
      /* Should we set rv->size to mdItem->size? */
      /* rv can't have been allocated */
      rv = (NSSItem *)NULL;
      goto done;
    }
  }

  (void)nsslibc_memcpy(rv->data, mdItem.item->data, rv->size);

  if (PR_TRUE == mdItem.needsFreeing) {
    PR_ASSERT(fwObject->mdObject->FreeAttribute);
    if (fwObject->mdObject->FreeAttribute) {
      *pError = fwObject->mdObject->FreeAttribute(&mdItem);
    }
  }

 done:
  (void)nssCKFWMutex_Unlock(fwObject->mutex);
  return rv;
}

Here is the caller graph for this function:

NSS_EXTERN CK_ULONG nssCKFWObject_GetAttributeCount ( NSSCKFWObject *  fwObject,
CK_RV pError 
)

Definition at line 459 of file object.c.

{
  CK_ULONG rv;

#ifdef NSSDEBUG
  if( (CK_RV *)NULL == pError ) {
    return (CK_ULONG)0;
  }

  *pError = nssCKFWObject_verifyPointer(fwObject);
  if( CKR_OK != *pError ) {
    return (CK_ULONG)0;
  }
#endif /* NSSDEBUG */

  if( (void *)NULL == (void *)fwObject->mdObject->GetAttributeCount ) {
    *pError = CKR_GENERAL_ERROR;
    return (CK_ULONG)0;
  }

  *pError = nssCKFWMutex_Lock(fwObject->mutex);
  if( CKR_OK != *pError ) {
    return (CK_ULONG)0;
  }

  rv = fwObject->mdObject->GetAttributeCount(fwObject->mdObject, fwObject,
    fwObject->mdSession, fwObject->fwSession, fwObject->mdToken, 
    fwObject->fwToken, fwObject->mdInstance, fwObject->fwInstance,
    pError);

  (void)nssCKFWMutex_Unlock(fwObject->mutex);
  return rv;
}

Here is the caller graph for this function:

NSS_EXTERN CK_ULONG nssCKFWObject_GetAttributeSize ( NSSCKFWObject *  fwObject,
CK_ATTRIBUTE_TYPE  attribute,
CK_RV pError 
)

Definition at line 545 of file object.c.

{
  CK_ULONG rv;

#ifdef NSSDEBUG
  if( (CK_RV *)NULL == pError ) {
    return (CK_ULONG)0;
  }

  *pError = nssCKFWObject_verifyPointer(fwObject);
  if( CKR_OK != *pError ) {
    return (CK_ULONG)0;
  }
#endif /* NSSDEBUG */

  if( (void *)NULL == (void *)fwObject->mdObject->GetAttributeSize ) {
    *pError = CKR_GENERAL_ERROR;
    return (CK_ULONG )0;
  }

  *pError = nssCKFWMutex_Lock(fwObject->mutex);
  if( CKR_OK != *pError ) {
    return (CK_ULONG)0;
  }

  rv = fwObject->mdObject->GetAttributeSize(fwObject->mdObject, fwObject,
    fwObject->mdSession, fwObject->fwSession, fwObject->mdToken, 
    fwObject->fwToken, fwObject->mdInstance, fwObject->fwInstance,
    attribute, pError);

  (void)nssCKFWMutex_Unlock(fwObject->mutex);
  return rv;
}

Here is the caller graph for this function:

NSS_EXTERN CK_RV nssCKFWObject_GetAttributeTypes ( NSSCKFWObject *  fwObject,
CK_ATTRIBUTE_TYPE_PTR  typeArray,
CK_ULONG  ulCount 
)

Definition at line 502 of file object.c.

{
  CK_RV error = CKR_OK;

#ifdef NSSDEBUG
  error = nssCKFWObject_verifyPointer(fwObject);
  if( CKR_OK != error ) {
    return error;
  }

  if( (CK_ATTRIBUTE_TYPE_PTR)NULL == typeArray ) {
    return CKR_ARGUMENTS_BAD;
  }
#endif /* NSSDEBUG */

  if( (void *)NULL == (void *)fwObject->mdObject->GetAttributeTypes ) {
    return CKR_GENERAL_ERROR;
  }

  error = nssCKFWMutex_Lock(fwObject->mutex);
  if( CKR_OK != error ) {
    return error;
  }

  error = fwObject->mdObject->GetAttributeTypes(fwObject->mdObject, fwObject,
    fwObject->mdSession, fwObject->fwSession, fwObject->mdToken, 
    fwObject->fwToken, fwObject->mdInstance, fwObject->fwInstance,
    typeArray, ulCount);

  (void)nssCKFWMutex_Unlock(fwObject->mutex);
  return error;
}

Here is the caller graph for this function:

NSS_EXTERN CK_OBJECT_HANDLE nssCKFWObject_GetHandle ( NSSCKFWObject *  fwObject)

Definition at line 395 of file object.c.

{
#ifdef NSSDEBUG
  if( CKR_OK != nssCKFWObject_verifyPointer(fwObject) ) {
    return (CK_OBJECT_HANDLE)0;
  }
#endif /* NSSDEBUG */

  return fwObject->hObject;
}

Here is the caller graph for this function:

NSS_EXTERN NSSCKMDObject* nssCKFWObject_GetMDObject ( NSSCKFWObject *  fwObject)

Definition at line 320 of file object.c.

{
#ifdef NSSDEBUG
  if( CKR_OK != nssCKFWObject_verifyPointer(fwObject) ) {
    return (NSSCKMDObject *)NULL;
  }
#endif /* NSSDEBUG */

  return fwObject->mdObject;
}

Here is the caller graph for this function:

NSS_EXTERN CK_ULONG nssCKFWObject_GetObjectSize ( NSSCKFWObject *  fwObject,
CK_RV pError 
)

Definition at line 819 of file object.c.

{
  CK_ULONG rv;

#ifdef NSSDEBUG
  if( (CK_RV *)NULL == pError ) {
    return (CK_ULONG)0;
  }

  *pError = nssCKFWObject_verifyPointer(fwObject);
  if( CKR_OK != *pError ) {
    return (CK_ULONG)0;
  }
#endif /* NSSDEBUG */

  if( (void *)NULL == (void *)fwObject->mdObject->GetObjectSize ) {
    *pError = CKR_INFORMATION_SENSITIVE;
    return (CK_ULONG)0;
  }

  *pError = nssCKFWMutex_Lock(fwObject->mutex);
  if( CKR_OK != *pError ) {
    return (CK_ULONG)0;
  }

  rv = fwObject->mdObject->GetObjectSize(fwObject->mdObject, fwObject,
    fwObject->mdSession, fwObject->fwSession, fwObject->mdToken, 
    fwObject->fwToken, fwObject->mdInstance, fwObject->fwInstance,
    pError);

  (void)nssCKFWMutex_Unlock(fwObject->mutex);
  return rv;
}

Here is the caller graph for this function:

NSS_EXTERN CK_BBOOL nssCKFWObject_IsTokenObject ( NSSCKFWObject *  fwObject)

Definition at line 414 of file object.c.

{
  CK_BBOOL b = CK_FALSE;

#ifdef NSSDEBUG
  if( CKR_OK != nssCKFWObject_verifyPointer(fwObject) ) {
    return CK_FALSE;
  }
#endif /* NSSDEBUG */

  if( (void *)NULL == (void *)fwObject->mdObject->IsTokenObject ) {
    NSSItem item;
    NSSItem *pItem;
    CK_RV rv = CKR_OK;

    item.data = (void *)&b;
    item.size = sizeof(b);

    pItem = nssCKFWObject_GetAttribute(fwObject, CKA_TOKEN, &item, 
      (NSSArena *)NULL, &rv);
    if( (NSSItem *)NULL == pItem ) {
      /* Error of some type */
      b = CK_FALSE;
      goto done;
    }

    goto done;
  }

  b = fwObject->mdObject->IsTokenObject(fwObject->mdObject, fwObject, 
    fwObject->mdSession, fwObject->fwSession, fwObject->mdToken,
    fwObject->fwToken, fwObject->mdInstance, fwObject->fwInstance);

 done:
  return b;
}

Here is the caller graph for this function:

NSS_EXTERN CK_RV nssCKFWObject_SetAttribute ( NSSCKFWObject *  fwObject,
CK_ATTRIBUTE_TYPE  attribute,
NSSItem *  value 
)

Definition at line 693 of file object.c.

{
  CK_RV error = CKR_OK;

#ifdef NSSDEBUG
  error = nssCKFWObject_verifyPointer(fwObject);
  if( CKR_OK != error ) {
    return error;
  }
#endif /* NSSDEBUG */

  if( CKA_TOKEN == attribute ) {
    /*
     * We're changing from a session object to a token object or 
     * vice-versa.
     */

    CK_ATTRIBUTE a;
    NSSCKFWObject *newFwObject;
    NSSCKFWObject swab;

    a.type = CKA_TOKEN;
    a.pValue = value->data;
    a.ulValueLen = value->size;

    newFwObject = nssCKFWSession_CopyObject(fwObject->fwSession, fwObject,
                    &a, 1, &error);
    if( (NSSCKFWObject *)NULL == newFwObject ) {
      if( CKR_OK == error ) {
        error = CKR_GENERAL_ERROR;
      }
      return error;
    }

    /*
     * Actually, I bet the locking is worse than this.. this part of
     * the code could probably use some scrutiny and reworking.
     */
    error = nssCKFWMutex_Lock(fwObject->mutex);
    if( CKR_OK != error ) {
      nssCKFWObject_Destroy(newFwObject);
      return error;
    }

    error = nssCKFWMutex_Lock(newFwObject->mutex);
    if( CKR_OK != error ) {
      nssCKFWMutex_Unlock(fwObject->mutex);
      nssCKFWObject_Destroy(newFwObject);
      return error;
    }

    /* 
     * Now, we have our new object, but it has a new fwObject pointer,
     * while we have to keep the existing one.  So quick swap the contents.
     */
    swab = *fwObject;
    *fwObject = *newFwObject;
    *newFwObject = swab;

    /* But keep the mutexes the same */
    swab.mutex = fwObject->mutex;
    fwObject->mutex = newFwObject->mutex;
    newFwObject->mutex = swab.mutex;

    (void)nssCKFWMutex_Unlock(newFwObject->mutex);
    (void)nssCKFWMutex_Unlock(fwObject->mutex);

    /*
     * Either remove or add this to the list of session objects
     */

    if( CK_FALSE == *(CK_BBOOL *)value->data ) {
      /* 
       * New one is a session object, except since we "stole" the fwObject, it's
       * not in the list.  Add it.
       */
      nssCKFWSession_RegisterSessionObject(fwObject->fwSession, fwObject);
    } else {
      /*
       * New one is a token object, except since we "stole" the fwObject, it's
       * in the list.  Remove it.
       */
      nssCKFWSession_DeregisterSessionObject(fwObject->fwSession, fwObject);
    }

    /*
     * Now delete the old object.  Remember the names have changed.
     */
    nssCKFWObject_Destroy(newFwObject);

    return CKR_OK;
  } else {
    /*
     * An "ordinary" change.
     */
    if( (void *)NULL == (void *)fwObject->mdObject->SetAttribute ) {
      /* We could fake it with copying, like above.. later */
      return CKR_ATTRIBUTE_READ_ONLY;
    }

    error = nssCKFWMutex_Lock(fwObject->mutex);
    if( CKR_OK != error ) {
      return error;
    }

    error = fwObject->mdObject->SetAttribute(fwObject->mdObject, fwObject,
      fwObject->mdSession, fwObject->fwSession, fwObject->mdToken, 
      fwObject->fwToken, fwObject->mdInstance, fwObject->fwInstance,
      attribute, value);

    (void)nssCKFWMutex_Unlock(fwObject->mutex);

    return error;
  }
}
NSS_EXTERN CK_RV nssCKFWObject_SetHandle ( NSSCKFWObject *  fwObject,
CK_OBJECT_HANDLE  hObject 
)

Definition at line 364 of file object.c.

{
#ifdef NSSDEBUG
  CK_RV error = CKR_OK;
#endif /* NSSDEBUG */

#ifdef NSSDEBUG
  error = nssCKFWObject_verifyPointer(fwObject);
  if( CKR_OK != error ) {
    return error;
  }
#endif /* NSSDEBUG */

  if( (CK_OBJECT_HANDLE)0 != fwObject->hObject ) {
    return CKR_GENERAL_ERROR;
  }

  fwObject->hObject = hObject;

  return CKR_OK;
}

Here is the caller graph for this function:

NSS_EXTERN CK_RV nssCKFWSession_CallNotification ( NSSCKFWSession *  fwSession,
CK_NOTIFICATION  event 
)

Definition at line 353 of file session.c.

{
  CK_RV error = CKR_OK;
  CK_SESSION_HANDLE handle;

#ifdef NSSDEBUG
  error = nssCKFWSession_verifyPointer(fwSession);
  if( CKR_OK != error ) {
    return error;
  }
#endif /* NSSDEBUG */

  if( (CK_NOTIFY)NULL == fwSession->Notify ) {
    return CKR_OK;
  }

  handle = nssCKFWInstance_FindSessionHandle(fwSession->fwInstance, fwSession);
  if( (CK_SESSION_HANDLE)0 == handle ) {
    return CKR_GENERAL_ERROR;
  }

  error = fwSession->Notify(handle, event, fwSession->pApplication);

  return error;
}

Here is the caller graph for this function:

NSS_EXTERN NSSCKFWObject* nssCKFWSession_CopyObject ( NSSCKFWSession *  fwSession,
NSSCKFWObject *  object,
CK_ATTRIBUTE_PTR  pTemplate,
CK_ULONG  ulAttributeCount,
CK_RV pError 
)

Definition at line 1399 of file session.c.

{
  CK_BBOOL oldIsToken;
  CK_BBOOL newIsToken;
  CK_ULONG i;
  NSSCKFWObject *rv;

#ifdef NSSDEBUG
  if( (CK_RV *)NULL == pError ) {
    return (NSSCKFWObject *)NULL;
  }

  *pError = nssCKFWSession_verifyPointer(fwSession);
  if( CKR_OK != *pError ) {
    return (NSSCKFWObject *)NULL;
  }

  *pError = nssCKFWObject_verifyPointer(fwObject);
  if( CKR_OK != *pError ) {
    return (NSSCKFWObject *)NULL;
  }

  if( (NSSCKMDSession *)NULL == fwSession->mdSession ) {
    *pError = CKR_GENERAL_ERROR;
    return (NSSCKFWObject *)NULL;
  }
#endif /* NSSDEBUG */

  /*
   * Sanity-check object
   */

  oldIsToken = nssCKFWObject_IsTokenObject(fwObject);

  newIsToken = oldIsToken;
  for( i = 0; i < ulAttributeCount; i++ ) {
    if( CKA_TOKEN == pTemplate[i].type ) {
      /* Since we sanity-checked the object, we know this is the right size. */
      (void)nsslibc_memcpy(&newIsToken, pTemplate[i].pValue, sizeof(CK_BBOOL));
      break;
    }
  }

  /*
   * If the Module handles its session objects, or if both the new
   * and old object are token objects, use CopyObject if it exists.
   */

  if( ((void *)NULL != (void *)fwSession->mdSession->CopyObject) &&
      (((CK_TRUE == oldIsToken) && (CK_TRUE == newIsToken)) ||
       (CK_TRUE == nssCKFWInstance_GetModuleHandlesSessionObjects(
                     fwSession->fwInstance))) ) {
    /* use copy object */
    NSSArena *arena;
    NSSCKMDObject *mdOldObject;
    NSSCKMDObject *mdObject;

    mdOldObject = nssCKFWObject_GetMDObject(fwObject);

    if( CK_TRUE == newIsToken ) {
      arena = nssCKFWToken_GetArena(fwSession->fwToken, pError);
    } else {
      arena = nssCKFWSession_GetArena(fwSession, pError);
    }
    if( (NSSArena *)NULL == arena ) {
      if( CKR_OK == *pError ) {
        *pError = CKR_GENERAL_ERROR;
      }
      return (NSSCKFWObject *)NULL;
    }

    mdObject = fwSession->mdSession->CopyObject(fwSession->mdSession,
      fwSession, fwSession->mdToken, fwSession->fwToken,
      fwSession->mdInstance, fwSession->fwInstance, mdOldObject,
      fwObject, arena, pTemplate, ulAttributeCount, pError);
    if( (NSSCKMDObject *)NULL == mdObject ) {
      if( CKR_OK == *pError ) {
        *pError = CKR_GENERAL_ERROR;
      }
      return (NSSCKFWObject *)NULL;
    }

    rv = nssCKFWObject_Create(arena, mdObject, fwSession,
      fwSession->fwToken, fwSession->fwInstance, pError);
    if( (NSSCKFWObject *)NULL == fwObject ) {
      if( CKR_OK == *pError ) {
        *pError = CKR_GENERAL_ERROR;
      }

      if( (void *)NULL != (void *)mdObject->Destroy ) {
        (void)mdObject->Destroy(mdObject, (NSSCKFWObject *)NULL,
          fwSession->mdSession, fwSession, fwSession->mdToken,
          fwSession->fwToken, fwSession->mdInstance, fwSession->fwInstance);
      }
    
      return (NSSCKFWObject *)NULL;
    }

    if( CK_FALSE == newIsToken ) {
      if( CK_FALSE == nssCKFWHash_Exists(fwSession->sessionObjectHash, rv) ) {
        *pError = nssCKFWHash_Add(fwSession->sessionObjectHash, rv, rv);
        if( CKR_OK != *pError ) {
          nssCKFWObject_Finalize(rv);
          return (NSSCKFWObject *)NULL;
        }
      }
    }

    return rv;
  } else {
    /* use create object */
    NSSArena *tmpArena;
    CK_ATTRIBUTE_PTR newTemplate;
    CK_ULONG i, j, n, newLength, k;
    CK_ATTRIBUTE_TYPE_PTR oldTypes;
    NSSCKFWObject *rv;
    
    tmpArena = NSSArena_Create();
    if( (NSSArena *)NULL == tmpArena ) {
      *pError = CKR_HOST_MEMORY;
      return (NSSCKFWObject *)NULL;
    }

    n = nssCKFWObject_GetAttributeCount(fwObject, pError);
    if( (0 == n) && (CKR_OK != *pError) ) {
      return (NSSCKFWObject *)NULL;
    }

    oldTypes = nss_ZNEWARRAY(tmpArena, CK_ATTRIBUTE_TYPE, n);
    if( (CK_ATTRIBUTE_TYPE_PTR)NULL == oldTypes ) {
      NSSArena_Destroy(tmpArena);
      *pError = CKR_HOST_MEMORY;
      return (NSSCKFWObject *)NULL;
    }

    *pError = nssCKFWObject_GetAttributeTypes(fwObject, oldTypes, n);
    if( CKR_OK != *pError ) {
      NSSArena_Destroy(tmpArena);
      return (NSSCKFWObject *)NULL;
    }

    newLength = n;
    for( i = 0; i < ulAttributeCount; i++ ) {
      for( j = 0; j < n; j++ ) {
        if( oldTypes[j] == pTemplate[i].type ) {
          if( (CK_VOID_PTR)NULL == pTemplate[i].pValue ) {
            /* Removing the attribute */
            newLength--;
          }
          break;
        }
      }
      if( j == n ) {
        /* Not found */
        newLength++;
      }
    }

    newTemplate = nss_ZNEWARRAY(tmpArena, CK_ATTRIBUTE, newLength);
    if( (CK_ATTRIBUTE_PTR)NULL == newTemplate ) {
      NSSArena_Destroy(tmpArena);
      *pError = CKR_HOST_MEMORY;
      return (NSSCKFWObject *)NULL;
    }

    k = 0;
    for( j = 0; j < n; j++ ) {
      for( i = 0; i < ulAttributeCount; i++ ) {
        if( oldTypes[j] == pTemplate[i].type ) {
          if( (CK_VOID_PTR)NULL == pTemplate[i].pValue ) {
            /* This attribute is being deleted */
            ;
          } else {
            /* This attribute is being replaced */
            newTemplate[k].type = pTemplate[i].type;
            newTemplate[k].pValue = pTemplate[i].pValue;
            newTemplate[k].ulValueLen = pTemplate[i].ulValueLen;
            k++;
          }
          break;
        }
      }
      if( i == ulAttributeCount ) {
        /* This attribute is being copied over from the old object */
        NSSItem item, *it;
        item.size = 0;
        item.data = (void *)NULL;
        it = nssCKFWObject_GetAttribute(fwObject, oldTypes[j],
          &item, tmpArena, pError);
        if( (NSSItem *)NULL == it ) {
          if( CKR_OK == *pError ) {
            *pError = CKR_GENERAL_ERROR;
          }
          NSSArena_Destroy(tmpArena);
          return (NSSCKFWObject *)NULL;
        }
        newTemplate[k].type = oldTypes[j];
        newTemplate[k].pValue = it->data;
        newTemplate[k].ulValueLen = it->size;
        k++;
      }
    }
    /* assert that k == newLength */

    rv = nssCKFWSession_CreateObject(fwSession, newTemplate, newLength, pError);
    if( (NSSCKFWObject *)NULL == rv ) {
      if( CKR_OK == *pError ) {
        *pError = CKR_GENERAL_ERROR;
      }
      NSSArena_Destroy(tmpArena);
      return (NSSCKFWObject *)NULL;
    }

    NSSArena_Destroy(tmpArena);
    return rv;
  }
}

Here is the caller graph for this function:

NSS_EXTERN NSSCKFWSession* nssCKFWSession_Create ( NSSCKFWToken *  fwToken,
CK_BBOOL  rw,
CK_VOID_PTR  pApplication,
CK_NOTIFY  Notify,
CK_RV pError 
)

Definition at line 168 of file session.c.

{
  NSSArena *arena = (NSSArena *)NULL;
  NSSCKFWSession *fwSession;
  NSSCKFWSlot *fwSlot;

#ifdef NSSDEBUG
  if( (CK_RV *)NULL == pError ) {
    return (NSSCKFWSession *)NULL;
  }

  *pError = nssCKFWToken_verifyPointer(fwToken);
  if( CKR_OK != *pError ) {
    return (NSSCKFWSession *)NULL;
  }
#endif /* NSSDEBUG */

  arena = NSSArena_Create();
  if( (NSSArena *)NULL == arena ) {
    *pError = CKR_HOST_MEMORY;
    return (NSSCKFWSession *)NULL;
  }

  fwSession = nss_ZNEW(arena, NSSCKFWSession);
  if( (NSSCKFWSession *)NULL == fwSession ) {
    *pError = CKR_HOST_MEMORY;
    goto loser;
  }

  fwSession->arena = arena;
  fwSession->mdSession = (NSSCKMDSession *)NULL; /* set later */
  fwSession->fwToken = fwToken;
  fwSession->mdToken = nssCKFWToken_GetMDToken(fwToken);

  fwSlot = nssCKFWToken_GetFWSlot(fwToken);
  fwSession->fwInstance = nssCKFWSlot_GetFWInstance(fwSlot);
  fwSession->mdInstance = nssCKFWSlot_GetMDInstance(fwSlot);

  fwSession->rw = rw;
  fwSession->pApplication = pApplication;
  fwSession->Notify = Notify;

  fwSession->fwFindObjects = (NSSCKFWFindObjects *)NULL;

  fwSession->sessionObjectHash = nssCKFWHash_Create(fwSession->fwInstance, arena, pError);
  if( (nssCKFWHash *)NULL == fwSession->sessionObjectHash ) {
    if( CKR_OK == *pError ) {
      *pError = CKR_GENERAL_ERROR;
    }
    goto loser;
  }

#ifdef DEBUG
  *pError = session_add_pointer(fwSession);
  if( CKR_OK != *pError ) {
    goto loser;
  }
#endif /* DEBUG */

  return fwSession;

 loser:
  if( (NSSArena *)NULL != arena ) {
    if( fwSession && (nssCKFWHash *)NULL != fwSession->sessionObjectHash ) {
      (void)nssCKFWHash_Destroy(fwSession->sessionObjectHash);
    }
    NSSArena_Destroy(arena);
  }

  return (NSSCKFWSession *)NULL;
}

Here is the caller graph for this function:

NSS_EXTERN NSSCKFWObject* nssCKFWSession_CreateObject ( NSSCKFWSession *  fwSession,
CK_ATTRIBUTE_PTR  pTemplate,
CK_ULONG  ulAttributeCount,
CK_RV pError 
)

Definition at line 1266 of file session.c.

{
  NSSArena *arena;
  NSSCKMDObject *mdObject;
  NSSCKFWObject *fwObject;
  CK_BBOOL isTokenObject;

#ifdef NSSDEBUG
  if( (CK_RV *)NULL == pError ) {
    return (NSSCKFWObject *)NULL;
  }

  *pError = nssCKFWSession_verifyPointer(fwSession);
  if( CKR_OK != pError ) {
    return (NSSCKFWObject *)NULL;
  }

  if( (CK_ATTRIBUTE_PTR)NULL == pTemplate ) {
    *pError = CKR_ARGUMENTS_BAD;
    return (NSSCKFWObject *)NULL;
  }

  if( (NSSCKMDSession *)NULL == fwSession->mdSession ) {
    *pError = CKR_GENERAL_ERROR;
    return (NSSCKFWObject *)NULL;
  }
#endif /* NSSDEBUG */

  /*
   * Here would be an excellent place to sanity-check the object.
   */

  isTokenObject = nss_attributes_form_token_object(pTemplate, ulAttributeCount);
  if( CK_TRUE == isTokenObject ) {
    /* === TOKEN OBJECT === */

    if( (void *)NULL == (void *)fwSession->mdSession->CreateObject ) {
      *pError = CKR_TOKEN_WRITE_PROTECTED;
      return (NSSCKFWObject *)NULL;
    }

    arena = nssCKFWToken_GetArena(fwSession->fwToken, pError);
    if( (NSSArena *)NULL == arena ) {
      if( CKR_OK == *pError ) {
        *pError = CKR_GENERAL_ERROR;
      }
      return (NSSCKFWObject *)NULL;
    }

    goto callmdcreateobject;
  } else {
    /* === SESSION OBJECT === */

    arena = nssCKFWSession_GetArena(fwSession, pError);
    if( (NSSArena *)NULL == arena ) {
      if( CKR_OK == *pError ) {
        *pError = CKR_GENERAL_ERROR;
      }
      return (NSSCKFWObject *)NULL;
    }

    if( CK_TRUE == nssCKFWInstance_GetModuleHandlesSessionObjects(
                     fwSession->fwInstance) ) {
      /* --- module handles the session object -- */

      if( (void *)NULL == (void *)fwSession->mdSession->CreateObject ) {
        *pError = CKR_GENERAL_ERROR;
        return (NSSCKFWObject *)NULL;
      }
      
      goto callmdcreateobject;
    } else {
      /* --- framework handles the session object -- */
      mdObject = nssCKMDSessionObject_Create(fwSession->fwToken, 
        arena, pTemplate, ulAttributeCount, pError);
      goto gotmdobject;
    }
  }

 callmdcreateobject:
  mdObject = fwSession->mdSession->CreateObject(fwSession->mdSession,
    fwSession, fwSession->mdToken, fwSession->fwToken,
    fwSession->mdInstance, fwSession->fwInstance, arena, pTemplate,
    ulAttributeCount, pError);

 gotmdobject:
  if( (NSSCKMDObject *)NULL == mdObject ) {
    if( CKR_OK == *pError ) {
      *pError = CKR_GENERAL_ERROR;
    }
    return (NSSCKFWObject *)NULL;
  }

  fwObject = nssCKFWObject_Create(arena, mdObject, fwSession, 
    fwSession->fwToken, fwSession->fwInstance, pError);
  if( (NSSCKFWObject *)NULL == fwObject ) {
    if( CKR_OK == *pError ) {
      *pError = CKR_GENERAL_ERROR;
    }
    
    if( (void *)NULL != (void *)mdObject->Destroy ) {
      (void)mdObject->Destroy(mdObject, (NSSCKFWObject *)NULL,
        fwSession->mdSession, fwSession, fwSession->mdToken,
        fwSession->fwToken, fwSession->mdInstance, fwSession->fwInstance);
    }
    
    return (NSSCKFWObject *)NULL;
  }

  if( CK_FALSE == isTokenObject ) {
    if( CK_FALSE == nssCKFWHash_Exists(fwSession->sessionObjectHash, fwObject) ) {
      *pError = nssCKFWHash_Add(fwSession->sessionObjectHash, fwObject, fwObject);
      if( CKR_OK != *pError ) {
        nssCKFWObject_Finalize(fwObject);
        return (NSSCKFWObject *)NULL;
      }
    }
  }
  
  return fwObject;
}

Here is the caller graph for this function:

NSS_EXTERN CK_RV nssCKFWSession_DeregisterSessionObject ( NSSCKFWSession *  fwSession,
NSSCKFWObject *  fwObject 
)

Definition at line 652 of file session.c.

{
#ifdef NSSDEBUG
  if( CKR_OK != nssCKFWSession_verifyPointer(fwSession) ) {
    return CKR_GENERAL_ERROR;
  }
#endif /* NSSDEBUG */

  if( (nssCKFWHash *)NULL != fwSession->sessionObjectHash ) {
    nssCKFWHash_Remove(fwSession->sessionObjectHash, fwObject);
  }

  return CKR_OK;
}

Here is the caller graph for this function:

NSS_EXTERN CK_RV nssCKFWSession_Destroy ( NSSCKFWSession *  fwSession,
CK_BBOOL  removeFromTokenHash 
)

Definition at line 264 of file session.c.

{
  CK_RV error = CKR_OK;
  nssCKFWHash *sessionObjectHash;

#ifdef NSSDEBUG
  error = nssCKFWSession_verifyPointer(fwSession);
  if( CKR_OK != error ) {
    return error;
  }
#endif /* NSSDEBUG */

  if( removeFromTokenHash ) {
    error = nssCKFWToken_RemoveSession(fwSession->fwToken, fwSession);
  }

  /*
   * Invalidate session objects
   */

  sessionObjectHash = fwSession->sessionObjectHash;
  fwSession->sessionObjectHash = (nssCKFWHash *)NULL;

  nssCKFWHash_Iterate(sessionObjectHash, 
                      nss_ckfw_session_object_destroy_iterator, 
                      (void *)NULL);

#ifdef DEBUG
  (void)session_remove_pointer(fwSession);
#endif /* DEBUG */
  (void)nssCKFWHash_Destroy(sessionObjectHash);
  NSSArena_Destroy(fwSession->arena);

  return error;
}

Here is the caller graph for this function:

NSS_EXTERN NSSCKFWFindObjects* nssCKFWSession_FindObjectsInit ( NSSCKFWSession *  fwSession,
CK_ATTRIBUTE_PTR  pTemplate,
CK_ULONG  ulAttributeCount,
CK_RV pError 
)

Definition at line 1629 of file session.c.

{
  NSSCKMDFindObjects *mdfo1 = (NSSCKMDFindObjects *)NULL;
  NSSCKMDFindObjects *mdfo2 = (NSSCKMDFindObjects *)NULL;

#ifdef NSSDEBUG
  if( (CK_RV *)NULL == pError ) {
    return (NSSCKFWFindObjects *)NULL;
  }

  *pError = nssCKFWSession_verifyPointer(fwSession);
  if( CKR_OK != *pError ) {
    return (NSSCKFWFindObjects *)NULL;
  }

  if( ((CK_ATTRIBUTE_PTR)NULL == pTemplate) && (ulAttributeCount != 0) ) {
    *pError = CKR_ARGUMENTS_BAD;
    return (NSSCKFWFindObjects *)NULL;
  }

  if( (NSSCKMDSession *)NULL == fwSession->mdSession ) {
    *pError = CKR_GENERAL_ERROR;
    return (NSSCKFWFindObjects *)NULL;
  }
#endif /* NSSDEBUG */

  if( CK_TRUE != nssCKFWInstance_GetModuleHandlesSessionObjects(
                   fwSession->fwInstance) ) {
    CK_ULONG i;

    /*
     * Does the search criteria restrict us to token or session
     * objects?
     */

    for( i = 0; i < ulAttributeCount; i++ ) {
      if( CKA_TOKEN == pTemplate[i].type ) {
        /* Yes, it does. */
        CK_BBOOL isToken;
        if( sizeof(CK_BBOOL) != pTemplate[i].ulValueLen ) {
          *pError = CKR_ATTRIBUTE_VALUE_INVALID;
          return (NSSCKFWFindObjects *)NULL;
        }
        (void)nsslibc_memcpy(&isToken, pTemplate[i].pValue, sizeof(CK_BBOOL));

        if( CK_TRUE == isToken ) {
          /* Pass it on to the module's search routine */
          if( (void *)NULL == (void *)fwSession->mdSession->FindObjectsInit ) {
            goto wrap;
          }

          mdfo1 = fwSession->mdSession->FindObjectsInit(fwSession->mdSession,
                    fwSession, fwSession->mdToken, fwSession->fwToken,
                    fwSession->mdInstance, fwSession->fwInstance, 
                    pTemplate, ulAttributeCount, pError);
        } else {
          /* Do the search ourselves */
          mdfo1 = nssCKMDFindSessionObjects_Create(fwSession->fwToken, 
                    pTemplate, ulAttributeCount, pError);
        }

        if( (NSSCKMDFindObjects *)NULL == mdfo1 ) {
          if( CKR_OK == *pError ) {
            *pError = CKR_GENERAL_ERROR;
          }
          return (NSSCKFWFindObjects *)NULL;
        }
        
        goto wrap;
      }
    }

    if( i == ulAttributeCount ) {
      /* No, it doesn't.  Do a hybrid search. */
      mdfo1 = fwSession->mdSession->FindObjectsInit(fwSession->mdSession,
                fwSession, fwSession->mdToken, fwSession->fwToken,
                fwSession->mdInstance, fwSession->fwInstance, 
                pTemplate, ulAttributeCount, pError);

      if( (NSSCKMDFindObjects *)NULL == mdfo1 ) {
        if( CKR_OK == *pError ) {
          *pError = CKR_GENERAL_ERROR;
        }
        return (NSSCKFWFindObjects *)NULL;
      }

      mdfo2 = nssCKMDFindSessionObjects_Create(fwSession->fwToken,
                pTemplate, ulAttributeCount, pError);
      if( (NSSCKMDFindObjects *)NULL == mdfo2 ) {
        if( CKR_OK == *pError ) {
          *pError = CKR_GENERAL_ERROR;
        }
        if( (void *)NULL != (void *)mdfo1->Final ) {
          mdfo1->Final(mdfo1, (NSSCKFWFindObjects *)NULL, fwSession->mdSession,
            fwSession, fwSession->mdToken, fwSession->fwToken, 
            fwSession->mdInstance, fwSession->fwInstance);
        }
        return (NSSCKFWFindObjects *)NULL;
      }

      goto wrap;
    }
    /*NOTREACHED*/
  } else {
    /* Module handles all its own objects.  Pass on to module's search */
    mdfo1 = fwSession->mdSession->FindObjectsInit(fwSession->mdSession,
              fwSession, fwSession->mdToken, fwSession->fwToken,
              fwSession->mdInstance, fwSession->fwInstance, 
              pTemplate, ulAttributeCount, pError);

    if( (NSSCKMDFindObjects *)NULL == mdfo1 ) {
      if( CKR_OK == *pError ) {
        *pError = CKR_GENERAL_ERROR;
      }
      return (NSSCKFWFindObjects *)NULL;
    }

    goto wrap;
  }

 wrap:
  return nssCKFWFindObjects_Create(fwSession, fwSession->fwToken,
           fwSession->fwInstance, mdfo1, mdfo2, pError);
}

Here is the caller graph for this function:

NSS_EXTERN NSSArena* nssCKFWSession_GetArena ( NSSCKFWSession *  fwSession,
CK_RV pError 
)

Definition at line 328 of file session.c.

{
#ifdef NSSDEBUG
  if( (CK_RV *)NULL == pError ) {
    return (NSSArena *)NULL;
  }

  *pError = nssCKFWSession_verifyPointer(fwSession);
  if( CKR_OK != *pError ) {
    return (NSSArena *)NULL;
  }
#endif /* NSSDEBUG */

  return fwSession->arena;
}

Here is the caller graph for this function:

NSS_EXTERN CK_ULONG nssCKFWSession_GetDeviceError ( NSSCKFWSession *  fwSession)

Definition at line 676 of file session.c.

{
#ifdef NSSDEBUG
  if( CKR_OK != nssCKFWSession_verifyPointer(fwSession) ) {
    return (CK_ULONG)0;
  }

  if( (NSSCKMDSession *)NULL == fwSession->mdSession ) {
    return (CK_ULONG)0;
  }
#endif /* NSSDEBUG */

  if( (void *)NULL == (void *)fwSession->mdSession->GetDeviceError ) {
    return (CK_ULONG)0;
  }

  return fwSession->mdSession->GetDeviceError(fwSession->mdSession, 
    fwSession, fwSession->mdToken, fwSession->fwToken, 
    fwSession->mdInstance, fwSession->fwInstance);
}

Here is the caller graph for this function:

NSS_EXTERN NSSCKFWFindObjects* nssCKFWSession_GetFWFindObjects ( NSSCKFWSession *  fwSesssion,
CK_RV pError 
)

Definition at line 511 of file session.c.

{
#ifdef NSSDEBUG
  if( (CK_RV *)NULL == pError ) {
    return (NSSCKFWFindObjects *)NULL;
  }

  *pError = nssCKFWSession_verifyPointer(fwSession);
  if( CKR_OK != *pError ) {
    return (NSSCKFWFindObjects *)NULL;
  }
#endif /* NSSDEBUG */

  if( (NSSCKFWFindObjects *)NULL == fwSession->fwFindObjects ) {
    *pError = CKR_OPERATION_NOT_INITIALIZED;
    return (NSSCKFWFindObjects *)NULL;
  }

  return fwSession->fwFindObjects;
}

Here is the caller graph for this function:

NSS_EXTERN NSSCKFWSlot* nssCKFWSession_GetFWSlot ( NSSCKFWSession *  fwSession)

Definition at line 439 of file session.c.

{
#ifdef NSSDEBUG
  if( CKR_OK != nssCKFWSession_verifyPointer(fwSession) ) {
    return (NSSCKFWSlot *)NULL;
  }
#endif /* NSSDEBUG */

  return nssCKFWToken_GetFWSlot(fwSession->fwToken);
}

Here is the caller graph for this function:

NSS_EXTERN CK_SESSION_HANDLE nssCKFWSession_GetHandle ( NSSCKFWSession *  fwSession)

Definition at line 607 of file session.c.

{
#ifdef NSSDEBUG
  if( CKR_OK != nssCKFWSession_verifyPointer(fwSession) ) {
    return NULL;
  }
#endif /* NSSDEBUG */

  return fwSession->hSession;
}

Here is the caller graph for this function:

NSS_EXTERN NSSCKMDSession* nssCKFWSession_GetMDSession ( NSSCKFWSession *  fwSession)

Definition at line 309 of file session.c.

{
#ifdef NSSDEBUG
  if( CKR_OK != nssCKFWSession_verifyPointer(fwSession) ) {
    return (NSSCKMDSession *)NULL;
  }
#endif /* NSSDEBUG */

  return fwSession->mdSession;
}

Here is the caller graph for this function:

NSS_EXTERN CK_RV nssCKFWSession_GetOperationState ( NSSCKFWSession *  fwSession,
NSSItem *  buffer 
)

Definition at line 1056 of file session.c.

{
  CK_RV error = CKR_OK;
  CK_ULONG fwAmt;
  CK_ULONG *ulBuffer;
  NSSItem i2;
  CK_ULONG n, i;

#ifdef NSSDEBUG
  error = nssCKFWSession_verifyPointer(fwSession);
  if( CKR_OK != error ) {
    return error;
  }

  if( (NSSItem *)NULL == buffer ) {
    return CKR_ARGUMENTS_BAD;
  }

  if( (void *)NULL == buffer->data ) {
    return CKR_ARGUMENTS_BAD;
  }

  if( (NSSCKMDSession *)NULL == fwSession->mdSession ) {
    return CKR_GENERAL_ERROR;
  }
#endif /* NSSDEBUG */

  if( (void *)NULL == (void *)fwSession->mdSession->GetOperationState ) {
    return CKR_STATE_UNSAVEABLE;
  }

  /*
   * Sanity-check the caller's buffer.
   */

  error = CKR_OK;
  fwAmt = nssCKFWSession_GetOperationStateLen(fwSession, &error);
  if( ((CK_ULONG)0 == fwAmt) && (CKR_OK != error) ) {
    return error;
  }

  if( buffer->size < fwAmt ) {
    return CKR_BUFFER_TOO_SMALL;
  }

  ulBuffer = (CK_ULONG *)buffer->data;

  i2.size = buffer->size - 2*sizeof(CK_ULONG);
  i2.data = (void *)&ulBuffer[2];

  error = fwSession->mdSession->GetOperationState(fwSession->mdSession,
    fwSession, fwSession->mdToken, fwSession->fwToken, 
    fwSession->mdInstance, fwSession->fwInstance, &i2);

  if( CKR_OK != error ) {
    return error;
  }

  /*
   * Add a little integrety/identity check.  
   * NOTE: right now, it's pretty stupid.  
   * A CRC or something would be better.
   */

  ulBuffer[0] = 0x434b4657; /* CKFW */
  ulBuffer[1] = 0;
  n = i2.size/sizeof(CK_ULONG);
  for( i = 0; i < n; i++ ) {
    ulBuffer[1] ^= ulBuffer[2+i];
  }

  return CKR_OK;
}

Here is the caller graph for this function:

NSS_EXTERN CK_ULONG nssCKFWSession_GetOperationStateLen ( NSSCKFWSession *  fwSession,
CK_RV pError 
)

Definition at line 1002 of file session.c.

{
  CK_ULONG mdAmt;
  CK_ULONG fwAmt;

#ifdef NSSDEBUG
  if( (CK_RV *)NULL == pError ) {
    return (CK_ULONG)0;
  }

  *pError = nssCKFWSession_verifyPointer(fwSession);
  if( CKR_OK != *pError ) {
    return (CK_ULONG)0;
  }

  if( (NSSCKMDSession *)NULL == fwSession->mdSession ) {
    *pError = CKR_GENERAL_ERROR;
    return (CK_ULONG)0;
  }
#endif /* NSSDEBUG */

  if( (void *)NULL == (void *)fwSession->mdSession->GetOperationStateLen ) {
    *pError = CKR_STATE_UNSAVEABLE;
  }

  /*
   * We could check that the session is actually in some state..
   */

  mdAmt = fwSession->mdSession->GetOperationStateLen(fwSession->mdSession,
    fwSession, fwSession->mdToken, fwSession->fwToken, fwSession->mdInstance,
    fwSession->fwInstance, pError);

  if( ((CK_ULONG)0 == mdAmt) && (CKR_OK != *pError) ) {
    return (CK_ULONG)0;
  }

  /*
   * Add a bit of sanity-checking
   */
  fwAmt = mdAmt + 2*sizeof(CK_ULONG);

  return fwAmt;
}

Here is the caller graph for this function:

NSS_EXTERN CK_RV nssCKFWSession_GetRandom ( NSSCKFWSession *  fwSession,
NSSItem *  buffer 
)

Definition at line 1812 of file session.c.

{
  CK_RV error = CKR_OK;

#ifdef NSSDEBUG
  error = nssCKFWSession_verifyPointer(fwSession);
  if( CKR_OK != error ) {
    return error;
  }

  if( (NSSItem *)NULL == buffer ) {
    return CKR_ARGUMENTS_BAD;
  }

  if( (void *)NULL == buffer->data ) {
    return CKR_ARGUMENTS_BAD;
  }

  if( (NSSCKMDSession *)NULL == fwSession->mdSession ) {
    return CKR_GENERAL_ERROR;
  }
#endif /* NSSDEBUG */

  if( (void *)NULL == (void *)fwSession->mdSession->GetRandom ) {
    if( CK_TRUE == nssCKFWToken_GetHasRNG(fwSession->fwToken) ) {
      return CKR_GENERAL_ERROR;
    } else {
      return CKR_RANDOM_NO_RNG;
    }
  }

  if( 0 == buffer->size ) {
    return CKR_OK;
  }

  error = fwSession->mdSession->GetRandom(fwSession->mdSession, fwSession,
    fwSession->mdToken, fwSession->fwToken, fwSession->mdInstance,
    fwSession->fwInstance, buffer);

  return error;
}

Here is the caller graph for this function:

NSS_EXTERN CK_STATE nssCKFWSession_GetSessionState ( NSSCKFWSession *  fwSession)

Definition at line 458 of file session.c.

{
#ifdef NSSDEBUG
  if( CKR_OK != nssCKFWSession_verifyPointer(fwSession) ) {
    return CKS_RO_PUBLIC_SESSION; /* whatever */
  }
#endif /* NSSDEBUG */

  return nssCKFWToken_GetSessionState(fwSession->fwToken);
}

Here is the caller graph for this function:

NSS_EXTERN CK_RV nssCKFWSession_InitPIN ( NSSCKFWSession *  fwSession,
NSSItem *  pin 
)

Definition at line 897 of file session.c.

{
  CK_RV error = CKR_OK;
  CK_STATE state;

#ifdef NSSDEBUG
  error = nssCKFWSession_verifyPointer(fwSession);
  if( CKR_OK != error ) {
    return error;
  }

  if( (NSSCKMDSession *)NULL == fwSession->mdSession ) {
    return CKR_GENERAL_ERROR;
  }
#endif /* NSSDEBUG */

  state = nssCKFWToken_GetSessionState(fwSession->fwToken);
  if( CKS_RW_SO_FUNCTIONS != state ) {
    return CKR_USER_NOT_LOGGED_IN;
  }

  if( (NSSItem *)NULL == pin ) {
    CK_BBOOL has = nssCKFWToken_GetHasProtectedAuthenticationPath(fwSession->fwToken);
    if( CK_TRUE != has ) {
      return CKR_ARGUMENTS_BAD;
    }
  }

  if( (void *)NULL == (void *)fwSession->mdSession->InitPIN ) {
    return CKR_TOKEN_WRITE_PROTECTED;
  }

  error = fwSession->mdSession->InitPIN(fwSession->mdSession, fwSession,
    fwSession->mdToken, fwSession->fwToken, fwSession->mdInstance,
    fwSession->fwInstance, pin);

  return error;
}

Here is the caller graph for this function:

NSS_EXTERN CK_BBOOL nssCKFWSession_IsRWSession ( NSSCKFWSession *  fwSession)

Definition at line 388 of file session.c.

{
#ifdef NSSDEBUG
  if( CKR_OK != nssCKFWSession_verifyPointer(fwSession) ) {
    return CK_FALSE;
  }
#endif /* NSSDEBUG */

  return fwSession->rw;
}

Here is the caller graph for this function:

NSS_EXTERN CK_BBOOL nssCKFWSession_IsSO ( NSSCKFWSession *  fwSession)

Definition at line 407 of file session.c.

{
  CK_STATE state;

#ifdef NSSDEBUG
  if( CKR_OK != nssCKFWSession_verifyPointer(fwSession) ) {
    return CK_FALSE;
  }
#endif /* NSSDEBUG */

  state = nssCKFWToken_GetSessionState(fwSession->fwToken);
  switch( state ) {
  case CKS_RO_PUBLIC_SESSION:
  case CKS_RO_USER_FUNCTIONS:
  case CKS_RW_PUBLIC_SESSION:
  case CKS_RW_USER_FUNCTIONS:
    return CK_FALSE;
  case CKS_RW_SO_FUNCTIONS:
    return CK_TRUE;
  default:
    return CK_FALSE;
  }
}

Here is the caller graph for this function:

NSS_EXTERN CK_RV nssCKFWSession_Login ( NSSCKFWSession *  fwSession,
CK_USER_TYPE  userType,
NSSItem *  pin 
)

Definition at line 705 of file session.c.

{
  CK_RV error = CKR_OK;
  CK_STATE oldState;
  CK_STATE newState;

#ifdef NSSDEBUG
  error = nssCKFWSession_verifyPointer(fwSession);
  if( CKR_OK != error ) {
    return error;
  }

  switch( userType ) {
  case CKU_SO:
  case CKU_USER:
    break;
  default:
    return CKR_USER_TYPE_INVALID;
  }

  if( (NSSItem *)NULL == pin ) {
    if( CK_TRUE != nssCKFWToken_GetHasProtectedAuthenticationPath(fwSession->fwToken) ) {
      return CKR_ARGUMENTS_BAD;
    }
  }

  if( (NSSCKMDSession *)NULL == fwSession->mdSession ) {
    return CKR_GENERAL_ERROR;
  }
#endif /* NSSDEBUG */

  oldState = nssCKFWToken_GetSessionState(fwSession->fwToken);

  /*
   * It's not clear what happens when you're already logged in.
   * I'll just fail; but if we decide to change, the logic is
   * all right here.
   */

  if( CKU_SO == userType ) {
    switch( oldState ) {
    case CKS_RO_PUBLIC_SESSION:      
      /*
       * There's no such thing as a read-only security officer
       * session, so fail.  The error should be CKR_SESSION_READ_ONLY,
       * except that C_Login isn't defined to return that.  So we'll
       * do CKR_SESSION_READ_ONLY_EXISTS, which is what is documented.
       */
      return CKR_SESSION_READ_ONLY_EXISTS;
    case CKS_RO_USER_FUNCTIONS:
      return CKR_USER_ANOTHER_ALREADY_LOGGED_IN;
    case CKS_RW_PUBLIC_SESSION:
      newState = CKS_RW_SO_FUNCTIONS;
      break;
    case CKS_RW_USER_FUNCTIONS:
      return CKR_USER_ANOTHER_ALREADY_LOGGED_IN;
    case CKS_RW_SO_FUNCTIONS:
      return CKR_USER_ALREADY_LOGGED_IN;
    default:
      return CKR_GENERAL_ERROR;
    }
  } else /* CKU_USER == userType */ {
    switch( oldState ) {
    case CKS_RO_PUBLIC_SESSION:      
      newState = CKS_RO_USER_FUNCTIONS;
      break;
    case CKS_RO_USER_FUNCTIONS:
      return CKR_USER_ALREADY_LOGGED_IN;
    case CKS_RW_PUBLIC_SESSION:
      newState = CKS_RW_USER_FUNCTIONS;
      break;
    case CKS_RW_USER_FUNCTIONS:
      return CKR_USER_ALREADY_LOGGED_IN;
    case CKS_RW_SO_FUNCTIONS:
      return CKR_USER_ANOTHER_ALREADY_LOGGED_IN;
    default:
      return CKR_GENERAL_ERROR;
    }
  }

  /*
   * So now we're in one of three cases:
   *
   * Old == CKS_RW_PUBLIC_SESSION, New == CKS_RW_SO_FUNCTIONS;
   * Old == CKS_RW_PUBLIC_SESSION, New == CKS_RW_USER_FUNCTIONS;
   * Old == CKS_RO_PUBLIC_SESSION, New == CKS_RO_USER_FUNCTIONS;
   */

  if( (void *)NULL == (void *)fwSession->mdSession->Login ) {
    /*
     * The Module doesn't want to be informed (or check the pin)
     * it'll just rely on the Framework as needed.
     */
    ;
  } else {
    error = fwSession->mdSession->Login(fwSession->mdSession, fwSession,
      fwSession->mdToken, fwSession->fwToken, fwSession->mdInstance,
      fwSession->fwInstance, userType, pin, oldState, newState);
    if( CKR_OK != error ) {
      return error;
    }
  }

  (void)nssCKFWToken_SetSessionState(fwSession->fwToken, newState);
  return CKR_OK;
}

Here is the caller graph for this function:

NSS_EXTERN CK_RV nssCKFWSession_Logout ( NSSCKFWSession *  fwSession)

Definition at line 822 of file session.c.

{
  CK_RV error = CKR_OK;
  CK_STATE oldState;
  CK_STATE newState;

#ifdef NSSDEBUG
  error = nssCKFWSession_verifyPointer(fwSession);
  if( CKR_OK != error ) {
    return error;
  }

  if( (NSSCKMDSession *)NULL == fwSession->mdSession ) {
    return CKR_GENERAL_ERROR;
  }
#endif /* NSSDEBUG */

  oldState = nssCKFWToken_GetSessionState(fwSession->fwToken);

  switch( oldState ) {
  case CKS_RO_PUBLIC_SESSION:
    return CKR_USER_NOT_LOGGED_IN;
  case CKS_RO_USER_FUNCTIONS:
    newState = CKS_RO_PUBLIC_SESSION;
    break;
  case CKS_RW_PUBLIC_SESSION:
    return CKR_USER_NOT_LOGGED_IN;
  case CKS_RW_USER_FUNCTIONS:
    newState = CKS_RW_PUBLIC_SESSION;
    break;
  case CKS_RW_SO_FUNCTIONS:
    newState = CKS_RW_PUBLIC_SESSION;
    break;
  default:
    return CKR_GENERAL_ERROR;
  }

  /*
   * So now we're in one of three cases:
   *
   * Old == CKS_RW_SO_FUNCTIONS,   New == CKS_RW_PUBLIC_SESSION;
   * Old == CKS_RW_USER_FUNCTIONS, New == CKS_RW_PUBLIC_SESSION;
   * Old == CKS_RO_USER_FUNCTIONS, New == CKS_RO_PUBLIC_SESSION;
   */

  if( (void *)NULL == (void *)fwSession->mdSession->Logout ) {
    /*
     * The Module doesn't want to be informed.  Okay.
     */
    ;
  } else {
    error = fwSession->mdSession->Logout(fwSession->mdSession, fwSession,
      fwSession->mdToken, fwSession->fwToken, fwSession->mdInstance,
      fwSession->fwInstance, oldState, newState);
    if( CKR_OK != error ) {
      /*
       * Now what?!  A failure really should end up with the Framework
       * considering it logged out, right?
       */
      ;
    }
  }

  (void)nssCKFWToken_SetSessionState(fwSession->fwToken, newState);
  return error;
}

Here is the caller graph for this function:

NSS_EXTERN CK_RV nssCKFWSession_RegisterSessionObject ( NSSCKFWSession *  fwSession,
NSSCKFWObject *  fwObject 
)

Definition at line 626 of file session.c.

{
  CK_RV rv = CKR_OK;

#ifdef NSSDEBUG
  if( CKR_OK != nssCKFWSession_verifyPointer(fwSession) ) {
    return CKR_GENERAL_ERROR;
  }
#endif /* NSSDEBUG */

  if( (nssCKFWHash *)NULL != fwSession->sessionObjectHash ) {
    rv = nssCKFWHash_Add(fwSession->sessionObjectHash, fwObject, fwObject);
  }

  return rv;
}

Here is the caller graph for this function:

NSS_EXTERN CK_RV nssCKFWSession_SeedRandom ( NSSCKFWSession *  fwSession,
NSSItem *  seed 
)

Definition at line 1765 of file session.c.

{
  CK_RV error = CKR_OK;

#ifdef NSSDEBUG
  error = nssCKFWSession_verifyPointer(fwSession);
  if( CKR_OK != error ) {
    return error;
  }

  if( (NSSItem *)NULL == seed ) {
    return CKR_ARGUMENTS_BAD;
  }

  if( (void *)NULL == seed->data ) {
    return CKR_ARGUMENTS_BAD;
  }

  if( 0 == seed->size ) {
    return CKR_ARGUMENTS_BAD;
  }

  if( (NSSCKMDSession *)NULL == fwSession->mdSession ) {
    return CKR_GENERAL_ERROR;
  }
#endif /* NSSDEBUG */

  if( (void *)NULL == (void *)fwSession->mdSession->SeedRandom ) {
    return CKR_RANDOM_SEED_NOT_SUPPORTED;
  }

  error = fwSession->mdSession->SeedRandom(fwSession->mdSession, fwSession,
    fwSession->mdToken, fwSession->fwToken, fwSession->mdInstance,
    fwSession->fwInstance, seed);

  return error;
}

Here is the caller graph for this function:

NSS_EXTERN CK_RV nssCKFWSession_SetFWFindObjects ( NSSCKFWSession *  fwSession,
NSSCKFWFindObjects *  fwFindObjects 
)

Definition at line 477 of file session.c.

{
#ifdef NSSDEBUG
  CK_RV error = CKR_OK;
#endif /* NSSDEBUG */

#ifdef NSSDEBUG
  error = nssCKFWSession_verifyPointer(fwSession);
  if( CKR_OK != error ) {
    return error;
  }

  /* fwFindObjects may be null */
#endif /* NSSDEBUG */

  if( ((NSSCKFWFindObjects *)NULL != fwSession->fwFindObjects) &&
      ((NSSCKFWFindObjects *)NULL != fwFindObjects) ) {
    return CKR_OPERATION_ACTIVE;
  }

  fwSession->fwFindObjects = fwFindObjects;

  return CKR_OK;
}

Here is the caller graph for this function:

NSS_EXTERN CK_RV nssCKFWSession_SetHandle ( NSSCKFWSession *  fwSession,
CK_SESSION_HANDLE  hSession 
)

Definition at line 576 of file session.c.

{
#ifdef NSSDEBUG
  CK_RV error = CKR_OK;
#endif /* NSSDEBUG */

#ifdef NSSDEBUG
  error = nssCKFWSession_verifyPointer(fwSession);
  if( CKR_OK != error ) {
    return error;
  }
#endif /* NSSDEBUG */

  if( (CK_SESSION_HANDLE)0 != fwSession->hSession ) {
    return CKR_GENERAL_ERROR;
  }

  fwSession->hSession = hSession;

  return CKR_OK;
}

Here is the caller graph for this function:

NSS_EXTERN CK_RV nssCKFWSession_SetMDSession ( NSSCKFWSession *  fwSession,
NSSCKMDSession *  mdSession 
)

Definition at line 541 of file session.c.

{
#ifdef NSSDEBUG
  CK_RV error = CKR_OK;
#endif /* NSSDEBUG */

#ifdef NSSDEBUG
  error = nssCKFWSession_verifyPointer(fwSession);
  if( CKR_OK != error ) {
    return error;
  }

  if( (NSSCKMDSession *)NULL == mdSession ) {
    return CKR_ARGUMENTS_BAD;
  }
#endif /* NSSDEBUG */

  if( (NSSCKMDSession *)NULL != fwSession->mdSession ) {
    return CKR_GENERAL_ERROR;
  }

  fwSession->mdSession = mdSession;

  return CKR_OK;
}

Here is the caller graph for this function:

NSS_EXTERN CK_RV nssCKFWSession_SetOperationState ( NSSCKFWSession *  fwSession,
NSSItem *  state,
NSSCKFWObject *  encryptionKey,
NSSCKFWObject *  authenticationKey 
)

Definition at line 1139 of file session.c.

{
  CK_RV error = CKR_OK;
  CK_ULONG *ulBuffer;
  CK_ULONG n, i;
  CK_ULONG x;
  NSSItem s;
  NSSCKMDObject *mdek;
  NSSCKMDObject *mdak;

#ifdef NSSDEBUG
  error = nssCKFWSession_verifyPointer(fwSession);
  if( CKR_OK != error ) {
    return error;
  }

  if( (NSSItem *)NULL == state ) {
    return CKR_ARGUMENTS_BAD;
  }

  if( (void *)NULL == state->data ) {
    return CKR_ARGUMENTS_BAD;
  }

  if( (NSSCKFWObject *)NULL != encryptionKey ) {
    error = nssCKFWObject_verifyPointer(encryptionKey);
    if( CKR_OK != error ) {
      return error;
    }
  }

  if( (NSSCKFWObject *)NULL != authenticationKey ) {
    error = nssCKFWObject_verifyPointer(authenticationKey);
    if( CKR_OK != error ) {
      return error;
    }
  }

  if( (NSSCKMDSession *)NULL == fwSession->mdSession ) {
    return CKR_GENERAL_ERROR;
  }
#endif /* NSSDEBUG */

  ulBuffer = (CK_ULONG *)state->data;
  if( 0x43b4657 != ulBuffer[0] ) {
    return CKR_SAVED_STATE_INVALID;
  }
  n = (state->size / sizeof(CK_ULONG)) - 2;
  x = (CK_ULONG)0;
  for( i = 0; i < n; i++ ) {
    x ^= ulBuffer[2+i];
  }

  if( x != ulBuffer[1] ) {
    return CKR_SAVED_STATE_INVALID;
  }

  if( (void *)NULL == (void *)fwSession->mdSession->SetOperationState ) {
    return CKR_GENERAL_ERROR;
  }

  s.size = state->size - 2*sizeof(CK_ULONG);
  s.data = (void *)&ulBuffer[2];

  if( (NSSCKFWObject *)NULL != encryptionKey ) {
    mdek = nssCKFWObject_GetMDObject(encryptionKey);
  } else {
    mdek = (NSSCKMDObject *)NULL;
  }

  if( (NSSCKFWObject *)NULL != authenticationKey ) {
    mdak = nssCKFWObject_GetMDObject(authenticationKey);
  } else {
    mdak = (NSSCKMDObject *)NULL;
  }

  error = fwSession->mdSession->SetOperationState(fwSession->mdSession, 
    fwSession, fwSession->mdToken, fwSession->fwToken, fwSession->mdInstance,
    fwSession->fwInstance, &s, mdek, encryptionKey, mdak, authenticationKey);

  if( CKR_OK != error ) {
    return error;
  }

  /*
   * Here'd we restore any session data
   */
  
  return CKR_OK;
}

Here is the caller graph for this function:

NSS_EXTERN CK_RV nssCKFWSession_SetPIN ( NSSCKFWSession *  fwSession,
NSSItem *  newPin,
NSSItem *  oldPin 
)

Definition at line 945 of file session.c.

{
  CK_RV error = CKR_OK;
  CK_STATE state;

#ifdef NSSDEBUG
  error = nssCKFWSession_verifyPointer(fwSession);
  if( CKR_OK != error ) {
    return error;
  }

  if( (NSSCKMDSession *)NULL == fwSession->mdSession ) {
    return CKR_GENERAL_ERROR;
  }
#endif /* NSSDEBUG */

  state = nssCKFWToken_GetSessionState(fwSession->fwToken);
  if( (CKS_RW_SO_FUNCTIONS != state) &&
      (CKS_RW_USER_FUNCTIONS != state) ) {
    return CKR_USER_NOT_LOGGED_IN;
  }

  if( (NSSItem *)NULL == newPin ) {
    CK_BBOOL has = nssCKFWToken_GetHasProtectedAuthenticationPath(fwSession->fwToken);
    if( CK_TRUE != has ) {
      return CKR_ARGUMENTS_BAD;
    }
  }

  if( (NSSItem *)NULL == oldPin ) {
    CK_BBOOL has = nssCKFWToken_GetHasProtectedAuthenticationPath(fwSession->fwToken);
    if( CK_TRUE != has ) {
      return CKR_ARGUMENTS_BAD;
    }
  }

  if( (void *)NULL == (void *)fwSession->mdSession->SetPIN ) {
    return CKR_TOKEN_WRITE_PROTECTED;
  }

  error = fwSession->mdSession->SetPIN(fwSession->mdSession, fwSession,
    fwSession->mdToken, fwSession->fwToken, fwSession->mdInstance,
    fwSession->fwInstance, newPin, oldPin);

  return error;
}

Here is the caller graph for this function:

NSS_EXTERN void nssCKFWSlot_ClearToken ( NSSCKFWSlot *  fwSlot)

Definition at line 681 of file slot.c.

{
#ifdef NSSDEBUG
  if( CKR_OK != nssCKFWSlot_verifyPointer(fwSlot) ) {
    return;
  }
#endif /* NSSDEBUG */

  if( CKR_OK != nssCKFWMutex_Lock(fwSlot->mutex) ) {
    /* Now what? */
    return;
  }

  fwSlot->fwToken = (NSSCKFWToken *)NULL;
  (void)nssCKFWMutex_Unlock(fwSlot->mutex);
  return;
}

Here is the caller graph for this function:

NSS_EXTERN NSSCKFWSlot* nssCKFWSlot_Create ( NSSCKFWInstance *  fwInstance,
NSSCKMDSlot *  mdSlot,
CK_SLOT_ID  slotID,
CK_RV pError 
)

Definition at line 163 of file slot.c.

{
  NSSCKFWSlot *fwSlot;
  NSSCKMDInstance *mdInstance;
  NSSArena *arena;

#ifdef NSSDEBUG
  if( (CK_RV *)NULL == pError ) {
    return (NSSCKFWSlot *)NULL;
  }

  *pError = nssCKFWInstance_verifyPointer(fwInstance);
  if( CKR_OK != *pError ) {
    return (NSSCKFWSlot *)NULL;
  }
#endif /* NSSDEBUG */

  mdInstance = nssCKFWInstance_GetMDInstance(fwInstance);
  if( (NSSCKMDInstance *)NULL == mdInstance ) {
    *pError = CKR_GENERAL_ERROR;
    return (NSSCKFWSlot *)NULL;
  }

  arena = nssCKFWInstance_GetArena(fwInstance, pError);
  if( (NSSArena *)NULL == arena ) {
    if( CKR_OK == *pError ) {
      *pError = CKR_GENERAL_ERROR;
    }
  }

  fwSlot = nss_ZNEW(arena, NSSCKFWSlot);
  if( (NSSCKFWSlot *)NULL == fwSlot ) {
    *pError = CKR_HOST_MEMORY;
    return (NSSCKFWSlot *)NULL;
  }

  fwSlot->mdSlot = mdSlot;
  fwSlot->fwInstance = fwInstance;
  fwSlot->mdInstance = mdInstance;
  fwSlot->slotID = slotID;

  fwSlot->mutex = nssCKFWInstance_CreateMutex(fwInstance, arena, pError);
  if( (NSSCKFWMutex *)NULL == fwSlot->mutex ) {
    if( CKR_OK == *pError ) {
      *pError = CKR_GENERAL_ERROR;
    }
    (void)nss_ZFreeIf(fwSlot);
    return (NSSCKFWSlot *)NULL;
  }

  if( (void *)NULL != (void *)mdSlot->Initialize ) {
    *pError = CKR_OK;
    *pError = mdSlot->Initialize(mdSlot, fwSlot, mdInstance, fwInstance);
    if( CKR_OK != *pError ) {
      (void)nssCKFWMutex_Destroy(fwSlot->mutex);
      (void)nss_ZFreeIf(fwSlot);
      return (NSSCKFWSlot *)NULL;
    }
  }

#ifdef DEBUG
  *pError = slot_add_pointer(fwSlot);
  if( CKR_OK != *pError ) {
    if( (void *)NULL != (void *)mdSlot->Destroy ) {
      mdSlot->Destroy(mdSlot, fwSlot, mdInstance, fwInstance);
    }

    (void)nssCKFWMutex_Destroy(fwSlot->mutex);
    (void)nss_ZFreeIf(fwSlot);
    return (NSSCKFWSlot *)NULL;
  }
#endif /* DEBUG */

  return fwSlot;
}

Here is the caller graph for this function:

NSS_EXTERN CK_RV nssCKFWSlot_Destroy ( NSSCKFWSlot *  fwSlot)

Definition at line 250 of file slot.c.

{
  CK_RV error = CKR_OK;

#ifdef NSSDEBUG
  error = nssCKFWSlot_verifyPointer(fwSlot);
  if( CKR_OK != error ) {
    return error;
  }
#endif /* NSSDEBUG */
  if (fwSlot->fwToken) {
    nssCKFWToken_Destroy(fwSlot->fwToken);
  }

  (void)nssCKFWMutex_Destroy(fwSlot->mutex);

  if( (void *)NULL != (void *)fwSlot->mdSlot->Destroy ) {
    fwSlot->mdSlot->Destroy(fwSlot->mdSlot, fwSlot, 
      fwSlot->mdInstance, fwSlot->fwInstance);
  }

#ifdef DEBUG
  error = slot_remove_pointer(fwSlot);
#endif /* DEBUG */
  (void)nss_ZFreeIf(fwSlot);
  return error;
}

Here is the caller graph for this function:

Definition at line 580 of file slot.c.

{
  CK_VERSION rv;

#ifdef NSSDEBUG
  if( CKR_OK != nssCKFWSlot_verifyPointer(fwSlot) ) {
    rv.major = rv.minor = 0;
    return rv;
  }
#endif /* NSSDEBUG */

  if( CKR_OK != nssCKFWMutex_Lock(fwSlot->mutex) ) {
    rv.major = rv.minor = 0;
    return rv;
  }

  if( (0 != fwSlot->firmwareVersion.major) ||
      (0 != fwSlot->firmwareVersion.minor) ) {
    rv = fwSlot->firmwareVersion;
    goto done;
  }

  if( (void *)NULL != (void *)fwSlot->mdSlot->GetFirmwareVersion ) {
    fwSlot->firmwareVersion = fwSlot->mdSlot->GetFirmwareVersion(
      fwSlot->mdSlot, fwSlot, fwSlot->mdInstance, fwSlot->fwInstance);
  } else {
    fwSlot->firmwareVersion.major = 0;
    fwSlot->firmwareVersion.minor = 1;
  }

  rv = fwSlot->firmwareVersion;
 done:
  (void)nssCKFWMutex_Unlock(fwSlot->mutex);
  return rv;
}

Here is the caller graph for this function:

NSS_EXTERN NSSCKFWInstance* nssCKFWSlot_GetFWInstance ( NSSCKFWSlot *  fwSlot)

Definition at line 306 of file slot.c.

{
#ifdef NSSDEBUG
  if( CKR_OK != nssCKFWSlot_verifyPointer(fwSlot) ) {
    return (NSSCKFWInstance *)NULL;
  }
#endif /* NSSDEBUG */

  return fwSlot->fwInstance;
}

Here is the caller graph for this function:

NSS_EXTERN CK_BBOOL nssCKFWSlot_GetHardwareSlot ( NSSCKFWSlot *  fwSlot)

Definition at line 512 of file slot.c.

{
#ifdef NSSDEBUG
  if( CKR_OK != nssCKFWSlot_verifyPointer(fwSlot) ) {
    return CK_FALSE;
  }
#endif /* NSSDEBUG */

  if( (void *)NULL == (void *)fwSlot->mdSlot->GetHardwareSlot ) {
    return CK_FALSE;
  }

  return fwSlot->mdSlot->GetHardwareSlot(fwSlot->mdSlot, fwSlot,
    fwSlot->mdInstance, fwSlot->fwInstance);
}

Here is the caller graph for this function:

Definition at line 536 of file slot.c.

{
  CK_VERSION rv;

#ifdef NSSDEBUG
  if( CKR_OK != nssCKFWSlot_verifyPointer(fwSlot) ) {
    rv.major = rv.minor = 0;
    return rv;
  }
#endif /* NSSDEBUG */

  if( CKR_OK != nssCKFWMutex_Lock(fwSlot->mutex) ) {
    rv.major = rv.minor = 0;
    return rv;
  }

  if( (0 != fwSlot->hardwareVersion.major) ||
      (0 != fwSlot->hardwareVersion.minor) ) {
    rv = fwSlot->hardwareVersion;
    goto done;
  }

  if( (void *)NULL != (void *)fwSlot->mdSlot->GetHardwareVersion ) {
    fwSlot->hardwareVersion = fwSlot->mdSlot->GetHardwareVersion(
      fwSlot->mdSlot, fwSlot, fwSlot->mdInstance, fwSlot->fwInstance);
  } else {
    fwSlot->hardwareVersion.major = 0;
    fwSlot->hardwareVersion.minor = 1;
  }

  rv = fwSlot->hardwareVersion;
 done:
  (void)nssCKFWMutex_Unlock(fwSlot->mutex);
  return rv;
}

Here is the caller graph for this function:

NSS_EXTERN CK_RV nssCKFWSlot_GetManufacturerID ( NSSCKFWSlot *  fwSlot,
CK_CHAR  manufacturerID[32] 
)

Definition at line 414 of file slot.c.

{
  CK_RV error = CKR_OK;

#ifdef NSSDEBUG
  if( (CK_CHAR_PTR)NULL == manufacturerID ) {
    return CKR_ARGUMENTS_BAD;
  }

  error = nssCKFWSlot_verifyPointer(fwSlot);
  if( CKR_OK != error ) {
    return error;
  }
#endif /* NSSDEBUG */

  error = nssCKFWMutex_Lock(fwSlot->mutex);
  if( CKR_OK != error ) {
    return error;
  }

  if( (NSSUTF8 *)NULL == fwSlot->manufacturerID ) {
    if( (void *)NULL != (void *)fwSlot->mdSlot->GetManufacturerID ) {
      fwSlot->manufacturerID = fwSlot->mdSlot->GetManufacturerID(
        fwSlot->mdSlot, fwSlot, fwSlot->mdInstance, 
        fwSlot->fwInstance, &error);
      if( ((NSSUTF8 *)NULL == fwSlot->manufacturerID) && (CKR_OK != error) ) {
        goto done;
      }
    } else {
      fwSlot->manufacturerID = (NSSUTF8 *) "";
    }
  }

  (void)nssUTF8_CopyIntoFixedBuffer(fwSlot->manufacturerID, (char *)manufacturerID, 32, ' ');
  error = CKR_OK;

 done:
  (void)nssCKFWMutex_Unlock(fwSlot->mutex);
  return error;
}

Here is the caller graph for this function:

NSS_EXTERN NSSCKMDInstance* nssCKFWSlot_GetMDInstance ( NSSCKFWSlot *  fwSlot)

Definition at line 326 of file slot.c.

{
#ifdef NSSDEBUG
  if( CKR_OK != nssCKFWSlot_verifyPointer(fwSlot) ) {
    return (NSSCKMDInstance *)NULL;
  }
#endif /* NSSDEBUG */

  return fwSlot->mdInstance;
}

Here is the caller graph for this function:

NSS_EXTERN NSSCKMDSlot* nssCKFWSlot_GetMDSlot ( NSSCKFWSlot *  fwSlot)

Definition at line 286 of file slot.c.

{
#ifdef NSSDEBUG
  if( CKR_OK != nssCKFWSlot_verifyPointer(fwSlot) ) {
    return (NSSCKMDSlot *)NULL;
  }
#endif /* NSSDEBUG */

  return fwSlot->mdSlot;
}

Here is the caller graph for this function:

Definition at line 488 of file slot.c.

{
#ifdef NSSDEBUG
  if( CKR_OK != nssCKFWSlot_verifyPointer(fwSlot) ) {
    return CK_FALSE;
  }
#endif /* NSSDEBUG */

  if( (void *)NULL == (void *)fwSlot->mdSlot->GetRemovableDevice ) {
    return CK_FALSE;
  }

  return fwSlot->mdSlot->GetRemovableDevice(fwSlot->mdSlot, fwSlot,
    fwSlot->mdInstance, fwSlot->fwInstance);
}

Here is the caller graph for this function:

NSS_EXTERN CK_RV nssCKFWSlot_GetSlotDescription ( NSSCKFWSlot *  fwSlot,
CK_CHAR  slotDescription[64] 
)

Definition at line 364 of file slot.c.

{
  CK_RV error = CKR_OK;

#ifdef NSSDEBUG
  if( (CK_CHAR_PTR)NULL == slotDescription ) {
    return CKR_ARGUMENTS_BAD;
  }

  error = nssCKFWSlot_verifyPointer(fwSlot);
  if( CKR_OK != error ) {
    return error;
  }
#endif /* NSSDEBUG */

  error = nssCKFWMutex_Lock(fwSlot->mutex);
  if( CKR_OK != error ) {
    return error;
  }

  if( (NSSUTF8 *)NULL == fwSlot->slotDescription ) {
    if( (void *)NULL != (void *)fwSlot->mdSlot->GetSlotDescription ) {
      fwSlot->slotDescription = fwSlot->mdSlot->GetSlotDescription(
        fwSlot->mdSlot, fwSlot, fwSlot->mdInstance, 
        fwSlot->fwInstance, &error);
      if( ((NSSUTF8 *)NULL == fwSlot->slotDescription) && (CKR_OK != error) ) {
        goto done;
      }
    } else {
      fwSlot->slotDescription = (NSSUTF8 *) "";
    }
  }

  (void)nssUTF8_CopyIntoFixedBuffer(fwSlot->slotDescription, (char *)slotDescription, 64, ' ');
  error = CKR_OK;

 done:
  (void)nssCKFWMutex_Unlock(fwSlot->mutex);
  return error;
}

Here is the caller graph for this function:

NSS_EXTERN CK_SLOT_ID nssCKFWSlot_GetSlotID ( NSSCKFWSlot *  fwSlot)

Definition at line 345 of file slot.c.

{
#ifdef NSSDEBUG
  if( CKR_OK != nssCKFWSlot_verifyPointer(fwSlot) ) {
    return (CK_SLOT_ID)0;
  }
#endif /* NSSDEBUG */

  return fwSlot->slotID;
}

Here is the caller graph for this function:

NSS_EXTERN NSSCKFWToken* nssCKFWSlot_GetToken ( NSSCKFWSlot *  fwSlot,
CK_RV pError 
)

Definition at line 624 of file slot.c.

{
  NSSCKMDToken *mdToken;
  NSSCKFWToken *fwToken;

#ifdef NSSDEBUG
  if( (CK_RV *)NULL == pError ) {
    return (NSSCKFWToken *)NULL;
  }

  *pError = nssCKFWSlot_verifyPointer(fwSlot);
  if( CKR_OK != *pError ) {
    return (NSSCKFWToken *)NULL;
  }
#endif /* NSSDEBUG */

  *pError = nssCKFWMutex_Lock(fwSlot->mutex);
  if( CKR_OK != *pError ) {
    return (NSSCKFWToken *)NULL;
  }

  if( (NSSCKFWToken *)NULL == fwSlot->fwToken ) {
    if( (void *)NULL == (void *)fwSlot->mdSlot->GetToken ) {
      *pError = CKR_GENERAL_ERROR;
      fwToken = (NSSCKFWToken *)NULL;
      goto done;
    }

    mdToken = fwSlot->mdSlot->GetToken(fwSlot->mdSlot, fwSlot,
      fwSlot->mdInstance, fwSlot->fwInstance, pError);
    if( (NSSCKMDToken *)NULL == mdToken ) {
      if( CKR_OK == *pError ) {
        *pError = CKR_GENERAL_ERROR;
      }
      return (NSSCKFWToken *)NULL;
    }

    fwToken = nssCKFWToken_Create(fwSlot, mdToken, pError);
    fwSlot->fwToken = fwToken;
  } else {
    fwToken = fwSlot->fwToken;
  }

 done:
  (void)nssCKFWMutex_Unlock(fwSlot->mutex);
  return fwToken;
}

Here is the caller graph for this function:

NSS_EXTERN CK_BBOOL nssCKFWSlot_GetTokenPresent ( NSSCKFWSlot *  fwSlot)

Definition at line 464 of file slot.c.

{
#ifdef NSSDEBUG
  if( CKR_OK != nssCKFWSlot_verifyPointer(fwSlot) ) {
    return CK_FALSE;
  }
#endif /* NSSDEBUG */

  if( (void *)NULL == (void *)fwSlot->mdSlot->GetTokenPresent ) {
    return CK_TRUE;
  }

  return fwSlot->mdSlot->GetTokenPresent(fwSlot->mdSlot, fwSlot,
    fwSlot->mdInstance, fwSlot->fwInstance);
}

Here is the caller graph for this function:

NSS_EXTERN CK_RV nssCKFWToken_CloseAllSessions ( NSSCKFWToken *  fwToken)

Definition at line 1589 of file token.c.

{
  CK_RV error = CKR_OK;

#ifdef NSSDEBUG
  error = nssCKFWToken_verifyPointer(fwToken);
  if( CKR_OK != error ) {
    return error;
  }
#endif /* NSSDEBUG */

  error = nssCKFWMutex_Lock(fwToken->mutex);
  if( CKR_OK != error ) {
    return error;
  }

  nssCKFWHash_Iterate(fwToken->sessions, nss_ckfwtoken_session_iterator, (void *)NULL);

  nssCKFWHash_Destroy(fwToken->sessions);

  fwToken->sessions = nssCKFWHash_Create(fwToken->fwInstance, fwToken->arena, &error);
  if( (nssCKFWHash *)NULL == fwToken->sessions ) {
    if( CKR_OK == error ) {
      error = CKR_GENERAL_ERROR;
    }
    goto done;
  }

  fwToken->state = CKS_RO_PUBLIC_SESSION; /* some default */
  fwToken->sessionCount = 0;
  fwToken->rwSessionCount = 0;

  error = CKR_OK;

 done:
  (void)nssCKFWMutex_Unlock(fwToken->mutex);
  return error;
}

Here is the caller graph for this function:

NSS_EXTERN NSSCKFWToken* nssCKFWToken_Create ( NSSCKFWSlot *  fwSlot,
NSSCKMDToken *  mdToken,
CK_RV pError 
)

Definition at line 205 of file token.c.

{
  NSSArena *arena = (NSSArena *)NULL;
  NSSCKFWToken *fwToken = (NSSCKFWToken *)NULL;
  CK_BBOOL called_setup = CK_FALSE;

  /*
   * We have already verified the arguments in nssCKFWSlot_GetToken.
   */

  arena = NSSArena_Create();
  if( (NSSArena *)NULL == arena ) {
    *pError = CKR_HOST_MEMORY;
    goto loser;
  }

  fwToken = nss_ZNEW(arena, NSSCKFWToken);
  if( (NSSCKFWToken *)NULL == fwToken ) {
    *pError = CKR_HOST_MEMORY;
    goto loser;
  }    

  fwToken->arena = arena;
  fwToken->mdToken = mdToken;
  fwToken->fwSlot = fwSlot;
  fwToken->fwInstance = nssCKFWSlot_GetFWInstance(fwSlot);
  fwToken->mdInstance = nssCKFWSlot_GetMDInstance(fwSlot);
  fwToken->state = CKS_RO_PUBLIC_SESSION; /* some default */
  fwToken->sessionCount = 0;
  fwToken->rwSessionCount = 0;

  fwToken->mutex = nssCKFWInstance_CreateMutex(fwToken->fwInstance, arena, pError);
  if( (NSSCKFWMutex *)NULL == fwToken->mutex ) {
    if( CKR_OK == *pError ) {
      *pError = CKR_GENERAL_ERROR;
    }
    goto loser;
  }

  fwToken->sessions = nssCKFWHash_Create(fwToken->fwInstance, arena, pError);
  if( (nssCKFWHash *)NULL == fwToken->sessions ) {
    if( CKR_OK == *pError ) {
      *pError = CKR_GENERAL_ERROR;
    }
    goto loser;
  }

  if( CK_TRUE != nssCKFWInstance_GetModuleHandlesSessionObjects(
                   fwToken->fwInstance) ) {
    fwToken->sessionObjectHash = nssCKFWHash_Create(fwToken->fwInstance, 
                                   arena, pError);
    if( (nssCKFWHash *)NULL == fwToken->sessionObjectHash ) {
      if( CKR_OK == *pError ) {
        *pError = CKR_GENERAL_ERROR;
      }
      goto loser;
    }
  }

  fwToken->mdObjectHash = nssCKFWHash_Create(fwToken->fwInstance, 
                            arena, pError);
  if( (nssCKFWHash *)NULL == fwToken->mdObjectHash ) {
    if( CKR_OK == *pError ) {
      *pError = CKR_GENERAL_ERROR;
    }
    goto loser;
  }

  /* More here */

  if( (void *)NULL != (void *)mdToken->Setup ) {
    *pError = mdToken->Setup(mdToken, fwToken, fwToken->mdInstance, fwToken->fwInstance);
    if( CKR_OK != *pError ) {
      goto loser;
    }
  }

  called_setup = CK_TRUE;

#ifdef DEBUG
  *pError = token_add_pointer(fwToken);
  if( CKR_OK != *pError ) {
    goto loser;
  }
#endif /* DEBUG */

  *pError = CKR_OK;
  return fwToken;

 loser:

  if( CK_TRUE == called_setup ) {
    if( (void *)NULL != (void *)mdToken->Invalidate ) {
      mdToken->Invalidate(mdToken, fwToken, fwToken->mdInstance, fwToken->fwInstance);
    }
  }

  if( (NSSArena *)NULL != arena ) {
    (void)NSSArena_Destroy(arena);
  }

  return (NSSCKFWToken *)NULL;
}

Here is the caller graph for this function:

NSS_EXTERN CK_RV nssCKFWToken_Destroy ( NSSCKFWToken *  fwToken)

Definition at line 335 of file token.c.

{
  CK_RV error = CKR_OK;

#ifdef NSSDEBUG
  error = nssCKFWToken_verifyPointer(fwToken);
  if( CKR_OK != error ) {
    return error;
  }
#endif /* NSSDEBUG */

  (void)nssCKFWMutex_Destroy(fwToken->mutex);
  
  if( (void *)NULL != (void *)fwToken->mdToken->Invalidate ) {
    fwToken->mdToken->Invalidate(fwToken->mdToken, fwToken,
      fwToken->mdInstance, fwToken->fwInstance);
  }
  /* we can destroy the list without locking now because no one else is 
   * referencing us (or _Destroy was invalidly called!)
   */
  nssCKFWHash_Iterate(fwToken->sessions, nss_ckfwtoken_session_iterator, 
                                                        (void *)NULL);
  nssCKFWHash_Destroy(fwToken->sessions);

  if (fwToken->sessionObjectHash) {
    nssCKFWHash_Destroy(fwToken->sessionObjectHash);
  }
  if (fwToken->mdObjectHash) {
    nssCKFWHash_Destroy(fwToken->mdObjectHash);
  }

  nssCKFWSlot_ClearToken(fwToken->fwSlot);
  
#ifdef DEBUG
  error = token_remove_pointer(fwToken);
#endif /* DEBUG */

  (void)NSSArena_Destroy(fwToken->arena);
  return error;
}

Here is the caller graph for this function:

NSS_EXTERN NSSArena* nssCKFWToken_GetArena ( NSSCKFWToken *  fwToken,
CK_RV pError 
)

Definition at line 403 of file token.c.

{
#ifdef NSSDEBUG
  if( (CK_RV *)NULL == pError ) {
    return (NSSArena *)NULL;
  }

  *pError = nssCKFWToken_verifyPointer(fwToken);
  if( CKR_OK != *pError ) {
    return (NSSArena *)NULL;
  }
#endif /* NSSDEBUG */

  return fwToken->arena;
}

Here is the caller graph for this function:

Definition at line 1179 of file token.c.

{
  CK_VERSION rv;

#ifdef NSSDEBUG
  if( CKR_OK != nssCKFWToken_verifyPointer(fwToken) ) {
    rv.major = rv.minor = 0;
    return rv;
  }
#endif /* NSSDEBUG */

  if( CKR_OK != nssCKFWMutex_Lock(fwToken->mutex) ) {
    rv.major = rv.minor = 0;
    return rv;
  }

  if( (0 != fwToken->firmwareVersion.major) ||
      (0 != fwToken->firmwareVersion.minor) ) {
    rv = fwToken->firmwareVersion;
    goto done;
  }

  if( (void *)NULL != (void *)fwToken->mdToken->GetFirmwareVersion ) {
    fwToken->firmwareVersion = fwToken->mdToken->GetFirmwareVersion(
      fwToken->mdToken, fwToken, fwToken->mdInstance, fwToken->fwInstance);
  } else {
    fwToken->firmwareVersion.major = 0;
    fwToken->firmwareVersion.minor = 1;
  }

  rv = fwToken->firmwareVersion;

 done:
  (void)nssCKFWMutex_Unlock(fwToken->mutex);
  return rv;
}

Here is the caller graph for this function:

Definition at line 1110 of file token.c.

{
#ifdef NSSDEBUG
  if( CKR_OK != nssCKFWToken_verifyPointer(fwToken) ) {
    return CK_UNAVAILABLE_INFORMATION;
  }
#endif /* NSSDEBUG */

  if( (void *)NULL == (void *)fwToken->mdToken->GetFreePrivateMemory ) {
    return CK_UNAVAILABLE_INFORMATION;
  }

  return fwToken->mdToken->GetFreePrivateMemory(fwToken->mdToken, fwToken, 
    fwToken->mdInstance, fwToken->fwInstance);
}

Here is the caller graph for this function:

Definition at line 1062 of file token.c.

{
#ifdef NSSDEBUG
  if( CKR_OK != nssCKFWToken_verifyPointer(fwToken) ) {
    return CK_UNAVAILABLE_INFORMATION;
  }
#endif /* NSSDEBUG */

  if( (void *)NULL == (void *)fwToken->mdToken->GetFreePublicMemory ) {
    return CK_UNAVAILABLE_INFORMATION;
  }

  return fwToken->mdToken->GetFreePublicMemory(fwToken->mdToken, fwToken, 
    fwToken->mdInstance, fwToken->fwInstance);
}

Here is the caller graph for this function:

NSS_EXTERN NSSCKFWSlot* nssCKFWToken_GetFWSlot ( NSSCKFWToken *  fwToken)

Definition at line 428 of file token.c.

{
#ifdef NSSDEBUG
  if( CKR_OK != nssCKFWToken_verifyPointer(fwToken) ) {
    return (NSSCKFWSlot *)NULL;
  }
#endif /* NSSDEBUG */

  return fwToken->fwSlot;
}

Here is the caller graph for this function:

Definition at line 1134 of file token.c.

{
  CK_VERSION rv;

#ifdef NSSDEBUG
  if( CKR_OK != nssCKFWToken_verifyPointer(fwToken) ) {
    rv.major = rv.minor = 0;
    return rv;
  }
#endif /* NSSDEBUG */

  if( CKR_OK != nssCKFWMutex_Lock(fwToken->mutex) ) {
    rv.major = rv.minor = 0;
    return rv;
  }

  if( (0 != fwToken->hardwareVersion.major) ||
      (0 != fwToken->hardwareVersion.minor) ) {
    rv = fwToken->hardwareVersion;
    goto done;
  }

  if( (void *)NULL != (void *)fwToken->mdToken->GetHardwareVersion ) {
    fwToken->hardwareVersion = fwToken->mdToken->GetHardwareVersion(
      fwToken->mdToken, fwToken, fwToken->mdInstance, fwToken->fwInstance);
  } else {
    fwToken->hardwareVersion.major = 0;
    fwToken->hardwareVersion.minor = 1;
  }

  rv = fwToken->hardwareVersion;

 done:
  (void)nssCKFWMutex_Unlock(fwToken->mutex);
  return rv;
}

Here is the caller graph for this function:

Definition at line 870 of file token.c.

{
#ifdef NSSDEBUG
  if( CKR_OK != nssCKFWToken_verifyPointer(fwToken) ) {
    return CK_FALSE;
  }
#endif /* NSSDEBUG */

  if( (void *)NULL == (void *)fwToken->mdToken->GetHasClockOnToken ) {
    return CK_FALSE;
  }

  return fwToken->mdToken->GetHasClockOnToken(fwToken->mdToken, fwToken, 
    fwToken->mdInstance, fwToken->fwInstance);
}

Here is the caller graph for this function:

Definition at line 894 of file token.c.

{
#ifdef NSSDEBUG
  if( CKR_OK != nssCKFWToken_verifyPointer(fwToken) ) {
    return CK_FALSE;
  }
#endif /* NSSDEBUG */

  if( (void *)NULL == (void *)fwToken->mdToken->GetHasProtectedAuthenticationPath ) {
    return CK_FALSE;
  }

  return fwToken->mdToken->GetHasProtectedAuthenticationPath(fwToken->mdToken, 
    fwToken, fwToken->mdInstance, fwToken->fwInstance);
}

Here is the caller graph for this function:

NSS_EXTERN CK_BBOOL nssCKFWToken_GetHasRNG ( NSSCKFWToken *  fwToken)

Definition at line 750 of file token.c.

{
#ifdef NSSDEBUG
  if( CKR_OK != nssCKFWToken_verifyPointer(fwToken) ) {
    return CK_FALSE;
  }
#endif /* NSSDEBUG */

  if( (void *)NULL == (void *)fwToken->mdToken->GetHasRNG ) {
    return CK_FALSE;
  }

  return fwToken->mdToken->GetHasRNG(fwToken->mdToken, fwToken, 
    fwToken->mdInstance, fwToken->fwInstance);
}

Here is the caller graph for this function:

Definition at line 774 of file token.c.

{
#ifdef NSSDEBUG
  if( CKR_OK != nssCKFWToken_verifyPointer(fwToken) ) {
    return CK_FALSE;
  }
#endif /* NSSDEBUG */

  if( (void *)NULL == (void *)fwToken->mdToken->GetIsWriteProtected ) {
    return CK_FALSE;
  }

  return fwToken->mdToken->GetIsWriteProtected(fwToken->mdToken, fwToken, 
    fwToken->mdInstance, fwToken->fwInstance);
}

Here is the caller graph for this function:

NSS_EXTERN CK_RV nssCKFWToken_GetLabel ( NSSCKFWToken *  fwToken,
CK_CHAR  label[32] 
)

Definition at line 553 of file token.c.

{
  CK_RV error = CKR_OK;

#ifdef NSSDEBUG
  if( (CK_CHAR_PTR)NULL == label ) {
    return CKR_ARGUMENTS_BAD;
  }

  error = nssCKFWToken_verifyPointer(fwToken);
  if( CKR_OK != error ) {
    return error;
  }
#endif /* NSSDEBUG */

  error = nssCKFWMutex_Lock(fwToken->mutex);
  if( CKR_OK != error ) {
    return error;
  }

  if( (NSSUTF8 *)NULL == fwToken->label ) {
    if( (void *)NULL != (void *)fwToken->mdToken->GetLabel ) {
      fwToken->label = fwToken->mdToken->GetLabel(fwToken->mdToken, fwToken,
        fwToken->mdInstance, fwToken->fwInstance, &error);
      if( ((NSSUTF8 *)NULL == fwToken->label) && (CKR_OK != error) ) {
        goto done;
      }
    } else {
      fwToken->label = (NSSUTF8 *) "";
    }
  }

  (void)nssUTF8_CopyIntoFixedBuffer(fwToken->label, (char *)label, 32, ' ');
  error = CKR_OK;

 done:
  (void)nssCKFWMutex_Unlock(fwToken->mutex);
  return error;
}

Here is the caller graph for this function:

NSS_EXTERN CK_BBOOL nssCKFWToken_GetLoginRequired ( NSSCKFWToken *  fwToken)

Definition at line 798 of file token.c.

{
#ifdef NSSDEBUG
  if( CKR_OK != nssCKFWToken_verifyPointer(fwToken) ) {
    return CK_FALSE;
  }
#endif /* NSSDEBUG */

  if( (void *)NULL == (void *)fwToken->mdToken->GetLoginRequired ) {
    return CK_FALSE;
  }

  return fwToken->mdToken->GetLoginRequired(fwToken->mdToken, fwToken, 
    fwToken->mdInstance, fwToken->fwInstance);
}

Here is the caller graph for this function:

NSS_EXTERN CK_RV nssCKFWToken_GetManufacturerID ( NSSCKFWToken *  fwToken,
CK_CHAR  manufacturerID[32] 
)

Definition at line 602 of file token.c.

{
  CK_RV error = CKR_OK;

#ifdef NSSDEBUG
  if( (CK_CHAR_PTR)NULL == manufacturerID ) {
    return CKR_ARGUMENTS_BAD;
  }

  error = nssCKFWToken_verifyPointer(fwToken);
  if( CKR_OK != error ) {
    return error;
  }
#endif /* NSSDEBUG */

  error = nssCKFWMutex_Lock(fwToken->mutex);
  if( CKR_OK != error ) {
    return error;
  }

  if( (NSSUTF8 *)NULL == fwToken->manufacturerID ) {
    if( (void *)NULL != (void *)fwToken->mdToken->GetManufacturerID ) {
      fwToken->manufacturerID = fwToken->mdToken->GetManufacturerID(fwToken->mdToken,
        fwToken, fwToken->mdInstance, fwToken->fwInstance, &error);
      if( ((NSSUTF8 *)NULL == fwToken->manufacturerID) && (CKR_OK != error) ) {
        goto done;
      }
    } else {
      fwToken->manufacturerID = (NSSUTF8 *)"";
    }
  }

  (void)nssUTF8_CopyIntoFixedBuffer(fwToken->manufacturerID, (char *)manufacturerID, 32, ' ');
  error = CKR_OK;

 done:
  (void)nssCKFWMutex_Unlock(fwToken->mutex);
  return error;
}

Here is the caller graph for this function:

NSS_EXTERN CK_ULONG nssCKFWToken_GetMaxPinLen ( NSSCKFWToken *  fwToken)

Definition at line 990 of file token.c.

{
#ifdef NSSDEBUG
  if( CKR_OK != nssCKFWToken_verifyPointer(fwToken) ) {
    return CK_UNAVAILABLE_INFORMATION;
  }
#endif /* NSSDEBUG */

  if( (void *)NULL == (void *)fwToken->mdToken->GetMaxPinLen ) {
    return CK_UNAVAILABLE_INFORMATION;
  }

  return fwToken->mdToken->GetMaxPinLen(fwToken->mdToken, fwToken, 
    fwToken->mdInstance, fwToken->fwInstance);
}

Here is the caller graph for this function:

Definition at line 966 of file token.c.

{
#ifdef NSSDEBUG
  if( CKR_OK != nssCKFWToken_verifyPointer(fwToken) ) {
    return CK_UNAVAILABLE_INFORMATION;
  }
#endif /* NSSDEBUG */

  if( (void *)NULL == (void *)fwToken->mdToken->GetMaxRwSessionCount ) {
    return CK_UNAVAILABLE_INFORMATION;
  }

  return fwToken->mdToken->GetMaxRwSessionCount(fwToken->mdToken, fwToken, 
    fwToken->mdInstance, fwToken->fwInstance);
}

Here is the caller graph for this function:

Definition at line 942 of file token.c.

{
#ifdef NSSDEBUG
  if( CKR_OK != nssCKFWToken_verifyPointer(fwToken) ) {
    return CK_UNAVAILABLE_INFORMATION;
  }
#endif /* NSSDEBUG */

  if( (void *)NULL == (void *)fwToken->mdToken->GetMaxSessionCount ) {
    return CK_UNAVAILABLE_INFORMATION;
  }

  return fwToken->mdToken->GetMaxSessionCount(fwToken->mdToken, fwToken, 
    fwToken->mdInstance, fwToken->fwInstance);
}

Here is the caller graph for this function:

NSS_EXTERN nssCKFWHash* nssCKFWToken_GetMDObjectHash ( NSSCKFWToken *  fwToken)

Definition at line 1736 of file token.c.

{
#ifdef NSSDEBUG
  if( CKR_OK != nssCKFWToken_verifyPointer(fwToken) ) {
    return (nssCKFWHash *)NULL;
  }
#endif /* NSSDEBUG */

  return fwToken->mdObjectHash;
}

Here is the caller graph for this function:

NSS_EXTERN NSSCKMDSlot* nssCKFWToken_GetMDSlot ( NSSCKFWToken *  fwToken)

Definition at line 447 of file token.c.

{
#ifdef NSSDEBUG
  if( CKR_OK != nssCKFWToken_verifyPointer(fwToken) ) {
    return (NSSCKMDSlot *)NULL;
  }
#endif /* NSSDEBUG */

  return fwToken->mdSlot;
}

Here is the caller graph for this function:

NSS_EXTERN NSSCKMDToken* nssCKFWToken_GetMDToken ( NSSCKFWToken *  fwToken)

Definition at line 384 of file token.c.

{
#ifdef NSSDEBUG
  if( CKR_OK != nssCKFWToken_verifyPointer(fwToken) ) {
    return (NSSCKMDToken *)NULL;
  }
#endif /* NSSDEBUG */

  return fwToken->mdToken;
}

Here is the caller graph for this function:

NSS_EXTERN NSSCKFWMechanism* nssCKFWToken_GetMechanism ( NSSCKFWToken *  fwToken,
CK_MECHANISM_TYPE  which,
CK_RV pError 
)

Definition at line 1481 of file token.c.

{
  /* XXX fgmr */
  return (NSSCKFWMechanism *)NULL;
}

Here is the caller graph for this function:

NSS_EXTERN CK_ULONG nssCKFWToken_GetMechanismCount ( NSSCKFWToken *  fwToken)

Definition at line 1421 of file token.c.

{
#ifdef NSSDEBUG
  if( CKR_OK != nssCKFWToken_verifyPointer(fwToken) ) {
    return 0;
  }
#endif /* NSSDEBUG */

  if( (void *)NULL == (void *)fwToken->mdToken->GetMechanismCount ) {
    return 0;
  }

  return fwToken->mdToken->GetMechanismCount(fwToken->mdToken, fwToken,
    fwToken->mdInstance, fwToken->fwInstance);
}

Here is the caller graph for this function:

NSS_EXTERN CK_RV nssCKFWToken_GetMechanismTypes ( NSSCKFWToken *  fwToken,
CK_MECHANISM_TYPE  types[] 
)

Definition at line 1445 of file token.c.

{
#ifdef NSSDEBUG
  if( CKR_OK != nssCKFWToken_verifyPointer(fwToken) ) {
    return CKR_ARGUMENTS_BAD;
  }

  if( (CK_MECHANISM_TYPE *)NULL == types ) {
    return CKR_ARGUMENTS_BAD;
  }
#endif /* NSSDEBUG */

  if( (void *)NULL == (void *)fwToken->mdToken->GetMechanismTypes ) {
    /*
     * This should only be called with a sufficiently-large
     * "types" array, which can only be done if GetMechanismCount
     * is implemented.  If that's implemented (and returns nonzero),
     * then this should be too.  So return an error.
     */
    return CKR_GENERAL_ERROR;
  }

  return fwToken->mdToken->GetMechanismTypes(fwToken->mdToken, fwToken,
    fwToken->mdInstance, fwToken->fwInstance, types);
}

Here is the caller graph for this function:

NSS_EXTERN CK_ULONG nssCKFWToken_GetMinPinLen ( NSSCKFWToken *  fwToken)

Definition at line 1014 of file token.c.

{
#ifdef NSSDEBUG
  if( CKR_OK != nssCKFWToken_verifyPointer(fwToken) ) {
    return CK_UNAVAILABLE_INFORMATION;
  }
#endif /* NSSDEBUG */

  if( (void *)NULL == (void *)fwToken->mdToken->GetMinPinLen ) {
    return CK_UNAVAILABLE_INFORMATION;
  }

  return fwToken->mdToken->GetMinPinLen(fwToken->mdToken, fwToken, 
    fwToken->mdInstance, fwToken->fwInstance);
}

Here is the caller graph for this function:

NSS_EXTERN CK_RV nssCKFWToken_GetModel ( NSSCKFWToken *  fwToken,
CK_CHAR  model[16] 
)

Definition at line 651 of file token.c.

{
  CK_RV error = CKR_OK;

#ifdef NSSDEBUG
  if( (CK_CHAR_PTR)NULL == model ) {
    return CKR_ARGUMENTS_BAD;
  }

  error = nssCKFWToken_verifyPointer(fwToken);
  if( CKR_OK != error ) {
    return error;
  }
#endif /* NSSDEBUG */

  error = nssCKFWMutex_Lock(fwToken->mutex);
  if( CKR_OK != error ) {
    return error;
  }

  if( (NSSUTF8 *)NULL == fwToken->model ) {
    if( (void *)NULL != (void *)fwToken->mdToken->GetModel ) {
      fwToken->model = fwToken->mdToken->GetModel(fwToken->mdToken, fwToken,
        fwToken->mdInstance, fwToken->fwInstance, &error);
      if( ((NSSUTF8 *)NULL == fwToken->model) && (CKR_OK != error) ) {
        goto done;
      }
    } else {
      fwToken->model = (NSSUTF8 *)"";
    }
  }

  (void)nssUTF8_CopyIntoFixedBuffer(fwToken->model, (char *)model, 16, ' ');
  error = CKR_OK;

 done:
  (void)nssCKFWMutex_Unlock(fwToken->mutex);
  return error;
}

Here is the caller graph for this function:

NSS_EXTERN nssCKFWHash* nssCKFWToken_GetObjectHandleHash ( NSSCKFWToken *  fwToken)

Definition at line 1755 of file token.c.

{
#ifdef NSSDEBUG
  if( CKR_OK != nssCKFWToken_verifyPointer(fwToken) ) {
    return (nssCKFWHash *)NULL;
  }
#endif /* NSSDEBUG */

  return fwToken->mdObjectHash;
}

Definition at line 846 of file token.c.

{
#ifdef NSSDEBUG
  if( CKR_OK != nssCKFWToken_verifyPointer(fwToken) ) {
    return CK_FALSE;
  }
#endif /* NSSDEBUG */

  if( (void *)NULL == (void *)fwToken->mdToken->GetRestoreKeyNotNeeded ) {
    return CK_FALSE;
  }

  return fwToken->mdToken->GetRestoreKeyNotNeeded(fwToken->mdToken, fwToken, 
    fwToken->mdInstance, fwToken->fwInstance);
}

Here is the caller graph for this function:

NSS_EXTERN CK_ULONG nssCKFWToken_GetRoSessionCount ( NSSCKFWToken *  fwToken)

Definition at line 1690 of file token.c.

{
  CK_ULONG rv;

#ifdef NSSDEBUG
  if( CKR_OK != nssCKFWToken_verifyPointer(fwToken) ) {
    return (CK_ULONG)0;
  }
#endif /* NSSDEBUG */

  if( CKR_OK != nssCKFWMutex_Lock(fwToken->mutex) ) {
    return (CK_ULONG)0;
  }

  rv = fwToken->sessionCount - fwToken->rwSessionCount;
  (void)nssCKFWMutex_Unlock(fwToken->mutex);
  return rv;
}
NSS_EXTERN CK_ULONG nssCKFWToken_GetRwSessionCount ( NSSCKFWToken *  fwToken)

Definition at line 1663 of file token.c.

{
  CK_ULONG rv;

#ifdef NSSDEBUG
  if( CKR_OK != nssCKFWToken_verifyPointer(fwToken) ) {
    return (CK_ULONG)0;
  }
#endif /* NSSDEBUG */

  if( CKR_OK != nssCKFWMutex_Lock(fwToken->mutex) ) {
    return (CK_ULONG)0;
  }

  rv = fwToken->rwSessionCount;
  (void)nssCKFWMutex_Unlock(fwToken->mutex);
  return rv;
}

Here is the caller graph for this function:

NSS_EXTERN CK_RV nssCKFWToken_GetSerialNumber ( NSSCKFWToken *  fwToken,
CK_CHAR  serialNumber[16] 
)

Definition at line 700 of file token.c.

{
  CK_RV error = CKR_OK;

#ifdef NSSDEBUG
  if( (CK_CHAR_PTR)NULL == serialNumber ) {
    return CKR_ARGUMENTS_BAD;
  }

  error = nssCKFWToken_verifyPointer(fwToken);
  if( CKR_OK != error ) {
    return error;
  }
#endif /* NSSDEBUG */

  error = nssCKFWMutex_Lock(fwToken->mutex);
  if( CKR_OK != error ) {
    return error;
  }

  if( (NSSUTF8 *)NULL == fwToken->serialNumber ) {
    if( (void *)NULL != (void *)fwToken->mdToken->GetSerialNumber ) {
      fwToken->serialNumber = fwToken->mdToken->GetSerialNumber(fwToken->mdToken, 
        fwToken, fwToken->mdInstance, fwToken->fwInstance, &error);
      if( ((NSSUTF8 *)NULL == fwToken->serialNumber) && (CKR_OK != error) ) {
        goto done;
      }
    } else {
      fwToken->serialNumber = (NSSUTF8 *)"";
    }
  }

  (void)nssUTF8_CopyIntoFixedBuffer(fwToken->serialNumber, (char *)serialNumber, 16, ' ');
  error = CKR_OK;

 done:
  (void)nssCKFWMutex_Unlock(fwToken->mutex);
  return error;
}

Here is the caller graph for this function:

NSS_EXTERN CK_ULONG nssCKFWToken_GetSessionCount ( NSSCKFWToken *  fwToken)

Definition at line 1636 of file token.c.

{
  CK_ULONG rv;

#ifdef NSSDEBUG
  if( CKR_OK != nssCKFWToken_verifyPointer(fwToken) ) {
    return (CK_ULONG)0;
  }
#endif /* NSSDEBUG */

  if( CKR_OK != nssCKFWMutex_Lock(fwToken->mutex) ) {
    return (CK_ULONG)0;
  }

  rv = fwToken->sessionCount;
  (void)nssCKFWMutex_Unlock(fwToken->mutex);
  return rv;
}

Here is the caller graph for this function:

NSS_EXTERN nssCKFWHash* nssCKFWToken_GetSessionObjectHash ( NSSCKFWToken *  fwToken)

Definition at line 1717 of file token.c.

{
#ifdef NSSDEBUG
  if( CKR_OK != nssCKFWToken_verifyPointer(fwToken) ) {
    return (nssCKFWHash *)NULL;
  }
#endif /* NSSDEBUG */

  return fwToken->sessionObjectHash;
}

Here is the caller graph for this function:

NSS_EXTERN CK_STATE nssCKFWToken_GetSessionState ( NSSCKFWToken *  fwToken)

Definition at line 466 of file token.c.

{
#ifdef NSSDEBUG
  if( CKR_OK != nssCKFWToken_verifyPointer(fwToken) ) {
    return CKS_RO_PUBLIC_SESSION; /* whatever */
  }
#endif /* NSSDEBUG */

  /*
   * BTW, do not lock the token in this method.
   */

  /*
   * Theoretically, there is no state if there aren't any
   * sessions open.  But then we'd need to worry about
   * reporting an error, etc.  What the heck-- let's just
   * revert to CKR_RO_PUBLIC_SESSION as the "default."
   */

  return fwToken->state;
}

Here is the caller graph for this function:

Definition at line 918 of file token.c.

{
#ifdef NSSDEBUG
  if( CKR_OK != nssCKFWToken_verifyPointer(fwToken) ) {
    return CK_FALSE;
  }
#endif /* NSSDEBUG */

  if( (void *)NULL == (void *)fwToken->mdToken->GetSupportsDualCryptoOperations ) {
    return CK_FALSE;
  }

  return fwToken->mdToken->GetSupportsDualCryptoOperations(fwToken->mdToken, 
    fwToken, fwToken->mdInstance, fwToken->fwInstance);
}

Here is the caller graph for this function:

Definition at line 1086 of file token.c.

{
#ifdef NSSDEBUG
  if( CKR_OK != nssCKFWToken_verifyPointer(fwToken) ) {
    return CK_UNAVAILABLE_INFORMATION;
  }
#endif /* NSSDEBUG */

  if( (void *)NULL == (void *)fwToken->mdToken->GetTotalPrivateMemory ) {
    return CK_UNAVAILABLE_INFORMATION;
  }

  return fwToken->mdToken->GetTotalPrivateMemory(fwToken->mdToken, fwToken, 
    fwToken->mdInstance, fwToken->fwInstance);
}

Here is the caller graph for this function:

Definition at line 1038 of file token.c.

{
#ifdef NSSDEBUG
  if( CKR_OK != nssCKFWToken_verifyPointer(fwToken) ) {
    return CK_UNAVAILABLE_INFORMATION;
  }
#endif /* NSSDEBUG */

  if( (void *)NULL == (void *)fwToken->mdToken->GetTotalPublicMemory ) {
    return CK_UNAVAILABLE_INFORMATION;
  }

  return fwToken->mdToken->GetTotalPublicMemory(fwToken->mdToken, fwToken, 
    fwToken->mdInstance, fwToken->fwInstance);
}

Here is the caller graph for this function:

Definition at line 822 of file token.c.

{
#ifdef NSSDEBUG
  if( CKR_OK != nssCKFWToken_verifyPointer(fwToken) ) {
    return CK_FALSE;
  }
#endif /* NSSDEBUG */

  if( (void *)NULL == (void *)fwToken->mdToken->GetUserPinInitialized ) {
    return CK_FALSE;
  }

  return fwToken->mdToken->GetUserPinInitialized(fwToken->mdToken, fwToken, 
    fwToken->mdInstance, fwToken->fwInstance);
}

Here is the caller graph for this function:

NSS_EXTERN CK_RV nssCKFWToken_GetUTCTime ( NSSCKFWToken *  fwToken,
CK_CHAR  utcTime[16] 
)

Definition at line 1224 of file token.c.

{
  CK_RV error = CKR_OK;

#ifdef NSSDEBUG
  error = nssCKFWToken_verifyPointer(fwToken);
  if( CKR_OK != error ) {
    return error;
  }

  if( (CK_CHAR_PTR)NULL == utcTime ) {
    return CKR_ARGUMENTS_BAD;
  }
#endif /* DEBUG */

  if( CK_TRUE != nssCKFWToken_GetHasClockOnToken(fwToken) ) {
    /* return CKR_DEVICE_ERROR; */
    (void)nssUTF8_CopyIntoFixedBuffer((NSSUTF8 *)NULL, (char *)utcTime, 16, ' ');
    return CKR_OK;
  }

  if( (void *)NULL == (void *)fwToken->mdToken->GetUTCTime ) {
    /* It said it had one! */
    return CKR_GENERAL_ERROR;
  }

  error = fwToken->mdToken->GetUTCTime(fwToken->mdToken, fwToken, 
            fwToken->mdInstance, fwToken->fwInstance, utcTime);
  if( CKR_OK != error ) {
    return error;
  }

  /* Sanity-check the data */
  {
    /* Format is YYYYMMDDhhmmss00 */
    int i;
    int Y, M, D, h, m, s, z;
    static int dims[] = { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };

    for( i = 0; i < 16; i++ ) {
      if( (utcTime[i] < '0') || (utcTime[i] > '9') ) {
        goto badtime;
      }
    }

    Y = ((utcTime[ 0] - '0') * 1000) + ((utcTime[1] - '0') * 100) +
        ((utcTime[ 2] - '0') * 10) + (utcTime[ 3] - '0');
    M = ((utcTime[ 4] - '0') * 10) + (utcTime[ 5] - '0');
    D = ((utcTime[ 6] - '0') * 10) + (utcTime[ 7] - '0');
    h = ((utcTime[ 8] - '0') * 10) + (utcTime[ 9] - '0');
    m = ((utcTime[10] - '0') * 10) + (utcTime[11] - '0');
    s = ((utcTime[12] - '0') * 10) + (utcTime[13] - '0');
    z = ((utcTime[14] - '0') * 10) + (utcTime[15] - '0');

    if( (Y < 1990) || (Y > 3000) ) goto badtime; /* Y3K problem.  heh heh heh */
    if( (M < 1) || (M > 12) ) goto badtime;
    if( (D < 1) || (D > 31) ) goto badtime;

    if( D > dims[M-1] ) goto badtime; /* per-month check */
    if( (2 == M) && (((Y%4)||!(Y%100))&&(Y%400)) && (D > 28) ) goto badtime; /* leap years */

    if( (h < 0) || (h > 23) ) goto badtime;
    if( (m < 0) || (m > 60) ) goto badtime;
    if( (s < 0) || (s > 61) ) goto badtime;

    /* 60m and 60 or 61s is only allowed for leap seconds. */
    if( (60 == m) || (s >= 60) ) {
      if( (23 != h) || (60 != m) || (s < 60) ) goto badtime;
      /* leap seconds can only happen on June 30 or Dec 31.. I think */
      /* if( ((6 != M) || (30 != D)) && ((12 != M) || (31 != D)) ) goto badtime; */
    }
  }

  return CKR_OK;

 badtime:
  return CKR_GENERAL_ERROR;
}

Here is the caller graph for this function:

NSS_EXTERN CK_RV nssCKFWToken_InitToken ( NSSCKFWToken *  fwToken,
NSSItem *  pin,
NSSUTF8 label 
)

Definition at line 496 of file token.c.

{
  CK_RV error;

#ifdef NSSDEBUG
  error = nssCKFWToken_verifyPointer(fwToken);
  if( CKR_OK != error ) {
    return CKR_ARGUMENTS_BAD;
  }
#endif /* NSSDEBUG */

  error = nssCKFWMutex_Lock(fwToken->mutex);
  if( CKR_OK != error ) {
    return error;
  }

  if( fwToken->sessionCount > 0 ) {
    error = CKR_SESSION_EXISTS;
    goto done;
  }

  if( (void *)NULL == (void *)fwToken->mdToken->InitToken ) {
    error = CKR_DEVICE_ERROR;
    goto done;
  }

  if( (NSSItem *)NULL == pin ) {
    if( nssCKFWToken_GetHasProtectedAuthenticationPath(fwToken) ) {
      ; /* okay */
    } else {
      error = CKR_PIN_INCORRECT;
      goto done;
    }
  }

  if( (NSSUTF8 *)NULL == label ) {
    label = (NSSUTF8 *) "";
  }

  error = fwToken->mdToken->InitToken(fwToken->mdToken, fwToken,
            fwToken->mdInstance, fwToken->fwInstance, pin, label);

 done:
  (void)nssCKFWMutex_Unlock(fwToken->mutex);
  return error;
}

Here is the caller graph for this function:

NSS_EXTERN NSSCKFWSession* nssCKFWToken_OpenSession ( NSSCKFWToken *  fwToken,
CK_BBOOL  rw,
CK_VOID_PTR  pApplication,
CK_NOTIFY  Notify,
CK_RV pError 
)

Definition at line 1312 of file token.c.

{
  NSSCKFWSession *fwSession = (NSSCKFWSession *)NULL;
  NSSCKMDSession *mdSession;

#ifdef NSSDEBUG
  if( (CK_RV *)NULL == pError ) {
    return (NSSCKFWSession *)NULL;
  }

  *pError = nssCKFWToken_verifyPointer(fwToken);
  if( CKR_OK != *pError ) {
    return (NSSCKFWSession *)NULL;
  }

  switch( rw ) {
  case CK_TRUE:
  case CK_FALSE:
    break;
  default:
    *pError = CKR_ARGUMENTS_BAD;
    return (NSSCKFWSession *)NULL;
  }
#endif /* NSSDEBUG */

  *pError = nssCKFWMutex_Lock(fwToken->mutex);
  if( CKR_OK != *pError ) {
    return (NSSCKFWSession *)NULL;
  }

  if( CK_TRUE == rw ) {
    /* Read-write session desired */
    if( CK_TRUE == nssCKFWToken_GetIsWriteProtected(fwToken) ) {
      *pError = CKR_TOKEN_WRITE_PROTECTED;
      goto done;
    }
  } else {
    /* Read-only session desired */
    if( CKS_RW_SO_FUNCTIONS == nssCKFWToken_GetSessionState(fwToken) ) {
      *pError = CKR_SESSION_READ_WRITE_SO_EXISTS;
      goto done;
    }
  }

  /* We could compare sesion counts to any limits we know of, I guess.. */

  if( (void *)NULL == (void *)fwToken->mdToken->OpenSession ) {
    /*
     * I'm not sure that the Module actually needs to implement
     * mdSessions -- the Framework can keep track of everything 
     * needed, really.  But I'll sort out that detail later..
     */
    *pError = CKR_GENERAL_ERROR;
    goto done;
  }

  fwSession = nssCKFWSession_Create(fwToken, rw, pApplication, Notify, pError);
  if( (NSSCKFWSession *)NULL == fwSession ) {
    if( CKR_OK == *pError ) {
      *pError = CKR_GENERAL_ERROR;
    }
    goto done;
  }

  mdSession = fwToken->mdToken->OpenSession(fwToken->mdToken, fwToken,
                fwToken->mdInstance, fwToken->fwInstance, fwSession,
                rw, pError);
  if( (NSSCKMDSession *)NULL == mdSession ) {
    (void)nssCKFWSession_Destroy(fwSession, CK_FALSE);
    if( CKR_OK == *pError ) {
      *pError = CKR_GENERAL_ERROR;
    }
    goto done;
  }

  *pError = nssCKFWSession_SetMDSession(fwSession, mdSession);
  if( CKR_OK != *pError ) {
    if( (void *)NULL != (void *)mdSession->Close ) {
      mdSession->Close(mdSession, fwSession, fwToken->mdToken, fwToken,
      fwToken->mdInstance, fwToken->fwInstance);
    }
    (void)nssCKFWSession_Destroy(fwSession, CK_FALSE);
    goto done;
  }

  *pError = nssCKFWHash_Add(fwToken->sessions, fwSession, fwSession);
  if( CKR_OK != *pError ) {
    (void)nssCKFWSession_Destroy(fwSession, CK_FALSE);
    fwSession = (NSSCKFWSession *)NULL;
    goto done;
  }

 done:
  (void)nssCKFWMutex_Unlock(fwToken->mutex);
  return fwSession;
}

Here is the caller graph for this function:

NSS_EXTERN CK_RV nssCKFWToken_RemoveSession ( NSSCKFWToken *  fwToken,
NSSCKFWSession *  fwSession 
)

Definition at line 1534 of file token.c.

{
  CK_RV error = CKR_OK;

#ifdef NSSDEBUG
  error = nssCKFWToken_verifyPointer(fwToken);
  if( CKR_OK != error ) {
    return error;
  }

  error = nssCKFWSession_verifyPointer(fwSession);
  if( CKR_OK != error ) {
    return error;
  }
#endif /* NSSDEBUG */

  error = nssCKFWMutex_Lock(fwToken->mutex);
  if( CKR_OK != error ) {
    return error;
  }

  if( CK_TRUE != nssCKFWHash_Exists(fwToken->sessions, fwSession) ) {
    error = CKR_SESSION_HANDLE_INVALID;
    goto done;
  }

  nssCKFWHash_Remove(fwToken->sessions, fwSession);
  fwToken->sessionCount--;

  if( nssCKFWSession_IsRWSession(fwSession) ) {
    fwToken->rwSessionCount--;
  }

  if( 0 == fwToken->sessionCount ) {
    fwToken->rwSessionCount = 0; /* sanity */
    fwToken->state = CKS_RO_PUBLIC_SESSION; /* some default */
  }

  error = CKR_OK;

 done:
  (void)nssCKFWMutex_Unlock(fwToken->mutex);
  return error;
}

Here is the caller graph for this function:

NSS_EXTERN CK_RV nssCKFWToken_SetSessionState ( NSSCKFWToken *  fwToken,
CK_STATE  newState 
)

Definition at line 1493 of file token.c.

{
  CK_RV error = CKR_OK;

#ifdef NSSDEBUG
  error = nssCKFWToken_verifyPointer(fwToken);
  if( CKR_OK != error ) {
    return error;
  }

  switch( newState ) {
  case CKS_RO_PUBLIC_SESSION:
  case CKS_RO_USER_FUNCTIONS:
  case CKS_RW_PUBLIC_SESSION:
  case CKS_RW_USER_FUNCTIONS:
  case CKS_RW_SO_FUNCTIONS:
    break;
  default:
    return CKR_ARGUMENTS_BAD;
  }
#endif /* NSSDEBUG */

  error = nssCKFWMutex_Lock(fwToken->mutex);
  if( CKR_OK != error ) {
    return error;
  }

  fwToken->state = newState;
  (void)nssCKFWMutex_Unlock(fwToken->mutex);
  return CKR_OK;
}

Here is the caller graph for this function: