Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add SpdmVersion13 enum value. #21

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion spdmlib/src/protocol/version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ pub enum SpdmVersion {
SpdmVersion10,
SpdmVersion11,
SpdmVersion12,
SpdmVersion13,
}

impl Default for SpdmVersion {
Expand All @@ -27,6 +28,8 @@ impl TryFrom<u8> 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(())
}
Expand All @@ -39,6 +42,7 @@ impl From<SpdmVersion> for u8 {
SpdmVersion::SpdmVersion10 => 0x10,
SpdmVersion::SpdmVersion11 => 0x11,
SpdmVersion::SpdmVersion12 => 0x12,
SpdmVersion::SpdmVersion13 => 0x13,
}
}
}
Expand All @@ -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] = [
Expand Down
2 changes: 2 additions & 0 deletions test/spdm-requester-emu/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ async fn test_spdm(
Some(SpdmVersion::SpdmVersion10),
Some(SpdmVersion::SpdmVersion11),
Some(SpdmVersion::SpdmVersion12),
None,
],
req_capabilities,
req_ct_exponent: 0,
Expand Down Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions test/spdm-responder-emu/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ async fn handle_message(
Some(SpdmVersion::SpdmVersion10),
Some(SpdmVersion::SpdmVersion11),
Some(SpdmVersion::SpdmVersion12),
None,
],
rsp_capabilities,
rsp_ct_exponent: 0,
Expand Down
3 changes: 3 additions & 0 deletions test/spdmlib-test/src/common/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
9 changes: 3 additions & 6 deletions test/spdmlib-test/src/responder_tests/version_rsp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<u16> = 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 {
Expand All @@ -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,
};
Expand Down
Loading