Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add NONE transport type to send SPDM without a transport layer #20

Merged
merged 1 commit into from
Oct 21, 2021
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
3 changes: 2 additions & 1 deletion spdm_emu/spdm_emu_common/command.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
// payload (SPDM message, starting from SPDM_HEADER): PayloadSize (little endian)
//

#define SOCKET_TRANSPORT_TYPE_NONE 0x00
#define SOCKET_TRANSPORT_TYPE_MCTP 0x01
#define SOCKET_TRANSPORT_TYPE_PCI_DOE 0x02

Expand Down Expand Up @@ -98,4 +99,4 @@ typedef struct {

#pragma pack()

#endif
#endif
3 changes: 2 additions & 1 deletion spdm_emu/spdm_emu_common/spdm_emu.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ uint32 m_exe_session =

void print_usage(IN char8 *name)
{
printf("\n%s [--trans MCTP|PCI_DOE]\n", name);
printf("\n%s [--trans MCTP|PCI_DOE|NONE]\n", name);
printf(" [--ver 1.0|1.1]\n");
printf(" [--sec_ver 0|1.1]\n");
printf(" [--cap CACHE|CERT|CHAL|MEAS_NO_SIG|MEAS_SIG|MEAS_FRESH|ENCRYPT|MAC|MUT_AUTH|KEY_EX|PSK|PSK_WITH_CONTEXT|ENCAP|HBEAT|KEY_UPD|HANDSHAKE_IN_CLEAR|PUB_KEY_ID]\n");
Expand Down Expand Up @@ -112,6 +112,7 @@ typedef struct {
} value_string_entry_t;

value_string_entry_t m_transport_value_string_table[] = {
{ SOCKET_TRANSPORT_TYPE_NONE, "NONE"},
{ SOCKET_TRANSPORT_TYPE_MCTP, "MCTP" },
{ SOCKET_TRANSPORT_TYPE_PCI_DOE, "PCI_DOE" },
};
Expand Down
3 changes: 3 additions & 0 deletions spdm_emu/spdm_requester_emu/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ cmake_minimum_required(VERSION 2.6)

INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/spdm_emu/spdm_requester_emu
${PROJECT_SOURCE_DIR}/spdm_emu/spdm_emu_common
${PROJECT_SOURCE_DIR}/spdm_emu/spdm_transport_none_lib
${LIBSPDM_DIR}/os_stub/spdm_device_secret_lib
${LIBSPDM_DIR}/include
${LIBSPDM_DIR}/include/hal
Expand All @@ -21,6 +22,8 @@ SET(src_spdm_requester_emu
${PROJECT_SOURCE_DIR}/spdm_emu/spdm_emu_common/nv_storage.c
${PROJECT_SOURCE_DIR}/spdm_emu/spdm_emu_common/pcap.c
${PROJECT_SOURCE_DIR}/spdm_emu/spdm_emu_common/support.c
${PROJECT_SOURCE_DIR}/spdm_emu/spdm_transport_none_lib/common.c
${PROJECT_SOURCE_DIR}/spdm_emu/spdm_transport_none_lib/none.c
)

SET(spdm_requester_emu_LIBRARY
Expand Down
6 changes: 5 additions & 1 deletion spdm_emu/spdm_requester_emu/spdm_requester.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,10 @@ void *spdm_client_init(void)
spdm_register_transport_layer_func(
spdm_context, spdm_transport_pci_doe_encode_message,
spdm_transport_pci_doe_decode_message);
} else if (m_use_transport_layer == SOCKET_TRANSPORT_TYPE_NONE) {
spdm_register_transport_layer_func(
spdm_context, spdm_transport_none_encode_message,
spdm_transport_none_decode_message);
} else {
return NULL;
}
Expand Down Expand Up @@ -303,4 +307,4 @@ void *spdm_client_init(void)
}

return m_spdm_context;
}
}
21 changes: 12 additions & 9 deletions spdm_emu/spdm_requester_emu/spdm_requester_emu.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,17 @@ boolean platform_client_routine(IN uint16 port_number)

m_socket = platform_socket;

response_size = sizeof(m_receive_buffer);
result = communicate_platform_data(platform_socket,
SOCKET_SPDM_COMMAND_TEST,
(uint8 *)"Client Hello!",
sizeof("Client Hello!"), &response,
&response_size, m_receive_buffer);
if (!result) {
goto done;
if (m_use_transport_layer != SOCKET_TRANSPORT_TYPE_NONE) {
response_size = sizeof(m_receive_buffer);
result = communicate_platform_data(
platform_socket,
SOCKET_SPDM_COMMAND_TEST,
(uint8 *)"Client Hello!",
sizeof("Client Hello!"), &response,
&response_size, m_receive_buffer);
if (!result) {
goto done;
}
}

if (m_use_transport_layer == SOCKET_TRANSPORT_TYPE_PCI_DOE) {
Expand Down Expand Up @@ -223,4 +226,4 @@ int main(int argc, char *argv[])

close_pcap_packet_file();
return 0;
}
}
3 changes: 2 additions & 1 deletion spdm_emu/spdm_requester_emu/spdm_requester_emu.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@
#include <base.h>
#include <library/memlib.h>
#include <library/spdm_requester_lib.h>
#include <spdm_transport_none_lib.h>
#include <library/spdm_transport_mctp_lib.h>
#include <library/spdm_transport_pcidoe_lib.h>

#include "os_include.h"
#include "stdio.h"
#include "spdm_emu.h"

#endif
#endif
3 changes: 3 additions & 0 deletions spdm_emu/spdm_responder_emu/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ cmake_minimum_required(VERSION 2.6)

INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/spdm_emu/spdm_responder_emu
${PROJECT_SOURCE_DIR}/spdm_emu/spdm_emu_common
${PROJECT_SOURCE_DIR}/spdm_emu/spdm_transport_none_lib
${LIBSPDM_DIR}/os_stub/spdm_device_secret_lib
${LIBSPDM_DIR}/include
${LIBSPDM_DIR}/include/hal
Expand All @@ -19,6 +20,8 @@ SET(src_spdm_responder_emu
${PROJECT_SOURCE_DIR}/spdm_emu/spdm_emu_common/nv_storage.c
${PROJECT_SOURCE_DIR}/spdm_emu/spdm_emu_common/pcap.c
${PROJECT_SOURCE_DIR}/spdm_emu/spdm_emu_common/support.c
${PROJECT_SOURCE_DIR}/spdm_emu/spdm_transport_none_lib/common.c
${PROJECT_SOURCE_DIR}/spdm_emu/spdm_transport_none_lib/none.c
)

SET(spdm_responder_emu_LIBRARY
Expand Down
4 changes: 4 additions & 0 deletions spdm_emu/spdm_responder_emu/spdm_responder.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,10 @@ void *spdm_server_init(void)
spdm_register_transport_layer_func(
spdm_context, spdm_transport_pci_doe_encode_message,
spdm_transport_pci_doe_decode_message);
} else if (m_use_transport_layer == SOCKET_TRANSPORT_TYPE_NONE) {
spdm_register_transport_layer_func(
spdm_context, spdm_transport_none_encode_message,
spdm_transport_none_decode_message);
} else {
return NULL;
}
Expand Down
3 changes: 2 additions & 1 deletion spdm_emu/spdm_responder_emu/spdm_responder_emu.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@
#include <base.h>
#include <library/memlib.h>
#include <library/spdm_responder_lib.h>
#include <spdm_transport_none_lib.h>
#include <library/spdm_transport_mctp_lib.h>
#include <library/spdm_transport_pcidoe_lib.h>

#include "os_include.h"
#include "stdio.h"
#include "spdm_emu.h"

#endif
#endif
Loading