Repository: DMTF/libspdm
Pull request #3024: Add TCP transport support in libspdm (DSP0287)
Author: login: manojkiraneda
Created: 2025-04-01T11:21:21Z | Merged: 2025-05-29T06:48:40Z



Diff:
diff --git a/CMakeLists.txt b/CMakeLists.txt
index de0e9c5d721..33004a6f7e1 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -894,6 +894,7 @@ if(ENABLE_CODEQL STREQUAL "ON")
     add_subdirectory(library/spdm_secured_message_lib)
     add_subdirectory(library/spdm_transport_mctp_lib)
     add_subdirectory(library/spdm_transport_pcidoe_lib)
+    add_subdirectory(library/spdm_transport_tcp_lib)
     add_subdirectory(os_stub/memlib)
     add_subdirectory(os_stub/debuglib)
     add_subdirectory(os_stub/debuglib_null)
@@ -931,6 +932,7 @@ else()
         add_subdirectory(library/spdm_secured_message_lib)
         add_subdirectory(library/spdm_transport_mctp_lib)
         add_subdirectory(library/spdm_transport_pcidoe_lib)
+        add_subdirectory(library/spdm_transport_tcp_lib)
         add_subdirectory(os_stub/memlib)
         add_subdirectory(os_stub/debuglib)
         add_subdirectory(os_stub/debuglib_null)
@@ -1004,6 +1006,8 @@ else()
             add_subdirectory(unit_test/fuzzing/test_transport/test_spdm_transport_mctp_decode_message)
             add_subdirectory(unit_test/fuzzing/test_transport/test_spdm_transport_pci_doe_encode_message)
             add_subdirectory(unit_test/fuzzing/test_transport/test_spdm_transport_pci_doe_decode_message)
+            add_subdirectory(unit_test/fuzzing/test_transport/test_spdm_transport_tcp_encode_message)
+            add_subdirectory(unit_test/fuzzing/test_transport/test_spdm_transport_tcp_decode_message)
             add_subdirectory(unit_test/fuzzing/test_secured_message/test_spdm_decode_secured_message)
             add_subdirectory(unit_test/fuzzing/test_secured_message/test_spdm_encode_secured_message)
             add_subdirectory(unit_test/fuzzing/test_spdm_crypt/test_x509_certificate_check)
@@ -1070,6 +1074,7 @@ else()
             $<TARGET_OBJECTS:spdm_secured_message_lib>
             $<TARGET_OBJECTS:spdm_transport_mctp_lib>
             $<TARGET_OBJECTS:spdm_transport_pcidoe_lib>
+            $<TARGET_OBJECTS:spdm_transport_tcp_lib>
         )
 
         add_library(${LIB_NAME}_platform SHARED
diff --git a/include/industry_standard/spdm_tcp_binding.h b/include/industry_standard/spdm_tcp_binding.h
new file mode 100644
index 00000000000..ae36d1ac332
--- /dev/null
+++ b/include/industry_standard/spdm_tcp_binding.h
@@ -0,0 +1,39 @@
+/**
+ *  Copyright Notice:
+ *  Copyright 2025 DMTF. All rights reserved.
+ *  License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/libspdm/blob/main/LICENSE.md
+ **/
+
+/** @file
+ * Definitions of DSP0287 SPDM over TCP Binding Specification
+ * version 1.0.0 in Distributed Management Task Force (DMTF).
+ *
+ **/
+
+#ifndef SPDM_TCP_BINDING_H
+#define SPDM_TCP_BINDING_H
+
+#pragma pack(1)
+
+typedef struct {
+    uint16_t payload_length;
+    uint8_t binding_version;
+    uint8_t message_type;
+} spdm_tcp_binding_header_t;
+
+#define SPDM_TCP_MESSAGE_TYPE_OUT_OF_SESSION 0x05
+#define SPDM_TCP_MESSAGE_TYPE_IN_SESSION 0x06
+#define SPDM_TCP_MESSAGE_TYPE_ROLE_INQUIRY 0xBF
+
+/* Error Messages*/
+#define SPDM_TCP_MESSAGE_TYPE_ERROR_TOO_LARGE 0xC0
+#define SPDM_TCP_MESSGAE_TYPE_ERROR_NOT_SUPPORTED 0xC1
+#define SPDM_TCP_MESSAGE_TYPE_ERROR_CANNOT_OPERATE_AS_REQUESTER 0xC2
+#define SPDM_TCP_MESSAGE_TYPE_ERROR_CANNOT_OPERATE_AS_RESPONDER 0xC3
+
+#define SPDM_TCP_SEQUENCE_NUMBER_COUNT 0
+#define SPDM_TCP_MAX_RANDOM_NUMBER_COUNT 0
+
+#pragma pack()
+
+#endif /* SPDM_TCP_BINDING_H */
diff --git a/include/library/spdm_transport_tcp_lib.h b/include/library/spdm_transport_tcp_lib.h
new file mode 100644
index 00000000000..04ae68b64e8
--- /dev/null
+++ b/include/library/spdm_transport_tcp_lib.h
@@ -0,0 +1,144 @@
+/**
+ *  Copyright Notice:
+ *  Copyright 2025 DMTF. All rights reserved.
+ *  License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/libspdm/blob/main/LICENSE.md
+ **/
+
+#ifndef SPDM_TCP_TRANSPORT_LIB_H
+#define SPDM_TCP_TRANSPORT_LIB_H
+
+#include "library/spdm_common_lib.h"
+
+/* Required sender/receive buffer in device io.
+ * +-------+--------+---------------------------+------+--+------+---+--------+-----+
+ * | TYPE  |TransHdr|      EncryptionHeader     |AppHdr|  |Random|MAC|AlignPad|FINAL|
+ * |       |        |SessionId|SeqNum|Len|AppLen|      |  |      |   |        |     |
+ * +-------+--------+---------------------------+------+  +------+---+--------+-----+
+ * |  TCP  |    4   |    4    |   0  | 2 |   2  |   0  |  |   0  | 16|   3    |  31 |
+ * +-------+--------+---------------------------+------+--+------+---+--------+-----+
+ *
+ */
+
+/*
+ * Encode an SPDM or APP message to a transport layer message.
+ *
+ * For normal SPDM message, it adds the transport layer wrapper.
+ * For secured SPDM message, it encrypts a secured message then adds the transport layer wrapper.
+ * For secured APP message, it encrypts a secured message then adds the transport layer wrapper.
+ *
+ * The APP message is encoded to a secured message directly in SPDM session.
+ * The APP message format is defined by the transport layer.
+ * Take TCP as example: APP message == TCP-SPDM-BINDING-HEADER + SPDM message
+ *
+ * @param  spdm_context                  A pointer to the SPDM context.
+ * @param  session_id                    Indicates if it is a secured message protected via SPDM session.
+ *                                     If session_id is NULL, it is a normal message.
+ *                                     If session_id is NOT NULL, it is a secured message.
+ * @param  is_app_message                 Indicates if it is an APP message or SPDM message.
+ * @param  is_requester                  Indicates if it is a requester message.
+ * @param  message_size                  size in bytes of the message data buffer.
+ * @param  message                      A pointer to a source buffer to store the message.
+ *                                      For normal message, it shall point to the acquired sender buffer.
+ *                                      For secured message, it shall point to the scratch buffer in spdm_context.
+ * @param  transport_message_size         size in bytes of the transport message data buffer.
+ * @param  transport_message             A pointer to a destination buffer to store the transport message.
+ *                                      On input, it shall be msg_buf_ptr from sender buffer.
+ *                                      On output, it will point to acquired sender buffer.
+ *
+ * @retval RETURN_SUCCESS               The message is encoded successfully.
+ * @retval RETURN_INVALID_PARAMETER     The message is NULL or the message_size is zero.
+ **/
+libspdm_return_t libspdm_transport_tcp_encode_message(
+    void *spdm_context, const uint32_t *session_id, bool is_app_message,
+    bool is_requester, size_t message_size, void *message,
+    size_t *transport_message_size, void **transport_message);
+
+/**
+ * Decode an SPDM or APP message from a transport layer message.
+ *
+ * For normal SPDM message, it removes the transport layer wrapper,
+ * For secured SPDM message, it removes the transport layer wrapper, then decrypts and verifies a secured message.
+ * For secured APP message, it removes the transport layer wrapper, then decrypts and verifies a secured message.
+ *
+ * The APP message is decoded from a secured message directly in SPDM session.
+ * The APP message format is defined by the transport layer.
+ * Take TCP as example: APP message == TCP-SPDM-BINDING-HEADER + SPDM message (For out-of-session message)
+ *
+ * @param  spdm_context                  A pointer to the SPDM context.
+ * @param  session_id                    Indicates if it is a secured message protected via SPDM session.
+ *                                     If *session_id is NULL, it is a normal message.
+ *                                     If *session_id is NOT NULL, it is a secured message.
+ * @param  is_app_message                 Indicates if it is an APP message or SPDM message.
+ * @param  is_requester                  Indicates if it is a requester message.
+ * @param  transport_message_size         size in bytes of the transport message data buffer.
+ * @param  transport_message             A pointer to a source buffer to store the transport message.
+ *                                      For normal message or secured message, it shall point to acquired receiver buffer.
+ * @param  message_size                  size in bytes of the message data buffer.
+ * @param  message                      A pointer to a destination buffer to store the message.
+ *                                      On input, it shall point to the scratch buffer in spdm_context.
+ *                                      On output, for normal message, it will point to the original receiver buffer.
+ *                                      On output, for secured message, it will point to the scratch buffer in spdm_context.
+ *
+ * @retval RETURN_SUCCESS               The message is decoded successfully.
+ * @retval RETURN_INVALID_PARAMETER     The message is NULL or the message_size is zero.
+ * @retval RETURN_UNSUPPORTED           The transport_message is unsupported.
+ **/
+libspdm_return_t libspdm_transport_tcp_decode_message(
+    void *spdm_context, uint32_t **session_id,
+    bool *is_app_message, bool is_requester,
+    size_t transport_message_size, void *transport_message,
+    size_t *message_size, void **message);
+
+/**
+ * Return the maximum transport layer message header size.
+ *   Transport Message Header Size + sizeof(spdm_secured_message_cipher_header_t))
+ *
+ *   For TCP, Transport Message Header Size = sizeof(tcp_spdm_binding_header_t)
+ *   For PCI_DOE, Transport Message Header Size = sizeof(pci_doe_data_object_header_t)
+ *
+ * @param  spdm_context                  A pointer to the SPDM context.
+ *
+ * @return size of maximum transport layer message header size
+ **/
+uint32_t libspdm_transport_tcp_get_header_size(
+    void *spdm_context);
+
+/**
+ * Get sequence number in an SPDM secure message.
+ *
+ * This value is transport layer specific.
+ *
+ * @param sequence_number        The current sequence number used to encode or decode message.
+ * @param sequence_number_buffer  A buffer to hold the sequence number output used in the secured message.
+ *                             The size in byte of the output buffer shall be 8.
+ *
+ * @return size in byte of the sequence_number_buffer.
+ *        It shall be no greater than 8.
+ *        0 means no sequence number is required.
+ **/
+uint8_t libspdm_tcp_get_sequence_number(uint64_t sequence_number,
+                                        uint8_t *sequence_number_buffer);
+
+/**
+ * Return max random number count in an SPDM secure message.
+ *
+ * This value is transport layer specific.
+ *
+ * @return Max random number count in an SPDM secured message.
+ *        0 means no randum number is required.
+ **/
+uint32_t libspdm_tcp_get_max_random_number_count(void);
+
+/**
+ * This function translates the negotiated secured_message_version to a DSP0277 version.
+ *
+ * @param  secured_message_version  The version specified in binding specification and
+ *                                  negotiated in KEY_EXCHANGE/KEY_EXCHANGE_RSP.
+ *
+ * @return The DSP0277 version specified in binding specification,
+ *         which is bound to secured_message_version.
+ */
+spdm_version_number_t libspdm_tcp_get_secured_spdm_version(
+    spdm_version_number_t secured_message_version);
+
+#endif /* SPDM_TCP_TRANSPORT_LIB_H */
diff --git a/library/spdm_transport_tcp_lib/CMakeLists.txt b/library/spdm_transport_tcp_lib/CMakeLists.txt
new file mode 100644
index 00000000000..a55ae366e9e
--- /dev/null
+++ b/library/spdm_transport_tcp_lib/CMakeLists.txt
@@ -0,0 +1,14 @@
+cmake_minimum_required(VERSION 3.5)
+
+add_library(spdm_transport_tcp_lib STATIC "")
+
+target_include_directories(spdm_transport_tcp_lib
+    PRIVATE
+        ${LIBSPDM_DIR}/include
+)
+
+target_sources(spdm_transport_tcp_lib
+    PRIVATE
+        libspdm_tcp_common.c
+        libspdm_tcp_tcp.c
+)
diff --git a/library/spdm_transport_tcp_lib/libspdm_tcp_common.c b/library/spdm_transport_tcp_lib/libspdm_tcp_common.c
new file mode 100644
index 00000000000..b6ca97f6eb4
--- /dev/null
+++ b/library/spdm_transport_tcp_lib/libspdm_tcp_common.c
@@ -0,0 +1,311 @@
+/**
+ *  Copyright Notice:
+ *  Copyright 2025 DMTF. All rights reserved.
+ *  License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/libspdm/blob/main/LICENSE.md
+ **/
+
+#include "library/spdm_transport_tcp_lib.h"
+#include "library/spdm_secured_message_lib.h"
+#include "hal/library/debuglib.h"
+
+/**
+ * Encode a normal message or secured message to a transport message.
+ *
+ * @param  session_id                    Indicates if it is a secured message protected via SPDM session.
+ *                                     If session_id is NULL, it is a normal message.
+ *                                     If session_id is NOT NULL, it is a secured message.
+ * @param  message_size                  size in bytes of the message data buffer.
+ * @param  message                      A pointer to a source buffer to store the message.
+ * @param  transport_message_size         size in bytes of the transport message data buffer.
+ * @param  transport_message             A pointer to a destination buffer to store the transport message.
+ *
+ * @retval RETURN_SUCCESS               The message is encoded successfully.
+ * @retval RETURN_INVALID_PARAMETER     The message is NULL or the message_size is zero.
+ **/
+libspdm_return_t libspdm_tcp_encode_message(const uint32_t *session_id, size_t message_size,
+                                            void *message,
+                                            size_t *transport_message_size,
+                                            void **transport_message);
+
+/**
+ * Decode a transport message to a normal message or secured message.
+ *
+ * @param  session_id                    Indicates if it is a secured message protected via SPDM session.
+ *                                     If *session_id is NULL, it is a normal message.
+ *                                     If *session_id is NOT NULL, it is a secured message.
+ * @param  transport_message_size         size in bytes of the transport message data buffer.
+ * @param  transport_message             A pointer to a source buffer to store the transport message.
+ * @param  message_size                  size in bytes of the message data buffer.
+ * @param  message                      A pointer to a destination buffer to store the message.
+ *
+ * @retval RETURN_SUCCESS               The message is encoded successfully.
+ * @retval RETURN_INVALID_PARAMETER     The message is NULL or the message_size is zero.
+ **/
+libspdm_return_t libspdm_tcp_decode_message(uint32_t **session_id,
+                                            size_t transport_message_size,
+                                            void *transport_message,
+                                            size_t *message_size,
+                                            void **message);
+
+/**
+ * Encode an SPDM or APP message to a transport layer message.
+ *
+ * For normal SPDM message, it adds the transport layer wrapper.
+ * For secured SPDM message, it encrypts a secured message then adds the transport layer wrapper.
+ * For secured APP message, it encrypts a secured message then adds the transport layer wrapper.
+ *
+ * The APP message is encoded to a secured message directly in SPDM session.
+ * The APP message format is defined by the transport layer.
+ *
+ * @param  spdm_context                  A pointer to the SPDM context.
+ * @param  session_id                    Indicates if it is a secured message protected via SPDM session.
+ *                                     If session_id is NULL, it is a normal message.
+ *                                     If session_id is NOT NULL, it is a secured message.
+ * @param  is_app_message                 Indicates if it is an APP message or SPDM message.
+ * @param  is_requester                  Indicates if it is a requester message.
+ * @param  message_size                  size in bytes of the message data buffer.
+ * @param  message                      A pointer to a source buffer to store the message.
+ *                                      For normal message, it shall point to the acquired sender buffer.
+ *                                      For secured message, it shall point to the scratch buffer in spdm_context.
+ * @param  transport_message_size         size in bytes of the transport message data buffer.
+ * @param  transport_message             A pointer to a destination buffer to store the transport message.
+ *                                      On input, it shall be msg_buf_ptr from sender buffer.
+ *                                      On output, it will point to acquired sender buffer.
+ *
+ * @retval RETURN_SUCCESS               The message is encoded successfully.
+ * @retval RETURN_INVALID_PARAMETER     The message is NULL or the message_size is zero.
+ **/
+libspdm_return_t libspdm_transport_tcp_encode_message(
+    void *spdm_context, const uint32_t *session_id, bool is_app_message,
+    bool is_requester, size_t message_size, void *message,
+    size_t *transport_message_size, void **transport_message)
+{
+    libspdm_return_t status;
+    void *app_message;
+    size_t app_message_size;
+    uint8_t *secured_message;
+    size_t secured_message_size;
+    libspdm_secured_message_callbacks_t spdm_secured_message_callbacks;
+    void *secured_message_context;
+    size_t transport_header_size;
+
+    spdm_secured_message_callbacks.version =
+        LIBSPDM_SECURED_MESSAGE_CALLBACKS_VERSION;
+    spdm_secured_message_callbacks.get_sequence_number =
+        libspdm_tcp_get_sequence_number;
+    spdm_secured_message_callbacks.get_max_random_number_count =
+        libspdm_tcp_get_max_random_number_count;
+    spdm_secured_message_callbacks.get_secured_spdm_version =
+        libspdm_tcp_get_secured_spdm_version;
+
+    if (is_app_message && (session_id == NULL)) {
+        return LIBSPDM_STATUS_UNSUPPORTED_CAP;
+    }
+
+    if (session_id != NULL) {
+        secured_message_context =
+            libspdm_get_secured_message_context_via_session_id(
+                spdm_context, *session_id);
+        if (secured_message_context == NULL) {
+            return LIBSPDM_STATUS_UNSUPPORTED_CAP;
+        }
+
+        if (!is_app_message) {
+            /* SPDM message to APP message*/
+            status = libspdm_tcp_encode_message(NULL, message_size,
+                                                message,
+                                                &app_message_size,
+                                                &app_message);
+            if (LIBSPDM_STATUS_IS_ERROR(status)) {
+                LIBSPDM_DEBUG((LIBSPDM_DEBUG_ERROR,
+                               "transport_encode_message - %p\n",
+                               status));
+                return status;
+            }
+        } else {
+            app_message = (void *)message;
+            app_message_size = message_size;
+        }
+        /* APP message to secured message*/
+        transport_header_size = libspdm_transport_tcp_get_header_size(spdm_context);
+        secured_message = (uint8_t *)*transport_message + transport_header_size;
+        secured_message_size = *transport_message_size - transport_header_size;
+        status = libspdm_encode_secured_message(
+            secured_message_context, *session_id, is_requester,
+            app_message_size, app_message, &secured_message_size,
+            secured_message, &spdm_secured_message_callbacks);
+        if (LIBSPDM_STATUS_IS_ERROR(status)) {
+            LIBSPDM_DEBUG((LIBSPDM_DEBUG_ERROR,
+                           "libspdm_encode_secured_message - %p\n", status));
+            return status;
+        }
+
+        /* secured message to secured TCP message*/
+        status = libspdm_tcp_encode_message(
+            session_id, secured_message_size, secured_message,
+            transport_message_size, transport_message);
+        if (LIBSPDM_STATUS_IS_ERROR(status)) {
+            LIBSPDM_DEBUG((LIBSPDM_DEBUG_ERROR, "transport_encode_message - %p\n",
+                           status));
+            return status;
+        }
+    } else {
+        /* SPDM message to normal TCP message*/
+        status = libspdm_tcp_encode_message(NULL, message_size, message,
+                                            transport_message_size,
+                                            transport_message);
+        if (LIBSPDM_STATUS_IS_ERROR(status)) {
+            LIBSPDM_DEBUG((LIBSPDM_DEBUG_ERROR, "transport_encode_message - %p\n",
+                           status));
+            return status;
+        }
+    }
+
+    return LIBSPDM_STATUS_SUCCESS;
+}
+
+/**
+ * Decode an SPDM or APP message from a transport layer message.
+ *
+ * For normal SPDM message, it removes the transport layer wrapper,
+ * For secured SPDM message, it removes the transport layer wrapper, then decrypts and verifies a secured message.
+ * For secured APP message, it removes the transport layer wrapper, then decrypts and verifies a secured message.
+ *
+ * The APP message is decoded from a secured message directly in SPDM session.
+ * The APP message format is defined by the transport layer.
+ *
+ * @param  spdm_context                  A pointer to the SPDM context.
+ * @param  session_id                    Indicates if it is a secured message protected via SPDM session.
+ *                                     If *session_id is NULL, it is a normal message.
+ *                                     If *session_id is NOT NULL, it is a secured message.
+ * @param  is_app_message                 Indicates if it is an APP message or SPDM message.
+ * @param  is_requester                  Indicates if it is a requester message.
+ * @param  transport_message_size         size in bytes of the transport message data buffer.
+ * @param  transport_message             A pointer to a source buffer to store the transport message.
+ *                                      For normal message or secured message, it shall point to acquired receiver buffer.
+ * @param  message_size                  size in bytes of the message data buffer.
+ * @param  message                      A pointer to a destination buffer to store the message.
+ *                                      On input, it shall point to the scratch buffer in spdm_context.
+ *                                      On output, for normal message, it will point to the original receiver buffer.
+ *                                      On output, for secured message, it will point to the scratch buffer in spdm_context.
+ *
+ * @retval RETURN_SUCCESS               The message is decoded successfully.
+ * @retval RETURN_INVALID_PARAMETER     The message is NULL or the message_size is zero.
+ * @retval RETURN_UNSUPPORTED           The transport_message is unsupported.
+ **/
+libspdm_return_t libspdm_transport_tcp_decode_message(
+    void *spdm_context, uint32_t **session_id,
+    bool *is_app_message, bool is_requester,
+    size_t transport_message_size, void *transport_message,
+    size_t *message_size, void **message)
+{
+    libspdm_return_t status;
+    uint32_t *secured_message_session_id;
+    uint8_t *secured_message;
+    size_t secured_message_size;
+    uint8_t *app_message;
+    size_t app_message_size;
+    libspdm_secured_message_callbacks_t spdm_secured_message_callbacks;
+    void *secured_message_context;
+    libspdm_error_struct_t spdm_error;
+
+    spdm_error.error_code = 0;
+    spdm_error.session_id = 0;
+    if(spdm_context) {
+        libspdm_set_last_spdm_error_struct(spdm_context, &spdm_error);
+    }
+
+    spdm_secured_message_callbacks.version =
+        LIBSPDM_SECURED_MESSAGE_CALLBACKS_VERSION;
+    spdm_secured_message_callbacks.get_sequence_number =
+        libspdm_tcp_get_sequence_number;
+    spdm_secured_message_callbacks.get_max_random_number_count =
+        libspdm_tcp_get_max_random_number_count;
+    spdm_secured_message_callbacks.get_secured_spdm_version =
+        libspdm_tcp_get_secured_spdm_version;
+
+    if ((session_id == NULL) || (is_app_message == NULL)) {
+        return LIBSPDM_STATUS_UNSUPPORTED_CAP;
+    }
+
+    secured_message_session_id = NULL;
+    /* Detect received message*/
+    status = libspdm_tcp_decode_message(
+        &secured_message_session_id, transport_message_size,
+        transport_message, &secured_message_size, (void **)&secured_message);
+    if (LIBSPDM_STATUS_IS_ERROR(status)) {
+        LIBSPDM_DEBUG((LIBSPDM_DEBUG_ERROR, "transport_decode_message - %p\n", status));
+        return status;
+    }
+
+    if (secured_message_session_id != NULL) {
+        *session_id = secured_message_session_id;
+
+        secured_message_context =
+            libspdm_get_secured_message_context_via_session_id(
+                spdm_context, *secured_message_session_id);
+        if (secured_message_context == NULL) {
+            spdm_error.error_code = SPDM_ERROR_CODE_INVALID_SESSION;
+            spdm_error.session_id = *secured_message_session_id;
+            libspdm_set_last_spdm_error_struct(spdm_context,
+                                               &spdm_error);
+            return LIBSPDM_STATUS_UNSUPPORTED_CAP;
+        }
+
+        /* Secured message to APP message*/
+        app_message = *message;
+        app_message_size = *message_size;
+        status = libspdm_decode_secured_message(
+            secured_message_context, *secured_message_session_id,
+            is_requester, secured_message_size, secured_message,
+            &app_message_size, (void **)&app_message,
+            &spdm_secured_message_callbacks);
+        if (LIBSPDM_STATUS_IS_ERROR(status)) {
+            LIBSPDM_DEBUG((LIBSPDM_DEBUG_ERROR,
+                           "libspdm_decode_secured_message - %p\n", status));
+            libspdm_secured_message_get_last_spdm_error_struct(
+                secured_message_context, &spdm_error);
+            libspdm_set_last_spdm_error_struct(spdm_context,
+                                               &spdm_error);
+            return status;
+        }
+
+        /* APP message to SPDM message.*/
+        status = libspdm_tcp_decode_message(&secured_message_session_id,
+                                            app_message_size, app_message,
+                                            message_size, message);
+        if (LIBSPDM_STATUS_IS_ERROR(status)) {
+            *is_app_message = true;
+            /* just return APP message.*/
+            *message = app_message;
+            *message_size = app_message_size;
+            return LIBSPDM_STATUS_SUCCESS;
+        } else {
+            *is_app_message = false;
+            if (secured_message_session_id == NULL) {
+                return LIBSPDM_STATUS_SUCCESS;
+            } else {
+                /* get encapsulated secured message - cannot handle it.*/
+                LIBSPDM_DEBUG((LIBSPDM_DEBUG_ERROR,
+                               "transport_decode_message - expect encapsulated normal but got session (%08x)\n",
+                               *secured_message_session_id));
+                return LIBSPDM_STATUS_UNSUPPORTED_CAP;
+            }
+        }
+    } else {
+        /* get non-secured message*/
+        status = libspdm_tcp_decode_message(&secured_message_session_id,
+                                            transport_message_size,
+                                            transport_message,
+                                            message_size, message);
+        if (LIBSPDM_STATUS_IS_ERROR(status)) {
+            LIBSPDM_DEBUG((LIBSPDM_DEBUG_ERROR, "transport_decode_message - %p\n",
+                           status));
+            return status;
+        }
+        LIBSPDM_ASSERT(secured_message_session_id == NULL);
+        *session_id = NULL;
+        *is_app_message = false;
+        return LIBSPDM_STATUS_SUCCESS;
+    }
+}
diff --git a/library/spdm_transport_tcp_lib/libspdm_tcp_tcp.c b/library/spdm_transport_tcp_lib/libspdm_tcp_tcp.c
new file mode 100644
index 00000000000..1ce089454b3
--- /dev/null
+++ b/library/spdm_transport_tcp_lib/libspdm_tcp_tcp.c
@@ -0,0 +1,183 @@
+/**
+ *  Copyright Notice:
+ *  Copyright 2025 DMTF. All rights reserved.
+ *  License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/libspdm/blob/main/LICENSE.md
+ **/
+
+#include "library/spdm_transport_tcp_lib.h"
+#include "internal/libspdm_common_lib.h"
+#include "hal/library/memlib.h"
+#include "industry_standard/spdm_tcp_binding.h"
+
+/**
+ * Get sequence number in an SPDM secure message.
+ *
+ * This value is transport layer specific.
+ *
+ * @param sequence_number        The current sequence number used to encode or decode message.
+ * @param sequence_number_buffer  A buffer to hold the sequence number output used in the secured message.
+ *                             The size in byte of the output buffer shall be 8.
+ *
+ * @return size in byte of the sequence_number_buffer.
+ *        It shall be no greater than 8.
+ *        0 means no sequence number is required.
+ **/
+uint8_t libspdm_tcp_get_sequence_number(uint64_t sequence_number,
+                                        uint8_t *sequence_number_buffer)
+{
+    return SPDM_TCP_SEQUENCE_NUMBER_COUNT;
+}
+
+/**
+ * Return max random number count in an SPDM secure message.
+ *
+ * This value is transport layer specific.
+ *
+ * @return Max random number count in an SPDM secured message.
+ *        0 means no randum number is required.
+ **/
+uint32_t libspdm_tcp_get_max_random_number_count(void)
+{
+    return SPDM_TCP_MAX_RANDOM_NUMBER_COUNT;
+}
+
+/**
+ * This function translates the negotiated secured_message_version to a DSP0277 version.
+ *
+ * @param  secured_message_version  The version specified in binding specification and
+ *                                  negotiated in KEY_EXCHANGE/KEY_EXCHANGE_RSP.
+ *
+ * @return The DSP0277 version specified in binding specification,
+ *         which is bound to secured_message_version.
+ */
+spdm_version_number_t libspdm_tcp_get_secured_spdm_version(
+    spdm_version_number_t secured_message_version)
+{
+    return SECURED_SPDM_VERSION_12;
+}
+
+/**
+ * Encode a normal message or secured message to a transport message.
+ *
+ * @param  session_id                    Indicates if it is a secured message protected via SPDM session.
+ *                                     If session_id is NULL, it is a normal message.
+ *                                     If session_id is NOT NULL, it is a secured message.
+ * @param  message_size                  size in bytes of the message data buffer.
+ * @param  message                      A pointer to a source buffer to store the message.
+ * @param  transport_message_size         size in bytes of the transport message data buffer.
+ * @param  transport_message             A pointer to a destination buffer to store the transport message.
+ *
+ * @retval RETURN_SUCCESS               The message is encoded successfully.
+ * @retval RETURN_INVALID_PARAMETER     The message is NULL or the message_size is zero.
+ **/
+libspdm_return_t libspdm_tcp_encode_message(const uint32_t *session_id, size_t message_size,
+                                            void *message,
+                                            size_t *transport_message_size,
+                                            void **transport_message)
+{
+    uint32_t data32;
+    spdm_tcp_binding_header_t *tcp_message_header;
+
+    if (*transport_message_size <
+        message_size + sizeof(spdm_tcp_binding_header_t)) {
+        *transport_message_size = message_size +
+                                  sizeof(spdm_tcp_binding_header_t);
+        return LIBSPDM_STATUS_BUFFER_TOO_SMALL;
+    }
+
+    *transport_message_size =
+        message_size + sizeof(spdm_tcp_binding_header_t);
+    *transport_message = (uint8_t *)message - sizeof(spdm_tcp_binding_header_t);
+    tcp_message_header = *transport_message;
+    tcp_message_header->payload_length = (uint16_t)(*transport_message_size - 2);
+    tcp_message_header->binding_version = 0x1;
+
+    if (session_id != NULL) {
+        tcp_message_header->message_type = SPDM_TCP_MESSAGE_TYPE_IN_SESSION;
+        data32 = libspdm_read_uint32((const uint8_t *)message);
+        LIBSPDM_ASSERT(*session_id == data32);
+        if (*session_id != data32) {
+            return LIBSPDM_STATUS_INVALID_MSG_FIELD;
+        }
+    } else {
+        tcp_message_header->message_type = SPDM_TCP_MESSAGE_TYPE_OUT_OF_SESSION;
+    }
+
+    return LIBSPDM_STATUS_SUCCESS;
+}
+
+
+/**
+ * Decode a transport message to a normal message or secured message.
+ *
+ * @param  session_id                    Indicates if it is a secured message protected via SPDM session.
+ *                                     If *session_id is NULL, it is a normal message.
+ *                                     If *session_id is NOT NULL, it is a secured message.
+ * @param  transport_message_size         size in bytes of the transport message data buffer.
+ * @param  transport_message             A pointer to a source buffer to store the transport message.
+ * @param  message_size                  size in bytes of the message data buffer.
+ * @param  message                      A pointer to a destination buffer to store the message.
+ *
+ * @retval RETURN_SUCCESS               The message is encoded successfully.
+ * @retval RETURN_INVALID_PARAMETER     The message is NULL or the message_size is zero.
+ **/
+libspdm_return_t libspdm_tcp_decode_message(uint32_t **session_id,
+                                            size_t transport_message_size,
+                                            void *transport_message,
+                                            size_t *message_size, void **message)
+{
+    const spdm_tcp_binding_header_t *tcp_message_header;
+
+    LIBSPDM_ASSERT(transport_message_size > sizeof(spdm_tcp_binding_header_t));
+    if (transport_message_size <= sizeof(spdm_tcp_binding_header_t)) {
+        return LIBSPDM_STATUS_INVALID_MSG_SIZE;
+    }
+
+    tcp_message_header = transport_message;
+
+    switch (tcp_message_header->message_type) {
+    case SPDM_TCP_MESSAGE_TYPE_IN_SESSION:
+        LIBSPDM_ASSERT(session_id != NULL);
+        if (session_id == NULL) {
+            return LIBSPDM_STATUS_INVALID_MSG_FIELD;
+        }
+        if (transport_message_size <=
+            sizeof(spdm_tcp_binding_header_t) + sizeof(uint32_t)) {
+            return LIBSPDM_STATUS_INVALID_MSG_SIZE;
+        }
+        *session_id = (uint32_t *)((uint8_t *)transport_message +
+                                   sizeof(spdm_tcp_binding_header_t));
+        break;
+
+    case SPDM_TCP_MESSAGE_TYPE_OUT_OF_SESSION:
+        if (session_id != NULL) {
+            *session_id = NULL;
+        }
+        break;
+
+    default:
+        return LIBSPDM_STATUS_UNSUPPORTED_CAP;
+    }
+
+    *message_size = transport_message_size - sizeof(spdm_tcp_binding_header_t);
+    *message = (uint8_t *)transport_message + sizeof(spdm_tcp_binding_header_t);
+
+    return LIBSPDM_STATUS_SUCCESS;
+}
+
+/**
+ * Return the maximum transport layer message header size.
+ *   Transport Message Header Size + sizeof(spdm_secured_message_cipher_header_t))
+ *
+ *   For TCP, Transport Message Header Size = sizeof(tcp_spdm_binding_header_t)
+ *   For PCI_DOE, Transport Message Header Size = sizeof(pci_doe_data_object_header_t)
+ *
+ * @param  spdm_context                  A pointer to the SPDM context.
+ *
+ * @return size of maximum transport layer message header size
+ **/
+uint32_t libspdm_transport_tcp_get_header_size(
+    void *spdm_context)
+{
+    return sizeof(spdm_tcp_binding_header_t) + sizeof(spdm_secured_message_cipher_header_t);
+}
diff --git a/unit_test/fuzzing/fuzzing_AFL.sh b/unit_test/fuzzing/fuzzing_AFL.sh
index 5e08fa75926..11faeb42372 100755
--- a/unit_test/fuzzing/fuzzing_AFL.sh
+++ b/unit_test/fuzzing/fuzzing_AFL.sh
@@ -101,6 +101,8 @@ make
 pushd bin
 
 cmds=(
+test_spdm_transport_tcp_encode_message
+test_spdm_transport_tcp_decode_message
 test_spdm_transport_mctp_encode_message
 test_spdm_transport_mctp_decode_message
 test_spdm_transport_pci_doe_encode_message
@@ -220,4 +222,4 @@ function walk_dir(){
 }
 
 echo afl_banner,unique_crashes,unique_hangs > $fuzzing_out"/SummaryList.csv"
-walk_dir $fuzzing_out
\ No newline at end of file
+walk_dir $fuzzing_out
diff --git a/unit_test/fuzzing/fuzzing_AFLTurbo.sh b/unit_test/fuzzing/fuzzing_AFLTurbo.sh
index 55540a45c23..9a7ad5db74c 100755
--- a/unit_test/fuzzing/fuzzing_AFLTurbo.sh
+++ b/unit_test/fuzzing/fuzzing_AFLTurbo.sh
@@ -102,6 +102,8 @@ make
 pushd bin
 
 cmds=(
+test_spdm_transport_tcp_encode_message
+test_spdm_transport_tcp_decode_mesasge
 test_spdm_transport_mctp_encode_message
 test_spdm_transport_mctp_decode_message
 test_spdm_transport_pci_doe_encode_message
@@ -224,4 +226,4 @@ function walk_dir(){
 }
 
 echo afl_banner,unique_crashes,unique_hangs > $fuzzing_out"/SummaryList.csv"
-walk_dir $fuzzing_out
\ No newline at end of file
+walk_dir $fuzzing_out
diff --git a/unit_test/fuzzing/fuzzing_AFLplusplus.sh b/unit_test/fuzzing/fuzzing_AFLplusplus.sh
index 6d60449bfcc..4acd18fdd9d 100755
--- a/unit_test/fuzzing/fuzzing_AFLplusplus.sh
+++ b/unit_test/fuzzing/fuzzing_AFLplusplus.sh
@@ -110,10 +110,14 @@ make
 pushd bin
 
 cmds=(
+test_spdm_transport_tcp_encode_message
+test_spdm_transport_tcp_decode_message
 test_spdm_transport_mctp_encode_message
 test_spdm_transport_mctp_decode_message
 test_spdm_transport_pci_doe_encode_message
 test_spdm_transport_pci_doe_decode_message
+test_spdm_transport_tcp_encode_message
+test_spdm_transport_tcp_decode_message
 test_spdm_decode_secured_message
 test_spdm_encode_secured_message
 test_spdm_requester_encap_digests
@@ -232,4 +236,4 @@ function walk_dir(){
 }
 
 echo afl_banner,unique_crashes,unique_hangs > $fuzzing_out"/SummaryList.csv"
-walk_dir $fuzzing_out
\ No newline at end of file
+walk_dir $fuzzing_out
diff --git a/unit_test/fuzzing/fuzzing_LibFuzzer.sh b/unit_test/fuzzing/fuzzing_LibFuzzer.sh
index 56c19d4f75f..4434ccbaa02 100755
--- a/unit_test/fuzzing/fuzzing_LibFuzzer.sh
+++ b/unit_test/fuzzing/fuzzing_LibFuzzer.sh
@@ -72,6 +72,8 @@ make
 pushd bin
 
 cmds=(
+test_spdm_trnasport_tcp_encode_message
+test_spdm_transport_tcp_decode_message
 test_spdm_transport_mctp_encode_message
 test_spdm_transport_mctp_decode_message
 test_spdm_transport_pci_doe_encode_message
@@ -180,4 +182,4 @@ echo libfuzzer_banner,leak,timeout,crash > $fuzzing_out"/SummaryList.csv"
 walk_dir $fuzzing_out
 
 sed -i '/SummaryList.csv/d' $fuzzing_out"/SummaryList.csv"
-sed -i '/coverage_log/d' $fuzzing_out"/SummaryList.csv"
\ No newline at end of file
+sed -i '/coverage_log/d' $fuzzing_out"/SummaryList.csv"
diff --git a/unit_test/fuzzing/oss_fuzz.sh b/unit_test/fuzzing/oss_fuzz.sh
index 70068bf30df..d8d3254c245 100755
--- a/unit_test/fuzzing/oss_fuzz.sh
+++ b/unit_test/fuzzing/oss_fuzz.sh
@@ -68,6 +68,8 @@ else
 fi
 
 cmds=(
+test_spdm_transport_tcp_encode_message
+test_spdm_transport_tcp_decode_message
 test_spdm_transport_mctp_encode_message
 test_spdm_transport_mctp_decode_message
 test_spdm_transport_pci_doe_encode_message
diff --git a/unit_test/fuzzing/run_initial_seed.sh b/unit_test/fuzzing/run_initial_seed.sh
index e3081835b1e..088c2acaf2b 100755
--- a/unit_test/fuzzing/run_initial_seed.sh
+++ b/unit_test/fuzzing/run_initial_seed.sh
@@ -3,6 +3,8 @@
 # this script will run one program one time, with a known good seed, to ensure it can pass the flow without any exception.
 
 cmds=(
+test_spdm_transport_tcp_encode_message
+test_spdm_transport_tcp_decode_message
 test_spdm_transport_mctp_encode_message
 test_spdm_transport_mctp_decode_message
 test_spdm_transport_pci_doe_encode_message
@@ -82,4 +84,4 @@ if [ ${flag} -eq 1 ]; then
         echo ${fail_list[$i]}
     done
 fi
-exit $flag
\ No newline at end of file
+exit $flag
diff --git a/unit_test/fuzzing/seeds/test_spdm_transport_tcp_decode_message/spdm_transport_tcp_decode_message.raw b/unit_test/fuzzing/seeds/test_spdm_transport_tcp_decode_message/spdm_transport_tcp_decode_message.raw
new file mode 100644
index 00000000000..f31125edec8
Binary files /dev/null and b/unit_test/fuzzing/seeds/test_spdm_transport_tcp_decode_message/spdm_transport_tcp_decode_message.raw differ
diff --git a/unit_test/fuzzing/seeds/test_spdm_transport_tcp_encode_message/spdm_transport_tcp_encode_message.raw b/unit_test/fuzzing/seeds/test_spdm_transport_tcp_encode_message/spdm_transport_tcp_encode_message.raw
new file mode 100644
index 00000000000..f31125edec8
Binary files /dev/null and b/unit_test/fuzzing/seeds/test_spdm_transport_tcp_encode_message/spdm_transport_tcp_encode_message.raw differ
diff --git a/unit_test/fuzzing/test_transport/test_spdm_transport_tcp_decode_message/CMakeLists.txt b/unit_test/fuzzing/test_transport/test_spdm_transport_tcp_decode_message/CMakeLists.txt
new file mode 100644
index 00000000000..fe4a72d7ab5
--- /dev/null
+++ b/unit_test/fuzzing/test_transport/test_spdm_transport_tcp_decode_message/CMakeLists.txt
@@ -0,0 +1,62 @@
+cmake_minimum_required(VERSION 3.5)
+
+add_executable(test_spdm_transport_tcp_decode_message)
+
+target_include_directories(test_spdm_transport_tcp_decode_message
+    PRIVATE
+        ${LIBSPDM_DIR}/unit_test/fuzzing/test_transport/test_spdm_transport_tcp_decode_message
+        ${LIBSPDM_DIR}/include
+        ${LIBSPDM_DIR}/include/library
+        ${LIBSPDM_DIR}/unit_test/include
+        ${LIBSPDM_DIR}/unit_test/fuzzing/spdm_unit_fuzzing_common
+        ${LIBSPDM_DIR}/os_stub/include
+)
+
+if(TOOLCHAIN STREQUAL "KLEE")
+    target_include_directories(test_spdm_transport_tcp_decode_message
+        PRIVATE
+            $ENV{KLEE_SRC_PATH}/include
+    )
+endif()
+
+target_sources(test_spdm_transport_tcp_decode_message
+    PRIVATE
+        spdm_transport_tcp_decode_message.c
+        ${PROJECT_SOURCE_DIR}/unit_test/fuzzing/spdm_unit_fuzzing_common/common.c
+        ${PROJECT_SOURCE_DIR}/unit_test/fuzzing/spdm_unit_fuzzing_common/toolchain_harness.c
+        ${PROJECT_SOURCE_DIR}/unit_test/fuzzing/spdm_unit_fuzzing_common/algo.c
+)
+
+if((TOOLCHAIN STREQUAL "KLEE") OR (TOOLCHAIN STREQUAL "CBMC"))
+    target_link_libraries(test_spdm_transport_tcp_decode_message
+        PRIVATE
+            $<TARGET_OBJECTS:memlib>
+            $<TARGET_OBJECTS:debuglib>
+            $<TARGET_OBJECTS:spdm_transport_tcp_lib>
+            $<TARGET_OBJECTS:spdm_common_lib>
+            $<TARGET_OBJECTS:${CRYPTO_LIB_PATHS}>
+            $<TARGET_OBJECTS:rnglib>
+            $<TARGET_OBJECTS:cryptlib_${CRYPTO}>
+            $<TARGET_OBJECTS:malloclib>
+            $<TARGET_OBJECTS:spdm_crypt_lib>
+            $<TARGET_OBJECTS:spdm_secured_message_lib>
+            $<TARGET_OBJECTS:spdm_transport_test_lib>
+            $<TARGET_OBJECTS:spdm_device_secret_lib_null>
+    )
+else()
+    target_link_libraries(test_spdm_transport_tcp_decode_message
+        PRIVATE
+            memlib
+            debuglib
+            spdm_transport_tcp_lib
+            spdm_common_lib
+            ${CRYPTO_LIB_PATHS}
+            rnglib
+            cryptlib_${CRYPTO}
+            malloclib
+            spdm_crypt_lib
+            spdm_secured_message_lib
+            spdm_transport_test_lib
+            spdm_device_secret_lib_null
+    )
+endif()
diff --git a/unit_test/fuzzing/test_transport/test_spdm_transport_tcp_decode_message/spdm_transport_tcp_decode_message.c b/unit_test/fuzzing/test_transport/test_spdm_transport_tcp_decode_message/spdm_transport_tcp_decode_message.c
new file mode 100644
index 00000000000..36899e5fb45
--- /dev/null
+++ b/unit_test/fuzzing/test_transport/test_spdm_transport_tcp_decode_message/spdm_transport_tcp_decode_message.c
@@ -0,0 +1,59 @@
+/**
+ *  Copyright Notice:
+ *  Copyright 2025 DMTF. All rights reserved.
+ *  License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/libspdm/blob/main/LICENSE.md
+ **/
+
+#include "internal/libspdm_responder_lib.h"
+#include "spdm_transport_tcp_lib.h"
+#include "spdm_unit_fuzzing.h"
+#include "toolchain_harness.h"
+
+size_t libspdm_get_max_buffer_size(void)
+{
+    return LIBSPDM_RECEIVER_BUFFER_SIZE;
+}
+
+void libspdm_test_transport_tcp_decode_message(void **State)
+{
+    libspdm_test_context_t *spdm_test_context;
+    libspdm_context_t *spdm_context;
+    size_t transport_message_size;
+    uint8_t *transport_message;
+    bool is_app_message;
+    bool is_requester;
+    spdm_test_context = *State;
+    spdm_context = spdm_test_context->spdm_context;
+    is_requester = spdm_test_context->is_requester;
+    is_app_message = false;
+
+    spdm_context->connection_info.connection_state = LIBSPDM_CONNECTION_STATE_AFTER_VERSION;
+
+    transport_message_size = spdm_test_context->test_buffer_size;
+
+    libspdm_transport_tcp_decode_message(spdm_context, NULL, &is_app_message, is_requester,
+                                         spdm_test_context->test_buffer_size,
+                                         spdm_test_context->test_buffer, &transport_message_size,
+                                         (void **)&transport_message);
+}
+
+libspdm_test_context_t m_libspdm_transport_tcp_test_context = {
+    LIBSPDM_TEST_CONTEXT_VERSION,
+    false,
+};
+
+void libspdm_run_test_harness(void *test_buffer, size_t test_buffer_size)
+{
+    void *State;
+
+    libspdm_setup_test_context(&m_libspdm_transport_tcp_test_context);
+
+    m_libspdm_transport_tcp_test_context.test_buffer = test_buffer;
+    m_libspdm_transport_tcp_test_context.test_buffer_size = test_buffer_size;
+
+    libspdm_unit_test_group_setup(&State);
+
+    libspdm_test_transport_tcp_decode_message(&State);
+
+    libspdm_unit_test_group_teardown(&State);
+}
diff --git a/unit_test/fuzzing/test_transport/test_spdm_transport_tcp_encode_message/CMakeLists.txt b/unit_test/fuzzing/test_transport/test_spdm_transport_tcp_encode_message/CMakeLists.txt
new file mode 100644
index 00000000000..722b142c86b
--- /dev/null
+++ b/unit_test/fuzzing/test_transport/test_spdm_transport_tcp_encode_message/CMakeLists.txt
@@ -0,0 +1,62 @@
+cmake_minimum_required(VERSION 3.5)
+
+add_executable(test_spdm_transport_tcp_encode_message)
+
+target_include_directories(test_spdm_transport_tcp_encode_message
+    PRIVATE
+        ${LIBSPDM_DIR}/unit_test/fuzzing/test_transport/test_spdm_transport_tcp_encode_message
+        ${LIBSPDM_DIR}/include
+        ${LIBSPDM_DIR}/include/library
+        ${LIBSPDM_DIR}/unit_test/include
+        ${LIBSPDM_DIR}/unit_test/fuzzing/spdm_unit_fuzzing_common
+        ${LIBSPDM_DIR}/os_stub/include
+)
+
+if(TOOLCHAIN STREQUAL "KLEE")
+    target_include_directories(test_spdm_transport_tcp_encode_message
+        PRIVATE
+            $ENV{KLEE_SRC_PATH}/include
+    )
+endif()
+
+target_sources(test_spdm_transport_tcp_encode_message
+    PRIVATE
+        spdm_transport_tcp_encode_message.c
+        ${PROJECT_SOURCE_DIR}/unit_test/fuzzing/spdm_unit_fuzzing_common/common.c
+        ${PROJECT_SOURCE_DIR}/unit_test/fuzzing/spdm_unit_fuzzing_common/toolchain_harness.c
+        ${PROJECT_SOURCE_DIR}/unit_test/fuzzing/spdm_unit_fuzzing_common/algo.c
+)
+
+if((TOOLCHAIN STREQUAL "KLEE") OR (TOOLCHAIN STREQUAL "CBMC"))
+    target_link_libraries(test_spdm_transport_tcp_encode_message
+        PRIVATE
+            $<TARGET_OBJECTS:memlib>
+            $<TARGET_OBJECTS:debuglib>
+            $<TARGET_OBJECTS:spdm_transport_tcp_lib>
+            $<TARGET_OBJECTS:spdm_common_lib>
+            $<TARGET_OBJECTS:${CRYPTO_LIB_PATHS}>
+            $<TARGET_OBJECTS:rnglib>
+            $<TARGET_OBJECTS:cryptlib_${CRYPTO}>
+            $<TARGET_OBJECTS:malloclib>
+            $<TARGET_OBJECTS:spdm_crypt_lib>
+            $<TARGET_OBJECTS:spdm_secured_message_lib>
+            $<TARGET_OBJECTS:spdm_transport_test_lib>
+            $<TARGET_OBJECTS:spdm_device_secret_lib_null>
+    )
+else()
+    target_link_libraries(test_spdm_transport_tcp_encode_message
+        PRIVATE
+            memlib
+            debuglib
+            spdm_transport_tcp_lib
+            spdm_common_lib
+            ${CRYPTO_LIB_PATHS}
+            rnglib
+            cryptlib_${CRYPTO}
+            malloclib
+            spdm_crypt_lib
+            spdm_secured_message_lib
+            spdm_transport_test_lib
+            spdm_device_secret_lib_null
+    )
+endif()
diff --git a/unit_test/fuzzing/test_transport/test_spdm_transport_tcp_encode_message/spdm_transport_tcp_encode_message.c b/unit_test/fuzzing/test_transport/test_spdm_transport_tcp_encode_message/spdm_transport_tcp_encode_message.c
new file mode 100644
index 00000000000..ff7c888acad
--- /dev/null
+++ b/unit_test/fuzzing/test_transport/test_spdm_transport_tcp_encode_message/spdm_transport_tcp_encode_message.c
@@ -0,0 +1,74 @@
+/**
+ *  Copyright Notice:
+ *  Copyright 2025 DMTF. All rights reserved.
+ *  License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/libspdm/blob/main/LICENSE.md
+ **/
+
+#include "internal/libspdm_responder_lib.h"
+#include "spdm_transport_tcp_lib.h"
+#include "industry_standard/spdm_tcp_binding.h"
+#include "spdm_unit_fuzzing.h"
+#include "toolchain_harness.h"
+
+size_t libspdm_get_max_buffer_size(void)
+{
+    return LIBSPDM_MAX_SPDM_MSG_SIZE;
+}
+
+void libspdm_test_transport_tcp_encode_message(void **State)
+{
+    libspdm_test_context_t *spdm_test_context;
+    libspdm_context_t *spdm_context;
+    size_t transport_message_size;
+    uint8_t *transport_message;
+    bool is_app_message;
+    bool is_requester;
+    size_t record_header_max_size;
+
+    spdm_test_context = *State;
+    spdm_context = spdm_test_context->spdm_context;
+    is_requester = spdm_test_context->is_requester;
+    is_app_message = false;
+
+    record_header_max_size = sizeof(spdm_tcp_binding_header_t);
+
+    transport_message_size = spdm_test_context->test_buffer_size;
+    transport_message = spdm_test_context->test_buffer;
+
+    libspdm_transport_tcp_encode_message(spdm_context, NULL, is_app_message, is_requester,
+                                         spdm_test_context->test_buffer_size - record_header_max_size,
+                                         (uint8_t *)spdm_test_context->test_buffer + record_header_max_size,
+                                         &transport_message_size,
+                                         (void **)&transport_message);
+}
+
+libspdm_test_context_t m_libspdm_transport_tcp_test_context = {
+    LIBSPDM_TEST_CONTEXT_VERSION,
+    false,
+};
+
+void libspdm_run_test_harness(void *test_buffer, size_t test_buffer_size)
+{
+    void *State;
+    size_t record_header_max_size;
+    size_t buffer_size;
+
+    libspdm_setup_test_context(&m_libspdm_transport_tcp_test_context);
+
+    /* limit the encoding buffer to avoid assert, because the input buffer is controlled by the libspdm consumer. */
+    record_header_max_size = sizeof(spdm_tcp_binding_header_t);
+    buffer_size = test_buffer_size;
+
+    if (buffer_size < record_header_max_size) {
+        /* buffer too small */
+        return;
+    }
+
+    m_libspdm_transport_tcp_test_context.test_buffer = test_buffer;
+    m_libspdm_transport_tcp_test_context.test_buffer_size = buffer_size;
+
+    libspdm_unit_test_group_setup(&State);
+
+    libspdm_test_transport_tcp_encode_message(&State);
+    libspdm_unit_test_group_teardown(&State);
+}


Reviews:
user: login: jyao1
state: COMMENTED
author_association: MEMBER
submitted_at: 2025-04-07T04:50:11Z
user: login: jyao1
state: COMMENTED
author_association: MEMBER
submitted_at: 2025-04-07T04:50:21Z
user: login: jyao1
state: COMMENTED
author_association: MEMBER
submitted_at: 2025-04-07T04:51:10Z
user: login: manojkiraneda
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-04-28T11:26:49Z
user: login: manojkiraneda
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-04-28T11:34:22Z
user: login: manojkiraneda
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-04-28T11:35:41Z
user: login: steven-bellock
state: CHANGES_REQUESTED
author_association: CONTRIBUTOR
submitted_at: 2025-04-28T21:40:40Z
user: login: manojkiraneda
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-04-29T11:39:04Z
user: login: manojkiraneda
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-04-29T11:39:16Z
user: login: manojkiraneda
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-04-29T11:40:11Z
user: login: manojkiraneda
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-04-29T11:40:21Z
user: login: manojkiraneda
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-04-29T11:40:33Z
user: login: steven-bellock
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-04-30T19:08:40Z
user: login: steven-bellock
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-04-30T21:10:07Z
user: login: steven-bellock
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-04-30T22:37:51Z
user: login: steven-bellock
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-04-30T22:38:33Z
user: login: steven-bellock
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-04-30T22:58:17Z
user: login: manojkiraneda
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-05-02T08:41:03Z
user: login: manojkiraneda
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-05-02T08:41:13Z
user: login: manojkiraneda
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-05-02T08:41:21Z
user: login: manojkiraneda
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-05-07T11:05:52Z
user: login: manojkiraneda
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-05-07T11:07:15Z
user: login: manojkiraneda
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-05-07T11:07:25Z
user: login: jyao1
state: COMMENTED
author_association: MEMBER
submitted_at: 2025-05-08T02:40:11Z
user: login: jyao1
state: COMMENTED
author_association: MEMBER
submitted_at: 2025-05-08T02:40:27Z
user: login: jyao1
state: COMMENTED
author_association: MEMBER
submitted_at: 2025-05-08T02:40:43Z
user: login: jyao1
state: COMMENTED
author_association: MEMBER
submitted_at: 2025-05-08T02:40:59Z
user: login: jyao1
state: COMMENTED
author_association: MEMBER
submitted_at: 2025-05-08T02:41:53Z
user: login: jyao1
state: COMMENTED
author_association: MEMBER
submitted_at: 2025-05-08T02:42:06Z
user: login: jyao1
state: COMMENTED
author_association: MEMBER
submitted_at: 2025-05-08T02:44:00Z
user: login: steven-bellock
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-05-11T14:26:15Z
user: login: manojkiraneda
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-05-22T03:47:28Z
user: login: manojkiraneda
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-05-22T03:47:35Z
user: login: manojkiraneda
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-05-22T03:47:43Z
user: login: manojkiraneda
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-05-22T03:47:50Z
user: login: manojkiraneda
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-05-22T03:47:57Z
user: login: manojkiraneda
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-05-22T03:48:03Z
user: login: manojkiraneda
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-05-22T03:49:03Z
user: login: steven-bellock
state: APPROVED
author_association: CONTRIBUTOR
submitted_at: 2025-05-28T21:15:56Z

Review comments:
diff_hunk: @@ -0,0 +1,169 @@
+/**
+ *  Copyright Notice:
+ *  Copyright 2025 DMTF. All rights reserved.
+ *  License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/libspdm/blob/main/LICENSE.md
+ **/
+
+#ifndef SPDM_TCP_TRANSPORT_LIB_H
+#define SPDM_TCP_TRANSPORT_LIB_H
+
+#include "library/spdm_common_lib.h"
+
+#define LIBSPDM_TCP_ALIGNMENT 4
+
+#define LIBSPDM_TCP_SEQUENCE_NUMBER_COUNT 0
+#define LIBSPDM_TCP_MAX_RANDOM_NUMBER_COUNT 0
+
+/* Required sender/receive buffer in device io.
+ * +-------+--------+---------------------------+------+--+------+---+--------+-----+
+ * | TYPE  |TransHdr|      EncryptionHeader     |AppHdr|  |Random|MAC|AlignPad|FINAL|
+ * |       |        |SessionId|SeqNum|Len|AppLen|      |  |      |   |        |     |
+ * +-------+--------+---------------------------+------+  +------+---+--------+-----+
+ * |  TCP  |    4   |    4    |   0  | 2 |   2  |   0  |  |   0  | 16|   3    |  31 |
+ * +-------+--------+---------------------------+------+--+------+---+--------+-----+
+ */
+#define LIBSPDM_TCP_TRANSPORT_ADDITIONAL_SIZE        (12 + \
+                                                      LIBSPDM_PCI_DOE_SEQUENCE_NUMBER_COUNT + \
+                                                      LIBSPDM_PCI_DOE_MAX_RANDOM_NUMBER_COUNT + \
+                                                      LIBSPDM_MAX_AEAD_TAG_SIZE + \
+                                                      (LIBSPDM_PCI_DOE_ALIGNMENT - 1))
+
+#pragma pack(1)
+
+typedef struct {
+    uint16_t payload_length;
+    uint8_t reserved;
path: include/library/spdm_transport_tcp_lib.h
user: login: jyao1
body: This should be binding version.
created_at: 2025-04-07T04:50:11Z
author_association: MEMBER
diff_hunk: @@ -0,0 +1,169 @@
+/**
+ *  Copyright Notice:
+ *  Copyright 2025 DMTF. All rights reserved.
+ *  License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/libspdm/blob/main/LICENSE.md
+ **/
+
+#ifndef SPDM_TCP_TRANSPORT_LIB_H
+#define SPDM_TCP_TRANSPORT_LIB_H
+
+#include "library/spdm_common_lib.h"
+
+#define LIBSPDM_TCP_ALIGNMENT 4
+
+#define LIBSPDM_TCP_SEQUENCE_NUMBER_COUNT 0
+#define LIBSPDM_TCP_MAX_RANDOM_NUMBER_COUNT 0
+
+/* Required sender/receive buffer in device io.
+ * +-------+--------+---------------------------+------+--+------+---+--------+-----+
+ * | TYPE  |TransHdr|      EncryptionHeader     |AppHdr|  |Random|MAC|AlignPad|FINAL|
+ * |       |        |SessionId|SeqNum|Len|AppLen|      |  |      |   |        |     |
+ * +-------+--------+---------------------------+------+  +------+---+--------+-----+
+ * |  TCP  |    4   |    4    |   0  | 2 |   2  |   0  |  |   0  | 16|   3    |  31 |
+ * +-------+--------+---------------------------+------+--+------+---+--------+-----+
+ */
+#define LIBSPDM_TCP_TRANSPORT_ADDITIONAL_SIZE        (12 + \
+                                                      LIBSPDM_PCI_DOE_SEQUENCE_NUMBER_COUNT + \
+                                                      LIBSPDM_PCI_DOE_MAX_RANDOM_NUMBER_COUNT + \
+                                                      LIBSPDM_MAX_AEAD_TAG_SIZE + \
+                                                      (LIBSPDM_PCI_DOE_ALIGNMENT - 1))
+
+#pragma pack(1)
+
+typedef struct {
+    uint16_t payload_length;
+    uint8_t reserved;
+    uint8_t message_type;
+} tcp_spdm_binding_header_t;
path: include/library/spdm_transport_tcp_lib.h
user: login: jyao1
body: this is defined in spec. please move to industry standard header file.
Not here.
created_at: 2025-04-07T04:50:21Z
author_association: MEMBER
diff_hunk: @@ -0,0 +1,169 @@
+/**
+ *  Copyright Notice:
+ *  Copyright 2025 DMTF. All rights reserved.
+ *  License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/libspdm/blob/main/LICENSE.md
+ **/
+
+#ifndef SPDM_TCP_TRANSPORT_LIB_H
+#define SPDM_TCP_TRANSPORT_LIB_H
+
+#include "library/spdm_common_lib.h"
+
+#define LIBSPDM_TCP_ALIGNMENT 4
+
+#define LIBSPDM_TCP_SEQUENCE_NUMBER_COUNT 0
+#define LIBSPDM_TCP_MAX_RANDOM_NUMBER_COUNT 0
+
+/* Required sender/receive buffer in device io.
+ * +-------+--------+---------------------------+------+--+------+---+--------+-----+
+ * | TYPE  |TransHdr|      EncryptionHeader     |AppHdr|  |Random|MAC|AlignPad|FINAL|
+ * |       |        |SessionId|SeqNum|Len|AppLen|      |  |      |   |        |     |
+ * +-------+--------+---------------------------+------+  +------+---+--------+-----+
+ * |  TCP  |    4   |    4    |   0  | 2 |   2  |   0  |  |   0  | 16|   3    |  31 |
+ * +-------+--------+---------------------------+------+--+------+---+--------+-----+
+ */
+#define LIBSPDM_TCP_TRANSPORT_ADDITIONAL_SIZE        (12 + \
+                                                      LIBSPDM_PCI_DOE_SEQUENCE_NUMBER_COUNT + \
+                                                      LIBSPDM_PCI_DOE_MAX_RANDOM_NUMBER_COUNT + \
+                                                      LIBSPDM_MAX_AEAD_TAG_SIZE + \
+                                                      (LIBSPDM_PCI_DOE_ALIGNMENT - 1))
+
+#pragma pack(1)
+
+typedef struct {
+    uint16_t payload_length;
+    uint8_t reserved;
+    uint8_t message_type;
+} tcp_spdm_binding_header_t;
+
+#define TCP_MESSAGE_TYPE_OUT_OF_SESSION 0x01
+#define TCP_MESSAGE_TYPE_IN_SESSION 0x02
+#define TCP_MESSAGE_TYPE_HANDSHAKE_REQUEST 0x03
path: include/library/spdm_transport_tcp_lib.h
user: login: jyao1
body: The definition is incorrect according to the spec.

created_at: 2025-04-07T04:51:09Z
author_association: MEMBER
diff_hunk: @@ -0,0 +1,169 @@
+/**
+ *  Copyright Notice:
+ *  Copyright 2025 DMTF. All rights reserved.
+ *  License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/libspdm/blob/main/LICENSE.md
+ **/
+
+#ifndef SPDM_TCP_TRANSPORT_LIB_H
+#define SPDM_TCP_TRANSPORT_LIB_H
+
+#include "library/spdm_common_lib.h"
+
+#define LIBSPDM_TCP_ALIGNMENT 4
+
+#define LIBSPDM_TCP_SEQUENCE_NUMBER_COUNT 0
+#define LIBSPDM_TCP_MAX_RANDOM_NUMBER_COUNT 0
+
+/* Required sender/receive buffer in device io.
+ * +-------+--------+---------------------------+------+--+------+---+--------+-----+
+ * | TYPE  |TransHdr|      EncryptionHeader     |AppHdr|  |Random|MAC|AlignPad|FINAL|
+ * |       |        |SessionId|SeqNum|Len|AppLen|      |  |      |   |        |     |
+ * +-------+--------+---------------------------+------+  +------+---+--------+-----+
+ * |  TCP  |    4   |    4    |   0  | 2 |   2  |   0  |  |   0  | 16|   3    |  31 |
+ * +-------+--------+---------------------------+------+--+------+---+--------+-----+
+ */
+#define LIBSPDM_TCP_TRANSPORT_ADDITIONAL_SIZE        (12 + \
+                                                      LIBSPDM_PCI_DOE_SEQUENCE_NUMBER_COUNT + \
+                                                      LIBSPDM_PCI_DOE_MAX_RANDOM_NUMBER_COUNT + \
+                                                      LIBSPDM_MAX_AEAD_TAG_SIZE + \
+                                                      (LIBSPDM_PCI_DOE_ALIGNMENT - 1))
+
+#pragma pack(1)
+
+typedef struct {
+    uint16_t payload_length;
+    uint8_t reserved;
path: include/library/spdm_transport_tcp_lib.h
user: login: manojkiraneda
body: done.
created_at: 2025-04-28T11:26:49Z
author_association: CONTRIBUTOR
diff_hunk: @@ -0,0 +1,169 @@
+/**
+ *  Copyright Notice:
+ *  Copyright 2025 DMTF. All rights reserved.
+ *  License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/libspdm/blob/main/LICENSE.md
+ **/
+
+#ifndef SPDM_TCP_TRANSPORT_LIB_H
+#define SPDM_TCP_TRANSPORT_LIB_H
+
+#include "library/spdm_common_lib.h"
+
+#define LIBSPDM_TCP_ALIGNMENT 4
+
+#define LIBSPDM_TCP_SEQUENCE_NUMBER_COUNT 0
+#define LIBSPDM_TCP_MAX_RANDOM_NUMBER_COUNT 0
+
+/* Required sender/receive buffer in device io.
+ * +-------+--------+---------------------------+------+--+------+---+--------+-----+
+ * | TYPE  |TransHdr|      EncryptionHeader     |AppHdr|  |Random|MAC|AlignPad|FINAL|
+ * |       |        |SessionId|SeqNum|Len|AppLen|      |  |      |   |        |     |
+ * +-------+--------+---------------------------+------+  +------+---+--------+-----+
+ * |  TCP  |    4   |    4    |   0  | 2 |   2  |   0  |  |   0  | 16|   3    |  31 |
+ * +-------+--------+---------------------------+------+--+------+---+--------+-----+
+ */
+#define LIBSPDM_TCP_TRANSPORT_ADDITIONAL_SIZE        (12 + \
+                                                      LIBSPDM_PCI_DOE_SEQUENCE_NUMBER_COUNT + \
+                                                      LIBSPDM_PCI_DOE_MAX_RANDOM_NUMBER_COUNT + \
+                                                      LIBSPDM_MAX_AEAD_TAG_SIZE + \
+                                                      (LIBSPDM_PCI_DOE_ALIGNMENT - 1))
+
+#pragma pack(1)
+
+typedef struct {
+    uint16_t payload_length;
+    uint8_t reserved;
+    uint8_t message_type;
+} tcp_spdm_binding_header_t;
path: include/library/spdm_transport_tcp_lib.h
user: login: manojkiraneda
body: done.
created_at: 2025-04-28T11:34:21Z
author_association: CONTRIBUTOR
diff_hunk: @@ -0,0 +1,169 @@
+/**
+ *  Copyright Notice:
+ *  Copyright 2025 DMTF. All rights reserved.
+ *  License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/libspdm/blob/main/LICENSE.md
+ **/
+
+#ifndef SPDM_TCP_TRANSPORT_LIB_H
+#define SPDM_TCP_TRANSPORT_LIB_H
+
+#include "library/spdm_common_lib.h"
+
+#define LIBSPDM_TCP_ALIGNMENT 4
+
+#define LIBSPDM_TCP_SEQUENCE_NUMBER_COUNT 0
+#define LIBSPDM_TCP_MAX_RANDOM_NUMBER_COUNT 0
+
+/* Required sender/receive buffer in device io.
+ * +-------+--------+---------------------------+------+--+------+---+--------+-----+
+ * | TYPE  |TransHdr|      EncryptionHeader     |AppHdr|  |Random|MAC|AlignPad|FINAL|
+ * |       |        |SessionId|SeqNum|Len|AppLen|      |  |      |   |        |     |
+ * +-------+--------+---------------------------+------+  +------+---+--------+-----+
+ * |  TCP  |    4   |    4    |   0  | 2 |   2  |   0  |  |   0  | 16|   3    |  31 |
+ * +-------+--------+---------------------------+------+--+------+---+--------+-----+
+ */
+#define LIBSPDM_TCP_TRANSPORT_ADDITIONAL_SIZE        (12 + \
+                                                      LIBSPDM_PCI_DOE_SEQUENCE_NUMBER_COUNT + \
+                                                      LIBSPDM_PCI_DOE_MAX_RANDOM_NUMBER_COUNT + \
+                                                      LIBSPDM_MAX_AEAD_TAG_SIZE + \
+                                                      (LIBSPDM_PCI_DOE_ALIGNMENT - 1))
+
+#pragma pack(1)
+
+typedef struct {
+    uint16_t payload_length;
+    uint8_t reserved;
+    uint8_t message_type;
+} tcp_spdm_binding_header_t;
+
+#define TCP_MESSAGE_TYPE_OUT_OF_SESSION 0x01
+#define TCP_MESSAGE_TYPE_IN_SESSION 0x02
+#define TCP_MESSAGE_TYPE_HANDSHAKE_REQUEST 0x03
path: include/library/spdm_transport_tcp_lib.h
user: login: manojkiraneda
body: Yes, i have modified them to be as per the spec now.

```
#define TCP_MESSAGE_TYPE_OUT_OF_SESSION 0x05
#define TCP_MESSAGE_TYPE_IN_SESSION 0x06
#define TCP_MESSAGE_TYPE_ROLE_INQUIRY 0xBF

/* Error Messages*/
#define TCP_MESSAGE_TYPE_ERROR_TOO_LARGE 0xC0
#define TCP_MESSGAE_TYPE_ERROR_NOT_SUPPORTED 0xC1
#define TCP_MESSAGE_TYPE_ERROR_CANNOT_OPERATE_AS_REQUESTER 0xC2
#define TCP_MESSAGE_TYPE_ERROR_CANNOT_OPERATE_AS_RESPONDER 0xC3
```

Would it be the right place to put the error codes ? as well ? 
created_at: 2025-04-28T11:35:41Z
author_association: CONTRIBUTOR
diff_hunk: @@ -0,0 +1,36 @@
+/**
+ *  Copyright Notice:
+ *  Copyright 2021-2025 DMTF. All rights reserved.
+ *  License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/libspdm/blob/main/LICENSE.md
+ **/
+
+/** @file
+ * Definitions of DSP0287 SPDM over TCP Binding Specification
+ * version 1.0.0 in Distributed Management Task Force (DMTF).
+ *
+ **/
+
+#ifndef TCP_BINDING_H
+#define TCP_BINDING_H
+
+#pragma pack(1)
+
+typedef struct {
+    uint16_t payload_length;
path: include/industry_standard/tcp.h
user: login: steven-bellock
body: It is unclear whether the binding header is big- or little-endian. I will file an issue against the specification.
created_at: 2025-04-28T19:10:23Z
author_association: CONTRIBUTOR
diff_hunk: @@ -0,0 +1,36 @@
+/**
+ *  Copyright Notice:
+ *  Copyright 2021-2025 DMTF. All rights reserved.
+ *  License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/libspdm/blob/main/LICENSE.md
+ **/
+
+/** @file
+ * Definitions of DSP0287 SPDM over TCP Binding Specification
+ * version 1.0.0 in Distributed Management Task Force (DMTF).
+ *
+ **/
+
+#ifndef TCP_BINDING_H
+#define TCP_BINDING_H
+
+#pragma pack(1)
+
+typedef struct {
+    uint16_t payload_length;
path: include/industry_standard/tcp.h
user: login: steven-bellock
body: Filed https://github.com/DMTF/SPDM-WG/issues/4094.
created_at: 2025-04-28T19:14:58Z
author_association: CONTRIBUTOR
diff_hunk: @@ -0,0 +1,36 @@
+/**
+ *  Copyright Notice:
+ *  Copyright 2021-2025 DMTF. All rights reserved.
path: include/industry_standard/tcp.h
user: login: steven-bellock
body: Just `2025`.
created_at: 2025-04-28T19:19:49Z
author_association: CONTRIBUTOR
path: include/industry_standard/tcp.h
user: login: steven-bellock
body: I would call the file `tcp_binding.h`.
created_at: 2025-04-28T21:07:26Z
author_association: CONTRIBUTOR
diff_hunk: @@ -0,0 +1,149 @@
+/**
+ *  Copyright Notice:
+ *  Copyright 2025 DMTF. All rights reserved.
+ *  License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/libspdm/blob/main/LICENSE.md
+ **/
+
+#ifndef SPDM_TCP_TRANSPORT_LIB_H
+#define SPDM_TCP_TRANSPORT_LIB_H
+
+#include "library/spdm_common_lib.h"
+
+#define LIBSPDM_TCP_ALIGNMENT 4
+
+#define LIBSPDM_TCP_SEQUENCE_NUMBER_COUNT 0
path: include/library/spdm_transport_tcp_lib.h
user: login: steven-bellock
body: These are defined in the specification and should go in `industry_standard/`.
created_at: 2025-04-28T21:26:31Z
author_association: CONTRIBUTOR
diff_hunk: @@ -0,0 +1,219 @@
+/**
+ *  Copyright Notice:
+ *  Copyright 2025 DMTF. All rights reserved.
+ *  License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/libspdm/blob/main/LICENSE.md
+ **/
+
+#include "library/spdm_transport_tcp_lib.h"
+#include "internal/libspdm_common_lib.h"
+#include "hal/library/memlib.h"
+#include "industry_standard/tcp.h"
+
+/**
+ * Get sequence number in an SPDM secure message.
+ *
+ * This value is transport layer specific.
+ *
+ * @param sequence_number        The current sequence number used to encode or decode message.
+ * @param sequence_number_buffer  A buffer to hold the sequence number output used in the secured message.
+ *                             The size in byte of the output buffer shall be 8.
+ *
+ * @return size in byte of the sequence_number_buffer.
+ *        It shall be no greater than 8.
+ *        0 means no sequence number is required.
+ **/
+uint8_t libspdm_tcp_get_sequence_number(uint64_t sequence_number,
+                                        uint8_t *sequence_number_buffer)
+{
+    return 0;
path: library/spdm_transport_tcp_lib/libspdm_tcp_tcp.c
user: login: steven-bellock
body: Should use the `#define`.
created_at: 2025-04-28T21:39:40Z
author_association: CONTRIBUTOR
diff_hunk: @@ -0,0 +1,219 @@
+/**
+ *  Copyright Notice:
+ *  Copyright 2025 DMTF. All rights reserved.
+ *  License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/libspdm/blob/main/LICENSE.md
+ **/
+
+#include "library/spdm_transport_tcp_lib.h"
+#include "internal/libspdm_common_lib.h"
+#include "hal/library/memlib.h"
+#include "industry_standard/tcp.h"
+
+/**
+ * Get sequence number in an SPDM secure message.
+ *
+ * This value is transport layer specific.
+ *
+ * @param sequence_number        The current sequence number used to encode or decode message.
+ * @param sequence_number_buffer  A buffer to hold the sequence number output used in the secured message.
+ *                             The size in byte of the output buffer shall be 8.
+ *
+ * @return size in byte of the sequence_number_buffer.
+ *        It shall be no greater than 8.
+ *        0 means no sequence number is required.
+ **/
+uint8_t libspdm_tcp_get_sequence_number(uint64_t sequence_number,
+                                        uint8_t *sequence_number_buffer)
+{
+    return 0;
+}
+
+/**
+ * Return max random number count in an SPDM secure message.
+ *
+ * This value is transport layer specific.
+ *
+ * @return Max random number count in an SPDM secured message.
+ *        0 means no randum number is required.
+ **/
+uint32_t libspdm_tcp_get_max_random_number_count(void)
+{
+    return 0;
path: library/spdm_transport_tcp_lib/libspdm_tcp_tcp.c
user: login: steven-bellock
body: Should use the `#define`.
created_at: 2025-04-28T21:39:48Z
author_association: CONTRIBUTOR
diff_hunk: @@ -0,0 +1,219 @@
+/**
+ *  Copyright Notice:
+ *  Copyright 2025 DMTF. All rights reserved.
+ *  License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/libspdm/blob/main/LICENSE.md
+ **/
+
+#include "library/spdm_transport_tcp_lib.h"
+#include "internal/libspdm_common_lib.h"
+#include "hal/library/memlib.h"
+#include "industry_standard/tcp.h"
+
+/**
+ * Get sequence number in an SPDM secure message.
+ *
+ * This value is transport layer specific.
+ *
+ * @param sequence_number        The current sequence number used to encode or decode message.
+ * @param sequence_number_buffer  A buffer to hold the sequence number output used in the secured message.
+ *                             The size in byte of the output buffer shall be 8.
+ *
+ * @return size in byte of the sequence_number_buffer.
+ *        It shall be no greater than 8.
+ *        0 means no sequence number is required.
+ **/
+uint8_t libspdm_tcp_get_sequence_number(uint64_t sequence_number,
+                                        uint8_t *sequence_number_buffer)
+{
+    return 0;
+}
+
+/**
+ * Return max random number count in an SPDM secure message.
+ *
+ * This value is transport layer specific.
+ *
+ * @return Max random number count in an SPDM secured message.
+ *        0 means no randum number is required.
+ **/
+uint32_t libspdm_tcp_get_max_random_number_count(void)
+{
+    return 0;
+}
+
+/**
+ * This function translates the negotiated secured_message_version to a DSP0277 version.
+ *
+ * @param  secured_message_version  The version specified in binding specification and
+ *                                  negotiated in KEY_EXCHANGE/KEY_EXCHANGE_RSP.
+ *
+ * @return The DSP0277 version specified in binding specification,
+ *         which is bound to secured_message_version.
+ */
+spdm_version_number_t libspdm_tcp_get_secured_spdm_version(
+    spdm_version_number_t secured_message_version)
+{
+    return secured_message_version;
path: library/spdm_transport_tcp_lib/libspdm_tcp_tcp.c
user: login: steven-bellock
body: The specification does not define this. I filed https://github.com/DMTF/SPDM-WG/issues/4095.
created_at: 2025-04-28T21:40:30Z
author_association: CONTRIBUTOR
diff_hunk: @@ -0,0 +1,219 @@
+/**
+ *  Copyright Notice:
+ *  Copyright 2025 DMTF. All rights reserved.
+ *  License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/libspdm/blob/main/LICENSE.md
+ **/
+
+#include "library/spdm_transport_tcp_lib.h"
+#include "internal/libspdm_common_lib.h"
+#include "hal/library/memlib.h"
+#include "industry_standard/tcp.h"
+
+/**
+ * Get sequence number in an SPDM secure message.
+ *
+ * This value is transport layer specific.
+ *
+ * @param sequence_number        The current sequence number used to encode or decode message.
+ * @param sequence_number_buffer  A buffer to hold the sequence number output used in the secured message.
+ *                             The size in byte of the output buffer shall be 8.
+ *
+ * @return size in byte of the sequence_number_buffer.
+ *        It shall be no greater than 8.
+ *        0 means no sequence number is required.
+ **/
+uint8_t libspdm_tcp_get_sequence_number(uint64_t sequence_number,
+                                        uint8_t *sequence_number_buffer)
+{
+    return 0;
+}
+
+/**
+ * Return max random number count in an SPDM secure message.
+ *
+ * This value is transport layer specific.
+ *
+ * @return Max random number count in an SPDM secured message.
+ *        0 means no randum number is required.
+ **/
+uint32_t libspdm_tcp_get_max_random_number_count(void)
+{
+    return 0;
path: library/spdm_transport_tcp_lib/libspdm_tcp_tcp.c
user: login: manojkiraneda
body: done.
created_at: 2025-04-29T11:39:04Z
author_association: CONTRIBUTOR
diff_hunk: @@ -0,0 +1,219 @@
+/**
+ *  Copyright Notice:
+ *  Copyright 2025 DMTF. All rights reserved.
+ *  License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/libspdm/blob/main/LICENSE.md
+ **/
+
+#include "library/spdm_transport_tcp_lib.h"
+#include "internal/libspdm_common_lib.h"
+#include "hal/library/memlib.h"
+#include "industry_standard/tcp.h"
+
+/**
+ * Get sequence number in an SPDM secure message.
+ *
+ * This value is transport layer specific.
+ *
+ * @param sequence_number        The current sequence number used to encode or decode message.
+ * @param sequence_number_buffer  A buffer to hold the sequence number output used in the secured message.
+ *                             The size in byte of the output buffer shall be 8.
+ *
+ * @return size in byte of the sequence_number_buffer.
+ *        It shall be no greater than 8.
+ *        0 means no sequence number is required.
+ **/
+uint8_t libspdm_tcp_get_sequence_number(uint64_t sequence_number,
+                                        uint8_t *sequence_number_buffer)
+{
+    return 0;
path: library/spdm_transport_tcp_lib/libspdm_tcp_tcp.c
user: login: manojkiraneda
body: done.
created_at: 2025-04-29T11:39:16Z
author_association: CONTRIBUTOR
diff_hunk: @@ -0,0 +1,149 @@
+/**
+ *  Copyright Notice:
+ *  Copyright 2025 DMTF. All rights reserved.
+ *  License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/libspdm/blob/main/LICENSE.md
+ **/
+
+#ifndef SPDM_TCP_TRANSPORT_LIB_H
+#define SPDM_TCP_TRANSPORT_LIB_H
+
+#include "library/spdm_common_lib.h"
+
+#define LIBSPDM_TCP_ALIGNMENT 4
+
+#define LIBSPDM_TCP_SEQUENCE_NUMBER_COUNT 0
path: include/library/spdm_transport_tcp_lib.h
user: login: manojkiraneda
body: Done.
created_at: 2025-04-29T11:40:10Z
author_association: CONTRIBUTOR
path: include/industry_standard/tcp.h
user: login: manojkiraneda
body: done.
created_at: 2025-04-29T11:40:21Z
author_association: CONTRIBUTOR
diff_hunk: @@ -0,0 +1,36 @@
+/**
+ *  Copyright Notice:
+ *  Copyright 2021-2025 DMTF. All rights reserved.
path: include/industry_standard/tcp.h
user: login: manojkiraneda
body: done.
created_at: 2025-04-29T11:40:33Z
author_association: CONTRIBUTOR
diff_hunk: @@ -0,0 +1,36 @@
+/**
+ *  Copyright Notice:
+ *  Copyright 2021-2025 DMTF. All rights reserved.
+ *  License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/libspdm/blob/main/LICENSE.md
+ **/
+
+/** @file
+ * Definitions of DSP0287 SPDM over TCP Binding Specification
+ * version 1.0.0 in Distributed Management Task Force (DMTF).
+ *
+ **/
+
+#ifndef TCP_BINDING_H
+#define TCP_BINDING_H
+
+#pragma pack(1)
+
+typedef struct {
+    uint16_t payload_length;
path: include/industry_standard/tcp.h
user: login: steven-bellock
body: @xiaoyuruan has stated that it is little-endian.
created_at: 2025-04-30T19:08:40Z
author_association: CONTRIBUTOR
diff_hunk: @@ -0,0 +1,219 @@
+/**
+ *  Copyright Notice:
+ *  Copyright 2025 DMTF. All rights reserved.
+ *  License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/libspdm/blob/main/LICENSE.md
+ **/
+
+#include "library/spdm_transport_tcp_lib.h"
+#include "internal/libspdm_common_lib.h"
+#include "hal/library/memlib.h"
+#include "industry_standard/tcp.h"
+
+/**
+ * Get sequence number in an SPDM secure message.
+ *
+ * This value is transport layer specific.
+ *
+ * @param sequence_number        The current sequence number used to encode or decode message.
+ * @param sequence_number_buffer  A buffer to hold the sequence number output used in the secured message.
+ *                             The size in byte of the output buffer shall be 8.
+ *
+ * @return size in byte of the sequence_number_buffer.
+ *        It shall be no greater than 8.
+ *        0 means no sequence number is required.
+ **/
+uint8_t libspdm_tcp_get_sequence_number(uint64_t sequence_number,
+                                        uint8_t *sequence_number_buffer)
+{
+    return 0;
+}
+
+/**
+ * Return max random number count in an SPDM secure message.
+ *
+ * This value is transport layer specific.
+ *
+ * @return Max random number count in an SPDM secured message.
+ *        0 means no randum number is required.
+ **/
+uint32_t libspdm_tcp_get_max_random_number_count(void)
+{
+    return 0;
+}
+
+/**
+ * This function translates the negotiated secured_message_version to a DSP0277 version.
+ *
+ * @param  secured_message_version  The version specified in binding specification and
+ *                                  negotiated in KEY_EXCHANGE/KEY_EXCHANGE_RSP.
+ *
+ * @return The DSP0277 version specified in binding specification,
+ *         which is bound to secured_message_version.
+ */
+spdm_version_number_t libspdm_tcp_get_secured_spdm_version(
+    spdm_version_number_t secured_message_version)
+{
+    return secured_message_version;
path: library/spdm_transport_tcp_lib/libspdm_tcp_tcp.c
user: login: steven-bellock
body: Per https://github.com/DMTF/SPDM-WG/pull/4099, sounds like it will bind to 277 1.2.
created_at: 2025-04-30T21:10:07Z
author_association: CONTRIBUTOR
diff_hunk: @@ -0,0 +1,40 @@
+/**
+ *  Copyright Notice:
+ *  Copyright 2025 DMTF. All rights reserved.
+ *  License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/libspdm/blob/main/LICENSE.md
+ **/
+
+/** @file
+ * Definitions of DSP0287 SPDM over TCP Binding Specification
+ * version 1.0.0 in Distributed Management Task Force (DMTF).
+ *
+ **/
+
+#ifndef TCP_BINDING_H
+#define TCP_BINDING_H
+
+#pragma pack(1)
+
+typedef struct {
+    uint16_t payload_length;
+    uint8_t binding_version;
+    uint8_t message_type;
+} tcp_spdm_binding_header_t;
+
+#define TCP_MESSAGE_TYPE_OUT_OF_SESSION 0x05
+#define TCP_MESSAGE_TYPE_IN_SESSION 0x06
+#define TCP_MESSAGE_TYPE_ROLE_INQUIRY 0xBF
+
+/* Error Messages*/
+#define TCP_MESSAGE_TYPE_ERROR_TOO_LARGE 0xC0
+#define TCP_MESSGAE_TYPE_ERROR_NOT_SUPPORTED 0xC1
+#define TCP_MESSAGE_TYPE_ERROR_CANNOT_OPERATE_AS_REQUESTER 0xC2
+#define TCP_MESSAGE_TYPE_ERROR_CANNOT_OPERATE_AS_RESPONDER 0xC3
+
+#define LIBSPDM_TCP_ALIGNMENT 4
path: include/industry_standard/tcp_binding.h
user: login: steven-bellock
body: This should stay in `spdm_transport_tcp_lib.h`.
created_at: 2025-04-30T22:37:51Z
author_association: CONTRIBUTOR
diff_hunk: @@ -0,0 +1,40 @@
+/**
+ *  Copyright Notice:
+ *  Copyright 2025 DMTF. All rights reserved.
+ *  License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/libspdm/blob/main/LICENSE.md
+ **/
+
+/** @file
+ * Definitions of DSP0287 SPDM over TCP Binding Specification
+ * version 1.0.0 in Distributed Management Task Force (DMTF).
+ *
+ **/
+
+#ifndef TCP_BINDING_H
+#define TCP_BINDING_H
+
+#pragma pack(1)
+
+typedef struct {
+    uint16_t payload_length;
+    uint8_t binding_version;
+    uint8_t message_type;
+} tcp_spdm_binding_header_t;
+
+#define TCP_MESSAGE_TYPE_OUT_OF_SESSION 0x05
+#define TCP_MESSAGE_TYPE_IN_SESSION 0x06
+#define TCP_MESSAGE_TYPE_ROLE_INQUIRY 0xBF
+
+/* Error Messages*/
+#define TCP_MESSAGE_TYPE_ERROR_TOO_LARGE 0xC0
+#define TCP_MESSGAE_TYPE_ERROR_NOT_SUPPORTED 0xC1
+#define TCP_MESSAGE_TYPE_ERROR_CANNOT_OPERATE_AS_REQUESTER 0xC2
+#define TCP_MESSAGE_TYPE_ERROR_CANNOT_OPERATE_AS_RESPONDER 0xC3
+
+#define LIBSPDM_TCP_ALIGNMENT 4
+#define LIBSPDM_TCP_SEQUENCE_NUMBER_COUNT 0
+#define LIBSPDM_TCP_MAX_RANDOM_NUMBER_COUNT 0
path: include/industry_standard/tcp_binding.h
user: login: steven-bellock
body: Remove the `LIBSPDM_` prefix.
created_at: 2025-04-30T22:38:33Z
author_association: CONTRIBUTOR
diff_hunk: @@ -0,0 +1,219 @@
+/**
+ *  Copyright Notice:
+ *  Copyright 2025 DMTF. All rights reserved.
+ *  License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/libspdm/blob/main/LICENSE.md
+ **/
+
+#include "library/spdm_transport_tcp_lib.h"
+#include "internal/libspdm_common_lib.h"
+#include "hal/library/memlib.h"
+#include "industry_standard/tcp_binding.h"
+
+/**
+ * Get sequence number in an SPDM secure message.
+ *
+ * This value is transport layer specific.
+ *
+ * @param sequence_number        The current sequence number used to encode or decode message.
+ * @param sequence_number_buffer  A buffer to hold the sequence number output used in the secured message.
+ *                             The size in byte of the output buffer shall be 8.
+ *
+ * @return size in byte of the sequence_number_buffer.
+ *        It shall be no greater than 8.
+ *        0 means no sequence number is required.
+ **/
+uint8_t libspdm_tcp_get_sequence_number(uint64_t sequence_number,
+                                        uint8_t *sequence_number_buffer)
+{
+    return LIBSPDM_TCP_SEQUENCE_NUMBER_COUNT;
+}
+
+/**
+ * Return max random number count in an SPDM secure message.
+ *
+ * This value is transport layer specific.
+ *
+ * @return Max random number count in an SPDM secured message.
+ *        0 means no randum number is required.
+ **/
+uint32_t libspdm_tcp_get_max_random_number_count(void)
+{
+    return LIBSPDM_TCP_MAX_RANDOM_NUMBER_COUNT;
+}
+
+/**
+ * This function translates the negotiated secured_message_version to a DSP0277 version.
+ *
+ * @param  secured_message_version  The version specified in binding specification and
+ *                                  negotiated in KEY_EXCHANGE/KEY_EXCHANGE_RSP.
+ *
+ * @return The DSP0277 version specified in binding specification,
+ *         which is bound to secured_message_version.
+ */
+spdm_version_number_t libspdm_tcp_get_secured_spdm_version(
+    spdm_version_number_t secured_message_version)
+{
+    return secured_message_version;
+}
+
+/**
+ * Encode a normal message or secured message to a transport message.
+ *
+ * @param  session_id                    Indicates if it is a secured message protected via SPDM session.
+ *                                     If session_id is NULL, it is a normal message.
+ *                                     If session_id is NOT NULL, it is a secured message.
+ * @param  message_size                  size in bytes of the message data buffer.
+ * @param  message                      A pointer to a source buffer to store the message.
+ * @param  transport_message_size         size in bytes of the transport message data buffer.
+ * @param  transport_message             A pointer to a destination buffer to store the transport message.
+ *
+ * @retval RETURN_SUCCESS               The message is encoded successfully.
+ * @retval RETURN_INVALID_PARAMETER     The message is NULL or the message_size is zero.
+ **/
+
+libspdm_return_t libspdm_tcp_encode_message(const uint32_t *session_id,
+                                            size_t message_size,
+                                            void *message,
+                                            size_t *transport_message_size,
+                                            void **transport_message)
+{
+    size_t alignment = LIBSPDM_TCP_ALIGNMENT;
+    size_t aligned_message_size = (message_size + (alignment - 1)) & ~(alignment - 1);
+    size_t required_size;
+    tcp_spdm_binding_header_t *tcp_message_header;
+    uint8_t *buffer;
+
+    /* Determine required buffer size */
+    required_size = (session_id == NULL && message == NULL && message_size == 0) ?
+                    sizeof(tcp_spdm_binding_header_t) :
+                    sizeof(tcp_spdm_binding_header_t) + aligned_message_size;
+
+    /* Check buffer size */
+    if (*transport_message_size < required_size) {
+        *transport_message_size = required_size;
+        return LIBSPDM_STATUS_BUFFER_TOO_SMALL;
+    }
+
+    *transport_message_size = required_size;
+    buffer = (uint8_t *)*transport_message;
+
+    if (session_id == NULL && message == NULL && message_size == 0) {
path: library/spdm_transport_tcp_lib/libspdm_tcp_tcp.c
user: login: steven-bellock
body: This is a brittle way to encode this information. In particular there may be other `MessageType`s introduced. I'll need to think about this one. @jyao1 may want to think too.
created_at: 2025-04-30T22:58:17Z
author_association: CONTRIBUTOR
diff_hunk: @@ -0,0 +1,219 @@
+/**
+ *  Copyright Notice:
+ *  Copyright 2025 DMTF. All rights reserved.
+ *  License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/libspdm/blob/main/LICENSE.md
+ **/
+
+#include "library/spdm_transport_tcp_lib.h"
+#include "internal/libspdm_common_lib.h"
+#include "hal/library/memlib.h"
+#include "industry_standard/tcp.h"
+
+/**
+ * Get sequence number in an SPDM secure message.
+ *
+ * This value is transport layer specific.
+ *
+ * @param sequence_number        The current sequence number used to encode or decode message.
+ * @param sequence_number_buffer  A buffer to hold the sequence number output used in the secured message.
+ *                             The size in byte of the output buffer shall be 8.
+ *
+ * @return size in byte of the sequence_number_buffer.
+ *        It shall be no greater than 8.
+ *        0 means no sequence number is required.
+ **/
+uint8_t libspdm_tcp_get_sequence_number(uint64_t sequence_number,
+                                        uint8_t *sequence_number_buffer)
+{
+    return 0;
+}
+
+/**
+ * Return max random number count in an SPDM secure message.
+ *
+ * This value is transport layer specific.
+ *
+ * @return Max random number count in an SPDM secured message.
+ *        0 means no randum number is required.
+ **/
+uint32_t libspdm_tcp_get_max_random_number_count(void)
+{
+    return 0;
+}
+
+/**
+ * This function translates the negotiated secured_message_version to a DSP0277 version.
+ *
+ * @param  secured_message_version  The version specified in binding specification and
+ *                                  negotiated in KEY_EXCHANGE/KEY_EXCHANGE_RSP.
+ *
+ * @return The DSP0277 version specified in binding specification,
+ *         which is bound to secured_message_version.
+ */
+spdm_version_number_t libspdm_tcp_get_secured_spdm_version(
+    spdm_version_number_t secured_message_version)
+{
+    return secured_message_version;
path: library/spdm_transport_tcp_lib/libspdm_tcp_tcp.c
user: login: manojkiraneda
body: I have returned `SECURED_SPDM_VERSION_12` would that be the right way ? 
created_at: 2025-05-02T08:41:03Z
author_association: CONTRIBUTOR
diff_hunk: @@ -0,0 +1,40 @@
+/**
+ *  Copyright Notice:
+ *  Copyright 2025 DMTF. All rights reserved.
+ *  License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/libspdm/blob/main/LICENSE.md
+ **/
+
+/** @file
+ * Definitions of DSP0287 SPDM over TCP Binding Specification
+ * version 1.0.0 in Distributed Management Task Force (DMTF).
+ *
+ **/
+
+#ifndef TCP_BINDING_H
+#define TCP_BINDING_H
+
+#pragma pack(1)
+
+typedef struct {
+    uint16_t payload_length;
+    uint8_t binding_version;
+    uint8_t message_type;
+} tcp_spdm_binding_header_t;
+
+#define TCP_MESSAGE_TYPE_OUT_OF_SESSION 0x05
+#define TCP_MESSAGE_TYPE_IN_SESSION 0x06
+#define TCP_MESSAGE_TYPE_ROLE_INQUIRY 0xBF
+
+/* Error Messages*/
+#define TCP_MESSAGE_TYPE_ERROR_TOO_LARGE 0xC0
+#define TCP_MESSGAE_TYPE_ERROR_NOT_SUPPORTED 0xC1
+#define TCP_MESSAGE_TYPE_ERROR_CANNOT_OPERATE_AS_REQUESTER 0xC2
+#define TCP_MESSAGE_TYPE_ERROR_CANNOT_OPERATE_AS_RESPONDER 0xC3
+
+#define LIBSPDM_TCP_ALIGNMENT 4
path: include/industry_standard/tcp_binding.h
user: login: manojkiraneda
body: done.
created_at: 2025-05-02T08:41:12Z
author_association: CONTRIBUTOR
diff_hunk: @@ -0,0 +1,40 @@
+/**
+ *  Copyright Notice:
+ *  Copyright 2025 DMTF. All rights reserved.
+ *  License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/libspdm/blob/main/LICENSE.md
+ **/
+
+/** @file
+ * Definitions of DSP0287 SPDM over TCP Binding Specification
+ * version 1.0.0 in Distributed Management Task Force (DMTF).
+ *
+ **/
+
+#ifndef TCP_BINDING_H
+#define TCP_BINDING_H
+
+#pragma pack(1)
+
+typedef struct {
+    uint16_t payload_length;
+    uint8_t binding_version;
+    uint8_t message_type;
+} tcp_spdm_binding_header_t;
+
+#define TCP_MESSAGE_TYPE_OUT_OF_SESSION 0x05
+#define TCP_MESSAGE_TYPE_IN_SESSION 0x06
+#define TCP_MESSAGE_TYPE_ROLE_INQUIRY 0xBF
+
+/* Error Messages*/
+#define TCP_MESSAGE_TYPE_ERROR_TOO_LARGE 0xC0
+#define TCP_MESSGAE_TYPE_ERROR_NOT_SUPPORTED 0xC1
+#define TCP_MESSAGE_TYPE_ERROR_CANNOT_OPERATE_AS_REQUESTER 0xC2
+#define TCP_MESSAGE_TYPE_ERROR_CANNOT_OPERATE_AS_RESPONDER 0xC3
+
+#define LIBSPDM_TCP_ALIGNMENT 4
+#define LIBSPDM_TCP_SEQUENCE_NUMBER_COUNT 0
+#define LIBSPDM_TCP_MAX_RANDOM_NUMBER_COUNT 0
path: include/industry_standard/tcp_binding.h
user: login: manojkiraneda
body: done.
created_at: 2025-05-02T08:41:21Z
author_association: CONTRIBUTOR
diff_hunk: @@ -0,0 +1,219 @@
+/**
+ *  Copyright Notice:
+ *  Copyright 2025 DMTF. All rights reserved.
+ *  License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/libspdm/blob/main/LICENSE.md
+ **/
+
+#include "library/spdm_transport_tcp_lib.h"
+#include "internal/libspdm_common_lib.h"
+#include "hal/library/memlib.h"
+#include "industry_standard/tcp.h"
+
+/**
+ * Get sequence number in an SPDM secure message.
+ *
+ * This value is transport layer specific.
+ *
+ * @param sequence_number        The current sequence number used to encode or decode message.
+ * @param sequence_number_buffer  A buffer to hold the sequence number output used in the secured message.
+ *                             The size in byte of the output buffer shall be 8.
+ *
+ * @return size in byte of the sequence_number_buffer.
+ *        It shall be no greater than 8.
+ *        0 means no sequence number is required.
+ **/
+uint8_t libspdm_tcp_get_sequence_number(uint64_t sequence_number,
+                                        uint8_t *sequence_number_buffer)
+{
+    return 0;
+}
+
+/**
+ * Return max random number count in an SPDM secure message.
+ *
+ * This value is transport layer specific.
+ *
+ * @return Max random number count in an SPDM secured message.
+ *        0 means no randum number is required.
+ **/
+uint32_t libspdm_tcp_get_max_random_number_count(void)
+{
+    return 0;
+}
+
+/**
+ * This function translates the negotiated secured_message_version to a DSP0277 version.
+ *
+ * @param  secured_message_version  The version specified in binding specification and
+ *                                  negotiated in KEY_EXCHANGE/KEY_EXCHANGE_RSP.
+ *
+ * @return The DSP0277 version specified in binding specification,
+ *         which is bound to secured_message_version.
+ */
+spdm_version_number_t libspdm_tcp_get_secured_spdm_version(
+    spdm_version_number_t secured_message_version)
+{
+    return secured_message_version;
path: library/spdm_transport_tcp_lib/libspdm_tcp_tcp.c
user: login: manojkiraneda
body: done.
created_at: 2025-05-07T11:05:52Z
author_association: CONTRIBUTOR
diff_hunk: @@ -0,0 +1,219 @@
+/**
+ *  Copyright Notice:
+ *  Copyright 2025 DMTF. All rights reserved.
+ *  License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/libspdm/blob/main/LICENSE.md
+ **/
+
+#include "library/spdm_transport_tcp_lib.h"
+#include "internal/libspdm_common_lib.h"
+#include "hal/library/memlib.h"
+#include "industry_standard/tcp_binding.h"
+
+/**
+ * Get sequence number in an SPDM secure message.
+ *
+ * This value is transport layer specific.
+ *
+ * @param sequence_number        The current sequence number used to encode or decode message.
+ * @param sequence_number_buffer  A buffer to hold the sequence number output used in the secured message.
+ *                             The size in byte of the output buffer shall be 8.
+ *
+ * @return size in byte of the sequence_number_buffer.
+ *        It shall be no greater than 8.
+ *        0 means no sequence number is required.
+ **/
+uint8_t libspdm_tcp_get_sequence_number(uint64_t sequence_number,
+                                        uint8_t *sequence_number_buffer)
+{
+    return LIBSPDM_TCP_SEQUENCE_NUMBER_COUNT;
+}
+
+/**
+ * Return max random number count in an SPDM secure message.
+ *
+ * This value is transport layer specific.
+ *
+ * @return Max random number count in an SPDM secured message.
+ *        0 means no randum number is required.
+ **/
+uint32_t libspdm_tcp_get_max_random_number_count(void)
+{
+    return LIBSPDM_TCP_MAX_RANDOM_NUMBER_COUNT;
+}
+
+/**
+ * This function translates the negotiated secured_message_version to a DSP0277 version.
+ *
+ * @param  secured_message_version  The version specified in binding specification and
+ *                                  negotiated in KEY_EXCHANGE/KEY_EXCHANGE_RSP.
+ *
+ * @return The DSP0277 version specified in binding specification,
+ *         which is bound to secured_message_version.
+ */
+spdm_version_number_t libspdm_tcp_get_secured_spdm_version(
+    spdm_version_number_t secured_message_version)
+{
+    return secured_message_version;
+}
+
+/**
+ * Encode a normal message or secured message to a transport message.
+ *
+ * @param  session_id                    Indicates if it is a secured message protected via SPDM session.
+ *                                     If session_id is NULL, it is a normal message.
+ *                                     If session_id is NOT NULL, it is a secured message.
+ * @param  message_size                  size in bytes of the message data buffer.
+ * @param  message                      A pointer to a source buffer to store the message.
+ * @param  transport_message_size         size in bytes of the transport message data buffer.
+ * @param  transport_message             A pointer to a destination buffer to store the transport message.
+ *
+ * @retval RETURN_SUCCESS               The message is encoded successfully.
+ * @retval RETURN_INVALID_PARAMETER     The message is NULL or the message_size is zero.
+ **/
+
+libspdm_return_t libspdm_tcp_encode_message(const uint32_t *session_id,
+                                            size_t message_size,
+                                            void *message,
+                                            size_t *transport_message_size,
+                                            void **transport_message)
+{
+    size_t alignment = LIBSPDM_TCP_ALIGNMENT;
+    size_t aligned_message_size = (message_size + (alignment - 1)) & ~(alignment - 1);
+    size_t required_size;
+    tcp_spdm_binding_header_t *tcp_message_header;
+    uint8_t *buffer;
+
+    /* Determine required buffer size */
+    required_size = (session_id == NULL && message == NULL && message_size == 0) ?
+                    sizeof(tcp_spdm_binding_header_t) :
+                    sizeof(tcp_spdm_binding_header_t) + aligned_message_size;
+
+    /* Check buffer size */
+    if (*transport_message_size < required_size) {
+        *transport_message_size = required_size;
+        return LIBSPDM_STATUS_BUFFER_TOO_SMALL;
+    }
+
+    *transport_message_size = required_size;
+    buffer = (uint8_t *)*transport_message;
+
+    if (session_id == NULL && message == NULL && message_size == 0) {
path: library/spdm_transport_tcp_lib/libspdm_tcp_tcp.c
user: login: manojkiraneda
body: Sure, as suggested in the Code TF meeting, I have removed the Role Inquiry message from this PR. That will be added as part of another PR later.
created_at: 2025-05-07T11:07:15Z
author_association: CONTRIBUTOR
diff_hunk: @@ -0,0 +1,169 @@
+/**
+ *  Copyright Notice:
+ *  Copyright 2025 DMTF. All rights reserved.
+ *  License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/libspdm/blob/main/LICENSE.md
+ **/
+
+#ifndef SPDM_TCP_TRANSPORT_LIB_H
+#define SPDM_TCP_TRANSPORT_LIB_H
+
+#include "library/spdm_common_lib.h"
+
+#define LIBSPDM_TCP_ALIGNMENT 4
+
+#define LIBSPDM_TCP_SEQUENCE_NUMBER_COUNT 0
+#define LIBSPDM_TCP_MAX_RANDOM_NUMBER_COUNT 0
+
+/* Required sender/receive buffer in device io.
+ * +-------+--------+---------------------------+------+--+------+---+--------+-----+
+ * | TYPE  |TransHdr|      EncryptionHeader     |AppHdr|  |Random|MAC|AlignPad|FINAL|
+ * |       |        |SessionId|SeqNum|Len|AppLen|      |  |      |   |        |     |
+ * +-------+--------+---------------------------+------+  +------+---+--------+-----+
+ * |  TCP  |    4   |    4    |   0  | 2 |   2  |   0  |  |   0  | 16|   3    |  31 |
+ * +-------+--------+---------------------------+------+--+------+---+--------+-----+
+ */
+#define LIBSPDM_TCP_TRANSPORT_ADDITIONAL_SIZE        (12 + \
+                                                      LIBSPDM_PCI_DOE_SEQUENCE_NUMBER_COUNT + \
+                                                      LIBSPDM_PCI_DOE_MAX_RANDOM_NUMBER_COUNT + \
+                                                      LIBSPDM_MAX_AEAD_TAG_SIZE + \
+                                                      (LIBSPDM_PCI_DOE_ALIGNMENT - 1))
+
+#pragma pack(1)
+
+typedef struct {
+    uint16_t payload_length;
+    uint8_t reserved;
+    uint8_t message_type;
+} tcp_spdm_binding_header_t;
+
+#define TCP_MESSAGE_TYPE_OUT_OF_SESSION 0x01
+#define TCP_MESSAGE_TYPE_IN_SESSION 0x02
+#define TCP_MESSAGE_TYPE_HANDSHAKE_REQUEST 0x03
path: include/library/spdm_transport_tcp_lib.h
user: login: manojkiraneda
body: done.
created_at: 2025-05-07T11:07:25Z
author_association: CONTRIBUTOR
diff_hunk: @@ -0,0 +1,39 @@
+/**
+ *  Copyright Notice:
+ *  Copyright 2025 DMTF. All rights reserved.
+ *  License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/libspdm/blob/main/LICENSE.md
+ **/
+
+/** @file
+ * Definitions of DSP0287 SPDM over TCP Binding Specification
+ * version 1.0.0 in Distributed Management Task Force (DMTF).
+ *
+ **/
+
+#ifndef TCP_BINDING_H
path: include/industry_standard/tcp_binding.h
user: login: jyao1
body: I recommend we use `SPDM_TCP_*` as name space, to avoid potential naming conflict.

E.g. the file name: spdm_tcp_binding.h.
Header file macro: SPDM_TCP_BINDING_H.

created_at: 2025-05-08T02:40:11Z
author_association: MEMBER
diff_hunk: @@ -0,0 +1,39 @@
+/**
+ *  Copyright Notice:
+ *  Copyright 2025 DMTF. All rights reserved.
+ *  License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/libspdm/blob/main/LICENSE.md
+ **/
+
+/** @file
+ * Definitions of DSP0287 SPDM over TCP Binding Specification
+ * version 1.0.0 in Distributed Management Task Force (DMTF).
+ *
+ **/
+
+#ifndef TCP_BINDING_H
+#define TCP_BINDING_H
+
+#pragma pack(1)
+
+typedef struct {
+    uint16_t payload_length;
+    uint8_t binding_version;
+    uint8_t message_type;
+} tcp_spdm_binding_header_t;
path: include/industry_standard/tcp_binding.h
user: login: jyao1
body: spdm_tcp_binding_header_t
created_at: 2025-05-08T02:40:27Z
author_association: MEMBER
diff_hunk: @@ -0,0 +1,39 @@
+/**
+ *  Copyright Notice:
+ *  Copyright 2025 DMTF. All rights reserved.
+ *  License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/libspdm/blob/main/LICENSE.md
+ **/
+
+/** @file
+ * Definitions of DSP0287 SPDM over TCP Binding Specification
+ * version 1.0.0 in Distributed Management Task Force (DMTF).
+ *
+ **/
+
+#ifndef TCP_BINDING_H
+#define TCP_BINDING_H
+
+#pragma pack(1)
+
+typedef struct {
+    uint16_t payload_length;
+    uint8_t binding_version;
+    uint8_t message_type;
+} tcp_spdm_binding_header_t;
+
+#define TCP_MESSAGE_TYPE_OUT_OF_SESSION 0x05
path: include/industry_standard/tcp_binding.h
user: login: jyao1
body: SPDM_TCP_MESSAGER_*
created_at: 2025-05-08T02:40:43Z
author_association: MEMBER
diff_hunk: @@ -0,0 +1,39 @@
+/**
+ *  Copyright Notice:
+ *  Copyright 2025 DMTF. All rights reserved.
+ *  License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/libspdm/blob/main/LICENSE.md
+ **/
+
+/** @file
+ * Definitions of DSP0287 SPDM over TCP Binding Specification
+ * version 1.0.0 in Distributed Management Task Force (DMTF).
+ *
+ **/
+
+#ifndef TCP_BINDING_H
+#define TCP_BINDING_H
+
+#pragma pack(1)
+
+typedef struct {
+    uint16_t payload_length;
+    uint8_t binding_version;
+    uint8_t message_type;
+} tcp_spdm_binding_header_t;
+
+#define TCP_MESSAGE_TYPE_OUT_OF_SESSION 0x05
+#define TCP_MESSAGE_TYPE_IN_SESSION 0x06
+#define TCP_MESSAGE_TYPE_ROLE_INQUIRY 0xBF
+
+/* Error Messages*/
+#define TCP_MESSAGE_TYPE_ERROR_TOO_LARGE 0xC0
path: include/industry_standard/tcp_binding.h
user: login: jyao1
body: SPDM_TCP_MESSAGE_TYPE_ERROR_*
created_at: 2025-05-08T02:40:59Z
author_association: MEMBER
diff_hunk: @@ -0,0 +1,39 @@
+/**
+ *  Copyright Notice:
+ *  Copyright 2025 DMTF. All rights reserved.
+ *  License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/libspdm/blob/main/LICENSE.md
+ **/
+
+/** @file
+ * Definitions of DSP0287 SPDM over TCP Binding Specification
+ * version 1.0.0 in Distributed Management Task Force (DMTF).
+ *
+ **/
+
+#ifndef TCP_BINDING_H
+#define TCP_BINDING_H
+
+#pragma pack(1)
+
+typedef struct {
+    uint16_t payload_length;
+    uint8_t binding_version;
+    uint8_t message_type;
+} tcp_spdm_binding_header_t;
+
+#define TCP_MESSAGE_TYPE_OUT_OF_SESSION 0x05
+#define TCP_MESSAGE_TYPE_IN_SESSION 0x06
+#define TCP_MESSAGE_TYPE_ROLE_INQUIRY 0xBF
+
+/* Error Messages*/
+#define TCP_MESSAGE_TYPE_ERROR_TOO_LARGE 0xC0
+#define TCP_MESSGAE_TYPE_ERROR_NOT_SUPPORTED 0xC1
+#define TCP_MESSAGE_TYPE_ERROR_CANNOT_OPERATE_AS_REQUESTER 0xC2
+#define TCP_MESSAGE_TYPE_ERROR_CANNOT_OPERATE_AS_RESPONDER 0xC3
+
+#define TCP_SEQUENCE_NUMBER_COUNT 0
path: include/industry_standard/tcp_binding.h
user: login: jyao1
body: SPDM_TCP_SEQUENCE_NUMBER_COUNT 
created_at: 2025-05-08T02:41:53Z
author_association: MEMBER
diff_hunk: @@ -0,0 +1,39 @@
+/**
+ *  Copyright Notice:
+ *  Copyright 2025 DMTF. All rights reserved.
+ *  License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/libspdm/blob/main/LICENSE.md
+ **/
+
+/** @file
+ * Definitions of DSP0287 SPDM over TCP Binding Specification
+ * version 1.0.0 in Distributed Management Task Force (DMTF).
+ *
+ **/
+
+#ifndef TCP_BINDING_H
+#define TCP_BINDING_H
+
+#pragma pack(1)
+
+typedef struct {
+    uint16_t payload_length;
+    uint8_t binding_version;
+    uint8_t message_type;
+} tcp_spdm_binding_header_t;
+
+#define TCP_MESSAGE_TYPE_OUT_OF_SESSION 0x05
+#define TCP_MESSAGE_TYPE_IN_SESSION 0x06
+#define TCP_MESSAGE_TYPE_ROLE_INQUIRY 0xBF
+
+/* Error Messages*/
+#define TCP_MESSAGE_TYPE_ERROR_TOO_LARGE 0xC0
+#define TCP_MESSGAE_TYPE_ERROR_NOT_SUPPORTED 0xC1
+#define TCP_MESSAGE_TYPE_ERROR_CANNOT_OPERATE_AS_REQUESTER 0xC2
+#define TCP_MESSAGE_TYPE_ERROR_CANNOT_OPERATE_AS_RESPONDER 0xC3
+
+#define TCP_SEQUENCE_NUMBER_COUNT 0
+#define TCP_MAX_RANDOM_NUMBER_COUNT 0
path: include/industry_standard/tcp_binding.h
user: login: jyao1
body: SPDM_TCP_MAX_RANDOM_NUMBER_COUNT 
created_at: 2025-05-08T02:42:06Z
author_association: MEMBER
diff_hunk: @@ -0,0 +1,146 @@
+/**
+ *  Copyright Notice:
+ *  Copyright 2025 DMTF. All rights reserved.
+ *  License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/libspdm/blob/main/LICENSE.md
+ **/
+
+#ifndef SPDM_TCP_TRANSPORT_LIB_H
+#define SPDM_TCP_TRANSPORT_LIB_H
+
+#include "library/spdm_common_lib.h"
+
+#define LIBSPDM_TCP_ALIGNMENT 4
path: include/library/spdm_transport_tcp_lib.h
user: login: jyao1
body: Why ALIGNMENT is 4 ?
created_at: 2025-05-08T02:44:00Z
author_association: MEMBER
diff_hunk: @@ -0,0 +1,146 @@
+/**
+ *  Copyright Notice:
+ *  Copyright 2025 DMTF. All rights reserved.
+ *  License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/libspdm/blob/main/LICENSE.md
+ **/
+
+#ifndef SPDM_TCP_TRANSPORT_LIB_H
+#define SPDM_TCP_TRANSPORT_LIB_H
+
+#include "library/spdm_common_lib.h"
+
+#define LIBSPDM_TCP_ALIGNMENT 4
path: include/library/spdm_transport_tcp_lib.h
user: login: steven-bellock
body: Yes, this probably is not needed, as TCP itself has no alignment requirements.
created_at: 2025-05-11T14:26:15Z
author_association: CONTRIBUTOR
diff_hunk: @@ -0,0 +1,39 @@
+/**
+ *  Copyright Notice:
+ *  Copyright 2025 DMTF. All rights reserved.
+ *  License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/libspdm/blob/main/LICENSE.md
+ **/
+
+/** @file
+ * Definitions of DSP0287 SPDM over TCP Binding Specification
+ * version 1.0.0 in Distributed Management Task Force (DMTF).
+ *
+ **/
+
+#ifndef TCP_BINDING_H
path: include/industry_standard/tcp_binding.h
user: login: manojkiraneda
body: done.
created_at: 2025-05-22T03:47:27Z
author_association: CONTRIBUTOR
diff_hunk: @@ -0,0 +1,39 @@
+/**
+ *  Copyright Notice:
+ *  Copyright 2025 DMTF. All rights reserved.
+ *  License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/libspdm/blob/main/LICENSE.md
+ **/
+
+/** @file
+ * Definitions of DSP0287 SPDM over TCP Binding Specification
+ * version 1.0.0 in Distributed Management Task Force (DMTF).
+ *
+ **/
+
+#ifndef TCP_BINDING_H
+#define TCP_BINDING_H
+
+#pragma pack(1)
+
+typedef struct {
+    uint16_t payload_length;
+    uint8_t binding_version;
+    uint8_t message_type;
+} tcp_spdm_binding_header_t;
path: include/industry_standard/tcp_binding.h
user: login: manojkiraneda
body: done
created_at: 2025-05-22T03:47:35Z
author_association: CONTRIBUTOR
diff_hunk: @@ -0,0 +1,39 @@
+/**
+ *  Copyright Notice:
+ *  Copyright 2025 DMTF. All rights reserved.
+ *  License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/libspdm/blob/main/LICENSE.md
+ **/
+
+/** @file
+ * Definitions of DSP0287 SPDM over TCP Binding Specification
+ * version 1.0.0 in Distributed Management Task Force (DMTF).
+ *
+ **/
+
+#ifndef TCP_BINDING_H
+#define TCP_BINDING_H
+
+#pragma pack(1)
+
+typedef struct {
+    uint16_t payload_length;
+    uint8_t binding_version;
+    uint8_t message_type;
+} tcp_spdm_binding_header_t;
+
+#define TCP_MESSAGE_TYPE_OUT_OF_SESSION 0x05
path: include/industry_standard/tcp_binding.h
user: login: manojkiraneda
body: done
created_at: 2025-05-22T03:47:43Z
author_association: CONTRIBUTOR
diff_hunk: @@ -0,0 +1,39 @@
+/**
+ *  Copyright Notice:
+ *  Copyright 2025 DMTF. All rights reserved.
+ *  License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/libspdm/blob/main/LICENSE.md
+ **/
+
+/** @file
+ * Definitions of DSP0287 SPDM over TCP Binding Specification
+ * version 1.0.0 in Distributed Management Task Force (DMTF).
+ *
+ **/
+
+#ifndef TCP_BINDING_H
+#define TCP_BINDING_H
+
+#pragma pack(1)
+
+typedef struct {
+    uint16_t payload_length;
+    uint8_t binding_version;
+    uint8_t message_type;
+} tcp_spdm_binding_header_t;
+
+#define TCP_MESSAGE_TYPE_OUT_OF_SESSION 0x05
+#define TCP_MESSAGE_TYPE_IN_SESSION 0x06
+#define TCP_MESSAGE_TYPE_ROLE_INQUIRY 0xBF
+
+/* Error Messages*/
+#define TCP_MESSAGE_TYPE_ERROR_TOO_LARGE 0xC0
path: include/industry_standard/tcp_binding.h
user: login: manojkiraneda
body: done
created_at: 2025-05-22T03:47:50Z
author_association: CONTRIBUTOR
diff_hunk: @@ -0,0 +1,39 @@
+/**
+ *  Copyright Notice:
+ *  Copyright 2025 DMTF. All rights reserved.
+ *  License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/libspdm/blob/main/LICENSE.md
+ **/
+
+/** @file
+ * Definitions of DSP0287 SPDM over TCP Binding Specification
+ * version 1.0.0 in Distributed Management Task Force (DMTF).
+ *
+ **/
+
+#ifndef TCP_BINDING_H
+#define TCP_BINDING_H
+
+#pragma pack(1)
+
+typedef struct {
+    uint16_t payload_length;
+    uint8_t binding_version;
+    uint8_t message_type;
+} tcp_spdm_binding_header_t;
+
+#define TCP_MESSAGE_TYPE_OUT_OF_SESSION 0x05
+#define TCP_MESSAGE_TYPE_IN_SESSION 0x06
+#define TCP_MESSAGE_TYPE_ROLE_INQUIRY 0xBF
+
+/* Error Messages*/
+#define TCP_MESSAGE_TYPE_ERROR_TOO_LARGE 0xC0
+#define TCP_MESSGAE_TYPE_ERROR_NOT_SUPPORTED 0xC1
+#define TCP_MESSAGE_TYPE_ERROR_CANNOT_OPERATE_AS_REQUESTER 0xC2
+#define TCP_MESSAGE_TYPE_ERROR_CANNOT_OPERATE_AS_RESPONDER 0xC3
+
+#define TCP_SEQUENCE_NUMBER_COUNT 0
path: include/industry_standard/tcp_binding.h
user: login: manojkiraneda
body: done
created_at: 2025-05-22T03:47:57Z
author_association: CONTRIBUTOR
diff_hunk: @@ -0,0 +1,39 @@
+/**
+ *  Copyright Notice:
+ *  Copyright 2025 DMTF. All rights reserved.
+ *  License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/libspdm/blob/main/LICENSE.md
+ **/
+
+/** @file
+ * Definitions of DSP0287 SPDM over TCP Binding Specification
+ * version 1.0.0 in Distributed Management Task Force (DMTF).
+ *
+ **/
+
+#ifndef TCP_BINDING_H
+#define TCP_BINDING_H
+
+#pragma pack(1)
+
+typedef struct {
+    uint16_t payload_length;
+    uint8_t binding_version;
+    uint8_t message_type;
+} tcp_spdm_binding_header_t;
+
+#define TCP_MESSAGE_TYPE_OUT_OF_SESSION 0x05
+#define TCP_MESSAGE_TYPE_IN_SESSION 0x06
+#define TCP_MESSAGE_TYPE_ROLE_INQUIRY 0xBF
+
+/* Error Messages*/
+#define TCP_MESSAGE_TYPE_ERROR_TOO_LARGE 0xC0
+#define TCP_MESSGAE_TYPE_ERROR_NOT_SUPPORTED 0xC1
+#define TCP_MESSAGE_TYPE_ERROR_CANNOT_OPERATE_AS_REQUESTER 0xC2
+#define TCP_MESSAGE_TYPE_ERROR_CANNOT_OPERATE_AS_RESPONDER 0xC3
+
+#define TCP_SEQUENCE_NUMBER_COUNT 0
+#define TCP_MAX_RANDOM_NUMBER_COUNT 0
path: include/industry_standard/tcp_binding.h
user: login: manojkiraneda
body: done
created_at: 2025-05-22T03:48:03Z
author_association: CONTRIBUTOR
diff_hunk: @@ -0,0 +1,146 @@
+/**
+ *  Copyright Notice:
+ *  Copyright 2025 DMTF. All rights reserved.
+ *  License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/libspdm/blob/main/LICENSE.md
+ **/
+
+#ifndef SPDM_TCP_TRANSPORT_LIB_H
+#define SPDM_TCP_TRANSPORT_LIB_H
+
+#include "library/spdm_common_lib.h"
+
+#define LIBSPDM_TCP_ALIGNMENT 4
path: include/library/spdm_transport_tcp_lib.h
user: login: manojkiraneda
body: I tried to follow other transports & the emulator code and ended up having an alignment. But I agree that we don't need it for TCP. Removed the alignment in the latest patch set.
created_at: 2025-05-22T03:49:03Z
author_association: CONTRIBUTOR

PR comments:
user: login: steven-bellock
created_at: 2025-05-05T14:13:30Z
body: At the Monday meeting we decided that, to start, this pull request should not support Role-Inquiry Messages, since that is a corner case.
author_association: CONTRIBUTOR
user: login: jyao1
created_at: 2025-05-05T14:14:54Z
body: For DOE discover , please refer to https://github.com/DMTF/spdm-emu/blob/main/library/pci_doe_responder_lib/pci_doe_dispatch.c#L30
author_association: MEMBER
user: login: manojkiraneda
created_at: 2025-05-28T06:43:47Z
body: @jyao1 @steven-bellock - can you take a look at this PR again ? 
author_association: CONTRIBUTOR