Skip to content

Commit

Permalink
Add SPDM 1.3 feature GET_ENDPOINT_INFO
Browse files Browse the repository at this point in the history
ENDPOINT_INFO is SPDM spec 1.3 new feature.
Add ENDPOINT_INFO for Libspdm.

Signed-off-by: Aaron Li <aaron.li@intel.com>
  • Loading branch information
Li-Aaron committed Mar 7, 2025
1 parent 8528ec2 commit 850d8f4
Show file tree
Hide file tree
Showing 10 changed files with 165 additions and 7 deletions.
2 changes: 1 addition & 1 deletion libspdm
Submodule libspdm updated 79 files
+1 −1 .github/workflows/cifuzz.yml
+2 −0 CMakeLists.txt
+8 −6 README.md
+1 −1 VERSION.md
+2 −2 include/industry_standard/cxl_idekm.h
+132 −4 include/industry_standard/spdm.h
+198 −3 include/internal/libspdm_common_lib.h
+9 −1 include/internal/libspdm_requester_lib.h
+10 −1 include/internal/libspdm_responder_lib.h
+69 −2 include/library/spdm_common_lib.h
+12 −1 include/library/spdm_lib_config.h
+35 −1 include/library/spdm_requester_lib.h
+19 −1 include/library/spdm_responder_lib.h
+2 −2 include/library/spdm_transport_pcidoe_lib.h
+335 −11 library/spdm_common_lib/libspdm_com_context_data.c
+4 −0 library/spdm_common_lib/libspdm_com_context_data_session.c
+450 −1 library/spdm_common_lib/libspdm_com_crypto_service.c
+109 −1 library/spdm_common_lib/libspdm_com_support.c
+2 −2 library/spdm_crypt_lib/fips/libspdm_selftest.c
+2 −2 library/spdm_crypt_lib/fips/libspdm_selftest_aes_gcm.c
+2 −2 library/spdm_crypt_lib/fips/libspdm_selftest_ecdh.c
+2 −2 library/spdm_crypt_lib/fips/libspdm_selftest_ecdsa.c
+2 −2 library/spdm_crypt_lib/fips/libspdm_selftest_eddsa.c
+2 −2 library/spdm_crypt_lib/fips/libspdm_selftest_ffdh.c
+2 −2 library/spdm_crypt_lib/fips/libspdm_selftest_hkdf.c
+4 −4 library/spdm_crypt_lib/fips/libspdm_selftest_hmac.c
+2 −2 library/spdm_crypt_lib/fips/libspdm_selftest_rsa_pss.c
+2 −2 library/spdm_crypt_lib/fips/libspdm_selftest_rsa_ssa.c
+4 −4 library/spdm_crypt_lib/fips/libspdm_selftest_sha2.c
+4 −4 library/spdm_crypt_lib/fips/libspdm_selftest_sha3.c
+5 −1 library/spdm_crypt_lib/libspdm_crypt_asym.c
+3 −3 library/spdm_crypt_lib/libspdm_crypt_cert.c
+9 −9 library/spdm_crypt_lib/libspdm_crypt_hmac.c
+2 −0 library/spdm_requester_lib/CMakeLists.txt
+328 −0 library/spdm_requester_lib/libspdm_req_encap_event_ack.c
+10 −4 library/spdm_requester_lib/libspdm_req_encap_key_update.c
+5 −1 library/spdm_requester_lib/libspdm_req_encap_request.c
+9 −1 library/spdm_requester_lib/libspdm_req_get_capabilities.c
+346 −0 library/spdm_requester_lib/libspdm_req_get_endpoint_info.c
+16 −1 library/spdm_requester_lib/libspdm_req_handle_error_response.c
+3 −7 library/spdm_requester_lib/libspdm_req_key_exchange.c
+6 −6 library/spdm_requester_lib/libspdm_req_negotiate_algorithms.c
+2 −2 library/spdm_requester_lib/libspdm_req_psk_exchange.c
+16 −5 library/spdm_requester_lib/libspdm_req_send_receive.c
+1 −0 library/spdm_responder_lib/CMakeLists.txt
+3 −3 library/spdm_responder_lib/libspdm_rsp_algorithms.c
+9 −1 library/spdm_responder_lib/libspdm_rsp_capabilities.c
+17 −3 library/spdm_responder_lib/libspdm_rsp_chunk_get.c
+9 −1 library/spdm_responder_lib/libspdm_rsp_chunk_send_ack.c
+2 −5 library/spdm_responder_lib/libspdm_rsp_encap_response.c
+278 −0 library/spdm_responder_lib/libspdm_rsp_endpoint_info.c
+3 −3 library/spdm_responder_lib/libspdm_rsp_measurement_extension_log.c
+2 −2 library/spdm_responder_lib/libspdm_rsp_psk_exchange.c
+5 −1 library/spdm_responder_lib/libspdm_rsp_receive_send.c
+7 −10 library/spdm_responder_lib/libspdm_rsp_set_key_pair_info_ack.c
+3 −3 library/spdm_transport_pcidoe_lib/libspdm_doe_pcidoe.c
+1 −1 unit_test/fuzzing/spdm_unit_fuzzing_common/algo.c
+3 −3 unit_test/fuzzing/test_requester/test_spdm_requester_get_event_types/get_event_types.c
+1 −1 unit_test/spdm_unit_test_common/algo.c
+48 −1 unit_test/spdm_unit_test_common/event_support.c
+10 −1 unit_test/spdm_unit_test_common/spdm_unit_test.h
+4 −3 unit_test/test_size/intrinsiclib/memory_intrinsics.c
+2 −2 unit_test/test_size/test_size_of_spdm_requester/spdm_requester_init.c
+2 −2 unit_test/test_size/test_size_of_spdm_responder/spdm_responder_init.c
+1 −1 unit_test/test_spdm_common/context_data.c
+2 −2 unit_test/test_spdm_fips/test_spdm_fips.c
+3 −0 unit_test/test_spdm_requester/CMakeLists.txt
+92 −1 unit_test/test_spdm_requester/chunk_get.c
+77 −1 unit_test/test_spdm_requester/chunk_send.c
+474 −0 unit_test/test_spdm_requester/encap_event_ack.c
+380 −0 unit_test/test_spdm_requester/error_test/encap_event_ack_err.c
+3,339 −0 unit_test/test_spdm_requester/get_endpoint_info.c
+23 −1 unit_test/test_spdm_requester/test_spdm_requester.c
+1 −0 unit_test/test_spdm_responder/CMakeLists.txt
+23 −23 unit_test/test_spdm_responder/algorithms.c
+98 −1 unit_test/test_spdm_responder/chunk_get.c
+165 −2 unit_test/test_spdm_responder/chunk_send_ack.c
+1,695 −0 unit_test/test_spdm_responder/endpoint_info.c
+10 −0 unit_test/test_spdm_responder/test_spdm_responder.c
2 changes: 2 additions & 0 deletions spdm_emu/spdm_emu_common/key.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ uint32_t m_use_requester_capability_flags =
SPDM_GET_CAPABILITIES_REQUEST_FLAGS_CHUNK_CAP |
/* SPDM_GET_CAPABILITIES_REQUEST_FLAGS_PUB_KEY_ID_CAP | conflict with SPDM_GET_CAPABILITIES_REQUEST_FLAGS_CERT_CAP */
SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MULTI_KEY_CAP_NEG |
SPDM_GET_CAPABILITIES_REQUEST_FLAGS_EP_INFO_CAP_SIG |
0);
uint32_t m_use_responder_capability_flags =
(0 | SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_CACHE_CAP |
Expand Down Expand Up @@ -52,6 +53,7 @@ uint32_t m_use_responder_capability_flags =
SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MULTI_KEY_CAP_NEG |
SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_GET_KEY_PAIR_INFO_CAP |
SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_SET_KEY_PAIR_INFO_CAP |
SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_EP_INFO_CAP_SIG |
0);

uint32_t m_use_capability_flags = 0;
Expand Down
18 changes: 12 additions & 6 deletions spdm_emu/spdm_emu_common/spdm_emu.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ uint32_t m_exe_connection = (0 |
EXE_CONNECTION_DIGEST | EXE_CONNECTION_CERT |
EXE_CONNECTION_CHAL | EXE_CONNECTION_MEAS | EXE_CONNECTION_MEL |
EXE_CONNECTION_SET_CERT | EXE_CONNECTION_GET_CSR |
EXE_CONNECTION_GET_KEY_PAIR_INFO | EXE_CONNECTION_SET_KEY_PAIR_INFO | 0);
EXE_CONNECTION_GET_KEY_PAIR_INFO | EXE_CONNECTION_SET_KEY_PAIR_INFO |
EXE_CONNECTION_EP_INFO | 0);

uint32_t m_exe_session =
(0 | EXE_SESSION_KEY_EX | EXE_SESSION_PSK |
Expand All @@ -26,7 +27,8 @@ uint32_t m_exe_session =
EXE_SESSION_MEAS | EXE_SESSION_MEL |
EXE_SESSION_SET_CERT | EXE_SESSION_GET_CSR |
EXE_SESSION_GET_KEY_PAIR_INFO | EXE_SESSION_SET_KEY_PAIR_INFO |
EXE_SESSION_DIGEST | EXE_SESSION_CERT | EXE_SESSION_APP | 0);
EXE_SESSION_DIGEST | EXE_SESSION_CERT | EXE_SESSION_APP |
EXE_SESSION_EP_INFO | 0);

#define IP_ADDRESS "127.0.0.1"

Expand Down Expand Up @@ -71,8 +73,8 @@ void print_usage(const char *name)
printf(" [--save_state <NegotiateStateFileName>]\n");
printf(" [--load_state <NegotiateStateFileName>]\n");
printf(" [--exe_mode SHUTDOWN|CONTINUE]\n");
printf(" [--exe_conn VER_ONLY|VCA|DIGEST|CERT|CHAL|MEAS|MEL|GET_CSR|SET_CERT|GET_KEY_PAIR_INFO|SET_KEY_PAIR_INFO]\n");
printf(" [--exe_session KEY_EX|PSK|NO_END|KEY_UPDATE|HEARTBEAT|MEAS|MEL|DIGEST|CERT|GET_CSR|SET_CERT|GET_KEY_PAIR_INFO|SET_KEY_PAIR_INFO|APP]\n");
printf(" [--exe_conn VER_ONLY|VCA|DIGEST|CERT|CHAL|MEAS|MEL|GET_CSR|SET_CERT|GET_KEY_PAIR_INFO|SET_KEY_PAIR_INFO|EP_INFO]\n");
printf(" [--exe_session KEY_EX|PSK|NO_END|KEY_UPDATE|HEARTBEAT|MEAS|MEL|DIGEST|CERT|GET_CSR|SET_CERT|GET_KEY_PAIR_INFO|SET_KEY_PAIR_INFO|EP_INFO|APP]\n");
printf(" [--pcap <pcap_file_name>]\n");
printf(" [--priv_key_mode PEM|RAW]\n");
printf("\n");
Expand Down Expand Up @@ -154,7 +156,7 @@ void print_usage(const char *name)
printf(
" CONTINUE means the requester asks the responder to preserve the current SPDM context.\n");
printf(
" [--exe_conn] is used to control the SPDM connection. By default, it is DIGEST,CERT,CHAL,MEAS,MEL,GET_CSR,SET_CERT,GET_KEY_PAIR_INFO,SET_KEY_PAIR_INFO.\n");
" [--exe_conn] is used to control the SPDM connection. By default, it is DIGEST,CERT,CHAL,MEAS,MEL,GET_CSR,SET_CERT,GET_KEY_PAIR_INFO,SET_KEY_PAIR_INFO,EP_INFO.\n");
printf(
" VER_ONLY means REQUESTER does not send GET_CAPABILITIES/NEGOTIATE_ALGORITHMS. It is used for quick symmetric authentication with PSK.\n");
printf(" The version for responder must be provisioned from ver.\n");
Expand All @@ -171,8 +173,9 @@ void print_usage(const char *name)
printf(" SET_CERT means send SET_CERTIFICATE command.\n");
printf(" GET_KEY_PAIR_INFO means send GET_KEY_PAIR_INFO command.\n");
printf(" SET_KEY_PAIR_INFO means send SET_KEY_PAIR_INFO command.\n");
printf(" EP_INFO means send GET_ENDPOINT_INFO command.\n");
printf(
" [--exe_session] is used to control the SPDM session. By default, it is KEY_EX,PSK,KEY_UPDATE,HEARTBEAT,MEAS,MEL,DIGEST,CERT,GET_CSR,SET_CERT,GET_KEY_PAIR_INFO,SET_KEY_PAIR_INFO,APP.\n");
" [--exe_session] is used to control the SPDM session. By default, it is KEY_EX,PSK,KEY_UPDATE,HEARTBEAT,MEAS,MEL,DIGEST,CERT,GET_CSR,SET_CERT,GET_KEY_PAIR_INFO,SET_KEY_PAIR_INFO,EP_INFO,APP.\n");
printf(" KEY_EX means to setup KEY_EXCHANGE session.\n");
printf(" PSK means to setup PSK_EXCHANGE session.\n");
printf(" NO_END means to not send END_SESSION.\n");
Expand All @@ -186,6 +189,7 @@ void print_usage(const char *name)
printf(" SET_CERT means send SET_CERTIFICATE command in session.\n");
printf(" GET_KEY_PAIR_INFO means send GET_KEY_PAIR_INFO command in session.\n");
printf(" SET_KEY_PAIR_INFO means send SET_KEY_PAIR_INFO command in session.\n");
printf(" EP_INFO means send GET_ENDPOINT_INFO command in session.\n");
printf(" APP means send vendor defined message or application message in session.\n");
printf(" [--pcap] is used to generate PCAP dump file for offline analysis.\n");
printf(
Expand Down Expand Up @@ -422,6 +426,7 @@ value_string_entry_t m_exe_connection_string_table[] = {
{ EXE_CONNECTION_GET_CSR, "GET_CSR" },
{ EXE_CONNECTION_GET_KEY_PAIR_INFO, "GET_KEY_PAIR_INFO" },
{ EXE_CONNECTION_SET_KEY_PAIR_INFO, "SET_KEY_PAIR_INFO" },
{ EXE_CONNECTION_EP_INFO, "EP_INFO" },
};

value_string_entry_t m_exe_session_string_table[] = {
Expand All @@ -439,6 +444,7 @@ value_string_entry_t m_exe_session_string_table[] = {
{ EXE_SESSION_SET_CERT, "SET_CERT" },
{ EXE_SESSION_GET_CSR, "GET_CSR" },
{ EXE_SESSION_APP, "APP" },
{ EXE_SESSION_EP_INFO, "EP_INFO" },
};

bool get_value_from_name(const value_string_entry_t *table,
Expand Down
2 changes: 2 additions & 0 deletions spdm_emu/spdm_emu_common/spdm_emu.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ extern uint32_t m_exe_mode;
#define EXE_CONNECTION_MEL 0x80
#define EXE_CONNECTION_GET_KEY_PAIR_INFO 0x100
#define EXE_CONNECTION_SET_KEY_PAIR_INFO 0x200
#define EXE_CONNECTION_EP_INFO 0x400
extern uint32_t m_exe_connection;

#define EXE_SESSION_KEY_EX 0x1
Expand All @@ -95,6 +96,7 @@ extern uint32_t m_exe_connection;
#define EXE_SESSION_MEL 0x800
#define EXE_SESSION_GET_KEY_PAIR_INFO 0x1000
#define EXE_SESSION_SET_KEY_PAIR_INFO 0x2000
#define EXE_SESSION_EP_INFO 0x4000
extern uint32_t m_exe_session;

void libspdm_dump_hex_str(const uint8_t *buffer, size_t buffer_size);
Expand Down
1 change: 1 addition & 0 deletions spdm_emu/spdm_requester_emu/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ include_directories(${PROJECT_SOURCE_DIR}/spdm_emu/spdm_requester_emu
set(src_spdm_requester_emu
spdm_requester_spdm.c
spdm_requester_authentication.c
spdm_requester_endpoint_info.c
spdm_requester_measurement.c
spdm_requester_key_pair_info.c
spdm_requester_session.c
Expand Down
16 changes: 16 additions & 0 deletions spdm_emu/spdm_requester_emu/spdm_requester_emu.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ libspdm_return_t do_measurement_via_spdm(const uint32_t *session_id);
libspdm_return_t do_measurement_mel_via_spdm(const uint32_t *session_id);
#endif /*LIBSPDM_ENABLE_CAPABILITY_MEL_CAP*/

#if LIBSPDM_ENABLE_ENDPOINT_INFO_CAP
libspdm_return_t do_get_endpoint_info_via_spdm(const uint32_t *session_id);
#endif /*LIBSPDM_ENABLE_ENDPOINT_INFO_CAP*/

#if LIBSPDM_ENABLE_CAPABILITY_GET_KEY_PAIR_INFO_CAP
libspdm_return_t do_get_key_pair_info_via_spdm(const uint32_t *session_id);
#endif /*LIBSPDM_ENABLE_CAPABILITY_GET_KEY_PAIR_INFO_CAP*/
Expand Down Expand Up @@ -145,6 +149,18 @@ bool platform_client_routine(uint16_t port_number)
}
#endif /*LIBSPDM_ENABLE_CAPABILITY_MEL_CAP*/

#if LIBSPDM_ENABLE_ENDPOINT_INFO_CAP
if ((m_exe_connection & EXE_CONNECTION_EP_INFO) != 0 &&
(m_use_version >= SPDM_MESSAGE_VERSION_13)) {
status = do_get_endpoint_info_via_spdm(NULL);
if (LIBSPDM_STATUS_IS_ERROR(status)) {
printf("do_get_endpoint_info_via_spdm - %x\n",
(uint32_t)status);
goto done;
}
}
#endif /*LIBSPDM_ENABLE_ENDPOINT_INFO_CAP*/

#if LIBSPDM_ENABLE_CAPABILITY_GET_KEY_PAIR_INFO_CAP
if (((m_exe_connection & EXE_CONNECTION_GET_KEY_PAIR_INFO) != 0) &&
(m_use_version >= SPDM_MESSAGE_VERSION_13)) {
Expand Down
43 changes: 43 additions & 0 deletions spdm_emu/spdm_requester_emu/spdm_requester_endpoint_info.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/**
* Copyright Notice:
* Copyright 2025 DMTF. All rights reserved.
* License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/spdm-emu/blob/main/LICENSE.md
**/

#include "spdm_requester_emu.h"

#if LIBSPDM_ENABLE_ENDPOINT_INFO_CAP

extern void *m_spdm_context;

/**
* This function executes SPDM endpoint info.
*
* @param[in] spdm_context The SPDM context for the device.
**/
libspdm_return_t do_get_endpoint_info_via_spdm(const uint32_t *session_id)
{
libspdm_return_t status;
void *spdm_context;
uint8_t sub_code;
uint8_t request_attributes;
uint32_t ep_info_length;
uint8_t ep_info_record[LIBSPDM_MAX_ENDPOINT_INFO_LENGTH];

spdm_context = m_spdm_context;

sub_code = SPDM_GET_ENDPOINT_INFO_REQUEST_SUBCODE_DEVICE_CLASS_IDENTIFIER;
request_attributes =
SPDM_GET_ENDPOINT_INFO_REQUEST_ATTRIBUTE_SIGNATURE_REQUESTED;

status = libspdm_get_endpoint_info(spdm_context, session_id, request_attributes,
sub_code, m_use_slot_id & SPDM_GET_ENDPOINT_INFO_REQUEST_SLOT_ID_MASK,
&ep_info_length, ep_info_record,
NULL, NULL, NULL);
if (LIBSPDM_STATUS_IS_ERROR(status)) {
return status;
}
return LIBSPDM_STATUS_SUCCESS;
}

#endif /*LIBSPDM_ENABLE_ENDPOINT_INFO_CAP*/
15 changes: 15 additions & 0 deletions spdm_emu/spdm_requester_emu/spdm_requester_session.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ libspdm_return_t do_measurement_via_spdm(const uint32_t *session_id);
libspdm_return_t do_measurement_mel_via_spdm(const uint32_t *session_id);
#endif /*LIBSPDM_ENABLE_CAPABILITY_MEL_CAP*/

#if LIBSPDM_ENABLE_ENDPOINT_INFO_CAP
libspdm_return_t do_get_endpoint_info_via_spdm(const uint32_t *session_id);
#endif /*LIBSPDM_ENABLE_ENDPOINT_INFO_CAP*/

#if LIBSPDM_ENABLE_CAPABILITY_GET_KEY_PAIR_INFO_CAP
libspdm_return_t do_get_key_pair_info_via_spdm(const uint32_t *session_id);
#endif /*LIBSPDM_ENABLE_CAPABILITY_GET_KEY_PAIR_INFO_CAP*/
Expand Down Expand Up @@ -194,6 +198,17 @@ libspdm_return_t do_session_via_spdm(bool use_psk)
}
#endif /*LIBSPDM_ENABLE_CAPABILITY_MEL_CAP*/

#if LIBSPDM_ENABLE_ENDPOINT_INFO_CAP
if ((m_exe_session & EXE_SESSION_EP_INFO) != 0 &&
(m_use_version >= SPDM_MESSAGE_VERSION_13)) {
status = do_get_endpoint_info_via_spdm(&session_id);
if (LIBSPDM_STATUS_IS_ERROR(status)) {
printf("do_get_endpoint_info_via_spdm - %x\n",
(uint32_t)status);
}
}
#endif /*LIBSPDM_ENABLE_ENDPOINT_INFO_CAP*/

#if LIBSPDM_ENABLE_CAPABILITY_GET_KEY_PAIR_INFO_CAP
if (((m_exe_session & EXE_SESSION_GET_KEY_PAIR_INFO) != 0) &&
(m_use_version >= SPDM_MESSAGE_VERSION_13)) {
Expand Down
7 changes: 7 additions & 0 deletions spdm_emu/spdm_requester_emu/spdm_requester_spdm.c
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,11 @@ void *spdm_client_init(void)
m_exe_session &= ~EXE_CONNECTION_SET_KEY_PAIR_INFO;
}

if ((SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_EP_INFO_CAP_SIG & responder_capabilities_flag) == 0) {
m_exe_connection &= ~EXE_CONNECTION_EP_INFO;
m_exe_session &= ~EXE_SESSION_EP_INFO;
}

data_size = sizeof(data32);
libspdm_get_data(spdm_context, LIBSPDM_DATA_CONNECTION_STATE, &parameter,
&data32, &data_size);
Expand Down Expand Up @@ -440,8 +445,10 @@ void *spdm_client_init(void)
if (((m_exe_connection & EXE_CONNECTION_CERT) == 0) && (m_use_slot_id != 0xFF)) {
m_exe_connection &= ~EXE_CONNECTION_CHAL;
m_exe_connection &= ~EXE_CONNECTION_MEAS;
m_exe_connection &= ~EXE_CONNECTION_EP_INFO;
m_exe_session &= ~EXE_SESSION_KEY_EX;
m_exe_session &= ~EXE_SESSION_MEAS;
m_exe_session &= ~EXE_SESSION_EP_INFO;
}

printf("slot_id - %x\n", m_use_slot_id);
Expand Down
66 changes: 66 additions & 0 deletions spdm_emu/spdm_responder_emu/spdm_responder_spdm.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ libspdm_return_t spdm_get_response_vendor_defined_request(
size_t request_size, const void *request, size_t *response_size,
void *response);

libspdm_return_t spdm_server_endpoint_info(
void *spdm_context, uint8_t sub_code,
uint32_t *endpoint_info_size, void *endpoint_info);

libspdm_return_t spdm_device_send_message(void *spdm_context,
size_t response_size, const void *response,
uint64_t timeout)
Expand Down Expand Up @@ -309,6 +313,9 @@ void *spdm_server_init(void)
libspdm_register_connection_state_callback_func(
spdm_context, spdm_server_connection_state_callback);

libspdm_register_endpoint_info_device_func(
spdm_context, spdm_server_endpoint_info);

if (m_load_state_file_name != NULL) {
/* Invoke callback to provision the rest*/
spdm_server_connection_state_callback(
Expand Down Expand Up @@ -627,3 +634,62 @@ void spdm_server_session_state_callback(void *spdm_context,
break;
}
}

libspdm_return_t spdm_server_endpoint_info(
void *spdm_context, uint8_t sub_code,
uint32_t *endpoint_info_size, void *endpoint_info)
{
uint8_t *ptr;
spdm_endpoint_info_device_class_identifier_t *device_class_identifier;
spdm_endpoint_info_device_class_identifier_element_t *identifier;
uint8_t *num_sub_ids;
spdm_endpoint_info_device_class_identifier_subordinate_id_t *subordinate_id;
uint8_t *sub_identifier;

if (endpoint_info_size == NULL) {
return LIBSPDM_STATUS_INVALID_PARAMETER;
}

switch (sub_code) {
case SPDM_GET_ENDPOINT_INFO_REQUEST_SUBCODE_DEVICE_CLASS_IDENTIFIER:
*endpoint_info_size = sizeof(spdm_endpoint_info_device_class_identifier_t) +
sizeof(spdm_endpoint_info_device_class_identifier_element_t) +
sizeof(uint8_t) +
sizeof(spdm_endpoint_info_device_class_identifier_subordinate_id_t) + 3;

if (endpoint_info != NULL) {
ptr = (uint8_t *)endpoint_info;
device_class_identifier = (spdm_endpoint_info_device_class_identifier_t *) ptr;
device_class_identifier->num_identifiers = 1;

ptr += sizeof(spdm_endpoint_info_device_class_identifier_t);
identifier = (spdm_endpoint_info_device_class_identifier_element_t *) ptr;
identifier->id_elem_length =
sizeof(spdm_svh_header_t) + sizeof(uint8_t) +
sizeof(spdm_endpoint_info_device_class_identifier_subordinate_id_t) + 3;

identifier->svh.id = 0x0;
identifier->svh.vendor_id_len = 0x0;
/* DMTF does not have a Vendor ID registry*/
ptr += sizeof(spdm_endpoint_info_device_class_identifier_element_t);

/* a fake sub id for structure sample*/
num_sub_ids = (uint8_t *) ptr;
*num_sub_ids = 1;

ptr += sizeof(uint8_t);
subordinate_id = (spdm_endpoint_info_device_class_identifier_subordinate_id_t *) ptr;
subordinate_id->sub_id_len = 0x3;

ptr += sizeof(spdm_endpoint_info_device_class_identifier_subordinate_id_t);
sub_identifier = (uint8_t *) ptr;
sub_identifier[0] = 0x12;
sub_identifier[1] = 0x34;
sub_identifier[2] = 0x56;
}
break;
default:
return LIBSPDM_STATUS_INVALID_PARAMETER;
}
return LIBSPDM_STATUS_SUCCESS;
}

0 comments on commit 850d8f4

Please # to comment.