1 /* ***** BEGIN LICENSE BLOCK *****
2 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 * The contents of this file are subject to the Mozilla Public License Version
5 * 1.1 (the "License"); you may not use this file except in compliance with
6 * the License. You may obtain a copy of the License at
7 * http://www.mozilla.org/MPL/
9 * Software distributed under the License is distributed on an "AS IS" basis,
10 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11 * for the specific language governing rights and limitations under the
14 * The Original Code is the Netscape security libraries.
16 * The Initial Developer of the Original Code is
17 * Netscape Communications Corporation.
18 * Portions created by the Initial Developer are Copyright (C) 1994-2000
19 * the Initial Developer. All Rights Reserved.
23 * Alternatively, the contents of this file may be used under the terms of
24 * either the GNU General Public License Version 2 or later (the "GPL"), or
25 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
26 * in which case the provisions of the GPL or the LGPL are applicable instead
27 * of those above. If you wish to allow use of your version of this file only
28 * under the terms of either the GPL or the LGPL, and not to allow others to
29 * use your version of this file under the terms of the MPL, indicate your
30 * decision by deleting the provisions above and replace them with the notice
31 * and other provisions required by the GPL or the LGPL. If you do not delete
32 * the provisions above, a recipient may use your version of this file under
33 * the terms of any one of the MPL, the GPL or the LGPL.
35 * ***** END LICENSE BLOCK ***** */
38 static const char CVS_ID[] = "@(#) $RCSfile: sessobj.c,v $ $Revision: 1.15 $ $Date: 2009/06/05 00:22:04 $";
44 * This file contains an NSSCKMDObject implementation for session
45 * objects. The framework uses this implementation to manage
46 * session objects when a Module doesn't wish to be bothered.
54 * nssCKMDSessionObject
57 * nssCKMDSessionObject_Create
60 * nss_ckmdSessionObject_Finalize
61 * nss_ckmdSessionObject_IsTokenObject
62 * nss_ckmdSessionObject_GetAttributeCount
63 * nss_ckmdSessionObject_GetAttributeTypes
64 * nss_ckmdSessionObject_GetAttributeSize
65 * nss_ckmdSessionObject_GetAttribute
66 * nss_ckmdSessionObject_SetAttribute
67 * nss_ckmdSessionObject_GetObjectSize
70 struct nssCKMDSessionObjectStr {
74 CK_ATTRIBUTE_TYPE_PTR types;
77 typedef struct nssCKMDSessionObjectStr nssCKMDSessionObject;
81 * But first, the pointer-tracking stuff.
83 * NOTE: the pointer-tracking support in NSS/base currently relies
84 * upon NSPR's CallOnce support. That, however, relies upon NSPR's
85 * locking, which is tied into the runtime. We need a pointer-tracker
86 * implementation that uses the locks supplied through C_Initialize.
87 * That support, however, can be filled in later. So for now, I'll
88 * just do this routines as no-ops.
92 nss_ckmdSessionObject_add_pointer
94 const NSSCKMDObject *mdObject
101 nss_ckmdSessionObject_remove_pointer
103 const NSSCKMDObject *mdObject
111 nss_ckmdSessionObject_verifyPointer
113 const NSSCKMDObject *mdObject
123 * We must forward-declare these routines
126 nss_ckmdSessionObject_Finalize
128 NSSCKMDObject *mdObject,
129 NSSCKFWObject *fwObject,
130 NSSCKMDSession *mdSession,
131 NSSCKFWSession *fwSession,
132 NSSCKMDToken *mdToken,
133 NSSCKFWToken *fwToken,
134 NSSCKMDInstance *mdInstance,
135 NSSCKFWInstance *fwInstance
139 nss_ckmdSessionObject_Destroy
141 NSSCKMDObject *mdObject,
142 NSSCKFWObject *fwObject,
143 NSSCKMDSession *mdSession,
144 NSSCKFWSession *fwSession,
145 NSSCKMDToken *mdToken,
146 NSSCKFWToken *fwToken,
147 NSSCKMDInstance *mdInstance,
148 NSSCKFWInstance *fwInstance
152 nss_ckmdSessionObject_IsTokenObject
154 NSSCKMDObject *mdObject,
155 NSSCKFWObject *fwObject,
156 NSSCKMDSession *mdSession,
157 NSSCKFWSession *fwSession,
158 NSSCKMDToken *mdToken,
159 NSSCKFWToken *fwToken,
160 NSSCKMDInstance *mdInstance,
161 NSSCKFWInstance *fwInstance
165 nss_ckmdSessionObject_GetAttributeCount
167 NSSCKMDObject *mdObject,
168 NSSCKFWObject *fwObject,
169 NSSCKMDSession *mdSession,
170 NSSCKFWSession *fwSession,
171 NSSCKMDToken *mdToken,
172 NSSCKFWToken *fwToken,
173 NSSCKMDInstance *mdInstance,
174 NSSCKFWInstance *fwInstance,
179 nss_ckmdSessionObject_GetAttributeTypes
181 NSSCKMDObject *mdObject,
182 NSSCKFWObject *fwObject,
183 NSSCKMDSession *mdSession,
184 NSSCKFWSession *fwSession,
185 NSSCKMDToken *mdToken,
186 NSSCKFWToken *fwToken,
187 NSSCKMDInstance *mdInstance,
188 NSSCKFWInstance *fwInstance,
189 CK_ATTRIBUTE_TYPE_PTR typeArray,
194 nss_ckmdSessionObject_GetAttributeSize
196 NSSCKMDObject *mdObject,
197 NSSCKFWObject *fwObject,
198 NSSCKMDSession *mdSession,
199 NSSCKFWSession *fwSession,
200 NSSCKMDToken *mdToken,
201 NSSCKFWToken *fwToken,
202 NSSCKMDInstance *mdInstance,
203 NSSCKFWInstance *fwInstance,
204 CK_ATTRIBUTE_TYPE attribute,
209 nss_ckmdSessionObject_GetAttribute
211 NSSCKMDObject *mdObject,
212 NSSCKFWObject *fwObject,
213 NSSCKMDSession *mdSession,
214 NSSCKFWSession *fwSession,
215 NSSCKMDToken *mdToken,
216 NSSCKFWToken *fwToken,
217 NSSCKMDInstance *mdInstance,
218 NSSCKFWInstance *fwInstance,
219 CK_ATTRIBUTE_TYPE attribute,
224 nss_ckmdSessionObject_SetAttribute
226 NSSCKMDObject *mdObject,
227 NSSCKFWObject *fwObject,
228 NSSCKMDSession *mdSession,
229 NSSCKFWSession *fwSession,
230 NSSCKMDToken *mdToken,
231 NSSCKFWToken *fwToken,
232 NSSCKMDInstance *mdInstance,
233 NSSCKFWInstance *fwInstance,
234 CK_ATTRIBUTE_TYPE attribute,
239 nss_ckmdSessionObject_GetObjectSize
241 NSSCKMDObject *mdObject,
242 NSSCKFWObject *fwObject,
243 NSSCKMDSession *mdSession,
244 NSSCKFWSession *fwSession,
245 NSSCKMDToken *mdToken,
246 NSSCKFWToken *fwToken,
247 NSSCKMDInstance *mdInstance,
248 NSSCKFWInstance *fwInstance,
253 * nssCKMDSessionObject_Create
256 NSS_IMPLEMENT NSSCKMDObject *
257 nssCKMDSessionObject_Create
259 NSSCKFWToken *fwToken,
261 CK_ATTRIBUTE_PTR attributes,
266 NSSCKMDObject *mdObject = (NSSCKMDObject *)NULL;
267 nssCKMDSessionObject *mdso = (nssCKMDSessionObject *)NULL;
273 mdso = nss_ZNEW(arena, nssCKMDSessionObject);
280 mdso->attributes = nss_ZNEWARRAY(arena, NSSItem, ulCount);
281 if (!mdso->attributes) {
285 mdso->types = nss_ZNEWARRAY(arena, CK_ATTRIBUTE_TYPE, ulCount);
289 for( i = 0; i < ulCount; i++ ) {
290 mdso->types[i] = attributes[i].type;
291 mdso->attributes[i].size = attributes[i].ulValueLen;
292 mdso->attributes[i].data = nss_ZAlloc(arena, attributes[i].ulValueLen);
293 if (!mdso->attributes[i].data) {
296 (void)nsslibc_memcpy(mdso->attributes[i].data, attributes[i].pValue,
297 attributes[i].ulValueLen);
300 mdObject = nss_ZNEW(arena, NSSCKMDObject);
305 mdObject->etc = (void *)mdso;
306 mdObject->Finalize = nss_ckmdSessionObject_Finalize;
307 mdObject->Destroy = nss_ckmdSessionObject_Destroy;
308 mdObject->IsTokenObject = nss_ckmdSessionObject_IsTokenObject;
309 mdObject->GetAttributeCount = nss_ckmdSessionObject_GetAttributeCount;
310 mdObject->GetAttributeTypes = nss_ckmdSessionObject_GetAttributeTypes;
311 mdObject->GetAttributeSize = nss_ckmdSessionObject_GetAttributeSize;
312 mdObject->GetAttribute = nss_ckmdSessionObject_GetAttribute;
313 mdObject->SetAttribute = nss_ckmdSessionObject_SetAttribute;
314 mdObject->GetObjectSize = nss_ckmdSessionObject_GetObjectSize;
316 hash = nssCKFWToken_GetSessionObjectHash(fwToken);
318 *pError = CKR_GENERAL_ERROR;
324 *pError = nssCKFWHash_Add(hash, mdObject, mdObject);
325 if( CKR_OK != *pError ) {
330 if(( *pError = nss_ckmdSessionObject_add_pointer(mdObject)) != CKR_OK ) {
339 if (mdso->attributes) {
340 for( i = 0; i < ulCount; i++ ) {
341 nss_ZFreeIf(mdso->attributes[i].data);
343 nss_ZFreeIf(mdso->attributes);
345 nss_ZFreeIf(mdso->types);
349 nss_ZFreeIf(mdObject);
350 if (*pError == CKR_OK) {
351 *pError = CKR_HOST_MEMORY;
353 return (NSSCKMDObject *)NULL;
357 * nss_ckmdSessionObject_Finalize
361 nss_ckmdSessionObject_Finalize
363 NSSCKMDObject *mdObject,
364 NSSCKFWObject *fwObject,
365 NSSCKMDSession *mdSession,
366 NSSCKFWSession *fwSession,
367 NSSCKMDToken *mdToken,
368 NSSCKFWToken *fwToken,
369 NSSCKMDInstance *mdInstance,
370 NSSCKFWInstance *fwInstance
373 /* This shouldn't ever be called */
378 * nss_ckmdSessionObject_Destroy
383 nss_ckmdSessionObject_Destroy
385 NSSCKMDObject *mdObject,
386 NSSCKFWObject *fwObject,
387 NSSCKMDSession *mdSession,
388 NSSCKFWSession *fwSession,
389 NSSCKMDToken *mdToken,
390 NSSCKFWToken *fwToken,
391 NSSCKMDInstance *mdInstance,
392 NSSCKFWInstance *fwInstance
396 CK_RV error = CKR_OK;
397 #endif /* NSSDEBUG */
398 nssCKMDSessionObject *mdso;
402 error = nss_ckmdSessionObject_verifyPointer(mdObject);
403 if( CKR_OK != error ) {
406 #endif /* NSSDEBUG */
408 mdso = (nssCKMDSessionObject *)mdObject->etc;
410 nssCKFWHash_Remove(mdso->hash, mdObject);
412 for( i = 0; i < mdso->n; i++ ) {
413 nss_ZFreeIf(mdso->attributes[i].data);
415 nss_ZFreeIf(mdso->attributes);
416 nss_ZFreeIf(mdso->types);
418 nss_ZFreeIf(mdObject);
421 (void)nss_ckmdSessionObject_remove_pointer(mdObject);
428 * nss_ckmdSessionObject_IsTokenObject
433 nss_ckmdSessionObject_IsTokenObject
435 NSSCKMDObject *mdObject,
436 NSSCKFWObject *fwObject,
437 NSSCKMDSession *mdSession,
438 NSSCKFWSession *fwSession,
439 NSSCKMDToken *mdToken,
440 NSSCKFWToken *fwToken,
441 NSSCKMDInstance *mdInstance,
442 NSSCKFWInstance *fwInstance
446 if( CKR_OK != nss_ckmdSessionObject_verifyPointer(mdObject) ) {
449 #endif /* NSSDEBUG */
452 * This implementation is only ever used for session objects.
458 * nss_ckmdSessionObject_GetAttributeCount
462 nss_ckmdSessionObject_GetAttributeCount
464 NSSCKMDObject *mdObject,
465 NSSCKFWObject *fwObject,
466 NSSCKMDSession *mdSession,
467 NSSCKFWSession *fwSession,
468 NSSCKMDToken *mdToken,
469 NSSCKFWToken *fwToken,
470 NSSCKMDInstance *mdInstance,
471 NSSCKFWInstance *fwInstance,
475 nssCKMDSessionObject *obj;
482 *pError = nss_ckmdSessionObject_verifyPointer(mdObject);
483 if( CKR_OK != *pError ) {
487 /* We could even check all the other arguments, for sanity. */
488 #endif /* NSSDEBUG */
490 obj = (nssCKMDSessionObject *)mdObject->etc;
496 * nss_ckmdSessionObject_GetAttributeTypes
500 nss_ckmdSessionObject_GetAttributeTypes
502 NSSCKMDObject *mdObject,
503 NSSCKFWObject *fwObject,
504 NSSCKMDSession *mdSession,
505 NSSCKFWSession *fwSession,
506 NSSCKMDToken *mdToken,
507 NSSCKFWToken *fwToken,
508 NSSCKMDInstance *mdInstance,
509 NSSCKFWInstance *fwInstance,
510 CK_ATTRIBUTE_TYPE_PTR typeArray,
515 CK_RV error = CKR_OK;
516 #endif /* NSSDEBUG */
517 nssCKMDSessionObject *obj;
520 error = nss_ckmdSessionObject_verifyPointer(mdObject);
521 if( CKR_OK != error ) {
525 /* We could even check all the other arguments, for sanity. */
526 #endif /* NSSDEBUG */
528 obj = (nssCKMDSessionObject *)mdObject->etc;
530 if( ulCount < obj->n ) {
531 return CKR_BUFFER_TOO_SMALL;
534 (void)nsslibc_memcpy(typeArray, obj->types,
535 sizeof(CK_ATTRIBUTE_TYPE) * obj->n);
541 * nss_ckmdSessionObject_GetAttributeSize
545 nss_ckmdSessionObject_GetAttributeSize
547 NSSCKMDObject *mdObject,
548 NSSCKFWObject *fwObject,
549 NSSCKMDSession *mdSession,
550 NSSCKFWSession *fwSession,
551 NSSCKMDToken *mdToken,
552 NSSCKFWToken *fwToken,
553 NSSCKMDInstance *mdInstance,
554 NSSCKFWInstance *fwInstance,
555 CK_ATTRIBUTE_TYPE attribute,
559 nssCKMDSessionObject *obj;
567 *pError = nss_ckmdSessionObject_verifyPointer(mdObject);
568 if( CKR_OK != *pError ) {
572 /* We could even check all the other arguments, for sanity. */
573 #endif /* NSSDEBUG */
575 obj = (nssCKMDSessionObject *)mdObject->etc;
577 for( i = 0; i < obj->n; i++ ) {
578 if( attribute == obj->types[i] ) {
579 return (CK_ULONG)(obj->attributes[i].size);
583 *pError = CKR_ATTRIBUTE_TYPE_INVALID;
588 * nss_ckmdSessionObject_GetAttribute
592 nss_ckmdSessionObject_GetAttribute
594 NSSCKMDObject *mdObject,
595 NSSCKFWObject *fwObject,
596 NSSCKMDSession *mdSession,
597 NSSCKFWSession *fwSession,
598 NSSCKMDToken *mdToken,
599 NSSCKFWToken *fwToken,
600 NSSCKMDInstance *mdInstance,
601 NSSCKFWInstance *fwInstance,
602 CK_ATTRIBUTE_TYPE attribute,
607 nssCKMDSessionObject *obj;
610 item.needsFreeing = PR_FALSE;
617 *pError = nss_ckmdSessionObject_verifyPointer(mdObject);
618 if( CKR_OK != *pError ) {
622 /* We could even check all the other arguments, for sanity. */
623 #endif /* NSSDEBUG */
625 obj = (nssCKMDSessionObject *)mdObject->etc;
627 for( i = 0; i < obj->n; i++ ) {
628 if( attribute == obj->types[i] ) {
629 item.item = &obj->attributes[i];
634 *pError = CKR_ATTRIBUTE_TYPE_INVALID;
639 * nss_ckmdSessionObject_SetAttribute
644 * Okay, so this implementation sucks. It doesn't support removing
645 * an attribute (if value == NULL), and could be more graceful about
646 * memory. It should allow "blank" slots in the arrays, with some
647 * invalid attribute type, and then it could support removal much
648 * more easily. Do this later.
651 nss_ckmdSessionObject_SetAttribute
653 NSSCKMDObject *mdObject,
654 NSSCKFWObject *fwObject,
655 NSSCKMDSession *mdSession,
656 NSSCKFWSession *fwSession,
657 NSSCKMDToken *mdToken,
658 NSSCKFWToken *fwToken,
659 NSSCKMDInstance *mdInstance,
660 NSSCKFWInstance *fwInstance,
661 CK_ATTRIBUTE_TYPE attribute,
665 nssCKMDSessionObject *obj;
669 CK_ATTRIBUTE_TYPE_PTR rt;
672 #endif /* NSSDEBUG */
675 error = nss_ckmdSessionObject_verifyPointer(mdObject);
676 if( CKR_OK != error ) {
680 /* We could even check all the other arguments, for sanity. */
681 #endif /* NSSDEBUG */
683 obj = (nssCKMDSessionObject *)mdObject->etc;
685 n.size = value->size;
686 n.data = nss_ZAlloc(obj->arena, n.size);
688 return CKR_HOST_MEMORY;
690 (void)nsslibc_memcpy(n.data, value->data, n.size);
692 for( i = 0; i < obj->n; i++ ) {
693 if( attribute == obj->types[i] ) {
694 nss_ZFreeIf(obj->attributes[i].data);
695 obj->attributes[i] = n;
704 ra = (NSSItem *)nss_ZRealloc(obj->attributes, sizeof(NSSItem) * (obj->n + 1));
707 return CKR_HOST_MEMORY;
709 obj->attributes = ra;
711 rt = (CK_ATTRIBUTE_TYPE_PTR)nss_ZRealloc(obj->types,
712 sizeof(CK_ATTRIBUTE_TYPE) * (obj->n + 1));
715 return CKR_HOST_MEMORY;
719 obj->attributes[obj->n] = n;
720 obj->types[obj->n] = attribute;
727 * nss_ckmdSessionObject_GetObjectSize
731 nss_ckmdSessionObject_GetObjectSize
733 NSSCKMDObject *mdObject,
734 NSSCKFWObject *fwObject,
735 NSSCKMDSession *mdSession,
736 NSSCKFWSession *fwSession,
737 NSSCKMDToken *mdToken,
738 NSSCKFWToken *fwToken,
739 NSSCKMDInstance *mdInstance,
740 NSSCKFWInstance *fwInstance,
744 nssCKMDSessionObject *obj;
746 CK_ULONG rv = (CK_ULONG)0;
753 *pError = nss_ckmdSessionObject_verifyPointer(mdObject);
754 if( CKR_OK != *pError ) {
758 /* We could even check all the other arguments, for sanity. */
759 #endif /* NSSDEBUG */
761 obj = (nssCKMDSessionObject *)mdObject->etc;
763 for( i = 0; i < obj->n; i++ ) {
764 rv += obj->attributes[i].size;
767 rv += sizeof(NSSItem) * obj->n;
768 rv += sizeof(CK_ATTRIBUTE_TYPE) * obj->n;
769 rv += sizeof(nssCKMDSessionObject);
775 * nssCKMDFindSessionObjects
778 * nssCKMDFindSessionObjects_Create
781 * nss_ckmdFindSessionObjects_Final
782 * nss_ckmdFindSessionObjects_Next
786 struct nodeStr *next;
787 NSSCKMDObject *mdObject;
790 struct nssCKMDFindSessionObjectsStr {
793 CK_ATTRIBUTE_PTR pTemplate;
795 struct nodeStr *list;
799 typedef struct nssCKMDFindSessionObjectsStr nssCKMDFindSessionObjects;
803 * But first, the pointer-tracking stuff.
805 * NOTE: the pointer-tracking support in NSS/base currently relies
806 * upon NSPR's CallOnce support. That, however, relies upon NSPR's
807 * locking, which is tied into the runtime. We need a pointer-tracker
808 * implementation that uses the locks supplied through C_Initialize.
809 * That support, however, can be filled in later. So for now, I'll
810 * just do this routines as no-ops.
814 nss_ckmdFindSessionObjects_add_pointer
816 const NSSCKMDFindObjects *mdFindObjects
823 nss_ckmdFindSessionObjects_remove_pointer
825 const NSSCKMDFindObjects *mdFindObjects
833 nss_ckmdFindSessionObjects_verifyPointer
835 const NSSCKMDFindObjects *mdFindObjects
845 * We must forward-declare these routines.
848 nss_ckmdFindSessionObjects_Final
850 NSSCKMDFindObjects *mdFindObjects,
851 NSSCKFWFindObjects *fwFindObjects,
852 NSSCKMDSession *mdSession,
853 NSSCKFWSession *fwSession,
854 NSSCKMDToken *mdToken,
855 NSSCKFWToken *fwToken,
856 NSSCKMDInstance *mdInstance,
857 NSSCKFWInstance *fwInstance
860 static NSSCKMDObject *
861 nss_ckmdFindSessionObjects_Next
863 NSSCKMDFindObjects *mdFindObjects,
864 NSSCKFWFindObjects *fwFindObjects,
865 NSSCKMDSession *mdSession,
866 NSSCKFWSession *fwSession,
867 NSSCKMDToken *mdToken,
868 NSSCKFWToken *fwToken,
869 NSSCKMDInstance *mdInstance,
870 NSSCKFWInstance *fwInstance,
883 if( a->size != ulValueLen ) {
887 if( PR_TRUE == nsslibc_memequal(a->data, pValue, ulValueLen, (PRStatus *)NULL) ) {
895 * Our hashtable iterator
905 NSSCKMDObject *mdObject = (NSSCKMDObject *)value;
906 nssCKMDSessionObject *mdso = (nssCKMDSessionObject *)mdObject->etc;
907 nssCKMDFindSessionObjects *mdfso = (nssCKMDFindSessionObjects *)closure;
909 struct nodeStr *node;
911 if( CKR_OK != mdfso->error ) {
915 for( i = 0; i < mdfso->ulCount; i++ ) {
916 CK_ATTRIBUTE_PTR p = &mdfso->pTemplate[i];
918 for( j = 0; j < mdso->n; j++ ) {
919 if( mdso->types[j] == p->type ) {
920 if( !items_match(&mdso->attributes[j], p->pValue, p->ulValueLen) ) {
929 /* Attribute not found */
935 node = nss_ZNEW(mdfso->arena, struct nodeStr);
936 if( (struct nodeStr *)NULL == node ) {
937 mdfso->error = CKR_HOST_MEMORY;
941 node->mdObject = mdObject;
942 node->next = mdfso->list;
949 * nssCKMDFindSessionObjects_Create
952 NSS_IMPLEMENT NSSCKMDFindObjects *
953 nssCKMDFindSessionObjects_Create
955 NSSCKFWToken *fwToken,
956 CK_ATTRIBUTE_PTR pTemplate,
962 nssCKMDFindSessionObjects *mdfso;
964 NSSCKMDFindObjects *rv;
968 return (NSSCKMDFindObjects *)NULL;
971 *pError = nssCKFWToken_verifyPointer(fwToken);
972 if( CKR_OK != *pError ) {
973 return (NSSCKMDFindObjects *)NULL;
976 if( (CK_ATTRIBUTE_PTR)NULL == pTemplate ) {
977 *pError = CKR_ARGUMENTS_BAD;
978 return (NSSCKMDFindObjects *)NULL;
980 #endif /* NSSDEBUG */
984 hash = nssCKFWToken_GetSessionObjectHash(fwToken);
986 *pError= CKR_GENERAL_ERROR;
987 return (NSSCKMDFindObjects *)NULL;
990 arena = NSSArena_Create();
992 *pError = CKR_HOST_MEMORY;
993 return (NSSCKMDFindObjects *)NULL;
996 mdfso = nss_ZNEW(arena, nssCKMDFindSessionObjects);
1001 rv = nss_ZNEW(arena, NSSCKMDFindObjects);
1006 mdfso->error = CKR_OK;
1007 mdfso->pTemplate = pTemplate;
1008 mdfso->ulCount = ulCount;
1011 nssCKFWHash_Iterate(hash, findfcn, mdfso);
1013 if( CKR_OK != mdfso->error ) {
1017 rv->etc = (void *)mdfso;
1018 rv->Final = nss_ckmdFindSessionObjects_Final;
1019 rv->Next = nss_ckmdFindSessionObjects_Next;
1022 if( (*pError = nss_ckmdFindSessionObjects_add_pointer(rv)) != CKR_OK ) {
1026 mdfso->arena = arena;
1032 NSSArena_Destroy(arena);
1034 if (*pError == CKR_OK) {
1035 *pError = CKR_HOST_MEMORY;
1041 nss_ckmdFindSessionObjects_Final
1043 NSSCKMDFindObjects *mdFindObjects,
1044 NSSCKFWFindObjects *fwFindObjects,
1045 NSSCKMDSession *mdSession,
1046 NSSCKFWSession *fwSession,
1047 NSSCKMDToken *mdToken,
1048 NSSCKFWToken *fwToken,
1049 NSSCKMDInstance *mdInstance,
1050 NSSCKFWInstance *fwInstance
1053 nssCKMDFindSessionObjects *mdfso;
1056 if( CKR_OK != nss_ckmdFindSessionObjects_verifyPointer(mdFindObjects) ) {
1059 #endif /* NSSDEBUG */
1061 mdfso = (nssCKMDFindSessionObjects *)mdFindObjects->etc;
1062 if (mdfso->arena) NSSArena_Destroy(mdfso->arena);
1065 (void)nss_ckmdFindSessionObjects_remove_pointer(mdFindObjects);
1071 static NSSCKMDObject *
1072 nss_ckmdFindSessionObjects_Next
1074 NSSCKMDFindObjects *mdFindObjects,
1075 NSSCKFWFindObjects *fwFindObjects,
1076 NSSCKMDSession *mdSession,
1077 NSSCKFWSession *fwSession,
1078 NSSCKMDToken *mdToken,
1079 NSSCKFWToken *fwToken,
1080 NSSCKMDInstance *mdInstance,
1081 NSSCKFWInstance *fwInstance,
1086 nssCKMDFindSessionObjects *mdfso;
1087 NSSCKMDObject *rv = (NSSCKMDObject *)NULL;
1090 if( CKR_OK != nss_ckmdFindSessionObjects_verifyPointer(mdFindObjects) ) {
1091 return (NSSCKMDObject *)NULL;
1093 #endif /* NSSDEBUG */
1095 mdfso = (nssCKMDFindSessionObjects *)mdFindObjects->etc;
1098 if( (struct nodeStr *)NULL == mdfso->list ) {
1100 return (NSSCKMDObject *)NULL;
1103 if( nssCKFWHash_Exists(mdfso->hash, mdfso->list->mdObject) ) {
1104 rv = mdfso->list->mdObject;
1107 mdfso->list = mdfso->list->next;