public inbox for linux-crypto@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 0/5] pkcs7: better handling of signed attributes
@ 2026-02-25 21:19 James Bottomley
  2026-02-25 21:19 ` [PATCH v3 1/5] certs: break out pkcs7 check into its own function James Bottomley
                   ` (5 more replies)
  0 siblings, 6 replies; 23+ messages in thread
From: James Bottomley @ 2026-02-25 21:19 UTC (permalink / raw)
  To: linux-crypto; +Cc: David Howells, Blaise Boscaccy

v3 updates for the now-upstream ml-dsa.  The ml-dsa patches actually
changed the definition of authattrs in struct pkcs7_signed_info, which
means I now don't have to justify stepping one back in patch 4
(thanks!).  Just in case I checked that nothing else was affected by
this change.

Original cover letter:

Although the biggest use of signed attributes is PKCS#7 and X509
specific data, they can be added to a signature to support arbitrary
and verifiable objects.  This makes them particularly useful when you
want to take an existing signature scheme and extend it with
additional (but always verified) data in such a way that it still
looks valid to both the old and new schemes.

To use a scheme like this to extend signatures requires that the
authenticated attribute only be pulled out of a signer info that can
be verified by one of the trusted keys, so the implementation loops
over all signer infos, discarding those that haven't been verified and
returns the first OID match it finds in the verified ones.  Note that
if you reparse a pkcs7 it starts out with no trusted signer infos, and
you must anchor trust by calling validate_pkcs7_trust() with the
trusted keyring.

The first three patches in this series are new to v2.  They add the
new validate_pkcs7_trust() call, thread a verified flag through struct
pkcs7_signer_info so we can tell which signers have been validated
against the trusted keyring. And finally thread pkcs7_digest through
the pkcs7_validate functions so they can operate on a plain parsed
pkcs7 structure that hasn't gone through pkcs7_verify.  Note we could
simply drop the last patch and insist that the pkcs7 be re-verified;
it just looked a bit inefficient, especially as the default way of
doing this (verify_pkcs7_signature() frees the pkcs7 structure before
returning.

The final two patches search for the authenticated attribute by OID,
stopping at the first one it finds belonging to a verified signer
info.  The final patch demonstrates how to use it.  I've added a check
to show that if you don't in any way validate the pkcs7 then no signed
attributes get returned.

Regards,

James

---

James Bottomley (5):
  certs: break out pkcs7 check into its own function
  crypto: pkcs7: add flag for validated trust on a signed info block
  crypto: pkcs7: allow pkcs7_digest() to be called from pkcs7_trust
  crypto: pkcs7: add ability to extract signed attributes by OID
  crypto: pkcs7: add tests for pkcs7_get_authattr

 certs/system_keyring.c                  | 76 +++++++++++++----------
 crypto/asymmetric_keys/Makefile         |  4 +-
 crypto/asymmetric_keys/pkcs7_aa.asn1    | 18 ++++++
 crypto/asymmetric_keys/pkcs7_key_type.c | 42 ++++++++++++-
 crypto/asymmetric_keys/pkcs7_parser.c   | 81 +++++++++++++++++++++++++
 crypto/asymmetric_keys/pkcs7_parser.h   |  4 ++
 crypto/asymmetric_keys/pkcs7_trust.c    |  9 +++
 crypto/asymmetric_keys/pkcs7_verify.c   | 13 ++--
 include/crypto/pkcs7.h                  |  4 ++
 include/linux/verification.h            |  2 +
 10 files changed, 216 insertions(+), 37 deletions(-)
 create mode 100644 crypto/asymmetric_keys/pkcs7_aa.asn1

-- 
2.51.0


^ permalink raw reply	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2026-03-05 22:12 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-25 21:19 [PATCH v3 0/5] pkcs7: better handling of signed attributes James Bottomley
2026-02-25 21:19 ` [PATCH v3 1/5] certs: break out pkcs7 check into its own function James Bottomley
2026-02-25 21:19 ` [PATCH v3 2/5] crypto: pkcs7: add flag for validated trust on a signed info block James Bottomley
2026-02-25 21:19 ` [PATCH v3 3/5] crypto: pkcs7: allow pkcs7_digest() to be called from pkcs7_trust James Bottomley
2026-02-26 20:31   ` Eric Biggers
2026-02-27  3:50     ` James Bottomley
2026-03-05  7:58       ` Eric Biggers
2026-03-05 14:53         ` James Bottomley
2026-03-05 18:50           ` Eric Biggers
2026-03-05 20:11             ` James Bottomley
2026-03-05 21:36               ` Eric Biggers
2026-03-05 22:06                 ` James Bottomley
2026-02-25 21:19 ` [PATCH v3 4/5] crypto: pkcs7: add ability to extract signed attributes by OID James Bottomley
2026-02-25 21:19 ` [PATCH v3 5/5] crypto: pkcs7: add tests for pkcs7_get_authattr James Bottomley
2026-02-26  1:12   ` kernel test robot
2026-02-26  2:13 ` [PATCH v3 0/5] pkcs7: better handling of signed attributes Eric Biggers
2026-02-26 12:43   ` James Bottomley
2026-03-05  7:55     ` Eric Biggers
2026-03-05 14:46       ` James Bottomley
2026-03-05 18:51         ` Eric Biggers
2026-03-05 20:18           ` James Bottomley
2026-03-05 21:40             ` Eric Biggers
2026-03-05 22:11               ` James Bottomley

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox