diff options
| author | tb <> | 2025-12-20 07:22:43 +0000 |
|---|---|---|
| committer | tb <> | 2025-12-20 07:22:43 +0000 |
| commit | 4e99a5c0b6fa18eb76160d4cb726840aacb45404 (patch) | |
| tree | b0d0acb9f140921d9cf4cbf885ff5bb8d5588b85 /src | |
| parent | a9b40e5ff0d02898290bff32f585973bf373feb5 (diff) | |
| download | openbsd-4e99a5c0b6fa18eb76160d4cb726840aacb45404.tar.gz openbsd-4e99a5c0b6fa18eb76160d4cb726840aacb45404.tar.bz2 openbsd-4e99a5c0b6fa18eb76160d4cb726840aacb45404.zip | |
pkcs7: add PKCS7_NO_DUAL_CONTENT flag/behavior
What Netscape fucked up just had to be embraced by secure boot and
other nonsense. First OpenSSL wanted to be strict (which we inherited)
then Rich Salz Postel-ized this and made OpenSSL bypass this check by
default and added a flag to be strict 10 years ago.
Now sthen found that PHP 8.5 uses/exposes this flag.
Follows OpenSSL 6b2ebe43 (2016)
ok kenjiro
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/libcrypto/man/PKCS7_verify.3 | 13 | ||||
| -rw-r--r-- | src/lib/libcrypto/pkcs7/pk7_smime.c | 23 | ||||
| -rw-r--r-- | src/lib/libcrypto/pkcs7/pkcs7.h | 3 |
3 files changed, 27 insertions, 12 deletions
diff --git a/src/lib/libcrypto/man/PKCS7_verify.3 b/src/lib/libcrypto/man/PKCS7_verify.3 index 6bf932b54b..53b32f738a 100644 --- a/src/lib/libcrypto/man/PKCS7_verify.3 +++ b/src/lib/libcrypto/man/PKCS7_verify.3 | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | .\" $OpenBSD: PKCS7_verify.3,v 1.12 2025/06/08 22:40:30 schwarze Exp $ | 1 | .\" $OpenBSD: PKCS7_verify.3,v 1.13 2025/12/20 07:22:43 tb Exp $ |
| 2 | .\" OpenSSL a528d4f0 Oct 27 13:40:11 2015 -0400 | 2 | .\" OpenSSL a528d4f0 Oct 27 13:40:11 2015 -0400 |
| 3 | .\" | 3 | .\" |
| 4 | .\" This file was written by Dr. Stephen Henson <steve@openssl.org>. | 4 | .\" This file was written by Dr. Stephen Henson <steve@openssl.org>. |
| @@ -48,7 +48,7 @@ | |||
| 48 | .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | 48 | .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED |
| 49 | .\" OF THE POSSIBILITY OF SUCH DAMAGE. | 49 | .\" OF THE POSSIBILITY OF SUCH DAMAGE. |
| 50 | .\" | 50 | .\" |
| 51 | .Dd $Mdocdate: June 8 2025 $ | 51 | .Dd $Mdocdate: December 20 2025 $ |
| 52 | .Dt PKCS7_VERIFY 3 | 52 | .Dt PKCS7_VERIFY 3 |
| 53 | .Os | 53 | .Os |
| 54 | .Sh NAME | 54 | .Sh NAME |
| @@ -125,6 +125,15 @@ is detached, | |||
| 125 | .Fa indata | 125 | .Fa indata |
| 126 | cannot be | 126 | cannot be |
| 127 | .Dv NULL . | 127 | .Dv NULL . |
| 128 | If the content is not detached and | ||
| 129 | .Fa indata | ||
| 130 | is not | ||
| 131 | .Fa NULL , | ||
| 132 | then the structure has both embedded and external content. | ||
| 133 | To treat this as an error, use the flag | ||
| 134 | .Dv PKCS7_NO_DUAL_CONTENT . | ||
| 135 | The default behavior allows this, for compatibility with other | ||
| 136 | implementations. | ||
| 128 | .Pp | 137 | .Pp |
| 129 | An attempt is made to locate all the signer's certificates, first | 138 | An attempt is made to locate all the signer's certificates, first |
| 130 | looking in the | 139 | looking in the |
diff --git a/src/lib/libcrypto/pkcs7/pk7_smime.c b/src/lib/libcrypto/pkcs7/pk7_smime.c index 32f28f0505..9baff7f525 100644 --- a/src/lib/libcrypto/pkcs7/pk7_smime.c +++ b/src/lib/libcrypto/pkcs7/pk7_smime.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: pk7_smime.c,v 1.28 2025/05/10 05:54:38 tb Exp $ */ | 1 | /* $OpenBSD: pk7_smime.c,v 1.29 2025/12/20 07:22:43 tb Exp $ */ |
| 2 | /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL | 2 | /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL |
| 3 | * project. | 3 | * project. |
| 4 | */ | 4 | */ |
| @@ -277,14 +277,19 @@ PKCS7_verify(PKCS7 *p7, STACK_OF(X509) *certs, X509_STORE *store, BIO *indata, | |||
| 277 | return 0; | 277 | return 0; |
| 278 | } | 278 | } |
| 279 | 279 | ||
| 280 | /* | 280 | if ((flags & PKCS7_NO_DUAL_CONTENT) != 0) { |
| 281 | * Very old Netscape illegally included empty content with | 281 | /* |
| 282 | * a detached signature. Very old users should upgrade. | 282 | * This was originally "#if 0" because we thought that only old |
| 283 | */ | 283 | * broken Netscape did this. It turns out that Authenticode |
| 284 | /* Check for data and content: two sets of data */ | 284 | * uses this kind of "extended" PKCS7 format, and things like |
| 285 | if (!PKCS7_get_detached(p7) && indata) { | 285 | * UEFI secure boot and tools like osslsigncode need it. In |
| 286 | PKCS7error(PKCS7_R_CONTENT_AND_DATA_PRESENT); | 286 | * Authenticode the verification process is different, but the |
| 287 | return 0; | 287 | * existing PKCS7 verification works. |
| 288 | */ | ||
| 289 | if (!PKCS7_get_detached(p7) && indata != NULL) { | ||
| 290 | PKCS7error(PKCS7_R_CONTENT_AND_DATA_PRESENT); | ||
| 291 | return 0; | ||
| 292 | } | ||
| 288 | } | 293 | } |
| 289 | 294 | ||
| 290 | sinfos = PKCS7_get_signer_info(p7); | 295 | sinfos = PKCS7_get_signer_info(p7); |
diff --git a/src/lib/libcrypto/pkcs7/pkcs7.h b/src/lib/libcrypto/pkcs7/pkcs7.h index 6f0ccc0dc8..bac461d30d 100644 --- a/src/lib/libcrypto/pkcs7/pkcs7.h +++ b/src/lib/libcrypto/pkcs7/pkcs7.h | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: pkcs7.h,v 1.24 2025/07/02 10:24:17 tb Exp $ */ | 1 | /* $OpenBSD: pkcs7.h,v 1.25 2025/12/20 07:22:43 tb Exp $ */ |
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
| 3 | * All rights reserved. | 3 | * All rights reserved. |
| 4 | * | 4 | * |
| @@ -241,6 +241,7 @@ DECLARE_PKCS12_STACK_OF(PKCS7) | |||
| 241 | #define PKCS7_NOCRL 0x2000 | 241 | #define PKCS7_NOCRL 0x2000 |
| 242 | #define PKCS7_PARTIAL 0x4000 | 242 | #define PKCS7_PARTIAL 0x4000 |
| 243 | #define PKCS7_REUSE_DIGEST 0x8000 | 243 | #define PKCS7_REUSE_DIGEST 0x8000 |
| 244 | #define PKCS7_NO_DUAL_CONTENT 0x10000 | ||
| 244 | 245 | ||
| 245 | /* Flags: for compatibility with older code */ | 246 | /* Flags: for compatibility with older code */ |
| 246 | 247 | ||
