From 5a258c72f6b7a23a03aa0d440c9fd44a422ee652 Mon Sep 17 00:00:00 2001 From: "Yang, Longlong" Date: Mon, 22 Jan 2024 02:04:26 -0500 Subject: [PATCH] add SpdmVersion13 enum value. Signed-off-by: Yang, Longlong --- 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 | 9 +++------ 5 files changed, 14 insertions(+), 7 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 9c4077e..3cbc344 100644 --- a/test/spdm-requester-emu/src/main.rs +++ b/test/spdm-requester-emu/src/main.rs @@ -155,6 +155,7 @@ async fn test_spdm( Some(SpdmVersion::SpdmVersion10), Some(SpdmVersion::SpdmVersion11), Some(SpdmVersion::SpdmVersion12), + None, ], req_capabilities, req_ct_exponent: 0, @@ -460,6 +461,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 2b558e0..c5d10a6 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..c80e624 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), + None, ], 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), + None, ], 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..062ba4b 100644 --- a/test/spdmlib-test/src/responder_tests/version_rsp.rs +++ b/test/spdmlib-test/src/responder_tests/version_rsp.rs @@ -98,12 +98,9 @@ pub fn construct_version_positive() -> (TestSpdmMessage, TestSpdmMessage) { }; let (config_info, provision_info) = create_info(); let mut VersionNumberEntryCount = 0; - let mut VersionNumberEntry: [u16; MAX_SPDM_VERSION_COUNT] = gen_array_clone( - u8::from(SpdmVersion::default()) as u16, - MAX_SPDM_VERSION_COUNT, - ); + let mut VersionNumberEntry: Vec = vec![]; for (_, v) in config_info.spdm_version.iter().flatten().enumerate() { - VersionNumberEntry[VersionNumberEntryCount] = (u8::from(*v) as u16) << 8; + VersionNumberEntry.push((u8::from(*v) as u16) << 8); VersionNumberEntryCount += 1; } let version_msg = TestSpdmMessage { @@ -114,7 +111,7 @@ pub fn construct_version_positive() -> (TestSpdmMessage, TestSpdmMessage) { Param2: 0, Reserved: 0, VersionNumberEntryCount: VersionNumberEntryCount as u8, - VersionNumberEntry: VersionNumberEntry.to_vec(), + VersionNumberEntry, }), secure: 0, };