libspdm_get_scratch_buffer_secure_message_capacity:
   17|    666|uint32_t libspdm_get_scratch_buffer_secure_message_capacity(libspdm_context_t *spdm_context) {
   18|    666|    return spdm_context->local_context.capability.max_spdm_msg_size +
   19|    666|           spdm_context->local_context.capability.transport_header_size +
   20|    666|           spdm_context->local_context.capability.transport_tail_size;
   21|    666|}
libspdm_get_scratch_buffer_large_message_capacity:
   28|    666|uint32_t libspdm_get_scratch_buffer_large_message_capacity(libspdm_context_t *spdm_context) {
   29|    666|    return spdm_context->local_context.capability.max_spdm_msg_size;
   30|    666|}
libspdm_get_scratch_buffer_sender_receiver_capacity:
   43|    666|uint32_t libspdm_get_scratch_buffer_sender_receiver_capacity(libspdm_context_t *spdm_context) {
   44|    666|    return spdm_context->local_context.capability.max_spdm_msg_size +
   45|    666|           spdm_context->local_context.capability.transport_header_size +
   46|    666|           spdm_context->local_context.capability.transport_tail_size;
   47|    666|}
libspdm_get_scratch_buffer_large_sender_receiver_capacity:
   58|    666|{
   59|    666|    return spdm_context->local_context.capability.max_spdm_msg_size +
   60|    666|           spdm_context->local_context.capability.transport_header_size +
   61|    666|           spdm_context->local_context.capability.transport_tail_size;
   62|    666|}
libspdm_get_scratch_buffer_last_spdm_request_offset:
   66|    222|uint32_t libspdm_get_scratch_buffer_last_spdm_request_offset(libspdm_context_t *spdm_context) {
   67|    222|    return 0 +
   68|    222|#if LIBSPDM_ENABLE_CAPABILITY_CHUNK_CAP
   69|    222|           libspdm_get_scratch_buffer_secure_message_capacity(spdm_context) +
   70|    222|           libspdm_get_scratch_buffer_large_message_capacity(spdm_context) +
   71|    222|#endif
   72|    222|           libspdm_get_scratch_buffer_sender_receiver_capacity(spdm_context) +
   73|    222|#if LIBSPDM_ENABLE_CAPABILITY_CHUNK_CAP
   74|    222|           libspdm_get_scratch_buffer_large_sender_receiver_capacity(spdm_context) +
   75|    222|#endif
   76|    222|           0;
   77|    222|}
libspdm_get_scratch_buffer_last_spdm_request_capacity:
   79|    444|uint32_t libspdm_get_scratch_buffer_last_spdm_request_capacity(libspdm_context_t *spdm_context) {
   80|    444|    return spdm_context->local_context.capability.max_spdm_msg_size;
   81|    444|}
libspdm_get_scratch_buffer_cache_spdm_request_offset:
   85|    222|uint32_t libspdm_get_scratch_buffer_cache_spdm_request_offset(libspdm_context_t *spdm_context) {
   86|    222|    return 0 +
   87|    222|#if LIBSPDM_ENABLE_CAPABILITY_CHUNK_CAP
   88|    222|           libspdm_get_scratch_buffer_secure_message_capacity(spdm_context) +
   89|    222|           libspdm_get_scratch_buffer_large_message_capacity(spdm_context) +
   90|    222|#endif
   91|    222|           libspdm_get_scratch_buffer_sender_receiver_capacity(spdm_context) +
   92|    222|#if LIBSPDM_ENABLE_CAPABILITY_CHUNK_CAP
   93|    222|           libspdm_get_scratch_buffer_large_sender_receiver_capacity(spdm_context) +
   94|    222|#endif
   95|    222|           libspdm_get_scratch_buffer_last_spdm_request_capacity(spdm_context) +
   96|    222|           0;
   97|    222|}
libspdm_get_scratch_buffer_cache_spdm_request_capacity:
   99|    222|uint32_t libspdm_get_scratch_buffer_cache_spdm_request_capacity(libspdm_context_t *spdm_context) {
  100|    222|    return spdm_context->local_context.capability.max_spdm_msg_size;
  101|    222|}
libspdm_get_scratch_buffer_capacity:
  105|    222|uint32_t libspdm_get_scratch_buffer_capacity(libspdm_context_t *spdm_context) {
  106|    222|    return 0 +
  107|    222|#if LIBSPDM_ENABLE_CAPABILITY_CHUNK_CAP
  108|    222|           libspdm_get_scratch_buffer_secure_message_capacity(spdm_context) +
  109|    222|           libspdm_get_scratch_buffer_large_message_capacity(spdm_context) +
  110|    222|#endif
  111|    222|           libspdm_get_scratch_buffer_sender_receiver_capacity(spdm_context) +
  112|    222|#if LIBSPDM_ENABLE_CAPABILITY_CHUNK_CAP
  113|    222|           libspdm_get_scratch_buffer_large_sender_receiver_capacity(spdm_context) +
  114|    222|#endif
  115|    222|           libspdm_get_scratch_buffer_last_spdm_request_capacity(spdm_context) +
  116|    222|#if LIBSPDM_RESPOND_IF_READY_SUPPORT
  117|    222|           libspdm_get_scratch_buffer_cache_spdm_request_capacity(spdm_context) +
  118|    222|#endif
  119|    222|           0;
  120|    222|}
libspdm_reset_message_m:
 1355|     28|{
 1356|     28|    libspdm_session_info_t *spdm_session_info;
 1357|       |
 1358|     28|    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|     28|    if (spdm_session_info == NULL) {
  ------------------
  |  Branch (1366:9): [True: 28, False: 0]
  ------------------
 1367|     28|        if (spdm_context->transcript.digest_context_l1l2 != NULL) {
  ------------------
  |  Branch (1367:13): [True: 0, False: 28]
  ------------------
 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|     28|    } 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|     28|#endif
 1380|     28|}
libspdm_reset_message_buffer_via_request_code:
 1533|     28|{
 1534|     28|    libspdm_context_t *spdm_context;
 1535|       |
 1536|     28|    spdm_context = context;
 1537|       |    /**
 1538|       |     * Any request other than SPDM_GET_MEASUREMENTS resets L1/L2
 1539|       |     */
 1540|     28|    if (request_code != SPDM_GET_MEASUREMENTS) {
  ------------------
  |  |   70|     28|#define SPDM_GET_MEASUREMENTS 0xE0
  ------------------
  |  Branch (1540:9): [True: 28, False: 0]
  ------------------
 1541|     28|        libspdm_reset_message_m(spdm_context, session_info);
 1542|     28|    }
 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|     28|    switch (request_code)
 1549|     28|    {
 1550|      0|    case SPDM_KEY_EXCHANGE:
  ------------------
  |  |   77|      0|#define SPDM_KEY_EXCHANGE 0xE4
  ------------------
  |  Branch (1550:5): [True: 0, False: 28]
  ------------------
 1551|      0|    case SPDM_GET_MEASUREMENTS:
  ------------------
  |  |   70|      0|#define SPDM_GET_MEASUREMENTS 0xE0
  ------------------
  |  Branch (1551:5): [True: 0, False: 28]
  ------------------
 1552|      0|    case SPDM_FINISH:
  ------------------
  |  |   78|      0|#define SPDM_FINISH 0xE5
  ------------------
  |  Branch (1552:5): [True: 0, False: 28]
  ------------------
 1553|      0|    case SPDM_PSK_EXCHANGE:
  ------------------
  |  |   79|      0|#define SPDM_PSK_EXCHANGE 0xE6
  ------------------
  |  Branch (1553:5): [True: 0, False: 28]
  ------------------
 1554|      0|    case SPDM_PSK_FINISH:
  ------------------
  |  |   80|      0|#define SPDM_PSK_FINISH 0xE7
  ------------------
  |  Branch (1554:5): [True: 0, False: 28]
  ------------------
 1555|      0|    case SPDM_KEY_UPDATE:
  ------------------
  |  |   82|      0|#define SPDM_KEY_UPDATE 0xE9
  ------------------
  |  Branch (1555:5): [True: 0, False: 28]
  ------------------
 1556|      0|    case SPDM_HEARTBEAT:
  ------------------
  |  |   81|      0|#define SPDM_HEARTBEAT 0xE8
  ------------------
  |  Branch (1556:5): [True: 0, False: 28]
  ------------------
 1557|      0|    case SPDM_GET_ENCAPSULATED_REQUEST:
  ------------------
  |  |   83|      0|#define SPDM_GET_ENCAPSULATED_REQUEST 0xEA
  ------------------
  |  Branch (1557:5): [True: 0, False: 28]
  ------------------
 1558|      0|    case SPDM_END_SESSION:
  ------------------
  |  |   85|      0|#define SPDM_END_SESSION 0xEC
  ------------------
  |  Branch (1558:5): [True: 0, False: 28]
  ------------------
 1559|     28|    case SPDM_GET_MEASUREMENT_EXTENSION_LOG:
  ------------------
  |  |   98|     28|#define SPDM_GET_MEASUREMENT_EXTENSION_LOG 0xEF
  ------------------
  |  Branch (1559:5): [True: 28, False: 0]
  ------------------
 1560|     28|        if (spdm_context->connection_info.connection_state <
  ------------------
  |  Branch (1560:13): [True: 0, False: 28]
  ------------------
 1561|     28|            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|     28|        break;
 1568|      0|    case SPDM_DELIVER_ENCAPSULATED_RESPONSE:
  ------------------
  |  |   84|      0|#define SPDM_DELIVER_ENCAPSULATED_RESPONSE 0xEB
  ------------------
  |  Branch (1568:5): [True: 0, False: 28]
  ------------------
 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: 28]
  ------------------
 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: 28]
  ------------------
 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|      0|    default:
  ------------------
  |  Branch (1582:5): [True: 0, False: 28]
  ------------------
 1583|      0|        break;
 1584|     28|    }
 1585|     28|}
libspdm_get_connection_version:
 2632|    638|{
 2633|    638|    return (uint8_t)(spdm_context->connection_info.version >> SPDM_VERSION_NUMBER_SHIFT_BIT);
  ------------------
  |  |  140|    638|#define SPDM_VERSION_NUMBER_SHIFT_BIT 8
  ------------------
 2634|    638|}
libspdm_is_capabilities_flag_supported:
 2651|    301|{
 2652|    301|    uint32_t negotiated_requester_capabilities_flag;
 2653|    301|    uint32_t negotiated_responder_capabilities_flag;
 2654|       |
 2655|    301|    if (is_requester) {
  ------------------
  |  Branch (2655:9): [True: 0, False: 301]
  ------------------
 2656|      0|        negotiated_requester_capabilities_flag = spdm_context->local_context.capability.flags;
 2657|      0|        negotiated_responder_capabilities_flag = spdm_context->connection_info.capability.flags;
 2658|    301|    } else {
 2659|    301|        negotiated_requester_capabilities_flag = spdm_context->connection_info.capability.flags;
 2660|    301|        negotiated_responder_capabilities_flag = spdm_context->local_context.capability.flags;
 2661|    301|    }
 2662|       |
 2663|    301|    if (((requester_capabilities_flag == 0) ||
  ------------------
  |  Branch (2663:10): [True: 154, False: 147]
  ------------------
 2664|    301|         ((negotiated_requester_capabilities_flag &
  ------------------
  |  Branch (2664:10): [True: 0, False: 147]
  ------------------
 2665|    147|           requester_capabilities_flag) != 0)) &&
 2666|    301|        ((responder_capabilities_flag == 0) ||
  ------------------
  |  Branch (2666:10): [True: 0, False: 154]
  ------------------
 2667|    154|         ((negotiated_responder_capabilities_flag &
  ------------------
  |  Branch (2667:10): [True: 154, False: 0]
  ------------------
 2668|    154|           responder_capabilities_flag) != 0))) {
 2669|    154|        return true;
 2670|    154|    } else {
 2671|    147|        return false;
 2672|    147|    }
 2673|    301|}
libspdm_register_device_io_func:
 2720|    222|{
 2721|    222|    libspdm_context_t *context;
 2722|       |
 2723|    222|    context = spdm_context;
 2724|    222|    context->send_message = send_message;
 2725|    222|    context->receive_message = receive_message;
 2726|    222|}
libspdm_register_device_buffer_func:
 2779|    222|{
 2780|    222|    libspdm_context_t *context;
 2781|       |
 2782|    222|    context = spdm_context;
 2783|    222|    context->sender_buffer_size = sender_buffer_size;
 2784|    222|    context->receiver_buffer_size = receiver_buffer_size;
 2785|    222|    context->acquire_sender_buffer = acquire_sender_buffer;
 2786|    222|    context->release_sender_buffer = release_sender_buffer;
 2787|    222|    context->acquire_receiver_buffer = acquire_receiver_buffer;
 2788|    222|    context->release_receiver_buffer = release_receiver_buffer;
 2789|       |
 2790|    222|    LIBSPDM_ASSERT (sender_buffer_size >=
 2791|    222|                    context->local_context.capability.transport_header_size +
 2792|    222|                    context->local_context.capability.transport_tail_size);
 2793|    222|    sender_buffer_size -= (context->local_context.capability.transport_header_size +
 2794|    222|                           context->local_context.capability.transport_tail_size);
 2795|    222|    LIBSPDM_ASSERT (sender_buffer_size >= SPDM_MIN_DATA_TRANSFER_SIZE_VERSION_12);
 2796|    222|    context->local_context.capability.sender_data_transfer_size = sender_buffer_size;
 2797|       |
 2798|    222|    LIBSPDM_ASSERT(receiver_buffer_size >=
 2799|    222|                   context->local_context.capability.transport_header_size +
 2800|    222|                   context->local_context.capability.transport_tail_size);
 2801|    222|    receiver_buffer_size -= (context->local_context.capability.transport_header_size +
 2802|    222|                             context->local_context.capability.transport_tail_size);
 2803|    222|    LIBSPDM_ASSERT (receiver_buffer_size >= SPDM_MIN_DATA_TRANSFER_SIZE_VERSION_12);
 2804|    222|    context->local_context.capability.data_transfer_size = receiver_buffer_size;
 2805|    222|}
libspdm_register_transport_layer_func:
 2823|    222|{
 2824|    222|    libspdm_context_t *context;
 2825|       |
 2826|    222|    context = spdm_context;
 2827|       |
 2828|       |    /* fix the data_transfer_size if it is set before */
 2829|    222|    if ((context->local_context.capability.data_transfer_size != 0) &&
  ------------------
  |  Branch (2829:9): [True: 0, False: 222]
  ------------------
 2830|    222|        (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|    222|    if ((context->local_context.capability.sender_data_transfer_size != 0) &&
  ------------------
  |  Branch (2836:9): [True: 0, False: 222]
  ------------------
 2837|    222|        (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|    222|    context->local_context.capability.max_spdm_msg_size = max_spdm_msg_size;
 2845|    222|    context->local_context.capability.transport_header_size = transport_header_size;
 2846|    222|    context->local_context.capability.transport_tail_size = transport_tail_size;
 2847|    222|    context->transport_encode_message = transport_encode_message;
 2848|    222|    context->transport_decode_message = transport_decode_message;
 2849|    222|}
libspdm_get_sizeof_required_scratch_buffer:
 2886|    222|{
 2887|    222|    libspdm_context_t *context;
 2888|    222|    size_t scratch_buffer_size;
 2889|       |
 2890|    222|    context = spdm_context;
 2891|    222|    LIBSPDM_ASSERT (context->local_context.capability.max_spdm_msg_size != 0);
 2892|       |
 2893|    222|    scratch_buffer_size = libspdm_get_scratch_buffer_capacity(context);
 2894|    222|    return scratch_buffer_size;
 2895|    222|}
libspdm_set_scratch_buffer:
 2911|    222|{
 2912|    222|    libspdm_context_t *context;
 2913|       |
 2914|    222|    context = spdm_context;
 2915|    222|    LIBSPDM_ASSERT (context->local_context.capability.max_spdm_msg_size != 0);
 2916|    222|    LIBSPDM_ASSERT (scratch_buffer_size >= libspdm_get_scratch_buffer_capacity(spdm_context));
 2917|    222|    context->scratch_buffer = scratch_buffer;
 2918|    222|    context->scratch_buffer_size = scratch_buffer_size;
 2919|    222|    context->last_spdm_request = (uint8_t *)scratch_buffer +
 2920|    222|                                 libspdm_get_scratch_buffer_last_spdm_request_offset(spdm_context);
 2921|    222|#if LIBSPDM_RESPOND_IF_READY_SUPPORT
 2922|    222|    context->cache_spdm_request = (uint8_t *)scratch_buffer +
 2923|    222|                                  libspdm_get_scratch_buffer_cache_spdm_request_offset(spdm_context);
 2924|    222|#endif
 2925|    222|}
libspdm_init_context_with_secured_context:
 3240|    222|{
 3241|    222|    libspdm_context_t *context;
 3242|    222|    size_t index;
 3243|       |
 3244|    222|    LIBSPDM_ASSERT(spdm_context != NULL);
 3245|    222|    LIBSPDM_ASSERT(secured_contexts != NULL);
 3246|    222|    LIBSPDM_ASSERT(num_secured_contexts == LIBSPDM_MAX_SESSION_COUNT);
 3247|       |
 3248|    222|    context = spdm_context;
 3249|    222|    libspdm_zero_mem(context, sizeof(libspdm_context_t));
 3250|    222|    context->version = LIBSPDM_CONTEXT_STRUCT_VERSION;
  ------------------
  |  |  527|    222|#define LIBSPDM_CONTEXT_STRUCT_VERSION 0x3
  ------------------
 3251|    222|    context->transcript.message_a.max_buffer_size =
 3252|    222|        sizeof(context->transcript.message_a.buffer);
 3253|    222|    context->transcript.message_d.max_buffer_size =
 3254|    222|        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|    222|    context->response_state = LIBSPDM_RESPONSE_STATE_NORMAL;
 3272|    222|    context->local_context.version.spdm_version_count = SPDM_MAX_VERSION_COUNT;
  ------------------
  |  |   17|    222|#define SPDM_MAX_VERSION_COUNT 4
  ------------------
 3273|    222|    context->local_context.version.spdm_version[0] = SPDM_MESSAGE_VERSION_10 <<
  ------------------
  |  |  110|    222|#define SPDM_MESSAGE_VERSION_10 0x10
  ------------------
 3274|    222|                                                     SPDM_VERSION_NUMBER_SHIFT_BIT;
  ------------------
  |  |  140|    222|#define SPDM_VERSION_NUMBER_SHIFT_BIT 8
  ------------------
 3275|    222|    context->local_context.version.spdm_version[1] = SPDM_MESSAGE_VERSION_11 <<
  ------------------
  |  |  111|    222|#define SPDM_MESSAGE_VERSION_11 0x11
  ------------------
 3276|    222|                                                     SPDM_VERSION_NUMBER_SHIFT_BIT;
  ------------------
  |  |  140|    222|#define SPDM_VERSION_NUMBER_SHIFT_BIT 8
  ------------------
 3277|    222|    context->local_context.version.spdm_version[2] = SPDM_MESSAGE_VERSION_12 <<
  ------------------
  |  |  112|    222|#define SPDM_MESSAGE_VERSION_12 0x12
  ------------------
 3278|    222|                                                     SPDM_VERSION_NUMBER_SHIFT_BIT;
  ------------------
  |  |  140|    222|#define SPDM_VERSION_NUMBER_SHIFT_BIT 8
  ------------------
 3279|    222|    context->local_context.version.spdm_version[3] = SPDM_MESSAGE_VERSION_13 <<
  ------------------
  |  |  113|    222|#define SPDM_MESSAGE_VERSION_13 0x13
  ------------------
 3280|    222|                                                     SPDM_VERSION_NUMBER_SHIFT_BIT;
  ------------------
  |  |  140|    222|#define SPDM_VERSION_NUMBER_SHIFT_BIT 8
  ------------------
 3281|    222|    context->local_context.secured_message_version.spdm_version_count =
 3282|    222|        SECURED_SPDM_MAX_VERSION_COUNT;
  ------------------
  |  |   55|    222|#define SECURED_SPDM_MAX_VERSION_COUNT 3
  ------------------
 3283|    222|    context->local_context.secured_message_version.spdm_version[0] =
 3284|    222|        SECURED_SPDM_VERSION_10 << SPDM_VERSION_NUMBER_SHIFT_BIT;
  ------------------
  |  |   57|    222|#define SECURED_SPDM_VERSION_10 0x10
  ------------------
                      SECURED_SPDM_VERSION_10 << SPDM_VERSION_NUMBER_SHIFT_BIT;
  ------------------
  |  |  140|    222|#define SPDM_VERSION_NUMBER_SHIFT_BIT 8
  ------------------
 3285|    222|    context->local_context.secured_message_version.spdm_version[1] =
 3286|    222|        SECURED_SPDM_VERSION_11 << SPDM_VERSION_NUMBER_SHIFT_BIT;
  ------------------
  |  |   58|    222|#define SECURED_SPDM_VERSION_11 0x11
  ------------------
                      SECURED_SPDM_VERSION_11 << SPDM_VERSION_NUMBER_SHIFT_BIT;
  ------------------
  |  |  140|    222|#define SPDM_VERSION_NUMBER_SHIFT_BIT 8
  ------------------
 3287|    222|    context->local_context.secured_message_version.spdm_version[2] =
 3288|    222|        SECURED_SPDM_VERSION_12 << SPDM_VERSION_NUMBER_SHIFT_BIT;
  ------------------
  |  |   59|    222|#define SECURED_SPDM_VERSION_12 0x12
  ------------------
                      SECURED_SPDM_VERSION_12 << SPDM_VERSION_NUMBER_SHIFT_BIT;
  ------------------
  |  |  140|    222|#define SPDM_VERSION_NUMBER_SHIFT_BIT 8
  ------------------
 3289|    222|    context->local_context.capability.st1 = SPDM_ST1_VALUE_US;
  ------------------
  |  | 1514|    222|#define SPDM_ST1_VALUE_US 100000
  ------------------
 3290|       |
 3291|    222|    context->mut_auth_cert_chain_buffer_size = 0;
 3292|       |
 3293|    222|    context->max_spdm_session_sequence_number = LIBSPDM_MAX_SPDM_SESSION_SEQUENCE_NUMBER;
  ------------------
  |  |   39|    222|#define LIBSPDM_MAX_SPDM_SESSION_SEQUENCE_NUMBER 0xFFFFFFFFFFFFFFFFull
  ------------------
 3294|       |
 3295|    222|    context->latest_session_id = INVALID_SESSION_ID;
  ------------------
  |  |   28|    222|#define INVALID_SESSION_ID 0
  ------------------
 3296|    222|    context->last_spdm_request_session_id = INVALID_SESSION_ID;
  ------------------
  |  |   28|    222|#define INVALID_SESSION_ID 0
  ------------------
 3297|    222|    context->last_spdm_request_session_id_valid = false;
 3298|    222|    context->last_spdm_request_size = 0;
 3299|       |
 3300|       |    /* To be updated in libspdm_register_device_buffer_func */
 3301|    222|    context->local_context.capability.data_transfer_size = 0;
 3302|    222|    context->local_context.capability.sender_data_transfer_size = 0;
 3303|    222|    context->local_context.capability.max_spdm_msg_size = 0;
 3304|       |
 3305|  1.11k|    for (index = 0; index < num_secured_contexts; index++) {
  ------------------
  |  Branch (3305:21): [True: 888, False: 222]
  ------------------
 3306|    888|        if (secured_contexts[index] == NULL) {
  ------------------
  |  Branch (3306:13): [True: 0, False: 888]
  ------------------
 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|    888|        context->session_info[index].secured_message_context = secured_contexts[index];
 3311|    888|        libspdm_secured_message_init_context(
 3312|    888|            context->session_info[index].secured_message_context);
 3313|    888|    }
 3314|       |
 3315|    222|    return LIBSPDM_STATUS_SUCCESS;
  ------------------
  |  |   59|    222|    LIBSPDM_STATUS_CONSTRUCT(LIBSPDM_SEVERITY_SUCCESS, LIBSPDM_SOURCE_SUCCESS, 0x0000)
  |  |  ------------------
  |  |  |  |   55|    222|    ((libspdm_return_t)(((severity) << 28) | ((source) << 16) | (code)))
  |  |  ------------------
  ------------------
 3316|    222|}
libspdm_init_context:
 3331|    222|{
 3332|    222|    libspdm_context_t *context;
 3333|    222|    void *secured_context;
 3334|    222|    void *secured_contexts[LIBSPDM_MAX_SESSION_COUNT];
 3335|    222|    size_t secured_context_size;
 3336|    222|    size_t index;
 3337|       |
 3338|    222|    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|    222|    context = spdm_context;
 3343|    222|    secured_context = (void *)((size_t)(context + 1));
 3344|    222|    secured_context_size = libspdm_secured_message_get_context_size();
 3345|       |
 3346|  1.11k|    for (index = 0; index < LIBSPDM_MAX_SESSION_COUNT; index++)
  ------------------
  |  |  198|  1.11k|#define LIBSPDM_MAX_SESSION_COUNT 4
  ------------------
  |  Branch (3346:21): [True: 888, False: 222]
  ------------------
 3347|    888|    {
 3348|    888|        secured_contexts[index] = (uint8_t *)secured_context + secured_context_size * index;
 3349|    888|    }
 3350|       |
 3351|    222|    return libspdm_init_context_with_secured_context(spdm_context,
 3352|    222|                                                     secured_contexts,
 3353|    222|                                                     LIBSPDM_MAX_SESSION_COUNT);
  ------------------
  |  |  198|    222|#define LIBSPDM_MAX_SESSION_COUNT 4
  ------------------
 3354|    222|}
libspdm_get_context_size:
 3467|    222|{
 3468|    222|    size_t size;
 3469|       |
 3470|    222|    size = sizeof(libspdm_context_t) +
 3471|    222|           libspdm_secured_message_get_context_size() * LIBSPDM_MAX_SESSION_COUNT;
  ------------------
  |  |  198|    222|#define LIBSPDM_MAX_SESSION_COUNT 4
  ------------------
 3472|    222|    LIBSPDM_ASSERT (size == LIBSPDM_CONTEXT_SIZE_ALL);
 3473|    222|    return size;
 3474|    222|}

libspdm_write_uint24:
  156|    441|{
  157|    441|    buffer[0] = (uint8_t)(value & 0xFF);
  158|    441|    buffer[1] = (uint8_t)((value >> 8) & 0xFF);
  159|    441|    buffer[2] = (uint8_t)((value >> 16) & 0xFF);
  160|    441|}

libspdm_generate_error_response:
   14|    194|{
   15|    194|    spdm_error_response_t *spdm_response;
   16|       |
   17|    194|    LIBSPDM_ASSERT(*response_size >= sizeof(spdm_error_response_t));
   18|    194|    *response_size = sizeof(spdm_error_response_t);
   19|    194|    spdm_response = response;
   20|       |
   21|    194|    spdm_response->header.spdm_version = libspdm_get_connection_version (spdm_context);
   22|    194|    if (spdm_response->header.spdm_version == 0) {
  ------------------
  |  Branch (22:9): [True: 0, False: 194]
  ------------------
   23|       |        /* if version is not negotiated, then use default version 1.0 */
   24|      0|        spdm_response->header.spdm_version = SPDM_MESSAGE_VERSION_10;
  ------------------
  |  |  110|      0|#define SPDM_MESSAGE_VERSION_10 0x10
  ------------------
   25|      0|    }
   26|    194|    spdm_response->header.request_response_code = SPDM_ERROR;
  ------------------
  |  |   37|    194|#define SPDM_ERROR 0x7F
  ------------------
   27|    194|    spdm_response->header.param1 = error_code;
   28|    194|    spdm_response->header.param2 = error_data;
   29|       |
   30|    194|    if (spdm_response->header.spdm_version <= SPDM_MESSAGE_VERSION_11) {
  ------------------
  |  |  111|    194|#define SPDM_MESSAGE_VERSION_11 0x11
  ------------------
  |  Branch (30:9): [True: 0, False: 194]
  ------------------
   31|      0|        LIBSPDM_ASSERT ((error_code != SPDM_ERROR_CODE_RESPONSE_TOO_LARGE) &&
   32|      0|                        (error_code != SPDM_ERROR_CODE_LARGE_RESPONSE));
   33|      0|    }
   34|       |
   35|    194|    return LIBSPDM_STATUS_SUCCESS;
  ------------------
  |  |   59|    194|    LIBSPDM_STATUS_CONSTRUCT(LIBSPDM_SEVERITY_SUCCESS, LIBSPDM_SOURCE_SUCCESS, 0x0000)
  |  |  ------------------
  |  |  |  |   55|    194|    ((libspdm_return_t)(((severity) << 28) | ((source) << 16) | (code)))
  |  |  ------------------
  ------------------
   36|    194|}

libspdm_get_response_measurement_extension_log:
   15|    222|{
   16|    222|    const spdm_get_measurement_extension_log_request_t *spdm_request;
   17|    222|    spdm_measurement_extension_log_response_t *spdm_response;
   18|    222|    uint32_t offset;
   19|    222|    uint32_t length;
   20|    222|    size_t remainder_length;
   21|    222|    size_t response_capacity;
   22|    222|    libspdm_session_info_t *session_info;
   23|    222|    libspdm_session_state_t session_state;
   24|    222|    spdm_measurement_extension_log_dmtf_t *spdm_mel;
   25|    222|    size_t spdm_mel_len;
   26|       |
   27|    222|    spdm_request = request;
   28|       |
   29|       |    /* -=[Check Parameters Phase]=- */
   30|    222|    LIBSPDM_ASSERT(spdm_request->header.request_response_code ==
   31|    222|                   SPDM_GET_MEASUREMENT_EXTENSION_LOG);
   32|       |
   33|    222|    if (libspdm_get_connection_version(spdm_context) < SPDM_MESSAGE_VERSION_13) {
  ------------------
  |  |  113|    222|#define SPDM_MESSAGE_VERSION_13 0x13
  ------------------
  |  Branch (33:9): [True: 0, False: 222]
  ------------------
   34|      0|        return libspdm_generate_error_response(spdm_context,
   35|      0|                                               SPDM_ERROR_CODE_UNSUPPORTED_REQUEST,
  ------------------
  |  |  859|      0|#define SPDM_ERROR_CODE_UNSUPPORTED_REQUEST 0x07
  ------------------
   36|      0|                                               SPDM_GET_MEASUREMENT_EXTENSION_LOG,
  ------------------
  |  |   98|      0|#define SPDM_GET_MEASUREMENT_EXTENSION_LOG 0xEF
  ------------------
   37|      0|                                               response_size, response);
   38|      0|    }
   39|       |
   40|    222|    if (spdm_request->header.spdm_version != libspdm_get_connection_version(spdm_context)) {
  ------------------
  |  Branch (40:9): [True: 68, False: 154]
  ------------------
   41|     68|        return libspdm_generate_error_response(spdm_context,
   42|     68|                                               SPDM_ERROR_CODE_VERSION_MISMATCH, 0,
  ------------------
  |  |  860|     68|#define SPDM_ERROR_CODE_VERSION_MISMATCH 0x41
  ------------------
   43|     68|                                               response_size, response);
   44|     68|    }
   45|    154|    if (spdm_context->response_state != LIBSPDM_RESPONSE_STATE_NORMAL) {
  ------------------
  |  Branch (45:9): [True: 0, False: 154]
  ------------------
   46|      0|        return libspdm_responder_handle_response_state(
   47|      0|            spdm_context,
   48|      0|            spdm_request->header.request_response_code,
   49|      0|            response_size, response);
   50|      0|    }
   51|    154|    if (spdm_context->connection_info.connection_state < LIBSPDM_CONNECTION_STATE_NEGOTIATED) {
  ------------------
  |  Branch (51:9): [True: 0, False: 154]
  ------------------
   52|      0|        return libspdm_generate_error_response(spdm_context,
   53|      0|                                               SPDM_ERROR_CODE_UNEXPECTED_REQUEST,
  ------------------
  |  |  857|      0|#define SPDM_ERROR_CODE_UNEXPECTED_REQUEST 0x04
  ------------------
   54|      0|                                               0, response_size, response);
   55|      0|    }
   56|       |
   57|    154|    session_info = NULL;
   58|    154|    if (spdm_context->last_spdm_request_session_id_valid) {
  ------------------
  |  Branch (58:9): [True: 0, False: 154]
  ------------------
   59|      0|        session_info = libspdm_get_session_info_via_session_id(
   60|      0|            spdm_context,
   61|      0|            spdm_context->last_spdm_request_session_id);
   62|      0|        if (session_info == NULL) {
  ------------------
  |  Branch (62:13): [True: 0, False: 0]
  ------------------
   63|      0|            return libspdm_generate_error_response(
   64|      0|                spdm_context,
   65|      0|                SPDM_ERROR_CODE_UNEXPECTED_REQUEST, 0,
  ------------------
  |  |  857|      0|#define SPDM_ERROR_CODE_UNEXPECTED_REQUEST 0x04
  ------------------
   66|      0|                response_size, response);
   67|      0|        }
   68|      0|        session_state = libspdm_secured_message_get_session_state(
   69|      0|            session_info->secured_message_context);
   70|      0|        if (session_state != LIBSPDM_SESSION_STATE_ESTABLISHED) {
  ------------------
  |  Branch (70:13): [True: 0, False: 0]
  ------------------
   71|      0|            return libspdm_generate_error_response(
   72|      0|                spdm_context,
   73|      0|                SPDM_ERROR_CODE_UNEXPECTED_REQUEST, 0,
  ------------------
  |  |  857|      0|#define SPDM_ERROR_CODE_UNEXPECTED_REQUEST 0x04
  ------------------
   74|      0|                response_size, response);
   75|      0|        }
   76|      0|    }
   77|    154|    if (!libspdm_is_capabilities_flag_supported(
  ------------------
  |  Branch (77:9): [True: 0, False: 154]
  ------------------
   78|    154|            spdm_context, false, 0,
   79|    154|            SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MEL_CAP)) {
  ------------------
  |  |  293|    154|#define SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MEL_CAP 0x01000000
  ------------------
   80|      0|        return libspdm_generate_error_response(
   81|      0|            spdm_context, SPDM_ERROR_CODE_UNSUPPORTED_REQUEST,
  ------------------
  |  |  859|      0|#define SPDM_ERROR_CODE_UNSUPPORTED_REQUEST 0x07
  ------------------
   82|      0|            SPDM_GET_MEASUREMENT_EXTENSION_LOG, response_size, response);
  ------------------
  |  |   98|      0|#define SPDM_GET_MEASUREMENT_EXTENSION_LOG 0xEF
  ------------------
   83|      0|    }
   84|       |
   85|    154|    if ((spdm_context->connection_info.algorithm.mel_spec == 0) ||
  ------------------
  |  Branch (85:9): [True: 0, False: 154]
  ------------------
   86|    154|        (spdm_context->connection_info.algorithm.measurement_hash_algo == 0) ) {
  ------------------
  |  Branch (86:9): [True: 0, False: 154]
  ------------------
   87|      0|        return libspdm_generate_error_response(
   88|      0|            spdm_context, SPDM_ERROR_CODE_UNEXPECTED_REQUEST,
  ------------------
  |  |  857|      0|#define SPDM_ERROR_CODE_UNEXPECTED_REQUEST 0x04
  ------------------
   89|      0|            0, response_size, response);
   90|      0|    }
   91|       |
   92|    154|    if (request_size < sizeof(spdm_get_measurement_extension_log_request_t)) {
  ------------------
  |  Branch (92:9): [True: 7, False: 147]
  ------------------
   93|      7|        return libspdm_generate_error_response(spdm_context,
   94|      7|                                               SPDM_ERROR_CODE_INVALID_REQUEST, 0,
  ------------------
  |  |  855|      7|#define SPDM_ERROR_CODE_INVALID_REQUEST 0x01
  ------------------
   95|      7|                                               response_size, response);
   96|      7|    }
   97|       |
   98|    147|    offset = spdm_request->offset;
   99|    147|    length = spdm_request->length;
  100|       |
  101|    147|    if (!libspdm_is_capabilities_flag_supported(spdm_context, false,
  ------------------
  |  Branch (101:9): [True: 147, False: 0]
  ------------------
  102|    147|                                                SPDM_GET_CAPABILITIES_REQUEST_FLAGS_CHUNK_CAP,
  ------------------
  |  |  213|    147|#define SPDM_GET_CAPABILITIES_REQUEST_FLAGS_CHUNK_CAP 0x00020000
  ------------------
  103|    147|                                                SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_CHUNK_CAP)) {
  ------------------
  |  |  274|    147|#define SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_CHUNK_CAP 0x00020000
  ------------------
  104|    147|        if (length > LIBSPDM_MAX_MEL_BLOCK_LEN) {
  ------------------
  |  |  225|    147|#define LIBSPDM_MAX_MEL_BLOCK_LEN 1024
  ------------------
  |  Branch (104:13): [True: 68, False: 79]
  ------------------
  105|     68|            length = LIBSPDM_MAX_MEL_BLOCK_LEN;
  ------------------
  |  |  225|     68|#define LIBSPDM_MAX_MEL_BLOCK_LEN 1024
  ------------------
  106|     68|        }
  107|    147|    }
  108|       |
  109|    147|    spdm_mel = NULL;
  110|    147|    spdm_mel_len = 0;
  111|    147|    if (!libspdm_measurement_extension_log_collection(
  ------------------
  |  Branch (111:9): [True: 0, False: 147]
  ------------------
  112|    147|            spdm_context,
  113|    147|            spdm_context->connection_info.algorithm.mel_spec,
  114|    147|            spdm_context->connection_info.algorithm.measurement_spec,
  115|    147|            spdm_context->connection_info.algorithm.measurement_hash_algo,
  116|    147|            (void **)&spdm_mel, &spdm_mel_len)) {
  117|      0|        return libspdm_generate_error_response(spdm_context,
  118|      0|                                               SPDM_ERROR_CODE_OPERATION_FAILED, 0,
  ------------------
  |  |  881|      0|#define SPDM_ERROR_CODE_OPERATION_FAILED 0x44
  ------------------
  119|      0|                                               response_size, response);
  120|      0|    }
  121|       |
  122|    147|    if (offset >= spdm_mel_len) {
  ------------------
  |  Branch (122:9): [True: 119, False: 28]
  ------------------
  123|    119|        return libspdm_generate_error_response(spdm_context,
  124|    119|                                               SPDM_ERROR_CODE_INVALID_REQUEST, 0,
  ------------------
  |  |  855|    119|#define SPDM_ERROR_CODE_INVALID_REQUEST 0x01
  ------------------
  125|    119|                                               response_size, response);
  126|    119|    }
  127|       |
  128|     28|    if ((uint64_t)(offset + length) > spdm_mel_len) {
  ------------------
  |  Branch (128:9): [True: 24, False: 4]
  ------------------
  129|     24|        length = (uint32_t)(spdm_mel_len - offset);
  130|     24|    }
  131|     28|    remainder_length = spdm_mel_len - (length + offset);
  132|       |
  133|     28|    libspdm_reset_message_buffer_via_request_code(spdm_context, session_info,
  134|     28|                                                  spdm_request->header.request_response_code);
  135|       |
  136|     28|    LIBSPDM_ASSERT(*response_size >= sizeof(spdm_measurement_extension_log_response_t) + length);
  137|       |
  138|     28|    response_capacity = *response_size;
  139|     28|    *response_size = sizeof(spdm_measurement_extension_log_response_t) + length;
  140|     28|    libspdm_zero_mem(response, *response_size);
  141|     28|    spdm_response = response;
  142|       |
  143|     28|    spdm_response->header.spdm_version = spdm_request->header.spdm_version;
  144|     28|    spdm_response->header.request_response_code = SPDM_MEASUREMENT_EXTENSION_LOG;
  ------------------
  |  |   61|     28|#define SPDM_MEASUREMENT_EXTENSION_LOG 0x6F
  ------------------
  145|     28|    spdm_response->header.param1 = 0;
  146|     28|    spdm_response->header.param2 = 0;
  147|       |
  148|     28|    spdm_response->portion_length = length;
  149|     28|    spdm_response->remainder_length = (uint32_t)remainder_length;
  150|       |
  151|     28|    libspdm_copy_mem(spdm_response + 1,
  152|     28|                     response_capacity - sizeof(spdm_measurement_extension_log_response_t),
  153|     28|                     (const uint8_t *)spdm_mel + offset, length);
  154|       |
  155|     28|    return LIBSPDM_STATUS_SUCCESS;
  ------------------
  |  |   59|     28|    LIBSPDM_STATUS_CONSTRUCT(LIBSPDM_SEVERITY_SUCCESS, LIBSPDM_SOURCE_SUCCESS, 0x0000)
  |  |  ------------------
  |  |  |  |   55|     28|    ((libspdm_return_t)(((severity) << 28) | ((source) << 16) | (code)))
  |  |  ------------------
  ------------------
  156|    147|}

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

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

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

libspdm_zero_mem:
   17|  1.13k|{
   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|  1.13k|    volatile uint8_t *pointer;
   27|       |
   28|  1.13k|    pointer = (uint8_t *)buffer;
   29|  2.78M|    while (length-- != 0) {
  ------------------
  |  Branch (29:12): [True: 2.78M, False: 1.13k]
  ------------------
   30|  2.78M|        *(pointer++) = 0;
   31|  2.78M|    }
   32|       |
   33|       |#if defined(_MSC_VER) && (_MSC_VER > 1200) && !defined(__clang__)
   34|       |    _ReadWriteBarrier();
   35|       |#elif defined(__GNUC__)
   36|       |    __asm__ __volatile__ ("" : : : "memory");
   37|  1.13k|#endif
   38|       |
   39|  1.13k|#endif
   40|  1.13k|}

libspdm_generate_mel:
   30|    147|{
   31|    147|    spdm_measurement_extension_log_dmtf_t *measurement_extension_log;
   32|    147|    spdm_mel_entry_dmtf_t *mel_entry1;
   33|    147|    spdm_mel_entry_dmtf_t *mel_entry2;
   34|    147|    spdm_mel_entry_dmtf_t *mel_entry3;
   35|       |
   36|    147|    uint8_t rom_informational[] = "ROM";
   37|    147|    uint8_t bootfv_informational[] = "Boot FW";
   38|    147|    uint32_t version = 0x0100030A;
   39|       |
   40|       |    /*generate MEL*/
   41|    147|    measurement_extension_log = (spdm_measurement_extension_log_dmtf_t *)m_libspdm_mel;
   42|       |
   43|    147|    measurement_extension_log->number_of_entries = 3;
   44|    147|    measurement_extension_log->mel_entries_len =
   45|    147|        measurement_extension_log->number_of_entries * sizeof(spdm_mel_entry_dmtf_t) +
   46|    147|        sizeof(rom_informational) - 1 + sizeof(bootfv_informational) - 1 + sizeof(version);
   47|    147|    measurement_extension_log->reserved = 0;
   48|       |
   49|       |    /*MEL Entry 1: informational ROM */
   50|    147|    mel_entry1 = (spdm_mel_entry_dmtf_t *)((uint8_t *)measurement_extension_log +
   51|    147|                                           sizeof(spdm_measurement_extension_log_dmtf_t));
   52|    147|    mel_entry1->mel_index = 1;
   53|    147|    mel_entry1->meas_index = LIBSPDM_MEASUREMENT_INDEX_HEM;
  ------------------
  |  |   34|    147|#define LIBSPDM_MEASUREMENT_INDEX_HEM 0x11
  ------------------
   54|    147|    libspdm_write_uint24(mel_entry1->reserved, 0);
   55|    147|    mel_entry1->measurement_block_dmtf_header.dmtf_spec_measurement_value_type =
   56|    147|        SPDM_MEASUREMENT_BLOCK_MEASUREMENT_TYPE_INFORMATIONAL |
  ------------------
  |  |  781|    147|#define SPDM_MEASUREMENT_BLOCK_MEASUREMENT_TYPE_INFORMATIONAL 9
  ------------------
   57|    147|        SPDM_MEASUREMENT_BLOCK_MEASUREMENT_TYPE_RAW_BIT_STREAM;
  ------------------
  |  |  784|    147|#define SPDM_MEASUREMENT_BLOCK_MEASUREMENT_TYPE_RAW_BIT_STREAM 0x00000080
  ------------------
   58|    147|    mel_entry1->measurement_block_dmtf_header.dmtf_spec_measurement_value_size =
   59|    147|        sizeof(rom_informational) - 1;
   60|    147|    libspdm_copy_mem((void *)(mel_entry1 + 1), sizeof(rom_informational) - 1,
   61|    147|                     rom_informational, sizeof(rom_informational) - 1);
   62|       |
   63|       |    /*MEL Entry 2: informational Boot FW */
   64|    147|    mel_entry2 = (spdm_mel_entry_dmtf_t *)((uint8_t *)(mel_entry1 + 1) +
   65|    147|                                           sizeof(rom_informational) - 1);
   66|    147|    mel_entry2->mel_index = 2;
   67|    147|    mel_entry2->meas_index = LIBSPDM_MEASUREMENT_INDEX_HEM;
  ------------------
  |  |   34|    147|#define LIBSPDM_MEASUREMENT_INDEX_HEM 0x11
  ------------------
   68|    147|    libspdm_write_uint24(mel_entry2->reserved, 0);
   69|    147|    mel_entry2->measurement_block_dmtf_header.dmtf_spec_measurement_value_type =
   70|    147|        SPDM_MEASUREMENT_BLOCK_MEASUREMENT_TYPE_INFORMATIONAL |
  ------------------
  |  |  781|    147|#define SPDM_MEASUREMENT_BLOCK_MEASUREMENT_TYPE_INFORMATIONAL 9
  ------------------
   71|    147|        SPDM_MEASUREMENT_BLOCK_MEASUREMENT_TYPE_RAW_BIT_STREAM;
  ------------------
  |  |  784|    147|#define SPDM_MEASUREMENT_BLOCK_MEASUREMENT_TYPE_RAW_BIT_STREAM 0x00000080
  ------------------
   72|    147|    mel_entry2->measurement_block_dmtf_header.dmtf_spec_measurement_value_size =
   73|    147|        sizeof(bootfv_informational) - 1;
   74|    147|    libspdm_copy_mem((void *)(mel_entry2 + 1), sizeof(bootfv_informational) - 1,
   75|    147|                     bootfv_informational, sizeof(bootfv_informational) - 1);
   76|       |
   77|       |    /*MEL Entry 3: version 0x0100030A */
   78|    147|    mel_entry3 = (spdm_mel_entry_dmtf_t *)((uint8_t *)(mel_entry2 + 1) +
   79|    147|                                           sizeof(bootfv_informational) - 1);
   80|    147|    mel_entry3->mel_index = 3;
   81|    147|    mel_entry3->meas_index = LIBSPDM_MEASUREMENT_INDEX_HEM;
  ------------------
  |  |   34|    147|#define LIBSPDM_MEASUREMENT_INDEX_HEM 0x11
  ------------------
   82|    147|    libspdm_write_uint24(mel_entry3->reserved, 0);
   83|    147|    mel_entry3->measurement_block_dmtf_header.dmtf_spec_measurement_value_type =
   84|    147|        SPDM_MEASUREMENT_BLOCK_MEASUREMENT_TYPE_VERSION |
  ------------------
  |  |  778|    147|#define SPDM_MEASUREMENT_BLOCK_MEASUREMENT_TYPE_VERSION 6
  ------------------
   85|    147|        SPDM_MEASUREMENT_BLOCK_MEASUREMENT_TYPE_RAW_BIT_STREAM;
  ------------------
  |  |  784|    147|#define SPDM_MEASUREMENT_BLOCK_MEASUREMENT_TYPE_RAW_BIT_STREAM 0x00000080
  ------------------
   86|    147|    mel_entry3->measurement_block_dmtf_header.dmtf_spec_measurement_value_size = sizeof(version);
   87|    147|    libspdm_copy_mem((void *)(mel_entry3 + 1), sizeof(version), &version, sizeof(version));
   88|    147|}
libspdm_measurement_extension_log_collection:
  774|    147|{
  775|    147|    spdm_measurement_extension_log_dmtf_t *measurement_extension_log;
  776|       |
  777|    147|    if ((measurement_specification !=
  ------------------
  |  Branch (777:9): [True: 0, False: 147]
  ------------------
  778|    147|         SPDM_MEASUREMENT_SPECIFICATION_DMTF) ||
  ------------------
  |  |  740|    147|#define SPDM_MEASUREMENT_SPECIFICATION_DMTF 0x01
  ------------------
  779|    147|        (mel_specification != SPDM_MEL_SPECIFICATION_DMTF) ||
  ------------------
  |  |  840|    147|#define SPDM_MEL_SPECIFICATION_DMTF 0x01
  ------------------
  |  Branch (779:9): [True: 0, False: 147]
  ------------------
  780|    147|        (measurement_hash_algo == 0)) {
  ------------------
  |  Branch (780:9): [True: 0, False: 147]
  ------------------
  781|      0|        return false;
  782|      0|    }
  783|       |
  784|    147|    libspdm_generate_mel(measurement_hash_algo);
  785|       |
  786|    147|    measurement_extension_log = (spdm_measurement_extension_log_dmtf_t *)m_libspdm_mel;
  787|    147|    *spdm_mel = (spdm_measurement_extension_log_dmtf_t *)m_libspdm_mel;
  788|    147|    *spdm_mel_size = (size_t)(measurement_extension_log->mel_entries_len) +
  789|    147|                     sizeof(spdm_measurement_extension_log_dmtf_t);
  790|    147|    return true;
  791|    147|}

libspdm_setup_test_context:
   59|    222|{
   60|    222|    m_libspdm_test_context = spdm_test_context;
   61|    222|}
libspdm_unit_test_group_setup:
   64|    222|{
   65|    222|    libspdm_test_context_t *spdm_test_context;
   66|    222|    void *spdm_context;
   67|       |
   68|    222|    spdm_test_context = m_libspdm_test_context;
   69|    222|    spdm_test_context->spdm_context =
   70|    222|        (void *)malloc(libspdm_get_context_size());
   71|    222|    if (spdm_test_context->spdm_context == NULL) {
  ------------------
  |  Branch (71:9): [True: 0, False: 222]
  ------------------
   72|      0|        return (size_t)-1;
   73|      0|    }
   74|    222|    spdm_context = spdm_test_context->spdm_context;
   75|       |
   76|    222|    libspdm_init_context(spdm_context);
   77|       |
   78|    222|    libspdm_register_device_io_func(spdm_context,
   79|    222|                                    spdm_test_context->send_message,
   80|    222|                                    spdm_test_context->receive_message);
   81|    222|    libspdm_register_transport_layer_func(spdm_context,
   82|    222|                                          LIBSPDM_MAX_SPDM_MSG_SIZE,
  ------------------
  |  |  101|    222|#define LIBSPDM_MAX_SPDM_MSG_SIZE 0x1200
  ------------------
   83|    222|                                          LIBSPDM_TEST_TRANSPORT_HEADER_SIZE,
  ------------------
  |  |   27|    222|#define LIBSPDM_TEST_TRANSPORT_HEADER_SIZE  (2 + 8 + \
  |  |   28|    222|                                             LIBSPDM_TEST_SEQUENCE_NUMBER_COUNT)
  |  |  ------------------
  |  |  |  |   16|    222|#define LIBSPDM_TEST_SEQUENCE_NUMBER_COUNT 2
  |  |  ------------------
  ------------------
   84|    222|                                          LIBSPDM_TEST_TRANSPORT_TAIL_SIZE,
  ------------------
  |  |   30|    222|#define LIBSPDM_TEST_TRANSPORT_TAIL_SIZE    (LIBSPDM_TEST_MAX_RANDOM_NUMBER_COUNT + \
  |  |  ------------------
  |  |  |  |   17|    222|#define LIBSPDM_TEST_MAX_RANDOM_NUMBER_COUNT 32
  |  |  ------------------
  |  |   31|    222|                                             LIBSPDM_MAX_AEAD_TAG_SIZE + \
  |  |  ------------------
  |  |  |  |   75|    222|#define LIBSPDM_MAX_AEAD_TAG_SIZE 16
  |  |  ------------------
  |  |   32|    222|                                             (LIBSPDM_TEST_ALIGNMENT - 1))
  |  |  ------------------
  |  |  |  |   15|    222|#define LIBSPDM_TEST_ALIGNMENT 4
  |  |  ------------------
  ------------------
   85|    222|                                          libspdm_transport_test_encode_message,
   86|    222|                                          libspdm_transport_test_decode_message);
   87|    222|    libspdm_register_device_buffer_func(spdm_context,
   88|    222|                                        LIBSPDM_MAX_SENDER_RECEIVER_BUFFER_SIZE,
  ------------------
  |  |   93|    222|#define LIBSPDM_MAX_SENDER_RECEIVER_BUFFER_SIZE LIBSPDM_RECEIVER_BUFFER_SIZE
  |  |  ------------------
  |  |  |  |   78|    222|#define LIBSPDM_RECEIVER_BUFFER_SIZE (0x1200 + \
  |  |  |  |   79|    222|                                      LIBSPDM_TRANSPORT_ADDITIONAL_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |   70|    222|#define LIBSPDM_TRANSPORT_ADDITIONAL_SIZE    (LIBSPDM_TEST_TRANSPORT_HEADER_SIZE + \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   27|    222|#define LIBSPDM_TEST_TRANSPORT_HEADER_SIZE  (2 + 8 + \
  |  |  |  |  |  |  |  |   28|    222|                                             LIBSPDM_TEST_SEQUENCE_NUMBER_COUNT)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   16|    222|#define LIBSPDM_TEST_SEQUENCE_NUMBER_COUNT 2
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   71|    222|                                              LIBSPDM_TEST_TRANSPORT_TAIL_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   30|    222|#define LIBSPDM_TEST_TRANSPORT_TAIL_SIZE    (LIBSPDM_TEST_MAX_RANDOM_NUMBER_COUNT + \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   17|    222|#define LIBSPDM_TEST_MAX_RANDOM_NUMBER_COUNT 32
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   31|    222|                                             LIBSPDM_MAX_AEAD_TAG_SIZE + \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   75|    222|#define LIBSPDM_MAX_AEAD_TAG_SIZE 16
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   32|    222|                                             (LIBSPDM_TEST_ALIGNMENT - 1))
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   15|    222|#define LIBSPDM_TEST_ALIGNMENT 4
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   89|    222|                                        LIBSPDM_MAX_SENDER_RECEIVER_BUFFER_SIZE,
  ------------------
  |  |   93|    222|#define LIBSPDM_MAX_SENDER_RECEIVER_BUFFER_SIZE LIBSPDM_RECEIVER_BUFFER_SIZE
  |  |  ------------------
  |  |  |  |   78|    222|#define LIBSPDM_RECEIVER_BUFFER_SIZE (0x1200 + \
  |  |  |  |   79|    222|                                      LIBSPDM_TRANSPORT_ADDITIONAL_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |   70|    222|#define LIBSPDM_TRANSPORT_ADDITIONAL_SIZE    (LIBSPDM_TEST_TRANSPORT_HEADER_SIZE + \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   27|    222|#define LIBSPDM_TEST_TRANSPORT_HEADER_SIZE  (2 + 8 + \
  |  |  |  |  |  |  |  |   28|    222|                                             LIBSPDM_TEST_SEQUENCE_NUMBER_COUNT)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   16|    222|#define LIBSPDM_TEST_SEQUENCE_NUMBER_COUNT 2
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |   71|    222|                                              LIBSPDM_TEST_TRANSPORT_TAIL_SIZE)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   30|    222|#define LIBSPDM_TEST_TRANSPORT_TAIL_SIZE    (LIBSPDM_TEST_MAX_RANDOM_NUMBER_COUNT + \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   17|    222|#define LIBSPDM_TEST_MAX_RANDOM_NUMBER_COUNT 32
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   31|    222|                                             LIBSPDM_MAX_AEAD_TAG_SIZE + \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   75|    222|#define LIBSPDM_MAX_AEAD_TAG_SIZE 16
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   32|    222|                                             (LIBSPDM_TEST_ALIGNMENT - 1))
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   15|    222|#define LIBSPDM_TEST_ALIGNMENT 4
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   90|    222|                                        spdm_device_acquire_sender_buffer,
   91|    222|                                        spdm_device_release_sender_buffer,
   92|    222|                                        spdm_device_acquire_receiver_buffer,
   93|    222|                                        spdm_device_release_receiver_buffer);
   94|       |
   95|    222|    spdm_test_context->scratch_buffer_size =
   96|    222|        libspdm_get_sizeof_required_scratch_buffer(spdm_context);
   97|    222|    spdm_test_context->scratch_buffer = (void *)malloc(spdm_test_context->scratch_buffer_size);
   98|    222|    libspdm_set_scratch_buffer (spdm_context,
   99|    222|                                spdm_test_context->scratch_buffer,
  100|    222|                                spdm_test_context->scratch_buffer_size);
  101|       |
  102|    222|    *State = spdm_test_context;
  103|    222|    return 0;
  104|    222|}
libspdm_unit_test_group_teardown:
  107|    222|{
  108|    222|    libspdm_test_context_t *spdm_test_context;
  109|       |
  110|    222|    spdm_test_context = *State;
  111|    222|    free(spdm_test_context->spdm_context);
  112|    222|    free(spdm_test_context->scratch_buffer);
  113|    222|    spdm_test_context->spdm_context = NULL;
  114|    222|    return 0;
  115|    222|}

libspdm_alignment_size:
   21|    222|{
   22|    222|    size_t alignment;
   23|    222|    size_t max_buffer_size;
   24|       |
   25|    222|    alignment = LIBSPDM_TEST_ALIGNMENT;
  ------------------
  |  |   15|    222|#define LIBSPDM_TEST_ALIGNMENT 4
  ------------------
   26|    222|    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|    222|    if ((size > max_buffer_size - alignment) && (size & (alignment - 1)) != 0) {
  ------------------
  |  Branch (29:9): [True: 45, False: 177]
  |  Branch (29:49): [True: 3, False: 42]
  ------------------
   30|      3|        size -= alignment;
   31|      3|    }
   32|       |
   33|    222|    if (((size) & (alignment - 1)) == 3) {
  ------------------
  |  Branch (33:9): [True: 26, False: 196]
  ------------------
   34|     26|        size += 1;
   35|     26|    }
   36|    222|    if (((size) & (alignment - 1)) == 2) {
  ------------------
  |  Branch (36:9): [True: 30, False: 192]
  ------------------
   37|     30|        size += 2;
   38|     30|    }
   39|    222|    if (((size) & (alignment - 1)) == 1) {
  ------------------
  |  Branch (39:9): [True: 92, False: 130]
  ------------------
   40|     92|        size += 3;
   41|     92|    }
   42|    222|    return size;
   43|    222|}
LLVMFuzzerTestOneInput:
  112|    222|{
  113|    222|    void *test_buffer;
  114|    222|    size_t max_buffer_size;
  115|       |
  116|       |    /* 1. Initialize test_buffer*/
  117|    222|    max_buffer_size = libspdm_get_max_buffer_size();
  118|    222|    test_buffer = allocate_zero_pool(max_buffer_size);
  119|    222|    if (test_buffer == NULL) {
  ------------------
  |  Branch (119:9): [True: 0, False: 222]
  ------------------
  120|      0|        return 0;
  121|      0|    }
  122|    222|    if (size == 0) {
  ------------------
  |  Branch (122:9): [True: 0, False: 222]
  ------------------
  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|    222|    if (size > max_buffer_size) {
  ------------------
  |  Branch (127:9): [True: 41, False: 181]
  ------------------
  128|     41|        size = max_buffer_size;
  129|    181|    } else {
  130|    181|        libspdm_copy_mem(test_buffer, max_buffer_size, data, size);
  131|    181|    }
  132|    222|    size = libspdm_alignment_size(size);
  133|       |    /* 2. Run test*/
  134|    222|    libspdm_run_test_harness(test_buffer, size);
  135|       |    /* 3. Clean up*/
  136|    222|    free(test_buffer);
  137|    222|    return 0;
  138|    222|}

libspdm_get_max_buffer_size:
   14|    444|{
   15|    444|    return LIBSPDM_MAX_SPDM_MSG_SIZE;
  ------------------
  |  |  101|    444|#define LIBSPDM_MAX_SPDM_MSG_SIZE 0x1200
  ------------------
   16|    444|}
libspdm_test_responder_measurement_extension_log:
   19|    222|{
   20|    222|    libspdm_test_context_t *spdm_test_context;
   21|    222|    libspdm_context_t *spdm_context;
   22|    222|    size_t response_size;
   23|    222|    uint8_t response[LIBSPDM_MAX_SPDM_MSG_SIZE];
   24|       |
   25|    222|    spdm_test_context = *State;
   26|    222|    spdm_context = spdm_test_context->spdm_context;
   27|       |
   28|    222|    spdm_context->connection_info.version = SPDM_MESSAGE_VERSION_13 <<
  ------------------
  |  |  113|    222|#define SPDM_MESSAGE_VERSION_13 0x13
  ------------------
   29|    222|                                            SPDM_VERSION_NUMBER_SHIFT_BIT;
  ------------------
  |  |  140|    222|#define SPDM_VERSION_NUMBER_SHIFT_BIT 8
  ------------------
   30|    222|    spdm_context->connection_info.connection_state =
   31|    222|        LIBSPDM_CONNECTION_STATE_AUTHENTICATED;
   32|    222|    spdm_context->local_context.capability.flags |=
   33|    222|        SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MEL_CAP;
  ------------------
  |  |  293|    222|#define SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MEL_CAP 0x01000000
  ------------------
   34|    222|    spdm_context->connection_info.algorithm.base_hash_algo =
   35|    222|        m_libspdm_use_hash_algo;
   36|    222|    spdm_context->connection_info.algorithm.base_asym_algo =
   37|    222|        m_libspdm_use_asym_algo;
   38|    222|    spdm_context->connection_info.algorithm.measurement_spec =
   39|    222|        m_libspdm_use_measurement_spec;
   40|    222|    spdm_context->connection_info.algorithm.mel_spec =
   41|    222|        SPDM_MEL_SPECIFICATION_DMTF;
  ------------------
  |  |  840|    222|#define SPDM_MEL_SPECIFICATION_DMTF 0x01
  ------------------
   42|    222|    spdm_context->connection_info.algorithm.measurement_hash_algo =
   43|    222|        m_libspdm_use_measurement_hash_algo;
   44|       |
   45|    222|    response_size = sizeof(response);
   46|    222|    libspdm_get_response_measurement_extension_log(spdm_context,
   47|    222|                                                   spdm_test_context->test_buffer_size,
   48|    222|                                                   spdm_test_context->test_buffer,
   49|    222|                                                   &response_size, response);
   50|    222|}
libspdm_run_test_harness:
   58|    222|{
   59|    222|    void *State;
   60|    222|    spdm_message_header_t *spdm_request_header;
   61|    222|    libspdm_setup_test_context(&m_libspdm_responder_measurement_extension_log_test_context);
   62|       |
   63|    222|    spdm_request_header = (spdm_message_header_t*)test_buffer;
   64|       |
   65|    222|    if (spdm_request_header->request_response_code != SPDM_GET_MEASUREMENT_EXTENSION_LOG) {
  ------------------
  |  |   98|    222|#define SPDM_GET_MEASUREMENT_EXTENSION_LOG 0xEF
  ------------------
  |  Branch (65:9): [True: 220, False: 2]
  ------------------
   66|    220|        spdm_request_header->request_response_code = SPDM_GET_MEASUREMENT_EXTENSION_LOG;
  ------------------
  |  |   98|    220|#define SPDM_GET_MEASUREMENT_EXTENSION_LOG 0xEF
  ------------------
   67|    220|    }
   68|       |
   69|    222|    m_libspdm_responder_measurement_extension_log_test_context.test_buffer = test_buffer;
   70|    222|    m_libspdm_responder_measurement_extension_log_test_context.test_buffer_size =
   71|    222|        test_buffer_size;
   72|       |
   73|       |    /* Success Case*/
   74|    222|    libspdm_unit_test_group_setup(&State);
   75|    222|    libspdm_test_responder_measurement_extension_log(&State);
   76|    222|    libspdm_unit_test_group_teardown(&State);
   77|    222|}

