summaryrefslogtreecommitdiffstats
path: root/crypto/cms
diff options
context:
space:
mode:
authorFdaSilvaYY <fdasilvayy@gmail.com>2019-01-29 23:54:30 +0100
committerShane Lontis <shane.lontis@oracle.com>2019-05-29 11:14:46 +1000
commit8c89c80a5580419bcc3e35abf18dd187c73881e4 (patch)
treecab49a3e79269da6031538f81215433f0802f22e /crypto/cms
parentf4a96507fb880d5f5a707c138388cb8b5b1ba8c8 (diff)
CAdES: Fix SignerInfo attribute construction order.
Reviewed-by: Matt Caswell <matt@openssl.org> Reviewed-by: Shane Lontis <shane.lontis@oracle.com> (Merged from https://github.com/openssl/openssl/pull/8117)
Diffstat (limited to 'crypto/cms')
-rw-r--r--crypto/cms/cms_sd.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/crypto/cms/cms_sd.c b/crypto/cms/cms_sd.c
index 71b3041116..65261cf470 100644
--- a/crypto/cms/cms_sd.c
+++ b/crypto/cms/cms_sd.c
@@ -325,13 +325,6 @@ CMS_SignerInfo *CMS_add1_signer(CMS_ContentInfo *cms,
if (!i)
goto merr;
}
- if (flags & CMS_REUSE_DIGEST) {
- if (!cms_copy_messageDigest(cms, si))
- goto err;
- if (!(flags & (CMS_PARTIAL | CMS_KEY_PARAM)) &&
- !CMS_SignerInfo_sign(si))
- goto err;
- }
if (flags & CMS_CADES) {
ESS_SIGNING_CERT *sc = NULL;
ESS_SIGNING_CERT_V2 *sc2 = NULL;
@@ -353,6 +346,13 @@ CMS_SignerInfo *CMS_add1_signer(CMS_ContentInfo *cms,
if (!add_sc)
goto err;
}
+ if (flags & CMS_REUSE_DIGEST) {
+ if (!cms_copy_messageDigest(cms, si))
+ goto err;
+ if (!(flags & (CMS_PARTIAL | CMS_KEY_PARAM)) &&
+ !CMS_SignerInfo_sign(si))
+ goto err;
+ }
}
if (!(flags & CMS_NOCERTS)) {
@@ -370,8 +370,7 @@ CMS_SignerInfo *CMS_add1_signer(CMS_ContentInfo *cms,
goto err;
if (EVP_PKEY_CTX_set_signature_md(si->pctx, md) <= 0)
goto err;
- } else if (EVP_DigestSignInit(si->mctx, &si->pctx, md, NULL, pk) <=
- 0)
+ } else if (EVP_DigestSignInit(si->mctx, &si->pctx, md, NULL, pk) <= 0)
goto err;
}