Repository navigation
Match SCEP signer keys by SPKI and require a CA for roll-over - #83
Merged
Merged
Conversation
There was a problem hiding this comment.
🟢 Approval recommended
The review reports no active issues with the SCEP signer-validation changes.
No open issues 🎉
What changed in this PR
This PR strengthens wolfCert’s SCEP signer validation by reusing the DER-based SubjectPublicKeyInfo comparison introduced in #72 and requiring a trusted CA key for certificate roll-over.
Changes:
- Unifies signer-key checks around full SubjectPublicKeyInfo bytes, including the AlgorithmIdentifier.
- Restricts GetNextCACert signers to keys held by trusted bundle certificates with basicConstraints cA set.
- Adds regression coverage and removes obsolete signer-check allocation-failure handling.
| File | Description |
|---|---|
wolfcert/scep.h |
Documents signer matching and roll-over authorization requirements. |
tests/unit/test_scep_msg.c |
Tests algorithm-identifier mismatches, RA roll-over rejection, and CA-check allocation failures. |
tests/integration/test_scep_roundtrip.c |
Tests rejection when the request signer and CSR keys differ. |
tests/integration/test_scep_poll_roundtrip.c |
Removes obsolete signer-check allocation-failure cases. |
src/scep/scep_server.c |
Uses shared SPKI matching for enrollment, resends, and polling. |
src/scep/scep_msg.c |
Enforces CA-only roll-over trust and reports authorization failures. |
src/scep/scep_client.c |
Updates CertRep validation to the revised signer-check interface. |
src/pkcs7_util.c |
Adds allocation-free comparison of complete SPKI encodings. |
src/internal.h |
Updates helper declarations, contracts, and fault-injection documentation. |
Review effort: Balanced
Member
Author
|
@claude review |
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #83
Scan targets checked: wolfcert-src, wolfcert-bugs
Not reviewed (no scan target covers them): src/internal.h, src/pkcs7_util.c
Coverage: 7 of 7 in-scope changed file(s) opened by the reviewer
Fenrir result: Approved ✅
No new issues found in the changed files.
Advisory only — this automated result does not count as a GitHub approval.
Review tier: Max
Two rules decided whether a certificate or CSR holds a given key. The issued-certificate match from wolfSSL#72 compares the SubjectPublicKeyInfo found by a DER walk, while the SCEP CertRep signer check and the test server's PKCSReq, resend and GetCertInitial checks went through wolfcert_extract_spki(), which ran wc_ParseCert and compared only DecodedCert.publicKey, the key without its AlgorithmIdentifier. wolfcert_spki_match() compares the SubjectPublicKeyInfo bytes that the same DER walk finds, and both SCEP paths now use it, so wolfcert_extract_spki() goes. The comparison no longer allocates or parses the whole certificate. That drops the out-of-memory path of the CertRep signer check and its OOM sweep, and the test server's signer-check OOM fault together with the 500 branches only it reached. A signer certificate whose AlgorithmIdentifier differs from the CSR's, such as RSA-PSS against rsaEncryption for the same key, no longer matches. The SCEP transactionID and the RA candidate hashes still cover DecodedCert.publicKey, since RFC 8894 defines the transactionID over the key alone. The CertRep signer test relabels an RA certificate's key as id-RSASSA-PSS, which the old rule still matched, and a PKCSReq signed with a key other than the CSR's now has a test of its badRequest reply. Fixes F-19178.
RFC 8894 section 4.7.1 has the current CA sign the GetNextCACert reply. wolfcert_scep_verify_next_ca_response() reused the CertRep check, which accepts a signer whose key matches any certificate in current_ca_der. scep.h tells callers to pass the GetCACert bundle there, and from a CA/RA deployment that bundle holds the RA certificate too, so whoever held the RA key could hand the client a new CA of their choosing. wolfcert_scep_verify_rep_signer() takes ca_only, and with it a matching bundle certificate counts only when its basicConstraints has cA set. GetNextCACert passes 1 and the CertRep check 0. A v1 CA certificate without basicConstraints can no longer vouch for a roll-over; RFC 5280 section 4.2.1.9 requires cA on any certificate that signs others. The test signs a roll-over with a self-signed non-CA certificate placed first in an [RA, CA] bundle and expects WOLFCERT_ERR_AUTH, and the OOM sweep covers the parse behind the CA check. A refused roll-over now leaves a message for wolfcert_last_error_message(). Fixes F-18384.
yosuke-wolfssl
approved these changes
Dec 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
SCEP signer checks now use one rule for "this certificate holds that key": the whole SubjectPublicKeyInfo, found by the DER walk #72 added. A GetNextCACert reply is accepted only when its signer's key belongs to a CA certificate in the caller's bundle, as RFC 8894 section 4.7.1 requires, so an RA key can no longer install a new CA.
Changes
wolfcert_spki_match()compares SubjectPublicKeyInfo bytes; the CertRep signer check and the test server's PKCSReq, resend and GetCertInitial checks use itwolfcert_extract_spki()and the server'ssigner_matches_key()are removedwolfcert_scep_verify_rep_signer()takesca_only; GetNextCACert counts only bundle certificates with basicConstraints cA setscep.hnames the SPKI rule andWOLFCERT_ERR_AUTHforpkcs_reqandget_next_ca_cert; a refused roll-over sets an error messageTesting
test_cert_rep_signer_trust: an RA certificate relabelled id-RSASSA-PSS is refusedtest_next_ca_response_signer_trust: a roll-over signed by the RA of an [RA, CA] bundle getsWOLFCERT_ERR_AUTH, with an OOM sweep over the CA checktest_scep_roundtrip: a PKCSReq signed with a key other than the CSR's gets badRequesttest_scep_poll_roundtripdrops the signer-check OOM cases