From 41499e36785a415c4a0538e516f1ecd872877f78 Mon Sep 17 00:00:00 2001 From: xiaotia3 Date: Thu, 7 Sep 2023 13:19:57 +0800 Subject: [PATCH] Test: add negative case for requester - unittests for handling certificate response - unittests for handling measurement response - cases to test issuing other requests before VCAed Signed-off-by: xiaotia3 --- .../requester_tests/get_certificate_req.rs | 161 ++++++++++++ .../src/requester_tests/get_digests_req.rs | 230 ++++++++++++++++++ .../requester_tests/get_measurements_req.rs | 197 +++++++++++++++ 3 files changed, 588 insertions(+) diff --git a/test/spdmlib-test/src/requester_tests/get_certificate_req.rs b/test/spdmlib-test/src/requester_tests/get_certificate_req.rs index 894dc49e..621f10b9 100644 --- a/test/spdmlib-test/src/requester_tests/get_certificate_req.rs +++ b/test/spdmlib-test/src/requester_tests/get_certificate_req.rs @@ -7,6 +7,8 @@ use crate::common::secret_callback::*; use crate::common::transport::PciDoeTransportEncap; use crate::common::util::{create_info, get_rsp_cert_chain_buff}; use spdmlib::common::SpdmConnectionState; +use spdmlib::config::{MAX_SPDM_CERT_CHAIN_DATA_SIZE, MAX_SPDM_MSG_SIZE}; +use spdmlib::error::{SpdmResult, SPDM_STATUS_ERROR_PEER, SPDM_STATUS_INVALID_MSG_FIELD}; use spdmlib::protocol::*; use spdmlib::requester::RequesterContext; use spdmlib::{responder, secret}; @@ -83,3 +85,162 @@ fn test_case0_send_receive_spdm_certificate() { }; executor::block_on(future); } + +#[test] +#[cfg(feature = "hashed-transcript-data")] +fn test_handle_spdm_certificate_partial_response() { + struct Tc<'a> { + name: &'a str, + slot_id: u8, + total_size: u16, + offset: u16, + length: u16, + receive_buffer: &'a [u8], + expected_result: SpdmResult<(u16, u16)>, + } + let tt: [Tc; 8] = [ + Tc { + name: "invalid certificate partial resp", + slot_id: 0u8, + total_size: 0u16, + offset: 0u16, + length: 0u16, + receive_buffer: &[0x12, 0x82, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], + expected_result: Err(SPDM_STATUS_ERROR_PEER), + }, + Tc { + name: "zero length portion", + slot_id: 0u8, + total_size: 2048u16, + offset: 0u16, + length: 2048u16, + receive_buffer: &[ + 0x12, 0x02, 0x00, 0x00, // + 0x00, 0x00, // portion + 0x00, 0x08, // remainder + ], + expected_result: Err(SPDM_STATUS_INVALID_MSG_FIELD), + }, + Tc { + name: "portion larger than remainder", + slot_id: 0u8, + total_size: 10u16, + offset: 7u16, + length: 3u16, + receive_buffer: &[ + 0x12, 0x02, 0x00, 0x00, // + 0x05, 0x00, // portion + 0x00, 0x00, // remainder + 0x05, 0x00, 0x00, 0x00, 0x00, + ], + expected_result: Err(SPDM_STATUS_INVALID_MSG_FIELD), + }, + Tc { + name: "portion larger than max cert chain size", + slot_id: 0u8, + total_size: MAX_SPDM_CERT_CHAIN_DATA_SIZE as u16, + offset: (MAX_SPDM_CERT_CHAIN_DATA_SIZE - 3) as u16, + length: 3u16, + receive_buffer: &[ + 0x12, 0x02, 0x00, 0x00, // + 0x05, 0x00, // portion + 0x00, 0x00, // remainder + 0x05, 0x00, 0x00, 0x00, 0x00, + ], + expected_result: Err(SPDM_STATUS_INVALID_MSG_FIELD), + }, + Tc { + name: "zero remainder but certificate is incomplete", + slot_id: 0u8, + total_size: 100u16, + offset: 90u16, + length: 10u16, + receive_buffer: &[ + 0x12, 0x02, 0x00, 0x00, // + 0x05, 0x00, // portion + 0x00, 0x00, // remainder + 0x05, 0x00, 0x00, 0x00, 0x00, + ], + expected_result: Err(SPDM_STATUS_INVALID_MSG_FIELD), + }, + Tc { + name: "remainder larger than max cert chain size", + slot_id: 0u8, + total_size: MAX_SPDM_CERT_CHAIN_DATA_SIZE as u16, + offset: (MAX_SPDM_CERT_CHAIN_DATA_SIZE - 10) as u16, + length: 10u16, + receive_buffer: &[ + 0x12, 0x02, 0x00, 0x00, // + 0x05, 0x00, // portion + 0x06, 0x00, // remainder + 0x05, 0x00, 0x00, 0x00, 0x00, + ], + expected_result: Err(SPDM_STATUS_INVALID_MSG_FIELD), + }, + Tc { + name: "wrong certificate slot id", + slot_id: 7u8, + total_size: 100u16, + offset: 90u16, + length: 10u16, + receive_buffer: &[ + 0x12, 0x02, 0x00, 0x00, // + 0x05, 0x00, // portion + 0x05, 0x00, // remainder + 0x05, 0x00, 0x00, 0x00, 0x00, + ], + expected_result: Err(SPDM_STATUS_INVALID_MSG_FIELD), + }, + Tc { + name: "positive", + slot_id: 0u8, + total_size: 100u16, + offset: 90u16, + length: 10u16, + receive_buffer: &[ + 0x12, 0x02, 0x00, 0x00, // + 0x05, 0x00, // portion + 0x05, 0x00, // remainder + 0x05, 0x00, 0x00, 0x00, 0x00, + ], + expected_result: Ok((5, 5)), + }, + ]; + for tc in tt { + executor::add_task(async move { + let (req_config_info, req_provision_info) = create_info(); + let pcidoe_transport_encap = Arc::new(Mutex::new(PciDoeTransportEncap {})); + let device_io = Arc::new(Mutex::new(FakeSpdmDeviceIoReceve::new(Arc::new( + SharedBuffer::new(), + )))); + let mut requester = RequesterContext::new( + device_io, + pcidoe_transport_encap, + req_config_info, + req_provision_info, + ); + requester.common.negotiate_info.spdm_version_sel = SpdmVersion::SpdmVersion12; + requester.common.negotiate_info.base_hash_sel = SpdmBaseHashAlgo::TPM_ALG_SHA_384; + requester.common.peer_info.peer_cert_chain_temp = Some(SpdmCertChainBuffer::default()); + let session_id = None; + let send_buffer = [0u8; MAX_SPDM_MSG_SIZE]; + let result = requester.handle_spdm_certificate_partial_response( + session_id, + tc.slot_id, + tc.total_size, + tc.offset, + tc.length, + &send_buffer, + tc.receive_buffer, + ); + assert!( + result == tc.expected_result, + "tc '{}' expect {:?} got {:?}", + tc.name, + tc.expected_result, + result + ); + }) + } + executor::poll_tasks(); +} diff --git a/test/spdmlib-test/src/requester_tests/get_digests_req.rs b/test/spdmlib-test/src/requester_tests/get_digests_req.rs index d4aa84fa..0ddaeab3 100644 --- a/test/spdmlib-test/src/requester_tests/get_digests_req.rs +++ b/test/spdmlib-test/src/requester_tests/get_digests_req.rs @@ -7,6 +7,8 @@ use crate::common::secret_callback::*; use crate::common::transport::PciDoeTransportEncap; use crate::common::util::create_info; use spdmlib::common::SpdmConnectionState; +use spdmlib::error::SPDM_STATUS_ERROR_PEER; +use spdmlib::message::{SpdmMeasurementAttributes, SpdmMeasurementOperation}; use spdmlib::protocol::*; use spdmlib::requester::RequesterContext; use spdmlib::{config, responder, secret}; @@ -75,3 +77,231 @@ fn test_case0_send_receive_spdm_digest() { }; executor::block_on(future); } + +#[test] +#[cfg(feature = "hashed-transcript-data")] +fn issue_other_request_before_vca_negotiated() { + secret::asym_sign::register(SECRET_ASYM_IMPL_INSTANCE.clone()); + // issue GET_DIGESTS + executor::add_task(async { + let (rsp_config_info, rsp_provision_info) = create_info(); + let (req_config_info, req_provision_info) = create_info(); + let shared_buffer = SharedBuffer::new(); + let device_io_responder = Arc::new(Mutex::new(FakeSpdmDeviceIoReceve::new(Arc::new( + shared_buffer, + )))); + let pcidoe_transport_encap = Arc::new(Mutex::new(PciDoeTransportEncap {})); + let mut responder = responder::ResponderContext::new( + device_io_responder, + pcidoe_transport_encap, + rsp_config_info, + rsp_provision_info, + ); + responder.common.provision_info.my_cert_chain = [ + Some(SpdmCertChainBuffer { + data_size: 512u16, + data: [0u8; 4 + SPDM_MAX_HASH_SIZE + config::MAX_SPDM_CERT_CHAIN_DATA_SIZE], + }), + None, + None, + None, + None, + None, + None, + None, + ]; + responder.common.negotiate_info.spdm_version_sel = SpdmVersion::SpdmVersion12; + + let pcidoe_transport_encap2 = Arc::new(Mutex::new(PciDoeTransportEncap {})); + let shared_buffer = SharedBuffer::new(); + let device_io_requester = Arc::new(Mutex::new(FakeSpdmDeviceIo::new( + Arc::new(shared_buffer), + Arc::new(Mutex::new(responder)), + ))); + + let mut requester = RequesterContext::new( + device_io_requester, + pcidoe_transport_encap2, + req_config_info, + req_provision_info, + ); + requester.common.negotiate_info.spdm_version_sel = SpdmVersion::SpdmVersion12; + let result = requester.send_receive_spdm_digest(None).await; + assert!( + result == Err(SPDM_STATUS_ERROR_PEER), + "issue GET_DIGESTS got {:?}", + result + ) + }); + // issue GET_CERTIFICATE + executor::add_task(async { + let (rsp_config_info, rsp_provision_info) = create_info(); + let (req_config_info, req_provision_info) = create_info(); + let shared_buffer = SharedBuffer::new(); + let device_io_responder = Arc::new(Mutex::new(FakeSpdmDeviceIoReceve::new(Arc::new( + shared_buffer, + )))); + let pcidoe_transport_encap = Arc::new(Mutex::new(PciDoeTransportEncap {})); + let mut responder = responder::ResponderContext::new( + device_io_responder, + pcidoe_transport_encap, + rsp_config_info, + rsp_provision_info, + ); + responder.common.provision_info.my_cert_chain = [ + Some(SpdmCertChainBuffer { + data_size: 512u16, + data: [0u8; 4 + SPDM_MAX_HASH_SIZE + config::MAX_SPDM_CERT_CHAIN_DATA_SIZE], + }), + None, + None, + None, + None, + None, + None, + None, + ]; + responder.common.negotiate_info.spdm_version_sel = SpdmVersion::SpdmVersion12; + + let pcidoe_transport_encap2 = Arc::new(Mutex::new(PciDoeTransportEncap {})); + let shared_buffer = SharedBuffer::new(); + let device_io_requester = Arc::new(Mutex::new(FakeSpdmDeviceIo::new( + Arc::new(shared_buffer), + Arc::new(Mutex::new(responder)), + ))); + + let mut requester = RequesterContext::new( + device_io_requester, + pcidoe_transport_encap2, + req_config_info, + req_provision_info, + ); + requester.common.negotiate_info.spdm_version_sel = SpdmVersion::SpdmVersion12; + let result = requester.send_receive_spdm_certificate(None, 0).await; + assert!( + result == Err(SPDM_STATUS_ERROR_PEER), + "issue GET_CERTIFICATE got {:?}", + result + ) + }); + // issue CHALLENGE + executor::add_task(async { + let (rsp_config_info, rsp_provision_info) = create_info(); + let (req_config_info, req_provision_info) = create_info(); + let shared_buffer = SharedBuffer::new(); + let device_io_responder = Arc::new(Mutex::new(FakeSpdmDeviceIoReceve::new(Arc::new( + shared_buffer, + )))); + let pcidoe_transport_encap = Arc::new(Mutex::new(PciDoeTransportEncap {})); + let mut responder = responder::ResponderContext::new( + device_io_responder, + pcidoe_transport_encap, + rsp_config_info, + rsp_provision_info, + ); + responder.common.provision_info.my_cert_chain = [ + Some(SpdmCertChainBuffer { + data_size: 512u16, + data: [0u8; 4 + SPDM_MAX_HASH_SIZE + config::MAX_SPDM_CERT_CHAIN_DATA_SIZE], + }), + None, + None, + None, + None, + None, + None, + None, + ]; + responder.common.negotiate_info.spdm_version_sel = SpdmVersion::SpdmVersion12; + + let pcidoe_transport_encap2 = Arc::new(Mutex::new(PciDoeTransportEncap {})); + let shared_buffer = SharedBuffer::new(); + let device_io_requester = Arc::new(Mutex::new(FakeSpdmDeviceIo::new( + Arc::new(shared_buffer), + Arc::new(Mutex::new(responder)), + ))); + + let mut requester = RequesterContext::new( + device_io_requester, + pcidoe_transport_encap2, + req_config_info, + req_provision_info, + ); + requester.common.negotiate_info.spdm_version_sel = SpdmVersion::SpdmVersion12; + let result = requester + .send_receive_spdm_challenge( + 0, + SpdmMeasurementSummaryHashType::SpdmMeasurementSummaryHashTypeNone, + ) + .await; + assert!( + result == Err(SPDM_STATUS_ERROR_PEER), + "issue CHALLENGE got {:?}", + result + ) + }); + // issue GET_MEASUREMENTS + executor::add_task(async { + let (rsp_config_info, rsp_provision_info) = create_info(); + let (req_config_info, req_provision_info) = create_info(); + let shared_buffer = SharedBuffer::new(); + let device_io_responder = Arc::new(Mutex::new(FakeSpdmDeviceIoReceve::new(Arc::new( + shared_buffer, + )))); + let pcidoe_transport_encap = Arc::new(Mutex::new(PciDoeTransportEncap {})); + let mut responder = responder::ResponderContext::new( + device_io_responder, + pcidoe_transport_encap, + rsp_config_info, + rsp_provision_info, + ); + responder.common.provision_info.my_cert_chain = [ + Some(SpdmCertChainBuffer { + data_size: 512u16, + data: [0u8; 4 + SPDM_MAX_HASH_SIZE + config::MAX_SPDM_CERT_CHAIN_DATA_SIZE], + }), + None, + None, + None, + None, + None, + None, + None, + ]; + responder.common.negotiate_info.spdm_version_sel = SpdmVersion::SpdmVersion12; + + let pcidoe_transport_encap2 = Arc::new(Mutex::new(PciDoeTransportEncap {})); + let shared_buffer = SharedBuffer::new(); + let device_io_requester = Arc::new(Mutex::new(FakeSpdmDeviceIo::new( + Arc::new(shared_buffer), + Arc::new(Mutex::new(responder)), + ))); + + let mut requester = RequesterContext::new( + device_io_requester, + pcidoe_transport_encap2, + req_config_info, + req_provision_info, + ); + requester.common.negotiate_info.spdm_version_sel = SpdmVersion::SpdmVersion12; + let measurement_operation = SpdmMeasurementOperation::SpdmMeasurementQueryTotalNumber; + let mut total_number: u8 = 0; + let mut spdm_measurement_record_structure = SpdmMeasurementRecordStructure::default(); + let result = requester + .send_receive_spdm_measurement( + None, + 0, + SpdmMeasurementAttributes::SIGNATURE_REQUESTED, + measurement_operation, + &mut total_number, + &mut spdm_measurement_record_structure, + ) + .await; + assert!( + result == Err(SPDM_STATUS_ERROR_PEER), + "issue GET_MEASUREMENTS got {:?}", + result + ) + }); + executor::poll_tasks(); +} diff --git a/test/spdmlib-test/src/requester_tests/get_measurements_req.rs b/test/spdmlib-test/src/requester_tests/get_measurements_req.rs index 6c805884..92d389b2 100644 --- a/test/spdmlib-test/src/requester_tests/get_measurements_req.rs +++ b/test/spdmlib-test/src/requester_tests/get_measurements_req.rs @@ -7,6 +7,8 @@ use crate::common::secret_callback::*; use crate::common::transport::PciDoeTransportEncap; use crate::common::util::{create_info, get_rsp_cert_chain_buff}; use spdmlib::common::SpdmConnectionState; +use spdmlib::config::MAX_SPDM_MSG_SIZE; +use spdmlib::error::{SpdmResult, SPDM_STATUS_INVALID_MSG_FIELD}; use spdmlib::message::{SpdmMeasurementAttributes, SpdmMeasurementOperation}; use spdmlib::protocol::*; use spdmlib::requester::RequesterContext; @@ -161,3 +163,198 @@ fn test_case0_send_receive_spdm_measurement() { }; executor::block_on(future); } + +#[test] +fn test_handle_spdm_measurement_record_response() { + struct Tc<'a> { + name: &'a str, + request_slot_id: u8, + attributes: SpdmMeasurementAttributes, + operation: SpdmMeasurementOperation, + receive_buffer: Box<[u8]>, + expected_result: SpdmResult, + } + let fixed_block: &[u8] = &[ + 0xFE, 0x01, 0x33, 0x00, 0x01, 0x30, 0x00, 0x90, 0x6D, 0x9F, 0xE9, 0x2A, 0x5E, 0x0A, 0xD7, + 0xE0, 0x20, 0x84, 0x21, 0x27, 0xF7, 0x97, 0x0B, 0x7D, 0x2A, 0xDF, 0xF3, 0xA9, 0x11, 0x06, + 0x92, 0x7B, 0x59, 0x2C, 0xF1, 0x57, 0x63, 0x3D, 0x86, 0xD0, 0xBE, 0x6A, 0xB7, 0x8F, 0x5D, + 0x39, 0x8E, 0x53, 0xF7, 0x05, 0x64, 0x3C, 0xCB, 0xFB, 0x78, + ]; + let tt: [Tc; 8] = [ + Tc { + name: "requested total number and success", + request_slot_id: 0u8, + attributes: SpdmMeasurementAttributes::RAW_BIT_STREAM_REQUESTED, + operation: SpdmMeasurementOperation::SpdmMeasurementQueryTotalNumber, + receive_buffer: (|| -> Box<[u8]> { + let mut v = vec![0x12, 0x60, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00]; + v.extend_from_slice(&[0xFF; 32]); // Nonce + v.extend_from_slice(&[0x10, 0x00]); // OpaqueDataLength + v.extend_from_slice(&[0x02; 16]); // OpaqueData + v.into_boxed_slice() + })(), + expected_result: Ok(5), + }, + Tc { + name: "requested total number but attached record", + request_slot_id: 0u8, + attributes: SpdmMeasurementAttributes::RAW_BIT_STREAM_REQUESTED, + operation: SpdmMeasurementOperation::SpdmMeasurementQueryTotalNumber, + receive_buffer: (|| -> Box<[u8]> { + let mut v = vec![0x12, 0x60, 0x01, 0x00, 0x01, 0x37, 0x00, 0x00]; + v.extend_from_slice(fixed_block); // MeasurementRecordData + v.extend_from_slice(&[0xFF; 32]); + v.extend_from_slice(&[0x10, 0x00]); + v.extend_from_slice(&[0x02; 16]); + v.into_boxed_slice() + })(), + expected_result: Ok(1), // should expect Err(SPDM_STATUS_INVALID_MSG_FIELD) + }, + Tc { + name: "requested certain index (0x05) but returned mismatch (0xFE)", + request_slot_id: 0u8, + attributes: SpdmMeasurementAttributes::RAW_BIT_STREAM_REQUESTED, + operation: SpdmMeasurementOperation::Unknown(0x05), + receive_buffer: (|| -> Box<[u8]> { + let mut v = vec![0x12, 0x60, 0x01, 0x00, 0x01, 0x37, 0x00, 0x00]; + v.extend_from_slice(fixed_block); + v.extend_from_slice(&[0xFF; 32]); + v.extend_from_slice(&[0x10, 0x00]); + v.extend_from_slice(&[0x02; 16]); + v.into_boxed_slice() + })(), + expected_result: Ok(1), // should expect Err? + }, + Tc { + name: "requested certain index but returned many", + request_slot_id: 0u8, + attributes: SpdmMeasurementAttributes::RAW_BIT_STREAM_REQUESTED, + operation: SpdmMeasurementOperation::Unknown(0x05), + receive_buffer: (|| -> Box<[u8]> { + let mut v = vec![0x12, 0x60, 0x00, 0x00, 0x02, 0x6E, 0x00, 0x00]; + v.extend_from_slice(fixed_block); + v.extend_from_slice(fixed_block); + v.extend_from_slice(&[0xFF; 32]); + v.extend_from_slice(&[0x10, 0x00]); + v.extend_from_slice(&[0x02; 16]); + v.into_boxed_slice() + })(), + expected_result: Err(SPDM_STATUS_INVALID_MSG_FIELD), + }, + Tc { + name: "requested certain index and success", + request_slot_id: 0u8, + attributes: SpdmMeasurementAttributes::RAW_BIT_STREAM_REQUESTED, + operation: SpdmMeasurementOperation::Unknown(0xFF), + receive_buffer: (|| -> Box<[u8]> { + let mut v = vec![0x12, 0x60, 0x01, 0x00, 0x01, 0x37, 0x00, 0x00]; + v.extend_from_slice(fixed_block); + v.extend_from_slice(&[0xFF; 32]); + v.extend_from_slice(&[0x10, 0x00]); + v.extend_from_slice(&[0x02; 16]); + v.into_boxed_slice() + })(), + expected_result: Ok(1), + }, + Tc { + name: "request all without signature and success", + request_slot_id: 0u8, + attributes: SpdmMeasurementAttributes::RAW_BIT_STREAM_REQUESTED, + operation: SpdmMeasurementOperation::SpdmMeasurementRequestAll, + receive_buffer: (|| -> Box<[u8]> { + let mut v = vec![0x12, 0x60, 0x01, 0x00, 0x01, 0x37, 0x00, 0x00]; + v.extend_from_slice(fixed_block); + v.extend_from_slice(&[0xFF; 32]); + v.extend_from_slice(&[0x10, 0x00]); + v.extend_from_slice(&[0x02; 16]); + v.into_boxed_slice() + })(), + expected_result: Ok(1), + }, + Tc { + name: "request all and no measurements returned", + request_slot_id: 0u8, + attributes: SpdmMeasurementAttributes::RAW_BIT_STREAM_REQUESTED, + operation: SpdmMeasurementOperation::SpdmMeasurementRequestAll, + receive_buffer: (|| -> Box<[u8]> { + let mut v = vec![0x12, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]; + v.extend_from_slice(&[0xFF; 32]); + v.extend_from_slice(&[0x10, 0x00]); + v.extend_from_slice(&[0x02; 16]); + v.into_boxed_slice() + })(), + expected_result: Ok(0), + }, + Tc { + name: "request all but returned blocks have the same index", + request_slot_id: 0u8, + attributes: SpdmMeasurementAttributes::SIGNATURE_REQUESTED, + operation: SpdmMeasurementOperation::SpdmMeasurementRequestAll, + receive_buffer: (|| -> Box<[u8]> { + let mut v = vec![0x12, 0x60, 0x00, 0x00, 0x02, 0x6E, 0x00, 0x00]; + v.extend_from_slice(fixed_block); + v.extend_from_slice(fixed_block); + v.extend_from_slice(&[0xFF; 32]); + v.extend_from_slice(&[0x10, 0x00]); + v.extend_from_slice(&[0x02; 16]); + v.extend_from_slice(&[0xFF; 96]); // Signature + v.into_boxed_slice() + })(), + expected_result: Err(SPDM_STATUS_INVALID_MSG_FIELD), + }, + ]; + for tc in tt { + executor::add_task(async move { + let (req_config_info, req_provision_info) = create_info(); + let pcidoe_transport_encap = Arc::new(Mutex::new(PciDoeTransportEncap {})); + let device_io = Arc::new(Mutex::new(FakeSpdmDeviceIoReceve::new(Arc::new( + SharedBuffer::new(), + )))); + let mut requester = RequesterContext::new( + device_io, + pcidoe_transport_encap, + req_config_info, + req_provision_info, + ); + requester.common.negotiate_info.spdm_version_sel = SpdmVersion::SpdmVersion12; + requester.common.negotiate_info.req_ct_exponent_sel = 0; + requester.common.negotiate_info.req_capabilities_sel = + SpdmRequestCapabilityFlags::CERT_CAP; + requester.common.negotiate_info.rsp_ct_exponent_sel = 0; + requester.common.negotiate_info.rsp_capabilities_sel = + SpdmResponseCapabilityFlags::CERT_CAP; + requester + .common + .negotiate_info + .measurement_specification_sel = SpdmMeasurementSpecification::DMTF; + requester.common.negotiate_info.base_hash_sel = SpdmBaseHashAlgo::TPM_ALG_SHA_384; + requester.common.negotiate_info.base_asym_sel = + SpdmBaseAsymAlgo::TPM_ALG_ECDSA_ECC_NIST_P384; + requester.common.negotiate_info.measurement_hash_sel = + SpdmMeasurementHashAlgo::TPM_ALG_SHA_384; + requester.common.peer_info.peer_cert_chain[0] = Some(get_rsp_cert_chain_buff()); + requester.common.reset_runtime_info(); + + let session_id = None; + let mut spdm_measurement_record_structure = SpdmMeasurementRecordStructure::default(); + let send_buffer = [0u8; MAX_SPDM_MSG_SIZE]; + let result = requester.handle_spdm_measurement_record_response( + session_id, + tc.request_slot_id, + tc.attributes, + tc.operation, + &mut spdm_measurement_record_structure, + &send_buffer, + &*tc.receive_buffer, + ); + assert!( + result == tc.expected_result, + "tc '{}' expect {:?} got {:?}", + tc.name, + tc.expected_result, + result + ); + }) + } + executor::poll_tasks(); +}