Back to index

lightning-sunbird  0.9+nobinonly
Functions
ckmd.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

NSS_EXTERN NSSCKMDObject * nssCKMDSessionObject_Create (NSSCKFWToken *fwToken, NSSArena *arena, CK_ATTRIBUTE_PTR attributes, CK_ULONG ulCount, CK_RV *pError)
NSS_EXTERN NSSCKMDFindObjects * nssCKMDFindSessionObjects_Create (NSSCKFWToken *fwToken, CK_ATTRIBUTE_PTR pTemplate, CK_ULONG ulCount, CK_RV *pError)

Function Documentation

NSS_EXTERN NSSCKMDFindObjects* nssCKMDFindSessionObjects_Create ( NSSCKFWToken *  fwToken,
CK_ATTRIBUTE_PTR  pTemplate,
CK_ULONG  ulCount,
CK_RV pError 
)

Definition at line 954 of file sessobj.c.

{
  NSSArena *arena;
  nssCKMDFindSessionObjects *mdfso;
  nssCKFWHash *hash;
  NSSCKMDFindObjects *rv;

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

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

  if( (CK_ATTRIBUTE_PTR)NULL == pTemplate ) {
    *pError = CKR_ARGUMENTS_BAD;
    return (NSSCKMDFindObjects *)NULL;
  }
#endif /* NSSDEBUG */

  hash = nssCKFWToken_GetSessionObjectHash(fwToken);
  if( (nssCKFWHash *)NULL == hash ) {
    *pError= CKR_GENERAL_ERROR;
    return (NSSCKMDFindObjects *)NULL;
  }

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

  mdfso = nss_ZNEW(arena, nssCKMDFindSessionObjects);
  if( (nssCKMDFindSessionObjects *)NULL == mdfso ) {
    NSSArena_Destroy(arena);
    *pError = CKR_HOST_MEMORY;
    return (NSSCKMDFindObjects *)NULL;
  }

  rv = nss_ZNEW(arena, NSSCKMDFindObjects);

  mdfso->error = CKR_OK;
  mdfso->pTemplate = pTemplate;
  mdfso->ulCount = ulCount;
  mdfso->hash = hash;

  nssCKFWHash_Iterate(hash, findfcn, mdfso);

  if( CKR_OK != mdfso->error ) {
    NSSArena_Destroy(arena);
    *pError = CKR_HOST_MEMORY;
    return (NSSCKMDFindObjects *)NULL;
  }

  rv->etc = (void *)mdfso;
  rv->Final = nss_ckmdFindSessionObjects_Final;
  rv->Next = nss_ckmdFindSessionObjects_Next;

#ifdef DEBUG
  if( (*pError = nss_ckmdFindSessionObjects_add_pointer(rv)) != CKR_OK ) {
    NSSArena_Destroy(arena);
    return (NSSCKMDFindObjects *)NULL;
  }
#endif /* DEBUG */    
  mdfso->arena = arena;

  return rv;
}

Here is the call graph for this function:

NSS_EXTERN NSSCKMDObject* nssCKMDSessionObject_Create ( NSSCKFWToken *  fwToken,
NSSArena *  arena,
CK_ATTRIBUTE_PTR  attributes,
CK_ULONG  ulCount,
CK_RV pError 
)

Definition at line 258 of file sessobj.c.

{
  NSSCKMDObject *mdObject = (NSSCKMDObject *)NULL;
  nssCKMDSessionObject *mdso = (nssCKMDSessionObject *)NULL;
  CK_ULONG i;
  nssCKFWHash *hash;

  mdso = nss_ZNEW(arena, nssCKMDSessionObject);
  if( (nssCKMDSessionObject *)NULL == mdso ) {
    goto loser;
  }

  mdso->arena = arena;
  mdso->n = ulCount;
  mdso->attributes = nss_ZNEWARRAY(arena, NSSItem, ulCount);
  if( (NSSItem *)NULL == mdso->attributes ) {
    goto loser;
  }

  mdso->types = nss_ZNEWARRAY(arena, CK_ATTRIBUTE_TYPE, ulCount);

  for( i = 0; i < ulCount; i++ ) {
    mdso->types[i] = attributes[i].type;
    mdso->attributes[i].size = attributes[i].ulValueLen;
    mdso->attributes[i].data = nss_ZAlloc(arena, attributes[i].ulValueLen);
    if( (void *)NULL == mdso->attributes[i].data ) {
      goto loser;
    }
    (void)nsslibc_memcpy(mdso->attributes[i].data, attributes[i].pValue,
      attributes[i].ulValueLen);
  }

  mdObject = nss_ZNEW(arena, NSSCKMDObject);
  if( (NSSCKMDObject *)NULL == mdObject ) {
    goto loser;
  }

  mdObject->etc = (void *)mdso;
  mdObject->Finalize = nss_ckmdSessionObject_Finalize;
  mdObject->Destroy = nss_ckmdSessionObject_Destroy;
  mdObject->IsTokenObject = nss_ckmdSessionObject_IsTokenObject;
  mdObject->GetAttributeCount = nss_ckmdSessionObject_GetAttributeCount;
  mdObject->GetAttributeTypes = nss_ckmdSessionObject_GetAttributeTypes;
  mdObject->GetAttributeSize = nss_ckmdSessionObject_GetAttributeSize;
  mdObject->GetAttribute = nss_ckmdSessionObject_GetAttribute;
  mdObject->SetAttribute = nss_ckmdSessionObject_SetAttribute;
  mdObject->GetObjectSize = nss_ckmdSessionObject_GetObjectSize;

  hash = nssCKFWToken_GetSessionObjectHash(fwToken);
  if( (nssCKFWHash *)NULL == hash ) {
    *pError = CKR_GENERAL_ERROR;
    goto loser;
  }

  mdso->hash = hash;

  *pError = nssCKFWHash_Add(hash, mdObject, mdObject);
  if( CKR_OK != *pError ) {
    goto loser;
  }

#ifdef DEBUG
  if( CKR_OK != nss_ckmdSessionObject_add_pointer(mdObject) ) {
    goto loser;
  }
#endif /* DEBUG */

  *pError = CKR_OK;
  return mdObject;

 loser:
  if( (nssCKMDSessionObject *)NULL != mdso ) {
    if( (NSSItem *)NULL != mdso->attributes ) {
      for( i = 0; i < ulCount; i++ ) {
        nss_ZFreeIf(mdso->attributes[i].data);
      }

      nss_ZFreeIf(mdso->attributes);
    }

    nss_ZFreeIf(mdso->types);
    nss_ZFreeIf(mdso);
  }

  nss_ZFreeIf(mdObject);
  *pError = CKR_HOST_MEMORY;
  return (NSSCKMDObject *)NULL;
}

Here is the call graph for this function: