Skip to content
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
4 changes: 4 additions & 0 deletions include/internal/libspdm_common_lib.h
Original file line number Diff line number Diff line change
Expand Up @@ -687,6 +687,10 @@ typedef struct {
#if (LIBSPDM_ENABLE_CAPABILITY_ENCAP_CAP) && (LIBSPDM_SEND_GET_ENDPOINT_INFO_SUPPORT)
libspdm_get_endpoint_info_callback_func get_endpoint_info_callback;
#endif /* (LIBSPDM_ENABLE_CAPABILITY_ENCAP_CAP) && (LIBSPDM_SEND_GET_ENDPOINT_INFO_SUPPORT) */

#if LIBSPDM_ENABLE_CAPABILITY_MEAS_CAP
libspdm_meas_log_reset_callback_func spdm_meas_log_reset_callback;
#endif /* LIBSPDM_ENABLE_CAPABILITY_MEAS_CAP */
} libspdm_context_t;

#define LIBSPDM_CONTEXT_SIZE_WITHOUT_SECURED_CONTEXT (sizeof(libspdm_context_t))
Expand Down
15 changes: 15 additions & 0 deletions include/library/spdm_common_lib.h
Original file line number Diff line number Diff line change
Expand Up @@ -1036,6 +1036,21 @@ typedef libspdm_return_t (*libspdm_get_endpoint_info_callback_func)(
const void *endpoint_info);
#endif /* LIBSPDM_ENABLE_CAPABILITY_ENCAP_CAP && LIBSPDM_SEND_GET_ENDPOINT_INFO_SUPPORT */

#if LIBSPDM_ENABLE_CAPABILITY_MEAS_CAP
/**
* A Callback function to notify integrator measurement log is reset.
* This is used to support the "Content changed" field in the MEASUREMENTS response.
*
* @param spdm_context A pointer to the SPDM context.
* @param session_id A pointer to the session ID.
* If non-NULL then message is within a secure session.
* If NULL then message is outside a secure session.
**/
typedef void (*libspdm_meas_log_reset_callback_func)(
void *spdm_context,
const uint32_t *session_id);
#endif /* LIBSPDM_ENABLE_CAPABILITY_MEAS_CAP */

#ifdef __cplusplus
}
#endif
Expand Down
15 changes: 15 additions & 0 deletions include/library/spdm_responder_lib.h
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,21 @@ libspdm_return_t libspdm_register_get_endpoint_info_callback_func(
void *spdm_context, libspdm_get_endpoint_info_callback_func get_endpoint_info_callback);
#endif /* LIBSPDM_ENABLE_CAPABILITY_ENCAP_CAP && LIBSPDM_SEND_GET_ENDPOINT_INFO_SUPPORT */

#if LIBSPDM_ENABLE_CAPABILITY_MEAS_CAP
/**
* This function registers the callback function for notify
* integrator L1L2 is reset.
*
* @param spdm_context A pointer to the SPDM context.
* @param spdm_meas_log_reset_callback L1L2 reset callback function
*
* @retval LIBSPDM_STATUS_SUCCESS Success
* @retval LIBSPDM_STATUS_INVALID_PARAMETER Some parameters invalid or NULL
*/
libspdm_return_t libspdm_register_meas_log_reset_callback(
void *spdm_context, libspdm_meas_log_reset_callback_func spdm_meas_log_reset_callback);
#endif /* LIBSPDM_ENABLE_CAPABILITY_MEAS_CAP */

/**
* This function allows the consumer to terminate a session.
* For example, it can be used when watchdog fires.
Expand Down
6 changes: 6 additions & 0 deletions library/spdm_common_lib/libspdm_com_context_data.c
Original file line number Diff line number Diff line change
Expand Up @@ -1384,6 +1384,12 @@ void libspdm_reset_message_m(libspdm_context_t *spdm_context, void *session_info
}
}
#endif
#if LIBSPDM_ENABLE_CAPABILITY_MEAS_CAP
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be a pre-existing issue, but presumably all message_m functions should be gated by LIBSPDM_ENABLE_CAPABILITY_MEAS_CAP.

if (spdm_context->spdm_meas_log_reset_callback != NULL) {
spdm_context->spdm_meas_log_reset_callback(
spdm_context, spdm_session_info == NULL ? NULL : &spdm_session_info->session_id);
}
#endif /* LIBSPDM_ENABLE_CAPABILITY_MEAS_CAP */
}

/**
Expand Down
9 changes: 9 additions & 0 deletions library/spdm_responder_lib/libspdm_rsp_measurements.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@
#include "internal/libspdm_responder_lib.h"

#if LIBSPDM_ENABLE_CAPABILITY_MEAS_CAP

libspdm_return_t libspdm_register_meas_log_reset_callback(
void *spdm_context, libspdm_meas_log_reset_callback_func spdm_meas_log_reset_callback)
{
libspdm_context_t *context = (libspdm_context_t *)spdm_context;
context->spdm_meas_log_reset_callback = spdm_meas_log_reset_callback;
return LIBSPDM_STATUS_SUCCESS;
}

bool libspdm_generate_measurement_signature(libspdm_context_t *spdm_context,
libspdm_session_info_t *session_info,
uint8_t slot_id,
Expand Down
22 changes: 22 additions & 0 deletions unit_test/test_spdm_responder/measurements.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,27 @@

#if LIBSPDM_ENABLE_CAPABILITY_MEAS_CAP

void spdm_meas_log_reset_callback (
void *spdm_context,
const uint32_t *session_id)
{
libspdm_context_t *context = spdm_context;
if (session_id == NULL) {
#if LIBSPDM_RECORD_TRANSCRIPT_DATA_SUPPORT
assert_int_equal(context->transcript.message_m.buffer_size, 0);
#else
assert_null(context->transcript.digest_context_l1l2);
#endif
} else {
libspdm_session_info_t* session_info = &context->session_info[0];
#if LIBSPDM_RECORD_TRANSCRIPT_DATA_SUPPORT
assert_int_equal(session_info->session_transcript.message_m.buffer_size, 0);
#else
assert_null(session_info->session_transcript.digest_context_l1l2);
#endif
}
}

spdm_get_measurements_request_t m_libspdm_get_measurements_request1 = {
{ SPDM_MESSAGE_VERSION_10, SPDM_GET_MEASUREMENTS, 0,
SPDM_GET_MEASUREMENTS_REQUEST_MEASUREMENT_OPERATION_TOTAL_NUMBER_OF_MEASUREMENTS },
Expand Down Expand Up @@ -147,6 +168,7 @@ static void rsp_measurements_case1(void **state)
m_libspdm_use_measurement_spec;
spdm_context->connection_info.algorithm.measurement_hash_algo =
m_libspdm_use_measurement_hash_algo;
spdm_context->spdm_meas_log_reset_callback = spdm_meas_log_reset_callback;
libspdm_reset_message_m(spdm_context, NULL);

libspdm_secret_lib_meas_opaque_data_size = 0;
Expand Down