2 * The contents of this file are subject to the Mozilla Public
3 * License Version 1.1 (the "License"); you may not use this file
4 * except in compliance with the License. You may obtain a copy of
5 * the License at http://www.mozilla.org/MPL/
7 * Software distributed under the License is distributed on an "AS
8 * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
9 * implied. See the License for the specific language governing
10 * rights and limitations under the License.
12 * The Original Code is the Netscape security libraries.
14 * The Initial Developer of the Original Code is Netscape
15 * Communications Corporation. Portions created by Netscape are
16 * Copyright (C) 1994-2000 Netscape Communications Corporation. All
21 * Alternatively, the contents of this file may be used under the
22 * terms of the GNU General Public License Version 2 or later (the
23 * "GPL"), in which case the provisions of the GPL are applicable
24 * instead of those above. If you wish to allow use of your
25 * version of this file only under the terms of the GPL and not to
26 * allow others to use your version of this file under the MPL,
27 * indicate your decision by deleting the provisions above and
28 * replace them with the notice and other provisions required by
29 * the GPL. If you do not delete the provisions above, a recipient
30 * may use your version of this file under either the MPL or the
35 * CMS signerInfo methods.
38 #include <Security/SecCmsSignerInfo.h>
39 #include "SecSMIMEPriv.h"
48 #include <security_asn1/secasn1.h>
49 #include <security_asn1/secerr.h>
50 #include <Security/SecKeychain.h>
51 #include <Security/SecIdentity.h>
52 #include <Security/SecCertificatePriv.h>
53 #include <Security/SecKeyPriv.h>
54 #include <CoreFoundation/CFTimeZone.h>
55 #include <AssertMacros.h>
56 #include <CoreServices/../Frameworks/CarbonCore.framework/Headers/MacErrors.h>
58 #include "tsaSupport.h"
59 #include "tsaSupportPriv.h"
61 #define HIDIGIT(v) (((v) / 10) + '0')
62 #define LODIGIT(v) (((v) % 10) + '0')
64 #define ISDIGIT(dig) (((dig) >= '0') && ((dig) <= '9'))
65 #define CAPTURE(var,p,label) \
67 if (!ISDIGIT((p)[0]) || !ISDIGIT((p)[1])) goto label; \
68 (var) = ((p)[0] - '0') * 10 + ((p)[1] - '0'); \
72 #define SIGINFO_DEBUG 1
76 #define dprintf(args...) printf(args)
78 #define dprintf(args...)
82 #define dprintfRC(args...) dprintf(args)
84 #define dprintfRC(args...)
88 DER_UTCTimeToCFDate(const CSSM_DATA_PTR utcTime
, CFAbsoluteTime
*date
)
90 CFGregorianDate gdate
;
91 char *string
= (char *)utcTime
->Data
;
92 long year
, month
, mday
, hour
, minute
, second
, hourOff
, minOff
;
93 CFTimeZoneRef timeZone
;
95 /* Verify time is formatted properly and capture information */
99 CAPTURE(year
,string
+0,loser
);
101 /* ASSUME that year # is in the 2000's, not the 1900's */
104 CAPTURE(month
,string
+2,loser
);
105 if ((month
== 0) || (month
> 12)) goto loser
;
106 CAPTURE(mday
,string
+4,loser
);
107 if ((mday
== 0) || (mday
> 31)) goto loser
;
108 CAPTURE(hour
,string
+6,loser
);
109 if (hour
> 23) goto loser
;
110 CAPTURE(minute
,string
+8,loser
);
111 if (minute
> 59) goto loser
;
112 if (ISDIGIT(string
[10])) {
113 CAPTURE(second
,string
+10,loser
);
114 if (second
> 59) goto loser
;
117 if (string
[10] == '+') {
118 CAPTURE(hourOff
,string
+11,loser
);
119 if (hourOff
> 23) goto loser
;
120 CAPTURE(minOff
,string
+13,loser
);
121 if (minOff
> 59) goto loser
;
122 } else if (string
[10] == '-') {
123 CAPTURE(hourOff
,string
+11,loser
);
124 if (hourOff
> 23) goto loser
;
126 CAPTURE(minOff
,string
+13,loser
);
127 if (minOff
> 59) goto loser
;
129 } else if (string
[10] != 'Z') {
133 gdate
.year
= year
+ 1900;
137 gdate
.minute
= minute
;
138 gdate
.second
= second
;
140 if (hourOff
== 0 && minOff
== 0)
141 timeZone
= NULL
; /* GMT */
144 timeZone
= CFTimeZoneCreateWithTimeIntervalFromGMT(NULL
, (hourOff
* 60 + minOff
) * 60);
147 *date
= CFGregorianDateGetAbsoluteTime(gdate
, timeZone
);
158 DER_CFDateToUTCTime(CFAbsoluteTime date
, CSSM_DATA_PTR utcTime
)
160 CFGregorianDate gdate
= CFAbsoluteTimeGetGregorianDate(date
, NULL
/* GMT */);
164 utcTime
->Length
= 13;
165 utcTime
->Data
= d
= PORT_Alloc(13);
169 /* UTC time does not handle the years before 1950 */
170 if (gdate
.year
< 1950)
173 /* remove the century since it's added to the year by the
174 CFAbsoluteTimeGetGregorianDate routine, but is not needed for UTC time */
176 second
= gdate
.second
+ 0.5;
178 d
[0] = HIDIGIT(gdate
.year
);
179 d
[1] = LODIGIT(gdate
.year
);
180 d
[2] = HIDIGIT(gdate
.month
);
181 d
[3] = LODIGIT(gdate
.month
);
182 d
[4] = HIDIGIT(gdate
.day
);
183 d
[5] = LODIGIT(gdate
.day
);
184 d
[6] = HIDIGIT(gdate
.hour
);
185 d
[7] = LODIGIT(gdate
.hour
);
186 d
[8] = HIDIGIT(gdate
.minute
);
187 d
[9] = LODIGIT(gdate
.minute
);
188 d
[10] = HIDIGIT(second
);
189 d
[11] = LODIGIT(second
);
194 /* =============================================================================
198 nss_cmssignerinfo_create(SecCmsMessageRef cmsg
, SecCmsSignerIDSelector type
, SecCertificateRef cert
, CSSM_DATA_PTR subjKeyID
, SecPublicKeyRef pubKey
, SecPrivateKeyRef signingKey
, SECOidTag digestalgtag
);
201 SecCmsSignerInfoCreateWithSubjKeyID(SecCmsMessageRef cmsg
, CSSM_DATA_PTR subjKeyID
, SecPublicKeyRef pubKey
, SecPrivateKeyRef signingKey
, SECOidTag digestalgtag
)
203 return nss_cmssignerinfo_create(cmsg
, SecCmsSignerIDSubjectKeyID
, NULL
, subjKeyID
, pubKey
, signingKey
, digestalgtag
);
207 SecCmsSignerInfoCreate(SecCmsMessageRef cmsg
, SecIdentityRef identity
, SECOidTag digestalgtag
)
209 SecCmsSignerInfoRef signerInfo
= NULL
;
210 SecCertificateRef cert
= NULL
;
211 SecPrivateKeyRef signingKey
= NULL
;
213 if (SecIdentityCopyCertificate(identity
, &cert
))
215 if (SecIdentityCopyPrivateKey(identity
, &signingKey
))
218 signerInfo
= nss_cmssignerinfo_create(cmsg
, SecCmsSignerIDIssuerSN
, cert
, NULL
, NULL
, signingKey
, digestalgtag
);
224 CFRelease(signingKey
);
230 nss_cmssignerinfo_create(SecCmsMessageRef cmsg
, SecCmsSignerIDSelector type
, SecCertificateRef cert
, CSSM_DATA_PTR subjKeyID
, SecPublicKeyRef pubKey
, SecPrivateKeyRef signingKey
, SECOidTag digestalgtag
)
233 SecCmsSignerInfoRef signerinfo
;
239 mark
= PORT_ArenaMark(poolp
);
241 signerinfo
= (SecCmsSignerInfoRef
)PORT_ArenaZAlloc(poolp
, sizeof(SecCmsSignerInfo
));
242 if (signerinfo
== NULL
) {
243 PORT_ArenaRelease(poolp
, mark
);
248 signerinfo
->cmsg
= cmsg
;
251 case SecCmsSignerIDIssuerSN
:
252 signerinfo
->signerIdentifier
.identifierType
= SecCmsSignerIDIssuerSN
;
253 if ((signerinfo
->cert
= CERT_DupCertificate(cert
)) == NULL
)
255 if ((signerinfo
->signerIdentifier
.id
.issuerAndSN
= CERT_GetCertIssuerAndSN(poolp
, cert
)) == NULL
)
257 dprintfRC("nss_cmssignerinfo_create: SecCmsSignerIDIssuerSN: cert.rc %d\n",
258 (int)CFGetRetainCount(signerinfo
->cert
));
260 case SecCmsSignerIDSubjectKeyID
:
261 signerinfo
->signerIdentifier
.identifierType
= SecCmsSignerIDSubjectKeyID
;
262 PORT_Assert(subjKeyID
);
265 signerinfo
->signerIdentifier
.id
.subjectKeyID
= PORT_ArenaNew(poolp
, CSSM_DATA
);
266 SECITEM_CopyItem(poolp
, signerinfo
->signerIdentifier
.id
.subjectKeyID
,
268 signerinfo
->pubKey
= SECKEY_CopyPublicKey(pubKey
);
269 if (!signerinfo
->pubKey
)
279 signerinfo
->signingKey
= SECKEY_CopyPrivateKey(signingKey
);
280 if (!signerinfo
->signingKey
)
283 /* set version right now */
284 version
= SEC_CMS_SIGNER_INFO_VERSION_ISSUERSN
;
285 /* RFC2630 5.3 "version is the syntax version number. If the .... " */
286 if (signerinfo
->signerIdentifier
.identifierType
== SecCmsSignerIDSubjectKeyID
)
287 version
= SEC_CMS_SIGNER_INFO_VERSION_SUBJKEY
;
288 (void)SEC_ASN1EncodeInteger(poolp
, &(signerinfo
->version
), (long)version
);
290 if (SECOID_SetAlgorithmID(poolp
, &signerinfo
->digestAlg
, digestalgtag
, NULL
) != SECSuccess
)
293 PORT_ArenaUnmark(poolp
, mark
);
297 PORT_ArenaRelease(poolp
, mark
);
302 * SecCmsSignerInfoDestroy - destroy a SignerInfo data structure
305 SecCmsSignerInfoDestroy(SecCmsSignerInfoRef si
)
307 if (si
->cert
!= NULL
) {
308 dprintfRC("SecCmsSignerInfoDestroy top: certp %p cert.rc %d\n",
309 si
->cert
, (int)CFGetRetainCount(si
->cert
));
310 CERT_DestroyCertificate(si
->cert
);
312 if (si
->certList
!= NULL
) {
313 dprintfRC("SecCmsSignerInfoDestroy top: certList.rc %d\n",
314 (int)CFGetRetainCount(si
->certList
));
315 CFRelease(si
->certList
);
317 if (si
->timestampCertList
!= NULL
) {
318 dprintfRC("SecCmsSignerInfoDestroy top: timestampCertList.rc %d\n",
319 (int)CFGetRetainCount(si
->timestampCertList
));
320 CFRelease(si
->timestampCertList
);
322 /* XXX storage ??? */
326 * SecCmsSignerInfoSign - sign something
330 SecCmsSignerInfoSign(SecCmsSignerInfoRef signerinfo
, CSSM_DATA_PTR digest
, CSSM_DATA_PTR contentType
)
332 SecCertificateRef cert
;
333 SecPrivateKeyRef privkey
= NULL
;
334 SECOidTag digestalgtag
;
335 SECOidTag pubkAlgTag
;
336 CSSM_DATA signature
= { 0 };
338 PLArenaPool
*poolp
, *tmppoolp
;
339 const SECAlgorithmID
*algID
;
340 SECAlgorithmID freeAlgID
;
341 //CERTSubjectPublicKeyInfo *spki;
343 PORT_Assert (digest
!= NULL
);
345 poolp
= signerinfo
->cmsg
->poolp
;
347 switch (signerinfo
->signerIdentifier
.identifierType
) {
348 case SecCmsSignerIDIssuerSN
:
349 privkey
= signerinfo
->signingKey
;
350 signerinfo
->signingKey
= NULL
;
351 cert
= signerinfo
->cert
;
352 if (SecCertificateGetAlgorithmID(cert
,&algID
)) {
353 PORT_SetError(SEC_ERROR_INVALID_ALGORITHM
);
357 case SecCmsSignerIDSubjectKeyID
:
358 privkey
= signerinfo
->signingKey
;
359 signerinfo
->signingKey
= NULL
;
361 spki
= SECKEY_CreateSubjectPublicKeyInfo(signerinfo
->pubKey
);
362 SECKEY_DestroyPublicKey(signerinfo
->pubKey
);
363 signerinfo
->pubKey
= NULL
;
364 SECOID_CopyAlgorithmID(NULL
, &freeAlgID
, &spki
->algorithm
);
365 SECKEY_DestroySubjectPublicKeyInfo(spki
);
368 if (SecKeyGetAlgorithmID(signerinfo
->pubKey
,&algID
)) {
369 PORT_SetError(SEC_ERROR_INVALID_ALGORITHM
);
372 CFRelease(signerinfo
->pubKey
);
373 signerinfo
->pubKey
= NULL
;
377 PORT_SetError(SEC_ERROR_UNSUPPORTED_MESSAGE_TYPE
);
380 digestalgtag
= SecCmsSignerInfoGetDigestAlgTag(signerinfo
);
382 * XXX I think there should be a cert-level interface for this,
383 * so that I do not have to know about subjectPublicKeyInfo...
385 pubkAlgTag
= SECOID_GetAlgorithmTag(algID
);
386 if (signerinfo
->signerIdentifier
.identifierType
== SecCmsSignerIDSubjectKeyID
) {
387 SECOID_DestroyAlgorithmID(&freeAlgID
, PR_FALSE
);
392 /* Fortezza MISSI have weird signature formats.
393 * Map them to standard DSA formats
395 pubkAlgTag
= PK11_FortezzaMapSig(pubkAlgTag
);
398 if (signerinfo
->authAttr
!= NULL
) {
399 CSSM_DATA encoded_attrs
;
401 /* find and fill in the message digest attribute. */
402 rv
= SecCmsAttributeArraySetAttr(poolp
, &(signerinfo
->authAttr
),
403 SEC_OID_PKCS9_MESSAGE_DIGEST
, digest
, PR_FALSE
);
404 if (rv
!= SECSuccess
)
407 if (contentType
!= NULL
) {
408 /* if the caller wants us to, find and fill in the content type attribute. */
409 rv
= SecCmsAttributeArraySetAttr(poolp
, &(signerinfo
->authAttr
),
410 SEC_OID_PKCS9_CONTENT_TYPE
, contentType
, PR_FALSE
);
411 if (rv
!= SECSuccess
)
415 if ((tmppoolp
= PORT_NewArena (1024)) == NULL
) {
416 PORT_SetError(SEC_ERROR_NO_MEMORY
);
421 * Before encoding, reorder the attributes so that when they
422 * are encoded, they will be conforming DER, which is required
423 * to have a specific order and that is what must be used for
424 * the hash/signature. We do this here, rather than building
425 * it into EncodeAttributes, because we do not want to do
426 * such reordering on incoming messages (which also uses
427 * EncodeAttributes) or our old signatures (and other "broken"
428 * implementations) will not verify. So, we want to guarantee
429 * that we send out good DER encodings of attributes, but not
430 * to expect to receive them.
432 if (SecCmsAttributeArrayReorder(signerinfo
->authAttr
) != SECSuccess
)
435 encoded_attrs
.Data
= NULL
;
436 encoded_attrs
.Length
= 0;
437 if (SecCmsAttributeArrayEncode(tmppoolp
, &(signerinfo
->authAttr
),
438 &encoded_attrs
) == NULL
)
441 rv
= SEC_SignData(&signature
, encoded_attrs
.Data
, encoded_attrs
.Length
,
442 privkey
, digestalgtag
, pubkAlgTag
);
443 PORT_FreeArena(tmppoolp
, PR_FALSE
); /* awkward memory management :-( */
445 rv
= SGN_Digest(privkey
, digestalgtag
, pubkAlgTag
, &signature
, digest
);
447 SECKEY_DestroyPrivateKey(privkey
);
450 if (rv
!= SECSuccess
)
453 if (SECITEM_CopyItem(poolp
, &(signerinfo
->encDigest
), &signature
)
457 SECITEM_FreeItem(&signature
, PR_FALSE
);
459 if(pubkAlgTag
== SEC_OID_EC_PUBLIC_KEY
) {
461 * RFC 3278 section section 2.1.1 states that the signatureAlgorithm
462 * field contains the full ecdsa-with-SHA1 OID, not plain old ecPublicKey
463 * as would appear in other forms of signed datas. However Microsoft doesn't
464 * do this, it puts ecPublicKey there, and if we put ecdsa-with-SHA1 there,
465 * MS can't verify - presumably because it takes the digest of the digest
466 * before feeding it to ECDSA.
467 * We handle this with a preference; default if it's not there is
468 * "Microsoft compatibility mode".
470 if(!SecCmsMsEcdsaCompatMode()) {
471 pubkAlgTag
= SEC_OID_ECDSA_WithSHA1
;
473 /* else violating the spec for compatibility */
476 if (SECOID_SetAlgorithmID(poolp
, &(signerinfo
->digestEncAlg
), pubkAlgTag
,
483 if (signature
.Length
!= 0)
484 SECITEM_FreeItem (&signature
, PR_FALSE
);
486 SECKEY_DestroyPrivateKey(privkey
);
487 if((algID
!= NULL
) & (algID
!= &freeAlgID
)) {
488 /* this is dicey - this was actually mallocd by either SecCertificate or
489 * by SecKey...it all boils down to a free() in the end though. */
490 SECOID_DestroyAlgorithmID((SECAlgorithmID
*)algID
, PR_FALSE
);
496 SecCmsSignerInfoVerifyCertificate(SecCmsSignerInfoRef signerinfo
, SecKeychainRef keychainOrArray
,
497 CFTypeRef policies
, SecTrustRef
*trustRef
)
499 SecCertificateRef cert
;
500 CFAbsoluteTime stime
;
502 CSSM_DATA_PTR
*otherCerts
;
504 if ((cert
= SecCmsSignerInfoGetSigningCertificate(signerinfo
, keychainOrArray
)) == NULL
) {
505 dprintf("SecCmsSignerInfoVerifyCertificate: no signing cert\n");
506 signerinfo
->verificationStatus
= SecCmsVSSigningCertNotFound
;
511 * Get and convert the signing time; if available, it will be used
512 * both on the cert verification and for importing the sender
515 if (SecCmsSignerInfoGetTimestampTime(signerinfo
, &stime
) != SECSuccess
)
516 if (SecCmsSignerInfoGetSigningTime(signerinfo
, &stime
) != SECSuccess
)
517 stime
= CFAbsoluteTimeGetCurrent();
518 rv
= SecCmsSignedDataRawCerts(signerinfo
->sigd
, &otherCerts
);
522 rv
= CERT_VerifyCert(keychainOrArray
, cert
, otherCerts
, policies
, stime
, trustRef
);
523 dprintfRC("SecCmsSignerInfoVerifyCertificate after vfy: certp %p cert.rc %d\n",
524 cert
, (int)CFGetRetainCount(cert
));
527 if (PORT_GetError() == SEC_ERROR_UNTRUSTED_CERT
)
529 /* Signature or digest level verificationStatus errors should supercede certificate level errors, so only change the verificationStatus if the status was GoodSignature. */
530 if (signerinfo
->verificationStatus
== SecCmsVSGoodSignature
)
531 signerinfo
->verificationStatus
= SecCmsVSSigningCertNotTrusted
;
534 /* FIXME isn't this leaking the cert? */
535 dprintf("SecCmsSignerInfoVerifyCertificate: CertVerify rtn %d\n", (int)rv
);
539 static void debugShowSigningCertificate(SecCmsSignerInfoRef signerinfo
)
542 CFStringRef cn
= SecCmsSignerInfoGetSignerCommonName(signerinfo
);
545 char *ccn
= cfStringToChar(cn
);
548 dprintf("SecCmsSignerInfoVerify: cn: %s\n", ccn
);
556 * SecCmsSignerInfoVerify - verify the signature of a single SignerInfo
558 * Just verifies the signature. The assumption is that verification of the certificate
562 SecCmsSignerInfoVerify(SecCmsSignerInfoRef signerinfo
, CSSM_DATA_PTR digest
, CSSM_DATA_PTR contentType
)
564 SecPublicKeyRef publickey
= NULL
;
565 SecCmsAttribute
*attr
;
566 CSSM_DATA encoded_attrs
;
567 SecCertificateRef cert
;
568 SecCmsVerificationStatus vs
= SecCmsVSUnverified
;
570 SECOidTag digestAlgTag
, digestEncAlgTag
;
572 if (signerinfo
== NULL
)
575 /* SecCmsSignerInfoGetSigningCertificate will fail if 2nd parm is NULL and */
576 /* cert has not been verified */
577 if ((cert
= SecCmsSignerInfoGetSigningCertificate(signerinfo
, NULL
)) == NULL
) {
578 dprintf("SecCmsSignerInfoVerify: no signing cert\n");
579 vs
= SecCmsVSSigningCertNotFound
;
583 dprintfRC("SecCmsSignerInfoVerify top: cert %p cert.rc %d\n", cert
, (int)CFGetRetainCount(cert
));
585 debugShowSigningCertificate(signerinfo
);
587 if (SecCertificateCopyPublicKey(cert
, &publickey
)) {
588 vs
= SecCmsVSProcessingError
;
592 digestAlgTag
= SECOID_GetAlgorithmTag(&(signerinfo
->digestAlg
));
593 digestEncAlgTag
= SECOID_GetAlgorithmTag(&(signerinfo
->digestEncAlg
));
596 * Gross hack necessitated by RFC 3278 section 2.1.1, which states
597 * that the signature algorithm (here, digestEncAlg) contains ecdsa_with-SHA1,
598 * *not* (as in all other algorithms) the raw signature algorithm, e.g.
599 * pkcs1RSAEncryption.
601 if(digestEncAlgTag
== SEC_OID_ECDSA_WithSHA1
) {
602 digestEncAlgTag
= SEC_OID_EC_PUBLIC_KEY
;
605 if (!SecCmsArrayIsEmpty((void **)signerinfo
->authAttr
)) {
610 * RFC2630 sez that if there are any authenticated attributes,
611 * then there must be one for content type which matches the
612 * content type of the content being signed, and there must
613 * be one for message digest which matches our message digest.
614 * So check these things first.
616 if ((attr
= SecCmsAttributeArrayFindAttrByOidTag(signerinfo
->authAttr
,
617 SEC_OID_PKCS9_CONTENT_TYPE
, PR_TRUE
)) == NULL
)
619 vs
= SecCmsVSMalformedSignature
;
623 if (SecCmsAttributeCompareValue(attr
, contentType
) == PR_FALSE
) {
624 vs
= SecCmsVSMalformedSignature
;
632 if ((attr
= SecCmsAttributeArrayFindAttrByOidTag(signerinfo
->authAttr
, SEC_OID_PKCS9_MESSAGE_DIGEST
, PR_TRUE
)) == NULL
)
634 vs
= SecCmsVSMalformedSignature
;
637 if (SecCmsAttributeCompareValue(attr
, digest
) == PR_FALSE
) {
638 vs
= SecCmsVSDigestMismatch
;
642 if ((poolp
= PORT_NewArena (1024)) == NULL
) {
643 vs
= SecCmsVSProcessingError
;
650 * The signature is based on a digest of the DER-encoded authenticated
651 * attributes. So, first we encode and then we digest/verify.
652 * we trust the decoder to have the attributes in the right (sorted) order
654 encoded_attrs
.Data
= NULL
;
655 encoded_attrs
.Length
= 0;
657 if (SecCmsAttributeArrayEncode(poolp
, &(signerinfo
->authAttr
), &encoded_attrs
) == NULL
||
658 encoded_attrs
.Data
== NULL
|| encoded_attrs
.Length
== 0)
660 vs
= SecCmsVSProcessingError
;
664 vs
= (VFY_VerifyData (encoded_attrs
.Data
, encoded_attrs
.Length
,
665 publickey
, &(signerinfo
->encDigest
),
666 digestAlgTag
, digestEncAlgTag
,
667 signerinfo
->cmsg
->pwfn_arg
) != SECSuccess
) ? SecCmsVSBadSignature
: SecCmsVSGoodSignature
;
669 dprintf("VFY_VerifyData (authenticated attributes): %s\n",
670 (vs
== SecCmsVSGoodSignature
)?"SecCmsVSGoodSignature":"SecCmsVSBadSignature");
672 PORT_FreeArena(poolp
, PR_FALSE
); /* awkward memory management :-( */
677 /* No authenticated attributes. The signature is based on the plain message digest. */
678 sig
= &(signerinfo
->encDigest
);
679 if (sig
->Length
== 0)
682 vs
= (VFY_VerifyDigest(digest
, publickey
, sig
,
683 digestAlgTag
, digestEncAlgTag
,
684 signerinfo
->cmsg
->pwfn_arg
) != SECSuccess
) ? SecCmsVSBadSignature
: SecCmsVSGoodSignature
;
686 dprintf("VFY_VerifyData (plain message digest): %s\n",
687 (vs
== SecCmsVSGoodSignature
)?"SecCmsVSGoodSignature":"SecCmsVSBadSignature");
690 if (!SecCmsArrayIsEmpty((void **)signerinfo
->unAuthAttr
))
692 dprintf("found an unAuthAttr\n");
693 OSStatus rux
= SecCmsSignerInfoVerifyUnAuthAttrs(signerinfo
);
694 dprintf("SecCmsSignerInfoVerifyUnAuthAttrs Status: %ld\n", (long)rux
);
699 if (vs
== SecCmsVSBadSignature
) {
701 * XXX Change the generic error into our specific one, because
702 * in that case we get a better explanation out of the Security
703 * Advisor. This is really a bug in our error strings (the
704 * "generic" error has a lousy/wrong message associated with it
705 * which assumes the signature verification was done for the
706 * purposes of checking the issuer signature on a certificate)
707 * but this is at least an easy workaround and/or in the
708 * Security Advisor, which specifically checks for the error
709 * SEC_ERROR_PKCS7_BAD_SIGNATURE and gives more explanation
710 * in that case but does not similarly check for
711 * SEC_ERROR_BAD_SIGNATURE. It probably should, but then would
712 * probably say the wrong thing in the case that it *was* the
713 * certificate signature check that failed during the cert
714 * verification done above. Our error handling is really a mess.
716 if (PORT_GetError() == SEC_ERROR_BAD_SIGNATURE
)
717 PORT_SetError(SEC_ERROR_PKCS7_BAD_SIGNATURE
);
720 if (publickey
!= NULL
)
721 CFRelease(publickey
);
723 signerinfo
->verificationStatus
= vs
;
724 dprintfRC("SecCmsSignerInfoVerify end: cerp %p cert.rc %d\n",
725 cert
, (int)CFGetRetainCount(cert
));
727 dprintf("verificationStatus: %d\n", vs
);
729 return (vs
== SecCmsVSGoodSignature
) ? SECSuccess
: SECFailure
;
732 if (publickey
!= NULL
)
733 SECKEY_DestroyPublicKey (publickey
);
735 dprintf("verificationStatus2: %d\n", vs
);
736 signerinfo
->verificationStatus
= vs
;
738 PORT_SetError (SEC_ERROR_PKCS7_BAD_SIGNATURE
);
744 SecCmsSignerInfoVerifyUnAuthAttrs(SecCmsSignerInfoRef signerinfo
)
747 unAuthAttr is an array of attributes; we expect to
748 see just one: the timestamp blob. If we have an unAuthAttr,
749 but don't see a timestamp, return an error since we have
750 no other cases where this would be present.
753 SecCmsAttribute
*attr
= NULL
;
754 OSStatus status
= SECFailure
;
756 require(signerinfo
, xit
);
757 attr
= SecCmsAttributeArrayFindAttrByOidTag(signerinfo
->unAuthAttr
,
758 SEC_OID_PKCS9_TIMESTAMP_TOKEN
, PR_TRUE
);
761 status
= errSecTimestampMissing
;
765 dprintf("found an id-ct-TSTInfo\n");
766 // Don't check the nonce in this case
767 status
= decodeTimeStampToken(signerinfo
, (attr
->values
)[0], &signerinfo
->encDigest
, 0);
773 SecCmsSignerInfoGetEncDigest(SecCmsSignerInfoRef signerinfo
)
775 return &signerinfo
->encDigest
;
778 SecCmsVerificationStatus
779 SecCmsSignerInfoGetVerificationStatus(SecCmsSignerInfoRef signerinfo
)
781 return signerinfo
->verificationStatus
;
785 SecCmsSignerInfoGetDigestAlg(SecCmsSignerInfoRef signerinfo
)
787 return SECOID_FindOID (&(signerinfo
->digestAlg
.algorithm
));
791 SecCmsSignerInfoGetDigestAlgTag(SecCmsSignerInfoRef signerinfo
)
795 algdata
= SECOID_FindOID (&(signerinfo
->digestAlg
.algorithm
));
797 return algdata
->offset
;
799 return SEC_OID_UNKNOWN
;
803 SecCmsSignerInfoGetCertList(SecCmsSignerInfoRef signerinfo
)
805 dprintfRC("SecCmsSignerInfoGetCertList: certList.rc %d\n",
806 (int)CFGetRetainCount(signerinfo
->certList
));
807 return signerinfo
->certList
;
811 SecCmsSignerInfoGetTimestampCertList(SecCmsSignerInfoRef signerinfo
)
813 dprintfRC("SecCmsSignerInfoGetCertList: timestampCertList.rc %d\n",
814 (int)CFGetRetainCount(signerinfo
->timestampCertList
));
815 return signerinfo
->timestampCertList
;
821 SecCmsSignerInfoGetVersion(SecCmsSignerInfoRef signerinfo
)
823 unsigned long version
;
825 /* always take apart the CSSM_DATA */
826 if (SEC_ASN1DecodeInteger(&(signerinfo
->version
), &version
) != SECSuccess
)
833 * SecCmsSignerInfoGetSigningTime - return the signing time,
834 * in UTCTime format, of a CMS signerInfo.
836 * sinfo - signerInfo data for this signer
838 * Returns a pointer to XXXX (what?)
839 * A return value of NULL is an error.
842 SecCmsSignerInfoGetSigningTime(SecCmsSignerInfoRef sinfo
, CFAbsoluteTime
*stime
)
844 SecCmsAttribute
*attr
;
850 if (sinfo
->signingTime
!= 0) {
851 *stime
= sinfo
->signingTime
; /* cached copy */
855 attr
= SecCmsAttributeArrayFindAttrByOidTag(sinfo
->authAttr
, SEC_OID_PKCS9_SIGNING_TIME
, PR_TRUE
);
856 /* XXXX multi-valued attributes NIH */
857 if (attr
== NULL
|| (value
= SecCmsAttributeGetValue(attr
)) == NULL
)
858 return errSecSigningTimeMissing
;
859 if (DER_UTCTimeToCFDate(value
, stime
) != SECSuccess
)
860 return errSecSigningTimeMissing
;
861 sinfo
->signingTime
= *stime
; /* make cached copy */
866 SecCmsSignerInfoGetTimestampTime(SecCmsSignerInfoRef sinfo
, CFAbsoluteTime
*stime
)
868 OSStatus status
= paramErr
;
870 require(sinfo
&& stime
, xit
);
872 if (sinfo
->timestampTime
!= 0)
874 *stime
= sinfo
->timestampTime
; /* cached copy */
878 // A bit heavyweight if haven't already called verify
879 status
= SecCmsSignerInfoVerifyUnAuthAttrs(sinfo
);
880 *stime
= sinfo
->timestampTime
;
886 * Return the signing cert of a CMS signerInfo.
888 * the certs in the enclosing SignedData must have been imported already
891 SecCmsSignerInfoGetSigningCertificate(SecCmsSignerInfoRef signerinfo
, SecKeychainRef keychainOrArray
)
893 SecCertificateRef cert
;
894 SecCmsSignerIdentifier
*sid
;
896 CSSM_DATA_PTR
*rawCerts
;
898 if (signerinfo
->cert
!= NULL
) {
899 dprintfRC("SecCmsSignerInfoGetSigningCertificate top: cert %p cert.rc %d\n",
900 signerinfo
->cert
, (int)CFGetRetainCount(signerinfo
->cert
));
901 return signerinfo
->cert
;
903 ortn
= SecCmsSignedDataRawCerts(signerinfo
->sigd
, &rawCerts
);
907 dprintf("SecCmsSignerInfoGetSigningCertificate: numRawCerts %d\n",
908 SecCmsArrayCount((void **)rawCerts
));
911 * This cert will also need to be freed, but since we save it
912 * in signerinfo for later, we do not want to destroy it when
913 * we leave this function -- we let the clean-up of the entire
914 * cinfo structure later do the destroy of this cert.
916 sid
= &signerinfo
->signerIdentifier
;
917 switch (sid
->identifierType
) {
918 case SecCmsSignerIDIssuerSN
:
919 cert
= CERT_FindCertByIssuerAndSN(keychainOrArray
, rawCerts
, signerinfo
->cmsg
->poolp
,
920 sid
->id
.issuerAndSN
);
922 case SecCmsSignerIDSubjectKeyID
:
923 cert
= CERT_FindCertBySubjectKeyID(keychainOrArray
, rawCerts
, sid
->id
.subjectKeyID
);
930 /* cert can be NULL at that point */
931 signerinfo
->cert
= cert
; /* earmark it */
932 dprintfRC("SecCmsSignerInfoGetSigningCertificate end: certp %p cert.rc %d\n",
933 signerinfo
->cert
, (int)CFGetRetainCount(signerinfo
->cert
));
939 * SecCmsSignerInfoGetSignerCommonName - return the common name of the signer
941 * sinfo - signerInfo data for this signer
943 * Returns a CFStringRef containing the common name of the signer.
944 * A return value of NULL is an error.
947 SecCmsSignerInfoGetSignerCommonName(SecCmsSignerInfoRef sinfo
)
949 SecCertificateRef signercert
;
950 CFStringRef commonName
= NULL
;
952 /* will fail if cert is not verified */
953 if ((signercert
= SecCmsSignerInfoGetSigningCertificate(sinfo
, NULL
)) == NULL
)
956 SecCertificateGetCommonName(signercert
, &commonName
);
962 * SecCmsSignerInfoGetSignerEmailAddress - return the email address of the signer
964 * sinfo - signerInfo data for this signer
966 * Returns a CFStringRef containing the name of the signer.
967 * A return value of NULL is an error.
970 SecCmsSignerInfoGetSignerEmailAddress(SecCmsSignerInfoRef sinfo
)
972 SecCertificateRef signercert
;
973 CFStringRef emailAddress
= NULL
;
975 if ((signercert
= SecCmsSignerInfoGetSigningCertificate(sinfo
, NULL
)) == NULL
)
978 SecCertificateGetEmailAddress(signercert
, &emailAddress
);
985 * SecCmsSignerInfoAddAuthAttr - add an attribute to the
986 * authenticated (i.e. signed) attributes of "signerinfo".
989 SecCmsSignerInfoAddAuthAttr(SecCmsSignerInfoRef signerinfo
, SecCmsAttribute
*attr
)
991 return SecCmsAttributeArrayAddAttr(signerinfo
->cmsg
->poolp
, &(signerinfo
->authAttr
), attr
);
995 * SecCmsSignerInfoAddUnauthAttr - add an attribute to the
996 * unauthenticated attributes of "signerinfo".
999 SecCmsSignerInfoAddUnauthAttr(SecCmsSignerInfoRef signerinfo
, SecCmsAttribute
*attr
)
1001 return SecCmsAttributeArrayAddAttr(signerinfo
->cmsg
->poolp
, &(signerinfo
->unAuthAttr
), attr
);
1005 * SecCmsSignerInfoAddSigningTime - add the signing time to the
1006 * authenticated (i.e. signed) attributes of "signerinfo".
1008 * This is expected to be included in outgoing signed
1009 * messages for email (S/MIME) but is likely useful in other situations.
1011 * This should only be added once; a second call will do nothing.
1013 * XXX This will probably just shove the current time into "signerinfo"
1014 * but it will not actually get signed until the entire item is
1015 * processed for encoding. Is this (expected to be small) delay okay?
1018 SecCmsSignerInfoAddSigningTime(SecCmsSignerInfoRef signerinfo
, CFAbsoluteTime t
)
1020 SecCmsAttribute
*attr
;
1025 poolp
= signerinfo
->cmsg
->poolp
;
1027 mark
= PORT_ArenaMark(poolp
);
1029 /* create new signing time attribute */
1030 if (DER_CFDateToUTCTime(t
, &stime
) != SECSuccess
)
1033 if ((attr
= SecCmsAttributeCreate(poolp
, SEC_OID_PKCS9_SIGNING_TIME
, &stime
, PR_FALSE
)) == NULL
) {
1034 SECITEM_FreeItem (&stime
, PR_FALSE
);
1038 SECITEM_FreeItem (&stime
, PR_FALSE
);
1040 if (SecCmsSignerInfoAddAuthAttr(signerinfo
, attr
) != SECSuccess
)
1043 PORT_ArenaUnmark (poolp
, mark
);
1048 PORT_ArenaRelease (poolp
, mark
);
1053 * SecCmsSignerInfoAddSMIMECaps - add a SMIMECapabilities attribute to the
1054 * authenticated (i.e. signed) attributes of "signerinfo".
1056 * This is expected to be included in outgoing signed
1057 * messages for email (S/MIME).
1060 SecCmsSignerInfoAddSMIMECaps(SecCmsSignerInfoRef signerinfo
)
1062 SecCmsAttribute
*attr
;
1063 CSSM_DATA_PTR smimecaps
= NULL
;
1067 poolp
= signerinfo
->cmsg
->poolp
;
1069 mark
= PORT_ArenaMark(poolp
);
1071 smimecaps
= SECITEM_AllocItem(poolp
, NULL
, 0);
1072 if (smimecaps
== NULL
)
1075 /* create new signing time attribute */
1077 // @@@ We don't do Fortezza yet.
1078 if (SecSMIMECreateSMIMECapabilities((SecArenaPoolRef
)poolp
, smimecaps
, PR_FALSE
) != SECSuccess
)
1080 if (SecSMIMECreateSMIMECapabilities(poolp
, smimecaps
,
1081 PK11_FortezzaHasKEA(signerinfo
->cert
)) != SECSuccess
)
1085 if ((attr
= SecCmsAttributeCreate(poolp
, SEC_OID_PKCS9_SMIME_CAPABILITIES
, smimecaps
, PR_TRUE
)) == NULL
)
1088 if (SecCmsSignerInfoAddAuthAttr(signerinfo
, attr
) != SECSuccess
)
1091 PORT_ArenaUnmark (poolp
, mark
);
1095 PORT_ArenaRelease (poolp
, mark
);
1100 * SecCmsSignerInfoAddSMIMEEncKeyPrefs - add a SMIMEEncryptionKeyPreferences attribute to the
1101 * authenticated (i.e. signed) attributes of "signerinfo".
1103 * This is expected to be included in outgoing signed messages for email (S/MIME).
1106 SecCmsSignerInfoAddSMIMEEncKeyPrefs(SecCmsSignerInfoRef signerinfo
, SecCertificateRef cert
, SecKeychainRef keychainOrArray
)
1108 SecCmsAttribute
*attr
;
1109 CSSM_DATA_PTR smimeekp
= NULL
;
1116 /* verify this cert for encryption */
1117 policy
= CERT_PolicyForCertUsage(certUsageEmailRecipient
);
1118 if (CERT_VerifyCert(keychainOrArray
, cert
, policy
, CFAbsoluteTimeGetCurrent(), NULL
) != SECSuccess
) {
1125 poolp
= signerinfo
->cmsg
->poolp
;
1126 mark
= PORT_ArenaMark(poolp
);
1128 smimeekp
= SECITEM_AllocItem(poolp
, NULL
, 0);
1129 if (smimeekp
== NULL
)
1132 /* create new signing time attribute */
1133 if (SecSMIMECreateSMIMEEncKeyPrefs((SecArenaPoolRef
)poolp
, smimeekp
, cert
) != SECSuccess
)
1136 if ((attr
= SecCmsAttributeCreate(poolp
, SEC_OID_SMIME_ENCRYPTION_KEY_PREFERENCE
, smimeekp
, PR_TRUE
)) == NULL
)
1139 if (SecCmsSignerInfoAddAuthAttr(signerinfo
, attr
) != SECSuccess
)
1142 PORT_ArenaUnmark (poolp
, mark
);
1146 PORT_ArenaRelease (poolp
, mark
);
1151 * SecCmsSignerInfoAddMSSMIMEEncKeyPrefs - add a SMIMEEncryptionKeyPreferences attribute to the
1152 * authenticated (i.e. signed) attributes of "signerinfo", using the OID prefered by Microsoft.
1154 * This is expected to be included in outgoing signed messages for email (S/MIME),
1155 * if compatibility with Microsoft mail clients is wanted.
1158 SecCmsSignerInfoAddMSSMIMEEncKeyPrefs(SecCmsSignerInfoRef signerinfo
, SecCertificateRef cert
, SecKeychainRef keychainOrArray
)
1160 SecCmsAttribute
*attr
;
1161 CSSM_DATA_PTR smimeekp
= NULL
;
1168 /* verify this cert for encryption */
1169 policy
= CERT_PolicyForCertUsage(certUsageEmailRecipient
);
1170 if (CERT_VerifyCert(keychainOrArray
, cert
, policy
, CFAbsoluteTimeGetCurrent(), NULL
) != SECSuccess
) {
1177 poolp
= signerinfo
->cmsg
->poolp
;
1178 mark
= PORT_ArenaMark(poolp
);
1180 smimeekp
= SECITEM_AllocItem(poolp
, NULL
, 0);
1181 if (smimeekp
== NULL
)
1184 /* create new signing time attribute */
1185 if (SecSMIMECreateMSSMIMEEncKeyPrefs((SecArenaPoolRef
)poolp
, smimeekp
, cert
) != SECSuccess
)
1188 if ((attr
= SecCmsAttributeCreate(poolp
, SEC_OID_MS_SMIME_ENCRYPTION_KEY_PREFERENCE
, smimeekp
, PR_TRUE
)) == NULL
)
1191 if (SecCmsSignerInfoAddAuthAttr(signerinfo
, attr
) != SECSuccess
)
1194 PORT_ArenaUnmark (poolp
, mark
);
1198 PORT_ArenaRelease (poolp
, mark
);
1203 * SecCmsSignerInfoAddTimeStamp - add time stamp to the
1204 * unauthenticated (i.e. unsigned) attributes of "signerinfo".
1206 * This will initially be used for time stamping signed applications
1207 * by using a Time Stamping Authority. It may also be included in outgoing signed
1208 * messages for email (S/MIME), and may be useful in other situations.
1210 * This should only be added once; a second call will do nothing.
1215 Countersignature attribute values have ASN.1 type Countersignature:
1216 Countersignature ::= SignerInfo
1217 Countersignature values have the same meaning as SignerInfo values
1218 for ordinary signatures, except that:
1219 1. The signedAttributes field MUST NOT contain a content-type
1220 attribute; there is no content type for countersignatures.
1221 2. The signedAttributes field MUST contain a message-digest
1222 attribute if it contains any other attributes.
1223 3. The input to the message-digesting process is the contents octets
1224 of the DER encoding of the signatureValue field of the SignerInfo
1225 value with which the attribute is associated.
1230 @abstract Create a timestamp unsigned attribute with a TimeStampToken.
1234 SecCmsSignerInfoAddTimeStamp(SecCmsSignerInfoRef signerinfo
, CSSM_DATA
*tstoken
)
1236 SecCmsAttribute
*attr
;
1237 PLArenaPool
*poolp
= signerinfo
->cmsg
->poolp
;
1238 void *mark
= PORT_ArenaMark(poolp
);
1240 // We have already encoded this ourselves, so last param is PR_TRUE
1241 if ((attr
= SecCmsAttributeCreate(poolp
, SEC_OID_PKCS9_TIMESTAMP_TOKEN
, tstoken
, PR_TRUE
)) == NULL
)
1244 if (SecCmsSignerInfoAddUnauthAttr(signerinfo
, attr
) != SECSuccess
)
1247 PORT_ArenaUnmark (poolp
, mark
);
1252 PORT_ArenaRelease (poolp
, mark
);
1257 * SecCmsSignerInfoAddCounterSignature - countersign a signerinfo
1259 * 1. digest the DER-encoded signature value of the original signerinfo
1260 * 2. create new signerinfo with correct version, sid, digestAlg
1261 * 3. add message-digest authAttr, but NO content-type
1262 * 4. sign the authAttrs
1263 * 5. DER-encode the new signerInfo
1264 * 6. add the whole thing to original signerInfo's unAuthAttrs
1265 * as a SEC_OID_PKCS9_COUNTER_SIGNATURE attribute
1267 * XXXX give back the new signerinfo?
1270 SecCmsSignerInfoAddCounterSignature(SecCmsSignerInfoRef signerinfo
,
1271 SECOidTag digestalg
, SecIdentityRef identity
)
1278 * XXXX the following needs to be done in the S/MIME layer code
1279 * after signature of a signerinfo is verified
1282 SecCmsSignerInfoSaveSMIMEProfile(SecCmsSignerInfoRef signerinfo
)
1284 SecCertificateRef cert
= NULL
;
1285 CSSM_DATA_PTR profile
= NULL
;
1286 SecCmsAttribute
*attr
;
1287 CSSM_DATA_PTR utc_stime
= NULL
;
1291 Boolean must_free_cert
= PR_FALSE
;
1293 SecKeychainRef keychainOrArray
;
1295 status
= SecKeychainCopyDefault(&keychainOrArray
);
1297 /* sanity check - see if verification status is ok (unverified does not count...) */
1298 if (signerinfo
->verificationStatus
!= SecCmsVSGoodSignature
)
1301 /* find preferred encryption cert */
1302 if (!SecCmsArrayIsEmpty((void **)signerinfo
->authAttr
) &&
1303 (attr
= SecCmsAttributeArrayFindAttrByOidTag(signerinfo
->authAttr
,
1304 SEC_OID_SMIME_ENCRYPTION_KEY_PREFERENCE
, PR_TRUE
)) != NULL
)
1305 { /* we have a SMIME_ENCRYPTION_KEY_PREFERENCE attribute! */
1306 ekp
= SecCmsAttributeGetValue(attr
);
1310 /* we assume that all certs coming with the message have been imported to the */
1311 /* temporary database */
1312 cert
= SecSMIMEGetCertFromEncryptionKeyPreference(keychainOrArray
, ekp
);
1315 must_free_cert
= PR_TRUE
;
1319 /* no preferred cert found?
1320 * find the cert the signerinfo is signed with instead */
1321 CFStringRef emailAddress
=NULL
;
1323 cert
= SecCmsSignerInfoGetSigningCertificate(signerinfo
, keychainOrArray
);
1326 if (SecCertificateGetEmailAddress(cert
,&emailAddress
))
1330 /* verify this cert for encryption (has been verified for signing so far) */ /* don't verify this cert for encryption. It may just be a signing cert.
1331 * that's OK, we can still save the S/MIME profile. The encryption cert
1332 * should have already been saved */
1334 if (CERT_VerifyCert(keychainOrArray
, cert
, certUsageEmailRecipient
, CFAbsoluteTimeGetCurrent(), NULL
) != SECSuccess
) {
1336 CERT_DestroyCertificate(cert
);
1341 /* XXX store encryption cert permanently? */
1344 * Remember the current error set because we do not care about
1345 * anything set by the functions we are about to call.
1347 save_error
= PORT_GetError();
1349 if (!SecCmsArrayIsEmpty((void **)signerinfo
->authAttr
)) {
1350 attr
= SecCmsAttributeArrayFindAttrByOidTag(signerinfo
->authAttr
,
1351 SEC_OID_PKCS9_SMIME_CAPABILITIES
,
1353 profile
= SecCmsAttributeGetValue(attr
);
1354 attr
= SecCmsAttributeArrayFindAttrByOidTag(signerinfo
->authAttr
,
1355 SEC_OID_PKCS9_SIGNING_TIME
,
1357 utc_stime
= SecCmsAttributeGetValue(attr
);
1360 rv
= CERT_SaveSMimeProfile (cert
, profile
, utc_stime
);
1362 CERT_DestroyCertificate(cert
);
1365 * Restore the saved error in case the calls above set a new
1366 * one that we do not actually care about.
1368 PORT_SetError (save_error
);
1374 * SecCmsSignerInfoIncludeCerts - set cert chain inclusion mode for this signer
1377 SecCmsSignerInfoIncludeCerts(SecCmsSignerInfoRef signerinfo
, SecCmsCertChainMode cm
, SECCertUsage usage
)
1379 if (signerinfo
->cert
== NULL
)
1382 /* don't leak if we get called twice */
1383 if (signerinfo
->certList
!= NULL
) {
1384 CFRelease(signerinfo
->certList
);
1385 signerinfo
->certList
= NULL
;
1390 signerinfo
->certList
= NULL
;
1392 case SecCmsCMCertOnly
:
1393 signerinfo
->certList
= CERT_CertListFromCert(signerinfo
->cert
);
1395 case SecCmsCMCertChain
:
1396 signerinfo
->certList
= CERT_CertChainFromCert(signerinfo
->cert
, usage
, PR_FALSE
);
1398 case SecCmsCMCertChainWithRoot
:
1399 signerinfo
->certList
= CERT_CertChainFromCert(signerinfo
->cert
, usage
, PR_TRUE
);
1403 if (cm
!= SecCmsCMNone
&& signerinfo
->certList
== NULL
)