Skip to content

Check each slot's chain with its certificate model - #4376

Merged
jyao1 merged 1 commit into
DMTF:mainfrom
Jhongwe1:per-slot-cert-model
Nov 30, 2026
Merged

jyao1 merged 1 commit into
DMTF:mainfrom
Jhongwe1:per-slot-cert-model

Conversation

@Jhongwe1

@Jhongwe1 Jhongwe1 commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Fix #4374.

libspdm_verify_peer_cert_chain_buffer_integrity() takes the slot ID. On the Requester, when multi_key_conn_rsp is true and the slot's certificate model is known, it checks the chain with that model, which DIGESTS and CERTIFICATE give and the Requester records in peer_cert_info[slot_id] before the check. Otherwise nothing changes: without multiple keys every slot uses the model of ALIAS_CERT_CAP (DSP0274 1.4.1, paragraph 370), and the Responder still does not determine the Requester's model. Its three callers pass the slot: libspdm_get_certificate(), the encapsulated GET_CERTIFICATE, and the sample verification callback.

The model can also be GenericCert, in slots 1 to 7. Such a chain is now checked with the GenericCert model, as SET_CERTIFICATE already checks one: libspdm_x509_common_certificate_check() lets a few fields of its leaf certificate be empty, and, as with DeviceCert, lets that certificate carry the hardware identity OID. Before, it was checked with the model of ALIAS_CERT_CAP. DSP0274 1.4.1 leaves the contents of GenericCert certificates, other than the key pair and related information in the leaf certificate, outside its scope (paragraph 130). Checked by adding the calls to case 85 locally: a DeviceCert chain in a GenericCert slot passes, with ALIAS_CERT_CAP set and with it clear. Case 85 as sent has no GenericCert step.

req_get_certificate_case30's sub case 2 had the Responder report the AliasCert model without ALIAS_CERT_CAP, and send the DeviceCert chain. It passed because the model was not used, and fails with this change, at the leaf certificate's hardware identity OID. DSP0274 1.4.1 forbids the AliasCert model without ALIAS_CERT_CAP, so the sub case now sets the bit and sends the AliasCert chain, and then, with the bit still set, gets a DeviceCert chain from slot 1, which is the case this fixes. Whether the Requester should refuse the AliasCert model without ALIAS_CERT_CAP is left as it is.

Tested on Linux, GCC, at main b3f7d2e, Mbed TLS Debug and OpenSSL Release:

  • test_spdm_requester (984 tests) and test_spdm_responder (736 with Mbed TLS, 737 with OpenSSL) pass before and after; test_spdm_common passes 103 before and 104 after, with the new case 85.
  • Against main's library, case 85 fails, and case 30 fails at its slot 1 step only, with "Hardware identity OID present in alias leaf certificate".
  • test_spdm_sample fails before and after at the same two cases, because dice_cert/dice_root_cert.der is not in the repository; so the change to the sample callback is built, not run.
  • script/format_nix.sh --check passes, and the build has no warning.

With spdm-emu 0ffa9e0, built as its workflows build it, and ALIAS_CERT added to the responder's --cap (slot 0 holds the AliasCert chain, slot 4 a DeviceCert chain), default flow:

main with this
ECDSA P-384 12 messages, 80020001 after slot 4's CERTIFICATE 1,134: every CERTIFICATE passes, and SET_CERTIFICATE is answered ERROR(Unspecified)
ML-DSA-87 38, the same 1,318, the same
SLH-DSA-SHA2-128f 72, the same 1,502, the same

The SET_CERTIFICATE failure is spdm-emu's, fixed in DMTF/spdm-emu#560. With it, P-384 completes: 2,272 messages, exit 0, the message sequence of the flow without ALIAS_CERT. ML-DSA and SLH-DSA then stop in the sample libspdm_update_local_cert_chain(), #4375. Without ALIAS_CERT, P-384 and ML-DSA-87 give the same messages before and after.

Fix DMTF#4374.

libspdm_verify_peer_cert_chain_buffer_integrity() checks a Responder's
certificate chain with the AliasCert model when the Responder sets
ALIAS_CERT_CAP, and with the DeviceCert model otherwise, whatever the
slot. When the connection uses multiple asymmetric keys, DIGESTS and
CERTIFICATE give a certificate model for each slot, and the Requester
records it and compares the two, but does not check the chain with it.
DSP0274 1.4.1 says of ALIAS_CERT_CAP in Table 15: "When set in
combination with MULTI_KEY_CAP being 01b or 10b, the certificate model
in each slot can vary and should be evaluated individually."

So a Responder with ALIAS_CERT_CAP cannot have a DeviceCert chain in
any slot: the chain's leaf certificate carries the hardware identity
OID, which the AliasCert model forbids, and GET_CERTIFICATE returns
LIBSPDM_STATUS_VERIF_FAIL.

When multi_key_conn_rsp is true and the slot's certificate model is
known, check the chain with that model. Otherwise nothing changes:
without multiple keys every slot uses the model ALIAS_CERT_CAP gives,
as paragraph 370 of DSP0274 1.4.1 requires, and the Responder still
does not determine the Requester's model. The function takes the slot
ID for this, and its callers pass it.

req_get_certificate_case30's sub case 2 reported the AliasCert model
without ALIAS_CERT_CAP, which DSP0274 1.4.1 forbids, for a DeviceCert
chain; it passed only because the model was not used. It now sets
ALIAS_CERT_CAP and sends the AliasCert chain, then takes a DeviceCert
chain from slot 1 with the bit still set. Test 85 checks the function
with each model.

Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Chung-Wei Lan <zwwe1f@gmail.com>
@jyao1
jyao1 merged commit 8444a74 into DMTF:main Nov 30, 2026
57 checks passed
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.

Requester checks every slot's certificate chain with the model of ALIAS_CERT_CAP

3 participants