summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortb <>2026-06-09 12:12:34 +0000
committertb <>2026-06-09 12:12:34 +0000
commit77ad4436cc0876666030d6cc1ca6e7be853ef788 (patch)
tree1d26e2aa19957cd1d59d7491987c45f9e95c8822 /src
parent2e00d0bb059dae7f2a099952fda78cd682f5b3e4 (diff)
downloadopenbsd-77ad4436cc0876666030d6cc1ca6e7be853ef788.tar.gz
openbsd-77ad4436cc0876666030d6cc1ca6e7be853ef788.tar.bz2
openbsd-77ad4436cc0876666030d6cc1ca6e7be853ef788.zip
Avoid NULL dereference in password-based CMS decryption
The keyDerivationAlgorithm field is OPTIONAL in the ASN.1 but required for password-based CMS. Check that the field is present before using it to avoid a crash. From Igor Ustinov via OpenSSL
Diffstat (limited to 'src')
-rw-r--r--src/lib/libcrypto/cms/cms_pwri.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/lib/libcrypto/cms/cms_pwri.c b/src/lib/libcrypto/cms/cms_pwri.c
index f64f4ab68c..d282d1d42f 100644
--- a/src/lib/libcrypto/cms/cms_pwri.c
+++ b/src/lib/libcrypto/cms/cms_pwri.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: cms_pwri.c,v 1.35 2025/09/30 12:51:16 tb Exp $ */ 1/* $OpenBSD: cms_pwri.c,v 1.36 2026/06/09 12:12:34 tb Exp $ */
2/* 2/*
3 * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 3 * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
4 * project. 4 * project.
@@ -386,6 +386,10 @@ cms_RecipientInfo_pwri_crypt(CMS_ContentInfo *cms, CMS_RecipientInfo *ri,
386 } 386 }
387 387
388 algtmp = pwri->keyDerivationAlgorithm; 388 algtmp = pwri->keyDerivationAlgorithm;
389 if (algtmp == NULL) {
390 CMSerror(CMS_R_INVALID_KEY_ENCRYPTION_PARAMETER);
391 goto err;
392 }
389 393
390 /* Finish password based key derivation to setup key in "ctx" */ 394 /* Finish password based key derivation to setup key in "ctx" */
391 395