This commit is contained in:
ian.mcgreer%sun.com 2001-10-11 18:40:34 +00:00
Родитель 7fe8a0eecb
Коммит a1f9c34e10
6 изменённых файлов: 56 добавлений и 33 удалений

Просмотреть файл

@ -32,7 +32,7 @@
*/
#ifdef DEBUG
static const char CVS_ID[] = "@(#) $RCSfile: ckhelper.c,v $ $Revision: 1.6 $ $Date: 2001-10-11 17:05:08 $ $Name: $";
static const char CVS_ID[] = "@(#) $RCSfile: ckhelper.c,v $ $Revision: 1.7 $ $Date: 2001-10-11 18:40:31 $ $Name: $";
#endif /* DEBUG */
#ifndef PKIT_H
@ -60,23 +60,23 @@ static const char CVS_ID[] = "@(#) $RCSfile: ckhelper.c,v $ $Revision: 1.6 $ $Da
#endif /* BASE_H */
static const CK_BBOOL s_true = CK_TRUE;
NSS_IMPLEMENT_DATA /* const */ NSSItem
NSS_IMPLEMENT_DATA const NSSItem
g_ck_true = { (CK_VOID_PTR)&s_true, sizeof(s_true) };
static const CK_BBOOL s_false = CK_FALSE;
NSS_IMPLEMENT_DATA /* const */ NSSItem
NSS_IMPLEMENT_DATA const NSSItem
g_ck_false = { (CK_VOID_PTR)&s_false, sizeof(s_false) };
static const CK_OBJECT_CLASS s_class_cert = CKO_CERTIFICATE;
NSS_IMPLEMENT_DATA /* const */ NSSItem
NSS_IMPLEMENT_DATA const NSSItem
g_ck_class_cert = { (CK_VOID_PTR)&s_class_cert, sizeof(s_class_cert) };
static const CK_OBJECT_CLASS s_class_pubkey = CKO_PUBLIC_KEY;
NSS_IMPLEMENT_DATA /* const */ NSSItem
NSS_IMPLEMENT_DATA const NSSItem
g_ck_class_pubkey = { (CK_VOID_PTR)&s_class_pubkey, sizeof(s_class_pubkey) };
static const CK_OBJECT_CLASS s_class_privkey = CKO_PRIVATE_KEY;
NSS_IMPLEMENT_DATA /* const */ NSSItem
NSS_IMPLEMENT_DATA const NSSItem
g_ck_class_privkey = { (CK_VOID_PTR)&s_class_privkey, sizeof(s_class_privkey) };
NSS_IMPLEMENT PRStatus
@ -193,8 +193,10 @@ nssCKObject_IsAttributeTrue
)
{
CK_BBOOL bool;
CK_ATTRIBUTE attr = { attribute, (CK_VOID_PTR)&bool, sizeof(bool) };
CK_ATTRIBUTE attr = { 0, NULL, 0 };
CK_RV ckrv;
attr.type = attribute;
NSS_CK_SET_ATTRIBUTE_VAR(&attr, 0, bool);
nssSession_EnterMonitor(session);
ckrv = CKAPI(slot)->C_GetAttributeValue(session->handle, object, &attr, 1);
nssSession_ExitMonitor(session);

Просмотреть файл

@ -41,7 +41,7 @@
#define CKHELPER_H
#ifdef DEBUG
static const char CKHELPER_CVS_ID[] = "@(#) $RCSfile: ckhelper.h,v $ $Revision: 1.6 $ $Date: 2001-10-11 17:05:08 $ $Name: $";
static const char CKHELPER_CVS_ID[] = "@(#) $RCSfile: ckhelper.h,v $ $Revision: 1.7 $ $Date: 2001-10-11 18:40:31 $ $Name: $";
#endif /* DEBUG */
#ifdef NSS_3_4_CODE
@ -63,13 +63,21 @@ PR_BEGIN_EXTERN_C
*/
/* Boolean values */
NSS_EXTERN_DATA /* const */ NSSItem g_ck_true;
NSS_EXTERN_DATA /* const */ NSSItem g_ck_false;
NSS_EXTERN_DATA const NSSItem g_ck_true;
NSS_EXTERN_DATA const NSSItem g_ck_false;
/* Object classes */
NSS_EXTERN_DATA /* const */ NSSItem g_ck_class_cert;
NSS_EXTERN_DATA /* const */ NSSItem g_ck_class_pubkey;
NSS_EXTERN_DATA /* const */ NSSItem g_ck_class_privkey;
NSS_EXTERN_DATA const NSSItem g_ck_class_cert;
NSS_EXTERN_DATA const NSSItem g_ck_class_pubkey;
NSS_EXTERN_DATA const NSSItem g_ck_class_privkey;
#define NSS_CK_SET_ATTRIBUTE_VAR(cktemplate, index, var) \
(cktemplate)[index].pValue = (CK_VOID_PTR)&var; \
(cktemplate)[index].ulValueLen = (CK_ULONG)sizeof(var)
#define NSS_CK_SET_ATTRIBUTE_ITEM(cktemplate, index, item) \
(cktemplate)[index].pValue = (CK_VOID_PTR)(item)->data; \
(cktemplate)[index].ulValueLen = (CK_ULONG)(item)->size;
/* NSS_CK_ATTRIBUTE_TO_ITEM(attrib, item)
*

Просмотреть файл

@ -32,7 +32,7 @@
*/
#ifdef DEBUG
static const char CVS_ID[] = "@(#) $RCSfile: token.c,v $ $Revision: 1.8 $ $Date: 2001-10-11 16:33:38 $ $Name: $";
static const char CVS_ID[] = "@(#) $RCSfile: token.c,v $ $Revision: 1.9 $ $Date: 2001-10-11 18:40:31 $ $Name: $";
#endif /* DEBUG */
#ifndef DEV_H
@ -451,9 +451,10 @@ nssToken_TraverseCertificates
PRStatus nssrv;
/* this is really traversal - the template is all certs */
CK_ATTRIBUTE cert_template[] = {
{ CKA_CLASS, g_ck_class_cert.data, g_ck_class_cert.size }
{ CKA_CLASS, NULL, 0 }
};
CK_ULONG ctsize = sizeof(cert_template) / sizeof(cert_template[0]);
NSS_CK_SET_ATTRIBUTE_ITEM(cert_template, 0, &g_ck_class_cert);
nssrv = nssToken_FindCertificatesByTemplate(tok, sessionOpt,
cert_template, ctsize,
callback, arg);

Просмотреть файл

@ -32,7 +32,7 @@
*/
#ifdef DEBUG
static const char CVS_ID[] = "@(#) $RCSfile: certificate.c,v $ $Revision: 1.5 $ $Date: 2001-10-11 16:34:44 $ $Name: $";
static const char CVS_ID[] = "@(#) $RCSfile: certificate.c,v $ $Revision: 1.6 $ $Date: 2001-10-11 18:40:33 $ $Name: $";
#endif /* DEBUG */
#ifndef NSSPKI_H
@ -69,7 +69,9 @@ static const char CVS_ID[] = "@(#) $RCSfile: certificate.c,v $ $Revision: 1.5 $
/* Hm, sadly, I'm using PK11_HashBuf... Need to get crypto context going to
* get rid of that
*/
#ifndef NSS_3_4_CODE
#define NSS_3_4_CODE
#endif /* NSS_3_4_CODE */
#include "pk11func.h"
#include "hasht.h"
@ -150,7 +152,6 @@ nss_cert_type_from_ck_attrib(CK_ATTRIBUTE_PTR attrib)
default:
return NSSCertificateType_Unknown;
}
return NSSCertificateType_Unknown;
}
static PRStatus
@ -166,17 +167,18 @@ nssCertificate_SetCertTrust
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 }
{ CKA_CLASS, NULL, 0 },
{ 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) }
{ CKA_TRUST_SERVER_AUTH, NULL, 0 },
{ CKA_TRUST_EMAIL_PROTECTION, NULL, 0 },
{ CKA_TRUST_CODE_SIGNING, NULL, 0 }
};
unsigned char sha1_hash[SHA1_LENGTH];
tobj_size = sizeof(tobj_template) / sizeof(tobj_template[0]);
trust_size = sizeof(trust_template) / sizeof(trust_template[0]);
NSS_CK_SET_ATTRIBUTE_VAR(tobj_template, 0, tobjc);
/* 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);
@ -188,6 +190,9 @@ nssCertificate_SetCertTrust
return PR_FAILURE;
}
/* Then use the trust object to find the trust settings */
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);
nssrv = nssCKObject_GetAttributes(tobjID,
trust_template, trust_size,
NULL, session, c->slot);
@ -563,11 +568,12 @@ NSSCertificate_GetPublicKey
{
PRStatus nssrv;
CK_ATTRIBUTE pubktemplate[] = {
{ CKA_CLASS, g_ck_class_pubkey.data, g_ck_class_pubkey.size },
{ CKA_ID, NULL, 0 },
{ CKA_SUBJECT, NULL, 0 }
{ CKA_CLASS, NULL, 0 },
{ CKA_ID, NULL, 0 },
{ CKA_SUBJECT, NULL, 0 }
};
CK_ULONG count = sizeof(pubktemplate) / sizeof(pubktemplate[0]);
NSS_CK_SET_ATTRIBUTE_ITEM(pubktemplate, 0, &g_ck_class_pubkey);
if (c->id.size > 0) {
/* CKA_ID */
NSS_CK_ITEM_TO_ATTRIBUTE(&c->id, &pubktemplate[1]);

Просмотреть файл

@ -32,7 +32,7 @@
*/
#ifdef DEBUG
static const char CVS_ID[] = "@(#) $RCSfile: tdcache.c,v $ $Revision: 1.2 $ $Date: 2001-10-11 17:41:44 $ $Name: $";
static const char CVS_ID[] = "@(#) $RCSfile: tdcache.c,v $ $Revision: 1.3 $ $Date: 2001-10-11 18:40:34 $ $Name: $";
#endif /* DEBUG */
#ifndef PKIT_H
@ -279,7 +279,9 @@ nssTrustDomain_RemoveCertFromCache
nssList *subjects;
NSSItem *ias;
unsigned char buf[128];
NSSItem s_ias = { (void *)buf, sizeof(buf) };
NSSItem s_ias;
s_ias.data = (void *)buf;
s_ias.size = sizeof(buf);
ias = get_static_ias(&s_ias, &cert->issuer, &cert->serial);
PZ_Lock(td->cache->lock);
if (nssHash_Exists(td->cache->issuerAndSN, &ias)) {
@ -504,7 +506,9 @@ nssTrustDomain_GetCertForIssuerAndSNFromCache
NSSCertificate *rvCert;
NSSItem *ias;
unsigned char buf[128];
NSSItem s_ias = { (void *)buf, sizeof(buf) };
NSSItem s_ias;
s_ias.data = (void *)buf;
s_ias.size = sizeof(buf);
ias = get_static_ias(&s_ias, issuer, serial);
#ifdef DEBUG
debug_cache(td);

Просмотреть файл

@ -32,7 +32,7 @@
*/
#ifdef DEBUG
static const char CVS_ID[] = "@(#) $RCSfile: trustdomain.c,v $ $Revision: 1.6 $ $Date: 2001-10-11 16:34:49 $ $Name: $";
static const char CVS_ID[] = "@(#) $RCSfile: trustdomain.c,v $ $Revision: 1.7 $ $Date: 2001-10-11 18:40:34 $ $Name: $";
#endif /* DEBUG */
#ifndef NSSPKI_H
@ -373,12 +373,13 @@ NSSTrustDomain_FindBestCertificateByNickname
NSSToken *tok;
CK_ATTRIBUTE cert_template[] =
{
{ CKA_CLASS, g_ck_class_cert.data, g_ck_class_cert.size },
{ CKA_LABEL, NULL, 0 }
{ CKA_CLASS, NULL, 0 },
{ CKA_LABEL, NULL, 0 }
};
struct get_best_cert_arg_str best;
CK_ULONG ctsize;
ctsize = (CK_ULONG)(sizeof(cert_template) / sizeof(cert_template[0]));
NSS_CK_SET_ATTRIBUTE_ITEM(cert_template, 0, &g_ck_class_cert);
cert_template[1].pValue = (CK_VOID_PTR)name;
cert_template[1].ulValueLen = (CK_ULONG)nssUTF8_Length(name, &nssrv);
best.td = td;
@ -448,12 +449,13 @@ NSSTrustDomain_FindCertificatesByNickname
nssList *foundCerts;
CK_ATTRIBUTE cert_template[] =
{
{ CKA_CLASS, g_ck_class_cert.data, g_ck_class_cert.size },
{ CKA_LABEL, NULL, 0 }
{ CKA_CLASS, NULL, 0 },
{ CKA_LABEL, NULL, 0 }
};
struct collect_arg_str ca;
CK_ULONG ctsize;
ctsize = (CK_ULONG)(sizeof(cert_template) / sizeof(cert_template[0]));
NSS_CK_SET_ATTRIBUTE_ITEM(cert_template, 0, &g_ck_class_cert);
cert_template[1].pValue = (CK_VOID_PTR)name;
cert_template[1].ulValueLen = (CK_ULONG)nssUTF8_Length(name, &nssrv);
foundCerts = nssList_Create(NULL, PR_FALSE);