Getting session objects working.

This commit is contained in:
roeber%netscape.com 2000-04-20 03:14:47 +00:00
Родитель 55078fbfc4
Коммит 94c0599e00
6 изменённых файлов: 84 добавлений и 28 удалений

Просмотреть файл

@ -32,7 +32,7 @@
*/
#ifdef DEBUG
static const char CVS_ID[] = "@(#) $RCSfile: find.c,v $ $Revision: 1.1 $ $Date: 2000-03-31 19:43:49 $ $Name: $";
static const char CVS_ID[] = "@(#) $RCSfile: find.c,v $ $Revision: 1.2 $ $Date: 2000-04-20 03:14:47 $ $Name: $";
#endif /* DEBUG */
#ifndef BUILTINS_H
@ -216,11 +216,6 @@ nss_builtins_FindObjectsInit
}
}
if( 0 == fo->n ) {
*pError = CKR_OK;
goto loser;
}
fo->objs = nss_ZNEWARRAY(arena, builtinsInternalObject *, fo->n);
if( (builtinsInternalObject **)NULL == temp ) {
*pError = CKR_HOST_MEMORY;

Просмотреть файл

@ -32,7 +32,7 @@
*/
#ifdef DEBUG
static const char CVS_ID[] = "@(#) $RCSfile: object.c,v $ $Revision: 1.2 $ $Date: 2000-04-19 21:31:54 $ $Name: $";
static const char CVS_ID[] = "@(#) $RCSfile: object.c,v $ $Revision: 1.3 $ $Date: 2000-04-20 03:14:04 $ $Name: $";
#endif /* DEBUG */
/*
@ -278,7 +278,7 @@ nssCKFWObject_Destroy
(void)nssCKFWMutex_Destroy(fwObject->mutex);
if( (void *)NULL != (void *)fwObject->mdObject->Destroy ) {
fwObject->mdObject->Finalize(fwObject->mdObject, fwObject,
fwObject->mdObject->Destroy(fwObject->mdObject, fwObject,
fwObject->mdSession, fwObject->fwSession, fwObject->mdToken,
fwObject->fwToken, fwObject->mdInstance, fwObject->fwInstance);
}

Просмотреть файл

@ -32,7 +32,7 @@
*/
#ifdef DEBUG
static const char CVS_ID[] = "@(#) $RCSfile: session.c,v $ $Revision: 1.2 $ $Date: 2000-04-19 21:31:55 $ $Name: $";
static const char CVS_ID[] = "@(#) $RCSfile: session.c,v $ $Revision: 1.3 $ $Date: 2000-04-20 03:14:08 $ $Name: $";
#endif /* DEBUG */
/*
@ -1405,7 +1405,8 @@ nssCKFWSession_CopyObject
/* use create object */
NSSArena *tmpArena;
CK_ATTRIBUTE_PTR newTemplate;
CK_ULONG i;
CK_ULONG i, j, n, newLength, k;
CK_ATTRIBUTE_TYPE_PTR oldTypes;
NSSCKFWObject *rv;
tmpArena = NSSArena_Create();
@ -1414,32 +1415,88 @@ nssCKFWSession_CopyObject
return (NSSCKFWObject *)NULL;
}
newTemplate = nss_ZNEWARRAY(tmpArena, CK_ATTRIBUTE, ulAttributeCount);
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;
}
for( i = 0; i < ulAttributeCount; i++ ) {
newTemplate[i] = pTemplate[i];
if( (void *)NULL == newTemplate[i].pValue ) {
NSSItem item;
NSSItem *it = nssCKFWObject_GetAttribute(fwObject, newTemplate[i].type,
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 ) {
if( CKR_OK == *pError ) {
*pError = CKR_GENERAL_ERROR;
}
NSSArena_Destroy(tmpArena);
return (NSSCKFWObject *)NULL;
}
newTemplate[i].pValue = it->data;
newTemplate[i].ulValueLen = it->size;
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, ulAttributeCount, pError);
rv = nssCKFWSession_CreateObject(fwSession, newTemplate, newLength, pError);
if( (NSSCKFWObject *)NULL == rv ) {
if( CKR_OK == *pError ) {
*pError = CKR_GENERAL_ERROR;
@ -1490,7 +1547,7 @@ nssCKFWSession_FindObjectsInit
}
#endif /* NSSDEBUG */
if( CK_TRUE == nssCKFWInstance_GetModuleHandlesSessionObjects(
if( CK_TRUE != nssCKFWInstance_GetModuleHandlesSessionObjects(
fwSession->fwInstance) ) {
CK_ULONG i;

Просмотреть файл

@ -32,7 +32,7 @@
*/
#ifdef DEBUG
static const char CVS_ID[] = "@(#) $RCSfile: sessobj.c,v $ $Revision: 1.3 $ $Date: 2000-04-19 21:32:11 $ $Name: $";
static const char CVS_ID[] = "@(#) $RCSfile: sessobj.c,v $ $Revision: 1.4 $ $Date: 2000-04-20 03:14:13 $ $Name: $";
#endif /* DEBUG */
/*
@ -908,6 +908,8 @@ findfcn
if( mdso->types[j] == p->type ) {
if( !items_match(&mdso->attributes[j], p->pValue, p->ulValueLen) ) {
return;
} else {
break;
}
}
}
@ -1061,6 +1063,7 @@ nss_ckmdFindSessionObjects_Next
)
{
nssCKMDFindSessionObjects *mdfso;
NSSCKMDObject *rv = (NSSCKMDObject *)NULL;
#ifdef NSSDEBUG
if( CKR_OK != nss_ckmdFindSessionObjects_verifyPointer(mdFindObjects) ) {
@ -1070,18 +1073,18 @@ nss_ckmdFindSessionObjects_Next
mdfso = (nssCKMDFindSessionObjects *)mdFindObjects->etc;
while( 1 ) {
while( (NSSCKMDObject *)NULL == rv ) {
if( (struct nodeStr *)NULL == mdfso->list ) {
*pError = CKR_OK;
return (NSSCKMDObject *)NULL;
}
if( nssCKFWHash_Exists(mdfso->hash, mdfso->list->mdObject) ) {
break;
rv = mdfso->list->mdObject;
}
mdfso->list = mdfso->list->next;
}
return mdfso->list->mdObject;
return rv;
}

Просмотреть файл

@ -32,7 +32,7 @@
*/
#ifdef DEBUG
static const char CVS_ID[] = "@(#) $RCSfile: slot.c,v $ $Revision: 1.1 $ $Date: 2000-03-31 19:43:39 $ $Name: $";
static const char CVS_ID[] = "@(#) $RCSfile: slot.c,v $ $Revision: 1.2 $ $Date: 2000-04-20 03:14:29 $ $Name: $";
#endif /* DEBUG */
/*
@ -656,6 +656,7 @@ nssCKFWSlot_GetToken
}
fwToken = nssCKFWToken_Create(fwSlot, mdToken, pError);
fwSlot->fwToken = fwToken;
} else {
fwToken = fwSlot->fwToken;
}

Просмотреть файл

@ -32,7 +32,7 @@
*/
#ifdef DEBUG
static const char CVS_ID[] = "@(#) $RCSfile: token.c,v $ $Revision: 1.2 $ $Date: 2000-04-19 21:32:20 $ $Name: $";
static const char CVS_ID[] = "@(#) $RCSfile: token.c,v $ $Revision: 1.3 $ $Date: 2000-04-20 03:14:41 $ $Name: $";
#endif /* DEBUG */
/*
@ -250,7 +250,7 @@ nssCKFWToken_Create
goto loser;
}
if( CK_TRUE == nssCKFWInstance_GetModuleHandlesSessionObjects(
if( CK_TRUE != nssCKFWInstance_GetModuleHandlesSessionObjects(
fwToken->fwInstance) ) {
fwToken->sessionObjectHash = nssCKFWHash_Create(fwToken->fwInstance,
arena, pError);