Skip to content

pkcs7: add RSA-PSS support for SignedData#9742

Open
sameehj wants to merge 2 commits intowolfSSL:masterfrom
sameehj:pkcs7-rsa-pss
Open

pkcs7: add RSA-PSS support for SignedData#9742
sameehj wants to merge 2 commits intowolfSSL:masterfrom
sameehj:pkcs7-rsa-pss

Conversation

@sameehj
Copy link
Contributor

@sameehj sameehj commented Feb 5, 2026

Add full RSA-PSS (RSASSA-PSS) support to PKCS#7 SignedData encoding and verification.

This change enables SignerInfo.signatureAlgorithm to use id-RSASSA-PSS with explicit RSASSA-PSS-params (hash, MGF1, salt length), as required by RFC 4055 and CMS profiles.

Key changes:

  • Add RSA-PSS encode and verify paths for PKCS7 SignedData
  • Encode full RSASSA-PSS AlgorithmIdentifier parameters
  • Decode RSA-PSS parameters from SignerInfo for verification
  • Treat RSA-PSS like ECDSA (sign raw digest, not DigestInfo)
  • Fix certificate signatureAlgorithm parameter length handling
  • Add API test coverage for RSA-PSS SignedData

This resolves failures when using RSA-PSS signer certificates (e.g. -173 invalid signature algorithm) and maintains backward compatibility with RSA PKCS#1 v1.5 and ECDSA.


Testing

  • API: New test test_wc_PKCS7_EncodeSignedData_RSA_PSS (guarded by HAVE_PKCS7, WC_RSA_PSS, RSA, filesystem, SHA-256). Uses certs/rsapss/client-rsapss.der and client-rsapss-priv.der; encodes SignedData and optionally round-trip verifies.
  • CI: os-check.yml updated with build --enable-pkcs7 CPPFLAGS=-DWC_RSA_PSS.
  • Manual: Encode/verify with RSA-PSS signer cert; existing RSA and ECDSA SignedData tests unchanged.

Checklist

  • added tests
  • updated/added doxygen (PKCS7_RSA_PSS page; cryptocb RSA-PSS notes; pkcs7.h EncodeSignedData \ref)
  • updated appropriate READMEs (examples/configs/README.md; user_settings_pkcs7.h with WC_RSA_PSS)
  • Updated manual and documentation (doxygen; main README/ChangeLog at merge time)

@sameehj sameehj force-pushed the pkcs7-rsa-pss branch 6 times, most recently from c4749c5 to 38bcb07 Compare February 6, 2026 10:15
@sameehj
Copy link
Contributor Author

sameehj commented Feb 6, 2026

retest this please

@sameehj sameehj force-pushed the pkcs7-rsa-pss branch 16 times, most recently from a4ff167 to 2f8e307 Compare February 10, 2026 17:55
@sameehj
Copy link
Contributor Author

sameehj commented Feb 11, 2026

retest this please

@sameehj
Copy link
Contributor Author

sameehj commented Feb 12, 2026

retest this please

@sameehj sameehj requested review from SparkiDev and dgarske February 12, 2026 13:50
@sameehj sameehj force-pushed the pkcs7-rsa-pss branch 2 times, most recently from cb9f6e4 to d4d412b Compare February 13, 2026 06:40
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds CMS/PKCS#7 SignedData support for RSA-PSS (id-RSASSA-PSS) by encoding/decoding RSASSA-PSS-params and adding RSA-PSS sign/verify paths alongside existing RSA PKCS#1 v1.5 and ECDSA handling.

Changes:

  • Add RSA-PSS signing and verification support in PKCS7 SignedData, including RSASSA-PSS parameter parsing/encoding.
  • Fix/adjust ASN.1 helpers to support decoding RSA-PSS parameters in template/non-template builds and improve RSA public-key decode behavior.
  • Add RSA-PSS API test coverage, documentation updates, and CI build coverage for WC_RSA_PSS.

Reviewed changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
wolfssl/wolfcrypt/pkcs7.h Adds fields to store decoded RSA-PSS params for verification.
wolfssl/wolfcrypt/asn.h Declares internal helpers to encode/decode RSASSA-PSS params.
wolfcrypt/src/pkcs7.c Implements RSA-PSS sign/verify paths and parses/encodes RSASSA-PSS AlgorithmIdentifier parameters.
wolfcrypt/src/asn.c Implements manual RSASSA-PSS params parsing and adds RSASSA-PSS AlgorithmIdentifier encoding helper; adjusts ASN helpers/length handling.
wolfcrypt/src/aes.c Adds Clang diagnostic push/pop around the file.
tests/api/test_pkcs7.h Registers the new RSA-PSS SignedData API test behind feature guards.
tests/api/test_pkcs7.c Adds test_wc_PKCS7_EncodeSignedData_RSA_PSS with encode + round-trip verify.
examples/configs/user_settings_pkcs7.h Enables WC_RSA_PSS in the PKCS#7 config template.
examples/configs/README.md Documents enabling RSA-PSS SignedData via WC_RSA_PSS.
doc/dox_comments/header_files/pkcs7.h Adds doxygen reference for RSA-PSS usage.
doc/dox_comments/header_files/doxygen_pages.h Adds a new doxygen page PKCS7_RSA_PSS.
doc/dox_comments/header_files/cryptocb.h Documents crypto-callback behavior for RSA-PSS operations.
.wolfssl_known_macro_extras Minor macro list adjustment.
.github/workflows/os-check.yml Adds CI build variant enabling PKCS7 + WC_RSA_PSS.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@sameehj sameehj force-pushed the pkcs7-rsa-pss branch 2 times, most recently from 51eb550 to a0edf71 Compare February 16, 2026 08:50
Add full RSA-PSS (RSASSA-PSS) support to PKCS#7 SignedData
encoding and verification.

This change enables SignerInfo.signatureAlgorithm to use
id-RSASSA-PSS with explicit RSASSA-PSS-params (hash, MGF1,
salt length), as required by RFC 4055 and CMS profiles.

Key changes:
- Add RSA-PSS encode and verify paths for PKCS7 SignedData
- Encode full RSASSA-PSS AlgorithmIdentifier parameters
- Decode RSA-PSS parameters from SignerInfo for verification
- Treat RSA-PSS like ECDSA (sign raw digest, not DigestInfo)
- Fix certificate signatureAlgorithm parameter length handling
- Add API test coverage for RSA-PSS SignedData

This resolves failures when using RSA-PSS signer certificates
(e.g. -173 invalid signature algorithm) and maintains backward
compatibility with RSA PKCS#1 v1.5 and ECDSA.

Signed-off-by: Sameeh Jubran <sameeh@wolfssl.com>
The revoked-cert verification check uses `echo "$var" | grep -q`
to look for "revoked" or "error 23" in the openssl verify output.
With `set -o pipefail`, when grep -q finds the pattern and exits
early, echo may fail writing to the closed pipe (SIGPIPE/EPIPE,
exit 141 or 1). pipefail reports the pipeline status as that
non-zero code from echo, even though grep matched successfully.
The `!` negation then treats this as success (pattern not found),
causing the test to incorrectly report failure.

Replace echo|grep pipelines with bash [[ ]] glob pattern matching,
which avoids pipes entirely and is immune to this interaction.

Signed-off-by: Sameeh Jubran <sameeh@wolfssl.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant