mirror-linux/include/crypto
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
..
internal This update includes the following changes: 2025-12-03 11:28:38 -08:00
acompress.h crypto: acomp - Clone folios properly 2025-05-05 18:20:45 +08:00
aead.h crypto: aead - Add support for on-stack AEAD req allocation 2025-10-31 17:43:56 +08:00
aes.h crypto: lib - implement library version of AES in CFB mode 2024-05-09 22:30:51 +03:00
akcipher.h crypto: akcipher - Drop sign/verify operations 2024-10-05 13:22:04 +08:00
algapi.h Revert "crypto: scatterwalk - Move skcipher walk and use it for memcpy_sglist" 2025-11-22 10:04:50 +08:00
arc4.h
aria.h
authenc.h crypto: Add 'krb5enc' hash and cipher AEAD algorithm 2025-03-02 21:39:34 +00:00
b128ops.h
blake2b.h crypto: blake2b - Reimplement using library API 2025-10-29 22:04:24 -07:00
blake2s.h lib/crypto: blake2s: Document the BLAKE2s library API 2025-10-29 22:04:24 -07:00
blowfish.h
cast5.h
cast6.h
cast_common.h
chacha.h lib/crypto: chacha: Add at_least decoration to fixed-size array params 2025-11-23 12:19:47 -08:00
chacha20poly1305.h lib/crypto: chacha20poly1305: Statically check fixed array lengths 2025-11-23 12:19:21 -08:00
cryptd.h
ctr.h crypto: ctr - Remove unnecessary header inclusions 2025-04-16 15:16:21 +08:00
curve25519.h lib/crypto: curve25519: Add at_least decoration to fixed-size array params 2025-11-23 12:19:47 -08:00
des.h
df_sp80090a.h crypto: drbg - Replace AES cipher calls with library calls 2025-10-17 16:03:57 +08:00
dh.h
drbg.h crypto: drbg - Export CTR DRBG DF functions 2025-10-17 16:03:57 +08:00
ecc_curve.h crypto: ecc - Add nbits field to ecc_curve structure 2024-04-12 15:07:52 +08:00
ecdh.h crypto: ecc - Add NIST P521 curve parameters 2024-04-12 15:07:52 +08:00
engine.h crypto: engine - remove request batching support 2025-07-18 20:52:00 +10:00
gcm.h
gf128mul.h crypto: lib/gf128mul - Remove some bbe deadcode 2024-12-21 22:46:24 +08:00
ghash.h crypto: riscv/ghash - Use API partial block handling 2025-04-23 11:33:47 +08:00
hash.h crypto: hash - Make HASH_MAX_DESCSIZE a bit more obvious 2025-08-22 17:28:44 +08:00
hash_info.h crypto: FIPS 202 SHA-3 register in hash info for IMA 2023-10-27 18:04:30 +08:00
hkdf.h crypto,fs: Separate out hkdf_extract() and hkdf_expand() 2025-03-20 16:53:53 -07:00
hmac.h
if_alg.h crypto: af_alg - Fix incorrect boolean values in af_alg_ctx 2025-09-24 14:43:32 -07:00
kdf_sp800108.h
kpp.h crypto: remove CONFIG_CRYPTO_STATS 2024-04-02 10:49:38 +08:00
krb5.h rxrpc: Add the security index for yfs-rxgk 2025-04-14 17:36:41 -07:00
md5.h lib/crypto: md5: Add at_least decoration to fixed-size array params 2025-11-23 12:19:47 -08:00
mldsa.h lib/crypto: Add ML-DSA verification support 2026-01-12 11:07:49 -08:00
nh.h lib/crypto: nh: Add NH library 2026-01-12 11:07:49 -08:00
null.h crypto: null - remove the default null skcipher 2025-05-12 13:32:53 +08:00
padlock.h
pcrypt.h
pkcs7.h
poly1305.h lib/crypto: poly1305: Add at_least decoration to fixed-size array params 2025-11-23 12:19:47 -08:00
polyval.h lib/crypto: x86/polyval: Migrate optimized code into library 2025-11-11 11:03:38 -08:00
public_key.h pkcs7: Allow the signing algo to do whatever digestion it wants itself 2026-01-30 11:33:19 +00:00
rng.h crypto: ansi_cprng - Remove unused ansi_cprng algorithm 2025-11-22 10:04:50 +08:00
scatterwalk.h Revert "crypto: scatterwalk - Move skcipher walk and use it for memcpy_sglist" 2025-11-22 10:04:50 +08:00
serpent.h
sha1.h lib/crypto: sha1: Add at_least decoration to fixed-size array params 2025-11-23 12:19:47 -08:00
sha2.h lib/crypto: sha2: Add at_least decoration to fixed-size array params 2025-11-23 12:19:47 -08:00
sha3.h crypto: sha3 - Reimplement using library API 2025-11-05 20:30:51 -08:00
sig.h crypto: ecdsa - Fix NIST P521 key size reported by KEYCTL_PKEY_QUERY 2025-04-16 15:16:21 +08:00
skcipher.h crypto: skcipher - Set tfm in SYNC_SKCIPHER_REQUEST_ON_STACK 2025-02-22 15:56:03 +08:00
sm3.h crypto: lib/sm3 - Remove partial block helpers 2025-04-23 15:52:47 +08:00
sm3_base.h crypto: lib/sm3 - Remove partial block helpers 2025-04-23 15:52:47 +08:00
sm4.h
streebog.h crypto: streebog - Use API partial block handling 2025-05-05 18:20:44 +08:00
twofish.h
utils.h move asm/unaligned.h to linux/unaligned.h 2024-10-02 17:23:23 -04:00
xts.h