SPDM

utils.py

SPDM conformance test case utilities.

class TestSetup(steps=None)

Composable SPDM TestSetup step pipeline.

get_capabilities(*, required_capabilities: dict[str, int] | None = None, **kwargs: Any) TestSetup

Run GET_CAPABILITIES. Skip test if provided capabilities are not met.

get_version(required_spdm_version: int | None = None) TestSetup

Run GET_VERSION and select a negotiated version.

The test is skipped when no entry in VERSION.VersionNumberEntry satisfies the requirement.

negotiate_algorithms(**kwargs) TestSetup

Run NEGOTIATE_ALGORITHMS using the supplied kwargs.

run(dut: sanblaze.script.dut.DUT) dict[str, Any]

Execute SPDM pipeline. Returns the accumulated context.

step(action: Callable[[sanblaze.script.dut.DUT], None]) TestSetup

Add step to SPDM pipeline.

Steps may write into self.context to expose values to the main function (e.g. the result of GET_CAPABILITIES).

common_req_alg_struct(spdm_version: int, *, include_pqc: bool = False, **kwargs) list

Generate ReqAlgStruct with all requester supported algorithms set, based on the SPDM version

common_spdm_test(setup: ~utils.TestSetup = <utils.TestSetup object>, teardown: ~collections.abc.Callable[[sanblaze.script.dut.DUT], None] | None = None)

Run SPDM TestSetup and TestTeardown

get_capabilities_common_params() dict

Default GET_CAPABILITIES requester flags from SPDM-Responder-Validator.

See spdm_test_case_algorithms_setup_version_capabilities() in spdm_responder_test_3_algorithms.c

multi_key_conn_rsp(MULTI_KEY_CAP: int, ResponderMultiKeyConn: int) bool | None

Table 38 — MULTI_KEY_CONN_RSP value calculation

negotiate_algorithms_common_params(spdm_version: int, *, include_pqc: bool | None = None) dict

Generate common NEGOTIATE_ALGORITHIMS parameters based on SPDM version

Based on: SPDM-Responder-Validator/library/spdm_responder_conformance_test_lib/spdm_responder_test_3_algorithms.c

NEGOTIATE_ALGORITHMS {SPDMVersion=NegotiatedVersion, …}

Code=E3h(NEGOTIATE_ALGORITHMS) NumAlgStruct=4 (NumAlgStruct=6 for SPDM 1.4+ with PQC) Length=48 (Length=56 for SPDM 1.4+ with PQC) MeasureSpec=1h OtherParamsSupport=2h BaseAsymAlgo=FFFh BaseHashAlgo=7Fh ExtAsymCount=0 ExtHashCount=0 ReqAlgStruct=02207F00,03200F00,0420FF0F,05200100 (+0620FF7F00,07200700 for SPDM 1.4+ with PQC)

spdm_test_ctx(dut: sanblaze.script.dut.DUT) dict[str, Any]

Return TestSetup context from @common_spdm_test(...).

Scripts can use this with def main(dut) so main(dut) in if __name__ == '__main__' keeps working without a ctx parameter.