From bc77aebd6414e337fd683b4a67fc531b66e20cc7 Mon Sep 17 00:00:00 2001 From: "julien.pierre.boogz%sun.com" Date: Wed, 7 Nov 2007 02:37:22 +0000 Subject: [PATCH] Fix for bug 286642 . Don't export DER template from libnssutil3. r=nelson git-svn-id: svn://10.0.0.236/trunk@238615 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/security/nss/lib/cryptohi/secsign.c | 44 ++++++++++++++------- mozilla/security/nss/lib/softoken/pkcs11c.c | 28 ++++++++++++- mozilla/security/nss/lib/util/nssutil.def | 2 - mozilla/security/nss/lib/util/secdig.c | 30 +------------- mozilla/security/nss/lib/util/secdig.h | 6 +-- 5 files changed, 59 insertions(+), 51 deletions(-) diff --git a/mozilla/security/nss/lib/cryptohi/secsign.c b/mozilla/security/nss/lib/cryptohi/secsign.c index 719b4c72b6b..22e2a67f52d 100644 --- a/mozilla/security/nss/lib/cryptohi/secsign.c +++ b/mozilla/security/nss/lib/cryptohi/secsign.c @@ -37,7 +37,7 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/* $Id: secsign.c,v 1.19 2007-10-12 01:44:43 julien.pierre.boogz%sun.com Exp $ */ +/* $Id: secsign.c,v 1.20 2007-11-07 02:37:21 julien.pierre.boogz%sun.com Exp $ */ #include #include "cryptohi.h" @@ -150,6 +150,32 @@ SGN_Update(SGNContext *cx, unsigned char *input, unsigned inputLen) return SECSuccess; } +/* XXX Old template; want to expunge it eventually. */ +static DERTemplate SECAlgorithmIDTemplate[] = { + { DER_SEQUENCE, + 0, NULL, sizeof(SECAlgorithmID) }, + { DER_OBJECT_ID, + offsetof(SECAlgorithmID,algorithm), }, + { DER_OPTIONAL | DER_ANY, + offsetof(SECAlgorithmID,parameters), }, + { 0, } +}; + +/* + * XXX OLD Template. Once all uses have been switched over to new one, + * remove this. + */ +static DERTemplate SGNDigestInfoTemplate[] = { + { DER_SEQUENCE, + 0, NULL, sizeof(SGNDigestInfo) }, + { DER_INLINE, + offsetof(SGNDigestInfo,digestAlgorithm), + SECAlgorithmIDTemplate, }, + { DER_OCTET_STRING, + offsetof(SGNDigestInfo,digest), }, + { 0, } +}; + SECStatus SGN_End(SGNContext *cx, SECItem *result) { @@ -189,7 +215,7 @@ SGN_End(SGNContext *cx, SECItem *result) } /* Der encode the digest as a DigestInfo */ - rv = DER_Encode(arena, &digder, SEC_ASN1_GET(SGNDigestInfoTemplate), + rv = DER_Encode(arena, &digder, SGNDigestInfoTemplate, di); if (rv != SECSuccess) { goto loser; @@ -280,16 +306,6 @@ SEC_SignData(SECItem *res, unsigned char *buf, int len, /************************************************************************/ -static DERTemplate SECAlgorithmIDTemplate[] = { - { DER_SEQUENCE, - 0, NULL, sizeof(SECAlgorithmID) }, - { DER_OBJECT_ID, - offsetof(SECAlgorithmID,algorithm), }, - { DER_OPTIONAL | DER_ANY, - offsetof(SECAlgorithmID,parameters), }, - { 0, } -}; - DERTemplate CERTSignedDataTemplate[] = { { DER_SEQUENCE, @@ -304,7 +320,7 @@ DERTemplate CERTSignedDataTemplate[] = { 0, } }; -SEC_ASN1_MKSUB(SECOID_AlgorithmIDTemplate); +SEC_ASN1_MKSUB(SECOID_AlgorithmIDTemplate) const SEC_ASN1Template CERT_SignedDataTemplate[] = { @@ -405,7 +421,7 @@ SGN_Digest(SECKEYPrivateKey *privKey, } /* Der encode the digest as a DigestInfo */ - rv = DER_Encode(arena, &digder, SEC_ASN1_GET(SGNDigestInfoTemplate), + rv = DER_Encode(arena, &digder, SGNDigestInfoTemplate, di); if (rv != SECSuccess) { goto loser; diff --git a/mozilla/security/nss/lib/softoken/pkcs11c.c b/mozilla/security/nss/lib/softoken/pkcs11c.c index e78615ee040..4f65a008cb3 100644 --- a/mozilla/security/nss/lib/softoken/pkcs11c.c +++ b/mozilla/security/nss/lib/softoken/pkcs11c.c @@ -1638,6 +1638,32 @@ sftk_HashSign(SFTKHashSignInfo *info,unsigned char *sig,unsigned int *sigLen, hash,hashLen); } +/* XXX Old template; want to expunge it eventually. */ +static DERTemplate SECAlgorithmIDTemplate[] = { + { DER_SEQUENCE, + 0, NULL, sizeof(SECAlgorithmID) }, + { DER_OBJECT_ID, + offsetof(SECAlgorithmID,algorithm), }, + { DER_OPTIONAL | DER_ANY, + offsetof(SECAlgorithmID,parameters), }, + { 0, } +}; + +/* + * XXX OLD Template. Once all uses have been switched over to new one, + * remove this. + */ +static DERTemplate SGNDigestInfoTemplate[] = { + { DER_SEQUENCE, + 0, NULL, sizeof(SGNDigestInfo) }, + { DER_INLINE, + offsetof(SGNDigestInfo,digestAlgorithm), + SECAlgorithmIDTemplate, }, + { DER_OCTET_STRING, + offsetof(SGNDigestInfo,digest), }, + { 0, } +}; + SECStatus RSA_HashSign(SECOidTag hashOid, NSSLOWKEYPrivateKey *key, unsigned char *sig, unsigned int *sigLen, unsigned int maxLen, @@ -1659,7 +1685,7 @@ RSA_HashSign(SECOidTag hashOid, NSSLOWKEYPrivateKey *key, if (!di) { goto loser; } /* Der encode the digest as a DigestInfo */ - rv = DER_Encode(arena, &digder, SEC_ASN1_GET(SGNDigestInfoTemplate), di); + rv = DER_Encode(arena, &digder, SGNDigestInfoTemplate, di); if (rv != SECSuccess) { goto loser; } diff --git a/mozilla/security/nss/lib/util/nssutil.def b/mozilla/security/nss/lib/util/nssutil.def index 26bdaad890e..3bc6001bb9e 100644 --- a/mozilla/security/nss/lib/util/nssutil.def +++ b/mozilla/security/nss/lib/util/nssutil.def @@ -219,7 +219,6 @@ SGN_DestroyDigestInfo_Util; ;;SEC_UTF8StringTemplate_Util DATA ; ;;SECOID_AlgorithmIDTemplate_Util DATA ; ;;sgn_DigestInfoTemplate_Util DATA ; -;;SGNDigestInfoTemplate DATA ; NSS_Get_CERT_TimeChoiceTemplate_Util; NSS_Get_SEC_AnyTemplate_Util; NSS_Get_SEC_BitStringTemplate_Util; @@ -246,7 +245,6 @@ NSS_Get_SEC_UniversalStringTemplate; NSS_Get_SEC_UTF8StringTemplate_Util; NSS_Get_SECOID_AlgorithmIDTemplate_Util; NSS_Get_sgn_DigestInfoTemplate_Util; -NSS_Get_SGNDigestInfoTemplate; ;+ local: ;+ *; ;+}; diff --git a/mozilla/security/nss/lib/util/secdig.c b/mozilla/security/nss/lib/util/secdig.c index 556f1922242..5e8a8490259 100644 --- a/mozilla/security/nss/lib/util/secdig.c +++ b/mozilla/security/nss/lib/util/secdig.c @@ -33,41 +33,13 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/* $Id: secdig.c,v 1.8 2007-10-12 01:44:51 julien.pierre.boogz%sun.com Exp $ */ +/* $Id: secdig.c,v 1.9 2007-11-07 02:37:22 julien.pierre.boogz%sun.com Exp $ */ #include "secdig.h" #include "secoid.h" #include "secasn1.h" #include "secerr.h" -/* XXX Old template; want to expunge it eventually. */ -static DERTemplate SECAlgorithmIDTemplate[] = { - { DER_SEQUENCE, - 0, NULL, sizeof(SECAlgorithmID) }, - { DER_OBJECT_ID, - offsetof(SECAlgorithmID,algorithm), }, - { DER_OPTIONAL | DER_ANY, - offsetof(SECAlgorithmID,parameters), }, - { 0, } -}; - -/* - * XXX OLD Template. Once all uses have been switched over to new one, - * remove this. - */ -DERTemplate SGNDigestInfoTemplate[] = { - { DER_SEQUENCE, - 0, NULL, sizeof(SGNDigestInfo) }, - { DER_INLINE, - offsetof(SGNDigestInfo,digestAlgorithm), - SECAlgorithmIDTemplate, }, - { DER_OCTET_STRING, - offsetof(SGNDigestInfo,digest), }, - { 0, } -}; - -SEC_ASN1_CHOOSER_IMPLEMENT(SGNDigestInfoTemplate) - /* * XXX Want to have a SGN_DecodeDigestInfo, like: * SGNDigestInfo *SGN_DecodeDigestInfo(SECItem *didata); diff --git a/mozilla/security/nss/lib/util/secdig.h b/mozilla/security/nss/lib/util/secdig.h index 77af9070b95..0eb366213ff 100644 --- a/mozilla/security/nss/lib/util/secdig.h +++ b/mozilla/security/nss/lib/util/secdig.h @@ -36,7 +36,7 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/* $Id: secdig.h,v 1.6 2007-10-12 01:44:51 julien.pierre.boogz%sun.com Exp $ */ +/* $Id: secdig.h,v 1.7 2007-11-07 02:37:22 julien.pierre.boogz%sun.com Exp $ */ #ifndef _SECDIG_H_ #define _SECDIG_H_ @@ -55,10 +55,6 @@ extern const SEC_ASN1Template sgn_DigestInfoTemplate[]; SEC_ASN1_CHOOSER_DECLARE(sgn_DigestInfoTemplate) -extern DERTemplate SGNDigestInfoTemplate[]; - -SEC_ASN1_CHOOSER_DECLARE(SGNDigestInfoTemplate) - /****************************************/ /* ** Digest-info functions