libspdm_get_scratch_buffer_secure_message_capacity:
   17|    357|uint32_t libspdm_get_scratch_buffer_secure_message_capacity(libspdm_context_t *spdm_context) {
   18|    357|    return spdm_context->local_context.capability.max_spdm_msg_size +
   19|    357|           spdm_context->local_context.capability.transport_header_size +
   20|    357|           spdm_context->local_context.capability.transport_tail_size;
   21|    357|}
libspdm_get_scratch_buffer_large_message_capacity:
   28|    357|uint32_t libspdm_get_scratch_buffer_large_message_capacity(libspdm_context_t *spdm_context) {
   29|    357|    return spdm_context->local_context.capability.max_spdm_msg_size;
   30|    357|}
libspdm_get_scratch_buffer_sender_receiver_capacity:
   43|    357|uint32_t libspdm_get_scratch_buffer_sender_receiver_capacity(libspdm_context_t *spdm_context) {
   44|    357|    return spdm_context->local_context.capability.max_spdm_msg_size +
   45|    357|           spdm_context->local_context.capability.transport_header_size +
   46|    357|           spdm_context->local_context.capability.transport_tail_size;
   47|    357|}
libspdm_get_scratch_buffer_large_sender_receiver_capacity:
   58|    357|{
   59|    357|    return spdm_context->local_context.capability.max_spdm_msg_size +
   60|    357|           spdm_context->local_context.capability.transport_header_size +
   61|    357|           spdm_context->local_context.capability.transport_tail_size;
   62|    357|}
libspdm_get_scratch_buffer_last_spdm_request_offset:
   66|    119|uint32_t libspdm_get_scratch_buffer_last_spdm_request_offset(libspdm_context_t *spdm_context) {
   67|    119|    return 0 +
   68|    119|#if LIBSPDM_ENABLE_CAPABILITY_CHUNK_CAP
   69|    119|           libspdm_get_scratch_buffer_secure_message_capacity(spdm_context) +
   70|    119|           libspdm_get_scratch_buffer_large_message_capacity(spdm_context) +
   71|    119|#endif
   72|    119|           libspdm_get_scratch_buffer_sender_receiver_capacity(spdm_context) +
   73|    119|#if LIBSPDM_ENABLE_CAPABILITY_CHUNK_CAP
   74|    119|           libspdm_get_scratch_buffer_large_sender_receiver_capacity(spdm_context) +
   75|    119|#endif
   76|    119|           0;
   77|    119|}
libspdm_get_scratch_buffer_last_spdm_request_capacity:
   79|    238|uint32_t libspdm_get_scratch_buffer_last_spdm_request_capacity(libspdm_context_t *spdm_context) {
   80|    238|    return spdm_context->local_context.capability.max_spdm_msg_size;
   81|    238|}
libspdm_get_scratch_buffer_cache_spdm_request_offset:
   85|    119|uint32_t libspdm_get_scratch_buffer_cache_spdm_request_offset(libspdm_context_t *spdm_context) {
   86|    119|    return 0 +
   87|    119|#if LIBSPDM_ENABLE_CAPABILITY_CHUNK_CAP
   88|    119|           libspdm_get_scratch_buffer_secure_message_capacity(spdm_context) +
   89|    119|           libspdm_get_scratch_buffer_large_message_capacity(spdm_context) +
   90|    119|#endif
   91|    119|           libspdm_get_scratch_buffer_sender_receiver_capacity(spdm_context) +
   92|    119|#if LIBSPDM_ENABLE_CAPABILITY_CHUNK_CAP
   93|    119|           libspdm_get_scratch_buffer_large_sender_receiver_capacity(spdm_context) +
   94|    119|#endif
   95|    119|           libspdm_get_scratch_buffer_last_spdm_request_capacity(spdm_context) +
   96|    119|           0;
   97|    119|}
libspdm_get_scratch_buffer_cache_spdm_request_capacity:
   99|    119|uint32_t libspdm_get_scratch_buffer_cache_spdm_request_capacity(libspdm_context_t *spdm_context) {
  100|    119|    return spdm_context->local_context.capability.max_spdm_msg_size;
  101|    119|}
libspdm_get_scratch_buffer_capacity:
  105|    119|uint32_t libspdm_get_scratch_buffer_capacity(libspdm_context_t *spdm_context) {
  106|    119|    return 0 +
  107|    119|#if LIBSPDM_ENABLE_CAPABILITY_CHUNK_CAP
  108|    119|           libspdm_get_scratch_buffer_secure_message_capacity(spdm_context) +
  109|    119|           libspdm_get_scratch_buffer_large_message_capacity(spdm_context) +
  110|    119|#endif
  111|    119|           libspdm_get_scratch_buffer_sender_receiver_capacity(spdm_context) +
  112|    119|#if LIBSPDM_ENABLE_CAPABILITY_CHUNK_CAP
  113|    119|           libspdm_get_scratch_buffer_large_sender_receiver_capacity(spdm_context) +
  114|    119|#endif
  115|    119|           libspdm_get_scratch_buffer_last_spdm_request_capacity(spdm_context) +
  116|    119|#if LIBSPDM_RESPOND_IF_READY_SUPPORT
  117|    119|           libspdm_get_scratch_buffer_cache_spdm_request_capacity(spdm_context) +
  118|    119|#endif
  119|    119|           0;
  120|    119|}
libspdm_reset_message_b:
 1280|     19|{
 1281|       |#if LIBSPDM_RECORD_TRANSCRIPT_DATA_SUPPORT
 1282|       |    libspdm_reset_managed_buffer(&spdm_context->transcript.message_b);
 1283|       |#else
 1284|     19|    if (spdm_context->transcript.digest_context_m1m2 != NULL) {
  ------------------
  |  Branch (1284:9): [True: 0, False: 19]
  ------------------
 1285|      0|        libspdm_hash_free (spdm_context->connection_info.algorithm.base_hash_algo,
 1286|      0|                           spdm_context->transcript.digest_context_m1m2);
 1287|      0|        spdm_context->transcript.digest_context_m1m2 = NULL;
 1288|      0|    }
 1289|     19|#endif
 1290|     19|}
libspdm_reset_message_c:
 1298|     18|{
 1299|       |#if LIBSPDM_RECORD_TRANSCRIPT_DATA_SUPPORT
 1300|       |    libspdm_reset_managed_buffer(&spdm_context->transcript.message_c);
 1301|       |#else
 1302|     18|    if (spdm_context->transcript.digest_context_m1m2 != NULL) {
  ------------------
  |  Branch (1302:9): [True: 0, False: 18]
  ------------------
 1303|      0|        libspdm_hash_free (spdm_context->connection_info.algorithm.base_hash_algo,
 1304|      0|                           spdm_context->transcript.digest_context_m1m2);
 1305|      0|        spdm_context->transcript.digest_context_m1m2 = NULL;
 1306|      0|    }
 1307|     18|#endif
 1308|     18|}
libspdm_reset_message_mut_b:
 1316|     17|{
 1317|       |#if LIBSPDM_RECORD_TRANSCRIPT_DATA_SUPPORT
 1318|       |    libspdm_reset_managed_buffer(&spdm_context->transcript.message_mut_b);
 1319|       |#else
 1320|     17|    if (spdm_context->transcript.digest_context_mut_m1m2 != NULL) {
  ------------------
  |  Branch (1320:9): [True: 0, False: 17]
  ------------------
 1321|      0|        libspdm_hash_free (spdm_context->connection_info.algorithm.base_hash_algo,
 1322|      0|                           spdm_context->transcript.digest_context_mut_m1m2);
 1323|      0|        spdm_context->transcript.digest_context_mut_m1m2 = NULL;
 1324|      0|    }
 1325|     17|#endif
 1326|     17|}
libspdm_reset_message_mut_c:
 1334|     17|{
 1335|       |#if LIBSPDM_RECORD_TRANSCRIPT_DATA_SUPPORT
 1336|       |    libspdm_reset_managed_buffer(&spdm_context->transcript.message_mut_c);
 1337|       |#else
 1338|     17|    if (spdm_context->transcript.digest_context_mut_m1m2 != NULL) {
  ------------------
  |  Branch (1338:9): [True: 0, False: 17]
  ------------------
 1339|      0|        libspdm_hash_free (spdm_context->connection_info.algorithm.base_hash_algo,
 1340|      0|                           spdm_context->transcript.digest_context_mut_m1m2);
 1341|      0|        spdm_context->transcript.digest_context_mut_m1m2 = NULL;
 1342|      0|    }
 1343|     17|#endif
 1344|     17|}
libspdm_reset_message_m:
 1355|     32|{
 1356|     32|    libspdm_session_info_t *spdm_session_info;
 1357|       |
 1358|     32|    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|     32|    if (spdm_session_info == NULL) {
  ------------------
  |  Branch (1366:9): [True: 0, False: 32]
  ------------------
 1367|      0|        if (spdm_context->transcript.digest_context_l1l2 != NULL) {
  ------------------
  |  Branch (1367:13): [True: 0, False: 0]
  ------------------
 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|     32|    } else {
 1373|     32|        if (spdm_session_info->session_transcript.digest_context_l1l2 != NULL) {
  ------------------
  |  Branch (1373:13): [True: 0, False: 32]
  ------------------
 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|     32|    }
 1379|     32|#endif
 1380|     32|}
libspdm_reset_message_e:
 1461|      1|{
 1462|      1|    libspdm_session_info_t *spdm_session_info;
 1463|       |
 1464|      1|    spdm_session_info = session_info;
 1465|       |#if LIBSPDM_RECORD_TRANSCRIPT_DATA_SUPPORT
 1466|       |    if (spdm_session_info == NULL) {
 1467|       |        libspdm_reset_managed_buffer(&spdm_context->transcript.message_e);
 1468|       |    } else {
 1469|       |        libspdm_reset_managed_buffer(&spdm_session_info->session_transcript.message_e);
 1470|       |    }
 1471|       |#else
 1472|      1|    if (spdm_session_info == NULL) {
  ------------------
  |  Branch (1472:9): [True: 0, False: 1]
  ------------------
 1473|      0|        if (spdm_context->transcript.digest_context_il1il2 != NULL) {
  ------------------
  |  Branch (1473:13): [True: 0, False: 0]
  ------------------
 1474|      0|            libspdm_hash_free (spdm_context->connection_info.algorithm.base_hash_algo,
 1475|      0|                               spdm_context->transcript.digest_context_il1il2);
 1476|      0|            spdm_context->transcript.digest_context_il1il2 = NULL;
 1477|      0|        }
 1478|      1|    } else {
 1479|      1|        if (spdm_session_info->session_transcript.digest_context_il1il2 != NULL) {
  ------------------
  |  Branch (1479:13): [True: 0, False: 1]
  ------------------
 1480|      0|            libspdm_hash_free (spdm_context->connection_info.algorithm.base_hash_algo,
 1481|      0|                               spdm_session_info->session_transcript.digest_context_il1il2);
 1482|      0|            spdm_session_info->session_transcript.digest_context_il1il2 = NULL;
 1483|      0|        }
 1484|      1|    }
 1485|      1|#endif
 1486|      1|}
libspdm_reset_message_encap_e:
 1497|      1|{
 1498|      1|    libspdm_session_info_t *spdm_session_info;
 1499|       |
 1500|      1|    spdm_session_info = session_info;
 1501|       |#if LIBSPDM_RECORD_TRANSCRIPT_DATA_SUPPORT
 1502|       |    if (spdm_session_info == NULL) {
 1503|       |        libspdm_reset_managed_buffer(&spdm_context->transcript.message_encap_e);
 1504|       |    } else {
 1505|       |        libspdm_reset_managed_buffer(&spdm_session_info->session_transcript.message_encap_e);
 1506|       |    }
 1507|       |#else
 1508|      1|    if (spdm_session_info == NULL) {
  ------------------
  |  Branch (1508:9): [True: 0, False: 1]
  ------------------
 1509|      0|        if (spdm_context->transcript.digest_context_encap_il1il2 != NULL) {
  ------------------
  |  Branch (1509:13): [True: 0, False: 0]
  ------------------
 1510|      0|            libspdm_hash_free (spdm_context->connection_info.algorithm.base_hash_algo,
 1511|      0|                               spdm_context->transcript.digest_context_encap_il1il2);
 1512|      0|            spdm_context->transcript.digest_context_encap_il1il2 = NULL;
 1513|      0|        }
 1514|      1|    } else {
 1515|      1|        if (spdm_session_info->session_transcript.digest_context_encap_il1il2 != NULL) {
  ------------------
  |  Branch (1515:13): [True: 0, False: 1]
  ------------------
 1516|      0|            libspdm_hash_free (spdm_context->connection_info.algorithm.base_hash_algo,
 1517|      0|                               spdm_session_info->session_transcript.digest_context_encap_il1il2);
 1518|      0|            spdm_session_info->session_transcript.digest_context_encap_il1il2 = NULL;
 1519|      0|        }
 1520|      1|    }
 1521|      1|#endif
 1522|      1|}
libspdm_reset_message_buffer_via_request_code:
 1533|     34|{
 1534|     34|    libspdm_context_t *spdm_context;
 1535|       |
 1536|     34|    spdm_context = context;
 1537|       |    /**
 1538|       |     * Any request other than SPDM_GET_MEASUREMENTS resets L1/L2
 1539|       |     */
 1540|     34|    if (request_code != SPDM_GET_MEASUREMENTS) {
  ------------------
  |  |   70|     34|#define SPDM_GET_MEASUREMENTS 0xE0
  ------------------
  |  Branch (1540:9): [True: 32, False: 2]
  ------------------
 1541|     32|        libspdm_reset_message_m(spdm_context, session_info);
 1542|     32|    }
 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|     34|    switch (request_code)
 1549|     34|    {
 1550|      6|    case SPDM_KEY_EXCHANGE:
  ------------------
  |  |   77|      6|#define SPDM_KEY_EXCHANGE 0xE4
  ------------------
  |  Branch (1550:5): [True: 6, False: 28]
  ------------------
 1551|      8|    case SPDM_GET_MEASUREMENTS:
  ------------------
  |  |   70|      8|#define SPDM_GET_MEASUREMENTS 0xE0
  ------------------
  |  Branch (1551:5): [True: 2, False: 32]
  ------------------
 1552|      9|    case SPDM_FINISH:
  ------------------
  |  |   78|      9|#define SPDM_FINISH 0xE5
  ------------------
  |  Branch (1552:5): [True: 1, False: 33]
  ------------------
 1553|     11|    case SPDM_PSK_EXCHANGE:
  ------------------
  |  |   79|     11|#define SPDM_PSK_EXCHANGE 0xE6
  ------------------
  |  Branch (1553:5): [True: 2, False: 32]
  ------------------
 1554|     12|    case SPDM_PSK_FINISH:
  ------------------
  |  |   80|     12|#define SPDM_PSK_FINISH 0xE7
  ------------------
  |  Branch (1554:5): [True: 1, False: 33]
  ------------------
 1555|     13|    case SPDM_KEY_UPDATE:
  ------------------
  |  |   82|     13|#define SPDM_KEY_UPDATE 0xE9
  ------------------
  |  Branch (1555:5): [True: 1, False: 33]
  ------------------
 1556|     14|    case SPDM_HEARTBEAT:
  ------------------
  |  |   81|     14|#define SPDM_HEARTBEAT 0xE8
  ------------------
  |  Branch (1556:5): [True: 1, False: 33]
  ------------------
 1557|     15|    case SPDM_GET_ENCAPSULATED_REQUEST:
  ------------------
  |  |   83|     15|#define SPDM_GET_ENCAPSULATED_REQUEST 0xEA
  ------------------
  |  Branch (1557:5): [True: 1, False: 33]
  ------------------
 1558|     16|    case SPDM_END_SESSION:
  ------------------
  |  |   85|     16|#define SPDM_END_SESSION 0xEC
  ------------------
  |  Branch (1558:5): [True: 1, False: 33]
  ------------------
 1559|     17|    case SPDM_GET_MEASUREMENT_EXTENSION_LOG:
  ------------------
  |  |   98|     17|#define SPDM_GET_MEASUREMENT_EXTENSION_LOG 0xEF
  ------------------
  |  Branch (1559:5): [True: 1, False: 33]
  ------------------
 1560|     17|        if (spdm_context->connection_info.connection_state <
  ------------------
  |  Branch (1560:13): [True: 17, False: 0]
  ------------------
 1561|     17|            LIBSPDM_CONNECTION_STATE_AUTHENTICATED) {
 1562|     17|            libspdm_reset_message_b(spdm_context);
 1563|     17|            libspdm_reset_message_c(spdm_context);
 1564|     17|            libspdm_reset_message_mut_b(spdm_context);
 1565|     17|            libspdm_reset_message_mut_c(spdm_context);
 1566|     17|        }
 1567|     17|        break;
 1568|      1|    case SPDM_DELIVER_ENCAPSULATED_RESPONSE:
  ------------------
  |  |   84|      1|#define SPDM_DELIVER_ENCAPSULATED_RESPONSE 0xEB
  ------------------
  |  Branch (1568:5): [True: 1, False: 33]
  ------------------
 1569|      1|        if (spdm_context->connection_info.connection_state <
  ------------------
  |  Branch (1569:13): [True: 1, False: 0]
  ------------------
 1570|      1|            LIBSPDM_CONNECTION_STATE_AUTHENTICATED) {
 1571|      1|            libspdm_reset_message_b(spdm_context);
 1572|      1|            libspdm_reset_message_c(spdm_context);
 1573|      1|        }
 1574|      1|        break;
 1575|      1|    case SPDM_GET_DIGESTS:
  ------------------
  |  |   66|      1|#define SPDM_GET_DIGESTS 0x81
  ------------------
  |  Branch (1575:5): [True: 1, False: 33]
  ------------------
 1576|      1|        libspdm_reset_message_b(spdm_context);
 1577|      1|        break;
 1578|      1|    case SPDM_GET_ENDPOINT_INFO:
  ------------------
  |  |   94|      1|#define SPDM_GET_ENDPOINT_INFO 0x87
  ------------------
  |  Branch (1578:5): [True: 1, False: 33]
  ------------------
 1579|      1|        libspdm_reset_message_e(spdm_context, session_info);
 1580|      1|        libspdm_reset_message_encap_e(spdm_context, session_info);
 1581|      1|        break;
 1582|     14|    default:
  ------------------
  |  Branch (1582:5): [True: 14, False: 20]
  ------------------
 1583|     14|        break;
 1584|     34|    }
 1585|     34|}
libspdm_get_connection_version:
 2632|    323|{
 2633|    323|    return (uint8_t)(spdm_context->connection_info.version >> SPDM_VERSION_NUMBER_SHIFT_BIT);
  ------------------
  |  |  140|    323|#define SPDM_VERSION_NUMBER_SHIFT_BIT 8
  ------------------
 2634|    323|}
libspdm_is_capabilities_flag_supported:
 2651|     46|{
 2652|     46|    uint32_t negotiated_requester_capabilities_flag;
 2653|     46|    uint32_t negotiated_responder_capabilities_flag;
 2654|       |
 2655|     46|    if (is_requester) {
  ------------------
  |  Branch (2655:9): [True: 46, False: 0]
  ------------------
 2656|     46|        negotiated_requester_capabilities_flag = spdm_context->local_context.capability.flags;
 2657|     46|        negotiated_responder_capabilities_flag = spdm_context->connection_info.capability.flags;
 2658|     46|    } else {
 2659|      0|        negotiated_requester_capabilities_flag = spdm_context->connection_info.capability.flags;
 2660|      0|        negotiated_responder_capabilities_flag = spdm_context->local_context.capability.flags;
 2661|      0|    }
 2662|       |
 2663|     46|    if (((requester_capabilities_flag == 0) ||
  ------------------
  |  Branch (2663:10): [True: 0, False: 46]
  ------------------
 2664|     46|         ((negotiated_requester_capabilities_flag &
  ------------------
  |  Branch (2664:10): [True: 46, False: 0]
  ------------------
 2665|     46|           requester_capabilities_flag) != 0)) &&
 2666|     46|        ((responder_capabilities_flag == 0) ||
  ------------------
  |  Branch (2666:10): [True: 0, False: 46]
  ------------------
 2667|     46|         ((negotiated_responder_capabilities_flag &
  ------------------
  |  Branch (2667:10): [True: 46, False: 0]
  ------------------
 2668|     46|           responder_capabilities_flag) != 0))) {
 2669|     46|        return true;
 2670|     46|    } else {
 2671|      0|        return false;
 2672|      0|    }
 2673|     46|}
libspdm_register_device_io_func:
 2720|    119|{
 2721|    119|    libspdm_context_t *context;
 2722|       |
 2723|    119|    context = spdm_context;
 2724|    119|    context->send_message = send_message;
 2725|    119|    context->receive_message = receive_message;
 2726|    119|}
libspdm_register_device_buffer_func:
 2779|    119|{
 2780|    119|    libspdm_context_t *context;
 2781|       |
 2782|    119|    context = spdm_context;
 2783|    119|    context->sender_buffer_size = sender_buffer_size;
 2784|    119|    context->receiver_buffer_size = receiver_buffer_size;
 2785|    119|    context->acquire_sender_buffer = acquire_sender_buffer;
 2786|    119|    context->release_sender_buffer = release_sender_buffer;
 2787|    119|    context->acquire_receiver_buffer = acquire_receiver_buffer;
 2788|    119|    context->release_receiver_buffer = release_receiver_buffer;
 2789|       |
 2790|    119|    LIBSPDM_ASSERT (sender_buffer_size >=
 2791|    119|                    context->local_context.capability.transport_header_size +
 2792|    119|                    context->local_context.capability.transport_tail_size);
 2793|    119|    sender_buffer_size -= (context->local_context.capability.transport_header_size +
 2794|    119|                           context->local_context.capability.transport_tail_size);
 2795|    119|    LIBSPDM_ASSERT (sender_buffer_size >= SPDM_MIN_DATA_TRANSFER_SIZE_VERSION_12);
 2796|    119|    context->local_context.capability.sender_data_transfer_size = sender_buffer_size;
 2797|       |
 2798|    119|    LIBSPDM_ASSERT(receiver_buffer_size >=
 2799|    119|                   context->local_context.capability.transport_header_size +
 2800|    119|                   context->local_context.capability.transport_tail_size);
 2801|    119|    receiver_buffer_size -= (context->local_context.capability.transport_header_size +
 2802|    119|                             context->local_context.capability.transport_tail_size);
 2803|    119|    LIBSPDM_ASSERT (receiver_buffer_size >= SPDM_MIN_DATA_TRANSFER_SIZE_VERSION_12);
 2804|    119|    context->local_context.capability.data_transfer_size = receiver_buffer_size;
 2805|    119|}
libspdm_register_transport_layer_func:
 2823|    119|{
 2824|    119|    libspdm_context_t *context;
 2825|       |
 2826|    119|    context = spdm_context;
 2827|       |
 2828|       |    /* fix the data_transfer_size if it is set before */
 2829|    119|    if ((context->local_context.capability.data_transfer_size != 0) &&
  ------------------
  |  Branch (2829:9): [True: 0, False: 119]
  ------------------
 2830|    119|        (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|    119|    if ((context->local_context.capability.sender_data_transfer_size != 0) &&
  ------------------
  |  Branch (2836:9): [True: 0, False: 119]
  ------------------
 2837|    119|        (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|    119|    context->local_context.capability.max_spdm_msg_size = max_spdm_msg_size;
 2845|    119|    context->local_context.capability.transport_header_size = transport_header_size;
 2846|    119|    context->local_context.capability.transport_tail_size = transport_tail_size;
 2847|    119|    context->transport_encode_message = transport_encode_message;
 2848|    119|    context->transport_decode_message = transport_decode_message;
 2849|    119|}
libspdm_get_sizeof_required_scratch_buffer:
 2886|    119|{
 2887|    119|    libspdm_context_t *context;
 2888|    119|    size_t scratch_buffer_size;
 2889|       |
 2890|    119|    context = spdm_context;
 2891|    119|    LIBSPDM_ASSERT (context->local_context.capability.max_spdm_msg_size != 0);
 2892|       |
 2893|    119|    scratch_buffer_size = libspdm_get_scratch_buffer_capacity(context);
 2894|    119|    return scratch_buffer_size;
 2895|    119|}
libspdm_set_scratch_buffer:
 2911|    119|{
 2912|    119|    libspdm_context_t *context;
 2913|       |
 2914|    119|    context = spdm_context;
 2915|    119|    LIBSPDM_ASSERT (context->local_context.capability.max_spdm_msg_size != 0);
 2916|    119|    LIBSPDM_ASSERT (scratch_buffer_size >= libspdm_get_scratch_buffer_capacity(spdm_context));
 2917|    119|    context->scratch_buffer = scratch_buffer;
 2918|    119|    context->scratch_buffer_size = scratch_buffer_size;
 2919|    119|    context->last_spdm_request = (uint8_t *)scratch_buffer +
 2920|    119|                                 libspdm_get_scratch_buffer_last_spdm_request_offset(spdm_context);
 2921|    119|#if LIBSPDM_RESPOND_IF_READY_SUPPORT
 2922|    119|    context->cache_spdm_request = (uint8_t *)scratch_buffer +
 2923|    119|                                  libspdm_get_scratch_buffer_cache_spdm_request_offset(spdm_context);
 2924|    119|#endif
 2925|    119|}
libspdm_init_context_with_secured_context:
 3240|    119|{
 3241|    119|    libspdm_context_t *context;
 3242|    119|    size_t index;
 3243|       |
 3244|    119|    LIBSPDM_ASSERT(spdm_context != NULL);
 3245|    119|    LIBSPDM_ASSERT(secured_contexts != NULL);
 3246|    119|    LIBSPDM_ASSERT(num_secured_contexts == LIBSPDM_MAX_SESSION_COUNT);
 3247|       |
 3248|    119|    context = spdm_context;
 3249|    119|    libspdm_zero_mem(context, sizeof(libspdm_context_t));
 3250|    119|    context->version = LIBSPDM_CONTEXT_STRUCT_VERSION;
  ------------------
  |  |  527|    119|#define LIBSPDM_CONTEXT_STRUCT_VERSION 0x3
  ------------------
 3251|    119|    context->transcript.message_a.max_buffer_size =
 3252|    119|        sizeof(context->transcript.message_a.buffer);
 3253|    119|    context->transcript.message_d.max_buffer_size =
 3254|    119|        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|    119|    context->response_state = LIBSPDM_RESPONSE_STATE_NORMAL;
 3272|    119|    context->local_context.version.spdm_version_count = SPDM_MAX_VERSION_COUNT;
  ------------------
  |  |   17|    119|#define SPDM_MAX_VERSION_COUNT 4
  ------------------
 3273|    119|    context->local_context.version.spdm_version[0] = SPDM_MESSAGE_VERSION_10 <<
  ------------------
  |  |  110|    119|#define SPDM_MESSAGE_VERSION_10 0x10
  ------------------
 3274|    119|                                                     SPDM_VERSION_NUMBER_SHIFT_BIT;
  ------------------
  |  |  140|    119|#define SPDM_VERSION_NUMBER_SHIFT_BIT 8
  ------------------
 3275|    119|    context->local_context.version.spdm_version[1] = SPDM_MESSAGE_VERSION_11 <<
  ------------------
  |  |  111|    119|#define SPDM_MESSAGE_VERSION_11 0x11
  ------------------
 3276|    119|                                                     SPDM_VERSION_NUMBER_SHIFT_BIT;
  ------------------
  |  |  140|    119|#define SPDM_VERSION_NUMBER_SHIFT_BIT 8
  ------------------
 3277|    119|    context->local_context.version.spdm_version[2] = SPDM_MESSAGE_VERSION_12 <<
  ------------------
  |  |  112|    119|#define SPDM_MESSAGE_VERSION_12 0x12
  ------------------
 3278|    119|                                                     SPDM_VERSION_NUMBER_SHIFT_BIT;
  ------------------
  |  |  140|    119|#define SPDM_VERSION_NUMBER_SHIFT_BIT 8
  ------------------
 3279|    119|    context->local_context.version.spdm_version[3] = SPDM_MESSAGE_VERSION_13 <<
  ------------------
  |  |  113|    119|#define SPDM_MESSAGE_VERSION_13 0x13
  ------------------
 3280|    119|                                                     SPDM_VERSION_NUMBER_SHIFT_BIT;
  ------------------
  |  |  140|    119|#define SPDM_VERSION_NUMBER_SHIFT_BIT 8
  ------------------
 3281|    119|    context->local_context.secured_message_version.spdm_version_count =
 3282|    119|        SECURED_SPDM_MAX_VERSION_COUNT;
  ------------------
  |  |   55|    119|#define SECURED_SPDM_MAX_VERSION_COUNT 3
  ------------------
 3283|    119|    context->local_context.secured_message_version.spdm_version[0] =
 3284|    119|        SECURED_SPDM_VERSION_10 << SPDM_VERSION_NUMBER_SHIFT_BIT;
  ------------------
  |  |   57|    119|#define SECURED_SPDM_VERSION_10 0x10
  ------------------
                      SECURED_SPDM_VERSION_10 << SPDM_VERSION_NUMBER_SHIFT_BIT;
  ------------------
  |  |  140|    119|#define SPDM_VERSION_NUMBER_SHIFT_BIT 8
  ------------------
 3285|    119|    context->local_context.secured_message_version.spdm_version[1] =
 3286|    119|        SECURED_SPDM_VERSION_11 << SPDM_VERSION_NUMBER_SHIFT_BIT;
  ------------------
  |  |   58|    119|#define SECURED_SPDM_VERSION_11 0x11
  ------------------
                      SECURED_SPDM_VERSION_11 << SPDM_VERSION_NUMBER_SHIFT_BIT;
  ------------------
  |  |  140|    119|#define SPDM_VERSION_NUMBER_SHIFT_BIT 8
  ------------------
 3287|    119|    context->local_context.secured_message_version.spdm_version[2] =
 3288|    119|        SECURED_SPDM_VERSION_12 << SPDM_VERSION_NUMBER_SHIFT_BIT;
  ------------------
  |  |   59|    119|#define SECURED_SPDM_VERSION_12 0x12
  ------------------
                      SECURED_SPDM_VERSION_12 << SPDM_VERSION_NUMBER_SHIFT_BIT;
  ------------------
  |  |  140|    119|#define SPDM_VERSION_NUMBER_SHIFT_BIT 8
  ------------------
 3289|    119|    context->local_context.capability.st1 = SPDM_ST1_VALUE_US;
  ------------------
  |  | 1514|    119|#define SPDM_ST1_VALUE_US 100000
  ------------------
 3290|       |
 3291|    119|    context->mut_auth_cert_chain_buffer_size = 0;
 3292|       |
 3293|    119|    context->max_spdm_session_sequence_number = LIBSPDM_MAX_SPDM_SESSION_SEQUENCE_NUMBER;
  ------------------
  |  |   39|    119|#define LIBSPDM_MAX_SPDM_SESSION_SEQUENCE_NUMBER 0xFFFFFFFFFFFFFFFFull
  ------------------
 3294|       |
 3295|    119|    context->latest_session_id = INVALID_SESSION_ID;
  ------------------
  |  |   28|    119|#define INVALID_SESSION_ID 0
  ------------------
 3296|    119|    context->last_spdm_request_session_id = INVALID_SESSION_ID;
  ------------------
  |  |   28|    119|#define INVALID_SESSION_ID 0
  ------------------
 3297|    119|    context->last_spdm_request_session_id_valid = false;
 3298|    119|    context->last_spdm_request_size = 0;
 3299|       |
 3300|       |    /* To be updated in libspdm_register_device_buffer_func */
 3301|    119|    context->local_context.capability.data_transfer_size = 0;
 3302|    119|    context->local_context.capability.sender_data_transfer_size = 0;
 3303|    119|    context->local_context.capability.max_spdm_msg_size = 0;
 3304|       |
 3305|    595|    for (index = 0; index < num_secured_contexts; index++) {
  ------------------
  |  Branch (3305:21): [True: 476, False: 119]
  ------------------
 3306|    476|        if (secured_contexts[index] == NULL) {
  ------------------
  |  Branch (3306:13): [True: 0, False: 476]
  ------------------
 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|    476|        context->session_info[index].secured_message_context = secured_contexts[index];
 3311|    476|        libspdm_secured_message_init_context(
 3312|    476|            context->session_info[index].secured_message_context);
 3313|    476|    }
 3314|       |
 3315|    119|    return LIBSPDM_STATUS_SUCCESS;
  ------------------
  |  |   59|    119|    LIBSPDM_STATUS_CONSTRUCT(LIBSPDM_SEVERITY_SUCCESS, LIBSPDM_SOURCE_SUCCESS, 0x0000)
  |  |  ------------------
  |  |  |  |   55|    119|    ((libspdm_return_t)(((severity) << 28) | ((source) << 16) | (code)))
  |  |  ------------------
  ------------------
 3316|    119|}
libspdm_init_context:
 3331|    119|{
 3332|    119|    libspdm_context_t *context;
 3333|    119|    void *secured_context;
 3334|    119|    void *secured_contexts[LIBSPDM_MAX_SESSION_COUNT];
 3335|    119|    size_t secured_context_size;
 3336|    119|    size_t index;
 3337|       |
 3338|    119|    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|    119|    context = spdm_context;
 3343|    119|    secured_context = (void *)((size_t)(context + 1));
 3344|    119|    secured_context_size = libspdm_secured_message_get_context_size();
 3345|       |
 3346|    595|    for (index = 0; index < LIBSPDM_MAX_SESSION_COUNT; index++)
  ------------------
  |  |  198|    595|#define LIBSPDM_MAX_SESSION_COUNT 4
  ------------------
  |  Branch (3346:21): [True: 476, False: 119]
  ------------------
 3347|    476|    {
 3348|    476|        secured_contexts[index] = (uint8_t *)secured_context + secured_context_size * index;
 3349|    476|    }
 3350|       |
 3351|    119|    return libspdm_init_context_with_secured_context(spdm_context,
 3352|    119|                                                     secured_contexts,
 3353|    119|                                                     LIBSPDM_MAX_SESSION_COUNT);
  ------------------
  |  |  198|    119|#define LIBSPDM_MAX_SESSION_COUNT 4
  ------------------
 3354|    119|}
libspdm_get_context_size:
 3467|    119|{
 3468|    119|    size_t size;
 3469|       |
 3470|    119|    size = sizeof(libspdm_context_t) +
 3471|    119|           libspdm_secured_message_get_context_size() * LIBSPDM_MAX_SESSION_COUNT;
  ------------------
  |  |  198|    119|#define LIBSPDM_MAX_SESSION_COUNT 4
  ------------------
 3472|    119|    LIBSPDM_ASSERT (size == LIBSPDM_CONTEXT_SIZE_ALL);
 3473|    119|    return size;
 3474|    119|}

libspdm_session_info_init:
   18|    119|{
   19|    119|    libspdm_session_type_t session_type;
   20|    119|    uint32_t capabilities_flag;
   21|       |
   22|    119|    if (session_id != INVALID_SESSION_ID) {
  ------------------
  |  |   28|    119|#define INVALID_SESSION_ID 0
  ------------------
  |  Branch (22:9): [True: 119, False: 0]
  ------------------
   23|    119|        if (use_psk) {
  ------------------
  |  Branch (23:13): [True: 119, False: 0]
  ------------------
   24|    119|            LIBSPDM_ASSERT((spdm_context->max_psk_session_count == 0) ||
   25|    119|                           (spdm_context->current_psk_session_count <
   26|    119|                            spdm_context->max_psk_session_count));
   27|    119|            spdm_context->current_psk_session_count++;
   28|    119|        } else {
   29|      0|            LIBSPDM_ASSERT((spdm_context->max_dhe_session_count == 0) ||
   30|      0|                           (spdm_context->current_dhe_session_count <
   31|      0|                            spdm_context->max_dhe_session_count));
   32|      0|            spdm_context->current_dhe_session_count++;
   33|      0|        }
   34|    119|    } else {
   35|      0|        if (use_psk) {
  ------------------
  |  Branch (35:13): [True: 0, False: 0]
  ------------------
   36|      0|            if (spdm_context->current_psk_session_count > 0) {
  ------------------
  |  Branch (36:17): [True: 0, False: 0]
  ------------------
   37|      0|                spdm_context->current_psk_session_count--;
   38|      0|            }
   39|      0|        } else {
   40|      0|            if (spdm_context->current_dhe_session_count > 0) {
  ------------------
  |  Branch (40:17): [True: 0, False: 0]
  ------------------
   41|      0|                spdm_context->current_dhe_session_count--;
   42|      0|            }
   43|      0|        }
   44|      0|    }
   45|       |
   46|    119|    capabilities_flag = spdm_context->connection_info.capability.flags &
   47|    119|                        spdm_context->local_context.capability.flags;
   48|    119|    switch (capabilities_flag &
   49|    119|            (SPDM_GET_CAPABILITIES_REQUEST_FLAGS_ENCRYPT_CAP |
  ------------------
  |  |  187|    119|#define SPDM_GET_CAPABILITIES_REQUEST_FLAGS_ENCRYPT_CAP 0x00000040
  ------------------
   50|    119|             SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MAC_CAP)) {
  ------------------
  |  |  188|    119|#define SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MAC_CAP 0x00000080
  ------------------
   51|      0|    case 0:
  ------------------
  |  Branch (51:5): [True: 0, False: 119]
  ------------------
   52|      0|        session_type = LIBSPDM_SESSION_TYPE_NONE;
   53|      0|        break;
   54|    119|    case (SPDM_GET_CAPABILITIES_REQUEST_FLAGS_ENCRYPT_CAP |
  ------------------
  |  |  187|    119|#define SPDM_GET_CAPABILITIES_REQUEST_FLAGS_ENCRYPT_CAP 0x00000040
  ------------------
  |  Branch (54:5): [True: 119, False: 0]
  ------------------
   55|    119|          SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MAC_CAP):
  ------------------
  |  |  188|    119|#define SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MAC_CAP 0x00000080
  ------------------
   56|    119|        session_type = LIBSPDM_SESSION_TYPE_ENC_MAC;
   57|    119|        break;
   58|      0|    case SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MAC_CAP:
  ------------------
  |  |  188|      0|#define SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MAC_CAP 0x00000080
  ------------------
  |  Branch (58:5): [True: 0, False: 119]
  ------------------
   59|      0|        session_type = LIBSPDM_SESSION_TYPE_MAC_ONLY;
   60|      0|        break;
   61|      0|    default:
  ------------------
  |  Branch (61:5): [True: 0, False: 119]
  ------------------
   62|      0|        LIBSPDM_ASSERT(false);
   63|      0|        session_type = LIBSPDM_SESSION_TYPE_MAX;
   64|      0|        break;
   65|    119|    }
   66|       |
   67|    119|#if !(LIBSPDM_RECORD_TRANSCRIPT_DATA_SUPPORT)
   68|    119|    if (session_info->session_transcript.digest_context_th != NULL) {
  ------------------
  |  Branch (68:9): [True: 0, False: 119]
  ------------------
   69|      0|        libspdm_hash_free (spdm_context->connection_info.algorithm.base_hash_algo,
   70|      0|                           session_info->session_transcript.digest_context_th);
   71|      0|        session_info->session_transcript.digest_context_th = NULL;
   72|      0|    }
   73|    119|    if (session_info->session_transcript.digest_context_th_backup != NULL) {
  ------------------
  |  Branch (73:9): [True: 0, False: 119]
  ------------------
   74|      0|        libspdm_hash_free (spdm_context->connection_info.algorithm.base_hash_algo,
   75|      0|                           session_info->session_transcript.digest_context_th_backup);
   76|      0|        session_info->session_transcript.digest_context_th_backup = NULL;
   77|      0|    }
   78|    119|#endif
   79|       |
   80|    119|    libspdm_zero_mem (&(session_info->last_key_update_request), sizeof(spdm_key_update_request_t));
   81|    119|    libspdm_zero_mem(session_info, offsetof(libspdm_session_info_t, secured_message_context));
   82|    119|    libspdm_secured_message_init_context(session_info->secured_message_context);
   83|    119|    session_info->session_id = session_id;
   84|    119|    session_info->use_psk = use_psk;
   85|    119|    libspdm_secured_message_set_use_psk(session_info->secured_message_context, use_psk);
   86|    119|    libspdm_secured_message_set_session_type(session_info->secured_message_context, session_type);
   87|       |
   88|       |    /* DSP0277 1.2 explicitly specifies a little-endian sequence number. 1.0 and 1.1 leave it up to
   89|       |     * the Integrator to specify. */
   90|    119|    if ((spdm_context->connection_info.secured_message_version >> SPDM_VERSION_NUMBER_SHIFT_BIT) >=
  ------------------
  |  |  140|    119|#define SPDM_VERSION_NUMBER_SHIFT_BIT 8
  ------------------
  |  Branch (90:9): [True: 0, False: 119]
  ------------------
   91|    119|        SECURED_SPDM_VERSION_12) {
  ------------------
  |  |   59|    119|#define SECURED_SPDM_VERSION_12 0x12
  ------------------
   92|      0|        libspdm_secured_message_set_sequence_number_endian(
   93|      0|            session_info->secured_message_context,
   94|      0|            LIBSPDM_DATA_SESSION_SEQ_NUM_ENC_LITTLE_DEC_LITTLE);
  ------------------
  |  |  251|      0|#define LIBSPDM_DATA_SESSION_SEQ_NUM_ENC_LITTLE_DEC_LITTLE 0
  ------------------
   95|    119|    } else {
   96|    119|        libspdm_secured_message_set_sequence_number_endian(session_info->secured_message_context,
   97|    119|                                                           spdm_context->sequence_number_endian);
   98|    119|    }
   99|       |
  100|    119|    libspdm_secured_message_set_max_spdm_session_sequence_number(
  101|    119|        session_info->secured_message_context, spdm_context->max_spdm_session_sequence_number);
  102|    119|    libspdm_secured_message_set_algorithms(
  103|    119|        session_info->secured_message_context,
  104|    119|        spdm_context->connection_info.version,
  105|    119|        spdm_context->connection_info.secured_message_version,
  106|    119|        spdm_context->connection_info.algorithm.base_hash_algo,
  107|    119|        spdm_context->connection_info.algorithm.dhe_named_group,
  108|    119|        spdm_context->connection_info.algorithm.aead_cipher_suite,
  109|    119|        spdm_context->connection_info.algorithm.key_schedule);
  110|    119|    session_info->session_transcript.message_encap_d.max_buffer_size =
  111|    119|        sizeof(session_info->session_transcript.message_encap_d.buffer);
  112|       |#if LIBSPDM_RECORD_TRANSCRIPT_DATA_SUPPORT
  113|       |    session_info->session_transcript.message_k.max_buffer_size =
  114|       |        sizeof(session_info->session_transcript.message_k.buffer);
  115|       |    session_info->session_transcript.message_f.max_buffer_size =
  116|       |        sizeof(session_info->session_transcript.message_f.buffer);
  117|       |    session_info->session_transcript.message_m.max_buffer_size =
  118|       |        sizeof(session_info->session_transcript.message_m.buffer);
  119|       |    session_info->session_transcript.message_e.max_buffer_size =
  120|       |        sizeof(session_info->session_transcript.message_e.buffer);
  121|       |    session_info->session_transcript.message_encap_e.max_buffer_size =
  122|       |        sizeof(session_info->session_transcript.message_encap_e.buffer);
  123|       |#endif
  124|    119|}
libspdm_get_session_info_via_session_id:
  147|     46|{
  148|     46|    libspdm_context_t *context;
  149|     46|    libspdm_session_info_t *session_info;
  150|     46|    size_t index;
  151|       |
  152|     46|    if (session_id == INVALID_SESSION_ID) {
  ------------------
  |  |   28|     46|#define INVALID_SESSION_ID 0
  ------------------
  |  Branch (152:9): [True: 0, False: 46]
  ------------------
  153|      0|        LIBSPDM_DEBUG((LIBSPDM_DEBUG_ERROR,
  154|      0|                       "libspdm_get_session_info_via_session_id - Invalid session_id\n"));
  155|      0|        LIBSPDM_ASSERT(false);
  156|      0|        return NULL;
  157|      0|    }
  158|       |
  159|     46|    context = spdm_context;
  160|       |
  161|     46|    session_info = (libspdm_session_info_t *)context->session_info;
  162|     46|    for (index = 0; index < LIBSPDM_MAX_SESSION_COUNT; index++) {
  ------------------
  |  |  198|     46|#define LIBSPDM_MAX_SESSION_COUNT 4
  ------------------
  |  Branch (162:21): [True: 46, False: 0]
  ------------------
  163|     46|        if (session_info[index].session_id == session_id) {
  ------------------
  |  Branch (163:13): [True: 46, False: 0]
  ------------------
  164|     46|            return &session_info[index];
  165|     46|        }
  166|     46|    }
  167|       |
  168|      0|    LIBSPDM_DEBUG((LIBSPDM_DEBUG_ERROR,
  169|      0|                   "libspdm_get_session_info_via_session_id - not found session_id\n"));
  170|      0|    return NULL;
  171|     46|}

libspdm_get_aead_key_size:
   10|    119|{
   11|    119|    switch (aead_cipher_suite) {
   12|      0|    case SPDM_ALGORITHMS_AEAD_CIPHER_SUITE_AES_128_GCM:
  ------------------
  |  |  417|      0|#define SPDM_ALGORITHMS_AEAD_CIPHER_SUITE_AES_128_GCM 0x00000001
  ------------------
  |  Branch (12:5): [True: 0, False: 119]
  ------------------
   13|      0|#if LIBSPDM_AEAD_AES_128_GCM_SUPPORT
   14|      0|        return 16;
   15|       |#else
   16|       |        return 0;
   17|       |#endif
   18|    119|    case SPDM_ALGORITHMS_AEAD_CIPHER_SUITE_AES_256_GCM:
  ------------------
  |  |  418|    119|#define SPDM_ALGORITHMS_AEAD_CIPHER_SUITE_AES_256_GCM 0x00000002
  ------------------
  |  Branch (18:5): [True: 119, False: 0]
  ------------------
   19|    119|#if LIBSPDM_AEAD_AES_256_GCM_SUPPORT
   20|    119|        return 32;
   21|       |#else
   22|       |        return 0;
   23|       |#endif
   24|      0|    case SPDM_ALGORITHMS_AEAD_CIPHER_SUITE_CHACHA20_POLY1305:
  ------------------
  |  |  419|      0|#define SPDM_ALGORITHMS_AEAD_CIPHER_SUITE_CHACHA20_POLY1305 0x00000004
  ------------------
  |  Branch (24:5): [True: 0, False: 119]
  ------------------
   25|      0|#if LIBSPDM_AEAD_CHACHA20_POLY1305_SUPPORT
   26|      0|        return 32;
   27|       |#else
   28|       |        return 0;
   29|       |#endif
   30|      0|    case SPDM_ALGORITHMS_AEAD_CIPHER_SUITE_AEAD_SM4_GCM:
  ------------------
  |  |  422|      0|#define SPDM_ALGORITHMS_AEAD_CIPHER_SUITE_AEAD_SM4_GCM 0x00000008
  ------------------
  |  Branch (30:5): [True: 0, False: 119]
  ------------------
   31|       |#if LIBSPDM_AEAD_SM4_128_GCM_SUPPORT
   32|       |        return 16;
   33|       |#else
   34|      0|        return 0;
   35|      0|#endif
   36|      0|    default:
  ------------------
  |  Branch (36:5): [True: 0, False: 119]
  ------------------
   37|      0|        return 0;
   38|    119|    }
   39|    119|}
libspdm_get_aead_iv_size:
   42|    119|{
   43|    119|    switch (aead_cipher_suite) {
   44|      0|    case SPDM_ALGORITHMS_AEAD_CIPHER_SUITE_AES_128_GCM:
  ------------------
  |  |  417|      0|#define SPDM_ALGORITHMS_AEAD_CIPHER_SUITE_AES_128_GCM 0x00000001
  ------------------
  |  Branch (44:5): [True: 0, False: 119]
  ------------------
   45|      0|#if LIBSPDM_AEAD_AES_128_GCM_SUPPORT
   46|      0|        return 12;
   47|       |#else
   48|       |        return 0;
   49|       |#endif
   50|    119|    case SPDM_ALGORITHMS_AEAD_CIPHER_SUITE_AES_256_GCM:
  ------------------
  |  |  418|    119|#define SPDM_ALGORITHMS_AEAD_CIPHER_SUITE_AES_256_GCM 0x00000002
  ------------------
  |  Branch (50:5): [True: 119, False: 0]
  ------------------
   51|    119|#if LIBSPDM_AEAD_AES_256_GCM_SUPPORT
   52|    119|        return 12;
   53|       |#else
   54|       |        return 0;
   55|       |#endif
   56|      0|    case SPDM_ALGORITHMS_AEAD_CIPHER_SUITE_CHACHA20_POLY1305:
  ------------------
  |  |  419|      0|#define SPDM_ALGORITHMS_AEAD_CIPHER_SUITE_CHACHA20_POLY1305 0x00000004
  ------------------
  |  Branch (56:5): [True: 0, False: 119]
  ------------------
   57|      0|#if LIBSPDM_AEAD_CHACHA20_POLY1305_SUPPORT
   58|      0|        return 12;
   59|       |#else
   60|       |        return 0;
   61|       |#endif
   62|      0|    case SPDM_ALGORITHMS_AEAD_CIPHER_SUITE_AEAD_SM4_GCM:
  ------------------
  |  |  422|      0|#define SPDM_ALGORITHMS_AEAD_CIPHER_SUITE_AEAD_SM4_GCM 0x00000008
  ------------------
  |  Branch (62:5): [True: 0, False: 119]
  ------------------
   63|       |#if LIBSPDM_AEAD_SM4_128_GCM_SUPPORT
   64|       |        return 12;
   65|       |#else
   66|      0|        return 0;
   67|      0|#endif
   68|      0|    default:
  ------------------
  |  Branch (68:5): [True: 0, False: 119]
  ------------------
   69|      0|        return 0;
   70|    119|    }
   71|    119|}
libspdm_get_aead_tag_size:
   74|    119|{
   75|    119|    switch (aead_cipher_suite) {
   76|      0|    case SPDM_ALGORITHMS_AEAD_CIPHER_SUITE_AES_128_GCM:
  ------------------
  |  |  417|      0|#define SPDM_ALGORITHMS_AEAD_CIPHER_SUITE_AES_128_GCM 0x00000001
  ------------------
  |  Branch (76:5): [True: 0, False: 119]
  ------------------
   77|      0|#if LIBSPDM_AEAD_AES_128_GCM_SUPPORT
   78|      0|        return 16;
   79|       |#else
   80|       |        return 0;
   81|       |#endif
   82|    119|    case SPDM_ALGORITHMS_AEAD_CIPHER_SUITE_AES_256_GCM:
  ------------------
  |  |  418|    119|#define SPDM_ALGORITHMS_AEAD_CIPHER_SUITE_AES_256_GCM 0x00000002
  ------------------
  |  Branch (82:5): [True: 119, False: 0]
  ------------------
   83|    119|#if LIBSPDM_AEAD_AES_256_GCM_SUPPORT
   84|    119|        return 16;
   85|       |#else
   86|       |        return 0;
   87|       |#endif
   88|      0|    case SPDM_ALGORITHMS_AEAD_CIPHER_SUITE_CHACHA20_POLY1305:
  ------------------
  |  |  419|      0|#define SPDM_ALGORITHMS_AEAD_CIPHER_SUITE_CHACHA20_POLY1305 0x00000004
  ------------------
  |  Branch (88:5): [True: 0, False: 119]
  ------------------
   89|      0|#if LIBSPDM_AEAD_CHACHA20_POLY1305_SUPPORT
   90|      0|        return 16;
   91|       |#else
   92|       |        return 0;
   93|       |#endif
   94|      0|    case SPDM_ALGORITHMS_AEAD_CIPHER_SUITE_AEAD_SM4_GCM:
  ------------------
  |  |  422|      0|#define SPDM_ALGORITHMS_AEAD_CIPHER_SUITE_AEAD_SM4_GCM 0x00000008
  ------------------
  |  Branch (94:5): [True: 0, False: 119]
  ------------------
   95|       |#if LIBSPDM_AEAD_SM4_128_GCM_SUPPORT
   96|       |        return 16;
   97|       |#else
   98|      0|        return 0;
   99|      0|#endif
  100|      0|    default:
  ------------------
  |  Branch (100:5): [True: 0, False: 119]
  ------------------
  101|      0|        return 0;
  102|    119|    }
  103|    119|}

libspdm_get_dhe_pub_key_size:
   17|    119|{
   18|    119|    switch (dhe_named_group) {
   19|      0|    case SPDM_ALGORITHMS_DHE_NAMED_GROUP_FFDHE_2048:
  ------------------
  |  |  406|      0|#define SPDM_ALGORITHMS_DHE_NAMED_GROUP_FFDHE_2048 0x00000001
  ------------------
  |  Branch (19:5): [True: 0, False: 119]
  ------------------
   20|      0|#if LIBSPDM_FFDHE_2048_SUPPORT
   21|      0|        return 256;
   22|       |#else
   23|       |        return 0;
   24|       |#endif
   25|      0|    case SPDM_ALGORITHMS_DHE_NAMED_GROUP_FFDHE_3072:
  ------------------
  |  |  407|      0|#define SPDM_ALGORITHMS_DHE_NAMED_GROUP_FFDHE_3072 0x00000002
  ------------------
  |  Branch (25:5): [True: 0, False: 119]
  ------------------
   26|      0|#if LIBSPDM_FFDHE_3072_SUPPORT
   27|      0|        return 384;
   28|       |#else
   29|       |        return 0;
   30|       |#endif
   31|      0|    case SPDM_ALGORITHMS_DHE_NAMED_GROUP_FFDHE_4096:
  ------------------
  |  |  408|      0|#define SPDM_ALGORITHMS_DHE_NAMED_GROUP_FFDHE_4096 0x00000004
  ------------------
  |  Branch (31:5): [True: 0, False: 119]
  ------------------
   32|      0|#if LIBSPDM_FFDHE_4096_SUPPORT
   33|      0|        return 512;
   34|       |#else
   35|       |        return 0;
   36|       |#endif
   37|    119|    case SPDM_ALGORITHMS_DHE_NAMED_GROUP_SECP_256_R1:
  ------------------
  |  |  409|    119|#define SPDM_ALGORITHMS_DHE_NAMED_GROUP_SECP_256_R1 0x00000008
  ------------------
  |  Branch (37:5): [True: 119, False: 0]
  ------------------
   38|    119|#if LIBSPDM_ECDHE_P256_SUPPORT
   39|    119|        return 32 * 2;
   40|       |#else
   41|       |        return 0;
   42|       |#endif
   43|      0|    case SPDM_ALGORITHMS_DHE_NAMED_GROUP_SECP_384_R1:
  ------------------
  |  |  410|      0|#define SPDM_ALGORITHMS_DHE_NAMED_GROUP_SECP_384_R1 0x00000010
  ------------------
  |  Branch (43:5): [True: 0, False: 119]
  ------------------
   44|      0|#if LIBSPDM_ECDHE_P384_SUPPORT
   45|      0|        return 48 * 2;
   46|       |#else
   47|       |        return 0;
   48|       |#endif
   49|      0|    case SPDM_ALGORITHMS_DHE_NAMED_GROUP_SECP_521_R1:
  ------------------
  |  |  411|      0|#define SPDM_ALGORITHMS_DHE_NAMED_GROUP_SECP_521_R1 0x00000020
  ------------------
  |  Branch (49:5): [True: 0, False: 119]
  ------------------
   50|      0|#if LIBSPDM_ECDHE_P521_SUPPORT
   51|      0|        return 66 * 2;
   52|       |#else
   53|       |        return 0;
   54|       |#endif
   55|      0|    case SPDM_ALGORITHMS_DHE_NAMED_GROUP_SM2_P256:
  ------------------
  |  |  414|      0|#define SPDM_ALGORITHMS_DHE_NAMED_GROUP_SM2_P256 0x00000040
  ------------------
  |  Branch (55:5): [True: 0, False: 119]
  ------------------
   56|       |#if LIBSPDM_SM2_KEY_EXCHANGE_P256_SUPPORT
   57|       |        return 32 * 2;
   58|       |#else
   59|      0|        return 0;
   60|      0|#endif
   61|      0|    default:
  ------------------
  |  Branch (61:5): [True: 0, False: 119]
  ------------------
   62|      0|        return 0;
   63|    119|    }
   64|    119|}

libspdm_get_hash_size:
   10|    119|{
   11|    119|    switch (base_hash_algo) {
   12|    119|    case SPDM_ALGORITHMS_BASE_HASH_ALGO_TPM_ALG_SHA_256:
  ------------------
  |  |  391|    119|#define SPDM_ALGORITHMS_BASE_HASH_ALGO_TPM_ALG_SHA_256 0x00000001
  ------------------
  |  Branch (12:5): [True: 119, False: 0]
  ------------------
   13|    119|#if LIBSPDM_SHA256_SUPPORT
   14|    119|        return 32;
   15|       |#else
   16|       |        return 0;
   17|       |#endif
   18|      0|    case SPDM_ALGORITHMS_BASE_HASH_ALGO_TPM_ALG_SHA3_256:
  ------------------
  |  |  394|      0|#define SPDM_ALGORITHMS_BASE_HASH_ALGO_TPM_ALG_SHA3_256 0x00000008
  ------------------
  |  Branch (18:5): [True: 0, False: 119]
  ------------------
   19|      0|#if LIBSPDM_SHA3_256_SUPPORT
   20|      0|        return 32;
   21|       |#else
   22|       |        return 0;
   23|       |#endif
   24|      0|    case SPDM_ALGORITHMS_BASE_HASH_ALGO_TPM_ALG_SHA_384:
  ------------------
  |  |  392|      0|#define SPDM_ALGORITHMS_BASE_HASH_ALGO_TPM_ALG_SHA_384 0x00000002
  ------------------
  |  Branch (24:5): [True: 0, False: 119]
  ------------------
   25|      0|#if LIBSPDM_SHA384_SUPPORT
   26|      0|        return 48;
   27|       |#else
   28|       |        return 0;
   29|       |#endif
   30|      0|    case SPDM_ALGORITHMS_BASE_HASH_ALGO_TPM_ALG_SHA3_384:
  ------------------
  |  |  395|      0|#define SPDM_ALGORITHMS_BASE_HASH_ALGO_TPM_ALG_SHA3_384 0x00000010
  ------------------
  |  Branch (30:5): [True: 0, False: 119]
  ------------------
   31|      0|#if LIBSPDM_SHA3_384_SUPPORT
   32|      0|        return 48;
   33|       |#else
   34|       |        return 0;
   35|       |#endif
   36|      0|    case SPDM_ALGORITHMS_BASE_HASH_ALGO_TPM_ALG_SHA_512:
  ------------------
  |  |  393|      0|#define SPDM_ALGORITHMS_BASE_HASH_ALGO_TPM_ALG_SHA_512 0x00000004
  ------------------
  |  Branch (36:5): [True: 0, False: 119]
  ------------------
   37|      0|#if LIBSPDM_SHA512_SUPPORT
   38|      0|        return 64;
   39|       |#else
   40|       |        return 0;
   41|       |#endif
   42|      0|    case SPDM_ALGORITHMS_BASE_HASH_ALGO_TPM_ALG_SHA3_512:
  ------------------
  |  |  396|      0|#define SPDM_ALGORITHMS_BASE_HASH_ALGO_TPM_ALG_SHA3_512 0x00000020
  ------------------
  |  Branch (42:5): [True: 0, False: 119]
  ------------------
   43|      0|#if LIBSPDM_SHA3_512_SUPPORT
   44|      0|        return 64;
   45|       |#else
   46|       |        return 0;
   47|       |#endif
   48|      0|    case SPDM_ALGORITHMS_BASE_HASH_ALGO_TPM_ALG_SM3_256:
  ------------------
  |  |  401|      0|#define SPDM_ALGORITHMS_BASE_HASH_ALGO_TPM_ALG_SM3_256 0x00000040
  ------------------
  |  Branch (48:5): [True: 0, False: 119]
  ------------------
   49|       |#if LIBSPDM_SM3_256_SUPPORT
   50|       |        return 32;
   51|       |#else
   52|      0|        return 0;
   53|      0|#endif
   54|      0|    default:
  ------------------
  |  Branch (54:5): [True: 0, False: 119]
  ------------------
   55|      0|        return 0;
   56|    119|    }
   57|    119|}

libspdm_hkdf_expand:
   72|    221|{
   73|    221|    switch (base_hash_algo) {
   74|    221|    case SPDM_ALGORITHMS_BASE_HASH_ALGO_TPM_ALG_SHA_256:
  ------------------
  |  |  391|    221|#define SPDM_ALGORITHMS_BASE_HASH_ALGO_TPM_ALG_SHA_256 0x00000001
  ------------------
  |  Branch (74:5): [True: 221, False: 0]
  ------------------
   75|    221|#if LIBSPDM_SHA256_SUPPORT
   76|    221|        return libspdm_hkdf_sha256_expand(prk, prk_size, info, info_size, out, out_size);
   77|       |#else
   78|       |        LIBSPDM_ASSERT(false);
   79|       |        return false;
   80|       |#endif
   81|      0|    case SPDM_ALGORITHMS_BASE_HASH_ALGO_TPM_ALG_SHA_384:
  ------------------
  |  |  392|      0|#define SPDM_ALGORITHMS_BASE_HASH_ALGO_TPM_ALG_SHA_384 0x00000002
  ------------------
  |  Branch (81:5): [True: 0, False: 221]
  ------------------
   82|      0|#if LIBSPDM_SHA384_SUPPORT
   83|      0|        return libspdm_hkdf_sha384_expand(prk, prk_size, info, info_size, out, out_size);
   84|       |#else
   85|       |        LIBSPDM_ASSERT(false);
   86|       |        return false;
   87|       |#endif
   88|      0|    case SPDM_ALGORITHMS_BASE_HASH_ALGO_TPM_ALG_SHA_512:
  ------------------
  |  |  393|      0|#define SPDM_ALGORITHMS_BASE_HASH_ALGO_TPM_ALG_SHA_512 0x00000004
  ------------------
  |  Branch (88:5): [True: 0, False: 221]
  ------------------
   89|      0|#if LIBSPDM_SHA512_SUPPORT
   90|      0|        return libspdm_hkdf_sha512_expand(prk, prk_size, info, info_size, out, out_size);
   91|       |#else
   92|       |        LIBSPDM_ASSERT(false);
   93|       |        return false;
   94|       |#endif
   95|      0|    case SPDM_ALGORITHMS_BASE_HASH_ALGO_TPM_ALG_SHA3_256:
  ------------------
  |  |  394|      0|#define SPDM_ALGORITHMS_BASE_HASH_ALGO_TPM_ALG_SHA3_256 0x00000008
  ------------------
  |  Branch (95:5): [True: 0, False: 221]
  ------------------
   96|      0|#if LIBSPDM_SHA3_256_SUPPORT
   97|      0|        return libspdm_hkdf_sha3_256_expand(prk, prk_size, info, info_size, out, out_size);
   98|       |#else
   99|       |        LIBSPDM_ASSERT(false);
  100|       |        return false;
  101|       |#endif
  102|      0|    case SPDM_ALGORITHMS_BASE_HASH_ALGO_TPM_ALG_SHA3_384:
  ------------------
  |  |  395|      0|#define SPDM_ALGORITHMS_BASE_HASH_ALGO_TPM_ALG_SHA3_384 0x00000010
  ------------------
  |  Branch (102:5): [True: 0, False: 221]
  ------------------
  103|      0|#if LIBSPDM_SHA3_384_SUPPORT
  104|      0|        return libspdm_hkdf_sha3_384_expand(prk, prk_size, info, info_size, out, out_size);
  105|       |#else
  106|       |        LIBSPDM_ASSERT(false);
  107|       |        return false;
  108|       |#endif
  109|      0|    case SPDM_ALGORITHMS_BASE_HASH_ALGO_TPM_ALG_SHA3_512:
  ------------------
  |  |  396|      0|#define SPDM_ALGORITHMS_BASE_HASH_ALGO_TPM_ALG_SHA3_512 0x00000020
  ------------------
  |  Branch (109:5): [True: 0, False: 221]
  ------------------
  110|      0|#if LIBSPDM_SHA3_512_SUPPORT
  111|      0|        return libspdm_hkdf_sha3_512_expand(prk, prk_size, info, info_size, out, out_size);
  112|       |#else
  113|       |        LIBSPDM_ASSERT(false);
  114|       |        return false;
  115|       |#endif
  116|      0|    case SPDM_ALGORITHMS_BASE_HASH_ALGO_TPM_ALG_SM3_256:
  ------------------
  |  |  401|      0|#define SPDM_ALGORITHMS_BASE_HASH_ALGO_TPM_ALG_SM3_256 0x00000040
  ------------------
  |  Branch (116:5): [True: 0, False: 221]
  ------------------
  117|       |#if LIBSPDM_SM3_256_SUPPORT
  118|       |        return libspdm_hkdf_sm3_256_expand(prk, prk_size, info, info_size, out, out_size);
  119|       |#else
  120|      0|        LIBSPDM_ASSERT(false);
  121|      0|        return false;
  122|      0|#endif
  123|      0|    default:
  ------------------
  |  Branch (123:5): [True: 0, False: 221]
  ------------------
  124|      0|        LIBSPDM_ASSERT(false);
  125|      0|        return false;
  126|    221|    }
  127|    221|}

libspdm_generate_encap_error_response:
   16|     85|{
   17|     85|    spdm_error_response_t *spdm_response;
   18|       |
   19|     85|    LIBSPDM_ASSERT(*response_size >= sizeof(spdm_error_response_t));
   20|     85|    *response_size = sizeof(spdm_error_response_t);
   21|     85|    spdm_response = response;
   22|       |
   23|     85|    spdm_response->header.spdm_version = libspdm_get_connection_version (spdm_context);
   24|     85|    spdm_response->header.request_response_code = SPDM_ERROR;
  ------------------
  |  |   37|     85|#define SPDM_ERROR 0x7F
  ------------------
   25|     85|    spdm_response->header.param1 = error_code;
   26|     85|    spdm_response->header.param2 = error_data;
   27|       |
   28|     85|    return LIBSPDM_STATUS_SUCCESS;
  ------------------
  |  |   59|     85|    LIBSPDM_STATUS_CONSTRUCT(LIBSPDM_SEVERITY_SUCCESS, LIBSPDM_SOURCE_SUCCESS, 0x0000)
  |  |  ------------------
  |  |  |  |   55|     85|    ((libspdm_return_t)(((severity) << 28) | ((source) << 16) | (code)))
  |  |  ------------------
  ------------------
   29|     85|}

libspdm_get_encap_response_key_update:
   17|    119|{
   18|    119|    uint32_t session_id;
   19|    119|    spdm_key_update_response_t *spdm_response;
   20|    119|    spdm_key_update_request_t *spdm_request;
   21|    119|    libspdm_context_t *context;
   22|    119|    libspdm_session_info_t *session_info;
   23|    119|    libspdm_session_state_t session_state;
   24|    119|    spdm_key_update_request_t *prev_spdm_request;
   25|    119|    spdm_key_update_request_t spdm_key_init_update_operation;
   26|    119|    bool result;
   27|       |
   28|    119|    context = spdm_context;
   29|    119|    spdm_request = request;
   30|       |
   31|    119|    if (libspdm_get_connection_version(context) < SPDM_MESSAGE_VERSION_11) {
  ------------------
  |  |  111|    119|#define SPDM_MESSAGE_VERSION_11 0x11
  ------------------
  |  Branch (31:9): [True: 0, False: 119]
  ------------------
   32|      0|        return libspdm_generate_encap_error_response(
   33|      0|            context, SPDM_ERROR_CODE_UNSUPPORTED_REQUEST,
  ------------------
  |  |  859|      0|#define SPDM_ERROR_CODE_UNSUPPORTED_REQUEST 0x07
  ------------------
   34|      0|            SPDM_KEY_UPDATE, response_size, response);
  ------------------
  |  |   82|      0|#define SPDM_KEY_UPDATE 0xE9
  ------------------
   35|      0|    }
   36|       |
   37|    119|    if (spdm_request->header.spdm_version != libspdm_get_connection_version(context)) {
  ------------------
  |  Branch (37:9): [True: 73, False: 46]
  ------------------
   38|     73|        return libspdm_generate_encap_error_response(
   39|     73|            context, SPDM_ERROR_CODE_VERSION_MISMATCH,
  ------------------
  |  |  860|     73|#define SPDM_ERROR_CODE_VERSION_MISMATCH 0x41
  ------------------
   40|     73|            0, response_size, response);
   41|     73|    }
   42|       |
   43|     46|    if (!libspdm_is_capabilities_flag_supported(
  ------------------
  |  Branch (43:9): [True: 0, False: 46]
  ------------------
   44|     46|            context, true,
   45|     46|            SPDM_GET_CAPABILITIES_REQUEST_FLAGS_KEY_UPD_CAP,
  ------------------
  |  |  195|     46|#define SPDM_GET_CAPABILITIES_REQUEST_FLAGS_KEY_UPD_CAP 0x00004000
  ------------------
   46|     46|            SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_KEY_UPD_CAP)) {
  ------------------
  |  |  257|     46|#define SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_KEY_UPD_CAP 0x00004000
  ------------------
   47|      0|        return libspdm_generate_encap_error_response(
   48|      0|            context, SPDM_ERROR_CODE_UNSUPPORTED_REQUEST,
  ------------------
  |  |  859|      0|#define SPDM_ERROR_CODE_UNSUPPORTED_REQUEST 0x07
  ------------------
   49|      0|            SPDM_KEY_UPDATE, response_size, response);
  ------------------
  |  |   82|      0|#define SPDM_KEY_UPDATE 0xE9
  ------------------
   50|      0|    }
   51|       |
   52|     46|    if (!context->last_spdm_request_session_id_valid) {
  ------------------
  |  Branch (52:9): [True: 0, False: 46]
  ------------------
   53|      0|        if (libspdm_get_connection_version(context) >= SPDM_MESSAGE_VERSION_12) {
  ------------------
  |  |  112|      0|#define SPDM_MESSAGE_VERSION_12 0x12
  ------------------
  |  Branch (53:13): [True: 0, False: 0]
  ------------------
   54|      0|            return libspdm_generate_encap_error_response(context,
   55|      0|                                                         SPDM_ERROR_CODE_SESSION_REQUIRED, 0,
  ------------------
  |  |  872|      0|#define SPDM_ERROR_CODE_SESSION_REQUIRED 0x0B
  ------------------
   56|      0|                                                         response_size, response);
   57|      0|        } else {
   58|      0|            return libspdm_generate_encap_error_response(context,
   59|      0|                                                         SPDM_ERROR_CODE_UNSPECIFIED, 0,
  ------------------
  |  |  858|      0|#define SPDM_ERROR_CODE_UNSPECIFIED 0x05
  ------------------
   60|      0|                                                         response_size, response);
   61|      0|        }
   62|      0|    }
   63|     46|    session_id = context->last_spdm_request_session_id;
   64|     46|    session_info =
   65|     46|        libspdm_get_session_info_via_session_id(context, session_id);
   66|     46|    if (session_info == NULL) {
  ------------------
  |  Branch (66:9): [True: 0, False: 46]
  ------------------
   67|      0|        return libspdm_generate_encap_error_response(
   68|      0|            context, SPDM_ERROR_CODE_INVALID_REQUEST, 0,
  ------------------
  |  |  855|      0|#define SPDM_ERROR_CODE_INVALID_REQUEST 0x01
  ------------------
   69|      0|            response_size, response);
   70|      0|    }
   71|     46|    session_state = libspdm_secured_message_get_session_state(
   72|     46|        session_info->secured_message_context);
   73|     46|    if (session_state != LIBSPDM_SESSION_STATE_ESTABLISHED) {
  ------------------
  |  Branch (73:9): [True: 0, False: 46]
  ------------------
   74|      0|        return libspdm_generate_encap_error_response(
   75|      0|            context, SPDM_ERROR_CODE_INVALID_REQUEST, 0,
  ------------------
  |  |  855|      0|#define SPDM_ERROR_CODE_INVALID_REQUEST 0x01
  ------------------
   76|      0|            response_size, response);
   77|      0|    }
   78|       |
   79|       |    /* this message can only be in secured session
   80|       |     * thus don't need to consider transport layer padding, just check its exact size */
   81|     46|    if (request_size != sizeof(spdm_key_update_request_t)) {
  ------------------
  |  Branch (81:9): [True: 0, False: 46]
  ------------------
   82|      0|        return libspdm_generate_encap_error_response(
   83|      0|            context, SPDM_ERROR_CODE_INVALID_REQUEST, 0,
  ------------------
  |  |  855|      0|#define SPDM_ERROR_CODE_INVALID_REQUEST 0x01
  ------------------
   84|      0|            response_size, response);
   85|      0|    }
   86|       |
   87|       |    /*last key operation*/
   88|     46|    prev_spdm_request = &(session_info->last_key_update_request);
   89|       |
   90|       |    /*the end status of the successful key update overall flow*/
   91|     46|    libspdm_zero_mem(&spdm_key_init_update_operation, sizeof(spdm_key_update_request_t));
   92|       |
   93|     46|    result = true;
   94|     46|    switch (spdm_request->header.param1) {
   95|     34|    case SPDM_KEY_UPDATE_OPERATIONS_TABLE_UPDATE_KEY:
  ------------------
  |  | 1108|     34|#define SPDM_KEY_UPDATE_OPERATIONS_TABLE_UPDATE_KEY 1
  ------------------
  |  Branch (95:5): [True: 34, False: 12]
  ------------------
   96|     34|        if(!libspdm_consttime_is_mem_equal(prev_spdm_request,
  ------------------
  |  Branch (96:12): [True: 0, False: 34]
  ------------------
   97|     34|                                           &spdm_key_init_update_operation,
   98|     34|                                           sizeof(spdm_key_update_request_t))) {
   99|      0|            result = false;
  100|      0|            break;
  101|      0|        }
  102|     34|        LIBSPDM_DEBUG((LIBSPDM_DEBUG_INFO,
  103|     34|                       "libspdm_create_update_session_data_key[%x] Responder\n",
  104|     34|                       session_id));
  105|     34|        result = libspdm_create_update_session_data_key(
  106|     34|            session_info->secured_message_context,
  107|     34|            LIBSPDM_KEY_UPDATE_ACTION_RESPONDER);
  108|       |
  109|       |        /*save the last update operation*/
  110|     34|        libspdm_copy_mem(prev_spdm_request, sizeof(spdm_key_update_request_t),
  111|     34|                         spdm_request, request_size);
  112|     34|        break;
  113|      1|    case SPDM_KEY_UPDATE_OPERATIONS_TABLE_UPDATE_ALL_KEYS:
  ------------------
  |  | 1109|      1|#define SPDM_KEY_UPDATE_OPERATIONS_TABLE_UPDATE_ALL_KEYS 2
  ------------------
  |  Branch (113:5): [True: 1, False: 45]
  ------------------
  114|      1|        result = false;
  115|      1|        break;
  116|      1|    case SPDM_KEY_UPDATE_OPERATIONS_TABLE_VERIFY_NEW_KEY:
  ------------------
  |  | 1110|      1|#define SPDM_KEY_UPDATE_OPERATIONS_TABLE_VERIFY_NEW_KEY 3
  ------------------
  |  Branch (116:5): [True: 1, False: 45]
  ------------------
  117|      1|        if(prev_spdm_request->header.param1 !=
  ------------------
  |  Branch (117:12): [True: 1, False: 0]
  ------------------
  118|      1|           SPDM_KEY_UPDATE_OPERATIONS_TABLE_UPDATE_KEY) {
  ------------------
  |  | 1108|      1|#define SPDM_KEY_UPDATE_OPERATIONS_TABLE_UPDATE_KEY 1
  ------------------
  119|      1|            result = false;
  120|      1|            break;
  121|      1|        }
  122|      0|        LIBSPDM_DEBUG((LIBSPDM_DEBUG_INFO,
  123|      0|                       "libspdm_activate_update_session_data_key[%x] Responder new\n",
  124|      0|                       session_id));
  125|      0|        result = libspdm_activate_update_session_data_key(
  126|      0|            session_info->secured_message_context,
  127|      0|            LIBSPDM_KEY_UPDATE_ACTION_RESPONDER, true);
  128|       |
  129|       |        /*clear last_key_update_request*/
  130|      0|        libspdm_zero_mem(prev_spdm_request, sizeof(spdm_key_update_request_t));
  131|      0|        break;
  132|     10|    default:
  ------------------
  |  Branch (132:5): [True: 10, False: 36]
  ------------------
  133|     10|        result = false;
  134|     10|        break;
  135|     46|    }
  136|       |
  137|     46|    if (!result) {
  ------------------
  |  Branch (137:9): [True: 12, False: 34]
  ------------------
  138|     12|        return libspdm_generate_encap_error_response(
  139|     12|            context, SPDM_ERROR_CODE_INVALID_REQUEST, 0,
  ------------------
  |  |  855|     12|#define SPDM_ERROR_CODE_INVALID_REQUEST 0x01
  ------------------
  140|     12|            response_size, response);
  141|     12|    }
  142|       |
  143|     34|    libspdm_reset_message_buffer_via_request_code(context, session_info,
  144|     34|                                                  spdm_request->header.request_response_code);
  145|       |
  146|     34|    LIBSPDM_ASSERT(*response_size >= sizeof(spdm_key_update_response_t));
  147|     34|    *response_size = sizeof(spdm_key_update_response_t);
  148|     34|    libspdm_zero_mem(response, *response_size);
  149|     34|    spdm_response = response;
  150|       |
  151|     34|    spdm_response->header.spdm_version = spdm_request->header.spdm_version;
  152|     34|    spdm_response->header.request_response_code = SPDM_KEY_UPDATE_ACK;
  ------------------
  |  |   45|     34|#define SPDM_KEY_UPDATE_ACK 0x69
  ------------------
  153|     34|    spdm_response->header.param1 = spdm_request->header.param1;
  154|     34|    spdm_response->header.param2 = spdm_request->header.param2;
  155|       |
  156|     34|    return LIBSPDM_STATUS_SUCCESS;
  ------------------
  |  |   59|     34|    LIBSPDM_STATUS_CONSTRUCT(LIBSPDM_SEVERITY_SUCCESS, LIBSPDM_SOURCE_SUCCESS, 0x0000)
  |  |  ------------------
  |  |  |  |   55|     34|    ((libspdm_return_t)(((severity) << 28) | ((source) << 16) | (code)))
  |  |  ------------------
  ------------------
  157|     46|}

libspdm_secured_message_get_context_size:
   15|    238|{
   16|    238|    return sizeof(libspdm_secured_message_context_t);
   17|    238|}
libspdm_secured_message_init_context:
   27|    595|{
   28|    595|    libspdm_secured_message_context_t *secured_message_context;
   29|       |
   30|    595|    secured_message_context = spdm_secured_message_context;
   31|    595|    libspdm_zero_mem(secured_message_context, sizeof(libspdm_secured_message_context_t));
   32|    595|}
libspdm_secured_message_set_use_psk:
   41|    119|{
   42|    119|    libspdm_secured_message_context_t *secured_message_context;
   43|       |
   44|    119|    secured_message_context = spdm_secured_message_context;
   45|    119|    secured_message_context->use_psk = use_psk;
   46|    119|}
libspdm_secured_message_set_session_state:
   57|    119|{
   58|    119|    libspdm_secured_message_context_t *secured_message_context;
   59|       |
   60|    119|    secured_message_context = spdm_secured_message_context;
   61|    119|    secured_message_context->session_state = session_state;
   62|       |
   63|    119|    if (session_state == LIBSPDM_SESSION_STATE_ESTABLISHED) {
  ------------------
  |  Branch (63:9): [True: 119, False: 0]
  ------------------
   64|       |        /* session handshake key should be zeroized after handshake phase. */
   65|    119|        libspdm_clear_handshake_secret(secured_message_context);
   66|    119|        libspdm_clear_master_secret(secured_message_context);
   67|    119|    }
   68|    119|}
libspdm_secured_message_get_session_state:
   79|     46|{
   80|     46|    libspdm_secured_message_context_t *secured_message_context;
   81|       |
   82|     46|    secured_message_context = spdm_secured_message_context;
   83|     46|    return secured_message_context->session_state;
   84|     46|}
libspdm_secured_message_set_session_type:
   94|    119|{
   95|    119|    libspdm_secured_message_context_t *secured_message_context;
   96|       |
   97|    119|    secured_message_context = spdm_secured_message_context;
   98|    119|    secured_message_context->session_type = session_type;
   99|    119|}
libspdm_secured_message_set_algorithms:
  117|    119|{
  118|    119|    libspdm_secured_message_context_t *secured_message_context;
  119|       |
  120|    119|    secured_message_context = spdm_secured_message_context;
  121|    119|    secured_message_context->version = version;
  122|    119|    secured_message_context->secured_message_version = secured_message_version;
  123|    119|    secured_message_context->base_hash_algo = base_hash_algo;
  124|    119|    secured_message_context->dhe_named_group = dhe_named_group;
  125|    119|    secured_message_context->aead_cipher_suite = aead_cipher_suite;
  126|    119|    secured_message_context->key_schedule = key_schedule;
  127|       |
  128|    119|    secured_message_context->hash_size =
  129|    119|        libspdm_get_hash_size(secured_message_context->base_hash_algo);
  130|    119|    secured_message_context->dhe_key_size = libspdm_get_dhe_pub_key_size(
  131|    119|        secured_message_context->dhe_named_group);
  132|    119|    secured_message_context->aead_key_size = libspdm_get_aead_key_size(
  133|    119|        secured_message_context->aead_cipher_suite);
  134|    119|    secured_message_context->aead_iv_size = libspdm_get_aead_iv_size(
  135|    119|        secured_message_context->aead_cipher_suite);
  136|    119|    secured_message_context->aead_tag_size = libspdm_get_aead_tag_size(
  137|    119|        secured_message_context->aead_cipher_suite);
  138|    119|}
libspdm_secured_message_set_max_spdm_session_sequence_number:
  167|    119|{
  168|    119|    libspdm_secured_message_context_t *secured_message_context;
  169|       |
  170|    119|    secured_message_context = spdm_secured_message_context;
  171|    119|    secured_message_context->max_spdm_session_sequence_number = max_spdm_session_sequence_number;
  172|    119|}
libspdm_secured_message_set_sequence_number_endian:
  177|    119|{
  178|    119|    libspdm_secured_message_context_t *secured_message_context;
  179|       |
  180|    119|    secured_message_context = spdm_secured_message_context;
  181|    119|    secured_message_context->sequence_number_endian = endian_value;
  182|    119|}

libspdm_bin_concat:
   25|    221|{
   26|    221|    size_t final_size;
   27|       |
   28|       |    /* The correct version characters (1.1 or 1.2) will replace the x.x. */
   29|    221|    #define LIBSPDM_BIN_CONCAT_LABEL "spdmx.x "
   30|       |
   31|    221|    final_size = sizeof(uint16_t) + sizeof(LIBSPDM_BIN_CONCAT_LABEL) - 1 + label_size;
  ------------------
  |  |   29|    221|    #define LIBSPDM_BIN_CONCAT_LABEL "spdmx.x "
  ------------------
   32|    221|    if (context != NULL) {
  ------------------
  |  Branch (32:9): [True: 0, False: 221]
  ------------------
   33|      0|        final_size += hash_size;
   34|      0|    }
   35|       |
   36|    221|    LIBSPDM_ASSERT(*out_bin_size >= final_size);
   37|       |
   38|    221|    *out_bin_size = final_size;
   39|       |
   40|    221|    libspdm_copy_mem(out_bin, *out_bin_size, &length, sizeof(uint16_t));
   41|    221|    libspdm_copy_mem(out_bin + sizeof(uint16_t), *out_bin_size - sizeof(uint16_t),
   42|    221|                     LIBSPDM_BIN_CONCAT_LABEL, sizeof(LIBSPDM_BIN_CONCAT_LABEL) - 1);
  ------------------
  |  |   29|    221|    #define LIBSPDM_BIN_CONCAT_LABEL "spdmx.x "
  ------------------
                                   LIBSPDM_BIN_CONCAT_LABEL, sizeof(LIBSPDM_BIN_CONCAT_LABEL) - 1);
  ------------------
  |  |   29|    221|    #define LIBSPDM_BIN_CONCAT_LABEL "spdmx.x "
  ------------------
   43|       |
   44|       |    /* Patch the version. */
   45|    221|    out_bin[6] = (char)('0' + ((spdm_version >> 12) & 0xF));
   46|    221|    out_bin[8] = (char)('0' + ((spdm_version >> 8) & 0xF));
   47|    221|    libspdm_copy_mem(out_bin + sizeof(uint16_t) + sizeof(LIBSPDM_BIN_CONCAT_LABEL) - 1,
  ------------------
  |  |   29|    221|    #define LIBSPDM_BIN_CONCAT_LABEL "spdmx.x "
  ------------------
   48|    221|                     *out_bin_size - (sizeof(uint16_t) + sizeof(LIBSPDM_BIN_CONCAT_LABEL) - 1),
  ------------------
  |  |   29|    221|    #define LIBSPDM_BIN_CONCAT_LABEL "spdmx.x "
  ------------------
   49|    221|                     label, label_size);
   50|       |
   51|    221|    if (context != NULL) {
  ------------------
  |  Branch (51:9): [True: 0, False: 221]
  ------------------
   52|      0|        libspdm_copy_mem(out_bin + sizeof(uint16_t) + sizeof(LIBSPDM_BIN_CONCAT_LABEL) -
  ------------------
  |  |   29|      0|    #define LIBSPDM_BIN_CONCAT_LABEL "spdmx.x "
  ------------------
   53|      0|                         1 + label_size,
   54|      0|                         *out_bin_size - (sizeof(uint16_t) + sizeof(LIBSPDM_BIN_CONCAT_LABEL) -
  ------------------
  |  |   29|      0|    #define LIBSPDM_BIN_CONCAT_LABEL "spdmx.x "
  ------------------
   55|      0|                                          1 + label_size), context, hash_size);
   56|      0|    }
   57|       |
   58|    221|    #undef LIBSPDM_BIN_CONCAT_LABEL
   59|    221|}
libspdm_generate_aead_key_and_iv:
   74|     34|{
   75|     34|    bool status;
   76|     34|    size_t hash_size;
   77|     34|    size_t key_length;
   78|     34|    size_t iv_length;
   79|     34|    uint8_t bin_str5[128];
   80|     34|    size_t bin_str5_size;
   81|     34|    uint8_t bin_str6[128];
   82|     34|    size_t bin_str6_size;
   83|       |
   84|     34|    hash_size = secured_message_context->hash_size;
   85|     34|    key_length = secured_message_context->aead_key_size;
   86|     34|    iv_length = secured_message_context->aead_iv_size;
   87|       |
   88|     34|    bin_str5_size = sizeof(bin_str5);
   89|     34|    libspdm_bin_concat(secured_message_context->version,
   90|     34|                       SPDM_BIN_STR_5_LABEL, sizeof(SPDM_BIN_STR_5_LABEL) - 1,
  ------------------
  |  | 1504|     34|#define SPDM_BIN_STR_5_LABEL "key"
  ------------------
                                     SPDM_BIN_STR_5_LABEL, sizeof(SPDM_BIN_STR_5_LABEL) - 1,
  ------------------
  |  | 1504|     34|#define SPDM_BIN_STR_5_LABEL "key"
  ------------------
   91|     34|                       NULL, (uint16_t)key_length, hash_size, bin_str5,
   92|     34|                       &bin_str5_size);
   93|       |
   94|     34|    LIBSPDM_DEBUG((LIBSPDM_DEBUG_INFO, "bin_str5 (0x%zx):\n", bin_str5_size));
   95|     34|    LIBSPDM_INTERNAL_DUMP_HEX(bin_str5, bin_str5_size);
   96|     34|    status = libspdm_hkdf_expand(secured_message_context->base_hash_algo,
   97|     34|                                 major_secret, hash_size, bin_str5,
   98|     34|                                 bin_str5_size, key, key_length);
   99|     34|    if (!status) {
  ------------------
  |  Branch (99:9): [True: 0, False: 34]
  ------------------
  100|      0|        return false;
  101|      0|    }
  102|     34|    LIBSPDM_DEBUG((LIBSPDM_DEBUG_INFO, "key (0x%zx) - ", key_length));
  103|     34|    LIBSPDM_INTERNAL_DUMP_DATA(key, key_length);
  104|     34|    LIBSPDM_DEBUG((LIBSPDM_DEBUG_INFO, "\n"));
  105|       |
  106|     34|    bin_str6_size = sizeof(bin_str6);
  107|     34|    libspdm_bin_concat(secured_message_context->version,
  108|     34|                       SPDM_BIN_STR_6_LABEL, sizeof(SPDM_BIN_STR_6_LABEL) - 1,
  ------------------
  |  | 1505|     34|#define SPDM_BIN_STR_6_LABEL "iv"
  ------------------
                                     SPDM_BIN_STR_6_LABEL, sizeof(SPDM_BIN_STR_6_LABEL) - 1,
  ------------------
  |  | 1505|     34|#define SPDM_BIN_STR_6_LABEL "iv"
  ------------------
  109|     34|                       NULL, (uint16_t)iv_length, hash_size, bin_str6,
  110|     34|                       &bin_str6_size);
  111|       |
  112|     34|    LIBSPDM_DEBUG((LIBSPDM_DEBUG_INFO, "bin_str6 (0x%zx):\n", bin_str6_size));
  113|     34|    LIBSPDM_INTERNAL_DUMP_HEX(bin_str6, bin_str6_size);
  114|     34|    status = libspdm_hkdf_expand(secured_message_context->base_hash_algo,
  115|     34|                                 major_secret, hash_size, bin_str6,
  116|     34|                                 bin_str6_size, iv, iv_length);
  117|     34|    if (!status) {
  ------------------
  |  Branch (117:9): [True: 0, False: 34]
  ------------------
  118|      0|        return false;
  119|      0|    }
  120|     34|    LIBSPDM_DEBUG((LIBSPDM_DEBUG_INFO, "iv (0x%zx) - ", iv_length));
  121|     34|    LIBSPDM_INTERNAL_DUMP_DATA(iv, iv_length);
  122|     34|    LIBSPDM_DEBUG((LIBSPDM_DEBUG_INFO, "\n"));
  123|       |
  124|     34|    return true;
  125|     34|}
libspdm_create_update_session_data_key:
  577|     34|{
  578|     34|    bool status;
  579|     34|    size_t hash_size;
  580|     34|    uint8_t bin_str9[128];
  581|     34|    size_t bin_str9_size;
  582|     34|    libspdm_secured_message_context_t *secured_message_context;
  583|       |
  584|     34|    secured_message_context = spdm_secured_message_context;
  585|       |
  586|     34|    hash_size = secured_message_context->hash_size;
  587|       |
  588|     34|    bin_str9_size = sizeof(bin_str9);
  589|     34|    libspdm_bin_concat(secured_message_context->version,
  590|     34|                       SPDM_BIN_STR_9_LABEL, sizeof(SPDM_BIN_STR_9_LABEL) - 1,
  ------------------
  |  | 1508|     34|#define SPDM_BIN_STR_9_LABEL "traffic upd"
  ------------------
                                     SPDM_BIN_STR_9_LABEL, sizeof(SPDM_BIN_STR_9_LABEL) - 1,
  ------------------
  |  | 1508|     34|#define SPDM_BIN_STR_9_LABEL "traffic upd"
  ------------------
  591|     34|                       NULL, (uint16_t)hash_size, hash_size, bin_str9,
  592|     34|                       &bin_str9_size);
  593|       |
  594|     34|    LIBSPDM_DEBUG((LIBSPDM_DEBUG_INFO, "bin_str9 (0x%zx):\n", bin_str9_size));
  595|     34|    LIBSPDM_INTERNAL_DUMP_HEX(bin_str9, bin_str9_size);
  596|       |
  597|     34|    if (action == LIBSPDM_KEY_UPDATE_ACTION_REQUESTER) {
  ------------------
  |  Branch (597:9): [True: 0, False: 34]
  ------------------
  598|      0|        libspdm_copy_mem(&secured_message_context->application_secret_backup
  599|      0|                         .request_data_secret,
  600|      0|                         sizeof(secured_message_context->application_secret_backup
  601|      0|                                .request_data_secret),
  602|      0|                         &secured_message_context->application_secret
  603|      0|                         .request_data_secret,
  604|      0|                         LIBSPDM_MAX_HASH_SIZE);
  ------------------
  |  |   65|      0|#define LIBSPDM_MAX_HASH_SIZE 64
  ------------------
  605|      0|        libspdm_copy_mem(&secured_message_context->application_secret_backup
  606|      0|                         .request_data_encryption_key,
  607|      0|                         sizeof(secured_message_context->application_secret_backup
  608|      0|                                .request_data_encryption_key),
  609|      0|                         &secured_message_context->application_secret
  610|      0|                         .request_data_encryption_key,
  611|      0|                         LIBSPDM_MAX_AEAD_KEY_SIZE);
  ------------------
  |  |   73|      0|#define LIBSPDM_MAX_AEAD_KEY_SIZE 32
  ------------------
  612|      0|        libspdm_copy_mem(&secured_message_context->application_secret_backup
  613|      0|                         .request_data_salt,
  614|      0|                         sizeof(secured_message_context->application_secret_backup
  615|      0|                                .request_data_salt),
  616|      0|                         &secured_message_context->application_secret
  617|      0|                         .request_data_salt,
  618|      0|                         LIBSPDM_MAX_AEAD_IV_SIZE);
  ------------------
  |  |   74|      0|#define LIBSPDM_MAX_AEAD_IV_SIZE 12
  ------------------
  619|      0|        secured_message_context->application_secret_backup
  620|      0|        .request_data_sequence_number =
  621|      0|            secured_message_context->application_secret.request_data_sequence_number;
  622|       |
  623|      0|        status = libspdm_hkdf_expand(
  624|      0|            secured_message_context->base_hash_algo,
  625|      0|            secured_message_context->application_secret.request_data_secret,
  626|      0|            hash_size, bin_str9, bin_str9_size,
  627|      0|            secured_message_context->application_secret.request_data_secret,
  628|      0|            hash_size);
  629|      0|        if (!status) {
  ------------------
  |  Branch (629:13): [True: 0, False: 0]
  ------------------
  630|      0|            return false;
  631|      0|        }
  632|      0|        LIBSPDM_DEBUG((LIBSPDM_DEBUG_INFO, "RequestDataSecretUpdate (0x%zx) - ", hash_size));
  633|      0|        LIBSPDM_INTERNAL_DUMP_DATA(secured_message_context->application_secret.request_data_secret,
  634|      0|                                   hash_size);
  635|      0|        LIBSPDM_DEBUG((LIBSPDM_DEBUG_INFO, "\n"));
  636|       |
  637|      0|        status = libspdm_generate_aead_key_and_iv(
  638|      0|            secured_message_context,
  639|      0|            secured_message_context->application_secret.request_data_secret,
  640|      0|            secured_message_context->application_secret.request_data_encryption_key,
  641|      0|            secured_message_context->application_secret.request_data_salt);
  642|      0|        if (!status) {
  ------------------
  |  Branch (642:13): [True: 0, False: 0]
  ------------------
  643|      0|            return status;
  644|      0|        }
  645|      0|        secured_message_context->application_secret.request_data_sequence_number = 0;
  646|       |
  647|      0|        secured_message_context->requester_backup_valid = true;
  648|     34|    } else if (action == LIBSPDM_KEY_UPDATE_ACTION_RESPONDER) {
  ------------------
  |  Branch (648:16): [True: 34, False: 0]
  ------------------
  649|     34|        libspdm_copy_mem(&secured_message_context->application_secret_backup
  650|     34|                         .response_data_secret,
  651|     34|                         sizeof(secured_message_context->application_secret_backup
  652|     34|                                .response_data_secret),
  653|     34|                         &secured_message_context->application_secret
  654|     34|                         .response_data_secret,
  655|     34|                         LIBSPDM_MAX_HASH_SIZE);
  ------------------
  |  |   65|     34|#define LIBSPDM_MAX_HASH_SIZE 64
  ------------------
  656|     34|        libspdm_copy_mem(&secured_message_context->application_secret_backup
  657|     34|                         .response_data_encryption_key,
  658|     34|                         sizeof(secured_message_context->application_secret_backup
  659|     34|                                .response_data_encryption_key),
  660|     34|                         &secured_message_context->application_secret
  661|     34|                         .response_data_encryption_key,
  662|     34|                         LIBSPDM_MAX_AEAD_KEY_SIZE);
  ------------------
  |  |   73|     34|#define LIBSPDM_MAX_AEAD_KEY_SIZE 32
  ------------------
  663|     34|        libspdm_copy_mem(&secured_message_context->application_secret_backup
  664|     34|                         .response_data_salt,
  665|     34|                         sizeof(secured_message_context->application_secret_backup
  666|     34|                                .response_data_salt),
  667|     34|                         &secured_message_context->application_secret
  668|     34|                         .response_data_salt,
  669|     34|                         LIBSPDM_MAX_AEAD_IV_SIZE);
  ------------------
  |  |   74|     34|#define LIBSPDM_MAX_AEAD_IV_SIZE 12
  ------------------
  670|     34|        secured_message_context->application_secret_backup
  671|     34|        .response_data_sequence_number =
  672|     34|            secured_message_context->application_secret.response_data_sequence_number;
  673|       |
  674|     34|        status = libspdm_hkdf_expand(
  675|     34|            secured_message_context->base_hash_algo,
  676|     34|            secured_message_context->application_secret.response_data_secret,
  677|     34|            hash_size, bin_str9, bin_str9_size,
  678|     34|            secured_message_context->application_secret.response_data_secret,
  679|     34|            hash_size);
  680|     34|        if (!status) {
  ------------------
  |  Branch (680:13): [True: 0, False: 34]
  ------------------
  681|      0|            return false;
  682|      0|        }
  683|     34|        LIBSPDM_DEBUG((LIBSPDM_DEBUG_INFO, "ResponseDataSecretUpdate (0x%zx) - ",
  684|     34|                       hash_size));
  685|     34|        LIBSPDM_INTERNAL_DUMP_DATA(secured_message_context->application_secret.response_data_secret,
  686|     34|                                   hash_size);
  687|     34|        LIBSPDM_DEBUG((LIBSPDM_DEBUG_INFO, "\n"));
  688|       |
  689|     34|        status = libspdm_generate_aead_key_and_iv(
  690|     34|            secured_message_context,
  691|     34|            secured_message_context->application_secret.response_data_secret,
  692|     34|            secured_message_context->application_secret.response_data_encryption_key,
  693|     34|            secured_message_context->application_secret.response_data_salt);
  694|     34|        if (!status) {
  ------------------
  |  Branch (694:13): [True: 0, False: 34]
  ------------------
  695|      0|            return status;
  696|      0|        }
  697|     34|        secured_message_context->application_secret.response_data_sequence_number = 0;
  698|       |
  699|     34|        secured_message_context->responder_backup_valid = true;
  700|     34|    } else {
  701|      0|        return false;
  702|      0|    }
  703|       |
  704|     34|    return true;
  705|     34|}
libspdm_clear_handshake_secret:
  708|    119|{
  709|    119|    libspdm_secured_message_context_t *secured_message_context;
  710|       |
  711|    119|    secured_message_context = spdm_secured_message_context;
  712|       |
  713|    119|    libspdm_zero_mem(secured_message_context->master_secret.handshake_secret,
  714|    119|                     LIBSPDM_MAX_HASH_SIZE);
  ------------------
  |  |   65|    119|#define LIBSPDM_MAX_HASH_SIZE 64
  ------------------
  715|    119|    libspdm_zero_mem(&(secured_message_context->handshake_secret),
  716|    119|                     sizeof(libspdm_session_info_struct_handshake_secret_t));
  717|       |
  718|    119|    secured_message_context->requester_backup_valid = false;
  719|    119|    secured_message_context->responder_backup_valid = false;
  720|    119|}
libspdm_clear_master_secret:
  723|    119|{
  724|    119|    libspdm_secured_message_context_t *secured_message_context;
  725|       |
  726|    119|    secured_message_context = spdm_secured_message_context;
  727|       |
  728|    119|    libspdm_zero_mem(secured_message_context->master_secret.master_secret, LIBSPDM_MAX_HASH_SIZE);
  ------------------
  |  |   65|    119|#define LIBSPDM_MAX_HASH_SIZE 64
  ------------------
  729|    119|}

hkdf_md_expand:
  138|    221|{
  139|    221|    const mbedtls_md_info_t *md;
  140|    221|    int ret;
  141|    221|    size_t md_size;
  142|       |
  143|    221|    if (prk == NULL || info == NULL || out == NULL || prk_size > INT_MAX ||
  ------------------
  |  Branch (143:9): [True: 0, False: 221]
  |  Branch (143:24): [True: 0, False: 221]
  |  Branch (143:40): [True: 0, False: 221]
  |  Branch (143:55): [True: 0, False: 221]
  ------------------
  144|    221|        info_size > INT_MAX || out_size > INT_MAX) {
  ------------------
  |  Branch (144:9): [True: 0, False: 221]
  |  Branch (144:32): [True: 0, False: 221]
  ------------------
  145|      0|        return false;
  146|      0|    }
  147|       |
  148|    221|    switch (md_type) {
  149|    221|    case MBEDTLS_MD_SHA256:
  ------------------
  |  Branch (149:5): [True: 221, False: 0]
  ------------------
  150|    221|        md_size = LIBSPDM_SHA256_DIGEST_SIZE;
  ------------------
  |  |   11|    221|#define LIBSPDM_SHA256_DIGEST_SIZE 32
  ------------------
  151|    221|        break;
  152|      0|    case MBEDTLS_MD_SHA384:
  ------------------
  |  Branch (152:5): [True: 0, False: 221]
  ------------------
  153|      0|        md_size = LIBSPDM_SHA384_DIGEST_SIZE;
  ------------------
  |  |   14|      0|#define LIBSPDM_SHA384_DIGEST_SIZE 48
  ------------------
  154|      0|        break;
  155|      0|    case MBEDTLS_MD_SHA512:
  ------------------
  |  Branch (155:5): [True: 0, False: 221]
  ------------------
  156|      0|        md_size = LIBSPDM_SHA512_DIGEST_SIZE;
  ------------------
  |  |   17|      0|#define LIBSPDM_SHA512_DIGEST_SIZE 64
  ------------------
  157|      0|        break;
  158|      0|    default:
  ------------------
  |  Branch (158:5): [True: 0, False: 221]
  ------------------
  159|      0|        LIBSPDM_ASSERT(false);
  160|      0|        return false;
  161|    221|    }
  162|    221|    if (prk_size != md_size) {
  ------------------
  |  Branch (162:9): [True: 0, False: 221]
  ------------------
  163|      0|        return false;
  164|      0|    }
  165|       |
  166|    221|    md = mbedtls_md_info_from_type(md_type);
  167|    221|    LIBSPDM_ASSERT(md != NULL);
  168|       |
  169|    221|    ret = mbedtls_hkdf_expand(md, prk, (uint32_t)prk_size, info,
  170|    221|                              (uint32_t)info_size, out, (uint32_t)out_size);
  171|    221|    if (ret != 0) {
  ------------------
  |  Branch (171:9): [True: 0, False: 221]
  ------------------
  172|      0|        return false;
  173|      0|    }
  174|       |
  175|    221|    return true;
  176|    221|}
libspdm_hkdf_sha256_expand:
  243|    221|{
  244|    221|    return hkdf_md_expand(MBEDTLS_MD_SHA256, prk, prk_size, info, info_size,
  245|    221|                          out, out_size);
  246|    221|}

mbedtls_platform_zeroize:
   29|  2.43k|{
   30|  2.43k|    libspdm_zero_mem(buf, len);
   31|  2.43k|}

my_calloc:
   34|    442|{
   35|    442|    CRYPTMEM_HEAD *pool_hdr;
   36|    442|    size_t new_size;
   37|    442|    void *data;
   38|       |
   39|       |
   40|       |    /* Adjust the size by the buffer header overhead*/
   41|       |
   42|    442|    new_size = (size_t)(size * num) + CRYPTMEM_OVERHEAD;
  ------------------
  |  |   26|    442|#define CRYPTMEM_OVERHEAD sizeof(CRYPTMEM_HEAD)
  ------------------
   43|       |
   44|    442|    data = allocate_zero_pool(new_size);
   45|    442|    if (data != NULL) {
  ------------------
  |  Branch (45:9): [True: 442, False: 0]
  ------------------
   46|    442|        pool_hdr = (CRYPTMEM_HEAD *)data;
   47|       |
   48|       |        /* Record the memory brief information*/
   49|       |
   50|    442|        pool_hdr->version = CRYPTMEM_HEAD_VERSION;
  ------------------
  |  |   19|    442|#define CRYPTMEM_HEAD_VERSION 0x1
  ------------------
   51|    442|        pool_hdr->size = size;
   52|       |
   53|    442|        return (void *)(pool_hdr + 1);
   54|    442|    } else {
   55|       |
   56|       |        /* The buffer allocation failed.*/
   57|       |
   58|      0|        return NULL;
   59|      0|    }
   60|    442|}
my_free:
   64|    442|{
   65|    442|    CRYPTMEM_HEAD *pool_hdr;
   66|       |
   67|       |
   68|       |    /* In Standard C, free() handles a null pointer argument transparently. This
   69|       |     * is not true of free_pool() below, so protect it.*/
   70|       |
   71|    442|    if (ptr != NULL) {
  ------------------
  |  Branch (71:9): [True: 442, False: 0]
  ------------------
   72|    442|        pool_hdr = (CRYPTMEM_HEAD *)ptr - 1;
   73|    442|        LIBSPDM_ASSERT(pool_hdr->version == CRYPTMEM_HEAD_VERSION);
   74|    442|        free_pool(pool_hdr);
   75|    442|    }
   76|    442|}

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

md.c:mbedtls_get_unaligned_uint64:
  220|  3.53k|{
  221|  3.53k|    uint64_t r;
  222|       |#if defined(UINT_UNALIGNED)
  223|       |    mbedtls_uint64_unaligned_t *p64 = (mbedtls_uint64_unaligned_t *) p;
  224|       |    r = *p64;
  225|       |#elif defined(UINT_UNALIGNED_STRUCT)
  226|       |    mbedtls_uint64_unaligned_t *p64 = (mbedtls_uint64_unaligned_t *) p;
  227|       |    r = p64->x;
  228|       |#else
  229|  3.53k|    memcpy(&r, p, sizeof(r));
  230|  3.53k|#endif
  231|  3.53k|    return r;
  232|  3.53k|}
md.c:mbedtls_put_unaligned_uint64:
  247|  1.76k|{
  248|       |#if defined(UINT_UNALIGNED)
  249|       |    mbedtls_uint64_unaligned_t *p64 = (mbedtls_uint64_unaligned_t *) p;
  250|       |    *p64 = x;
  251|       |#elif defined(UINT_UNALIGNED_STRUCT)
  252|       |    mbedtls_uint64_unaligned_t *p64 = (mbedtls_uint64_unaligned_t *) p;
  253|       |    p64->x = x;
  254|       |#else
  255|  1.76k|    memcpy(p, &x, sizeof(x));
  256|  1.76k|#endif
  257|  1.76k|}
sha256.c:mbedtls_get_unaligned_uint32:
  168|  14.1k|{
  169|  14.1k|    uint32_t r;
  170|       |#if defined(UINT_UNALIGNED)
  171|       |    mbedtls_uint32_unaligned_t *p32 = (mbedtls_uint32_unaligned_t *) p;
  172|       |    r = *p32;
  173|       |#elif defined(UINT_UNALIGNED_STRUCT)
  174|       |    mbedtls_uint32_unaligned_t *p32 = (mbedtls_uint32_unaligned_t *) p;
  175|       |    r = p32->x;
  176|       |#else
  177|  14.1k|    memcpy(&r, p, sizeof(r));
  178|  14.1k|#endif
  179|  14.1k|    return r;
  180|  14.1k|}
sha256.c:mbedtls_put_unaligned_uint32:
  195|  4.42k|{
  196|       |#if defined(UINT_UNALIGNED)
  197|       |    mbedtls_uint32_unaligned_t *p32 = (mbedtls_uint32_unaligned_t *) p;
  198|       |    *p32 = x;
  199|       |#elif defined(UINT_UNALIGNED_STRUCT)
  200|       |    mbedtls_uint32_unaligned_t *p32 = (mbedtls_uint32_unaligned_t *) p;
  201|       |    p32->x = x;
  202|       |#else
  203|  4.42k|    memcpy(p, &x, sizeof(x));
  204|  4.42k|#endif
  205|  4.42k|}

md.c:mbedtls_xor:
  190|    442|{
  191|    442|    size_t i = 0;
  192|    442|#if defined(MBEDTLS_EFFICIENT_UNALIGNED_ACCESS)
  193|       |#if defined(MBEDTLS_HAVE_NEON_INTRINSICS) && \
  194|       |    (!(defined(MBEDTLS_COMPILER_IS_GCC) && MBEDTLS_GCC_VERSION < 70300))
  195|       |    /* Old GCC versions generate a warning here, so disable the NEON path for these compilers */
  196|       |    for (; (i + 16) <= n; i += 16) {
  197|       |        uint8x16_t v1 = vld1q_u8(a + i);
  198|       |        uint8x16_t v2 = vld1q_u8(b + i);
  199|       |        uint8x16_t x = veorq_u8(v1, v2);
  200|       |        vst1q_u8(r + i, x);
  201|       |    }
  202|       |#if defined(__IAR_SYSTEMS_ICC__)
  203|       |    /* This if statement helps some compilers (e.g., IAR) optimise out the byte-by-byte tail case
  204|       |     * where n is a constant multiple of 16.
  205|       |     * For other compilers (e.g. recent gcc and clang) it makes no difference if n is a compile-time
  206|       |     * constant, and is a very small perf regression if n is not a compile-time constant. */
  207|       |    if (n % 16 == 0) {
  208|       |        return;
  209|       |    }
  210|       |#endif
  211|       |#elif defined(MBEDTLS_ARCH_IS_X64) || defined(MBEDTLS_ARCH_IS_ARM64)
  212|       |    /* This codepath probably only makes sense on architectures with 64-bit registers */
  213|  2.21k|    for (; (i + 8) <= n; i += 8) {
  ------------------
  |  Branch (213:12): [True: 1.76k, False: 442]
  ------------------
  214|  1.76k|        uint64_t x = mbedtls_get_unaligned_uint64(a + i) ^ mbedtls_get_unaligned_uint64(b + i);
  215|  1.76k|        mbedtls_put_unaligned_uint64(r + i, x);
  216|  1.76k|    }
  217|       |#if defined(__IAR_SYSTEMS_ICC__)
  218|       |    if (n % 8 == 0) {
  219|       |        return;
  220|       |    }
  221|       |#endif
  222|       |#else
  223|       |    for (; (i + 4) <= n; i += 4) {
  224|       |        uint32_t x = mbedtls_get_unaligned_uint32(a + i) ^ mbedtls_get_unaligned_uint32(b + i);
  225|       |        mbedtls_put_unaligned_uint32(r + i, x);
  226|       |    }
  227|       |#if defined(__IAR_SYSTEMS_ICC__)
  228|       |    if (n % 4 == 0) {
  229|       |        return;
  230|       |    }
  231|       |#endif
  232|       |#endif
  233|    442|#endif
  234|    442|    for (; i < n; i++) {
  ------------------
  |  Branch (234:12): [True: 0, False: 442]
  ------------------
  235|      0|        r[i] = a[i] ^ b[i];
  236|      0|    }
  237|    442|}

mbedtls_hkdf_expand:
   66|    221|{
   67|    221|    size_t hash_len;
   68|    221|    size_t where = 0;
   69|    221|    size_t n;
   70|    221|    size_t t_len = 0;
   71|    221|    size_t i;
   72|    221|    int ret = 0;
   73|    221|    mbedtls_md_context_t ctx;
   74|    221|    unsigned char t[MBEDTLS_MD_MAX_SIZE];
   75|       |
   76|    221|    if (okm == NULL) {
  ------------------
  |  Branch (76:9): [True: 0, False: 221]
  ------------------
   77|      0|        return MBEDTLS_ERR_HKDF_BAD_INPUT_DATA;
  ------------------
  |  |   25|      0|#define MBEDTLS_ERR_HKDF_BAD_INPUT_DATA  -0x5F80
  ------------------
   78|      0|    }
   79|       |
   80|    221|    hash_len = mbedtls_md_get_size(md);
   81|       |
   82|    221|    if (prk_len < hash_len || hash_len == 0) {
  ------------------
  |  Branch (82:9): [True: 0, False: 221]
  |  Branch (82:31): [True: 0, False: 221]
  ------------------
   83|      0|        return MBEDTLS_ERR_HKDF_BAD_INPUT_DATA;
  ------------------
  |  |   25|      0|#define MBEDTLS_ERR_HKDF_BAD_INPUT_DATA  -0x5F80
  ------------------
   84|      0|    }
   85|       |
   86|    221|    if (info == NULL) {
  ------------------
  |  Branch (86:9): [True: 0, False: 221]
  ------------------
   87|      0|        info = (const unsigned char *) "";
   88|      0|        info_len = 0;
   89|      0|    }
   90|       |
   91|    221|    n = okm_len / hash_len;
   92|       |
   93|    221|    if (okm_len % hash_len != 0) {
  ------------------
  |  Branch (93:9): [True: 34, False: 187]
  ------------------
   94|     34|        n++;
   95|     34|    }
   96|       |
   97|       |    /*
   98|       |     * Per RFC 5869 Section 2.3, okm_len must not exceed
   99|       |     * 255 times the hash length
  100|       |     */
  101|    221|    if (n > 255) {
  ------------------
  |  Branch (101:9): [True: 0, False: 221]
  ------------------
  102|      0|        return MBEDTLS_ERR_HKDF_BAD_INPUT_DATA;
  ------------------
  |  |   25|      0|#define MBEDTLS_ERR_HKDF_BAD_INPUT_DATA  -0x5F80
  ------------------
  103|      0|    }
  104|       |
  105|    221|    mbedtls_md_init(&ctx);
  106|       |
  107|    221|    if ((ret = mbedtls_md_setup(&ctx, md, 1)) != 0) {
  ------------------
  |  Branch (107:9): [True: 0, False: 221]
  ------------------
  108|      0|        goto exit;
  109|      0|    }
  110|       |
  111|    221|    memset(t, 0, hash_len);
  112|       |
  113|       |    /*
  114|       |     * Compute T = T(1) | T(2) | T(3) | ... | T(N)
  115|       |     * Where T(N) is defined in RFC 5869 Section 2.3
  116|       |     */
  117|    442|    for (i = 1; i <= n; i++) {
  ------------------
  |  Branch (117:17): [True: 221, False: 221]
  ------------------
  118|    221|        size_t num_to_copy;
  119|    221|        unsigned char c = i & 0xff;
  120|       |
  121|    221|        ret = mbedtls_md_hmac_starts(&ctx, prk, prk_len);
  122|    221|        if (ret != 0) {
  ------------------
  |  Branch (122:13): [True: 0, False: 221]
  ------------------
  123|      0|            goto exit;
  124|      0|        }
  125|       |
  126|    221|        ret = mbedtls_md_hmac_update(&ctx, t, t_len);
  127|    221|        if (ret != 0) {
  ------------------
  |  Branch (127:13): [True: 0, False: 221]
  ------------------
  128|      0|            goto exit;
  129|      0|        }
  130|       |
  131|    221|        ret = mbedtls_md_hmac_update(&ctx, info, info_len);
  132|    221|        if (ret != 0) {
  ------------------
  |  Branch (132:13): [True: 0, False: 221]
  ------------------
  133|      0|            goto exit;
  134|      0|        }
  135|       |
  136|       |        /* The constant concatenated to the end of each T(n) is a single octet.
  137|       |         * */
  138|    221|        ret = mbedtls_md_hmac_update(&ctx, &c, 1);
  139|    221|        if (ret != 0) {
  ------------------
  |  Branch (139:13): [True: 0, False: 221]
  ------------------
  140|      0|            goto exit;
  141|      0|        }
  142|       |
  143|    221|        ret = mbedtls_md_hmac_finish(&ctx, t);
  144|    221|        if (ret != 0) {
  ------------------
  |  Branch (144:13): [True: 0, False: 221]
  ------------------
  145|      0|            goto exit;
  146|      0|        }
  147|       |
  148|    221|        num_to_copy = i != n ? hash_len : okm_len - where;
  ------------------
  |  Branch (148:23): [True: 0, False: 221]
  ------------------
  149|    221|        memcpy(okm + where, t, num_to_copy);
  150|    221|        where += hash_len;
  151|    221|        t_len = hash_len;
  152|    221|    }
  153|       |
  154|    221|exit:
  155|    221|    mbedtls_md_free(&ctx);
  156|    221|    mbedtls_platform_zeroize(t, sizeof(t));
  157|       |
  158|    221|    return ret;
  159|    221|}

mbedtls_md_info_from_type:
  140|    221|{
  141|    221|    switch (md_type) {
  142|       |#if defined(MBEDTLS_MD_CAN_MD5)
  143|       |        case MBEDTLS_MD_MD5:
  144|       |            return &mbedtls_md5_info;
  145|       |#endif
  146|       |#if defined(MBEDTLS_MD_CAN_RIPEMD160)
  147|       |        case MBEDTLS_MD_RIPEMD160:
  148|       |            return &mbedtls_ripemd160_info;
  149|       |#endif
  150|       |#if defined(MBEDTLS_MD_CAN_SHA1)
  151|       |        case MBEDTLS_MD_SHA1:
  152|       |            return &mbedtls_sha1_info;
  153|       |#endif
  154|       |#if defined(MBEDTLS_MD_CAN_SHA224)
  155|       |        case MBEDTLS_MD_SHA224:
  156|       |            return &mbedtls_sha224_info;
  157|       |#endif
  158|      0|#if defined(MBEDTLS_MD_CAN_SHA256)
  159|    221|        case MBEDTLS_MD_SHA256:
  ------------------
  |  Branch (159:9): [True: 221, False: 0]
  ------------------
  160|    221|            return &mbedtls_sha256_info;
  161|      0|#endif
  162|      0|#if defined(MBEDTLS_MD_CAN_SHA384)
  163|      0|        case MBEDTLS_MD_SHA384:
  ------------------
  |  Branch (163:9): [True: 0, False: 221]
  ------------------
  164|      0|            return &mbedtls_sha384_info;
  165|      0|#endif
  166|      0|#if defined(MBEDTLS_MD_CAN_SHA512)
  167|      0|        case MBEDTLS_MD_SHA512:
  ------------------
  |  Branch (167:9): [True: 0, False: 221]
  ------------------
  168|      0|            return &mbedtls_sha512_info;
  169|      0|#endif
  170|      0|#if defined(MBEDTLS_MD_CAN_SHA3_224)
  171|      0|        case MBEDTLS_MD_SHA3_224:
  ------------------
  |  Branch (171:9): [True: 0, False: 221]
  ------------------
  172|      0|            return &mbedtls_sha3_224_info;
  173|      0|#endif
  174|      0|#if defined(MBEDTLS_MD_CAN_SHA3_256)
  175|      0|        case MBEDTLS_MD_SHA3_256:
  ------------------
  |  Branch (175:9): [True: 0, False: 221]
  ------------------
  176|      0|            return &mbedtls_sha3_256_info;
  177|      0|#endif
  178|      0|#if defined(MBEDTLS_MD_CAN_SHA3_384)
  179|      0|        case MBEDTLS_MD_SHA3_384:
  ------------------
  |  Branch (179:9): [True: 0, False: 221]
  ------------------
  180|      0|            return &mbedtls_sha3_384_info;
  181|      0|#endif
  182|      0|#if defined(MBEDTLS_MD_CAN_SHA3_512)
  183|      0|        case MBEDTLS_MD_SHA3_512:
  ------------------
  |  Branch (183:9): [True: 0, False: 221]
  ------------------
  184|      0|            return &mbedtls_sha3_512_info;
  185|      0|#endif
  186|      0|        default:
  ------------------
  |  Branch (186:9): [True: 0, False: 221]
  ------------------
  187|      0|            return NULL;
  188|    221|    }
  189|    221|}
mbedtls_md_init:
  256|    221|{
  257|       |    /* Note: this sets engine (if present) to MBEDTLS_MD_ENGINE_LEGACY */
  258|    221|    memset(ctx, 0, sizeof(mbedtls_md_context_t));
  259|    221|}
mbedtls_md_free:
  262|    221|{
  263|    221|    if (ctx == NULL || ctx->md_info == NULL) {
  ------------------
  |  Branch (263:9): [True: 0, False: 221]
  |  Branch (263:24): [True: 0, False: 221]
  ------------------
  264|      0|        return;
  265|      0|    }
  266|       |
  267|    221|    if (ctx->md_ctx != NULL) {
  ------------------
  |  Branch (267:9): [True: 221, False: 0]
  ------------------
  268|       |#if defined(MBEDTLS_MD_SOME_PSA)
  269|       |        if (ctx->engine == MBEDTLS_MD_ENGINE_PSA) {
  270|       |            psa_hash_abort(ctx->md_ctx);
  271|       |        } else
  272|       |#endif
  273|    221|        switch (ctx->md_info->type) {
  274|       |#if defined(MBEDTLS_MD5_C)
  275|       |            case MBEDTLS_MD_MD5:
  276|       |                mbedtls_md5_free(ctx->md_ctx);
  277|       |                break;
  278|       |#endif
  279|       |#if defined(MBEDTLS_RIPEMD160_C)
  280|       |            case MBEDTLS_MD_RIPEMD160:
  281|       |                mbedtls_ripemd160_free(ctx->md_ctx);
  282|       |                break;
  283|       |#endif
  284|       |#if defined(MBEDTLS_SHA1_C)
  285|       |            case MBEDTLS_MD_SHA1:
  286|       |                mbedtls_sha1_free(ctx->md_ctx);
  287|       |                break;
  288|       |#endif
  289|       |#if defined(MBEDTLS_SHA224_C)
  290|       |            case MBEDTLS_MD_SHA224:
  291|       |                mbedtls_sha256_free(ctx->md_ctx);
  292|       |                break;
  293|       |#endif
  294|      0|#if defined(MBEDTLS_SHA256_C)
  295|    221|            case MBEDTLS_MD_SHA256:
  ------------------
  |  Branch (295:13): [True: 221, False: 0]
  ------------------
  296|    221|                mbedtls_sha256_free(ctx->md_ctx);
  297|    221|                break;
  298|      0|#endif
  299|      0|#if defined(MBEDTLS_SHA384_C)
  300|      0|            case MBEDTLS_MD_SHA384:
  ------------------
  |  Branch (300:13): [True: 0, False: 221]
  ------------------
  301|      0|                mbedtls_sha512_free(ctx->md_ctx);
  302|      0|                break;
  303|      0|#endif
  304|      0|#if defined(MBEDTLS_SHA512_C)
  305|      0|            case MBEDTLS_MD_SHA512:
  ------------------
  |  Branch (305:13): [True: 0, False: 221]
  ------------------
  306|      0|                mbedtls_sha512_free(ctx->md_ctx);
  307|      0|                break;
  308|      0|#endif
  309|      0|#if defined(MBEDTLS_SHA3_C)
  310|      0|            case MBEDTLS_MD_SHA3_224:
  ------------------
  |  Branch (310:13): [True: 0, False: 221]
  ------------------
  311|      0|            case MBEDTLS_MD_SHA3_256:
  ------------------
  |  Branch (311:13): [True: 0, False: 221]
  ------------------
  312|      0|            case MBEDTLS_MD_SHA3_384:
  ------------------
  |  Branch (312:13): [True: 0, False: 221]
  ------------------
  313|      0|            case MBEDTLS_MD_SHA3_512:
  ------------------
  |  Branch (313:13): [True: 0, False: 221]
  ------------------
  314|      0|                mbedtls_sha3_free(ctx->md_ctx);
  315|      0|                break;
  316|      0|#endif
  317|      0|            default:
  ------------------
  |  Branch (317:13): [True: 0, False: 221]
  ------------------
  318|       |                /* Shouldn't happen */
  319|      0|                break;
  320|    221|        }
  321|    221|        mbedtls_free(ctx->md_ctx);
  ------------------
  |  |  143|    221|#define mbedtls_free       MBEDTLS_PLATFORM_FREE_MACRO
  |  |  ------------------
  |  |  |  | 4095|    221|#define MBEDTLS_PLATFORM_FREE_MACRO            my_free
  |  |  ------------------
  ------------------
  322|    221|    }
  323|       |
  324|    221|#if defined(MBEDTLS_MD_C)
  325|    221|    if (ctx->hmac_ctx != NULL) {
  ------------------
  |  Branch (325:9): [True: 221, False: 0]
  ------------------
  326|    221|        mbedtls_zeroize_and_free(ctx->hmac_ctx,
  327|    221|                                 2 * ctx->md_info->block_size);
  328|    221|    }
  329|    221|#endif
  330|       |
  331|    221|    mbedtls_platform_zeroize(ctx, sizeof(mbedtls_md_context_t));
  332|    221|}
mbedtls_md_setup:
  419|    221|{
  420|    221|#if defined(MBEDTLS_MD_C)
  421|    221|    if (ctx == NULL) {
  ------------------
  |  Branch (421:9): [True: 0, False: 221]
  ------------------
  422|      0|        return MBEDTLS_ERR_MD_BAD_INPUT_DATA;
  ------------------
  |  |   26|      0|#define MBEDTLS_ERR_MD_BAD_INPUT_DATA                     -0x5100
  ------------------
  423|      0|    }
  424|    221|#endif
  425|    221|    if (md_info == NULL) {
  ------------------
  |  Branch (425:9): [True: 0, False: 221]
  ------------------
  426|      0|        return MBEDTLS_ERR_MD_BAD_INPUT_DATA;
  ------------------
  |  |   26|      0|#define MBEDTLS_ERR_MD_BAD_INPUT_DATA                     -0x5100
  ------------------
  427|      0|    }
  428|       |
  429|    221|    ctx->md_info = md_info;
  430|    221|    ctx->md_ctx = NULL;
  431|    221|#if defined(MBEDTLS_MD_C)
  432|    221|    ctx->hmac_ctx = NULL;
  433|       |#else
  434|       |    if (hmac != 0) {
  435|       |        return MBEDTLS_ERR_MD_BAD_INPUT_DATA;
  436|       |    }
  437|       |#endif
  438|       |
  439|       |#if defined(MBEDTLS_MD_SOME_PSA)
  440|       |    if (md_can_use_psa(ctx->md_info)) {
  441|       |        ctx->md_ctx = mbedtls_calloc(1, sizeof(psa_hash_operation_t));
  442|       |        if (ctx->md_ctx == NULL) {
  443|       |            return MBEDTLS_ERR_MD_ALLOC_FAILED;
  444|       |        }
  445|       |        ctx->engine = MBEDTLS_MD_ENGINE_PSA;
  446|       |    } else
  447|       |#endif
  448|    221|    switch (md_info->type) {
  449|       |#if defined(MBEDTLS_MD5_C)
  450|       |        case MBEDTLS_MD_MD5:
  451|       |            ALLOC(md5);
  452|       |            break;
  453|       |#endif
  454|       |#if defined(MBEDTLS_RIPEMD160_C)
  455|       |        case MBEDTLS_MD_RIPEMD160:
  456|       |            ALLOC(ripemd160);
  457|       |            break;
  458|       |#endif
  459|       |#if defined(MBEDTLS_SHA1_C)
  460|       |        case MBEDTLS_MD_SHA1:
  461|       |            ALLOC(sha1);
  462|       |            break;
  463|       |#endif
  464|       |#if defined(MBEDTLS_SHA224_C)
  465|       |        case MBEDTLS_MD_SHA224:
  466|       |            ALLOC(sha256);
  467|       |            break;
  468|       |#endif
  469|      0|#if defined(MBEDTLS_SHA256_C)
  470|    221|        case MBEDTLS_MD_SHA256:
  ------------------
  |  Branch (470:9): [True: 221, False: 0]
  ------------------
  471|    221|            ALLOC(sha256);
  ------------------
  |  |  410|    221|    do {                                                                \
  |  |  411|    221|        ctx->md_ctx = mbedtls_calloc(1, sizeof(mbedtls_##type##_context)); \
  |  |  ------------------
  |  |  |  |  144|    221|#define mbedtls_calloc     MBEDTLS_PLATFORM_CALLOC_MACRO
  |  |  |  |  ------------------
  |  |  |  |  |  | 4093|    221|#define MBEDTLS_PLATFORM_CALLOC_MACRO        my_calloc
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  412|    221|        if (ctx->md_ctx == NULL)                                       \
  |  |  ------------------
  |  |  |  Branch (412:13): [True: 0, False: 221]
  |  |  ------------------
  |  |  413|    221|        return MBEDTLS_ERR_MD_ALLOC_FAILED;                      \
  |  |  ------------------
  |  |  |  |   28|      0|#define MBEDTLS_ERR_MD_ALLOC_FAILED                       -0x5180
  |  |  ------------------
  |  |  414|    221|        mbedtls_##type##_init(ctx->md_ctx);                           \
  |  |  415|    221|    }                                                                   \
  |  |  416|    221|    while (0)
  |  |  ------------------
  |  |  |  Branch (416:12): [Folded - Ignored]
  |  |  ------------------
  ------------------
  472|    221|            break;
  473|    221|#endif
  474|    221|#if defined(MBEDTLS_SHA384_C)
  475|    221|        case MBEDTLS_MD_SHA384:
  ------------------
  |  Branch (475:9): [True: 0, False: 221]
  ------------------
  476|      0|            ALLOC(sha512);
  ------------------
  |  |  410|      0|    do {                                                                \
  |  |  411|      0|        ctx->md_ctx = mbedtls_calloc(1, sizeof(mbedtls_##type##_context)); \
  |  |  ------------------
  |  |  |  |  144|      0|#define mbedtls_calloc     MBEDTLS_PLATFORM_CALLOC_MACRO
  |  |  |  |  ------------------
  |  |  |  |  |  | 4093|      0|#define MBEDTLS_PLATFORM_CALLOC_MACRO        my_calloc
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  412|      0|        if (ctx->md_ctx == NULL)                                       \
  |  |  ------------------
  |  |  |  Branch (412:13): [True: 0, False: 0]
  |  |  ------------------
  |  |  413|      0|        return MBEDTLS_ERR_MD_ALLOC_FAILED;                      \
  |  |  ------------------
  |  |  |  |   28|      0|#define MBEDTLS_ERR_MD_ALLOC_FAILED                       -0x5180
  |  |  ------------------
  |  |  414|      0|        mbedtls_##type##_init(ctx->md_ctx);                           \
  |  |  415|      0|    }                                                                   \
  |  |  416|      0|    while (0)
  |  |  ------------------
  |  |  |  Branch (416:12): [Folded - Ignored]
  |  |  ------------------
  ------------------
  477|      0|            break;
  478|      0|#endif
  479|      0|#if defined(MBEDTLS_SHA512_C)
  480|      0|        case MBEDTLS_MD_SHA512:
  ------------------
  |  Branch (480:9): [True: 0, False: 221]
  ------------------
  481|      0|            ALLOC(sha512);
  ------------------
  |  |  410|      0|    do {                                                                \
  |  |  411|      0|        ctx->md_ctx = mbedtls_calloc(1, sizeof(mbedtls_##type##_context)); \
  |  |  ------------------
  |  |  |  |  144|      0|#define mbedtls_calloc     MBEDTLS_PLATFORM_CALLOC_MACRO
  |  |  |  |  ------------------
  |  |  |  |  |  | 4093|      0|#define MBEDTLS_PLATFORM_CALLOC_MACRO        my_calloc
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  412|      0|        if (ctx->md_ctx == NULL)                                       \
  |  |  ------------------
  |  |  |  Branch (412:13): [True: 0, False: 0]
  |  |  ------------------
  |  |  413|      0|        return MBEDTLS_ERR_MD_ALLOC_FAILED;                      \
  |  |  ------------------
  |  |  |  |   28|      0|#define MBEDTLS_ERR_MD_ALLOC_FAILED                       -0x5180
  |  |  ------------------
  |  |  414|      0|        mbedtls_##type##_init(ctx->md_ctx);                           \
  |  |  415|      0|    }                                                                   \
  |  |  416|      0|    while (0)
  |  |  ------------------
  |  |  |  Branch (416:12): [Folded - Ignored]
  |  |  ------------------
  ------------------
  482|      0|            break;
  483|      0|#endif
  484|      0|#if defined(MBEDTLS_SHA3_C)
  485|      0|        case MBEDTLS_MD_SHA3_224:
  ------------------
  |  Branch (485:9): [True: 0, False: 221]
  ------------------
  486|      0|        case MBEDTLS_MD_SHA3_256:
  ------------------
  |  Branch (486:9): [True: 0, False: 221]
  ------------------
  487|      0|        case MBEDTLS_MD_SHA3_384:
  ------------------
  |  Branch (487:9): [True: 0, False: 221]
  ------------------
  488|      0|        case MBEDTLS_MD_SHA3_512:
  ------------------
  |  Branch (488:9): [True: 0, False: 221]
  ------------------
  489|      0|            ALLOC(sha3);
  ------------------
  |  |  410|      0|    do {                                                                \
  |  |  411|      0|        ctx->md_ctx = mbedtls_calloc(1, sizeof(mbedtls_##type##_context)); \
  |  |  ------------------
  |  |  |  |  144|      0|#define mbedtls_calloc     MBEDTLS_PLATFORM_CALLOC_MACRO
  |  |  |  |  ------------------
  |  |  |  |  |  | 4093|      0|#define MBEDTLS_PLATFORM_CALLOC_MACRO        my_calloc
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  412|      0|        if (ctx->md_ctx == NULL)                                       \
  |  |  ------------------
  |  |  |  Branch (412:13): [True: 0, False: 0]
  |  |  ------------------
  |  |  413|      0|        return MBEDTLS_ERR_MD_ALLOC_FAILED;                      \
  |  |  ------------------
  |  |  |  |   28|      0|#define MBEDTLS_ERR_MD_ALLOC_FAILED                       -0x5180
  |  |  ------------------
  |  |  414|      0|        mbedtls_##type##_init(ctx->md_ctx);                           \
  |  |  415|      0|    }                                                                   \
  |  |  416|      0|    while (0)
  |  |  ------------------
  |  |  |  Branch (416:12): [Folded - Ignored]
  |  |  ------------------
  ------------------
  490|      0|            break;
  491|      0|#endif
  492|      0|        default:
  ------------------
  |  Branch (492:9): [True: 0, False: 221]
  ------------------
  493|      0|            return MBEDTLS_ERR_MD_BAD_INPUT_DATA;
  ------------------
  |  |   26|      0|#define MBEDTLS_ERR_MD_BAD_INPUT_DATA                     -0x5100
  ------------------
  494|    221|    }
  495|       |
  496|    221|#if defined(MBEDTLS_MD_C)
  497|    221|    if (hmac != 0) {
  ------------------
  |  Branch (497:9): [True: 221, False: 0]
  ------------------
  498|    221|        ctx->hmac_ctx = mbedtls_calloc(2, md_info->block_size);
  ------------------
  |  |  144|    221|#define mbedtls_calloc     MBEDTLS_PLATFORM_CALLOC_MACRO
  |  |  ------------------
  |  |  |  | 4093|    221|#define MBEDTLS_PLATFORM_CALLOC_MACRO        my_calloc
  |  |  ------------------
  ------------------
  499|    221|        if (ctx->hmac_ctx == NULL) {
  ------------------
  |  Branch (499:13): [True: 0, False: 221]
  ------------------
  500|      0|            mbedtls_md_free(ctx);
  501|      0|            return MBEDTLS_ERR_MD_ALLOC_FAILED;
  ------------------
  |  |   28|      0|#define MBEDTLS_ERR_MD_ALLOC_FAILED                       -0x5180
  ------------------
  502|      0|        }
  503|    221|    }
  504|    221|#endif
  505|       |
  506|    221|    return 0;
  507|    221|}
mbedtls_md_starts:
  511|    442|{
  512|    442|#if defined(MBEDTLS_MD_C)
  513|    442|    if (ctx == NULL || ctx->md_info == NULL) {
  ------------------
  |  Branch (513:9): [True: 0, False: 442]
  |  Branch (513:24): [True: 0, False: 442]
  ------------------
  514|      0|        return MBEDTLS_ERR_MD_BAD_INPUT_DATA;
  ------------------
  |  |   26|      0|#define MBEDTLS_ERR_MD_BAD_INPUT_DATA                     -0x5100
  ------------------
  515|      0|    }
  516|    442|#endif
  517|       |
  518|       |#if defined(MBEDTLS_MD_SOME_PSA)
  519|       |    if (ctx->engine == MBEDTLS_MD_ENGINE_PSA) {
  520|       |        psa_algorithm_t alg = psa_alg_of_md(ctx->md_info);
  521|       |        psa_hash_abort(ctx->md_ctx);
  522|       |        psa_status_t status = psa_hash_setup(ctx->md_ctx, alg);
  523|       |        return mbedtls_md_error_from_psa(status);
  524|       |    }
  525|       |#endif
  526|       |
  527|    442|    switch (ctx->md_info->type) {
  528|       |#if defined(MBEDTLS_MD5_C)
  529|       |        case MBEDTLS_MD_MD5:
  530|       |            return mbedtls_md5_starts(ctx->md_ctx);
  531|       |#endif
  532|       |#if defined(MBEDTLS_RIPEMD160_C)
  533|       |        case MBEDTLS_MD_RIPEMD160:
  534|       |            return mbedtls_ripemd160_starts(ctx->md_ctx);
  535|       |#endif
  536|       |#if defined(MBEDTLS_SHA1_C)
  537|       |        case MBEDTLS_MD_SHA1:
  538|       |            return mbedtls_sha1_starts(ctx->md_ctx);
  539|       |#endif
  540|       |#if defined(MBEDTLS_SHA224_C)
  541|       |        case MBEDTLS_MD_SHA224:
  542|       |            return mbedtls_sha256_starts(ctx->md_ctx, 1);
  543|       |#endif
  544|      0|#if defined(MBEDTLS_SHA256_C)
  545|    442|        case MBEDTLS_MD_SHA256:
  ------------------
  |  Branch (545:9): [True: 442, False: 0]
  ------------------
  546|    442|            return mbedtls_sha256_starts(ctx->md_ctx, 0);
  547|      0|#endif
  548|      0|#if defined(MBEDTLS_SHA384_C)
  549|      0|        case MBEDTLS_MD_SHA384:
  ------------------
  |  Branch (549:9): [True: 0, False: 442]
  ------------------
  550|      0|            return mbedtls_sha512_starts(ctx->md_ctx, 1);
  551|      0|#endif
  552|      0|#if defined(MBEDTLS_SHA512_C)
  553|      0|        case MBEDTLS_MD_SHA512:
  ------------------
  |  Branch (553:9): [True: 0, False: 442]
  ------------------
  554|      0|            return mbedtls_sha512_starts(ctx->md_ctx, 0);
  555|      0|#endif
  556|      0|#if defined(MBEDTLS_SHA3_C)
  557|      0|        case MBEDTLS_MD_SHA3_224:
  ------------------
  |  Branch (557:9): [True: 0, False: 442]
  ------------------
  558|      0|            return mbedtls_sha3_starts(ctx->md_ctx, MBEDTLS_SHA3_224);
  559|      0|        case MBEDTLS_MD_SHA3_256:
  ------------------
  |  Branch (559:9): [True: 0, False: 442]
  ------------------
  560|      0|            return mbedtls_sha3_starts(ctx->md_ctx, MBEDTLS_SHA3_256);
  561|      0|        case MBEDTLS_MD_SHA3_384:
  ------------------
  |  Branch (561:9): [True: 0, False: 442]
  ------------------
  562|      0|            return mbedtls_sha3_starts(ctx->md_ctx, MBEDTLS_SHA3_384);
  563|      0|        case MBEDTLS_MD_SHA3_512:
  ------------------
  |  Branch (563:9): [True: 0, False: 442]
  ------------------
  564|      0|            return mbedtls_sha3_starts(ctx->md_ctx, MBEDTLS_SHA3_512);
  565|      0|#endif
  566|      0|        default:
  ------------------
  |  Branch (566:9): [True: 0, False: 442]
  ------------------
  567|      0|            return MBEDTLS_ERR_MD_BAD_INPUT_DATA;
  ------------------
  |  |   26|      0|#define MBEDTLS_ERR_MD_BAD_INPUT_DATA                     -0x5100
  ------------------
  568|    442|    }
  569|    442|}
mbedtls_md_update:
  572|  1.32k|{
  573|  1.32k|#if defined(MBEDTLS_MD_C)
  574|  1.32k|    if (ctx == NULL || ctx->md_info == NULL) {
  ------------------
  |  Branch (574:9): [True: 0, False: 1.32k]
  |  Branch (574:24): [True: 0, False: 1.32k]
  ------------------
  575|      0|        return MBEDTLS_ERR_MD_BAD_INPUT_DATA;
  ------------------
  |  |   26|      0|#define MBEDTLS_ERR_MD_BAD_INPUT_DATA                     -0x5100
  ------------------
  576|      0|    }
  577|  1.32k|#endif
  578|       |
  579|       |#if defined(MBEDTLS_MD_SOME_PSA)
  580|       |    if (ctx->engine == MBEDTLS_MD_ENGINE_PSA) {
  581|       |        psa_status_t status = psa_hash_update(ctx->md_ctx, input, ilen);
  582|       |        return mbedtls_md_error_from_psa(status);
  583|       |    }
  584|       |#endif
  585|       |
  586|  1.32k|    switch (ctx->md_info->type) {
  587|       |#if defined(MBEDTLS_MD5_C)
  588|       |        case MBEDTLS_MD_MD5:
  589|       |            return mbedtls_md5_update(ctx->md_ctx, input, ilen);
  590|       |#endif
  591|       |#if defined(MBEDTLS_RIPEMD160_C)
  592|       |        case MBEDTLS_MD_RIPEMD160:
  593|       |            return mbedtls_ripemd160_update(ctx->md_ctx, input, ilen);
  594|       |#endif
  595|       |#if defined(MBEDTLS_SHA1_C)
  596|       |        case MBEDTLS_MD_SHA1:
  597|       |            return mbedtls_sha1_update(ctx->md_ctx, input, ilen);
  598|       |#endif
  599|       |#if defined(MBEDTLS_SHA224_C)
  600|       |        case MBEDTLS_MD_SHA224:
  601|       |            return mbedtls_sha256_update(ctx->md_ctx, input, ilen);
  602|       |#endif
  603|      0|#if defined(MBEDTLS_SHA256_C)
  604|  1.32k|        case MBEDTLS_MD_SHA256:
  ------------------
  |  Branch (604:9): [True: 1.32k, False: 0]
  ------------------
  605|  1.32k|            return mbedtls_sha256_update(ctx->md_ctx, input, ilen);
  606|      0|#endif
  607|      0|#if defined(MBEDTLS_SHA384_C)
  608|      0|        case MBEDTLS_MD_SHA384:
  ------------------
  |  Branch (608:9): [True: 0, False: 1.32k]
  ------------------
  609|      0|            return mbedtls_sha512_update(ctx->md_ctx, input, ilen);
  610|      0|#endif
  611|      0|#if defined(MBEDTLS_SHA512_C)
  612|      0|        case MBEDTLS_MD_SHA512:
  ------------------
  |  Branch (612:9): [True: 0, False: 1.32k]
  ------------------
  613|      0|            return mbedtls_sha512_update(ctx->md_ctx, input, ilen);
  614|      0|#endif
  615|      0|#if defined(MBEDTLS_SHA3_C)
  616|      0|        case MBEDTLS_MD_SHA3_224:
  ------------------
  |  Branch (616:9): [True: 0, False: 1.32k]
  ------------------
  617|      0|        case MBEDTLS_MD_SHA3_256:
  ------------------
  |  Branch (617:9): [True: 0, False: 1.32k]
  ------------------
  618|      0|        case MBEDTLS_MD_SHA3_384:
  ------------------
  |  Branch (618:9): [True: 0, False: 1.32k]
  ------------------
  619|      0|        case MBEDTLS_MD_SHA3_512:
  ------------------
  |  Branch (619:9): [True: 0, False: 1.32k]
  ------------------
  620|      0|            return mbedtls_sha3_update(ctx->md_ctx, input, ilen);
  621|      0|#endif
  622|      0|        default:
  ------------------
  |  Branch (622:9): [True: 0, False: 1.32k]
  ------------------
  623|      0|            return MBEDTLS_ERR_MD_BAD_INPUT_DATA;
  ------------------
  |  |   26|      0|#define MBEDTLS_ERR_MD_BAD_INPUT_DATA                     -0x5100
  ------------------
  624|  1.32k|    }
  625|  1.32k|}
mbedtls_md_finish:
  628|    442|{
  629|    442|#if defined(MBEDTLS_MD_C)
  630|    442|    if (ctx == NULL || ctx->md_info == NULL) {
  ------------------
  |  Branch (630:9): [True: 0, False: 442]
  |  Branch (630:24): [True: 0, False: 442]
  ------------------
  631|      0|        return MBEDTLS_ERR_MD_BAD_INPUT_DATA;
  ------------------
  |  |   26|      0|#define MBEDTLS_ERR_MD_BAD_INPUT_DATA                     -0x5100
  ------------------
  632|      0|    }
  633|    442|#endif
  634|       |
  635|       |#if defined(MBEDTLS_MD_SOME_PSA)
  636|       |    if (ctx->engine == MBEDTLS_MD_ENGINE_PSA) {
  637|       |        size_t size = ctx->md_info->size;
  638|       |        psa_status_t status = psa_hash_finish(ctx->md_ctx,
  639|       |                                              output, size, &size);
  640|       |        return mbedtls_md_error_from_psa(status);
  641|       |    }
  642|       |#endif
  643|       |
  644|    442|    switch (ctx->md_info->type) {
  645|       |#if defined(MBEDTLS_MD5_C)
  646|       |        case MBEDTLS_MD_MD5:
  647|       |            return mbedtls_md5_finish(ctx->md_ctx, output);
  648|       |#endif
  649|       |#if defined(MBEDTLS_RIPEMD160_C)
  650|       |        case MBEDTLS_MD_RIPEMD160:
  651|       |            return mbedtls_ripemd160_finish(ctx->md_ctx, output);
  652|       |#endif
  653|       |#if defined(MBEDTLS_SHA1_C)
  654|       |        case MBEDTLS_MD_SHA1:
  655|       |            return mbedtls_sha1_finish(ctx->md_ctx, output);
  656|       |#endif
  657|       |#if defined(MBEDTLS_SHA224_C)
  658|       |        case MBEDTLS_MD_SHA224:
  659|       |            return mbedtls_sha256_finish(ctx->md_ctx, output);
  660|       |#endif
  661|      0|#if defined(MBEDTLS_SHA256_C)
  662|    442|        case MBEDTLS_MD_SHA256:
  ------------------
  |  Branch (662:9): [True: 442, False: 0]
  ------------------
  663|    442|            return mbedtls_sha256_finish(ctx->md_ctx, output);
  664|      0|#endif
  665|      0|#if defined(MBEDTLS_SHA384_C)
  666|      0|        case MBEDTLS_MD_SHA384:
  ------------------
  |  Branch (666:9): [True: 0, False: 442]
  ------------------
  667|      0|            return mbedtls_sha512_finish(ctx->md_ctx, output);
  668|      0|#endif
  669|      0|#if defined(MBEDTLS_SHA512_C)
  670|      0|        case MBEDTLS_MD_SHA512:
  ------------------
  |  Branch (670:9): [True: 0, False: 442]
  ------------------
  671|      0|            return mbedtls_sha512_finish(ctx->md_ctx, output);
  672|      0|#endif
  673|      0|#if defined(MBEDTLS_SHA3_C)
  674|      0|        case MBEDTLS_MD_SHA3_224:
  ------------------
  |  Branch (674:9): [True: 0, False: 442]
  ------------------
  675|      0|        case MBEDTLS_MD_SHA3_256:
  ------------------
  |  Branch (675:9): [True: 0, False: 442]
  ------------------
  676|      0|        case MBEDTLS_MD_SHA3_384:
  ------------------
  |  Branch (676:9): [True: 0, False: 442]
  ------------------
  677|      0|        case MBEDTLS_MD_SHA3_512:
  ------------------
  |  Branch (677:9): [True: 0, False: 442]
  ------------------
  678|      0|            return mbedtls_sha3_finish(ctx->md_ctx, output, ctx->md_info->size);
  679|      0|#endif
  680|      0|        default:
  ------------------
  |  Branch (680:9): [True: 0, False: 442]
  ------------------
  681|      0|            return MBEDTLS_ERR_MD_BAD_INPUT_DATA;
  ------------------
  |  |   26|      0|#define MBEDTLS_ERR_MD_BAD_INPUT_DATA                     -0x5100
  ------------------
  682|    442|    }
  683|    442|}
mbedtls_md_get_size:
  747|    221|{
  748|    221|    if (md_info == NULL) {
  ------------------
  |  Branch (748:9): [True: 0, False: 221]
  ------------------
  749|      0|        return 0;
  750|      0|    }
  751|       |
  752|    221|    return md_info->size;
  753|    221|}
mbedtls_md_hmac_starts:
  970|    221|{
  971|    221|    int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
  ------------------
  |  |  100|    221|#define MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED -0x006E
  ------------------
  972|    221|    unsigned char sum[MBEDTLS_MD_MAX_SIZE];
  973|    221|    unsigned char *ipad, *opad;
  974|       |
  975|    221|    if (ctx == NULL || ctx->md_info == NULL || ctx->hmac_ctx == NULL) {
  ------------------
  |  Branch (975:9): [True: 0, False: 221]
  |  Branch (975:24): [True: 0, False: 221]
  |  Branch (975:48): [True: 0, False: 221]
  ------------------
  976|      0|        return MBEDTLS_ERR_MD_BAD_INPUT_DATA;
  ------------------
  |  |   26|      0|#define MBEDTLS_ERR_MD_BAD_INPUT_DATA                     -0x5100
  ------------------
  977|      0|    }
  978|       |
  979|    221|    if (keylen > (size_t) ctx->md_info->block_size) {
  ------------------
  |  Branch (979:9): [True: 0, False: 221]
  ------------------
  980|      0|        if ((ret = mbedtls_md_starts(ctx)) != 0) {
  ------------------
  |  Branch (980:13): [True: 0, False: 0]
  ------------------
  981|      0|            goto cleanup;
  982|      0|        }
  983|      0|        if ((ret = mbedtls_md_update(ctx, key, keylen)) != 0) {
  ------------------
  |  Branch (983:13): [True: 0, False: 0]
  ------------------
  984|      0|            goto cleanup;
  985|      0|        }
  986|      0|        if ((ret = mbedtls_md_finish(ctx, sum)) != 0) {
  ------------------
  |  Branch (986:13): [True: 0, False: 0]
  ------------------
  987|      0|            goto cleanup;
  988|      0|        }
  989|       |
  990|      0|        keylen = ctx->md_info->size;
  991|      0|        key = sum;
  992|      0|    }
  993|       |
  994|    221|    ipad = (unsigned char *) ctx->hmac_ctx;
  995|    221|    opad = (unsigned char *) ctx->hmac_ctx + ctx->md_info->block_size;
  996|       |
  997|    221|    memset(ipad, 0x36, ctx->md_info->block_size);
  998|    221|    memset(opad, 0x5C, ctx->md_info->block_size);
  999|       |
 1000|    221|    mbedtls_xor(ipad, ipad, key, keylen);
 1001|    221|    mbedtls_xor(opad, opad, key, keylen);
 1002|       |
 1003|    221|    if ((ret = mbedtls_md_starts(ctx)) != 0) {
  ------------------
  |  Branch (1003:9): [True: 0, False: 221]
  ------------------
 1004|      0|        goto cleanup;
 1005|      0|    }
 1006|    221|    if ((ret = mbedtls_md_update(ctx, ipad,
  ------------------
  |  Branch (1006:9): [True: 0, False: 221]
  ------------------
 1007|    221|                                 ctx->md_info->block_size)) != 0) {
 1008|      0|        goto cleanup;
 1009|      0|    }
 1010|       |
 1011|    221|cleanup:
 1012|    221|    mbedtls_platform_zeroize(sum, sizeof(sum));
 1013|       |
 1014|    221|    return ret;
 1015|    221|}
mbedtls_md_hmac_update:
 1018|    663|{
 1019|    663|    if (ctx == NULL || ctx->md_info == NULL || ctx->hmac_ctx == NULL) {
  ------------------
  |  Branch (1019:9): [True: 0, False: 663]
  |  Branch (1019:24): [True: 0, False: 663]
  |  Branch (1019:48): [True: 0, False: 663]
  ------------------
 1020|      0|        return MBEDTLS_ERR_MD_BAD_INPUT_DATA;
  ------------------
  |  |   26|      0|#define MBEDTLS_ERR_MD_BAD_INPUT_DATA                     -0x5100
  ------------------
 1021|      0|    }
 1022|       |
 1023|    663|    return mbedtls_md_update(ctx, input, ilen);
 1024|    663|}
mbedtls_md_hmac_finish:
 1027|    221|{
 1028|    221|    int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
  ------------------
  |  |  100|    221|#define MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED -0x006E
  ------------------
 1029|    221|    unsigned char tmp[MBEDTLS_MD_MAX_SIZE];
 1030|    221|    unsigned char *opad;
 1031|       |
 1032|    221|    if (ctx == NULL || ctx->md_info == NULL || ctx->hmac_ctx == NULL) {
  ------------------
  |  Branch (1032:9): [True: 0, False: 221]
  |  Branch (1032:24): [True: 0, False: 221]
  |  Branch (1032:48): [True: 0, False: 221]
  ------------------
 1033|      0|        return MBEDTLS_ERR_MD_BAD_INPUT_DATA;
  ------------------
  |  |   26|      0|#define MBEDTLS_ERR_MD_BAD_INPUT_DATA                     -0x5100
  ------------------
 1034|      0|    }
 1035|       |
 1036|    221|    opad = (unsigned char *) ctx->hmac_ctx + ctx->md_info->block_size;
 1037|       |
 1038|    221|    if ((ret = mbedtls_md_finish(ctx, tmp)) != 0) {
  ------------------
  |  Branch (1038:9): [True: 0, False: 221]
  ------------------
 1039|      0|        return ret;
 1040|      0|    }
 1041|    221|    if ((ret = mbedtls_md_starts(ctx)) != 0) {
  ------------------
  |  Branch (1041:9): [True: 0, False: 221]
  ------------------
 1042|      0|        return ret;
 1043|      0|    }
 1044|    221|    if ((ret = mbedtls_md_update(ctx, opad,
  ------------------
  |  Branch (1044:9): [True: 0, False: 221]
  ------------------
 1045|    221|                                 ctx->md_info->block_size)) != 0) {
 1046|      0|        return ret;
 1047|      0|    }
 1048|    221|    if ((ret = mbedtls_md_update(ctx, tmp,
  ------------------
  |  Branch (1048:9): [True: 0, False: 221]
  ------------------
 1049|    221|                                 ctx->md_info->size)) != 0) {
 1050|      0|        return ret;
 1051|      0|    }
 1052|    221|    return mbedtls_md_finish(ctx, output);
 1053|    221|}

mbedtls_zeroize_and_free:
  140|    221|{
  141|    221|    if (buf != NULL) {
  ------------------
  |  Branch (141:9): [True: 221, False: 0]
  ------------------
  142|    221|        mbedtls_platform_zeroize(buf, len);
  143|    221|    }
  144|       |
  145|    221|    mbedtls_free(buf);
  ------------------
  |  |  143|    221|#define mbedtls_free       MBEDTLS_PLATFORM_FREE_MACRO
  |  |  ------------------
  |  |  |  | 4095|    221|#define MBEDTLS_PLATFORM_FREE_MACRO            my_free
  |  |  ------------------
  ------------------
  146|    221|}

mbedtls_sha256_init:
  226|    221|{
  227|    221|    memset(ctx, 0, sizeof(mbedtls_sha256_context));
  228|    221|}
mbedtls_sha256_free:
  231|    663|{
  232|    663|    if (ctx == NULL) {
  ------------------
  |  Branch (232:9): [True: 0, False: 663]
  ------------------
  233|      0|        return;
  234|      0|    }
  235|       |
  236|    663|    mbedtls_platform_zeroize(ctx, sizeof(mbedtls_sha256_context));
  237|    663|}
mbedtls_sha256_starts:
  249|    442|{
  250|       |#if defined(MBEDTLS_SHA224_C) && defined(MBEDTLS_SHA256_C)
  251|       |    if (is224 != 0 && is224 != 1) {
  252|       |        return MBEDTLS_ERR_SHA256_BAD_INPUT_DATA;
  253|       |    }
  254|       |#elif defined(MBEDTLS_SHA256_C)
  255|    442|    if (is224 != 0) {
  ------------------
  |  Branch (255:9): [True: 0, False: 442]
  ------------------
  256|      0|        return MBEDTLS_ERR_SHA256_BAD_INPUT_DATA;
  ------------------
  |  |   23|      0|#define MBEDTLS_ERR_SHA256_BAD_INPUT_DATA                 -0x0074
  ------------------
  257|      0|    }
  258|       |#else /* defined MBEDTLS_SHA224_C only */
  259|       |    if (is224 == 0) {
  260|       |        return MBEDTLS_ERR_SHA256_BAD_INPUT_DATA;
  261|       |    }
  262|       |#endif
  263|       |
  264|    442|    ctx->total[0] = 0;
  265|    442|    ctx->total[1] = 0;
  266|       |
  267|    442|    if (is224 == 0) {
  ------------------
  |  Branch (267:9): [True: 442, False: 0]
  ------------------
  268|    442|#if defined(MBEDTLS_SHA256_C)
  269|    442|        ctx->state[0] = 0x6A09E667;
  270|    442|        ctx->state[1] = 0xBB67AE85;
  271|    442|        ctx->state[2] = 0x3C6EF372;
  272|    442|        ctx->state[3] = 0xA54FF53A;
  273|    442|        ctx->state[4] = 0x510E527F;
  274|    442|        ctx->state[5] = 0x9B05688C;
  275|    442|        ctx->state[6] = 0x1F83D9AB;
  276|    442|        ctx->state[7] = 0x5BE0CD19;
  277|    442|#endif
  278|    442|    } else {
  279|       |#if defined(MBEDTLS_SHA224_C)
  280|       |        ctx->state[0] = 0xC1059ED8;
  281|       |        ctx->state[1] = 0x367CD507;
  282|       |        ctx->state[2] = 0x3070DD17;
  283|       |        ctx->state[3] = 0xF70E5939;
  284|       |        ctx->state[4] = 0xFFC00B31;
  285|       |        ctx->state[5] = 0x68581511;
  286|       |        ctx->state[6] = 0x64F98FA7;
  287|       |        ctx->state[7] = 0xBEFA4FA4;
  288|       |#endif
  289|      0|    }
  290|       |
  291|       |#if defined(MBEDTLS_SHA224_C)
  292|       |    ctx->is224 = is224;
  293|       |#endif
  294|       |
  295|    442|    return 0;
  296|    442|}
mbedtls_internal_sha256_process:
  494|    884|{
  495|    884|    struct {
  496|    884|        uint32_t temp1, temp2, W[64];
  497|    884|        uint32_t A[8];
  498|    884|    } local;
  499|       |
  500|    884|    unsigned int i;
  501|       |
  502|  7.95k|    for (i = 0; i < 8; i++) {
  ------------------
  |  Branch (502:17): [True: 7.07k, False: 884]
  ------------------
  503|  7.07k|        local.A[i] = ctx->state[i];
  504|  7.07k|    }
  505|       |
  506|       |#if defined(MBEDTLS_SHA256_SMALLER)
  507|       |    for (i = 0; i < 64; i++) {
  508|       |        if (i < 16) {
  509|       |            local.W[i] = MBEDTLS_GET_UINT32_BE(data, 4 * i);
  510|       |        } else {
  511|       |            R(i);
  512|       |        }
  513|       |
  514|       |        P(local.A[0], local.A[1], local.A[2], local.A[3], local.A[4],
  515|       |          local.A[5], local.A[6], local.A[7], local.W[i], K[i]);
  516|       |
  517|       |        local.temp1 = local.A[7]; local.A[7] = local.A[6];
  518|       |        local.A[6] = local.A[5]; local.A[5] = local.A[4];
  519|       |        local.A[4] = local.A[3]; local.A[3] = local.A[2];
  520|       |        local.A[2] = local.A[1]; local.A[1] = local.A[0];
  521|       |        local.A[0] = local.temp1;
  522|       |    }
  523|       |#else /* MBEDTLS_SHA256_SMALLER */
  524|  15.0k|    for (i = 0; i < 16; i++) {
  ------------------
  |  Branch (524:17): [True: 14.1k, False: 884]
  ------------------
  525|  14.1k|        local.W[i] = MBEDTLS_GET_UINT32_BE(data, 4 * i);
  ------------------
  |  |  413|  14.1k|    ((MBEDTLS_IS_BIG_ENDIAN)                                               \
  |  |  ------------------
  |  |  |  |  398|  14.1k|#define MBEDTLS_IS_BIG_ENDIAN 0
  |  |  ------------------
  |  |  |  Branch (413:6): [Folded - Ignored]
  |  |  ------------------
  |  |  414|  14.1k|        ? mbedtls_get_unaligned_uint32((data) + (offset))                  \
  |  |  415|  14.1k|        : MBEDTLS_BSWAP32(mbedtls_get_unaligned_uint32((data) + (offset))) \
  |  |  ------------------
  |  |  |  |  298|  14.1k|#define MBEDTLS_BSWAP32 __builtin_bswap32
  |  |  ------------------
  |  |  416|  14.1k|    )
  ------------------
  526|  14.1k|    }
  527|       |
  528|  2.65k|    for (i = 0; i < 16; i += 8) {
  ------------------
  |  Branch (528:17): [True: 1.76k, False: 884]
  ------------------
  529|  1.76k|        P(local.A[0], local.A[1], local.A[2], local.A[3], local.A[4],
  ------------------
  |  |  478|  1.76k|    do                                                              \
  |  |  479|  1.76k|    {                                                               \
  |  |  480|  1.76k|        local.temp1 = (h) + S3(e) + F1((e), (f), (g)) + (K) + (x);    \
  |  |  ------------------
  |  |  |  |  466|  1.76k|#define S3(x) (ROTR(x, 6) ^ ROTR(x, 11) ^ ROTR(x, 25))
  |  |  |  |  ------------------
  |  |  |  |  |  |  460|  1.76k|#define ROTR(x, n) (SHR(x, n) | ((x) << (32 - (n))))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  459|  1.76k|#define  SHR(x, n) (((x) & 0xFFFFFFFF) >> (n))
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define S3(x) (ROTR(x, 6) ^ ROTR(x, 11) ^ ROTR(x, 25))
  |  |  |  |  ------------------
  |  |  |  |  |  |  460|  1.76k|#define ROTR(x, n) (SHR(x, n) | ((x) << (32 - (n))))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  459|  1.76k|#define  SHR(x, n) (((x) & 0xFFFFFFFF) >> (n))
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define S3(x) (ROTR(x, 6) ^ ROTR(x, 11) ^ ROTR(x, 25))
  |  |  |  |  ------------------
  |  |  |  |  |  |  460|  1.76k|#define ROTR(x, n) (SHR(x, n) | ((x) << (32 - (n))))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  459|  1.76k|#define  SHR(x, n) (((x) & 0xFFFFFFFF) >> (n))
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                       local.temp1 = (h) + S3(e) + F1((e), (f), (g)) + (K) + (x);    \
  |  |  ------------------
  |  |  |  |  469|  1.76k|#define F1(x, y, z) ((z) ^ ((x) & ((y) ^ (z))))
  |  |  ------------------
  |  |  481|  1.76k|        local.temp2 = S2(a) + F0((a), (b), (c));                      \
  |  |  ------------------
  |  |  |  |  465|  1.76k|#define S2(x) (ROTR(x, 2) ^ ROTR(x, 13) ^ ROTR(x, 22))
  |  |  |  |  ------------------
  |  |  |  |  |  |  460|  1.76k|#define ROTR(x, n) (SHR(x, n) | ((x) << (32 - (n))))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  459|  1.76k|#define  SHR(x, n) (((x) & 0xFFFFFFFF) >> (n))
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define S2(x) (ROTR(x, 2) ^ ROTR(x, 13) ^ ROTR(x, 22))
  |  |  |  |  ------------------
  |  |  |  |  |  |  460|  1.76k|#define ROTR(x, n) (SHR(x, n) | ((x) << (32 - (n))))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  459|  1.76k|#define  SHR(x, n) (((x) & 0xFFFFFFFF) >> (n))
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define S2(x) (ROTR(x, 2) ^ ROTR(x, 13) ^ ROTR(x, 22))
  |  |  |  |  ------------------
  |  |  |  |  |  |  460|  1.76k|#define ROTR(x, n) (SHR(x, n) | ((x) << (32 - (n))))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  459|  1.76k|#define  SHR(x, n) (((x) & 0xFFFFFFFF) >> (n))
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                       local.temp2 = S2(a) + F0((a), (b), (c));                      \
  |  |  ------------------
  |  |  |  |  468|  1.76k|#define F0(x, y, z) (((x) & (y)) | ((z) & ((x) | (y))))
  |  |  ------------------
  |  |  482|  1.76k|        (d) += local.temp1; (h) = local.temp1 + local.temp2;        \
  |  |  483|  1.76k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (483:14): [Folded - Ignored]
  |  |  ------------------
  ------------------
  530|  1.76k|          local.A[5], local.A[6], local.A[7], local.W[i+0], K[i+0]);
  531|  1.76k|        P(local.A[7], local.A[0], local.A[1], local.A[2], local.A[3],
  ------------------
  |  |  478|  1.76k|    do                                                              \
  |  |  479|  1.76k|    {                                                               \
  |  |  480|  1.76k|        local.temp1 = (h) + S3(e) + F1((e), (f), (g)) + (K) + (x);    \
  |  |  ------------------
  |  |  |  |  466|  1.76k|#define S3(x) (ROTR(x, 6) ^ ROTR(x, 11) ^ ROTR(x, 25))
  |  |  |  |  ------------------
  |  |  |  |  |  |  460|  1.76k|#define ROTR(x, n) (SHR(x, n) | ((x) << (32 - (n))))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  459|  1.76k|#define  SHR(x, n) (((x) & 0xFFFFFFFF) >> (n))
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define S3(x) (ROTR(x, 6) ^ ROTR(x, 11) ^ ROTR(x, 25))
  |  |  |  |  ------------------
  |  |  |  |  |  |  460|  1.76k|#define ROTR(x, n) (SHR(x, n) | ((x) << (32 - (n))))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  459|  1.76k|#define  SHR(x, n) (((x) & 0xFFFFFFFF) >> (n))
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define S3(x) (ROTR(x, 6) ^ ROTR(x, 11) ^ ROTR(x, 25))
  |  |  |  |  ------------------
  |  |  |  |  |  |  460|  1.76k|#define ROTR(x, n) (SHR(x, n) | ((x) << (32 - (n))))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  459|  1.76k|#define  SHR(x, n) (((x) & 0xFFFFFFFF) >> (n))
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                       local.temp1 = (h) + S3(e) + F1((e), (f), (g)) + (K) + (x);    \
  |  |  ------------------
  |  |  |  |  469|  1.76k|#define F1(x, y, z) ((z) ^ ((x) & ((y) ^ (z))))
  |  |  ------------------
  |  |  481|  1.76k|        local.temp2 = S2(a) + F0((a), (b), (c));                      \
  |  |  ------------------
  |  |  |  |  465|  1.76k|#define S2(x) (ROTR(x, 2) ^ ROTR(x, 13) ^ ROTR(x, 22))
  |  |  |  |  ------------------
  |  |  |  |  |  |  460|  1.76k|#define ROTR(x, n) (SHR(x, n) | ((x) << (32 - (n))))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  459|  1.76k|#define  SHR(x, n) (((x) & 0xFFFFFFFF) >> (n))
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define S2(x) (ROTR(x, 2) ^ ROTR(x, 13) ^ ROTR(x, 22))
  |  |  |  |  ------------------
  |  |  |  |  |  |  460|  1.76k|#define ROTR(x, n) (SHR(x, n) | ((x) << (32 - (n))))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  459|  1.76k|#define  SHR(x, n) (((x) & 0xFFFFFFFF) >> (n))
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define S2(x) (ROTR(x, 2) ^ ROTR(x, 13) ^ ROTR(x, 22))
  |  |  |  |  ------------------
  |  |  |  |  |  |  460|  1.76k|#define ROTR(x, n) (SHR(x, n) | ((x) << (32 - (n))))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  459|  1.76k|#define  SHR(x, n) (((x) & 0xFFFFFFFF) >> (n))
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                       local.temp2 = S2(a) + F0((a), (b), (c));                      \
  |  |  ------------------
  |  |  |  |  468|  1.76k|#define F0(x, y, z) (((x) & (y)) | ((z) & ((x) | (y))))
  |  |  ------------------
  |  |  482|  1.76k|        (d) += local.temp1; (h) = local.temp1 + local.temp2;        \
  |  |  483|  1.76k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (483:14): [Folded - Ignored]
  |  |  ------------------
  ------------------
  532|  1.76k|          local.A[4], local.A[5], local.A[6], local.W[i+1], K[i+1]);
  533|  1.76k|        P(local.A[6], local.A[7], local.A[0], local.A[1], local.A[2],
  ------------------
  |  |  478|  1.76k|    do                                                              \
  |  |  479|  1.76k|    {                                                               \
  |  |  480|  1.76k|        local.temp1 = (h) + S3(e) + F1((e), (f), (g)) + (K) + (x);    \
  |  |  ------------------
  |  |  |  |  466|  1.76k|#define S3(x) (ROTR(x, 6) ^ ROTR(x, 11) ^ ROTR(x, 25))
  |  |  |  |  ------------------
  |  |  |  |  |  |  460|  1.76k|#define ROTR(x, n) (SHR(x, n) | ((x) << (32 - (n))))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  459|  1.76k|#define  SHR(x, n) (((x) & 0xFFFFFFFF) >> (n))
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define S3(x) (ROTR(x, 6) ^ ROTR(x, 11) ^ ROTR(x, 25))
  |  |  |  |  ------------------
  |  |  |  |  |  |  460|  1.76k|#define ROTR(x, n) (SHR(x, n) | ((x) << (32 - (n))))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  459|  1.76k|#define  SHR(x, n) (((x) & 0xFFFFFFFF) >> (n))
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define S3(x) (ROTR(x, 6) ^ ROTR(x, 11) ^ ROTR(x, 25))
  |  |  |  |  ------------------
  |  |  |  |  |  |  460|  1.76k|#define ROTR(x, n) (SHR(x, n) | ((x) << (32 - (n))))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  459|  1.76k|#define  SHR(x, n) (((x) & 0xFFFFFFFF) >> (n))
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                       local.temp1 = (h) + S3(e) + F1((e), (f), (g)) + (K) + (x);    \
  |  |  ------------------
  |  |  |  |  469|  1.76k|#define F1(x, y, z) ((z) ^ ((x) & ((y) ^ (z))))
  |  |  ------------------
  |  |  481|  1.76k|        local.temp2 = S2(a) + F0((a), (b), (c));                      \
  |  |  ------------------
  |  |  |  |  465|  1.76k|#define S2(x) (ROTR(x, 2) ^ ROTR(x, 13) ^ ROTR(x, 22))
  |  |  |  |  ------------------
  |  |  |  |  |  |  460|  1.76k|#define ROTR(x, n) (SHR(x, n) | ((x) << (32 - (n))))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  459|  1.76k|#define  SHR(x, n) (((x) & 0xFFFFFFFF) >> (n))
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define S2(x) (ROTR(x, 2) ^ ROTR(x, 13) ^ ROTR(x, 22))
  |  |  |  |  ------------------
  |  |  |  |  |  |  460|  1.76k|#define ROTR(x, n) (SHR(x, n) | ((x) << (32 - (n))))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  459|  1.76k|#define  SHR(x, n) (((x) & 0xFFFFFFFF) >> (n))
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define S2(x) (ROTR(x, 2) ^ ROTR(x, 13) ^ ROTR(x, 22))
  |  |  |  |  ------------------
  |  |  |  |  |  |  460|  1.76k|#define ROTR(x, n) (SHR(x, n) | ((x) << (32 - (n))))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  459|  1.76k|#define  SHR(x, n) (((x) & 0xFFFFFFFF) >> (n))
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                       local.temp2 = S2(a) + F0((a), (b), (c));                      \
  |  |  ------------------
  |  |  |  |  468|  1.76k|#define F0(x, y, z) (((x) & (y)) | ((z) & ((x) | (y))))
  |  |  ------------------
  |  |  482|  1.76k|        (d) += local.temp1; (h) = local.temp1 + local.temp2;        \
  |  |  483|  1.76k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (483:14): [Folded - Ignored]
  |  |  ------------------
  ------------------
  534|  1.76k|          local.A[3], local.A[4], local.A[5], local.W[i+2], K[i+2]);
  535|  1.76k|        P(local.A[5], local.A[6], local.A[7], local.A[0], local.A[1],
  ------------------
  |  |  478|  1.76k|    do                                                              \
  |  |  479|  1.76k|    {                                                               \
  |  |  480|  1.76k|        local.temp1 = (h) + S3(e) + F1((e), (f), (g)) + (K) + (x);    \
  |  |  ------------------
  |  |  |  |  466|  1.76k|#define S3(x) (ROTR(x, 6) ^ ROTR(x, 11) ^ ROTR(x, 25))
  |  |  |  |  ------------------
  |  |  |  |  |  |  460|  1.76k|#define ROTR(x, n) (SHR(x, n) | ((x) << (32 - (n))))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  459|  1.76k|#define  SHR(x, n) (((x) & 0xFFFFFFFF) >> (n))
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define S3(x) (ROTR(x, 6) ^ ROTR(x, 11) ^ ROTR(x, 25))
  |  |  |  |  ------------------
  |  |  |  |  |  |  460|  1.76k|#define ROTR(x, n) (SHR(x, n) | ((x) << (32 - (n))))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  459|  1.76k|#define  SHR(x, n) (((x) & 0xFFFFFFFF) >> (n))
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define S3(x) (ROTR(x, 6) ^ ROTR(x, 11) ^ ROTR(x, 25))
  |  |  |  |  ------------------
  |  |  |  |  |  |  460|  1.76k|#define ROTR(x, n) (SHR(x, n) | ((x) << (32 - (n))))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  459|  1.76k|#define  SHR(x, n) (((x) & 0xFFFFFFFF) >> (n))
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                       local.temp1 = (h) + S3(e) + F1((e), (f), (g)) + (K) + (x);    \
  |  |  ------------------
  |  |  |  |  469|  1.76k|#define F1(x, y, z) ((z) ^ ((x) & ((y) ^ (z))))
  |  |  ------------------
  |  |  481|  1.76k|        local.temp2 = S2(a) + F0((a), (b), (c));                      \
  |  |  ------------------
  |  |  |  |  465|  1.76k|#define S2(x) (ROTR(x, 2) ^ ROTR(x, 13) ^ ROTR(x, 22))
  |  |  |  |  ------------------
  |  |  |  |  |  |  460|  1.76k|#define ROTR(x, n) (SHR(x, n) | ((x) << (32 - (n))))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  459|  1.76k|#define  SHR(x, n) (((x) & 0xFFFFFFFF) >> (n))
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define S2(x) (ROTR(x, 2) ^ ROTR(x, 13) ^ ROTR(x, 22))
  |  |  |  |  ------------------
  |  |  |  |  |  |  460|  1.76k|#define ROTR(x, n) (SHR(x, n) | ((x) << (32 - (n))))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  459|  1.76k|#define  SHR(x, n) (((x) & 0xFFFFFFFF) >> (n))
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define S2(x) (ROTR(x, 2) ^ ROTR(x, 13) ^ ROTR(x, 22))
  |  |  |  |  ------------------
  |  |  |  |  |  |  460|  1.76k|#define ROTR(x, n) (SHR(x, n) | ((x) << (32 - (n))))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  459|  1.76k|#define  SHR(x, n) (((x) & 0xFFFFFFFF) >> (n))
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                       local.temp2 = S2(a) + F0((a), (b), (c));                      \
  |  |  ------------------
  |  |  |  |  468|  1.76k|#define F0(x, y, z) (((x) & (y)) | ((z) & ((x) | (y))))
  |  |  ------------------
  |  |  482|  1.76k|        (d) += local.temp1; (h) = local.temp1 + local.temp2;        \
  |  |  483|  1.76k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (483:14): [Folded - Ignored]
  |  |  ------------------
  ------------------
  536|  1.76k|          local.A[2], local.A[3], local.A[4], local.W[i+3], K[i+3]);
  537|  1.76k|        P(local.A[4], local.A[5], local.A[6], local.A[7], local.A[0],
  ------------------
  |  |  478|  1.76k|    do                                                              \
  |  |  479|  1.76k|    {                                                               \
  |  |  480|  1.76k|        local.temp1 = (h) + S3(e) + F1((e), (f), (g)) + (K) + (x);    \
  |  |  ------------------
  |  |  |  |  466|  1.76k|#define S3(x) (ROTR(x, 6) ^ ROTR(x, 11) ^ ROTR(x, 25))
  |  |  |  |  ------------------
  |  |  |  |  |  |  460|  1.76k|#define ROTR(x, n) (SHR(x, n) | ((x) << (32 - (n))))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  459|  1.76k|#define  SHR(x, n) (((x) & 0xFFFFFFFF) >> (n))
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define S3(x) (ROTR(x, 6) ^ ROTR(x, 11) ^ ROTR(x, 25))
  |  |  |  |  ------------------
  |  |  |  |  |  |  460|  1.76k|#define ROTR(x, n) (SHR(x, n) | ((x) << (32 - (n))))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  459|  1.76k|#define  SHR(x, n) (((x) & 0xFFFFFFFF) >> (n))
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define S3(x) (ROTR(x, 6) ^ ROTR(x, 11) ^ ROTR(x, 25))
  |  |  |  |  ------------------
  |  |  |  |  |  |  460|  1.76k|#define ROTR(x, n) (SHR(x, n) | ((x) << (32 - (n))))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  459|  1.76k|#define  SHR(x, n) (((x) & 0xFFFFFFFF) >> (n))
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                       local.temp1 = (h) + S3(e) + F1((e), (f), (g)) + (K) + (x);    \
  |  |  ------------------
  |  |  |  |  469|  1.76k|#define F1(x, y, z) ((z) ^ ((x) & ((y) ^ (z))))
  |  |  ------------------
  |  |  481|  1.76k|        local.temp2 = S2(a) + F0((a), (b), (c));                      \
  |  |  ------------------
  |  |  |  |  465|  1.76k|#define S2(x) (ROTR(x, 2) ^ ROTR(x, 13) ^ ROTR(x, 22))
  |  |  |  |  ------------------
  |  |  |  |  |  |  460|  1.76k|#define ROTR(x, n) (SHR(x, n) | ((x) << (32 - (n))))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  459|  1.76k|#define  SHR(x, n) (((x) & 0xFFFFFFFF) >> (n))
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define S2(x) (ROTR(x, 2) ^ ROTR(x, 13) ^ ROTR(x, 22))
  |  |  |  |  ------------------
  |  |  |  |  |  |  460|  1.76k|#define ROTR(x, n) (SHR(x, n) | ((x) << (32 - (n))))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  459|  1.76k|#define  SHR(x, n) (((x) & 0xFFFFFFFF) >> (n))
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define S2(x) (ROTR(x, 2) ^ ROTR(x, 13) ^ ROTR(x, 22))
  |  |  |  |  ------------------
  |  |  |  |  |  |  460|  1.76k|#define ROTR(x, n) (SHR(x, n) | ((x) << (32 - (n))))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  459|  1.76k|#define  SHR(x, n) (((x) & 0xFFFFFFFF) >> (n))
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                       local.temp2 = S2(a) + F0((a), (b), (c));                      \
  |  |  ------------------
  |  |  |  |  468|  1.76k|#define F0(x, y, z) (((x) & (y)) | ((z) & ((x) | (y))))
  |  |  ------------------
  |  |  482|  1.76k|        (d) += local.temp1; (h) = local.temp1 + local.temp2;        \
  |  |  483|  1.76k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (483:14): [Folded - Ignored]
  |  |  ------------------
  ------------------
  538|  1.76k|          local.A[1], local.A[2], local.A[3], local.W[i+4], K[i+4]);
  539|  1.76k|        P(local.A[3], local.A[4], local.A[5], local.A[6], local.A[7],
  ------------------
  |  |  478|  1.76k|    do                                                              \
  |  |  479|  1.76k|    {                                                               \
  |  |  480|  1.76k|        local.temp1 = (h) + S3(e) + F1((e), (f), (g)) + (K) + (x);    \
  |  |  ------------------
  |  |  |  |  466|  1.76k|#define S3(x) (ROTR(x, 6) ^ ROTR(x, 11) ^ ROTR(x, 25))
  |  |  |  |  ------------------
  |  |  |  |  |  |  460|  1.76k|#define ROTR(x, n) (SHR(x, n) | ((x) << (32 - (n))))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  459|  1.76k|#define  SHR(x, n) (((x) & 0xFFFFFFFF) >> (n))
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define S3(x) (ROTR(x, 6) ^ ROTR(x, 11) ^ ROTR(x, 25))
  |  |  |  |  ------------------
  |  |  |  |  |  |  460|  1.76k|#define ROTR(x, n) (SHR(x, n) | ((x) << (32 - (n))))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  459|  1.76k|#define  SHR(x, n) (((x) & 0xFFFFFFFF) >> (n))
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define S3(x) (ROTR(x, 6) ^ ROTR(x, 11) ^ ROTR(x, 25))
  |  |  |  |  ------------------
  |  |  |  |  |  |  460|  1.76k|#define ROTR(x, n) (SHR(x, n) | ((x) << (32 - (n))))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  459|  1.76k|#define  SHR(x, n) (((x) & 0xFFFFFFFF) >> (n))
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                       local.temp1 = (h) + S3(e) + F1((e), (f), (g)) + (K) + (x);    \
  |  |  ------------------
  |  |  |  |  469|  1.76k|#define F1(x, y, z) ((z) ^ ((x) & ((y) ^ (z))))
  |  |  ------------------
  |  |  481|  1.76k|        local.temp2 = S2(a) + F0((a), (b), (c));                      \
  |  |  ------------------
  |  |  |  |  465|  1.76k|#define S2(x) (ROTR(x, 2) ^ ROTR(x, 13) ^ ROTR(x, 22))
  |  |  |  |  ------------------
  |  |  |  |  |  |  460|  1.76k|#define ROTR(x, n) (SHR(x, n) | ((x) << (32 - (n))))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  459|  1.76k|#define  SHR(x, n) (((x) & 0xFFFFFFFF) >> (n))
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define S2(x) (ROTR(x, 2) ^ ROTR(x, 13) ^ ROTR(x, 22))
  |  |  |  |  ------------------
  |  |  |  |  |  |  460|  1.76k|#define ROTR(x, n) (SHR(x, n) | ((x) << (32 - (n))))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  459|  1.76k|#define  SHR(x, n) (((x) & 0xFFFFFFFF) >> (n))
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define S2(x) (ROTR(x, 2) ^ ROTR(x, 13) ^ ROTR(x, 22))
  |  |  |  |  ------------------
  |  |  |  |  |  |  460|  1.76k|#define ROTR(x, n) (SHR(x, n) | ((x) << (32 - (n))))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  459|  1.76k|#define  SHR(x, n) (((x) & 0xFFFFFFFF) >> (n))
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                       local.temp2 = S2(a) + F0((a), (b), (c));                      \
  |  |  ------------------
  |  |  |  |  468|  1.76k|#define F0(x, y, z) (((x) & (y)) | ((z) & ((x) | (y))))
  |  |  ------------------
  |  |  482|  1.76k|        (d) += local.temp1; (h) = local.temp1 + local.temp2;        \
  |  |  483|  1.76k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (483:14): [Folded - Ignored]
  |  |  ------------------
  ------------------
  540|  1.76k|          local.A[0], local.A[1], local.A[2], local.W[i+5], K[i+5]);
  541|  1.76k|        P(local.A[2], local.A[3], local.A[4], local.A[5], local.A[6],
  ------------------
  |  |  478|  1.76k|    do                                                              \
  |  |  479|  1.76k|    {                                                               \
  |  |  480|  1.76k|        local.temp1 = (h) + S3(e) + F1((e), (f), (g)) + (K) + (x);    \
  |  |  ------------------
  |  |  |  |  466|  1.76k|#define S3(x) (ROTR(x, 6) ^ ROTR(x, 11) ^ ROTR(x, 25))
  |  |  |  |  ------------------
  |  |  |  |  |  |  460|  1.76k|#define ROTR(x, n) (SHR(x, n) | ((x) << (32 - (n))))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  459|  1.76k|#define  SHR(x, n) (((x) & 0xFFFFFFFF) >> (n))
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define S3(x) (ROTR(x, 6) ^ ROTR(x, 11) ^ ROTR(x, 25))
  |  |  |  |  ------------------
  |  |  |  |  |  |  460|  1.76k|#define ROTR(x, n) (SHR(x, n) | ((x) << (32 - (n))))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  459|  1.76k|#define  SHR(x, n) (((x) & 0xFFFFFFFF) >> (n))
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define S3(x) (ROTR(x, 6) ^ ROTR(x, 11) ^ ROTR(x, 25))
  |  |  |  |  ------------------
  |  |  |  |  |  |  460|  1.76k|#define ROTR(x, n) (SHR(x, n) | ((x) << (32 - (n))))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  459|  1.76k|#define  SHR(x, n) (((x) & 0xFFFFFFFF) >> (n))
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                       local.temp1 = (h) + S3(e) + F1((e), (f), (g)) + (K) + (x);    \
  |  |  ------------------
  |  |  |  |  469|  1.76k|#define F1(x, y, z) ((z) ^ ((x) & ((y) ^ (z))))
  |  |  ------------------
  |  |  481|  1.76k|        local.temp2 = S2(a) + F0((a), (b), (c));                      \
  |  |  ------------------
  |  |  |  |  465|  1.76k|#define S2(x) (ROTR(x, 2) ^ ROTR(x, 13) ^ ROTR(x, 22))
  |  |  |  |  ------------------
  |  |  |  |  |  |  460|  1.76k|#define ROTR(x, n) (SHR(x, n) | ((x) << (32 - (n))))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  459|  1.76k|#define  SHR(x, n) (((x) & 0xFFFFFFFF) >> (n))
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define S2(x) (ROTR(x, 2) ^ ROTR(x, 13) ^ ROTR(x, 22))
  |  |  |  |  ------------------
  |  |  |  |  |  |  460|  1.76k|#define ROTR(x, n) (SHR(x, n) | ((x) << (32 - (n))))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  459|  1.76k|#define  SHR(x, n) (((x) & 0xFFFFFFFF) >> (n))
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define S2(x) (ROTR(x, 2) ^ ROTR(x, 13) ^ ROTR(x, 22))
  |  |  |  |  ------------------
  |  |  |  |  |  |  460|  1.76k|#define ROTR(x, n) (SHR(x, n) | ((x) << (32 - (n))))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  459|  1.76k|#define  SHR(x, n) (((x) & 0xFFFFFFFF) >> (n))
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                       local.temp2 = S2(a) + F0((a), (b), (c));                      \
  |  |  ------------------
  |  |  |  |  468|  1.76k|#define F0(x, y, z) (((x) & (y)) | ((z) & ((x) | (y))))
  |  |  ------------------
  |  |  482|  1.76k|        (d) += local.temp1; (h) = local.temp1 + local.temp2;        \
  |  |  483|  1.76k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (483:14): [Folded - Ignored]
  |  |  ------------------
  ------------------
  542|  1.76k|          local.A[7], local.A[0], local.A[1], local.W[i+6], K[i+6]);
  543|  1.76k|        P(local.A[1], local.A[2], local.A[3], local.A[4], local.A[5],
  ------------------
  |  |  478|  1.76k|    do                                                              \
  |  |  479|  1.76k|    {                                                               \
  |  |  480|  1.76k|        local.temp1 = (h) + S3(e) + F1((e), (f), (g)) + (K) + (x);    \
  |  |  ------------------
  |  |  |  |  466|  1.76k|#define S3(x) (ROTR(x, 6) ^ ROTR(x, 11) ^ ROTR(x, 25))
  |  |  |  |  ------------------
  |  |  |  |  |  |  460|  1.76k|#define ROTR(x, n) (SHR(x, n) | ((x) << (32 - (n))))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  459|  1.76k|#define  SHR(x, n) (((x) & 0xFFFFFFFF) >> (n))
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define S3(x) (ROTR(x, 6) ^ ROTR(x, 11) ^ ROTR(x, 25))
  |  |  |  |  ------------------
  |  |  |  |  |  |  460|  1.76k|#define ROTR(x, n) (SHR(x, n) | ((x) << (32 - (n))))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  459|  1.76k|#define  SHR(x, n) (((x) & 0xFFFFFFFF) >> (n))
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define S3(x) (ROTR(x, 6) ^ ROTR(x, 11) ^ ROTR(x, 25))
  |  |  |  |  ------------------
  |  |  |  |  |  |  460|  1.76k|#define ROTR(x, n) (SHR(x, n) | ((x) << (32 - (n))))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  459|  1.76k|#define  SHR(x, n) (((x) & 0xFFFFFFFF) >> (n))
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                       local.temp1 = (h) + S3(e) + F1((e), (f), (g)) + (K) + (x);    \
  |  |  ------------------
  |  |  |  |  469|  1.76k|#define F1(x, y, z) ((z) ^ ((x) & ((y) ^ (z))))
  |  |  ------------------
  |  |  481|  1.76k|        local.temp2 = S2(a) + F0((a), (b), (c));                      \
  |  |  ------------------
  |  |  |  |  465|  1.76k|#define S2(x) (ROTR(x, 2) ^ ROTR(x, 13) ^ ROTR(x, 22))
  |  |  |  |  ------------------
  |  |  |  |  |  |  460|  1.76k|#define ROTR(x, n) (SHR(x, n) | ((x) << (32 - (n))))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  459|  1.76k|#define  SHR(x, n) (((x) & 0xFFFFFFFF) >> (n))
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define S2(x) (ROTR(x, 2) ^ ROTR(x, 13) ^ ROTR(x, 22))
  |  |  |  |  ------------------
  |  |  |  |  |  |  460|  1.76k|#define ROTR(x, n) (SHR(x, n) | ((x) << (32 - (n))))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  459|  1.76k|#define  SHR(x, n) (((x) & 0xFFFFFFFF) >> (n))
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define S2(x) (ROTR(x, 2) ^ ROTR(x, 13) ^ ROTR(x, 22))
  |  |  |  |  ------------------
  |  |  |  |  |  |  460|  1.76k|#define ROTR(x, n) (SHR(x, n) | ((x) << (32 - (n))))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  459|  1.76k|#define  SHR(x, n) (((x) & 0xFFFFFFFF) >> (n))
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                       local.temp2 = S2(a) + F0((a), (b), (c));                      \
  |  |  ------------------
  |  |  |  |  468|  1.76k|#define F0(x, y, z) (((x) & (y)) | ((z) & ((x) | (y))))
  |  |  ------------------
  |  |  482|  1.76k|        (d) += local.temp1; (h) = local.temp1 + local.temp2;        \
  |  |  483|  1.76k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (483:14): [Folded - Ignored]
  |  |  ------------------
  ------------------
  544|  1.76k|          local.A[6], local.A[7], local.A[0], local.W[i+7], K[i+7]);
  545|  1.76k|    }
  546|       |
  547|  6.18k|    for (i = 16; i < 64; i += 8) {
  ------------------
  |  Branch (547:18): [True: 5.30k, False: 884]
  ------------------
  548|  5.30k|        P(local.A[0], local.A[1], local.A[2], local.A[3], local.A[4],
  ------------------
  |  |  478|  5.30k|    do                                                              \
  |  |  479|  5.30k|    {                                                               \
  |  |  480|  5.30k|        local.temp1 = (h) + S3(e) + F1((e), (f), (g)) + (K) + (x);    \
  |  |  ------------------
  |  |  |  |  466|  5.30k|#define S3(x) (ROTR(x, 6) ^ ROTR(x, 11) ^ ROTR(x, 25))
  |  |  |  |  ------------------
  |  |  |  |  |  |  460|  5.30k|#define ROTR(x, n) (SHR(x, n) | ((x) << (32 - (n))))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  459|  5.30k|#define  SHR(x, n) (((x) & 0xFFFFFFFF) >> (n))
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define S3(x) (ROTR(x, 6) ^ ROTR(x, 11) ^ ROTR(x, 25))
  |  |  |  |  ------------------
  |  |  |  |  |  |  460|  5.30k|#define ROTR(x, n) (SHR(x, n) | ((x) << (32 - (n))))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  459|  5.30k|#define  SHR(x, n) (((x) & 0xFFFFFFFF) >> (n))
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define S3(x) (ROTR(x, 6) ^ ROTR(x, 11) ^ ROTR(x, 25))
  |  |  |  |  ------------------
  |  |  |  |  |  |  460|  5.30k|#define ROTR(x, n) (SHR(x, n) | ((x) << (32 - (n))))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  459|  5.30k|#define  SHR(x, n) (((x) & 0xFFFFFFFF) >> (n))
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                       local.temp1 = (h) + S3(e) + F1((e), (f), (g)) + (K) + (x);    \
  |  |  ------------------
  |  |  |  |  469|  5.30k|#define F1(x, y, z) ((z) ^ ((x) & ((y) ^ (z))))
  |  |  ------------------
  |  |  481|  5.30k|        local.temp2 = S2(a) + F0((a), (b), (c));                      \
  |  |  ------------------
  |  |  |  |  465|  5.30k|#define S2(x) (ROTR(x, 2) ^ ROTR(x, 13) ^ ROTR(x, 22))
  |  |  |  |  ------------------
  |  |  |  |  |  |  460|  5.30k|#define ROTR(x, n) (SHR(x, n) | ((x) << (32 - (n))))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  459|  5.30k|#define  SHR(x, n) (((x) & 0xFFFFFFFF) >> (n))
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define S2(x) (ROTR(x, 2) ^ ROTR(x, 13) ^ ROTR(x, 22))
  |  |  |  |  ------------------
  |  |  |  |  |  |  460|  5.30k|#define ROTR(x, n) (SHR(x, n) | ((x) << (32 - (n))))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  459|  5.30k|#define  SHR(x, n) (((x) & 0xFFFFFFFF) >> (n))
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define S2(x) (ROTR(x, 2) ^ ROTR(x, 13) ^ ROTR(x, 22))
  |  |  |  |  ------------------
  |  |  |  |  |  |  460|  5.30k|#define ROTR(x, n) (SHR(x, n) | ((x) << (32 - (n))))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  459|  5.30k|#define  SHR(x, n) (((x) & 0xFFFFFFFF) >> (n))
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                       local.temp2 = S2(a) + F0((a), (b), (c));                      \
  |  |  ------------------
  |  |  |  |  468|  5.30k|#define F0(x, y, z) (((x) & (y)) | ((z) & ((x) | (y))))
  |  |  ------------------
  |  |  482|  5.30k|        (d) += local.temp1; (h) = local.temp1 + local.temp2;        \
  |  |  483|  5.30k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (483:14): [Folded - Ignored]
  |  |  ------------------
  ------------------
  549|  5.30k|          local.A[5], local.A[6], local.A[7], R(i+0), K[i+0]);
  550|  5.30k|        P(local.A[7], local.A[0], local.A[1], local.A[2], local.A[3],
  ------------------
  |  |  478|  5.30k|    do                                                              \
  |  |  479|  5.30k|    {                                                               \
  |  |  480|  5.30k|        local.temp1 = (h) + S3(e) + F1((e), (f), (g)) + (K) + (x);    \
  |  |  ------------------
  |  |  |  |  466|  5.30k|#define S3(x) (ROTR(x, 6) ^ ROTR(x, 11) ^ ROTR(x, 25))
  |  |  |  |  ------------------
  |  |  |  |  |  |  460|  5.30k|#define ROTR(x, n) (SHR(x, n) | ((x) << (32 - (n))))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  459|  5.30k|#define  SHR(x, n) (((x) & 0xFFFFFFFF) >> (n))
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define S3(x) (ROTR(x, 6) ^ ROTR(x, 11) ^ ROTR(x, 25))
  |  |  |  |  ------------------
  |  |  |  |  |  |  460|  5.30k|#define ROTR(x, n) (SHR(x, n) | ((x) << (32 - (n))))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  459|  5.30k|#define  SHR(x, n) (((x) & 0xFFFFFFFF) >> (n))
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define S3(x) (ROTR(x, 6) ^ ROTR(x, 11) ^ ROTR(x, 25))
  |  |  |  |  ------------------
  |  |  |  |  |  |  460|  5.30k|#define ROTR(x, n) (SHR(x, n) | ((x) << (32 - (n))))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  459|  5.30k|#define  SHR(x, n) (((x) & 0xFFFFFFFF) >> (n))
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                       local.temp1 = (h) + S3(e) + F1((e), (f), (g)) + (K) + (x);    \
  |  |  ------------------
  |  |  |  |  469|  5.30k|#define F1(x, y, z) ((z) ^ ((x) & ((y) ^ (z))))
  |  |  ------------------
  |  |  481|  5.30k|        local.temp2 = S2(a) + F0((a), (b), (c));                      \
  |  |  ------------------
  |  |  |  |  465|  5.30k|#define S2(x) (ROTR(x, 2) ^ ROTR(x, 13) ^ ROTR(x, 22))
  |  |  |  |  ------------------
  |  |  |  |  |  |  460|  5.30k|#define ROTR(x, n) (SHR(x, n) | ((x) << (32 - (n))))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  459|  5.30k|#define  SHR(x, n) (((x) & 0xFFFFFFFF) >> (n))
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define S2(x) (ROTR(x, 2) ^ ROTR(x, 13) ^ ROTR(x, 22))
  |  |  |  |  ------------------
  |  |  |  |  |  |  460|  5.30k|#define ROTR(x, n) (SHR(x, n) | ((x) << (32 - (n))))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  459|  5.30k|#define  SHR(x, n) (((x) & 0xFFFFFFFF) >> (n))
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define S2(x) (ROTR(x, 2) ^ ROTR(x, 13) ^ ROTR(x, 22))
  |  |  |  |  ------------------
  |  |  |  |  |  |  460|  5.30k|#define ROTR(x, n) (SHR(x, n) | ((x) << (32 - (n))))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  459|  5.30k|#define  SHR(x, n) (((x) & 0xFFFFFFFF) >> (n))
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                       local.temp2 = S2(a) + F0((a), (b), (c));                      \
  |  |  ------------------
  |  |  |  |  468|  5.30k|#define F0(x, y, z) (((x) & (y)) | ((z) & ((x) | (y))))
  |  |  ------------------
  |  |  482|  5.30k|        (d) += local.temp1; (h) = local.temp1 + local.temp2;        \
  |  |  483|  5.30k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (483:14): [Folded - Ignored]
  |  |  ------------------
  ------------------
  551|  5.30k|          local.A[4], local.A[5], local.A[6], R(i+1), K[i+1]);
  552|  5.30k|        P(local.A[6], local.A[7], local.A[0], local.A[1], local.A[2],
  ------------------
  |  |  478|  5.30k|    do                                                              \
  |  |  479|  5.30k|    {                                                               \
  |  |  480|  5.30k|        local.temp1 = (h) + S3(e) + F1((e), (f), (g)) + (K) + (x);    \
  |  |  ------------------
  |  |  |  |  466|  5.30k|#define S3(x) (ROTR(x, 6) ^ ROTR(x, 11) ^ ROTR(x, 25))
  |  |  |  |  ------------------
  |  |  |  |  |  |  460|  5.30k|#define ROTR(x, n) (SHR(x, n) | ((x) << (32 - (n))))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  459|  5.30k|#define  SHR(x, n) (((x) & 0xFFFFFFFF) >> (n))
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define S3(x) (ROTR(x, 6) ^ ROTR(x, 11) ^ ROTR(x, 25))
  |  |  |  |  ------------------
  |  |  |  |  |  |  460|  5.30k|#define ROTR(x, n) (SHR(x, n) | ((x) << (32 - (n))))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  459|  5.30k|#define  SHR(x, n) (((x) & 0xFFFFFFFF) >> (n))
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define S3(x) (ROTR(x, 6) ^ ROTR(x, 11) ^ ROTR(x, 25))
  |  |  |  |  ------------------
  |  |  |  |  |  |  460|  5.30k|#define ROTR(x, n) (SHR(x, n) | ((x) << (32 - (n))))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  459|  5.30k|#define  SHR(x, n) (((x) & 0xFFFFFFFF) >> (n))
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                       local.temp1 = (h) + S3(e) + F1((e), (f), (g)) + (K) + (x);    \
  |  |  ------------------
  |  |  |  |  469|  5.30k|#define F1(x, y, z) ((z) ^ ((x) & ((y) ^ (z))))
  |  |  ------------------
  |  |  481|  5.30k|        local.temp2 = S2(a) + F0((a), (b), (c));                      \
  |  |  ------------------
  |  |  |  |  465|  5.30k|#define S2(x) (ROTR(x, 2) ^ ROTR(x, 13) ^ ROTR(x, 22))
  |  |  |  |  ------------------
  |  |  |  |  |  |  460|  5.30k|#define ROTR(x, n) (SHR(x, n) | ((x) << (32 - (n))))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  459|  5.30k|#define  SHR(x, n) (((x) & 0xFFFFFFFF) >> (n))
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define S2(x) (ROTR(x, 2) ^ ROTR(x, 13) ^ ROTR(x, 22))
  |  |  |  |  ------------------
  |  |  |  |  |  |  460|  5.30k|#define ROTR(x, n) (SHR(x, n) | ((x) << (32 - (n))))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  459|  5.30k|#define  SHR(x, n) (((x) & 0xFFFFFFFF) >> (n))
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define S2(x) (ROTR(x, 2) ^ ROTR(x, 13) ^ ROTR(x, 22))
  |  |  |  |  ------------------
  |  |  |  |  |  |  460|  5.30k|#define ROTR(x, n) (SHR(x, n) | ((x) << (32 - (n))))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  459|  5.30k|#define  SHR(x, n) (((x) & 0xFFFFFFFF) >> (n))
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                       local.temp2 = S2(a) + F0((a), (b), (c));                      \
  |  |  ------------------
  |  |  |  |  468|  5.30k|#define F0(x, y, z) (((x) & (y)) | ((z) & ((x) | (y))))
  |  |  ------------------
  |  |  482|  5.30k|        (d) += local.temp1; (h) = local.temp1 + local.temp2;        \
  |  |  483|  5.30k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (483:14): [Folded - Ignored]
  |  |  ------------------
  ------------------
  553|  5.30k|          local.A[3], local.A[4], local.A[5], R(i+2), K[i+2]);
  554|  5.30k|        P(local.A[5], local.A[6], local.A[7], local.A[0], local.A[1],
  ------------------
  |  |  478|  5.30k|    do                                                              \
  |  |  479|  5.30k|    {                                                               \
  |  |  480|  5.30k|        local.temp1 = (h) + S3(e) + F1((e), (f), (g)) + (K) + (x);    \
  |  |  ------------------
  |  |  |  |  466|  5.30k|#define S3(x) (ROTR(x, 6) ^ ROTR(x, 11) ^ ROTR(x, 25))
  |  |  |  |  ------------------
  |  |  |  |  |  |  460|  5.30k|#define ROTR(x, n) (SHR(x, n) | ((x) << (32 - (n))))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  459|  5.30k|#define  SHR(x, n) (((x) & 0xFFFFFFFF) >> (n))
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define S3(x) (ROTR(x, 6) ^ ROTR(x, 11) ^ ROTR(x, 25))
  |  |  |  |  ------------------
  |  |  |  |  |  |  460|  5.30k|#define ROTR(x, n) (SHR(x, n) | ((x) << (32 - (n))))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  459|  5.30k|#define  SHR(x, n) (((x) & 0xFFFFFFFF) >> (n))
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define S3(x) (ROTR(x, 6) ^ ROTR(x, 11) ^ ROTR(x, 25))
  |  |  |  |  ------------------
  |  |  |  |  |  |  460|  5.30k|#define ROTR(x, n) (SHR(x, n) | ((x) << (32 - (n))))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  459|  5.30k|#define  SHR(x, n) (((x) & 0xFFFFFFFF) >> (n))
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                       local.temp1 = (h) + S3(e) + F1((e), (f), (g)) + (K) + (x);    \
  |  |  ------------------
  |  |  |  |  469|  5.30k|#define F1(x, y, z) ((z) ^ ((x) & ((y) ^ (z))))
  |  |  ------------------
  |  |  481|  5.30k|        local.temp2 = S2(a) + F0((a), (b), (c));                      \
  |  |  ------------------
  |  |  |  |  465|  5.30k|#define S2(x) (ROTR(x, 2) ^ ROTR(x, 13) ^ ROTR(x, 22))
  |  |  |  |  ------------------
  |  |  |  |  |  |  460|  5.30k|#define ROTR(x, n) (SHR(x, n) | ((x) << (32 - (n))))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  459|  5.30k|#define  SHR(x, n) (((x) & 0xFFFFFFFF) >> (n))
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define S2(x) (ROTR(x, 2) ^ ROTR(x, 13) ^ ROTR(x, 22))
  |  |  |  |  ------------------
  |  |  |  |  |  |  460|  5.30k|#define ROTR(x, n) (SHR(x, n) | ((x) << (32 - (n))))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  459|  5.30k|#define  SHR(x, n) (((x) & 0xFFFFFFFF) >> (n))
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define S2(x) (ROTR(x, 2) ^ ROTR(x, 13) ^ ROTR(x, 22))
  |  |  |  |  ------------------
  |  |  |  |  |  |  460|  5.30k|#define ROTR(x, n) (SHR(x, n) | ((x) << (32 - (n))))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  459|  5.30k|#define  SHR(x, n) (((x) & 0xFFFFFFFF) >> (n))
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                       local.temp2 = S2(a) + F0((a), (b), (c));                      \
  |  |  ------------------
  |  |  |  |  468|  5.30k|#define F0(x, y, z) (((x) & (y)) | ((z) & ((x) | (y))))
  |  |  ------------------
  |  |  482|  5.30k|        (d) += local.temp1; (h) = local.temp1 + local.temp2;        \
  |  |  483|  5.30k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (483:14): [Folded - Ignored]
  |  |  ------------------
  ------------------
  555|  5.30k|          local.A[2], local.A[3], local.A[4], R(i+3), K[i+3]);
  556|  5.30k|        P(local.A[4], local.A[5], local.A[6], local.A[7], local.A[0],
  ------------------
  |  |  478|  5.30k|    do                                                              \
  |  |  479|  5.30k|    {                                                               \
  |  |  480|  5.30k|        local.temp1 = (h) + S3(e) + F1((e), (f), (g)) + (K) + (x);    \
  |  |  ------------------
  |  |  |  |  466|  5.30k|#define S3(x) (ROTR(x, 6) ^ ROTR(x, 11) ^ ROTR(x, 25))
  |  |  |  |  ------------------
  |  |  |  |  |  |  460|  5.30k|#define ROTR(x, n) (SHR(x, n) | ((x) << (32 - (n))))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  459|  5.30k|#define  SHR(x, n) (((x) & 0xFFFFFFFF) >> (n))
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define S3(x) (ROTR(x, 6) ^ ROTR(x, 11) ^ ROTR(x, 25))
  |  |  |  |  ------------------
  |  |  |  |  |  |  460|  5.30k|#define ROTR(x, n) (SHR(x, n) | ((x) << (32 - (n))))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  459|  5.30k|#define  SHR(x, n) (((x) & 0xFFFFFFFF) >> (n))
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define S3(x) (ROTR(x, 6) ^ ROTR(x, 11) ^ ROTR(x, 25))
  |  |  |  |  ------------------
  |  |  |  |  |  |  460|  5.30k|#define ROTR(x, n) (SHR(x, n) | ((x) << (32 - (n))))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  459|  5.30k|#define  SHR(x, n) (((x) & 0xFFFFFFFF) >> (n))
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                       local.temp1 = (h) + S3(e) + F1((e), (f), (g)) + (K) + (x);    \
  |  |  ------------------
  |  |  |  |  469|  5.30k|#define F1(x, y, z) ((z) ^ ((x) & ((y) ^ (z))))
  |  |  ------------------
  |  |  481|  5.30k|        local.temp2 = S2(a) + F0((a), (b), (c));                      \
  |  |  ------------------
  |  |  |  |  465|  5.30k|#define S2(x) (ROTR(x, 2) ^ ROTR(x, 13) ^ ROTR(x, 22))
  |  |  |  |  ------------------
  |  |  |  |  |  |  460|  5.30k|#define ROTR(x, n) (SHR(x, n) | ((x) << (32 - (n))))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  459|  5.30k|#define  SHR(x, n) (((x) & 0xFFFFFFFF) >> (n))
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define S2(x) (ROTR(x, 2) ^ ROTR(x, 13) ^ ROTR(x, 22))
  |  |  |  |  ------------------
  |  |  |  |  |  |  460|  5.30k|#define ROTR(x, n) (SHR(x, n) | ((x) << (32 - (n))))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  459|  5.30k|#define  SHR(x, n) (((x) & 0xFFFFFFFF) >> (n))
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define S2(x) (ROTR(x, 2) ^ ROTR(x, 13) ^ ROTR(x, 22))
  |  |  |  |  ------------------
  |  |  |  |  |  |  460|  5.30k|#define ROTR(x, n) (SHR(x, n) | ((x) << (32 - (n))))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  459|  5.30k|#define  SHR(x, n) (((x) & 0xFFFFFFFF) >> (n))
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                       local.temp2 = S2(a) + F0((a), (b), (c));                      \
  |  |  ------------------
  |  |  |  |  468|  5.30k|#define F0(x, y, z) (((x) & (y)) | ((z) & ((x) | (y))))
  |  |  ------------------
  |  |  482|  5.30k|        (d) += local.temp1; (h) = local.temp1 + local.temp2;        \
  |  |  483|  5.30k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (483:14): [Folded - Ignored]
  |  |  ------------------
  ------------------
  557|  5.30k|          local.A[1], local.A[2], local.A[3], R(i+4), K[i+4]);
  558|  5.30k|        P(local.A[3], local.A[4], local.A[5], local.A[6], local.A[7],
  ------------------
  |  |  478|  5.30k|    do                                                              \
  |  |  479|  5.30k|    {                                                               \
  |  |  480|  5.30k|        local.temp1 = (h) + S3(e) + F1((e), (f), (g)) + (K) + (x);    \
  |  |  ------------------
  |  |  |  |  466|  5.30k|#define S3(x) (ROTR(x, 6) ^ ROTR(x, 11) ^ ROTR(x, 25))
  |  |  |  |  ------------------
  |  |  |  |  |  |  460|  5.30k|#define ROTR(x, n) (SHR(x, n) | ((x) << (32 - (n))))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  459|  5.30k|#define  SHR(x, n) (((x) & 0xFFFFFFFF) >> (n))
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define S3(x) (ROTR(x, 6) ^ ROTR(x, 11) ^ ROTR(x, 25))
  |  |  |  |  ------------------
  |  |  |  |  |  |  460|  5.30k|#define ROTR(x, n) (SHR(x, n) | ((x) << (32 - (n))))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  459|  5.30k|#define  SHR(x, n) (((x) & 0xFFFFFFFF) >> (n))
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define S3(x) (ROTR(x, 6) ^ ROTR(x, 11) ^ ROTR(x, 25))
  |  |  |  |  ------------------
  |  |  |  |  |  |  460|  5.30k|#define ROTR(x, n) (SHR(x, n) | ((x) << (32 - (n))))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  459|  5.30k|#define  SHR(x, n) (((x) & 0xFFFFFFFF) >> (n))
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                       local.temp1 = (h) + S3(e) + F1((e), (f), (g)) + (K) + (x);    \
  |  |  ------------------
  |  |  |  |  469|  5.30k|#define F1(x, y, z) ((z) ^ ((x) & ((y) ^ (z))))
  |  |  ------------------
  |  |  481|  5.30k|        local.temp2 = S2(a) + F0((a), (b), (c));                      \
  |  |  ------------------
  |  |  |  |  465|  5.30k|#define S2(x) (ROTR(x, 2) ^ ROTR(x, 13) ^ ROTR(x, 22))
  |  |  |  |  ------------------
  |  |  |  |  |  |  460|  5.30k|#define ROTR(x, n) (SHR(x, n) | ((x) << (32 - (n))))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  459|  5.30k|#define  SHR(x, n) (((x) & 0xFFFFFFFF) >> (n))
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define S2(x) (ROTR(x, 2) ^ ROTR(x, 13) ^ ROTR(x, 22))
  |  |  |  |  ------------------
  |  |  |  |  |  |  460|  5.30k|#define ROTR(x, n) (SHR(x, n) | ((x) << (32 - (n))))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  459|  5.30k|#define  SHR(x, n) (((x) & 0xFFFFFFFF) >> (n))
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define S2(x) (ROTR(x, 2) ^ ROTR(x, 13) ^ ROTR(x, 22))
  |  |  |  |  ------------------
  |  |  |  |  |  |  460|  5.30k|#define ROTR(x, n) (SHR(x, n) | ((x) << (32 - (n))))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  459|  5.30k|#define  SHR(x, n) (((x) & 0xFFFFFFFF) >> (n))
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                       local.temp2 = S2(a) + F0((a), (b), (c));                      \
  |  |  ------------------
  |  |  |  |  468|  5.30k|#define F0(x, y, z) (((x) & (y)) | ((z) & ((x) | (y))))
  |  |  ------------------
  |  |  482|  5.30k|        (d) += local.temp1; (h) = local.temp1 + local.temp2;        \
  |  |  483|  5.30k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (483:14): [Folded - Ignored]
  |  |  ------------------
  ------------------
  559|  5.30k|          local.A[0], local.A[1], local.A[2], R(i+5), K[i+5]);
  560|  5.30k|        P(local.A[2], local.A[3], local.A[4], local.A[5], local.A[6],
  ------------------
  |  |  478|  5.30k|    do                                                              \
  |  |  479|  5.30k|    {                                                               \
  |  |  480|  5.30k|        local.temp1 = (h) + S3(e) + F1((e), (f), (g)) + (K) + (x);    \
  |  |  ------------------
  |  |  |  |  466|  5.30k|#define S3(x) (ROTR(x, 6) ^ ROTR(x, 11) ^ ROTR(x, 25))
  |  |  |  |  ------------------
  |  |  |  |  |  |  460|  5.30k|#define ROTR(x, n) (SHR(x, n) | ((x) << (32 - (n))))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  459|  5.30k|#define  SHR(x, n) (((x) & 0xFFFFFFFF) >> (n))
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define S3(x) (ROTR(x, 6) ^ ROTR(x, 11) ^ ROTR(x, 25))
  |  |  |  |  ------------------
  |  |  |  |  |  |  460|  5.30k|#define ROTR(x, n) (SHR(x, n) | ((x) << (32 - (n))))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  459|  5.30k|#define  SHR(x, n) (((x) & 0xFFFFFFFF) >> (n))
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define S3(x) (ROTR(x, 6) ^ ROTR(x, 11) ^ ROTR(x, 25))
  |  |  |  |  ------------------
  |  |  |  |  |  |  460|  5.30k|#define ROTR(x, n) (SHR(x, n) | ((x) << (32 - (n))))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  459|  5.30k|#define  SHR(x, n) (((x) & 0xFFFFFFFF) >> (n))
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                       local.temp1 = (h) + S3(e) + F1((e), (f), (g)) + (K) + (x);    \
  |  |  ------------------
  |  |  |  |  469|  5.30k|#define F1(x, y, z) ((z) ^ ((x) & ((y) ^ (z))))
  |  |  ------------------
  |  |  481|  5.30k|        local.temp2 = S2(a) + F0((a), (b), (c));                      \
  |  |  ------------------
  |  |  |  |  465|  5.30k|#define S2(x) (ROTR(x, 2) ^ ROTR(x, 13) ^ ROTR(x, 22))
  |  |  |  |  ------------------
  |  |  |  |  |  |  460|  5.30k|#define ROTR(x, n) (SHR(x, n) | ((x) << (32 - (n))))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  459|  5.30k|#define  SHR(x, n) (((x) & 0xFFFFFFFF) >> (n))
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define S2(x) (ROTR(x, 2) ^ ROTR(x, 13) ^ ROTR(x, 22))
  |  |  |  |  ------------------
  |  |  |  |  |  |  460|  5.30k|#define ROTR(x, n) (SHR(x, n) | ((x) << (32 - (n))))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  459|  5.30k|#define  SHR(x, n) (((x) & 0xFFFFFFFF) >> (n))
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define S2(x) (ROTR(x, 2) ^ ROTR(x, 13) ^ ROTR(x, 22))
  |  |  |  |  ------------------
  |  |  |  |  |  |  460|  5.30k|#define ROTR(x, n) (SHR(x, n) | ((x) << (32 - (n))))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  459|  5.30k|#define  SHR(x, n) (((x) & 0xFFFFFFFF) >> (n))
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                       local.temp2 = S2(a) + F0((a), (b), (c));                      \
  |  |  ------------------
  |  |  |  |  468|  5.30k|#define F0(x, y, z) (((x) & (y)) | ((z) & ((x) | (y))))
  |  |  ------------------
  |  |  482|  5.30k|        (d) += local.temp1; (h) = local.temp1 + local.temp2;        \
  |  |  483|  5.30k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (483:14): [Folded - Ignored]
  |  |  ------------------
  ------------------
  561|  5.30k|          local.A[7], local.A[0], local.A[1], R(i+6), K[i+6]);
  562|  5.30k|        P(local.A[1], local.A[2], local.A[3], local.A[4], local.A[5],
  ------------------
  |  |  478|  5.30k|    do                                                              \
  |  |  479|  5.30k|    {                                                               \
  |  |  480|  5.30k|        local.temp1 = (h) + S3(e) + F1((e), (f), (g)) + (K) + (x);    \
  |  |  ------------------
  |  |  |  |  466|  5.30k|#define S3(x) (ROTR(x, 6) ^ ROTR(x, 11) ^ ROTR(x, 25))
  |  |  |  |  ------------------
  |  |  |  |  |  |  460|  5.30k|#define ROTR(x, n) (SHR(x, n) | ((x) << (32 - (n))))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  459|  5.30k|#define  SHR(x, n) (((x) & 0xFFFFFFFF) >> (n))
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define S3(x) (ROTR(x, 6) ^ ROTR(x, 11) ^ ROTR(x, 25))
  |  |  |  |  ------------------
  |  |  |  |  |  |  460|  5.30k|#define ROTR(x, n) (SHR(x, n) | ((x) << (32 - (n))))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  459|  5.30k|#define  SHR(x, n) (((x) & 0xFFFFFFFF) >> (n))
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define S3(x) (ROTR(x, 6) ^ ROTR(x, 11) ^ ROTR(x, 25))
  |  |  |  |  ------------------
  |  |  |  |  |  |  460|  5.30k|#define ROTR(x, n) (SHR(x, n) | ((x) << (32 - (n))))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  459|  5.30k|#define  SHR(x, n) (((x) & 0xFFFFFFFF) >> (n))
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                       local.temp1 = (h) + S3(e) + F1((e), (f), (g)) + (K) + (x);    \
  |  |  ------------------
  |  |  |  |  469|  5.30k|#define F1(x, y, z) ((z) ^ ((x) & ((y) ^ (z))))
  |  |  ------------------
  |  |  481|  5.30k|        local.temp2 = S2(a) + F0((a), (b), (c));                      \
  |  |  ------------------
  |  |  |  |  465|  5.30k|#define S2(x) (ROTR(x, 2) ^ ROTR(x, 13) ^ ROTR(x, 22))
  |  |  |  |  ------------------
  |  |  |  |  |  |  460|  5.30k|#define ROTR(x, n) (SHR(x, n) | ((x) << (32 - (n))))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  459|  5.30k|#define  SHR(x, n) (((x) & 0xFFFFFFFF) >> (n))
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define S2(x) (ROTR(x, 2) ^ ROTR(x, 13) ^ ROTR(x, 22))
  |  |  |  |  ------------------
  |  |  |  |  |  |  460|  5.30k|#define ROTR(x, n) (SHR(x, n) | ((x) << (32 - (n))))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  459|  5.30k|#define  SHR(x, n) (((x) & 0xFFFFFFFF) >> (n))
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define S2(x) (ROTR(x, 2) ^ ROTR(x, 13) ^ ROTR(x, 22))
  |  |  |  |  ------------------
  |  |  |  |  |  |  460|  5.30k|#define ROTR(x, n) (SHR(x, n) | ((x) << (32 - (n))))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  459|  5.30k|#define  SHR(x, n) (((x) & 0xFFFFFFFF) >> (n))
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                       local.temp2 = S2(a) + F0((a), (b), (c));                      \
  |  |  ------------------
  |  |  |  |  468|  5.30k|#define F0(x, y, z) (((x) & (y)) | ((z) & ((x) | (y))))
  |  |  ------------------
  |  |  482|  5.30k|        (d) += local.temp1; (h) = local.temp1 + local.temp2;        \
  |  |  483|  5.30k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (483:14): [Folded - Ignored]
  |  |  ------------------
  ------------------
  563|  5.30k|          local.A[6], local.A[7], local.A[0], R(i+7), K[i+7]);
  564|  5.30k|    }
  565|    884|#endif /* MBEDTLS_SHA256_SMALLER */
  566|       |
  567|  7.95k|    for (i = 0; i < 8; i++) {
  ------------------
  |  Branch (567:17): [True: 7.07k, False: 884]
  ------------------
  568|  7.07k|        ctx->state[i] += local.A[i];
  569|  7.07k|    }
  570|       |
  571|       |    /* Zeroise buffers and variables to clear sensitive data from memory. */
  572|    884|    mbedtls_platform_zeroize(&local, sizeof(local));
  573|       |
  574|    884|    return 0;
  575|    884|}
mbedtls_sha256_update:
  648|  1.32k|{
  649|  1.32k|    int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
  ------------------
  |  |  100|  1.32k|#define MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED -0x006E
  ------------------
  650|  1.32k|    size_t fill;
  651|  1.32k|    uint32_t left;
  652|       |
  653|  1.32k|    if (ilen == 0) {
  ------------------
  |  Branch (653:9): [True: 221, False: 1.10k]
  ------------------
  654|    221|        return 0;
  655|    221|    }
  656|       |
  657|  1.10k|    left = ctx->total[0] & 0x3F;
  658|  1.10k|    fill = SHA256_BLOCK_SIZE - left;
  ------------------
  |  |  223|  1.10k|#define SHA256_BLOCK_SIZE 64
  ------------------
  659|       |
  660|  1.10k|    ctx->total[0] += (uint32_t) ilen;
  661|  1.10k|    ctx->total[0] &= 0xFFFFFFFF;
  662|       |
  663|  1.10k|    if (ctx->total[0] < (uint32_t) ilen) {
  ------------------
  |  Branch (663:9): [True: 0, False: 1.10k]
  ------------------
  664|      0|        ctx->total[1]++;
  665|      0|    }
  666|       |
  667|  1.10k|    if (left && ilen >= fill) {
  ------------------
  |  Branch (667:9): [True: 221, False: 884]
  |  Branch (667:17): [True: 0, False: 221]
  ------------------
  668|      0|        memcpy((void *) (ctx->buffer + left), input, fill);
  669|       |
  670|      0|        if ((ret = mbedtls_internal_sha256_process(ctx, ctx->buffer)) != 0) {
  ------------------
  |  Branch (670:13): [True: 0, False: 0]
  ------------------
  671|      0|            return ret;
  672|      0|        }
  673|       |
  674|      0|        input += fill;
  675|      0|        ilen  -= fill;
  676|      0|        left = 0;
  677|      0|    }
  678|       |
  679|  1.54k|    while (ilen >= SHA256_BLOCK_SIZE) {
  ------------------
  |  |  223|  1.54k|#define SHA256_BLOCK_SIZE 64
  ------------------
  |  Branch (679:12): [True: 442, False: 1.10k]
  ------------------
  680|    442|        size_t processed =
  681|    442|            mbedtls_internal_sha256_process_many(ctx, input, ilen);
  682|    442|        if (processed < SHA256_BLOCK_SIZE) {
  ------------------
  |  |  223|    442|#define SHA256_BLOCK_SIZE 64
  ------------------
  |  Branch (682:13): [True: 0, False: 442]
  ------------------
  683|      0|            return MBEDTLS_ERR_ERROR_GENERIC_ERROR;
  ------------------
  |  |   98|      0|#define MBEDTLS_ERR_ERROR_GENERIC_ERROR       -0x0001
  ------------------
  684|      0|        }
  685|       |
  686|    442|        input += processed;
  687|    442|        ilen  -= processed;
  688|    442|    }
  689|       |
  690|  1.10k|    if (ilen > 0) {
  ------------------
  |  Branch (690:9): [True: 663, False: 442]
  ------------------
  691|    663|        memcpy((void *) (ctx->buffer + left), input, ilen);
  692|    663|    }
  693|       |
  694|  1.10k|    return 0;
  695|  1.10k|}
mbedtls_sha256_finish:
  702|    442|{
  703|    442|    int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
  ------------------
  |  |  100|    442|#define MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED -0x006E
  ------------------
  704|    442|    uint32_t used;
  705|    442|    uint32_t high, low;
  706|    442|    int truncated = 0;
  707|       |
  708|       |    /*
  709|       |     * Add padding: 0x80 then 0x00 until 8 bytes remain for the length
  710|       |     */
  711|    442|    used = ctx->total[0] & 0x3F;
  712|       |
  713|    442|    ctx->buffer[used++] = 0x80;
  714|       |
  715|    442|    if (used <= 56) {
  ------------------
  |  Branch (715:9): [True: 442, False: 0]
  ------------------
  716|       |        /* Enough room for padding + length in current block */
  717|    442|        memset(ctx->buffer + used, 0, 56 - used);
  718|    442|    } else {
  719|       |        /* We'll need an extra block */
  720|      0|        memset(ctx->buffer + used, 0, SHA256_BLOCK_SIZE - used);
  ------------------
  |  |  223|      0|#define SHA256_BLOCK_SIZE 64
  ------------------
  721|       |
  722|      0|        if ((ret = mbedtls_internal_sha256_process(ctx, ctx->buffer)) != 0) {
  ------------------
  |  Branch (722:13): [True: 0, False: 0]
  ------------------
  723|      0|            goto exit;
  724|      0|        }
  725|       |
  726|      0|        memset(ctx->buffer, 0, 56);
  727|      0|    }
  728|       |
  729|       |    /*
  730|       |     * Add message length
  731|       |     */
  732|    442|    high = (ctx->total[0] >> 29)
  733|    442|           | (ctx->total[1] <<  3);
  734|    442|    low  = (ctx->total[0] <<  3);
  735|       |
  736|    442|    MBEDTLS_PUT_UINT32_BE(high, ctx->buffer, 56);
  ------------------
  |  |  428|    442|    {                                                                            \
  |  |  429|    442|        if (MBEDTLS_IS_BIG_ENDIAN)                                               \
  |  |  ------------------
  |  |  |  |  398|    442|#define MBEDTLS_IS_BIG_ENDIAN 0
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (398:31): [Folded - Ignored]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  430|    442|        {                                                                        \
  |  |  431|      0|            mbedtls_put_unaligned_uint32((data) + (offset), (uint32_t) (n));     \
  |  |  432|      0|        }                                                                        \
  |  |  433|    442|        else                                                                     \
  |  |  434|    442|        {                                                                        \
  |  |  435|    442|            mbedtls_put_unaligned_uint32((data) + (offset), MBEDTLS_BSWAP32((uint32_t) (n))); \
  |  |  ------------------
  |  |  |  |  298|    442|#define MBEDTLS_BSWAP32 __builtin_bswap32
  |  |  ------------------
  |  |  436|    442|        }                                                                        \
  |  |  437|    442|    }
  ------------------
  737|    442|    MBEDTLS_PUT_UINT32_BE(low,  ctx->buffer, 60);
  ------------------
  |  |  428|    442|    {                                                                            \
  |  |  429|    442|        if (MBEDTLS_IS_BIG_ENDIAN)                                               \
  |  |  ------------------
  |  |  |  |  398|    442|#define MBEDTLS_IS_BIG_ENDIAN 0
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (398:31): [Folded - Ignored]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  430|    442|        {                                                                        \
  |  |  431|      0|            mbedtls_put_unaligned_uint32((data) + (offset), (uint32_t) (n));     \
  |  |  432|      0|        }                                                                        \
  |  |  433|    442|        else                                                                     \
  |  |  434|    442|        {                                                                        \
  |  |  435|    442|            mbedtls_put_unaligned_uint32((data) + (offset), MBEDTLS_BSWAP32((uint32_t) (n))); \
  |  |  ------------------
  |  |  |  |  298|    442|#define MBEDTLS_BSWAP32 __builtin_bswap32
  |  |  ------------------
  |  |  436|    442|        }                                                                        \
  |  |  437|    442|    }
  ------------------
  738|       |
  739|    442|    if ((ret = mbedtls_internal_sha256_process(ctx, ctx->buffer)) != 0) {
  ------------------
  |  Branch (739:9): [True: 0, False: 442]
  ------------------
  740|      0|        goto exit;
  741|      0|    }
  742|       |
  743|       |    /*
  744|       |     * Output final state
  745|       |     */
  746|    442|    MBEDTLS_PUT_UINT32_BE(ctx->state[0], output,  0);
  ------------------
  |  |  428|    442|    {                                                                            \
  |  |  429|    442|        if (MBEDTLS_IS_BIG_ENDIAN)                                               \
  |  |  ------------------
  |  |  |  |  398|    442|#define MBEDTLS_IS_BIG_ENDIAN 0
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (398:31): [Folded - Ignored]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  430|    442|        {                                                                        \
  |  |  431|      0|            mbedtls_put_unaligned_uint32((data) + (offset), (uint32_t) (n));     \
  |  |  432|      0|        }                                                                        \
  |  |  433|    442|        else                                                                     \
  |  |  434|    442|        {                                                                        \
  |  |  435|    442|            mbedtls_put_unaligned_uint32((data) + (offset), MBEDTLS_BSWAP32((uint32_t) (n))); \
  |  |  ------------------
  |  |  |  |  298|    442|#define MBEDTLS_BSWAP32 __builtin_bswap32
  |  |  ------------------
  |  |  436|    442|        }                                                                        \
  |  |  437|    442|    }
  ------------------
  747|    442|    MBEDTLS_PUT_UINT32_BE(ctx->state[1], output,  4);
  ------------------
  |  |  428|    442|    {                                                                            \
  |  |  429|    442|        if (MBEDTLS_IS_BIG_ENDIAN)                                               \
  |  |  ------------------
  |  |  |  |  398|    442|#define MBEDTLS_IS_BIG_ENDIAN 0
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (398:31): [Folded - Ignored]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  430|    442|        {                                                                        \
  |  |  431|      0|            mbedtls_put_unaligned_uint32((data) + (offset), (uint32_t) (n));     \
  |  |  432|      0|        }                                                                        \
  |  |  433|    442|        else                                                                     \
  |  |  434|    442|        {                                                                        \
  |  |  435|    442|            mbedtls_put_unaligned_uint32((data) + (offset), MBEDTLS_BSWAP32((uint32_t) (n))); \
  |  |  ------------------
  |  |  |  |  298|    442|#define MBEDTLS_BSWAP32 __builtin_bswap32
  |  |  ------------------
  |  |  436|    442|        }                                                                        \
  |  |  437|    442|    }
  ------------------
  748|    442|    MBEDTLS_PUT_UINT32_BE(ctx->state[2], output,  8);
  ------------------
  |  |  428|    442|    {                                                                            \
  |  |  429|    442|        if (MBEDTLS_IS_BIG_ENDIAN)                                               \
  |  |  ------------------
  |  |  |  |  398|    442|#define MBEDTLS_IS_BIG_ENDIAN 0
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (398:31): [Folded - Ignored]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  430|    442|        {                                                                        \
  |  |  431|      0|            mbedtls_put_unaligned_uint32((data) + (offset), (uint32_t) (n));     \
  |  |  432|      0|        }                                                                        \
  |  |  433|    442|        else                                                                     \
  |  |  434|    442|        {                                                                        \
  |  |  435|    442|            mbedtls_put_unaligned_uint32((data) + (offset), MBEDTLS_BSWAP32((uint32_t) (n))); \
  |  |  ------------------
  |  |  |  |  298|    442|#define MBEDTLS_BSWAP32 __builtin_bswap32
  |  |  ------------------
  |  |  436|    442|        }                                                                        \
  |  |  437|    442|    }
  ------------------
  749|    442|    MBEDTLS_PUT_UINT32_BE(ctx->state[3], output, 12);
  ------------------
  |  |  428|    442|    {                                                                            \
  |  |  429|    442|        if (MBEDTLS_IS_BIG_ENDIAN)                                               \
  |  |  ------------------
  |  |  |  |  398|    442|#define MBEDTLS_IS_BIG_ENDIAN 0
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (398:31): [Folded - Ignored]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  430|    442|        {                                                                        \
  |  |  431|      0|            mbedtls_put_unaligned_uint32((data) + (offset), (uint32_t) (n));     \
  |  |  432|      0|        }                                                                        \
  |  |  433|    442|        else                                                                     \
  |  |  434|    442|        {                                                                        \
  |  |  435|    442|            mbedtls_put_unaligned_uint32((data) + (offset), MBEDTLS_BSWAP32((uint32_t) (n))); \
  |  |  ------------------
  |  |  |  |  298|    442|#define MBEDTLS_BSWAP32 __builtin_bswap32
  |  |  ------------------
  |  |  436|    442|        }                                                                        \
  |  |  437|    442|    }
  ------------------
  750|    442|    MBEDTLS_PUT_UINT32_BE(ctx->state[4], output, 16);
  ------------------
  |  |  428|    442|    {                                                                            \
  |  |  429|    442|        if (MBEDTLS_IS_BIG_ENDIAN)                                               \
  |  |  ------------------
  |  |  |  |  398|    442|#define MBEDTLS_IS_BIG_ENDIAN 0
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (398:31): [Folded - Ignored]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  430|    442|        {                                                                        \
  |  |  431|      0|            mbedtls_put_unaligned_uint32((data) + (offset), (uint32_t) (n));     \
  |  |  432|      0|        }                                                                        \
  |  |  433|    442|        else                                                                     \
  |  |  434|    442|        {                                                                        \
  |  |  435|    442|            mbedtls_put_unaligned_uint32((data) + (offset), MBEDTLS_BSWAP32((uint32_t) (n))); \
  |  |  ------------------
  |  |  |  |  298|    442|#define MBEDTLS_BSWAP32 __builtin_bswap32
  |  |  ------------------
  |  |  436|    442|        }                                                                        \
  |  |  437|    442|    }
  ------------------
  751|    442|    MBEDTLS_PUT_UINT32_BE(ctx->state[5], output, 20);
  ------------------
  |  |  428|    442|    {                                                                            \
  |  |  429|    442|        if (MBEDTLS_IS_BIG_ENDIAN)                                               \
  |  |  ------------------
  |  |  |  |  398|    442|#define MBEDTLS_IS_BIG_ENDIAN 0
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (398:31): [Folded - Ignored]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  430|    442|        {                                                                        \
  |  |  431|      0|            mbedtls_put_unaligned_uint32((data) + (offset), (uint32_t) (n));     \
  |  |  432|      0|        }                                                                        \
  |  |  433|    442|        else                                                                     \
  |  |  434|    442|        {                                                                        \
  |  |  435|    442|            mbedtls_put_unaligned_uint32((data) + (offset), MBEDTLS_BSWAP32((uint32_t) (n))); \
  |  |  ------------------
  |  |  |  |  298|    442|#define MBEDTLS_BSWAP32 __builtin_bswap32
  |  |  ------------------
  |  |  436|    442|        }                                                                        \
  |  |  437|    442|    }
  ------------------
  752|    442|    MBEDTLS_PUT_UINT32_BE(ctx->state[6], output, 24);
  ------------------
  |  |  428|    442|    {                                                                            \
  |  |  429|    442|        if (MBEDTLS_IS_BIG_ENDIAN)                                               \
  |  |  ------------------
  |  |  |  |  398|    442|#define MBEDTLS_IS_BIG_ENDIAN 0
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (398:31): [Folded - Ignored]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  430|    442|        {                                                                        \
  |  |  431|      0|            mbedtls_put_unaligned_uint32((data) + (offset), (uint32_t) (n));     \
  |  |  432|      0|        }                                                                        \
  |  |  433|    442|        else                                                                     \
  |  |  434|    442|        {                                                                        \
  |  |  435|    442|            mbedtls_put_unaligned_uint32((data) + (offset), MBEDTLS_BSWAP32((uint32_t) (n))); \
  |  |  ------------------
  |  |  |  |  298|    442|#define MBEDTLS_BSWAP32 __builtin_bswap32
  |  |  ------------------
  |  |  436|    442|        }                                                                        \
  |  |  437|    442|    }
  ------------------
  753|       |
  754|       |#if defined(MBEDTLS_SHA224_C)
  755|       |    truncated = ctx->is224;
  756|       |#endif
  757|    442|    if (!truncated) {
  ------------------
  |  Branch (757:9): [True: 442, False: 0]
  ------------------
  758|    442|        MBEDTLS_PUT_UINT32_BE(ctx->state[7], output, 28);
  ------------------
  |  |  428|    442|    {                                                                            \
  |  |  429|    442|        if (MBEDTLS_IS_BIG_ENDIAN)                                               \
  |  |  ------------------
  |  |  |  |  398|    442|#define MBEDTLS_IS_BIG_ENDIAN 0
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (398:31): [Folded - Ignored]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  430|    442|        {                                                                        \
  |  |  431|      0|            mbedtls_put_unaligned_uint32((data) + (offset), (uint32_t) (n));     \
  |  |  432|      0|        }                                                                        \
  |  |  433|    442|        else                                                                     \
  |  |  434|    442|        {                                                                        \
  |  |  435|    442|            mbedtls_put_unaligned_uint32((data) + (offset), MBEDTLS_BSWAP32((uint32_t) (n))); \
  |  |  ------------------
  |  |  |  |  298|    442|#define MBEDTLS_BSWAP32 __builtin_bswap32
  |  |  ------------------
  |  |  436|    442|        }                                                                        \
  |  |  437|    442|    }
  ------------------
  759|    442|    }
  760|       |
  761|    442|    ret = 0;
  762|       |
  763|    442|exit:
  764|    442|    mbedtls_sha256_free(ctx);
  765|    442|    return ret;
  766|    442|}
sha256.c:mbedtls_internal_sha256_process_many:
  584|    442|{
  585|    442|    size_t processed = 0;
  586|       |
  587|    884|    while (len >= SHA256_BLOCK_SIZE) {
  ------------------
  |  |  223|    884|#define SHA256_BLOCK_SIZE 64
  ------------------
  |  Branch (587:12): [True: 442, False: 442]
  ------------------
  588|    442|        if (mbedtls_internal_sha256_process_c(ctx, data) != 0) {
  ------------------
  |  |  452|    442|#define mbedtls_internal_sha256_process_c      mbedtls_internal_sha256_process
  ------------------
  |  Branch (588:13): [True: 0, False: 442]
  ------------------
  589|      0|            return 0;
  590|      0|        }
  591|       |
  592|    442|        data += SHA256_BLOCK_SIZE;
  ------------------
  |  |  223|    442|#define SHA256_BLOCK_SIZE 64
  ------------------
  593|    442|        len  -= SHA256_BLOCK_SIZE;
  ------------------
  |  |  223|    442|#define SHA256_BLOCK_SIZE 64
  ------------------
  594|       |
  595|    442|        processed += SHA256_BLOCK_SIZE;
  ------------------
  |  |  223|    442|#define SHA256_BLOCK_SIZE 64
  ------------------
  596|    442|    }
  597|       |
  598|    442|    return processed;
  599|    442|}

libspdm_consttime_is_mem_equal:
   11|     34|{
   12|     34|    const volatile uint8_t *pointer_dst;
   13|     34|    const volatile uint8_t *pointer_src;
   14|     34|    uint8_t delta;
   15|       |
   16|     34|    pointer_dst = (const uint8_t *)destination_buffer;
   17|     34|    pointer_src = (const uint8_t *)source_buffer;
   18|     34|    delta = 0;
   19|    170|    while ((length-- != 0)) {
  ------------------
  |  Branch (19:12): [True: 136, False: 34]
  ------------------
   20|    136|        delta |= *(pointer_dst++) ^ *(pointer_src++);
   21|    136|    }
   22|       |
   23|     34|    return ((delta == 0) ? true : false);
  ------------------
  |  Branch (23:13): [True: 34, False: 0]
  ------------------
   24|     34|}

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

libspdm_set_mem:
   10|    714|{
   11|    714|    volatile uint8_t *pointer;
   12|       |
   13|    714|    pointer = (uint8_t *)buffer;
   14|  18.8k|    while (length-- != 0) {
  ------------------
  |  Branch (14:12): [True: 18.0k, False: 714]
  ------------------
   15|  18.0k|        *(pointer++) = value;
   16|  18.0k|    }
   17|    714|}

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

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

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

libspdm_get_max_buffer_size:
   94|    238|{
   95|    238|    return LIBSPDM_MAX_SPDM_MSG_SIZE;
  ------------------
  |  |  101|    238|#define LIBSPDM_MAX_SPDM_MSG_SIZE 0x1200
  ------------------
   96|    238|}
libspdm_test_requester_encap_key_update:
   99|    119|{
  100|    119|    libspdm_test_context_t *spdm_test_context;
  101|    119|    libspdm_context_t *spdm_context;
  102|    119|    uint32_t session_id;
  103|    119|    libspdm_session_info_t *session_info;
  104|    119|    libspdm_secured_message_context_t *secured_message_context;
  105|    119|    size_t request_size;
  106|    119|    size_t response_size;
  107|    119|    uint8_t response[LIBSPDM_MAX_SPDM_MSG_SIZE];
  108|    119|    uint8_t m_req_secret_buffer[LIBSPDM_MAX_HASH_SIZE];
  109|    119|    uint8_t m_rsp_secret_buffer[LIBSPDM_MAX_HASH_SIZE];
  110|       |
  111|    119|    spdm_test_context = *State;
  112|    119|    spdm_context = spdm_test_context->spdm_context;
  113|    119|    spdm_context->connection_info.version = SPDM_MESSAGE_VERSION_11 <<
  ------------------
  |  |  111|    119|#define SPDM_MESSAGE_VERSION_11 0x11
  ------------------
  114|    119|                                            SPDM_VERSION_NUMBER_SHIFT_BIT;
  ------------------
  |  |  140|    119|#define SPDM_VERSION_NUMBER_SHIFT_BIT 8
  ------------------
  115|    119|    libspdm_set_standard_key_update_test_state(spdm_context, &session_id);
  116|       |
  117|    119|    session_info = &spdm_context->session_info[0];
  118|    119|    secured_message_context = session_info->secured_message_context;
  119|       |
  120|    119|    libspdm_set_standard_key_update_test_secrets(session_info->secured_message_context,
  121|    119|                                                 m_rsp_secret_buffer, (uint8_t)(0xFF),
  122|    119|                                                 m_req_secret_buffer, (uint8_t)(0xEE));
  123|       |
  124|    119|    libspdm_compute_secret_update(spdm_context->connection_info.version,
  125|    119|                                  secured_message_context->hash_size, m_req_secret_buffer,
  126|    119|                                  m_req_secret_buffer, secured_message_context->hash_size);
  127|       |
  128|    119|    request_size = spdm_test_context->test_buffer_size;
  129|    119|    if (request_size > sizeof(spdm_key_update_request_t)) {
  ------------------
  |  Branch (129:9): [True: 82, False: 37]
  ------------------
  130|     82|        request_size = sizeof(spdm_key_update_request_t);
  131|     82|    }
  132|       |
  133|    119|    response_size = sizeof(response);
  134|    119|    libspdm_get_encap_response_key_update(spdm_context, request_size,
  135|    119|                                          (uint8_t *)spdm_test_context->test_buffer,
  136|    119|                                          &response_size, response);
  137|    119|}
libspdm_run_test_harness:
  145|    119|{
  146|    119|    void *State;
  147|       |
  148|    119|    libspdm_setup_test_context(&m_libspdm_requester_encap_key_update_test_context);
  149|       |
  150|    119|    m_libspdm_requester_encap_key_update_test_context.test_buffer = test_buffer;
  151|    119|    m_libspdm_requester_encap_key_update_test_context.test_buffer_size = test_buffer_size;
  152|       |
  153|       |    /* Successful response*/
  154|    119|    libspdm_unit_test_group_setup(&State);
  155|    119|    libspdm_test_requester_encap_key_update(&State);
  156|    119|    libspdm_unit_test_group_teardown(&State);
  157|    119|}
encap_key_update.c:libspdm_set_standard_key_update_test_state:
   16|    119|{
   17|    119|    libspdm_session_info_t *session_info;
   18|       |
   19|    119|    spdm_context->response_state = LIBSPDM_RESPONSE_STATE_NORMAL;
   20|    119|    spdm_context->connection_info.connection_state = LIBSPDM_CONNECTION_STATE_NEGOTIATED;
   21|    119|    spdm_context->connection_info.capability.flags |=
   22|    119|        SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_KEY_UPD_CAP;
  ------------------
  |  |  257|    119|#define SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_KEY_UPD_CAP 0x00004000
  ------------------
   23|    119|    spdm_context->connection_info.capability.flags |=
   24|    119|        SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_ENCRYPT_CAP;
  ------------------
  |  |  248|    119|#define SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_ENCRYPT_CAP 0x00000040
  ------------------
   25|    119|    spdm_context->connection_info.capability.flags |= SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MAC_CAP;
  ------------------
  |  |  249|    119|#define SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_MAC_CAP 0x00000080
  ------------------
   26|    119|    spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_REQUEST_FLAGS_KEY_UPD_CAP;
  ------------------
  |  |  195|    119|#define SPDM_GET_CAPABILITIES_REQUEST_FLAGS_KEY_UPD_CAP 0x00004000
  ------------------
   27|    119|    spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_REQUEST_FLAGS_ENCRYPT_CAP;
  ------------------
  |  |  187|    119|#define SPDM_GET_CAPABILITIES_REQUEST_FLAGS_ENCRYPT_CAP 0x00000040
  ------------------
   28|    119|    spdm_context->local_context.capability.flags |= SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MAC_CAP;
  ------------------
  |  |  188|    119|#define SPDM_GET_CAPABILITIES_REQUEST_FLAGS_MAC_CAP 0x00000080
  ------------------
   29|       |
   30|    119|    spdm_context->transcript.message_a.buffer_size = 0;
   31|    119|    spdm_context->connection_info.algorithm.base_hash_algo = m_libspdm_use_hash_algo;
   32|    119|    spdm_context->connection_info.algorithm.base_asym_algo = m_libspdm_use_asym_algo;
   33|    119|    spdm_context->connection_info.algorithm.dhe_named_group = m_libspdm_use_dhe_algo;
   34|    119|    spdm_context->connection_info.algorithm.aead_cipher_suite = m_libspdm_use_aead_algo;
   35|       |
   36|    119|    *session_id = 0xFFFFFFFF;
   37|    119|    spdm_context->latest_session_id = *session_id;
   38|    119|    spdm_context->last_spdm_request_session_id_valid = true;
   39|    119|    spdm_context->last_spdm_request_session_id = *session_id;
   40|    119|    session_info = &spdm_context->session_info[0];
   41|    119|    libspdm_session_info_init(spdm_context, session_info, *session_id, true);
   42|    119|    libspdm_secured_message_set_session_state(session_info->secured_message_context,
   43|    119|                                              LIBSPDM_SESSION_STATE_ESTABLISHED);
   44|    119|}
encap_key_update.c:libspdm_set_standard_key_update_test_secrets:
   50|    119|{
   51|    119|    libspdm_set_mem(m_rsp_secret_buffer, secured_message_context->hash_size, rsp_secret_fill);
   52|    119|    libspdm_set_mem(m_req_secret_buffer, secured_message_context->hash_size, req_secret_fill);
   53|       |
   54|    119|    libspdm_copy_mem(secured_message_context->application_secret.response_data_secret,
   55|    119|                     sizeof(secured_message_context->application_secret.response_data_secret),
   56|    119|                     m_rsp_secret_buffer, secured_message_context->aead_key_size);
   57|       |
   58|    119|    libspdm_copy_mem(secured_message_context->application_secret.request_data_secret,
   59|    119|                     sizeof(secured_message_context->application_secret.request_data_secret),
   60|    119|                     m_req_secret_buffer, secured_message_context->aead_key_size);
   61|       |
   62|    119|    libspdm_set_mem(secured_message_context->application_secret.response_data_encryption_key,
   63|    119|                    secured_message_context->aead_key_size, (uint8_t)(0xFF));
   64|    119|    libspdm_set_mem(secured_message_context->application_secret.response_data_salt,
   65|    119|                    secured_message_context->aead_iv_size, (uint8_t)(0xFF));
   66|       |
   67|    119|    libspdm_set_mem(secured_message_context->application_secret.request_data_encryption_key,
   68|    119|                    secured_message_context->aead_key_size, (uint8_t)(0xEE));
   69|    119|    libspdm_set_mem(secured_message_context->application_secret.request_data_salt,
   70|    119|                    secured_message_context->aead_iv_size, (uint8_t)(0xEE));
   71|       |
   72|    119|    secured_message_context->application_secret.response_data_sequence_number = 0;
   73|    119|    secured_message_context->application_secret.request_data_sequence_number = 0;
   74|    119|}
encap_key_update.c:libspdm_compute_secret_update:
   79|    119|{
   80|    119|    uint8_t bin_str9[128];
   81|    119|    size_t bin_str9_size;
   82|       |
   83|    119|    bin_str9_size = sizeof(bin_str9);
   84|    119|    libspdm_bin_concat(spdm_version,
   85|    119|                       SPDM_BIN_STR_9_LABEL, sizeof(SPDM_BIN_STR_9_LABEL) - 1,
  ------------------
  |  | 1508|    119|#define SPDM_BIN_STR_9_LABEL "traffic upd"
  ------------------
                                     SPDM_BIN_STR_9_LABEL, sizeof(SPDM_BIN_STR_9_LABEL) - 1,
  ------------------
  |  | 1508|    119|#define SPDM_BIN_STR_9_LABEL "traffic upd"
  ------------------
   86|    119|                       NULL, (uint16_t)hash_size, hash_size, bin_str9,
   87|    119|                       &bin_str9_size);
   88|       |
   89|    119|    libspdm_hkdf_expand(m_libspdm_use_hash_algo, in_secret, hash_size, bin_str9, bin_str9_size,
   90|    119|                        out_secret, out_secret_size);
   91|    119|}

