Repository navigation
Conversation
LeonLinAtAMI
left a comment
There was a problem hiding this comment.
Do you consider to change LIBSPDM_MAX_CERT_CHAIN_SIZE under unit_test folder too?
bc34591 to
effd81b
Compare
|
Yes. The three copies under With transcript data the unit tests already take libspdm's value, so with this change they get 0x40000 either way. The cost is stack: with OpenSSL the deepest unit test, I also rebased onto main, so the chain sizes in the commit message are the ones after #4377. |
Fix DMTF#4381. The SLH-DSA-SHA2-256f and SLH-DSA-SHAKE-256f AliasCert chains in unit_test/sample_key hold 201,146 and 201,154 bytes of certificates, more than the 0x28000 bytes LIBSPDM_MAX_CERT_CHAIN_SIZE gives a chain when an SLH-DSA parameter set is enabled. With LIBSPDM_RECORD_TRANSCRIPT_DATA_SUPPORT, the only configuration in which libspdm defines the macro, the context keeps each peer chain in a buffer of that size, so a Requester cannot keep such a chain. Make the SLH-DSA value 0x40000. It holds those chains with their 4-byte header and a root hash of up to 64 bytes, and it is the value the Tier 2 row config-record-transcript-large already builds with. Without RECORD_TRANSCRIPT_DATA_SUPPORT nothing changes. With it, sizeof(libspdm_context_t) on x64 grows from 2,961,368 to 3,944,408 bytes: eight per-slot chain buffers and two transcript buffers. The unit tests, the fuzzing harnesses and test_size keep their own copies of the block, at 0x28000, for builds without transcript data. At 0x40000 the unit tests' Windows Debug builds with OpenSSL run out of their 1 MiB stack in req_get_certificate_case12, whose path holds several chain buffers. Assisted-by: Claude Code:claude-opus-5-5 Signed-off-by: Chung-Wei Lan <zwwe1f@gmail.com>
effd81b to
169fc97
Compare
|
Correction: the second version failed on Windows. In the Debug builds with OpenSSL, So the unit_test copies are back at 0x28000, and the PR is the first version again, rebased onto main. For the copies to follow, the unit tests' chain buffers have to come off the stack first. I can send that as a separate PR if you want. |
Fix #4381.
The SLH-DSA-256f AliasCert sample chains are longer than the 0x28000 bytes
LIBSPDM_MAX_CERT_CHAIN_SIZEgives a chain with SLH-DSA. This makes the SLH-DSA value 0x40000, inspdm_lib_config.hand in the changelog line that names it.Measured on x64 with GCC, main
19ac314before, this branch after:LIBSPDM_RECORD_TRANSCRIPT_DATA_SUPPORT, mbedtls Debug, OpenSSL Debug and OpenSSL Release: all 80 test executables of each build are byte-identical before and after.sizeof(libspdm_context_t)goes from 2,961,368 to 3,944,408 bytes.dd4b434built with transcript data,ALIAS_CERTand SLH-DSA-SHA2-256f: the Requester used to stop at slot 0's chain withLIBSPDM_STATUS_BUFFER_TOO_SMALL, after 86 messages. Now it keeps that chain and stops at slot 4's, after 108: the Responder cannot append slot 4'sCERTIFICATEtomessage_b, which holds one chain and already holds slot 0's (a Debug build printslibspdm_append_managed_buffer 0x24d74 fail, rest 0xef66 only). WithoutALIAS_CERT, slots 0 and 4 hold 150,832-byte chains, and the flow stops there before and after this change.ALIAS_CERT, and the default flow, give the same messages before and after, in both builds.The unit tests' own copies of the value, used without transcript data, stay at 0x28000. At 0x40000 the Windows Debug builds with OpenSSL overflowed their 1 MiB stack in
req_get_certificate_case12(this PR's second version:windows-x64-vs-openssl-debug,windows-ia32-vs-openssl-debugandwindows-x64-clang-openssl-debug). With transcript data the unit tests take libspdm's value, so a Windows Debug build of them with OpenSSL and transcript data would put 0x40000 chain buffers on the stack too; no tier builds that configuration.