File: pkcs7-verification.patch

package info (click to toggle)
wolfssl 5.9.0-0.2
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 125,492 kB
  • sloc: ansic: 1,677,618; asm: 527,601; sh: 13,308; cs: 6,596; xml: 5,175; ada: 4,141; perl: 3,291; makefile: 2,266; python: 799; javascript: 748; cpp: 131; ruby: 118; objc: 80; tcl: 73
file content (30 lines) | stat: -rw-r--r-- 1,491 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
Origin: https://github.com/haxtibal/wolfssl/commit/7af95eecfa56155cafa15ee45b0ff02877eee1e8
From: Tobias Deiminger <tobias.deiminger@posteo.de>
Date: Fri, 27 Mar 2026 21:48:36 +0100
Subject: wolfcrypt/src/pkcs7.c: Fix PKCS#7 verification for digestAlgorithm.parameters = NULL

RFC 8017 hardcodes DER serialization samples of DigestInfo, where the
parameter part is always NULL (05 00) for any hash algorithm. This value
does therefore *not* depend on SignerInfo.digestAlgorithm.parameters.
WolfSSL wrongly assumed and implemented such a dependency.

This non-conformance caused an interoperability bug with OpenSSL: A
signature created with openssl cms (SHA-2) could not be verified in
WolfSSL. OpenSSL leaves SignerInfo.digestAlgorithm.parameters absent,
and adds explicit NULL to DigestInfo. WolfSSL saw the absence and
wrongly inferred DigestInfo would have no explicit NULL - but it has -
leading to size mismatch.
---
--- a/wolfcrypt/src/pkcs7.c
+++ b/wolfcrypt/src/pkcs7.c
@@ -4771,9 +4771,7 @@ static int wc_PKCS7_BuildSignedDataDigest(wc_PKCS7* pkcs7, byte* signedAttrib,
         }
     }

-    /* Set algoID, match whatever was input to match either NULL or absent */
-    algoIdSz = SetAlgoIDEx(pkcs7->hashOID, algoId, oidHashType,
-                            0, pkcs7->hashParamsAbsent);
+    algoIdSz = SetAlgoID(pkcs7->hashOID, algoId, oidHashType, 0);

     digestStrSz = SetOctetString(hashSz, digestStr);
     digestInfoSeqSz = SetSequence(algoIdSz + digestStrSz + hashSz,