Prepare for 1.0.1l-dev
[openssl.git] / crypto / cms / cms_lib.c
index 6c0d5c097cc213fd35cb978fb17926f17003d2ba..ba08279a046196b77e8a86a0de40d73518718db6 100644 (file)
@@ -406,11 +406,12 @@ int cms_DigestAlgorithm_find_ctx(EVP_MD_CTX *mctx, BIO *chain,
                        return 0;
                        }
                BIO_get_md_ctx(chain, &mtmp);
-               if (EVP_MD_CTX_type(mtmp) == nid)
-                       {
-                       EVP_MD_CTX_copy_ex(mctx, mtmp);
-                       return 1;
-                       }
+               if (EVP_MD_CTX_type(mtmp) == nid
+               /* Workaround for broken implementations that use signature
+                * algorithm  OID instead of digest.
+                */
+                       || EVP_MD_pkey_type(EVP_MD_CTX_md(mtmp)) == nid)
+                       return EVP_MD_CTX_copy_ex(mctx, mtmp);
                chain = BIO_next(chain);
                }
        }
@@ -462,8 +463,6 @@ int CMS_add0_cert(CMS_ContentInfo *cms, X509 *cert)
        STACK_OF(CMS_CertificateChoices) **pcerts;
        int i;
        pcerts = cms_get0_certificate_choices(cms);
-       if (!pcerts)
-               return 0;
        if (!pcerts)
                return 0;
        for (i = 0; i < sk_CMS_CertificateChoices_num(*pcerts); i++)