static NSSCertificate * get_best_temp_or_perm(NSSCertificate *ct, NSSCertificate *cp) { NSSUsage usage; NSSCertificate *arr[3]; if (!ct) { return nssCertificate_AddRef(cp); } else if (!cp) { return nssCertificate_AddRef(ct); } arr[0] = ct; arr[1] = cp; arr[2] = NULL; usage.anyUsage = PR_TRUE; return nssCertificateArray_FindBestCertificate(arr, NULL, &usage, NULL); }
/* Caller holds store->lock */ static NSSCertificate * nssCertStore_FindCertByIssuerAndSerialNumberLocked ( nssCertificateStore *store, NSSDER *issuer, NSSDER *serial ) { certificate_hash_entry *entry; NSSCertificate *rvCert = NULL; NSSCertificate index; index.issuer = *issuer; index.serial = *serial; entry = (certificate_hash_entry *) nssHash_Lookup(store->issuer_and_serial, &index); if (entry) { rvCert = nssCertificate_AddRef(entry->cert); } return rvCert; }
NSS_IMPLEMENT NSSCertificate * nssCertificateStore_FindOrAdd ( nssCertificateStore *store, NSSCertificate *c ) { PRStatus nssrv; NSSCertificate *rvCert = NULL; PZ_Lock(store->lock); rvCert = nssCertStore_FindCertByIssuerAndSerialNumberLocked( store, &c->issuer, &c->serial); if (!rvCert) { nssrv = nssCertificateStore_AddLocked(store, c); if (PR_SUCCESS == nssrv) { rvCert = nssCertificate_AddRef(c); } } PZ_Unlock(store->lock); return rvCert; }
static PRStatus add_ref_callback(NSSCertificate *c, void *a) { nssCertificate_AddRef(c); return PR_SUCCESS; }
static void cert_iter(const void *k, void *v, void *a) { nssList *certList = (nssList *)a; NSSCertificate *c = (NSSCertificate *)k; nssList_Add(certList, nssCertificate_AddRef(c)); }