NSS_CK_SET_ATTRIBUTE_VAR(trust_template, 0, saTrust); NSS_CK_SET_ATTRIBUTE_VAR(trust_template, 1, epTrust); NSS_CK_SET_ATTRIBUTE_VAR(trust_template, 2, csTrust);
nssCertificate_SetCertTrust(  NSSCertificate *c,  nssSession *session){    PRStatus nssrv;    CK_TRUST saTrust, epTrust, csTrust;    CK_ULONG tobj_size, trust_size;    CK_OBJECT_CLASS tobjc = CKO_NETSCAPE_TRUST;    CK_OBJECT_HANDLE tobjID;    CK_ATTRIBUTE tobj_template[] = {	{ CKA_CLASS,          &tobjc, sizeof(CK_OBJECT_CLASS) },	{ CKA_CERT_SHA1_HASH, NULL,   0                       }    };    CK_ATTRIBUTE trust_template[] = {	{ CKA_TRUST_SERVER_AUTH,      &saTrust, sizeof(CK_TRUST) },	{ CKA_TRUST_EMAIL_PROTECTION, &epTrust, sizeof(CK_TRUST) },	{ CKA_TRUST_CODE_SIGNING,     &csTrust, sizeof(CK_TRUST) }    };    unsigned char sha1_hash[SHA1_LENGTH];    tobj_size = sizeof(tobj_template) / sizeof(tobj_template[0]);    trust_size = sizeof(trust_template) / sizeof(trust_template[0]);    /* First, use the SHA-1 hash of the cert to locate the trust object */    /* XXX get rid of this PK11_ call! */    PK11_HashBuf(SEC_OID_SHA1, sha1_hash, c->encoding.data, c->encoding.size);    tobj_template[1].pValue = (void *)sha1_hash;    tobj_template[1].ulValueLen = SHA1_LENGTH;    tobjID = nssToken_FindObjectByTemplate(c->token, session,                                           tobj_template, tobj_size);    if (tobjID == CK_INVALID_KEY) {	return PR_FAILURE;    }    /* Then use the trust object to find the trust settings */    nssrv = nssCKObject_GetAttributes(tobjID,                                      trust_template, trust_size,                                      NULL, session, c->slot);    c->trust.serverAuth = saTrust;    c->trust.emailProtection = epTrust;    c->trust.codeSigning = csTrust;    return PR_SUCCESS;}