libspdm_get_scratch_buffer_secure_message_offset:
   13|     47|uint32_t libspdm_get_scratch_buffer_secure_message_offset(libspdm_context_t *spdm_context) {
   14|     47|    return 0;
   15|     47|}
libspdm_get_scratch_buffer_secure_message_capacity:
   17|    967|uint32_t libspdm_get_scratch_buffer_secure_message_capacity(libspdm_context_t *spdm_context) {
   18|    967|    return spdm_context->local_context.capability.max_spdm_msg_size +
   19|    967|           spdm_context->local_context.capability.transport_header_size +
   20|    967|           spdm_context->local_context.capability.transport_tail_size;
   21|    967|}
libspdm_get_scratch_buffer_large_message_capacity:
   28|    920|uint32_t libspdm_get_scratch_buffer_large_message_capacity(libspdm_context_t *spdm_context) {
   29|    920|    return spdm_context->local_context.capability.max_spdm_msg_size;
   30|    920|}
libspdm_get_scratch_buffer_sender_receiver_offset:
   34|    184|uint32_t libspdm_get_scratch_buffer_sender_receiver_offset(libspdm_context_t *spdm_context) {
   35|    184|    return 0 +
   36|    184|#if LIBSPDM_ENABLE_CAPABILITY_CHUNK_CAP
   37|    184|           libspdm_get_scratch_buffer_secure_message_capacity(spdm_context) +
   38|    184|           libspdm_get_scratch_buffer_large_message_capacity(spdm_context) +
   39|    184|#endif
   40|    184|           0;
   41|    184|}
libspdm_get_scratch_buffer_sender_receiver_capacity:
   43|    828|uint32_t libspdm_get_scratch_buffer_sender_receiver_capacity(libspdm_context_t *spdm_context) {
   44|    828|    return spdm_context->local_context.capability.max_spdm_msg_size +
   45|    828|           spdm_context->local_context.capability.transport_header_size +
   46|    828|           spdm_context->local_context.capability.transport_tail_size;
   47|    828|}
libspdm_get_scratch_buffer_large_sender_receiver_offset:
   51|    460|uint32_t libspdm_get_scratch_buffer_large_sender_receiver_offset(libspdm_context_t *spdm_context) {
   52|    460|    return libspdm_get_scratch_buffer_secure_message_capacity(spdm_context) +
   53|    460|           libspdm_get_scratch_buffer_large_message_capacity(spdm_context) +
   54|    460|           libspdm_get_scratch_buffer_sender_receiver_capacity(spdm_context);
   55|    460|}
libspdm_get_scratch_buffer_large_sender_receiver_capacity:
   58|    644|{
   59|    644|    return spdm_context->local_context.capability.max_spdm_msg_size +
   60|    644|           spdm_context->local_context.capability.transport_header_size +
   61|    644|           spdm_context->local_context.capability.transport_tail_size;
   62|    644|}
libspdm_get_scratch_buffer_last_spdm_request_offset:
   66|     92|uint32_t libspdm_get_scratch_buffer_last_spdm_request_offset(libspdm_context_t *spdm_context) {
   67|     92|    return 0 +
   68|     92|#if LIBSPDM_ENABLE_CAPABILITY_CHUNK_CAP
   69|     92|           libspdm_get_scratch_buffer_secure_message_capacity(spdm_context) +
   70|     92|           libspdm_get_scratch_buffer_large_message_capacity(spdm_context) +
   71|     92|#endif
   72|     92|           libspdm_get_scratch_buffer_sender_receiver_capacity(spdm_context) +
   73|     92|#if LIBSPDM_ENABLE_CAPABILITY_CHUNK_CAP
   74|     92|           libspdm_get_scratch_buffer_large_sender_receiver_capacity(spdm_context) +
   75|     92|#endif
   76|     92|           0;
   77|     92|}
libspdm_get_scratch_buffer_last_spdm_request_capacity:
   79|    415|uint32_t libspdm_get_scratch_buffer_last_spdm_request_capacity(libspdm_context_t *spdm_context) {
   80|    415|    return spdm_context->local_context.capability.max_spdm_msg_size;
   81|    415|}
libspdm_get_scratch_buffer_cache_spdm_request_offset:
   85|     92|uint32_t libspdm_get_scratch_buffer_cache_spdm_request_offset(libspdm_context_t *spdm_context) {
   86|     92|    return 0 +
   87|     92|#if LIBSPDM_ENABLE_CAPABILITY_CHUNK_CAP
   88|     92|           libspdm_get_scratch_buffer_secure_message_capacity(spdm_context) +
   89|     92|           libspdm_get_scratch_buffer_large_message_capacity(spdm_context) +
   90|     92|#endif
   91|     92|           libspdm_get_scratch_buffer_sender_receiver_capacity(spdm_context) +
   92|     92|#if LIBSPDM_ENABLE_CAPABILITY_CHUNK_CAP
   93|     92|           libspdm_get_scratch_buffer_large_sender_receiver_capacity(spdm_context) +
   94|     92|#endif
   95|     92|           libspdm_get_scratch_buffer_last_spdm_request_capacity(spdm_context) +
   96|     92|           0;
   97|     92|}
libspdm_get_scratch_buffer_cache_spdm_request_capacity:
   99|    231|uint32_t libspdm_get_scratch_buffer_cache_spdm_request_capacity(libspdm_context_t *spdm_context) {
  100|    231|    return spdm_context->local_context.capability.max_spdm_msg_size;
  101|    231|}
libspdm_get_scratch_buffer_capacity:
  105|     92|uint32_t libspdm_get_scratch_buffer_capacity(libspdm_context_t *spdm_context) {
  106|     92|    return 0 +
  107|     92|#if LIBSPDM_ENABLE_CAPABILITY_CHUNK_CAP
  108|     92|           libspdm_get_scratch_buffer_secure_message_capacity(spdm_context) +
  109|     92|           libspdm_get_scratch_buffer_large_message_capacity(spdm_context) +
  110|     92|#endif
  111|     92|           libspdm_get_scratch_buffer_sender_receiver_capacity(spdm_context) +
  112|     92|#if LIBSPDM_ENABLE_CAPABILITY_CHUNK_CAP
  113|     92|           libspdm_get_scratch_buffer_large_sender_receiver_capacity(spdm_context) +
  114|     92|#endif
  115|     92|           libspdm_get_scratch_buffer_last_spdm_request_capacity(spdm_context) +
  116|     92|#if LIBSPDM_RESPOND_IF_READY_SUPPORT
  117|     92|           libspdm_get_scratch_buffer_cache_spdm_request_capacity(spdm_context) +
  118|     92|#endif
  119|     92|           0;
  120|     92|}
libspdm_reset_message_a:
 1260|     92|{
 1261|     92|    libspdm_reset_managed_buffer(&spdm_context->transcript.message_a);
 1262|     92|}
libspdm_reset_message_m:
 1355|     92|{
 1356|     92|    libspdm_session_info_t *spdm_session_info;
 1357|       |
 1358|     92|    spdm_session_info = session_info;
 1359|       |#if LIBSPDM_RECORD_TRANSCRIPT_DATA_SUPPORT
 1360|       |    if (spdm_session_info == NULL) {
 1361|       |        libspdm_reset_managed_buffer(&spdm_context->transcript.message_m);
 1362|       |    } else {
 1363|       |        libspdm_reset_managed_buffer(&spdm_session_info->session_transcript.message_m);
 1364|       |    }
 1365|       |#else
 1366|     92|    if (spdm_session_info == NULL) {
  ------------------
  |  Branch (1366:9): [True: 92, False: 0]
  ------------------
 1367|     92|        if (spdm_context->transcript.digest_context_l1l2 != NULL) {
  ------------------
  |  Branch (1367:13): [True: 0, False: 92]
  ------------------
 1368|      0|            libspdm_hash_free (spdm_context->connection_info.algorithm.base_hash_algo,
 1369|      0|                               spdm_context->transcript.digest_context_l1l2);
 1370|      0|            spdm_context->transcript.digest_context_l1l2 = NULL;
 1371|      0|        }
 1372|     92|    } else {
 1373|      0|        if (spdm_session_info->session_transcript.digest_context_l1l2 != NULL) {
  ------------------
  |  Branch (1373:13): [True: 0, False: 0]
  ------------------
 1374|      0|            libspdm_hash_free (spdm_context->connection_info.algorithm.base_hash_algo,
 1375|      0|                               spdm_session_info->session_transcript.digest_context_l1l2);
 1376|      0|            spdm_session_info->session_transcript.digest_context_l1l2 = NULL;
 1377|      0|        }
 1378|      0|    }
 1379|     92|#endif
 1380|     92|}
libspdm_reset_message_buffer_via_request_code:
 1533|     92|{
 1534|     92|    libspdm_context_t *spdm_context;
 1535|       |
 1536|     92|    spdm_context = context;
 1537|       |    /**
 1538|       |     * Any request other than SPDM_GET_MEASUREMENTS resets L1/L2
 1539|       |     */
 1540|     92|    if (request_code != SPDM_GET_MEASUREMENTS) {
  ------------------
  |  |   70|     92|#define SPDM_GET_MEASUREMENTS 0xE0
  ------------------
  |  Branch (1540:9): [True: 92, False: 0]
  ------------------
 1541|     92|        libspdm_reset_message_m(spdm_context, session_info);
 1542|     92|    }
 1543|       |    /**
 1544|       |     * If the Requester issued GET_MEASUREMENTS or KEY_EXCHANGE or FINISH or PSK_EXCHANGE
 1545|       |     * or PSK_FINISH or KEY_UPDATE or HEARTBEAT or GET_ENCAPSULATED_REQUEST or DELIVER_ENCAPSULATED_RESPONSE
 1546|       |     * or END_SESSION request(s) or SPDM_GET_MEASUREMENT_EXTENSION_LOG and skipped CHALLENGE completion, M1 and M2 are reset to null.
 1547|       |     */
 1548|     92|    switch (request_code)
 1549|     92|    {
 1550|      0|    case SPDM_KEY_EXCHANGE:
  ------------------
  |  |   77|      0|#define SPDM_KEY_EXCHANGE 0xE4
  ------------------
  |  Branch (1550:5): [True: 0, False: 92]
  ------------------
 1551|      0|    case SPDM_GET_MEASUREMENTS:
  ------------------
  |  |   70|      0|#define SPDM_GET_MEASUREMENTS 0xE0
  ------------------
  |  Branch (1551:5): [True: 0, False: 92]
  ------------------
 1552|      0|    case SPDM_FINISH:
  ------------------
  |  |   78|      0|#define SPDM_FINISH 0xE5
  ------------------
  |  Branch (1552:5): [True: 0, False: 92]
  ------------------
 1553|      0|    case SPDM_PSK_EXCHANGE:
  ------------------
  |  |   79|      0|#define SPDM_PSK_EXCHANGE 0xE6
  ------------------
  |  Branch (1553:5): [True: 0, False: 92]
  ------------------
 1554|      0|    case SPDM_PSK_FINISH:
  ------------------
  |  |   80|      0|#define SPDM_PSK_FINISH 0xE7
  ------------------
  |  Branch (1554:5): [True: 0, False: 92]
  ------------------
 1555|      0|    case SPDM_KEY_UPDATE:
  ------------------
  |  |   82|      0|#define SPDM_KEY_UPDATE 0xE9
  ------------------
  |  Branch (1555:5): [True: 0, False: 92]
  ------------------
 1556|      0|    case SPDM_HEARTBEAT:
  ------------------
  |  |   81|      0|#define SPDM_HEARTBEAT 0xE8
  ------------------
  |  Branch (1556:5): [True: 0, False: 92]
  ------------------
 1557|      0|    case SPDM_GET_ENCAPSULATED_REQUEST:
  ------------------
  |  |   83|      0|#define SPDM_GET_ENCAPSULATED_REQUEST 0xEA
  ------------------
  |  Branch (1557:5): [True: 0, False: 92]
  ------------------
 1558|      0|    case SPDM_END_SESSION:
  ------------------
  |  |   85|      0|#define SPDM_END_SESSION 0xEC
  ------------------
  |  Branch (1558:5): [True: 0, False: 92]
  ------------------
 1559|      0|    case SPDM_GET_MEASUREMENT_EXTENSION_LOG:
  ------------------
  |  |   98|      0|#define SPDM_GET_MEASUREMENT_EXTENSION_LOG 0xEF
  ------------------
  |  Branch (1559:5): [True: 0, False: 92]
  ------------------
 1560|      0|        if (spdm_context->connection_info.connection_state <
  ------------------
  |  Branch (1560:13): [True: 0, False: 0]
  ------------------
 1561|      0|            LIBSPDM_CONNECTION_STATE_AUTHENTICATED) {
 1562|      0|            libspdm_reset_message_b(spdm_context);
 1563|      0|            libspdm_reset_message_c(spdm_context);
 1564|      0|            libspdm_reset_message_mut_b(spdm_context);
 1565|      0|            libspdm_reset_message_mut_c(spdm_context);
 1566|      0|        }
 1567|      0|        break;
 1568|      0|    case SPDM_DELIVER_ENCAPSULATED_RESPONSE:
  ------------------
  |  |   84|      0|#define SPDM_DELIVER_ENCAPSULATED_RESPONSE 0xEB
  ------------------
  |  Branch (1568:5): [True: 0, False: 92]
  ------------------
 1569|      0|        if (spdm_context->connection_info.connection_state <
  ------------------
  |  Branch (1569:13): [True: 0, False: 0]
  ------------------
 1570|      0|            LIBSPDM_CONNECTION_STATE_AUTHENTICATED) {
 1571|      0|            libspdm_reset_message_b(spdm_context);
 1572|      0|            libspdm_reset_message_c(spdm_context);
 1573|      0|        }
 1574|      0|        break;
 1575|      0|    case SPDM_GET_DIGESTS:
  ------------------
  |  |   66|      0|#define SPDM_GET_DIGESTS 0x81
  ------------------
  |  Branch (1575:5): [True: 0, False: 92]
  ------------------
 1576|      0|        libspdm_reset_message_b(spdm_context);
 1577|      0|        break;
 1578|      0|    case SPDM_GET_ENDPOINT_INFO:
  ------------------
  |  |   94|      0|#define SPDM_GET_ENDPOINT_INFO 0x87
  ------------------
  |  Branch (1578:5): [True: 0, False: 92]
  ------------------
 1579|      0|        libspdm_reset_message_e(spdm_context, session_info);
 1580|      0|        libspdm_reset_message_encap_e(spdm_context, session_info);
 1581|      0|        break;
 1582|     92|    default:
  ------------------
  |  Branch (1582:5): [True: 92, False: 0]
  ------------------
 1583|     92|        break;
 1584|     92|    }
 1585|     92|}
libspdm_get_connection_version:
 2632|     92|{
 2633|     92|    return (uint8_t)(spdm_context->connection_info.version >> SPDM_VERSION_NUMBER_SHIFT_BIT);
  ------------------
  |  |  140|     92|#define SPDM_VERSION_NUMBER_SHIFT_BIT 8
  ------------------
 2634|     92|}
libspdm_is_capabilities_flag_supported:
 2651|     92|{
 2652|     92|    uint32_t negotiated_requester_capabilities_flag;
 2653|     92|    uint32_t negotiated_responder_capabilities_flag;
 2654|       |
 2655|     92|    if (is_requester) {
  ------------------
  |  Branch (2655:9): [True: 92, False: 0]
  ------------------
 2656|     92|        negotiated_requester_capabilities_flag = spdm_context->local_context.capability.flags;
 2657|     92|        negotiated_responder_capabilities_flag = spdm_context->connection_info.capability.flags;
 2658|     92|    } else {
 2659|      0|        negotiated_requester_capabilities_flag = spdm_context->connection_info.capability.flags;
 2660|      0|        negotiated_responder_capabilities_flag = spdm_context->local_context.capability.flags;
 2661|      0|    }
 2662|       |
 2663|     92|    if (((requester_capabilities_flag == 0) ||
  ------------------
  |  Branch (2663:10): [True: 0, False: 92]
  ------------------
 2664|     92|         ((negotiated_requester_capabilities_flag &
  ------------------
  |  Branch (2664:10): [True: 92, False: 0]
  ------------------
 2665|     92|           requester_capabilities_flag) != 0)) &&
 2666|     92|        ((responder_capabilities_flag == 0) ||
  ------------------
  |  Branch (2666:10): [True: 0, False: 92]
  ------------------
 2667|     92|         ((negotiated_responder_capabilities_flag &
  ------------------
  |  Branch (2667:10): [True: 92, False: 0]
  ------------------
 2668|     92|           responder_capabilities_flag) != 0))) {
 2669|     92|        return true;
 2670|     92|    } else {
 2671|      0|        return false;
 2672|      0|    }
 2673|     92|}
libspdm_register_device_io_func:
 2720|     92|{
 2721|     92|    libspdm_context_t *context;
 2722|       |
 2723|     92|    context = spdm_context;
 2724|     92|    context->send_message = send_message;
 2725|     92|    context->receive_message = receive_message;
 2726|     92|}
libspdm_register_device_buffer_func:
 2779|     92|{
 2780|     92|    libspdm_context_t *context;
 2781|       |
 2782|     92|    context = spdm_context;
 2783|     92|    context->sender_buffer_size = sender_buffer_size;
 2784|     92|    context->receiver_buffer_size = receiver_buffer_size;
 2785|     92|    context->acquire_sender_buffer = acquire_sender_buffer;
 2786|     92|    context->release_sender_buffer = release_sender_buffer;
 2787|     92|    context->acquire_receiver_buffer = acquire_receiver_buffer;
 2788|     92|    context->release_receiver_buffer = release_receiver_buffer;
 2789|       |
 2790|     92|    LIBSPDM_ASSERT (sender_buffer_size >=
 2791|     92|                    context->local_context.capability.transport_header_size +
 2792|     92|                    context->local_context.capability.transport_tail_size);
 2793|     92|    sender_buffer_size -= (context->local_context.capability.transport_header_size +
 2794|     92|                           context->local_context.capability.transport_tail_size);
 2795|     92|    LIBSPDM_ASSERT (sender_buffer_size >= SPDM_MIN_DATA_TRANSFER_SIZE_VERSION_12);
 2796|     92|    context->local_context.capability.sender_data_transfer_size = sender_buffer_size;
 2797|       |
 2798|     92|    LIBSPDM_ASSERT(receiver_buffer_size >=
 2799|     92|                   context->local_context.capability.transport_header_size +
 2800|     92|                   context->local_context.capability.transport_tail_size);
 2801|     92|    receiver_buffer_size -= (context->local_context.capability.transport_header_size +
 2802|     92|                             context->local_context.capability.transport_tail_size);
 2803|     92|    LIBSPDM_ASSERT (receiver_buffer_size >= SPDM_MIN_DATA_TRANSFER_SIZE_VERSION_12);
 2804|     92|    context->local_context.capability.data_transfer_size = receiver_buffer_size;
 2805|     92|}
libspdm_register_transport_layer_func:
 2823|     92|{
 2824|     92|    libspdm_context_t *context;
 2825|       |
 2826|     92|    context = spdm_context;
 2827|       |
 2828|       |    /* fix the data_transfer_size if it is set before */
 2829|     92|    if ((context->local_context.capability.data_transfer_size != 0) &&
  ------------------
  |  Branch (2829:9): [True: 0, False: 92]
  ------------------
 2830|     92|        (context->local_context.capability.data_transfer_size ==
  ------------------
  |  Branch (2830:9): [True: 0, False: 0]
  ------------------
 2831|      0|         context->receiver_buffer_size)) {
 2832|      0|        context->local_context.capability.data_transfer_size =
 2833|      0|            (uint32_t)(context->receiver_buffer_size -
 2834|      0|                       (transport_header_size + transport_tail_size));
 2835|      0|    }
 2836|     92|    if ((context->local_context.capability.sender_data_transfer_size != 0) &&
  ------------------
  |  Branch (2836:9): [True: 0, False: 92]
  ------------------
 2837|     92|        (context->local_context.capability.sender_data_transfer_size ==
  ------------------
  |  Branch (2837:9): [True: 0, False: 0]
  ------------------
 2838|      0|         context->sender_buffer_size)) {
 2839|      0|        context->local_context.capability.sender_data_transfer_size =
 2840|      0|            (uint32_t)(context->sender_buffer_size -
 2841|      0|                       (transport_header_size + transport_tail_size));
 2842|      0|    }
 2843|       |
 2844|     92|    context->local_context.capability.max_spdm_msg_size = max_spdm_msg_size;
 2845|     92|    context->local_context.capability.transport_header_size = transport_header_size;
 2846|     92|    context->local_context.capability.transport_tail_size = transport_tail_size;
 2847|     92|    context->transport_encode_message = transport_encode_message;
 2848|     92|    context->transport_decode_message = transport_decode_message;
 2849|     92|}
libspdm_get_sizeof_required_scratch_buffer:
 2886|     92|{
 2887|     92|    libspdm_context_t *context;
 2888|     92|    size_t scratch_buffer_size;
 2889|       |
 2890|     92|    context = spdm_context;
 2891|     92|    LIBSPDM_ASSERT (context->local_context.capability.max_spdm_msg_size != 0);
 2892|       |
 2893|     92|    scratch_buffer_size = libspdm_get_scratch_buffer_capacity(context);
 2894|     92|    return scratch_buffer_size;
 2895|     92|}
libspdm_set_scratch_buffer:
 2911|     92|{
 2912|     92|    libspdm_context_t *context;
 2913|       |
 2914|     92|    context = spdm_context;
 2915|     92|    LIBSPDM_ASSERT (context->local_context.capability.max_spdm_msg_size != 0);
 2916|     92|    LIBSPDM_ASSERT (scratch_buffer_size >= libspdm_get_scratch_buffer_capacity(spdm_context));
 2917|     92|    context->scratch_buffer = scratch_buffer;
 2918|     92|    context->scratch_buffer_size = scratch_buffer_size;
 2919|     92|    context->last_spdm_request = (uint8_t *)scratch_buffer +
 2920|     92|                                 libspdm_get_scratch_buffer_last_spdm_request_offset(spdm_context);
 2921|     92|#if LIBSPDM_RESPOND_IF_READY_SUPPORT
 2922|     92|    context->cache_spdm_request = (uint8_t *)scratch_buffer +
 2923|     92|                                  libspdm_get_scratch_buffer_cache_spdm_request_offset(spdm_context);
 2924|     92|#endif
 2925|     92|}
libspdm_get_scratch_buffer:
 2939|    139|{
 2940|    139|    libspdm_context_t *context;
 2941|       |
 2942|    139|    context = spdm_context;
 2943|    139|    LIBSPDM_ASSERT (context->scratch_buffer != NULL);
 2944|    139|    LIBSPDM_ASSERT (context->scratch_buffer_size >=
 2945|    139|                    libspdm_get_scratch_buffer_capacity(spdm_context));
 2946|    139|    *scratch_buffer = context->scratch_buffer;
 2947|    139|    *scratch_buffer_size = context->scratch_buffer_size;
 2948|       |    /* need to remove last 2 sections, because they are for libspdm internal state track. */
 2949|    139|    *scratch_buffer_size -= libspdm_get_scratch_buffer_last_spdm_request_capacity(spdm_context);
 2950|    139|#if LIBSPDM_RESPOND_IF_READY_SUPPORT
 2951|    139|    *scratch_buffer_size -= libspdm_get_scratch_buffer_cache_spdm_request_capacity(spdm_context);
 2952|    139|#endif
 2953|    139|}
libspdm_acquire_sender_buffer:
 2965|     92|{
 2966|     92|    libspdm_return_t status;
 2967|       |
 2968|     92|    LIBSPDM_ASSERT (spdm_context->sender_buffer == NULL);
 2969|     92|    LIBSPDM_ASSERT (spdm_context->sender_buffer_size != 0);
 2970|     92|    status = spdm_context->acquire_sender_buffer (spdm_context, msg_buf_ptr);
 2971|     92|    if (status != LIBSPDM_STATUS_SUCCESS) {
  ------------------
  |  |   59|     92|    LIBSPDM_STATUS_CONSTRUCT(LIBSPDM_SEVERITY_SUCCESS, LIBSPDM_SOURCE_SUCCESS, 0x0000)
  |  |  ------------------
  |  |  |  |   55|     92|    ((libspdm_return_t)(((severity) << 28) | ((source) << 16) | (code)))
  |  |  ------------------
  ------------------
  |  Branch (2971:9): [True: 0, False: 92]
  ------------------
 2972|      0|        return status;
 2973|      0|    }
 2974|     92|    spdm_context->sender_buffer = *msg_buf_ptr;
 2975|     92|    *max_msg_size = spdm_context->sender_buffer_size;
 2976|     92|    #if LIBSPDM_ENABLE_CAPABILITY_CHUNK_CAP
 2977|       |    /* it return scratch buffer, because the requester need build message there.*/
 2978|     92|    *msg_buf_ptr = (uint8_t *)spdm_context->scratch_buffer +
 2979|     92|                   libspdm_get_scratch_buffer_large_sender_receiver_offset(spdm_context);
 2980|     92|    *max_msg_size = libspdm_get_scratch_buffer_large_sender_receiver_capacity(spdm_context);
 2981|     92|    #endif
 2982|     92|    return LIBSPDM_STATUS_SUCCESS;
  ------------------
  |  |   59|     92|    LIBSPDM_STATUS_CONSTRUCT(LIBSPDM_SEVERITY_SUCCESS, LIBSPDM_SOURCE_SUCCESS, 0x0000)
  |  |  ------------------
  |  |  |  |   55|     92|    ((libspdm_return_t)(((severity) << 28) | ((source) << 16) | (code)))
  |  |  ------------------
  ------------------
 2983|     92|}
libspdm_release_sender_buffer:
 2993|     92|{
 2994|     92|    LIBSPDM_ASSERT(spdm_context->sender_buffer != NULL);
 2995|     92|    LIBSPDM_ASSERT(spdm_context->sender_buffer_size != 0);
 2996|       |
 2997|     92|    spdm_context->release_sender_buffer (spdm_context, spdm_context->sender_buffer);
 2998|     92|    spdm_context->sender_buffer = NULL;
 2999|     92|}
libspdm_get_sender_buffer:
 3013|     92|{
 3014|     92|    *sender_buffer = spdm_context->sender_buffer;
 3015|     92|    *sender_buffer_size = spdm_context->sender_buffer_size;
 3016|     92|}
libspdm_acquire_receiver_buffer:
 3029|     92|{
 3030|     92|    libspdm_return_t status;
 3031|       |
 3032|     92|    LIBSPDM_ASSERT (spdm_context->receiver_buffer == NULL);
 3033|     92|    LIBSPDM_ASSERT (spdm_context->receiver_buffer_size != 0);
 3034|     92|    status = spdm_context->acquire_receiver_buffer (spdm_context, msg_buf_ptr);
 3035|     92|    if (status != LIBSPDM_STATUS_SUCCESS) {
  ------------------
  |  |   59|     92|    LIBSPDM_STATUS_CONSTRUCT(LIBSPDM_SEVERITY_SUCCESS, LIBSPDM_SOURCE_SUCCESS, 0x0000)
  |  |  ------------------
  |  |  |  |   55|     92|    ((libspdm_return_t)(((severity) << 28) | ((source) << 16) | (code)))
  |  |  ------------------
  ------------------
  |  Branch (3035:9): [True: 0, False: 92]
  ------------------
 3036|      0|        return status;
 3037|      0|    }
 3038|     92|    spdm_context->receiver_buffer = *msg_buf_ptr;
 3039|     92|    *max_msg_size = spdm_context->receiver_buffer_size;
 3040|     92|    #if LIBSPDM_ENABLE_CAPABILITY_CHUNK_CAP
 3041|       |    /* it return scratch buffer, because the requester need build message there.*/
 3042|     92|    *msg_buf_ptr = (uint8_t *)spdm_context->scratch_buffer +
 3043|     92|                   libspdm_get_scratch_buffer_large_sender_receiver_offset(spdm_context);
 3044|     92|    *max_msg_size = libspdm_get_scratch_buffer_large_sender_receiver_capacity(spdm_context);
 3045|     92|    #endif
 3046|     92|    return LIBSPDM_STATUS_SUCCESS;
  ------------------
  |  |   59|     92|    LIBSPDM_STATUS_CONSTRUCT(LIBSPDM_SEVERITY_SUCCESS, LIBSPDM_SOURCE_SUCCESS, 0x0000)
  |  |  ------------------
  |  |  |  |   55|     92|    ((libspdm_return_t)(((severity) << 28) | ((source) << 16) | (code)))
  |  |  ------------------
  ------------------
 3047|     92|}
libspdm_release_receiver_buffer:
 3057|     92|{
 3058|     92|    LIBSPDM_ASSERT(spdm_context->receiver_buffer != NULL);
 3059|     92|    LIBSPDM_ASSERT(spdm_context->receiver_buffer_size != 0);
 3060|       |
 3061|     92|    spdm_context->release_receiver_buffer (spdm_context, spdm_context->receiver_buffer);
 3062|     92|    spdm_context->receiver_buffer = NULL;
 3063|     92|}
libspdm_set_last_spdm_error_struct:
 3104|     47|{
 3105|     47|    libspdm_context_t *context;
 3106|       |
 3107|     47|    context = spdm_context;
 3108|     47|    libspdm_copy_mem(&context->last_spdm_error, sizeof(context->last_spdm_error),
 3109|     47|                     last_spdm_error, sizeof(libspdm_error_struct_t));
 3110|     47|}
libspdm_init_context_with_secured_context:
 3240|     92|{
 3241|     92|    libspdm_context_t *context;
 3242|     92|    size_t index;
 3243|       |
 3244|     92|    LIBSPDM_ASSERT(spdm_context != NULL);
 3245|     92|    LIBSPDM_ASSERT(secured_contexts != NULL);
 3246|     92|    LIBSPDM_ASSERT(num_secured_contexts == LIBSPDM_MAX_SESSION_COUNT);
 3247|       |
 3248|     92|    context = spdm_context;
 3249|     92|    libspdm_zero_mem(context, sizeof(libspdm_context_t));
 3250|     92|    context->version = LIBSPDM_CONTEXT_STRUCT_VERSION;
  ------------------
  |  |  527|     92|#define LIBSPDM_CONTEXT_STRUCT_VERSION 0x3
  ------------------
 3251|     92|    context->transcript.message_a.max_buffer_size =
 3252|     92|        sizeof(context->transcript.message_a.buffer);
 3253|     92|    context->transcript.message_d.max_buffer_size =
 3254|     92|        sizeof(context->transcript.message_d.buffer);
 3255|       |#if LIBSPDM_RECORD_TRANSCRIPT_DATA_SUPPORT
 3256|       |    context->transcript.message_b.max_buffer_size =
 3257|       |        sizeof(context->transcript.message_b.buffer);
 3258|       |    context->transcript.message_c.max_buffer_size =
 3259|       |        sizeof(context->transcript.message_c.buffer);
 3260|       |    context->transcript.message_mut_b.max_buffer_size =
 3261|       |        sizeof(context->transcript.message_mut_b.buffer);
 3262|       |    context->transcript.message_mut_c.max_buffer_size =
 3263|       |        sizeof(context->transcript.message_mut_c.buffer);
 3264|       |    context->transcript.message_m.max_buffer_size =
 3265|       |        sizeof(context->transcript.message_m.buffer);
 3266|       |    context->transcript.message_e.max_buffer_size =
 3267|       |        sizeof(context->transcript.message_e.buffer);
 3268|       |    context->transcript.message_encap_e.max_buffer_size =
 3269|       |        sizeof(context->transcript.message_encap_e.buffer);
 3270|       |#endif
 3271|     92|    context->response_state = LIBSPDM_RESPONSE_STATE_NORMAL;
 3272|     92|    context->local_context.version.spdm_version_count = SPDM_MAX_VERSION_COUNT;
  ------------------
  |  |   17|     92|#define SPDM_MAX_VERSION_COUNT 4
  ------------------
 3273|     92|    context->local_context.version.spdm_version[0] = SPDM_MESSAGE_VERSION_10 <<
  ------------------
  |  |  110|     92|#define SPDM_MESSAGE_VERSION_10 0x10
  ------------------
 3274|     92|                                                     SPDM_VERSION_NUMBER_SHIFT_BIT;
  ------------------
  |  |  140|     92|#define SPDM_VERSION_NUMBER_SHIFT_BIT 8
  ------------------
 3275|     92|    context->local_context.version.spdm_version[1] = SPDM_MESSAGE_VERSION_11 <<
  ------------------
  |  |  111|     92|#define SPDM_MESSAGE_VERSION_11 0x11
  ------------------
 3276|     92|                                                     SPDM_VERSION_NUMBER_SHIFT_BIT;
  ------------------
  |  |  140|     92|#define SPDM_VERSION_NUMBER_SHIFT_BIT 8
  ------------------
 3277|     92|    context->local_context.version.spdm_version[2] = SPDM_MESSAGE_VERSION_12 <<
  ------------------
  |  |  112|     92|#define SPDM_MESSAGE_VERSION_12 0x12
  ------------------
 3278|     92|                                                     SPDM_VERSION_NUMBER_SHIFT_BIT;
  ------------------
  |  |  140|     92|#define SPDM_VERSION_NUMBER_SHIFT_BIT 8
  ------------------
 3279|     92|    context->local_context.version.spdm_version[3] = SPDM_MESSAGE_VERSION_13 <<
  ------------------
  |  |  113|     92|#define SPDM_MESSAGE_VERSION_13 0x13
  ------------------
 3280|     92|                                                     SPDM_VERSION_NUMBER_SHIFT_BIT;
  ------------------
  |  |  140|     92|#define SPDM_VERSION_NUMBER_SHIFT_BIT 8
  ------------------
 3281|     92|    context->local_context.secured_message_version.spdm_version_count =
 3282|     92|        SECURED_SPDM_MAX_VERSION_COUNT;
  ------------------
  |  |   55|     92|#define SECURED_SPDM_MAX_VERSION_COUNT 3
  ------------------
 3283|     92|    context->local_context.secured_message_version.spdm_version[0] =
 3284|     92|        SECURED_SPDM_VERSION_10 << SPDM_VERSION_NUMBER_SHIFT_BIT;
  ------------------
  |  |   57|     92|#define SECURED_SPDM_VERSION_10 0x10
  ------------------
                      SECURED_SPDM_VERSION_10 << SPDM_VERSION_NUMBER_SHIFT_BIT;
  ------------------
  |  |  140|     92|#define SPDM_VERSION_NUMBER_SHIFT_BIT 8
  ------------------
 3285|     92|    context->local_context.secured_message_version.spdm_version[1] =
 3286|     92|        SECURED_SPDM_VERSION_11 << SPDM_VERSION_NUMBER_SHIFT_BIT;
  ------------------
  |  |   58|     92|#define SECURED_SPDM_VERSION_11 0x11
  ------------------
                      SECURED_SPDM_VERSION_11 << SPDM_VERSION_NUMBER_SHIFT_BIT;
  ------------------
  |  |  140|     92|#define SPDM_VERSION_NUMBER_SHIFT_BIT 8
  ------------------
 3287|     92|    context->local_context.secured_message_version.spdm_version[2] =
 3288|     92|        SECURED_SPDM_VERSION_12 << SPDM_VERSION_NUMBER_SHIFT_BIT;
  ------------------
  |  |   59|     92|#define SECURED_SPDM_VERSION_12 0x12
  ------------------
                      SECURED_SPDM_VERSION_12 << SPDM_VERSION_NUMBER_SHIFT_BIT;
  ------------------
  |  |  140|     92|#define SPDM_VERSION_NUMBER_SHIFT_BIT 8
  ------------------
 3289|     92|    context->local_context.capability.st1 = SPDM_ST1_VALUE_US;
  ------------------
  |  | 1514|     92|#define SPDM_ST1_VALUE_US 100000
  ------------------
 3290|       |
 3291|     92|    context->mut_auth_cert_chain_buffer_size = 0;
 3292|       |
 3293|     92|    context->max_spdm_session_sequence_number = LIBSPDM_MAX_SPDM_SESSION_SEQUENCE_NUMBER;
  ------------------
  |  |   39|     92|#define LIBSPDM_MAX_SPDM_SESSION_SEQUENCE_NUMBER 0xFFFFFFFFFFFFFFFFull
  ------------------
 3294|       |
 3295|     92|    context->latest_session_id = INVALID_SESSION_ID;
  ------------------
  |  |   28|     92|#define INVALID_SESSION_ID 0
  ------------------
 3296|     92|    context->last_spdm_request_session_id = INVALID_SESSION_ID;
  ------------------
  |  |   28|     92|#define INVALID_SESSION_ID 0
  ------------------
 3297|     92|    context->last_spdm_request_session_id_valid = false;
 3298|     92|    context->last_spdm_request_size = 0;
 3299|       |
 3300|       |    /* To be updated in libspdm_register_device_buffer_func */
 3301|     92|    context->local_context.capability.data_transfer_size = 0;
 3302|     92|    context->local_context.capability.sender_data_transfer_size = 0;
 3303|     92|    context->local_context.capability.max_spdm_msg_size = 0;
 3304|       |
 3305|    460|    for (index = 0; index < num_secured_contexts; index++) {
  ------------------
  |  Branch (3305:21): [True: 368, False: 92]
  ------------------
 3306|    368|        if (secured_contexts[index] == NULL) {
  ------------------
  |  Branch (3306:13): [True: 0, False: 368]
  ------------------
 3307|      0|            return LIBSPDM_STATUS_INVALID_PARAMETER;
  ------------------
  |  |   73|      0|    LIBSPDM_STATUS_CONSTRUCT(LIBSPDM_SEVERITY_ERROR, LIBSPDM_SOURCE_CORE, 0x0001)
  |  |  ------------------
  |  |  |  |   55|      0|    ((libspdm_return_t)(((severity) << 28) | ((source) << 16) | (code)))
  |  |  ------------------
  ------------------
 3308|      0|        }
 3309|       |
 3310|    368|        context->session_info[index].secured_message_context = secured_contexts[index];
 3311|    368|        libspdm_secured_message_init_context(
 3312|    368|            context->session_info[index].secured_message_context);
 3313|    368|    }
 3314|       |
 3315|     92|    return LIBSPDM_STATUS_SUCCESS;
  ------------------
  |  |   59|     92|    LIBSPDM_STATUS_CONSTRUCT(LIBSPDM_SEVERITY_SUCCESS, LIBSPDM_SOURCE_SUCCESS, 0x0000)
  |  |  ------------------
  |  |  |  |   55|     92|    ((libspdm_return_t)(((severity) << 28) | ((source) << 16) | (code)))
  |  |  ------------------
  ------------------
 3316|     92|}
libspdm_init_context:
 3331|     92|{
 3332|     92|    libspdm_context_t *context;
 3333|     92|    void *secured_context;
 3334|     92|    void *secured_contexts[LIBSPDM_MAX_SESSION_COUNT];
 3335|     92|    size_t secured_context_size;
 3336|     92|    size_t index;
 3337|       |
 3338|     92|    LIBSPDM_ASSERT(spdm_context != NULL);
 3339|       |
 3340|       |    /* libspdm_get_context_size() allocates space for all secured message
 3341|       |     * contexts. They are appended to the general SPDM context. */
 3342|     92|    context = spdm_context;
 3343|     92|    secured_context = (void *)((size_t)(context + 1));
 3344|     92|    secured_context_size = libspdm_secured_message_get_context_size();
 3345|       |
 3346|    460|    for (index = 0; index < LIBSPDM_MAX_SESSION_COUNT; index++)
  ------------------
  |  |  198|    460|#define LIBSPDM_MAX_SESSION_COUNT 4
  ------------------
  |  Branch (3346:21): [True: 368, False: 92]
  ------------------
 3347|    368|    {
 3348|    368|        secured_contexts[index] = (uint8_t *)secured_context + secured_context_size * index;
 3349|    368|    }
 3350|       |
 3351|     92|    return libspdm_init_context_with_secured_context(spdm_context,
 3352|     92|                                                     secured_contexts,
 3353|     92|                                                     LIBSPDM_MAX_SESSION_COUNT);
  ------------------
  |  |  198|     92|#define LIBSPDM_MAX_SESSION_COUNT 4
  ------------------
 3354|     92|}
libspdm_get_context_size:
 3467|     92|{
 3468|     92|    size_t size;
 3469|       |
 3470|     92|    size = sizeof(libspdm_context_t) +
 3471|     92|           libspdm_secured_message_get_context_size() * LIBSPDM_MAX_SESSION_COUNT;
  ------------------
  |  |  198|     92|#define LIBSPDM_MAX_SESSION_COUNT 4
  ------------------
 3472|     92|    LIBSPDM_ASSERT (size == LIBSPDM_CONTEXT_SIZE_ALL);
 3473|     92|    return size;
 3474|     92|}

libspdm_get_msg_log_size:
   47|     92|{
   48|     92|    libspdm_context_t *context;
   49|       |
   50|     92|    LIBSPDM_ASSERT(spdm_context != NULL);
   51|       |
   52|     92|    context = spdm_context;
   53|       |
   54|     92|    return context->msg_log.buffer_size;
   55|     92|}
libspdm_append_msg_log:
   71|     92|{
   72|     92|    LIBSPDM_ASSERT((spdm_context != NULL) && (message != NULL));
   73|       |
   74|     92|    if (((spdm_context->msg_log.mode & LIBSPDM_MSG_LOG_MODE_ENABLE) != 0) &&
  ------------------
  |  |  174|     92|#define LIBSPDM_MSG_LOG_MODE_ENABLE 1
  ------------------
  |  Branch (74:9): [True: 0, False: 92]
  ------------------
   75|     92|        ((spdm_context->msg_log.status & LIBSPDM_MSG_LOG_STATUS_BUFFER_FULL) == 0)) {
  ------------------
  |  |  173|      0|#define LIBSPDM_MSG_LOG_STATUS_BUFFER_FULL 1
  ------------------
  |  Branch (75:9): [True: 0, False: 0]
  ------------------
   76|      0|        if (spdm_context->msg_log.buffer_size + message_size >
  ------------------
  |  Branch (76:13): [True: 0, False: 0]
  ------------------
   77|      0|            spdm_context->msg_log.max_buffer_size) {
   78|      0|            libspdm_copy_mem((uint8_t *)spdm_context->msg_log.buffer +
   79|      0|                             spdm_context->msg_log.buffer_size,
   80|      0|                             spdm_context->msg_log.max_buffer_size, message,
   81|      0|                             spdm_context->msg_log.max_buffer_size -
   82|      0|                             spdm_context->msg_log.buffer_size);
   83|      0|            spdm_context->msg_log.status |= LIBSPDM_MSG_LOG_STATUS_BUFFER_FULL;
  ------------------
  |  |  173|      0|#define LIBSPDM_MSG_LOG_STATUS_BUFFER_FULL 1
  ------------------
   84|      0|            spdm_context->msg_log.buffer_size = spdm_context->msg_log.max_buffer_size;
   85|      0|        } else {
   86|      0|            libspdm_copy_mem((uint8_t *)spdm_context->msg_log.buffer +
   87|      0|                             spdm_context->msg_log.buffer_size,
   88|      0|                             spdm_context->msg_log.max_buffer_size, message, message_size);
   89|      0|            spdm_context->msg_log.buffer_size += message_size;
   90|      0|        }
   91|       |
   92|      0|        LIBSPDM_DEBUG((LIBSPDM_DEBUG_INFO, "Message Logging Status = [%x] Buffer Size = [%zx] "
   93|      0|                       "Max Buffer Size = [%zx]\n", spdm_context->msg_log.status,
   94|      0|                       spdm_context->msg_log.buffer_size, spdm_context->msg_log.max_buffer_size));
   95|      0|        LIBSPDM_INTERNAL_DUMP_HEX(spdm_context->msg_log.buffer, spdm_context->msg_log.buffer_size);
   96|      0|    }
   97|     92|}

libspdm_reset_managed_buffer:
  283|     92|{
  284|     92|    libspdm_managed_buffer_t *managed_buffer;
  285|       |
  286|     92|    managed_buffer = m_buffer;
  287|     92|    managed_buffer->buffer_size = 0;
  288|       |
  289|     92|    libspdm_zero_mem(managed_buffer + 1, managed_buffer->max_buffer_size);
  290|     92|}

libspdm_negotiate_algorithms:
  640|     92|{
  641|     92|    size_t retry;
  642|     92|    uint64_t retry_delay_time;
  643|     92|    libspdm_return_t status;
  644|       |
  645|     92|    spdm_context->crypto_request = false;
  646|     92|    retry = spdm_context->retry_times;
  647|     92|    retry_delay_time = spdm_context->retry_delay_time;
  648|     92|    do {
  649|     92|        status = libspdm_try_negotiate_algorithms(spdm_context);
  650|     92|        if (status != LIBSPDM_STATUS_BUSY_PEER) {
  ------------------
  |  |  102|     92|    LIBSPDM_STATUS_CONSTRUCT(LIBSPDM_SEVERITY_ERROR, LIBSPDM_SOURCE_CORE, 0x0008)
  |  |  ------------------
  |  |  |  |   55|     92|    ((libspdm_return_t)(((severity) << 28) | ((source) << 16) | (code)))
  |  |  ------------------
  ------------------
  |  Branch (650:13): [True: 92, False: 0]
  ------------------
  651|     92|            return status;
  652|     92|        }
  653|       |
  654|      0|        libspdm_sleep(retry_delay_time);
  655|      0|    } while (retry-- != 0);
  ------------------
  |  Branch (655:14): [True: 0, False: 0]
  ------------------
  656|       |
  657|      0|    return status;
  658|     92|}
libspdm_req_negotiate_algorithms.c:libspdm_try_negotiate_algorithms:
   72|     92|{
   73|     92|    libspdm_return_t status;
   74|     92|    libspdm_negotiate_algorithms_request_mine_t *spdm_request;
   75|     92|    size_t spdm_request_size;
   76|     92|    libspdm_algorithms_response_max_t *spdm_response;
   77|     92|    size_t spdm_response_size;
   78|     92|    uint32_t algo_size;
   79|     92|    size_t index = 0;
   80|     92|    spdm_negotiate_algorithms_common_struct_table_t *struct_table;
   81|     92|    uint8_t fixed_alg_size;
   82|     92|    uint8_t ext_alg_count;
   83|     92|    uint8_t *message;
   84|     92|    size_t message_size;
   85|     92|    size_t transport_header_size;
   86|     92|    uint8_t alg_type_pre;
   87|     92|    uint8_t req_param1 = 0;
   88|       |
   89|       |    /* -=[Verify State Phase]=- */
   90|     92|    if (spdm_context->connection_info.connection_state !=
  ------------------
  |  Branch (90:9): [True: 0, False: 92]
  ------------------
   91|     92|        LIBSPDM_CONNECTION_STATE_AFTER_CAPABILITIES) {
   92|      0|        return LIBSPDM_STATUS_INVALID_STATE_LOCAL;
  ------------------
  |  |   82|      0|    LIBSPDM_STATUS_CONSTRUCT(LIBSPDM_SEVERITY_ERROR, LIBSPDM_SOURCE_CORE, 0x0003)
  |  |  ------------------
  |  |  |  |   55|      0|    ((libspdm_return_t)(((severity) << 28) | ((source) << 16) | (code)))
  |  |  ------------------
  ------------------
   93|      0|    }
   94|       |
   95|     92|    libspdm_reset_message_buffer_via_request_code(spdm_context, NULL, SPDM_NEGOTIATE_ALGORITHMS);
  ------------------
  |  |   72|     92|#define SPDM_NEGOTIATE_ALGORITHMS 0xE3
  ------------------
   96|       |
   97|       |    /* -=[Construct Request Phase]=- */
   98|     92|    transport_header_size = spdm_context->local_context.capability.transport_header_size;
   99|     92|    status = libspdm_acquire_sender_buffer (spdm_context, &message_size, (void **)&message);
  100|     92|    if (LIBSPDM_STATUS_IS_ERROR(status)) {
  ------------------
  |  |   30|     92|    (LIBSPDM_STATUS_SEVERITY(status) == LIBSPDM_SEVERITY_ERROR)
  |  |  ------------------
  |  |  |  |   37|     92|#define LIBSPDM_STATUS_SEVERITY(status) (((status) >> 28) & 0xf)
  |  |  ------------------
  |  |                   (LIBSPDM_STATUS_SEVERITY(status) == LIBSPDM_SEVERITY_ERROR)
  |  |  ------------------
  |  |  |  |   44|     92|#define LIBSPDM_SEVERITY_ERROR 0x8
  |  |  ------------------
  |  |  |  Branch (30:5): [True: 0, False: 92]
  |  |  ------------------
  ------------------
  101|      0|        return status;
  102|      0|    }
  103|     92|    LIBSPDM_ASSERT (message_size >= transport_header_size +
  104|     92|                    spdm_context->local_context.capability.transport_tail_size);
  105|     92|    spdm_request = (void *)(message + transport_header_size);
  106|     92|    spdm_request_size = message_size - transport_header_size -
  107|     92|                        spdm_context->local_context.capability.transport_tail_size;
  108|       |
  109|     92|    LIBSPDM_ASSERT(spdm_request_size >= sizeof(spdm_negotiate_algorithms_request_t));
  110|     92|    libspdm_zero_mem(spdm_request, spdm_request_size);
  111|     92|    spdm_request->header.spdm_version = libspdm_get_connection_version (spdm_context);
  112|     92|    if (spdm_request->header.spdm_version >= SPDM_MESSAGE_VERSION_11) {
  ------------------
  |  |  111|     92|#define SPDM_MESSAGE_VERSION_11 0x11
  ------------------
  |  Branch (112:9): [True: 92, False: 0]
  ------------------
  113|       |        /* Number of Algorithms Structure Tables based on supported algorithms */
  114|     92|        if (spdm_context->local_context.algorithm.dhe_named_group != 0) {
  ------------------
  |  Branch (114:13): [True: 0, False: 92]
  ------------------
  115|      0|            req_param1++;
  116|      0|        }
  117|     92|        if (spdm_context->local_context.algorithm.aead_cipher_suite != 0) {
  ------------------
  |  Branch (117:13): [True: 0, False: 92]
  ------------------
  118|      0|            req_param1++;
  119|      0|        }
  120|     92|        if (spdm_context->local_context.algorithm.req_base_asym_alg != 0) {
  ------------------
  |  Branch (120:13): [True: 0, False: 92]
  ------------------
  121|      0|            req_param1++;
  122|      0|        }
  123|     92|        if (spdm_context->local_context.algorithm.key_schedule != 0) {
  ------------------
  |  Branch (123:13): [True: 0, False: 92]
  ------------------
  124|      0|            req_param1++;
  125|      0|        }
  126|     92|        LIBSPDM_ASSERT(req_param1 <=
  127|     92|                       SPDM_NEGOTIATE_ALGORITHMS_MAX_NUM_STRUCT_TABLE_ALG);
  128|     92|        spdm_request->header.param1 = req_param1;
  129|     92|        spdm_request->length = sizeof(libspdm_negotiate_algorithms_request_mine_t) -
  130|     92|                               ((SPDM_NEGOTIATE_ALGORITHMS_MAX_NUM_STRUCT_TABLE_ALG  -
  ------------------
  |  |  348|     92|#define SPDM_NEGOTIATE_ALGORITHMS_MAX_NUM_STRUCT_TABLE_ALG 4
  ------------------
  131|     92|                                 req_param1) *
  132|     92|                                sizeof(spdm_negotiate_algorithms_common_struct_table_t));
  133|     92|    } else {
  134|      0|        spdm_request->length = sizeof(libspdm_negotiate_algorithms_request_mine_t) -
  135|      0|                               sizeof(spdm_request->struct_table);
  136|      0|        spdm_request->header.param1 = 0;
  137|      0|    }
  138|       |
  139|     92|    LIBSPDM_ASSERT(spdm_request_size >= spdm_request->length);
  140|     92|    spdm_request->header.request_response_code = SPDM_NEGOTIATE_ALGORITHMS;
  ------------------
  |  |   72|     92|#define SPDM_NEGOTIATE_ALGORITHMS 0xE3
  ------------------
  141|     92|    spdm_request->header.param2 = 0;
  142|     92|    spdm_request->measurement_specification =
  143|     92|        spdm_context->local_context.algorithm.measurement_spec;
  144|     92|    if (spdm_request->header.spdm_version >= SPDM_MESSAGE_VERSION_12) {
  ------------------
  |  |  112|     92|#define SPDM_MESSAGE_VERSION_12 0x12
  ------------------
  |  Branch (144:9): [True: 92, False: 0]
  ------------------
  145|     92|        spdm_request->other_params_support =
  146|     92|            spdm_context->local_context.algorithm.other_params_support &
  147|     92|            SPDM_ALGORITHMS_OPAQUE_DATA_FORMAT_MASK;
  ------------------
  |  |  476|     92|#define SPDM_ALGORITHMS_OPAQUE_DATA_FORMAT_MASK 0xF
  ------------------
  148|     92|        if (spdm_request->header.spdm_version >= SPDM_MESSAGE_VERSION_13) {
  ------------------
  |  |  113|     92|#define SPDM_MESSAGE_VERSION_13 0x13
  ------------------
  |  Branch (148:13): [True: 0, False: 92]
  ------------------
  149|      0|            spdm_request->other_params_support =
  150|      0|                spdm_context->local_context.algorithm.other_params_support;
  151|      0|            spdm_request->mel_specification =
  152|      0|                spdm_context->local_context.algorithm.mel_spec;
  153|      0|        }
  154|     92|    }
  155|     92|    if (spdm_request->header.spdm_version >= SPDM_MESSAGE_VERSION_13) {
  ------------------
  |  |  113|     92|#define SPDM_MESSAGE_VERSION_13 0x13
  ------------------
  |  Branch (155:9): [True: 0, False: 92]
  ------------------
  156|      0|        switch (spdm_context->connection_info.capability.flags &
  157|      0|                SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MULTI_KEY_CAP) {
  ------------------
  |  |  295|      0|#define SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MULTI_KEY_CAP (0x04000000 | 0x08000000)
  ------------------
  158|      0|        case 0:
  ------------------
  |  Branch (158:9): [True: 0, False: 0]
  ------------------
  159|      0|            spdm_context->connection_info.multi_key_conn_rsp = false;
  160|      0|            break;
  161|      0|        case SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MULTI_KEY_CAP_ONLY:
  ------------------
  |  |  296|      0|#define SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MULTI_KEY_CAP_ONLY 0x04000000
  ------------------
  |  Branch (161:9): [True: 0, False: 0]
  ------------------
  162|      0|            spdm_context->connection_info.multi_key_conn_rsp = true;
  163|      0|            break;
  164|      0|        case SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MULTI_KEY_CAP_NEG:
  ------------------
  |  |  297|      0|#define SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MULTI_KEY_CAP_NEG 0x08000000
  ------------------
  |  Branch (164:9): [True: 0, False: 0]
  ------------------
  165|      0|            if ((spdm_context->local_context.algorithm.other_params_support &
  ------------------
  |  Branch (165:17): [True: 0, False: 0]
  ------------------
  166|      0|                 SPDM_ALGORITHMS_MULTI_KEY_CONN) == 0) {
  ------------------
  |  |  478|      0|#define SPDM_ALGORITHMS_MULTI_KEY_CONN 0x10
  ------------------
  167|      0|                spdm_context->connection_info.multi_key_conn_rsp = false;
  168|      0|            } else {
  169|      0|                spdm_context->connection_info.multi_key_conn_rsp = true;
  170|      0|            }
  171|      0|            break;
  172|      0|        default:
  ------------------
  |  Branch (172:9): [True: 0, False: 0]
  ------------------
  173|      0|            return LIBSPDM_STATUS_INVALID_MSG_FIELD;
  ------------------
  |  |   90|      0|    LIBSPDM_STATUS_CONSTRUCT(LIBSPDM_SEVERITY_ERROR, LIBSPDM_SOURCE_CORE, 0x0005)
  |  |  ------------------
  |  |  |  |   55|      0|    ((libspdm_return_t)(((severity) << 28) | ((source) << 16) | (code)))
  |  |  ------------------
  ------------------
  174|      0|        }
  175|      0|        if (spdm_context->connection_info.multi_key_conn_rsp) {
  ------------------
  |  Branch (175:13): [True: 0, False: 0]
  ------------------
  176|      0|            spdm_request->other_params_support |= SPDM_ALGORITHMS_MULTI_KEY_CONN;
  ------------------
  |  |  478|      0|#define SPDM_ALGORITHMS_MULTI_KEY_CONN 0x10
  ------------------
  177|      0|        } else {
  178|      0|            spdm_request->other_params_support &= ~SPDM_ALGORITHMS_MULTI_KEY_CONN;
  ------------------
  |  |  478|      0|#define SPDM_ALGORITHMS_MULTI_KEY_CONN 0x10
  ------------------
  179|      0|        }
  180|      0|    }
  181|     92|    spdm_request->base_asym_algo = spdm_context->local_context.algorithm.base_asym_algo;
  182|     92|    spdm_request->base_hash_algo = spdm_context->local_context.algorithm.base_hash_algo;
  183|     92|    spdm_request->ext_asym_count = 0;
  184|     92|    spdm_request->ext_hash_count = 0;
  185|     92|    if (spdm_request->header.spdm_version >= SPDM_MESSAGE_VERSION_11) {
  ------------------
  |  |  111|     92|#define SPDM_MESSAGE_VERSION_11 0x11
  ------------------
  |  Branch (185:9): [True: 92, False: 0]
  ------------------
  186|       |        /* ReqAlgStruct order based on by AlgType */
  187|     92|        if (spdm_context->local_context.algorithm.dhe_named_group) {
  ------------------
  |  Branch (187:13): [True: 0, False: 92]
  ------------------
  188|      0|            spdm_request->struct_table[index].alg_type =
  189|      0|                SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_DHE;
  ------------------
  |  |  349|      0|#define SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_DHE 2
  ------------------
  190|      0|            spdm_request->struct_table[index].alg_count = 0x20;
  191|      0|            spdm_request->struct_table[index].alg_supported =
  192|      0|                spdm_context->local_context.algorithm.dhe_named_group;
  193|      0|            index++;
  194|      0|        }
  195|     92|        if (spdm_context->local_context.algorithm.aead_cipher_suite) {
  ------------------
  |  Branch (195:13): [True: 0, False: 92]
  ------------------
  196|      0|            spdm_request->struct_table[index].alg_type =
  197|      0|                SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_AEAD;
  ------------------
  |  |  350|      0|#define SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_AEAD 3
  ------------------
  198|      0|            spdm_request->struct_table[index].alg_count = 0x20;
  199|      0|            spdm_request->struct_table[index].alg_supported =
  200|      0|                spdm_context->local_context.algorithm.aead_cipher_suite;
  201|      0|            index++;
  202|      0|        }
  203|     92|        if (spdm_context->local_context.algorithm.req_base_asym_alg) {
  ------------------
  |  Branch (203:13): [True: 0, False: 92]
  ------------------
  204|      0|            spdm_request->struct_table[index].alg_type =
  205|      0|                SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_REQ_BASE_ASYM_ALG;
  ------------------
  |  |  351|      0|#define SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_REQ_BASE_ASYM_ALG 4
  ------------------
  206|      0|            spdm_request->struct_table[index].alg_count = 0x20;
  207|      0|            spdm_request->struct_table[index].alg_supported =
  208|      0|                spdm_context->local_context.algorithm.req_base_asym_alg;
  209|      0|            index++;
  210|      0|        }
  211|     92|        if (spdm_context->local_context.algorithm.key_schedule) {
  ------------------
  |  Branch (211:13): [True: 0, False: 92]
  ------------------
  212|      0|            spdm_request->struct_table[index].alg_type =
  213|      0|                SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_KEY_SCHEDULE;
  ------------------
  |  |  352|      0|#define SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_KEY_SCHEDULE 5
  ------------------
  214|      0|            spdm_request->struct_table[index].alg_count = 0x20;
  215|      0|            spdm_request->struct_table[index].alg_supported =
  216|      0|                spdm_context->local_context.algorithm.key_schedule;
  217|      0|            index++;
  218|      0|        }
  219|     92|        LIBSPDM_ASSERT(index == spdm_request->header.param1);
  220|     92|    }
  221|     92|    spdm_request_size = spdm_request->length;
  222|       |
  223|       |    /* -=[Send Request Phase]=- */
  224|     92|    status = libspdm_send_spdm_request(spdm_context, NULL, spdm_request_size, spdm_request);
  225|     92|    if (LIBSPDM_STATUS_IS_ERROR(status)) {
  ------------------
  |  |   30|     92|    (LIBSPDM_STATUS_SEVERITY(status) == LIBSPDM_SEVERITY_ERROR)
  |  |  ------------------
  |  |  |  |   37|     92|#define LIBSPDM_STATUS_SEVERITY(status) (((status) >> 28) & 0xf)
  |  |  ------------------
  |  |                   (LIBSPDM_STATUS_SEVERITY(status) == LIBSPDM_SEVERITY_ERROR)
  |  |  ------------------
  |  |  |  |   44|     92|#define LIBSPDM_SEVERITY_ERROR 0x8
  |  |  ------------------
  |  |  |  Branch (30:5): [True: 0, False: 92]
  |  |  ------------------
  ------------------
  226|      0|        libspdm_release_sender_buffer (spdm_context);
  227|      0|        return status;
  228|      0|    }
  229|     92|    libspdm_release_sender_buffer (spdm_context);
  230|     92|    spdm_request = (void *)spdm_context->last_spdm_request;
  231|       |
  232|       |    /* -=[Receive Response Phase]=- */
  233|     92|    status = libspdm_acquire_receiver_buffer (spdm_context, &message_size, (void **)&message);
  234|     92|    if (LIBSPDM_STATUS_IS_ERROR(status)) {
  ------------------
  |  |   30|     92|    (LIBSPDM_STATUS_SEVERITY(status) == LIBSPDM_SEVERITY_ERROR)
  |  |  ------------------
  |  |  |  |   37|     92|#define LIBSPDM_STATUS_SEVERITY(status) (((status) >> 28) & 0xf)
  |  |  ------------------
  |  |                   (LIBSPDM_STATUS_SEVERITY(status) == LIBSPDM_SEVERITY_ERROR)
  |  |  ------------------
  |  |  |  |   44|     92|#define LIBSPDM_SEVERITY_ERROR 0x8
  |  |  ------------------
  |  |  |  Branch (30:5): [True: 0, False: 92]
  |  |  ------------------
  ------------------
  235|      0|        return status;
  236|      0|    }
  237|     92|    LIBSPDM_ASSERT (message_size >= transport_header_size);
  238|     92|    spdm_response = (void *)(message);
  239|     92|    spdm_response_size = message_size;
  240|       |
  241|     92|    status = libspdm_receive_spdm_response(spdm_context, NULL, &spdm_response_size,
  242|     92|                                           (void **)&spdm_response);
  243|     92|    if (LIBSPDM_STATUS_IS_ERROR(status)) {
  ------------------
  |  |   30|     92|    (LIBSPDM_STATUS_SEVERITY(status) == LIBSPDM_SEVERITY_ERROR)
  |  |  ------------------
  |  |  |  |   37|     92|#define LIBSPDM_STATUS_SEVERITY(status) (((status) >> 28) & 0xf)
  |  |  ------------------
  |  |                   (LIBSPDM_STATUS_SEVERITY(status) == LIBSPDM_SEVERITY_ERROR)
  |  |  ------------------
  |  |  |  |   44|     92|#define LIBSPDM_SEVERITY_ERROR 0x8
  |  |  ------------------
  |  |  |  Branch (30:5): [True: 45, False: 47]
  |  |  ------------------
  ------------------
  244|     45|        goto receive_done;
  245|     45|    }
  246|       |
  247|       |    /* -=[Validate Response Phase]=- */
  248|     47|    if (spdm_response_size < sizeof(spdm_message_header_t)) {
  ------------------
  |  Branch (248:9): [True: 0, False: 47]
  ------------------
  249|      0|        status = LIBSPDM_STATUS_INVALID_MSG_SIZE;
  ------------------
  |  |   94|      0|    LIBSPDM_STATUS_CONSTRUCT(LIBSPDM_SEVERITY_ERROR, LIBSPDM_SOURCE_CORE, 0x0006)
  |  |  ------------------
  |  |  |  |   55|      0|    ((libspdm_return_t)(((severity) << 28) | ((source) << 16) | (code)))
  |  |  ------------------
  ------------------
  250|      0|        goto receive_done;
  251|      0|    }
  252|     47|    if (spdm_response->header.spdm_version != spdm_request->header.spdm_version) {
  ------------------
  |  Branch (252:9): [True: 47, False: 0]
  ------------------
  253|     47|        status = LIBSPDM_STATUS_INVALID_MSG_FIELD;
  ------------------
  |  |   90|     47|    LIBSPDM_STATUS_CONSTRUCT(LIBSPDM_SEVERITY_ERROR, LIBSPDM_SOURCE_CORE, 0x0005)
  |  |  ------------------
  |  |  |  |   55|     47|    ((libspdm_return_t)(((severity) << 28) | ((source) << 16) | (code)))
  |  |  ------------------
  ------------------
  254|     47|        goto receive_done;
  255|     47|    }
  256|      0|    if (spdm_response->header.request_response_code == SPDM_ERROR) {
  ------------------
  |  |   37|      0|#define SPDM_ERROR 0x7F
  ------------------
  |  Branch (256:9): [True: 0, False: 0]
  ------------------
  257|      0|        status = libspdm_handle_simple_error_response(spdm_context, spdm_response->header.param1);
  258|      0|        if (LIBSPDM_STATUS_IS_ERROR(status)) {
  ------------------
  |  |   30|      0|    (LIBSPDM_STATUS_SEVERITY(status) == LIBSPDM_SEVERITY_ERROR)
  |  |  ------------------
  |  |  |  |   37|      0|#define LIBSPDM_STATUS_SEVERITY(status) (((status) >> 28) & 0xf)
  |  |  ------------------
  |  |                   (LIBSPDM_STATUS_SEVERITY(status) == LIBSPDM_SEVERITY_ERROR)
  |  |  ------------------
  |  |  |  |   44|      0|#define LIBSPDM_SEVERITY_ERROR 0x8
  |  |  ------------------
  |  |  |  Branch (30:5): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  259|      0|            goto receive_done;
  260|      0|        }
  261|      0|    } else if (spdm_response->header.request_response_code != SPDM_ALGORITHMS) {
  ------------------
  |  |   35|      0|#define SPDM_ALGORITHMS 0x63
  ------------------
  |  Branch (261:16): [True: 0, False: 0]
  ------------------
  262|      0|        status = LIBSPDM_STATUS_INVALID_MSG_FIELD;
  ------------------
  |  |   90|      0|    LIBSPDM_STATUS_CONSTRUCT(LIBSPDM_SEVERITY_ERROR, LIBSPDM_SOURCE_CORE, 0x0005)
  |  |  ------------------
  |  |  |  |   55|      0|    ((libspdm_return_t)(((severity) << 28) | ((source) << 16) | (code)))
  |  |  ------------------
  ------------------
  263|      0|        goto receive_done;
  264|      0|    }
  265|      0|    if (spdm_response_size < sizeof(spdm_algorithms_response_t)) {
  ------------------
  |  Branch (265:9): [True: 0, False: 0]
  ------------------
  266|      0|        status = LIBSPDM_STATUS_INVALID_MSG_SIZE;
  ------------------
  |  |   94|      0|    LIBSPDM_STATUS_CONSTRUCT(LIBSPDM_SEVERITY_ERROR, LIBSPDM_SOURCE_CORE, 0x0006)
  |  |  ------------------
  |  |  |  |   55|      0|    ((libspdm_return_t)(((severity) << 28) | ((source) << 16) | (code)))
  |  |  ------------------
  ------------------
  267|      0|        goto receive_done;
  268|      0|    }
  269|      0|    if (!libspdm_onehot0(spdm_response->measurement_specification_sel)) {
  ------------------
  |  Branch (269:9): [True: 0, False: 0]
  ------------------
  270|      0|        status = LIBSPDM_STATUS_INVALID_MSG_FIELD;
  ------------------
  |  |   90|      0|    LIBSPDM_STATUS_CONSTRUCT(LIBSPDM_SEVERITY_ERROR, LIBSPDM_SOURCE_CORE, 0x0005)
  |  |  ------------------
  |  |  |  |   55|      0|    ((libspdm_return_t)(((severity) << 28) | ((source) << 16) | (code)))
  |  |  ------------------
  ------------------
  271|      0|        goto receive_done;
  272|      0|    }
  273|      0|    if (spdm_request->header.spdm_version >= SPDM_MESSAGE_VERSION_12) {
  ------------------
  |  |  112|      0|#define SPDM_MESSAGE_VERSION_12 0x12
  ------------------
  |  Branch (273:9): [True: 0, False: 0]
  ------------------
  274|      0|        if (!libspdm_onehot0(spdm_response->other_params_selection &
  ------------------
  |  Branch (274:13): [True: 0, False: 0]
  ------------------
  275|      0|                             SPDM_ALGORITHMS_OPAQUE_DATA_FORMAT_MASK)) {
  ------------------
  |  |  476|      0|#define SPDM_ALGORITHMS_OPAQUE_DATA_FORMAT_MASK 0xF
  ------------------
  276|      0|            status = LIBSPDM_STATUS_INVALID_MSG_FIELD;
  ------------------
  |  |   90|      0|    LIBSPDM_STATUS_CONSTRUCT(LIBSPDM_SEVERITY_ERROR, LIBSPDM_SOURCE_CORE, 0x0005)
  |  |  ------------------
  |  |  |  |   55|      0|    ((libspdm_return_t)(((severity) << 28) | ((source) << 16) | (code)))
  |  |  ------------------
  ------------------
  277|      0|            goto receive_done;
  278|      0|        }
  279|      0|    }
  280|      0|    if (!libspdm_onehot0(spdm_response->measurement_hash_algo)) {
  ------------------
  |  Branch (280:9): [True: 0, False: 0]
  ------------------
  281|      0|        status = LIBSPDM_STATUS_INVALID_MSG_FIELD;
  ------------------
  |  |   90|      0|    LIBSPDM_STATUS_CONSTRUCT(LIBSPDM_SEVERITY_ERROR, LIBSPDM_SOURCE_CORE, 0x0005)
  |  |  ------------------
  |  |  |  |   55|      0|    ((libspdm_return_t)(((severity) << 28) | ((source) << 16) | (code)))
  |  |  ------------------
  ------------------
  282|      0|        goto receive_done;
  283|      0|    }
  284|      0|    if (!libspdm_onehot0(spdm_response->base_asym_sel)) {
  ------------------
  |  Branch (284:9): [True: 0, False: 0]
  ------------------
  285|      0|        status = LIBSPDM_STATUS_INVALID_MSG_FIELD;
  ------------------
  |  |   90|      0|    LIBSPDM_STATUS_CONSTRUCT(LIBSPDM_SEVERITY_ERROR, LIBSPDM_SOURCE_CORE, 0x0005)
  |  |  ------------------
  |  |  |  |   55|      0|    ((libspdm_return_t)(((severity) << 28) | ((source) << 16) | (code)))
  |  |  ------------------
  ------------------
  286|      0|        goto receive_done;
  287|      0|    }
  288|      0|    if (!libspdm_onehot0(spdm_response->base_hash_sel)) {
  ------------------
  |  Branch (288:9): [True: 0, False: 0]
  ------------------
  289|      0|        status = LIBSPDM_STATUS_INVALID_MSG_FIELD;
  ------------------
  |  |   90|      0|    LIBSPDM_STATUS_CONSTRUCT(LIBSPDM_SEVERITY_ERROR, LIBSPDM_SOURCE_CORE, 0x0005)
  |  |  ------------------
  |  |  |  |   55|      0|    ((libspdm_return_t)(((severity) << 28) | ((source) << 16) | (code)))
  |  |  ------------------
  ------------------
  290|      0|        goto receive_done;
  291|      0|    }
  292|      0|    if (spdm_response->ext_asym_sel_count > 0) {
  ------------------
  |  Branch (292:9): [True: 0, False: 0]
  ------------------
  293|      0|        status = LIBSPDM_STATUS_INVALID_MSG_FIELD;
  ------------------
  |  |   90|      0|    LIBSPDM_STATUS_CONSTRUCT(LIBSPDM_SEVERITY_ERROR, LIBSPDM_SOURCE_CORE, 0x0005)
  |  |  ------------------
  |  |  |  |   55|      0|    ((libspdm_return_t)(((severity) << 28) | ((source) << 16) | (code)))
  |  |  ------------------
  ------------------
  294|      0|        goto receive_done;
  295|      0|    }
  296|      0|    if (spdm_response->ext_hash_sel_count > 0) {
  ------------------
  |  Branch (296:9): [True: 0, False: 0]
  ------------------
  297|      0|        status = LIBSPDM_STATUS_INVALID_MSG_FIELD;
  ------------------
  |  |   90|      0|    LIBSPDM_STATUS_CONSTRUCT(LIBSPDM_SEVERITY_ERROR, LIBSPDM_SOURCE_CORE, 0x0005)
  |  |  ------------------
  |  |  |  |   55|      0|    ((libspdm_return_t)(((severity) << 28) | ((source) << 16) | (code)))
  |  |  ------------------
  ------------------
  298|      0|        goto receive_done;
  299|      0|    }
  300|      0|    if (spdm_response_size <
  ------------------
  |  Branch (300:9): [True: 0, False: 0]
  ------------------
  301|      0|        sizeof(spdm_algorithms_response_t) +
  302|      0|        sizeof(uint32_t) * spdm_response->ext_asym_sel_count +
  303|      0|        sizeof(uint32_t) * spdm_response->ext_hash_sel_count +
  304|      0|        sizeof(spdm_negotiate_algorithms_common_struct_table_t) * spdm_response->header.param1) {
  305|      0|        status = LIBSPDM_STATUS_INVALID_MSG_SIZE;
  ------------------
  |  |   94|      0|    LIBSPDM_STATUS_CONSTRUCT(LIBSPDM_SEVERITY_ERROR, LIBSPDM_SOURCE_CORE, 0x0006)
  |  |  ------------------
  |  |  |  |   55|      0|    ((libspdm_return_t)(((severity) << 28) | ((source) << 16) | (code)))
  |  |  ------------------
  ------------------
  306|      0|        goto receive_done;
  307|      0|    }
  308|      0|    struct_table =
  309|      0|        (void *)((size_t)spdm_response +
  310|      0|                 sizeof(spdm_algorithms_response_t) +
  311|      0|                 sizeof(uint32_t) * spdm_response->ext_asym_sel_count +
  312|      0|                 sizeof(uint32_t) * spdm_response->ext_hash_sel_count);
  313|      0|    if (spdm_response->header.spdm_version >= SPDM_MESSAGE_VERSION_11) {
  ------------------
  |  |  111|      0|#define SPDM_MESSAGE_VERSION_11 0x11
  ------------------
  |  Branch (313:9): [True: 0, False: 0]
  ------------------
  314|      0|        alg_type_pre = struct_table->alg_type;
  315|       |        /* header.param1 is implicitly checked through spdm_response_size. */
  316|      0|        for (index = 0; index < spdm_response->header.param1; index++) {
  ------------------
  |  Branch (316:25): [True: 0, False: 0]
  ------------------
  317|      0|            if ((size_t)spdm_response + spdm_response_size < (size_t)struct_table) {
  ------------------
  |  Branch (317:17): [True: 0, False: 0]
  ------------------
  318|      0|                status = LIBSPDM_STATUS_INVALID_MSG_SIZE;
  ------------------
  |  |   94|      0|    LIBSPDM_STATUS_CONSTRUCT(LIBSPDM_SEVERITY_ERROR, LIBSPDM_SOURCE_CORE, 0x0006)
  |  |  ------------------
  |  |  |  |   55|      0|    ((libspdm_return_t)(((severity) << 28) | ((source) << 16) | (code)))
  |  |  ------------------
  ------------------
  319|      0|                goto receive_done;
  320|      0|            }
  321|      0|            if ((size_t)spdm_response + spdm_response_size - (size_t)struct_table <
  ------------------
  |  Branch (321:17): [True: 0, False: 0]
  ------------------
  322|      0|                sizeof(spdm_negotiate_algorithms_common_struct_table_t)) {
  323|      0|                status = LIBSPDM_STATUS_INVALID_MSG_SIZE;
  ------------------
  |  |   94|      0|    LIBSPDM_STATUS_CONSTRUCT(LIBSPDM_SEVERITY_ERROR, LIBSPDM_SOURCE_CORE, 0x0006)
  |  |  ------------------
  |  |  |  |   55|      0|    ((libspdm_return_t)(((severity) << 28) | ((source) << 16) | (code)))
  |  |  ------------------
  ------------------
  324|      0|                goto receive_done;
  325|      0|            }
  326|      0|            if ((struct_table->alg_type < SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_DHE) ||
  ------------------
  |  |  349|      0|#define SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_DHE 2
  ------------------
  |  Branch (326:17): [True: 0, False: 0]
  ------------------
  327|      0|                (struct_table->alg_type >
  ------------------
  |  Branch (327:17): [True: 0, False: 0]
  ------------------
  328|      0|                 SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_KEY_SCHEDULE)) {
  ------------------
  |  |  352|      0|#define SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_KEY_SCHEDULE 5
  ------------------
  329|      0|                status = LIBSPDM_STATUS_INVALID_MSG_FIELD;
  ------------------
  |  |   90|      0|    LIBSPDM_STATUS_CONSTRUCT(LIBSPDM_SEVERITY_ERROR, LIBSPDM_SOURCE_CORE, 0x0005)
  |  |  ------------------
  |  |  |  |   55|      0|    ((libspdm_return_t)(((severity) << 28) | ((source) << 16) | (code)))
  |  |  ------------------
  ------------------
  330|      0|                goto receive_done;
  331|      0|            }
  332|       |            /* AlgType shall monotonically increase for subsequent entries. */
  333|      0|            if ((index != 0) && (struct_table->alg_type <= alg_type_pre)) {
  ------------------
  |  Branch (333:17): [True: 0, False: 0]
  |  Branch (333:33): [True: 0, False: 0]
  ------------------
  334|      0|                status = LIBSPDM_STATUS_INVALID_MSG_FIELD;
  ------------------
  |  |   90|      0|    LIBSPDM_STATUS_CONSTRUCT(LIBSPDM_SEVERITY_ERROR, LIBSPDM_SOURCE_CORE, 0x0005)
  |  |  ------------------
  |  |  |  |   55|      0|    ((libspdm_return_t)(((severity) << 28) | ((source) << 16) | (code)))
  |  |  ------------------
  ------------------
  335|      0|                goto receive_done;
  336|      0|            }
  337|      0|            alg_type_pre = struct_table->alg_type;
  338|      0|            fixed_alg_size = (struct_table->alg_count >> 4) & 0xF;
  339|      0|            ext_alg_count = struct_table->alg_count & 0xF;
  340|      0|            if (fixed_alg_size != 2) {
  ------------------
  |  Branch (340:17): [True: 0, False: 0]
  ------------------
  341|      0|                status = LIBSPDM_STATUS_INVALID_MSG_FIELD;
  ------------------
  |  |   90|      0|    LIBSPDM_STATUS_CONSTRUCT(LIBSPDM_SEVERITY_ERROR, LIBSPDM_SOURCE_CORE, 0x0005)
  |  |  ------------------
  |  |  |  |   55|      0|    ((libspdm_return_t)(((severity) << 28) | ((source) << 16) | (code)))
  |  |  ------------------
  ------------------
  342|      0|                goto receive_done;
  343|      0|            }
  344|      0|            if (ext_alg_count > 0) {
  ------------------
  |  Branch (344:17): [True: 0, False: 0]
  ------------------
  345|      0|                status = LIBSPDM_STATUS_INVALID_MSG_FIELD;
  ------------------
  |  |   90|      0|    LIBSPDM_STATUS_CONSTRUCT(LIBSPDM_SEVERITY_ERROR, LIBSPDM_SOURCE_CORE, 0x0005)
  |  |  ------------------
  |  |  |  |   55|      0|    ((libspdm_return_t)(((severity) << 28) | ((source) << 16) | (code)))
  |  |  ------------------
  ------------------
  346|      0|                goto receive_done;
  347|      0|            }
  348|      0|            if (!libspdm_onehot0(struct_table->alg_supported)) {
  ------------------
  |  Branch (348:17): [True: 0, False: 0]
  ------------------
  349|      0|                status = LIBSPDM_STATUS_INVALID_MSG_FIELD;
  ------------------
  |  |   90|      0|    LIBSPDM_STATUS_CONSTRUCT(LIBSPDM_SEVERITY_ERROR, LIBSPDM_SOURCE_CORE, 0x0005)
  |  |  ------------------
  |  |  |  |   55|      0|    ((libspdm_return_t)(((severity) << 28) | ((source) << 16) | (code)))
  |  |  ------------------
  ------------------
  350|      0|                goto receive_done;
  351|      0|            }
  352|      0|            if ((size_t)spdm_response + spdm_response_size -
  ------------------
  |  Branch (352:17): [True: 0, False: 0]
  ------------------
  353|      0|                (size_t)struct_table - sizeof(spdm_negotiate_algorithms_common_struct_table_t) <
  354|      0|                sizeof(uint32_t) * ext_alg_count) {
  355|      0|                status = LIBSPDM_STATUS_INVALID_MSG_SIZE;
  ------------------
  |  |   94|      0|    LIBSPDM_STATUS_CONSTRUCT(LIBSPDM_SEVERITY_ERROR, LIBSPDM_SOURCE_CORE, 0x0006)
  |  |  ------------------
  |  |  |  |   55|      0|    ((libspdm_return_t)(((severity) << 28) | ((source) << 16) | (code)))
  |  |  ------------------
  ------------------
  356|      0|                goto receive_done;
  357|      0|            }
  358|      0|            struct_table =
  359|      0|                (void *)((size_t)struct_table +
  360|      0|                         sizeof(spdm_negotiate_algorithms_common_struct_table_t) +
  361|      0|                         sizeof(uint32_t) * ext_alg_count);
  362|      0|        }
  363|      0|    }
  364|       |
  365|      0|    spdm_response_size = (size_t)struct_table - (size_t)spdm_response;
  366|      0|    if (spdm_response_size != spdm_response->length) {
  ------------------
  |  Branch (366:9): [True: 0, False: 0]
  ------------------
  367|      0|        status = LIBSPDM_STATUS_INVALID_MSG_SIZE;
  ------------------
  |  |   94|      0|    LIBSPDM_STATUS_CONSTRUCT(LIBSPDM_SEVERITY_ERROR, LIBSPDM_SOURCE_CORE, 0x0006)
  |  |  ------------------
  |  |  |  |   55|      0|    ((libspdm_return_t)(((severity) << 28) | ((source) << 16) | (code)))
  |  |  ------------------
  ------------------
  368|      0|        goto receive_done;
  369|      0|    }
  370|       |
  371|       |    /* -=[Process Response Phase]=- */
  372|      0|    status = libspdm_append_message_a(spdm_context, spdm_request, spdm_request_size);
  373|      0|    if (LIBSPDM_STATUS_IS_ERROR(status)) {
  ------------------
  |  |   30|      0|    (LIBSPDM_STATUS_SEVERITY(status) == LIBSPDM_SEVERITY_ERROR)
  |  |  ------------------
  |  |  |  |   37|      0|#define LIBSPDM_STATUS_SEVERITY(status) (((status) >> 28) & 0xf)
  |  |  ------------------
  |  |                   (LIBSPDM_STATUS_SEVERITY(status) == LIBSPDM_SEVERITY_ERROR)
  |  |  ------------------
  |  |  |  |   44|      0|#define LIBSPDM_SEVERITY_ERROR 0x8
  |  |  ------------------
  |  |  |  Branch (30:5): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  374|      0|        goto receive_done;
  375|      0|    }
  376|       |
  377|      0|    status = libspdm_append_message_a(spdm_context, spdm_response, spdm_response_size);
  378|      0|    if (LIBSPDM_STATUS_IS_ERROR(status)) {
  ------------------
  |  |   30|      0|    (LIBSPDM_STATUS_SEVERITY(status) == LIBSPDM_SEVERITY_ERROR)
  |  |  ------------------
  |  |  |  |   37|      0|#define LIBSPDM_STATUS_SEVERITY(status) (((status) >> 28) & 0xf)
  |  |  ------------------
  |  |                   (LIBSPDM_STATUS_SEVERITY(status) == LIBSPDM_SEVERITY_ERROR)
  |  |  ------------------
  |  |  |  |   44|      0|#define LIBSPDM_SEVERITY_ERROR 0x8
  |  |  ------------------
  |  |  |  Branch (30:5): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  379|      0|        goto receive_done;
  380|      0|    }
  381|       |
  382|      0|    spdm_context->connection_info.algorithm.measurement_spec =
  383|      0|        spdm_response->measurement_specification_sel;
  384|      0|    if (spdm_response->header.spdm_version >= SPDM_MESSAGE_VERSION_12) {
  ------------------
  |  |  112|      0|#define SPDM_MESSAGE_VERSION_12 0x12
  ------------------
  |  Branch (384:9): [True: 0, False: 0]
  ------------------
  385|      0|        spdm_context->connection_info.algorithm.other_params_support =
  386|      0|            spdm_response->other_params_selection & SPDM_ALGORITHMS_OPAQUE_DATA_FORMAT_MASK;
  ------------------
  |  |  476|      0|#define SPDM_ALGORITHMS_OPAQUE_DATA_FORMAT_MASK 0xF
  ------------------
  387|      0|        if (spdm_response->header.spdm_version >= SPDM_MESSAGE_VERSION_13) {
  ------------------
  |  |  113|      0|#define SPDM_MESSAGE_VERSION_13 0x13
  ------------------
  |  Branch (387:13): [True: 0, False: 0]
  ------------------
  388|      0|            spdm_context->connection_info.algorithm.other_params_support =
  389|      0|                spdm_response->other_params_selection;
  390|      0|            spdm_context->connection_info.algorithm.mel_spec =
  391|      0|                spdm_response->mel_specification_sel;
  392|      0|        }
  393|      0|    }
  394|      0|    spdm_context->connection_info.algorithm.measurement_hash_algo =
  395|      0|        spdm_response->measurement_hash_algo;
  396|      0|    spdm_context->connection_info.algorithm.base_asym_algo = spdm_response->base_asym_sel;
  397|      0|    spdm_context->connection_info.algorithm.base_hash_algo = spdm_response->base_hash_sel;
  398|       |
  399|      0|    if (libspdm_is_capabilities_flag_supported(
  ------------------
  |  Branch (399:9): [True: 0, False: 0]
  ------------------
  400|      0|            spdm_context, true, 0,
  401|      0|            SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MEAS_CAP) &&
  ------------------
  |  |  236|      0|#define SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MEAS_CAP (0x00000008 | 0x00000010)
  ------------------
  402|      0|        (spdm_request->measurement_specification != 0)) {
  ------------------
  |  Branch (402:9): [True: 0, False: 0]
  ------------------
  403|      0|        if (spdm_context->connection_info.algorithm.measurement_spec !=
  ------------------
  |  Branch (403:13): [True: 0, False: 0]
  ------------------
  404|      0|            SPDM_MEASUREMENT_SPECIFICATION_DMTF) {
  ------------------
  |  |  740|      0|#define SPDM_MEASUREMENT_SPECIFICATION_DMTF 0x01
  ------------------
  405|      0|            status = LIBSPDM_STATUS_INVALID_MSG_FIELD;
  ------------------
  |  |   90|      0|    LIBSPDM_STATUS_CONSTRUCT(LIBSPDM_SEVERITY_ERROR, LIBSPDM_SOURCE_CORE, 0x0005)
  |  |  ------------------
  |  |  |  |   55|      0|    ((libspdm_return_t)(((severity) << 28) | ((source) << 16) | (code)))
  |  |  ------------------
  ------------------
  406|      0|            goto receive_done;
  407|      0|        }
  408|      0|        algo_size = libspdm_get_measurement_hash_size(
  409|      0|            spdm_context->connection_info.algorithm.measurement_hash_algo);
  410|      0|        if (algo_size == 0) {
  ------------------
  |  Branch (410:13): [True: 0, False: 0]
  ------------------
  411|      0|            status = LIBSPDM_STATUS_NEGOTIATION_FAIL;
  ------------------
  |  |   98|      0|    LIBSPDM_STATUS_CONSTRUCT(LIBSPDM_SEVERITY_ERROR, LIBSPDM_SOURCE_CORE, 0x0007)
  |  |  ------------------
  |  |  |  |   55|      0|    ((libspdm_return_t)(((severity) << 28) | ((source) << 16) | (code)))
  |  |  ------------------
  ------------------
  412|      0|            goto receive_done;
  413|      0|        }
  414|      0|    } else {
  415|      0|        if (spdm_context->connection_info.algorithm.measurement_spec != 0) {
  ------------------
  |  Branch (415:13): [True: 0, False: 0]
  ------------------
  416|      0|            status = LIBSPDM_STATUS_INVALID_MSG_FIELD;
  ------------------
  |  |   90|      0|    LIBSPDM_STATUS_CONSTRUCT(LIBSPDM_SEVERITY_ERROR, LIBSPDM_SOURCE_CORE, 0x0005)
  |  |  ------------------
  |  |  |  |   55|      0|    ((libspdm_return_t)(((severity) << 28) | ((source) << 16) | (code)))
  |  |  ------------------
  ------------------
  417|      0|            goto receive_done;
  418|      0|        }
  419|      0|    }
  420|       |
  421|      0|    if (libspdm_is_capabilities_flag_supported(
  ------------------
  |  Branch (421:9): [True: 0, False: 0]
  ------------------
  422|      0|            spdm_context, true, 0,
  423|      0|            SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_CERT_CAP) ||
  ------------------
  |  |  234|      0|#define SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_CERT_CAP 0x00000002
  ------------------
  424|      0|        libspdm_is_capabilities_flag_supported(
  ------------------
  |  Branch (424:9): [True: 0, False: 0]
  ------------------
  425|      0|            spdm_context, true, 0,
  426|      0|            SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_CHAL_CAP) ||
  ------------------
  |  |  235|      0|#define SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_CHAL_CAP 0x00000004
  ------------------
  427|      0|        libspdm_is_capabilities_flag_supported(
  ------------------
  |  Branch (427:9): [True: 0, False: 0]
  ------------------
  428|      0|            spdm_context, true, 0,
  429|      0|            SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MEAS_CAP_SIG) ||
  ------------------
  |  |  238|      0|#define SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MEAS_CAP_SIG 0x00000010
  ------------------
  430|      0|        libspdm_is_capabilities_flag_supported(
  ------------------
  |  Branch (430:9): [True: 0, False: 0]
  ------------------
  431|      0|            spdm_context, true,
  432|      0|            SPDM_GET_CAPABILITIES_REQUEST_FLAGS_KEY_EX_CAP,
  ------------------
  |  |  190|      0|#define SPDM_GET_CAPABILITIES_REQUEST_FLAGS_KEY_EX_CAP 0x00000200
  ------------------
  433|      0|            SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_KEY_EX_CAP) ||
  ------------------
  |  |  251|      0|#define SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_KEY_EX_CAP 0x00000200
  ------------------
  434|      0|        libspdm_is_capabilities_flag_supported(
  ------------------
  |  Branch (434:9): [True: 0, False: 0]
  ------------------
  435|      0|            spdm_context, true,
  436|      0|            SPDM_GET_CAPABILITIES_REQUEST_FLAGS_PSK_CAP,
  ------------------
  |  |  191|      0|#define SPDM_GET_CAPABILITIES_REQUEST_FLAGS_PSK_CAP (0x00000400 | 0x00000800)
  ------------------
  437|      0|            SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_PSK_CAP)) {
  ------------------
  |  |  252|      0|#define SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_PSK_CAP (0x00000400 | 0x00000800)
  ------------------
  438|      0|        algo_size = libspdm_get_hash_size(spdm_context->connection_info.algorithm.base_hash_algo);
  439|      0|        if (algo_size == 0) {
  ------------------
  |  Branch (439:13): [True: 0, False: 0]
  ------------------
  440|      0|            status = LIBSPDM_STATUS_NEGOTIATION_FAIL;
  ------------------
  |  |   98|      0|    LIBSPDM_STATUS_CONSTRUCT(LIBSPDM_SEVERITY_ERROR, LIBSPDM_SOURCE_CORE, 0x0007)
  |  |  ------------------
  |  |  |  |   55|      0|    ((libspdm_return_t)(((severity) << 28) | ((source) << 16) | (code)))
  |  |  ------------------
  ------------------
  441|      0|            goto receive_done;
  442|      0|        }
  443|      0|        if ((spdm_context->connection_info.algorithm.base_hash_algo &
  ------------------
  |  Branch (443:13): [True: 0, False: 0]
  ------------------
  444|      0|             spdm_context->local_context.algorithm.base_hash_algo) == 0) {
  445|      0|            status = LIBSPDM_STATUS_NEGOTIATION_FAIL;
  ------------------
  |  |   98|      0|    LIBSPDM_STATUS_CONSTRUCT(LIBSPDM_SEVERITY_ERROR, LIBSPDM_SOURCE_CORE, 0x0007)
  |  |  ------------------
  |  |  |  |   55|      0|    ((libspdm_return_t)(((severity) << 28) | ((source) << 16) | (code)))
  |  |  ------------------
  ------------------
  446|      0|            goto receive_done;
  447|      0|        }
  448|      0|    }
  449|       |
  450|      0|    if (libspdm_is_capabilities_flag_supported(
  ------------------
  |  Branch (450:9): [True: 0, False: 0]
  ------------------
  451|      0|            spdm_context, true, 0,
  452|      0|            SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_CERT_CAP) ||
  ------------------
  |  |  234|      0|#define SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_CERT_CAP 0x00000002
  ------------------
  453|      0|        libspdm_is_capabilities_flag_supported(
  ------------------
  |  Branch (453:9): [True: 0, False: 0]
  ------------------
  454|      0|            spdm_context, true, 0,
  455|      0|            SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_CHAL_CAP) ||
  ------------------
  |  |  235|      0|#define SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_CHAL_CAP 0x00000004
  ------------------
  456|      0|        libspdm_is_capabilities_flag_supported(
  ------------------
  |  Branch (456:9): [True: 0, False: 0]
  ------------------
  457|      0|            spdm_context, true, 0,
  458|      0|            SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MEAS_CAP_SIG) ||
  ------------------
  |  |  238|      0|#define SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MEAS_CAP_SIG 0x00000010
  ------------------
  459|      0|        libspdm_is_capabilities_flag_supported(
  ------------------
  |  Branch (459:9): [True: 0, False: 0]
  ------------------
  460|      0|            spdm_context, true,
  461|      0|            SPDM_GET_CAPABILITIES_REQUEST_FLAGS_KEY_EX_CAP,
  ------------------
  |  |  190|      0|#define SPDM_GET_CAPABILITIES_REQUEST_FLAGS_KEY_EX_CAP 0x00000200
  ------------------
  462|      0|            SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_KEY_EX_CAP)) {
  ------------------
  |  |  251|      0|#define SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_KEY_EX_CAP 0x00000200
  ------------------
  463|      0|        algo_size = libspdm_get_asym_signature_size(
  464|      0|            spdm_context->connection_info.algorithm.base_asym_algo);
  465|      0|        if (algo_size == 0) {
  ------------------
  |  Branch (465:13): [True: 0, False: 0]
  ------------------
  466|      0|            status = LIBSPDM_STATUS_NEGOTIATION_FAIL;
  ------------------
  |  |   98|      0|    LIBSPDM_STATUS_CONSTRUCT(LIBSPDM_SEVERITY_ERROR, LIBSPDM_SOURCE_CORE, 0x0007)
  |  |  ------------------
  |  |  |  |   55|      0|    ((libspdm_return_t)(((severity) << 28) | ((source) << 16) | (code)))
  |  |  ------------------
  ------------------
  467|      0|            goto receive_done;
  468|      0|        }
  469|      0|        if ((spdm_context->connection_info.algorithm.base_asym_algo &
  ------------------
  |  Branch (469:13): [True: 0, False: 0]
  ------------------
  470|      0|             spdm_context->local_context.algorithm.base_asym_algo) == 0) {
  471|      0|            status = LIBSPDM_STATUS_NEGOTIATION_FAIL;
  ------------------
  |  |   98|      0|    LIBSPDM_STATUS_CONSTRUCT(LIBSPDM_SEVERITY_ERROR, LIBSPDM_SOURCE_CORE, 0x0007)
  |  |  ------------------
  |  |  |  |   55|      0|    ((libspdm_return_t)(((severity) << 28) | ((source) << 16) | (code)))
  |  |  ------------------
  ------------------
  472|      0|            goto receive_done;
  473|      0|        }
  474|      0|    }
  475|       |
  476|      0|    if (spdm_response->header.spdm_version >= SPDM_MESSAGE_VERSION_11) {
  ------------------
  |  |  111|      0|#define SPDM_MESSAGE_VERSION_11 0x11
  ------------------
  |  Branch (476:9): [True: 0, False: 0]
  ------------------
  477|      0|        struct_table =
  478|      0|            (void *)((size_t)spdm_response +
  479|      0|                     sizeof(spdm_algorithms_response_t) +
  480|      0|                     sizeof(uint32_t) * spdm_response->ext_asym_sel_count +
  481|      0|                     sizeof(uint32_t) * spdm_response->ext_hash_sel_count);
  482|      0|        for (index = 0; index < spdm_response->header.param1; index++) {
  ------------------
  |  Branch (482:25): [True: 0, False: 0]
  ------------------
  483|      0|            switch (struct_table->alg_type) {
  ------------------
  |  Branch (483:21): [True: 0, False: 0]
  ------------------
  484|      0|            case SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_DHE:
  ------------------
  |  |  349|      0|#define SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_DHE 2
  ------------------
  |  Branch (484:13): [True: 0, False: 0]
  ------------------
  485|      0|                spdm_context->connection_info.algorithm.dhe_named_group =
  486|      0|                    struct_table->alg_supported;
  487|      0|                break;
  488|      0|            case SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_AEAD:
  ------------------
  |  |  350|      0|#define SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_AEAD 3
  ------------------
  |  Branch (488:13): [True: 0, False: 0]
  ------------------
  489|      0|                spdm_context->connection_info.algorithm.aead_cipher_suite =
  490|      0|                    struct_table->alg_supported;
  491|      0|                break;
  492|      0|            case SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_REQ_BASE_ASYM_ALG:
  ------------------
  |  |  351|      0|#define SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_REQ_BASE_ASYM_ALG 4
  ------------------
  |  Branch (492:13): [True: 0, False: 0]
  ------------------
  493|      0|                spdm_context->connection_info.algorithm.req_base_asym_alg =
  494|      0|                    struct_table->alg_supported;
  495|      0|                break;
  496|      0|            case SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_KEY_SCHEDULE:
  ------------------
  |  |  352|      0|#define SPDM_NEGOTIATE_ALGORITHMS_STRUCT_TABLE_ALG_TYPE_KEY_SCHEDULE 5
  ------------------
  |  Branch (496:13): [True: 0, False: 0]
  ------------------
  497|      0|                spdm_context->connection_info.algorithm.key_schedule =
  498|      0|                    struct_table->alg_supported;
  499|      0|                break;
  500|      0|            }
  501|      0|            ext_alg_count = struct_table->alg_count & 0xF;
  502|      0|            struct_table =
  503|      0|                (void *)((size_t)struct_table +
  504|      0|                         sizeof(spdm_negotiate_algorithms_common_struct_table_t) +
  505|      0|                         sizeof(uint32_t) * ext_alg_count);
  506|      0|        }
  507|       |
  508|      0|        if (libspdm_is_capabilities_flag_supported(
  ------------------
  |  Branch (508:13): [True: 0, False: 0]
  ------------------
  509|      0|                spdm_context, true,
  510|      0|                SPDM_GET_CAPABILITIES_REQUEST_FLAGS_KEY_EX_CAP,
  ------------------
  |  |  190|      0|#define SPDM_GET_CAPABILITIES_REQUEST_FLAGS_KEY_EX_CAP 0x00000200
  ------------------
  511|      0|                SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_KEY_EX_CAP)) {
  ------------------
  |  |  251|      0|#define SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_KEY_EX_CAP 0x00000200
  ------------------
  512|      0|            algo_size = libspdm_get_dhe_pub_key_size(
  513|      0|                spdm_context->connection_info.algorithm.dhe_named_group);
  514|      0|            if (algo_size == 0) {
  ------------------
  |  Branch (514:17): [True: 0, False: 0]
  ------------------
  515|      0|                status = LIBSPDM_STATUS_NEGOTIATION_FAIL;
  ------------------
  |  |   98|      0|    LIBSPDM_STATUS_CONSTRUCT(LIBSPDM_SEVERITY_ERROR, LIBSPDM_SOURCE_CORE, 0x0007)
  |  |  ------------------
  |  |  |  |   55|      0|    ((libspdm_return_t)(((severity) << 28) | ((source) << 16) | (code)))
  |  |  ------------------
  ------------------
  516|      0|                goto receive_done;
  517|      0|            }
  518|      0|            if ((spdm_context->connection_info.algorithm.dhe_named_group &
  ------------------
  |  Branch (518:17): [True: 0, False: 0]
  ------------------
  519|      0|                 spdm_context->local_context.algorithm.dhe_named_group) == 0) {
  520|      0|                status = LIBSPDM_STATUS_NEGOTIATION_FAIL;
  ------------------
  |  |   98|      0|    LIBSPDM_STATUS_CONSTRUCT(LIBSPDM_SEVERITY_ERROR, LIBSPDM_SOURCE_CORE, 0x0007)
  |  |  ------------------
  |  |  |  |   55|      0|    ((libspdm_return_t)(((severity) << 28) | ((source) << 16) | (code)))
  |  |  ------------------
  ------------------
  521|      0|                goto receive_done;
  522|      0|            }
  523|      0|        }
  524|      0|        if (libspdm_is_capabilities_flag_supported(
  ------------------
  |  Branch (524:13): [True: 0, False: 0]
  ------------------
  525|      0|                spdm_context, true,
  526|      0|                SPDM_GET_CAPABILITIES_REQUEST_FLAGS_ENCRYPT_CAP,
  ------------------
  |  |  187|      0|#define SPDM_GET_CAPABILITIES_REQUEST_FLAGS_ENCRYPT_CAP 0x00000040
  ------------------
  527|      0|                SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_ENCRYPT_CAP) ||
  ------------------
  |  |  248|      0|#define SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_ENCRYPT_CAP 0x00000040
  ------------------
  528|      0|            libspdm_is_capabilities_flag_supported(
  ------------------
  |  Branch (528:13): [True: 0, False: 0]
  ------------------
  529|      0|                spdm_context, true,
  530|      0|                SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MAC_CAP,
  ------------------
  |  |  188|      0|#define SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MAC_CAP 0x00000080
  ------------------
  531|      0|                SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MAC_CAP)) {
  ------------------
  |  |  249|      0|#define SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MAC_CAP 0x00000080
  ------------------
  532|      0|            algo_size = libspdm_get_aead_key_size(
  533|      0|                spdm_context->connection_info.algorithm.aead_cipher_suite);
  534|      0|            if (algo_size == 0) {
  ------------------
  |  Branch (534:17): [True: 0, False: 0]
  ------------------
  535|      0|                status = LIBSPDM_STATUS_NEGOTIATION_FAIL;
  ------------------
  |  |   98|      0|    LIBSPDM_STATUS_CONSTRUCT(LIBSPDM_SEVERITY_ERROR, LIBSPDM_SOURCE_CORE, 0x0007)
  |  |  ------------------
  |  |  |  |   55|      0|    ((libspdm_return_t)(((severity) << 28) | ((source) << 16) | (code)))
  |  |  ------------------
  ------------------
  536|      0|                goto receive_done;
  537|      0|            }
  538|      0|            if ((spdm_context->connection_info.algorithm.aead_cipher_suite &
  ------------------
  |  Branch (538:17): [True: 0, False: 0]
  ------------------
  539|      0|                 spdm_context->local_context.algorithm.aead_cipher_suite) == 0) {
  540|      0|                status = LIBSPDM_STATUS_NEGOTIATION_FAIL;
  ------------------
  |  |   98|      0|    LIBSPDM_STATUS_CONSTRUCT(LIBSPDM_SEVERITY_ERROR, LIBSPDM_SOURCE_CORE, 0x0007)
  |  |  ------------------
  |  |  |  |   55|      0|    ((libspdm_return_t)(((severity) << 28) | ((source) << 16) | (code)))
  |  |  ------------------
  ------------------
  541|      0|                goto receive_done;
  542|      0|            }
  543|      0|        }
  544|      0|        if (libspdm_is_capabilities_flag_supported(
  ------------------
  |  Branch (544:13): [True: 0, False: 0]
  ------------------
  545|      0|                spdm_context, true,
  546|      0|                SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MUT_AUTH_CAP,
  ------------------
  |  |  189|      0|#define SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MUT_AUTH_CAP 0x00000100
  ------------------
  547|      0|                SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MUT_AUTH_CAP)) {
  ------------------
  |  |  250|      0|#define SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MUT_AUTH_CAP 0x00000100
  ------------------
  548|      0|            algo_size = libspdm_get_req_asym_signature_size(
  549|      0|                spdm_context->connection_info.algorithm.req_base_asym_alg);
  550|      0|            if (algo_size == 0) {
  ------------------
  |  Branch (550:17): [True: 0, False: 0]
  ------------------
  551|      0|                status = LIBSPDM_STATUS_NEGOTIATION_FAIL;
  ------------------
  |  |   98|      0|    LIBSPDM_STATUS_CONSTRUCT(LIBSPDM_SEVERITY_ERROR, LIBSPDM_SOURCE_CORE, 0x0007)
  |  |  ------------------
  |  |  |  |   55|      0|    ((libspdm_return_t)(((severity) << 28) | ((source) << 16) | (code)))
  |  |  ------------------
  ------------------
  552|      0|                goto receive_done;
  553|      0|            }
  554|      0|            if ((spdm_context->connection_info.algorithm.req_base_asym_alg &
  ------------------
  |  Branch (554:17): [True: 0, False: 0]
  ------------------
  555|      0|                 spdm_context->local_context.algorithm.req_base_asym_alg) == 0) {
  556|      0|                status = LIBSPDM_STATUS_NEGOTIATION_FAIL;
  ------------------
  |  |   98|      0|    LIBSPDM_STATUS_CONSTRUCT(LIBSPDM_SEVERITY_ERROR, LIBSPDM_SOURCE_CORE, 0x0007)
  |  |  ------------------
  |  |  |  |   55|      0|    ((libspdm_return_t)(((severity) << 28) | ((source) << 16) | (code)))
  |  |  ------------------
  ------------------
  557|      0|                goto receive_done;
  558|      0|            }
  559|      0|        }
  560|      0|        if (libspdm_is_capabilities_flag_supported(
  ------------------
  |  Branch (560:13): [True: 0, False: 0]
  ------------------
  561|      0|                spdm_context, true,
  562|      0|                SPDM_GET_CAPABILITIES_REQUEST_FLAGS_KEY_EX_CAP,
  ------------------
  |  |  190|      0|#define SPDM_GET_CAPABILITIES_REQUEST_FLAGS_KEY_EX_CAP 0x00000200
  ------------------
  563|      0|                SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_KEY_EX_CAP) ||
  ------------------
  |  |  251|      0|#define SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_KEY_EX_CAP 0x00000200
  ------------------
  564|      0|            libspdm_is_capabilities_flag_supported(
  ------------------
  |  Branch (564:13): [True: 0, False: 0]
  ------------------
  565|      0|                spdm_context, true,
  566|      0|                SPDM_GET_CAPABILITIES_REQUEST_FLAGS_PSK_CAP,
  ------------------
  |  |  191|      0|#define SPDM_GET_CAPABILITIES_REQUEST_FLAGS_PSK_CAP (0x00000400 | 0x00000800)
  ------------------
  567|      0|                SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_PSK_CAP)) {
  ------------------
  |  |  252|      0|#define SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_PSK_CAP (0x00000400 | 0x00000800)
  ------------------
  568|      0|            if (spdm_context->connection_info.algorithm.key_schedule !=
  ------------------
  |  Branch (568:17): [True: 0, False: 0]
  ------------------
  569|      0|                SPDM_ALGORITHMS_KEY_SCHEDULE_SPDM) {
  ------------------
  |  |  425|      0|#define SPDM_ALGORITHMS_KEY_SCHEDULE_SPDM 0x00000001
  ------------------
  570|      0|                status = LIBSPDM_STATUS_NEGOTIATION_FAIL;
  ------------------
  |  |   98|      0|    LIBSPDM_STATUS_CONSTRUCT(LIBSPDM_SEVERITY_ERROR, LIBSPDM_SOURCE_CORE, 0x0007)
  |  |  ------------------
  |  |  |  |   55|      0|    ((libspdm_return_t)(((severity) << 28) | ((source) << 16) | (code)))
  |  |  ------------------
  ------------------
  571|      0|                goto receive_done;
  572|      0|            }
  573|      0|            if ((spdm_context->connection_info.algorithm.key_schedule &
  ------------------
  |  Branch (573:17): [True: 0, False: 0]
  ------------------
  574|      0|                 spdm_context->local_context.algorithm.key_schedule) == 0) {
  575|      0|                status = LIBSPDM_STATUS_NEGOTIATION_FAIL;
  ------------------
  |  |   98|      0|    LIBSPDM_STATUS_CONSTRUCT(LIBSPDM_SEVERITY_ERROR, LIBSPDM_SOURCE_CORE, 0x0007)
  |  |  ------------------
  |  |  |  |   55|      0|    ((libspdm_return_t)(((severity) << 28) | ((source) << 16) | (code)))
  |  |  ------------------
  ------------------
  576|      0|                goto receive_done;
  577|      0|            }
  578|      0|            if (spdm_response->header.spdm_version >= SPDM_MESSAGE_VERSION_13) {
  ------------------
  |  |  113|      0|#define SPDM_MESSAGE_VERSION_13 0x13
  ------------------
  |  Branch (578:17): [True: 0, False: 0]
  ------------------
  579|      0|                if (libspdm_is_capabilities_flag_supported(
  ------------------
  |  Branch (579:21): [True: 0, False: 0]
  ------------------
  580|      0|                        spdm_context, true, 0,
  581|      0|                        SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MEL_CAP) &&
  ------------------
  |  |  293|      0|#define SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MEL_CAP 0x01000000
  ------------------
  582|      0|                    (spdm_request->mel_specification != 0)) {
  ------------------
  |  Branch (582:21): [True: 0, False: 0]
  ------------------
  583|      0|                    if (spdm_context->connection_info.algorithm.mel_spec !=
  ------------------
  |  Branch (583:25): [True: 0, False: 0]
  ------------------
  584|      0|                        SPDM_MEL_SPECIFICATION_DMTF) {
  ------------------
  |  |  840|      0|#define SPDM_MEL_SPECIFICATION_DMTF 0x01
  ------------------
  585|      0|                        status = LIBSPDM_STATUS_INVALID_MSG_FIELD;
  ------------------
  |  |   90|      0|    LIBSPDM_STATUS_CONSTRUCT(LIBSPDM_SEVERITY_ERROR, LIBSPDM_SOURCE_CORE, 0x0005)
  |  |  ------------------
  |  |  |  |   55|      0|    ((libspdm_return_t)(((severity) << 28) | ((source) << 16) | (code)))
  |  |  ------------------
  ------------------
  586|      0|                        goto receive_done;
  587|      0|                    }
  588|      0|                } else {
  589|      0|                    if (spdm_context->connection_info.algorithm.mel_spec != 0) {
  ------------------
  |  Branch (589:25): [True: 0, False: 0]
  ------------------
  590|      0|                        status = LIBSPDM_STATUS_INVALID_MSG_FIELD;
  ------------------
  |  |   90|      0|    LIBSPDM_STATUS_CONSTRUCT(LIBSPDM_SEVERITY_ERROR, LIBSPDM_SOURCE_CORE, 0x0005)
  |  |  ------------------
  |  |  |  |   55|      0|    ((libspdm_return_t)(((severity) << 28) | ((source) << 16) | (code)))
  |  |  ------------------
  ------------------
  591|      0|                        goto receive_done;
  592|      0|                    }
  593|      0|                }
  594|      0|            }
  595|      0|        }
  596|       |
  597|      0|        if (spdm_request->header.spdm_version >= SPDM_MESSAGE_VERSION_13) {
  ------------------
  |  |  113|      0|#define SPDM_MESSAGE_VERSION_13 0x13
  ------------------
  |  Branch (597:13): [True: 0, False: 0]
  ------------------
  598|      0|            if ((spdm_context->connection_info.algorithm.other_params_support &
  ------------------
  |  Branch (598:17): [True: 0, False: 0]
  ------------------
  599|      0|                 SPDM_ALGORITHMS_MULTI_KEY_CONN) == 0) {
  ------------------
  |  |  478|      0|#define SPDM_ALGORITHMS_MULTI_KEY_CONN 0x10
  ------------------
  600|      0|                if ((spdm_context->local_context.capability.flags &
  ------------------
  |  Branch (600:21): [True: 0, False: 0]
  ------------------
  601|      0|                     SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MULTI_KEY_CAP) ==
  ------------------
  |  |  223|      0|#define SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MULTI_KEY_CAP (0x04000000 | 0x08000000)
  ------------------
  602|      0|                    SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MULTI_KEY_CAP_ONLY) {
  ------------------
  |  |  224|      0|#define SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MULTI_KEY_CAP_ONLY 0x04000000
  ------------------
  603|      0|                    status = LIBSPDM_STATUS_NEGOTIATION_FAIL;
  ------------------
  |  |   98|      0|    LIBSPDM_STATUS_CONSTRUCT(LIBSPDM_SEVERITY_ERROR, LIBSPDM_SOURCE_CORE, 0x0007)
  |  |  ------------------
  |  |  |  |   55|      0|    ((libspdm_return_t)(((severity) << 28) | ((source) << 16) | (code)))
  |  |  ------------------
  ------------------
  604|      0|                    goto receive_done;
  605|      0|                }
  606|      0|                spdm_context->connection_info.multi_key_conn_req = false;
  607|      0|            } else {
  608|      0|                if ((spdm_context->local_context.capability.flags &
  ------------------
  |  Branch (608:21): [True: 0, False: 0]
  ------------------
  609|      0|                     SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MULTI_KEY_CAP) == 0) {
  ------------------
  |  |  223|      0|#define SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MULTI_KEY_CAP (0x04000000 | 0x08000000)
  ------------------
  610|      0|                    status = LIBSPDM_STATUS_NEGOTIATION_FAIL;
  ------------------
  |  |   98|      0|    LIBSPDM_STATUS_CONSTRUCT(LIBSPDM_SEVERITY_ERROR, LIBSPDM_SOURCE_CORE, 0x0007)
  |  |  ------------------
  |  |  |  |   55|      0|    ((libspdm_return_t)(((severity) << 28) | ((source) << 16) | (code)))
  |  |  ------------------
  ------------------
  611|      0|                    goto receive_done;
  612|      0|                }
  613|      0|                spdm_context->connection_info.multi_key_conn_req = true;
  614|      0|            }
  615|      0|        }
  616|      0|    } else {
  617|      0|        spdm_context->connection_info.algorithm.dhe_named_group = 0;
  618|      0|        spdm_context->connection_info.algorithm.aead_cipher_suite = 0;
  619|      0|        spdm_context->connection_info.algorithm.req_base_asym_alg = 0;
  620|      0|        spdm_context->connection_info.algorithm.key_schedule = 0;
  621|      0|        spdm_context->connection_info.algorithm.other_params_support = 0;
  622|      0|    }
  623|       |
  624|       |    /* -=[Update State Phase]=- */
  625|      0|    spdm_context->connection_info.connection_state = LIBSPDM_CONNECTION_STATE_NEGOTIATED;
  626|       |
  627|       |    /* -=[Log Message Phase]=- */
  628|      0|    #if LIBSPDM_ENABLE_MSG_LOG
  629|      0|    libspdm_append_msg_log(spdm_context, spdm_response, spdm_response_size);
  630|      0|    #endif /* LIBSPDM_ENABLE_MSG_LOG */
  631|       |
  632|      0|    status = LIBSPDM_STATUS_SUCCESS;
  ------------------
  |  |   59|      0|    LIBSPDM_STATUS_CONSTRUCT(LIBSPDM_SEVERITY_SUCCESS, LIBSPDM_SOURCE_SUCCESS, 0x0000)
  |  |  ------------------
  |  |  |  |   55|      0|    ((libspdm_return_t)(((severity) << 28) | ((source) << 16) | (code)))
  |  |  ------------------
  ------------------
  633|       |
  634|     92|receive_done:
  635|     92|    libspdm_release_receiver_buffer (spdm_context);
  636|     92|    return status;
  637|      0|}

libspdm_send_request:
   13|     92|{
   14|     92|    libspdm_context_t *context;
   15|     92|    libspdm_return_t status;
   16|     92|    uint8_t *message;
   17|     92|    size_t message_size;
   18|     92|    uint64_t timeout;
   19|     92|    uint8_t *scratch_buffer;
   20|     92|    size_t scratch_buffer_size;
   21|     92|    size_t transport_header_size;
   22|     92|    uint8_t *sender_buffer;
   23|     92|    size_t sender_buffer_size;
   24|       |
   25|     92|    context = spdm_context;
   26|       |
   27|     92|    LIBSPDM_DEBUG((LIBSPDM_DEBUG_INFO,
   28|     92|                   "libspdm_send_spdm_request[%x] msg %s(0x%x), size (0x%zx): \n",
   29|     92|                   (session_id != NULL) ? *session_id : 0x0,
   30|     92|                   libspdm_get_code_str(((spdm_message_header_t *)request)->request_response_code),
   31|     92|                   ((spdm_message_header_t *)request)->request_response_code, request_size));
   32|     92|    LIBSPDM_INTERNAL_DUMP_HEX(request, request_size);
   33|       |
   34|     92|    transport_header_size = context->local_context.capability.transport_header_size;
   35|     92|    libspdm_get_scratch_buffer(context, (void **)&scratch_buffer, &scratch_buffer_size);
   36|     92|    libspdm_get_sender_buffer(context, (void **)&sender_buffer, &sender_buffer_size);
   37|       |
   38|       |    /* This is a problem because original code assumes request is in the sender buffer,
   39|       |     * when it can really be using the scratch space for chunking.
   40|       |     * Did not want to modify all request handlers to pass this information,
   41|       |     * so just making the determination here by examining scratch/sender buffers.
   42|       |     * This may be something that should be refactored in the future. */
   43|     92|    #if LIBSPDM_ENABLE_CAPABILITY_CHUNK_CAP
   44|     92|    if ((uint8_t *)request >= sender_buffer &&
  ------------------
  |  Branch (44:9): [True: 92, False: 0]
  ------------------
   45|     92|        (uint8_t *)request < sender_buffer + sender_buffer_size) {
  ------------------
  |  Branch (45:9): [True: 0, False: 92]
  ------------------
   46|      0|        message = sender_buffer;
   47|      0|        message_size = sender_buffer_size;
   48|     92|    } else {
   49|     92|        if ((uint8_t *)request >=
  ------------------
  |  Branch (49:13): [True: 92, False: 0]
  ------------------
   50|     92|            scratch_buffer + libspdm_get_scratch_buffer_sender_receiver_offset(spdm_context)
   51|     92|            && (uint8_t *)request <
  ------------------
  |  Branch (51:16): [True: 0, False: 92]
  ------------------
   52|     92|            scratch_buffer + libspdm_get_scratch_buffer_sender_receiver_offset(spdm_context)
   53|     92|            + libspdm_get_scratch_buffer_sender_receiver_capacity(spdm_context)) {
   54|      0|            message = scratch_buffer +
   55|      0|                      libspdm_get_scratch_buffer_sender_receiver_offset(spdm_context);
   56|      0|            message_size = libspdm_get_scratch_buffer_sender_receiver_capacity(spdm_context);
   57|     92|        } else if ((uint8_t *)request >=
  ------------------
  |  Branch (57:20): [True: 92, False: 0]
  ------------------
   58|     92|                   scratch_buffer +
   59|     92|                   libspdm_get_scratch_buffer_large_sender_receiver_offset(spdm_context)
   60|     92|                   && (uint8_t *)request <
  ------------------
  |  Branch (60:23): [True: 92, False: 0]
  ------------------
   61|     92|                   scratch_buffer +
   62|     92|                   libspdm_get_scratch_buffer_large_sender_receiver_offset(spdm_context) +
   63|     92|                   libspdm_get_scratch_buffer_large_sender_receiver_capacity(spdm_context)) {
   64|     92|            message = scratch_buffer +
   65|     92|                      libspdm_get_scratch_buffer_large_sender_receiver_offset(spdm_context);
   66|     92|            message_size = libspdm_get_scratch_buffer_large_sender_receiver_capacity(spdm_context);
   67|     92|        }
   68|     92|    }
   69|       |    #else /* LIBSPDM_ENABLE_CAPABILITY_CHUNK_CAP */
   70|       |    message = sender_buffer;
   71|       |    message_size = sender_buffer_size;
   72|       |    #endif /* LIBSPDM_ENABLE_CAPABILITY_CHUNK_CAP */
   73|       |
   74|     92|    if (session_id != NULL) {
  ------------------
  |  Branch (74:9): [True: 0, False: 92]
  ------------------
   75|       |        /* For secure message, message is in sender buffer, we need copy it to scratch buffer.
   76|       |         * transport_message is always in sender buffer. */
   77|       |
   78|      0|        libspdm_copy_mem (scratch_buffer + transport_header_size,
   79|      0|                          scratch_buffer_size - transport_header_size,
   80|      0|                          request, request_size);
   81|      0|        request = scratch_buffer + transport_header_size;
   82|      0|    }
   83|       |
   84|       |    /* backup it to last_spdm_request, because the caller wants to compare it with response */
   85|     92|    if (((const spdm_message_header_t *)request)->request_response_code != SPDM_RESPOND_IF_READY
  ------------------
  |  |   74|    184|#define SPDM_RESPOND_IF_READY 0xFF
  ------------------
  |  Branch (85:9): [True: 92, False: 0]
  ------------------
   86|     92|        && ((const spdm_message_header_t *)request)->request_response_code != SPDM_CHUNK_GET
  ------------------
  |  |   91|    184|#define SPDM_CHUNK_GET 0x86
  ------------------
  |  Branch (86:12): [True: 92, False: 0]
  ------------------
   87|     92|        && ((const spdm_message_header_t *)request)->request_response_code != SPDM_CHUNK_SEND) {
  ------------------
  |  |   90|     92|#define SPDM_CHUNK_SEND 0x85
  ------------------
  |  Branch (87:12): [True: 92, False: 0]
  ------------------
   88|     92|        libspdm_copy_mem (context->last_spdm_request,
   89|     92|                          libspdm_get_scratch_buffer_last_spdm_request_capacity(context),
   90|     92|                          request,
   91|     92|                          request_size);
   92|     92|        context->last_spdm_request_size = request_size;
   93|     92|    }
   94|       |
   95|     92|    status = context->transport_encode_message(
   96|     92|        context, session_id, is_app_message, true, request_size,
   97|     92|        request, &message_size, (void **)&message);
   98|     92|    if (LIBSPDM_STATUS_IS_ERROR(status)) {
  ------------------
  |  |   30|     92|    (LIBSPDM_STATUS_SEVERITY(status) == LIBSPDM_SEVERITY_ERROR)
  |  |  ------------------
  |  |  |  |   37|     92|#define LIBSPDM_STATUS_SEVERITY(status) (((status) >> 28) & 0xf)
  |  |  ------------------
  |  |                   (LIBSPDM_STATUS_SEVERITY(status) == LIBSPDM_SEVERITY_ERROR)
  |  |  ------------------
  |  |  |  |   44|     92|#define LIBSPDM_SEVERITY_ERROR 0x8
  |  |  ------------------
  |  |  |  Branch (30:5): [True: 0, False: 92]
  |  |  ------------------
  ------------------
   99|      0|        LIBSPDM_DEBUG((LIBSPDM_DEBUG_INFO, "transport_encode_message status - %xu\n", status));
  100|      0|        if ((session_id != NULL) &&
  ------------------
  |  Branch (100:13): [True: 0, False: 0]
  ------------------
  101|      0|            ((status == LIBSPDM_STATUS_SEQUENCE_NUMBER_OVERFLOW) ||
  ------------------
  |  |  164|      0|    LIBSPDM_STATUS_CONSTRUCT(LIBSPDM_SEVERITY_ERROR, LIBSPDM_SOURCE_CRYPTO, 0x0002)
  |  |  ------------------
  |  |  |  |   55|      0|    ((libspdm_return_t)(((severity) << 28) | ((source) << 16) | (code)))
  |  |  ------------------
  ------------------
  |  Branch (101:14): [True: 0, False: 0]
  ------------------
  102|      0|             (status == LIBSPDM_STATUS_CRYPTO_ERROR))) {
  ------------------
  |  |  156|      0|    LIBSPDM_STATUS_CONSTRUCT(LIBSPDM_SEVERITY_ERROR, LIBSPDM_SOURCE_CRYPTO, 0x0000)
  |  |  ------------------
  |  |  |  |   55|      0|    ((libspdm_return_t)(((severity) << 28) | ((source) << 16) | (code)))
  |  |  ------------------
  ------------------
  |  Branch (102:14): [True: 0, False: 0]
  ------------------
  103|      0|            libspdm_free_session_id(context, *session_id);
  104|      0|        }
  105|      0|        return status;
  106|      0|    }
  107|       |
  108|     92|    timeout = context->local_context.capability.rtt;
  109|     92|    status = context->send_message(context, message_size, message, timeout);
  110|       |
  111|     92|    if (LIBSPDM_STATUS_IS_ERROR(status)) {
  ------------------
  |  |   30|     92|    (LIBSPDM_STATUS_SEVERITY(status) == LIBSPDM_SEVERITY_ERROR)
  |  |  ------------------
  |  |  |  |   37|     92|#define LIBSPDM_STATUS_SEVERITY(status) (((status) >> 28) & 0xf)
  |  |  ------------------
  |  |                   (LIBSPDM_STATUS_SEVERITY(status) == LIBSPDM_SEVERITY_ERROR)
  |  |  ------------------
  |  |  |  |   44|     92|#define LIBSPDM_SEVERITY_ERROR 0x8
  |  |  ------------------
  |  |  |  Branch (30:5): [True: 0, False: 92]
  |  |  ------------------
  ------------------
  112|      0|        LIBSPDM_DEBUG((LIBSPDM_DEBUG_INFO, "libspdm_send_spdm_request[%x] status - %xu\n",
  113|      0|                       (session_id != NULL) ? *session_id : 0x0, status));
  114|      0|    }
  115|       |
  116|     92|    return status;
  117|     92|}
libspdm_receive_response:
  123|     92|{
  124|     92|    libspdm_context_t *context;
  125|     92|    void *temp_session_context;
  126|     92|    libspdm_return_t status;
  127|     92|    uint8_t *message;
  128|     92|    size_t message_size;
  129|     92|    uint32_t *message_session_id;
  130|     92|    bool is_message_app_message;
  131|     92|    uint64_t timeout;
  132|     92|    size_t transport_header_size;
  133|     92|    uint8_t *scratch_buffer;
  134|     92|    size_t scratch_buffer_size;
  135|     92|    void *backup_response;
  136|     92|    size_t backup_response_size;
  137|     92|    bool reset_key_update;
  138|     92|    bool result;
  139|       |
  140|     92|    context = spdm_context;
  141|       |
  142|     92|    if (context->crypto_request) {
  ------------------
  |  Branch (142:9): [True: 0, False: 92]
  ------------------
  143|      0|        timeout = context->local_context.capability.rtt +
  144|      0|                  ((uint64_t)1 << context->connection_info.capability.ct_exponent);
  145|     92|    } else {
  146|     92|        timeout = context->local_context.capability.rtt + context->local_context.capability.st1;
  147|     92|    }
  148|       |
  149|     92|    message = *response;
  150|     92|    message_size = *response_size;
  151|     92|    status = context->receive_message(context, &message_size, (void **)&message, timeout);
  152|     92|    if (LIBSPDM_STATUS_IS_ERROR(status)) {
  ------------------
  |  |   30|     92|    (LIBSPDM_STATUS_SEVERITY(status) == LIBSPDM_SEVERITY_ERROR)
  |  |  ------------------
  |  |  |  |   37|     92|#define LIBSPDM_STATUS_SEVERITY(status) (((status) >> 28) & 0xf)
  |  |  ------------------
  |  |                   (LIBSPDM_STATUS_SEVERITY(status) == LIBSPDM_SEVERITY_ERROR)
  |  |  ------------------
  |  |  |  |   44|     92|#define LIBSPDM_SEVERITY_ERROR 0x8
  |  |  ------------------
  |  |  |  Branch (30:5): [True: 45, False: 47]
  |  |  ------------------
  ------------------
  153|     45|        LIBSPDM_DEBUG((LIBSPDM_DEBUG_INFO,
  154|     45|                       "libspdm_receive_spdm_response[%x] status - %xu\n",
  155|     45|                       (session_id != NULL) ? *session_id : 0x0, status));
  156|     45|        return status;
  157|     45|    }
  158|       |
  159|     47|    message_session_id = NULL;
  160|     47|    is_message_app_message = false;
  161|       |
  162|       |    /* always use scratch buffer to response.
  163|       |     * if it is secured message, this scratch buffer will be used.
  164|       |     * if it is normal message, the response ptr will point to receiver buffer. */
  165|     47|    transport_header_size = context->local_context.capability.transport_header_size;
  166|     47|    libspdm_get_scratch_buffer (context, (void **)&scratch_buffer, &scratch_buffer_size);
  167|     47|    #if LIBSPDM_ENABLE_CAPABILITY_CHUNK_CAP
  168|     47|    *response = scratch_buffer + libspdm_get_scratch_buffer_secure_message_offset(context) +
  169|     47|                transport_header_size;
  170|     47|    *response_size = libspdm_get_scratch_buffer_secure_message_capacity(context) -
  171|     47|                     transport_header_size;
  172|       |    #else
  173|       |    *response = scratch_buffer + transport_header_size;
  174|       |    *response_size = scratch_buffer_size - transport_header_size;
  175|       |    #endif
  176|       |
  177|     47|    backup_response = *response;
  178|     47|    backup_response_size = *response_size;
  179|       |
  180|     47|    status = context->transport_decode_message(
  181|     47|        context, &message_session_id, &is_message_app_message,
  182|     47|        false, message_size, message, response_size, response);
  183|       |
  184|     47|    reset_key_update = false;
  185|     47|    temp_session_context = NULL;
  186|       |
  187|     47|    if (status == LIBSPDM_STATUS_SESSION_TRY_DISCARD_KEY_UPDATE) {
  ------------------
  |  |  138|     47|    LIBSPDM_STATUS_CONSTRUCT(LIBSPDM_SEVERITY_ERROR, LIBSPDM_SOURCE_CORE, 0x0011)
  |  |  ------------------
  |  |  |  |   55|     47|    ((libspdm_return_t)(((severity) << 28) | ((source) << 16) | (code)))
  |  |  ------------------
  ------------------
  |  Branch (187:9): [True: 0, False: 47]
  ------------------
  188|       |        /* Failed to decode, but have backup keys. Try rolling back before aborting.
  189|       |         * message_session_id must be valid for us to have attempted decryption. */
  190|      0|        if (message_session_id == NULL) {
  ------------------
  |  Branch (190:13): [True: 0, False: 0]
  ------------------
  191|      0|            return LIBSPDM_STATUS_INVALID_STATE_LOCAL;
  ------------------
  |  |   82|      0|    LIBSPDM_STATUS_CONSTRUCT(LIBSPDM_SEVERITY_ERROR, LIBSPDM_SOURCE_CORE, 0x0003)
  |  |  ------------------
  |  |  |  |   55|      0|    ((libspdm_return_t)(((severity) << 28) | ((source) << 16) | (code)))
  |  |  ------------------
  ------------------
  192|      0|        }
  193|      0|        temp_session_context = libspdm_get_secured_message_context_via_session_id(
  194|      0|            context, *message_session_id);
  195|      0|        if (temp_session_context == NULL) {
  ------------------
  |  Branch (195:13): [True: 0, False: 0]
  ------------------
  196|      0|            return LIBSPDM_STATUS_INVALID_STATE_LOCAL;
  ------------------
  |  |   82|      0|    LIBSPDM_STATUS_CONSTRUCT(LIBSPDM_SEVERITY_ERROR, LIBSPDM_SOURCE_CORE, 0x0003)
  |  |  ------------------
  |  |  |  |   55|      0|    ((libspdm_return_t)(((severity) << 28) | ((source) << 16) | (code)))
  |  |  ------------------
  ------------------
  197|      0|        }
  198|       |
  199|      0|        result = libspdm_activate_update_session_data_key(
  200|      0|            temp_session_context, LIBSPDM_KEY_UPDATE_ACTION_RESPONDER, false);
  201|      0|        if (!result) {
  ------------------
  |  Branch (201:13): [True: 0, False: 0]
  ------------------
  202|      0|            return LIBSPDM_STATUS_INVALID_STATE_LOCAL;
  ------------------
  |  |   82|      0|    LIBSPDM_STATUS_CONSTRUCT(LIBSPDM_SEVERITY_ERROR, LIBSPDM_SOURCE_CORE, 0x0003)
  |  |  ------------------
  |  |  |  |   55|      0|    ((libspdm_return_t)(((severity) << 28) | ((source) << 16) | (code)))
  |  |  ------------------
  ------------------
  203|      0|        }
  204|       |
  205|       |        /* Retry decoding message with backup Requester key.
  206|       |         * Must reset some of the parameters in case they were modified */
  207|      0|        message_session_id = NULL;
  208|      0|        is_message_app_message = false;
  209|      0|        *response = backup_response;
  210|      0|        *response_size = backup_response_size;
  211|      0|        status = context->transport_decode_message(
  212|      0|            context, &message_session_id, &is_message_app_message,
  213|      0|            false, message_size, message, response_size, response);
  214|       |
  215|      0|        reset_key_update = true;
  216|      0|    }
  217|       |
  218|     47|    if (session_id != NULL) {
  ------------------
  |  Branch (218:9): [True: 0, False: 47]
  ------------------
  219|      0|        if (message_session_id == NULL) {
  ------------------
  |  Branch (219:13): [True: 0, False: 0]
  ------------------
  220|      0|            LIBSPDM_DEBUG((LIBSPDM_DEBUG_INFO,
  221|      0|                           "libspdm_receive_spdm_response[%x] GetSessionId - NULL\n",
  222|      0|                           (session_id != NULL) ? *session_id : 0x0));
  223|      0|            goto error;
  224|      0|        }
  225|      0|        if (*message_session_id != *session_id) {
  ------------------
  |  Branch (225:13): [True: 0, False: 0]
  ------------------
  226|      0|            LIBSPDM_DEBUG((LIBSPDM_DEBUG_INFO,
  227|      0|                           "libspdm_receive_spdm_response[%x] GetSessionId - %x\n",
  228|      0|                           (session_id != NULL) ? *session_id : 0x0, *message_session_id));
  229|      0|            goto error;
  230|      0|        }
  231|     47|    } else {
  232|     47|        if (message_session_id != NULL) {
  ------------------
  |  Branch (232:13): [True: 0, False: 47]
  ------------------
  233|      0|            LIBSPDM_DEBUG((LIBSPDM_DEBUG_INFO,
  234|      0|                           "libspdm_receive_spdm_response[%x] GetSessionId - %x\n",
  235|      0|                           (session_id != NULL) ? *session_id : 0x0, *message_session_id));
  236|      0|            goto error;
  237|      0|        }
  238|     47|    }
  239|       |
  240|     47|    if ((is_app_message && !is_message_app_message) ||
  ------------------
  |  Branch (240:10): [True: 0, False: 47]
  |  Branch (240:28): [True: 0, False: 0]
  ------------------
  241|     47|        (!is_app_message && is_message_app_message)) {
  ------------------
  |  Branch (241:10): [True: 47, False: 0]
  |  Branch (241:29): [True: 0, False: 47]
  ------------------
  242|      0|        LIBSPDM_DEBUG((LIBSPDM_DEBUG_INFO,
  243|      0|                       "libspdm_receive_spdm_response[%x] app_message mismatch\n",
  244|      0|                       (session_id != NULL) ? *session_id : 0x0));
  245|      0|        goto error;
  246|      0|    }
  247|       |
  248|     47|    if (LIBSPDM_STATUS_IS_ERROR(status)) {
  ------------------
  |  |   30|     47|    (LIBSPDM_STATUS_SEVERITY(status) == LIBSPDM_SEVERITY_ERROR)
  |  |  ------------------
  |  |  |  |   37|     47|#define LIBSPDM_STATUS_SEVERITY(status) (((status) >> 28) & 0xf)
  |  |  ------------------
  |  |                   (LIBSPDM_STATUS_SEVERITY(status) == LIBSPDM_SEVERITY_ERROR)
  |  |  ------------------
  |  |  |  |   44|     47|#define LIBSPDM_SEVERITY_ERROR 0x8
  |  |  ------------------
  |  |  |  Branch (30:5): [True: 0, False: 47]
  |  |  ------------------
  ------------------
  249|      0|        if ((session_id != NULL) &&
  ------------------
  |  Branch (249:13): [True: 0, False: 0]
  ------------------
  250|      0|            (context->last_spdm_error.error_code == SPDM_ERROR_CODE_DECRYPT_ERROR)) {
  ------------------
  |  |  866|      0|#define SPDM_ERROR_CODE_DECRYPT_ERROR 0x06
  ------------------
  |  Branch (250:13): [True: 0, False: 0]
  ------------------
  251|      0|            libspdm_free_session_id(context, *session_id);
  252|      0|        }
  253|      0|        LIBSPDM_DEBUG((LIBSPDM_DEBUG_INFO,
  254|      0|                       "libspdm_receive_spdm_response[%x] status - %xu\n",
  255|      0|                       (session_id != NULL) ? *session_id : 0x0, status));
  256|     47|    } else {
  257|     47|        LIBSPDM_DEBUG((LIBSPDM_DEBUG_INFO,
  258|     47|                       "libspdm_receive_spdm_response[%x] msg %s(0x%x), size (0x%zx): \n",
  259|     47|                       (session_id != NULL) ? *session_id : 0x0,
  260|     47|                       libspdm_get_code_str(((spdm_message_header_t *)*response)->
  261|     47|                                            request_response_code),
  262|     47|                       ((spdm_message_header_t *)*response)->request_response_code,
  263|     47|                       *response_size));
  264|     47|        LIBSPDM_INTERNAL_DUMP_HEX(*response, *response_size);
  265|     47|    }
  266|       |
  267|       |    /* Handle special case:
  268|       |     * If the Responder returns RESPONSE_NOT_READY error to KEY_UPDATE, the Requester needs
  269|       |     * to activate backup key to parse the error. Then later the Responder will return SUCCESS,
  270|       |     * the Requester needs new key. So we need to restore the environment by
  271|       |     * libspdm_create_update_session_data_key() again.*/
  272|     47|    if (reset_key_update) {
  ------------------
  |  Branch (272:9): [True: 0, False: 47]
  ------------------
  273|       |        /* temp_session_context and message_session_id must necessarily
  274|       |         * be valid for us to reach here. */
  275|      0|        if (temp_session_context == NULL || message_session_id == NULL) {
  ------------------
  |  Branch (275:13): [True: 0, False: 0]
  |  Branch (275:45): [True: 0, False: 0]
  ------------------
  276|      0|            return LIBSPDM_STATUS_INVALID_STATE_LOCAL;
  ------------------
  |  |   82|      0|    LIBSPDM_STATUS_CONSTRUCT(LIBSPDM_SEVERITY_ERROR, LIBSPDM_SOURCE_CORE, 0x0003)
  |  |  ------------------
  |  |  |  |   55|      0|    ((libspdm_return_t)(((severity) << 28) | ((source) << 16) | (code)))
  |  |  ------------------
  ------------------
  277|      0|        }
  278|      0|        result = libspdm_create_update_session_data_key(
  279|      0|            temp_session_context, LIBSPDM_KEY_UPDATE_ACTION_RESPONDER);
  280|      0|        if (!result) {
  ------------------
  |  Branch (280:13): [True: 0, False: 0]
  ------------------
  281|      0|            return LIBSPDM_STATUS_INVALID_STATE_LOCAL;
  ------------------
  |  |   82|      0|    LIBSPDM_STATUS_CONSTRUCT(LIBSPDM_SEVERITY_ERROR, LIBSPDM_SOURCE_CORE, 0x0003)
  |  |  ------------------
  |  |  |  |   55|      0|    ((libspdm_return_t)(((severity) << 28) | ((source) << 16) | (code)))
  |  |  ------------------
  ------------------
  282|      0|        }
  283|      0|    }
  284|       |
  285|     47|    return status;
  286|       |
  287|      0|error:
  288|      0|    if (context->last_spdm_error.error_code == SPDM_ERROR_CODE_DECRYPT_ERROR) {
  ------------------
  |  |  866|      0|#define SPDM_ERROR_CODE_DECRYPT_ERROR 0x06
  ------------------
  |  Branch (288:9): [True: 0, False: 0]
  ------------------
  289|      0|        return LIBSPDM_STATUS_SESSION_MSG_ERROR;
  ------------------
  |  |  130|      0|    LIBSPDM_STATUS_CONSTRUCT(LIBSPDM_SEVERITY_ERROR, LIBSPDM_SOURCE_CORE, 0x000f)
  |  |  ------------------
  |  |  |  |   55|      0|    ((libspdm_return_t)(((severity) << 28) | ((source) << 16) | (code)))
  |  |  ------------------
  ------------------
  290|      0|    } else {
  291|      0|        return LIBSPDM_STATUS_RECEIVE_FAIL;
  ------------------
  |  |  188|      0|    LIBSPDM_STATUS_CONSTRUCT(LIBSPDM_SEVERITY_ERROR, LIBSPDM_SOURCE_TRANSPORT, 0x0001)
  |  |  ------------------
  |  |  |  |   55|      0|    ((libspdm_return_t)(((severity) << 28) | ((source) << 16) | (code)))
  |  |  ------------------
  ------------------
  292|      0|    }
  293|      0|}
libspdm_send_spdm_request:
  554|     92|{
  555|     92|    libspdm_session_info_t *session_info;
  556|     92|    libspdm_session_state_t session_state;
  557|     92|    libspdm_return_t status;
  558|     92|    #if LIBSPDM_ENABLE_MSG_LOG
  559|     92|    size_t msg_log_size;
  560|     92|    #endif /* LIBSPDM_ENABLE_MSG_LOG */
  561|       |
  562|       |    /* If chunking is not supported then message must fit in both the send buffer and the receive
  563|       |     * buffer. */
  564|     92|    if (!libspdm_is_capabilities_flag_supported(
  ------------------
  |  Branch (564:9): [True: 0, False: 92]
  ------------------
  565|     92|            spdm_context, true,
  566|     92|            SPDM_GET_CAPABILITIES_REQUEST_FLAGS_CHUNK_CAP,
  ------------------
  |  |  213|     92|#define SPDM_GET_CAPABILITIES_REQUEST_FLAGS_CHUNK_CAP 0x00020000
  ------------------
  567|     92|            SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_CHUNK_CAP)) {
  ------------------
  |  |  274|     92|#define SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_CHUNK_CAP 0x00020000
  ------------------
  568|      0|        if ((spdm_context->connection_info.capability.data_transfer_size != 0) &&
  ------------------
  |  Branch (568:13): [True: 0, False: 0]
  ------------------
  569|      0|            (request_size > spdm_context->connection_info.capability.data_transfer_size)) {
  ------------------
  |  Branch (569:13): [True: 0, False: 0]
  ------------------
  570|      0|            return LIBSPDM_STATUS_PEER_BUFFER_TOO_SMALL;
  ------------------
  |  |  146|      0|    LIBSPDM_STATUS_CONSTRUCT(LIBSPDM_SEVERITY_ERROR, LIBSPDM_SOURCE_CORE, 0x0013)
  |  |  ------------------
  |  |  |  |   55|      0|    ((libspdm_return_t)(((severity) << 28) | ((source) << 16) | (code)))
  |  |  ------------------
  ------------------
  571|      0|        }
  572|      0|        if ((spdm_context->local_context.capability.sender_data_transfer_size != 0) &&
  ------------------
  |  Branch (572:13): [True: 0, False: 0]
  ------------------
  573|      0|            (request_size > spdm_context->local_context.capability.sender_data_transfer_size)) {
  ------------------
  |  Branch (573:13): [True: 0, False: 0]
  ------------------
  574|      0|            return LIBSPDM_STATUS_BUFFER_TOO_SMALL;
  ------------------
  |  |  122|      0|    LIBSPDM_STATUS_CONSTRUCT(LIBSPDM_SEVERITY_ERROR, LIBSPDM_SOURCE_CORE, 0x000d)
  |  |  ------------------
  |  |  |  |   55|      0|    ((libspdm_return_t)(((severity) << 28) | ((source) << 16) | (code)))
  |  |  ------------------
  ------------------
  575|      0|        }
  576|      0|    }
  577|       |
  578|     92|    if ((session_id != NULL) &&
  ------------------
  |  Branch (578:9): [True: 0, False: 92]
  ------------------
  579|     92|        libspdm_is_capabilities_flag_supported(
  ------------------
  |  Branch (579:9): [True: 0, False: 0]
  ------------------
  580|      0|            spdm_context, true,
  581|      0|            SPDM_GET_CAPABILITIES_REQUEST_FLAGS_HANDSHAKE_IN_THE_CLEAR_CAP,
  ------------------
  |  |  196|      0|#define SPDM_GET_CAPABILITIES_REQUEST_FLAGS_HANDSHAKE_IN_THE_CLEAR_CAP 0x00008000
  ------------------
  582|      0|            SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_HANDSHAKE_IN_THE_CLEAR_CAP)) {
  ------------------
  |  |  258|      0|#define SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_HANDSHAKE_IN_THE_CLEAR_CAP 0x00008000
  ------------------
  583|      0|        session_info = libspdm_get_session_info_via_session_id(spdm_context, *session_id);
  584|      0|        LIBSPDM_ASSERT(session_info != NULL);
  585|      0|        if (session_info == NULL) {
  ------------------
  |  Branch (585:13): [True: 0, False: 0]
  ------------------
  586|      0|            return LIBSPDM_STATUS_INVALID_STATE_LOCAL;
  ------------------
  |  |   82|      0|    LIBSPDM_STATUS_CONSTRUCT(LIBSPDM_SEVERITY_ERROR, LIBSPDM_SOURCE_CORE, 0x0003)
  |  |  ------------------
  |  |  |  |   55|      0|    ((libspdm_return_t)(((severity) << 28) | ((source) << 16) | (code)))
  |  |  ------------------
  ------------------
  587|      0|        }
  588|      0|        session_state = libspdm_secured_message_get_session_state(
  589|      0|            session_info->secured_message_context);
  590|      0|        if ((session_state == LIBSPDM_SESSION_STATE_HANDSHAKING) && !session_info->use_psk) {
  ------------------
  |  Branch (590:13): [True: 0, False: 0]
  |  Branch (590:69): [True: 0, False: 0]
  ------------------
  591|      0|            session_id = NULL;
  592|      0|        }
  593|      0|    }
  594|       |
  595|     92|    if ((spdm_context->connection_info.capability.max_spdm_msg_size != 0) &&
  ------------------
  |  Branch (595:9): [True: 0, False: 92]
  ------------------
  596|     92|        (request_size > spdm_context->connection_info.capability.max_spdm_msg_size)) {
  ------------------
  |  Branch (596:9): [True: 0, False: 0]
  ------------------
  597|      0|        LIBSPDM_DEBUG((LIBSPDM_DEBUG_ERROR, "request_size > rsp max_spdm_msg_size\n"));
  598|      0|        return LIBSPDM_STATUS_PEER_BUFFER_TOO_SMALL;
  ------------------
  |  |  146|      0|    LIBSPDM_STATUS_CONSTRUCT(LIBSPDM_SEVERITY_ERROR, LIBSPDM_SOURCE_CORE, 0x0013)
  |  |  ------------------
  |  |  |  |   55|      0|    ((libspdm_return_t)(((severity) << 28) | ((source) << 16) | (code)))
  |  |  ------------------
  ------------------
  599|      0|    }
  600|     92|    LIBSPDM_ASSERT (request_size <= spdm_context->local_context.capability.max_spdm_msg_size);
  601|       |
  602|     92|    #if LIBSPDM_ENABLE_MSG_LOG
  603|       |    /* First save the size of the message log buffer. If there is an error it will be reverted. */
  604|     92|    msg_log_size = libspdm_get_msg_log_size(spdm_context);
  605|     92|    libspdm_append_msg_log(spdm_context, request, request_size);
  606|     92|    #endif /* LIBSPDM_ENABLE_MSG_LOG */
  607|       |
  608|       |    /* large SPDM message is the SPDM message whose size is greater than the DataTransferSize of the receiving
  609|       |     * SPDM endpoint or greater than the transmit buffer size of the sending SPDM endpoint */
  610|     92|    if (((const spdm_message_header_t *)request)->request_response_code != SPDM_GET_VERSION
  ------------------
  |  |   69|    184|#define SPDM_GET_VERSION 0x84
  ------------------
  |  Branch (610:9): [True: 92, False: 0]
  ------------------
  611|     92|        && ((const spdm_message_header_t *)request)->request_response_code != SPDM_GET_CAPABILITIES
  ------------------
  |  |   71|    184|#define SPDM_GET_CAPABILITIES 0xE1
  ------------------
  |  Branch (611:12): [True: 92, False: 0]
  ------------------
  612|     92|        && ((spdm_context->connection_info.capability.data_transfer_size != 0 &&
  ------------------
  |  Branch (612:14): [True: 0, False: 92]
  ------------------
  613|     92|             request_size > spdm_context->connection_info.capability.data_transfer_size) ||
  ------------------
  |  Branch (613:14): [True: 0, False: 0]
  ------------------
  614|     92|            (spdm_context->local_context.capability.sender_data_transfer_size != 0 &&
  ------------------
  |  Branch (614:14): [True: 92, False: 0]
  ------------------
  615|     92|             request_size > spdm_context->local_context.capability.sender_data_transfer_size))) {
  ------------------
  |  Branch (615:14): [True: 0, False: 92]
  ------------------
  616|       |
  617|      0|        #if LIBSPDM_ENABLE_CAPABILITY_CHUNK_CAP
  618|       |        /* libspdm_send_request is not called with the original request in this flow.
  619|       |         * This leads to the last_spdm_request field not having the original request value.
  620|       |         * The caller assumes the request has been copied to last_spdm_request,
  621|       |         * so that it can compare last_spdm_request's fields with response fields
  622|       |         * Therefore the request must be copied to last_spdm_request here. */
  623|       |
  624|      0|        if (((const spdm_message_header_t *)request)->request_response_code != SPDM_RESPOND_IF_READY
  ------------------
  |  |   74|      0|#define SPDM_RESPOND_IF_READY 0xFF
  ------------------
  |  Branch (624:13): [True: 0, False: 0]
  ------------------
  625|      0|            && ((const spdm_message_header_t *)request)->request_response_code != SPDM_CHUNK_GET
  ------------------
  |  |   91|      0|#define SPDM_CHUNK_GET 0x86
  ------------------
  |  Branch (625:16): [True: 0, False: 0]
  ------------------
  626|      0|            && ((const spdm_message_header_t *)request)->request_response_code != SPDM_CHUNK_SEND) {
  ------------------
  |  |   90|      0|#define SPDM_CHUNK_SEND 0x85
  ------------------
  |  Branch (626:16): [True: 0, False: 0]
  ------------------
  627|      0|            libspdm_copy_mem(
  628|      0|                spdm_context->last_spdm_request,
  629|      0|                libspdm_get_scratch_buffer_last_spdm_request_capacity(spdm_context),
  630|      0|                request, request_size);
  631|      0|            spdm_context->last_spdm_request_size = request_size;
  632|      0|        }
  633|       |
  634|      0|        status = libspdm_handle_large_request(
  635|      0|            spdm_context, session_id, request_size, request);
  636|       |        #else  /* LIBSPDM_ENABLE_CAPABILITY_CHUNK_CAP*/
  637|       |        status = LIBSPDM_STATUS_BUFFER_TOO_SMALL;
  638|       |        #endif /* LIBSPDM_ENABLE_CAPABILITY_CHUNK_CAP*/
  639|     92|    } else {
  640|     92|        status = libspdm_send_request(spdm_context, session_id, false, request_size, request);
  641|     92|    }
  642|       |
  643|     92|    #if LIBSPDM_ENABLE_MSG_LOG
  644|       |    /* If there is an error in sending the request then revert the request in the message log. */
  645|     92|    if (LIBSPDM_STATUS_IS_ERROR(status)) {
  ------------------
  |  |   30|     92|    (LIBSPDM_STATUS_SEVERITY(status) == LIBSPDM_SEVERITY_ERROR)
  |  |  ------------------
  |  |  |  |   37|     92|#define LIBSPDM_STATUS_SEVERITY(status) (((status) >> 28) & 0xf)
  |  |  ------------------
  |  |                   (LIBSPDM_STATUS_SEVERITY(status) == LIBSPDM_SEVERITY_ERROR)
  |  |  ------------------
  |  |  |  |   44|     92|#define LIBSPDM_SEVERITY_ERROR 0x8
  |  |  ------------------
  |  |  |  Branch (30:5): [True: 0, False: 92]
  |  |  ------------------
  ------------------
  646|      0|        spdm_context->msg_log.buffer_size = msg_log_size;
  647|      0|    }
  648|     92|    #endif /* LIBSPDM_ENABLE_MSG_LOG */
  649|       |
  650|     92|    return status;
  651|     92|}
libspdm_receive_spdm_response:
  657|     92|{
  658|     92|    libspdm_return_t status;
  659|     92|    libspdm_session_info_t *session_info;
  660|     92|    libspdm_session_state_t session_state;
  661|       |
  662|     92|    #if LIBSPDM_ENABLE_CAPABILITY_CHUNK_CAP
  663|     92|    spdm_message_header_t *spdm_response;
  664|     92|    size_t response_capacity;
  665|     92|    libspdm_chunk_info_t *send_info;
  666|     92|    #endif /* LIBSPDM_ENABLE_CAPABILITY_CHUNK_CAP */
  667|       |
  668|     92|    if ((session_id != NULL) &&
  ------------------
  |  Branch (668:9): [True: 0, False: 92]
  ------------------
  669|     92|        libspdm_is_capabilities_flag_supported(
  ------------------
  |  Branch (669:9): [True: 0, False: 0]
  ------------------
  670|      0|            spdm_context, true,
  671|      0|            SPDM_GET_CAPABILITIES_REQUEST_FLAGS_HANDSHAKE_IN_THE_CLEAR_CAP,
  ------------------
  |  |  196|      0|#define SPDM_GET_CAPABILITIES_REQUEST_FLAGS_HANDSHAKE_IN_THE_CLEAR_CAP 0x00008000
  ------------------
  672|      0|            SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_HANDSHAKE_IN_THE_CLEAR_CAP)) {
  ------------------
  |  |  258|      0|#define SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_HANDSHAKE_IN_THE_CLEAR_CAP 0x00008000
  ------------------
  673|      0|        session_info = libspdm_get_session_info_via_session_id(spdm_context, *session_id);
  674|      0|        LIBSPDM_ASSERT(session_info != NULL);
  675|      0|        if (session_info == NULL) {
  ------------------
  |  Branch (675:13): [True: 0, False: 0]
  ------------------
  676|      0|            return LIBSPDM_STATUS_INVALID_STATE_LOCAL;
  ------------------
  |  |   82|      0|    LIBSPDM_STATUS_CONSTRUCT(LIBSPDM_SEVERITY_ERROR, LIBSPDM_SOURCE_CORE, 0x0003)
  |  |  ------------------
  |  |  |  |   55|      0|    ((libspdm_return_t)(((severity) << 28) | ((source) << 16) | (code)))
  |  |  ------------------
  ------------------
  677|      0|        }
  678|      0|        session_state = libspdm_secured_message_get_session_state(
  679|      0|            session_info->secured_message_context);
  680|      0|        if ((session_state == LIBSPDM_SESSION_STATE_HANDSHAKING) && !session_info->use_psk) {
  ------------------
  |  Branch (680:13): [True: 0, False: 0]
  |  Branch (680:69): [True: 0, False: 0]
  ------------------
  681|      0|            session_id = NULL;
  682|      0|        }
  683|      0|    }
  684|       |
  685|       |    #if !(LIBSPDM_ENABLE_CAPABILITY_CHUNK_CAP)
  686|       |    status = libspdm_receive_response(spdm_context, session_id, false, response_size, response);
  687|       |    #else /* LIBSPDM_ENABLE_CAPABILITY_CHUNK_CAP */
  688|     92|    send_info = &spdm_context->chunk_context.send;
  689|     92|    if (send_info->chunk_in_use) {
  ------------------
  |  Branch (689:9): [True: 0, False: 92]
  ------------------
  690|      0|        libspdm_copy_mem(*response, *response_size,
  691|      0|                         send_info->large_message, send_info->large_message_size);
  692|      0|        *response_size = send_info->large_message_size;
  693|      0|        response_capacity = send_info->large_message_capacity;
  694|       |
  695|       |        /* This response may either be an actual response or ERROR_LARGE_RESPONSE,
  696|       |         * the latter which should be handled in the large response handler. */
  697|      0|        send_info->chunk_in_use = false;
  698|      0|        send_info->chunk_handle++; /* Implicit wrap-around*/
  699|      0|        send_info->chunk_seq_no = 0;
  700|      0|        send_info->chunk_bytes_transferred = 0;
  701|      0|        send_info->large_message = NULL;
  702|      0|        send_info->large_message_size = 0;
  703|      0|        send_info->large_message_capacity = 0;
  704|      0|        status = LIBSPDM_STATUS_SUCCESS;
  ------------------
  |  |   59|      0|    LIBSPDM_STATUS_CONSTRUCT(LIBSPDM_SEVERITY_SUCCESS, LIBSPDM_SOURCE_SUCCESS, 0x0000)
  |  |  ------------------
  |  |  |  |   55|      0|    ((libspdm_return_t)(((severity) << 28) | ((source) << 16) | (code)))
  |  |  ------------------
  ------------------
  705|     92|    } else {
  706|     92|        response_capacity = *response_size;
  707|     92|        status = libspdm_receive_response(spdm_context, session_id, false, response_size, response);
  708|     92|        if (LIBSPDM_STATUS_IS_ERROR(status)) {
  ------------------
  |  |   30|     92|    (LIBSPDM_STATUS_SEVERITY(status) == LIBSPDM_SEVERITY_ERROR)
  |  |  ------------------
  |  |  |  |   37|     92|#define LIBSPDM_STATUS_SEVERITY(status) (((status) >> 28) & 0xf)
  |  |  ------------------
  |  |                   (LIBSPDM_STATUS_SEVERITY(status) == LIBSPDM_SEVERITY_ERROR)
  |  |  ------------------
  |  |  |  |   44|     92|#define LIBSPDM_SEVERITY_ERROR 0x8
  |  |  ------------------
  |  |  |  Branch (30:5): [True: 45, False: 47]
  |  |  ------------------
  ------------------
  709|     45|            goto receive_done;
  710|     45|        }
  711|     92|    }
  712|       |
  713|     47|    spdm_response = (spdm_message_header_t *)(*response);
  714|       |
  715|     47|    if (*response_size < sizeof(spdm_message_header_t)) {
  ------------------
  |  Branch (715:9): [True: 0, False: 47]
  ------------------
  716|      0|        status = LIBSPDM_STATUS_INVALID_MSG_SIZE;
  ------------------
  |  |   94|      0|    LIBSPDM_STATUS_CONSTRUCT(LIBSPDM_SEVERITY_ERROR, LIBSPDM_SOURCE_CORE, 0x0006)
  |  |  ------------------
  |  |  |  |   55|      0|    ((libspdm_return_t)(((severity) << 28) | ((source) << 16) | (code)))
  |  |  ------------------
  ------------------
  717|      0|        goto receive_done;
  718|      0|    }
  719|       |
  720|     47|    if (spdm_response->request_response_code == SPDM_ERROR
  ------------------
  |  |   37|     94|#define SPDM_ERROR 0x7F
  ------------------
  |  Branch (720:9): [True: 2, False: 45]
  ------------------
  721|     47|        && spdm_response->param1 == SPDM_ERROR_CODE_LARGE_RESPONSE) {
  ------------------
  |  |  876|      2|#define SPDM_ERROR_CODE_LARGE_RESPONSE 0x0F
  ------------------
  |  Branch (721:12): [True: 0, False: 2]
  ------------------
  722|      0|        status = libspdm_handle_error_large_response(
  723|      0|            spdm_context, session_id,
  724|      0|            response_size, (void *)spdm_response, response_capacity);
  725|       |
  726|      0|        if (LIBSPDM_STATUS_IS_ERROR(status)) {
  ------------------
  |  |   30|      0|    (LIBSPDM_STATUS_SEVERITY(status) == LIBSPDM_SEVERITY_ERROR)
  |  |  ------------------
  |  |  |  |   37|      0|#define LIBSPDM_STATUS_SEVERITY(status) (((status) >> 28) & 0xf)
  |  |  ------------------
  |  |                   (LIBSPDM_STATUS_SEVERITY(status) == LIBSPDM_SEVERITY_ERROR)
  |  |  ------------------
  |  |  |  |   44|      0|#define LIBSPDM_SEVERITY_ERROR 0x8
  |  |  ------------------
  |  |  |  Branch (30:5): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  727|      0|            goto receive_done;
  728|      0|        }
  729|       |
  730|      0|        if (*response_size < sizeof(spdm_message_header_t)) {
  ------------------
  |  Branch (730:13): [True: 0, False: 0]
  ------------------
  731|      0|            status = LIBSPDM_STATUS_INVALID_MSG_SIZE;
  ------------------
  |  |   94|      0|    LIBSPDM_STATUS_CONSTRUCT(LIBSPDM_SEVERITY_ERROR, LIBSPDM_SOURCE_CORE, 0x0006)
  |  |  ------------------
  |  |  |  |   55|      0|    ((libspdm_return_t)(((severity) << 28) | ((source) << 16) | (code)))
  |  |  ------------------
  ------------------
  732|      0|            goto receive_done;
  733|      0|        }
  734|       |
  735|       |        /* Per the spec, SPDM_VERSION and SPDM_CAPABILITIES shall not be chunked
  736|       |         * and should be an unexpected error. */
  737|      0|        if (spdm_response->request_response_code == SPDM_VERSION ||
  ------------------
  |  |   32|      0|#define SPDM_VERSION 0x04
  ------------------
  |  Branch (737:13): [True: 0, False: 0]
  ------------------
  738|      0|            spdm_response->request_response_code == SPDM_CAPABILITIES) {
  ------------------
  |  |   34|      0|#define SPDM_CAPABILITIES 0x61
  ------------------
  |  Branch (738:13): [True: 0, False: 0]
  ------------------
  739|      0|            status = LIBSPDM_STATUS_INVALID_MSG_FIELD;
  ------------------
  |  |   90|      0|    LIBSPDM_STATUS_CONSTRUCT(LIBSPDM_SEVERITY_ERROR, LIBSPDM_SOURCE_CORE, 0x0005)
  |  |  ------------------
  |  |  |  |   55|      0|    ((libspdm_return_t)(((severity) << 28) | ((source) << 16) | (code)))
  |  |  ------------------
  ------------------
  740|      0|            goto receive_done;
  741|      0|        }
  742|      0|    }
  743|       |
  744|     92|receive_done:
  745|     92|    #endif /* LIBSPDM_ENABLE_CAPABILITY_CHUNK_CAP */
  746|       |
  747|     92|    return status;
  748|     47|}

libspdm_secured_message_get_context_size:
   15|    184|{
   16|    184|    return sizeof(libspdm_secured_message_context_t);
   17|    184|}
libspdm_secured_message_init_context:
   27|    368|{
   28|    368|    libspdm_secured_message_context_t *secured_message_context;
   29|       |
   30|    368|    secured_message_context = spdm_secured_message_context;
   31|    368|    libspdm_zero_mem(secured_message_context, sizeof(libspdm_secured_message_context_t));
   32|    368|}

allocate_zero_pool:
   20|     92|{
   21|     92|    void *buffer;
   22|     92|    buffer = malloc(AllocationSize);
   23|     92|    if (buffer == NULL) {
  ------------------
  |  Branch (23:9): [True: 0, False: 92]
  ------------------
   24|      0|        return NULL;
   25|      0|    }
   26|     92|    memset(buffer, 0, AllocationSize);
   27|     92|    return buffer;
   28|     92|}

libspdm_copy_mem:
   12|    191|{
   13|    191|    volatile uint8_t* dst;
   14|    191|    const volatile uint8_t* src;
   15|       |
   16|    191|    dst = (volatile uint8_t*) dst_buf;
   17|    191|    src = (const volatile uint8_t*) src_buf;
   18|       |
   19|    191|    if ((dst == NULL) || (src == NULL)) {
  ------------------
  |  Branch (19:9): [True: 0, False: 191]
  |  Branch (19:26): [True: 0, False: 191]
  ------------------
   20|      0|        LIBSPDM_ASSERT(0);
   21|      0|    }
   22|    191|    if (((src < dst) && ((src + src_len) > dst)) || ((dst < src) && ((dst + src_len) > src))) {
  ------------------
  |  Branch (22:10): [True: 143, False: 48]
  |  Branch (22:25): [True: 0, False: 143]
  |  Branch (22:54): [True: 48, False: 143]
  |  Branch (22:69): [True: 0, False: 48]
  ------------------
   23|      0|        LIBSPDM_ASSERT(0);
   24|      0|    }
   25|    191|    if (src_len > dst_len) {
  ------------------
  |  Branch (25:9): [True: 0, False: 191]
  ------------------
   26|      0|        LIBSPDM_ASSERT(0);
   27|      0|    }
   28|       |
   29|  49.5k|    while (src_len-- != 0) {
  ------------------
  |  Branch (29:12): [True: 49.3k, False: 191]
  ------------------
   30|  49.3k|        *(dst++) = *(src++);
   31|  49.3k|    }
   32|    191|}

libspdm_zero_mem:
   17|    967|{
   18|       |
   19|       |#if defined(__STDC_LIB_EXT1__)
   20|       |    memset_s(buffer, length, 0, length);
   21|       |#elif defined(_WIN32)
   22|       |    SecureZeroMemory(buffer, length);
   23|       |#elif defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
   24|       |    explicit_bzero(buffer, length);
   25|       |#else
   26|    967|    volatile uint8_t *pointer;
   27|       |
   28|    967|    pointer = (uint8_t *)buffer;
   29|  2.45M|    while (length-- != 0) {
  ------------------
  |  Branch (29:12): [True: 2.45M, False: 967]
  ------------------
   30|  2.45M|        *(pointer++) = 0;
   31|  2.45M|    }
   32|       |
   33|       |#if defined(_MSC_VER) && (_MSC_VER > 1200) && !defined(__clang__)
   34|       |    _ReadWriteBarrier();
   35|       |#elif defined(__GNUC__)
   36|       |    __asm__ __volatile__ ("" : : : "memory");
   37|    967|#endif
   38|       |
   39|    967|#endif
   40|    967|}

spdm_device_acquire_sender_buffer:
   17|     92|{
   18|     92|    LIBSPDM_ASSERT (!m_send_receive_buffer_acquired);
   19|     92|    *msg_buf_ptr = m_send_receive_buffer;
   20|     92|    libspdm_zero_mem (m_send_receive_buffer, sizeof(m_send_receive_buffer));
   21|     92|    m_send_receive_buffer_acquired = true;
   22|     92|    return LIBSPDM_STATUS_SUCCESS;
  ------------------
  |  |   59|     92|    LIBSPDM_STATUS_CONSTRUCT(LIBSPDM_SEVERITY_SUCCESS, LIBSPDM_SOURCE_SUCCESS, 0x0000)
  |  |  ------------------
  |  |  |  |   55|     92|    ((libspdm_return_t)(((severity) << 28) | ((source) << 16) | (code)))
  |  |  ------------------
  ------------------
   23|     92|}
spdm_device_release_sender_buffer:
   27|     92|{
   28|     92|    LIBSPDM_ASSERT (m_send_receive_buffer_acquired);
   29|     92|    LIBSPDM_ASSERT (msg_buf_ptr == m_send_receive_buffer);
   30|     92|    m_send_receive_buffer_acquired = false;
   31|     92|    return;
   32|     92|}
spdm_device_acquire_receiver_buffer:
   36|     92|{
   37|     92|    LIBSPDM_ASSERT (!m_send_receive_buffer_acquired);
   38|     92|    *msg_buf_ptr = m_send_receive_buffer;
   39|     92|    libspdm_zero_mem (m_send_receive_buffer, sizeof(m_send_receive_buffer));
   40|     92|    m_send_receive_buffer_acquired = true;
   41|     92|    return LIBSPDM_STATUS_SUCCESS;
  ------------------
  |  |   59|     92|    LIBSPDM_STATUS_CONSTRUCT(LIBSPDM_SEVERITY_SUCCESS, LIBSPDM_SOURCE_SUCCESS, 0x0000)
  |  |  ------------------
  |  |  |  |   55|     92|    ((libspdm_return_t)(((severity) << 28) | ((source) << 16) | (code)))
  |  |  ------------------
  ------------------
   42|     92|}
spdm_device_release_receiver_buffer:
   46|     92|{
   47|     92|    LIBSPDM_ASSERT (m_send_receive_buffer_acquired);
   48|     92|    LIBSPDM_ASSERT (msg_buf_ptr == m_send_receive_buffer);
   49|     92|    m_send_receive_buffer_acquired = false;
   50|     92|    return;
   51|     92|}
libspdm_get_test_context:
   54|     92|{
   55|     92|    return m_libspdm_test_context;
   56|     92|}
libspdm_setup_test_context:
   59|     92|{
   60|     92|    m_libspdm_test_context = spdm_test_context;
   61|     92|}
libspdm_unit_test_group_setup:
   64|     92|{
   65|     92|    libspdm_test_context_t *spdm_test_context;
   66|     92|    void *spdm_context;
   67|       |
   68|     92|    spdm_test_context = m_libspdm_test_context;
   69|     92|    spdm_test_context->spdm_context =
   70|     92|        (void *)malloc(libspdm_get_context_size());
   71|     92|    if (spdm_test_context->spdm_context == NULL) {
  ------------------
  |  Branch (71:9): [True: 0, False: 92]
  ------------------
   72|      0|        return (size_t)-1;
   73|      0|    }
   74|     92|    spdm_context = spdm_test_context->spdm_context;
   75|       |
   76|     92|    libspdm_init_context(spdm_context);
   77|       |
   78|     92|    libspdm_register_device_io_func(spdm_context,
   79|     92|                                    spdm_test_context->send_message,
   80|     92|                                    spdm_test_context->receive_message);
   81|     92|    libspdm_register_transport_layer_func(spdm_context,
   82|     92|                                          LIBSPDM_MAX_SPDM_MSG_SIZE,
  ------------------
  |  |  101|     92|#define LIBSPDM_MAX_SPDM_MSG_SIZE 0x1200
  ------------------
   83|     92|                                          LIBSPDM_TEST_TRANSPORT_HEADER_SIZE,
  ------------------
  |  |   27|     92|#define LIBSPDM_TEST_TRANSPORT_HEADER_SIZE  (2 + 8 + \
  |  |   28|     92|                                             LIBSPDM_TEST_SEQUENCE_NUMBER_COUNT)
  |  |  ------------------
  |  |  |  |   16|     92|#define LIBSPDM_TEST_SEQUENCE_NUMBER_COUNT 2
  |  |  ------------------
  ------------------
   84|     92|                                          LIBSPDM_TEST_TRANSPORT_TAIL_SIZE,
  ------------------
  |  |   30|     92|#define LIBSPDM_TEST_TRANSPORT_TAIL_SIZE    (LIBSPDM_TEST_MAX_RANDOM_NUMBER_COUNT + \
  |  |  ------------------
  |  |  |  |   17|     92|#define LIBSPDM_TEST_MAX_RANDOM_NUMBER_COUNT 32
  |  |  ------------------
  |  |   31|     92|                                             LIBSPDM_MAX_AEAD_TAG_SIZE + \
  |  |  ------------------
  |  |  |  |   75|     92|#define LIBSPDM_MAX_AEAD_TAG_SIZE 16
  |  |  ------------------
  |  |   32|     92|                                             (LIBSPDM_TEST_ALIGNMENT - 1))
  |  |  ------------------
  |  |  |  |   15|     92|#define LIBSPDM_TEST_ALIGNMENT 4
  |  |  ------------------
  ------------------
   85|     92|                                          libspdm_transport_test_encode_message,
   86|     92|                                          libspdm_transport_test_decode_message);
   87|     92|    libspdm_register_device_buffer_func(spdm_context,
   88|     92|                                        LIBSPDM_MAX_SENDER_RECEIVER_BUFFER_SIZE,
  ------------------
  |  |   93|     92|#define LIBSPDM_MAX_SENDER_RECEIVER_BUFFER_SIZE LIBSPDM_RECEIVER_BUFFER_SIZE
  |  |  ------------------
  |  |  |  |   78|     92|#define LIBSPDM_RECEIVER_BUFFER_SIZE (0x1200 + \
  |  |  |  |   79|     92|                                      LIBSPDM_TRANSPORT_ADDITIONAL_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |   70|     92|#define LIBSPDM_TRANSPORT_ADDITIONAL_SIZE    (LIBSPDM_TEST_TRANSPORT_HEADER_SIZE + \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   27|     92|#define LIBSPDM_TEST_TRANSPORT_HEADER_SIZE  (2 + 8 + \
  |  |  |  |  |  |  |  |   28|     92|                                             LIBSPDM_TEST_SEQUENCE_NUMBER_COUNT)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   16|     92|#define LIBSPDM_TEST_SEQUENCE_NUMBER_COUNT 2
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   71|     92|                                              LIBSPDM_TEST_TRANSPORT_TAIL_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   30|     92|#define LIBSPDM_TEST_TRANSPORT_TAIL_SIZE    (LIBSPDM_TEST_MAX_RANDOM_NUMBER_COUNT + \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   17|     92|#define LIBSPDM_TEST_MAX_RANDOM_NUMBER_COUNT 32
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   31|     92|                                             LIBSPDM_MAX_AEAD_TAG_SIZE + \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   75|     92|#define LIBSPDM_MAX_AEAD_TAG_SIZE 16
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   32|     92|                                             (LIBSPDM_TEST_ALIGNMENT - 1))
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   15|     92|#define LIBSPDM_TEST_ALIGNMENT 4
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   89|     92|                                        LIBSPDM_MAX_SENDER_RECEIVER_BUFFER_SIZE,
  ------------------
  |  |   93|     92|#define LIBSPDM_MAX_SENDER_RECEIVER_BUFFER_SIZE LIBSPDM_RECEIVER_BUFFER_SIZE
  |  |  ------------------
  |  |  |  |   78|     92|#define LIBSPDM_RECEIVER_BUFFER_SIZE (0x1200 + \
  |  |  |  |   79|     92|                                      LIBSPDM_TRANSPORT_ADDITIONAL_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |   70|     92|#define LIBSPDM_TRANSPORT_ADDITIONAL_SIZE    (LIBSPDM_TEST_TRANSPORT_HEADER_SIZE + \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   27|     92|#define LIBSPDM_TEST_TRANSPORT_HEADER_SIZE  (2 + 8 + \
  |  |  |  |  |  |  |  |   28|     92|                                             LIBSPDM_TEST_SEQUENCE_NUMBER_COUNT)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   16|     92|#define LIBSPDM_TEST_SEQUENCE_NUMBER_COUNT 2
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   71|     92|                                              LIBSPDM_TEST_TRANSPORT_TAIL_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   30|     92|#define LIBSPDM_TEST_TRANSPORT_TAIL_SIZE    (LIBSPDM_TEST_MAX_RANDOM_NUMBER_COUNT + \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   17|     92|#define LIBSPDM_TEST_MAX_RANDOM_NUMBER_COUNT 32
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   31|     92|                                             LIBSPDM_MAX_AEAD_TAG_SIZE + \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   75|     92|#define LIBSPDM_MAX_AEAD_TAG_SIZE 16
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   32|     92|                                             (LIBSPDM_TEST_ALIGNMENT - 1))
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   15|     92|#define LIBSPDM_TEST_ALIGNMENT 4
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   90|     92|                                        spdm_device_acquire_sender_buffer,
   91|     92|                                        spdm_device_release_sender_buffer,
   92|     92|                                        spdm_device_acquire_receiver_buffer,
   93|     92|                                        spdm_device_release_receiver_buffer);
   94|       |
   95|     92|    spdm_test_context->scratch_buffer_size =
   96|     92|        libspdm_get_sizeof_required_scratch_buffer(spdm_context);
   97|     92|    spdm_test_context->scratch_buffer = (void *)malloc(spdm_test_context->scratch_buffer_size);
   98|     92|    libspdm_set_scratch_buffer (spdm_context,
   99|     92|                                spdm_test_context->scratch_buffer,
  100|     92|                                spdm_test_context->scratch_buffer_size);
  101|       |
  102|     92|    *State = spdm_test_context;
  103|     92|    return 0;
  104|     92|}
libspdm_unit_test_group_teardown:
  107|     92|{
  108|     92|    libspdm_test_context_t *spdm_test_context;
  109|       |
  110|     92|    spdm_test_context = *State;
  111|     92|    free(spdm_test_context->spdm_context);
  112|     92|    free(spdm_test_context->scratch_buffer);
  113|     92|    spdm_test_context->spdm_context = NULL;
  114|     92|    return 0;
  115|     92|}

libspdm_alignment_size:
   21|     92|{
   22|     92|    size_t alignment;
   23|     92|    size_t max_buffer_size;
   24|       |
   25|     92|    alignment = LIBSPDM_TEST_ALIGNMENT;
  ------------------
  |  |   15|     92|#define LIBSPDM_TEST_ALIGNMENT 4
  ------------------
   26|     92|    max_buffer_size = libspdm_get_max_buffer_size();
   27|       |
   28|       |    /* In the situation where max_buffer_size is not four-byte aligned, reserve sufficient size for the buffer_size */
   29|     92|    if ((size > max_buffer_size - alignment) && (size & (alignment - 1)) != 0) {
  ------------------
  |  Branch (29:9): [True: 45, False: 47]
  |  Branch (29:49): [True: 3, False: 42]
  ------------------
   30|      3|        size -= alignment;
   31|      3|    }
   32|       |
   33|     92|    if (((size) & (alignment - 1)) == 3) {
  ------------------
  |  Branch (33:9): [True: 18, False: 74]
  ------------------
   34|     18|        size += 1;
   35|     18|    }
   36|     92|    if (((size) & (alignment - 1)) == 2) {
  ------------------
  |  Branch (36:9): [True: 4, False: 88]
  ------------------
   37|      4|        size += 2;
   38|      4|    }
   39|     92|    if (((size) & (alignment - 1)) == 1) {
  ------------------
  |  Branch (39:9): [True: 13, False: 79]
  ------------------
   40|     13|        size += 3;
   41|     13|    }
   42|     92|    return size;
   43|     92|}
LLVMFuzzerTestOneInput:
  112|     92|{
  113|     92|    void *test_buffer;
  114|     92|    size_t max_buffer_size;
  115|       |
  116|       |    /* 1. Initialize test_buffer*/
  117|     92|    max_buffer_size = libspdm_get_max_buffer_size();
  118|     92|    test_buffer = allocate_zero_pool(max_buffer_size);
  119|     92|    if (test_buffer == NULL) {
  ------------------
  |  Branch (119:9): [True: 0, False: 92]
  ------------------
  120|      0|        return 0;
  121|      0|    }
  122|     92|    if (size == 0) {
  ------------------
  |  Branch (122:9): [True: 0, False: 92]
  ------------------
  123|      0|        printf("\033[1;33m file_size of the seed file is 0, so exit.\033[0m \n");
  124|      0|        free(test_buffer);
  125|      0|        return 0;
  126|      0|    }
  127|     92|    if (size > max_buffer_size) {
  ------------------
  |  Branch (127:9): [True: 41, False: 51]
  ------------------
  128|     41|        size = max_buffer_size;
  129|     51|    } else {
  130|     51|        libspdm_copy_mem(test_buffer, max_buffer_size, data, size);
  131|     51|    }
  132|     92|    size = libspdm_alignment_size(size);
  133|       |    /* 2. Run test*/
  134|     92|    libspdm_run_test_harness(test_buffer, size);
  135|       |    /* 3. Clean up*/
  136|     92|    free(test_buffer);
  137|     92|    return 0;
  138|     92|}

libspdm_get_max_buffer_size:
   19|    184|{
   20|    184|    return LIBSPDM_MAX_SPDM_MSG_SIZE;
  ------------------
  |  |  101|    184|#define LIBSPDM_MAX_SPDM_MSG_SIZE 0x1200
  ------------------
   21|    184|}
libspdm_device_send_message:
   26|     92|{
   27|     92|    return LIBSPDM_STATUS_SUCCESS;
  ------------------
  |  |   59|     92|    LIBSPDM_STATUS_CONSTRUCT(LIBSPDM_SEVERITY_SUCCESS, LIBSPDM_SOURCE_SUCCESS, 0x0000)
  |  |  ------------------
  |  |  |  |   55|     92|    ((libspdm_return_t)(((severity) << 28) | ((source) << 16) | (code)))
  |  |  ------------------
  ------------------
   28|     92|}
libspdm_device_receive_message:
   34|     92|{
   35|     92|    libspdm_test_context_t *spdm_test_context;
   36|     92|    static uint8_t *spdm_response;
   37|     92|    size_t spdm_response_size;
   38|     92|    size_t test_message_header_size;
   39|     92|    static bool error_large_response_sent = false;
   40|     92|    static size_t chunk_rsp_buf = 0;
   41|     92|    spdm_chunk_response_response_t* chunk_rsp;
   42|       |
   43|     92|    size_t chunk_rsp_size;
   44|       |
   45|     92|    spdm_test_context = libspdm_get_test_context();
   46|       |
   47|     92|    spdm_error_response_t* error_rsp;
   48|     92|    size_t error_rsp_size;
   49|       |
   50|     92|    test_message_header_size = LIBSPDM_TEST_TRANSPORT_HEADER_SIZE;
  ------------------
  |  |   27|     92|#define LIBSPDM_TEST_TRANSPORT_HEADER_SIZE  (2 + 8 + \
  |  |   28|     92|                                             LIBSPDM_TEST_SEQUENCE_NUMBER_COUNT)
  |  |  ------------------
  |  |  |  |   16|     92|#define LIBSPDM_TEST_SEQUENCE_NUMBER_COUNT 2
  |  |  ------------------
  ------------------
   51|     92|    spdm_response_size = spdm_test_context->test_buffer_size;
   52|       |
   53|     92|    if (error_large_response_sent == false) {
  ------------------
  |  Branch (53:9): [True: 1, False: 91]
  ------------------
   54|      1|        error_large_response_sent = true;
   55|       |
   56|      1|        spdm_response = (void *)((uint8_t *)temp_buf + test_message_header_size);
   57|      1|        if (spdm_response_size >
  ------------------
  |  Branch (57:13): [True: 0, False: 1]
  ------------------
   58|      1|            sizeof(temp_buf) - test_message_header_size - LIBSPDM_TEST_ALIGNMENT) {
  ------------------
  |  |   15|      1|#define LIBSPDM_TEST_ALIGNMENT 4
  ------------------
   59|      0|            spdm_response_size = sizeof(temp_buf) - test_message_header_size -
   60|      0|                                 LIBSPDM_TEST_ALIGNMENT;
  ------------------
  |  |   15|      0|#define LIBSPDM_TEST_ALIGNMENT 4
  ------------------
   61|      0|        }
   62|      1|        libspdm_copy_mem((uint8_t *)temp_buf + test_message_header_size,
   63|      1|                         sizeof(temp_buf) - test_message_header_size,
   64|      1|                         spdm_test_context->test_buffer,
   65|      1|                         spdm_response_size);
   66|       |
   67|      1|        error_rsp = (void *)(spdm_response);
   68|      1|        error_rsp_size = sizeof(spdm_error_response_t) + sizeof(uint8_t);
   69|       |
   70|      1|        error_rsp->header.request_response_code = SPDM_ERROR;
  ------------------
  |  |   37|      1|#define SPDM_ERROR 0x7F
  ------------------
   71|       |
   72|      1|        libspdm_transport_test_encode_message(
   73|      1|            spdm_context, NULL, false, false,
   74|      1|            error_rsp_size, error_rsp,
   75|      1|            response_size, response);
   76|       |
   77|      1|        return LIBSPDM_STATUS_SUCCESS;
  ------------------
  |  |   59|      1|    LIBSPDM_STATUS_CONSTRUCT(LIBSPDM_SEVERITY_SUCCESS, LIBSPDM_SOURCE_SUCCESS, 0x0000)
  |  |  ------------------
  |  |  |  |   55|      1|    ((libspdm_return_t)(((severity) << 28) | ((source) << 16) | (code)))
  |  |  ------------------
  ------------------
   78|      1|    }
   79|     91|    chunk_rsp = (void *)(spdm_response);
   80|       |
   81|     91|    chunk_rsp_size = sizeof(spdm_chunk_response_response_t)
   82|     91|                     + sizeof(uint32_t) + sizeof(spdm_algorithms_response_t);
   83|       |
   84|     91|    chunk_rsp_buf += chunk_rsp_size;
   85|     91|    if (chunk_rsp_buf + sizeof(spdm_error_response_t) + sizeof(uint8_t) > spdm_response_size) {
  ------------------
  |  Branch (85:9): [True: 45, False: 46]
  ------------------
   86|     45|        return LIBSPDM_STATUS_RECEIVE_FAIL;
  ------------------
  |  |  188|     45|    LIBSPDM_STATUS_CONSTRUCT(LIBSPDM_SEVERITY_ERROR, LIBSPDM_SOURCE_TRANSPORT, 0x0001)
  |  |  ------------------
  |  |  |  |   55|     45|    ((libspdm_return_t)(((severity) << 28) | ((source) << 16) | (code)))
  |  |  ------------------
  ------------------
   87|     45|    }
   88|       |
   89|     46|    libspdm_transport_test_encode_message(
   90|     46|        spdm_context, NULL, false, false,
   91|     46|        chunk_rsp_size, chunk_rsp,
   92|     46|        response_size, response);
   93|       |
   94|     46|    spdm_response += chunk_rsp_size;
   95|       |
   96|     46|    return LIBSPDM_STATUS_SUCCESS;
  ------------------
  |  |   59|     46|    LIBSPDM_STATUS_CONSTRUCT(LIBSPDM_SEVERITY_SUCCESS, LIBSPDM_SOURCE_SUCCESS, 0x0000)
  |  |  ------------------
  |  |  |  |   55|     46|    ((libspdm_return_t)(((severity) << 28) | ((source) << 16) | (code)))
  |  |  ------------------
  ------------------
   97|     91|}
libspdm_test_requester_chunk_get_case1:
  100|     92|{
  101|     92|    libspdm_test_context_t* spdm_test_context;
  102|     92|    libspdm_context_t* spdm_context;
  103|       |
  104|     92|    spdm_test_context = *State;
  105|     92|    spdm_context = spdm_test_context->spdm_context;
  106|       |
  107|     92|    spdm_context->connection_info.version = SPDM_MESSAGE_VERSION_12 <<
  ------------------
  |  |  112|     92|#define SPDM_MESSAGE_VERSION_12 0x12
  ------------------
  108|     92|                                            SPDM_VERSION_NUMBER_SHIFT_BIT;
  ------------------
  |  |  140|     92|#define SPDM_VERSION_NUMBER_SHIFT_BIT 8
  ------------------
  109|     92|    spdm_context->connection_info.connection_state =
  110|     92|        LIBSPDM_CONNECTION_STATE_AFTER_CAPABILITIES;
  111|     92|    spdm_context->connection_info.capability.flags |=
  112|     92|        (SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_CERT_CAP
  ------------------
  |  |  234|     92|#define SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_CERT_CAP 0x00000002
  ------------------
  113|     92|         | SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_CHUNK_CAP);
  ------------------
  |  |  274|     92|#define SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_CHUNK_CAP 0x00020000
  ------------------
  114|       |
  115|     92|    spdm_context->local_context.capability.flags |=
  116|     92|        SPDM_GET_CAPABILITIES_REQUEST_FLAGS_CHUNK_CAP;
  ------------------
  |  |  213|     92|#define SPDM_GET_CAPABILITIES_REQUEST_FLAGS_CHUNK_CAP 0x00020000
  ------------------
  117|     92|    spdm_context->local_context.capability.data_transfer_size
  118|     92|        = CHUNK_GET_REQUESTER_UNIT_TEST_DATA_TRANSFER_SIZE;
  ------------------
  |  |   16|     92|#define CHUNK_GET_REQUESTER_UNIT_TEST_DATA_TRANSFER_SIZE (44)
  ------------------
  119|       |
  120|     92|    spdm_context->local_context.algorithm.measurement_hash_algo =
  121|     92|        m_libspdm_use_measurement_hash_algo;
  122|     92|    spdm_context->local_context.algorithm.base_asym_algo = m_libspdm_use_asym_algo;
  123|     92|    spdm_context->local_context.algorithm.base_hash_algo = m_libspdm_use_hash_algo;
  124|     92|    libspdm_reset_message_a(spdm_context);
  125|       |
  126|     92|    libspdm_negotiate_algorithms(spdm_context);
  127|     92|}
libspdm_run_test_harness:
  137|     92|{
  138|     92|    void *State;
  139|       |
  140|     92|    libspdm_setup_test_context(&m_libspdm_requester_chunk_get_test_context);
  141|       |
  142|     92|    m_libspdm_requester_chunk_get_test_context.test_buffer = test_buffer;
  143|     92|    m_libspdm_requester_chunk_get_test_context.test_buffer_size =
  144|     92|        test_buffer_size;
  145|       |
  146|     92|    libspdm_unit_test_group_setup(&State);
  147|     92|    libspdm_test_requester_chunk_get_case1(&State);
  148|     92|    libspdm_unit_test_group_teardown(&State);
  149|     92|}

libspdm_transport_test_encode_message:
   85|    139|{
   86|    139|    libspdm_return_t status;
   87|    139|    void *app_message;
   88|    139|    size_t app_message_size;
   89|    139|    uint8_t *secured_message;
   90|    139|    size_t secured_message_size;
   91|    139|    libspdm_secured_message_callbacks_t spdm_secured_message_callbacks;
   92|    139|    void *secured_message_context;
   93|    139|    size_t transport_header_size;
   94|       |
   95|    139|    spdm_secured_message_callbacks.version =
   96|    139|        LIBSPDM_SECURED_MESSAGE_CALLBACKS_VERSION;
  ------------------
  |  |  224|    139|#define LIBSPDM_SECURED_MESSAGE_CALLBACKS_VERSION 2
  ------------------
   97|    139|    spdm_secured_message_callbacks.get_sequence_number =
   98|    139|        libspdm_test_get_sequence_number;
   99|    139|    spdm_secured_message_callbacks.get_max_random_number_count =
  100|    139|        libspdm_test_get_max_random_number_count;
  101|    139|    spdm_secured_message_callbacks.get_secured_spdm_version =
  102|    139|        libspdm_test_get_secured_spdm_version;
  103|       |
  104|    139|    if (is_app_message && (session_id == NULL)) {
  ------------------
  |  Branch (104:9): [True: 0, False: 139]
  |  Branch (104:27): [True: 0, False: 0]
  ------------------
  105|      0|        return LIBSPDM_STATUS_UNSUPPORTED_CAP;
  ------------------
  |  |   78|      0|    LIBSPDM_STATUS_CONSTRUCT(LIBSPDM_SEVERITY_ERROR, LIBSPDM_SOURCE_CORE, 0x0002)
  |  |  ------------------
  |  |  |  |   55|      0|    ((libspdm_return_t)(((severity) << 28) | ((source) << 16) | (code)))
  |  |  ------------------
  ------------------
  106|      0|    }
  107|       |
  108|    139|    if (session_id != NULL) {
  ------------------
  |  Branch (108:9): [True: 0, False: 139]
  ------------------
  109|      0|        secured_message_context =
  110|      0|            libspdm_get_secured_message_context_via_session_id(
  111|      0|                spdm_context, *session_id);
  112|      0|        if (secured_message_context == NULL) {
  ------------------
  |  Branch (112:13): [True: 0, False: 0]
  ------------------
  113|      0|            return LIBSPDM_STATUS_UNSUPPORTED_CAP;
  ------------------
  |  |   78|      0|    LIBSPDM_STATUS_CONSTRUCT(LIBSPDM_SEVERITY_ERROR, LIBSPDM_SOURCE_CORE, 0x0002)
  |  |  ------------------
  |  |  |  |   55|      0|    ((libspdm_return_t)(((severity) << 28) | ((source) << 16) | (code)))
  |  |  ------------------
  ------------------
  114|      0|        }
  115|       |
  116|      0|        transport_header_size = LIBSPDM_TEST_TRANSPORT_HEADER_SIZE;
  ------------------
  |  |   27|      0|#define LIBSPDM_TEST_TRANSPORT_HEADER_SIZE  (2 + 8 + \
  |  |   28|      0|                                             LIBSPDM_TEST_SEQUENCE_NUMBER_COUNT)
  |  |  ------------------
  |  |  |  |   16|      0|#define LIBSPDM_TEST_SEQUENCE_NUMBER_COUNT 2
  |  |  ------------------
  ------------------
  117|       |
  118|      0|        if (!is_app_message) {
  ------------------
  |  Branch (118:13): [True: 0, False: 0]
  ------------------
  119|       |            /* SPDM message to APP message*/
  120|      0|            app_message = NULL;
  121|      0|            app_message_size = transport_header_size + message_size + (LIBSPDM_TEST_ALIGNMENT - 1);
  ------------------
  |  |   15|      0|#define LIBSPDM_TEST_ALIGNMENT 4
  ------------------
  122|      0|            status = libspdm_test_encode_message(NULL, false, message_size,
  123|      0|                                                 message,
  124|      0|                                                 &app_message_size,
  125|      0|                                                 &app_message);
  126|      0|            if (LIBSPDM_STATUS_IS_ERROR(status)) {
  ------------------
  |  |   30|      0|    (LIBSPDM_STATUS_SEVERITY(status) == LIBSPDM_SEVERITY_ERROR)
  |  |  ------------------
  |  |  |  |   37|      0|#define LIBSPDM_STATUS_SEVERITY(status) (((status) >> 28) & 0xf)
  |  |  ------------------
  |  |                   (LIBSPDM_STATUS_SEVERITY(status) == LIBSPDM_SEVERITY_ERROR)
  |  |  ------------------
  |  |  |  |   44|      0|#define LIBSPDM_SEVERITY_ERROR 0x8
  |  |  ------------------
  |  |  |  Branch (30:5): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  127|      0|                LIBSPDM_DEBUG((LIBSPDM_DEBUG_ERROR,
  128|      0|                               "transport_encode_message - %xu\n",
  129|      0|                               status));
  130|      0|                return status;
  131|      0|            }
  132|      0|        } else {
  133|      0|            app_message = (void *)message;
  134|      0|            app_message_size = message_size;
  135|      0|        }
  136|       |        /* APP message to secured message*/
  137|      0|        secured_message = (uint8_t *)*transport_message + transport_header_size;
  138|      0|        secured_message_size = *transport_message_size - transport_header_size;
  139|      0|        status = libspdm_encode_secured_message(
  140|      0|            secured_message_context, *session_id, is_request_message,
  141|      0|            app_message_size, app_message, &secured_message_size,
  142|      0|            secured_message, &spdm_secured_message_callbacks);
  143|      0|        if (LIBSPDM_STATUS_IS_ERROR(status)) {
  ------------------
  |  |   30|      0|    (LIBSPDM_STATUS_SEVERITY(status) == LIBSPDM_SEVERITY_ERROR)
  |  |  ------------------
  |  |  |  |   37|      0|#define LIBSPDM_STATUS_SEVERITY(status) (((status) >> 28) & 0xf)
  |  |  ------------------
  |  |                   (LIBSPDM_STATUS_SEVERITY(status) == LIBSPDM_SEVERITY_ERROR)
  |  |  ------------------
  |  |  |  |   44|      0|#define LIBSPDM_SEVERITY_ERROR 0x8
  |  |  ------------------
  |  |  |  Branch (30:5): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  144|      0|            LIBSPDM_DEBUG((LIBSPDM_DEBUG_ERROR,
  145|      0|                           "libspdm_encode_secured_message - %xu\n", status));
  146|      0|            return status;
  147|      0|        }
  148|       |
  149|       |        /* secured message to secured Test message*/
  150|      0|        status = libspdm_test_encode_message(
  151|      0|            session_id, true, secured_message_size, secured_message,
  152|      0|            transport_message_size, transport_message);
  153|      0|        if (LIBSPDM_STATUS_IS_ERROR(status)) {
  ------------------
  |  |   30|      0|    (LIBSPDM_STATUS_SEVERITY(status) == LIBSPDM_SEVERITY_ERROR)
  |  |  ------------------
  |  |  |  |   37|      0|#define LIBSPDM_STATUS_SEVERITY(status) (((status) >> 28) & 0xf)
  |  |  ------------------
  |  |                   (LIBSPDM_STATUS_SEVERITY(status) == LIBSPDM_SEVERITY_ERROR)
  |  |  ------------------
  |  |  |  |   44|      0|#define LIBSPDM_SEVERITY_ERROR 0x8
  |  |  ------------------
  |  |  |  Branch (30:5): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  154|      0|            LIBSPDM_DEBUG((LIBSPDM_DEBUG_ERROR, "transport_encode_message - %xu\n",
  155|      0|                           status));
  156|      0|            return status;
  157|      0|        }
  158|    139|    } else {
  159|       |        /* SPDM message to normal Test message*/
  160|    139|        status = libspdm_test_encode_message(NULL, true, message_size, message,
  161|    139|                                             transport_message_size,
  162|    139|                                             transport_message);
  163|    139|        if (LIBSPDM_STATUS_IS_ERROR(status)) {
  ------------------
  |  |   30|    139|    (LIBSPDM_STATUS_SEVERITY(status) == LIBSPDM_SEVERITY_ERROR)
  |  |  ------------------
  |  |  |  |   37|    139|#define LIBSPDM_STATUS_SEVERITY(status) (((status) >> 28) & 0xf)
  |  |  ------------------
  |  |                   (LIBSPDM_STATUS_SEVERITY(status) == LIBSPDM_SEVERITY_ERROR)
  |  |  ------------------
  |  |  |  |   44|    139|#define LIBSPDM_SEVERITY_ERROR 0x8
  |  |  ------------------
  |  |  |  Branch (30:5): [True: 0, False: 139]
  |  |  ------------------
  ------------------
  164|      0|            LIBSPDM_DEBUG((LIBSPDM_DEBUG_ERROR, "transport_encode_message - %xu\n",
  165|      0|                           status));
  166|      0|            return status;
  167|      0|        }
  168|    139|    }
  169|       |
  170|    139|    return LIBSPDM_STATUS_SUCCESS;
  ------------------
  |  |   59|    139|    LIBSPDM_STATUS_CONSTRUCT(LIBSPDM_SEVERITY_SUCCESS, LIBSPDM_SOURCE_SUCCESS, 0x0000)
  |  |  ------------------
  |  |  |  |   55|    139|    ((libspdm_return_t)(((severity) << 28) | ((source) << 16) | (code)))
  |  |  ------------------
  ------------------
  171|    139|}
libspdm_transport_test_decode_message:
  208|     47|{
  209|     47|    libspdm_return_t status;
  210|     47|    uint32_t *secured_message_session_id;
  211|     47|    uint8_t *secured_message;
  212|     47|    size_t secured_message_size;
  213|     47|    uint8_t *app_message;
  214|     47|    size_t app_message_size;
  215|     47|    libspdm_secured_message_callbacks_t spdm_secured_message_callbacks;
  216|     47|    void *secured_message_context;
  217|     47|    libspdm_error_struct_t spdm_error;
  218|       |
  219|     47|    spdm_error.error_code = 0;
  220|     47|    spdm_error.session_id = 0;
  221|     47|    libspdm_set_last_spdm_error_struct(spdm_context, &spdm_error);
  222|       |
  223|     47|    spdm_secured_message_callbacks.version =
  224|     47|        LIBSPDM_SECURED_MESSAGE_CALLBACKS_VERSION;
  ------------------
  |  |  224|     47|#define LIBSPDM_SECURED_MESSAGE_CALLBACKS_VERSION 2
  ------------------
  225|     47|    spdm_secured_message_callbacks.get_sequence_number =
  226|     47|        libspdm_test_get_sequence_number;
  227|     47|    spdm_secured_message_callbacks.get_max_random_number_count =
  228|     47|        libspdm_test_get_max_random_number_count;
  229|     47|    spdm_secured_message_callbacks.get_secured_spdm_version =
  230|     47|        libspdm_test_get_secured_spdm_version;
  231|       |
  232|     47|    if ((session_id == NULL) || (is_app_message == NULL)) {
  ------------------
  |  Branch (232:9): [True: 0, False: 47]
  |  Branch (232:33): [True: 0, False: 47]
  ------------------
  233|      0|        return LIBSPDM_STATUS_UNSUPPORTED_CAP;
  ------------------
  |  |   78|      0|    LIBSPDM_STATUS_CONSTRUCT(LIBSPDM_SEVERITY_ERROR, LIBSPDM_SOURCE_CORE, 0x0002)
  |  |  ------------------
  |  |  |  |   55|      0|    ((libspdm_return_t)(((severity) << 28) | ((source) << 16) | (code)))
  |  |  ------------------
  ------------------
  234|      0|    }
  235|       |
  236|     47|    secured_message_session_id = NULL;
  237|       |    /* Detect received message*/
  238|     47|    status = libspdm_test_decode_message(
  239|     47|        &secured_message_session_id, true, transport_message_size,
  240|     47|        transport_message, &secured_message_size, (void **)&secured_message);
  241|     47|    if (LIBSPDM_STATUS_IS_ERROR(status)) {
  ------------------
  |  |   30|     47|    (LIBSPDM_STATUS_SEVERITY(status) == LIBSPDM_SEVERITY_ERROR)
  |  |  ------------------
  |  |  |  |   37|     47|#define LIBSPDM_STATUS_SEVERITY(status) (((status) >> 28) & 0xf)
  |  |  ------------------
  |  |                   (LIBSPDM_STATUS_SEVERITY(status) == LIBSPDM_SEVERITY_ERROR)
  |  |  ------------------
  |  |  |  |   44|     47|#define LIBSPDM_SEVERITY_ERROR 0x8
  |  |  ------------------
  |  |  |  Branch (30:5): [True: 0, False: 47]
  |  |  ------------------
  ------------------
  242|      0|        LIBSPDM_DEBUG((LIBSPDM_DEBUG_ERROR, "transport_decode_message - %xu\n", status));
  243|      0|        return status;
  244|      0|    }
  245|       |
  246|     47|    if (secured_message_session_id != NULL) {
  ------------------
  |  Branch (246:9): [True: 0, False: 47]
  ------------------
  247|      0|        *session_id = secured_message_session_id;
  248|       |
  249|      0|        secured_message_context =
  250|      0|            libspdm_get_secured_message_context_via_session_id(
  251|      0|                spdm_context, *secured_message_session_id);
  252|      0|        if (secured_message_context == NULL) {
  ------------------
  |  Branch (252:13): [True: 0, False: 0]
  ------------------
  253|      0|            spdm_error.error_code = SPDM_ERROR_CODE_INVALID_SESSION;
  ------------------
  |  |   44|      0|#define SPDM_ERROR_CODE_INVALID_SESSION 0x02
  ------------------
  254|      0|            spdm_error.session_id = *secured_message_session_id;
  255|      0|            libspdm_set_last_spdm_error_struct(spdm_context,
  256|      0|                                               &spdm_error);
  257|      0|            return LIBSPDM_STATUS_UNSUPPORTED_CAP;
  ------------------
  |  |   78|      0|    LIBSPDM_STATUS_CONSTRUCT(LIBSPDM_SEVERITY_ERROR, LIBSPDM_SOURCE_CORE, 0x0002)
  |  |  ------------------
  |  |  |  |   55|      0|    ((libspdm_return_t)(((severity) << 28) | ((source) << 16) | (code)))
  |  |  ------------------
  ------------------
  258|      0|        }
  259|       |
  260|       |        /* Secured message to APP message*/
  261|      0|        app_message = *message;
  262|      0|        app_message_size = *message_size;
  263|      0|        status = libspdm_decode_secured_message(
  264|      0|            secured_message_context, *secured_message_session_id,
  265|      0|            is_request_message, secured_message_size, secured_message,
  266|      0|            &app_message_size, (void **)&app_message,
  267|      0|            &spdm_secured_message_callbacks);
  268|      0|        if (LIBSPDM_STATUS_IS_ERROR(status)) {
  ------------------
  |  |   30|      0|    (LIBSPDM_STATUS_SEVERITY(status) == LIBSPDM_SEVERITY_ERROR)
  |  |  ------------------
  |  |  |  |   37|      0|#define LIBSPDM_STATUS_SEVERITY(status) (((status) >> 28) & 0xf)
  |  |  ------------------
  |  |                   (LIBSPDM_STATUS_SEVERITY(status) == LIBSPDM_SEVERITY_ERROR)
  |  |  ------------------
  |  |  |  |   44|      0|#define LIBSPDM_SEVERITY_ERROR 0x8
  |  |  ------------------
  |  |  |  Branch (30:5): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  269|      0|            LIBSPDM_DEBUG((LIBSPDM_DEBUG_ERROR,
  270|      0|                           "libspdm_decode_secured_message - %xu\n", status));
  271|      0|            libspdm_secured_message_get_last_spdm_error_struct(
  272|      0|                secured_message_context, &spdm_error);
  273|      0|            libspdm_set_last_spdm_error_struct(spdm_context,
  274|      0|                                               &spdm_error);
  275|      0|            return status;
  276|      0|        }
  277|       |
  278|       |        /* APP message to SPDM message.*/
  279|      0|        status = libspdm_test_decode_message(&secured_message_session_id, false,
  280|      0|                                             app_message_size, app_message,
  281|      0|                                             message_size, message);
  282|      0|        if (LIBSPDM_STATUS_IS_ERROR(status)) {
  ------------------
  |  |   30|      0|    (LIBSPDM_STATUS_SEVERITY(status) == LIBSPDM_SEVERITY_ERROR)
  |  |  ------------------
  |  |  |  |   37|      0|#define LIBSPDM_STATUS_SEVERITY(status) (((status) >> 28) & 0xf)
  |  |  ------------------
  |  |                   (LIBSPDM_STATUS_SEVERITY(status) == LIBSPDM_SEVERITY_ERROR)
  |  |  ------------------
  |  |  |  |   44|      0|#define LIBSPDM_SEVERITY_ERROR 0x8
  |  |  ------------------
  |  |  |  Branch (30:5): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  283|      0|            *is_app_message = true;
  284|       |            /* just return APP message.*/
  285|      0|            *message = app_message;
  286|      0|            *message_size = app_message_size;
  287|      0|            return LIBSPDM_STATUS_SUCCESS;
  ------------------
  |  |   59|      0|    LIBSPDM_STATUS_CONSTRUCT(LIBSPDM_SEVERITY_SUCCESS, LIBSPDM_SOURCE_SUCCESS, 0x0000)
  |  |  ------------------
  |  |  |  |   55|      0|    ((libspdm_return_t)(((severity) << 28) | ((source) << 16) | (code)))
  |  |  ------------------
  ------------------
  288|      0|        } else {
  289|      0|            *is_app_message = false;
  290|      0|            if (secured_message_session_id == NULL) {
  ------------------
  |  Branch (290:17): [True: 0, False: 0]
  ------------------
  291|      0|                return LIBSPDM_STATUS_SUCCESS;
  ------------------
  |  |   59|      0|    LIBSPDM_STATUS_CONSTRUCT(LIBSPDM_SEVERITY_SUCCESS, LIBSPDM_SOURCE_SUCCESS, 0x0000)
  |  |  ------------------
  |  |  |  |   55|      0|    ((libspdm_return_t)(((severity) << 28) | ((source) << 16) | (code)))
  |  |  ------------------
  ------------------
  292|      0|            } else {
  293|       |                /* get encapsulated secured message - cannot handle it.*/
  294|      0|                LIBSPDM_DEBUG((LIBSPDM_DEBUG_ERROR,
  295|      0|                               "transport_decode_message - expect encapsulated normal but got session (%08x)\n",
  296|      0|                               *secured_message_session_id));
  297|      0|                return LIBSPDM_STATUS_UNSUPPORTED_CAP;
  ------------------
  |  |   78|      0|    LIBSPDM_STATUS_CONSTRUCT(LIBSPDM_SEVERITY_ERROR, LIBSPDM_SOURCE_CORE, 0x0002)
  |  |  ------------------
  |  |  |  |   55|      0|    ((libspdm_return_t)(((severity) << 28) | ((source) << 16) | (code)))
  |  |  ------------------
  ------------------
  298|      0|            }
  299|      0|        }
  300|     47|    } else {
  301|       |        /* get non-secured message*/
  302|     47|        status = libspdm_test_decode_message(&secured_message_session_id, true,
  303|     47|                                             transport_message_size,
  304|     47|                                             transport_message,
  305|     47|                                             message_size, message);
  306|     47|        if (LIBSPDM_STATUS_IS_ERROR(status)) {
  ------------------
  |  |   30|     47|    (LIBSPDM_STATUS_SEVERITY(status) == LIBSPDM_SEVERITY_ERROR)
  |  |  ------------------
  |  |  |  |   37|     47|#define LIBSPDM_STATUS_SEVERITY(status) (((status) >> 28) & 0xf)
  |  |  ------------------
  |  |                   (LIBSPDM_STATUS_SEVERITY(status) == LIBSPDM_SEVERITY_ERROR)
  |  |  ------------------
  |  |  |  |   44|     47|#define LIBSPDM_SEVERITY_ERROR 0x8
  |  |  ------------------
  |  |  |  Branch (30:5): [True: 0, False: 47]
  |  |  ------------------
  ------------------
  307|      0|            LIBSPDM_DEBUG((LIBSPDM_DEBUG_ERROR, "transport_decode_message - %xu\n",
  308|      0|                           status));
  309|      0|            return status;
  310|      0|        }
  311|     47|        LIBSPDM_ASSERT(secured_message_session_id == NULL);
  312|     47|        *session_id = NULL;
  313|     47|        *is_app_message = false;
  314|     47|        return LIBSPDM_STATUS_SUCCESS;
  ------------------
  |  |   59|     47|    LIBSPDM_STATUS_CONSTRUCT(LIBSPDM_SEVERITY_SUCCESS, LIBSPDM_SOURCE_SUCCESS, 0x0000)
  |  |  ------------------
  |  |  |  |   55|     47|    ((libspdm_return_t)(((severity) << 28) | ((source) << 16) | (code)))
  |  |  ------------------
  ------------------
  315|     47|    }
  316|     47|}

libspdm_test_encode_message:
   79|    139|{
   80|    139|    size_t aligned_message_size;
   81|    139|    size_t alignment;
   82|    139|    uint32_t data32;
   83|    139|    libspdm_test_message_header_t *test_message_header;
   84|       |
   85|    139|    if (need_alignment) {
  ------------------
  |  Branch (85:9): [True: 139, False: 0]
  ------------------
   86|    139|        alignment = LIBSPDM_TEST_ALIGNMENT;
  ------------------
  |  |   15|    139|#define LIBSPDM_TEST_ALIGNMENT 4
  ------------------
   87|    139|    } else {
   88|      0|        alignment = 1;
   89|      0|    }
   90|    139|    aligned_message_size =
   91|    139|        (message_size + (alignment - 1)) & ~(alignment - 1);
   92|       |
   93|    139|    LIBSPDM_ASSERT(*transport_message_size >=
   94|    139|                   aligned_message_size + sizeof(libspdm_test_message_header_t));
   95|    139|    if (*transport_message_size <
  ------------------
  |  Branch (95:9): [True: 0, False: 139]
  ------------------
   96|    139|        aligned_message_size + sizeof(libspdm_test_message_header_t)) {
   97|      0|        *transport_message_size = aligned_message_size +
   98|      0|                                  sizeof(libspdm_test_message_header_t);
   99|      0|        return LIBSPDM_STATUS_BUFFER_TOO_SMALL;
  ------------------
  |  |  122|      0|    LIBSPDM_STATUS_CONSTRUCT(LIBSPDM_SEVERITY_ERROR, LIBSPDM_SOURCE_CORE, 0x000d)
  |  |  ------------------
  |  |  |  |   55|      0|    ((libspdm_return_t)(((severity) << 28) | ((source) << 16) | (code)))
  |  |  ------------------
  ------------------
  100|      0|    }
  101|       |
  102|    139|    *transport_message_size =
  103|    139|        aligned_message_size + sizeof(libspdm_test_message_header_t);
  104|    139|    *transport_message = (uint8_t *)message - sizeof(libspdm_test_message_header_t);
  105|    139|    test_message_header = *transport_message;
  106|    139|    if (session_id != NULL) {
  ------------------
  |  Branch (106:9): [True: 0, False: 139]
  ------------------
  107|      0|        test_message_header->message_type =
  108|      0|            LIBSPDM_TEST_MESSAGE_TYPE_SECURED_TEST;
  ------------------
  |  |   35|      0|#define LIBSPDM_TEST_MESSAGE_TYPE_SECURED_TEST 0x02
  ------------------
  109|      0|        data32 = libspdm_read_uint32((const uint8_t *)message);
  110|      0|        LIBSPDM_ASSERT(*session_id == data32);
  111|      0|        if (*session_id != data32) {
  ------------------
  |  Branch (111:13): [True: 0, False: 0]
  ------------------
  112|      0|            return LIBSPDM_STATUS_INVALID_MSG_FIELD;
  ------------------
  |  |   90|      0|    LIBSPDM_STATUS_CONSTRUCT(LIBSPDM_SEVERITY_ERROR, LIBSPDM_SOURCE_CORE, 0x0005)
  |  |  ------------------
  |  |  |  |   55|      0|    ((libspdm_return_t)(((severity) << 28) | ((source) << 16) | (code)))
  |  |  ------------------
  ------------------
  113|      0|        }
  114|    139|    } else {
  115|    139|        test_message_header->message_type = LIBSPDM_TEST_MESSAGE_TYPE_SPDM;
  ------------------
  |  |   34|    139|#define LIBSPDM_TEST_MESSAGE_TYPE_SPDM 0x01
  ------------------
  116|    139|    }
  117|    139|    libspdm_zero_mem((uint8_t *)message + message_size,
  118|    139|                     aligned_message_size - message_size);
  119|    139|    return LIBSPDM_STATUS_SUCCESS;
  ------------------
  |  |   59|    139|    LIBSPDM_STATUS_CONSTRUCT(LIBSPDM_SEVERITY_SUCCESS, LIBSPDM_SOURCE_SUCCESS, 0x0000)
  |  |  ------------------
  |  |  |  |   55|    139|    ((libspdm_return_t)(((severity) << 28) | ((source) << 16) | (code)))
  |  |  ------------------
  ------------------
  120|    139|}
libspdm_test_decode_message:
  141|     94|{
  142|     94|    const libspdm_test_message_header_t *test_message_header;
  143|       |
  144|     94|    LIBSPDM_ASSERT(transport_message_size > sizeof(libspdm_test_message_header_t));
  145|     94|    if (transport_message_size <= sizeof(libspdm_test_message_header_t)) {
  ------------------
  |  Branch (145:9): [True: 0, False: 94]
  ------------------
  146|      0|        return LIBSPDM_STATUS_INVALID_MSG_SIZE;
  ------------------
  |  |   94|      0|    LIBSPDM_STATUS_CONSTRUCT(LIBSPDM_SEVERITY_ERROR, LIBSPDM_SOURCE_CORE, 0x0006)
  |  |  ------------------
  |  |  |  |   55|      0|    ((libspdm_return_t)(((severity) << 28) | ((source) << 16) | (code)))
  |  |  ------------------
  ------------------
  147|      0|    }
  148|       |
  149|     94|    test_message_header = transport_message;
  150|       |
  151|     94|    switch (test_message_header->message_type) {
  152|      0|    case LIBSPDM_TEST_MESSAGE_TYPE_SECURED_TEST:
  ------------------
  |  |   35|      0|#define LIBSPDM_TEST_MESSAGE_TYPE_SECURED_TEST 0x02
  ------------------
  |  Branch (152:5): [True: 0, False: 94]
  ------------------
  153|      0|        LIBSPDM_ASSERT(session_id != NULL);
  154|      0|        if (session_id == NULL) {
  ------------------
  |  Branch (154:13): [True: 0, False: 0]
  ------------------
  155|      0|            return LIBSPDM_STATUS_INVALID_MSG_FIELD;
  ------------------
  |  |   90|      0|    LIBSPDM_STATUS_CONSTRUCT(LIBSPDM_SEVERITY_ERROR, LIBSPDM_SOURCE_CORE, 0x0005)
  |  |  ------------------
  |  |  |  |   55|      0|    ((libspdm_return_t)(((severity) << 28) | ((source) << 16) | (code)))
  |  |  ------------------
  ------------------
  156|      0|        }
  157|      0|        if (transport_message_size <=
  ------------------
  |  Branch (157:13): [True: 0, False: 0]
  ------------------
  158|      0|            sizeof(libspdm_test_message_header_t) + sizeof(uint32_t)) {
  159|      0|            return LIBSPDM_STATUS_INVALID_MSG_SIZE;
  ------------------
  |  |   94|      0|    LIBSPDM_STATUS_CONSTRUCT(LIBSPDM_SEVERITY_ERROR, LIBSPDM_SOURCE_CORE, 0x0006)
  |  |  ------------------
  |  |  |  |   55|      0|    ((libspdm_return_t)(((severity) << 28) | ((source) << 16) | (code)))
  |  |  ------------------
  ------------------
  160|      0|        }
  161|      0|        *session_id = (uint32_t *)((uint8_t *)transport_message +
  162|      0|                                   sizeof(libspdm_test_message_header_t));
  163|      0|        break;
  164|     94|    case LIBSPDM_TEST_MESSAGE_TYPE_SPDM:
  ------------------
  |  |   34|     94|#define LIBSPDM_TEST_MESSAGE_TYPE_SPDM 0x01
  ------------------
  |  Branch (164:5): [True: 94, False: 0]
  ------------------
  165|     94|        if (session_id != NULL) {
  ------------------
  |  Branch (165:13): [True: 94, False: 0]
  ------------------
  166|     94|            *session_id = NULL;
  167|     94|        }
  168|     94|        break;
  169|      0|    default:
  ------------------
  |  Branch (169:5): [True: 0, False: 94]
  ------------------
  170|      0|        return LIBSPDM_STATUS_UNSUPPORTED_CAP;
  ------------------
  |  |   78|      0|    LIBSPDM_STATUS_CONSTRUCT(LIBSPDM_SEVERITY_ERROR, LIBSPDM_SOURCE_CORE, 0x0002)
  |  |  ------------------
  |  |  |  |   55|      0|    ((libspdm_return_t)(((severity) << 28) | ((source) << 16) | (code)))
  |  |  ------------------
  ------------------
  171|     94|    }
  172|       |
  173|     94|    if (need_alignment) {
  ------------------
  |  Branch (173:9): [True: 94, False: 0]
  ------------------
  174|     94|        LIBSPDM_ASSERT(((transport_message_size - sizeof(libspdm_test_message_header_t)) &
  175|     94|                        (LIBSPDM_TEST_ALIGNMENT - 1)) == 0);
  176|     94|    }
  177|       |
  178|     94|    *message_size = transport_message_size - sizeof(libspdm_test_message_header_t);
  179|     94|    *message = (uint8_t *)transport_message + sizeof(libspdm_test_message_header_t);
  180|     94|    return LIBSPDM_STATUS_SUCCESS;
  ------------------
  |  |   59|     94|    LIBSPDM_STATUS_CONSTRUCT(LIBSPDM_SEVERITY_SUCCESS, LIBSPDM_SOURCE_SUCCESS, 0x0000)
  |  |  ------------------
  |  |  |  |   55|     94|    ((libspdm_return_t)(((severity) << 28) | ((source) << 16) | (code)))
  |  |  ------------------
  ------------------
  181|     94|}

