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

libspdm_append_managed_buffer:
  251|    150|{
  252|    150|    libspdm_managed_buffer_t *managed_buffer;
  253|       |
  254|    150|    LIBSPDM_ASSERT(buffer != NULL);
  255|       |
  256|    150|    if (buffer_size == 0) {
  ------------------
  |  Branch (256:9): [True: 0, False: 150]
  ------------------
  257|      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)))
  |  |  ------------------
  ------------------
  258|      0|    }
  259|       |
  260|    150|    managed_buffer = m_buffer;
  261|       |
  262|    150|    LIBSPDM_ASSERT(buffer_size != 0);
  263|    150|    LIBSPDM_ASSERT(managed_buffer->max_buffer_size >= managed_buffer->buffer_size);
  264|       |
  265|    150|    if (buffer_size > managed_buffer->max_buffer_size - managed_buffer->buffer_size) {
  ------------------
  |  Branch (265:9): [True: 0, False: 150]
  ------------------
  266|       |        /* Do not LIBSPDM_ASSERT here, because command processor will append message from external.*/
  267|      0|        LIBSPDM_DEBUG((LIBSPDM_DEBUG_ERROR,
  268|      0|                       "libspdm_append_managed_buffer 0x%x fail, rest 0x%x only\n",
  269|      0|                       (uint32_t)buffer_size,
  270|      0|                       (uint32_t)(managed_buffer->max_buffer_size - managed_buffer->buffer_size)));
  271|      0|        return LIBSPDM_STATUS_BUFFER_FULL;
  ------------------
  |  |  118|      0|    LIBSPDM_STATUS_CONSTRUCT(LIBSPDM_SEVERITY_ERROR, LIBSPDM_SOURCE_CORE, 0x000c)
  |  |  ------------------
  |  |  |  |   55|      0|    ((libspdm_return_t)(((severity) << 28) | ((source) << 16) | (code)))
  |  |  ------------------
  ------------------
  272|      0|    }
  273|    150|    LIBSPDM_ASSERT(buffer_size <= managed_buffer->max_buffer_size - managed_buffer->buffer_size);
  274|       |
  275|    150|    libspdm_copy_mem((uint8_t *)(managed_buffer + 1) + managed_buffer->buffer_size,
  276|    150|                     buffer_size, buffer, buffer_size);
  277|    150|    managed_buffer->buffer_size += buffer_size;
  278|       |
  279|    150|    return LIBSPDM_STATUS_SUCCESS;
  ------------------
  |  |   59|    150|    LIBSPDM_STATUS_CONSTRUCT(LIBSPDM_SEVERITY_SUCCESS, LIBSPDM_SOURCE_SUCCESS, 0x0000)
  |  |  ------------------
  |  |  |  |   55|    150|    ((libspdm_return_t)(((severity) << 28) | ((source) << 16) | (code)))
  |  |  ------------------
  ------------------
  280|    150|}
libspdm_mask_capability_flags:
  347|    150|{
  348|    150|    switch (libspdm_get_connection_version(spdm_context)) {
  349|     78|    case SPDM_MESSAGE_VERSION_10:
  ------------------
  |  |  110|     78|#define SPDM_MESSAGE_VERSION_10 0x10
  ------------------
  |  Branch (349:5): [True: 78, False: 72]
  ------------------
  350|     78|        if (is_request_flags) {
  ------------------
  |  Branch (350:13): [True: 39, False: 39]
  ------------------
  351|       |            /* A 1.0 Requester does not have any capability flags. */
  352|     39|            return 0;
  353|     39|        } else {
  354|     39|            return (flags & SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_10_MASK);
  ------------------
  |  |  240|     39|#define SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_10_MASK ( \
  |  |  241|     39|        SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_CACHE_CAP | \
  |  |  ------------------
  |  |  |  |  233|     39|#define SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_CACHE_CAP 0x00000001
  |  |  ------------------
  |  |  242|     39|        SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_CERT_CAP | \
  |  |  ------------------
  |  |  |  |  234|     39|#define SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_CERT_CAP 0x00000002
  |  |  ------------------
  |  |  243|     39|        SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_CHAL_CAP | \
  |  |  ------------------
  |  |  |  |  235|     39|#define SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_CHAL_CAP 0x00000004
  |  |  ------------------
  |  |  244|     39|        SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MEAS_CAP | \
  |  |  ------------------
  |  |  |  |  236|     39|#define SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MEAS_CAP (0x00000008 | 0x00000010)
  |  |  ------------------
  |  |  245|     39|        SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MEAS_FRESH_CAP)
  |  |  ------------------
  |  |  |  |  239|     39|#define SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MEAS_FRESH_CAP 0x00000020
  |  |  ------------------
  ------------------
  355|     39|        }
  356|     48|    case SPDM_MESSAGE_VERSION_11:
  ------------------
  |  |  111|     48|#define SPDM_MESSAGE_VERSION_11 0x11
  ------------------
  |  Branch (356:5): [True: 48, False: 102]
  ------------------
  357|     48|        if (is_request_flags) {
  ------------------
  |  Branch (357:13): [True: 24, False: 24]
  ------------------
  358|     24|            return (flags & SPDM_GET_CAPABILITIES_REQUEST_FLAGS_11_MASK);
  ------------------
  |  |  198|     24|#define SPDM_GET_CAPABILITIES_REQUEST_FLAGS_11_MASK ( \
  |  |  199|     24|        SPDM_GET_CAPABILITIES_REQUEST_FLAGS_CERT_CAP | \
  |  |  ------------------
  |  |  |  |  185|     24|#define SPDM_GET_CAPABILITIES_REQUEST_FLAGS_CERT_CAP 0x00000002
  |  |  ------------------
  |  |  200|     24|        SPDM_GET_CAPABILITIES_REQUEST_FLAGS_CHAL_CAP | \
  |  |  ------------------
  |  |  |  |  186|     24|#define SPDM_GET_CAPABILITIES_REQUEST_FLAGS_CHAL_CAP 0x00000004
  |  |  ------------------
  |  |  201|     24|        SPDM_GET_CAPABILITIES_REQUEST_FLAGS_ENCRYPT_CAP | \
  |  |  ------------------
  |  |  |  |  187|     24|#define SPDM_GET_CAPABILITIES_REQUEST_FLAGS_ENCRYPT_CAP 0x00000040
  |  |  ------------------
  |  |  202|     24|        SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MAC_CAP | \
  |  |  ------------------
  |  |  |  |  188|     24|#define SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MAC_CAP 0x00000080
  |  |  ------------------
  |  |  203|     24|        SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MUT_AUTH_CAP | \
  |  |  ------------------
  |  |  |  |  189|     24|#define SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MUT_AUTH_CAP 0x00000100
  |  |  ------------------
  |  |  204|     24|        SPDM_GET_CAPABILITIES_REQUEST_FLAGS_KEY_EX_CAP | \
  |  |  ------------------
  |  |  |  |  190|     24|#define SPDM_GET_CAPABILITIES_REQUEST_FLAGS_KEY_EX_CAP 0x00000200
  |  |  ------------------
  |  |  205|     24|        SPDM_GET_CAPABILITIES_REQUEST_FLAGS_PSK_CAP | \
  |  |  ------------------
  |  |  |  |  191|     24|#define SPDM_GET_CAPABILITIES_REQUEST_FLAGS_PSK_CAP (0x00000400 | 0x00000800)
  |  |  ------------------
  |  |  206|     24|        SPDM_GET_CAPABILITIES_REQUEST_FLAGS_ENCAP_CAP | \
  |  |  ------------------
  |  |  |  |  193|     24|#define SPDM_GET_CAPABILITIES_REQUEST_FLAGS_ENCAP_CAP 0x00001000
  |  |  ------------------
  |  |  207|     24|        SPDM_GET_CAPABILITIES_REQUEST_FLAGS_HBEAT_CAP | \
  |  |  ------------------
  |  |  |  |  194|     24|#define SPDM_GET_CAPABILITIES_REQUEST_FLAGS_HBEAT_CAP 0x00002000
  |  |  ------------------
  |  |  208|     24|        SPDM_GET_CAPABILITIES_REQUEST_FLAGS_KEY_UPD_CAP | \
  |  |  ------------------
  |  |  |  |  195|     24|#define SPDM_GET_CAPABILITIES_REQUEST_FLAGS_KEY_UPD_CAP 0x00004000
  |  |  ------------------
  |  |  209|     24|        SPDM_GET_CAPABILITIES_REQUEST_FLAGS_HANDSHAKE_IN_THE_CLEAR_CAP | \
  |  |  ------------------
  |  |  |  |  196|     24|#define SPDM_GET_CAPABILITIES_REQUEST_FLAGS_HANDSHAKE_IN_THE_CLEAR_CAP 0x00008000
  |  |  ------------------
  |  |  210|     24|        SPDM_GET_CAPABILITIES_REQUEST_FLAGS_PUB_KEY_ID_CAP)
  |  |  ------------------
  |  |  |  |  197|     24|#define SPDM_GET_CAPABILITIES_REQUEST_FLAGS_PUB_KEY_ID_CAP 0x00010000
  |  |  ------------------
  ------------------
  359|     24|        } else {
  360|     24|            return (flags & SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_11_MASK);
  ------------------
  |  |  260|     24|#define SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_11_MASK ( \
  |  |  261|     24|        SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_10_MASK | \
  |  |  ------------------
  |  |  |  |  240|     24|#define SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_10_MASK ( \
  |  |  |  |  241|     24|        SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_CACHE_CAP | \
  |  |  |  |  ------------------
  |  |  |  |  |  |  233|     24|#define SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_CACHE_CAP 0x00000001
  |  |  |  |  ------------------
  |  |  |  |  242|     24|        SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_CERT_CAP | \
  |  |  |  |  ------------------
  |  |  |  |  |  |  234|     24|#define SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_CERT_CAP 0x00000002
  |  |  |  |  ------------------
  |  |  |  |  243|     24|        SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_CHAL_CAP | \
  |  |  |  |  ------------------
  |  |  |  |  |  |  235|     24|#define SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_CHAL_CAP 0x00000004
  |  |  |  |  ------------------
  |  |  |  |  244|     24|        SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MEAS_CAP | \
  |  |  |  |  ------------------
  |  |  |  |  |  |  236|     24|#define SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MEAS_CAP (0x00000008 | 0x00000010)
  |  |  |  |  ------------------
  |  |  |  |  245|     24|        SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MEAS_FRESH_CAP)
  |  |  |  |  ------------------
  |  |  |  |  |  |  239|     24|#define SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MEAS_FRESH_CAP 0x00000020
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  262|     24|        SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_ENCRYPT_CAP | \
  |  |  ------------------
  |  |  |  |  248|     24|#define SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_ENCRYPT_CAP 0x00000040
  |  |  ------------------
  |  |  263|     24|        SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MAC_CAP | \
  |  |  ------------------
  |  |  |  |  249|     24|#define SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MAC_CAP 0x00000080
  |  |  ------------------
  |  |  264|     24|        SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MUT_AUTH_CAP | \
  |  |  ------------------
  |  |  |  |  250|     24|#define SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MUT_AUTH_CAP 0x00000100
  |  |  ------------------
  |  |  265|     24|        SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_KEY_EX_CAP | \
  |  |  ------------------
  |  |  |  |  251|     24|#define SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_KEY_EX_CAP 0x00000200
  |  |  ------------------
  |  |  266|     24|        SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_PSK_CAP | \
  |  |  ------------------
  |  |  |  |  252|     24|#define SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_PSK_CAP (0x00000400 | 0x00000800)
  |  |  ------------------
  |  |  267|     24|        SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_ENCAP_CAP | \
  |  |  ------------------
  |  |  |  |  255|     24|#define SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_ENCAP_CAP 0x00001000
  |  |  ------------------
  |  |  268|     24|        SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_HBEAT_CAP | \
  |  |  ------------------
  |  |  |  |  256|     24|#define SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_HBEAT_CAP 0x00002000
  |  |  ------------------
  |  |  269|     24|        SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_KEY_UPD_CAP | \
  |  |  ------------------
  |  |  |  |  257|     24|#define SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_KEY_UPD_CAP 0x00004000
  |  |  ------------------
  |  |  270|     24|        SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_HANDSHAKE_IN_THE_CLEAR_CAP | \
  |  |  ------------------
  |  |  |  |  258|     24|#define SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_HANDSHAKE_IN_THE_CLEAR_CAP 0x00008000
  |  |  ------------------
  |  |  271|     24|        SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_PUB_KEY_ID_CAP)
  |  |  ------------------
  |  |  |  |  259|     24|#define SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_PUB_KEY_ID_CAP 0x00010000
  |  |  ------------------
  ------------------
  361|     24|        }
  362|     18|    case SPDM_MESSAGE_VERSION_12:
  ------------------
  |  |  112|     18|#define SPDM_MESSAGE_VERSION_12 0x12
  ------------------
  |  Branch (362:5): [True: 18, False: 132]
  ------------------
  363|     18|        if (is_request_flags) {
  ------------------
  |  Branch (363:13): [True: 9, False: 9]
  ------------------
  364|      9|            return (flags & SPDM_GET_CAPABILITIES_REQUEST_FLAGS_12_MASK);
  ------------------
  |  |  214|      9|#define SPDM_GET_CAPABILITIES_REQUEST_FLAGS_12_MASK ( \
  |  |  215|      9|        SPDM_GET_CAPABILITIES_REQUEST_FLAGS_11_MASK | \
  |  |  ------------------
  |  |  |  |  198|      9|#define SPDM_GET_CAPABILITIES_REQUEST_FLAGS_11_MASK ( \
  |  |  |  |  199|      9|        SPDM_GET_CAPABILITIES_REQUEST_FLAGS_CERT_CAP | \
  |  |  |  |  ------------------
  |  |  |  |  |  |  185|      9|#define SPDM_GET_CAPABILITIES_REQUEST_FLAGS_CERT_CAP 0x00000002
  |  |  |  |  ------------------
  |  |  |  |  200|      9|        SPDM_GET_CAPABILITIES_REQUEST_FLAGS_CHAL_CAP | \
  |  |  |  |  ------------------
  |  |  |  |  |  |  186|      9|#define SPDM_GET_CAPABILITIES_REQUEST_FLAGS_CHAL_CAP 0x00000004
  |  |  |  |  ------------------
  |  |  |  |  201|      9|        SPDM_GET_CAPABILITIES_REQUEST_FLAGS_ENCRYPT_CAP | \
  |  |  |  |  ------------------
  |  |  |  |  |  |  187|      9|#define SPDM_GET_CAPABILITIES_REQUEST_FLAGS_ENCRYPT_CAP 0x00000040
  |  |  |  |  ------------------
  |  |  |  |  202|      9|        SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MAC_CAP | \
  |  |  |  |  ------------------
  |  |  |  |  |  |  188|      9|#define SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MAC_CAP 0x00000080
  |  |  |  |  ------------------
  |  |  |  |  203|      9|        SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MUT_AUTH_CAP | \
  |  |  |  |  ------------------
  |  |  |  |  |  |  189|      9|#define SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MUT_AUTH_CAP 0x00000100
  |  |  |  |  ------------------
  |  |  |  |  204|      9|        SPDM_GET_CAPABILITIES_REQUEST_FLAGS_KEY_EX_CAP | \
  |  |  |  |  ------------------
  |  |  |  |  |  |  190|      9|#define SPDM_GET_CAPABILITIES_REQUEST_FLAGS_KEY_EX_CAP 0x00000200
  |  |  |  |  ------------------
  |  |  |  |  205|      9|        SPDM_GET_CAPABILITIES_REQUEST_FLAGS_PSK_CAP | \
  |  |  |  |  ------------------
  |  |  |  |  |  |  191|      9|#define SPDM_GET_CAPABILITIES_REQUEST_FLAGS_PSK_CAP (0x00000400 | 0x00000800)
  |  |  |  |  ------------------
  |  |  |  |  206|      9|        SPDM_GET_CAPABILITIES_REQUEST_FLAGS_ENCAP_CAP | \
  |  |  |  |  ------------------
  |  |  |  |  |  |  193|      9|#define SPDM_GET_CAPABILITIES_REQUEST_FLAGS_ENCAP_CAP 0x00001000
  |  |  |  |  ------------------
  |  |  |  |  207|      9|        SPDM_GET_CAPABILITIES_REQUEST_FLAGS_HBEAT_CAP | \
  |  |  |  |  ------------------
  |  |  |  |  |  |  194|      9|#define SPDM_GET_CAPABILITIES_REQUEST_FLAGS_HBEAT_CAP 0x00002000
  |  |  |  |  ------------------
  |  |  |  |  208|      9|        SPDM_GET_CAPABILITIES_REQUEST_FLAGS_KEY_UPD_CAP | \
  |  |  |  |  ------------------
  |  |  |  |  |  |  195|      9|#define SPDM_GET_CAPABILITIES_REQUEST_FLAGS_KEY_UPD_CAP 0x00004000
  |  |  |  |  ------------------
  |  |  |  |  209|      9|        SPDM_GET_CAPABILITIES_REQUEST_FLAGS_HANDSHAKE_IN_THE_CLEAR_CAP | \
  |  |  |  |  ------------------
  |  |  |  |  |  |  196|      9|#define SPDM_GET_CAPABILITIES_REQUEST_FLAGS_HANDSHAKE_IN_THE_CLEAR_CAP 0x00008000
  |  |  |  |  ------------------
  |  |  |  |  210|      9|        SPDM_GET_CAPABILITIES_REQUEST_FLAGS_PUB_KEY_ID_CAP)
  |  |  |  |  ------------------
  |  |  |  |  |  |  197|      9|#define SPDM_GET_CAPABILITIES_REQUEST_FLAGS_PUB_KEY_ID_CAP 0x00010000
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  216|      9|        SPDM_GET_CAPABILITIES_REQUEST_FLAGS_CHUNK_CAP)
  |  |  ------------------
  |  |  |  |  213|      9|#define SPDM_GET_CAPABILITIES_REQUEST_FLAGS_CHUNK_CAP 0x00020000
  |  |  ------------------
  ------------------
  365|      9|        } else {
  366|      9|            return (flags & SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_12_MASK);
  ------------------
  |  |  281|      9|#define SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_12_MASK ( \
  |  |  282|      9|        SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_11_MASK | \
  |  |  ------------------
  |  |  |  |  260|      9|#define SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_11_MASK ( \
  |  |  |  |  261|      9|        SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_10_MASK | \
  |  |  |  |  ------------------
  |  |  |  |  |  |  240|      9|#define SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_10_MASK ( \
  |  |  |  |  |  |  241|      9|        SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_CACHE_CAP | \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  233|      9|#define SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_CACHE_CAP 0x00000001
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  242|      9|        SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_CERT_CAP | \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  234|      9|#define SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_CERT_CAP 0x00000002
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  243|      9|        SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_CHAL_CAP | \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  235|      9|#define SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_CHAL_CAP 0x00000004
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  244|      9|        SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MEAS_CAP | \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  236|      9|#define SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MEAS_CAP (0x00000008 | 0x00000010)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  245|      9|        SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MEAS_FRESH_CAP)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  239|      9|#define SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MEAS_FRESH_CAP 0x00000020
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  262|      9|        SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_ENCRYPT_CAP | \
  |  |  |  |  ------------------
  |  |  |  |  |  |  248|      9|#define SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_ENCRYPT_CAP 0x00000040
  |  |  |  |  ------------------
  |  |  |  |  263|      9|        SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MAC_CAP | \
  |  |  |  |  ------------------
  |  |  |  |  |  |  249|      9|#define SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MAC_CAP 0x00000080
  |  |  |  |  ------------------
  |  |  |  |  264|      9|        SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MUT_AUTH_CAP | \
  |  |  |  |  ------------------
  |  |  |  |  |  |  250|      9|#define SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MUT_AUTH_CAP 0x00000100
  |  |  |  |  ------------------
  |  |  |  |  265|      9|        SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_KEY_EX_CAP | \
  |  |  |  |  ------------------
  |  |  |  |  |  |  251|      9|#define SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_KEY_EX_CAP 0x00000200
  |  |  |  |  ------------------
  |  |  |  |  266|      9|        SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_PSK_CAP | \
  |  |  |  |  ------------------
  |  |  |  |  |  |  252|      9|#define SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_PSK_CAP (0x00000400 | 0x00000800)
  |  |  |  |  ------------------
  |  |  |  |  267|      9|        SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_ENCAP_CAP | \
  |  |  |  |  ------------------
  |  |  |  |  |  |  255|      9|#define SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_ENCAP_CAP 0x00001000
  |  |  |  |  ------------------
  |  |  |  |  268|      9|        SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_HBEAT_CAP | \
  |  |  |  |  ------------------
  |  |  |  |  |  |  256|      9|#define SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_HBEAT_CAP 0x00002000
  |  |  |  |  ------------------
  |  |  |  |  269|      9|        SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_KEY_UPD_CAP | \
  |  |  |  |  ------------------
  |  |  |  |  |  |  257|      9|#define SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_KEY_UPD_CAP 0x00004000
  |  |  |  |  ------------------
  |  |  |  |  270|      9|        SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_HANDSHAKE_IN_THE_CLEAR_CAP | \
  |  |  |  |  ------------------
  |  |  |  |  |  |  258|      9|#define SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_HANDSHAKE_IN_THE_CLEAR_CAP 0x00008000
  |  |  |  |  ------------------
  |  |  |  |  271|      9|        SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_PUB_KEY_ID_CAP)
  |  |  |  |  ------------------
  |  |  |  |  |  |  259|      9|#define SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_PUB_KEY_ID_CAP 0x00010000
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  283|      9|        SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_CHUNK_CAP | \
  |  |  ------------------
  |  |  |  |  274|      9|#define SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_CHUNK_CAP 0x00020000
  |  |  ------------------
  |  |  284|      9|        SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_ALIAS_CERT_CAP | \
  |  |  ------------------
  |  |  |  |  275|      9|#define SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_ALIAS_CERT_CAP 0x00040000
  |  |  ------------------
  |  |  285|      9|        SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_SET_CERT_CAP | \
  |  |  ------------------
  |  |  |  |  278|      9|#define SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_SET_CERT_CAP 0x00080000
  |  |  ------------------
  |  |  286|      9|        SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_CSR_CAP | \
  |  |  ------------------
  |  |  |  |  279|      9|#define SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_CSR_CAP 0x00100000
  |  |  ------------------
  |  |  287|      9|        SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_CERT_INSTALL_RESET_CAP)
  |  |  ------------------
  |  |  |  |  280|      9|#define SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_CERT_INSTALL_RESET_CAP 0x00200000
  |  |  ------------------
  ------------------
  367|      9|        }
  368|      6|    case SPDM_MESSAGE_VERSION_13:
  ------------------
  |  |  113|      6|#define SPDM_MESSAGE_VERSION_13 0x13
  ------------------
  |  Branch (368:5): [True: 6, False: 144]
  ------------------
  369|      6|        if (is_request_flags) {
  ------------------
  |  Branch (369:13): [True: 3, False: 3]
  ------------------
  370|      3|            return (flags & SPDM_GET_CAPABILITIES_REQUEST_FLAGS_13_MASK);
  ------------------
  |  |  226|      3|#define SPDM_GET_CAPABILITIES_REQUEST_FLAGS_13_MASK ( \
  |  |  227|      3|        SPDM_GET_CAPABILITIES_REQUEST_FLAGS_12_MASK | \
  |  |  ------------------
  |  |  |  |  214|      3|#define SPDM_GET_CAPABILITIES_REQUEST_FLAGS_12_MASK ( \
  |  |  |  |  215|      3|        SPDM_GET_CAPABILITIES_REQUEST_FLAGS_11_MASK | \
  |  |  |  |  ------------------
  |  |  |  |  |  |  198|      3|#define SPDM_GET_CAPABILITIES_REQUEST_FLAGS_11_MASK ( \
  |  |  |  |  |  |  199|      3|        SPDM_GET_CAPABILITIES_REQUEST_FLAGS_CERT_CAP | \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  185|      3|#define SPDM_GET_CAPABILITIES_REQUEST_FLAGS_CERT_CAP 0x00000002
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  200|      3|        SPDM_GET_CAPABILITIES_REQUEST_FLAGS_CHAL_CAP | \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  186|      3|#define SPDM_GET_CAPABILITIES_REQUEST_FLAGS_CHAL_CAP 0x00000004
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  201|      3|        SPDM_GET_CAPABILITIES_REQUEST_FLAGS_ENCRYPT_CAP | \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  187|      3|#define SPDM_GET_CAPABILITIES_REQUEST_FLAGS_ENCRYPT_CAP 0x00000040
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  202|      3|        SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MAC_CAP | \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  188|      3|#define SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MAC_CAP 0x00000080
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  203|      3|        SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MUT_AUTH_CAP | \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  189|      3|#define SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MUT_AUTH_CAP 0x00000100
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  204|      3|        SPDM_GET_CAPABILITIES_REQUEST_FLAGS_KEY_EX_CAP | \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  190|      3|#define SPDM_GET_CAPABILITIES_REQUEST_FLAGS_KEY_EX_CAP 0x00000200
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  205|      3|        SPDM_GET_CAPABILITIES_REQUEST_FLAGS_PSK_CAP | \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  191|      3|#define SPDM_GET_CAPABILITIES_REQUEST_FLAGS_PSK_CAP (0x00000400 | 0x00000800)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  206|      3|        SPDM_GET_CAPABILITIES_REQUEST_FLAGS_ENCAP_CAP | \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  193|      3|#define SPDM_GET_CAPABILITIES_REQUEST_FLAGS_ENCAP_CAP 0x00001000
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  207|      3|        SPDM_GET_CAPABILITIES_REQUEST_FLAGS_HBEAT_CAP | \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  194|      3|#define SPDM_GET_CAPABILITIES_REQUEST_FLAGS_HBEAT_CAP 0x00002000
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  208|      3|        SPDM_GET_CAPABILITIES_REQUEST_FLAGS_KEY_UPD_CAP | \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  195|      3|#define SPDM_GET_CAPABILITIES_REQUEST_FLAGS_KEY_UPD_CAP 0x00004000
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  209|      3|        SPDM_GET_CAPABILITIES_REQUEST_FLAGS_HANDSHAKE_IN_THE_CLEAR_CAP | \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  196|      3|#define SPDM_GET_CAPABILITIES_REQUEST_FLAGS_HANDSHAKE_IN_THE_CLEAR_CAP 0x00008000
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  210|      3|        SPDM_GET_CAPABILITIES_REQUEST_FLAGS_PUB_KEY_ID_CAP)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  197|      3|#define SPDM_GET_CAPABILITIES_REQUEST_FLAGS_PUB_KEY_ID_CAP 0x00010000
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  216|      3|        SPDM_GET_CAPABILITIES_REQUEST_FLAGS_CHUNK_CAP)
  |  |  |  |  ------------------
  |  |  |  |  |  |  213|      3|#define SPDM_GET_CAPABILITIES_REQUEST_FLAGS_CHUNK_CAP 0x00020000
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  228|      3|        SPDM_GET_CAPABILITIES_REQUEST_FLAGS_EP_INFO_CAP | \
  |  |  ------------------
  |  |  |  |  219|      3|#define SPDM_GET_CAPABILITIES_REQUEST_FLAGS_EP_INFO_CAP (0x00400000 | 0x00800000)
  |  |  ------------------
  |  |  229|      3|        SPDM_GET_CAPABILITIES_REQUEST_FLAGS_EVENT_CAP | \
  |  |  ------------------
  |  |  |  |  222|      3|#define SPDM_GET_CAPABILITIES_REQUEST_FLAGS_EVENT_CAP 0x02000000
  |  |  ------------------
  |  |  230|      3|        SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MULTI_KEY_CAP)
  |  |  ------------------
  |  |  |  |  223|      3|#define SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MULTI_KEY_CAP (0x04000000 | 0x08000000)
  |  |  ------------------
  ------------------
  371|      3|        } else {
  372|      3|            return (flags & SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_13_MASK);
  ------------------
  |  |  300|      3|#define SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_13_MASK ( \
  |  |  301|      3|        SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_12_MASK | \
  |  |  ------------------
  |  |  |  |  281|      3|#define SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_12_MASK ( \
  |  |  |  |  282|      3|        SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_11_MASK | \
  |  |  |  |  ------------------
  |  |  |  |  |  |  260|      3|#define SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_11_MASK ( \
  |  |  |  |  |  |  261|      3|        SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_10_MASK | \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  240|      3|#define SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_10_MASK ( \
  |  |  |  |  |  |  |  |  241|      3|        SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_CACHE_CAP | \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  233|      3|#define SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_CACHE_CAP 0x00000001
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  242|      3|        SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_CERT_CAP | \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  234|      3|#define SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_CERT_CAP 0x00000002
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  243|      3|        SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_CHAL_CAP | \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  235|      3|#define SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_CHAL_CAP 0x00000004
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  244|      3|        SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MEAS_CAP | \
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  236|      3|#define SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MEAS_CAP (0x00000008 | 0x00000010)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  245|      3|        SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MEAS_FRESH_CAP)
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  239|      3|#define SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MEAS_FRESH_CAP 0x00000020
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  262|      3|        SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_ENCRYPT_CAP | \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  248|      3|#define SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_ENCRYPT_CAP 0x00000040
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  263|      3|        SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MAC_CAP | \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  249|      3|#define SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MAC_CAP 0x00000080
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  264|      3|        SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MUT_AUTH_CAP | \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  250|      3|#define SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MUT_AUTH_CAP 0x00000100
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  265|      3|        SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_KEY_EX_CAP | \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  251|      3|#define SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_KEY_EX_CAP 0x00000200
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  266|      3|        SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_PSK_CAP | \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  252|      3|#define SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_PSK_CAP (0x00000400 | 0x00000800)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  267|      3|        SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_ENCAP_CAP | \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  255|      3|#define SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_ENCAP_CAP 0x00001000
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  268|      3|        SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_HBEAT_CAP | \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  256|      3|#define SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_HBEAT_CAP 0x00002000
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  269|      3|        SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_KEY_UPD_CAP | \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  257|      3|#define SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_KEY_UPD_CAP 0x00004000
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  270|      3|        SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_HANDSHAKE_IN_THE_CLEAR_CAP | \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  258|      3|#define SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_HANDSHAKE_IN_THE_CLEAR_CAP 0x00008000
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  271|      3|        SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_PUB_KEY_ID_CAP)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  259|      3|#define SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_PUB_KEY_ID_CAP 0x00010000
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  283|      3|        SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_CHUNK_CAP | \
  |  |  |  |  ------------------
  |  |  |  |  |  |  274|      3|#define SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_CHUNK_CAP 0x00020000
  |  |  |  |  ------------------
  |  |  |  |  284|      3|        SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_ALIAS_CERT_CAP | \
  |  |  |  |  ------------------
  |  |  |  |  |  |  275|      3|#define SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_ALIAS_CERT_CAP 0x00040000
  |  |  |  |  ------------------
  |  |  |  |  285|      3|        SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_SET_CERT_CAP | \
  |  |  |  |  ------------------
  |  |  |  |  |  |  278|      3|#define SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_SET_CERT_CAP 0x00080000
  |  |  |  |  ------------------
  |  |  |  |  286|      3|        SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_CSR_CAP | \
  |  |  |  |  ------------------
  |  |  |  |  |  |  279|      3|#define SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_CSR_CAP 0x00100000
  |  |  |  |  ------------------
  |  |  |  |  287|      3|        SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_CERT_INSTALL_RESET_CAP)
  |  |  |  |  ------------------
  |  |  |  |  |  |  280|      3|#define SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_CERT_INSTALL_RESET_CAP 0x00200000
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  302|      3|        SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_EP_INFO_CAP | \
  |  |  ------------------
  |  |  |  |  290|      3|#define SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_EP_INFO_CAP (0x00400000 | 0x00800000)
  |  |  ------------------
  |  |  303|      3|        SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MEL_CAP | \
  |  |  ------------------
  |  |  |  |  293|      3|#define SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MEL_CAP 0x01000000
  |  |  ------------------
  |  |  304|      3|        SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_EVENT_CAP | \
  |  |  ------------------
  |  |  |  |  294|      3|#define SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_EVENT_CAP 0x02000000
  |  |  ------------------
  |  |  305|      3|        SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MULTI_KEY_CAP | \
  |  |  ------------------
  |  |  |  |  295|      3|#define SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MULTI_KEY_CAP (0x04000000 | 0x08000000)
  |  |  ------------------
  |  |  306|      3|        SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_GET_KEY_PAIR_INFO_CAP | \
  |  |  ------------------
  |  |  |  |  298|      3|#define SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_GET_KEY_PAIR_INFO_CAP 0x10000000
  |  |  ------------------
  |  |  307|      3|        SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_SET_KEY_PAIR_INFO_CAP)
  |  |  ------------------
  |  |  |  |  299|      3|#define SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_SET_KEY_PAIR_INFO_CAP 0x20000000
  |  |  ------------------
  ------------------
  373|      3|        }
  374|      0|    default:
  ------------------
  |  Branch (374:5): [True: 0, False: 150]
  ------------------
  375|      0|        LIBSPDM_ASSERT(false);
  376|      0|        return 0;
  377|    150|    }
  378|    150|}

libspdm_get_response_capabilities:
  170|    843|{
  171|    843|    const spdm_get_capabilities_request_t *spdm_request;
  172|    843|    spdm_capabilities_response_t *spdm_response;
  173|    843|    libspdm_return_t status;
  174|       |
  175|    843|    spdm_request = request;
  176|       |
  177|       |    /* -=[Check Parameters Phase]=- */
  178|    843|    LIBSPDM_ASSERT(spdm_request->header.request_response_code == SPDM_GET_CAPABILITIES);
  179|       |
  180|       |    /* -=[Verify State Phase]=- */
  181|    843|    if (spdm_context->response_state != LIBSPDM_RESPONSE_STATE_NORMAL) {
  ------------------
  |  Branch (181:9): [True: 0, False: 843]
  ------------------
  182|      0|        return libspdm_responder_handle_response_state(
  183|      0|            spdm_context, spdm_request->header.request_response_code,  response_size, response);
  184|      0|    }
  185|    843|    if (spdm_context->connection_info.connection_state != LIBSPDM_CONNECTION_STATE_AFTER_VERSION) {
  ------------------
  |  Branch (185:9): [True: 0, False: 843]
  ------------------
  186|      0|        return libspdm_generate_error_response(spdm_context,
  187|      0|                                               SPDM_ERROR_CODE_UNEXPECTED_REQUEST,
  ------------------
  |  |  857|      0|#define SPDM_ERROR_CODE_UNEXPECTED_REQUEST 0x04
  ------------------
  188|      0|                                               0, response_size, response);
  189|      0|    }
  190|       |
  191|       |    /* -=[Validate Request Phase]=- */
  192|    843|    if (!libspdm_check_request_version_compatibility(
  ------------------
  |  Branch (192:9): [True: 186, False: 657]
  ------------------
  193|    843|            spdm_context, spdm_request->header.spdm_version)) {
  194|    186|        return libspdm_generate_error_response(spdm_context,
  195|    186|                                               SPDM_ERROR_CODE_VERSION_MISMATCH, 0,
  ------------------
  |  |  860|    186|#define SPDM_ERROR_CODE_VERSION_MISMATCH 0x41
  ------------------
  196|    186|                                               response_size, response);
  197|    186|    }
  198|    657|    if (spdm_request->header.spdm_version >= SPDM_MESSAGE_VERSION_12) {
  ------------------
  |  |  112|    657|#define SPDM_MESSAGE_VERSION_12 0x12
  ------------------
  |  Branch (198:9): [True: 480, False: 177]
  ------------------
  199|    480|        if (request_size < sizeof(spdm_get_capabilities_request_t)) {
  ------------------
  |  Branch (199:13): [True: 24, False: 456]
  ------------------
  200|     24|            return libspdm_generate_error_response(
  201|     24|                spdm_context, SPDM_ERROR_CODE_INVALID_REQUEST, 0, response_size, response);
  ------------------
  |  |  855|     24|#define SPDM_ERROR_CODE_INVALID_REQUEST 0x01
  ------------------
  202|    456|        } else {
  203|    456|            request_size = sizeof(spdm_get_capabilities_request_t);
  204|    456|        }
  205|    480|    } else if (spdm_request->header.spdm_version >= SPDM_MESSAGE_VERSION_11) {
  ------------------
  |  |  111|    177|#define SPDM_MESSAGE_VERSION_11 0x11
  ------------------
  |  Branch (205:16): [True: 138, False: 39]
  ------------------
  206|    138|        if (request_size < sizeof(spdm_get_capabilities_request_t) -
  ------------------
  |  Branch (206:13): [True: 12, False: 126]
  ------------------
  207|    138|            sizeof(spdm_request->data_transfer_size) - sizeof(spdm_request->max_spdm_msg_size)) {
  208|     12|            return libspdm_generate_error_response(
  209|     12|                spdm_context, SPDM_ERROR_CODE_INVALID_REQUEST, 0, response_size, response);
  ------------------
  |  |  855|     12|#define SPDM_ERROR_CODE_INVALID_REQUEST 0x01
  ------------------
  210|    126|        } else {
  211|    126|            request_size = sizeof(spdm_get_capabilities_request_t) -
  212|    126|                           sizeof(spdm_request->data_transfer_size) -
  213|    126|                           sizeof(spdm_request->max_spdm_msg_size);
  214|    126|        }
  215|    138|    } else {
  216|     39|        if (request_size < sizeof(spdm_message_header_t)) {
  ------------------
  |  Branch (216:13): [True: 0, False: 39]
  ------------------
  217|      0|            return libspdm_generate_error_response(
  218|      0|                spdm_context, SPDM_ERROR_CODE_INVALID_REQUEST, 0, response_size, response);
  ------------------
  |  |  855|      0|#define SPDM_ERROR_CODE_INVALID_REQUEST 0x01
  ------------------
  219|     39|        } else {
  220|     39|            request_size = sizeof(spdm_message_header_t);
  221|     39|        }
  222|     39|    }
  223|    621|    if (!libspdm_check_request_flag_compatibility(
  ------------------
  |  Branch (223:9): [True: 138, False: 483]
  ------------------
  224|    621|            spdm_request->flags, spdm_request->header.spdm_version)) {
  225|    138|        return libspdm_generate_error_response(spdm_context,
  226|    138|                                               SPDM_ERROR_CODE_INVALID_REQUEST, 0,
  ------------------
  |  |  855|    138|#define SPDM_ERROR_CODE_INVALID_REQUEST 0x01
  ------------------
  227|    138|                                               response_size, response);
  228|    138|    }
  229|    483|    if (spdm_request->header.spdm_version >= SPDM_MESSAGE_VERSION_12) {
  ------------------
  |  |  112|    483|#define SPDM_MESSAGE_VERSION_12 0x12
  ------------------
  |  Branch (229:9): [True: 399, False: 84]
  ------------------
  230|    399|        if ((spdm_request->data_transfer_size < SPDM_MIN_DATA_TRANSFER_SIZE_VERSION_12) ||
  ------------------
  |  |  182|    399|#define SPDM_MIN_DATA_TRANSFER_SIZE_VERSION_12  42
  ------------------
  |  Branch (230:13): [True: 12, False: 387]
  ------------------
  231|    399|            (spdm_request->data_transfer_size > spdm_request->max_spdm_msg_size)) {
  ------------------
  |  Branch (231:13): [True: 198, False: 189]
  ------------------
  232|    210|            return libspdm_generate_error_response(spdm_context,
  233|    210|                                                   SPDM_ERROR_CODE_INVALID_REQUEST, 0,
  ------------------
  |  |  855|    210|#define SPDM_ERROR_CODE_INVALID_REQUEST 0x01
  ------------------
  234|    210|                                                   response_size, response);
  235|    210|        }
  236|    189|        if (((spdm_request->flags & SPDM_GET_CAPABILITIES_REQUEST_FLAGS_CHUNK_CAP) == 0) &&
  ------------------
  |  |  213|    189|#define SPDM_GET_CAPABILITIES_REQUEST_FLAGS_CHUNK_CAP 0x00020000
  ------------------
  |  Branch (236:13): [True: 186, False: 3]
  ------------------
  237|    189|            (spdm_request->data_transfer_size != spdm_request->max_spdm_msg_size)) {
  ------------------
  |  Branch (237:13): [True: 174, False: 12]
  ------------------
  238|    174|            return libspdm_generate_error_response(spdm_context,
  239|    174|                                                   SPDM_ERROR_CODE_INVALID_REQUEST, 0,
  ------------------
  |  |  855|    174|#define SPDM_ERROR_CODE_INVALID_REQUEST 0x01
  ------------------
  240|    174|                                                   response_size, response);
  241|    174|        }
  242|    189|    }
  243|     99|    if (spdm_request->header.spdm_version >= SPDM_MESSAGE_VERSION_11) {
  ------------------
  |  |  111|     99|#define SPDM_MESSAGE_VERSION_11 0x11
  ------------------
  |  Branch (243:9): [True: 60, False: 39]
  ------------------
  244|     60|        if (spdm_request->ct_exponent > LIBSPDM_MAX_CT_EXPONENT) {
  ------------------
  |  |   36|     60|#define LIBSPDM_MAX_CT_EXPONENT 31
  ------------------
  |  Branch (244:13): [True: 24, False: 36]
  ------------------
  245|     24|            return libspdm_generate_error_response(spdm_context,
  246|     24|                                                   SPDM_ERROR_CODE_INVALID_REQUEST, 0,
  ------------------
  |  |  855|     24|#define SPDM_ERROR_CODE_INVALID_REQUEST 0x01
  ------------------
  247|     24|                                                   response_size, response);
  248|     24|        }
  249|     60|    }
  250|       |
  251|     75|    libspdm_reset_message_buffer_via_request_code(spdm_context, NULL,
  252|     75|                                                  spdm_request->header.request_response_code);
  253|       |
  254|       |    /* -=[Construct Response Phase]=- */
  255|     75|    LIBSPDM_ASSERT(*response_size >= sizeof(spdm_capabilities_response_t));
  256|     75|    *response_size = sizeof(spdm_capabilities_response_t);
  257|     75|    libspdm_zero_mem(response, *response_size);
  258|     75|    spdm_response = response;
  259|       |
  260|     75|    spdm_response->header.spdm_version = spdm_request->header.spdm_version;
  261|     75|    spdm_response->header.request_response_code = SPDM_CAPABILITIES;
  ------------------
  |  |   34|     75|#define SPDM_CAPABILITIES 0x61
  ------------------
  262|     75|    spdm_response->header.param1 = 0;
  263|     75|    spdm_response->header.param2 = 0;
  264|     75|    spdm_response->ct_exponent = spdm_context->local_context.capability.ct_exponent;
  265|     75|    spdm_response->flags =
  266|     75|        libspdm_mask_capability_flags(spdm_context, false,
  267|     75|                                      spdm_context->local_context.capability.flags);
  268|     75|    if (spdm_request->header.spdm_version >= SPDM_MESSAGE_VERSION_12) {
  ------------------
  |  |  112|     75|#define SPDM_MESSAGE_VERSION_12 0x12
  ------------------
  |  Branch (268:9): [True: 12, False: 63]
  ------------------
  269|     12|        spdm_response->data_transfer_size =
  270|     12|            spdm_context->local_context.capability.data_transfer_size;
  271|     12|        spdm_response->max_spdm_msg_size =
  272|     12|            spdm_context->local_context.capability.max_spdm_msg_size;
  273|     12|    }
  274|       |
  275|     75|    if (spdm_response->header.spdm_version >= SPDM_MESSAGE_VERSION_12) {
  ------------------
  |  |  112|     75|#define SPDM_MESSAGE_VERSION_12 0x12
  ------------------
  |  Branch (275:9): [True: 12, False: 63]
  ------------------
  276|     12|        *response_size = sizeof(spdm_capabilities_response_t);
  277|     63|    } else {
  278|     63|        *response_size = sizeof(spdm_capabilities_response_t) -
  279|     63|                         sizeof(spdm_response->data_transfer_size) -
  280|     63|                         sizeof(spdm_response->max_spdm_msg_size);
  281|     63|    }
  282|       |
  283|       |    /* -=[Process Request Phase]=- */
  284|     75|    status = libspdm_append_message_a(spdm_context, spdm_request, request_size);
  285|     75|    if (LIBSPDM_STATUS_IS_ERROR(status)) {
  ------------------
  |  |   30|     75|    (LIBSPDM_STATUS_SEVERITY(status) == LIBSPDM_SEVERITY_ERROR)
  |  |  ------------------
  |  |  |  |   37|     75|#define LIBSPDM_STATUS_SEVERITY(status) (((status) >> 28) & 0xf)
  |  |  ------------------
  |  |                   (LIBSPDM_STATUS_SEVERITY(status) == LIBSPDM_SEVERITY_ERROR)
  |  |  ------------------
  |  |  |  |   44|     75|#define LIBSPDM_SEVERITY_ERROR 0x8
  |  |  ------------------
  |  |  |  Branch (30:5): [True: 0, False: 75]
  |  |  ------------------
  ------------------
  286|      0|        return libspdm_generate_error_response(spdm_context,
  287|      0|                                               SPDM_ERROR_CODE_UNSPECIFIED, 0,
  ------------------
  |  |  858|      0|#define SPDM_ERROR_CODE_UNSPECIFIED 0x05
  ------------------
  288|      0|                                               response_size, response);
  289|      0|    }
  290|     75|    status = libspdm_append_message_a(spdm_context, spdm_response, *response_size);
  291|       |
  292|     75|    if (LIBSPDM_STATUS_IS_ERROR(status)) {
  ------------------
  |  |   30|     75|    (LIBSPDM_STATUS_SEVERITY(status) == LIBSPDM_SEVERITY_ERROR)
  |  |  ------------------
  |  |  |  |   37|     75|#define LIBSPDM_STATUS_SEVERITY(status) (((status) >> 28) & 0xf)
  |  |  ------------------
  |  |                   (LIBSPDM_STATUS_SEVERITY(status) == LIBSPDM_SEVERITY_ERROR)
  |  |  ------------------
  |  |  |  |   44|     75|#define LIBSPDM_SEVERITY_ERROR 0x8
  |  |  ------------------
  |  |  |  Branch (30:5): [True: 0, False: 75]
  |  |  ------------------
  ------------------
  293|      0|        return libspdm_generate_error_response(spdm_context,
  294|      0|                                               SPDM_ERROR_CODE_UNSPECIFIED, 0,
  ------------------
  |  |  858|      0|#define SPDM_ERROR_CODE_UNSPECIFIED 0x05
  ------------------
  295|      0|                                               response_size, response);
  296|      0|    }
  297|       |
  298|     75|    if (spdm_response->header.spdm_version >= SPDM_MESSAGE_VERSION_11) {
  ------------------
  |  |  111|     75|#define SPDM_MESSAGE_VERSION_11 0x11
  ------------------
  |  Branch (298:9): [True: 36, False: 39]
  ------------------
  299|     36|        spdm_context->connection_info.capability.ct_exponent = spdm_request->ct_exponent;
  300|     39|    } else {
  301|     39|        spdm_context->connection_info.capability.ct_exponent = 0;
  302|     39|    }
  303|       |
  304|     75|    spdm_context->connection_info.capability.flags =
  305|     75|        libspdm_mask_capability_flags(spdm_context, true, spdm_request->flags);
  306|       |
  307|     75|    if (spdm_response->header.spdm_version >= SPDM_MESSAGE_VERSION_12) {
  ------------------
  |  |  112|     75|#define SPDM_MESSAGE_VERSION_12 0x12
  ------------------
  |  Branch (307:9): [True: 12, False: 63]
  ------------------
  308|     12|        spdm_context->connection_info.capability.data_transfer_size =
  309|     12|            spdm_request->data_transfer_size;
  310|     12|        spdm_context->connection_info.capability.max_spdm_msg_size =
  311|     12|            spdm_request->max_spdm_msg_size;
  312|     63|    } else {
  313|     63|        spdm_context->connection_info.capability.data_transfer_size = 0;
  314|     63|        spdm_context->connection_info.capability.max_spdm_msg_size = 0;
  315|     63|    }
  316|       |
  317|       |    /* -=[Update State Phase]=- */
  318|     75|    libspdm_set_connection_state(spdm_context, LIBSPDM_CONNECTION_STATE_AFTER_CAPABILITIES);
  319|       |
  320|     75|    return LIBSPDM_STATUS_SUCCESS;
  ------------------
  |  |   59|     75|    LIBSPDM_STATUS_CONSTRUCT(LIBSPDM_SEVERITY_SUCCESS, LIBSPDM_SOURCE_SUCCESS, 0x0000)
  |  |  ------------------
  |  |  |  |   55|     75|    ((libspdm_return_t)(((severity) << 28) | ((source) << 16) | (code)))
  |  |  ------------------
  ------------------
  321|     75|}
libspdm_rsp_capabilities.c:libspdm_check_request_version_compatibility:
   22|    843|{
   23|    843|    uint8_t local_ver;
   24|    843|    size_t index;
   25|       |
   26|  2.89k|    for (index = 0; index < spdm_context->local_context.version.spdm_version_count; index++) {
  ------------------
  |  Branch (26:21): [True: 2.70k, False: 186]
  ------------------
   27|  2.70k|        local_ver = libspdm_get_version_from_version_number(
   28|  2.70k|            spdm_context->local_context.version.spdm_version[index]);
   29|  2.70k|        if (local_ver == version) {
  ------------------
  |  Branch (29:13): [True: 657, False: 2.04k]
  ------------------
   30|    657|            spdm_context->connection_info.version = version << SPDM_VERSION_NUMBER_SHIFT_BIT;
  ------------------
  |  |  140|    657|#define SPDM_VERSION_NUMBER_SHIFT_BIT 8
  ------------------
   31|    657|            return true;
   32|    657|        }
   33|  2.70k|    }
   34|    186|    return false;
   35|    843|}
libspdm_rsp_capabilities.c:libspdm_check_request_flag_compatibility:
   49|    621|{
   50|    621|    const uint8_t cert_cap = (uint8_t)(capabilities_flag >> 1) & 0x01;
   51|    621|    const uint8_t chal_cap = (uint8_t)(capabilities_flag >> 2) & 0x01;
   52|    621|    const uint8_t encrypt_cap = (uint8_t)(capabilities_flag >> 6) & 0x01;
   53|    621|    const uint8_t mac_cap = (uint8_t)(capabilities_flag >> 7) & 0x01;
   54|    621|    const uint8_t mut_auth_cap = (uint8_t)(capabilities_flag >> 8) & 0x01;
   55|    621|    const uint8_t key_ex_cap = (uint8_t)(capabilities_flag >> 9) & 0x01;
   56|    621|    const uint8_t psk_cap = (uint8_t)(capabilities_flag >> 10) & 0x03;
   57|    621|    const uint8_t encap_cap = (uint8_t)(capabilities_flag >> 12) & 0x01;
   58|    621|    const uint8_t hbeat_cap = (uint8_t)(capabilities_flag >> 13) & 0x01;
   59|    621|    const uint8_t key_upd_cap = (uint8_t)(capabilities_flag >> 14) & 0x01;
   60|    621|    const uint8_t handshake_in_the_clear_cap = (uint8_t)(capabilities_flag >> 15) & 0x01;
   61|    621|    const uint8_t pub_key_id_cap = (uint8_t)(capabilities_flag >> 16) & 0x01;
   62|    621|    const uint8_t ep_info_cap = (uint8_t)(capabilities_flag >> 22) & 0x03;
   63|    621|    const uint8_t event_cap = (uint8_t)(capabilities_flag >> 25) & 0x01;
   64|    621|    const uint8_t multi_key_cap = (uint8_t)(capabilities_flag >> 26) & 0x03;
   65|       |
   66|       |    /* Checks common to 1.1 and higher */
   67|    621|    if (version >= SPDM_MESSAGE_VERSION_11) {
  ------------------
  |  |  111|    621|#define SPDM_MESSAGE_VERSION_11 0x11
  ------------------
  |  Branch (67:9): [True: 582, False: 39]
  ------------------
   68|       |        /* Illegal to return reserved values. */
   69|    582|        if ((psk_cap == 2) || (psk_cap == 3)) {
  ------------------
  |  Branch (69:13): [True: 3, False: 579]
  |  Branch (69:31): [True: 15, False: 564]
  ------------------
   70|     18|            return false;
   71|     18|        }
   72|       |
   73|       |        /* Checks that originate from key exchange capabilities. */
   74|    564|        if ((key_ex_cap == 1) || (psk_cap != 0)) {
  ------------------
  |  Branch (74:13): [True: 66, False: 498]
  |  Branch (74:34): [True: 18, False: 480]
  ------------------
   75|     84|            if ((mac_cap == 0) && (encrypt_cap == 0)) {
  ------------------
  |  Branch (75:17): [True: 39, False: 45]
  |  Branch (75:35): [True: 18, False: 21]
  ------------------
   76|     18|                return false;
   77|     18|            }
   78|    480|        } else {
   79|    480|            if ((mac_cap == 1) || (encrypt_cap == 1) || (handshake_in_the_clear_cap == 1) ||
  ------------------
  |  Branch (79:17): [True: 9, False: 471]
  |  Branch (79:35): [True: 3, False: 468]
  |  Branch (79:57): [True: 3, False: 465]
  ------------------
   80|    480|                (hbeat_cap == 1) || (key_upd_cap == 1)) {
  ------------------
  |  Branch (80:17): [True: 3, False: 462]
  |  Branch (80:37): [True: 3, False: 459]
  ------------------
   81|     21|                return false;
   82|     21|            }
   83|    459|            if (version >= SPDM_MESSAGE_VERSION_13) {
  ------------------
  |  |  113|    459|#define SPDM_MESSAGE_VERSION_13 0x13
  ------------------
  |  Branch (83:17): [True: 174, False: 285]
  ------------------
   84|    174|                if (event_cap == 1) {
  ------------------
  |  Branch (84:21): [True: 12, False: 162]
  ------------------
   85|     12|                    return false;
   86|     12|                }
   87|    174|            }
   88|    459|        }
   89|    513|        if ((key_ex_cap == 0) && (psk_cap == 1)) {
  ------------------
  |  Branch (89:13): [True: 465, False: 48]
  |  Branch (89:34): [True: 18, False: 447]
  ------------------
   90|     18|            if (handshake_in_the_clear_cap == 1) {
  ------------------
  |  Branch (90:17): [True: 3, False: 15]
  ------------------
   91|      3|                return false;
   92|      3|            }
   93|     18|        }
   94|       |
   95|       |        /* Checks that originate from certificate or public key capabilities. */
   96|    510|        if ((cert_cap == 1) || (pub_key_id_cap == 1)) {
  ------------------
  |  Branch (96:13): [True: 75, False: 435]
  |  Branch (96:32): [True: 57, False: 378]
  ------------------
   97|       |            /* Certificate capabilities and public key capabilities cannot both be set. */
   98|    132|            if ((cert_cap == 1) && (pub_key_id_cap == 1)) {
  ------------------
  |  Branch (98:17): [True: 75, False: 57]
  |  Branch (98:36): [True: 3, False: 72]
  ------------------
   99|      3|                return false;
  100|      3|            }
  101|       |            /* If certificates or public keys are enabled then at least one of these capabilities
  102|       |             * must be enabled to use the key. */
  103|    129|            if ((chal_cap == 0) && (key_ex_cap == 0)) {
  ------------------
  |  Branch (103:17): [True: 63, False: 66]
  |  Branch (103:36): [True: 42, False: 21]
  ------------------
  104|     42|                if (version >= SPDM_MESSAGE_VERSION_13) {
  ------------------
  |  |  113|     42|#define SPDM_MESSAGE_VERSION_13 0x13
  ------------------
  |  Branch (104:21): [True: 21, False: 21]
  ------------------
  105|     21|                    if ((ep_info_cap == 0) || (ep_info_cap == 1)) {
  ------------------
  |  Branch (105:25): [True: 6, False: 15]
  |  Branch (105:47): [True: 3, False: 12]
  ------------------
  106|      9|                        return false;
  107|      9|                    }
  108|     21|                } else {
  109|     21|                    return false;
  110|     21|                }
  111|     42|            }
  112|    378|        } else {
  113|       |            /* If certificates or public keys are not enabled then these capabilities
  114|       |             * cannot be enabled. */
  115|    378|            if ((chal_cap == 1) || (mut_auth_cap == 1)) {
  ------------------
  |  Branch (115:17): [True: 6, False: 372]
  |  Branch (115:36): [True: 6, False: 366]
  ------------------
  116|     12|                return false;
  117|     12|            }
  118|    366|            if (version >= SPDM_MESSAGE_VERSION_13) {
  ------------------
  |  |  113|    366|#define SPDM_MESSAGE_VERSION_13 0x13
  ------------------
  |  Branch (118:17): [True: 111, False: 255]
  ------------------
  119|    111|                if (ep_info_cap == 2) {
  ------------------
  |  Branch (119:21): [True: 3, False: 108]
  ------------------
  120|      3|                    return false;
  121|      3|                }
  122|    111|            }
  123|    366|        }
  124|       |
  125|       |        /* Checks that originate from mutual authentication capabilities. */
  126|    462|        if (mut_auth_cap == 1) {
  ------------------
  |  Branch (126:13): [True: 33, False: 429]
  ------------------
  127|       |            /* Mutual authentication with asymmetric keys can only occur through the basic mutual
  128|       |             * authentication flow (CHAL_CAP == 1) or the session-based mutual authentication flow
  129|       |             * (KEY_EX_CAP == 1). */
  130|     33|            if ((key_ex_cap == 0) && (chal_cap == 0)) {
  ------------------
  |  Branch (130:17): [True: 12, False: 21]
  |  Branch (130:38): [True: 3, False: 9]
  ------------------
  131|      3|                return false;
  132|      3|            }
  133|     33|        }
  134|    462|    }
  135|       |
  136|       |    /* Checks specific to 1.1. */
  137|    498|    if (version == SPDM_MESSAGE_VERSION_11) {
  ------------------
  |  |  111|    498|#define SPDM_MESSAGE_VERSION_11 0x11
  ------------------
  |  Branch (137:9): [True: 51, False: 447]
  ------------------
  138|     51|        if ((mut_auth_cap == 1) && (encap_cap == 0)) {
  ------------------
  |  Branch (138:13): [True: 18, False: 33]
  |  Branch (138:36): [True: 6, False: 12]
  ------------------
  139|      6|            return false;
  140|      6|        }
  141|     51|    }
  142|       |
  143|       |    /* Checks specific to 1.3 and higher. */
  144|    492|    if (version >= SPDM_MESSAGE_VERSION_13) {
  ------------------
  |  |  113|    492|#define SPDM_MESSAGE_VERSION_13 0x13
  ------------------
  |  Branch (144:9): [True: 162, False: 330]
  ------------------
  145|       |        /* Illegal to return reserved values. */
  146|    162|        if ((ep_info_cap == 3) || (multi_key_cap == 3)) {
  ------------------
  |  Branch (146:13): [True: 3, False: 159]
  |  Branch (146:35): [True: 3, False: 156]
  ------------------
  147|      6|            return false;
  148|      6|        }
  149|       |        /* check multi-key and pub_key_id */
  150|    156|        if ((multi_key_cap != 0) && (pub_key_id_cap == 1)) {
  ------------------
  |  Branch (150:13): [True: 36, False: 120]
  |  Branch (150:37): [True: 3, False: 33]
  ------------------
  151|      3|            return false;
  152|      3|        }
  153|    156|    }
  154|       |
  155|       |    /* Checks that are deferred to when a message is received.
  156|       |     *
  157|       |     * If the Requester supports key exchange then MAC_CAP must be set. In addition, if the
  158|       |     * negotiated SPDM version is greater than 1.1 then the negotiated opaque data format must be
  159|       |     * OpaqueDataFmt1.
  160|       |     */
  161|       |
  162|    483|    return true;
  163|    492|}

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

libspdm_set_connection_state:
  392|     75|{
  393|     75|    if (spdm_context->connection_info.connection_state != connection_state) {
  ------------------
  |  Branch (393:9): [True: 75, False: 0]
  ------------------
  394|     75|        spdm_context->connection_info.connection_state = connection_state;
  395|     75|        libspdm_trigger_connection_state_callback(spdm_context, connection_state);
  396|     75|    }
  397|     75|}
libspdm_rsp_receive_send.c:libspdm_trigger_connection_state_callback:
  377|     75|{
  378|     75|    if (spdm_context->spdm_connection_state_callback != NULL) {
  ------------------
  |  Branch (378:9): [True: 0, False: 75]
  ------------------
  379|      0|        ((libspdm_connection_state_callback_func)
  380|      0|         spdm_context->spdm_connection_state_callback)(spdm_context, connection_state);
  381|      0|    }
  382|     75|}

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

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

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

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

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

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

libspdm_get_max_buffer_size:
   12|    562|{
   13|    562|    return LIBSPDM_MAX_SPDM_MSG_SIZE;
  ------------------
  |  |  101|    562|#define LIBSPDM_MAX_SPDM_MSG_SIZE 0x1200
  ------------------
   14|    562|}
libspdm_test_responder_capabilities_case1:
   17|    281|{
   18|    281|    libspdm_test_context_t *spdm_test_context;
   19|    281|    libspdm_context_t *spdm_context;
   20|    281|    size_t response_size;
   21|    281|    uint8_t response[LIBSPDM_MAX_SPDM_MSG_SIZE];
   22|       |
   23|    281|    spdm_test_context = *State;
   24|    281|    spdm_context = spdm_test_context->spdm_context;
   25|       |
   26|    281|    spdm_context->connection_info.connection_state =
   27|    281|        LIBSPDM_CONNECTION_STATE_AFTER_VERSION;
   28|       |
   29|    281|    response_size = sizeof(response);
   30|    281|    libspdm_get_response_capabilities(spdm_context,
   31|    281|                                      spdm_test_context->test_buffer_size,
   32|    281|                                      spdm_test_context->test_buffer,
   33|    281|                                      &response_size, response);
   34|    281|}
libspdm_test_responder_capabilities_case2:
   37|    281|{
   38|    281|    libspdm_test_context_t *spdm_test_context;
   39|    281|    libspdm_context_t *spdm_context;
   40|    281|    size_t response_size;
   41|    281|    uint8_t response[LIBSPDM_MAX_SPDM_MSG_SIZE];
   42|       |
   43|    281|    spdm_test_context = *State;
   44|    281|    spdm_context = spdm_test_context->spdm_context;
   45|       |
   46|    281|    spdm_context->response_state = LIBSPDM_RESPONSE_STATE_NORMAL;
   47|    281|    spdm_context->connection_info.connection_state =
   48|    281|        LIBSPDM_CONNECTION_STATE_AFTER_VERSION;
   49|       |
   50|    281|    response_size = sizeof(response);
   51|    281|    libspdm_get_response_capabilities(spdm_context,
   52|    281|                                      spdm_test_context->test_buffer_size,
   53|    281|                                      spdm_test_context->test_buffer,
   54|    281|                                      &response_size, response);
   55|    281|}
libspdm_test_responder_capabilities_case3:
   58|    281|{
   59|    281|    libspdm_test_context_t *spdm_test_context;
   60|    281|    libspdm_context_t *spdm_context;
   61|    281|    size_t response_size;
   62|    281|    uint8_t response[LIBSPDM_MAX_SPDM_MSG_SIZE];
   63|       |
   64|    281|    spdm_test_context = *State;
   65|    281|    spdm_context = spdm_test_context->spdm_context;
   66|       |
   67|    281|    spdm_context->response_state = LIBSPDM_RESPONSE_STATE_NORMAL;
   68|    281|    spdm_context->connection_info.connection_state =
   69|    281|        LIBSPDM_CONNECTION_STATE_AFTER_VERSION;
   70|       |
   71|    281|    response_size = sizeof(response);
   72|    281|    libspdm_get_response_capabilities(spdm_context,
   73|    281|                                      spdm_test_context->test_buffer_size,
   74|    281|                                      spdm_test_context->test_buffer,
   75|    281|                                      &response_size, response);
   76|    281|}
libspdm_run_test_harness:
   84|    281|{
   85|    281|    void *State;
   86|    281|    spdm_message_header_t *spdm_request_header;
   87|    281|    libspdm_setup_test_context(&libspdm_test_responder_context);
   88|       |
   89|    281|    spdm_request_header = (spdm_message_header_t*)test_buffer;
   90|       |
   91|    281|    if (spdm_request_header->request_response_code != SPDM_GET_CAPABILITIES) {
  ------------------
  |  |   71|    281|#define SPDM_GET_CAPABILITIES 0xE1
  ------------------
  |  Branch (91:9): [True: 279, False: 2]
  ------------------
   92|    279|        spdm_request_header->request_response_code = SPDM_GET_CAPABILITIES;
  ------------------
  |  |   71|    279|#define SPDM_GET_CAPABILITIES 0xE1
  ------------------
   93|    279|    }
   94|       |
   95|    281|    libspdm_test_responder_context.test_buffer = test_buffer;
   96|    281|    libspdm_test_responder_context.test_buffer_size = test_buffer_size;
   97|       |
   98|    281|    libspdm_unit_test_group_setup(&State);
   99|       |
  100|       |    /* Success Case */
  101|    281|    libspdm_test_responder_capabilities_case1(&State);
  102|       |    /* connection_state Check*/
  103|    281|    libspdm_test_responder_capabilities_case2(&State);
  104|       |    /* response_state*/
  105|    281|    libspdm_test_responder_capabilities_case3(&State);
  106|       |
  107|    281|    libspdm_unit_test_group_teardown(&State);
  108|    281|}

