scep: size the signer key DER buffer from the key - #18
Open
yosuke-wolfssl wants to merge 1 commit into
Open
Conversation
- rsa_key_to_der derives its capacity from key->rsa_bits, falling back to 4096 bits for a key loaded from DER, in place of a fixed 2048 bytes. - The wc_RsaKeyToDer failure path reports through WOLFCERT_ERR_WC. - test_scep_roundtrip gains check_rsa4096, which enrolls an RSA-4096 key and verifies the issued certificate against the CA that answered, reusing main's rc for the diagnostic. Issue: F-8011
There was a problem hiding this comment.
Pull request overview
Fixes SCEP RSA-4096 private-key DER serialization and adds regression coverage.
Changes:
- Sizes RSA DER buffers dynamically.
- Improves serialization error reporting.
- Adds RSA-4096 enrollment and certificate-chain verification.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
tests/integration/test_scep_roundtrip.c |
Adds RSA-4096 SCEP enrollment and chain verification coverage. |
src/scep/scep_client.c |
Dynamically sizes RSA DER buffers and improves diagnostics. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
wolfSSL-Fenrir-bot
approved these changes
Aug 21, 2026
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #18
Scan targets checked: wolfcert-bugs, wolfcert-src
No new issues found in the changed files. ✅
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.
Problem
rsa_key_to_der(src/scep/scep_client.c) allocated a fixed 2048-byte buffer forwc_RsaKeyToDer, while every other serializer in the tree sizes from the key (keygen.c,csr.c,ca_issue.c).rsa_makeaccepts 2048|3072|4096 and the CLI advertises--key-type rsa:BITS, so--key-type rsa:4096 --proto scepdied with a bareWOLFCERT_ERR_CRYPTObefore sending a byte — an advertised configuration dead on arrival.BUFFER_EThe finding text also claims RSA-3072 overflows. It does not; only 4096 was broken.
Fix (
src/scep/scep_client.c)bits + 2048, the same idiomkeygen.c:229andcsr.c:368already use. It falls back to 4096 bits becausersa_priv_decodeleavesrsa_bitsat 0 for a key loaded from DER/PEM, so the fallback is load-bearing rather than decorative.WOLFCERT_ERR_WCreplaces the bareWOLFCERT_ERR_CRYPTOon thewc_RsaKeyToDerfailure path, so a future sizing failure is diagnosable.The helper is the single choke point for all six SCEP serialization sites, so the blocking and non-blocking session entry points are both covered by the one change.
Closes f-8011.
Test harness
check_rsa4096intests/integration/test_scep_roundtrip.cenrolls an RSA-4096 key over SCEP and verifies the issued certificate chains to the CA that answered, through aWOLFSSL_CERT_MANAGER— not a PEM-marker match. It follows the surroundingcheck_*helpers' fallthrough-rcand free-on-every-path discipline.Verification
-Werror.rc=-9against the unfixed helper.skoll review: 0 findings, APPROVE.Not in this PR
rsa_priv_decodenever setsrsa_bits, unlikeecc_priv_decodewhich repopulatescurve_id. Fixing that properly means dropping the? : 4096guard from all three sites and failing whenwc_RsaEncryptSize()returns<= 0— dropping the guard alone reintroduces this bug. It is unfiled and wants its own finding, alongside8014(same class,ca_issue.c).