This repository has been archived by the owner on Jul 29, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
add support to export the full transcript (VCA + message_m) #109
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,42 +15,52 @@ use crate::protocol::*; | |
use crate::requester::*; | ||
|
||
impl RequesterContext { | ||
#[allow(clippy::too_many_arguments)] | ||
async fn send_receive_spdm_measurement_record( | ||
&mut self, | ||
session_id: Option<u32>, | ||
measurement_attributes: SpdmMeasurementAttributes, | ||
measurement_operation: SpdmMeasurementOperation, | ||
content_changed: &mut Option<SpdmMeasurementContentChanged>, | ||
spdm_measurement_record_structure: &mut SpdmMeasurementRecordStructure, | ||
transcript_meas: &mut Option<ManagedBufferM>, | ||
slot_id: u8, | ||
) -> SpdmResult<u8> { | ||
if transcript_meas.is_none() { | ||
*transcript_meas = Some(ManagedBufferM::default()); | ||
} | ||
|
||
let result = self | ||
.delegate_send_receive_spdm_measurement_record( | ||
session_id, | ||
measurement_attributes, | ||
measurement_operation, | ||
content_changed, | ||
spdm_measurement_record_structure, | ||
transcript_meas, | ||
slot_id, | ||
) | ||
.await; | ||
|
||
if let Err(e) = result { | ||
if e != SPDM_STATUS_NOT_READY_PEER { | ||
self.common.reset_message_m(session_id); | ||
*transcript_meas = None; | ||
} | ||
} | ||
|
||
result | ||
} | ||
|
||
#[allow(clippy::too_many_arguments)] | ||
async fn delegate_send_receive_spdm_measurement_record( | ||
&mut self, | ||
session_id: Option<u32>, | ||
measurement_attributes: SpdmMeasurementAttributes, | ||
measurement_operation: SpdmMeasurementOperation, | ||
content_changed: &mut Option<SpdmMeasurementContentChanged>, | ||
spdm_measurement_record_structure: &mut SpdmMeasurementRecordStructure, | ||
transcript_meas: &mut Option<ManagedBufferM>, | ||
slot_id: u8, | ||
) -> SpdmResult<u8> { | ||
info!("send spdm measurement\n"); | ||
|
@@ -89,6 +99,7 @@ impl RequesterContext { | |
spdm_measurement_record_structure, | ||
&send_buffer[..send_used], | ||
&receive_buffer[..used], | ||
transcript_meas, | ||
) | ||
} | ||
|
||
|
@@ -131,6 +142,7 @@ impl RequesterContext { | |
spdm_measurement_record_structure: &mut SpdmMeasurementRecordStructure, | ||
send_buffer: &[u8], | ||
receive_buffer: &[u8], | ||
transcript_meas: &mut Option<ManagedBufferM>, | ||
) -> SpdmResult<u8> { | ||
self.common.runtime_info.need_measurement_signature = | ||
measurement_attributes.contains(SpdmMeasurementAttributes::SIGNATURE_REQUESTED); | ||
|
@@ -181,6 +193,26 @@ impl RequesterContext { | |
self.common.append_message_m(session_id, send_buffer)?; | ||
self.common | ||
.append_message_m(session_id, &receive_buffer[..temp_used])?; | ||
if let Some(ret_message_m) = transcript_meas { | ||
ret_message_m | ||
.append_message(send_buffer) | ||
.ok_or(SPDM_STATUS_BUFFER_FULL)?; | ||
ret_message_m | ||
.append_message(&receive_buffer[..temp_used]) | ||
.ok_or(SPDM_STATUS_BUFFER_FULL)?; | ||
|
||
if measurement_attributes | ||
.contains(SpdmMeasurementAttributes::SIGNATURE_REQUESTED) | ||
{ | ||
if measurements.signature.as_ref().is_empty() { | ||
return Err(SPDM_STATUS_INVALID_MSG_FIELD); | ||
} else { | ||
ret_message_m | ||
.append_message(measurements.signature.as_ref()) | ||
.ok_or(SPDM_STATUS_BUFFER_FULL)?; | ||
} | ||
} | ||
} | ||
|
||
// verify signature | ||
if measurement_attributes | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Need append signature There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
updated. |
||
|
@@ -247,6 +279,7 @@ impl RequesterContext { | |
out_total_number: &mut u8, // out, total number when measurement_operation = SpdmMeasurementQueryTotalNumber | ||
// number of blocks got measured. | ||
spdm_measurement_record_structure: &mut SpdmMeasurementRecordStructure, // out | ||
transcript_meas: &mut Option<ManagedBufferM>, // out | ||
) -> SpdmResult { | ||
*out_total_number = self | ||
.send_receive_spdm_measurement_record( | ||
|
@@ -255,6 +288,7 @@ impl RequesterContext { | |
measurement_operation, | ||
content_changed, | ||
spdm_measurement_record_structure, | ||
transcript_meas, | ||
slot_id, | ||
) | ||
.await?; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the caller needs to invoke send_receive_spdm_measurement_record() multiple times, then transcript_vca will be copied multiple times.
That is not efficient.
Can we do that in init_connection()?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, updated.