Skip to content

Commit

Permalink
req_communication: pass session ID to transport
Browse files Browse the repository at this point in the history
This allows transports such as Storage (DSP0286) to determine if the
next response is protected via secured messages. Unlike other transport
layers, storage does not encode the message type in a response header.
As such, the requester must track the expected type.

The issue [1] discusses this implementation requirement in further
detail with regards to DSP0286.

[1] DMTF/SPDM-WG#3520

Signed-off-by: Wilfred Mallawa <[email protected]>
Signed-off-by: Alistair Francis <[email protected]>
  • Loading branch information
twilfredo committed Oct 2, 2024
1 parent 3e473dc commit 5569c6c
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions library/spdm_requester_lib/libspdm_req_send_receive.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ libspdm_return_t libspdm_receive_response(void *spdm_context, const uint32_t *se
libspdm_return_t status;
uint8_t *message;
size_t message_size;
uint32_t *message_session_id;
uint32_t *message_session_id, message_id;
bool is_message_app_message;
uint64_t timeout;
size_t transport_header_size;
Expand Down Expand Up @@ -163,7 +163,22 @@ libspdm_return_t libspdm_receive_response(void *spdm_context, const uint32_t *se
return status;
}

message_session_id = NULL;
/*
* The storage transport encoding, defined by DSP0286, does not indicate
* if we are/are not in a secure session in the transport data. This is
* different to most other transport encodings, which includes session
* information in the encoding.
*
* As such if we are in a secure session, session_id != NULL, we set
* message_session_id to be non-NULL to indicate to the lower layer
* that we are in a secure session.
*/
if (session_id != NULL) {
message_session_id = &message_id;
message_id = *session_id;
} else {
message_session_id = NULL;
}
is_message_app_message = false;

/* always use scratch buffer to response.
Expand Down Expand Up @@ -211,7 +226,11 @@ libspdm_return_t libspdm_receive_response(void *spdm_context, const uint32_t *se

/* Retry decoding message with backup Requester key.
* Must reset some of the parameters in case they were modified */
message_session_id = NULL;
if (session_id != NULL) {
*message_session_id = *session_id;
} else {
message_session_id = NULL;
}
is_message_app_message = false;
*response = backup_response;
*response_size = backup_response_size;
Expand Down

0 comments on commit 5569c6c

Please sign in to comment.