From eb134fc8d6d5b6308d843e763c91b82e1e0f38b8 Mon Sep 17 00:00:00 2001 From: "Lu, Xiaoyu1" Date: Wed, 30 Oct 2024 21:16:03 -0400 Subject: [PATCH] Increase MAX_SPDM_VERSION_COUNT to support more versions in VERSION response Signed-off-by: xiaoyuxlu --- spdmlib/src/protocol/version.rs | 6 +++++- test/spdm-requester-emu/src/main.rs | 2 ++ test/spdm-responder-emu/src/main.rs | 1 + test/spdmlib-test/src/common/util.rs | 3 +++ test/spdmlib-test/src/responder_tests/version_rsp.rs | 2 +- 5 files changed, 12 insertions(+), 2 deletions(-) diff --git a/spdmlib/src/protocol/version.rs b/spdmlib/src/protocol/version.rs index e42d487..b49e17e 100644 --- a/spdmlib/src/protocol/version.rs +++ b/spdmlib/src/protocol/version.rs @@ -10,6 +10,7 @@ pub enum SpdmVersion { SpdmVersion10, SpdmVersion11, SpdmVersion12, + SpdmVersion13, } impl Default for SpdmVersion { @@ -27,6 +28,8 @@ impl TryFrom for SpdmVersion { Ok(SpdmVersion::SpdmVersion11) } else if untrusted_spdm_version == 0x12 { Ok(SpdmVersion::SpdmVersion12) + } else if untrusted_spdm_version == 0x13 { + Ok(SpdmVersion::SpdmVersion13) } else { Err(()) } @@ -39,6 +42,7 @@ impl From for u8 { SpdmVersion::SpdmVersion10 => 0x10, SpdmVersion::SpdmVersion11 => 0x11, SpdmVersion::SpdmVersion12 => 0x12, + SpdmVersion::SpdmVersion13 => 0x13, } } } @@ -60,7 +64,7 @@ impl Codec for SpdmVersion { } } -pub const MAX_SPDM_VERSION_COUNT: usize = 3; +pub const MAX_SPDM_VERSION_COUNT: usize = 4; //SPDM V1.2 signing prefix context pub const SPDM_VERSION_1_2_SIGNING_PREFIX_CONTEXT: [u8; 64] = [ diff --git a/test/spdm-requester-emu/src/main.rs b/test/spdm-requester-emu/src/main.rs index 853406f..fd2a934 100644 --- a/test/spdm-requester-emu/src/main.rs +++ b/test/spdm-requester-emu/src/main.rs @@ -121,6 +121,7 @@ async fn test_spdm( Some(SpdmVersion::SpdmVersion10), Some(SpdmVersion::SpdmVersion11), Some(SpdmVersion::SpdmVersion12), + None, ], req_capabilities, req_ct_exponent: 0, @@ -609,6 +610,7 @@ async fn test_idekm_tdisp( Some(SpdmVersion::SpdmVersion10), Some(SpdmVersion::SpdmVersion11), Some(SpdmVersion::SpdmVersion12), + None, ], req_capabilities, req_ct_exponent: 0, diff --git a/test/spdm-responder-emu/src/main.rs b/test/spdm-responder-emu/src/main.rs index d41289f..481a865 100644 --- a/test/spdm-responder-emu/src/main.rs +++ b/test/spdm-responder-emu/src/main.rs @@ -285,6 +285,7 @@ async fn handle_message( Some(SpdmVersion::SpdmVersion10), Some(SpdmVersion::SpdmVersion11), Some(SpdmVersion::SpdmVersion12), + None, ], rsp_capabilities, rsp_ct_exponent: 0, diff --git a/test/spdmlib-test/src/common/util.rs b/test/spdmlib-test/src/common/util.rs index d846db1..02148b3 100644 --- a/test/spdmlib-test/src/common/util.rs +++ b/test/spdmlib-test/src/common/util.rs @@ -37,6 +37,7 @@ pub fn create_info() -> (SpdmConfigInfo, SpdmProvisionInfo) { Some(SpdmVersion::SpdmVersion10), Some(SpdmVersion::SpdmVersion11), Some(SpdmVersion::SpdmVersion12), + Some(SpdmVersion::SpdmVersion13), ], rsp_capabilities: SpdmResponseCapabilityFlags::CERT_CAP | SpdmResponseCapabilityFlags::CHAL_CAP @@ -176,6 +177,7 @@ pub fn req_create_info() -> (SpdmConfigInfo, SpdmProvisionInfo) { Some(SpdmVersion::SpdmVersion10), Some(SpdmVersion::SpdmVersion11), Some(SpdmVersion::SpdmVersion12), + None, ], req_capabilities: req_capabilities, req_ct_exponent: 0, @@ -305,6 +307,7 @@ pub fn rsp_create_info() -> (SpdmConfigInfo, SpdmProvisionInfo) { Some(SpdmVersion::SpdmVersion10), Some(SpdmVersion::SpdmVersion11), Some(SpdmVersion::SpdmVersion12), + Some(SpdmVersion::SpdmVersion13), ], rsp_capabilities: rsp_capabilities, rsp_ct_exponent: 0, diff --git a/test/spdmlib-test/src/responder_tests/version_rsp.rs b/test/spdmlib-test/src/responder_tests/version_rsp.rs index 0000a1f..d6fb6fa 100644 --- a/test/spdmlib-test/src/responder_tests/version_rsp.rs +++ b/test/spdmlib-test/src/responder_tests/version_rsp.rs @@ -73,7 +73,7 @@ fn test_case0_handle_spdm_version() { SpdmRequestResponseCode::SpdmResponseVersion ); if let SpdmMessagePayload::SpdmVersionResponse(payload) = &spdm_message.payload { - assert_eq!(payload.version_number_entry_count, 0x03); + assert_eq!(payload.version_number_entry_count, 0x04); assert_eq!(payload.versions[0].update, 0); assert_eq!(payload.versions[0].version, SpdmVersion::SpdmVersion10); assert_eq!(payload.versions[1].update, 0);