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: object.c,v $ $Revision: 1.15 $ $Date: 2007/12/12 00:41:37 $";
44 * This file implements the NSSCKFWObject type and methods.
54 * -- create/destroy --
55 * nssCKFWObject_Create
56 * nssCKFWObject_Finalize
57 * nssCKFWObject_Destroy
59 * -- public accessors --
60 * NSSCKFWObject_GetMDObject
61 * NSSCKFWObject_GetArena
62 * NSSCKFWObject_IsTokenObject
63 * NSSCKFWObject_GetAttributeCount
64 * NSSCKFWObject_GetAttributeTypes
65 * NSSCKFWObject_GetAttributeSize
66 * NSSCKFWObject_GetAttribute
67 * NSSCKFWObject_SetAttribute
68 * NSSCKFWObject_GetObjectSize
70 * -- implement public accessors --
71 * nssCKFWObject_GetMDObject
72 * nssCKFWObject_GetArena
74 * -- private accessors --
75 * nssCKFWObject_SetHandle
76 * nssCKFWObject_GetHandle
79 * nssCKFWObject_IsTokenObject
80 * nssCKFWObject_GetAttributeCount
81 * nssCKFWObject_GetAttributeTypes
82 * nssCKFWObject_GetAttributeSize
83 * nssCKFWObject_GetAttribute
84 * nssCKFWObject_SetAttribute
85 * nssCKFWObject_GetObjectSize
88 struct NSSCKFWObjectStr
{
89 NSSCKFWMutex
*mutex
; /* merely to serialise the MDObject calls */
91 NSSCKMDObject
*mdObject
;
92 NSSCKMDSession
*mdSession
;
93 NSSCKFWSession
*fwSession
;
94 NSSCKMDToken
*mdToken
;
95 NSSCKFWToken
*fwToken
;
96 NSSCKMDInstance
*mdInstance
;
97 NSSCKFWInstance
*fwInstance
;
98 CK_OBJECT_HANDLE hObject
;
103 * But first, the pointer-tracking stuff.
105 * NOTE: the pointer-tracking support in NSS/base currently relies
106 * upon NSPR's CallOnce support. That, however, relies upon NSPR's
107 * locking, which is tied into the runtime. We need a pointer-tracker
108 * implementation that uses the locks supplied through C_Initialize.
109 * That support, however, can be filled in later. So for now, I'll
110 * just do this routines as no-ops.
116 const NSSCKFWObject
*fwObject
123 object_remove_pointer
125 const NSSCKFWObject
*fwObject
132 nssCKFWObject_verifyPointer
134 const NSSCKFWObject
*fwObject
144 * nssCKFWObject_Create
147 NSS_IMPLEMENT NSSCKFWObject
*
151 NSSCKMDObject
*mdObject
,
152 NSSCKFWSession
*fwSession
,
153 NSSCKFWToken
*fwToken
,
154 NSSCKFWInstance
*fwInstance
,
158 NSSCKFWObject
*fwObject
;
159 nssCKFWHash
*mdObjectHash
;
162 if( (CK_RV
*)NULL
== pError
) {
163 return (NSSCKFWObject
*)NULL
;
166 if( PR_SUCCESS
!= nssArena_verifyPointer(arena
) ) {
167 *pError
= CKR_ARGUMENTS_BAD
;
168 return (NSSCKFWObject
*)NULL
;
170 #endif /* NSSDEBUG */
172 if( (NSSCKFWToken
*)NULL
== fwToken
) {
173 *pError
= CKR_ARGUMENTS_BAD
;
174 return (NSSCKFWObject
*)NULL
;
176 mdObjectHash
= nssCKFWToken_GetMDObjectHash(fwToken
);
177 if( (nssCKFWHash
*)NULL
== mdObjectHash
) {
178 *pError
= CKR_GENERAL_ERROR
;
179 return (NSSCKFWObject
*)NULL
;
182 if( nssCKFWHash_Exists(mdObjectHash
, mdObject
) ) {
183 fwObject
= nssCKFWHash_Lookup(mdObjectHash
, mdObject
);
187 fwObject
= nss_ZNEW(arena
, NSSCKFWObject
);
188 if( (NSSCKFWObject
*)NULL
== fwObject
) {
189 *pError
= CKR_HOST_MEMORY
;
190 return (NSSCKFWObject
*)NULL
;
193 fwObject
->arena
= arena
;
194 fwObject
->mdObject
= mdObject
;
195 fwObject
->fwSession
= fwSession
;
197 if( (NSSCKFWSession
*)NULL
!= fwSession
) {
198 fwObject
->mdSession
= nssCKFWSession_GetMDSession(fwSession
);
201 fwObject
->fwToken
= fwToken
;
202 fwObject
->mdToken
= nssCKFWToken_GetMDToken(fwToken
);
203 fwObject
->fwInstance
= fwInstance
;
204 fwObject
->mdInstance
= nssCKFWInstance_GetMDInstance(fwInstance
);
205 fwObject
->mutex
= nssCKFWInstance_CreateMutex(fwInstance
, arena
, pError
);
206 if( (NSSCKFWMutex
*)NULL
== fwObject
->mutex
) {
207 if( CKR_OK
== *pError
) {
208 *pError
= CKR_GENERAL_ERROR
;
210 return (NSSCKFWObject
*)NULL
;
213 *pError
= nssCKFWHash_Add(mdObjectHash
, mdObject
, fwObject
);
214 if( CKR_OK
!= *pError
) {
215 nss_ZFreeIf(fwObject
);
216 return (NSSCKFWObject
*)NULL
;
220 *pError
= object_add_pointer(fwObject
);
221 if( CKR_OK
!= *pError
) {
222 nssCKFWHash_Remove(mdObjectHash
, mdObject
);
223 nss_ZFreeIf(fwObject
);
224 return (NSSCKFWObject
*)NULL
;
233 * nssCKFWObject_Finalize
237 nssCKFWObject_Finalize
239 NSSCKFWObject
*fwObject
,
240 PRBool removeFromHash
243 nssCKFWHash
*mdObjectHash
;
246 if( CKR_OK
!= nssCKFWObject_verifyPointer(fwObject
) ) {
249 #endif /* NSSDEBUG */
251 (void)nssCKFWMutex_Destroy(fwObject
->mutex
);
253 if( (void *)NULL
!= (void *)fwObject
->mdObject
->Finalize
) {
254 fwObject
->mdObject
->Finalize(fwObject
->mdObject
, fwObject
,
255 fwObject
->mdSession
, fwObject
->fwSession
, fwObject
->mdToken
,
256 fwObject
->fwToken
, fwObject
->mdInstance
, fwObject
->fwInstance
);
259 if (removeFromHash
) {
260 mdObjectHash
= nssCKFWToken_GetMDObjectHash(fwObject
->fwToken
);
261 if( (nssCKFWHash
*)NULL
!= mdObjectHash
) {
262 nssCKFWHash_Remove(mdObjectHash
, fwObject
->mdObject
);
266 if (fwObject
->fwSession
) {
267 nssCKFWSession_DeregisterSessionObject(fwObject
->fwSession
, fwObject
);
269 nss_ZFreeIf(fwObject
);
272 (void)object_remove_pointer(fwObject
);
279 * nssCKFWObject_Destroy
283 nssCKFWObject_Destroy
285 NSSCKFWObject
*fwObject
288 nssCKFWHash
*mdObjectHash
;
291 if( CKR_OK
!= nssCKFWObject_verifyPointer(fwObject
) ) {
294 #endif /* NSSDEBUG */
296 (void)nssCKFWMutex_Destroy(fwObject
->mutex
);
298 if( (void *)NULL
!= (void *)fwObject
->mdObject
->Destroy
) {
299 fwObject
->mdObject
->Destroy(fwObject
->mdObject
, fwObject
,
300 fwObject
->mdSession
, fwObject
->fwSession
, fwObject
->mdToken
,
301 fwObject
->fwToken
, fwObject
->mdInstance
, fwObject
->fwInstance
);
304 mdObjectHash
= nssCKFWToken_GetMDObjectHash(fwObject
->fwToken
);
305 if( (nssCKFWHash
*)NULL
!= mdObjectHash
) {
306 nssCKFWHash_Remove(mdObjectHash
, fwObject
->mdObject
);
309 if (fwObject
->fwSession
) {
310 nssCKFWSession_DeregisterSessionObject(fwObject
->fwSession
, fwObject
);
312 nss_ZFreeIf(fwObject
);
315 (void)object_remove_pointer(fwObject
);
322 * nssCKFWObject_GetMDObject
325 NSS_IMPLEMENT NSSCKMDObject
*
326 nssCKFWObject_GetMDObject
328 NSSCKFWObject
*fwObject
332 if( CKR_OK
!= nssCKFWObject_verifyPointer(fwObject
) ) {
333 return (NSSCKMDObject
*)NULL
;
335 #endif /* NSSDEBUG */
337 return fwObject
->mdObject
;
341 * nssCKFWObject_GetArena
344 NSS_IMPLEMENT NSSArena
*
345 nssCKFWObject_GetArena
347 NSSCKFWObject
*fwObject
,
352 if( (CK_RV
*)NULL
== pError
) {
353 return (NSSArena
*)NULL
;
356 *pError
= nssCKFWObject_verifyPointer(fwObject
);
357 if( CKR_OK
!= *pError
) {
358 return (NSSArena
*)NULL
;
360 #endif /* NSSDEBUG */
362 return fwObject
->arena
;
366 * nssCKFWObject_SetHandle
370 nssCKFWObject_SetHandle
372 NSSCKFWObject
*fwObject
,
373 CK_OBJECT_HANDLE hObject
377 CK_RV error
= CKR_OK
;
378 #endif /* NSSDEBUG */
381 error
= nssCKFWObject_verifyPointer(fwObject
);
382 if( CKR_OK
!= error
) {
385 #endif /* NSSDEBUG */
387 if( (CK_OBJECT_HANDLE
)0 != fwObject
->hObject
) {
388 return CKR_GENERAL_ERROR
;
391 fwObject
->hObject
= hObject
;
397 * nssCKFWObject_GetHandle
400 NSS_IMPLEMENT CK_OBJECT_HANDLE
401 nssCKFWObject_GetHandle
403 NSSCKFWObject
*fwObject
407 if( CKR_OK
!= nssCKFWObject_verifyPointer(fwObject
) ) {
408 return (CK_OBJECT_HANDLE
)0;
410 #endif /* NSSDEBUG */
412 return fwObject
->hObject
;
416 * nssCKFWObject_IsTokenObject
419 NSS_IMPLEMENT CK_BBOOL
420 nssCKFWObject_IsTokenObject
422 NSSCKFWObject
*fwObject
425 CK_BBOOL b
= CK_FALSE
;
428 if( CKR_OK
!= nssCKFWObject_verifyPointer(fwObject
) ) {
431 #endif /* NSSDEBUG */
433 if( (void *)NULL
== (void *)fwObject
->mdObject
->IsTokenObject
) {
438 item
.data
= (void *)&b
;
439 item
.size
= sizeof(b
);
441 pItem
= nssCKFWObject_GetAttribute(fwObject
, CKA_TOKEN
, &item
,
442 (NSSArena
*)NULL
, &rv
);
443 if( (NSSItem
*)NULL
== pItem
) {
444 /* Error of some type */
452 b
= fwObject
->mdObject
->IsTokenObject(fwObject
->mdObject
, fwObject
,
453 fwObject
->mdSession
, fwObject
->fwSession
, fwObject
->mdToken
,
454 fwObject
->fwToken
, fwObject
->mdInstance
, fwObject
->fwInstance
);
461 * nssCKFWObject_GetAttributeCount
464 NSS_IMPLEMENT CK_ULONG
465 nssCKFWObject_GetAttributeCount
467 NSSCKFWObject
*fwObject
,
474 if( (CK_RV
*)NULL
== pError
) {
478 *pError
= nssCKFWObject_verifyPointer(fwObject
);
479 if( CKR_OK
!= *pError
) {
482 #endif /* NSSDEBUG */
484 if( (void *)NULL
== (void *)fwObject
->mdObject
->GetAttributeCount
) {
485 *pError
= CKR_GENERAL_ERROR
;
489 *pError
= nssCKFWMutex_Lock(fwObject
->mutex
);
490 if( CKR_OK
!= *pError
) {
494 rv
= fwObject
->mdObject
->GetAttributeCount(fwObject
->mdObject
, fwObject
,
495 fwObject
->mdSession
, fwObject
->fwSession
, fwObject
->mdToken
,
496 fwObject
->fwToken
, fwObject
->mdInstance
, fwObject
->fwInstance
,
499 (void)nssCKFWMutex_Unlock(fwObject
->mutex
);
504 * nssCKFWObject_GetAttributeTypes
508 nssCKFWObject_GetAttributeTypes
510 NSSCKFWObject
*fwObject
,
511 CK_ATTRIBUTE_TYPE_PTR typeArray
,
515 CK_RV error
= CKR_OK
;
518 error
= nssCKFWObject_verifyPointer(fwObject
);
519 if( CKR_OK
!= error
) {
523 if( (CK_ATTRIBUTE_TYPE_PTR
)NULL
== typeArray
) {
524 return CKR_ARGUMENTS_BAD
;
526 #endif /* NSSDEBUG */
528 if( (void *)NULL
== (void *)fwObject
->mdObject
->GetAttributeTypes
) {
529 return CKR_GENERAL_ERROR
;
532 error
= nssCKFWMutex_Lock(fwObject
->mutex
);
533 if( CKR_OK
!= error
) {
537 error
= fwObject
->mdObject
->GetAttributeTypes(fwObject
->mdObject
, fwObject
,
538 fwObject
->mdSession
, fwObject
->fwSession
, fwObject
->mdToken
,
539 fwObject
->fwToken
, fwObject
->mdInstance
, fwObject
->fwInstance
,
542 (void)nssCKFWMutex_Unlock(fwObject
->mutex
);
547 * nssCKFWObject_GetAttributeSize
550 NSS_IMPLEMENT CK_ULONG
551 nssCKFWObject_GetAttributeSize
553 NSSCKFWObject
*fwObject
,
554 CK_ATTRIBUTE_TYPE attribute
,
561 if( (CK_RV
*)NULL
== pError
) {
565 *pError
= nssCKFWObject_verifyPointer(fwObject
);
566 if( CKR_OK
!= *pError
) {
569 #endif /* NSSDEBUG */
571 if( (void *)NULL
== (void *)fwObject
->mdObject
->GetAttributeSize
) {
572 *pError
= CKR_GENERAL_ERROR
;
576 *pError
= nssCKFWMutex_Lock(fwObject
->mutex
);
577 if( CKR_OK
!= *pError
) {
581 rv
= fwObject
->mdObject
->GetAttributeSize(fwObject
->mdObject
, fwObject
,
582 fwObject
->mdSession
, fwObject
->fwSession
, fwObject
->mdToken
,
583 fwObject
->fwToken
, fwObject
->mdInstance
, fwObject
->fwInstance
,
586 (void)nssCKFWMutex_Unlock(fwObject
->mutex
);
591 * nssCKFWObject_GetAttribute
593 * Usual NSS allocation rules:
594 * If itemOpt is not NULL, it will be returned; otherwise an NSSItem
595 * will be allocated. If itemOpt is not NULL but itemOpt->data is,
596 * the buffer will be allocated; otherwise, the buffer will be used.
597 * Any allocations will come from the optional arena, if one is
600 NSS_IMPLEMENT NSSItem
*
601 nssCKFWObject_GetAttribute
603 NSSCKFWObject
*fwObject
,
604 CK_ATTRIBUTE_TYPE attribute
,
610 NSSItem
*rv
= (NSSItem
*)NULL
;
614 if( (CK_RV
*)NULL
== pError
) {
615 return (NSSItem
*)NULL
;
618 *pError
= nssCKFWObject_verifyPointer(fwObject
);
619 if( CKR_OK
!= *pError
) {
620 return (NSSItem
*)NULL
;
622 #endif /* NSSDEBUG */
624 if( (void *)NULL
== (void *)fwObject
->mdObject
->GetAttribute
) {
625 *pError
= CKR_GENERAL_ERROR
;
626 return (NSSItem
*)NULL
;
629 *pError
= nssCKFWMutex_Lock(fwObject
->mutex
);
630 if( CKR_OK
!= *pError
) {
631 return (NSSItem
*)NULL
;
634 mdItem
= fwObject
->mdObject
->GetAttribute(fwObject
->mdObject
, fwObject
,
635 fwObject
->mdSession
, fwObject
->fwSession
, fwObject
->mdToken
,
636 fwObject
->fwToken
, fwObject
->mdInstance
, fwObject
->fwInstance
,
639 if( (NSSItem
*)NULL
== mdItem
.item
) {
640 if( CKR_OK
== *pError
) {
641 *pError
= CKR_GENERAL_ERROR
;
647 if( (NSSItem
*)NULL
== itemOpt
) {
648 rv
= nss_ZNEW(arenaOpt
, NSSItem
);
649 if( (NSSItem
*)NULL
== rv
) {
650 *pError
= CKR_HOST_MEMORY
;
657 if( (void *)NULL
== rv
->data
) {
658 rv
->size
= mdItem
.item
->size
;
659 rv
->data
= nss_ZAlloc(arenaOpt
, rv
->size
);
660 if( (void *)NULL
== rv
->data
) {
661 *pError
= CKR_HOST_MEMORY
;
662 if( (NSSItem
*)NULL
== itemOpt
) {
665 rv
= (NSSItem
*)NULL
;
669 if( rv
->size
>= mdItem
.item
->size
) {
670 rv
->size
= mdItem
.item
->size
;
672 *pError
= CKR_BUFFER_TOO_SMALL
;
673 /* Should we set rv->size to mdItem->size? */
674 /* rv can't have been allocated */
675 rv
= (NSSItem
*)NULL
;
680 (void)nsslibc_memcpy(rv
->data
, mdItem
.item
->data
, rv
->size
);
682 if (PR_TRUE
== mdItem
.needsFreeing
) {
683 PR_ASSERT(fwObject
->mdObject
->FreeAttribute
);
684 if (fwObject
->mdObject
->FreeAttribute
) {
685 *pError
= fwObject
->mdObject
->FreeAttribute(&mdItem
);
690 (void)nssCKFWMutex_Unlock(fwObject
->mutex
);
695 * nssCKFWObject_SetAttribute
699 nssCKFWObject_SetAttribute
701 NSSCKFWObject
*fwObject
,
702 NSSCKFWSession
*fwSession
,
703 CK_ATTRIBUTE_TYPE attribute
,
707 CK_RV error
= CKR_OK
;
710 error
= nssCKFWObject_verifyPointer(fwObject
);
711 if( CKR_OK
!= error
) {
714 #endif /* NSSDEBUG */
716 if( CKA_TOKEN
== attribute
) {
718 * We're changing from a session object to a token object or
723 NSSCKFWObject
*newFwObject
;
727 a
.pValue
= value
->data
;
728 a
.ulValueLen
= value
->size
;
730 newFwObject
= nssCKFWSession_CopyObject(fwSession
, fwObject
,
732 if( (NSSCKFWObject
*)NULL
== newFwObject
) {
733 if( CKR_OK
== error
) {
734 error
= CKR_GENERAL_ERROR
;
740 * Actually, I bet the locking is worse than this.. this part of
741 * the code could probably use some scrutiny and reworking.
743 error
= nssCKFWMutex_Lock(fwObject
->mutex
);
744 if( CKR_OK
!= error
) {
745 nssCKFWObject_Destroy(newFwObject
);
749 error
= nssCKFWMutex_Lock(newFwObject
->mutex
);
750 if( CKR_OK
!= error
) {
751 nssCKFWMutex_Unlock(fwObject
->mutex
);
752 nssCKFWObject_Destroy(newFwObject
);
757 * Now, we have our new object, but it has a new fwObject pointer,
758 * while we have to keep the existing one. So quick swap the contents.
761 *fwObject
= *newFwObject
;
764 /* But keep the mutexes the same */
765 swab
.mutex
= fwObject
->mutex
;
766 fwObject
->mutex
= newFwObject
->mutex
;
767 newFwObject
->mutex
= swab
.mutex
;
769 (void)nssCKFWMutex_Unlock(newFwObject
->mutex
);
770 (void)nssCKFWMutex_Unlock(fwObject
->mutex
);
773 * Either remove or add this to the list of session objects
776 if( CK_FALSE
== *(CK_BBOOL
*)value
->data
) {
778 * New one is a session object, except since we "stole" the fwObject, it's
779 * not in the list. Add it.
781 nssCKFWSession_RegisterSessionObject(fwSession
, fwObject
);
784 * New one is a token object, except since we "stole" the fwObject, it's
785 * in the list. Remove it.
787 if (fwObject
->fwSession
) {
788 nssCKFWSession_DeregisterSessionObject(fwObject
->fwSession
, fwObject
);
793 * Now delete the old object. Remember the names have changed.
795 nssCKFWObject_Destroy(newFwObject
);
800 * An "ordinary" change.
802 if( (void *)NULL
== (void *)fwObject
->mdObject
->SetAttribute
) {
803 /* We could fake it with copying, like above.. later */
804 return CKR_ATTRIBUTE_READ_ONLY
;
807 error
= nssCKFWMutex_Lock(fwObject
->mutex
);
808 if( CKR_OK
!= error
) {
812 error
= fwObject
->mdObject
->SetAttribute(fwObject
->mdObject
, fwObject
,
813 fwObject
->mdSession
, fwObject
->fwSession
, fwObject
->mdToken
,
814 fwObject
->fwToken
, fwObject
->mdInstance
, fwObject
->fwInstance
,
817 (void)nssCKFWMutex_Unlock(fwObject
->mutex
);
824 * nssCKFWObject_GetObjectSize
827 NSS_IMPLEMENT CK_ULONG
828 nssCKFWObject_GetObjectSize
830 NSSCKFWObject
*fwObject
,
837 if( (CK_RV
*)NULL
== pError
) {
841 *pError
= nssCKFWObject_verifyPointer(fwObject
);
842 if( CKR_OK
!= *pError
) {
845 #endif /* NSSDEBUG */
847 if( (void *)NULL
== (void *)fwObject
->mdObject
->GetObjectSize
) {
848 *pError
= CKR_INFORMATION_SENSITIVE
;
852 *pError
= nssCKFWMutex_Lock(fwObject
->mutex
);
853 if( CKR_OK
!= *pError
) {
857 rv
= fwObject
->mdObject
->GetObjectSize(fwObject
->mdObject
, fwObject
,
858 fwObject
->mdSession
, fwObject
->fwSession
, fwObject
->mdToken
,
859 fwObject
->fwToken
, fwObject
->mdInstance
, fwObject
->fwInstance
,
862 (void)nssCKFWMutex_Unlock(fwObject
->mutex
);
867 * NSSCKFWObject_GetMDObject
870 NSS_IMPLEMENT NSSCKMDObject
*
871 NSSCKFWObject_GetMDObject
873 NSSCKFWObject
*fwObject
877 if( CKR_OK
!= nssCKFWObject_verifyPointer(fwObject
) ) {
878 return (NSSCKMDObject
*)NULL
;
882 return nssCKFWObject_GetMDObject(fwObject
);
886 * NSSCKFWObject_GetArena
889 NSS_IMPLEMENT NSSArena
*
890 NSSCKFWObject_GetArena
892 NSSCKFWObject
*fwObject
,
897 if( (CK_RV
*)NULL
== pError
) {
898 return (NSSArena
*)NULL
;
901 *pError
= nssCKFWObject_verifyPointer(fwObject
);
902 if( CKR_OK
!= *pError
) {
903 return (NSSArena
*)NULL
;
907 return nssCKFWObject_GetArena(fwObject
, pError
);
911 * NSSCKFWObject_IsTokenObject
914 NSS_IMPLEMENT CK_BBOOL
915 NSSCKFWObject_IsTokenObject
917 NSSCKFWObject
*fwObject
921 if( CKR_OK
!= nssCKFWObject_verifyPointer(fwObject
) ) {
926 return nssCKFWObject_IsTokenObject(fwObject
);
930 * NSSCKFWObject_GetAttributeCount
933 NSS_IMPLEMENT CK_ULONG
934 NSSCKFWObject_GetAttributeCount
936 NSSCKFWObject
*fwObject
,
941 if( (CK_RV
*)NULL
== pError
) {
945 *pError
= nssCKFWObject_verifyPointer(fwObject
);
946 if( CKR_OK
!= *pError
) {
951 return nssCKFWObject_GetAttributeCount(fwObject
, pError
);
955 * NSSCKFWObject_GetAttributeTypes
959 NSSCKFWObject_GetAttributeTypes
961 NSSCKFWObject
*fwObject
,
962 CK_ATTRIBUTE_TYPE_PTR typeArray
,
967 CK_RV error
= CKR_OK
;
969 error
= nssCKFWObject_verifyPointer(fwObject
);
970 if( CKR_OK
!= error
) {
974 if( (CK_ATTRIBUTE_TYPE_PTR
)NULL
== typeArray
) {
975 return CKR_ARGUMENTS_BAD
;
979 return nssCKFWObject_GetAttributeTypes(fwObject
, typeArray
, ulCount
);
983 * NSSCKFWObject_GetAttributeSize
986 NSS_IMPLEMENT CK_ULONG
987 NSSCKFWObject_GetAttributeSize
989 NSSCKFWObject
*fwObject
,
990 CK_ATTRIBUTE_TYPE attribute
,
995 if( (CK_RV
*)NULL
== pError
) {
999 *pError
= nssCKFWObject_verifyPointer(fwObject
);
1000 if( CKR_OK
!= *pError
) {
1005 return nssCKFWObject_GetAttributeSize(fwObject
, attribute
, pError
);
1009 * NSSCKFWObject_GetAttribute
1012 NSS_IMPLEMENT NSSItem
*
1013 NSSCKFWObject_GetAttribute
1015 NSSCKFWObject
*fwObject
,
1016 CK_ATTRIBUTE_TYPE attribute
,
1023 if( (CK_RV
*)NULL
== pError
) {
1024 return (NSSItem
*)NULL
;
1027 *pError
= nssCKFWObject_verifyPointer(fwObject
);
1028 if( CKR_OK
!= *pError
) {
1029 return (NSSItem
*)NULL
;
1033 return nssCKFWObject_GetAttribute(fwObject
, attribute
, itemOpt
, arenaOpt
, pError
);
1037 * NSSCKFWObject_GetObjectSize
1040 NSS_IMPLEMENT CK_ULONG
1041 NSSCKFWObject_GetObjectSize
1043 NSSCKFWObject
*fwObject
,
1048 if( (CK_RV
*)NULL
== pError
) {
1052 *pError
= nssCKFWObject_verifyPointer(fwObject
);
1053 if( CKR_OK
!= *pError
) {
1058 return nssCKFWObject_GetObjectSize(fwObject
, pError
);