From c6c1bc65dc134c42cf68194bca94466db0b825f0 Mon Sep 17 00:00:00 2001 From: "ian.mcgreer%sun.com" Date: Mon, 4 Mar 2002 17:13:54 +0000 Subject: [PATCH] bug 125808, update cert token instances when caching smart card certs that are already cached git-svn-id: svn://10.0.0.236/trunk@115724 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/security/nss/lib/dev/dev.h | 14 +++++++++++++- mozilla/security/nss/lib/dev/devobject.c | 17 ++++++++++++++++- mozilla/security/nss/lib/pki/pki3hack.c | 13 ++++++++++++- 3 files changed, 41 insertions(+), 3 deletions(-) diff --git a/mozilla/security/nss/lib/dev/dev.h b/mozilla/security/nss/lib/dev/dev.h index 2198e0cf141..ee064a88770 100644 --- a/mozilla/security/nss/lib/dev/dev.h +++ b/mozilla/security/nss/lib/dev/dev.h @@ -35,7 +35,7 @@ #define DEV_H #ifdef DEBUG -static const char DEV_CVS_ID[] = "@(#) $RCSfile: dev.h,v $ $Revision: 1.17 $ $Date: 2002-02-04 21:57:03 $ $Name: not supported by cvs2svn $"; +static const char DEV_CVS_ID[] = "@(#) $RCSfile: dev.h,v $ $Revision: 1.18 $ $Date: 2002-03-04 17:13:52 $ $Name: not supported by cvs2svn $"; #endif /* DEBUG */ #ifndef DEVT_H @@ -450,6 +450,18 @@ NSSAlgorithmAndParameters_CreateMD5Digest NSSArena *arenaOpt ); +#ifdef NSS_3_4_CODE +/* exposing this for the smart card cache code */ +NSS_IMPLEMENT nssCryptokiInstance * +nssCryptokiInstance_Create +( + NSSArena *arena, + NSSToken *t, + CK_OBJECT_HANDLE h, + PRBool isTokenObject +); +#endif + PR_END_EXTERN_C #endif /* DEV_H */ diff --git a/mozilla/security/nss/lib/dev/devobject.c b/mozilla/security/nss/lib/dev/devobject.c index 67b415b83d2..d2f4f9e7e7c 100644 --- a/mozilla/security/nss/lib/dev/devobject.c +++ b/mozilla/security/nss/lib/dev/devobject.c @@ -32,7 +32,7 @@ */ #ifdef DEBUG -static const char CVS_ID[] = "@(#) $RCSfile: devobject.c,v $ $Revision: 1.18 $ $Date: 2002-02-15 17:37:58 $ $Name: not supported by cvs2svn $"; +static const char CVS_ID[] = "@(#) $RCSfile: devobject.c,v $ $Revision: 1.19 $ $Date: 2002-03-04 17:13:52 $ $Name: not supported by cvs2svn $"; #endif /* DEBUG */ #ifndef DEV_H @@ -302,6 +302,21 @@ create_cryptoki_instance return instance; } +#ifdef NSS_3_4_CODE +/* exposing this for the smart card cache code */ +NSS_IMPLEMENT nssCryptokiInstance * +nssCryptokiInstance_Create +( + NSSArena *arena, + NSSToken *t, + CK_OBJECT_HANDLE h, + PRBool isTokenObject +) +{ + return create_cryptoki_instance(arena, t, h, isTokenObject); +} +#endif + static NSSCertificateType nss_cert_type_from_ck_attrib(CK_ATTRIBUTE_PTR attrib) { diff --git a/mozilla/security/nss/lib/pki/pki3hack.c b/mozilla/security/nss/lib/pki/pki3hack.c index 8c752060cae..140c836b4ba 100644 --- a/mozilla/security/nss/lib/pki/pki3hack.c +++ b/mozilla/security/nss/lib/pki/pki3hack.c @@ -32,7 +32,7 @@ */ #ifdef DEBUG -static const char CVS_ID[] = "@(#) $RCSfile: pki3hack.c,v $ $Revision: 1.37 $ $Date: 2002-03-01 21:43:55 $ $Name: not supported by cvs2svn $"; +static const char CVS_ID[] = "@(#) $RCSfile: pki3hack.c,v $ $Revision: 1.38 $ $Date: 2002-03-04 17:13:54 $ $Name: not supported by cvs2svn $"; #endif /* DEBUG */ /* @@ -120,6 +120,17 @@ cache_token_cert(NSSCertificate *c, void *arg) nssTrustDomain_AddCertsToCache(td, &c, 1); if (cp == c) { NSSCertificate_Destroy(cp); + } else { + /* The cert was already in the cache, from another token. Add this + * token's instance to the cert. + */ + nssCryptokiInstance *tokenInstance, *instance; + nssList_GetArray(cp->object.instanceList, (void **)&tokenInstance, 1); + instance = nssCryptokiInstance_Create(c->object.arena, token, + tokenInstance->handle, PR_TRUE); + nssList_Add(c->object.instanceList, instance); + nssListIterator_Destroy(c->object.instances); + c->object.instances = nssList_CreateIterator(c->object.instanceList); } /* This list reference persists with the token */ nssList_Add(token->certList, nssCertificate_AddRef(c));