diff options
author | Dr. Stephen Henson <steve@openssl.org> | 2008-04-06 16:30:38 +0000 |
---|---|---|
committer | Dr. Stephen Henson <steve@openssl.org> | 2008-04-06 16:30:38 +0000 |
commit | fb4c24b6e76c511eb86fe90e5b0f0c8e80c28cc6 (patch) | |
tree | b9126af461beadc877ee4a39029654992a5f2353 /crypto/cms | |
parent | 1366f6b9bdce15a051da1a5f12e9fa74284d06ca (diff) |
Update from HEAD.
Diffstat (limited to 'crypto/cms')
-rw-r--r-- | crypto/cms/cms_sd.c | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/crypto/cms/cms_sd.c b/crypto/cms/cms_sd.c index 2b3c1c8dc7..591bfbec33 100644 --- a/crypto/cms/cms_sd.c +++ b/crypto/cms/cms_sd.c @@ -414,16 +414,17 @@ CMS_SignerInfo *CMS_add1_signer(CMS_ContentInfo *cms, if (!(flags & CMS_NOATTR)) { - /* Copy content type across */ - ASN1_OBJECT *ctype = - OBJ_dup(sd->encapContentInfo->eContentType); - if (!ctype) - goto merr; - i = CMS_signed_add1_attr_by_NID(si, NID_pkcs9_contentType, - V_ASN1_OBJECT, ctype, -1); - ASN1_OBJECT_free(ctype); - if (i <= 0) - goto merr; + /* Initialialize signed attributes strutucture so other + * attributes such as signing time etc are added later + * even if we add none here. + */ + if (!si->signedAttrs) + { + si->signedAttrs = sk_X509_ATTRIBUTE_new_null(); + if (!si->signedAttrs) + goto merr; + } + if (!(flags & CMS_NOSMIMECAP)) { STACK_OF(X509_ALGOR) *smcap = NULL; @@ -644,7 +645,8 @@ static void cms_fixup_mctx(EVP_MD_CTX *mctx, EVP_PKEY *pkey) #endif } -static int cms_SignerInfo_content_sign(CMS_SignerInfo *si, BIO *chain) +static int cms_SignerInfo_content_sign(CMS_ContentInfo *cms, + CMS_SignerInfo *si, BIO *chain) { EVP_MD_CTX mctx; int r = 0; @@ -664,6 +666,8 @@ static int cms_SignerInfo_content_sign(CMS_SignerInfo *si, BIO *chain) if (CMS_signed_get_attr_count(si) >= 0) { + ASN1_OBJECT *ctype = + cms->d.signedData->encapContentInfo->eContentType; unsigned char md[EVP_MAX_MD_SIZE]; unsigned int mdlen; EVP_DigestFinal_ex(&mctx, md, &mdlen); @@ -671,6 +675,10 @@ static int cms_SignerInfo_content_sign(CMS_SignerInfo *si, BIO *chain) V_ASN1_OCTET_STRING, md, mdlen)) goto err; + /* Copy content type across */ + if (CMS_signed_add1_attr_by_NID(si, NID_pkcs9_contentType, + V_ASN1_OBJECT, ctype, -1) <= 0) + goto err; if (!CMS_SignerInfo_sign(si)) goto err; } @@ -713,7 +721,7 @@ int cms_SignedData_final(CMS_ContentInfo *cms, BIO *chain) for (i = 0; i < sk_CMS_SignerInfo_num(sinfos); i++) { si = sk_CMS_SignerInfo_value(sinfos, i); - if (!cms_SignerInfo_content_sign(si, chain)) + if (!cms_SignerInfo_content_sign(cms, si, chain)) return 0; } cms->d.signedData->encapContentInfo->partial = 0; |