pkcs7: better handling of signed attributes
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v4 Latest3 patches 0 repliesNew
- v35 patches 16 repliesSuperseded
- v25 patches 0 repliesSuperseded
Earlier versions · 1
| Version | Posted | Patches | Replies | Status |
|---|---|---|---|---|
| v1 | 2 patches | 4 replies | Superseded |
Patches in v4 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/3 | crypto: pkcs7: add flag for validated trust on a signed info blockcerts/ crypto/ crypto/ | +3 | 0 replies | |
| 2/3 | crypto: pkcs7: add ability to extract signed attributes by OIDcrypto/ crypto/ crypto/ +1 more | +106 | 0 replies | |
| 3/3 | crypto: pkcs7: add tests for pkcs7_get_authattrcrypto/ | +43 | 0 replies |
Reviews trailers per patch
1 of 3 patches has a Reviewed-by or Acked-by.
| Patch | David Howells |
|---|---|
| 1/3 | |
| 2/3 | |
| 3/3 | A-b |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.
Cover letter [PATCH v4 0/3] pkcs7: better handling of signed attributes
v4: the patch set got much smaller thanks to dumping the ability to verify only the signature itself without having to supply the buffer for verification (all potential consumers confirmed they have the buffer and it's not a huge overhead). So the use flow now is parse the pkcs7, call the existing verify_pkcs7_message_sig to get the trust for the signed attributes and then extract them.
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 (3):
crypto: pkcs7: add flag for validated trust on a signed info block
crypto: pkcs7: add ability to extract signed attributes by OID
crypto: pkcs7: add tests for pkcs7_get_authattr
certs/system_keyring.c | 1 + crypto/asymmetric_keys/Makefile | 4 +- crypto/asymmetric_keys/pkcs7_aa.asn1 | 18 ++++++ crypto/asymmetric_keys/pkcs7_key_type.c | 44 +++++++++++++- crypto/asymmetric_keys/pkcs7_parser.c | 81 +++++++++++++++++++++++++ crypto/asymmetric_keys/pkcs7_parser.h | 1 + crypto/asymmetric_keys/pkcs7_trust.c | 1 + include/crypto/pkcs7.h | 4 ++ 8 files changed, 152 insertions(+), 2 deletions(-) create mode 100644 crypto/asymmetric_keys/pkcs7_aa.asn1
Signature · 1 line
2.51.0