summaryrefslogtreecommitdiffstats
path: root/crypto/cms
diff options
context:
space:
mode:
authorDr. Stephen Henson <steve@openssl.org>2014-05-08 13:10:56 +0100
committerDr. Stephen Henson <steve@openssl.org>2014-05-09 14:24:53 +0100
commit2c4144638ae7739871db0574265952dc350c5dfa (patch)
treeaca6261773f6d0ad4a52103754bcdea9038f436c /crypto/cms
parent2fc04cb8728aafe9016569947d64763b5b106594 (diff)
Return an error if no recipient type matches.
If the key type does not match any CMS recipient type return an error instead of using a random key (MMA mitigation). This does not leak any useful information to an attacker. PR#3348 (cherry picked from commit bd43b4cf778a53ffa5d77510ecd408a009dc00d2)
Diffstat (limited to 'crypto/cms')
-rw-r--r--crypto/cms/cms_smime.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/crypto/cms/cms_smime.c b/crypto/cms/cms_smime.c
index 204595b908..d2b9eec3dd 100644
--- a/crypto/cms/cms_smime.c
+++ b/crypto/cms/cms_smime.c
@@ -637,7 +637,7 @@ int CMS_decrypt_set1_pkey(CMS_ContentInfo *cms, EVP_PKEY *pk, X509 *cert)
STACK_OF(CMS_RecipientInfo) *ris;
CMS_RecipientInfo *ri;
int i, r, ri_type;
- int debug = 0;
+ int debug = 0, match_ri = 0;
ris = CMS_get0_RecipientInfos(cms);
if (ris)
debug = cms->d.envelopedData->encryptedContentInfo->debug;
@@ -654,6 +654,7 @@ int CMS_decrypt_set1_pkey(CMS_ContentInfo *cms, EVP_PKEY *pk, X509 *cert)
ri = sk_CMS_RecipientInfo_value(ris, i);
if (CMS_RecipientInfo_type(ri) != ri_type)
continue;
+ match_ri = 1;
if (ri_type == CMS_RECIPINFO_AGREE)
{
r = cms_kari_set1_pkey(cms, ri, pk, cert);
@@ -697,7 +698,7 @@ int CMS_decrypt_set1_pkey(CMS_ContentInfo *cms, EVP_PKEY *pk, X509 *cert)
}
}
/* If no cert and not debugging always return success */
- if (!cert && !debug)
+ if (match_ri && !cert && !debug)
{
ERR_clear_error();
return 1;