Skip to content

Commit 589fa3b

Browse files
committed
Add MEASUREMENTS response handler stub, add doc
1 parent ee61275 commit 589fa3b

3 files changed

Lines changed: 40 additions & 0 deletions

File tree

examples/spdm_requester.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -493,6 +493,14 @@ fn full_flow(stream: TcpStream, config: &RequesterConfig) -> IoResult<()> {
493493
println!("GET_MEASUREMENTS: {:?}", &message_buffer.message_data());
494494
}
495495

496+
spdm_context
497+
.requester_process_message(&mut message_buffer)
498+
.unwrap();
499+
500+
if config.verbose {
501+
println!("CHALLENGE_AUTH: {:x?}", &message_buffer.message_data());
502+
}
503+
496504
Ok(())
497505
}
498506

src/commands/measurements/request.rs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,27 @@ use crate::{
1111
state::ConnectionState,
1212
};
1313

14+
/// Generate a GET_MEASUREMENTS request
15+
///
16+
/// # Arguments
17+
/// * `ctx`: The SPDM context
18+
/// * `req_buf`: Buffer to write the request into
19+
/// * `raw_bitstream_requested`: Request a raw bit stream (if supported) (SPDM v1.2+)
20+
/// * `new_measurement_requested`: Request new measurement if the responder has pending updates to blocks (SPDM v1.3+)
21+
/// * `meas_op`: Measurement operation
22+
/// (0x00: query total number of available blocks, 0x01-0xFE: query block, 0xFF: query all blocks)
23+
/// * `slot_id`: Request a signed measurement if provided, signed with certificate slot identifier (0-7)
24+
/// * `context`: Append optional 8 byte context (SPDM v1.3+)
25+
///
26+
/// # Returns
27+
/// - () on success
28+
/// - [CommandError] on failure
29+
///
30+
/// # Connection State Requirements
31+
/// - Connection state must be >= AlgorithmsNegotiated
32+
///
33+
/// # Transcript
34+
/// - Appends request to the L1 transcript context
1435
pub fn generate_get_measurements<'a>(
1536
ctx: &mut SpdmContext<'a>,
1637
req_buf: &mut MessageBuf<'a>,
@@ -125,3 +146,12 @@ fn responder_supports_signed_measurements(ctx: &SpdmContext<'_>) -> bool {
125146
return false;
126147
}
127148
}
149+
150+
/// Handle an incoming MEASUREMENTS response
151+
pub(crate) fn handle_measurements_response<'a>(
152+
ctx: &mut SpdmContext<'a>,
153+
resp_header: SpdmMsgHdr,
154+
resp: &mut MessageBuf<'a>,
155+
) -> CommandResult<()> {
156+
todo!()
157+
}

src/context.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use crate::commands::capabilities::handle_capabilities_response;
88
use crate::commands::challenge::handle_challenge_auth_response;
99
use crate::commands::digests::{handle_digests_response, handle_get_digests};
1010
use crate::commands::error_rsp::{encode_error_response, ErrorCode};
11+
use crate::commands::measurements::request::handle_measurements_response;
1112
use crate::commands::version::handle_version_response;
1213
use crate::commands::{
1314
algorithms, capabilities, certificate, challenge, chunk_get_rsp, measurements, version,
@@ -226,6 +227,7 @@ impl<'a> SpdmContext<'a> {
226227
ReqRespCode::ChallengeAuth => {
227228
handle_challenge_auth_response(self, resp_msg_header, resp)?
228229
}
230+
ReqRespCode::Measurements => handle_measurements_response(self, resp_msg_header, resp)?,
229231
_ => Err((false, CommandError::UnsupportedResponse))?,
230232
}
231233

0 commit comments

Comments
 (0)