mirror-linux/include
David Howells f3eccecd78 pkcs7: Allow the signing algo to do whatever digestion it wants itself
Allow the data to be verified in a PKCS#7 or CMS message to be passed
directly to an asymmetric cipher algorithm (e.g. ML-DSA) if it wants to do
whatever passes for hashing/digestion itself.  The normal digestion of the
data is then skipped as that would be ignored unless another signed info in
the message has some other algorithm that needs it.

The 'data to be verified' may be the content of the PKCS#7 message or it
will be the authenticatedAttributes (signedAttrs if CMS), modified, if
those are present.

This is done by:

 (1) Make ->m and ->m_size point to the data to be verified rather than
     making public_key_verify_signature() access the data directly.  This
     is so that keyctl(KEYCTL_PKEY_VERIFY) will still work.

 (2) Add a flag, ->algo_takes_data, to indicate that the verification
     algorithm wants to access the data to be verified directly rather than
     having it digested first.

 (3) If the PKCS#7 message has authenticatedAttributes (or CMS
     signedAttrs), then the digest contained therein will be validated as
     now, and the modified attrs blob will either be digested or assigned
     to ->m as appropriate.

 (4) If present, always copy and modify the authenticatedAttributes (or
     signedAttrs) then digest that in one go rather than calling the shash
     update twice (once for the tag and once for the rest).

 (5) For ML-DSA, point ->m to the TBSCertificate instead of digesting it
     and using the digest.

Note that whilst ML-DSA does allow for an "external mu", CMS doesn't yet
have that standardised.

Signed-off-by: David Howells <dhowells@redhat.com>
cc: Lukas Wunner <lukas@wunner.de>
cc: Ignat Korchagin <ignat@cloudflare.com>
cc: Stephan Mueller <smueller@chronox.de>
cc: Eric Biggers <ebiggers@kernel.org>
cc: Herbert Xu <herbert@gondor.apana.org.au>
cc: keyrings@vger.kernel.org
cc: linux-crypto@vger.kernel.org
2026-01-30 11:33:19 +00:00
..
acpi ACPI: PCI: IRQ: Fix INTx GSIs signedness 2026-01-05 19:06:40 +01:00
asm-generic hyperv-next for v6.19 2025-12-09 06:10:17 +09:00
clocksource
crypto pkcs7: Allow the signing algo to do whatever digestion it wants itself 2026-01-30 11:33:19 +00:00
cxl
drm drm-misc-fixes for v6.19-rc5: 2026-01-08 07:41:00 +10:00
dt-bindings This pull request is entirely SoC clk drivers, not for lack of trying to modify 2025-12-08 09:38:52 +09:00
hyperv mshv: Add definitions for MSHV sleep state configuration 2025-12-05 23:24:57 +00:00
keys
kunit kunit: Enforce task execution in {soft,hard}irq contexts 2025-12-22 12:20:08 -08:00
kvm
linux treewide: Update email address 2026-01-11 06:09:11 -10:00
math-emu
media
memory
misc
net net: dsa: properly keep track of conduit reference 2025-12-23 10:32:08 +01:00
pcmcia
ras Significant patch series in this merge are as follows: 2025-12-05 13:52:43 -08:00
rdma
rv
scsi
soc This pull request is entirely SoC clk drivers, not for lack of trying to modify 2025-12-08 09:38:52 +09:00
sound ASoC: soc-acpi / SOF: Add best_effort flag to get_function_tplg_files op 2025-12-15 23:08:35 +09:00
target
trace nfsd-6.19 fixes: 2026-01-06 09:12:52 -08:00
uapi treewide: Update email address 2026-01-11 06:09:11 -10:00
ufs
vdso
video
xen
Kbuild