Repository navigation
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
The custom-extension test and its registration are missing the WOLFSSL_ASN_TEMPLATE and HAVE_OID_ENCODING guards, causing supported custom-OID configurations to call an unavailable function and fail the unit-test build.
1 open issue
What changed in this PR
This PR updates wolfCert’s certificate signing request (CSR) buffer estimate to account for custom extensions, preventing buffer errors when customization callbacks add large payloads such as attestation evidence.
Changes:
- Include custom-extension OIDs, values, and encoding overhead in the DER buffer estimate.
- Add a regression test that verifies a CSR contains a 3,000-byte custom extension.
| File | Description |
|---|---|
tests/unit/test_csr.c |
Adds and registers the large custom-extension regression test. |
src/csr.c |
Counts custom-extension sizes when allocating the CSR output buffer. |
Review effort: Balanced
Frauschi
left a comment
There was a problem hiding this comment.
The fix looks right, and cmake-full-all already runs the new test since --enable-all defines WOLFSSL_CUSTOM_OID, so no CI change is needed.
| sz += (size_t)ext->valSz; | ||
| sz += 16; | ||
| } | ||
| if (cert->extCustom.oidSz > 0 || cert->extCustom.valSz > 0) |
There was a problem hiding this comment.
Nothing sets cert->extCustom, so this branch is untested; add a case whose callback fills extCustom with a few KB, or drop the term. wolfSSL only encodes extCustom when oidSz > 0, so the valSz check can go.
| return rc; | ||
| } | ||
|
|
||
| /* Encoded size bound of the extensions a customize callback can add on top |
There was a problem hiding this comment.
sbjRaw is only set on renewal, so the estimate does not count a subject from meta (a known gap), and custom_ext_size covers only the WOLFSSL_CUSTOM_OID fields. Something like /* Encoded size of the custom OID extensions the customize callback set. */ would be accurate.
|
|
||
| #if defined(WOLFSSL_CUSTOM_OID) && defined(WOLFSSL_ASN_TEMPLATE) && \ | ||
| defined(HAVE_OID_ENCODING) | ||
| /* A customize callback adding a large custom extension (e.g. attestation |
There was a problem hiding this comment.
Per CONTRIBUTING this should be one or two lines naming input and outcome, such as /* 3000-byte custom extension from customize: the CSR carries it. */. The L782 comment can go too, since extnValue holds any DER and wolfSSL adds the OCTET STRING wrapper.

wolfcert_csr_build_ex() sizes the DER buffer from the key, the SAN and
the subject only. Extensions added by the customize callback
(wc_SetCustomExtension, the extCustom request extension) are not
counted, so a large one - e.g. attestation evidence per
draft-ietf-lamps-csr-attestation, 1.5 KB and more - makes
wc_MakeCertReq_ex() fail with a buffer error.
Add their encoded size (OID, value, 16 bytes of headers) to the
estimate. The fields exist with WOLFSSL_CUSTOM_OID only.
Add csr_carries_large_custom_ext: a 3000-byte custom extension from
the customize callback.
Note for CI
None of the CI wolfSSL configs in
scripts/ci/build-wolfssl.shdefinesWOLFSSL_CUSTOM_OID, so CI does not run the new test. Adding-DWOLFSSL_CUSTOM_OID -DHAVE_OID_ENCODINGto_base_flags(or to a singleconfig) would cover it. That changes the wolfSSL build cache key, so I left
it out of this PR. Happy to add it here or in a follow-up, whichever you
prefer.