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

Increase MAX_SPDM_VERSION_COUNT to support more versions in VERSION response #128

Merged
merged 1 commit into from
Oct 31, 2024
Merged
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 @@ -121,6 +121,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 @@ -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,
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),
Some(SpdmVersion::SpdmVersion13),
],
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),
Some(SpdmVersion::SpdmVersion13),
],
rsp_capabilities: rsp_capabilities,
rsp_ct_exponent: 0,
Expand Down
2 changes: 1 addition & 1 deletion test/spdmlib-test/src/responder_tests/version_rsp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Loading