Back to index

lightning-sunbird  0.9+nobinonly
Functions
token.c File Reference
#include "ckdbm.h"

Go to the source code of this file.

Functions

static CK_RV nss_dbm_mdToken_Setup (NSSCKMDToken *mdToken, NSSCKFWToken *fwToken, NSSCKMDInstance *mdInstance, NSSCKFWInstance *fwInstance)
static void nss_dbm_mdToken_Invalidate (NSSCKMDToken *mdToken, NSSCKFWToken *fwToken, NSSCKMDInstance *mdInstance, NSSCKFWInstance *fwInstance)
static CK_RV nss_dbm_mdToken_InitToken (NSSCKMDToken *mdToken, NSSCKFWToken *fwToken, NSSCKMDInstance *mdInstance, NSSCKFWInstance *fwInstance, NSSItem *pin, NSSUTF8 *label)
static NSSUTF8nss_dbm_mdToken_GetLabel (NSSCKMDToken *mdToken, NSSCKFWToken *fwToken, NSSCKMDInstance *mdInstance, NSSCKFWInstance *fwInstance, CK_RV *pError)
static NSSUTF8nss_dbm_mdToken_GetManufacturerID (NSSCKMDToken *mdToken, NSSCKFWToken *fwToken, NSSCKMDInstance *mdInstance, NSSCKFWInstance *fwInstance, CK_RV *pError)
static NSSUTF8nss_dbm_mdToken_GetModel (NSSCKMDToken *mdToken, NSSCKFWToken *fwToken, NSSCKMDInstance *mdInstance, NSSCKFWInstance *fwInstance, CK_RV *pError)
static CK_BBOOL nss_dbm_mdToken_GetIsWriteProtected (NSSCKMDToken *mdToken, NSSCKFWToken *fwToken, NSSCKMDInstance *mdInstance, NSSCKFWInstance *fwInstance)
static CK_ULONG nss_dbm_mdToken_effectively_infinite (NSSCKMDToken *mdToken, NSSCKFWToken *fwToken, NSSCKMDInstance *mdInstance, NSSCKFWInstance *fwInstance)
static CK_VERSION nss_dbm_mdToken_GetHardwareVersion (NSSCKMDToken *mdToken, NSSCKFWToken *fwToken, NSSCKMDInstance *mdInstance, NSSCKFWInstance *fwInstance)
static NSSCKMDSession * nss_dbm_mdToken_OpenSession (NSSCKMDToken *mdToken, NSSCKFWToken *fwToken, NSSCKMDInstance *mdInstance, NSSCKFWInstance *fwInstance, NSSCKFWSession *fwSession, CK_BBOOL rw, CK_RV *pError)
NSS_IMPLEMENT NSSCKMDToken * nss_dbm_mdToken_factory (nss_dbm_slot_t *slot, CK_RV *pError)

Function Documentation

static CK_ULONG nss_dbm_mdToken_effectively_infinite ( NSSCKMDToken *  mdToken,
NSSCKFWToken *  fwToken,
NSSCKMDInstance *  mdInstance,
NSSCKFWInstance *  fwInstance 
) [static]

Definition at line 217 of file token.c.

Here is the caller graph for this function:

NSS_IMPLEMENT NSSCKMDToken* nss_dbm_mdToken_factory ( nss_dbm_slot_t *  slot,
CK_RV pError 
)

Definition at line 265 of file token.c.

{
  nss_dbm_token_t *token;
  NSSCKMDToken *rv;

  token = nss_ZNEW(slot->instance->arena, nss_dbm_token_t);
  if( (nss_dbm_token_t *)NULL == token ) {
    *pError = CKR_HOST_MEMORY;
    return (NSSCKMDToken *)NULL;
  }

  rv = nss_ZNEW(slot->instance->arena, NSSCKMDToken);
  if( (NSSCKMDToken *)NULL == rv ) {
    *pError = CKR_HOST_MEMORY;
    return (NSSCKMDToken *)NULL;
  }

  token->slot = slot;

  rv->etc = (void *)token;
  rv->Setup = nss_dbm_mdToken_Setup;
  rv->Invalidate = nss_dbm_mdToken_Invalidate;
  rv->InitToken = nss_dbm_mdToken_InitToken;
  rv->GetLabel = nss_dbm_mdToken_GetLabel;
  rv->GetManufacturerID = nss_dbm_mdToken_GetManufacturerID;
  rv->GetModel = nss_dbm_mdToken_GetModel;
  /*  GetSerialNumber is irrelevant */
  /*  GetHasRNG defaults to CK_FALSE */
  rv->GetIsWriteProtected = nss_dbm_mdToken_GetIsWriteProtected;
  /*  GetLoginRequired defaults to CK_FALSE */
  /*  GetUserPinInitialized defaults to CK_FALSE */
  /*  GetRestoreKeyNotNeeded is irrelevant */
  /*  GetHasClockOnToken defaults to CK_FALSE */
  /*  GetHasProtectedAuthenticationPath defaults to CK_FALSE */
  /*  GetSupportsDualCryptoOperations is irrelevant */
  rv->GetMaxSessionCount = nss_dbm_mdToken_effectively_infinite;
  rv->GetMaxRwSessionCount = nss_dbm_mdToken_effectively_infinite;
  /*  GetMaxPinLen is irrelevant */
  /*  GetMinPinLen is irrelevant */
  /*  GetTotalPublicMemory defaults to CK_UNAVAILABLE_INFORMATION */
  /*  GetFreePublicMemory defaults to CK_UNAVAILABLE_INFORMATION */
  /*  GetTotalPrivateMemory defaults to CK_UNAVAILABLE_INFORMATION */
  /*  GetFreePrivateMemory defaults to CK_UNAVAILABLE_INFORMATION */
  rv->GetHardwareVersion = nss_dbm_mdToken_GetHardwareVersion;
  /*  GetFirmwareVersion is irrelevant */
  /*  GetUTCTime is irrelevant */
  rv->OpenSession = nss_dbm_mdToken_OpenSession;
  rv->null = NULL;

  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static CK_VERSION nss_dbm_mdToken_GetHardwareVersion ( NSSCKMDToken *  mdToken,
NSSCKFWToken *  fwToken,
NSSCKMDInstance *  mdInstance,
NSSCKFWInstance *  fwInstance 
) [static]

Definition at line 229 of file token.c.

{
  nss_dbm_token_t *token = (nss_dbm_token_t *)mdToken->etc;
  return nss_dbm_db_get_format_version(token->slot->token_db);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static CK_BBOOL nss_dbm_mdToken_GetIsWriteProtected ( NSSCKMDToken *  mdToken,
NSSCKFWToken *  fwToken,
NSSCKMDInstance *  mdInstance,
NSSCKFWInstance *  fwInstance 
) [static]

Definition at line 192 of file token.c.

{
  nss_dbm_token_t *token = (nss_dbm_token_t *)mdToken->etc;

  if( token->slot->flags & O_RDWR ) {
    return CK_FALSE;
  } else {
    return CK_TRUE;
  }
}

Here is the caller graph for this function:

static NSSUTF8* nss_dbm_mdToken_GetLabel ( NSSCKMDToken *  mdToken,
NSSCKFWToken *  fwToken,
NSSCKMDInstance *  mdInstance,
NSSCKFWInstance *  fwInstance,
CK_RV pError 
) [static]

Definition at line 139 of file token.c.

{
  nss_dbm_token_t *token = (nss_dbm_token_t *)mdToken->etc;

  if( (NSSUTF8 *)NULL == token->label ) {
    token->label = nss_dbm_db_get_label(token->slot->token_db, token->arena, pError);
  }

  /* If no label has been set, return *something* */
  if( (NSSUTF8 *)NULL == token->label ) {
    return token->slot->filename;
  }

  return token->label;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static NSSUTF8* nss_dbm_mdToken_GetManufacturerID ( NSSCKMDToken *  mdToken,
NSSCKFWToken *  fwToken,
NSSCKMDInstance *  mdInstance,
NSSCKFWInstance *  fwInstance,
CK_RV pError 
) [static]

Definition at line 163 of file token.c.

{
  return "mozilla.org NSS";
}

Here is the caller graph for this function:

static NSSUTF8* nss_dbm_mdToken_GetModel ( NSSCKMDToken *  mdToken,
NSSCKFWToken *  fwToken,
NSSCKMDInstance *  mdInstance,
NSSCKFWInstance *  fwInstance,
CK_RV pError 
) [static]

Definition at line 176 of file token.c.

{
  return "dbm";
}

Here is the caller graph for this function:

static CK_RV nss_dbm_mdToken_InitToken ( NSSCKMDToken *  mdToken,
NSSCKFWToken *  fwToken,
NSSCKMDInstance *  mdInstance,
NSSCKFWInstance *  fwInstance,
NSSItem *  pin,
NSSUTF8 label 
) [static]

Definition at line 86 of file token.c.

{
  nss_dbm_token_t *token = (nss_dbm_token_t *)mdToken->etc;
  nss_dbm_instance_t *instance = (nss_dbm_instance_t *)mdInstance->etc;
  CK_RV rv;

  /* Wipe the session object data */
  
  if( (nss_dbm_db_t *)NULL != token->session_db ) {
    nss_dbm_db_close(token->session_db);
  }

  token->session_db = nss_dbm_db_open(token->arena, fwInstance, (char *)NULL, 
                                      O_RDWR|O_CREAT, &rv);
  if( (nss_dbm_db_t *)NULL == token->session_db ) {
    return rv;
  }

  /* Wipe the token object data */

  if( token->slot->flags & O_RDWR ) {
    if( (nss_dbm_db_t *)NULL != token->slot->token_db ) {
      nss_dbm_db_close(token->slot->token_db);
    }

    token->slot->token_db = nss_dbm_db_open(instance->arena, fwInstance, 
                                            token->slot->filename,
                                            token->slot->flags | O_CREAT | O_TRUNC, 
                                            &rv);
    if( (nss_dbm_db_t *)NULL == token->slot->token_db ) {
      return rv;
    }

    /* PIN is irrelevant */

    rv = nss_dbm_db_set_label(token->slot->token_db, label);
    if( CKR_OK != rv ) {
      return rv;
    }
  }

  return CKR_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void nss_dbm_mdToken_Invalidate ( NSSCKMDToken *  mdToken,
NSSCKFWToken *  fwToken,
NSSCKMDInstance *  mdInstance,
NSSCKFWInstance *  fwInstance 
) [static]

Definition at line 69 of file token.c.

{
  nss_dbm_token_t *token = (nss_dbm_token_t *)mdToken->etc;

  if( (nss_dbm_db_t *)NULL != token->session_db ) {
    nss_dbm_db_close(token->session_db);
    token->session_db = (nss_dbm_db_t *)NULL;
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static NSSCKMDSession* nss_dbm_mdToken_OpenSession ( NSSCKMDToken *  mdToken,
NSSCKFWToken *  fwToken,
NSSCKMDInstance *  mdInstance,
NSSCKFWInstance *  fwInstance,
NSSCKFWSession *  fwSession,
CK_BBOOL  rw,
CK_RV pError 
) [static]

Definition at line 245 of file token.c.

{
  nss_dbm_token_t *token = (nss_dbm_token_t *)mdToken->etc;
  return nss_dbm_mdSession_factory(token, fwSession, fwInstance, rw, pError);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static CK_RV nss_dbm_mdToken_Setup ( NSSCKMDToken *  mdToken,
NSSCKFWToken *  fwToken,
NSSCKMDInstance *  mdInstance,
NSSCKFWInstance *  fwInstance 
) [static]

Definition at line 45 of file token.c.

{
  nss_dbm_token_t *token = (nss_dbm_token_t *)mdToken->etc;
  CK_RV rv = CKR_OK;

  token->arena = NSSCKFWToken_GetArena(fwToken, &rv);
  token->session_db = nss_dbm_db_open(token->arena, fwInstance, (char *)NULL, 
                                      O_RDWR|O_CREAT, &rv);
  if( (nss_dbm_db_t *)NULL == token->session_db ) {
    return rv;
  }

  /* Add a label record if there isn't one? */

  return CKR_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function: