ssh_agent_new:
  136|  17.2k|{
  137|  17.2k|    ssh_agent agent = NULL;
  138|       |
  139|  17.2k|    agent = calloc(1, sizeof(struct ssh_agent_struct));
  140|  17.2k|    if (agent == NULL) {
  ------------------
  |  Branch (140:9): [True: 0, False: 17.2k]
  ------------------
  141|      0|        return NULL;
  142|      0|    }
  143|       |
  144|  17.2k|    agent->count = 0;
  145|  17.2k|    agent->sock = ssh_socket_new(session);
  146|  17.2k|    if (agent->sock == NULL) {
  ------------------
  |  Branch (146:9): [True: 0, False: 17.2k]
  ------------------
  147|      0|        SAFE_FREE(agent);
  ------------------
  |  |  373|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
  148|      0|        return NULL;
  149|      0|    }
  150|  17.2k|    agent->channel = NULL;
  151|  17.2k|    return agent;
  152|  17.2k|}
ssh_agent_close:
  221|  17.2k|{
  222|  17.2k|    if (agent == NULL) {
  ------------------
  |  Branch (222:9): [True: 0, False: 17.2k]
  ------------------
  223|      0|        return;
  224|      0|    }
  225|       |
  226|  17.2k|    ssh_socket_close(agent->sock);
  227|  17.2k|}
ssh_agent_free:
  230|  17.2k|{
  231|  17.2k|    if (agent) {
  ------------------
  |  Branch (231:9): [True: 17.2k, False: 0]
  ------------------
  232|  17.2k|        if (agent->ident) {
  ------------------
  |  Branch (232:13): [True: 0, False: 17.2k]
  ------------------
  233|      0|            SSH_BUFFER_FREE(agent->ident);
  ------------------
  |  |  934|      0|    do { if ((x) != NULL) { ssh_buffer_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (934:14): [True: 0, False: 0]
  |  |  |  Branch (934:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
  234|      0|        }
  235|  17.2k|        if (agent->sock) {
  ------------------
  |  Branch (235:13): [True: 17.2k, False: 0]
  ------------------
  236|  17.2k|            ssh_agent_close(agent);
  237|  17.2k|            ssh_socket_free(agent->sock);
  238|  17.2k|        }
  239|       |        SAFE_FREE(agent);
  ------------------
  |  |  373|  17.2k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 17.2k, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 17.2k]
  |  |  ------------------
  ------------------
  240|  17.2k|    }
  241|  17.2k|}

ssh_packet_userauth_success:
  303|  8.64k|{
  304|  8.64k|  struct ssh_crypto_struct *crypto = NULL;
  305|       |
  306|  8.64k|  (void)packet;
  307|  8.64k|  (void)type;
  308|  8.64k|  (void)user;
  309|       |
  310|  8.64k|  SSH_LOG(SSH_LOG_DEBUG, "Authentication successful");
  ------------------
  |  |  281|  8.64k|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  311|  8.64k|  SSH_LOG(SSH_LOG_TRACE, "Received SSH_USERAUTH_SUCCESS");
  ------------------
  |  |  281|  8.64k|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  312|       |
  313|  8.64k|  session->auth.state = SSH_AUTH_STATE_SUCCESS;
  314|  8.64k|  session->session_state = SSH_SESSION_STATE_AUTHENTICATED;
  315|  8.64k|  session->flags |= SSH_SESSION_FLAG_AUTHENTICATED;
  ------------------
  |  |   78|  8.64k|#define SSH_SESSION_FLAG_AUTHENTICATED 0x0002
  ------------------
  316|       |
  317|  8.64k|  crypto = ssh_packet_get_current_crypto(session, SSH_DIRECTION_OUT);
  318|  8.64k|  if (crypto != NULL && crypto->delayed_compress_out) {
  ------------------
  |  Branch (318:7): [True: 8.64k, False: 0]
  |  Branch (318:25): [True: 0, False: 8.64k]
  ------------------
  319|      0|      SSH_LOG(SSH_LOG_DEBUG, "Enabling delayed compression OUT");
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  320|      0|      crypto->do_compress_out = 1;
  321|      0|  }
  322|       |
  323|  8.64k|  crypto = ssh_packet_get_current_crypto(session, SSH_DIRECTION_IN);
  324|  8.64k|  if (crypto != NULL && crypto->delayed_compress_in) {
  ------------------
  |  Branch (324:7): [True: 8.64k, False: 0]
  |  Branch (324:25): [True: 0, False: 8.64k]
  ------------------
  325|      0|      SSH_LOG(SSH_LOG_DEBUG, "Enabling delayed compression IN");
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  326|      0|      crypto->do_compress_in = 1;
  327|      0|  }
  328|       |
  329|       |    /* Reset errors by previous authentication methods. */
  330|  8.64k|    ssh_reset_error(session);
  331|  8.64k|    session->auth.current_method = SSH_AUTH_METHOD_UNKNOWN;
  ------------------
  |  |  155|  8.64k|#define SSH_AUTH_METHOD_UNKNOWN      0x0000u
  ------------------
  332|  8.64k|  return SSH_PACKET_USED;
  ------------------
  |  |  637|  8.64k|#define SSH_PACKET_USED 1
  ------------------
  333|  8.64k|}
ssh_userauth_none:
  423|  8.64k|{
  424|  8.64k|    int rc;
  425|       |
  426|  8.64k|    switch (session->pending_call_state) {
  427|  8.64k|        case SSH_PENDING_CALL_NONE:
  ------------------
  |  Branch (427:9): [True: 8.64k, False: 0]
  ------------------
  428|  8.64k|            break;
  429|      0|        case SSH_PENDING_CALL_AUTH_NONE:
  ------------------
  |  Branch (429:9): [True: 0, False: 8.64k]
  ------------------
  430|      0|            goto pending;
  431|      0|        default:
  ------------------
  |  Branch (431:9): [True: 0, False: 8.64k]
  ------------------
  432|      0|            ssh_set_error(session, SSH_FATAL,
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  433|      0|                          "Wrong state (%d) during pending SSH call",
  434|      0|                          session->pending_call_state);
  435|      0|            return SSH_AUTH_ERROR;
  436|  8.64k|    }
  437|       |
  438|  8.64k|    rc = ssh_userauth_request_service(session);
  439|  8.64k|    if (rc == SSH_AGAIN) {
  ------------------
  |  |  318|  8.64k|#define SSH_AGAIN -2 /* The nonblocking call must be repeated */
  ------------------
  |  Branch (439:9): [True: 0, False: 8.64k]
  ------------------
  440|      0|        return SSH_AUTH_AGAIN;
  441|  8.64k|    } else if (rc == SSH_ERROR) {
  ------------------
  |  |  317|  8.64k|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  |  Branch (441:16): [True: 0, False: 8.64k]
  ------------------
  442|      0|        return SSH_AUTH_ERROR;
  443|      0|    }
  444|       |
  445|       |    /* request */
  446|  8.64k|    rc = ssh_buffer_pack(session->out_buffer, "bsss",
  ------------------
  |  |   50|  17.2k|    _ssh_buffer_pack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |  451|  8.64k|        (__VA_NARG_(__VA_ARGS__, __RSEQ_N()))
  |  |  |  |  ------------------
  |  |  |  |  |  |  453|  8.64k|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  448|  8.64k|#define VA_APPLY_VARIADIC_MACRO(macro, tuple) macro tuple
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  453|  8.64k|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  461|  8.64k|        _61,_62,_63,N,...) N
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                   _ssh_buffer_pack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |   28|  8.64k|#define SSH_BUFFER_PACK_END ((uint32_t) 0x4f65feb3)
  |  |  ------------------
  |  |  |  Branch (50:68): [True: 0, False: 8.64k]
  |  |  ------------------
  ------------------
  447|  8.64k|            SSH2_MSG_USERAUTH_REQUEST,
  448|  8.64k|            username ? username : session->opts.username,
  449|  8.64k|            "ssh-connection",
  450|  8.64k|            "none"
  451|  8.64k|            );
  452|  8.64k|    if (rc < 0) {
  ------------------
  |  Branch (452:9): [True: 0, False: 8.64k]
  ------------------
  453|      0|        goto fail;
  454|      0|    }
  455|       |
  456|  8.64k|    session->auth.current_method = SSH_AUTH_METHOD_NONE;
  ------------------
  |  |  156|  8.64k|#define SSH_AUTH_METHOD_NONE         0x0001u
  ------------------
  457|  8.64k|    session->auth.state = SSH_AUTH_STATE_AUTH_NONE_SENT;
  458|  8.64k|    session->pending_call_state = SSH_PENDING_CALL_AUTH_NONE;
  459|  8.64k|    rc = ssh_packet_send(session);
  460|  8.64k|    if (rc == SSH_ERROR) {
  ------------------
  |  |  317|  8.64k|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  |  Branch (460:9): [True: 0, False: 8.64k]
  ------------------
  461|      0|        return SSH_AUTH_ERROR;
  462|      0|    }
  463|       |
  464|  8.64k|pending:
  465|  8.64k|    rc = ssh_userauth_get_response(session);
  466|  8.64k|    if (rc != SSH_AUTH_AGAIN) {
  ------------------
  |  Branch (466:9): [True: 8.64k, False: 0]
  ------------------
  467|  8.64k|        session->pending_call_state = SSH_PENDING_CALL_NONE;
  468|  8.64k|    }
  469|       |
  470|  8.64k|    return rc;
  471|      0|fail:
  472|      0|    ssh_set_error_oom(session);
  ------------------
  |  |  318|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
  473|      0|    ssh_buffer_reinit(session->out_buffer);
  474|       |
  475|      0|    return SSH_AUTH_ERROR;
  476|  8.64k|}
ssh_agent_state_free:
 1056|  17.2k|{
 1057|  17.2k|    struct ssh_agent_state_struct *state = data;
 1058|       |
 1059|  17.2k|    if (state) {
  ------------------
  |  Branch (1059:9): [True: 0, False: 17.2k]
  ------------------
 1060|       |        SSH_STRING_FREE_CHAR(state->comment);
  ------------------
  |  |  902|      0|    do { if ((x) != NULL) { ssh_string_free_char(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (902:14): [True: 0, False: 0]
  |  |  |  Branch (902:74): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1061|      0|        ssh_key_free(state->pubkey);
 1062|      0|        free(state);
 1063|      0|    }
 1064|  17.2k|}
auth.c:ssh_userauth_request_service:
   70|  8.64k|{
   71|  8.64k|    int rc;
   72|       |
   73|  8.64k|    rc = ssh_service_request(session, "ssh-userauth");
   74|  8.64k|    if ((rc != SSH_OK) && (rc != SSH_AGAIN)) {
  ------------------
  |  |  316|  8.64k|#define SSH_OK 0     /* No error */
  ------------------
                  if ((rc != SSH_OK) && (rc != SSH_AGAIN)) {
  ------------------
  |  |  318|      0|#define SSH_AGAIN -2 /* The nonblocking call must be repeated */
  ------------------
  |  Branch (74:9): [True: 0, False: 8.64k]
  |  Branch (74:27): [True: 0, False: 0]
  ------------------
   75|      0|        SSH_LOG(SSH_LOG_TRACE,
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
   76|      0|                "Failed to request \"ssh-userauth\" service");
   77|      0|    }
   78|       |
   79|  8.64k|    return rc;
   80|  8.64k|}
auth.c:ssh_userauth_get_response:
  151|  8.64k|{
  152|  8.64k|    int rc = SSH_AUTH_ERROR;
  153|       |
  154|  8.64k|    rc = ssh_handle_packets_termination(session, SSH_TIMEOUT_USER,
  ------------------
  |  |  101|  8.64k|#define SSH_TIMEOUT_USER -2
  ------------------
  155|  8.64k|        ssh_auth_response_termination, session);
  156|  8.64k|    if (rc == SSH_ERROR) {
  ------------------
  |  |  317|  8.64k|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  |  Branch (156:9): [True: 0, False: 8.64k]
  ------------------
  157|      0|        return SSH_AUTH_ERROR;
  158|      0|    }
  159|  8.64k|    if (!ssh_auth_response_termination(session)) {
  ------------------
  |  Branch (159:9): [True: 0, False: 8.64k]
  ------------------
  160|      0|        return SSH_AUTH_AGAIN;
  161|      0|    }
  162|       |
  163|  8.64k|    switch(session->auth.state) {
  ------------------
  |  Branch (163:12): [True: 8.64k, False: 0]
  ------------------
  164|      0|        case SSH_AUTH_STATE_ERROR:
  ------------------
  |  Branch (164:9): [True: 0, False: 8.64k]
  ------------------
  165|      0|            rc = SSH_AUTH_ERROR;
  166|      0|            break;
  167|      0|        case SSH_AUTH_STATE_FAILED:
  ------------------
  |  Branch (167:9): [True: 0, False: 8.64k]
  ------------------
  168|      0|            rc = SSH_AUTH_DENIED;
  169|      0|            break;
  170|      0|        case SSH_AUTH_STATE_INFO:
  ------------------
  |  Branch (170:9): [True: 0, False: 8.64k]
  ------------------
  171|      0|            rc = SSH_AUTH_INFO;
  172|      0|            break;
  173|      0|        case SSH_AUTH_STATE_PARTIAL:
  ------------------
  |  Branch (173:9): [True: 0, False: 8.64k]
  ------------------
  174|      0|            rc = SSH_AUTH_PARTIAL;
  175|      0|            break;
  176|      0|        case SSH_AUTH_STATE_PK_OK:
  ------------------
  |  Branch (176:9): [True: 0, False: 8.64k]
  ------------------
  177|  8.64k|        case SSH_AUTH_STATE_SUCCESS:
  ------------------
  |  Branch (177:9): [True: 8.64k, False: 0]
  ------------------
  178|  8.64k|            rc = SSH_AUTH_SUCCESS;
  179|  8.64k|            break;
  180|      0|        case SSH_AUTH_STATE_KBDINT_SENT:
  ------------------
  |  Branch (180:9): [True: 0, False: 8.64k]
  ------------------
  181|      0|        case SSH_AUTH_STATE_GSSAPI_REQUEST_SENT:
  ------------------
  |  Branch (181:9): [True: 0, False: 8.64k]
  ------------------
  182|      0|        case SSH_AUTH_STATE_GSSAPI_TOKEN:
  ------------------
  |  Branch (182:9): [True: 0, False: 8.64k]
  ------------------
  183|      0|        case SSH_AUTH_STATE_GSSAPI_MIC_SENT:
  ------------------
  |  Branch (183:9): [True: 0, False: 8.64k]
  ------------------
  184|      0|        case SSH_AUTH_STATE_GSSAPI_KEYEX_MIC_SENT:
  ------------------
  |  Branch (184:9): [True: 0, False: 8.64k]
  ------------------
  185|      0|        case SSH_AUTH_STATE_PUBKEY_OFFER_SENT:
  ------------------
  |  Branch (185:9): [True: 0, False: 8.64k]
  ------------------
  186|      0|        case SSH_AUTH_STATE_PUBKEY_AUTH_SENT:
  ------------------
  |  Branch (186:9): [True: 0, False: 8.64k]
  ------------------
  187|      0|        case SSH_AUTH_STATE_PASSWORD_AUTH_SENT:
  ------------------
  |  Branch (187:9): [True: 0, False: 8.64k]
  ------------------
  188|      0|        case SSH_AUTH_STATE_AUTH_NONE_SENT:
  ------------------
  |  Branch (188:9): [True: 0, False: 8.64k]
  ------------------
  189|      0|        case SSH_AUTH_STATE_NONE:
  ------------------
  |  Branch (189:9): [True: 0, False: 8.64k]
  ------------------
  190|       |            /* not reached */
  191|      0|            rc = SSH_AUTH_ERROR;
  192|      0|            break;
  193|  8.64k|    }
  194|       |
  195|  8.64k|    return rc;
  196|  8.64k|}
auth.c:ssh_auth_response_termination:
   83|  34.5k|{
   84|  34.5k|    ssh_session session = (ssh_session)user;
   85|  34.5k|    switch (session->auth.state) {
   86|      0|        case SSH_AUTH_STATE_NONE:
  ------------------
  |  Branch (86:9): [True: 0, False: 34.5k]
  ------------------
   87|      0|        case SSH_AUTH_STATE_KBDINT_SENT:
  ------------------
  |  Branch (87:9): [True: 0, False: 34.5k]
  ------------------
   88|      0|        case SSH_AUTH_STATE_GSSAPI_REQUEST_SENT:
  ------------------
  |  Branch (88:9): [True: 0, False: 34.5k]
  ------------------
   89|      0|        case SSH_AUTH_STATE_GSSAPI_TOKEN:
  ------------------
  |  Branch (89:9): [True: 0, False: 34.5k]
  ------------------
   90|      0|        case SSH_AUTH_STATE_GSSAPI_MIC_SENT:
  ------------------
  |  Branch (90:9): [True: 0, False: 34.5k]
  ------------------
   91|      0|        case SSH_AUTH_STATE_GSSAPI_KEYEX_MIC_SENT:
  ------------------
  |  Branch (91:9): [True: 0, False: 34.5k]
  ------------------
   92|      0|        case SSH_AUTH_STATE_PUBKEY_AUTH_SENT:
  ------------------
  |  Branch (92:9): [True: 0, False: 34.5k]
  ------------------
   93|      0|        case SSH_AUTH_STATE_PUBKEY_OFFER_SENT:
  ------------------
  |  Branch (93:9): [True: 0, False: 34.5k]
  ------------------
   94|      0|        case SSH_AUTH_STATE_PASSWORD_AUTH_SENT:
  ------------------
  |  Branch (94:9): [True: 0, False: 34.5k]
  ------------------
   95|  17.2k|        case SSH_AUTH_STATE_AUTH_NONE_SENT:
  ------------------
  |  Branch (95:9): [True: 17.2k, False: 17.2k]
  ------------------
   96|  17.2k|            return 0;
   97|  17.2k|        default:
  ------------------
  |  Branch (97:9): [True: 17.2k, False: 17.2k]
  ------------------
   98|  17.2k|            return 1;
   99|  34.5k|    }
  100|  34.5k|}

base64_to_bin:
   64|  8.64k|{
   65|  8.64k|    ssh_buffer buffer = NULL;
   66|  8.64k|    unsigned char block[3];
   67|  8.64k|    char *base64 = NULL;
   68|  8.64k|    char *ptr = NULL;
   69|  8.64k|    size_t len;
   70|  8.64k|    int equals;
   71|       |
   72|  8.64k|    base64 = strdup(source);
   73|  8.64k|    if (base64 == NULL) {
  ------------------
  |  Branch (73:9): [True: 0, False: 8.64k]
  ------------------
   74|      0|        return NULL;
   75|      0|    }
   76|  8.64k|    ptr = base64;
   77|       |
   78|       |    /* Get the number of equals signs, which mirrors the padding */
   79|  8.64k|    equals = get_equals(ptr);
   80|  8.64k|    if (equals > 2) {
  ------------------
  |  Branch (80:9): [True: 0, False: 8.64k]
  ------------------
   81|      0|        SAFE_FREE(base64);
  ------------------
  |  |  373|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
   82|      0|        return NULL;
   83|      0|    }
   84|       |
   85|  8.64k|    buffer = ssh_buffer_new();
   86|  8.64k|    if (buffer == NULL) {
  ------------------
  |  Branch (86:9): [True: 0, False: 8.64k]
  ------------------
   87|      0|        SAFE_FREE(base64);
  ------------------
  |  |  373|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
   88|      0|        return NULL;
   89|      0|    }
   90|       |    /*
   91|       |     * The base64 buffer often contains sensitive data. Make sure we don't leak
   92|       |     * sensitive data
   93|       |     */
   94|  8.64k|    ssh_buffer_set_secure(buffer);
   95|       |
   96|  8.64k|    len = strlen(ptr);
   97|   725k|    while (len > 4) {
  ------------------
  |  Branch (97:12): [True: 717k, False: 8.64k]
  ------------------
   98|   717k|        if (_base64_to_bin(block, ptr, 3) < 0) {
  ------------------
  |  Branch (98:13): [True: 0, False: 717k]
  ------------------
   99|      0|            goto error;
  100|      0|        }
  101|   717k|        if (ssh_buffer_add_data(buffer, block, 3) < 0) {
  ------------------
  |  Branch (101:13): [True: 0, False: 717k]
  ------------------
  102|      0|            goto error;
  103|      0|        }
  104|   717k|        len -= 4;
  105|   717k|        ptr += 4;
  106|   717k|    }
  107|       |
  108|       |    /*
  109|       |     * Depending on the number of bytes resting, there are 3 possibilities
  110|       |     * from the RFC.
  111|       |     */
  112|  8.64k|    switch (len) {
  113|       |    /*
  114|       |     * (1) The final quantum of encoding input is an integral multiple of
  115|       |     *     24 bits. Here, the final unit of encoded output will be an integral
  116|       |     *     multiple of 4 characters with no "=" padding
  117|       |     */
  118|      0|    case 4:
  ------------------
  |  Branch (118:5): [True: 0, False: 8.64k]
  ------------------
  119|      0|        if (equals != 0) {
  ------------------
  |  Branch (119:13): [True: 0, False: 0]
  ------------------
  120|      0|            goto error;
  121|      0|        }
  122|      0|        if (_base64_to_bin(block, ptr, 3) < 0) {
  ------------------
  |  Branch (122:13): [True: 0, False: 0]
  ------------------
  123|      0|            goto error;
  124|      0|        }
  125|      0|        if (ssh_buffer_add_data(buffer, block, 3) < 0) {
  ------------------
  |  Branch (125:13): [True: 0, False: 0]
  ------------------
  126|      0|            goto error;
  127|      0|        }
  128|      0|        SAFE_FREE(base64);
  ------------------
  |  |  373|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
  129|       |
  130|      0|        return buffer;
  131|       |    /*
  132|       |     * (2) The final quantum of encoding input is exactly 8 bits; here, the
  133|       |     *     final unit of encoded output will be two characters followed by
  134|       |     *     two "=" padding characters.
  135|       |     */
  136|  8.64k|    case 2:
  ------------------
  |  Branch (136:5): [True: 8.64k, False: 0]
  ------------------
  137|  8.64k|        if (equals != 2) {
  ------------------
  |  Branch (137:13): [True: 0, False: 8.64k]
  ------------------
  138|      0|            goto error;
  139|      0|        }
  140|       |
  141|  8.64k|        if (_base64_to_bin(block, ptr, 1) < 0) {
  ------------------
  |  Branch (141:13): [True: 0, False: 8.64k]
  ------------------
  142|      0|            goto error;
  143|      0|        }
  144|  8.64k|        if (ssh_buffer_add_data(buffer, block, 1) < 0) {
  ------------------
  |  Branch (144:13): [True: 0, False: 8.64k]
  ------------------
  145|      0|            goto error;
  146|      0|        }
  147|  8.64k|        SAFE_FREE(base64);
  ------------------
  |  |  373|  8.64k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 8.64k, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 8.64k]
  |  |  ------------------
  ------------------
  148|       |
  149|  8.64k|        return buffer;
  150|       |    /*
  151|       |     * The final quantum of encoding input is exactly 16 bits. Here, the final
  152|       |     * unit of encoded output will be three characters followed by one "="
  153|       |     * padding character.
  154|       |     */
  155|      0|    case 3:
  ------------------
  |  Branch (155:5): [True: 0, False: 8.64k]
  ------------------
  156|      0|        if (equals != 1) {
  ------------------
  |  Branch (156:13): [True: 0, False: 0]
  ------------------
  157|      0|            goto error;
  158|      0|        }
  159|      0|        if (_base64_to_bin(block, ptr, 2) < 0) {
  ------------------
  |  Branch (159:13): [True: 0, False: 0]
  ------------------
  160|      0|            goto error;
  161|      0|        }
  162|      0|        if (ssh_buffer_add_data(buffer, block, 2) < 0) {
  ------------------
  |  Branch (162:13): [True: 0, False: 0]
  ------------------
  163|      0|            goto error;
  164|      0|        }
  165|      0|        SAFE_FREE(base64);
  ------------------
  |  |  373|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
  166|       |
  167|      0|        return buffer;
  168|      0|    default:
  ------------------
  |  Branch (168:5): [True: 0, False: 8.64k]
  ------------------
  169|       |        /* 4,3,2 are the only padding size allowed */
  170|      0|        goto error;
  171|  8.64k|    }
  172|       |
  173|      0|error:
  174|      0|    SAFE_FREE(base64);
  ------------------
  |  |  373|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
  175|      0|    SSH_BUFFER_FREE(buffer);
  ------------------
  |  |  934|      0|    do { if ((x) != NULL) { ssh_buffer_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (934:14): [True: 0, False: 0]
  |  |  |  Branch (934:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
  176|       |    return NULL;
  177|  8.64k|}
base64.c:_base64_to_bin:
  216|   725k|{
  217|   725k|    unsigned long block;
  218|       |
  219|   725k|    if (to_block4(&block, source, num) < 0) {
  ------------------
  |  Branch (219:9): [True: 0, False: 725k]
  ------------------
  220|      0|        return -1;
  221|      0|    }
  222|   725k|    dest[0] = GET_A(block);
  ------------------
  |  |   46|   725k|#define GET_A(n) (unsigned char) (((n) & 0xff0000) >> 16)
  ------------------
  223|   725k|    dest[1] = GET_B(block);
  ------------------
  |  |   47|   725k|#define GET_B(n) (unsigned char) (((n) & 0xff00) >> 8)
  ------------------
  224|   725k|    dest[2] = GET_C(block);
  ------------------
  |  |   48|   725k|#define GET_C(n) (unsigned char) ((n) & 0xff)
  ------------------
  225|       |
  226|   725k|    return 0;
  227|   725k|}
base64.c:to_block4:
  187|   725k|{
  188|   725k|    const char *ptr = NULL;
  189|   725k|    size_t i;
  190|       |
  191|   725k|    *block = 0;
  192|   725k|    if (num < 1) {
  ------------------
  |  Branch (192:9): [True: 0, False: 725k]
  ------------------
  193|      0|        return 0;
  194|      0|    }
  195|       |
  196|   725k|    BLOCK(A, 0); /* 6 bit */
  ------------------
  |  |  179|   725k|#define BLOCK(letter, n) do {ptr = strchr((const char *)alphabet, source[n]); \
  |  |  180|   725k|                             if(!ptr) return -1; \
  |  |  ------------------
  |  |  |  Branch (180:33): [True: 0, False: 725k]
  |  |  ------------------
  |  |  181|   725k|                             i = ptr - (const char *)alphabet; \
  |  |  182|   725k|                             SET_##letter(*block, i); \
  |  |  ------------------
  |  |  |  |   41|   725k|#define SET_A(n, i) do { (n) |= ((i) & 63) <<18; } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (41:59): [Folded, False: 725k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  183|   725k|                         } while(0)
  |  |  ------------------
  |  |  |  Branch (183:34): [Folded, False: 725k]
  |  |  ------------------
  ------------------
  197|   725k|    BLOCK(B, 1); /* 12 bit */
  ------------------
  |  |  179|   725k|#define BLOCK(letter, n) do {ptr = strchr((const char *)alphabet, source[n]); \
  |  |  180|   725k|                             if(!ptr) return -1; \
  |  |  ------------------
  |  |  |  Branch (180:33): [True: 0, False: 725k]
  |  |  ------------------
  |  |  181|   725k|                             i = ptr - (const char *)alphabet; \
  |  |  182|   725k|                             SET_##letter(*block, i); \
  |  |  ------------------
  |  |  |  |   42|   725k|#define SET_B(n, i) do { (n) |= ((i) & 63) <<12; } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (42:59): [Folded, False: 725k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  183|   725k|                         } while(0)
  |  |  ------------------
  |  |  |  Branch (183:34): [Folded, False: 725k]
  |  |  ------------------
  ------------------
  198|       |
  199|   725k|    if (num < 2) {
  ------------------
  |  Branch (199:9): [True: 8.64k, False: 717k]
  ------------------
  200|  8.64k|        return 0;
  201|  8.64k|    }
  202|       |
  203|   717k|    BLOCK(C, 2); /* 18 bit */
  ------------------
  |  |  179|   717k|#define BLOCK(letter, n) do {ptr = strchr((const char *)alphabet, source[n]); \
  |  |  180|   717k|                             if(!ptr) return -1; \
  |  |  ------------------
  |  |  |  Branch (180:33): [True: 0, False: 717k]
  |  |  ------------------
  |  |  181|   717k|                             i = ptr - (const char *)alphabet; \
  |  |  182|   717k|                             SET_##letter(*block, i); \
  |  |  ------------------
  |  |  |  |   43|   717k|#define SET_C(n, i) do { (n) |= ((i) & 63) << 6; } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (43:59): [Folded, False: 717k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  183|   717k|                         } while(0)
  |  |  ------------------
  |  |  |  Branch (183:34): [Folded, False: 717k]
  |  |  ------------------
  ------------------
  204|       |
  205|   717k|    if (num < 3) {
  ------------------
  |  Branch (205:9): [True: 0, False: 717k]
  ------------------
  206|      0|        return 0;
  207|      0|    }
  208|       |
  209|   717k|    BLOCK(D, 3); /* 24 bit */
  ------------------
  |  |  179|   717k|#define BLOCK(letter, n) do {ptr = strchr((const char *)alphabet, source[n]); \
  |  |  180|   717k|                             if(!ptr) return -1; \
  |  |  ------------------
  |  |  |  Branch (180:33): [True: 0, False: 717k]
  |  |  ------------------
  |  |  181|   717k|                             i = ptr - (const char *)alphabet; \
  |  |  182|   717k|                             SET_##letter(*block, i); \
  |  |  ------------------
  |  |  |  |   44|   717k|#define SET_D(n, i) do { (n) |= ((i) & 63); } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (44:54): [Folded, False: 717k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  183|   717k|                         } while(0)
  |  |  ------------------
  |  |  |  Branch (183:34): [Folded, False: 717k]
  |  |  ------------------
  ------------------
  210|       |
  211|   717k|    return 0;
  212|   717k|}
base64.c:get_equals:
  231|  8.64k|{
  232|  8.64k|    char *ptr = string;
  233|  8.64k|    int num = 0;
  234|       |
  235|  25.9k|    while ((ptr = strchr(ptr, '=')) != NULL) {
  ------------------
  |  Branch (235:12): [True: 17.2k, False: 8.64k]
  ------------------
  236|  17.2k|        num++;
  237|  17.2k|        *ptr = '\0';
  238|  17.2k|        ptr++;
  239|  17.2k|    }
  240|       |
  241|  8.64k|    return num;
  242|  8.64k|}

ssh_bind_new:
  136|  8.64k|{
  137|  8.64k|    ssh_bind ptr = NULL;
  138|       |
  139|  8.64k|    ptr = calloc(1, sizeof(struct ssh_bind_struct));
  140|  8.64k|    if (ptr == NULL) {
  ------------------
  |  Branch (140:9): [True: 0, False: 8.64k]
  ------------------
  141|      0|        return NULL;
  142|      0|    }
  143|  8.64k|    ptr->bindfd = SSH_INVALID_SOCKET;
  ------------------
  |  |  124|  8.64k|#define SSH_INVALID_SOCKET ((socket_t) -1)
  ------------------
  144|  8.64k|    ptr->bindport = 22;
  145|  8.64k|    ptr->common.log_verbosity = 0;
  146|       |
  147|  8.64k|    return ptr;
  148|  8.64k|}
ssh_bind_free:
  372|  8.64k|void ssh_bind_free(ssh_bind sshbind){
  373|  8.64k|  int i;
  374|       |
  375|  8.64k|  if (sshbind == NULL) {
  ------------------
  |  Branch (375:7): [True: 0, False: 8.64k]
  ------------------
  376|      0|    return;
  377|      0|  }
  378|       |
  379|  8.64k|  if (sshbind->bindfd >= 0) {
  ------------------
  |  Branch (379:7): [True: 0, False: 8.64k]
  ------------------
  380|      0|      CLOSE_SOCKET(sshbind->bindfd);
  ------------------
  |  |  472|      0|#define CLOSE_SOCKET(s) do { if ((s) != SSH_INVALID_SOCKET) { _XCLOSESOCKET(s); (s) = SSH_INVALID_SOCKET;} } while(0)
  |  |  ------------------
  |  |  |  |  124|      0|#define SSH_INVALID_SOCKET ((socket_t) -1)
  |  |  ------------------
  |  |               #define CLOSE_SOCKET(s) do { if ((s) != SSH_INVALID_SOCKET) { _XCLOSESOCKET(s); (s) = SSH_INVALID_SOCKET;} } while(0)
  |  |  ------------------
  |  |  |  |  199|      0|#define _XCLOSESOCKET close
  |  |  ------------------
  |  |               #define CLOSE_SOCKET(s) do { if ((s) != SSH_INVALID_SOCKET) { _XCLOSESOCKET(s); (s) = SSH_INVALID_SOCKET;} } while(0)
  |  |  ------------------
  |  |  |  |  124|      0|#define SSH_INVALID_SOCKET ((socket_t) -1)
  |  |  ------------------
  |  |  |  Branch (472:34): [True: 0, False: 0]
  |  |  |  Branch (472:116): [Folded, False: 0]
  |  |  ------------------
  ------------------
  381|      0|  }
  382|  8.64k|  sshbind->bindfd = SSH_INVALID_SOCKET;
  ------------------
  |  |  124|  8.64k|#define SSH_INVALID_SOCKET ((socket_t) -1)
  ------------------
  383|       |
  384|       |  /* options */
  385|  8.64k|  SAFE_FREE(sshbind->banner);
  ------------------
  |  |  373|  8.64k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 8.64k]
  |  |  |  Branch (373:71): [Folded, False: 8.64k]
  |  |  ------------------
  ------------------
  386|  8.64k|  SAFE_FREE(sshbind->moduli_file);
  ------------------
  |  |  373|  8.64k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 8.64k]
  |  |  |  Branch (373:71): [Folded, False: 8.64k]
  |  |  ------------------
  ------------------
  387|  8.64k|  SAFE_FREE(sshbind->bindaddr);
  ------------------
  |  |  373|  8.64k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 8.64k]
  |  |  |  Branch (373:71): [Folded, False: 8.64k]
  |  |  ------------------
  ------------------
  388|  8.64k|  SAFE_FREE(sshbind->config_dir);
  ------------------
  |  |  373|  8.64k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 8.64k]
  |  |  |  Branch (373:71): [Folded, False: 8.64k]
  |  |  ------------------
  ------------------
  389|  8.64k|  SAFE_FREE(sshbind->pubkey_accepted_key_types);
  ------------------
  |  |  373|  8.64k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 8.64k]
  |  |  |  Branch (373:71): [Folded, False: 8.64k]
  |  |  ------------------
  ------------------
  390|       |
  391|  8.64k|  SAFE_FREE(sshbind->rsakey);
  ------------------
  |  |  373|  8.64k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 8.64k]
  |  |  |  Branch (373:71): [Folded, False: 8.64k]
  |  |  ------------------
  ------------------
  392|  8.64k|  SAFE_FREE(sshbind->ecdsakey);
  ------------------
  |  |  373|  8.64k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 8.64k]
  |  |  |  Branch (373:71): [Folded, False: 8.64k]
  |  |  ------------------
  ------------------
  393|  8.64k|  SAFE_FREE(sshbind->ed25519key);
  ------------------
  |  |  373|  8.64k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 8.64k, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 8.64k]
  |  |  ------------------
  ------------------
  394|  8.64k|  SAFE_FREE(sshbind->gssapi_key_exchange_algs);
  ------------------
  |  |  373|  8.64k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 8.64k]
  |  |  |  Branch (373:71): [Folded, False: 8.64k]
  |  |  ------------------
  ------------------
  395|       |
  396|  8.64k|  ssh_key_free(sshbind->rsa);
  397|  8.64k|  sshbind->rsa = NULL;
  398|  8.64k|  ssh_key_free(sshbind->ecdsa);
  399|  8.64k|  sshbind->ecdsa = NULL;
  400|  8.64k|  ssh_key_free(sshbind->ed25519);
  401|  8.64k|  sshbind->ed25519 = NULL;
  402|       |
  403|  95.0k|  for (i = 0; i < SSH_KEX_METHODS; i++) {
  ------------------
  |  |   27|  95.0k|#define SSH_KEX_METHODS 10
  ------------------
  |  Branch (403:15): [True: 86.4k, False: 8.64k]
  ------------------
  404|  86.4k|    if (sshbind->wanted_methods[i]) {
  ------------------
  |  Branch (404:9): [True: 34.5k, False: 51.8k]
  ------------------
  405|  34.5k|      SAFE_FREE(sshbind->wanted_methods[i]);
  ------------------
  |  |  373|  34.5k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 34.5k, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 34.5k]
  |  |  ------------------
  ------------------
  406|  34.5k|    }
  407|  86.4k|  }
  408|       |
  409|       |  SAFE_FREE(sshbind);
  ------------------
  |  |  373|  8.64k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 8.64k, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 8.64k]
  |  |  ------------------
  ------------------
  410|  8.64k|}
ssh_bind_accept_fd:
  413|  8.64k|{
  414|  8.64k|    ssh_poll_handle handle = NULL;
  415|  8.64k|    int i, rc;
  416|       |
  417|  8.64k|    if (sshbind == NULL) {
  ------------------
  |  Branch (417:9): [True: 0, False: 8.64k]
  ------------------
  418|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  419|      0|    }
  420|       |
  421|  8.64k|    if (session == NULL){
  ------------------
  |  Branch (421:9): [True: 0, False: 8.64k]
  ------------------
  422|      0|        ssh_set_error(sshbind, SSH_FATAL,"session is null");
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  423|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  424|      0|    }
  425|       |
  426|  8.64k|    session->server = 1;
  427|       |
  428|       |    /* Copy options from bind to session */
  429|  95.0k|    for (i = 0; i < SSH_KEX_METHODS; i++) {
  ------------------
  |  |   27|  95.0k|#define SSH_KEX_METHODS 10
  ------------------
  |  Branch (429:17): [True: 86.4k, False: 8.64k]
  ------------------
  430|  86.4k|      if (sshbind->wanted_methods[i]) {
  ------------------
  |  Branch (430:11): [True: 34.5k, False: 51.8k]
  ------------------
  431|  34.5k|        session->opts.wanted_methods[i] = strdup(sshbind->wanted_methods[i]);
  432|  34.5k|        if (session->opts.wanted_methods[i] == NULL) {
  ------------------
  |  Branch (432:13): [True: 0, False: 34.5k]
  ------------------
  433|      0|          return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  434|      0|        }
  435|  34.5k|      }
  436|  86.4k|    }
  437|       |
  438|  8.64k|    if (sshbind->bindaddr == NULL)
  ------------------
  |  Branch (438:9): [True: 8.64k, False: 0]
  ------------------
  439|  8.64k|      session->opts.bindaddr = NULL;
  440|      0|    else {
  441|      0|      SAFE_FREE(session->opts.bindaddr);
  ------------------
  |  |  373|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
  442|      0|      session->opts.bindaddr = strdup(sshbind->bindaddr);
  443|      0|      if (session->opts.bindaddr == NULL) {
  ------------------
  |  Branch (443:11): [True: 0, False: 0]
  ------------------
  444|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  445|      0|      }
  446|      0|    }
  447|       |
  448|  8.64k|    if (sshbind->pubkey_accepted_key_types != NULL) {
  ------------------
  |  Branch (448:9): [True: 0, False: 8.64k]
  ------------------
  449|      0|        if (session->opts.pubkey_accepted_types == NULL) {
  ------------------
  |  Branch (449:13): [True: 0, False: 0]
  ------------------
  450|      0|            session->opts.pubkey_accepted_types = strdup(sshbind->pubkey_accepted_key_types);
  451|      0|            if (session->opts.pubkey_accepted_types == NULL) {
  ------------------
  |  Branch (451:17): [True: 0, False: 0]
  ------------------
  452|      0|                ssh_set_error_oom(sshbind);
  ------------------
  |  |  318|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
  453|      0|                return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  454|      0|            }
  455|      0|        } else {
  456|      0|            char *p = NULL;
  457|       |            /* If something was set to the session prior to calling this
  458|       |             * function, keep only what is allowed by the options set in
  459|       |             * sshbind */
  460|      0|            p = ssh_find_all_matching(sshbind->pubkey_accepted_key_types,
  461|      0|                                      session->opts.pubkey_accepted_types);
  462|      0|            if (p == NULL) {
  ------------------
  |  Branch (462:17): [True: 0, False: 0]
  ------------------
  463|      0|                return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  464|      0|            }
  465|       |
  466|      0|            SAFE_FREE(session->opts.pubkey_accepted_types);
  ------------------
  |  |  373|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
  467|      0|            session->opts.pubkey_accepted_types = p;
  468|      0|        }
  469|      0|    }
  470|       |
  471|  8.64k|    session->common.log_verbosity = sshbind->common.log_verbosity;
  472|  8.64k|    session->opts.gssapi_key_exchange = sshbind->gssapi_key_exchange;
  473|       |
  474|  8.64k|    if (sshbind->gssapi_key_exchange_algs != NULL) {
  ------------------
  |  Branch (474:9): [True: 0, False: 8.64k]
  ------------------
  475|      0|        SAFE_FREE(session->opts.gssapi_key_exchange_algs);
  ------------------
  |  |  373|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
  476|      0|        session->opts.gssapi_key_exchange_algs =
  477|      0|            strdup(sshbind->gssapi_key_exchange_algs);
  478|      0|        if (session->opts.gssapi_key_exchange_algs == NULL) {
  ------------------
  |  Branch (478:13): [True: 0, False: 0]
  ------------------
  479|      0|            ssh_set_error_oom(sshbind);
  ------------------
  |  |  318|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
  480|      0|            return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  481|      0|        }
  482|      0|    }
  483|       |
  484|  8.64k|    if (sshbind->banner != NULL) {
  ------------------
  |  Branch (484:9): [True: 0, False: 8.64k]
  ------------------
  485|      0|        session->server_opts.custombanner = strdup(sshbind->banner);
  486|      0|        if (session->server_opts.custombanner == NULL) {
  ------------------
  |  Branch (486:13): [True: 0, False: 0]
  ------------------
  487|      0|            ssh_set_error_oom(sshbind);
  ------------------
  |  |  318|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
  488|      0|            return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  489|      0|        }
  490|      0|    }
  491|       |
  492|  8.64k|    if (sshbind->moduli_file != NULL) {
  ------------------
  |  Branch (492:9): [True: 0, False: 8.64k]
  ------------------
  493|      0|        session->server_opts.moduli_file = strdup(sshbind->moduli_file);
  494|      0|        if (session->server_opts.moduli_file == NULL) {
  ------------------
  |  Branch (494:13): [True: 0, False: 0]
  ------------------
  495|      0|            ssh_set_error_oom(sshbind);
  ------------------
  |  |  318|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
  496|      0|            return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  497|      0|        }
  498|      0|    }
  499|       |
  500|  8.64k|    session->opts.rsa_min_size = sshbind->rsa_min_size;
  501|       |
  502|  8.64k|    ssh_socket_free(session->socket);
  503|  8.64k|    session->socket = ssh_socket_new(session);
  504|  8.64k|    if (session->socket == NULL) {
  ------------------
  |  Branch (504:9): [True: 0, False: 8.64k]
  ------------------
  505|       |      /* perhaps it may be better to copy the error from session to sshbind */
  506|      0|      ssh_set_error_oom(sshbind);
  ------------------
  |  |  318|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
  507|      0|      return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  508|      0|    }
  509|  8.64k|    rc = ssh_socket_set_fd(session->socket, fd);
  510|  8.64k|    if (rc != SSH_OK) {
  ------------------
  |  |  316|  8.64k|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (510:9): [True: 0, False: 8.64k]
  ------------------
  511|      0|        return rc;
  512|      0|    }
  513|  8.64k|    handle = ssh_socket_get_poll_handle(session->socket);
  514|  8.64k|    if (handle == NULL) {
  ------------------
  |  Branch (514:9): [True: 0, False: 8.64k]
  ------------------
  515|      0|        ssh_set_error_oom(sshbind);
  ------------------
  |  |  318|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
  516|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  517|      0|    }
  518|  8.64k|    ssh_socket_set_connected(session->socket, handle);
  519|       |
  520|       |    /* We must try to import any keys that could be imported in case
  521|       |     * we are not using ssh_bind_listen (which is the other place
  522|       |     * where keys can be imported) on this ssh_bind and are instead
  523|       |     * only using ssh_bind_accept_fd to manage sockets ourselves.
  524|       |     */
  525|  8.64k|    if (sshbind->rsa == NULL &&
  ------------------
  |  Branch (525:9): [True: 8.64k, False: 0]
  ------------------
  526|  8.64k|        sshbind->ecdsa == NULL &&
  ------------------
  |  Branch (526:9): [True: 8.64k, False: 0]
  ------------------
  527|  8.64k|        sshbind->ed25519 == NULL) {
  ------------------
  |  Branch (527:9): [True: 0, False: 8.64k]
  ------------------
  528|      0|        rc = ssh_bind_import_keys(sshbind);
  529|      0|        if (rc == SSH_ERROR) {
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  |  Branch (529:13): [True: 0, False: 0]
  ------------------
  530|      0|            if (!sshbind->gssapi_key_exchange) {
  ------------------
  |  Branch (530:17): [True: 0, False: 0]
  ------------------
  531|      0|                ssh_set_error(sshbind, SSH_FATAL, "No usable hostkeys found");
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  532|      0|                return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  533|      0|            }
  534|      0|            SSH_LOG(SSH_LOG_DEBUG,
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  535|      0|                    "No usable hostkeys found: Using \"null\" hostkey algorithm");
  536|      0|        }
  537|      0|    }
  538|       |
  539|  8.64k|#ifdef HAVE_ECC
  540|  8.64k|    if (sshbind->ecdsa) {
  ------------------
  |  Branch (540:9): [True: 0, False: 8.64k]
  ------------------
  541|      0|        session->srv.ecdsa_key = ssh_key_dup(sshbind->ecdsa);
  542|      0|        if (session->srv.ecdsa_key == NULL) {
  ------------------
  |  Branch (542:13): [True: 0, False: 0]
  ------------------
  543|      0|          ssh_set_error_oom(sshbind);
  ------------------
  |  |  318|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
  544|      0|          return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  545|      0|        }
  546|      0|    }
  547|  8.64k|#endif
  548|  8.64k|    if (sshbind->rsa) {
  ------------------
  |  Branch (548:9): [True: 0, False: 8.64k]
  ------------------
  549|      0|        session->srv.rsa_key = ssh_key_dup(sshbind->rsa);
  550|      0|        if (session->srv.rsa_key == NULL) {
  ------------------
  |  Branch (550:13): [True: 0, False: 0]
  ------------------
  551|      0|          ssh_set_error_oom(sshbind);
  ------------------
  |  |  318|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
  552|      0|          return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  553|      0|        }
  554|      0|    }
  555|  8.64k|    if (sshbind->ed25519 != NULL) {
  ------------------
  |  Branch (555:9): [True: 8.64k, False: 0]
  ------------------
  556|  8.64k|        session->srv.ed25519_key = ssh_key_dup(sshbind->ed25519);
  557|  8.64k|        if (session->srv.ed25519_key == NULL){
  ------------------
  |  Branch (557:13): [True: 0, False: 8.64k]
  ------------------
  558|      0|            ssh_set_error_oom(sshbind);
  ------------------
  |  |  318|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
  559|      0|            return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  560|      0|        }
  561|  8.64k|    }
  562|       |
  563|       |    /* force PRNG to change state in case we fork after ssh_bind_accept */
  564|  8.64k|    ssh_reseed();
  565|  8.64k|    return SSH_OK;
  ------------------
  |  |  316|  8.64k|#define SSH_OK 0     /* No error */
  ------------------
  566|  8.64k|}

ssh_buffer_new:
  126|   362k|{
  127|   362k|    struct ssh_buffer_struct *buf = NULL;
  128|   362k|    int rc;
  129|       |
  130|   362k|    buf = calloc(1, sizeof(struct ssh_buffer_struct));
  131|   362k|    if (buf == NULL) {
  ------------------
  |  Branch (131:9): [True: 0, False: 362k]
  ------------------
  132|      0|        return NULL;
  133|      0|    }
  134|       |
  135|       |    /*
  136|       |     * Always preallocate 64 bytes.
  137|       |     *
  138|       |     * -1 for realloc_buffer magic.
  139|       |     */
  140|   362k|    rc = ssh_buffer_allocate_size(buf, 64 - 1);
  141|   362k|    if (rc != 0) {
  ------------------
  |  Branch (141:9): [True: 0, False: 362k]
  ------------------
  142|      0|        SAFE_FREE(buf);
  ------------------
  |  |  373|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
  143|      0|        return NULL;
  144|      0|    }
  145|   362k|    buffer_verify(buf);
  146|       |
  147|   362k|    return buf;
  148|   362k|}
ssh_buffer_free:
  156|   362k|{
  157|   362k|    if (buffer == NULL) {
  ------------------
  |  Branch (157:9): [True: 0, False: 362k]
  ------------------
  158|      0|        return;
  159|      0|    }
  160|   362k|    buffer_verify(buffer);
  161|       |
  162|   362k|    if (buffer->secure && buffer->allocated > 0) {
  ------------------
  |  Branch (162:9): [True: 77.7k, False: 285k]
  |  Branch (162:27): [True: 77.7k, False: 0]
  ------------------
  163|       |        /* burn the data */
  164|  77.7k|        ssh_burn(buffer->data, buffer->allocated);
  ------------------
  |  |  388|  77.7k|#define ssh_burn(ptr, len) explicit_bzero((ptr), (len))
  ------------------
  165|  77.7k|        SAFE_FREE(buffer->data);
  ------------------
  |  |  373|  77.7k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 77.7k, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 77.7k]
  |  |  ------------------
  ------------------
  166|       |
  167|  77.7k|        ssh_burn(buffer, sizeof(struct ssh_buffer_struct));
  ------------------
  |  |  388|  77.7k|#define ssh_burn(ptr, len) explicit_bzero((ptr), (len))
  ------------------
  168|   285k|    } else {
  169|   285k|        SAFE_FREE(buffer->data);
  ------------------
  |  |  373|   285k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 285k, False: 18.4E]
  |  |  |  Branch (373:71): [Folded, False: 285k]
  |  |  ------------------
  ------------------
  170|   285k|    }
  171|       |    SAFE_FREE(buffer);
  ------------------
  |  |  373|   362k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 362k, False: 18.4E]
  |  |  |  Branch (373:71): [Folded, False: 362k]
  |  |  ------------------
  ------------------
  172|   362k|}
ssh_buffer_set_secure:
  183|  77.7k|{
  184|       |    buffer->secure = true;
  185|  77.7k|}
ssh_buffer_reinit:
  266|   472k|{
  267|   472k|    if (buffer == NULL) {
  ------------------
  |  Branch (267:9): [True: 0, False: 472k]
  ------------------
  268|      0|        return -1;
  269|      0|    }
  270|       |
  271|   472k|    buffer_verify(buffer);
  272|       |
  273|   472k|    if (buffer->secure && buffer->allocated > 0) {
  ------------------
  |  Branch (273:9): [True: 0, False: 472k]
  |  Branch (273:27): [True: 0, False: 0]
  ------------------
  274|      0|        ssh_burn(buffer->data, buffer->allocated);
  ------------------
  |  |  388|      0|#define ssh_burn(ptr, len) explicit_bzero((ptr), (len))
  ------------------
  275|      0|    }
  276|   472k|    buffer->used = 0;
  277|   472k|    buffer->pos = 0;
  278|       |
  279|       |    /* If the buffer is bigger then 64K, reset it to 64K */
  280|   472k|    if (buffer->allocated > 65536) {
  ------------------
  |  Branch (280:9): [True: 2.56k, False: 469k]
  ------------------
  281|  2.56k|        int rc;
  282|       |
  283|       |        /* -1 for realloc_buffer magic */
  284|  2.56k|        rc = realloc_buffer(buffer, 65536 - 1);
  285|  2.56k|        if (rc != 0) {
  ------------------
  |  Branch (285:13): [True: 0, False: 2.56k]
  ------------------
  286|      0|            return -1;
  287|      0|        }
  288|  2.56k|    }
  289|       |
  290|   472k|    buffer_verify(buffer);
  291|       |
  292|   472k|    return 0;
  293|   472k|}
ssh_buffer_add_data:
  307|  3.34M|{
  308|  3.34M|    if (buffer == NULL) {
  ------------------
  |  Branch (308:9): [True: 0, False: 3.34M]
  ------------------
  309|      0|        return -1;
  310|      0|    }
  311|       |
  312|  3.34M|    buffer_verify(buffer);
  313|       |
  314|  3.34M|    if (data == NULL) {
  ------------------
  |  Branch (314:9): [True: 0, False: 3.34M]
  ------------------
  315|      0|        return -1;
  316|      0|    }
  317|       |
  318|  3.34M|    if (buffer->used + len < len) {
  ------------------
  |  Branch (318:9): [True: 0, False: 3.34M]
  ------------------
  319|      0|        return -1;
  320|      0|    }
  321|       |
  322|  3.34M|    if (buffer->allocated < (buffer->used + len)) {
  ------------------
  |  Branch (322:9): [True: 226k, False: 3.11M]
  ------------------
  323|   226k|        if (buffer->pos > 0) {
  ------------------
  |  Branch (323:13): [True: 0, False: 226k]
  ------------------
  324|      0|            buffer_shift(buffer);
  325|      0|        }
  326|   226k|        if (realloc_buffer(buffer, buffer->used + len) < 0) {
  ------------------
  |  Branch (326:13): [True: 0, False: 226k]
  ------------------
  327|      0|            return -1;
  328|      0|        }
  329|   226k|    }
  330|       |
  331|  3.34M|    memcpy(buffer->data + buffer->used, data, len);
  332|  3.34M|    buffer->used += len;
  333|  3.34M|    buffer_verify(buffer);
  334|  3.34M|    return 0;
  335|  3.34M|}
ssh_buffer_allocate_size:
  348|   800k|{
  349|   800k|    buffer_verify(buffer);
  350|       |
  351|   800k|    if (buffer->allocated < len) {
  ------------------
  |  Branch (351:9): [True: 429k, False: 370k]
  ------------------
  352|   429k|        if (buffer->pos > 0) {
  ------------------
  |  Branch (352:13): [True: 0, False: 429k]
  ------------------
  353|      0|            buffer_shift(buffer);
  354|      0|        }
  355|   429k|        if (realloc_buffer(buffer, len) < 0) {
  ------------------
  |  Branch (355:13): [True: 0, False: 429k]
  ------------------
  356|      0|            return -1;
  357|      0|        }
  358|   429k|    }
  359|       |
  360|   800k|    buffer_verify(buffer);
  361|       |
  362|   800k|    return 0;
  363|   800k|}
ssh_buffer_allocate:
  378|   842k|{
  379|   842k|    void *ptr = NULL;
  380|       |
  381|   842k|    buffer_verify(buffer);
  382|       |
  383|   842k|    if (buffer->used + len < len) {
  ------------------
  |  Branch (383:9): [True: 0, False: 842k]
  ------------------
  384|      0|        return NULL;
  385|      0|    }
  386|       |
  387|   842k|    if (buffer->allocated < (buffer->used + len)) {
  ------------------
  |  Branch (387:9): [True: 105k, False: 736k]
  ------------------
  388|   105k|        if (buffer->pos > 0) {
  ------------------
  |  Branch (388:13): [True: 30.9k, False: 74.3k]
  ------------------
  389|  30.9k|            buffer_shift(buffer);
  390|  30.9k|        }
  391|       |
  392|   105k|        if (realloc_buffer(buffer, buffer->used + len) < 0) {
  ------------------
  |  Branch (392:13): [True: 0, False: 105k]
  ------------------
  393|      0|            return NULL;
  394|      0|        }
  395|   105k|    }
  396|       |
  397|   842k|    ptr = buffer->data + buffer->used;
  398|   842k|    buffer->used+=len;
  399|   842k|    buffer_verify(buffer);
  400|       |
  401|   842k|    return ptr;
  402|   842k|}
ssh_buffer_add_ssh_string:
  418|   673k|{
  419|   673k|    size_t len;
  420|   673k|    int rc;
  421|       |
  422|   673k|    if (string == NULL) {
  ------------------
  |  Branch (422:9): [True: 0, False: 673k]
  ------------------
  423|      0|        return -1;
  424|      0|    }
  425|       |
  426|   673k|    len = ssh_string_len(string) + sizeof(uint32_t);
  427|       |    /* this can't overflow the uint32_t as the
  428|       |     * STRING_SIZE_MAX is (UINT32_MAX >> 8) + 1 */
  429|   673k|    rc = ssh_buffer_add_data(buffer, string, (uint32_t)len);
  430|   673k|    if (rc < 0) {
  ------------------
  |  Branch (430:9): [True: 0, False: 673k]
  ------------------
  431|      0|        return -1;
  432|      0|    }
  433|       |
  434|   673k|    return 0;
  435|   673k|}
ssh_buffer_add_u32:
  449|   515k|{
  450|   515k|    int rc;
  451|       |
  452|   515k|    rc = ssh_buffer_add_data(buffer, &data, sizeof(data));
  453|   515k|    if (rc < 0) {
  ------------------
  |  Branch (453:9): [True: 0, False: 515k]
  ------------------
  454|      0|        return -1;
  455|      0|    }
  456|       |
  457|   515k|    return 0;
  458|   515k|}
ssh_buffer_add_u8:
  518|   313k|{
  519|   313k|    int rc;
  520|       |
  521|   313k|    rc = ssh_buffer_add_data(buffer, &data, sizeof(uint8_t));
  522|   313k|    if (rc < 0) {
  ------------------
  |  Branch (522:9): [True: 0, False: 313k]
  ------------------
  523|      0|        return -1;
  524|      0|    }
  525|       |
  526|   313k|    return 0;
  527|   313k|}
ssh_buffer_prepend_data:
  543|   210k|    uint32_t len) {
  544|   210k|  buffer_verify(buffer);
  545|       |
  546|   210k|  if(len <= buffer->pos){
  ------------------
  |  Branch (546:6): [True: 0, False: 210k]
  ------------------
  547|       |    /* It's possible to insert data between begin and pos */
  548|      0|    memcpy(buffer->data + (buffer->pos - len), data, len);
  549|      0|    buffer->pos -= len;
  550|      0|    buffer_verify(buffer);
  551|      0|    return 0;
  552|      0|  }
  553|       |  /* pos isn't high enough */
  554|   210k|  if (buffer->used - buffer->pos + len < len) {
  ------------------
  |  Branch (554:7): [True: 0, False: 210k]
  ------------------
  555|      0|    return -1;
  556|      0|  }
  557|       |
  558|   210k|  if (buffer->allocated < (buffer->used - buffer->pos + len)) {
  ------------------
  |  Branch (558:7): [True: 936, False: 209k]
  ------------------
  559|    936|    if (realloc_buffer(buffer, buffer->used - buffer->pos + len) < 0) {
  ------------------
  |  Branch (559:9): [True: 0, False: 936]
  ------------------
  560|      0|      return -1;
  561|      0|    }
  562|    936|  }
  563|   210k|  memmove(buffer->data + len, buffer->data + buffer->pos, buffer->used - buffer->pos);
  564|   210k|  memcpy(buffer->data, data, len);
  565|   210k|  buffer->used += len - buffer->pos;
  566|   210k|  buffer->pos = 0;
  567|   210k|  buffer_verify(buffer);
  568|   210k|  return 0;
  569|   210k|}
ssh_buffer_get:
  607|  1.93M|void *ssh_buffer_get(struct ssh_buffer_struct *buffer){
  608|  1.93M|    return buffer->data + buffer->pos;
  609|  1.93M|}
ssh_buffer_get_len:
  620|  4.20M|uint32_t ssh_buffer_get_len(struct ssh_buffer_struct *buffer){
  621|  4.20M|  buffer_verify(buffer);
  622|  4.20M|  return buffer->used - buffer->pos;
  623|  4.20M|}
ssh_buffer_pass_bytes:
  685|  1.03M|uint32_t ssh_buffer_pass_bytes(struct ssh_buffer_struct *buffer, uint32_t len){
  686|  1.03M|    buffer_verify(buffer);
  687|       |
  688|  1.03M|    if (buffer->pos + len < len || buffer->used < buffer->pos + len) {
  ------------------
  |  Branch (688:9): [True: 18.4E, False: 1.03M]
  |  Branch (688:36): [True: 18.4E, False: 1.03M]
  ------------------
  689|      0|        return 0;
  690|      0|    }
  691|       |
  692|  1.03M|    buffer->pos+=len;
  693|       |    /* if the buffer is empty after having passed the whole bytes into it, we can clean it */
  694|  1.03M|    if(buffer->pos==buffer->used){
  ------------------
  |  Branch (694:8): [True: 457k, False: 578k]
  ------------------
  695|   457k|        buffer->pos=0;
  696|   457k|        buffer->used=0;
  697|   457k|    }
  698|  1.03M|    buffer_verify(buffer);
  699|  1.03M|    return len;
  700|  1.03M|}
ssh_buffer_pass_bytes_end:
  713|   657k|uint32_t ssh_buffer_pass_bytes_end(struct ssh_buffer_struct *buffer, uint32_t len){
  714|   657k|  buffer_verify(buffer);
  715|       |
  716|   657k|  if (buffer->used < len) {
  ------------------
  |  Branch (716:7): [True: 0, False: 657k]
  ------------------
  717|      0|      return 0;
  718|      0|  }
  719|       |
  720|   657k|  buffer->used-=len;
  721|   657k|  buffer_verify(buffer);
  722|   657k|  return len;
  723|   657k|}
ssh_buffer_get_data:
  737|  1.65M|{
  738|  1.65M|    int rc;
  739|       |
  740|       |    /*
  741|       |     * Check for a integer overflow first, then check if not enough data is in
  742|       |     * the buffer.
  743|       |     */
  744|  1.65M|    rc = ssh_buffer_validate_length(buffer, len);
  745|  1.65M|    if (rc != SSH_OK) {
  ------------------
  |  |  316|  1.65M|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (745:9): [True: 0, False: 1.65M]
  ------------------
  746|      0|        return 0;
  747|      0|    }
  748|  1.65M|    memcpy(data,buffer->data+buffer->pos,len);
  749|  1.65M|    buffer->pos+=len;
  750|  1.65M|    return len;   /* no yet support for partial reads (is it really needed ?? ) */
  751|  1.65M|}
ssh_buffer_get_u8:
  765|   437k|uint32_t ssh_buffer_get_u8(struct ssh_buffer_struct *buffer, uint8_t *data){
  766|   437k|    return ssh_buffer_get_data(buffer,data,sizeof(uint8_t));
  767|   437k|}
ssh_buffer_get_u32:
  780|   661k|uint32_t ssh_buffer_get_u32(struct ssh_buffer_struct *buffer, uint32_t *data){
  781|   661k|    return ssh_buffer_get_data(buffer,data,sizeof(uint32_t));
  782|   661k|}
ssh_buffer_validate_length:
  809|  2.15M|{
  810|  2.15M|    if (buffer == NULL || buffer->pos + len < len ||
  ------------------
  |  Branch (810:9): [True: 18.4E, False: 2.15M]
  |  Branch (810:27): [True: 18.4E, False: 2.15M]
  ------------------
  811|  2.15M|        buffer->pos + len > buffer->used) {
  ------------------
  |  Branch (811:9): [True: 18.4E, False: 2.15M]
  ------------------
  812|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  813|      0|    }
  814|       |
  815|  2.15M|    return SSH_OK;
  ------------------
  |  |  316|  2.15M|#define SSH_OK 0     /* No error */
  ------------------
  816|  2.15M|}
ssh_buffer_get_ssh_string:
  829|   356k|{
  830|   356k|    uint32_t stringlen;
  831|   356k|    uint32_t hostlen;
  832|   356k|    struct ssh_string_struct *str = NULL;
  833|   356k|    int rc;
  834|       |
  835|   356k|    rc = ssh_buffer_get_u32(buffer, &stringlen);
  836|   356k|    if (rc == 0) {
  ------------------
  |  Branch (836:9): [True: 0, False: 356k]
  ------------------
  837|      0|        return NULL;
  838|      0|    }
  839|   356k|    hostlen = ntohl(stringlen);
  840|       |    /* verify if there is enough space in buffer to get it */
  841|   356k|    rc = ssh_buffer_validate_length(buffer, hostlen);
  842|   356k|    if (rc != SSH_OK) {
  ------------------
  |  |  316|   356k|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (842:9): [True: 0, False: 356k]
  ------------------
  843|      0|      return NULL; /* it is indeed */
  844|      0|    }
  845|   356k|    str = ssh_string_new(hostlen);
  846|   356k|    if (str == NULL) {
  ------------------
  |  Branch (846:9): [True: 0, False: 356k]
  ------------------
  847|      0|        return NULL;
  848|      0|    }
  849|       |
  850|   356k|    stringlen = ssh_buffer_get_data(buffer, ssh_string_data(str), hostlen);
  851|   356k|    if (stringlen != hostlen) {
  ------------------
  |  Branch (851:9): [True: 0, False: 356k]
  ------------------
  852|       |        /* should never happen */
  853|      0|        SAFE_FREE(str);
  ------------------
  |  |  373|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
  854|      0|        return NULL;
  855|      0|    }
  856|       |
  857|   356k|    return str;
  858|   356k|}
_ssh_buffer_pack:
 1135|   403k|{
 1136|   403k|    va_list ap;
 1137|   403k|    int rc;
 1138|       |
 1139|   403k|    if (argc > 256) {
  ------------------
  |  Branch (1139:9): [True: 0, False: 403k]
  ------------------
 1140|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 1141|      0|    }
 1142|       |
 1143|   403k|    va_start(ap, argc);
 1144|   403k|    rc = ssh_buffer_pack_allocate_va(buffer, format, argc, ap);
 1145|   403k|    va_end(ap);
 1146|       |
 1147|   403k|    if (rc != SSH_OK) {
  ------------------
  |  |  316|   403k|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (1147:9): [True: 0, False: 403k]
  ------------------
 1148|      0|        return rc;
 1149|      0|    }
 1150|       |
 1151|   403k|    va_start(ap, argc);
 1152|   403k|    rc = ssh_buffer_pack_va(buffer, format, argc, ap);
 1153|   403k|    va_end(ap);
 1154|       |
 1155|   403k|    return rc;
 1156|   403k|}
ssh_buffer_unpack_va:
 1173|   201k|{
 1174|   201k|    int rc = SSH_ERROR;
  ------------------
  |  |  317|   201k|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 1175|   201k|    const char *p = format, *last = NULL;
 1176|   201k|    union {
 1177|   201k|        uint8_t *byte;
 1178|   201k|        uint16_t *word;
 1179|   201k|        uint32_t *dword;
 1180|   201k|        uint64_t *qword;
 1181|   201k|        ssh_string *string;
 1182|   201k|        char **cstring;
 1183|   201k|        bignum *bignum;
 1184|   201k|        void **data;
 1185|   201k|    } o;
 1186|   201k|    size_t len;
 1187|   201k|    uint32_t rlen, max_len;
 1188|   201k|    ssh_string tmp_string = NULL;
 1189|   201k|    va_list ap_copy;
 1190|   201k|    size_t count;
 1191|       |
 1192|   201k|    max_len = ssh_buffer_get_len(buffer);
 1193|       |
 1194|       |    /* copy the argument list in case a rollback is needed */
 1195|   201k|    va_copy(ap_copy, ap);
 1196|       |
 1197|   201k|    if (argc > 256) {
  ------------------
  |  Branch (1197:9): [True: 0, False: 201k]
  ------------------
 1198|      0|        rc = SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 1199|      0|        goto cleanup;
 1200|      0|    }
 1201|       |
 1202|   558k|    for (count = 0; *p != '\0'; p++, count++) {
  ------------------
  |  Branch (1202:21): [True: 357k, False: 201k]
  ------------------
 1203|       |        /* Invalid number of arguments passed */
 1204|   357k|        if (count > argc) {
  ------------------
  |  Branch (1204:13): [True: 0, False: 357k]
  ------------------
 1205|      0|            rc = SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 1206|      0|            goto cleanup;
 1207|      0|        }
 1208|       |
 1209|   357k|        rc = SSH_ERROR;
  ------------------
  |  |  317|   357k|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 1210|   357k|        switch (*p) {
 1211|  8.64k|        case 'b':
  ------------------
  |  Branch (1211:9): [True: 8.64k, False: 348k]
  ------------------
 1212|  8.64k|            o.byte = va_arg(ap, uint8_t *);
 1213|  8.64k|            rlen = ssh_buffer_get_u8(buffer, o.byte);
 1214|  8.64k|            rc = rlen==1 ? SSH_OK : SSH_ERROR;
  ------------------
  |  |  316|  8.64k|#define SSH_OK 0     /* No error */
  ------------------
                          rc = rlen==1 ? SSH_OK : SSH_ERROR;
  ------------------
  |  |  317|  8.64k|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  |  Branch (1214:18): [True: 8.64k, False: 0]
  ------------------
 1215|  8.64k|            break;
 1216|      0|        case 'w':
  ------------------
  |  Branch (1216:9): [True: 0, False: 357k]
  ------------------
 1217|      0|            o.word = va_arg(ap,  uint16_t *);
 1218|      0|            rlen = ssh_buffer_get_data(buffer, o.word, sizeof(uint16_t));
 1219|      0|            if (rlen == 2) {
  ------------------
  |  Branch (1219:17): [True: 0, False: 0]
  ------------------
 1220|      0|                *o.word = ntohs(*o.word);
 1221|      0|                rc = SSH_OK;
  ------------------
  |  |  316|      0|#define SSH_OK 0     /* No error */
  ------------------
 1222|      0|            }
 1223|      0|            break;
 1224|   158k|        case 'd':
  ------------------
  |  Branch (1224:9): [True: 158k, False: 198k]
  ------------------
 1225|   158k|            o.dword = va_arg(ap, uint32_t *);
 1226|   158k|            rlen = ssh_buffer_get_u32(buffer, o.dword);
 1227|   158k|            if (rlen == 4) {
  ------------------
  |  Branch (1227:17): [True: 158k, False: 0]
  ------------------
 1228|   158k|                *o.dword = ntohl(*o.dword);
 1229|   158k|                rc = SSH_OK;
  ------------------
  |  |  316|   158k|#define SSH_OK 0     /* No error */
  ------------------
 1230|   158k|            }
 1231|   158k|            break;
 1232|      0|        case 'q':
  ------------------
  |  Branch (1232:9): [True: 0, False: 357k]
  ------------------
 1233|      0|            o.qword = va_arg(ap, uint64_t*);
 1234|      0|            rlen = ssh_buffer_get_u64(buffer, o.qword);
 1235|      0|            if (rlen == 8) {
  ------------------
  |  Branch (1235:17): [True: 0, False: 0]
  ------------------
 1236|      0|                *o.qword = ntohll(*o.qword);
  ------------------
  |  |  488|      0|    (((uint64_t)ntohl((x) & 0xFFFFFFFF) << 32) | ntohl((x) >> 32))
  ------------------
 1237|      0|                rc = SSH_OK;
  ------------------
  |  |  316|      0|#define SSH_OK 0     /* No error */
  ------------------
 1238|      0|            }
 1239|      0|            break;
 1240|      0|        case 'B':
  ------------------
  |  Branch (1240:9): [True: 0, False: 357k]
  ------------------
 1241|      0|            o.bignum = va_arg(ap, bignum *);
 1242|      0|            *o.bignum = NULL;
 1243|      0|            tmp_string = ssh_buffer_get_ssh_string(buffer);
 1244|      0|            if (tmp_string == NULL) {
  ------------------
  |  Branch (1244:17): [True: 0, False: 0]
  ------------------
 1245|      0|                break;
 1246|      0|            }
 1247|      0|            *o.bignum = ssh_make_string_bn(tmp_string);
 1248|      0|            ssh_string_burn(tmp_string);
 1249|      0|            SSH_STRING_FREE(tmp_string);
  ------------------
  |  |  893|      0|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (893:14): [True: 0, False: 0]
  |  |  |  Branch (893:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1250|      0|            rc = (*o.bignum != NULL) ? SSH_OK : SSH_ERROR;
  ------------------
  |  |  316|      0|#define SSH_OK 0     /* No error */
  ------------------
                          rc = (*o.bignum != NULL) ? SSH_OK : SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  |  Branch (1250:18): [True: 0, False: 0]
  ------------------
 1251|      0|            break;
 1252|  43.2k|        case 'S':
  ------------------
  |  Branch (1252:9): [True: 43.2k, False: 313k]
  ------------------
 1253|  43.2k|            o.string = va_arg(ap, ssh_string *);
 1254|  43.2k|            *o.string = ssh_buffer_get_ssh_string(buffer);
 1255|  43.2k|            rc = *o.string != NULL ? SSH_OK : SSH_ERROR;
  ------------------
  |  |  316|  43.2k|#define SSH_OK 0     /* No error */
  ------------------
                          rc = *o.string != NULL ? SSH_OK : SSH_ERROR;
  ------------------
  |  |  317|  43.2k|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  |  Branch (1255:18): [True: 43.2k, False: 0]
  ------------------
 1256|  43.2k|            o.string = NULL;
 1257|  43.2k|            break;
 1258|   138k|        case 's': {
  ------------------
  |  Branch (1258:9): [True: 138k, False: 218k]
  ------------------
 1259|   138k|            uint32_t u32len = 0;
 1260|       |
 1261|   138k|            o.cstring = va_arg(ap, char **);
 1262|   138k|            *o.cstring = NULL;
 1263|   138k|            rlen = ssh_buffer_get_u32(buffer, &u32len);
 1264|   138k|            if (rlen != 4){
  ------------------
  |  Branch (1264:17): [True: 0, False: 138k]
  ------------------
 1265|      0|                break;
 1266|      0|            }
 1267|   138k|            u32len = ntohl(u32len);
 1268|   138k|            if (u32len > max_len - 1) {
  ------------------
  |  Branch (1268:17): [True: 0, False: 138k]
  ------------------
 1269|      0|                break;
 1270|      0|            }
 1271|       |
 1272|   138k|            rc = ssh_buffer_validate_length(buffer, u32len);
 1273|   138k|            if (rc != SSH_OK) {
  ------------------
  |  |  316|   138k|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (1273:17): [True: 0, False: 138k]
  ------------------
 1274|      0|                break;
 1275|      0|            }
 1276|       |
 1277|   138k|            *o.cstring = malloc(u32len + 1);
 1278|   138k|            if (*o.cstring == NULL){
  ------------------
  |  Branch (1278:17): [True: 0, False: 138k]
  ------------------
 1279|      0|                rc = SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 1280|      0|                break;
 1281|      0|            }
 1282|   138k|            rlen = ssh_buffer_get_data(buffer, *o.cstring, u32len);
 1283|   138k|            if (rlen != u32len) {
  ------------------
  |  Branch (1283:17): [True: 0, False: 138k]
  ------------------
 1284|      0|                SAFE_FREE(*o.cstring);
  ------------------
  |  |  373|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1285|      0|                rc = SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 1286|      0|                break;
 1287|      0|            }
 1288|   138k|            (*o.cstring)[u32len] = '\0';
 1289|   138k|            o.cstring = NULL;
 1290|   138k|            rc = SSH_OK;
  ------------------
  |  |  316|   138k|#define SSH_OK 0     /* No error */
  ------------------
 1291|   138k|            break;
 1292|   138k|        }
 1293|  8.64k|        case 'P':
  ------------------
  |  Branch (1293:9): [True: 8.64k, False: 348k]
  ------------------
 1294|  8.64k|            len = va_arg(ap, size_t);
 1295|  8.64k|            if (len > max_len - 1) {
  ------------------
  |  Branch (1295:17): [True: 0, False: 8.64k]
  ------------------
 1296|      0|                rc = SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 1297|      0|                break;
 1298|      0|            }
 1299|       |
 1300|  8.64k|            rc = ssh_buffer_validate_length(buffer, len);
 1301|  8.64k|            if (rc != SSH_OK) {
  ------------------
  |  |  316|  8.64k|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (1301:17): [True: 0, False: 8.64k]
  ------------------
 1302|      0|                break;
 1303|      0|            }
 1304|       |
 1305|  8.64k|            o.data = va_arg(ap, void **);
 1306|  8.64k|            count++;
 1307|       |
 1308|  8.64k|            *o.data = malloc(len);
 1309|  8.64k|            if(*o.data == NULL){
  ------------------
  |  Branch (1309:16): [True: 0, False: 8.64k]
  ------------------
 1310|      0|                rc = SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 1311|      0|                break;
 1312|      0|            }
 1313|  8.64k|            rlen = ssh_buffer_get_data(buffer, *o.data, (uint32_t)len);
 1314|  8.64k|            if (rlen != len){
  ------------------
  |  Branch (1314:17): [True: 0, False: 8.64k]
  ------------------
 1315|      0|                SAFE_FREE(*o.data);
  ------------------
  |  |  373|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1316|      0|                rc = SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 1317|      0|                break;
 1318|      0|            }
 1319|  8.64k|            o.data = NULL;
 1320|  8.64k|            rc = SSH_OK;
  ------------------
  |  |  316|  8.64k|#define SSH_OK 0     /* No error */
  ------------------
 1321|  8.64k|            break;
 1322|      0|        default:
  ------------------
  |  Branch (1322:9): [True: 0, False: 357k]
  ------------------
 1323|      0|            SSH_LOG(SSH_LOG_TRACE, "Invalid buffer format %c", *p);
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 1324|   357k|        }
 1325|   357k|        if (rc != SSH_OK) {
  ------------------
  |  |  316|   357k|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (1325:13): [True: 0, False: 357k]
  ------------------
 1326|      0|            break;
 1327|      0|        }
 1328|   357k|    }
 1329|       |
 1330|   201k|    if (argc != count) {
  ------------------
  |  Branch (1330:9): [True: 0, False: 201k]
  ------------------
 1331|      0|        rc = SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 1332|      0|    }
 1333|       |
 1334|   201k|cleanup:
 1335|   201k|    if (rc != SSH_ERROR){
  ------------------
  |  |  317|   201k|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  |  Branch (1335:9): [True: 201k, False: 0]
  ------------------
 1336|       |        /* Check if our canary is intact, if not something really bad happened */
 1337|   201k|        uint32_t canary = va_arg(ap, uint32_t);
 1338|   201k|        if (canary != SSH_BUFFER_PACK_END){
  ------------------
  |  |   28|   201k|#define SSH_BUFFER_PACK_END ((uint32_t) 0x4f65feb3)
  ------------------
  |  Branch (1338:13): [True: 0, False: 201k]
  ------------------
 1339|      0|            abort();
 1340|      0|        }
 1341|   201k|    }
 1342|       |
 1343|   201k|    if (rc != SSH_OK){
  ------------------
  |  |  316|   201k|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (1343:9): [True: 0, False: 201k]
  ------------------
 1344|       |        /* Reset the format string and erase everything that was allocated */
 1345|      0|        last = p;
 1346|      0|        for(p=format;p<last;++p){
  ------------------
  |  Branch (1346:22): [True: 0, False: 0]
  ------------------
 1347|      0|            switch(*p){
 1348|      0|            case 'b':
  ------------------
  |  Branch (1348:13): [True: 0, False: 0]
  ------------------
 1349|      0|                o.byte = va_arg(ap_copy, uint8_t *);
 1350|      0|                if (buffer->secure) {
  ------------------
  |  Branch (1350:21): [True: 0, False: 0]
  ------------------
 1351|      0|                    ssh_burn(o.byte, sizeof(uint8_t));
  ------------------
  |  |  388|      0|#define ssh_burn(ptr, len) explicit_bzero((ptr), (len))
  ------------------
 1352|      0|                    break;
 1353|      0|                }
 1354|      0|                break;
 1355|      0|            case 'w':
  ------------------
  |  Branch (1355:13): [True: 0, False: 0]
  ------------------
 1356|      0|                o.word = va_arg(ap_copy, uint16_t *);
 1357|      0|                if (buffer->secure) {
  ------------------
  |  Branch (1357:21): [True: 0, False: 0]
  ------------------
 1358|      0|                    ssh_burn(o.word, sizeof(uint16_t));
  ------------------
  |  |  388|      0|#define ssh_burn(ptr, len) explicit_bzero((ptr), (len))
  ------------------
 1359|      0|                    break;
 1360|      0|                }
 1361|      0|                break;
 1362|      0|            case 'd':
  ------------------
  |  Branch (1362:13): [True: 0, False: 0]
  ------------------
 1363|      0|                o.dword = va_arg(ap_copy, uint32_t *);
 1364|      0|                if (buffer->secure) {
  ------------------
  |  Branch (1364:21): [True: 0, False: 0]
  ------------------
 1365|      0|                    ssh_burn(o.dword, sizeof(uint32_t));
  ------------------
  |  |  388|      0|#define ssh_burn(ptr, len) explicit_bzero((ptr), (len))
  ------------------
 1366|      0|                    break;
 1367|      0|                }
 1368|      0|                break;
 1369|      0|            case 'q':
  ------------------
  |  Branch (1369:13): [True: 0, False: 0]
  ------------------
 1370|      0|                o.qword = va_arg(ap_copy, uint64_t *);
 1371|      0|                if (buffer->secure) {
  ------------------
  |  Branch (1371:21): [True: 0, False: 0]
  ------------------
 1372|      0|                    ssh_burn(o.qword, sizeof(uint64_t));
  ------------------
  |  |  388|      0|#define ssh_burn(ptr, len) explicit_bzero((ptr), (len))
  ------------------
 1373|      0|                    break;
 1374|      0|                }
 1375|      0|                break;
 1376|      0|            case 'B':
  ------------------
  |  Branch (1376:13): [True: 0, False: 0]
  ------------------
 1377|      0|                o.bignum = va_arg(ap_copy, bignum *);
 1378|      0|                bignum_safe_free(*o.bignum);
  ------------------
  |  |   71|      0|#define bignum_safe_free(num) do { \
  |  |   72|      0|    if ((num) != NULL) { \
  |  |  ------------------
  |  |  |  Branch (72:9): [True: 0, False: 0]
  |  |  ------------------
  |  |   73|      0|        BN_clear_free((num)); \
  |  |   74|      0|        (num)=NULL; \
  |  |   75|      0|    } \
  |  |   76|      0|    } while(0)
  |  |  ------------------
  |  |  |  Branch (76:13): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1379|      0|                break;
 1380|      0|            case 'S':
  ------------------
  |  Branch (1380:13): [True: 0, False: 0]
  ------------------
 1381|      0|                o.string = va_arg(ap_copy, ssh_string *);
 1382|      0|                if (buffer->secure) {
  ------------------
  |  Branch (1382:21): [True: 0, False: 0]
  ------------------
 1383|      0|                    ssh_string_burn(*o.string);
 1384|      0|                }
 1385|      0|                SAFE_FREE(*o.string);
  ------------------
  |  |  373|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1386|      0|                break;
 1387|      0|            case 's':
  ------------------
  |  Branch (1387:13): [True: 0, False: 0]
  ------------------
 1388|      0|                o.cstring = va_arg(ap_copy, char **);
 1389|      0|                if (buffer->secure) {
  ------------------
  |  Branch (1389:21): [True: 0, False: 0]
  ------------------
 1390|      0|                    ssh_burn(*o.cstring, strlen(*o.cstring));
  ------------------
  |  |  388|      0|#define ssh_burn(ptr, len) explicit_bzero((ptr), (len))
  ------------------
 1391|      0|                }
 1392|      0|                SAFE_FREE(*o.cstring);
  ------------------
  |  |  373|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1393|      0|                break;
 1394|      0|            case 'P':
  ------------------
  |  Branch (1394:13): [True: 0, False: 0]
  ------------------
 1395|      0|                len = va_arg(ap_copy, size_t);
 1396|      0|                o.data = va_arg(ap_copy, void **);
 1397|      0|                if (buffer->secure) {
  ------------------
  |  Branch (1397:21): [True: 0, False: 0]
  ------------------
 1398|      0|                    ssh_burn(*o.data, len);
  ------------------
  |  |  388|      0|#define ssh_burn(ptr, len) explicit_bzero((ptr), (len))
  ------------------
 1399|      0|                }
 1400|      0|                SAFE_FREE(*o.data);
  ------------------
  |  |  373|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1401|      0|                break;
 1402|      0|            default:
  ------------------
  |  Branch (1402:13): [True: 0, False: 0]
  ------------------
 1403|      0|                (void)va_arg(ap_copy, void *);
 1404|      0|                break;
 1405|      0|            }
 1406|      0|        }
 1407|      0|    }
 1408|   201k|    va_end(ap_copy);
 1409|       |
 1410|   201k|    return rc;
 1411|   201k|}
_ssh_buffer_unpack:
 1439|   201k|{
 1440|   201k|    va_list ap;
 1441|   201k|    int rc;
 1442|       |
 1443|   201k|    va_start(ap, argc);
 1444|   201k|    rc = ssh_buffer_unpack_va(buffer, format, argc, ap);
 1445|       |    va_end(ap);
 1446|   201k|    return rc;
 1447|   201k|}
buffer.c:realloc_buffer:
  188|   765k|{
  189|   765k|    uint32_t smallest = 1;
  190|   765k|    uint8_t *new = NULL;
  191|       |
  192|   765k|    buffer_verify(buffer);
  193|       |
  194|       |    /* Find the smallest power of two which is greater or equal to needed */
  195|  7.52M|    while(smallest <= needed) {
  ------------------
  |  Branch (195:11): [True: 6.75M, False: 765k]
  ------------------
  196|  6.75M|        if (smallest == 0) {
  ------------------
  |  Branch (196:13): [True: 0, False: 6.75M]
  ------------------
  197|      0|            return -1;
  198|      0|        }
  199|  6.75M|        smallest <<= 1;
  200|  6.75M|    }
  201|   765k|    needed = smallest;
  202|       |
  203|   765k|    if (needed > BUFFER_SIZE_MAX) {
  ------------------
  |  |   57|   765k|#define BUFFER_SIZE_MAX 0x10000000
  ------------------
  |  Branch (203:9): [True: 0, False: 765k]
  ------------------
  204|      0|        return -1;
  205|      0|    }
  206|       |
  207|   765k|    if (buffer->secure) {
  ------------------
  |  Branch (207:9): [True: 25.9k, False: 739k]
  ------------------
  208|  25.9k|        new = malloc(needed);
  209|  25.9k|        if (new == NULL) {
  ------------------
  |  Branch (209:13): [True: 0, False: 25.9k]
  ------------------
  210|      0|            return -1;
  211|      0|        }
  212|  25.9k|        memcpy(new, buffer->data, buffer->used);
  213|  25.9k|        ssh_burn(buffer->data, buffer->used);
  ------------------
  |  |  388|  25.9k|#define ssh_burn(ptr, len) explicit_bzero((ptr), (len))
  ------------------
  214|  25.9k|        SAFE_FREE(buffer->data);
  ------------------
  |  |  373|  25.9k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 25.9k, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 25.9k]
  |  |  ------------------
  ------------------
  215|   739k|    } else {
  216|   739k|        new = realloc(buffer->data, needed);
  217|   739k|        if (new == NULL) {
  ------------------
  |  Branch (217:13): [True: 0, False: 739k]
  ------------------
  218|      0|            return -1;
  219|      0|        }
  220|   739k|    }
  221|   765k|    buffer->data = new;
  222|   765k|    buffer->allocated = needed;
  223|       |
  224|   765k|    buffer_verify(buffer);
  225|   765k|    return 0;
  226|   765k|}
buffer.c:buffer_shift:
  233|  30.9k|{
  234|  30.9k|    size_t burn_pos = buffer->pos;
  235|       |
  236|  30.9k|    buffer_verify(buffer);
  237|       |
  238|  30.9k|    if (buffer->pos == 0) {
  ------------------
  |  Branch (238:9): [True: 0, False: 30.9k]
  ------------------
  239|      0|        return;
  240|      0|    }
  241|  30.9k|    memmove(buffer->data,
  242|  30.9k|            buffer->data + buffer->pos,
  243|  30.9k|            buffer->used - buffer->pos);
  244|  30.9k|    buffer->used -= buffer->pos;
  245|  30.9k|    buffer->pos = 0;
  246|       |
  247|  30.9k|    if (buffer->secure) {
  ------------------
  |  Branch (247:9): [True: 0, False: 30.9k]
  ------------------
  248|      0|        void *ptr = buffer->data + buffer->used;
  249|      0|        ssh_burn(ptr, burn_pos);
  ------------------
  |  |  388|      0|#define ssh_burn(ptr, len) explicit_bzero((ptr), (len))
  ------------------
  250|      0|    }
  251|       |
  252|  30.9k|    buffer_verify(buffer);
  253|  30.9k|}
buffer.c:ssh_buffer_pack_allocate_va:
  880|   403k|{
  881|   403k|    const char *p = NULL;
  882|   403k|    ssh_string string = NULL;
  883|   403k|    char *cstring = NULL;
  884|   403k|    bignum b = NULL;
  885|   403k|    size_t needed_size = 0;
  886|   403k|    size_t len;
  887|   403k|    size_t count;
  888|   403k|    int rc = SSH_OK;
  ------------------
  |  |  316|   403k|#define SSH_OK 0     /* No error */
  ------------------
  889|       |
  890|  1.38M|    for (p = format, count = 0; *p != '\0'; p++, count++) {
  ------------------
  |  Branch (890:33): [True: 979k, False: 403k]
  ------------------
  891|       |        /* Invalid number of arguments passed */
  892|   979k|        if (count > argc) {
  ------------------
  |  Branch (892:13): [True: 0, False: 979k]
  ------------------
  893|      0|            return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  894|      0|        }
  895|       |
  896|   979k|        switch(*p) {
  897|   210k|        case 'b':
  ------------------
  |  Branch (897:9): [True: 210k, False: 768k]
  ------------------
  898|   210k|            va_arg(ap, unsigned int);
  899|   210k|            needed_size += sizeof(uint8_t);
  900|   210k|            break;
  901|      0|        case 'w':
  ------------------
  |  Branch (901:9): [True: 0, False: 979k]
  ------------------
  902|      0|            va_arg(ap, unsigned int);
  903|      0|            needed_size += sizeof(uint16_t);
  904|      0|            break;
  905|   308k|        case 'd':
  ------------------
  |  Branch (905:9): [True: 308k, False: 670k]
  ------------------
  906|   308k|            va_arg(ap, uint32_t);
  907|   308k|            needed_size += sizeof(uint32_t);
  908|   308k|            break;
  909|      0|        case 'q':
  ------------------
  |  Branch (909:9): [True: 0, False: 979k]
  ------------------
  910|      0|            va_arg(ap, uint64_t);
  911|      0|            needed_size += sizeof(uint64_t);
  912|      0|            break;
  913|  77.7k|        case 'S':
  ------------------
  |  Branch (913:9): [True: 77.7k, False: 901k]
  ------------------
  914|  77.7k|            string = va_arg(ap, ssh_string);
  915|  77.7k|            needed_size += sizeof(uint32_t) + ssh_string_len(string);
  916|  77.7k|            string = NULL;
  917|  77.7k|            break;
  918|   172k|        case 's':
  ------------------
  |  Branch (918:9): [True: 172k, False: 806k]
  ------------------
  919|   172k|            cstring = va_arg(ap, char *);
  920|   172k|            needed_size += sizeof(uint32_t) + strlen(cstring);
  921|   172k|            cstring = NULL;
  922|   172k|            break;
  923|   210k|        case 'P':
  ------------------
  |  Branch (923:9): [True: 210k, False: 768k]
  ------------------
  924|   210k|            len = va_arg(ap, size_t);
  925|   210k|            needed_size += len;
  926|   210k|            va_arg(ap, void *);
  927|   210k|            count++; /* increase argument count */
  928|   210k|            break;
  929|      0|        case 'B':
  ------------------
  |  Branch (929:9): [True: 0, False: 979k]
  ------------------
  930|      0|            b = va_arg(ap, bignum);
  931|       |            /* The bignum bytes + 1 for possible padding */
  932|      0|            needed_size += sizeof(uint32_t) + bignum_num_bytes(b) + 1;
  ------------------
  |  |   98|      0|#define bignum_num_bytes(num) (size_t)BN_num_bytes(num)
  ------------------
  933|      0|            break;
  934|      0|        case 't':
  ------------------
  |  Branch (934:9): [True: 0, False: 979k]
  ------------------
  935|      0|            cstring = va_arg(ap, char *);
  936|      0|            needed_size += strlen(cstring);
  937|      0|            cstring = NULL;
  938|      0|            break;
  939|      0|        default:
  ------------------
  |  Branch (939:9): [True: 0, False: 979k]
  ------------------
  940|      0|            SSH_LOG(SSH_LOG_TRACE, "Invalid buffer format %c", *p);
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  941|      0|            rc = SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  942|   979k|        }
  943|   979k|        if (rc != SSH_OK){
  ------------------
  |  |  316|   979k|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (943:13): [True: 0, False: 979k]
  ------------------
  944|      0|            break;
  945|      0|        }
  946|   979k|    }
  947|       |
  948|   403k|    if (argc != count) {
  ------------------
  |  Branch (948:9): [True: 0, False: 403k]
  ------------------
  949|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  950|      0|    }
  951|       |
  952|   403k|    if (rc != SSH_ERROR){
  ------------------
  |  |  317|   403k|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  |  Branch (952:9): [True: 403k, False: 18.4E]
  ------------------
  953|       |        /*
  954|       |         * Check if our canary is intact, if not, something really bad happened.
  955|       |         */
  956|   403k|        uint32_t canary = va_arg(ap, uint32_t);
  957|   403k|        if (canary != SSH_BUFFER_PACK_END) {
  ------------------
  |  |   28|   403k|#define SSH_BUFFER_PACK_END ((uint32_t) 0x4f65feb3)
  ------------------
  |  Branch (957:13): [True: 0, False: 403k]
  ------------------
  958|      0|            abort();
  959|      0|        }
  960|   403k|    }
  961|       |
  962|   403k|    rc = ssh_buffer_allocate_size(buffer, (uint32_t)needed_size);
  963|   403k|    if (rc != 0) {
  ------------------
  |  Branch (963:9): [True: 0, False: 403k]
  ------------------
  964|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  965|      0|    }
  966|       |
  967|   403k|    return SSH_OK;
  ------------------
  |  |  316|   403k|#define SSH_OK 0     /* No error */
  ------------------
  968|   403k|}
buffer.c:ssh_buffer_pack_va:
  987|   403k|{
  988|   403k|    int rc = SSH_ERROR;
  ------------------
  |  |  317|   403k|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  989|   403k|    const char *p = NULL;
  990|   403k|    union {
  991|   403k|        uint8_t byte;
  992|   403k|        uint16_t word;
  993|   403k|        uint32_t dword;
  994|   403k|        uint64_t qword;
  995|   403k|        ssh_string string;
  996|   403k|        void *data;
  997|   403k|    } o;
  998|   403k|    char *cstring = NULL;
  999|   403k|    bignum b;
 1000|   403k|    size_t len;
 1001|   403k|    size_t count;
 1002|       |
 1003|   403k|    if (argc > 256) {
  ------------------
  |  Branch (1003:9): [True: 0, False: 403k]
  ------------------
 1004|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 1005|      0|    }
 1006|       |
 1007|  1.38M|    for (p = format, count = 0; *p != '\0'; p++, count++) {
  ------------------
  |  Branch (1007:33): [True: 979k, False: 403k]
  ------------------
 1008|       |        /* Invalid number of arguments passed */
 1009|   979k|        if (count > argc) {
  ------------------
  |  Branch (1009:13): [True: 0, False: 979k]
  ------------------
 1010|      0|            return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 1011|      0|        }
 1012|       |
 1013|   979k|        switch(*p) {
 1014|   210k|        case 'b':
  ------------------
  |  Branch (1014:9): [True: 210k, False: 768k]
  ------------------
 1015|   210k|            o.byte = (uint8_t)va_arg(ap, unsigned int);
 1016|   210k|            rc = ssh_buffer_add_u8(buffer, o.byte);
 1017|   210k|            break;
 1018|      0|        case 'w':
  ------------------
  |  Branch (1018:9): [True: 0, False: 979k]
  ------------------
 1019|      0|            o.word = (uint16_t)va_arg(ap, unsigned int);
 1020|      0|            o.word = htons(o.word);
 1021|      0|            rc = ssh_buffer_add_u16(buffer, o.word);
 1022|      0|            break;
 1023|   308k|        case 'd':
  ------------------
  |  Branch (1023:9): [True: 308k, False: 670k]
  ------------------
 1024|   308k|            o.dword = va_arg(ap, uint32_t);
 1025|   308k|            o.dword = htonl(o.dword);
 1026|   308k|            rc = ssh_buffer_add_u32(buffer, o.dword);
 1027|   308k|            break;
 1028|      0|        case 'q':
  ------------------
  |  Branch (1028:9): [True: 0, False: 979k]
  ------------------
 1029|      0|            o.qword = va_arg(ap, uint64_t);
 1030|      0|            o.qword = htonll(o.qword);
  ------------------
  |  |  479|      0|    (((uint64_t)htonl((x) & 0xFFFFFFFF) << 32) | htonl((x) >> 32))
  ------------------
 1031|      0|            rc = ssh_buffer_add_u64(buffer, o.qword);
 1032|      0|            break;
 1033|  77.7k|        case 'S':
  ------------------
  |  Branch (1033:9): [True: 77.7k, False: 901k]
  ------------------
 1034|  77.7k|            o.string = va_arg(ap, ssh_string);
 1035|  77.7k|            rc = ssh_buffer_add_ssh_string(buffer, o.string);
 1036|  77.7k|            o.string = NULL;
 1037|  77.7k|            break;
 1038|   172k|        case 's':
  ------------------
  |  Branch (1038:9): [True: 172k, False: 806k]
  ------------------
 1039|   172k|            cstring = va_arg(ap, char *);
 1040|   172k|            len = strlen(cstring);
 1041|   172k|            if (len > UINT32_MAX) {
  ------------------
  |  Branch (1041:17): [True: 0, False: 172k]
  ------------------
 1042|      0|                rc = SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 1043|      0|                break;
 1044|      0|            }
 1045|   172k|            o.dword = (uint32_t)len;
 1046|   172k|            rc = ssh_buffer_add_u32(buffer, htonl(o.dword));
 1047|   172k|            if (rc == SSH_OK){
  ------------------
  |  |  316|   172k|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (1047:17): [True: 172k, False: 0]
  ------------------
 1048|   172k|                rc = ssh_buffer_add_data(buffer, cstring, o.dword);
 1049|   172k|            }
 1050|   172k|            cstring = NULL;
 1051|   172k|            break;
 1052|   210k|        case 'P':
  ------------------
  |  Branch (1052:9): [True: 210k, False: 768k]
  ------------------
 1053|   210k|            len = va_arg(ap, size_t);
 1054|   210k|            if (len > UINT32_MAX) {
  ------------------
  |  Branch (1054:17): [True: 0, False: 210k]
  ------------------
 1055|      0|                rc = SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 1056|      0|                break;
 1057|      0|            }
 1058|       |
 1059|   210k|            o.data = va_arg(ap, void *);
 1060|   210k|            count++; /* increase argument count */
 1061|       |
 1062|   210k|            rc = ssh_buffer_add_data(buffer, o.data, (uint32_t)len);
 1063|   210k|            o.data = NULL;
 1064|   210k|            break;
 1065|      0|        case 'B':
  ------------------
  |  Branch (1065:9): [True: 0, False: 979k]
  ------------------
 1066|      0|            b = va_arg(ap, bignum);
 1067|      0|            o.string = ssh_make_bignum_string(b);
 1068|      0|            if(o.string == NULL){
  ------------------
  |  Branch (1068:16): [True: 0, False: 0]
  ------------------
 1069|      0|                rc = SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 1070|      0|                break;
 1071|      0|            }
 1072|      0|            rc = ssh_buffer_add_ssh_string(buffer, o.string);
 1073|      0|            SAFE_FREE(o.string);
  ------------------
  |  |  373|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1074|      0|            break;
 1075|      0|        case 't':
  ------------------
  |  Branch (1075:9): [True: 0, False: 979k]
  ------------------
 1076|      0|            cstring = va_arg(ap, char *);
 1077|      0|            len = strlen(cstring);
 1078|      0|            if (len > UINT32_MAX) {
  ------------------
  |  Branch (1078:17): [True: 0, False: 0]
  ------------------
 1079|      0|                rc = SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 1080|      0|                break;
 1081|      0|            }
 1082|      0|            rc = ssh_buffer_add_data(buffer, cstring, (uint32_t)len);
 1083|      0|            cstring = NULL;
 1084|      0|            break;
 1085|      0|        default:
  ------------------
  |  Branch (1085:9): [True: 0, False: 979k]
  ------------------
 1086|      0|            SSH_LOG(SSH_LOG_TRACE, "Invalid buffer format %c", *p);
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 1087|      0|            rc = SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 1088|   979k|        }
 1089|   979k|        if (rc != SSH_OK){
  ------------------
  |  |  316|   979k|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (1089:13): [True: 0, False: 979k]
  ------------------
 1090|      0|            break;
 1091|      0|        }
 1092|   979k|    }
 1093|       |
 1094|   403k|    if (argc != count) {
  ------------------
  |  Branch (1094:9): [True: 0, False: 403k]
  ------------------
 1095|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 1096|      0|    }
 1097|       |
 1098|   403k|    if (rc != SSH_ERROR){
  ------------------
  |  |  317|   403k|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  |  Branch (1098:9): [True: 403k, False: 4]
  ------------------
 1099|       |        /* Check if our canary is intact, if not something really bad happened */
 1100|   403k|        uint32_t canary = va_arg(ap, uint32_t);
 1101|   403k|        if (canary != SSH_BUFFER_PACK_END) {
  ------------------
  |  |   28|   403k|#define SSH_BUFFER_PACK_END ((uint32_t) 0x4f65feb3)
  ------------------
  |  Branch (1101:13): [True: 0, False: 403k]
  ------------------
 1102|      0|            abort();
 1103|      0|        }
 1104|   403k|    }
 1105|   403k|    return rc;
 1106|   403k|}

_ssh_remove_legacy_log_cb:
   49|  17.2k|{
   50|  17.2k|    if (ssh_get_log_callback() == ssh_legacy_log_callback) {
  ------------------
  |  Branch (50:9): [True: 0, False: 17.2k]
  ------------------
   51|      0|        _ssh_reset_log_cb();
   52|       |        ssh_set_log_userdata(NULL);
   53|      0|    }
   54|  17.2k|}
ssh_set_channel_callbacks:
  114|  8.64k|{
  115|  8.64k|    return ssh_add_set_channel_callbacks(channel, cb, 1);
  116|  8.64k|}
ssh_set_server_callbacks:
  142|  8.64k|{
  143|  8.64k|    if (session == NULL || cb == NULL) {
  ------------------
  |  Branch (143:9): [True: 0, False: 8.64k]
  |  Branch (143:28): [True: 0, False: 8.64k]
  ------------------
  144|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  145|      0|    }
  146|       |
  147|  8.64k|    if (!is_callback_valid(session, cb)) {
  ------------------
  |  |   31|  8.64k|    (cb->size > 0 || cb->size <= 1024 * sizeof(void *))
  |  |  ------------------
  |  |  |  Branch (31:6): [True: 8.64k, False: 0]
  |  |  |  Branch (31:22): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  148|      0|        ssh_set_error(session,
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  149|      0|                      SSH_FATAL,
  150|      0|                      "Invalid callback passed in (badly initialized)");
  151|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  152|  8.64k|    };
  153|  8.64k|    session->server_callbacks = cb;
  154|       |
  155|  8.64k|    return 0;
  156|  8.64k|}
callbacks.c:ssh_add_set_channel_callbacks:
   82|  8.64k|{
   83|  8.64k|    ssh_session session = NULL;
   84|  8.64k|    int rc;
   85|       |
   86|  8.64k|    if (channel == NULL || cb == NULL) {
  ------------------
  |  Branch (86:9): [True: 0, False: 8.64k]
  |  Branch (86:28): [True: 0, False: 8.64k]
  ------------------
   87|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
   88|      0|    }
   89|  8.64k|    session = channel->session;
   90|       |
   91|  8.64k|    if (!is_callback_valid(session, cb)) {
  ------------------
  |  |   31|  8.64k|    (cb->size > 0 || cb->size <= 1024 * sizeof(void *))
  |  |  ------------------
  |  |  |  Branch (31:6): [True: 8.64k, False: 0]
  |  |  |  Branch (31:22): [True: 0, False: 0]
  |  |  ------------------
  ------------------
   92|      0|        ssh_set_error(session,
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
   93|      0|                      SSH_FATAL,
   94|      0|                      "Invalid callback passed in (badly initialized)");
   95|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
   96|  8.64k|    };
   97|  8.64k|    if (channel->callbacks == NULL) {
  ------------------
  |  Branch (97:9): [True: 8.64k, False: 0]
  ------------------
   98|  8.64k|        channel->callbacks = ssh_list_new();
   99|  8.64k|        if (channel->callbacks == NULL) {
  ------------------
  |  Branch (99:13): [True: 0, False: 8.64k]
  ------------------
  100|      0|            ssh_set_error_oom(session);
  ------------------
  |  |  318|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
  101|      0|            return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  102|      0|        }
  103|  8.64k|    }
  104|  8.64k|    if (prepend) {
  ------------------
  |  Branch (104:9): [True: 8.64k, False: 0]
  ------------------
  105|  8.64k|        rc = ssh_list_prepend(channel->callbacks, cb);
  106|  8.64k|    } else {
  107|      0|        rc = ssh_list_append(channel->callbacks, cb);
  108|      0|    }
  109|       |
  110|  8.64k|    return rc;
  111|  8.64k|}

ssh_channel_new:
   91|  17.2k|{
   92|  17.2k|    ssh_channel channel = NULL;
   93|       |
   94|  17.2k|    if (session == NULL) {
  ------------------
  |  Branch (94:9): [True: 0, False: 17.2k]
  ------------------
   95|      0|        return NULL;
   96|      0|    }
   97|       |
   98|       |    /* Check if we have an authenticated session */
   99|  17.2k|    if (!(session->flags & SSH_SESSION_FLAG_AUTHENTICATED)) {
  ------------------
  |  |   78|  17.2k|#define SSH_SESSION_FLAG_AUTHENTICATED 0x0002
  ------------------
  |  Branch (99:9): [True: 0, False: 17.2k]
  ------------------
  100|      0|        return NULL;
  101|      0|    }
  102|       |
  103|  17.2k|    channel = calloc(1, sizeof(struct ssh_channel_struct));
  104|  17.2k|    if (channel == NULL) {
  ------------------
  |  Branch (104:9): [True: 0, False: 17.2k]
  ------------------
  105|      0|        ssh_set_error_oom(session);
  ------------------
  |  |  318|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
  106|      0|        return NULL;
  107|      0|    }
  108|       |
  109|  17.2k|    channel->stdout_buffer = ssh_buffer_new();
  110|  17.2k|    if (channel->stdout_buffer == NULL) {
  ------------------
  |  Branch (110:9): [True: 0, False: 17.2k]
  ------------------
  111|      0|        ssh_set_error_oom(session);
  ------------------
  |  |  318|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
  112|      0|        SAFE_FREE(channel);
  ------------------
  |  |  373|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
  113|      0|        return NULL;
  114|      0|    }
  115|       |
  116|  17.2k|    channel->stderr_buffer = ssh_buffer_new();
  117|  17.2k|    if (channel->stderr_buffer == NULL) {
  ------------------
  |  Branch (117:9): [True: 0, False: 17.2k]
  ------------------
  118|      0|        ssh_set_error_oom(session);
  ------------------
  |  |  318|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
  119|      0|        SSH_BUFFER_FREE(channel->stdout_buffer);
  ------------------
  |  |  934|      0|    do { if ((x) != NULL) { ssh_buffer_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (934:14): [True: 0, False: 0]
  |  |  |  Branch (934:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
  120|      0|        SAFE_FREE(channel);
  ------------------
  |  |  373|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
  121|      0|        return NULL;
  122|      0|    }
  123|       |
  124|  17.2k|    channel->session = session;
  125|  17.2k|    channel->exit.code = (uint32_t)-1;
  126|  17.2k|    channel->flags = SSH_CHANNEL_FLAG_NOT_BOUND;
  ------------------
  |  |   64|  17.2k|#define SSH_CHANNEL_FLAG_NOT_BOUND 0x0008
  ------------------
  127|       |
  128|  17.2k|    if (session->channels == NULL) {
  ------------------
  |  Branch (128:9): [True: 17.2k, False: 2]
  ------------------
  129|  17.2k|        session->channels = ssh_list_new();
  130|  17.2k|        if (session->channels == NULL) {
  ------------------
  |  Branch (130:13): [True: 0, False: 17.2k]
  ------------------
  131|      0|            ssh_set_error_oom(session);
  ------------------
  |  |  318|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
  132|      0|            SSH_BUFFER_FREE(channel->stdout_buffer);
  ------------------
  |  |  934|      0|    do { if ((x) != NULL) { ssh_buffer_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (934:14): [True: 0, False: 0]
  |  |  |  Branch (934:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
  133|      0|            SSH_BUFFER_FREE(channel->stderr_buffer);
  ------------------
  |  |  934|      0|    do { if ((x) != NULL) { ssh_buffer_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (934:14): [True: 0, False: 0]
  |  |  |  Branch (934:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
  134|      0|            SAFE_FREE(channel);
  ------------------
  |  |  373|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
  135|      0|            return NULL;
  136|      0|        }
  137|  17.2k|    }
  138|       |
  139|  17.2k|    ssh_list_prepend(session->channels, channel);
  140|       |
  141|       |    /* Set states explicitly */
  142|  17.2k|    channel->state = SSH_CHANNEL_STATE_NOT_OPEN;
  143|  17.2k|    channel->request_state = SSH_CHANNEL_REQ_STATE_NONE;
  144|       |
  145|  17.2k|    return channel;
  146|  17.2k|}
ssh_channel_new_id:
  158|  17.2k|{
  159|  17.2k|    return ++(session->maxchannel);
  160|  17.2k|}
ssh_packet_channel_open_conf:
  170|  8.64k|{
  171|  8.64k|    uint32_t channelid = 0;
  172|  8.64k|    ssh_channel channel = NULL;
  173|  8.64k|    int rc;
  174|  8.64k|    (void)type;
  175|  8.64k|    (void)user;
  176|       |
  177|  8.64k|    SSH_LOG(SSH_LOG_PACKET, "Received SSH2_MSG_CHANNEL_OPEN_CONFIRMATION");
  ------------------
  |  |  281|  8.64k|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  178|       |
  179|  8.64k|    rc = ssh_buffer_unpack(packet, "d", &channelid);
  ------------------
  |  |   60|  8.64k|    _ssh_buffer_unpack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |  451|  8.64k|        (__VA_NARG_(__VA_ARGS__, __RSEQ_N()))
  |  |  |  |  ------------------
  |  |  |  |  |  |  453|  8.64k|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  448|  8.64k|#define VA_APPLY_VARIADIC_MACRO(macro, tuple) macro tuple
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  453|  8.64k|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  461|  8.64k|        _61,_62,_63,N,...) N
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                   _ssh_buffer_unpack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |   28|  8.64k|#define SSH_BUFFER_PACK_END ((uint32_t) 0x4f65feb3)
  |  |  ------------------
  ------------------
  180|  8.64k|    if (rc != SSH_OK)
  ------------------
  |  |  316|  8.64k|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (180:9): [True: 0, False: 8.64k]
  ------------------
  181|      0|        goto error;
  182|  8.64k|    channel = ssh_channel_from_local(session, channelid);
  183|  8.64k|    if (channel == NULL) {
  ------------------
  |  Branch (183:9): [True: 0, False: 8.64k]
  ------------------
  184|      0|        ssh_set_error(session,
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  185|      0|                      SSH_FATAL,
  186|      0|                      "Unknown channel id %" PRIu32,
  187|      0|                      (uint32_t)channelid);
  188|       |        /* TODO: Set error marking in channel object */
  189|       |
  190|      0|        return SSH_PACKET_USED;
  ------------------
  |  |  637|      0|#define SSH_PACKET_USED 1
  ------------------
  191|      0|    }
  192|       |
  193|  8.64k|    rc = ssh_buffer_unpack(packet,
  ------------------
  |  |   60|  8.64k|    _ssh_buffer_unpack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |  451|  8.64k|        (__VA_NARG_(__VA_ARGS__, __RSEQ_N()))
  |  |  |  |  ------------------
  |  |  |  |  |  |  453|  8.64k|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  448|  8.64k|#define VA_APPLY_VARIADIC_MACRO(macro, tuple) macro tuple
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  453|  8.64k|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  461|  8.64k|        _61,_62,_63,N,...) N
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                   _ssh_buffer_unpack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |   28|  8.64k|#define SSH_BUFFER_PACK_END ((uint32_t) 0x4f65feb3)
  |  |  ------------------
  ------------------
  194|  8.64k|                           "ddd",
  195|  8.64k|                           &channel->remote_channel,
  196|  8.64k|                           &channel->remote_window,
  197|  8.64k|                           &channel->remote_maxpacket);
  198|  8.64k|    if (rc != SSH_OK)
  ------------------
  |  |  316|  8.64k|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (198:9): [True: 0, False: 8.64k]
  ------------------
  199|      0|        goto error;
  200|       |
  201|  8.64k|    if (channel->remote_maxpacket == 0) {
  ------------------
  |  Branch (201:9): [True: 0, False: 8.64k]
  ------------------
  202|      0|        SSH_LOG(SSH_LOG_RARE,
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  203|      0|                "Invalid maximum packet size 0 in "
  204|      0|                "SSH2_MSG_CHANNEL_OPEN_CONFIRMATION");
  205|      0|        goto error;
  206|      0|    }
  207|       |
  208|  8.64k|    SSH_LOG(SSH_LOG_DEBUG,
  ------------------
  |  |  281|  8.64k|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  209|  8.64k|            "Received a CHANNEL_OPEN_CONFIRMATION for channel %" PRIu32
  210|  8.64k|            ":%" PRIu32,
  211|  8.64k|            channel->local_channel,
  212|  8.64k|            channel->remote_channel);
  213|       |
  214|  8.64k|    if (channel->state != SSH_CHANNEL_STATE_OPENING) {
  ------------------
  |  Branch (214:9): [True: 0, False: 8.64k]
  ------------------
  215|      0|        SSH_LOG(SSH_LOG_RARE,
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  216|      0|                "SSH2_MSG_CHANNEL_OPEN_CONFIRMATION received in incorrect "
  217|      0|                "channel state %d",
  218|      0|                channel->state);
  219|      0|        goto error;
  220|      0|    }
  221|       |
  222|  8.64k|    SSH_LOG(SSH_LOG_DEBUG,
  ------------------
  |  |  281|  8.64k|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  223|  8.64k|            "Remote window : %" PRIu32 ", maxpacket : %" PRIu32,
  224|  8.64k|            channel->remote_window,
  225|  8.64k|            channel->remote_maxpacket);
  226|       |
  227|  8.64k|    channel->state = SSH_CHANNEL_STATE_OPEN;
  228|  8.64k|    channel->flags &= ~SSH_CHANNEL_FLAG_NOT_BOUND;
  ------------------
  |  |   64|  8.64k|#define SSH_CHANNEL_FLAG_NOT_BOUND 0x0008
  ------------------
  229|       |
  230|  8.64k|    ssh_callbacks_execute_list(channel->callbacks,
  ------------------
  |  |  566|  8.64k|    do {                                                      \
  |  |  567|  8.64k|        struct ssh_iterator *i = ssh_list_get_iterator(list); \
  |  |  568|  8.64k|        cbtype cb;                                            \
  |  |  569|  8.64k|        while (i != NULL){                                    \
  |  |  ------------------
  |  |  |  Branch (569:16): [True: 0, False: 8.64k]
  |  |  ------------------
  |  |  570|      0|            cb = ssh_iterator_value(cbtype, i);               \
  |  |  ------------------
  |  |  |  |  114|      0|  ((type)((iterator)->data))
  |  |  ------------------
  |  |  571|      0|            if (ssh_callbacks_exists(cb, c))                  \
  |  |  ------------------
  |  |  |  |  547|      0|#define ssh_callbacks_exists(p,c) (\
  |  |  |  |  548|      0|  (p != NULL) && ( (char *)&((p)-> c) < (char *)(p) + (p)->size ) && \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (548:3): [True: 0, False: 0]
  |  |  |  |  |  Branch (548:18): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  549|      0|  ((p)-> c != NULL) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (549:3): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  550|      0|  )
  |  |  ------------------
  |  |  572|      0|                cb-> c (__VA_ARGS__, cb->userdata);           \
  |  |  573|      0|            i = i->next;                                      \
  |  |  574|      0|        }                                                     \
  |  |  575|  8.64k|    } while(0)
  |  |  ------------------
  |  |  |  Branch (575:13): [Folded, False: 8.64k]
  |  |  ------------------
  ------------------
  231|  8.64k|                               ssh_channel_callbacks,
  232|  8.64k|                               channel_open_response_function,
  233|  8.64k|                               channel->session,
  234|  8.64k|                               channel,
  235|  8.64k|                               true /* is_success */);
  236|       |
  237|  8.64k|    return SSH_PACKET_USED;
  ------------------
  |  |  637|  8.64k|#define SSH_PACKET_USED 1
  ------------------
  238|       |
  239|      0|error:
  240|      0|    ssh_set_error(session, SSH_FATAL, "Invalid packet");
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  241|      0|    return SSH_PACKET_USED;
  ------------------
  |  |  637|      0|#define SSH_PACKET_USED 1
  ------------------
  242|  8.64k|}
ssh_channel_from_local:
  420|  80.6k|{
  421|  80.6k|    struct ssh_iterator *it = NULL;
  422|  80.6k|    ssh_channel channel = NULL;
  423|       |
  424|  80.6k|    for (it = ssh_list_get_iterator(session->channels); it != NULL;
  ------------------
  |  Branch (424:57): [True: 80.6k, False: 0]
  ------------------
  425|  80.6k|         it = it->next) {
  426|  80.6k|        channel = ssh_iterator_value(ssh_channel, it);
  ------------------
  |  |  114|  80.6k|  ((type)((iterator)->data))
  ------------------
  427|  80.6k|        if (channel == NULL) {
  ------------------
  |  Branch (427:13): [True: 0, False: 80.6k]
  ------------------
  428|      0|            continue;
  429|      0|        }
  430|  80.6k|        if (channel->local_channel == id) {
  ------------------
  |  Branch (430:13): [True: 80.6k, False: 0]
  ------------------
  431|  80.6k|            return channel;
  432|  80.6k|        }
  433|  80.6k|    }
  434|       |
  435|      0|    return NULL;
  436|  80.6k|}
channel_rcv_data:
  603|  46.0k|{
  604|  46.0k|    ssh_channel channel = NULL;
  605|  46.0k|    ssh_string str = NULL;
  606|  46.0k|    ssh_buffer buf = NULL;
  607|  46.0k|    void *data = NULL;
  608|  46.0k|    uint32_t len;
  609|  46.0k|    int extended, is_stderr = 0;
  610|  46.0k|    int rest;
  611|       |
  612|  46.0k|    (void)user;
  613|       |
  614|  46.0k|    if (type == SSH2_MSG_CHANNEL_DATA) {
  ------------------
  |  |   58|  46.0k|#define SSH2_MSG_CHANNEL_DATA 94
  ------------------
  |  Branch (614:9): [True: 46.0k, False: 0]
  ------------------
  615|  46.0k|        extended = 0;
  616|  46.0k|    } else { /* SSH_MSG_CHANNEL_EXTENDED_DATA */
  617|      0|        extended = 1;
  618|      0|    }
  619|       |
  620|  46.0k|    channel = channel_from_msg(session, packet);
  621|  46.0k|    if (channel == NULL) {
  ------------------
  |  Branch (621:9): [True: 0, False: 46.0k]
  ------------------
  622|      0|        SSH_LOG(SSH_LOG_FUNCTIONS, "%s", ssh_get_error(session));
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  623|       |
  624|      0|        return SSH_PACKET_USED;
  ------------------
  |  |  637|      0|#define SSH_PACKET_USED 1
  ------------------
  625|      0|    }
  626|       |
  627|  46.0k|    if (extended) {
  ------------------
  |  Branch (627:9): [True: 0, False: 46.0k]
  ------------------
  628|      0|        uint32_t data_type_code, rc;
  629|      0|        rc = ssh_buffer_get_u32(packet, &data_type_code);
  630|      0|        if (rc != sizeof(uint32_t)) {
  ------------------
  |  Branch (630:13): [True: 0, False: 0]
  ------------------
  631|      0|            SSH_LOG(SSH_LOG_PACKET,
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  632|      0|                    "Failed to read data type code: rc = %" PRIu32, rc);
  633|       |
  634|      0|            return SSH_PACKET_USED;
  ------------------
  |  |  637|      0|#define SSH_PACKET_USED 1
  ------------------
  635|      0|        }
  636|      0|        is_stderr = 1;
  637|      0|        data_type_code = ntohl(data_type_code);
  638|      0|        if (data_type_code != SSH2_EXTENDED_DATA_STDERR) {
  ------------------
  |  |   94|      0|#define SSH2_EXTENDED_DATA_STDERR			1
  ------------------
  |  Branch (638:13): [True: 0, False: 0]
  ------------------
  639|      0|            SSH_LOG(SSH_LOG_PACKET, "Invalid data type code %" PRIu32 "!",
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  640|      0|                    data_type_code);
  641|      0|        }
  642|      0|    }
  643|       |
  644|  46.0k|    str = ssh_buffer_get_ssh_string(packet);
  645|  46.0k|    if (str == NULL) {
  ------------------
  |  Branch (645:9): [True: 0, False: 46.0k]
  ------------------
  646|      0|        SSH_LOG(SSH_LOG_PACKET, "Invalid data packet!");
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  647|       |
  648|      0|        return SSH_PACKET_USED;
  ------------------
  |  |  637|      0|#define SSH_PACKET_USED 1
  ------------------
  649|      0|    }
  650|       |    /* STRING_SIZE_MAX < UINT32_MAX */
  651|  46.0k|    len = (uint32_t)ssh_string_len(str);
  652|       |
  653|  46.0k|    SSH_LOG(SSH_LOG_PACKET,
  ------------------
  |  |  281|  92.1k|    _ssh_log(priority, __func__, __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (281:34): [True: 0, False: 46.0k]
  |  |  ------------------
  ------------------
  654|  46.0k|            "Channel receiving %" PRIu32 " bytes data%s (local win=%" PRIu32
  655|  46.0k|            " remote win=%" PRIu32 ") on channel %" PRIu32 ":%" PRIu32,
  656|  46.0k|            len,
  657|  46.0k|            is_stderr ? " in stderr" : "",
  658|  46.0k|            channel->local_window,
  659|  46.0k|            channel->remote_window,
  660|  46.0k|            channel->local_channel,
  661|  46.0k|            channel->remote_channel);
  662|       |
  663|  46.0k|    if (len > channel->local_window) {
  ------------------
  |  Branch (663:9): [True: 0, False: 46.0k]
  ------------------
  664|      0|        SSH_LOG(SSH_LOG_RARE,
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  665|      0|                "Data packet too big for our window(%" PRIu32 " vs %" PRIu32 ")",
  666|      0|                len,
  667|      0|                channel->local_window);
  668|       |
  669|      0|        SSH_STRING_FREE(str);
  ------------------
  |  |  893|      0|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (893:14): [True: 0, False: 0]
  |  |  |  Branch (893:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
  670|       |
  671|      0|        ssh_set_error(session, SSH_FATAL, "Window exceeded");
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  672|       |
  673|      0|        return SSH_PACKET_USED;
  ------------------
  |  |  637|      0|#define SSH_PACKET_USED 1
  ------------------
  674|      0|    }
  675|       |
  676|  46.0k|    data = ssh_string_data(str);
  677|  46.0k|    if (channel_default_bufferize(channel, data, len, is_stderr) < 0) {
  ------------------
  |  Branch (677:9): [True: 0, False: 46.0k]
  ------------------
  678|      0|        SSH_STRING_FREE(str);
  ------------------
  |  |  893|      0|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (893:14): [True: 0, False: 0]
  |  |  |  Branch (893:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
  679|       |
  680|      0|        return SSH_PACKET_USED;
  ------------------
  |  |  637|      0|#define SSH_PACKET_USED 1
  ------------------
  681|      0|    }
  682|       |
  683|  46.0k|    channel->local_window -= len;
  684|       |
  685|  46.0k|    SSH_LOG(SSH_LOG_PACKET,
  ------------------
  |  |  281|  46.0k|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  686|  46.0k|            "Channel windows are now (local win=%" PRIu32 " remote win=%" PRIu32 ")",
  687|  46.0k|            channel->local_window,
  688|  46.0k|            channel->remote_window);
  689|       |
  690|  46.0k|    SSH_STRING_FREE(str);
  ------------------
  |  |  893|  46.0k|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (893:14): [True: 46.0k, False: 0]
  |  |  |  Branch (893:69): [Folded, False: 46.0k]
  |  |  ------------------
  ------------------
  691|       |
  692|  46.0k|    if (is_stderr) {
  ------------------
  |  Branch (692:9): [True: 0, False: 46.0k]
  ------------------
  693|      0|        buf = channel->stderr_buffer;
  694|  46.0k|    } else {
  695|  46.0k|        buf = channel->stdout_buffer;
  696|  46.0k|    }
  697|       |
  698|  46.0k|    ssh_callbacks_iterate(channel->callbacks,
  ------------------
  |  |  598|  46.0k|    do {                                                              \
  |  |  599|  46.0k|        struct ssh_iterator *_cb_i = ssh_list_get_iterator(_cb_list); \
  |  |  600|  46.0k|        _cb_type _cb;                                                 \
  |  |  601|  46.0k|        for (; _cb_i != NULL; _cb_i = _cb_i->next) {                  \
  |  |  ------------------
  |  |  |  Branch (601:16): [True: 0, False: 46.0k]
  |  |  ------------------
  |  |  602|      0|            _cb = ssh_iterator_value(_cb_type, _cb_i);                \
  |  |  ------------------
  |  |  |  |  114|      0|  ((type)((iterator)->data))
  |  |  ------------------
  |  |  603|      0|            if (ssh_callbacks_exists(_cb, _cb_name))
  |  |  ------------------
  |  |  |  |  547|      0|#define ssh_callbacks_exists(p,c) (\
  |  |  |  |  548|      0|  (p != NULL) && ( (char *)&((p)-> c) < (char *)(p) + (p)->size ) && \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (548:3): [True: 0, False: 0]
  |  |  |  |  |  Branch (548:18): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  549|      0|  ((p)-> c != NULL) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (549:3): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  550|      0|  )
  |  |  ------------------
  ------------------
  699|  46.0k|                          ssh_channel_callbacks,
  700|  46.0k|                          channel_data_function) {
  701|      0|        if (ssh_buffer_get(buf) == NULL) {
  ------------------
  |  Branch (701:13): [True: 0, False: 0]
  ------------------
  702|      0|            break;
  703|      0|        }
  704|      0|        rest = ssh_callbacks_iterate_exec(channel_data_function,
  ------------------
  |  |  612|      0|                _cb->_cb_name(__VA_ARGS__, _cb->userdata)
  ------------------
  705|      0|                                          channel->session,
  706|      0|                                          channel,
  707|      0|                                          ssh_buffer_get(buf),
  708|      0|                                          ssh_buffer_get_len(buf),
  709|      0|                                          is_stderr);
  710|      0|        if (rest > 0) {
  ------------------
  |  Branch (710:13): [True: 0, False: 0]
  ------------------
  711|      0|            int rc;
  712|      0|            if (channel->counter != NULL) {
  ------------------
  |  Branch (712:17): [True: 0, False: 0]
  ------------------
  713|      0|                channel->counter->in_bytes += rest;
  714|      0|            }
  715|      0|            ssh_buffer_pass_bytes(buf, rest);
  716|       |
  717|      0|            rc = grow_window(session, channel);
  718|      0|            if (rc == SSH_ERROR) {
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  |  Branch (718:17): [True: 0, False: 0]
  ------------------
  719|      0|              return -1;
  720|      0|            }
  721|      0|        }
  722|      0|    }
  723|  46.0k|    ssh_callbacks_iterate_end();
  ------------------
  |  |  618|      0|        }                           \
  |  |  619|  46.0k|    } while(0)
  |  |  ------------------
  |  |  |  Branch (619:13): [Folded, False: 46.0k]
  |  |  ------------------
  ------------------
  724|       |
  725|  46.0k|    return SSH_PACKET_USED;
  ------------------
  |  |  637|  46.0k|#define SSH_PACKET_USED 1
  ------------------
  726|  46.0k|}
channel_rcv_eof:
  729|  8.64k|{
  730|  8.64k|    ssh_channel channel = NULL;
  731|  8.64k|    (void)user;
  732|  8.64k|    (void)type;
  733|       |
  734|  8.64k|    channel = channel_from_msg(session, packet);
  735|  8.64k|    if (channel == NULL) {
  ------------------
  |  Branch (735:9): [True: 0, False: 8.64k]
  ------------------
  736|      0|        SSH_LOG(SSH_LOG_FUNCTIONS, "%s", ssh_get_error(session));
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  737|       |
  738|      0|        return SSH_PACKET_USED;
  ------------------
  |  |  637|      0|#define SSH_PACKET_USED 1
  ------------------
  739|      0|    }
  740|       |
  741|  8.64k|    SSH_LOG(SSH_LOG_PACKET,
  ------------------
  |  |  281|  8.64k|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  742|  8.64k|            "Received eof on channel (%" PRIu32 ":%" PRIu32 ")",
  743|  8.64k|            channel->local_channel,
  744|  8.64k|            channel->remote_channel);
  745|       |    /* channel->remote_window = 0; */
  746|  8.64k|    channel->remote_eof = 1;
  747|       |
  748|  8.64k|    ssh_callbacks_execute_list(channel->callbacks,
  ------------------
  |  |  566|  8.64k|    do {                                                      \
  |  |  567|  8.64k|        struct ssh_iterator *i = ssh_list_get_iterator(list); \
  |  |  568|  8.64k|        cbtype cb;                                            \
  |  |  569|  8.64k|        while (i != NULL){                                    \
  |  |  ------------------
  |  |  |  Branch (569:16): [True: 0, False: 8.64k]
  |  |  ------------------
  |  |  570|      0|            cb = ssh_iterator_value(cbtype, i);               \
  |  |  ------------------
  |  |  |  |  114|      0|  ((type)((iterator)->data))
  |  |  ------------------
  |  |  571|      0|            if (ssh_callbacks_exists(cb, c))                  \
  |  |  ------------------
  |  |  |  |  547|      0|#define ssh_callbacks_exists(p,c) (\
  |  |  |  |  548|      0|  (p != NULL) && ( (char *)&((p)-> c) < (char *)(p) + (p)->size ) && \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (548:3): [True: 0, False: 0]
  |  |  |  |  |  Branch (548:18): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  549|      0|  ((p)-> c != NULL) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (549:3): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  550|      0|  )
  |  |  ------------------
  |  |  572|      0|                cb-> c (__VA_ARGS__, cb->userdata);           \
  |  |  573|      0|            i = i->next;                                      \
  |  |  574|      0|        }                                                     \
  |  |  575|  8.64k|    } while(0)
  |  |  ------------------
  |  |  |  Branch (575:13): [Folded, False: 8.64k]
  |  |  ------------------
  ------------------
  749|  8.64k|                               ssh_channel_callbacks,
  750|  8.64k|                               channel_eof_function,
  751|  8.64k|                               channel->session,
  752|  8.64k|                               channel);
  753|       |
  754|  8.64k|    return SSH_PACKET_USED;
  ------------------
  |  |  637|  8.64k|#define SSH_PACKET_USED 1
  ------------------
  755|  8.64k|}
channel_rcv_close:
  775|  8.64k|{
  776|  8.64k|    ssh_channel channel = NULL;
  777|  8.64k|    (void)user;
  778|  8.64k|    (void)type;
  779|       |
  780|  8.64k|    channel = channel_from_msg(session,packet);
  781|  8.64k|    if (channel == NULL) {
  ------------------
  |  Branch (781:9): [True: 0, False: 8.64k]
  ------------------
  782|      0|        SSH_LOG(SSH_LOG_FUNCTIONS, "%s", ssh_get_error(session));
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  783|       |
  784|      0|        return SSH_PACKET_USED;
  ------------------
  |  |  637|      0|#define SSH_PACKET_USED 1
  ------------------
  785|      0|    }
  786|       |
  787|  8.64k|    SSH_LOG(SSH_LOG_PACKET,
  ------------------
  |  |  281|  8.64k|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  788|  8.64k|        "Received close on channel (%" PRIu32 ":%" PRIu32 ")",
  789|  8.64k|        channel->local_channel,
  790|  8.64k|        channel->remote_channel);
  791|       |
  792|  8.64k|    if (!ssh_channel_has_unread_data(channel)) {
  ------------------
  |  Branch (792:9): [True: 0, False: 8.64k]
  ------------------
  793|      0|        channel->state = SSH_CHANNEL_STATE_CLOSED;
  794|  8.64k|    } else {
  795|  8.64k|        channel->delayed_close = 1;
  796|  8.64k|    }
  797|       |
  798|  8.64k|    if (channel->remote_eof == 0) {
  ------------------
  |  Branch (798:9): [True: 0, False: 8.64k]
  ------------------
  799|      0|        SSH_LOG(SSH_LOG_PACKET,
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  800|      0|            "Remote host not polite enough to send an eof before close");
  801|      0|    }
  802|       |    /*
  803|       |    * The remote eof doesn't break things if there was still data into read
  804|       |    * buffer because the eof is ignored until the buffer is empty.
  805|       |    */
  806|  8.64k|    channel->remote_eof = 1;
  807|       |
  808|  8.64k|    ssh_callbacks_execute_list(channel->callbacks,
  ------------------
  |  |  566|  8.64k|    do {                                                      \
  |  |  567|  8.64k|        struct ssh_iterator *i = ssh_list_get_iterator(list); \
  |  |  568|  8.64k|        cbtype cb;                                            \
  |  |  569|  8.64k|        while (i != NULL){                                    \
  |  |  ------------------
  |  |  |  Branch (569:16): [True: 0, False: 8.64k]
  |  |  ------------------
  |  |  570|      0|            cb = ssh_iterator_value(cbtype, i);               \
  |  |  ------------------
  |  |  |  |  114|      0|  ((type)((iterator)->data))
  |  |  ------------------
  |  |  571|      0|            if (ssh_callbacks_exists(cb, c))                  \
  |  |  ------------------
  |  |  |  |  547|      0|#define ssh_callbacks_exists(p,c) (\
  |  |  |  |  548|      0|  (p != NULL) && ( (char *)&((p)-> c) < (char *)(p) + (p)->size ) && \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (548:3): [True: 0, False: 0]
  |  |  |  |  |  Branch (548:18): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  549|      0|  ((p)-> c != NULL) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (549:3): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  550|      0|  )
  |  |  ------------------
  |  |  572|      0|                cb-> c (__VA_ARGS__, cb->userdata);           \
  |  |  573|      0|            i = i->next;                                      \
  |  |  574|      0|        }                                                     \
  |  |  575|  8.64k|    } while(0)
  |  |  ------------------
  |  |  |  Branch (575:13): [Folded, False: 8.64k]
  |  |  ------------------
  ------------------
  809|  8.64k|                               ssh_channel_callbacks,
  810|  8.64k|                               channel_close_function,
  811|  8.64k|                               channel->session,
  812|  8.64k|                               channel);
  813|       |
  814|  8.64k|    channel->flags |= SSH_CHANNEL_FLAG_CLOSED_REMOTE;
  ------------------
  |  |   55|  8.64k|#define SSH_CHANNEL_FLAG_CLOSED_REMOTE 0x0001
  ------------------
  815|  8.64k|    if(channel->flags & SSH_CHANNEL_FLAG_FREED_LOCAL)
  ------------------
  |  |   61|  8.64k|#define SSH_CHANNEL_FLAG_FREED_LOCAL 0x0004
  ------------------
  |  Branch (815:8): [True: 0, False: 8.64k]
  ------------------
  816|      0|        ssh_channel_do_free(channel);
  817|       |
  818|  8.64k|    return SSH_PACKET_USED;
  ------------------
  |  |  637|  8.64k|#define SSH_PACKET_USED 1
  ------------------
  819|  8.64k|}
channel_rcv_request:
  822|  8.64k|{
  823|  8.64k|    ssh_channel channel = NULL;
  824|  8.64k|    char *request = NULL;
  825|  8.64k|    uint8_t want_reply;
  826|  8.64k|    int rc;
  827|  8.64k|    (void)user;
  828|  8.64k|    (void)type;
  829|       |
  830|  8.64k|    channel = channel_from_msg(session, packet);
  831|  8.64k|    if (channel == NULL) {
  ------------------
  |  Branch (831:9): [True: 0, False: 8.64k]
  ------------------
  832|      0|        SSH_LOG(SSH_LOG_FUNCTIONS, "%s", ssh_get_error(session));
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  833|      0|        return SSH_PACKET_USED;
  ------------------
  |  |  637|      0|#define SSH_PACKET_USED 1
  ------------------
  834|      0|    }
  835|       |
  836|  8.64k|    rc = ssh_buffer_unpack(packet, "sb", &request, &want_reply);
  ------------------
  |  |   60|  8.64k|    _ssh_buffer_unpack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |  451|  8.64k|        (__VA_NARG_(__VA_ARGS__, __RSEQ_N()))
  |  |  |  |  ------------------
  |  |  |  |  |  |  453|  8.64k|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  448|  8.64k|#define VA_APPLY_VARIADIC_MACRO(macro, tuple) macro tuple
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  453|  8.64k|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  461|  8.64k|        _61,_62,_63,N,...) N
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                   _ssh_buffer_unpack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |   28|  8.64k|#define SSH_BUFFER_PACK_END ((uint32_t) 0x4f65feb3)
  |  |  ------------------
  ------------------
  837|  8.64k|    if (rc != SSH_OK) {
  ------------------
  |  |  316|  8.64k|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (837:9): [True: 0, False: 8.64k]
  ------------------
  838|      0|        SSH_LOG(SSH_LOG_PACKET, "Invalid MSG_CHANNEL_REQUEST");
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  839|      0|        return SSH_PACKET_USED;
  ------------------
  |  |  637|      0|#define SSH_PACKET_USED 1
  ------------------
  840|      0|    }
  841|       |
  842|  8.64k|    if (strcmp(request, "exit-status") == 0) {
  ------------------
  |  Branch (842:9): [True: 0, False: 8.64k]
  ------------------
  843|      0|        SAFE_FREE(request);
  ------------------
  |  |  373|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
  844|      0|        rc = ssh_buffer_unpack(packet, "d", &channel->exit.code);
  ------------------
  |  |   60|      0|    _ssh_buffer_unpack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |  451|      0|        (__VA_NARG_(__VA_ARGS__, __RSEQ_N()))
  |  |  |  |  ------------------
  |  |  |  |  |  |  453|      0|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  448|      0|#define VA_APPLY_VARIADIC_MACRO(macro, tuple) macro tuple
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  453|      0|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  461|      0|        _61,_62,_63,N,...) N
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                   _ssh_buffer_unpack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |   28|      0|#define SSH_BUFFER_PACK_END ((uint32_t) 0x4f65feb3)
  |  |  ------------------
  ------------------
  845|      0|        if (rc != SSH_OK) {
  ------------------
  |  |  316|      0|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (845:13): [True: 0, False: 0]
  ------------------
  846|      0|            SSH_LOG(SSH_LOG_PACKET, "Invalid exit-status packet");
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  847|      0|            return SSH_PACKET_USED;
  ------------------
  |  |  637|      0|#define SSH_PACKET_USED 1
  ------------------
  848|      0|        }
  849|      0|        channel->exit.status = true;
  850|       |
  851|      0|        SSH_LOG(SSH_LOG_PACKET,
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  852|      0|                "received exit-status %u on channel %" PRIu32 ":%" PRIu32,
  853|      0|                channel->exit.code,
  854|      0|                channel->local_channel,
  855|      0|                channel->remote_channel);
  856|       |
  857|      0|        ssh_callbacks_execute_list(channel->callbacks,
  ------------------
  |  |  566|      0|    do {                                                      \
  |  |  567|      0|        struct ssh_iterator *i = ssh_list_get_iterator(list); \
  |  |  568|      0|        cbtype cb;                                            \
  |  |  569|      0|        while (i != NULL){                                    \
  |  |  ------------------
  |  |  |  Branch (569:16): [True: 0, False: 0]
  |  |  ------------------
  |  |  570|      0|            cb = ssh_iterator_value(cbtype, i);               \
  |  |  ------------------
  |  |  |  |  114|      0|  ((type)((iterator)->data))
  |  |  ------------------
  |  |  571|      0|            if (ssh_callbacks_exists(cb, c))                  \
  |  |  ------------------
  |  |  |  |  547|      0|#define ssh_callbacks_exists(p,c) (\
  |  |  |  |  548|      0|  (p != NULL) && ( (char *)&((p)-> c) < (char *)(p) + (p)->size ) && \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (548:3): [True: 0, False: 0]
  |  |  |  |  |  Branch (548:18): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  549|      0|  ((p)-> c != NULL) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (549:3): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  550|      0|  )
  |  |  ------------------
  |  |  572|      0|                cb-> c (__VA_ARGS__, cb->userdata);           \
  |  |  573|      0|            i = i->next;                                      \
  |  |  574|      0|        }                                                     \
  |  |  575|      0|    } while(0)
  |  |  ------------------
  |  |  |  Branch (575:13): [Folded, False: 0]
  |  |  ------------------
  ------------------
  858|      0|                                   ssh_channel_callbacks,
  859|      0|                                   channel_exit_status_function,
  860|      0|                                   channel->session,
  861|      0|                                   channel,
  862|      0|                                   channel->exit.code);
  863|       |
  864|      0|        return SSH_PACKET_USED;
  ------------------
  |  |  637|      0|#define SSH_PACKET_USED 1
  ------------------
  865|      0|    }
  866|       |
  867|  8.64k|    if (strcmp(request, "signal") == 0) {
  ------------------
  |  Branch (867:9): [True: 0, False: 8.64k]
  ------------------
  868|      0|        char *sig = NULL;
  869|       |
  870|      0|        SAFE_FREE(request);
  ------------------
  |  |  373|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
  871|      0|        SSH_LOG(SSH_LOG_PACKET, "received signal");
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  872|       |
  873|      0|        rc = ssh_buffer_unpack(packet, "s", &sig);
  ------------------
  |  |   60|      0|    _ssh_buffer_unpack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |  451|      0|        (__VA_NARG_(__VA_ARGS__, __RSEQ_N()))
  |  |  |  |  ------------------
  |  |  |  |  |  |  453|      0|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  448|      0|#define VA_APPLY_VARIADIC_MACRO(macro, tuple) macro tuple
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  453|      0|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  461|      0|        _61,_62,_63,N,...) N
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                   _ssh_buffer_unpack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |   28|      0|#define SSH_BUFFER_PACK_END ((uint32_t) 0x4f65feb3)
  |  |  ------------------
  ------------------
  874|      0|        if (rc != SSH_OK) {
  ------------------
  |  |  316|      0|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (874:13): [True: 0, False: 0]
  ------------------
  875|      0|            SSH_LOG(SSH_LOG_PACKET, "Invalid MSG_CHANNEL_REQUEST");
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  876|      0|            return SSH_PACKET_USED;
  ------------------
  |  |  637|      0|#define SSH_PACKET_USED 1
  ------------------
  877|      0|        }
  878|       |
  879|      0|        SSH_LOG(SSH_LOG_PACKET, "Remote connection sent a signal SIG %s", sig);
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  880|      0|        ssh_callbacks_execute_list(channel->callbacks,
  ------------------
  |  |  566|      0|    do {                                                      \
  |  |  567|      0|        struct ssh_iterator *i = ssh_list_get_iterator(list); \
  |  |  568|      0|        cbtype cb;                                            \
  |  |  569|      0|        while (i != NULL){                                    \
  |  |  ------------------
  |  |  |  Branch (569:16): [True: 0, False: 0]
  |  |  ------------------
  |  |  570|      0|            cb = ssh_iterator_value(cbtype, i);               \
  |  |  ------------------
  |  |  |  |  114|      0|  ((type)((iterator)->data))
  |  |  ------------------
  |  |  571|      0|            if (ssh_callbacks_exists(cb, c))                  \
  |  |  ------------------
  |  |  |  |  547|      0|#define ssh_callbacks_exists(p,c) (\
  |  |  |  |  548|      0|  (p != NULL) && ( (char *)&((p)-> c) < (char *)(p) + (p)->size ) && \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (548:3): [True: 0, False: 0]
  |  |  |  |  |  Branch (548:18): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  549|      0|  ((p)-> c != NULL) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (549:3): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  550|      0|  )
  |  |  ------------------
  |  |  572|      0|                cb-> c (__VA_ARGS__, cb->userdata);           \
  |  |  573|      0|            i = i->next;                                      \
  |  |  574|      0|        }                                                     \
  |  |  575|      0|    } while(0)
  |  |  ------------------
  |  |  |  Branch (575:13): [Folded, False: 0]
  |  |  ------------------
  ------------------
  881|      0|                                   ssh_channel_callbacks,
  882|      0|                                   channel_signal_function,
  883|      0|                                   channel->session,
  884|      0|                                   channel,
  885|      0|                                   sig);
  886|      0|        SAFE_FREE(sig);
  ------------------
  |  |  373|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
  887|       |
  888|      0|        return SSH_PACKET_USED;
  ------------------
  |  |  637|      0|#define SSH_PACKET_USED 1
  ------------------
  889|      0|    }
  890|       |
  891|  8.64k|    if (strcmp(request, "exit-signal") == 0) {
  ------------------
  |  Branch (891:9): [True: 0, False: 8.64k]
  ------------------
  892|      0|        const char *core = "(core dumped)";
  893|      0|        char *sig = NULL;
  894|      0|        char *errmsg = NULL;
  895|      0|        char *lang = NULL;
  896|      0|        uint8_t core_dumped;
  897|       |
  898|      0|        SAFE_FREE(request);
  ------------------
  |  |  373|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
  899|       |
  900|      0|        rc = ssh_buffer_unpack(packet,
  ------------------
  |  |   60|      0|    _ssh_buffer_unpack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |  451|      0|        (__VA_NARG_(__VA_ARGS__, __RSEQ_N()))
  |  |  |  |  ------------------
  |  |  |  |  |  |  453|      0|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  448|      0|#define VA_APPLY_VARIADIC_MACRO(macro, tuple) macro tuple
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  453|      0|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  461|      0|        _61,_62,_63,N,...) N
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                   _ssh_buffer_unpack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |   28|      0|#define SSH_BUFFER_PACK_END ((uint32_t) 0x4f65feb3)
  |  |  ------------------
  ------------------
  901|      0|                               "sbss",
  902|      0|                               &sig,         /* signal name */
  903|      0|                               &core_dumped, /* core dumped */
  904|      0|                               &errmsg,      /* error message */
  905|      0|                               &lang);
  906|      0|        if (rc != SSH_OK) {
  ------------------
  |  |  316|      0|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (906:13): [True: 0, False: 0]
  ------------------
  907|      0|            SSH_LOG(SSH_LOG_PACKET, "Invalid MSG_CHANNEL_REQUEST");
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  908|      0|            return SSH_PACKET_USED;
  ------------------
  |  |  637|      0|#define SSH_PACKET_USED 1
  ------------------
  909|      0|        }
  910|       |
  911|      0|        if (core_dumped == 0) {
  ------------------
  |  Branch (911:13): [True: 0, False: 0]
  ------------------
  912|      0|            core = "";
  913|      0|        }
  914|       |
  915|      0|        SSH_LOG(SSH_LOG_PACKET,
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  916|      0|                "Remote connection closed by signal SIG %s %s",
  917|      0|                sig,
  918|      0|                core);
  919|      0|        ssh_callbacks_execute_list(channel->callbacks,
  ------------------
  |  |  566|      0|    do {                                                      \
  |  |  567|      0|        struct ssh_iterator *i = ssh_list_get_iterator(list); \
  |  |  568|      0|        cbtype cb;                                            \
  |  |  569|      0|        while (i != NULL){                                    \
  |  |  ------------------
  |  |  |  Branch (569:16): [True: 0, False: 0]
  |  |  ------------------
  |  |  570|      0|            cb = ssh_iterator_value(cbtype, i);               \
  |  |  ------------------
  |  |  |  |  114|      0|  ((type)((iterator)->data))
  |  |  ------------------
  |  |  571|      0|            if (ssh_callbacks_exists(cb, c))                  \
  |  |  ------------------
  |  |  |  |  547|      0|#define ssh_callbacks_exists(p,c) (\
  |  |  |  |  548|      0|  (p != NULL) && ( (char *)&((p)-> c) < (char *)(p) + (p)->size ) && \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (548:3): [True: 0, False: 0]
  |  |  |  |  |  Branch (548:18): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  549|      0|  ((p)-> c != NULL) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (549:3): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  550|      0|  )
  |  |  ------------------
  |  |  572|      0|                cb-> c (__VA_ARGS__, cb->userdata);           \
  |  |  573|      0|            i = i->next;                                      \
  |  |  574|      0|        }                                                     \
  |  |  575|      0|    } while(0)
  |  |  ------------------
  |  |  |  Branch (575:13): [Folded, False: 0]
  |  |  ------------------
  ------------------
  920|      0|                                   ssh_channel_callbacks,
  921|      0|                                   channel_exit_signal_function,
  922|      0|                                   channel->session,
  923|      0|                                   channel,
  924|      0|                                   sig,
  925|      0|                                   core_dumped,
  926|      0|                                   errmsg,
  927|      0|                                   lang);
  928|       |
  929|      0|        channel->exit.core_dumped = core_dumped;
  930|      0|        if (sig != NULL) {
  ------------------
  |  Branch (930:13): [True: 0, False: 0]
  ------------------
  931|      0|            SAFE_FREE(channel->exit.signal);
  ------------------
  |  |  373|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
  932|      0|            channel->exit.signal = sig;
  933|      0|        }
  934|      0|        channel->exit.status = true;
  935|       |
  936|      0|        SAFE_FREE(lang);
  ------------------
  |  |  373|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
  937|      0|        SAFE_FREE(errmsg);
  ------------------
  |  |  373|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
  938|       |
  939|      0|        return SSH_PACKET_USED;
  ------------------
  |  |  637|      0|#define SSH_PACKET_USED 1
  ------------------
  940|      0|    }
  941|  8.64k|    if (strcmp(request, "keepalive@openssh.com") == 0) {
  ------------------
  |  Branch (941:9): [True: 0, False: 8.64k]
  ------------------
  942|      0|        SAFE_FREE(request);
  ------------------
  |  |  373|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
  943|      0|        SSH_LOG(SSH_LOG_DEBUG, "Responding to Openssh's keepalive");
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  944|       |
  945|      0|        rc = ssh_buffer_pack(session->out_buffer,
  ------------------
  |  |   50|      0|    _ssh_buffer_pack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |  451|      0|        (__VA_NARG_(__VA_ARGS__, __RSEQ_N()))
  |  |  |  |  ------------------
  |  |  |  |  |  |  453|      0|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  448|      0|#define VA_APPLY_VARIADIC_MACRO(macro, tuple) macro tuple
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  453|      0|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  461|      0|        _61,_62,_63,N,...) N
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                   _ssh_buffer_pack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |   28|      0|#define SSH_BUFFER_PACK_END ((uint32_t) 0x4f65feb3)
  |  |  ------------------
  ------------------
  946|      0|                             "bd",
  947|      0|                             SSH2_MSG_CHANNEL_FAILURE,
  948|      0|                             channel->remote_channel);
  949|      0|        if (rc != SSH_OK) {
  ------------------
  |  |  316|      0|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (949:13): [True: 0, False: 0]
  ------------------
  950|      0|            return SSH_PACKET_USED;
  ------------------
  |  |  637|      0|#define SSH_PACKET_USED 1
  ------------------
  951|      0|        }
  952|      0|        ssh_packet_send(session);
  953|       |
  954|      0|        return SSH_PACKET_USED;
  ------------------
  |  |  637|      0|#define SSH_PACKET_USED 1
  ------------------
  955|      0|    }
  956|       |
  957|  8.64k|    if (strcmp(request, "auth-agent-req@openssh.com") == 0) {
  ------------------
  |  Branch (957:9): [True: 0, False: 8.64k]
  ------------------
  958|      0|        int status;
  959|       |
  960|      0|        SAFE_FREE(request);
  ------------------
  |  |  373|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
  961|      0|        SSH_LOG(SSH_LOG_DEBUG, "Received an auth-agent-req request");
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  962|       |
  963|      0|        status = SSH2_MSG_CHANNEL_FAILURE;
  ------------------
  |  |   64|      0|#define SSH2_MSG_CHANNEL_FAILURE 100
  ------------------
  964|      0|        ssh_callbacks_iterate (channel->callbacks,
  ------------------
  |  |  598|      0|    do {                                                              \
  |  |  599|      0|        struct ssh_iterator *_cb_i = ssh_list_get_iterator(_cb_list); \
  |  |  600|      0|        _cb_type _cb;                                                 \
  |  |  601|      0|        for (; _cb_i != NULL; _cb_i = _cb_i->next) {                  \
  |  |  ------------------
  |  |  |  Branch (601:16): [True: 0, False: 0]
  |  |  ------------------
  |  |  602|      0|            _cb = ssh_iterator_value(_cb_type, _cb_i);                \
  |  |  ------------------
  |  |  |  |  114|      0|  ((type)((iterator)->data))
  |  |  ------------------
  |  |  603|      0|            if (ssh_callbacks_exists(_cb, _cb_name))
  |  |  ------------------
  |  |  |  |  547|      0|#define ssh_callbacks_exists(p,c) (\
  |  |  |  |  548|      0|  (p != NULL) && ( (char *)&((p)-> c) < (char *)(p) + (p)->size ) && \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (548:3): [True: 0, False: 0]
  |  |  |  |  |  Branch (548:18): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  549|      0|  ((p)-> c != NULL) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (549:3): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  550|      0|  )
  |  |  ------------------
  ------------------
  965|      0|                               ssh_channel_callbacks,
  966|      0|                               channel_auth_agent_req_function) {
  967|      0|            ssh_callbacks_iterate_exec(channel_auth_agent_req_function,
  ------------------
  |  |  612|      0|                _cb->_cb_name(__VA_ARGS__, _cb->userdata)
  ------------------
  968|      0|                                       channel->session,
  969|      0|                                       channel);
  970|       |            /* in lieu of a return value, if the callback exists it's supported
  971|       |             */
  972|      0|            status = SSH2_MSG_CHANNEL_SUCCESS;
  ------------------
  |  |   63|      0|#define SSH2_MSG_CHANNEL_SUCCESS 99
  ------------------
  973|      0|            break;
  974|      0|        }
  975|      0|        ssh_callbacks_iterate_end();
  ------------------
  |  |  618|      0|        }                           \
  |  |  619|      0|    } while(0)
  |  |  ------------------
  |  |  |  Branch (619:13): [Folded, False: 0]
  |  |  ------------------
  ------------------
  976|       |
  977|      0|        if (want_reply) {
  ------------------
  |  Branch (977:13): [True: 0, False: 0]
  ------------------
  978|      0|            rc = ssh_buffer_pack(session->out_buffer,
  ------------------
  |  |   50|      0|    _ssh_buffer_pack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |  451|      0|        (__VA_NARG_(__VA_ARGS__, __RSEQ_N()))
  |  |  |  |  ------------------
  |  |  |  |  |  |  453|      0|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  448|      0|#define VA_APPLY_VARIADIC_MACRO(macro, tuple) macro tuple
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  453|      0|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  461|      0|        _61,_62,_63,N,...) N
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                   _ssh_buffer_pack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |   28|      0|#define SSH_BUFFER_PACK_END ((uint32_t) 0x4f65feb3)
  |  |  ------------------
  ------------------
  979|      0|                                 "bd",
  980|      0|                                 status,
  981|      0|                                 channel->remote_channel);
  982|      0|            if (rc != SSH_OK) {
  ------------------
  |  |  316|      0|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (982:17): [True: 0, False: 0]
  ------------------
  983|      0|                return SSH_PACKET_USED;
  ------------------
  |  |  637|      0|#define SSH_PACKET_USED 1
  ------------------
  984|      0|            }
  985|      0|            ssh_packet_send(session);
  986|      0|        }
  987|       |
  988|      0|        return SSH_PACKET_USED;
  ------------------
  |  |  637|      0|#define SSH_PACKET_USED 1
  ------------------
  989|      0|    }
  990|  8.64k|#ifdef WITH_SERVER
  991|       |    /* If we are here, that means we have a request that is not in the
  992|       |     * understood client requests. That means we need to create a ssh message to
  993|       |     * be passed to the user code handling ssh messages
  994|       |     */
  995|  8.64k|    ssh_message_handle_channel_request(session,
  996|  8.64k|                                       channel,
  997|  8.64k|                                       packet,
  998|  8.64k|                                       request,
  999|  8.64k|                                       want_reply);
 1000|       |#else
 1001|       |    SSH_LOG(SSH_LOG_DEBUG, "Unhandled channel request %s", request);
 1002|       |#endif
 1003|       |
 1004|  8.64k|    SAFE_FREE(request);
  ------------------
  |  |  373|  8.64k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 8.64k, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 8.64k]
  |  |  ------------------
  ------------------
 1005|       |
 1006|  8.64k|    return SSH_PACKET_USED;
  ------------------
  |  |  637|  8.64k|#define SSH_PACKET_USED 1
  ------------------
 1007|  8.64k|}
channel_default_bufferize:
 1018|  46.0k|{
 1019|  46.0k|    ssh_session session = NULL;
 1020|       |
 1021|  46.0k|    if (channel == NULL) {
  ------------------
  |  Branch (1021:9): [True: 0, False: 46.0k]
  ------------------
 1022|      0|        return -1;
 1023|      0|    }
 1024|       |
 1025|  46.0k|    session = channel->session;
 1026|       |
 1027|  46.0k|    if (data == NULL) {
  ------------------
  |  Branch (1027:9): [True: 0, False: 46.0k]
  ------------------
 1028|      0|        ssh_set_error_invalid(session);
  ------------------
  |  |  322|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 1029|      0|        return -1;
 1030|      0|    }
 1031|       |
 1032|  46.0k|    SSH_LOG(SSH_LOG_PACKET,
  ------------------
  |  |  281|  92.1k|    _ssh_log(priority, __func__, __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (281:34): [True: 0, False: 46.0k]
  |  |  ------------------
  ------------------
 1033|  46.0k|            "placing %" PRIu32 " bytes into channel buffer (%s)",
 1034|  46.0k|            len,
 1035|  46.0k|            is_stderr ? "stderr" : "stdout");
 1036|  46.0k|    if (!is_stderr) {
  ------------------
  |  Branch (1036:9): [True: 46.0k, False: 0]
  ------------------
 1037|       |        /* stdout */
 1038|  46.0k|        if (channel->stdout_buffer == NULL) {
  ------------------
  |  Branch (1038:13): [True: 0, False: 46.0k]
  ------------------
 1039|      0|            channel->stdout_buffer = ssh_buffer_new();
 1040|      0|            if (channel->stdout_buffer == NULL) {
  ------------------
  |  Branch (1040:17): [True: 0, False: 0]
  ------------------
 1041|      0|                ssh_set_error_oom(session);
  ------------------
  |  |  318|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
 1042|      0|                return -1;
 1043|      0|            }
 1044|      0|        }
 1045|       |
 1046|  46.0k|        if (ssh_buffer_add_data(channel->stdout_buffer, data, len) < 0) {
  ------------------
  |  Branch (1046:13): [True: 0, False: 46.0k]
  ------------------
 1047|      0|            ssh_set_error_oom(session);
  ------------------
  |  |  318|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
 1048|      0|            SSH_BUFFER_FREE(channel->stdout_buffer);
  ------------------
  |  |  934|      0|    do { if ((x) != NULL) { ssh_buffer_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (934:14): [True: 0, False: 0]
  |  |  |  Branch (934:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1049|      0|            channel->stdout_buffer = NULL;
 1050|      0|            return -1;
 1051|      0|        }
 1052|  46.0k|    } else {
 1053|       |        /* stderr */
 1054|      0|        if (channel->stderr_buffer == NULL) {
  ------------------
  |  Branch (1054:13): [True: 0, False: 0]
  ------------------
 1055|      0|            channel->stderr_buffer = ssh_buffer_new();
 1056|      0|            if (channel->stderr_buffer == NULL) {
  ------------------
  |  Branch (1056:17): [True: 0, False: 0]
  ------------------
 1057|      0|                ssh_set_error_oom(session);
  ------------------
  |  |  318|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
 1058|      0|                return -1;
 1059|      0|            }
 1060|      0|        }
 1061|       |
 1062|      0|        if (ssh_buffer_add_data(channel->stderr_buffer, data, len) < 0) {
  ------------------
  |  Branch (1062:13): [True: 0, False: 0]
  ------------------
 1063|      0|            ssh_set_error_oom(session);
  ------------------
  |  |  318|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
 1064|      0|            SSH_BUFFER_FREE(channel->stderr_buffer);
  ------------------
  |  |  934|      0|    do { if ((x) != NULL) { ssh_buffer_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (934:14): [True: 0, False: 0]
  |  |  |  Branch (934:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1065|      0|            channel->stderr_buffer = NULL;
 1066|      0|            return -1;
 1067|      0|        }
 1068|      0|    }
 1069|       |
 1070|  46.0k|    return 0;
 1071|  46.0k|}
ssh_channel_open_session:
 1089|  8.64k|{
 1090|  8.64k|  if (channel == NULL) {
  ------------------
  |  Branch (1090:7): [True: 0, False: 8.64k]
  ------------------
 1091|      0|      return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 1092|      0|  }
 1093|       |
 1094|  8.64k|  return channel_open(channel,
 1095|  8.64k|                      "session",
 1096|  8.64k|                      WINDOW_DEFAULT,
  ------------------
  |  |   67|  8.64k|#define WINDOW_DEFAULT (64*CHANNEL_MAX_PACKET)
  |  |  ------------------
  |  |  |  |   60|  8.64k|#define CHANNEL_MAX_PACKET 32768
  |  |  ------------------
  ------------------
 1097|  8.64k|                      CHANNEL_MAX_PACKET,
  ------------------
  |  |   60|  8.64k|#define CHANNEL_MAX_PACKET 32768
  ------------------
 1098|       |                      NULL);
 1099|  8.64k|}
ssh_channel_free:
 1292|  8.64k|{
 1293|  8.64k|    ssh_session session = NULL;
 1294|       |
 1295|  8.64k|    if (channel == NULL) {
  ------------------
  |  Branch (1295:9): [True: 0, False: 8.64k]
  ------------------
 1296|      0|        return;
 1297|      0|    }
 1298|       |
 1299|  8.64k|    session = channel->session;
 1300|  8.64k|    if (session->alive) {
  ------------------
  |  Branch (1300:9): [True: 0, False: 8.64k]
  ------------------
 1301|      0|        bool send_close = false;
 1302|       |
 1303|      0|        switch (channel->state) {
 1304|      0|        case SSH_CHANNEL_STATE_OPEN:
  ------------------
  |  Branch (1304:9): [True: 0, False: 0]
  ------------------
 1305|      0|            send_close = true;
 1306|      0|            break;
 1307|      0|        case SSH_CHANNEL_STATE_CLOSED:
  ------------------
  |  Branch (1307:9): [True: 0, False: 0]
  ------------------
 1308|      0|            if (channel->flags & SSH_CHANNEL_FLAG_CLOSED_REMOTE) {
  ------------------
  |  |   55|      0|#define SSH_CHANNEL_FLAG_CLOSED_REMOTE 0x0001
  ------------------
  |  Branch (1308:17): [True: 0, False: 0]
  ------------------
 1309|      0|                send_close = true;
 1310|      0|            }
 1311|      0|            if (channel->flags & SSH_CHANNEL_FLAG_CLOSED_LOCAL) {
  ------------------
  |  |   58|      0|#define SSH_CHANNEL_FLAG_CLOSED_LOCAL 0x0002
  ------------------
  |  Branch (1311:17): [True: 0, False: 0]
  ------------------
 1312|      0|                send_close = false;
 1313|      0|            }
 1314|      0|            break;
 1315|      0|        default:
  ------------------
  |  Branch (1315:9): [True: 0, False: 0]
  ------------------
 1316|      0|            send_close = false;
 1317|      0|            break;
 1318|      0|        }
 1319|       |
 1320|      0|        if (send_close) {
  ------------------
  |  Branch (1320:13): [True: 0, False: 0]
  ------------------
 1321|      0|            ssh_channel_close(channel);
 1322|      0|        }
 1323|      0|    }
 1324|  8.64k|    channel->flags |= SSH_CHANNEL_FLAG_FREED_LOCAL;
  ------------------
  |  |   61|  8.64k|#define SSH_CHANNEL_FLAG_FREED_LOCAL 0x0004
  ------------------
 1325|       |
 1326|  8.64k|    if (channel->callbacks != NULL) {
  ------------------
  |  Branch (1326:9): [True: 0, False: 8.64k]
  ------------------
 1327|      0|        ssh_list_free(channel->callbacks);
 1328|      0|        channel->callbacks = NULL;
 1329|      0|    }
 1330|       |
 1331|       |    /* The idea behind the flags is the following : it is well possible
 1332|       |     * that a client closes a channel that still exists on the server side.
 1333|       |     * We definitively close the channel when we receive a close message *and*
 1334|       |     * the user closed it.
 1335|       |     */
 1336|  8.64k|    if ((channel->flags & SSH_CHANNEL_FLAG_CLOSED_REMOTE) ||
  ------------------
  |  |   55|  8.64k|#define SSH_CHANNEL_FLAG_CLOSED_REMOTE 0x0001
  ------------------
  |  Branch (1336:9): [True: 8.64k, False: 2]
  ------------------
 1337|  8.64k|        (channel->flags & SSH_CHANNEL_FLAG_NOT_BOUND)) {
  ------------------
  |  |   64|      2|#define SSH_CHANNEL_FLAG_NOT_BOUND 0x0008
  ------------------
  |  Branch (1337:9): [True: 2, False: 0]
  ------------------
 1338|  8.64k|        ssh_channel_do_free(channel);
 1339|  8.64k|    }
 1340|  8.64k|}
ssh_channel_do_free:
 1348|  17.2k|{
 1349|  17.2k|    struct ssh_iterator *it = NULL;
 1350|  17.2k|    ssh_session session = channel->session;
 1351|       |
 1352|  17.2k|    it = ssh_list_find(session->channels, channel);
 1353|  17.2k|    if (it != NULL) {
  ------------------
  |  Branch (1353:9): [True: 17.2k, False: 0]
  ------------------
 1354|  17.2k|        ssh_list_remove(session->channels, it);
 1355|  17.2k|    }
 1356|       |
 1357|  17.2k|    SSH_BUFFER_FREE(channel->stdout_buffer);
  ------------------
  |  |  934|  17.2k|    do { if ((x) != NULL) { ssh_buffer_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (934:14): [True: 17.2k, False: 0]
  |  |  |  Branch (934:69): [Folded, False: 17.2k]
  |  |  ------------------
  ------------------
 1358|  17.2k|    SSH_BUFFER_FREE(channel->stderr_buffer);
  ------------------
  |  |  934|  17.2k|    do { if ((x) != NULL) { ssh_buffer_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (934:14): [True: 17.2k, False: 0]
  |  |  |  Branch (934:69): [Folded, False: 17.2k]
  |  |  ------------------
  ------------------
 1359|       |
 1360|  17.2k|    if (channel->callbacks != NULL) {
  ------------------
  |  Branch (1360:9): [True: 8.64k, False: 8.64k]
  ------------------
 1361|  8.64k|        ssh_list_free(channel->callbacks);
 1362|  8.64k|        channel->callbacks = NULL;
 1363|  8.64k|    }
 1364|  17.2k|    SAFE_FREE(channel->exit.signal);
  ------------------
  |  |  373|  17.2k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 17.2k]
  |  |  |  Branch (373:71): [Folded, False: 17.2k]
  |  |  ------------------
  ------------------
 1365|       |
 1366|  17.2k|    channel->session = NULL;
 1367|       |    SAFE_FREE(channel);
  ------------------
  |  |  373|  17.2k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 17.2k, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 17.2k]
  |  |  ------------------
  ------------------
 1368|  17.2k|}
ssh_channel_send_eof:
 1399|  34.5k|{
 1400|  34.5k|    ssh_session session = NULL;
 1401|  34.5k|    int rc = SSH_ERROR;
  ------------------
  |  |  317|  34.5k|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 1402|  34.5k|    int err;
 1403|       |
 1404|  34.5k|    if (channel == NULL || channel->session == NULL) {
  ------------------
  |  Branch (1404:9): [True: 0, False: 34.5k]
  |  Branch (1404:28): [True: 0, False: 34.5k]
  ------------------
 1405|      0|        return rc;
 1406|      0|    }
 1407|       |
 1408|       |    /* If the EOF has already been sent we're done here. */
 1409|  34.5k|    if (channel->local_eof != 0) {
  ------------------
  |  Branch (1409:9): [True: 17.2k, False: 17.2k]
  ------------------
 1410|  17.2k|        return SSH_OK;
  ------------------
  |  |  316|  17.2k|#define SSH_OK 0     /* No error */
  ------------------
 1411|  17.2k|    }
 1412|       |
 1413|  17.2k|    session = channel->session;
 1414|       |
 1415|  17.2k|    err = ssh_buffer_pack(session->out_buffer,
  ------------------
  |  |   50|  17.2k|    _ssh_buffer_pack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |  451|  17.2k|        (__VA_NARG_(__VA_ARGS__, __RSEQ_N()))
  |  |  |  |  ------------------
  |  |  |  |  |  |  453|  17.2k|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  448|  17.2k|#define VA_APPLY_VARIADIC_MACRO(macro, tuple) macro tuple
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  453|  17.2k|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  461|  17.2k|        _61,_62,_63,N,...) N
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                   _ssh_buffer_pack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |   28|  17.2k|#define SSH_BUFFER_PACK_END ((uint32_t) 0x4f65feb3)
  |  |  ------------------
  ------------------
 1416|  17.2k|                          "bd",
 1417|  17.2k|                          SSH2_MSG_CHANNEL_EOF,
 1418|  17.2k|                          channel->remote_channel);
 1419|  17.2k|    if (err != SSH_OK) {
  ------------------
  |  |  316|  17.2k|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (1419:9): [True: 0, False: 17.2k]
  ------------------
 1420|      0|        ssh_set_error_oom(session);
  ------------------
  |  |  318|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
 1421|      0|        goto error;
 1422|      0|    }
 1423|       |
 1424|  17.2k|    rc = ssh_packet_send(session);
 1425|  17.2k|    SSH_LOG(SSH_LOG_PACKET,
  ------------------
  |  |  281|  17.2k|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 1426|  17.2k|        "Sent a EOF on client channel (%" PRIu32 ":%" PRIu32 ")",
 1427|  17.2k|        channel->local_channel,
 1428|  17.2k|        channel->remote_channel);
 1429|  17.2k|    if (rc != SSH_OK) {
  ------------------
  |  |  316|  17.2k|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (1429:9): [True: 8, False: 17.2k]
  ------------------
 1430|      8|        goto error;
 1431|      8|    }
 1432|       |
 1433|  17.2k|    rc = ssh_channel_flush(channel);
 1434|  17.2k|    if (rc == SSH_ERROR) {
  ------------------
  |  |  317|  17.2k|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  |  Branch (1434:9): [True: 0, False: 17.2k]
  ------------------
 1435|      0|        goto error;
 1436|      0|    }
 1437|  17.2k|    channel->local_eof = 1;
 1438|       |
 1439|  17.2k|    return rc;
 1440|      8|error:
 1441|      8|    ssh_buffer_reinit(session->out_buffer);
 1442|       |
 1443|      8|    return rc;
 1444|  17.2k|}
ssh_channel_close:
 1460|  17.2k|{
 1461|  17.2k|    ssh_session session = NULL;
 1462|  17.2k|    int rc = 0;
 1463|       |
 1464|  17.2k|    if(channel == NULL) {
  ------------------
  |  Branch (1464:8): [True: 0, False: 17.2k]
  ------------------
 1465|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 1466|      0|    }
 1467|       |
 1468|       |    /* If the channel close has already been sent we're done here. */
 1469|  17.2k|    if (channel->flags & SSH_CHANNEL_FLAG_CLOSED_LOCAL) {
  ------------------
  |  |   58|  17.2k|#define SSH_CHANNEL_FLAG_CLOSED_LOCAL 0x0002
  ------------------
  |  Branch (1469:9): [True: 0, False: 17.2k]
  ------------------
 1470|      0|        return SSH_OK;
  ------------------
  |  |  316|      0|#define SSH_OK 0     /* No error */
  ------------------
 1471|      0|    }
 1472|       |
 1473|  17.2k|    session = channel->session;
 1474|       |
 1475|  17.2k|    rc = ssh_channel_send_eof(channel);
 1476|  17.2k|    if (rc != SSH_OK) {
  ------------------
  |  |  316|  17.2k|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (1476:9): [True: 0, False: 17.2k]
  ------------------
 1477|      0|        return rc;
 1478|      0|    }
 1479|       |
 1480|  17.2k|    rc = ssh_buffer_pack(session->out_buffer,
  ------------------
  |  |   50|  17.2k|    _ssh_buffer_pack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |  451|  17.2k|        (__VA_NARG_(__VA_ARGS__, __RSEQ_N()))
  |  |  |  |  ------------------
  |  |  |  |  |  |  453|  17.2k|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  448|  17.2k|#define VA_APPLY_VARIADIC_MACRO(macro, tuple) macro tuple
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  453|  17.2k|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  461|  17.2k|        _61,_62,_63,N,...) N
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                   _ssh_buffer_pack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |   28|  17.2k|#define SSH_BUFFER_PACK_END ((uint32_t) 0x4f65feb3)
  |  |  ------------------
  ------------------
 1481|  17.2k|                         "bd",
 1482|  17.2k|                         SSH2_MSG_CHANNEL_CLOSE,
 1483|  17.2k|                         channel->remote_channel);
 1484|  17.2k|    if (rc != SSH_OK) {
  ------------------
  |  |  316|  17.2k|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (1484:9): [True: 0, False: 17.2k]
  ------------------
 1485|      0|        ssh_set_error_oom(session);
  ------------------
  |  |  318|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
 1486|      0|        goto error;
 1487|      0|    }
 1488|       |
 1489|  17.2k|    rc = ssh_packet_send(session);
 1490|  17.2k|    SSH_LOG(SSH_LOG_PACKET,
  ------------------
  |  |  281|  17.2k|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 1491|  17.2k|            "Sent a close on client channel (%" PRIu32 ":%" PRIu32 ")",
 1492|  17.2k|            channel->local_channel,
 1493|  17.2k|            channel->remote_channel);
 1494|       |
 1495|  17.2k|    if (rc == SSH_OK) {
  ------------------
  |  |  316|  17.2k|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (1495:9): [True: 8.64k, False: 8.63k]
  ------------------
 1496|  8.64k|        channel->state = SSH_CHANNEL_STATE_CLOSED;
 1497|  8.64k|        channel->flags |= SSH_CHANNEL_FLAG_CLOSED_LOCAL;
  ------------------
  |  |   58|  8.64k|#define SSH_CHANNEL_FLAG_CLOSED_LOCAL 0x0002
  ------------------
 1498|  8.64k|    }
 1499|       |
 1500|  17.2k|    rc = ssh_channel_flush(channel);
 1501|  17.2k|    if(rc == SSH_ERROR) {
  ------------------
  |  |  317|  17.2k|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  |  Branch (1501:8): [True: 0, False: 17.2k]
  ------------------
 1502|      0|        goto error;
 1503|      0|    }
 1504|       |
 1505|  17.2k|    return rc;
 1506|      0|error:
 1507|      0|    ssh_buffer_reinit(session->out_buffer);
 1508|       |
 1509|      0|    return rc;
 1510|  17.2k|}
ssh_channel_flush:
 1549|  43.1k|{
 1550|  43.1k|    return ssh_blocking_flush(channel->session, SSH_TIMEOUT_DEFAULT);
  ------------------
  |  |  103|  43.1k|#define SSH_TIMEOUT_DEFAULT -3
  ------------------
 1551|  43.1k|}
ssh_channel_write:
 1742|  8.64k|{
 1743|  8.64k|    return channel_write_common(channel, data, len, 0);
 1744|  8.64k|}
ssh_channel_is_closed:
 1773|  25.9k|{
 1774|  25.9k|    if (channel == NULL || channel->session == NULL) {
  ------------------
  |  Branch (1774:9): [True: 0, False: 25.9k]
  |  Branch (1774:28): [True: 0, False: 25.9k]
  ------------------
 1775|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 1776|      0|    }
 1777|  25.9k|    return (channel->state != SSH_CHANNEL_STATE_OPEN || channel->session->alive == 0);
  ------------------
  |  Branch (1777:13): [True: 8.64k, False: 17.2k]
  |  Branch (1777:57): [True: 0, False: 17.2k]
  ------------------
 1778|  25.9k|}
ssh_channel_is_eof:
 1788|  25.9k|{
 1789|  25.9k|    if (channel == NULL) {
  ------------------
  |  Branch (1789:9): [True: 0, False: 25.9k]
  ------------------
 1790|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 1791|      0|    }
 1792|  25.9k|    if (ssh_channel_has_unread_data(channel)) {
  ------------------
  |  Branch (1792:9): [True: 8.63k, False: 17.2k]
  ------------------
 1793|  8.63k|        return 0;
 1794|  8.63k|    }
 1795|       |
 1796|  17.2k|    return (channel->remote_eof != 0);
 1797|  25.9k|}
ssh_packet_channel_success:
 1824|      2|{
 1825|      2|    ssh_channel channel = NULL;
 1826|      2|    (void)type;
 1827|      2|    (void)user;
 1828|       |
 1829|      2|    channel = channel_from_msg(session, packet);
 1830|      2|    if (channel == NULL) {
  ------------------
  |  Branch (1830:9): [True: 0, False: 2]
  ------------------
 1831|      0|        SSH_LOG(SSH_LOG_FUNCTIONS, "%s", ssh_get_error(session));
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 1832|      0|        return SSH_PACKET_USED;
  ------------------
  |  |  637|      0|#define SSH_PACKET_USED 1
  ------------------
 1833|      0|    }
 1834|       |
 1835|      2|    SSH_LOG(SSH_LOG_PACKET,
  ------------------
  |  |  281|      2|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 1836|      2|            "Received SSH_CHANNEL_SUCCESS on channel (%" PRIu32 ":%" PRIu32 ")",
 1837|      2|            channel->local_channel,
 1838|      2|            channel->remote_channel);
 1839|      2|    if (channel->request_state != SSH_CHANNEL_REQ_STATE_PENDING) {
  ------------------
  |  Branch (1839:9): [True: 0, False: 2]
  ------------------
 1840|      0|        SSH_LOG(SSH_LOG_RARE,
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 1841|      0|                "SSH_CHANNEL_SUCCESS received in incorrect state %d",
 1842|      0|                channel->request_state);
 1843|      2|    } else {
 1844|      2|        channel->request_state = SSH_CHANNEL_REQ_STATE_ACCEPTED;
 1845|       |
 1846|      2|        ssh_callbacks_execute_list(channel->callbacks,
  ------------------
  |  |  566|      2|    do {                                                      \
  |  |  567|      2|        struct ssh_iterator *i = ssh_list_get_iterator(list); \
  |  |  568|      2|        cbtype cb;                                            \
  |  |  569|      2|        while (i != NULL){                                    \
  |  |  ------------------
  |  |  |  Branch (569:16): [True: 0, False: 2]
  |  |  ------------------
  |  |  570|      0|            cb = ssh_iterator_value(cbtype, i);               \
  |  |  ------------------
  |  |  |  |  114|      0|  ((type)((iterator)->data))
  |  |  ------------------
  |  |  571|      0|            if (ssh_callbacks_exists(cb, c))                  \
  |  |  ------------------
  |  |  |  |  547|      0|#define ssh_callbacks_exists(p,c) (\
  |  |  |  |  548|      0|  (p != NULL) && ( (char *)&((p)-> c) < (char *)(p) + (p)->size ) && \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (548:3): [True: 0, False: 0]
  |  |  |  |  |  Branch (548:18): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  549|      0|  ((p)-> c != NULL) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (549:3): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  550|      0|  )
  |  |  ------------------
  |  |  572|      0|                cb-> c (__VA_ARGS__, cb->userdata);           \
  |  |  573|      0|            i = i->next;                                      \
  |  |  574|      0|        }                                                     \
  |  |  575|      2|    } while(0)
  |  |  ------------------
  |  |  |  Branch (575:13): [Folded, False: 2]
  |  |  ------------------
  ------------------
 1847|      2|                                   ssh_channel_callbacks,
 1848|      2|                                   channel_request_response_function,
 1849|      2|                                   channel->session,
 1850|      2|                                   channel);
 1851|      2|    }
 1852|       |
 1853|      2|    return SSH_PACKET_USED;
  ------------------
  |  |  637|      2|#define SSH_PACKET_USED 1
  ------------------
 1854|      2|}
ssh_channel_request_exec:
 2875|  8.64k|{
 2876|  8.64k|  ssh_buffer buffer = NULL;
 2877|  8.64k|  int rc = SSH_ERROR;
  ------------------
  |  |  317|  8.64k|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 2878|       |
 2879|  8.64k|  if(channel == NULL) {
  ------------------
  |  Branch (2879:6): [True: 0, False: 8.64k]
  ------------------
 2880|      0|      return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 2881|      0|  }
 2882|  8.64k|  if(cmd == NULL) {
  ------------------
  |  Branch (2882:6): [True: 0, False: 8.64k]
  ------------------
 2883|      0|      ssh_set_error_invalid(channel->session);
  ------------------
  |  |  322|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 2884|      0|      return rc;
 2885|      0|  }
 2886|       |
 2887|  8.64k|  switch(channel->request_state){
 2888|  8.64k|  case SSH_CHANNEL_REQ_STATE_NONE:
  ------------------
  |  Branch (2888:3): [True: 8.64k, False: 0]
  ------------------
 2889|  8.64k|    break;
 2890|      0|  default:
  ------------------
  |  Branch (2890:3): [True: 0, False: 8.64k]
  ------------------
 2891|      0|    goto pending;
 2892|  8.64k|  }
 2893|  8.64k|  buffer = ssh_buffer_new();
 2894|  8.64k|  if (buffer == NULL) {
  ------------------
  |  Branch (2894:7): [True: 0, False: 8.64k]
  ------------------
 2895|      0|    ssh_set_error_oom(channel->session);
  ------------------
  |  |  318|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
 2896|      0|    goto error;
 2897|      0|  }
 2898|       |
 2899|  8.64k|  rc = ssh_buffer_pack(buffer, "s", cmd);
  ------------------
  |  |   50|  8.64k|    _ssh_buffer_pack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |  451|  8.64k|        (__VA_NARG_(__VA_ARGS__, __RSEQ_N()))
  |  |  |  |  ------------------
  |  |  |  |  |  |  453|  8.64k|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  448|  8.64k|#define VA_APPLY_VARIADIC_MACRO(macro, tuple) macro tuple
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  453|  8.64k|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  461|  8.64k|        _61,_62,_63,N,...) N
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                   _ssh_buffer_pack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |   28|  8.64k|#define SSH_BUFFER_PACK_END ((uint32_t) 0x4f65feb3)
  |  |  ------------------
  ------------------
 2900|       |
 2901|  8.64k|  if (rc != SSH_OK) {
  ------------------
  |  |  316|  8.64k|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (2901:7): [True: 0, False: 8.64k]
  ------------------
 2902|      0|    ssh_set_error_oom(channel->session);
  ------------------
  |  |  318|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
 2903|      0|    goto error;
 2904|      0|  }
 2905|  8.64k|pending:
 2906|  8.64k|  rc = channel_request(channel, "exec", buffer, 1);
 2907|  8.64k|error:
 2908|       |  SSH_BUFFER_FREE(buffer);
  ------------------
  |  |  934|  8.64k|    do { if ((x) != NULL) { ssh_buffer_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (934:14): [True: 8.64k, False: 0]
  |  |  |  Branch (934:69): [Folded, False: 8.64k]
  |  |  ------------------
  ------------------
 2909|  8.64k|  return rc;
 2910|  8.64k|}
ssh_channel_read:
 3137|  25.0k|{
 3138|  25.0k|    return ssh_channel_read_timeout(channel,
 3139|  25.0k|                                    dest,
 3140|  25.0k|                                    count,
 3141|  25.0k|                                    is_stderr,
 3142|  25.0k|                                    SSH_TIMEOUT_DEFAULT);
  ------------------
  |  |  103|  25.0k|#define SSH_TIMEOUT_DEFAULT -3
  ------------------
 3143|  25.0k|}
ssh_channel_read_timeout:
 3170|  25.0k|{
 3171|  25.0k|    ssh_session session = NULL;
 3172|  25.0k|    ssh_buffer stdbuf = NULL;
 3173|  25.0k|    uint32_t len;
 3174|  25.0k|    struct ssh_channel_read_termination_struct ctx;
 3175|  25.0k|    int rc;
 3176|       |
 3177|  25.0k|    if (channel == NULL) {
  ------------------
  |  Branch (3177:9): [True: 0, False: 25.0k]
  ------------------
 3178|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 3179|      0|    }
 3180|  25.0k|    if (dest == NULL) {
  ------------------
  |  Branch (3180:9): [True: 0, False: 25.0k]
  ------------------
 3181|      0|        ssh_set_error_invalid(channel->session);
  ------------------
  |  |  322|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 3182|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 3183|      0|    }
 3184|       |
 3185|  25.0k|    session = channel->session;
 3186|  25.0k|    stdbuf = channel->stdout_buffer;
 3187|       |
 3188|  25.0k|    if (count == 0) {
  ------------------
  |  Branch (3188:9): [True: 0, False: 25.0k]
  ------------------
 3189|      0|        return 0;
 3190|      0|    }
 3191|       |
 3192|  25.0k|    if (is_stderr) {
  ------------------
  |  Branch (3192:9): [True: 0, False: 25.0k]
  ------------------
 3193|      0|        stdbuf = channel->stderr_buffer;
 3194|      0|    }
 3195|       |
 3196|  25.0k|    SSH_LOG(SSH_LOG_PACKET,
  ------------------
  |  |  281|  25.0k|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 3197|  25.0k|            "Read (%" PRIu32 ") buffered : %" PRIu32 " bytes. Window: %" PRIu32,
 3198|  25.0k|            count,
 3199|  25.0k|            ssh_buffer_get_len(stdbuf),
 3200|  25.0k|            channel->local_window);
 3201|       |
 3202|       |    /* block reading until at least one byte has been read
 3203|       |     * and ignore the trivial case count=0
 3204|       |     */
 3205|  25.0k|    ctx.channel = channel;
 3206|  25.0k|    ctx.buffer = stdbuf;
 3207|       |
 3208|  25.0k|    if (timeout_ms < SSH_TIMEOUT_DEFAULT) {
  ------------------
  |  |  103|  25.0k|#define SSH_TIMEOUT_DEFAULT -3
  ------------------
  |  Branch (3208:9): [True: 0, False: 25.0k]
  ------------------
 3209|      0|        timeout_ms = SSH_TIMEOUT_INFINITE;
  ------------------
  |  |   99|      0|#define SSH_TIMEOUT_INFINITE -1
  ------------------
 3210|      0|    }
 3211|       |
 3212|  25.0k|    rc = ssh_handle_packets_termination(session,
 3213|  25.0k|                                        timeout_ms,
 3214|  25.0k|                                        ssh_channel_read_termination,
 3215|  25.0k|                                        &ctx);
 3216|  25.0k|    if (rc == SSH_ERROR || rc == SSH_AGAIN) {
  ------------------
  |  |  317|  50.0k|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
                  if (rc == SSH_ERROR || rc == SSH_AGAIN) {
  ------------------
  |  |  318|  25.0k|#define SSH_AGAIN -2 /* The nonblocking call must be repeated */
  ------------------
  |  Branch (3216:9): [True: 0, False: 25.0k]
  |  Branch (3216:28): [True: 0, False: 25.0k]
  ------------------
 3217|      0|        return rc;
 3218|      0|    }
 3219|       |
 3220|       |    /*
 3221|       |     * If the channel is closed or in an error state, reading from it is an
 3222|       |     * error
 3223|       |     */
 3224|  25.0k|    if (session->session_state == SSH_SESSION_STATE_ERROR) {
  ------------------
  |  Branch (3224:9): [True: 8.63k, False: 16.3k]
  ------------------
 3225|  8.63k|        return SSH_ERROR;
  ------------------
  |  |  317|  8.63k|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 3226|  8.63k|    }
 3227|       |    /* If the server closed the channel properly, there is nothing to do */
 3228|  16.3k|    if (channel->remote_eof && ssh_buffer_get_len(stdbuf) == 0) {
  ------------------
  |  Branch (3228:9): [True: 16.3k, False: 0]
  |  Branch (3228:32): [True: 0, False: 16.3k]
  ------------------
 3229|      0|        return 0;
 3230|      0|    }
 3231|  16.3k|    if (channel->state == SSH_CHANNEL_STATE_CLOSED) {
  ------------------
  |  Branch (3231:9): [True: 0, False: 16.3k]
  ------------------
 3232|      0|        ssh_set_error(session, SSH_FATAL, "Remote channel is closed.");
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
 3233|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 3234|      0|    }
 3235|  16.3k|    len = ssh_buffer_get_len(stdbuf);
 3236|       |    /* Read count bytes if len is greater, everything otherwise */
 3237|  16.3k|    len = (len > count ? count : len);
  ------------------
  |  Branch (3237:12): [True: 16.3k, False: 0]
  ------------------
 3238|  16.3k|    memcpy(dest, ssh_buffer_get(stdbuf), len);
 3239|  16.3k|    ssh_buffer_pass_bytes(stdbuf, len);
 3240|  16.3k|    if (channel->counter != NULL) {
  ------------------
  |  Branch (3240:9): [True: 0, False: 16.3k]
  ------------------
 3241|      0|        channel->counter->in_bytes += len;
 3242|      0|    }
 3243|       |    /* Try completing the delayed_close */
 3244|  16.3k|    if (channel->delayed_close && !ssh_channel_has_unread_data(channel)) {
  ------------------
  |  Branch (3244:9): [True: 16.3k, False: 0]
  |  Branch (3244:35): [True: 0, False: 16.3k]
  ------------------
 3245|      0|        channel->state = SSH_CHANNEL_STATE_CLOSED;
 3246|      0|    }
 3247|       |
 3248|  16.3k|    rc = grow_window(session, channel);
 3249|  16.3k|    if (rc == SSH_ERROR) {
  ------------------
  |  |  317|  16.3k|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  |  Branch (3249:9): [True: 0, False: 16.3k]
  ------------------
 3250|      0|        return -1;
 3251|      0|    }
 3252|       |
 3253|  16.3k|    return len;
 3254|  16.3k|}
channels.c:channel_from_msg:
  518|  71.9k|{
  519|  71.9k|    ssh_channel channel = NULL;
  520|  71.9k|    uint32_t chan;
  521|  71.9k|    int rc;
  522|       |
  523|  71.9k|    rc = ssh_buffer_unpack(packet, "d", &chan);
  ------------------
  |  |   60|  71.9k|    _ssh_buffer_unpack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |  451|  71.9k|        (__VA_NARG_(__VA_ARGS__, __RSEQ_N()))
  |  |  |  |  ------------------
  |  |  |  |  |  |  453|  71.9k|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  448|  71.9k|#define VA_APPLY_VARIADIC_MACRO(macro, tuple) macro tuple
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  453|  71.9k|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  461|  71.9k|        _61,_62,_63,N,...) N
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                   _ssh_buffer_unpack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |   28|  71.9k|#define SSH_BUFFER_PACK_END ((uint32_t) 0x4f65feb3)
  |  |  ------------------
  ------------------
  524|  71.9k|    if (rc != SSH_OK) {
  ------------------
  |  |  316|  71.9k|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (524:9): [True: 0, False: 71.9k]
  ------------------
  525|      0|        ssh_set_error(session,
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  526|      0|                      SSH_FATAL,
  527|      0|                      "Getting channel from message: short read");
  528|      0|        return NULL;
  529|      0|    }
  530|       |
  531|  71.9k|    channel = ssh_channel_from_local(session, chan);
  532|  71.9k|    if (channel == NULL) {
  ------------------
  |  Branch (532:9): [True: 0, False: 71.9k]
  ------------------
  533|      0|        ssh_set_error(session,
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  534|      0|                      SSH_FATAL,
  535|      0|                      "Server specified invalid channel %" PRIu32,
  536|      0|                      (uint32_t)chan);
  537|      0|    }
  538|       |
  539|  71.9k|    return channel;
  540|  71.9k|}
channels.c:grow_window:
  447|  16.3k|{
  448|  16.3k|  uint32_t used;
  449|  16.3k|  uint32_t increment;
  450|  16.3k|  int rc;
  451|       |
  452|       |  /* Calculate the increment taking into account what the peer may still send
  453|       |   * (local_window) and what we've already buffered (stdout_buffer and
  454|       |   * stderr_buffer).
  455|       |  */
  456|  16.3k|  used = channel->local_window;
  457|  16.3k|  if (channel->stdout_buffer != NULL) {
  ------------------
  |  Branch (457:7): [True: 16.3k, False: 0]
  ------------------
  458|  16.3k|    used += ssh_buffer_get_len(channel->stdout_buffer);
  459|  16.3k|  }
  460|  16.3k|  if (channel->stderr_buffer != NULL) {
  ------------------
  |  Branch (460:7): [True: 16.3k, False: 0]
  ------------------
  461|  16.3k|    used += ssh_buffer_get_len(channel->stderr_buffer);
  462|  16.3k|  }
  463|       |  /* Avoid a negative increment in case the peer sent more than the window allowed */
  464|  16.3k|  increment = WINDOW_DEFAULT > used ? WINDOW_DEFAULT - used : 0;
  ------------------
  |  |   67|  16.3k|#define WINDOW_DEFAULT (64*CHANNEL_MAX_PACKET)
  |  |  ------------------
  |  |  |  |   60|  16.3k|#define CHANNEL_MAX_PACKET 32768
  |  |  ------------------
  ------------------
                increment = WINDOW_DEFAULT > used ? WINDOW_DEFAULT - used : 0;
  ------------------
  |  |   67|  16.3k|#define WINDOW_DEFAULT (64*CHANNEL_MAX_PACKET)
  |  |  ------------------
  |  |  |  |   60|  16.3k|#define CHANNEL_MAX_PACKET 32768
  |  |  ------------------
  ------------------
  |  Branch (464:15): [True: 16.3k, False: 0]
  ------------------
  465|       |  /* Don't grow until we can request at least half a window */
  466|  16.3k|  if (increment < (WINDOW_DEFAULT / 2)) {
  ------------------
  |  |   67|  16.3k|#define WINDOW_DEFAULT (64*CHANNEL_MAX_PACKET)
  |  |  ------------------
  |  |  |  |   60|  16.3k|#define CHANNEL_MAX_PACKET 32768
  |  |  ------------------
  ------------------
  |  Branch (466:7): [True: 16.3k, False: 0]
  ------------------
  467|  16.3k|    SSH_LOG(SSH_LOG_DEBUG,
  ------------------
  |  |  281|  16.3k|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  468|  16.3k|        "growing window (channel %" PRIu32 ":%" PRIu32 ") to %" PRIu32 " bytes : not needed (%" PRIu32 " bytes)",
  469|  16.3k|        channel->local_channel, channel->remote_channel, WINDOW_DEFAULT,
  470|  16.3k|        channel->local_window);
  471|       |
  472|  16.3k|    return SSH_OK;
  ------------------
  |  |  316|  16.3k|#define SSH_OK 0     /* No error */
  ------------------
  473|  16.3k|  }
  474|       |
  475|      0|  rc = ssh_buffer_pack(session->out_buffer,
  ------------------
  |  |   50|      0|    _ssh_buffer_pack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |  451|      0|        (__VA_NARG_(__VA_ARGS__, __RSEQ_N()))
  |  |  |  |  ------------------
  |  |  |  |  |  |  453|      0|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  448|      0|#define VA_APPLY_VARIADIC_MACRO(macro, tuple) macro tuple
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  453|      0|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  461|      0|        _61,_62,_63,N,...) N
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                   _ssh_buffer_pack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |   28|      0|#define SSH_BUFFER_PACK_END ((uint32_t) 0x4f65feb3)
  |  |  ------------------
  ------------------
  476|      0|                       "bdd",
  477|      0|                       SSH2_MSG_CHANNEL_WINDOW_ADJUST,
  478|      0|                       channel->remote_channel,
  479|      0|                       increment);
  480|      0|  if (rc != SSH_OK) {
  ------------------
  |  |  316|      0|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (480:7): [True: 0, False: 0]
  ------------------
  481|      0|    ssh_set_error_oom(session);
  ------------------
  |  |  318|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
  482|      0|    goto error;
  483|      0|  }
  484|       |
  485|      0|  if (ssh_packet_send(session) == SSH_ERROR) {
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  |  Branch (485:7): [True: 0, False: 0]
  ------------------
  486|      0|    goto error;
  487|      0|  }
  488|       |
  489|      0|  SSH_LOG(SSH_LOG_DEBUG,
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  490|      0|      "growing window (channel %" PRIu32 ":%" PRIu32 ") by %" PRIu32 " bytes",
  491|      0|      channel->local_channel,
  492|      0|      channel->remote_channel,
  493|      0|      increment);
  494|       |
  495|      0|  channel->local_window += increment;
  496|       |
  497|      0|  return SSH_OK;
  ------------------
  |  |  316|      0|#define SSH_OK 0     /* No error */
  ------------------
  498|      0|error:
  499|      0|  ssh_buffer_reinit(session->out_buffer);
  500|       |
  501|      0|  return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  502|      0|}
channels.c:ssh_channel_has_unread_data:
  758|  50.9k|{
  759|  50.9k|    if (channel == NULL) {
  ------------------
  |  Branch (759:9): [True: 0, False: 50.9k]
  ------------------
  760|      0|        return false;
  761|      0|    }
  762|       |
  763|  50.9k|    if ((channel->stdout_buffer &&
  ------------------
  |  Branch (763:10): [True: 50.9k, False: 0]
  ------------------
  764|  50.9k|         ssh_buffer_get_len(channel->stdout_buffer) > 0) ||
  ------------------
  |  Branch (764:10): [True: 33.6k, False: 17.2k]
  ------------------
  765|  17.2k|        (channel->stderr_buffer &&
  ------------------
  |  Branch (765:10): [True: 17.2k, False: 0]
  ------------------
  766|  17.2k|         ssh_buffer_get_len(channel->stderr_buffer) > 0))
  ------------------
  |  Branch (766:10): [True: 0, False: 17.2k]
  ------------------
  767|  33.6k|    {
  768|  33.6k|        return true;
  769|  33.6k|    }
  770|       |
  771|  17.2k|    return false;
  772|  50.9k|}
channels.c:channel_open:
  339|  8.64k|{
  340|  8.64k|    ssh_session session = channel->session;
  341|  8.64k|    int err = SSH_ERROR;
  ------------------
  |  |  317|  8.64k|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  342|  8.64k|    int rc;
  343|       |
  344|  8.64k|    switch (channel->state) {
  345|  8.64k|    case SSH_CHANNEL_STATE_NOT_OPEN:
  ------------------
  |  Branch (345:5): [True: 8.64k, False: 0]
  ------------------
  346|  8.64k|        break;
  347|      0|    case SSH_CHANNEL_STATE_OPENING:
  ------------------
  |  Branch (347:5): [True: 0, False: 8.64k]
  ------------------
  348|      0|        goto pending;
  349|      0|    case SSH_CHANNEL_STATE_OPEN:
  ------------------
  |  Branch (349:5): [True: 0, False: 8.64k]
  ------------------
  350|      0|    case SSH_CHANNEL_STATE_CLOSED:
  ------------------
  |  Branch (350:5): [True: 0, False: 8.64k]
  ------------------
  351|      0|    case SSH_CHANNEL_STATE_OPEN_DENIED:
  ------------------
  |  Branch (351:5): [True: 0, False: 8.64k]
  ------------------
  352|      0|        goto end;
  353|      0|    default:
  ------------------
  |  Branch (353:5): [True: 0, False: 8.64k]
  ------------------
  354|      0|        ssh_set_error(session, SSH_FATAL, "Bad state in channel_open: %d",
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  355|  8.64k|                      channel->state);
  356|  8.64k|    }
  357|       |
  358|  8.64k|    channel->local_channel = ssh_channel_new_id(session);
  359|  8.64k|    channel->local_maxpacket = maxpacket;
  360|  8.64k|    channel->local_window = window;
  361|       |
  362|  8.64k|    SSH_LOG(SSH_LOG_DEBUG,
  ------------------
  |  |  281|  8.64k|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  363|  8.64k|            "Creating a channel %" PRIu32 " with %" PRIu32 " window and %" PRIu32 " max packet",
  364|  8.64k|            channel->local_channel, window, maxpacket);
  365|       |
  366|  8.64k|    rc = ssh_buffer_pack(session->out_buffer,
  ------------------
  |  |   50|  8.64k|    _ssh_buffer_pack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |  451|  8.64k|        (__VA_NARG_(__VA_ARGS__, __RSEQ_N()))
  |  |  |  |  ------------------
  |  |  |  |  |  |  453|  8.64k|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  448|  8.64k|#define VA_APPLY_VARIADIC_MACRO(macro, tuple) macro tuple
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  453|  8.64k|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  461|  8.64k|        _61,_62,_63,N,...) N
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                   _ssh_buffer_pack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |   28|  8.64k|#define SSH_BUFFER_PACK_END ((uint32_t) 0x4f65feb3)
  |  |  ------------------
  ------------------
  367|  8.64k|                         "bsddd",
  368|  8.64k|                         SSH2_MSG_CHANNEL_OPEN,
  369|  8.64k|                         type,
  370|  8.64k|                         channel->local_channel,
  371|  8.64k|                         channel->local_window,
  372|  8.64k|                         channel->local_maxpacket);
  373|  8.64k|    if (rc != SSH_OK) {
  ------------------
  |  |  316|  8.64k|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (373:9): [True: 0, False: 8.64k]
  ------------------
  374|      0|        ssh_set_error_oom(session);
  ------------------
  |  |  318|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
  375|      0|        return err;
  376|      0|    }
  377|       |
  378|  8.64k|    if (payload != NULL) {
  ------------------
  |  Branch (378:9): [True: 0, False: 8.64k]
  ------------------
  379|      0|        if (ssh_buffer_add_buffer(session->out_buffer, payload) < 0) {
  ------------------
  |  Branch (379:13): [True: 0, False: 0]
  ------------------
  380|      0|            ssh_set_error_oom(session);
  ------------------
  |  |  318|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
  381|       |
  382|      0|            return err;
  383|      0|        }
  384|      0|    }
  385|  8.64k|    channel->state = SSH_CHANNEL_STATE_OPENING;
  386|  8.64k|    if (ssh_packet_send(session) == SSH_ERROR) {
  ------------------
  |  |  317|  8.64k|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  |  Branch (386:9): [True: 0, False: 8.64k]
  ------------------
  387|      0|        return err;
  388|      0|    }
  389|       |
  390|  8.64k|    SSH_LOG(SSH_LOG_PACKET,
  ------------------
  |  |  281|  8.64k|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  391|  8.64k|            "Sent a SSH_MSG_CHANNEL_OPEN type %s for channel %" PRIu32,
  392|  8.64k|            type, channel->local_channel);
  393|       |
  394|  8.64k|pending:
  395|       |    /* wait until channel is opened by server */
  396|  8.64k|    err = ssh_handle_packets_termination(session,
  397|  8.64k|                                         SSH_TIMEOUT_DEFAULT,
  ------------------
  |  |  103|  8.64k|#define SSH_TIMEOUT_DEFAULT -3
  ------------------
  398|  8.64k|                                         ssh_channel_open_termination,
  399|  8.64k|                                         channel);
  400|       |
  401|  8.64k|    if (session->session_state == SSH_SESSION_STATE_ERROR) {
  ------------------
  |  Branch (401:9): [True: 2, False: 8.64k]
  ------------------
  402|      2|        err = SSH_ERROR;
  ------------------
  |  |  317|      2|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  403|      2|    }
  404|       |
  405|  8.64k|end:
  406|       |    /* This needs to pass the SSH_AGAIN from the above,
  407|       |     * but needs to catch failed channel states */
  408|  8.64k|    if (channel->state == SSH_CHANNEL_STATE_OPEN) {
  ------------------
  |  Branch (408:9): [True: 8.64k, False: 2]
  ------------------
  409|  8.64k|        err = SSH_OK;
  ------------------
  |  |  316|  8.64k|#define SSH_OK 0     /* No error */
  ------------------
  410|  8.64k|    } else if (err != SSH_AGAIN) {
  ------------------
  |  |  318|      2|#define SSH_AGAIN -2 /* The nonblocking call must be repeated */
  ------------------
  |  Branch (410:16): [True: 2, False: 0]
  ------------------
  411|       |        /* Messages were handled correctly, but the channel state is invalid */
  412|      2|        err = SSH_ERROR;
  ------------------
  |  |  317|      2|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  413|      2|    }
  414|       |
  415|  8.64k|    return err;
  416|  8.64k|}
channels.c:ssh_channel_open_termination:
  304|  25.9k|{
  305|  25.9k|  ssh_channel channel = (ssh_channel) c;
  306|  25.9k|  if (channel->state != SSH_CHANNEL_STATE_OPENING ||
  ------------------
  |  Branch (306:7): [True: 8.64k, False: 17.2k]
  ------------------
  307|  17.2k|      channel->session->session_state == SSH_SESSION_STATE_ERROR)
  ------------------
  |  Branch (307:7): [True: 2, False: 17.2k]
  ------------------
  308|  8.64k|    return 1;
  309|  17.2k|  else
  310|  17.2k|    return 0;
  311|  25.9k|}
channels.c:channel_write_common:
 1556|  8.64k|{
 1557|  8.64k|    ssh_session session = NULL;
 1558|  8.64k|    uint32_t origlen = len;
 1559|  8.64k|    uint32_t effectivelen;
 1560|  8.64k|    int rc;
 1561|       |
 1562|  8.64k|    if (channel == NULL) {
  ------------------
  |  Branch (1562:9): [True: 0, False: 8.64k]
  ------------------
 1563|      0|        return -1;
 1564|      0|    }
 1565|  8.64k|    session = channel->session;
 1566|  8.64k|    if (data == NULL) {
  ------------------
  |  Branch (1566:9): [True: 0, False: 8.64k]
  ------------------
 1567|      0|        ssh_set_error_invalid(session);
  ------------------
  |  |  322|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 1568|      0|        return -1;
 1569|      0|    }
 1570|       |
 1571|  8.64k|    if (len > INT_MAX) {
  ------------------
  |  Branch (1571:9): [True: 0, False: 8.64k]
  ------------------
 1572|      0|        SSH_LOG(SSH_LOG_TRACE,
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 1573|      0|                "Length (%" PRIu32 ") is bigger than INT_MAX",
 1574|      0|                len);
 1575|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 1576|      0|    }
 1577|       |
 1578|  8.64k|    if (channel->local_eof) {
  ------------------
  |  Branch (1578:9): [True: 0, False: 8.64k]
  ------------------
 1579|      0|        ssh_set_error(session,
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
 1580|      0|                      SSH_REQUEST_DENIED,
 1581|      0|                      "Can't write to channel %" PRIu32 ":%" PRIu32
 1582|      0|                      " after EOF was sent",
 1583|      0|                      channel->local_channel,
 1584|      0|                      channel->remote_channel);
 1585|      0|        return -1;
 1586|      0|    }
 1587|       |
 1588|  8.64k|    if (channel->state != SSH_CHANNEL_STATE_OPEN ||
  ------------------
  |  Branch (1588:9): [True: 0, False: 8.64k]
  ------------------
 1589|  8.64k|        channel->delayed_close != 0) {
  ------------------
  |  Branch (1589:9): [True: 2, False: 8.64k]
  ------------------
 1590|      2|        ssh_set_error(session, SSH_REQUEST_DENIED, "Remote channel is closed");
  ------------------
  |  |  311|      2|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
 1591|       |
 1592|      2|        return -1;
 1593|      2|    }
 1594|       |
 1595|  8.64k|    if (session->session_state == SSH_SESSION_STATE_ERROR) {
  ------------------
  |  Branch (1595:9): [True: 0, False: 8.64k]
  ------------------
 1596|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 1597|      0|    }
 1598|       |
 1599|  8.64k|    if (ssh_waitsession_unblocked(session) == 0) {
  ------------------
  |  Branch (1599:9): [True: 0, False: 8.64k]
  ------------------
 1600|      0|        rc = ssh_handle_packets_termination(session,
 1601|      0|                                            SSH_TIMEOUT_DEFAULT,
  ------------------
  |  |  103|      0|#define SSH_TIMEOUT_DEFAULT -3
  ------------------
 1602|      0|                                            ssh_waitsession_unblocked,
 1603|      0|                                            session);
 1604|      0|        if (rc == SSH_ERROR || !ssh_waitsession_unblocked(session))
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  |  Branch (1604:13): [True: 0, False: 0]
  |  Branch (1604:32): [True: 0, False: 0]
  ------------------
 1605|      0|            goto out;
 1606|      0|    }
 1607|  54.7k|    while (len > 0) {
  ------------------
  |  Branch (1607:12): [True: 46.0k, False: 8.64k]
  ------------------
 1608|  46.0k|        if (channel->remote_window < len) {
  ------------------
  |  Branch (1608:13): [True: 0, False: 46.0k]
  ------------------
 1609|      0|            SSH_LOG(SSH_LOG_DEBUG,
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 1610|      0|                    "Remote window is %" PRIu32
 1611|      0|                    " bytes. going to write %" PRIu32 " bytes",
 1612|      0|                    channel->remote_window,
 1613|      0|                    len);
 1614|       |            /* When the window is zero, wait for it to grow */
 1615|      0|            if (channel->remote_window == 0) {
  ------------------
  |  Branch (1615:17): [True: 0, False: 0]
  ------------------
 1616|       |                /* nothing can be written */
 1617|      0|                SSH_LOG(SSH_LOG_DEBUG, "Wait for a growing window message...");
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 1618|      0|                rc = ssh_handle_packets_termination(
 1619|      0|                    session,
 1620|      0|                    SSH_TIMEOUT_DEFAULT,
  ------------------
  |  |  103|      0|#define SSH_TIMEOUT_DEFAULT -3
  ------------------
 1621|      0|                    ssh_channel_waitwindow_termination,
 1622|      0|                    channel);
 1623|      0|                if (rc == SSH_ERROR ||
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  |  Branch (1623:21): [True: 0, False: 0]
  ------------------
 1624|      0|                    !ssh_channel_waitwindow_termination(channel) ||
  ------------------
  |  Branch (1624:21): [True: 0, False: 0]
  ------------------
 1625|      0|                    session->session_state == SSH_SESSION_STATE_ERROR ||
  ------------------
  |  Branch (1625:21): [True: 0, False: 0]
  ------------------
 1626|      0|                    channel->state == SSH_CHANNEL_STATE_CLOSED)
  ------------------
  |  Branch (1626:21): [True: 0, False: 0]
  ------------------
 1627|      0|                    goto out;
 1628|      0|                continue;
 1629|      0|            }
 1630|       |            /* When the window is non-zero, accept data up to the window size */
 1631|      0|            effectivelen = MIN(len, channel->remote_window);
  ------------------
  |  |  365|      0|#define MIN(a,b) ((a) < (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (365:19): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 1632|  46.0k|        } else {
 1633|  46.0k|            effectivelen = len;
 1634|  46.0k|        }
 1635|       |
 1636|       |        /*
 1637|       |         * Like OpenSSH, don't subtract bytes for the header fields
 1638|       |         * and allow to send a payload of remote_maxpacket length.
 1639|       |         */
 1640|  46.0k|        effectivelen = MIN(effectivelen, channel->remote_maxpacket);
  ------------------
  |  |  365|  46.0k|#define MIN(a,b) ((a) < (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (365:19): [True: 8.35k, False: 37.7k]
  |  |  ------------------
  ------------------
 1641|       |
 1642|  46.0k|        rc = ssh_buffer_pack(session->out_buffer,
  ------------------
  |  |   50|  92.1k|    _ssh_buffer_pack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |  451|  46.0k|        (__VA_NARG_(__VA_ARGS__, __RSEQ_N()))
  |  |  |  |  ------------------
  |  |  |  |  |  |  453|  46.0k|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  448|  46.0k|#define VA_APPLY_VARIADIC_MACRO(macro, tuple) macro tuple
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  453|  46.0k|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  461|  46.0k|        _61,_62,_63,N,...) N
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                   _ssh_buffer_pack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |   28|  46.0k|#define SSH_BUFFER_PACK_END ((uint32_t) 0x4f65feb3)
  |  |  ------------------
  |  |  |  Branch (50:68): [True: 0, False: 46.0k]
  |  |  ------------------
  ------------------
 1643|  46.0k|                             "bd",
 1644|  46.0k|                             is_stderr ? SSH2_MSG_CHANNEL_EXTENDED_DATA
 1645|  46.0k|                                       : SSH2_MSG_CHANNEL_DATA,
 1646|  46.0k|                             channel->remote_channel);
 1647|  46.0k|        if (rc != SSH_OK) {
  ------------------
  |  |  316|  46.0k|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (1647:13): [True: 0, False: 46.0k]
  ------------------
 1648|      0|            ssh_set_error_oom(session);
  ------------------
  |  |  318|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
 1649|      0|            goto error;
 1650|      0|        }
 1651|       |
 1652|       |        /* stderr message has an extra field */
 1653|  46.0k|        if (is_stderr) {
  ------------------
  |  Branch (1653:13): [True: 0, False: 46.0k]
  ------------------
 1654|      0|            rc = ssh_buffer_pack(session->out_buffer,
  ------------------
  |  |   50|      0|    _ssh_buffer_pack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |  451|      0|        (__VA_NARG_(__VA_ARGS__, __RSEQ_N()))
  |  |  |  |  ------------------
  |  |  |  |  |  |  453|      0|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  448|      0|#define VA_APPLY_VARIADIC_MACRO(macro, tuple) macro tuple
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  453|      0|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  461|      0|        _61,_62,_63,N,...) N
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                   _ssh_buffer_pack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |   28|      0|#define SSH_BUFFER_PACK_END ((uint32_t) 0x4f65feb3)
  |  |  ------------------
  ------------------
 1655|      0|                                 "d",
 1656|      0|                                 SSH2_EXTENDED_DATA_STDERR);
 1657|      0|            if (rc != SSH_OK) {
  ------------------
  |  |  316|      0|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (1657:17): [True: 0, False: 0]
  ------------------
 1658|      0|                ssh_set_error_oom(session);
  ------------------
  |  |  318|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
 1659|      0|                goto error;
 1660|      0|            }
 1661|      0|        }
 1662|       |
 1663|       |        /* append payload data */
 1664|  46.0k|        rc = ssh_buffer_pack(session->out_buffer,
  ------------------
  |  |   50|  46.0k|    _ssh_buffer_pack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |  451|  46.0k|        (__VA_NARG_(__VA_ARGS__, __RSEQ_N()))
  |  |  |  |  ------------------
  |  |  |  |  |  |  453|  46.0k|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  448|  46.0k|#define VA_APPLY_VARIADIC_MACRO(macro, tuple) macro tuple
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  453|  46.0k|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  461|  46.0k|        _61,_62,_63,N,...) N
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                   _ssh_buffer_pack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |   28|  46.0k|#define SSH_BUFFER_PACK_END ((uint32_t) 0x4f65feb3)
  |  |  ------------------
  ------------------
 1665|  46.0k|                             "dP",
 1666|  46.0k|                             effectivelen,
 1667|  46.0k|                             (size_t)effectivelen,
 1668|  46.0k|                             data);
 1669|  46.0k|        if (rc != SSH_OK) {
  ------------------
  |  |  316|  46.0k|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (1669:13): [True: 0, False: 46.0k]
  ------------------
 1670|      0|            ssh_set_error_oom(session);
  ------------------
  |  |  318|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
 1671|      0|            goto error;
 1672|      0|        }
 1673|       |
 1674|  46.0k|        rc = ssh_packet_send(session);
 1675|  46.0k|        if (rc == SSH_ERROR) {
  ------------------
  |  |  317|  46.0k|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  |  Branch (1675:13): [True: 0, False: 46.0k]
  ------------------
 1676|      0|            return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 1677|      0|        }
 1678|       |
 1679|  46.0k|        SSH_LOG(SSH_LOG_PACKET,
  ------------------
  |  |  281|  46.0k|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 1680|  46.0k|                "ssh_channel_write wrote %" PRIu32 " bytes",
 1681|  46.0k|                effectivelen);
 1682|       |
 1683|  46.0k|        channel->remote_window -= effectivelen;
 1684|  46.0k|        len -= effectivelen;
 1685|  46.0k|        data = ((uint8_t *)data + effectivelen);
 1686|  46.0k|        if (channel->counter != NULL) {
  ------------------
  |  Branch (1686:13): [True: 0, False: 46.0k]
  ------------------
 1687|      0|            channel->counter->out_bytes += effectivelen;
 1688|      0|        }
 1689|  46.0k|    }
 1690|       |
 1691|       |    /* it's a good idea to flush the socket now */
 1692|  8.64k|    rc = ssh_channel_flush(channel);
 1693|  8.64k|    if (rc == SSH_ERROR) {
  ------------------
  |  |  317|  8.64k|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  |  Branch (1693:9): [True: 0, False: 8.64k]
  ------------------
 1694|      0|        goto error;
 1695|      0|    }
 1696|       |
 1697|  8.64k|out:
 1698|  8.64k|    return (int)(origlen - len);
 1699|       |
 1700|      0|error:
 1701|      0|    ssh_buffer_reinit(session->out_buffer);
 1702|       |
 1703|      0|    return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 1704|  8.64k|}
channels.c:ssh_waitsession_unblocked:
 1528|  8.64k|{
 1529|  8.64k|    ssh_session session = (ssh_session)s;
 1530|  8.64k|    switch (session->session_state){
 1531|      0|        case SSH_SESSION_STATE_DH:
  ------------------
  |  Branch (1531:9): [True: 0, False: 8.64k]
  ------------------
 1532|      0|        case SSH_SESSION_STATE_INITIAL_KEX:
  ------------------
  |  Branch (1532:9): [True: 0, False: 8.64k]
  ------------------
 1533|      0|        case SSH_SESSION_STATE_KEXINIT_RECEIVED:
  ------------------
  |  Branch (1533:9): [True: 0, False: 8.64k]
  ------------------
 1534|      0|            return 0;
 1535|  8.64k|        default:
  ------------------
  |  Branch (1535:9): [True: 8.64k, False: 0]
  ------------------
 1536|  8.64k|            return 1;
 1537|  8.64k|    }
 1538|  8.64k|}
channels.c:channel_request:
 1907|  8.64k|{
 1908|  8.64k|  ssh_session session = channel->session;
 1909|  8.64k|  int rc = SSH_ERROR;
  ------------------
  |  |  317|  8.64k|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 1910|  8.64k|  int ret;
 1911|       |
 1912|  8.64k|  switch(channel->request_state){
 1913|  8.64k|  case SSH_CHANNEL_REQ_STATE_NONE:
  ------------------
  |  Branch (1913:3): [True: 8.64k, False: 0]
  ------------------
 1914|  8.64k|    break;
 1915|      0|  default:
  ------------------
  |  Branch (1915:3): [True: 0, False: 8.64k]
  ------------------
 1916|      0|    goto pending;
 1917|  8.64k|  }
 1918|       |
 1919|  8.64k|  ret = ssh_buffer_pack(session->out_buffer,
  ------------------
  |  |   50|  17.2k|    _ssh_buffer_pack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |  451|  8.64k|        (__VA_NARG_(__VA_ARGS__, __RSEQ_N()))
  |  |  |  |  ------------------
  |  |  |  |  |  |  453|  8.64k|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  448|  8.64k|#define VA_APPLY_VARIADIC_MACRO(macro, tuple) macro tuple
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  453|  8.64k|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  461|  8.64k|        _61,_62,_63,N,...) N
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                   _ssh_buffer_pack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |   28|  8.64k|#define SSH_BUFFER_PACK_END ((uint32_t) 0x4f65feb3)
  |  |  ------------------
  |  |  |  Branch (50:68): [True: 0, False: 8.64k]
  |  |  ------------------
  ------------------
 1920|  8.64k|                        "bdsb",
 1921|  8.64k|                        SSH2_MSG_CHANNEL_REQUEST,
 1922|  8.64k|                        channel->remote_channel,
 1923|  8.64k|                        request,
 1924|  8.64k|                        reply == 0 ? 0 : 1);
 1925|  8.64k|  if (ret != SSH_OK) {
  ------------------
  |  |  316|  8.64k|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (1925:7): [True: 0, False: 8.64k]
  ------------------
 1926|      0|    ssh_set_error_oom(session);
  ------------------
  |  |  318|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
 1927|      0|    goto error;
 1928|      0|  }
 1929|       |
 1930|  8.64k|  if (buffer != NULL) {
  ------------------
  |  Branch (1930:7): [True: 8.64k, False: 0]
  ------------------
 1931|  8.64k|    if (ssh_buffer_add_data(session->out_buffer, ssh_buffer_get(buffer),
  ------------------
  |  Branch (1931:9): [True: 0, False: 8.64k]
  ------------------
 1932|  8.64k|        ssh_buffer_get_len(buffer)) < 0) {
 1933|      0|      ssh_set_error_oom(session);
  ------------------
  |  |  318|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
 1934|      0|      goto error;
 1935|      0|    }
 1936|  8.64k|  }
 1937|  8.64k|  channel->request_state = SSH_CHANNEL_REQ_STATE_PENDING;
 1938|  8.64k|  if (ssh_packet_send(session) == SSH_ERROR) {
  ------------------
  |  |  317|  8.64k|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  |  Branch (1938:7): [True: 0, False: 8.64k]
  ------------------
 1939|      0|    return rc;
 1940|      0|  }
 1941|       |
 1942|  8.64k|  SSH_LOG(SSH_LOG_PACKET,
  ------------------
  |  |  281|  8.64k|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 1943|  8.64k|          "Sent a SSH_MSG_CHANNEL_REQUEST %s on channel %" PRIu32 ":%" PRIu32,
 1944|  8.64k|          request,
 1945|  8.64k|          channel->local_channel,
 1946|  8.64k|          channel->remote_channel);
 1947|  8.64k|  if (reply == 0) {
  ------------------
  |  Branch (1947:7): [True: 0, False: 8.64k]
  ------------------
 1948|      0|    channel->request_state = SSH_CHANNEL_REQ_STATE_NONE;
 1949|      0|    return SSH_OK;
  ------------------
  |  |  316|      0|#define SSH_OK 0     /* No error */
  ------------------
 1950|      0|  }
 1951|  8.64k|pending:
 1952|  8.64k|  rc = ssh_handle_packets_termination(session,
 1953|  8.64k|                                      SSH_TIMEOUT_DEFAULT,
  ------------------
  |  |  103|  8.64k|#define SSH_TIMEOUT_DEFAULT -3
  ------------------
 1954|  8.64k|                                      ssh_channel_request_termination,
 1955|  8.64k|                                      channel);
 1956|       |
 1957|  8.64k|  if(session->session_state == SSH_SESSION_STATE_ERROR || rc == SSH_ERROR) {
  ------------------
  |  |  317|      2|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  |  Branch (1957:6): [True: 8.63k, False: 2]
  |  Branch (1957:59): [True: 0, False: 2]
  ------------------
 1958|  8.63k|      channel->request_state = SSH_CHANNEL_REQ_STATE_ERROR;
 1959|  8.63k|  }
 1960|       |  /* we received something */
 1961|  8.64k|  switch (channel->request_state){
  ------------------
  |  Branch (1961:11): [True: 8.64k, False: 0]
  ------------------
 1962|  8.63k|    case SSH_CHANNEL_REQ_STATE_ERROR:
  ------------------
  |  Branch (1962:5): [True: 8.63k, False: 2]
  ------------------
 1963|  8.63k|      rc=SSH_ERROR;
  ------------------
  |  |  317|  8.63k|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 1964|  8.63k|      break;
 1965|      0|    case SSH_CHANNEL_REQ_STATE_DENIED:
  ------------------
  |  Branch (1965:5): [True: 0, False: 8.64k]
  ------------------
 1966|      0|      ssh_set_error(session,
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
 1967|      0|                    SSH_REQUEST_DENIED,
 1968|      0|                    "Channel request %s failed on channel %" PRIu32 ":%" PRIu32,
 1969|      0|                    request,
 1970|      0|                    channel->local_channel,
 1971|      0|                    channel->remote_channel);
 1972|      0|      rc=SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 1973|      0|      break;
 1974|      2|    case SSH_CHANNEL_REQ_STATE_ACCEPTED:
  ------------------
  |  Branch (1974:5): [True: 2, False: 8.63k]
  ------------------
 1975|      2|      SSH_LOG(SSH_LOG_DEBUG,
  ------------------
  |  |  281|      2|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 1976|      2|              "Channel request %s success on channel %" PRIu32 ":%" PRIu32,
 1977|      2|              request,
 1978|      2|              channel->local_channel,
 1979|      2|              channel->remote_channel);
 1980|      2|      rc=SSH_OK;
  ------------------
  |  |  316|      2|#define SSH_OK 0     /* No error */
  ------------------
 1981|      2|      break;
 1982|      0|    case SSH_CHANNEL_REQ_STATE_PENDING:
  ------------------
  |  Branch (1982:5): [True: 0, False: 8.64k]
  ------------------
 1983|      0|      rc = SSH_AGAIN;
  ------------------
  |  |  318|      0|#define SSH_AGAIN -2 /* The nonblocking call must be repeated */
  ------------------
 1984|      0|      return rc;
 1985|      0|    case SSH_CHANNEL_REQ_STATE_NONE:
  ------------------
  |  Branch (1985:5): [True: 0, False: 8.64k]
  ------------------
 1986|       |      /* Never reached */
 1987|      0|      ssh_set_error(session, SSH_FATAL, "Invalid state in channel_request()");
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
 1988|      0|      rc=SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 1989|      0|      break;
 1990|  8.64k|  }
 1991|  8.64k|  channel->request_state=SSH_CHANNEL_REQ_STATE_NONE;
 1992|       |
 1993|  8.64k|  return rc;
 1994|      0|error:
 1995|      0|  ssh_buffer_reinit(session->out_buffer);
 1996|       |
 1997|      0|  return rc;
 1998|  8.64k|}
channels.c:ssh_channel_request_termination:
 1896|   354k|{
 1897|   354k|  ssh_channel channel = (ssh_channel)c;
 1898|   354k|  if(channel->request_state != SSH_CHANNEL_REQ_STATE_PENDING ||
  ------------------
  |  Branch (1898:6): [True: 2, False: 354k]
  ------------------
 1899|   354k|      channel->session->session_state == SSH_SESSION_STATE_ERROR)
  ------------------
  |  Branch (1899:7): [True: 0, False: 354k]
  ------------------
 1900|      2|    return 1;
 1901|   354k|  else
 1902|   354k|    return 0;
 1903|   354k|}
channels.c:ssh_channel_read_termination:
 3109|  25.0k|{
 3110|  25.0k|  struct ssh_channel_read_termination_struct *ctx = s;
 3111|  25.0k|  if (ssh_buffer_get_len(ctx->buffer) >= 1 ||
  ------------------
  |  Branch (3111:7): [True: 25.0k, False: 0]
  ------------------
 3112|      0|      ctx->channel->remote_eof ||
  ------------------
  |  Branch (3112:7): [True: 0, False: 0]
  ------------------
 3113|      0|      ctx->channel->session->session_state == SSH_SESSION_STATE_ERROR)
  ------------------
  |  Branch (3113:7): [True: 0, False: 0]
  ------------------
 3114|  25.0k|    return 1;
 3115|      0|  else
 3116|      0|    return 0;
 3117|  25.0k|}

ssh_send_banner:
  187|  17.2k|{
  188|  17.2k|    const char *banner = CLIENT_BANNER_SSH2;
  ------------------
  |  |  223|  17.2k|#define CLIENT_BANNER_SSH2 "SSH-2.0-libssh_" SSH_STRINGIFY(LIBSSH_VERSION)
  |  |  ------------------
  |  |  |  |   71|  17.2k|#define SSH_STRINGIFY(s) SSH_TOSTRING(s)
  |  |  |  |  ------------------
  |  |  |  |  |  |   72|  17.2k|#define SSH_TOSTRING(s) #s
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  189|  17.2k|    const char *terminator = "\r\n";
  190|       |    /* The maximum banner length is 255 for SSH2 */
  191|  17.2k|    char buffer[256] = {0};
  192|  17.2k|    size_t len;
  193|  17.2k|    int rc = SSH_ERROR;
  ------------------
  |  |  317|  17.2k|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  194|       |
  195|  17.2k|    if (server == 1) {
  ------------------
  |  Branch (195:9): [True: 8.64k, False: 8.64k]
  ------------------
  196|  8.64k|        if (session->server_opts.custombanner == NULL) {
  ------------------
  |  Branch (196:13): [True: 8.64k, False: 0]
  ------------------
  197|  8.64k|            session->serverbanner = strdup(banner);
  198|  8.64k|            if (session->serverbanner == NULL) {
  ------------------
  |  Branch (198:17): [True: 0, False: 8.64k]
  ------------------
  199|      0|                goto end;
  200|      0|            }
  201|  8.64k|        } else {
  202|      0|            len = strlen(session->server_opts.custombanner);
  203|      0|            session->serverbanner = malloc(len + 8 + 1);
  204|      0|            if(session->serverbanner == NULL) {
  ------------------
  |  Branch (204:16): [True: 0, False: 0]
  ------------------
  205|      0|                goto end;
  206|      0|            }
  207|      0|            snprintf(session->serverbanner,
  208|      0|                     len + 8 + 1,
  209|      0|                     "SSH-2.0-%s",
  210|      0|                     session->server_opts.custombanner);
  211|      0|        }
  212|       |
  213|  8.64k|        snprintf(buffer,
  214|  8.64k|                 sizeof(buffer),
  215|  8.64k|                 "%s%s",
  216|  8.64k|                 session->serverbanner,
  217|  8.64k|                 terminator);
  218|  8.64k|    } else {
  219|  8.64k|        session->clientbanner = strdup(banner);
  220|  8.64k|        if (session->clientbanner == NULL) {
  ------------------
  |  Branch (220:13): [True: 0, False: 8.64k]
  ------------------
  221|      0|            goto end;
  222|      0|        }
  223|       |
  224|  8.64k|        snprintf(buffer,
  225|  8.64k|                 sizeof(buffer),
  226|  8.64k|                 "%s%s",
  227|  8.64k|                 session->clientbanner,
  228|  8.64k|                 terminator);
  229|  8.64k|    }
  230|       |
  231|  17.2k|    rc = ssh_socket_write(session->socket, buffer, (uint32_t)strlen(buffer));
  232|  17.2k|    if (rc == SSH_ERROR) {
  ------------------
  |  |  317|  17.2k|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  |  Branch (232:9): [True: 0, False: 17.2k]
  ------------------
  233|      0|        goto end;
  234|      0|    }
  235|  17.2k|#ifdef WITH_PCAP
  236|  17.2k|    if (session->pcap_ctx != NULL) {
  ------------------
  |  Branch (236:9): [True: 0, False: 17.2k]
  ------------------
  237|      0|        ssh_pcap_context_write(session->pcap_ctx,
  238|      0|                               SSH_PCAP_DIR_OUT,
  239|      0|                               buffer,
  240|      0|                               (uint32_t)strlen(buffer),
  241|      0|                               (uint32_t)strlen(buffer));
  242|      0|    }
  243|  17.2k|#endif
  244|       |
  245|  17.2k|    rc = SSH_OK;
  ------------------
  |  |  316|  17.2k|#define SSH_OK 0     /* No error */
  ------------------
  246|  17.2k|end:
  247|  17.2k|    return rc;
  248|  17.2k|}
dh_handshake:
  258|  8.64k|{
  259|  8.64k|    int rc = SSH_AGAIN;
  ------------------
  |  |  318|  8.64k|#define SSH_AGAIN -2 /* The nonblocking call must be repeated */
  ------------------
  260|       |
  261|  8.64k|    SSH_LOG(SSH_LOG_TRACE,
  ------------------
  |  |  281|  8.64k|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  262|  8.64k|            "dh_handshake_state = %d, kex_type = %d",
  263|  8.64k|            session->dh_handshake_state,
  264|  8.64k|            session->next_crypto->kex_type);
  265|       |
  266|  8.64k|    switch (session->dh_handshake_state) {
  267|  8.64k|    case DH_STATE_INIT:
  ------------------
  |  Branch (267:5): [True: 8.64k, False: 0]
  ------------------
  268|  8.64k|        switch (session->next_crypto->kex_type) {
  269|       |#ifdef WITH_GSSAPI
  270|       |        case SSH_GSS_KEX_DH_GROUP14_SHA256:
  271|       |        case SSH_GSS_KEX_DH_GROUP16_SHA512:
  272|       |        case SSH_GSS_KEX_ECDH_NISTP256_SHA256:
  273|       |        case SSH_GSS_KEX_CURVE25519_SHA256:
  274|       |            rc = ssh_client_gss_kex_init(session);
  275|       |            break;
  276|       |#endif
  277|      0|        case SSH_KEX_DH_GROUP1_SHA1:
  ------------------
  |  Branch (277:9): [True: 0, False: 8.64k]
  ------------------
  278|      0|        case SSH_KEX_DH_GROUP14_SHA1:
  ------------------
  |  Branch (278:9): [True: 0, False: 8.64k]
  ------------------
  279|      0|        case SSH_KEX_DH_GROUP14_SHA256:
  ------------------
  |  Branch (279:9): [True: 0, False: 8.64k]
  ------------------
  280|      0|        case SSH_KEX_DH_GROUP16_SHA512:
  ------------------
  |  Branch (280:9): [True: 0, False: 8.64k]
  ------------------
  281|      0|        case SSH_KEX_DH_GROUP18_SHA512:
  ------------------
  |  Branch (281:9): [True: 0, False: 8.64k]
  ------------------
  282|      0|            rc = ssh_client_dh_init(session);
  283|      0|            break;
  284|      0|#ifdef WITH_GEX
  285|      0|        case SSH_KEX_DH_GEX_SHA1:
  ------------------
  |  Branch (285:9): [True: 0, False: 8.64k]
  ------------------
  286|      0|        case SSH_KEX_DH_GEX_SHA256:
  ------------------
  |  Branch (286:9): [True: 0, False: 8.64k]
  ------------------
  287|      0|            rc = ssh_client_dhgex_init(session);
  288|      0|            break;
  289|      0|#endif /* WITH_GEX */
  290|      0|#ifdef HAVE_ECDH
  291|      0|        case SSH_KEX_ECDH_SHA2_NISTP256:
  ------------------
  |  Branch (291:9): [True: 0, False: 8.64k]
  ------------------
  292|      0|        case SSH_KEX_ECDH_SHA2_NISTP384:
  ------------------
  |  Branch (292:9): [True: 0, False: 8.64k]
  ------------------
  293|      0|        case SSH_KEX_ECDH_SHA2_NISTP521:
  ------------------
  |  Branch (293:9): [True: 0, False: 8.64k]
  ------------------
  294|      0|            rc = ssh_client_ecdh_init(session);
  295|      0|            break;
  296|      0|#endif
  297|      0|#ifdef HAVE_CURVE25519
  298|      0|        case SSH_KEX_CURVE25519_SHA256:
  ------------------
  |  Branch (298:9): [True: 0, False: 8.64k]
  ------------------
  299|      0|        case SSH_KEX_CURVE25519_SHA256_LIBSSH_ORG:
  ------------------
  |  Branch (299:9): [True: 0, False: 8.64k]
  ------------------
  300|      0|            rc = ssh_client_curve25519_init(session);
  301|      0|            break;
  302|      0|#endif
  303|      0|#ifdef HAVE_SNTRUP761
  304|      0|        case SSH_KEX_SNTRUP761X25519_SHA512:
  ------------------
  |  Branch (304:9): [True: 0, False: 8.64k]
  ------------------
  305|      0|        case SSH_KEX_SNTRUP761X25519_SHA512_OPENSSH_COM:
  ------------------
  |  Branch (305:9): [True: 0, False: 8.64k]
  ------------------
  306|      0|            rc = ssh_client_sntrup761x25519_init(session);
  307|      0|            break;
  308|      0|#endif
  309|  8.64k|        case SSH_KEX_MLKEM768X25519_SHA256:
  ------------------
  |  Branch (309:9): [True: 8.64k, False: 0]
  ------------------
  310|  8.64k|        case SSH_KEX_MLKEM768NISTP256_SHA256:
  ------------------
  |  Branch (310:9): [True: 0, False: 8.64k]
  ------------------
  311|       |#ifdef HAVE_MLKEM1024
  312|       |        case SSH_KEX_MLKEM1024NISTP384_SHA384:
  313|       |#endif
  314|  8.64k|            rc = ssh_client_hybrid_mlkem_init(session);
  315|  8.64k|            break;
  316|      0|        default:
  ------------------
  |  Branch (316:9): [True: 0, False: 8.64k]
  ------------------
  317|      0|            rc = SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  318|  8.64k|        }
  319|       |
  320|  8.64k|        break;
  321|  8.64k|    case DH_STATE_INIT_SENT:
  ------------------
  |  Branch (321:5): [True: 0, False: 8.64k]
  ------------------
  322|       |    	/* wait until ssh_packet_dh_reply is called */
  323|      0|    	break;
  324|      0|    case DH_STATE_NEWKEYS_SENT:
  ------------------
  |  Branch (324:5): [True: 0, False: 8.64k]
  ------------------
  325|       |    	/* wait until ssh_packet_newkeys is called */
  326|      0|    	break;
  327|      0|    case DH_STATE_FINISHED:
  ------------------
  |  Branch (327:5): [True: 0, False: 8.64k]
  ------------------
  328|      0|        return SSH_OK;
  ------------------
  |  |  316|      0|#define SSH_OK 0     /* No error */
  ------------------
  329|      0|    default:
  ------------------
  |  Branch (329:5): [True: 0, False: 8.64k]
  ------------------
  330|      0|        ssh_set_error(session,
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  331|      0|                      SSH_FATAL,
  332|      0|                      "Invalid state in dh_handshake(): %d",
  333|      0|                      session->dh_handshake_state);
  334|       |
  335|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  336|  8.64k|    }
  337|       |
  338|  8.64k|    return rc;
  339|  8.64k|}
ssh_service_request:
  373|  8.64k|{
  374|  8.64k|  int rc = SSH_ERROR;
  ------------------
  |  |  317|  8.64k|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  375|       |
  376|  8.64k|  if(session->auth.service_state != SSH_AUTH_SERVICE_NONE)
  ------------------
  |  Branch (376:6): [True: 0, False: 8.64k]
  ------------------
  377|      0|    goto pending;
  378|       |
  379|  8.64k|  rc = ssh_buffer_pack(session->out_buffer,
  ------------------
  |  |   50|  8.64k|    _ssh_buffer_pack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |  451|  8.64k|        (__VA_NARG_(__VA_ARGS__, __RSEQ_N()))
  |  |  |  |  ------------------
  |  |  |  |  |  |  453|  8.64k|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  448|  8.64k|#define VA_APPLY_VARIADIC_MACRO(macro, tuple) macro tuple
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  453|  8.64k|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  461|  8.64k|        _61,_62,_63,N,...) N
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                   _ssh_buffer_pack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |   28|  8.64k|#define SSH_BUFFER_PACK_END ((uint32_t) 0x4f65feb3)
  |  |  ------------------
  ------------------
  380|  8.64k|                       "bs",
  381|  8.64k|                       SSH2_MSG_SERVICE_REQUEST,
  382|  8.64k|                       service);
  383|  8.64k|  if (rc != SSH_OK){
  ------------------
  |  |  316|  8.64k|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (383:7): [True: 0, False: 8.64k]
  ------------------
  384|      0|      ssh_set_error_oom(session);
  ------------------
  |  |  318|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
  385|      0|      return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  386|      0|  }
  387|  8.64k|  session->auth.service_state = SSH_AUTH_SERVICE_SENT;
  388|  8.64k|  if (ssh_packet_send(session) == SSH_ERROR) {
  ------------------
  |  |  317|  8.64k|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  |  Branch (388:7): [True: 0, False: 8.64k]
  ------------------
  389|      0|    ssh_set_error(session, SSH_FATAL,
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  390|      0|        "Sending SSH2_MSG_SERVICE_REQUEST failed.");
  391|      0|      return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  392|      0|  }
  393|       |
  394|  8.64k|  SSH_LOG(SSH_LOG_PACKET,
  ------------------
  |  |  281|  8.64k|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  395|  8.64k|      "Sent SSH_MSG_SERVICE_REQUEST (service %s)", service);
  396|  8.64k|pending:
  397|  8.64k|  rc=ssh_handle_packets_termination(session,SSH_TIMEOUT_USER,
  ------------------
  |  |  101|  8.64k|#define SSH_TIMEOUT_USER -2
  ------------------
  398|  8.64k|      ssh_service_request_termination, session);
  399|  8.64k|  if (rc == SSH_ERROR) {
  ------------------
  |  |  317|  8.64k|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  |  Branch (399:7): [True: 0, False: 8.64k]
  ------------------
  400|      0|      return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  401|      0|  }
  402|  8.64k|  switch(session->auth.service_state) {
  ------------------
  |  Branch (402:10): [True: 8.64k, False: 0]
  ------------------
  403|      0|  case SSH_AUTH_SERVICE_DENIED:
  ------------------
  |  Branch (403:3): [True: 0, False: 8.64k]
  ------------------
  404|      0|    ssh_set_error(session,SSH_FATAL,"ssh_auth_service request denied");
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  405|      0|    break;
  406|  8.64k|  case SSH_AUTH_SERVICE_ACCEPTED:
  ------------------
  |  Branch (406:3): [True: 8.64k, False: 0]
  ------------------
  407|  8.64k|    rc=SSH_OK;
  ------------------
  |  |  316|  8.64k|#define SSH_OK 0     /* No error */
  ------------------
  408|  8.64k|    break;
  409|      0|  case SSH_AUTH_SERVICE_SENT:
  ------------------
  |  Branch (409:3): [True: 0, False: 8.64k]
  ------------------
  410|      0|    rc=SSH_AGAIN;
  ------------------
  |  |  318|      0|#define SSH_AGAIN -2 /* The nonblocking call must be repeated */
  ------------------
  411|      0|    break;
  412|      0|  case SSH_AUTH_SERVICE_NONE:
  ------------------
  |  Branch (412:3): [True: 0, False: 8.64k]
  ------------------
  413|      0|    rc=SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  414|      0|    break;
  415|  8.64k|  }
  416|       |
  417|  8.64k|  return rc;
  418|  8.64k|}
ssh_connect:
  556|  8.64k|{
  557|  8.64k|    int ret;
  558|       |
  559|  8.64k|    if (!is_ssh_initialized()) {
  ------------------
  |  Branch (559:9): [True: 0, False: 8.64k]
  ------------------
  560|      0|        ssh_set_error(session, SSH_FATAL,
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  561|      0|                      "Library not initialized.");
  562|       |
  563|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  564|      0|    }
  565|       |
  566|  8.64k|    if (session == NULL) {
  ------------------
  |  Branch (566:9): [True: 0, False: 8.64k]
  ------------------
  567|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  568|      0|    }
  569|       |
  570|  8.64k|    switch(session->pending_call_state) {
  571|  8.64k|    case SSH_PENDING_CALL_NONE:
  ------------------
  |  Branch (571:5): [True: 8.64k, False: 0]
  ------------------
  572|  8.64k|        break;
  573|      0|    case SSH_PENDING_CALL_CONNECT:
  ------------------
  |  Branch (573:5): [True: 0, False: 8.64k]
  ------------------
  574|      0|        goto pending;
  575|      0|    default:
  ------------------
  |  Branch (575:5): [True: 0, False: 8.64k]
  ------------------
  576|      0|        ssh_set_error(session, SSH_FATAL,
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  577|      0|                      "Bad call during pending SSH call in ssh_connect");
  578|       |
  579|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  580|  8.64k|    }
  581|  8.64k|    session->alive = 0;
  582|  8.64k|    session->client = 1;
  583|       |
  584|  8.64k|    if (session->opts.fd == SSH_INVALID_SOCKET &&
  ------------------
  |  |  124|  17.2k|#define SSH_INVALID_SOCKET ((socket_t) -1)
  ------------------
  |  Branch (584:9): [True: 0, False: 8.64k]
  ------------------
  585|      0|        session->opts.originalhost == NULL &&
  ------------------
  |  Branch (585:9): [True: 0, False: 0]
  ------------------
  586|      0|        session->opts.ProxyCommand == NULL) {
  ------------------
  |  Branch (586:9): [True: 0, False: 0]
  ------------------
  587|      0|        ssh_set_error(session, SSH_FATAL, "Hostname required");
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  588|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  589|      0|    }
  590|       |
  591|       |    /* If the system configuration files were not yet processed, do it now */
  592|  8.64k|    if (!session->opts.config_processed) {
  ------------------
  |  Branch (592:9): [True: 8.64k, False: 0]
  ------------------
  593|  8.64k|        ret = ssh_options_parse_config(session, NULL);
  594|  8.64k|        if (ret != 0) {
  ------------------
  |  Branch (594:13): [True: 0, False: 8.64k]
  ------------------
  595|      0|            ssh_set_error(session, SSH_FATAL,
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  596|      0|                          "Failed to process system configuration files");
  597|      0|            return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  598|      0|        }
  599|  8.64k|    }
  600|       |
  601|  8.64k|    ret = ssh_options_apply(session);
  602|  8.64k|    if (ret < 0) {
  ------------------
  |  Branch (602:9): [True: 0, False: 8.64k]
  ------------------
  603|      0|        ssh_set_error(session, SSH_FATAL, "Couldn't apply options");
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  604|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  605|      0|    }
  606|       |
  607|  8.64k|    SSH_LOG(SSH_LOG_DEBUG,
  ------------------
  |  |  281|  8.64k|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  608|  8.64k|            "libssh %s, using threading %s",
  609|  8.64k|            ssh_copyright(),
  610|  8.64k|            ssh_threads_get_type());
  611|       |
  612|  8.64k|    session->ssh_connection_callback = ssh_client_connection_callback;
  613|  8.64k|    session->session_state = SSH_SESSION_STATE_CONNECTING;
  614|  8.64k|    ssh_socket_set_callbacks(session->socket, &session->socket_callbacks);
  615|  8.64k|    session->socket_callbacks.connected = socket_callback_connected;
  616|  8.64k|    session->socket_callbacks.data = callback_receive_banner;
  617|  8.64k|    session->socket_callbacks.exception = ssh_socket_exception_callback;
  618|  8.64k|    session->socket_callbacks.userdata = session;
  619|       |
  620|  8.64k|    if (session->opts.fd != SSH_INVALID_SOCKET) {
  ------------------
  |  |  124|  8.64k|#define SSH_INVALID_SOCKET ((socket_t) -1)
  ------------------
  |  Branch (620:9): [True: 8.64k, False: 0]
  ------------------
  621|  8.64k|        session->session_state = SSH_SESSION_STATE_SOCKET_CONNECTED;
  622|  8.64k|        ret = ssh_socket_set_fd(session->socket, session->opts.fd);
  623|  8.64k|#ifndef _WIN32
  624|  8.64k|#ifdef HAVE_PTHREAD
  625|  8.64k|    } else if (ssh_libssh_proxy_jumps() &&
  ------------------
  |  Branch (625:16): [True: 0, False: 0]
  ------------------
  626|      0|               ssh_list_count(session->opts.proxy_jumps) != 0) {
  ------------------
  |  Branch (626:16): [True: 0, False: 0]
  ------------------
  627|      0|        ret = ssh_socket_connect_proxyjump(session->socket);
  628|      0|#endif /* HAVE_PTHREAD */
  629|      0|#endif /* _WIN32 */
  630|      0|    } else if (session->opts.ProxyCommand != NULL) {
  ------------------
  |  Branch (630:16): [True: 0, False: 0]
  ------------------
  631|       |#ifdef WITH_EXEC
  632|       |        ret = ssh_socket_connect_proxycommand(session->socket,
  633|       |                session->opts.ProxyCommand);
  634|       |#else
  635|      0|        ssh_set_error(session,
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  636|      0|                      SSH_FATAL,
  637|      0|                      "The libssh is built without support for proxy commands.");
  638|      0|        ret = SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  639|      0|#endif /* WITH_EXEC */
  640|      0|    } else {
  641|      0|        ret = ssh_socket_connect(session->socket,
  642|      0|                                 session->opts.host,
  643|      0|                                 session->opts.port > 0 ? session->opts.port : 22,
  ------------------
  |  Branch (643:34): [True: 0, False: 0]
  ------------------
  644|      0|                                 session->opts.bindaddr);
  645|      0|    }
  646|  8.64k|    if (ret == SSH_ERROR) {
  ------------------
  |  |  317|  8.64k|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  |  Branch (646:9): [True: 0, False: 8.64k]
  ------------------
  647|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  648|      0|    }
  649|       |
  650|  8.64k|    set_status(session, 0.2f);
  ------------------
  |  |   58|  8.64k|#define set_status(session, status) do {\
  |  |   59|  8.64k|        if (session->common.callbacks && session->common.callbacks->connect_status_function) \
  |  |  ------------------
  |  |  |  Branch (59:13): [True: 0, False: 8.64k]
  |  |  |  Branch (59:42): [True: 0, False: 0]
  |  |  ------------------
  |  |   60|  8.64k|            session->common.callbacks->connect_status_function(session->common.callbacks->userdata, status); \
  |  |   61|  8.64k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (61:14): [Folded, False: 8.64k]
  |  |  ------------------
  ------------------
  651|       |
  652|  8.64k|    session->alive = 1;
  653|  8.64k|    SSH_LOG(SSH_LOG_DEBUG,
  ------------------
  |  |  281|  8.64k|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  654|  8.64k|            "Socket connecting, now waiting for the callbacks to work");
  655|       |
  656|  8.64k|pending:
  657|  8.64k|    session->pending_call_state = SSH_PENDING_CALL_CONNECT;
  658|  8.64k|    if(ssh_is_blocking(session)) {
  ------------------
  |  Branch (658:8): [True: 8.64k, False: 0]
  ------------------
  659|  8.64k|        int timeout = ssh_make_milliseconds(session->opts.timeout,
  660|  8.64k|                                            session->opts.timeout_usec);
  661|  8.64k|        SSH_LOG(SSH_LOG_PACKET, "Actual timeout : %d", timeout);
  ------------------
  |  |  281|  8.64k|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  662|  8.64k|        ret = ssh_handle_packets_termination(session, timeout,
  663|  8.64k|                                             ssh_connect_termination, session);
  664|  8.64k|        if (session->session_state != SSH_SESSION_STATE_ERROR &&
  ------------------
  |  Branch (664:13): [True: 8.64k, False: 0]
  ------------------
  665|  8.64k|            (ret == SSH_ERROR || !ssh_connect_termination(session)))
  ------------------
  |  |  317|  17.2k|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  |  Branch (665:14): [True: 0, False: 8.64k]
  |  Branch (665:34): [True: 0, False: 8.64k]
  ------------------
  666|      0|        {
  667|      0|            ssh_set_error(session, SSH_FATAL,
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  668|      0|                          "Timeout connecting to %s", session->opts.host);
  669|      0|            session->session_state = SSH_SESSION_STATE_ERROR;
  670|      0|        }
  671|  8.64k|    } else {
  672|      0|        ret = ssh_handle_packets_termination(session,
  673|      0|                                             SSH_TIMEOUT_NONBLOCKING,
  ------------------
  |  |  105|      0|#define SSH_TIMEOUT_NONBLOCKING 0
  ------------------
  674|      0|                                             ssh_connect_termination,
  675|      0|                                             session);
  676|      0|        if (ret == SSH_ERROR) {
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  |  Branch (676:13): [True: 0, False: 0]
  ------------------
  677|      0|            session->session_state = SSH_SESSION_STATE_ERROR;
  678|      0|        }
  679|      0|    }
  680|       |
  681|  8.64k|    SSH_LOG(SSH_LOG_PACKET, "current state : %d", session->session_state);
  ------------------
  |  |  281|  8.64k|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  682|  8.64k|    if (!ssh_is_blocking(session) && !ssh_connect_termination(session)) {
  ------------------
  |  Branch (682:9): [True: 0, False: 8.64k]
  |  Branch (682:38): [True: 0, False: 0]
  ------------------
  683|      0|        return SSH_AGAIN;
  ------------------
  |  |  318|      0|#define SSH_AGAIN -2 /* The nonblocking call must be repeated */
  ------------------
  684|      0|    }
  685|       |
  686|  8.64k|    session->pending_call_state = SSH_PENDING_CALL_NONE;
  687|  8.64k|    if (session->session_state == SSH_SESSION_STATE_ERROR ||
  ------------------
  |  Branch (687:9): [True: 0, False: 8.64k]
  ------------------
  688|  8.64k|        session->session_state == SSH_SESSION_STATE_DISCONNECTED)
  ------------------
  |  Branch (688:9): [True: 0, False: 8.64k]
  ------------------
  689|      0|    {
  690|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  691|      0|    }
  692|       |
  693|  8.64k|    return SSH_OK;
  ------------------
  |  |  316|  8.64k|#define SSH_OK 0     /* No error */
  ------------------
  694|  8.64k|}
ssh_disconnect:
  809|  17.2k|{
  810|  17.2k|    struct ssh_iterator *it = NULL;
  811|  17.2k|    int rc;
  812|       |
  813|  17.2k|    if (session == NULL) {
  ------------------
  |  Branch (813:9): [True: 0, False: 17.2k]
  ------------------
  814|      0|        return;
  815|      0|    }
  816|       |
  817|  17.2k|#ifndef _WIN32
  818|  17.2k|#ifdef HAVE_PTHREAD
  819|       |    /* Only send the disconnect to all other threads when the root session calls
  820|       |     * ssh_disconnect() */
  821|  17.2k|    if (session->proxy_root) {
  ------------------
  |  Branch (821:9): [True: 17.2k, False: 0]
  ------------------
  822|  17.2k|        proxy_disconnect = 1;
  823|  17.2k|    }
  824|  17.2k|#endif /* HAVE_PTHREAD */
  825|  17.2k|#endif /* _WIN32 */
  826|       |
  827|  17.2k|    if (session->disconnect_message == NULL) {
  ------------------
  |  Branch (827:9): [True: 17.2k, False: 0]
  ------------------
  828|  17.2k|        session->disconnect_message = strdup("Bye Bye") ;
  829|  17.2k|        if (session->disconnect_message == NULL) {
  ------------------
  |  Branch (829:13): [True: 0, False: 17.2k]
  ------------------
  830|      0|            ssh_set_error_oom(session);
  ------------------
  |  |  318|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
  831|      0|            goto error;
  832|      0|        }
  833|  17.2k|    }
  834|       |
  835|  17.2k|    if (session->socket != NULL && ssh_socket_is_open(session->socket)) {
  ------------------
  |  Branch (835:9): [True: 17.2k, False: 0]
  |  Branch (835:36): [True: 8.64k, False: 8.64k]
  ------------------
  836|  8.64k|        rc = ssh_buffer_pack(session->out_buffer,
  ------------------
  |  |   50|  8.64k|    _ssh_buffer_pack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |  451|  8.64k|        (__VA_NARG_(__VA_ARGS__, __RSEQ_N()))
  |  |  |  |  ------------------
  |  |  |  |  |  |  453|  8.64k|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  448|  8.64k|#define VA_APPLY_VARIADIC_MACRO(macro, tuple) macro tuple
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  453|  8.64k|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  461|  8.64k|        _61,_62,_63,N,...) N
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                   _ssh_buffer_pack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |   28|  8.64k|#define SSH_BUFFER_PACK_END ((uint32_t) 0x4f65feb3)
  |  |  ------------------
  ------------------
  837|  8.64k|                             "bdss",
  838|  8.64k|                             SSH2_MSG_DISCONNECT,
  839|  8.64k|                             SSH2_DISCONNECT_BY_APPLICATION,
  840|  8.64k|                             session->disconnect_message,
  841|  8.64k|                             ""); /* language tag */
  842|  8.64k|        if (rc != SSH_OK) {
  ------------------
  |  |  316|  8.64k|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (842:13): [True: 0, False: 8.64k]
  ------------------
  843|      0|            ssh_set_error_oom(session);
  ------------------
  |  |  318|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
  844|      0|            goto error;
  845|      0|        }
  846|       |
  847|  8.64k|        ssh_packet_send(session);
  848|  8.64k|        ssh_session_socket_close(session);
  849|  8.64k|    }
  850|       |
  851|  17.2k|error:
  852|  17.2k|    session->recv_seq = 0;
  853|  17.2k|    session->send_seq = 0;
  854|  17.2k|    session->alive = 0;
  855|  17.2k|    if (session->socket != NULL){
  ------------------
  |  Branch (855:9): [True: 17.2k, False: 0]
  ------------------
  856|  17.2k|        ssh_socket_reset(session->socket);
  857|  17.2k|    }
  858|  17.2k|    session->opts.fd = SSH_INVALID_SOCKET;
  ------------------
  |  |  124|  17.2k|#define SSH_INVALID_SOCKET ((socket_t) -1)
  ------------------
  859|  17.2k|    session->session_state = SSH_SESSION_STATE_DISCONNECTED;
  860|  17.2k|    session->pending_call_state = SSH_PENDING_CALL_NONE;
  861|  17.2k|    session->packet_state = PACKET_STATE_INIT;
  862|       |
  863|  25.9k|    while ((it = ssh_list_get_iterator(session->channels)) != NULL) {
  ------------------
  |  Branch (863:12): [True: 8.64k, False: 17.2k]
  ------------------
  864|  8.64k|        ssh_channel_do_free(ssh_iterator_value(ssh_channel, it));
  ------------------
  |  |  114|  8.64k|  ((type)((iterator)->data))
  ------------------
  865|  8.64k|        ssh_list_remove(session->channels, it);
  866|  8.64k|    }
  867|  17.2k|    if (session->current_crypto) {
  ------------------
  |  Branch (867:9): [True: 17.2k, False: 0]
  ------------------
  868|  17.2k|      crypto_free(session->current_crypto);
  869|  17.2k|      session->current_crypto = NULL;
  870|  17.2k|    }
  871|  17.2k|    if (session->next_crypto) {
  ------------------
  |  Branch (871:9): [True: 17.2k, False: 0]
  ------------------
  872|  17.2k|        crypto_free(session->next_crypto);
  873|  17.2k|        session->next_crypto = crypto_new();
  874|  17.2k|        if (session->next_crypto == NULL) {
  ------------------
  |  Branch (874:13): [True: 0, False: 17.2k]
  ------------------
  875|      0|            ssh_set_error_oom(session);
  ------------------
  |  |  318|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
  876|      0|        }
  877|  17.2k|    }
  878|  17.2k|    if (session->in_buffer) {
  ------------------
  |  Branch (878:9): [True: 17.2k, False: 0]
  ------------------
  879|  17.2k|        ssh_buffer_reinit(session->in_buffer);
  880|  17.2k|    }
  881|  17.2k|    if (session->out_buffer) {
  ------------------
  |  Branch (881:9): [True: 17.2k, False: 0]
  ------------------
  882|  17.2k|        ssh_buffer_reinit(session->out_buffer);
  883|  17.2k|    }
  884|  17.2k|    if (session->in_hashbuf) {
  ------------------
  |  Branch (884:9): [True: 0, False: 17.2k]
  ------------------
  885|      0|        ssh_buffer_reinit(session->in_hashbuf);
  886|      0|    }
  887|  17.2k|    if (session->out_hashbuf) {
  ------------------
  |  Branch (887:9): [True: 0, False: 17.2k]
  ------------------
  888|      0|        ssh_buffer_reinit(session->out_hashbuf);
  889|      0|    }
  890|  17.2k|    session->auth.supported_methods = 0;
  891|  17.2k|    SAFE_FREE(session->serverbanner);
  ------------------
  |  |  373|  17.2k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 17.2k, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 17.2k]
  |  |  ------------------
  ------------------
  892|  17.2k|    SAFE_FREE(session->clientbanner);
  ------------------
  |  |  373|  17.2k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 17.2k, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 17.2k]
  |  |  ------------------
  ------------------
  893|  17.2k|    SAFE_FREE(session->disconnect_message);
  ------------------
  |  |  373|  17.2k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 17.2k, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 17.2k]
  |  |  ------------------
  ------------------
  894|       |
  895|  17.2k|    if (session->ssh_message_list) {
  ------------------
  |  Branch (895:9): [True: 0, False: 17.2k]
  ------------------
  896|      0|        ssh_message msg = NULL;
  897|       |
  898|      0|        while ((msg = ssh_list_pop_head(ssh_message,
  ------------------
  |  |  122|      0|  ((type)_ssh_list_pop_head(ssh_list))
  ------------------
  |  Branch (898:16): [True: 0, False: 0]
  ------------------
  899|      0|                                        session->ssh_message_list)) != NULL) {
  900|      0|              ssh_message_free(msg);
  901|      0|        }
  902|      0|        ssh_list_free(session->ssh_message_list);
  903|      0|        session->ssh_message_list = NULL;
  904|      0|    }
  905|       |
  906|  17.2k|    if (session->packet_callbacks) {
  ------------------
  |  Branch (906:9): [True: 17.2k, False: 0]
  ------------------
  907|  17.2k|        ssh_list_free(session->packet_callbacks);
  908|       |        session->packet_callbacks = NULL;
  909|  17.2k|    }
  910|  17.2k|}
ssh_copyright:
  920|  8.64k|{
  921|  8.64k|    return SSH_STRINGIFY(LIBSSH_VERSION) " (c) 2003-2026 "
  ------------------
  |  |   71|  8.64k|#define SSH_STRINGIFY(s) SSH_TOSTRING(s)
  |  |  ------------------
  |  |  |  |   72|  8.64k|#define SSH_TOSTRING(s) #s
  |  |  ------------------
  ------------------
  922|  8.64k|           "Aris Adamantiadis, Andreas Schneider "
  923|  8.64k|           "and libssh contributors. "
  924|  8.64k|           "Distributed under the LGPL, please refer to COPYING "
  925|  8.64k|           "file for information about your rights";
  926|  8.64k|}
client.c:ssh_service_request_termination:
  342|  34.5k|{
  343|  34.5k|    ssh_session session = (ssh_session)s;
  344|       |
  345|  34.5k|    if (session->session_state == SSH_SESSION_STATE_ERROR ||
  ------------------
  |  Branch (345:9): [True: 0, False: 34.5k]
  ------------------
  346|  34.5k|        session->auth.service_state != SSH_AUTH_SERVICE_SENT)
  ------------------
  |  Branch (346:9): [True: 8.64k, False: 25.9k]
  ------------------
  347|  8.64k|        return 1;
  348|  25.9k|    else
  349|  25.9k|        return 0;
  350|  34.5k|}
client.c:ssh_client_connection_callback:
  427|  51.8k|{
  428|  51.8k|    int rc;
  429|       |
  430|  51.8k|    SSH_LOG(SSH_LOG_DEBUG, "session_state=%d", session->session_state);
  ------------------
  |  |  281|  51.8k|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  431|       |
  432|  51.8k|    switch (session->session_state) {
  433|      0|    case SSH_SESSION_STATE_NONE:
  ------------------
  |  Branch (433:5): [True: 0, False: 51.8k]
  ------------------
  434|      0|    case SSH_SESSION_STATE_CONNECTING:
  ------------------
  |  Branch (434:5): [True: 0, False: 51.8k]
  ------------------
  435|      0|        break;
  436|  8.64k|    case SSH_SESSION_STATE_SOCKET_CONNECTED:
  ------------------
  |  Branch (436:5): [True: 8.64k, False: 43.1k]
  ------------------
  437|  8.64k|        ssh_set_fd_towrite(session);
  438|  8.64k|        ssh_send_banner(session, 0);
  439|       |
  440|  8.64k|        break;
  441|  8.64k|    case SSH_SESSION_STATE_BANNER_RECEIVED:
  ------------------
  |  Branch (441:5): [True: 8.64k, False: 43.1k]
  ------------------
  442|  8.64k|        if (session->serverbanner == NULL) {
  ------------------
  |  Branch (442:13): [True: 0, False: 8.64k]
  ------------------
  443|      0|            goto error;
  444|      0|        }
  445|  8.64k|        set_status(session, 0.4f);
  ------------------
  |  |   58|  8.64k|#define set_status(session, status) do {\
  |  |   59|  8.64k|        if (session->common.callbacks && session->common.callbacks->connect_status_function) \
  |  |  ------------------
  |  |  |  Branch (59:13): [True: 0, False: 8.64k]
  |  |  |  Branch (59:42): [True: 0, False: 0]
  |  |  ------------------
  |  |   60|  8.64k|            session->common.callbacks->connect_status_function(session->common.callbacks->userdata, status); \
  |  |   61|  8.64k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (61:14): [Folded, False: 8.64k]
  |  |  ------------------
  ------------------
  446|  8.64k|        SSH_LOG(SSH_LOG_DEBUG, "SSH server banner: %s", session->serverbanner);
  ------------------
  |  |  281|  8.64k|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  447|       |
  448|       |        /* Here we analyze the different protocols the server allows. */
  449|  8.64k|        rc = ssh_analyze_banner(session, 0);
  450|  8.64k|        if (rc < 0) {
  ------------------
  |  Branch (450:13): [True: 0, False: 8.64k]
  ------------------
  451|      0|            ssh_set_error(session, SSH_FATAL,
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  452|      0|                          "No version of SSH protocol usable (banner: %s)",
  453|      0|                          session->serverbanner);
  454|      0|            goto error;
  455|      0|        }
  456|       |
  457|  8.64k|        ssh_packet_register_socket_callback(session, session->socket);
  458|       |
  459|  8.64k|        ssh_packet_set_default_callbacks(session);
  460|  8.64k|        session->session_state = SSH_SESSION_STATE_INITIAL_KEX;
  461|  8.64k|        rc = ssh_set_client_kex(session);
  462|  8.64k|        if (rc != SSH_OK) {
  ------------------
  |  |  316|  8.64k|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (462:13): [True: 0, False: 8.64k]
  ------------------
  463|      0|            goto error;
  464|      0|        }
  465|  8.64k|        rc = ssh_send_kex(session);
  466|  8.64k|        if (rc < 0) {
  ------------------
  |  Branch (466:13): [True: 0, False: 8.64k]
  ------------------
  467|      0|            goto error;
  468|      0|        }
  469|  8.64k|        set_status(session, 0.5f);
  ------------------
  |  |   58|  8.64k|#define set_status(session, status) do {\
  |  |   59|  8.64k|        if (session->common.callbacks && session->common.callbacks->connect_status_function) \
  |  |  ------------------
  |  |  |  Branch (59:13): [True: 0, False: 8.64k]
  |  |  |  Branch (59:42): [True: 0, False: 0]
  |  |  ------------------
  |  |   60|  8.64k|            session->common.callbacks->connect_status_function(session->common.callbacks->userdata, status); \
  |  |   61|  8.64k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (61:14): [Folded, False: 8.64k]
  |  |  ------------------
  ------------------
  470|       |
  471|  8.64k|        break;
  472|      0|    case SSH_SESSION_STATE_INITIAL_KEX:
  ------------------
  |  Branch (472:5): [True: 0, False: 51.8k]
  ------------------
  473|       |        /* TODO: This state should disappear in favor of get_key handle */
  474|      0|        break;
  475|  8.64k|    case SSH_SESSION_STATE_KEXINIT_RECEIVED:
  ------------------
  |  Branch (475:5): [True: 8.64k, False: 43.1k]
  ------------------
  476|  8.64k|        set_status(session, 0.6f);
  ------------------
  |  |   58|  8.64k|#define set_status(session, status) do {\
  |  |   59|  8.64k|        if (session->common.callbacks && session->common.callbacks->connect_status_function) \
  |  |  ------------------
  |  |  |  Branch (59:13): [True: 0, False: 8.64k]
  |  |  |  Branch (59:42): [True: 0, False: 0]
  |  |  ------------------
  |  |   60|  8.64k|            session->common.callbacks->connect_status_function(session->common.callbacks->userdata, status); \
  |  |   61|  8.64k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (61:14): [Folded, False: 8.64k]
  |  |  ------------------
  ------------------
  477|  8.64k|        ssh_list_kex(&session->next_crypto->server_kex);
  478|  8.64k|        if ((session->flags & SSH_SESSION_FLAG_KEXINIT_SENT) == 0) {
  ------------------
  |  |   86|  8.64k|#define SSH_SESSION_FLAG_KEXINIT_SENT 0x0008
  ------------------
  |  Branch (478:13): [True: 0, False: 8.64k]
  ------------------
  479|       |            /* in rekeying state if next_crypto client_kex might be empty */
  480|      0|            rc = ssh_set_client_kex(session);
  481|      0|            if (rc != SSH_OK) {
  ------------------
  |  |  316|      0|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (481:17): [True: 0, False: 0]
  ------------------
  482|      0|                goto error;
  483|      0|            }
  484|      0|            rc = ssh_send_kex(session);
  485|      0|            if (rc < 0) {
  ------------------
  |  Branch (485:17): [True: 0, False: 0]
  ------------------
  486|      0|                goto error;
  487|      0|            }
  488|      0|        }
  489|  8.64k|        if (ssh_kex_select_methods(session) == SSH_ERROR)
  ------------------
  |  |  317|  8.64k|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  |  Branch (489:13): [True: 0, False: 8.64k]
  ------------------
  490|      0|            goto error;
  491|  8.64k|        set_status(session, 0.8f);
  ------------------
  |  |   58|  8.64k|#define set_status(session, status) do {\
  |  |   59|  8.64k|        if (session->common.callbacks && session->common.callbacks->connect_status_function) \
  |  |  ------------------
  |  |  |  Branch (59:13): [True: 0, False: 8.64k]
  |  |  |  Branch (59:42): [True: 0, False: 0]
  |  |  ------------------
  |  |   60|  8.64k|            session->common.callbacks->connect_status_function(session->common.callbacks->userdata, status); \
  |  |   61|  8.64k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (61:14): [Folded, False: 8.64k]
  |  |  ------------------
  ------------------
  492|  8.64k|        session->session_state = SSH_SESSION_STATE_DH;
  493|       |
  494|       |        /* If the init packet was already sent in previous step, this will be no
  495|       |         * operation */
  496|  8.64k|        if (dh_handshake(session) == SSH_ERROR) {
  ------------------
  |  |  317|  8.64k|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  |  Branch (496:13): [True: 0, False: 8.64k]
  ------------------
  497|      0|            goto error;
  498|      0|        }
  499|  8.64k|        FALL_THROUGH;
  ------------------
  |  |  494|  8.64k|#  define FALL_THROUGH __attribute__ ((fallthrough))
  ------------------
  500|  17.2k|    case SSH_SESSION_STATE_DH:
  ------------------
  |  Branch (500:5): [True: 8.64k, False: 43.1k]
  ------------------
  501|  17.2k|        if (session->dh_handshake_state == DH_STATE_FINISHED) {
  ------------------
  |  Branch (501:13): [True: 8.64k, False: 8.64k]
  ------------------
  502|  8.64k|            set_status(session, 1.0f);
  ------------------
  |  |   58|  8.64k|#define set_status(session, status) do {\
  |  |   59|  8.64k|        if (session->common.callbacks && session->common.callbacks->connect_status_function) \
  |  |  ------------------
  |  |  |  Branch (59:13): [True: 0, False: 8.64k]
  |  |  |  Branch (59:42): [True: 0, False: 0]
  |  |  ------------------
  |  |   60|  8.64k|            session->common.callbacks->connect_status_function(session->common.callbacks->userdata, status); \
  |  |   61|  8.64k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (61:14): [Folded, False: 8.64k]
  |  |  ------------------
  ------------------
  503|  8.64k|            session->connected = 1;
  504|  8.64k|            if (session->flags & SSH_SESSION_FLAG_AUTHENTICATED) {
  ------------------
  |  |   78|  8.64k|#define SSH_SESSION_FLAG_AUTHENTICATED 0x0002
  ------------------
  |  Branch (504:17): [True: 0, False: 8.64k]
  ------------------
  505|      0|                session->session_state = SSH_SESSION_STATE_AUTHENTICATED;
  506|  8.64k|            } else {
  507|  8.64k|                session->session_state = SSH_SESSION_STATE_AUTHENTICATING;
  508|  8.64k|            }
  509|  8.64k|        }
  510|  17.2k|        break;
  511|      0|    case SSH_SESSION_STATE_AUTHENTICATING:
  ------------------
  |  Branch (511:5): [True: 0, False: 51.8k]
  ------------------
  512|      0|        break;
  513|  17.2k|    case SSH_SESSION_STATE_ERROR:
  ------------------
  |  Branch (513:5): [True: 17.2k, False: 34.5k]
  ------------------
  514|  17.2k|        goto error;
  515|      0|    default:
  ------------------
  |  Branch (515:5): [True: 0, False: 51.8k]
  ------------------
  516|      0|        ssh_set_error(session, SSH_FATAL, "Invalid state %d",
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  517|  51.8k|                      session->session_state);
  518|  51.8k|    }
  519|       |
  520|  34.5k|    return;
  521|  34.5k|error:
  522|  17.2k|    ssh_session_socket_close(session);
  523|  17.2k|    SSH_LOG(SSH_LOG_WARN, "%s", ssh_get_error(session));
  ------------------
  |  |  281|  17.2k|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  524|  17.2k|}
client.c:socket_callback_connected:
   72|  8.64k|{
   73|  8.64k|	ssh_session session=(ssh_session)user;
   74|       |
   75|  8.64k|	if (session->session_state != SSH_SESSION_STATE_CONNECTING &&
  ------------------
  |  Branch (75:6): [True: 8.64k, False: 0]
  ------------------
   76|  8.64k|	    session->session_state != SSH_SESSION_STATE_SOCKET_CONNECTED)
  ------------------
  |  Branch (76:6): [True: 0, False: 8.64k]
  ------------------
   77|      0|	{
   78|      0|		ssh_set_error(session,SSH_FATAL, "Wrong state in socket_callback_connected : %d",
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
   79|      0|				session->session_state);
   80|       |
   81|      0|		return;
   82|      0|	}
   83|       |
   84|  8.64k|	SSH_LOG(SSH_LOG_TRACE,"Socket connection callback: %d (%d)",code, errno_code);
  ------------------
  |  |  281|  8.64k|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
   85|  8.64k|	if(code == SSH_SOCKET_CONNECTED_OK)
  ------------------
  |  |  523|  8.64k|#define SSH_SOCKET_CONNECTED_OK 			1
  ------------------
  |  Branch (85:5): [True: 8.64k, False: 0]
  ------------------
   86|  8.64k|		session->session_state=SSH_SESSION_STATE_SOCKET_CONNECTED;
   87|      0|	else {
   88|      0|        char err_msg[SSH_ERRNO_MSG_MAX] = {0};
   89|      0|		session->session_state=SSH_SESSION_STATE_ERROR;
   90|      0|		ssh_set_error(session,SSH_FATAL,"%s",
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
   91|      0|                      ssh_strerror(errno_code, err_msg, SSH_ERRNO_MSG_MAX));
   92|      0|	}
   93|  8.64k|	session->ssh_connection_callback(session);
   94|  8.64k|}
client.c:callback_receive_banner:
  108|  8.64k|{
  109|  8.64k|    char *buffer = (char *)data;
  110|  8.64k|    ssh_session session = (ssh_session) user;
  111|  8.64k|    char *str = NULL;
  112|  8.64k|    uint32_t i;
  113|  8.64k|    int ret=0;
  114|       |
  115|  8.64k|    if (session->session_state != SSH_SESSION_STATE_SOCKET_CONNECTED) {
  ------------------
  |  Branch (115:9): [True: 0, False: 8.64k]
  ------------------
  116|      0|        ssh_set_error(session,SSH_FATAL,
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  117|      0|                      "Wrong state in callback_receive_banner : %d",
  118|      0|                      session->session_state);
  119|       |
  120|      0|        return 0;
  121|      0|    }
  122|   198k|    for (i = 0; i < len; ++i) {
  ------------------
  |  Branch (122:17): [True: 198k, False: 0]
  ------------------
  123|   198k|#ifdef WITH_PCAP
  124|   198k|        if (session->pcap_ctx && buffer[i] == '\n') {
  ------------------
  |  Branch (124:13): [True: 0, False: 198k]
  |  Branch (124:34): [True: 0, False: 0]
  ------------------
  125|      0|            ssh_pcap_context_write(session->pcap_ctx,
  126|      0|                                   SSH_PCAP_DIR_IN,
  127|      0|                                   buffer,i+1,
  128|      0|                                   i+1);
  129|      0|        }
  130|   198k|#endif
  131|   198k|        if (buffer[i] == '\r') {
  ------------------
  |  Branch (131:13): [True: 8.64k, False: 190k]
  ------------------
  132|  8.64k|            buffer[i] = '\0';
  133|  8.64k|        }
  134|   198k|        if (buffer[i] == '\n') {
  ------------------
  |  Branch (134:13): [True: 8.64k, False: 190k]
  ------------------
  135|  8.64k|            int cmp;
  136|       |
  137|  8.64k|            buffer[i] = '\0';
  138|       |
  139|       |            /* The server MAY send other lines of data... */
  140|  8.64k|            cmp = strncmp(buffer, "SSH-", 4);
  141|  8.64k|            if (cmp == 0) {
  ------------------
  |  Branch (141:17): [True: 8.64k, False: 0]
  ------------------
  142|  8.64k|                str = strdup(buffer);
  143|  8.64k|                if (str == NULL) {
  ------------------
  |  Branch (143:21): [True: 0, False: 8.64k]
  ------------------
  144|      0|                    return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  145|      0|                }
  146|       |                /* number of bytes read */
  147|  8.64k|                ret = i + 1;
  148|  8.64k|                session->serverbanner = str;
  149|  8.64k|                session->session_state = SSH_SESSION_STATE_BANNER_RECEIVED;
  150|  8.64k|                SSH_LOG(SSH_LOG_PACKET, "Received banner: %s", str);
  ------------------
  |  |  281|  8.64k|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  151|  8.64k|                session->ssh_connection_callback(session);
  152|       |
  153|  8.64k|                return ret;
  154|  8.64k|            } else {
  155|      0|                SSH_LOG(SSH_LOG_DEBUG,
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  156|      0|                        "ssh_protocol_version_exchange: %s",
  157|      0|                        buffer);
  158|      0|                ret = i + 1;
  159|      0|                break;
  160|      0|            }
  161|  8.64k|        }
  162|       |        /* According to RFC 4253 the max banner length is 255 */
  163|   190k|        if (i > 255) {
  ------------------
  |  Branch (163:13): [True: 0, False: 190k]
  ------------------
  164|       |            /* Too big banner */
  165|      0|            session->session_state=SSH_SESSION_STATE_ERROR;
  166|      0|            ssh_set_error(session,
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  167|      0|                          SSH_FATAL,
  168|      0|                          "Receiving banner: too large banner");
  169|       |
  170|      0|            return 0;
  171|      0|        }
  172|   190k|    }
  173|       |
  174|      0|    return ret;
  175|  8.64k|}
client.c:ssh_connect_termination:
  530|  64.1k|{
  531|  64.1k|    ssh_session session = (ssh_session)user;
  532|       |
  533|  64.1k|    switch (session->session_state) {
  534|      0|    case SSH_SESSION_STATE_ERROR:
  ------------------
  |  Branch (534:5): [True: 0, False: 64.1k]
  ------------------
  535|  17.2k|    case SSH_SESSION_STATE_AUTHENTICATING:
  ------------------
  |  Branch (535:5): [True: 17.2k, False: 46.8k]
  ------------------
  536|  17.2k|    case SSH_SESSION_STATE_DISCONNECTED:
  ------------------
  |  Branch (536:5): [True: 0, False: 64.1k]
  ------------------
  537|  17.2k|        return 1;
  538|  46.8k|    default:
  ------------------
  |  Branch (538:5): [True: 46.8k, False: 17.2k]
  ------------------
  539|  46.8k|        return 0;
  540|  64.1k|    }
  541|  64.1k|}

ssh_config_parse_file:
 2166|  8.64k|{
 2167|  8.64k|    FILE *fp = NULL;
 2168|  8.64k|    int rv;
 2169|  8.64k|    bool global = 0;
 2170|       |
 2171|  8.64k|    fp = ssh_strict_fopen(filename, SSH_MAX_CONFIG_FILE_SIZE);
  ------------------
  |  |  528|  8.64k|#define SSH_MAX_CONFIG_FILE_SIZE 16 * 1024 * 1024
  ------------------
 2172|  8.64k|    if (fp == NULL) {
  ------------------
  |  Branch (2172:9): [True: 8.64k, False: 0]
  ------------------
 2173|       |        /* The underlying function logs the reasons */
 2174|  8.64k|        return 0;
 2175|  8.64k|    }
 2176|       |
 2177|      0|    rv = strcmp(filename, GLOBAL_CLIENT_CONFIG);
  ------------------
  |  |   21|      0|#define GLOBAL_CLIENT_CONFIG "/etc/ssh/ssh_config"
  ------------------
 2178|       |#ifdef USR_GLOBAL_CLIENT_CONFIG
 2179|       |    if (rv != 0) {
 2180|       |        rv = strcmp(filename, USR_GLOBAL_CLIENT_CONFIG);
 2181|       |    }
 2182|       |#endif
 2183|       |
 2184|      0|    if (rv == 0) {
  ------------------
  |  Branch (2184:9): [True: 0, False: 0]
  ------------------
 2185|      0|        global = true;
 2186|      0|    }
 2187|       |
 2188|      0|    SSH_LOG(SSH_LOG_PACKET, "Reading configuration data from %s", filename);
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 2189|       |
 2190|      0|    rv = ssh_config_parse(session, fp, global);
 2191|       |
 2192|      0|    fclose(fp);
 2193|      0|    return rv;
 2194|  8.64k|}

ssh_config_parse_uri:
  248|  17.2k|{
  249|  17.2k|    const char *endp = NULL;
  250|  17.2k|    long port_n;
  251|  17.2k|    int rc;
  252|       |
  253|       |    /* Sanitize inputs */
  254|  17.2k|    if (username != NULL) {
  ------------------
  |  Branch (254:9): [True: 8.64k, False: 8.64k]
  ------------------
  255|  8.64k|        *username = NULL;
  256|  8.64k|    }
  257|  17.2k|    if (hostname != NULL) {
  ------------------
  |  Branch (257:9): [True: 17.2k, False: 0]
  ------------------
  258|  17.2k|        *hostname = NULL;
  259|  17.2k|    }
  260|  17.2k|    if (port != NULL) {
  ------------------
  |  Branch (260:9): [True: 0, False: 17.2k]
  ------------------
  261|      0|        *port = NULL;
  262|      0|    }
  263|       |
  264|       |    /* Username part (optional) */
  265|  17.2k|    endp = strrchr(tok, '@');
  266|  17.2k|    if (endp != NULL) {
  ------------------
  |  Branch (266:9): [True: 0, False: 17.2k]
  ------------------
  267|       |        /* Zero-length username is not valid */
  268|      0|        if (tok == endp) {
  ------------------
  |  Branch (268:13): [True: 0, False: 0]
  ------------------
  269|      0|            goto error;
  270|      0|        }
  271|      0|        if (username != NULL) {
  ------------------
  |  Branch (271:13): [True: 0, False: 0]
  ------------------
  272|      0|            *username = strndup(tok, endp - tok);
  273|      0|            if (*username == NULL) {
  ------------------
  |  Branch (273:17): [True: 0, False: 0]
  ------------------
  274|      0|                goto error;
  275|      0|            }
  276|      0|            rc = ssh_check_username_syntax(*username);
  277|      0|            if (rc != SSH_OK) {
  ------------------
  |  |  316|      0|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (277:17): [True: 0, False: 0]
  ------------------
  278|      0|                goto error;
  279|      0|            }
  280|      0|        }
  281|      0|        tok = endp + 1;
  282|       |        /* If there is second @ character, this does not look like our URI */
  283|      0|        endp = strchr(tok, '@');
  284|      0|        if (endp != NULL) {
  ------------------
  |  Branch (284:13): [True: 0, False: 0]
  ------------------
  285|      0|            goto error;
  286|      0|        }
  287|      0|    }
  288|       |
  289|       |    /* Hostname */
  290|  17.2k|    if (*tok == '[') {
  ------------------
  |  Branch (290:9): [True: 0, False: 17.2k]
  ------------------
  291|       |        /* IPv6 address is enclosed with square brackets */
  292|      0|        tok++;
  293|      0|        endp = strchr(tok, ']');
  294|      0|        if (endp == NULL) {
  ------------------
  |  Branch (294:13): [True: 0, False: 0]
  ------------------
  295|      0|            goto error;
  296|      0|        }
  297|  17.2k|    } else if (!ignore_port) {
  ------------------
  |  Branch (297:16): [True: 0, False: 17.2k]
  ------------------
  298|       |        /* Hostnames or aliases expand to the last colon (if port is requested)
  299|       |         * or to the end */
  300|      0|        endp = strrchr(tok, ':');
  301|      0|        if (endp == NULL) {
  ------------------
  |  Branch (301:13): [True: 0, False: 0]
  ------------------
  302|      0|            endp = strchr(tok, '\0');
  303|      0|        }
  304|  17.2k|    } else {
  305|       |        /* If no port is requested, expand to the end of line
  306|       |         * (to accommodate the IPv6 addresses) */
  307|  17.2k|        endp = strchr(tok, '\0');
  308|  17.2k|    }
  309|  17.2k|    if (tok == endp) {
  ------------------
  |  Branch (309:9): [True: 0, False: 17.2k]
  ------------------
  310|       |        /* Zero-length hostnames are not valid */
  311|      0|        goto error;
  312|      0|    }
  313|  17.2k|    if (hostname != NULL) {
  ------------------
  |  Branch (313:9): [True: 17.2k, False: 0]
  ------------------
  314|  17.2k|        *hostname = strndup(tok, endp - tok);
  315|  17.2k|        if (*hostname == NULL) {
  ------------------
  |  Branch (315:13): [True: 0, False: 17.2k]
  ------------------
  316|      0|            goto error;
  317|      0|        }
  318|  17.2k|        if (strict) {
  ------------------
  |  Branch (318:13): [True: 8.64k, False: 8.64k]
  ------------------
  319|       |            /* if not an ip, check syntax */
  320|  8.64k|            rc = ssh_is_ipaddr(*hostname);
  321|  8.64k|            if (rc == 0) {
  ------------------
  |  Branch (321:17): [True: 8.64k, False: 0]
  ------------------
  322|  8.64k|                rc = ssh_check_hostname_syntax(*hostname);
  323|  8.64k|                if (rc != SSH_OK) {
  ------------------
  |  |  316|  8.64k|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (323:21): [True: 0, False: 8.64k]
  ------------------
  324|      0|                    goto error;
  325|      0|                }
  326|  8.64k|            }
  327|  8.64k|        } else {
  328|       |            /* Reject shell metacharacters to allow config aliases with
  329|       |             * non-RFC1035 chars (e.g. %, _). Modeled on OpenSSH's
  330|       |             * valid_hostname() in ssh.c. */
  331|  8.64k|            const char *c = NULL;
  332|  8.64k|            if ((*hostname)[0] == '-') {
  ------------------
  |  Branch (332:17): [True: 0, False: 8.64k]
  ------------------
  333|      0|                goto error;
  334|      0|            }
  335|  86.4k|            for (c = *hostname; *c != '\0'; c++) {
  ------------------
  |  Branch (335:33): [True: 77.7k, False: 8.64k]
  ------------------
  336|  77.7k|                const char *is_meta = strchr("'`\"$\\;&<>|(){},", *c);
  337|  77.7k|                int is_space = isspace((unsigned char)*c);
  338|  77.7k|                int is_ctrl = iscntrl((unsigned char)*c);
  339|  77.7k|                if (is_meta != NULL || is_space || is_ctrl) {
  ------------------
  |  Branch (339:21): [True: 0, False: 77.7k]
  |  Branch (339:40): [True: 0, False: 77.7k]
  |  Branch (339:52): [True: 0, False: 77.7k]
  ------------------
  340|      0|                    goto error;
  341|      0|                }
  342|  77.7k|            }
  343|  8.64k|        }
  344|  17.2k|    }
  345|       |    /* Skip also the closing bracket */
  346|  17.2k|    if (*endp == ']') {
  ------------------
  |  Branch (346:9): [True: 0, False: 17.2k]
  ------------------
  347|      0|        endp++;
  348|      0|    }
  349|       |
  350|       |    /* Port (optional) */
  351|  17.2k|    if (*endp != '\0') {
  ------------------
  |  Branch (351:9): [True: 0, False: 17.2k]
  ------------------
  352|      0|        char *port_end = NULL;
  353|       |
  354|       |        /* Verify the port is valid positive number */
  355|      0|        port_n = strtol(endp + 1, &port_end, 10);
  356|      0|        if (port_n < 1 || *port_end != '\0') {
  ------------------
  |  Branch (356:13): [True: 0, False: 0]
  |  Branch (356:27): [True: 0, False: 0]
  ------------------
  357|      0|            SSH_LOG(SSH_LOG_TRACE, "Failed to parse port number."
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  358|      0|                    " The value '%ld' is invalid or there are some"
  359|      0|                    " trailing characters: '%s'", port_n, port_end);
  360|      0|            goto error;
  361|      0|        }
  362|      0|        if (port != NULL) {
  ------------------
  |  Branch (362:13): [True: 0, False: 0]
  ------------------
  363|      0|            *port = strdup(endp + 1);
  364|      0|            if (*port == NULL) {
  ------------------
  |  Branch (364:17): [True: 0, False: 0]
  ------------------
  365|      0|                goto error;
  366|      0|            }
  367|      0|        }
  368|      0|    }
  369|       |
  370|  17.2k|    return SSH_OK;
  ------------------
  |  |  316|  17.2k|#define SSH_OK 0     /* No error */
  ------------------
  371|       |
  372|      0|error:
  373|      0|    if (username != NULL) {
  ------------------
  |  Branch (373:9): [True: 0, False: 0]
  ------------------
  374|      0|        SAFE_FREE(*username);
  ------------------
  |  |  373|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
  375|      0|    }
  376|      0|    if (hostname != NULL) {
  ------------------
  |  Branch (376:9): [True: 0, False: 0]
  ------------------
  377|      0|        SAFE_FREE(*hostname);
  ------------------
  |  |  373|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
  378|      0|    }
  379|      0|    if (port != NULL) {
  ------------------
  |  Branch (379:9): [True: 0, False: 0]
  ------------------
  380|      0|        SAFE_FREE(*port);
  ------------------
  |  |  373|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
  381|      0|    }
  382|      0|    return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  383|  17.2k|}

secure_memcmp:
   25|  88.3k|{
   26|  88.3k|    size_t i;
   27|  88.3k|    uint8_t status = 0;
   28|  88.3k|    const uint8_t *p1 = s1;
   29|  88.3k|    const uint8_t *p2 = s2;
   30|       |
   31|  2.38M|    for (i = 0; i < n; i++) {
  ------------------
  |  Branch (31:17): [True: 2.29M, False: 88.3k]
  ------------------
   32|  2.29M|        status |= (p1[i] ^ p2[i]);
   33|  2.29M|    }
   34|       |
   35|  88.3k|    return (status != 0);
   36|  88.3k|}

ssh_curve25519_create_k:
   52|  17.2k|{
   53|  17.2k|    int rc;
   54|       |
   55|       |#ifdef DEBUG_CRYPTO
   56|       |    ssh_log_hexdump("Session server cookie",
   57|       |                    session->next_crypto->server_kex.cookie,
   58|       |                    16);
   59|       |    ssh_log_hexdump("Session client cookie",
   60|       |                    session->next_crypto->client_kex.cookie,
   61|       |                    16);
   62|       |#endif
   63|       |
   64|  17.2k|    rc = curve25519_do_create_k(session, k);
   65|  17.2k|    return rc;
   66|  17.2k|}

ssh_curve25519_init:
   34|  17.2k|{
   35|  17.2k|    ssh_curve25519_pubkey *pubkey_loc = NULL;
   36|  17.2k|    EVP_PKEY_CTX *pctx = NULL;
   37|  17.2k|    EVP_PKEY *pkey = NULL;
   38|  17.2k|    size_t pubkey_len = CURVE25519_PUBKEY_SIZE;
  ------------------
  |  |   40|  17.2k|#define CURVE25519_PUBKEY_SIZE 32
  ------------------
   39|  17.2k|    int rc;
   40|       |
   41|  17.2k|    if (session->server) {
  ------------------
  |  Branch (41:9): [True: 8.64k, False: 8.64k]
  ------------------
   42|  8.64k|        pubkey_loc = &session->next_crypto->curve25519_server_pubkey;
   43|  8.64k|    } else {
   44|  8.64k|        pubkey_loc = &session->next_crypto->curve25519_client_pubkey;
   45|  8.64k|    }
   46|       |
   47|  17.2k|    pctx = EVP_PKEY_CTX_new_id(EVP_PKEY_X25519, NULL);
   48|  17.2k|    if (pctx == NULL) {
  ------------------
  |  Branch (48:9): [True: 0, False: 17.2k]
  ------------------
   49|      0|        SSH_LOG(SSH_LOG_TRACE,
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
   50|      0|                "Failed to initialize X25519 context: %s",
   51|      0|                ERR_error_string(ERR_get_error(), NULL));
   52|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
   53|      0|    }
   54|       |
   55|  17.2k|    rc = EVP_PKEY_keygen_init(pctx);
   56|  17.2k|    if (rc != 1) {
  ------------------
  |  Branch (56:9): [True: 0, False: 17.2k]
  ------------------
   57|      0|        SSH_LOG(SSH_LOG_TRACE,
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
   58|      0|                "Failed to initialize X25519 keygen: %s",
   59|      0|                ERR_error_string(ERR_get_error(), NULL));
   60|      0|        EVP_PKEY_CTX_free(pctx);
   61|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
   62|      0|    }
   63|       |
   64|  17.2k|    rc = EVP_PKEY_keygen(pctx, &pkey);
   65|  17.2k|    EVP_PKEY_CTX_free(pctx);
   66|  17.2k|    if (rc != 1) {
  ------------------
  |  Branch (66:9): [True: 0, False: 17.2k]
  ------------------
   67|      0|        SSH_LOG(SSH_LOG_TRACE,
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
   68|      0|                "Failed to generate X25519 keys: %s",
   69|      0|                ERR_error_string(ERR_get_error(), NULL));
   70|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
   71|      0|    }
   72|       |
   73|  17.2k|    rc = EVP_PKEY_get_raw_public_key(pkey, *pubkey_loc, &pubkey_len);
   74|  17.2k|    if (rc != 1) {
  ------------------
  |  Branch (74:9): [True: 0, False: 17.2k]
  ------------------
   75|      0|        SSH_LOG(SSH_LOG_TRACE,
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
   76|      0|                "Failed to get X25519 raw public key: %s",
   77|      0|                ERR_error_string(ERR_get_error(), NULL));
   78|      0|        EVP_PKEY_free(pkey);
   79|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
   80|      0|    }
   81|       |
   82|       |    /* Free any previously allocated privkey */
   83|  17.2k|    if (session->next_crypto->curve25519_privkey != NULL) {
  ------------------
  |  Branch (83:9): [True: 0, False: 17.2k]
  ------------------
   84|      0|        EVP_PKEY_free(session->next_crypto->curve25519_privkey);
   85|      0|        session->next_crypto->curve25519_privkey = NULL;
   86|      0|    }
   87|       |
   88|  17.2k|    session->next_crypto->curve25519_privkey = pkey;
   89|  17.2k|    pkey = NULL;
   90|       |
   91|  17.2k|    return SSH_OK;
  ------------------
  |  |  316|  17.2k|#define SSH_OK 0     /* No error */
  ------------------
   92|  17.2k|}
curve25519_do_create_k:
   95|  17.2k|{
   96|  17.2k|    ssh_curve25519_pubkey *peer_pubkey_loc = NULL;
   97|  17.2k|    int rc, ret = SSH_ERROR;
  ------------------
  |  |  317|  17.2k|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
   98|  17.2k|    EVP_PKEY_CTX *pctx = NULL;
   99|  17.2k|    EVP_PKEY *pkey = NULL, *pubkey = NULL;
  100|  17.2k|    size_t shared_key_len = CURVE25519_PUBKEY_SIZE;
  ------------------
  |  |   40|  17.2k|#define CURVE25519_PUBKEY_SIZE 32
  ------------------
  101|       |
  102|  17.2k|    if (session->server) {
  ------------------
  |  Branch (102:9): [True: 8.64k, False: 8.64k]
  ------------------
  103|  8.64k|        peer_pubkey_loc = &session->next_crypto->curve25519_client_pubkey;
  104|  8.64k|    } else {
  105|  8.64k|        peer_pubkey_loc = &session->next_crypto->curve25519_server_pubkey;
  106|  8.64k|    }
  107|       |
  108|  17.2k|    pkey = session->next_crypto->curve25519_privkey;
  109|  17.2k|    if (pkey == NULL) {
  ------------------
  |  Branch (109:9): [True: 0, False: 17.2k]
  ------------------
  110|      0|        SSH_LOG(SSH_LOG_TRACE,
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  111|      0|                "Failed to create X25519 EVP_PKEY: %s",
  112|      0|                ERR_error_string(ERR_get_error(), NULL));
  113|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  114|      0|    }
  115|       |
  116|  17.2k|    pctx = EVP_PKEY_CTX_new(pkey, NULL);
  117|  17.2k|    if (pctx == NULL) {
  ------------------
  |  Branch (117:9): [True: 0, False: 17.2k]
  ------------------
  118|      0|        SSH_LOG(SSH_LOG_TRACE,
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  119|      0|                "Failed to initialize X25519 context: %s",
  120|      0|                ERR_error_string(ERR_get_error(), NULL));
  121|      0|        goto out;
  122|      0|    }
  123|       |
  124|  17.2k|    rc = EVP_PKEY_derive_init(pctx);
  125|  17.2k|    if (rc != 1) {
  ------------------
  |  Branch (125:9): [True: 0, False: 17.2k]
  ------------------
  126|      0|        SSH_LOG(SSH_LOG_TRACE,
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  127|      0|                "Failed to initialize X25519 key derivation: %s",
  128|      0|                ERR_error_string(ERR_get_error(), NULL));
  129|      0|        goto out;
  130|      0|    }
  131|       |
  132|  17.2k|    pubkey = EVP_PKEY_new_raw_public_key(EVP_PKEY_X25519,
  133|  17.2k|                                         NULL,
  134|  17.2k|                                         *peer_pubkey_loc,
  135|  17.2k|                                         CURVE25519_PUBKEY_SIZE);
  ------------------
  |  |   40|  17.2k|#define CURVE25519_PUBKEY_SIZE 32
  ------------------
  136|  17.2k|    if (pubkey == NULL) {
  ------------------
  |  Branch (136:9): [True: 0, False: 17.2k]
  ------------------
  137|      0|        SSH_LOG(SSH_LOG_TRACE,
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  138|      0|                "Failed to create X25519 public key EVP_PKEY: %s",
  139|      0|                ERR_error_string(ERR_get_error(), NULL));
  140|      0|        goto out;
  141|      0|    }
  142|       |
  143|  17.2k|    rc = EVP_PKEY_derive_set_peer(pctx, pubkey);
  144|  17.2k|    if (rc != 1) {
  ------------------
  |  Branch (144:9): [True: 0, False: 17.2k]
  ------------------
  145|      0|        SSH_LOG(SSH_LOG_TRACE,
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  146|      0|                "Failed to set peer X25519 public key: %s",
  147|      0|                ERR_error_string(ERR_get_error(), NULL));
  148|      0|        goto out;
  149|      0|    }
  150|       |
  151|  17.2k|    rc = EVP_PKEY_derive(pctx, k, &shared_key_len);
  152|  17.2k|    if (rc != 1) {
  ------------------
  |  Branch (152:9): [True: 0, False: 17.2k]
  ------------------
  153|      0|        SSH_LOG(SSH_LOG_TRACE,
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  154|      0|                "Failed to derive X25519 shared secret: %s",
  155|      0|                ERR_error_string(ERR_get_error(), NULL));
  156|      0|        goto out;
  157|      0|    }
  158|  17.2k|    ret = SSH_OK;
  ------------------
  |  |  316|  17.2k|#define SSH_OK 0     /* No error */
  ------------------
  159|       |
  160|  17.2k|out:
  161|  17.2k|    EVP_PKEY_free(pubkey);
  162|  17.2k|    EVP_PKEY_CTX_free(pctx);
  163|  17.2k|    return ret;
  164|  17.2k|}

ssh_dh_init:
  235|      2|{
  236|      2|    unsigned long g_int = 2 ;	/* G is defined as 2 by the ssh2 standards */
  237|      2|    int rc;
  238|      2|    if (dh_crypto_initialized) {
  ------------------
  |  Branch (238:9): [True: 0, False: 2]
  ------------------
  239|      0|        return SSH_OK;
  ------------------
  |  |  316|      0|#define SSH_OK 0     /* No error */
  ------------------
  240|      0|    }
  241|      2|    dh_crypto_initialized = 1;
  242|       |
  243|      2|    ssh_dh_generator = bignum_new();
  ------------------
  |  |   70|      2|#define bignum_new() BN_new()
  ------------------
  244|      2|    if (ssh_dh_generator == NULL) {
  ------------------
  |  Branch (244:9): [True: 0, False: 2]
  ------------------
  245|      0|        goto error;
  246|      0|    }
  247|      2|    rc = bignum_set_word(ssh_dh_generator, g_int);
  ------------------
  |  |   77|      2|#define bignum_set_word(bn,n) BN_set_word(bn,n)
  ------------------
  248|      2|    if (rc != 1) {
  ------------------
  |  Branch (248:9): [True: 0, False: 2]
  ------------------
  249|      0|        goto error;
  250|      0|    }
  251|       |
  252|      2|    bignum_bin2bn(p_group1_value, P_GROUP1_LEN, &ssh_dh_group1);
  ------------------
  |  |   79|      2|    do {                                     \
  |  |   80|      2|        (*dest) = BN_new();                  \
  |  |   81|      2|        if ((*dest) != NULL) {               \
  |  |  ------------------
  |  |  |  Branch (81:13): [True: 2, False: 0]
  |  |  ------------------
  |  |   82|      2|            BN_bin2bn(data,datalen,(*dest)); \
  |  |   83|      2|        }                                    \
  |  |   84|      2|    } while(0)
  |  |  ------------------
  |  |  |  Branch (84:13): [Folded, False: 2]
  |  |  ------------------
  ------------------
  253|      2|    if (ssh_dh_group1 == NULL) {
  ------------------
  |  Branch (253:9): [True: 0, False: 2]
  ------------------
  254|      0|        goto error;
  255|      0|    }
  256|      2|    bignum_bin2bn(p_group14_value, P_GROUP14_LEN, &ssh_dh_group14);
  ------------------
  |  |   79|      2|    do {                                     \
  |  |   80|      2|        (*dest) = BN_new();                  \
  |  |   81|      2|        if ((*dest) != NULL) {               \
  |  |  ------------------
  |  |  |  Branch (81:13): [True: 2, False: 0]
  |  |  ------------------
  |  |   82|      2|            BN_bin2bn(data,datalen,(*dest)); \
  |  |   83|      2|        }                                    \
  |  |   84|      2|    } while(0)
  |  |  ------------------
  |  |  |  Branch (84:13): [Folded, False: 2]
  |  |  ------------------
  ------------------
  257|      2|    if (ssh_dh_group14 == NULL) {
  ------------------
  |  Branch (257:9): [True: 0, False: 2]
  ------------------
  258|      0|        goto error;
  259|      0|    }
  260|      2|    bignum_bin2bn(p_group16_value, P_GROUP16_LEN, &ssh_dh_group16);
  ------------------
  |  |   79|      2|    do {                                     \
  |  |   80|      2|        (*dest) = BN_new();                  \
  |  |   81|      2|        if ((*dest) != NULL) {               \
  |  |  ------------------
  |  |  |  Branch (81:13): [True: 2, False: 0]
  |  |  ------------------
  |  |   82|      2|            BN_bin2bn(data,datalen,(*dest)); \
  |  |   83|      2|        }                                    \
  |  |   84|      2|    } while(0)
  |  |  ------------------
  |  |  |  Branch (84:13): [Folded, False: 2]
  |  |  ------------------
  ------------------
  261|      2|    if (ssh_dh_group16 == NULL) {
  ------------------
  |  Branch (261:9): [True: 0, False: 2]
  ------------------
  262|      0|        goto error;
  263|      0|    }
  264|      2|    bignum_bin2bn(p_group18_value, P_GROUP18_LEN, &ssh_dh_group18);
  ------------------
  |  |   79|      2|    do {                                     \
  |  |   80|      2|        (*dest) = BN_new();                  \
  |  |   81|      2|        if ((*dest) != NULL) {               \
  |  |  ------------------
  |  |  |  Branch (81:13): [True: 2, False: 0]
  |  |  ------------------
  |  |   82|      2|            BN_bin2bn(data,datalen,(*dest)); \
  |  |   83|      2|        }                                    \
  |  |   84|      2|    } while(0)
  |  |  ------------------
  |  |  |  Branch (84:13): [Folded, False: 2]
  |  |  ------------------
  ------------------
  265|      2|    if (ssh_dh_group18 == NULL) {
  ------------------
  |  Branch (265:9): [True: 0, False: 2]
  ------------------
  266|      0|        goto error;
  267|      0|    }
  268|       |
  269|      2|    return 0;
  270|      0|error:
  271|      0|    ssh_dh_finalize();
  272|      0|    return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  273|      2|}
ssh_dh_import_next_pubkey_blob:
  295|  17.2k|{
  296|  17.2k|    return ssh_pki_import_pubkey_blob(pubkey_blob,
  297|  17.2k|                                      &session->next_crypto->server_pubkey);
  298|       |
  299|  17.2k|}
ssh_dh_get_next_server_publickey:
  676|  34.5k|{
  677|  34.5k|    return session->next_crypto->server_pubkey;
  678|  34.5k|}
ssh_dh_get_next_server_publickey_blob:
  683|  25.9k|{
  684|  25.9k|    const ssh_key pubkey = ssh_dh_get_next_server_publickey(session);
  685|       |
  686|  25.9k|    return ssh_pki_export_pubkey_blob(pubkey, pubkey_blob);
  687|  25.9k|}

ssh_dh_cleanup:
  449|  51.8k|{
  450|  51.8k|    if (crypto->dh_ctx != NULL) {
  ------------------
  |  Branch (450:9): [True: 0, False: 51.8k]
  ------------------
  451|      0|#if OPENSSL_VERSION_NUMBER < 0x30000000L
  452|      0|        DH_free(crypto->dh_ctx->keypair[0]);
  453|      0|        DH_free(crypto->dh_ctx->keypair[1]);
  454|       |#else
  455|       |        EVP_PKEY_free(crypto->dh_ctx->keypair[0]);
  456|       |        EVP_PKEY_free(crypto->dh_ctx->keypair[1]);
  457|       |#endif /* OPENSSL_VERSION_NUMBER */
  458|      0|        free(crypto->dh_ctx);
  459|       |        crypto->dh_ctx = NULL;
  460|      0|    }
  461|  51.8k|}

_ssh_set_error:
   55|  25.9k|{
   56|  25.9k|    struct ssh_common_struct *err = error;
   57|  25.9k|    va_list va;
   58|       |
   59|  25.9k|    va_start(va, descr);
   60|  25.9k|    vsnprintf(err->error.error_buffer, ERROR_BUFFERLEN, descr, va);
  ------------------
  |  |  219|  25.9k|#define ERROR_BUFFERLEN 1024
  ------------------
   61|  25.9k|    va_end(va);
   62|       |
   63|  25.9k|    err->error.error_code = code;
   64|  25.9k|    if (ssh_get_log_level() == SSH_LOG_TRACE) {
  ------------------
  |  |  363|  25.9k|#define SSH_LOG_TRACE 4
  ------------------
  |  Branch (64:9): [True: 0, False: 25.9k]
  ------------------
   65|      0|        ssh_log_function(SSH_LOG_TRACE,
  ------------------
  |  |  363|      0|#define SSH_LOG_TRACE 4
  ------------------
   66|      0|                         function,
   67|      0|                         err->error.error_buffer);
   68|      0|    }
   69|  25.9k|}
ssh_reset_error:
  113|  8.64k|{
  114|  8.64k|    struct ssh_common_struct *err = error;
  115|       |
  116|  8.64k|    ZERO_STRUCT(err->error.error_buffer);
  ------------------
  |  |  376|  8.64k|#define ZERO_STRUCT(x) memset(&(x), 0, sizeof(x))
  ------------------
  117|  8.64k|    err->error.error_code = 0;
  118|  8.64k|}
ssh_get_error:
  127|  17.2k|const char *ssh_get_error(void *error) {
  128|  17.2k|  struct error_struct *err = error;
  129|       |
  130|  17.2k|  return err->error_buffer;
  131|  17.2k|}

libcrux_ml_kem_mlkem768_portable_decapsulate:
 8039|  8.64k|    libcrux_ml_kem_mlkem768_MlKem768Ciphertext *ciphertext, uint8_t ret[32U]) {
 8040|  8.64k|  libcrux_ml_kem_ind_cca_instantiations_portable_decapsulate_35(
 8041|  8.64k|      private_key, ciphertext, ret);
 8042|  8.64k|}
libcrux_ml_kem_mlkem768_portable_encapsulate:
 8172|  8.64k|    uint8_t randomness[32U]) {
 8173|  8.64k|  return libcrux_ml_kem_ind_cca_instantiations_portable_encapsulate_cd(
 8174|  8.64k|      public_key, randomness);
 8175|  8.64k|}
libcrux_ml_kem_mlkem768_portable_generate_key_pair:
 8762|  8.64k|libcrux_ml_kem_mlkem768_portable_generate_key_pair(uint8_t randomness[64U]) {
 8763|  8.64k|  return libcrux_ml_kem_ind_cca_instantiations_portable_generate_keypair_ce(
 8764|  8.64k|      randomness);
 8765|  8.64k|}
libcrux_ml_kem_mlkem768_portable_validate_public_key:
 8876|  8.64k|    libcrux_ml_kem_types_MlKemPublicKey_30 *public_key) {
 8877|  8.64k|  return libcrux_ml_kem_ind_cca_instantiations_portable_validate_public_key_41(
 8878|  8.64k|      public_key->value);
 8879|  8.64k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_ind_cca_instantiations_portable_decapsulate_35:
 8026|  8.64k|    libcrux_ml_kem_mlkem768_MlKem768Ciphertext *ciphertext, uint8_t ret[32U]) {
 8027|  8.64k|  libcrux_ml_kem_ind_cca_decapsulate_62(private_key, ciphertext, ret);
 8028|  8.64k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_ind_cca_decapsulate_62:
 7937|  8.64k|    libcrux_ml_kem_mlkem768_MlKem768Ciphertext *ciphertext, uint8_t ret[32U]) {
 7938|  8.64k|  Eurydice_slice_uint8_t_x4 uu____0 =
 7939|  8.64k|      libcrux_ml_kem_types_unpack_private_key_b4(
 7940|  8.64k|          Eurydice_array_to_slice((size_t)2400U, private_key->value, uint8_t));
  ------------------
  |  |  204|  8.64k|  EURYDICE_SLICE(x, 0,                     \
  |  |  ------------------
  |  |  |  |  169|  8.64k|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|  8.64k|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  205|  8.64k|                 end) /* x is already at an array type, no need for cast */
  ------------------
 7941|  8.64k|  Eurydice_slice ind_cpa_secret_key = uu____0.fst;
 7942|  8.64k|  Eurydice_slice ind_cpa_public_key = uu____0.snd;
 7943|  8.64k|  Eurydice_slice ind_cpa_public_key_hash = uu____0.thd;
 7944|  8.64k|  Eurydice_slice implicit_rejection_value = uu____0.f3;
 7945|  8.64k|  uint8_t decrypted[32U];
 7946|  8.64k|  libcrux_ml_kem_ind_cpa_decrypt_42(ind_cpa_secret_key, ciphertext->value,
 7947|  8.64k|                                    decrypted);
 7948|  8.64k|  uint8_t to_hash0[64U];
 7949|  8.64k|  libcrux_ml_kem_utils_into_padded_array_24(
 7950|  8.64k|      Eurydice_array_to_slice((size_t)32U, decrypted, uint8_t), to_hash0);
  ------------------
  |  |  204|  8.64k|  EURYDICE_SLICE(x, 0,                     \
  |  |  ------------------
  |  |  |  |  169|  8.64k|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|  8.64k|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  205|  8.64k|                 end) /* x is already at an array type, no need for cast */
  ------------------
 7951|  8.64k|  Eurydice_slice_copy(
  ------------------
  |  |  229|  8.64k|  memcpy(dst.ptr, src.ptr, dst.len * sizeof(t))
  ------------------
 7952|  8.64k|      Eurydice_array_to_subslice_from(
 7953|  8.64k|          (size_t)64U, to_hash0, LIBCRUX_ML_KEM_CONSTANTS_SHARED_SECRET_SIZE,
 7954|  8.64k|          uint8_t, size_t, uint8_t[]),
 7955|  8.64k|      ind_cpa_public_key_hash, uint8_t);
 7956|  8.64k|  uint8_t hashed[64U];
 7957|  8.64k|  libcrux_ml_kem_hash_functions_portable_G_4a_e0(
 7958|  8.64k|      Eurydice_array_to_slice((size_t)64U, to_hash0, uint8_t), hashed);
  ------------------
  |  |  204|  8.64k|  EURYDICE_SLICE(x, 0,                     \
  |  |  ------------------
  |  |  |  |  169|  8.64k|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|  8.64k|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  205|  8.64k|                 end) /* x is already at an array type, no need for cast */
  ------------------
 7959|  8.64k|  Eurydice_slice_uint8_t_x2 uu____1 = Eurydice_slice_split_at(
  ------------------
  |  |  254|  8.64k|  KRML_CLITERAL(ret_t) {                                                  \
  |  |  ------------------
  |  |  |  |  154|  8.64k|#define KRML_CLITERAL(type) (type)
  |  |  ------------------
  |  |  255|  8.64k|    EURYDICE_CFIELD(.fst =)                                               \
  |  |  256|  8.64k|    EURYDICE_SLICE((element_type *)(slice).ptr, 0, mid),                  \
  |  |  ------------------
  |  |  |  |  169|  8.64k|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|  8.64k|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  257|  8.64k|        EURYDICE_CFIELD(.snd =)                                           \
  |  |  258|  8.64k|            EURYDICE_SLICE((element_type *)(slice).ptr, mid, (slice).len) \
  |  |  ------------------
  |  |  |  |  169|  8.64k|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|  8.64k|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  259|  8.64k|  }
  ------------------
 7960|  8.64k|      Eurydice_array_to_slice((size_t)64U, hashed, uint8_t),
 7961|  8.64k|      LIBCRUX_ML_KEM_CONSTANTS_SHARED_SECRET_SIZE, uint8_t,
 7962|  8.64k|      Eurydice_slice_uint8_t_x2);
 7963|  8.64k|  Eurydice_slice shared_secret0 = uu____1.fst;
 7964|  8.64k|  Eurydice_slice pseudorandomness = uu____1.snd;
 7965|  8.64k|  uint8_t to_hash[1120U];
 7966|  8.64k|  libcrux_ml_kem_utils_into_padded_array_15(implicit_rejection_value, to_hash);
 7967|  8.64k|  Eurydice_slice uu____2 = Eurydice_array_to_subslice_from(
  ------------------
  |  |  225|  8.64k|  EURYDICE_SLICE((t *)x, r, size)
  |  |  ------------------
  |  |  |  |  169|  8.64k|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|  8.64k|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 7968|  8.64k|      (size_t)1120U, to_hash, LIBCRUX_ML_KEM_CONSTANTS_SHARED_SECRET_SIZE,
 7969|  8.64k|      uint8_t, size_t, uint8_t[]);
 7970|  8.64k|  Eurydice_slice_copy(uu____2, libcrux_ml_kem_types_as_ref_d3_80(ciphertext),
  ------------------
  |  |  229|  8.64k|  memcpy(dst.ptr, src.ptr, dst.len * sizeof(t))
  ------------------
 7971|  8.64k|                      uint8_t);
 7972|  8.64k|  uint8_t implicit_rejection_shared_secret0[32U];
 7973|  8.64k|  libcrux_ml_kem_hash_functions_portable_PRF_4a_41(
 7974|  8.64k|      Eurydice_array_to_slice((size_t)1120U, to_hash, uint8_t),
  ------------------
  |  |  204|  8.64k|  EURYDICE_SLICE(x, 0,                     \
  |  |  ------------------
  |  |  |  |  169|  8.64k|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|  8.64k|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  205|  8.64k|                 end) /* x is already at an array type, no need for cast */
  ------------------
 7975|  8.64k|      implicit_rejection_shared_secret0);
 7976|  8.64k|  uint8_t expected_ciphertext[1088U];
 7977|  8.64k|  libcrux_ml_kem_ind_cpa_encrypt_2a(ind_cpa_public_key, decrypted,
 7978|  8.64k|                                    pseudorandomness, expected_ciphertext);
 7979|  8.64k|  uint8_t implicit_rejection_shared_secret[32U];
 7980|  8.64k|  libcrux_ml_kem_variant_kdf_39_d6(
 7981|  8.64k|      Eurydice_array_to_slice((size_t)32U, implicit_rejection_shared_secret0,
  ------------------
  |  |  204|  8.64k|  EURYDICE_SLICE(x, 0,                     \
  |  |  ------------------
  |  |  |  |  169|  8.64k|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|  8.64k|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  205|  8.64k|                 end) /* x is already at an array type, no need for cast */
  ------------------
 7982|  8.64k|                              uint8_t),
 7983|  8.64k|      libcrux_ml_kem_types_as_slice_a9_80(ciphertext),
 7984|  8.64k|      implicit_rejection_shared_secret);
 7985|  8.64k|  uint8_t shared_secret[32U];
 7986|  8.64k|  libcrux_ml_kem_variant_kdf_39_d6(
 7987|  8.64k|      shared_secret0, libcrux_ml_kem_types_as_slice_a9_80(ciphertext),
 7988|  8.64k|      shared_secret);
 7989|  8.64k|  uint8_t ret0[32U];
 7990|  8.64k|  libcrux_ml_kem_constant_time_ops_compare_ciphertexts_select_shared_secret_in_constant_time(
 7991|  8.64k|      libcrux_ml_kem_types_as_ref_d3_80(ciphertext),
 7992|  8.64k|      Eurydice_array_to_slice((size_t)1088U, expected_ciphertext, uint8_t),
  ------------------
  |  |  204|  8.64k|  EURYDICE_SLICE(x, 0,                     \
  |  |  ------------------
  |  |  |  |  169|  8.64k|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|  8.64k|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  205|  8.64k|                 end) /* x is already at an array type, no need for cast */
  ------------------
 7993|  8.64k|      Eurydice_array_to_slice((size_t)32U, shared_secret, uint8_t),
  ------------------
  |  |  204|  8.64k|  EURYDICE_SLICE(x, 0,                     \
  |  |  ------------------
  |  |  |  |  169|  8.64k|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|  8.64k|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  205|  8.64k|                 end) /* x is already at an array type, no need for cast */
  ------------------
 7994|  8.64k|      Eurydice_array_to_slice((size_t)32U, implicit_rejection_shared_secret,
  ------------------
  |  |  204|  8.64k|  EURYDICE_SLICE(x, 0,                     \
  |  |  ------------------
  |  |  |  |  169|  8.64k|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|  8.64k|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  205|  8.64k|                 end) /* x is already at an array type, no need for cast */
  ------------------
 7995|  8.64k|                              uint8_t),
 7996|  8.64k|      ret0);
 7997|  8.64k|  memcpy(ret, ret0, (size_t)32U * sizeof(uint8_t));
 7998|  8.64k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_types_unpack_private_key_b4:
  989|  8.64k|libcrux_ml_kem_types_unpack_private_key_b4(Eurydice_slice private_key) {
  990|  8.64k|  Eurydice_slice_uint8_t_x2 uu____0 = Eurydice_slice_split_at(
  ------------------
  |  |  254|  8.64k|  KRML_CLITERAL(ret_t) {                                                  \
  |  |  ------------------
  |  |  |  |  154|  8.64k|#define KRML_CLITERAL(type) (type)
  |  |  ------------------
  |  |  255|  8.64k|    EURYDICE_CFIELD(.fst =)                                               \
  |  |  256|  8.64k|    EURYDICE_SLICE((element_type *)(slice).ptr, 0, mid),                  \
  |  |  ------------------
  |  |  |  |  169|  8.64k|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|  8.64k|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  257|  8.64k|        EURYDICE_CFIELD(.snd =)                                           \
  |  |  258|  8.64k|            EURYDICE_SLICE((element_type *)(slice).ptr, mid, (slice).len) \
  |  |  ------------------
  |  |  |  |  169|  8.64k|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|  8.64k|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  259|  8.64k|  }
  ------------------
  991|  8.64k|      private_key, (size_t)1152U, uint8_t, Eurydice_slice_uint8_t_x2);
  992|  8.64k|  Eurydice_slice ind_cpa_secret_key = uu____0.fst;
  993|  8.64k|  Eurydice_slice secret_key0 = uu____0.snd;
  994|  8.64k|  Eurydice_slice_uint8_t_x2 uu____1 = Eurydice_slice_split_at(
  ------------------
  |  |  254|  8.64k|  KRML_CLITERAL(ret_t) {                                                  \
  |  |  ------------------
  |  |  |  |  154|  8.64k|#define KRML_CLITERAL(type) (type)
  |  |  ------------------
  |  |  255|  8.64k|    EURYDICE_CFIELD(.fst =)                                               \
  |  |  256|  8.64k|    EURYDICE_SLICE((element_type *)(slice).ptr, 0, mid),                  \
  |  |  ------------------
  |  |  |  |  169|  8.64k|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|  8.64k|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  257|  8.64k|        EURYDICE_CFIELD(.snd =)                                           \
  |  |  258|  8.64k|            EURYDICE_SLICE((element_type *)(slice).ptr, mid, (slice).len) \
  |  |  ------------------
  |  |  |  |  169|  8.64k|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|  8.64k|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  259|  8.64k|  }
  ------------------
  995|  8.64k|      secret_key0, (size_t)1184U, uint8_t, Eurydice_slice_uint8_t_x2);
  996|  8.64k|  Eurydice_slice ind_cpa_public_key = uu____1.fst;
  997|  8.64k|  Eurydice_slice secret_key = uu____1.snd;
  998|  8.64k|  Eurydice_slice_uint8_t_x2 uu____2 = Eurydice_slice_split_at(
  ------------------
  |  |  254|  8.64k|  KRML_CLITERAL(ret_t) {                                                  \
  |  |  ------------------
  |  |  |  |  154|  8.64k|#define KRML_CLITERAL(type) (type)
  |  |  ------------------
  |  |  255|  8.64k|    EURYDICE_CFIELD(.fst =)                                               \
  |  |  256|  8.64k|    EURYDICE_SLICE((element_type *)(slice).ptr, 0, mid),                  \
  |  |  ------------------
  |  |  |  |  169|  8.64k|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|  8.64k|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  257|  8.64k|        EURYDICE_CFIELD(.snd =)                                           \
  |  |  258|  8.64k|            EURYDICE_SLICE((element_type *)(slice).ptr, mid, (slice).len) \
  |  |  ------------------
  |  |  |  |  169|  8.64k|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|  8.64k|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  259|  8.64k|  }
  ------------------
  999|  8.64k|      secret_key, LIBCRUX_ML_KEM_CONSTANTS_H_DIGEST_SIZE, uint8_t,
 1000|  8.64k|      Eurydice_slice_uint8_t_x2);
 1001|  8.64k|  Eurydice_slice ind_cpa_public_key_hash = uu____2.fst;
 1002|  8.64k|  Eurydice_slice implicit_rejection_value = uu____2.snd;
 1003|  8.64k|  return (
 1004|  8.64k|      KRML_CLITERAL(Eurydice_slice_uint8_t_x4){.fst = ind_cpa_secret_key,
  ------------------
  |  |  154|  8.64k|#define KRML_CLITERAL(type) (type)
  ------------------
 1005|  8.64k|                                               .snd = ind_cpa_public_key,
 1006|  8.64k|                                               .thd = ind_cpa_public_key_hash,
 1007|  8.64k|                                               .f3 = implicit_rejection_value});
 1008|  8.64k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_ind_cpa_decrypt_42:
 6268|  8.64k|    Eurydice_slice secret_key, uint8_t *ciphertext, uint8_t ret[32U]) {
 6269|  8.64k|  libcrux_ml_kem_ind_cpa_unpacked_IndCpaPrivateKeyUnpacked_a0
 6270|  8.64k|      secret_key_unpacked;
 6271|  8.64k|  libcrux_ml_kem_polynomial_PolynomialRingElement_1d ret0[3U];
 6272|  34.5k|  for (size_t i = (size_t)0U; i < (size_t)3U; i++) {
  ------------------
  |  Branch (6272:31): [True: 25.9k, False: 8.64k]
  ------------------
 6273|       |    /* original Rust expression is not an lvalue in C */
 6274|  25.9k|    void *lvalue = (void *)0U;
 6275|  25.9k|    ret0[i] = libcrux_ml_kem_ind_cpa_decrypt_call_mut_0b_42(&lvalue, i);
 6276|  25.9k|  }
 6277|  8.64k|  memcpy(
 6278|  8.64k|      secret_key_unpacked.secret_as_ntt, ret0,
 6279|  8.64k|      (size_t)3U * sizeof(libcrux_ml_kem_polynomial_PolynomialRingElement_1d));
 6280|  8.64k|  libcrux_ml_kem_ind_cpa_deserialize_vector_1b(
 6281|  8.64k|      secret_key, secret_key_unpacked.secret_as_ntt);
 6282|  8.64k|  uint8_t ret1[32U];
 6283|  8.64k|  libcrux_ml_kem_ind_cpa_decrypt_unpacked_42(&secret_key_unpacked, ciphertext,
 6284|  8.64k|                                             ret1);
 6285|  8.64k|  memcpy(ret, ret1, (size_t)32U * sizeof(uint8_t));
 6286|  8.64k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_ind_cpa_decrypt_call_mut_0b_42:
 5348|  25.9k|libcrux_ml_kem_ind_cpa_decrypt_call_mut_0b_42(void **_, size_t tupled_args) {
 5349|  25.9k|  return libcrux_ml_kem_polynomial_ZERO_d6_ea();
 5350|  25.9k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_polynomial_ZERO_d6_ea:
 5317|   803k|libcrux_ml_kem_polynomial_ZERO_d6_ea(void) {
 5318|   803k|  libcrux_ml_kem_polynomial_PolynomialRingElement_1d lit;
 5319|   803k|  libcrux_ml_kem_vector_portable_vector_type_PortableVector
 5320|   803k|      repeat_expression[16U];
 5321|  13.6M|  for (size_t i = (size_t)0U; i < (size_t)16U; i++) {
  ------------------
  |  Branch (5321:31): [True: 12.8M, False: 803k]
  ------------------
 5322|  12.8M|    repeat_expression[i] = libcrux_ml_kem_vector_portable_ZERO_b8();
 5323|  12.8M|  }
 5324|   803k|  memcpy(lit.coefficients, repeat_expression,
 5325|   803k|         (size_t)16U *
 5326|   803k|             sizeof(libcrux_ml_kem_vector_portable_vector_type_PortableVector));
 5327|   803k|  return lit;
 5328|   803k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_vector_portable_ZERO_b8:
 3836|  24.3M|libcrux_ml_kem_vector_portable_ZERO_b8(void) {
 3837|  24.3M|  return libcrux_ml_kem_vector_portable_vector_type_zero();
 3838|  24.3M|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_vector_portable_vector_type_zero:
 3822|  29.5M|libcrux_ml_kem_vector_portable_vector_type_zero(void) {
 3823|  29.5M|  libcrux_ml_kem_vector_portable_vector_type_PortableVector lit;
 3824|  29.5M|  int16_t ret[16U];
 3825|  29.5M|  int16_t buf[16U] = {0U};
 3826|  29.5M|  libcrux_secrets_int_public_integers_classify_27_46(buf, ret);
 3827|  29.5M|  memcpy(lit.elements, ret, (size_t)16U * sizeof(int16_t));
 3828|  29.5M|  return lit;
 3829|  29.5M|}
libcrux_mlkem768_sha3.c:libcrux_secrets_int_public_integers_classify_27_46:
 1075|  29.5M|    int16_t self[16U], int16_t ret[16U]) {
 1076|  29.5M|  memcpy(ret, self, (size_t)16U * sizeof(int16_t));
 1077|  29.5M|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_ind_cpa_deserialize_vector_1b:
 5387|  8.64k|    libcrux_ml_kem_polynomial_PolynomialRingElement_1d *secret_as_ntt) {
 5388|  34.5k|  for (size_t i = (size_t)0U; i < (size_t)3U; i++) {
  ------------------
  |  Branch (5388:31): [True: 25.9k, False: 8.64k]
  ------------------
 5389|  25.9k|    size_t i0 = i;
 5390|  25.9k|    libcrux_ml_kem_polynomial_PolynomialRingElement_1d uu____0 =
 5391|  25.9k|        libcrux_ml_kem_serialize_deserialize_to_uncompressed_ring_element_ea(
 5392|  25.9k|            Eurydice_slice_subslice3(
  ------------------
  |  |  195|  25.9k|  EURYDICE_SLICE((t_ptr)s.ptr, (start), (end))
  |  |  ------------------
  |  |  |  |  169|  25.9k|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|  25.9k|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5393|  25.9k|                secret_key,
 5394|  25.9k|                i0 * LIBCRUX_ML_KEM_CONSTANTS_BYTES_PER_RING_ELEMENT,
 5395|  25.9k|                (i0 + (size_t)1U) *
 5396|  25.9k|                    LIBCRUX_ML_KEM_CONSTANTS_BYTES_PER_RING_ELEMENT,
 5397|  25.9k|                uint8_t *));
 5398|  25.9k|    secret_as_ntt[i0] = uu____0;
 5399|  25.9k|  }
 5400|  8.64k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_serialize_deserialize_to_uncompressed_ring_element_ea:
 5360|  25.9k|    Eurydice_slice serialized) {
 5361|  25.9k|  libcrux_ml_kem_polynomial_PolynomialRingElement_1d re =
 5362|  25.9k|      libcrux_ml_kem_polynomial_ZERO_d6_ea();
 5363|  25.9k|  for (size_t i = (size_t)0U;
 5364|   440k|       i < Eurydice_slice_len(serialized, uint8_t) / (size_t)24U; i++) {
  ------------------
  |  |  173|   440k|#define Eurydice_slice_len(s, _) (s).len
  ------------------
  |  Branch (5364:8): [True: 414k, False: 25.9k]
  ------------------
 5365|   414k|    size_t i0 = i;
 5366|   414k|    Eurydice_slice bytes =
 5367|   414k|        Eurydice_slice_subslice3(serialized, i0 * (size_t)24U,
  ------------------
  |  |  195|   414k|  EURYDICE_SLICE((t_ptr)s.ptr, (start), (end))
  |  |  ------------------
  |  |  |  |  169|   414k|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|   414k|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5368|   414k|                                 i0 * (size_t)24U + (size_t)24U, uint8_t *);
 5369|   414k|    libcrux_ml_kem_vector_portable_vector_type_PortableVector uu____0 =
 5370|   414k|        libcrux_ml_kem_vector_portable_deserialize_12_b8(bytes);
 5371|   414k|    re.coefficients[i0] = uu____0;
 5372|   414k|  }
 5373|  25.9k|  return re;
 5374|  25.9k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_vector_portable_deserialize_12_b8:
 5179|  1.65M|libcrux_ml_kem_vector_portable_deserialize_12_b8(Eurydice_slice a) {
 5180|  1.65M|  return libcrux_ml_kem_vector_portable_deserialize_12(a);
 5181|  1.65M|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_vector_portable_deserialize_12:
 5169|  1.65M|libcrux_ml_kem_vector_portable_deserialize_12(Eurydice_slice a) {
 5170|  1.65M|  return libcrux_ml_kem_vector_portable_serialize_deserialize_12(
 5171|  1.65M|      libcrux_secrets_int_classify_public_classify_ref_9b_90(a));
 5172|  1.65M|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_vector_portable_serialize_deserialize_12:
 5140|  1.65M|libcrux_ml_kem_vector_portable_serialize_deserialize_12(Eurydice_slice bytes) {
 5141|  1.65M|  int16_t_x2 v0_1 = libcrux_ml_kem_vector_portable_serialize_deserialize_12_int(
 5142|  1.65M|      Eurydice_slice_subslice3(bytes, (size_t)0U, (size_t)3U, uint8_t *));
  ------------------
  |  |  195|  1.65M|  EURYDICE_SLICE((t_ptr)s.ptr, (start), (end))
  |  |  ------------------
  |  |  |  |  169|  1.65M|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|  1.65M|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5143|  1.65M|  int16_t_x2 v2_3 = libcrux_ml_kem_vector_portable_serialize_deserialize_12_int(
 5144|  1.65M|      Eurydice_slice_subslice3(bytes, (size_t)3U, (size_t)6U, uint8_t *));
  ------------------
  |  |  195|  1.65M|  EURYDICE_SLICE((t_ptr)s.ptr, (start), (end))
  |  |  ------------------
  |  |  |  |  169|  1.65M|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|  1.65M|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5145|  1.65M|  int16_t_x2 v4_5 = libcrux_ml_kem_vector_portable_serialize_deserialize_12_int(
 5146|  1.65M|      Eurydice_slice_subslice3(bytes, (size_t)6U, (size_t)9U, uint8_t *));
  ------------------
  |  |  195|  1.65M|  EURYDICE_SLICE((t_ptr)s.ptr, (start), (end))
  |  |  ------------------
  |  |  |  |  169|  1.65M|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|  1.65M|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5147|  1.65M|  int16_t_x2 v6_7 = libcrux_ml_kem_vector_portable_serialize_deserialize_12_int(
 5148|  1.65M|      Eurydice_slice_subslice3(bytes, (size_t)9U, (size_t)12U, uint8_t *));
  ------------------
  |  |  195|  1.65M|  EURYDICE_SLICE((t_ptr)s.ptr, (start), (end))
  |  |  ------------------
  |  |  |  |  169|  1.65M|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|  1.65M|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5149|  1.65M|  int16_t_x2 v8_9 = libcrux_ml_kem_vector_portable_serialize_deserialize_12_int(
 5150|  1.65M|      Eurydice_slice_subslice3(bytes, (size_t)12U, (size_t)15U, uint8_t *));
  ------------------
  |  |  195|  1.65M|  EURYDICE_SLICE((t_ptr)s.ptr, (start), (end))
  |  |  ------------------
  |  |  |  |  169|  1.65M|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|  1.65M|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5151|  1.65M|  int16_t_x2 v10_11 =
 5152|  1.65M|      libcrux_ml_kem_vector_portable_serialize_deserialize_12_int(
 5153|  1.65M|          Eurydice_slice_subslice3(bytes, (size_t)15U, (size_t)18U, uint8_t *));
  ------------------
  |  |  195|  1.65M|  EURYDICE_SLICE((t_ptr)s.ptr, (start), (end))
  |  |  ------------------
  |  |  |  |  169|  1.65M|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|  1.65M|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5154|  1.65M|  int16_t_x2 v12_13 =
 5155|  1.65M|      libcrux_ml_kem_vector_portable_serialize_deserialize_12_int(
 5156|  1.65M|          Eurydice_slice_subslice3(bytes, (size_t)18U, (size_t)21U, uint8_t *));
  ------------------
  |  |  195|  1.65M|  EURYDICE_SLICE((t_ptr)s.ptr, (start), (end))
  |  |  ------------------
  |  |  |  |  169|  1.65M|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|  1.65M|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5157|  1.65M|  int16_t_x2 v14_15 =
 5158|  1.65M|      libcrux_ml_kem_vector_portable_serialize_deserialize_12_int(
 5159|  1.65M|          Eurydice_slice_subslice3(bytes, (size_t)21U, (size_t)24U, uint8_t *));
  ------------------
  |  |  195|  1.65M|  EURYDICE_SLICE((t_ptr)s.ptr, (start), (end))
  |  |  ------------------
  |  |  |  |  169|  1.65M|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|  1.65M|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5160|  1.65M|  return (
 5161|  1.65M|      KRML_CLITERAL(libcrux_ml_kem_vector_portable_vector_type_PortableVector){
  ------------------
  |  |  154|  1.65M|#define KRML_CLITERAL(type) (type)
  ------------------
 5162|  1.65M|          .elements = {v0_1.fst, v0_1.snd, v2_3.fst, v2_3.snd, v4_5.fst,
 5163|  1.65M|                       v4_5.snd, v6_7.fst, v6_7.snd, v8_9.fst, v8_9.snd,
 5164|  1.65M|                       v10_11.fst, v10_11.snd, v12_13.fst, v12_13.snd,
 5165|  1.65M|                       v14_15.fst, v14_15.snd}});
 5166|  1.65M|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_vector_portable_serialize_deserialize_12_int:
 5127|  13.2M|    Eurydice_slice bytes) {
 5128|  13.2M|  int16_t byte0 = libcrux_secrets_int_as_i16_59(
 5129|  13.2M|      Eurydice_slice_index(bytes, (size_t)0U, uint8_t, uint8_t *));
  ------------------
  |  |  180|  13.2M|#define Eurydice_slice_index(s, i, t, t_ptr_t) (((t_ptr_t)s.ptr)[i])
  ------------------
 5130|  13.2M|  int16_t byte1 = libcrux_secrets_int_as_i16_59(
 5131|  13.2M|      Eurydice_slice_index(bytes, (size_t)1U, uint8_t, uint8_t *));
  ------------------
  |  |  180|  13.2M|#define Eurydice_slice_index(s, i, t, t_ptr_t) (((t_ptr_t)s.ptr)[i])
  ------------------
 5132|  13.2M|  int16_t byte2 = libcrux_secrets_int_as_i16_59(
 5133|  13.2M|      Eurydice_slice_index(bytes, (size_t)2U, uint8_t, uint8_t *));
  ------------------
  |  |  180|  13.2M|#define Eurydice_slice_index(s, i, t, t_ptr_t) (((t_ptr_t)s.ptr)[i])
  ------------------
 5134|  13.2M|  int16_t r0 = (byte1 & (int16_t)15) << 8U | (byte0 & (int16_t)255);
 5135|  13.2M|  int16_t r1 = byte2 << 4U | (byte1 >> 4U & (int16_t)15);
 5136|  13.2M|  return (KRML_CLITERAL(int16_t_x2){.fst = r0, .snd = r1});
  ------------------
  |  |  154|  13.2M|#define KRML_CLITERAL(type) (type)
  ------------------
 5137|  13.2M|}
libcrux_mlkem768_sha3.c:libcrux_secrets_int_as_i16_59:
  535|  61.9M|static KRML_MUSTINLINE int16_t libcrux_secrets_int_as_i16_59(uint8_t self) {
  536|  61.9M|  return libcrux_secrets_int_public_integers_classify_27_39(
  537|  61.9M|      (int16_t)libcrux_secrets_int_public_integers_declassify_d8_90(self));
  538|  61.9M|}
libcrux_mlkem768_sha3.c:libcrux_secrets_int_public_integers_classify_27_39:
  515|  1.99G|libcrux_secrets_int_public_integers_classify_27_39(int16_t self) {
  516|  1.99G|  return self;
  517|  1.99G|}
libcrux_mlkem768_sha3.c:libcrux_secrets_int_public_integers_declassify_d8_90:
  528|  61.9M|libcrux_secrets_int_public_integers_declassify_d8_90(uint8_t self) {
  529|  61.9M|  return self;
  530|  61.9M|}
libcrux_mlkem768_sha3.c:libcrux_secrets_int_classify_public_classify_ref_9b_90:
 1089|  2.48M|libcrux_secrets_int_classify_public_classify_ref_9b_90(Eurydice_slice self) {
 1090|  2.48M|  return self;
 1091|  2.48M|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_ind_cpa_decrypt_unpacked_42:
 6241|  8.64k|    uint8_t *ciphertext, uint8_t ret[32U]) {
 6242|  8.64k|  libcrux_ml_kem_polynomial_PolynomialRingElement_1d u_as_ntt[3U];
 6243|  8.64k|  libcrux_ml_kem_ind_cpa_deserialize_then_decompress_u_6c(ciphertext, u_as_ntt);
 6244|  8.64k|  libcrux_ml_kem_polynomial_PolynomialRingElement_1d v =
 6245|  8.64k|      libcrux_ml_kem_serialize_deserialize_then_decompress_ring_element_v_89(
 6246|  8.64k|          Eurydice_array_to_subslice_from((size_t)1088U, ciphertext,
  ------------------
  |  |  225|  8.64k|  EURYDICE_SLICE((t *)x, r, size)
  |  |  ------------------
  |  |  |  |  169|  8.64k|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|  8.64k|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 6247|  8.64k|                                          (size_t)960U, uint8_t, size_t,
 6248|  8.64k|                                          uint8_t[]));
 6249|  8.64k|  libcrux_ml_kem_polynomial_PolynomialRingElement_1d message =
 6250|  8.64k|      libcrux_ml_kem_matrix_compute_message_1b(&v, secret_key->secret_as_ntt,
 6251|  8.64k|                                               u_as_ntt);
 6252|  8.64k|  uint8_t ret0[32U];
 6253|  8.64k|  libcrux_ml_kem_serialize_compress_then_serialize_message_ea(message, ret0);
 6254|  8.64k|  memcpy(ret, ret0, (size_t)32U * sizeof(uint8_t));
 6255|  8.64k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_ind_cpa_deserialize_then_decompress_u_6c:
 5694|  8.64k|    libcrux_ml_kem_polynomial_PolynomialRingElement_1d ret[3U]) {
 5695|  8.64k|  libcrux_ml_kem_polynomial_PolynomialRingElement_1d u_as_ntt[3U];
 5696|  34.5k|  for (size_t i = (size_t)0U; i < (size_t)3U; i++) {
  ------------------
  |  Branch (5696:31): [True: 25.9k, False: 8.64k]
  ------------------
 5697|       |    /* original Rust expression is not an lvalue in C */
 5698|  25.9k|    void *lvalue = (void *)0U;
 5699|  25.9k|    u_as_ntt[i] =
 5700|  25.9k|        libcrux_ml_kem_ind_cpa_deserialize_then_decompress_u_call_mut_35_6c(
 5701|  25.9k|            &lvalue, i);
 5702|  25.9k|  }
 5703|  8.64k|  for (size_t i = (size_t)0U;
 5704|  34.5k|       i < Eurydice_slice_len(
  ------------------
  |  |  173|  34.5k|#define Eurydice_slice_len(s, _) (s).len
  ------------------
  |  Branch (5704:8): [True: 25.9k, False: 8.64k]
  ------------------
 5705|  34.5k|               Eurydice_array_to_slice((size_t)1088U, ciphertext, uint8_t),
 5706|  34.5k|               uint8_t) /
 5707|  34.5k|               (LIBCRUX_ML_KEM_CONSTANTS_COEFFICIENTS_IN_RING_ELEMENT *
  ------------------
  |  |  447|  34.5k|#define LIBCRUX_ML_KEM_CONSTANTS_COEFFICIENTS_IN_RING_ELEMENT ((size_t)256U)
  ------------------
 5708|  34.5k|                (size_t)10U / (size_t)8U);
 5709|  25.9k|       i++) {
 5710|  25.9k|    size_t i0 = i;
 5711|  25.9k|    Eurydice_slice u_bytes = Eurydice_array_to_subslice3(
  ------------------
  |  |  215|  25.9k|  EURYDICE_SLICE((t_ptr)x, (start), (end))
  |  |  ------------------
  |  |  |  |  169|  25.9k|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|  25.9k|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5712|  25.9k|        ciphertext,
 5713|  25.9k|        i0 * (LIBCRUX_ML_KEM_CONSTANTS_COEFFICIENTS_IN_RING_ELEMENT *
 5714|  25.9k|              (size_t)10U / (size_t)8U),
 5715|  25.9k|        i0 * (LIBCRUX_ML_KEM_CONSTANTS_COEFFICIENTS_IN_RING_ELEMENT *
 5716|  25.9k|              (size_t)10U / (size_t)8U) +
 5717|  25.9k|            LIBCRUX_ML_KEM_CONSTANTS_COEFFICIENTS_IN_RING_ELEMENT *
 5718|  25.9k|                (size_t)10U / (size_t)8U,
 5719|  25.9k|        uint8_t *);
 5720|  25.9k|    u_as_ntt[i0] =
 5721|  25.9k|        libcrux_ml_kem_serialize_deserialize_then_decompress_ring_element_u_0a(
 5722|  25.9k|            u_bytes);
 5723|  25.9k|    libcrux_ml_kem_ntt_ntt_vector_u_0a(&u_as_ntt[i0]);
 5724|  25.9k|  }
 5725|  8.64k|  memcpy(
 5726|  8.64k|      ret, u_as_ntt,
 5727|  8.64k|      (size_t)3U * sizeof(libcrux_ml_kem_polynomial_PolynomialRingElement_1d));
 5728|  8.64k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_ind_cpa_deserialize_then_decompress_u_call_mut_35_6c:
 5419|  25.9k|    void **_, size_t tupled_args) {
 5420|  25.9k|  return libcrux_ml_kem_polynomial_ZERO_d6_ea();
 5421|  25.9k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_serialize_deserialize_then_decompress_ring_element_u_0a:
 5499|  25.9k|    Eurydice_slice serialized) {
 5500|  25.9k|  return libcrux_ml_kem_serialize_deserialize_then_decompress_10_ea(serialized);
 5501|  25.9k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_serialize_deserialize_then_decompress_10_ea:
 5472|  25.9k|    Eurydice_slice serialized) {
 5473|  25.9k|  libcrux_ml_kem_polynomial_PolynomialRingElement_1d re =
 5474|  25.9k|      libcrux_ml_kem_polynomial_ZERO_d6_ea();
 5475|  25.9k|  for (size_t i = (size_t)0U;
 5476|   440k|       i < Eurydice_slice_len(serialized, uint8_t) / (size_t)20U; i++) {
  ------------------
  |  |  173|   440k|#define Eurydice_slice_len(s, _) (s).len
  ------------------
  |  Branch (5476:8): [True: 414k, False: 25.9k]
  ------------------
 5477|   414k|    size_t i0 = i;
 5478|   414k|    Eurydice_slice bytes =
 5479|   414k|        Eurydice_slice_subslice3(serialized, i0 * (size_t)20U,
  ------------------
  |  |  195|   414k|  EURYDICE_SLICE((t_ptr)s.ptr, (start), (end))
  |  |  ------------------
  |  |  |  |  169|   414k|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|   414k|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5480|   414k|                                 i0 * (size_t)20U + (size_t)20U, uint8_t *);
 5481|   414k|    libcrux_ml_kem_vector_portable_vector_type_PortableVector coefficient =
 5482|   414k|        libcrux_ml_kem_vector_portable_deserialize_10_b8(bytes);
 5483|   414k|    libcrux_ml_kem_vector_portable_vector_type_PortableVector uu____0 =
 5484|   414k|        libcrux_ml_kem_vector_portable_decompress_ciphertext_coefficient_b8_ef(
 5485|   414k|            coefficient);
 5486|   414k|    re.coefficients[i0] = uu____0;
 5487|   414k|  }
 5488|  25.9k|  return re;
 5489|  25.9k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_vector_portable_deserialize_10_b8:
 5024|   414k|libcrux_ml_kem_vector_portable_deserialize_10_b8(Eurydice_slice a) {
 5025|   414k|  return libcrux_ml_kem_vector_portable_deserialize_10(a);
 5026|   414k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_vector_portable_deserialize_10:
 5014|   414k|libcrux_ml_kem_vector_portable_deserialize_10(Eurydice_slice a) {
 5015|   414k|  return libcrux_ml_kem_vector_portable_serialize_deserialize_10(
 5016|   414k|      libcrux_secrets_int_classify_public_classify_ref_9b_90(a));
 5017|   414k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_vector_portable_serialize_deserialize_10:
 5000|   414k|libcrux_ml_kem_vector_portable_serialize_deserialize_10(Eurydice_slice bytes) {
 5001|   414k|  int16_t_x8 v0_7 = libcrux_ml_kem_vector_portable_serialize_deserialize_10_int(
 5002|   414k|      Eurydice_slice_subslice3(bytes, (size_t)0U, (size_t)10U, uint8_t *));
  ------------------
  |  |  195|   414k|  EURYDICE_SLICE((t_ptr)s.ptr, (start), (end))
  |  |  ------------------
  |  |  |  |  169|   414k|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|   414k|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5003|   414k|  int16_t_x8 v8_15 =
 5004|   414k|      libcrux_ml_kem_vector_portable_serialize_deserialize_10_int(
 5005|   414k|          Eurydice_slice_subslice3(bytes, (size_t)10U, (size_t)20U, uint8_t *));
  ------------------
  |  |  195|   414k|  EURYDICE_SLICE((t_ptr)s.ptr, (start), (end))
  |  |  ------------------
  |  |  |  |  169|   414k|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|   414k|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5006|   414k|  return (
 5007|   414k|      KRML_CLITERAL(libcrux_ml_kem_vector_portable_vector_type_PortableVector){
  ------------------
  |  |  154|   414k|#define KRML_CLITERAL(type) (type)
  ------------------
 5008|   414k|          .elements = {v0_7.fst, v0_7.snd, v0_7.thd, v0_7.f3, v0_7.f4, v0_7.f5,
 5009|   414k|                       v0_7.f6, v0_7.f7, v8_15.fst, v8_15.snd, v8_15.thd,
 5010|   414k|                       v8_15.f3, v8_15.f4, v8_15.f5, v8_15.f6, v8_15.f7}});
 5011|   414k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_vector_portable_serialize_deserialize_10_int:
 4926|   829k|    Eurydice_slice bytes) {
 4927|   829k|  int16_t r0 = libcrux_secrets_int_as_i16_f5(
 4928|   829k|      (libcrux_secrets_int_as_i16_59(
 4929|   829k|           Eurydice_slice_index(bytes, (size_t)1U, uint8_t, uint8_t *)) &
  ------------------
  |  |  180|   829k|#define Eurydice_slice_index(s, i, t, t_ptr_t) (((t_ptr_t)s.ptr)[i])
  ------------------
 4930|   829k|       (int16_t)3)
 4931|   829k|          << 8U |
 4932|   829k|      (libcrux_secrets_int_as_i16_59(
 4933|   829k|           Eurydice_slice_index(bytes, (size_t)0U, uint8_t, uint8_t *)) &
  ------------------
  |  |  180|   829k|#define Eurydice_slice_index(s, i, t, t_ptr_t) (((t_ptr_t)s.ptr)[i])
  ------------------
 4934|   829k|       (int16_t)255));
 4935|   829k|  int16_t r1 = libcrux_secrets_int_as_i16_f5(
 4936|   829k|      (libcrux_secrets_int_as_i16_59(
 4937|   829k|           Eurydice_slice_index(bytes, (size_t)2U, uint8_t, uint8_t *)) &
  ------------------
  |  |  180|   829k|#define Eurydice_slice_index(s, i, t, t_ptr_t) (((t_ptr_t)s.ptr)[i])
  ------------------
 4938|   829k|       (int16_t)15)
 4939|   829k|          << 6U |
 4940|   829k|      libcrux_secrets_int_as_i16_59(
 4941|   829k|          Eurydice_slice_index(bytes, (size_t)1U, uint8_t, uint8_t *)) >>
  ------------------
  |  |  180|   829k|#define Eurydice_slice_index(s, i, t, t_ptr_t) (((t_ptr_t)s.ptr)[i])
  ------------------
 4942|   829k|          2U);
 4943|   829k|  int16_t r2 = libcrux_secrets_int_as_i16_f5(
 4944|   829k|      (libcrux_secrets_int_as_i16_59(
 4945|   829k|           Eurydice_slice_index(bytes, (size_t)3U, uint8_t, uint8_t *)) &
  ------------------
  |  |  180|   829k|#define Eurydice_slice_index(s, i, t, t_ptr_t) (((t_ptr_t)s.ptr)[i])
  ------------------
 4946|   829k|       (int16_t)63)
 4947|   829k|          << 4U |
 4948|   829k|      libcrux_secrets_int_as_i16_59(
 4949|   829k|          Eurydice_slice_index(bytes, (size_t)2U, uint8_t, uint8_t *)) >>
  ------------------
  |  |  180|   829k|#define Eurydice_slice_index(s, i, t, t_ptr_t) (((t_ptr_t)s.ptr)[i])
  ------------------
 4950|   829k|          4U);
 4951|   829k|  int16_t r3 = libcrux_secrets_int_as_i16_f5(
 4952|   829k|      libcrux_secrets_int_as_i16_59(
 4953|   829k|          Eurydice_slice_index(bytes, (size_t)4U, uint8_t, uint8_t *))
  ------------------
  |  |  180|   829k|#define Eurydice_slice_index(s, i, t, t_ptr_t) (((t_ptr_t)s.ptr)[i])
  ------------------
 4954|   829k|          << 2U |
 4955|   829k|      libcrux_secrets_int_as_i16_59(
 4956|   829k|          Eurydice_slice_index(bytes, (size_t)3U, uint8_t, uint8_t *)) >>
  ------------------
  |  |  180|   829k|#define Eurydice_slice_index(s, i, t, t_ptr_t) (((t_ptr_t)s.ptr)[i])
  ------------------
 4957|   829k|          6U);
 4958|   829k|  int16_t r4 = libcrux_secrets_int_as_i16_f5(
 4959|   829k|      (libcrux_secrets_int_as_i16_59(
 4960|   829k|           Eurydice_slice_index(bytes, (size_t)6U, uint8_t, uint8_t *)) &
  ------------------
  |  |  180|   829k|#define Eurydice_slice_index(s, i, t, t_ptr_t) (((t_ptr_t)s.ptr)[i])
  ------------------
 4961|   829k|       (int16_t)3)
 4962|   829k|          << 8U |
 4963|   829k|      (libcrux_secrets_int_as_i16_59(
 4964|   829k|           Eurydice_slice_index(bytes, (size_t)5U, uint8_t, uint8_t *)) &
  ------------------
  |  |  180|   829k|#define Eurydice_slice_index(s, i, t, t_ptr_t) (((t_ptr_t)s.ptr)[i])
  ------------------
 4965|   829k|       (int16_t)255));
 4966|   829k|  int16_t r5 = libcrux_secrets_int_as_i16_f5(
 4967|   829k|      (libcrux_secrets_int_as_i16_59(
 4968|   829k|           Eurydice_slice_index(bytes, (size_t)7U, uint8_t, uint8_t *)) &
  ------------------
  |  |  180|   829k|#define Eurydice_slice_index(s, i, t, t_ptr_t) (((t_ptr_t)s.ptr)[i])
  ------------------
 4969|   829k|       (int16_t)15)
 4970|   829k|          << 6U |
 4971|   829k|      libcrux_secrets_int_as_i16_59(
 4972|   829k|          Eurydice_slice_index(bytes, (size_t)6U, uint8_t, uint8_t *)) >>
  ------------------
  |  |  180|   829k|#define Eurydice_slice_index(s, i, t, t_ptr_t) (((t_ptr_t)s.ptr)[i])
  ------------------
 4973|   829k|          2U);
 4974|   829k|  int16_t r6 = libcrux_secrets_int_as_i16_f5(
 4975|   829k|      (libcrux_secrets_int_as_i16_59(
 4976|   829k|           Eurydice_slice_index(bytes, (size_t)8U, uint8_t, uint8_t *)) &
  ------------------
  |  |  180|   829k|#define Eurydice_slice_index(s, i, t, t_ptr_t) (((t_ptr_t)s.ptr)[i])
  ------------------
 4977|   829k|       (int16_t)63)
 4978|   829k|          << 4U |
 4979|   829k|      libcrux_secrets_int_as_i16_59(
 4980|   829k|          Eurydice_slice_index(bytes, (size_t)7U, uint8_t, uint8_t *)) >>
  ------------------
  |  |  180|   829k|#define Eurydice_slice_index(s, i, t, t_ptr_t) (((t_ptr_t)s.ptr)[i])
  ------------------
 4981|   829k|          4U);
 4982|   829k|  int16_t r7 = libcrux_secrets_int_as_i16_f5(
 4983|   829k|      libcrux_secrets_int_as_i16_59(
 4984|   829k|          Eurydice_slice_index(bytes, (size_t)9U, uint8_t, uint8_t *))
  ------------------
  |  |  180|   829k|#define Eurydice_slice_index(s, i, t, t_ptr_t) (((t_ptr_t)s.ptr)[i])
  ------------------
 4985|   829k|          << 2U |
 4986|   829k|      libcrux_secrets_int_as_i16_59(
 4987|   829k|          Eurydice_slice_index(bytes, (size_t)8U, uint8_t, uint8_t *)) >>
  ------------------
  |  |  180|   829k|#define Eurydice_slice_index(s, i, t, t_ptr_t) (((t_ptr_t)s.ptr)[i])
  ------------------
 4988|   829k|          6U);
 4989|   829k|  return (KRML_CLITERAL(int16_t_x8){.fst = r0,
  ------------------
  |  |  154|   829k|#define KRML_CLITERAL(type) (type)
  ------------------
 4990|   829k|                                    .snd = r1,
 4991|   829k|                                    .thd = r2,
 4992|   829k|                                    .f3 = r3,
 4993|   829k|                                    .f4 = r4,
 4994|   829k|                                    .f5 = r5,
 4995|   829k|                                    .f6 = r6,
 4996|   829k|                                    .f7 = r7});
 4997|   829k|}
libcrux_mlkem768_sha3.c:libcrux_secrets_int_as_i16_f5:
  711|  24.3M|static KRML_MUSTINLINE int16_t libcrux_secrets_int_as_i16_f5(int16_t self) {
  712|  24.3M|  return libcrux_secrets_int_public_integers_classify_27_39(
  713|  24.3M|      libcrux_secrets_int_public_integers_declassify_d8_39(self));
  714|  24.3M|}
libcrux_mlkem768_sha3.c:libcrux_secrets_int_public_integers_declassify_d8_39:
  494|  2.04G|libcrux_secrets_int_public_integers_declassify_d8_39(int16_t self) {
  495|  2.04G|  return self;
  496|  2.04G|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_vector_portable_decompress_ciphertext_coefficient_b8_ef:
 5459|   414k|    libcrux_ml_kem_vector_portable_vector_type_PortableVector a) {
 5460|   414k|  return libcrux_ml_kem_vector_portable_compress_decompress_ciphertext_coefficient_ef(
 5461|   414k|      a);
 5462|   414k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_vector_portable_compress_decompress_ciphertext_coefficient_ef:
 5431|   414k|    libcrux_ml_kem_vector_portable_vector_type_PortableVector a) {
 5432|   414k|  for (size_t i = (size_t)0U;
 5433|  7.05M|       i < LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_ELEMENTS_IN_VECTOR; i++) {
  ------------------
  |  | 3772|  7.05M|#define LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_ELEMENTS_IN_VECTOR ((size_t)16U)
  ------------------
  |  Branch (5433:8): [True: 6.63M, False: 414k]
  ------------------
 5434|  6.63M|    size_t i0 = i;
 5435|  6.63M|    int32_t decompressed =
 5436|  6.63M|        libcrux_secrets_int_as_i32_f5(a.elements[i0]) *
 5437|  6.63M|        libcrux_secrets_int_as_i32_f5(
 5438|  6.63M|            libcrux_secrets_int_public_integers_classify_27_39(
 5439|  6.63M|                LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_MODULUS));
  ------------------
  |  | 3777|  6.63M|#define LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_MODULUS ((int16_t)3329)
  ------------------
 5440|  6.63M|    decompressed = (decompressed << 1U) + ((int32_t)1 << (uint32_t)(int32_t)10);
 5441|  6.63M|    decompressed = decompressed >> (uint32_t)((int32_t)10 + (int32_t)1);
 5442|  6.63M|    a.elements[i0] = libcrux_secrets_int_as_i16_36(decompressed);
 5443|  6.63M|  }
 5444|   414k|  return a;
 5445|   414k|}
libcrux_mlkem768_sha3.c:libcrux_secrets_int_as_i32_f5:
  556|  1.91G|static KRML_MUSTINLINE int32_t libcrux_secrets_int_as_i32_f5(int16_t self) {
  557|  1.91G|  return libcrux_secrets_int_public_integers_classify_27_a8(
  558|  1.91G|      (int32_t)libcrux_secrets_int_public_integers_declassify_d8_39(self));
  559|  1.91G|}
libcrux_mlkem768_sha3.c:libcrux_secrets_int_public_integers_classify_27_a8:
  549|  2.23G|libcrux_secrets_int_public_integers_classify_27_a8(int32_t self) {
  550|  2.23G|  return self;
  551|  2.23G|}
libcrux_mlkem768_sha3.c:libcrux_secrets_int_as_i16_36:
  577|  1.43G|static KRML_MUSTINLINE int16_t libcrux_secrets_int_as_i16_36(int32_t self) {
  578|  1.43G|  return libcrux_secrets_int_public_integers_classify_27_39(
  579|  1.43G|      (int16_t)libcrux_secrets_int_public_integers_declassify_d8_a8(self));
  580|  1.43G|}
libcrux_mlkem768_sha3.c:libcrux_secrets_int_public_integers_declassify_d8_a8:
  570|  1.43G|libcrux_secrets_int_public_integers_declassify_d8_a8(int32_t self) {
  571|  1.43G|  return self;
  572|  1.43G|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_ntt_ntt_vector_u_0a:
 5663|  25.9k|    libcrux_ml_kem_polynomial_PolynomialRingElement_1d *re) {
 5664|  25.9k|  size_t zeta_i = (size_t)0U;
 5665|  25.9k|  libcrux_ml_kem_ntt_ntt_at_layer_4_plus_ea(&zeta_i, re, (size_t)7U,
 5666|  25.9k|                                            (size_t)3328U);
 5667|  25.9k|  libcrux_ml_kem_ntt_ntt_at_layer_4_plus_ea(&zeta_i, re, (size_t)6U,
 5668|  25.9k|                                            (size_t)2U * (size_t)3328U);
 5669|  25.9k|  libcrux_ml_kem_ntt_ntt_at_layer_4_plus_ea(&zeta_i, re, (size_t)5U,
 5670|  25.9k|                                            (size_t)3U * (size_t)3328U);
 5671|  25.9k|  libcrux_ml_kem_ntt_ntt_at_layer_4_plus_ea(&zeta_i, re, (size_t)4U,
 5672|  25.9k|                                            (size_t)4U * (size_t)3328U);
 5673|  25.9k|  libcrux_ml_kem_ntt_ntt_at_layer_3_ea(&zeta_i, re, (size_t)5U * (size_t)3328U);
 5674|  25.9k|  libcrux_ml_kem_ntt_ntt_at_layer_2_ea(&zeta_i, re, (size_t)6U * (size_t)3328U);
 5675|  25.9k|  libcrux_ml_kem_ntt_ntt_at_layer_1_ea(&zeta_i, re, (size_t)7U * (size_t)3328U);
 5676|  25.9k|  libcrux_ml_kem_polynomial_poly_barrett_reduce_d6_ea(re);
 5677|  25.9k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_ntt_ntt_at_layer_4_plus_ea:
 5538|   414k|    size_t layer, size_t _initial_coefficient_bound) {
 5539|   414k|  size_t step = (size_t)1U << (uint32_t)layer;
 5540|  2.25M|  for (size_t i0 = (size_t)0U; i0 < (size_t)128U >> (uint32_t)layer; i0++) {
  ------------------
  |  Branch (5540:32): [True: 1.84M, False: 414k]
  ------------------
 5541|  1.84M|    size_t round = i0;
 5542|  1.84M|    zeta_i[0U] = zeta_i[0U] + (size_t)1U;
 5543|  1.84M|    size_t offset = round * step * (size_t)2U;
 5544|  1.84M|    size_t offset_vec = offset / (size_t)16U;
 5545|  1.84M|    size_t step_vec = step / (size_t)16U;
 5546|  5.15M|    for (size_t i = offset_vec; i < offset_vec + step_vec; i++) {
  ------------------
  |  Branch (5546:33): [True: 3.31M, False: 1.84M]
  ------------------
 5547|  3.31M|      size_t j = i;
 5548|  3.31M|      libcrux_ml_kem_vector_portable_vector_type_PortableVector_x2 uu____0 =
 5549|  3.31M|          libcrux_ml_kem_ntt_ntt_layer_int_vec_step_ea(
 5550|  3.31M|              re->coefficients[j], re->coefficients[j + step_vec],
 5551|  3.31M|              libcrux_ml_kem_polynomial_zeta(zeta_i[0U]));
 5552|  3.31M|      libcrux_ml_kem_vector_portable_vector_type_PortableVector x = uu____0.fst;
 5553|  3.31M|      libcrux_ml_kem_vector_portable_vector_type_PortableVector y = uu____0.snd;
 5554|  3.31M|      re->coefficients[j] = x;
 5555|  3.31M|      re->coefficients[j + step_vec] = y;
 5556|  3.31M|    }
 5557|  1.84M|  }
 5558|   414k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_ntt_ntt_layer_int_vec_step_ea:
 5519|  3.31M|        int16_t zeta_r) {
 5520|  3.31M|  libcrux_ml_kem_vector_portable_vector_type_PortableVector t =
 5521|  3.31M|      libcrux_ml_kem_vector_portable_montgomery_multiply_by_constant_b8(b,
 5522|  3.31M|                                                                        zeta_r);
 5523|  3.31M|  b = libcrux_ml_kem_vector_portable_sub_b8(a, &t);
 5524|  3.31M|  a = libcrux_ml_kem_vector_portable_add_b8(a, &t);
 5525|  3.31M|  return (KRML_CLITERAL(
  ------------------
  |  |  154|  3.31M|#define KRML_CLITERAL(type) (type)
  ------------------
 5526|  3.31M|      libcrux_ml_kem_vector_portable_vector_type_PortableVector_x2){.fst = a,
 5527|  3.31M|                                                                    .snd = b});
 5528|  3.31M|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_vector_portable_montgomery_multiply_by_constant_b8:
 4077|  7.46M|    int16_t constant) {
 4078|  7.46M|  return libcrux_ml_kem_vector_portable_arithmetic_montgomery_multiply_by_constant(
 4079|  7.46M|      vector, libcrux_secrets_int_public_integers_classify_27_39(constant));
 4080|  7.46M|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_vector_portable_arithmetic_montgomery_multiply_by_constant:
 4059|  7.46M|    libcrux_ml_kem_vector_portable_vector_type_PortableVector vec, int16_t c) {
 4060|  7.46M|  for (size_t i = (size_t)0U;
 4061|   126M|       i < LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_ELEMENTS_IN_VECTOR; i++) {
  ------------------
  |  | 3772|   126M|#define LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_ELEMENTS_IN_VECTOR ((size_t)16U)
  ------------------
  |  Branch (4061:8): [True: 119M, False: 7.46M]
  ------------------
 4062|   119M|    size_t i0 = i;
 4063|   119M|    vec.elements[i0] =
 4064|   119M|        libcrux_ml_kem_vector_portable_arithmetic_montgomery_multiply_fe_by_fer(
 4065|   119M|            vec.elements[i0], c);
 4066|   119M|  }
 4067|  7.46M|  return vec;
 4068|  7.46M|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_vector_portable_arithmetic_montgomery_multiply_fe_by_fer:
 4050|   199M|    int16_t fe, int16_t fer) {
 4051|   199M|  int32_t product =
 4052|   199M|      libcrux_secrets_int_as_i32_f5(fe) * libcrux_secrets_int_as_i32_f5(fer);
 4053|   199M|  return libcrux_ml_kem_vector_portable_arithmetic_montgomery_reduce_element(
 4054|   199M|      product);
 4055|   199M|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_vector_portable_arithmetic_montgomery_reduce_element:
 4017|   318M|    int32_t value) {
 4018|   318M|  int32_t k =
 4019|   318M|      libcrux_secrets_int_as_i32_f5(libcrux_secrets_int_as_i16_36(value)) *
 4020|   318M|      libcrux_secrets_int_as_i32_b8(
 4021|   318M|          libcrux_secrets_int_public_integers_classify_27_df(
 4022|   318M|              LIBCRUX_ML_KEM_VECTOR_TRAITS_INVERSE_OF_MODULUS_MOD_MONTGOMERY_R));
  ------------------
  |  | 3780|   318M|  (62209U)
  ------------------
 4023|   318M|  int32_t k_times_modulus =
 4024|   318M|      libcrux_secrets_int_as_i32_f5(libcrux_secrets_int_as_i16_36(k)) *
 4025|   318M|      libcrux_secrets_int_as_i32_f5(
 4026|   318M|          libcrux_secrets_int_public_integers_classify_27_39(
 4027|   318M|              LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_MODULUS));
  ------------------
  |  | 3777|   318M|#define LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_MODULUS ((int16_t)3329)
  ------------------
 4028|   318M|  int16_t c = libcrux_secrets_int_as_i16_36(
 4029|   318M|      k_times_modulus >>
 4030|   318M|      (uint32_t)LIBCRUX_ML_KEM_VECTOR_PORTABLE_ARITHMETIC_MONTGOMERY_SHIFT);
  ------------------
  |  | 3997|   318M|#define LIBCRUX_ML_KEM_VECTOR_PORTABLE_ARITHMETIC_MONTGOMERY_SHIFT (16U)
  ------------------
 4031|   318M|  int16_t value_high = libcrux_secrets_int_as_i16_36(
 4032|   318M|      value >>
 4033|   318M|      (uint32_t)LIBCRUX_ML_KEM_VECTOR_PORTABLE_ARITHMETIC_MONTGOMERY_SHIFT);
  ------------------
  |  | 3997|   318M|#define LIBCRUX_ML_KEM_VECTOR_PORTABLE_ARITHMETIC_MONTGOMERY_SHIFT (16U)
  ------------------
 4034|   318M|  return value_high - c;
 4035|   318M|}
libcrux_mlkem768_sha3.c:libcrux_secrets_int_as_i32_b8:
  598|   318M|static KRML_MUSTINLINE int32_t libcrux_secrets_int_as_i32_b8(uint32_t self) {
  599|   318M|  return libcrux_secrets_int_public_integers_classify_27_a8(
  600|   318M|      (int32_t)libcrux_secrets_int_public_integers_declassify_d8_df(self));
  601|   318M|}
libcrux_mlkem768_sha3.c:libcrux_secrets_int_public_integers_declassify_d8_df:
  591|   336M|libcrux_secrets_int_public_integers_declassify_d8_df(uint32_t self) {
  592|   336M|  return self;
  593|   336M|}
libcrux_mlkem768_sha3.c:libcrux_secrets_int_public_integers_classify_27_df:
  675|   336M|libcrux_secrets_int_public_integers_classify_27_df(uint32_t self) {
  676|   336M|  return self;
  677|   336M|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_vector_portable_sub_b8:
 3884|  6.77M|    libcrux_ml_kem_vector_portable_vector_type_PortableVector *rhs) {
 3885|  6.77M|  return libcrux_ml_kem_vector_portable_arithmetic_sub(lhs, rhs);
 3886|  6.77M|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_vector_portable_arithmetic_sub:
 3867|  7.05M|    libcrux_ml_kem_vector_portable_vector_type_PortableVector *rhs) {
 3868|  7.05M|  for (size_t i = (size_t)0U;
 3869|   119M|       i < LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_ELEMENTS_IN_VECTOR; i++) {
  ------------------
  |  | 3772|   119M|#define LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_ELEMENTS_IN_VECTOR ((size_t)16U)
  ------------------
  |  Branch (3869:8): [True: 112M, False: 7.05M]
  ------------------
 3870|   112M|    size_t i0 = i;
 3871|   112M|    size_t uu____0 = i0;
 3872|   112M|    lhs.elements[uu____0] = lhs.elements[uu____0] - rhs->elements[i0];
 3873|   112M|  }
 3874|  7.05M|  return lhs;
 3875|  7.05M|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_vector_portable_add_b8:
 3860|  13.4M|    libcrux_ml_kem_vector_portable_vector_type_PortableVector *rhs) {
 3861|  13.4M|  return libcrux_ml_kem_vector_portable_arithmetic_add(lhs, rhs);
 3862|  13.4M|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_vector_portable_arithmetic_add:
 3843|  15.8M|    libcrux_ml_kem_vector_portable_vector_type_PortableVector *rhs) {
 3844|  15.8M|  for (size_t i = (size_t)0U;
 3845|   270M|       i < LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_ELEMENTS_IN_VECTOR; i++) {
  ------------------
  |  | 3772|   270M|#define LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_ELEMENTS_IN_VECTOR ((size_t)16U)
  ------------------
  |  Branch (3845:8): [True: 254M, False: 15.8M]
  ------------------
 3846|   254M|    size_t i0 = i;
 3847|   254M|    size_t uu____0 = i0;
 3848|   254M|    lhs.elements[uu____0] = lhs.elements[uu____0] + rhs->elements[i0];
 3849|   254M|  }
 3850|  15.8M|  return lhs;
 3851|  15.8M|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_polynomial_zeta:
 3766|  48.9M|static KRML_MUSTINLINE int16_t libcrux_ml_kem_polynomial_zeta(size_t i) {
 3767|  48.9M|  return libcrux_ml_kem_polynomial_ZETAS_TIMES_MONTGOMERY_R[i];
 3768|  48.9M|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_ntt_ntt_at_layer_3_ea:
 5568|   129k|    size_t _initial_coefficient_bound) {
 5569|  2.20M|  for (size_t i = (size_t)0U; i < (size_t)16U; i++) {
  ------------------
  |  Branch (5569:31): [True: 2.07M, False: 129k]
  ------------------
 5570|  2.07M|    size_t round = i;
 5571|  2.07M|    zeta_i[0U] = zeta_i[0U] + (size_t)1U;
 5572|  2.07M|    libcrux_ml_kem_vector_portable_vector_type_PortableVector uu____0 =
 5573|  2.07M|        libcrux_ml_kem_vector_portable_ntt_layer_3_step_b8(
 5574|  2.07M|            re->coefficients[round],
 5575|  2.07M|            libcrux_ml_kem_polynomial_zeta(zeta_i[0U]));
 5576|  2.07M|    re->coefficients[round] = uu____0;
 5577|  2.07M|  }
 5578|   129k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_vector_portable_ntt_layer_3_step_b8:
 4344|  2.07M|    libcrux_ml_kem_vector_portable_vector_type_PortableVector a, int16_t zeta) {
 4345|  2.07M|  return libcrux_ml_kem_vector_portable_ntt_ntt_layer_3_step(a, zeta);
 4346|  2.07M|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_vector_portable_ntt_ntt_layer_3_step:
 4318|  2.07M|    int16_t zeta) {
 4319|  2.07M|  libcrux_ml_kem_vector_portable_ntt_ntt_step(&vec, zeta, (size_t)0U,
 4320|  2.07M|                                              (size_t)8U);
 4321|  2.07M|  libcrux_ml_kem_vector_portable_ntt_ntt_step(&vec, zeta, (size_t)1U,
 4322|  2.07M|                                              (size_t)9U);
 4323|  2.07M|  libcrux_ml_kem_vector_portable_ntt_ntt_step(&vec, zeta, (size_t)2U,
 4324|  2.07M|                                              (size_t)10U);
 4325|  2.07M|  libcrux_ml_kem_vector_portable_ntt_ntt_step(&vec, zeta, (size_t)3U,
 4326|  2.07M|                                              (size_t)11U);
 4327|  2.07M|  libcrux_ml_kem_vector_portable_ntt_ntt_step(&vec, zeta, (size_t)4U,
 4328|  2.07M|                                              (size_t)12U);
 4329|  2.07M|  libcrux_ml_kem_vector_portable_ntt_ntt_step(&vec, zeta, (size_t)5U,
 4330|  2.07M|                                              (size_t)13U);
 4331|  2.07M|  libcrux_ml_kem_vector_portable_ntt_ntt_step(&vec, zeta, (size_t)6U,
 4332|  2.07M|                                              (size_t)14U);
 4333|  2.07M|  libcrux_ml_kem_vector_portable_ntt_ntt_step(&vec, zeta, (size_t)7U,
 4334|  2.07M|                                              (size_t)15U);
 4335|  2.07M|  return vec;
 4336|  2.07M|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_vector_portable_ntt_ntt_step:
 4235|  49.7M|    int16_t zeta, size_t i, size_t j) {
 4236|  49.7M|  int16_t t =
 4237|  49.7M|      libcrux_ml_kem_vector_portable_arithmetic_montgomery_multiply_fe_by_fer(
 4238|  49.7M|          vec->elements[j],
 4239|  49.7M|          libcrux_secrets_int_public_integers_classify_27_39(zeta));
 4240|  49.7M|  int16_t a_minus_t = vec->elements[i] - t;
 4241|  49.7M|  int16_t a_plus_t = vec->elements[i] + t;
 4242|  49.7M|  vec->elements[j] = a_minus_t;
 4243|  49.7M|  vec->elements[i] = a_plus_t;
 4244|  49.7M|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_ntt_ntt_at_layer_2_ea:
 5588|   129k|    size_t _initial_coefficient_bound) {
 5589|  2.20M|  for (size_t i = (size_t)0U; i < (size_t)16U; i++) {
  ------------------
  |  Branch (5589:31): [True: 2.07M, False: 129k]
  ------------------
 5590|  2.07M|    size_t round = i;
 5591|  2.07M|    zeta_i[0U] = zeta_i[0U] + (size_t)1U;
 5592|  2.07M|    re->coefficients[round] =
 5593|  2.07M|        libcrux_ml_kem_vector_portable_ntt_layer_2_step_b8(
 5594|  2.07M|            re->coefficients[round], libcrux_ml_kem_polynomial_zeta(zeta_i[0U]),
 5595|  2.07M|            libcrux_ml_kem_polynomial_zeta(zeta_i[0U] + (size_t)1U));
 5596|  2.07M|    zeta_i[0U] = zeta_i[0U] + (size_t)1U;
 5597|  2.07M|  }
 5598|   129k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_vector_portable_ntt_layer_2_step_b8:
 4311|  2.07M|    int16_t zeta1) {
 4312|  2.07M|  return libcrux_ml_kem_vector_portable_ntt_ntt_layer_2_step(a, zeta0, zeta1);
 4313|  2.07M|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_vector_portable_ntt_ntt_layer_2_step:
 4284|  2.07M|    int16_t zeta0, int16_t zeta1) {
 4285|  2.07M|  libcrux_ml_kem_vector_portable_ntt_ntt_step(&vec, zeta0, (size_t)0U,
 4286|  2.07M|                                              (size_t)4U);
 4287|  2.07M|  libcrux_ml_kem_vector_portable_ntt_ntt_step(&vec, zeta0, (size_t)1U,
 4288|  2.07M|                                              (size_t)5U);
 4289|  2.07M|  libcrux_ml_kem_vector_portable_ntt_ntt_step(&vec, zeta0, (size_t)2U,
 4290|  2.07M|                                              (size_t)6U);
 4291|  2.07M|  libcrux_ml_kem_vector_portable_ntt_ntt_step(&vec, zeta0, (size_t)3U,
 4292|  2.07M|                                              (size_t)7U);
 4293|  2.07M|  libcrux_ml_kem_vector_portable_ntt_ntt_step(&vec, zeta1, (size_t)8U,
 4294|  2.07M|                                              (size_t)12U);
 4295|  2.07M|  libcrux_ml_kem_vector_portable_ntt_ntt_step(&vec, zeta1, (size_t)9U,
 4296|  2.07M|                                              (size_t)13U);
 4297|  2.07M|  libcrux_ml_kem_vector_portable_ntt_ntt_step(&vec, zeta1, (size_t)10U,
 4298|  2.07M|                                              (size_t)14U);
 4299|  2.07M|  libcrux_ml_kem_vector_portable_ntt_ntt_step(&vec, zeta1, (size_t)11U,
 4300|  2.07M|                                              (size_t)15U);
 4301|  2.07M|  return vec;
 4302|  2.07M|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_ntt_ntt_at_layer_1_ea:
 5608|   129k|    size_t _initial_coefficient_bound) {
 5609|  2.20M|  for (size_t i = (size_t)0U; i < (size_t)16U; i++) {
  ------------------
  |  Branch (5609:31): [True: 2.07M, False: 129k]
  ------------------
 5610|  2.07M|    size_t round = i;
 5611|  2.07M|    zeta_i[0U] = zeta_i[0U] + (size_t)1U;
 5612|  2.07M|    re->coefficients[round] =
 5613|  2.07M|        libcrux_ml_kem_vector_portable_ntt_layer_1_step_b8(
 5614|  2.07M|            re->coefficients[round], libcrux_ml_kem_polynomial_zeta(zeta_i[0U]),
 5615|  2.07M|            libcrux_ml_kem_polynomial_zeta(zeta_i[0U] + (size_t)1U),
 5616|  2.07M|            libcrux_ml_kem_polynomial_zeta(zeta_i[0U] + (size_t)2U),
 5617|  2.07M|            libcrux_ml_kem_polynomial_zeta(zeta_i[0U] + (size_t)3U));
 5618|  2.07M|    zeta_i[0U] = zeta_i[0U] + (size_t)3U;
 5619|  2.07M|  }
 5620|   129k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_vector_portable_ntt_layer_1_step_b8:
 4276|  2.07M|    int16_t zeta1, int16_t zeta2, int16_t zeta3) {
 4277|  2.07M|  return libcrux_ml_kem_vector_portable_ntt_ntt_layer_1_step(a, zeta0, zeta1,
 4278|  2.07M|                                                             zeta2, zeta3);
 4279|  2.07M|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_vector_portable_ntt_ntt_layer_1_step:
 4249|  2.07M|    int16_t zeta0, int16_t zeta1, int16_t zeta2, int16_t zeta3) {
 4250|  2.07M|  libcrux_ml_kem_vector_portable_ntt_ntt_step(&vec, zeta0, (size_t)0U,
 4251|  2.07M|                                              (size_t)2U);
 4252|  2.07M|  libcrux_ml_kem_vector_portable_ntt_ntt_step(&vec, zeta0, (size_t)1U,
 4253|  2.07M|                                              (size_t)3U);
 4254|  2.07M|  libcrux_ml_kem_vector_portable_ntt_ntt_step(&vec, zeta1, (size_t)4U,
 4255|  2.07M|                                              (size_t)6U);
 4256|  2.07M|  libcrux_ml_kem_vector_portable_ntt_ntt_step(&vec, zeta1, (size_t)5U,
 4257|  2.07M|                                              (size_t)7U);
 4258|  2.07M|  libcrux_ml_kem_vector_portable_ntt_ntt_step(&vec, zeta2, (size_t)8U,
 4259|  2.07M|                                              (size_t)10U);
 4260|  2.07M|  libcrux_ml_kem_vector_portable_ntt_ntt_step(&vec, zeta2, (size_t)9U,
 4261|  2.07M|                                              (size_t)11U);
 4262|  2.07M|  libcrux_ml_kem_vector_portable_ntt_ntt_step(&vec, zeta3, (size_t)12U,
 4263|  2.07M|                                              (size_t)14U);
 4264|  2.07M|  libcrux_ml_kem_vector_portable_ntt_ntt_step(&vec, zeta3, (size_t)13U,
 4265|  2.07M|                                              (size_t)15U);
 4266|  2.07M|  return vec;
 4267|  2.07M|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_polynomial_poly_barrett_reduce_d6_ea:
 5652|   207k|    libcrux_ml_kem_polynomial_PolynomialRingElement_1d *self) {
 5653|   207k|  libcrux_ml_kem_polynomial_poly_barrett_reduce_ea(self);
 5654|   207k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_polynomial_poly_barrett_reduce_ea:
 5629|   207k|    libcrux_ml_kem_polynomial_PolynomialRingElement_1d *myself) {
 5630|   207k|  for (size_t i = (size_t)0U;
 5631|  3.52M|       i < LIBCRUX_ML_KEM_POLYNOMIAL_VECTORS_IN_RING_ELEMENT; i++) {
  ------------------
  |  | 3770|  3.52M|#define LIBCRUX_ML_KEM_POLYNOMIAL_VECTORS_IN_RING_ELEMENT ((size_t)16U)
  ------------------
  |  Branch (5631:8): [True: 3.31M, False: 207k]
  ------------------
 5632|  3.31M|    size_t i0 = i;
 5633|  3.31M|    libcrux_ml_kem_vector_portable_vector_type_PortableVector uu____0 =
 5634|  3.31M|        libcrux_ml_kem_vector_portable_barrett_reduce_b8(
 5635|  3.31M|            myself->coefficients[i0]);
 5636|  3.31M|    myself->coefficients[i0] = uu____0;
 5637|  3.31M|  }
 5638|   207k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_vector_portable_barrett_reduce_b8:
 3993|  7.46M|    libcrux_ml_kem_vector_portable_vector_type_PortableVector vector) {
 3994|  7.46M|  return libcrux_ml_kem_vector_portable_arithmetic_barrett_reduce(vector);
 3995|  7.46M|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_vector_portable_arithmetic_barrett_reduce:
 3975|  7.46M|    libcrux_ml_kem_vector_portable_vector_type_PortableVector vec) {
 3976|  7.46M|  for (size_t i = (size_t)0U;
 3977|   126M|       i < LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_ELEMENTS_IN_VECTOR; i++) {
  ------------------
  |  | 3772|   126M|#define LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_ELEMENTS_IN_VECTOR ((size_t)16U)
  ------------------
  |  Branch (3977:8): [True: 119M, False: 7.46M]
  ------------------
 3978|   119M|    size_t i0 = i;
 3979|   119M|    int16_t vi =
 3980|   119M|        libcrux_ml_kem_vector_portable_arithmetic_barrett_reduce_element(
 3981|   119M|            vec.elements[i0]);
 3982|   119M|    vec.elements[i0] = vi;
 3983|   119M|  }
 3984|  7.46M|  return vec;
 3985|  7.46M|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_vector_portable_arithmetic_barrett_reduce_element:
 3964|   149M|    int16_t value) {
 3965|   149M|  int32_t t = libcrux_secrets_int_as_i32_f5(value) *
 3966|   149M|                  LIBCRUX_ML_KEM_VECTOR_PORTABLE_ARITHMETIC_BARRETT_MULTIPLIER +
  ------------------
  |  | 3940|   149M|  ((int32_t)20159)
  ------------------
 3967|   149M|              (LIBCRUX_ML_KEM_VECTOR_TRAITS_BARRETT_R >> 1U);
  ------------------
  |  | 3945|   149M|  ((int32_t)1 << (uint32_t)LIBCRUX_ML_KEM_VECTOR_TRAITS_BARRETT_SHIFT)
  |  |  ------------------
  |  |  |  | 3942|   149M|#define LIBCRUX_ML_KEM_VECTOR_TRAITS_BARRETT_SHIFT ((int32_t)26)
  |  |  ------------------
  ------------------
 3968|   149M|  int16_t quotient = libcrux_secrets_int_as_i16_36(
 3969|   149M|      t >> (uint32_t)LIBCRUX_ML_KEM_VECTOR_TRAITS_BARRETT_SHIFT);
  ------------------
  |  | 3942|   149M|#define LIBCRUX_ML_KEM_VECTOR_TRAITS_BARRETT_SHIFT ((int32_t)26)
  ------------------
 3970|   149M|  return value - quotient * LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_MODULUS;
  ------------------
  |  | 3777|   149M|#define LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_MODULUS ((int16_t)3329)
  ------------------
 3971|   149M|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_serialize_deserialize_then_decompress_ring_element_v_89:
 5806|  8.64k|    Eurydice_slice serialized) {
 5807|  8.64k|  return libcrux_ml_kem_serialize_deserialize_then_decompress_4_ea(serialized);
 5808|  8.64k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_serialize_deserialize_then_decompress_4_ea:
 5779|  8.64k|    Eurydice_slice serialized) {
 5780|  8.64k|  libcrux_ml_kem_polynomial_PolynomialRingElement_1d re =
 5781|  8.64k|      libcrux_ml_kem_polynomial_ZERO_d6_ea();
 5782|  8.64k|  for (size_t i = (size_t)0U;
 5783|   146k|       i < Eurydice_slice_len(serialized, uint8_t) / (size_t)8U; i++) {
  ------------------
  |  |  173|   146k|#define Eurydice_slice_len(s, _) (s).len
  ------------------
  |  Branch (5783:8): [True: 138k, False: 8.64k]
  ------------------
 5784|   138k|    size_t i0 = i;
 5785|   138k|    Eurydice_slice bytes = Eurydice_slice_subslice3(
  ------------------
  |  |  195|   138k|  EURYDICE_SLICE((t_ptr)s.ptr, (start), (end))
  |  |  ------------------
  |  |  |  |  169|   138k|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|   138k|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5786|   138k|        serialized, i0 * (size_t)8U, i0 * (size_t)8U + (size_t)8U, uint8_t *);
 5787|   138k|    libcrux_ml_kem_vector_portable_vector_type_PortableVector coefficient =
 5788|   138k|        libcrux_ml_kem_vector_portable_deserialize_4_b8(bytes);
 5789|   138k|    libcrux_ml_kem_vector_portable_vector_type_PortableVector uu____0 =
 5790|   138k|        libcrux_ml_kem_vector_portable_decompress_ciphertext_coefficient_b8_d1(
 5791|   138k|            coefficient);
 5792|   138k|    re.coefficients[i0] = uu____0;
 5793|   138k|  }
 5794|  8.64k|  return re;
 5795|  8.64k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_vector_portable_deserialize_4_b8:
 4824|   138k|libcrux_ml_kem_vector_portable_deserialize_4_b8(Eurydice_slice a) {
 4825|   138k|  return libcrux_ml_kem_vector_portable_deserialize_4(a);
 4826|   138k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_vector_portable_deserialize_4:
 4814|   138k|libcrux_ml_kem_vector_portable_deserialize_4(Eurydice_slice a) {
 4815|   138k|  return libcrux_ml_kem_vector_portable_serialize_deserialize_4(
 4816|   138k|      libcrux_secrets_int_classify_public_classify_ref_9b_90(a));
 4817|   138k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_vector_portable_serialize_deserialize_4:
 4801|   138k|libcrux_ml_kem_vector_portable_serialize_deserialize_4(Eurydice_slice bytes) {
 4802|   138k|  int16_t_x8 v0_7 = libcrux_ml_kem_vector_portable_serialize_deserialize_4_int(
 4803|   138k|      Eurydice_slice_subslice3(bytes, (size_t)0U, (size_t)4U, uint8_t *));
  ------------------
  |  |  195|   138k|  EURYDICE_SLICE((t_ptr)s.ptr, (start), (end))
  |  |  ------------------
  |  |  |  |  169|   138k|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|   138k|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4804|   138k|  int16_t_x8 v8_15 = libcrux_ml_kem_vector_portable_serialize_deserialize_4_int(
 4805|   138k|      Eurydice_slice_subslice3(bytes, (size_t)4U, (size_t)8U, uint8_t *));
  ------------------
  |  |  195|   138k|  EURYDICE_SLICE((t_ptr)s.ptr, (start), (end))
  |  |  ------------------
  |  |  |  |  169|   138k|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|   138k|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4806|   138k|  return (
 4807|   138k|      KRML_CLITERAL(libcrux_ml_kem_vector_portable_vector_type_PortableVector){
  ------------------
  |  |  154|   138k|#define KRML_CLITERAL(type) (type)
  ------------------
 4808|   138k|          .elements = {v0_7.fst, v0_7.snd, v0_7.thd, v0_7.f3, v0_7.f4, v0_7.f5,
 4809|   138k|                       v0_7.f6, v0_7.f7, v8_15.fst, v8_15.snd, v8_15.thd,
 4810|   138k|                       v8_15.f3, v8_15.f4, v8_15.f5, v8_15.f6, v8_15.f7}});
 4811|   138k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_vector_portable_serialize_deserialize_4_int:
 4761|   276k|    Eurydice_slice bytes) {
 4762|   276k|  int16_t v0 = libcrux_secrets_int_as_i16_59(
 4763|   276k|      (uint32_t)Eurydice_slice_index(bytes, (size_t)0U, uint8_t, uint8_t *) &
  ------------------
  |  |  180|   276k|#define Eurydice_slice_index(s, i, t, t_ptr_t) (((t_ptr_t)s.ptr)[i])
  ------------------
 4764|   276k|      15U);
 4765|   276k|  int16_t v1 = libcrux_secrets_int_as_i16_59(
 4766|   276k|      (uint32_t)Eurydice_slice_index(bytes, (size_t)0U, uint8_t, uint8_t *) >>
  ------------------
  |  |  180|   276k|#define Eurydice_slice_index(s, i, t, t_ptr_t) (((t_ptr_t)s.ptr)[i])
  ------------------
 4767|   276k|          4U &
 4768|   276k|      15U);
 4769|   276k|  int16_t v2 = libcrux_secrets_int_as_i16_59(
 4770|   276k|      (uint32_t)Eurydice_slice_index(bytes, (size_t)1U, uint8_t, uint8_t *) &
  ------------------
  |  |  180|   276k|#define Eurydice_slice_index(s, i, t, t_ptr_t) (((t_ptr_t)s.ptr)[i])
  ------------------
 4771|   276k|      15U);
 4772|   276k|  int16_t v3 = libcrux_secrets_int_as_i16_59(
 4773|   276k|      (uint32_t)Eurydice_slice_index(bytes, (size_t)1U, uint8_t, uint8_t *) >>
  ------------------
  |  |  180|   276k|#define Eurydice_slice_index(s, i, t, t_ptr_t) (((t_ptr_t)s.ptr)[i])
  ------------------
 4774|   276k|          4U &
 4775|   276k|      15U);
 4776|   276k|  int16_t v4 = libcrux_secrets_int_as_i16_59(
 4777|   276k|      (uint32_t)Eurydice_slice_index(bytes, (size_t)2U, uint8_t, uint8_t *) &
  ------------------
  |  |  180|   276k|#define Eurydice_slice_index(s, i, t, t_ptr_t) (((t_ptr_t)s.ptr)[i])
  ------------------
 4778|   276k|      15U);
 4779|   276k|  int16_t v5 = libcrux_secrets_int_as_i16_59(
 4780|   276k|      (uint32_t)Eurydice_slice_index(bytes, (size_t)2U, uint8_t, uint8_t *) >>
  ------------------
  |  |  180|   276k|#define Eurydice_slice_index(s, i, t, t_ptr_t) (((t_ptr_t)s.ptr)[i])
  ------------------
 4781|   276k|          4U &
 4782|   276k|      15U);
 4783|   276k|  int16_t v6 = libcrux_secrets_int_as_i16_59(
 4784|   276k|      (uint32_t)Eurydice_slice_index(bytes, (size_t)3U, uint8_t, uint8_t *) &
  ------------------
  |  |  180|   276k|#define Eurydice_slice_index(s, i, t, t_ptr_t) (((t_ptr_t)s.ptr)[i])
  ------------------
 4785|   276k|      15U);
 4786|   276k|  int16_t v7 = libcrux_secrets_int_as_i16_59(
 4787|   276k|      (uint32_t)Eurydice_slice_index(bytes, (size_t)3U, uint8_t, uint8_t *) >>
  ------------------
  |  |  180|   276k|#define Eurydice_slice_index(s, i, t, t_ptr_t) (((t_ptr_t)s.ptr)[i])
  ------------------
 4788|   276k|          4U &
 4789|   276k|      15U);
 4790|   276k|  return (KRML_CLITERAL(int16_t_x8){.fst = v0,
  ------------------
  |  |  154|   276k|#define KRML_CLITERAL(type) (type)
  ------------------
 4791|   276k|                                    .snd = v1,
 4792|   276k|                                    .thd = v2,
 4793|   276k|                                    .f3 = v3,
 4794|   276k|                                    .f4 = v4,
 4795|   276k|                                    .f5 = v5,
 4796|   276k|                                    .f6 = v6,
 4797|   276k|                                    .f7 = v7});
 4798|   276k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_vector_portable_decompress_ciphertext_coefficient_b8_d1:
 5766|   138k|    libcrux_ml_kem_vector_portable_vector_type_PortableVector a) {
 5767|   138k|  return libcrux_ml_kem_vector_portable_compress_decompress_ciphertext_coefficient_d1(
 5768|   138k|      a);
 5769|   138k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_vector_portable_compress_decompress_ciphertext_coefficient_d1:
 5738|   138k|    libcrux_ml_kem_vector_portable_vector_type_PortableVector a) {
 5739|   138k|  for (size_t i = (size_t)0U;
 5740|  2.35M|       i < LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_ELEMENTS_IN_VECTOR; i++) {
  ------------------
  |  | 3772|  2.35M|#define LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_ELEMENTS_IN_VECTOR ((size_t)16U)
  ------------------
  |  Branch (5740:8): [True: 2.21M, False: 138k]
  ------------------
 5741|  2.21M|    size_t i0 = i;
 5742|  2.21M|    int32_t decompressed =
 5743|  2.21M|        libcrux_secrets_int_as_i32_f5(a.elements[i0]) *
 5744|  2.21M|        libcrux_secrets_int_as_i32_f5(
 5745|  2.21M|            libcrux_secrets_int_public_integers_classify_27_39(
 5746|  2.21M|                LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_MODULUS));
  ------------------
  |  | 3777|  2.21M|#define LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_MODULUS ((int16_t)3329)
  ------------------
 5747|  2.21M|    decompressed = (decompressed << 1U) + ((int32_t)1 << (uint32_t)(int32_t)4);
 5748|  2.21M|    decompressed = decompressed >> (uint32_t)((int32_t)4 + (int32_t)1);
 5749|  2.21M|    a.elements[i0] = libcrux_secrets_int_as_i16_36(decompressed);
 5750|  2.21M|  }
 5751|   138k|  return a;
 5752|   138k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_matrix_compute_message_1b:
 6150|  8.64k|    libcrux_ml_kem_polynomial_PolynomialRingElement_1d *u_as_ntt) {
 6151|  8.64k|  libcrux_ml_kem_polynomial_PolynomialRingElement_1d result =
 6152|  8.64k|      libcrux_ml_kem_polynomial_ZERO_d6_ea();
 6153|  34.5k|  for (size_t i = (size_t)0U; i < (size_t)3U; i++) {
  ------------------
  |  Branch (6153:31): [True: 25.9k, False: 8.64k]
  ------------------
 6154|  25.9k|    size_t i0 = i;
 6155|  25.9k|    libcrux_ml_kem_polynomial_PolynomialRingElement_1d product =
 6156|  25.9k|        libcrux_ml_kem_polynomial_ntt_multiply_d6_ea(&secret_as_ntt[i0],
 6157|  25.9k|                                                     &u_as_ntt[i0]);
 6158|  25.9k|    libcrux_ml_kem_polynomial_add_to_ring_element_d6_1b(&result, &product);
 6159|  25.9k|  }
 6160|  8.64k|  libcrux_ml_kem_invert_ntt_invert_ntt_montgomery_1b(&result);
 6161|  8.64k|  return libcrux_ml_kem_polynomial_subtract_reduce_d6_ea(v, result);
 6162|  8.64k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_polynomial_ntt_multiply_d6_ea:
 5901|   311k|    libcrux_ml_kem_polynomial_PolynomialRingElement_1d *rhs) {
 5902|   311k|  return libcrux_ml_kem_polynomial_ntt_multiply_ea(self, rhs);
 5903|   311k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_polynomial_ntt_multiply_ea:
 5866|   311k|    libcrux_ml_kem_polynomial_PolynomialRingElement_1d *rhs) {
 5867|   311k|  libcrux_ml_kem_polynomial_PolynomialRingElement_1d out =
 5868|   311k|      libcrux_ml_kem_polynomial_ZERO_ea();
 5869|   311k|  for (size_t i = (size_t)0U;
 5870|  5.28M|       i < LIBCRUX_ML_KEM_POLYNOMIAL_VECTORS_IN_RING_ELEMENT; i++) {
  ------------------
  |  | 3770|  5.28M|#define LIBCRUX_ML_KEM_POLYNOMIAL_VECTORS_IN_RING_ELEMENT ((size_t)16U)
  ------------------
  |  Branch (5870:8): [True: 4.97M, False: 311k]
  ------------------
 5871|  4.97M|    size_t i0 = i;
 5872|  4.97M|    libcrux_ml_kem_vector_portable_vector_type_PortableVector uu____0 =
 5873|  4.97M|        libcrux_ml_kem_vector_portable_ntt_multiply_b8(
 5874|  4.97M|            &myself->coefficients[i0], &rhs->coefficients[i0],
 5875|  4.97M|            libcrux_ml_kem_polynomial_zeta((size_t)64U + (size_t)4U * i0),
 5876|  4.97M|            libcrux_ml_kem_polynomial_zeta((size_t)64U + (size_t)4U * i0 +
 5877|  4.97M|                                           (size_t)1U),
 5878|  4.97M|            libcrux_ml_kem_polynomial_zeta((size_t)64U + (size_t)4U * i0 +
 5879|  4.97M|                                           (size_t)2U),
 5880|  4.97M|            libcrux_ml_kem_polynomial_zeta((size_t)64U + (size_t)4U * i0 +
 5881|  4.97M|                                           (size_t)3U));
 5882|  4.97M|    out.coefficients[i0] = uu____0;
 5883|  4.97M|  }
 5884|   311k|  return out;
 5885|   311k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_polynomial_ZERO_ea:
 5817|   717k|libcrux_ml_kem_polynomial_ZERO_ea(void) {
 5818|   717k|  libcrux_ml_kem_polynomial_PolynomialRingElement_1d lit;
 5819|   717k|  libcrux_ml_kem_vector_portable_vector_type_PortableVector
 5820|   717k|      repeat_expression[16U];
 5821|  12.1M|  for (size_t i = (size_t)0U; i < (size_t)16U; i++) {
  ------------------
  |  Branch (5821:31): [True: 11.4M, False: 717k]
  ------------------
 5822|  11.4M|    repeat_expression[i] = libcrux_ml_kem_vector_portable_ZERO_b8();
 5823|  11.4M|  }
 5824|   717k|  memcpy(lit.coefficients, repeat_expression,
 5825|   717k|         (size_t)16U *
 5826|   717k|             sizeof(libcrux_ml_kem_vector_portable_vector_type_PortableVector));
 5827|   717k|  return lit;
 5828|   717k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_vector_portable_ntt_multiply_b8:
 4567|  4.97M|    int16_t zeta0, int16_t zeta1, int16_t zeta2, int16_t zeta3) {
 4568|  4.97M|  return libcrux_ml_kem_vector_portable_ntt_ntt_multiply(lhs, rhs, zeta0, zeta1,
 4569|  4.97M|                                                         zeta2, zeta3);
 4570|  4.97M|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_vector_portable_ntt_ntt_multiply:
 4525|  4.97M|    int16_t zeta0, int16_t zeta1, int16_t zeta2, int16_t zeta3) {
 4526|  4.97M|  int16_t nzeta0 = -zeta0;
 4527|  4.97M|  int16_t nzeta1 = -zeta1;
 4528|  4.97M|  int16_t nzeta2 = -zeta2;
 4529|  4.97M|  int16_t nzeta3 = -zeta3;
 4530|  4.97M|  libcrux_ml_kem_vector_portable_vector_type_PortableVector out =
 4531|  4.97M|      libcrux_ml_kem_vector_portable_vector_type_zero();
 4532|  4.97M|  libcrux_ml_kem_vector_portable_ntt_ntt_multiply_binomials(
 4533|  4.97M|      lhs, rhs, libcrux_secrets_int_public_integers_classify_27_39(zeta0),
 4534|  4.97M|      (size_t)0U, &out);
 4535|  4.97M|  libcrux_ml_kem_vector_portable_ntt_ntt_multiply_binomials(
 4536|  4.97M|      lhs, rhs, libcrux_secrets_int_public_integers_classify_27_39(nzeta0),
 4537|  4.97M|      (size_t)1U, &out);
 4538|  4.97M|  libcrux_ml_kem_vector_portable_ntt_ntt_multiply_binomials(
 4539|  4.97M|      lhs, rhs, libcrux_secrets_int_public_integers_classify_27_39(zeta1),
 4540|  4.97M|      (size_t)2U, &out);
 4541|  4.97M|  libcrux_ml_kem_vector_portable_ntt_ntt_multiply_binomials(
 4542|  4.97M|      lhs, rhs, libcrux_secrets_int_public_integers_classify_27_39(nzeta1),
 4543|  4.97M|      (size_t)3U, &out);
 4544|  4.97M|  libcrux_ml_kem_vector_portable_ntt_ntt_multiply_binomials(
 4545|  4.97M|      lhs, rhs, libcrux_secrets_int_public_integers_classify_27_39(zeta2),
 4546|  4.97M|      (size_t)4U, &out);
 4547|  4.97M|  libcrux_ml_kem_vector_portable_ntt_ntt_multiply_binomials(
 4548|  4.97M|      lhs, rhs, libcrux_secrets_int_public_integers_classify_27_39(nzeta2),
 4549|  4.97M|      (size_t)5U, &out);
 4550|  4.97M|  libcrux_ml_kem_vector_portable_ntt_ntt_multiply_binomials(
 4551|  4.97M|      lhs, rhs, libcrux_secrets_int_public_integers_classify_27_39(zeta3),
 4552|  4.97M|      (size_t)6U, &out);
 4553|  4.97M|  libcrux_ml_kem_vector_portable_ntt_ntt_multiply_binomials(
 4554|  4.97M|      lhs, rhs, libcrux_secrets_int_public_integers_classify_27_39(nzeta3),
 4555|  4.97M|      (size_t)7U, &out);
 4556|  4.97M|  return out;
 4557|  4.97M|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_vector_portable_ntt_ntt_multiply_binomials:
 4491|  39.8M|    size_t i, libcrux_ml_kem_vector_portable_vector_type_PortableVector *out) {
 4492|  39.8M|  int16_t ai = a->elements[(size_t)2U * i];
 4493|  39.8M|  int16_t bi = b->elements[(size_t)2U * i];
 4494|  39.8M|  int16_t aj = a->elements[(size_t)2U * i + (size_t)1U];
 4495|  39.8M|  int16_t bj = b->elements[(size_t)2U * i + (size_t)1U];
 4496|  39.8M|  int32_t ai_bi =
 4497|  39.8M|      libcrux_secrets_int_as_i32_f5(ai) * libcrux_secrets_int_as_i32_f5(bi);
 4498|  39.8M|  int32_t aj_bj_ =
 4499|  39.8M|      libcrux_secrets_int_as_i32_f5(aj) * libcrux_secrets_int_as_i32_f5(bj);
 4500|  39.8M|  int16_t aj_bj =
 4501|  39.8M|      libcrux_ml_kem_vector_portable_arithmetic_montgomery_reduce_element(
 4502|  39.8M|          aj_bj_);
 4503|  39.8M|  int32_t aj_bj_zeta = libcrux_secrets_int_as_i32_f5(aj_bj) *
 4504|  39.8M|                       libcrux_secrets_int_as_i32_f5(zeta);
 4505|  39.8M|  int32_t ai_bi_aj_bj = ai_bi + aj_bj_zeta;
 4506|  39.8M|  int16_t o0 =
 4507|  39.8M|      libcrux_ml_kem_vector_portable_arithmetic_montgomery_reduce_element(
 4508|  39.8M|          ai_bi_aj_bj);
 4509|  39.8M|  int32_t ai_bj =
 4510|  39.8M|      libcrux_secrets_int_as_i32_f5(ai) * libcrux_secrets_int_as_i32_f5(bj);
 4511|  39.8M|  int32_t aj_bi =
 4512|  39.8M|      libcrux_secrets_int_as_i32_f5(aj) * libcrux_secrets_int_as_i32_f5(bi);
 4513|  39.8M|  int32_t ai_bj_aj_bi = ai_bj + aj_bi;
 4514|  39.8M|  int16_t o1 =
 4515|  39.8M|      libcrux_ml_kem_vector_portable_arithmetic_montgomery_reduce_element(
 4516|  39.8M|          ai_bj_aj_bi);
 4517|  39.8M|  out->elements[(size_t)2U * i] = o0;
 4518|  39.8M|  out->elements[(size_t)2U * i + (size_t)1U] = o1;
 4519|  39.8M|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_polynomial_add_to_ring_element_d6_1b:
 5946|   311k|    libcrux_ml_kem_polynomial_PolynomialRingElement_1d *rhs) {
 5947|   311k|  libcrux_ml_kem_polynomial_add_to_ring_element_1b(self, rhs);
 5948|   311k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_polynomial_add_to_ring_element_1b:
 5917|   311k|    libcrux_ml_kem_polynomial_PolynomialRingElement_1d *rhs) {
 5918|   311k|  for (size_t i = (size_t)0U;
 5919|  5.28M|       i < Eurydice_slice_len(
  ------------------
  |  |  173|  5.28M|#define Eurydice_slice_len(s, _) (s).len
  ------------------
  |  Branch (5919:8): [True: 4.97M, False: 311k]
  ------------------
 5920|   311k|               Eurydice_array_to_slice(
 5921|   311k|                   (size_t)16U, myself->coefficients,
 5922|   311k|                   libcrux_ml_kem_vector_portable_vector_type_PortableVector),
 5923|   311k|               libcrux_ml_kem_vector_portable_vector_type_PortableVector);
 5924|  4.97M|       i++) {
 5925|  4.97M|    size_t i0 = i;
 5926|  4.97M|    libcrux_ml_kem_vector_portable_vector_type_PortableVector uu____0 =
 5927|  4.97M|        libcrux_ml_kem_vector_portable_add_b8(myself->coefficients[i0],
 5928|  4.97M|                                              &rhs->coefficients[i0]);
 5929|  4.97M|    myself->coefficients[i0] = uu____0;
 5930|  4.97M|  }
 5931|   311k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_invert_ntt_invert_ntt_montgomery_1b:
 6072|  77.7k|    libcrux_ml_kem_polynomial_PolynomialRingElement_1d *re) {
 6073|  77.7k|  size_t zeta_i =
 6074|  77.7k|      LIBCRUX_ML_KEM_CONSTANTS_COEFFICIENTS_IN_RING_ELEMENT / (size_t)2U;
  ------------------
  |  |  447|  77.7k|#define LIBCRUX_ML_KEM_CONSTANTS_COEFFICIENTS_IN_RING_ELEMENT ((size_t)256U)
  ------------------
 6075|  77.7k|  libcrux_ml_kem_invert_ntt_invert_ntt_at_layer_1_ea(&zeta_i, re);
 6076|  77.7k|  libcrux_ml_kem_invert_ntt_invert_ntt_at_layer_2_ea(&zeta_i, re);
 6077|  77.7k|  libcrux_ml_kem_invert_ntt_invert_ntt_at_layer_3_ea(&zeta_i, re);
 6078|  77.7k|  libcrux_ml_kem_invert_ntt_invert_ntt_at_layer_4_plus_ea(&zeta_i, re,
 6079|  77.7k|                                                          (size_t)4U);
 6080|  77.7k|  libcrux_ml_kem_invert_ntt_invert_ntt_at_layer_4_plus_ea(&zeta_i, re,
 6081|  77.7k|                                                          (size_t)5U);
 6082|  77.7k|  libcrux_ml_kem_invert_ntt_invert_ntt_at_layer_4_plus_ea(&zeta_i, re,
 6083|  77.7k|                                                          (size_t)6U);
 6084|  77.7k|  libcrux_ml_kem_invert_ntt_invert_ntt_at_layer_4_plus_ea(&zeta_i, re,
 6085|  77.7k|                                                          (size_t)7U);
 6086|  77.7k|  libcrux_ml_kem_polynomial_poly_barrett_reduce_d6_ea(re);
 6087|  77.7k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_invert_ntt_invert_ntt_at_layer_1_ea:
 5957|  77.7k|    size_t *zeta_i, libcrux_ml_kem_polynomial_PolynomialRingElement_1d *re) {
 5958|  1.32M|  for (size_t i = (size_t)0U; i < (size_t)16U; i++) {
  ------------------
  |  Branch (5958:31): [True: 1.24M, False: 77.7k]
  ------------------
 5959|  1.24M|    size_t round = i;
 5960|  1.24M|    zeta_i[0U] = zeta_i[0U] - (size_t)1U;
 5961|  1.24M|    re->coefficients[round] =
 5962|  1.24M|        libcrux_ml_kem_vector_portable_inv_ntt_layer_1_step_b8(
 5963|  1.24M|            re->coefficients[round], libcrux_ml_kem_polynomial_zeta(zeta_i[0U]),
 5964|  1.24M|            libcrux_ml_kem_polynomial_zeta(zeta_i[0U] - (size_t)1U),
 5965|  1.24M|            libcrux_ml_kem_polynomial_zeta(zeta_i[0U] - (size_t)2U),
 5966|  1.24M|            libcrux_ml_kem_polynomial_zeta(zeta_i[0U] - (size_t)3U));
 5967|  1.24M|    zeta_i[0U] = zeta_i[0U] - (size_t)3U;
 5968|  1.24M|  }
 5969|  77.7k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_vector_portable_inv_ntt_layer_1_step_b8:
 4392|  1.24M|    int16_t zeta1, int16_t zeta2, int16_t zeta3) {
 4393|  1.24M|  return libcrux_ml_kem_vector_portable_ntt_inv_ntt_layer_1_step(
 4394|  1.24M|      a, zeta0, zeta1, zeta2, zeta3);
 4395|  1.24M|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_vector_portable_ntt_inv_ntt_layer_1_step:
 4365|  1.24M|    int16_t zeta0, int16_t zeta1, int16_t zeta2, int16_t zeta3) {
 4366|  1.24M|  libcrux_ml_kem_vector_portable_ntt_inv_ntt_step(&vec, zeta0, (size_t)0U,
 4367|  1.24M|                                                  (size_t)2U);
 4368|  1.24M|  libcrux_ml_kem_vector_portable_ntt_inv_ntt_step(&vec, zeta0, (size_t)1U,
 4369|  1.24M|                                                  (size_t)3U);
 4370|  1.24M|  libcrux_ml_kem_vector_portable_ntt_inv_ntt_step(&vec, zeta1, (size_t)4U,
 4371|  1.24M|                                                  (size_t)6U);
 4372|  1.24M|  libcrux_ml_kem_vector_portable_ntt_inv_ntt_step(&vec, zeta1, (size_t)5U,
 4373|  1.24M|                                                  (size_t)7U);
 4374|  1.24M|  libcrux_ml_kem_vector_portable_ntt_inv_ntt_step(&vec, zeta2, (size_t)8U,
 4375|  1.24M|                                                  (size_t)10U);
 4376|  1.24M|  libcrux_ml_kem_vector_portable_ntt_inv_ntt_step(&vec, zeta2, (size_t)9U,
 4377|  1.24M|                                                  (size_t)11U);
 4378|  1.24M|  libcrux_ml_kem_vector_portable_ntt_inv_ntt_step(&vec, zeta3, (size_t)12U,
 4379|  1.24M|                                                  (size_t)14U);
 4380|  1.24M|  libcrux_ml_kem_vector_portable_ntt_inv_ntt_step(&vec, zeta3, (size_t)13U,
 4381|  1.24M|                                                  (size_t)15U);
 4382|  1.24M|  return vec;
 4383|  1.24M|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_vector_portable_ntt_inv_ntt_step:
 4350|  29.8M|    int16_t zeta, size_t i, size_t j) {
 4351|  29.8M|  int16_t a_minus_b = vec->elements[j] - vec->elements[i];
 4352|  29.8M|  int16_t a_plus_b = vec->elements[j] + vec->elements[i];
 4353|  29.8M|  int16_t o0 = libcrux_ml_kem_vector_portable_arithmetic_barrett_reduce_element(
 4354|  29.8M|      a_plus_b);
 4355|  29.8M|  int16_t o1 =
 4356|  29.8M|      libcrux_ml_kem_vector_portable_arithmetic_montgomery_multiply_fe_by_fer(
 4357|  29.8M|          a_minus_b, libcrux_secrets_int_public_integers_classify_27_39(zeta));
 4358|  29.8M|  vec->elements[i] = o0;
 4359|  29.8M|  vec->elements[j] = o1;
 4360|  29.8M|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_invert_ntt_invert_ntt_at_layer_2_ea:
 5978|  77.7k|    size_t *zeta_i, libcrux_ml_kem_polynomial_PolynomialRingElement_1d *re) {
 5979|  1.32M|  for (size_t i = (size_t)0U; i < (size_t)16U; i++) {
  ------------------
  |  Branch (5979:31): [True: 1.24M, False: 77.7k]
  ------------------
 5980|  1.24M|    size_t round = i;
 5981|  1.24M|    zeta_i[0U] = zeta_i[0U] - (size_t)1U;
 5982|  1.24M|    re->coefficients[round] =
 5983|  1.24M|        libcrux_ml_kem_vector_portable_inv_ntt_layer_2_step_b8(
 5984|  1.24M|            re->coefficients[round], libcrux_ml_kem_polynomial_zeta(zeta_i[0U]),
 5985|  1.24M|            libcrux_ml_kem_polynomial_zeta(zeta_i[0U] - (size_t)1U));
 5986|  1.24M|    zeta_i[0U] = zeta_i[0U] - (size_t)1U;
 5987|  1.24M|  }
 5988|  77.7k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_vector_portable_inv_ntt_layer_2_step_b8:
 4427|  1.24M|    int16_t zeta1) {
 4428|  1.24M|  return libcrux_ml_kem_vector_portable_ntt_inv_ntt_layer_2_step(a, zeta0,
 4429|  1.24M|                                                                 zeta1);
 4430|  1.24M|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_vector_portable_ntt_inv_ntt_layer_2_step:
 4400|  1.24M|    int16_t zeta0, int16_t zeta1) {
 4401|  1.24M|  libcrux_ml_kem_vector_portable_ntt_inv_ntt_step(&vec, zeta0, (size_t)0U,
 4402|  1.24M|                                                  (size_t)4U);
 4403|  1.24M|  libcrux_ml_kem_vector_portable_ntt_inv_ntt_step(&vec, zeta0, (size_t)1U,
 4404|  1.24M|                                                  (size_t)5U);
 4405|  1.24M|  libcrux_ml_kem_vector_portable_ntt_inv_ntt_step(&vec, zeta0, (size_t)2U,
 4406|  1.24M|                                                  (size_t)6U);
 4407|  1.24M|  libcrux_ml_kem_vector_portable_ntt_inv_ntt_step(&vec, zeta0, (size_t)3U,
 4408|  1.24M|                                                  (size_t)7U);
 4409|  1.24M|  libcrux_ml_kem_vector_portable_ntt_inv_ntt_step(&vec, zeta1, (size_t)8U,
 4410|  1.24M|                                                  (size_t)12U);
 4411|  1.24M|  libcrux_ml_kem_vector_portable_ntt_inv_ntt_step(&vec, zeta1, (size_t)9U,
 4412|  1.24M|                                                  (size_t)13U);
 4413|  1.24M|  libcrux_ml_kem_vector_portable_ntt_inv_ntt_step(&vec, zeta1, (size_t)10U,
 4414|  1.24M|                                                  (size_t)14U);
 4415|  1.24M|  libcrux_ml_kem_vector_portable_ntt_inv_ntt_step(&vec, zeta1, (size_t)11U,
 4416|  1.24M|                                                  (size_t)15U);
 4417|  1.24M|  return vec;
 4418|  1.24M|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_invert_ntt_invert_ntt_at_layer_3_ea:
 5997|  77.7k|    size_t *zeta_i, libcrux_ml_kem_polynomial_PolynomialRingElement_1d *re) {
 5998|  1.32M|  for (size_t i = (size_t)0U; i < (size_t)16U; i++) {
  ------------------
  |  Branch (5998:31): [True: 1.24M, False: 77.7k]
  ------------------
 5999|  1.24M|    size_t round = i;
 6000|  1.24M|    zeta_i[0U] = zeta_i[0U] - (size_t)1U;
 6001|  1.24M|    libcrux_ml_kem_vector_portable_vector_type_PortableVector uu____0 =
 6002|  1.24M|        libcrux_ml_kem_vector_portable_inv_ntt_layer_3_step_b8(
 6003|  1.24M|            re->coefficients[round],
 6004|  1.24M|            libcrux_ml_kem_polynomial_zeta(zeta_i[0U]));
 6005|  1.24M|    re->coefficients[round] = uu____0;
 6006|  1.24M|  }
 6007|  77.7k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_vector_portable_inv_ntt_layer_3_step_b8:
 4461|  1.24M|    libcrux_ml_kem_vector_portable_vector_type_PortableVector a, int16_t zeta) {
 4462|  1.24M|  return libcrux_ml_kem_vector_portable_ntt_inv_ntt_layer_3_step(a, zeta);
 4463|  1.24M|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_vector_portable_ntt_inv_ntt_layer_3_step:
 4435|  1.24M|    int16_t zeta) {
 4436|  1.24M|  libcrux_ml_kem_vector_portable_ntt_inv_ntt_step(&vec, zeta, (size_t)0U,
 4437|  1.24M|                                                  (size_t)8U);
 4438|  1.24M|  libcrux_ml_kem_vector_portable_ntt_inv_ntt_step(&vec, zeta, (size_t)1U,
 4439|  1.24M|                                                  (size_t)9U);
 4440|  1.24M|  libcrux_ml_kem_vector_portable_ntt_inv_ntt_step(&vec, zeta, (size_t)2U,
 4441|  1.24M|                                                  (size_t)10U);
 4442|  1.24M|  libcrux_ml_kem_vector_portable_ntt_inv_ntt_step(&vec, zeta, (size_t)3U,
 4443|  1.24M|                                                  (size_t)11U);
 4444|  1.24M|  libcrux_ml_kem_vector_portable_ntt_inv_ntt_step(&vec, zeta, (size_t)4U,
 4445|  1.24M|                                                  (size_t)12U);
 4446|  1.24M|  libcrux_ml_kem_vector_portable_ntt_inv_ntt_step(&vec, zeta, (size_t)5U,
 4447|  1.24M|                                                  (size_t)13U);
 4448|  1.24M|  libcrux_ml_kem_vector_portable_ntt_inv_ntt_step(&vec, zeta, (size_t)6U,
 4449|  1.24M|                                                  (size_t)14U);
 4450|  1.24M|  libcrux_ml_kem_vector_portable_ntt_inv_ntt_step(&vec, zeta, (size_t)7U,
 4451|  1.24M|                                                  (size_t)15U);
 4452|  1.24M|  return vec;
 4453|  1.24M|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_invert_ntt_invert_ntt_at_layer_4_plus_ea:
 6041|   311k|    size_t layer) {
 6042|   311k|  size_t step = (size_t)1U << (uint32_t)layer;
 6043|  1.47M|  for (size_t i0 = (size_t)0U; i0 < (size_t)128U >> (uint32_t)layer; i0++) {
  ------------------
  |  Branch (6043:32): [True: 1.16M, False: 311k]
  ------------------
 6044|  1.16M|    size_t round = i0;
 6045|  1.16M|    zeta_i[0U] = zeta_i[0U] - (size_t)1U;
 6046|  1.16M|    size_t offset = round * step * (size_t)2U;
 6047|  1.16M|    size_t offset_vec =
 6048|  1.16M|        offset / LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_ELEMENTS_IN_VECTOR;
  ------------------
  |  | 3772|  1.16M|#define LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_ELEMENTS_IN_VECTOR ((size_t)16U)
  ------------------
 6049|  1.16M|    size_t step_vec =
 6050|  1.16M|        step / LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_ELEMENTS_IN_VECTOR;
  ------------------
  |  | 3772|  1.16M|#define LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_ELEMENTS_IN_VECTOR ((size_t)16U)
  ------------------
 6051|  3.65M|    for (size_t i = offset_vec; i < offset_vec + step_vec; i++) {
  ------------------
  |  Branch (6051:33): [True: 2.48M, False: 1.16M]
  ------------------
 6052|  2.48M|      size_t j = i;
 6053|  2.48M|      libcrux_ml_kem_vector_portable_vector_type_PortableVector_x2 uu____0 =
 6054|  2.48M|          libcrux_ml_kem_invert_ntt_inv_ntt_layer_int_vec_step_reduce_ea(
 6055|  2.48M|              re->coefficients[j], re->coefficients[j + step_vec],
 6056|  2.48M|              libcrux_ml_kem_polynomial_zeta(zeta_i[0U]));
 6057|  2.48M|      libcrux_ml_kem_vector_portable_vector_type_PortableVector x = uu____0.fst;
 6058|  2.48M|      libcrux_ml_kem_vector_portable_vector_type_PortableVector y = uu____0.snd;
 6059|  2.48M|      re->coefficients[j] = x;
 6060|  2.48M|      re->coefficients[j + step_vec] = y;
 6061|  2.48M|    }
 6062|  1.16M|  }
 6063|   311k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_invert_ntt_inv_ntt_layer_int_vec_step_reduce_ea:
 6020|  2.48M|        int16_t zeta_r) {
 6021|  2.48M|  libcrux_ml_kem_vector_portable_vector_type_PortableVector a_minus_b =
 6022|  2.48M|      libcrux_ml_kem_vector_portable_sub_b8(b, &a);
 6023|  2.48M|  a = libcrux_ml_kem_vector_portable_barrett_reduce_b8(
 6024|  2.48M|      libcrux_ml_kem_vector_portable_add_b8(a, &b));
 6025|  2.48M|  b = libcrux_ml_kem_vector_portable_montgomery_multiply_by_constant_b8(
 6026|  2.48M|      a_minus_b, zeta_r);
 6027|  2.48M|  return (KRML_CLITERAL(
  ------------------
  |  |  154|  2.48M|#define KRML_CLITERAL(type) (type)
  ------------------
 6028|  2.48M|      libcrux_ml_kem_vector_portable_vector_type_PortableVector_x2){.fst = a,
 6029|  2.48M|                                                                    .snd = b});
 6030|  2.48M|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_polynomial_subtract_reduce_d6_ea:
 6130|  8.64k|    libcrux_ml_kem_polynomial_PolynomialRingElement_1d b) {
 6131|  8.64k|  return libcrux_ml_kem_polynomial_subtract_reduce_ea(self, b);
 6132|  8.64k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_polynomial_subtract_reduce_ea:
 6098|  8.64k|    libcrux_ml_kem_polynomial_PolynomialRingElement_1d b) {
 6099|  8.64k|  for (size_t i = (size_t)0U;
 6100|   146k|       i < LIBCRUX_ML_KEM_POLYNOMIAL_VECTORS_IN_RING_ELEMENT; i++) {
  ------------------
  |  | 3770|   146k|#define LIBCRUX_ML_KEM_POLYNOMIAL_VECTORS_IN_RING_ELEMENT ((size_t)16U)
  ------------------
  |  Branch (6100:8): [True: 138k, False: 8.64k]
  ------------------
 6101|   138k|    size_t i0 = i;
 6102|   138k|    libcrux_ml_kem_vector_portable_vector_type_PortableVector
 6103|   138k|        coefficient_normal_form =
 6104|   138k|            libcrux_ml_kem_vector_portable_montgomery_multiply_by_constant_b8(
 6105|   138k|                b.coefficients[i0], (int16_t)1441);
 6106|   138k|    libcrux_ml_kem_vector_portable_vector_type_PortableVector diff =
 6107|   138k|        libcrux_ml_kem_vector_portable_sub_b8(myself->coefficients[i0],
 6108|   138k|                                              &coefficient_normal_form);
 6109|   138k|    libcrux_ml_kem_vector_portable_vector_type_PortableVector red =
 6110|   138k|        libcrux_ml_kem_vector_portable_barrett_reduce_b8(diff);
 6111|   138k|    b.coefficients[i0] = red;
 6112|   138k|  }
 6113|  8.64k|  return b;
 6114|  8.64k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_serialize_compress_then_serialize_message_ea:
 6184|  8.64k|    libcrux_ml_kem_polynomial_PolynomialRingElement_1d re, uint8_t ret[32U]) {
 6185|  8.64k|  uint8_t serialized[32U] = {0U};
 6186|   146k|  for (size_t i = (size_t)0U; i < (size_t)16U; i++) {
  ------------------
  |  Branch (6186:31): [True: 138k, False: 8.64k]
  ------------------
 6187|   138k|    size_t i0 = i;
 6188|   138k|    libcrux_ml_kem_vector_portable_vector_type_PortableVector coefficient =
 6189|   138k|        libcrux_ml_kem_serialize_to_unsigned_field_modulus_ea(
 6190|   138k|            re.coefficients[i0]);
 6191|   138k|    libcrux_ml_kem_vector_portable_vector_type_PortableVector
 6192|   138k|        coefficient_compressed =
 6193|   138k|            libcrux_ml_kem_vector_portable_compress_1_b8(coefficient);
 6194|   138k|    uint8_t bytes[2U];
 6195|   138k|    libcrux_ml_kem_vector_portable_serialize_1_b8(coefficient_compressed,
 6196|   138k|                                                  bytes);
 6197|   138k|    Eurydice_slice_copy(
  ------------------
  |  |  229|   138k|  memcpy(dst.ptr, src.ptr, dst.len * sizeof(t))
  ------------------
 6198|   138k|        Eurydice_array_to_subslice3(serialized, (size_t)2U * i0,
 6199|   138k|                                    (size_t)2U * i0 + (size_t)2U, uint8_t *),
 6200|   138k|        Eurydice_array_to_slice((size_t)2U, bytes, uint8_t), uint8_t);
 6201|   138k|  }
 6202|  8.64k|  memcpy(ret, serialized, (size_t)32U * sizeof(uint8_t));
 6203|  8.64k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_serialize_to_unsigned_field_modulus_ea:
 6172|  2.48M|    libcrux_ml_kem_vector_portable_vector_type_PortableVector a) {
 6173|  2.48M|  return libcrux_ml_kem_vector_portable_to_unsigned_representative_b8(a);
 6174|  2.48M|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_vector_portable_to_unsigned_representative_b8:
 4127|  2.48M|    libcrux_ml_kem_vector_portable_vector_type_PortableVector a) {
 4128|  2.48M|  return libcrux_ml_kem_vector_portable_arithmetic_to_unsigned_representative(
 4129|  2.48M|      a);
 4130|  2.48M|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_vector_portable_arithmetic_to_unsigned_representative:
 4112|  2.48M|    libcrux_ml_kem_vector_portable_vector_type_PortableVector a) {
 4113|  2.48M|  libcrux_ml_kem_vector_portable_vector_type_PortableVector t =
 4114|  2.48M|      libcrux_ml_kem_vector_portable_arithmetic_shift_right_ef(a);
 4115|  2.48M|  libcrux_ml_kem_vector_portable_vector_type_PortableVector fm =
 4116|  2.48M|      libcrux_ml_kem_vector_portable_arithmetic_bitwise_and_with_constant(
 4117|  2.48M|          t, LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_MODULUS);
  ------------------
  |  | 3777|  2.48M|#define LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_MODULUS ((int16_t)3329)
  ------------------
 4118|  2.48M|  return libcrux_ml_kem_vector_portable_arithmetic_add(a, &fm);
 4119|  2.48M|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_vector_portable_arithmetic_shift_right_ef:
 4101|  2.48M|    libcrux_ml_kem_vector_portable_vector_type_PortableVector vec) {
 4102|  2.48M|  for (size_t i = (size_t)0U;
 4103|  42.3M|       i < LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_ELEMENTS_IN_VECTOR; i++) {
  ------------------
  |  | 3772|  42.3M|#define LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_ELEMENTS_IN_VECTOR ((size_t)16U)
  ------------------
  |  Branch (4103:8): [True: 39.8M, False: 2.48M]
  ------------------
 4104|  39.8M|    size_t i0 = i;
 4105|  39.8M|    vec.elements[i0] = vec.elements[i0] >> (uint32_t)(int32_t)15;
 4106|  39.8M|  }
 4107|  2.48M|  return vec;
 4108|  2.48M|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_vector_portable_arithmetic_bitwise_and_with_constant:
 4084|  2.76M|    libcrux_ml_kem_vector_portable_vector_type_PortableVector vec, int16_t c) {
 4085|  2.76M|  for (size_t i = (size_t)0U;
 4086|  47.0M|       i < LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_ELEMENTS_IN_VECTOR; i++) {
  ------------------
  |  | 3772|  47.0M|#define LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_ELEMENTS_IN_VECTOR ((size_t)16U)
  ------------------
  |  Branch (4086:8): [True: 44.2M, False: 2.76M]
  ------------------
 4087|  44.2M|    size_t i0 = i;
 4088|  44.2M|    size_t uu____0 = i0;
 4089|  44.2M|    vec.elements[uu____0] = vec.elements[uu____0] & c;
 4090|  44.2M|  }
 4091|  2.76M|  return vec;
 4092|  2.76M|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_vector_portable_compress_1_b8:
 4187|   138k|    libcrux_ml_kem_vector_portable_vector_type_PortableVector a) {
 4188|   138k|  return libcrux_ml_kem_vector_portable_compress_compress_1(a);
 4189|   138k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_vector_portable_compress_compress_1:
 4170|   138k|    libcrux_ml_kem_vector_portable_vector_type_PortableVector a) {
 4171|   138k|  for (size_t i = (size_t)0U;
 4172|  2.35M|       i < LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_ELEMENTS_IN_VECTOR; i++) {
  ------------------
  |  | 3772|  2.35M|#define LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_ELEMENTS_IN_VECTOR ((size_t)16U)
  ------------------
  |  Branch (4172:8): [True: 2.21M, False: 138k]
  ------------------
 4173|  2.21M|    size_t i0 = i;
 4174|  2.21M|    a.elements[i0] = libcrux_secrets_int_as_i16_59(
 4175|  2.21M|        libcrux_ml_kem_vector_portable_compress_compress_message_coefficient(
 4176|  2.21M|            libcrux_secrets_int_as_u16_f5(a.elements[i0])));
 4177|  2.21M|  }
 4178|   138k|  return a;
 4179|   138k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_vector_portable_compress_compress_message_coefficient:
 4156|  2.21M|    uint16_t fe) {
 4157|  2.21M|  int16_t shifted =
 4158|  2.21M|      libcrux_secrets_int_public_integers_classify_27_39((int16_t)1664) -
 4159|  2.21M|      libcrux_secrets_int_as_i16_ca(fe);
 4160|  2.21M|  int16_t mask = shifted >> 15U;
 4161|  2.21M|  int16_t shifted_to_positive = mask ^ shifted;
 4162|  2.21M|  int16_t shifted_positive_in_range = shifted_to_positive - (int16_t)832;
 4163|  2.21M|  int16_t r0 = shifted_positive_in_range >> 15U;
 4164|  2.21M|  int16_t r1 = r0 & (int16_t)1;
 4165|  2.21M|  return libcrux_secrets_int_as_u8_f5(r1);
 4166|  2.21M|}
libcrux_mlkem768_sha3.c:libcrux_secrets_int_as_i16_ca:
  640|  2.21M|static KRML_MUSTINLINE int16_t libcrux_secrets_int_as_i16_ca(uint16_t self) {
  641|  2.21M|  return libcrux_secrets_int_public_integers_classify_27_39(
  642|  2.21M|      (int16_t)libcrux_secrets_int_public_integers_declassify_d8_de(self));
  643|  2.21M|}
libcrux_mlkem768_sha3.c:libcrux_secrets_int_public_integers_declassify_d8_de:
  633|  19.9M|libcrux_secrets_int_public_integers_declassify_d8_de(uint16_t self) {
  634|  19.9M|  return self;
  635|  19.9M|}
libcrux_mlkem768_sha3.c:libcrux_secrets_int_as_u8_f5:
  501|  65.2M|static KRML_MUSTINLINE uint8_t libcrux_secrets_int_as_u8_f5(int16_t self) {
  502|  65.2M|  return libcrux_secrets_int_public_integers_classify_27_90(
  503|  65.2M|      (uint8_t)libcrux_secrets_int_public_integers_declassify_d8_39(self));
  504|  65.2M|}
libcrux_mlkem768_sha3.c:libcrux_secrets_int_public_integers_classify_27_90:
  481|  65.2M|libcrux_secrets_int_public_integers_classify_27_90(uint8_t self) {
  482|  65.2M|  return self;
  483|  65.2M|}
libcrux_mlkem768_sha3.c:libcrux_secrets_int_as_u16_f5:
  619|  19.9M|static KRML_MUSTINLINE uint16_t libcrux_secrets_int_as_u16_f5(int16_t self) {
  620|  19.9M|  return libcrux_secrets_int_public_integers_classify_27_de(
  621|  19.9M|      (uint16_t)libcrux_secrets_int_public_integers_declassify_d8_39(self));
  622|  19.9M|}
libcrux_mlkem768_sha3.c:libcrux_secrets_int_public_integers_classify_27_de:
  612|  19.9M|libcrux_secrets_int_public_integers_classify_27_de(uint16_t self) {
  613|  19.9M|  return self;
  614|  19.9M|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_vector_portable_serialize_1_b8:
 4612|   138k|    uint8_t ret[2U]) {
 4613|   138k|  libcrux_ml_kem_vector_portable_serialize_1(a, ret);
 4614|   138k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_vector_portable_serialize_1:
 4600|   138k|    uint8_t ret[2U]) {
 4601|   138k|  uint8_t ret0[2U];
 4602|   138k|  libcrux_ml_kem_vector_portable_serialize_serialize_1(a, ret0);
 4603|   138k|  libcrux_secrets_int_public_integers_declassify_d8_d4(ret0, ret);
 4604|   138k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_vector_portable_serialize_serialize_1:
 4575|   138k|    uint8_t ret[2U]) {
 4576|   138k|  uint8_t result0 =
 4577|   138k|      (((((((uint32_t)libcrux_secrets_int_as_u8_f5(v.elements[0U]) |
 4578|   138k|            (uint32_t)libcrux_secrets_int_as_u8_f5(v.elements[1U]) << 1U) |
 4579|   138k|           (uint32_t)libcrux_secrets_int_as_u8_f5(v.elements[2U]) << 2U) |
 4580|   138k|          (uint32_t)libcrux_secrets_int_as_u8_f5(v.elements[3U]) << 3U) |
 4581|   138k|         (uint32_t)libcrux_secrets_int_as_u8_f5(v.elements[4U]) << 4U) |
 4582|   138k|        (uint32_t)libcrux_secrets_int_as_u8_f5(v.elements[5U]) << 5U) |
 4583|   138k|       (uint32_t)libcrux_secrets_int_as_u8_f5(v.elements[6U]) << 6U) |
 4584|   138k|      (uint32_t)libcrux_secrets_int_as_u8_f5(v.elements[7U]) << 7U;
 4585|   138k|  uint8_t result1 =
 4586|   138k|      (((((((uint32_t)libcrux_secrets_int_as_u8_f5(v.elements[8U]) |
 4587|   138k|            (uint32_t)libcrux_secrets_int_as_u8_f5(v.elements[9U]) << 1U) |
 4588|   138k|           (uint32_t)libcrux_secrets_int_as_u8_f5(v.elements[10U]) << 2U) |
 4589|   138k|          (uint32_t)libcrux_secrets_int_as_u8_f5(v.elements[11U]) << 3U) |
 4590|   138k|         (uint32_t)libcrux_secrets_int_as_u8_f5(v.elements[12U]) << 4U) |
 4591|   138k|        (uint32_t)libcrux_secrets_int_as_u8_f5(v.elements[13U]) << 5U) |
 4592|   138k|       (uint32_t)libcrux_secrets_int_as_u8_f5(v.elements[14U]) << 6U) |
 4593|   138k|      (uint32_t)libcrux_secrets_int_as_u8_f5(v.elements[15U]) << 7U;
 4594|   138k|  ret[0U] = result0;
 4595|   138k|  ret[1U] = result1;
 4596|   138k|}
libcrux_mlkem768_sha3.c:libcrux_secrets_int_public_integers_declassify_d8_d4:
 1062|   138k|                                                     uint8_t ret[2U]) {
 1063|   138k|  memcpy(ret, self, (size_t)2U * sizeof(uint8_t));
 1064|   138k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_utils_into_padded_array_24:
  955|  17.2k|    Eurydice_slice slice, uint8_t ret[64U]) {
  956|  17.2k|  uint8_t out[64U] = {0U};
  957|  17.2k|  uint8_t *uu____0 = out;
  958|  17.2k|  Eurydice_slice_copy(
  ------------------
  |  |  229|  17.2k|  memcpy(dst.ptr, src.ptr, dst.len * sizeof(t))
  ------------------
  959|  17.2k|      Eurydice_array_to_subslice3(
  960|  17.2k|          uu____0, (size_t)0U, Eurydice_slice_len(slice, uint8_t), uint8_t *),
  961|  17.2k|      slice, uint8_t);
  962|  17.2k|  memcpy(ret, out, (size_t)64U * sizeof(uint8_t));
  963|  17.2k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_hash_functions_portable_G_4a_e0:
 6298|  25.9k|    Eurydice_slice input, uint8_t ret[64U]) {
 6299|  25.9k|  libcrux_ml_kem_hash_functions_portable_G(input, ret);
 6300|  25.9k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_hash_functions_portable_G:
 3717|  25.9k|    Eurydice_slice input, uint8_t ret[64U]) {
 3718|  25.9k|  uint8_t digest[64U] = {0U};
 3719|  25.9k|  libcrux_sha3_portable_sha512(
 3720|  25.9k|      Eurydice_array_to_slice((size_t)64U, digest, uint8_t), input);
  ------------------
  |  |  204|  25.9k|  EURYDICE_SLICE(x, 0,                     \
  |  |  ------------------
  |  |  |  |  169|  25.9k|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|  25.9k|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  205|  25.9k|                 end) /* x is already at an array type, no need for cast */
  ------------------
 3721|  25.9k|  memcpy(ret, digest, (size_t)64U * sizeof(uint8_t));
 3722|  25.9k|}
libcrux_mlkem768_sha3.c:libcrux_sha3_portable_sha512:
 3128|  25.9k|                                                         Eurydice_slice data) {
 3129|  25.9k|  libcrux_sha3_generic_keccak_portable_keccak1_96(data, digest);
 3130|  25.9k|}
libcrux_mlkem768_sha3.c:libcrux_sha3_generic_keccak_portable_keccak1_96:
 3092|  25.9k|    Eurydice_slice data, Eurydice_slice out) {
 3093|  25.9k|  libcrux_sha3_generic_keccak_KeccakState_17 s =
 3094|  25.9k|      libcrux_sha3_generic_keccak_new_80_04();
 3095|  25.9k|  size_t data_len = Eurydice_slice_len(data, uint8_t);
  ------------------
  |  |  173|  25.9k|#define Eurydice_slice_len(s, _) (s).len
  ------------------
 3096|  25.9k|  for (size_t i = (size_t)0U; i < data_len / (size_t)72U; i++) {
  ------------------
  |  Branch (3096:31): [True: 0, False: 25.9k]
  ------------------
 3097|      0|    size_t i0 = i;
 3098|      0|    Eurydice_slice buf[1U] = {data};
 3099|      0|    libcrux_sha3_generic_keccak_absorb_block_80_c6(&s, buf, i0 * (size_t)72U);
 3100|      0|  }
 3101|  25.9k|  size_t rem = data_len % (size_t)72U;
 3102|  25.9k|  Eurydice_slice buf[1U] = {data};
 3103|  25.9k|  libcrux_sha3_generic_keccak_absorb_final_80_9e(&s, buf, data_len - rem, rem);
 3104|  25.9k|  size_t outlen = Eurydice_slice_len(out, uint8_t);
  ------------------
  |  |  173|  25.9k|#define Eurydice_slice_len(s, _) (s).len
  ------------------
 3105|  25.9k|  size_t blocks = outlen / (size_t)72U;
 3106|  25.9k|  size_t last = outlen - outlen % (size_t)72U;
 3107|  25.9k|  if (blocks == (size_t)0U) {
  ------------------
  |  Branch (3107:7): [True: 25.9k, False: 0]
  ------------------
 3108|  25.9k|    libcrux_sha3_simd_portable_squeeze_13_f8(&s, out, (size_t)0U, outlen);
 3109|  25.9k|  } else {
 3110|      0|    libcrux_sha3_simd_portable_squeeze_13_f8(&s, out, (size_t)0U, (size_t)72U);
 3111|      0|    for (size_t i = (size_t)1U; i < blocks; i++) {
  ------------------
  |  Branch (3111:33): [True: 0, False: 0]
  ------------------
 3112|      0|      size_t i0 = i;
 3113|      0|      libcrux_sha3_generic_keccak_keccakf1600_80_04(&s);
 3114|      0|      libcrux_sha3_simd_portable_squeeze_13_f8(&s, out, i0 * (size_t)72U,
 3115|      0|                                               (size_t)72U);
 3116|      0|    }
 3117|      0|    if (last < outlen) {
  ------------------
  |  Branch (3117:9): [True: 0, False: 0]
  ------------------
 3118|      0|      libcrux_sha3_generic_keccak_keccakf1600_80_04(&s);
 3119|      0|      libcrux_sha3_simd_portable_squeeze_13_f8(&s, out, last, outlen - last);
 3120|      0|    }
 3121|      0|  }
 3122|  25.9k|}
libcrux_mlkem768_sha3.c:libcrux_sha3_generic_keccak_new_80_04:
 1449|   457k|libcrux_sha3_generic_keccak_new_80_04(void) {
 1450|   457k|  libcrux_sha3_generic_keccak_KeccakState_17 lit;
 1451|   457k|  uint64_t repeat_expression[25U];
 1452|  11.9M|  for (size_t i = (size_t)0U; i < (size_t)25U; i++) {
  ------------------
  |  Branch (1452:31): [True: 11.4M, False: 457k]
  ------------------
 1453|  11.4M|    repeat_expression[i] = libcrux_sha3_simd_portable_zero_d2();
 1454|  11.4M|  }
 1455|   457k|  memcpy(lit.st, repeat_expression, (size_t)25U * sizeof(uint64_t));
 1456|   457k|  return lit;
 1457|   457k|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_zero_d2:
 1320|  11.4M|static KRML_MUSTINLINE uint64_t libcrux_sha3_simd_portable_zero_d2(void) {
 1321|  11.4M|  return 0ULL;
 1322|  11.4M|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_load_block_f8:
 1489|  25.9k|    uint64_t *state, Eurydice_slice blocks, size_t start) {
 1490|  25.9k|  uint64_t state_flat[25U] = {0U};
 1491|   259k|  for (size_t i = (size_t)0U; i < (size_t)72U / (size_t)8U; i++) {
  ------------------
  |  Branch (1491:31): [True: 233k, False: 25.9k]
  ------------------
 1492|   233k|    size_t i0 = i;
 1493|   233k|    size_t offset = start + (size_t)8U * i0;
 1494|   233k|    uint8_t uu____0[8U];
 1495|   233k|    Result_15 dst;
 1496|   233k|    Eurydice_slice_to_array2(
  ------------------
  |  |  277|   233k|  Eurydice_slice_to_array3(&(dst)->tag, (char *)&(dst)->val.case_Ok, src, \
  |  |  278|   233k|                           sizeof(t_arr))
  ------------------
 1497|   233k|        &dst,
 1498|   233k|        Eurydice_slice_subslice3(blocks, offset, offset + (size_t)8U,
 1499|   233k|                                 uint8_t *),
 1500|   233k|        Eurydice_slice, uint8_t[8U], TryFromSliceError);
 1501|   233k|    unwrap_26_68(dst, uu____0);
 1502|   233k|    state_flat[i0] = core_num__u64__from_le_bytes(uu____0);
 1503|   233k|  }
 1504|   259k|  for (size_t i = (size_t)0U; i < (size_t)72U / (size_t)8U; i++) {
  ------------------
  |  Branch (1504:31): [True: 233k, False: 25.9k]
  ------------------
 1505|   233k|    size_t i0 = i;
 1506|   233k|    libcrux_sha3_traits_set_ij_04(
 1507|   233k|        state, i0 / (size_t)5U, i0 % (size_t)5U,
 1508|   233k|        libcrux_sha3_traits_get_ij_04(state, i0 / (size_t)5U,
 1509|   233k|                                      i0 % (size_t)5U)[0U] ^
 1510|   233k|            state_flat[i0]);
 1511|   233k|  }
 1512|  25.9k|}
libcrux_mlkem768_sha3.c:Eurydice_slice_to_array3:
  281|  18.5M|                                            Eurydice_slice src, size_t sz) {
  282|  18.5M|  *dst_tag = 0;
  283|  18.5M|  memcpy(dst_ok, src.ptr, sz);
  284|  18.5M|}
libcrux_mlkem768_sha3.c:unwrap_26_68:
 1163|  12.0M|static inline void unwrap_26_68(Result_15 self, uint8_t ret[8U]) {
 1164|  12.0M|  if (self.tag == Ok) {
  ------------------
  |  |  721|  12.0M|#define Ok 0
  ------------------
  |  Branch (1164:7): [True: 12.0M, False: 0]
  ------------------
 1165|  12.0M|    uint8_t f0[8U];
 1166|  12.0M|    memcpy(f0, self.val.case_Ok, (size_t)8U * sizeof(uint8_t));
 1167|  12.0M|    memcpy(ret, f0, (size_t)8U * sizeof(uint8_t));
 1168|  12.0M|  } else {
 1169|      0|    KRML_HOST_EPRINTF("KaRaMeL abort at %s:%d\n%s\n", __FILE__, __LINE__,
 1170|      0|                      "unwrap not Ok");
 1171|       |    KRML_HOST_EXIT(255U);
  ------------------
  |  |   41|      0|#define KRML_HOST_EXIT(x) do { \
  |  |   42|      0|    fprintf(stderr, "mlkem internal error"); \
  |  |   43|      0|    exit(x); \
  |  |   44|      0|} while (0)
  |  |  ------------------
  |  |  |  Branch (44:10): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1172|      0|  }
 1173|  12.0M|}
libcrux_mlkem768_sha3.c:core_num__u64__from_le_bytes:
  331|  12.0M|static inline uint64_t core_num__u64__from_le_bytes(uint8_t buf[8]) {
  332|  12.0M|  return load64_le(buf);
  333|  12.0M|}
libcrux_mlkem768_sha3.c:load64_le:
   61|  12.0M|{
   62|  12.0M|	return (uint64_t)(src[0]) |
   63|  12.0M|	    ((uint64_t)(src[1]) << 8) |
   64|  12.0M|	    ((uint64_t)(src[2]) << 16) |
   65|  12.0M|	    ((uint64_t)(src[3]) << 24) |
   66|  12.0M|	    ((uint64_t)(src[4]) << 32) |
   67|  12.0M|	    ((uint64_t)(src[5]) << 40) |
   68|  12.0M|	    ((uint64_t)(src[6]) << 48) |
   69|  12.0M|	    ((uint64_t)(src[7]) << 56);
   70|  12.0M|}
libcrux_mlkem768_sha3.c:libcrux_sha3_traits_set_ij_04:
 1479|  2.05G|                                                          uint64_t value) {
 1480|  2.05G|  arr[(size_t)5U * j + i] = value;
 1481|  2.05G|}
libcrux_mlkem768_sha3.c:libcrux_sha3_traits_get_ij_04:
 1467|  4.12G|                                                               size_t j) {
 1468|  4.12G|  return &arr[(size_t)5U * j + i];
 1469|  4.12G|}
libcrux_mlkem768_sha3.c:libcrux_sha3_generic_keccak_absorb_final_80_9e:
 3027|  25.9k|    size_t start, size_t len) {
 3028|  25.9k|  libcrux_sha3_simd_portable_load_last_a1_96(self, last, start, len);
 3029|  25.9k|  libcrux_sha3_generic_keccak_keccakf1600_80_04(self);
 3030|  25.9k|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_load_last_a1_96:
 3009|  25.9k|    size_t start, size_t len) {
 3010|  25.9k|  libcrux_sha3_simd_portable_load_last_96(self->st, input[0U], start, len);
 3011|  25.9k|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_load_last_96:
 2983|  25.9k|    uint64_t *state, Eurydice_slice blocks, size_t start, size_t len) {
 2984|  25.9k|  uint8_t buffer[72U] = {0U};
 2985|  25.9k|  Eurydice_slice_copy(
  ------------------
  |  |  229|  25.9k|  memcpy(dst.ptr, src.ptr, dst.len * sizeof(t))
  ------------------
 2986|  25.9k|      Eurydice_array_to_subslice3(buffer, (size_t)0U, len, uint8_t *),
 2987|  25.9k|      Eurydice_slice_subslice3(blocks, start, start + len, uint8_t *), uint8_t);
 2988|  25.9k|  buffer[len] = 6U;
 2989|  25.9k|  size_t uu____0 = (size_t)72U - (size_t)1U;
 2990|  25.9k|  buffer[uu____0] = (uint32_t)buffer[uu____0] | 128U;
 2991|  25.9k|  libcrux_sha3_simd_portable_load_block_f8(
 2992|  25.9k|      state, Eurydice_array_to_slice((size_t)72U, buffer, uint8_t), (size_t)0U);
  ------------------
  |  |  204|  25.9k|  EURYDICE_SLICE(x, 0,                     \
  |  |  ------------------
  |  |  |  |  169|  25.9k|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|  25.9k|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  205|  25.9k|                 end) /* x is already at an array type, no need for cast */
  ------------------
 2993|  25.9k|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_squeeze_13_f8:
 3081|  25.9k|    size_t start, size_t len) {
 3082|  25.9k|  libcrux_sha3_simd_portable_store_block_f8(self->st, out, start, len);
 3083|  25.9k|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_store_block_f8:
 3038|  25.9k|    uint64_t *s, Eurydice_slice out, size_t start, size_t len) {
 3039|  25.9k|  size_t octets = len / (size_t)8U;
 3040|   233k|  for (size_t i = (size_t)0U; i < octets; i++) {
  ------------------
  |  Branch (3040:31): [True: 207k, False: 25.9k]
  ------------------
 3041|   207k|    size_t i0 = i;
 3042|   207k|    Eurydice_slice uu____0 = Eurydice_slice_subslice3(
  ------------------
  |  |  195|   207k|  EURYDICE_SLICE((t_ptr)s.ptr, (start), (end))
  |  |  ------------------
  |  |  |  |  169|   207k|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|   207k|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3043|   207k|        out, start + (size_t)8U * i0, start + (size_t)8U * i0 + (size_t)8U,
 3044|   207k|        uint8_t *);
 3045|   207k|    uint8_t ret[8U];
 3046|   207k|    core_num__u64__to_le_bytes(
 3047|   207k|        libcrux_sha3_traits_get_ij_04(s, i0 / (size_t)5U, i0 % (size_t)5U)[0U],
 3048|   207k|        ret);
 3049|   207k|    Eurydice_slice_copy(
  ------------------
  |  |  229|   207k|  memcpy(dst.ptr, src.ptr, dst.len * sizeof(t))
  ------------------
 3050|   207k|        uu____0, Eurydice_array_to_slice((size_t)8U, ret, uint8_t), uint8_t);
 3051|   207k|  }
 3052|  25.9k|  size_t remaining = len % (size_t)8U;
 3053|  25.9k|  if (remaining > (size_t)0U) {
  ------------------
  |  Branch (3053:7): [True: 0, False: 25.9k]
  ------------------
 3054|      0|    Eurydice_slice uu____1 = Eurydice_slice_subslice3(
  ------------------
  |  |  195|      0|  EURYDICE_SLICE((t_ptr)s.ptr, (start), (end))
  |  |  ------------------
  |  |  |  |  169|      0|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3055|      0|        out, start + len - remaining, start + len, uint8_t *);
 3056|      0|    uint8_t ret[8U];
 3057|      0|    core_num__u64__to_le_bytes(
 3058|      0|        libcrux_sha3_traits_get_ij_04(s, octets / (size_t)5U,
 3059|      0|                                      octets % (size_t)5U)[0U],
 3060|      0|        ret);
 3061|      0|    Eurydice_slice_copy(
  ------------------
  |  |  229|      0|  memcpy(dst.ptr, src.ptr, dst.len * sizeof(t))
  ------------------
 3062|      0|        uu____1,
 3063|      0|        Eurydice_array_to_subslice3(ret, (size_t)0U, remaining, uint8_t *),
 3064|      0|        uint8_t);
 3065|      0|  }
 3066|  25.9k|}
libcrux_mlkem768_sha3.c:core_num__u64__to_le_bytes:
  327|  17.8M|static inline void core_num__u64__to_le_bytes(uint64_t v, uint8_t buf[8]) {
  328|  17.8M|  store64_le(buf, v);
  329|  17.8M|}
libcrux_mlkem768_sha3.c:store64_le:
   48|  17.8M|{
   49|  17.8M|	dst[0] = src & 0xff;
   50|  17.8M|	dst[1] = (src >> 8) & 0xff;
   51|  17.8M|	dst[2] = (src >> 16) & 0xff;
   52|  17.8M|	dst[3] = (src >> 24) & 0xff;
   53|  17.8M|	dst[4] = (src >> 32) & 0xff;
   54|  17.8M|	dst[5] = (src >> 40) & 0xff;
   55|  17.8M|	dst[6] = (src >> 48) & 0xff;
   56|  17.8M|	dst[7] = (src >> 56) & 0xff;
   57|  17.8M|}
libcrux_mlkem768_sha3.c:libcrux_sha3_generic_keccak_keccakf1600_80_04:
 2943|  1.13M|    libcrux_sha3_generic_keccak_KeccakState_17 *self) {
 2944|  28.4M|  for (size_t i = (size_t)0U; i < (size_t)24U; i++) {
  ------------------
  |  Branch (2944:31): [True: 27.2M, False: 1.13M]
  ------------------
 2945|  27.2M|    size_t i0 = i;
 2946|  27.2M|    uint64_t t[5U];
 2947|  27.2M|    libcrux_sha3_generic_keccak_theta_80_04(self, t);
 2948|  27.2M|    libcrux_sha3_generic_keccak_KeccakState_17 *uu____0 = self;
 2949|  27.2M|    uint64_t uu____1[5U];
 2950|  27.2M|    memcpy(uu____1, t, (size_t)5U * sizeof(uint64_t));
 2951|  27.2M|    libcrux_sha3_generic_keccak_rho_80_04(uu____0, uu____1);
 2952|  27.2M|    libcrux_sha3_generic_keccak_pi_80_04(self);
 2953|  27.2M|    libcrux_sha3_generic_keccak_chi_80_04(self);
 2954|  27.2M|    libcrux_sha3_generic_keccak_iota_80_04(self, i0);
 2955|  27.2M|  }
 2956|  1.13M|}
libcrux_mlkem768_sha3.c:libcrux_sha3_generic_keccak_theta_80_04:
 1557|  27.2M|    libcrux_sha3_generic_keccak_KeccakState_17 *self, uint64_t ret[5U]) {
 1558|  27.2M|  uint64_t c[5U] = {
 1559|  27.2M|      libcrux_sha3_simd_portable_xor5_d2(
 1560|  27.2M|          libcrux_sha3_generic_keccak_index_c2_04(
 1561|  27.2M|              self, (KRML_CLITERAL(size_t_x2){.fst = (size_t)0U,
  ------------------
  |  |  154|  27.2M|#define KRML_CLITERAL(type) (type)
  ------------------
 1562|  27.2M|                                              .snd = (size_t)0U}))[0U],
 1563|  27.2M|          libcrux_sha3_generic_keccak_index_c2_04(
 1564|  27.2M|              self, (KRML_CLITERAL(size_t_x2){.fst = (size_t)1U,
  ------------------
  |  |  154|  27.2M|#define KRML_CLITERAL(type) (type)
  ------------------
 1565|  27.2M|                                              .snd = (size_t)0U}))[0U],
 1566|  27.2M|          libcrux_sha3_generic_keccak_index_c2_04(
 1567|  27.2M|              self, (KRML_CLITERAL(size_t_x2){.fst = (size_t)2U,
  ------------------
  |  |  154|  27.2M|#define KRML_CLITERAL(type) (type)
  ------------------
 1568|  27.2M|                                              .snd = (size_t)0U}))[0U],
 1569|  27.2M|          libcrux_sha3_generic_keccak_index_c2_04(
 1570|  27.2M|              self, (KRML_CLITERAL(size_t_x2){.fst = (size_t)3U,
  ------------------
  |  |  154|  27.2M|#define KRML_CLITERAL(type) (type)
  ------------------
 1571|  27.2M|                                              .snd = (size_t)0U}))[0U],
 1572|  27.2M|          libcrux_sha3_generic_keccak_index_c2_04(
 1573|  27.2M|              self, (KRML_CLITERAL(size_t_x2){.fst = (size_t)4U,
  ------------------
  |  |  154|  27.2M|#define KRML_CLITERAL(type) (type)
  ------------------
 1574|  27.2M|                                              .snd = (size_t)0U}))[0U]),
 1575|  27.2M|      libcrux_sha3_simd_portable_xor5_d2(
 1576|  27.2M|          libcrux_sha3_generic_keccak_index_c2_04(
 1577|  27.2M|              self, (KRML_CLITERAL(size_t_x2){.fst = (size_t)0U,
  ------------------
  |  |  154|  27.2M|#define KRML_CLITERAL(type) (type)
  ------------------
 1578|  27.2M|                                              .snd = (size_t)1U}))[0U],
 1579|  27.2M|          libcrux_sha3_generic_keccak_index_c2_04(
 1580|  27.2M|              self, (KRML_CLITERAL(size_t_x2){.fst = (size_t)1U,
  ------------------
  |  |  154|  27.2M|#define KRML_CLITERAL(type) (type)
  ------------------
 1581|  27.2M|                                              .snd = (size_t)1U}))[0U],
 1582|  27.2M|          libcrux_sha3_generic_keccak_index_c2_04(
 1583|  27.2M|              self, (KRML_CLITERAL(size_t_x2){.fst = (size_t)2U,
  ------------------
  |  |  154|  27.2M|#define KRML_CLITERAL(type) (type)
  ------------------
 1584|  27.2M|                                              .snd = (size_t)1U}))[0U],
 1585|  27.2M|          libcrux_sha3_generic_keccak_index_c2_04(
 1586|  27.2M|              self, (KRML_CLITERAL(size_t_x2){.fst = (size_t)3U,
  ------------------
  |  |  154|  27.2M|#define KRML_CLITERAL(type) (type)
  ------------------
 1587|  27.2M|                                              .snd = (size_t)1U}))[0U],
 1588|  27.2M|          libcrux_sha3_generic_keccak_index_c2_04(
 1589|  27.2M|              self, (KRML_CLITERAL(size_t_x2){.fst = (size_t)4U,
  ------------------
  |  |  154|  27.2M|#define KRML_CLITERAL(type) (type)
  ------------------
 1590|  27.2M|                                              .snd = (size_t)1U}))[0U]),
 1591|  27.2M|      libcrux_sha3_simd_portable_xor5_d2(
 1592|  27.2M|          libcrux_sha3_generic_keccak_index_c2_04(
 1593|  27.2M|              self, (KRML_CLITERAL(size_t_x2){.fst = (size_t)0U,
  ------------------
  |  |  154|  27.2M|#define KRML_CLITERAL(type) (type)
  ------------------
 1594|  27.2M|                                              .snd = (size_t)2U}))[0U],
 1595|  27.2M|          libcrux_sha3_generic_keccak_index_c2_04(
 1596|  27.2M|              self, (KRML_CLITERAL(size_t_x2){.fst = (size_t)1U,
  ------------------
  |  |  154|  27.2M|#define KRML_CLITERAL(type) (type)
  ------------------
 1597|  27.2M|                                              .snd = (size_t)2U}))[0U],
 1598|  27.2M|          libcrux_sha3_generic_keccak_index_c2_04(
 1599|  27.2M|              self, (KRML_CLITERAL(size_t_x2){.fst = (size_t)2U,
  ------------------
  |  |  154|  27.2M|#define KRML_CLITERAL(type) (type)
  ------------------
 1600|  27.2M|                                              .snd = (size_t)2U}))[0U],
 1601|  27.2M|          libcrux_sha3_generic_keccak_index_c2_04(
 1602|  27.2M|              self, (KRML_CLITERAL(size_t_x2){.fst = (size_t)3U,
  ------------------
  |  |  154|  27.2M|#define KRML_CLITERAL(type) (type)
  ------------------
 1603|  27.2M|                                              .snd = (size_t)2U}))[0U],
 1604|  27.2M|          libcrux_sha3_generic_keccak_index_c2_04(
 1605|  27.2M|              self, (KRML_CLITERAL(size_t_x2){.fst = (size_t)4U,
  ------------------
  |  |  154|  27.2M|#define KRML_CLITERAL(type) (type)
  ------------------
 1606|  27.2M|                                              .snd = (size_t)2U}))[0U]),
 1607|  27.2M|      libcrux_sha3_simd_portable_xor5_d2(
 1608|  27.2M|          libcrux_sha3_generic_keccak_index_c2_04(
 1609|  27.2M|              self, (KRML_CLITERAL(size_t_x2){.fst = (size_t)0U,
  ------------------
  |  |  154|  27.2M|#define KRML_CLITERAL(type) (type)
  ------------------
 1610|  27.2M|                                              .snd = (size_t)3U}))[0U],
 1611|  27.2M|          libcrux_sha3_generic_keccak_index_c2_04(
 1612|  27.2M|              self, (KRML_CLITERAL(size_t_x2){.fst = (size_t)1U,
  ------------------
  |  |  154|  27.2M|#define KRML_CLITERAL(type) (type)
  ------------------
 1613|  27.2M|                                              .snd = (size_t)3U}))[0U],
 1614|  27.2M|          libcrux_sha3_generic_keccak_index_c2_04(
 1615|  27.2M|              self, (KRML_CLITERAL(size_t_x2){.fst = (size_t)2U,
  ------------------
  |  |  154|  27.2M|#define KRML_CLITERAL(type) (type)
  ------------------
 1616|  27.2M|                                              .snd = (size_t)3U}))[0U],
 1617|  27.2M|          libcrux_sha3_generic_keccak_index_c2_04(
 1618|  27.2M|              self, (KRML_CLITERAL(size_t_x2){.fst = (size_t)3U,
  ------------------
  |  |  154|  27.2M|#define KRML_CLITERAL(type) (type)
  ------------------
 1619|  27.2M|                                              .snd = (size_t)3U}))[0U],
 1620|  27.2M|          libcrux_sha3_generic_keccak_index_c2_04(
 1621|  27.2M|              self, (KRML_CLITERAL(size_t_x2){.fst = (size_t)4U,
  ------------------
  |  |  154|  27.2M|#define KRML_CLITERAL(type) (type)
  ------------------
 1622|  27.2M|                                              .snd = (size_t)3U}))[0U]),
 1623|  27.2M|      libcrux_sha3_simd_portable_xor5_d2(
 1624|  27.2M|          libcrux_sha3_generic_keccak_index_c2_04(
 1625|  27.2M|              self, (KRML_CLITERAL(size_t_x2){.fst = (size_t)0U,
  ------------------
  |  |  154|  27.2M|#define KRML_CLITERAL(type) (type)
  ------------------
 1626|  27.2M|                                              .snd = (size_t)4U}))[0U],
 1627|  27.2M|          libcrux_sha3_generic_keccak_index_c2_04(
 1628|  27.2M|              self, (KRML_CLITERAL(size_t_x2){.fst = (size_t)1U,
  ------------------
  |  |  154|  27.2M|#define KRML_CLITERAL(type) (type)
  ------------------
 1629|  27.2M|                                              .snd = (size_t)4U}))[0U],
 1630|  27.2M|          libcrux_sha3_generic_keccak_index_c2_04(
 1631|  27.2M|              self, (KRML_CLITERAL(size_t_x2){.fst = (size_t)2U,
  ------------------
  |  |  154|  27.2M|#define KRML_CLITERAL(type) (type)
  ------------------
 1632|  27.2M|                                              .snd = (size_t)4U}))[0U],
 1633|  27.2M|          libcrux_sha3_generic_keccak_index_c2_04(
 1634|  27.2M|              self, (KRML_CLITERAL(size_t_x2){.fst = (size_t)3U,
  ------------------
  |  |  154|  27.2M|#define KRML_CLITERAL(type) (type)
  ------------------
 1635|  27.2M|                                              .snd = (size_t)4U}))[0U],
 1636|  27.2M|          libcrux_sha3_generic_keccak_index_c2_04(
 1637|  27.2M|              self, (KRML_CLITERAL(size_t_x2){.fst = (size_t)4U,
  ------------------
  |  |  154|  27.2M|#define KRML_CLITERAL(type) (type)
  ------------------
 1638|  27.2M|                                              .snd = (size_t)4U}))[0U])};
 1639|  27.2M|  uint64_t uu____0 = libcrux_sha3_simd_portable_rotate_left1_and_xor_d2(
 1640|  27.2M|      c[((size_t)0U + (size_t)4U) % (size_t)5U],
 1641|  27.2M|      c[((size_t)0U + (size_t)1U) % (size_t)5U]);
 1642|  27.2M|  uint64_t uu____1 = libcrux_sha3_simd_portable_rotate_left1_and_xor_d2(
 1643|  27.2M|      c[((size_t)1U + (size_t)4U) % (size_t)5U],
 1644|  27.2M|      c[((size_t)1U + (size_t)1U) % (size_t)5U]);
 1645|  27.2M|  uint64_t uu____2 = libcrux_sha3_simd_portable_rotate_left1_and_xor_d2(
 1646|  27.2M|      c[((size_t)2U + (size_t)4U) % (size_t)5U],
 1647|  27.2M|      c[((size_t)2U + (size_t)1U) % (size_t)5U]);
 1648|  27.2M|  uint64_t uu____3 = libcrux_sha3_simd_portable_rotate_left1_and_xor_d2(
 1649|  27.2M|      c[((size_t)3U + (size_t)4U) % (size_t)5U],
 1650|  27.2M|      c[((size_t)3U + (size_t)1U) % (size_t)5U]);
 1651|  27.2M|  ret[0U] = uu____0;
 1652|  27.2M|  ret[1U] = uu____1;
 1653|  27.2M|  ret[2U] = uu____2;
 1654|  27.2M|  ret[3U] = uu____3;
 1655|  27.2M|  ret[4U] = libcrux_sha3_simd_portable_rotate_left1_and_xor_d2(
 1656|  27.2M|      c[((size_t)4U + (size_t)4U) % (size_t)5U],
 1657|  27.2M|      c[((size_t)4U + (size_t)1U) % (size_t)5U]);
 1658|  27.2M|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_xor5_d2:
 1333|   136M|    uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e) {
 1334|   136M|  return libcrux_sha3_simd_portable__veor5q_u64(a, b, c, d, e);
 1335|   136M|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable__veor5q_u64:
 1325|   136M|    uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e) {
 1326|   136M|  return (((a ^ b) ^ c) ^ d) ^ e;
 1327|   136M|}
libcrux_mlkem768_sha3.c:libcrux_sha3_generic_keccak_index_c2_04:
 1542|  4.09G|    libcrux_sha3_generic_keccak_KeccakState_17 *self, size_t_x2 index) {
 1543|  4.09G|  return libcrux_sha3_traits_get_ij_04(self->st, index.fst, index.snd);
 1544|  4.09G|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_rotate_left1_and_xor_d2:
 1358|   136M|libcrux_sha3_simd_portable_rotate_left1_and_xor_d2(uint64_t a, uint64_t b) {
 1359|   136M|  return libcrux_sha3_simd_portable__vrax1q_u64(a, b);
 1360|   136M|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable__vrax1q_u64:
 1349|   136M|libcrux_sha3_simd_portable__vrax1q_u64(uint64_t a, uint64_t b) {
 1350|   136M|  uint64_t uu____0 = a;
 1351|   136M|  return uu____0 ^ libcrux_sha3_simd_portable_rotate_left_76(b);
 1352|   136M|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_rotate_left_76:
 1344|   163M|libcrux_sha3_simd_portable_rotate_left_76(uint64_t x) {
 1345|   163M|  return core_num__u64__rotate_left(x, (uint32_t)(int32_t)1);
 1346|   163M|}
libcrux_mlkem768_sha3.c:core_num__u64__rotate_left:
  342|   791M|static inline uint64_t core_num__u64__rotate_left(uint64_t x0, uint32_t x1) {
  343|   791M|  return (x0 << x1 | x0 >> (64 - x1));
  344|   791M|}
libcrux_mlkem768_sha3.c:libcrux_sha3_generic_keccak_rho_80_04:
 2540|  27.2M|    libcrux_sha3_generic_keccak_KeccakState_17 *self, uint64_t t[5U]) {
 2541|  27.2M|  libcrux_sha3_generic_keccak_set_80_04(
 2542|  27.2M|      self, (size_t)0U, (size_t)0U,
 2543|  27.2M|      libcrux_sha3_simd_portable_xor_d2(
 2544|  27.2M|          libcrux_sha3_generic_keccak_index_c2_04(
 2545|  27.2M|              self, (KRML_CLITERAL(size_t_x2){.fst = (size_t)0U,
  ------------------
  |  |  154|  27.2M|#define KRML_CLITERAL(type) (type)
  ------------------
 2546|  27.2M|                                              .snd = (size_t)0U}))[0U],
 2547|  27.2M|          t[0U]));
 2548|  27.2M|  libcrux_sha3_generic_keccak_KeccakState_17 *uu____0 = self;
 2549|  27.2M|  libcrux_sha3_generic_keccak_set_80_04(
 2550|  27.2M|      uu____0, (size_t)1U, (size_t)0U,
 2551|  27.2M|      libcrux_sha3_simd_portable_xor_and_rotate_d2_02(
 2552|  27.2M|          libcrux_sha3_generic_keccak_index_c2_04(
 2553|  27.2M|              self, (KRML_CLITERAL(size_t_x2){.fst = (size_t)1U,
  ------------------
  |  |  154|  27.2M|#define KRML_CLITERAL(type) (type)
  ------------------
 2554|  27.2M|                                              .snd = (size_t)0U}))[0U],
 2555|  27.2M|          t[0U]));
 2556|  27.2M|  libcrux_sha3_generic_keccak_KeccakState_17 *uu____1 = self;
 2557|  27.2M|  libcrux_sha3_generic_keccak_set_80_04(
 2558|  27.2M|      uu____1, (size_t)2U, (size_t)0U,
 2559|  27.2M|      libcrux_sha3_simd_portable_xor_and_rotate_d2_ac(
 2560|  27.2M|          libcrux_sha3_generic_keccak_index_c2_04(
 2561|  27.2M|              self, (KRML_CLITERAL(size_t_x2){.fst = (size_t)2U,
  ------------------
  |  |  154|  27.2M|#define KRML_CLITERAL(type) (type)
  ------------------
 2562|  27.2M|                                              .snd = (size_t)0U}))[0U],
 2563|  27.2M|          t[0U]));
 2564|  27.2M|  libcrux_sha3_generic_keccak_KeccakState_17 *uu____2 = self;
 2565|  27.2M|  libcrux_sha3_generic_keccak_set_80_04(
 2566|  27.2M|      uu____2, (size_t)3U, (size_t)0U,
 2567|  27.2M|      libcrux_sha3_simd_portable_xor_and_rotate_d2_020(
 2568|  27.2M|          libcrux_sha3_generic_keccak_index_c2_04(
 2569|  27.2M|              self, (KRML_CLITERAL(size_t_x2){.fst = (size_t)3U,
  ------------------
  |  |  154|  27.2M|#define KRML_CLITERAL(type) (type)
  ------------------
 2570|  27.2M|                                              .snd = (size_t)0U}))[0U],
 2571|  27.2M|          t[0U]));
 2572|  27.2M|  libcrux_sha3_generic_keccak_KeccakState_17 *uu____3 = self;
 2573|  27.2M|  libcrux_sha3_generic_keccak_set_80_04(
 2574|  27.2M|      uu____3, (size_t)4U, (size_t)0U,
 2575|  27.2M|      libcrux_sha3_simd_portable_xor_and_rotate_d2_a9(
 2576|  27.2M|          libcrux_sha3_generic_keccak_index_c2_04(
 2577|  27.2M|              self, (KRML_CLITERAL(size_t_x2){.fst = (size_t)4U,
  ------------------
  |  |  154|  27.2M|#define KRML_CLITERAL(type) (type)
  ------------------
 2578|  27.2M|                                              .snd = (size_t)0U}))[0U],
 2579|  27.2M|          t[0U]));
 2580|  27.2M|  libcrux_sha3_generic_keccak_KeccakState_17 *uu____4 = self;
 2581|  27.2M|  libcrux_sha3_generic_keccak_set_80_04(
 2582|  27.2M|      uu____4, (size_t)0U, (size_t)1U,
 2583|  27.2M|      libcrux_sha3_simd_portable_xor_and_rotate_d2_76(
 2584|  27.2M|          libcrux_sha3_generic_keccak_index_c2_04(
 2585|  27.2M|              self, (KRML_CLITERAL(size_t_x2){.fst = (size_t)0U,
  ------------------
  |  |  154|  27.2M|#define KRML_CLITERAL(type) (type)
  ------------------
 2586|  27.2M|                                              .snd = (size_t)1U}))[0U],
 2587|  27.2M|          t[1U]));
 2588|  27.2M|  libcrux_sha3_generic_keccak_KeccakState_17 *uu____5 = self;
 2589|  27.2M|  libcrux_sha3_generic_keccak_set_80_04(
 2590|  27.2M|      uu____5, (size_t)1U, (size_t)1U,
 2591|  27.2M|      libcrux_sha3_simd_portable_xor_and_rotate_d2_58(
 2592|  27.2M|          libcrux_sha3_generic_keccak_index_c2_04(
 2593|  27.2M|              self, (KRML_CLITERAL(size_t_x2){.fst = (size_t)1U,
  ------------------
  |  |  154|  27.2M|#define KRML_CLITERAL(type) (type)
  ------------------
 2594|  27.2M|                                              .snd = (size_t)1U}))[0U],
 2595|  27.2M|          t[1U]));
 2596|  27.2M|  libcrux_sha3_generic_keccak_KeccakState_17 *uu____6 = self;
 2597|  27.2M|  libcrux_sha3_generic_keccak_set_80_04(
 2598|  27.2M|      uu____6, (size_t)2U, (size_t)1U,
 2599|  27.2M|      libcrux_sha3_simd_portable_xor_and_rotate_d2_e0(
 2600|  27.2M|          libcrux_sha3_generic_keccak_index_c2_04(
 2601|  27.2M|              self, (KRML_CLITERAL(size_t_x2){.fst = (size_t)2U,
  ------------------
  |  |  154|  27.2M|#define KRML_CLITERAL(type) (type)
  ------------------
 2602|  27.2M|                                              .snd = (size_t)1U}))[0U],
 2603|  27.2M|          t[1U]));
 2604|  27.2M|  libcrux_sha3_generic_keccak_KeccakState_17 *uu____7 = self;
 2605|  27.2M|  libcrux_sha3_generic_keccak_set_80_04(
 2606|  27.2M|      uu____7, (size_t)3U, (size_t)1U,
 2607|  27.2M|      libcrux_sha3_simd_portable_xor_and_rotate_d2_63(
 2608|  27.2M|          libcrux_sha3_generic_keccak_index_c2_04(
 2609|  27.2M|              self, (KRML_CLITERAL(size_t_x2){.fst = (size_t)3U,
  ------------------
  |  |  154|  27.2M|#define KRML_CLITERAL(type) (type)
  ------------------
 2610|  27.2M|                                              .snd = (size_t)1U}))[0U],
 2611|  27.2M|          t[1U]));
 2612|  27.2M|  libcrux_sha3_generic_keccak_KeccakState_17 *uu____8 = self;
 2613|  27.2M|  libcrux_sha3_generic_keccak_set_80_04(
 2614|  27.2M|      uu____8, (size_t)4U, (size_t)1U,
 2615|  27.2M|      libcrux_sha3_simd_portable_xor_and_rotate_d2_6a(
 2616|  27.2M|          libcrux_sha3_generic_keccak_index_c2_04(
 2617|  27.2M|              self, (KRML_CLITERAL(size_t_x2){.fst = (size_t)4U,
  ------------------
  |  |  154|  27.2M|#define KRML_CLITERAL(type) (type)
  ------------------
 2618|  27.2M|                                              .snd = (size_t)1U}))[0U],
 2619|  27.2M|          t[1U]));
 2620|  27.2M|  libcrux_sha3_generic_keccak_KeccakState_17 *uu____9 = self;
 2621|  27.2M|  libcrux_sha3_generic_keccak_set_80_04(
 2622|  27.2M|      uu____9, (size_t)0U, (size_t)2U,
 2623|  27.2M|      libcrux_sha3_simd_portable_xor_and_rotate_d2_ab(
 2624|  27.2M|          libcrux_sha3_generic_keccak_index_c2_04(
 2625|  27.2M|              self, (KRML_CLITERAL(size_t_x2){.fst = (size_t)0U,
  ------------------
  |  |  154|  27.2M|#define KRML_CLITERAL(type) (type)
  ------------------
 2626|  27.2M|                                              .snd = (size_t)2U}))[0U],
 2627|  27.2M|          t[2U]));
 2628|  27.2M|  libcrux_sha3_generic_keccak_KeccakState_17 *uu____10 = self;
 2629|  27.2M|  libcrux_sha3_generic_keccak_set_80_04(
 2630|  27.2M|      uu____10, (size_t)1U, (size_t)2U,
 2631|  27.2M|      libcrux_sha3_simd_portable_xor_and_rotate_d2_5b(
 2632|  27.2M|          libcrux_sha3_generic_keccak_index_c2_04(
 2633|  27.2M|              self, (KRML_CLITERAL(size_t_x2){.fst = (size_t)1U,
  ------------------
  |  |  154|  27.2M|#define KRML_CLITERAL(type) (type)
  ------------------
 2634|  27.2M|                                              .snd = (size_t)2U}))[0U],
 2635|  27.2M|          t[2U]));
 2636|  27.2M|  libcrux_sha3_generic_keccak_KeccakState_17 *uu____11 = self;
 2637|  27.2M|  libcrux_sha3_generic_keccak_set_80_04(
 2638|  27.2M|      uu____11, (size_t)2U, (size_t)2U,
 2639|  27.2M|      libcrux_sha3_simd_portable_xor_and_rotate_d2_6f(
 2640|  27.2M|          libcrux_sha3_generic_keccak_index_c2_04(
 2641|  27.2M|              self, (KRML_CLITERAL(size_t_x2){.fst = (size_t)2U,
  ------------------
  |  |  154|  27.2M|#define KRML_CLITERAL(type) (type)
  ------------------
 2642|  27.2M|                                              .snd = (size_t)2U}))[0U],
 2643|  27.2M|          t[2U]));
 2644|  27.2M|  libcrux_sha3_generic_keccak_KeccakState_17 *uu____12 = self;
 2645|  27.2M|  libcrux_sha3_generic_keccak_set_80_04(
 2646|  27.2M|      uu____12, (size_t)3U, (size_t)2U,
 2647|  27.2M|      libcrux_sha3_simd_portable_xor_and_rotate_d2_62(
 2648|  27.2M|          libcrux_sha3_generic_keccak_index_c2_04(
 2649|  27.2M|              self, (KRML_CLITERAL(size_t_x2){.fst = (size_t)3U,
  ------------------
  |  |  154|  27.2M|#define KRML_CLITERAL(type) (type)
  ------------------
 2650|  27.2M|                                              .snd = (size_t)2U}))[0U],
 2651|  27.2M|          t[2U]));
 2652|  27.2M|  libcrux_sha3_generic_keccak_KeccakState_17 *uu____13 = self;
 2653|  27.2M|  libcrux_sha3_generic_keccak_set_80_04(
 2654|  27.2M|      uu____13, (size_t)4U, (size_t)2U,
 2655|  27.2M|      libcrux_sha3_simd_portable_xor_and_rotate_d2_23(
 2656|  27.2M|          libcrux_sha3_generic_keccak_index_c2_04(
 2657|  27.2M|              self, (KRML_CLITERAL(size_t_x2){.fst = (size_t)4U,
  ------------------
  |  |  154|  27.2M|#define KRML_CLITERAL(type) (type)
  ------------------
 2658|  27.2M|                                              .snd = (size_t)2U}))[0U],
 2659|  27.2M|          t[2U]));
 2660|  27.2M|  libcrux_sha3_generic_keccak_KeccakState_17 *uu____14 = self;
 2661|  27.2M|  libcrux_sha3_generic_keccak_set_80_04(
 2662|  27.2M|      uu____14, (size_t)0U, (size_t)3U,
 2663|  27.2M|      libcrux_sha3_simd_portable_xor_and_rotate_d2_37(
 2664|  27.2M|          libcrux_sha3_generic_keccak_index_c2_04(
 2665|  27.2M|              self, (KRML_CLITERAL(size_t_x2){.fst = (size_t)0U,
  ------------------
  |  |  154|  27.2M|#define KRML_CLITERAL(type) (type)
  ------------------
 2666|  27.2M|                                              .snd = (size_t)3U}))[0U],
 2667|  27.2M|          t[3U]));
 2668|  27.2M|  libcrux_sha3_generic_keccak_KeccakState_17 *uu____15 = self;
 2669|  27.2M|  libcrux_sha3_generic_keccak_set_80_04(
 2670|  27.2M|      uu____15, (size_t)1U, (size_t)3U,
 2671|  27.2M|      libcrux_sha3_simd_portable_xor_and_rotate_d2_bb(
 2672|  27.2M|          libcrux_sha3_generic_keccak_index_c2_04(
 2673|  27.2M|              self, (KRML_CLITERAL(size_t_x2){.fst = (size_t)1U,
  ------------------
  |  |  154|  27.2M|#define KRML_CLITERAL(type) (type)
  ------------------
 2674|  27.2M|                                              .snd = (size_t)3U}))[0U],
 2675|  27.2M|          t[3U]));
 2676|  27.2M|  libcrux_sha3_generic_keccak_KeccakState_17 *uu____16 = self;
 2677|  27.2M|  libcrux_sha3_generic_keccak_set_80_04(
 2678|  27.2M|      uu____16, (size_t)2U, (size_t)3U,
 2679|  27.2M|      libcrux_sha3_simd_portable_xor_and_rotate_d2_b9(
 2680|  27.2M|          libcrux_sha3_generic_keccak_index_c2_04(
 2681|  27.2M|              self, (KRML_CLITERAL(size_t_x2){.fst = (size_t)2U,
  ------------------
  |  |  154|  27.2M|#define KRML_CLITERAL(type) (type)
  ------------------
 2682|  27.2M|                                              .snd = (size_t)3U}))[0U],
 2683|  27.2M|          t[3U]));
 2684|  27.2M|  libcrux_sha3_generic_keccak_KeccakState_17 *uu____17 = self;
 2685|  27.2M|  libcrux_sha3_generic_keccak_set_80_04(
 2686|  27.2M|      uu____17, (size_t)3U, (size_t)3U,
 2687|  27.2M|      libcrux_sha3_simd_portable_xor_and_rotate_d2_54(
 2688|  27.2M|          libcrux_sha3_generic_keccak_index_c2_04(
 2689|  27.2M|              self, (KRML_CLITERAL(size_t_x2){.fst = (size_t)3U,
  ------------------
  |  |  154|  27.2M|#define KRML_CLITERAL(type) (type)
  ------------------
 2690|  27.2M|                                              .snd = (size_t)3U}))[0U],
 2691|  27.2M|          t[3U]));
 2692|  27.2M|  libcrux_sha3_generic_keccak_KeccakState_17 *uu____18 = self;
 2693|  27.2M|  libcrux_sha3_generic_keccak_set_80_04(
 2694|  27.2M|      uu____18, (size_t)4U, (size_t)3U,
 2695|  27.2M|      libcrux_sha3_simd_portable_xor_and_rotate_d2_4c(
 2696|  27.2M|          libcrux_sha3_generic_keccak_index_c2_04(
 2697|  27.2M|              self, (KRML_CLITERAL(size_t_x2){.fst = (size_t)4U,
  ------------------
  |  |  154|  27.2M|#define KRML_CLITERAL(type) (type)
  ------------------
 2698|  27.2M|                                              .snd = (size_t)3U}))[0U],
 2699|  27.2M|          t[3U]));
 2700|  27.2M|  libcrux_sha3_generic_keccak_KeccakState_17 *uu____19 = self;
 2701|  27.2M|  libcrux_sha3_generic_keccak_set_80_04(
 2702|  27.2M|      uu____19, (size_t)0U, (size_t)4U,
 2703|  27.2M|      libcrux_sha3_simd_portable_xor_and_rotate_d2_ce(
 2704|  27.2M|          libcrux_sha3_generic_keccak_index_c2_04(
 2705|  27.2M|              self, (KRML_CLITERAL(size_t_x2){.fst = (size_t)0U,
  ------------------
  |  |  154|  27.2M|#define KRML_CLITERAL(type) (type)
  ------------------
 2706|  27.2M|                                              .snd = (size_t)4U}))[0U],
 2707|  27.2M|          t[4U]));
 2708|  27.2M|  libcrux_sha3_generic_keccak_KeccakState_17 *uu____20 = self;
 2709|  27.2M|  libcrux_sha3_generic_keccak_set_80_04(
 2710|  27.2M|      uu____20, (size_t)1U, (size_t)4U,
 2711|  27.2M|      libcrux_sha3_simd_portable_xor_and_rotate_d2_77(
 2712|  27.2M|          libcrux_sha3_generic_keccak_index_c2_04(
 2713|  27.2M|              self, (KRML_CLITERAL(size_t_x2){.fst = (size_t)1U,
  ------------------
  |  |  154|  27.2M|#define KRML_CLITERAL(type) (type)
  ------------------
 2714|  27.2M|                                              .snd = (size_t)4U}))[0U],
 2715|  27.2M|          t[4U]));
 2716|  27.2M|  libcrux_sha3_generic_keccak_KeccakState_17 *uu____21 = self;
 2717|  27.2M|  libcrux_sha3_generic_keccak_set_80_04(
 2718|  27.2M|      uu____21, (size_t)2U, (size_t)4U,
 2719|  27.2M|      libcrux_sha3_simd_portable_xor_and_rotate_d2_25(
 2720|  27.2M|          libcrux_sha3_generic_keccak_index_c2_04(
 2721|  27.2M|              self, (KRML_CLITERAL(size_t_x2){.fst = (size_t)2U,
  ------------------
  |  |  154|  27.2M|#define KRML_CLITERAL(type) (type)
  ------------------
 2722|  27.2M|                                              .snd = (size_t)4U}))[0U],
 2723|  27.2M|          t[4U]));
 2724|  27.2M|  libcrux_sha3_generic_keccak_KeccakState_17 *uu____22 = self;
 2725|  27.2M|  libcrux_sha3_generic_keccak_set_80_04(
 2726|  27.2M|      uu____22, (size_t)3U, (size_t)4U,
 2727|  27.2M|      libcrux_sha3_simd_portable_xor_and_rotate_d2_af(
 2728|  27.2M|          libcrux_sha3_generic_keccak_index_c2_04(
 2729|  27.2M|              self, (KRML_CLITERAL(size_t_x2){.fst = (size_t)3U,
  ------------------
  |  |  154|  27.2M|#define KRML_CLITERAL(type) (type)
  ------------------
 2730|  27.2M|                                              .snd = (size_t)4U}))[0U],
 2731|  27.2M|          t[4U]));
 2732|  27.2M|  libcrux_sha3_generic_keccak_KeccakState_17 *uu____23 = self;
 2733|  27.2M|  libcrux_sha3_generic_keccak_set_80_04(
 2734|  27.2M|      uu____23, (size_t)4U, (size_t)4U,
 2735|  27.2M|      libcrux_sha3_simd_portable_xor_and_rotate_d2_fd(
 2736|  27.2M|          libcrux_sha3_generic_keccak_index_c2_04(
 2737|  27.2M|              self, (KRML_CLITERAL(size_t_x2){.fst = (size_t)4U,
  ------------------
  |  |  154|  27.2M|#define KRML_CLITERAL(type) (type)
  ------------------
 2738|  27.2M|                                              .snd = (size_t)4U}))[0U],
 2739|  27.2M|          t[4U]));
 2740|  27.2M|}
libcrux_mlkem768_sha3.c:libcrux_sha3_generic_keccak_set_80_04:
 1672|  2.04G|    uint64_t v) {
 1673|  2.04G|  libcrux_sha3_traits_set_ij_04(self->st, i, j, v);
 1674|  2.04G|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_xor_d2:
 1392|  27.2M|                                                                  uint64_t b) {
 1393|  27.2M|  return a ^ b;
 1394|  27.2M|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_xor_and_rotate_d2_02:
 1708|  27.2M|libcrux_sha3_simd_portable_xor_and_rotate_d2_02(uint64_t a, uint64_t b) {
 1709|  27.2M|  return libcrux_sha3_simd_portable__vxarq_u64_02(a, b);
 1710|  27.2M|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable__vxarq_u64_02:
 1694|  27.2M|libcrux_sha3_simd_portable__vxarq_u64_02(uint64_t a, uint64_t b) {
 1695|  27.2M|  return libcrux_sha3_simd_portable_rotate_left_02(a ^ b);
 1696|  27.2M|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_rotate_left_02:
 1683|  27.2M|libcrux_sha3_simd_portable_rotate_left_02(uint64_t x) {
 1684|  27.2M|  return core_num__u64__rotate_left(x, (uint32_t)(int32_t)36);
 1685|  27.2M|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_xor_and_rotate_d2_ac:
 1744|  27.2M|libcrux_sha3_simd_portable_xor_and_rotate_d2_ac(uint64_t a, uint64_t b) {
 1745|  27.2M|  return libcrux_sha3_simd_portable__vxarq_u64_ac(a, b);
 1746|  27.2M|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable__vxarq_u64_ac:
 1730|  27.2M|libcrux_sha3_simd_portable__vxarq_u64_ac(uint64_t a, uint64_t b) {
 1731|  27.2M|  return libcrux_sha3_simd_portable_rotate_left_ac(a ^ b);
 1732|  27.2M|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_rotate_left_ac:
 1719|  27.2M|libcrux_sha3_simd_portable_rotate_left_ac(uint64_t x) {
 1720|  27.2M|  return core_num__u64__rotate_left(x, (uint32_t)(int32_t)3);
 1721|  27.2M|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_xor_and_rotate_d2_020:
 1780|  27.2M|libcrux_sha3_simd_portable_xor_and_rotate_d2_020(uint64_t a, uint64_t b) {
 1781|  27.2M|  return libcrux_sha3_simd_portable__vxarq_u64_020(a, b);
 1782|  27.2M|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable__vxarq_u64_020:
 1766|  27.2M|libcrux_sha3_simd_portable__vxarq_u64_020(uint64_t a, uint64_t b) {
 1767|  27.2M|  return libcrux_sha3_simd_portable_rotate_left_020(a ^ b);
 1768|  27.2M|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_rotate_left_020:
 1755|  27.2M|libcrux_sha3_simd_portable_rotate_left_020(uint64_t x) {
 1756|  27.2M|  return core_num__u64__rotate_left(x, (uint32_t)(int32_t)41);
 1757|  27.2M|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_xor_and_rotate_d2_a9:
 1816|  27.2M|libcrux_sha3_simd_portable_xor_and_rotate_d2_a9(uint64_t a, uint64_t b) {
 1817|  27.2M|  return libcrux_sha3_simd_portable__vxarq_u64_a9(a, b);
 1818|  27.2M|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable__vxarq_u64_a9:
 1802|  27.2M|libcrux_sha3_simd_portable__vxarq_u64_a9(uint64_t a, uint64_t b) {
 1803|  27.2M|  return libcrux_sha3_simd_portable_rotate_left_a9(a ^ b);
 1804|  27.2M|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_rotate_left_a9:
 1791|  27.2M|libcrux_sha3_simd_portable_rotate_left_a9(uint64_t x) {
 1792|  27.2M|  return core_num__u64__rotate_left(x, (uint32_t)(int32_t)18);
 1793|  27.2M|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_xor_and_rotate_d2_76:
 1841|  27.2M|libcrux_sha3_simd_portable_xor_and_rotate_d2_76(uint64_t a, uint64_t b) {
 1842|  27.2M|  return libcrux_sha3_simd_portable__vxarq_u64_76(a, b);
 1843|  27.2M|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable__vxarq_u64_76:
 1827|  27.2M|libcrux_sha3_simd_portable__vxarq_u64_76(uint64_t a, uint64_t b) {
 1828|  27.2M|  return libcrux_sha3_simd_portable_rotate_left_76(a ^ b);
 1829|  27.2M|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_xor_and_rotate_d2_58:
 1877|  27.2M|libcrux_sha3_simd_portable_xor_and_rotate_d2_58(uint64_t a, uint64_t b) {
 1878|  27.2M|  return libcrux_sha3_simd_portable__vxarq_u64_58(a, b);
 1879|  27.2M|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable__vxarq_u64_58:
 1863|  27.2M|libcrux_sha3_simd_portable__vxarq_u64_58(uint64_t a, uint64_t b) {
 1864|  27.2M|  return libcrux_sha3_simd_portable_rotate_left_58(a ^ b);
 1865|  27.2M|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_rotate_left_58:
 1852|  27.2M|libcrux_sha3_simd_portable_rotate_left_58(uint64_t x) {
 1853|  27.2M|  return core_num__u64__rotate_left(x, (uint32_t)(int32_t)44);
 1854|  27.2M|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_xor_and_rotate_d2_e0:
 1913|  27.2M|libcrux_sha3_simd_portable_xor_and_rotate_d2_e0(uint64_t a, uint64_t b) {
 1914|  27.2M|  return libcrux_sha3_simd_portable__vxarq_u64_e0(a, b);
 1915|  27.2M|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable__vxarq_u64_e0:
 1899|  27.2M|libcrux_sha3_simd_portable__vxarq_u64_e0(uint64_t a, uint64_t b) {
 1900|  27.2M|  return libcrux_sha3_simd_portable_rotate_left_e0(a ^ b);
 1901|  27.2M|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_rotate_left_e0:
 1888|  27.2M|libcrux_sha3_simd_portable_rotate_left_e0(uint64_t x) {
 1889|  27.2M|  return core_num__u64__rotate_left(x, (uint32_t)(int32_t)10);
 1890|  27.2M|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_xor_and_rotate_d2_63:
 1949|  27.2M|libcrux_sha3_simd_portable_xor_and_rotate_d2_63(uint64_t a, uint64_t b) {
 1950|  27.2M|  return libcrux_sha3_simd_portable__vxarq_u64_63(a, b);
 1951|  27.2M|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable__vxarq_u64_63:
 1935|  27.2M|libcrux_sha3_simd_portable__vxarq_u64_63(uint64_t a, uint64_t b) {
 1936|  27.2M|  return libcrux_sha3_simd_portable_rotate_left_63(a ^ b);
 1937|  27.2M|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_rotate_left_63:
 1924|  27.2M|libcrux_sha3_simd_portable_rotate_left_63(uint64_t x) {
 1925|  27.2M|  return core_num__u64__rotate_left(x, (uint32_t)(int32_t)45);
 1926|  27.2M|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_xor_and_rotate_d2_6a:
 1985|  27.2M|libcrux_sha3_simd_portable_xor_and_rotate_d2_6a(uint64_t a, uint64_t b) {
 1986|  27.2M|  return libcrux_sha3_simd_portable__vxarq_u64_6a(a, b);
 1987|  27.2M|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable__vxarq_u64_6a:
 1971|  27.2M|libcrux_sha3_simd_portable__vxarq_u64_6a(uint64_t a, uint64_t b) {
 1972|  27.2M|  return libcrux_sha3_simd_portable_rotate_left_6a(a ^ b);
 1973|  27.2M|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_rotate_left_6a:
 1960|  27.2M|libcrux_sha3_simd_portable_rotate_left_6a(uint64_t x) {
 1961|  27.2M|  return core_num__u64__rotate_left(x, (uint32_t)(int32_t)2);
 1962|  27.2M|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_xor_and_rotate_d2_ab:
 2021|  27.2M|libcrux_sha3_simd_portable_xor_and_rotate_d2_ab(uint64_t a, uint64_t b) {
 2022|  27.2M|  return libcrux_sha3_simd_portable__vxarq_u64_ab(a, b);
 2023|  27.2M|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable__vxarq_u64_ab:
 2007|  27.2M|libcrux_sha3_simd_portable__vxarq_u64_ab(uint64_t a, uint64_t b) {
 2008|  27.2M|  return libcrux_sha3_simd_portable_rotate_left_ab(a ^ b);
 2009|  27.2M|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_rotate_left_ab:
 1996|  27.2M|libcrux_sha3_simd_portable_rotate_left_ab(uint64_t x) {
 1997|  27.2M|  return core_num__u64__rotate_left(x, (uint32_t)(int32_t)62);
 1998|  27.2M|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_xor_and_rotate_d2_5b:
 2057|  27.2M|libcrux_sha3_simd_portable_xor_and_rotate_d2_5b(uint64_t a, uint64_t b) {
 2058|  27.2M|  return libcrux_sha3_simd_portable__vxarq_u64_5b(a, b);
 2059|  27.2M|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable__vxarq_u64_5b:
 2043|  27.2M|libcrux_sha3_simd_portable__vxarq_u64_5b(uint64_t a, uint64_t b) {
 2044|  27.2M|  return libcrux_sha3_simd_portable_rotate_left_5b(a ^ b);
 2045|  27.2M|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_rotate_left_5b:
 2032|  27.2M|libcrux_sha3_simd_portable_rotate_left_5b(uint64_t x) {
 2033|  27.2M|  return core_num__u64__rotate_left(x, (uint32_t)(int32_t)6);
 2034|  27.2M|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_xor_and_rotate_d2_6f:
 2093|  27.2M|libcrux_sha3_simd_portable_xor_and_rotate_d2_6f(uint64_t a, uint64_t b) {
 2094|  27.2M|  return libcrux_sha3_simd_portable__vxarq_u64_6f(a, b);
 2095|  27.2M|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable__vxarq_u64_6f:
 2079|  27.2M|libcrux_sha3_simd_portable__vxarq_u64_6f(uint64_t a, uint64_t b) {
 2080|  27.2M|  return libcrux_sha3_simd_portable_rotate_left_6f(a ^ b);
 2081|  27.2M|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_rotate_left_6f:
 2068|  27.2M|libcrux_sha3_simd_portable_rotate_left_6f(uint64_t x) {
 2069|  27.2M|  return core_num__u64__rotate_left(x, (uint32_t)(int32_t)43);
 2070|  27.2M|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_xor_and_rotate_d2_62:
 2129|  27.2M|libcrux_sha3_simd_portable_xor_and_rotate_d2_62(uint64_t a, uint64_t b) {
 2130|  27.2M|  return libcrux_sha3_simd_portable__vxarq_u64_62(a, b);
 2131|  27.2M|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable__vxarq_u64_62:
 2115|  27.2M|libcrux_sha3_simd_portable__vxarq_u64_62(uint64_t a, uint64_t b) {
 2116|  27.2M|  return libcrux_sha3_simd_portable_rotate_left_62(a ^ b);
 2117|  27.2M|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_rotate_left_62:
 2104|  27.2M|libcrux_sha3_simd_portable_rotate_left_62(uint64_t x) {
 2105|  27.2M|  return core_num__u64__rotate_left(x, (uint32_t)(int32_t)15);
 2106|  27.2M|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_xor_and_rotate_d2_23:
 2165|  27.2M|libcrux_sha3_simd_portable_xor_and_rotate_d2_23(uint64_t a, uint64_t b) {
 2166|  27.2M|  return libcrux_sha3_simd_portable__vxarq_u64_23(a, b);
 2167|  27.2M|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable__vxarq_u64_23:
 2151|  27.2M|libcrux_sha3_simd_portable__vxarq_u64_23(uint64_t a, uint64_t b) {
 2152|  27.2M|  return libcrux_sha3_simd_portable_rotate_left_23(a ^ b);
 2153|  27.2M|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_rotate_left_23:
 2140|  27.2M|libcrux_sha3_simd_portable_rotate_left_23(uint64_t x) {
 2141|  27.2M|  return core_num__u64__rotate_left(x, (uint32_t)(int32_t)61);
 2142|  27.2M|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_xor_and_rotate_d2_37:
 2201|  27.2M|libcrux_sha3_simd_portable_xor_and_rotate_d2_37(uint64_t a, uint64_t b) {
 2202|  27.2M|  return libcrux_sha3_simd_portable__vxarq_u64_37(a, b);
 2203|  27.2M|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable__vxarq_u64_37:
 2187|  27.2M|libcrux_sha3_simd_portable__vxarq_u64_37(uint64_t a, uint64_t b) {
 2188|  27.2M|  return libcrux_sha3_simd_portable_rotate_left_37(a ^ b);
 2189|  27.2M|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_rotate_left_37:
 2176|  27.2M|libcrux_sha3_simd_portable_rotate_left_37(uint64_t x) {
 2177|  27.2M|  return core_num__u64__rotate_left(x, (uint32_t)(int32_t)28);
 2178|  27.2M|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_xor_and_rotate_d2_bb:
 2237|  27.2M|libcrux_sha3_simd_portable_xor_and_rotate_d2_bb(uint64_t a, uint64_t b) {
 2238|  27.2M|  return libcrux_sha3_simd_portable__vxarq_u64_bb(a, b);
 2239|  27.2M|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable__vxarq_u64_bb:
 2223|  27.2M|libcrux_sha3_simd_portable__vxarq_u64_bb(uint64_t a, uint64_t b) {
 2224|  27.2M|  return libcrux_sha3_simd_portable_rotate_left_bb(a ^ b);
 2225|  27.2M|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_rotate_left_bb:
 2212|  27.2M|libcrux_sha3_simd_portable_rotate_left_bb(uint64_t x) {
 2213|  27.2M|  return core_num__u64__rotate_left(x, (uint32_t)(int32_t)55);
 2214|  27.2M|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_xor_and_rotate_d2_b9:
 2273|  27.2M|libcrux_sha3_simd_portable_xor_and_rotate_d2_b9(uint64_t a, uint64_t b) {
 2274|  27.2M|  return libcrux_sha3_simd_portable__vxarq_u64_b9(a, b);
 2275|  27.2M|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable__vxarq_u64_b9:
 2259|  27.2M|libcrux_sha3_simd_portable__vxarq_u64_b9(uint64_t a, uint64_t b) {
 2260|  27.2M|  return libcrux_sha3_simd_portable_rotate_left_b9(a ^ b);
 2261|  27.2M|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_rotate_left_b9:
 2248|  27.2M|libcrux_sha3_simd_portable_rotate_left_b9(uint64_t x) {
 2249|  27.2M|  return core_num__u64__rotate_left(x, (uint32_t)(int32_t)25);
 2250|  27.2M|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_xor_and_rotate_d2_54:
 2309|  27.2M|libcrux_sha3_simd_portable_xor_and_rotate_d2_54(uint64_t a, uint64_t b) {
 2310|  27.2M|  return libcrux_sha3_simd_portable__vxarq_u64_54(a, b);
 2311|  27.2M|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable__vxarq_u64_54:
 2295|  27.2M|libcrux_sha3_simd_portable__vxarq_u64_54(uint64_t a, uint64_t b) {
 2296|  27.2M|  return libcrux_sha3_simd_portable_rotate_left_54(a ^ b);
 2297|  27.2M|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_rotate_left_54:
 2284|  27.2M|libcrux_sha3_simd_portable_rotate_left_54(uint64_t x) {
 2285|  27.2M|  return core_num__u64__rotate_left(x, (uint32_t)(int32_t)21);
 2286|  27.2M|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_xor_and_rotate_d2_4c:
 2345|  27.2M|libcrux_sha3_simd_portable_xor_and_rotate_d2_4c(uint64_t a, uint64_t b) {
 2346|  27.2M|  return libcrux_sha3_simd_portable__vxarq_u64_4c(a, b);
 2347|  27.2M|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable__vxarq_u64_4c:
 2331|  27.2M|libcrux_sha3_simd_portable__vxarq_u64_4c(uint64_t a, uint64_t b) {
 2332|  27.2M|  return libcrux_sha3_simd_portable_rotate_left_4c(a ^ b);
 2333|  27.2M|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_rotate_left_4c:
 2320|  27.2M|libcrux_sha3_simd_portable_rotate_left_4c(uint64_t x) {
 2321|  27.2M|  return core_num__u64__rotate_left(x, (uint32_t)(int32_t)56);
 2322|  27.2M|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_xor_and_rotate_d2_ce:
 2381|  27.2M|libcrux_sha3_simd_portable_xor_and_rotate_d2_ce(uint64_t a, uint64_t b) {
 2382|  27.2M|  return libcrux_sha3_simd_portable__vxarq_u64_ce(a, b);
 2383|  27.2M|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable__vxarq_u64_ce:
 2367|  27.2M|libcrux_sha3_simd_portable__vxarq_u64_ce(uint64_t a, uint64_t b) {
 2368|  27.2M|  return libcrux_sha3_simd_portable_rotate_left_ce(a ^ b);
 2369|  27.2M|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_rotate_left_ce:
 2356|  27.2M|libcrux_sha3_simd_portable_rotate_left_ce(uint64_t x) {
 2357|  27.2M|  return core_num__u64__rotate_left(x, (uint32_t)(int32_t)27);
 2358|  27.2M|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_xor_and_rotate_d2_77:
 2417|  27.2M|libcrux_sha3_simd_portable_xor_and_rotate_d2_77(uint64_t a, uint64_t b) {
 2418|  27.2M|  return libcrux_sha3_simd_portable__vxarq_u64_77(a, b);
 2419|  27.2M|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable__vxarq_u64_77:
 2403|  27.2M|libcrux_sha3_simd_portable__vxarq_u64_77(uint64_t a, uint64_t b) {
 2404|  27.2M|  return libcrux_sha3_simd_portable_rotate_left_77(a ^ b);
 2405|  27.2M|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_rotate_left_77:
 2392|  27.2M|libcrux_sha3_simd_portable_rotate_left_77(uint64_t x) {
 2393|  27.2M|  return core_num__u64__rotate_left(x, (uint32_t)(int32_t)20);
 2394|  27.2M|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_xor_and_rotate_d2_25:
 2453|  27.2M|libcrux_sha3_simd_portable_xor_and_rotate_d2_25(uint64_t a, uint64_t b) {
 2454|  27.2M|  return libcrux_sha3_simd_portable__vxarq_u64_25(a, b);
 2455|  27.2M|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable__vxarq_u64_25:
 2439|  27.2M|libcrux_sha3_simd_portable__vxarq_u64_25(uint64_t a, uint64_t b) {
 2440|  27.2M|  return libcrux_sha3_simd_portable_rotate_left_25(a ^ b);
 2441|  27.2M|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_rotate_left_25:
 2428|  27.2M|libcrux_sha3_simd_portable_rotate_left_25(uint64_t x) {
 2429|  27.2M|  return core_num__u64__rotate_left(x, (uint32_t)(int32_t)39);
 2430|  27.2M|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_xor_and_rotate_d2_af:
 2489|  27.2M|libcrux_sha3_simd_portable_xor_and_rotate_d2_af(uint64_t a, uint64_t b) {
 2490|  27.2M|  return libcrux_sha3_simd_portable__vxarq_u64_af(a, b);
 2491|  27.2M|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable__vxarq_u64_af:
 2475|  27.2M|libcrux_sha3_simd_portable__vxarq_u64_af(uint64_t a, uint64_t b) {
 2476|  27.2M|  return libcrux_sha3_simd_portable_rotate_left_af(a ^ b);
 2477|  27.2M|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_rotate_left_af:
 2464|  27.2M|libcrux_sha3_simd_portable_rotate_left_af(uint64_t x) {
 2465|  27.2M|  return core_num__u64__rotate_left(x, (uint32_t)(int32_t)8);
 2466|  27.2M|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_xor_and_rotate_d2_fd:
 2525|  27.2M|libcrux_sha3_simd_portable_xor_and_rotate_d2_fd(uint64_t a, uint64_t b) {
 2526|  27.2M|  return libcrux_sha3_simd_portable__vxarq_u64_fd(a, b);
 2527|  27.2M|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable__vxarq_u64_fd:
 2511|  27.2M|libcrux_sha3_simd_portable__vxarq_u64_fd(uint64_t a, uint64_t b) {
 2512|  27.2M|  return libcrux_sha3_simd_portable_rotate_left_fd(a ^ b);
 2513|  27.2M|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_rotate_left_fd:
 2500|  27.2M|libcrux_sha3_simd_portable_rotate_left_fd(uint64_t x) {
 2501|  27.2M|  return core_num__u64__rotate_left(x, (uint32_t)(int32_t)14);
 2502|  27.2M|}
libcrux_mlkem768_sha3.c:libcrux_sha3_generic_keccak_pi_80_04:
 2753|  27.2M|    libcrux_sha3_generic_keccak_KeccakState_17 *self) {
 2754|  27.2M|  libcrux_sha3_generic_keccak_KeccakState_17 old = self[0U];
 2755|  27.2M|  libcrux_sha3_generic_keccak_set_80_04(
 2756|  27.2M|      self, (size_t)1U, (size_t)0U,
 2757|  27.2M|      libcrux_sha3_generic_keccak_index_c2_04(
 2758|  27.2M|          &old, (KRML_CLITERAL(size_t_x2){.fst = (size_t)0U,
  ------------------
  |  |  154|  27.2M|#define KRML_CLITERAL(type) (type)
  ------------------
 2759|  27.2M|                                          .snd = (size_t)3U}))[0U]);
 2760|  27.2M|  libcrux_sha3_generic_keccak_set_80_04(
 2761|  27.2M|      self, (size_t)2U, (size_t)0U,
 2762|  27.2M|      libcrux_sha3_generic_keccak_index_c2_04(
 2763|  27.2M|          &old, (KRML_CLITERAL(size_t_x2){.fst = (size_t)0U,
  ------------------
  |  |  154|  27.2M|#define KRML_CLITERAL(type) (type)
  ------------------
 2764|  27.2M|                                          .snd = (size_t)1U}))[0U]);
 2765|  27.2M|  libcrux_sha3_generic_keccak_set_80_04(
 2766|  27.2M|      self, (size_t)3U, (size_t)0U,
 2767|  27.2M|      libcrux_sha3_generic_keccak_index_c2_04(
 2768|  27.2M|          &old, (KRML_CLITERAL(size_t_x2){.fst = (size_t)0U,
  ------------------
  |  |  154|  27.2M|#define KRML_CLITERAL(type) (type)
  ------------------
 2769|  27.2M|                                          .snd = (size_t)4U}))[0U]);
 2770|  27.2M|  libcrux_sha3_generic_keccak_set_80_04(
 2771|  27.2M|      self, (size_t)4U, (size_t)0U,
 2772|  27.2M|      libcrux_sha3_generic_keccak_index_c2_04(
 2773|  27.2M|          &old, (KRML_CLITERAL(size_t_x2){.fst = (size_t)0U,
  ------------------
  |  |  154|  27.2M|#define KRML_CLITERAL(type) (type)
  ------------------
 2774|  27.2M|                                          .snd = (size_t)2U}))[0U]);
 2775|  27.2M|  libcrux_sha3_generic_keccak_set_80_04(
 2776|  27.2M|      self, (size_t)0U, (size_t)1U,
 2777|  27.2M|      libcrux_sha3_generic_keccak_index_c2_04(
 2778|  27.2M|          &old, (KRML_CLITERAL(size_t_x2){.fst = (size_t)1U,
  ------------------
  |  |  154|  27.2M|#define KRML_CLITERAL(type) (type)
  ------------------
 2779|  27.2M|                                          .snd = (size_t)1U}))[0U]);
 2780|  27.2M|  libcrux_sha3_generic_keccak_set_80_04(
 2781|  27.2M|      self, (size_t)1U, (size_t)1U,
 2782|  27.2M|      libcrux_sha3_generic_keccak_index_c2_04(
 2783|  27.2M|          &old, (KRML_CLITERAL(size_t_x2){.fst = (size_t)1U,
  ------------------
  |  |  154|  27.2M|#define KRML_CLITERAL(type) (type)
  ------------------
 2784|  27.2M|                                          .snd = (size_t)4U}))[0U]);
 2785|  27.2M|  libcrux_sha3_generic_keccak_set_80_04(
 2786|  27.2M|      self, (size_t)2U, (size_t)1U,
 2787|  27.2M|      libcrux_sha3_generic_keccak_index_c2_04(
 2788|  27.2M|          &old, (KRML_CLITERAL(size_t_x2){.fst = (size_t)1U,
  ------------------
  |  |  154|  27.2M|#define KRML_CLITERAL(type) (type)
  ------------------
 2789|  27.2M|                                          .snd = (size_t)2U}))[0U]);
 2790|  27.2M|  libcrux_sha3_generic_keccak_set_80_04(
 2791|  27.2M|      self, (size_t)3U, (size_t)1U,
 2792|  27.2M|      libcrux_sha3_generic_keccak_index_c2_04(
 2793|  27.2M|          &old, (KRML_CLITERAL(size_t_x2){.fst = (size_t)1U,
  ------------------
  |  |  154|  27.2M|#define KRML_CLITERAL(type) (type)
  ------------------
 2794|  27.2M|                                          .snd = (size_t)0U}))[0U]);
 2795|  27.2M|  libcrux_sha3_generic_keccak_set_80_04(
 2796|  27.2M|      self, (size_t)4U, (size_t)1U,
 2797|  27.2M|      libcrux_sha3_generic_keccak_index_c2_04(
 2798|  27.2M|          &old, (KRML_CLITERAL(size_t_x2){.fst = (size_t)1U,
  ------------------
  |  |  154|  27.2M|#define KRML_CLITERAL(type) (type)
  ------------------
 2799|  27.2M|                                          .snd = (size_t)3U}))[0U]);
 2800|  27.2M|  libcrux_sha3_generic_keccak_set_80_04(
 2801|  27.2M|      self, (size_t)0U, (size_t)2U,
 2802|  27.2M|      libcrux_sha3_generic_keccak_index_c2_04(
 2803|  27.2M|          &old, (KRML_CLITERAL(size_t_x2){.fst = (size_t)2U,
  ------------------
  |  |  154|  27.2M|#define KRML_CLITERAL(type) (type)
  ------------------
 2804|  27.2M|                                          .snd = (size_t)2U}))[0U]);
 2805|  27.2M|  libcrux_sha3_generic_keccak_set_80_04(
 2806|  27.2M|      self, (size_t)1U, (size_t)2U,
 2807|  27.2M|      libcrux_sha3_generic_keccak_index_c2_04(
 2808|  27.2M|          &old, (KRML_CLITERAL(size_t_x2){.fst = (size_t)2U,
  ------------------
  |  |  154|  27.2M|#define KRML_CLITERAL(type) (type)
  ------------------
 2809|  27.2M|                                          .snd = (size_t)0U}))[0U]);
 2810|  27.2M|  libcrux_sha3_generic_keccak_set_80_04(
 2811|  27.2M|      self, (size_t)2U, (size_t)2U,
 2812|  27.2M|      libcrux_sha3_generic_keccak_index_c2_04(
 2813|  27.2M|          &old, (KRML_CLITERAL(size_t_x2){.fst = (size_t)2U,
  ------------------
  |  |  154|  27.2M|#define KRML_CLITERAL(type) (type)
  ------------------
 2814|  27.2M|                                          .snd = (size_t)3U}))[0U]);
 2815|  27.2M|  libcrux_sha3_generic_keccak_set_80_04(
 2816|  27.2M|      self, (size_t)3U, (size_t)2U,
 2817|  27.2M|      libcrux_sha3_generic_keccak_index_c2_04(
 2818|  27.2M|          &old, (KRML_CLITERAL(size_t_x2){.fst = (size_t)2U,
  ------------------
  |  |  154|  27.2M|#define KRML_CLITERAL(type) (type)
  ------------------
 2819|  27.2M|                                          .snd = (size_t)1U}))[0U]);
 2820|  27.2M|  libcrux_sha3_generic_keccak_set_80_04(
 2821|  27.2M|      self, (size_t)4U, (size_t)2U,
 2822|  27.2M|      libcrux_sha3_generic_keccak_index_c2_04(
 2823|  27.2M|          &old, (KRML_CLITERAL(size_t_x2){.fst = (size_t)2U,
  ------------------
  |  |  154|  27.2M|#define KRML_CLITERAL(type) (type)
  ------------------
 2824|  27.2M|                                          .snd = (size_t)4U}))[0U]);
 2825|  27.2M|  libcrux_sha3_generic_keccak_set_80_04(
 2826|  27.2M|      self, (size_t)0U, (size_t)3U,
 2827|  27.2M|      libcrux_sha3_generic_keccak_index_c2_04(
 2828|  27.2M|          &old, (KRML_CLITERAL(size_t_x2){.fst = (size_t)3U,
  ------------------
  |  |  154|  27.2M|#define KRML_CLITERAL(type) (type)
  ------------------
 2829|  27.2M|                                          .snd = (size_t)3U}))[0U]);
 2830|  27.2M|  libcrux_sha3_generic_keccak_set_80_04(
 2831|  27.2M|      self, (size_t)1U, (size_t)3U,
 2832|  27.2M|      libcrux_sha3_generic_keccak_index_c2_04(
 2833|  27.2M|          &old, (KRML_CLITERAL(size_t_x2){.fst = (size_t)3U,
  ------------------
  |  |  154|  27.2M|#define KRML_CLITERAL(type) (type)
  ------------------
 2834|  27.2M|                                          .snd = (size_t)1U}))[0U]);
 2835|  27.2M|  libcrux_sha3_generic_keccak_set_80_04(
 2836|  27.2M|      self, (size_t)2U, (size_t)3U,
 2837|  27.2M|      libcrux_sha3_generic_keccak_index_c2_04(
 2838|  27.2M|          &old, (KRML_CLITERAL(size_t_x2){.fst = (size_t)3U,
  ------------------
  |  |  154|  27.2M|#define KRML_CLITERAL(type) (type)
  ------------------
 2839|  27.2M|                                          .snd = (size_t)4U}))[0U]);
 2840|  27.2M|  libcrux_sha3_generic_keccak_set_80_04(
 2841|  27.2M|      self, (size_t)3U, (size_t)3U,
 2842|  27.2M|      libcrux_sha3_generic_keccak_index_c2_04(
 2843|  27.2M|          &old, (KRML_CLITERAL(size_t_x2){.fst = (size_t)3U,
  ------------------
  |  |  154|  27.2M|#define KRML_CLITERAL(type) (type)
  ------------------
 2844|  27.2M|                                          .snd = (size_t)2U}))[0U]);
 2845|  27.2M|  libcrux_sha3_generic_keccak_set_80_04(
 2846|  27.2M|      self, (size_t)4U, (size_t)3U,
 2847|  27.2M|      libcrux_sha3_generic_keccak_index_c2_04(
 2848|  27.2M|          &old, (KRML_CLITERAL(size_t_x2){.fst = (size_t)3U,
  ------------------
  |  |  154|  27.2M|#define KRML_CLITERAL(type) (type)
  ------------------
 2849|  27.2M|                                          .snd = (size_t)0U}))[0U]);
 2850|  27.2M|  libcrux_sha3_generic_keccak_set_80_04(
 2851|  27.2M|      self, (size_t)0U, (size_t)4U,
 2852|  27.2M|      libcrux_sha3_generic_keccak_index_c2_04(
 2853|  27.2M|          &old, (KRML_CLITERAL(size_t_x2){.fst = (size_t)4U,
  ------------------
  |  |  154|  27.2M|#define KRML_CLITERAL(type) (type)
  ------------------
 2854|  27.2M|                                          .snd = (size_t)4U}))[0U]);
 2855|  27.2M|  libcrux_sha3_generic_keccak_set_80_04(
 2856|  27.2M|      self, (size_t)1U, (size_t)4U,
 2857|  27.2M|      libcrux_sha3_generic_keccak_index_c2_04(
 2858|  27.2M|          &old, (KRML_CLITERAL(size_t_x2){.fst = (size_t)4U,
  ------------------
  |  |  154|  27.2M|#define KRML_CLITERAL(type) (type)
  ------------------
 2859|  27.2M|                                          .snd = (size_t)2U}))[0U]);
 2860|  27.2M|  libcrux_sha3_generic_keccak_set_80_04(
 2861|  27.2M|      self, (size_t)2U, (size_t)4U,
 2862|  27.2M|      libcrux_sha3_generic_keccak_index_c2_04(
 2863|  27.2M|          &old, (KRML_CLITERAL(size_t_x2){.fst = (size_t)4U,
  ------------------
  |  |  154|  27.2M|#define KRML_CLITERAL(type) (type)
  ------------------
 2864|  27.2M|                                          .snd = (size_t)0U}))[0U]);
 2865|  27.2M|  libcrux_sha3_generic_keccak_set_80_04(
 2866|  27.2M|      self, (size_t)3U, (size_t)4U,
 2867|  27.2M|      libcrux_sha3_generic_keccak_index_c2_04(
 2868|  27.2M|          &old, (KRML_CLITERAL(size_t_x2){.fst = (size_t)4U,
  ------------------
  |  |  154|  27.2M|#define KRML_CLITERAL(type) (type)
  ------------------
 2869|  27.2M|                                          .snd = (size_t)3U}))[0U]);
 2870|  27.2M|  libcrux_sha3_generic_keccak_set_80_04(
 2871|  27.2M|      self, (size_t)4U, (size_t)4U,
 2872|  27.2M|      libcrux_sha3_generic_keccak_index_c2_04(
 2873|  27.2M|          &old, (KRML_CLITERAL(size_t_x2){.fst = (size_t)4U,
  ------------------
  |  |  154|  27.2M|#define KRML_CLITERAL(type) (type)
  ------------------
 2874|  27.2M|                                          .snd = (size_t)1U}))[0U]);
 2875|  27.2M|}
libcrux_mlkem768_sha3.c:libcrux_sha3_generic_keccak_chi_80_04:
 2888|  27.2M|    libcrux_sha3_generic_keccak_KeccakState_17 *self) {
 2889|  27.2M|  libcrux_sha3_generic_keccak_KeccakState_17 old = self[0U];
 2890|   163M|  for (size_t i0 = (size_t)0U; i0 < (size_t)5U; i0++) {
  ------------------
  |  Branch (2890:32): [True: 136M, False: 27.2M]
  ------------------
 2891|   136M|    size_t i1 = i0;
 2892|   818M|    for (size_t i = (size_t)0U; i < (size_t)5U; i++) {
  ------------------
  |  Branch (2892:33): [True: 682M, False: 136M]
  ------------------
 2893|   682M|      size_t j = i;
 2894|   682M|      libcrux_sha3_generic_keccak_set_80_04(
 2895|   682M|          self, i1, j,
 2896|   682M|          libcrux_sha3_simd_portable_and_not_xor_d2(
 2897|   682M|              libcrux_sha3_generic_keccak_index_c2_04(
 2898|   682M|                  self, (KRML_CLITERAL(size_t_x2){.fst = i1, .snd = j}))[0U],
  ------------------
  |  |  154|   682M|#define KRML_CLITERAL(type) (type)
  ------------------
 2899|   682M|              libcrux_sha3_generic_keccak_index_c2_04(
 2900|   682M|                  &old,
 2901|   682M|                  (KRML_CLITERAL(size_t_x2){
  ------------------
  |  |  154|   682M|#define KRML_CLITERAL(type) (type)
  ------------------
 2902|   682M|                      .fst = i1, .snd = (j + (size_t)2U) % (size_t)5U}))[0U],
 2903|   682M|              libcrux_sha3_generic_keccak_index_c2_04(
 2904|   682M|                  &old,
 2905|   682M|                  (KRML_CLITERAL(size_t_x2){
  ------------------
  |  |  154|   682M|#define KRML_CLITERAL(type) (type)
  ------------------
 2906|   682M|                      .fst = i1, .snd = (j + (size_t)1U) % (size_t)5U}))[0U]));
 2907|   682M|    }
 2908|   136M|  }
 2909|  27.2M|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_and_not_xor_d2:
 1371|   682M|libcrux_sha3_simd_portable_and_not_xor_d2(uint64_t a, uint64_t b, uint64_t c) {
 1372|   682M|  return libcrux_sha3_simd_portable__vbcaxq_u64(a, b, c);
 1373|   682M|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable__vbcaxq_u64:
 1363|   682M|libcrux_sha3_simd_portable__vbcaxq_u64(uint64_t a, uint64_t b, uint64_t c) {
 1364|   682M|  return a ^ (b & ~c);
 1365|   682M|}
libcrux_mlkem768_sha3.c:libcrux_sha3_generic_keccak_iota_80_04:
 2922|  27.2M|    libcrux_sha3_generic_keccak_KeccakState_17 *self, size_t i) {
 2923|  27.2M|  libcrux_sha3_generic_keccak_set_80_04(
 2924|  27.2M|      self, (size_t)0U, (size_t)0U,
 2925|  27.2M|      libcrux_sha3_simd_portable_xor_constant_d2(
 2926|  27.2M|          libcrux_sha3_generic_keccak_index_c2_04(
 2927|  27.2M|              self, (KRML_CLITERAL(size_t_x2){.fst = (size_t)0U,
  ------------------
  |  |  154|  27.2M|#define KRML_CLITERAL(type) (type)
  ------------------
 2928|  27.2M|                                              .snd = (size_t)0U}))[0U],
 2929|  27.2M|          libcrux_sha3_generic_keccak_constants_ROUNDCONSTANTS[i]));
 2930|  27.2M|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_xor_constant_d2:
 1384|  27.2M|libcrux_sha3_simd_portable_xor_constant_d2(uint64_t a, uint64_t c) {
 1385|  27.2M|  return libcrux_sha3_simd_portable__veorq_n_u64(a, c);
 1386|  27.2M|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable__veorq_n_u64:
 1376|  27.2M|libcrux_sha3_simd_portable__veorq_n_u64(uint64_t a, uint64_t c) {
 1377|  27.2M|  return a ^ c;
 1378|  27.2M|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_utils_into_padded_array_15:
  936|  8.64k|    Eurydice_slice slice, uint8_t ret[1120U]) {
  937|  8.64k|  uint8_t out[1120U] = {0U};
  938|  8.64k|  uint8_t *uu____0 = out;
  939|  8.64k|  Eurydice_slice_copy(
  ------------------
  |  |  229|  8.64k|  memcpy(dst.ptr, src.ptr, dst.len * sizeof(t))
  ------------------
  940|  8.64k|      Eurydice_array_to_subslice3(
  941|  8.64k|          uu____0, (size_t)0U, Eurydice_slice_len(slice, uint8_t), uint8_t *),
  942|  8.64k|      slice, uint8_t);
  943|  8.64k|  memcpy(ret, out, (size_t)1120U * sizeof(uint8_t));
  944|  8.64k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_types_as_ref_d3_80:
  923|  17.2k|    libcrux_ml_kem_mlkem768_MlKem768Ciphertext *self) {
  924|  17.2k|  return Eurydice_array_to_slice((size_t)1088U, self->value, uint8_t);
  ------------------
  |  |  204|  17.2k|  EURYDICE_SLICE(x, 0,                     \
  |  |  ------------------
  |  |  |  |  169|  17.2k|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|  17.2k|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  205|  17.2k|                 end) /* x is already at an array type, no need for cast */
  ------------------
  925|  17.2k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_hash_functions_portable_PRF_4a_41:
 6326|  8.64k|    Eurydice_slice input, uint8_t ret[32U]) {
 6327|  8.64k|  libcrux_ml_kem_hash_functions_portable_PRF_9e(input, ret);
 6328|  8.64k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_hash_functions_portable_PRF_9e:
 6308|  8.64k|    Eurydice_slice input, uint8_t ret[32U]) {
 6309|  8.64k|  uint8_t digest[32U] = {0U};
 6310|  8.64k|  libcrux_sha3_portable_shake256(
 6311|  8.64k|      Eurydice_array_to_slice((size_t)32U, digest, uint8_t), input);
  ------------------
  |  |  204|  8.64k|  EURYDICE_SLICE(x, 0,                     \
  |  |  ------------------
  |  |  |  |  169|  8.64k|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|  8.64k|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  205|  8.64k|                 end) /* x is already at an array type, no need for cast */
  ------------------
 6312|  8.64k|  memcpy(ret, digest, (size_t)32U * sizeof(uint8_t));
 6313|  8.64k|}
libcrux_mlkem768_sha3.c:libcrux_sha3_portable_shake256:
 3455|   181k|    Eurydice_slice digest, Eurydice_slice data) {
 3456|   181k|  libcrux_sha3_generic_keccak_portable_keccak1_ad0(data, digest);
 3457|   181k|}
libcrux_mlkem768_sha3.c:libcrux_sha3_generic_keccak_portable_keccak1_ad0:
 3419|   181k|    Eurydice_slice data, Eurydice_slice out) {
 3420|   181k|  libcrux_sha3_generic_keccak_KeccakState_17 s =
 3421|   181k|      libcrux_sha3_generic_keccak_new_80_04();
 3422|   181k|  size_t data_len = Eurydice_slice_len(data, uint8_t);
  ------------------
  |  |  173|   181k|#define Eurydice_slice_len(s, _) (s).len
  ------------------
 3423|   250k|  for (size_t i = (size_t)0U; i < data_len / (size_t)136U; i++) {
  ------------------
  |  Branch (3423:31): [True: 69.1k, False: 181k]
  ------------------
 3424|  69.1k|    size_t i0 = i;
 3425|  69.1k|    Eurydice_slice buf[1U] = {data};
 3426|  69.1k|    libcrux_sha3_generic_keccak_absorb_block_80_c60(&s, buf, i0 * (size_t)136U);
 3427|  69.1k|  }
 3428|   181k|  size_t rem = data_len % (size_t)136U;
 3429|   181k|  Eurydice_slice buf[1U] = {data};
 3430|   181k|  libcrux_sha3_generic_keccak_absorb_final_80_9e1(&s, buf, data_len - rem, rem);
 3431|   181k|  size_t outlen = Eurydice_slice_len(out, uint8_t);
  ------------------
  |  |  173|   181k|#define Eurydice_slice_len(s, _) (s).len
  ------------------
 3432|   181k|  size_t blocks = outlen / (size_t)136U;
 3433|   181k|  size_t last = outlen - outlen % (size_t)136U;
 3434|   181k|  if (blocks == (size_t)0U) {
  ------------------
  |  Branch (3434:7): [True: 181k, False: 0]
  ------------------
 3435|   181k|    libcrux_sha3_simd_portable_squeeze_13_5b(&s, out, (size_t)0U, outlen);
 3436|   181k|  } else {
 3437|      0|    libcrux_sha3_simd_portable_squeeze_13_5b(&s, out, (size_t)0U, (size_t)136U);
 3438|      0|    for (size_t i = (size_t)1U; i < blocks; i++) {
  ------------------
  |  Branch (3438:33): [True: 0, False: 0]
  ------------------
 3439|      0|      size_t i0 = i;
 3440|      0|      libcrux_sha3_generic_keccak_keccakf1600_80_04(&s);
 3441|      0|      libcrux_sha3_simd_portable_squeeze_13_5b(&s, out, i0 * (size_t)136U,
 3442|      0|                                               (size_t)136U);
 3443|      0|    }
 3444|      0|    if (last < outlen) {
  ------------------
  |  Branch (3444:9): [True: 0, False: 0]
  ------------------
 3445|      0|      libcrux_sha3_generic_keccak_keccakf1600_80_04(&s);
 3446|      0|      libcrux_sha3_simd_portable_squeeze_13_5b(&s, out, last, outlen - last);
 3447|      0|    }
 3448|      0|  }
 3449|   181k|}
libcrux_mlkem768_sha3.c:libcrux_sha3_generic_keccak_absorb_block_80_c60:
 3193|   207k|    size_t start) {
 3194|   207k|  libcrux_sha3_simd_portable_load_block_a1_5b(self, blocks, start);
 3195|   207k|  libcrux_sha3_generic_keccak_keccakf1600_80_04(self);
 3196|   207k|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_load_block_a1_5b:
 3176|   207k|    size_t start) {
 3177|   207k|  libcrux_sha3_simd_portable_load_block_5b(self->st, input[0U], start);
 3178|   207k|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_load_block_5b:
 3138|   406k|    uint64_t *state, Eurydice_slice blocks, size_t start) {
 3139|   406k|  uint64_t state_flat[25U] = {0U};
 3140|  7.30M|  for (size_t i = (size_t)0U; i < (size_t)136U / (size_t)8U; i++) {
  ------------------
  |  Branch (3140:31): [True: 6.90M, False: 406k]
  ------------------
 3141|  6.90M|    size_t i0 = i;
 3142|  6.90M|    size_t offset = start + (size_t)8U * i0;
 3143|  6.90M|    uint8_t uu____0[8U];
 3144|  6.90M|    Result_15 dst;
 3145|  6.90M|    Eurydice_slice_to_array2(
  ------------------
  |  |  277|  6.90M|  Eurydice_slice_to_array3(&(dst)->tag, (char *)&(dst)->val.case_Ok, src, \
  |  |  278|  6.90M|                           sizeof(t_arr))
  ------------------
 3146|  6.90M|        &dst,
 3147|  6.90M|        Eurydice_slice_subslice3(blocks, offset, offset + (size_t)8U,
 3148|  6.90M|                                 uint8_t *),
 3149|  6.90M|        Eurydice_slice, uint8_t[8U], TryFromSliceError);
 3150|  6.90M|    unwrap_26_68(dst, uu____0);
 3151|  6.90M|    state_flat[i0] = core_num__u64__from_le_bytes(uu____0);
 3152|  6.90M|  }
 3153|  7.30M|  for (size_t i = (size_t)0U; i < (size_t)136U / (size_t)8U; i++) {
  ------------------
  |  Branch (3153:31): [True: 6.90M, False: 406k]
  ------------------
 3154|  6.90M|    size_t i0 = i;
 3155|  6.90M|    libcrux_sha3_traits_set_ij_04(
 3156|  6.90M|        state, i0 / (size_t)5U, i0 % (size_t)5U,
 3157|  6.90M|        libcrux_sha3_traits_get_ij_04(state, i0 / (size_t)5U,
 3158|  6.90M|                                      i0 % (size_t)5U)[0U] ^
 3159|  6.90M|            state_flat[i0]);
 3160|  6.90M|  }
 3161|   406k|}
libcrux_mlkem768_sha3.c:libcrux_sha3_generic_keccak_absorb_final_80_9e1:
 3407|   181k|    size_t start, size_t len) {
 3408|   181k|  libcrux_sha3_simd_portable_load_last_a1_ad0(self, last, start, len);
 3409|   181k|  libcrux_sha3_generic_keccak_keccakf1600_80_04(self);
 3410|   181k|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_load_last_a1_ad0:
 3389|   181k|    size_t start, size_t len) {
 3390|   181k|  libcrux_sha3_simd_portable_load_last_ad0(self->st, input[0U], start, len);
 3391|   181k|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_load_last_ad0:
 3362|   181k|    uint64_t *state, Eurydice_slice blocks, size_t start, size_t len) {
 3363|   181k|  uint8_t buffer[136U] = {0U};
 3364|   181k|  Eurydice_slice_copy(
  ------------------
  |  |  229|   181k|  memcpy(dst.ptr, src.ptr, dst.len * sizeof(t))
  ------------------
 3365|   181k|      Eurydice_array_to_subslice3(buffer, (size_t)0U, len, uint8_t *),
 3366|   181k|      Eurydice_slice_subslice3(blocks, start, start + len, uint8_t *), uint8_t);
 3367|   181k|  buffer[len] = 31U;
 3368|   181k|  size_t uu____0 = (size_t)136U - (size_t)1U;
 3369|   181k|  buffer[uu____0] = (uint32_t)buffer[uu____0] | 128U;
 3370|   181k|  libcrux_sha3_simd_portable_load_block_5b(
 3371|   181k|      state, Eurydice_array_to_slice((size_t)136U, buffer, uint8_t),
  ------------------
  |  |  204|   181k|  EURYDICE_SLICE(x, 0,                     \
  |  |  ------------------
  |  |  |  |  169|   181k|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|   181k|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  205|   181k|                 end) /* x is already at an array type, no need for cast */
  ------------------
 3372|   181k|      (size_t)0U);
 3373|   181k|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_squeeze_13_5b:
 3304|   198k|    size_t start, size_t len) {
 3305|   198k|  libcrux_sha3_simd_portable_store_block_5b(self->st, out, start, len);
 3306|   198k|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_store_block_5b:
 3261|   198k|    uint64_t *s, Eurydice_slice out, size_t start, size_t len) {
 3262|   198k|  size_t octets = len / (size_t)8U;
 3263|  3.06M|  for (size_t i = (size_t)0U; i < octets; i++) {
  ------------------
  |  Branch (3263:31): [True: 2.86M, False: 198k]
  ------------------
 3264|  2.86M|    size_t i0 = i;
 3265|  2.86M|    Eurydice_slice uu____0 = Eurydice_slice_subslice3(
  ------------------
  |  |  195|  2.86M|  EURYDICE_SLICE((t_ptr)s.ptr, (start), (end))
  |  |  ------------------
  |  |  |  |  169|  2.86M|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|  2.86M|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3266|  2.86M|        out, start + (size_t)8U * i0, start + (size_t)8U * i0 + (size_t)8U,
 3267|  2.86M|        uint8_t *);
 3268|  2.86M|    uint8_t ret[8U];
 3269|  2.86M|    core_num__u64__to_le_bytes(
 3270|  2.86M|        libcrux_sha3_traits_get_ij_04(s, i0 / (size_t)5U, i0 % (size_t)5U)[0U],
 3271|  2.86M|        ret);
 3272|  2.86M|    Eurydice_slice_copy(
  ------------------
  |  |  229|  2.86M|  memcpy(dst.ptr, src.ptr, dst.len * sizeof(t))
  ------------------
 3273|  2.86M|        uu____0, Eurydice_array_to_slice((size_t)8U, ret, uint8_t), uint8_t);
 3274|  2.86M|  }
 3275|   198k|  size_t remaining = len % (size_t)8U;
 3276|   198k|  if (remaining > (size_t)0U) {
  ------------------
  |  Branch (3276:7): [True: 0, False: 198k]
  ------------------
 3277|      0|    Eurydice_slice uu____1 = Eurydice_slice_subslice3(
  ------------------
  |  |  195|      0|  EURYDICE_SLICE((t_ptr)s.ptr, (start), (end))
  |  |  ------------------
  |  |  |  |  169|      0|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3278|      0|        out, start + len - remaining, start + len, uint8_t *);
 3279|      0|    uint8_t ret[8U];
 3280|      0|    core_num__u64__to_le_bytes(
 3281|      0|        libcrux_sha3_traits_get_ij_04(s, octets / (size_t)5U,
 3282|      0|                                      octets % (size_t)5U)[0U],
 3283|      0|        ret);
 3284|      0|    Eurydice_slice_copy(
  ------------------
  |  |  229|      0|  memcpy(dst.ptr, src.ptr, dst.len * sizeof(t))
  ------------------
 3285|      0|        uu____1,
 3286|      0|        Eurydice_array_to_subslice3(ret, (size_t)0U, remaining, uint8_t *),
 3287|      0|        uint8_t);
 3288|      0|  }
 3289|   198k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_ind_cpa_encrypt_2a:
 7881|  17.2k|    uint8_t ret[1088U]) {
 7882|  17.2k|  libcrux_ml_kem_ind_cpa_unpacked_IndCpaPublicKeyUnpacked_a0
 7883|  17.2k|      unpacked_public_key =
 7884|  17.2k|          libcrux_ml_kem_ind_cpa_build_unpacked_public_key_3f(public_key);
 7885|  17.2k|  uint8_t ret0[1088U];
 7886|  17.2k|  libcrux_ml_kem_ind_cpa_encrypt_unpacked_2a(&unpacked_public_key, message,
 7887|  17.2k|                                             randomness, ret0);
 7888|  17.2k|  memcpy(ret, ret0, (size_t)1088U * sizeof(uint8_t));
 7889|  17.2k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_ind_cpa_build_unpacked_public_key_3f:
 6924|  17.2k|        Eurydice_slice public_key) {
 6925|  17.2k|  libcrux_ml_kem_ind_cpa_unpacked_IndCpaPublicKeyUnpacked_a0
 6926|  17.2k|      unpacked_public_key = libcrux_ml_kem_ind_cpa_unpacked_default_8b_1b();
 6927|  17.2k|  libcrux_ml_kem_ind_cpa_build_unpacked_public_key_mut_3f(public_key,
 6928|  17.2k|                                                          &unpacked_public_key);
 6929|  17.2k|  return unpacked_public_key;
 6930|  17.2k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_ind_cpa_unpacked_default_8b_1b:
 6354|  25.9k|libcrux_ml_kem_ind_cpa_unpacked_default_8b_1b(void) {
 6355|  25.9k|  libcrux_ml_kem_polynomial_PolynomialRingElement_1d uu____0[3U];
 6356|   103k|  for (size_t i = (size_t)0U; i < (size_t)3U; i++) {
  ------------------
  |  Branch (6356:31): [True: 77.7k, False: 25.9k]
  ------------------
 6357|  77.7k|    uu____0[i] = libcrux_ml_kem_polynomial_ZERO_d6_ea();
 6358|  77.7k|  }
 6359|  25.9k|  uint8_t uu____1[32U] = {0U};
 6360|  25.9k|  libcrux_ml_kem_ind_cpa_unpacked_IndCpaPublicKeyUnpacked_a0 lit;
 6361|  25.9k|  memcpy(
 6362|  25.9k|      lit.t_as_ntt, uu____0,
 6363|  25.9k|      (size_t)3U * sizeof(libcrux_ml_kem_polynomial_PolynomialRingElement_1d));
 6364|  25.9k|  memcpy(lit.seed_for_A, uu____1, (size_t)32U * sizeof(uint8_t));
 6365|  25.9k|  libcrux_ml_kem_polynomial_PolynomialRingElement_1d repeat_expression0[3U][3U];
 6366|   103k|  for (size_t i0 = (size_t)0U; i0 < (size_t)3U; i0++) {
  ------------------
  |  Branch (6366:32): [True: 77.7k, False: 25.9k]
  ------------------
 6367|  77.7k|    libcrux_ml_kem_polynomial_PolynomialRingElement_1d repeat_expression[3U];
 6368|   311k|    for (size_t i = (size_t)0U; i < (size_t)3U; i++) {
  ------------------
  |  Branch (6368:33): [True: 233k, False: 77.7k]
  ------------------
 6369|   233k|      repeat_expression[i] = libcrux_ml_kem_polynomial_ZERO_d6_ea();
 6370|   233k|    }
 6371|  77.7k|    memcpy(repeat_expression0[i0], repeat_expression,
 6372|  77.7k|           (size_t)3U *
 6373|  77.7k|               sizeof(libcrux_ml_kem_polynomial_PolynomialRingElement_1d));
 6374|  77.7k|  }
 6375|  25.9k|  memcpy(lit.A, repeat_expression0,
 6376|  25.9k|         (size_t)3U *
 6377|  25.9k|             sizeof(libcrux_ml_kem_polynomial_PolynomialRingElement_1d[3U]));
 6378|  25.9k|  return lit;
 6379|  25.9k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_ind_cpa_build_unpacked_public_key_mut_3f:
 6899|  17.2k|        *unpacked_public_key) {
 6900|  17.2k|  Eurydice_slice uu____0 = Eurydice_slice_subslice_to(
  ------------------
  |  |  198|  17.2k|  EURYDICE_SLICE((t *)s.ptr, 0, subslice_end_pos)
  |  |  ------------------
  |  |  |  |  169|  17.2k|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|  17.2k|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 6901|  17.2k|      public_key, (size_t)1152U, uint8_t, size_t, uint8_t[]);
 6902|  17.2k|  libcrux_ml_kem_serialize_deserialize_ring_elements_reduced_1b(
 6903|  17.2k|      uu____0, unpacked_public_key->t_as_ntt);
 6904|  17.2k|  Eurydice_slice seed = Eurydice_slice_subslice_from(
  ------------------
  |  |  201|  17.2k|  EURYDICE_SLICE((t *)s.ptr, subslice_start_pos, s.len)
  |  |  ------------------
  |  |  |  |  169|  17.2k|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|  17.2k|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 6905|  17.2k|      public_key, (size_t)1152U, uint8_t, size_t, uint8_t[]);
 6906|  17.2k|  libcrux_ml_kem_polynomial_PolynomialRingElement_1d(*uu____1)[3U] =
 6907|  17.2k|      unpacked_public_key->A;
 6908|  17.2k|  uint8_t ret[34U];
 6909|  17.2k|  libcrux_ml_kem_utils_into_padded_array_b6(seed, ret);
 6910|       |  libcrux_ml_kem_matrix_sample_matrix_A_2b(uu____1, ret, false);
 6911|  17.2k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_serialize_deserialize_ring_elements_reduced_1b:
 6425|  25.9k|    libcrux_ml_kem_polynomial_PolynomialRingElement_1d *deserialized_pk) {
 6426|  25.9k|  for (size_t i = (size_t)0U;
 6427|   103k|       i < Eurydice_slice_len(public_key, uint8_t) /
  ------------------
  |  |  173|   103k|#define Eurydice_slice_len(s, _) (s).len
  ------------------
  |  Branch (6427:8): [True: 77.7k, False: 25.9k]
  ------------------
 6428|   103k|               LIBCRUX_ML_KEM_CONSTANTS_BYTES_PER_RING_ELEMENT;
  ------------------
  |  |  453|   103k|  (LIBCRUX_ML_KEM_CONSTANTS_BITS_PER_RING_ELEMENT / (size_t)8U)
  |  |  ------------------
  |  |  |  |  450|   103k|  (LIBCRUX_ML_KEM_CONSTANTS_COEFFICIENTS_IN_RING_ELEMENT * (size_t)12U)
  |  |  |  |  ------------------
  |  |  |  |  |  |  447|   103k|#define LIBCRUX_ML_KEM_CONSTANTS_COEFFICIENTS_IN_RING_ELEMENT ((size_t)256U)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 6429|  77.7k|       i++) {
 6430|  77.7k|    size_t i0 = i;
 6431|  77.7k|    Eurydice_slice ring_element = Eurydice_slice_subslice3(
  ------------------
  |  |  195|  77.7k|  EURYDICE_SLICE((t_ptr)s.ptr, (start), (end))
  |  |  ------------------
  |  |  |  |  169|  77.7k|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|  77.7k|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 6432|  77.7k|        public_key, i0 * LIBCRUX_ML_KEM_CONSTANTS_BYTES_PER_RING_ELEMENT,
 6433|  77.7k|        i0 * LIBCRUX_ML_KEM_CONSTANTS_BYTES_PER_RING_ELEMENT +
 6434|  77.7k|            LIBCRUX_ML_KEM_CONSTANTS_BYTES_PER_RING_ELEMENT,
 6435|  77.7k|        uint8_t *);
 6436|  77.7k|    libcrux_ml_kem_polynomial_PolynomialRingElement_1d uu____0 =
 6437|  77.7k|        libcrux_ml_kem_serialize_deserialize_to_reduced_ring_element_ea(
 6438|  77.7k|            ring_element);
 6439|  77.7k|    deserialized_pk[i0] = uu____0;
 6440|  77.7k|  }
 6441|  25.9k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_serialize_deserialize_to_reduced_ring_element_ea:
 6395|  77.7k|    Eurydice_slice serialized) {
 6396|  77.7k|  libcrux_ml_kem_polynomial_PolynomialRingElement_1d re =
 6397|  77.7k|      libcrux_ml_kem_polynomial_ZERO_d6_ea();
 6398|  77.7k|  for (size_t i = (size_t)0U;
 6399|  1.32M|       i < Eurydice_slice_len(serialized, uint8_t) / (size_t)24U; i++) {
  ------------------
  |  |  173|  1.32M|#define Eurydice_slice_len(s, _) (s).len
  ------------------
  |  Branch (6399:8): [True: 1.24M, False: 77.7k]
  ------------------
 6400|  1.24M|    size_t i0 = i;
 6401|  1.24M|    Eurydice_slice bytes =
 6402|  1.24M|        Eurydice_slice_subslice3(serialized, i0 * (size_t)24U,
  ------------------
  |  |  195|  1.24M|  EURYDICE_SLICE((t_ptr)s.ptr, (start), (end))
  |  |  ------------------
  |  |  |  |  169|  1.24M|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|  1.24M|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 6403|  1.24M|                                 i0 * (size_t)24U + (size_t)24U, uint8_t *);
 6404|  1.24M|    libcrux_ml_kem_vector_portable_vector_type_PortableVector coefficient =
 6405|  1.24M|        libcrux_ml_kem_vector_portable_deserialize_12_b8(bytes);
 6406|  1.24M|    libcrux_ml_kem_vector_portable_vector_type_PortableVector uu____0 =
 6407|  1.24M|        libcrux_ml_kem_vector_portable_cond_subtract_3329_b8(coefficient);
 6408|  1.24M|    re.coefficients[i0] = uu____0;
 6409|  1.24M|  }
 6410|  77.7k|  return re;
 6411|  77.7k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_vector_portable_cond_subtract_3329_b8:
 3935|  1.24M|    libcrux_ml_kem_vector_portable_vector_type_PortableVector v) {
 3936|  1.24M|  return libcrux_ml_kem_vector_portable_arithmetic_cond_subtract_3329(v);
 3937|  1.24M|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_vector_portable_arithmetic_cond_subtract_3329:
 3916|  1.24M|    libcrux_ml_kem_vector_portable_vector_type_PortableVector vec) {
 3917|  1.24M|  for (size_t i = (size_t)0U;
 3918|  21.1M|       i < LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_ELEMENTS_IN_VECTOR; i++) {
  ------------------
  |  | 3772|  21.1M|#define LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_ELEMENTS_IN_VECTOR ((size_t)16U)
  ------------------
  |  Branch (3918:8): [True: 19.9M, False: 1.24M]
  ------------------
 3919|  19.9M|    size_t i0 = i;
 3920|  19.9M|    if (libcrux_secrets_int_public_integers_declassify_d8_39(
  ------------------
  |  Branch (3920:9): [True: 0, False: 19.9M]
  ------------------
 3921|  19.9M|            vec.elements[i0]) >= (int16_t)3329) {
 3922|      0|      size_t uu____0 = i0;
 3923|      0|      vec.elements[uu____0] = vec.elements[uu____0] - (int16_t)3329;
 3924|      0|    }
 3925|  19.9M|  }
 3926|  1.24M|  return vec;
 3927|  1.24M|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_utils_into_padded_array_b6:
  903|  25.9k|    Eurydice_slice slice, uint8_t ret[34U]) {
  904|  25.9k|  uint8_t out[34U] = {0U};
  905|  25.9k|  uint8_t *uu____0 = out;
  906|  25.9k|  Eurydice_slice_copy(
  ------------------
  |  |  229|  25.9k|  memcpy(dst.ptr, src.ptr, dst.len * sizeof(t))
  ------------------
  907|  25.9k|      Eurydice_array_to_subslice3(
  908|  25.9k|          uu____0, (size_t)0U, Eurydice_slice_len(slice, uint8_t), uint8_t *),
  909|  25.9k|      slice, uint8_t);
  910|  25.9k|  memcpy(ret, out, (size_t)34U * sizeof(uint8_t));
  911|  25.9k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_matrix_sample_matrix_A_2b:
 6854|  25.9k|    uint8_t *seed, bool transpose) {
 6855|   103k|  for (size_t i0 = (size_t)0U; i0 < (size_t)3U; i0++) {
  ------------------
  |  Branch (6855:32): [True: 77.7k, False: 25.9k]
  ------------------
 6856|  77.7k|    size_t i1 = i0;
 6857|  77.7k|    uint8_t seeds[3U][34U];
 6858|   311k|    for (size_t i = (size_t)0U; i < (size_t)3U; i++) {
  ------------------
  |  Branch (6858:33): [True: 233k, False: 77.7k]
  ------------------
 6859|   233k|      core_array__core__clone__Clone_for__Array_T__N___clone(
  ------------------
  |  |  236|   233k|  (memcpy(dst, src, len * sizeof(elem_type)))
  ------------------
 6860|   233k|          (size_t)34U, seed, seeds[i], uint8_t, void *);
 6861|   233k|    }
 6862|   311k|    for (size_t i = (size_t)0U; i < (size_t)3U; i++) {
  ------------------
  |  Branch (6862:33): [True: 233k, False: 77.7k]
  ------------------
 6863|   233k|      size_t j = i;
 6864|   233k|      seeds[j][32U] = (uint8_t)i1;
 6865|   233k|      seeds[j][33U] = (uint8_t)j;
 6866|   233k|    }
 6867|  77.7k|    libcrux_ml_kem_polynomial_PolynomialRingElement_1d sampled[3U];
 6868|  77.7k|    libcrux_ml_kem_sampling_sample_from_xof_2b(seeds, sampled);
 6869|  77.7k|    for (size_t i = (size_t)0U;
 6870|   311k|         i < Eurydice_slice_len(
  ------------------
  |  |  173|   311k|#define Eurydice_slice_len(s, _) (s).len
  ------------------
  |  Branch (6870:10): [True: 233k, False: 77.7k]
  ------------------
 6871|  77.7k|                 Eurydice_array_to_slice(
 6872|  77.7k|                     (size_t)3U, sampled,
 6873|  77.7k|                     libcrux_ml_kem_polynomial_PolynomialRingElement_1d),
 6874|  77.7k|                 libcrux_ml_kem_polynomial_PolynomialRingElement_1d);
 6875|   233k|         i++) {
 6876|   233k|      size_t j = i;
 6877|   233k|      libcrux_ml_kem_polynomial_PolynomialRingElement_1d sample = sampled[j];
 6878|   233k|      if (transpose) {
  ------------------
  |  Branch (6878:11): [True: 77.7k, False: 155k]
  ------------------
 6879|  77.7k|        A_transpose[j][i1] = sample;
 6880|   155k|      } else {
 6881|   155k|        A_transpose[i1][j] = sample;
 6882|   155k|      }
 6883|   233k|    }
 6884|  77.7k|  }
 6885|  25.9k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_sampling_sample_from_xof_2b:
 6808|  77.7k|    libcrux_ml_kem_polynomial_PolynomialRingElement_1d ret[3U]) {
 6809|  77.7k|  size_t sampled_coefficients[3U] = {0U};
 6810|  77.7k|  int16_t out[3U][272U] = {{0U}};
 6811|  77.7k|  libcrux_ml_kem_hash_functions_portable_PortableHash_88 xof_state =
 6812|  77.7k|      libcrux_ml_kem_hash_functions_portable_shake128_init_absorb_final_4a_e0(
 6813|  77.7k|          seeds);
 6814|  77.7k|  uint8_t randomness0[3U][504U];
 6815|  77.7k|  libcrux_ml_kem_hash_functions_portable_shake128_squeeze_first_three_blocks_4a_e0(
 6816|  77.7k|      &xof_state, randomness0);
 6817|  77.7k|  bool done = libcrux_ml_kem_sampling_sample_from_uniform_distribution_next_89(
 6818|  77.7k|      randomness0, sampled_coefficients, out);
 6819|  79.6k|  while (true) {
  ------------------
  |  Branch (6819:10): [True: 79.6k, Folded]
  ------------------
 6820|  79.6k|    if (done) {
  ------------------
  |  Branch (6820:9): [True: 77.7k, False: 1.87k]
  ------------------
 6821|  77.7k|      break;
 6822|  77.7k|    } else {
 6823|  1.87k|      uint8_t randomness[3U][168U];
 6824|  1.87k|      libcrux_ml_kem_hash_functions_portable_shake128_squeeze_next_block_4a_e0(
 6825|  1.87k|          &xof_state, randomness);
 6826|  1.87k|      done = libcrux_ml_kem_sampling_sample_from_uniform_distribution_next_890(
 6827|  1.87k|          randomness, sampled_coefficients, out);
 6828|  1.87k|    }
 6829|  79.6k|  }
 6830|       |  /* Passing arrays by value in Rust generates a copy in C */
 6831|  77.7k|  int16_t copy_of_out[3U][272U];
 6832|  77.7k|  memcpy(copy_of_out, out, (size_t)3U * sizeof(int16_t[272U]));
 6833|  77.7k|  libcrux_ml_kem_polynomial_PolynomialRingElement_1d ret0[3U];
 6834|   311k|  for (size_t i = (size_t)0U; i < (size_t)3U; i++) {
  ------------------
  |  Branch (6834:31): [True: 233k, False: 77.7k]
  ------------------
 6835|       |    /* original Rust expression is not an lvalue in C */
 6836|   233k|    void *lvalue = (void *)0U;
 6837|   233k|    ret0[i] = libcrux_ml_kem_sampling_sample_from_xof_call_mut_e7_2b(
 6838|   233k|        &lvalue, copy_of_out[i]);
 6839|   233k|  }
 6840|  77.7k|  memcpy(
 6841|  77.7k|      ret, ret0,
 6842|  77.7k|      (size_t)3U * sizeof(libcrux_ml_kem_polynomial_PolynomialRingElement_1d));
 6843|  77.7k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_hash_functions_portable_shake128_init_absorb_final_4a_e0:
 6489|  77.7k|    uint8_t (*input)[34U]) {
 6490|  77.7k|  return libcrux_ml_kem_hash_functions_portable_shake128_init_absorb_final_e0(
 6491|  77.7k|      input);
 6492|  77.7k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_hash_functions_portable_shake128_init_absorb_final_e0:
 6460|  77.7k|    uint8_t (*input)[34U]) {
 6461|  77.7k|  libcrux_ml_kem_hash_functions_portable_PortableHash_88 shake128_state;
 6462|  77.7k|  libcrux_sha3_generic_keccak_KeccakState_17 repeat_expression[3U];
 6463|   311k|  for (size_t i = (size_t)0U; i < (size_t)3U; i++) {
  ------------------
  |  Branch (6463:31): [True: 233k, False: 77.7k]
  ------------------
 6464|   233k|    repeat_expression[i] = libcrux_sha3_portable_incremental_shake128_init();
 6465|   233k|  }
 6466|  77.7k|  memcpy(shake128_state.shake128_state, repeat_expression,
 6467|  77.7k|         (size_t)3U * sizeof(libcrux_sha3_generic_keccak_KeccakState_17));
 6468|   311k|  for (size_t i = (size_t)0U; i < (size_t)3U; i++) {
  ------------------
  |  Branch (6468:31): [True: 233k, False: 77.7k]
  ------------------
 6469|   233k|    size_t i0 = i;
 6470|   233k|    libcrux_sha3_portable_incremental_shake128_absorb_final(
 6471|   233k|        &shake128_state.shake128_state[i0],
 6472|   233k|        Eurydice_array_to_slice((size_t)34U, input[i0], uint8_t));
  ------------------
  |  |  204|   233k|  EURYDICE_SLICE(x, 0,                     \
  |  |  ------------------
  |  |  |  |  169|   233k|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|   233k|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  205|   233k|                 end) /* x is already at an array type, no need for cast */
  ------------------
 6473|   233k|  }
 6474|  77.7k|  return shake128_state;
 6475|  77.7k|}
libcrux_mlkem768_sha3.c:libcrux_sha3_portable_incremental_shake128_init:
 3466|   233k|libcrux_sha3_portable_incremental_shake128_init(void) {
 3467|   233k|  return libcrux_sha3_generic_keccak_new_80_04();
 3468|   233k|}
libcrux_mlkem768_sha3.c:libcrux_sha3_portable_incremental_shake128_absorb_final:
 3563|   233k|    libcrux_sha3_generic_keccak_KeccakState_17 *s, Eurydice_slice data0) {
 3564|   233k|  libcrux_sha3_generic_keccak_KeccakState_17 *uu____0 = s;
 3565|   233k|  Eurydice_slice uu____1[1U] = {data0};
 3566|   233k|  libcrux_sha3_generic_keccak_absorb_final_80_9e2(
 3567|   233k|      uu____0, uu____1, (size_t)0U, Eurydice_slice_len(data0, uint8_t));
  ------------------
  |  |  173|   233k|#define Eurydice_slice_len(s, _) (s).len
  ------------------
 3568|   233k|}
libcrux_mlkem768_sha3.c:libcrux_sha3_generic_keccak_absorb_final_80_9e2:
 3553|   233k|    size_t start, size_t len) {
 3554|   233k|  libcrux_sha3_simd_portable_load_last_a1_c6(self, last, start, len);
 3555|   233k|  libcrux_sha3_generic_keccak_keccakf1600_80_04(self);
 3556|   233k|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_load_last_a1_c6:
 3535|   233k|    size_t start, size_t len) {
 3536|   233k|  libcrux_sha3_simd_portable_load_last_c6(self->st, input[0U], start, len);
 3537|   233k|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_load_last_c6:
 3508|   233k|    uint64_t *state, Eurydice_slice blocks, size_t start, size_t len) {
 3509|   233k|  uint8_t buffer[168U] = {0U};
 3510|   233k|  Eurydice_slice_copy(
  ------------------
  |  |  229|   233k|  memcpy(dst.ptr, src.ptr, dst.len * sizeof(t))
  ------------------
 3511|   233k|      Eurydice_array_to_subslice3(buffer, (size_t)0U, len, uint8_t *),
 3512|   233k|      Eurydice_slice_subslice3(blocks, start, start + len, uint8_t *), uint8_t);
 3513|   233k|  buffer[len] = 31U;
 3514|   233k|  size_t uu____0 = (size_t)168U - (size_t)1U;
 3515|   233k|  buffer[uu____0] = (uint32_t)buffer[uu____0] | 128U;
 3516|   233k|  libcrux_sha3_simd_portable_load_block_3a(
 3517|   233k|      state, Eurydice_array_to_slice((size_t)168U, buffer, uint8_t),
  ------------------
  |  |  204|   233k|  EURYDICE_SLICE(x, 0,                     \
  |  |  ------------------
  |  |  |  |  169|   233k|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|   233k|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  205|   233k|                 end) /* x is already at an array type, no need for cast */
  ------------------
 3518|   233k|      (size_t)0U);
 3519|   233k|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_load_block_3a:
 3476|   233k|    uint64_t *state, Eurydice_slice blocks, size_t start) {
 3477|   233k|  uint64_t state_flat[25U] = {0U};
 3478|  5.13M|  for (size_t i = (size_t)0U; i < (size_t)168U / (size_t)8U; i++) {
  ------------------
  |  Branch (3478:31): [True: 4.89M, False: 233k]
  ------------------
 3479|  4.89M|    size_t i0 = i;
 3480|  4.89M|    size_t offset = start + (size_t)8U * i0;
 3481|  4.89M|    uint8_t uu____0[8U];
 3482|  4.89M|    Result_15 dst;
 3483|  4.89M|    Eurydice_slice_to_array2(
  ------------------
  |  |  277|  4.89M|  Eurydice_slice_to_array3(&(dst)->tag, (char *)&(dst)->val.case_Ok, src, \
  |  |  278|  4.89M|                           sizeof(t_arr))
  ------------------
 3484|  4.89M|        &dst,
 3485|  4.89M|        Eurydice_slice_subslice3(blocks, offset, offset + (size_t)8U,
 3486|  4.89M|                                 uint8_t *),
 3487|  4.89M|        Eurydice_slice, uint8_t[8U], TryFromSliceError);
 3488|  4.89M|    unwrap_26_68(dst, uu____0);
 3489|  4.89M|    state_flat[i0] = core_num__u64__from_le_bytes(uu____0);
 3490|  4.89M|  }
 3491|  5.13M|  for (size_t i = (size_t)0U; i < (size_t)168U / (size_t)8U; i++) {
  ------------------
  |  Branch (3491:31): [True: 4.89M, False: 233k]
  ------------------
 3492|  4.89M|    size_t i0 = i;
 3493|  4.89M|    libcrux_sha3_traits_set_ij_04(
 3494|  4.89M|        state, i0 / (size_t)5U, i0 % (size_t)5U,
 3495|  4.89M|        libcrux_sha3_traits_get_ij_04(state, i0 / (size_t)5U,
 3496|  4.89M|                                      i0 % (size_t)5U)[0U] ^
 3497|  4.89M|            state_flat[i0]);
 3498|  4.89M|  }
 3499|   233k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_hash_functions_portable_shake128_squeeze_first_three_blocks_4a_e0:
 6527|  77.7k|    uint8_t ret[3U][504U]) {
 6528|  77.7k|  libcrux_ml_kem_hash_functions_portable_shake128_squeeze_first_three_blocks_e0(
 6529|  77.7k|      self, ret);
 6530|  77.7k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_hash_functions_portable_shake128_squeeze_first_three_blocks_e0:
 6503|  77.7k|    uint8_t ret[3U][504U]) {
 6504|  77.7k|  uint8_t out[3U][504U] = {{0U}};
 6505|   311k|  for (size_t i = (size_t)0U; i < (size_t)3U; i++) {
  ------------------
  |  Branch (6505:31): [True: 233k, False: 77.7k]
  ------------------
 6506|   233k|    size_t i0 = i;
 6507|   233k|    libcrux_sha3_portable_incremental_shake128_squeeze_first_three_blocks(
 6508|   233k|        &st->shake128_state[i0],
 6509|   233k|        Eurydice_array_to_slice((size_t)504U, out[i0], uint8_t));
  ------------------
  |  |  204|   233k|  EURYDICE_SLICE(x, 0,                     \
  |  |  ------------------
  |  |  |  |  169|   233k|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|   233k|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  205|   233k|                 end) /* x is already at an array type, no need for cast */
  ------------------
 6510|   233k|  }
 6511|  77.7k|  memcpy(ret, out, (size_t)3U * sizeof(uint8_t[504U]));
 6512|  77.7k|}
libcrux_mlkem768_sha3.c:libcrux_sha3_portable_incremental_shake128_squeeze_first_three_blocks:
 3652|   233k|    libcrux_sha3_generic_keccak_KeccakState_17 *s, Eurydice_slice out0) {
 3653|   233k|  libcrux_sha3_generic_keccak_portable_squeeze_first_three_blocks_b4_3a(s,
 3654|   233k|                                                                        out0);
 3655|   233k|}
libcrux_mlkem768_sha3.c:libcrux_sha3_generic_keccak_portable_squeeze_first_three_blocks_b4_3a:
 3637|   233k|    libcrux_sha3_generic_keccak_KeccakState_17 *self, Eurydice_slice out) {
 3638|   233k|  libcrux_sha3_simd_portable_squeeze_13_3a(self, out, (size_t)0U, (size_t)168U);
 3639|   233k|  libcrux_sha3_generic_keccak_keccakf1600_80_04(self);
 3640|   233k|  libcrux_sha3_simd_portable_squeeze_13_3a(self, out, (size_t)168U,
 3641|   233k|                                           (size_t)168U);
 3642|   233k|  libcrux_sha3_generic_keccak_keccakf1600_80_04(self);
 3643|   233k|  libcrux_sha3_simd_portable_squeeze_13_3a(self, out, (size_t)2U * (size_t)168U,
 3644|   233k|                                           (size_t)168U);
 3645|   233k|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_squeeze_13_3a:
 3619|   705k|    size_t start, size_t len) {
 3620|   705k|  libcrux_sha3_simd_portable_store_block_3a(self->st, out, start, len);
 3621|   705k|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_store_block_3a:
 3576|   705k|    uint64_t *s, Eurydice_slice out, size_t start, size_t len) {
 3577|   705k|  size_t octets = len / (size_t)8U;
 3578|  15.5M|  for (size_t i = (size_t)0U; i < octets; i++) {
  ------------------
  |  Branch (3578:31): [True: 14.8M, False: 705k]
  ------------------
 3579|  14.8M|    size_t i0 = i;
 3580|  14.8M|    Eurydice_slice uu____0 = Eurydice_slice_subslice3(
  ------------------
  |  |  195|  14.8M|  EURYDICE_SLICE((t_ptr)s.ptr, (start), (end))
  |  |  ------------------
  |  |  |  |  169|  14.8M|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|  14.8M|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3581|  14.8M|        out, start + (size_t)8U * i0, start + (size_t)8U * i0 + (size_t)8U,
 3582|  14.8M|        uint8_t *);
 3583|  14.8M|    uint8_t ret[8U];
 3584|  14.8M|    core_num__u64__to_le_bytes(
 3585|  14.8M|        libcrux_sha3_traits_get_ij_04(s, i0 / (size_t)5U, i0 % (size_t)5U)[0U],
 3586|  14.8M|        ret);
 3587|  14.8M|    Eurydice_slice_copy(
  ------------------
  |  |  229|  14.8M|  memcpy(dst.ptr, src.ptr, dst.len * sizeof(t))
  ------------------
 3588|  14.8M|        uu____0, Eurydice_array_to_slice((size_t)8U, ret, uint8_t), uint8_t);
 3589|  14.8M|  }
 3590|   705k|  size_t remaining = len % (size_t)8U;
 3591|   705k|  if (remaining > (size_t)0U) {
  ------------------
  |  Branch (3591:7): [True: 0, False: 705k]
  ------------------
 3592|      0|    Eurydice_slice uu____1 = Eurydice_slice_subslice3(
  ------------------
  |  |  195|      0|  EURYDICE_SLICE((t_ptr)s.ptr, (start), (end))
  |  |  ------------------
  |  |  |  |  169|      0|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      0|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3593|      0|        out, start + len - remaining, start + len, uint8_t *);
 3594|      0|    uint8_t ret[8U];
 3595|      0|    core_num__u64__to_le_bytes(
 3596|      0|        libcrux_sha3_traits_get_ij_04(s, octets / (size_t)5U,
 3597|      0|                                      octets % (size_t)5U)[0U],
 3598|      0|        ret);
 3599|      0|    Eurydice_slice_copy(
  ------------------
  |  |  229|      0|  memcpy(dst.ptr, src.ptr, dst.len * sizeof(t))
  ------------------
 3600|      0|        uu____1,
 3601|      0|        Eurydice_array_to_subslice3(ret, (size_t)0U, remaining, uint8_t *),
 3602|      0|        uint8_t);
 3603|      0|  }
 3604|   705k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_sampling_sample_from_uniform_distribution_next_89:
 6583|  77.7k|    int16_t (*out)[272U]) {
 6584|   311k|  for (size_t i0 = (size_t)0U; i0 < (size_t)3U; i0++) {
  ------------------
  |  Branch (6584:32): [True: 233k, False: 77.7k]
  ------------------
 6585|   233k|    size_t i1 = i0;
 6586|  5.13M|    for (size_t i = (size_t)0U; i < (size_t)504U / (size_t)24U; i++) {
  ------------------
  |  Branch (6586:33): [True: 4.89M, False: 233k]
  ------------------
 6587|  4.89M|      size_t r = i;
 6588|  4.89M|      if (sampled_coefficients[i1] <
  ------------------
  |  Branch (6588:11): [True: 4.69M, False: 199k]
  ------------------
 6589|  4.89M|          LIBCRUX_ML_KEM_CONSTANTS_COEFFICIENTS_IN_RING_ELEMENT) {
  ------------------
  |  |  447|  4.89M|#define LIBCRUX_ML_KEM_CONSTANTS_COEFFICIENTS_IN_RING_ELEMENT ((size_t)256U)
  ------------------
 6590|  4.69M|        size_t sampled = libcrux_ml_kem_vector_portable_rej_sample_b8(
 6591|  4.69M|            Eurydice_array_to_subslice3(randomness[i1], r * (size_t)24U,
  ------------------
  |  |  215|  4.69M|  EURYDICE_SLICE((t_ptr)x, (start), (end))
  |  |  ------------------
  |  |  |  |  169|  4.69M|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|  4.69M|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 6592|  4.69M|                                        r * (size_t)24U + (size_t)24U,
 6593|  4.69M|                                        uint8_t *),
 6594|  4.69M|            Eurydice_array_to_subslice3(out[i1], sampled_coefficients[i1],
  ------------------
  |  |  215|  4.69M|  EURYDICE_SLICE((t_ptr)x, (start), (end))
  |  |  ------------------
  |  |  |  |  169|  4.69M|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|  4.69M|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 6595|  4.69M|                                        sampled_coefficients[i1] + (size_t)16U,
 6596|  4.69M|                                        int16_t *));
 6597|  4.69M|        size_t uu____0 = i1;
 6598|  4.69M|        sampled_coefficients[uu____0] = sampled_coefficients[uu____0] + sampled;
 6599|  4.69M|      }
 6600|  4.89M|    }
 6601|   233k|  }
 6602|  77.7k|  bool done = true;
 6603|   311k|  for (size_t i = (size_t)0U; i < (size_t)3U; i++) {
  ------------------
  |  Branch (6603:31): [True: 233k, False: 77.7k]
  ------------------
 6604|   233k|    size_t i0 = i;
 6605|   233k|    if (sampled_coefficients[i0] >=
  ------------------
  |  Branch (6605:9): [True: 231k, False: 1.90k]
  ------------------
 6606|   233k|        LIBCRUX_ML_KEM_CONSTANTS_COEFFICIENTS_IN_RING_ELEMENT) {
  ------------------
  |  |  447|   233k|#define LIBCRUX_ML_KEM_CONSTANTS_COEFFICIENTS_IN_RING_ELEMENT ((size_t)256U)
  ------------------
 6607|   231k|      sampled_coefficients[i0] =
 6608|   231k|          LIBCRUX_ML_KEM_CONSTANTS_COEFFICIENTS_IN_RING_ELEMENT;
  ------------------
  |  |  447|   231k|#define LIBCRUX_ML_KEM_CONSTANTS_COEFFICIENTS_IN_RING_ELEMENT ((size_t)256U)
  ------------------
 6609|   231k|    } else {
 6610|       |      done = false;
 6611|  1.90k|    }
 6612|   233k|  }
 6613|  77.7k|  return done;
 6614|  77.7k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_vector_portable_rej_sample_b8:
 5219|  4.70M|    Eurydice_slice a, Eurydice_slice out) {
 5220|  4.70M|  return libcrux_ml_kem_vector_portable_sampling_rej_sample(a, out);
 5221|  4.70M|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_vector_portable_sampling_rej_sample:
 5185|  4.70M|                                                   Eurydice_slice result) {
 5186|  4.70M|  size_t sampled = (size_t)0U;
 5187|  42.3M|  for (size_t i = (size_t)0U; i < Eurydice_slice_len(a, uint8_t) / (size_t)3U;
  ------------------
  |  |  173|  42.3M|#define Eurydice_slice_len(s, _) (s).len
  ------------------
  |  Branch (5187:31): [True: 37.6M, False: 4.70M]
  ------------------
 5188|  37.6M|       i++) {
 5189|  37.6M|    size_t i0 = i;
 5190|  37.6M|    int16_t b1 = (int16_t)Eurydice_slice_index(a, i0 * (size_t)3U + (size_t)0U,
  ------------------
  |  |  180|  37.6M|#define Eurydice_slice_index(s, i, t, t_ptr_t) (((t_ptr_t)s.ptr)[i])
  ------------------
 5191|  37.6M|                                               uint8_t, uint8_t *);
 5192|  37.6M|    int16_t b2 = (int16_t)Eurydice_slice_index(a, i0 * (size_t)3U + (size_t)1U,
  ------------------
  |  |  180|  37.6M|#define Eurydice_slice_index(s, i, t, t_ptr_t) (((t_ptr_t)s.ptr)[i])
  ------------------
 5193|  37.6M|                                               uint8_t, uint8_t *);
 5194|  37.6M|    int16_t b3 = (int16_t)Eurydice_slice_index(a, i0 * (size_t)3U + (size_t)2U,
  ------------------
  |  |  180|  37.6M|#define Eurydice_slice_index(s, i, t, t_ptr_t) (((t_ptr_t)s.ptr)[i])
  ------------------
 5195|  37.6M|                                               uint8_t, uint8_t *);
 5196|  37.6M|    int16_t d1 = (b2 & (int16_t)15) << 8U | b1;
 5197|  37.6M|    int16_t d2 = b3 << 4U | b2 >> 4U;
 5198|  37.6M|    if (d1 < LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_MODULUS) {
  ------------------
  |  | 3777|  37.6M|#define LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_MODULUS ((int16_t)3329)
  ------------------
  |  Branch (5198:9): [True: 30.5M, False: 7.03M]
  ------------------
 5199|  30.5M|      if (sampled < (size_t)16U) {
  ------------------
  |  Branch (5199:11): [True: 30.5M, False: 0]
  ------------------
 5200|  30.5M|        Eurydice_slice_index(result, sampled, int16_t, int16_t *) = d1;
  ------------------
  |  |  180|  30.5M|#define Eurydice_slice_index(s, i, t, t_ptr_t) (((t_ptr_t)s.ptr)[i])
  ------------------
 5201|  30.5M|        sampled++;
 5202|  30.5M|      }
 5203|  30.5M|    }
 5204|  37.6M|    if (d2 < LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_MODULUS) {
  ------------------
  |  | 3777|  37.6M|#define LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_MODULUS ((int16_t)3329)
  ------------------
  |  Branch (5204:9): [True: 30.5M, False: 7.03M]
  ------------------
 5205|  30.5M|      if (sampled < (size_t)16U) {
  ------------------
  |  Branch (5205:11): [True: 30.5M, False: 0]
  ------------------
 5206|  30.5M|        Eurydice_slice_index(result, sampled, int16_t, int16_t *) = d2;
  ------------------
  |  |  180|  30.5M|#define Eurydice_slice_index(s, i, t, t_ptr_t) (((t_ptr_t)s.ptr)[i])
  ------------------
 5207|  30.5M|        sampled++;
 5208|  30.5M|      }
 5209|  30.5M|    }
 5210|  37.6M|  }
 5211|  4.70M|  return sampled;
 5212|  4.70M|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_hash_functions_portable_shake128_squeeze_next_block_4a_e0:
 6649|  1.87k|    uint8_t ret[3U][168U]) {
 6650|  1.87k|  libcrux_ml_kem_hash_functions_portable_shake128_squeeze_next_block_e0(self,
 6651|  1.87k|                                                                        ret);
 6652|  1.87k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_hash_functions_portable_shake128_squeeze_next_block_e0:
 6625|  1.87k|    uint8_t ret[3U][168U]) {
 6626|  1.87k|  uint8_t out[3U][168U] = {{0U}};
 6627|  7.50k|  for (size_t i = (size_t)0U; i < (size_t)3U; i++) {
  ------------------
  |  Branch (6627:31): [True: 5.62k, False: 1.87k]
  ------------------
 6628|  5.62k|    size_t i0 = i;
 6629|  5.62k|    libcrux_sha3_portable_incremental_shake128_squeeze_next_block(
 6630|  5.62k|        &st->shake128_state[i0],
 6631|  5.62k|        Eurydice_array_to_slice((size_t)168U, out[i0], uint8_t));
  ------------------
  |  |  204|  5.62k|  EURYDICE_SLICE(x, 0,                     \
  |  |  ------------------
  |  |  |  |  169|  5.62k|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|  5.62k|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  205|  5.62k|                 end) /* x is already at an array type, no need for cast */
  ------------------
 6632|  5.62k|  }
 6633|  1.87k|  memcpy(ret, out, (size_t)3U * sizeof(uint8_t[168U]));
 6634|  1.87k|}
libcrux_mlkem768_sha3.c:libcrux_sha3_portable_incremental_shake128_squeeze_next_block:
 3681|  5.62k|    libcrux_sha3_generic_keccak_KeccakState_17 *s, Eurydice_slice out0) {
 3682|  5.62k|  libcrux_sha3_generic_keccak_portable_squeeze_next_block_b4_3a(s, out0,
 3683|  5.62k|                                                                (size_t)0U);
 3684|  5.62k|}
libcrux_mlkem768_sha3.c:libcrux_sha3_generic_keccak_portable_squeeze_next_block_b4_3a:
 3671|  5.62k|    size_t start) {
 3672|  5.62k|  libcrux_sha3_generic_keccak_keccakf1600_80_04(self);
 3673|  5.62k|  libcrux_sha3_simd_portable_squeeze_13_3a(self, out, start, (size_t)168U);
 3674|  5.62k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_sampling_sample_from_uniform_distribution_next_890:
 6705|  1.87k|    int16_t (*out)[272U]) {
 6706|  7.50k|  for (size_t i0 = (size_t)0U; i0 < (size_t)3U; i0++) {
  ------------------
  |  Branch (6706:32): [True: 5.62k, False: 1.87k]
  ------------------
 6707|  5.62k|    size_t i1 = i0;
 6708|  45.0k|    for (size_t i = (size_t)0U; i < (size_t)168U / (size_t)24U; i++) {
  ------------------
  |  Branch (6708:33): [True: 39.3k, False: 5.62k]
  ------------------
 6709|  39.3k|      size_t r = i;
 6710|  39.3k|      if (sampled_coefficients[i1] <
  ------------------
  |  Branch (6710:11): [True: 1.90k, False: 37.4k]
  ------------------
 6711|  39.3k|          LIBCRUX_ML_KEM_CONSTANTS_COEFFICIENTS_IN_RING_ELEMENT) {
  ------------------
  |  |  447|  39.3k|#define LIBCRUX_ML_KEM_CONSTANTS_COEFFICIENTS_IN_RING_ELEMENT ((size_t)256U)
  ------------------
 6712|  1.90k|        size_t sampled = libcrux_ml_kem_vector_portable_rej_sample_b8(
 6713|  1.90k|            Eurydice_array_to_subslice3(randomness[i1], r * (size_t)24U,
  ------------------
  |  |  215|  1.90k|  EURYDICE_SLICE((t_ptr)x, (start), (end))
  |  |  ------------------
  |  |  |  |  169|  1.90k|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|  1.90k|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 6714|  1.90k|                                        r * (size_t)24U + (size_t)24U,
 6715|  1.90k|                                        uint8_t *),
 6716|  1.90k|            Eurydice_array_to_subslice3(out[i1], sampled_coefficients[i1],
  ------------------
  |  |  215|  1.90k|  EURYDICE_SLICE((t_ptr)x, (start), (end))
  |  |  ------------------
  |  |  |  |  169|  1.90k|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|  1.90k|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 6717|  1.90k|                                        sampled_coefficients[i1] + (size_t)16U,
 6718|  1.90k|                                        int16_t *));
 6719|  1.90k|        size_t uu____0 = i1;
 6720|  1.90k|        sampled_coefficients[uu____0] = sampled_coefficients[uu____0] + sampled;
 6721|  1.90k|      }
 6722|  39.3k|    }
 6723|  5.62k|  }
 6724|  1.87k|  bool done = true;
 6725|  7.50k|  for (size_t i = (size_t)0U; i < (size_t)3U; i++) {
  ------------------
  |  Branch (6725:31): [True: 5.62k, False: 1.87k]
  ------------------
 6726|  5.62k|    size_t i0 = i;
 6727|  5.62k|    if (sampled_coefficients[i0] >=
  ------------------
  |  Branch (6727:9): [True: 5.62k, False: 0]
  ------------------
 6728|  5.62k|        LIBCRUX_ML_KEM_CONSTANTS_COEFFICIENTS_IN_RING_ELEMENT) {
  ------------------
  |  |  447|  5.62k|#define LIBCRUX_ML_KEM_CONSTANTS_COEFFICIENTS_IN_RING_ELEMENT ((size_t)256U)
  ------------------
 6729|  5.62k|      sampled_coefficients[i0] =
 6730|  5.62k|          LIBCRUX_ML_KEM_CONSTANTS_COEFFICIENTS_IN_RING_ELEMENT;
  ------------------
  |  |  447|  5.62k|#define LIBCRUX_ML_KEM_CONSTANTS_COEFFICIENTS_IN_RING_ELEMENT ((size_t)256U)
  ------------------
 6731|  5.62k|    } else {
 6732|       |      done = false;
 6733|      0|    }
 6734|  5.62k|  }
 6735|  1.87k|  return done;
 6736|  1.87k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_sampling_sample_from_xof_call_mut_e7_2b:
 6792|   233k|    void **_, int16_t tupled_args[272U]) {
 6793|   233k|  int16_t s[272U];
 6794|   233k|  memcpy(s, tupled_args, (size_t)272U * sizeof(int16_t));
 6795|   233k|  return libcrux_ml_kem_polynomial_from_i16_array_d6_ea(
 6796|   233k|      Eurydice_array_to_subslice3(s, (size_t)0U, (size_t)256U, int16_t *));
  ------------------
  |  |  215|   233k|  EURYDICE_SLICE((t_ptr)x, (start), (end))
  |  |  ------------------
  |  |  |  |  169|   233k|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|   233k|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 6797|   233k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_polynomial_from_i16_array_d6_ea:
 6773|   406k|libcrux_ml_kem_polynomial_from_i16_array_d6_ea(Eurydice_slice a) {
 6774|   406k|  return libcrux_ml_kem_polynomial_from_i16_array_ea(a);
 6775|   406k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_polynomial_from_i16_array_ea:
 6745|   406k|libcrux_ml_kem_polynomial_from_i16_array_ea(Eurydice_slice a) {
 6746|   406k|  libcrux_ml_kem_polynomial_PolynomialRingElement_1d result =
 6747|   406k|      libcrux_ml_kem_polynomial_ZERO_ea();
 6748|   406k|  for (size_t i = (size_t)0U;
 6749|  6.90M|       i < LIBCRUX_ML_KEM_POLYNOMIAL_VECTORS_IN_RING_ELEMENT; i++) {
  ------------------
  |  | 3770|  6.90M|#define LIBCRUX_ML_KEM_POLYNOMIAL_VECTORS_IN_RING_ELEMENT ((size_t)16U)
  ------------------
  |  Branch (6749:8): [True: 6.49M, False: 406k]
  ------------------
 6750|  6.49M|    size_t i0 = i;
 6751|  6.49M|    libcrux_ml_kem_vector_portable_vector_type_PortableVector uu____0 =
 6752|  6.49M|        libcrux_ml_kem_vector_portable_from_i16_array_b8(
 6753|  6.49M|            Eurydice_slice_subslice3(a, i0 * (size_t)16U,
  ------------------
  |  |  195|  6.49M|  EURYDICE_SLICE((t_ptr)s.ptr, (start), (end))
  |  |  ------------------
  |  |  |  |  169|  6.49M|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|  6.49M|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 6754|  6.49M|                                     (i0 + (size_t)1U) * (size_t)16U,
 6755|  6.49M|                                     int16_t *));
 6756|  6.49M|    result.coefficients[i0] = uu____0;
 6757|  6.49M|  }
 6758|   406k|  return result;
 6759|   406k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_vector_portable_from_i16_array_b8:
 3805|  6.49M|libcrux_ml_kem_vector_portable_from_i16_array_b8(Eurydice_slice array) {
 3806|  6.49M|  return libcrux_ml_kem_vector_portable_vector_type_from_i16_array(
 3807|  6.49M|      libcrux_secrets_int_classify_public_classify_ref_9b_39(array));
 3808|  6.49M|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_vector_portable_vector_type_from_i16_array:
 3788|  6.49M|    Eurydice_slice array) {
 3789|  6.49M|  libcrux_ml_kem_vector_portable_vector_type_PortableVector lit;
 3790|  6.49M|  int16_t ret[16U];
 3791|  6.49M|  Result_0a dst;
 3792|  6.49M|  Eurydice_slice_to_array2(
  ------------------
  |  |  277|  6.49M|  Eurydice_slice_to_array3(&(dst)->tag, (char *)&(dst)->val.case_Ok, src, \
  |  |  278|  6.49M|                           sizeof(t_arr))
  ------------------
 3793|  6.49M|      &dst, Eurydice_slice_subslice3(array, (size_t)0U, (size_t)16U, int16_t *),
 3794|  6.49M|      Eurydice_slice, int16_t[16U], TryFromSliceError);
 3795|  6.49M|  unwrap_26_00(dst, ret);
 3796|  6.49M|  memcpy(lit.elements, ret, (size_t)16U * sizeof(int16_t));
 3797|  6.49M|  return lit;
 3798|  6.49M|}
libcrux_mlkem768_sha3.c:unwrap_26_00:
 1129|  6.49M|static inline void unwrap_26_00(Result_0a self, int16_t ret[16U]) {
 1130|  6.49M|  if (self.tag == Ok) {
  ------------------
  |  |  721|  6.49M|#define Ok 0
  ------------------
  |  Branch (1130:7): [True: 6.49M, False: 0]
  ------------------
 1131|  6.49M|    int16_t f0[16U];
 1132|  6.49M|    memcpy(f0, self.val.case_Ok, (size_t)16U * sizeof(int16_t));
 1133|  6.49M|    memcpy(ret, f0, (size_t)16U * sizeof(int16_t));
 1134|  6.49M|  } else {
 1135|      0|    KRML_HOST_EPRINTF("KaRaMeL abort at %s:%d\n%s\n", __FILE__, __LINE__,
 1136|      0|                      "unwrap not Ok");
 1137|       |    KRML_HOST_EXIT(255U);
  ------------------
  |  |   41|      0|#define KRML_HOST_EXIT(x) do { \
  |  |   42|      0|    fprintf(stderr, "mlkem internal error"); \
  |  |   43|      0|    exit(x); \
  |  |   44|      0|} while (0)
  |  |  ------------------
  |  |  |  Branch (44:10): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1138|      0|  }
 1139|  6.49M|}
libcrux_mlkem768_sha3.c:libcrux_secrets_int_classify_public_classify_ref_9b_39:
 1103|  6.49M|libcrux_secrets_int_classify_public_classify_ref_9b_39(Eurydice_slice self) {
 1104|  6.49M|  return self;
 1105|  6.49M|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_ind_cpa_encrypt_unpacked_2a:
 7838|  17.2k|    uint8_t *message, Eurydice_slice randomness, uint8_t ret[1088U]) {
 7839|  17.2k|  uint8_t ciphertext[1088U] = {0U};
 7840|  17.2k|  tuple_ed uu____0 = libcrux_ml_kem_ind_cpa_encrypt_c1_85(
 7841|  17.2k|      randomness, public_key->A,
 7842|  17.2k|      Eurydice_array_to_subslice3(ciphertext, (size_t)0U, (size_t)960U,
  ------------------
  |  |  215|  17.2k|  EURYDICE_SLICE((t_ptr)x, (start), (end))
  |  |  ------------------
  |  |  |  |  169|  17.2k|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|  17.2k|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 7843|  17.2k|                                  uint8_t *));
 7844|  17.2k|  libcrux_ml_kem_polynomial_PolynomialRingElement_1d r_as_ntt[3U];
 7845|  17.2k|  memcpy(
 7846|  17.2k|      r_as_ntt, uu____0.fst,
 7847|  17.2k|      (size_t)3U * sizeof(libcrux_ml_kem_polynomial_PolynomialRingElement_1d));
 7848|  17.2k|  libcrux_ml_kem_polynomial_PolynomialRingElement_1d error_2 = uu____0.snd;
 7849|  17.2k|  libcrux_ml_kem_polynomial_PolynomialRingElement_1d *uu____1 =
 7850|  17.2k|      public_key->t_as_ntt;
 7851|  17.2k|  libcrux_ml_kem_polynomial_PolynomialRingElement_1d *uu____2 = r_as_ntt;
 7852|  17.2k|  libcrux_ml_kem_polynomial_PolynomialRingElement_1d *uu____3 = &error_2;
 7853|  17.2k|  uint8_t *uu____4 = message;
 7854|  17.2k|  libcrux_ml_kem_ind_cpa_encrypt_c2_6c(
 7855|  17.2k|      uu____1, uu____2, uu____3, uu____4,
 7856|  17.2k|      Eurydice_array_to_subslice_from((size_t)1088U, ciphertext, (size_t)960U,
  ------------------
  |  |  225|  17.2k|  EURYDICE_SLICE((t *)x, r, size)
  |  |  ------------------
  |  |  |  |  169|  17.2k|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|  17.2k|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 7857|  17.2k|                                      uint8_t, size_t, uint8_t[]));
 7858|  17.2k|  memcpy(ret, ciphertext, (size_t)1088U * sizeof(uint8_t));
 7859|  17.2k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_ind_cpa_encrypt_c1_85:
 7528|  17.2k|    Eurydice_slice ciphertext) {
 7529|  17.2k|  uint8_t prf_input[33U];
 7530|  17.2k|  libcrux_ml_kem_utils_into_padded_array_c8(randomness, prf_input);
 7531|  17.2k|  libcrux_ml_kem_polynomial_PolynomialRingElement_1d r_as_ntt[3U];
 7532|  69.1k|  for (size_t i = (size_t)0U; i < (size_t)3U; i++) {
  ------------------
  |  Branch (7532:31): [True: 51.8k, False: 17.2k]
  ------------------
 7533|       |    /* original Rust expression is not an lvalue in C */
 7534|  51.8k|    void *lvalue = (void *)0U;
 7535|  51.8k|    r_as_ntt[i] = libcrux_ml_kem_ind_cpa_encrypt_c1_call_mut_f1_85(&lvalue, i);
 7536|  51.8k|  }
 7537|  17.2k|  uint8_t domain_separator0 =
 7538|  17.2k|      libcrux_ml_kem_ind_cpa_sample_vector_cbd_then_ntt_3b(r_as_ntt, prf_input,
 7539|  17.2k|                                                           0U);
 7540|  17.2k|  libcrux_ml_kem_polynomial_PolynomialRingElement_1d error_1[3U];
 7541|  69.1k|  for (size_t i = (size_t)0U; i < (size_t)3U; i++) {
  ------------------
  |  Branch (7541:31): [True: 51.8k, False: 17.2k]
  ------------------
 7542|       |    /* original Rust expression is not an lvalue in C */
 7543|  51.8k|    void *lvalue = (void *)0U;
 7544|  51.8k|    error_1[i] = libcrux_ml_kem_ind_cpa_encrypt_c1_call_mut_dd_85(&lvalue, i);
 7545|  51.8k|  }
 7546|  17.2k|  uint8_t domain_separator = libcrux_ml_kem_ind_cpa_sample_ring_element_cbd_3b(
 7547|  17.2k|      prf_input, domain_separator0, error_1);
 7548|  17.2k|  prf_input[32U] = domain_separator;
 7549|  17.2k|  uint8_t prf_output[128U];
 7550|  17.2k|  libcrux_ml_kem_hash_functions_portable_PRF_4a_410(
 7551|  17.2k|      Eurydice_array_to_slice((size_t)33U, prf_input, uint8_t), prf_output);
  ------------------
  |  |  204|  17.2k|  EURYDICE_SLICE(x, 0,                     \
  |  |  ------------------
  |  |  |  |  169|  17.2k|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|  17.2k|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  205|  17.2k|                 end) /* x is already at an array type, no need for cast */
  ------------------
 7552|  17.2k|  libcrux_ml_kem_polynomial_PolynomialRingElement_1d error_2 =
 7553|  17.2k|      libcrux_ml_kem_sampling_sample_from_binomial_distribution_a0(
 7554|  17.2k|          Eurydice_array_to_slice((size_t)128U, prf_output, uint8_t));
  ------------------
  |  |  204|  17.2k|  EURYDICE_SLICE(x, 0,                     \
  |  |  ------------------
  |  |  |  |  169|  17.2k|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|  17.2k|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  205|  17.2k|                 end) /* x is already at an array type, no need for cast */
  ------------------
 7555|  17.2k|  libcrux_ml_kem_polynomial_PolynomialRingElement_1d u[3U];
 7556|  17.2k|  libcrux_ml_kem_matrix_compute_vector_u_1b(matrix, r_as_ntt, error_1, u);
 7557|  17.2k|  libcrux_ml_kem_polynomial_PolynomialRingElement_1d uu____0[3U];
 7558|  17.2k|  memcpy(
 7559|  17.2k|      uu____0, u,
 7560|  17.2k|      (size_t)3U * sizeof(libcrux_ml_kem_polynomial_PolynomialRingElement_1d));
 7561|  17.2k|  libcrux_ml_kem_ind_cpa_compress_then_serialize_u_43(uu____0, ciphertext);
 7562|       |  /* Passing arrays by value in Rust generates a copy in C */
 7563|  17.2k|  libcrux_ml_kem_polynomial_PolynomialRingElement_1d copy_of_r_as_ntt[3U];
 7564|  17.2k|  memcpy(
 7565|  17.2k|      copy_of_r_as_ntt, r_as_ntt,
 7566|  17.2k|      (size_t)3U * sizeof(libcrux_ml_kem_polynomial_PolynomialRingElement_1d));
 7567|  17.2k|  tuple_ed lit;
 7568|  17.2k|  memcpy(
 7569|  17.2k|      lit.fst, copy_of_r_as_ntt,
 7570|  17.2k|      (size_t)3U * sizeof(libcrux_ml_kem_polynomial_PolynomialRingElement_1d));
 7571|  17.2k|  lit.snd = error_2;
 7572|  17.2k|  return lit;
 7573|  17.2k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_utils_into_padded_array_c8:
  884|  25.9k|    Eurydice_slice slice, uint8_t ret[33U]) {
  885|  25.9k|  uint8_t out[33U] = {0U};
  886|  25.9k|  uint8_t *uu____0 = out;
  887|  25.9k|  Eurydice_slice_copy(
  ------------------
  |  |  229|  25.9k|  memcpy(dst.ptr, src.ptr, dst.len * sizeof(t))
  ------------------
  888|  25.9k|      Eurydice_array_to_subslice3(
  889|  25.9k|          uu____0, (size_t)0U, Eurydice_slice_len(slice, uint8_t), uint8_t *),
  890|  25.9k|      slice, uint8_t);
  891|  25.9k|  memcpy(ret, out, (size_t)33U * sizeof(uint8_t));
  892|  25.9k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_ind_cpa_encrypt_c1_call_mut_f1_85:
 6968|  51.8k|libcrux_ml_kem_ind_cpa_encrypt_c1_call_mut_f1_85(void **_, size_t tupled_args) {
 6969|  51.8k|  return libcrux_ml_kem_polynomial_ZERO_d6_ea();
 6970|  51.8k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_ind_cpa_sample_vector_cbd_then_ntt_3b:
 7177|  34.5k|    uint8_t *prf_input, uint8_t domain_separator) {
 7178|  34.5k|  uint8_t prf_inputs[3U][33U];
 7179|   138k|  for (size_t i = (size_t)0U; i < (size_t)3U; i++) {
  ------------------
  |  Branch (7179:31): [True: 103k, False: 34.5k]
  ------------------
 7180|   103k|    core_array__core__clone__Clone_for__Array_T__N___clone(
  ------------------
  |  |  236|   103k|  (memcpy(dst, src, len * sizeof(elem_type)))
  ------------------
 7181|   103k|        (size_t)33U, prf_input, prf_inputs[i], uint8_t, void *);
 7182|   103k|  }
 7183|  34.5k|  domain_separator =
 7184|  34.5k|      libcrux_ml_kem_utils_prf_input_inc_e0(prf_inputs, domain_separator);
 7185|  34.5k|  uint8_t prf_outputs[3U][128U];
 7186|  34.5k|  libcrux_ml_kem_hash_functions_portable_PRFxN_4a_41(prf_inputs, prf_outputs);
 7187|   138k|  for (size_t i = (size_t)0U; i < (size_t)3U; i++) {
  ------------------
  |  Branch (7187:31): [True: 103k, False: 34.5k]
  ------------------
 7188|   103k|    size_t i0 = i;
 7189|   103k|    re_as_ntt[i0] =
 7190|   103k|        libcrux_ml_kem_sampling_sample_from_binomial_distribution_a0(
 7191|   103k|            Eurydice_array_to_slice((size_t)128U, prf_outputs[i0], uint8_t));
  ------------------
  |  |  204|   103k|  EURYDICE_SLICE(x, 0,                     \
  |  |  ------------------
  |  |  |  |  169|   103k|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|   103k|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  205|   103k|                 end) /* x is already at an array type, no need for cast */
  ------------------
 7192|   103k|    libcrux_ml_kem_ntt_ntt_binomially_sampled_ring_element_ea(&re_as_ntt[i0]);
 7193|   103k|  }
 7194|  34.5k|  return domain_separator;
 7195|  34.5k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_utils_prf_input_inc_e0:
  866|  51.8k|    uint8_t (*prf_inputs)[33U], uint8_t domain_separator) {
  867|   207k|  for (size_t i = (size_t)0U; i < (size_t)3U; i++) {
  ------------------
  |  Branch (867:31): [True: 155k, False: 51.8k]
  ------------------
  868|   155k|    size_t i0 = i;
  869|   155k|    prf_inputs[i0][32U] = domain_separator;
  870|   155k|    domain_separator = (uint32_t)domain_separator + 1U;
  871|   155k|  }
  872|  51.8k|  return domain_separator;
  873|  51.8k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_hash_functions_portable_PRFxN_4a_41:
 7001|  51.8k|    uint8_t (*input)[33U], uint8_t ret[3U][128U]) {
 7002|  51.8k|  libcrux_ml_kem_hash_functions_portable_PRFxN_41(input, ret);
 7003|  51.8k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_hash_functions_portable_PRFxN_41:
 6979|  51.8k|    uint8_t (*input)[33U], uint8_t ret[3U][128U]) {
 6980|  51.8k|  uint8_t out[3U][128U] = {{0U}};
 6981|   207k|  for (size_t i = (size_t)0U; i < (size_t)3U; i++) {
  ------------------
  |  Branch (6981:31): [True: 155k, False: 51.8k]
  ------------------
 6982|   155k|    size_t i0 = i;
 6983|   155k|    libcrux_sha3_portable_shake256(
 6984|   155k|        Eurydice_array_to_slice((size_t)128U, out[i0], uint8_t),
  ------------------
  |  |  204|   155k|  EURYDICE_SLICE(x, 0,                     \
  |  |  ------------------
  |  |  |  |  169|   155k|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|   155k|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  205|   155k|                 end) /* x is already at an array type, no need for cast */
  ------------------
 6985|   155k|        Eurydice_array_to_slice((size_t)33U, input[i0], uint8_t));
  ------------------
  |  |  204|   155k|  EURYDICE_SLICE(x, 0,                     \
  |  |  ------------------
  |  |  |  |  169|   155k|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|   155k|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  205|   155k|                 end) /* x is already at an array type, no need for cast */
  ------------------
 6986|   155k|  }
 6987|  51.8k|  memcpy(ret, out, (size_t)3U * sizeof(uint8_t[128U]));
 6988|  51.8k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_ntt_ntt_binomially_sampled_ring_element_ea:
 7143|   103k|    libcrux_ml_kem_polynomial_PolynomialRingElement_1d *re) {
 7144|   103k|  libcrux_ml_kem_ntt_ntt_at_layer_7_ea(re);
 7145|   103k|  size_t zeta_i = (size_t)1U;
 7146|   103k|  libcrux_ml_kem_ntt_ntt_at_layer_4_plus_ea(&zeta_i, re, (size_t)6U,
 7147|   103k|                                            (size_t)11207U);
 7148|   103k|  libcrux_ml_kem_ntt_ntt_at_layer_4_plus_ea(&zeta_i, re, (size_t)5U,
 7149|   103k|                                            (size_t)11207U + (size_t)3328U);
 7150|   103k|  libcrux_ml_kem_ntt_ntt_at_layer_4_plus_ea(
 7151|   103k|      &zeta_i, re, (size_t)4U, (size_t)11207U + (size_t)2U * (size_t)3328U);
 7152|   103k|  libcrux_ml_kem_ntt_ntt_at_layer_3_ea(
 7153|   103k|      &zeta_i, re, (size_t)11207U + (size_t)3U * (size_t)3328U);
 7154|   103k|  libcrux_ml_kem_ntt_ntt_at_layer_2_ea(
 7155|   103k|      &zeta_i, re, (size_t)11207U + (size_t)4U * (size_t)3328U);
 7156|   103k|  libcrux_ml_kem_ntt_ntt_at_layer_1_ea(
 7157|   103k|      &zeta_i, re, (size_t)11207U + (size_t)5U * (size_t)3328U);
 7158|   103k|  libcrux_ml_kem_polynomial_poly_barrett_reduce_d6_ea(re);
 7159|   103k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_ntt_ntt_at_layer_7_ea:
 7120|   103k|    libcrux_ml_kem_polynomial_PolynomialRingElement_1d *re) {
 7121|   103k|  size_t step = LIBCRUX_ML_KEM_POLYNOMIAL_VECTORS_IN_RING_ELEMENT / (size_t)2U;
  ------------------
  |  | 3770|   103k|#define LIBCRUX_ML_KEM_POLYNOMIAL_VECTORS_IN_RING_ELEMENT ((size_t)16U)
  ------------------
 7122|   933k|  for (size_t i = (size_t)0U; i < step; i++) {
  ------------------
  |  Branch (7122:31): [True: 829k, False: 103k]
  ------------------
 7123|   829k|    size_t j = i;
 7124|   829k|    libcrux_ml_kem_vector_portable_vector_type_PortableVector t =
 7125|   829k|        libcrux_ml_kem_vector_portable_multiply_by_constant_b8(
 7126|   829k|            re->coefficients[j + step], (int16_t)-1600);
 7127|   829k|    re->coefficients[j + step] =
 7128|   829k|        libcrux_ml_kem_vector_portable_sub_b8(re->coefficients[j], &t);
 7129|   829k|    libcrux_ml_kem_vector_portable_vector_type_PortableVector uu____1 =
 7130|   829k|        libcrux_ml_kem_vector_portable_add_b8(re->coefficients[j], &t);
 7131|   829k|    re->coefficients[j] = uu____1;
 7132|   829k|  }
 7133|   103k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_vector_portable_multiply_by_constant_b8:
 3906|   829k|    libcrux_ml_kem_vector_portable_vector_type_PortableVector vec, int16_t c) {
 3907|   829k|  return libcrux_ml_kem_vector_portable_arithmetic_multiply_by_constant(vec, c);
 3908|   829k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_vector_portable_arithmetic_multiply_by_constant:
 3890|   829k|    libcrux_ml_kem_vector_portable_vector_type_PortableVector vec, int16_t c) {
 3891|   829k|  for (size_t i = (size_t)0U;
 3892|  14.1M|       i < LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_ELEMENTS_IN_VECTOR; i++) {
  ------------------
  |  | 3772|  14.1M|#define LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_ELEMENTS_IN_VECTOR ((size_t)16U)
  ------------------
  |  Branch (3892:8): [True: 13.2M, False: 829k]
  ------------------
 3893|  13.2M|    size_t i0 = i;
 3894|  13.2M|    size_t uu____0 = i0;
 3895|  13.2M|    vec.elements[uu____0] = vec.elements[uu____0] * c;
 3896|  13.2M|  }
 3897|   829k|  return vec;
 3898|   829k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_ind_cpa_encrypt_c1_call_mut_dd_85:
 7220|  51.8k|libcrux_ml_kem_ind_cpa_encrypt_c1_call_mut_dd_85(void **_, size_t tupled_args) {
 7221|  51.8k|  return libcrux_ml_kem_polynomial_ZERO_d6_ea();
 7222|  51.8k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_ind_cpa_sample_ring_element_cbd_3b:
 7239|  17.2k|    libcrux_ml_kem_polynomial_PolynomialRingElement_1d *error_1) {
 7240|  17.2k|  uint8_t prf_inputs[3U][33U];
 7241|  69.1k|  for (size_t i = (size_t)0U; i < (size_t)3U; i++) {
  ------------------
  |  Branch (7241:31): [True: 51.8k, False: 17.2k]
  ------------------
 7242|  51.8k|    core_array__core__clone__Clone_for__Array_T__N___clone(
  ------------------
  |  |  236|  51.8k|  (memcpy(dst, src, len * sizeof(elem_type)))
  ------------------
 7243|  51.8k|        (size_t)33U, prf_input, prf_inputs[i], uint8_t, void *);
 7244|  51.8k|  }
 7245|  17.2k|  domain_separator =
 7246|  17.2k|      libcrux_ml_kem_utils_prf_input_inc_e0(prf_inputs, domain_separator);
 7247|  17.2k|  uint8_t prf_outputs[3U][128U];
 7248|  17.2k|  libcrux_ml_kem_hash_functions_portable_PRFxN_4a_41(prf_inputs, prf_outputs);
 7249|  69.1k|  for (size_t i = (size_t)0U; i < (size_t)3U; i++) {
  ------------------
  |  Branch (7249:31): [True: 51.8k, False: 17.2k]
  ------------------
 7250|  51.8k|    size_t i0 = i;
 7251|  51.8k|    libcrux_ml_kem_polynomial_PolynomialRingElement_1d uu____0 =
 7252|  51.8k|        libcrux_ml_kem_sampling_sample_from_binomial_distribution_a0(
 7253|  51.8k|            Eurydice_array_to_slice((size_t)128U, prf_outputs[i0], uint8_t));
  ------------------
  |  |  204|  51.8k|  EURYDICE_SLICE(x, 0,                     \
  |  |  ------------------
  |  |  |  |  169|  51.8k|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|  51.8k|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  205|  51.8k|                 end) /* x is already at an array type, no need for cast */
  ------------------
 7254|  51.8k|    error_1[i0] = uu____0;
 7255|  51.8k|  }
 7256|  17.2k|  return domain_separator;
 7257|  17.2k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_hash_functions_portable_PRF_4a_410:
 7283|  17.2k|    Eurydice_slice input, uint8_t ret[128U]) {
 7284|  17.2k|  libcrux_ml_kem_hash_functions_portable_PRF_a6(input, ret);
 7285|  17.2k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_hash_functions_portable_PRF_a6:
 7265|  17.2k|    Eurydice_slice input, uint8_t ret[128U]) {
 7266|  17.2k|  uint8_t digest[128U] = {0U};
 7267|  17.2k|  libcrux_sha3_portable_shake256(
 7268|  17.2k|      Eurydice_array_to_slice((size_t)128U, digest, uint8_t), input);
  ------------------
  |  |  204|  17.2k|  EURYDICE_SLICE(x, 0,                     \
  |  |  ------------------
  |  |  |  |  169|  17.2k|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|  17.2k|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  205|  17.2k|                 end) /* x is already at an array type, no need for cast */
  ------------------
 7269|  17.2k|  memcpy(ret, digest, (size_t)128U * sizeof(uint8_t));
 7270|  17.2k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_sampling_sample_from_binomial_distribution_a0:
 7108|   172k|    Eurydice_slice randomness) {
 7109|   172k|  return libcrux_ml_kem_sampling_sample_from_binomial_distribution_2_ea(
 7110|   172k|      randomness);
 7111|   172k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_sampling_sample_from_binomial_distribution_2_ea:
 7062|   172k|    Eurydice_slice randomness) {
 7063|   172k|  int16_t sampled_i16s[256U] = {0U};
 7064|   172k|  for (size_t i0 = (size_t)0U;
 7065|  5.70M|       i0 < Eurydice_slice_len(randomness, uint8_t) / (size_t)4U; i0++) {
  ------------------
  |  |  173|  5.70M|#define Eurydice_slice_len(s, _) (s).len
  ------------------
  |  Branch (7065:8): [True: 5.52M, False: 172k]
  ------------------
 7066|  5.52M|    size_t chunk_number = i0;
 7067|  5.52M|    Eurydice_slice byte_chunk = Eurydice_slice_subslice3(
  ------------------
  |  |  195|  5.52M|  EURYDICE_SLICE((t_ptr)s.ptr, (start), (end))
  |  |  ------------------
  |  |  |  |  169|  5.52M|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|  5.52M|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 7068|  5.52M|        randomness, chunk_number * (size_t)4U,
 7069|  5.52M|        chunk_number * (size_t)4U + (size_t)4U, uint8_t *);
 7070|  5.52M|    uint32_t random_bits_as_u32 =
 7071|  5.52M|        (((uint32_t)Eurydice_slice_index(byte_chunk, (size_t)0U, uint8_t,
  ------------------
  |  |  180|  5.52M|#define Eurydice_slice_index(s, i, t, t_ptr_t) (((t_ptr_t)s.ptr)[i])
  ------------------
 7072|  5.52M|                                         uint8_t *) |
 7073|  5.52M|          (uint32_t)Eurydice_slice_index(byte_chunk, (size_t)1U, uint8_t,
  ------------------
  |  |  180|  5.52M|#define Eurydice_slice_index(s, i, t, t_ptr_t) (((t_ptr_t)s.ptr)[i])
  ------------------
 7074|  5.52M|                                         uint8_t *)
 7075|  5.52M|              << 8U) |
 7076|  5.52M|         (uint32_t)Eurydice_slice_index(byte_chunk, (size_t)2U, uint8_t,
  ------------------
  |  |  180|  5.52M|#define Eurydice_slice_index(s, i, t, t_ptr_t) (((t_ptr_t)s.ptr)[i])
  ------------------
 7077|  5.52M|                                        uint8_t *)
 7078|  5.52M|             << 16U) |
 7079|  5.52M|        (uint32_t)Eurydice_slice_index(byte_chunk, (size_t)3U, uint8_t,
  ------------------
  |  |  180|  5.52M|#define Eurydice_slice_index(s, i, t, t_ptr_t) (((t_ptr_t)s.ptr)[i])
  ------------------
 7080|  5.52M|                                       uint8_t *)
 7081|  5.52M|            << 24U;
 7082|  5.52M|    uint32_t even_bits = random_bits_as_u32 & 1431655765U;
 7083|  5.52M|    uint32_t odd_bits = random_bits_as_u32 >> 1U & 1431655765U;
 7084|  5.52M|    uint32_t coin_toss_outcomes = even_bits + odd_bits;
 7085|  49.7M|    for (uint32_t i = 0U; i < 32U / 4U; i++) {
  ------------------
  |  Branch (7085:27): [True: 44.2M, False: 5.52M]
  ------------------
 7086|  44.2M|      uint32_t outcome_set = i;
 7087|  44.2M|      uint32_t outcome_set0 = outcome_set * 4U;
 7088|  44.2M|      int16_t outcome_1 =
 7089|  44.2M|          (int16_t)(coin_toss_outcomes >> (uint32_t)outcome_set0 & 3U);
 7090|  44.2M|      int16_t outcome_2 =
 7091|  44.2M|          (int16_t)(coin_toss_outcomes >> (uint32_t)(outcome_set0 + 2U) & 3U);
 7092|  44.2M|      size_t offset = (size_t)(outcome_set0 >> 2U);
 7093|  44.2M|      sampled_i16s[(size_t)8U * chunk_number + offset] = outcome_1 - outcome_2;
 7094|  44.2M|    }
 7095|  5.52M|  }
 7096|   172k|  return libcrux_ml_kem_polynomial_from_i16_array_d6_ea(
 7097|   172k|      Eurydice_array_to_slice((size_t)256U, sampled_i16s, int16_t));
  ------------------
  |  |  204|   172k|  EURYDICE_SLICE(x, 0,                     \
  |  |  ------------------
  |  |  |  |  169|   172k|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|   172k|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  205|   172k|                 end) /* x is already at an array type, no need for cast */
  ------------------
 7098|   172k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_matrix_compute_vector_u_1b:
 7360|  17.2k|    libcrux_ml_kem_polynomial_PolynomialRingElement_1d ret[3U]) {
 7361|  17.2k|  libcrux_ml_kem_polynomial_PolynomialRingElement_1d result[3U];
 7362|  69.1k|  for (size_t i = (size_t)0U; i < (size_t)3U; i++) {
  ------------------
  |  Branch (7362:31): [True: 51.8k, False: 17.2k]
  ------------------
 7363|       |    /* original Rust expression is not an lvalue in C */
 7364|  51.8k|    void *lvalue = (void *)0U;
 7365|  51.8k|    result[i] =
 7366|  51.8k|        libcrux_ml_kem_matrix_compute_vector_u_call_mut_a8_1b(&lvalue, i);
 7367|  51.8k|  }
 7368|  17.2k|  for (size_t i0 = (size_t)0U;
 7369|  69.1k|       i0 < Eurydice_slice_len(
  ------------------
  |  |  173|  69.1k|#define Eurydice_slice_len(s, _) (s).len
  ------------------
  |  Branch (7369:8): [True: 51.8k, False: 17.2k]
  ------------------
 7370|  17.2k|                Eurydice_array_to_slice(
 7371|  17.2k|                    (size_t)3U, a_as_ntt,
 7372|  17.2k|                    libcrux_ml_kem_polynomial_PolynomialRingElement_1d[3U]),
 7373|  17.2k|                libcrux_ml_kem_polynomial_PolynomialRingElement_1d[3U]);
 7374|  51.8k|       i0++) {
 7375|  51.8k|    size_t i1 = i0;
 7376|  51.8k|    libcrux_ml_kem_polynomial_PolynomialRingElement_1d *row = a_as_ntt[i1];
 7377|  51.8k|    for (size_t i = (size_t)0U;
 7378|   207k|         i < Eurydice_slice_len(
  ------------------
  |  |  173|   207k|#define Eurydice_slice_len(s, _) (s).len
  ------------------
  |  Branch (7378:10): [True: 155k, False: 51.8k]
  ------------------
 7379|  51.8k|                 Eurydice_array_to_slice(
 7380|  51.8k|                     (size_t)3U, row,
 7381|  51.8k|                     libcrux_ml_kem_polynomial_PolynomialRingElement_1d),
 7382|  51.8k|                 libcrux_ml_kem_polynomial_PolynomialRingElement_1d);
 7383|   155k|         i++) {
 7384|   155k|      size_t j = i;
 7385|   155k|      libcrux_ml_kem_polynomial_PolynomialRingElement_1d *a_element = &row[j];
 7386|   155k|      libcrux_ml_kem_polynomial_PolynomialRingElement_1d product =
 7387|   155k|          libcrux_ml_kem_polynomial_ntt_multiply_d6_ea(a_element, &r_as_ntt[j]);
 7388|   155k|      libcrux_ml_kem_polynomial_add_to_ring_element_d6_1b(&result[i1],
 7389|   155k|                                                          &product);
 7390|   155k|    }
 7391|  51.8k|    libcrux_ml_kem_invert_ntt_invert_ntt_montgomery_1b(&result[i1]);
 7392|  51.8k|    libcrux_ml_kem_polynomial_add_error_reduce_d6_ea(&result[i1], &error_1[i1]);
 7393|  51.8k|  }
 7394|  17.2k|  memcpy(
 7395|  17.2k|      ret, result,
 7396|  17.2k|      (size_t)3U * sizeof(libcrux_ml_kem_polynomial_PolynomialRingElement_1d));
 7397|  17.2k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_matrix_compute_vector_u_call_mut_a8_1b:
 7301|  51.8k|                                                      size_t tupled_args) {
 7302|  51.8k|  return libcrux_ml_kem_polynomial_ZERO_d6_ea();
 7303|  51.8k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_polynomial_add_error_reduce_d6_ea:
 7343|  51.8k|    libcrux_ml_kem_polynomial_PolynomialRingElement_1d *error) {
 7344|  51.8k|  libcrux_ml_kem_polynomial_add_error_reduce_ea(self, error);
 7345|  51.8k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_polynomial_add_error_reduce_ea:
 7313|  51.8k|    libcrux_ml_kem_polynomial_PolynomialRingElement_1d *error) {
 7314|  51.8k|  for (size_t i = (size_t)0U;
 7315|   881k|       i < LIBCRUX_ML_KEM_POLYNOMIAL_VECTORS_IN_RING_ELEMENT; i++) {
  ------------------
  |  | 3770|   881k|#define LIBCRUX_ML_KEM_POLYNOMIAL_VECTORS_IN_RING_ELEMENT ((size_t)16U)
  ------------------
  |  Branch (7315:8): [True: 829k, False: 51.8k]
  ------------------
 7316|   829k|    size_t j = i;
 7317|   829k|    libcrux_ml_kem_vector_portable_vector_type_PortableVector
 7318|   829k|        coefficient_normal_form =
 7319|   829k|            libcrux_ml_kem_vector_portable_montgomery_multiply_by_constant_b8(
 7320|   829k|                myself->coefficients[j], (int16_t)1441);
 7321|   829k|    libcrux_ml_kem_vector_portable_vector_type_PortableVector sum =
 7322|   829k|        libcrux_ml_kem_vector_portable_add_b8(coefficient_normal_form,
 7323|   829k|                                              &error->coefficients[j]);
 7324|   829k|    libcrux_ml_kem_vector_portable_vector_type_PortableVector red =
 7325|   829k|        libcrux_ml_kem_vector_portable_barrett_reduce_b8(sum);
 7326|   829k|    myself->coefficients[j] = red;
 7327|   829k|  }
 7328|  51.8k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_ind_cpa_compress_then_serialize_u_43:
 7490|  17.2k|    Eurydice_slice out) {
 7491|  17.2k|  for (size_t i = (size_t)0U;
 7492|  69.1k|       i < Eurydice_slice_len(
  ------------------
  |  |  173|  69.1k|#define Eurydice_slice_len(s, _) (s).len
  ------------------
  |  Branch (7492:8): [True: 51.8k, False: 17.2k]
  ------------------
 7493|  17.2k|               Eurydice_array_to_slice(
 7494|  17.2k|                   (size_t)3U, input,
 7495|  17.2k|                   libcrux_ml_kem_polynomial_PolynomialRingElement_1d),
 7496|  17.2k|               libcrux_ml_kem_polynomial_PolynomialRingElement_1d);
 7497|  51.8k|       i++) {
 7498|  51.8k|    size_t i0 = i;
 7499|  51.8k|    libcrux_ml_kem_polynomial_PolynomialRingElement_1d re = input[i0];
 7500|  51.8k|    Eurydice_slice uu____0 = Eurydice_slice_subslice3(
  ------------------
  |  |  195|  51.8k|  EURYDICE_SLICE((t_ptr)s.ptr, (start), (end))
  |  |  ------------------
  |  |  |  |  169|  51.8k|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|  51.8k|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 7501|  51.8k|        out, i0 * ((size_t)960U / (size_t)3U),
 7502|  51.8k|        (i0 + (size_t)1U) * ((size_t)960U / (size_t)3U), uint8_t *);
 7503|  51.8k|    uint8_t ret[320U];
 7504|  51.8k|    libcrux_ml_kem_serialize_compress_then_serialize_ring_element_u_fe(&re,
 7505|  51.8k|                                                                       ret);
 7506|  51.8k|    Eurydice_slice_copy(
  ------------------
  |  |  229|  51.8k|  memcpy(dst.ptr, src.ptr, dst.len * sizeof(t))
  ------------------
 7507|  51.8k|        uu____0, Eurydice_array_to_slice((size_t)320U, ret, uint8_t), uint8_t);
 7508|  51.8k|  }
 7509|  17.2k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_serialize_compress_then_serialize_ring_element_u_fe:
 7470|  51.8k|    libcrux_ml_kem_polynomial_PolynomialRingElement_1d *re, uint8_t ret[320U]) {
 7471|  51.8k|  uint8_t uu____0[320U];
 7472|  51.8k|  libcrux_ml_kem_serialize_compress_then_serialize_10_ff(re, uu____0);
 7473|  51.8k|  memcpy(ret, uu____0, (size_t)320U * sizeof(uint8_t));
 7474|  51.8k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_serialize_compress_then_serialize_10_ff:
 7442|  51.8k|    libcrux_ml_kem_polynomial_PolynomialRingElement_1d *re, uint8_t ret[320U]) {
 7443|  51.8k|  uint8_t serialized[320U] = {0U};
 7444|  51.8k|  for (size_t i = (size_t)0U;
 7445|   881k|       i < LIBCRUX_ML_KEM_POLYNOMIAL_VECTORS_IN_RING_ELEMENT; i++) {
  ------------------
  |  | 3770|   881k|#define LIBCRUX_ML_KEM_POLYNOMIAL_VECTORS_IN_RING_ELEMENT ((size_t)16U)
  ------------------
  |  Branch (7445:8): [True: 829k, False: 51.8k]
  ------------------
 7446|   829k|    size_t i0 = i;
 7447|   829k|    libcrux_ml_kem_vector_portable_vector_type_PortableVector coefficient =
 7448|   829k|        libcrux_ml_kem_vector_portable_compress_b8_ef(
 7449|   829k|            libcrux_ml_kem_serialize_to_unsigned_field_modulus_ea(
 7450|   829k|                re->coefficients[i0]));
 7451|   829k|    uint8_t bytes[20U];
 7452|   829k|    libcrux_ml_kem_vector_portable_serialize_10_b8(coefficient, bytes);
 7453|   829k|    Eurydice_slice_copy(
  ------------------
  |  |  229|   829k|  memcpy(dst.ptr, src.ptr, dst.len * sizeof(t))
  ------------------
 7454|   829k|        Eurydice_array_to_subslice3(serialized, (size_t)20U * i0,
 7455|   829k|                                    (size_t)20U * i0 + (size_t)20U, uint8_t *),
 7456|   829k|        Eurydice_array_to_slice((size_t)20U, bytes, uint8_t), uint8_t);
 7457|   829k|  }
 7458|  51.8k|  memcpy(ret, serialized, (size_t)320U * sizeof(uint8_t));
 7459|  51.8k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_vector_portable_compress_b8_ef:
 7430|   829k|    libcrux_ml_kem_vector_portable_vector_type_PortableVector a) {
 7431|   829k|  return libcrux_ml_kem_vector_portable_compress_compress_ef(a);
 7432|   829k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_vector_portable_compress_compress_ef:
 7406|   829k|    libcrux_ml_kem_vector_portable_vector_type_PortableVector a) {
 7407|   829k|  for (size_t i = (size_t)0U;
 7408|  14.1M|       i < LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_ELEMENTS_IN_VECTOR; i++) {
  ------------------
  |  | 3772|  14.1M|#define LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_ELEMENTS_IN_VECTOR ((size_t)16U)
  ------------------
  |  Branch (7408:8): [True: 13.2M, False: 829k]
  ------------------
 7409|  13.2M|    size_t i0 = i;
 7410|  13.2M|    int16_t uu____0 = libcrux_secrets_int_as_i16_f5(
 7411|  13.2M|        libcrux_ml_kem_vector_portable_compress_compress_ciphertext_coefficient(
 7412|  13.2M|            (uint8_t)(int32_t)10,
 7413|  13.2M|            libcrux_secrets_int_as_u16_f5(a.elements[i0])));
 7414|  13.2M|    a.elements[i0] = uu____0;
 7415|  13.2M|  }
 7416|   829k|  return a;
 7417|   829k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_vector_portable_compress_compress_ciphertext_coefficient:
 4199|  17.6M|    uint8_t coefficient_bits, uint16_t fe) {
 4200|  17.6M|  uint64_t compressed = libcrux_secrets_int_as_u64_ca(fe)
 4201|  17.6M|                        << (uint32_t)coefficient_bits;
 4202|  17.6M|  compressed = compressed + 1664ULL;
 4203|  17.6M|  compressed = compressed * 10321340ULL;
 4204|  17.6M|  compressed = compressed >> 35U;
 4205|  17.6M|  return libcrux_secrets_int_as_i16_b8(
 4206|  17.6M|      libcrux_ml_kem_vector_portable_arithmetic_get_n_least_significant_bits(
 4207|  17.6M|          coefficient_bits, libcrux_secrets_int_as_u32_a3(compressed)));
 4208|  17.6M|}
libcrux_mlkem768_sha3.c:libcrux_secrets_int_as_u64_ca:
  661|  17.6M|static KRML_MUSTINLINE uint64_t libcrux_secrets_int_as_u64_ca(uint16_t self) {
  662|  17.6M|  return libcrux_secrets_int_public_integers_classify_27_49(
  663|  17.6M|      (uint64_t)libcrux_secrets_int_public_integers_declassify_d8_de(self));
  664|  17.6M|}
libcrux_mlkem768_sha3.c:libcrux_secrets_int_public_integers_classify_27_49:
  654|  17.6M|libcrux_secrets_int_public_integers_classify_27_49(uint64_t self) {
  655|  17.6M|  return self;
  656|  17.6M|}
libcrux_mlkem768_sha3.c:libcrux_secrets_int_as_i16_b8:
  703|  17.6M|static KRML_MUSTINLINE int16_t libcrux_secrets_int_as_i16_b8(uint32_t self) {
  704|  17.6M|  return libcrux_secrets_int_public_integers_classify_27_39(
  705|  17.6M|      (int16_t)libcrux_secrets_int_public_integers_declassify_d8_df(self));
  706|  17.6M|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_vector_portable_arithmetic_get_n_least_significant_bits:
 4193|  17.6M|    uint8_t n, uint32_t value) {
 4194|  17.6M|  return value & ((1U << (uint32_t)n) - 1U);
 4195|  17.6M|}
libcrux_mlkem768_sha3.c:libcrux_secrets_int_as_u32_a3:
  695|  17.6M|static KRML_MUSTINLINE uint32_t libcrux_secrets_int_as_u32_a3(uint64_t self) {
  696|  17.6M|  return libcrux_secrets_int_public_integers_classify_27_df(
  697|  17.6M|      (uint32_t)libcrux_secrets_int_public_integers_declassify_d8_49(self));
  698|  17.6M|}
libcrux_mlkem768_sha3.c:libcrux_secrets_int_public_integers_declassify_d8_49:
  688|  17.6M|libcrux_secrets_int_public_integers_declassify_d8_49(uint64_t self) {
  689|  17.6M|  return self;
  690|  17.6M|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_vector_portable_serialize_10_b8:
 4920|   829k|    uint8_t ret[20U]) {
 4921|   829k|  libcrux_ml_kem_vector_portable_serialize_10(a, ret);
 4922|   829k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_vector_portable_serialize_10:
 4908|   829k|    uint8_t ret[20U]) {
 4909|   829k|  uint8_t ret0[20U];
 4910|   829k|  libcrux_ml_kem_vector_portable_serialize_serialize_10(a, ret0);
 4911|   829k|  libcrux_secrets_int_public_integers_declassify_d8_57(ret0, ret);
 4912|   829k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_vector_portable_serialize_serialize_10:
 4871|   829k|    uint8_t ret[20U]) {
 4872|   829k|  uint8_t_x5 r0_4 = libcrux_ml_kem_vector_portable_serialize_serialize_10_int(
 4873|   829k|      Eurydice_array_to_subslice3(v.elements, (size_t)0U, (size_t)4U,
  ------------------
  |  |  215|   829k|  EURYDICE_SLICE((t_ptr)x, (start), (end))
  |  |  ------------------
  |  |  |  |  169|   829k|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|   829k|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4874|   829k|                                  int16_t *));
 4875|   829k|  uint8_t_x5 r5_9 = libcrux_ml_kem_vector_portable_serialize_serialize_10_int(
 4876|   829k|      Eurydice_array_to_subslice3(v.elements, (size_t)4U, (size_t)8U,
  ------------------
  |  |  215|   829k|  EURYDICE_SLICE((t_ptr)x, (start), (end))
  |  |  ------------------
  |  |  |  |  169|   829k|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|   829k|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4877|   829k|                                  int16_t *));
 4878|   829k|  uint8_t_x5 r10_14 = libcrux_ml_kem_vector_portable_serialize_serialize_10_int(
 4879|   829k|      Eurydice_array_to_subslice3(v.elements, (size_t)8U, (size_t)12U,
  ------------------
  |  |  215|   829k|  EURYDICE_SLICE((t_ptr)x, (start), (end))
  |  |  ------------------
  |  |  |  |  169|   829k|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|   829k|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4880|   829k|                                  int16_t *));
 4881|   829k|  uint8_t_x5 r15_19 = libcrux_ml_kem_vector_portable_serialize_serialize_10_int(
 4882|   829k|      Eurydice_array_to_subslice3(v.elements, (size_t)12U, (size_t)16U,
  ------------------
  |  |  215|   829k|  EURYDICE_SLICE((t_ptr)x, (start), (end))
  |  |  ------------------
  |  |  |  |  169|   829k|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|   829k|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4883|   829k|                                  int16_t *));
 4884|   829k|  ret[0U] = r0_4.fst;
 4885|   829k|  ret[1U] = r0_4.snd;
 4886|   829k|  ret[2U] = r0_4.thd;
 4887|   829k|  ret[3U] = r0_4.f3;
 4888|   829k|  ret[4U] = r0_4.f4;
 4889|   829k|  ret[5U] = r5_9.fst;
 4890|   829k|  ret[6U] = r5_9.snd;
 4891|   829k|  ret[7U] = r5_9.thd;
 4892|   829k|  ret[8U] = r5_9.f3;
 4893|   829k|  ret[9U] = r5_9.f4;
 4894|   829k|  ret[10U] = r10_14.fst;
 4895|   829k|  ret[11U] = r10_14.snd;
 4896|   829k|  ret[12U] = r10_14.thd;
 4897|   829k|  ret[13U] = r10_14.f3;
 4898|   829k|  ret[14U] = r10_14.f4;
 4899|   829k|  ret[15U] = r15_19.fst;
 4900|   829k|  ret[16U] = r15_19.snd;
 4901|   829k|  ret[17U] = r15_19.thd;
 4902|   829k|  ret[18U] = r15_19.f3;
 4903|   829k|  ret[19U] = r15_19.f4;
 4904|   829k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_vector_portable_serialize_serialize_10_int:
 4837|  3.31M|libcrux_ml_kem_vector_portable_serialize_serialize_10_int(Eurydice_slice v) {
 4838|  3.31M|  uint8_t r0 = libcrux_secrets_int_as_u8_f5(
 4839|  3.31M|      Eurydice_slice_index(v, (size_t)0U, int16_t, int16_t *) & (int16_t)255);
  ------------------
  |  |  180|  3.31M|#define Eurydice_slice_index(s, i, t, t_ptr_t) (((t_ptr_t)s.ptr)[i])
  ------------------
 4840|  3.31M|  uint8_t r1 =
 4841|  3.31M|      (uint32_t)libcrux_secrets_int_as_u8_f5(
 4842|  3.31M|          Eurydice_slice_index(v, (size_t)1U, int16_t, int16_t *) & (int16_t)63)
  ------------------
  |  |  180|  3.31M|#define Eurydice_slice_index(s, i, t, t_ptr_t) (((t_ptr_t)s.ptr)[i])
  ------------------
 4843|  3.31M|          << 2U |
 4844|  3.31M|      (uint32_t)libcrux_secrets_int_as_u8_f5(
 4845|  3.31M|          Eurydice_slice_index(v, (size_t)0U, int16_t, int16_t *) >> 8U &
  ------------------
  |  |  180|  3.31M|#define Eurydice_slice_index(s, i, t, t_ptr_t) (((t_ptr_t)s.ptr)[i])
  ------------------
 4846|  3.31M|          (int16_t)3);
 4847|  3.31M|  uint8_t r2 =
 4848|  3.31M|      (uint32_t)libcrux_secrets_int_as_u8_f5(
 4849|  3.31M|          Eurydice_slice_index(v, (size_t)2U, int16_t, int16_t *) & (int16_t)15)
  ------------------
  |  |  180|  3.31M|#define Eurydice_slice_index(s, i, t, t_ptr_t) (((t_ptr_t)s.ptr)[i])
  ------------------
 4850|  3.31M|          << 4U |
 4851|  3.31M|      (uint32_t)libcrux_secrets_int_as_u8_f5(
 4852|  3.31M|          Eurydice_slice_index(v, (size_t)1U, int16_t, int16_t *) >> 6U &
  ------------------
  |  |  180|  3.31M|#define Eurydice_slice_index(s, i, t, t_ptr_t) (((t_ptr_t)s.ptr)[i])
  ------------------
 4853|  3.31M|          (int16_t)15);
 4854|  3.31M|  uint8_t r3 =
 4855|  3.31M|      (uint32_t)libcrux_secrets_int_as_u8_f5(
 4856|  3.31M|          Eurydice_slice_index(v, (size_t)3U, int16_t, int16_t *) & (int16_t)3)
  ------------------
  |  |  180|  3.31M|#define Eurydice_slice_index(s, i, t, t_ptr_t) (((t_ptr_t)s.ptr)[i])
  ------------------
 4857|  3.31M|          << 6U |
 4858|  3.31M|      (uint32_t)libcrux_secrets_int_as_u8_f5(
 4859|  3.31M|          Eurydice_slice_index(v, (size_t)2U, int16_t, int16_t *) >> 4U &
  ------------------
  |  |  180|  3.31M|#define Eurydice_slice_index(s, i, t, t_ptr_t) (((t_ptr_t)s.ptr)[i])
  ------------------
 4860|  3.31M|          (int16_t)63);
 4861|  3.31M|  uint8_t r4 = libcrux_secrets_int_as_u8_f5(
 4862|  3.31M|      Eurydice_slice_index(v, (size_t)3U, int16_t, int16_t *) >> 2U &
  ------------------
  |  |  180|  3.31M|#define Eurydice_slice_index(s, i, t, t_ptr_t) (((t_ptr_t)s.ptr)[i])
  ------------------
 4863|  3.31M|      (int16_t)255);
 4864|  3.31M|  return (KRML_CLITERAL(uint8_t_x5){
  ------------------
  |  |  154|  3.31M|#define KRML_CLITERAL(type) (type)
  ------------------
 4865|  3.31M|      .fst = r0, .snd = r1, .thd = r2, .f3 = r3, .f4 = r4});
 4866|  3.31M|}
libcrux_mlkem768_sha3.c:libcrux_secrets_int_public_integers_declassify_d8_57:
 1034|   829k|                                                     uint8_t ret[20U]) {
 1035|   829k|  memcpy(ret, self, (size_t)20U * sizeof(uint8_t));
 1036|   829k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_ind_cpa_encrypt_c2_6c:
 7767|  17.2k|    uint8_t *message, Eurydice_slice ciphertext) {
 7768|  17.2k|  libcrux_ml_kem_polynomial_PolynomialRingElement_1d message_as_ring_element =
 7769|  17.2k|      libcrux_ml_kem_serialize_deserialize_then_decompress_message_ea(message);
 7770|  17.2k|  libcrux_ml_kem_polynomial_PolynomialRingElement_1d v =
 7771|  17.2k|      libcrux_ml_kem_matrix_compute_ring_element_v_1b(
 7772|  17.2k|          t_as_ntt, r_as_ntt, error_2, &message_as_ring_element);
 7773|  17.2k|  libcrux_ml_kem_serialize_compress_then_serialize_ring_element_v_6c(
 7774|  17.2k|      v, ciphertext);
 7775|  17.2k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_serialize_deserialize_then_decompress_message_ea:
 7583|  17.2k|    uint8_t *serialized) {
 7584|  17.2k|  libcrux_ml_kem_polynomial_PolynomialRingElement_1d re =
 7585|  17.2k|      libcrux_ml_kem_polynomial_ZERO_d6_ea();
 7586|   293k|  for (size_t i = (size_t)0U; i < (size_t)16U; i++) {
  ------------------
  |  Branch (7586:31): [True: 276k, False: 17.2k]
  ------------------
 7587|   276k|    size_t i0 = i;
 7588|   276k|    libcrux_ml_kem_vector_portable_vector_type_PortableVector
 7589|   276k|        coefficient_compressed =
 7590|   276k|            libcrux_ml_kem_vector_portable_deserialize_1_b8(
 7591|   276k|                Eurydice_array_to_subslice3(serialized, (size_t)2U * i0,
  ------------------
  |  |  215|   276k|  EURYDICE_SLICE((t_ptr)x, (start), (end))
  |  |  ------------------
  |  |  |  |  169|   276k|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|   276k|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 7592|   276k|                                            (size_t)2U * i0 + (size_t)2U,
 7593|   276k|                                            uint8_t *));
 7594|   276k|    libcrux_ml_kem_vector_portable_vector_type_PortableVector uu____0 =
 7595|   276k|        libcrux_ml_kem_vector_portable_decompress_1_b8(coefficient_compressed);
 7596|   276k|    re.coefficients[i0] = uu____0;
 7597|   276k|  }
 7598|  17.2k|  return re;
 7599|  17.2k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_vector_portable_deserialize_1_b8:
 4682|   276k|libcrux_ml_kem_vector_portable_deserialize_1_b8(Eurydice_slice a) {
 4683|   276k|  return libcrux_ml_kem_vector_portable_deserialize_1(a);
 4684|   276k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_vector_portable_deserialize_1:
 4672|   276k|libcrux_ml_kem_vector_portable_deserialize_1(Eurydice_slice a) {
 4673|   276k|  return libcrux_ml_kem_vector_portable_serialize_deserialize_1(
 4674|   276k|      libcrux_secrets_int_classify_public_classify_ref_9b_90(a));
 4675|   276k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_vector_portable_serialize_deserialize_1:
 4617|   276k|libcrux_ml_kem_vector_portable_serialize_deserialize_1(Eurydice_slice v) {
 4618|   276k|  int16_t result0 = libcrux_secrets_int_as_i16_59(
 4619|   276k|      (uint32_t)Eurydice_slice_index(v, (size_t)0U, uint8_t, uint8_t *) & 1U);
  ------------------
  |  |  180|   276k|#define Eurydice_slice_index(s, i, t, t_ptr_t) (((t_ptr_t)s.ptr)[i])
  ------------------
 4620|   276k|  int16_t result1 = libcrux_secrets_int_as_i16_59(
 4621|   276k|      (uint32_t)Eurydice_slice_index(v, (size_t)0U, uint8_t, uint8_t *) >> 1U &
  ------------------
  |  |  180|   276k|#define Eurydice_slice_index(s, i, t, t_ptr_t) (((t_ptr_t)s.ptr)[i])
  ------------------
 4622|   276k|      1U);
 4623|   276k|  int16_t result2 = libcrux_secrets_int_as_i16_59(
 4624|   276k|      (uint32_t)Eurydice_slice_index(v, (size_t)0U, uint8_t, uint8_t *) >> 2U &
  ------------------
  |  |  180|   276k|#define Eurydice_slice_index(s, i, t, t_ptr_t) (((t_ptr_t)s.ptr)[i])
  ------------------
 4625|   276k|      1U);
 4626|   276k|  int16_t result3 = libcrux_secrets_int_as_i16_59(
 4627|   276k|      (uint32_t)Eurydice_slice_index(v, (size_t)0U, uint8_t, uint8_t *) >> 3U &
  ------------------
  |  |  180|   276k|#define Eurydice_slice_index(s, i, t, t_ptr_t) (((t_ptr_t)s.ptr)[i])
  ------------------
 4628|   276k|      1U);
 4629|   276k|  int16_t result4 = libcrux_secrets_int_as_i16_59(
 4630|   276k|      (uint32_t)Eurydice_slice_index(v, (size_t)0U, uint8_t, uint8_t *) >> 4U &
  ------------------
  |  |  180|   276k|#define Eurydice_slice_index(s, i, t, t_ptr_t) (((t_ptr_t)s.ptr)[i])
  ------------------
 4631|   276k|      1U);
 4632|   276k|  int16_t result5 = libcrux_secrets_int_as_i16_59(
 4633|   276k|      (uint32_t)Eurydice_slice_index(v, (size_t)0U, uint8_t, uint8_t *) >> 5U &
  ------------------
  |  |  180|   276k|#define Eurydice_slice_index(s, i, t, t_ptr_t) (((t_ptr_t)s.ptr)[i])
  ------------------
 4634|   276k|      1U);
 4635|   276k|  int16_t result6 = libcrux_secrets_int_as_i16_59(
 4636|   276k|      (uint32_t)Eurydice_slice_index(v, (size_t)0U, uint8_t, uint8_t *) >> 6U &
  ------------------
  |  |  180|   276k|#define Eurydice_slice_index(s, i, t, t_ptr_t) (((t_ptr_t)s.ptr)[i])
  ------------------
 4637|   276k|      1U);
 4638|   276k|  int16_t result7 = libcrux_secrets_int_as_i16_59(
 4639|   276k|      (uint32_t)Eurydice_slice_index(v, (size_t)0U, uint8_t, uint8_t *) >> 7U &
  ------------------
  |  |  180|   276k|#define Eurydice_slice_index(s, i, t, t_ptr_t) (((t_ptr_t)s.ptr)[i])
  ------------------
 4640|   276k|      1U);
 4641|   276k|  int16_t result8 = libcrux_secrets_int_as_i16_59(
 4642|   276k|      (uint32_t)Eurydice_slice_index(v, (size_t)1U, uint8_t, uint8_t *) & 1U);
  ------------------
  |  |  180|   276k|#define Eurydice_slice_index(s, i, t, t_ptr_t) (((t_ptr_t)s.ptr)[i])
  ------------------
 4643|   276k|  int16_t result9 = libcrux_secrets_int_as_i16_59(
 4644|   276k|      (uint32_t)Eurydice_slice_index(v, (size_t)1U, uint8_t, uint8_t *) >> 1U &
  ------------------
  |  |  180|   276k|#define Eurydice_slice_index(s, i, t, t_ptr_t) (((t_ptr_t)s.ptr)[i])
  ------------------
 4645|   276k|      1U);
 4646|   276k|  int16_t result10 = libcrux_secrets_int_as_i16_59(
 4647|   276k|      (uint32_t)Eurydice_slice_index(v, (size_t)1U, uint8_t, uint8_t *) >> 2U &
  ------------------
  |  |  180|   276k|#define Eurydice_slice_index(s, i, t, t_ptr_t) (((t_ptr_t)s.ptr)[i])
  ------------------
 4648|   276k|      1U);
 4649|   276k|  int16_t result11 = libcrux_secrets_int_as_i16_59(
 4650|   276k|      (uint32_t)Eurydice_slice_index(v, (size_t)1U, uint8_t, uint8_t *) >> 3U &
  ------------------
  |  |  180|   276k|#define Eurydice_slice_index(s, i, t, t_ptr_t) (((t_ptr_t)s.ptr)[i])
  ------------------
 4651|   276k|      1U);
 4652|   276k|  int16_t result12 = libcrux_secrets_int_as_i16_59(
 4653|   276k|      (uint32_t)Eurydice_slice_index(v, (size_t)1U, uint8_t, uint8_t *) >> 4U &
  ------------------
  |  |  180|   276k|#define Eurydice_slice_index(s, i, t, t_ptr_t) (((t_ptr_t)s.ptr)[i])
  ------------------
 4654|   276k|      1U);
 4655|   276k|  int16_t result13 = libcrux_secrets_int_as_i16_59(
 4656|   276k|      (uint32_t)Eurydice_slice_index(v, (size_t)1U, uint8_t, uint8_t *) >> 5U &
  ------------------
  |  |  180|   276k|#define Eurydice_slice_index(s, i, t, t_ptr_t) (((t_ptr_t)s.ptr)[i])
  ------------------
 4657|   276k|      1U);
 4658|   276k|  int16_t result14 = libcrux_secrets_int_as_i16_59(
 4659|   276k|      (uint32_t)Eurydice_slice_index(v, (size_t)1U, uint8_t, uint8_t *) >> 6U &
  ------------------
  |  |  180|   276k|#define Eurydice_slice_index(s, i, t, t_ptr_t) (((t_ptr_t)s.ptr)[i])
  ------------------
 4660|   276k|      1U);
 4661|   276k|  int16_t result15 = libcrux_secrets_int_as_i16_59(
 4662|   276k|      (uint32_t)Eurydice_slice_index(v, (size_t)1U, uint8_t, uint8_t *) >> 7U &
  ------------------
  |  |  180|   276k|#define Eurydice_slice_index(s, i, t, t_ptr_t) (((t_ptr_t)s.ptr)[i])
  ------------------
 4663|   276k|      1U);
 4664|   276k|  return (
 4665|   276k|      KRML_CLITERAL(libcrux_ml_kem_vector_portable_vector_type_PortableVector){
  ------------------
  |  |  154|   276k|#define KRML_CLITERAL(type) (type)
  ------------------
 4666|   276k|          .elements = {result0, result1, result2, result3, result4, result5,
 4667|   276k|                       result6, result7, result8, result9, result10, result11,
 4668|   276k|                       result12, result13, result14, result15}});
 4669|   276k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_vector_portable_decompress_1_b8:
 4229|   276k|    libcrux_ml_kem_vector_portable_vector_type_PortableVector a) {
 4230|   276k|  return libcrux_ml_kem_vector_portable_compress_decompress_1(a);
 4231|   276k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_vector_portable_compress_decompress_1:
 4212|   276k|    libcrux_ml_kem_vector_portable_vector_type_PortableVector a) {
 4213|   276k|  libcrux_ml_kem_vector_portable_vector_type_PortableVector z =
 4214|   276k|      libcrux_ml_kem_vector_portable_vector_type_zero();
 4215|   276k|  libcrux_ml_kem_vector_portable_vector_type_PortableVector s =
 4216|   276k|      libcrux_ml_kem_vector_portable_arithmetic_sub(z, &a);
 4217|   276k|  libcrux_ml_kem_vector_portable_vector_type_PortableVector res =
 4218|   276k|      libcrux_ml_kem_vector_portable_arithmetic_bitwise_and_with_constant(
 4219|   276k|          s, (int16_t)1665);
 4220|   276k|  return res;
 4221|   276k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_matrix_compute_ring_element_v_1b:
 7665|  17.2k|    libcrux_ml_kem_polynomial_PolynomialRingElement_1d *message) {
 7666|  17.2k|  libcrux_ml_kem_polynomial_PolynomialRingElement_1d result =
 7667|  17.2k|      libcrux_ml_kem_polynomial_ZERO_d6_ea();
 7668|  69.1k|  for (size_t i = (size_t)0U; i < (size_t)3U; i++) {
  ------------------
  |  Branch (7668:31): [True: 51.8k, False: 17.2k]
  ------------------
 7669|  51.8k|    size_t i0 = i;
 7670|  51.8k|    libcrux_ml_kem_polynomial_PolynomialRingElement_1d product =
 7671|  51.8k|        libcrux_ml_kem_polynomial_ntt_multiply_d6_ea(&t_as_ntt[i0],
 7672|  51.8k|                                                     &r_as_ntt[i0]);
 7673|  51.8k|    libcrux_ml_kem_polynomial_add_to_ring_element_d6_1b(&result, &product);
 7674|  51.8k|  }
 7675|  17.2k|  libcrux_ml_kem_invert_ntt_invert_ntt_montgomery_1b(&result);
 7676|  17.2k|  return libcrux_ml_kem_polynomial_add_message_error_reduce_d6_ea(
 7677|  17.2k|      error_2, message, result);
 7678|  17.2k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_polynomial_add_message_error_reduce_d6_ea:
 7646|  17.2k|    libcrux_ml_kem_polynomial_PolynomialRingElement_1d result) {
 7647|  17.2k|  return libcrux_ml_kem_polynomial_add_message_error_reduce_ea(self, message,
 7648|  17.2k|                                                               result);
 7649|  17.2k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_polynomial_add_message_error_reduce_ea:
 7611|  17.2k|    libcrux_ml_kem_polynomial_PolynomialRingElement_1d result) {
 7612|  17.2k|  for (size_t i = (size_t)0U;
 7613|   293k|       i < LIBCRUX_ML_KEM_POLYNOMIAL_VECTORS_IN_RING_ELEMENT; i++) {
  ------------------
  |  | 3770|   293k|#define LIBCRUX_ML_KEM_POLYNOMIAL_VECTORS_IN_RING_ELEMENT ((size_t)16U)
  ------------------
  |  Branch (7613:8): [True: 276k, False: 17.2k]
  ------------------
 7614|   276k|    size_t i0 = i;
 7615|   276k|    libcrux_ml_kem_vector_portable_vector_type_PortableVector
 7616|   276k|        coefficient_normal_form =
 7617|   276k|            libcrux_ml_kem_vector_portable_montgomery_multiply_by_constant_b8(
 7618|   276k|                result.coefficients[i0], (int16_t)1441);
 7619|   276k|    libcrux_ml_kem_vector_portable_vector_type_PortableVector sum1 =
 7620|   276k|        libcrux_ml_kem_vector_portable_add_b8(myself->coefficients[i0],
 7621|   276k|                                              &message->coefficients[i0]);
 7622|   276k|    libcrux_ml_kem_vector_portable_vector_type_PortableVector sum2 =
 7623|   276k|        libcrux_ml_kem_vector_portable_add_b8(coefficient_normal_form, &sum1);
 7624|   276k|    libcrux_ml_kem_vector_portable_vector_type_PortableVector red =
 7625|   276k|        libcrux_ml_kem_vector_portable_barrett_reduce_b8(sum2);
 7626|   276k|    result.coefficients[i0] = red;
 7627|   276k|  }
 7628|  17.2k|  return result;
 7629|  17.2k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_serialize_compress_then_serialize_ring_element_v_6c:
 7751|  17.2k|    libcrux_ml_kem_polynomial_PolynomialRingElement_1d re, Eurydice_slice out) {
 7752|  17.2k|  libcrux_ml_kem_serialize_compress_then_serialize_4_ea(re, out);
 7753|  17.2k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_serialize_compress_then_serialize_4_ea:
 7724|  17.2k|    Eurydice_slice serialized) {
 7725|  17.2k|  for (size_t i = (size_t)0U;
 7726|   293k|       i < LIBCRUX_ML_KEM_POLYNOMIAL_VECTORS_IN_RING_ELEMENT; i++) {
  ------------------
  |  | 3770|   293k|#define LIBCRUX_ML_KEM_POLYNOMIAL_VECTORS_IN_RING_ELEMENT ((size_t)16U)
  ------------------
  |  Branch (7726:8): [True: 276k, False: 17.2k]
  ------------------
 7727|   276k|    size_t i0 = i;
 7728|   276k|    libcrux_ml_kem_vector_portable_vector_type_PortableVector coefficient =
 7729|   276k|        libcrux_ml_kem_vector_portable_compress_b8_d1(
 7730|   276k|            libcrux_ml_kem_serialize_to_unsigned_field_modulus_ea(
 7731|   276k|                re.coefficients[i0]));
 7732|   276k|    uint8_t bytes[8U];
 7733|   276k|    libcrux_ml_kem_vector_portable_serialize_4_b8(coefficient, bytes);
 7734|   276k|    Eurydice_slice_copy(
  ------------------
  |  |  229|   276k|  memcpy(dst.ptr, src.ptr, dst.len * sizeof(t))
  ------------------
 7735|   276k|        Eurydice_slice_subslice3(serialized, (size_t)8U * i0,
 7736|   276k|                                 (size_t)8U * i0 + (size_t)8U, uint8_t *),
 7737|   276k|        Eurydice_array_to_slice((size_t)8U, bytes, uint8_t), uint8_t);
 7738|   276k|  }
 7739|  17.2k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_vector_portable_compress_b8_d1:
 7711|   276k|    libcrux_ml_kem_vector_portable_vector_type_PortableVector a) {
 7712|   276k|  return libcrux_ml_kem_vector_portable_compress_compress_d1(a);
 7713|   276k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_vector_portable_compress_compress_d1:
 7687|   276k|    libcrux_ml_kem_vector_portable_vector_type_PortableVector a) {
 7688|   276k|  for (size_t i = (size_t)0U;
 7689|  4.70M|       i < LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_ELEMENTS_IN_VECTOR; i++) {
  ------------------
  |  | 3772|  4.70M|#define LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_ELEMENTS_IN_VECTOR ((size_t)16U)
  ------------------
  |  Branch (7689:8): [True: 4.42M, False: 276k]
  ------------------
 7690|  4.42M|    size_t i0 = i;
 7691|  4.42M|    int16_t uu____0 = libcrux_secrets_int_as_i16_f5(
 7692|  4.42M|        libcrux_ml_kem_vector_portable_compress_compress_ciphertext_coefficient(
 7693|  4.42M|            (uint8_t)(int32_t)4,
 7694|  4.42M|            libcrux_secrets_int_as_u16_f5(a.elements[i0])));
 7695|  4.42M|    a.elements[i0] = uu____0;
 7696|  4.42M|  }
 7697|   276k|  return a;
 7698|   276k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_vector_portable_serialize_4_b8:
 4755|   276k|    uint8_t ret[8U]) {
 4756|   276k|  libcrux_ml_kem_vector_portable_serialize_4(a, ret);
 4757|   276k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_vector_portable_serialize_4:
 4743|   276k|    uint8_t ret[8U]) {
 4744|   276k|  uint8_t ret0[8U];
 4745|   276k|  libcrux_ml_kem_vector_portable_serialize_serialize_4(a, ret0);
 4746|   276k|  libcrux_secrets_int_public_integers_declassify_d8_76(ret0, ret);
 4747|   276k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_vector_portable_serialize_serialize_4:
 4722|   276k|    uint8_t ret[8U]) {
 4723|   276k|  uint8_t_x4 result0_3 =
 4724|   276k|      libcrux_ml_kem_vector_portable_serialize_serialize_4_int(
 4725|   276k|          Eurydice_array_to_subslice3(v.elements, (size_t)0U, (size_t)8U,
  ------------------
  |  |  215|   276k|  EURYDICE_SLICE((t_ptr)x, (start), (end))
  |  |  ------------------
  |  |  |  |  169|   276k|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|   276k|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4726|   276k|                                      int16_t *));
 4727|   276k|  uint8_t_x4 result4_7 =
 4728|   276k|      libcrux_ml_kem_vector_portable_serialize_serialize_4_int(
 4729|   276k|          Eurydice_array_to_subslice3(v.elements, (size_t)8U, (size_t)16U,
  ------------------
  |  |  215|   276k|  EURYDICE_SLICE((t_ptr)x, (start), (end))
  |  |  ------------------
  |  |  |  |  169|   276k|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|   276k|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4730|   276k|                                      int16_t *));
 4731|   276k|  ret[0U] = result0_3.fst;
 4732|   276k|  ret[1U] = result0_3.snd;
 4733|   276k|  ret[2U] = result0_3.thd;
 4734|   276k|  ret[3U] = result0_3.f3;
 4735|   276k|  ret[4U] = result4_7.fst;
 4736|   276k|  ret[5U] = result4_7.snd;
 4737|   276k|  ret[6U] = result4_7.thd;
 4738|   276k|  ret[7U] = result4_7.f3;
 4739|   276k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_vector_portable_serialize_serialize_4_int:
 4694|   552k|libcrux_ml_kem_vector_portable_serialize_serialize_4_int(Eurydice_slice v) {
 4695|   552k|  uint8_t result0 = (uint32_t)libcrux_secrets_int_as_u8_f5(
 4696|   552k|                        Eurydice_slice_index(v, (size_t)1U, int16_t, int16_t *))
  ------------------
  |  |  180|   552k|#define Eurydice_slice_index(s, i, t, t_ptr_t) (((t_ptr_t)s.ptr)[i])
  ------------------
 4697|   552k|                        << 4U |
 4698|   552k|                    (uint32_t)libcrux_secrets_int_as_u8_f5(Eurydice_slice_index(
  ------------------
  |  |  180|   552k|#define Eurydice_slice_index(s, i, t, t_ptr_t) (((t_ptr_t)s.ptr)[i])
  ------------------
 4699|   552k|                        v, (size_t)0U, int16_t, int16_t *));
 4700|   552k|  uint8_t result1 = (uint32_t)libcrux_secrets_int_as_u8_f5(
 4701|   552k|                        Eurydice_slice_index(v, (size_t)3U, int16_t, int16_t *))
  ------------------
  |  |  180|   552k|#define Eurydice_slice_index(s, i, t, t_ptr_t) (((t_ptr_t)s.ptr)[i])
  ------------------
 4702|   552k|                        << 4U |
 4703|   552k|                    (uint32_t)libcrux_secrets_int_as_u8_f5(Eurydice_slice_index(
  ------------------
  |  |  180|   552k|#define Eurydice_slice_index(s, i, t, t_ptr_t) (((t_ptr_t)s.ptr)[i])
  ------------------
 4704|   552k|                        v, (size_t)2U, int16_t, int16_t *));
 4705|   552k|  uint8_t result2 = (uint32_t)libcrux_secrets_int_as_u8_f5(
 4706|   552k|                        Eurydice_slice_index(v, (size_t)5U, int16_t, int16_t *))
  ------------------
  |  |  180|   552k|#define Eurydice_slice_index(s, i, t, t_ptr_t) (((t_ptr_t)s.ptr)[i])
  ------------------
 4707|   552k|                        << 4U |
 4708|   552k|                    (uint32_t)libcrux_secrets_int_as_u8_f5(Eurydice_slice_index(
  ------------------
  |  |  180|   552k|#define Eurydice_slice_index(s, i, t, t_ptr_t) (((t_ptr_t)s.ptr)[i])
  ------------------
 4709|   552k|                        v, (size_t)4U, int16_t, int16_t *));
 4710|   552k|  uint8_t result3 = (uint32_t)libcrux_secrets_int_as_u8_f5(
 4711|   552k|                        Eurydice_slice_index(v, (size_t)7U, int16_t, int16_t *))
  ------------------
  |  |  180|   552k|#define Eurydice_slice_index(s, i, t, t_ptr_t) (((t_ptr_t)s.ptr)[i])
  ------------------
 4712|   552k|                        << 4U |
 4713|   552k|                    (uint32_t)libcrux_secrets_int_as_u8_f5(Eurydice_slice_index(
  ------------------
  |  |  180|   552k|#define Eurydice_slice_index(s, i, t, t_ptr_t) (((t_ptr_t)s.ptr)[i])
  ------------------
 4714|   552k|                        v, (size_t)6U, int16_t, int16_t *));
 4715|   552k|  return (KRML_CLITERAL(uint8_t_x4){
  ------------------
  |  |  154|   552k|#define KRML_CLITERAL(type) (type)
  ------------------
 4716|   552k|      .fst = result0, .snd = result1, .thd = result2, .f3 = result3});
 4717|   552k|}
libcrux_mlkem768_sha3.c:libcrux_secrets_int_public_integers_declassify_d8_76:
 1048|   276k|                                                     uint8_t ret[8U]) {
 1049|   276k|  memcpy(ret, self, (size_t)8U * sizeof(uint8_t));
 1050|   276k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_variant_kdf_39_d6:
 7903|  25.9k|    Eurydice_slice shared_secret, uint8_t *_, uint8_t ret[32U]) {
 7904|  25.9k|  uint8_t out[32U] = {0U};
 7905|  25.9k|  Eurydice_slice_copy(Eurydice_array_to_slice((size_t)32U, out, uint8_t),
  ------------------
  |  |  229|  25.9k|  memcpy(dst.ptr, src.ptr, dst.len * sizeof(t))
  ------------------
 7906|  25.9k|                      shared_secret, uint8_t);
 7907|  25.9k|  memcpy(ret, out, (size_t)32U * sizeof(uint8_t));
 7908|  25.9k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_types_as_slice_a9_80:
  856|  17.2k|    libcrux_ml_kem_mlkem768_MlKem768Ciphertext *self) {
  857|  17.2k|  return self->value;
  858|  17.2k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_constant_time_ops_compare_ciphertexts_select_shared_secret_in_constant_time:
 1277|  8.64k|    Eurydice_slice rhs_s, uint8_t ret[32U]) {
 1278|  8.64k|  uint8_t selector =
 1279|  8.64k|      libcrux_ml_kem_constant_time_ops_compare_ciphertexts_in_constant_time(
 1280|  8.64k|          lhs_c, rhs_c);
 1281|  8.64k|  uint8_t ret0[32U];
 1282|  8.64k|  libcrux_ml_kem_constant_time_ops_select_shared_secret_in_constant_time(
 1283|  8.64k|      lhs_s, rhs_s, selector, ret0);
 1284|  8.64k|  memcpy(ret, ret0, (size_t)32U * sizeof(uint8_t));
 1285|  8.64k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_constant_time_ops_compare_ciphertexts_in_constant_time:
 1240|  8.64k|    Eurydice_slice lhs, Eurydice_slice rhs) {
 1241|  8.64k|  return libcrux_ml_kem_constant_time_ops_compare(lhs, rhs);
 1242|  8.64k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_constant_time_ops_compare:
 1226|  8.64k|    Eurydice_slice lhs, Eurydice_slice rhs) {
 1227|  8.64k|  uint8_t r = 0U;
 1228|  9.40M|  for (size_t i = (size_t)0U; i < Eurydice_slice_len(lhs, uint8_t); i++) {
  ------------------
  |  |  173|  9.40M|#define Eurydice_slice_len(s, _) (s).len
  ------------------
  |  Branch (1228:31): [True: 9.40M, False: 8.64k]
  ------------------
 1229|  9.40M|    size_t i0 = i;
 1230|  9.40M|    uint8_t nr = (uint32_t)r |
 1231|  9.40M|                 ((uint32_t)Eurydice_slice_index(lhs, i0, uint8_t, uint8_t *) ^
  ------------------
  |  |  180|  9.40M|#define Eurydice_slice_index(s, i, t, t_ptr_t) (((t_ptr_t)s.ptr)[i])
  ------------------
 1232|  9.40M|                  (uint32_t)Eurydice_slice_index(rhs, i0, uint8_t, uint8_t *));
  ------------------
  |  |  180|  9.40M|#define Eurydice_slice_index(s, i, t, t_ptr_t) (((t_ptr_t)s.ptr)[i])
  ------------------
 1233|  9.40M|    r = nr;
 1234|  9.40M|  }
 1235|  8.64k|  return libcrux_ml_kem_constant_time_ops_is_non_zero(r);
 1236|  8.64k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_constant_time_ops_is_non_zero:
 1217|  17.2k|libcrux_ml_kem_constant_time_ops_is_non_zero(uint8_t value) {
 1218|  17.2k|  return libcrux_ml_kem_constant_time_ops_inz(value);
 1219|  17.2k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_constant_time_ops_inz:
 1209|  17.2k|libcrux_ml_kem_constant_time_ops_inz(uint8_t value) {
 1210|  17.2k|  uint16_t value0 = (uint16_t)value;
 1211|  17.2k|  uint8_t result =
 1212|  17.2k|      (uint8_t)((uint32_t)core_num__u16__wrapping_add(~value0, 1U) >> 8U);
 1213|  17.2k|  return (uint32_t)result & 1U;
 1214|  17.2k|}
libcrux_mlkem768_sha3.c:core_num__u16__wrapping_add:
  336|  17.2k|static inline uint16_t core_num__u16__wrapping_add(uint16_t x, uint16_t y) {
  337|  17.2k|  return x + y;
  338|  17.2k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_constant_time_ops_select_shared_secret_in_constant_time:
 1270|  8.64k|    uint8_t ret[32U]) {
 1271|  8.64k|  libcrux_ml_kem_constant_time_ops_select_ct(lhs, rhs, selector, ret);
 1272|  8.64k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_constant_time_ops_select_ct:
 1250|  8.64k|    uint8_t ret[32U]) {
 1251|  8.64k|  uint8_t mask = core_num__u8__wrapping_sub(
 1252|  8.64k|      libcrux_ml_kem_constant_time_ops_is_non_zero(selector), 1U);
 1253|  8.64k|  uint8_t out[32U] = {0U};
 1254|   285k|  for (size_t i = (size_t)0U; i < LIBCRUX_ML_KEM_CONSTANTS_SHARED_SECRET_SIZE;
  ------------------
  |  |  443|   285k|#define LIBCRUX_ML_KEM_CONSTANTS_SHARED_SECRET_SIZE ((size_t)32U)
  ------------------
  |  Branch (1254:31): [True: 276k, False: 8.64k]
  ------------------
 1255|   276k|       i++) {
 1256|   276k|    size_t i0 = i;
 1257|   276k|    uint8_t outi =
 1258|   276k|        ((uint32_t)Eurydice_slice_index(lhs, i0, uint8_t, uint8_t *) &
  ------------------
  |  |  180|   276k|#define Eurydice_slice_index(s, i, t, t_ptr_t) (((t_ptr_t)s.ptr)[i])
  ------------------
 1259|   276k|         (uint32_t)mask) |
 1260|   276k|        ((uint32_t)Eurydice_slice_index(rhs, i0, uint8_t, uint8_t *) &
  ------------------
  |  |  180|   276k|#define Eurydice_slice_index(s, i, t, t_ptr_t) (((t_ptr_t)s.ptr)[i])
  ------------------
 1261|   276k|         (uint32_t)~mask);
 1262|   276k|    out[i0] = outi;
 1263|   276k|  }
 1264|  8.64k|  memcpy(ret, out, (size_t)32U * sizeof(uint8_t));
 1265|  8.64k|}
libcrux_mlkem768_sha3.c:core_num__u8__wrapping_sub:
  339|  8.64k|static inline uint8_t core_num__u8__wrapping_sub(uint8_t x, uint8_t y) {
  340|  8.64k|  return x - y;
  341|  8.64k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_ind_cca_instantiations_portable_encapsulate_cd:
 8159|  8.64k|    libcrux_ml_kem_types_MlKemPublicKey_30 *public_key, uint8_t *randomness) {
 8160|  8.64k|  return libcrux_ml_kem_ind_cca_encapsulate_ca(public_key, randomness);
 8161|  8.64k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_ind_cca_encapsulate_ca:
 8096|  8.64k|    libcrux_ml_kem_types_MlKemPublicKey_30 *public_key, uint8_t *randomness) {
 8097|  8.64k|  uint8_t randomness0[32U];
 8098|  8.64k|  libcrux_ml_kem_variant_entropy_preprocess_39_9c(
 8099|  8.64k|      Eurydice_array_to_slice((size_t)32U, randomness, uint8_t), randomness0);
  ------------------
  |  |  204|  8.64k|  EURYDICE_SLICE(x, 0,                     \
  |  |  ------------------
  |  |  |  |  169|  8.64k|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|  8.64k|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  205|  8.64k|                 end) /* x is already at an array type, no need for cast */
  ------------------
 8100|  8.64k|  uint8_t to_hash[64U];
 8101|  8.64k|  libcrux_ml_kem_utils_into_padded_array_24(
 8102|  8.64k|      Eurydice_array_to_slice((size_t)32U, randomness0, uint8_t), to_hash);
  ------------------
  |  |  204|  8.64k|  EURYDICE_SLICE(x, 0,                     \
  |  |  ------------------
  |  |  |  |  169|  8.64k|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|  8.64k|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  205|  8.64k|                 end) /* x is already at an array type, no need for cast */
  ------------------
 8103|  8.64k|  Eurydice_slice uu____0 = Eurydice_array_to_subslice_from(
  ------------------
  |  |  225|  8.64k|  EURYDICE_SLICE((t *)x, r, size)
  |  |  ------------------
  |  |  |  |  169|  8.64k|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|  8.64k|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 8104|  8.64k|      (size_t)64U, to_hash, LIBCRUX_ML_KEM_CONSTANTS_H_DIGEST_SIZE, uint8_t,
 8105|  8.64k|      size_t, uint8_t[]);
 8106|  8.64k|  uint8_t ret0[32U];
 8107|  8.64k|  libcrux_ml_kem_hash_functions_portable_H_4a_e0(
 8108|  8.64k|      Eurydice_array_to_slice((size_t)1184U,
  ------------------
  |  |  204|  8.64k|  EURYDICE_SLICE(x, 0,                     \
  |  |  ------------------
  |  |  |  |  169|  8.64k|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|  8.64k|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  205|  8.64k|                 end) /* x is already at an array type, no need for cast */
  ------------------
 8109|  8.64k|                              libcrux_ml_kem_types_as_slice_e6_d0(public_key),
 8110|  8.64k|                              uint8_t),
 8111|  8.64k|      ret0);
 8112|  8.64k|  Eurydice_slice_copy(
  ------------------
  |  |  229|  8.64k|  memcpy(dst.ptr, src.ptr, dst.len * sizeof(t))
  ------------------
 8113|  8.64k|      uu____0, Eurydice_array_to_slice((size_t)32U, ret0, uint8_t), uint8_t);
 8114|  8.64k|  uint8_t hashed[64U];
 8115|  8.64k|  libcrux_ml_kem_hash_functions_portable_G_4a_e0(
 8116|  8.64k|      Eurydice_array_to_slice((size_t)64U, to_hash, uint8_t), hashed);
  ------------------
  |  |  204|  8.64k|  EURYDICE_SLICE(x, 0,                     \
  |  |  ------------------
  |  |  |  |  169|  8.64k|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|  8.64k|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  205|  8.64k|                 end) /* x is already at an array type, no need for cast */
  ------------------
 8117|  8.64k|  Eurydice_slice_uint8_t_x2 uu____1 = Eurydice_slice_split_at(
  ------------------
  |  |  254|  8.64k|  KRML_CLITERAL(ret_t) {                                                  \
  |  |  ------------------
  |  |  |  |  154|  8.64k|#define KRML_CLITERAL(type) (type)
  |  |  ------------------
  |  |  255|  8.64k|    EURYDICE_CFIELD(.fst =)                                               \
  |  |  256|  8.64k|    EURYDICE_SLICE((element_type *)(slice).ptr, 0, mid),                  \
  |  |  ------------------
  |  |  |  |  169|  8.64k|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|  8.64k|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  257|  8.64k|        EURYDICE_CFIELD(.snd =)                                           \
  |  |  258|  8.64k|            EURYDICE_SLICE((element_type *)(slice).ptr, mid, (slice).len) \
  |  |  ------------------
  |  |  |  |  169|  8.64k|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|  8.64k|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  259|  8.64k|  }
  ------------------
 8118|  8.64k|      Eurydice_array_to_slice((size_t)64U, hashed, uint8_t),
 8119|  8.64k|      LIBCRUX_ML_KEM_CONSTANTS_SHARED_SECRET_SIZE, uint8_t,
 8120|  8.64k|      Eurydice_slice_uint8_t_x2);
 8121|  8.64k|  Eurydice_slice shared_secret = uu____1.fst;
 8122|  8.64k|  Eurydice_slice pseudorandomness = uu____1.snd;
 8123|  8.64k|  uint8_t ciphertext[1088U];
 8124|  8.64k|  libcrux_ml_kem_ind_cpa_encrypt_2a(
 8125|  8.64k|      Eurydice_array_to_slice((size_t)1184U,
  ------------------
  |  |  204|  8.64k|  EURYDICE_SLICE(x, 0,                     \
  |  |  ------------------
  |  |  |  |  169|  8.64k|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|  8.64k|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  205|  8.64k|                 end) /* x is already at an array type, no need for cast */
  ------------------
 8126|  8.64k|                              libcrux_ml_kem_types_as_slice_e6_d0(public_key),
 8127|  8.64k|                              uint8_t),
 8128|  8.64k|      randomness0, pseudorandomness, ciphertext);
 8129|       |  /* Passing arrays by value in Rust generates a copy in C */
 8130|  8.64k|  uint8_t copy_of_ciphertext[1088U];
 8131|  8.64k|  memcpy(copy_of_ciphertext, ciphertext, (size_t)1088U * sizeof(uint8_t));
 8132|  8.64k|  tuple_c2 lit;
 8133|  8.64k|  lit.fst = libcrux_ml_kem_types_from_e0_80(copy_of_ciphertext);
 8134|  8.64k|  uint8_t ret[32U];
 8135|  8.64k|  libcrux_ml_kem_variant_kdf_39_d6(shared_secret, ciphertext, ret);
 8136|  8.64k|  memcpy(lit.snd, ret, (size_t)32U * sizeof(uint8_t));
 8137|  8.64k|  return lit;
 8138|  8.64k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_variant_entropy_preprocess_39_9c:
 8055|  8.64k|    Eurydice_slice randomness, uint8_t ret[32U]) {
 8056|  8.64k|  uint8_t out[32U] = {0U};
 8057|  8.64k|  Eurydice_slice_copy(Eurydice_array_to_slice((size_t)32U, out, uint8_t),
  ------------------
  |  |  229|  8.64k|  memcpy(dst.ptr, src.ptr, dst.len * sizeof(t))
  ------------------
 8058|  8.64k|                      randomness, uint8_t);
 8059|  8.64k|  memcpy(ret, out, (size_t)32U * sizeof(uint8_t));
 8060|  8.64k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_hash_functions_portable_H_4a_e0:
 8072|  17.2k|    Eurydice_slice input, uint8_t ret[32U]) {
 8073|  17.2k|  libcrux_ml_kem_hash_functions_portable_H(input, ret);
 8074|  17.2k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_hash_functions_portable_H:
 3725|  17.2k|    Eurydice_slice input, uint8_t ret[32U]) {
 3726|  17.2k|  uint8_t digest[32U] = {0U};
 3727|  17.2k|  libcrux_sha3_portable_sha256(
 3728|  17.2k|      Eurydice_array_to_slice((size_t)32U, digest, uint8_t), input);
  ------------------
  |  |  204|  17.2k|  EURYDICE_SLICE(x, 0,                     \
  |  |  ------------------
  |  |  |  |  169|  17.2k|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|  17.2k|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  205|  17.2k|                 end) /* x is already at an array type, no need for cast */
  ------------------
 3729|  17.2k|  memcpy(ret, digest, (size_t)32U * sizeof(uint8_t));
 3730|  17.2k|}
libcrux_mlkem768_sha3.c:libcrux_sha3_portable_sha256:
 3351|  17.2k|                                                         Eurydice_slice data) {
 3352|  17.2k|  libcrux_sha3_generic_keccak_portable_keccak1_ad(data, digest);
 3353|  17.2k|}
libcrux_mlkem768_sha3.c:libcrux_sha3_generic_keccak_portable_keccak1_ad:
 3315|  17.2k|    Eurydice_slice data, Eurydice_slice out) {
 3316|  17.2k|  libcrux_sha3_generic_keccak_KeccakState_17 s =
 3317|  17.2k|      libcrux_sha3_generic_keccak_new_80_04();
 3318|  17.2k|  size_t data_len = Eurydice_slice_len(data, uint8_t);
  ------------------
  |  |  173|  17.2k|#define Eurydice_slice_len(s, _) (s).len
  ------------------
 3319|   155k|  for (size_t i = (size_t)0U; i < data_len / (size_t)136U; i++) {
  ------------------
  |  Branch (3319:31): [True: 138k, False: 17.2k]
  ------------------
 3320|   138k|    size_t i0 = i;
 3321|   138k|    Eurydice_slice buf[1U] = {data};
 3322|   138k|    libcrux_sha3_generic_keccak_absorb_block_80_c60(&s, buf, i0 * (size_t)136U);
 3323|   138k|  }
 3324|  17.2k|  size_t rem = data_len % (size_t)136U;
 3325|  17.2k|  Eurydice_slice buf[1U] = {data};
 3326|  17.2k|  libcrux_sha3_generic_keccak_absorb_final_80_9e0(&s, buf, data_len - rem, rem);
 3327|  17.2k|  size_t outlen = Eurydice_slice_len(out, uint8_t);
  ------------------
  |  |  173|  17.2k|#define Eurydice_slice_len(s, _) (s).len
  ------------------
 3328|  17.2k|  size_t blocks = outlen / (size_t)136U;
 3329|  17.2k|  size_t last = outlen - outlen % (size_t)136U;
 3330|  17.2k|  if (blocks == (size_t)0U) {
  ------------------
  |  Branch (3330:7): [True: 17.2k, False: 0]
  ------------------
 3331|  17.2k|    libcrux_sha3_simd_portable_squeeze_13_5b(&s, out, (size_t)0U, outlen);
 3332|  17.2k|  } else {
 3333|      0|    libcrux_sha3_simd_portable_squeeze_13_5b(&s, out, (size_t)0U, (size_t)136U);
 3334|      0|    for (size_t i = (size_t)1U; i < blocks; i++) {
  ------------------
  |  Branch (3334:33): [True: 0, False: 0]
  ------------------
 3335|      0|      size_t i0 = i;
 3336|      0|      libcrux_sha3_generic_keccak_keccakf1600_80_04(&s);
 3337|      0|      libcrux_sha3_simd_portable_squeeze_13_5b(&s, out, i0 * (size_t)136U,
 3338|      0|                                               (size_t)136U);
 3339|      0|    }
 3340|      0|    if (last < outlen) {
  ------------------
  |  Branch (3340:9): [True: 0, False: 0]
  ------------------
 3341|      0|      libcrux_sha3_generic_keccak_keccakf1600_80_04(&s);
 3342|      0|      libcrux_sha3_simd_portable_squeeze_13_5b(&s, out, last, outlen - last);
 3343|      0|    }
 3344|      0|  }
 3345|  17.2k|}
libcrux_mlkem768_sha3.c:libcrux_sha3_generic_keccak_absorb_final_80_9e0:
 3250|  17.2k|    size_t start, size_t len) {
 3251|  17.2k|  libcrux_sha3_simd_portable_load_last_a1_ad(self, last, start, len);
 3252|  17.2k|  libcrux_sha3_generic_keccak_keccakf1600_80_04(self);
 3253|  17.2k|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_load_last_a1_ad:
 3232|  17.2k|    size_t start, size_t len) {
 3233|  17.2k|  libcrux_sha3_simd_portable_load_last_ad(self->st, input[0U], start, len);
 3234|  17.2k|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_load_last_ad:
 3205|  17.2k|    uint64_t *state, Eurydice_slice blocks, size_t start, size_t len) {
 3206|  17.2k|  uint8_t buffer[136U] = {0U};
 3207|  17.2k|  Eurydice_slice_copy(
  ------------------
  |  |  229|  17.2k|  memcpy(dst.ptr, src.ptr, dst.len * sizeof(t))
  ------------------
 3208|  17.2k|      Eurydice_array_to_subslice3(buffer, (size_t)0U, len, uint8_t *),
 3209|  17.2k|      Eurydice_slice_subslice3(blocks, start, start + len, uint8_t *), uint8_t);
 3210|  17.2k|  buffer[len] = 6U;
 3211|  17.2k|  size_t uu____0 = (size_t)136U - (size_t)1U;
 3212|  17.2k|  buffer[uu____0] = (uint32_t)buffer[uu____0] | 128U;
 3213|  17.2k|  libcrux_sha3_simd_portable_load_block_5b(
 3214|  17.2k|      state, Eurydice_array_to_slice((size_t)136U, buffer, uint8_t),
  ------------------
  |  |  204|  17.2k|  EURYDICE_SLICE(x, 0,                     \
  |  |  ------------------
  |  |  |  |  169|  17.2k|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|  17.2k|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  205|  17.2k|                 end) /* x is already at an array type, no need for cast */
  ------------------
 3215|  17.2k|      (size_t)0U);
 3216|  17.2k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_types_as_slice_e6_d0:
  843|  17.2k|    libcrux_ml_kem_types_MlKemPublicKey_30 *self) {
  844|  17.2k|  return self->value;
  845|  17.2k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_types_from_e0_80:
  825|  8.64k|libcrux_ml_kem_types_from_e0_80(uint8_t value[1088U]) {
  826|       |  /* Passing arrays by value in Rust generates a copy in C */
  827|  8.64k|  uint8_t copy_of_value[1088U];
  828|  8.64k|  memcpy(copy_of_value, value, (size_t)1088U * sizeof(uint8_t));
  829|  8.64k|  libcrux_ml_kem_mlkem768_MlKem768Ciphertext lit;
  830|  8.64k|  memcpy(lit.value, copy_of_value, (size_t)1088U * sizeof(uint8_t));
  831|  8.64k|  return lit;
  832|  8.64k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_ind_cca_instantiations_portable_generate_keypair_ce:
 8754|  8.64k|    uint8_t *randomness) {
 8755|  8.64k|  return libcrux_ml_kem_ind_cca_generate_keypair_15(randomness);
 8756|  8.64k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_ind_cca_generate_keypair_15:
 8705|  8.64k|libcrux_ml_kem_ind_cca_generate_keypair_15(uint8_t *randomness) {
 8706|  8.64k|  Eurydice_slice ind_cpa_keypair_randomness = Eurydice_array_to_subslice3(
  ------------------
  |  |  215|  8.64k|  EURYDICE_SLICE((t_ptr)x, (start), (end))
  |  |  ------------------
  |  |  |  |  169|  8.64k|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|  8.64k|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 8707|  8.64k|      randomness, (size_t)0U,
 8708|  8.64k|      LIBCRUX_ML_KEM_CONSTANTS_CPA_PKE_KEY_GENERATION_SEED_SIZE, uint8_t *);
 8709|  8.64k|  Eurydice_slice implicit_rejection_value = Eurydice_array_to_subslice_from(
  ------------------
  |  |  225|  8.64k|  EURYDICE_SLICE((t *)x, r, size)
  |  |  ------------------
  |  |  |  |  169|  8.64k|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|  8.64k|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 8710|  8.64k|      (size_t)64U, randomness,
 8711|  8.64k|      LIBCRUX_ML_KEM_CONSTANTS_CPA_PKE_KEY_GENERATION_SEED_SIZE, uint8_t,
 8712|  8.64k|      size_t, uint8_t[]);
 8713|  8.64k|  libcrux_ml_kem_utils_extraction_helper_Keypair768 uu____0 =
 8714|  8.64k|      libcrux_ml_kem_ind_cpa_generate_keypair_ea(ind_cpa_keypair_randomness);
 8715|  8.64k|  uint8_t ind_cpa_private_key[1152U];
 8716|  8.64k|  memcpy(ind_cpa_private_key, uu____0.fst, (size_t)1152U * sizeof(uint8_t));
 8717|  8.64k|  uint8_t public_key[1184U];
 8718|  8.64k|  memcpy(public_key, uu____0.snd, (size_t)1184U * sizeof(uint8_t));
 8719|  8.64k|  uint8_t secret_key_serialized[2400U];
 8720|  8.64k|  libcrux_ml_kem_ind_cca_serialize_kem_secret_key_d6(
 8721|  8.64k|      Eurydice_array_to_slice((size_t)1152U, ind_cpa_private_key, uint8_t),
  ------------------
  |  |  204|  8.64k|  EURYDICE_SLICE(x, 0,                     \
  |  |  ------------------
  |  |  |  |  169|  8.64k|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|  8.64k|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  205|  8.64k|                 end) /* x is already at an array type, no need for cast */
  ------------------
 8722|  8.64k|      Eurydice_array_to_slice((size_t)1184U, public_key, uint8_t),
  ------------------
  |  |  204|  8.64k|  EURYDICE_SLICE(x, 0,                     \
  |  |  ------------------
  |  |  |  |  169|  8.64k|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|  8.64k|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  205|  8.64k|                 end) /* x is already at an array type, no need for cast */
  ------------------
 8723|  8.64k|      implicit_rejection_value, secret_key_serialized);
 8724|       |  /* Passing arrays by value in Rust generates a copy in C */
 8725|  8.64k|  uint8_t copy_of_secret_key_serialized[2400U];
 8726|  8.64k|  memcpy(copy_of_secret_key_serialized, secret_key_serialized,
 8727|  8.64k|         (size_t)2400U * sizeof(uint8_t));
 8728|  8.64k|  libcrux_ml_kem_types_MlKemPrivateKey_d9 private_key =
 8729|  8.64k|      libcrux_ml_kem_types_from_77_28(copy_of_secret_key_serialized);
 8730|  8.64k|  libcrux_ml_kem_types_MlKemPrivateKey_d9 uu____2 = private_key;
 8731|       |  /* Passing arrays by value in Rust generates a copy in C */
 8732|  8.64k|  uint8_t copy_of_public_key[1184U];
 8733|  8.64k|  memcpy(copy_of_public_key, public_key, (size_t)1184U * sizeof(uint8_t));
 8734|  8.64k|  return libcrux_ml_kem_types_from_17_74(
 8735|  8.64k|      uu____2, libcrux_ml_kem_types_from_fd_d0(copy_of_public_key));
 8736|  8.64k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_ind_cpa_generate_keypair_ea:
 8605|  8.64k|libcrux_ml_kem_ind_cpa_generate_keypair_ea(Eurydice_slice key_generation_seed) {
 8606|  8.64k|  libcrux_ml_kem_ind_cpa_unpacked_IndCpaPrivateKeyUnpacked_a0 private_key =
 8607|  8.64k|      libcrux_ml_kem_ind_cpa_unpacked_default_70_1b();
 8608|  8.64k|  libcrux_ml_kem_ind_cpa_unpacked_IndCpaPublicKeyUnpacked_a0 public_key =
 8609|  8.64k|      libcrux_ml_kem_ind_cpa_unpacked_default_8b_1b();
 8610|  8.64k|  libcrux_ml_kem_ind_cpa_generate_keypair_unpacked_1c(
 8611|  8.64k|      key_generation_seed, &private_key, &public_key);
 8612|  8.64k|  return libcrux_ml_kem_ind_cpa_serialize_unpacked_secret_key_6c(&public_key,
 8613|  8.64k|                                                                 &private_key);
 8614|  8.64k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_ind_cpa_unpacked_default_70_1b:
 8189|  8.64k|libcrux_ml_kem_ind_cpa_unpacked_default_70_1b(void) {
 8190|  8.64k|  libcrux_ml_kem_ind_cpa_unpacked_IndCpaPrivateKeyUnpacked_a0 lit;
 8191|  8.64k|  libcrux_ml_kem_polynomial_PolynomialRingElement_1d repeat_expression[3U];
 8192|  34.5k|  for (size_t i = (size_t)0U; i < (size_t)3U; i++) {
  ------------------
  |  Branch (8192:31): [True: 25.9k, False: 8.64k]
  ------------------
 8193|  25.9k|    repeat_expression[i] = libcrux_ml_kem_polynomial_ZERO_d6_ea();
 8194|  25.9k|  }
 8195|  8.64k|  memcpy(
 8196|  8.64k|      lit.secret_as_ntt, repeat_expression,
 8197|  8.64k|      (size_t)3U * sizeof(libcrux_ml_kem_polynomial_PolynomialRingElement_1d));
 8198|  8.64k|  return lit;
 8199|  8.64k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_ind_cpa_generate_keypair_unpacked_1c:
 8409|  8.64k|    libcrux_ml_kem_ind_cpa_unpacked_IndCpaPublicKeyUnpacked_a0 *public_key) {
 8410|  8.64k|  uint8_t hashed[64U];
 8411|  8.64k|  libcrux_ml_kem_variant_cpa_keygen_seed_39_9c(key_generation_seed, hashed);
 8412|  8.64k|  Eurydice_slice_uint8_t_x2 uu____0 = Eurydice_slice_split_at(
  ------------------
  |  |  254|  8.64k|  KRML_CLITERAL(ret_t) {                                                  \
  |  |  ------------------
  |  |  |  |  154|  8.64k|#define KRML_CLITERAL(type) (type)
  |  |  ------------------
  |  |  255|  8.64k|    EURYDICE_CFIELD(.fst =)                                               \
  |  |  256|  8.64k|    EURYDICE_SLICE((element_type *)(slice).ptr, 0, mid),                  \
  |  |  ------------------
  |  |  |  |  169|  8.64k|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|  8.64k|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  257|  8.64k|        EURYDICE_CFIELD(.snd =)                                           \
  |  |  258|  8.64k|            EURYDICE_SLICE((element_type *)(slice).ptr, mid, (slice).len) \
  |  |  ------------------
  |  |  |  |  169|  8.64k|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|  8.64k|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  259|  8.64k|  }
  ------------------
 8413|  8.64k|      Eurydice_array_to_slice((size_t)64U, hashed, uint8_t), (size_t)32U,
 8414|  8.64k|      uint8_t, Eurydice_slice_uint8_t_x2);
 8415|  8.64k|  Eurydice_slice seed_for_A = uu____0.fst;
 8416|  8.64k|  Eurydice_slice seed_for_secret_and_error = uu____0.snd;
 8417|  8.64k|  libcrux_ml_kem_polynomial_PolynomialRingElement_1d(*uu____1)[3U] =
 8418|  8.64k|      public_key->A;
 8419|  8.64k|  uint8_t ret[34U];
 8420|  8.64k|  libcrux_ml_kem_utils_into_padded_array_b6(seed_for_A, ret);
 8421|  8.64k|  libcrux_ml_kem_matrix_sample_matrix_A_2b(uu____1, ret, true);
 8422|  8.64k|  uint8_t prf_input[33U];
 8423|  8.64k|  libcrux_ml_kem_utils_into_padded_array_c8(seed_for_secret_and_error,
 8424|  8.64k|                                            prf_input);
 8425|  8.64k|  uint8_t domain_separator =
 8426|  8.64k|      libcrux_ml_kem_ind_cpa_sample_vector_cbd_then_ntt_3b(
 8427|  8.64k|          private_key->secret_as_ntt, prf_input, 0U);
 8428|  8.64k|  libcrux_ml_kem_polynomial_PolynomialRingElement_1d error_as_ntt[3U];
 8429|  34.5k|  for (size_t i = (size_t)0U; i < (size_t)3U; i++) {
  ------------------
  |  Branch (8429:31): [True: 25.9k, False: 8.64k]
  ------------------
 8430|       |    /* original Rust expression is not an lvalue in C */
 8431|  25.9k|    void *lvalue = (void *)0U;
 8432|  25.9k|    error_as_ntt[i] =
 8433|  25.9k|        libcrux_ml_kem_ind_cpa_generate_keypair_unpacked_call_mut_73_1c(&lvalue,
 8434|  25.9k|                                                                        i);
 8435|  25.9k|  }
 8436|  8.64k|  libcrux_ml_kem_ind_cpa_sample_vector_cbd_then_ntt_3b(error_as_ntt, prf_input,
 8437|  8.64k|                                                       domain_separator);
 8438|  8.64k|  libcrux_ml_kem_matrix_compute_As_plus_e_1b(
 8439|  8.64k|      public_key->t_as_ntt, public_key->A, private_key->secret_as_ntt,
 8440|  8.64k|      error_as_ntt);
 8441|  8.64k|  uint8_t uu____2[32U];
 8442|  8.64k|  Result_fb dst;
 8443|  8.64k|  Eurydice_slice_to_array2(&dst, seed_for_A, Eurydice_slice, uint8_t[32U],
  ------------------
  |  |  277|  8.64k|  Eurydice_slice_to_array3(&(dst)->tag, (char *)&(dst)->val.case_Ok, src, \
  |  |  278|  8.64k|                           sizeof(t_arr))
  ------------------
 8444|  8.64k|                           TryFromSliceError);
 8445|  8.64k|  unwrap_26_b3(dst, uu____2);
 8446|  8.64k|  memcpy(public_key->seed_for_A, uu____2, (size_t)32U * sizeof(uint8_t));
 8447|  8.64k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_variant_cpa_keygen_seed_39_9c:
 8212|  8.64k|    Eurydice_slice key_generation_seed, uint8_t ret[64U]) {
 8213|  8.64k|  uint8_t seed[33U] = {0U};
 8214|  8.64k|  Eurydice_slice_copy(
  ------------------
  |  |  229|  8.64k|  memcpy(dst.ptr, src.ptr, dst.len * sizeof(t))
  ------------------
 8215|  8.64k|      Eurydice_array_to_subslice3(
 8216|  8.64k|          seed, (size_t)0U,
 8217|  8.64k|          LIBCRUX_ML_KEM_CONSTANTS_CPA_PKE_KEY_GENERATION_SEED_SIZE, uint8_t *),
 8218|  8.64k|      key_generation_seed, uint8_t);
 8219|  8.64k|  seed[LIBCRUX_ML_KEM_CONSTANTS_CPA_PKE_KEY_GENERATION_SEED_SIZE] =
  ------------------
  |  |  455|  8.64k|#define LIBCRUX_ML_KEM_CONSTANTS_CPA_PKE_KEY_GENERATION_SEED_SIZE ((size_t)32U)
  ------------------
 8220|  8.64k|      (uint8_t)(size_t)3U;
 8221|  8.64k|  uint8_t ret0[64U];
 8222|  8.64k|  libcrux_ml_kem_hash_functions_portable_G_4a_e0(
 8223|  8.64k|      Eurydice_array_to_slice((size_t)33U, seed, uint8_t), ret0);
  ------------------
  |  |  204|  8.64k|  EURYDICE_SLICE(x, 0,                     \
  |  |  ------------------
  |  |  |  |  169|  8.64k|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|  8.64k|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  205|  8.64k|                 end) /* x is already at an array type, no need for cast */
  ------------------
 8224|  8.64k|  memcpy(ret, ret0, (size_t)64U * sizeof(uint8_t));
 8225|  8.64k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_ind_cpa_generate_keypair_unpacked_call_mut_73_1c:
 8247|  25.9k|    void **_, size_t tupled_args) {
 8248|  25.9k|  return libcrux_ml_kem_polynomial_ZERO_d6_ea();
 8249|  25.9k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_matrix_compute_As_plus_e_1b:
 8322|  8.64k|    libcrux_ml_kem_polynomial_PolynomialRingElement_1d *error_as_ntt) {
 8323|  8.64k|  for (size_t i = (size_t)0U;
 8324|  34.5k|       i < Eurydice_slice_len(
  ------------------
  |  |  173|  34.5k|#define Eurydice_slice_len(s, _) (s).len
  ------------------
  |  Branch (8324:8): [True: 25.9k, False: 8.64k]
  ------------------
 8325|  8.64k|               Eurydice_array_to_slice(
 8326|  8.64k|                   (size_t)3U, matrix_A,
 8327|  8.64k|                   libcrux_ml_kem_polynomial_PolynomialRingElement_1d[3U]),
 8328|  8.64k|               libcrux_ml_kem_polynomial_PolynomialRingElement_1d[3U]);
 8329|  25.9k|       i++) {
 8330|  25.9k|    size_t i0 = i;
 8331|  25.9k|    libcrux_ml_kem_polynomial_PolynomialRingElement_1d *row = matrix_A[i0];
 8332|  25.9k|    libcrux_ml_kem_polynomial_PolynomialRingElement_1d uu____0 =
 8333|  25.9k|        libcrux_ml_kem_polynomial_ZERO_d6_ea();
 8334|  25.9k|    t_as_ntt[i0] = uu____0;
 8335|  25.9k|    for (size_t i1 = (size_t)0U;
 8336|   103k|         i1 < Eurydice_slice_len(
  ------------------
  |  |  173|   103k|#define Eurydice_slice_len(s, _) (s).len
  ------------------
  |  Branch (8336:10): [True: 77.7k, False: 25.9k]
  ------------------
 8337|  25.9k|                  Eurydice_array_to_slice(
 8338|  25.9k|                      (size_t)3U, row,
 8339|  25.9k|                      libcrux_ml_kem_polynomial_PolynomialRingElement_1d),
 8340|  25.9k|                  libcrux_ml_kem_polynomial_PolynomialRingElement_1d);
 8341|  77.7k|         i1++) {
 8342|  77.7k|      size_t j = i1;
 8343|  77.7k|      libcrux_ml_kem_polynomial_PolynomialRingElement_1d *matrix_element =
 8344|  77.7k|          &row[j];
 8345|  77.7k|      libcrux_ml_kem_polynomial_PolynomialRingElement_1d product =
 8346|  77.7k|          libcrux_ml_kem_polynomial_ntt_multiply_d6_ea(matrix_element,
 8347|  77.7k|                                                       &s_as_ntt[j]);
 8348|  77.7k|      libcrux_ml_kem_polynomial_add_to_ring_element_d6_1b(&t_as_ntt[i0],
 8349|  77.7k|                                                          &product);
 8350|  77.7k|    }
 8351|  25.9k|    libcrux_ml_kem_polynomial_add_standard_error_reduce_d6_ea(
 8352|  25.9k|        &t_as_ntt[i0], &error_as_ntt[i0]);
 8353|  25.9k|  }
 8354|  8.64k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_polynomial_add_standard_error_reduce_d6_ea:
 8305|  25.9k|    libcrux_ml_kem_polynomial_PolynomialRingElement_1d *error) {
 8306|  25.9k|  libcrux_ml_kem_polynomial_add_standard_error_reduce_ea(self, error);
 8307|  25.9k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_polynomial_add_standard_error_reduce_ea:
 8274|  25.9k|    libcrux_ml_kem_polynomial_PolynomialRingElement_1d *error) {
 8275|  25.9k|  for (size_t i = (size_t)0U;
 8276|   440k|       i < LIBCRUX_ML_KEM_POLYNOMIAL_VECTORS_IN_RING_ELEMENT; i++) {
  ------------------
  |  | 3770|   440k|#define LIBCRUX_ML_KEM_POLYNOMIAL_VECTORS_IN_RING_ELEMENT ((size_t)16U)
  ------------------
  |  Branch (8276:8): [True: 414k, False: 25.9k]
  ------------------
 8277|   414k|    size_t j = i;
 8278|   414k|    libcrux_ml_kem_vector_portable_vector_type_PortableVector
 8279|   414k|        coefficient_normal_form =
 8280|   414k|            libcrux_ml_kem_polynomial_to_standard_domain_ea(
 8281|   414k|                myself->coefficients[j]);
 8282|   414k|    libcrux_ml_kem_vector_portable_vector_type_PortableVector sum =
 8283|   414k|        libcrux_ml_kem_vector_portable_add_b8(coefficient_normal_form,
 8284|   414k|                                              &error->coefficients[j]);
 8285|   414k|    libcrux_ml_kem_vector_portable_vector_type_PortableVector red =
 8286|   414k|        libcrux_ml_kem_vector_portable_barrett_reduce_b8(sum);
 8287|   414k|    myself->coefficients[j] = red;
 8288|   414k|  }
 8289|  25.9k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_polynomial_to_standard_domain_ea:
 8259|   414k|    libcrux_ml_kem_vector_portable_vector_type_PortableVector vector) {
 8260|   414k|  return libcrux_ml_kem_vector_portable_montgomery_multiply_by_constant_b8(
 8261|   414k|      vector,
 8262|   414k|      LIBCRUX_ML_KEM_VECTOR_TRAITS_MONTGOMERY_R_SQUARED_MOD_FIELD_MODULUS);
  ------------------
  |  | 3775|   414k|  ((int16_t)1353)
  ------------------
 8263|   414k|}
libcrux_mlkem768_sha3.c:unwrap_26_b3:
  803|  8.64k|static inline void unwrap_26_b3(Result_fb self, uint8_t ret[32U]) {
  804|  8.64k|  if (self.tag == Ok) {
  ------------------
  |  |  721|  8.64k|#define Ok 0
  ------------------
  |  Branch (804:7): [True: 8.64k, False: 0]
  ------------------
  805|  8.64k|    uint8_t f0[32U];
  806|  8.64k|    memcpy(f0, self.val.case_Ok, (size_t)32U * sizeof(uint8_t));
  807|  8.64k|    memcpy(ret, f0, (size_t)32U * sizeof(uint8_t));
  808|  8.64k|  } else {
  809|      0|    KRML_HOST_EPRINTF("KaRaMeL abort at %s:%d\n%s\n", __FILE__, __LINE__,
  810|      0|                      "unwrap not Ok");
  811|       |    KRML_HOST_EXIT(255U);
  ------------------
  |  |   41|      0|#define KRML_HOST_EXIT(x) do { \
  |  |   42|      0|    fprintf(stderr, "mlkem internal error"); \
  |  |   43|      0|    exit(x); \
  |  |   44|      0|} while (0)
  |  |  ------------------
  |  |  |  Branch (44:10): [Folded, False: 0]
  |  |  ------------------
  ------------------
  812|      0|  }
  813|  8.64k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_ind_cpa_serialize_unpacked_secret_key_6c:
 8567|  8.64k|    libcrux_ml_kem_ind_cpa_unpacked_IndCpaPrivateKeyUnpacked_a0 *private_key) {
 8568|  8.64k|  uint8_t public_key_serialized[1184U];
 8569|  8.64k|  libcrux_ml_kem_ind_cpa_serialize_public_key_89(
 8570|  8.64k|      public_key->t_as_ntt,
 8571|  8.64k|      Eurydice_array_to_slice((size_t)32U, public_key->seed_for_A, uint8_t),
  ------------------
  |  |  204|  8.64k|  EURYDICE_SLICE(x, 0,                     \
  |  |  ------------------
  |  |  |  |  169|  8.64k|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|  8.64k|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  205|  8.64k|                 end) /* x is already at an array type, no need for cast */
  ------------------
 8572|  8.64k|      public_key_serialized);
 8573|  8.64k|  uint8_t secret_key_serialized[1152U] = {0U};
 8574|  8.64k|  libcrux_ml_kem_ind_cpa_serialize_vector_1b(
 8575|  8.64k|      private_key->secret_as_ntt,
 8576|  8.64k|      Eurydice_array_to_slice((size_t)1152U, secret_key_serialized, uint8_t));
  ------------------
  |  |  204|  8.64k|  EURYDICE_SLICE(x, 0,                     \
  |  |  ------------------
  |  |  |  |  169|  8.64k|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|  8.64k|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  205|  8.64k|                 end) /* x is already at an array type, no need for cast */
  ------------------
 8577|       |  /* Passing arrays by value in Rust generates a copy in C */
 8578|  8.64k|  uint8_t copy_of_secret_key_serialized[1152U];
 8579|  8.64k|  memcpy(copy_of_secret_key_serialized, secret_key_serialized,
 8580|  8.64k|         (size_t)1152U * sizeof(uint8_t));
 8581|       |  /* Passing arrays by value in Rust generates a copy in C */
 8582|  8.64k|  uint8_t copy_of_public_key_serialized[1184U];
 8583|  8.64k|  memcpy(copy_of_public_key_serialized, public_key_serialized,
 8584|  8.64k|         (size_t)1184U * sizeof(uint8_t));
 8585|  8.64k|  libcrux_ml_kem_utils_extraction_helper_Keypair768 lit;
 8586|  8.64k|  memcpy(lit.fst, copy_of_secret_key_serialized,
 8587|  8.64k|         (size_t)1152U * sizeof(uint8_t));
 8588|  8.64k|  memcpy(lit.snd, copy_of_public_key_serialized,
 8589|  8.64k|         (size_t)1184U * sizeof(uint8_t));
 8590|  8.64k|  return lit;
 8591|  8.64k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_ind_cpa_serialize_public_key_89:
 8546|  17.2k|    Eurydice_slice seed_for_a, uint8_t ret[1184U]) {
 8547|  17.2k|  uint8_t public_key_serialized[1184U] = {0U};
 8548|  17.2k|  libcrux_ml_kem_ind_cpa_serialize_public_key_mut_89(t_as_ntt, seed_for_a,
 8549|  17.2k|                                                     public_key_serialized);
 8550|  17.2k|  memcpy(ret, public_key_serialized, (size_t)1184U * sizeof(uint8_t));
 8551|  17.2k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_ind_cpa_serialize_public_key_mut_89:
 8519|  17.2k|    Eurydice_slice seed_for_a, uint8_t *serialized) {
 8520|  17.2k|  libcrux_ml_kem_ind_cpa_serialize_vector_1b(
 8521|  17.2k|      t_as_ntt,
 8522|  17.2k|      Eurydice_array_to_subslice3(
  ------------------
  |  |  215|  17.2k|  EURYDICE_SLICE((t_ptr)x, (start), (end))
  |  |  ------------------
  |  |  |  |  169|  17.2k|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|  17.2k|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 8523|  17.2k|          serialized, (size_t)0U,
 8524|  17.2k|          libcrux_ml_kem_constants_ranked_bytes_per_ring_element((size_t)3U),
 8525|  17.2k|          uint8_t *));
 8526|  17.2k|  Eurydice_slice_copy(
  ------------------
  |  |  229|  17.2k|  memcpy(dst.ptr, src.ptr, dst.len * sizeof(t))
  ------------------
 8527|  17.2k|      Eurydice_array_to_subslice_from(
 8528|  17.2k|          (size_t)1184U, serialized,
 8529|  17.2k|          libcrux_ml_kem_constants_ranked_bytes_per_ring_element((size_t)3U),
 8530|  17.2k|          uint8_t, size_t, uint8_t[]),
 8531|  17.2k|      seed_for_a, uint8_t);
 8532|  17.2k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_constants_ranked_bytes_per_ring_element:
  468|   112k|    size_t rank) {
  469|   112k|  return rank * LIBCRUX_ML_KEM_CONSTANTS_BITS_PER_RING_ELEMENT / (size_t)8U;
  ------------------
  |  |  450|   112k|  (LIBCRUX_ML_KEM_CONSTANTS_COEFFICIENTS_IN_RING_ELEMENT * (size_t)12U)
  |  |  ------------------
  |  |  |  |  447|   112k|#define LIBCRUX_ML_KEM_CONSTANTS_COEFFICIENTS_IN_RING_ELEMENT ((size_t)256U)
  |  |  ------------------
  ------------------
  470|   112k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_ind_cpa_serialize_vector_1b:
 8486|  25.9k|    Eurydice_slice out) {
 8487|  25.9k|  for (size_t i = (size_t)0U;
 8488|   103k|       i < Eurydice_slice_len(
  ------------------
  |  |  173|   103k|#define Eurydice_slice_len(s, _) (s).len
  ------------------
  |  Branch (8488:8): [True: 77.7k, False: 25.9k]
  ------------------
 8489|  25.9k|               Eurydice_array_to_slice(
 8490|  25.9k|                   (size_t)3U, key,
 8491|  25.9k|                   libcrux_ml_kem_polynomial_PolynomialRingElement_1d),
 8492|  25.9k|               libcrux_ml_kem_polynomial_PolynomialRingElement_1d);
 8493|  77.7k|       i++) {
 8494|  77.7k|    size_t i0 = i;
 8495|  77.7k|    libcrux_ml_kem_polynomial_PolynomialRingElement_1d re = key[i0];
 8496|  77.7k|    Eurydice_slice uu____0 = Eurydice_slice_subslice3(
  ------------------
  |  |  195|  77.7k|  EURYDICE_SLICE((t_ptr)s.ptr, (start), (end))
  |  |  ------------------
  |  |  |  |  169|  77.7k|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|  77.7k|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 8497|  77.7k|        out, i0 * LIBCRUX_ML_KEM_CONSTANTS_BYTES_PER_RING_ELEMENT,
 8498|  77.7k|        (i0 + (size_t)1U) * LIBCRUX_ML_KEM_CONSTANTS_BYTES_PER_RING_ELEMENT,
 8499|  77.7k|        uint8_t *);
 8500|  77.7k|    uint8_t ret[384U];
 8501|  77.7k|    libcrux_ml_kem_serialize_serialize_uncompressed_ring_element_ea(&re, ret);
 8502|  77.7k|    Eurydice_slice_copy(
  ------------------
  |  |  229|  77.7k|  memcpy(dst.ptr, src.ptr, dst.len * sizeof(t))
  ------------------
 8503|  77.7k|        uu____0, Eurydice_array_to_slice((size_t)384U, ret, uint8_t), uint8_t);
 8504|  77.7k|  }
 8505|  25.9k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_serialize_serialize_uncompressed_ring_element_ea:
 8457|  77.7k|    libcrux_ml_kem_polynomial_PolynomialRingElement_1d *re, uint8_t ret[384U]) {
 8458|  77.7k|  uint8_t serialized[384U] = {0U};
 8459|  77.7k|  for (size_t i = (size_t)0U;
 8460|  1.32M|       i < LIBCRUX_ML_KEM_POLYNOMIAL_VECTORS_IN_RING_ELEMENT; i++) {
  ------------------
  |  | 3770|  1.32M|#define LIBCRUX_ML_KEM_POLYNOMIAL_VECTORS_IN_RING_ELEMENT ((size_t)16U)
  ------------------
  |  Branch (8460:8): [True: 1.24M, False: 77.7k]
  ------------------
 8461|  1.24M|    size_t i0 = i;
 8462|  1.24M|    libcrux_ml_kem_vector_portable_vector_type_PortableVector coefficient =
 8463|  1.24M|        libcrux_ml_kem_serialize_to_unsigned_field_modulus_ea(
 8464|  1.24M|            re->coefficients[i0]);
 8465|  1.24M|    uint8_t bytes[24U];
 8466|  1.24M|    libcrux_ml_kem_vector_portable_serialize_12_b8(coefficient, bytes);
 8467|  1.24M|    Eurydice_slice_copy(
  ------------------
  |  |  229|  1.24M|  memcpy(dst.ptr, src.ptr, dst.len * sizeof(t))
  ------------------
 8468|  1.24M|        Eurydice_array_to_subslice3(serialized, (size_t)24U * i0,
 8469|  1.24M|                                    (size_t)24U * i0 + (size_t)24U, uint8_t *),
 8470|  1.24M|        Eurydice_array_to_slice((size_t)24U, bytes, uint8_t), uint8_t);
 8471|  1.24M|  }
 8472|  77.7k|  memcpy(ret, serialized, (size_t)384U * sizeof(uint8_t));
 8473|  77.7k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_vector_portable_serialize_12_b8:
 5116|  1.24M|    uint8_t ret[24U]) {
 5117|  1.24M|  libcrux_ml_kem_vector_portable_serialize_12(a, ret);
 5118|  1.24M|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_vector_portable_serialize_12:
 5104|  1.24M|    uint8_t ret[24U]) {
 5105|  1.24M|  uint8_t ret0[24U];
 5106|  1.24M|  libcrux_ml_kem_vector_portable_serialize_serialize_12(a, ret0);
 5107|  1.24M|  libcrux_secrets_int_public_integers_declassify_d8_d2(ret0, ret);
 5108|  1.24M|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_vector_portable_serialize_serialize_12:
 5051|  1.24M|    uint8_t ret[24U]) {
 5052|  1.24M|  uint8_t_x3 r0_2 = libcrux_ml_kem_vector_portable_serialize_serialize_12_int(
 5053|  1.24M|      Eurydice_array_to_subslice3(v.elements, (size_t)0U, (size_t)2U,
  ------------------
  |  |  215|  1.24M|  EURYDICE_SLICE((t_ptr)x, (start), (end))
  |  |  ------------------
  |  |  |  |  169|  1.24M|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|  1.24M|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5054|  1.24M|                                  int16_t *));
 5055|  1.24M|  uint8_t_x3 r3_5 = libcrux_ml_kem_vector_portable_serialize_serialize_12_int(
 5056|  1.24M|      Eurydice_array_to_subslice3(v.elements, (size_t)2U, (size_t)4U,
  ------------------
  |  |  215|  1.24M|  EURYDICE_SLICE((t_ptr)x, (start), (end))
  |  |  ------------------
  |  |  |  |  169|  1.24M|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|  1.24M|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5057|  1.24M|                                  int16_t *));
 5058|  1.24M|  uint8_t_x3 r6_8 = libcrux_ml_kem_vector_portable_serialize_serialize_12_int(
 5059|  1.24M|      Eurydice_array_to_subslice3(v.elements, (size_t)4U, (size_t)6U,
  ------------------
  |  |  215|  1.24M|  EURYDICE_SLICE((t_ptr)x, (start), (end))
  |  |  ------------------
  |  |  |  |  169|  1.24M|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|  1.24M|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5060|  1.24M|                                  int16_t *));
 5061|  1.24M|  uint8_t_x3 r9_11 = libcrux_ml_kem_vector_portable_serialize_serialize_12_int(
 5062|  1.24M|      Eurydice_array_to_subslice3(v.elements, (size_t)6U, (size_t)8U,
  ------------------
  |  |  215|  1.24M|  EURYDICE_SLICE((t_ptr)x, (start), (end))
  |  |  ------------------
  |  |  |  |  169|  1.24M|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|  1.24M|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5063|  1.24M|                                  int16_t *));
 5064|  1.24M|  uint8_t_x3 r12_14 = libcrux_ml_kem_vector_portable_serialize_serialize_12_int(
 5065|  1.24M|      Eurydice_array_to_subslice3(v.elements, (size_t)8U, (size_t)10U,
  ------------------
  |  |  215|  1.24M|  EURYDICE_SLICE((t_ptr)x, (start), (end))
  |  |  ------------------
  |  |  |  |  169|  1.24M|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|  1.24M|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5066|  1.24M|                                  int16_t *));
 5067|  1.24M|  uint8_t_x3 r15_17 = libcrux_ml_kem_vector_portable_serialize_serialize_12_int(
 5068|  1.24M|      Eurydice_array_to_subslice3(v.elements, (size_t)10U, (size_t)12U,
  ------------------
  |  |  215|  1.24M|  EURYDICE_SLICE((t_ptr)x, (start), (end))
  |  |  ------------------
  |  |  |  |  169|  1.24M|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|  1.24M|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5069|  1.24M|                                  int16_t *));
 5070|  1.24M|  uint8_t_x3 r18_20 = libcrux_ml_kem_vector_portable_serialize_serialize_12_int(
 5071|  1.24M|      Eurydice_array_to_subslice3(v.elements, (size_t)12U, (size_t)14U,
  ------------------
  |  |  215|  1.24M|  EURYDICE_SLICE((t_ptr)x, (start), (end))
  |  |  ------------------
  |  |  |  |  169|  1.24M|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|  1.24M|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5072|  1.24M|                                  int16_t *));
 5073|  1.24M|  uint8_t_x3 r21_23 = libcrux_ml_kem_vector_portable_serialize_serialize_12_int(
 5074|  1.24M|      Eurydice_array_to_subslice3(v.elements, (size_t)14U, (size_t)16U,
  ------------------
  |  |  215|  1.24M|  EURYDICE_SLICE((t_ptr)x, (start), (end))
  |  |  ------------------
  |  |  |  |  169|  1.24M|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|  1.24M|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5075|  1.24M|                                  int16_t *));
 5076|  1.24M|  ret[0U] = r0_2.fst;
 5077|  1.24M|  ret[1U] = r0_2.snd;
 5078|  1.24M|  ret[2U] = r0_2.thd;
 5079|  1.24M|  ret[3U] = r3_5.fst;
 5080|  1.24M|  ret[4U] = r3_5.snd;
 5081|  1.24M|  ret[5U] = r3_5.thd;
 5082|  1.24M|  ret[6U] = r6_8.fst;
 5083|  1.24M|  ret[7U] = r6_8.snd;
 5084|  1.24M|  ret[8U] = r6_8.thd;
 5085|  1.24M|  ret[9U] = r9_11.fst;
 5086|  1.24M|  ret[10U] = r9_11.snd;
 5087|  1.24M|  ret[11U] = r9_11.thd;
 5088|  1.24M|  ret[12U] = r12_14.fst;
 5089|  1.24M|  ret[13U] = r12_14.snd;
 5090|  1.24M|  ret[14U] = r12_14.thd;
 5091|  1.24M|  ret[15U] = r15_17.fst;
 5092|  1.24M|  ret[16U] = r15_17.snd;
 5093|  1.24M|  ret[17U] = r15_17.thd;
 5094|  1.24M|  ret[18U] = r18_20.fst;
 5095|  1.24M|  ret[19U] = r18_20.snd;
 5096|  1.24M|  ret[20U] = r18_20.thd;
 5097|  1.24M|  ret[21U] = r21_23.fst;
 5098|  1.24M|  ret[22U] = r21_23.snd;
 5099|  1.24M|  ret[23U] = r21_23.thd;
 5100|  1.24M|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_vector_portable_serialize_serialize_12_int:
 5035|  9.95M|libcrux_ml_kem_vector_portable_serialize_serialize_12_int(Eurydice_slice v) {
 5036|  9.95M|  uint8_t r0 = libcrux_secrets_int_as_u8_f5(
 5037|  9.95M|      Eurydice_slice_index(v, (size_t)0U, int16_t, int16_t *) & (int16_t)255);
  ------------------
  |  |  180|  9.95M|#define Eurydice_slice_index(s, i, t, t_ptr_t) (((t_ptr_t)s.ptr)[i])
  ------------------
 5038|  9.95M|  uint8_t r1 = libcrux_secrets_int_as_u8_f5(
 5039|  9.95M|      Eurydice_slice_index(v, (size_t)0U, int16_t, int16_t *) >> 8U |
  ------------------
  |  |  180|  9.95M|#define Eurydice_slice_index(s, i, t, t_ptr_t) (((t_ptr_t)s.ptr)[i])
  ------------------
 5040|  9.95M|      (Eurydice_slice_index(v, (size_t)1U, int16_t, int16_t *) & (int16_t)15)
  ------------------
  |  |  180|  9.95M|#define Eurydice_slice_index(s, i, t, t_ptr_t) (((t_ptr_t)s.ptr)[i])
  ------------------
 5041|  9.95M|          << 4U);
 5042|  9.95M|  uint8_t r2 = libcrux_secrets_int_as_u8_f5(
 5043|  9.95M|      Eurydice_slice_index(v, (size_t)1U, int16_t, int16_t *) >> 4U &
  ------------------
  |  |  180|  9.95M|#define Eurydice_slice_index(s, i, t, t_ptr_t) (((t_ptr_t)s.ptr)[i])
  ------------------
 5044|  9.95M|      (int16_t)255);
 5045|  9.95M|  return (KRML_CLITERAL(uint8_t_x3){.fst = r0, .snd = r1, .thd = r2});
  ------------------
  |  |  154|  9.95M|#define KRML_CLITERAL(type) (type)
  ------------------
 5046|  9.95M|}
libcrux_mlkem768_sha3.c:libcrux_secrets_int_public_integers_declassify_d8_d2:
 1020|  1.24M|                                                     uint8_t ret[24U]) {
 1021|  1.24M|  memcpy(ret, self, (size_t)24U * sizeof(uint8_t));
 1022|  1.24M|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_ind_cca_serialize_kem_secret_key_d6:
 8677|  8.64k|    Eurydice_slice implicit_rejection_value, uint8_t ret[2400U]) {
 8678|  8.64k|  uint8_t out[2400U] = {0U};
 8679|  8.64k|  libcrux_ml_kem_ind_cca_serialize_kem_secret_key_mut_d6(
 8680|  8.64k|      private_key, public_key, implicit_rejection_value, out);
 8681|  8.64k|  memcpy(ret, out, (size_t)2400U * sizeof(uint8_t));
 8682|  8.64k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_ind_cca_serialize_kem_secret_key_mut_d6:
 8629|  8.64k|    Eurydice_slice implicit_rejection_value, uint8_t *serialized) {
 8630|  8.64k|  size_t pointer = (size_t)0U;
 8631|  8.64k|  uint8_t *uu____0 = serialized;
 8632|  8.64k|  size_t uu____1 = pointer;
 8633|  8.64k|  size_t uu____2 = pointer;
 8634|  8.64k|  Eurydice_slice_copy(
  ------------------
  |  |  229|  8.64k|  memcpy(dst.ptr, src.ptr, dst.len * sizeof(t))
  ------------------
 8635|  8.64k|      Eurydice_array_to_subslice3(
 8636|  8.64k|          uu____0, uu____1, uu____2 + Eurydice_slice_len(private_key, uint8_t),
 8637|  8.64k|          uint8_t *),
 8638|  8.64k|      private_key, uint8_t);
 8639|  8.64k|  pointer = pointer + Eurydice_slice_len(private_key, uint8_t);
  ------------------
  |  |  173|  8.64k|#define Eurydice_slice_len(s, _) (s).len
  ------------------
 8640|  8.64k|  uint8_t *uu____3 = serialized;
 8641|  8.64k|  size_t uu____4 = pointer;
 8642|  8.64k|  size_t uu____5 = pointer;
 8643|  8.64k|  Eurydice_slice_copy(
  ------------------
  |  |  229|  8.64k|  memcpy(dst.ptr, src.ptr, dst.len * sizeof(t))
  ------------------
 8644|  8.64k|      Eurydice_array_to_subslice3(
 8645|  8.64k|          uu____3, uu____4, uu____5 + Eurydice_slice_len(public_key, uint8_t),
 8646|  8.64k|          uint8_t *),
 8647|  8.64k|      public_key, uint8_t);
 8648|  8.64k|  pointer = pointer + Eurydice_slice_len(public_key, uint8_t);
  ------------------
  |  |  173|  8.64k|#define Eurydice_slice_len(s, _) (s).len
  ------------------
 8649|  8.64k|  Eurydice_slice uu____6 = Eurydice_array_to_subslice3(
  ------------------
  |  |  215|  8.64k|  EURYDICE_SLICE((t_ptr)x, (start), (end))
  |  |  ------------------
  |  |  |  |  169|  8.64k|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|  8.64k|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 8650|  8.64k|      serialized, pointer, pointer + LIBCRUX_ML_KEM_CONSTANTS_H_DIGEST_SIZE,
 8651|  8.64k|      uint8_t *);
 8652|  8.64k|  uint8_t ret[32U];
 8653|  8.64k|  libcrux_ml_kem_hash_functions_portable_H_4a_e0(public_key, ret);
 8654|  8.64k|  Eurydice_slice_copy(
  ------------------
  |  |  229|  8.64k|  memcpy(dst.ptr, src.ptr, dst.len * sizeof(t))
  ------------------
 8655|  8.64k|      uu____6, Eurydice_array_to_slice((size_t)32U, ret, uint8_t), uint8_t);
 8656|  8.64k|  pointer = pointer + LIBCRUX_ML_KEM_CONSTANTS_H_DIGEST_SIZE;
  ------------------
  |  |  459|  8.64k|#define LIBCRUX_ML_KEM_CONSTANTS_H_DIGEST_SIZE ((size_t)32U)
  ------------------
 8657|  8.64k|  uint8_t *uu____7 = serialized;
 8658|  8.64k|  size_t uu____8 = pointer;
 8659|  8.64k|  size_t uu____9 = pointer;
 8660|  8.64k|  Eurydice_slice_copy(
  ------------------
  |  |  229|  8.64k|  memcpy(dst.ptr, src.ptr, dst.len * sizeof(t))
  ------------------
 8661|  8.64k|      Eurydice_array_to_subslice3(
 8662|  8.64k|          uu____7, uu____8,
 8663|  8.64k|          uu____9 + Eurydice_slice_len(implicit_rejection_value, uint8_t),
 8664|  8.64k|          uint8_t *),
 8665|  8.64k|      implicit_rejection_value, uint8_t);
 8666|  8.64k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_types_from_77_28:
  772|  8.64k|libcrux_ml_kem_types_from_77_28(uint8_t value[2400U]) {
  773|       |  /* Passing arrays by value in Rust generates a copy in C */
  774|  8.64k|  uint8_t copy_of_value[2400U];
  775|  8.64k|  memcpy(copy_of_value, value, (size_t)2400U * sizeof(uint8_t));
  776|  8.64k|  libcrux_ml_kem_types_MlKemPrivateKey_d9 lit;
  777|  8.64k|  memcpy(lit.value, copy_of_value, (size_t)2400U * sizeof(uint8_t));
  778|  8.64k|  return lit;
  779|  8.64k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_types_from_17_74:
  757|  8.64k|                                libcrux_ml_kem_types_MlKemPublicKey_30 pk) {
  758|  8.64k|  return (KRML_CLITERAL(libcrux_ml_kem_mlkem768_MlKem768KeyPair){.sk = sk,
  ------------------
  |  |  154|  8.64k|#define KRML_CLITERAL(type) (type)
  ------------------
  759|  8.64k|                                                                 .pk = pk});
  760|  8.64k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_types_from_fd_d0:
  736|  8.64k|libcrux_ml_kem_types_from_fd_d0(uint8_t value[1184U]) {
  737|       |  /* Passing arrays by value in Rust generates a copy in C */
  738|  8.64k|  uint8_t copy_of_value[1184U];
  739|  8.64k|  memcpy(copy_of_value, value, (size_t)1184U * sizeof(uint8_t));
  740|  8.64k|  libcrux_ml_kem_types_MlKemPublicKey_30 lit;
  741|  8.64k|  memcpy(lit.value, copy_of_value, (size_t)1184U * sizeof(uint8_t));
  742|  8.64k|  return lit;
  743|  8.64k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_ind_cca_instantiations_portable_validate_public_key_41:
 8866|  8.64k|    uint8_t *public_key) {
 8867|  8.64k|  return libcrux_ml_kem_ind_cca_validate_public_key_89(public_key);
 8868|  8.64k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_ind_cca_validate_public_key_89:
 8833|  8.64k|    uint8_t *public_key) {
 8834|  8.64k|  libcrux_ml_kem_polynomial_PolynomialRingElement_1d deserialized_pk[3U];
 8835|  8.64k|  libcrux_ml_kem_serialize_deserialize_ring_elements_reduced_out_1b(
 8836|  8.64k|      Eurydice_array_to_subslice_to(
  ------------------
  |  |  223|  8.64k|  EURYDICE_SLICE((t *)x, 0, r)
  |  |  ------------------
  |  |  |  |  169|  8.64k|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|  8.64k|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 8837|  8.64k|          (size_t)1184U, public_key,
 8838|  8.64k|          libcrux_ml_kem_constants_ranked_bytes_per_ring_element((size_t)3U),
 8839|  8.64k|          uint8_t, size_t, uint8_t[]),
 8840|  8.64k|      deserialized_pk);
 8841|  8.64k|  libcrux_ml_kem_polynomial_PolynomialRingElement_1d *uu____0 = deserialized_pk;
 8842|  8.64k|  uint8_t public_key_serialized[1184U];
 8843|  8.64k|  libcrux_ml_kem_ind_cpa_serialize_public_key_89(
 8844|  8.64k|      uu____0,
 8845|  8.64k|      Eurydice_array_to_subslice_from(
  ------------------
  |  |  225|  8.64k|  EURYDICE_SLICE((t *)x, r, size)
  |  |  ------------------
  |  |  |  |  169|  8.64k|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|  8.64k|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 8846|  8.64k|          (size_t)1184U, public_key,
 8847|  8.64k|          libcrux_ml_kem_constants_ranked_bytes_per_ring_element((size_t)3U),
 8848|  8.64k|          uint8_t, size_t, uint8_t[]),
 8849|  8.64k|      public_key_serialized);
 8850|  8.64k|  return Eurydice_array_eq((size_t)1184U, public_key, public_key_serialized,
  ------------------
  |  |  240|  8.64k|#define Eurydice_array_eq(sz, a1, a2, t) (memcmp(a1, a2, sz * sizeof(t)) == 0)
  ------------------
 8851|  8.64k|                           uint8_t);
 8852|  8.64k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_serialize_deserialize_ring_elements_reduced_out_1b:
 8802|  8.64k|    libcrux_ml_kem_polynomial_PolynomialRingElement_1d ret[3U]) {
 8803|  8.64k|  libcrux_ml_kem_polynomial_PolynomialRingElement_1d deserialized_pk[3U];
 8804|  34.5k|  for (size_t i = (size_t)0U; i < (size_t)3U; i++) {
  ------------------
  |  Branch (8804:31): [True: 25.9k, False: 8.64k]
  ------------------
 8805|       |    /* original Rust expression is not an lvalue in C */
 8806|  25.9k|    void *lvalue = (void *)0U;
 8807|  25.9k|    deserialized_pk[i] =
 8808|  25.9k|        libcrux_ml_kem_serialize_deserialize_ring_elements_reduced_out_call_mut_0b_1b(
 8809|  25.9k|            &lvalue, i);
 8810|  25.9k|  }
 8811|  8.64k|  libcrux_ml_kem_serialize_deserialize_ring_elements_reduced_1b(
 8812|  8.64k|      public_key, deserialized_pk);
 8813|  8.64k|  memcpy(
 8814|  8.64k|      ret, deserialized_pk,
 8815|  8.64k|      (size_t)3U * sizeof(libcrux_ml_kem_polynomial_PolynomialRingElement_1d));
 8816|  8.64k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_serialize_deserialize_ring_elements_reduced_out_call_mut_0b_1b:
 8783|  25.9k|    void **_, size_t tupled_args) {
 8784|  25.9k|  return libcrux_ml_kem_polynomial_ZERO_d6_ea();
 8785|  25.9k|}

ssh_get_random:
   48|   192k|{
   49|       |#ifdef HAVE_OPENSSL_RAND_PRIV_BYTES
   50|       |    if (strong) {
   51|       |        /* Returns -1 when not supported, 0 on error, 1 on success */
   52|       |        return !!RAND_priv_bytes(where, len);
   53|       |    }
   54|       |#else
   55|   192k|    (void)strong;
   56|   192k|#endif /* HAVE_RAND_PRIV_BYTES */
   57|       |
   58|       |    /* Returns -1 when not supported, 0 on error, 1 on success */
   59|   192k|    return !!RAND_bytes(where, len);
   60|   192k|}

compress_cleanup:
  268|  51.8k|{
  269|  51.8k|    if (crypto->compress_out_ctx) {
  ------------------
  |  Branch (269:9): [True: 0, False: 51.8k]
  ------------------
  270|      0|        deflateEnd(crypto->compress_out_ctx);
  271|      0|    }
  272|  51.8k|    SAFE_FREE(crypto->compress_out_ctx);
  ------------------
  |  |  373|  51.8k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 51.8k]
  |  |  |  Branch (373:71): [Folded, False: 51.8k]
  |  |  ------------------
  ------------------
  273|       |
  274|  51.8k|    if (crypto->compress_in_ctx) {
  ------------------
  |  Branch (274:9): [True: 0, False: 51.8k]
  ------------------
  275|      0|        inflateEnd(crypto->compress_in_ctx);
  276|      0|    }
  277|       |    SAFE_FREE(crypto->compress_in_ctx);
  ------------------
  |  |  373|  51.8k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 51.8k]
  |  |  |  Branch (373:71): [Folded, False: 51.8k]
  |  |  ------------------
  ------------------
  278|  51.8k|}

ssh_client_hybrid_mlkem_init:
  201|  8.64k|{
  202|  8.64k|    struct ssh_crypto_struct *crypto = session->next_crypto;
  203|  8.64k|    ssh_buffer client_init_buffer = NULL;
  204|  8.64k|    int rc, ret = SSH_ERROR;
  ------------------
  |  |  317|  8.64k|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  205|       |
  206|  8.64k|    SSH_LOG(SSH_LOG_TRACE, "Initializing hybrid ML-KEM key exchange");
  ------------------
  |  |  281|  8.64k|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  207|       |
  208|       |    /* Prepare a buffer to concatenate ML-KEM + ECDH public keys */
  209|  8.64k|    client_init_buffer = ssh_buffer_new();
  210|  8.64k|    if (client_init_buffer == NULL) {
  ------------------
  |  Branch (210:9): [True: 0, False: 8.64k]
  ------------------
  211|      0|        ssh_set_error_oom(session);
  ------------------
  |  |  318|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
  212|      0|        goto cleanup;
  213|      0|    }
  214|       |
  215|       |    /* Generate an ML-KEM keypair */
  216|  8.64k|    rc = ssh_mlkem_init(session);
  217|  8.64k|    if (rc != SSH_OK) {
  ------------------
  |  |  316|  8.64k|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (217:9): [True: 0, False: 8.64k]
  ------------------
  218|      0|        ssh_set_error(session, SSH_FATAL, "Failed to generate an ML-KEM keypair");
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  219|      0|        goto cleanup;
  220|      0|    }
  221|       |
  222|       |#ifdef DEBUG_CRYPTO
  223|       |    ssh_log_hexdump("ML-KEM client pubkey",
  224|       |                    ssh_string_data(crypto->mlkem_client_pubkey),
  225|       |                    ssh_string_len(crypto->mlkem_client_pubkey));
  226|       |#endif
  227|       |
  228|       |    /* Generate an ECDH keypair and concatenate the public keys  */
  229|  8.64k|    switch (crypto->kex_type) {
  230|  8.64k|    case SSH_KEX_MLKEM768X25519_SHA256:
  ------------------
  |  Branch (230:5): [True: 8.64k, False: 0]
  ------------------
  231|  8.64k|        rc = ssh_curve25519_init(session);
  232|  8.64k|        if (rc != SSH_OK) {
  ------------------
  |  |  316|  8.64k|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (232:13): [True: 0, False: 8.64k]
  ------------------
  233|      0|            ssh_set_error(session,
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  234|      0|                          SSH_FATAL,
  235|      0|                          "Failed to generate a Curve25519 ECDH keypair");
  236|      0|            goto cleanup;
  237|      0|        }
  238|       |#ifdef DEBUG_CRYPTO
  239|       |        ssh_log_hexdump("Curve25519 client pubkey",
  240|       |                        crypto->curve25519_client_pubkey,
  241|       |                        CURVE25519_PUBKEY_SIZE);
  242|       |#endif
  243|  8.64k|        rc = ssh_buffer_pack(client_init_buffer,
  ------------------
  |  |   50|  8.64k|    _ssh_buffer_pack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |  451|  8.64k|        (__VA_NARG_(__VA_ARGS__, __RSEQ_N()))
  |  |  |  |  ------------------
  |  |  |  |  |  |  453|  8.64k|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  448|  8.64k|#define VA_APPLY_VARIADIC_MACRO(macro, tuple) macro tuple
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  453|  8.64k|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  461|  8.64k|        _61,_62,_63,N,...) N
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                   _ssh_buffer_pack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |   28|  8.64k|#define SSH_BUFFER_PACK_END ((uint32_t) 0x4f65feb3)
  |  |  ------------------
  ------------------
  244|  8.64k|                             "PP",
  245|  8.64k|                             ssh_string_len(crypto->mlkem_client_pubkey),
  246|  8.64k|                             ssh_string_data(crypto->mlkem_client_pubkey),
  247|  8.64k|                             (size_t)CURVE25519_PUBKEY_SIZE,
  248|  8.64k|                             crypto->curve25519_client_pubkey);
  249|  8.64k|        break;
  250|      0|    case SSH_KEX_MLKEM768NISTP256_SHA256:
  ------------------
  |  Branch (250:5): [True: 0, False: 8.64k]
  ------------------
  251|       |#ifdef HAVE_MLKEM1024
  252|       |    case SSH_KEX_MLKEM1024NISTP384_SHA384:
  253|       |#endif
  254|      0|        rc = ssh_ecdh_init(session);
  255|      0|        if (rc != SSH_OK) {
  ------------------
  |  |  316|      0|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (255:13): [True: 0, False: 0]
  ------------------
  256|      0|            ssh_set_error(session,
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  257|      0|                          SSH_FATAL,
  258|      0|                          "Failed to generate a NIST-curve ECDH keypair");
  259|      0|            goto cleanup;
  260|      0|        }
  261|       |#ifdef DEBUG_CRYPTO
  262|       |        ssh_log_hexdump("ECDH client pubkey",
  263|       |                        ssh_string_data(crypto->ecdh_client_pubkey),
  264|       |                        ssh_string_len(crypto->ecdh_client_pubkey));
  265|       |#endif
  266|      0|        rc = ssh_buffer_pack(client_init_buffer,
  ------------------
  |  |   50|      0|    _ssh_buffer_pack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |  451|      0|        (__VA_NARG_(__VA_ARGS__, __RSEQ_N()))
  |  |  |  |  ------------------
  |  |  |  |  |  |  453|      0|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  448|      0|#define VA_APPLY_VARIADIC_MACRO(macro, tuple) macro tuple
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  453|      0|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  461|      0|        _61,_62,_63,N,...) N
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                   _ssh_buffer_pack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |   28|      0|#define SSH_BUFFER_PACK_END ((uint32_t) 0x4f65feb3)
  |  |  ------------------
  ------------------
  267|      0|                             "PP",
  268|      0|                             ssh_string_len(crypto->mlkem_client_pubkey),
  269|      0|                             ssh_string_data(crypto->mlkem_client_pubkey),
  270|      0|                             ssh_string_len(crypto->ecdh_client_pubkey),
  271|      0|                             ssh_string_data(crypto->ecdh_client_pubkey));
  272|       |
  273|      0|        break;
  274|      0|    default:
  ------------------
  |  Branch (274:5): [True: 0, False: 8.64k]
  ------------------
  275|      0|        ssh_set_error(session, SSH_FATAL, "Unsupported KEX type");
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  276|      0|        goto cleanup;
  277|  8.64k|    }
  278|  8.64k|    if (rc != SSH_OK) {
  ------------------
  |  |  316|  8.64k|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (278:9): [True: 0, False: 8.64k]
  ------------------
  279|      0|        ssh_set_error(session, SSH_FATAL, "Failed to construct client init buffer");
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  280|      0|        goto cleanup;
  281|      0|    }
  282|       |
  283|       |    /* Convert the client init buffer to an SSH string */
  284|  8.64k|    ssh_string_free(crypto->hybrid_client_init);
  285|  8.64k|    crypto->hybrid_client_init = ssh_string_new(ssh_buffer_get_len(client_init_buffer));
  286|  8.64k|    if (crypto->hybrid_client_init == NULL) {
  ------------------
  |  Branch (286:9): [True: 0, False: 8.64k]
  ------------------
  287|      0|        ssh_set_error_oom(session);
  ------------------
  |  |  318|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
  288|      0|        goto cleanup;
  289|      0|    }
  290|       |
  291|  8.64k|    rc = ssh_string_fill(crypto->hybrid_client_init,
  292|  8.64k|                         ssh_buffer_get(client_init_buffer),
  293|  8.64k|                         ssh_buffer_get_len(client_init_buffer));
  294|  8.64k|    if (rc != SSH_OK) {
  ------------------
  |  |  316|  8.64k|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (294:9): [True: 0, False: 8.64k]
  ------------------
  295|      0|        ssh_set_error(session, SSH_FATAL, "Failed to convert client init to string");
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  296|      0|        goto cleanup;
  297|      0|    }
  298|       |
  299|  8.64k|    rc = ssh_buffer_pack(session->out_buffer,
  ------------------
  |  |   50|  8.64k|    _ssh_buffer_pack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |  451|  8.64k|        (__VA_NARG_(__VA_ARGS__, __RSEQ_N()))
  |  |  |  |  ------------------
  |  |  |  |  |  |  453|  8.64k|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  448|  8.64k|#define VA_APPLY_VARIADIC_MACRO(macro, tuple) macro tuple
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  453|  8.64k|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  461|  8.64k|        _61,_62,_63,N,...) N
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                   _ssh_buffer_pack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |   28|  8.64k|#define SSH_BUFFER_PACK_END ((uint32_t) 0x4f65feb3)
  |  |  ------------------
  ------------------
  300|  8.64k|                         "bS",
  301|  8.64k|                         SSH2_MSG_KEX_HYBRID_INIT,
  302|  8.64k|                         crypto->hybrid_client_init);
  303|  8.64k|    if (rc != SSH_OK) {
  ------------------
  |  |  316|  8.64k|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (303:9): [True: 0, False: 8.64k]
  ------------------
  304|      0|        ssh_set_error(session, SSH_FATAL, "Failed to construct SSH_MSG_KEX_HYBRID_INIT");
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  305|      0|        goto cleanup;
  306|      0|    }
  307|       |
  308|  8.64k|    ssh_packet_set_callbacks(session, &ssh_hybrid_mlkem_client_callbacks);
  309|  8.64k|    session->dh_handshake_state = DH_STATE_INIT_SENT;
  310|       |
  311|  8.64k|    rc = ssh_packet_send(session);
  312|  8.64k|    if (rc != SSH_OK) {
  ------------------
  |  |  316|  8.64k|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (312:9): [True: 0, False: 8.64k]
  ------------------
  313|      0|        ssh_set_error(session, SSH_FATAL, "Failed to send SSH_MSG_KEX_HYBRID_INIT");
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  314|      0|        goto cleanup;
  315|      0|    }
  316|       |
  317|  8.64k|    ret = SSH_OK;
  ------------------
  |  |  316|  8.64k|#define SSH_OK 0     /* No error */
  ------------------
  318|       |
  319|  8.64k|cleanup:
  320|  8.64k|    ssh_buffer_free(client_init_buffer);
  321|  8.64k|    return ret;
  322|  8.64k|}
ssh_client_hybrid_mlkem_remove_callbacks:
  531|  8.64k|{
  532|  8.64k|    ssh_packet_remove_callbacks(session, &ssh_hybrid_mlkem_client_callbacks);
  533|  8.64k|}
ssh_server_hybrid_mlkem_init:
  905|  8.64k|{
  906|  8.64k|    SSH_LOG(SSH_LOG_TRACE, "Setting up ML-KEM hybrid server callbacks");
  ------------------
  |  |  281|  8.64k|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  907|  8.64k|    ssh_packet_set_callbacks(session, &ssh_hybrid_mlkem_server_callbacks);
  908|  8.64k|}
hybrid_mlkem.c:ssh_packet_client_hybrid_mlkem_reply:
  325|  8.64k|{
  326|  8.64k|    struct ssh_crypto_struct *crypto = session->next_crypto;
  327|  8.64k|    const struct mlkem_type_info *mlkem_info = NULL;
  328|  8.64k|    ssh_string pubkey_blob = NULL;
  329|  8.64k|    ssh_string signature = NULL;
  330|  8.64k|    ssh_mlkem_shared_secret mlkem_shared_secret;
  331|  8.64k|    ssh_string ecdh_shared_secret = NULL;
  332|  8.64k|    ssh_buffer server_reply_buffer = NULL;
  333|  8.64k|    size_t read_len;
  334|  8.64k|    size_t ecdh_server_pubkey_size;
  335|  8.64k|    int rc;
  336|  8.64k|    (void)type;
  337|  8.64k|    (void)user;
  338|       |
  339|  8.64k|    SSH_LOG(SSH_LOG_TRACE, "Received ML-KEM hybrid server reply");
  ------------------
  |  |  281|  8.64k|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  340|       |
  341|  8.64k|    ssh_client_hybrid_mlkem_remove_callbacks(session);
  342|       |
  343|  8.64k|    mlkem_info = kex_type_to_mlkem_info(crypto->kex_type);
  344|  8.64k|    if (mlkem_info == NULL) {
  ------------------
  |  Branch (344:9): [True: 0, False: 8.64k]
  ------------------
  345|      0|        ssh_set_error(session, SSH_FATAL, "Unknown ML-KEM type");
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  346|      0|        session->session_state = SSH_SESSION_STATE_ERROR;
  347|      0|        goto cleanup;
  348|      0|    }
  349|       |
  350|  8.64k|    pubkey_blob = ssh_buffer_get_ssh_string(packet);
  351|  8.64k|    if (pubkey_blob == NULL) {
  ------------------
  |  Branch (351:9): [True: 0, False: 8.64k]
  ------------------
  352|      0|        ssh_set_error(session, SSH_FATAL, "No public key in packet");
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  353|      0|        session->session_state = SSH_SESSION_STATE_ERROR;
  354|      0|        goto cleanup;
  355|      0|    }
  356|       |
  357|  8.64k|    rc = ssh_dh_import_next_pubkey_blob(session, pubkey_blob);
  358|  8.64k|    if (rc != SSH_OK) {
  ------------------
  |  |  316|  8.64k|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (358:9): [True: 0, False: 8.64k]
  ------------------
  359|      0|        ssh_set_error(session, SSH_FATAL, "Failed to import public key");
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  360|      0|        session->session_state = SSH_SESSION_STATE_ERROR;
  361|      0|        goto cleanup;
  362|      0|    }
  363|       |
  364|       |    /* Get server reply containing ML-KEM ciphertext + ECDH public key */
  365|  8.64k|    ssh_string_free(crypto->hybrid_server_reply);
  366|  8.64k|    crypto->hybrid_server_reply = ssh_buffer_get_ssh_string(packet);
  367|  8.64k|    if (crypto->hybrid_server_reply == NULL) {
  ------------------
  |  Branch (367:9): [True: 0, False: 8.64k]
  ------------------
  368|      0|        ssh_set_error(session, SSH_FATAL, "No server reply in packet");
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  369|      0|        session->session_state = SSH_SESSION_STATE_ERROR;
  370|      0|        goto cleanup;
  371|      0|    }
  372|       |
  373|  8.64k|    server_reply_buffer = ssh_buffer_new();
  374|  8.64k|    if (server_reply_buffer == NULL) {
  ------------------
  |  Branch (374:9): [True: 0, False: 8.64k]
  ------------------
  375|      0|        ssh_set_error_oom(session);
  ------------------
  |  |  318|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
  376|      0|        session->session_state = SSH_SESSION_STATE_ERROR;
  377|      0|        goto cleanup;
  378|      0|    }
  379|       |
  380|  8.64k|    rc = ssh_buffer_add_data(server_reply_buffer,
  381|  8.64k|                             ssh_string_data(crypto->hybrid_server_reply),
  382|  8.64k|                             ssh_string_len(crypto->hybrid_server_reply));
  383|  8.64k|    if (rc != SSH_OK) {
  ------------------
  |  |  316|  8.64k|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (383:9): [True: 0, False: 8.64k]
  ------------------
  384|      0|        ssh_set_error(session, SSH_FATAL, "Failed to pack server reply to a buffer");
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  385|      0|        session->session_state = SSH_SESSION_STATE_ERROR;
  386|      0|        goto cleanup;
  387|      0|    }
  388|       |
  389|       |    /* Store ML-KEM ciphertext for decapsulation and sessionid calculation */
  390|  8.64k|    ssh_string_free(crypto->mlkem_ciphertext);
  391|  8.64k|    crypto->mlkem_ciphertext = ssh_string_new(mlkem_info->ciphertext_size);
  392|  8.64k|    if (crypto->mlkem_ciphertext == NULL) {
  ------------------
  |  Branch (392:9): [True: 0, False: 8.64k]
  ------------------
  393|      0|        ssh_set_error_oom(session);
  ------------------
  |  |  318|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
  394|      0|        session->session_state = SSH_SESSION_STATE_ERROR;
  395|      0|        goto cleanup;
  396|      0|    }
  397|       |
  398|  8.64k|    read_len = ssh_buffer_get_data(server_reply_buffer,
  399|  8.64k|                                   ssh_string_data(crypto->mlkem_ciphertext),
  400|  8.64k|                                   mlkem_info->ciphertext_size);
  401|  8.64k|    if (read_len != mlkem_info->ciphertext_size) {
  ------------------
  |  Branch (401:9): [True: 0, False: 8.64k]
  ------------------
  402|      0|        ssh_set_error(session,
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  403|      0|                      SSH_FATAL,
  404|      0|                      "Could not read ML-KEM ciphertext from "
  405|      0|                      "the server reply buffer, buffer too short");
  406|      0|        session->session_state = SSH_SESSION_STATE_ERROR;
  407|      0|        goto cleanup;
  408|      0|    }
  409|       |
  410|       |#ifdef DEBUG_CRYPTO
  411|       |    ssh_log_hexdump("ML-KEM ciphertext",
  412|       |                    ssh_string_data(crypto->mlkem_ciphertext),
  413|       |                    ssh_string_len(crypto->mlkem_ciphertext));
  414|       |#endif
  415|       |
  416|       |    /* Extract server ECDH public key */
  417|  8.64k|    switch (crypto->kex_type) {
  418|  8.64k|    case SSH_KEX_MLKEM768X25519_SHA256:
  ------------------
  |  Branch (418:5): [True: 8.64k, False: 0]
  ------------------
  419|  8.64k|        read_len = ssh_buffer_get_data(server_reply_buffer,
  420|  8.64k|                                       crypto->curve25519_server_pubkey,
  421|  8.64k|                                       CURVE25519_PUBKEY_SIZE);
  ------------------
  |  |   40|  8.64k|#define CURVE25519_PUBKEY_SIZE 32
  ------------------
  422|  8.64k|        if (read_len != CURVE25519_PUBKEY_SIZE) {
  ------------------
  |  |   40|  8.64k|#define CURVE25519_PUBKEY_SIZE 32
  ------------------
  |  Branch (422:13): [True: 0, False: 8.64k]
  ------------------
  423|      0|            ssh_set_error(session,
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  424|      0|                          SSH_FATAL,
  425|      0|                          "Could not read Curve25519 pubkey from "
  426|      0|                          "the server reply buffer, buffer too short");
  427|      0|            session->session_state = SSH_SESSION_STATE_ERROR;
  428|      0|            goto cleanup;
  429|      0|        }
  430|  8.64k|        if (ssh_buffer_get_len(server_reply_buffer) > 0) {
  ------------------
  |  Branch (430:13): [True: 0, False: 8.64k]
  ------------------
  431|      0|            ssh_set_error(session,
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  432|      0|                          SSH_FATAL,
  433|      0|                          "Unrecognized data in the server reply buffer");
  434|      0|            session->session_state = SSH_SESSION_STATE_ERROR;
  435|      0|            goto cleanup;
  436|      0|        }
  437|       |#ifdef DEBUG_CRYPTO
  438|       |        ssh_log_hexdump("Curve25519 server pubkey",
  439|       |                        crypto->curve25519_server_pubkey,
  440|       |                        CURVE25519_PUBKEY_SIZE);
  441|       |#endif
  442|  8.64k|        break;
  443|  8.64k|    case SSH_KEX_MLKEM768NISTP256_SHA256:
  ------------------
  |  Branch (443:5): [True: 0, False: 8.64k]
  ------------------
  444|       |#ifdef HAVE_MLKEM1024
  445|       |    case SSH_KEX_MLKEM1024NISTP384_SHA384:
  446|       |#endif
  447|      0|        ecdh_server_pubkey_size = ssh_buffer_get_len(server_reply_buffer);
  448|      0|        ssh_string_free(crypto->ecdh_server_pubkey);
  449|      0|        crypto->ecdh_server_pubkey = ssh_string_new(ecdh_server_pubkey_size);
  450|      0|        if (crypto->ecdh_server_pubkey == NULL) {
  ------------------
  |  Branch (450:13): [True: 0, False: 0]
  ------------------
  451|      0|            ssh_set_error_oom(session);
  ------------------
  |  |  318|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
  452|      0|            session->session_state = SSH_SESSION_STATE_ERROR;
  453|      0|            goto cleanup;
  454|      0|        }
  455|      0|        ssh_buffer_get_data(server_reply_buffer,
  456|      0|                            ssh_string_data(crypto->ecdh_server_pubkey),
  457|      0|                            ecdh_server_pubkey_size);
  458|       |#ifdef DEBUG_CRYPTO
  459|       |        ssh_log_hexdump("ECDH server pubkey",
  460|       |                        ssh_string_data(crypto->ecdh_server_pubkey),
  461|       |                        ssh_string_len(crypto->ecdh_server_pubkey));
  462|       |#endif
  463|      0|        break;
  464|      0|    default:
  ------------------
  |  Branch (464:5): [True: 0, False: 8.64k]
  ------------------
  465|      0|        ssh_set_error(session, SSH_FATAL, "Unsupported KEX type");
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  466|      0|        goto cleanup;
  467|  8.64k|    }
  468|       |
  469|       |    /* Decapsulate ML-KEM shared secret */
  470|  8.64k|    rc = ssh_mlkem_decapsulate(session, mlkem_shared_secret);
  471|  8.64k|    if (rc != SSH_OK) {
  ------------------
  |  |  316|  8.64k|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (471:9): [True: 0, False: 8.64k]
  ------------------
  472|      0|        ssh_set_error(session, SSH_FATAL, "ML-KEM decapsulation failed");
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  473|      0|        session->session_state = SSH_SESSION_STATE_ERROR;
  474|      0|        goto cleanup;
  475|      0|    }
  476|       |
  477|       |#ifdef DEBUG_CRYPTO
  478|       |    ssh_log_hexdump("ML-KEM shared secret",
  479|       |                    mlkem_shared_secret,
  480|       |                    MLKEM_SHARED_SECRET_SIZE);
  481|       |#endif
  482|       |
  483|       |    /* Derive the classical ECDH shared secret */
  484|  8.64k|    ecdh_shared_secret = derive_ecdh_secret(session);
  485|  8.64k|    if (ecdh_shared_secret == NULL) {
  ------------------
  |  Branch (485:9): [True: 0, False: 8.64k]
  ------------------
  486|      0|        session->session_state = SSH_SESSION_STATE_ERROR;
  487|      0|        goto cleanup;
  488|      0|    }
  489|       |
  490|       |#ifdef DEBUG_CRYPTO
  491|       |    ssh_log_hexdump("ECDH shared secret",
  492|       |                    ssh_string_data(ecdh_shared_secret),
  493|       |                    ssh_string_len(ecdh_shared_secret));
  494|       |#endif
  495|       |
  496|       |    /* Derive the final shared secret */
  497|  8.64k|    rc = derive_hybrid_secret(session, mlkem_shared_secret, ecdh_shared_secret);
  498|  8.64k|    if (rc != SSH_OK) {
  ------------------
  |  |  316|  8.64k|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (498:9): [True: 0, False: 8.64k]
  ------------------
  499|      0|        session->session_state = SSH_SESSION_STATE_ERROR;
  500|      0|        goto cleanup;
  501|      0|    }
  502|       |
  503|       |    /* Get signature for verification */
  504|  8.64k|    signature = ssh_buffer_get_ssh_string(packet);
  505|  8.64k|    if (signature == NULL) {
  ------------------
  |  Branch (505:9): [True: 0, False: 8.64k]
  ------------------
  506|      0|        ssh_set_error(session, SSH_FATAL, "No signature in packet");
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  507|      0|        session->session_state = SSH_SESSION_STATE_ERROR;
  508|      0|        goto cleanup;
  509|      0|    }
  510|  8.64k|    crypto->dh_server_signature = signature;
  511|       |
  512|       |    /* Send the MSG_NEWKEYS */
  513|  8.64k|    rc = ssh_packet_send_newkeys(session);
  514|  8.64k|    if (rc != SSH_OK) {
  ------------------
  |  |  316|  8.64k|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (514:9): [True: 0, False: 8.64k]
  ------------------
  515|      0|        ssh_set_error(session, SSH_FATAL, "Failed to send SSH_MSG_NEWKEYS");
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  516|      0|        session->session_state = SSH_SESSION_STATE_ERROR;
  517|      0|        goto cleanup;
  518|      0|    }
  519|  8.64k|    session->dh_handshake_state = DH_STATE_NEWKEYS_SENT;
  520|       |
  521|  8.64k|cleanup:
  522|  8.64k|    ssh_burn(mlkem_shared_secret, sizeof(mlkem_shared_secret));
  ------------------
  |  |  388|  8.64k|#define ssh_burn(ptr, len) explicit_bzero((ptr), (len))
  ------------------
  523|  8.64k|    ssh_string_burn(ecdh_shared_secret);
  524|  8.64k|    ssh_string_free(ecdh_shared_secret);
  525|  8.64k|    ssh_string_free(pubkey_blob);
  526|  8.64k|    ssh_buffer_free(server_reply_buffer);
  527|  8.64k|    return SSH_PACKET_USED;
  ------------------
  |  |  637|  8.64k|#define SSH_PACKET_USED 1
  ------------------
  528|  8.64k|}
hybrid_mlkem.c:derive_ecdh_secret:
   95|  17.2k|{
   96|  17.2k|    ssh_string secret = NULL;
   97|       |
   98|  17.2k|    switch (session->next_crypto->kex_type) {
   99|  17.2k|    case SSH_KEX_MLKEM768X25519_SHA256:
  ------------------
  |  Branch (99:5): [True: 17.2k, False: 0]
  ------------------
  100|  17.2k|        secret = derive_curve25519_secret(session);
  101|  17.2k|        break;
  102|      0|    case SSH_KEX_MLKEM768NISTP256_SHA256:
  ------------------
  |  Branch (102:5): [True: 0, False: 17.2k]
  ------------------
  103|      0|        secret = derive_nist_curve_secret(session, NISTP256_SHARED_SECRET_SIZE);
  ------------------
  |  |   37|      0|#define NISTP256_SHARED_SECRET_SIZE 32
  ------------------
  104|      0|        break;
  105|       |#ifdef HAVE_MLKEM1024
  106|       |    case SSH_KEX_MLKEM1024NISTP384_SHA384:
  107|       |        secret = derive_nist_curve_secret(session, NISTP384_SHARED_SECRET_SIZE);
  108|       |        break;
  109|       |#endif
  110|      0|    default:
  ------------------
  |  Branch (110:5): [True: 0, False: 17.2k]
  ------------------
  111|      0|        ssh_set_error(session, SSH_FATAL, "Unsupported KEX type");
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  112|      0|        return NULL;
  113|  17.2k|    }
  114|       |
  115|  17.2k|    return secret;
  116|  17.2k|}
hybrid_mlkem.c:derive_curve25519_secret:
   49|  17.2k|{
   50|  17.2k|    ssh_string secret = NULL;
   51|  17.2k|    int rc;
   52|       |
   53|  17.2k|    secret = ssh_string_new(CURVE25519_PUBKEY_SIZE);
  ------------------
  |  |   40|  17.2k|#define CURVE25519_PUBKEY_SIZE 32
  ------------------
   54|  17.2k|    if (secret == NULL) {
  ------------------
  |  Branch (54:9): [True: 0, False: 17.2k]
  ------------------
   55|      0|        ssh_set_error_oom(session);
  ------------------
  |  |  318|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
   56|      0|        return NULL;
   57|      0|    }
   58|       |
   59|  17.2k|    rc = ssh_curve25519_create_k(session, ssh_string_data(secret));
   60|  17.2k|    if (rc != SSH_OK) {
  ------------------
  |  |  316|  17.2k|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (60:9): [True: 0, False: 17.2k]
  ------------------
   61|      0|        ssh_set_error(session,
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
   62|      0|                      SSH_FATAL,
   63|      0|                      "Curve25519 secret derivation failed");
   64|      0|        ssh_string_free(secret);
   65|      0|        return NULL;
   66|      0|    }
   67|       |
   68|  17.2k|    return secret;
   69|  17.2k|}
hybrid_mlkem.c:derive_hybrid_secret:
  121|  17.2k|{
  122|  17.2k|    struct ssh_crypto_struct *crypto = session->next_crypto;
  123|  17.2k|    ssh_buffer combined_secret = NULL;
  124|  17.2k|    int (*digest)(const unsigned char *, size_t, unsigned char *) = NULL;
  125|  17.2k|    size_t digest_len;
  126|  17.2k|    int rc, ret = SSH_ERROR;
  ------------------
  |  |  317|  17.2k|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  127|       |
  128|  17.2k|    switch (crypto->kex_type) {
  129|  17.2k|    case SSH_KEX_MLKEM768X25519_SHA256:
  ------------------
  |  Branch (129:5): [True: 17.2k, False: 0]
  ------------------
  130|  17.2k|    case SSH_KEX_MLKEM768NISTP256_SHA256:
  ------------------
  |  Branch (130:5): [True: 0, False: 17.2k]
  ------------------
  131|  17.2k|        digest = sha256;
  132|  17.2k|        digest_len = SHA256_DIGEST_LEN;
  ------------------
  |  |   45|  17.2k|#define SHA256_DIGEST_LEN SHA256_DIGEST_LENGTH
  ------------------
  133|  17.2k|        break;
  134|       |#ifdef HAVE_MLKEM1024
  135|       |    case SSH_KEX_MLKEM1024NISTP384_SHA384:
  136|       |        digest = sha384;
  137|       |        digest_len = SHA384_DIGEST_LEN;
  138|       |        break;
  139|       |#endif
  140|      0|    default:
  ------------------
  |  Branch (140:5): [True: 0, False: 17.2k]
  ------------------
  141|      0|        ssh_set_error(session, SSH_FATAL, "Unsupported KEX type");
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  142|      0|        goto cleanup;
  143|  17.2k|    }
  144|       |
  145|       |    /* Concatenate the two shared secrets */
  146|  17.2k|    combined_secret = ssh_buffer_new();
  147|  17.2k|    if (combined_secret == NULL) {
  ------------------
  |  Branch (147:9): [True: 0, False: 17.2k]
  ------------------
  148|      0|        ssh_set_error_oom(session);
  ------------------
  |  |  318|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
  149|      0|        goto cleanup;
  150|      0|    }
  151|  17.2k|    ssh_buffer_set_secure(combined_secret);
  152|       |
  153|  17.2k|    rc = ssh_buffer_pack(combined_secret,
  ------------------
  |  |   50|  17.2k|    _ssh_buffer_pack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |  451|  17.2k|        (__VA_NARG_(__VA_ARGS__, __RSEQ_N()))
  |  |  |  |  ------------------
  |  |  |  |  |  |  453|  17.2k|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  448|  17.2k|#define VA_APPLY_VARIADIC_MACRO(macro, tuple) macro tuple
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  453|  17.2k|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  461|  17.2k|        _61,_62,_63,N,...) N
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                   _ssh_buffer_pack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |   28|  17.2k|#define SSH_BUFFER_PACK_END ((uint32_t) 0x4f65feb3)
  |  |  ------------------
  ------------------
  154|  17.2k|                         "PP",
  155|  17.2k|                         (size_t)MLKEM_SHARED_SECRET_SIZE,
  156|  17.2k|                         mlkem_shared_secret,
  157|  17.2k|                         ssh_string_len(ecdh_shared_secret),
  158|  17.2k|                         ssh_string_data(ecdh_shared_secret));
  159|  17.2k|    if (rc != SSH_OK) {
  ------------------
  |  |  316|  17.2k|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (159:9): [True: 0, False: 17.2k]
  ------------------
  160|      0|        ssh_set_error(session, SSH_FATAL, "Failed to concatenate shared secrets");
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  161|      0|        goto cleanup;
  162|      0|    }
  163|       |
  164|       |#ifdef DEBUG_CRYPTO
  165|       |    ssh_log_hexdump("Concatenated shared secrets",
  166|       |                    ssh_buffer_get(combined_secret),
  167|       |                    ssh_buffer_get_len(combined_secret));
  168|       |#endif
  169|       |
  170|       |    /* Store the hashed combined shared secrets */
  171|  17.2k|    ssh_string_burn(crypto->hybrid_shared_secret);
  172|  17.2k|    ssh_string_free(crypto->hybrid_shared_secret);
  173|  17.2k|    crypto->hybrid_shared_secret = ssh_string_new(digest_len);
  174|  17.2k|    if (crypto->hybrid_shared_secret == NULL) {
  ------------------
  |  Branch (174:9): [True: 0, False: 17.2k]
  ------------------
  175|      0|        ssh_set_error_oom(session);
  ------------------
  |  |  318|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
  176|      0|        goto cleanup;
  177|      0|    }
  178|       |
  179|  17.2k|    rc = digest(ssh_buffer_get(combined_secret),
  180|  17.2k|                ssh_buffer_get_len(combined_secret),
  181|  17.2k|                ssh_string_data(crypto->hybrid_shared_secret));
  182|  17.2k|    if (rc != SSH_OK) {
  ------------------
  |  |  316|  17.2k|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (182:9): [True: 0, False: 17.2k]
  ------------------
  183|      0|        ssh_set_error(session, SSH_FATAL, "Shared secret hashing failed");
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  184|      0|        goto cleanup;
  185|      0|    }
  186|       |
  187|       |#ifdef DEBUG_CRYPTO
  188|       |    ssh_log_hexdump("Hybrid shared secret",
  189|       |                    ssh_string_data(crypto->hybrid_shared_secret),
  190|       |                    digest_len);
  191|       |#endif
  192|       |
  193|  17.2k|    ret = SSH_OK;
  ------------------
  |  |  316|  17.2k|#define SSH_OK 0     /* No error */
  ------------------
  194|       |
  195|  17.2k|cleanup:
  196|  17.2k|    ssh_buffer_free(combined_secret);
  197|  17.2k|    return ret;
  198|  17.2k|}
hybrid_mlkem.c:ssh_packet_server_hybrid_mlkem_init:
  551|  8.64k|{
  552|  8.64k|    struct ssh_crypto_struct *crypto = session->next_crypto;
  553|  8.64k|    const struct mlkem_type_info *mlkem_info = NULL;
  554|  8.64k|    ssh_string ecdh_shared_secret = NULL;
  555|  8.64k|    ssh_mlkem_shared_secret mlkem_shared_secret;
  556|  8.64k|    ssh_buffer server_reply_buffer = NULL;
  557|  8.64k|    ssh_buffer client_init_buffer = NULL;
  558|  8.64k|    ssh_key privkey = NULL;
  559|  8.64k|    enum ssh_digest_e digest = SSH_DIGEST_AUTO;
  560|  8.64k|    ssh_string signature = NULL;
  561|  8.64k|    ssh_string pubkey_blob = NULL;
  562|  8.64k|    size_t ecdh_client_pubkey_size;
  563|  8.64k|    size_t read_len;
  564|  8.64k|    int rc;
  565|  8.64k|    (void)type;
  566|  8.64k|    (void)user;
  567|       |
  568|  8.64k|    SSH_LOG(SSH_LOG_TRACE, "Received ML-KEM hybrid client init");
  ------------------
  |  |  281|  8.64k|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  569|       |
  570|  8.64k|    ssh_packet_remove_callbacks(session, &ssh_hybrid_mlkem_server_callbacks);
  571|       |
  572|  8.64k|    mlkem_info = kex_type_to_mlkem_info(crypto->kex_type);
  573|  8.64k|    if (mlkem_info == NULL) {
  ------------------
  |  Branch (573:9): [True: 0, False: 8.64k]
  ------------------
  574|      0|        ssh_set_error(session, SSH_FATAL, "Unknown ML-KEM type");
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  575|      0|        session->session_state = SSH_SESSION_STATE_ERROR;
  576|      0|        goto cleanup;
  577|      0|    }
  578|       |
  579|       |    /* Generate an ECDH keypair  */
  580|  8.64k|    switch (crypto->kex_type) {
  581|  8.64k|    case SSH_KEX_MLKEM768X25519_SHA256:
  ------------------
  |  Branch (581:5): [True: 8.64k, False: 0]
  ------------------
  582|  8.64k|        rc = ssh_curve25519_init(session);
  583|  8.64k|        if (rc != SSH_OK) {
  ------------------
  |  |  316|  8.64k|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (583:13): [True: 0, False: 8.64k]
  ------------------
  584|      0|            ssh_set_error(session,
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  585|      0|                          SSH_FATAL,
  586|      0|                          "Failed to generate a Curve25519 ECDH keypair");
  587|      0|            goto cleanup;
  588|      0|        }
  589|       |#ifdef DEBUG_CRYPTO
  590|       |        ssh_log_hexdump("Curve25519 server pubkey",
  591|       |                        crypto->curve25519_server_pubkey,
  592|       |                        CURVE25519_PUBKEY_SIZE);
  593|       |#endif
  594|  8.64k|        break;
  595|  8.64k|    case SSH_KEX_MLKEM768NISTP256_SHA256:
  ------------------
  |  Branch (595:5): [True: 0, False: 8.64k]
  ------------------
  596|       |#ifdef HAVE_MLKEM1024
  597|       |    case SSH_KEX_MLKEM1024NISTP384_SHA384:
  598|       |#endif
  599|      0|        rc = ssh_ecdh_init(session);
  600|      0|        if (rc != SSH_OK) {
  ------------------
  |  |  316|      0|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (600:13): [True: 0, False: 0]
  ------------------
  601|      0|            ssh_set_error(session,
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  602|      0|                          SSH_FATAL,
  603|      0|                          "Failed to generate a NIST-curve ECDH keypair");
  604|      0|            goto cleanup;
  605|      0|        }
  606|       |#ifdef DEBUG_CRYPTO
  607|       |        ssh_log_hexdump("ECDH server pubkey",
  608|       |                        ssh_string_data(crypto->ecdh_server_pubkey),
  609|       |                        ssh_string_len(crypto->ecdh_server_pubkey));
  610|       |#endif
  611|      0|        break;
  612|      0|    default:
  ------------------
  |  Branch (612:5): [True: 0, False: 8.64k]
  ------------------
  613|      0|        ssh_set_error(session, SSH_FATAL, "Unsupported KEX type");
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  614|      0|        goto cleanup;
  615|  8.64k|    }
  616|       |
  617|       |    /* Get client init: ML-KEM public key + ECDH public key */
  618|  8.64k|    ssh_string_free(crypto->hybrid_client_init);
  619|  8.64k|    crypto->hybrid_client_init = ssh_buffer_get_ssh_string(packet);
  620|  8.64k|    if (crypto->hybrid_client_init == NULL) {
  ------------------
  |  Branch (620:9): [True: 0, False: 8.64k]
  ------------------
  621|      0|        ssh_set_error(session, SSH_FATAL, "No client public keys in packet");
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  622|      0|        session->session_state = SSH_SESSION_STATE_ERROR;
  623|      0|        goto cleanup;
  624|      0|    }
  625|       |
  626|  8.64k|    client_init_buffer = ssh_buffer_new();
  627|  8.64k|    if (client_init_buffer == NULL) {
  ------------------
  |  Branch (627:9): [True: 0, False: 8.64k]
  ------------------
  628|      0|        ssh_set_error_oom(session);
  ------------------
  |  |  318|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
  629|      0|        session->session_state = SSH_SESSION_STATE_ERROR;
  630|      0|        goto cleanup;
  631|      0|    }
  632|       |
  633|  8.64k|    rc = ssh_buffer_add_data(client_init_buffer,
  634|  8.64k|                             ssh_string_data(crypto->hybrid_client_init),
  635|  8.64k|                             ssh_string_len(crypto->hybrid_client_init));
  636|  8.64k|    if (rc != SSH_OK) {
  ------------------
  |  |  316|  8.64k|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (636:9): [True: 0, False: 8.64k]
  ------------------
  637|      0|        ssh_set_error(session, SSH_FATAL, "Failed to pack client init to a buffer");
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  638|      0|        session->session_state = SSH_SESSION_STATE_ERROR;
  639|      0|        goto cleanup;
  640|      0|    }
  641|       |
  642|       |    /* Extract client ML-KEM public key */
  643|  8.64k|    ssh_string_free(crypto->mlkem_client_pubkey);
  644|  8.64k|    crypto->mlkem_client_pubkey = ssh_string_new(mlkem_info->pubkey_size);
  645|  8.64k|    if (crypto->mlkem_client_pubkey == NULL) {
  ------------------
  |  Branch (645:9): [True: 0, False: 8.64k]
  ------------------
  646|      0|        ssh_set_error_oom(session);
  ------------------
  |  |  318|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
  647|      0|        session->session_state = SSH_SESSION_STATE_ERROR;
  648|      0|        goto cleanup;
  649|      0|    }
  650|       |
  651|  8.64k|    read_len = ssh_buffer_get_data(client_init_buffer,
  652|  8.64k|                                   ssh_string_data(crypto->mlkem_client_pubkey),
  653|  8.64k|                                   mlkem_info->pubkey_size);
  654|  8.64k|    if (read_len != mlkem_info->pubkey_size) {
  ------------------
  |  Branch (654:9): [True: 0, False: 8.64k]
  ------------------
  655|      0|        ssh_set_error(session,
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  656|      0|                      SSH_FATAL,
  657|      0|                      "Could not read ML-KEM pubkey from "
  658|      0|                      "the client init buffer, buffer too short");
  659|      0|        session->session_state = SSH_SESSION_STATE_ERROR;
  660|      0|        goto cleanup;
  661|      0|    }
  662|       |
  663|       |#ifdef DEBUG_CRYPTO
  664|       |    ssh_log_hexdump("ML-KEM client pubkey",
  665|       |                    ssh_string_data(crypto->mlkem_client_pubkey),
  666|       |                    ssh_string_len(crypto->mlkem_client_pubkey));
  667|       |#endif
  668|       |
  669|       |    /* Extract client ECDH public key */
  670|  8.64k|    switch (crypto->kex_type) {
  671|  8.64k|    case SSH_KEX_MLKEM768X25519_SHA256:
  ------------------
  |  Branch (671:5): [True: 8.64k, False: 0]
  ------------------
  672|  8.64k|        read_len = ssh_buffer_get_data(client_init_buffer,
  673|  8.64k|                                       crypto->curve25519_client_pubkey,
  674|  8.64k|                                       CURVE25519_PUBKEY_SIZE);
  ------------------
  |  |   40|  8.64k|#define CURVE25519_PUBKEY_SIZE 32
  ------------------
  675|  8.64k|        if (read_len != CURVE25519_PUBKEY_SIZE) {
  ------------------
  |  |   40|  8.64k|#define CURVE25519_PUBKEY_SIZE 32
  ------------------
  |  Branch (675:13): [True: 0, False: 8.64k]
  ------------------
  676|      0|            ssh_set_error(session,
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  677|      0|                          SSH_FATAL,
  678|      0|                          "Could not read Curve25519 pubkey from "
  679|      0|                          "the client init buffer, buffer too short");
  680|      0|            session->session_state = SSH_SESSION_STATE_ERROR;
  681|      0|            goto cleanup;
  682|      0|        }
  683|  8.64k|        if (ssh_buffer_get_len(client_init_buffer) > 0) {
  ------------------
  |  Branch (683:13): [True: 0, False: 8.64k]
  ------------------
  684|      0|            ssh_set_error(session,
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  685|      0|                          SSH_FATAL,
  686|      0|                          "Unrecognized data in the client init buffer");
  687|      0|            session->session_state = SSH_SESSION_STATE_ERROR;
  688|      0|            goto cleanup;
  689|      0|        }
  690|       |#ifdef DEBUG_CRYPTO
  691|       |        ssh_log_hexdump("Curve25519 client pubkey",
  692|       |                        crypto->curve25519_client_pubkey,
  693|       |                        CURVE25519_PUBKEY_SIZE);
  694|       |#endif
  695|  8.64k|        break;
  696|  8.64k|    case SSH_KEX_MLKEM768NISTP256_SHA256:
  ------------------
  |  Branch (696:5): [True: 0, False: 8.64k]
  ------------------
  697|       |#ifdef HAVE_MLKEM1024
  698|       |    case SSH_KEX_MLKEM1024NISTP384_SHA384:
  699|       |#endif
  700|      0|        ecdh_client_pubkey_size = ssh_buffer_get_len(client_init_buffer);
  701|      0|        ssh_string_free(crypto->ecdh_client_pubkey);
  702|      0|        crypto->ecdh_client_pubkey = ssh_string_new(ecdh_client_pubkey_size);
  703|      0|        if (crypto->ecdh_client_pubkey == NULL) {
  ------------------
  |  Branch (703:13): [True: 0, False: 0]
  ------------------
  704|      0|            ssh_set_error_oom(session);
  ------------------
  |  |  318|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
  705|      0|            session->session_state = SSH_SESSION_STATE_ERROR;
  706|      0|            goto cleanup;
  707|      0|        }
  708|      0|        ssh_buffer_get_data(client_init_buffer,
  709|      0|                            ssh_string_data(crypto->ecdh_client_pubkey),
  710|      0|                            ecdh_client_pubkey_size);
  711|       |#ifdef DEBUG_CRYPTO
  712|       |        ssh_log_hexdump("ECDH client pubkey",
  713|       |                        ssh_string_data(crypto->ecdh_client_pubkey),
  714|       |                        ssh_string_len(crypto->ecdh_client_pubkey));
  715|       |#endif
  716|      0|        break;
  717|      0|    default:
  ------------------
  |  Branch (717:5): [True: 0, False: 8.64k]
  ------------------
  718|      0|        ssh_set_error(session, SSH_FATAL, "Unsupported KEX type");
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  719|      0|        goto cleanup;
  720|  8.64k|    }
  721|       |
  722|       |    /* Encapsulate an ML-KEM shared secret using client's ML-KEM public key */
  723|  8.64k|    rc = ssh_mlkem_encapsulate(session, mlkem_shared_secret);
  724|  8.64k|    if (rc != SSH_OK) {
  ------------------
  |  |  316|  8.64k|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (724:9): [True: 0, False: 8.64k]
  ------------------
  725|      0|        ssh_set_error(session, SSH_FATAL, "ML-KEM encapsulation failed");
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  726|      0|        session->session_state = SSH_SESSION_STATE_ERROR;
  727|      0|        goto cleanup;
  728|      0|    }
  729|       |
  730|       |#ifdef DEBUG_CRYPTO
  731|       |    ssh_log_hexdump("ML-KEM shared secret",
  732|       |                    mlkem_shared_secret,
  733|       |                    MLKEM_SHARED_SECRET_SIZE);
  734|       |    ssh_log_hexdump("ML-KEM ciphertext",
  735|       |                    ssh_string_data(crypto->mlkem_ciphertext),
  736|       |                    ssh_string_len(crypto->mlkem_ciphertext));
  737|       |#endif
  738|       |
  739|       |    /* Derive the classical ECDH shared secret */
  740|  8.64k|    ecdh_shared_secret = derive_ecdh_secret(session);
  741|  8.64k|    if (ecdh_shared_secret == NULL) {
  ------------------
  |  Branch (741:9): [True: 0, False: 8.64k]
  ------------------
  742|      0|        session->session_state = SSH_SESSION_STATE_ERROR;
  743|      0|        goto cleanup;
  744|      0|    }
  745|       |
  746|       |#ifdef DEBUG_CRYPTO
  747|       |    ssh_log_hexdump("ECDH shared secret",
  748|       |                    ssh_string_data(ecdh_shared_secret),
  749|       |                    ssh_string_len(ecdh_shared_secret));
  750|       |#endif
  751|       |
  752|       |    /* Derive the final shared secret */
  753|  8.64k|    rc = derive_hybrid_secret(session, mlkem_shared_secret, ecdh_shared_secret);
  754|  8.64k|    if (rc != SSH_OK) {
  ------------------
  |  |  316|  8.64k|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (754:9): [True: 0, False: 8.64k]
  ------------------
  755|      0|        session->session_state = SSH_SESSION_STATE_ERROR;
  756|      0|        goto cleanup;
  757|      0|    }
  758|       |
  759|       |    /* Create server reply: ML-KEM ciphertext + ECDH public key */
  760|  8.64k|    server_reply_buffer = ssh_buffer_new();
  761|  8.64k|    if (server_reply_buffer == NULL) {
  ------------------
  |  Branch (761:9): [True: 0, False: 8.64k]
  ------------------
  762|      0|        ssh_set_error_oom(session);
  ------------------
  |  |  318|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
  763|      0|        session->session_state = SSH_SESSION_STATE_ERROR;
  764|      0|        goto cleanup;
  765|      0|    }
  766|       |
  767|  8.64k|    switch (crypto->kex_type) {
  768|  8.64k|    case SSH_KEX_MLKEM768X25519_SHA256:
  ------------------
  |  Branch (768:5): [True: 8.64k, False: 0]
  ------------------
  769|  8.64k|        rc = ssh_buffer_pack(server_reply_buffer,
  ------------------
  |  |   50|  8.64k|    _ssh_buffer_pack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |  451|  8.64k|        (__VA_NARG_(__VA_ARGS__, __RSEQ_N()))
  |  |  |  |  ------------------
  |  |  |  |  |  |  453|  8.64k|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  448|  8.64k|#define VA_APPLY_VARIADIC_MACRO(macro, tuple) macro tuple
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  453|  8.64k|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  461|  8.64k|        _61,_62,_63,N,...) N
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                   _ssh_buffer_pack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |   28|  8.64k|#define SSH_BUFFER_PACK_END ((uint32_t) 0x4f65feb3)
  |  |  ------------------
  ------------------
  770|  8.64k|                             "PP",
  771|  8.64k|                             ssh_string_len(crypto->mlkem_ciphertext),
  772|  8.64k|                             ssh_string_data(crypto->mlkem_ciphertext),
  773|  8.64k|                             (size_t)CURVE25519_PUBKEY_SIZE,
  774|  8.64k|                             crypto->curve25519_server_pubkey);
  775|  8.64k|        break;
  776|      0|    case SSH_KEX_MLKEM768NISTP256_SHA256:
  ------------------
  |  Branch (776:5): [True: 0, False: 8.64k]
  ------------------
  777|       |#ifdef HAVE_MLKEM1024
  778|       |    case SSH_KEX_MLKEM1024NISTP384_SHA384:
  779|       |#endif
  780|      0|        rc = ssh_buffer_pack(server_reply_buffer,
  ------------------
  |  |   50|      0|    _ssh_buffer_pack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |  451|      0|        (__VA_NARG_(__VA_ARGS__, __RSEQ_N()))
  |  |  |  |  ------------------
  |  |  |  |  |  |  453|      0|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  448|      0|#define VA_APPLY_VARIADIC_MACRO(macro, tuple) macro tuple
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  453|      0|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  461|      0|        _61,_62,_63,N,...) N
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                   _ssh_buffer_pack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |   28|      0|#define SSH_BUFFER_PACK_END ((uint32_t) 0x4f65feb3)
  |  |  ------------------
  ------------------
  781|      0|                             "PP",
  782|      0|                             ssh_string_len(crypto->mlkem_ciphertext),
  783|      0|                             ssh_string_data(crypto->mlkem_ciphertext),
  784|      0|                             ssh_string_len(crypto->ecdh_server_pubkey),
  785|      0|                             ssh_string_data(crypto->ecdh_server_pubkey));
  786|      0|        break;
  787|      0|    default:
  ------------------
  |  Branch (787:5): [True: 0, False: 8.64k]
  ------------------
  788|      0|        ssh_set_error(session, SSH_FATAL, "Unsupported KEX type");
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  789|      0|        goto cleanup;
  790|  8.64k|    }
  791|  8.64k|    if (rc != SSH_OK) {
  ------------------
  |  |  316|  8.64k|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (791:9): [True: 0, False: 8.64k]
  ------------------
  792|      0|        ssh_set_error(session, SSH_FATAL, "Failed to construct server reply buffer");
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  793|      0|        goto cleanup;
  794|      0|    }
  795|       |
  796|       |    /* Convert the reply buffer to an SSH string for sending */
  797|  8.64k|    ssh_string_free(crypto->hybrid_server_reply);
  798|  8.64k|    crypto->hybrid_server_reply = ssh_string_new(ssh_buffer_get_len(server_reply_buffer));
  799|  8.64k|    if (crypto->hybrid_server_reply == NULL) {
  ------------------
  |  Branch (799:9): [True: 0, False: 8.64k]
  ------------------
  800|      0|        ssh_set_error_oom(session);
  ------------------
  |  |  318|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
  801|      0|        session->session_state = SSH_SESSION_STATE_ERROR;
  802|      0|        goto cleanup;
  803|      0|    }
  804|       |
  805|  8.64k|    rc = ssh_string_fill(crypto->hybrid_server_reply,
  806|  8.64k|                         ssh_buffer_get(server_reply_buffer),
  807|  8.64k|                         ssh_buffer_get_len(server_reply_buffer));
  808|  8.64k|    if (rc != SSH_OK) {
  ------------------
  |  |  316|  8.64k|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (808:9): [True: 0, False: 8.64k]
  ------------------
  809|      0|        ssh_set_error(session, SSH_FATAL, "Failed to convert reply buffer to string");
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  810|      0|        session->session_state = SSH_SESSION_STATE_ERROR;
  811|      0|        goto cleanup;
  812|      0|    }
  813|       |
  814|       |    /* Add MSG_KEX_ECDH_REPLY header */
  815|  8.64k|    rc = ssh_buffer_add_u8(session->out_buffer, SSH2_MSG_KEX_HYBRID_REPLY);
  ------------------
  |  |   20|  8.64k|#define SSH2_MSG_KEX_HYBRID_REPLY 31
  ------------------
  816|  8.64k|    if (rc != SSH_OK) {
  ------------------
  |  |  316|  8.64k|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (816:9): [True: 0, False: 8.64k]
  ------------------
  817|      0|        ssh_set_error(session, SSH_FATAL, "Failed to add MSG_KEX_HYBRID_REPLY to buffer");
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  818|      0|        session->session_state = SSH_SESSION_STATE_ERROR;
  819|      0|        goto cleanup;
  820|      0|    }
  821|       |
  822|       |    /* Get server host key */
  823|  8.64k|    rc = ssh_get_key_params(session, &privkey, &digest);
  824|  8.64k|    if (rc != SSH_OK) {
  ------------------
  |  |  316|  8.64k|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (824:9): [True: 0, False: 8.64k]
  ------------------
  825|      0|        ssh_set_error(session, SSH_FATAL, "Could not get server key params");
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  826|      0|        session->session_state = SSH_SESSION_STATE_ERROR;
  827|      0|        goto cleanup;
  828|      0|    }
  829|       |
  830|       |    /* Build session ID */
  831|  8.64k|    rc = ssh_make_sessionid(session);
  832|  8.64k|    if (rc != SSH_OK) {
  ------------------
  |  |  316|  8.64k|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (832:9): [True: 0, False: 8.64k]
  ------------------
  833|      0|        ssh_set_error(session, SSH_FATAL, "Could not create a session id");
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  834|      0|        session->session_state = SSH_SESSION_STATE_ERROR;
  835|      0|        goto cleanup;
  836|      0|    }
  837|       |
  838|  8.64k|    rc = ssh_dh_get_next_server_publickey_blob(session, &pubkey_blob);
  839|  8.64k|    if (rc != SSH_OK) {
  ------------------
  |  |  316|  8.64k|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (839:9): [True: 0, False: 8.64k]
  ------------------
  840|      0|        ssh_set_error(session, SSH_FATAL, "Could not export server public key");
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  841|      0|        session->session_state = SSH_SESSION_STATE_ERROR;
  842|      0|        goto cleanup;
  843|      0|    }
  844|       |
  845|       |    /* Add server public key to output */
  846|  8.64k|    rc = ssh_buffer_add_ssh_string(session->out_buffer, pubkey_blob);
  847|  8.64k|    if (rc != SSH_OK) {
  ------------------
  |  |  316|  8.64k|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (847:9): [True: 0, False: 8.64k]
  ------------------
  848|      0|        ssh_set_error(session, SSH_FATAL, "Failed to add server hostkey to buffer");
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  849|      0|        session->session_state = SSH_SESSION_STATE_ERROR;
  850|      0|        goto cleanup;
  851|      0|    }
  852|       |
  853|       |    /* Add server reply */
  854|  8.64k|    rc = ssh_buffer_add_ssh_string(session->out_buffer, crypto->hybrid_server_reply);
  855|  8.64k|    if (rc != SSH_OK) {
  ------------------
  |  |  316|  8.64k|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (855:9): [True: 0, False: 8.64k]
  ------------------
  856|      0|        ssh_set_error(session, SSH_FATAL, "Failed to add server reply to buffer");
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  857|      0|        session->session_state = SSH_SESSION_STATE_ERROR;
  858|      0|        goto cleanup;
  859|      0|    }
  860|       |
  861|       |    /* Sign the exchange hash */
  862|  8.64k|    signature = ssh_srv_pki_do_sign_sessionid(session, privkey, digest);
  863|  8.64k|    if (signature == NULL) {
  ------------------
  |  Branch (863:9): [True: 0, False: 8.64k]
  ------------------
  864|      0|        ssh_set_error(session, SSH_FATAL, "Could not sign the session id");
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  865|      0|        session->session_state = SSH_SESSION_STATE_ERROR;
  866|      0|        goto cleanup;
  867|      0|    }
  868|       |
  869|       |    /* Add signature */
  870|  8.64k|    rc = ssh_buffer_add_ssh_string(session->out_buffer, signature);
  871|  8.64k|    if (rc != SSH_OK) {
  ------------------
  |  |  316|  8.64k|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (871:9): [True: 0, False: 8.64k]
  ------------------
  872|      0|        ssh_set_error(session, SSH_FATAL, "Failed to add signature to buffer");
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  873|      0|        session->session_state = SSH_SESSION_STATE_ERROR;
  874|      0|        goto cleanup;
  875|      0|    }
  876|       |
  877|  8.64k|    rc = ssh_packet_send(session);
  878|  8.64k|    if (rc != SSH_OK) {
  ------------------
  |  |  316|  8.64k|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (878:9): [True: 0, False: 8.64k]
  ------------------
  879|      0|        ssh_set_error(session, SSH_FATAL, "Failed to send SSH_MSG_KEX_ECDH_REPLY");
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  880|      0|        session->session_state = SSH_SESSION_STATE_ERROR;
  881|      0|        goto cleanup;
  882|      0|    }
  883|       |
  884|       |    /* Send the MSG_NEWKEYS */
  885|  8.64k|    rc = ssh_packet_send_newkeys(session);
  886|  8.64k|    if (rc != SSH_OK) {
  ------------------
  |  |  316|  8.64k|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (886:9): [True: 0, False: 8.64k]
  ------------------
  887|      0|        ssh_set_error(session, SSH_FATAL, "Failed to send SSH_MSG_NEWKEYS");
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  888|      0|        session->session_state = SSH_SESSION_STATE_ERROR;
  889|      0|        goto cleanup;
  890|      0|    }
  891|  8.64k|    session->dh_handshake_state = DH_STATE_NEWKEYS_SENT;
  892|       |
  893|  8.64k|cleanup:
  894|  8.64k|    ssh_burn(mlkem_shared_secret, sizeof(mlkem_shared_secret));
  ------------------
  |  |  388|  8.64k|#define ssh_burn(ptr, len) explicit_bzero((ptr), (len))
  ------------------
  895|  8.64k|    ssh_string_burn(ecdh_shared_secret);
  896|  8.64k|    ssh_string_free(ecdh_shared_secret);
  897|  8.64k|    ssh_string_free(pubkey_blob);
  898|  8.64k|    ssh_string_free(signature);
  899|  8.64k|    ssh_buffer_free(client_init_buffer);
  900|  8.64k|    ssh_buffer_free(server_reply_buffer);
  901|  8.64k|    return SSH_PACKET_USED;
  ------------------
  |  |  637|  8.64k|#define SSH_PACKET_USED 1
  ------------------
  902|  8.64k|}

libssh_constructor:
  114|      2|{
  115|       |
  116|      2|    int rc;
  117|       |
  118|      2|    rc = _ssh_init(1);
  119|       |
  120|      2|    if (rc < 0) {
  ------------------
  |  Branch (120:9): [True: 0, False: 2]
  ------------------
  121|      0|        fprintf(stderr, "Error in auto_init()\n");
  122|      0|    }
  123|       |
  124|      2|    return;
  125|      2|}
ssh_init:
  156|      2|int ssh_init(void) {
  157|      2|    return _ssh_init(0);
  158|      2|}
ssh_finalize:
  241|      2|int ssh_finalize(void) {
  242|      2|    return _ssh_finalize(0);
  243|      2|}
is_ssh_initialized:
  284|  8.64k|bool is_ssh_initialized(void) {
  285|       |
  286|  8.64k|    bool is_initialized = false;
  287|       |
  288|  8.64k|    ssh_mutex_lock(&ssh_init_mutex);
  289|  8.64k|    is_initialized = _ssh_initialized > 0;
  290|  8.64k|    ssh_mutex_unlock(&ssh_init_mutex);
  291|       |
  292|  8.64k|    return is_initialized;
  293|  8.64k|}
init.c:_ssh_init:
   62|      4|static int _ssh_init(unsigned constructor) {
   63|       |
   64|      4|    int rc = 0;
   65|       |
   66|      4|    if (!constructor) {
  ------------------
  |  Branch (66:9): [True: 2, False: 2]
  ------------------
   67|      2|        ssh_mutex_lock(&ssh_init_mutex);
   68|      2|    }
   69|       |
   70|      4|    _ssh_initialized++;
   71|       |
   72|      4|    if (_ssh_initialized > 1) {
  ------------------
  |  Branch (72:9): [True: 2, False: 2]
  ------------------
   73|      2|        rc = _ssh_init_ret;
   74|      2|        goto _ret;
   75|      2|    }
   76|       |
   77|      2|    rc = ssh_threads_init();
   78|      2|    if (rc) {
  ------------------
  |  Branch (78:9): [True: 0, False: 2]
  ------------------
   79|      0|        goto _ret;
   80|      0|    }
   81|       |
   82|      2|    rc = ssh_crypto_init();
   83|      2|    if (rc) {
  ------------------
  |  Branch (83:9): [True: 0, False: 2]
  ------------------
   84|      0|        goto _ret;
   85|      0|    }
   86|       |
   87|      2|    rc = ssh_dh_init();
   88|      2|    if (rc) {
  ------------------
  |  Branch (88:9): [True: 0, False: 2]
  ------------------
   89|      0|        goto _ret;
   90|      0|    }
   91|       |
   92|      2|    rc = ssh_socket_init();
   93|      2|    if (rc) {
  ------------------
  |  Branch (93:9): [True: 0, False: 2]
  ------------------
   94|      0|        goto _ret;
   95|      0|    }
   96|       |
   97|      4|_ret:
   98|      4|    _ssh_init_ret = rc;
   99|       |
  100|      4|    if (!constructor) {
  ------------------
  |  Branch (100:9): [True: 2, False: 2]
  ------------------
  101|      2|        ssh_mutex_unlock(&ssh_init_mutex);
  102|      2|    }
  103|       |
  104|      4|    return rc;
  105|      2|}
init.c:_ssh_finalize:
  160|      2|static int _ssh_finalize(unsigned destructor) {
  161|       |
  162|      2|    if (!destructor) {
  ------------------
  |  Branch (162:9): [True: 2, False: 0]
  ------------------
  163|      2|        ssh_mutex_lock(&ssh_init_mutex);
  164|       |
  165|      2|        if (_ssh_initialized > 1) {
  ------------------
  |  Branch (165:13): [True: 2, False: 0]
  ------------------
  166|      2|            _ssh_initialized--;
  167|      2|            ssh_mutex_unlock(&ssh_init_mutex);
  168|      2|            return 0;
  169|      2|        }
  170|       |
  171|      0|        if (_ssh_initialized == 1) {
  ------------------
  |  Branch (171:13): [True: 0, False: 0]
  ------------------
  172|      0|            if (_ssh_init_ret < 0) {
  ------------------
  |  Branch (172:17): [True: 0, False: 0]
  ------------------
  173|      0|                ssh_mutex_unlock(&ssh_init_mutex);
  174|      0|                return 0;
  175|      0|            }
  176|      0|        }
  177|      0|    }
  178|       |
  179|       |    /* If the counter reaches zero or it is the destructor calling, finalize */
  180|      0|    ssh_dh_finalize();
  181|      0|    ssh_crypto_finalize();
  182|      0|    ssh_socket_cleanup();
  183|       |    /* It is important to finalize threading after CRYPTO because
  184|       |     * it still depends on it */
  185|      0|    ssh_threads_finalize();
  186|       |
  187|      0|    _ssh_initialized = 0;
  188|       |
  189|      0|    if (!destructor) {
  ------------------
  |  Branch (189:9): [True: 0, False: 0]
  ------------------
  190|      0|        ssh_mutex_unlock(&ssh_init_mutex);
  191|      0|    }
  192|       |
  193|       |#if (defined(_WIN32) && !defined(HAVE_PTHREAD))
  194|       |    if (ssh_init_mutex != NULL) {
  195|       |        DeleteCriticalSection(ssh_init_mutex);
  196|       |        SAFE_FREE(ssh_init_mutex);
  197|       |    }
  198|       |#endif
  199|       |
  200|      0|    return 0;
  201|      2|}

sshkdf_derive_key:
  158|   103k|{
  159|       |    /* Can't use VLAs with Visual Studio, so allocate the biggest
  160|       |     * digest buffer we can possibly need */
  161|   103k|    unsigned char digest[DIGEST_MAX_LEN];
  162|   103k|    size_t output_len = crypto->digest_len;
  163|   103k|    ssh_mac_ctx ctx;
  164|   103k|    int rc;
  165|       |
  166|   103k|    if (DIGEST_MAX_LEN < crypto->digest_len) {
  ------------------
  |  |   56|   103k|#define DIGEST_MAX_LEN 64
  ------------------
  |  Branch (166:9): [True: 0, False: 103k]
  ------------------
  167|      0|        return -1;
  168|      0|    }
  169|       |
  170|   103k|    ctx = ssh_mac_ctx_init(crypto->digest_type);
  171|   103k|    if (ctx == NULL) {
  ------------------
  |  Branch (171:9): [True: 0, False: 103k]
  ------------------
  172|      0|        return -1;
  173|      0|    }
  174|       |
  175|   103k|    rc = ssh_mac_update(ctx, key, key_len);
  176|   103k|    if (rc != SSH_OK) {
  ------------------
  |  |  316|   103k|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (176:9): [True: 0, False: 103k]
  ------------------
  177|      0|        ssh_mac_ctx_free(ctx);
  178|      0|        return -1;
  179|      0|    }
  180|   103k|    rc = ssh_mac_update(ctx, crypto->secret_hash, crypto->digest_len);
  181|   103k|    if (rc != SSH_OK) {
  ------------------
  |  |  316|   103k|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (181:9): [True: 0, False: 103k]
  ------------------
  182|      0|        ssh_mac_ctx_free(ctx);
  183|      0|        return -1;
  184|      0|    }
  185|   103k|    rc = ssh_mac_update(ctx, &key_type, 1);
  186|   103k|    if (rc != SSH_OK) {
  ------------------
  |  |  316|   103k|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (186:9): [True: 0, False: 103k]
  ------------------
  187|      0|        ssh_mac_ctx_free(ctx);
  188|      0|        return -1;
  189|      0|    }
  190|   103k|    rc = ssh_mac_update(ctx, crypto->session_id, crypto->session_id_len);
  191|   103k|    if (rc != SSH_OK) {
  ------------------
  |  |  316|   103k|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (191:9): [True: 0, False: 103k]
  ------------------
  192|      0|        ssh_mac_ctx_free(ctx);
  193|      0|        return -1;
  194|      0|    }
  195|   103k|    rc = ssh_mac_final(digest, ctx);
  196|   103k|    if (rc != SSH_OK) {
  ------------------
  |  |  316|   103k|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (196:9): [True: 0, False: 103k]
  ------------------
  197|      0|        return -1;
  198|      0|    }
  199|       |
  200|   103k|    if (requested_len < output_len) {
  ------------------
  |  Branch (200:9): [True: 48.9k, False: 54.7k]
  ------------------
  201|  48.9k|        output_len = requested_len;
  202|  48.9k|    }
  203|   103k|    memcpy(output, digest, output_len);
  204|       |
  205|   103k|    while (requested_len > output_len) {
  ------------------
  |  Branch (205:12): [True: 0, False: 103k]
  ------------------
  206|      0|        ctx = ssh_mac_ctx_init(crypto->digest_type);
  207|      0|        if (ctx == NULL) {
  ------------------
  |  Branch (207:13): [True: 0, False: 0]
  ------------------
  208|      0|            return -1;
  209|      0|        }
  210|      0|        rc = ssh_mac_update(ctx, key, key_len);
  211|      0|        if (rc != SSH_OK) {
  ------------------
  |  |  316|      0|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (211:13): [True: 0, False: 0]
  ------------------
  212|      0|            ssh_mac_ctx_free(ctx);
  213|      0|            return -1;
  214|      0|        }
  215|      0|        rc = ssh_mac_update(ctx, crypto->secret_hash, crypto->digest_len);
  216|      0|        if (rc != SSH_OK) {
  ------------------
  |  |  316|      0|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (216:13): [True: 0, False: 0]
  ------------------
  217|      0|            ssh_mac_ctx_free(ctx);
  218|      0|            return -1;
  219|      0|        }
  220|      0|        rc = ssh_mac_update(ctx, output, output_len);
  221|      0|        if (rc != SSH_OK) {
  ------------------
  |  |  316|      0|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (221:13): [True: 0, False: 0]
  ------------------
  222|      0|            ssh_mac_ctx_free(ctx);
  223|      0|            return -1;
  224|      0|        }
  225|      0|        rc = ssh_mac_final(digest, ctx);
  226|      0|        if (rc != SSH_OK) {
  ------------------
  |  |  316|      0|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (226:13): [True: 0, False: 0]
  ------------------
  227|      0|            return -1;
  228|      0|        }
  229|      0|        if (requested_len < output_len + crypto->digest_len) {
  ------------------
  |  Branch (229:13): [True: 0, False: 0]
  ------------------
  230|      0|            memcpy(output + output_len, digest, requested_len - output_len);
  231|      0|        } else {
  232|      0|            memcpy(output + output_len, digest, crypto->digest_len);
  233|      0|        }
  234|      0|        output_len += crypto->digest_len;
  235|      0|    }
  236|       |
  237|   103k|    return 0;
  238|   103k|}
kdf.c:ssh_mac_ctx_init:
   54|   103k|{
   55|   103k|    ssh_mac_ctx ctx = malloc(sizeof(struct ssh_mac_ctx_struct));
   56|   103k|    if (ctx == NULL) {
  ------------------
  |  Branch (56:9): [True: 0, False: 103k]
  ------------------
   57|      0|        return NULL;
   58|      0|    }
   59|       |
   60|   103k|    ctx->digest_type = type;
   61|   103k|    switch (type) {
  ------------------
  |  Branch (61:13): [True: 103k, False: 0]
  ------------------
   62|      0|    case SSH_KDF_SHA1:
  ------------------
  |  Branch (62:5): [True: 0, False: 103k]
  ------------------
   63|      0|        ctx->ctx.sha1_ctx = sha1_init();
   64|      0|        if (ctx->ctx.sha1_ctx == NULL) {
  ------------------
  |  Branch (64:13): [True: 0, False: 0]
  ------------------
   65|      0|            goto err;
   66|      0|        }
   67|      0|        return ctx;
   68|   103k|    case SSH_KDF_SHA256:
  ------------------
  |  Branch (68:5): [True: 103k, False: 0]
  ------------------
   69|   103k|        ctx->ctx.sha256_ctx = sha256_init();
   70|   103k|        if (ctx->ctx.sha256_ctx == NULL) {
  ------------------
  |  Branch (70:13): [True: 0, False: 103k]
  ------------------
   71|      0|            goto err;
   72|      0|        }
   73|   103k|        return ctx;
   74|      0|    case SSH_KDF_SHA384:
  ------------------
  |  Branch (74:5): [True: 0, False: 103k]
  ------------------
   75|      0|        ctx->ctx.sha384_ctx = sha384_init();
   76|      0|        if (ctx->ctx.sha384_ctx == NULL) {
  ------------------
  |  Branch (76:13): [True: 0, False: 0]
  ------------------
   77|      0|            goto err;
   78|      0|        }
   79|      0|        return ctx;
   80|      0|    case SSH_KDF_SHA512:
  ------------------
  |  Branch (80:5): [True: 0, False: 103k]
  ------------------
   81|      0|        ctx->ctx.sha512_ctx = sha512_init();
   82|      0|        if (ctx->ctx.sha512_ctx == NULL) {
  ------------------
  |  Branch (82:13): [True: 0, False: 0]
  ------------------
   83|      0|            goto err;
   84|      0|        }
   85|      0|        return ctx;
   86|   103k|    }
   87|      0|err:
   88|      0|    SAFE_FREE(ctx);
  ------------------
  |  |  373|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
   89|       |    return NULL;
   90|   103k|}
kdf.c:ssh_mac_update:
  116|   414k|{
  117|   414k|    switch (ctx->digest_type) {
  ------------------
  |  Branch (117:13): [True: 414k, False: 0]
  ------------------
  118|      0|    case SSH_KDF_SHA1:
  ------------------
  |  Branch (118:5): [True: 0, False: 414k]
  ------------------
  119|      0|        return sha1_update(ctx->ctx.sha1_ctx, data, len);
  120|   414k|    case SSH_KDF_SHA256:
  ------------------
  |  Branch (120:5): [True: 414k, False: 0]
  ------------------
  121|   414k|        return sha256_update(ctx->ctx.sha256_ctx, data, len);
  122|      0|    case SSH_KDF_SHA384:
  ------------------
  |  Branch (122:5): [True: 0, False: 414k]
  ------------------
  123|      0|        return sha384_update(ctx->ctx.sha384_ctx, data, len);
  124|      0|    case SSH_KDF_SHA512:
  ------------------
  |  Branch (124:5): [True: 0, False: 414k]
  ------------------
  125|      0|        return sha512_update(ctx->ctx.sha512_ctx, data, len);
  126|   414k|    }
  127|      0|    return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  128|   414k|}
kdf.c:ssh_mac_final:
  131|   103k|{
  132|   103k|    int rc = SSH_ERROR;
  ------------------
  |  |  317|   103k|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  133|       |
  134|   103k|    switch (ctx->digest_type) {
  ------------------
  |  Branch (134:13): [True: 103k, False: 0]
  ------------------
  135|      0|    case SSH_KDF_SHA1:
  ------------------
  |  Branch (135:5): [True: 0, False: 103k]
  ------------------
  136|      0|        rc = sha1_final(md, ctx->ctx.sha1_ctx);
  137|      0|        break;
  138|   103k|    case SSH_KDF_SHA256:
  ------------------
  |  Branch (138:5): [True: 103k, False: 0]
  ------------------
  139|   103k|        rc = sha256_final(md, ctx->ctx.sha256_ctx);
  140|   103k|        break;
  141|      0|    case SSH_KDF_SHA384:
  ------------------
  |  Branch (141:5): [True: 0, False: 103k]
  ------------------
  142|      0|        rc = sha384_final(md, ctx->ctx.sha384_ctx);
  143|      0|        break;
  144|      0|    case SSH_KDF_SHA512:
  ------------------
  |  Branch (144:5): [True: 0, False: 103k]
  ------------------
  145|      0|        rc = sha512_final(md, ctx->ctx.sha512_ctx);
  146|      0|        break;
  147|   103k|    }
  148|   103k|    SAFE_FREE(ctx);
  ------------------
  |  |  373|   103k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 103k, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 103k]
  |  |  ------------------
  ------------------
  149|   103k|    return rc;
  150|   103k|}

ssh_kex_get_default_methods:
  300|  69.1k|{
  301|  69.1k|    if (type >= SSH_KEX_METHODS) {
  ------------------
  |  |   27|  69.1k|#define SSH_KEX_METHODS 10
  ------------------
  |  Branch (301:9): [True: 0, False: 69.1k]
  ------------------
  302|      0|        return NULL;
  303|      0|    }
  304|       |
  305|  69.1k|    return default_methods[type];
  306|  69.1k|}
ssh_packet_kexinit:
  397|  17.2k|{
  398|  17.2k|    int i, ok;
  399|  17.2k|    struct ssh_crypto_struct *crypto = session->next_crypto;
  400|  17.2k|    int server_kex = session->server;
  401|  17.2k|    ssh_string str = NULL;
  402|  17.2k|    char *strings[SSH_KEX_METHODS] = {0};
  403|  17.2k|    int rc = SSH_ERROR;
  ------------------
  |  |  317|  17.2k|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  404|  17.2k|    size_t len;
  405|       |
  406|  17.2k|    uint8_t first_kex_packet_follows = 0;
  407|  17.2k|    uint32_t kexinit_reserved = 0;
  408|       |
  409|  17.2k|    (void)type;
  410|  17.2k|    (void)user;
  411|       |
  412|  17.2k|    SSH_LOG(SSH_LOG_TRACE, "KEXINIT received");
  ------------------
  |  |  281|  17.2k|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  413|       |
  414|  17.2k|    if (session->session_state == SSH_SESSION_STATE_AUTHENTICATED) {
  ------------------
  |  Branch (414:9): [True: 0, False: 17.2k]
  ------------------
  415|      0|        if (session->dh_handshake_state == DH_STATE_FINISHED) {
  ------------------
  |  Branch (415:13): [True: 0, False: 0]
  ------------------
  416|      0|            SSH_LOG(SSH_LOG_DEBUG, "Peer initiated key re-exchange");
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  417|       |            /* Reset the sent flag if the re-kex was initiated by the peer */
  418|      0|            session->flags &= ~SSH_SESSION_FLAG_KEXINIT_SENT;
  ------------------
  |  |   86|      0|#define SSH_SESSION_FLAG_KEXINIT_SENT 0x0008
  ------------------
  419|      0|        } else if (session->flags & SSH_SESSION_FLAG_KEXINIT_SENT &&
  ------------------
  |  |   86|      0|#define SSH_SESSION_FLAG_KEXINIT_SENT 0x0008
  ------------------
  |  Branch (419:20): [True: 0, False: 0]
  ------------------
  420|      0|                   session->dh_handshake_state == DH_STATE_INIT_SENT) {
  ------------------
  |  Branch (420:20): [True: 0, False: 0]
  ------------------
  421|       |            /* This happens only when we are sending our-guessed first kex
  422|       |             * packet right after our KEXINIT packet. */
  423|      0|            SSH_LOG(SSH_LOG_DEBUG, "Received peer kexinit answer.");
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  424|      0|        } else if (session->session_state != SSH_SESSION_STATE_INITIAL_KEX) {
  ------------------
  |  Branch (424:20): [True: 0, False: 0]
  ------------------
  425|      0|            ssh_set_error(session, SSH_FATAL,
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  426|      0|                          "SSH_KEXINIT received in wrong state");
  427|      0|            goto error;
  428|      0|        }
  429|  17.2k|    } else if (session->session_state != SSH_SESSION_STATE_INITIAL_KEX) {
  ------------------
  |  Branch (429:16): [True: 0, False: 17.2k]
  ------------------
  430|      0|        ssh_set_error(session, SSH_FATAL,
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  431|      0|                      "SSH_KEXINIT received in wrong state");
  432|      0|        goto error;
  433|      0|    }
  434|       |
  435|  17.2k|    if (server_kex) {
  ------------------
  |  Branch (435:9): [True: 8.64k, False: 8.62k]
  ------------------
  436|  8.64k|#ifdef WITH_SERVER
  437|  8.64k|        len = ssh_buffer_get_data(packet, crypto->client_kex.cookie, 16);
  438|  8.64k|        if (len != 16) {
  ------------------
  |  Branch (438:13): [True: 0, False: 8.64k]
  ------------------
  439|      0|            ssh_set_error(session, SSH_FATAL,
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  440|      0|                          "ssh_packet_kexinit: no cookie in packet");
  441|      0|            goto error;
  442|      0|        }
  443|       |
  444|  8.64k|        ok = ssh_hashbufin_add_cookie(session, crypto->client_kex.cookie);
  445|  8.64k|        if (ok < 0) {
  ------------------
  |  Branch (445:13): [True: 0, False: 8.64k]
  ------------------
  446|      0|            ssh_set_error(session, SSH_FATAL,
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  447|      0|                          "ssh_packet_kexinit: adding cookie failed");
  448|      0|            goto error;
  449|      0|        }
  450|       |
  451|  8.64k|        ok = server_set_kex(session);
  452|  8.64k|        if (ok == SSH_ERROR) {
  ------------------
  |  |  317|  8.64k|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  |  Branch (452:13): [True: 0, False: 8.64k]
  ------------------
  453|      0|            goto error;
  454|      0|        }
  455|  8.64k|#endif /* WITH_SERVER */
  456|  8.64k|    } else {
  457|  8.62k|        len = ssh_buffer_get_data(packet, crypto->server_kex.cookie, 16);
  458|  8.62k|        if (len != 16) {
  ------------------
  |  Branch (458:13): [True: 0, False: 8.62k]
  ------------------
  459|      0|            ssh_set_error(session, SSH_FATAL,
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  460|      0|                          "ssh_packet_kexinit: no cookie in packet");
  461|      0|            goto error;
  462|      0|        }
  463|       |
  464|  8.62k|        ok = ssh_hashbufin_add_cookie(session, crypto->server_kex.cookie);
  465|  8.62k|        if (ok < 0) {
  ------------------
  |  Branch (465:13): [True: 0, False: 8.62k]
  ------------------
  466|      0|            ssh_set_error(session, SSH_FATAL,
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  467|      0|                          "ssh_packet_kexinit: adding cookie failed");
  468|      0|            goto error;
  469|      0|        }
  470|       |
  471|  8.62k|        ok = ssh_set_client_kex(session);
  472|  8.62k|        if (ok == SSH_ERROR) {
  ------------------
  |  |  317|  8.62k|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  |  Branch (472:13): [True: 0, False: 8.62k]
  ------------------
  473|      0|            goto error;
  474|      0|        }
  475|  8.62k|    }
  476|       |
  477|   189k|    for (i = 0; i < SSH_KEX_METHODS; i++) {
  ------------------
  |  |   27|   189k|#define SSH_KEX_METHODS 10
  ------------------
  |  Branch (477:17): [True: 172k, False: 17.2k]
  ------------------
  478|   172k|        str = ssh_buffer_get_ssh_string(packet);
  479|   172k|        if (str == NULL) {
  ------------------
  |  Branch (479:13): [True: 0, False: 172k]
  ------------------
  480|      0|          goto error;
  481|      0|        }
  482|       |
  483|   172k|        rc = ssh_buffer_add_ssh_string(session->in_hashbuf, str);
  484|   172k|        if (rc < 0) {
  ------------------
  |  Branch (484:13): [True: 0, False: 172k]
  ------------------
  485|      0|            ssh_set_error(session, SSH_FATAL,
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  486|      0|                          "Error adding string in hash buffer");
  487|      0|            goto error;
  488|      0|        }
  489|       |
  490|   172k|        strings[i] = ssh_string_to_char(str);
  491|   172k|        if (strings[i] == NULL) {
  ------------------
  |  Branch (491:13): [True: 0, False: 172k]
  ------------------
  492|      0|            ssh_set_error_oom(session);
  ------------------
  |  |  318|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
  493|      0|            goto error;
  494|      0|        }
  495|   172k|        SSH_STRING_FREE(str);
  ------------------
  |  |  893|   172k|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (893:14): [True: 172k, False: 45]
  |  |  |  Branch (893:69): [Folded, False: 172k]
  |  |  ------------------
  ------------------
  496|   172k|        str = NULL;
  497|   172k|    }
  498|       |
  499|       |    /* copy the peer kex info into an array of strings */
  500|  17.2k|    if (server_kex) {
  ------------------
  |  Branch (500:9): [True: 8.64k, False: 8.62k]
  ------------------
  501|  8.64k|#ifdef WITH_SERVER
  502|  95.0k|        for (i = 0; i < SSH_KEX_METHODS; i++) {
  ------------------
  |  |   27|  95.0k|#define SSH_KEX_METHODS 10
  ------------------
  |  Branch (502:21): [True: 86.4k, False: 8.64k]
  ------------------
  503|  86.4k|            crypto->client_kex.methods[i] = strings[i];
  504|  86.4k|        }
  505|  8.64k|#endif /* WITH_SERVER */
  506|  8.64k|    } else { /* client */
  507|  95.0k|        for (i = 0; i < SSH_KEX_METHODS; i++) {
  ------------------
  |  |   27|  95.0k|#define SSH_KEX_METHODS 10
  ------------------
  |  Branch (507:21): [True: 86.4k, False: 8.62k]
  ------------------
  508|  86.4k|            crypto->server_kex.methods[i] = strings[i];
  509|  86.4k|        }
  510|  8.62k|    }
  511|       |
  512|       |    /*
  513|       |     * Handle the two final fields for the KEXINIT message (RFC 4253 7.1):
  514|       |     *
  515|       |     *      boolean      first_kex_packet_follows
  516|       |     *      uint32       0 (reserved for future extension)
  517|       |     *
  518|       |     * Notably if clients set 'first_kex_packet_follows', it is expected
  519|       |     * that its value is included when computing the session ID (see
  520|       |     * 'make_sessionid').
  521|       |     */
  522|       |
  523|  17.2k|    rc = ssh_buffer_get_u8(packet, &first_kex_packet_follows);
  524|  17.2k|    if (rc != 1) {
  ------------------
  |  Branch (524:9): [True: 0, False: 17.2k]
  ------------------
  525|      0|        goto error;
  526|      0|    }
  527|       |
  528|  17.2k|    rc = ssh_buffer_add_u8(session->in_hashbuf, first_kex_packet_follows);
  529|  17.2k|    if (rc < 0) {
  ------------------
  |  Branch (529:9): [True: 0, False: 17.2k]
  ------------------
  530|      0|        goto error;
  531|      0|    }
  532|       |
  533|  17.2k|    rc = ssh_buffer_add_u32(session->in_hashbuf, kexinit_reserved);
  534|  17.2k|    if (rc < 0) {
  ------------------
  |  Branch (534:9): [True: 0, False: 17.2k]
  ------------------
  535|      0|        goto error;
  536|      0|    }
  537|       |
  538|       |    /*
  539|       |     * Remember whether 'first_kex_packet_follows' was set and the client
  540|       |     * guess was wrong: in this case the next SSH_MSG_KEXDH_INIT message
  541|       |     * must be ignored on the server side.
  542|       |     * Client needs to start the Key exchange over with the correct method
  543|       |     */
  544|  17.2k|    if (first_kex_packet_follows || session->send_first_kex_follows) {
  ------------------
  |  Branch (544:9): [True: 18.4E, False: 17.2k]
  |  Branch (544:37): [True: 1, False: 17.2k]
  ------------------
  545|      0|        char **client_methods = crypto->client_kex.methods;
  546|      0|        char **server_methods = crypto->server_kex.methods;
  547|      0|        session->first_kex_follows_guess_wrong =
  548|      0|            cmp_first_kex_algo(client_methods[SSH_KEX],
  ------------------
  |  Branch (548:13): [True: 0, False: 0]
  ------------------
  549|      0|                               server_methods[SSH_KEX]) ||
  550|      0|            cmp_first_kex_algo(client_methods[SSH_HOSTKEYS],
  ------------------
  |  Branch (550:13): [True: 0, False: 0]
  ------------------
  551|      0|                               server_methods[SSH_HOSTKEYS]);
  552|      0|            SSH_LOG(SSH_LOG_DEBUG, "The initial guess was %s.",
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (281:34): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  553|      0|                    session->first_kex_follows_guess_wrong ? "wrong" : "right");
  554|      0|    }
  555|       |
  556|       |    /*
  557|       |     * handle the "strict KEX" feature. If supported by peer, then set up the
  558|       |     * flag and verify packet sequence numbers.
  559|       |     */
  560|  17.2k|    if (server_kex) {
  ------------------
  |  Branch (560:9): [True: 8.64k, False: 8.62k]
  ------------------
  561|  8.64k|        ok = match_group(crypto->client_kex.methods[SSH_KEX],
  562|  8.64k|                         KEX_STRICT_CLIENT);
  ------------------
  |  |  196|  8.64k|#define KEX_STRICT_CLIENT "kex-strict-c-v00@openssh.com"
  ------------------
  563|  8.64k|        if (ok) {
  ------------------
  |  Branch (563:13): [True: 8.64k, False: 0]
  ------------------
  564|  8.64k|            SSH_LOG(SSH_LOG_DEBUG, "Client supports strict kex, enabling.");
  ------------------
  |  |  281|  8.64k|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  565|  8.64k|            session->flags |= SSH_SESSION_FLAG_KEX_STRICT;
  ------------------
  |  |   90|  8.64k|#define SSH_SESSION_FLAG_KEX_STRICT 0x0010
  ------------------
  566|  8.64k|        }
  567|  8.64k|    } else {
  568|       |        /* client kex */
  569|  8.62k|        ok = match_group(crypto->server_kex.methods[SSH_KEX],
  570|  8.62k|                         KEX_STRICT_SERVER);
  ------------------
  |  |  197|  8.62k|#define KEX_STRICT_SERVER "kex-strict-s-v00@openssh.com"
  ------------------
  571|  8.64k|        if (ok) {
  ------------------
  |  Branch (571:13): [True: 8.64k, False: 18.4E]
  ------------------
  572|  8.64k|            SSH_LOG(SSH_LOG_DEBUG, "Server supports strict kex, enabling.");
  ------------------
  |  |  281|  8.64k|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  573|  8.64k|            session->flags |= SSH_SESSION_FLAG_KEX_STRICT;
  ------------------
  |  |   90|  8.64k|#define SSH_SESSION_FLAG_KEX_STRICT 0x0010
  ------------------
  574|  8.64k|        }
  575|  8.62k|    }
  576|  17.2k|#ifdef WITH_SERVER
  577|  17.2k|    if (server_kex) {
  ------------------
  |  Branch (577:9): [True: 8.64k, False: 8.62k]
  ------------------
  578|       |        /*
  579|       |         * If client sent a ext-info-c message in the kex list, it supports
  580|       |         * RFC 8308 extension negotiation.
  581|       |         */
  582|  8.64k|        ok = match_group(crypto->client_kex.methods[SSH_KEX],
  583|  8.64k|                         KEX_EXTENSION_CLIENT);
  ------------------
  |  |  194|  8.64k|#define KEX_EXTENSION_CLIENT "ext-info-c"
  ------------------
  584|  8.64k|        if (ok) {
  ------------------
  |  Branch (584:13): [True: 8.64k, False: 0]
  ------------------
  585|  8.64k|            const char *hostkeys = NULL, *wanted_hostkeys = NULL;
  586|       |
  587|       |            /* The client supports extension negotiation */
  588|  8.64k|            session->extensions |= SSH_EXT_NEGOTIATION;
  ------------------
  |  |  123|  8.64k|#define SSH_EXT_NEGOTIATION     0x01
  ------------------
  589|       |            /*
  590|       |             * RFC 8332 Section 3.1: Use for Server Authentication
  591|       |             * Check what algorithms were provided in the SSH_HOSTKEYS list
  592|       |             * by the client and enable the respective extensions to provide
  593|       |             * correct signature in the next packet if RSA is negotiated
  594|       |             */
  595|  8.64k|            hostkeys = crypto->client_kex.methods[SSH_HOSTKEYS];
  596|  8.64k|            wanted_hostkeys = session->opts.wanted_methods[SSH_HOSTKEYS];
  597|  8.64k|            ok = match_group(hostkeys, "rsa-sha2-512");
  598|  8.64k|            if (ok) {
  ------------------
  |  Branch (598:17): [True: 8.64k, False: 0]
  ------------------
  599|       |                /* Check if rsa-sha2-512 is allowed by config */
  600|  8.64k|                if (wanted_hostkeys != NULL) {
  ------------------
  |  Branch (600:21): [True: 8.64k, False: 0]
  ------------------
  601|  8.64k|                    char *is_allowed = ssh_find_matching(wanted_hostkeys,
  602|  8.64k|                                                         "rsa-sha2-512");
  603|  8.64k|                    if (is_allowed != NULL) {
  ------------------
  |  Branch (603:25): [True: 0, False: 8.64k]
  ------------------
  604|      0|                        session->extensions |= SSH_EXT_SIG_RSA_SHA512;
  ------------------
  |  |  126|      0|#define SSH_EXT_SIG_RSA_SHA512  0x04
  ------------------
  605|      0|                    }
  606|  8.64k|                    SAFE_FREE(is_allowed);
  ------------------
  |  |  373|  8.64k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 8.64k]
  |  |  |  Branch (373:71): [Folded, False: 8.64k]
  |  |  ------------------
  ------------------
  607|  8.64k|                }
  608|  8.64k|            }
  609|  8.64k|            ok = match_group(hostkeys, "rsa-sha2-256");
  610|  8.64k|            if (ok) {
  ------------------
  |  Branch (610:17): [True: 8.64k, False: 0]
  ------------------
  611|       |                /* Check if rsa-sha2-256 is allowed by config */
  612|  8.64k|                if (wanted_hostkeys != NULL) {
  ------------------
  |  Branch (612:21): [True: 8.64k, False: 0]
  ------------------
  613|  8.64k|                    char *is_allowed = ssh_find_matching(wanted_hostkeys,
  614|  8.64k|                                                         "rsa-sha2-256");
  615|  8.64k|                    if (is_allowed != NULL) {
  ------------------
  |  Branch (615:25): [True: 0, False: 8.64k]
  ------------------
  616|      0|                        session->extensions |= SSH_EXT_SIG_RSA_SHA256;
  ------------------
  |  |  125|      0|#define SSH_EXT_SIG_RSA_SHA256  0x02
  ------------------
  617|      0|                    }
  618|  8.64k|                    SAFE_FREE(is_allowed);
  ------------------
  |  |  373|  8.64k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 8.64k]
  |  |  |  Branch (373:71): [Folded, False: 8.64k]
  |  |  ------------------
  ------------------
  619|  8.64k|                }
  620|  8.64k|            }
  621|       |
  622|       |            /*
  623|       |             * Ensure that the client preference is honored for the case
  624|       |             * both signature types are enabled.
  625|       |             */
  626|  8.64k|            if ((session->extensions & SSH_EXT_SIG_RSA_SHA256) &&
  ------------------
  |  |  125|  8.64k|#define SSH_EXT_SIG_RSA_SHA256  0x02
  ------------------
  |  Branch (626:17): [True: 0, False: 8.64k]
  ------------------
  627|      0|                (session->extensions & SSH_EXT_SIG_RSA_SHA512)) {
  ------------------
  |  |  126|      0|#define SSH_EXT_SIG_RSA_SHA512  0x04
  ------------------
  |  Branch (627:17): [True: 0, False: 0]
  ------------------
  628|      0|                char *rsa_sig_ext = NULL;
  629|      0|                session->extensions &= ~(SSH_EXT_SIG_RSA_SHA256 | SSH_EXT_SIG_RSA_SHA512);
  ------------------
  |  |  125|      0|#define SSH_EXT_SIG_RSA_SHA256  0x02
  ------------------
                              session->extensions &= ~(SSH_EXT_SIG_RSA_SHA256 | SSH_EXT_SIG_RSA_SHA512);
  ------------------
  |  |  126|      0|#define SSH_EXT_SIG_RSA_SHA512  0x04
  ------------------
  630|      0|                rsa_sig_ext = ssh_find_matching("rsa-sha2-512,rsa-sha2-256",
  631|      0|                                                hostkeys);
  632|      0|                if (rsa_sig_ext == NULL) {
  ------------------
  |  Branch (632:21): [True: 0, False: 0]
  ------------------
  633|      0|                    goto error; /* should never happen */
  634|      0|                } else if (strcmp(rsa_sig_ext, "rsa-sha2-512") == 0) {
  ------------------
  |  Branch (634:28): [True: 0, False: 0]
  ------------------
  635|      0|                    session->extensions |= SSH_EXT_SIG_RSA_SHA512;
  ------------------
  |  |  126|      0|#define SSH_EXT_SIG_RSA_SHA512  0x04
  ------------------
  636|      0|                } else if (strcmp(rsa_sig_ext, "rsa-sha2-256") == 0) {
  ------------------
  |  Branch (636:28): [True: 0, False: 0]
  ------------------
  637|      0|                    session->extensions |= SSH_EXT_SIG_RSA_SHA256;
  ------------------
  |  |  125|      0|#define SSH_EXT_SIG_RSA_SHA256  0x02
  ------------------
  638|      0|                } else {
  639|      0|                    SAFE_FREE(rsa_sig_ext);
  ------------------
  |  |  373|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
  640|      0|                    goto error; /* should never happen */
  641|      0|                }
  642|      0|                SAFE_FREE(rsa_sig_ext);
  ------------------
  |  |  373|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
  643|      0|            }
  644|       |
  645|  8.64k|            SSH_LOG(SSH_LOG_DEBUG, "The client supports extension "
  ------------------
  |  |  281|  34.5k|    _ssh_log(priority, __func__, __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (281:34): [True: 0, False: 8.64k]
  |  |  |  Branch (281:34): [True: 0, False: 8.64k]
  |  |  ------------------
  ------------------
  646|  8.64k|                    "negotiation. Enabled signature algorithms: %s%s",
  647|  8.64k|                    session->extensions & SSH_EXT_SIG_RSA_SHA256 ? "SHA256" : "",
  648|  8.64k|                    session->extensions & SSH_EXT_SIG_RSA_SHA512 ? " SHA512" : "");
  649|  8.64k|        }
  650|  8.64k|    }
  651|  17.2k|#endif /* WITH_SERVER */
  652|       |
  653|       |    /* Note, that his overwrites authenticated state in case of rekeying */
  654|  17.2k|    session->session_state = SSH_SESSION_STATE_KEXINIT_RECEIVED;
  655|       |    /* if we already sent our initial key exchange packet, do not reset the
  656|       |     * DH state. We will know if we were right with our guess only in
  657|       |     * dh_handshake_state() */
  658|  17.2k|    if (session->send_first_kex_follows == false) {
  ------------------
  |  Branch (658:9): [True: 17.2k, False: 18.4E]
  ------------------
  659|  17.2k|        session->dh_handshake_state = DH_STATE_INIT;
  660|  17.2k|    }
  661|  17.2k|    session->ssh_connection_callback(session);
  662|  17.2k|    return SSH_PACKET_USED;
  ------------------
  |  |  637|  17.2k|#define SSH_PACKET_USED 1
  ------------------
  663|       |
  664|      0|error:
  665|      0|    SSH_STRING_FREE(str);
  ------------------
  |  |  893|      0|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (893:14): [True: 0, False: 0]
  |  |  |  Branch (893:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
  666|      0|    for (i = 0; i < SSH_KEX_METHODS; i++) {
  ------------------
  |  |   27|      0|#define SSH_KEX_METHODS 10
  ------------------
  |  Branch (666:17): [True: 0, False: 0]
  ------------------
  667|      0|        if (server_kex) {
  ------------------
  |  Branch (667:13): [True: 0, False: 0]
  ------------------
  668|      0|#ifdef WITH_SERVER
  669|      0|            session->next_crypto->client_kex.methods[i] = NULL;
  670|      0|#endif /* WITH_SERVER */
  671|      0|        } else { /* client */
  672|      0|            session->next_crypto->server_kex.methods[i] = NULL;
  673|      0|        }
  674|      0|        SAFE_FREE(strings[i]);
  ------------------
  |  |  373|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
  675|      0|    }
  676|       |
  677|      0|    session->session_state = SSH_SESSION_STATE_ERROR;
  678|       |
  679|      0|    return SSH_PACKET_USED;
  ------------------
  |  |  637|      0|#define SSH_PACKET_USED 1
  ------------------
  680|  17.2k|}
ssh_list_kex:
  682|  34.5k|void ssh_list_kex(struct ssh_kex_struct *kex) {
  683|  34.5k|  int i = 0;
  684|       |
  685|       |#ifdef DEBUG_CRYPTO
  686|       |  ssh_log_hexdump("session cookie", kex->cookie, 16);
  687|       |#endif
  688|       |
  689|   379k|  for(i = 0; i < SSH_KEX_METHODS; i++) {
  ------------------
  |  |   27|   379k|#define SSH_KEX_METHODS 10
  ------------------
  |  Branch (689:14): [True: 344k, False: 34.5k]
  ------------------
  690|   344k|    if (kex->methods[i] == NULL) {
  ------------------
  |  Branch (690:9): [True: 0, False: 344k]
  ------------------
  691|      0|      continue;
  692|      0|    }
  693|   344k|    SSH_LOG(SSH_LOG_FUNCTIONS, "%s: %s",
  ------------------
  |  |  281|   344k|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  694|   344k|        ssh_kex_descriptions[i], kex->methods[i]);
  695|   344k|  }
  696|  34.5k|}
ssh_client_select_hostkeys:
  708|  8.64k|{
  709|  8.64k|    const char *wanted = NULL;
  710|  8.64k|    char *wanted_without_certs = NULL;
  711|  8.64k|    char *known_hosts_algorithms = NULL;
  712|  8.64k|    char *known_hosts_ordered = NULL;
  713|  8.64k|    char *new_hostkeys = NULL;
  714|  8.64k|    char *fips_hostkeys = NULL;
  715|       |
  716|  8.64k|    wanted = session->opts.wanted_methods[SSH_HOSTKEYS];
  717|  8.64k|    if (wanted == NULL) {
  ------------------
  |  Branch (717:9): [True: 8.64k, False: 0]
  ------------------
  718|  8.64k|        if (ssh_fips_mode()) {
  ------------------
  |  |  115|  8.64k|#define ssh_fips_mode() (FIPS_mode() != 0)
  |  |  ------------------
  |  |  |  Branch (115:25): [True: 0, False: 8.64k]
  |  |  ------------------
  ------------------
  719|      0|            wanted = ssh_kex_get_fips_methods(SSH_HOSTKEYS);
  720|  8.64k|        } else {
  721|  8.64k|            wanted = ssh_kex_get_default_methods(SSH_HOSTKEYS);
  722|  8.64k|        }
  723|  8.64k|    }
  724|       |
  725|       |    /* This removes the certificate types, unsupported for now */
  726|  8.64k|    wanted_without_certs = ssh_find_all_matching(HOSTKEYS, wanted);
  ------------------
  |  |  142|  8.64k|#define HOSTKEYS "ssh-ed25519," \
  |  |  143|  8.64k|                 EC_HOSTKEYS \
  |  |  144|  8.64k|                 "sk-ssh-ed25519@openssh.com," \
  |  |  145|  8.64k|                 EC_SK_HOSTKEYS \
  |  |  146|  8.64k|                 "rsa-sha2-512," \
  |  |  147|  8.64k|                 "rsa-sha2-256," \
  |  |  148|  8.64k|                 "ssh-rsa"
  ------------------
  727|  8.64k|    if (wanted_without_certs == NULL) {
  ------------------
  |  Branch (727:9): [True: 0, False: 8.64k]
  ------------------
  728|      0|        SSH_LOG(SSH_LOG_TRACE,
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  729|      0|                "List of allowed host key algorithms is empty or contains only "
  730|      0|                "unsupported algorithms");
  731|      0|        return NULL;
  732|      0|    }
  733|       |
  734|  8.64k|    SSH_LOG(SSH_LOG_DEBUG,
  ------------------
  |  |  281|  8.64k|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  735|  8.64k|            "Order of wanted host keys: \"%s\"",
  736|  8.64k|            wanted_without_certs);
  737|       |
  738|  8.64k|    known_hosts_algorithms = ssh_known_hosts_get_algorithms_names(session);
  739|  8.64k|    if (known_hosts_algorithms == NULL) {
  ------------------
  |  Branch (739:9): [True: 8.64k, False: 0]
  ------------------
  740|  8.64k|        SSH_LOG(SSH_LOG_DEBUG,
  ------------------
  |  |  281|  8.64k|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  741|  8.64k|                "No key found in known_hosts; "
  742|  8.64k|                "changing host key method to \"%s\"",
  743|  8.64k|                wanted_without_certs);
  744|       |
  745|  8.64k|        return wanted_without_certs;
  746|  8.64k|    }
  747|       |
  748|      0|    SSH_LOG(SSH_LOG_DEBUG,
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  749|      0|            "Algorithms found in known_hosts files: \"%s\"",
  750|      0|            known_hosts_algorithms);
  751|       |
  752|       |    /* Filter and order the keys from known_hosts according to wanted list */
  753|      0|    known_hosts_ordered = ssh_find_all_matching(known_hosts_algorithms,
  754|      0|                                                wanted_without_certs);
  755|      0|    SAFE_FREE(known_hosts_algorithms);
  ------------------
  |  |  373|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
  756|      0|    if (known_hosts_ordered == NULL) {
  ------------------
  |  Branch (756:9): [True: 0, False: 0]
  ------------------
  757|      0|        SSH_LOG(SSH_LOG_DEBUG,
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  758|      0|                "No key found in known_hosts is allowed; "
  759|      0|                "changing host key method to \"%s\"",
  760|      0|                wanted_without_certs);
  761|       |
  762|      0|        return wanted_without_certs;
  763|      0|    }
  764|       |
  765|       |    /* Append the other supported keys after the preferred ones
  766|       |     * This function tolerates NULL pointers in parameters */
  767|      0|    new_hostkeys = ssh_append_without_duplicates(known_hosts_ordered,
  768|      0|                                                 wanted_without_certs);
  769|      0|    SAFE_FREE(known_hosts_ordered);
  ------------------
  |  |  373|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
  770|      0|    SAFE_FREE(wanted_without_certs);
  ------------------
  |  |  373|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
  771|      0|    if (new_hostkeys == NULL) {
  ------------------
  |  Branch (771:9): [True: 0, False: 0]
  ------------------
  772|      0|        ssh_set_error_oom(session);
  ------------------
  |  |  318|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
  773|      0|        return NULL;
  774|      0|    }
  775|       |
  776|      0|    if (ssh_fips_mode()) {
  ------------------
  |  |  115|      0|#define ssh_fips_mode() (FIPS_mode() != 0)
  |  |  ------------------
  |  |  |  Branch (115:25): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  777|       |        /* Filter out algorithms not allowed in FIPS mode */
  778|      0|        fips_hostkeys = ssh_keep_fips_algos(SSH_HOSTKEYS, new_hostkeys);
  779|      0|        SAFE_FREE(new_hostkeys);
  ------------------
  |  |  373|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
  780|      0|        if (fips_hostkeys == NULL) {
  ------------------
  |  Branch (780:13): [True: 0, False: 0]
  ------------------
  781|      0|            SSH_LOG(SSH_LOG_TRACE,
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  782|      0|                    "None of the wanted host keys or keys in known_hosts files "
  783|      0|                    "is allowed in FIPS mode.");
  784|      0|            return NULL;
  785|      0|        }
  786|      0|        new_hostkeys = fips_hostkeys;
  787|      0|    }
  788|       |
  789|      0|    SSH_LOG(SSH_LOG_DEBUG,
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  790|      0|            "Changing host key method to \"%s\"",
  791|      0|            new_hostkeys);
  792|       |
  793|      0|    return new_hostkeys;
  794|      0|}
ssh_set_client_kex:
  801|  17.2k|{
  802|  17.2k|    struct ssh_kex_struct *client = &session->next_crypto->client_kex;
  803|  17.2k|    const char *wanted = NULL;
  804|  17.2k|    int ok;
  805|  17.2k|    int i;
  806|  17.2k|    bool gssapi_null_alg = false;
  807|  17.2k|    char *hostkeys = NULL;
  808|       |
  809|       |    /* Skip if already set, for example for the rekey or when we do the guessing
  810|       |     * it could have been already used to make some protocol decisions. */
  811|  17.2k|    if (client->methods[0] != NULL) {
  ------------------
  |  Branch (811:9): [True: 8.64k, False: 8.64k]
  ------------------
  812|  8.64k|        return SSH_OK;
  ------------------
  |  |  316|  8.64k|#define SSH_OK 0     /* No error */
  ------------------
  813|  8.64k|    }
  814|       |
  815|  8.64k|    ok = ssh_get_random(client->cookie, 16, 0);
  816|  8.64k|    if (!ok) {
  ------------------
  |  Branch (816:9): [True: 0, False: 8.64k]
  ------------------
  817|      0|        ssh_set_error(session, SSH_FATAL, "PRNG error");
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  818|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  819|      0|    }
  820|       |#ifdef WITH_GSSAPI
  821|       |    if (session->opts.gssapi_key_exchange) {
  822|       |        char *gssapi_algs = NULL;
  823|       |
  824|       |        ok = ssh_gssapi_init(session);
  825|       |        if (ok != SSH_OK) {
  826|       |            ssh_set_error_oom(session);
  827|       |            return SSH_ERROR;
  828|       |        }
  829|       |
  830|       |        ok = ssh_gssapi_import_name(session->gssapi, session->opts.host);
  831|       |        if (ok != SSH_OK) {
  832|       |            return SSH_ERROR;
  833|       |        }
  834|       |
  835|       |        gssapi_algs = ssh_gssapi_kex_mechs(session);
  836|       |        if (gssapi_algs == NULL) {
  837|       |            return SSH_ERROR;
  838|       |        }
  839|       |
  840|       |        /* Prefix the default algorithms with gsskex algs */
  841|       |        if (ssh_fips_mode()) {
  842|       |            session->opts.wanted_methods[SSH_KEX] =
  843|       |                ssh_prefix_without_duplicates(fips_methods[SSH_KEX],
  844|       |                                              gssapi_algs);
  845|       |        } else {
  846|       |            session->opts.wanted_methods[SSH_KEX] =
  847|       |                ssh_prefix_without_duplicates(default_methods[SSH_KEX],
  848|       |                                              gssapi_algs);
  849|       |        }
  850|       |
  851|       |        gssapi_null_alg = true;
  852|       |
  853|       |        SAFE_FREE(gssapi_algs);
  854|       |    }
  855|       |#endif
  856|       |
  857|       |    /* Set the list of allowed algorithms in order of preference, if it hadn't
  858|       |     * been set yet. */
  859|  95.0k|    for (i = 0; i < SSH_KEX_METHODS; i++) {
  ------------------
  |  |   27|  95.0k|#define SSH_KEX_METHODS 10
  ------------------
  |  Branch (859:17): [True: 86.4k, False: 8.64k]
  ------------------
  860|  86.4k|        if (i == SSH_HOSTKEYS) {
  ------------------
  |  Branch (860:13): [True: 8.64k, False: 77.7k]
  ------------------
  861|       |            /* Set the hostkeys in the following order:
  862|       |             * - First: keys present in known_hosts files ordered by preference
  863|       |             * - Next: other wanted algorithms ordered by preference */
  864|  8.64k|            client->methods[i] = ssh_client_select_hostkeys(session);
  865|  8.64k|            if (client->methods[i] == NULL) {
  ------------------
  |  Branch (865:17): [True: 0, False: 8.64k]
  ------------------
  866|      0|                ssh_set_error_oom(session);
  ------------------
  |  |  318|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
  867|      0|                return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  868|      0|            }
  869|  8.64k|            if (gssapi_null_alg) {
  ------------------
  |  Branch (869:17): [True: 0, False: 8.64k]
  ------------------
  870|      0|                hostkeys =
  871|      0|                    ssh_append_without_duplicates(client->methods[i], "null");
  872|      0|                if (hostkeys == NULL) {
  ------------------
  |  Branch (872:21): [True: 0, False: 0]
  ------------------
  873|      0|                    ssh_set_error_oom(session);
  ------------------
  |  |  318|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
  874|      0|                    return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  875|      0|                }
  876|      0|                SAFE_FREE(client->methods[i]);
  ------------------
  |  |  373|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
  877|      0|                client->methods[i] = hostkeys;
  878|      0|            }
  879|  8.64k|            continue;
  880|  8.64k|        }
  881|       |
  882|  77.7k|        wanted = session->opts.wanted_methods[i];
  883|  77.7k|        if (wanted == NULL) {
  ------------------
  |  Branch (883:13): [True: 43.2k, False: 34.5k]
  ------------------
  884|  43.2k|            if (ssh_fips_mode()) {
  ------------------
  |  |  115|  43.2k|#define ssh_fips_mode() (FIPS_mode() != 0)
  |  |  ------------------
  |  |  |  Branch (115:25): [True: 0, False: 43.2k]
  |  |  ------------------
  ------------------
  885|      0|                wanted = fips_methods[i];
  886|  43.2k|            } else {
  887|  43.2k|                wanted = default_methods[i];
  888|  43.2k|            }
  889|  43.2k|        }
  890|  77.7k|        client->methods[i] = strdup(wanted);
  891|  77.7k|        if (client->methods[i] == NULL) {
  ------------------
  |  Branch (891:13): [True: 0, False: 77.7k]
  ------------------
  892|      0|            ssh_set_error_oom(session);
  ------------------
  |  |  318|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
  893|      0|            return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  894|      0|        }
  895|  77.7k|    }
  896|       |
  897|       |    /* For rekeying, skip the extension negotiation */
  898|  8.64k|    if (session->flags & SSH_SESSION_FLAG_AUTHENTICATED) {
  ------------------
  |  |   78|  8.64k|#define SSH_SESSION_FLAG_AUTHENTICATED 0x0002
  ------------------
  |  Branch (898:9): [True: 0, False: 8.64k]
  ------------------
  899|      0|        return SSH_OK;
  ------------------
  |  |  316|      0|#define SSH_OK 0     /* No error */
  ------------------
  900|      0|    }
  901|       |
  902|  8.64k|    ok = ssh_kex_append_extensions(session, client);
  903|  8.64k|    if (ok != SSH_OK){
  ------------------
  |  |  316|  8.64k|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (903:9): [True: 0, False: 8.64k]
  ------------------
  904|      0|        return ok;
  905|      0|    }
  906|       |
  907|  8.64k|    return SSH_OK;
  ------------------
  |  |  316|  8.64k|#define SSH_OK 0     /* No error */
  ------------------
  908|  8.64k|}
ssh_kex_append_extensions:
  911|  17.2k|{
  912|  17.2k|    char *kex = NULL;
  913|  17.2k|    char *kex_tmp = NULL;
  914|  17.2k|    size_t kex_len, len;
  915|       |
  916|       |    /* Here we append ext-info-c and kex-strict-c-v00@openssh.com for client
  917|       |     * and kex-strict-s-v00@openssh.com for server to the list of kex algorithms
  918|       |     */
  919|  17.2k|    kex = pkex->methods[SSH_KEX];
  920|  17.2k|    len = strlen(kex);
  921|  17.2k|    if (session->server) {
  ------------------
  |  Branch (921:9): [True: 8.64k, False: 8.64k]
  ------------------
  922|       |        /* Comma, nul byte */
  923|  8.64k|        kex_len = len + 1 + strlen(KEX_STRICT_SERVER) + 1;
  ------------------
  |  |  197|  8.64k|#define KEX_STRICT_SERVER "kex-strict-s-v00@openssh.com"
  ------------------
  924|  8.64k|    } else {
  925|       |        /* Comma, comma, nul byte */
  926|  8.64k|        kex_len = len + 1 + strlen(KEX_EXTENSION_CLIENT) + 1 +
  ------------------
  |  |  194|  8.64k|#define KEX_EXTENSION_CLIENT "ext-info-c"
  ------------------
  927|  8.64k|                  strlen(KEX_STRICT_CLIENT) + 1;
  ------------------
  |  |  196|  8.64k|#define KEX_STRICT_CLIENT "kex-strict-c-v00@openssh.com"
  ------------------
  928|  8.64k|    }
  929|  17.2k|    if (kex_len >= MAX_PACKET_LEN) {
  ------------------
  |  |  216|  17.2k|#define MAX_PACKET_LEN 262144
  ------------------
  |  Branch (929:9): [True: 0, False: 17.2k]
  ------------------
  930|       |        /* Overflow */
  931|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  932|      0|    }
  933|  17.2k|    kex_tmp = realloc(kex, kex_len);
  934|  17.2k|    if (kex_tmp == NULL) {
  ------------------
  |  Branch (934:9): [True: 0, False: 17.2k]
  ------------------
  935|      0|        ssh_set_error_oom(session);
  ------------------
  |  |  318|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
  936|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  937|      0|    }
  938|  17.2k|    if (session->server){
  ------------------
  |  Branch (938:9): [True: 8.64k, False: 8.64k]
  ------------------
  939|  8.64k|        snprintf(kex_tmp + len, kex_len - len, ",%s", KEX_STRICT_SERVER);
  ------------------
  |  |  197|  8.64k|#define KEX_STRICT_SERVER "kex-strict-s-v00@openssh.com"
  ------------------
  940|  8.64k|    } else {
  941|  8.64k|        snprintf(kex_tmp + len,
  942|  8.64k|                 kex_len - len,
  943|  8.64k|                 ",%s,%s",
  944|  8.64k|                 KEX_EXTENSION_CLIENT,
  ------------------
  |  |  194|  8.64k|#define KEX_EXTENSION_CLIENT "ext-info-c"
  ------------------
  945|  8.64k|                 KEX_STRICT_CLIENT);
  ------------------
  |  |  196|  8.64k|#define KEX_STRICT_CLIENT "kex-strict-c-v00@openssh.com"
  ------------------
  946|  8.64k|    }
  947|  17.2k|    pkex->methods[SSH_KEX] = kex_tmp;
  948|  17.2k|    return SSH_OK;
  ------------------
  |  |  316|  17.2k|#define SSH_OK 0     /* No error */
  ------------------
  949|  17.2k|}
ssh_kex_select_methods:
 1082|  17.2k|{
 1083|  17.2k|    struct ssh_crypto_struct *crypto = session->next_crypto;
 1084|  17.2k|    struct ssh_kex_struct *server = &crypto->server_kex;
 1085|  17.2k|    struct ssh_kex_struct *client = &crypto->client_kex;
 1086|  17.2k|    char *ext_start = NULL;
 1087|  17.2k|    const char *aead_hmac = NULL;
 1088|  17.2k|    enum ssh_key_exchange_e kex_type;
 1089|  17.2k|    int i;
 1090|       |
 1091|       |    /* Here we should drop the extensions from the list so we avoid matching.
 1092|       |     * it. We added it to the end, so we can just truncate the string here */
 1093|  17.2k|    if (session->client) {
  ------------------
  |  Branch (1093:9): [True: 8.64k, False: 8.63k]
  ------------------
 1094|  8.64k|        ext_start = strstr(client->methods[SSH_KEX], "," KEX_EXTENSION_CLIENT);
  ------------------
  |  |  194|  8.64k|#define KEX_EXTENSION_CLIENT "ext-info-c"
  ------------------
 1095|  8.64k|        if (ext_start != NULL) {
  ------------------
  |  Branch (1095:13): [True: 8.64k, False: 0]
  ------------------
 1096|  8.64k|            ext_start[0] = '\0';
 1097|  8.64k|        }
 1098|  8.64k|    }
 1099|  17.2k|    if (session->server) {
  ------------------
  |  Branch (1099:9): [True: 8.64k, False: 8.63k]
  ------------------
 1100|  8.64k|        ext_start = strstr(server->methods[SSH_KEX], "," KEX_STRICT_SERVER);
  ------------------
  |  |  197|  8.64k|#define KEX_STRICT_SERVER "kex-strict-s-v00@openssh.com"
  ------------------
 1101|  8.64k|        if (ext_start != NULL) {
  ------------------
  |  Branch (1101:13): [True: 8.64k, False: 0]
  ------------------
 1102|  8.64k|            ext_start[0] = '\0';
 1103|  8.64k|        }
 1104|  8.64k|    }
 1105|       |
 1106|   189k|    for (i = 0; i < SSH_KEX_METHODS; i++) {
  ------------------
  |  |   27|   189k|#define SSH_KEX_METHODS 10
  ------------------
  |  Branch (1106:17): [True: 172k, False: 17.2k]
  ------------------
 1107|   172k|        crypto->kex_methods[i] = ssh_find_matching(server->methods[i],
 1108|   172k|                                                   client->methods[i]);
 1109|       |
 1110|   172k|        if (i == SSH_MAC_C_S || i == SSH_MAC_S_C) {
  ------------------
  |  Branch (1110:13): [True: 16.7k, False: 155k]
  |  Branch (1110:33): [True: 17.2k, False: 138k]
  ------------------
 1111|  34.5k|            aead_hmac = ssh_find_aead_hmac(crypto->kex_methods[i - 2]);
 1112|  34.5k|            if (aead_hmac) {
  ------------------
  |  Branch (1112:17): [True: 0, False: 34.5k]
  ------------------
 1113|      0|                free(crypto->kex_methods[i]);
 1114|      0|                crypto->kex_methods[i] = strdup(aead_hmac);
 1115|      0|            }
 1116|  34.5k|        }
 1117|   172k|        if (crypto->kex_methods[i] == NULL && i < SSH_LANG_C_S) {
  ------------------
  |  Branch (1117:13): [True: 0, False: 172k]
  |  Branch (1117:47): [True: 0, False: 0]
  ------------------
 1118|      0|            ssh_set_error(session, SSH_FATAL,
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
 1119|      0|                          "kex error : no match for method %s: server [%s], "
 1120|      0|                          "client [%s]", ssh_kex_descriptions[i],
 1121|      0|                          server->methods[i], client->methods[i]);
 1122|      0|            return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 1123|   172k|        } else if ((i >= SSH_LANG_C_S) && (crypto->kex_methods[i] == NULL)) {
  ------------------
  |  Branch (1123:20): [True: 34.5k, False: 137k]
  |  Branch (1123:43): [True: 0, False: 34.5k]
  ------------------
 1124|       |            /* we can safely do that for languages */
 1125|      0|            crypto->kex_methods[i] = strdup("");
 1126|      0|        }
 1127|   172k|    }
 1128|       |
 1129|       |    /* We can not set this value directly as the old value is needed to revert
 1130|       |     * callbacks if we are client */
 1131|  17.2k|    kex_type = kex_select_kex_type(crypto->kex_methods[SSH_KEX]);
 1132|  17.2k|    if (session->client && session->first_kex_follows_guess_wrong) {
  ------------------
  |  Branch (1132:9): [True: 8.64k, False: 8.63k]
  |  Branch (1132:28): [True: 0, False: 8.64k]
  ------------------
 1133|      0|        SSH_LOG(SSH_LOG_DEBUG, "Our guess was wrong. Restarting the KEX");
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 1134|       |        /* We need to remove the wrong callbacks and start kex again */
 1135|      0|        revert_kex_callbacks(session);
 1136|      0|        session->dh_handshake_state = DH_STATE_INIT;
 1137|      0|        session->first_kex_follows_guess_wrong = false;
 1138|      0|    }
 1139|  17.2k|    crypto->kex_type = kex_type;
 1140|       |
 1141|  17.2k|    SSH_LOG(SSH_LOG_DEBUG, "Negotiated %s,%s,%s,%s,%s,%s,%s,%s,%s,%s",
  ------------------
  |  |  281|  17.2k|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 1142|  17.2k|            session->next_crypto->kex_methods[SSH_KEX],
 1143|  17.2k|            session->next_crypto->kex_methods[SSH_HOSTKEYS],
 1144|  17.2k|            session->next_crypto->kex_methods[SSH_CRYPT_C_S],
 1145|  17.2k|            session->next_crypto->kex_methods[SSH_CRYPT_S_C],
 1146|  17.2k|            session->next_crypto->kex_methods[SSH_MAC_C_S],
 1147|  17.2k|            session->next_crypto->kex_methods[SSH_MAC_S_C],
 1148|  17.2k|            session->next_crypto->kex_methods[SSH_COMP_C_S],
 1149|  17.2k|            session->next_crypto->kex_methods[SSH_COMP_S_C],
 1150|  17.2k|            session->next_crypto->kex_methods[SSH_LANG_C_S],
 1151|  17.2k|            session->next_crypto->kex_methods[SSH_LANG_S_C]
 1152|  17.2k|    );
 1153|  17.2k|    return SSH_OK;
  ------------------
  |  |  316|  17.2k|#define SSH_OK 0     /* No error */
  ------------------
 1154|  17.2k|}
ssh_send_kex:
 1159|  17.2k|{
 1160|  17.2k|    struct ssh_kex_struct *kex = (session->server ?
  ------------------
  |  Branch (1160:35): [True: 8.64k, False: 8.64k]
  ------------------
 1161|  8.64k|        &session->next_crypto->server_kex :
 1162|  17.2k|        &session->next_crypto->client_kex);
 1163|  17.2k|    ssh_string str = NULL;
 1164|  17.2k|    int i;
 1165|  17.2k|    int rc;
 1166|  17.2k|    int first_kex_packet_follows = 0;
 1167|       |
 1168|       |    /* Only client can initiate the handshake methods we implement. If we
 1169|       |     * already received the peer mechanisms, there is no point in guessing */
 1170|  17.2k|    if (session->client &&
  ------------------
  |  Branch (1170:9): [True: 8.64k, False: 8.64k]
  ------------------
 1171|  8.64k|        session->session_state != SSH_SESSION_STATE_KEXINIT_RECEIVED &&
  ------------------
  |  Branch (1171:9): [True: 8.64k, False: 0]
  ------------------
 1172|  8.64k|        session->send_first_kex_follows) {
  ------------------
  |  Branch (1172:9): [True: 0, False: 8.64k]
  ------------------
 1173|      0|        first_kex_packet_follows = 1;
 1174|      0|    }
 1175|       |
 1176|  17.2k|    SSH_LOG(SSH_LOG_TRACE,
  ------------------
  |  |  281|  17.2k|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 1177|  17.2k|            "Sending KEXINIT packet, first_kex_packet_follows = %d",
 1178|  17.2k|            first_kex_packet_follows);
 1179|       |
 1180|  17.2k|    rc = ssh_buffer_pack(session->out_buffer,
  ------------------
  |  |   50|  17.2k|    _ssh_buffer_pack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |  451|  17.2k|        (__VA_NARG_(__VA_ARGS__, __RSEQ_N()))
  |  |  |  |  ------------------
  |  |  |  |  |  |  453|  17.2k|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  448|  17.2k|#define VA_APPLY_VARIADIC_MACRO(macro, tuple) macro tuple
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  453|  17.2k|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  461|  17.2k|        _61,_62,_63,N,...) N
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                   _ssh_buffer_pack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |   28|  17.2k|#define SSH_BUFFER_PACK_END ((uint32_t) 0x4f65feb3)
  |  |  ------------------
  ------------------
 1181|  17.2k|                         "bP",
 1182|  17.2k|                         SSH2_MSG_KEXINIT,
 1183|  17.2k|                         (size_t)16,
 1184|  17.2k|                         kex->cookie); /* cookie */
 1185|  17.2k|    if (rc != SSH_OK)
  ------------------
  |  |  316|  17.2k|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (1185:9): [True: 0, False: 17.2k]
  ------------------
 1186|      0|        goto error;
 1187|  17.2k|    if (ssh_hashbufout_add_cookie(session) < 0) {
  ------------------
  |  Branch (1187:9): [True: 0, False: 17.2k]
  ------------------
 1188|      0|        goto error;
 1189|      0|    }
 1190|       |
 1191|  17.2k|    ssh_list_kex(kex);
 1192|       |
 1193|   189k|    for (i = 0; i < SSH_KEX_METHODS; i++) {
  ------------------
  |  |   27|   189k|#define SSH_KEX_METHODS 10
  ------------------
  |  Branch (1193:17): [True: 172k, False: 17.2k]
  ------------------
 1194|   172k|        str = ssh_string_from_char(kex->methods[i]);
 1195|   172k|        if (str == NULL) {
  ------------------
  |  Branch (1195:13): [True: 0, False: 172k]
  ------------------
 1196|      0|            goto error;
 1197|      0|        }
 1198|       |
 1199|   172k|        rc = ssh_buffer_add_ssh_string(session->out_hashbuf, str);
 1200|   172k|        if (rc < 0) {
  ------------------
  |  Branch (1200:13): [True: 0, False: 172k]
  ------------------
 1201|      0|            goto error;
 1202|      0|        }
 1203|   172k|        rc = ssh_buffer_add_ssh_string(session->out_buffer, str);
 1204|   172k|        if (rc < 0) {
  ------------------
  |  Branch (1204:13): [True: 0, False: 172k]
  ------------------
 1205|      0|            goto error;
 1206|      0|        }
 1207|   172k|        SSH_STRING_FREE(str);
  ------------------
  |  |  893|   172k|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (893:14): [True: 172k, False: 18.4E]
  |  |  |  Branch (893:69): [Folded, False: 172k]
  |  |  ------------------
  ------------------
 1208|   172k|        str = NULL;
 1209|   172k|    }
 1210|       |
 1211|  17.2k|    rc = ssh_buffer_pack(session->out_buffer,
  ------------------
  |  |   50|  17.2k|    _ssh_buffer_pack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |  451|  17.2k|        (__VA_NARG_(__VA_ARGS__, __RSEQ_N()))
  |  |  |  |  ------------------
  |  |  |  |  |  |  453|  17.2k|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  448|  17.2k|#define VA_APPLY_VARIADIC_MACRO(macro, tuple) macro tuple
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  453|  17.2k|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  461|  17.2k|        _61,_62,_63,N,...) N
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                   _ssh_buffer_pack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |   28|  17.2k|#define SSH_BUFFER_PACK_END ((uint32_t) 0x4f65feb3)
  |  |  ------------------
  ------------------
 1212|  17.2k|                         "bd",
 1213|  17.2k|                         first_kex_packet_follows,
 1214|  17.2k|                         0);
 1215|  17.2k|    if (rc != SSH_OK) {
  ------------------
  |  |  316|  17.2k|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (1215:9): [True: 0, False: 17.2k]
  ------------------
 1216|      0|        goto error;
 1217|      0|    }
 1218|       |
 1219|       |    /* Prepare also the first_kex_packet_follows and reserved to 0 */
 1220|  17.2k|    rc = ssh_buffer_add_u8(session->out_hashbuf, first_kex_packet_follows);
 1221|  17.2k|    if (rc < 0) {
  ------------------
  |  Branch (1221:9): [True: 0, False: 17.2k]
  ------------------
 1222|      0|        goto error;
 1223|      0|    }
 1224|  17.2k|    rc = ssh_buffer_add_u32(session->out_hashbuf, 0);
 1225|  17.2k|    if (rc < 0) {
  ------------------
  |  Branch (1225:9): [True: 0, False: 17.2k]
  ------------------
 1226|      0|        goto error;
 1227|      0|    }
 1228|       |
 1229|  17.2k|    rc = ssh_packet_send(session);
 1230|  17.2k|    if (rc == SSH_ERROR) {
  ------------------
  |  |  317|  17.2k|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  |  Branch (1230:9): [True: 0, False: 17.2k]
  ------------------
 1231|      0|        return -1;
 1232|      0|    }
 1233|       |
 1234|  17.2k|    session->flags |= SSH_SESSION_FLAG_KEXINIT_SENT;
  ------------------
  |  |   86|  17.2k|#define SSH_SESSION_FLAG_KEXINIT_SENT 0x0008
  ------------------
 1235|  17.2k|    SSH_LOG(SSH_LOG_PACKET, "SSH_MSG_KEXINIT sent");
  ------------------
  |  |  281|  17.2k|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 1236|       |
 1237|       |    /* If we indicated that we are sending the guessed key exchange packet,
 1238|       |     * do it now. The packet is simple, but we need to do some preparations */
 1239|  17.2k|    if (first_kex_packet_follows == 1) {
  ------------------
  |  Branch (1239:9): [True: 0, False: 17.2k]
  ------------------
 1240|      0|        char *list = kex->methods[SSH_KEX];
 1241|      0|        const char *colon = strchr(list, ',');
 1242|      0|        size_t kex_name_len = colon ? (size_t)(colon - list) : strlen(list);
  ------------------
  |  Branch (1242:31): [True: 0, False: 0]
  ------------------
 1243|      0|        char *kex_name = calloc(kex_name_len + 1, 1);
 1244|      0|        if (kex_name == NULL) {
  ------------------
  |  Branch (1244:13): [True: 0, False: 0]
  ------------------
 1245|      0|            ssh_set_error_oom(session);
  ------------------
  |  |  318|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
 1246|      0|            goto error;
 1247|      0|        }
 1248|      0|        snprintf(kex_name, kex_name_len + 1, "%.*s", (int)kex_name_len, list);
 1249|      0|        SSH_LOG(SSH_LOG_TRACE, "Sending the first kex packet for %s", kex_name);
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 1250|       |
 1251|      0|        session->next_crypto->kex_type = kex_select_kex_type(kex_name);
 1252|      0|        free(kex_name);
 1253|       |
 1254|       |        /* run the first step of the DH handshake */
 1255|      0|        session->dh_handshake_state = DH_STATE_INIT;
 1256|      0|        if (dh_handshake(session) == SSH_ERROR) {
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  |  Branch (1256:13): [True: 0, False: 0]
  ------------------
 1257|      0|            goto error;
 1258|      0|        }
 1259|      0|    }
 1260|  17.2k|    return 0;
 1261|       |
 1262|      0|error:
 1263|      0|    ssh_buffer_reinit(session->out_buffer);
 1264|      0|    ssh_buffer_reinit(session->out_hashbuf);
 1265|      0|    SSH_STRING_FREE(str);
  ------------------
  |  |  893|      0|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (893:14): [True: 0, False: 0]
  |  |  |  Branch (893:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1266|       |
 1267|      0|    return -1;
 1268|  17.2k|}
ssh_keep_known_algos:
 1324|  77.7k|{
 1325|  77.7k|    if (algo > SSH_LANG_S_C) {
  ------------------
  |  Branch (1325:9): [True: 0, False: 77.7k]
  ------------------
 1326|      0|        return NULL;
 1327|      0|    }
 1328|       |
 1329|  77.7k|    return ssh_find_all_matching(supported_methods[algo], list);
 1330|  77.7k|}
ssh_make_sessionid:
 1459|  17.2k|{
 1460|  17.2k|    ssh_string num = NULL;
 1461|  17.2k|    ssh_buffer server_hash = NULL;
 1462|  17.2k|    ssh_buffer client_hash = NULL;
 1463|  17.2k|    ssh_buffer buf = NULL;
 1464|  17.2k|    ssh_string server_pubkey_blob = NULL;
 1465|  17.2k|#if !defined(HAVE_LIBCRYPTO) || OPENSSL_VERSION_NUMBER < 0x30000000L
 1466|  17.2k|    const_bignum client_pubkey, server_pubkey;
 1467|       |#else
 1468|       |    bignum client_pubkey = NULL, server_pubkey = NULL;
 1469|       |#endif /* OPENSSL_VERSION_NUMBER */
 1470|  17.2k|#ifdef WITH_GEX
 1471|  17.2k|#if !defined(HAVE_LIBCRYPTO) || OPENSSL_VERSION_NUMBER < 0x30000000L
 1472|  17.2k|    const_bignum modulus, generator;
 1473|       |#else
 1474|       |    bignum modulus = NULL, generator = NULL;
 1475|       |#endif /* OPENSSL_VERSION_NUMBER */
 1476|  17.2k|#endif /* WITH_GEX */
 1477|  17.2k|    int rc = SSH_ERROR;
  ------------------
  |  |  317|  17.2k|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 1478|       |
 1479|  17.2k|    buf = ssh_buffer_new();
 1480|  17.2k|    if (buf == NULL) {
  ------------------
  |  Branch (1480:9): [True: 0, False: 17.2k]
  ------------------
 1481|      0|        ssh_set_error_oom(session);
  ------------------
  |  |  318|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
 1482|      0|        return rc;
 1483|      0|    }
 1484|       |
 1485|  17.2k|    rc = ssh_buffer_pack(buf,
  ------------------
  |  |   50|  17.2k|    _ssh_buffer_pack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |  451|  17.2k|        (__VA_NARG_(__VA_ARGS__, __RSEQ_N()))
  |  |  |  |  ------------------
  |  |  |  |  |  |  453|  17.2k|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  448|  17.2k|#define VA_APPLY_VARIADIC_MACRO(macro, tuple) macro tuple
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  453|  17.2k|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  461|  17.2k|        _61,_62,_63,N,...) N
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                   _ssh_buffer_pack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |   28|  17.2k|#define SSH_BUFFER_PACK_END ((uint32_t) 0x4f65feb3)
  |  |  ------------------
  ------------------
 1486|  17.2k|                         "ss",
 1487|  17.2k|                         session->clientbanner,
 1488|  17.2k|                         session->serverbanner);
 1489|  17.2k|    if (rc == SSH_ERROR) {
  ------------------
  |  |  317|  17.2k|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  |  Branch (1489:9): [True: 0, False: 17.2k]
  ------------------
 1490|      0|        ssh_set_error(session,
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
 1491|      0|                      SSH_FATAL,
 1492|      0|                      "Failed to pack client and server banner");
 1493|      0|        goto error;
 1494|      0|    }
 1495|       |
 1496|  17.2k|    if (session->client) {
  ------------------
  |  Branch (1496:9): [True: 8.64k, False: 8.64k]
  ------------------
 1497|  8.64k|        server_hash = session->in_hashbuf;
 1498|  8.64k|        client_hash = session->out_hashbuf;
 1499|  8.64k|    } else {
 1500|  8.64k|        server_hash = session->out_hashbuf;
 1501|  8.64k|        client_hash = session->in_hashbuf;
 1502|  8.64k|    }
 1503|       |
 1504|  17.2k|    rc = ssh_dh_get_next_server_publickey_blob(session, &server_pubkey_blob);
 1505|  17.2k|    if (rc != SSH_OK) {
  ------------------
  |  |  316|  17.2k|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (1505:9): [True: 0, False: 17.2k]
  ------------------
 1506|      0|        ssh_set_error(session,
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
 1507|      0|                      SSH_FATAL,
 1508|      0|                      "Failed to get next server pubkey blob");
 1509|      0|        goto error;
 1510|      0|    }
 1511|       |
 1512|  17.2k|    if (server_pubkey_blob == NULL) {
  ------------------
  |  Branch (1512:9): [True: 0, False: 17.2k]
  ------------------
 1513|      0|        if ((session->server && ssh_kex_is_gss(session->next_crypto)) ||
  ------------------
  |  Branch (1513:14): [True: 0, False: 0]
  |  Branch (1513:33): [True: 0, False: 0]
  ------------------
 1514|      0|            session->opts.gssapi_key_exchange) {
  ------------------
  |  Branch (1514:13): [True: 0, False: 0]
  ------------------
 1515|      0|            server_pubkey_blob = ssh_string_new(0);
 1516|      0|            if (server_pubkey_blob == NULL) {
  ------------------
  |  Branch (1516:17): [True: 0, False: 0]
  ------------------
 1517|      0|                ssh_set_error_oom(session);
  ------------------
  |  |  318|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
 1518|      0|                rc = SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 1519|      0|                goto error;
 1520|      0|            }
 1521|      0|        }
 1522|      0|    }
 1523|       |
 1524|  17.2k|    rc = ssh_buffer_pack(buf,
  ------------------
  |  |   50|  17.2k|    _ssh_buffer_pack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |  451|  17.2k|        (__VA_NARG_(__VA_ARGS__, __RSEQ_N()))
  |  |  |  |  ------------------
  |  |  |  |  |  |  453|  17.2k|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  448|  17.2k|#define VA_APPLY_VARIADIC_MACRO(macro, tuple) macro tuple
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  453|  17.2k|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  461|  17.2k|        _61,_62,_63,N,...) N
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                   _ssh_buffer_pack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |   28|  17.2k|#define SSH_BUFFER_PACK_END ((uint32_t) 0x4f65feb3)
  |  |  ------------------
  ------------------
 1525|  17.2k|                         "dPdPS",
 1526|  17.2k|                         ssh_buffer_get_len(client_hash),
 1527|  17.2k|                         (size_t)ssh_buffer_get_len(client_hash),
 1528|  17.2k|                         ssh_buffer_get(client_hash),
 1529|  17.2k|                         ssh_buffer_get_len(server_hash),
 1530|  17.2k|                         (size_t)ssh_buffer_get_len(server_hash),
 1531|  17.2k|                         ssh_buffer_get(server_hash),
 1532|  17.2k|                         server_pubkey_blob);
 1533|  17.2k|    SSH_STRING_FREE(server_pubkey_blob);
  ------------------
  |  |  893|  17.2k|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (893:14): [True: 17.2k, False: 0]
  |  |  |  Branch (893:69): [Folded, False: 17.2k]
  |  |  ------------------
  ------------------
 1534|  17.2k|    if (rc != SSH_OK){
  ------------------
  |  |  316|  17.2k|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (1534:9): [True: 0, False: 17.2k]
  ------------------
 1535|      0|        ssh_set_error(session,
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
 1536|      0|                      SSH_FATAL,
 1537|      0|                      "Failed to pack hashes and pubkey blob");
 1538|      0|        goto error;
 1539|      0|    }
 1540|       |
 1541|  17.2k|    switch(session->next_crypto->kex_type) {
 1542|      0|    case SSH_KEX_DH_GROUP1_SHA1:
  ------------------
  |  Branch (1542:5): [True: 0, False: 17.2k]
  ------------------
 1543|      0|    case SSH_KEX_DH_GROUP14_SHA1:
  ------------------
  |  Branch (1543:5): [True: 0, False: 17.2k]
  ------------------
 1544|      0|    case SSH_KEX_DH_GROUP14_SHA256:
  ------------------
  |  Branch (1544:5): [True: 0, False: 17.2k]
  ------------------
 1545|      0|    case SSH_GSS_KEX_DH_GROUP14_SHA256:
  ------------------
  |  Branch (1545:5): [True: 0, False: 17.2k]
  ------------------
 1546|      0|    case SSH_KEX_DH_GROUP16_SHA512:
  ------------------
  |  Branch (1546:5): [True: 0, False: 17.2k]
  ------------------
 1547|      0|    case SSH_GSS_KEX_DH_GROUP16_SHA512:
  ------------------
  |  Branch (1547:5): [True: 0, False: 17.2k]
  ------------------
 1548|      0|    case SSH_KEX_DH_GROUP18_SHA512:
  ------------------
  |  Branch (1548:5): [True: 0, False: 17.2k]
  ------------------
 1549|      0|        rc = ssh_dh_keypair_get_keys(session->next_crypto->dh_ctx,
 1550|      0|                                     DH_CLIENT_KEYPAIR, NULL, &client_pubkey);
  ------------------
  |  |   30|      0|#define DH_CLIENT_KEYPAIR 0
  ------------------
 1551|      0|        if (rc != SSH_OK) {
  ------------------
  |  |  316|      0|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (1551:13): [True: 0, False: 0]
  ------------------
 1552|      0|            goto error;
 1553|      0|        }
 1554|      0|        rc = ssh_dh_keypair_get_keys(session->next_crypto->dh_ctx,
 1555|      0|                                     DH_SERVER_KEYPAIR, NULL, &server_pubkey);
  ------------------
  |  |   31|      0|#define DH_SERVER_KEYPAIR 1
  ------------------
 1556|      0|        if (rc != SSH_OK) {
  ------------------
  |  |  316|      0|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (1556:13): [True: 0, False: 0]
  ------------------
 1557|      0|            goto error;
 1558|      0|        }
 1559|      0|        rc = ssh_buffer_pack(buf,
  ------------------
  |  |   50|      0|    _ssh_buffer_pack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |  451|      0|        (__VA_NARG_(__VA_ARGS__, __RSEQ_N()))
  |  |  |  |  ------------------
  |  |  |  |  |  |  453|      0|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  448|      0|#define VA_APPLY_VARIADIC_MACRO(macro, tuple) macro tuple
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  453|      0|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  461|      0|        _61,_62,_63,N,...) N
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                   _ssh_buffer_pack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |   28|      0|#define SSH_BUFFER_PACK_END ((uint32_t) 0x4f65feb3)
  |  |  ------------------
  ------------------
 1560|      0|                             "BB",
 1561|      0|                             client_pubkey,
 1562|      0|                             server_pubkey);
 1563|      0|        if (rc != SSH_OK) {
  ------------------
  |  |  316|      0|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (1563:13): [True: 0, False: 0]
  ------------------
 1564|      0|            ssh_set_error(session, SSH_FATAL, "Failed to pack DH pubkeys");
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
 1565|      0|            goto error;
 1566|      0|        }
 1567|       |#if defined(HAVE_LIBCRYPTO) && OPENSSL_VERSION_NUMBER >= 0x30000000L
 1568|       |        bignum_safe_free(client_pubkey);
 1569|       |        bignum_safe_free(server_pubkey);
 1570|       |#endif /* OPENSSL_VERSION_NUMBER */
 1571|      0|        break;
 1572|      0|#ifdef WITH_GEX
 1573|      0|    case SSH_KEX_DH_GEX_SHA1:
  ------------------
  |  Branch (1573:5): [True: 0, False: 17.2k]
  ------------------
 1574|      0|    case SSH_KEX_DH_GEX_SHA256:
  ------------------
  |  Branch (1574:5): [True: 0, False: 17.2k]
  ------------------
 1575|      0|        rc = ssh_dh_keypair_get_keys(session->next_crypto->dh_ctx,
 1576|      0|                                     DH_CLIENT_KEYPAIR, NULL, &client_pubkey);
  ------------------
  |  |   30|      0|#define DH_CLIENT_KEYPAIR 0
  ------------------
 1577|      0|        if (rc != SSH_OK) {
  ------------------
  |  |  316|      0|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (1577:13): [True: 0, False: 0]
  ------------------
 1578|      0|            goto error;
 1579|      0|        }
 1580|      0|        rc = ssh_dh_keypair_get_keys(session->next_crypto->dh_ctx,
 1581|      0|                                     DH_SERVER_KEYPAIR, NULL, &server_pubkey);
  ------------------
  |  |   31|      0|#define DH_SERVER_KEYPAIR 1
  ------------------
 1582|      0|        if (rc != SSH_OK) {
  ------------------
  |  |  316|      0|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (1582:13): [True: 0, False: 0]
  ------------------
 1583|      0|            goto error;
 1584|      0|        }
 1585|      0|        rc = ssh_dh_get_parameters(session->next_crypto->dh_ctx,
 1586|      0|                                   &modulus, &generator);
 1587|      0|        if (rc != SSH_OK) {
  ------------------
  |  |  316|      0|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (1587:13): [True: 0, False: 0]
  ------------------
 1588|      0|            goto error;
 1589|      0|        }
 1590|      0|        rc = ssh_buffer_pack(buf,
  ------------------
  |  |   50|      0|    _ssh_buffer_pack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |  451|      0|        (__VA_NARG_(__VA_ARGS__, __RSEQ_N()))
  |  |  |  |  ------------------
  |  |  |  |  |  |  453|      0|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  448|      0|#define VA_APPLY_VARIADIC_MACRO(macro, tuple) macro tuple
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  453|      0|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  461|      0|        _61,_62,_63,N,...) N
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                   _ssh_buffer_pack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |   28|      0|#define SSH_BUFFER_PACK_END ((uint32_t) 0x4f65feb3)
  |  |  ------------------
  ------------------
 1591|      0|                    "dddBBBB",
 1592|      0|                    session->next_crypto->dh_pmin,
 1593|      0|                    session->next_crypto->dh_pn,
 1594|      0|                    session->next_crypto->dh_pmax,
 1595|      0|                    modulus,
 1596|      0|                    generator,
 1597|      0|                    client_pubkey,
 1598|      0|                    server_pubkey);
 1599|      0|        if (rc != SSH_OK) {
  ------------------
  |  |  316|      0|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (1599:13): [True: 0, False: 0]
  ------------------
 1600|      0|            ssh_set_error(session, SSH_FATAL, "Failed to pack DH GEX params");
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
 1601|      0|            goto error;
 1602|      0|        }
 1603|       |#if defined(HAVE_LIBCRYPTO) && OPENSSL_VERSION_NUMBER >= 0x30000000L
 1604|       |        bignum_safe_free(modulus);
 1605|       |        bignum_safe_free(generator);
 1606|       |#endif /* OPENSSL_VERSION_NUMBER */
 1607|      0|        break;
 1608|      0|#endif /* WITH_GEX */
 1609|      0|#ifdef HAVE_ECDH
 1610|      0|    case SSH_KEX_ECDH_SHA2_NISTP256:
  ------------------
  |  Branch (1610:5): [True: 0, False: 17.2k]
  ------------------
 1611|      0|    case SSH_KEX_ECDH_SHA2_NISTP384:
  ------------------
  |  Branch (1611:5): [True: 0, False: 17.2k]
  ------------------
 1612|      0|    case SSH_KEX_ECDH_SHA2_NISTP521:
  ------------------
  |  Branch (1612:5): [True: 0, False: 17.2k]
  ------------------
 1613|      0|    case SSH_GSS_KEX_ECDH_NISTP256_SHA256:
  ------------------
  |  Branch (1613:5): [True: 0, False: 17.2k]
  ------------------
 1614|      0|        if (session->next_crypto->ecdh_client_pubkey == NULL ||
  ------------------
  |  Branch (1614:13): [True: 0, False: 0]
  ------------------
 1615|      0|            session->next_crypto->ecdh_server_pubkey == NULL) {
  ------------------
  |  Branch (1615:13): [True: 0, False: 0]
  ------------------
 1616|      0|            SSH_LOG(SSH_LOG_TRACE, "ECDH parameter missing");
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 1617|      0|            goto error;
 1618|      0|        }
 1619|      0|        rc = ssh_buffer_pack(buf,
  ------------------
  |  |   50|      0|    _ssh_buffer_pack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |  451|      0|        (__VA_NARG_(__VA_ARGS__, __RSEQ_N()))
  |  |  |  |  ------------------
  |  |  |  |  |  |  453|      0|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  448|      0|#define VA_APPLY_VARIADIC_MACRO(macro, tuple) macro tuple
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  453|      0|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  461|      0|        _61,_62,_63,N,...) N
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                   _ssh_buffer_pack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |   28|      0|#define SSH_BUFFER_PACK_END ((uint32_t) 0x4f65feb3)
  |  |  ------------------
  ------------------
 1620|      0|                             "SS",
 1621|      0|                             session->next_crypto->ecdh_client_pubkey,
 1622|      0|                             session->next_crypto->ecdh_server_pubkey);
 1623|      0|        if (rc != SSH_OK) {
  ------------------
  |  |  316|      0|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (1623:13): [True: 0, False: 0]
  ------------------
 1624|      0|            ssh_set_error(session, SSH_FATAL, "Failed to pack ECDH pubkeys");
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
 1625|      0|            goto error;
 1626|      0|        }
 1627|      0|        break;
 1628|      0|#endif /* HAVE_ECDH */
 1629|      0|#ifdef HAVE_CURVE25519
 1630|      0|    case SSH_KEX_CURVE25519_SHA256:
  ------------------
  |  Branch (1630:5): [True: 0, False: 17.2k]
  ------------------
 1631|      0|    case SSH_KEX_CURVE25519_SHA256_LIBSSH_ORG:
  ------------------
  |  Branch (1631:5): [True: 0, False: 17.2k]
  ------------------
 1632|      0|    case SSH_GSS_KEX_CURVE25519_SHA256:
  ------------------
  |  Branch (1632:5): [True: 0, False: 17.2k]
  ------------------
 1633|      0|        rc = ssh_buffer_pack(buf,
  ------------------
  |  |   50|      0|    _ssh_buffer_pack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |  451|      0|        (__VA_NARG_(__VA_ARGS__, __RSEQ_N()))
  |  |  |  |  ------------------
  |  |  |  |  |  |  453|      0|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  448|      0|#define VA_APPLY_VARIADIC_MACRO(macro, tuple) macro tuple
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  453|      0|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  461|      0|        _61,_62,_63,N,...) N
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                   _ssh_buffer_pack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |   28|      0|#define SSH_BUFFER_PACK_END ((uint32_t) 0x4f65feb3)
  |  |  ------------------
  ------------------
 1634|      0|                             "dPdP",
 1635|      0|                             CURVE25519_PUBKEY_SIZE,
 1636|      0|                             (size_t)CURVE25519_PUBKEY_SIZE,
 1637|      0|                             session->next_crypto->curve25519_client_pubkey,
 1638|      0|                             CURVE25519_PUBKEY_SIZE,
 1639|      0|                             (size_t)CURVE25519_PUBKEY_SIZE,
 1640|      0|                             session->next_crypto->curve25519_server_pubkey);
 1641|       |
 1642|      0|        if (rc != SSH_OK) {
  ------------------
  |  |  316|      0|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (1642:13): [True: 0, False: 0]
  ------------------
 1643|      0|            ssh_set_error(session,
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
 1644|      0|                          SSH_FATAL,
 1645|      0|                          "Failed to pack Curve25519 pubkeys");
 1646|      0|            goto error;
 1647|      0|        }
 1648|      0|        break;
 1649|      0|#endif /* HAVE_CURVE25519 */
 1650|      0|#ifdef HAVE_SNTRUP761
 1651|      0|    case SSH_KEX_SNTRUP761X25519_SHA512:
  ------------------
  |  Branch (1651:5): [True: 0, False: 17.2k]
  ------------------
 1652|      0|    case SSH_KEX_SNTRUP761X25519_SHA512_OPENSSH_COM:
  ------------------
  |  Branch (1652:5): [True: 0, False: 17.2k]
  ------------------
 1653|      0|        rc = ssh_buffer_pack(buf,
  ------------------
  |  |   50|      0|    _ssh_buffer_pack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |  451|      0|        (__VA_NARG_(__VA_ARGS__, __RSEQ_N()))
  |  |  |  |  ------------------
  |  |  |  |  |  |  453|      0|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  448|      0|#define VA_APPLY_VARIADIC_MACRO(macro, tuple) macro tuple
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  453|      0|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  461|      0|        _61,_62,_63,N,...) N
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                   _ssh_buffer_pack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |   28|      0|#define SSH_BUFFER_PACK_END ((uint32_t) 0x4f65feb3)
  |  |  ------------------
  ------------------
 1654|      0|                             "dPPdPP",
 1655|      0|                             SNTRUP761_PUBLICKEY_SIZE + CURVE25519_PUBKEY_SIZE,
 1656|      0|                             (size_t)SNTRUP761_PUBLICKEY_SIZE,
 1657|      0|                             session->next_crypto->sntrup761_client_pubkey,
 1658|      0|                             (size_t)CURVE25519_PUBKEY_SIZE,
 1659|      0|                             session->next_crypto->curve25519_client_pubkey,
 1660|      0|                             SNTRUP761_CIPHERTEXT_SIZE + CURVE25519_PUBKEY_SIZE,
 1661|      0|                             (size_t)SNTRUP761_CIPHERTEXT_SIZE,
 1662|      0|                             session->next_crypto->sntrup761_ciphertext,
 1663|      0|                             (size_t)CURVE25519_PUBKEY_SIZE,
 1664|      0|                             session->next_crypto->curve25519_server_pubkey);
 1665|       |
 1666|      0|        if (rc != SSH_OK) {
  ------------------
  |  |  316|      0|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (1666:13): [True: 0, False: 0]
  ------------------
 1667|      0|            ssh_set_error(session,
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
 1668|      0|                          SSH_FATAL,
 1669|      0|                          "Failed to pack SNTRU Prime params");
 1670|      0|            goto error;
 1671|      0|        }
 1672|      0|        break;
 1673|      0|#endif /* HAVE_SNTRUP761 */
 1674|  17.2k|    case SSH_KEX_MLKEM768X25519_SHA256:
  ------------------
  |  Branch (1674:5): [True: 17.2k, False: 0]
  ------------------
 1675|  17.2k|    case SSH_KEX_MLKEM768NISTP256_SHA256:
  ------------------
  |  Branch (1675:5): [True: 0, False: 17.2k]
  ------------------
 1676|       |#ifdef HAVE_MLKEM1024
 1677|       |    case SSH_KEX_MLKEM1024NISTP384_SHA384:
 1678|       |#endif
 1679|  17.2k|        rc = ssh_buffer_pack(buf,
  ------------------
  |  |   50|  17.2k|    _ssh_buffer_pack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |  451|  17.2k|        (__VA_NARG_(__VA_ARGS__, __RSEQ_N()))
  |  |  |  |  ------------------
  |  |  |  |  |  |  453|  17.2k|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  448|  17.2k|#define VA_APPLY_VARIADIC_MACRO(macro, tuple) macro tuple
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  453|  17.2k|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  461|  17.2k|        _61,_62,_63,N,...) N
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                   _ssh_buffer_pack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |   28|  17.2k|#define SSH_BUFFER_PACK_END ((uint32_t) 0x4f65feb3)
  |  |  ------------------
  ------------------
 1680|  17.2k|                             "SS",
 1681|  17.2k|                             session->next_crypto->hybrid_client_init,
 1682|  17.2k|                             session->next_crypto->hybrid_server_reply);
 1683|  17.2k|        if (rc != SSH_OK) {
  ------------------
  |  |  316|  17.2k|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (1683:13): [True: 0, False: 17.2k]
  ------------------
 1684|      0|            ssh_set_error(session,
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
 1685|      0|                          SSH_FATAL,
 1686|      0|                          "Failed to pack ML-KEM individual components");
 1687|      0|            goto error;
 1688|      0|        }
 1689|  17.2k|        break;
 1690|  17.2k|    default:
  ------------------
  |  Branch (1690:5): [True: 0, False: 17.2k]
  ------------------
 1691|       |        /* Handle unsupported kex types - this should not happen in normal operation */
 1692|      0|        rc = SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 1693|      0|        ssh_set_error(session, SSH_FATAL, "Unsupported KEX algorithm");
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
 1694|      0|        goto error;
 1695|  17.2k|    }
 1696|  17.2k|    switch (session->next_crypto->kex_type) {
 1697|      0|    case SSH_KEX_SNTRUP761X25519_SHA512:
  ------------------
  |  Branch (1697:5): [True: 0, False: 17.2k]
  ------------------
 1698|      0|    case SSH_KEX_SNTRUP761X25519_SHA512_OPENSSH_COM:
  ------------------
  |  Branch (1698:5): [True: 0, False: 17.2k]
  ------------------
 1699|  17.2k|    case SSH_KEX_MLKEM768X25519_SHA256:
  ------------------
  |  Branch (1699:5): [True: 17.2k, False: 0]
  ------------------
 1700|  17.2k|    case SSH_KEX_MLKEM768NISTP256_SHA256:
  ------------------
  |  Branch (1700:5): [True: 0, False: 17.2k]
  ------------------
 1701|       |#ifdef HAVE_MLKEM1024
 1702|       |    case SSH_KEX_MLKEM1024NISTP384_SHA384:
 1703|       |#endif
 1704|  17.2k|        rc = ssh_buffer_pack(buf, "S", session->next_crypto->hybrid_shared_secret);
  ------------------
  |  |   50|  17.2k|    _ssh_buffer_pack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |  451|  17.2k|        (__VA_NARG_(__VA_ARGS__, __RSEQ_N()))
  |  |  |  |  ------------------
  |  |  |  |  |  |  453|  17.2k|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  448|  17.2k|#define VA_APPLY_VARIADIC_MACRO(macro, tuple) macro tuple
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  453|  17.2k|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  461|  17.2k|        _61,_62,_63,N,...) N
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                   _ssh_buffer_pack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |   28|  17.2k|#define SSH_BUFFER_PACK_END ((uint32_t) 0x4f65feb3)
  |  |  ------------------
  ------------------
 1705|  17.2k|        break;
 1706|      0|    default:
  ------------------
  |  Branch (1706:5): [True: 0, False: 17.2k]
  ------------------
 1707|      0|        rc = ssh_buffer_pack(buf, "B", session->next_crypto->shared_secret);
  ------------------
  |  |   50|      0|    _ssh_buffer_pack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |  451|      0|        (__VA_NARG_(__VA_ARGS__, __RSEQ_N()))
  |  |  |  |  ------------------
  |  |  |  |  |  |  453|      0|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  448|      0|#define VA_APPLY_VARIADIC_MACRO(macro, tuple) macro tuple
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  453|      0|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  461|      0|        _61,_62,_63,N,...) N
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                   _ssh_buffer_pack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |   28|      0|#define SSH_BUFFER_PACK_END ((uint32_t) 0x4f65feb3)
  |  |  ------------------
  ------------------
 1708|      0|        break;
 1709|  17.2k|    }
 1710|  17.2k|    if (rc != SSH_OK) {
  ------------------
  |  |  316|  17.2k|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (1710:9): [True: 0, False: 17.2k]
  ------------------
 1711|      0|        ssh_set_error(session, SSH_FATAL, "Failed to pack shared secret");
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
 1712|      0|        goto error;
 1713|      0|    }
 1714|       |
 1715|       |#ifdef DEBUG_CRYPTO
 1716|       |    ssh_log_hexdump("hash buffer", ssh_buffer_get(buf), ssh_buffer_get_len(buf));
 1717|       |#endif
 1718|       |
 1719|       |    /* Set rc for the following switch statement in case we goto error. */
 1720|  17.2k|    rc = SSH_ERROR;
  ------------------
  |  |  317|  17.2k|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 1721|  17.2k|    switch (session->next_crypto->kex_type) {
 1722|      0|    case SSH_KEX_DH_GROUP1_SHA1:
  ------------------
  |  Branch (1722:5): [True: 0, False: 17.2k]
  ------------------
 1723|      0|    case SSH_KEX_DH_GROUP14_SHA1:
  ------------------
  |  Branch (1723:5): [True: 0, False: 17.2k]
  ------------------
 1724|      0|#ifdef WITH_GEX
 1725|      0|    case SSH_KEX_DH_GEX_SHA1:
  ------------------
  |  Branch (1725:5): [True: 0, False: 17.2k]
  ------------------
 1726|      0|#endif /* WITH_GEX */
 1727|      0|        session->next_crypto->digest_len = SHA_DIGEST_LENGTH;
 1728|      0|        session->next_crypto->digest_type = SSH_KDF_SHA1;
 1729|      0|        session->next_crypto->secret_hash = malloc(session->next_crypto->digest_len);
 1730|      0|        if (session->next_crypto->secret_hash == NULL) {
  ------------------
  |  Branch (1730:13): [True: 0, False: 0]
  ------------------
 1731|      0|            ssh_set_error_oom(session);
  ------------------
  |  |  318|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
 1732|      0|            goto error;
 1733|      0|        }
 1734|      0|        sha1(ssh_buffer_get(buf), ssh_buffer_get_len(buf),
 1735|      0|                                   session->next_crypto->secret_hash);
 1736|      0|        break;
 1737|      0|    case SSH_KEX_DH_GROUP14_SHA256:
  ------------------
  |  Branch (1737:5): [True: 0, False: 17.2k]
  ------------------
 1738|      0|    case SSH_GSS_KEX_DH_GROUP14_SHA256:
  ------------------
  |  Branch (1738:5): [True: 0, False: 17.2k]
  ------------------
 1739|      0|    case SSH_KEX_ECDH_SHA2_NISTP256:
  ------------------
  |  Branch (1739:5): [True: 0, False: 17.2k]
  ------------------
 1740|      0|    case SSH_KEX_CURVE25519_SHA256:
  ------------------
  |  Branch (1740:5): [True: 0, False: 17.2k]
  ------------------
 1741|      0|    case SSH_KEX_CURVE25519_SHA256_LIBSSH_ORG:
  ------------------
  |  Branch (1741:5): [True: 0, False: 17.2k]
  ------------------
 1742|  17.2k|    case SSH_KEX_MLKEM768X25519_SHA256:
  ------------------
  |  Branch (1742:5): [True: 17.2k, False: 0]
  ------------------
 1743|  17.2k|    case SSH_KEX_MLKEM768NISTP256_SHA256:
  ------------------
  |  Branch (1743:5): [True: 0, False: 17.2k]
  ------------------
 1744|  17.2k|    case SSH_GSS_KEX_ECDH_NISTP256_SHA256:
  ------------------
  |  Branch (1744:5): [True: 0, False: 17.2k]
  ------------------
 1745|  17.2k|    case SSH_GSS_KEX_CURVE25519_SHA256:
  ------------------
  |  Branch (1745:5): [True: 0, False: 17.2k]
  ------------------
 1746|  17.2k|#ifdef WITH_GEX
 1747|  17.2k|    case SSH_KEX_DH_GEX_SHA256:
  ------------------
  |  Branch (1747:5): [True: 0, False: 17.2k]
  ------------------
 1748|  17.2k|#endif /* WITH_GEX */
 1749|  17.2k|        session->next_crypto->digest_len = SHA256_DIGEST_LENGTH;
 1750|  17.2k|        session->next_crypto->digest_type = SSH_KDF_SHA256;
 1751|  17.2k|        session->next_crypto->secret_hash = malloc(session->next_crypto->digest_len);
 1752|  17.2k|        if (session->next_crypto->secret_hash == NULL) {
  ------------------
  |  Branch (1752:13): [True: 0, False: 17.2k]
  ------------------
 1753|      0|            ssh_set_error_oom(session);
  ------------------
  |  |  318|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
 1754|      0|            goto error;
 1755|      0|        }
 1756|  17.2k|        sha256(ssh_buffer_get(buf), ssh_buffer_get_len(buf),
 1757|  17.2k|                                     session->next_crypto->secret_hash);
 1758|  17.2k|        break;
 1759|      0|    case SSH_KEX_ECDH_SHA2_NISTP384:
  ------------------
  |  Branch (1759:5): [True: 0, False: 17.2k]
  ------------------
 1760|       |#ifdef HAVE_MLKEM1024
 1761|       |    case SSH_KEX_MLKEM1024NISTP384_SHA384:
 1762|       |#endif
 1763|      0|        session->next_crypto->digest_len = SHA384_DIGEST_LENGTH;
 1764|      0|        session->next_crypto->digest_type = SSH_KDF_SHA384;
 1765|      0|        session->next_crypto->secret_hash = malloc(session->next_crypto->digest_len);
 1766|      0|        if (session->next_crypto->secret_hash == NULL) {
  ------------------
  |  Branch (1766:13): [True: 0, False: 0]
  ------------------
 1767|      0|            ssh_set_error_oom(session);
  ------------------
  |  |  318|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
 1768|      0|            goto error;
 1769|      0|        }
 1770|      0|        sha384(ssh_buffer_get(buf), ssh_buffer_get_len(buf),
 1771|      0|                                     session->next_crypto->secret_hash);
 1772|      0|        break;
 1773|      0|    case SSH_KEX_DH_GROUP16_SHA512:
  ------------------
  |  Branch (1773:5): [True: 0, False: 17.2k]
  ------------------
 1774|      0|    case SSH_GSS_KEX_DH_GROUP16_SHA512:
  ------------------
  |  Branch (1774:5): [True: 0, False: 17.2k]
  ------------------
 1775|      0|    case SSH_KEX_DH_GROUP18_SHA512:
  ------------------
  |  Branch (1775:5): [True: 0, False: 17.2k]
  ------------------
 1776|      0|    case SSH_KEX_ECDH_SHA2_NISTP521:
  ------------------
  |  Branch (1776:5): [True: 0, False: 17.2k]
  ------------------
 1777|      0|    case SSH_KEX_SNTRUP761X25519_SHA512:
  ------------------
  |  Branch (1777:5): [True: 0, False: 17.2k]
  ------------------
 1778|      0|    case SSH_KEX_SNTRUP761X25519_SHA512_OPENSSH_COM:
  ------------------
  |  Branch (1778:5): [True: 0, False: 17.2k]
  ------------------
 1779|      0|        session->next_crypto->digest_len = SHA512_DIGEST_LENGTH;
 1780|      0|        session->next_crypto->digest_type = SSH_KDF_SHA512;
 1781|      0|        session->next_crypto->secret_hash = malloc(session->next_crypto->digest_len);
 1782|      0|        if (session->next_crypto->secret_hash == NULL) {
  ------------------
  |  Branch (1782:13): [True: 0, False: 0]
  ------------------
 1783|      0|            ssh_set_error_oom(session);
  ------------------
  |  |  318|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
 1784|      0|            goto error;
 1785|      0|        }
 1786|      0|        sha512(ssh_buffer_get(buf),
 1787|      0|               ssh_buffer_get_len(buf),
 1788|      0|               session->next_crypto->secret_hash);
 1789|      0|        break;
 1790|      0|    default:
  ------------------
  |  Branch (1790:5): [True: 0, False: 17.2k]
  ------------------
 1791|       |        /* Handle unsupported kex types - this should not happen in normal operation */
 1792|      0|        ssh_set_error(session, SSH_FATAL, "Unsupported KEX algorithm for hash computation");
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
 1793|      0|        rc = SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 1794|      0|        goto error;
 1795|  17.2k|    }
 1796|       |
 1797|       |    /* During the first kex, secret hash and session ID are equal. However, after
 1798|       |     * a key re-exchange, a new secret hash is calculated. This hash will not replace
 1799|       |     * but complement existing session id.
 1800|       |     */
 1801|  17.2k|    if (!session->next_crypto->session_id) {
  ------------------
  |  Branch (1801:9): [True: 17.2k, False: 0]
  ------------------
 1802|  17.2k|        session->next_crypto->session_id = malloc(session->next_crypto->digest_len);
 1803|  17.2k|        if (session->next_crypto->session_id == NULL) {
  ------------------
  |  Branch (1803:13): [True: 0, False: 17.2k]
  ------------------
 1804|      0|            ssh_set_error_oom(session);
  ------------------
  |  |  318|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
 1805|      0|            rc = SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 1806|      0|            goto error;
 1807|      0|        }
 1808|  17.2k|        memcpy(session->next_crypto->session_id, session->next_crypto->secret_hash,
 1809|  17.2k|                session->next_crypto->digest_len);
 1810|       |	/* Initial length is the same as secret hash */
 1811|  17.2k|	session->next_crypto->session_id_len = session->next_crypto->digest_len;
 1812|  17.2k|    }
 1813|       |#ifdef DEBUG_CRYPTO
 1814|       |    SSH_LOG(SSH_LOG_DEBUG, "Session hash: \n");
 1815|       |    ssh_log_hexdump("secret hash", session->next_crypto->secret_hash, session->next_crypto->digest_len);
 1816|       |    ssh_log_hexdump("session id", session->next_crypto->session_id, session->next_crypto->session_id_len);
 1817|       |#endif /* DEBUG_CRYPTO */
 1818|       |
 1819|  17.2k|    rc = SSH_OK;
  ------------------
  |  |  316|  17.2k|#define SSH_OK 0     /* No error */
  ------------------
 1820|  17.2k|error:
 1821|  17.2k|    SSH_BUFFER_FREE(buf);
  ------------------
  |  |  934|  17.2k|    do { if ((x) != NULL) { ssh_buffer_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (934:14): [True: 17.2k, False: 0]
  |  |  |  Branch (934:69): [Folded, False: 17.2k]
  |  |  ------------------
  ------------------
 1822|  17.2k|    SSH_BUFFER_FREE(client_hash);
  ------------------
  |  |  934|  17.2k|    do { if ((x) != NULL) { ssh_buffer_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (934:14): [True: 17.2k, False: 0]
  |  |  |  Branch (934:69): [Folded, False: 17.2k]
  |  |  ------------------
  ------------------
 1823|  17.2k|    SSH_BUFFER_FREE(server_hash);
  ------------------
  |  |  934|  17.2k|    do { if ((x) != NULL) { ssh_buffer_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (934:14): [True: 17.2k, False: 0]
  |  |  |  Branch (934:69): [Folded, False: 17.2k]
  |  |  ------------------
  ------------------
 1824|       |
 1825|  17.2k|    session->in_hashbuf = NULL;
 1826|  17.2k|    session->out_hashbuf = NULL;
 1827|       |
 1828|  17.2k|    SSH_STRING_FREE(num);
  ------------------
  |  |  893|  17.2k|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (893:14): [True: 0, False: 17.2k]
  |  |  |  Branch (893:69): [Folded, False: 17.2k]
  |  |  ------------------
  ------------------
 1829|       |#if defined(HAVE_LIBCRYPTO) && OPENSSL_VERSION_NUMBER >= 0x30000000L
 1830|       |    bignum_safe_free(client_pubkey);
 1831|       |    bignum_safe_free(server_pubkey);
 1832|       |#endif /* OPENSSL_VERSION_NUMBER */
 1833|       |
 1834|  17.2k|    return rc;
 1835|  17.2k|}
ssh_hashbufout_add_cookie:
 1838|  17.2k|{
 1839|  17.2k|    int rc;
 1840|       |
 1841|  17.2k|    session->out_hashbuf = ssh_buffer_new();
 1842|  17.2k|    if (session->out_hashbuf == NULL) {
  ------------------
  |  Branch (1842:9): [True: 0, False: 17.2k]
  ------------------
 1843|      0|        return -1;
 1844|      0|    }
 1845|       |
 1846|  17.2k|    rc = ssh_buffer_allocate_size(session->out_hashbuf,
 1847|  17.2k|            sizeof(uint8_t) + 16);
 1848|  17.2k|    if (rc < 0) {
  ------------------
  |  Branch (1848:9): [True: 0, False: 17.2k]
  ------------------
 1849|      0|        ssh_buffer_reinit(session->out_hashbuf);
 1850|      0|        return -1;
 1851|      0|    }
 1852|       |
 1853|  17.2k|    if (ssh_buffer_add_u8(session->out_hashbuf, 20) < 0) {
  ------------------
  |  Branch (1853:9): [True: 0, False: 17.2k]
  ------------------
 1854|      0|        ssh_buffer_reinit(session->out_hashbuf);
 1855|      0|        return -1;
 1856|      0|    }
 1857|       |
 1858|  17.2k|    if (session->server) {
  ------------------
  |  Branch (1858:9): [True: 8.64k, False: 8.61k]
  ------------------
 1859|  8.64k|        if (ssh_buffer_add_data(session->out_hashbuf,
  ------------------
  |  Branch (1859:13): [True: 0, False: 8.64k]
  ------------------
 1860|  8.64k|                    session->next_crypto->server_kex.cookie, 16) < 0) {
 1861|      0|            ssh_buffer_reinit(session->out_hashbuf);
 1862|      0|            return -1;
 1863|      0|        }
 1864|  8.64k|    } else {
 1865|  8.61k|        if (ssh_buffer_add_data(session->out_hashbuf,
  ------------------
  |  Branch (1865:13): [True: 0, False: 8.61k]
  ------------------
 1866|  8.61k|                    session->next_crypto->client_kex.cookie, 16) < 0) {
 1867|      0|            ssh_buffer_reinit(session->out_hashbuf);
 1868|      0|            return -1;
 1869|      0|        }
 1870|  8.61k|    }
 1871|       |
 1872|  17.2k|    return 0;
 1873|  17.2k|}
ssh_hashbufin_add_cookie:
 1876|  17.2k|{
 1877|  17.2k|    int rc;
 1878|       |
 1879|  17.2k|    session->in_hashbuf = ssh_buffer_new();
 1880|  17.2k|    if (session->in_hashbuf == NULL) {
  ------------------
  |  Branch (1880:9): [True: 0, False: 17.2k]
  ------------------
 1881|      0|        return -1;
 1882|      0|    }
 1883|       |
 1884|  17.2k|    rc = ssh_buffer_allocate_size(session->in_hashbuf,
 1885|  17.2k|            sizeof(uint8_t) + 20 + 16);
 1886|  17.2k|    if (rc < 0) {
  ------------------
  |  Branch (1886:9): [True: 0, False: 17.2k]
  ------------------
 1887|      0|        ssh_buffer_reinit(session->in_hashbuf);
 1888|      0|        return -1;
 1889|      0|    }
 1890|       |
 1891|  17.2k|    if (ssh_buffer_add_u8(session->in_hashbuf, 20) < 0) {
  ------------------
  |  Branch (1891:9): [True: 0, False: 17.2k]
  ------------------
 1892|      0|        ssh_buffer_reinit(session->in_hashbuf);
 1893|      0|        return -1;
 1894|      0|    }
 1895|  17.2k|    if (ssh_buffer_add_data(session->in_hashbuf,cookie, 16) < 0) {
  ------------------
  |  Branch (1895:9): [True: 0, False: 17.2k]
  ------------------
 1896|      0|        ssh_buffer_reinit(session->in_hashbuf);
 1897|      0|        return -1;
 1898|      0|    }
 1899|       |
 1900|  17.2k|    return 0;
 1901|  17.2k|}
ssh_generate_session_keys:
 1904|  17.2k|{
 1905|  17.2k|    ssh_string k_string = NULL;
 1906|  17.2k|    struct ssh_crypto_struct *crypto = session->next_crypto;
 1907|  17.2k|    unsigned char *key = NULL;
 1908|  17.2k|    unsigned char *IV_cli_to_srv = NULL;
 1909|  17.2k|    unsigned char *IV_srv_to_cli = NULL;
 1910|  17.2k|    unsigned char *enckey_cli_to_srv = NULL;
 1911|  17.2k|    unsigned char *enckey_srv_to_cli = NULL;
 1912|  17.2k|    unsigned char *intkey_cli_to_srv = NULL;
 1913|  17.2k|    unsigned char *intkey_srv_to_cli = NULL;
 1914|  17.2k|    size_t key_len = 0;
 1915|  17.2k|    size_t IV_len = 0;
 1916|  17.2k|    size_t enckey_cli_to_srv_len = 0;
 1917|  17.2k|    size_t enckey_srv_to_cli_len = 0;
 1918|  17.2k|    size_t intkey_cli_to_srv_len = 0;
 1919|  17.2k|    size_t intkey_srv_to_cli_len = 0;
 1920|  17.2k|    int rc = -1;
 1921|       |
 1922|  17.2k|    switch (session->next_crypto->kex_type) {
 1923|      0|    case SSH_KEX_SNTRUP761X25519_SHA512:
  ------------------
  |  Branch (1923:5): [True: 0, False: 17.2k]
  ------------------
 1924|      0|    case SSH_KEX_SNTRUP761X25519_SHA512_OPENSSH_COM:
  ------------------
  |  Branch (1924:5): [True: 0, False: 17.2k]
  ------------------
 1925|  17.2k|    case SSH_KEX_MLKEM768X25519_SHA256:
  ------------------
  |  Branch (1925:5): [True: 17.2k, False: 0]
  ------------------
 1926|  17.2k|    case SSH_KEX_MLKEM768NISTP256_SHA256:
  ------------------
  |  Branch (1926:5): [True: 0, False: 17.2k]
  ------------------
 1927|       |#ifdef HAVE_MLKEM1024
 1928|       |    case SSH_KEX_MLKEM1024NISTP384_SHA384:
 1929|       |#endif
 1930|  17.2k|        k_string = ssh_string_copy(crypto->hybrid_shared_secret);
 1931|  17.2k|        break;
 1932|      0|    default:
  ------------------
  |  Branch (1932:5): [True: 0, False: 17.2k]
  ------------------
 1933|      0|        k_string = ssh_make_bignum_string(crypto->shared_secret);
 1934|      0|        break;
 1935|  17.2k|    }
 1936|  17.2k|    if (k_string == NULL) {
  ------------------
  |  Branch (1936:9): [True: 0, False: 17.2k]
  ------------------
 1937|      0|        ssh_set_error_oom(session);
  ------------------
  |  |  318|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
 1938|      0|        goto error;
 1939|      0|    }
 1940|       |    /* See RFC4251 Section 5 for the definition of mpint which is the
 1941|       |     * encoding we need to use for key in the SSH KDF */
 1942|  17.2k|    key = (unsigned char *)k_string;
 1943|  17.2k|    key_len = ssh_string_len(k_string) + 4;
 1944|       |
 1945|  17.2k|    IV_len = crypto->digest_len;
 1946|  17.2k|    if (session->client) {
  ------------------
  |  Branch (1946:9): [True: 8.64k, False: 8.64k]
  ------------------
 1947|  8.64k|        enckey_cli_to_srv_len = crypto->out_cipher->keysize / 8;
 1948|  8.64k|        enckey_srv_to_cli_len = crypto->in_cipher->keysize / 8;
 1949|  8.64k|        intkey_cli_to_srv_len = hmac_digest_len(crypto->out_hmac);
 1950|  8.64k|        intkey_srv_to_cli_len = hmac_digest_len(crypto->in_hmac);
 1951|  8.64k|    } else {
 1952|  8.64k|        enckey_cli_to_srv_len = crypto->in_cipher->keysize / 8;
 1953|  8.64k|        enckey_srv_to_cli_len = crypto->out_cipher->keysize / 8;
 1954|  8.64k|        intkey_cli_to_srv_len = hmac_digest_len(crypto->in_hmac);
 1955|  8.64k|        intkey_srv_to_cli_len = hmac_digest_len(crypto->out_hmac);
 1956|  8.64k|    }
 1957|       |
 1958|  17.2k|    IV_cli_to_srv = malloc(IV_len);
 1959|  17.2k|    IV_srv_to_cli = malloc(IV_len);
 1960|  17.2k|    enckey_cli_to_srv = malloc(enckey_cli_to_srv_len);
 1961|  17.2k|    enckey_srv_to_cli = malloc(enckey_srv_to_cli_len);
 1962|  17.2k|    intkey_cli_to_srv = malloc(intkey_cli_to_srv_len);
 1963|  17.2k|    intkey_srv_to_cli = malloc(intkey_srv_to_cli_len);
 1964|  17.2k|    if (IV_cli_to_srv == NULL || IV_srv_to_cli == NULL ||
  ------------------
  |  Branch (1964:9): [True: 0, False: 17.2k]
  |  Branch (1964:34): [True: 0, False: 17.2k]
  ------------------
 1965|  17.2k|        enckey_cli_to_srv == NULL || enckey_srv_to_cli == NULL ||
  ------------------
  |  Branch (1965:9): [True: 0, False: 17.2k]
  |  Branch (1965:38): [True: 0, False: 17.2k]
  ------------------
 1966|  17.2k|        intkey_cli_to_srv == NULL || intkey_srv_to_cli == NULL) {
  ------------------
  |  Branch (1966:9): [True: 0, False: 17.2k]
  |  Branch (1966:38): [True: 0, False: 17.2k]
  ------------------
 1967|      0|        ssh_set_error_oom(session);
  ------------------
  |  |  318|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
 1968|      0|        goto error;
 1969|      0|    }
 1970|       |
 1971|       |    /* IV */
 1972|  17.2k|    rc = ssh_kdf(crypto, key, key_len, 'A', IV_cli_to_srv, IV_len);
 1973|  17.2k|    if (rc < 0) {
  ------------------
  |  Branch (1973:9): [True: 0, False: 17.2k]
  ------------------
 1974|      0|        goto error;
 1975|      0|    }
 1976|  17.2k|    rc = ssh_kdf(crypto, key, key_len, 'B', IV_srv_to_cli, IV_len);
 1977|  17.2k|    if (rc < 0) {
  ------------------
  |  Branch (1977:9): [True: 0, False: 17.2k]
  ------------------
 1978|      0|        goto error;
 1979|      0|    }
 1980|       |    /* Encryption Key */
 1981|  17.2k|    rc = ssh_kdf(crypto, key, key_len, 'C', enckey_cli_to_srv,
 1982|  17.2k|                 enckey_cli_to_srv_len);
 1983|  17.2k|    if (rc < 0) {
  ------------------
  |  Branch (1983:9): [True: 0, False: 17.2k]
  ------------------
 1984|      0|        goto error;
 1985|      0|    }
 1986|  17.2k|    rc = ssh_kdf(crypto, key, key_len, 'D', enckey_srv_to_cli,
 1987|  17.2k|                 enckey_srv_to_cli_len);
 1988|  17.2k|    if (rc < 0) {
  ------------------
  |  Branch (1988:9): [True: 0, False: 17.2k]
  ------------------
 1989|      0|        goto error;
 1990|      0|    }
 1991|       |    /* Integrity Key */
 1992|  17.2k|    rc = ssh_kdf(crypto, key, key_len, 'E', intkey_cli_to_srv,
 1993|  17.2k|                 intkey_cli_to_srv_len);
 1994|  17.2k|    if (rc < 0) {
  ------------------
  |  Branch (1994:9): [True: 0, False: 17.2k]
  ------------------
 1995|      0|        goto error;
 1996|      0|    }
 1997|  17.2k|    rc = ssh_kdf(crypto, key, key_len, 'F', intkey_srv_to_cli,
 1998|  17.2k|                 intkey_srv_to_cli_len);
 1999|  17.2k|    if (rc < 0) {
  ------------------
  |  Branch (1999:9): [True: 0, False: 17.2k]
  ------------------
 2000|      0|        goto error;
 2001|      0|    }
 2002|       |
 2003|  17.2k|    if (session->client) {
  ------------------
  |  Branch (2003:9): [True: 8.64k, False: 8.64k]
  ------------------
 2004|  8.64k|        crypto->encryptIV = IV_cli_to_srv;
 2005|  8.64k|        crypto->decryptIV = IV_srv_to_cli;
 2006|  8.64k|        crypto->encryptkey = enckey_cli_to_srv;
 2007|  8.64k|        crypto->decryptkey = enckey_srv_to_cli;
 2008|  8.64k|        crypto->encryptMAC = intkey_cli_to_srv;
 2009|  8.64k|        crypto->decryptMAC = intkey_srv_to_cli;
 2010|  8.64k|    } else {
 2011|  8.64k|        crypto->encryptIV = IV_srv_to_cli;
 2012|  8.64k|        crypto->decryptIV = IV_cli_to_srv;
 2013|  8.64k|        crypto->encryptkey = enckey_srv_to_cli;
 2014|  8.64k|        crypto->decryptkey = enckey_cli_to_srv;
 2015|  8.64k|        crypto->encryptMAC = intkey_srv_to_cli;
 2016|  8.64k|        crypto->decryptMAC = intkey_cli_to_srv;
 2017|  8.64k|    }
 2018|       |
 2019|       |#ifdef DEBUG_CRYPTO
 2020|       |    ssh_log_hexdump("Client to Server IV", IV_cli_to_srv, IV_len);
 2021|       |    ssh_log_hexdump("Server to Client IV", IV_srv_to_cli, IV_len);
 2022|       |    ssh_log_hexdump("Client to Server Encryption Key", enckey_cli_to_srv,
 2023|       |                   enckey_cli_to_srv_len);
 2024|       |    ssh_log_hexdump("Server to Client Encryption Key", enckey_srv_to_cli,
 2025|       |                   enckey_srv_to_cli_len);
 2026|       |    ssh_log_hexdump("Client to Server Integrity Key", intkey_cli_to_srv,
 2027|       |                   intkey_cli_to_srv_len);
 2028|       |    ssh_log_hexdump("Server to Client Integrity Key", intkey_srv_to_cli,
 2029|       |                   intkey_srv_to_cli_len);
 2030|       |#endif /* DEBUG_CRYPTO */
 2031|       |
 2032|  17.2k|    rc = 0;
 2033|  17.2k|error:
 2034|  17.2k|    ssh_string_burn(k_string);
 2035|  17.2k|    SSH_STRING_FREE(k_string);
  ------------------
  |  |  893|  17.2k|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (893:14): [True: 17.2k, False: 0]
  |  |  |  Branch (893:69): [Folded, False: 17.2k]
  |  |  ------------------
  ------------------
 2036|  17.2k|    if (rc != 0) {
  ------------------
  |  Branch (2036:9): [True: 0, False: 17.2k]
  ------------------
 2037|      0|        free(IV_cli_to_srv);
 2038|      0|        free(IV_srv_to_cli);
 2039|      0|        free(enckey_cli_to_srv);
 2040|      0|        free(enckey_srv_to_cli);
 2041|      0|        free(intkey_cli_to_srv);
 2042|      0|        free(intkey_srv_to_cli);
 2043|      0|    }
 2044|       |
 2045|  17.2k|    return rc;
 2046|  17.2k|}
kex.c:ssh_find_aead_hmac:
  952|  34.5k|{
  953|  34.5k|    if (cipher == NULL) {
  ------------------
  |  Branch (953:9): [True: 0, False: 34.5k]
  ------------------
  954|      0|        return NULL;
  955|  34.5k|    } else if (strcmp(cipher, "chacha20-poly1305@openssh.com") == 0) {
  ------------------
  |  Branch (955:16): [True: 0, False: 34.5k]
  ------------------
  956|      0|        return "aead-poly1305";
  957|  34.5k|    } else if (strcmp(cipher, "aes256-gcm@openssh.com") == 0) {
  ------------------
  |  Branch (957:16): [True: 0, False: 34.5k]
  ------------------
  958|      0|        return "aead-gcm";
  959|  34.5k|    } else if (strcmp(cipher, "aes128-gcm@openssh.com") == 0) {
  ------------------
  |  Branch (959:16): [True: 0, False: 34.5k]
  ------------------
  960|      0|        return "aead-gcm";
  961|      0|    }
  962|  34.5k|    return NULL;
  963|  34.5k|}
kex.c:kex_select_kex_type:
  967|  17.2k|{
  968|  17.2k|    if (strcmp(kex, "diffie-hellman-group1-sha1") == 0) {
  ------------------
  |  Branch (968:9): [True: 0, False: 17.2k]
  ------------------
  969|      0|        return SSH_KEX_DH_GROUP1_SHA1;
  970|  17.2k|    } else if (strncmp(kex, "gss-group14-sha256-", 19) == 0) {
  ------------------
  |  Branch (970:16): [True: 0, False: 17.2k]
  ------------------
  971|      0|        return SSH_GSS_KEX_DH_GROUP14_SHA256;
  972|  17.2k|    } else if (strncmp(kex, "gss-group16-sha512-", 19) == 0) {
  ------------------
  |  Branch (972:16): [True: 0, False: 17.2k]
  ------------------
  973|      0|        return SSH_GSS_KEX_DH_GROUP16_SHA512;
  974|  17.2k|    } else if (strncmp(kex, "gss-nistp256-sha256-", 20) == 0) {
  ------------------
  |  Branch (974:16): [True: 0, False: 17.2k]
  ------------------
  975|      0|        return SSH_GSS_KEX_ECDH_NISTP256_SHA256;
  976|  17.2k|    } else if (strncmp(kex, "gss-curve25519-sha256-", 22) == 0) {
  ------------------
  |  Branch (976:16): [True: 0, False: 17.2k]
  ------------------
  977|      0|        return SSH_GSS_KEX_CURVE25519_SHA256;
  978|  17.2k|    } else if (strcmp(kex, "diffie-hellman-group14-sha1") == 0) {
  ------------------
  |  Branch (978:16): [True: 0, False: 17.2k]
  ------------------
  979|      0|        return SSH_KEX_DH_GROUP14_SHA1;
  980|  17.2k|    } else if (strcmp(kex, "diffie-hellman-group14-sha256") == 0) {
  ------------------
  |  Branch (980:16): [True: 0, False: 17.2k]
  ------------------
  981|      0|        return SSH_KEX_DH_GROUP14_SHA256;
  982|  17.2k|    } else if (strcmp(kex, "diffie-hellman-group16-sha512") == 0) {
  ------------------
  |  Branch (982:16): [True: 0, False: 17.2k]
  ------------------
  983|      0|        return SSH_KEX_DH_GROUP16_SHA512;
  984|  17.2k|    } else if (strcmp(kex, "diffie-hellman-group18-sha512") == 0) {
  ------------------
  |  Branch (984:16): [True: 0, False: 17.2k]
  ------------------
  985|      0|        return SSH_KEX_DH_GROUP18_SHA512;
  986|      0|#ifdef WITH_GEX
  987|  17.2k|    } else if (strcmp(kex, "diffie-hellman-group-exchange-sha1") == 0) {
  ------------------
  |  Branch (987:16): [True: 0, False: 17.2k]
  ------------------
  988|      0|        return SSH_KEX_DH_GEX_SHA1;
  989|  17.2k|    } else if (strcmp(kex, "diffie-hellman-group-exchange-sha256") == 0) {
  ------------------
  |  Branch (989:16): [True: 0, False: 17.2k]
  ------------------
  990|      0|        return SSH_KEX_DH_GEX_SHA256;
  991|      0|#endif /* WITH_GEX */
  992|  17.2k|    } else if (strcmp(kex, "ecdh-sha2-nistp256") == 0) {
  ------------------
  |  Branch (992:16): [True: 0, False: 17.2k]
  ------------------
  993|      0|        return SSH_KEX_ECDH_SHA2_NISTP256;
  994|  17.2k|    } else if (strcmp(kex, "ecdh-sha2-nistp384") == 0) {
  ------------------
  |  Branch (994:16): [True: 0, False: 17.2k]
  ------------------
  995|      0|        return SSH_KEX_ECDH_SHA2_NISTP384;
  996|  17.2k|    } else if (strcmp(kex, "ecdh-sha2-nistp521") == 0) {
  ------------------
  |  Branch (996:16): [True: 0, False: 17.2k]
  ------------------
  997|      0|        return SSH_KEX_ECDH_SHA2_NISTP521;
  998|  17.2k|    } else if (strcmp(kex, "curve25519-sha256@libssh.org") == 0) {
  ------------------
  |  Branch (998:16): [True: 0, False: 17.2k]
  ------------------
  999|      0|        return SSH_KEX_CURVE25519_SHA256_LIBSSH_ORG;
 1000|  17.2k|    } else if (strcmp(kex, "curve25519-sha256") == 0) {
  ------------------
  |  Branch (1000:16): [True: 0, False: 17.2k]
  ------------------
 1001|      0|        return SSH_KEX_CURVE25519_SHA256;
 1002|  17.2k|    } else if (strcmp(kex, "sntrup761x25519-sha512@openssh.com") == 0) {
  ------------------
  |  Branch (1002:16): [True: 0, False: 17.2k]
  ------------------
 1003|      0|        return SSH_KEX_SNTRUP761X25519_SHA512_OPENSSH_COM;
 1004|  17.2k|    } else if (strcmp(kex, "sntrup761x25519-sha512") == 0) {
  ------------------
  |  Branch (1004:16): [True: 0, False: 17.2k]
  ------------------
 1005|      0|        return SSH_KEX_SNTRUP761X25519_SHA512;
 1006|  17.2k|    } else if (strcmp(kex, "mlkem768x25519-sha256") == 0) {
  ------------------
  |  Branch (1006:16): [True: 17.2k, False: 20]
  ------------------
 1007|  17.2k|        return SSH_KEX_MLKEM768X25519_SHA256;
 1008|  17.2k|    } else if (strcmp(kex, "mlkem768nistp256-sha256") == 0) {
  ------------------
  |  Branch (1008:16): [True: 0, False: 20]
  ------------------
 1009|      0|        return SSH_KEX_MLKEM768NISTP256_SHA256;
 1010|       |#ifdef HAVE_MLKEM1024
 1011|       |    } else if (strcmp(kex, "mlkem1024nistp384-sha384") == 0) {
 1012|       |        return SSH_KEX_MLKEM1024NISTP384_SHA384;
 1013|       |#endif
 1014|      0|    }
 1015|       |    /* should not happen. We should be getting only valid names at this stage */
 1016|     20|    return 0;
 1017|  17.2k|}

ssh_known_hosts_get_algorithms_names:
  565|  8.64k|{
  566|  8.64k|    char methods_buffer[256 + 1] = {0};
  567|  8.64k|    struct ssh_list *entry_list = NULL;
  568|  8.64k|    struct ssh_iterator *it = NULL;
  569|  8.64k|    char *host_port = NULL;
  570|  8.64k|    size_t count;
  571|  8.64k|    bool needcomma = false;
  572|  8.64k|    char *names = NULL;
  573|       |
  574|  8.64k|    int rc;
  575|       |
  576|  8.64k|    if (session->opts.knownhosts == NULL ||
  ------------------
  |  Branch (576:9): [True: 0, False: 8.64k]
  ------------------
  577|  8.64k|        session->opts.global_knownhosts == NULL) {
  ------------------
  |  Branch (577:9): [True: 0, False: 8.64k]
  ------------------
  578|      0|        if (ssh_options_apply(session) < 0) {
  ------------------
  |  Branch (578:13): [True: 0, False: 0]
  ------------------
  579|      0|            ssh_set_error(session,
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  580|      0|                          SSH_REQUEST_DENIED,
  581|      0|                          "Can't find a known_hosts file");
  582|       |
  583|      0|            return NULL;
  584|      0|        }
  585|      0|    }
  586|       |
  587|  8.64k|    host_port = ssh_session_get_host_port(session);
  588|  8.64k|    if (host_port == NULL) {
  ------------------
  |  Branch (588:9): [True: 0, False: 8.64k]
  ------------------
  589|      0|        return NULL;
  590|      0|    }
  591|       |
  592|  8.64k|    rc = ssh_known_hosts_read_entries(host_port,
  593|  8.64k|                                      session->opts.knownhosts,
  594|  8.64k|                                      &entry_list);
  595|  8.64k|    if (rc != 0) {
  ------------------
  |  Branch (595:9): [True: 0, False: 8.64k]
  ------------------
  596|      0|        SAFE_FREE(host_port);
  ------------------
  |  |  373|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
  597|      0|        ssh_knownhosts_entries_free(entry_list);
  598|      0|        return NULL;
  599|      0|    }
  600|       |
  601|  8.64k|    rc = ssh_known_hosts_read_entries(host_port,
  602|  8.64k|                                      session->opts.global_knownhosts,
  603|  8.64k|                                      &entry_list);
  604|  8.64k|    SAFE_FREE(host_port);
  ------------------
  |  |  373|  8.64k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 8.64k, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 8.64k]
  |  |  ------------------
  ------------------
  605|  8.64k|    if (rc != 0) {
  ------------------
  |  Branch (605:9): [True: 0, False: 8.64k]
  ------------------
  606|      0|        ssh_knownhosts_entries_free(entry_list);
  607|      0|        return NULL;
  608|      0|    }
  609|       |
  610|  8.64k|    if (entry_list == NULL) {
  ------------------
  |  Branch (610:9): [True: 8.64k, False: 0]
  ------------------
  611|  8.64k|        return NULL;
  612|  8.64k|    }
  613|       |
  614|      0|    count = ssh_list_count(entry_list);
  615|      0|    if (count == 0) {
  ------------------
  |  Branch (615:9): [True: 0, False: 0]
  ------------------
  616|      0|        ssh_list_free(entry_list);
  617|      0|        return NULL;
  618|      0|    }
  619|       |
  620|      0|    for (it = ssh_list_get_iterator(entry_list);
  621|      0|         it != NULL;
  ------------------
  |  Branch (621:10): [True: 0, False: 0]
  ------------------
  622|      0|         it = ssh_list_get_iterator(entry_list))
  623|      0|    {
  624|      0|        struct ssh_knownhosts_entry *entry = NULL;
  625|      0|        const char *algo = NULL;
  626|       |
  627|      0|        entry = ssh_iterator_value(struct ssh_knownhosts_entry *, it);
  ------------------
  |  |  114|      0|  ((type)((iterator)->data))
  ------------------
  628|      0|        algo = ssh_known_host_sigs_from_hostkey_type(entry->publickey->type);
  629|      0|        if (algo == NULL) {
  ------------------
  |  Branch (629:13): [True: 0, False: 0]
  ------------------
  630|      0|            ssh_knownhosts_entry_free(entry);
  631|      0|            ssh_list_remove(entry_list, it);
  632|      0|            continue;
  633|      0|        }
  634|       |
  635|      0|        if (needcomma) {
  ------------------
  |  Branch (635:13): [True: 0, False: 0]
  ------------------
  636|      0|            strlcat(methods_buffer, ",", sizeof(methods_buffer));
  637|      0|        }
  638|       |
  639|      0|        strlcat(methods_buffer, algo, sizeof(methods_buffer));
  640|      0|        needcomma = true;
  641|       |
  642|      0|        ssh_knownhosts_entry_free(entry);
  643|      0|        ssh_list_remove(entry_list, it);
  644|      0|    }
  645|       |
  646|      0|    ssh_list_free(entry_list);
  647|       |
  648|      0|    names = ssh_remove_duplicates(methods_buffer);
  649|       |
  650|      0|    return names;
  651|      0|}
knownhosts.c:ssh_session_get_host_port:
  330|  8.64k|{
  331|  8.64k|    char *host_port = NULL;
  332|  8.64k|    char *host = NULL;
  333|       |
  334|  8.64k|    if (session->opts.host == NULL) {
  ------------------
  |  Branch (334:9): [True: 0, False: 8.64k]
  ------------------
  335|      0|        ssh_set_error(session,
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  336|      0|                      SSH_FATAL,
  337|      0|                      "Can't verify server in known hosts if the host we "
  338|      0|                      "should connect to has not been set");
  339|       |
  340|      0|        return NULL;
  341|      0|    }
  342|       |
  343|  8.64k|    host = ssh_lowercase(session->opts.host);
  344|  8.64k|    if (host == NULL) {
  ------------------
  |  Branch (344:9): [True: 0, False: 8.64k]
  ------------------
  345|      0|        ssh_set_error_oom(session);
  ------------------
  |  |  318|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
  346|      0|        return NULL;
  347|      0|    }
  348|       |
  349|  8.64k|    if (session->opts.port == 0 || session->opts.port == 22) {
  ------------------
  |  Branch (349:9): [True: 0, False: 8.64k]
  |  Branch (349:36): [True: 8.64k, False: 0]
  ------------------
  350|  8.64k|        host_port = host;
  351|  8.64k|    } else {
  352|      0|        host_port = ssh_hostport(host, session->opts.port);
  353|      0|        SAFE_FREE(host);
  ------------------
  |  |  373|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
  354|      0|        if (host_port == NULL) {
  ------------------
  |  Branch (354:13): [True: 0, False: 0]
  ------------------
  355|      0|            ssh_set_error_oom(session);
  ------------------
  |  |  318|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
  356|      0|            return NULL;
  357|      0|        }
  358|      0|    }
  359|       |
  360|  8.64k|    return host_port;
  361|  8.64k|}
knownhosts.c:ssh_known_hosts_read_entries:
  239|  17.2k|{
  240|  17.2k|    char line[MAX_LINE_SIZE];
  241|  17.2k|    size_t lineno = 0;
  242|  17.2k|    size_t len = 0;
  243|  17.2k|    FILE *fp = NULL;
  244|  17.2k|    int rc;
  245|       |
  246|  17.2k|    fp = ssh_strict_fopen(filename, SSH_MAX_CONFIG_FILE_SIZE);
  ------------------
  |  |  528|  17.2k|#define SSH_MAX_CONFIG_FILE_SIZE 16 * 1024 * 1024
  ------------------
  247|  17.2k|    if (fp == NULL) {
  ------------------
  |  Branch (247:9): [True: 17.2k, False: 0]
  ------------------
  248|  17.2k|        SSH_LOG_STRERROR(SSH_LOG_TRACE,
  ------------------
  |  |  283|  17.2k|    do {                                                            \
  |  |  284|  17.2k|        char err_msg[SSH_ERRNO_MSG_MAX] = {0};                      \
  |  |  285|  17.2k|        _ssh_log(priority,                                          \
  |  |  286|  17.2k|                 __func__,                                          \
  |  |  287|  17.2k|                 __VA_ARGS__,                                       \
  |  |  288|  17.2k|                 ssh_strerror(errnum, err_msg, SSH_ERRNO_MSG_MAX)); \
  |  |  ------------------
  |  |  |  |  520|  17.2k|#define SSH_ERRNO_MSG_MAX   1024
  |  |  ------------------
  |  |  289|  17.2k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (289:14): [Folded, False: 17.2k]
  |  |  ------------------
  ------------------
  249|  17.2k|                         errno,
  250|  17.2k|                         "Failed to open the known_hosts file '%s': %s",
  251|  17.2k|                         filename);
  252|       |        /* The missing file is not an error here */
  253|  17.2k|        return SSH_OK;
  ------------------
  |  |  316|  17.2k|#define SSH_OK 0     /* No error */
  ------------------
  254|  17.2k|    }
  255|       |
  256|      0|    if (*entries == NULL) {
  ------------------
  |  Branch (256:9): [True: 0, False: 0]
  ------------------
  257|      0|        *entries = ssh_list_new();
  258|      0|        if (*entries == NULL) {
  ------------------
  |  Branch (258:13): [True: 0, False: 0]
  ------------------
  259|      0|            fclose(fp);
  260|      0|            return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  261|      0|        }
  262|      0|    }
  263|       |
  264|      0|    for (rc = known_hosts_read_line(fp, line, sizeof(line), &len, &lineno);
  265|      0|         rc == 0;
  ------------------
  |  Branch (265:10): [True: 0, False: 0]
  ------------------
  266|      0|         rc = known_hosts_read_line(fp, line, sizeof(line), &len, &lineno)) {
  267|      0|        struct ssh_knownhosts_entry *entry = NULL;
  268|      0|        struct ssh_iterator *it = NULL;
  269|      0|        char *p = NULL;
  270|       |
  271|      0|        if (line[len] != '\n') {
  ------------------
  |  Branch (271:13): [True: 0, False: 0]
  ------------------
  272|      0|            len = strcspn(line, "\n");
  273|      0|        }
  274|      0|        line[len] = '\0';
  275|       |
  276|       |        /* Skip leading spaces */
  277|      0|        for (p = line; isspace((int)p[0]); p++);
  ------------------
  |  Branch (277:24): [True: 0, False: 0]
  ------------------
  278|       |
  279|       |        /* Skip comments and empty lines */
  280|      0|        if (p[0] == '\0' || p[0] == '#') {
  ------------------
  |  Branch (280:13): [True: 0, False: 0]
  |  Branch (280:29): [True: 0, False: 0]
  ------------------
  281|      0|            continue;
  282|      0|        }
  283|       |
  284|       |        /* Skip lines starting with markers (@cert-authority, @revoked):
  285|       |         * we do not completely support them anyway */
  286|      0|        if (p[0] == '@') {
  ------------------
  |  Branch (286:13): [True: 0, False: 0]
  ------------------
  287|      0|            continue;
  288|      0|        }
  289|       |
  290|      0|        rc = ssh_known_hosts_parse_line(match,
  291|      0|                                        line,
  292|      0|                                        &entry);
  293|      0|        if (rc == SSH_AGAIN) {
  ------------------
  |  |  318|      0|#define SSH_AGAIN -2 /* The nonblocking call must be repeated */
  ------------------
  |  Branch (293:13): [True: 0, False: 0]
  ------------------
  294|      0|            continue;
  295|      0|        } else if (rc != SSH_OK) {
  ------------------
  |  |  316|      0|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (295:20): [True: 0, False: 0]
  ------------------
  296|      0|            goto error;
  297|      0|        }
  298|       |
  299|       |        /* Check for duplicates */
  300|      0|        for (it = ssh_list_get_iterator(*entries);
  301|      0|             it != NULL;
  ------------------
  |  Branch (301:14): [True: 0, False: 0]
  ------------------
  302|      0|             it = it->next) {
  303|      0|            struct ssh_knownhosts_entry *entry2 = NULL;
  304|      0|            int cmp;
  305|      0|            entry2 = ssh_iterator_value(struct ssh_knownhosts_entry *, it);
  ------------------
  |  |  114|      0|  ((type)((iterator)->data))
  ------------------
  306|      0|            cmp = ssh_known_hosts_entries_compare(entry, entry2);
  307|      0|            if (cmp == 0) {
  ------------------
  |  Branch (307:17): [True: 0, False: 0]
  ------------------
  308|      0|                ssh_knownhosts_entry_free(entry);
  309|      0|                entry = NULL;
  310|      0|                break;
  311|      0|            }
  312|      0|        }
  313|      0|        if (entry != NULL) {
  ------------------
  |  Branch (313:13): [True: 0, False: 0]
  ------------------
  314|      0|            rc = ssh_list_append(*entries, entry);
  315|      0|            if (rc != SSH_OK) {
  ------------------
  |  |  316|      0|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (315:17): [True: 0, False: 0]
  ------------------
  316|      0|                ssh_knownhosts_entry_free(entry);
  317|      0|                goto error;
  318|      0|            }
  319|      0|        }
  320|      0|    }
  321|       |
  322|      0|    fclose(fp);
  323|      0|    return SSH_OK;
  ------------------
  |  |  316|      0|#define SSH_OK 0     /* No error */
  ------------------
  324|      0|error:
  325|      0|    fclose(fp);
  326|      0|    return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  327|      0|}

ssh_reseed:
   94|  8.64k|void ssh_reseed(void){
   95|  8.64k|#ifndef _WIN32
   96|  8.64k|    struct timeval tv;
   97|       |    gettimeofday(&tv, NULL);
   98|  8.64k|    RAND_add(&tv, sizeof(tv), 0.0);
   99|  8.64k|#endif
  100|  8.64k|}
ssh_kdf:
  337|   103k|{
  338|   103k|    return sshkdf_derive_key(crypto, key, key_len,
  339|   103k|                             key_type, output, requested_len);
  340|   103k|}
hmac_init:
  344|   193k|{
  345|   193k|    HMACCTX ctx = NULL;
  346|   193k|    EVP_PKEY *pkey = NULL;
  347|   193k|    int rc = -1;
  348|       |
  349|   193k|    ctx = EVP_MD_CTX_new();
  350|   193k|    if (ctx == NULL) {
  ------------------
  |  Branch (350:9): [True: 0, False: 193k]
  ------------------
  351|      0|        return NULL;
  352|      0|    }
  353|       |
  354|   193k|    pkey = EVP_PKEY_new_mac_key(EVP_PKEY_HMAC, NULL, key, (int)len);
  355|   193k|    if (pkey == NULL) {
  ------------------
  |  Branch (355:9): [True: 0, False: 193k]
  ------------------
  356|      0|        goto error;
  357|      0|    }
  358|       |
  359|   193k|    switch (type) {
  360|  96.9k|    case SSH_HMAC_SHA1:
  ------------------
  |  Branch (360:5): [True: 96.9k, False: 96.9k]
  ------------------
  361|  96.9k|        rc = EVP_DigestSignInit(ctx, NULL, EVP_sha1(), NULL, pkey);
  362|  96.9k|        break;
  363|  96.9k|    case SSH_HMAC_SHA256:
  ------------------
  |  Branch (363:5): [True: 96.9k, False: 96.9k]
  ------------------
  364|  96.9k|        rc = EVP_DigestSignInit(ctx, NULL, EVP_sha256(), NULL, pkey);
  365|  96.9k|        break;
  366|      0|    case SSH_HMAC_SHA512:
  ------------------
  |  Branch (366:5): [True: 0, False: 193k]
  ------------------
  367|      0|        rc = EVP_DigestSignInit(ctx, NULL, EVP_sha512(), NULL, pkey);
  368|      0|        break;
  369|      0|    case SSH_HMAC_MD5:
  ------------------
  |  Branch (369:5): [True: 0, False: 193k]
  ------------------
  370|      0|        rc = EVP_DigestSignInit(ctx, NULL, EVP_md5(), NULL, pkey);
  371|      0|        break;
  372|      0|    default:
  ------------------
  |  Branch (372:5): [True: 0, False: 193k]
  ------------------
  373|      0|        rc = -1;
  374|      0|        break;
  375|   193k|    }
  376|       |
  377|   193k|    EVP_PKEY_free(pkey);
  378|   193k|    if (rc != 1) {
  ------------------
  |  Branch (378:9): [True: 0, False: 193k]
  ------------------
  379|      0|        goto error;
  380|      0|    }
  381|   193k|    return ctx;
  382|       |
  383|      0|error:
  384|      0|    EVP_MD_CTX_free(ctx);
  385|       |    return NULL;
  386|   193k|}
hmac_update:
  389|   387k|{
  390|       |    return EVP_DigestSignUpdate(ctx, data, len);
  391|   387k|}
hmac_final:
  394|   193k|{
  395|   193k|    size_t res = *len;
  396|   193k|    int rc;
  397|   193k|    rc = EVP_DigestSignFinal(ctx, hashmacbuf, &res);
  398|   193k|    EVP_MD_CTX_free(ctx);
  399|   193k|    if (rc == 1) {
  ------------------
  |  Branch (399:9): [True: 193k, False: 18.4E]
  ------------------
  400|   193k|        *len = res;
  401|   193k|    }
  402|       |
  403|   193k|    return rc;
  404|   193k|}
ssh_get_ciphertab:
 1382|  60.4k|{
 1383|  60.4k|    return ssh_ciphertab;
 1384|  60.4k|}
ssh_crypto_init:
 1391|      2|{
 1392|       |#ifndef HAVE_OPENSSL_EVP_CHACHA20
 1393|       |    size_t i;
 1394|       |#endif
 1395|       |
 1396|      2|    if (libcrypto_initialized) {
  ------------------
  |  Branch (1396:9): [True: 0, False: 2]
  ------------------
 1397|      0|        return SSH_OK;
  ------------------
  |  |  316|      0|#define SSH_OK 0     /* No error */
  ------------------
 1398|      0|    }
 1399|      2|    if (OpenSSL_version_num() != OPENSSL_VERSION_NUMBER) {
  ------------------
  |  Branch (1399:9): [True: 0, False: 2]
  ------------------
 1400|      0|        SSH_LOG(SSH_LOG_DEBUG,
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 1401|      0|                "libssh compiled with %s "
 1402|      0|                "headers, currently running with %s.",
 1403|      0|                OPENSSL_VERSION_TEXT,
 1404|      0|                OpenSSL_version(OpenSSL_version_num()));
 1405|      0|    }
 1406|       |#ifdef CAN_DISABLE_AESNI
 1407|       |    /*
 1408|       |     * disable AES-NI when running within Valgrind, because they generate
 1409|       |     * too many "uninitialized memory access" false positives
 1410|       |     */
 1411|       |    if (RUNNING_ON_VALGRIND) {
 1412|       |        SSH_LOG(SSH_LOG_INFO, "Running within Valgrind, disabling AES-NI");
 1413|       |        /* Bit #57 denotes AES-NI instruction set extension */
 1414|       |        OPENSSL_ia32cap &= ~(1LL << 57);
 1415|       |    }
 1416|       |#endif /* CAN_DISABLE_AESNI */
 1417|       |
 1418|       |#ifndef HAVE_OPENSSL_EVP_CHACHA20
 1419|       |    for (i = 0; ssh_ciphertab[i].name != NULL; i++) {
 1420|       |        int cmp;
 1421|       |
 1422|       |        cmp = strcmp(ssh_ciphertab[i].name, "chacha20-poly1305@openssh.com");
 1423|       |        if (cmp == 0) {
 1424|       |            memcpy(&ssh_ciphertab[i],
 1425|       |                   ssh_get_chacha20poly1305_cipher(),
 1426|       |                   sizeof(struct ssh_cipher_struct));
 1427|       |            break;
 1428|       |        }
 1429|       |    }
 1430|       |#endif /* HAVE_OPENSSL_EVP_CHACHA20 */
 1431|       |
 1432|      2|    libcrypto_initialized = 1;
 1433|       |
 1434|      2|    return SSH_OK;
  ------------------
  |  |  316|      2|#define SSH_OK 0     /* No error */
  ------------------
 1435|      2|}
libcrypto.c:evp_cipher_set_encrypt_key:
  459|  12.9k|{
  460|  12.9k|    int rc;
  461|       |
  462|  12.9k|    evp_cipher_init(cipher);
  463|       |
  464|  12.9k|    rc = EVP_EncryptInit_ex(cipher->ctx, cipher->cipher, NULL, key, IV);
  465|  12.9k|    if (rc != 1){
  ------------------
  |  Branch (465:9): [True: 0, False: 12.9k]
  ------------------
  466|      0|        SSH_LOG(SSH_LOG_TRACE, "EVP_EncryptInit_ex failed");
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  467|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  468|      0|    }
  469|       |
  470|       |    /* For AES-GCM we need to set IV in specific way */
  471|  12.9k|    if (cipher->ciphertype == SSH_AEAD_AES128_GCM ||
  ------------------
  |  Branch (471:9): [True: 0, False: 12.9k]
  ------------------
  472|  12.9k|        cipher->ciphertype == SSH_AEAD_AES256_GCM) {
  ------------------
  |  Branch (472:9): [True: 0, False: 12.9k]
  ------------------
  473|      0|        rc = EVP_CIPHER_CTX_ctrl(cipher->ctx,
  474|      0|                                 EVP_CTRL_GCM_SET_IV_FIXED,
  475|      0|                                 -1,
  476|      0|                                 (uint8_t *)IV);
  477|      0|        if (rc != 1) {
  ------------------
  |  Branch (477:13): [True: 0, False: 0]
  ------------------
  478|      0|            SSH_LOG(SSH_LOG_TRACE, "EVP_CTRL_GCM_SET_IV_FIXED failed");
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  479|      0|            return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  480|      0|        }
  481|      0|    }
  482|       |
  483|  12.9k|    EVP_CIPHER_CTX_set_padding(cipher->ctx, 0);
  484|       |
  485|  12.9k|    return SSH_OK;
  ------------------
  |  |  316|  12.9k|#define SSH_OK 0     /* No error */
  ------------------
  486|  12.9k|}
libcrypto.c:evp_cipher_init:
  407|  25.9k|{
  408|  25.9k|    if (cipher->ctx == NULL) {
  ------------------
  |  Branch (408:9): [True: 25.9k, False: 0]
  ------------------
  409|  25.9k|        cipher->ctx = EVP_CIPHER_CTX_new();
  410|  25.9k|    } else {
  411|      0|        EVP_CIPHER_CTX_reset(cipher->ctx);
  412|      0|    }
  413|       |
  414|  25.9k|    switch(cipher->ciphertype){
  ------------------
  |  Branch (414:12): [True: 25.9k, False: 0]
  ------------------
  415|  8.64k|    case SSH_AES128_CBC:
  ------------------
  |  Branch (415:5): [True: 8.64k, False: 17.2k]
  ------------------
  416|  8.64k|        cipher->cipher = EVP_aes_128_cbc();
  417|  8.64k|        break;
  418|      0|    case SSH_AES192_CBC:
  ------------------
  |  Branch (418:5): [True: 0, False: 25.9k]
  ------------------
  419|      0|        cipher->cipher = EVP_aes_192_cbc();
  420|      0|        break;
  421|      0|    case SSH_AES256_CBC:
  ------------------
  |  Branch (421:5): [True: 0, False: 25.9k]
  ------------------
  422|      0|        cipher->cipher = EVP_aes_256_cbc();
  423|      0|        break;
  424|  8.64k|    case SSH_AES128_CTR:
  ------------------
  |  Branch (424:5): [True: 8.64k, False: 17.2k]
  ------------------
  425|  8.64k|        cipher->cipher = EVP_aes_128_ctr();
  426|  8.64k|        break;
  427|      0|    case SSH_AES192_CTR:
  ------------------
  |  Branch (427:5): [True: 0, False: 25.9k]
  ------------------
  428|      0|        cipher->cipher = EVP_aes_192_ctr();
  429|      0|        break;
  430|  8.64k|    case SSH_AES256_CTR:
  ------------------
  |  Branch (430:5): [True: 8.64k, False: 17.2k]
  ------------------
  431|  8.64k|        cipher->cipher = EVP_aes_256_ctr();
  432|  8.64k|        break;
  433|      0|    case SSH_AEAD_AES128_GCM:
  ------------------
  |  Branch (433:5): [True: 0, False: 25.9k]
  ------------------
  434|      0|        cipher->cipher = EVP_aes_128_gcm();
  435|      0|        break;
  436|      0|    case SSH_AEAD_AES256_GCM:
  ------------------
  |  Branch (436:5): [True: 0, False: 25.9k]
  ------------------
  437|      0|        cipher->cipher = EVP_aes_256_gcm();
  438|      0|        break;
  439|      0|    case SSH_3DES_CBC:
  ------------------
  |  Branch (439:5): [True: 0, False: 25.9k]
  ------------------
  440|      0|        cipher->cipher = EVP_des_ede3_cbc();
  441|      0|        break;
  442|       |#ifdef HAVE_BLOWFISH
  443|       |    case SSH_BLOWFISH_CBC:
  444|       |        cipher->cipher = EVP_bf_cbc();
  445|       |        break;
  446|       |        /* ciphers not using EVP */
  447|       |#endif /* HAVE_BLOWFISH */
  448|      0|    case SSH_AEAD_CHACHA20_POLY1305:
  ------------------
  |  Branch (448:5): [True: 0, False: 25.9k]
  ------------------
  449|      0|        SSH_LOG(SSH_LOG_TRACE, "The ChaCha cipher cannot be handled here");
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  450|      0|        break;
  451|      0|    case SSH_NO_CIPHER:
  ------------------
  |  Branch (451:5): [True: 0, False: 25.9k]
  ------------------
  452|      0|        SSH_LOG(SSH_LOG_TRACE, "No valid ciphertype found");
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  453|      0|        break;
  454|  25.9k|    }
  455|  25.9k|}
libcrypto.c:evp_cipher_set_decrypt_key:
  489|  12.9k|            void *key, void *IV) {
  490|  12.9k|    int rc;
  491|       |
  492|  12.9k|    evp_cipher_init(cipher);
  493|       |
  494|  12.9k|    rc = EVP_DecryptInit_ex(cipher->ctx, cipher->cipher, NULL, key, IV);
  495|  12.9k|    if (rc != 1){
  ------------------
  |  Branch (495:9): [True: 0, False: 12.9k]
  ------------------
  496|      0|        SSH_LOG(SSH_LOG_TRACE, "EVP_DecryptInit_ex failed");
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  497|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  498|      0|    }
  499|       |
  500|       |    /* For AES-GCM we need to set IV in specific way */
  501|  12.9k|    if (cipher->ciphertype == SSH_AEAD_AES128_GCM ||
  ------------------
  |  Branch (501:9): [True: 0, False: 12.9k]
  ------------------
  502|  12.9k|        cipher->ciphertype == SSH_AEAD_AES256_GCM) {
  ------------------
  |  Branch (502:9): [True: 0, False: 12.9k]
  ------------------
  503|      0|        rc = EVP_CIPHER_CTX_ctrl(cipher->ctx,
  504|      0|                                 EVP_CTRL_GCM_SET_IV_FIXED,
  505|      0|                                 -1,
  506|      0|                                 (uint8_t *)IV);
  507|      0|        if (rc != 1) {
  ------------------
  |  Branch (507:13): [True: 0, False: 0]
  ------------------
  508|      0|            SSH_LOG(SSH_LOG_TRACE, "EVP_CTRL_GCM_SET_IV_FIXED failed");
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  509|      0|            return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  510|      0|        }
  511|      0|    }
  512|       |
  513|  12.9k|    EVP_CIPHER_CTX_set_padding(cipher->ctx, 0);
  514|       |
  515|  12.9k|    return SSH_OK;
  ------------------
  |  |  316|  12.9k|#define SSH_OK 0     /* No error */
  ------------------
  516|  12.9k|}
libcrypto.c:evp_cipher_encrypt:
  523|   118k|{
  524|   118k|    int outlen = 0;
  525|   118k|    int rc = 0;
  526|       |
  527|   118k|    rc = EVP_EncryptUpdate(cipher->ctx,
  528|   118k|                           (unsigned char *)out,
  529|   118k|                           &outlen,
  530|   118k|                           (unsigned char *)in,
  531|   118k|                           (int)len);
  532|   118k|    if (rc != 1){
  ------------------
  |  Branch (532:9): [True: 0, False: 118k]
  ------------------
  533|      0|        SSH_LOG(SSH_LOG_TRACE, "EVP_EncryptUpdate failed");
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  534|      0|        return;
  535|      0|    }
  536|   118k|    if (outlen != (int)len){
  ------------------
  |  Branch (536:9): [True: 0, False: 118k]
  ------------------
  537|      0|        SSH_LOG(SSH_LOG_DEBUG,
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  538|      0|                "EVP_EncryptUpdate: output size %d for %zu in",
  539|      0|                outlen,
  540|      0|                len);
  541|      0|        return;
  542|      0|    }
  543|   118k|}
libcrypto.c:evp_cipher_decrypt:
  549|   179k|{
  550|   179k|    int outlen = 0;
  551|   179k|    int rc = 0;
  552|       |
  553|   179k|    rc = EVP_DecryptUpdate(cipher->ctx,
  554|   179k|                           (unsigned char *)out,
  555|   179k|                           &outlen,
  556|   179k|                           (unsigned char *)in,
  557|   179k|                           (int)len);
  558|   179k|    if (rc != 1){
  ------------------
  |  Branch (558:9): [True: 0, False: 179k]
  ------------------
  559|      0|        SSH_LOG(SSH_LOG_TRACE, "EVP_DecryptUpdate failed");
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  560|      0|        return;
  561|      0|    }
  562|   179k|    if (outlen != (int)len){
  ------------------
  |  Branch (562:9): [True: 0, False: 179k]
  ------------------
  563|      0|        SSH_LOG(SSH_LOG_DEBUG,
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  564|      0|                "EVP_DecryptUpdate: output size %d for %zu in",
  565|      0|                outlen,
  566|      0|                len);
  567|      0|        return;
  568|      0|    }
  569|   179k|}
libcrypto.c:evp_cipher_cleanup:
  571|  25.9k|static void evp_cipher_cleanup(struct ssh_cipher_struct *cipher) {
  572|  25.9k|    if (cipher->ctx != NULL) {
  ------------------
  |  Branch (572:9): [True: 25.9k, False: 0]
  ------------------
  573|  25.9k|        EVP_CIPHER_CTX_free(cipher->ctx);
  574|  25.9k|    }
  575|  25.9k|}
libcrypto.c:none_crypt:
 1217|   105k|{
 1218|   105k|    memcpy(out, in, len);
 1219|   105k|}

_ssh_log:
  168|  4.31M|{
  169|  4.31M|    va_list va;
  170|       |
  171|  4.31M|    if (verbosity <= ssh_get_log_level()) {
  ------------------
  |  Branch (171:9): [True: 0, False: 4.31M]
  ------------------
  172|      0|        va_start(va, format);
  173|      0|        ssh_vlog(verbosity, function, format, &va);
  174|       |        va_end(va);
  175|      0|    }
  176|  4.31M|}
ssh_get_log_level:
  252|  4.33M|int ssh_get_log_level(void) {
  253|  4.33M|  return ssh_log_level;
  254|  4.33M|}
ssh_get_log_callback:
  275|  17.2k|ssh_logging_callback ssh_get_log_callback(void) {
  276|  17.2k|  return ssh_log_cb;
  277|  17.2k|}

match_group:
  589|  60.4k|{
  590|  60.4k|    const char *a = NULL;
  591|  60.4k|    const char *z = NULL;
  592|       |
  593|  60.4k|    if (group == NULL || object == NULL) {
  ------------------
  |  Branch (593:9): [True: 0, False: 60.4k]
  |  Branch (593:26): [True: 18.4E, False: 60.4k]
  ------------------
  594|      0|        return 0;
  595|      0|    }
  596|       |
  597|  60.4k|    z = group;
  598|   723k|    do {
  599|   723k|        a = strchr(z, ',');
  600|   723k|        if (a == NULL) {
  ------------------
  |  Branch (600:13): [True: 34.4k, False: 689k]
  ------------------
  601|  34.4k|            if (strcmp(z, object) == 0) {
  ------------------
  |  Branch (601:17): [True: 34.4k, False: 18.4E]
  ------------------
  602|  34.4k|                return 1;
  603|  34.4k|            }
  604|  18.4E|            return 0;
  605|   689k|        } else {
  606|   689k|            if (strncmp(z, object, a - z) == 0) {
  ------------------
  |  Branch (606:17): [True: 25.9k, False: 663k]
  ------------------
  607|  25.9k|                return 1;
  608|  25.9k|            }
  609|   689k|        }
  610|   663k|        z = a + 1;
  611|   663k|    } while (1);
  ------------------
  |  Branch (611:14): [True: 663k, Folded]
  ------------------
  612|       |
  613|       |    /* not reached */
  614|     99|    return 0;
  615|  60.4k|}

sha256_init:
   97|   138k|{
   98|   138k|    int rc;
   99|   138k|    SHA256CTX c = EVP_MD_CTX_new();
  100|   138k|    if (c == NULL) {
  ------------------
  |  Branch (100:9): [True: 0, False: 138k]
  ------------------
  101|      0|        return NULL;
  102|      0|    }
  103|   138k|    rc = EVP_DigestInit_ex(c, EVP_sha256(), NULL);
  104|   138k|    if (rc == 0) {
  ------------------
  |  Branch (104:9): [True: 0, False: 138k]
  ------------------
  105|      0|        EVP_MD_CTX_free(c);
  106|       |        c = NULL;
  107|      0|    }
  108|   138k|    return c;
  109|   138k|}
sha256_update:
  119|   449k|{
  120|   449k|    int rc = EVP_DigestUpdate(c, data, len);
  121|   449k|    if (rc != 1) {
  ------------------
  |  Branch (121:9): [True: 0, False: 449k]
  ------------------
  122|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  123|      0|    }
  124|   449k|    return SSH_OK;
  ------------------
  |  |  316|   449k|#define SSH_OK 0     /* No error */
  ------------------
  125|   449k|}
sha256_final:
  129|   138k|{
  130|   138k|    unsigned int mdlen = 0;
  131|   138k|    int rc = EVP_DigestFinal(c, md, &mdlen);
  132|       |
  133|   138k|    EVP_MD_CTX_free(c);
  134|   138k|    if (rc != 1) {
  ------------------
  |  Branch (134:9): [True: 0, False: 138k]
  ------------------
  135|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  136|      0|    }
  137|   138k|    return SSH_OK;
  ------------------
  |  |  316|   138k|#define SSH_OK 0     /* No error */
  ------------------
  138|   138k|}
sha256:
  142|  34.5k|{
  143|  34.5k|    SHA256CTX c = sha256_init();
  144|  34.5k|    int rc;
  145|       |
  146|  34.5k|    if (c == NULL) {
  ------------------
  |  Branch (146:9): [True: 0, False: 34.5k]
  ------------------
  147|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  148|      0|    }
  149|  34.5k|    rc = sha256_update(c, digest, len);
  150|  34.5k|    if (rc != SSH_OK) {
  ------------------
  |  |  316|  34.5k|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (150:9): [True: 0, False: 34.5k]
  ------------------
  151|      0|        EVP_MD_CTX_free(c);
  152|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  153|      0|    }
  154|  34.5k|    return sha256_final(hash, c);
  155|  34.5k|}

ssh_message_free:
  676|  34.5k|void ssh_message_free(ssh_message msg){
  677|  34.5k|  if (msg == NULL) {
  ------------------
  |  Branch (677:7): [True: 0, False: 34.5k]
  ------------------
  678|      0|    return;
  679|      0|  }
  680|       |
  681|  34.5k|  switch(msg->type) {
  ------------------
  |  Branch (681:10): [True: 34.5k, False: 0]
  ------------------
  682|  8.64k|    case SSH_REQUEST_AUTH:
  ------------------
  |  Branch (682:5): [True: 8.64k, False: 25.9k]
  ------------------
  683|  8.64k|      SAFE_FREE(msg->auth_request.username);
  ------------------
  |  |  373|  8.64k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 8.64k, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 8.64k]
  |  |  ------------------
  ------------------
  684|  8.64k|      SAFE_FREE(msg->auth_request.sigtype);
  ------------------
  |  |  373|  8.64k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 8.64k]
  |  |  |  Branch (373:71): [Folded, False: 8.64k]
  |  |  ------------------
  ------------------
  685|  8.64k|      if (msg->auth_request.password) {
  ------------------
  |  Branch (685:11): [True: 0, False: 8.64k]
  ------------------
  686|      0|          ssh_burn(msg->auth_request.password,
  ------------------
  |  |  388|      0|#define ssh_burn(ptr, len) explicit_bzero((ptr), (len))
  ------------------
  687|      0|                   strlen(msg->auth_request.password));
  688|      0|          SAFE_FREE(msg->auth_request.password);
  ------------------
  |  |  373|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
  689|      0|      }
  690|  8.64k|      ssh_key_free(msg->auth_request.pubkey);
  691|  8.64k|      ssh_key_free(msg->auth_request.server_pubkey);
  692|  8.64k|      break;
  693|  8.64k|    case SSH_REQUEST_CHANNEL_OPEN:
  ------------------
  |  Branch (693:5): [True: 8.64k, False: 25.9k]
  ------------------
  694|  8.64k|      SAFE_FREE(msg->channel_request_open.originator);
  ------------------
  |  |  373|  8.64k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 8.64k]
  |  |  |  Branch (373:71): [Folded, False: 8.64k]
  |  |  ------------------
  ------------------
  695|  8.64k|      SAFE_FREE(msg->channel_request_open.destination);
  ------------------
  |  |  373|  8.64k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 8.64k]
  |  |  |  Branch (373:71): [Folded, False: 8.64k]
  |  |  ------------------
  ------------------
  696|  8.64k|      break;
  697|  8.64k|    case SSH_REQUEST_CHANNEL:
  ------------------
  |  Branch (697:5): [True: 8.64k, False: 25.9k]
  ------------------
  698|  8.64k|      SAFE_FREE(msg->channel_request.TERM);
  ------------------
  |  |  373|  8.64k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 8.64k]
  |  |  |  Branch (373:71): [Folded, False: 8.64k]
  |  |  ------------------
  ------------------
  699|  8.64k|      SAFE_FREE(msg->channel_request.modes);
  ------------------
  |  |  373|  8.64k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 8.64k]
  |  |  |  Branch (373:71): [Folded, False: 8.64k]
  |  |  ------------------
  ------------------
  700|  8.64k|      SAFE_FREE(msg->channel_request.var_name);
  ------------------
  |  |  373|  8.64k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 8.64k]
  |  |  |  Branch (373:71): [Folded, False: 8.64k]
  |  |  ------------------
  ------------------
  701|  8.64k|      SAFE_FREE(msg->channel_request.var_value);
  ------------------
  |  |  373|  8.64k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 8.64k]
  |  |  |  Branch (373:71): [Folded, False: 8.64k]
  |  |  ------------------
  ------------------
  702|  8.64k|      SAFE_FREE(msg->channel_request.command);
  ------------------
  |  |  373|  8.64k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 8.64k, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 8.64k]
  |  |  ------------------
  ------------------
  703|  8.64k|      SAFE_FREE(msg->channel_request.subsystem);
  ------------------
  |  |  373|  8.64k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 8.64k]
  |  |  |  Branch (373:71): [Folded, False: 8.64k]
  |  |  ------------------
  ------------------
  704|  8.64k|      switch (msg->channel_request.type) {
  ------------------
  |  Branch (704:15): [True: 8.64k, False: 0]
  ------------------
  705|  8.64k|      case SSH_CHANNEL_REQUEST_EXEC:
  ------------------
  |  Branch (705:7): [True: 8.64k, False: 0]
  ------------------
  706|  8.64k|          SAFE_FREE(msg->channel_request.command);
  ------------------
  |  |  373|  8.64k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 8.64k]
  |  |  |  Branch (373:71): [Folded, False: 8.64k]
  |  |  ------------------
  ------------------
  707|  8.64k|          break;
  708|      0|      case SSH_CHANNEL_REQUEST_ENV:
  ------------------
  |  Branch (708:7): [True: 0, False: 8.64k]
  ------------------
  709|      0|          SAFE_FREE(msg->channel_request.var_name);
  ------------------
  |  |  373|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
  710|      0|          SAFE_FREE(msg->channel_request.var_value);
  ------------------
  |  |  373|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
  711|      0|          break;
  712|      0|      case SSH_CHANNEL_REQUEST_PTY:
  ------------------
  |  Branch (712:7): [True: 0, False: 8.64k]
  ------------------
  713|      0|          SAFE_FREE(msg->channel_request.TERM);
  ------------------
  |  |  373|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
  714|      0|          break;
  715|      0|      case SSH_CHANNEL_REQUEST_SUBSYSTEM:
  ------------------
  |  Branch (715:7): [True: 0, False: 8.64k]
  ------------------
  716|      0|          SAFE_FREE(msg->channel_request.subsystem);
  ------------------
  |  |  373|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
  717|      0|          break;
  718|      0|      case SSH_CHANNEL_REQUEST_X11:
  ------------------
  |  Branch (718:7): [True: 0, False: 8.64k]
  ------------------
  719|      0|          SAFE_FREE(msg->channel_request.x11_auth_protocol);
  ------------------
  |  |  373|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
  720|      0|          SAFE_FREE(msg->channel_request.x11_auth_cookie);
  ------------------
  |  |  373|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
  721|      0|          break;
  722|  8.64k|      }
  723|  8.64k|      break;
  724|  8.64k|    case SSH_REQUEST_SERVICE:
  ------------------
  |  Branch (724:5): [True: 8.64k, False: 25.9k]
  ------------------
  725|  8.64k|      SAFE_FREE(msg->service_request.service);
  ------------------
  |  |  373|  8.64k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 8.64k, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 8.64k]
  |  |  ------------------
  ------------------
  726|  8.64k|      break;
  727|      0|    case SSH_REQUEST_GLOBAL:
  ------------------
  |  Branch (727:5): [True: 0, False: 34.5k]
  ------------------
  728|      0|      SAFE_FREE(msg->global_request.bind_address);
  ------------------
  |  |  373|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
  729|      0|      break;
  730|  34.5k|  }
  731|  34.5k|  ZERO_STRUCTP(msg);
  ------------------
  |  |  379|  34.5k|#define ZERO_STRUCTP(x) do { if ((x) != NULL) memset((x), 0, sizeof(*(x))); } while(0)
  |  |  ------------------
  |  |  |  Branch (379:34): [True: 34.5k, False: 0]
  |  |  |  Branch (379:85): [Folded, False: 34.5k]
  |  |  ------------------
  ------------------
  732|       |  SAFE_FREE(msg);
  ------------------
  |  |  373|  34.5k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 34.5k, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 34.5k]
  |  |  ------------------
  ------------------
  733|  34.5k|}
ssh_packet_service_request:
  738|  8.64k|{
  739|  8.64k|    char *service_c = NULL;
  740|  8.64k|    ssh_message msg = NULL;
  741|  8.64k|    int rc;
  742|       |
  743|  8.64k|    (void)type;
  744|  8.64k|    (void)user;
  745|       |
  746|  8.64k|    rc = ssh_buffer_unpack(packet,
  ------------------
  |  |   60|  8.64k|    _ssh_buffer_unpack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |  451|  8.64k|        (__VA_NARG_(__VA_ARGS__, __RSEQ_N()))
  |  |  |  |  ------------------
  |  |  |  |  |  |  453|  8.64k|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  448|  8.64k|#define VA_APPLY_VARIADIC_MACRO(macro, tuple) macro tuple
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  453|  8.64k|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  461|  8.64k|        _61,_62,_63,N,...) N
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                   _ssh_buffer_unpack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |   28|  8.64k|#define SSH_BUFFER_PACK_END ((uint32_t) 0x4f65feb3)
  |  |  ------------------
  ------------------
  747|  8.64k|                           "s",
  748|  8.64k|                           &service_c);
  749|  8.64k|    if (rc != SSH_OK) {
  ------------------
  |  |  316|  8.64k|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (749:9): [True: 0, False: 8.64k]
  ------------------
  750|      0|        ssh_set_error(session,
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  751|      0|                      SSH_FATAL,
  752|      0|                      "Invalid SSH_MSG_SERVICE_REQUEST packet");
  753|      0|        goto error;
  754|      0|    }
  755|       |
  756|  8.64k|    SSH_LOG(SSH_LOG_PACKET,
  ------------------
  |  |  281|  8.64k|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  757|  8.64k|            "Received a SERVICE_REQUEST for service %s",
  758|  8.64k|            service_c);
  759|       |
  760|  8.64k|    msg = ssh_message_new(session);
  761|  8.64k|    if (msg == NULL) {
  ------------------
  |  Branch (761:9): [True: 0, False: 8.64k]
  ------------------
  762|      0|        SAFE_FREE(service_c);
  ------------------
  |  |  373|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
  763|      0|        goto error;
  764|      0|    }
  765|       |
  766|  8.64k|    msg->type = SSH_REQUEST_SERVICE;
  767|  8.64k|    msg->service_request.service = service_c;
  768|       |
  769|  8.64k|    ssh_message_queue(session, msg);
  770|  8.64k|error:
  771|       |
  772|  8.64k|    return SSH_PACKET_USED;
  ------------------
  |  |  637|  8.64k|#define SSH_PACKET_USED 1
  ------------------
  773|  8.64k|}
ssh_packet_userauth_request:
  855|  8.64k|{
  856|  8.64k|    ssh_message msg = NULL;
  857|  8.64k|    ssh_signature sig = NULL;
  858|  8.64k|    char *service = NULL;
  859|  8.64k|    char *method = NULL;
  860|  8.64k|    int cmp;
  861|  8.64k|    int rc;
  862|       |
  863|  8.64k|    (void)user;
  864|  8.64k|    (void)type;
  865|       |
  866|  8.64k|    msg = ssh_message_new(session);
  867|  8.64k|    if (msg == NULL) {
  ------------------
  |  Branch (867:9): [True: 0, False: 8.64k]
  ------------------
  868|      0|        ssh_set_error_oom(session);
  ------------------
  |  |  318|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
  869|      0|        goto error;
  870|      0|    }
  871|  8.64k|    msg->type = SSH_REQUEST_AUTH;
  872|  8.64k|    rc = ssh_buffer_unpack(packet,
  ------------------
  |  |   60|  8.64k|    _ssh_buffer_unpack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |  451|  8.64k|        (__VA_NARG_(__VA_ARGS__, __RSEQ_N()))
  |  |  |  |  ------------------
  |  |  |  |  |  |  453|  8.64k|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  448|  8.64k|#define VA_APPLY_VARIADIC_MACRO(macro, tuple) macro tuple
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  453|  8.64k|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  461|  8.64k|        _61,_62,_63,N,...) N
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                   _ssh_buffer_unpack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |   28|  8.64k|#define SSH_BUFFER_PACK_END ((uint32_t) 0x4f65feb3)
  |  |  ------------------
  ------------------
  873|  8.64k|                           "sss",
  874|  8.64k|                           &msg->auth_request.username,
  875|  8.64k|                           &service,
  876|  8.64k|                           &method);
  877|       |
  878|  8.64k|    if (rc != SSH_OK) {
  ------------------
  |  |  316|  8.64k|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (878:9): [True: 0, False: 8.64k]
  ------------------
  879|      0|        goto error;
  880|      0|    }
  881|       |
  882|  8.64k|    SSH_LOG(SSH_LOG_PACKET,
  ------------------
  |  |  281|  8.64k|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  883|  8.64k|            "Auth request for service %s, method %s for user '%s'",
  884|  8.64k|            service,
  885|  8.64k|            method,
  886|  8.64k|            msg->auth_request.username);
  887|       |
  888|  8.64k|    cmp = strcmp(service, "ssh-connection");
  889|  8.64k|    if (cmp != 0) {
  ------------------
  |  Branch (889:9): [True: 0, False: 8.64k]
  ------------------
  890|      0|        SSH_LOG(SSH_LOG_TRACE, "Invalid service request: %s", service);
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  891|      0|        goto end;
  892|      0|    }
  893|       |
  894|  8.64k|    if (strcmp(method, "none") == 0) {
  ------------------
  |  Branch (894:9): [True: 8.64k, False: 0]
  ------------------
  895|  8.64k|        msg->auth_request.method = SSH_AUTH_METHOD_NONE;
  ------------------
  |  |  156|  8.64k|#define SSH_AUTH_METHOD_NONE         0x0001u
  ------------------
  896|  8.64k|        goto end;
  897|  8.64k|    }
  898|       |
  899|      0|    if (strcmp(method, "password") == 0) {
  ------------------
  |  Branch (899:9): [True: 0, False: 0]
  ------------------
  900|      0|        uint8_t tmp;
  901|       |
  902|      0|        msg->auth_request.method = SSH_AUTH_METHOD_PASSWORD;
  ------------------
  |  |  157|      0|#define SSH_AUTH_METHOD_PASSWORD     0x0002u
  ------------------
  903|      0|        rc = ssh_buffer_unpack(packet, "bs", &tmp, &msg->auth_request.password);
  ------------------
  |  |   60|      0|    _ssh_buffer_unpack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |  451|      0|        (__VA_NARG_(__VA_ARGS__, __RSEQ_N()))
  |  |  |  |  ------------------
  |  |  |  |  |  |  453|      0|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  448|      0|#define VA_APPLY_VARIADIC_MACRO(macro, tuple) macro tuple
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  453|      0|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  461|      0|        _61,_62,_63,N,...) N
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                   _ssh_buffer_unpack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |   28|      0|#define SSH_BUFFER_PACK_END ((uint32_t) 0x4f65feb3)
  |  |  ------------------
  ------------------
  904|      0|        if (rc != SSH_OK) {
  ------------------
  |  |  316|      0|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (904:13): [True: 0, False: 0]
  ------------------
  905|      0|            goto error;
  906|      0|        }
  907|      0|        goto end;
  908|      0|    }
  909|       |
  910|      0|    if (strcmp(method, "keyboard-interactive") == 0) {
  ------------------
  |  Branch (910:9): [True: 0, False: 0]
  ------------------
  911|      0|        ssh_string lang = NULL;
  912|      0|        ssh_string submethods = NULL;
  913|       |
  914|      0|        msg->auth_request.method = SSH_AUTH_METHOD_INTERACTIVE;
  ------------------
  |  |  160|      0|#define SSH_AUTH_METHOD_INTERACTIVE  0x0010u
  ------------------
  915|      0|        lang = ssh_buffer_get_ssh_string(packet);
  916|      0|        if (lang == NULL) {
  ------------------
  |  Branch (916:13): [True: 0, False: 0]
  ------------------
  917|      0|            goto error;
  918|      0|        }
  919|       |        /* from the RFC 4256
  920|       |         * 3.1.  Initial Exchange
  921|       |         * "The language tag is deprecated and SHOULD be the empty string."
  922|       |         */
  923|      0|        SSH_STRING_FREE(lang);
  ------------------
  |  |  893|      0|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (893:14): [True: 0, False: 0]
  |  |  |  Branch (893:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
  924|       |
  925|      0|        submethods = ssh_buffer_get_ssh_string(packet);
  926|      0|        if (submethods == NULL) {
  ------------------
  |  Branch (926:13): [True: 0, False: 0]
  ------------------
  927|      0|            goto error;
  928|      0|        }
  929|       |        /* from the RFC 4256
  930|       |         * 3.1.  Initial Exchange
  931|       |         * "One possible implementation strategy of the submethods field on the
  932|       |         *  server is that, unless the user may use multiple different
  933|       |         *  submethods, the server ignores this field."
  934|       |         */
  935|      0|        SSH_STRING_FREE(submethods);
  ------------------
  |  |  893|      0|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (893:14): [True: 0, False: 0]
  |  |  |  Branch (893:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
  936|       |
  937|      0|        goto end;
  938|      0|    }
  939|       |
  940|      0|    if (strcmp(method, "publickey") == 0 ||
  ------------------
  |  Branch (940:9): [True: 0, False: 0]
  ------------------
  941|      0|        strcmp(method, "publickey-hostbound-v00@openssh.com") == 0) {
  ------------------
  |  Branch (941:9): [True: 0, False: 0]
  ------------------
  942|      0|        ssh_string algo = NULL;
  943|      0|        ssh_string pubkey_blob = NULL;
  944|      0|        ssh_string server_pubkey_blob = NULL;
  945|      0|        uint8_t has_sign;
  946|       |
  947|      0|        msg->auth_request.method = SSH_AUTH_METHOD_PUBLICKEY;
  ------------------
  |  |  158|      0|#define SSH_AUTH_METHOD_PUBLICKEY    0x0004u
  ------------------
  948|       |
  949|      0|        rc = ssh_buffer_unpack(packet, "bSS", &has_sign, &algo, &pubkey_blob);
  ------------------
  |  |   60|      0|    _ssh_buffer_unpack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |  451|      0|        (__VA_NARG_(__VA_ARGS__, __RSEQ_N()))
  |  |  |  |  ------------------
  |  |  |  |  |  |  453|      0|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  448|      0|#define VA_APPLY_VARIADIC_MACRO(macro, tuple) macro tuple
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  453|      0|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  461|      0|        _61,_62,_63,N,...) N
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                   _ssh_buffer_unpack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |   28|      0|#define SSH_BUFFER_PACK_END ((uint32_t) 0x4f65feb3)
  |  |  ------------------
  ------------------
  950|       |
  951|      0|        if (rc != SSH_OK) {
  ------------------
  |  |  316|      0|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (951:13): [True: 0, False: 0]
  ------------------
  952|      0|            goto error;
  953|      0|        }
  954|       |
  955|      0|        cmp = strcmp(method, "publickey-hostbound-v00@openssh.com");
  956|      0|        if (cmp == 0) {
  ------------------
  |  Branch (956:13): [True: 0, False: 0]
  ------------------
  957|      0|            server_pubkey_blob = ssh_buffer_get_ssh_string(packet);
  958|      0|            if (server_pubkey_blob == NULL) {
  ------------------
  |  Branch (958:17): [True: 0, False: 0]
  ------------------
  959|      0|                SSH_STRING_FREE(pubkey_blob);
  ------------------
  |  |  893|      0|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (893:14): [True: 0, False: 0]
  |  |  |  Branch (893:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
  960|      0|                SSH_STRING_FREE(algo);
  ------------------
  |  |  893|      0|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (893:14): [True: 0, False: 0]
  |  |  |  Branch (893:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
  961|      0|                goto error;
  962|      0|            }
  963|       |
  964|      0|            rc = ssh_pki_import_pubkey_blob(server_pubkey_blob,
  965|      0|                                            &msg->auth_request.server_pubkey);
  966|      0|            SSH_STRING_FREE(server_pubkey_blob);
  ------------------
  |  |  893|      0|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (893:14): [True: 0, False: 0]
  |  |  |  Branch (893:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
  967|       |
  968|      0|            if (rc < 0) {
  ------------------
  |  Branch (968:17): [True: 0, False: 0]
  ------------------
  969|      0|                SSH_STRING_FREE(pubkey_blob);
  ------------------
  |  |  893|      0|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (893:14): [True: 0, False: 0]
  |  |  |  Branch (893:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
  970|      0|                SSH_STRING_FREE(algo);
  ------------------
  |  |  893|      0|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (893:14): [True: 0, False: 0]
  |  |  |  Branch (893:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
  971|      0|                goto error;
  972|      0|            }
  973|      0|        }
  974|       |
  975|      0|        rc = ssh_pki_import_pubkey_blob(pubkey_blob, &msg->auth_request.pubkey);
  976|      0|        SSH_STRING_FREE(pubkey_blob);
  ------------------
  |  |  893|      0|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (893:14): [True: 0, False: 0]
  |  |  |  Branch (893:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
  977|      0|        pubkey_blob = NULL;
  978|      0|        if (rc < 0) {
  ------------------
  |  Branch (978:13): [True: 0, False: 0]
  ------------------
  979|      0|            SSH_STRING_FREE(algo);
  ------------------
  |  |  893|      0|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (893:14): [True: 0, False: 0]
  |  |  |  Branch (893:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
  980|      0|            algo = NULL;
  981|      0|            goto error;
  982|      0|        }
  983|      0|        msg->auth_request.signature_state = SSH_PUBLICKEY_STATE_NONE;
  984|      0|        msg->auth_request.sigtype = strdup(ssh_string_get_char(algo));
  985|      0|        if (msg->auth_request.sigtype == NULL) {
  ------------------
  |  Branch (985:13): [True: 0, False: 0]
  ------------------
  986|      0|            msg->auth_request.signature_state = SSH_PUBLICKEY_STATE_ERROR;
  987|      0|            SSH_STRING_FREE(algo);
  ------------------
  |  |  893|      0|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (893:14): [True: 0, False: 0]
  |  |  |  Branch (893:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
  988|      0|            algo = NULL;
  989|      0|            goto error;
  990|      0|        }
  991|       |
  992|       |        // has a valid signature ?
  993|      0|        if (has_sign) {
  ------------------
  |  Branch (993:13): [True: 0, False: 0]
  ------------------
  994|      0|            ssh_string sig_blob = NULL;
  995|      0|            ssh_buffer digest = NULL;
  996|       |
  997|      0|            sig_blob = ssh_buffer_get_ssh_string(packet);
  998|      0|            if (sig_blob == NULL) {
  ------------------
  |  Branch (998:17): [True: 0, False: 0]
  ------------------
  999|      0|                SSH_LOG(SSH_LOG_PACKET, "Invalid signature packet from peer");
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 1000|      0|                msg->auth_request.signature_state = SSH_PUBLICKEY_STATE_ERROR;
 1001|      0|                SSH_STRING_FREE(algo);
  ------------------
  |  |  893|      0|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (893:14): [True: 0, False: 0]
  |  |  |  Branch (893:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1002|      0|                algo = NULL;
 1003|      0|                goto error;
 1004|      0|            }
 1005|       |
 1006|      0|            digest = ssh_msg_userauth_build_digest(session,
 1007|      0|                                                   msg,
 1008|      0|                                                   service,
 1009|      0|                                                   algo,
 1010|      0|                                                   method);
 1011|      0|            SSH_STRING_FREE(algo);
  ------------------
  |  |  893|      0|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (893:14): [True: 0, False: 0]
  |  |  |  Branch (893:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1012|      0|            algo = NULL;
 1013|      0|            if (digest == NULL) {
  ------------------
  |  Branch (1013:17): [True: 0, False: 0]
  ------------------
 1014|      0|                SSH_STRING_FREE(sig_blob);
  ------------------
  |  |  893|      0|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (893:14): [True: 0, False: 0]
  |  |  |  Branch (893:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1015|      0|                SSH_LOG(SSH_LOG_PACKET, "Failed to get digest");
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 1016|      0|                msg->auth_request.signature_state = SSH_PUBLICKEY_STATE_WRONG;
 1017|      0|                goto error;
 1018|      0|            }
 1019|       |
 1020|      0|            rc = ssh_pki_import_signature_blob(sig_blob,
 1021|      0|                                               msg->auth_request.pubkey,
 1022|      0|                                               &sig);
 1023|      0|            if (rc == SSH_OK) {
  ------------------
  |  |  316|      0|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (1023:17): [True: 0, False: 0]
  ------------------
 1024|       |                /* Check if the signature from client matches server preferences
 1025|       |                 */
 1026|      0|                if (session->opts.pubkey_accepted_types) {
  ------------------
  |  Branch (1026:21): [True: 0, False: 0]
  ------------------
 1027|      0|                    cmp = match_group(session->opts.pubkey_accepted_types,
 1028|      0|                                      sig->type_c);
 1029|      0|                    if (cmp != 1) {
  ------------------
  |  Branch (1029:25): [True: 0, False: 0]
  ------------------
 1030|      0|                        ssh_set_error(
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
 1031|      0|                            session,
 1032|      0|                            SSH_FATAL,
 1033|      0|                            "Public key from client (%s) doesn't match server "
 1034|      0|                            "preference (%s)",
 1035|      0|                            sig->type_c,
 1036|      0|                            session->opts.pubkey_accepted_types);
 1037|      0|                        rc = SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 1038|      0|                    }
 1039|      0|                }
 1040|       |
 1041|      0|                if (rc == SSH_OK) {
  ------------------
  |  |  316|      0|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (1041:21): [True: 0, False: 0]
  ------------------
 1042|      0|                    rc = ssh_pki_signature_verify(session,
 1043|      0|                                                  sig,
 1044|      0|                                                  msg->auth_request.pubkey,
 1045|      0|                                                  ssh_buffer_get(digest),
 1046|      0|                                                  ssh_buffer_get_len(digest));
 1047|      0|                }
 1048|      0|            }
 1049|      0|            SSH_STRING_FREE(sig_blob);
  ------------------
  |  |  893|      0|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (893:14): [True: 0, False: 0]
  |  |  |  Branch (893:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1050|      0|            SSH_BUFFER_FREE(digest);
  ------------------
  |  |  934|      0|    do { if ((x) != NULL) { ssh_buffer_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (934:14): [True: 0, False: 0]
  |  |  |  Branch (934:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1051|      0|            ssh_signature_free(sig);
 1052|      0|            if (rc < 0) {
  ------------------
  |  Branch (1052:17): [True: 0, False: 0]
  ------------------
 1053|      0|                SSH_LOG(SSH_LOG_PACKET,
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 1054|      0|                        "Received an invalid signature from peer");
 1055|      0|                msg->auth_request.signature_state = SSH_PUBLICKEY_STATE_WRONG;
 1056|      0|                goto error;
 1057|      0|            }
 1058|       |
 1059|      0|            SSH_LOG(SSH_LOG_PACKET, "Valid signature received");
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 1060|       |
 1061|      0|            cmp = strcmp(method, "publickey-hostbound-v00@openssh.com");
 1062|      0|            if (cmp == 0) {
  ------------------
  |  Branch (1062:17): [True: 0, False: 0]
  ------------------
 1063|      0|                ssh_key server_key = NULL;
 1064|       |
 1065|      0|                if (msg->auth_request.server_pubkey == NULL) {
  ------------------
  |  Branch (1065:21): [True: 0, False: 0]
  ------------------
 1066|      0|                    SSH_LOG(SSH_LOG_PACKET,
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 1067|      0|                            "Server public key not provided by client");
 1068|      0|                    msg->auth_request.signature_state =
 1069|      0|                        SSH_PUBLICKEY_STATE_WRONG;
 1070|      0|                    goto error;
 1071|      0|                }
 1072|       |
 1073|      0|                rc = ssh_get_server_publickey(session, &server_key);
 1074|      0|                if (rc != SSH_OK) {
  ------------------
  |  |  316|      0|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (1074:21): [True: 0, False: 0]
  ------------------
 1075|      0|                    SSH_LOG(SSH_LOG_PACKET,
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 1076|      0|                            "Failed to get server public key for hostbound "
 1077|      0|                            "verification");
 1078|      0|                    msg->auth_request.signature_state =
 1079|      0|                        SSH_PUBLICKEY_STATE_ERROR;
 1080|      0|                    ssh_key_free(server_key);
 1081|      0|                    goto error;
 1082|      0|                }
 1083|       |
 1084|      0|                if (ssh_key_cmp(server_key,
  ------------------
  |  Branch (1084:21): [True: 0, False: 0]
  ------------------
 1085|      0|                                msg->auth_request.server_pubkey,
 1086|      0|                                SSH_KEY_CMP_PUBLIC) != 0) {
 1087|      0|                    SSH_LOG(SSH_LOG_PACKET,
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 1088|      0|                            "Server public key doesn't match the one provided "
 1089|      0|                            "by client");
 1090|      0|                    msg->auth_request.signature_state =
 1091|      0|                        SSH_PUBLICKEY_STATE_WRONG;
 1092|      0|                    ssh_key_free(server_key);
 1093|      0|                    goto error;
 1094|      0|                }
 1095|      0|                ssh_key_free(server_key);
 1096|      0|            }
 1097|       |
 1098|      0|            msg->auth_request.signature_state = SSH_PUBLICKEY_STATE_VALID;
 1099|      0|        }
 1100|       |
 1101|      0|        SAFE_FREE(method);
  ------------------
  |  |  373|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1102|      0|        SSH_STRING_FREE(algo);
  ------------------
  |  |  893|      0|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (893:14): [True: 0, False: 0]
  |  |  |  Branch (893:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1103|      0|        goto end;
 1104|      0|    }
 1105|       |#ifdef WITH_GSSAPI
 1106|       |    if (strcmp(method, "gssapi-with-mic") == 0) {
 1107|       |        uint32_t n_oid;
 1108|       |        ssh_string *oids = NULL;
 1109|       |        ssh_string oid = NULL;
 1110|       |        char *hexa = NULL;
 1111|       |        int i;
 1112|       |        ssh_buffer_get_u32(packet, &n_oid);
 1113|       |        n_oid = ntohl(n_oid);
 1114|       |        if (n_oid > 100) {
 1115|       |            ssh_set_error(
 1116|       |                session,
 1117|       |                SSH_FATAL,
 1118|       |                "USERAUTH_REQUEST: gssapi-with-mic OID count too big (%d)",
 1119|       |                n_oid);
 1120|       |            goto error;
 1121|       |        }
 1122|       |        SSH_LOG(SSH_LOG_PACKET, "gssapi: %d OIDs", n_oid);
 1123|       |        oids = calloc(n_oid, sizeof(ssh_string));
 1124|       |        if (oids == NULL) {
 1125|       |            ssh_set_error_oom(session);
 1126|       |            goto error;
 1127|       |        }
 1128|       |        for (i = 0; i < (int)n_oid; ++i) {
 1129|       |            oid = ssh_buffer_get_ssh_string(packet);
 1130|       |            if (oid == NULL) {
 1131|       |                for (i = i - 1; i >= 0; --i) {
 1132|       |                    SAFE_FREE(oids[i]);
 1133|       |                }
 1134|       |                SAFE_FREE(oids);
 1135|       |                ssh_set_error(session,
 1136|       |                              SSH_LOG_PACKET,
 1137|       |                              "USERAUTH_REQUEST: gssapi-with-mic missing OID");
 1138|       |                goto error;
 1139|       |            }
 1140|       |            oids[i] = oid;
 1141|       |            if (session->common.log_verbosity >= SSH_LOG_PACKET) {
 1142|       |                hexa = ssh_get_hexa(ssh_string_data(oid), ssh_string_len(oid));
 1143|       |                SSH_LOG(SSH_LOG_PACKET, "gssapi: OID %d: %s", i, hexa);
 1144|       |                SAFE_FREE(hexa);
 1145|       |            }
 1146|       |        }
 1147|       |        ssh_gssapi_handle_userauth(session,
 1148|       |                                   msg->auth_request.username,
 1149|       |                                   n_oid,
 1150|       |                                   oids);
 1151|       |
 1152|       |        for (i = 0; i < (int)n_oid; ++i) {
 1153|       |            SAFE_FREE(oids[i]);
 1154|       |        }
 1155|       |        SAFE_FREE(oids);
 1156|       |        /* bypass the message queue thing */
 1157|       |        SAFE_FREE(service);
 1158|       |        SAFE_FREE(method);
 1159|       |        SSH_MESSAGE_FREE(msg);
 1160|       |
 1161|       |        return SSH_PACKET_USED;
 1162|       |    }
 1163|       |    if (strcmp(method, "gssapi-keyex") == 0) {
 1164|       |        gss_buffer_desc received_mic = GSS_C_EMPTY_BUFFER;
 1165|       |        gss_buffer_desc mic_buf = GSS_C_EMPTY_BUFFER;
 1166|       |        ssh_string mic_token_string = NULL;
 1167|       |        OM_uint32 maj_stat, min_stat;
 1168|       |        ssh_buffer buf = NULL;
 1169|       |
 1170|       |        if (!ssh_kex_is_gss(session->current_crypto)) {
 1171|       |            ssh_set_error(session,
 1172|       |                          SSH_FATAL,
 1173|       |                          "Attempt to authenticate with gssapi-keyex without "
 1174|       |                          "doing GSSAPI Key Exchange.");
 1175|       |            ssh_auth_reply_default(session, 0);
 1176|       |            goto error;
 1177|       |        }
 1178|       |
 1179|       |        if (session->gssapi == NULL || session->gssapi->ctx == NULL) {
 1180|       |            ssh_set_error(session, SSH_FATAL, "GSSAPI context not initialized");
 1181|       |            ssh_auth_reply_default(session, 0);
 1182|       |            goto error;
 1183|       |        }
 1184|       |
 1185|       |        rc = ssh_buffer_unpack(packet, "S", &mic_token_string);
 1186|       |        if (rc != SSH_OK) {
 1187|       |            ssh_auth_reply_default(session, 0);
 1188|       |            goto error;
 1189|       |        }
 1190|       |        received_mic.length = ssh_string_len(mic_token_string);
 1191|       |        received_mic.value = ssh_string_data(mic_token_string);
 1192|       |
 1193|       |        SAFE_FREE(session->gssapi->user);
 1194|       |        session->gssapi->user = strdup(msg->auth_request.username);
 1195|       |        buf = ssh_gssapi_build_mic(session, "gssapi-keyex");
 1196|       |        if (buf == NULL) {
 1197|       |            ssh_set_error_oom(session);
 1198|       |            SSH_STRING_FREE(mic_token_string);
 1199|       |            ssh_auth_reply_default(session, 0);
 1200|       |            goto error;
 1201|       |        }
 1202|       |
 1203|       |        mic_buf.length = ssh_buffer_get_len(buf);
 1204|       |        mic_buf.value = ssh_buffer_get(buf);
 1205|       |
 1206|       |        maj_stat = gss_verify_mic(&min_stat,
 1207|       |                                  session->gssapi->ctx,
 1208|       |                                  &mic_buf,
 1209|       |                                  &received_mic,
 1210|       |                                  NULL);
 1211|       |        if (maj_stat != GSS_S_COMPLETE) {
 1212|       |            ssh_set_error(session,
 1213|       |                          SSH_FATAL,
 1214|       |                          "Failed to verify MIC for gssapi-keyex auth");
 1215|       |            SSH_BUFFER_FREE(buf);
 1216|       |            SSH_STRING_FREE(mic_token_string);
 1217|       |            ssh_auth_reply_default(session, 0);
 1218|       |            goto error;
 1219|       |        }
 1220|       |
 1221|       |        ssh_auth_reply_success(session, 0);
 1222|       |
 1223|       |        /* bypass the message queue thing */
 1224|       |        SAFE_FREE(service);
 1225|       |        SAFE_FREE(method);
 1226|       |        SSH_BUFFER_FREE(buf);
 1227|       |        SSH_MESSAGE_FREE(msg);
 1228|       |        SSH_STRING_FREE(mic_token_string);
 1229|       |
 1230|       |        return SSH_PACKET_USED;
 1231|       |    }
 1232|       |#endif
 1233|       |
 1234|      0|    msg->auth_request.method = SSH_AUTH_METHOD_UNKNOWN;
  ------------------
  |  |  155|      0|#define SSH_AUTH_METHOD_UNKNOWN      0x0000u
  ------------------
 1235|      0|    SAFE_FREE(method);
  ------------------
  |  |  373|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1236|      0|    goto end;
 1237|      0|error:
 1238|      0|    SAFE_FREE(service);
  ------------------
  |  |  373|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1239|      0|    SAFE_FREE(method);
  ------------------
  |  |  373|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1240|       |
 1241|      0|    SSH_MESSAGE_FREE(msg);
  ------------------
  |  |  697|      0|    do { if ((x) != NULL) { ssh_message_free(x); (x) = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (697:14): [True: 0, False: 0]
  |  |  |  Branch (697:72): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1242|       |
 1243|      0|    return SSH_PACKET_USED;
  ------------------
  |  |  637|      0|#define SSH_PACKET_USED 1
  ------------------
 1244|  8.64k|end:
 1245|  8.64k|    SAFE_FREE(service);
  ------------------
  |  |  373|  8.64k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 8.64k, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 8.64k]
  |  |  ------------------
  ------------------
 1246|  8.64k|    SAFE_FREE(method);
  ------------------
  |  |  373|  8.64k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 8.64k, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 8.64k]
  |  |  ------------------
  ------------------
 1247|       |
 1248|  8.64k|    ssh_message_queue(session, msg);
 1249|       |
 1250|  8.64k|    return SSH_PACKET_USED;
  ------------------
  |  |  637|  8.64k|#define SSH_PACKET_USED 1
  ------------------
 1251|      0|}
ssh_packet_channel_open:
 1390|  8.64k|SSH_PACKET_CALLBACK(ssh_packet_channel_open){
 1391|  8.64k|  ssh_message msg = NULL;
 1392|  8.64k|  char *type_c = NULL;
 1393|  8.64k|  uint32_t originator_port, destination_port;
 1394|  8.64k|  int rc;
 1395|       |
 1396|  8.64k|  (void)type;
 1397|  8.64k|  (void)user;
 1398|  8.64k|  msg = ssh_message_new(session);
 1399|  8.64k|  if (msg == NULL) {
  ------------------
  |  Branch (1399:7): [True: 0, False: 8.64k]
  ------------------
 1400|      0|    ssh_set_error_oom(session);
  ------------------
  |  |  318|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
 1401|      0|    goto error;
 1402|      0|  }
 1403|       |
 1404|  8.64k|  msg->type = SSH_REQUEST_CHANNEL_OPEN;
 1405|  8.64k|  rc = ssh_buffer_unpack(packet, "s", &type_c);
  ------------------
  |  |   60|  8.64k|    _ssh_buffer_unpack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |  451|  8.64k|        (__VA_NARG_(__VA_ARGS__, __RSEQ_N()))
  |  |  |  |  ------------------
  |  |  |  |  |  |  453|  8.64k|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  448|  8.64k|#define VA_APPLY_VARIADIC_MACRO(macro, tuple) macro tuple
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  453|  8.64k|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  461|  8.64k|        _61,_62,_63,N,...) N
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                   _ssh_buffer_unpack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |   28|  8.64k|#define SSH_BUFFER_PACK_END ((uint32_t) 0x4f65feb3)
  |  |  ------------------
  ------------------
 1406|  8.64k|  if (rc != SSH_OK){
  ------------------
  |  |  316|  8.64k|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (1406:7): [True: 0, False: 8.64k]
  ------------------
 1407|      0|      goto error;
 1408|      0|  }
 1409|       |
 1410|  8.64k|  SSH_LOG(SSH_LOG_PACKET,
  ------------------
  |  |  281|  8.64k|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 1411|  8.64k|      "Clients wants to open a %s channel", type_c);
 1412|       |
 1413|  8.64k|  rc = ssh_buffer_unpack(packet,
  ------------------
  |  |   60|  8.64k|    _ssh_buffer_unpack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |  451|  8.64k|        (__VA_NARG_(__VA_ARGS__, __RSEQ_N()))
  |  |  |  |  ------------------
  |  |  |  |  |  |  453|  8.64k|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  448|  8.64k|#define VA_APPLY_VARIADIC_MACRO(macro, tuple) macro tuple
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  453|  8.64k|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  461|  8.64k|        _61,_62,_63,N,...) N
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                   _ssh_buffer_unpack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |   28|  8.64k|#define SSH_BUFFER_PACK_END ((uint32_t) 0x4f65feb3)
  |  |  ------------------
  ------------------
 1414|  8.64k|                         "ddd",
 1415|  8.64k|                         &msg->channel_request_open.sender,
 1416|  8.64k|                         &msg->channel_request_open.window,
 1417|  8.64k|                         &msg->channel_request_open.packet_size);
 1418|  8.64k|  if (rc != SSH_OK){
  ------------------
  |  |  316|  8.64k|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (1418:7): [True: 0, False: 8.64k]
  ------------------
 1419|      0|      goto error;
 1420|      0|  }
 1421|       |
 1422|  8.64k|  if (msg->channel_request_open.packet_size == 0) {
  ------------------
  |  Branch (1422:7): [True: 0, False: 8.64k]
  ------------------
 1423|      0|      ssh_set_error(session,
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
 1424|      0|                    SSH_FATAL,
 1425|      0|                    "Invalid maximum packet size 0 in SSH2_MSG_CHANNEL_OPEN");
 1426|      0|      goto error;
 1427|      0|  }
 1428|       |
 1429|  8.64k|  if (session->session_state != SSH_SESSION_STATE_AUTHENTICATED){
  ------------------
  |  Branch (1429:7): [True: 0, False: 8.64k]
  ------------------
 1430|      0|    ssh_set_error(session,SSH_FATAL, "Invalid state when receiving channel open request (must be authenticated)");
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
 1431|      0|    goto error;
 1432|      0|  }
 1433|       |
 1434|  8.64k|  if (strcmp(type_c, "session") == 0) {
  ------------------
  |  Branch (1434:7): [True: 8.64k, False: 0]
  ------------------
 1435|  8.64k|    if (session->flags & SSH_SESSION_FLAG_NO_MORE_SESSIONS) {
  ------------------
  |  |   81|  8.64k|#define SSH_SESSION_FLAG_NO_MORE_SESSIONS 0x0004
  ------------------
  |  Branch (1435:9): [True: 0, False: 8.64k]
  ------------------
 1436|      0|        ssh_session_set_disconnect_message(session, "No more sessions allowed!");
 1437|      0|        ssh_set_error(session, SSH_FATAL, "No more sessions allowed!");
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
 1438|      0|        session->session_state = SSH_SESSION_STATE_ERROR;
 1439|      0|        ssh_send_disconnect(session);
 1440|      0|        goto error;
 1441|      0|    }
 1442|       |
 1443|  8.64k|    msg->channel_request_open.type = SSH_CHANNEL_SESSION;
 1444|  8.64k|    SAFE_FREE(type_c);
  ------------------
  |  |  373|  8.64k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 8.64k, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 8.64k]
  |  |  ------------------
  ------------------
 1445|  8.64k|    goto end;
 1446|  8.64k|  }
 1447|       |
 1448|      0|  if (strcmp(type_c,"direct-tcpip") == 0) {
  ------------------
  |  Branch (1448:7): [True: 0, False: 0]
  ------------------
 1449|      0|    rc = ssh_buffer_unpack(packet,
  ------------------
  |  |   60|      0|    _ssh_buffer_unpack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |  451|      0|        (__VA_NARG_(__VA_ARGS__, __RSEQ_N()))
  |  |  |  |  ------------------
  |  |  |  |  |  |  453|      0|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  448|      0|#define VA_APPLY_VARIADIC_MACRO(macro, tuple) macro tuple
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  453|      0|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  461|      0|        _61,_62,_63,N,...) N
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                   _ssh_buffer_unpack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |   28|      0|#define SSH_BUFFER_PACK_END ((uint32_t) 0x4f65feb3)
  |  |  ------------------
  ------------------
 1450|      0|                           "sdsd",
 1451|      0|                           &msg->channel_request_open.destination,
 1452|      0|                           &destination_port,
 1453|      0|                           &msg->channel_request_open.originator,
 1454|      0|                           &originator_port);
 1455|      0|    if (rc != SSH_OK) {
  ------------------
  |  |  316|      0|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (1455:9): [True: 0, False: 0]
  ------------------
 1456|      0|      goto error;
 1457|      0|    }
 1458|       |
 1459|      0|    msg->channel_request_open.destination_port = (uint16_t) destination_port;
 1460|      0|    msg->channel_request_open.originator_port = (uint16_t) originator_port;
 1461|      0|    msg->channel_request_open.type = SSH_CHANNEL_DIRECT_TCPIP;
 1462|      0|    goto end;
 1463|      0|  }
 1464|       |
 1465|      0|  if (strcmp(type_c,"forwarded-tcpip") == 0) {
  ------------------
  |  Branch (1465:7): [True: 0, False: 0]
  ------------------
 1466|      0|    rc = ssh_buffer_unpack(packet, "sdsd",
  ------------------
  |  |   60|      0|    _ssh_buffer_unpack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |  451|      0|        (__VA_NARG_(__VA_ARGS__, __RSEQ_N()))
  |  |  |  |  ------------------
  |  |  |  |  |  |  453|      0|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  448|      0|#define VA_APPLY_VARIADIC_MACRO(macro, tuple) macro tuple
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  453|      0|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  461|      0|        _61,_62,_63,N,...) N
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                   _ssh_buffer_unpack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |   28|      0|#define SSH_BUFFER_PACK_END ((uint32_t) 0x4f65feb3)
  |  |  ------------------
  ------------------
 1467|      0|            &msg->channel_request_open.destination,
 1468|      0|            &destination_port,
 1469|      0|            &msg->channel_request_open.originator,
 1470|      0|            &originator_port
 1471|      0|        );
 1472|      0|    if (rc != SSH_OK){
  ------------------
  |  |  316|      0|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (1472:9): [True: 0, False: 0]
  ------------------
 1473|      0|        goto error;
 1474|      0|    }
 1475|      0|    msg->channel_request_open.destination_port = (uint16_t) destination_port;
 1476|      0|    msg->channel_request_open.originator_port = (uint16_t) originator_port;
 1477|      0|    msg->channel_request_open.type = SSH_CHANNEL_FORWARDED_TCPIP;
 1478|      0|    goto end;
 1479|      0|  }
 1480|       |
 1481|      0|  if (strcmp(type_c,"x11") == 0) {
  ------------------
  |  Branch (1481:7): [True: 0, False: 0]
  ------------------
 1482|      0|    rc = ssh_buffer_unpack(packet, "sd",
  ------------------
  |  |   60|      0|    _ssh_buffer_unpack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |  451|      0|        (__VA_NARG_(__VA_ARGS__, __RSEQ_N()))
  |  |  |  |  ------------------
  |  |  |  |  |  |  453|      0|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  448|      0|#define VA_APPLY_VARIADIC_MACRO(macro, tuple) macro tuple
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  453|      0|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  461|      0|        _61,_62,_63,N,...) N
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                   _ssh_buffer_unpack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |   28|      0|#define SSH_BUFFER_PACK_END ((uint32_t) 0x4f65feb3)
  |  |  ------------------
  ------------------
 1483|      0|            &msg->channel_request_open.originator,
 1484|      0|            &originator_port);
 1485|      0|    if (rc != SSH_OK){
  ------------------
  |  |  316|      0|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (1485:9): [True: 0, False: 0]
  ------------------
 1486|      0|        goto error;
 1487|      0|    }
 1488|      0|    msg->channel_request_open.originator_port = (uint16_t) originator_port;
 1489|      0|    msg->channel_request_open.type = SSH_CHANNEL_X11;
 1490|      0|    goto end;
 1491|      0|  }
 1492|       |
 1493|      0|  if (strcmp(type_c,"auth-agent@openssh.com") == 0) {
  ------------------
  |  Branch (1493:7): [True: 0, False: 0]
  ------------------
 1494|      0|    msg->channel_request_open.type = SSH_CHANNEL_AUTH_AGENT;
 1495|      0|    goto end;
 1496|      0|  }
 1497|       |
 1498|      0|  msg->channel_request_open.type = SSH_CHANNEL_UNKNOWN;
 1499|      0|  goto end;
 1500|       |
 1501|      0|error:
 1502|      0|  SSH_MESSAGE_FREE(msg);
  ------------------
  |  |  697|      0|    do { if ((x) != NULL) { ssh_message_free(x); (x) = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (697:14): [True: 0, False: 0]
  |  |  |  Branch (697:72): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1503|  8.64k|end:
 1504|  8.64k|  SAFE_FREE(type_c);
  ------------------
  |  |  373|  8.64k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 8.64k]
  |  |  |  Branch (373:71): [Folded, False: 8.64k]
  |  |  ------------------
  ------------------
 1505|  8.64k|  if(msg != NULL)
  ------------------
  |  Branch (1505:6): [True: 8.64k, False: 0]
  ------------------
 1506|  8.64k|    ssh_message_queue(session,msg);
 1507|       |
 1508|  8.64k|  return SSH_PACKET_USED;
  ------------------
  |  |  637|  8.64k|#define SSH_PACKET_USED 1
  ------------------
 1509|      0|}
ssh_message_channel_request_open_reply_accept_channel:
 1524|  8.64k|{
 1525|  8.64k|    ssh_session session = NULL;
 1526|  8.64k|    int rc;
 1527|       |
 1528|  8.64k|    if (msg == NULL) {
  ------------------
  |  Branch (1528:9): [True: 0, False: 8.64k]
  ------------------
 1529|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 1530|      0|    }
 1531|       |
 1532|  8.64k|    session = msg->session;
 1533|       |
 1534|  8.64k|    chan->local_channel = ssh_channel_new_id(session);
 1535|  8.64k|    chan->local_maxpacket = 35000;
 1536|  8.64k|    chan->local_window = 32000;
 1537|  8.64k|    chan->remote_channel = msg->channel_request_open.sender;
 1538|  8.64k|    chan->remote_maxpacket = msg->channel_request_open.packet_size;
 1539|  8.64k|    chan->remote_window = msg->channel_request_open.window;
 1540|  8.64k|    chan->state = SSH_CHANNEL_STATE_OPEN;
 1541|  8.64k|    chan->flags &= ~SSH_CHANNEL_FLAG_NOT_BOUND;
  ------------------
  |  |   64|  8.64k|#define SSH_CHANNEL_FLAG_NOT_BOUND 0x0008
  ------------------
 1542|       |
 1543|  8.64k|    rc = ssh_buffer_pack(session->out_buffer,
  ------------------
  |  |   50|  8.64k|    _ssh_buffer_pack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |  451|  8.64k|        (__VA_NARG_(__VA_ARGS__, __RSEQ_N()))
  |  |  |  |  ------------------
  |  |  |  |  |  |  453|  8.64k|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  448|  8.64k|#define VA_APPLY_VARIADIC_MACRO(macro, tuple) macro tuple
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  453|  8.64k|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  461|  8.64k|        _61,_62,_63,N,...) N
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                   _ssh_buffer_pack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |   28|  8.64k|#define SSH_BUFFER_PACK_END ((uint32_t) 0x4f65feb3)
  |  |  ------------------
  ------------------
 1544|  8.64k|                         "bdddd",
 1545|  8.64k|                         SSH2_MSG_CHANNEL_OPEN_CONFIRMATION,
 1546|  8.64k|                         chan->remote_channel,
 1547|  8.64k|                         chan->local_channel,
 1548|  8.64k|                         chan->local_window,
 1549|  8.64k|                         chan->local_maxpacket);
 1550|  8.64k|    if (rc != SSH_OK) {
  ------------------
  |  |  316|  8.64k|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (1550:9): [True: 0, False: 8.64k]
  ------------------
 1551|      0|        ssh_set_error_oom(session);
  ------------------
  |  |  318|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
 1552|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 1553|      0|    }
 1554|       |
 1555|  8.64k|    SSH_LOG(SSH_LOG_PACKET,
  ------------------
  |  |  281|  8.64k|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 1556|  8.64k|            "Accepting a channel request_open for chan %" PRIu32,
 1557|  8.64k|            chan->remote_channel);
 1558|       |
 1559|  8.64k|    rc = ssh_packet_send(session);
 1560|       |
 1561|  8.64k|    return rc;
 1562|  8.64k|}
ssh_message_handle_channel_request:
 1621|  8.64k|{
 1622|  8.64k|    ssh_message msg = NULL;
 1623|  8.64k|    int rc;
 1624|       |
 1625|  8.64k|    msg = ssh_message_new(session);
 1626|  8.64k|    if (msg == NULL) {
  ------------------
  |  Branch (1626:9): [True: 0, False: 8.64k]
  ------------------
 1627|      0|        ssh_set_error_oom(session);
  ------------------
  |  |  318|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
 1628|      0|        goto error;
 1629|      0|    }
 1630|       |
 1631|  8.64k|    SSH_LOG(SSH_LOG_PACKET,
  ------------------
  |  |  281|  8.64k|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 1632|  8.64k|            "Received a %s channel_request for channel (%" PRIu32 ":%" PRIu32
 1633|  8.64k|            ") (want_reply=%hhu)",
 1634|  8.64k|            request,
 1635|  8.64k|            channel->local_channel,
 1636|  8.64k|            channel->remote_channel,
 1637|  8.64k|            want_reply);
 1638|       |
 1639|  8.64k|    msg->type = SSH_REQUEST_CHANNEL;
 1640|  8.64k|    msg->channel_request.channel = channel;
 1641|  8.64k|    msg->channel_request.want_reply = want_reply;
 1642|       |
 1643|  8.64k|    if (strcmp(request, "pty-req") == 0) {
  ------------------
  |  Branch (1643:9): [True: 0, False: 8.64k]
  ------------------
 1644|      0|        rc = ssh_buffer_unpack(packet,
  ------------------
  |  |   60|      0|    _ssh_buffer_unpack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |  451|      0|        (__VA_NARG_(__VA_ARGS__, __RSEQ_N()))
  |  |  |  |  ------------------
  |  |  |  |  |  |  453|      0|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  448|      0|#define VA_APPLY_VARIADIC_MACRO(macro, tuple) macro tuple
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  453|      0|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  461|      0|        _61,_62,_63,N,...) N
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                   _ssh_buffer_unpack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |   28|      0|#define SSH_BUFFER_PACK_END ((uint32_t) 0x4f65feb3)
  |  |  ------------------
  ------------------
 1645|      0|                               "sddddS",
 1646|      0|                               &msg->channel_request.TERM,
 1647|      0|                               &msg->channel_request.width,
 1648|      0|                               &msg->channel_request.height,
 1649|      0|                               &msg->channel_request.pxwidth,
 1650|      0|                               &msg->channel_request.pxheight,
 1651|      0|                               &msg->channel_request.modes);
 1652|       |
 1653|      0|        msg->channel_request.type = SSH_CHANNEL_REQUEST_PTY;
 1654|       |
 1655|      0|        if (rc != SSH_OK) {
  ------------------
  |  |  316|      0|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (1655:13): [True: 0, False: 0]
  ------------------
 1656|      0|            goto error;
 1657|      0|        }
 1658|      0|        goto end;
 1659|      0|    }
 1660|       |
 1661|  8.64k|    if (strcmp(request, "window-change") == 0) {
  ------------------
  |  Branch (1661:9): [True: 0, False: 8.64k]
  ------------------
 1662|      0|        msg->channel_request.type = SSH_CHANNEL_REQUEST_WINDOW_CHANGE;
 1663|      0|        rc = ssh_buffer_unpack(packet,
  ------------------
  |  |   60|      0|    _ssh_buffer_unpack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |  451|      0|        (__VA_NARG_(__VA_ARGS__, __RSEQ_N()))
  |  |  |  |  ------------------
  |  |  |  |  |  |  453|      0|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  448|      0|#define VA_APPLY_VARIADIC_MACRO(macro, tuple) macro tuple
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  453|      0|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  461|      0|        _61,_62,_63,N,...) N
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                   _ssh_buffer_unpack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |   28|      0|#define SSH_BUFFER_PACK_END ((uint32_t) 0x4f65feb3)
  |  |  ------------------
  ------------------
 1664|      0|                               "dddd",
 1665|      0|                               &msg->channel_request.width,
 1666|      0|                               &msg->channel_request.height,
 1667|      0|                               &msg->channel_request.pxwidth,
 1668|      0|                               &msg->channel_request.pxheight);
 1669|      0|        if (rc != SSH_OK) {
  ------------------
  |  |  316|      0|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (1669:13): [True: 0, False: 0]
  ------------------
 1670|      0|            goto error;
 1671|      0|        }
 1672|      0|        goto end;
 1673|      0|    }
 1674|       |
 1675|  8.64k|    if (strcmp(request, "subsystem") == 0) {
  ------------------
  |  Branch (1675:9): [True: 0, False: 8.64k]
  ------------------
 1676|      0|        rc = ssh_buffer_unpack(packet, "s", &msg->channel_request.subsystem);
  ------------------
  |  |   60|      0|    _ssh_buffer_unpack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |  451|      0|        (__VA_NARG_(__VA_ARGS__, __RSEQ_N()))
  |  |  |  |  ------------------
  |  |  |  |  |  |  453|      0|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  448|      0|#define VA_APPLY_VARIADIC_MACRO(macro, tuple) macro tuple
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  453|      0|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  461|      0|        _61,_62,_63,N,...) N
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                   _ssh_buffer_unpack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |   28|      0|#define SSH_BUFFER_PACK_END ((uint32_t) 0x4f65feb3)
  |  |  ------------------
  ------------------
 1677|      0|        msg->channel_request.type = SSH_CHANNEL_REQUEST_SUBSYSTEM;
 1678|      0|        if (rc != SSH_OK) {
  ------------------
  |  |  316|      0|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (1678:13): [True: 0, False: 0]
  ------------------
 1679|      0|            goto error;
 1680|      0|        }
 1681|      0|        goto end;
 1682|      0|    }
 1683|       |
 1684|  8.64k|    if (strcmp(request, "shell") == 0) {
  ------------------
  |  Branch (1684:9): [True: 0, False: 8.64k]
  ------------------
 1685|      0|        msg->channel_request.type = SSH_CHANNEL_REQUEST_SHELL;
 1686|      0|        goto end;
 1687|      0|    }
 1688|       |
 1689|  8.64k|    if (strcmp(request, "exec") == 0) {
  ------------------
  |  Branch (1689:9): [True: 8.64k, False: 0]
  ------------------
 1690|  8.64k|        rc = ssh_buffer_unpack(packet, "s", &msg->channel_request.command);
  ------------------
  |  |   60|  8.64k|    _ssh_buffer_unpack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |  451|  8.64k|        (__VA_NARG_(__VA_ARGS__, __RSEQ_N()))
  |  |  |  |  ------------------
  |  |  |  |  |  |  453|  8.64k|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  448|  8.64k|#define VA_APPLY_VARIADIC_MACRO(macro, tuple) macro tuple
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  453|  8.64k|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  461|  8.64k|        _61,_62,_63,N,...) N
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                   _ssh_buffer_unpack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |   28|  8.64k|#define SSH_BUFFER_PACK_END ((uint32_t) 0x4f65feb3)
  |  |  ------------------
  ------------------
 1691|  8.64k|        msg->channel_request.type = SSH_CHANNEL_REQUEST_EXEC;
 1692|  8.64k|        if (rc != SSH_OK) {
  ------------------
  |  |  316|  8.64k|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (1692:13): [True: 0, False: 8.64k]
  ------------------
 1693|      0|            goto error;
 1694|      0|        }
 1695|  8.64k|        goto end;
 1696|  8.64k|    }
 1697|       |
 1698|      0|    if (strcmp(request, "env") == 0) {
  ------------------
  |  Branch (1698:9): [True: 0, False: 0]
  ------------------
 1699|      0|        rc = ssh_buffer_unpack(packet,
  ------------------
  |  |   60|      0|    _ssh_buffer_unpack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |  451|      0|        (__VA_NARG_(__VA_ARGS__, __RSEQ_N()))
  |  |  |  |  ------------------
  |  |  |  |  |  |  453|      0|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  448|      0|#define VA_APPLY_VARIADIC_MACRO(macro, tuple) macro tuple
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  453|      0|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  461|      0|        _61,_62,_63,N,...) N
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                   _ssh_buffer_unpack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |   28|      0|#define SSH_BUFFER_PACK_END ((uint32_t) 0x4f65feb3)
  |  |  ------------------
  ------------------
 1700|      0|                               "ss",
 1701|      0|                               &msg->channel_request.var_name,
 1702|      0|                               &msg->channel_request.var_value);
 1703|      0|        msg->channel_request.type = SSH_CHANNEL_REQUEST_ENV;
 1704|      0|        if (rc != SSH_OK) {
  ------------------
  |  |  316|      0|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (1704:13): [True: 0, False: 0]
  ------------------
 1705|      0|            goto error;
 1706|      0|        }
 1707|      0|        goto end;
 1708|      0|    }
 1709|       |
 1710|      0|    if (strcmp(request, "x11-req") == 0) {
  ------------------
  |  Branch (1710:9): [True: 0, False: 0]
  ------------------
 1711|      0|        rc = ssh_buffer_unpack(packet,
  ------------------
  |  |   60|      0|    _ssh_buffer_unpack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |  451|      0|        (__VA_NARG_(__VA_ARGS__, __RSEQ_N()))
  |  |  |  |  ------------------
  |  |  |  |  |  |  453|      0|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  448|      0|#define VA_APPLY_VARIADIC_MACRO(macro, tuple) macro tuple
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  453|      0|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  461|      0|        _61,_62,_63,N,...) N
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                   _ssh_buffer_unpack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |   28|      0|#define SSH_BUFFER_PACK_END ((uint32_t) 0x4f65feb3)
  |  |  ------------------
  ------------------
 1712|      0|                               "bssd",
 1713|      0|                               &msg->channel_request.x11_single_connection,
 1714|      0|                               &msg->channel_request.x11_auth_protocol,
 1715|      0|                               &msg->channel_request.x11_auth_cookie,
 1716|      0|                               &msg->channel_request.x11_screen_number);
 1717|       |
 1718|      0|        msg->channel_request.type = SSH_CHANNEL_REQUEST_X11;
 1719|      0|        if (rc != SSH_OK) {
  ------------------
  |  |  316|      0|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (1719:13): [True: 0, False: 0]
  ------------------
 1720|      0|            goto error;
 1721|      0|        }
 1722|       |
 1723|      0|        goto end;
 1724|      0|    }
 1725|       |
 1726|      0|    msg->channel_request.type = SSH_CHANNEL_REQUEST_UNKNOWN;
 1727|  8.64k|end:
 1728|  8.64k|    ssh_message_queue(session, msg);
 1729|       |
 1730|  8.64k|    return SSH_OK;
  ------------------
  |  |  316|  8.64k|#define SSH_OK 0     /* No error */
  ------------------
 1731|      0|error:
 1732|      0|    SSH_MESSAGE_FREE(msg);
  ------------------
  |  |  697|      0|    do { if ((x) != NULL) { ssh_message_free(x); (x) = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (697:14): [True: 0, False: 0]
  |  |  |  Branch (697:72): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1733|       |
 1734|      0|    return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 1735|      0|}
ssh_message_channel_request_reply_success:
 1746|  8.64k|{
 1747|  8.64k|    uint32_t channel;
 1748|  8.64k|    int rc;
 1749|       |
 1750|  8.64k|    if (msg == NULL) {
  ------------------
  |  Branch (1750:9): [True: 0, False: 8.64k]
  ------------------
 1751|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 1752|      0|    }
 1753|       |
 1754|  8.64k|    if (msg->channel_request.want_reply) {
  ------------------
  |  Branch (1754:9): [True: 8.64k, False: 0]
  ------------------
 1755|  8.64k|        channel = msg->channel_request.channel->remote_channel;
 1756|       |
 1757|  8.64k|        SSH_LOG(SSH_LOG_PACKET,
  ------------------
  |  |  281|  8.64k|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 1758|  8.64k|                "Sending a channel_request success to channel %" PRIu32,
 1759|  8.64k|                channel);
 1760|       |
 1761|  8.64k|        rc = ssh_buffer_pack(msg->session->out_buffer,
  ------------------
  |  |   50|  8.64k|    _ssh_buffer_pack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |  451|  8.64k|        (__VA_NARG_(__VA_ARGS__, __RSEQ_N()))
  |  |  |  |  ------------------
  |  |  |  |  |  |  453|  8.64k|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  448|  8.64k|#define VA_APPLY_VARIADIC_MACRO(macro, tuple) macro tuple
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  453|  8.64k|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  461|  8.64k|        _61,_62,_63,N,...) N
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                   _ssh_buffer_pack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |   28|  8.64k|#define SSH_BUFFER_PACK_END ((uint32_t) 0x4f65feb3)
  |  |  ------------------
  ------------------
 1762|  8.64k|                             "bd",
 1763|  8.64k|                             SSH2_MSG_CHANNEL_SUCCESS,
 1764|  8.64k|                             channel);
 1765|  8.64k|        if (rc != SSH_OK) {
  ------------------
  |  |  316|  8.64k|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (1765:13): [True: 0, False: 8.64k]
  ------------------
 1766|      0|            ssh_set_error_oom(msg->session);
  ------------------
  |  |  318|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
 1767|      0|            return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 1768|      0|        }
 1769|       |
 1770|  8.64k|        return ssh_packet_send(msg->session);
 1771|  8.64k|    }
 1772|       |
 1773|      0|    SSH_LOG(SSH_LOG_PACKET,
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 1774|      0|            "The client doesn't want to know the request succeeded");
 1775|       |
 1776|      0|    return SSH_OK;
  ------------------
  |  |  316|      0|#define SSH_OK 0     /* No error */
  ------------------
 1777|  8.64k|}
messages.c:ssh_message_new:
   67|  34.5k|{
   68|  34.5k|    ssh_message msg = calloc(1, sizeof(struct ssh_message_struct));
   69|  34.5k|    if (msg == NULL) {
  ------------------
  |  Branch (69:9): [True: 0, False: 34.5k]
  ------------------
   70|      0|        return NULL;
   71|      0|    }
   72|  34.5k|    msg->session = session;
   73|       |
   74|       |    /* Set states explicitly */
   75|  34.5k|    msg->auth_request.signature_state = SSH_PUBLICKEY_STATE_NONE;
   76|       |
   77|  34.5k|    return msg;
   78|  34.5k|}
messages.c:ssh_message_queue:
  498|  34.5k|{
  499|  34.5k|#ifdef WITH_SERVER
  500|  34.5k|    int ret;
  501|  34.5k|#endif
  502|       |
  503|  34.5k|    if (message == NULL) {
  ------------------
  |  Branch (503:9): [True: 0, False: 34.5k]
  ------------------
  504|      0|        return;
  505|      0|    }
  506|       |
  507|  34.5k|#ifdef WITH_SERVER
  508|       |    /* probably not the best place to execute server callbacks, but still better
  509|       |     * than nothing.
  510|       |     */
  511|  34.5k|    ret = ssh_execute_server_callbacks(session, message);
  512|  34.5k|    if (ret == SSH_OK) {
  ------------------
  |  |  316|  34.5k|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (512:9): [True: 25.9k, False: 8.64k]
  ------------------
  513|  25.9k|        SSH_MESSAGE_FREE(message);
  ------------------
  |  |  697|  25.9k|    do { if ((x) != NULL) { ssh_message_free(x); (x) = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (697:14): [True: 25.9k, False: 0]
  |  |  |  Branch (697:72): [Folded, False: 25.9k]
  |  |  ------------------
  ------------------
  514|  25.9k|        return;
  515|  25.9k|    }
  516|  8.64k|#endif /* WITH_SERVER */
  517|       |
  518|  8.64k|    if (session->ssh_message_callback != NULL) {
  ------------------
  |  Branch (518:9): [True: 0, False: 8.64k]
  ------------------
  519|       |        /* This will transfer the message, do not free. */
  520|      0|        ssh_execute_message_callback(session, message);
  521|      0|        return;
  522|      0|    }
  523|       |
  524|  8.64k|    if (session->server_callbacks != NULL) {
  ------------------
  |  Branch (524:9): [True: 8.64k, False: 0]
  ------------------
  525|       |        /* if we have server callbacks, but nothing was executed, it means we are
  526|       |         * in non-synchronous mode, and we just don't care about the message we
  527|       |         * received. Just send a default response. Do not queue it.
  528|       |         */
  529|  8.64k|        ssh_message_reply_default(message);
  530|  8.64k|        SSH_MESSAGE_FREE(message);
  ------------------
  |  |  697|  8.64k|    do { if ((x) != NULL) { ssh_message_free(x); (x) = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (697:14): [True: 8.64k, False: 0]
  |  |  |  Branch (697:72): [Folded, False: 8.64k]
  |  |  ------------------
  ------------------
  531|  8.64k|        return;
  532|  8.64k|    }
  533|       |
  534|      0|    if (session->ssh_message_list == NULL) {
  ------------------
  |  Branch (534:9): [True: 0, False: 0]
  ------------------
  535|      0|        session->ssh_message_list = ssh_list_new();
  536|      0|        if (session->ssh_message_list == NULL) {
  ------------------
  |  Branch (536:13): [True: 0, False: 0]
  ------------------
  537|       |            /*
  538|       |             * If the message list couldn't be allocated, the message can't be
  539|       |             * enqueued
  540|       |             */
  541|      0|            ssh_message_reply_default(message);
  542|      0|            ssh_set_error_oom(session);
  ------------------
  |  |  318|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
  543|      0|            SSH_MESSAGE_FREE(message);
  ------------------
  |  |  697|      0|    do { if ((x) != NULL) { ssh_message_free(x); (x) = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (697:14): [True: 0, False: 0]
  |  |  |  Branch (697:72): [Folded, False: 0]
  |  |  ------------------
  ------------------
  544|      0|            return;
  545|      0|        }
  546|      0|    }
  547|       |
  548|       |    /* This will transfer the message, do not free. */
  549|      0|    ssh_list_append(session->ssh_message_list, message);
  550|      0|    return;
  551|      0|}
messages.c:ssh_execute_server_callbacks:
  448|  34.5k|static int ssh_execute_server_callbacks(ssh_session session, ssh_message msg){
  449|  34.5k|    int rc = SSH_AGAIN;
  ------------------
  |  |  318|  34.5k|#define SSH_AGAIN -2 /* The nonblocking call must be repeated */
  ------------------
  450|       |
  451|  34.5k|    if (session->server_callbacks != NULL){
  ------------------
  |  Branch (451:9): [True: 34.5k, False: 0]
  ------------------
  452|  34.5k|        rc = ssh_execute_server_request(session, msg);
  453|  34.5k|    } else if (session->common.callbacks != NULL) {
  ------------------
  |  Branch (453:16): [True: 0, False: 0]
  ------------------
  454|       |        /* This one is in fact a client callback... */
  455|      0|        rc = ssh_execute_client_request(session, msg);
  456|      0|    }
  457|       |
  458|  34.5k|    return rc;
  459|  34.5k|}
messages.c:ssh_execute_server_request:
  138|  34.5k|{
  139|  34.5k|    ssh_channel channel = NULL;
  140|  34.5k|    int rc;
  141|       |
  142|  34.5k|    switch(msg->type) {
  ------------------
  |  Branch (142:12): [True: 34.5k, False: 0]
  ------------------
  143|  8.64k|        case SSH_REQUEST_AUTH:
  ------------------
  |  Branch (143:9): [True: 8.64k, False: 25.9k]
  ------------------
  144|  8.64k|            if (msg->auth_request.method == SSH_AUTH_METHOD_PASSWORD &&
  ------------------
  |  |  157|  17.2k|#define SSH_AUTH_METHOD_PASSWORD     0x0002u
  ------------------
  |  Branch (144:17): [True: 0, False: 8.64k]
  ------------------
  145|      0|                ssh_callbacks_exists(session->server_callbacks, auth_password_function)) {
  ------------------
  |  |  547|      0|#define ssh_callbacks_exists(p,c) (\
  |  |  548|      0|  (p != NULL) && ( (char *)&((p)-> c) < (char *)(p) + (p)->size ) && \
  |  |  ------------------
  |  |  |  Branch (548:3): [True: 0, False: 0]
  |  |  |  Branch (548:18): [True: 0, False: 0]
  |  |  ------------------
  |  |  549|      0|  ((p)-> c != NULL) \
  |  |  ------------------
  |  |  |  Branch (549:3): [True: 0, False: 0]
  |  |  ------------------
  |  |  550|      0|  )
  ------------------
  146|      0|                rc = session->server_callbacks->auth_password_function(session,
  147|      0|                        msg->auth_request.username, msg->auth_request.password,
  148|      0|                        session->server_callbacks->userdata);
  149|      0|                if (rc == SSH_AUTH_SUCCESS || rc == SSH_AUTH_PARTIAL) {
  ------------------
  |  Branch (149:21): [True: 0, False: 0]
  |  Branch (149:47): [True: 0, False: 0]
  ------------------
  150|      0|                    ssh_message_auth_reply_success(msg, rc == SSH_AUTH_PARTIAL);
  151|      0|                } else {
  152|      0|                    ssh_message_reply_default(msg);
  153|      0|                }
  154|       |
  155|      0|                return SSH_OK;
  ------------------
  |  |  316|      0|#define SSH_OK 0     /* No error */
  ------------------
  156|  8.64k|            } else if(msg->auth_request.method == SSH_AUTH_METHOD_PUBLICKEY &&
  ------------------
  |  |  158|  17.2k|#define SSH_AUTH_METHOD_PUBLICKEY    0x0004u
  ------------------
  |  Branch (156:23): [True: 0, False: 8.64k]
  ------------------
  157|      0|                      ssh_callbacks_exists(session->server_callbacks, auth_pubkey_function)) {
  ------------------
  |  |  547|      0|#define ssh_callbacks_exists(p,c) (\
  |  |  548|      0|  (p != NULL) && ( (char *)&((p)-> c) < (char *)(p) + (p)->size ) && \
  |  |  ------------------
  |  |  |  Branch (548:3): [True: 0, False: 0]
  |  |  |  Branch (548:18): [True: 0, False: 0]
  |  |  ------------------
  |  |  549|      0|  ((p)-> c != NULL) \
  |  |  ------------------
  |  |  |  Branch (549:3): [True: 0, False: 0]
  |  |  ------------------
  |  |  550|      0|  )
  ------------------
  158|      0|               rc = session->server_callbacks->auth_pubkey_function(session,
  159|      0|                       msg->auth_request.username, msg->auth_request.pubkey,
  160|      0|                       msg->auth_request.signature_state,
  161|      0|                       session->server_callbacks->userdata);
  162|      0|               if (msg->auth_request.signature_state != SSH_PUBLICKEY_STATE_NONE) {
  ------------------
  |  Branch (162:20): [True: 0, False: 0]
  ------------------
  163|      0|                 if (rc == SSH_AUTH_SUCCESS || rc == SSH_AUTH_PARTIAL) {
  ------------------
  |  Branch (163:22): [True: 0, False: 0]
  |  Branch (163:48): [True: 0, False: 0]
  ------------------
  164|      0|                   ssh_message_auth_reply_success(msg, rc == SSH_AUTH_PARTIAL);
  165|      0|                 } else {
  166|      0|                   ssh_message_reply_default(msg);
  167|      0|                 }
  168|      0|               } else {
  169|      0|                 if (rc == SSH_AUTH_SUCCESS) {
  ------------------
  |  Branch (169:22): [True: 0, False: 0]
  ------------------
  170|      0|                   ssh_message_auth_reply_pk_ok_simple(msg);
  171|      0|                 } else {
  172|      0|                   ssh_message_reply_default(msg);
  173|      0|                 }
  174|      0|               }
  175|       |
  176|      0|               return SSH_OK;
  ------------------
  |  |  316|      0|#define SSH_OK 0     /* No error */
  ------------------
  177|  8.64k|            } else if (msg->auth_request.method == SSH_AUTH_METHOD_NONE &&
  ------------------
  |  |  156|  17.2k|#define SSH_AUTH_METHOD_NONE         0x0001u
  ------------------
  |  Branch (177:24): [True: 8.64k, False: 0]
  ------------------
  178|  8.64k|                       ssh_callbacks_exists(session->server_callbacks, auth_none_function)) {
  ------------------
  |  |  547|  8.64k|#define ssh_callbacks_exists(p,c) (\
  |  |  548|  8.64k|  (p != NULL) && ( (char *)&((p)-> c) < (char *)(p) + (p)->size ) && \
  |  |  ------------------
  |  |  |  Branch (548:3): [True: 8.64k, False: 0]
  |  |  |  Branch (548:18): [True: 8.64k, False: 0]
  |  |  ------------------
  |  |  549|  8.64k|  ((p)-> c != NULL) \
  |  |  ------------------
  |  |  |  Branch (549:3): [True: 8.64k, False: 0]
  |  |  ------------------
  |  |  550|  8.64k|  )
  ------------------
  179|  8.64k|                rc = session->server_callbacks->auth_none_function(session,
  180|  8.64k|                    msg->auth_request.username, session->server_callbacks->userdata);
  181|  8.64k|                if (rc == SSH_AUTH_SUCCESS || rc == SSH_AUTH_PARTIAL){
  ------------------
  |  Branch (181:21): [True: 8.64k, False: 0]
  |  Branch (181:47): [True: 0, False: 0]
  ------------------
  182|  8.64k|                    ssh_message_auth_reply_success(msg, rc == SSH_AUTH_PARTIAL);
  183|  8.64k|                } else {
  184|      0|                    ssh_message_reply_default(msg);
  185|      0|                }
  186|       |
  187|  8.64k|                return SSH_OK;
  ------------------
  |  |  316|  8.64k|#define SSH_OK 0     /* No error */
  ------------------
  188|  8.64k|            } else if (msg->auth_request.method == SSH_AUTH_METHOD_INTERACTIVE &&
  ------------------
  |  |  160|      0|#define SSH_AUTH_METHOD_INTERACTIVE  0x0010u
  ------------------
  |  Branch (188:24): [True: 0, False: 0]
  ------------------
  189|      0|                       ssh_callbacks_exists(session->server_callbacks, auth_kbdint_function)) {
  ------------------
  |  |  547|      0|#define ssh_callbacks_exists(p,c) (\
  |  |  548|      0|  (p != NULL) && ( (char *)&((p)-> c) < (char *)(p) + (p)->size ) && \
  |  |  ------------------
  |  |  |  Branch (548:3): [True: 0, False: 0]
  |  |  |  Branch (548:18): [True: 0, False: 0]
  |  |  ------------------
  |  |  549|      0|  ((p)-> c != NULL) \
  |  |  ------------------
  |  |  |  Branch (549:3): [True: 0, False: 0]
  |  |  ------------------
  |  |  550|      0|  )
  ------------------
  190|      0|                rc = session->server_callbacks->auth_kbdint_function(msg,
  191|      0|                                                                     session,
  192|      0|                                                                     session->server_callbacks->userdata);
  193|      0|                if (rc == SSH_AUTH_SUCCESS || rc == SSH_AUTH_PARTIAL) {
  ------------------
  |  Branch (193:21): [True: 0, False: 0]
  |  Branch (193:47): [True: 0, False: 0]
  ------------------
  194|      0|                    ssh_message_auth_reply_success(msg, rc == SSH_AUTH_PARTIAL);
  195|      0|                } else if (rc == SSH_AUTH_INFO) {
  ------------------
  |  Branch (195:28): [True: 0, False: 0]
  ------------------
  196|      0|                    return SSH_OK;
  ------------------
  |  |  316|      0|#define SSH_OK 0     /* No error */
  ------------------
  197|      0|                } else {
  198|      0|                    ssh_message_reply_default(msg);
  199|      0|                }
  200|      0|                return SSH_OK;
  ------------------
  |  |  316|      0|#define SSH_OK 0     /* No error */
  ------------------
  201|      0|            }
  202|      0|            break;
  203|  8.64k|        case SSH_REQUEST_CHANNEL_OPEN:
  ------------------
  |  Branch (203:9): [True: 8.64k, False: 25.9k]
  ------------------
  204|  8.64k|            if (msg->channel_request_open.type == SSH_CHANNEL_SESSION &&
  ------------------
  |  Branch (204:17): [True: 8.64k, False: 0]
  ------------------
  205|  8.64k|                ssh_callbacks_exists(session->server_callbacks, channel_open_request_session_function)) {
  ------------------
  |  |  547|  8.64k|#define ssh_callbacks_exists(p,c) (\
  |  |  548|  8.64k|  (p != NULL) && ( (char *)&((p)-> c) < (char *)(p) + (p)->size ) && \
  |  |  ------------------
  |  |  |  Branch (548:3): [True: 8.64k, False: 0]
  |  |  |  Branch (548:18): [True: 8.64k, False: 0]
  |  |  ------------------
  |  |  549|  8.64k|  ((p)-> c != NULL) \
  |  |  ------------------
  |  |  |  Branch (549:3): [True: 8.64k, False: 0]
  |  |  ------------------
  |  |  550|  8.64k|  )
  ------------------
  206|  8.64k|                channel = session->server_callbacks->channel_open_request_session_function(session,
  207|  8.64k|                        session->server_callbacks->userdata);
  208|  8.64k|                if (channel != NULL) {
  ------------------
  |  Branch (208:21): [True: 8.64k, False: 0]
  ------------------
  209|  8.64k|                    rc = ssh_message_channel_request_open_reply_accept_channel(msg, channel);
  210|  8.64k|                    if (rc != SSH_OK) {
  ------------------
  |  |  316|  8.64k|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (210:25): [True: 0, False: 8.64k]
  ------------------
  211|      0|                        SSH_LOG(SSH_LOG_TRACE,
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  212|      0|                                "Failed to send reply for accepting a channel "
  213|      0|                                "open");
  214|      0|                    }
  215|  8.64k|                    return SSH_OK;
  ------------------
  |  |  316|  8.64k|#define SSH_OK 0     /* No error */
  ------------------
  216|  8.64k|                } else {
  217|      0|                    ssh_message_reply_default(msg);
  218|      0|                }
  219|       |
  220|      0|                return SSH_OK;
  ------------------
  |  |  316|      0|#define SSH_OK 0     /* No error */
  ------------------
  221|  8.64k|#define CB channel_open_request_direct_tcpip_function
  222|  8.64k|            } else if (msg->channel_request_open.type == SSH_CHANNEL_DIRECT_TCPIP &&
  ------------------
  |  Branch (222:24): [True: 0, False: 0]
  ------------------
  223|      0|                       ssh_callbacks_exists(session->server_callbacks, CB)) {
  ------------------
  |  |  547|      0|#define ssh_callbacks_exists(p,c) (\
  |  |  548|      0|  (p != NULL) && ( (char *)&((p)-> c) < (char *)(p) + (p)->size ) && \
  |  |  ------------------
  |  |  |  Branch (548:3): [True: 0, False: 0]
  |  |  |  Branch (548:18): [True: 0, False: 0]
  |  |  ------------------
  |  |  549|      0|  ((p)-> c != NULL) \
  |  |  ------------------
  |  |  |  Branch (549:3): [True: 0, False: 0]
  |  |  ------------------
  |  |  550|      0|  )
  ------------------
  224|      0|                struct ssh_channel_request_open *rq = &msg->channel_request_open;
  225|      0|                channel = session->server_callbacks->CB(session,
  ------------------
  |  |  221|      0|#define CB channel_open_request_direct_tcpip_function
  ------------------
  226|      0|                                                        rq->destination,
  227|      0|                                                        rq->destination_port,
  228|      0|                                                        rq->originator,
  229|      0|                                                        rq->originator_port,
  230|      0|                                                        session->server_callbacks->userdata);
  231|      0|#undef CB
  232|      0|                if (channel != NULL) {
  ------------------
  |  Branch (232:21): [True: 0, False: 0]
  ------------------
  233|      0|                    rc = ssh_message_channel_request_open_reply_accept_channel(
  234|      0|                        msg,
  235|      0|                        channel);
  236|      0|                    if (rc != SSH_OK) {
  ------------------
  |  |  316|      0|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (236:25): [True: 0, False: 0]
  ------------------
  237|      0|                        SSH_LOG(SSH_LOG_TRACE,
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  238|      0|                                "Failed to send reply for accepting a channel "
  239|      0|                                "open");
  240|      0|                    }
  241|      0|                    return SSH_OK;
  ------------------
  |  |  316|      0|#define SSH_OK 0     /* No error */
  ------------------
  242|      0|                } else {
  243|      0|                    ssh_message_reply_default(msg);
  244|      0|                }
  245|       |
  246|      0|                return SSH_OK;
  ------------------
  |  |  316|      0|#define SSH_OK 0     /* No error */
  ------------------
  247|      0|            }
  248|       |
  249|      0|            break;
  250|  8.64k|        case SSH_REQUEST_CHANNEL:
  ------------------
  |  Branch (250:9): [True: 8.64k, False: 25.9k]
  ------------------
  251|  8.64k|            channel = msg->channel_request.channel;
  252|       |
  253|  8.64k|            if (msg->channel_request.type == SSH_CHANNEL_REQUEST_PTY){
  ------------------
  |  Branch (253:17): [True: 0, False: 8.64k]
  ------------------
  254|      0|                ssh_callbacks_iterate(channel->callbacks,
  ------------------
  |  |  598|      0|    do {                                                              \
  |  |  599|      0|        struct ssh_iterator *_cb_i = ssh_list_get_iterator(_cb_list); \
  |  |  600|      0|        _cb_type _cb;                                                 \
  |  |  601|      0|        for (; _cb_i != NULL; _cb_i = _cb_i->next) {                  \
  |  |  ------------------
  |  |  |  Branch (601:16): [True: 0, False: 0]
  |  |  ------------------
  |  |  602|      0|            _cb = ssh_iterator_value(_cb_type, _cb_i);                \
  |  |  ------------------
  |  |  |  |  114|      0|  ((type)((iterator)->data))
  |  |  ------------------
  |  |  603|      0|            if (ssh_callbacks_exists(_cb, _cb_name))
  |  |  ------------------
  |  |  |  |  547|      0|#define ssh_callbacks_exists(p,c) (\
  |  |  |  |  548|      0|  (p != NULL) && ( (char *)&((p)-> c) < (char *)(p) + (p)->size ) && \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (548:3): [True: 0, False: 0]
  |  |  |  |  |  Branch (548:18): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  549|      0|  ((p)-> c != NULL) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (549:3): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  550|      0|  )
  |  |  ------------------
  ------------------
  255|      0|                                      ssh_channel_callbacks,
  256|      0|                                      channel_pty_request_function) {
  257|      0|                    rc = ssh_callbacks_iterate_exec(channel_pty_request_function,
  ------------------
  |  |  612|      0|                _cb->_cb_name(__VA_ARGS__, _cb->userdata)
  ------------------
  258|      0|                                                    session,
  259|      0|                                                    channel,
  260|      0|                                                    msg->channel_request.TERM,
  261|      0|                                                    msg->channel_request.width,
  262|      0|                                                    msg->channel_request.height,
  263|      0|                                                    msg->channel_request.pxwidth,
  264|      0|                                                    msg->channel_request.pxheight);
  265|      0|                    if (rc == 0) {
  ------------------
  |  Branch (265:25): [True: 0, False: 0]
  ------------------
  266|      0|                        ssh_message_channel_request_reply_success(msg);
  267|      0|                    } else {
  268|      0|                        ssh_message_reply_default(msg);
  269|      0|                    }
  270|      0|                    return SSH_OK;
  ------------------
  |  |  316|      0|#define SSH_OK 0     /* No error */
  ------------------
  271|      0|                }
  272|      0|                ssh_callbacks_iterate_end();
  ------------------
  |  |  618|      0|        }                           \
  |  |  619|      0|    } while(0)
  |  |  ------------------
  |  |  |  Branch (619:13): [Folded, False: 0]
  |  |  ------------------
  ------------------
  273|  8.64k|            } else if (msg->channel_request.type == SSH_CHANNEL_REQUEST_SHELL){
  ------------------
  |  Branch (273:24): [True: 0, False: 8.64k]
  ------------------
  274|      0|                ssh_callbacks_iterate(channel->callbacks,
  ------------------
  |  |  598|      0|    do {                                                              \
  |  |  599|      0|        struct ssh_iterator *_cb_i = ssh_list_get_iterator(_cb_list); \
  |  |  600|      0|        _cb_type _cb;                                                 \
  |  |  601|      0|        for (; _cb_i != NULL; _cb_i = _cb_i->next) {                  \
  |  |  ------------------
  |  |  |  Branch (601:16): [True: 0, False: 0]
  |  |  ------------------
  |  |  602|      0|            _cb = ssh_iterator_value(_cb_type, _cb_i);                \
  |  |  ------------------
  |  |  |  |  114|      0|  ((type)((iterator)->data))
  |  |  ------------------
  |  |  603|      0|            if (ssh_callbacks_exists(_cb, _cb_name))
  |  |  ------------------
  |  |  |  |  547|      0|#define ssh_callbacks_exists(p,c) (\
  |  |  |  |  548|      0|  (p != NULL) && ( (char *)&((p)-> c) < (char *)(p) + (p)->size ) && \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (548:3): [True: 0, False: 0]
  |  |  |  |  |  Branch (548:18): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  549|      0|  ((p)-> c != NULL) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (549:3): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  550|      0|  )
  |  |  ------------------
  ------------------
  275|      0|                                      ssh_channel_callbacks,
  276|      0|                                      channel_shell_request_function) {
  277|      0|                    rc = ssh_callbacks_iterate_exec(channel_shell_request_function,
  ------------------
  |  |  612|      0|                _cb->_cb_name(__VA_ARGS__, _cb->userdata)
  ------------------
  278|      0|                                                    session,
  279|      0|                                                    channel);
  280|      0|                    if (rc == 0) {
  ------------------
  |  Branch (280:25): [True: 0, False: 0]
  ------------------
  281|      0|                        ssh_message_channel_request_reply_success(msg);
  282|      0|                    } else {
  283|      0|                        ssh_message_reply_default(msg);
  284|      0|                    }
  285|      0|                    return SSH_OK;
  ------------------
  |  |  316|      0|#define SSH_OK 0     /* No error */
  ------------------
  286|      0|                }
  287|      0|                ssh_callbacks_iterate_end();
  ------------------
  |  |  618|      0|        }                           \
  |  |  619|      0|    } while(0)
  |  |  ------------------
  |  |  |  Branch (619:13): [Folded, False: 0]
  |  |  ------------------
  ------------------
  288|  8.64k|            } else if (msg->channel_request.type == SSH_CHANNEL_REQUEST_X11){
  ------------------
  |  Branch (288:24): [True: 0, False: 8.64k]
  ------------------
  289|      0|                ssh_callbacks_iterate(channel->callbacks,
  ------------------
  |  |  598|      0|    do {                                                              \
  |  |  599|      0|        struct ssh_iterator *_cb_i = ssh_list_get_iterator(_cb_list); \
  |  |  600|      0|        _cb_type _cb;                                                 \
  |  |  601|      0|        for (; _cb_i != NULL; _cb_i = _cb_i->next) {                  \
  |  |  ------------------
  |  |  |  Branch (601:16): [True: 0, False: 0]
  |  |  ------------------
  |  |  602|      0|            _cb = ssh_iterator_value(_cb_type, _cb_i);                \
  |  |  ------------------
  |  |  |  |  114|      0|  ((type)((iterator)->data))
  |  |  ------------------
  |  |  603|      0|            if (ssh_callbacks_exists(_cb, _cb_name))
  |  |  ------------------
  |  |  |  |  547|      0|#define ssh_callbacks_exists(p,c) (\
  |  |  |  |  548|      0|  (p != NULL) && ( (char *)&((p)-> c) < (char *)(p) + (p)->size ) && \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (548:3): [True: 0, False: 0]
  |  |  |  |  |  Branch (548:18): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  549|      0|  ((p)-> c != NULL) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (549:3): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  550|      0|  )
  |  |  ------------------
  ------------------
  290|      0|                                      ssh_channel_callbacks,
  291|      0|                                      channel_x11_req_function) {
  292|      0|                    ssh_callbacks_iterate_exec(channel_x11_req_function,
  ------------------
  |  |  612|      0|                _cb->_cb_name(__VA_ARGS__, _cb->userdata)
  ------------------
  293|      0|                                               session,
  294|      0|                                               channel,
  295|      0|                                               msg->channel_request.x11_single_connection,
  296|      0|                                               msg->channel_request.x11_auth_protocol,
  297|      0|                                               msg->channel_request.x11_auth_cookie,
  298|      0|                                               msg->channel_request.x11_screen_number);
  299|      0|                    ssh_message_channel_request_reply_success(msg);
  300|      0|                    return SSH_OK;
  ------------------
  |  |  316|      0|#define SSH_OK 0     /* No error */
  ------------------
  301|      0|                }
  302|      0|                ssh_callbacks_iterate_end();
  ------------------
  |  |  618|      0|        }                           \
  |  |  619|      0|    } while(0)
  |  |  ------------------
  |  |  |  Branch (619:13): [Folded, False: 0]
  |  |  ------------------
  ------------------
  303|  8.64k|            } else if (msg->channel_request.type == SSH_CHANNEL_REQUEST_WINDOW_CHANGE){
  ------------------
  |  Branch (303:24): [True: 0, False: 8.64k]
  ------------------
  304|      0|                ssh_callbacks_iterate(channel->callbacks,
  ------------------
  |  |  598|      0|    do {                                                              \
  |  |  599|      0|        struct ssh_iterator *_cb_i = ssh_list_get_iterator(_cb_list); \
  |  |  600|      0|        _cb_type _cb;                                                 \
  |  |  601|      0|        for (; _cb_i != NULL; _cb_i = _cb_i->next) {                  \
  |  |  ------------------
  |  |  |  Branch (601:16): [True: 0, False: 0]
  |  |  ------------------
  |  |  602|      0|            _cb = ssh_iterator_value(_cb_type, _cb_i);                \
  |  |  ------------------
  |  |  |  |  114|      0|  ((type)((iterator)->data))
  |  |  ------------------
  |  |  603|      0|            if (ssh_callbacks_exists(_cb, _cb_name))
  |  |  ------------------
  |  |  |  |  547|      0|#define ssh_callbacks_exists(p,c) (\
  |  |  |  |  548|      0|  (p != NULL) && ( (char *)&((p)-> c) < (char *)(p) + (p)->size ) && \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (548:3): [True: 0, False: 0]
  |  |  |  |  |  Branch (548:18): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  549|      0|  ((p)-> c != NULL) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (549:3): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  550|      0|  )
  |  |  ------------------
  ------------------
  305|      0|                                      ssh_channel_callbacks,
  306|      0|                                      channel_pty_window_change_function) {
  307|      0|                    rc = ssh_callbacks_iterate_exec(channel_pty_window_change_function,
  ------------------
  |  |  612|      0|                _cb->_cb_name(__VA_ARGS__, _cb->userdata)
  ------------------
  308|      0|                                                    session,
  309|      0|                                                    channel,
  310|      0|                                                    msg->channel_request.width,
  311|      0|                                                    msg->channel_request.height,
  312|      0|                                                    msg->channel_request.pxwidth,
  313|      0|                                                    msg->channel_request.pxheight);
  314|      0|                    if (rc != SSH_OK) {
  ------------------
  |  |  316|      0|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (314:25): [True: 0, False: 0]
  ------------------
  315|      0|                        SSH_LOG(SSH_LOG_TRACE,
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  316|      0|                                "Failed to iterate callbacks for window change");
  317|      0|                    }
  318|      0|                    return SSH_OK;
  ------------------
  |  |  316|      0|#define SSH_OK 0     /* No error */
  ------------------
  319|      0|                }
  320|      0|                ssh_callbacks_iterate_end();
  ------------------
  |  |  618|      0|        }                           \
  |  |  619|      0|    } while(0)
  |  |  ------------------
  |  |  |  Branch (619:13): [Folded, False: 0]
  |  |  ------------------
  ------------------
  321|  8.64k|            } else if (msg->channel_request.type == SSH_CHANNEL_REQUEST_EXEC){
  ------------------
  |  Branch (321:24): [True: 8.64k, False: 0]
  ------------------
  322|  17.2k|                ssh_callbacks_iterate(channel->callbacks,
  ------------------
  |  |  598|  8.64k|    do {                                                              \
  |  |  599|  8.64k|        struct ssh_iterator *_cb_i = ssh_list_get_iterator(_cb_list); \
  |  |  600|  8.64k|        _cb_type _cb;                                                 \
  |  |  601|  8.64k|        for (; _cb_i != NULL; _cb_i = _cb_i->next) {                  \
  |  |  ------------------
  |  |  |  Branch (601:16): [True: 8.64k, False: 0]
  |  |  ------------------
  |  |  602|  8.64k|            _cb = ssh_iterator_value(_cb_type, _cb_i);                \
  |  |  ------------------
  |  |  |  |  114|  8.64k|  ((type)((iterator)->data))
  |  |  ------------------
  |  |  603|  8.64k|            if (ssh_callbacks_exists(_cb, _cb_name))
  |  |  ------------------
  |  |  |  |  547|  8.64k|#define ssh_callbacks_exists(p,c) (\
  |  |  |  |  548|  8.64k|  (p != NULL) && ( (char *)&((p)-> c) < (char *)(p) + (p)->size ) && \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (548:3): [True: 8.64k, False: 0]
  |  |  |  |  |  Branch (548:18): [True: 8.64k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  549|  8.64k|  ((p)-> c != NULL) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (549:3): [True: 8.64k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  550|  8.64k|  )
  |  |  ------------------
  ------------------
  323|  17.2k|                                      ssh_channel_callbacks,
  324|  17.2k|                                      channel_exec_request_function) {
  325|  8.64k|                    rc = ssh_callbacks_iterate_exec(channel_exec_request_function,
  ------------------
  |  |  612|  8.64k|                _cb->_cb_name(__VA_ARGS__, _cb->userdata)
  ------------------
  326|  8.64k|                                                    session,
  327|  8.64k|                                                    channel,
  328|  8.64k|                                                    msg->channel_request.command);
  329|  8.64k|                    if (rc == 0) {
  ------------------
  |  Branch (329:25): [True: 8.64k, False: 0]
  ------------------
  330|  8.64k|                        ssh_message_channel_request_reply_success(msg);
  331|  8.64k|                    } else {
  332|      0|                        ssh_message_reply_default(msg);
  333|      0|                    }
  334|       |
  335|  8.64k|                    return SSH_OK;
  ------------------
  |  |  316|  8.64k|#define SSH_OK 0     /* No error */
  ------------------
  336|  8.64k|                }
  337|  17.2k|                ssh_callbacks_iterate_end();
  ------------------
  |  |  618|  8.64k|        }                           \
  |  |  619|  8.64k|    } while(0)
  |  |  ------------------
  |  |  |  Branch (619:13): [Folded, False: 0]
  |  |  ------------------
  ------------------
  338|  8.64k|            } else if (msg->channel_request.type == SSH_CHANNEL_REQUEST_ENV){
  ------------------
  |  Branch (338:24): [True: 0, False: 0]
  ------------------
  339|      0|                ssh_callbacks_iterate(channel->callbacks,
  ------------------
  |  |  598|      0|    do {                                                              \
  |  |  599|      0|        struct ssh_iterator *_cb_i = ssh_list_get_iterator(_cb_list); \
  |  |  600|      0|        _cb_type _cb;                                                 \
  |  |  601|      0|        for (; _cb_i != NULL; _cb_i = _cb_i->next) {                  \
  |  |  ------------------
  |  |  |  Branch (601:16): [True: 0, False: 0]
  |  |  ------------------
  |  |  602|      0|            _cb = ssh_iterator_value(_cb_type, _cb_i);                \
  |  |  ------------------
  |  |  |  |  114|      0|  ((type)((iterator)->data))
  |  |  ------------------
  |  |  603|      0|            if (ssh_callbacks_exists(_cb, _cb_name))
  |  |  ------------------
  |  |  |  |  547|      0|#define ssh_callbacks_exists(p,c) (\
  |  |  |  |  548|      0|  (p != NULL) && ( (char *)&((p)-> c) < (char *)(p) + (p)->size ) && \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (548:3): [True: 0, False: 0]
  |  |  |  |  |  Branch (548:18): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  549|      0|  ((p)-> c != NULL) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (549:3): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  550|      0|  )
  |  |  ------------------
  ------------------
  340|      0|                                      ssh_channel_callbacks,
  341|      0|                                      channel_env_request_function) {
  342|      0|                    rc = ssh_callbacks_iterate_exec(channel_env_request_function,
  ------------------
  |  |  612|      0|                _cb->_cb_name(__VA_ARGS__, _cb->userdata)
  ------------------
  343|      0|                                                    session,
  344|      0|                                                    channel,
  345|      0|                                                    msg->channel_request.var_name,
  346|      0|                                                    msg->channel_request.var_value);
  347|      0|                    if (rc == 0) {
  ------------------
  |  Branch (347:25): [True: 0, False: 0]
  ------------------
  348|      0|                        ssh_message_channel_request_reply_success(msg);
  349|      0|                    } else {
  350|      0|                        ssh_message_reply_default(msg);
  351|      0|                    }
  352|      0|                    return SSH_OK;
  ------------------
  |  |  316|      0|#define SSH_OK 0     /* No error */
  ------------------
  353|      0|                }
  354|      0|                ssh_callbacks_iterate_end();
  ------------------
  |  |  618|      0|        }                           \
  |  |  619|      0|    } while(0)
  |  |  ------------------
  |  |  |  Branch (619:13): [Folded, False: 0]
  |  |  ------------------
  ------------------
  355|      0|            } else if (msg->channel_request.type == SSH_CHANNEL_REQUEST_SUBSYSTEM){
  ------------------
  |  Branch (355:24): [True: 0, False: 0]
  ------------------
  356|      0|                ssh_callbacks_iterate(channel->callbacks,
  ------------------
  |  |  598|      0|    do {                                                              \
  |  |  599|      0|        struct ssh_iterator *_cb_i = ssh_list_get_iterator(_cb_list); \
  |  |  600|      0|        _cb_type _cb;                                                 \
  |  |  601|      0|        for (; _cb_i != NULL; _cb_i = _cb_i->next) {                  \
  |  |  ------------------
  |  |  |  Branch (601:16): [True: 0, False: 0]
  |  |  ------------------
  |  |  602|      0|            _cb = ssh_iterator_value(_cb_type, _cb_i);                \
  |  |  ------------------
  |  |  |  |  114|      0|  ((type)((iterator)->data))
  |  |  ------------------
  |  |  603|      0|            if (ssh_callbacks_exists(_cb, _cb_name))
  |  |  ------------------
  |  |  |  |  547|      0|#define ssh_callbacks_exists(p,c) (\
  |  |  |  |  548|      0|  (p != NULL) && ( (char *)&((p)-> c) < (char *)(p) + (p)->size ) && \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (548:3): [True: 0, False: 0]
  |  |  |  |  |  Branch (548:18): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  549|      0|  ((p)-> c != NULL) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (549:3): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  550|      0|  )
  |  |  ------------------
  ------------------
  357|      0|                                      ssh_channel_callbacks,
  358|      0|                                      channel_subsystem_request_function) {
  359|      0|                    rc = ssh_callbacks_iterate_exec(channel_subsystem_request_function,
  ------------------
  |  |  612|      0|                _cb->_cb_name(__VA_ARGS__, _cb->userdata)
  ------------------
  360|      0|                                                    session,
  361|      0|                                                    channel,
  362|      0|                                                    msg->channel_request.subsystem);
  363|      0|                    if (rc == 0) {
  ------------------
  |  Branch (363:25): [True: 0, False: 0]
  ------------------
  364|      0|                        ssh_message_channel_request_reply_success(msg);
  365|      0|                    } else {
  366|      0|                        ssh_message_reply_default(msg);
  367|      0|                    }
  368|       |
  369|      0|                    return SSH_OK;
  ------------------
  |  |  316|      0|#define SSH_OK 0     /* No error */
  ------------------
  370|      0|                }
  371|      0|                ssh_callbacks_iterate_end();
  ------------------
  |  |  618|      0|        }                           \
  |  |  619|      0|    } while(0)
  |  |  ------------------
  |  |  |  Branch (619:13): [Folded, False: 0]
  |  |  ------------------
  ------------------
  372|      0|            }
  373|      0|            break;
  374|  8.64k|        case SSH_REQUEST_SERVICE:
  ------------------
  |  Branch (374:9): [True: 8.64k, False: 25.9k]
  ------------------
  375|  8.64k|            if (ssh_callbacks_exists(session->server_callbacks, service_request_function)) {
  ------------------
  |  |  547|  8.64k|#define ssh_callbacks_exists(p,c) (\
  |  |  548|  8.64k|  (p != NULL) && ( (char *)&((p)-> c) < (char *)(p) + (p)->size ) && \
  |  |  ------------------
  |  |  |  Branch (548:3): [True: 8.64k, False: 0]
  |  |  |  Branch (548:18): [True: 8.64k, False: 0]
  |  |  ------------------
  |  |  549|  8.64k|  ((p)-> c != NULL) \
  |  |  ------------------
  |  |  |  Branch (549:3): [True: 0, False: 8.64k]
  |  |  ------------------
  |  |  550|  8.64k|  )
  ------------------
  376|      0|                rc = session->server_callbacks->service_request_function(session,
  377|      0|                        msg->service_request.service, session->server_callbacks->userdata);
  378|      0|                if (rc == 0) {
  ------------------
  |  Branch (378:21): [True: 0, False: 0]
  ------------------
  379|      0|                    ssh_message_reply_default(msg);
  380|      0|                } else {
  381|      0|                    ssh_send_disconnect(session);
  382|      0|                }
  383|       |
  384|      0|                return SSH_OK;
  ------------------
  |  |  316|      0|#define SSH_OK 0     /* No error */
  ------------------
  385|      0|            }
  386|       |
  387|  8.64k|            return SSH_AGAIN;
  ------------------
  |  |  318|  8.64k|#define SSH_AGAIN -2 /* The nonblocking call must be repeated */
  ------------------
  388|      0|        case SSH_REQUEST_GLOBAL:
  ------------------
  |  Branch (388:9): [True: 0, False: 34.5k]
  ------------------
  389|      0|            break;
  390|  34.5k|    }
  391|       |
  392|      0|    return SSH_AGAIN;
  ------------------
  |  |  318|      0|#define SSH_AGAIN -2 /* The nonblocking call must be repeated */
  ------------------
  393|  34.5k|}

ssh_is_ipaddr_v4:
  430|  34.5k|{
  431|  34.5k|    int rc = -1;
  432|  34.5k|    struct in_addr dest;
  433|       |
  434|  34.5k|    rc = inet_pton(AF_INET, str, &dest);
  435|  34.5k|    if (rc > 0) {
  ------------------
  |  Branch (435:9): [True: 0, False: 34.5k]
  ------------------
  436|      0|        return 1;
  437|      0|    }
  438|       |
  439|  34.5k|    return 0;
  440|  34.5k|}
ssh_is_ipaddr:
  450|  34.5k|{
  451|  34.5k|    int rc = -1;
  452|  34.5k|    char *s = strdup(str);
  453|       |
  454|  34.5k|    if (s == NULL) {
  ------------------
  |  Branch (454:9): [True: 0, False: 34.5k]
  ------------------
  455|      0|        return -1;
  456|      0|    }
  457|  34.5k|    if (strchr(s, ':')) {
  ------------------
  |  Branch (457:9): [True: 0, False: 34.5k]
  ------------------
  458|      0|        struct in6_addr dest6;
  459|      0|        char *network_interface = strchr(s, '%');
  460|       |
  461|       |        /* link-local (IP:v6:addr%ifname). */
  462|      0|        if (network_interface != NULL) {
  ------------------
  |  Branch (462:13): [True: 0, False: 0]
  ------------------
  463|      0|            rc = if_nametoindex(network_interface + 1);
  464|      0|            if (rc == 0) {
  ------------------
  |  Branch (464:17): [True: 0, False: 0]
  ------------------
  465|      0|                free(s);
  466|      0|                return 0;
  467|      0|            }
  468|      0|            *network_interface = '\0';
  469|      0|        }
  470|      0|        rc = inet_pton(AF_INET6, s, &dest6);
  471|      0|        if (rc > 0) {
  ------------------
  |  Branch (471:13): [True: 0, False: 0]
  ------------------
  472|      0|            free(s);
  473|      0|            return 1;
  474|      0|        }
  475|      0|    }
  476|       |
  477|  34.5k|    free(s);
  478|  34.5k|    return ssh_is_ipaddr_v4(str);
  479|  34.5k|}
ssh_get_user_home_dir:
  495|  51.8k|{
  496|  51.8k|    char *szPath = NULL;
  497|       |
  498|       |    /* If used previously, reuse cached value */
  499|  51.8k|    if (session != NULL && session->opts.homedir != NULL) {
  ------------------
  |  Branch (499:9): [True: 43.2k, False: 8.64k]
  |  Branch (499:28): [True: 34.5k, False: 8.64k]
  ------------------
  500|  34.5k|        return strdup(session->opts.homedir);
  501|  34.5k|    }
  502|       |
  503|  17.2k|    szPath = ssh_get_user_home_dir_internal();
  504|  17.2k|    if (szPath == NULL) {
  ------------------
  |  Branch (504:9): [True: 0, False: 17.2k]
  ------------------
  505|      0|        return NULL;
  506|      0|    }
  507|       |
  508|  17.2k|    if (session != NULL) {
  ------------------
  |  Branch (508:9): [True: 8.64k, False: 8.64k]
  ------------------
  509|       |        /* cache it:
  510|       |         * failure is not fatal -- at worst we will just not cache it */
  511|  8.64k|        session->opts.homedir = strdup(szPath);
  512|  8.64k|    }
  513|       |
  514|  17.2k|    return szPath;
  515|  17.2k|}
ssh_lowercase:
  526|  17.2k|{
  527|  17.2k|    char *new = NULL, *p = NULL;
  528|       |
  529|  17.2k|    if (str == NULL) {
  ------------------
  |  Branch (529:9): [True: 0, False: 17.2k]
  ------------------
  530|      0|        return NULL;
  531|      0|    }
  532|       |
  533|  17.2k|    new = strdup(str);
  534|  17.2k|    if (new == NULL) {
  ------------------
  |  Branch (534:9): [True: 0, False: 17.2k]
  ------------------
  535|      0|        return NULL;
  536|      0|    }
  537|       |
  538|   172k|    for (p = new; *p; p++) {
  ------------------
  |  Branch (538:19): [True: 155k, False: 17.2k]
  ------------------
  539|   155k|        *p = tolower(*p);
  ------------------
  |  Branch (539:14): [True: 0, False: 0]
  |  Branch (539:14): [True: 0, False: 0]
  |  Branch (539:14): [Folded, False: 155k]
  ------------------
  540|   155k|    }
  541|       |
  542|  17.2k|    return new;
  543|  17.2k|}
ssh_list_new:
  865|   172k|{
  866|   172k|    struct ssh_list *ret = malloc(sizeof(struct ssh_list));
  867|   172k|    if (ret == NULL) {
  ------------------
  |  Branch (867:9): [True: 0, False: 172k]
  ------------------
  868|      0|        return NULL;
  869|      0|    }
  870|   172k|    ret->root = ret->end = NULL;
  871|   172k|    return ret;
  872|   172k|}
ssh_list_free:
  882|   172k|{
  883|   172k|    struct ssh_iterator *ptr = NULL, *next = NULL;
  884|   172k|    if (!list)
  ------------------
  |  Branch (884:9): [True: 0, False: 172k]
  ------------------
  885|      0|        return;
  886|   172k|    ptr = list->root;
  887|   207k|    while (ptr) {
  ------------------
  |  Branch (887:12): [True: 34.5k, False: 172k]
  ------------------
  888|  34.5k|        next = ptr->next;
  889|  34.5k|        SAFE_FREE(ptr);
  ------------------
  |  |  373|  34.5k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 34.5k, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 34.5k]
  |  |  ------------------
  ------------------
  890|  34.5k|        ptr = next;
  891|  34.5k|    }
  892|       |    SAFE_FREE(list);
  ------------------
  |  |  373|   172k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 172k, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 172k]
  |  |  ------------------
  ------------------
  893|   172k|}
ssh_list_get_iterator:
  903|   576k|{
  904|   576k|    if (!list)
  ------------------
  |  Branch (904:9): [True: 164k, False: 411k]
  ------------------
  905|   164k|        return NULL;
  906|   411k|    return list->root;
  907|   576k|}
ssh_list_find:
  918|  34.5k|{
  919|  34.5k|    struct ssh_iterator *it = NULL;
  920|       |
  921|  51.8k|    for (it = ssh_list_get_iterator(list); it != NULL ; it = it->next)
  ------------------
  |  Branch (921:44): [True: 51.8k, False: 0]
  ------------------
  922|  51.8k|        if (it->data == value)
  ------------------
  |  Branch (922:13): [True: 34.5k, False: 17.2k]
  ------------------
  923|  34.5k|            return it;
  924|      0|    return NULL;
  925|  34.5k|}
ssh_list_append:
  969|   120k|{
  970|   120k|  struct ssh_iterator *iterator = NULL;
  971|       |
  972|   120k|  if (list == NULL) {
  ------------------
  |  Branch (972:7): [True: 0, False: 120k]
  ------------------
  973|      0|      return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  974|      0|  }
  975|       |
  976|   120k|  iterator = ssh_iterator_new(data);
  977|   120k|  if (iterator == NULL) {
  ------------------
  |  Branch (977:7): [True: 0, False: 120k]
  ------------------
  978|      0|      return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  979|      0|  }
  980|       |
  981|   120k|  if(!list->end){
  ------------------
  |  Branch (981:6): [True: 51.8k, False: 69.1k]
  ------------------
  982|       |    /* list is empty */
  983|  51.8k|    list->root=list->end=iterator;
  984|  69.1k|  } else {
  985|       |    /* put it on end of list */
  986|  69.1k|    list->end->next=iterator;
  987|  69.1k|    list->end=iterator;
  988|  69.1k|  }
  989|   120k|  return SSH_OK;
  ------------------
  |  |  316|   120k|#define SSH_OK 0     /* No error */
  ------------------
  990|   120k|}
ssh_list_prepend:
 1001|  25.9k|{
 1002|  25.9k|  struct ssh_iterator *it = NULL;
 1003|       |
 1004|  25.9k|  if (list == NULL) {
  ------------------
  |  Branch (1004:7): [True: 0, False: 25.9k]
  ------------------
 1005|      0|      return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 1006|      0|  }
 1007|       |
 1008|  25.9k|  it = ssh_iterator_new(data);
 1009|  25.9k|  if (it == NULL) {
  ------------------
  |  Branch (1009:7): [True: 0, False: 25.9k]
  ------------------
 1010|      0|    return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 1011|      0|  }
 1012|       |
 1013|  25.9k|  if (list->end == NULL) {
  ------------------
  |  Branch (1013:7): [True: 25.9k, False: 2]
  ------------------
 1014|       |    /* list is empty */
 1015|  25.9k|    list->root = list->end = it;
 1016|  25.9k|  } else {
 1017|       |    /* set as new root */
 1018|      2|    it->next = list->root;
 1019|      2|    list->root = it;
 1020|      2|  }
 1021|       |
 1022|  25.9k|  return SSH_OK;
  ------------------
  |  |  316|  25.9k|#define SSH_OK 0     /* No error */
  ------------------
 1023|  25.9k|}
ssh_list_remove:
 1032|  43.2k|{
 1033|  43.2k|    struct ssh_iterator *ptr = NULL, *prev = NULL;
 1034|       |
 1035|  43.2k|    if (list == NULL) {
  ------------------
  |  Branch (1035:9): [True: 0, False: 43.2k]
  ------------------
 1036|      0|        return;
 1037|      0|    }
 1038|       |
 1039|  43.2k|    prev = NULL;
 1040|  43.2k|    ptr = list->root;
 1041|  60.4k|    while (ptr && ptr != iterator) {
  ------------------
  |  Branch (1041:12): [True: 51.8k, False: 8.64k]
  |  Branch (1041:19): [True: 17.2k, False: 34.5k]
  ------------------
 1042|  17.2k|        prev = ptr;
 1043|  17.2k|        ptr = ptr->next;
 1044|  17.2k|    }
 1045|  43.2k|    if (!ptr) {
  ------------------
  |  Branch (1045:9): [True: 8.64k, False: 34.5k]
  ------------------
 1046|       |        /* we did not find the element */
 1047|  8.64k|        return;
 1048|  8.64k|    }
 1049|       |    /* unlink it */
 1050|  34.5k|    if (prev)
  ------------------
  |  Branch (1050:9): [True: 17.2k, False: 17.2k]
  ------------------
 1051|  17.2k|        prev->next = ptr->next;
 1052|       |    /* if iterator was the head */
 1053|  34.5k|    if (list->root == iterator)
  ------------------
  |  Branch (1053:9): [True: 17.2k, False: 17.2k]
  ------------------
 1054|  17.2k|        list->root = iterator->next;
 1055|       |    /* if iterator was the tail */
 1056|  34.5k|    if (list->end == iterator)
  ------------------
  |  Branch (1056:9): [True: 34.5k, False: 2]
  ------------------
 1057|  34.5k|        list->end = prev;
 1058|       |    SAFE_FREE(iterator);
  ------------------
  |  |  373|  34.5k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 34.5k, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 34.5k]
  |  |  ------------------
  ------------------
 1059|  34.5k|}
_ssh_list_pop_head:
 1073|   198k|{
 1074|   198k|  struct ssh_iterator *iterator = NULL;
 1075|   198k|  const void *data = NULL;
 1076|       |
 1077|   198k|  if (list == NULL) {
  ------------------
  |  Branch (1077:7): [True: 0, False: 198k]
  ------------------
 1078|      0|      return NULL;
 1079|      0|  }
 1080|       |
 1081|   198k|  iterator = list->root;
 1082|   198k|  if (iterator == NULL) {
  ------------------
  |  Branch (1082:7): [True: 120k, False: 77.7k]
  ------------------
 1083|   120k|      return NULL;
 1084|   120k|  }
 1085|  77.7k|  data=iterator->data;
 1086|  77.7k|  list->root=iterator->next;
 1087|  77.7k|  if(list->end==iterator)
  ------------------
  |  Branch (1087:6): [True: 25.9k, False: 51.8k]
  ------------------
 1088|  25.9k|    list->end=NULL;
 1089|       |  SAFE_FREE(iterator);
  ------------------
  |  |  373|  77.7k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 77.7k, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 77.7k]
  |  |  ------------------
  ------------------
 1090|  77.7k|  return data;
 1091|   198k|}
ssh_path_expand_tilde:
 1309|  51.8k|{
 1310|  51.8k|    char *h = NULL, *r = NULL;
 1311|  51.8k|    const char *p = NULL;
 1312|  51.8k|    size_t ld;
 1313|  51.8k|    size_t lh = 0;
 1314|       |
 1315|  51.8k|    if (d[0] != '~') {
  ------------------
  |  Branch (1315:9): [True: 43.2k, False: 8.64k]
  ------------------
 1316|  43.2k|        return strdup(d);
 1317|  43.2k|    }
 1318|  8.64k|    d++;
 1319|       |
 1320|       |    /* handle ~user/path */
 1321|  8.64k|    p = strchr(d, '/');
 1322|  8.64k|    if (p != NULL && p > d) {
  ------------------
  |  Branch (1322:9): [True: 8.64k, False: 0]
  |  Branch (1322:22): [True: 0, False: 8.64k]
  ------------------
 1323|       |#ifdef _WIN32
 1324|       |        return strdup(d);
 1325|       |#else
 1326|      0|        struct passwd *pw = NULL;
 1327|      0|        size_t s = p - d;
 1328|      0|        char u[128];
 1329|       |
 1330|      0|        if (s >= sizeof(u)) {
  ------------------
  |  Branch (1330:13): [True: 0, False: 0]
  ------------------
 1331|      0|            return NULL;
 1332|      0|        }
 1333|      0|        memcpy(u, d, s);
 1334|      0|        u[s] = '\0';
 1335|      0|        pw = getpwnam(u);
 1336|      0|        if (pw == NULL) {
  ------------------
  |  Branch (1336:13): [True: 0, False: 0]
  ------------------
 1337|      0|            return NULL;
 1338|      0|        }
 1339|      0|        ld = strlen(p);
 1340|      0|        h = strdup(pw->pw_dir);
 1341|      0|#endif
 1342|  8.64k|    } else {
 1343|  8.64k|        ld = strlen(d);
 1344|  8.64k|        p = (char *) d;
 1345|  8.64k|        h = ssh_get_user_home_dir(NULL);
 1346|  8.64k|    }
 1347|  8.64k|    if (h == NULL) {
  ------------------
  |  Branch (1347:9): [True: 0, False: 8.64k]
  ------------------
 1348|      0|        return NULL;
 1349|      0|    }
 1350|  8.64k|    lh = strlen(h);
 1351|       |
 1352|  8.64k|    r = malloc(ld + lh + 1);
 1353|  8.64k|    if (r == NULL) {
  ------------------
  |  Branch (1353:9): [True: 0, False: 8.64k]
  ------------------
 1354|      0|        SAFE_FREE(h);
  ------------------
  |  |  373|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1355|      0|        return NULL;
 1356|      0|    }
 1357|       |
 1358|  8.64k|    if (lh > 0) {
  ------------------
  |  Branch (1358:9): [True: 8.64k, False: 0]
  ------------------
 1359|  8.64k|        memcpy(r, h, lh);
 1360|  8.64k|    }
 1361|  8.64k|    SAFE_FREE(h);
  ------------------
  |  |  373|  8.64k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 8.64k, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 8.64k]
  |  |  ------------------
  ------------------
 1362|  8.64k|    memcpy(r + lh, p, ld + 1);
 1363|       |
 1364|  8.64k|    return r;
 1365|  8.64k|}
ssh_path_expand_escape:
 1699|  43.2k|{
 1700|       |    return ssh_path_expand_internal(session, s, false);
 1701|  43.2k|}
ssh_analyze_banner:
 1734|  17.2k|{
 1735|  17.2k|    const char *banner = NULL;
 1736|  17.2k|    const char *openssh = NULL;
 1737|  17.2k|    const char *ios = NULL;
 1738|       |
 1739|  17.2k|    if (server) {
  ------------------
  |  Branch (1739:9): [True: 8.64k, False: 8.64k]
  ------------------
 1740|  8.64k|        banner = session->clientbanner;
 1741|  8.64k|    } else {
 1742|  8.64k|        banner = session->serverbanner;
 1743|  8.64k|    }
 1744|       |
 1745|  17.2k|    if (banner == NULL) {
  ------------------
  |  Branch (1745:9): [True: 0, False: 17.2k]
  ------------------
 1746|      0|        ssh_set_error(session, SSH_FATAL, "Invalid banner");
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
 1747|      0|        return -1;
 1748|      0|    }
 1749|       |
 1750|       |    /*
 1751|       |     * Typical banners e.g. are:
 1752|       |     *
 1753|       |     * SSH-1.5-openSSH_5.4
 1754|       |     * SSH-1.99-openSSH_3.0
 1755|       |     *
 1756|       |     * SSH-2.0-something
 1757|       |     * 012345678901234567890
 1758|       |     */
 1759|  17.2k|    if (strlen(banner) < 6 ||
  ------------------
  |  Branch (1759:9): [True: 0, False: 17.2k]
  ------------------
 1760|  17.2k|        strncmp(banner, "SSH-", 4) != 0) {
  ------------------
  |  Branch (1760:9): [True: 0, False: 17.2k]
  ------------------
 1761|      0|          ssh_set_error(session, SSH_FATAL, "Protocol mismatch: %s", banner);
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
 1762|      0|          return -1;
 1763|      0|    }
 1764|       |
 1765|  17.2k|    SSH_LOG(SSH_LOG_DEBUG, "Analyzing banner: %s", banner);
  ------------------
  |  |  281|  17.2k|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 1766|       |
 1767|  17.2k|    switch (banner[4]) {
 1768|  17.2k|        case '2':
  ------------------
  |  Branch (1768:9): [True: 17.2k, False: 0]
  ------------------
 1769|  17.2k|            break;
 1770|      0|        case '1':
  ------------------
  |  Branch (1770:9): [True: 0, False: 17.2k]
  ------------------
 1771|      0|            if (strlen(banner) > 6) {
  ------------------
  |  Branch (1771:17): [True: 0, False: 0]
  ------------------
 1772|      0|                if (banner[6] == '9') {
  ------------------
  |  Branch (1772:21): [True: 0, False: 0]
  ------------------
 1773|      0|                    break;
 1774|      0|                }
 1775|      0|            }
 1776|      0|            FALL_THROUGH;
  ------------------
  |  |  494|      0|#  define FALL_THROUGH __attribute__ ((fallthrough))
  ------------------
 1777|      0|        default:
  ------------------
  |  Branch (1777:9): [True: 0, False: 17.2k]
  ------------------
 1778|      0|            ssh_set_error(session, SSH_FATAL, "Protocol mismatch: %s", banner);
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
 1779|      0|            return -1;
 1780|  17.2k|    }
 1781|       |
 1782|       |    /* Make a best-effort to extract OpenSSH version numbers. */
 1783|  17.2k|    openssh = strstr(banner, "OpenSSH");
 1784|  17.2k|    if (openssh != NULL) {
  ------------------
  |  Branch (1784:9): [True: 0, False: 17.2k]
  ------------------
 1785|      0|        char *tmp = NULL;
 1786|      0|        unsigned long int major = 0UL;
 1787|      0|        unsigned long int minor = 0UL;
 1788|      0|        int off = 0;
 1789|       |
 1790|       |        /*
 1791|       |         * The banner is typical:
 1792|       |         * OpenSSH_5.4
 1793|       |         * 012345678901234567890
 1794|       |         */
 1795|      0|        if (strlen(openssh) > 9) {
  ------------------
  |  Branch (1795:13): [True: 0, False: 0]
  ------------------
 1796|      0|            errno = 0;
 1797|      0|            major = strtoul(openssh + 8, &tmp, 10);
 1798|      0|            if ((tmp == (openssh + 8)) ||
  ------------------
  |  Branch (1798:17): [True: 0, False: 0]
  ------------------
 1799|      0|                ((errno == ERANGE) && (major == ULONG_MAX)) ||
  ------------------
  |  Branch (1799:18): [True: 0, False: 0]
  |  Branch (1799:39): [True: 0, False: 0]
  ------------------
 1800|      0|                ((errno != 0) && (major == 0)) ||
  ------------------
  |  Branch (1800:18): [True: 0, False: 0]
  |  Branch (1800:34): [True: 0, False: 0]
  ------------------
 1801|      0|                ((major < 1) || (major > 100))) {
  ------------------
  |  Branch (1801:18): [True: 0, False: 0]
  |  Branch (1801:33): [True: 0, False: 0]
  ------------------
 1802|       |                /* invalid major */
 1803|      0|                errno = 0;
 1804|      0|                goto done;
 1805|      0|            }
 1806|       |
 1807|      0|            errno = 0;
 1808|      0|            off = major >= 10 ? 11 : 10;
  ------------------
  |  Branch (1808:19): [True: 0, False: 0]
  ------------------
 1809|      0|            minor = strtoul(openssh + off, &tmp, 10);
 1810|      0|            if ((tmp == (openssh + off)) ||
  ------------------
  |  Branch (1810:17): [True: 0, False: 0]
  ------------------
 1811|      0|                ((errno == ERANGE) && (major == ULONG_MAX)) ||
  ------------------
  |  Branch (1811:18): [True: 0, False: 0]
  |  Branch (1811:39): [True: 0, False: 0]
  ------------------
 1812|      0|                ((errno != 0) && (major == 0)) ||
  ------------------
  |  Branch (1812:18): [True: 0, False: 0]
  |  Branch (1812:34): [True: 0, False: 0]
  ------------------
 1813|      0|                (minor > 100)) {
  ------------------
  |  Branch (1813:17): [True: 0, False: 0]
  ------------------
 1814|       |                /* invalid minor */
 1815|      0|                errno = 0;
 1816|      0|                goto done;
 1817|      0|            }
 1818|       |
 1819|      0|            session->openssh = SSH_VERSION_INT(((int) major), ((int) minor), 0);
  ------------------
  |  |   25|      0|#define SSH_VERSION_INT(a, b, c) ((a) << 16 | (b) << 8 | (c))
  ------------------
 1820|       |
 1821|      0|            SSH_LOG(SSH_LOG_DEBUG,
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (281:34): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 1822|      0|                    "We are talking to an OpenSSH %s version: %lu.%lu (%x)",
 1823|      0|                    server ? "client" : "server",
 1824|      0|                    major, minor, session->openssh);
 1825|      0|        }
 1826|      0|    }
 1827|       |    /* Cisco devices have odd scp implementation which breaks */
 1828|  17.2k|    ios = strstr(banner, "Cisco");
 1829|  17.2k|    if (ios != NULL) {
  ------------------
  |  Branch (1829:9): [True: 0, False: 17.2k]
  ------------------
 1830|      0|        session->flags |= SSH_SESSION_FLAG_SCP_QUOTING_BROKEN;
  ------------------
  |  |   95|      0|#define SSH_SESSION_FLAG_SCP_QUOTING_BROKEN 0x0040
  ------------------
 1831|      0|    }
 1832|       |
 1833|  17.2k|done:
 1834|  17.2k|    return 0;
 1835|  17.2k|}
ssh_timestamp_init:
 1850|  2.18M|{
 1851|  2.18M|#ifdef HAVE_CLOCK_GETTIME
 1852|  2.18M|  struct timespec tp;
 1853|  2.18M|  clock_gettime(CLOCK, &tp);
  ------------------
  |  | 1839|  2.18M|#define CLOCK CLOCK_MONOTONIC
  ------------------
 1854|  2.18M|  ts->useconds = tp.tv_nsec / 1000;
 1855|       |#else
 1856|       |  struct timeval tp;
 1857|       |  gettimeofday(&tp, NULL);
 1858|       |  ts->useconds = tp.tv_usec;
 1859|       |#endif
 1860|  2.18M|  ts->seconds = tp.tv_sec;
 1861|  2.18M|}
ssh_make_milliseconds:
 1898|  85.4k|{
 1899|  85.4k|    unsigned long res;
 1900|       |
 1901|  85.4k|    if (sec == (unsigned long)SSH_TIMEOUT_INFINITE) {
  ------------------
  |  |   99|  85.4k|#define SSH_TIMEOUT_INFINITE -1
  ------------------
  |  Branch (1901:9): [True: 0, False: 85.4k]
  ------------------
 1902|      0|        return SSH_TIMEOUT_INFINITE;
  ------------------
  |  |   99|      0|#define SSH_TIMEOUT_INFINITE -1
  ------------------
 1903|      0|    }
 1904|  85.4k|    if (sec > (unsigned long)INT_MAX / 1000) {
  ------------------
  |  Branch (1904:9): [True: 0, False: 85.4k]
  ------------------
 1905|      0|        return INT_MAX;
 1906|      0|    }
 1907|       |
 1908|  85.4k|    res = usec / 1000;
 1909|  85.4k|    res += (sec * 1000);
 1910|  85.4k|    if (res == 0) {
  ------------------
  |  Branch (1910:9): [True: 0, False: 85.4k]
  ------------------
 1911|      0|        res = 10 * 1000; /* use a reasonable default value in case
 1912|       |                          * SSH_OPTIONS_TIMEOUT is not set in options. */
 1913|      0|    }
 1914|       |
 1915|  85.4k|    if (res > INT_MAX) {
  ------------------
  |  Branch (1915:9): [True: 0, False: 85.4k]
  ------------------
 1916|      0|        return INT_MAX;
 1917|  85.4k|    } else {
 1918|  85.4k|        return (int)res;
 1919|  85.4k|    }
 1920|  85.4k|}
ssh_timeout_elapsed:
 1933|   550k|{
 1934|   550k|    struct ssh_timestamp now;
 1935|       |
 1936|   550k|    switch(timeout) {
 1937|      0|        case -2: /*
  ------------------
  |  Branch (1937:9): [True: 0, False: 550k]
  ------------------
 1938|       |                  * -2 means user-defined timeout as available in
 1939|       |                  * session->timeout, session->timeout_usec.
 1940|       |                  */
 1941|      0|            SSH_LOG(SSH_LOG_DEBUG, "ssh_timeout_elapsed called with -2. this needs to "
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 1942|      0|                            "be fixed. please set a breakpoint on misc.c:%d and "
 1943|      0|                            "fix the caller\n", __LINE__);
 1944|      0|            return 0;
 1945|  97.4k|        case -1: /* -1 means infinite timeout */
  ------------------
  |  Branch (1945:9): [True: 97.4k, False: 453k]
  ------------------
 1946|  97.4k|            return 0;
 1947|      0|        case 0: /* 0 means no timeout */
  ------------------
  |  Branch (1947:9): [True: 0, False: 550k]
  ------------------
 1948|      0|            return 1;
 1949|   453k|        default:
  ------------------
  |  Branch (1949:9): [True: 453k, False: 97.3k]
  ------------------
 1950|   453k|            break;
 1951|   550k|    }
 1952|       |
 1953|   453k|    ssh_timestamp_init(&now);
 1954|       |
 1955|   453k|    return (ssh_timestamp_difference(ts,&now) >= timeout);
 1956|   550k|}
ssh_timeout_update:
 1966|  1.17M|{
 1967|  1.17M|  struct ssh_timestamp now;
 1968|  1.17M|  int ms, ret;
 1969|  1.17M|  if (timeout <= 0) {
  ------------------
  |  Branch (1969:7): [True: 194k, False: 984k]
  ------------------
 1970|   194k|      return timeout;
 1971|   194k|  }
 1972|   984k|  ssh_timestamp_init(&now);
 1973|   984k|  ms = ssh_timestamp_difference(ts,&now);
 1974|   984k|  if(ms < 0)
  ------------------
  |  Branch (1974:6): [True: 0, False: 984k]
  ------------------
 1975|      0|    ms = 0;
 1976|   984k|  ret = timeout - ms;
 1977|  18.4E|  return ret >= 0 ? ret: 0;
  ------------------
  |  Branch (1977:10): [True: 984k, False: 18.4E]
  ------------------
 1978|  1.17M|}
ssh_quote_file_name:
 2078|  8.64k|{
 2079|  8.64k|    const char *src = NULL;
 2080|  8.64k|    char *dst = NULL;
 2081|  8.64k|    size_t required_buf_len;
 2082|       |
 2083|  8.64k|    enum ssh_quote_state_e state = NO_QUOTE;
 2084|       |
 2085|  8.64k|    if (file_name == NULL || buf == NULL || buf_len == 0) {
  ------------------
  |  Branch (2085:9): [True: 0, False: 8.64k]
  |  Branch (2085:30): [True: 0, False: 8.64k]
  |  Branch (2085:45): [True: 0, False: 8.64k]
  ------------------
 2086|      0|        SSH_LOG(SSH_LOG_TRACE, "Invalid parameter");
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 2087|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 2088|      0|    }
 2089|       |
 2090|       |    /* Only allow file names smaller than 32kb. */
 2091|  8.64k|    if (strlen(file_name) > 32 * 1024) {
  ------------------
  |  Branch (2091:9): [True: 0, False: 8.64k]
  ------------------
 2092|      0|        SSH_LOG(SSH_LOG_TRACE, "File name too long");
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 2093|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 2094|      0|    }
 2095|       |
 2096|       |    /* Paranoia check */
 2097|  8.64k|    required_buf_len = (size_t)3 * strlen(file_name) + 1;
 2098|  8.64k|    if (required_buf_len > buf_len) {
  ------------------
  |  Branch (2098:9): [True: 0, False: 8.64k]
  ------------------
 2099|      0|        SSH_LOG(SSH_LOG_TRACE, "Buffer too small");
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 2100|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 2101|      0|    }
 2102|       |
 2103|  8.64k|    src = file_name;
 2104|  8.64k|    dst = buf;
 2105|       |
 2106|  86.4k|    while ((*src != '\0')) {
  ------------------
  |  Branch (2106:12): [True: 77.7k, False: 8.64k]
  ------------------
 2107|  77.7k|        switch (*src) {
 2108|       |
 2109|       |        /* The '\'' char is double quoted */
 2110|       |
 2111|      0|        case '\'':
  ------------------
  |  Branch (2111:9): [True: 0, False: 77.7k]
  ------------------
 2112|      0|            switch (state) {
 2113|      0|            case NO_QUOTE:
  ------------------
  |  Branch (2113:13): [True: 0, False: 0]
  ------------------
 2114|       |                /* Start a new double quoted string. The '\'' char will be
 2115|       |                 * copied to the beginning of it at the end of the loop. */
 2116|      0|                *dst++ = '"';
 2117|      0|                break;
 2118|      0|            case SINGLE_QUOTE:
  ------------------
  |  Branch (2118:13): [True: 0, False: 0]
  ------------------
 2119|       |                /* Close the current single quoted string and start a new double
 2120|       |                 * quoted string. The '\'' char will be copied to the beginning
 2121|       |                 * of it at the end of the loop. */
 2122|      0|                *dst++ = '\'';
 2123|      0|                *dst++ = '"';
 2124|      0|                break;
 2125|      0|            case DOUBLE_QUOTE:
  ------------------
  |  Branch (2125:13): [True: 0, False: 0]
  ------------------
 2126|       |                /* If already in the double quoted string, keep copying the
 2127|       |                 * sequence of chars. */
 2128|      0|                break;
 2129|      0|            default:
  ------------------
  |  Branch (2129:13): [True: 0, False: 0]
  ------------------
 2130|       |                /* Should never be reached */
 2131|      0|                goto error;
 2132|      0|            }
 2133|       |
 2134|       |            /* When the '\'' char is found, the resulting state will be
 2135|       |             * DOUBLE_QUOTE in any case*/
 2136|      0|            state = DOUBLE_QUOTE;
 2137|      0|            break;
 2138|       |
 2139|       |        /* The '!' char is replaced by unquoted "\!" */
 2140|       |
 2141|      0|        case '!':
  ------------------
  |  Branch (2141:9): [True: 0, False: 77.7k]
  ------------------
 2142|      0|            switch (state) {
 2143|      0|            case NO_QUOTE:
  ------------------
  |  Branch (2143:13): [True: 0, False: 0]
  ------------------
 2144|       |                /* The '!' char is interpreted in some shells (e.g. CSH) even
 2145|       |                 * when is quoted with single quotes.  Replace it with unquoted
 2146|       |                 * "\!" which is correctly interpreted as the '!' character. */
 2147|      0|                *dst++ = '\\';
 2148|      0|                break;
 2149|      0|            case SINGLE_QUOTE:
  ------------------
  |  Branch (2149:13): [True: 0, False: 0]
  ------------------
 2150|       |                /* Close the currently quoted string and replace '!' for unquoted
 2151|       |                 * "\!" */
 2152|      0|                *dst++ = '\'';
 2153|      0|                *dst++ = '\\';
 2154|      0|                break;
 2155|      0|            case DOUBLE_QUOTE:
  ------------------
  |  Branch (2155:13): [True: 0, False: 0]
  ------------------
 2156|       |                /* Close currently quoted string and replace  "!" for unquoted
 2157|       |                 * "\!" */
 2158|      0|                *dst++ = '"';
 2159|      0|                *dst++ = '\\';
 2160|      0|                break;
 2161|      0|            default:
  ------------------
  |  Branch (2161:13): [True: 0, False: 0]
  ------------------
 2162|       |                /* Should never be reached */
 2163|      0|                goto error;
 2164|      0|            }
 2165|       |
 2166|       |            /* When the '!' char is found, the resulting state will be NO_QUOTE
 2167|       |             * in any case*/
 2168|      0|            state = NO_QUOTE;
 2169|      0|            break;
 2170|       |
 2171|       |        /* Ordinary chars are single quoted */
 2172|       |
 2173|  77.7k|        default:
  ------------------
  |  Branch (2173:9): [True: 77.7k, False: 0]
  ------------------
 2174|  77.7k|            switch (state) {
 2175|  8.64k|            case NO_QUOTE:
  ------------------
  |  Branch (2175:13): [True: 8.64k, False: 69.1k]
  ------------------
 2176|       |                /* Start a new single quoted string */
 2177|  8.64k|                *dst++ = '\'';
 2178|  8.64k|                break;
 2179|  69.1k|            case SINGLE_QUOTE:
  ------------------
  |  Branch (2179:13): [True: 69.1k, False: 8.64k]
  ------------------
 2180|       |                /* If already in the single quoted string, keep copying the
 2181|       |                 * sequence of chars. */
 2182|  69.1k|                break;
 2183|      0|            case DOUBLE_QUOTE:
  ------------------
  |  Branch (2183:13): [True: 0, False: 77.7k]
  ------------------
 2184|       |                /* Close current double quoted string and start a new single
 2185|       |                 * quoted string. */
 2186|      0|                *dst++ = '"';
 2187|      0|                *dst++ = '\'';
 2188|      0|                break;
 2189|      0|            default:
  ------------------
  |  Branch (2189:13): [True: 0, False: 77.7k]
  ------------------
 2190|       |                /* Should never be reached */
 2191|      0|                goto error;
 2192|  77.7k|            }
 2193|       |
 2194|       |            /* When an ordinary char is found, the resulting state will be
 2195|       |             * SINGLE_QUOTE in any case*/
 2196|  77.7k|            state = SINGLE_QUOTE;
 2197|  77.7k|            break;
 2198|  77.7k|        }
 2199|       |
 2200|       |        /* Copy the current char to output */
 2201|  77.7k|        *dst++ = *src++;
 2202|  77.7k|    }
 2203|       |
 2204|       |    /* Close the quoted string when necessary */
 2205|       |
 2206|  8.64k|    switch (state) {
 2207|      0|    case NO_QUOTE:
  ------------------
  |  Branch (2207:5): [True: 0, False: 8.64k]
  ------------------
 2208|       |        /* No open string */
 2209|      0|        break;
 2210|  8.64k|    case SINGLE_QUOTE:
  ------------------
  |  Branch (2210:5): [True: 8.64k, False: 0]
  ------------------
 2211|       |        /* Close current single quoted string */
 2212|  8.64k|        *dst++ = '\'';
 2213|  8.64k|        break;
 2214|      0|    case DOUBLE_QUOTE:
  ------------------
  |  Branch (2214:5): [True: 0, False: 8.64k]
  ------------------
 2215|       |        /* Close current double quoted string */
 2216|      0|        *dst++ = '"';
 2217|      0|        break;
 2218|      0|    default:
  ------------------
  |  Branch (2218:5): [True: 0, False: 8.64k]
  ------------------
 2219|       |        /* Should never be reached */
 2220|      0|        goto error;
 2221|  8.64k|    }
 2222|       |
 2223|       |    /* Put the string terminator */
 2224|  8.64k|    *dst = '\0';
 2225|       |
 2226|  8.64k|    return (int)(dst - buf);
 2227|       |
 2228|      0|error:
 2229|      0|    return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 2230|  8.64k|}
ssh_strerror:
 2396|  60.4k|{
 2397|       |#if ((defined(__linux__) && defined(__GLIBC__)) || defined(__CYGWIN__)) && defined(_GNU_SOURCE)
 2398|       |    /* GNU extension on Linux */
 2399|       |    return strerror_r(err_num, buf, buflen);
 2400|       |#else
 2401|  60.4k|    int rv;
 2402|       |
 2403|       |#if defined(_WIN32)
 2404|       |    rv = strerror_s(buf, buflen, err_num);
 2405|       |#else
 2406|       |    /* POSIX version available for example on FreeBSD or in musl libc */
 2407|  60.4k|    rv = strerror_r(err_num, buf, buflen);
 2408|  60.4k|#endif /* _WIN32 */
 2409|       |
 2410|       |    /* make sure the buffer is initialized and terminated with NULL */
 2411|  60.4k|    if (-rv == ERANGE) {
  ------------------
  |  Branch (2411:9): [True: 0, False: 60.4k]
  ------------------
 2412|      0|        buf[0] = '\0';
 2413|      0|    }
 2414|  60.4k|    return buf;
 2415|  60.4k|#endif /* ((defined(__linux__) && defined(__GLIBC__)) || defined(__CYGWIN__)) && defined(_GNU_SOURCE) */
 2416|  60.4k|}
ssh_check_hostname_syntax:
 2547|  8.64k|{
 2548|  8.64k|    char *it = NULL, *s = NULL, *buf = NULL;
 2549|  8.64k|    size_t it_len;
 2550|  8.64k|    char c;
 2551|       |
 2552|  8.64k|    if (hostname == NULL || strlen(hostname) == 0) {
  ------------------
  |  Branch (2552:9): [True: 0, False: 8.64k]
  |  Branch (2552:29): [True: 0, False: 8.64k]
  ------------------
 2553|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 2554|      0|    }
 2555|       |
 2556|       |    /* strtok_r writes into the string, keep the input clean */
 2557|  8.64k|    s = strdup(hostname);
 2558|  8.64k|    if (s == NULL) {
  ------------------
  |  Branch (2558:9): [True: 0, False: 8.64k]
  ------------------
 2559|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 2560|      0|    }
 2561|       |
 2562|  8.64k|    it = strtok_r(s, ".", &buf);
 2563|       |    /* if the token has 0 length */
 2564|  8.64k|    if (it == NULL) {
  ------------------
  |  Branch (2564:9): [True: 0, False: 8.64k]
  ------------------
 2565|      0|        free(s);
 2566|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 2567|      0|    }
 2568|  8.64k|    do {
 2569|  8.64k|        it_len = strlen(it);
 2570|  8.64k|        if (it_len > ARPA_DOMAIN_MAX_LEN ||
  ------------------
  |  |  100|  17.2k|#define ARPA_DOMAIN_MAX_LEN 63
  ------------------
  |  Branch (2570:13): [True: 0, False: 8.64k]
  ------------------
 2571|       |            /* the first char must be a letter, but some virtual urls start
 2572|       |             * with a number */
 2573|  8.64k|            isalnum(it[0]) == 0 ||
  ------------------
  |  Branch (2573:13): [True: 0, False: 8.64k]
  ------------------
 2574|  8.64k|            isalnum(it[it_len - 1]) == 0) {
  ------------------
  |  Branch (2574:13): [True: 0, False: 8.64k]
  ------------------
 2575|      0|            free(s);
 2576|      0|            return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 2577|      0|        }
 2578|  86.4k|        while (*it != '\0') {
  ------------------
  |  Branch (2578:16): [True: 77.7k, False: 8.64k]
  ------------------
 2579|  77.7k|            c = *it;
 2580|       |            /* the "." is allowed too, but tokenization removes it from the
 2581|       |             * string */
 2582|  77.7k|            if (isalnum(c) == 0 && c != '-') {
  ------------------
  |  Branch (2582:17): [True: 0, False: 77.7k]
  |  Branch (2582:36): [True: 0, False: 0]
  ------------------
 2583|      0|                free(s);
 2584|      0|                return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 2585|      0|            }
 2586|  77.7k|            it++;
 2587|  77.7k|        }
 2588|  8.64k|    } while ((it = strtok_r(NULL, ".", &buf)) != NULL);
  ------------------
  |  Branch (2588:14): [True: 0, False: 8.64k]
  ------------------
 2589|       |
 2590|  8.64k|    free(s);
 2591|       |
 2592|  8.64k|    return SSH_OK;
  ------------------
  |  |  316|  8.64k|#define SSH_OK 0     /* No error */
  ------------------
 2593|  8.64k|}
ssh_check_username_syntax:
 2606|  8.64k|{
 2607|  8.64k|    size_t username_len;
 2608|       |
 2609|  8.64k|    if (username == NULL || *username == '-') {
  ------------------
  |  Branch (2609:9): [True: 0, False: 8.64k]
  |  Branch (2609:29): [True: 0, False: 8.64k]
  ------------------
 2610|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 2611|      0|    }
 2612|       |
 2613|  8.64k|    username_len = strlen(username);
 2614|  8.64k|    if (username_len == 0 || username[username_len - 1] == '\\' ||
  ------------------
  |  Branch (2614:9): [True: 0, False: 8.64k]
  |  Branch (2614:30): [True: 0, False: 8.64k]
  ------------------
 2615|  8.64k|        strpbrk(username, "'`\";&<>|(){}") != NULL) {
  ------------------
  |  Branch (2615:9): [True: 0, False: 8.64k]
  ------------------
 2616|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 2617|      0|    }
 2618|  43.2k|    for (size_t i = 0; i < username_len; i++) {
  ------------------
  |  Branch (2618:24): [True: 34.5k, False: 8.64k]
  ------------------
 2619|  34.5k|        if (isspace(username[i]) != 0 && username[i + 1] == '-') {
  ------------------
  |  Branch (2619:13): [True: 0, False: 34.5k]
  |  Branch (2619:42): [True: 0, False: 0]
  ------------------
 2620|      0|            return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 2621|      0|        }
 2622|  34.5k|    }
 2623|       |
 2624|  8.64k|    return SSH_OK;
  ------------------
  |  |  316|  8.64k|#define SSH_OK 0     /* No error */
  ------------------
 2625|  8.64k|}
ssh_proxyjumps_free:
 2637|  17.2k|{
 2638|  17.2k|    struct ssh_jump_info_struct *jump = NULL;
 2639|       |
 2640|  17.2k|    for (jump =
 2641|  17.2k|             ssh_list_pop_head(struct ssh_jump_info_struct *, proxy_jump_list);
  ------------------
  |  |  122|  17.2k|  ((type)_ssh_list_pop_head(ssh_list))
  ------------------
 2642|  17.2k|         jump != NULL;
  ------------------
  |  Branch (2642:10): [True: 0, False: 17.2k]
  ------------------
 2643|  17.2k|         jump = ssh_list_pop_head(struct ssh_jump_info_struct *,
  ------------------
  |  |  122|      0|  ((type)_ssh_list_pop_head(ssh_list))
  ------------------
 2644|  17.2k|                                  proxy_jump_list)) {
 2645|      0|        SAFE_FREE(jump->hostname);
  ------------------
  |  |  373|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2646|      0|        SAFE_FREE(jump->username);
  ------------------
  |  |  373|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2647|       |        SAFE_FREE(jump);
  ------------------
  |  |  373|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2648|      0|    }
 2649|  17.2k|}
ssh_strict_fopen:
 2683|  34.5k|{
 2684|  34.5k|    FILE *f = NULL;
 2685|  34.5k|    struct stat sb;
 2686|  34.5k|    int r, fd;
 2687|       |
 2688|       |    /* open first to avoid TOCTOU */
 2689|  34.5k|    fd = open(filename, O_RDONLY);
 2690|  34.5k|    if (fd == -1) {
  ------------------
  |  Branch (2690:9): [True: 34.5k, False: 0]
  ------------------
 2691|  34.5k|        SSH_LOG_STRERROR(SSH_LOG_TRACE,
  ------------------
  |  |  283|  34.5k|    do {                                                            \
  |  |  284|  34.5k|        char err_msg[SSH_ERRNO_MSG_MAX] = {0};                      \
  |  |  285|  34.5k|        _ssh_log(priority,                                          \
  |  |  286|  34.5k|                 __func__,                                          \
  |  |  287|  34.5k|                 __VA_ARGS__,                                       \
  |  |  288|  34.5k|                 ssh_strerror(errnum, err_msg, SSH_ERRNO_MSG_MAX)); \
  |  |  ------------------
  |  |  |  |  520|  34.5k|#define SSH_ERRNO_MSG_MAX   1024
  |  |  ------------------
  |  |  289|  34.5k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (289:14): [Folded, False: 34.5k]
  |  |  ------------------
  ------------------
 2692|  34.5k|                         errno,
 2693|  34.5k|                         "Failed to open a file %s for reading: %s",
 2694|  34.5k|                         filename);
 2695|  34.5k|        return NULL;
 2696|  34.5k|    }
 2697|       |
 2698|       |    /* Check the file is sensible for a configuration file */
 2699|      0|    r = fstat(fd, &sb);
 2700|      0|    if (r != 0) {
  ------------------
  |  Branch (2700:9): [True: 0, False: 0]
  ------------------
 2701|      0|        SSH_LOG_STRERROR(SSH_LOG_TRACE,
  ------------------
  |  |  283|      0|    do {                                                            \
  |  |  284|      0|        char err_msg[SSH_ERRNO_MSG_MAX] = {0};                      \
  |  |  285|      0|        _ssh_log(priority,                                          \
  |  |  286|      0|                 __func__,                                          \
  |  |  287|      0|                 __VA_ARGS__,                                       \
  |  |  288|      0|                 ssh_strerror(errnum, err_msg, SSH_ERRNO_MSG_MAX)); \
  |  |  ------------------
  |  |  |  |  520|      0|#define SSH_ERRNO_MSG_MAX   1024
  |  |  ------------------
  |  |  289|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (289:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2702|      0|                         errno,
 2703|      0|                         "Failed to stat %s: %s",
 2704|      0|                         filename);
 2705|      0|        close(fd);
 2706|      0|        return NULL;
 2707|      0|    }
 2708|      0|    if ((sb.st_mode & S_IFMT) != S_IFREG) {
  ------------------
  |  Branch (2708:9): [True: 0, False: 0]
  ------------------
 2709|      0|        SSH_LOG(SSH_LOG_TRACE,
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 2710|      0|                "The file %s is not a regular file: skipping",
 2711|      0|                filename);
 2712|      0|        close(fd);
 2713|      0|        return NULL;
 2714|      0|    }
 2715|       |
 2716|      0|    if ((size_t)sb.st_size > max_file_size) {
  ------------------
  |  Branch (2716:9): [True: 0, False: 0]
  ------------------
 2717|      0|        SSH_LOG(SSH_LOG_TRACE,
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 2718|      0|                "The file %s is too large (%jd MB > %zu MB): skipping",
 2719|      0|                filename,
 2720|      0|                (intmax_t)sb.st_size / 1024 / 1024,
 2721|      0|                max_file_size / 1024 / 1024);
 2722|      0|        close(fd);
 2723|      0|        return NULL;
 2724|      0|    }
 2725|       |
 2726|      0|    f = fdopen(fd, "r");
 2727|      0|    if (f == NULL) {
  ------------------
  |  Branch (2727:9): [True: 0, False: 0]
  ------------------
 2728|      0|        SSH_LOG_STRERROR(SSH_LOG_TRACE,
  ------------------
  |  |  283|      0|    do {                                                            \
  |  |  284|      0|        char err_msg[SSH_ERRNO_MSG_MAX] = {0};                      \
  |  |  285|      0|        _ssh_log(priority,                                          \
  |  |  286|      0|                 __func__,                                          \
  |  |  287|      0|                 __VA_ARGS__,                                       \
  |  |  288|      0|                 ssh_strerror(errnum, err_msg, SSH_ERRNO_MSG_MAX)); \
  |  |  ------------------
  |  |  |  |  520|      0|#define SSH_ERRNO_MSG_MAX   1024
  |  |  ------------------
  |  |  289|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (289:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2729|      0|                         errno,
 2730|      0|                         "Failed to open a file %s for reading: %s",
 2731|      0|                         filename);
 2732|      0|        close(fd);
 2733|      0|        return NULL;
 2734|      0|    }
 2735|       |
 2736|       |    /* the flcose() will close also the underlying fd */
 2737|      0|    return f;
 2738|      0|}
strlcpy:
 2749|  43.2k|{
 2750|  43.2k|    size_t len = strlen(src);
 2751|       |
 2752|  43.2k|    if (size != 0) {
  ------------------
  |  Branch (2752:9): [True: 43.2k, False: 0]
  ------------------
 2753|  43.2k|        size_t copy_len = (len >= size) ? size - 1 : len;
  ------------------
  |  Branch (2753:27): [True: 0, False: 43.2k]
  ------------------
 2754|       |
 2755|  43.2k|        memcpy(dst, src, copy_len);
 2756|  43.2k|        dst[copy_len] = '\0';
 2757|  43.2k|    }
 2758|       |
 2759|  43.2k|    return len;
 2760|  43.2k|}
ssh_normalize_loose_ip:
 2797|  17.2k|{
 2798|  17.2k|    struct in_addr addr;
 2799|  17.2k|    char buf[INET_ADDRSTRLEN];
 2800|  17.2k|    const char *p = NULL;
 2801|  17.2k|    int rc;
 2802|  17.2k|    int is_ip;
 2803|       |#ifdef _WIN32
 2804|       |    unsigned long ip;
 2805|       |    int is_broadcast;
 2806|       |#endif
 2807|       |
 2808|  17.2k|    if (host == NULL || result == NULL) {
  ------------------
  |  Branch (2808:9): [True: 0, False: 17.2k]
  |  Branch (2808:25): [True: 0, False: 17.2k]
  ------------------
 2809|      0|        return -1;
 2810|      0|    }
 2811|       |
 2812|       |    /* We don't want to normalize stricter IP checks already handled by valid
 2813|       |     * IPv4/IPv6 */
 2814|  17.2k|    is_ip = ssh_is_ipaddr(host);
 2815|  17.2k|    if (is_ip) {
  ------------------
  |  Branch (2815:9): [True: 0, False: 17.2k]
  ------------------
 2816|      0|        return 1; /* not a loose IP — already a strict address */
 2817|      0|    }
 2818|       |
 2819|       |#ifdef _WIN32
 2820|       |    ip = inet_addr(host);
 2821|       |    is_broadcast = strcmp(host, "255.255.255.255");
 2822|       |    if (ip == INADDR_NONE && is_broadcast != 0) {
 2823|       |        return 1; /* not a loose IP */
 2824|       |    }
 2825|       |    addr.S_un.S_addr = ip;
 2826|       |#else
 2827|  17.2k|    rc = inet_aton(host, &addr);
 2828|  17.2k|    if (rc == 0) {
  ------------------
  |  Branch (2828:9): [True: 17.2k, False: 0]
  ------------------
 2829|  17.2k|        return 1; /* not a loose IP */
 2830|  17.2k|    }
 2831|      0|#endif
 2832|       |
 2833|      0|    p = inet_ntop(AF_INET, &addr, buf, sizeof(buf));
 2834|      0|    if (p == NULL) {
  ------------------
  |  Branch (2834:9): [True: 0, False: 0]
  ------------------
 2835|      0|        return -1;
 2836|      0|    }
 2837|       |
 2838|      0|    *result = strdup(p);
 2839|      0|    if (*result == NULL) {
  ------------------
  |  Branch (2839:9): [True: 0, False: 0]
  ------------------
 2840|      0|        return -1;
 2841|      0|    }
 2842|       |
 2843|      0|    return 0;
 2844|      0|}
misc.c:ssh_get_user_home_dir_internal:
  329|  17.2k|{
  330|  17.2k|    char *szPath = NULL;
  331|  17.2k|    struct passwd pwd;
  332|  17.2k|    struct passwd *pwdbuf = NULL;
  333|  17.2k|    char buf[NSS_BUFLEN_PASSWD] = {0};
  334|  17.2k|    int rc;
  335|       |
  336|  17.2k|    rc = getpwuid_r(getuid(), &pwd, buf, NSS_BUFLEN_PASSWD, &pwdbuf);
  337|  17.2k|    if (rc != 0 || pwdbuf == NULL ) {
  ------------------
  |  Branch (337:9): [True: 0, False: 17.2k]
  |  Branch (337:20): [True: 0, False: 17.2k]
  ------------------
  338|      0|        szPath = getenv("HOME");
  339|      0|        if (szPath == NULL) {
  ------------------
  |  Branch (339:13): [True: 0, False: 0]
  ------------------
  340|      0|            return NULL;
  341|      0|        }
  342|      0|        snprintf(buf, sizeof(buf), "%s", szPath);
  343|      0|        return strdup(buf);
  344|      0|    }
  345|       |
  346|  17.2k|    szPath = strdup(pwd.pw_dir);
  347|       |
  348|  17.2k|    return szPath;
  349|  17.2k|}
misc.c:ssh_iterator_new:
  947|   146k|{
  948|   146k|    struct ssh_iterator *iterator = malloc(sizeof(struct ssh_iterator));
  949|       |
  950|   146k|    if (iterator == NULL) {
  ------------------
  |  Branch (950:9): [True: 0, False: 146k]
  ------------------
  951|      0|        return NULL;
  952|      0|    }
  953|   146k|    iterator->next = NULL;
  954|   146k|    iterator->data = data;
  955|   146k|    return iterator;
  956|   146k|}
misc.c:ssh_path_expand_internal:
 1478|  43.2k|{
 1479|  43.2k|    char *buf = NULL;
 1480|  43.2k|    char *r = NULL;
 1481|  43.2k|    char *x = NULL;
 1482|  43.2k|    const char *p = NULL;
 1483|  43.2k|    size_t i, l;
 1484|       |
 1485|  43.2k|    r = ssh_path_expand_tilde(s);
 1486|  43.2k|    if (r == NULL) {
  ------------------
  |  Branch (1486:9): [True: 0, False: 43.2k]
  ------------------
 1487|      0|        ssh_set_error_oom(session);
  ------------------
  |  |  318|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
 1488|      0|        return NULL;
 1489|      0|    }
 1490|       |
 1491|  43.2k|    if (strlen(r) > MAX_BUF_SIZE) {
  ------------------
  |  |  230|  43.2k|#define MAX_BUF_SIZE 4096
  ------------------
  |  Branch (1491:9): [True: 0, False: 43.2k]
  ------------------
 1492|      0|        ssh_set_error(session, SSH_FATAL, "string to expand too long");
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
 1493|      0|        free(r);
 1494|      0|        return NULL;
 1495|      0|    }
 1496|       |
 1497|  43.2k|    buf = malloc(MAX_BUF_SIZE);
  ------------------
  |  |  230|  43.2k|#define MAX_BUF_SIZE 4096
  ------------------
 1498|  43.2k|    if (buf == NULL) {
  ------------------
  |  Branch (1498:9): [True: 0, False: 43.2k]
  ------------------
 1499|      0|        ssh_set_error_oom(session);
  ------------------
  |  |  318|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
 1500|      0|        free(r);
 1501|      0|        return NULL;
 1502|      0|    }
 1503|       |
 1504|  43.2k|    p = r;
 1505|  43.2k|    buf[0] = '\0';
 1506|       |
 1507|   699k|    for (i = 0; *p != '\0'; p++) {
  ------------------
  |  Branch (1507:17): [True: 656k, False: 43.2k]
  ------------------
 1508|   656k|        if (*p != '%') {
  ------------------
  |  Branch (1508:13): [True: 613k, False: 43.2k]
  ------------------
 1509|   613k|            buf[i] = hostname_lenient ? tolower((unsigned char)*p) : *p;
  ------------------
  |  Branch (1509:22): [True: 0, False: 613k]
  |  Branch (1509:41): [True: 0, False: 0]
  |  Branch (1509:41): [True: 0, False: 0]
  |  Branch (1509:41): [Folded, False: 0]
  ------------------
 1510|   613k|            i++;
 1511|   613k|            if (i >= MAX_BUF_SIZE) {
  ------------------
  |  |  230|   613k|#define MAX_BUF_SIZE 4096
  ------------------
  |  Branch (1511:17): [True: 0, False: 613k]
  ------------------
 1512|      0|                free(buf);
 1513|      0|                free(r);
 1514|      0|                return NULL;
 1515|      0|            }
 1516|   613k|            buf[i] = '\0';
 1517|   613k|            continue;
 1518|   613k|        }
 1519|       |
 1520|  43.2k|        p++;
 1521|  43.2k|        if (*p == '\0') {
  ------------------
  |  Branch (1521:13): [True: 0, False: 43.2k]
  ------------------
 1522|       |            /* HostName expansion rejects trailing '%' to match the parse-time
 1523|       |             * scan. Keep the general expansion path unchanged, where a
 1524|       |             * trailing '%' is truncated.
 1525|       |             */
 1526|      0|            if (hostname_lenient) {
  ------------------
  |  Branch (1526:17): [True: 0, False: 0]
  ------------------
 1527|      0|                ssh_set_error(session, SSH_FATAL, "Incomplete Hostname token");
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
 1528|      0|                free(buf);
 1529|      0|                free(r);
 1530|      0|                return NULL;
 1531|      0|            }
 1532|      0|            break;
 1533|      0|        }
 1534|       |
 1535|  43.2k|        if (hostname_lenient && *p != '%' && *p != 'h') {
  ------------------
  |  Branch (1535:13): [True: 0, False: 43.2k]
  |  Branch (1535:33): [True: 0, False: 0]
  |  Branch (1535:46): [True: 0, False: 0]
  ------------------
 1536|      0|            buf[i] = '%';
 1537|      0|            i++;
 1538|      0|            if (i >= MAX_BUF_SIZE) {
  ------------------
  |  |  230|      0|#define MAX_BUF_SIZE 4096
  ------------------
  |  Branch (1538:17): [True: 0, False: 0]
  ------------------
 1539|      0|                ssh_set_error(session, SSH_FATAL, "String too long");
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
 1540|      0|                free(buf);
 1541|      0|                free(r);
 1542|      0|                return NULL;
 1543|      0|            }
 1544|      0|            buf[i] = *p;
 1545|      0|            i++;
 1546|      0|            if (i >= MAX_BUF_SIZE) {
  ------------------
  |  |  230|      0|#define MAX_BUF_SIZE 4096
  ------------------
  |  Branch (1546:17): [True: 0, False: 0]
  ------------------
 1547|      0|                ssh_set_error(session, SSH_FATAL, "String too long");
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
 1548|      0|                free(buf);
 1549|      0|                free(r);
 1550|      0|                return NULL;
 1551|      0|            }
 1552|      0|            buf[i] = '\0';
 1553|      0|            continue;
 1554|      0|        }
 1555|       |
 1556|  43.2k|        switch (*p) {
 1557|      0|        case '%':
  ------------------
  |  Branch (1557:9): [True: 0, False: 43.2k]
  ------------------
 1558|      0|            buf[i] = '%';
 1559|      0|            i++;
 1560|      0|            if (i >= MAX_BUF_SIZE) {
  ------------------
  |  |  230|      0|#define MAX_BUF_SIZE 4096
  ------------------
  |  Branch (1560:17): [True: 0, False: 0]
  ------------------
 1561|      0|                free(buf);
 1562|      0|                free(r);
 1563|      0|                return NULL;
 1564|      0|            }
 1565|      0|            buf[i] = '\0';
 1566|      0|            continue;
 1567|  43.2k|        case 'd':
  ------------------
  |  Branch (1567:9): [True: 43.2k, False: 0]
  ------------------
 1568|  43.2k|            x = ssh_get_user_home_dir(session);
 1569|  43.2k|            if (x == NULL) {
  ------------------
  |  Branch (1569:17): [True: 0, False: 43.2k]
  ------------------
 1570|      0|                ssh_set_error(session, SSH_FATAL, "Cannot expand homedir");
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
 1571|      0|                free(buf);
 1572|      0|                free(r);
 1573|      0|                return NULL;
 1574|      0|            }
 1575|  43.2k|            break;
 1576|  43.2k|        case 'u':
  ------------------
  |  Branch (1576:9): [True: 0, False: 43.2k]
  ------------------
 1577|      0|            x = ssh_get_local_username();
 1578|      0|            break;
 1579|      0|        case 'l':
  ------------------
  |  Branch (1579:9): [True: 0, False: 43.2k]
  ------------------
 1580|      0|            x = ssh_get_local_hostname();
 1581|      0|            break;
 1582|      0|        case 'h':
  ------------------
  |  Branch (1582:9): [True: 0, False: 43.2k]
  ------------------
 1583|      0|            if (session->opts.host) {
  ------------------
  |  Branch (1583:17): [True: 0, False: 0]
  ------------------
 1584|      0|                x = hostname_lenient ? ssh_lowercase(session->opts.host)
  ------------------
  |  Branch (1584:21): [True: 0, False: 0]
  ------------------
 1585|      0|                                     : strdup(session->opts.host);
 1586|      0|            } else if (session->opts.originalhost) {
  ------------------
  |  Branch (1586:24): [True: 0, False: 0]
  ------------------
 1587|      0|                x = hostname_lenient ? ssh_lowercase(session->opts.originalhost)
  ------------------
  |  Branch (1587:21): [True: 0, False: 0]
  ------------------
 1588|      0|                                     : strdup(session->opts.originalhost);
 1589|      0|            } else {
 1590|      0|                ssh_set_error(session, SSH_FATAL, "Cannot expand host");
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
 1591|      0|                free(buf);
 1592|      0|                free(r);
 1593|      0|                return NULL;
 1594|      0|            }
 1595|      0|            break;
 1596|      0|        case 'n':
  ------------------
  |  Branch (1596:9): [True: 0, False: 43.2k]
  ------------------
 1597|      0|            if (session->opts.originalhost) {
  ------------------
  |  Branch (1597:17): [True: 0, False: 0]
  ------------------
 1598|      0|                x = strdup(session->opts.originalhost);
 1599|      0|            } else {
 1600|      0|                ssh_set_error(session,
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
 1601|      0|                              SSH_FATAL,
 1602|      0|                              "Cannot expand original host");
 1603|      0|                free(buf);
 1604|      0|                free(r);
 1605|      0|                return NULL;
 1606|      0|            }
 1607|      0|            break;
 1608|      0|        case 'r':
  ------------------
  |  Branch (1608:9): [True: 0, False: 43.2k]
  ------------------
 1609|      0|            if (session->opts.username) {
  ------------------
  |  Branch (1609:17): [True: 0, False: 0]
  ------------------
 1610|      0|                x = strdup(session->opts.username);
 1611|      0|            } else {
 1612|      0|                ssh_set_error(session, SSH_FATAL, "Cannot expand username");
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
 1613|      0|                free(buf);
 1614|      0|                free(r);
 1615|      0|                return NULL;
 1616|      0|            }
 1617|      0|            break;
 1618|      0|        case 'p': {
  ------------------
  |  Branch (1618:9): [True: 0, False: 43.2k]
  ------------------
 1619|      0|            char tmp[6];
 1620|      0|            unsigned int port;
 1621|       |
 1622|      0|            ssh_options_get_port(session, &port);
 1623|      0|            snprintf(tmp, sizeof(tmp), "%u", port);
 1624|      0|            x = strdup(tmp);
 1625|      0|            break;
 1626|      0|        }
 1627|      0|        case 'j':
  ------------------
  |  Branch (1627:9): [True: 0, False: 43.2k]
  ------------------
 1628|      0|            if (session->opts.proxy_jumps_str != NULL) {
  ------------------
  |  Branch (1628:17): [True: 0, False: 0]
  ------------------
 1629|      0|                x = strdup(session->opts.proxy_jumps_str);
 1630|      0|            } else {
 1631|      0|                x = strdup("");
 1632|      0|            }
 1633|      0|            break;
 1634|      0|        case 'C':
  ------------------
  |  Branch (1634:9): [True: 0, False: 43.2k]
  ------------------
 1635|      0|            x = get_connection_hash(session);
 1636|      0|            break;
 1637|      0|        default:
  ------------------
  |  Branch (1637:9): [True: 0, False: 43.2k]
  ------------------
 1638|      0|            ssh_set_error(session, SSH_FATAL, "Wrong escape sequence detected");
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
 1639|      0|            free(buf);
 1640|      0|            free(r);
 1641|      0|            return NULL;
 1642|  43.2k|        }
 1643|       |
 1644|  43.2k|        if (x == NULL) {
  ------------------
  |  Branch (1644:13): [True: 0, False: 43.2k]
  ------------------
 1645|      0|            ssh_set_error_oom(session);
  ------------------
  |  |  318|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
 1646|      0|            free(buf);
 1647|      0|            free(r);
 1648|      0|            return NULL;
 1649|      0|        }
 1650|       |
 1651|  43.2k|        i += strlen(x);
 1652|  43.2k|        if (i >= MAX_BUF_SIZE) {
  ------------------
  |  |  230|  43.2k|#define MAX_BUF_SIZE 4096
  ------------------
  |  Branch (1652:13): [True: 0, False: 43.2k]
  ------------------
 1653|      0|            ssh_set_error(session, SSH_FATAL, "String too long");
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
 1654|      0|            free(buf);
 1655|      0|            free(x);
 1656|      0|            free(r);
 1657|      0|            return NULL;
 1658|      0|        }
 1659|  43.2k|        l = strlen(buf);
 1660|  43.2k|        strlcpy(buf + l, x, MAX_BUF_SIZE - l);
  ------------------
  |  |  230|  43.2k|#define MAX_BUF_SIZE 4096
  ------------------
 1661|  43.2k|        buf[i] = '\0';
 1662|  43.2k|        SAFE_FREE(x);
  ------------------
  |  |  373|  43.2k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 43.2k, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 43.2k]
  |  |  ------------------
  ------------------
 1663|  43.2k|    }
 1664|       |
 1665|  43.2k|    free(r);
 1666|       |
 1667|       |    /* strip the unused space by realloc */
 1668|  43.2k|    x = realloc(buf, strlen(buf) + 1);
 1669|  43.2k|    if (x == NULL) {
  ------------------
  |  Branch (1669:9): [True: 0, False: 43.2k]
  ------------------
 1670|      0|        ssh_set_error_oom(session);
  ------------------
  |  |  318|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
 1671|      0|        free(buf);
 1672|      0|    }
 1673|  43.2k|    return x;
 1674|  43.2k|}
misc.c:ssh_timestamp_difference:
 1875|  1.43M|{
 1876|  1.43M|    long seconds, usecs, msecs;
 1877|  1.43M|    seconds = new->seconds - old->seconds;
 1878|  1.43M|    usecs = new->useconds - old->useconds;
 1879|  1.43M|    if (usecs < 0){
  ------------------
  |  Branch (1879:9): [True: 1.71k, False: 1.43M]
  ------------------
 1880|  1.71k|        seconds--;
 1881|  1.71k|        usecs += 1000000;
 1882|  1.71k|    }
 1883|  1.43M|    msecs = seconds * 1000 + usecs/1000;
 1884|  1.43M|    return msecs;
 1885|  1.43M|}

kex_type_to_mlkem_info:
   28|  43.2k|{
   29|  43.2k|    switch (kex_type) {
   30|  43.2k|    case SSH_KEX_MLKEM768X25519_SHA256:
  ------------------
  |  Branch (30:5): [True: 43.2k, False: 0]
  ------------------
   31|  43.2k|    case SSH_KEX_MLKEM768NISTP256_SHA256:
  ------------------
  |  Branch (31:5): [True: 0, False: 43.2k]
  ------------------
   32|  43.2k|        return &MLKEM768_INFO;
   33|       |#ifdef HAVE_MLKEM1024
   34|       |    case SSH_KEX_MLKEM1024NISTP384_SHA384:
   35|       |        return &MLKEM1024_INFO;
   36|       |#endif
   37|      0|    default:
  ------------------
  |  Branch (37:5): [True: 0, False: 43.2k]
  ------------------
   38|       |        return NULL;
   39|  43.2k|    }
   40|  43.2k|}

ssh_mlkem_init:
   41|  8.64k|{
   42|  8.64k|    int ret = SSH_ERROR;
  ------------------
  |  |  317|  8.64k|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
   43|  8.64k|    struct ssh_crypto_struct *crypto = session->next_crypto;
   44|  8.64k|    const struct mlkem_type_info *mlkem_info = NULL;
   45|  8.64k|    unsigned char rnd[LIBCRUX_ML_KEM_KEY_PAIR_PRNG_LEN];
   46|  8.64k|    struct libcrux_mlkem768_keypair keypair;
   47|  8.64k|    int err;
   48|       |
   49|  8.64k|    mlkem_info = kex_type_to_mlkem_info(crypto->kex_type);
   50|  8.64k|    if (mlkem_info == NULL) {
  ------------------
  |  Branch (50:9): [True: 0, False: 8.64k]
  ------------------
   51|      0|        SSH_LOG(SSH_LOG_WARNING, "Unknown ML-KEM type");
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
   52|      0|        goto cleanup;
   53|      0|    }
   54|       |
   55|  8.64k|    err = ssh_get_random(rnd, sizeof(rnd), 0);
   56|  8.64k|    if (err != 1) {
  ------------------
  |  Branch (56:9): [True: 0, False: 8.64k]
  ------------------
   57|      0|        SSH_LOG(SSH_LOG_WARNING,
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
   58|      0|                "Failed to generate random data for ML-KEM keygen");
   59|      0|        goto cleanup;
   60|      0|    }
   61|       |
   62|  8.64k|    keypair = libcrux_ml_kem_mlkem768_portable_generate_key_pair(rnd);
   63|       |
   64|  8.64k|    if (ssh_string_len(crypto->mlkem_client_pubkey) < mlkem_info->pubkey_size) {
  ------------------
  |  Branch (64:9): [True: 8.64k, False: 0]
  ------------------
   65|  8.64k|        SSH_STRING_FREE(crypto->mlkem_client_pubkey);
  ------------------
  |  |  893|  8.64k|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (893:14): [True: 0, False: 8.64k]
  |  |  |  Branch (893:69): [Folded, False: 8.64k]
  |  |  ------------------
  ------------------
   66|  8.64k|    }
   67|  8.64k|    if (crypto->mlkem_client_pubkey == NULL) {
  ------------------
  |  Branch (67:9): [True: 8.64k, False: 0]
  ------------------
   68|  8.64k|        crypto->mlkem_client_pubkey = ssh_string_new(mlkem_info->pubkey_size);
   69|  8.64k|        if (crypto->mlkem_client_pubkey == NULL) {
  ------------------
  |  Branch (69:13): [True: 0, False: 8.64k]
  ------------------
   70|      0|            ssh_set_error_oom(session);
  ------------------
  |  |  318|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
   71|      0|            goto cleanup;
   72|      0|        }
   73|  8.64k|    }
   74|  8.64k|    err = ssh_string_fill(crypto->mlkem_client_pubkey,
   75|  8.64k|                          keypair.pk.value,
   76|  8.64k|                          mlkem_info->pubkey_size);
   77|  8.64k|    if (err) {
  ------------------
  |  Branch (77:9): [True: 0, False: 8.64k]
  ------------------
   78|      0|        SSH_LOG(SSH_LOG_WARNING,
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
   79|      0|                "Failed to fill the string with client pubkey");
   80|      0|        goto cleanup;
   81|      0|    }
   82|       |
   83|  8.64k|    if (crypto->mlkem_privkey == NULL) {
  ------------------
  |  Branch (83:9): [True: 8.64k, False: 0]
  ------------------
   84|  8.64k|        crypto->mlkem_privkey = malloc(mlkem_info->privkey_size);
   85|  8.64k|        if (crypto->mlkem_privkey == NULL) {
  ------------------
  |  Branch (85:13): [True: 0, False: 8.64k]
  ------------------
   86|      0|            ssh_set_error_oom(session);
  ------------------
  |  |  318|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
   87|      0|            goto cleanup;
   88|      0|        }
   89|  8.64k|    }
   90|  8.64k|    memcpy(crypto->mlkem_privkey, keypair.sk.value, mlkem_info->privkey_size);
   91|  8.64k|    crypto->mlkem_privkey_len = mlkem_info->privkey_size;
   92|       |
   93|  8.64k|    ret = SSH_OK;
  ------------------
  |  |  316|  8.64k|#define SSH_OK 0     /* No error */
  ------------------
   94|       |
   95|  8.64k|cleanup:
   96|  8.64k|    ssh_burn(&keypair, sizeof(keypair));
  ------------------
  |  |  388|  8.64k|#define ssh_burn(ptr, len) explicit_bzero((ptr), (len))
  ------------------
   97|  8.64k|    ssh_burn(rnd, sizeof(rnd));
  ------------------
  |  |  388|  8.64k|#define ssh_burn(ptr, len) explicit_bzero((ptr), (len))
  ------------------
   98|  8.64k|    return ret;
   99|  8.64k|}
ssh_mlkem_encapsulate:
  103|  8.64k|{
  104|  8.64k|    int ret = SSH_ERROR;
  ------------------
  |  |  317|  8.64k|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  105|  8.64k|    const struct mlkem_type_info *mlkem_info = NULL;
  106|  8.64k|    struct ssh_crypto_struct *crypto = session->next_crypto;
  107|  8.64k|    const unsigned char *pubkey_data = NULL;
  108|  8.64k|    ssh_string pubkey = crypto->mlkem_client_pubkey;
  109|  8.64k|    struct libcrux_mlkem768_enc_result enc;
  110|  8.64k|    struct libcrux_mlkem768_pk mlkem_pub = {0};
  111|  8.64k|    unsigned char rnd[LIBCRUX_ML_KEM_ENC_PRNG_LEN];
  112|  8.64k|    int err;
  113|       |
  114|  8.64k|    if (pubkey == NULL) {
  ------------------
  |  Branch (114:9): [True: 0, False: 8.64k]
  ------------------
  115|      0|        SSH_LOG(SSH_LOG_WARNING, "Missing pubkey in session");
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  116|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  117|      0|    }
  118|       |
  119|  8.64k|    mlkem_info = kex_type_to_mlkem_info(crypto->kex_type);
  120|  8.64k|    if (mlkem_info == NULL) {
  ------------------
  |  Branch (120:9): [True: 0, False: 8.64k]
  ------------------
  121|      0|        SSH_LOG(SSH_LOG_WARNING, "Unknown ML-KEM type");
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  122|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  123|      0|    }
  124|       |
  125|  8.64k|    pubkey_data = ssh_string_data(pubkey);
  126|  8.64k|    memcpy(mlkem_pub.value, pubkey_data, mlkem_info->pubkey_size);
  127|  8.64k|    err = libcrux_ml_kem_mlkem768_portable_validate_public_key(&mlkem_pub);
  128|  8.64k|    if (err == 0) {
  ------------------
  |  Branch (128:9): [True: 0, False: 8.64k]
  ------------------
  129|      0|        SSH_LOG(SSH_LOG_WARNING, "Invalid public key");
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  130|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  131|      0|    }
  132|       |
  133|  8.64k|    err = ssh_get_random(rnd, sizeof(rnd), 0);
  134|  8.64k|    if (err != 1) {
  ------------------
  |  Branch (134:9): [True: 0, False: 8.64k]
  ------------------
  135|      0|        SSH_LOG(SSH_LOG_WARNING,
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  136|      0|                "Failed to generate random data for ML-KEM keygen");
  137|      0|        goto cleanup;
  138|      0|    }
  139|       |
  140|  8.64k|    enc = libcrux_ml_kem_mlkem768_portable_encapsulate(&mlkem_pub, rnd);
  141|       |
  142|  8.64k|    if (ssh_string_len(crypto->mlkem_ciphertext) < mlkem_info->ciphertext_size) {
  ------------------
  |  Branch (142:9): [True: 8.64k, False: 0]
  ------------------
  143|  8.64k|        SSH_STRING_FREE(crypto->mlkem_ciphertext);
  ------------------
  |  |  893|  8.64k|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (893:14): [True: 0, False: 8.64k]
  |  |  |  Branch (893:69): [Folded, False: 8.64k]
  |  |  ------------------
  ------------------
  144|  8.64k|    }
  145|  8.64k|    if (crypto->mlkem_ciphertext == NULL) {
  ------------------
  |  Branch (145:9): [True: 8.64k, False: 0]
  ------------------
  146|  8.64k|        crypto->mlkem_ciphertext = ssh_string_new(mlkem_info->ciphertext_size);
  147|  8.64k|        if (crypto->mlkem_ciphertext == NULL) {
  ------------------
  |  Branch (147:13): [True: 0, False: 8.64k]
  ------------------
  148|      0|            ssh_set_error_oom(session);
  ------------------
  |  |  318|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
  149|      0|            goto cleanup;
  150|      0|        }
  151|  8.64k|    }
  152|  8.64k|    err = ssh_string_fill(crypto->mlkem_ciphertext,
  153|  8.64k|                          enc.fst.value,
  154|  8.64k|                          sizeof(enc.fst.value));
  155|  8.64k|    if (err != SSH_OK) {
  ------------------
  |  |  316|  8.64k|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (155:9): [True: 0, False: 8.64k]
  ------------------
  156|      0|        SSH_LOG(SSH_LOG_WARNING, "Failed to fill the string with ciphertext");
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  157|      0|        goto cleanup;
  158|      0|    }
  159|  8.64k|    memcpy(shared_secret, enc.snd, sizeof(enc.snd));
  160|       |
  161|  8.64k|    ret = SSH_OK;
  ------------------
  |  |  316|  8.64k|#define SSH_OK 0     /* No error */
  ------------------
  162|       |
  163|  8.64k|cleanup:
  164|  8.64k|    ssh_burn(rnd, sizeof(rnd));
  ------------------
  |  |  388|  8.64k|#define ssh_burn(ptr, len) explicit_bzero((ptr), (len))
  ------------------
  165|  8.64k|    ssh_burn(&enc, sizeof(enc));
  ------------------
  |  |  388|  8.64k|#define ssh_burn(ptr, len) explicit_bzero((ptr), (len))
  ------------------
  166|  8.64k|    return ret;
  167|  8.64k|}
ssh_mlkem_decapsulate:
  171|  8.64k|{
  172|  8.64k|    const struct mlkem_type_info *mlkem_info = NULL;
  173|  8.64k|    struct ssh_crypto_struct *crypto = session->next_crypto;
  174|  8.64k|    ssh_string ciphertext = NULL;
  175|  8.64k|    unsigned char *ciphertext_data = NULL;
  176|  8.64k|    struct libcrux_mlkem768_sk mlkem_priv = {0};
  177|  8.64k|    struct libcrux_mlkem768_ciphertext mlkem_ciphertext = {0};
  178|       |
  179|  8.64k|    mlkem_info = kex_type_to_mlkem_info(crypto->kex_type);
  180|  8.64k|    if (mlkem_info == NULL) {
  ------------------
  |  Branch (180:9): [True: 0, False: 8.64k]
  ------------------
  181|      0|        SSH_LOG(SSH_LOG_WARNING, "Unknown ML-KEM type");
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  182|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  183|      0|    }
  184|       |
  185|  8.64k|    ciphertext = crypto->mlkem_ciphertext;
  186|  8.64k|    if (ciphertext == NULL) {
  ------------------
  |  Branch (186:9): [True: 0, False: 8.64k]
  ------------------
  187|      0|        SSH_LOG(SSH_LOG_WARNING, "Missing ciphertext in session");
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  188|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  189|      0|    }
  190|       |
  191|  8.64k|    ciphertext_data = ssh_string_data(ciphertext);
  192|  8.64k|    memcpy(mlkem_ciphertext.value,
  193|  8.64k|           ciphertext_data,
  194|  8.64k|           sizeof(mlkem_ciphertext.value));
  195|       |
  196|  8.64k|    memcpy(mlkem_priv.value, crypto->mlkem_privkey, crypto->mlkem_privkey_len);
  197|       |
  198|  8.64k|    libcrux_ml_kem_mlkem768_portable_decapsulate(&mlkem_priv,
  199|  8.64k|                                                 &mlkem_ciphertext,
  200|  8.64k|                                                 shared_secret);
  201|  8.64k|    return SSH_OK;
  ------------------
  |  |  316|  8.64k|#define SSH_OK 0     /* No error */
  ------------------
  202|  8.64k|}

ssh_options_set_algo:
  327|  77.7k|{
  328|       |    /* When the list start with +,-,^ the filtration of unknown algorithms
  329|       |     * gets handled inside the helper functions, otherwise the list is taken
  330|       |     * as it is. */
  331|  77.7k|    char *p = (char *)list;
  332|       |
  333|  77.7k|    if (algo < SSH_COMP_C_S) {
  ------------------
  |  Branch (333:9): [True: 77.7k, False: 0]
  ------------------
  334|  77.7k|        if (list[0] == '+') {
  ------------------
  |  Branch (334:13): [True: 0, False: 77.7k]
  ------------------
  335|      0|            p = ssh_add_to_default_algos(algo, list+1);
  336|  77.7k|        } else if (list[0] == '-') {
  ------------------
  |  Branch (336:20): [True: 0, False: 77.7k]
  ------------------
  337|      0|            p = ssh_remove_from_default_algos(algo, list+1);
  338|  77.7k|        } else if (list[0] == '^') {
  ------------------
  |  Branch (338:20): [True: 0, False: 77.7k]
  ------------------
  339|      0|            p = ssh_prefix_default_algos(algo, list+1);
  340|      0|        }
  341|  77.7k|    }
  342|       |
  343|  77.7k|    if (p == list) {
  ------------------
  |  Branch (343:9): [True: 77.7k, False: 0]
  ------------------
  344|  77.7k|        if (ssh_fips_mode()) {
  ------------------
  |  |  115|  77.7k|#define ssh_fips_mode() (FIPS_mode() != 0)
  |  |  ------------------
  |  |  |  Branch (115:25): [True: 0, False: 77.7k]
  |  |  ------------------
  ------------------
  345|      0|            p = ssh_keep_fips_algos(algo, list);
  346|  77.7k|        } else {
  347|  77.7k|            p = ssh_keep_known_algos(algo, list);
  348|  77.7k|        }
  349|  77.7k|    }
  350|       |
  351|  77.7k|    if (p == NULL) {
  ------------------
  |  Branch (351:9): [True: 0, False: 77.7k]
  ------------------
  352|      0|        ssh_set_error(session, SSH_REQUEST_DENIED,
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  353|      0|                "Setting method: no allowed algorithm for method \"%s\" (%s)",
  354|      0|                ssh_kex_get_description(algo), list);
  355|      0|        return -1;
  356|      0|    }
  357|       |
  358|  77.7k|    SAFE_FREE(*place);
  ------------------
  |  |  373|  77.7k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 77.7k]
  |  |  |  Branch (373:71): [Folded, False: 77.7k]
  |  |  ------------------
  ------------------
  359|  77.7k|    *place = p;
  360|       |
  361|  77.7k|    return 0;
  362|  77.7k|}
ssh_options_set:
  755|  77.7k|{
  756|  77.7k|    const char *v = NULL;
  757|  77.7k|    char *p = NULL, *q = NULL;
  758|  77.7k|    long int i;
  759|  77.7k|    unsigned int u;
  760|  77.7k|    int rc;
  761|  77.7k|    char **wanted_methods = session->opts.wanted_methods;
  762|  77.7k|    struct ssh_jump_callbacks_struct *j = NULL;
  763|       |
  764|  77.7k|    if (session == NULL) {
  ------------------
  |  Branch (764:9): [True: 0, False: 77.7k]
  ------------------
  765|      0|        return -1;
  766|      0|    }
  767|       |
  768|  77.7k|    switch (type) {
  769|  8.64k|        case SSH_OPTIONS_HOST:
  ------------------
  |  Branch (769:9): [True: 8.64k, False: 69.1k]
  ------------------
  770|  8.64k|            v = value;
  771|  8.64k|            if (v == NULL || v[0] == '\0') {
  ------------------
  |  Branch (771:17): [True: 0, False: 8.64k]
  |  Branch (771:30): [True: 0, False: 8.64k]
  ------------------
  772|      0|                ssh_set_error_invalid(session);
  ------------------
  |  |  322|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
  773|      0|                return -1;
  774|  8.64k|            } else {
  775|  8.64k|                char *username = NULL, *hostname = NULL;
  776|  8.64k|                char *strict_hostname = NULL;
  777|  8.64k|                char *normalized = NULL;
  778|       |
  779|       |                /* Non-strict parse: reject shell metacharacters */
  780|  8.64k|                rc = ssh_config_parse_uri(value,
  781|  8.64k|                                          &username,
  782|  8.64k|                                          &hostname,
  783|  8.64k|                                          NULL,
  784|  8.64k|                                          true,
  785|  8.64k|                                          false);
  786|  8.64k|                if (rc != SSH_OK || hostname == NULL) {
  ------------------
  |  |  316|  17.2k|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (786:21): [True: 0, False: 8.64k]
  |  Branch (786:37): [True: 0, False: 8.64k]
  ------------------
  787|      0|                    SAFE_FREE(username);
  ------------------
  |  |  373|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
  788|      0|                    SAFE_FREE(hostname);
  ------------------
  |  |  373|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
  789|      0|                    ssh_set_error_invalid(session);
  ------------------
  |  |  322|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
  790|      0|                    return -1;
  791|      0|                }
  792|       |
  793|       |                /* Non-strict passed: set username and originalhost */
  794|  8.64k|                if (username != NULL) {
  ------------------
  |  Branch (794:21): [True: 0, False: 8.64k]
  ------------------
  795|      0|                    SAFE_FREE(session->opts.username);
  ------------------
  |  |  373|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
  796|      0|                    session->opts.username = username;
  797|      0|                }
  798|  8.64k|                if (!session->opts.config_hostname_only) {
  ------------------
  |  Branch (798:21): [True: 8.64k, False: 0]
  ------------------
  799|  8.64k|                    SAFE_FREE(session->opts.config_hostname);
  ------------------
  |  |  373|  8.64k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 8.64k]
  |  |  |  Branch (373:71): [Folded, False: 8.64k]
  |  |  ------------------
  ------------------
  800|  8.64k|                    SAFE_FREE(session->opts.originalhost);
  ------------------
  |  |  373|  8.64k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 8.64k]
  |  |  |  Branch (373:71): [Folded, False: 8.64k]
  |  |  ------------------
  ------------------
  801|  8.64k|                    session->opts.originalhost = hostname;
  802|  8.64k|                } else {
  803|      0|                    SAFE_FREE(hostname);
  ------------------
  |  |  373|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
  804|      0|                }
  805|       |
  806|       |                /* Strict parse: set host only if valid hostname or IP */
  807|  8.64k|                rc = ssh_normalize_loose_ip(value, &normalized);
  808|  8.64k|                if (rc == -1) {
  ------------------
  |  Branch (808:21): [True: 0, False: 8.64k]
  ------------------
  809|       |                    /* Error */
  810|      0|                    SAFE_FREE(username);
  ------------------
  |  |  373|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
  811|      0|                    ssh_set_error_oom(session);
  ------------------
  |  |  318|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
  812|      0|                    return -1;
  813|      0|                }
  814|  8.64k|                rc = ssh_config_parse_uri(
  815|  8.64k|                    (normalized != NULL) ? normalized : value,
  ------------------
  |  Branch (815:21): [True: 0, False: 8.64k]
  ------------------
  816|  8.64k|                    NULL,
  817|  8.64k|                    &strict_hostname,
  818|  8.64k|                    NULL,
  819|  8.64k|                    true,
  820|  8.64k|                    true);
  821|  8.64k|                SAFE_FREE(normalized);
  ------------------
  |  |  373|  8.64k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 8.64k]
  |  |  |  Branch (373:71): [Folded, False: 8.64k]
  |  |  ------------------
  ------------------
  822|       |
  823|  8.64k|                if (rc != SSH_OK || strict_hostname == NULL) {
  ------------------
  |  |  316|  17.2k|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (823:21): [True: 0, False: 8.64k]
  |  Branch (823:37): [True: 0, False: 8.64k]
  ------------------
  824|      0|                    SAFE_FREE(session->opts.host);
  ------------------
  |  |  373|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
  825|      0|                    SAFE_FREE(strict_hostname);
  ------------------
  |  |  373|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
  826|      0|                    if (session->opts.config_hostname_only) {
  ------------------
  |  Branch (826:25): [True: 0, False: 0]
  ------------------
  827|       |                        /* Config path: Hostname must be valid */
  828|      0|                        ssh_set_error_invalid(session);
  ------------------
  |  |  322|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
  829|      0|                        return -1;
  830|      0|                    }
  831|  8.64k|                } else {
  832|  8.64k|                    SAFE_FREE(session->opts.host);
  ------------------
  |  |  373|  8.64k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 8.64k]
  |  |  |  Branch (373:71): [Folded, False: 8.64k]
  |  |  ------------------
  ------------------
  833|  8.64k|                    session->opts.host = strict_hostname;
  834|  8.64k|                }
  835|  8.64k|            }
  836|  8.64k|            break;
  837|  8.64k|        case SSH_OPTIONS_PORT:
  ------------------
  |  Branch (837:9): [True: 0, False: 77.7k]
  ------------------
  838|      0|            if (value == NULL) {
  ------------------
  |  Branch (838:17): [True: 0, False: 0]
  ------------------
  839|      0|                ssh_set_error_invalid(session);
  ------------------
  |  |  322|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
  840|      0|                return -1;
  841|      0|            } else {
  842|      0|                int *x = (int *) value;
  843|      0|                if (*x <= 0 || *x > 65535) {
  ------------------
  |  Branch (843:21): [True: 0, False: 0]
  |  Branch (843:32): [True: 0, False: 0]
  ------------------
  844|      0|                    ssh_set_error_invalid(session);
  ------------------
  |  |  322|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
  845|      0|                    return -1;
  846|      0|                }
  847|       |
  848|      0|                session->opts.port = *x;
  849|      0|            }
  850|      0|            break;
  851|      0|        case SSH_OPTIONS_PORT_STR:
  ------------------
  |  Branch (851:9): [True: 0, False: 77.7k]
  ------------------
  852|      0|            v = value;
  853|      0|            if (v == NULL || v[0] == '\0') {
  ------------------
  |  Branch (853:17): [True: 0, False: 0]
  |  Branch (853:30): [True: 0, False: 0]
  ------------------
  854|      0|                ssh_set_error_invalid(session);
  ------------------
  |  |  322|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
  855|      0|                return -1;
  856|      0|            } else {
  857|      0|                q = strdup(v);
  858|      0|                if (q == NULL) {
  ------------------
  |  Branch (858:21): [True: 0, False: 0]
  ------------------
  859|      0|                    ssh_set_error_oom(session);
  ------------------
  |  |  318|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
  860|      0|                    return -1;
  861|      0|                }
  862|      0|                i = strtol(q, &p, 10);
  863|      0|                if (q == p || *p != '\0') {
  ------------------
  |  Branch (863:21): [True: 0, False: 0]
  |  Branch (863:31): [True: 0, False: 0]
  ------------------
  864|      0|                    SSH_LOG(SSH_LOG_DEBUG, "No port number was parsed");
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  865|      0|                    SAFE_FREE(q);
  ------------------
  |  |  373|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
  866|      0|                    return -1;
  867|      0|                }
  868|      0|                SAFE_FREE(q);
  ------------------
  |  |  373|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
  869|      0|                if (i <= 0 || i > 65535) {
  ------------------
  |  Branch (869:21): [True: 0, False: 0]
  |  Branch (869:31): [True: 0, False: 0]
  ------------------
  870|      0|                    ssh_set_error_invalid(session);
  ------------------
  |  |  322|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
  871|      0|                    return -1;
  872|      0|                }
  873|       |
  874|      0|                session->opts.port = i;
  875|      0|            }
  876|      0|            break;
  877|  8.64k|        case SSH_OPTIONS_FD:
  ------------------
  |  Branch (877:9): [True: 8.64k, False: 69.1k]
  ------------------
  878|  8.64k|            if (value == NULL) {
  ------------------
  |  Branch (878:17): [True: 0, False: 8.64k]
  ------------------
  879|      0|                session->opts.fd = SSH_INVALID_SOCKET;
  ------------------
  |  |  124|      0|#define SSH_INVALID_SOCKET ((socket_t) -1)
  ------------------
  880|      0|                ssh_set_error_invalid(session);
  ------------------
  |  |  322|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
  881|      0|                return -1;
  882|  8.64k|            } else {
  883|  8.64k|                socket_t *x = (socket_t *) value;
  884|  8.64k|                if (*x < 0) {
  ------------------
  |  Branch (884:21): [True: 0, False: 8.64k]
  ------------------
  885|      0|                    session->opts.fd = SSH_INVALID_SOCKET;
  ------------------
  |  |  124|      0|#define SSH_INVALID_SOCKET ((socket_t) -1)
  ------------------
  886|      0|                    ssh_set_error_invalid(session);
  ------------------
  |  |  322|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
  887|      0|                    return -1;
  888|      0|                }
  889|       |
  890|  8.64k|                session->opts.fd = *x & 0xffff;
  891|  8.64k|            }
  892|  8.64k|            break;
  893|  8.64k|        case SSH_OPTIONS_BINDADDR:
  ------------------
  |  Branch (893:9): [True: 0, False: 77.7k]
  ------------------
  894|      0|            v = value;
  895|      0|            if (v == NULL || v[0] == '\0') {
  ------------------
  |  Branch (895:17): [True: 0, False: 0]
  |  Branch (895:30): [True: 0, False: 0]
  ------------------
  896|      0|                ssh_set_error_invalid(session);
  ------------------
  |  |  322|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
  897|      0|                return -1;
  898|      0|            }
  899|       |
  900|      0|            q = strdup(v);
  901|      0|            if (q == NULL) {
  ------------------
  |  Branch (901:17): [True: 0, False: 0]
  ------------------
  902|      0|                return -1;
  903|      0|            }
  904|      0|            SAFE_FREE(session->opts.bindaddr);
  ------------------
  |  |  373|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
  905|      0|            session->opts.bindaddr = q;
  906|      0|            break;
  907|  8.64k|        case SSH_OPTIONS_USER:
  ------------------
  |  Branch (907:9): [True: 8.64k, False: 69.1k]
  ------------------
  908|  8.64k|            v = value;
  909|  8.64k|            SAFE_FREE(session->opts.username);
  ------------------
  |  |  373|  8.64k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 8.64k]
  |  |  |  Branch (373:71): [Folded, False: 8.64k]
  |  |  ------------------
  ------------------
  910|  8.64k|            if (v == NULL) {
  ------------------
  |  Branch (910:17): [True: 0, False: 8.64k]
  ------------------
  911|      0|                q = ssh_get_local_username();
  912|      0|                if (q == NULL) {
  ------------------
  |  Branch (912:21): [True: 0, False: 0]
  ------------------
  913|      0|                    ssh_set_error_oom(session);
  ------------------
  |  |  318|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
  914|      0|                    return -1;
  915|      0|                }
  916|      0|                session->opts.username = q;
  917|  8.64k|            } else if (v[0] == '\0') {
  ------------------
  |  Branch (917:24): [True: 0, False: 8.64k]
  ------------------
  918|      0|                ssh_set_error_invalid(session);
  ------------------
  |  |  322|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
  919|      0|                return -1;
  920|  8.64k|            } else { /* username provided */
  921|  8.64k|                session->opts.username = strdup(value);
  922|  8.64k|                if (session->opts.username == NULL) {
  ------------------
  |  Branch (922:21): [True: 0, False: 8.64k]
  ------------------
  923|      0|                    ssh_set_error_oom(session);
  ------------------
  |  |  318|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
  924|      0|                    return -1;
  925|      0|                }
  926|  8.64k|                rc = ssh_check_username_syntax(session->opts.username);
  927|  8.64k|                if (rc != SSH_OK) {
  ------------------
  |  |  316|  8.64k|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (927:21): [True: 0, False: 8.64k]
  ------------------
  928|      0|                    ssh_set_error_invalid(session);
  ------------------
  |  |  322|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
  929|      0|                    return -1;
  930|      0|                }
  931|  8.64k|            }
  932|  8.64k|            break;
  933|  8.64k|        case SSH_OPTIONS_SSH_DIR:
  ------------------
  |  Branch (933:9): [True: 8.64k, False: 69.1k]
  ------------------
  934|  8.64k|            v = value;
  935|  8.64k|            SAFE_FREE(session->opts.sshdir);
  ------------------
  |  |  373|  8.64k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 8.64k]
  |  |  |  Branch (373:71): [Folded, False: 8.64k]
  |  |  ------------------
  ------------------
  936|  8.64k|            if (v == NULL) {
  ------------------
  |  Branch (936:17): [True: 8.64k, False: 0]
  ------------------
  937|  8.64k|                session->opts.sshdir = ssh_path_expand_tilde("~/.ssh");
  938|  8.64k|                if (session->opts.sshdir == NULL) {
  ------------------
  |  Branch (938:21): [True: 0, False: 8.64k]
  ------------------
  939|      0|                    return -1;
  940|      0|                }
  941|  8.64k|            } else if (v[0] == '\0') {
  ------------------
  |  Branch (941:24): [True: 0, False: 0]
  ------------------
  942|      0|                ssh_set_error_invalid(session);
  ------------------
  |  |  322|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
  943|      0|                return -1;
  944|      0|            } else {
  945|      0|                session->opts.sshdir = ssh_path_expand_tilde(v);
  946|      0|                if (session->opts.sshdir == NULL) {
  ------------------
  |  Branch (946:21): [True: 0, False: 0]
  ------------------
  947|      0|                    ssh_set_error_oom(session);
  ------------------
  |  |  318|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
  948|      0|                    return -1;
  949|      0|                }
  950|      0|            }
  951|  8.64k|            break;
  952|  8.64k|        case SSH_OPTIONS_IDENTITY:
  ------------------
  |  Branch (952:9): [True: 0, False: 77.7k]
  ------------------
  953|      0|        case SSH_OPTIONS_ADD_IDENTITY:
  ------------------
  |  Branch (953:9): [True: 0, False: 77.7k]
  ------------------
  954|      0|            v = value;
  955|      0|            if (v == NULL || v[0] == '\0') {
  ------------------
  |  Branch (955:17): [True: 0, False: 0]
  |  Branch (955:30): [True: 0, False: 0]
  ------------------
  956|      0|                ssh_set_error_invalid(session);
  ------------------
  |  |  322|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
  957|      0|                return -1;
  958|      0|            }
  959|      0|            q = strdup(v);
  960|      0|            if (q == NULL) {
  ------------------
  |  Branch (960:17): [True: 0, False: 0]
  ------------------
  961|      0|                return -1;
  962|      0|            }
  963|      0|            if (session->opts.exp_flags & SSH_OPT_EXP_FLAG_IDENTITY) {
  ------------------
  |  |  118|      0|#define SSH_OPT_EXP_FLAG_IDENTITY 0x8
  ------------------
  |  Branch (963:17): [True: 0, False: 0]
  ------------------
  964|      0|                rc = ssh_list_append(session->opts.identity_non_exp, q);
  965|      0|            } else {
  966|      0|                rc = ssh_list_prepend(session->opts.identity_non_exp, q);
  967|      0|            }
  968|      0|            if (rc < 0) {
  ------------------
  |  Branch (968:17): [True: 0, False: 0]
  ------------------
  969|      0|                free(q);
  970|      0|                return -1;
  971|      0|            }
  972|      0|            break;
  973|      0|        case SSH_OPTIONS_CERTIFICATE:
  ------------------
  |  Branch (973:9): [True: 0, False: 77.7k]
  ------------------
  974|      0|            v = value;
  975|      0|            if (v == NULL || v[0] == '\0') {
  ------------------
  |  Branch (975:17): [True: 0, False: 0]
  |  Branch (975:30): [True: 0, False: 0]
  ------------------
  976|      0|                ssh_set_error_invalid(session);
  ------------------
  |  |  322|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
  977|      0|                return -1;
  978|      0|            }
  979|      0|            q = strdup(v);
  980|      0|            if (q == NULL) {
  ------------------
  |  Branch (980:17): [True: 0, False: 0]
  ------------------
  981|      0|                return -1;
  982|      0|            }
  983|      0|            rc = ssh_list_append(session->opts.certificate_non_exp, q);
  984|      0|            if (rc < 0) {
  ------------------
  |  Branch (984:17): [True: 0, False: 0]
  ------------------
  985|      0|                free(q);
  986|      0|                return -1;
  987|      0|            }
  988|      0|            break;
  989|      0|        case SSH_OPTIONS_KNOWNHOSTS:
  ------------------
  |  Branch (989:9): [True: 0, False: 77.7k]
  ------------------
  990|      0|            v = value;
  991|      0|            SAFE_FREE(session->opts.knownhosts);
  ------------------
  |  |  373|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
  992|      0|            if (v == NULL) {
  ------------------
  |  Branch (992:17): [True: 0, False: 0]
  ------------------
  993|       |                /* The default value will be set by the ssh_options_apply() */
  994|      0|            } else if (v[0] == '\0') {
  ------------------
  |  Branch (994:24): [True: 0, False: 0]
  ------------------
  995|      0|                ssh_set_error_invalid(session);
  ------------------
  |  |  322|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
  996|      0|                return -1;
  997|      0|            } else {
  998|      0|                session->opts.knownhosts = strdup(v);
  999|      0|                if (session->opts.knownhosts == NULL) {
  ------------------
  |  Branch (999:21): [True: 0, False: 0]
  ------------------
 1000|      0|                    ssh_set_error_oom(session);
  ------------------
  |  |  318|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
 1001|      0|                    return -1;
 1002|      0|                }
 1003|      0|                session->opts.exp_flags &= ~SSH_OPT_EXP_FLAG_KNOWNHOSTS;
  ------------------
  |  |  115|      0|#define SSH_OPT_EXP_FLAG_KNOWNHOSTS 0x1
  ------------------
 1004|      0|            }
 1005|      0|            break;
 1006|      0|        case SSH_OPTIONS_GLOBAL_KNOWNHOSTS:
  ------------------
  |  Branch (1006:9): [True: 0, False: 77.7k]
  ------------------
 1007|      0|            v = value;
 1008|      0|            SAFE_FREE(session->opts.global_knownhosts);
  ------------------
  |  |  373|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1009|      0|            if (v == NULL) {
  ------------------
  |  Branch (1009:17): [True: 0, False: 0]
  ------------------
 1010|      0|                session->opts.global_knownhosts =
 1011|      0|                    strdup(GLOBAL_CONF_DIR "/ssh_known_hosts");
  ------------------
  |  |   13|      0|#define GLOBAL_CONF_DIR "/etc/ssh"
  ------------------
 1012|      0|                if (session->opts.global_knownhosts == NULL) {
  ------------------
  |  Branch (1012:21): [True: 0, False: 0]
  ------------------
 1013|      0|                    ssh_set_error_oom(session);
  ------------------
  |  |  318|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
 1014|      0|                    return -1;
 1015|      0|                }
 1016|      0|            } else if (v[0] == '\0') {
  ------------------
  |  Branch (1016:24): [True: 0, False: 0]
  ------------------
 1017|      0|                ssh_set_error_invalid(session);
  ------------------
  |  |  322|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 1018|      0|                return -1;
 1019|      0|            } else {
 1020|      0|                session->opts.global_knownhosts = strdup(v);
 1021|      0|                if (session->opts.global_knownhosts == NULL) {
  ------------------
  |  Branch (1021:21): [True: 0, False: 0]
  ------------------
 1022|      0|                    ssh_set_error_oom(session);
  ------------------
  |  |  318|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
 1023|      0|                    return -1;
 1024|      0|                }
 1025|      0|                session->opts.exp_flags &= ~SSH_OPT_EXP_FLAG_GLOBAL_KNOWNHOSTS;
  ------------------
  |  |  116|      0|#define SSH_OPT_EXP_FLAG_GLOBAL_KNOWNHOSTS 0x2
  ------------------
 1026|      0|            }
 1027|      0|            break;
 1028|  8.64k|        case SSH_OPTIONS_TIMEOUT:
  ------------------
  |  Branch (1028:9): [True: 8.64k, False: 69.1k]
  ------------------
 1029|  8.64k|            if (value == NULL) {
  ------------------
  |  Branch (1029:17): [True: 0, False: 8.64k]
  ------------------
 1030|      0|                ssh_set_error_invalid(session);
  ------------------
  |  |  322|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 1031|      0|                return -1;
 1032|  8.64k|            } else {
 1033|  8.64k|                long *x = (long *) value;
 1034|  8.64k|                if (*x < 0) {
  ------------------
  |  Branch (1034:21): [True: 0, False: 8.64k]
  ------------------
 1035|      0|                    ssh_set_error_invalid(session);
  ------------------
  |  |  322|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 1036|      0|                    return -1;
 1037|      0|                }
 1038|       |
 1039|  8.64k|                session->opts.timeout = *x & 0xffffffffU;
 1040|  8.64k|            }
 1041|  8.64k|            break;
 1042|  8.64k|        case SSH_OPTIONS_TIMEOUT_USEC:
  ------------------
  |  Branch (1042:9): [True: 0, False: 77.7k]
  ------------------
 1043|      0|            if (value == NULL) {
  ------------------
  |  Branch (1043:17): [True: 0, False: 0]
  ------------------
 1044|      0|                ssh_set_error_invalid(session);
  ------------------
  |  |  322|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 1045|      0|                return -1;
 1046|      0|            } else {
 1047|      0|                long *x = (long *) value;
 1048|      0|                if (*x < 0) {
  ------------------
  |  Branch (1048:21): [True: 0, False: 0]
  ------------------
 1049|      0|                    ssh_set_error_invalid(session);
  ------------------
  |  |  322|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 1050|      0|                    return -1;
 1051|      0|                }
 1052|       |
 1053|      0|                session->opts.timeout_usec = *x & 0xffffffffU;
 1054|      0|            }
 1055|      0|            break;
 1056|      0|        case SSH_OPTIONS_SSH1:
  ------------------
  |  Branch (1056:9): [True: 0, False: 77.7k]
  ------------------
 1057|      0|            break;
 1058|      0|        case SSH_OPTIONS_SSH2:
  ------------------
  |  Branch (1058:9): [True: 0, False: 77.7k]
  ------------------
 1059|      0|            break;
 1060|      0|        case SSH_OPTIONS_LOG_VERBOSITY:
  ------------------
  |  Branch (1060:9): [True: 0, False: 77.7k]
  ------------------
 1061|      0|            if (value == NULL) {
  ------------------
  |  Branch (1061:17): [True: 0, False: 0]
  ------------------
 1062|      0|                ssh_set_error_invalid(session);
  ------------------
  |  |  322|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 1063|      0|                return -1;
 1064|      0|            } else {
 1065|      0|                int *x = (int *) value;
 1066|      0|                if (*x < 0) {
  ------------------
  |  Branch (1066:21): [True: 0, False: 0]
  ------------------
 1067|      0|                    ssh_set_error_invalid(session);
  ------------------
  |  |  322|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 1068|      0|                    return -1;
 1069|      0|                }
 1070|       |
 1071|      0|                session->common.log_verbosity = *x & 0xffffU;
 1072|      0|                ssh_set_log_level(*x & 0xffffU);
 1073|      0|            }
 1074|      0|            break;
 1075|      0|        case SSH_OPTIONS_LOG_VERBOSITY_STR:
  ------------------
  |  Branch (1075:9): [True: 0, False: 77.7k]
  ------------------
 1076|      0|            v = value;
 1077|      0|            if (v == NULL || v[0] == '\0') {
  ------------------
  |  Branch (1077:17): [True: 0, False: 0]
  |  Branch (1077:30): [True: 0, False: 0]
  ------------------
 1078|      0|                session->common.log_verbosity = 0;
 1079|      0|                ssh_set_error_invalid(session);
  ------------------
  |  |  322|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 1080|      0|                return -1;
 1081|      0|            } else {
 1082|      0|                q = strdup(v);
 1083|      0|                if (q == NULL) {
  ------------------
  |  Branch (1083:21): [True: 0, False: 0]
  ------------------
 1084|      0|                    ssh_set_error_oom(session);
  ------------------
  |  |  318|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
 1085|      0|                    return -1;
 1086|      0|                }
 1087|      0|                i = strtol(q, &p, 10);
 1088|      0|                if (q == p) {
  ------------------
  |  Branch (1088:21): [True: 0, False: 0]
  ------------------
 1089|      0|                    SSH_LOG(SSH_LOG_DEBUG, "No log verbositiy was parsed");
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 1090|      0|                    SAFE_FREE(q);
  ------------------
  |  |  373|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1091|      0|                    return -1;
 1092|      0|                }
 1093|      0|                SAFE_FREE(q);
  ------------------
  |  |  373|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1094|      0|                if (i < 0) {
  ------------------
  |  Branch (1094:21): [True: 0, False: 0]
  ------------------
 1095|      0|                    ssh_set_error_invalid(session);
  ------------------
  |  |  322|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 1096|      0|                    return -1;
 1097|      0|                }
 1098|       |
 1099|      0|                session->common.log_verbosity = i & 0xffffU;
 1100|      0|                ssh_set_log_level(i & 0xffffU);
 1101|      0|            }
 1102|      0|            break;
 1103|  8.64k|        case SSH_OPTIONS_CIPHERS_C_S:
  ------------------
  |  Branch (1103:9): [True: 8.64k, False: 69.1k]
  ------------------
 1104|  8.64k|            v = value;
 1105|  8.64k|            if (v == NULL || v[0] == '\0') {
  ------------------
  |  Branch (1105:17): [True: 0, False: 8.64k]
  |  Branch (1105:30): [True: 0, False: 8.64k]
  ------------------
 1106|      0|                ssh_set_error_invalid(session);
  ------------------
  |  |  322|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 1107|      0|                return -1;
 1108|  8.64k|            } else {
 1109|  8.64k|                rc = ssh_options_set_algo(session,
 1110|  8.64k|                                          SSH_CRYPT_C_S,
 1111|  8.64k|                                          v,
 1112|  8.64k|                                          &wanted_methods[SSH_CRYPT_C_S]);
 1113|  8.64k|                if (rc < 0)
  ------------------
  |  Branch (1113:21): [True: 0, False: 8.64k]
  ------------------
 1114|      0|                    return -1;
 1115|  8.64k|            }
 1116|  8.64k|            break;
 1117|  8.64k|        case SSH_OPTIONS_CIPHERS_S_C:
  ------------------
  |  Branch (1117:9): [True: 8.64k, False: 69.1k]
  ------------------
 1118|  8.64k|            v = value;
 1119|  8.64k|            if (v == NULL || v[0] == '\0') {
  ------------------
  |  Branch (1119:17): [True: 0, False: 8.64k]
  |  Branch (1119:30): [True: 0, False: 8.64k]
  ------------------
 1120|      0|                ssh_set_error_invalid(session);
  ------------------
  |  |  322|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 1121|      0|                return -1;
 1122|  8.64k|            } else {
 1123|  8.64k|                rc = ssh_options_set_algo(session,
 1124|  8.64k|                                          SSH_CRYPT_S_C,
 1125|  8.64k|                                          v,
 1126|  8.64k|                                          &wanted_methods[SSH_CRYPT_S_C]);
 1127|  8.64k|                if (rc < 0)
  ------------------
  |  Branch (1127:21): [True: 0, False: 8.64k]
  ------------------
 1128|      0|                    return -1;
 1129|  8.64k|            }
 1130|  8.64k|            break;
 1131|  8.64k|        case SSH_OPTIONS_KEY_EXCHANGE:
  ------------------
  |  Branch (1131:9): [True: 0, False: 77.7k]
  ------------------
 1132|      0|            v = value;
 1133|      0|            if (v == NULL || v[0] == '\0') {
  ------------------
  |  Branch (1133:17): [True: 0, False: 0]
  |  Branch (1133:30): [True: 0, False: 0]
  ------------------
 1134|      0|                ssh_set_error_invalid(session);
  ------------------
  |  |  322|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 1135|      0|                return -1;
 1136|      0|            } else {
 1137|      0|                rc = ssh_options_set_algo(session,
 1138|      0|                                          SSH_KEX,
 1139|      0|                                          v,
 1140|      0|                                          &wanted_methods[SSH_KEX]);
 1141|      0|                if (rc < 0)
  ------------------
  |  Branch (1141:21): [True: 0, False: 0]
  ------------------
 1142|      0|                    return -1;
 1143|      0|            }
 1144|      0|            break;
 1145|      0|        case SSH_OPTIONS_HOSTKEYS:
  ------------------
  |  Branch (1145:9): [True: 0, False: 77.7k]
  ------------------
 1146|      0|            v = value;
 1147|      0|            if (v == NULL || v[0] == '\0') {
  ------------------
  |  Branch (1147:17): [True: 0, False: 0]
  |  Branch (1147:30): [True: 0, False: 0]
  ------------------
 1148|      0|                ssh_set_error_invalid(session);
  ------------------
  |  |  322|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 1149|      0|                return -1;
 1150|      0|            } else {
 1151|      0|                rc = ssh_options_set_algo(session,
 1152|      0|                                          SSH_HOSTKEYS,
 1153|      0|                                          v,
 1154|      0|                                          &wanted_methods[SSH_HOSTKEYS]);
 1155|      0|                if (rc < 0)
  ------------------
  |  Branch (1155:21): [True: 0, False: 0]
  ------------------
 1156|      0|                    return -1;
 1157|      0|            }
 1158|      0|            break;
 1159|      0|        case SSH_OPTIONS_PUBLICKEY_ACCEPTED_TYPES:
  ------------------
  |  Branch (1159:9): [True: 0, False: 77.7k]
  ------------------
 1160|      0|            v = value;
 1161|      0|            if (v == NULL || v[0] == '\0') {
  ------------------
  |  Branch (1161:17): [True: 0, False: 0]
  |  Branch (1161:30): [True: 0, False: 0]
  ------------------
 1162|      0|                ssh_set_error_invalid(session);
  ------------------
  |  |  322|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 1163|      0|                return -1;
 1164|      0|            } else {
 1165|      0|                rc = ssh_options_set_algo(session,
 1166|      0|                                          SSH_HOSTKEYS,
 1167|      0|                                          v,
 1168|      0|                                          &session->opts.pubkey_accepted_types);
 1169|      0|                if (rc < 0)
  ------------------
  |  Branch (1169:21): [True: 0, False: 0]
  ------------------
 1170|      0|                    return -1;
 1171|      0|            }
 1172|      0|            break;
 1173|  8.64k|        case SSH_OPTIONS_HMAC_C_S:
  ------------------
  |  Branch (1173:9): [True: 8.64k, False: 69.1k]
  ------------------
 1174|  8.64k|            v = value;
 1175|  8.64k|            if (v == NULL || v[0] == '\0') {
  ------------------
  |  Branch (1175:17): [True: 0, False: 8.64k]
  |  Branch (1175:30): [True: 0, False: 8.64k]
  ------------------
 1176|      0|                ssh_set_error_invalid(session);
  ------------------
  |  |  322|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 1177|      0|                return -1;
 1178|  8.64k|            } else {
 1179|  8.64k|                rc = ssh_options_set_algo(session,
 1180|  8.64k|                                          SSH_MAC_C_S,
 1181|  8.64k|                                          v,
 1182|  8.64k|                                          &wanted_methods[SSH_MAC_C_S]);
 1183|  8.64k|                if (rc < 0)
  ------------------
  |  Branch (1183:21): [True: 0, False: 8.64k]
  ------------------
 1184|      0|                    return -1;
 1185|  8.64k|            }
 1186|  8.64k|            break;
 1187|  8.64k|         case SSH_OPTIONS_HMAC_S_C:
  ------------------
  |  Branch (1187:10): [True: 8.64k, False: 69.1k]
  ------------------
 1188|  8.64k|            v = value;
 1189|  8.64k|            if (v == NULL || v[0] == '\0') {
  ------------------
  |  Branch (1189:17): [True: 0, False: 8.64k]
  |  Branch (1189:30): [True: 0, False: 8.64k]
  ------------------
 1190|      0|                ssh_set_error_invalid(session);
  ------------------
  |  |  322|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 1191|      0|                return -1;
 1192|  8.64k|            } else {
 1193|  8.64k|                rc = ssh_options_set_algo(session,
 1194|  8.64k|                                          SSH_MAC_S_C,
 1195|  8.64k|                                          v,
 1196|  8.64k|                                          &wanted_methods[SSH_MAC_S_C]);
 1197|  8.64k|                if (rc < 0)
  ------------------
  |  Branch (1197:21): [True: 0, False: 8.64k]
  ------------------
 1198|      0|                    return -1;
 1199|  8.64k|            }
 1200|  8.64k|            break;
 1201|  8.64k|        case SSH_OPTIONS_COMPRESSION_C_S:
  ------------------
  |  Branch (1201:9): [True: 0, False: 77.7k]
  ------------------
 1202|      0|            v = value;
 1203|      0|            if (v == NULL || v[0] == '\0') {
  ------------------
  |  Branch (1203:17): [True: 0, False: 0]
  |  Branch (1203:30): [True: 0, False: 0]
  ------------------
 1204|      0|                ssh_set_error_invalid(session);
  ------------------
  |  |  322|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 1205|      0|                return -1;
 1206|      0|            } else {
 1207|      0|                const char *tmp = v;
 1208|      0|                if (strcasecmp(value, "yes") == 0){
  ------------------
  |  Branch (1208:21): [True: 0, False: 0]
  ------------------
 1209|      0|                    tmp = "zlib@openssh.com,none";
 1210|      0|                } else if (strcasecmp(value, "no") == 0){
  ------------------
  |  Branch (1210:28): [True: 0, False: 0]
  ------------------
 1211|      0|                    tmp = "none,zlib@openssh.com";
 1212|      0|                }
 1213|      0|                rc = ssh_options_set_algo(session,
 1214|      0|                                          SSH_COMP_C_S,
 1215|      0|                                          tmp,
 1216|      0|                                          &wanted_methods[SSH_COMP_C_S]);
 1217|      0|                if (rc < 0)
  ------------------
  |  Branch (1217:21): [True: 0, False: 0]
  ------------------
 1218|      0|                    return -1;
 1219|      0|            }
 1220|      0|            break;
 1221|      0|        case SSH_OPTIONS_COMPRESSION_S_C:
  ------------------
  |  Branch (1221:9): [True: 0, False: 77.7k]
  ------------------
 1222|      0|            v = value;
 1223|      0|            if (v == NULL || v[0] == '\0') {
  ------------------
  |  Branch (1223:17): [True: 0, False: 0]
  |  Branch (1223:30): [True: 0, False: 0]
  ------------------
 1224|      0|                ssh_set_error_invalid(session);
  ------------------
  |  |  322|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 1225|      0|                return -1;
 1226|      0|            } else {
 1227|      0|                const char *tmp = v;
 1228|      0|                if (strcasecmp(value, "yes") == 0){
  ------------------
  |  Branch (1228:21): [True: 0, False: 0]
  ------------------
 1229|      0|                    tmp = "zlib@openssh.com,none";
 1230|      0|                } else if (strcasecmp(value, "no") == 0){
  ------------------
  |  Branch (1230:28): [True: 0, False: 0]
  ------------------
 1231|      0|                    tmp = "none,zlib@openssh.com";
 1232|      0|                }
 1233|       |
 1234|      0|                rc = ssh_options_set_algo(session,
 1235|      0|                                          SSH_COMP_S_C,
 1236|      0|                                          tmp,
 1237|      0|                                          &wanted_methods[SSH_COMP_S_C]);
 1238|      0|                if (rc < 0)
  ------------------
  |  Branch (1238:21): [True: 0, False: 0]
  ------------------
 1239|      0|                    return -1;
 1240|      0|            }
 1241|      0|            break;
 1242|      0|        case SSH_OPTIONS_COMPRESSION:
  ------------------
  |  Branch (1242:9): [True: 0, False: 77.7k]
  ------------------
 1243|      0|            v = value;
 1244|      0|            if (v == NULL || v[0] == '\0') {
  ------------------
  |  Branch (1244:17): [True: 0, False: 0]
  |  Branch (1244:30): [True: 0, False: 0]
  ------------------
 1245|      0|                ssh_set_error_invalid(session);
  ------------------
  |  |  322|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 1246|      0|                return -1;
 1247|      0|            }
 1248|      0|            if(ssh_options_set(session,SSH_OPTIONS_COMPRESSION_C_S, v) < 0)
  ------------------
  |  Branch (1248:16): [True: 0, False: 0]
  ------------------
 1249|      0|                return -1;
 1250|      0|            if(ssh_options_set(session,SSH_OPTIONS_COMPRESSION_S_C, v) < 0)
  ------------------
  |  Branch (1250:16): [True: 0, False: 0]
  ------------------
 1251|      0|                return -1;
 1252|      0|            break;
 1253|      0|        case SSH_OPTIONS_COMPRESSION_LEVEL:
  ------------------
  |  Branch (1253:9): [True: 0, False: 77.7k]
  ------------------
 1254|      0|            if (value == NULL) {
  ------------------
  |  Branch (1254:17): [True: 0, False: 0]
  ------------------
 1255|      0|                ssh_set_error_invalid(session);
  ------------------
  |  |  322|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 1256|      0|                return -1;
 1257|      0|            } else {
 1258|      0|                int *x = (int *)value;
 1259|      0|                if (*x < 1 || *x > 9) {
  ------------------
  |  Branch (1259:21): [True: 0, False: 0]
  |  Branch (1259:31): [True: 0, False: 0]
  ------------------
 1260|      0|                    ssh_set_error_invalid(session);
  ------------------
  |  |  322|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 1261|      0|                    return -1;
 1262|      0|                }
 1263|      0|                session->opts.compressionlevel = *x & 0xff;
 1264|      0|            }
 1265|      0|            break;
 1266|      0|        case SSH_OPTIONS_STRICTHOSTKEYCHECK:
  ------------------
  |  Branch (1266:9): [True: 0, False: 77.7k]
  ------------------
 1267|      0|            if (value == NULL) {
  ------------------
  |  Branch (1267:17): [True: 0, False: 0]
  ------------------
 1268|      0|                ssh_set_error_invalid(session);
  ------------------
  |  |  322|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 1269|      0|                return -1;
 1270|      0|            } else {
 1271|      0|                int *x = (int *) value;
 1272|      0|                int mode = *x;
 1273|       |
 1274|      0|                switch (mode) {
 1275|      0|                case SSH_STRICT_HOSTKEY_OFF:
  ------------------
  |  Branch (1275:17): [True: 0, False: 0]
  ------------------
 1276|      0|                case SSH_STRICT_HOSTKEY_YES:
  ------------------
  |  Branch (1276:17): [True: 0, False: 0]
  ------------------
 1277|      0|                case SSH_STRICT_HOSTKEY_ASK:
  ------------------
  |  Branch (1277:17): [True: 0, False: 0]
  ------------------
 1278|      0|                case SSH_STRICT_HOSTKEY_ACCEPT_NEW:
  ------------------
  |  Branch (1278:17): [True: 0, False: 0]
  ------------------
 1279|      0|                    session->opts.StrictHostKeyChecking = mode;
 1280|      0|                    break;
 1281|      0|                default:
  ------------------
  |  Branch (1281:17): [True: 0, False: 0]
  ------------------
 1282|       |                    /* Preserve the legacy low-byte "non-zero means yes"
 1283|       |                     * normalization.
 1284|       |                     */
 1285|      0|                    session->opts.StrictHostKeyChecking =
 1286|      0|                        (mode & 0xff) > 0 ? SSH_STRICT_HOSTKEY_YES
  ------------------
  |  Branch (1286:25): [True: 0, False: 0]
  ------------------
 1287|      0|                                          : SSH_STRICT_HOSTKEY_OFF;
 1288|      0|                    break;
 1289|      0|                }
 1290|      0|            }
 1291|      0|            break;
 1292|      0|        case SSH_OPTIONS_PROXYCOMMAND:
  ------------------
  |  Branch (1292:9): [True: 0, False: 77.7k]
  ------------------
 1293|      0|            v = value;
 1294|      0|            if (v == NULL || v[0] == '\0') {
  ------------------
  |  Branch (1294:17): [True: 0, False: 0]
  |  Branch (1294:30): [True: 0, False: 0]
  ------------------
 1295|      0|                ssh_set_error_invalid(session);
  ------------------
  |  |  322|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 1296|      0|                return -1;
 1297|      0|            } else {
 1298|      0|                SAFE_FREE(session->opts.ProxyCommand);
  ------------------
  |  |  373|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1299|       |                /* Setting the command to 'none' disables this option. */
 1300|      0|                rc = strcasecmp(v, "none");
 1301|      0|                if (rc != 0) {
  ------------------
  |  Branch (1301:21): [True: 0, False: 0]
  ------------------
 1302|      0|                    q = strdup(v);
 1303|      0|                    if (q == NULL) {
  ------------------
  |  Branch (1303:25): [True: 0, False: 0]
  ------------------
 1304|      0|                        return -1;
 1305|      0|                    }
 1306|      0|                    session->opts.ProxyCommand = q;
 1307|      0|                    session->opts.exp_flags &= ~SSH_OPT_EXP_FLAG_PROXYCOMMAND;
  ------------------
  |  |  117|      0|#define SSH_OPT_EXP_FLAG_PROXYCOMMAND 0x4
  ------------------
 1308|      0|                }
 1309|      0|            }
 1310|      0|            break;
 1311|      0|        case SSH_OPTIONS_PROXYJUMP:
  ------------------
  |  Branch (1311:9): [True: 0, False: 77.7k]
  ------------------
 1312|      0|            v = value;
 1313|      0|            if (v == NULL || v[0] == '\0') {
  ------------------
  |  Branch (1313:17): [True: 0, False: 0]
  |  Branch (1313:30): [True: 0, False: 0]
  ------------------
 1314|      0|                ssh_set_error_invalid(session);
  ------------------
  |  |  322|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 1315|      0|                return -1;
 1316|      0|            } else {
 1317|      0|                rc = ssh_config_parse_proxy_jump(session, v, true);
 1318|      0|                if (rc != SSH_OK) {
  ------------------
  |  |  316|      0|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (1318:21): [True: 0, False: 0]
  ------------------
 1319|      0|                    return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 1320|      0|                }
 1321|      0|            }
 1322|      0|            break;
 1323|      0|        case SSH_OPTIONS_PROXYJUMP_CB_LIST_APPEND:
  ------------------
  |  Branch (1323:9): [True: 0, False: 77.7k]
  ------------------
 1324|      0|            j = (struct ssh_jump_callbacks_struct *)value;
 1325|      0|            if (j == NULL) {
  ------------------
  |  Branch (1325:17): [True: 0, False: 0]
  ------------------
 1326|      0|                ssh_set_error_invalid(session);
  ------------------
  |  |  322|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 1327|      0|                return -1;
 1328|      0|            } else {
 1329|      0|                rc = ssh_list_prepend(session->opts.proxy_jumps_user_cb, j);
 1330|      0|                if (rc != SSH_OK) {
  ------------------
  |  |  316|      0|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (1330:21): [True: 0, False: 0]
  ------------------
 1331|      0|                    ssh_set_error_oom(session);
  ------------------
  |  |  318|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
 1332|      0|                    return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 1333|      0|                }
 1334|      0|            }
 1335|      0|            break;
 1336|      0|        case SSH_OPTIONS_GSSAPI_SERVER_IDENTITY:
  ------------------
  |  Branch (1336:9): [True: 0, False: 77.7k]
  ------------------
 1337|      0|            v = value;
 1338|      0|            if (v == NULL || v[0] == '\0') {
  ------------------
  |  Branch (1338:17): [True: 0, False: 0]
  |  Branch (1338:30): [True: 0, False: 0]
  ------------------
 1339|      0|                ssh_set_error_invalid(session);
  ------------------
  |  |  322|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 1340|      0|                return -1;
 1341|      0|            } else {
 1342|      0|                SAFE_FREE(session->opts.gss_server_identity);
  ------------------
  |  |  373|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1343|      0|                session->opts.gss_server_identity = strdup(v);
 1344|      0|                if (session->opts.gss_server_identity == NULL) {
  ------------------
  |  Branch (1344:21): [True: 0, False: 0]
  ------------------
 1345|      0|                    ssh_set_error_oom(session);
  ------------------
  |  |  318|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
 1346|      0|                    return -1;
 1347|      0|                }
 1348|      0|            }
 1349|      0|            break;
 1350|      0|        case SSH_OPTIONS_GSSAPI_CLIENT_IDENTITY:
  ------------------
  |  Branch (1350:9): [True: 0, False: 77.7k]
  ------------------
 1351|      0|            v = value;
 1352|      0|            if (v == NULL || v[0] == '\0') {
  ------------------
  |  Branch (1352:17): [True: 0, False: 0]
  |  Branch (1352:30): [True: 0, False: 0]
  ------------------
 1353|      0|                ssh_set_error_invalid(session);
  ------------------
  |  |  322|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 1354|      0|                return -1;
 1355|      0|            } else {
 1356|      0|                SAFE_FREE(session->opts.gss_client_identity);
  ------------------
  |  |  373|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1357|      0|                session->opts.gss_client_identity = strdup(v);
 1358|      0|                if (session->opts.gss_client_identity == NULL) {
  ------------------
  |  Branch (1358:21): [True: 0, False: 0]
  ------------------
 1359|      0|                    ssh_set_error_oom(session);
  ------------------
  |  |  318|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
 1360|      0|                    return -1;
 1361|      0|                }
 1362|      0|            }
 1363|      0|            break;
 1364|      0|        case SSH_OPTIONS_GSSAPI_DELEGATE_CREDENTIALS:
  ------------------
  |  Branch (1364:9): [True: 0, False: 77.7k]
  ------------------
 1365|      0|            if (value == NULL) {
  ------------------
  |  Branch (1365:17): [True: 0, False: 0]
  ------------------
 1366|      0|                ssh_set_error_invalid(session);
  ------------------
  |  |  322|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 1367|      0|                return -1;
 1368|      0|            } else {
 1369|      0|                int x = *(int *)value;
 1370|       |
 1371|      0|                session->opts.gss_delegate_creds = (x & 0xff);
 1372|      0|            }
 1373|      0|            break;
 1374|       |#ifdef WITH_GSSAPI
 1375|       |        case SSH_OPTIONS_GSSAPI_KEY_EXCHANGE:
 1376|       |            if (value == NULL) {
 1377|       |                ssh_set_error_invalid(session);
 1378|       |                return -1;
 1379|       |            } else {
 1380|       |                bool *x = (bool *)value;
 1381|       |                session->opts.gssapi_key_exchange = *x;
 1382|       |            }
 1383|       |            break;
 1384|       |        case SSH_OPTIONS_GSSAPI_KEY_EXCHANGE_ALGS:
 1385|       |            v = value;
 1386|       |            if (v == NULL || v[0] == '\0') {
 1387|       |                ssh_set_error_invalid(session);
 1388|       |                return -1;
 1389|       |            } else {
 1390|       |                /* Check if algorithms are supported */
 1391|       |                char *ret =
 1392|       |                    ssh_find_all_matching(GSSAPI_KEY_EXCHANGE_SUPPORTED, v);
 1393|       |                if (ret == NULL) {
 1394|       |                    ssh_set_error(session,
 1395|       |                                  SSH_FATAL,
 1396|       |                                  "GSSAPI key exchange algorithms not "
 1397|       |                                  "supported or invalid");
 1398|       |                    return -1;
 1399|       |                }
 1400|       |                SAFE_FREE(session->opts.gssapi_key_exchange_algs);
 1401|       |                session->opts.gssapi_key_exchange_algs = ret;
 1402|       |            }
 1403|       |            break;
 1404|       |#endif
 1405|      0|        case SSH_OPTIONS_PASSWORD_AUTH:
  ------------------
  |  Branch (1405:9): [True: 0, False: 77.7k]
  ------------------
 1406|      0|        case SSH_OPTIONS_PUBKEY_AUTH:
  ------------------
  |  Branch (1406:9): [True: 0, False: 77.7k]
  ------------------
 1407|      0|        case SSH_OPTIONS_KBDINT_AUTH:
  ------------------
  |  Branch (1407:9): [True: 0, False: 77.7k]
  ------------------
 1408|      0|        case SSH_OPTIONS_GSSAPI_AUTH:
  ------------------
  |  Branch (1408:9): [True: 0, False: 77.7k]
  ------------------
 1409|      0|            if (value == NULL) {
  ------------------
  |  Branch (1409:17): [True: 0, False: 0]
  ------------------
 1410|      0|                ssh_set_error_invalid(session);
  ------------------
  |  |  322|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 1411|      0|                return -1;
 1412|      0|            } else {
 1413|      0|                int x = *(int *)value;
 1414|      0|                u = type == SSH_OPTIONS_PASSWORD_AUTH ?
  ------------------
  |  Branch (1414:21): [True: 0, False: 0]
  ------------------
 1415|      0|                    SSH_OPT_FLAG_PASSWORD_AUTH:
  ------------------
  |  |  109|      0|#define SSH_OPT_FLAG_PASSWORD_AUTH 0x1
  ------------------
 1416|      0|                    type == SSH_OPTIONS_PUBKEY_AUTH ?
  ------------------
  |  Branch (1416:21): [True: 0, False: 0]
  ------------------
 1417|      0|                        SSH_OPT_FLAG_PUBKEY_AUTH:
  ------------------
  |  |  110|      0|#define SSH_OPT_FLAG_PUBKEY_AUTH 0x2
  ------------------
 1418|      0|                        type == SSH_OPTIONS_KBDINT_AUTH ?
  ------------------
  |  Branch (1418:25): [True: 0, False: 0]
  ------------------
 1419|      0|                            SSH_OPT_FLAG_KBDINT_AUTH:
  ------------------
  |  |  111|      0|#define SSH_OPT_FLAG_KBDINT_AUTH 0x4
  ------------------
 1420|      0|                            SSH_OPT_FLAG_GSSAPI_AUTH;
  ------------------
  |  |  112|      0|#define SSH_OPT_FLAG_GSSAPI_AUTH 0x8
  ------------------
 1421|      0|                if (x != 0) {
  ------------------
  |  Branch (1421:21): [True: 0, False: 0]
  ------------------
 1422|      0|                    session->opts.flags |= u;
 1423|      0|                } else {
 1424|      0|                    session->opts.flags &= ~u;
 1425|      0|                }
 1426|      0|                if (type == SSH_OPTIONS_PUBKEY_AUTH) {
  ------------------
  |  Branch (1426:21): [True: 0, False: 0]
  ------------------
 1427|       |                    /*
 1428|       |                     * Keep the legacy enabled/disabled auth flag semantics in
 1429|       |                     * sync above while also storing the selected
 1430|       |                     * PubkeyAuthentication mode here.
 1431|       |                     */
 1432|      0|                    switch (x) {
 1433|      0|                    case SSH_PUBKEY_AUTH_NO:
  ------------------
  |  Branch (1433:21): [True: 0, False: 0]
  ------------------
 1434|      0|                    case SSH_PUBKEY_AUTH_ALL:
  ------------------
  |  Branch (1434:21): [True: 0, False: 0]
  ------------------
 1435|      0|                    case SSH_PUBKEY_AUTH_UNBOUND:
  ------------------
  |  Branch (1435:21): [True: 0, False: 0]
  ------------------
 1436|      0|                    case SSH_PUBKEY_AUTH_HOST_BOUND:
  ------------------
  |  Branch (1436:21): [True: 0, False: 0]
  ------------------
 1437|      0|                        session->opts.pubkey_auth = x;
 1438|      0|                        break;
 1439|      0|                    default:
  ------------------
  |  Branch (1439:21): [True: 0, False: 0]
  ------------------
 1440|       |                        /* Preserve the legacy non-zero "yes" normalization
 1441|       |                         * here so callers passing -1 still land on
 1442|       |                         * SSH_PUBKEY_AUTH_ALL.
 1443|       |                         */
 1444|      0|                        session->opts.pubkey_auth = SSH_PUBKEY_AUTH_ALL;
 1445|      0|                        break;
 1446|      0|                    }
 1447|      0|                }
 1448|      0|            }
 1449|      0|            break;
 1450|      0|        case SSH_OPTIONS_NODELAY:
  ------------------
  |  Branch (1450:9): [True: 0, False: 77.7k]
  ------------------
 1451|      0|            if (value == NULL) {
  ------------------
  |  Branch (1451:17): [True: 0, False: 0]
  ------------------
 1452|      0|                ssh_set_error_invalid(session);
  ------------------
  |  |  322|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 1453|      0|                return -1;
 1454|      0|            } else {
 1455|      0|                int *x = (int *) value;
 1456|      0|                session->opts.nodelay = (*x & 0xff) > 0 ? 1 : 0;
  ------------------
  |  Branch (1456:41): [True: 0, False: 0]
  ------------------
 1457|      0|            }
 1458|      0|            break;
 1459|      0|        case SSH_OPTIONS_PROCESS_CONFIG:
  ------------------
  |  Branch (1459:9): [True: 0, False: 77.7k]
  ------------------
 1460|      0|            if (value == NULL) {
  ------------------
  |  Branch (1460:17): [True: 0, False: 0]
  ------------------
 1461|      0|                ssh_set_error_invalid(session);
  ------------------
  |  |  322|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 1462|      0|                return -1;
 1463|      0|            } else {
 1464|      0|                bool *x = (bool *)value;
 1465|      0|                session->opts.config_processed = !(*x);
 1466|      0|            }
 1467|      0|            break;
 1468|      0|        case SSH_OPTIONS_REKEY_DATA:
  ------------------
  |  Branch (1468:9): [True: 0, False: 77.7k]
  ------------------
 1469|      0|            if (value == NULL) {
  ------------------
  |  Branch (1469:17): [True: 0, False: 0]
  ------------------
 1470|      0|                ssh_set_error_invalid(session);
  ------------------
  |  |  322|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 1471|      0|                return -1;
 1472|      0|            } else {
 1473|      0|                uint64_t *x = (uint64_t *)value;
 1474|      0|                session->opts.rekey_data = *x;
 1475|      0|            }
 1476|      0|            break;
 1477|      0|        case SSH_OPTIONS_REKEY_TIME:
  ------------------
  |  Branch (1477:9): [True: 0, False: 77.7k]
  ------------------
 1478|      0|            if (value == NULL) {
  ------------------
  |  Branch (1478:17): [True: 0, False: 0]
  ------------------
 1479|      0|                ssh_set_error_invalid(session);
  ------------------
  |  |  322|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 1480|      0|                return -1;
 1481|      0|            } else {
 1482|      0|                uint32_t *x = (uint32_t *)value;
 1483|      0|                if ((*x * 1000) < *x) {
  ------------------
  |  Branch (1483:21): [True: 0, False: 0]
  ------------------
 1484|      0|                    ssh_set_error(session, SSH_REQUEST_DENIED,
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
 1485|      0|                                  "The provided value (%" PRIu32 ") for rekey"
 1486|      0|                                  " time is too large", *x);
 1487|      0|                    return -1;
 1488|      0|                }
 1489|      0|                session->opts.rekey_time = (*x) * 1000;
 1490|      0|            }
 1491|      0|            break;
 1492|      0|        case SSH_OPTIONS_RSA_MIN_SIZE:
  ------------------
  |  Branch (1492:9): [True: 0, False: 77.7k]
  ------------------
 1493|      0|            if (value == NULL) {
  ------------------
  |  Branch (1493:17): [True: 0, False: 0]
  ------------------
 1494|      0|                ssh_set_error_invalid(session);
  ------------------
  |  |  322|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 1495|      0|                return -1;
 1496|      0|            } else {
 1497|      0|                int *x = (int *)value;
 1498|       |
 1499|      0|                if (*x < 0) {
  ------------------
  |  Branch (1499:21): [True: 0, False: 0]
  ------------------
 1500|      0|                    ssh_set_error_invalid(session);
  ------------------
  |  |  322|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 1501|      0|                    return -1;
 1502|      0|                }
 1503|       |
 1504|       |                /* (*x == 0) is allowed as it is used to revert to default */
 1505|       |
 1506|      0|                if (*x > 0 && *x < RSA_MIN_KEY_SIZE) {
  ------------------
  |  |   49|      0|#define RSA_MIN_KEY_SIZE      1024
  ------------------
  |  Branch (1506:21): [True: 0, False: 0]
  |  Branch (1506:31): [True: 0, False: 0]
  ------------------
 1507|      0|                    ssh_set_error(session,
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
 1508|      0|                                  SSH_REQUEST_DENIED,
 1509|      0|                                  "The provided value (%d) for minimal RSA key "
 1510|      0|                                  "size is too small. Use at least %d bits.",
 1511|      0|                                  *x,
 1512|      0|                                  RSA_MIN_KEY_SIZE);
 1513|      0|                    return -1;
 1514|      0|                }
 1515|      0|                session->opts.rsa_min_size = *x;
 1516|      0|            }
 1517|      0|            break;
 1518|      0|        case SSH_OPTIONS_IDENTITY_AGENT:
  ------------------
  |  Branch (1518:9): [True: 0, False: 77.7k]
  ------------------
 1519|      0|            v = value;
 1520|      0|            SAFE_FREE(session->opts.agent_socket);
  ------------------
  |  |  373|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1521|      0|            if (v == NULL) {
  ------------------
  |  Branch (1521:17): [True: 0, False: 0]
  ------------------
 1522|       |                /* The default value will be set by the ssh_options_apply() */
 1523|      0|            } else if (v[0] == '\0') {
  ------------------
  |  Branch (1523:24): [True: 0, False: 0]
  ------------------
 1524|      0|                ssh_set_error_invalid(session);
  ------------------
  |  |  322|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 1525|      0|                return -1;
 1526|      0|            } else {
 1527|      0|                session->opts.agent_socket = ssh_path_expand_tilde(v);
 1528|      0|                if (session->opts.agent_socket == NULL) {
  ------------------
  |  Branch (1528:21): [True: 0, False: 0]
  ------------------
 1529|      0|                    ssh_set_error_oom(session);
  ------------------
  |  |  318|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
 1530|      0|                    return -1;
 1531|      0|                }
 1532|      0|            }
 1533|      0|            break;
 1534|      0|        case SSH_OPTIONS_IDENTITIES_ONLY:
  ------------------
  |  Branch (1534:9): [True: 0, False: 77.7k]
  ------------------
 1535|      0|            if (value == NULL) {
  ------------------
  |  Branch (1535:17): [True: 0, False: 0]
  ------------------
 1536|      0|                ssh_set_error_invalid(session);
  ------------------
  |  |  322|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 1537|      0|                return -1;
 1538|      0|            } else {
 1539|      0|                bool *x = (bool *)value;
 1540|      0|                session->opts.identities_only = *x;
 1541|      0|            }
 1542|      0|            break;
 1543|      0|        case SSH_OPTIONS_CONTROL_MASTER:
  ------------------
  |  Branch (1543:9): [True: 0, False: 77.7k]
  ------------------
 1544|      0|            if (value == NULL) {
  ------------------
  |  Branch (1544:17): [True: 0, False: 0]
  ------------------
 1545|      0|                ssh_set_error_invalid(session);
  ------------------
  |  |  322|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 1546|      0|                return -1;
 1547|      0|            } else {
 1548|      0|                int *x = (int *) value;
 1549|      0|                if (*x < SSH_CONTROL_MASTER_NO || *x > SSH_CONTROL_MASTER_AUTOASK) {
  ------------------
  |  Branch (1549:21): [True: 0, False: 0]
  |  Branch (1549:51): [True: 0, False: 0]
  ------------------
 1550|      0|                    ssh_set_error_invalid(session);
  ------------------
  |  |  322|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 1551|      0|                    return -1;
 1552|      0|                }
 1553|      0|                session->opts.control_master = *x;
 1554|      0|            }
 1555|      0|            break;
 1556|      0|        case SSH_OPTIONS_CONTROL_PATH:
  ------------------
  |  Branch (1556:9): [True: 0, False: 77.7k]
  ------------------
 1557|      0|            v = value;
 1558|      0|            if (v == NULL || v[0] == '\0') {
  ------------------
  |  Branch (1558:17): [True: 0, False: 0]
  |  Branch (1558:30): [True: 0, False: 0]
  ------------------
 1559|      0|                ssh_set_error_invalid(session);
  ------------------
  |  |  322|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 1560|      0|                return -1;
 1561|      0|            } else {
 1562|      0|                SAFE_FREE(session->opts.control_path);
  ------------------
  |  |  373|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1563|      0|                rc = strcasecmp(v, "none");
 1564|      0|                if (rc != 0) {
  ------------------
  |  Branch (1564:21): [True: 0, False: 0]
  ------------------
 1565|      0|                    session->opts.control_path = ssh_path_expand_tilde(v);
 1566|      0|                    if (session->opts.control_path == NULL) {
  ------------------
  |  Branch (1566:25): [True: 0, False: 0]
  ------------------
 1567|      0|                        ssh_set_error_oom(session);
  ------------------
  |  |  318|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
 1568|      0|                        return -1;
 1569|      0|                    }
 1570|      0|                    session->opts.exp_flags &= ~SSH_OPT_EXP_FLAG_CONTROL_PATH;
  ------------------
  |  |  119|      0|#define SSH_OPT_EXP_FLAG_CONTROL_PATH 0x10
  ------------------
 1571|      0|                }
 1572|      0|            }
 1573|      0|            break;
 1574|      0|        case SSH_OPTIONS_PKI_CONTEXT:
  ------------------
  |  Branch (1574:9): [True: 0, False: 77.7k]
  ------------------
 1575|      0|            if (value == NULL) {
  ------------------
  |  Branch (1575:17): [True: 0, False: 0]
  ------------------
 1576|      0|                ssh_set_error_invalid(session);
  ------------------
  |  |  322|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 1577|      0|                return -1;
 1578|      0|            }
 1579|       |
 1580|      0|            SSH_PKI_CTX_FREE(session->pki_context);
  ------------------
  |  | 1027|      0|    do {                         \
  |  | 1028|      0|        if ((x) != NULL) {       \
  |  |  ------------------
  |  |  |  Branch (1028:13): [True: 0, False: 0]
  |  |  ------------------
  |  | 1029|      0|            ssh_pki_ctx_free(x); \
  |  | 1030|      0|            x = NULL;            \
  |  | 1031|      0|        }                        \
  |  | 1032|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (1032:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1581|       |
 1582|      0|            session->pki_context = ssh_pki_ctx_dup((const ssh_pki_ctx)value);
 1583|      0|            if (session->pki_context == NULL) {
  ------------------
  |  Branch (1583:17): [True: 0, False: 0]
  ------------------
 1584|      0|                ssh_set_error_oom(session);
  ------------------
  |  |  318|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
 1585|      0|                return -1;
 1586|      0|            }
 1587|      0|            break;
 1588|      0|        case SSH_OPTIONS_ADDRESS_FAMILY:
  ------------------
  |  Branch (1588:9): [True: 0, False: 77.7k]
  ------------------
 1589|      0|            if (value == NULL) {
  ------------------
  |  Branch (1589:17): [True: 0, False: 0]
  ------------------
 1590|      0|                ssh_set_error_invalid(session);
  ------------------
  |  |  322|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 1591|      0|                return -1;
 1592|      0|            } else {
 1593|      0|                int *x = (int *)value;
 1594|      0|                if (*x < SSH_ADDRESS_FAMILY_ANY ||
  ------------------
  |  Branch (1594:21): [True: 0, False: 0]
  ------------------
 1595|      0|                    *x > SSH_ADDRESS_FAMILY_INET6) {
  ------------------
  |  Branch (1595:21): [True: 0, False: 0]
  ------------------
 1596|      0|                    ssh_set_error_invalid(session);
  ------------------
  |  |  322|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 1597|      0|                    return -1;
 1598|      0|                }
 1599|      0|                session->opts.address_family = *x;
 1600|      0|            }
 1601|      0|            break;
 1602|      0|        case SSH_OPTIONS_BATCH_MODE:
  ------------------
  |  Branch (1602:9): [True: 0, False: 77.7k]
  ------------------
 1603|      0|            if (value == NULL) {
  ------------------
  |  Branch (1603:17): [True: 0, False: 0]
  ------------------
 1604|      0|                ssh_set_error_invalid(session);
  ------------------
  |  |  322|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 1605|      0|                return -1;
 1606|      0|            } else {
 1607|      0|                bool *x = (bool *)value;
 1608|      0|                session->opts.batch_mode = *x;
 1609|      0|            }
 1610|      0|            break;
 1611|      0|        default:
  ------------------
  |  Branch (1611:9): [True: 0, False: 77.7k]
  ------------------
 1612|      0|            ssh_set_error(session, SSH_REQUEST_DENIED, "Unknown ssh option %d", type);
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
 1613|      0|            return -1;
 1614|      0|            break;
 1615|  77.7k|    }
 1616|       |
 1617|  77.7k|    return 0;
 1618|  77.7k|}
ssh_options_parse_config:
 2210|  8.64k|{
 2211|  8.64k|    char *expanded_filename = NULL;
 2212|  8.64k|    int r;
 2213|  8.64k|    FILE *fp = NULL;
 2214|       |
 2215|  8.64k|    if (session == NULL) {
  ------------------
  |  Branch (2215:9): [True: 0, False: 8.64k]
  ------------------
 2216|      0|        return -1;
 2217|      0|    }
 2218|  8.64k|    if (session->opts.originalhost == NULL) {
  ------------------
  |  Branch (2218:9): [True: 0, False: 8.64k]
  ------------------
 2219|      0|        ssh_set_error_invalid(session);
  ------------------
  |  |  322|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 2220|      0|        return -1;
 2221|      0|    }
 2222|       |
 2223|  8.64k|    if (session->opts.sshdir == NULL) {
  ------------------
  |  Branch (2223:9): [True: 8.64k, False: 0]
  ------------------
 2224|  8.64k|        r = ssh_options_set(session, SSH_OPTIONS_SSH_DIR, NULL);
 2225|  8.64k|        if (r < 0) {
  ------------------
  |  Branch (2225:13): [True: 0, False: 8.64k]
  ------------------
 2226|      0|            ssh_set_error_oom(session);
  ------------------
  |  |  318|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
 2227|      0|            return -1;
 2228|      0|        }
 2229|  8.64k|    }
 2230|       |
 2231|       |    /* set default filename */
 2232|  8.64k|    if (filename == NULL) {
  ------------------
  |  Branch (2232:9): [True: 8.64k, False: 0]
  ------------------
 2233|  8.64k|        expanded_filename = ssh_path_expand_escape(session, "%d/.ssh/config");
 2234|  8.64k|    } else {
 2235|      0|        expanded_filename = ssh_path_expand_escape(session, filename);
 2236|      0|    }
 2237|  8.64k|    if (expanded_filename == NULL) {
  ------------------
  |  Branch (2237:9): [True: 0, False: 8.64k]
  ------------------
 2238|      0|        return -1;
 2239|      0|    }
 2240|       |
 2241|  8.64k|    r = ssh_config_parse_file(session, expanded_filename);
 2242|  8.64k|    if (r < 0) {
  ------------------
  |  Branch (2242:9): [True: 0, False: 8.64k]
  ------------------
 2243|      0|        goto out;
 2244|      0|    }
 2245|  8.64k|    if (filename == NULL) {
  ------------------
  |  Branch (2245:9): [True: 8.64k, False: 0]
  ------------------
 2246|  8.64k|        fp = ssh_strict_fopen(GLOBAL_CLIENT_CONFIG, SSH_MAX_CONFIG_FILE_SIZE);
  ------------------
  |  |   21|  8.64k|#define GLOBAL_CLIENT_CONFIG "/etc/ssh/ssh_config"
  ------------------
                      fp = ssh_strict_fopen(GLOBAL_CLIENT_CONFIG, SSH_MAX_CONFIG_FILE_SIZE);
  ------------------
  |  |  528|  8.64k|#define SSH_MAX_CONFIG_FILE_SIZE 16 * 1024 * 1024
  ------------------
 2247|  8.64k|        if (fp != NULL) {
  ------------------
  |  Branch (2247:13): [True: 0, False: 8.64k]
  ------------------
 2248|      0|            filename = GLOBAL_CLIENT_CONFIG;
  ------------------
  |  |   21|      0|#define GLOBAL_CLIENT_CONFIG "/etc/ssh/ssh_config"
  ------------------
 2249|       |#ifdef USR_GLOBAL_CLIENT_CONFIG
 2250|       |        } else {
 2251|       |            fp = ssh_strict_fopen(USR_GLOBAL_CLIENT_CONFIG,
 2252|       |                                  SSH_MAX_CONFIG_FILE_SIZE);
 2253|       |            if (fp != NULL) {
 2254|       |                filename = USR_GLOBAL_CLIENT_CONFIG;
 2255|       |            }
 2256|       |#endif
 2257|      0|        }
 2258|       |
 2259|  8.64k|        if (fp) {
  ------------------
  |  Branch (2259:13): [True: 0, False: 8.64k]
  ------------------
 2260|      0|            SSH_LOG(SSH_LOG_PACKET,
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 2261|      0|                    "Reading configuration data from %s",
 2262|      0|                    filename);
 2263|      0|            r = ssh_config_parse(session, fp, true);
 2264|      0|            fclose(fp);
 2265|      0|        }
 2266|  8.64k|    }
 2267|       |
 2268|       |    /* Do not process the default configuration as part of connection again */
 2269|  8.64k|    session->opts.config_processed = true;
 2270|  8.64k|out:
 2271|  8.64k|    free(expanded_filename);
 2272|  8.64k|    return r;
 2273|  8.64k|}
ssh_options_apply:
 2286|  8.64k|{
 2287|  8.64k|    char *tmp = NULL;
 2288|  8.64k|    int rc;
 2289|       |
 2290|  8.64k|    if (session->opts.host != NULL) {
  ------------------
  |  Branch (2290:9): [True: 8.64k, False: 0]
  ------------------
 2291|  8.64k|        char *normalized_host = NULL;
 2292|  8.64k|        rc = ssh_normalize_loose_ip(session->opts.host, &normalized_host);
 2293|  8.64k|        if (rc == -1) {
  ------------------
  |  Branch (2293:13): [True: 0, False: 8.64k]
  ------------------
 2294|       |            /* Error (e.g. NULL input or OOM) — leave host as it is */
 2295|  8.64k|        } else if (rc == 0) {
  ------------------
  |  Branch (2295:20): [True: 0, False: 8.64k]
  ------------------
 2296|       |            /* Was a loose IP — use the normalized dotted-quad form */
 2297|      0|            SAFE_FREE(session->opts.host);
  ------------------
  |  |  373|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2298|      0|            session->opts.host = normalized_host;
 2299|  8.64k|        } else {
 2300|       |            /* rc == 1: not a loose IP — lowercase if it's not a strict IP */
 2301|  8.64k|            bool is_ip = ssh_is_ipaddr(session->opts.host);
 2302|  8.64k|            if (!is_ip) {
  ------------------
  |  Branch (2302:17): [True: 8.64k, False: 0]
  ------------------
 2303|  8.64k|                char *lower = ssh_lowercase(session->opts.host);
 2304|  8.64k|                if (lower != NULL) {
  ------------------
  |  Branch (2304:21): [True: 8.64k, False: 0]
  ------------------
 2305|  8.64k|                    SAFE_FREE(session->opts.host);
  ------------------
  |  |  373|  8.64k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 8.64k, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 8.64k]
  |  |  ------------------
  ------------------
 2306|  8.64k|                    session->opts.host = lower;
 2307|  8.64k|                }
 2308|  8.64k|            }
 2309|  8.64k|        }
 2310|  8.64k|    }
 2311|       |
 2312|  8.64k|    if (session->opts.sshdir == NULL) {
  ------------------
  |  Branch (2312:9): [True: 0, False: 8.64k]
  ------------------
 2313|      0|        rc = ssh_options_set(session, SSH_OPTIONS_SSH_DIR, NULL);
 2314|      0|        if (rc < 0) {
  ------------------
  |  Branch (2314:13): [True: 0, False: 0]
  ------------------
 2315|      0|            return -1;
 2316|      0|        }
 2317|      0|    }
 2318|       |
 2319|  8.64k|    if (session->opts.username == NULL) {
  ------------------
  |  Branch (2319:9): [True: 0, False: 8.64k]
  ------------------
 2320|      0|        rc = ssh_options_set(session, SSH_OPTIONS_USER, NULL);
 2321|      0|        if (rc < 0) {
  ------------------
  |  Branch (2321:13): [True: 0, False: 0]
  ------------------
 2322|      0|            return -1;
 2323|      0|        }
 2324|      0|    }
 2325|       |
 2326|  8.64k|    if (session->opts.config_hostname != NULL) {
  ------------------
  |  Branch (2326:9): [True: 0, False: 8.64k]
  ------------------
 2327|      0|        char *saved_host = NULL;
 2328|       |
 2329|      0|        tmp = ssh_path_expand_hostname(session, session->opts.config_hostname);
 2330|      0|        if (tmp == NULL) {
  ------------------
  |  Branch (2330:13): [True: 0, False: 0]
  ------------------
 2331|      0|            return -1;
 2332|      0|        }
 2333|      0|        if (session->opts.host != NULL) {
  ------------------
  |  Branch (2333:13): [True: 0, False: 0]
  ------------------
 2334|      0|            saved_host = strdup(session->opts.host);
 2335|      0|            if (saved_host == NULL) {
  ------------------
  |  Branch (2335:17): [True: 0, False: 0]
  ------------------
 2336|      0|                free(tmp);
 2337|      0|                ssh_set_error_oom(session);
  ------------------
  |  |  318|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
 2338|      0|                return -1;
 2339|      0|            }
 2340|      0|        }
 2341|      0|        session->opts.config_hostname_only = true;
 2342|      0|        rc = ssh_options_set(session, SSH_OPTIONS_HOST, tmp);
 2343|      0|        session->opts.config_hostname_only = false;
 2344|      0|        if (rc != SSH_OK) {
  ------------------
  |  |  316|      0|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (2344:13): [True: 0, False: 0]
  ------------------
 2345|       |            /* If HostName expansion leaves a literal '%', keep the current
 2346|       |             * host instead of treating the deferred HostName as fatal.
 2347|       |             */
 2348|      0|            if (strchr(tmp, '%') == NULL) {
  ------------------
  |  Branch (2348:17): [True: 0, False: 0]
  ------------------
 2349|      0|                SAFE_FREE(saved_host);
  ------------------
  |  |  373|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2350|      0|                free(tmp);
 2351|      0|                return -1;
 2352|      0|            }
 2353|      0|            SSH_LOG(SSH_LOG_WARN,
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 2354|      0|                    "HostName %s contains unknown expansion tokens and could "
 2355|      0|                    "not be applied; falling back to current host",
 2356|      0|                    tmp);
 2357|      0|            SAFE_FREE(session->opts.host);
  ------------------
  |  |  373|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2358|      0|            session->opts.host = saved_host;
 2359|      0|            saved_host = NULL;
 2360|      0|        }
 2361|      0|        SAFE_FREE(saved_host);
  ------------------
  |  |  373|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2362|      0|        free(tmp);
 2363|      0|        SAFE_FREE(session->opts.config_hostname);
  ------------------
  |  |  373|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2364|      0|    }
 2365|       |
 2366|  8.64k|    if ((session->opts.exp_flags & SSH_OPT_EXP_FLAG_KNOWNHOSTS) == 0) {
  ------------------
  |  |  115|  8.64k|#define SSH_OPT_EXP_FLAG_KNOWNHOSTS 0x1
  ------------------
  |  Branch (2366:9): [True: 8.64k, False: 0]
  ------------------
 2367|  8.64k|        if (session->opts.knownhosts == NULL) {
  ------------------
  |  Branch (2367:13): [True: 8.64k, False: 0]
  ------------------
 2368|  8.64k|            tmp = ssh_path_expand_escape(session, "%d/.ssh/known_hosts");
 2369|  8.64k|        } else {
 2370|      0|            tmp = ssh_path_expand_escape(session, session->opts.knownhosts);
 2371|      0|        }
 2372|  8.64k|        if (tmp == NULL) {
  ------------------
  |  Branch (2372:13): [True: 0, False: 8.64k]
  ------------------
 2373|      0|            return -1;
 2374|      0|        }
 2375|  8.64k|        free(session->opts.knownhosts);
 2376|  8.64k|        session->opts.knownhosts = tmp;
 2377|  8.64k|        session->opts.exp_flags |= SSH_OPT_EXP_FLAG_KNOWNHOSTS;
  ------------------
  |  |  115|  8.64k|#define SSH_OPT_EXP_FLAG_KNOWNHOSTS 0x1
  ------------------
 2378|  8.64k|    }
 2379|       |
 2380|  8.64k|    if ((session->opts.exp_flags & SSH_OPT_EXP_FLAG_GLOBAL_KNOWNHOSTS) == 0) {
  ------------------
  |  |  116|  8.64k|#define SSH_OPT_EXP_FLAG_GLOBAL_KNOWNHOSTS 0x2
  ------------------
  |  Branch (2380:9): [True: 8.64k, False: 0]
  ------------------
 2381|  8.64k|        if (session->opts.global_knownhosts == NULL) {
  ------------------
  |  Branch (2381:13): [True: 8.64k, False: 0]
  ------------------
 2382|  8.64k|            tmp = strdup(GLOBAL_CONF_DIR "/ssh_known_hosts");
  ------------------
  |  |   13|  8.64k|#define GLOBAL_CONF_DIR "/etc/ssh"
  ------------------
 2383|  8.64k|        } else {
 2384|      0|            tmp = ssh_path_expand_escape(session,
 2385|      0|                                         session->opts.global_knownhosts);
 2386|      0|        }
 2387|  8.64k|        if (tmp == NULL) {
  ------------------
  |  Branch (2387:13): [True: 0, False: 8.64k]
  ------------------
 2388|      0|            return -1;
 2389|      0|        }
 2390|  8.64k|        free(session->opts.global_knownhosts);
 2391|  8.64k|        session->opts.global_knownhosts = tmp;
 2392|  8.64k|        session->opts.exp_flags |= SSH_OPT_EXP_FLAG_GLOBAL_KNOWNHOSTS;
  ------------------
  |  |  116|  8.64k|#define SSH_OPT_EXP_FLAG_GLOBAL_KNOWNHOSTS 0x2
  ------------------
 2393|  8.64k|    }
 2394|       |
 2395|       |
 2396|  8.64k|    if ((session->opts.exp_flags & SSH_OPT_EXP_FLAG_PROXYCOMMAND) == 0) {
  ------------------
  |  |  117|  8.64k|#define SSH_OPT_EXP_FLAG_PROXYCOMMAND 0x4
  ------------------
  |  Branch (2396:9): [True: 8.64k, False: 0]
  ------------------
 2397|  8.64k|        if (session->opts.ProxyCommand != NULL) {
  ------------------
  |  Branch (2397:13): [True: 0, False: 8.64k]
  ------------------
 2398|      0|            char *p = NULL;
 2399|      0|            size_t plen = strlen(session->opts.ProxyCommand) +
 2400|      0|                          5 /* strlen("exec ") */;
 2401|       |
 2402|      0|            if (strncmp(session->opts.ProxyCommand, "exec ", 5) != 0) {
  ------------------
  |  Branch (2402:17): [True: 0, False: 0]
  ------------------
 2403|      0|                p = malloc(plen + 1 /* \0 */);
 2404|      0|                if (p == NULL) {
  ------------------
  |  Branch (2404:21): [True: 0, False: 0]
  ------------------
 2405|      0|                    return -1;
 2406|      0|                }
 2407|       |
 2408|      0|                rc = snprintf(p, plen + 1, "exec %s", session->opts.ProxyCommand);
 2409|      0|                if ((size_t)rc != plen) {
  ------------------
  |  Branch (2409:21): [True: 0, False: 0]
  ------------------
 2410|      0|                    free(p);
 2411|      0|                    return -1;
 2412|      0|                }
 2413|      0|                tmp = ssh_path_expand_escape(session, p);
 2414|      0|                free(p);
 2415|      0|            } else {
 2416|      0|                tmp = ssh_path_expand_escape(session,
 2417|      0|                                             session->opts.ProxyCommand);
 2418|      0|            }
 2419|       |
 2420|      0|            if (tmp == NULL) {
  ------------------
  |  Branch (2420:17): [True: 0, False: 0]
  ------------------
 2421|      0|                return -1;
 2422|      0|            }
 2423|      0|            free(session->opts.ProxyCommand);
 2424|      0|            session->opts.ProxyCommand = tmp;
 2425|      0|            session->opts.exp_flags |= SSH_OPT_EXP_FLAG_PROXYCOMMAND;
  ------------------
  |  |  117|      0|#define SSH_OPT_EXP_FLAG_PROXYCOMMAND 0x4
  ------------------
 2426|      0|        }
 2427|  8.64k|    }
 2428|       |
 2429|  8.64k|    if ((session->opts.exp_flags & SSH_OPT_EXP_FLAG_CONTROL_PATH) == 0) {
  ------------------
  |  |  119|  8.64k|#define SSH_OPT_EXP_FLAG_CONTROL_PATH 0x10
  ------------------
  |  Branch (2429:9): [True: 8.64k, False: 0]
  ------------------
 2430|  8.64k|        if (session->opts.control_path != NULL) {
  ------------------
  |  Branch (2430:13): [True: 0, False: 8.64k]
  ------------------
 2431|      0|            tmp = ssh_path_expand_escape(session, session->opts.control_path);
 2432|      0|            if (tmp == NULL) {
  ------------------
  |  Branch (2432:17): [True: 0, False: 0]
  ------------------
 2433|      0|                return -1;
 2434|      0|            }
 2435|      0|            free(session->opts.control_path);
 2436|      0|            session->opts.control_path = tmp;
 2437|      0|            session->opts.exp_flags |= SSH_OPT_EXP_FLAG_CONTROL_PATH;
  ------------------
  |  |  119|      0|#define SSH_OPT_EXP_FLAG_CONTROL_PATH 0x10
  ------------------
 2438|      0|        }
 2439|  8.64k|    }
 2440|       |
 2441|  8.64k|    for (tmp = ssh_list_pop_head(char *, session->opts.identity_non_exp);
  ------------------
  |  |  122|  8.64k|  ((type)_ssh_list_pop_head(ssh_list))
  ------------------
 2442|  34.5k|         tmp != NULL;
  ------------------
  |  Branch (2442:10): [True: 25.9k, False: 8.64k]
  ------------------
 2443|  25.9k|         tmp = ssh_list_pop_head(char *, session->opts.identity_non_exp)) {
  ------------------
  |  |  122|  25.9k|  ((type)_ssh_list_pop_head(ssh_list))
  ------------------
 2444|  25.9k|        char *id = tmp;
 2445|  25.9k|        if (strncmp(id, "pkcs11:", 6) != 0) {
  ------------------
  |  Branch (2445:13): [True: 25.9k, False: 0]
  ------------------
 2446|       |            /* PKCS#11 URIs are using percent-encoding so we can not mix
 2447|       |             * it with ssh expansion of ssh escape characters.
 2448|       |             */
 2449|  25.9k|            tmp = ssh_path_expand_escape(session, id);
 2450|  25.9k|            free(id);
 2451|  25.9k|            if (tmp == NULL) {
  ------------------
  |  Branch (2451:17): [True: 0, False: 25.9k]
  ------------------
 2452|      0|                return -1;
 2453|      0|            }
 2454|  25.9k|        }
 2455|       |
 2456|       |        /* use append to keep the order at first call and use prepend
 2457|       |         * to put anything that comes on the nth calls to the beginning */
 2458|  25.9k|        if (session->opts.exp_flags & SSH_OPT_EXP_FLAG_IDENTITY) {
  ------------------
  |  |  118|  25.9k|#define SSH_OPT_EXP_FLAG_IDENTITY 0x8
  ------------------
  |  Branch (2458:13): [True: 0, False: 25.9k]
  ------------------
 2459|      0|            rc = ssh_list_prepend(session->opts.identity, tmp);
 2460|  25.9k|        } else {
 2461|  25.9k|            rc = ssh_list_append(session->opts.identity, tmp);
 2462|  25.9k|        }
 2463|  25.9k|        if (rc != SSH_OK) {
  ------------------
  |  |  316|  25.9k|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (2463:13): [True: 0, False: 25.9k]
  ------------------
 2464|      0|            free(tmp);
 2465|      0|            return -1;
 2466|      0|        }
 2467|  25.9k|    }
 2468|  8.64k|    session->opts.exp_flags |= SSH_OPT_EXP_FLAG_IDENTITY;
  ------------------
  |  |  118|  8.64k|#define SSH_OPT_EXP_FLAG_IDENTITY 0x8
  ------------------
 2469|       |
 2470|  8.64k|    for (tmp = ssh_list_pop_head(char *, session->opts.certificate_non_exp);
  ------------------
  |  |  122|  8.64k|  ((type)_ssh_list_pop_head(ssh_list))
  ------------------
 2471|  8.64k|         tmp != NULL;
  ------------------
  |  Branch (2471:10): [True: 0, False: 8.64k]
  ------------------
 2472|  8.64k|         tmp = ssh_list_pop_head(char *, session->opts.certificate_non_exp)) {
  ------------------
  |  |  122|      0|  ((type)_ssh_list_pop_head(ssh_list))
  ------------------
 2473|      0|        char *id = tmp;
 2474|       |
 2475|      0|        tmp = ssh_path_expand_escape(session, id);
 2476|      0|        free(id);
 2477|      0|        if (tmp == NULL) {
  ------------------
  |  Branch (2477:13): [True: 0, False: 0]
  ------------------
 2478|      0|            return -1;
 2479|      0|        }
 2480|       |
 2481|      0|        rc = ssh_list_append(session->opts.certificate, tmp);
 2482|      0|        if (rc != SSH_OK) {
  ------------------
  |  |  316|      0|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (2482:13): [True: 0, False: 0]
  ------------------
 2483|      0|            free(tmp);
 2484|      0|            return -1;
 2485|      0|        }
 2486|      0|    }
 2487|       |
 2488|       |#ifdef WITH_GSSAPI
 2489|       |    if (session->opts.gssapi_key_exchange) {
 2490|       |        rc = ssh_gssapi_check_client_config(session);
 2491|       |        if (rc != SSH_OK) {
 2492|       |            SSH_LOG(SSH_LOG_WARN, "Disabled GSSAPI key exchange");
 2493|       |            session->opts.gssapi_key_exchange = false;
 2494|       |        }
 2495|       |    }
 2496|       |#endif
 2497|       |
 2498|  8.64k|    return 0;
 2499|  8.64k|}
ssh_bind_options_set:
 2725|  51.8k|{
 2726|  51.8k|    bool allowed;
 2727|  51.8k|    char *p = NULL, *q = NULL;
 2728|  51.8k|    const char *v = NULL;
 2729|  51.8k|    int i, rc;
 2730|  51.8k|    char **wanted_methods = sshbind->wanted_methods;
 2731|       |
 2732|  51.8k|    if (sshbind == NULL) {
  ------------------
  |  Branch (2732:9): [True: 0, False: 51.8k]
  ------------------
 2733|      0|        return -1;
 2734|      0|    }
 2735|       |
 2736|  51.8k|    switch (type) {
 2737|      0|    case SSH_BIND_OPTIONS_RSAKEY:
  ------------------
  |  Branch (2737:5): [True: 0, False: 51.8k]
  ------------------
 2738|      0|    case SSH_BIND_OPTIONS_ECDSAKEY:
  ------------------
  |  Branch (2738:5): [True: 0, False: 51.8k]
  ------------------
 2739|       |        /* deprecated */
 2740|  8.64k|    case SSH_BIND_OPTIONS_HOSTKEY:
  ------------------
  |  Branch (2740:5): [True: 8.64k, False: 43.2k]
  ------------------
 2741|  8.64k|    case SSH_BIND_OPTIONS_IMPORT_KEY:
  ------------------
  |  Branch (2741:5): [True: 0, False: 51.8k]
  ------------------
 2742|  8.64k|    case SSH_BIND_OPTIONS_IMPORT_KEY_STR:
  ------------------
  |  Branch (2742:5): [True: 0, False: 51.8k]
  ------------------
 2743|  8.64k|        if (value == NULL) {
  ------------------
  |  Branch (2743:13): [True: 0, False: 8.64k]
  ------------------
 2744|      0|            ssh_set_error_invalid(sshbind);
  ------------------
  |  |  322|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 2745|      0|            return -1;
 2746|  8.64k|        } else {
 2747|  8.64k|            int key_type;
 2748|  8.64k|            ssh_key *bind_key_loc = NULL;
 2749|  8.64k|            ssh_key key = NULL;
 2750|  8.64k|            char **bind_key_path_loc = NULL;
 2751|       |
 2752|  8.64k|            if (type == SSH_BIND_OPTIONS_IMPORT_KEY_STR) {
  ------------------
  |  Branch (2752:17): [True: 0, False: 8.64k]
  ------------------
 2753|      0|                const char *key_str = (const char *)value;
 2754|      0|                rc = ssh_pki_import_privkey_base64(key_str,
 2755|      0|                                                   NULL,
 2756|      0|                                                   NULL,
 2757|      0|                                                   NULL,
 2758|      0|                                                   &key);
 2759|      0|                if (rc == SSH_ERROR) {
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  |  Branch (2759:21): [True: 0, False: 0]
  ------------------
 2760|      0|                    ssh_set_error(sshbind,
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
 2761|      0|                                  SSH_FATAL,
 2762|      0|                                  "Failed to import key from buffer");
 2763|      0|                    return -1;
 2764|      0|                }
 2765|  8.64k|            } else if (type == SSH_BIND_OPTIONS_IMPORT_KEY) {
  ------------------
  |  Branch (2765:24): [True: 0, False: 8.64k]
  ------------------
 2766|      0|                key = (ssh_key)value;
 2767|  8.64k|            } else {
 2768|  8.64k|                rc = ssh_pki_import_privkey_file(value, NULL, NULL, NULL, &key);
 2769|  8.64k|                if (rc != SSH_OK) {
  ------------------
  |  |  316|  8.64k|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (2769:21): [True: 0, False: 8.64k]
  ------------------
 2770|      0|                    return -1;
 2771|      0|                }
 2772|  8.64k|            }
 2773|  8.64k|            allowed = ssh_bind_key_size_allowed(sshbind, key);
 2774|  8.64k|            if (!allowed) {
  ------------------
  |  Branch (2774:17): [True: 0, False: 8.64k]
  ------------------
 2775|      0|                ssh_set_error(sshbind,
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
 2776|      0|                              SSH_FATAL,
 2777|      0|                              "The host key size %d is too small.",
 2778|      0|                              ssh_key_size(key));
 2779|      0|                if (type != SSH_BIND_OPTIONS_IMPORT_KEY) {
  ------------------
  |  Branch (2779:21): [True: 0, False: 0]
  ------------------
 2780|      0|                    SSH_KEY_FREE(key);
  ------------------
  |  |  752|      0|    do { if ((x) != NULL) { ssh_key_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (752:14): [True: 0, False: 0]
  |  |  |  Branch (752:66): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2781|      0|                }
 2782|      0|                return -1;
 2783|      0|            }
 2784|  8.64k|            key_type = ssh_key_type(key);
 2785|  8.64k|            switch (key_type) {
 2786|      0|            case SSH_KEYTYPE_ECDSA_P256:
  ------------------
  |  Branch (2786:13): [True: 0, False: 8.64k]
  ------------------
 2787|      0|            case SSH_KEYTYPE_ECDSA_P384:
  ------------------
  |  Branch (2787:13): [True: 0, False: 8.64k]
  ------------------
 2788|      0|            case SSH_KEYTYPE_ECDSA_P521:
  ------------------
  |  Branch (2788:13): [True: 0, False: 8.64k]
  ------------------
 2789|      0|#ifdef HAVE_ECC
 2790|      0|                bind_key_loc = &sshbind->ecdsa;
 2791|      0|                bind_key_path_loc = &sshbind->ecdsakey;
 2792|       |#else
 2793|       |                ssh_set_error(sshbind,
 2794|       |                              SSH_FATAL,
 2795|       |                              "ECDSA key used and libssh compiled "
 2796|       |                              "without ECDSA support");
 2797|       |#endif
 2798|      0|                break;
 2799|      0|            case SSH_KEYTYPE_RSA:
  ------------------
  |  Branch (2799:13): [True: 0, False: 8.64k]
  ------------------
 2800|      0|                bind_key_loc = &sshbind->rsa;
 2801|      0|                bind_key_path_loc = &sshbind->rsakey;
 2802|      0|                break;
 2803|  8.64k|            case SSH_KEYTYPE_ED25519:
  ------------------
  |  Branch (2803:13): [True: 8.64k, False: 0]
  ------------------
 2804|  8.64k|                bind_key_loc = &sshbind->ed25519;
 2805|  8.64k|                bind_key_path_loc = &sshbind->ed25519key;
 2806|  8.64k|                break;
 2807|      0|            default:
  ------------------
  |  Branch (2807:13): [True: 0, False: 8.64k]
  ------------------
 2808|      0|                ssh_set_error(sshbind,
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
 2809|  8.64k|                              SSH_FATAL,
 2810|  8.64k|                              "Unsupported key type %d",
 2811|  8.64k|                              key_type);
 2812|  8.64k|            }
 2813|  8.64k|            if (type == SSH_BIND_OPTIONS_RSAKEY ||
  ------------------
  |  Branch (2813:17): [True: 0, False: 8.64k]
  ------------------
 2814|  8.64k|                type == SSH_BIND_OPTIONS_ECDSAKEY ||
  ------------------
  |  Branch (2814:17): [True: 0, False: 8.64k]
  ------------------
 2815|  8.64k|                type == SSH_BIND_OPTIONS_HOSTKEY) {
  ------------------
  |  Branch (2815:17): [True: 8.64k, False: 0]
  ------------------
 2816|  8.64k|                if (bind_key_loc == NULL) {
  ------------------
  |  Branch (2816:21): [True: 0, False: 8.64k]
  ------------------
 2817|      0|                    ssh_key_free(key);
 2818|      0|                    return -1;
 2819|      0|                }
 2820|       |                /* Set the location of the key on disk even though we don't
 2821|       |                   need it in case some other function wants it */
 2822|  8.64k|                rc = ssh_bind_set_key(sshbind, bind_key_path_loc, value);
 2823|  8.64k|                if (rc < 0) {
  ------------------
  |  Branch (2823:21): [True: 0, False: 8.64k]
  ------------------
 2824|      0|                    ssh_key_free(key);
 2825|      0|                    return -1;
 2826|      0|                }
 2827|  8.64k|            } else if (type == SSH_BIND_OPTIONS_IMPORT_KEY_STR) {
  ------------------
  |  Branch (2827:24): [True: 0, False: 0]
  ------------------
 2828|      0|                if (bind_key_loc == NULL) {
  ------------------
  |  Branch (2828:21): [True: 0, False: 0]
  ------------------
 2829|      0|                    ssh_key_free(key);
 2830|      0|                    return -1;
 2831|      0|                }
 2832|      0|            } else {
 2833|      0|                if (bind_key_loc == NULL) {
  ------------------
  |  Branch (2833:21): [True: 0, False: 0]
  ------------------
 2834|      0|                    return -1;
 2835|      0|                }
 2836|      0|            }
 2837|  8.64k|            ssh_key_free(*bind_key_loc);
 2838|  8.64k|            *bind_key_loc = key;
 2839|  8.64k|        }
 2840|  8.64k|        break;
 2841|  8.64k|    case SSH_BIND_OPTIONS_BINDADDR:
  ------------------
  |  Branch (2841:5): [True: 0, False: 51.8k]
  ------------------
 2842|      0|        if (value == NULL) {
  ------------------
  |  Branch (2842:13): [True: 0, False: 0]
  ------------------
 2843|      0|            ssh_set_error_invalid(sshbind);
  ------------------
  |  |  322|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 2844|      0|            return -1;
 2845|      0|        } else {
 2846|      0|            SAFE_FREE(sshbind->bindaddr);
  ------------------
  |  |  373|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2847|      0|            sshbind->bindaddr = strdup(value);
 2848|      0|            if (sshbind->bindaddr == NULL) {
  ------------------
  |  Branch (2848:17): [True: 0, False: 0]
  ------------------
 2849|      0|                ssh_set_error_oom(sshbind);
  ------------------
  |  |  318|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
 2850|      0|                return -1;
 2851|      0|            }
 2852|      0|        }
 2853|      0|        break;
 2854|      0|    case SSH_BIND_OPTIONS_BINDPORT:
  ------------------
  |  Branch (2854:5): [True: 0, False: 51.8k]
  ------------------
 2855|      0|        if (value == NULL) {
  ------------------
  |  Branch (2855:13): [True: 0, False: 0]
  ------------------
 2856|      0|            ssh_set_error_invalid(sshbind);
  ------------------
  |  |  322|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 2857|      0|            return -1;
 2858|      0|        } else {
 2859|      0|            int *x = (int *)value;
 2860|      0|            sshbind->bindport = *x & 0xffffU;
 2861|      0|        }
 2862|      0|        break;
 2863|      0|    case SSH_BIND_OPTIONS_BINDPORT_STR:
  ------------------
  |  Branch (2863:5): [True: 0, False: 51.8k]
  ------------------
 2864|      0|        if (value == NULL) {
  ------------------
  |  Branch (2864:13): [True: 0, False: 0]
  ------------------
 2865|      0|            sshbind->bindport = 22 & 0xffffU;
 2866|      0|        } else {
 2867|      0|            q = strdup(value);
 2868|      0|            if (q == NULL) {
  ------------------
  |  Branch (2868:17): [True: 0, False: 0]
  ------------------
 2869|      0|                ssh_set_error_oom(sshbind);
  ------------------
  |  |  318|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
 2870|      0|                return -1;
 2871|      0|            }
 2872|      0|            i = strtol(q, &p, 10);
 2873|      0|            if (q == p) {
  ------------------
  |  Branch (2873:17): [True: 0, False: 0]
  ------------------
 2874|      0|                SSH_LOG(SSH_LOG_DEBUG, "No bind port was parsed");
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 2875|      0|                SAFE_FREE(q);
  ------------------
  |  |  373|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2876|      0|                return -1;
 2877|      0|            }
 2878|      0|            SAFE_FREE(q);
  ------------------
  |  |  373|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2879|       |
 2880|      0|            sshbind->bindport = i & 0xffffU;
 2881|      0|        }
 2882|      0|        break;
 2883|      0|    case SSH_BIND_OPTIONS_LOG_VERBOSITY:
  ------------------
  |  Branch (2883:5): [True: 0, False: 51.8k]
  ------------------
 2884|      0|        if (value == NULL) {
  ------------------
  |  Branch (2884:13): [True: 0, False: 0]
  ------------------
 2885|      0|            ssh_set_error_invalid(sshbind);
  ------------------
  |  |  322|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 2886|      0|            return -1;
 2887|      0|        } else {
 2888|      0|            int *x = (int *)value;
 2889|      0|            ssh_set_log_level(*x & 0xffffU);
 2890|      0|        }
 2891|      0|        break;
 2892|      0|    case SSH_BIND_OPTIONS_LOG_VERBOSITY_STR:
  ------------------
  |  Branch (2892:5): [True: 0, False: 51.8k]
  ------------------
 2893|      0|        if (value == NULL) {
  ------------------
  |  Branch (2893:13): [True: 0, False: 0]
  ------------------
 2894|      0|            ssh_set_log_level(0);
 2895|      0|        } else {
 2896|      0|            q = strdup(value);
 2897|      0|            if (q == NULL) {
  ------------------
  |  Branch (2897:17): [True: 0, False: 0]
  ------------------
 2898|      0|                ssh_set_error_oom(sshbind);
  ------------------
  |  |  318|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
 2899|      0|                return -1;
 2900|      0|            }
 2901|      0|            i = strtol(q, &p, 10);
 2902|      0|            if (q == p) {
  ------------------
  |  Branch (2902:17): [True: 0, False: 0]
  ------------------
 2903|      0|                SSH_LOG(SSH_LOG_DEBUG, "No log verbositiy was parsed");
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 2904|      0|                SAFE_FREE(q);
  ------------------
  |  |  373|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2905|      0|                return -1;
 2906|      0|            }
 2907|      0|            SAFE_FREE(q);
  ------------------
  |  |  373|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2908|       |
 2909|      0|            ssh_set_log_level(i & 0xffffU);
 2910|      0|        }
 2911|      0|        break;
 2912|      0|    case SSH_BIND_OPTIONS_BANNER:
  ------------------
  |  Branch (2912:5): [True: 0, False: 51.8k]
  ------------------
 2913|      0|        if (value == NULL) {
  ------------------
  |  Branch (2913:13): [True: 0, False: 0]
  ------------------
 2914|      0|            ssh_set_error_invalid(sshbind);
  ------------------
  |  |  322|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 2915|      0|            return -1;
 2916|      0|        } else {
 2917|      0|            SAFE_FREE(sshbind->banner);
  ------------------
  |  |  373|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2918|      0|            sshbind->banner = strdup(value);
 2919|      0|            if (sshbind->banner == NULL) {
  ------------------
  |  Branch (2919:17): [True: 0, False: 0]
  ------------------
 2920|      0|                ssh_set_error_oom(sshbind);
  ------------------
  |  |  318|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
 2921|      0|                return -1;
 2922|      0|            }
 2923|      0|        }
 2924|      0|        break;
 2925|  8.64k|    case SSH_BIND_OPTIONS_CIPHERS_C_S:
  ------------------
  |  Branch (2925:5): [True: 8.64k, False: 43.2k]
  ------------------
 2926|  8.64k|        v = value;
 2927|  8.64k|        if (v == NULL || v[0] == '\0') {
  ------------------
  |  Branch (2927:13): [True: 0, False: 8.64k]
  |  Branch (2927:26): [True: 0, False: 8.64k]
  ------------------
 2928|      0|            ssh_set_error_invalid(sshbind);
  ------------------
  |  |  322|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 2929|      0|            return -1;
 2930|  8.64k|        } else {
 2931|  8.64k|            rc = ssh_bind_set_algo(sshbind,
 2932|  8.64k|                                   SSH_CRYPT_C_S,
 2933|  8.64k|                                   v,
 2934|  8.64k|                                   &wanted_methods[SSH_CRYPT_C_S]);
 2935|  8.64k|            if (rc < 0) {
  ------------------
  |  Branch (2935:17): [True: 0, False: 8.64k]
  ------------------
 2936|      0|                return -1;
 2937|      0|            }
 2938|  8.64k|        }
 2939|  8.64k|        break;
 2940|  8.64k|    case SSH_BIND_OPTIONS_CIPHERS_S_C:
  ------------------
  |  Branch (2940:5): [True: 8.64k, False: 43.2k]
  ------------------
 2941|  8.64k|        v = value;
 2942|  8.64k|        if (v == NULL || v[0] == '\0') {
  ------------------
  |  Branch (2942:13): [True: 0, False: 8.64k]
  |  Branch (2942:26): [True: 0, False: 8.64k]
  ------------------
 2943|      0|            ssh_set_error_invalid(sshbind);
  ------------------
  |  |  322|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 2944|      0|            return -1;
 2945|  8.64k|        } else {
 2946|  8.64k|            rc = ssh_bind_set_algo(sshbind,
 2947|  8.64k|                                   SSH_CRYPT_S_C,
 2948|  8.64k|                                   v,
 2949|  8.64k|                                   &wanted_methods[SSH_CRYPT_S_C]);
 2950|  8.64k|            if (rc < 0) {
  ------------------
  |  Branch (2950:17): [True: 0, False: 8.64k]
  ------------------
 2951|      0|                return -1;
 2952|      0|            }
 2953|  8.64k|        }
 2954|  8.64k|        break;
 2955|  8.64k|    case SSH_BIND_OPTIONS_KEY_EXCHANGE:
  ------------------
  |  Branch (2955:5): [True: 0, False: 51.8k]
  ------------------
 2956|      0|        v = value;
 2957|      0|        if (v == NULL || v[0] == '\0') {
  ------------------
  |  Branch (2957:13): [True: 0, False: 0]
  |  Branch (2957:26): [True: 0, False: 0]
  ------------------
 2958|      0|            ssh_set_error_invalid(sshbind);
  ------------------
  |  |  322|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 2959|      0|            return -1;
 2960|      0|        } else {
 2961|      0|            rc = ssh_bind_set_algo(sshbind,
 2962|      0|                                   SSH_KEX,
 2963|      0|                                   v,
 2964|      0|                                   &wanted_methods[SSH_KEX]);
 2965|      0|            if (rc < 0) {
  ------------------
  |  Branch (2965:17): [True: 0, False: 0]
  ------------------
 2966|      0|                return -1;
 2967|      0|            }
 2968|      0|        }
 2969|      0|        break;
 2970|  8.64k|    case SSH_BIND_OPTIONS_HMAC_C_S:
  ------------------
  |  Branch (2970:5): [True: 8.64k, False: 43.2k]
  ------------------
 2971|  8.64k|        v = value;
 2972|  8.64k|        if (v == NULL || v[0] == '\0') {
  ------------------
  |  Branch (2972:13): [True: 0, False: 8.64k]
  |  Branch (2972:26): [True: 0, False: 8.64k]
  ------------------
 2973|      0|            ssh_set_error_invalid(sshbind);
  ------------------
  |  |  322|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 2974|      0|            return -1;
 2975|  8.64k|        } else {
 2976|  8.64k|            rc = ssh_bind_set_algo(sshbind,
 2977|  8.64k|                                   SSH_MAC_C_S,
 2978|  8.64k|                                   v,
 2979|  8.64k|                                   &wanted_methods[SSH_MAC_C_S]);
 2980|  8.64k|            if (rc < 0) {
  ------------------
  |  Branch (2980:17): [True: 0, False: 8.64k]
  ------------------
 2981|      0|                return -1;
 2982|      0|            }
 2983|  8.64k|        }
 2984|  8.64k|        break;
 2985|  8.64k|    case SSH_BIND_OPTIONS_HMAC_S_C:
  ------------------
  |  Branch (2985:5): [True: 8.64k, False: 43.2k]
  ------------------
 2986|  8.64k|        v = value;
 2987|  8.64k|        if (v == NULL || v[0] == '\0') {
  ------------------
  |  Branch (2987:13): [True: 0, False: 8.64k]
  |  Branch (2987:26): [True: 0, False: 8.64k]
  ------------------
 2988|      0|            ssh_set_error_invalid(sshbind);
  ------------------
  |  |  322|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 2989|      0|            return -1;
 2990|  8.64k|        } else {
 2991|  8.64k|            rc = ssh_bind_set_algo(sshbind,
 2992|  8.64k|                                   SSH_MAC_S_C,
 2993|  8.64k|                                   v,
 2994|  8.64k|                                   &wanted_methods[SSH_MAC_S_C]);
 2995|  8.64k|            if (rc < 0) {
  ------------------
  |  Branch (2995:17): [True: 0, False: 8.64k]
  ------------------
 2996|      0|                return -1;
 2997|      0|            }
 2998|  8.64k|        }
 2999|  8.64k|        break;
 3000|  8.64k|    case SSH_BIND_OPTIONS_CONFIG_DIR:
  ------------------
  |  Branch (3000:5): [True: 0, False: 51.8k]
  ------------------
 3001|      0|        v = value;
 3002|      0|        SAFE_FREE(sshbind->config_dir);
  ------------------
  |  |  373|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
 3003|      0|        if (v == NULL) {
  ------------------
  |  Branch (3003:13): [True: 0, False: 0]
  ------------------
 3004|      0|            break;
 3005|      0|        } else if (v[0] == '\0') {
  ------------------
  |  Branch (3005:20): [True: 0, False: 0]
  ------------------
 3006|      0|            ssh_set_error_invalid(sshbind);
  ------------------
  |  |  322|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 3007|      0|            return -1;
 3008|      0|        } else {
 3009|      0|            sshbind->config_dir = ssh_path_expand_tilde(v);
 3010|      0|            if (sshbind->config_dir == NULL) {
  ------------------
  |  Branch (3010:17): [True: 0, False: 0]
  ------------------
 3011|      0|                ssh_set_error_oom(sshbind);
  ------------------
  |  |  318|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
 3012|      0|                return -1;
 3013|      0|            }
 3014|      0|        }
 3015|      0|        break;
 3016|      0|    case SSH_BIND_OPTIONS_PUBKEY_ACCEPTED_KEY_TYPES:
  ------------------
  |  Branch (3016:5): [True: 0, False: 51.8k]
  ------------------
 3017|      0|        v = value;
 3018|      0|        if (v == NULL || v[0] == '\0') {
  ------------------
  |  Branch (3018:13): [True: 0, False: 0]
  |  Branch (3018:26): [True: 0, False: 0]
  ------------------
 3019|      0|            ssh_set_error_invalid(sshbind);
  ------------------
  |  |  322|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 3020|      0|            return -1;
 3021|      0|        } else {
 3022|      0|            rc = ssh_bind_set_algo(sshbind,
 3023|      0|                                   SSH_HOSTKEYS,
 3024|      0|                                   v,
 3025|      0|                                   &sshbind->pubkey_accepted_key_types);
 3026|      0|            if (rc < 0) {
  ------------------
  |  Branch (3026:17): [True: 0, False: 0]
  ------------------
 3027|      0|                return -1;
 3028|      0|            }
 3029|      0|        }
 3030|      0|        break;
 3031|      0|    case SSH_BIND_OPTIONS_HOSTKEY_ALGORITHMS:
  ------------------
  |  Branch (3031:5): [True: 0, False: 51.8k]
  ------------------
 3032|      0|        v = value;
 3033|      0|        if (v == NULL || v[0] == '\0') {
  ------------------
  |  Branch (3033:13): [True: 0, False: 0]
  |  Branch (3033:26): [True: 0, False: 0]
  ------------------
 3034|      0|            ssh_set_error_invalid(sshbind);
  ------------------
  |  |  322|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 3035|      0|            return -1;
 3036|      0|        } else {
 3037|      0|            rc = ssh_bind_set_algo(sshbind,
 3038|      0|                                   SSH_HOSTKEYS,
 3039|      0|                                   v,
 3040|      0|                                   &wanted_methods[SSH_HOSTKEYS]);
 3041|      0|            if (rc < 0) {
  ------------------
  |  Branch (3041:17): [True: 0, False: 0]
  ------------------
 3042|      0|                return -1;
 3043|      0|            }
 3044|      0|        }
 3045|      0|        break;
 3046|  8.64k|    case SSH_BIND_OPTIONS_PROCESS_CONFIG:
  ------------------
  |  Branch (3046:5): [True: 8.64k, False: 43.2k]
  ------------------
 3047|  8.64k|        if (value == NULL) {
  ------------------
  |  Branch (3047:13): [True: 0, False: 8.64k]
  ------------------
 3048|      0|            ssh_set_error_invalid(sshbind);
  ------------------
  |  |  322|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 3049|      0|            return -1;
 3050|  8.64k|        } else {
 3051|  8.64k|            bool *x = (bool *)value;
 3052|  8.64k|            sshbind->config_processed = !(*x);
 3053|  8.64k|        }
 3054|  8.64k|        break;
 3055|  8.64k|    case SSH_BIND_OPTIONS_MODULI:
  ------------------
  |  Branch (3055:5): [True: 0, False: 51.8k]
  ------------------
 3056|      0|        if (value == NULL) {
  ------------------
  |  Branch (3056:13): [True: 0, False: 0]
  ------------------
 3057|      0|            ssh_set_error_invalid(sshbind);
  ------------------
  |  |  322|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 3058|      0|            return -1;
 3059|      0|        } else {
 3060|      0|            SAFE_FREE(sshbind->moduli_file);
  ------------------
  |  |  373|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
 3061|      0|            sshbind->moduli_file = strdup(value);
 3062|      0|            if (sshbind->moduli_file == NULL) {
  ------------------
  |  Branch (3062:17): [True: 0, False: 0]
  ------------------
 3063|      0|                ssh_set_error_oom(sshbind);
  ------------------
  |  |  318|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
 3064|      0|                return -1;
 3065|      0|            }
 3066|      0|        }
 3067|      0|        break;
 3068|      0|    case SSH_BIND_OPTIONS_RSA_MIN_SIZE:
  ------------------
  |  Branch (3068:5): [True: 0, False: 51.8k]
  ------------------
 3069|      0|        if (value == NULL) {
  ------------------
  |  Branch (3069:13): [True: 0, False: 0]
  ------------------
 3070|      0|            ssh_set_error_invalid(sshbind);
  ------------------
  |  |  322|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 3071|      0|            return -1;
 3072|      0|        } else {
 3073|      0|            int *x = (int *)value;
 3074|       |
 3075|      0|            if (*x < 0) {
  ------------------
  |  Branch (3075:17): [True: 0, False: 0]
  ------------------
 3076|      0|                ssh_set_error_invalid(sshbind);
  ------------------
  |  |  322|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 3077|      0|                return -1;
 3078|      0|            }
 3079|       |
 3080|       |            /* (*x == 0) is allowed as it is used to revert to default */
 3081|       |
 3082|      0|            if (*x > 0 && *x < RSA_MIN_KEY_SIZE) {
  ------------------
  |  |   49|      0|#define RSA_MIN_KEY_SIZE      1024
  ------------------
  |  Branch (3082:17): [True: 0, False: 0]
  |  Branch (3082:27): [True: 0, False: 0]
  ------------------
 3083|      0|                ssh_set_error(sshbind,
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
 3084|      0|                              SSH_REQUEST_DENIED,
 3085|      0|                              "The provided value (%d) for minimal RSA key "
 3086|      0|                              "size is too small. Use at least %d bits.",
 3087|      0|                              *x,
 3088|      0|                              RSA_MIN_KEY_SIZE);
 3089|      0|                return -1;
 3090|      0|            }
 3091|      0|            sshbind->rsa_min_size = *x;
 3092|      0|        }
 3093|      0|        break;
 3094|       |#ifdef WITH_GSSAPI
 3095|       |    case SSH_BIND_OPTIONS_GSSAPI_KEY_EXCHANGE:
 3096|       |        if (value == NULL) {
 3097|       |            ssh_set_error_invalid(sshbind);
 3098|       |            return -1;
 3099|       |        } else {
 3100|       |            bool *x = (bool *)value;
 3101|       |            sshbind->gssapi_key_exchange = *x;
 3102|       |        }
 3103|       |        break;
 3104|       |    case SSH_BIND_OPTIONS_GSSAPI_KEY_EXCHANGE_ALGS:
 3105|       |        if (value == NULL) {
 3106|       |            ssh_set_error_invalid(sshbind);
 3107|       |            return -1;
 3108|       |        } else {
 3109|       |            char *ret = NULL;
 3110|       |            SAFE_FREE(sshbind->gssapi_key_exchange_algs);
 3111|       |            ret = ssh_find_all_matching(GSSAPI_KEY_EXCHANGE_SUPPORTED, value);
 3112|       |            if (ret == NULL) {
 3113|       |                ssh_set_error(
 3114|       |                    sshbind,
 3115|       |                    SSH_REQUEST_DENIED,
 3116|       |                    "GSSAPI key exchange algorithms not supported or invalid");
 3117|       |                return -1;
 3118|       |            }
 3119|       |            sshbind->gssapi_key_exchange_algs = ret;
 3120|       |        }
 3121|       |        break;
 3122|       |#endif /* WITH_GSSAPI */
 3123|      0|    default:
  ------------------
  |  Branch (3123:5): [True: 0, False: 51.8k]
  ------------------
 3124|      0|        ssh_set_error(sshbind,
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
 3125|      0|                      SSH_REQUEST_DENIED,
 3126|      0|                      "Unknown ssh option %d",
 3127|      0|                      type);
 3128|      0|        return -1;
 3129|      0|        break;
 3130|  51.8k|    }
 3131|       |
 3132|  51.8k|    return 0;
 3133|  51.8k|}
options.c:ssh_bind_key_size_allowed:
 2505|  8.64k|{
 2506|  8.64k|    int min_size = 0;
 2507|       |
 2508|  8.64k|    switch (ssh_key_type(key)) {
 2509|      0|    case SSH_KEYTYPE_RSA:
  ------------------
  |  Branch (2509:5): [True: 0, False: 8.64k]
  ------------------
 2510|      0|    case SSH_KEYTYPE_RSA_CERT01:
  ------------------
  |  Branch (2510:5): [True: 0, False: 8.64k]
  ------------------
 2511|      0|        min_size = sshbind->rsa_min_size;
 2512|      0|        return ssh_key_size_allowed_rsa(min_size, key);
 2513|  8.64k|    default:
  ------------------
  |  Branch (2513:5): [True: 8.64k, False: 0]
  ------------------
 2514|       |        return true;
 2515|  8.64k|    }
 2516|  8.64k|}
options.c:ssh_bind_set_key:
 2524|  8.64k|{
 2525|  8.64k|    if (value == NULL) {
  ------------------
  |  Branch (2525:9): [True: 0, False: 8.64k]
  ------------------
 2526|      0|        ssh_set_error_invalid(sshbind);
  ------------------
  |  |  322|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 2527|      0|        return -1;
 2528|  8.64k|    } else {
 2529|  8.64k|        SAFE_FREE(*key_loc);
  ------------------
  |  |  373|  8.64k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 8.64k]
  |  |  |  Branch (373:71): [Folded, False: 8.64k]
  |  |  ------------------
  ------------------
 2530|  8.64k|        *key_loc = strdup(value);
 2531|  8.64k|        if (*key_loc == NULL) {
  ------------------
  |  Branch (2531:13): [True: 0, False: 8.64k]
  ------------------
 2532|      0|            ssh_set_error_oom(sshbind);
  ------------------
  |  |  318|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
 2533|      0|            return -1;
 2534|      0|        }
 2535|  8.64k|    }
 2536|  8.64k|    return 0;
 2537|  8.64k|}
options.c:ssh_bind_set_algo:
 2543|  34.5k|{
 2544|       |    /* sshbind is needed only for ssh_set_error which takes void*
 2545|       |     * the typecast is only to satisfy function parameter type */
 2546|  34.5k|    return ssh_options_set_algo((ssh_session)sshbind, algo, list, place);
 2547|  34.5k|}

ssh_packet_get_current_crypto:
 1159|  1.84M|{
 1160|  1.84M|    struct ssh_crypto_struct *crypto = NULL;
 1161|       |
 1162|  1.84M|    if (session == NULL) {
  ------------------
  |  Branch (1162:9): [True: 0, False: 1.84M]
  ------------------
 1163|      0|        return NULL;
 1164|      0|    }
 1165|       |
 1166|  1.84M|    if (session->current_crypto != NULL &&
  ------------------
  |  Branch (1166:9): [True: 1.59M, False: 248k]
  ------------------
 1167|  1.59M|        session->current_crypto->used & direction) {
  ------------------
  |  Branch (1167:9): [True: 1.59M, False: 18.4E]
  ------------------
 1168|  1.59M|        crypto = session->current_crypto;
 1169|  1.59M|    } else if (session->next_crypto != NULL &&
  ------------------
  |  Branch (1169:16): [True: 248k, False: 18.4E]
  ------------------
 1170|   248k|               session->next_crypto->used & direction) {
  ------------------
  |  Branch (1170:16): [True: 0, False: 248k]
  ------------------
 1171|      0|        crypto = session->next_crypto;
 1172|   248k|    } else {
 1173|   248k|        return NULL;
 1174|   248k|    }
 1175|       |
 1176|  1.59M|    switch (direction) {
  ------------------
  |  Branch (1176:13): [True: 1.59M, False: 18.4E]
  ------------------
 1177|  1.03M|    case SSH_DIRECTION_IN:
  ------------------
  |  Branch (1177:5): [True: 1.03M, False: 555k]
  ------------------
 1178|  1.03M|        if (crypto->in_cipher != NULL) {
  ------------------
  |  Branch (1178:13): [True: 1.03M, False: 18.4E]
  ------------------
 1179|  1.03M|            return crypto;
 1180|  1.03M|        }
 1181|  18.4E|        break;
 1182|  18.4E|    case SSH_DIRECTION_OUT:
  ------------------
  |  Branch (1182:5): [True: 334k, False: 1.26M]
  ------------------
 1183|   334k|        if (crypto->out_cipher != NULL) {
  ------------------
  |  Branch (1183:13): [True: 334k, False: 0]
  ------------------
 1184|   334k|            return crypto;
 1185|   334k|        }
 1186|      0|        break;
 1187|   221k|    case SSH_DIRECTION_BOTH:
  ------------------
  |  Branch (1187:5): [True: 221k, False: 1.37M]
  ------------------
 1188|   221k|        if (crypto->in_cipher != NULL &&
  ------------------
  |  Branch (1188:13): [True: 221k, False: 1]
  ------------------
 1189|   221k|            crypto->out_cipher != NULL) {
  ------------------
  |  Branch (1189:13): [True: 221k, False: 0]
  ------------------
 1190|   221k|            return crypto;
 1191|   221k|        }
 1192|  1.59M|    }
 1193|       |
 1194|      0|    return NULL;
 1195|  1.59M|}
ssh_packet_socket_callback:
 1286|   649k|{
 1287|   649k|    ssh_session session = (ssh_session)user;
 1288|   649k|    uint32_t blocksize = 8;
 1289|   649k|    uint32_t lenfield_blocksize = 8;
 1290|   649k|    size_t current_macsize = 0;
 1291|   649k|    uint8_t *ptr = NULL;
 1292|   649k|    ssize_t to_be_read;
 1293|   649k|    int rc;
 1294|   649k|    uint8_t *cleartext_packet = NULL;
 1295|   649k|    uint8_t *packet_second_block = NULL;
 1296|   649k|    uint8_t *mac = NULL;
 1297|   649k|    size_t packet_remaining, packet_offset;
 1298|   649k|    uint32_t packet_len, compsize, payloadsize;
 1299|   649k|    uint8_t padding;
 1300|   649k|    size_t processed = 0; /* number of bytes processed from the callback */
 1301|   649k|    enum ssh_packet_filter_result_e filter_result;
 1302|   649k|    struct ssh_crypto_struct *crypto = NULL;
 1303|   649k|    bool etm = false;
 1304|   649k|    uint32_t etm_packet_offset = 0;
 1305|   649k|    bool ok;
 1306|       |
 1307|   649k|    crypto = ssh_packet_get_current_crypto(session, SSH_DIRECTION_IN);
 1308|   649k|    if (crypto != NULL) {
  ------------------
  |  Branch (1308:9): [True: 556k, False: 93.0k]
  ------------------
 1309|   556k|        current_macsize = hmac_digest_len(crypto->in_hmac);
 1310|   556k|        blocksize = crypto->in_cipher->blocksize;
 1311|   556k|        lenfield_blocksize = crypto->in_cipher->lenfield_blocksize;
 1312|   556k|        etm = crypto->in_hmac_etm;
 1313|   556k|    }
 1314|       |
 1315|   649k|    if (etm) {
  ------------------
  |  Branch (1315:9): [True: 0, False: 649k]
  ------------------
 1316|       |        /* In EtM mode packet size is unencrypted. This means
 1317|       |         * we need to use this offset and set the block size
 1318|       |         * that is part of the encrypted part to 0.
 1319|       |         */
 1320|      0|        etm_packet_offset = sizeof(uint32_t);
 1321|      0|        lenfield_blocksize = 0;
 1322|   649k|    } else if (lenfield_blocksize == 0) {
  ------------------
  |  Branch (1322:16): [True: 556k, False: 93.0k]
  ------------------
 1323|   556k|        lenfield_blocksize = blocksize;
 1324|   556k|    }
 1325|   649k|    if (data == NULL) {
  ------------------
  |  Branch (1325:9): [True: 0, False: 649k]
  ------------------
 1326|      0|        goto error;
 1327|      0|    }
 1328|       |
 1329|   649k|    if (session->session_state == SSH_SESSION_STATE_ERROR) {
  ------------------
  |  Branch (1329:9): [True: 0, False: 649k]
  ------------------
 1330|      0|        goto error;
 1331|      0|    }
 1332|       |#ifdef DEBUG_PACKET
 1333|       |    SSH_LOG(SSH_LOG_PACKET,
 1334|       |            "rcv packet cb (len=%zu, state=%s)",
 1335|       |            receivedlen,
 1336|       |            session->packet_state == PACKET_STATE_INIT ?
 1337|       |                "INIT" :
 1338|       |                session->packet_state == PACKET_STATE_SIZEREAD ?
 1339|       |                    "SIZE_READ" :
 1340|       |                    session->packet_state == PACKET_STATE_PROCESSING ?
 1341|       |                    "PROCESSING" : "unknown");
 1342|       |#endif
 1343|   649k|    switch (session->packet_state) {
  ------------------
  |  Branch (1343:13): [True: 649k, False: 18.4E]
  ------------------
 1344|   328k|        case PACKET_STATE_INIT:
  ------------------
  |  Branch (1344:9): [True: 328k, False: 320k]
  ------------------
 1345|   328k|            if (receivedlen < lenfield_blocksize + etm_packet_offset) {
  ------------------
  |  Branch (1345:17): [True: 144k, False: 184k]
  ------------------
 1346|       |                /*
 1347|       |                 * We didn't receive enough data to read either at least one
 1348|       |                 * block size or the unencrypted length in EtM mode.
 1349|       |                 */
 1350|       |#ifdef DEBUG_PACKET
 1351|       |                SSH_LOG(SSH_LOG_PACKET,
 1352|       |                        "Waiting for more data (%zu < %u)",
 1353|       |                        receivedlen,
 1354|       |                        lenfield_blocksize);
 1355|       |#endif
 1356|   144k|                return 0;
 1357|   144k|            }
 1358|       |
 1359|   184k|            session->in_packet = (struct packet_struct) {
 1360|   184k|                .type = 0,
 1361|   184k|            };
 1362|       |
 1363|   184k|            if (session->in_buffer) {
  ------------------
  |  Branch (1363:17): [True: 184k, False: 18.4E]
  ------------------
 1364|   184k|                rc = ssh_buffer_reinit(session->in_buffer);
 1365|   184k|                if (rc < 0) {
  ------------------
  |  Branch (1365:21): [True: 0, False: 184k]
  ------------------
 1366|      0|                    goto error;
 1367|      0|                }
 1368|  18.4E|            } else {
 1369|  18.4E|                session->in_buffer = ssh_buffer_new();
 1370|  18.4E|                if (session->in_buffer == NULL) {
  ------------------
  |  Branch (1370:21): [True: 0, False: 18.4E]
  ------------------
 1371|      0|                    goto error;
 1372|      0|                }
 1373|  18.4E|            }
 1374|       |
 1375|   184k|            if (!etm) {
  ------------------
  |  Branch (1375:17): [True: 184k, False: 1]
  ------------------
 1376|   184k|                ptr = ssh_buffer_allocate(session->in_buffer,
 1377|   184k|                                          lenfield_blocksize);
 1378|   184k|                if (ptr == NULL) {
  ------------------
  |  Branch (1378:21): [True: 0, False: 184k]
  ------------------
 1379|      0|                    goto error;
 1380|      0|                }
 1381|   184k|                packet_len = ssh_packet_decrypt_len(session, ptr,
 1382|   184k|                                                    (uint8_t *)data);
 1383|   184k|                to_be_read = packet_len - lenfield_blocksize + sizeof(uint32_t);
 1384|   184k|            } else {
 1385|       |                /* Length is unencrypted in case of Encrypt-then-MAC */
 1386|      1|                packet_len = PULL_BE_U32(data, 0);
  ------------------
  |  |   75|      1|    ((((uint32_t)PULL_BE_U16(data, pos)) << 16) | (uint32_t)(PULL_BE_U16(data, (pos) + 2)))
  |  |  ------------------
  |  |  |  |   72|      1|    ((((uint16_t)(PULL_BE_U8(data, pos))) << 8) | (uint16_t)PULL_BE_U8(data, (pos) + 1))
  |  |  |  |  ------------------
  |  |  |  |  |  |   69|      1|    (_DATA_BYTE_CONST(data, pos))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   28|      1|    ((uint8_t)(((const uint8_t *)(data))[(pos)]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |                   ((((uint16_t)(PULL_BE_U8(data, pos))) << 8) | (uint16_t)PULL_BE_U8(data, (pos) + 1))
  |  |  |  |  ------------------
  |  |  |  |  |  |   69|      1|    (_DATA_BYTE_CONST(data, pos))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   28|      1|    ((uint8_t)(((const uint8_t *)(data))[(pos)]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                   ((((uint32_t)PULL_BE_U16(data, pos)) << 16) | (uint32_t)(PULL_BE_U16(data, (pos) + 2)))
  |  |  ------------------
  |  |  |  |   72|      1|    ((((uint16_t)(PULL_BE_U8(data, pos))) << 8) | (uint16_t)PULL_BE_U8(data, (pos) + 1))
  |  |  |  |  ------------------
  |  |  |  |  |  |   69|      1|    (_DATA_BYTE_CONST(data, pos))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   28|      1|    ((uint8_t)(((const uint8_t *)(data))[(pos)]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |                   ((((uint16_t)(PULL_BE_U8(data, pos))) << 8) | (uint16_t)PULL_BE_U8(data, (pos) + 1))
  |  |  |  |  ------------------
  |  |  |  |  |  |   69|      1|    (_DATA_BYTE_CONST(data, pos))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   28|      1|    ((uint8_t)(((const uint8_t *)(data))[(pos)]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1387|      1|                to_be_read = packet_len - etm_packet_offset;
 1388|      1|            }
 1389|       |
 1390|   184k|            processed += lenfield_blocksize + etm_packet_offset;
 1391|   184k|            if (packet_len > MAX_PACKET_LEN) {
  ------------------
  |  |  216|   184k|#define MAX_PACKET_LEN 262144
  ------------------
  |  Branch (1391:17): [True: 0, False: 184k]
  ------------------
 1392|      0|                ssh_set_error(session,
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
 1393|      0|                              SSH_FATAL,
 1394|      0|                              "read_packet(): Packet len too high(%" PRIu32 " %.4" PRIx32 ")",
 1395|      0|                              packet_len, packet_len);
 1396|      0|                goto error;
 1397|      0|            }
 1398|   184k|            if (to_be_read < 0) {
  ------------------
  |  Branch (1398:17): [True: 0, False: 184k]
  ------------------
 1399|       |                /* remote sshd sends invalid sizes? */
 1400|      0|                ssh_set_error(session,
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
 1401|      0|                              SSH_FATAL,
 1402|      0|                              "Given numbers of bytes left to be read < 0 (%zd)!",
 1403|      0|                              to_be_read);
 1404|      0|                goto error;
 1405|      0|            }
 1406|       |
 1407|   184k|            session->in_packet.len = packet_len;
 1408|   184k|            session->packet_state = PACKET_STATE_SIZEREAD;
 1409|   184k|            FALL_THROUGH;
  ------------------
  |  |  494|   184k|#  define FALL_THROUGH __attribute__ ((fallthrough))
  ------------------
 1410|   504k|        case PACKET_STATE_SIZEREAD:
  ------------------
  |  Branch (1410:9): [True: 320k, False: 328k]
  ------------------
 1411|   504k|            packet_len = session->in_packet.len;
 1412|   504k|            packet_offset = processed = lenfield_blocksize + etm_packet_offset;
 1413|   504k|            to_be_read = packet_len + sizeof(uint32_t) + current_macsize;
 1414|       |            /* if to_be_read is zero, the whole packet was blocksize bytes. */
 1415|   504k|            if (to_be_read != 0) {
  ------------------
  |  Branch (1415:17): [True: 504k, False: 18.4E]
  ------------------
 1416|   504k|                if (receivedlen < (unsigned long)to_be_read) {
  ------------------
  |  Branch (1416:21): [True: 320k, False: 184k]
  ------------------
 1417|       |                    /* give up, not enough data in buffer */
 1418|   320k|                    SSH_LOG(SSH_LOG_PACKET,
  ------------------
  |  |  281|   320k|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 1419|   320k|                            "packet: partial packet (read len) "
 1420|   320k|                            "[len=%" PRIu32 ", receivedlen=%zu, to_be_read=%zd]",
 1421|   320k|                            packet_len,
 1422|   320k|                            receivedlen,
 1423|   320k|                            to_be_read);
 1424|   320k|                    return 0;
 1425|   320k|                }
 1426|       |
 1427|   184k|                packet_second_block = (uint8_t*)data + packet_offset;
 1428|   184k|                processed = to_be_read - current_macsize;
 1429|   184k|            }
 1430|       |
 1431|   184k|            if (packet_offset - sizeof(uint32_t) > (size_t)packet_len) {
  ------------------
  |  Branch (1431:17): [True: 0, False: 184k]
  ------------------
 1432|      0|                ssh_set_error(session,
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
 1433|      0|                              SSH_FATAL,
 1434|      0|                              "Invalid packet length %" PRIu32 ", required %zu",
 1435|      0|                              packet_len,
 1436|      0|                              packet_offset + sizeof(uint32_t));
 1437|      0|                goto error;
 1438|      0|            }
 1439|       |
 1440|       |            /* remaining encrypted bytes from the packet, MAC not included */
 1441|   184k|            packet_remaining = packet_len - (packet_offset - sizeof(uint32_t));
 1442|   184k|            cleartext_packet = ssh_buffer_allocate(session->in_buffer,
 1443|   184k|                                                   (uint32_t)packet_remaining);
 1444|   184k|            if (cleartext_packet == NULL) {
  ------------------
  |  Branch (1444:17): [True: 0, False: 184k]
  ------------------
 1445|      0|                goto error;
 1446|      0|            }
 1447|       |
 1448|   184k|            if (packet_second_block != NULL) {
  ------------------
  |  Branch (1448:17): [True: 184k, False: 18.4E]
  ------------------
 1449|   184k|                if (crypto != NULL) {
  ------------------
  |  Branch (1449:21): [True: 132k, False: 51.8k]
  ------------------
 1450|   132k|                    mac = packet_second_block + packet_remaining;
 1451|       |
 1452|   132k|                    if (crypto->in_hmac != SSH_HMAC_NONE && etm) {
  ------------------
  |  Branch (1452:25): [True: 88.3k, False: 44.1k]
  |  Branch (1452:61): [True: 0, False: 88.3k]
  ------------------
 1453|      0|                        rc = ssh_packet_hmac_verify(session,
 1454|      0|                                                    data,
 1455|      0|                                                    processed,
 1456|      0|                                                    mac,
 1457|      0|                                                    crypto->in_hmac);
 1458|      0|                        if (rc < 0) {
  ------------------
  |  Branch (1458:29): [True: 0, False: 0]
  ------------------
 1459|      0|                            ssh_set_error(session, SSH_FATAL, "HMAC error");
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
 1460|      0|                            goto error;
 1461|      0|                        }
 1462|      0|                    }
 1463|       |                    /*
 1464|       |                     * Decrypt the packet. In case of EtM mode, the length is
 1465|       |                     * already known as it's unencrypted. In the other case,
 1466|       |                     * lenfield_blocksize bytes already have been decrypted.
 1467|       |                     */
 1468|   132k|                    if (packet_remaining > 0) {
  ------------------
  |  Branch (1468:25): [True: 113k, False: 19.4k]
  ------------------
 1469|   113k|                        rc = ssh_packet_decrypt(session,
 1470|   113k|                                                cleartext_packet,
 1471|   113k|                                                (uint8_t *)data,
 1472|   113k|                                                packet_offset,
 1473|   113k|                                                processed - packet_offset);
 1474|   113k|                        if (rc < 0) {
  ------------------
  |  Branch (1474:29): [True: 0, False: 113k]
  ------------------
 1475|      0|                            ssh_set_error(session,
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
 1476|      0|                                          SSH_FATAL,
 1477|      0|                                          "Decryption error");
 1478|      0|                            goto error;
 1479|      0|                        }
 1480|   113k|                    }
 1481|       |
 1482|   132k|                    if (crypto->in_hmac != SSH_HMAC_NONE && !etm) {
  ------------------
  |  Branch (1482:25): [True: 88.3k, False: 44.1k]
  |  Branch (1482:61): [True: 88.3k, False: 0]
  ------------------
 1483|  88.3k|                        ssh_buffer in = session->in_buffer;
 1484|  88.3k|                        rc = ssh_packet_hmac_verify(session,
 1485|  88.3k|                                                    ssh_buffer_get(in),
 1486|  88.3k|                                                    ssh_buffer_get_len(in),
 1487|  88.3k|                                                    mac,
 1488|  88.3k|                                                    crypto->in_hmac);
 1489|  88.3k|                        if (rc < 0) {
  ------------------
  |  Branch (1489:29): [True: 0, False: 88.3k]
  ------------------
 1490|      0|                            ssh_set_error(session, SSH_FATAL, "HMAC error");
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
 1491|      0|                            goto error;
 1492|      0|                        }
 1493|  88.3k|                    }
 1494|   132k|                    processed += current_macsize;
 1495|   132k|                } else {
 1496|  51.8k|                    memcpy(cleartext_packet,
 1497|  51.8k|                           packet_second_block,
 1498|  51.8k|                           packet_remaining);
 1499|  51.8k|                }
 1500|   184k|            }
 1501|       |
 1502|   184k|#ifdef WITH_PCAP
 1503|   184k|            if (session->pcap_ctx != NULL) {
  ------------------
  |  Branch (1503:17): [True: 0, False: 184k]
  ------------------
 1504|      0|                ssh_pcap_context_write(session->pcap_ctx,
 1505|      0|                                       SSH_PCAP_DIR_IN,
 1506|      0|                                       ssh_buffer_get(session->in_buffer),
 1507|      0|                                       ssh_buffer_get_len(session->in_buffer),
 1508|      0|                                       ssh_buffer_get_len(session->in_buffer));
 1509|      0|            }
 1510|   184k|#endif
 1511|       |
 1512|   184k|            if (!etm) {
  ------------------
  |  Branch (1512:17): [True: 184k, False: 18.4E]
  ------------------
 1513|       |                /* skip the size field which has been processed before */
 1514|   184k|                ssh_buffer_pass_bytes(session->in_buffer, sizeof(uint32_t));
 1515|   184k|            }
 1516|       |
 1517|   184k|            rc = ssh_buffer_get_u8(session->in_buffer, &padding);
 1518|   184k|            if (rc == 0) {
  ------------------
  |  Branch (1518:17): [True: 0, False: 184k]
  ------------------
 1519|      0|                ssh_set_error(session,
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
 1520|      0|                              SSH_FATAL,
 1521|      0|                              "Packet too short to read padding");
 1522|      0|                goto error;
 1523|      0|            }
 1524|       |
 1525|   184k|            if (padding > ssh_buffer_get_len(session->in_buffer)) {
  ------------------
  |  Branch (1525:17): [True: 0, False: 184k]
  ------------------
 1526|      0|                ssh_set_error(session,
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
 1527|      0|                              SSH_FATAL,
 1528|      0|                              "Invalid padding: %d (%" PRIu32 " left)",
 1529|      0|                              padding,
 1530|      0|                              ssh_buffer_get_len(session->in_buffer));
 1531|      0|                goto error;
 1532|      0|            }
 1533|   184k|            ssh_buffer_pass_bytes_end(session->in_buffer, padding);
 1534|   184k|            compsize = ssh_buffer_get_len(session->in_buffer);
 1535|       |
 1536|   184k|            if (crypto && crypto->do_compress_in &&
  ------------------
  |  Branch (1536:17): [True: 132k, False: 51.8k]
  |  Branch (1536:27): [True: 0, False: 132k]
  ------------------
 1537|      0|                ssh_buffer_get_len(session->in_buffer) > 0) {
  ------------------
  |  Branch (1537:17): [True: 0, False: 0]
  ------------------
 1538|      0|                rc = decompress_buffer(session, session->in_buffer,
 1539|      0|                                       MAX_PACKET_LEN);
  ------------------
  |  |  216|      0|#define MAX_PACKET_LEN 262144
  ------------------
 1540|      0|                if (rc < 0) {
  ------------------
  |  Branch (1540:21): [True: 0, False: 0]
  ------------------
 1541|      0|                    goto error;
 1542|      0|                }
 1543|      0|            }
 1544|   184k|            payloadsize = ssh_buffer_get_len(session->in_buffer);
 1545|   184k|            if (session->recv_seq == UINT32_MAX) {
  ------------------
  |  Branch (1545:17): [True: 0, False: 184k]
  ------------------
 1546|       |                /* Overflowing sequence numbers is always fishy */
 1547|      0|                if (crypto == NULL) {
  ------------------
  |  Branch (1547:21): [True: 0, False: 0]
  ------------------
 1548|       |                    /* don't allow sequence number overflow when unencrypted */
 1549|      0|                    ssh_set_error(session,
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
 1550|      0|                                  SSH_FATAL,
 1551|      0|                                  "Incoming sequence number overflow");
 1552|      0|                    goto error;
 1553|      0|                } else {
 1554|      0|                    SSH_LOG(SSH_LOG_WARNING,
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 1555|      0|                            "Incoming sequence number overflow");
 1556|      0|                }
 1557|      0|            }
 1558|   184k|            session->recv_seq++;
 1559|   184k|            if (crypto != NULL) {
  ------------------
  |  Branch (1559:17): [True: 132k, False: 51.8k]
  ------------------
 1560|   132k|                struct ssh_cipher_struct *cipher = NULL;
 1561|       |
 1562|   132k|                cipher = crypto->in_cipher;
 1563|   132k|                cipher->packets++;
 1564|   132k|                cipher->blocks += payloadsize / cipher->blocksize;
 1565|   132k|            }
 1566|   184k|            if (session->raw_counter != NULL) {
  ------------------
  |  Branch (1566:17): [True: 0, False: 184k]
  ------------------
 1567|      0|                session->raw_counter->in_bytes += payloadsize;
 1568|      0|                session->raw_counter->in_packets++;
 1569|      0|            }
 1570|       |
 1571|       |            /*
 1572|       |             * We don't want to rewrite a new packet while still executing the
 1573|       |             * packet callbacks
 1574|       |             */
 1575|   184k|            session->packet_state = PACKET_STATE_PROCESSING;
 1576|   184k|            ssh_packet_parse_type(session);
 1577|   184k|            SSH_LOG(SSH_LOG_PACKET,
  ------------------
  |  |  281|   184k|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 1578|   184k|                    "packet: read type %hhd [len=%" PRIu32 ",padding=%hhd,"
 1579|   184k|                    "comp=%" PRIu32 ",payload=%" PRIu32 "]",
 1580|   184k|                    session->in_packet.type, packet_len, padding, compsize,
 1581|   184k|                    payloadsize);
 1582|   184k|            if (crypto == NULL) {
  ------------------
  |  Branch (1582:17): [True: 51.8k, False: 132k]
  ------------------
 1583|       |                /* In strict kex, only a few packets are allowed. Taint the session
 1584|       |                 * if we received packets that are normally allowed but to be
 1585|       |                 * refused if we are in strict kex when KEX is over.
 1586|       |                 */
 1587|  51.8k|                uint8_t type = session->in_packet.type;
 1588|       |
 1589|  51.8k|                if (type != SSH2_MSG_KEXINIT && type != SSH2_MSG_NEWKEYS &&
  ------------------
  |  |   12|   103k|#define SSH2_MSG_KEXINIT	 20
  ------------------
                              if (type != SSH2_MSG_KEXINIT && type != SSH2_MSG_NEWKEYS &&
  ------------------
  |  |   13|  86.3k|#define SSH2_MSG_NEWKEYS 21
  ------------------
  |  Branch (1589:21): [True: 34.5k, False: 17.2k]
  |  Branch (1589:49): [True: 17.2k, False: 17.2k]
  ------------------
 1590|  17.2k|                    (type < SSH2_MSG_KEXDH_INIT ||
  ------------------
  |  |   15|  34.5k|#define SSH2_MSG_KEXDH_INIT 30
  ------------------
  |  Branch (1590:22): [True: 0, False: 17.2k]
  ------------------
 1591|  17.2k|                     type > SSH2_MSG_KEX_DH_GEX_REQUEST)) {
  ------------------
  |  |   26|  17.2k|#define SSH2_MSG_KEX_DH_GEX_REQUEST 34
  ------------------
  |  Branch (1591:22): [True: 0, False: 17.2k]
  ------------------
 1592|      0|                    session->flags |= SSH_SESSION_FLAG_KEX_TAINTED;
  ------------------
  |  |   92|      0|#define SSH_SESSION_FLAG_KEX_TAINTED 0x0020
  ------------------
 1593|      0|                }
 1594|  51.8k|            }
 1595|       |            /* Check if the packet is expected */
 1596|   184k|            filter_result = ssh_packet_incoming_filter(session);
 1597|       |
 1598|   184k|            switch (filter_result) {
  ------------------
  |  Branch (1598:21): [True: 184k, False: 18.4E]
  ------------------
 1599|   184k|            case SSH_PACKET_ALLOWED:
  ------------------
  |  Branch (1599:13): [True: 184k, False: 18.4E]
  ------------------
 1600|       |                /* Execute callbacks */
 1601|   184k|                ssh_packet_process(session, session->in_packet.type);
 1602|   184k|                break;
 1603|      0|            case SSH_PACKET_DENIED:
  ------------------
  |  Branch (1603:13): [True: 0, False: 184k]
  ------------------
 1604|      0|                ssh_set_error(session,
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
 1605|      0|                              SSH_FATAL,
 1606|      0|                              "Packet filter: rejected packet (type %d)",
 1607|      0|                              session->in_packet.type);
 1608|      0|                goto error;
 1609|      0|            case SSH_PACKET_UNKNOWN:
  ------------------
  |  Branch (1609:13): [True: 0, False: 184k]
  ------------------
 1610|      0|                if (crypto == NULL) {
  ------------------
  |  Branch (1610:21): [True: 0, False: 0]
  ------------------
 1611|      0|                    session->flags |= SSH_SESSION_FLAG_KEX_TAINTED;
  ------------------
  |  |   92|      0|#define SSH_SESSION_FLAG_KEX_TAINTED 0x0020
  ------------------
 1612|      0|                }
 1613|      0|                ssh_packet_send_unimplemented(session, session->recv_seq - 1);
 1614|      0|                break;
 1615|   184k|            }
 1616|       |
 1617|   184k|            session->packet_state = PACKET_STATE_INIT;
 1618|   184k|            if (processed < receivedlen) {
  ------------------
  |  Branch (1618:17): [True: 54.9k, False: 129k]
  ------------------
 1619|  54.9k|                SSH_LOG(SSH_LOG_PACKET,
  ------------------
  |  |  281|  54.9k|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 1620|  54.9k|                        "packet: %zu bytes still remaining in socket buffer "
 1621|  54.9k|                        "after processing",
 1622|  54.9k|                        receivedlen-processed);
 1623|  54.9k|            }
 1624|       |
 1625|   184k|            ok = ssh_packet_need_rekey(session, 0);
 1626|   184k|            if (ok) {
  ------------------
  |  Branch (1626:17): [True: 0, False: 184k]
  ------------------
 1627|      0|                SSH_LOG(SSH_LOG_PACKET, "Incoming packet triggered rekey");
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 1628|      0|                rc = ssh_send_rekex(session);
 1629|      0|                if (rc != SSH_OK) {
  ------------------
  |  |  316|      0|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (1629:21): [True: 0, False: 0]
  ------------------
 1630|      0|                    SSH_LOG(SSH_LOG_PACKET, "Rekey failed: rc = %d", rc);
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 1631|      0|                    goto error;
 1632|      0|                }
 1633|      0|            }
 1634|       |
 1635|   184k|            return processed;
 1636|      0|        case PACKET_STATE_PROCESSING:
  ------------------
  |  Branch (1636:9): [True: 0, False: 649k]
  ------------------
 1637|      0|            SSH_LOG(SSH_LOG_PACKET, "Nested packet processing. Delaying.");
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 1638|      0|            return 0;
 1639|   649k|    }
 1640|       |
 1641|      0|    ssh_set_error(session,
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
 1642|      0|                  SSH_FATAL,
 1643|      0|                  "Invalid state into packet_read2(): %d",
 1644|      0|                  session->packet_state);
 1645|       |
 1646|      0|error:
 1647|      0|    session->session_state = SSH_SESSION_STATE_ERROR;
 1648|      0|    SSH_LOG(SSH_LOG_PACKET, "Packet: processed %zu bytes", processed);
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 1649|      0|    return processed;
 1650|      0|}
ssh_packet_register_socket_callback:
 1677|  17.2k|{
 1678|  17.2k|    struct ssh_socket_callbacks_struct *callbacks = &session->socket_callbacks;
 1679|       |
 1680|  17.2k|    callbacks->data = ssh_packet_socket_callback;
 1681|       |    callbacks->connected = NULL;
 1682|  17.2k|    callbacks->controlflow = ssh_packet_socket_controlflow_callback;
 1683|  17.2k|    callbacks->userdata = session;
 1684|  17.2k|    ssh_socket_set_callbacks(s, callbacks);
 1685|  17.2k|}
ssh_packet_set_callbacks:
 1692|  34.5k|{
 1693|  34.5k|    if (session->packet_callbacks == NULL) {
  ------------------
  |  Branch (1693:9): [True: 17.2k, False: 17.2k]
  ------------------
 1694|  17.2k|        session->packet_callbacks = ssh_list_new();
 1695|  17.2k|        if (session->packet_callbacks == NULL) {
  ------------------
  |  Branch (1695:13): [True: 0, False: 17.2k]
  ------------------
 1696|      0|            ssh_set_error_oom(session);
  ------------------
  |  |  318|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
 1697|      0|            return;
 1698|      0|        }
 1699|  17.2k|    }
 1700|  34.5k|    ssh_list_append(session->packet_callbacks, callbacks);
 1701|  34.5k|}
ssh_packet_remove_callbacks:
 1708|  17.2k|{
 1709|  17.2k|    struct ssh_iterator *it = NULL;
 1710|       |
 1711|  17.2k|    it = ssh_list_find(session->packet_callbacks, callbacks);
 1712|  17.2k|    if (it != NULL) {
  ------------------
  |  Branch (1712:9): [True: 17.2k, False: 0]
  ------------------
 1713|  17.2k|        ssh_list_remove(session->packet_callbacks, it);
 1714|  17.2k|    }
 1715|  17.2k|}
ssh_packet_set_default_callbacks:
 1721|  17.2k|{
 1722|  17.2k|    struct ssh_packet_callbacks_struct *c = &session->default_packet_callbacks;
 1723|       |
 1724|  17.2k|    c->start = 1;
 1725|  17.2k|    c->n_callbacks = sizeof(default_packet_handlers) / sizeof(ssh_packet_callback);
 1726|  17.2k|    c->user = session;
 1727|  17.2k|    c->callbacks = default_packet_handlers;
 1728|  17.2k|    ssh_packet_set_callbacks(session, c);
 1729|  17.2k|}
ssh_packet_process:
 1736|   184k|{
 1737|   184k|    struct ssh_iterator *i = NULL;
 1738|   184k|    int rc = SSH_PACKET_NOT_USED;
  ------------------
  |  |  640|   184k|#define SSH_PACKET_NOT_USED 2
  ------------------
 1739|   184k|    ssh_packet_callbacks cb;
 1740|       |
 1741|   184k|    SSH_LOG(SSH_LOG_PACKET, "Dispatching handler for packet type %d", type);
  ------------------
  |  |  281|   184k|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 1742|   184k|    if (session->packet_callbacks == NULL) {
  ------------------
  |  Branch (1742:9): [True: 0, False: 184k]
  ------------------
 1743|      0|        SSH_LOG(SSH_LOG_RARE, "Packet callback is not initialized !");
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 1744|      0|        return;
 1745|      0|    }
 1746|       |
 1747|   184k|    i = ssh_list_get_iterator(session->packet_callbacks);
 1748|   201k|    while (i != NULL) {
  ------------------
  |  Branch (1748:12): [True: 201k, False: 18.4E]
  ------------------
 1749|   201k|        cb = ssh_iterator_value(ssh_packet_callbacks, i);
  ------------------
  |  |  114|   201k|  ((type)((iterator)->data))
  ------------------
 1750|   201k|        i = i->next;
 1751|       |
 1752|   201k|        if (!cb) {
  ------------------
  |  Branch (1752:13): [True: 0, False: 201k]
  ------------------
 1753|      0|            continue;
 1754|      0|        }
 1755|       |
 1756|   201k|        if (cb->start > type) {
  ------------------
  |  Branch (1756:13): [True: 0, False: 201k]
  ------------------
 1757|      0|            continue;
 1758|      0|        }
 1759|       |
 1760|   201k|        if (cb->start + cb->n_callbacks <= type) {
  ------------------
  |  Branch (1760:13): [True: 0, False: 201k]
  ------------------
 1761|      0|            continue;
 1762|      0|        }
 1763|       |
 1764|   201k|        if (cb->callbacks[type - cb->start] == NULL) {
  ------------------
  |  Branch (1764:13): [True: 8.64k, False: 192k]
  ------------------
 1765|  8.64k|            continue;
 1766|  8.64k|        }
 1767|       |
 1768|   192k|        rc = cb->callbacks[type - cb->start](session, type, session->in_buffer,
 1769|   192k|                                             cb->user);
 1770|   192k|        if (rc == SSH_PACKET_USED) {
  ------------------
  |  |  637|   192k|#define SSH_PACKET_USED 1
  ------------------
  |  Branch (1770:13): [True: 184k, False: 8.62k]
  ------------------
 1771|   184k|            break;
 1772|   184k|        }
 1773|   192k|    }
 1774|       |
 1775|   184k|    if (rc == SSH_PACKET_NOT_USED) {
  ------------------
  |  |  640|   184k|#define SSH_PACKET_NOT_USED 2
  ------------------
  |  Branch (1775:9): [True: 0, False: 184k]
  ------------------
 1776|      0|        SSH_LOG(SSH_LOG_RARE, "Couldn't do anything with packet type %d", type);
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 1777|      0|        rc = ssh_packet_send_unimplemented(session, session->recv_seq - 1);
 1778|      0|        if (rc != SSH_OK) {
  ------------------
  |  |  316|      0|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (1778:13): [True: 0, False: 0]
  ------------------
 1779|      0|            SSH_LOG(SSH_LOG_RARE, "Failed to send unimplemented: %s",
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 1780|      0|                    ssh_get_error(session));
 1781|      0|        }
 1782|      0|        if (session->current_crypto == NULL) {
  ------------------
  |  Branch (1782:13): [True: 0, False: 0]
  ------------------
 1783|      0|            session->flags |= SSH_SESSION_FLAG_KEX_TAINTED;
  ------------------
  |  |   92|      0|#define SSH_SESSION_FLAG_KEX_TAINTED 0x0020
  ------------------
 1784|      0|        }
 1785|      0|    }
 1786|   184k|}
ssh_packet_send_newkeys:
 1794|  17.2k|{
 1795|  17.2k|    int rc;
 1796|       |
 1797|       |    /* Send the MSG_NEWKEYS */
 1798|  17.2k|    rc = ssh_buffer_add_u8(session->out_buffer, SSH2_MSG_NEWKEYS);
  ------------------
  |  |   13|  17.2k|#define SSH2_MSG_NEWKEYS 21
  ------------------
 1799|  17.2k|    if (rc < 0) {
  ------------------
  |  Branch (1799:9): [True: 0, False: 17.2k]
  ------------------
 1800|      0|        return rc;
 1801|      0|    }
 1802|       |
 1803|  17.2k|    rc = ssh_packet_send(session);
 1804|  17.2k|    if (rc == SSH_ERROR) {
  ------------------
  |  |  317|  17.2k|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  |  Branch (1804:9): [True: 0, False: 17.2k]
  ------------------
 1805|      0|        return rc;
 1806|      0|    }
 1807|  17.2k|    SSH_LOG(SSH_LOG_DEBUG, "SSH_MSG_NEWKEYS sent");
  ------------------
  |  |  281|  17.2k|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 1808|  17.2k|    return rc;
 1809|  17.2k|}
ssh_packet_parse_type:
 1860|   184k|{
 1861|   184k|    session->in_packet = (struct packet_struct) {
 1862|   184k|        .type = 0,
 1863|   184k|    };
 1864|       |
 1865|   184k|    if (session->in_buffer == NULL) {
  ------------------
  |  Branch (1865:9): [True: 0, False: 184k]
  ------------------
 1866|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 1867|      0|    }
 1868|       |
 1869|   184k|    if (ssh_buffer_get_u8(session->in_buffer, &session->in_packet.type) == 0) {
  ------------------
  |  Branch (1869:9): [True: 0, False: 184k]
  ------------------
 1870|      0|        ssh_set_error(session, SSH_FATAL, "Packet too short to read type");
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
 1871|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 1872|      0|    }
 1873|       |
 1874|   184k|    session->in_packet.valid = 1;
 1875|       |
 1876|   184k|    return SSH_OK;
  ------------------
  |  |  316|   184k|#define SSH_OK 0     /* No error */
  ------------------
 1877|   184k|}
ssh_packet_send:
 2065|   218k|{
 2066|   218k|    uint32_t payloadsize;
 2067|   218k|    uint8_t type, *payload;
 2068|   218k|    bool need_rekey, in_rekey;
 2069|   218k|    int rc;
 2070|       |
 2071|   218k|    if (session->socket == NULL || !ssh_socket_is_open(session->socket)) {
  ------------------
  |  Branch (2071:9): [True: 0, False: 218k]
  |  Branch (2071:36): [True: 8.64k, False: 210k]
  ------------------
 2072|  8.64k|        ssh_buffer_reinit(session->out_buffer);
 2073|  8.64k|        return SSH_ERROR;
  ------------------
  |  |  317|  8.64k|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 2074|  8.64k|    }
 2075|       |
 2076|   210k|    payloadsize = ssh_buffer_get_len(session->out_buffer);
 2077|   210k|    if (payloadsize < 1) {
  ------------------
  |  Branch (2077:9): [True: 0, False: 210k]
  ------------------
 2078|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 2079|      0|    }
 2080|       |
 2081|   210k|    payload = (uint8_t *)ssh_buffer_get(session->out_buffer);
 2082|   210k|    type = payload[0]; /* type is the first byte of the packet now */
 2083|   210k|    need_rekey = ssh_packet_need_rekey(session, payloadsize);
 2084|   210k|    in_rekey = ssh_packet_in_rekey(session);
 2085|       |
 2086|       |    /* The rekey is triggered here. After that, only the key exchange
 2087|       |     * packets can be sent, until we send our NEWKEYS.
 2088|       |     */
 2089|   210k|    if (need_rekey || (in_rekey && !ssh_packet_is_kex(type))) {
  ------------------
  |  Branch (2089:9): [True: 0, False: 210k]
  |  Branch (2089:24): [True: 0, False: 210k]
  |  Branch (2089:36): [True: 0, False: 0]
  ------------------
 2090|      0|        if (need_rekey) {
  ------------------
  |  Branch (2090:13): [True: 0, False: 0]
  ------------------
 2091|      0|            SSH_LOG(SSH_LOG_PACKET, "Outgoing packet triggered rekey");
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 2092|      0|        }
 2093|       |        /* Queue the current packet -- we will send it after the rekey */
 2094|      0|        SSH_LOG(SSH_LOG_PACKET, "Queuing packet type %d", type);
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 2095|      0|        rc = ssh_list_append(session->out_queue, session->out_buffer);
 2096|      0|        if (rc != SSH_OK) {
  ------------------
  |  |  316|      0|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (2096:13): [True: 0, False: 0]
  ------------------
 2097|      0|            return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 2098|      0|        }
 2099|      0|        session->out_buffer = ssh_buffer_new();
 2100|      0|        if (session->out_buffer == NULL) {
  ------------------
  |  Branch (2100:13): [True: 0, False: 0]
  ------------------
 2101|      0|            ssh_set_error_oom(session);
  ------------------
  |  |  318|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
 2102|      0|            return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 2103|      0|        }
 2104|       |
 2105|      0|        if (need_rekey) {
  ------------------
  |  Branch (2105:13): [True: 0, False: 0]
  ------------------
 2106|       |            /* Send the KEXINIT packet instead.
 2107|       |             * This recursively calls the packet_send(), but it should
 2108|       |             * not get into rekeying again.
 2109|       |             * After that we need to handle the key exchange responses
 2110|       |             * up to the point where we can send the rest of the queue.
 2111|       |             */
 2112|      0|            return ssh_send_rekex(session);
 2113|      0|        }
 2114|      0|        return SSH_OK;
  ------------------
  |  |  316|      0|#define SSH_OK 0     /* No error */
  ------------------
 2115|      0|    }
 2116|       |
 2117|       |    /* Send the packet normally */
 2118|   210k|    rc = packet_send2(session);
 2119|       |
 2120|       |    /* We finished the key exchange so we can try to send our queue now */
 2121|   210k|    if (rc == SSH_OK && type == SSH2_MSG_NEWKEYS) {
  ------------------
  |  |  316|   420k|#define SSH_OK 0     /* No error */
  ------------------
                  if (rc == SSH_OK && type == SSH2_MSG_NEWKEYS) {
  ------------------
  |  |   13|   210k|#define SSH2_MSG_NEWKEYS 21
  ------------------
  |  Branch (2121:9): [True: 210k, False: 6]
  |  Branch (2121:25): [True: 17.2k, False: 192k]
  ------------------
 2122|  17.2k|        struct ssh_iterator *it = NULL;
 2123|       |
 2124|  17.2k|        if (session->flags & SSH_SESSION_FLAG_KEX_STRICT) {
  ------------------
  |  |   90|  17.2k|#define SSH_SESSION_FLAG_KEX_STRICT 0x0010
  ------------------
  |  Branch (2124:13): [True: 17.2k, False: 0]
  ------------------
 2125|       |            /* reset packet sequence number when running in strict kex mode */
 2126|  17.2k|            session->send_seq = 0;
 2127|  17.2k|        }
 2128|  17.2k|        for (it = ssh_list_get_iterator(session->out_queue);
 2129|  17.2k|             it != NULL;
  ------------------
  |  Branch (2129:14): [True: 0, False: 17.2k]
  ------------------
 2130|  17.2k|             it = ssh_list_get_iterator(session->out_queue)) {
 2131|      0|            struct ssh_buffer_struct *next_buffer = NULL;
 2132|       |
 2133|       |            /* Peek only -- do not remove from queue yet */
 2134|      0|            next_buffer = (struct ssh_buffer_struct *)it->data;
 2135|      0|            payloadsize = ssh_buffer_get_len(next_buffer);
 2136|      0|            if (ssh_packet_need_rekey(session, payloadsize)) {
  ------------------
  |  Branch (2136:17): [True: 0, False: 0]
  ------------------
 2137|       |                /* Sigh ... we still can not send this packet. Repeat. */
 2138|      0|                SSH_LOG(SSH_LOG_PACKET, "Queued packet triggered rekey");
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 2139|      0|                return ssh_send_rekex(session);
 2140|      0|            }
 2141|      0|            SSH_BUFFER_FREE(session->out_buffer);
  ------------------
  |  |  934|      0|    do { if ((x) != NULL) { ssh_buffer_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (934:14): [True: 0, False: 0]
  |  |  |  Branch (934:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2142|      0|            session->out_buffer = ssh_list_pop_head(struct ssh_buffer_struct *,
  ------------------
  |  |  122|      0|  ((type)_ssh_list_pop_head(ssh_list))
  ------------------
 2143|      0|                                                    session->out_queue);
 2144|      0|            payload = (uint8_t *)ssh_buffer_get(session->out_buffer);
 2145|      0|            type = payload[0];
 2146|      0|            SSH_LOG(SSH_LOG_PACKET, "Dequeue packet type %d", type);
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 2147|      0|            rc = packet_send2(session);
 2148|      0|            if (rc != SSH_OK) {
  ------------------
  |  |  316|      0|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (2148:17): [True: 0, False: 0]
  ------------------
 2149|      0|                return rc;
 2150|      0|            }
 2151|      0|        }
 2152|  17.2k|    }
 2153|       |
 2154|   210k|    return rc;
 2155|   210k|}
ssh_packet_set_newkeys:
 2270|  34.5k|{
 2271|  34.5k|    struct ssh_cipher_struct *in_cipher = NULL, *out_cipher = NULL;
 2272|  34.5k|    int rc;
 2273|       |
 2274|  34.5k|    SSH_LOG(SSH_LOG_TRACE,
  ------------------
  |  |  281|   138k|    _ssh_log(priority, __func__, __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (281:34): [True: 17.2k, False: 17.2k]
  |  |  |  Branch (281:34): [True: 17.2k, False: 17.2k]
  |  |  ------------------
  ------------------
 2275|  34.5k|            "called, direction =%s%s",
 2276|  34.5k|            direction & SSH_DIRECTION_IN ? " IN " : "",
 2277|  34.5k|            direction & SSH_DIRECTION_OUT ? " OUT " : "");
 2278|       |
 2279|  34.5k|    if (session->next_crypto == NULL) {
  ------------------
  |  Branch (2279:9): [True: 0, False: 34.5k]
  ------------------
 2280|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 2281|      0|    }
 2282|       |
 2283|  34.5k|    session->next_crypto->used |= direction;
 2284|  34.5k|    if (session->current_crypto != NULL) {
  ------------------
  |  Branch (2284:9): [True: 0, False: 34.5k]
  ------------------
 2285|      0|        if (session->current_crypto->used & direction) {
  ------------------
  |  Branch (2285:13): [True: 0, False: 0]
  ------------------
 2286|      0|            SSH_LOG(SSH_LOG_TRACE, "This direction isn't used anymore.");
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 2287|      0|        }
 2288|       |        /* Mark the current requested direction unused */
 2289|      0|        session->current_crypto->used &= ~direction;
 2290|      0|    }
 2291|       |
 2292|       |    /* Both sides switched: do the actual switch now */
 2293|  34.5k|    if (session->next_crypto->used == SSH_DIRECTION_BOTH) {
  ------------------
  |  Branch (2293:9): [True: 17.2k, False: 17.2k]
  ------------------
 2294|  17.2k|        size_t session_id_len;
 2295|       |
 2296|  17.2k|        if (session->current_crypto != NULL) {
  ------------------
  |  Branch (2296:13): [True: 0, False: 17.2k]
  ------------------
 2297|      0|            crypto_free(session->current_crypto);
 2298|      0|            session->current_crypto = NULL;
 2299|      0|        }
 2300|       |
 2301|  17.2k|        session->current_crypto = session->next_crypto;
 2302|  17.2k|        session->current_crypto->used = SSH_DIRECTION_BOTH;
 2303|       |
 2304|       |        /* Initialize the next_crypto structure */
 2305|  17.2k|        session->next_crypto = crypto_new();
 2306|  17.2k|        if (session->next_crypto == NULL) {
  ------------------
  |  Branch (2306:13): [True: 0, False: 17.2k]
  ------------------
 2307|      0|            ssh_set_error_oom(session);
  ------------------
  |  |  318|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
 2308|      0|            return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 2309|      0|        }
 2310|       |
 2311|  17.2k|        session_id_len = session->current_crypto->session_id_len;
 2312|  17.2k|        session->next_crypto->session_id = malloc(session_id_len);
 2313|  17.2k|        if (session->next_crypto->session_id == NULL) {
  ------------------
  |  Branch (2313:13): [True: 0, False: 17.2k]
  ------------------
 2314|      0|            ssh_set_error_oom(session);
  ------------------
  |  |  318|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
 2315|      0|            return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 2316|      0|        }
 2317|       |
 2318|  17.2k|        memcpy(session->next_crypto->session_id,
 2319|  17.2k|               session->current_crypto->session_id,
 2320|  17.2k|               session_id_len);
 2321|  17.2k|        session->next_crypto->session_id_len = session_id_len;
 2322|       |
 2323|  17.2k|        return SSH_OK;
  ------------------
  |  |  316|  17.2k|#define SSH_OK 0     /* No error */
  ------------------
 2324|  17.2k|    }
 2325|       |
 2326|       |    /* Initialize common structures so the next context can be used in
 2327|       |     * either direction */
 2328|  17.2k|    if (session->client) {
  ------------------
  |  Branch (2328:9): [True: 8.64k, False: 8.64k]
  ------------------
 2329|       |        /* The server has this part already done */
 2330|  8.64k|        rc = ssh_make_sessionid(session);
 2331|  8.64k|        if (rc != SSH_OK) {
  ------------------
  |  |  316|  8.64k|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (2331:13): [True: 0, False: 8.64k]
  ------------------
 2332|      0|            return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 2333|      0|        }
 2334|       |
 2335|       |        /*
 2336|       |         * Set the cryptographic functions for the next crypto
 2337|       |         * (it is needed for ssh_generate_session_keys for key lengths)
 2338|       |         */
 2339|  8.64k|        rc = crypt_set_algorithms_client(session);
 2340|  8.64k|        if (rc < 0) {
  ------------------
  |  Branch (2340:13): [True: 0, False: 8.64k]
  ------------------
 2341|      0|            return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 2342|      0|        }
 2343|  8.64k|    }
 2344|       |
 2345|  17.2k|    if (ssh_generate_session_keys(session) < 0) {
  ------------------
  |  Branch (2345:9): [True: 0, False: 17.2k]
  ------------------
 2346|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 2347|      0|    }
 2348|       |
 2349|  17.2k|    in_cipher = session->next_crypto->in_cipher;
 2350|  17.2k|    out_cipher = session->next_crypto->out_cipher;
 2351|  17.2k|    if (in_cipher == NULL || out_cipher == NULL) {
  ------------------
  |  Branch (2351:9): [True: 0, False: 17.2k]
  |  Branch (2351:30): [True: 0, False: 17.2k]
  ------------------
 2352|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 2353|      0|    }
 2354|       |
 2355|       |    /* Initialize rekeying states */
 2356|  17.2k|    ssh_init_rekey_state(session, out_cipher);
 2357|  17.2k|    ssh_init_rekey_state(session, in_cipher);
 2358|  17.2k|    if (session->opts.rekey_time != 0) {
  ------------------
  |  Branch (2358:9): [True: 0, False: 17.2k]
  ------------------
 2359|      0|        ssh_timestamp_init(&session->last_rekey_time);
 2360|      0|        SSH_LOG(SSH_LOG_DEBUG, "Set rekey after %" PRIu32 " seconds",
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 2361|      0|                session->opts.rekey_time/1000);
 2362|      0|    }
 2363|       |
 2364|  17.2k|    if (in_cipher->set_decrypt_key) {
  ------------------
  |  Branch (2364:9): [True: 12.9k, False: 4.32k]
  ------------------
 2365|       |        /* Initialize the encryption and decryption keys in next_crypto */
 2366|  12.9k|        rc = in_cipher->set_decrypt_key(in_cipher,
 2367|  12.9k|                                        session->next_crypto->decryptkey,
 2368|  12.9k|                                        session->next_crypto->decryptIV);
 2369|  12.9k|        if (rc < 0) {
  ------------------
  |  Branch (2369:13): [True: 0, False: 12.9k]
  ------------------
 2370|       |            /* On error, make sure it is not used */
 2371|      0|            session->next_crypto->used = 0;
 2372|      0|            return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 2373|      0|        }
 2374|  12.9k|    }
 2375|       |
 2376|  17.2k|    if (out_cipher->set_encrypt_key) {
  ------------------
  |  Branch (2376:9): [True: 12.9k, False: 4.32k]
  ------------------
 2377|  12.9k|        rc = out_cipher->set_encrypt_key(out_cipher,
 2378|  12.9k|                                         session->next_crypto->encryptkey,
 2379|  12.9k|                                         session->next_crypto->encryptIV);
 2380|  12.9k|        if (rc < 0) {
  ------------------
  |  Branch (2380:13): [True: 0, False: 12.9k]
  ------------------
 2381|       |            /* On error, make sure it is not used */
 2382|      0|            session->next_crypto->used = 0;
 2383|      0|            return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 2384|      0|        }
 2385|  12.9k|    }
 2386|       |
 2387|  17.2k|    return SSH_OK;
  ------------------
  |  |  316|  17.2k|#define SSH_OK 0     /* No error */
  ------------------
 2388|  17.2k|}
packet.c:ssh_packet_incoming_filter:
  143|   184k|{
  144|   184k|    enum ssh_packet_filter_result_e rc;
  145|       |
  146|       |#ifdef DEBUG_PACKET
  147|       |    SSH_LOG(SSH_LOG_PACKET, "Filtering packet type %d",
  148|       |            session->in_packet.type);
  149|       |#endif
  150|       |
  151|   184k|    switch(session->in_packet.type) {
  152|      0|    case SSH2_MSG_DISCONNECT:                         // 1
  ------------------
  |  |    4|      0|#define SSH2_MSG_DISCONNECT 1
  ------------------
  |  Branch (152:5): [True: 0, False: 184k]
  ------------------
  153|       |        /*
  154|       |         * States required:
  155|       |         * - None
  156|       |         *
  157|       |         * Transitions:
  158|       |         * - session->socket->state = SSH_SOCKET_CLOSED
  159|       |         * - session->session_state = SSH_SESSION_STATE_ERROR
  160|       |         * */
  161|       |
  162|       |        /* Always allowed */
  163|      0|        rc = SSH_PACKET_ALLOWED;
  164|      0|        break;
  165|      0|    case SSH2_MSG_IGNORE:                             // 2
  ------------------
  |  |    5|      0|#define SSH2_MSG_IGNORE	 2
  ------------------
  |  Branch (165:5): [True: 0, False: 184k]
  ------------------
  166|       |        /*
  167|       |         * States required:
  168|       |         * - None
  169|       |         *
  170|       |         * Transitions:
  171|       |         * - None
  172|       |         * */
  173|       |
  174|       |        /* Always allowed */
  175|      0|        rc = SSH_PACKET_ALLOWED;
  176|      0|        break;
  177|      0|    case SSH2_MSG_UNIMPLEMENTED:                      // 3
  ------------------
  |  |    6|      0|#define SSH2_MSG_UNIMPLEMENTED 3
  ------------------
  |  Branch (177:5): [True: 0, False: 184k]
  ------------------
  178|       |        /*
  179|       |         * States required:
  180|       |         * - None
  181|       |         *
  182|       |         * Transitions:
  183|       |         * - None
  184|       |         * */
  185|       |
  186|       |        /* Always allowed */
  187|      0|        rc = SSH_PACKET_ALLOWED;
  188|      0|        break;
  189|      0|    case SSH2_MSG_DEBUG:                              // 4
  ------------------
  |  |    7|      0|#define SSH2_MSG_DEBUG	4
  ------------------
  |  Branch (189:5): [True: 0, False: 184k]
  ------------------
  190|       |        /*
  191|       |         * States required:
  192|       |         * - None
  193|       |         *
  194|       |         * Transitions:
  195|       |         * - None
  196|       |         * */
  197|       |
  198|       |        /* Always allowed */
  199|      0|        rc = SSH_PACKET_ALLOWED;
  200|      0|        break;
  201|  8.64k|    case SSH2_MSG_SERVICE_REQUEST:                    // 5
  ------------------
  |  |    8|  8.64k|#define SSH2_MSG_SERVICE_REQUEST	5
  ------------------
  |  Branch (201:5): [True: 8.64k, False: 175k]
  ------------------
  202|       |        /* Server only */
  203|       |
  204|       |        /*
  205|       |         * States required:
  206|       |         * - session->session_state == SSH_SESSION_STATE_AUTHENTICATING
  207|       |         *   or session->session_state == SSH_SESSION_STATE_AUTHENTICATED
  208|       |         * - session->dh_handshake_state == DH_STATE_FINISHED
  209|       |         *
  210|       |         * Transitions:
  211|       |         * - None
  212|       |         * */
  213|       |
  214|       |        /* If this is a client, reject the message */
  215|  8.64k|        if (session->client) {
  ------------------
  |  Branch (215:13): [True: 0, False: 8.64k]
  ------------------
  216|      0|            rc = SSH_PACKET_DENIED;
  217|      0|            break;
  218|      0|        }
  219|       |
  220|  8.64k|        if ((session->session_state != SSH_SESSION_STATE_AUTHENTICATING) &&
  ------------------
  |  Branch (220:13): [True: 0, False: 8.64k]
  ------------------
  221|      0|            (session->session_state != SSH_SESSION_STATE_AUTHENTICATED))
  ------------------
  |  Branch (221:13): [True: 0, False: 0]
  ------------------
  222|      0|        {
  223|      0|            rc = SSH_PACKET_DENIED;
  224|      0|            break;
  225|      0|        }
  226|       |
  227|  8.64k|        if (session->dh_handshake_state != DH_STATE_FINISHED) {
  ------------------
  |  Branch (227:13): [True: 0, False: 8.64k]
  ------------------
  228|      0|            rc = SSH_PACKET_DENIED;
  229|      0|            break;
  230|      0|        }
  231|       |
  232|  8.64k|        rc = SSH_PACKET_ALLOWED;
  233|  8.64k|        break;
  234|  8.64k|    case SSH2_MSG_SERVICE_ACCEPT:                     // 6
  ------------------
  |  |    9|  8.64k|#define SSH2_MSG_SERVICE_ACCEPT 6
  ------------------
  |  Branch (234:5): [True: 8.64k, False: 175k]
  ------------------
  235|       |        /*
  236|       |         * States required:
  237|       |         * - session->session_state == SSH_SESSION_STATE_AUTHENTICATING
  238|       |         *   or session->session_state == SSH_SESSION_STATE_AUTHENTICATED
  239|       |         * - session->dh_handshake_state == DH_STATE_FINISHED
  240|       |         * - session->auth.service_state == SSH_AUTH_SERVICE_SENT
  241|       |         *
  242|       |         * Transitions:
  243|       |         * - auth.service_state = SSH_AUTH_SERVICE_ACCEPTED
  244|       |         * */
  245|       |
  246|  8.64k|        if ((session->session_state != SSH_SESSION_STATE_AUTHENTICATING) &&
  ------------------
  |  Branch (246:13): [True: 0, False: 8.64k]
  ------------------
  247|      0|            (session->session_state != SSH_SESSION_STATE_AUTHENTICATED))
  ------------------
  |  Branch (247:13): [True: 0, False: 0]
  ------------------
  248|      0|        {
  249|      0|            rc = SSH_PACKET_DENIED;
  250|      0|            break;
  251|      0|        }
  252|       |
  253|  8.64k|        if (session->dh_handshake_state != DH_STATE_FINISHED) {
  ------------------
  |  Branch (253:13): [True: 0, False: 8.64k]
  ------------------
  254|      0|            rc = SSH_PACKET_DENIED;
  255|      0|            break;
  256|      0|        }
  257|       |
  258|       |        /* TODO check if only auth service can be requested */
  259|  8.64k|        if (session->auth.service_state != SSH_AUTH_SERVICE_SENT) {
  ------------------
  |  Branch (259:13): [True: 0, False: 8.64k]
  ------------------
  260|      0|            rc = SSH_PACKET_DENIED;
  261|      0|            break;
  262|      0|        }
  263|       |
  264|  8.64k|        rc = SSH_PACKET_ALLOWED;
  265|  8.64k|        break;
  266|  8.64k|    case SSH2_MSG_EXT_INFO:                           // 7
  ------------------
  |  |   10|  8.64k|#define SSH2_MSG_EXT_INFO 7
  ------------------
  |  Branch (266:5): [True: 8.64k, False: 175k]
  ------------------
  267|       |        /*
  268|       |         * States required:
  269|       |         * - session_state == SSH_SESSION_STATE_AUTHENTICATING
  270|       |         *   or session->session_state == SSH_SESSION_STATE_AUTHENTICATED
  271|       |         *   (re-exchange)
  272|       |         * - dh_handshake_state == DH_STATE_FINISHED
  273|       |         *
  274|       |         * Transitions:
  275|       |         * - None
  276|       |         * */
  277|       |
  278|  8.64k|        if ((session->session_state != SSH_SESSION_STATE_AUTHENTICATING) &&
  ------------------
  |  Branch (278:13): [True: 0, False: 8.64k]
  ------------------
  279|      0|            (session->session_state != SSH_SESSION_STATE_AUTHENTICATED))
  ------------------
  |  Branch (279:13): [True: 0, False: 0]
  ------------------
  280|      0|        {
  281|      0|            rc = SSH_PACKET_DENIED;
  282|      0|            break;
  283|      0|        }
  284|       |
  285|  8.64k|        if (session->dh_handshake_state != DH_STATE_FINISHED) {
  ------------------
  |  Branch (285:13): [True: 0, False: 8.64k]
  ------------------
  286|      0|            rc = SSH_PACKET_DENIED;
  287|      0|            break;
  288|      0|        }
  289|       |
  290|  8.64k|        rc = SSH_PACKET_ALLOWED;
  291|  8.64k|        break;
  292|  17.2k|    case SSH2_MSG_KEXINIT:                            // 20
  ------------------
  |  |   12|  17.2k|#define SSH2_MSG_KEXINIT	 20
  ------------------
  |  Branch (292:5): [True: 17.2k, False: 167k]
  ------------------
  293|       |        /*
  294|       |         * States required:
  295|       |         * - session_state == SSH_SESSION_STATE_AUTHENTICATED
  296|       |         *   or session_state == SSH_SESSION_STATE_INITIAL_KEX
  297|       |         * - dh_handshake_state == DH_STATE_INIT
  298|       |         *   or dh_handshake_state == DH_STATE_INIT_SENT (re-exchange)
  299|       |         *   or dh_handshake_state == DH_STATE_REQUEST_SENT (dh-gex)
  300|       |         *   or dh_handshake_state == DH_STATE_FINISHED (re-exchange)
  301|       |         *
  302|       |         * Transitions:
  303|       |         * - session->dh_handshake_state = DH_STATE_INIT
  304|       |         * - session->session_state = SSH_SESSION_STATE_KEXINIT_RECEIVED
  305|       |         *
  306|       |         * On server:
  307|       |         * - session->session_state = SSH_SESSION_STATE_DH
  308|       |         * */
  309|       |
  310|  17.2k|        if ((session->session_state != SSH_SESSION_STATE_AUTHENTICATED) &&
  ------------------
  |  Branch (310:13): [True: 17.2k, False: 1]
  ------------------
  311|  17.2k|            (session->session_state != SSH_SESSION_STATE_INITIAL_KEX))
  ------------------
  |  Branch (311:13): [True: 0, False: 17.2k]
  ------------------
  312|      0|        {
  313|      0|            rc = SSH_PACKET_DENIED;
  314|      0|            break;
  315|      0|        }
  316|       |
  317|  17.2k|        if ((session->dh_handshake_state != DH_STATE_INIT) &&
  ------------------
  |  Branch (317:13): [True: 0, False: 17.2k]
  ------------------
  318|      0|            (session->dh_handshake_state != DH_STATE_INIT_SENT) &&
  ------------------
  |  Branch (318:13): [True: 0, False: 0]
  ------------------
  319|      0|            (session->dh_handshake_state != DH_STATE_REQUEST_SENT) &&
  ------------------
  |  Branch (319:13): [True: 0, False: 0]
  ------------------
  320|      0|            (session->dh_handshake_state != DH_STATE_FINISHED))
  ------------------
  |  Branch (320:13): [True: 0, False: 0]
  ------------------
  321|      0|        {
  322|      0|            rc = SSH_PACKET_DENIED;
  323|      0|            break;
  324|      0|        }
  325|       |
  326|  17.2k|        rc = SSH_PACKET_ALLOWED;
  327|  17.2k|        break;
  328|  17.2k|    case SSH2_MSG_NEWKEYS:                            // 21
  ------------------
  |  |   13|  17.2k|#define SSH2_MSG_NEWKEYS 21
  ------------------
  |  Branch (328:5): [True: 17.2k, False: 167k]
  ------------------
  329|       |        /*
  330|       |         * States required:
  331|       |         * - session_state == SSH_SESSION_STATE_DH
  332|       |         * - dh_handshake_state == DH_STATE_NEWKEYS_SENT
  333|       |         *
  334|       |         * Transitions:
  335|       |         * - session->dh_handshake_state = DH_STATE_FINISHED
  336|       |         * - session->session_state = SSH_SESSION_STATE_AUTHENTICATING
  337|       |         * if session->flags & SSH_SESSION_FLAG_AUTHENTICATED
  338|       |         * - session->session_state = SSH_SESSION_STATE_AUTHENTICATED
  339|       |         * */
  340|       |
  341|       |        /* If DH has not been started, reject message */
  342|  17.2k|        if (session->session_state != SSH_SESSION_STATE_DH) {
  ------------------
  |  Branch (342:13): [True: 0, False: 17.2k]
  ------------------
  343|      0|            rc = SSH_PACKET_DENIED;
  344|      0|            break;
  345|      0|        }
  346|       |
  347|       |        /* Only allowed if dh_handshake_state is in NEWKEYS_SENT state */
  348|  17.2k|        if (session->dh_handshake_state != DH_STATE_NEWKEYS_SENT) {
  ------------------
  |  Branch (348:13): [True: 0, False: 17.2k]
  ------------------
  349|      0|            rc = SSH_PACKET_DENIED;
  350|      0|            break;
  351|      0|        }
  352|       |
  353|  17.2k|        rc = SSH_PACKET_ALLOWED;
  354|  17.2k|        break;
  355|  8.64k|    case SSH2_MSG_KEXDH_INIT:                         // 30
  ------------------
  |  |   15|  8.64k|#define SSH2_MSG_KEXDH_INIT 30
  ------------------
  |  Branch (355:5): [True: 8.64k, False: 175k]
  ------------------
  356|       |      // SSH2_MSG_KEX_ECDH_INIT:                      // 30
  357|       |      // SSH2_MSG_KEX_HYBRID_INIT:                    // 30
  358|       |      // SSH2_MSG_KEX_DH_GEX_REQUEST_OLD:             // 30
  359|       |
  360|       |        /* Server only */
  361|       |
  362|       |        /*
  363|       |         * States required:
  364|       |         * - session_state == SSH_SESSION_STATE_DH
  365|       |         * - dh_handshake_state == DH_STATE_INIT
  366|       |         *
  367|       |         * Transitions:
  368|       |         * - session->dh_handshake_state = DH_STATE_INIT_SENT
  369|       |         * then calls dh_handshake_server which triggers:
  370|       |         * - session->dh_handshake_state = DH_STATE_NEWKEYS_SENT
  371|       |         * */
  372|       |
  373|  8.64k|        if (session->client) {
  ------------------
  |  Branch (373:13): [True: 0, False: 8.64k]
  ------------------
  374|      0|            rc = SSH_PACKET_DENIED;
  375|      0|            break;
  376|      0|        }
  377|       |
  378|  8.64k|        if (session->session_state != SSH_SESSION_STATE_DH) {
  ------------------
  |  Branch (378:13): [True: 0, False: 8.64k]
  ------------------
  379|      0|            rc = SSH_PACKET_DENIED;
  380|      0|            break;
  381|      0|        }
  382|       |
  383|       |        /* Only allowed if dh_handshake_state is in initial state */
  384|  8.64k|        if (session->dh_handshake_state != DH_STATE_INIT) {
  ------------------
  |  Branch (384:13): [True: 0, False: 8.64k]
  ------------------
  385|      0|            rc = SSH_PACKET_DENIED;
  386|      0|            break;
  387|      0|        }
  388|       |
  389|  8.64k|        rc = SSH_PACKET_ALLOWED;
  390|  8.64k|        break;
  391|  8.64k|    case SSH2_MSG_KEXDH_REPLY:                        // 31
  ------------------
  |  |   16|  8.64k|#define SSH2_MSG_KEXDH_REPLY 31
  ------------------
  |  Branch (391:5): [True: 8.64k, False: 175k]
  ------------------
  392|       |      // SSH2_MSG_KEX_ECDH_REPLY:                     // 31
  393|       |      // SSH2_MSG_KEX_HYBRID_REPLY:                   // 31
  394|       |      // SSH2_MSG_KEX_DH_GEX_GROUP:                   // 31
  395|       |
  396|       |        /* Client only */
  397|       |
  398|       |        /*
  399|       |         * States required:
  400|       |         * - session_state == SSH_SESSION_STATE_DH
  401|       |         * - dh_handshake_state == DH_STATE_INIT_SENT
  402|       |         *   or dh_handshake_state == DH_STATE_REQUEST_SENT (dh-gex)
  403|       |         *
  404|       |         * Transitions:
  405|       |         * - session->dh_handshake_state = DH_STATE_NEWKEYS_SENT
  406|       |         * */
  407|       |
  408|  8.64k|        if (session->server) {
  ------------------
  |  Branch (408:13): [True: 0, False: 8.64k]
  ------------------
  409|      0|            rc = SSH_PACKET_DENIED;
  410|      0|            break;
  411|      0|        }
  412|       |
  413|  8.64k|        if (session->session_state != SSH_SESSION_STATE_DH) {
  ------------------
  |  Branch (413:13): [True: 0, False: 8.64k]
  ------------------
  414|      0|            rc = SSH_PACKET_DENIED;
  415|      0|            break;
  416|      0|        }
  417|       |
  418|  8.64k|        if (session->dh_handshake_state != DH_STATE_INIT_SENT &&
  ------------------
  |  Branch (418:13): [True: 0, False: 8.64k]
  ------------------
  419|      0|            session->dh_handshake_state != DH_STATE_REQUEST_SENT) {
  ------------------
  |  Branch (419:13): [True: 0, False: 0]
  ------------------
  420|      0|            rc = SSH_PACKET_DENIED;
  421|      0|            break;
  422|      0|        }
  423|       |
  424|  8.64k|        rc = SSH_PACKET_ALLOWED;
  425|  8.64k|        break;
  426|      0|    case SSH2_MSG_KEX_DH_GEX_INIT:                    // 32
  ------------------
  |  |   24|      0|#define SSH2_MSG_KEX_DH_GEX_INIT 32
  ------------------
  |  Branch (426:5): [True: 0, False: 184k]
  ------------------
  427|       |      // SSH2_MSG_KEXGSS_COMPLETE:                    // 32
  428|      0|        if (ssh_kex_is_gss(session->next_crypto)) {
  ------------------
  |  Branch (428:13): [True: 0, False: 0]
  ------------------
  429|       |            /* SSH2_MSG_KEXGSS_COMPLETE */
  430|       |            /* Client only */
  431|       |
  432|       |            /*
  433|       |             * States required:
  434|       |             * - session_state == SSH_SESSION_STATE_DH
  435|       |             * - dh_handshake_state == DH_STATE_INIT_SENT
  436|       |             *
  437|       |             * Transitions:
  438|       |             * - session->dh_handshake_state = DH_STATE_INIT_SENT
  439|       |             * then calls ssh_packet_client_gss_kex_reply which triggers:
  440|       |             * - session->dh_handshake_state = DH_STATE_NEWKEYS_SENT
  441|       |             * */
  442|       |
  443|      0|            if (!session->client) {
  ------------------
  |  Branch (443:17): [True: 0, False: 0]
  ------------------
  444|      0|                rc = SSH_PACKET_DENIED;
  445|      0|                break;
  446|      0|            }
  447|       |
  448|      0|            if (session->session_state != SSH_SESSION_STATE_DH) {
  ------------------
  |  Branch (448:17): [True: 0, False: 0]
  ------------------
  449|      0|                rc = SSH_PACKET_DENIED;
  450|      0|                break;
  451|      0|            }
  452|       |
  453|      0|            if (session->dh_handshake_state != DH_STATE_INIT_SENT) {
  ------------------
  |  Branch (453:17): [True: 0, False: 0]
  ------------------
  454|      0|                rc = SSH_PACKET_DENIED;
  455|      0|                break;
  456|      0|            }
  457|      0|        } else {
  458|       |            /* SSH2_MSG_KEX_DH_GEX_INIT */
  459|       |            /* Server only */
  460|       |
  461|       |            /*
  462|       |             * States required:
  463|       |             * - session_state == SSH_SESSION_STATE_DH
  464|       |             * - dh_handshake_state == DH_STATE_GROUP_SENT
  465|       |             *
  466|       |             * Transitions:
  467|       |             * - session->dh_handshake_state = DH_STATE_GROUP_SENT
  468|       |             * then calls ssh_packet_server_dhgex_init which triggers:
  469|       |             * - session->dh_handshake_state = DH_STATE_NEWKEYS_SENT
  470|       |             * */
  471|       |
  472|      0|            if (session->client) {
  ------------------
  |  Branch (472:17): [True: 0, False: 0]
  ------------------
  473|      0|                rc = SSH_PACKET_DENIED;
  474|      0|                break;
  475|      0|            }
  476|       |
  477|      0|            if (session->session_state != SSH_SESSION_STATE_DH) {
  ------------------
  |  Branch (477:17): [True: 0, False: 0]
  ------------------
  478|      0|                rc = SSH_PACKET_DENIED;
  479|      0|                break;
  480|      0|            }
  481|       |
  482|       |            /* Only allowed if dh_handshake_state is in initial state */
  483|      0|            if (session->dh_handshake_state != DH_STATE_GROUP_SENT) {
  ------------------
  |  Branch (483:17): [True: 0, False: 0]
  ------------------
  484|      0|                rc = SSH_PACKET_DENIED;
  485|      0|                break;
  486|      0|            }
  487|      0|        }
  488|      0|        rc = SSH_PACKET_ALLOWED;
  489|      0|        break;
  490|      0|    case SSH2_MSG_KEX_DH_GEX_REPLY:                   // 33
  ------------------
  |  |   25|      0|#define SSH2_MSG_KEX_DH_GEX_REPLY 33
  ------------------
  |  Branch (490:5): [True: 0, False: 184k]
  ------------------
  491|       |
  492|       |        /* Client only */
  493|       |
  494|       |        /*
  495|       |         * States required:
  496|       |         * - session_state == SSH_SESSION_STATE_DH
  497|       |         * - dh_handshake_state == DH_STATE_INIT_SENT
  498|       |         *
  499|       |         * Transitions:
  500|       |         * - session->dh_handshake_state = DH_STATE_NEWKEYS_SENT
  501|       |         * */
  502|       |
  503|      0|        if (session->server) {
  ------------------
  |  Branch (503:13): [True: 0, False: 0]
  ------------------
  504|      0|            rc = SSH_PACKET_DENIED;
  505|      0|            break;
  506|      0|        }
  507|       |
  508|      0|        if (session->session_state != SSH_SESSION_STATE_DH) {
  ------------------
  |  Branch (508:13): [True: 0, False: 0]
  ------------------
  509|      0|            rc = SSH_PACKET_DENIED;
  510|      0|            break;
  511|      0|        }
  512|       |
  513|      0|        if (session->dh_handshake_state != DH_STATE_INIT_SENT) {
  ------------------
  |  Branch (513:13): [True: 0, False: 0]
  ------------------
  514|      0|            rc = SSH_PACKET_DENIED;
  515|      0|            break;
  516|      0|        }
  517|       |
  518|      0|        rc = SSH_PACKET_ALLOWED;
  519|      0|        break;
  520|      0|    case SSH2_MSG_KEX_DH_GEX_REQUEST:                 // 34
  ------------------
  |  |   26|      0|#define SSH2_MSG_KEX_DH_GEX_REQUEST 34
  ------------------
  |  Branch (520:5): [True: 0, False: 184k]
  ------------------
  521|       |
  522|       |        /* Server only */
  523|       |
  524|       |        /*
  525|       |         * States required:
  526|       |         * - session_state == SSH_SESSION_STATE_DH
  527|       |         * - dh_handshake_state == DH_STATE_INIT
  528|       |         *
  529|       |         * Transitions:
  530|       |         * - session->dh_handshake_state = DH_STATE_INIT_SENT
  531|       |         * then calls ssh_packet_server_dhgex_request which triggers:
  532|       |         * - session->dh_handshake_state = DH_STATE_GROUP_SENT
  533|       |         * */
  534|       |
  535|      0|        if (session->client) {
  ------------------
  |  Branch (535:13): [True: 0, False: 0]
  ------------------
  536|      0|            rc = SSH_PACKET_DENIED;
  537|      0|            break;
  538|      0|        }
  539|       |
  540|      0|        if (session->session_state != SSH_SESSION_STATE_DH) {
  ------------------
  |  Branch (540:13): [True: 0, False: 0]
  ------------------
  541|      0|            rc = SSH_PACKET_DENIED;
  542|      0|            break;
  543|      0|        }
  544|       |
  545|       |        /* Only allowed if dh_handshake_state is in initial state */
  546|      0|        if (session->dh_handshake_state != DH_STATE_INIT) {
  ------------------
  |  Branch (546:13): [True: 0, False: 0]
  ------------------
  547|      0|            rc = SSH_PACKET_DENIED;
  548|      0|            break;
  549|      0|        }
  550|       |
  551|      0|        rc = SSH_PACKET_ALLOWED;
  552|      0|        break;
  553|  8.64k|    case SSH2_MSG_USERAUTH_REQUEST:                   // 50
  ------------------
  |  |   36|  8.64k|#define SSH2_MSG_USERAUTH_REQUEST 50
  ------------------
  |  Branch (553:5): [True: 8.64k, False: 175k]
  ------------------
  554|       |        /* Server only */
  555|       |
  556|       |        /*
  557|       |         * States required:
  558|       |         * - session_state == SSH_SESSION_STATE_AUTHENTICATING
  559|       |         * - dh_handshake_state == DH_STATE_FINISHED
  560|       |         *
  561|       |         * Transitions:
  562|       |         * - if authentication was successful:
  563|       |         *   - session_state = SSH_SESSION_STATE_AUTHENTICATED
  564|       |         * */
  565|       |
  566|       |        /* If this is a client, reject the message */
  567|  8.64k|        if (session->client) {
  ------------------
  |  Branch (567:13): [True: 0, False: 8.64k]
  ------------------
  568|      0|            rc = SSH_PACKET_DENIED;
  569|      0|            break;
  570|      0|        }
  571|       |
  572|  8.64k|        if (session->dh_handshake_state != DH_STATE_FINISHED) {
  ------------------
  |  Branch (572:13): [True: 0, False: 8.64k]
  ------------------
  573|      0|            rc = SSH_PACKET_DENIED;
  574|      0|            break;
  575|      0|        }
  576|       |
  577|  8.64k|        if (session->session_state != SSH_SESSION_STATE_AUTHENTICATING) {
  ------------------
  |  Branch (577:13): [True: 0, False: 8.64k]
  ------------------
  578|      0|            rc = SSH_PACKET_DENIED;
  579|      0|            break;
  580|      0|        }
  581|       |
  582|  8.64k|        rc = SSH_PACKET_ALLOWED;
  583|  8.64k|        break;
  584|      0|    case SSH2_MSG_USERAUTH_FAILURE:                   // 51
  ------------------
  |  |   37|      0|#define SSH2_MSG_USERAUTH_FAILURE 51
  ------------------
  |  Branch (584:5): [True: 0, False: 184k]
  ------------------
  585|       |        /*
  586|       |         * States required:
  587|       |         * - session_state == SSH_SESSION_STATE_AUTHENTICATING
  588|       |         * - dh_handshake_state == DH_STATE_FINISHED
  589|       |         * - session->auth.state == SSH_AUTH_STATE_KBDINT_SENT
  590|       |         *   or session->auth.state == SSH_AUTH_STATE_PUBKEY_OFFER_SENT
  591|       |         *   or session->auth.state == SSH_AUTH_STATE_PUBKEY_AUTH_SENT
  592|       |         *   or session->auth.state == SSH_AUTH_STATE_PASSWORD_AUTH_SENT
  593|       |         *   or session->auth.state == SSH_AUTH_STATE_GSSAPI_MIC_SENT
  594|       |         *
  595|       |         * Transitions:
  596|       |         * - if unpacking failed:
  597|       |         *   - session->auth.state = SSH_AUTH_ERROR
  598|       |         * - if failure was partial:
  599|       |         *   - session->auth.state = SSH_AUTH_PARTIAL
  600|       |         * - else:
  601|       |         *   - session->auth.state = SSH_AUTH_STATE_FAILED
  602|       |         * */
  603|       |
  604|       |        /* If this is a server, reject the message */
  605|      0|        if (session->server) {
  ------------------
  |  Branch (605:13): [True: 0, False: 0]
  ------------------
  606|      0|            rc = SSH_PACKET_DENIED;
  607|      0|            break;
  608|      0|        }
  609|       |
  610|      0|        if (session->dh_handshake_state != DH_STATE_FINISHED) {
  ------------------
  |  Branch (610:13): [True: 0, False: 0]
  ------------------
  611|      0|            rc = SSH_PACKET_DENIED;
  612|      0|            break;
  613|      0|        }
  614|       |
  615|      0|        if (session->session_state != SSH_SESSION_STATE_AUTHENTICATING) {
  ------------------
  |  Branch (615:13): [True: 0, False: 0]
  ------------------
  616|      0|            rc = SSH_PACKET_DENIED;
  617|      0|            break;
  618|      0|        }
  619|       |
  620|      0|        rc = SSH_PACKET_ALLOWED;
  621|      0|        break;
  622|  8.64k|    case SSH2_MSG_USERAUTH_SUCCESS:                   // 52
  ------------------
  |  |   38|  8.64k|#define SSH2_MSG_USERAUTH_SUCCESS 52
  ------------------
  |  Branch (622:5): [True: 8.64k, False: 175k]
  ------------------
  623|       |        /*
  624|       |         * States required:
  625|       |         * - session_state == SSH_SESSION_STATE_AUTHENTICATING
  626|       |         * - dh_handshake_state == DH_STATE_FINISHED
  627|       |         * - session->auth.state == SSH_AUTH_STATE_KBDINT_SENT
  628|       |         *   or session->auth.state == SSH_AUTH_STATE_PUBKEY_AUTH_SENT
  629|       |         *   or session->auth.state == SSH_AUTH_STATE_PASSWORD_AUTH_SENT
  630|       |         *   or session->auth.state == SSH_AUTH_STATE_GSSAPI_MIC_SENT
  631|       |         *   or session->auth.state == SSH_AUTH_STATE_GSSAPI_KEYEX_MIC_SENT
  632|       |         *   or session->auth.state == SSH_AUTH_STATE_AUTH_NONE_SENT
  633|       |         *
  634|       |         * Transitions:
  635|       |         * - session->auth.state = SSH_AUTH_STATE_SUCCESS
  636|       |         * - session->session_state = SSH_SESSION_STATE_AUTHENTICATED
  637|       |         * - session->flags |= SSH_SESSION_FLAG_AUTHENTICATED
  638|       |         * - sessions->auth.current_method = SSH_AUTH_METHOD_UNKNOWN
  639|       |         * */
  640|       |
  641|       |        /* If this is a server, reject the message */
  642|  8.64k|        if (session->server) {
  ------------------
  |  Branch (642:13): [True: 0, False: 8.64k]
  ------------------
  643|      0|            rc = SSH_PACKET_DENIED;
  644|      0|            break;
  645|      0|        }
  646|       |
  647|  8.64k|        if (session->dh_handshake_state != DH_STATE_FINISHED) {
  ------------------
  |  Branch (647:13): [True: 0, False: 8.64k]
  ------------------
  648|      0|            rc = SSH_PACKET_DENIED;
  649|      0|            break;
  650|      0|        }
  651|       |
  652|  8.64k|        if (session->session_state != SSH_SESSION_STATE_AUTHENTICATING) {
  ------------------
  |  Branch (652:13): [True: 0, False: 8.64k]
  ------------------
  653|      0|            rc = SSH_PACKET_DENIED;
  654|      0|            break;
  655|      0|        }
  656|       |
  657|  8.64k|        if ((session->auth.state != SSH_AUTH_STATE_KBDINT_SENT) &&
  ------------------
  |  Branch (657:13): [True: 8.64k, False: 0]
  ------------------
  658|  8.64k|            (session->auth.state != SSH_AUTH_STATE_PUBKEY_AUTH_SENT) &&
  ------------------
  |  Branch (658:13): [True: 8.64k, False: 0]
  ------------------
  659|  8.64k|            (session->auth.state != SSH_AUTH_STATE_PASSWORD_AUTH_SENT) &&
  ------------------
  |  Branch (659:13): [True: 8.64k, False: 0]
  ------------------
  660|  8.64k|            (session->auth.state != SSH_AUTH_STATE_GSSAPI_MIC_SENT) &&
  ------------------
  |  Branch (660:13): [True: 8.64k, False: 0]
  ------------------
  661|  8.64k|            (session->auth.state != SSH_AUTH_STATE_GSSAPI_KEYEX_MIC_SENT) &&
  ------------------
  |  Branch (661:13): [True: 8.64k, False: 0]
  ------------------
  662|  8.64k|            (session->auth.state != SSH_AUTH_STATE_AUTH_NONE_SENT)) {
  ------------------
  |  Branch (662:13): [True: 0, False: 8.64k]
  ------------------
  663|      0|            rc = SSH_PACKET_DENIED;
  664|      0|            break;
  665|      0|        }
  666|       |
  667|  8.64k|        rc = SSH_PACKET_ALLOWED;
  668|  8.64k|        break;
  669|      0|    case SSH2_MSG_USERAUTH_BANNER:                    // 53
  ------------------
  |  |   39|      0|#define SSH2_MSG_USERAUTH_BANNER 53
  ------------------
  |  Branch (669:5): [True: 0, False: 184k]
  ------------------
  670|       |        /*
  671|       |         * States required:
  672|       |         * - session_state == SSH_SESSION_STATE_AUTHENTICATING
  673|       |         *
  674|       |         * Transitions:
  675|       |         * - None
  676|       |         * */
  677|       |
  678|      0|        if (session->session_state != SSH_SESSION_STATE_AUTHENTICATING) {
  ------------------
  |  Branch (678:13): [True: 0, False: 0]
  ------------------
  679|      0|            rc = SSH_PACKET_DENIED;
  680|      0|            break;
  681|      0|        }
  682|       |
  683|      0|        rc = SSH_PACKET_ALLOWED;
  684|      0|        break;
  685|      0|    case SSH2_MSG_USERAUTH_PK_OK:                     // 60
  ------------------
  |  |   40|      0|#define SSH2_MSG_USERAUTH_PK_OK 60
  ------------------
  |  Branch (685:5): [True: 0, False: 184k]
  ------------------
  686|       |      // SSH2_MSG_USERAUTH_PASSWD_CHANGEREQ:          // 60
  687|       |      // SSH2_MSG_USERAUTH_INFO_REQUEST:              // 60
  688|       |      // SSH2_MSG_USERAUTH_GSSAPI_RESPONSE:           // 60
  689|       |
  690|       |        /*
  691|       |         * States required:
  692|       |         * - session_state == SSH_SESSION_STATE_AUTHENTICATING
  693|       |         * - session->auth.state == SSH_AUTH_STATE_KBDINT_SENT
  694|       |         *   or
  695|       |         *   session->auth.state == SSH_AUTH_STATE_GSSAPI_REQUEST_SENT
  696|       |         *   or
  697|       |         *   session->auth.state == SSH_AUTH_STATE_PUBKEY_OFFER_SENT
  698|       |         *
  699|       |         * Transitions:
  700|       |         * Depending on the current state, the message is treated
  701|       |         * differently:
  702|       |         * - session->auth.state == SSH_AUTH_STATE_KBDINT_SENT
  703|       |         *   - session->auth.state = SSH_AUTH_STATE_INFO
  704|       |         * - session->auth.state == SSH_AUTH_STATE_GSSAPI_REQUEST_SENT
  705|       |         *   - session->auth.state = SSH_AUTH_STATE_GSSAPI_TOKEN
  706|       |         * - session->auth.state == SSH_AUTH_STATE_PUBKEY_OFFER_SENT
  707|       |         *   - session->auth.state = SSH_AUTH_STATE_PK_OK
  708|       |         * */
  709|       |
  710|      0|        if (session->session_state != SSH_SESSION_STATE_AUTHENTICATING) {
  ------------------
  |  Branch (710:13): [True: 0, False: 0]
  ------------------
  711|      0|            rc = SSH_PACKET_DENIED;
  712|      0|            break;
  713|      0|        }
  714|       |
  715|      0|        if ((session->auth.state != SSH_AUTH_STATE_KBDINT_SENT) &&
  ------------------
  |  Branch (715:13): [True: 0, False: 0]
  ------------------
  716|      0|            (session->auth.state != SSH_AUTH_STATE_PUBKEY_OFFER_SENT) &&
  ------------------
  |  Branch (716:13): [True: 0, False: 0]
  ------------------
  717|      0|            (session->auth.state != SSH_AUTH_STATE_GSSAPI_REQUEST_SENT))
  ------------------
  |  Branch (717:13): [True: 0, False: 0]
  ------------------
  718|      0|        {
  719|      0|            rc = SSH_PACKET_DENIED;
  720|      0|            break;
  721|      0|        }
  722|       |
  723|      0|        rc = SSH_PACKET_ALLOWED;
  724|      0|        break;
  725|      0|    case SSH2_MSG_USERAUTH_INFO_RESPONSE:             // 61
  ------------------
  |  |   44|      0|#define SSH2_MSG_USERAUTH_INFO_RESPONSE 61
  ------------------
  |  Branch (725:5): [True: 0, False: 184k]
  ------------------
  726|       |      // SSH2_MSG_USERAUTH_GSSAPI_TOKEN:              // 61
  727|       |
  728|       |        /*
  729|       |         * States required:
  730|       |         * - session_state == SSH_SESSION_STATE_AUTHENTICATING
  731|       |         * - session_state->auth.state == SSH_SESSION_STATE_GSSAPI_TOKEN
  732|       |         *   or
  733|       |         *   session_state->auth.state == SSH_SESSION_STATE_INFO
  734|       |         *
  735|       |         * Transitions:
  736|       |         * - None
  737|       |         * */
  738|       |
  739|      0|        if (session->session_state != SSH_SESSION_STATE_AUTHENTICATING) {
  ------------------
  |  Branch (739:13): [True: 0, False: 0]
  ------------------
  740|      0|            rc = SSH_PACKET_DENIED;
  741|      0|            break;
  742|      0|        }
  743|       |
  744|      0|        if ((session->auth.state != SSH_AUTH_STATE_INFO) &&
  ------------------
  |  Branch (744:13): [True: 0, False: 0]
  ------------------
  745|      0|            (session->auth.state != SSH_AUTH_STATE_GSSAPI_TOKEN))
  ------------------
  |  Branch (745:13): [True: 0, False: 0]
  ------------------
  746|      0|        {
  747|      0|            rc = SSH_PACKET_DENIED;
  748|      0|            break;
  749|      0|        }
  750|       |
  751|      0|        rc = SSH_PACKET_ALLOWED;
  752|      0|        break;
  753|      0|    case SSH2_MSG_USERAUTH_GSSAPI_EXCHANGE_COMPLETE:  // 63
  ------------------
  |  |   46|      0|#define SSH2_MSG_USERAUTH_GSSAPI_EXCHANGE_COMPLETE 63
  ------------------
  |  Branch (753:5): [True: 0, False: 184k]
  ------------------
  754|       |        /* Server only */
  755|       |        /*
  756|       |         * States required:
  757|       |         * - session_state == SSH_SESSION_STATE_AUTHENTICATING
  758|       |         * - session->gssapi->state == SSH_GSSAPI_STATE_RCV_MIC
  759|       |         *
  760|       |         * Transitions:
  761|       |         * - None
  762|       |         */
  763|       |#ifdef WITH_GSSAPI
  764|       |        if (session->client) {
  765|       |            rc = SSH_PACKET_DENIED;
  766|       |            break;
  767|       |        }
  768|       |        if (session->session_state != SSH_SESSION_STATE_AUTHENTICATING) {
  769|       |            rc = SSH_PACKET_DENIED;
  770|       |            break;
  771|       |        }
  772|       |        if (session->gssapi == NULL) {
  773|       |            rc = SSH_PACKET_DENIED;
  774|       |            break;
  775|       |        }
  776|       |        if (session->gssapi->state != SSH_GSSAPI_STATE_RCV_MIC) {
  777|       |            rc = SSH_PACKET_DENIED;
  778|       |            break;
  779|       |        }
  780|       |        rc = SSH_PACKET_ALLOWED;
  781|       |        break;
  782|       |#else
  783|      0|        rc = SSH_PACKET_DENIED;
  784|      0|        break;
  785|      0|#endif  /* WITH_GSSAPI */
  786|      0|    case SSH2_MSG_USERAUTH_GSSAPI_ERROR:              // 64
  ------------------
  |  |   47|      0|#define SSH2_MSG_USERAUTH_GSSAPI_ERROR 64
  ------------------
  |  Branch (786:5): [True: 0, False: 184k]
  ------------------
  787|       |        /* Client only */
  788|       |        /*
  789|       |         * States required:
  790|       |         * - session_state == SSH_SESSION_STATE_AUTHENTICATING
  791|       |         *
  792|       |         * Transitions:
  793|       |         * - None
  794|       |         */
  795|       |#ifdef WITH_GSSAPI
  796|       |        if (session->server) {
  797|       |            rc = SSH_PACKET_DENIED;
  798|       |            break;
  799|       |        }
  800|       |        if (session->session_state != SSH_SESSION_STATE_AUTHENTICATING) {
  801|       |            rc = SSH_PACKET_DENIED;
  802|       |            break;
  803|       |        }
  804|       |
  805|       |        rc = SSH_PACKET_ALLOWED;
  806|       |        break;
  807|       |#else
  808|      0|        rc = SSH_PACKET_DENIED;
  809|      0|        break;
  810|      0|#endif  /* WITH_GSSAPI */
  811|      0|    case SSH2_MSG_USERAUTH_GSSAPI_ERRTOK:             // 65
  ------------------
  |  |   48|      0|#define SSH2_MSG_USERAUTH_GSSAPI_ERRTOK 65
  ------------------
  |  Branch (811:5): [True: 0, False: 184k]
  ------------------
  812|       |        /*
  813|       |         * States required:
  814|       |         * - session_state == SSH_SESSION_STATE_AUTHENTICATING
  815|       |         *
  816|       |         * Transitions:
  817|       |         * - None
  818|       |         */
  819|       |#ifdef WITH_GSSAPI
  820|       |        if (session->session_state != SSH_SESSION_STATE_AUTHENTICATING) {
  821|       |            rc = SSH_PACKET_DENIED;
  822|       |            break;
  823|       |        }
  824|       |
  825|       |        rc = SSH_PACKET_ALLOWED;
  826|       |        break;
  827|       |#else
  828|      0|        rc = SSH_PACKET_DENIED;
  829|      0|        break;
  830|      0|#endif  /* WITH_GSSAPI */
  831|      0|    case SSH2_MSG_USERAUTH_GSSAPI_MIC:                // 66
  ------------------
  |  |   49|      0|#define SSH2_MSG_USERAUTH_GSSAPI_MIC 66
  ------------------
  |  Branch (831:5): [True: 0, False: 184k]
  ------------------
  832|       |        /* Server only */
  833|       |
  834|       |        /*
  835|       |         * States required:
  836|       |         * - session_state == SSH_SESSION_STATE_AUTHENTICATING
  837|       |         * - session->gssapi->state == SSH_GSSAPI_STATE_RCV_MIC
  838|       |         *
  839|       |         * Transitions:
  840|       |         * Depending on the result of the verification, the states are
  841|       |         * changed:
  842|       |         * - SSH_AUTH_SUCCESS:
  843|       |         *   - session->session_state = SSH_SESSION_STATE_AUTHENTICATED
  844|       |         *   - session->flags != SSH_SESSION_FLAG_AUTHENTICATED
  845|       |         * - SSH_AUTH_PARTIAL:
  846|       |         *   - None
  847|       |         * - any other case:
  848|       |         *   - None
  849|       |         * */
  850|       |#ifdef WITH_GSSAPI
  851|       |        /* If this is a client, reject the message */
  852|       |        if (session->client) {
  853|       |            rc = SSH_PACKET_DENIED;
  854|       |            break;
  855|       |        }
  856|       |
  857|       |        if (session->dh_handshake_state != DH_STATE_FINISHED) {
  858|       |            rc = SSH_PACKET_DENIED;
  859|       |            break;
  860|       |        }
  861|       |
  862|       |        if (session->session_state != SSH_SESSION_STATE_AUTHENTICATING) {
  863|       |            rc = SSH_PACKET_DENIED;
  864|       |            break;
  865|       |        }
  866|       |
  867|       |        rc = SSH_PACKET_ALLOWED;
  868|       |        break;
  869|       |#else
  870|      0|        rc = SSH_PACKET_DENIED;
  871|      0|        break;
  872|      0|#endif  /* WITH_GSSAPI */
  873|      0|    case SSH2_MSG_GLOBAL_REQUEST:                     // 80
  ------------------
  |  |   51|      0|#define SSH2_MSG_GLOBAL_REQUEST 80
  ------------------
  |  Branch (873:5): [True: 0, False: 184k]
  ------------------
  874|       |        /*
  875|       |         * States required:
  876|       |         * - session_state == SSH_SESSION_STATE_AUTHENTICATED
  877|       |         *
  878|       |         * Transitions:
  879|       |         * - None
  880|       |         * */
  881|       |
  882|      0|        if (session->session_state != SSH_SESSION_STATE_AUTHENTICATED) {
  ------------------
  |  Branch (882:13): [True: 0, False: 0]
  ------------------
  883|      0|            rc = SSH_PACKET_DENIED;
  884|      0|            break;
  885|      0|        }
  886|       |
  887|      0|        rc = SSH_PACKET_ALLOWED;
  888|      0|        break;
  889|      0|    case SSH2_MSG_REQUEST_SUCCESS:                    // 81
  ------------------
  |  |   52|      0|#define SSH2_MSG_REQUEST_SUCCESS 81
  ------------------
  |  Branch (889:5): [True: 0, False: 184k]
  ------------------
  890|       |        /*
  891|       |         * States required:
  892|       |         * - session_state == SSH_SESSION_STATE_AUTHENTICATED
  893|       |         *
  894|       |         * Transitions:
  895|       |         * - From channel->request_state == SSH_CHANNEL_REQ_STATE_PENDING
  896|       |         * - To   channel->request_state = SSH_CHANNEL_REQ_STATE_ACCEPTED
  897|       |         *
  898|       |         * If not in a pending state, message is ignored in the callback handler.
  899|       |         * */
  900|       |
  901|      0|        if (session->session_state != SSH_SESSION_STATE_AUTHENTICATED) {
  ------------------
  |  Branch (901:13): [True: 0, False: 0]
  ------------------
  902|      0|            rc = SSH_PACKET_DENIED;
  903|      0|            break;
  904|      0|        }
  905|       |
  906|      0|        rc = SSH_PACKET_ALLOWED;
  907|      0|        break;
  908|      0|    case SSH2_MSG_REQUEST_FAILURE:                    // 82
  ------------------
  |  |   53|      0|#define SSH2_MSG_REQUEST_FAILURE 82
  ------------------
  |  Branch (908:5): [True: 0, False: 184k]
  ------------------
  909|       |        /*
  910|       |         * States required:
  911|       |         * - session_state == SSH_SESSION_STATE_AUTHENTICATED
  912|       |         *
  913|       |         * Transitions:
  914|       |         * - From channel->request_state == SSH_CHANNEL_REQ_STATE_PENDING
  915|       |         * - To   channel->request_state = SSH_CHANNEL_REQ_STATE_ACCEPTED
  916|       |         *
  917|       |         * If not in a pending state, message is ignored in the callback handler.
  918|       |         * */
  919|       |
  920|      0|        if (session->session_state != SSH_SESSION_STATE_AUTHENTICATED) {
  ------------------
  |  Branch (920:13): [True: 0, False: 0]
  ------------------
  921|      0|            rc = SSH_PACKET_DENIED;
  922|      0|            break;
  923|      0|        }
  924|       |
  925|      0|        rc = SSH_PACKET_ALLOWED;
  926|      0|        break;
  927|  8.64k|    case SSH2_MSG_CHANNEL_OPEN:                       // 90
  ------------------
  |  |   54|  8.64k|#define SSH2_MSG_CHANNEL_OPEN 90
  ------------------
  |  Branch (927:5): [True: 8.64k, False: 175k]
  ------------------
  928|       |        /*
  929|       |         * States required:
  930|       |         * - session_state == SSH_SESSION_STATE_AUTHENTICATED
  931|       |         *
  932|       |         * Transitions:
  933|       |         * - None
  934|       |         * */
  935|       |
  936|  8.64k|        if (session->session_state != SSH_SESSION_STATE_AUTHENTICATED) {
  ------------------
  |  Branch (936:13): [True: 0, False: 8.64k]
  ------------------
  937|      0|            rc = SSH_PACKET_DENIED;
  938|      0|            break;
  939|      0|        }
  940|       |
  941|  8.64k|        rc = SSH_PACKET_ALLOWED;
  942|  8.64k|        break;
  943|  8.64k|    case SSH2_MSG_CHANNEL_OPEN_CONFIRMATION:          // 91
  ------------------
  |  |   55|  8.64k|#define SSH2_MSG_CHANNEL_OPEN_CONFIRMATION 91
  ------------------
  |  Branch (943:5): [True: 8.64k, False: 175k]
  ------------------
  944|       |        /*
  945|       |         * States required:
  946|       |         * - session_state == SSH_SESSION_STATE_AUTHENTICATED
  947|       |         *
  948|       |         * Transitions:
  949|       |         * - channel->state = SSH_CHANNEL_STATE_OPEN
  950|       |         * - channel->flags &= ~SSH_CHANNEL_FLAG_NOT_BOUND
  951|       |         * */
  952|       |
  953|  8.64k|        if (session->session_state != SSH_SESSION_STATE_AUTHENTICATED) {
  ------------------
  |  Branch (953:13): [True: 0, False: 8.64k]
  ------------------
  954|      0|            rc = SSH_PACKET_DENIED;
  955|      0|            break;
  956|      0|        }
  957|       |
  958|  8.64k|        rc = SSH_PACKET_ALLOWED;
  959|  8.64k|        break;
  960|      0|    case SSH2_MSG_CHANNEL_OPEN_FAILURE:               // 92
  ------------------
  |  |   56|      0|#define SSH2_MSG_CHANNEL_OPEN_FAILURE 92
  ------------------
  |  Branch (960:5): [True: 0, False: 184k]
  ------------------
  961|       |        /*
  962|       |         * States required:
  963|       |         * - session_state == SSH_SESSION_STATE_AUTHENTICATED
  964|       |         *
  965|       |         * Transitions:
  966|       |         * - channel->state = SSH_CHANNEL_STATE_OPEN_DENIED
  967|       |         * */
  968|       |
  969|      0|        if (session->session_state != SSH_SESSION_STATE_AUTHENTICATED) {
  ------------------
  |  Branch (969:13): [True: 0, False: 0]
  ------------------
  970|      0|            rc = SSH_PACKET_DENIED;
  971|      0|            break;
  972|      0|        }
  973|       |
  974|      0|        rc = SSH_PACKET_ALLOWED;
  975|      0|        break;
  976|      0|    case SSH2_MSG_CHANNEL_WINDOW_ADJUST:              // 93
  ------------------
  |  |   57|      0|#define SSH2_MSG_CHANNEL_WINDOW_ADJUST 93
  ------------------
  |  Branch (976:5): [True: 0, False: 184k]
  ------------------
  977|       |        /*
  978|       |         * States required:
  979|       |         * - session_state == SSH_SESSION_STATE_AUTHENTICATED
  980|       |         *
  981|       |         * Transitions:
  982|       |         * - None
  983|       |         * */
  984|       |
  985|      0|        if (session->session_state != SSH_SESSION_STATE_AUTHENTICATED) {
  ------------------
  |  Branch (985:13): [True: 0, False: 0]
  ------------------
  986|      0|            rc = SSH_PACKET_DENIED;
  987|      0|            break;
  988|      0|        }
  989|       |
  990|      0|        rc = SSH_PACKET_ALLOWED;
  991|      0|        break;
  992|  46.0k|    case SSH2_MSG_CHANNEL_DATA:                       // 94
  ------------------
  |  |   58|  46.0k|#define SSH2_MSG_CHANNEL_DATA 94
  ------------------
  |  Branch (992:5): [True: 46.0k, False: 138k]
  ------------------
  993|       |        /*
  994|       |         * States required:
  995|       |         * - session_state == SSH_SESSION_STATE_AUTHENTICATED
  996|       |         *
  997|       |         * Transitions:
  998|       |         * - None
  999|       |         * */
 1000|       |
 1001|  46.0k|        if (session->session_state != SSH_SESSION_STATE_AUTHENTICATED) {
  ------------------
  |  Branch (1001:13): [True: 0, False: 46.0k]
  ------------------
 1002|      0|            rc = SSH_PACKET_DENIED;
 1003|      0|            break;
 1004|      0|        }
 1005|       |
 1006|  46.0k|        rc = SSH_PACKET_ALLOWED;
 1007|  46.0k|        break;
 1008|      0|    case SSH2_MSG_CHANNEL_EXTENDED_DATA:              // 95
  ------------------
  |  |   59|      0|#define SSH2_MSG_CHANNEL_EXTENDED_DATA 95
  ------------------
  |  Branch (1008:5): [True: 0, False: 184k]
  ------------------
 1009|       |        /*
 1010|       |         * States required:
 1011|       |         * - session_state == SSH_SESSION_STATE_AUTHENTICATED
 1012|       |         *
 1013|       |         * Transitions:
 1014|       |         * - None
 1015|       |         * */
 1016|       |
 1017|      0|        if (session->session_state != SSH_SESSION_STATE_AUTHENTICATED) {
  ------------------
  |  Branch (1017:13): [True: 0, False: 0]
  ------------------
 1018|      0|            rc = SSH_PACKET_DENIED;
 1019|      0|            break;
 1020|      0|        }
 1021|       |
 1022|      0|        rc = SSH_PACKET_ALLOWED;
 1023|      0|        break;
 1024|  8.64k|    case SSH2_MSG_CHANNEL_EOF:                        // 96
  ------------------
  |  |   60|  8.64k|#define SSH2_MSG_CHANNEL_EOF	96
  ------------------
  |  Branch (1024:5): [True: 8.64k, False: 175k]
  ------------------
 1025|       |        /*
 1026|       |         * States required:
 1027|       |         * - session_state == SSH_SESSION_STATE_AUTHENTICATED
 1028|       |         *
 1029|       |         * Transitions:
 1030|       |         * - None
 1031|       |         * */
 1032|       |
 1033|  8.64k|        if (session->session_state != SSH_SESSION_STATE_AUTHENTICATED) {
  ------------------
  |  Branch (1033:13): [True: 0, False: 8.64k]
  ------------------
 1034|      0|            rc = SSH_PACKET_DENIED;
 1035|      0|            break;
 1036|      0|        }
 1037|       |
 1038|  8.64k|        rc = SSH_PACKET_ALLOWED;
 1039|  8.64k|        break;
 1040|  8.64k|    case SSH2_MSG_CHANNEL_CLOSE:                      // 97
  ------------------
  |  |   61|  8.64k|#define SSH2_MSG_CHANNEL_CLOSE 97
  ------------------
  |  Branch (1040:5): [True: 8.64k, False: 175k]
  ------------------
 1041|       |        /*
 1042|       |         * States required:
 1043|       |         * - session_state == SSH_SESSION_STATE_AUTHENTICATED
 1044|       |         *
 1045|       |         * Transitions:
 1046|       |         * - channel->state = SSH_CHANNEL_STATE_CLOSED
 1047|       |         * - channel->flags |= SSH_CHANNEL_FLAG_CLOSED_REMOTE
 1048|       |         * */
 1049|       |
 1050|  8.64k|        if (session->session_state != SSH_SESSION_STATE_AUTHENTICATED) {
  ------------------
  |  Branch (1050:13): [True: 0, False: 8.64k]
  ------------------
 1051|      0|            rc = SSH_PACKET_DENIED;
 1052|      0|            break;
 1053|      0|        }
 1054|       |
 1055|  8.64k|        rc = SSH_PACKET_ALLOWED;
 1056|  8.64k|        break;
 1057|  8.64k|    case SSH2_MSG_CHANNEL_REQUEST:                    // 98
  ------------------
  |  |   62|  8.64k|#define SSH2_MSG_CHANNEL_REQUEST 98
  ------------------
  |  Branch (1057:5): [True: 8.64k, False: 175k]
  ------------------
 1058|       |        /*
 1059|       |         * States required:
 1060|       |         * - session_state == SSH_SESSION_STATE_AUTHENTICATED
 1061|       |         *
 1062|       |         * Transitions:
 1063|       |         * - Depends on the request
 1064|       |         * */
 1065|       |
 1066|  8.64k|        if (session->session_state != SSH_SESSION_STATE_AUTHENTICATED) {
  ------------------
  |  Branch (1066:13): [True: 0, False: 8.64k]
  ------------------
 1067|      0|            rc = SSH_PACKET_DENIED;
 1068|      0|            break;
 1069|      0|        }
 1070|       |
 1071|  8.64k|        rc = SSH_PACKET_ALLOWED;
 1072|  8.64k|        break;
 1073|      2|    case SSH2_MSG_CHANNEL_SUCCESS:                    // 99
  ------------------
  |  |   63|      2|#define SSH2_MSG_CHANNEL_SUCCESS 99
  ------------------
  |  Branch (1073:5): [True: 2, False: 184k]
  ------------------
 1074|       |        /*
 1075|       |         * States required:
 1076|       |         * - session_state == SSH_SESSION_STATE_AUTHENTICATED
 1077|       |         *
 1078|       |         * Transitions:
 1079|       |         * - From channel->request_state == SSH_CHANNEL_REQ_STATE_PENDING
 1080|       |         * - To   channel->request_state = SSH_CHANNEL_REQ_STATE_ACCEPTED
 1081|       |         *
 1082|       |         * If not in a pending state, message is ignored in the callback handler.
 1083|       |         * */
 1084|       |
 1085|      2|        if (session->session_state != SSH_SESSION_STATE_AUTHENTICATED) {
  ------------------
  |  Branch (1085:13): [True: 0, False: 2]
  ------------------
 1086|      0|            rc = SSH_PACKET_DENIED;
 1087|      0|            break;
 1088|      0|        }
 1089|       |
 1090|      2|        rc = SSH_PACKET_ALLOWED;
 1091|      2|        break;
 1092|      0|    case SSH2_MSG_CHANNEL_FAILURE:                    // 100
  ------------------
  |  |   64|      0|#define SSH2_MSG_CHANNEL_FAILURE 100
  ------------------
  |  Branch (1092:5): [True: 0, False: 184k]
  ------------------
 1093|       |        /*
 1094|       |         * States required:
 1095|       |         * - session_state == SSH_SESSION_STATE_AUTHENTICATED
 1096|       |         *
 1097|       |         * Transitions:
 1098|       |         * - From channel->request_state == SSH_CHANNEL_REQ_STATE_PENDING
 1099|       |         * - To   channel->request_state = SSH_CHANNEL_REQ_STATE_ACCEPTED
 1100|       |         *
 1101|       |         * If not in a pending state, message is ignored in the callback handler.
 1102|       |         * */
 1103|       |
 1104|      0|        if (session->session_state != SSH_SESSION_STATE_AUTHENTICATED) {
  ------------------
  |  Branch (1104:13): [True: 0, False: 0]
  ------------------
 1105|      0|            rc = SSH_PACKET_DENIED;
 1106|      0|            break;
 1107|      0|        }
 1108|       |
 1109|      0|        rc = SSH_PACKET_ALLOWED;
 1110|      0|        break;
 1111|      0|    case SSH2_MSG_PING: // 192
  ------------------
  |  |   69|      0|#define SSH2_MSG_PING 192
  ------------------
  |  Branch (1111:5): [True: 0, False: 184k]
  ------------------
 1112|      0|    case SSH2_MSG_PONG: // 193
  ------------------
  |  |   70|      0|#define SSH2_MSG_PONG 193
  ------------------
  |  Branch (1112:5): [True: 0, False: 184k]
  ------------------
 1113|       |        /*
 1114|       |         * Transport-level ping/pong messages.
 1115|       |         *
 1116|       |         * Always allow PING and PONG messages through the filter.
 1117|       |         * State checking (auth/rekey) is handled in the packet handler itself,
 1118|       |         * following OpenSSH's approach of treating these as implicit
 1119|       |         * transport-level messages (like IGNORE and DEBUG).
 1120|       |         *
 1121|       |         * States required:
 1122|       |         * - None (always allowed)
 1123|       |         *
 1124|       |         * Transitions:
 1125|       |         * - None
 1126|       |         */
 1127|      0|        rc = SSH_PACKET_ALLOWED;
 1128|      0|        break;
 1129|      0|    default:
  ------------------
  |  Branch (1129:5): [True: 0, False: 184k]
  ------------------
 1130|       |        /* Unknown message, do not filter */
 1131|      0|        rc = SSH_PACKET_UNKNOWN;
 1132|      0|        goto end;
 1133|   184k|    }
 1134|       |
 1135|   184k|end:
 1136|       |#ifdef DEBUG_PACKET
 1137|       |    if (rc == SSH_PACKET_DENIED) {
 1138|       |        SSH_LOG(SSH_LOG_PACKET, "REJECTED packet type %d: ",
 1139|       |                session->in_packet.type);
 1140|       |    }
 1141|       |
 1142|       |    if (rc == SSH_PACKET_UNKNOWN) {
 1143|       |        SSH_LOG(SSH_LOG_PACKET, "UNKNOWN packet type %d",
 1144|       |                session->in_packet.type);
 1145|       |    }
 1146|       |#endif
 1147|       |
 1148|   184k|    return rc;
 1149|   184k|}
packet.c:ssh_packet_need_rekey:
 1201|   394k|{
 1202|   394k|    bool data_rekey_needed = false;
 1203|   394k|    struct ssh_crypto_struct *crypto = NULL;
 1204|   394k|    struct ssh_cipher_struct *out_cipher = NULL, *in_cipher = NULL;
 1205|   394k|    uint32_t next_blocks;
 1206|       |
 1207|       |    /* We can safely rekey only in authenticated state */
 1208|   394k|    if ((session->flags & SSH_SESSION_FLAG_AUTHENTICATED) == 0) {
  ------------------
  |  |   78|   394k|#define SSH_SESSION_FLAG_AUTHENTICATED 0x0002
  ------------------
  |  Branch (1208:9): [True: 172k, False: 221k]
  ------------------
 1209|   172k|        return false;
 1210|   172k|    }
 1211|       |
 1212|       |    /* Do not rekey if the rekey/key-exchange is in progress */
 1213|   221k|    if (session->dh_handshake_state != DH_STATE_FINISHED) {
  ------------------
  |  Branch (1213:9): [True: 0, False: 221k]
  ------------------
 1214|      0|        return false;
 1215|      0|    }
 1216|       |
 1217|   221k|    crypto = ssh_packet_get_current_crypto(session, SSH_DIRECTION_BOTH);
 1218|   221k|    if (crypto == NULL) {
  ------------------
  |  Branch (1218:9): [True: 0, False: 221k]
  ------------------
 1219|      0|        return false;
 1220|      0|    }
 1221|       |
 1222|   221k|    out_cipher = crypto->out_cipher;
 1223|   221k|    in_cipher = crypto->in_cipher;
 1224|       |
 1225|       |    /* Make sure we can send at least something for very small limits */
 1226|   221k|    if ((out_cipher->packets == 0) && (in_cipher->packets == 0)) {
  ------------------
  |  Branch (1226:9): [True: 0, False: 221k]
  |  Branch (1226:39): [True: 0, False: 0]
  ------------------
 1227|      0|        return false;
 1228|      0|    }
 1229|       |
 1230|       |    /* Time based rekeying */
 1231|   221k|    if (session->opts.rekey_time != 0 &&
  ------------------
  |  Branch (1231:9): [True: 0, False: 221k]
  ------------------
 1232|      0|        ssh_timeout_elapsed(&session->last_rekey_time,
  ------------------
  |  Branch (1232:9): [True: 0, False: 0]
  ------------------
 1233|      0|                            session->opts.rekey_time)) {
 1234|      0|        return true;
 1235|      0|    }
 1236|       |
 1237|       |    /* RFC4344, Section 3.1 Recommends rekeying after 2^31 packets in either
 1238|       |     * direction to avoid possible information leakage through the MAC tag
 1239|       |     */
 1240|   221k|    if (out_cipher->packets > MAX_PACKETS ||
  ------------------
  |  | 1197|   443k|#define MAX_PACKETS    (1UL<<31)
  ------------------
  |  Branch (1240:9): [True: 0, False: 221k]
  ------------------
 1241|   221k|        in_cipher->packets > MAX_PACKETS) {
  ------------------
  |  | 1197|   221k|#define MAX_PACKETS    (1UL<<31)
  ------------------
  |  Branch (1241:9): [True: 18.4E, False: 221k]
  ------------------
 1242|      0|        return true;
 1243|      0|    }
 1244|       |
 1245|       |    /* Data-based rekeying:
 1246|       |     *  * For outgoing packets we can still delay them
 1247|       |     *  * Incoming packets need to be processed anyway, but we can
 1248|       |     *    signalize our intention to rekey
 1249|       |     */
 1250|   221k|    next_blocks = payloadsize / out_cipher->blocksize;
 1251|   221k|    data_rekey_needed = (out_cipher->max_blocks != 0 &&
  ------------------
  |  Branch (1251:26): [True: 221k, False: 18.4E]
  ------------------
 1252|   221k|                         out_cipher->blocks + next_blocks > out_cipher->max_blocks) ||
  ------------------
  |  Branch (1252:26): [True: 0, False: 221k]
  ------------------
 1253|   221k|                         (in_cipher->max_blocks != 0 &&
  ------------------
  |  Branch (1253:27): [True: 221k, False: 0]
  ------------------
 1254|   221k|                         in_cipher->blocks + next_blocks > in_cipher->max_blocks);
  ------------------
  |  Branch (1254:26): [True: 0, False: 221k]
  ------------------
 1255|       |
 1256|   221k|    SSH_LOG(SSH_LOG_PACKET,
  ------------------
  |  |  281|   221k|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 1257|   221k|            "rekey: [data_rekey_needed=%d, out_blocks=%" PRIu64 ", in_blocks=%" PRIu64 "]",
 1258|   221k|            data_rekey_needed,
 1259|   221k|            out_cipher->blocks + next_blocks,
 1260|   221k|            in_cipher->blocks + next_blocks);
 1261|       |
 1262|   221k|    return data_rekey_needed;
 1263|   221k|}
packet.c:ssh_packet_socket_controlflow_callback:
 1653|   101k|{
 1654|   101k|    ssh_session session = userdata;
 1655|   101k|    struct ssh_iterator *it = NULL;
 1656|   101k|    ssh_channel channel = NULL;
 1657|       |
 1658|   101k|    if (code == SSH_SOCKET_FLOW_WRITEWONTBLOCK) {
  ------------------
  |  |  518|   101k|#define SSH_SOCKET_FLOW_WRITEWONTBLOCK 2
  ------------------
  |  Branch (1658:9): [True: 101k, False: 0]
  ------------------
 1659|   101k|        SSH_LOG(SSH_LOG_TRACE, "sending channel_write_wontblock callback");
  ------------------
  |  |  281|   101k|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 1660|       |
 1661|       |        /* the out pipe is empty so we can forward this to channels */
 1662|   101k|        it = ssh_list_get_iterator(session->channels);
 1663|   127k|        while (it != NULL) {
  ------------------
  |  Branch (1663:16): [True: 25.9k, False: 101k]
  ------------------
 1664|  25.9k|            channel = ssh_iterator_value(ssh_channel, it);
  ------------------
  |  |  114|  25.9k|  ((type)((iterator)->data))
  ------------------
 1665|       |            ssh_callbacks_execute_list(channel->callbacks,
  ------------------
  |  |  566|  25.9k|    do {                                                      \
  |  |  567|  25.9k|        struct ssh_iterator *i = ssh_list_get_iterator(list); \
  |  |  568|  25.9k|        cbtype cb;                                            \
  |  |  569|  34.5k|        while (i != NULL){                                    \
  |  |  ------------------
  |  |  |  Branch (569:16): [True: 8.63k, False: 25.9k]
  |  |  ------------------
  |  |  570|  8.63k|            cb = ssh_iterator_value(cbtype, i);               \
  |  |  ------------------
  |  |  |  |  114|  8.63k|  ((type)((iterator)->data))
  |  |  ------------------
  |  |  571|  8.63k|            if (ssh_callbacks_exists(cb, c))                  \
  |  |  ------------------
  |  |  |  |  547|  8.63k|#define ssh_callbacks_exists(p,c) (\
  |  |  |  |  548|  8.63k|  (p != NULL) && ( (char *)&((p)-> c) < (char *)(p) + (p)->size ) && \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (548:3): [True: 8.63k, False: 0]
  |  |  |  |  |  Branch (548:18): [True: 8.63k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  549|  8.63k|  ((p)-> c != NULL) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (549:3): [True: 0, False: 8.63k]
  |  |  |  |  ------------------
  |  |  |  |  550|  8.63k|  )
  |  |  ------------------
  |  |  572|  8.63k|                cb-> c (__VA_ARGS__, cb->userdata);           \
  |  |  573|  8.63k|            i = i->next;                                      \
  |  |  574|  8.63k|        }                                                     \
  |  |  575|  25.9k|    } while(0)
  |  |  ------------------
  |  |  |  Branch (575:13): [Folded, False: 25.9k]
  |  |  ------------------
  ------------------
 1666|  25.9k|                                       ssh_channel_callbacks,
 1667|  25.9k|                                       channel_write_wontblock_function,
 1668|  25.9k|                                       session,
 1669|  25.9k|                                       channel,
 1670|  25.9k|                                       channel->remote_window);
 1671|  25.9k|            it = it->next;
 1672|  25.9k|        }
 1673|   101k|    }
 1674|   101k|}
packet.c:ssh_packet_in_rekey:
 2054|   210k|{
 2055|       |    /* We know we are rekeying if we are authenticated and the DH
 2056|       |     * status is not finished, but we only queue packets until we've
 2057|       |     * sent our NEWKEYS.
 2058|       |     */
 2059|   210k|    return (session->flags & SSH_SESSION_FLAG_AUTHENTICATED) &&
  ------------------
  |  |   78|   210k|#define SSH_SESSION_FLAG_AUTHENTICATED 0x0002
  ------------------
  |  Branch (2059:12): [True: 115k, False: 95.0k]
  ------------------
 2060|   115k|           (session->dh_handshake_state != DH_STATE_FINISHED) &&
  ------------------
  |  Branch (2060:12): [True: 0, False: 115k]
  ------------------
 2061|      0|           (session->dh_handshake_state != DH_STATE_NEWKEYS_SENT);
  ------------------
  |  Branch (2061:12): [True: 0, False: 0]
  ------------------
 2062|   210k|}
packet.c:packet_send2:
 1894|   210k|{
 1895|   210k|    unsigned int blocksize = 8;
 1896|   210k|    unsigned int lenfield_blocksize = 0;
 1897|   210k|    enum ssh_hmac_e hmac_type;
 1898|   210k|    uint32_t currentlen = ssh_buffer_get_len(session->out_buffer);
 1899|   210k|    struct ssh_crypto_struct *crypto = NULL;
 1900|   210k|    unsigned char *hmac = NULL;
 1901|   210k|    uint8_t padding_data[32] = { 0 };
 1902|   210k|    uint8_t padding_size;
 1903|   210k|    uint32_t finallen, payloadsize, compsize;
 1904|   210k|    uint8_t header[5] = {0};
 1905|   210k|    uint8_t type, *payload;
 1906|   210k|    int rc = SSH_ERROR;
  ------------------
  |  |  317|   210k|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 1907|   210k|    bool etm = false;
 1908|   210k|    int etm_packet_offset = 0;
 1909|       |
 1910|   210k|    crypto = ssh_packet_get_current_crypto(session, SSH_DIRECTION_OUT);
 1911|   210k|    if (crypto) {
  ------------------
  |  Branch (1911:9): [True: 158k, False: 51.8k]
  ------------------
 1912|   158k|        blocksize = crypto->out_cipher->blocksize;
 1913|   158k|        lenfield_blocksize = crypto->out_cipher->lenfield_blocksize;
 1914|   158k|        hmac_type = crypto->out_hmac;
 1915|   158k|        etm = crypto->out_hmac_etm;
 1916|   158k|    } else {
 1917|  51.8k|        hmac_type = session->next_crypto->out_hmac;
 1918|  51.8k|    }
 1919|       |
 1920|   210k|    payload = (uint8_t *)ssh_buffer_get(session->out_buffer);
 1921|   210k|    type = payload[0]; /* type is the first byte of the packet now */
 1922|       |
 1923|   210k|    payloadsize = currentlen;
 1924|   210k|    if (etm) {
  ------------------
  |  Branch (1924:9): [True: 0, False: 210k]
  ------------------
 1925|      0|        etm_packet_offset = sizeof(uint32_t);
 1926|      0|        lenfield_blocksize = 0;
 1927|      0|    }
 1928|       |
 1929|   210k|    if (crypto != NULL && crypto->do_compress_out &&
  ------------------
  |  Branch (1929:9): [True: 158k, False: 51.8k]
  |  Branch (1929:27): [True: 0, False: 158k]
  ------------------
 1930|      0|        ssh_buffer_get_len(session->out_buffer) > 0) {
  ------------------
  |  Branch (1930:9): [True: 0, False: 0]
  ------------------
 1931|      0|        rc = compress_buffer(session,session->out_buffer);
 1932|      0|        if (rc < 0) {
  ------------------
  |  Branch (1932:13): [True: 0, False: 0]
  ------------------
 1933|      0|            goto error;
 1934|      0|        }
 1935|      0|        currentlen = ssh_buffer_get_len(session->out_buffer);
 1936|      0|    }
 1937|   210k|    compsize = currentlen;
 1938|       |    /* compressed payload + packet len (4) + padding_size len (1) */
 1939|       |    /* totallen - lenfield_blocksize - etm_packet_offset must be equal to 0 (mod blocksize) */
 1940|   210k|    padding_size = (blocksize - ((blocksize - lenfield_blocksize - etm_packet_offset + currentlen + 5) % blocksize));
 1941|   210k|    if (padding_size < 4) {
  ------------------
  |  Branch (1941:9): [True: 90.6k, False: 119k]
  ------------------
 1942|  90.6k|        padding_size += blocksize;
 1943|  90.6k|    }
 1944|       |
 1945|   210k|    if (crypto != NULL) {
  ------------------
  |  Branch (1945:9): [True: 158k, False: 51.8k]
  ------------------
 1946|   158k|        int ok;
 1947|       |
 1948|   158k|        ok = ssh_get_random(padding_data, padding_size, 0);
 1949|   158k|        if (!ok) {
  ------------------
  |  Branch (1949:13): [True: 0, False: 158k]
  ------------------
 1950|      0|            ssh_set_error(session, SSH_FATAL, "PRNG error");
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
 1951|      0|            goto error;
 1952|      0|        }
 1953|   158k|    }
 1954|       |
 1955|   210k|    finallen = currentlen - etm_packet_offset + padding_size + 1;
 1956|       |
 1957|   210k|    PUSH_BE_U32(header, 0, finallen);
  ------------------
  |  |   89|   210k|    (PUSH_BE_U16((data), (pos), (uint16_t)(((uint32_t)(val)) >> 16)), PUSH_BE_U16((data), (pos) + 2, (uint16_t)((val) & 0xffff)))
  |  |  ------------------
  |  |  |  |   86|   210k|    (PUSH_BE_U8((data), (pos), (uint8_t)(((uint16_t)(val)) >> 8)), PUSH_BE_U8((data), (pos) + 1, (uint8_t)((val) & 0xff)))
  |  |  |  |  ------------------
  |  |  |  |  |  |   83|   210k|    (_DATA_BYTE(data, pos) = ((uint8_t)(val)))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   31|   210k|    (((uint8_t *)(data))[(pos)])
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |                   (PUSH_BE_U8((data), (pos), (uint8_t)(((uint16_t)(val)) >> 8)), PUSH_BE_U8((data), (pos) + 1, (uint8_t)((val) & 0xff)))
  |  |  |  |  ------------------
  |  |  |  |  |  |   83|   210k|    (_DATA_BYTE(data, pos) = ((uint8_t)(val)))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   31|   210k|    (((uint8_t *)(data))[(pos)])
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                   (PUSH_BE_U16((data), (pos), (uint16_t)(((uint32_t)(val)) >> 16)), PUSH_BE_U16((data), (pos) + 2, (uint16_t)((val) & 0xffff)))
  |  |  ------------------
  |  |  |  |   86|   210k|    (PUSH_BE_U8((data), (pos), (uint8_t)(((uint16_t)(val)) >> 8)), PUSH_BE_U8((data), (pos) + 1, (uint8_t)((val) & 0xff)))
  |  |  |  |  ------------------
  |  |  |  |  |  |   83|   210k|    (_DATA_BYTE(data, pos) = ((uint8_t)(val)))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   31|   210k|    (((uint8_t *)(data))[(pos)])
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |                   (PUSH_BE_U8((data), (pos), (uint8_t)(((uint16_t)(val)) >> 8)), PUSH_BE_U8((data), (pos) + 1, (uint8_t)((val) & 0xff)))
  |  |  |  |  ------------------
  |  |  |  |  |  |   83|   210k|    (_DATA_BYTE(data, pos) = ((uint8_t)(val)))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   31|   210k|    (((uint8_t *)(data))[(pos)])
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1958|   210k|    PUSH_BE_U8(header, 4, padding_size);
  ------------------
  |  |   83|   210k|    (_DATA_BYTE(data, pos) = ((uint8_t)(val)))
  |  |  ------------------
  |  |  |  |   31|   210k|    (((uint8_t *)(data))[(pos)])
  |  |  ------------------
  ------------------
 1959|       |
 1960|   210k|    rc = ssh_buffer_prepend_data(session->out_buffer,
 1961|   210k|                                 header,
 1962|   210k|                                 sizeof(header));
 1963|   210k|    if (rc < 0) {
  ------------------
  |  Branch (1963:9): [True: 0, False: 210k]
  ------------------
 1964|      0|        goto error;
 1965|      0|    }
 1966|       |
 1967|   210k|    rc = ssh_buffer_add_data(session->out_buffer, padding_data, padding_size);
 1968|   210k|    if (rc < 0) {
  ------------------
  |  Branch (1968:9): [True: 0, False: 210k]
  ------------------
 1969|      0|        goto error;
 1970|      0|    }
 1971|       |
 1972|   210k|#ifdef WITH_PCAP
 1973|   210k|    if (session->pcap_ctx != NULL) {
  ------------------
  |  Branch (1973:9): [True: 0, False: 210k]
  ------------------
 1974|      0|        ssh_pcap_context_write(session->pcap_ctx,
 1975|      0|                               SSH_PCAP_DIR_OUT,
 1976|      0|                               ssh_buffer_get(session->out_buffer),
 1977|      0|                               ssh_buffer_get_len(session->out_buffer),
 1978|      0|                               ssh_buffer_get_len(session->out_buffer));
 1979|      0|    }
 1980|   210k|#endif
 1981|       |
 1982|   210k|    hmac = ssh_packet_encrypt(session,
 1983|   210k|                              ssh_buffer_get(session->out_buffer),
 1984|   210k|                              ssh_buffer_get_len(session->out_buffer));
 1985|       |    /* XXX This returns null before switching on crypto, with none MAC
 1986|       |     * and on various errors.
 1987|       |     * We should distinguish between these cases to avoid hiding errors. */
 1988|   210k|    if (hmac != NULL) {
  ------------------
  |  Branch (1988:9): [True: 158k, False: 51.8k]
  ------------------
 1989|   158k|        rc = ssh_buffer_add_data(session->out_buffer,
 1990|   158k|                                 hmac,
 1991|   158k|                                 (uint32_t)hmac_digest_len(hmac_type));
 1992|   158k|        if (rc < 0) {
  ------------------
  |  Branch (1992:13): [True: 0, False: 158k]
  ------------------
 1993|      0|            goto error;
 1994|      0|        }
 1995|   158k|    }
 1996|       |
 1997|   210k|    rc = ssh_packet_write(session);
 1998|   210k|    if (rc == SSH_ERROR) {
  ------------------
  |  |  317|   210k|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  |  Branch (1998:9): [True: 0, False: 210k]
  ------------------
 1999|      0|        goto error;
 2000|      0|    }
 2001|   210k|    session->send_seq++;
 2002|   210k|    if (crypto != NULL) {
  ------------------
  |  Branch (2002:9): [True: 158k, False: 51.8k]
  ------------------
 2003|   158k|        struct ssh_cipher_struct *cipher = NULL;
 2004|       |
 2005|   158k|        cipher = crypto->out_cipher;
 2006|   158k|        cipher->packets++;
 2007|   158k|        cipher->blocks += payloadsize / cipher->blocksize;
 2008|   158k|    }
 2009|   210k|    if (session->raw_counter != NULL) {
  ------------------
  |  Branch (2009:9): [True: 0, False: 210k]
  ------------------
 2010|      0|        session->raw_counter->out_bytes += payloadsize;
 2011|      0|        session->raw_counter->out_packets++;
 2012|      0|    }
 2013|       |
 2014|   210k|    SSH_LOG(SSH_LOG_PACKET,
  ------------------
  |  |  281|   210k|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 2015|   210k|            "packet: wrote [type=%u, len=%" PRIu32 ", padding_size=%hhd, comp=%" PRIu32 ", "
 2016|   210k|            "payload=%" PRIu32 "]",
 2017|   210k|            type,
 2018|   210k|            finallen,
 2019|   210k|            padding_size,
 2020|   210k|            compsize,
 2021|   210k|            payloadsize);
 2022|       |
 2023|   210k|    rc = ssh_buffer_reinit(session->out_buffer);
 2024|   210k|    if (rc < 0) {
  ------------------
  |  Branch (2024:9): [True: 0, False: 210k]
  ------------------
 2025|      0|        rc = SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 2026|      0|        goto error;
 2027|      0|    }
 2028|       |
 2029|       |    /* We sent the NEWKEYS so any further packet needs to be encrypted
 2030|       |     * with the new keys. We can not switch both directions (need to decrypt
 2031|       |     * peer NEWKEYS) and we do not want to wait for the peer NEWKEYS
 2032|       |     * too, so we will switch only the OUT direction now.
 2033|       |     */
 2034|   210k|    if (type == SSH2_MSG_NEWKEYS) {
  ------------------
  |  |   13|   210k|#define SSH2_MSG_NEWKEYS 21
  ------------------
  |  Branch (2034:9): [True: 17.2k, False: 192k]
  ------------------
 2035|  17.2k|        rc = ssh_packet_set_newkeys(session, SSH_DIRECTION_OUT);
 2036|  17.2k|    }
 2037|   210k|error:
 2038|   210k|    return rc; /* SSH_OK, AGAIN or ERROR */
 2039|   210k|}
packet.c:ssh_packet_write:
 1883|   210k|static int ssh_packet_write(ssh_session session) {
 1884|   210k|  int rc = SSH_ERROR;
  ------------------
  |  |  317|   210k|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 1885|       |
 1886|   210k|  rc=ssh_socket_write(session->socket,
 1887|   210k|      ssh_buffer_get(session->out_buffer),
 1888|   210k|      ssh_buffer_get_len(session->out_buffer));
 1889|       |
 1890|   210k|  return rc;
 1891|   210k|}
packet.c:ssh_init_rekey_state:
 2239|  34.5k|{
 2240|       |    /* Reset the counters: should be NOOP */
 2241|  34.5k|    cipher->packets = 0;
 2242|  34.5k|    cipher->blocks = 0;
 2243|       |
 2244|       |    /* Default rekey limits for ciphers as specified in RFC4344, Section 3.2 */
 2245|  34.5k|    if (cipher->blocksize >= 16) {
  ------------------
  |  Branch (2245:9): [True: 25.9k, False: 8.64k]
  ------------------
 2246|       |        /* For larger block size (L bits) use maximum of 2**(L/4) blocks */
 2247|  25.9k|        cipher->max_blocks = (uint64_t)1 << (cipher->blocksize*2);
 2248|  25.9k|    } else {
 2249|       |        /* For smaller blocks use limit of 1 GB as recommended in RFC4253 */
 2250|  8.64k|        cipher->max_blocks = ((uint64_t)1 << 30) / cipher->blocksize;
 2251|  8.64k|    }
 2252|       |    /* If we have limit provided by user, use the smaller one */
 2253|  34.5k|    if (session->opts.rekey_data != 0) {
  ------------------
  |  Branch (2253:9): [True: 0, False: 34.5k]
  ------------------
 2254|      0|        cipher->max_blocks = MIN(cipher->max_blocks,
  ------------------
  |  |  365|      0|#define MIN(a,b) ((a) < (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (365:19): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 2255|      0|                                 session->opts.rekey_data / cipher->blocksize);
 2256|      0|    }
 2257|       |
 2258|  34.5k|    SSH_LOG(SSH_LOG_DEBUG,
  ------------------
  |  |  281|  34.5k|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 2259|  34.5k|            "Set rekey after %" PRIu64 " blocks",
 2260|  34.5k|            cipher->max_blocks);
 2261|  34.5k|}

ssh_packet_newkeys:
  143|  17.2k|{
  144|  17.2k|    ssh_string sig_blob = NULL;
  145|  17.2k|    ssh_signature sig = NULL;
  146|  17.2k|    int rc;
  147|       |
  148|  17.2k|    (void)packet;
  149|  17.2k|    (void)user;
  150|  17.2k|    (void)type;
  151|       |
  152|  17.2k|    SSH_LOG(SSH_LOG_DEBUG, "Received SSH_MSG_NEWKEYS");
  ------------------
  |  |  281|  17.2k|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  153|       |
  154|  17.2k|    if (session->session_state != SSH_SESSION_STATE_DH ||
  ------------------
  |  Branch (154:9): [True: 18.4E, False: 17.2k]
  ------------------
  155|  17.2k|        session->dh_handshake_state != DH_STATE_NEWKEYS_SENT) {
  ------------------
  |  Branch (155:9): [True: 0, False: 17.2k]
  ------------------
  156|      0|        ssh_set_error(session,
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  157|      0|                      SSH_FATAL,
  158|      0|                      "ssh_packet_newkeys called in wrong state : %d:%d",
  159|      0|                      session->session_state,
  160|      0|                      session->dh_handshake_state);
  161|      0|        goto error;
  162|      0|    }
  163|       |
  164|  17.2k|    if (session->flags & SSH_SESSION_FLAG_KEX_STRICT) {
  ------------------
  |  |   90|  17.2k|#define SSH_SESSION_FLAG_KEX_STRICT 0x0010
  ------------------
  |  Branch (164:9): [True: 17.2k, False: 1]
  ------------------
  165|       |        /* reset packet sequence number when running in strict kex mode */
  166|  17.2k|        session->recv_seq = 0;
  167|       |        /* Check that we aren't tainted */
  168|  17.2k|        if (session->flags & SSH_SESSION_FLAG_KEX_TAINTED) {
  ------------------
  |  |   92|  17.2k|#define SSH_SESSION_FLAG_KEX_TAINTED 0x0020
  ------------------
  |  Branch (168:13): [True: 0, False: 17.2k]
  ------------------
  169|      0|            ssh_set_error(session,
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  170|      0|                          SSH_FATAL,
  171|      0|                          "Received unexpected packets in strict KEX mode.");
  172|      0|            goto error;
  173|      0|        }
  174|  17.2k|    }
  175|       |
  176|  17.2k|    if (session->server) {
  ------------------
  |  Branch (176:9): [True: 8.64k, False: 8.63k]
  ------------------
  177|       |        /* server things are done in server.c */
  178|  8.64k|        session->dh_handshake_state=DH_STATE_FINISHED;
  179|  8.64k|    } else {
  180|       |#ifdef WITH_GSSAPI
  181|       |        if (ssh_kex_is_gss(session->next_crypto)) {
  182|       |            OM_uint32 maj_stat, min_stat;
  183|       |            gss_buffer_desc mic = GSS_C_EMPTY_BUFFER, msg = GSS_C_EMPTY_BUFFER;
  184|       |
  185|       |            if (session->gssapi == NULL || session->gssapi->ctx == NULL) {
  186|       |                ssh_set_error(session, SSH_FATAL, "GSSAPI context not initialized");
  187|       |                goto error;
  188|       |            }
  189|       |
  190|       |            if (session->gssapi_key_exchange_mic == NULL) {
  191|       |                ssh_set_error(session,
  192|       |                              SSH_FATAL,
  193|       |                              "GSSAPI mic not set");
  194|       |                goto error;
  195|       |            }
  196|       |
  197|       |            mic.length = ssh_string_len(session->gssapi_key_exchange_mic);
  198|       |            mic.value = ssh_string_data(session->gssapi_key_exchange_mic);
  199|       |
  200|       |            msg.length = session->next_crypto->digest_len;
  201|       |            msg.value = session->next_crypto->secret_hash;
  202|       |
  203|       |            maj_stat = gss_verify_mic(&min_stat,
  204|       |                                      session->gssapi->ctx,
  205|       |                                      &msg,
  206|       |                                      &mic,
  207|       |                                      NULL);
  208|       |            if (maj_stat != GSS_S_COMPLETE) {
  209|       |                ssh_set_error(session,
  210|       |                              SSH_FATAL,
  211|       |                              "Failed to verify mic after GSSAPI Key Exchange");
  212|       |                goto error;
  213|       |            }
  214|       |            SSH_STRING_FREE(session->gssapi_key_exchange_mic);
  215|       |        } else
  216|       |#endif
  217|  8.63k|        {
  218|  8.63k|            ssh_key server_key = NULL;
  219|       |
  220|       |            /* client */
  221|       |
  222|       |            /* Verify the host's signature. FIXME do it sooner */
  223|  8.63k|            sig_blob = session->next_crypto->dh_server_signature;
  224|  8.63k|            session->next_crypto->dh_server_signature = NULL;
  225|       |
  226|       |            /* get the server public key */
  227|  8.63k|            server_key = ssh_dh_get_next_server_publickey(session);
  228|  8.63k|            if (server_key == NULL) {
  ------------------
  |  Branch (228:17): [True: 0, False: 8.63k]
  ------------------
  229|      0|                goto error;
  230|      0|            }
  231|       |
  232|  8.63k|            rc = ssh_pki_import_signature_blob(sig_blob, server_key, &sig);
  233|  8.63k|            ssh_string_burn(sig_blob);
  234|  8.63k|            SSH_STRING_FREE(sig_blob);
  ------------------
  |  |  893|  8.64k|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (893:14): [True: 8.64k, False: 18.4E]
  |  |  |  Branch (893:69): [Folded, False: 8.63k]
  |  |  ------------------
  ------------------
  235|  8.63k|            if (rc != SSH_OK) {
  ------------------
  |  |  316|  8.63k|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (235:17): [True: 0, False: 8.63k]
  ------------------
  236|      0|                goto error;
  237|      0|            }
  238|       |
  239|       |            /* Check if signature from server matches user preferences */
  240|  8.63k|            if (session->opts.wanted_methods[SSH_HOSTKEYS]) {
  ------------------
  |  Branch (240:17): [True: 0, False: 8.63k]
  ------------------
  241|      0|                rc = match_group(session->opts.wanted_methods[SSH_HOSTKEYS],
  242|      0|                                 sig->type_c);
  243|      0|                if (rc == 0) {
  ------------------
  |  Branch (243:21): [True: 0, False: 0]
  ------------------
  244|      0|                    ssh_set_error(
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  245|      0|                        session,
  246|      0|                        SSH_FATAL,
  247|      0|                        "Public key from server (%s) doesn't match user "
  248|      0|                        "preference (%s)",
  249|      0|                        sig->type_c,
  250|      0|                        session->opts.wanted_methods[SSH_HOSTKEYS]);
  251|      0|                    goto error;
  252|      0|                }
  253|      0|            }
  254|       |
  255|  8.63k|            rc = ssh_pki_signature_verify(session,
  256|  8.63k|                                          sig,
  257|  8.63k|                                          server_key,
  258|  8.63k|                                          session->next_crypto->secret_hash,
  259|  8.63k|                                          session->next_crypto->digest_len);
  260|  8.63k|            SSH_SIGNATURE_FREE(sig);
  ------------------
  |  |  161|  8.63k|    do { ssh_signature_free(x); x = NULL; } while(0)
  |  |  ------------------
  |  |  |  Branch (161:51): [Folded, False: 8.63k]
  |  |  ------------------
  ------------------
  261|  8.63k|            if (rc == SSH_ERROR) {
  ------------------
  |  |  317|  8.63k|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  |  Branch (261:17): [True: 0, False: 8.63k]
  ------------------
  262|      0|                ssh_set_error(session,
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  263|      0|                              SSH_FATAL,
  264|      0|                              "Failed to verify server hostkey signature");
  265|      0|                goto error;
  266|      0|            }
  267|  8.63k|        }
  268|  8.63k|        SSH_LOG(SSH_LOG_DEBUG, "Signature verified and valid");
  ------------------
  |  |  281|  8.63k|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  269|       |
  270|       |        /* When receiving this packet, we switch on the incoming crypto. */
  271|  8.63k|        rc = ssh_packet_set_newkeys(session, SSH_DIRECTION_IN);
  272|  8.63k|        if (rc != SSH_OK) {
  ------------------
  |  |  316|  8.63k|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (272:13): [True: 0, False: 8.63k]
  ------------------
  273|      0|            goto error;
  274|      0|        }
  275|  8.63k|    }
  276|  17.2k|    session->dh_handshake_state = DH_STATE_FINISHED;
  277|  17.2k|    session->ssh_connection_callback(session);
  278|  17.2k|    return SSH_PACKET_USED;
  ------------------
  |  |  637|  17.2k|#define SSH_PACKET_USED 1
  ------------------
  279|       |
  280|      0|error:
  281|       |#ifdef WITH_GSSAPI
  282|       |    SSH_STRING_FREE(session->gssapi_key_exchange_mic);
  283|       |#endif
  284|      0|    SSH_SIGNATURE_FREE(sig);
  ------------------
  |  |  161|      0|    do { ssh_signature_free(x); x = NULL; } while(0)
  |  |  ------------------
  |  |  |  Branch (161:51): [Folded, False: 0]
  |  |  ------------------
  ------------------
  285|      0|    ssh_string_burn(sig_blob);
  286|      0|    SSH_STRING_FREE(sig_blob);
  ------------------
  |  |  893|      0|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (893:14): [True: 0, False: 0]
  |  |  |  Branch (893:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
  287|      0|    session->session_state = SSH_SESSION_STATE_ERROR;
  288|      0|    return SSH_PACKET_USED;
  ------------------
  |  |  637|      0|#define SSH_PACKET_USED 1
  ------------------
  289|  17.2k|}
ssh_packet_service_accept:
  297|  8.64k|{
  298|  8.64k|    (void)packet;
  299|  8.64k|    (void)type;
  300|  8.64k|    (void)user;
  301|       |
  302|  8.64k|    session->auth.service_state = SSH_AUTH_SERVICE_ACCEPTED;
  303|  8.64k|    SSH_LOG(SSH_LOG_PACKET, "Received SSH_MSG_SERVICE_ACCEPT");
  ------------------
  |  |  281|  8.64k|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  304|       |
  305|  8.64k|    return SSH_PACKET_USED;
  ------------------
  |  |  637|  8.64k|#define SSH_PACKET_USED 1
  ------------------
  306|  8.64k|}
ssh_packet_ext_info:
  314|  8.64k|{
  315|  8.64k|    int rc;
  316|  8.64k|    uint32_t nr_extensions = 0;
  317|  8.64k|    uint32_t i;
  318|       |
  319|  8.64k|    (void)type;
  320|  8.64k|    (void)user;
  321|       |
  322|  8.64k|    SSH_LOG(SSH_LOG_PACKET, "Received SSH_MSG_EXT_INFO");
  ------------------
  |  |  281|  8.64k|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  323|       |
  324|  8.64k|    rc = ssh_buffer_get_u32(packet, &nr_extensions);
  325|  8.64k|    if (rc == 0) {
  ------------------
  |  Branch (325:9): [True: 0, False: 8.64k]
  ------------------
  326|      0|        SSH_LOG(SSH_LOG_PACKET, "Failed to read number of extensions");
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  327|      0|        return SSH_PACKET_USED;
  ------------------
  |  |  637|      0|#define SSH_PACKET_USED 1
  ------------------
  328|      0|    }
  329|       |
  330|  8.64k|    nr_extensions = ntohl(nr_extensions);
  331|  8.64k|    if (nr_extensions > 128) {
  ------------------
  |  Branch (331:9): [True: 0, False: 8.64k]
  ------------------
  332|      0|        SSH_LOG(SSH_LOG_PACKET, "Invalid number of extensions");
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  333|      0|        return SSH_PACKET_USED;
  ------------------
  |  |  637|      0|#define SSH_PACKET_USED 1
  ------------------
  334|      0|    }
  335|       |
  336|  8.64k|    SSH_LOG(SSH_LOG_PACKET, "Follows %" PRIu32 " extensions", nr_extensions);
  ------------------
  |  |  281|  8.64k|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  337|       |
  338|  34.5k|    for (i = 0; i < nr_extensions; i++) {
  ------------------
  |  Branch (338:17): [True: 25.9k, False: 8.64k]
  ------------------
  339|  25.9k|        char *name = NULL;
  340|  25.9k|        char *value = NULL;
  341|       |
  342|  25.9k|        rc = ssh_buffer_unpack(packet, "ss", &name, &value);
  ------------------
  |  |   60|  25.9k|    _ssh_buffer_unpack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |  451|  25.9k|        (__VA_NARG_(__VA_ARGS__, __RSEQ_N()))
  |  |  |  |  ------------------
  |  |  |  |  |  |  453|  25.9k|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  448|  25.9k|#define VA_APPLY_VARIADIC_MACRO(macro, tuple) macro tuple
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  453|  25.9k|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  461|  25.9k|        _61,_62,_63,N,...) N
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                   _ssh_buffer_unpack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |   28|  25.9k|#define SSH_BUFFER_PACK_END ((uint32_t) 0x4f65feb3)
  |  |  ------------------
  ------------------
  343|  25.9k|        if (rc != SSH_OK) {
  ------------------
  |  |  316|  25.9k|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (343:13): [True: 0, False: 25.9k]
  ------------------
  344|      0|            SSH_LOG(SSH_LOG_PACKET, "Error reading extension name-value pair");
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  345|      0|            return SSH_PACKET_USED;
  ------------------
  |  |  637|      0|#define SSH_PACKET_USED 1
  ------------------
  346|      0|        }
  347|       |
  348|  25.9k|        if (strcmp(name, "server-sig-algs") == 0) {
  ------------------
  |  Branch (348:13): [True: 8.64k, False: 17.2k]
  ------------------
  349|       |            /* TODO check for NULL bytes */
  350|  8.64k|            SSH_LOG(SSH_LOG_PACKET, "Extension: %s=<%s>", name, value);
  ------------------
  |  |  281|  8.64k|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  351|       |
  352|  8.64k|            rc = match_group(value, "rsa-sha2-512");
  353|  8.64k|            if (rc == 1) {
  ------------------
  |  Branch (353:17): [True: 8.64k, False: 0]
  ------------------
  354|  8.64k|                session->extensions |= SSH_EXT_SIG_RSA_SHA512;
  ------------------
  |  |  126|  8.64k|#define SSH_EXT_SIG_RSA_SHA512  0x04
  ------------------
  355|  8.64k|            }
  356|       |
  357|  8.64k|            rc = match_group(value, "rsa-sha2-256");
  358|  8.64k|            if (rc == 1) {
  ------------------
  |  Branch (358:17): [True: 8.64k, False: 0]
  ------------------
  359|  8.64k|                session->extensions |= SSH_EXT_SIG_RSA_SHA256;
  ------------------
  |  |  125|  8.64k|#define SSH_EXT_SIG_RSA_SHA256  0x02
  ------------------
  360|  8.64k|            }
  361|  17.2k|        } else if (strcmp(name, "publickey-hostbound@openssh.com") == 0) {
  ------------------
  |  Branch (361:20): [True: 8.64k, False: 8.64k]
  ------------------
  362|  8.64k|            SSH_LOG(SSH_LOG_PACKET, "Extension: %s=<%s>", name, value);
  ------------------
  |  |  281|  8.64k|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  363|  8.64k|            session->extensions |= SSH_EXT_PUBLICKEY_HOSTBOUND;
  ------------------
  |  |  128|  8.64k|#define SSH_EXT_PUBLICKEY_HOSTBOUND 0x08
  ------------------
  364|  8.64k|        } else if (strcmp(name, "ping@openssh.com") == 0) {
  ------------------
  |  Branch (364:20): [True: 8.64k, False: 0]
  ------------------
  365|  8.64k|            if (strcmp(value, "0") == 0) {
  ------------------
  |  Branch (365:17): [True: 8.64k, False: 0]
  ------------------
  366|  8.64k|                SSH_LOG(SSH_LOG_PACKET,
  ------------------
  |  |  281|  8.64k|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  367|  8.64k|                        "Extension: %s=<%s> (supported)",
  368|  8.64k|                        name,
  369|  8.64k|                        value);
  370|  8.64k|                session->extensions |= SSH_EXT_PING;
  ------------------
  |  |  130|  8.64k|#define SSH_EXT_PING 0x10
  ------------------
  371|  8.64k|            } else {
  372|      0|                SSH_LOG(SSH_LOG_PACKET,
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  373|      0|                        "Extension: %s=<%s> (unsupported version, expected 0)",
  374|      0|                        name,
  375|      0|                        value);
  376|      0|            }
  377|  8.64k|        } else {
  378|      0|            SSH_LOG(SSH_LOG_PACKET, "Unknown extension: %s", name);
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  379|      0|        }
  380|  25.9k|        free(name);
  381|  25.9k|        free(value);
  382|  25.9k|    }
  383|       |
  384|  8.64k|    return SSH_PACKET_USED;
  ------------------
  |  |  637|  8.64k|#define SSH_PACKET_USED 1
  ------------------
  385|  8.64k|}

ssh_packet_decrypt_len:
   55|   184k|{
   56|   184k|    struct ssh_crypto_struct *crypto = NULL;
   57|   184k|    uint32_t decrypted;
   58|   184k|    int rc;
   59|       |
   60|   184k|    crypto = ssh_packet_get_current_crypto(session, SSH_DIRECTION_IN);
   61|   184k|    if (crypto != NULL) {
  ------------------
  |  Branch (61:9): [True: 132k, False: 51.8k]
  ------------------
   62|   132k|        if (crypto->in_cipher->aead_decrypt_length != NULL) {
  ------------------
  |  Branch (62:13): [True: 0, False: 132k]
  ------------------
   63|      0|            rc = crypto->in_cipher->aead_decrypt_length(
   64|      0|                    crypto->in_cipher, source, destination,
   65|      0|                    crypto->in_cipher->lenfield_blocksize,
   66|      0|                    session->recv_seq);
   67|   132k|        } else {
   68|   132k|            rc = ssh_packet_decrypt(
   69|   132k|                    session,
   70|   132k|                    destination,
   71|   132k|                    source,
   72|   132k|                    0,
   73|   132k|                    crypto->in_cipher->blocksize);
   74|   132k|        }
   75|   132k|        if (rc < 0) {
  ------------------
  |  Branch (75:13): [True: 0, False: 132k]
  ------------------
   76|      0|            return 0;
   77|      0|        }
   78|   132k|    } else {
   79|  51.8k|        memcpy(destination, source, 8);
   80|  51.8k|    }
   81|   184k|    memcpy(&decrypted,destination,sizeof(decrypted));
   82|       |
   83|       |    return ntohl(decrypted);
   84|   184k|}
ssh_packet_decrypt:
   97|   245k|{
   98|   245k|    struct ssh_crypto_struct *crypto = NULL;
   99|   245k|    struct ssh_cipher_struct *cipher = NULL;
  100|       |
  101|   245k|    if (encrypted_size <= 0) {
  ------------------
  |  Branch (101:9): [True: 0, False: 245k]
  ------------------
  102|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  103|      0|    }
  104|       |
  105|   245k|    crypto = ssh_packet_get_current_crypto(session, SSH_DIRECTION_IN);
  106|   245k|    if (crypto == NULL) {
  ------------------
  |  Branch (106:9): [True: 0, False: 245k]
  ------------------
  107|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  108|      0|    }
  109|   245k|    cipher = crypto->in_cipher;
  110|       |
  111|   245k|    if (encrypted_size % cipher->blocksize != 0) {
  ------------------
  |  Branch (111:9): [True: 0, False: 245k]
  ------------------
  112|      0|        ssh_set_error(session,
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  113|      0|                      SSH_FATAL,
  114|      0|                      "Cryptographic functions must be used on multiple of "
  115|      0|                      "blocksize (received %zu)",
  116|      0|                      encrypted_size);
  117|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  118|      0|    }
  119|       |
  120|   245k|    if (cipher->aead_decrypt != NULL) {
  ------------------
  |  Branch (120:9): [True: 0, False: 245k]
  ------------------
  121|      0|        return cipher->aead_decrypt(cipher,
  122|      0|                                    source,
  123|      0|                                    destination,
  124|      0|                                    encrypted_size,
  125|      0|                                    session->recv_seq);
  126|   245k|    } else {
  127|   245k|        cipher->decrypt(cipher, source + start, destination, encrypted_size);
  128|   245k|    }
  129|       |
  130|   245k|    return 0;
  131|   245k|}
ssh_packet_encrypt:
  134|   210k|{
  135|   210k|  struct ssh_crypto_struct *crypto = NULL;
  136|   210k|  struct ssh_cipher_struct *cipher = NULL;
  137|   210k|  HMACCTX ctx = NULL;
  138|   210k|  char *out = NULL;
  139|   210k|  int etm_packet_offset = 0, rc;
  140|   210k|  unsigned int blocksize;
  141|   210k|  size_t finallen = DIGEST_MAX_LEN;
  ------------------
  |  |   56|   210k|#define DIGEST_MAX_LEN 64
  ------------------
  142|   210k|  uint32_t seq, lenfield_blocksize;
  143|   210k|  enum ssh_hmac_e type;
  144|   210k|  bool etm;
  145|       |
  146|   210k|  assert(len);
  ------------------
  |  Branch (146:3): [True: 0, False: 210k]
  |  Branch (146:3): [True: 210k, False: 0]
  ------------------
  147|       |
  148|   210k|  crypto = ssh_packet_get_current_crypto(session, SSH_DIRECTION_OUT);
  149|   210k|  if (crypto == NULL) {
  ------------------
  |  Branch (149:7): [True: 51.8k, False: 158k]
  ------------------
  150|  51.8k|      return NULL; /* nothing to do here */
  151|  51.8k|  }
  152|       |
  153|   158k|  blocksize = crypto->out_cipher->blocksize;
  154|   158k|  lenfield_blocksize = crypto->out_cipher->lenfield_blocksize;
  155|       |
  156|   158k|  type = crypto->out_hmac;
  157|   158k|  etm = crypto->out_hmac_etm;
  158|       |
  159|   158k|  if (etm) {
  ------------------
  |  Branch (159:7): [True: 0, False: 158k]
  ------------------
  160|      0|      etm_packet_offset = sizeof(uint32_t);
  161|      0|  }
  162|       |
  163|   158k|  if ((len - lenfield_blocksize - etm_packet_offset) % blocksize != 0) {
  ------------------
  |  Branch (163:7): [True: 0, False: 158k]
  ------------------
  164|      0|      ssh_set_error(session, SSH_FATAL, "Cryptographic functions must be set"
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  165|      0|                    " on at least one blocksize (received %zu)", len);
  166|      0|      return NULL;
  167|      0|  }
  168|   158k|  out = calloc(1, len);
  169|   158k|  if (out == NULL) {
  ------------------
  |  Branch (169:7): [True: 0, False: 158k]
  ------------------
  170|      0|    return NULL;
  171|      0|  }
  172|       |
  173|   158k|  seq = ntohl(session->send_seq);
  174|   158k|  cipher = crypto->out_cipher;
  175|       |
  176|   158k|  if (cipher->aead_encrypt != NULL) {
  ------------------
  |  Branch (176:7): [True: 0, False: 158k]
  ------------------
  177|      0|      cipher->aead_encrypt(cipher, data, out, len,
  178|      0|            crypto->hmacbuf, session->send_seq);
  179|      0|      memcpy(data, out, len);
  180|   158k|  } else {
  181|   158k|      if (type != SSH_HMAC_NONE) {
  ------------------
  |  Branch (181:11): [True: 105k, False: 52.7k]
  ------------------
  182|   105k|          ctx = hmac_init(crypto->encryptMAC, hmac_digest_len(type), type);
  183|   105k|          if (ctx == NULL) {
  ------------------
  |  Branch (183:15): [True: 0, False: 105k]
  ------------------
  184|      0|              SAFE_FREE(out);
  ------------------
  |  |  373|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
  185|      0|              return NULL;
  186|      0|          }
  187|       |
  188|   105k|          if (!etm) {
  ------------------
  |  Branch (188:15): [True: 105k, False: 0]
  ------------------
  189|   105k|              rc = hmac_update(ctx, (unsigned char *)&seq, sizeof(uint32_t));
  190|   105k|              if (rc != 1) {
  ------------------
  |  Branch (190:19): [True: 0, False: 105k]
  ------------------
  191|      0|                  SAFE_FREE(out);
  ------------------
  |  |  373|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
  192|      0|                  return NULL;
  193|      0|              }
  194|   105k|              rc = hmac_update(ctx, data, len);
  195|   105k|              if (rc != 1) {
  ------------------
  |  Branch (195:19): [True: 0, False: 105k]
  ------------------
  196|      0|                  SAFE_FREE(out);
  ------------------
  |  |  373|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
  197|      0|                  return NULL;
  198|      0|              }
  199|   105k|              rc = hmac_final(ctx, crypto->hmacbuf, &finallen);
  200|   105k|              if (rc != 1) {
  ------------------
  |  Branch (200:19): [True: 0, False: 105k]
  ------------------
  201|      0|                  SAFE_FREE(out);
  ------------------
  |  |  373|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
  202|      0|                  return NULL;
  203|      0|              }
  204|   105k|          }
  205|   105k|      }
  206|       |
  207|   158k|      cipher->encrypt(cipher, (uint8_t*)data + etm_packet_offset, out, len - etm_packet_offset);
  208|   158k|      memcpy((uint8_t*)data + etm_packet_offset, out, len - etm_packet_offset);
  209|       |
  210|   158k|      if (type != SSH_HMAC_NONE) {
  ------------------
  |  Branch (210:11): [True: 105k, False: 52.7k]
  ------------------
  211|   105k|          if (etm) {
  ------------------
  |  Branch (211:15): [True: 0, False: 105k]
  ------------------
  212|      0|              PUSH_BE_U32(data, 0, len - etm_packet_offset);
  ------------------
  |  |   89|      0|    (PUSH_BE_U16((data), (pos), (uint16_t)(((uint32_t)(val)) >> 16)), PUSH_BE_U16((data), (pos) + 2, (uint16_t)((val) & 0xffff)))
  |  |  ------------------
  |  |  |  |   86|      0|    (PUSH_BE_U8((data), (pos), (uint8_t)(((uint16_t)(val)) >> 8)), PUSH_BE_U8((data), (pos) + 1, (uint8_t)((val) & 0xff)))
  |  |  |  |  ------------------
  |  |  |  |  |  |   83|      0|    (_DATA_BYTE(data, pos) = ((uint8_t)(val)))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   31|      0|    (((uint8_t *)(data))[(pos)])
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |                   (PUSH_BE_U8((data), (pos), (uint8_t)(((uint16_t)(val)) >> 8)), PUSH_BE_U8((data), (pos) + 1, (uint8_t)((val) & 0xff)))
  |  |  |  |  ------------------
  |  |  |  |  |  |   83|      0|    (_DATA_BYTE(data, pos) = ((uint8_t)(val)))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   31|      0|    (((uint8_t *)(data))[(pos)])
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                   (PUSH_BE_U16((data), (pos), (uint16_t)(((uint32_t)(val)) >> 16)), PUSH_BE_U16((data), (pos) + 2, (uint16_t)((val) & 0xffff)))
  |  |  ------------------
  |  |  |  |   86|      0|    (PUSH_BE_U8((data), (pos), (uint8_t)(((uint16_t)(val)) >> 8)), PUSH_BE_U8((data), (pos) + 1, (uint8_t)((val) & 0xff)))
  |  |  |  |  ------------------
  |  |  |  |  |  |   83|      0|    (_DATA_BYTE(data, pos) = ((uint8_t)(val)))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   31|      0|    (((uint8_t *)(data))[(pos)])
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |                   (PUSH_BE_U8((data), (pos), (uint8_t)(((uint16_t)(val)) >> 8)), PUSH_BE_U8((data), (pos) + 1, (uint8_t)((val) & 0xff)))
  |  |  |  |  ------------------
  |  |  |  |  |  |   83|      0|    (_DATA_BYTE(data, pos) = ((uint8_t)(val)))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   31|      0|    (((uint8_t *)(data))[(pos)])
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  213|      0|              rc = hmac_update(ctx, (unsigned char *)&seq, sizeof(uint32_t));
  214|      0|              if (rc != 1) {
  ------------------
  |  Branch (214:19): [True: 0, False: 0]
  ------------------
  215|      0|                  SAFE_FREE(out);
  ------------------
  |  |  373|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
  216|      0|                  return NULL;
  217|      0|              }
  218|      0|              rc = hmac_update(ctx, data, len);
  219|      0|              if (rc != 1) {
  ------------------
  |  Branch (219:19): [True: 0, False: 0]
  ------------------
  220|      0|                  SAFE_FREE(out);
  ------------------
  |  |  373|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
  221|      0|                  return NULL;
  222|      0|              }
  223|      0|              rc = hmac_final(ctx, crypto->hmacbuf, &finallen);
  224|      0|              if (rc != 1) {
  ------------------
  |  Branch (224:19): [True: 0, False: 0]
  ------------------
  225|      0|                  SAFE_FREE(out);
  ------------------
  |  |  373|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
  226|      0|                  return NULL;
  227|      0|              }
  228|      0|          }
  229|       |#ifdef DEBUG_CRYPTO
  230|       |          ssh_log_hexdump("mac: ", data, len);
  231|       |          if (finallen != hmac_digest_len(type)) {
  232|       |              printf("Final len is %zu\n", finallen);
  233|       |          }
  234|       |          ssh_log_hexdump("Packet hmac", crypto->hmacbuf, hmac_digest_len(type));
  235|       |#endif
  236|   105k|      }
  237|   158k|  }
  238|   158k|  ssh_burn(out, len);
  ------------------
  |  |  388|   158k|#define ssh_burn(ptr, len) explicit_bzero((ptr), (len))
  ------------------
  239|   158k|  SAFE_FREE(out);
  ------------------
  |  |  373|   158k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 158k, False: 1]
  |  |  |  Branch (373:71): [Folded, False: 158k]
  |  |  ------------------
  ------------------
  240|       |
  241|   158k|  return crypto->hmacbuf;
  242|   158k|}
ssh_packet_hmac_verify:
  262|  88.3k|{
  263|  88.3k|    struct ssh_crypto_struct *crypto = NULL;
  264|  88.3k|    unsigned char hmacbuf[DIGEST_MAX_LEN] = {0};
  265|  88.3k|    HMACCTX ctx = NULL;
  266|  88.3k|    size_t hmaclen = DIGEST_MAX_LEN;
  ------------------
  |  |   56|  88.3k|#define DIGEST_MAX_LEN 64
  ------------------
  267|  88.3k|    uint32_t seq;
  268|  88.3k|    int cmp;
  269|  88.3k|    int rc;
  270|       |
  271|       |    /* AEAD types have no mac checking */
  272|  88.3k|    if (type == SSH_HMAC_AEAD_POLY1305 ||
  ------------------
  |  Branch (272:9): [True: 0, False: 88.3k]
  ------------------
  273|  88.3k|        type == SSH_HMAC_AEAD_GCM) {
  ------------------
  |  Branch (273:9): [True: 0, False: 88.3k]
  ------------------
  274|      0|        return SSH_OK;
  ------------------
  |  |  316|      0|#define SSH_OK 0     /* No error */
  ------------------
  275|      0|    }
  276|       |
  277|  88.3k|    crypto = ssh_packet_get_current_crypto(session,
  278|  88.3k|                                           SSH_DIRECTION_IN);
  279|  88.3k|    if (crypto == NULL) {
  ------------------
  |  Branch (279:9): [True: 0, False: 88.3k]
  ------------------
  280|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  281|      0|    }
  282|       |
  283|  88.3k|    ctx = hmac_init(crypto->decryptMAC,
  284|  88.3k|                    hmac_digest_len(type),
  285|  88.3k|                    type);
  286|  88.3k|    if (ctx == NULL) {
  ------------------
  |  Branch (286:9): [True: 0, False: 88.3k]
  ------------------
  287|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  288|      0|    }
  289|       |
  290|  88.3k|    seq = htonl(session->recv_seq);
  291|       |
  292|  88.3k|    rc = hmac_update(ctx,
  293|  88.3k|                     (unsigned char *) &seq,
  294|  88.3k|                     sizeof(uint32_t));
  295|  88.3k|    if (rc != 1) {
  ------------------
  |  Branch (295:9): [True: 0, False: 88.3k]
  ------------------
  296|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  297|      0|    }
  298|  88.3k|    rc = hmac_update(ctx,
  299|  88.3k|                     data,
  300|  88.3k|                     len);
  301|  88.3k|    if (rc != 1) {
  ------------------
  |  Branch (301:9): [True: 0, False: 88.3k]
  ------------------
  302|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  303|      0|    }
  304|  88.3k|    rc = hmac_final(ctx,
  305|  88.3k|                    hmacbuf,
  306|  88.3k|                    &hmaclen);
  307|  88.3k|    if (rc != 1) {
  ------------------
  |  Branch (307:9): [True: 0, False: 88.3k]
  ------------------
  308|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  309|      0|    }
  310|       |
  311|       |#ifdef DEBUG_CRYPTO
  312|       |    ssh_log_hexdump("received mac",
  313|       |                    mac,
  314|       |                    hmaclen);
  315|       |    ssh_log_hexdump("Computed mac",
  316|       |                    hmacbuf,
  317|       |                    hmaclen);
  318|       |    ssh_log_hexdump("seq",
  319|       |                    (unsigned char *)&seq,
  320|       |                    sizeof(uint32_t));
  321|       |#endif
  322|  88.3k|    cmp = secure_memcmp(mac,
  323|  88.3k|                        hmacbuf,
  324|  88.3k|                        hmaclen);
  325|  88.3k|    if (cmp == 0) {
  ------------------
  |  Branch (325:9): [True: 88.3k, False: 0]
  ------------------
  326|  88.3k|        return SSH_OK;
  ------------------
  |  |  316|  88.3k|#define SSH_OK 0     /* No error */
  ------------------
  327|  88.3k|    }
  328|       |
  329|      0|    return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  330|  88.3k|}

ssh_key_new:
  113|  43.2k|{
  114|  43.2k|    ssh_key ptr = malloc (sizeof (struct ssh_key_struct));
  115|  43.2k|    if (ptr == NULL) {
  ------------------
  |  Branch (115:9): [True: 0, False: 43.2k]
  ------------------
  116|      0|        return NULL;
  117|      0|    }
  118|  43.2k|    ZERO_STRUCTP(ptr);
  ------------------
  |  |  379|  43.2k|#define ZERO_STRUCTP(x) do { if ((x) != NULL) memset((x), 0, sizeof(*(x))); } while(0)
  |  |  ------------------
  |  |  |  Branch (379:34): [True: 43.2k, False: 0]
  |  |  |  Branch (379:85): [Folded, False: 43.2k]
  |  |  ------------------
  ------------------
  119|  43.2k|    return ptr;
  120|  43.2k|}
pki_key_dup_common_init:
  145|  17.2k|{
  146|  17.2k|    ssh_key new = NULL;
  147|       |
  148|  17.2k|    if (key == NULL) {
  ------------------
  |  Branch (148:9): [True: 0, False: 17.2k]
  ------------------
  149|      0|        return NULL;
  150|      0|    }
  151|       |
  152|  17.2k|    new = ssh_key_new();
  153|  17.2k|    if (new == NULL) {
  ------------------
  |  Branch (153:9): [True: 0, False: 17.2k]
  ------------------
  154|      0|        return NULL;
  155|      0|    }
  156|       |
  157|  17.2k|    new->type = key->type;
  158|  17.2k|    new->type_c = key->type_c;
  159|  17.2k|    if (demote) {
  ------------------
  |  Branch (159:9): [True: 8.64k, False: 8.64k]
  ------------------
  160|  8.64k|        new->flags = SSH_KEY_FLAG_PUBLIC;
  ------------------
  |  |   54|  8.64k|#define SSH_KEY_FLAG_PUBLIC  0x0001
  ------------------
  161|  8.64k|    } else {
  162|  8.64k|        new->flags = key->flags;
  163|  8.64k|    }
  164|       |
  165|       |    /* Copy security key fields if present */
  166|  17.2k|    if (is_sk_key_type(key->type)) {
  ------------------
  |  |  153|  17.2k|    ((kt) == SSH_KEYTYPE_SK_ECDSA || (kt) == SSH_KEYTYPE_SK_ED25519 || \
  |  |  ------------------
  |  |  |  Branch (153:6): [True: 0, False: 17.2k]
  |  |  |  Branch (153:38): [True: 0, False: 17.2k]
  |  |  ------------------
  |  |  154|  17.2k|     (kt) == SSH_KEYTYPE_SK_ECDSA_CERT01 ||                            \
  |  |  ------------------
  |  |  |  Branch (154:6): [True: 0, False: 17.2k]
  |  |  ------------------
  |  |  155|  17.2k|     (kt) == SSH_KEYTYPE_SK_ED25519_CERT01)
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 0, False: 17.2k]
  |  |  ------------------
  ------------------
  167|      0|        new->sk_application = ssh_string_copy(key->sk_application);
  168|      0|        if (new->sk_application == NULL) {
  ------------------
  |  Branch (168:13): [True: 0, False: 0]
  ------------------
  169|      0|            goto fail;
  170|      0|        }
  171|       |
  172|      0|        if (key->sk_user_id != NULL) {
  ------------------
  |  Branch (172:13): [True: 0, False: 0]
  ------------------
  173|      0|            new->sk_user_id = ssh_string_copy(key->sk_user_id);
  174|      0|            if (new->sk_user_id == NULL) {
  ------------------
  |  Branch (174:17): [True: 0, False: 0]
  ------------------
  175|      0|                goto fail;
  176|      0|            }
  177|      0|        }
  178|       |
  179|      0|        if (!demote) {
  ------------------
  |  Branch (179:13): [True: 0, False: 0]
  ------------------
  180|      0|            new->sk_flags = key->sk_flags;
  181|       |
  182|      0|            new->sk_key_handle = ssh_string_copy(key->sk_key_handle);
  183|      0|            if (new->sk_key_handle == NULL) {
  ------------------
  |  Branch (183:17): [True: 0, False: 0]
  ------------------
  184|      0|                goto fail;
  185|      0|            }
  186|       |
  187|      0|            new->sk_reserved = ssh_string_copy(key->sk_reserved);
  188|      0|            if (new->sk_reserved == NULL) {
  ------------------
  |  Branch (188:17): [True: 0, False: 0]
  ------------------
  189|      0|                goto fail;
  190|      0|            }
  191|      0|        }
  192|      0|    }
  193|       |
  194|  17.2k|    return new;
  195|       |
  196|      0|fail:
  197|      0|    SSH_KEY_FREE(new);
  ------------------
  |  |  752|      0|    do { if ((x) != NULL) { ssh_key_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (752:14): [True: 0, False: 0]
  |  |  |  Branch (752:66): [Folded, False: 0]
  |  |  ------------------
  ------------------
  198|       |    return NULL;
  199|  17.2k|}
ssh_key_dup:
  209|  8.64k|{
  210|  8.64k|    if (key == NULL) {
  ------------------
  |  Branch (210:9): [True: 0, False: 8.64k]
  ------------------
  211|      0|        return NULL;
  212|      0|    }
  213|       |
  214|  8.64k|    return pki_key_dup(key, 0);
  215|  8.64k|}
ssh_key_clean:
  222|  43.2k|{
  223|  43.2k|    if (key == NULL)
  ------------------
  |  Branch (223:9): [True: 0, False: 43.2k]
  ------------------
  224|      0|        return;
  225|       |
  226|  43.2k|    pki_key_clean(key);
  227|       |
  228|       |#ifndef HAVE_LIBCRYPTO
  229|       |    if (key->ed25519_privkey != NULL) {
  230|       |        ssh_burn(key->ed25519_privkey, sizeof(ed25519_privkey));
  231|       |        SAFE_FREE(key->ed25519_privkey);
  232|       |    }
  233|       |    SAFE_FREE(key->ed25519_pubkey);
  234|       |#endif /* HAVE_LIBCRYPTO */
  235|  43.2k|    if (key->cert != NULL) {
  ------------------
  |  Branch (235:9): [True: 0, False: 43.2k]
  ------------------
  236|      0|        SSH_BUFFER_FREE(key->cert);
  ------------------
  |  |  934|      0|    do { if ((x) != NULL) { ssh_buffer_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (934:14): [True: 0, False: 0]
  |  |  |  Branch (934:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
  237|      0|    }
  238|  43.2k|    if (is_sk_key_type(key->type)) {
  ------------------
  |  |  153|  43.2k|    ((kt) == SSH_KEYTYPE_SK_ECDSA || (kt) == SSH_KEYTYPE_SK_ED25519 || \
  |  |  ------------------
  |  |  |  Branch (153:6): [True: 0, False: 43.2k]
  |  |  |  Branch (153:38): [True: 0, False: 43.2k]
  |  |  ------------------
  |  |  154|  43.2k|     (kt) == SSH_KEYTYPE_SK_ECDSA_CERT01 ||                            \
  |  |  ------------------
  |  |  |  Branch (154:6): [True: 0, False: 43.2k]
  |  |  ------------------
  |  |  155|  43.2k|     (kt) == SSH_KEYTYPE_SK_ED25519_CERT01)
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 0, False: 43.2k]
  |  |  ------------------
  ------------------
  239|      0|        ssh_string_burn(key->sk_application);
  240|      0|        ssh_string_free(key->sk_application);
  241|      0|        ssh_string_burn(key->sk_key_handle);
  242|      0|        ssh_string_free(key->sk_key_handle);
  243|      0|        ssh_string_burn(key->sk_reserved);
  244|      0|        ssh_string_free(key->sk_reserved);
  245|      0|        ssh_string_burn(key->sk_user_id);
  246|      0|        ssh_string_free(key->sk_user_id);
  247|      0|        key->sk_flags = 0;
  248|      0|    }
  249|  43.2k|    key->cert_type = SSH_KEYTYPE_UNKNOWN;
  250|  43.2k|    key->flags = SSH_KEY_FLAG_EMPTY;
  ------------------
  |  |   53|  43.2k|#define SSH_KEY_FLAG_EMPTY   0x0
  ------------------
  251|  43.2k|    key->type = SSH_KEYTYPE_UNKNOWN;
  252|  43.2k|    key->ecdsa_nid = 0;
  253|       |    key->type_c = NULL;
  254|  43.2k|}
ssh_key_free:
  261|   164k|{
  262|   164k|    if (key) {
  ------------------
  |  Branch (262:9): [True: 43.2k, False: 120k]
  ------------------
  263|  43.2k|        ssh_key_clean(key);
  264|       |        SAFE_FREE(key);
  ------------------
  |  |  373|  43.2k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 43.2k, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 43.2k]
  |  |  ------------------
  ------------------
  265|  43.2k|    }
  266|   164k|}
ssh_key_type:
  280|  43.2k|{
  281|  43.2k|    if (key == NULL) {
  ------------------
  |  Branch (281:9): [True: 0, False: 43.2k]
  ------------------
  282|      0|        return SSH_KEYTYPE_UNKNOWN;
  283|      0|    }
  284|  43.2k|    return key->type;
  285|  43.2k|}
ssh_key_signature_to_char:
  367|  17.2k|{
  368|  17.2k|    switch (type) {
  369|      0|    case SSH_KEYTYPE_RSA:
  ------------------
  |  Branch (369:5): [True: 0, False: 17.2k]
  ------------------
  370|      0|        switch (hash_type) {
  371|      0|        case SSH_DIGEST_SHA256:
  ------------------
  |  Branch (371:9): [True: 0, False: 0]
  ------------------
  372|      0|            return "rsa-sha2-256";
  373|      0|        case SSH_DIGEST_SHA512:
  ------------------
  |  Branch (373:9): [True: 0, False: 0]
  ------------------
  374|      0|            return "rsa-sha2-512";
  375|      0|        case SSH_DIGEST_SHA1:
  ------------------
  |  Branch (375:9): [True: 0, False: 0]
  ------------------
  376|      0|        case SSH_DIGEST_AUTO:
  ------------------
  |  Branch (376:9): [True: 0, False: 0]
  ------------------
  377|      0|            return "ssh-rsa";
  378|      0|        default:
  ------------------
  |  Branch (378:9): [True: 0, False: 0]
  ------------------
  379|      0|            return NULL;
  380|      0|        }
  381|      0|        break;
  382|      0|    case SSH_KEYTYPE_RSA_CERT01:
  ------------------
  |  Branch (382:5): [True: 0, False: 17.2k]
  ------------------
  383|      0|        switch (hash_type) {
  384|      0|        case SSH_DIGEST_SHA256:
  ------------------
  |  Branch (384:9): [True: 0, False: 0]
  ------------------
  385|      0|            return "rsa-sha2-256-cert-v01@openssh.com";
  386|      0|        case SSH_DIGEST_SHA512:
  ------------------
  |  Branch (386:9): [True: 0, False: 0]
  ------------------
  387|      0|            return "rsa-sha2-512-cert-v01@openssh.com";
  388|      0|        case SSH_DIGEST_SHA1:
  ------------------
  |  Branch (388:9): [True: 0, False: 0]
  ------------------
  389|      0|        case SSH_DIGEST_AUTO:
  ------------------
  |  Branch (389:9): [True: 0, False: 0]
  ------------------
  390|      0|            return "ssh-rsa-cert-v01@openssh.com";
  391|      0|        default:
  ------------------
  |  Branch (391:9): [True: 0, False: 0]
  ------------------
  392|      0|            return NULL;
  393|      0|        }
  394|      0|        break;
  395|  17.2k|    default:
  ------------------
  |  Branch (395:5): [True: 17.2k, False: 0]
  ------------------
  396|  17.2k|        return ssh_key_type_to_char(type);
  397|  17.2k|    }
  398|       |
  399|       |    /* We should never reach this */
  400|      0|    return NULL;
  401|  17.2k|}
ssh_key_type_to_char:
  410|  51.8k|const char *ssh_key_type_to_char(enum ssh_keytypes_e type) {
  411|  51.8k|  switch (type) {
  ------------------
  |  Branch (411:11): [True: 51.8k, False: 0]
  ------------------
  412|      0|    case SSH_KEYTYPE_RSA:
  ------------------
  |  Branch (412:5): [True: 0, False: 51.8k]
  ------------------
  413|      0|      return "ssh-rsa";
  414|      0|    case SSH_KEYTYPE_ECDSA:
  ------------------
  |  Branch (414:5): [True: 0, False: 51.8k]
  ------------------
  415|      0|      return "ssh-ecdsa"; /* deprecated. invalid value */
  416|      0|    case SSH_KEYTYPE_ECDSA_P256:
  ------------------
  |  Branch (416:5): [True: 0, False: 51.8k]
  ------------------
  417|      0|      return "ecdsa-sha2-nistp256";
  418|      0|    case SSH_KEYTYPE_ECDSA_P384:
  ------------------
  |  Branch (418:5): [True: 0, False: 51.8k]
  ------------------
  419|      0|      return "ecdsa-sha2-nistp384";
  420|      0|    case SSH_KEYTYPE_ECDSA_P521:
  ------------------
  |  Branch (420:5): [True: 0, False: 51.8k]
  ------------------
  421|      0|      return "ecdsa-sha2-nistp521";
  422|  51.8k|    case SSH_KEYTYPE_ED25519:
  ------------------
  |  Branch (422:5): [True: 51.8k, False: 0]
  ------------------
  423|  51.8k|      return "ssh-ed25519";
  424|      0|    case SSH_KEYTYPE_RSA_CERT01:
  ------------------
  |  Branch (424:5): [True: 0, False: 51.8k]
  ------------------
  425|      0|      return "ssh-rsa-cert-v01@openssh.com";
  426|      0|    case SSH_KEYTYPE_ECDSA_P256_CERT01:
  ------------------
  |  Branch (426:5): [True: 0, False: 51.8k]
  ------------------
  427|      0|      return "ecdsa-sha2-nistp256-cert-v01@openssh.com";
  428|      0|    case SSH_KEYTYPE_ECDSA_P384_CERT01:
  ------------------
  |  Branch (428:5): [True: 0, False: 51.8k]
  ------------------
  429|      0|      return "ecdsa-sha2-nistp384-cert-v01@openssh.com";
  430|      0|    case SSH_KEYTYPE_ECDSA_P521_CERT01:
  ------------------
  |  Branch (430:5): [True: 0, False: 51.8k]
  ------------------
  431|      0|      return "ecdsa-sha2-nistp521-cert-v01@openssh.com";
  432|      0|    case SSH_KEYTYPE_ED25519_CERT01:
  ------------------
  |  Branch (432:5): [True: 0, False: 51.8k]
  ------------------
  433|      0|      return "ssh-ed25519-cert-v01@openssh.com";
  434|      0|    case SSH_KEYTYPE_SK_ECDSA:
  ------------------
  |  Branch (434:5): [True: 0, False: 51.8k]
  ------------------
  435|      0|      return "sk-ecdsa-sha2-nistp256@openssh.com";
  436|      0|    case SSH_KEYTYPE_SK_ED25519:
  ------------------
  |  Branch (436:5): [True: 0, False: 51.8k]
  ------------------
  437|      0|      return "sk-ssh-ed25519@openssh.com";
  438|      0|    case SSH_KEYTYPE_SK_ECDSA_CERT01:
  ------------------
  |  Branch (438:5): [True: 0, False: 51.8k]
  ------------------
  439|      0|      return "sk-ecdsa-sha2-nistp256-cert-v01@openssh.com";
  440|      0|    case SSH_KEYTYPE_SK_ED25519_CERT01:
  ------------------
  |  Branch (440:5): [True: 0, False: 51.8k]
  ------------------
  441|      0|      return "sk-ssh-ed25519-cert-v01@openssh.com";
  442|      0|    case SSH_KEYTYPE_DSS:   /* deprecated */
  ------------------
  |  Branch (442:5): [True: 0, False: 51.8k]
  ------------------
  443|      0|    case SSH_KEYTYPE_RSA1:
  ------------------
  |  Branch (443:5): [True: 0, False: 51.8k]
  ------------------
  444|      0|    case SSH_KEYTYPE_DSS_CERT01:    /* deprecated */
  ------------------
  |  Branch (444:5): [True: 0, False: 51.8k]
  ------------------
  445|      0|    case SSH_KEYTYPE_UNKNOWN:
  ------------------
  |  Branch (445:5): [True: 0, False: 51.8k]
  ------------------
  446|      0|      return NULL;
  447|  51.8k|  }
  448|       |
  449|       |  /* We should never reach this */
  450|      0|  return NULL;
  451|  51.8k|}
ssh_key_type_and_hash_from_signature_name:
  472|  17.2k|{
  473|  17.2k|    size_t len;
  474|       |
  475|  17.2k|    if (name == NULL || type == NULL || hash_type == NULL) {
  ------------------
  |  Branch (475:9): [True: 0, False: 17.2k]
  |  Branch (475:25): [True: 0, False: 17.2k]
  |  Branch (475:41): [True: 0, False: 17.2k]
  ------------------
  476|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  477|      0|    }
  478|       |
  479|  17.2k|    len = strlen(name);
  480|       |
  481|  17.2k|    if (len == 7 && strcmp(name, "ssh-rsa") == 0) {
  ------------------
  |  Branch (481:9): [True: 0, False: 17.2k]
  |  Branch (481:21): [True: 0, False: 0]
  ------------------
  482|      0|        *type = SSH_KEYTYPE_RSA;
  483|      0|        *hash_type = SSH_DIGEST_SHA1;
  484|      0|        return SSH_OK;
  ------------------
  |  |  316|      0|#define SSH_OK 0     /* No error */
  ------------------
  485|      0|    }
  486|       |
  487|  17.2k|    if (len == 11 && strcmp(name, "ssh-ed25519") == 0) {
  ------------------
  |  Branch (487:9): [True: 17.2k, False: 0]
  |  Branch (487:22): [True: 17.2k, False: 0]
  ------------------
  488|  17.2k|        *type = SSH_KEYTYPE_ED25519;
  489|  17.2k|        *hash_type = SSH_DIGEST_AUTO;
  490|  17.2k|        return SSH_OK;
  ------------------
  |  |  316|  17.2k|#define SSH_OK 0     /* No error */
  ------------------
  491|  17.2k|    }
  492|       |
  493|      0|    if (len == 12) {
  ------------------
  |  Branch (493:9): [True: 0, False: 0]
  ------------------
  494|      0|        if (strcmp(name, "rsa-sha2-256") == 0) {
  ------------------
  |  Branch (494:13): [True: 0, False: 0]
  ------------------
  495|      0|            *type = SSH_KEYTYPE_RSA;
  496|      0|            *hash_type = SSH_DIGEST_SHA256;
  497|      0|            return SSH_OK;
  ------------------
  |  |  316|      0|#define SSH_OK 0     /* No error */
  ------------------
  498|      0|        }
  499|      0|        if (strcmp(name, "rsa-sha2-512") == 0) {
  ------------------
  |  Branch (499:13): [True: 0, False: 0]
  ------------------
  500|      0|            *type = SSH_KEYTYPE_RSA;
  501|      0|            *hash_type = SSH_DIGEST_SHA512;
  502|      0|            return SSH_OK;
  ------------------
  |  |  316|      0|#define SSH_OK 0     /* No error */
  ------------------
  503|      0|        }
  504|      0|    }
  505|       |
  506|      0|    if (len == 19) {
  ------------------
  |  Branch (506:9): [True: 0, False: 0]
  ------------------
  507|      0|        if (strcmp(name, "ecdsa-sha2-nistp256") == 0) {
  ------------------
  |  Branch (507:13): [True: 0, False: 0]
  ------------------
  508|      0|            *type = SSH_KEYTYPE_ECDSA_P256;
  509|      0|            *hash_type = SSH_DIGEST_SHA256;
  510|      0|            return SSH_OK;
  ------------------
  |  |  316|      0|#define SSH_OK 0     /* No error */
  ------------------
  511|      0|        }
  512|      0|        if (strcmp(name, "ecdsa-sha2-nistp384") == 0) {
  ------------------
  |  Branch (512:13): [True: 0, False: 0]
  ------------------
  513|      0|            *type = SSH_KEYTYPE_ECDSA_P384;
  514|      0|            *hash_type = SSH_DIGEST_SHA384;
  515|      0|            return SSH_OK;
  ------------------
  |  |  316|      0|#define SSH_OK 0     /* No error */
  ------------------
  516|      0|        }
  517|       |
  518|      0|        if (strcmp(name, "ecdsa-sha2-nistp521") == 0) {
  ------------------
  |  Branch (518:13): [True: 0, False: 0]
  ------------------
  519|      0|            *type = SSH_KEYTYPE_ECDSA_P521;
  520|      0|            *hash_type = SSH_DIGEST_SHA512;
  521|      0|            return SSH_OK;
  ------------------
  |  |  316|      0|#define SSH_OK 0     /* No error */
  ------------------
  522|      0|        }
  523|      0|    }
  524|       |
  525|      0|    if (len == 26 && strcmp(name, "sk-ssh-ed25519@openssh.com") == 0) {
  ------------------
  |  Branch (525:9): [True: 0, False: 0]
  |  Branch (525:22): [True: 0, False: 0]
  ------------------
  526|      0|        *type = SSH_KEYTYPE_SK_ED25519;
  527|      0|        *hash_type = SSH_DIGEST_AUTO;
  528|      0|        return SSH_OK;
  ------------------
  |  |  316|      0|#define SSH_OK 0     /* No error */
  ------------------
  529|      0|    }
  530|       |
  531|      0|    if (len == 28 && strcmp(name, "ssh-rsa-cert-v01@openssh.com") == 0) {
  ------------------
  |  Branch (531:9): [True: 0, False: 0]
  |  Branch (531:22): [True: 0, False: 0]
  ------------------
  532|      0|        *type = SSH_KEYTYPE_RSA_CERT01;
  533|      0|        *hash_type = SSH_DIGEST_SHA1;
  534|      0|        return SSH_OK;
  ------------------
  |  |  316|      0|#define SSH_OK 0     /* No error */
  ------------------
  535|      0|    }
  536|       |
  537|      0|    if (len == 32 && strcmp(name, "ssh-ed25519-cert-v01@openssh.com") == 0) {
  ------------------
  |  Branch (537:9): [True: 0, False: 0]
  |  Branch (537:22): [True: 0, False: 0]
  ------------------
  538|      0|        *type = SSH_KEYTYPE_ED25519_CERT01;
  539|      0|        *hash_type = SSH_DIGEST_AUTO;
  540|      0|        return SSH_OK;
  ------------------
  |  |  316|      0|#define SSH_OK 0     /* No error */
  ------------------
  541|      0|    }
  542|       |
  543|      0|    if (len == 33) {
  ------------------
  |  Branch (543:9): [True: 0, False: 0]
  ------------------
  544|      0|        if (strcmp(name, "rsa-sha2-256-cert-v01@openssh.com") == 0) {
  ------------------
  |  Branch (544:13): [True: 0, False: 0]
  ------------------
  545|      0|            *type = SSH_KEYTYPE_RSA_CERT01;
  546|      0|            *hash_type = SSH_DIGEST_SHA256;
  547|      0|            return SSH_OK;
  ------------------
  |  |  316|      0|#define SSH_OK 0     /* No error */
  ------------------
  548|      0|        }
  549|      0|        if (strcmp(name, "rsa-sha2-512-cert-v01@openssh.com") == 0) {
  ------------------
  |  Branch (549:13): [True: 0, False: 0]
  ------------------
  550|      0|            *type = SSH_KEYTYPE_RSA_CERT01;
  551|      0|            *hash_type = SSH_DIGEST_SHA512;
  552|      0|            return SSH_OK;
  ------------------
  |  |  316|      0|#define SSH_OK 0     /* No error */
  ------------------
  553|      0|        }
  554|      0|    }
  555|       |
  556|      0|    if (len == 34 && strcmp(name, "sk-ecdsa-sha2-nistp256@openssh.com") == 0) {
  ------------------
  |  Branch (556:9): [True: 0, False: 0]
  |  Branch (556:22): [True: 0, False: 0]
  ------------------
  557|      0|        *type = SSH_KEYTYPE_SK_ECDSA;
  558|      0|        *hash_type = SSH_DIGEST_SHA256;
  559|      0|        return SSH_OK;
  ------------------
  |  |  316|      0|#define SSH_OK 0     /* No error */
  ------------------
  560|      0|    }
  561|       |
  562|      0|    if (len == 40) {
  ------------------
  |  Branch (562:9): [True: 0, False: 0]
  ------------------
  563|      0|        if (strcmp(name, "ecdsa-sha2-nistp256-cert-v01@openssh.com") == 0) {
  ------------------
  |  Branch (563:13): [True: 0, False: 0]
  ------------------
  564|      0|            *type = SSH_KEYTYPE_ECDSA_P256_CERT01;
  565|      0|            *hash_type = SSH_DIGEST_SHA256;
  566|      0|            return SSH_OK;
  ------------------
  |  |  316|      0|#define SSH_OK 0     /* No error */
  ------------------
  567|      0|        }
  568|      0|        if (strcmp(name, "ecdsa-sha2-nistp384-cert-v01@openssh.com") == 0) {
  ------------------
  |  Branch (568:13): [True: 0, False: 0]
  ------------------
  569|      0|            *type = SSH_KEYTYPE_ECDSA_P384_CERT01;
  570|      0|            *hash_type = SSH_DIGEST_SHA384;
  571|      0|            return SSH_OK;
  ------------------
  |  |  316|      0|#define SSH_OK 0     /* No error */
  ------------------
  572|      0|        }
  573|      0|        if (strcmp(name, "ecdsa-sha2-nistp521-cert-v01@openssh.com") == 0) {
  ------------------
  |  Branch (573:13): [True: 0, False: 0]
  ------------------
  574|      0|            *type = SSH_KEYTYPE_ECDSA_P521_CERT01;
  575|      0|            *hash_type = SSH_DIGEST_SHA512;
  576|      0|            return SSH_OK;
  ------------------
  |  |  316|      0|#define SSH_OK 0     /* No error */
  ------------------
  577|      0|        }
  578|      0|    }
  579|       |
  580|      0|    SSH_LOG(SSH_LOG_TRACE, "Unknown signature name %s", name);
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  581|      0|    return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  582|      0|}
ssh_key_size_allowed:
  646|  17.2k|{
  647|  17.2k|    int min_size = 0;
  648|       |
  649|  17.2k|    switch (ssh_key_type(key)) {
  650|      0|    case SSH_KEYTYPE_RSA:
  ------------------
  |  Branch (650:5): [True: 0, False: 17.2k]
  ------------------
  651|      0|    case SSH_KEYTYPE_RSA_CERT01:
  ------------------
  |  Branch (651:5): [True: 0, False: 17.2k]
  ------------------
  652|      0|        min_size = session->opts.rsa_min_size;
  653|      0|        return ssh_key_size_allowed_rsa(min_size, key);
  654|  17.2k|    default:
  ------------------
  |  Branch (654:5): [True: 17.2k, False: 0]
  ------------------
  655|       |        return true;
  656|  17.2k|    }
  657|  17.2k|}
ssh_key_type_from_name:
  808|  25.9k|{
  809|  25.9k|    if (name == NULL) {
  ------------------
  |  Branch (809:9): [True: 0, False: 25.9k]
  ------------------
  810|      0|        return SSH_KEYTYPE_UNKNOWN;
  811|      0|    }
  812|       |
  813|  25.9k|    if (strcmp(name, "rsa") == 0) {
  ------------------
  |  Branch (813:9): [True: 0, False: 25.9k]
  ------------------
  814|      0|        return SSH_KEYTYPE_RSA;
  815|  25.9k|    } else if (strcmp(name, "ssh-rsa") == 0) {
  ------------------
  |  Branch (815:16): [True: 0, False: 25.9k]
  ------------------
  816|      0|        return SSH_KEYTYPE_RSA;
  817|  25.9k|    } else if (strcmp(name, "ssh-ecdsa") == 0
  ------------------
  |  Branch (817:16): [True: 0, False: 25.9k]
  ------------------
  818|  25.9k|            || strcmp(name, "ecdsa") == 0
  ------------------
  |  Branch (818:16): [True: 0, False: 25.9k]
  ------------------
  819|  25.9k|            || strcmp(name, "ecdsa-sha2-nistp256") == 0) {
  ------------------
  |  Branch (819:16): [True: 0, False: 25.9k]
  ------------------
  820|      0|        return SSH_KEYTYPE_ECDSA_P256;
  821|  25.9k|    } else if (strcmp(name, "ecdsa-sha2-nistp384") == 0) {
  ------------------
  |  Branch (821:16): [True: 0, False: 25.9k]
  ------------------
  822|      0|        return SSH_KEYTYPE_ECDSA_P384;
  823|  25.9k|    } else if (strcmp(name, "ecdsa-sha2-nistp521") == 0) {
  ------------------
  |  Branch (823:16): [True: 0, False: 25.9k]
  ------------------
  824|      0|        return SSH_KEYTYPE_ECDSA_P521;
  825|  25.9k|    } else if (strcmp(name, "ssh-ed25519") == 0){
  ------------------
  |  Branch (825:16): [True: 25.9k, False: 0]
  ------------------
  826|  25.9k|        return SSH_KEYTYPE_ED25519;
  827|  25.9k|    } else if (strcmp(name, "ssh-rsa-cert-v01@openssh.com") == 0) {
  ------------------
  |  Branch (827:16): [True: 0, False: 0]
  ------------------
  828|      0|        return SSH_KEYTYPE_RSA_CERT01;
  829|      0|    } else if (strcmp(name, "ecdsa-sha2-nistp256-cert-v01@openssh.com") == 0) {
  ------------------
  |  Branch (829:16): [True: 0, False: 0]
  ------------------
  830|      0|        return SSH_KEYTYPE_ECDSA_P256_CERT01;
  831|      0|    } else if (strcmp(name, "ecdsa-sha2-nistp384-cert-v01@openssh.com") == 0) {
  ------------------
  |  Branch (831:16): [True: 0, False: 0]
  ------------------
  832|      0|        return SSH_KEYTYPE_ECDSA_P384_CERT01;
  833|      0|    } else if (strcmp(name, "ecdsa-sha2-nistp521-cert-v01@openssh.com") == 0) {
  ------------------
  |  Branch (833:16): [True: 0, False: 0]
  ------------------
  834|      0|        return SSH_KEYTYPE_ECDSA_P521_CERT01;
  835|      0|    } else if (strcmp(name, "ssh-ed25519-cert-v01@openssh.com") == 0) {
  ------------------
  |  Branch (835:16): [True: 0, False: 0]
  ------------------
  836|      0|        return SSH_KEYTYPE_ED25519_CERT01;
  837|      0|    } else if(strcmp(name, "sk-ecdsa-sha2-nistp256@openssh.com") == 0) {
  ------------------
  |  Branch (837:15): [True: 0, False: 0]
  ------------------
  838|      0|        return SSH_KEYTYPE_SK_ECDSA;
  839|      0|    } else if(strcmp(name, "sk-ecdsa-sha2-nistp256-cert-v01@openssh.com") == 0) {
  ------------------
  |  Branch (839:15): [True: 0, False: 0]
  ------------------
  840|      0|        return SSH_KEYTYPE_SK_ECDSA_CERT01;
  841|      0|    } else if(strcmp(name, "sk-ssh-ed25519@openssh.com") == 0) {
  ------------------
  |  Branch (841:15): [True: 0, False: 0]
  ------------------
  842|      0|        return SSH_KEYTYPE_SK_ED25519;
  843|      0|    } else if(strcmp(name, "sk-ssh-ed25519-cert-v01@openssh.com") == 0) {
  ------------------
  |  Branch (843:15): [True: 0, False: 0]
  ------------------
  844|      0|        return SSH_KEYTYPE_SK_ED25519_CERT01;
  845|      0|    }
  846|       |
  847|      0|    return SSH_KEYTYPE_UNKNOWN;
  848|  25.9k|}
ssh_key_type_plain:
  858|  17.2k|{
  859|  17.2k|    switch (type) {
  860|      0|        case SSH_KEYTYPE_RSA_CERT01:
  ------------------
  |  Branch (860:9): [True: 0, False: 17.2k]
  ------------------
  861|      0|            return SSH_KEYTYPE_RSA;
  862|      0|        case SSH_KEYTYPE_ECDSA_P256_CERT01:
  ------------------
  |  Branch (862:9): [True: 0, False: 17.2k]
  ------------------
  863|      0|            return SSH_KEYTYPE_ECDSA_P256;
  864|      0|        case SSH_KEYTYPE_ECDSA_P384_CERT01:
  ------------------
  |  Branch (864:9): [True: 0, False: 17.2k]
  ------------------
  865|      0|            return SSH_KEYTYPE_ECDSA_P384;
  866|      0|        case SSH_KEYTYPE_ECDSA_P521_CERT01:
  ------------------
  |  Branch (866:9): [True: 0, False: 17.2k]
  ------------------
  867|      0|            return SSH_KEYTYPE_ECDSA_P521;
  868|      0|        case SSH_KEYTYPE_ED25519_CERT01:
  ------------------
  |  Branch (868:9): [True: 0, False: 17.2k]
  ------------------
  869|      0|            return SSH_KEYTYPE_ED25519;
  870|      0|        case SSH_KEYTYPE_SK_ECDSA_CERT01:
  ------------------
  |  Branch (870:9): [True: 0, False: 17.2k]
  ------------------
  871|      0|            return SSH_KEYTYPE_SK_ECDSA;
  872|      0|        case SSH_KEYTYPE_SK_ED25519_CERT01:
  ------------------
  |  Branch (872:9): [True: 0, False: 17.2k]
  ------------------
  873|      0|            return SSH_KEYTYPE_SK_ED25519;
  874|  17.2k|        default:
  ------------------
  |  Branch (874:9): [True: 17.2k, False: 0]
  ------------------
  875|  17.2k|            return type;
  876|  17.2k|    }
  877|  17.2k|}
ssh_key_is_private:
  902|  34.5k|int ssh_key_is_private(const ssh_key k) {
  903|  34.5k|    if (k == NULL) {
  ------------------
  |  Branch (903:9): [True: 0, False: 34.5k]
  ------------------
  904|      0|        return 0;
  905|      0|    }
  906|       |
  907|  34.5k|    return (k->flags & SSH_KEY_FLAG_PRIVATE) == SSH_KEY_FLAG_PRIVATE;
  ------------------
  |  |   55|  34.5k|#define SSH_KEY_FLAG_PRIVATE 0x0002
  ------------------
                  return (k->flags & SSH_KEY_FLAG_PRIVATE) == SSH_KEY_FLAG_PRIVATE;
  ------------------
  |  |   55|  34.5k|#define SSH_KEY_FLAG_PRIVATE 0x0002
  ------------------
  908|  34.5k|}
ssh_signature_new:
  997|  17.2k|{
  998|  17.2k|    struct ssh_signature_struct *sig = NULL;
  999|       |
 1000|  17.2k|    sig = calloc(1, sizeof(struct ssh_signature_struct));
 1001|  17.2k|    if (sig == NULL) {
  ------------------
  |  Branch (1001:9): [True: 0, False: 17.2k]
  ------------------
 1002|      0|        return NULL;
 1003|      0|    }
 1004|       |
 1005|  17.2k|    return sig;
 1006|  17.2k|}
ssh_signature_free:
 1009|  17.2k|{
 1010|  17.2k|    if (sig == NULL) {
  ------------------
  |  Branch (1010:9): [True: 0, False: 17.2k]
  ------------------
 1011|      0|        return;
 1012|      0|    }
 1013|       |
 1014|  17.2k|    switch(sig->type) {
  ------------------
  |  Branch (1014:12): [True: 17.2k, False: 0]
  ------------------
 1015|      0|        case SSH_KEYTYPE_RSA:
  ------------------
  |  Branch (1015:9): [True: 0, False: 17.2k]
  ------------------
 1016|       |#ifdef HAVE_LIBMBEDCRYPTO
 1017|       |            SAFE_FREE(sig->rsa_sig);
 1018|       |#endif /* HAVE_LIBMBEDCRYPTO */
 1019|      0|            break;
 1020|      0|        case SSH_KEYTYPE_ECDSA_P256:
  ------------------
  |  Branch (1020:9): [True: 0, False: 17.2k]
  ------------------
 1021|      0|        case SSH_KEYTYPE_ECDSA_P384:
  ------------------
  |  Branch (1021:9): [True: 0, False: 17.2k]
  ------------------
 1022|      0|        case SSH_KEYTYPE_ECDSA_P521:
  ------------------
  |  Branch (1022:9): [True: 0, False: 17.2k]
  ------------------
 1023|      0|        case SSH_KEYTYPE_SK_ECDSA:
  ------------------
  |  Branch (1023:9): [True: 0, False: 17.2k]
  ------------------
 1024|       |#ifdef HAVE_GCRYPT_ECC
 1025|       |            gcry_sexp_release(sig->ecdsa_sig);
 1026|       |#elif defined HAVE_LIBMBEDCRYPTO
 1027|       |            bignum_safe_free(sig->ecdsa_sig.r);
 1028|       |            bignum_safe_free(sig->ecdsa_sig.s);
 1029|       |#endif /* HAVE_GCRYPT_ECC */
 1030|      0|            break;
 1031|  17.2k|        case SSH_KEYTYPE_ED25519:
  ------------------
  |  Branch (1031:9): [True: 17.2k, False: 0]
  ------------------
 1032|  17.2k|        case SSH_KEYTYPE_SK_ED25519:
  ------------------
  |  Branch (1032:9): [True: 0, False: 17.2k]
  ------------------
 1033|       |#ifndef HAVE_LIBCRYPTO
 1034|       |            /* When using OpenSSL, the signature is stored in sig->raw_sig */
 1035|       |            SAFE_FREE(sig->ed25519_sig);
 1036|       |#endif /* HAVE_LIBCRYPTO */
 1037|  17.2k|            break;
 1038|      0|        case SSH_KEYTYPE_DSS:   /* deprecated */
  ------------------
  |  Branch (1038:9): [True: 0, False: 17.2k]
  ------------------
 1039|      0|        case SSH_KEYTYPE_DSS_CERT01:    /* deprecated */
  ------------------
  |  Branch (1039:9): [True: 0, False: 17.2k]
  ------------------
 1040|      0|        case SSH_KEYTYPE_RSA_CERT01:
  ------------------
  |  Branch (1040:9): [True: 0, False: 17.2k]
  ------------------
 1041|      0|        case SSH_KEYTYPE_ECDSA_P256_CERT01:
  ------------------
  |  Branch (1041:9): [True: 0, False: 17.2k]
  ------------------
 1042|      0|        case SSH_KEYTYPE_ECDSA_P384_CERT01:
  ------------------
  |  Branch (1042:9): [True: 0, False: 17.2k]
  ------------------
 1043|      0|        case SSH_KEYTYPE_ECDSA_P521_CERT01:
  ------------------
  |  Branch (1043:9): [True: 0, False: 17.2k]
  ------------------
 1044|      0|        case SSH_KEYTYPE_ED25519_CERT01:
  ------------------
  |  Branch (1044:9): [True: 0, False: 17.2k]
  ------------------
 1045|      0|        case SSH_KEYTYPE_SK_ECDSA_CERT01:
  ------------------
  |  Branch (1045:9): [True: 0, False: 17.2k]
  ------------------
 1046|      0|        case SSH_KEYTYPE_SK_ED25519_CERT01:
  ------------------
  |  Branch (1046:9): [True: 0, False: 17.2k]
  ------------------
 1047|      0|        case SSH_KEYTYPE_RSA1:
  ------------------
  |  Branch (1047:9): [True: 0, False: 17.2k]
  ------------------
 1048|      0|        case SSH_KEYTYPE_ECDSA:
  ------------------
  |  Branch (1048:9): [True: 0, False: 17.2k]
  ------------------
 1049|      0|        case SSH_KEYTYPE_UNKNOWN:
  ------------------
  |  Branch (1049:9): [True: 0, False: 17.2k]
  ------------------
 1050|      0|            break;
 1051|  17.2k|    }
 1052|       |
 1053|       |    /* Explicitly zero the signature content before free */
 1054|  17.2k|    ssh_string_burn(sig->raw_sig);
 1055|  17.2k|    SSH_STRING_FREE(sig->raw_sig);
  ------------------
  |  |  893|  17.2k|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (893:14): [True: 17.2k, False: 0]
  |  |  |  Branch (893:69): [Folded, False: 17.2k]
  |  |  ------------------
  ------------------
 1056|       |    SAFE_FREE(sig);
  ------------------
  |  |  373|  17.2k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 17.2k, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 17.2k]
  |  |  ------------------
  ------------------
 1057|  17.2k|}
ssh_pki_import_privkey_base64:
 1082|  8.64k|{
 1083|  8.64k|    ssh_key key = NULL;
 1084|  8.64k|    const char *openssh_header = NULL;
 1085|       |
 1086|  8.64k|    if (b64_key == NULL || pkey == NULL) {
  ------------------
  |  Branch (1086:9): [True: 0, False: 8.64k]
  |  Branch (1086:28): [True: 0, False: 8.64k]
  ------------------
 1087|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 1088|      0|    }
 1089|       |
 1090|  8.64k|    if (b64_key == NULL || !*b64_key) {
  ------------------
  |  Branch (1090:9): [True: 0, False: 8.64k]
  |  Branch (1090:28): [True: 0, False: 8.64k]
  ------------------
 1091|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 1092|      0|    }
 1093|       |
 1094|  8.64k|    SSH_LOG(SSH_LOG_DEBUG,
  ------------------
  |  |  281|  17.2k|    _ssh_log(priority, __func__, __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (281:34): [True: 0, False: 8.64k]
  |  |  ------------------
  ------------------
 1095|  8.64k|            "Trying to decode privkey passphrase=%s",
 1096|  8.64k|            passphrase ? "true" : "false");
 1097|       |
 1098|       |    /* Test for OpenSSH key format first */
 1099|  8.64k|    openssh_header = strstr(b64_key, OPENSSH_HEADER_BEGIN);
  ------------------
  |  |   43|  8.64k|#define OPENSSH_HEADER_BEGIN "-----BEGIN OPENSSH PRIVATE KEY-----"
  ------------------
 1100|  8.64k|    if (openssh_header != NULL) {
  ------------------
  |  Branch (1100:9): [True: 8.64k, False: 0]
  ------------------
 1101|  8.64k|        key = ssh_pki_openssh_privkey_import(openssh_header,
 1102|  8.64k|                                             passphrase,
 1103|  8.64k|                                             auth_fn,
 1104|  8.64k|                                             auth_data);
 1105|  8.64k|    } else {
 1106|       |        /* fallback on PEM decoder */
 1107|      0|        key = pki_private_key_from_base64(b64_key,
 1108|      0|                                          passphrase,
 1109|      0|                                          auth_fn,
 1110|      0|                                          auth_data);
 1111|      0|    }
 1112|  8.64k|    if (key == NULL) {
  ------------------
  |  Branch (1112:9): [True: 0, False: 8.64k]
  ------------------
 1113|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 1114|      0|    }
 1115|       |
 1116|  8.64k|    *pkey = key;
 1117|       |
 1118|  8.64k|    return SSH_OK;
  ------------------
  |  |  316|  8.64k|#define SSH_OK 0     /* No error */
  ------------------
 1119|  8.64k|}
ssh_pki_import_privkey_file:
 1266|  8.64k|                                ssh_key *pkey) {
 1267|  8.64k|    struct stat sb;
 1268|  8.64k|    char *key_buf = NULL;
 1269|  8.64k|    FILE *file = NULL;
 1270|  8.64k|    off_t size;
 1271|  8.64k|    int rc;
 1272|       |
 1273|  8.64k|    if (pkey == NULL || filename == NULL || *filename == '\0') {
  ------------------
  |  Branch (1273:9): [True: 0, False: 8.64k]
  |  Branch (1273:25): [True: 0, False: 8.64k]
  |  Branch (1273:45): [True: 0, False: 8.64k]
  ------------------
 1274|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 1275|      0|    }
 1276|       |
 1277|       |#ifdef WITH_PKCS11_URI
 1278|       |    if (ssh_pki_is_uri(filename)) {
 1279|       |        rc = pki_uri_import(filename, pkey, SSH_KEY_PRIVATE);
 1280|       |        return rc;
 1281|       |    }
 1282|       |#endif /* WITH_PKCS11_URI */
 1283|       |
 1284|  8.64k|    file = fopen(filename, "rb");
 1285|  8.64k|    if (file == NULL) {
  ------------------
  |  Branch (1285:9): [True: 0, False: 8.64k]
  ------------------
 1286|      0|        SSH_LOG_STRERROR(SSH_LOG_TRACE,
  ------------------
  |  |  283|      0|    do {                                                            \
  |  |  284|      0|        char err_msg[SSH_ERRNO_MSG_MAX] = {0};                      \
  |  |  285|      0|        _ssh_log(priority,                                          \
  |  |  286|      0|                 __func__,                                          \
  |  |  287|      0|                 __VA_ARGS__,                                       \
  |  |  288|      0|                 ssh_strerror(errnum, err_msg, SSH_ERRNO_MSG_MAX)); \
  |  |  ------------------
  |  |  |  |  520|      0|#define SSH_ERRNO_MSG_MAX   1024
  |  |  ------------------
  |  |  289|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (289:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1287|      0|                         errno,
 1288|      0|                         "Error opening %s: %s",
 1289|      0|                         filename);
 1290|      0|        return SSH_EOF;
  ------------------
  |  |  319|      0|#define SSH_EOF -127 /* We have already a eof */
  ------------------
 1291|      0|    }
 1292|       |
 1293|  8.64k|    rc = fstat(fileno(file), &sb);
 1294|  8.64k|    if (rc < 0) {
  ------------------
  |  Branch (1294:9): [True: 0, False: 8.64k]
  ------------------
 1295|      0|        fclose(file);
 1296|      0|        SSH_LOG_STRERROR(SSH_LOG_TRACE,
  ------------------
  |  |  283|      0|    do {                                                            \
  |  |  284|      0|        char err_msg[SSH_ERRNO_MSG_MAX] = {0};                      \
  |  |  285|      0|        _ssh_log(priority,                                          \
  |  |  286|      0|                 __func__,                                          \
  |  |  287|      0|                 __VA_ARGS__,                                       \
  |  |  288|      0|                 ssh_strerror(errnum, err_msg, SSH_ERRNO_MSG_MAX)); \
  |  |  ------------------
  |  |  |  |  520|      0|#define SSH_ERRNO_MSG_MAX   1024
  |  |  ------------------
  |  |  289|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (289:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1297|      0|                         errno,
 1298|      0|                         "Error getting fstat of %s: %s",
 1299|      0|                         filename);
 1300|      0|        switch (errno) {
  ------------------
  |  Branch (1300:17): [True: 0, False: 0]
  ------------------
 1301|      0|            case ENOENT:
  ------------------
  |  Branch (1301:13): [True: 0, False: 0]
  ------------------
 1302|      0|            case EACCES:
  ------------------
  |  Branch (1302:13): [True: 0, False: 0]
  ------------------
 1303|      0|                return SSH_EOF;
  ------------------
  |  |  319|      0|#define SSH_EOF -127 /* We have already a eof */
  ------------------
 1304|      0|        }
 1305|       |
 1306|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 1307|      0|    }
 1308|       |
 1309|  8.64k|    if (sb.st_size > MAX_PRIVKEY_SIZE) {
  ------------------
  |  |   47|  8.64k|#define MAX_PRIVKEY_SIZE 0x400000 /* 4M */
  ------------------
  |  Branch (1309:9): [True: 0, False: 8.64k]
  ------------------
 1310|      0|        SSH_LOG(SSH_LOG_TRACE,
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 1311|      0|                "Private key is bigger than 4M.");
 1312|      0|        fclose(file);
 1313|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 1314|      0|    }
 1315|       |
 1316|  8.64k|    key_buf = malloc(sb.st_size + 1);
 1317|  8.64k|    if (key_buf == NULL) {
  ------------------
  |  Branch (1317:9): [True: 0, False: 8.64k]
  ------------------
 1318|      0|        fclose(file);
 1319|      0|        SSH_LOG(SSH_LOG_TRACE, "Out of memory!");
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 1320|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 1321|      0|    }
 1322|       |
 1323|  8.64k|    size = fread(key_buf, 1, sb.st_size, file);
 1324|  8.64k|    fclose(file);
 1325|       |
 1326|  8.64k|    if (size != sb.st_size) {
  ------------------
  |  Branch (1326:9): [True: 0, False: 8.64k]
  ------------------
 1327|      0|        SAFE_FREE(key_buf);
  ------------------
  |  |  373|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1328|      0|        SSH_LOG_STRERROR(SSH_LOG_TRACE,
  ------------------
  |  |  283|      0|    do {                                                            \
  |  |  284|      0|        char err_msg[SSH_ERRNO_MSG_MAX] = {0};                      \
  |  |  285|      0|        _ssh_log(priority,                                          \
  |  |  286|      0|                 __func__,                                          \
  |  |  287|      0|                 __VA_ARGS__,                                       \
  |  |  288|      0|                 ssh_strerror(errnum, err_msg, SSH_ERRNO_MSG_MAX)); \
  |  |  ------------------
  |  |  |  |  520|      0|#define SSH_ERRNO_MSG_MAX   1024
  |  |  ------------------
  |  |  289|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (289:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1329|      0|                         errno,
 1330|      0|                         "Error reading %s: %s",
 1331|      0|                         filename);
 1332|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 1333|      0|    }
 1334|  8.64k|    key_buf[size] = 0;
 1335|       |
 1336|  8.64k|    rc = ssh_pki_import_privkey_base64(key_buf,
 1337|  8.64k|                                       passphrase,
 1338|  8.64k|                                       auth_fn,
 1339|  8.64k|                                       auth_data,
 1340|  8.64k|                                       pkey);
 1341|       |
 1342|       |    SAFE_FREE(key_buf);
  ------------------
  |  |  373|  8.64k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 8.64k, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 8.64k]
  |  |  ------------------
  ------------------
 1343|  8.64k|    return rc;
 1344|  8.64k|}
pki_import_privkey_buffer:
 1537|  8.64k|{
 1538|  8.64k|    ssh_key key = NULL;
 1539|  8.64k|    int rc;
 1540|       |
 1541|  8.64k|    key = ssh_key_new();
 1542|  8.64k|    if (key == NULL) {
  ------------------
  |  Branch (1542:9): [True: 0, False: 8.64k]
  ------------------
 1543|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 1544|      0|    }
 1545|       |
 1546|  8.64k|    key->type = type;
 1547|  8.64k|    key->type_c = ssh_key_type_to_char(type);
 1548|  8.64k|    key->flags = SSH_KEY_FLAG_PRIVATE | SSH_KEY_FLAG_PUBLIC;
  ------------------
  |  |   55|  8.64k|#define SSH_KEY_FLAG_PRIVATE 0x0002
  ------------------
                  key->flags = SSH_KEY_FLAG_PRIVATE | SSH_KEY_FLAG_PUBLIC;
  ------------------
  |  |   54|  8.64k|#define SSH_KEY_FLAG_PUBLIC  0x0001
  ------------------
 1549|       |
 1550|  8.64k|    switch (type) {
 1551|      0|    case SSH_KEYTYPE_RSA: {
  ------------------
  |  Branch (1551:5): [True: 0, False: 8.64k]
  ------------------
 1552|      0|        ssh_string n = NULL;
 1553|      0|        ssh_string e = NULL;
 1554|      0|        ssh_string d = NULL;
 1555|      0|        ssh_string iqmp = NULL;
 1556|      0|        ssh_string p = NULL;
 1557|      0|        ssh_string q = NULL;
 1558|       |
 1559|      0|        rc = ssh_buffer_unpack(buffer, "SSSSSS", &n, &e, &d, &iqmp, &p, &q);
  ------------------
  |  |   60|      0|    _ssh_buffer_unpack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |  451|      0|        (__VA_NARG_(__VA_ARGS__, __RSEQ_N()))
  |  |  |  |  ------------------
  |  |  |  |  |  |  453|      0|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  448|      0|#define VA_APPLY_VARIADIC_MACRO(macro, tuple) macro tuple
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  453|      0|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  461|      0|        _61,_62,_63,N,...) N
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                   _ssh_buffer_unpack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |   28|      0|#define SSH_BUFFER_PACK_END ((uint32_t) 0x4f65feb3)
  |  |  ------------------
  ------------------
 1560|      0|        if (rc != SSH_OK) {
  ------------------
  |  |  316|      0|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (1560:13): [True: 0, False: 0]
  ------------------
 1561|      0|            SSH_LOG(SSH_LOG_TRACE, "Unpack error");
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 1562|      0|            goto fail;
 1563|      0|        }
 1564|       |
 1565|      0|        rc = pki_privkey_build_rsa(key, n, e, d, iqmp, p, q);
 1566|       |#ifdef DEBUG_CRYPTO
 1567|       |        ssh_log_hexdump("n", ssh_string_data(n), ssh_string_len(n));
 1568|       |        ssh_log_hexdump("e", ssh_string_data(e), ssh_string_len(e));
 1569|       |        ssh_log_hexdump("d", ssh_string_data(d), ssh_string_len(d));
 1570|       |        ssh_log_hexdump("iqmp", ssh_string_data(iqmp), ssh_string_len(iqmp));
 1571|       |        ssh_log_hexdump("p", ssh_string_data(p), ssh_string_len(p));
 1572|       |        ssh_log_hexdump("q", ssh_string_data(q), ssh_string_len(q));
 1573|       |#endif /* DEBUG_CRYPTO */
 1574|      0|        ssh_string_burn(n);
 1575|      0|        SSH_STRING_FREE(n);
  ------------------
  |  |  893|      0|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (893:14): [True: 0, False: 0]
  |  |  |  Branch (893:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1576|      0|        ssh_string_burn(e);
 1577|      0|        SSH_STRING_FREE(e);
  ------------------
  |  |  893|      0|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (893:14): [True: 0, False: 0]
  |  |  |  Branch (893:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1578|      0|        ssh_string_burn(d);
 1579|      0|        SSH_STRING_FREE(d);
  ------------------
  |  |  893|      0|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (893:14): [True: 0, False: 0]
  |  |  |  Branch (893:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1580|      0|        ssh_string_burn(iqmp);
 1581|      0|        SSH_STRING_FREE(iqmp);
  ------------------
  |  |  893|      0|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (893:14): [True: 0, False: 0]
  |  |  |  Branch (893:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1582|      0|        ssh_string_burn(p);
 1583|      0|        SSH_STRING_FREE(p);
  ------------------
  |  |  893|      0|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (893:14): [True: 0, False: 0]
  |  |  |  Branch (893:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1584|      0|        ssh_string_burn(q);
 1585|      0|        SSH_STRING_FREE(q);
  ------------------
  |  |  893|      0|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (893:14): [True: 0, False: 0]
  |  |  |  Branch (893:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1586|      0|        if (rc == SSH_ERROR) {
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  |  Branch (1586:13): [True: 0, False: 0]
  ------------------
 1587|      0|            SSH_LOG(SSH_LOG_TRACE, "Failed to build RSA private key");
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 1588|      0|            goto fail;
 1589|      0|        }
 1590|      0|        break;
 1591|      0|    }
 1592|      0|#ifdef HAVE_ECC
 1593|      0|    case SSH_KEYTYPE_ECDSA_P256:
  ------------------
  |  Branch (1593:5): [True: 0, False: 8.64k]
  ------------------
 1594|      0|    case SSH_KEYTYPE_ECDSA_P384:
  ------------------
  |  Branch (1594:5): [True: 0, False: 8.64k]
  ------------------
 1595|      0|    case SSH_KEYTYPE_ECDSA_P521: {
  ------------------
  |  Branch (1595:5): [True: 0, False: 8.64k]
  ------------------
 1596|      0|        ssh_string e = NULL;
 1597|      0|        ssh_string exp = NULL;
 1598|      0|        ssh_string i = NULL;
 1599|      0|        int nid;
 1600|       |
 1601|      0|        rc = ssh_buffer_unpack(buffer, "SSS", &i, &e, &exp);
  ------------------
  |  |   60|      0|    _ssh_buffer_unpack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |  451|      0|        (__VA_NARG_(__VA_ARGS__, __RSEQ_N()))
  |  |  |  |  ------------------
  |  |  |  |  |  |  453|      0|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  448|      0|#define VA_APPLY_VARIADIC_MACRO(macro, tuple) macro tuple
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  453|      0|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  461|      0|        _61,_62,_63,N,...) N
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                   _ssh_buffer_unpack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |   28|      0|#define SSH_BUFFER_PACK_END ((uint32_t) 0x4f65feb3)
  |  |  ------------------
  ------------------
 1602|      0|        if (rc != SSH_OK) {
  ------------------
  |  |  316|      0|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (1602:13): [True: 0, False: 0]
  ------------------
 1603|      0|            SSH_LOG(SSH_LOG_TRACE, "Unpack error");
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 1604|      0|            goto fail;
 1605|      0|        }
 1606|       |
 1607|      0|        nid = pki_key_ecdsa_nid_from_name(ssh_string_get_char(i));
 1608|      0|        SSH_STRING_FREE(i);
  ------------------
  |  |  893|      0|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (893:14): [True: 0, False: 0]
  |  |  |  Branch (893:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1609|      0|        if (nid == -1) {
  ------------------
  |  Branch (1609:13): [True: 0, False: 0]
  ------------------
 1610|      0|            ssh_string_burn(e);
 1611|      0|            SSH_STRING_FREE(e);
  ------------------
  |  |  893|      0|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (893:14): [True: 0, False: 0]
  |  |  |  Branch (893:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1612|      0|            ssh_string_burn(exp);
 1613|      0|            SSH_STRING_FREE(exp);
  ------------------
  |  |  893|      0|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (893:14): [True: 0, False: 0]
  |  |  |  Branch (893:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1614|      0|            goto fail;
 1615|      0|        }
 1616|       |
 1617|      0|        rc = pki_privkey_build_ecdsa(key, nid, e, exp);
 1618|      0|        ssh_string_burn(e);
 1619|      0|        SSH_STRING_FREE(e);
  ------------------
  |  |  893|      0|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (893:14): [True: 0, False: 0]
  |  |  |  Branch (893:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1620|      0|        ssh_string_burn(exp);
 1621|      0|        SSH_STRING_FREE(exp);
  ------------------
  |  |  893|      0|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (893:14): [True: 0, False: 0]
  |  |  |  Branch (893:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1622|      0|        if (rc < 0) {
  ------------------
  |  Branch (1622:13): [True: 0, False: 0]
  ------------------
 1623|      0|            SSH_LOG(SSH_LOG_TRACE, "Failed to build ECDSA private key");
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 1624|      0|            goto fail;
 1625|      0|        }
 1626|      0|        break;
 1627|      0|    }
 1628|      0|    case SSH_KEYTYPE_SK_ECDSA: {
  ------------------
  |  Branch (1628:5): [True: 0, False: 8.64k]
  ------------------
 1629|      0|        ssh_string type_str = NULL;
 1630|      0|        ssh_string pubkey = NULL;
 1631|      0|        int nid;
 1632|       |
 1633|      0|        rc = ssh_buffer_unpack(buffer, "SS", &type_str, &pubkey);
  ------------------
  |  |   60|      0|    _ssh_buffer_unpack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |  451|      0|        (__VA_NARG_(__VA_ARGS__, __RSEQ_N()))
  |  |  |  |  ------------------
  |  |  |  |  |  |  453|      0|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  448|      0|#define VA_APPLY_VARIADIC_MACRO(macro, tuple) macro tuple
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  453|      0|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  461|      0|        _61,_62,_63,N,...) N
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                   _ssh_buffer_unpack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |   28|      0|#define SSH_BUFFER_PACK_END ((uint32_t) 0x4f65feb3)
  |  |  ------------------
  ------------------
 1634|      0|        if (rc != SSH_OK) {
  ------------------
  |  |  316|      0|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (1634:13): [True: 0, False: 0]
  ------------------
 1635|      0|            goto fail;
 1636|      0|        }
 1637|       |
 1638|      0|        rc = pki_buffer_unpack_sk_priv_data(buffer, key);
 1639|      0|        if (rc != SSH_OK) {
  ------------------
  |  |  316|      0|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (1639:13): [True: 0, False: 0]
  ------------------
 1640|      0|            SSH_STRING_FREE(type_str);
  ------------------
  |  |  893|      0|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (893:14): [True: 0, False: 0]
  |  |  |  Branch (893:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1641|      0|            SSH_STRING_FREE(pubkey);
  ------------------
  |  |  893|      0|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (893:14): [True: 0, False: 0]
  |  |  |  Branch (893:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1642|      0|            goto fail;
 1643|      0|        }
 1644|       |
 1645|      0|        nid = pki_key_ecdsa_nid_from_name(ssh_string_get_char(type_str));
 1646|      0|        SSH_STRING_FREE(type_str);
  ------------------
  |  |  893|      0|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (893:14): [True: 0, False: 0]
  |  |  |  Branch (893:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1647|       |
 1648|      0|        if (nid == -1) {
  ------------------
  |  Branch (1648:13): [True: 0, False: 0]
  ------------------
 1649|      0|            SSH_STRING_FREE(pubkey);
  ------------------
  |  |  893|      0|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (893:14): [True: 0, False: 0]
  |  |  |  Branch (893:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1650|      0|            goto fail;
 1651|      0|        }
 1652|       |
 1653|      0|        rc = pki_pubkey_build_ecdsa(key, nid, pubkey);
 1654|      0|        SSH_STRING_FREE(pubkey);
  ------------------
  |  |  893|      0|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (893:14): [True: 0, False: 0]
  |  |  |  Branch (893:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1655|      0|        if (rc != SSH_OK) {
  ------------------
  |  |  316|      0|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (1655:13): [True: 0, False: 0]
  ------------------
 1656|      0|            goto fail;
 1657|      0|        }
 1658|      0|        break;
 1659|      0|    }
 1660|      0|#endif /* HAVE_ECC */
 1661|  8.64k|    case SSH_KEYTYPE_ED25519: {
  ------------------
  |  Branch (1661:5): [True: 8.64k, False: 0]
  ------------------
 1662|  8.64k|        ssh_string pubkey = NULL, privkey = NULL;
 1663|       |
 1664|  8.64k|        if (ssh_fips_mode()) {
  ------------------
  |  |  115|  8.64k|#define ssh_fips_mode() (FIPS_mode() != 0)
  |  |  ------------------
  |  |  |  Branch (115:25): [True: 0, False: 8.64k]
  |  |  ------------------
  ------------------
 1665|      0|            SSH_LOG(SSH_LOG_TRACE, "Ed25519 keys not supported in FIPS mode");
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 1666|      0|            goto fail;
 1667|      0|        }
 1668|       |
 1669|  8.64k|        rc = ssh_buffer_unpack(buffer, "SS", &pubkey, &privkey);
  ------------------
  |  |   60|  8.64k|    _ssh_buffer_unpack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |  451|  8.64k|        (__VA_NARG_(__VA_ARGS__, __RSEQ_N()))
  |  |  |  |  ------------------
  |  |  |  |  |  |  453|  8.64k|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  448|  8.64k|#define VA_APPLY_VARIADIC_MACRO(macro, tuple) macro tuple
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  453|  8.64k|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  461|  8.64k|        _61,_62,_63,N,...) N
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                   _ssh_buffer_unpack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |   28|  8.64k|#define SSH_BUFFER_PACK_END ((uint32_t) 0x4f65feb3)
  |  |  ------------------
  ------------------
 1670|  8.64k|        if (rc != SSH_OK) {
  ------------------
  |  |  316|  8.64k|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (1670:13): [True: 0, False: 8.64k]
  ------------------
 1671|      0|            SSH_LOG(SSH_LOG_TRACE, "Unpack error");
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 1672|      0|            goto fail;
 1673|      0|        }
 1674|       |
 1675|  8.64k|        rc = pki_privkey_build_ed25519(key, pubkey, privkey);
 1676|  8.64k|        ssh_string_burn(privkey);
 1677|  8.64k|        SSH_STRING_FREE(privkey);
  ------------------
  |  |  893|  8.64k|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (893:14): [True: 8.64k, False: 0]
  |  |  |  Branch (893:69): [Folded, False: 8.64k]
  |  |  ------------------
  ------------------
 1678|  8.64k|        SSH_STRING_FREE(pubkey);
  ------------------
  |  |  893|  8.64k|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (893:14): [True: 8.64k, False: 0]
  |  |  |  Branch (893:69): [Folded, False: 8.64k]
  |  |  ------------------
  ------------------
 1679|  8.64k|        if (rc != SSH_OK) {
  ------------------
  |  |  316|  8.64k|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (1679:13): [True: 0, False: 8.64k]
  ------------------
 1680|      0|            SSH_LOG(SSH_LOG_TRACE, "Failed to build ed25519 key");
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 1681|      0|            goto fail;
 1682|      0|        }
 1683|  8.64k|        break;
 1684|  8.64k|    }
 1685|  8.64k|    case SSH_KEYTYPE_SK_ED25519: {
  ------------------
  |  Branch (1685:5): [True: 0, False: 8.64k]
  ------------------
 1686|      0|        ssh_string pubkey = NULL;
 1687|       |
 1688|      0|        if (ssh_fips_mode()) {
  ------------------
  |  |  115|      0|#define ssh_fips_mode() (FIPS_mode() != 0)
  |  |  ------------------
  |  |  |  Branch (115:25): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 1689|      0|            SSH_LOG(SSH_LOG_TRACE, "Ed25519 keys not supported in FIPS mode");
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 1690|      0|            goto fail;
 1691|      0|        }
 1692|       |
 1693|      0|        rc = ssh_buffer_unpack(buffer, "S", &pubkey);
  ------------------
  |  |   60|      0|    _ssh_buffer_unpack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |  451|      0|        (__VA_NARG_(__VA_ARGS__, __RSEQ_N()))
  |  |  |  |  ------------------
  |  |  |  |  |  |  453|      0|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  448|      0|#define VA_APPLY_VARIADIC_MACRO(macro, tuple) macro tuple
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  453|      0|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  461|      0|        _61,_62,_63,N,...) N
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                   _ssh_buffer_unpack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |   28|      0|#define SSH_BUFFER_PACK_END ((uint32_t) 0x4f65feb3)
  |  |  ------------------
  ------------------
 1694|      0|        if (rc != SSH_OK) {
  ------------------
  |  |  316|      0|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (1694:13): [True: 0, False: 0]
  ------------------
 1695|      0|            goto fail;
 1696|      0|        }
 1697|       |
 1698|      0|        rc = pki_buffer_unpack_sk_priv_data(buffer, key);
 1699|      0|        if (rc != SSH_OK) {
  ------------------
  |  |  316|      0|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (1699:13): [True: 0, False: 0]
  ------------------
 1700|      0|            SSH_STRING_FREE(pubkey);
  ------------------
  |  |  893|      0|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (893:14): [True: 0, False: 0]
  |  |  |  Branch (893:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1701|      0|            goto fail;
 1702|      0|        }
 1703|       |
 1704|      0|        rc = pki_pubkey_build_ed25519(key, pubkey);
 1705|      0|        SSH_STRING_FREE(pubkey);
  ------------------
  |  |  893|      0|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (893:14): [True: 0, False: 0]
  |  |  |  Branch (893:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1706|      0|        if (rc != SSH_OK) {
  ------------------
  |  |  316|      0|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (1706:13): [True: 0, False: 0]
  ------------------
 1707|      0|            goto fail;
 1708|      0|        }
 1709|      0|        break;
 1710|      0|    }
 1711|      0|    case SSH_KEYTYPE_RSA_CERT01:
  ------------------
  |  Branch (1711:5): [True: 0, False: 8.64k]
  ------------------
 1712|      0|    case SSH_KEYTYPE_ECDSA_P256_CERT01:
  ------------------
  |  Branch (1712:5): [True: 0, False: 8.64k]
  ------------------
 1713|      0|    case SSH_KEYTYPE_ECDSA_P384_CERT01:
  ------------------
  |  Branch (1713:5): [True: 0, False: 8.64k]
  ------------------
 1714|      0|    case SSH_KEYTYPE_ECDSA_P521_CERT01:
  ------------------
  |  Branch (1714:5): [True: 0, False: 8.64k]
  ------------------
 1715|      0|    case SSH_KEYTYPE_ED25519_CERT01:
  ------------------
  |  Branch (1715:5): [True: 0, False: 8.64k]
  ------------------
 1716|      0|    case SSH_KEYTYPE_SK_ECDSA_CERT01:
  ------------------
  |  Branch (1716:5): [True: 0, False: 8.64k]
  ------------------
 1717|      0|    case SSH_KEYTYPE_SK_ED25519_CERT01:
  ------------------
  |  Branch (1717:5): [True: 0, False: 8.64k]
  ------------------
 1718|      0|    case SSH_KEYTYPE_RSA1:
  ------------------
  |  Branch (1718:5): [True: 0, False: 8.64k]
  ------------------
 1719|      0|    case SSH_KEYTYPE_UNKNOWN:
  ------------------
  |  Branch (1719:5): [True: 0, False: 8.64k]
  ------------------
 1720|      0|    default:
  ------------------
  |  Branch (1720:5): [True: 0, False: 8.64k]
  ------------------
 1721|      0|        SSH_LOG(SSH_LOG_TRACE, "Unknown private key type (%d)", type);
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 1722|      0|        goto fail;
 1723|  8.64k|    }
 1724|       |
 1725|  8.64k|    *pkey = key;
 1726|  8.64k|    return SSH_OK;
  ------------------
  |  |  316|  8.64k|#define SSH_OK 0     /* No error */
  ------------------
 1727|      0|fail:
 1728|      0|    ssh_key_free(key);
 1729|       |
 1730|      0|    return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 1731|  8.64k|}
ssh_pki_import_pubkey_blob:
 2027|  17.2k|{
 2028|  17.2k|    ssh_buffer buffer = NULL;
 2029|  17.2k|    ssh_string type_s = NULL;
 2030|  17.2k|    enum ssh_keytypes_e type;
 2031|  17.2k|    int rc;
 2032|       |
 2033|  17.2k|    if (key_blob == NULL || pkey == NULL) {
  ------------------
  |  Branch (2033:9): [True: 0, False: 17.2k]
  |  Branch (2033:29): [True: 0, False: 17.2k]
  ------------------
 2034|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 2035|      0|    }
 2036|       |
 2037|  17.2k|    buffer = ssh_buffer_new();
 2038|  17.2k|    if (buffer == NULL) {
  ------------------
  |  Branch (2038:9): [True: 0, False: 17.2k]
  ------------------
 2039|      0|        SSH_LOG(SSH_LOG_TRACE, "Out of memory!");
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 2040|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 2041|      0|    }
 2042|       |
 2043|  17.2k|    rc = ssh_buffer_add_data(buffer,
 2044|  17.2k|                             ssh_string_data(key_blob),
 2045|  17.2k|                             (uint32_t)ssh_string_len(key_blob));
 2046|  17.2k|    if (rc < 0) {
  ------------------
  |  Branch (2046:9): [True: 0, False: 17.2k]
  ------------------
 2047|      0|        SSH_LOG(SSH_LOG_TRACE, "Out of memory!");
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 2048|      0|        goto fail;
 2049|      0|    }
 2050|       |
 2051|  17.2k|    type_s = ssh_buffer_get_ssh_string(buffer);
 2052|  17.2k|    if (type_s == NULL) {
  ------------------
  |  Branch (2052:9): [True: 0, False: 17.2k]
  ------------------
 2053|      0|        SSH_LOG(SSH_LOG_TRACE, "Out of memory!");
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 2054|      0|        goto fail;
 2055|      0|    }
 2056|       |
 2057|  17.2k|    type = ssh_key_type_from_name(ssh_string_get_char(type_s));
 2058|  17.2k|    if (type == SSH_KEYTYPE_UNKNOWN) {
  ------------------
  |  Branch (2058:9): [True: 0, False: 17.2k]
  ------------------
 2059|      0|        SSH_LOG(SSH_LOG_TRACE, "Unknown key type found!");
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 2060|      0|        goto fail;
 2061|      0|    }
 2062|  17.2k|    SSH_STRING_FREE(type_s);
  ------------------
  |  |  893|  17.2k|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (893:14): [True: 17.2k, False: 0]
  |  |  |  Branch (893:69): [Folded, False: 17.2k]
  |  |  ------------------
  ------------------
 2063|       |
 2064|  17.2k|    if (is_cert_type(type)) {
  ------------------
  |  |  146|  17.2k|    ((kt) == SSH_KEYTYPE_RSA_CERT01 ||\
  |  |  ------------------
  |  |  |  Branch (146:6): [True: 0, False: 17.2k]
  |  |  ------------------
  |  |  147|  17.2k|     (kt) == SSH_KEYTYPE_SK_ECDSA_CERT01 ||\
  |  |  ------------------
  |  |  |  Branch (147:6): [True: 0, False: 17.2k]
  |  |  ------------------
  |  |  148|  17.2k|     (kt) == SSH_KEYTYPE_SK_ED25519_CERT01 ||\
  |  |  ------------------
  |  |  |  Branch (148:6): [True: 0, False: 17.2k]
  |  |  ------------------
  |  |  149|  17.2k|    ((kt) >= SSH_KEYTYPE_ECDSA_P256_CERT01 &&\
  |  |  ------------------
  |  |  |  Branch (149:6): [True: 0, False: 17.2k]
  |  |  ------------------
  |  |  150|  17.2k|     (kt) <= SSH_KEYTYPE_ED25519_CERT01))
  |  |  ------------------
  |  |  |  Branch (150:6): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 2065|      0|        rc = pki_import_cert_buffer(buffer, type, pkey);
 2066|  17.2k|    } else {
 2067|  17.2k|        rc = pki_import_pubkey_buffer(buffer, type, pkey);
 2068|  17.2k|    }
 2069|       |
 2070|  17.2k|    SSH_BUFFER_FREE(buffer);
  ------------------
  |  |  934|  17.2k|    do { if ((x) != NULL) { ssh_buffer_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (934:14): [True: 17.2k, False: 0]
  |  |  |  Branch (934:69): [Folded, False: 17.2k]
  |  |  ------------------
  ------------------
 2071|       |
 2072|  17.2k|    return rc;
 2073|      0|fail:
 2074|      0|    SSH_BUFFER_FREE(buffer);
  ------------------
  |  |  934|      0|    do { if ((x) != NULL) { ssh_buffer_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (934:14): [True: 0, False: 0]
  |  |  |  Branch (934:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2075|      0|    SSH_STRING_FREE(type_s);
  ------------------
  |  |  893|      0|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (893:14): [True: 0, False: 0]
  |  |  |  Branch (893:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2076|       |
 2077|      0|    return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 2078|  17.2k|}
ssh_pki_export_privkey_to_pubkey:
 2570|  8.64k|{
 2571|  8.64k|    ssh_key pubkey = NULL;
 2572|       |
 2573|  8.64k|    if (privkey == NULL || !ssh_key_is_private(privkey)) {
  ------------------
  |  Branch (2573:9): [True: 0, False: 8.64k]
  |  Branch (2573:28): [True: 0, False: 8.64k]
  ------------------
 2574|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 2575|      0|    }
 2576|       |
 2577|  8.64k|    pubkey = pki_key_dup(privkey, 1);
 2578|  8.64k|    if (pubkey == NULL) {
  ------------------
  |  Branch (2578:9): [True: 0, False: 8.64k]
  ------------------
 2579|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 2580|      0|    }
 2581|       |
 2582|  8.64k|    *pkey = pubkey;
 2583|  8.64k|    return SSH_OK;
  ------------------
  |  |  316|  8.64k|#define SSH_OK 0     /* No error */
  ------------------
 2584|  8.64k|}
ssh_pki_export_pubkey_blob:
 2666|  34.5k|{
 2667|  34.5k|    ssh_string blob = NULL;
 2668|       |
 2669|  34.5k|    if (key == NULL) {
  ------------------
  |  Branch (2669:9): [True: 0, False: 34.5k]
  ------------------
 2670|      0|        return SSH_OK;
  ------------------
  |  |  316|      0|#define SSH_OK 0     /* No error */
  ------------------
 2671|      0|    }
 2672|       |
 2673|  34.5k|    blob = pki_key_to_blob(key, SSH_KEY_PUBLIC);
 2674|  34.5k|    if (blob == NULL) {
  ------------------
  |  Branch (2674:9): [True: 0, False: 34.5k]
  ------------------
 2675|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 2676|      0|    }
 2677|       |
 2678|  34.5k|    *pblob = blob;
 2679|  34.5k|    return SSH_OK;
  ------------------
  |  |  316|  34.5k|#define SSH_OK 0     /* No error */
  ------------------
 2680|  34.5k|}
ssh_pki_export_signature_blob:
 2877|  8.64k|{
 2878|  8.64k|    ssh_buffer buf = NULL;
 2879|  8.64k|    ssh_string str = NULL;
 2880|  8.64k|    int rc;
 2881|       |
 2882|  8.64k|    if (sig == NULL || sig_blob == NULL) {
  ------------------
  |  Branch (2882:9): [True: 0, False: 8.64k]
  |  Branch (2882:24): [True: 0, False: 8.64k]
  ------------------
 2883|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 2884|      0|    }
 2885|       |
 2886|  8.64k|    buf = ssh_buffer_new();
 2887|  8.64k|    if (buf == NULL) {
  ------------------
  |  Branch (2887:9): [True: 0, False: 8.64k]
  ------------------
 2888|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 2889|      0|    }
 2890|       |
 2891|  8.64k|    str = ssh_string_from_char(sig->type_c);
 2892|  8.64k|    if (str == NULL) {
  ------------------
  |  Branch (2892:9): [True: 0, False: 8.64k]
  ------------------
 2893|      0|        SSH_BUFFER_FREE(buf);
  ------------------
  |  |  934|      0|    do { if ((x) != NULL) { ssh_buffer_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (934:14): [True: 0, False: 0]
  |  |  |  Branch (934:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2894|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 2895|      0|    }
 2896|       |
 2897|  8.64k|    rc = ssh_buffer_add_ssh_string(buf, str);
 2898|  8.64k|    SSH_STRING_FREE(str);
  ------------------
  |  |  893|  8.64k|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (893:14): [True: 8.64k, False: 0]
  |  |  |  Branch (893:69): [Folded, False: 8.64k]
  |  |  ------------------
  ------------------
 2899|  8.64k|    if (rc < 0) {
  ------------------
  |  Branch (2899:9): [True: 0, False: 8.64k]
  ------------------
 2900|      0|        SSH_BUFFER_FREE(buf);
  ------------------
  |  |  934|      0|    do { if ((x) != NULL) { ssh_buffer_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (934:14): [True: 0, False: 0]
  |  |  |  Branch (934:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2901|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 2902|      0|    }
 2903|       |
 2904|  8.64k|    str = pki_signature_to_blob(sig);
 2905|  8.64k|    if (str == NULL) {
  ------------------
  |  Branch (2905:9): [True: 0, False: 8.64k]
  ------------------
 2906|      0|        SSH_BUFFER_FREE(buf);
  ------------------
  |  |  934|      0|    do { if ((x) != NULL) { ssh_buffer_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (934:14): [True: 0, False: 0]
  |  |  |  Branch (934:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2907|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 2908|      0|    }
 2909|       |
 2910|  8.64k|    rc = ssh_buffer_add_ssh_string(buf, str);
 2911|  8.64k|    SSH_STRING_FREE(str);
  ------------------
  |  |  893|  8.64k|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (893:14): [True: 8.64k, False: 0]
  |  |  |  Branch (893:69): [Folded, False: 8.64k]
  |  |  ------------------
  ------------------
 2912|  8.64k|    if (rc < 0) {
  ------------------
  |  Branch (2912:9): [True: 0, False: 8.64k]
  ------------------
 2913|      0|        SSH_BUFFER_FREE(buf);
  ------------------
  |  |  934|      0|    do { if ((x) != NULL) { ssh_buffer_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (934:14): [True: 0, False: 0]
  |  |  |  Branch (934:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2914|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 2915|      0|    }
 2916|       |
 2917|  8.64k|    if (is_sk_key_type(sig->type)) {
  ------------------
  |  |  153|  8.64k|    ((kt) == SSH_KEYTYPE_SK_ECDSA || (kt) == SSH_KEYTYPE_SK_ED25519 || \
  |  |  ------------------
  |  |  |  Branch (153:6): [True: 0, False: 8.64k]
  |  |  |  Branch (153:38): [True: 0, False: 8.64k]
  |  |  ------------------
  |  |  154|  8.64k|     (kt) == SSH_KEYTYPE_SK_ECDSA_CERT01 ||                            \
  |  |  ------------------
  |  |  |  Branch (154:6): [True: 0, False: 8.64k]
  |  |  ------------------
  |  |  155|  8.64k|     (kt) == SSH_KEYTYPE_SK_ED25519_CERT01)
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 0, False: 8.64k]
  |  |  ------------------
  ------------------
 2918|       |        /* Add flags and counter for SK keys */
 2919|      0|        rc = ssh_buffer_pack(buf, "bd", sig->sk_flags, sig->sk_counter);
  ------------------
  |  |   50|      0|    _ssh_buffer_pack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |  451|      0|        (__VA_NARG_(__VA_ARGS__, __RSEQ_N()))
  |  |  |  |  ------------------
  |  |  |  |  |  |  453|      0|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  448|      0|#define VA_APPLY_VARIADIC_MACRO(macro, tuple) macro tuple
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  453|      0|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  461|      0|        _61,_62,_63,N,...) N
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                   _ssh_buffer_pack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |   28|      0|#define SSH_BUFFER_PACK_END ((uint32_t) 0x4f65feb3)
  |  |  ------------------
  ------------------
 2920|      0|        if (rc < 0) {
  ------------------
  |  Branch (2920:13): [True: 0, False: 0]
  ------------------
 2921|      0|            SSH_BUFFER_FREE(buf);
  ------------------
  |  |  934|      0|    do { if ((x) != NULL) { ssh_buffer_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (934:14): [True: 0, False: 0]
  |  |  |  Branch (934:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2922|      0|            return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 2923|      0|        }
 2924|      0|    }
 2925|       |
 2926|  8.64k|    str = ssh_string_new(ssh_buffer_get_len(buf));
 2927|  8.64k|    if (str == NULL) {
  ------------------
  |  Branch (2927:9): [True: 0, False: 8.64k]
  ------------------
 2928|      0|        SSH_BUFFER_FREE(buf);
  ------------------
  |  |  934|      0|    do { if ((x) != NULL) { ssh_buffer_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (934:14): [True: 0, False: 0]
  |  |  |  Branch (934:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2929|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 2930|      0|    }
 2931|       |
 2932|  8.64k|    rc = ssh_string_fill(str, ssh_buffer_get(buf), ssh_buffer_get_len(buf));
 2933|  8.64k|    SSH_BUFFER_FREE(buf);
  ------------------
  |  |  934|  8.64k|    do { if ((x) != NULL) { ssh_buffer_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (934:14): [True: 8.64k, False: 0]
  |  |  |  Branch (934:69): [Folded, False: 8.64k]
  |  |  ------------------
  ------------------
 2934|  8.64k|    if (rc < 0) {
  ------------------
  |  Branch (2934:9): [True: 0, False: 8.64k]
  ------------------
 2935|      0|        SSH_STRING_FREE(str);
  ------------------
  |  |  893|      0|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (893:14): [True: 0, False: 0]
  |  |  |  Branch (893:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2936|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 2937|      0|    }
 2938|       |
 2939|  8.64k|    *sig_blob = str;
 2940|       |
 2941|  8.64k|    return SSH_OK;
  ------------------
  |  |  316|  8.64k|#define SSH_OK 0     /* No error */
  ------------------
 2942|  8.64k|}
ssh_pki_import_signature_blob:
 2947|  8.64k|{
 2948|  8.64k|    ssh_signature sig = NULL;
 2949|  8.64k|    enum ssh_keytypes_e type;
 2950|  8.64k|    enum ssh_digest_e hash_type;
 2951|  8.64k|    ssh_string algorithm = NULL, blob = NULL;
 2952|  8.64k|    ssh_buffer buf = NULL;
 2953|  8.64k|    const char *alg = NULL;
 2954|  8.64k|    uint8_t flags = 0;
 2955|  8.64k|    uint32_t counter = 0;
 2956|  8.64k|    int rc;
 2957|       |
 2958|  8.64k|    if (sig_blob == NULL || psig == NULL) {
  ------------------
  |  Branch (2958:9): [True: 0, False: 8.64k]
  |  Branch (2958:29): [True: 0, False: 8.64k]
  ------------------
 2959|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 2960|      0|    }
 2961|       |
 2962|  8.64k|    buf = ssh_buffer_new();
 2963|  8.64k|    if (buf == NULL) {
  ------------------
  |  Branch (2963:9): [True: 0, False: 8.64k]
  ------------------
 2964|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 2965|      0|    }
 2966|       |
 2967|  8.64k|    rc = ssh_buffer_add_data(buf,
 2968|  8.64k|                             ssh_string_data(sig_blob),
 2969|  8.64k|                             (uint32_t)ssh_string_len(sig_blob));
 2970|  8.64k|    if (rc < 0) {
  ------------------
  |  Branch (2970:9): [True: 0, False: 8.64k]
  ------------------
 2971|      0|        SSH_BUFFER_FREE(buf);
  ------------------
  |  |  934|      0|    do { if ((x) != NULL) { ssh_buffer_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (934:14): [True: 0, False: 0]
  |  |  |  Branch (934:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2972|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 2973|      0|    }
 2974|       |
 2975|  8.64k|    algorithm = ssh_buffer_get_ssh_string(buf);
 2976|  8.64k|    if (algorithm == NULL) {
  ------------------
  |  Branch (2976:9): [True: 0, False: 8.64k]
  ------------------
 2977|      0|        SSH_BUFFER_FREE(buf);
  ------------------
  |  |  934|      0|    do { if ((x) != NULL) { ssh_buffer_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (934:14): [True: 0, False: 0]
  |  |  |  Branch (934:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2978|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 2979|      0|    }
 2980|       |
 2981|  8.64k|    alg = ssh_string_get_char(algorithm);
 2982|  8.64k|    rc = ssh_key_type_and_hash_from_signature_name(alg, &type, &hash_type);
 2983|  8.64k|    if (rc != SSH_OK) {
  ------------------
  |  |  316|  8.64k|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (2983:9): [True: 0, False: 8.64k]
  ------------------
 2984|      0|        SSH_BUFFER_FREE(buf);
  ------------------
  |  |  934|      0|    do { if ((x) != NULL) { ssh_buffer_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (934:14): [True: 0, False: 0]
  |  |  |  Branch (934:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2985|      0|        SSH_STRING_FREE(algorithm);
  ------------------
  |  |  893|      0|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (893:14): [True: 0, False: 0]
  |  |  |  Branch (893:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2986|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 2987|      0|    }
 2988|  8.64k|    SSH_STRING_FREE(algorithm);
  ------------------
  |  |  893|  8.64k|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (893:14): [True: 8.64k, False: 0]
  |  |  |  Branch (893:69): [Folded, False: 8.64k]
  |  |  ------------------
  ------------------
 2989|       |
 2990|  8.64k|    blob = ssh_buffer_get_ssh_string(buf);
 2991|  8.64k|    if (blob == NULL) {
  ------------------
  |  Branch (2991:9): [True: 0, False: 8.64k]
  ------------------
 2992|      0|        SSH_BUFFER_FREE(buf);
  ------------------
  |  |  934|      0|    do { if ((x) != NULL) { ssh_buffer_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (934:14): [True: 0, False: 0]
  |  |  |  Branch (934:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2993|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 2994|      0|    }
 2995|       |
 2996|  8.64k|    if (type == SSH_KEYTYPE_SK_ECDSA ||
  ------------------
  |  Branch (2996:9): [True: 0, False: 8.64k]
  ------------------
 2997|  8.64k|        type == SSH_KEYTYPE_SK_ED25519) {
  ------------------
  |  Branch (2997:9): [True: 0, False: 8.64k]
  ------------------
 2998|      0|        rc = ssh_buffer_unpack(buf, "bd", &flags, &counter);
  ------------------
  |  |   60|      0|    _ssh_buffer_unpack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |  451|      0|        (__VA_NARG_(__VA_ARGS__, __RSEQ_N()))
  |  |  |  |  ------------------
  |  |  |  |  |  |  453|      0|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  448|      0|#define VA_APPLY_VARIADIC_MACRO(macro, tuple) macro tuple
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  453|      0|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  461|      0|        _61,_62,_63,N,...) N
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                   _ssh_buffer_unpack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |   28|      0|#define SSH_BUFFER_PACK_END ((uint32_t) 0x4f65feb3)
  |  |  ------------------
  ------------------
 2999|      0|        if (rc < 0) {
  ------------------
  |  Branch (2999:13): [True: 0, False: 0]
  ------------------
 3000|      0|            SSH_BUFFER_FREE(buf);
  ------------------
  |  |  934|      0|    do { if ((x) != NULL) { ssh_buffer_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (934:14): [True: 0, False: 0]
  |  |  |  Branch (934:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
 3001|      0|            SSH_STRING_FREE(blob);
  ------------------
  |  |  893|      0|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (893:14): [True: 0, False: 0]
  |  |  |  Branch (893:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
 3002|      0|            return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 3003|      0|        }
 3004|      0|    }
 3005|  8.64k|    SSH_BUFFER_FREE(buf);
  ------------------
  |  |  934|  8.64k|    do { if ((x) != NULL) { ssh_buffer_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (934:14): [True: 8.64k, False: 0]
  |  |  |  Branch (934:69): [Folded, False: 8.64k]
  |  |  ------------------
  ------------------
 3006|       |
 3007|  8.64k|    sig = pki_signature_from_blob(pubkey, blob, type, hash_type);
 3008|  8.64k|    SSH_STRING_FREE(blob);
  ------------------
  |  |  893|  8.64k|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (893:14): [True: 8.64k, False: 0]
  |  |  |  Branch (893:69): [Folded, False: 8.64k]
  |  |  ------------------
  ------------------
 3009|  8.64k|    if (sig == NULL) {
  ------------------
  |  Branch (3009:9): [True: 0, False: 8.64k]
  ------------------
 3010|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 3011|      0|    }
 3012|       |
 3013|       |    /* Set SK specific values */
 3014|  8.64k|    sig->sk_flags = flags;
 3015|  8.64k|    sig->sk_counter = counter;
 3016|       |
 3017|  8.64k|    *psig = sig;
 3018|  8.64k|    return SSH_OK;
  ------------------
  |  |  316|  8.64k|#define SSH_OK 0     /* No error */
  ------------------
 3019|  8.64k|}
pki_key_check_hash_compatible:
 3034|  34.5k|{
 3035|  34.5k|    if (key == NULL) {
  ------------------
  |  Branch (3035:9): [True: 0, False: 34.5k]
  ------------------
 3036|      0|        SSH_LOG(SSH_LOG_TRACE, "Null pointer provided as key to "
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 3037|      0|                               "pki_key_check_hash_compatible()");
 3038|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 3039|      0|    }
 3040|       |
 3041|  34.5k|    switch(key->type) {
  ------------------
  |  Branch (3041:12): [True: 34.5k, False: 0]
  ------------------
 3042|      0|    case SSH_KEYTYPE_RSA_CERT01:
  ------------------
  |  Branch (3042:5): [True: 0, False: 34.5k]
  ------------------
 3043|      0|    case SSH_KEYTYPE_RSA:
  ------------------
  |  Branch (3043:5): [True: 0, False: 34.5k]
  ------------------
 3044|      0|        if (hash_type == SSH_DIGEST_SHA1) {
  ------------------
  |  Branch (3044:13): [True: 0, False: 0]
  ------------------
 3045|      0|            if (ssh_fips_mode()) {
  ------------------
  |  |  115|      0|#define ssh_fips_mode() (FIPS_mode() != 0)
  |  |  ------------------
  |  |  |  Branch (115:25): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 3046|      0|                SSH_LOG(SSH_LOG_TRACE, "SHA1 is not allowed in FIPS mode");
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 3047|      0|                return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 3048|      0|            } else {
 3049|      0|                return SSH_OK;
  ------------------
  |  |  316|      0|#define SSH_OK 0     /* No error */
  ------------------
 3050|      0|            }
 3051|      0|        }
 3052|       |
 3053|      0|        if (hash_type == SSH_DIGEST_SHA256 ||
  ------------------
  |  Branch (3053:13): [True: 0, False: 0]
  ------------------
 3054|      0|            hash_type == SSH_DIGEST_SHA512)
  ------------------
  |  Branch (3054:13): [True: 0, False: 0]
  ------------------
 3055|      0|        {
 3056|      0|            return SSH_OK;
  ------------------
  |  |  316|      0|#define SSH_OK 0     /* No error */
  ------------------
 3057|      0|        }
 3058|      0|        break;
 3059|      0|    case SSH_KEYTYPE_ECDSA_P256_CERT01:
  ------------------
  |  Branch (3059:5): [True: 0, False: 34.5k]
  ------------------
 3060|      0|    case SSH_KEYTYPE_ECDSA_P256:
  ------------------
  |  Branch (3060:5): [True: 0, False: 34.5k]
  ------------------
 3061|      0|    case SSH_KEYTYPE_SK_ECDSA_CERT01:
  ------------------
  |  Branch (3061:5): [True: 0, False: 34.5k]
  ------------------
 3062|      0|    case SSH_KEYTYPE_SK_ECDSA:
  ------------------
  |  Branch (3062:5): [True: 0, False: 34.5k]
  ------------------
 3063|      0|        if (hash_type == SSH_DIGEST_SHA256) {
  ------------------
  |  Branch (3063:13): [True: 0, False: 0]
  ------------------
 3064|      0|            return SSH_OK;
  ------------------
  |  |  316|      0|#define SSH_OK 0     /* No error */
  ------------------
 3065|      0|        }
 3066|      0|        break;
 3067|      0|    case SSH_KEYTYPE_ECDSA_P384_CERT01:
  ------------------
  |  Branch (3067:5): [True: 0, False: 34.5k]
  ------------------
 3068|      0|    case SSH_KEYTYPE_ECDSA_P384:
  ------------------
  |  Branch (3068:5): [True: 0, False: 34.5k]
  ------------------
 3069|      0|        if (hash_type == SSH_DIGEST_SHA384) {
  ------------------
  |  Branch (3069:13): [True: 0, False: 0]
  ------------------
 3070|      0|            return SSH_OK;
  ------------------
  |  |  316|      0|#define SSH_OK 0     /* No error */
  ------------------
 3071|      0|        }
 3072|      0|        break;
 3073|      0|    case SSH_KEYTYPE_ECDSA_P521_CERT01:
  ------------------
  |  Branch (3073:5): [True: 0, False: 34.5k]
  ------------------
 3074|      0|    case SSH_KEYTYPE_ECDSA_P521:
  ------------------
  |  Branch (3074:5): [True: 0, False: 34.5k]
  ------------------
 3075|      0|        if (hash_type == SSH_DIGEST_SHA512) {
  ------------------
  |  Branch (3075:13): [True: 0, False: 0]
  ------------------
 3076|      0|            return SSH_OK;
  ------------------
  |  |  316|      0|#define SSH_OK 0     /* No error */
  ------------------
 3077|      0|        }
 3078|      0|        break;
 3079|      0|    case SSH_KEYTYPE_ED25519_CERT01:
  ------------------
  |  Branch (3079:5): [True: 0, False: 34.5k]
  ------------------
 3080|  34.5k|    case SSH_KEYTYPE_ED25519:
  ------------------
  |  Branch (3080:5): [True: 34.5k, False: 0]
  ------------------
 3081|  34.5k|    case SSH_KEYTYPE_SK_ED25519_CERT01:
  ------------------
  |  Branch (3081:5): [True: 0, False: 34.5k]
  ------------------
 3082|  34.5k|    case SSH_KEYTYPE_SK_ED25519:
  ------------------
  |  Branch (3082:5): [True: 0, False: 34.5k]
  ------------------
 3083|  34.5k|        if (hash_type == SSH_DIGEST_AUTO) {
  ------------------
  |  Branch (3083:13): [True: 34.5k, False: 0]
  ------------------
 3084|  34.5k|            return SSH_OK;
  ------------------
  |  |  316|  34.5k|#define SSH_OK 0     /* No error */
  ------------------
 3085|  34.5k|        }
 3086|      0|        break;
 3087|      0|    case SSH_KEYTYPE_DSS:   /* deprecated */
  ------------------
  |  Branch (3087:5): [True: 0, False: 34.5k]
  ------------------
 3088|      0|    case SSH_KEYTYPE_DSS_CERT01:    /* deprecated */
  ------------------
  |  Branch (3088:5): [True: 0, False: 34.5k]
  ------------------
 3089|      0|    case SSH_KEYTYPE_RSA1:
  ------------------
  |  Branch (3089:5): [True: 0, False: 34.5k]
  ------------------
 3090|      0|    case SSH_KEYTYPE_ECDSA:
  ------------------
  |  Branch (3090:5): [True: 0, False: 34.5k]
  ------------------
 3091|      0|    case SSH_KEYTYPE_UNKNOWN:
  ------------------
  |  Branch (3091:5): [True: 0, False: 34.5k]
  ------------------
 3092|      0|        SSH_LOG(SSH_LOG_TRACE, "Unknown key type %d", key->type);
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 3093|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 3094|  34.5k|    }
 3095|       |
 3096|      0|    SSH_LOG(SSH_LOG_TRACE, "Key type %d incompatible with hash type  %d",
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 3097|      0|            key->type, hash_type);
 3098|       |
 3099|      0|    return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 3100|  34.5k|}
ssh_pki_signature_verify:
 3190|  8.64k|{
 3191|  8.64k|    int rc;
 3192|  8.64k|    bool allowed;
 3193|  8.64k|    enum ssh_keytypes_e key_type;
 3194|       |
 3195|  8.64k|    if (session == NULL || sig == NULL || key == NULL || input == NULL) {
  ------------------
  |  Branch (3195:9): [True: 0, False: 8.64k]
  |  Branch (3195:28): [True: 0, False: 8.64k]
  |  Branch (3195:43): [True: 0, False: 8.64k]
  |  Branch (3195:58): [True: 0, False: 8.64k]
  ------------------
 3196|      0|        SSH_LOG(SSH_LOG_TRACE, "Bad parameter(s) provided to %s()", __func__);
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 3197|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 3198|      0|    }
 3199|  8.64k|    key_type = ssh_key_type_plain(key->type);
 3200|       |
 3201|  8.64k|    SSH_LOG(SSH_LOG_FUNCTIONS,
  ------------------
  |  |  281|  8.64k|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 3202|  8.64k|            "Going to verify a %s type signature",
 3203|  8.64k|            sig->type_c);
 3204|       |
 3205|  8.64k|    if (key_type != sig->type) {
  ------------------
  |  Branch (3205:9): [True: 0, False: 8.64k]
  ------------------
 3206|      0|        SSH_LOG(SSH_LOG_TRACE,
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 3207|      0|                "Can not verify %s signature with %s key",
 3208|      0|                sig->type_c, key->type_c);
 3209|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 3210|      0|    }
 3211|       |
 3212|  8.64k|    allowed = ssh_key_size_allowed(session, key);
 3213|  8.64k|    if (!allowed) {
  ------------------
  |  Branch (3213:9): [True: 0, False: 8.64k]
  ------------------
 3214|      0|        ssh_set_error(session,
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
 3215|      0|                      SSH_FATAL,
 3216|      0|                      "The '%s' key of size %d is not allowed by RSA_MIN_SIZE",
 3217|      0|                      key->type_c,
 3218|      0|                      ssh_key_size(key));
 3219|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 3220|      0|    }
 3221|       |
 3222|       |    /* Check if public key and hash type are compatible */
 3223|  8.64k|    rc = pki_key_check_hash_compatible(key, sig->hash_type);
 3224|  8.64k|    if (rc != SSH_OK) {
  ------------------
  |  |  316|  8.64k|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (3224:9): [True: 0, False: 8.64k]
  ------------------
 3225|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 3226|      0|    }
 3227|       |
 3228|  8.64k|    if (is_sk_key_type(key->type)) {
  ------------------
  |  |  153|  8.64k|    ((kt) == SSH_KEYTYPE_SK_ECDSA || (kt) == SSH_KEYTYPE_SK_ED25519 || \
  |  |  ------------------
  |  |  |  Branch (153:6): [True: 0, False: 8.64k]
  |  |  |  Branch (153:38): [True: 0, False: 8.64k]
  |  |  ------------------
  |  |  154|  8.64k|     (kt) == SSH_KEYTYPE_SK_ECDSA_CERT01 ||                            \
  |  |  ------------------
  |  |  |  Branch (154:6): [True: 0, False: 8.64k]
  |  |  ------------------
  |  |  155|  8.64k|     (kt) == SSH_KEYTYPE_SK_ED25519_CERT01)
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 0, False: 8.64k]
  |  |  ------------------
  ------------------
 3229|      0|        ssh_buffer sk_buffer = NULL;
 3230|       |
 3231|      0|        rc = pki_sk_signature_buffer_prepare(key,
 3232|      0|                                             sig,
 3233|      0|                                             input,
 3234|      0|                                             input_len,
 3235|      0|                                             &sk_buffer);
 3236|      0|        if (rc != SSH_OK) {
  ------------------
  |  |  316|      0|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (3236:13): [True: 0, False: 0]
  ------------------
 3237|      0|            return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 3238|      0|        }
 3239|       |
 3240|      0|        rc = pki_verify_data_signature(sig,
 3241|      0|                                       key,
 3242|      0|                                       ssh_buffer_get(sk_buffer),
 3243|      0|                                       ssh_buffer_get_len(sk_buffer));
 3244|      0|        SSH_BUFFER_FREE(sk_buffer);
  ------------------
  |  |  934|      0|    do { if ((x) != NULL) { ssh_buffer_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (934:14): [True: 0, False: 0]
  |  |  |  Branch (934:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
 3245|      0|        return rc;
 3246|      0|    }
 3247|       |
 3248|  8.64k|    return pki_verify_data_signature(sig, key, input, input_len);
 3249|  8.64k|}
pki_do_sign:
 3255|  8.64k|{
 3256|  8.64k|    int rc;
 3257|       |
 3258|  8.64k|    if (privkey == NULL || input == NULL) {
  ------------------
  |  Branch (3258:9): [True: 0, False: 8.64k]
  |  Branch (3258:28): [True: 0, False: 8.64k]
  ------------------
 3259|      0|        SSH_LOG(SSH_LOG_TRACE, "Bad parameter provided to "
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 3260|      0|                               "pki_do_sign()");
 3261|      0|        return NULL;
 3262|      0|    }
 3263|       |
 3264|       |    /* Check if public key and hash type are compatible */
 3265|  8.64k|    rc = pki_key_check_hash_compatible(privkey, hash_type);
 3266|  8.64k|    if (rc != SSH_OK) {
  ------------------
  |  |  316|  8.64k|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (3266:9): [True: 0, False: 8.64k]
  ------------------
 3267|      0|        return NULL;
 3268|      0|    }
 3269|       |
 3270|  8.64k|    return pki_sign_data(privkey, hash_type, input, input_len);
 3271|  8.64k|}
ssh_srv_pki_do_sign_sessionid:
 4027|  8.64k|{
 4028|  8.64k|    struct ssh_crypto_struct *crypto = NULL;
 4029|  8.64k|    bool allowed;
 4030|  8.64k|    ssh_signature sig = NULL;
 4031|  8.64k|    ssh_string sig_blob = NULL;
 4032|       |
 4033|  8.64k|    ssh_buffer sign_input = NULL;
 4034|       |
 4035|  8.64k|    int rc;
 4036|       |
 4037|  8.64k|    if (session == NULL || privkey == NULL || !ssh_key_is_private(privkey)) {
  ------------------
  |  Branch (4037:9): [True: 0, False: 8.64k]
  |  Branch (4037:28): [True: 0, False: 8.64k]
  |  Branch (4037:47): [True: 0, False: 8.64k]
  ------------------
 4038|      0|        return NULL;
 4039|      0|    }
 4040|       |
 4041|  8.64k|    allowed = ssh_key_size_allowed(session, privkey);
 4042|  8.64k|    if (!allowed) {
  ------------------
  |  Branch (4042:9): [True: 0, False: 8.64k]
  ------------------
 4043|      0|        ssh_set_error(session, SSH_FATAL, "The hostkey size too small");
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
 4044|      0|        return NULL;
 4045|      0|    }
 4046|       |
 4047|  8.64k|    crypto = session->next_crypto ? session->next_crypto :
  ------------------
  |  Branch (4047:14): [True: 8.64k, False: 0]
  ------------------
 4048|  8.64k|                                    session->current_crypto;
 4049|       |
 4050|  8.64k|    if (crypto->secret_hash == NULL){
  ------------------
  |  Branch (4050:9): [True: 0, False: 8.64k]
  ------------------
 4051|      0|        ssh_set_error(session, SSH_FATAL, "Missing secret_hash");
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
 4052|      0|        return NULL;
 4053|      0|    }
 4054|       |
 4055|       |    /* Fill the input */
 4056|  8.64k|    sign_input = ssh_buffer_new();
 4057|  8.64k|    if (sign_input == NULL) {
  ------------------
  |  Branch (4057:9): [True: 0, False: 8.64k]
  ------------------
 4058|      0|        goto end;
 4059|      0|    }
 4060|  8.64k|    ssh_buffer_set_secure(sign_input);
 4061|       |
 4062|  8.64k|    rc = ssh_buffer_pack(sign_input,
  ------------------
  |  |   50|  8.64k|    _ssh_buffer_pack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |  451|  8.64k|        (__VA_NARG_(__VA_ARGS__, __RSEQ_N()))
  |  |  |  |  ------------------
  |  |  |  |  |  |  453|  8.64k|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  448|  8.64k|#define VA_APPLY_VARIADIC_MACRO(macro, tuple) macro tuple
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  453|  8.64k|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  461|  8.64k|        _61,_62,_63,N,...) N
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                   _ssh_buffer_pack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |   28|  8.64k|#define SSH_BUFFER_PACK_END ((uint32_t) 0x4f65feb3)
  |  |  ------------------
  ------------------
 4063|  8.64k|                         "P",
 4064|  8.64k|                         crypto->digest_len,
 4065|  8.64k|                         crypto->secret_hash);
 4066|  8.64k|    if (rc != SSH_OK) {
  ------------------
  |  |  316|  8.64k|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (4066:9): [True: 0, False: 8.64k]
  ------------------
 4067|      0|        goto end;
 4068|      0|    }
 4069|       |
 4070|       |    /* Generate the signature */
 4071|  8.64k|    sig = pki_do_sign(privkey,
 4072|  8.64k|                      ssh_buffer_get(sign_input),
 4073|  8.64k|                      ssh_buffer_get_len(sign_input),
 4074|  8.64k|                      digest);
 4075|  8.64k|    if (sig == NULL) {
  ------------------
  |  Branch (4075:9): [True: 0, False: 8.64k]
  ------------------
 4076|      0|        goto end;
 4077|      0|    }
 4078|       |
 4079|       |    /* Convert the signature to blob */
 4080|  8.64k|    rc = ssh_pki_export_signature_blob(sig, &sig_blob);
 4081|  8.64k|    if (rc < 0) {
  ------------------
  |  Branch (4081:9): [True: 0, False: 8.64k]
  ------------------
 4082|      0|        sig_blob = NULL;
 4083|      0|    }
 4084|       |
 4085|  8.64k|end:
 4086|  8.64k|    ssh_signature_free(sig);
 4087|  8.64k|    SSH_BUFFER_FREE(sign_input);
  ------------------
  |  |  934|  8.64k|    do { if ((x) != NULL) { ssh_buffer_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (934:14): [True: 8.64k, False: 0]
  |  |  |  Branch (934:69): [Folded, False: 8.64k]
  |  |  ------------------
  ------------------
 4088|       |
 4089|  8.64k|    return sig_blob;
 4090|  8.64k|}
pki.c:pki_import_pubkey_buffer:
 1736|  17.2k|{
 1737|  17.2k|    ssh_key key = NULL;
 1738|  17.2k|    int rc;
 1739|       |
 1740|  17.2k|    key = ssh_key_new();
 1741|  17.2k|    if (key == NULL) {
  ------------------
  |  Branch (1741:9): [True: 0, False: 17.2k]
  ------------------
 1742|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 1743|      0|    }
 1744|       |
 1745|  17.2k|    key->type = type;
 1746|  17.2k|    key->type_c = ssh_key_type_to_char(type);
 1747|  17.2k|    key->flags = SSH_KEY_FLAG_PUBLIC;
  ------------------
  |  |   54|  17.2k|#define SSH_KEY_FLAG_PUBLIC  0x0001
  ------------------
 1748|       |
 1749|  17.2k|    switch (type) {
 1750|      0|        case SSH_KEYTYPE_RSA:
  ------------------
  |  Branch (1750:9): [True: 0, False: 17.2k]
  ------------------
 1751|      0|            {
 1752|      0|                ssh_string e = NULL;
 1753|      0|                ssh_string n = NULL;
 1754|       |
 1755|      0|                rc = ssh_buffer_unpack(buffer, "SS", &e, &n);
  ------------------
  |  |   60|      0|    _ssh_buffer_unpack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |  451|      0|        (__VA_NARG_(__VA_ARGS__, __RSEQ_N()))
  |  |  |  |  ------------------
  |  |  |  |  |  |  453|      0|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  448|      0|#define VA_APPLY_VARIADIC_MACRO(macro, tuple) macro tuple
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  453|      0|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  461|      0|        _61,_62,_63,N,...) N
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                   _ssh_buffer_unpack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |   28|      0|#define SSH_BUFFER_PACK_END ((uint32_t) 0x4f65feb3)
  |  |  ------------------
  ------------------
 1756|      0|                if (rc != SSH_OK) {
  ------------------
  |  |  316|      0|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (1756:21): [True: 0, False: 0]
  ------------------
 1757|      0|                    SSH_LOG(SSH_LOG_TRACE, "Unpack error");
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 1758|      0|                    goto fail;
 1759|      0|                }
 1760|       |
 1761|      0|                rc = pki_pubkey_build_rsa(key, e, n);
 1762|       |#ifdef DEBUG_CRYPTO
 1763|       |                ssh_log_hexdump("e", ssh_string_data(e), ssh_string_len(e));
 1764|       |                ssh_log_hexdump("n", ssh_string_data(n), ssh_string_len(n));
 1765|       |#endif /* DEBUG_CRYPTO */
 1766|      0|                ssh_string_burn(e);
 1767|      0|                SSH_STRING_FREE(e);
  ------------------
  |  |  893|      0|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (893:14): [True: 0, False: 0]
  |  |  |  Branch (893:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1768|      0|                ssh_string_burn(n);
 1769|      0|                SSH_STRING_FREE(n);
  ------------------
  |  |  893|      0|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (893:14): [True: 0, False: 0]
  |  |  |  Branch (893:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1770|      0|                if (rc == SSH_ERROR) {
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  |  Branch (1770:21): [True: 0, False: 0]
  ------------------
 1771|      0|                    SSH_LOG(SSH_LOG_TRACE, "Failed to build RSA public key");
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 1772|      0|                    goto fail;
 1773|      0|                }
 1774|      0|            }
 1775|      0|            break;
 1776|      0|#ifdef HAVE_ECC
 1777|      0|        case SSH_KEYTYPE_ECDSA: /* deprecated */
  ------------------
  |  Branch (1777:9): [True: 0, False: 17.2k]
  ------------------
 1778|      0|        case SSH_KEYTYPE_ECDSA_P256:
  ------------------
  |  Branch (1778:9): [True: 0, False: 17.2k]
  ------------------
 1779|      0|        case SSH_KEYTYPE_ECDSA_P384:
  ------------------
  |  Branch (1779:9): [True: 0, False: 17.2k]
  ------------------
 1780|      0|        case SSH_KEYTYPE_ECDSA_P521:
  ------------------
  |  Branch (1780:9): [True: 0, False: 17.2k]
  ------------------
 1781|      0|        case SSH_KEYTYPE_SK_ECDSA:
  ------------------
  |  Branch (1781:9): [True: 0, False: 17.2k]
  ------------------
 1782|      0|            {
 1783|      0|                ssh_string e = NULL;
 1784|      0|                ssh_string i = NULL;
 1785|      0|                int nid;
 1786|       |
 1787|      0|                rc = ssh_buffer_unpack(buffer, "SS", &i, &e);
  ------------------
  |  |   60|      0|    _ssh_buffer_unpack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |  451|      0|        (__VA_NARG_(__VA_ARGS__, __RSEQ_N()))
  |  |  |  |  ------------------
  |  |  |  |  |  |  453|      0|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  448|      0|#define VA_APPLY_VARIADIC_MACRO(macro, tuple) macro tuple
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  453|      0|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  461|      0|        _61,_62,_63,N,...) N
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                   _ssh_buffer_unpack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |   28|      0|#define SSH_BUFFER_PACK_END ((uint32_t) 0x4f65feb3)
  |  |  ------------------
  ------------------
 1788|      0|                if (rc != SSH_OK) {
  ------------------
  |  |  316|      0|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (1788:21): [True: 0, False: 0]
  ------------------
 1789|      0|                    SSH_LOG(SSH_LOG_TRACE, "Unpack error");
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 1790|      0|                    goto fail;
 1791|      0|                }
 1792|       |
 1793|      0|                nid = pki_key_ecdsa_nid_from_name(ssh_string_get_char(i));
 1794|      0|                SSH_STRING_FREE(i);
  ------------------
  |  |  893|      0|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (893:14): [True: 0, False: 0]
  |  |  |  Branch (893:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1795|      0|                if (nid == -1) {
  ------------------
  |  Branch (1795:21): [True: 0, False: 0]
  ------------------
 1796|      0|                    ssh_string_burn(e);
 1797|      0|                    SSH_STRING_FREE(e);
  ------------------
  |  |  893|      0|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (893:14): [True: 0, False: 0]
  |  |  |  Branch (893:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1798|      0|                    goto fail;
 1799|      0|                }
 1800|       |
 1801|      0|                rc = pki_pubkey_build_ecdsa(key, nid, e);
 1802|      0|                ssh_string_burn(e);
 1803|      0|                SSH_STRING_FREE(e);
  ------------------
  |  |  893|      0|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (893:14): [True: 0, False: 0]
  |  |  |  Branch (893:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1804|      0|                if (rc < 0) {
  ------------------
  |  Branch (1804:21): [True: 0, False: 0]
  ------------------
 1805|      0|                    SSH_LOG(SSH_LOG_TRACE, "Failed to build ECDSA public key");
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 1806|      0|                    goto fail;
 1807|      0|                }
 1808|       |
 1809|       |                /* Unpack SK specific parameters */
 1810|      0|                if (type == SSH_KEYTYPE_SK_ECDSA) {
  ------------------
  |  Branch (1810:21): [True: 0, False: 0]
  ------------------
 1811|      0|                    ssh_string application = ssh_buffer_get_ssh_string(buffer);
 1812|      0|                    if (application == NULL) {
  ------------------
  |  Branch (1812:25): [True: 0, False: 0]
  ------------------
 1813|      0|                        SSH_LOG(SSH_LOG_TRACE, "SK Unpack error");
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 1814|      0|                        goto fail;
 1815|      0|                    }
 1816|      0|                    key->sk_application = application;
 1817|      0|                    key->type_c = ssh_key_type_to_char(key->type);
 1818|      0|                }
 1819|      0|            }
 1820|      0|            break;
 1821|      0|#endif /* HAVE_ECC */
 1822|  17.2k|        case SSH_KEYTYPE_ED25519:
  ------------------
  |  Branch (1822:9): [True: 17.2k, False: 0]
  ------------------
 1823|  17.2k|        case SSH_KEYTYPE_SK_ED25519:
  ------------------
  |  Branch (1823:9): [True: 0, False: 17.2k]
  ------------------
 1824|  17.2k|        {
 1825|  17.2k|            ssh_string pubkey = ssh_buffer_get_ssh_string(buffer);
 1826|       |
 1827|  17.2k|            if (ssh_string_len(pubkey) != ED25519_KEY_LEN) {
  ------------------
  |  |   44|  17.2k|#define ED25519_KEY_LEN 32
  ------------------
  |  Branch (1827:17): [True: 0, False: 17.2k]
  ------------------
 1828|      0|                SSH_LOG(SSH_LOG_TRACE, "Invalid public key length");
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 1829|      0|                ssh_string_burn(pubkey);
 1830|      0|                SSH_STRING_FREE(pubkey);
  ------------------
  |  |  893|      0|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (893:14): [True: 0, False: 0]
  |  |  |  Branch (893:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1831|      0|                goto fail;
 1832|      0|            }
 1833|       |
 1834|  17.2k|            rc = pki_pubkey_build_ed25519(key, pubkey);
 1835|  17.2k|            ssh_string_burn(pubkey);
 1836|  17.2k|            SSH_STRING_FREE(pubkey);
  ------------------
  |  |  893|  17.2k|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (893:14): [True: 17.2k, False: 0]
  |  |  |  Branch (893:69): [Folded, False: 17.2k]
  |  |  ------------------
  ------------------
 1837|  17.2k|            if (rc < 0) {
  ------------------
  |  Branch (1837:17): [True: 0, False: 17.2k]
  ------------------
 1838|      0|                SSH_LOG(SSH_LOG_TRACE, "Failed to build ED25519 public key");
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 1839|      0|                goto fail;
 1840|      0|            }
 1841|       |
 1842|  17.2k|            if (type == SSH_KEYTYPE_SK_ED25519) {
  ------------------
  |  Branch (1842:17): [True: 0, False: 17.2k]
  ------------------
 1843|      0|                ssh_string application = ssh_buffer_get_ssh_string(buffer);
 1844|      0|                if (application == NULL) {
  ------------------
  |  Branch (1844:21): [True: 0, False: 0]
  ------------------
 1845|      0|                    SSH_LOG(SSH_LOG_TRACE, "SK Unpack error");
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 1846|      0|                    goto fail;
 1847|      0|                }
 1848|      0|                key->sk_application = application;
 1849|      0|            }
 1850|  17.2k|        }
 1851|  17.2k|        break;
 1852|  17.2k|        case SSH_KEYTYPE_RSA_CERT01:
  ------------------
  |  Branch (1852:9): [True: 0, False: 17.2k]
  ------------------
 1853|      0|        case SSH_KEYTYPE_ECDSA_P256_CERT01:
  ------------------
  |  Branch (1853:9): [True: 0, False: 17.2k]
  ------------------
 1854|      0|        case SSH_KEYTYPE_ECDSA_P384_CERT01:
  ------------------
  |  Branch (1854:9): [True: 0, False: 17.2k]
  ------------------
 1855|      0|        case SSH_KEYTYPE_ECDSA_P521_CERT01:
  ------------------
  |  Branch (1855:9): [True: 0, False: 17.2k]
  ------------------
 1856|      0|        case SSH_KEYTYPE_SK_ECDSA_CERT01:
  ------------------
  |  Branch (1856:9): [True: 0, False: 17.2k]
  ------------------
 1857|      0|        case SSH_KEYTYPE_ED25519_CERT01:
  ------------------
  |  Branch (1857:9): [True: 0, False: 17.2k]
  ------------------
 1858|      0|        case SSH_KEYTYPE_SK_ED25519_CERT01:
  ------------------
  |  Branch (1858:9): [True: 0, False: 17.2k]
  ------------------
 1859|      0|        case SSH_KEYTYPE_RSA1:
  ------------------
  |  Branch (1859:9): [True: 0, False: 17.2k]
  ------------------
 1860|      0|        case SSH_KEYTYPE_UNKNOWN:
  ------------------
  |  Branch (1860:9): [True: 0, False: 17.2k]
  ------------------
 1861|      0|        default:
  ------------------
  |  Branch (1861:9): [True: 0, False: 17.2k]
  ------------------
 1862|      0|            SSH_LOG(SSH_LOG_TRACE, "Unknown public key type %d", type);
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 1863|      0|            goto fail;
 1864|  17.2k|    }
 1865|       |
 1866|  17.2k|    *pkey = key;
 1867|  17.2k|    return SSH_OK;
  ------------------
  |  |  316|  17.2k|#define SSH_OK 0     /* No error */
  ------------------
 1868|      0|fail:
 1869|      0|    ssh_key_free(key);
 1870|       |
 1871|      0|    return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 1872|  17.2k|}

ssh_pki_openssh_privkey_import:
  387|  8.64k|{
  388|       |    return ssh_pki_openssh_import(text_key, passphrase, auth_fn, auth_data, true);
  389|  8.64k|}
pki_container_openssh.c:ssh_pki_openssh_import:
  235|  8.64k|{
  236|  8.64k|    const char *ptr = text_key;
  237|  8.64k|    const char *end = NULL;
  238|  8.64k|    char *base64 = NULL;
  239|  8.64k|    int cmp;
  240|  8.64k|    int rc;
  241|  8.64k|    int i;
  242|  8.64k|    ssh_buffer buffer = NULL, privkey_buffer = NULL;
  243|  8.64k|    char *magic = NULL, *ciphername = NULL, *kdfname = NULL;
  244|  8.64k|    uint32_t nkeys = 0, checkint1 = 0, checkint2 = 0xFFFF;
  245|  8.64k|    ssh_string kdfoptions = NULL;
  246|  8.64k|    ssh_string pubkey0 = NULL;
  247|  8.64k|    ssh_string privkeys = NULL;
  248|  8.64k|    ssh_string comment = NULL;
  249|  8.64k|    ssh_key key = NULL;
  250|  8.64k|    uint8_t padding;
  251|       |
  252|  8.64k|    cmp = strncmp(ptr, OPENSSH_HEADER_BEGIN, strlen(OPENSSH_HEADER_BEGIN));
  ------------------
  |  |   43|  8.64k|#define OPENSSH_HEADER_BEGIN "-----BEGIN OPENSSH PRIVATE KEY-----"
  ------------------
                  cmp = strncmp(ptr, OPENSSH_HEADER_BEGIN, strlen(OPENSSH_HEADER_BEGIN));
  ------------------
  |  |   43|  8.64k|#define OPENSSH_HEADER_BEGIN "-----BEGIN OPENSSH PRIVATE KEY-----"
  ------------------
  253|  8.64k|    if (cmp != 0) {
  ------------------
  |  Branch (253:9): [True: 0, False: 8.64k]
  ------------------
  254|      0|        SSH_LOG(SSH_LOG_TRACE, "Not an OpenSSH private key (no header)");
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  255|      0|        goto out;
  256|      0|    }
  257|  8.64k|    ptr += strlen(OPENSSH_HEADER_BEGIN);
  ------------------
  |  |   43|  8.64k|#define OPENSSH_HEADER_BEGIN "-----BEGIN OPENSSH PRIVATE KEY-----"
  ------------------
  258|  8.64k|    while(ptr[0] != '\0' && !isspace((int)ptr[0])) {
  ------------------
  |  Branch (258:11): [True: 8.64k, False: 0]
  |  Branch (258:29): [True: 0, False: 8.64k]
  ------------------
  259|      0|        ptr++;
  260|      0|    }
  261|  8.64k|    end = strstr(ptr, OPENSSH_HEADER_END);
  ------------------
  |  |   44|  8.64k|#define OPENSSH_HEADER_END "-----END OPENSSH PRIVATE KEY-----"
  ------------------
  262|  8.64k|    if (end == NULL) {
  ------------------
  |  Branch (262:9): [True: 0, False: 8.64k]
  ------------------
  263|      0|        SSH_LOG(SSH_LOG_TRACE, "Not an OpenSSH private key (no footer)");
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  264|      0|        goto out;
  265|      0|    }
  266|  8.64k|    base64 = malloc(end - ptr + 1);
  267|  8.64k|    if (base64 == NULL) {
  ------------------
  |  Branch (267:9): [True: 0, False: 8.64k]
  ------------------
  268|      0|        goto out;
  269|      0|    }
  270|  2.96M|    for (i = 0; ptr < end; ptr++) {
  ------------------
  |  Branch (270:17): [True: 2.95M, False: 8.64k]
  ------------------
  271|  2.95M|        if (!isspace((int)ptr[0])) {
  ------------------
  |  Branch (271:13): [True: 2.90M, False: 51.8k]
  ------------------
  272|  2.90M|            base64[i] = ptr[0];
  273|  2.90M|            i++;
  274|  2.90M|        }
  275|  2.95M|    }
  276|  8.64k|    base64[i] = '\0';
  277|  8.64k|    buffer = base64_to_bin(base64);
  278|  8.64k|    SAFE_FREE(base64);
  ------------------
  |  |  373|  8.64k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 8.64k, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 8.64k]
  |  |  ------------------
  ------------------
  279|  8.64k|    if (buffer == NULL) {
  ------------------
  |  Branch (279:9): [True: 0, False: 8.64k]
  ------------------
  280|      0|        SSH_LOG(SSH_LOG_TRACE, "Not an OpenSSH private key (base64 error)");
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  281|      0|        goto out;
  282|      0|    }
  283|  8.64k|    rc = ssh_buffer_unpack(buffer, "PssSdSS",
  ------------------
  |  |   60|  8.64k|    _ssh_buffer_unpack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |  451|  8.64k|        (__VA_NARG_(__VA_ARGS__, __RSEQ_N()))
  |  |  |  |  ------------------
  |  |  |  |  |  |  453|  8.64k|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  448|  8.64k|#define VA_APPLY_VARIADIC_MACRO(macro, tuple) macro tuple
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  453|  8.64k|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  461|  8.64k|        _61,_62,_63,N,...) N
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                   _ssh_buffer_unpack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |   28|  8.64k|#define SSH_BUFFER_PACK_END ((uint32_t) 0x4f65feb3)
  |  |  ------------------
  ------------------
  284|  8.64k|                           strlen(OPENSSH_AUTH_MAGIC) + 1,
  285|  8.64k|                           &magic,
  286|  8.64k|                           &ciphername,
  287|  8.64k|                           &kdfname,
  288|  8.64k|                           &kdfoptions,
  289|  8.64k|                           &nkeys,
  290|  8.64k|                           &pubkey0,
  291|  8.64k|                           &privkeys);
  292|  8.64k|    if (rc == SSH_ERROR) {
  ------------------
  |  |  317|  8.64k|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  |  Branch (292:9): [True: 0, False: 8.64k]
  ------------------
  293|      0|        SSH_LOG(SSH_LOG_TRACE, "Not an OpenSSH private key (unpack error)");
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  294|      0|        goto out;
  295|      0|    }
  296|  8.64k|    cmp = strncmp(magic, OPENSSH_AUTH_MAGIC, strlen(OPENSSH_AUTH_MAGIC));
  ------------------
  |  |   46|  8.64k|#define OPENSSH_AUTH_MAGIC      "openssh-key-v1"
  ------------------
                  cmp = strncmp(magic, OPENSSH_AUTH_MAGIC, strlen(OPENSSH_AUTH_MAGIC));
  ------------------
  |  |   46|  8.64k|#define OPENSSH_AUTH_MAGIC      "openssh-key-v1"
  ------------------
  297|  8.64k|    if (cmp != 0) {
  ------------------
  |  Branch (297:9): [True: 0, False: 8.64k]
  ------------------
  298|      0|        SSH_LOG(SSH_LOG_TRACE, "Not an OpenSSH private key (bad magic)");
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  299|      0|        goto out;
  300|      0|    }
  301|  8.64k|    SSH_LOG(SSH_LOG_DEBUG,
  ------------------
  |  |  281|  8.64k|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  302|  8.64k|            "Opening OpenSSH private key: ciphername: %s, kdf: %s, nkeys: %" PRIu32,
  303|  8.64k|            ciphername,
  304|  8.64k|            kdfname,
  305|  8.64k|            nkeys);
  306|  8.64k|    if (nkeys != 1) {
  ------------------
  |  Branch (306:9): [True: 0, False: 8.64k]
  ------------------
  307|      0|        SSH_LOG(SSH_LOG_TRACE, "Opening OpenSSH private key: only 1 key supported (%" PRIu32 " available)", nkeys);
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  308|      0|        goto out;
  309|      0|    }
  310|       |
  311|       |    /* If we are interested only in public key do not progress
  312|       |     * to the key decryption later
  313|       |     */
  314|  8.64k|    if (!private) {
  ------------------
  |  Branch (314:9): [True: 0, False: 8.64k]
  ------------------
  315|      0|        rc = ssh_pki_import_pubkey_blob(pubkey0, &key);
  316|      0|        if (rc != SSH_OK) {
  ------------------
  |  |  316|      0|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (316:13): [True: 0, False: 0]
  ------------------
  317|      0|            SSH_LOG(SSH_LOG_TRACE, "Failed to import public key blob");
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  318|      0|        }
  319|       |        /* in either case we clean up here */
  320|      0|        goto out;
  321|      0|    }
  322|       |
  323|  8.64k|    rc = pki_private_key_decrypt(privkeys,
  324|  8.64k|                                 passphrase,
  325|  8.64k|                                 ciphername,
  326|  8.64k|                                 kdfname,
  327|  8.64k|                                 kdfoptions,
  328|  8.64k|                                 auth_fn,
  329|  8.64k|                                 auth_data);
  330|  8.64k|    if (rc == SSH_ERROR) {
  ------------------
  |  |  317|  8.64k|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  |  Branch (330:9): [True: 0, False: 8.64k]
  ------------------
  331|      0|        goto out;
  332|      0|    }
  333|       |
  334|  8.64k|    privkey_buffer = ssh_buffer_new();
  335|  8.64k|    if (privkey_buffer == NULL) {
  ------------------
  |  Branch (335:9): [True: 0, False: 8.64k]
  ------------------
  336|      0|        goto out;
  337|      0|    }
  338|       |
  339|  8.64k|    ssh_buffer_set_secure(privkey_buffer);
  340|  8.64k|    ssh_buffer_add_data(privkey_buffer,
  341|  8.64k|                        ssh_string_data(privkeys),
  342|  8.64k|                        (uint32_t)ssh_string_len(privkeys));
  343|       |
  344|  8.64k|    rc = ssh_buffer_unpack(privkey_buffer, "dd", &checkint1, &checkint2);
  ------------------
  |  |   60|  8.64k|    _ssh_buffer_unpack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |  451|  8.64k|        (__VA_NARG_(__VA_ARGS__, __RSEQ_N()))
  |  |  |  |  ------------------
  |  |  |  |  |  |  453|  8.64k|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  448|  8.64k|#define VA_APPLY_VARIADIC_MACRO(macro, tuple) macro tuple
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  453|  8.64k|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  461|  8.64k|        _61,_62,_63,N,...) N
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                   _ssh_buffer_unpack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |   28|  8.64k|#define SSH_BUFFER_PACK_END ((uint32_t) 0x4f65feb3)
  |  |  ------------------
  ------------------
  345|  8.64k|    if (rc == SSH_ERROR || checkint1 != checkint2) {
  ------------------
  |  |  317|  17.2k|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  |  Branch (345:9): [True: 0, False: 8.64k]
  |  Branch (345:28): [True: 0, False: 8.64k]
  ------------------
  346|      0|        SSH_LOG(SSH_LOG_TRACE, "OpenSSH private key unpack error (correct password?)");
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  347|      0|        goto out;
  348|      0|    }
  349|  8.64k|    rc = pki_openssh_import_privkey_blob(privkey_buffer, &key);
  350|  8.64k|    if (rc == SSH_ERROR) {
  ------------------
  |  |  317|  8.64k|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  |  Branch (350:9): [True: 0, False: 8.64k]
  ------------------
  351|      0|        goto out;
  352|      0|    }
  353|  8.64k|    comment = ssh_buffer_get_ssh_string(privkey_buffer);
  354|  8.64k|    SAFE_FREE(comment);
  ------------------
  |  |  373|  8.64k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 8.64k, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 8.64k]
  |  |  ------------------
  ------------------
  355|       |    /* verify that the remaining data is correct padding */
  356|  51.8k|    for (i = 1; ssh_buffer_get_len(privkey_buffer) > 0; ++i) {
  ------------------
  |  Branch (356:17): [True: 43.2k, False: 8.64k]
  ------------------
  357|  43.2k|        ssh_buffer_get_u8(privkey_buffer, &padding);
  358|  43.2k|        if (padding != i) {
  ------------------
  |  Branch (358:13): [True: 0, False: 43.2k]
  ------------------
  359|      0|            ssh_key_free(key);
  360|      0|            key = NULL;
  361|      0|            SSH_LOG(SSH_LOG_TRACE, "Invalid padding");
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  362|      0|            goto out;
  363|      0|        }
  364|  43.2k|    }
  365|  8.64k|out:
  366|  8.64k|    if (buffer != NULL) {
  ------------------
  |  Branch (366:9): [True: 8.64k, False: 0]
  ------------------
  367|  8.64k|        SSH_BUFFER_FREE(buffer);
  ------------------
  |  |  934|  8.64k|    do { if ((x) != NULL) { ssh_buffer_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (934:14): [True: 8.64k, False: 0]
  |  |  |  Branch (934:69): [Folded, False: 8.64k]
  |  |  ------------------
  ------------------
  368|  8.64k|        buffer = NULL;
  369|  8.64k|    }
  370|  8.64k|    if (privkey_buffer != NULL) {
  ------------------
  |  Branch (370:9): [True: 8.64k, False: 0]
  ------------------
  371|  8.64k|        SSH_BUFFER_FREE(privkey_buffer);
  ------------------
  |  |  934|  8.64k|    do { if ((x) != NULL) { ssh_buffer_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (934:14): [True: 8.64k, False: 0]
  |  |  |  Branch (934:69): [Folded, False: 8.64k]
  |  |  ------------------
  ------------------
  372|  8.64k|        privkey_buffer = NULL;
  373|  8.64k|    }
  374|  8.64k|    SAFE_FREE(magic);
  ------------------
  |  |  373|  8.64k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 8.64k, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 8.64k]
  |  |  ------------------
  ------------------
  375|  8.64k|    SAFE_FREE(ciphername);
  ------------------
  |  |  373|  8.64k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 8.64k, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 8.64k]
  |  |  ------------------
  ------------------
  376|  8.64k|    SAFE_FREE(kdfname);
  ------------------
  |  |  373|  8.64k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 8.64k, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 8.64k]
  |  |  ------------------
  ------------------
  377|  8.64k|    SAFE_FREE(kdfoptions);
  ------------------
  |  |  373|  8.64k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 8.64k, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 8.64k]
  |  |  ------------------
  ------------------
  378|  8.64k|    SAFE_FREE(pubkey0);
  ------------------
  |  |  373|  8.64k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 8.64k, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 8.64k]
  |  |  ------------------
  ------------------
  379|       |    SAFE_FREE(privkeys);
  ------------------
  |  |  373|  8.64k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 8.64k, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 8.64k]
  |  |  ------------------
  ------------------
  380|  8.64k|    return key;
  381|  8.64k|}
pki_container_openssh.c:pki_private_key_decrypt:
  108|  8.64k|{
  109|  8.64k|    struct ssh_cipher_struct *ciphers = ssh_get_ciphertab();
  110|  8.64k|    struct ssh_cipher_struct cipher;
  111|  8.64k|    uint8_t key_material[128] = {0};
  112|  8.64k|    char passphrase_buffer[128] = {0};
  113|  8.64k|    size_t key_material_len;
  114|  8.64k|    ssh_buffer buffer = NULL;
  115|  8.64k|    ssh_string salt = NULL;
  116|  8.64k|    uint32_t rounds;
  117|  8.64k|    int cmp;
  118|  8.64k|    int rc;
  119|  8.64k|    int i;
  120|       |
  121|  8.64k|    cmp = strcmp(ciphername, "none");
  122|  8.64k|    if (cmp == 0){
  ------------------
  |  Branch (122:9): [True: 8.64k, False: 0]
  ------------------
  123|       |        /* no decryption required */
  124|  8.64k|        return SSH_OK;
  ------------------
  |  |  316|  8.64k|#define SSH_OK 0     /* No error */
  ------------------
  125|  8.64k|    }
  126|       |
  127|      0|    for (i = 0; ciphers[i].name != NULL; i++) {
  ------------------
  |  Branch (127:17): [True: 0, False: 0]
  ------------------
  128|      0|        cmp = strcmp(ciphername, ciphers[i].name);
  129|      0|        if (cmp == 0){
  ------------------
  |  Branch (129:13): [True: 0, False: 0]
  ------------------
  130|      0|            memcpy(&cipher, &ciphers[i], sizeof(cipher));
  131|      0|            break;
  132|      0|        }
  133|      0|    }
  134|       |
  135|      0|    if (ciphers[i].name == NULL){
  ------------------
  |  Branch (135:9): [True: 0, False: 0]
  ------------------
  136|      0|        SSH_LOG(SSH_LOG_TRACE, "Unsupported cipher %s", ciphername);
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  137|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  138|      0|    }
  139|       |
  140|      0|    cmp = strcmp(kdfname, "bcrypt");
  141|      0|    if (cmp != 0) {
  ------------------
  |  Branch (141:9): [True: 0, False: 0]
  ------------------
  142|      0|        SSH_LOG(SSH_LOG_TRACE, "Unsupported KDF %s", kdfname);
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  143|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  144|      0|    }
  145|      0|    if (ssh_string_len(blob) % cipher.blocksize != 0) {
  ------------------
  |  Branch (145:9): [True: 0, False: 0]
  ------------------
  146|      0|        SSH_LOG(SSH_LOG_TRACE,
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  147|      0|                "Encrypted string not multiple of blocksize: %zu",
  148|      0|                ssh_string_len(blob));
  149|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  150|      0|    }
  151|       |
  152|      0|    buffer = ssh_buffer_new();
  153|      0|    if (buffer == NULL){
  ------------------
  |  Branch (153:9): [True: 0, False: 0]
  ------------------
  154|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  155|      0|    }
  156|      0|    rc = ssh_buffer_add_data(buffer,
  157|      0|                             ssh_string_data(kdfoptions),
  158|      0|                             (uint32_t)ssh_string_len(kdfoptions));
  159|      0|    if (rc != SSH_ERROR){
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  |  Branch (159:9): [True: 0, False: 0]
  ------------------
  160|      0|        rc = ssh_buffer_unpack(buffer, "Sd", &salt, &rounds);
  ------------------
  |  |   60|      0|    _ssh_buffer_unpack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |  451|      0|        (__VA_NARG_(__VA_ARGS__, __RSEQ_N()))
  |  |  |  |  ------------------
  |  |  |  |  |  |  453|      0|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  448|      0|#define VA_APPLY_VARIADIC_MACRO(macro, tuple) macro tuple
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  453|      0|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  461|      0|        _61,_62,_63,N,...) N
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                   _ssh_buffer_unpack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |   28|      0|#define SSH_BUFFER_PACK_END ((uint32_t) 0x4f65feb3)
  |  |  ------------------
  ------------------
  161|      0|    }
  162|      0|    SSH_BUFFER_FREE(buffer);
  ------------------
  |  |  934|      0|    do { if ((x) != NULL) { ssh_buffer_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (934:14): [True: 0, False: 0]
  |  |  |  Branch (934:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
  163|      0|    if (rc == SSH_ERROR){
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  |  Branch (163:9): [True: 0, False: 0]
  ------------------
  164|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  165|      0|    }
  166|       |
  167|       |    /* We need material for key (keysize bits / 8) and IV (blocksize)  */
  168|      0|    key_material_len =  cipher.keysize/8 + cipher.blocksize;
  169|      0|    if (key_material_len > sizeof(key_material)) {
  ------------------
  |  Branch (169:9): [True: 0, False: 0]
  ------------------
  170|      0|        SSH_LOG(SSH_LOG_TRACE, "Key material too big");
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  171|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  172|      0|    }
  173|       |
  174|      0|    SSH_LOG(SSH_LOG_DEBUG,
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  175|      0|            "Decryption: %d key, %d IV, %" PRIu32 " rounds, %zu bytes salt",
  176|      0|            cipher.keysize/8,
  177|      0|            cipher.blocksize,
  178|      0|            rounds,
  179|      0|            ssh_string_len(salt));
  180|       |
  181|      0|    if (passphrase == NULL) {
  ------------------
  |  Branch (181:9): [True: 0, False: 0]
  ------------------
  182|      0|        if (auth_fn == NULL) {
  ------------------
  |  Branch (182:13): [True: 0, False: 0]
  ------------------
  183|      0|            SAFE_FREE(salt);
  ------------------
  |  |  373|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
  184|      0|            SSH_LOG(SSH_LOG_TRACE, "No passphrase provided");
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  185|      0|            return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  186|      0|        }
  187|      0|        rc = auth_fn("Passphrase",
  188|      0|                     passphrase_buffer,
  189|      0|                     sizeof(passphrase_buffer),
  190|      0|                     0,
  191|      0|                     0,
  192|      0|                     auth_data);
  193|      0|        if (rc != SSH_OK) {
  ------------------
  |  |  316|      0|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (193:13): [True: 0, False: 0]
  ------------------
  194|      0|            SAFE_FREE(salt);
  ------------------
  |  |  373|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
  195|      0|            return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  196|      0|        }
  197|      0|        passphrase = passphrase_buffer;
  198|      0|    }
  199|       |
  200|      0|    rc = bcrypt_pbkdf(passphrase,
  201|      0|                      strlen(passphrase),
  202|      0|                      ssh_string_data(salt),
  203|      0|                      ssh_string_len(salt),
  204|      0|                      key_material,
  205|      0|                      key_material_len,
  206|      0|                      rounds);
  207|      0|    SAFE_FREE(salt);
  ------------------
  |  |  373|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
  208|      0|    if (rc < 0){
  ------------------
  |  Branch (208:9): [True: 0, False: 0]
  ------------------
  209|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  210|      0|    }
  211|      0|    ssh_burn(passphrase_buffer, sizeof(passphrase_buffer));
  ------------------
  |  |  388|      0|#define ssh_burn(ptr, len) explicit_bzero((ptr), (len))
  ------------------
  212|       |
  213|      0|    cipher.set_decrypt_key(&cipher,
  214|      0|                           key_material,
  215|      0|                           key_material + cipher.keysize/8);
  216|      0|    cipher.decrypt(&cipher,
  217|      0|                   ssh_string_data(blob),
  218|      0|                   ssh_string_data(blob),
  219|      0|                   ssh_string_len(blob));
  220|      0|    ssh_cipher_clear(&cipher);
  221|      0|    return SSH_OK;
  ------------------
  |  |  316|      0|#define SSH_OK 0     /* No error */
  ------------------
  222|      0|}
pki_container_openssh.c:pki_openssh_import_privkey_blob:
   60|  8.64k|{
   61|  8.64k|    enum ssh_keytypes_e type;
   62|  8.64k|    char *type_s = NULL;
   63|  8.64k|    ssh_key key = NULL;
   64|  8.64k|    int rc;
   65|       |
   66|  8.64k|    if (pkey == NULL) {
  ------------------
  |  Branch (66:9): [True: 0, False: 8.64k]
  ------------------
   67|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
   68|      0|    }
   69|       |
   70|  8.64k|    rc = ssh_buffer_unpack(key_blob_buffer, "s", &type_s);
  ------------------
  |  |   60|  8.64k|    _ssh_buffer_unpack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |  451|  8.64k|        (__VA_NARG_(__VA_ARGS__, __RSEQ_N()))
  |  |  |  |  ------------------
  |  |  |  |  |  |  453|  8.64k|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  448|  8.64k|#define VA_APPLY_VARIADIC_MACRO(macro, tuple) macro tuple
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  453|  8.64k|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  461|  8.64k|        _61,_62,_63,N,...) N
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                   _ssh_buffer_unpack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |   28|  8.64k|#define SSH_BUFFER_PACK_END ((uint32_t) 0x4f65feb3)
  |  |  ------------------
  ------------------
   71|  8.64k|    if (rc == SSH_ERROR){
  ------------------
  |  |  317|  8.64k|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  |  Branch (71:9): [True: 0, False: 8.64k]
  ------------------
   72|      0|        SSH_LOG(SSH_LOG_TRACE, "Unpack error");
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
   73|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
   74|      0|    }
   75|       |
   76|  8.64k|    type = ssh_key_type_from_name(type_s);
   77|  8.64k|    if (type == SSH_KEYTYPE_UNKNOWN) {
  ------------------
  |  Branch (77:9): [True: 0, False: 8.64k]
  ------------------
   78|      0|        SSH_LOG(SSH_LOG_TRACE, "Unknown key type '%s' found!", type_s);
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
   79|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
   80|      0|    }
   81|  8.64k|    SAFE_FREE(type_s);
  ------------------
  |  |  373|  8.64k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 8.64k, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 8.64k]
  |  |  ------------------
  ------------------
   82|       |
   83|  8.64k|    rc = pki_import_privkey_buffer(type, key_blob_buffer, &key);
   84|  8.64k|    if (rc != SSH_OK) {
  ------------------
  |  |  316|  8.64k|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (84:9): [True: 0, False: 8.64k]
  ------------------
   85|      0|        SSH_LOG(SSH_LOG_TRACE, "Failed to read key in OpenSSH format");
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
   86|      0|        goto fail;
   87|      0|    }
   88|       |
   89|  8.64k|    *pkey = key;
   90|  8.64k|    return SSH_OK;
  ------------------
  |  |  316|  8.64k|#define SSH_OK 0     /* No error */
  ------------------
   91|      0|fail:
   92|      0|    ssh_key_free(key);
   93|       |
   94|      0|    return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
   95|  8.64k|}

ssh_pki_ctx_new:
   49|  17.2k|{
   50|  17.2k|    struct ssh_pki_ctx_struct *ctx = NULL;
   51|       |
   52|  17.2k|    ctx = calloc(1, sizeof(struct ssh_pki_ctx_struct));
   53|  17.2k|    if (ctx == NULL) {
  ------------------
  |  Branch (53:9): [True: 0, False: 17.2k]
  ------------------
   54|      0|        return NULL;
   55|      0|    }
   56|       |
   57|       |#ifdef WITH_FIDO2
   58|       |    /* Initialize SK fields with default, if available. */
   59|       |    ctx->sk_callbacks = ssh_sk_get_default_callbacks();
   60|       |
   61|       |    /*
   62|       |     * Both OpenSSH security key enrollment and server authentication require
   63|       |     * user presence by default, so we replicate that for consistency.
   64|       |     */
   65|       |    ctx->sk_flags = SSH_SK_USER_PRESENCE_REQD;
   66|       |
   67|       |    ctx->sk_application = strdup("ssh:");
   68|       |    if (ctx->sk_application == NULL) {
   69|       |        SSH_LOG(SSH_LOG_WARN,
   70|       |                "Failed to allocate memory for default application");
   71|       |        SAFE_FREE(ctx);
   72|       |        return NULL;
   73|       |    }
   74|       |#endif /* WITH_FIDO2 */
   75|       |
   76|  17.2k|    return ctx;
   77|  17.2k|}
ssh_pki_ctx_free:
   86|  17.2k|{
   87|  17.2k|    if (context == NULL) {
  ------------------
  |  Branch (87:9): [True: 0, False: 17.2k]
  ------------------
   88|      0|        return;
   89|      0|    }
   90|       |
   91|       |#ifdef WITH_FIDO2
   92|       |    SAFE_FREE(context->sk_application);
   93|       |    SSH_BUFFER_FREE(context->sk_challenge_buffer);
   94|       |    SSH_BUFFER_FREE(context->sk_attestation_buffer);
   95|       |    SK_OPTIONS_FREE(context->sk_callbacks_options);
   96|       |#endif /* WITH_FIDO2 */
   97|       |
   98|  17.2k|    SAFE_FREE(context);
  ------------------
  |  |  373|  17.2k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 17.2k, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 17.2k]
  |  |  ------------------
  ------------------
   99|  17.2k|}

pki_key_clean:
   96|  43.2k|{
   97|  43.2k|    if (key == NULL)
  ------------------
  |  Branch (97:9): [True: 0, False: 43.2k]
  ------------------
   98|      0|        return;
   99|  43.2k|    EVP_PKEY_free(key->key);
  100|       |    key->key = NULL;
  101|  43.2k|}
pki_privkey_build_ed25519:
  418|  8.64k|{
  419|  8.64k|    EVP_PKEY *pkey = NULL;
  420|       |
  421|  8.64k|    if (ssh_string_len(pubkey) != ED25519_KEY_LEN ||
  ------------------
  |  |   44|  17.2k|#define ED25519_KEY_LEN 32
  ------------------
  |  Branch (421:9): [True: 0, False: 8.64k]
  ------------------
  422|  8.64k|        ssh_string_len(privkey) != (2 * ED25519_KEY_LEN)) {
  ------------------
  |  |   44|  8.64k|#define ED25519_KEY_LEN 32
  ------------------
  |  Branch (422:9): [True: 0, False: 8.64k]
  ------------------
  423|      0|        SSH_LOG(SSH_LOG_TRACE, "Invalid ed25519 key len");
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  424|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  425|      0|    }
  426|       |
  427|  8.64k|    pkey = EVP_PKEY_new_raw_private_key(EVP_PKEY_ED25519,
  428|  8.64k|                                        NULL,
  429|  8.64k|                                        (const uint8_t *)ssh_string_data(privkey),
  430|  8.64k|                                        ED25519_KEY_LEN);
  ------------------
  |  |   44|  8.64k|#define ED25519_KEY_LEN 32
  ------------------
  431|  8.64k|    if (pkey == NULL) {
  ------------------
  |  Branch (431:9): [True: 0, False: 8.64k]
  ------------------
  432|      0|        SSH_LOG(SSH_LOG_TRACE,
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  433|      0|                "Failed to create ed25519 EVP_PKEY: %s",
  434|      0|                ERR_error_string(ERR_get_error(), NULL));
  435|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  436|      0|    }
  437|       |
  438|  8.64k|    key->key = pkey;
  439|       |
  440|  8.64k|    return SSH_OK;
  ------------------
  |  |  316|  8.64k|#define SSH_OK 0     /* No error */
  ------------------
  441|  8.64k|}
pki_pubkey_build_ed25519:
  444|  17.2k|{
  445|  17.2k|    EVP_PKEY *pkey = NULL;
  446|       |
  447|  17.2k|    if (ssh_string_len(pubkey) != ED25519_KEY_LEN) {
  ------------------
  |  |   44|  17.2k|#define ED25519_KEY_LEN 32
  ------------------
  |  Branch (447:9): [True: 0, False: 17.2k]
  ------------------
  448|      0|        SSH_LOG(SSH_LOG_TRACE, "Invalid ed25519 key len");
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  449|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  450|      0|    }
  451|       |
  452|  17.2k|    if (ssh_fips_mode()) {
  ------------------
  |  |  115|  17.2k|#define ssh_fips_mode() (FIPS_mode() != 0)
  |  |  ------------------
  |  |  |  Branch (115:25): [True: 0, False: 17.2k]
  |  |  ------------------
  ------------------
  453|       |        /* We do not want to fail here as we know the algorithm, but we can not
  454|       |         * use it. Just store the public key here. We won't be able to use it
  455|       |         * for anything though. */
  456|      0|        key->ed25519_pubkey = malloc(ED25519_KEY_LEN);
  ------------------
  |  |   44|      0|#define ED25519_KEY_LEN 32
  ------------------
  457|      0|        if (key->ed25519_pubkey == NULL) {
  ------------------
  |  Branch (457:13): [True: 0, False: 0]
  ------------------
  458|      0|            SSH_LOG(SSH_LOG_TRACE,
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  459|      0|                    "Failed to allocate memory for the Ed25519 public key");
  460|      0|            return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  461|      0|        }
  462|       |
  463|      0|        memcpy(key->ed25519_pubkey, ssh_string_data(pubkey), ED25519_KEY_LEN);
  ------------------
  |  |   44|      0|#define ED25519_KEY_LEN 32
  ------------------
  464|      0|        return SSH_OK;
  ------------------
  |  |  316|      0|#define SSH_OK 0     /* No error */
  ------------------
  465|      0|    }
  466|       |
  467|  17.2k|    pkey = EVP_PKEY_new_raw_public_key(EVP_PKEY_ED25519,
  468|  17.2k|                                       NULL,
  469|  17.2k|                                       (const uint8_t *)ssh_string_data(pubkey),
  470|  17.2k|                                       ED25519_KEY_LEN);
  ------------------
  |  |   44|  17.2k|#define ED25519_KEY_LEN 32
  ------------------
  471|  17.2k|    if (pkey == NULL) {
  ------------------
  |  Branch (471:9): [True: 0, False: 17.2k]
  ------------------
  472|      0|        SSH_LOG(SSH_LOG_TRACE,
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  473|      0|                "Failed to create ed25519 EVP_PKEY: %s",
  474|      0|                ERR_error_string(ERR_get_error(), NULL));
  475|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  476|      0|    }
  477|       |
  478|  17.2k|    key->key = pkey;
  479|       |
  480|  17.2k|    return SSH_OK;
  ------------------
  |  |  316|  17.2k|#define SSH_OK 0     /* No error */
  ------------------
  481|  17.2k|}
pki_key_dup:
  484|  17.2k|{
  485|  17.2k|    ssh_key new = NULL;
  486|  17.2k|    int rc;
  487|       |
  488|  17.2k|    new = pki_key_dup_common_init(key, demote);
  489|  17.2k|    if (new == NULL) {
  ------------------
  |  Branch (489:9): [True: 0, False: 17.2k]
  ------------------
  490|      0|        return NULL;
  491|      0|    }
  492|       |
  493|  17.2k|    switch (key->type) {
  494|      0|    case SSH_KEYTYPE_RSA:
  ------------------
  |  Branch (494:5): [True: 0, False: 17.2k]
  ------------------
  495|      0|    case SSH_KEYTYPE_RSA1: {
  ------------------
  |  Branch (495:5): [True: 0, False: 17.2k]
  ------------------
  496|      0|#if OPENSSL_VERSION_NUMBER < 0x30000000L
  497|      0|        const BIGNUM *n = NULL, *e = NULL, *d = NULL;
  498|      0|        BIGNUM *nn, *ne, *nd;
  499|      0|        RSA *new_rsa = NULL;
  500|      0|        const RSA *key_rsa = EVP_PKEY_get0_RSA(key->key);
  501|      0|#endif /* OPENSSL_VERSION_NUMBER < 0x30000000L */
  502|       |#ifdef WITH_PKCS11_URI
  503|       |        /* Take the PKCS#11 keys as they are */
  504|       |        if (key->flags & SSH_KEY_FLAG_PKCS11_URI && !demote) {
  505|       |            rc = EVP_PKEY_up_ref(key->key);
  506|       |            if (rc != 1) {
  507|       |                goto fail;
  508|       |            }
  509|       |            new->key = key->key;
  510|       |            return new;
  511|       |        }
  512|       |#endif /* WITH_PKCS11_URI */
  513|      0|#if OPENSSL_VERSION_NUMBER < 0x30000000L
  514|      0|        new_rsa = RSA_new();
  515|      0|        if (new_rsa == NULL) {
  ------------------
  |  Branch (515:13): [True: 0, False: 0]
  ------------------
  516|      0|            goto fail;
  517|      0|        }
  518|       |
  519|       |        /*
  520|       |         * n    = public modulus
  521|       |         * e    = public exponent
  522|       |         * d    = private exponent
  523|       |         * p    = secret prime factor
  524|       |         * q    = secret prime factor
  525|       |         * dmp1 = d mod (p-1)
  526|       |         * dmq1 = d mod (q-1)
  527|       |         * iqmp = q^-1 mod p
  528|       |         */
  529|      0|        RSA_get0_key(key_rsa, &n, &e, &d);
  530|      0|        nn = BN_dup(n);
  531|      0|        ne = BN_dup(e);
  532|      0|        if (nn == NULL || ne == NULL) {
  ------------------
  |  Branch (532:13): [True: 0, False: 0]
  |  Branch (532:27): [True: 0, False: 0]
  ------------------
  533|      0|            RSA_free(new_rsa);
  534|      0|            BN_free(nn);
  535|      0|            BN_free(ne);
  536|      0|            goto fail;
  537|      0|        }
  538|       |
  539|       |        /* Memory management of nn and ne is transferred to RSA object */
  540|      0|        rc = RSA_set0_key(new_rsa, nn, ne, NULL);
  541|      0|        if (rc == 0) {
  ------------------
  |  Branch (541:13): [True: 0, False: 0]
  ------------------
  542|      0|            RSA_free(new_rsa);
  543|      0|            BN_free(nn);
  544|      0|            BN_free(ne);
  545|      0|            goto fail;
  546|      0|        }
  547|       |
  548|      0|        if (!demote && (key->flags & SSH_KEY_FLAG_PRIVATE)) {
  ------------------
  |  |   55|      0|#define SSH_KEY_FLAG_PRIVATE 0x0002
  ------------------
  |  Branch (548:13): [True: 0, False: 0]
  |  Branch (548:24): [True: 0, False: 0]
  ------------------
  549|      0|            const BIGNUM *p = NULL, *q = NULL, *dmp1 = NULL,
  550|      0|              *dmq1 = NULL, *iqmp = NULL;
  551|      0|            BIGNUM *np, *nq, *ndmp1, *ndmq1, *niqmp;
  552|       |
  553|      0|            nd = BN_dup(d);
  554|      0|            if (nd == NULL) {
  ------------------
  |  Branch (554:17): [True: 0, False: 0]
  ------------------
  555|      0|                RSA_free(new_rsa);
  556|      0|                goto fail;
  557|      0|            }
  558|       |
  559|       |            /* Memory management of nd is transferred to RSA object */
  560|      0|            rc = RSA_set0_key(new_rsa, NULL, NULL, nd);
  561|      0|            if (rc == 0) {
  ------------------
  |  Branch (561:17): [True: 0, False: 0]
  ------------------
  562|      0|                RSA_free(new_rsa);
  563|      0|                goto fail;
  564|      0|            }
  565|       |
  566|       |            /* p, q, dmp1, dmq1 and iqmp may be NULL in private keys, but the
  567|       |             * RSA operations are much faster when these values are available.
  568|       |             */
  569|      0|            RSA_get0_factors(key_rsa, &p, &q);
  570|      0|            if (p != NULL && q != NULL) { /* need to set both of them */
  ------------------
  |  Branch (570:17): [True: 0, False: 0]
  |  Branch (570:30): [True: 0, False: 0]
  ------------------
  571|      0|                np = BN_dup(p);
  572|      0|                nq = BN_dup(q);
  573|      0|                if (np == NULL || nq == NULL) {
  ------------------
  |  Branch (573:21): [True: 0, False: 0]
  |  Branch (573:35): [True: 0, False: 0]
  ------------------
  574|      0|                    RSA_free(new_rsa);
  575|      0|                    BN_free(np);
  576|      0|                    BN_free(nq);
  577|      0|                    goto fail;
  578|      0|                }
  579|       |
  580|       |                /* Memory management of np and nq is transferred to RSA object */
  581|      0|                rc = RSA_set0_factors(new_rsa, np, nq);
  582|      0|                if (rc == 0) {
  ------------------
  |  Branch (582:21): [True: 0, False: 0]
  ------------------
  583|      0|                    RSA_free(new_rsa);
  584|      0|                    BN_free(np);
  585|      0|                    BN_free(nq);
  586|      0|                    goto fail;
  587|      0|                }
  588|      0|            }
  589|       |
  590|      0|            RSA_get0_crt_params(key_rsa, &dmp1, &dmq1, &iqmp);
  591|      0|            if (dmp1 != NULL || dmq1 != NULL || iqmp != NULL) {
  ------------------
  |  Branch (591:17): [True: 0, False: 0]
  |  Branch (591:33): [True: 0, False: 0]
  |  Branch (591:49): [True: 0, False: 0]
  ------------------
  592|      0|                ndmp1 = BN_dup(dmp1);
  593|      0|                ndmq1 = BN_dup(dmq1);
  594|      0|                niqmp = BN_dup(iqmp);
  595|      0|                if (ndmp1 == NULL || ndmq1 == NULL || niqmp == NULL) {
  ------------------
  |  Branch (595:21): [True: 0, False: 0]
  |  Branch (595:38): [True: 0, False: 0]
  |  Branch (595:55): [True: 0, False: 0]
  ------------------
  596|      0|                    RSA_free(new_rsa);
  597|      0|                    BN_free(ndmp1);
  598|      0|                    BN_free(ndmq1);
  599|      0|                    BN_free(niqmp);
  600|      0|                    goto fail;
  601|      0|                }
  602|       |
  603|       |                /* Memory management of ndmp1, ndmq1 and niqmp is transferred
  604|       |                 * to RSA object */
  605|      0|                rc = RSA_set0_crt_params(new_rsa, ndmp1, ndmq1, niqmp);
  606|      0|                if (rc == 0) {
  ------------------
  |  Branch (606:21): [True: 0, False: 0]
  ------------------
  607|      0|                    RSA_free(new_rsa);
  608|      0|                    BN_free(ndmp1);
  609|      0|                    BN_free(ndmq1);
  610|      0|                    BN_free(niqmp);
  611|      0|                    goto fail;
  612|      0|                }
  613|      0|            }
  614|      0|        }
  615|       |
  616|      0|        new->key = EVP_PKEY_new();
  617|      0|        if (new->key == NULL) {
  ------------------
  |  Branch (617:13): [True: 0, False: 0]
  ------------------
  618|      0|            RSA_free(new_rsa);
  619|      0|            goto fail;
  620|      0|        }
  621|       |
  622|      0|        rc = EVP_PKEY_assign_RSA(new->key, new_rsa);
  623|      0|        if (rc != 1) {
  ------------------
  |  Branch (623:13): [True: 0, False: 0]
  ------------------
  624|      0|            EVP_PKEY_free(new->key);
  625|      0|            RSA_free(new_rsa);
  626|      0|            goto fail;
  627|      0|        }
  628|       |
  629|      0|        new_rsa = NULL;
  630|       |#else
  631|       |        rc = evp_dup_rsa_pkey(key, new, demote);
  632|       |        if (rc != SSH_OK) {
  633|       |            goto fail;
  634|       |        }
  635|       |#endif /* OPENSSL_VERSION_NUMBER */
  636|      0|        break;
  637|      0|    }
  638|      0|    case SSH_KEYTYPE_ECDSA_P256:
  ------------------
  |  Branch (638:5): [True: 0, False: 17.2k]
  ------------------
  639|      0|    case SSH_KEYTYPE_ECDSA_P384:
  ------------------
  |  Branch (639:5): [True: 0, False: 17.2k]
  ------------------
  640|      0|    case SSH_KEYTYPE_ECDSA_P521:
  ------------------
  |  Branch (640:5): [True: 0, False: 17.2k]
  ------------------
  641|      0|    case SSH_KEYTYPE_SK_ECDSA:
  ------------------
  |  Branch (641:5): [True: 0, False: 17.2k]
  ------------------
  642|      0|#ifdef HAVE_OPENSSL_ECC
  643|      0|        new->ecdsa_nid = key->ecdsa_nid;
  644|       |#ifdef WITH_PKCS11_URI
  645|       |        /* Take the PKCS#11 keys as they are */
  646|       |        if (key->flags & SSH_KEY_FLAG_PKCS11_URI && !demote) {
  647|       |            rc = EVP_PKEY_up_ref(key->key);
  648|       |            if (rc != 1) {
  649|       |                goto fail;
  650|       |            }
  651|       |            new->key = key->key;
  652|       |            return new;
  653|       |        }
  654|       |#endif /* WITH_PKCS11_URI */
  655|      0|#if OPENSSL_VERSION_NUMBER < 0x30000000L
  656|       |        /* privkey -> pubkey */
  657|      0|        if (demote && ssh_key_is_private(key)) {
  ------------------
  |  Branch (657:13): [True: 0, False: 0]
  |  Branch (657:23): [True: 0, False: 0]
  ------------------
  658|      0|            const EC_POINT *p = NULL;
  659|      0|            EC_KEY *new_ecdsa = NULL, *old_ecdsa = NULL;
  660|      0|            int ok;
  661|       |
  662|      0|            new_ecdsa = EC_KEY_new_by_curve_name(key->ecdsa_nid);
  663|      0|            if (new_ecdsa == NULL) {
  ------------------
  |  Branch (663:17): [True: 0, False: 0]
  ------------------
  664|      0|                goto fail;
  665|      0|            }
  666|       |
  667|      0|            old_ecdsa = EVP_PKEY_get0_EC_KEY(key->key);
  668|      0|            if (old_ecdsa == NULL) {
  ------------------
  |  Branch (668:17): [True: 0, False: 0]
  ------------------
  669|      0|                EC_KEY_free(new_ecdsa);
  670|      0|                goto fail;
  671|      0|            }
  672|       |
  673|      0|            p = EC_KEY_get0_public_key(old_ecdsa);
  674|      0|            if (p == NULL) {
  ------------------
  |  Branch (674:17): [True: 0, False: 0]
  ------------------
  675|      0|                EC_KEY_free(new_ecdsa);
  676|      0|                goto fail;
  677|      0|            }
  678|       |
  679|      0|            ok = EC_KEY_set_public_key(new_ecdsa, p);
  680|      0|            if (ok != 1) {
  ------------------
  |  Branch (680:17): [True: 0, False: 0]
  ------------------
  681|      0|                EC_KEY_free(new_ecdsa);
  682|      0|                goto fail;
  683|      0|            }
  684|       |
  685|      0|            new->key = EVP_PKEY_new();
  686|      0|            if (new->key == NULL) {
  ------------------
  |  Branch (686:17): [True: 0, False: 0]
  ------------------
  687|      0|                EC_KEY_free(new_ecdsa);
  688|      0|                goto fail;
  689|      0|            }
  690|       |
  691|      0|            ok = EVP_PKEY_assign_EC_KEY(new->key, new_ecdsa);
  692|      0|            if (ok != 1) {
  ------------------
  |  Branch (692:17): [True: 0, False: 0]
  ------------------
  693|      0|                EC_KEY_free(new_ecdsa);
  694|      0|                goto fail;
  695|      0|            }
  696|      0|        } else {
  697|      0|            rc = EVP_PKEY_up_ref(key->key);
  698|      0|            if (rc != 1) {
  ------------------
  |  Branch (698:17): [True: 0, False: 0]
  ------------------
  699|      0|                goto fail;
  700|      0|            }
  701|      0|            new->key = key->key;
  702|      0|        }
  703|       |#else
  704|       |        rc = evp_dup_ecdsa_pkey(key, new, demote);
  705|       |        if (rc != SSH_OK) {
  706|       |            goto fail;
  707|       |        }
  708|       |#endif /* OPENSSL_VERSION_NUMBER */
  709|      0|        break;
  710|      0|#endif /* HAVE_OPENSSL_ECC */
  711|  17.2k|    case SSH_KEYTYPE_ED25519:
  ------------------
  |  Branch (711:5): [True: 17.2k, False: 0]
  ------------------
  712|  17.2k|    case SSH_KEYTYPE_SK_ED25519: {
  ------------------
  |  Branch (712:5): [True: 0, False: 17.2k]
  ------------------
  713|  17.2k|#if OPENSSL_VERSION_NUMBER < 0x30000000L
  714|       |        /* Take the PKCS#11 keys as they are */
  715|  17.2k|        if (key->flags & SSH_KEY_FLAG_PKCS11_URI && !demote) {
  ------------------
  |  |   56|  34.5k|#define SSH_KEY_FLAG_PKCS11_URI 0x0004
  ------------------
  |  Branch (715:13): [True: 0, False: 17.2k]
  |  Branch (715:53): [True: 0, False: 0]
  ------------------
  716|      0|            rc = EVP_PKEY_up_ref(key->key);
  717|      0|            if (rc != 1) {
  ------------------
  |  Branch (717:17): [True: 0, False: 0]
  ------------------
  718|      0|                goto fail;
  719|      0|            }
  720|      0|            new->key = key->key;
  721|      0|            return new;
  722|      0|        }
  723|       |
  724|  17.2k|        if (!demote && (key->flags & SSH_KEY_FLAG_PRIVATE) &&
  ------------------
  |  |   55|  8.64k|#define SSH_KEY_FLAG_PRIVATE 0x0002
  ------------------
  |  Branch (724:13): [True: 8.64k, False: 8.64k]
  |  Branch (724:24): [True: 8.64k, False: 0]
  ------------------
  725|  8.64k|            key->type == SSH_KEYTYPE_ED25519) {
  ------------------
  |  Branch (725:13): [True: 8.64k, False: 0]
  ------------------
  726|  8.64k|            rc = EVP_PKEY_up_ref(key->key);
  727|  8.64k|            if (rc != 1) {
  ------------------
  |  Branch (727:17): [True: 0, False: 8.64k]
  ------------------
  728|      0|                goto fail;
  729|      0|            }
  730|  8.64k|            new->key = key->key;
  731|  8.64k|        } else {
  732|  8.64k|            unsigned char *ed25519_pubkey = NULL;
  733|  8.64k|            size_t key_len = 0;
  734|       |
  735|  8.64k|            rc = EVP_PKEY_get_raw_public_key(key->key, NULL, &key_len);
  736|  8.64k|            if (rc != 1) {
  ------------------
  |  Branch (736:17): [True: 0, False: 8.64k]
  ------------------
  737|      0|                SSH_LOG(SSH_LOG_TRACE,
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  738|      0|                        "Failed to get ed25519 raw public key length: %s",
  739|      0|                        ERR_error_string(ERR_get_error(), NULL));
  740|      0|                goto fail;
  741|      0|            }
  742|       |
  743|  8.64k|            if (key_len != ED25519_KEY_LEN) {
  ------------------
  |  |   44|  8.64k|#define ED25519_KEY_LEN 32
  ------------------
  |  Branch (743:17): [True: 0, False: 8.64k]
  ------------------
  744|      0|                SSH_LOG(SSH_LOG_TRACE,
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  745|      0|                        "Unexpected length of public key %zu. Expected %d.",
  746|      0|                        key_len,
  747|      0|                        ED25519_KEY_LEN);
  748|      0|                goto fail;
  749|      0|            }
  750|       |
  751|  8.64k|            ed25519_pubkey = malloc(key_len);
  752|  8.64k|            if (ed25519_pubkey == NULL) {
  ------------------
  |  Branch (752:17): [True: 0, False: 8.64k]
  ------------------
  753|      0|                SSH_LOG(SSH_LOG_TRACE, "Out of memory");
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  754|      0|                goto fail;
  755|      0|            }
  756|       |
  757|  8.64k|            rc = EVP_PKEY_get_raw_public_key(key->key,
  758|  8.64k|                                             ed25519_pubkey,
  759|  8.64k|                                             &key_len);
  760|  8.64k|            if (rc != 1) {
  ------------------
  |  Branch (760:17): [True: 0, False: 8.64k]
  ------------------
  761|      0|                SSH_LOG(SSH_LOG_TRACE,
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  762|      0|                        "Failed to get ed25519 raw public key: %s",
  763|      0|                        ERR_error_string(ERR_get_error(), NULL));
  764|      0|                free(ed25519_pubkey);
  765|      0|                goto fail;
  766|      0|            }
  767|       |
  768|  8.64k|            new->key = EVP_PKEY_new_raw_public_key(EVP_PKEY_ED25519,
  769|  8.64k|                                                   NULL,
  770|  8.64k|                                                   ed25519_pubkey,
  771|  8.64k|                                                   key_len);
  772|  8.64k|            free(ed25519_pubkey);
  773|  8.64k|        }
  774|       |
  775|       |#else
  776|       |        rc = evp_dup_ed25519_pkey(key, new, demote);
  777|       |        if (rc != SSH_OK) {
  778|       |            goto fail;
  779|       |        }
  780|       |#endif /* OPENSSL_VERSION_NUMBER < 0x30000000L */
  781|  17.2k|        break;
  782|  17.2k|    }
  783|  17.2k|    case SSH_KEYTYPE_UNKNOWN:
  ------------------
  |  Branch (783:5): [True: 0, False: 17.2k]
  ------------------
  784|      0|    default:
  ------------------
  |  Branch (784:5): [True: 0, False: 17.2k]
  ------------------
  785|      0|        ssh_key_free(new);
  786|      0|        return NULL;
  787|  17.2k|    }
  788|       |
  789|  17.2k|    return new;
  790|      0|fail:
  791|      0|    ssh_key_free(new);
  792|       |    return NULL;
  793|  17.2k|}
pki_key_to_blob:
 1493|  34.5k|{
 1494|  34.5k|    ssh_buffer buffer = NULL;
 1495|  34.5k|    ssh_string type_s = NULL;
 1496|  34.5k|    ssh_string str = NULL;
 1497|  34.5k|    ssh_string e = NULL;
 1498|  34.5k|    ssh_string n = NULL;
 1499|  34.5k|    ssh_string p = NULL;
 1500|  34.5k|    ssh_string g = NULL;
 1501|  34.5k|    ssh_string q = NULL;
 1502|  34.5k|    ssh_string d = NULL;
 1503|  34.5k|    ssh_string iqmp = NULL;
 1504|  34.5k|    int rc;
 1505|       |#if OPENSSL_VERSION_NUMBER >= 0x30000000L
 1506|       |    BIGNUM *bp = NULL, *bq = NULL, *bg = NULL, *bpub_key = NULL,
 1507|       |           *bn = NULL, *be = NULL,
 1508|       |           *bd = NULL, *biqmp = NULL;
 1509|       |    OSSL_PARAM *params = NULL;
 1510|       |#endif /* OPENSSL_VERSION_NUMBER */
 1511|  34.5k|    uint8_t *ed25519_pubkey = NULL;
 1512|  34.5k|    uint8_t *ed25519_privkey = NULL;
 1513|  34.5k|    size_t key_len = 0;
 1514|       |
 1515|  34.5k|    buffer = ssh_buffer_new();
 1516|  34.5k|    if (buffer == NULL) {
  ------------------
  |  Branch (1516:9): [True: 0, False: 34.5k]
  ------------------
 1517|      0|        return NULL;
 1518|      0|    }
 1519|       |    /* The buffer will contain sensitive information. Make sure it is erased */
 1520|  34.5k|    ssh_buffer_set_secure(buffer);
 1521|       |
 1522|  34.5k|    if (key->cert != NULL) {
  ------------------
  |  Branch (1522:9): [True: 0, False: 34.5k]
  ------------------
 1523|      0|        rc = ssh_buffer_add_buffer(buffer, key->cert);
 1524|      0|        if (rc < 0) {
  ------------------
  |  Branch (1524:13): [True: 0, False: 0]
  ------------------
 1525|      0|            SSH_BUFFER_FREE(buffer);
  ------------------
  |  |  934|      0|    do { if ((x) != NULL) { ssh_buffer_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (934:14): [True: 0, False: 0]
  |  |  |  Branch (934:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1526|      0|            return NULL;
 1527|      0|        }
 1528|      0|        goto makestring;
 1529|      0|    }
 1530|       |
 1531|  34.5k|    type_s = ssh_string_from_char(key->type_c);
 1532|  34.5k|    if (type_s == NULL) {
  ------------------
  |  Branch (1532:9): [True: 0, False: 34.5k]
  ------------------
 1533|      0|        SSH_BUFFER_FREE(buffer);
  ------------------
  |  |  934|      0|    do { if ((x) != NULL) { ssh_buffer_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (934:14): [True: 0, False: 0]
  |  |  |  Branch (934:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1534|      0|        return NULL;
 1535|      0|    }
 1536|       |
 1537|  34.5k|    rc = ssh_buffer_add_ssh_string(buffer, type_s);
 1538|  34.5k|    SSH_STRING_FREE(type_s);
  ------------------
  |  |  893|  34.5k|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (893:14): [True: 34.5k, False: 0]
  |  |  |  Branch (893:69): [Folded, False: 34.5k]
  |  |  ------------------
  ------------------
 1539|  34.5k|    if (rc < 0) {
  ------------------
  |  Branch (1539:9): [True: 0, False: 34.5k]
  ------------------
 1540|      0|        SSH_BUFFER_FREE(buffer);
  ------------------
  |  |  934|      0|    do { if ((x) != NULL) { ssh_buffer_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (934:14): [True: 0, False: 0]
  |  |  |  Branch (934:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1541|      0|        return NULL;
 1542|      0|    }
 1543|       |
 1544|  34.5k|    switch (key->type) {
 1545|      0|    case SSH_KEYTYPE_RSA:
  ------------------
  |  Branch (1545:5): [True: 0, False: 34.5k]
  ------------------
 1546|      0|    case SSH_KEYTYPE_RSA1: {
  ------------------
  |  Branch (1546:5): [True: 0, False: 34.5k]
  ------------------
 1547|      0|#if OPENSSL_VERSION_NUMBER < 0x30000000L
 1548|      0|        const BIGNUM *be = NULL, *bn = NULL;
 1549|      0|        const RSA *key_rsa = EVP_PKEY_get0_RSA(key->key);
 1550|      0|        RSA_get0_key(key_rsa, &bn, &be, NULL);
 1551|       |#else
 1552|       |        const OSSL_PARAM *out_param = NULL;
 1553|       |        rc = EVP_PKEY_todata(key->key, EVP_PKEY_PUBLIC_KEY, &params);
 1554|       |        if (rc != 1) {
 1555|       |            goto fail;
 1556|       |        }
 1557|       |        out_param = OSSL_PARAM_locate_const(params, OSSL_PKEY_PARAM_RSA_E);
 1558|       |        if (out_param == NULL) {
 1559|       |            SSH_LOG(SSH_LOG_TRACE, "RSA: No param E has been found");
 1560|       |            goto fail;
 1561|       |        }
 1562|       |        rc = OSSL_PARAM_get_BN(out_param, &be);
 1563|       |        if (rc != 1) {
 1564|       |            goto fail;
 1565|       |        }
 1566|       |        out_param = OSSL_PARAM_locate_const(params, OSSL_PKEY_PARAM_RSA_N);
 1567|       |        if (out_param == NULL) {
 1568|       |            SSH_LOG(SSH_LOG_TRACE, "RSA: No param N has been found");
 1569|       |            goto fail;
 1570|       |        }
 1571|       |        rc = OSSL_PARAM_get_BN(out_param, &bn);
 1572|       |        if (rc != 1) {
 1573|       |            goto fail;
 1574|       |        }
 1575|       |#endif /* OPENSSL_VERSION_NUMBER */
 1576|      0|        e = ssh_make_bignum_string((BIGNUM *)be);
 1577|      0|        if (e == NULL) {
  ------------------
  |  Branch (1577:13): [True: 0, False: 0]
  ------------------
 1578|      0|            goto fail;
 1579|      0|        }
 1580|       |
 1581|      0|        n = ssh_make_bignum_string((BIGNUM *)bn);
 1582|      0|        if (n == NULL) {
  ------------------
  |  Branch (1582:13): [True: 0, False: 0]
  ------------------
 1583|      0|            goto fail;
 1584|      0|        }
 1585|       |
 1586|      0|        if (type == SSH_KEY_PUBLIC) {
  ------------------
  |  Branch (1586:13): [True: 0, False: 0]
  ------------------
 1587|       |            /* The N and E parts are swapped in the public key export ! */
 1588|      0|            rc = ssh_buffer_add_ssh_string(buffer, e);
 1589|      0|            if (rc < 0) {
  ------------------
  |  Branch (1589:17): [True: 0, False: 0]
  ------------------
 1590|      0|                goto fail;
 1591|      0|            }
 1592|      0|            rc = ssh_buffer_add_ssh_string(buffer, n);
 1593|      0|            if (rc < 0) {
  ------------------
  |  Branch (1593:17): [True: 0, False: 0]
  ------------------
 1594|      0|                goto fail;
 1595|      0|            }
 1596|      0|        } else if (type == SSH_KEY_PRIVATE) {
  ------------------
  |  Branch (1596:20): [True: 0, False: 0]
  ------------------
 1597|      0|#if OPENSSL_VERSION_NUMBER < 0x30000000L
 1598|      0|            const BIGNUM *bd, *biqmp, *bp, *bq;
 1599|      0|            RSA_get0_key(key_rsa, NULL, NULL, &bd);
 1600|      0|            RSA_get0_factors(key_rsa, &bp, &bq);
 1601|      0|            RSA_get0_crt_params(key_rsa, NULL, NULL, &biqmp);
 1602|       |#else
 1603|       |            OSSL_PARAM_free(params);
 1604|       |            rc = EVP_PKEY_todata(key->key, EVP_PKEY_KEYPAIR, &params);
 1605|       |            if (rc != 1) {
 1606|       |                goto fail;
 1607|       |            }
 1608|       |
 1609|       |            out_param = OSSL_PARAM_locate_const(params, OSSL_PKEY_PARAM_RSA_D);
 1610|       |            if (out_param == NULL) {
 1611|       |                SSH_LOG(SSH_LOG_TRACE, "RSA: No param D has been found");
 1612|       |                goto fail;
 1613|       |            }
 1614|       |            rc = OSSL_PARAM_get_BN(out_param, &bd);
 1615|       |            if (rc != 1) {
 1616|       |                goto fail;
 1617|       |            }
 1618|       |
 1619|       |            out_param = OSSL_PARAM_locate_const(params, OSSL_PKEY_PARAM_RSA_FACTOR1);
 1620|       |            if (out_param == NULL) {
 1621|       |                SSH_LOG(SSH_LOG_TRACE, "RSA: No param P has been found");
 1622|       |                goto fail;
 1623|       |            }
 1624|       |            rc = OSSL_PARAM_get_BN(out_param, &bp);
 1625|       |            if (rc != 1) {
 1626|       |                goto fail;
 1627|       |            }
 1628|       |
 1629|       |            out_param = OSSL_PARAM_locate_const(params, OSSL_PKEY_PARAM_RSA_FACTOR2);
 1630|       |            if (out_param == NULL) {
 1631|       |                SSH_LOG(SSH_LOG_TRACE, "RSA: No param Q has been found");
 1632|       |                goto fail;
 1633|       |            }
 1634|       |            rc = OSSL_PARAM_get_BN(out_param, &bq);
 1635|       |            if (rc != 1) {
 1636|       |                goto fail;
 1637|       |            }
 1638|       |
 1639|       |            out_param = OSSL_PARAM_locate_const(params, OSSL_PKEY_PARAM_RSA_COEFFICIENT1);
 1640|       |            if (out_param == NULL) {
 1641|       |                SSH_LOG(SSH_LOG_TRACE, "RSA: No param IQMP has been found");
 1642|       |                goto fail;
 1643|       |            }
 1644|       |            rc = OSSL_PARAM_get_BN(out_param, &biqmp);
 1645|       |            if (rc != 1) {
 1646|       |                goto fail;
 1647|       |            }
 1648|       |#endif /* OPENSSL_VERSION_NUMBER */
 1649|      0|            rc = ssh_buffer_add_ssh_string(buffer, n);
 1650|      0|            if (rc < 0) {
  ------------------
  |  Branch (1650:17): [True: 0, False: 0]
  ------------------
 1651|      0|                goto fail;
 1652|      0|            }
 1653|      0|            rc = ssh_buffer_add_ssh_string(buffer, e);
 1654|      0|            if (rc < 0) {
  ------------------
  |  Branch (1654:17): [True: 0, False: 0]
  ------------------
 1655|      0|                goto fail;
 1656|      0|            }
 1657|       |
 1658|      0|            d = ssh_make_bignum_string((BIGNUM *)bd);
 1659|      0|            if (d == NULL) {
  ------------------
  |  Branch (1659:17): [True: 0, False: 0]
  ------------------
 1660|      0|                goto fail;
 1661|      0|            }
 1662|       |
 1663|      0|            iqmp = ssh_make_bignum_string((BIGNUM *)biqmp);
 1664|      0|            if (iqmp == NULL) {
  ------------------
  |  Branch (1664:17): [True: 0, False: 0]
  ------------------
 1665|      0|                goto fail;
 1666|      0|            }
 1667|       |
 1668|      0|            p = ssh_make_bignum_string((BIGNUM *)bp);
 1669|      0|            if (p == NULL) {
  ------------------
  |  Branch (1669:17): [True: 0, False: 0]
  ------------------
 1670|      0|                goto fail;
 1671|      0|            }
 1672|       |
 1673|      0|            q = ssh_make_bignum_string((BIGNUM *)bq);
 1674|      0|            if (q == NULL) {
  ------------------
  |  Branch (1674:17): [True: 0, False: 0]
  ------------------
 1675|      0|                goto fail;
 1676|      0|            }
 1677|       |
 1678|      0|            rc = ssh_buffer_add_ssh_string(buffer, d);
 1679|      0|            if (rc < 0) {
  ------------------
  |  Branch (1679:17): [True: 0, False: 0]
  ------------------
 1680|      0|                goto fail;
 1681|      0|            }
 1682|      0|            rc = ssh_buffer_add_ssh_string(buffer, iqmp);
 1683|      0|            if (rc < 0) {
  ------------------
  |  Branch (1683:17): [True: 0, False: 0]
  ------------------
 1684|      0|                goto fail;
 1685|      0|            }
 1686|      0|            rc = ssh_buffer_add_ssh_string(buffer, p);
 1687|      0|            if (rc < 0) {
  ------------------
  |  Branch (1687:17): [True: 0, False: 0]
  ------------------
 1688|      0|                goto fail;
 1689|      0|            }
 1690|      0|            rc = ssh_buffer_add_ssh_string(buffer, q);
 1691|      0|            if (rc < 0) {
  ------------------
  |  Branch (1691:17): [True: 0, False: 0]
  ------------------
 1692|      0|                goto fail;
 1693|      0|            }
 1694|       |
 1695|      0|            ssh_string_burn(d);
 1696|      0|            SSH_STRING_FREE(d);
  ------------------
  |  |  893|      0|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (893:14): [True: 0, False: 0]
  |  |  |  Branch (893:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1697|      0|            ssh_string_burn(iqmp);
 1698|      0|            SSH_STRING_FREE(iqmp);
  ------------------
  |  |  893|      0|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (893:14): [True: 0, False: 0]
  |  |  |  Branch (893:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1699|      0|            ssh_string_burn(p);
 1700|      0|            SSH_STRING_FREE(p);
  ------------------
  |  |  893|      0|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (893:14): [True: 0, False: 0]
  |  |  |  Branch (893:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1701|      0|            ssh_string_burn(q);
 1702|      0|            SSH_STRING_FREE(q);
  ------------------
  |  |  893|      0|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (893:14): [True: 0, False: 0]
  |  |  |  Branch (893:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1703|       |#if OPENSSL_VERSION_NUMBER >= 0x30000000L
 1704|       |            bignum_safe_free(bd);
 1705|       |            bignum_safe_free(biqmp);
 1706|       |            bignum_safe_free(bp);
 1707|       |            bignum_safe_free(bq);
 1708|       |#endif /* OPENSSL_VERSION_NUMBER */
 1709|      0|        }
 1710|      0|        ssh_string_burn(e);
 1711|      0|        SSH_STRING_FREE(e);
  ------------------
  |  |  893|      0|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (893:14): [True: 0, False: 0]
  |  |  |  Branch (893:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1712|      0|        ssh_string_burn(n);
 1713|      0|        SSH_STRING_FREE(n);
  ------------------
  |  |  893|      0|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (893:14): [True: 0, False: 0]
  |  |  |  Branch (893:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1714|       |#if OPENSSL_VERSION_NUMBER >= 0x30000000L
 1715|       |        bignum_safe_free(bn);
 1716|       |        bignum_safe_free(be);
 1717|       |        OSSL_PARAM_free(params);
 1718|       |        params = NULL;
 1719|       |#endif /* OPENSSL_VERSION_NUMBER */
 1720|      0|        break;
 1721|      0|    }
 1722|  34.5k|    case SSH_KEYTYPE_ED25519:
  ------------------
  |  Branch (1722:5): [True: 34.5k, False: 0]
  ------------------
 1723|  34.5k|    case SSH_KEYTYPE_SK_ED25519:
  ------------------
  |  Branch (1723:5): [True: 0, False: 34.5k]
  ------------------
 1724|  34.5k|        rc = EVP_PKEY_get_raw_public_key(key->key, NULL, &key_len);
 1725|  34.5k|        if (rc != 1) {
  ------------------
  |  Branch (1725:13): [True: 0, False: 34.5k]
  ------------------
 1726|      0|            SSH_LOG(SSH_LOG_TRACE,
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 1727|      0|                    "Failed to get ed25519 raw public key length: %s",
 1728|      0|                    ERR_error_string(ERR_get_error(), NULL));
 1729|      0|            goto fail;
 1730|      0|        }
 1731|       |
 1732|  34.5k|        if (key_len != ED25519_KEY_LEN) {
  ------------------
  |  |   44|  34.5k|#define ED25519_KEY_LEN 32
  ------------------
  |  Branch (1732:13): [True: 0, False: 34.5k]
  ------------------
 1733|      0|            SSH_LOG(SSH_LOG_TRACE,
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 1734|      0|                    "Unexpected length of private key %zu. Expected %d.",
 1735|      0|                    key_len,
 1736|      0|                    ED25519_KEY_LEN);
 1737|      0|            goto fail;
 1738|      0|        }
 1739|       |
 1740|  34.5k|        ed25519_pubkey = malloc(key_len);
 1741|  34.5k|        if (ed25519_pubkey == NULL) {
  ------------------
  |  Branch (1741:13): [True: 0, False: 34.5k]
  ------------------
 1742|      0|            SSH_LOG(SSH_LOG_TRACE, "Out of memory");
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 1743|      0|            goto fail;
 1744|      0|        }
 1745|       |
 1746|  34.5k|        rc = EVP_PKEY_get_raw_public_key(key->key,
 1747|  34.5k|                                         (uint8_t *)ed25519_pubkey,
 1748|  34.5k|                                         &key_len);
 1749|  34.5k|        if (rc != 1) {
  ------------------
  |  Branch (1749:13): [True: 0, False: 34.5k]
  ------------------
 1750|      0|            SSH_LOG(SSH_LOG_TRACE,
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 1751|      0|                    "Failed to get ed25519 raw public key:  %s",
 1752|      0|                    ERR_error_string(ERR_get_error(), NULL));
 1753|      0|            goto fail;
 1754|      0|        }
 1755|       |
 1756|  34.5k|        rc = ssh_buffer_pack(buffer,
  ------------------
  |  |   50|  34.5k|    _ssh_buffer_pack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |  451|  34.5k|        (__VA_NARG_(__VA_ARGS__, __RSEQ_N()))
  |  |  |  |  ------------------
  |  |  |  |  |  |  453|  34.5k|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  448|  34.5k|#define VA_APPLY_VARIADIC_MACRO(macro, tuple) macro tuple
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  453|  34.5k|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  461|  34.5k|        _61,_62,_63,N,...) N
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                   _ssh_buffer_pack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |   28|  34.5k|#define SSH_BUFFER_PACK_END ((uint32_t) 0x4f65feb3)
  |  |  ------------------
  ------------------
 1757|  34.5k|                             "dP",
 1758|  34.5k|                             (uint32_t)ED25519_KEY_LEN,
 1759|  34.5k|                             (size_t)ED25519_KEY_LEN,
 1760|  34.5k|                             ed25519_pubkey);
 1761|  34.5k|        if (rc == SSH_ERROR) {
  ------------------
  |  |  317|  34.5k|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  |  Branch (1761:13): [True: 0, False: 34.5k]
  ------------------
 1762|      0|            goto fail;
 1763|      0|        }
 1764|       |
 1765|  34.5k|        if (type == SSH_KEY_PRIVATE && key->type == SSH_KEYTYPE_ED25519) {
  ------------------
  |  Branch (1765:13): [True: 0, False: 34.5k]
  |  Branch (1765:40): [True: 0, False: 0]
  ------------------
 1766|      0|            key_len = 0;
 1767|      0|            rc = EVP_PKEY_get_raw_private_key(key->key, NULL, &key_len);
 1768|      0|            if (rc != 1) {
  ------------------
  |  Branch (1768:17): [True: 0, False: 0]
  ------------------
 1769|      0|                SSH_LOG(SSH_LOG_TRACE,
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 1770|      0|                        "Failed to get ed25519 raw private key length: %s",
 1771|      0|                        ERR_error_string(ERR_get_error(), NULL));
 1772|      0|                goto fail;
 1773|      0|            }
 1774|       |
 1775|      0|            if (key_len != ED25519_KEY_LEN) {
  ------------------
  |  |   44|      0|#define ED25519_KEY_LEN 32
  ------------------
  |  Branch (1775:17): [True: 0, False: 0]
  ------------------
 1776|      0|                SSH_LOG(SSH_LOG_TRACE,
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 1777|      0|                        "Unexpected length of private key %zu. Expected %d.",
 1778|      0|                        key_len,
 1779|      0|                        ED25519_KEY_LEN);
 1780|      0|                goto fail;
 1781|      0|            }
 1782|       |
 1783|      0|            ed25519_privkey = malloc(key_len);
 1784|      0|            if (ed25519_privkey == NULL) {
  ------------------
  |  Branch (1784:17): [True: 0, False: 0]
  ------------------
 1785|      0|                SSH_LOG(SSH_LOG_TRACE, "Out of memory");
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 1786|      0|                goto fail;
 1787|      0|            }
 1788|       |
 1789|      0|            rc = EVP_PKEY_get_raw_private_key(key->key,
 1790|      0|                                              ed25519_privkey,
 1791|      0|                                              &key_len);
 1792|      0|            if (rc != 1) {
  ------------------
  |  Branch (1792:17): [True: 0, False: 0]
  ------------------
 1793|      0|                SSH_LOG(SSH_LOG_TRACE,
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 1794|      0|                        "Failed to get ed25519 raw private key: %s",
 1795|      0|                        ERR_error_string(ERR_get_error(), NULL));
 1796|      0|                goto fail;
 1797|      0|            }
 1798|       |
 1799|      0|            rc = ssh_buffer_pack(buffer,
  ------------------
  |  |   50|      0|    _ssh_buffer_pack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |  451|      0|        (__VA_NARG_(__VA_ARGS__, __RSEQ_N()))
  |  |  |  |  ------------------
  |  |  |  |  |  |  453|      0|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  448|      0|#define VA_APPLY_VARIADIC_MACRO(macro, tuple) macro tuple
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  453|      0|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  461|      0|        _61,_62,_63,N,...) N
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                   _ssh_buffer_pack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |   28|      0|#define SSH_BUFFER_PACK_END ((uint32_t) 0x4f65feb3)
  |  |  ------------------
  ------------------
 1800|      0|                                 "dPP",
 1801|      0|                                 (uint32_t)(2 * ED25519_KEY_LEN),
 1802|      0|                                 (size_t)ED25519_KEY_LEN,
 1803|      0|                                 ed25519_privkey,
 1804|      0|                                 (size_t)ED25519_KEY_LEN,
 1805|      0|                                 ed25519_pubkey);
 1806|      0|            if (rc == SSH_ERROR) {
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  |  Branch (1806:17): [True: 0, False: 0]
  ------------------
 1807|      0|                goto fail;
 1808|      0|            }
 1809|      0|            ssh_burn(ed25519_privkey, ED25519_KEY_LEN);
  ------------------
  |  |  388|      0|#define ssh_burn(ptr, len) explicit_bzero((ptr), (len))
  ------------------
 1810|      0|            SAFE_FREE(ed25519_privkey);
  ------------------
  |  |  373|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1811|  34.5k|        } else if (type == SSH_KEY_PRIVATE &&
  ------------------
  |  Branch (1811:20): [True: 0, False: 34.5k]
  ------------------
 1812|      0|                   key->type == SSH_KEYTYPE_SK_ED25519) {
  ------------------
  |  Branch (1812:20): [True: 0, False: 0]
  ------------------
 1813|       |
 1814|      0|            rc = pki_buffer_pack_sk_priv_data(buffer, key);
 1815|      0|            if (rc == SSH_ERROR) {
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  |  Branch (1815:17): [True: 0, False: 0]
  ------------------
 1816|      0|                goto fail;
 1817|      0|            }
 1818|  34.5k|        } else if (type == SSH_KEY_PUBLIC &&
  ------------------
  |  Branch (1818:20): [True: 34.5k, False: 0]
  ------------------
 1819|  34.5k|                   key->type == SSH_KEYTYPE_SK_ED25519) {
  ------------------
  |  Branch (1819:20): [True: 0, False: 34.5k]
  ------------------
 1820|       |            /* public key can contain certificate sk information */
 1821|      0|            rc = ssh_buffer_add_ssh_string(buffer, key->sk_application);
 1822|      0|            if (rc != SSH_OK) {
  ------------------
  |  |  316|      0|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (1822:17): [True: 0, False: 0]
  ------------------
 1823|      0|                goto fail;
 1824|      0|            }
 1825|      0|        }
 1826|       |
 1827|  34.5k|        SAFE_FREE(ed25519_pubkey);
  ------------------
  |  |  373|  34.5k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 34.5k, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 34.5k]
  |  |  ------------------
  ------------------
 1828|  34.5k|        break;
 1829|      0|    case SSH_KEYTYPE_ECDSA_P256:
  ------------------
  |  Branch (1829:5): [True: 0, False: 34.5k]
  ------------------
 1830|      0|    case SSH_KEYTYPE_ECDSA_P384:
  ------------------
  |  Branch (1830:5): [True: 0, False: 34.5k]
  ------------------
 1831|      0|    case SSH_KEYTYPE_ECDSA_P521:
  ------------------
  |  Branch (1831:5): [True: 0, False: 34.5k]
  ------------------
 1832|      0|    case SSH_KEYTYPE_SK_ECDSA:
  ------------------
  |  Branch (1832:5): [True: 0, False: 34.5k]
  ------------------
 1833|      0|#ifdef HAVE_OPENSSL_ECC
 1834|      0|    {
 1835|       |#if OPENSSL_VERSION_NUMBER >= 0x30000000L
 1836|       |        EC_GROUP *group = NULL;
 1837|       |        EC_POINT *point = NULL;
 1838|       |        const void *pubkey = NULL;
 1839|       |        size_t pubkey_len;
 1840|       |        OSSL_PARAM *locate_param = NULL;
 1841|       |#else
 1842|      0|        const EC_GROUP *group = NULL;
 1843|      0|        const EC_POINT *point = NULL;
 1844|      0|        const BIGNUM *exp = NULL;
 1845|      0|        EC_KEY *ec = NULL;
 1846|      0|#endif /* OPENSSL_VERSION_NUMBER */
 1847|       |
 1848|      0|        type_s = ssh_string_from_char(pki_key_ecdsa_nid_to_char(key->ecdsa_nid));
 1849|      0|        if (type_s == NULL) {
  ------------------
  |  Branch (1849:13): [True: 0, False: 0]
  ------------------
 1850|      0|            SSH_BUFFER_FREE(buffer);
  ------------------
  |  |  934|      0|    do { if ((x) != NULL) { ssh_buffer_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (934:14): [True: 0, False: 0]
  |  |  |  Branch (934:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1851|      0|            return NULL;
 1852|      0|        }
 1853|       |
 1854|      0|        rc = ssh_buffer_add_ssh_string(buffer, type_s);
 1855|      0|        SSH_STRING_FREE(type_s);
  ------------------
  |  |  893|      0|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (893:14): [True: 0, False: 0]
  |  |  |  Branch (893:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1856|      0|        if (rc < 0) {
  ------------------
  |  Branch (1856:13): [True: 0, False: 0]
  ------------------
 1857|      0|            SSH_BUFFER_FREE(buffer);
  ------------------
  |  |  934|      0|    do { if ((x) != NULL) { ssh_buffer_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (934:14): [True: 0, False: 0]
  |  |  |  Branch (934:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1858|      0|            return NULL;
 1859|      0|        }
 1860|       |
 1861|      0|#if OPENSSL_VERSION_NUMBER < 0x30000000L
 1862|      0|        ec = EVP_PKEY_get0_EC_KEY(key->key);
 1863|      0|        if (ec == NULL) {
  ------------------
  |  Branch (1863:13): [True: 0, False: 0]
  ------------------
 1864|      0|            goto fail;
 1865|      0|        }
 1866|       |#ifdef WITH_PKCS11_URI
 1867|       |        if (ssh_key_is_private(key) && !EC_KEY_get0_public_key(ec)) {
 1868|       |            SSH_LOG(SSH_LOG_TRACE,
 1869|       |                    "It is mandatory to have separate"
 1870|       |                    " public ECDSA key objects in the PKCS #11 device."
 1871|       |                    " Unlike RSA, ECDSA public keys cannot be derived"
 1872|       |                    " from their private keys.");
 1873|       |            goto fail;
 1874|       |        }
 1875|       |#endif /* WITH_PKCS11_URI */
 1876|      0|        group = EC_KEY_get0_group(ec);
 1877|      0|        point = EC_KEY_get0_public_key(ec);
 1878|      0|        if (group == NULL || point == NULL) {
  ------------------
  |  Branch (1878:13): [True: 0, False: 0]
  |  Branch (1878:30): [True: 0, False: 0]
  ------------------
 1879|      0|            goto fail;
 1880|      0|        }
 1881|      0|        e = pki_key_make_ecpoint_string(group, point);
 1882|       |#else
 1883|       |        rc = EVP_PKEY_todata(key->key, EVP_PKEY_PUBLIC_KEY, &params);
 1884|       |        if (rc < 0) {
 1885|       |            goto fail;
 1886|       |        }
 1887|       |
 1888|       |        locate_param = OSSL_PARAM_locate(params, OSSL_PKEY_PARAM_PUB_KEY);
 1889|       |#ifdef WITH_PKCS11_URI
 1890|       |        if (ssh_key_is_private(key) && !locate_param) {
 1891|       |            SSH_LOG(SSH_LOG_TRACE,
 1892|       |                    "It is mandatory to have separate"
 1893|       |                    " public ECDSA key objects in the PKCS #11 device."
 1894|       |                    " Unlike RSA, ECDSA public keys cannot be derived"
 1895|       |                    " from their private keys.");
 1896|       |            goto fail;
 1897|       |        }
 1898|       |#endif /* WITH_PKCS11_URI */
 1899|       |
 1900|       |        rc = OSSL_PARAM_get_octet_string_ptr(locate_param, &pubkey, &pubkey_len);
 1901|       |        if (rc != 1) {
 1902|       |            goto fail;
 1903|       |        }
 1904|       |        /* Convert the data to low-level representation */
 1905|       |        group = EC_GROUP_new_by_curve_name_ex(NULL, NULL, key->ecdsa_nid);
 1906|       |        point = EC_POINT_new(group);
 1907|       |        rc = EC_POINT_oct2point(group, point, pubkey, pubkey_len, NULL);
 1908|       |        if (group == NULL || point == NULL || rc != 1) {
 1909|       |            EC_GROUP_free(group);
 1910|       |            EC_POINT_free(point);
 1911|       |            goto fail;
 1912|       |        }
 1913|       |
 1914|       |        e = pki_key_make_ecpoint_string(group, point);
 1915|       |        EC_GROUP_free(group);
 1916|       |        EC_POINT_free(point);
 1917|       |#endif /* OPENSSL_VERSION_NUMBER */
 1918|      0|        if (e == NULL) {
  ------------------
  |  Branch (1918:13): [True: 0, False: 0]
  ------------------
 1919|      0|            SSH_BUFFER_FREE(buffer);
  ------------------
  |  |  934|      0|    do { if ((x) != NULL) { ssh_buffer_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (934:14): [True: 0, False: 0]
  |  |  |  Branch (934:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1920|      0|            return NULL;
 1921|      0|        }
 1922|       |
 1923|      0|        rc = ssh_buffer_add_ssh_string(buffer, e);
 1924|      0|        if (rc < 0) {
  ------------------
  |  Branch (1924:13): [True: 0, False: 0]
  ------------------
 1925|      0|            goto fail;
 1926|      0|        }
 1927|       |
 1928|      0|        ssh_string_burn(e);
 1929|      0|        SSH_STRING_FREE(e);
  ------------------
  |  |  893|      0|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (893:14): [True: 0, False: 0]
  |  |  |  Branch (893:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1930|      0|        e = NULL;
 1931|       |
 1932|      0|        if (type == SSH_KEY_PRIVATE && key->type != SSH_KEYTYPE_SK_ECDSA) {
  ------------------
  |  Branch (1932:13): [True: 0, False: 0]
  |  Branch (1932:40): [True: 0, False: 0]
  ------------------
 1933|       |#if OPENSSL_VERSION_NUMBER >= 0x30000000L
 1934|       |            OSSL_PARAM_free(params);
 1935|       |            rc = EVP_PKEY_todata(key->key, EVP_PKEY_KEYPAIR, &params);
 1936|       |            if (rc < 0) {
 1937|       |                goto fail;
 1938|       |            }
 1939|       |
 1940|       |            locate_param = OSSL_PARAM_locate(params, OSSL_PKEY_PARAM_PRIV_KEY);
 1941|       |            rc = OSSL_PARAM_get_BN(locate_param, &bd);
 1942|       |            if (rc != 1) {
 1943|       |                goto fail;
 1944|       |            }
 1945|       |            d = ssh_make_bignum_string((BIGNUM *)bd);
 1946|       |            if (d == NULL) {
 1947|       |                goto fail;
 1948|       |            }
 1949|       |            if (ssh_buffer_add_ssh_string(buffer, d) < 0) {
 1950|       |                goto fail;
 1951|       |            }
 1952|       |#else
 1953|      0|            exp = EC_KEY_get0_private_key(ec);
 1954|      0|            if (exp == NULL) {
  ------------------
  |  Branch (1954:17): [True: 0, False: 0]
  ------------------
 1955|      0|                goto fail;
 1956|      0|            }
 1957|      0|            d = ssh_make_bignum_string((BIGNUM *)exp);
 1958|      0|            if (d == NULL) {
  ------------------
  |  Branch (1958:17): [True: 0, False: 0]
  ------------------
 1959|      0|                goto fail;
 1960|      0|            }
 1961|      0|            rc = ssh_buffer_add_ssh_string(buffer, d);
 1962|      0|            if (rc < 0) {
  ------------------
  |  Branch (1962:17): [True: 0, False: 0]
  ------------------
 1963|      0|                goto fail;
 1964|      0|            }
 1965|      0|#endif /* OPENSSL_VERSION_NUMBER */
 1966|      0|            ssh_string_burn(d);
 1967|      0|            SSH_STRING_FREE(d);
  ------------------
  |  |  893|      0|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (893:14): [True: 0, False: 0]
  |  |  |  Branch (893:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1968|      0|            d = NULL;
 1969|      0|        } else if (type == SSH_KEY_PRIVATE &&
  ------------------
  |  Branch (1969:20): [True: 0, False: 0]
  ------------------
 1970|      0|                   key->type == SSH_KEYTYPE_SK_ECDSA) {
  ------------------
  |  Branch (1970:20): [True: 0, False: 0]
  ------------------
 1971|       |
 1972|      0|            rc = pki_buffer_pack_sk_priv_data(buffer, key);
 1973|      0|            if (rc == SSH_ERROR) {
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  |  Branch (1973:17): [True: 0, False: 0]
  ------------------
 1974|      0|                goto fail;
 1975|      0|            }
 1976|      0|        } else if (type == SSH_KEY_PUBLIC &&
  ------------------
  |  Branch (1976:20): [True: 0, False: 0]
  ------------------
 1977|      0|                   key->type == SSH_KEYTYPE_SK_ECDSA) {
  ------------------
  |  Branch (1977:20): [True: 0, False: 0]
  ------------------
 1978|       |            /* public key can contain certificate sk information */
 1979|      0|            rc = ssh_buffer_add_ssh_string(buffer, key->sk_application);
 1980|      0|            if (rc != SSH_OK) {
  ------------------
  |  |  316|      0|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (1980:17): [True: 0, False: 0]
  ------------------
 1981|      0|                goto fail;
 1982|      0|            }
 1983|      0|        }
 1984|       |#if OPENSSL_VERSION_NUMBER >= 0x30000000L
 1985|       |        bignum_safe_free(bd);
 1986|       |        OSSL_PARAM_free(params);
 1987|       |        params = NULL;
 1988|       |#endif /* OPENSSL_VERSION_NUMBER */
 1989|      0|        break;
 1990|      0|    }
 1991|      0|#endif /* HAVE_OPENSSL_ECC */
 1992|      0|    case SSH_KEYTYPE_UNKNOWN:
  ------------------
  |  Branch (1992:5): [True: 0, False: 34.5k]
  ------------------
 1993|      0|    default:
  ------------------
  |  Branch (1993:5): [True: 0, False: 34.5k]
  ------------------
 1994|      0|        goto fail;
 1995|  34.5k|    }
 1996|       |
 1997|  34.5k|makestring:
 1998|  34.5k|    str = ssh_string_new(ssh_buffer_get_len(buffer));
 1999|  34.5k|    if (str == NULL) {
  ------------------
  |  Branch (1999:9): [True: 0, False: 34.5k]
  ------------------
 2000|      0|        goto fail;
 2001|      0|    }
 2002|       |
 2003|  34.5k|    rc = ssh_string_fill(str, ssh_buffer_get(buffer), ssh_buffer_get_len(buffer));
 2004|  34.5k|    if (rc < 0) {
  ------------------
  |  Branch (2004:9): [True: 0, False: 34.5k]
  ------------------
 2005|      0|        goto fail;
 2006|      0|    }
 2007|  34.5k|    SSH_BUFFER_FREE(buffer);
  ------------------
  |  |  934|  34.5k|    do { if ((x) != NULL) { ssh_buffer_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (934:14): [True: 34.5k, False: 0]
  |  |  |  Branch (934:69): [Folded, False: 34.5k]
  |  |  ------------------
  ------------------
 2008|       |
 2009|  34.5k|    return str;
 2010|      0|fail:
 2011|      0|    SSH_BUFFER_FREE(buffer);
  ------------------
  |  |  934|      0|    do { if ((x) != NULL) { ssh_buffer_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (934:14): [True: 0, False: 0]
  |  |  |  Branch (934:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2012|      0|    ssh_string_burn(str);
 2013|      0|    SSH_STRING_FREE(str);
  ------------------
  |  |  893|      0|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (893:14): [True: 0, False: 0]
  |  |  |  Branch (893:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2014|      0|    ssh_string_burn(e);
 2015|      0|    SSH_STRING_FREE(e);
  ------------------
  |  |  893|      0|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (893:14): [True: 0, False: 0]
  |  |  |  Branch (893:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2016|      0|    ssh_string_burn(p);
 2017|      0|    SSH_STRING_FREE(p);
  ------------------
  |  |  893|      0|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (893:14): [True: 0, False: 0]
  |  |  |  Branch (893:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2018|      0|    ssh_string_burn(g);
 2019|      0|    SSH_STRING_FREE(g);
  ------------------
  |  |  893|      0|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (893:14): [True: 0, False: 0]
  |  |  |  Branch (893:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2020|      0|    ssh_string_burn(q);
 2021|      0|    SSH_STRING_FREE(q);
  ------------------
  |  |  893|      0|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (893:14): [True: 0, False: 0]
  |  |  |  Branch (893:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2022|      0|    ssh_string_burn(n);
 2023|      0|    SSH_STRING_FREE(n);
  ------------------
  |  |  893|      0|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (893:14): [True: 0, False: 0]
  |  |  |  Branch (893:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2024|      0|    ssh_string_burn(d);
 2025|      0|    SSH_STRING_FREE(d);
  ------------------
  |  |  893|      0|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (893:14): [True: 0, False: 0]
  |  |  |  Branch (893:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2026|      0|    ssh_string_burn(iqmp);
 2027|      0|    SSH_STRING_FREE(iqmp);
  ------------------
  |  |  893|      0|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (893:14): [True: 0, False: 0]
  |  |  |  Branch (893:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2028|       |#if OPENSSL_VERSION_NUMBER >= 0x30000000L
 2029|       |    bignum_safe_free(bp);
 2030|       |    bignum_safe_free(bq);
 2031|       |    bignum_safe_free(bg);
 2032|       |    bignum_safe_free(bpub_key);
 2033|       |    bignum_safe_free(bn);
 2034|       |    bignum_safe_free(be);
 2035|       |    bignum_safe_free(bd);
 2036|       |    bignum_safe_free(biqmp);
 2037|       |    OSSL_PARAM_free(params);
 2038|       |#endif /* OPENSSL_VERSION_NUMBER */
 2039|      0|    free(ed25519_pubkey);
 2040|      0|    if (ed25519_privkey) {
  ------------------
  |  Branch (2040:9): [True: 0, False: 0]
  ------------------
 2041|      0|        ssh_burn(ed25519_privkey, ED25519_KEY_LEN);
  ------------------
  |  |  388|      0|#define ssh_burn(ptr, len) explicit_bzero((ptr), (len))
  ------------------
 2042|      0|        free(ed25519_privkey);
 2043|      0|    }
 2044|       |
 2045|       |    return NULL;
 2046|  34.5k|}
pki_signature_to_blob:
 2136|  8.64k|{
 2137|  8.64k|    ssh_string sig_blob = NULL;
 2138|       |
 2139|  8.64k|    switch(sig->type) {
 2140|      0|        case SSH_KEYTYPE_RSA:
  ------------------
  |  Branch (2140:9): [True: 0, False: 8.64k]
  ------------------
 2141|      0|        case SSH_KEYTYPE_RSA1:
  ------------------
  |  Branch (2141:9): [True: 0, False: 8.64k]
  ------------------
 2142|      0|            sig_blob = ssh_string_copy(sig->raw_sig);
 2143|      0|            break;
 2144|  8.64k|        case SSH_KEYTYPE_ED25519:
  ------------------
  |  Branch (2144:9): [True: 8.64k, False: 0]
  ------------------
 2145|  8.64k|            sig_blob = pki_ed25519_signature_to_blob(sig);
 2146|  8.64k|            break;
 2147|      0|        case SSH_KEYTYPE_ECDSA_P256:
  ------------------
  |  Branch (2147:9): [True: 0, False: 8.64k]
  ------------------
 2148|      0|        case SSH_KEYTYPE_ECDSA_P384:
  ------------------
  |  Branch (2148:9): [True: 0, False: 8.64k]
  ------------------
 2149|      0|        case SSH_KEYTYPE_ECDSA_P521:
  ------------------
  |  Branch (2149:9): [True: 0, False: 8.64k]
  ------------------
 2150|      0|#ifdef HAVE_OPENSSL_ECC
 2151|      0|            sig_blob = pki_ecdsa_signature_to_blob(sig);
 2152|      0|            break;
 2153|      0|#endif /* HAVE_OPENSSL_ECC */
 2154|      0|        case SSH_KEYTYPE_SK_ECDSA:
  ------------------
  |  Branch (2154:9): [True: 0, False: 8.64k]
  ------------------
 2155|      0|        case SSH_KEYTYPE_SK_ED25519:
  ------------------
  |  Branch (2155:9): [True: 0, False: 8.64k]
  ------------------
 2156|       |            /* For SK keys, signature data is already in raw_sig */
 2157|      0|            sig_blob = ssh_string_copy(sig->raw_sig);
 2158|      0|            break;
 2159|      0|        default:
  ------------------
  |  Branch (2159:9): [True: 0, False: 8.64k]
  ------------------
 2160|      0|        case SSH_KEYTYPE_UNKNOWN:
  ------------------
  |  Branch (2160:9): [True: 0, False: 8.64k]
  ------------------
 2161|      0|            SSH_LOG(SSH_LOG_TRACE, "Unknown signature key type: %s", sig->type_c);
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 2162|      0|            return NULL;
 2163|  8.64k|    }
 2164|       |
 2165|  8.64k|    return sig_blob;
 2166|  8.64k|}
pki_signature_from_blob:
 2393|  8.64k|{
 2394|  8.64k|    ssh_signature sig;
 2395|  8.64k|    int rc;
 2396|       |
 2397|  8.64k|    if (ssh_key_type_plain(pubkey->type) != type) {
  ------------------
  |  Branch (2397:9): [True: 0, False: 8.64k]
  ------------------
 2398|      0|        SSH_LOG(SSH_LOG_TRACE,
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 2399|      0|                "Incompatible public key provided (%d) expecting (%d)",
 2400|      0|                type,
 2401|      0|                pubkey->type);
 2402|      0|        return NULL;
 2403|      0|    }
 2404|       |
 2405|  8.64k|    sig = ssh_signature_new();
 2406|  8.64k|    if (sig == NULL) {
  ------------------
  |  Branch (2406:9): [True: 0, False: 8.64k]
  ------------------
 2407|      0|        return NULL;
 2408|      0|    }
 2409|       |
 2410|  8.64k|    sig->type = type;
 2411|  8.64k|    sig->type_c = ssh_key_signature_to_char(type, hash_type);
 2412|  8.64k|    sig->hash_type = hash_type;
 2413|       |
 2414|  8.64k|    switch(type) {
 2415|      0|        case SSH_KEYTYPE_RSA:
  ------------------
  |  Branch (2415:9): [True: 0, False: 8.64k]
  ------------------
 2416|      0|        case SSH_KEYTYPE_RSA1:
  ------------------
  |  Branch (2416:9): [True: 0, False: 8.64k]
  ------------------
 2417|      0|            rc = pki_signature_from_rsa_blob(pubkey, sig_blob, sig);
 2418|      0|            if (rc != SSH_OK) {
  ------------------
  |  |  316|      0|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (2418:17): [True: 0, False: 0]
  ------------------
 2419|      0|                goto error;
 2420|      0|            }
 2421|      0|            break;
 2422|  8.64k|        case SSH_KEYTYPE_ED25519:
  ------------------
  |  Branch (2422:9): [True: 8.64k, False: 0]
  ------------------
 2423|  8.64k|        case SSH_KEYTYPE_SK_ED25519:
  ------------------
  |  Branch (2423:9): [True: 0, False: 8.64k]
  ------------------
 2424|  8.64k|            rc = pki_signature_from_ed25519_blob(sig, sig_blob);
 2425|  8.64k|            if (rc != SSH_OK){
  ------------------
  |  |  316|  8.64k|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (2425:17): [True: 0, False: 8.64k]
  ------------------
 2426|      0|                goto error;
 2427|      0|            }
 2428|  8.64k|            break;
 2429|  8.64k|        case SSH_KEYTYPE_ECDSA_P256:
  ------------------
  |  Branch (2429:9): [True: 0, False: 8.64k]
  ------------------
 2430|      0|        case SSH_KEYTYPE_ECDSA_P384:
  ------------------
  |  Branch (2430:9): [True: 0, False: 8.64k]
  ------------------
 2431|      0|        case SSH_KEYTYPE_ECDSA_P521:
  ------------------
  |  Branch (2431:9): [True: 0, False: 8.64k]
  ------------------
 2432|      0|        case SSH_KEYTYPE_ECDSA_P256_CERT01:
  ------------------
  |  Branch (2432:9): [True: 0, False: 8.64k]
  ------------------
 2433|      0|        case SSH_KEYTYPE_ECDSA_P384_CERT01:
  ------------------
  |  Branch (2433:9): [True: 0, False: 8.64k]
  ------------------
 2434|      0|        case SSH_KEYTYPE_ECDSA_P521_CERT01:
  ------------------
  |  Branch (2434:9): [True: 0, False: 8.64k]
  ------------------
 2435|      0|        case SSH_KEYTYPE_SK_ECDSA:
  ------------------
  |  Branch (2435:9): [True: 0, False: 8.64k]
  ------------------
 2436|      0|        case SSH_KEYTYPE_SK_ECDSA_CERT01:
  ------------------
  |  Branch (2436:9): [True: 0, False: 8.64k]
  ------------------
 2437|      0|#ifdef HAVE_OPENSSL_ECC
 2438|      0|            rc = pki_signature_from_ecdsa_blob(pubkey, sig_blob, sig);
 2439|      0|            if (rc != SSH_OK) {
  ------------------
  |  |  316|      0|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (2439:17): [True: 0, False: 0]
  ------------------
 2440|      0|                goto error;
 2441|      0|            }
 2442|      0|            break;
 2443|      0|#endif
 2444|      0|        default:
  ------------------
  |  Branch (2444:9): [True: 0, False: 8.64k]
  ------------------
 2445|      0|        case SSH_KEYTYPE_UNKNOWN:
  ------------------
  |  Branch (2445:9): [True: 0, False: 8.64k]
  ------------------
 2446|      0|            SSH_LOG(SSH_LOG_TRACE, "Unknown signature type");
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 2447|      0|            goto error;
 2448|  8.64k|    }
 2449|       |
 2450|  8.64k|    return sig;
 2451|       |
 2452|      0|error:
 2453|      0|    ssh_signature_free(sig);
 2454|       |    return NULL;
 2455|  8.64k|}
pki_sign_data:
 2549|  8.64k|{
 2550|  8.64k|    const EVP_MD *md = NULL;
 2551|  8.64k|    EVP_MD_CTX *ctx = NULL;
 2552|  8.64k|    EVP_PKEY *pkey = NULL;
 2553|       |
 2554|  8.64k|    unsigned char *raw_sig_data = NULL;
 2555|  8.64k|    size_t raw_sig_len;
 2556|       |
 2557|  8.64k|    ssh_signature sig = NULL;
 2558|       |
 2559|  8.64k|    int rc;
 2560|       |
 2561|  8.64k|    if (privkey == NULL || !ssh_key_is_private(privkey) || input == NULL) {
  ------------------
  |  Branch (2561:9): [True: 0, False: 8.64k]
  |  Branch (2561:28): [True: 0, False: 8.64k]
  |  Branch (2561:60): [True: 0, False: 8.64k]
  ------------------
 2562|      0|        SSH_LOG(SSH_LOG_TRACE, "Bad parameter provided to "
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 2563|      0|                               "pki_sign_data()");
 2564|      0|        return NULL;
 2565|      0|    }
 2566|       |
 2567|       |    /* Check if public key and hash type are compatible */
 2568|  8.64k|    rc = pki_key_check_hash_compatible(privkey, hash_type);
 2569|  8.64k|    if (rc != SSH_OK) {
  ------------------
  |  |  316|  8.64k|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (2569:9): [True: 0, False: 8.64k]
  ------------------
 2570|      0|        return NULL;
 2571|      0|    }
 2572|       |
 2573|       |    /* Set hash algorithm to be used */
 2574|  8.64k|    md = pki_digest_to_md(hash_type);
 2575|  8.64k|    if (md == NULL) {
  ------------------
  |  Branch (2575:9): [True: 8.64k, False: 0]
  ------------------
 2576|  8.64k|        if (hash_type != SSH_DIGEST_AUTO) {
  ------------------
  |  Branch (2576:13): [True: 0, False: 8.64k]
  ------------------
 2577|      0|            return NULL;
 2578|      0|        }
 2579|  8.64k|    }
 2580|       |
 2581|       |    /* Setup private key EVP_PKEY */
 2582|  8.64k|    pkey = pki_key_to_pkey(privkey);
 2583|  8.64k|    if (pkey == NULL) {
  ------------------
  |  Branch (2583:9): [True: 0, False: 8.64k]
  ------------------
 2584|      0|        return NULL;
 2585|      0|    }
 2586|       |
 2587|       |    /* Allocate buffer for signature */
 2588|  8.64k|    raw_sig_len = (size_t)EVP_PKEY_size(pkey);
 2589|  8.64k|    raw_sig_data = (unsigned char *)malloc(raw_sig_len);
 2590|  8.64k|    if (raw_sig_data == NULL) {
  ------------------
  |  Branch (2590:9): [True: 0, False: 8.64k]
  ------------------
 2591|      0|        SSH_LOG(SSH_LOG_TRACE, "Out of memory");
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 2592|      0|        goto out;
 2593|      0|    }
 2594|       |
 2595|       |    /* Create the context */
 2596|  8.64k|    ctx = EVP_MD_CTX_new();
 2597|  8.64k|    if (ctx == NULL) {
  ------------------
  |  Branch (2597:9): [True: 0, False: 8.64k]
  ------------------
 2598|      0|        SSH_LOG(SSH_LOG_TRACE, "Out of memory");
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 2599|      0|        goto out;
 2600|      0|    }
 2601|       |
 2602|       |    /* Sign the data */
 2603|  8.64k|    rc = EVP_DigestSignInit(ctx, NULL, md, NULL, pkey);
 2604|  8.64k|    if (rc != 1){
  ------------------
  |  Branch (2604:9): [True: 0, False: 8.64k]
  ------------------
 2605|      0|        SSH_LOG(SSH_LOG_TRACE,
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 2606|      0|                "EVP_DigestSignInit() failed: %s",
 2607|      0|                ERR_error_string(ERR_get_error(), NULL));
 2608|      0|        goto out;
 2609|      0|    }
 2610|       |
 2611|  8.64k|    rc = EVP_DigestSign(ctx, raw_sig_data, &raw_sig_len, input, input_len);
 2612|  8.64k|    if (rc != 1) {
  ------------------
  |  Branch (2612:9): [True: 0, False: 8.64k]
  ------------------
 2613|      0|        SSH_LOG(SSH_LOG_TRACE,
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 2614|      0|                "EVP_DigestSign() failed: %s",
 2615|      0|                ERR_error_string(ERR_get_error(), NULL));
 2616|      0|        goto out;
 2617|      0|    }
 2618|       |
 2619|       |#ifdef DEBUG_CRYPTO
 2620|       |        ssh_log_hexdump("Generated signature", raw_sig_data, raw_sig_len);
 2621|       |#endif
 2622|       |
 2623|       |    /* Allocate and fill output signature */
 2624|  8.64k|    sig = ssh_signature_new();
 2625|  8.64k|    if (sig == NULL) {
  ------------------
  |  Branch (2625:9): [True: 0, False: 8.64k]
  ------------------
 2626|      0|        goto out;
 2627|      0|    }
 2628|       |
 2629|  8.64k|    sig->raw_sig = ssh_string_new(raw_sig_len);
 2630|  8.64k|    if (sig->raw_sig == NULL) {
  ------------------
  |  Branch (2630:9): [True: 0, False: 8.64k]
  ------------------
 2631|      0|        ssh_signature_free(sig);
 2632|      0|        sig = NULL;
 2633|      0|        goto out;
 2634|      0|    }
 2635|       |
 2636|  8.64k|    rc = ssh_string_fill(sig->raw_sig, raw_sig_data, raw_sig_len);
 2637|  8.64k|    if (rc < 0) {
  ------------------
  |  Branch (2637:9): [True: 0, False: 8.64k]
  ------------------
 2638|      0|        ssh_signature_free(sig);
 2639|      0|        sig = NULL;
 2640|      0|        goto out;
 2641|      0|    }
 2642|       |
 2643|  8.64k|    sig->type = privkey->type;
 2644|  8.64k|    sig->hash_type = hash_type;
 2645|  8.64k|    sig->type_c = ssh_key_signature_to_char(privkey->type, hash_type);
 2646|       |
 2647|  8.64k|out:
 2648|  8.64k|    if (ctx != NULL) {
  ------------------
  |  Branch (2648:9): [True: 8.64k, False: 0]
  ------------------
 2649|  8.64k|        EVP_MD_CTX_free(ctx);
 2650|  8.64k|    }
 2651|  8.64k|    if (raw_sig_data != NULL) {
  ------------------
  |  Branch (2651:9): [True: 8.64k, False: 0]
  ------------------
 2652|  8.64k|        ssh_burn(raw_sig_data, raw_sig_len);
  ------------------
  |  |  388|  8.64k|#define ssh_burn(ptr, len) explicit_bzero((ptr), (len))
  ------------------
 2653|  8.64k|    }
 2654|       |    SAFE_FREE(raw_sig_data);
  ------------------
  |  |  373|  8.64k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 8.64k, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 8.64k]
  |  |  ------------------
  ------------------
 2655|  8.64k|    EVP_PKEY_free(pkey);
 2656|  8.64k|    return sig;
 2657|  8.64k|}
pki_verify_data_signature:
 2676|  8.64k|{
 2677|  8.64k|    const EVP_MD *md = NULL;
 2678|  8.64k|    EVP_MD_CTX *ctx = NULL;
 2679|  8.64k|    EVP_PKEY *pkey = NULL;
 2680|       |
 2681|  8.64k|    unsigned char *raw_sig_data = NULL;
 2682|  8.64k|    size_t raw_sig_len;
 2683|       |
 2684|       |    /* Function return code
 2685|       |     * Do not change this variable throughout the function until the signature
 2686|       |     * is successfully verified!
 2687|       |     */
 2688|  8.64k|    int rc = SSH_ERROR;
  ------------------
  |  |  317|  8.64k|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 2689|  8.64k|    int ok;
 2690|       |
 2691|  8.64k|    if (pubkey == NULL || ssh_key_is_private(pubkey) || input == NULL ||
  ------------------
  |  Branch (2691:9): [True: 0, False: 8.64k]
  |  Branch (2691:27): [True: 0, False: 8.64k]
  |  Branch (2691:57): [True: 0, False: 8.64k]
  ------------------
 2692|  8.64k|        signature == NULL || signature->raw_sig == NULL)
  ------------------
  |  Branch (2692:9): [True: 0, False: 8.64k]
  |  Branch (2692:30): [True: 0, False: 8.64k]
  ------------------
 2693|      0|    {
 2694|      0|        SSH_LOG(SSH_LOG_TRACE, "Bad parameter provided to "
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 2695|      0|                               "pki_verify_data_signature()");
 2696|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 2697|      0|    }
 2698|       |
 2699|       |    /* Check if public key and hash type are compatible */
 2700|  8.64k|    ok = pki_key_check_hash_compatible(pubkey, signature->hash_type);
 2701|  8.64k|    if (ok != SSH_OK) {
  ------------------
  |  |  316|  8.64k|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (2701:9): [True: 0, False: 8.64k]
  ------------------
 2702|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 2703|      0|    }
 2704|       |
 2705|       |    /* Get the signature to be verified */
 2706|  8.64k|    raw_sig_data = ssh_string_data(signature->raw_sig);
 2707|  8.64k|    raw_sig_len = ssh_string_len(signature->raw_sig);
 2708|  8.64k|    if (raw_sig_data == NULL) {
  ------------------
  |  Branch (2708:9): [True: 0, False: 8.64k]
  ------------------
 2709|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 2710|      0|    }
 2711|       |
 2712|       |    /* Set hash algorithm to be used */
 2713|  8.64k|    md = pki_digest_to_md(signature->hash_type);
 2714|  8.64k|    if (md == NULL) {
  ------------------
  |  Branch (2714:9): [True: 8.64k, False: 0]
  ------------------
 2715|  8.64k|        if (signature->hash_type != SSH_DIGEST_AUTO) {
  ------------------
  |  Branch (2715:13): [True: 0, False: 8.64k]
  ------------------
 2716|      0|            return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 2717|      0|        }
 2718|  8.64k|    }
 2719|       |
 2720|       |    /* Setup public key EVP_PKEY */
 2721|  8.64k|    pkey = pki_key_to_pkey(pubkey);
 2722|  8.64k|    if (pkey == NULL) {
  ------------------
  |  Branch (2722:9): [True: 0, False: 8.64k]
  ------------------
 2723|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 2724|      0|    }
 2725|       |
 2726|       |    /* Create the context */
 2727|  8.64k|    ctx = EVP_MD_CTX_new();
 2728|  8.64k|    if (ctx == NULL) {
  ------------------
  |  Branch (2728:9): [True: 0, False: 8.64k]
  ------------------
 2729|      0|        SSH_LOG(SSH_LOG_TRACE,
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 2730|      0|                "Failed to create EVP_MD_CTX: %s",
 2731|      0|                ERR_error_string(ERR_get_error(), NULL));
 2732|      0|        goto out;
 2733|      0|    }
 2734|       |
 2735|       |    /* Verify the signature */
 2736|  8.64k|    ok = EVP_DigestVerifyInit(ctx, NULL, md, NULL, pkey);
 2737|  8.64k|    if (ok != 1){
  ------------------
  |  Branch (2737:9): [True: 0, False: 8.64k]
  ------------------
 2738|      0|        SSH_LOG(SSH_LOG_TRACE,
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 2739|      0|                "EVP_DigestVerifyInit() failed: %s",
 2740|      0|                ERR_error_string(ERR_get_error(), NULL));
 2741|      0|        goto out;
 2742|      0|    }
 2743|       |
 2744|  8.64k|    ok = EVP_DigestVerify(ctx, raw_sig_data, raw_sig_len, input, input_len);
 2745|  8.64k|    if (ok != 1) {
  ------------------
  |  Branch (2745:9): [True: 0, False: 8.64k]
  ------------------
 2746|      0|        SSH_LOG(SSH_LOG_TRACE,
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 2747|      0|                "Signature invalid: %s",
 2748|      0|                ERR_error_string(ERR_get_error(), NULL));
 2749|      0|        goto out;
 2750|      0|    }
 2751|       |
 2752|  8.64k|    SSH_LOG(SSH_LOG_TRACE, "Signature valid");
  ------------------
  |  |  281|  8.64k|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 2753|  8.64k|    rc = SSH_OK;
  ------------------
  |  |  316|  8.64k|#define SSH_OK 0     /* No error */
  ------------------
 2754|       |
 2755|  8.64k|out:
 2756|  8.64k|    EVP_MD_CTX_free(ctx);
 2757|  8.64k|    EVP_PKEY_free(pkey);
 2758|  8.64k|    return rc;
 2759|  8.64k|}
pki_crypto.c:pki_digest_to_md:
 2458|  17.2k|{
 2459|  17.2k|    const EVP_MD *md = NULL;
 2460|       |
 2461|  17.2k|    switch (hash_type) {
 2462|      0|    case SSH_DIGEST_SHA256:
  ------------------
  |  Branch (2462:5): [True: 0, False: 17.2k]
  ------------------
 2463|      0|        md = EVP_sha256();
 2464|      0|        break;
 2465|      0|    case SSH_DIGEST_SHA384:
  ------------------
  |  Branch (2465:5): [True: 0, False: 17.2k]
  ------------------
 2466|      0|        md = EVP_sha384();
 2467|      0|        break;
 2468|      0|    case SSH_DIGEST_SHA512:
  ------------------
  |  Branch (2468:5): [True: 0, False: 17.2k]
  ------------------
 2469|      0|        md = EVP_sha512();
 2470|      0|        break;
 2471|      0|    case SSH_DIGEST_SHA1:
  ------------------
  |  Branch (2471:5): [True: 0, False: 17.2k]
  ------------------
 2472|      0|        md = EVP_sha1();
 2473|      0|        break;
 2474|  17.2k|    case SSH_DIGEST_AUTO:
  ------------------
  |  Branch (2474:5): [True: 17.2k, False: 0]
  ------------------
 2475|  17.2k|        md = NULL;
 2476|  17.2k|        break;
 2477|      0|    default:
  ------------------
  |  Branch (2477:5): [True: 0, False: 17.2k]
  ------------------
 2478|      0|        SSH_LOG(SSH_LOG_TRACE, "Unknown hash algorithm for type: %d",
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 2479|      0|                hash_type);
 2480|      0|        return NULL;
 2481|  17.2k|    }
 2482|       |
 2483|  17.2k|    return md;
 2484|  17.2k|}
pki_crypto.c:pki_key_to_pkey:
 2487|  17.2k|{
 2488|  17.2k|    EVP_PKEY *pkey = NULL;
 2489|  17.2k|    int rc = 0;
 2490|       |
 2491|  17.2k|    switch (key->type) {
 2492|      0|    case SSH_KEYTYPE_RSA:
  ------------------
  |  Branch (2492:5): [True: 0, False: 17.2k]
  ------------------
 2493|      0|    case SSH_KEYTYPE_RSA1:
  ------------------
  |  Branch (2493:5): [True: 0, False: 17.2k]
  ------------------
 2494|      0|    case SSH_KEYTYPE_RSA_CERT01:
  ------------------
  |  Branch (2494:5): [True: 0, False: 17.2k]
  ------------------
 2495|      0|    case SSH_KEYTYPE_ECDSA_P256:
  ------------------
  |  Branch (2495:5): [True: 0, False: 17.2k]
  ------------------
 2496|      0|    case SSH_KEYTYPE_ECDSA_P384:
  ------------------
  |  Branch (2496:5): [True: 0, False: 17.2k]
  ------------------
 2497|      0|    case SSH_KEYTYPE_ECDSA_P521:
  ------------------
  |  Branch (2497:5): [True: 0, False: 17.2k]
  ------------------
 2498|      0|    case SSH_KEYTYPE_ECDSA_P256_CERT01:
  ------------------
  |  Branch (2498:5): [True: 0, False: 17.2k]
  ------------------
 2499|      0|    case SSH_KEYTYPE_ECDSA_P384_CERT01:
  ------------------
  |  Branch (2499:5): [True: 0, False: 17.2k]
  ------------------
 2500|      0|    case SSH_KEYTYPE_ECDSA_P521_CERT01:
  ------------------
  |  Branch (2500:5): [True: 0, False: 17.2k]
  ------------------
 2501|      0|    case SSH_KEYTYPE_SK_ECDSA:
  ------------------
  |  Branch (2501:5): [True: 0, False: 17.2k]
  ------------------
 2502|      0|    case SSH_KEYTYPE_SK_ECDSA_CERT01:
  ------------------
  |  Branch (2502:5): [True: 0, False: 17.2k]
  ------------------
 2503|  17.2k|    case SSH_KEYTYPE_ED25519:
  ------------------
  |  Branch (2503:5): [True: 17.2k, False: 0]
  ------------------
 2504|  17.2k|    case SSH_KEYTYPE_ED25519_CERT01:
  ------------------
  |  Branch (2504:5): [True: 0, False: 17.2k]
  ------------------
 2505|  17.2k|    case SSH_KEYTYPE_SK_ED25519:
  ------------------
  |  Branch (2505:5): [True: 0, False: 17.2k]
  ------------------
 2506|  17.2k|    case SSH_KEYTYPE_SK_ED25519_CERT01:
  ------------------
  |  Branch (2506:5): [True: 0, False: 17.2k]
  ------------------
 2507|  17.2k|        if (key->key == NULL) {
  ------------------
  |  Branch (2507:13): [True: 0, False: 17.2k]
  ------------------
 2508|      0|            SSH_LOG(SSH_LOG_TRACE, "NULL key->key");
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 2509|      0|            goto error;
 2510|      0|        }
 2511|  17.2k|        rc = EVP_PKEY_up_ref(key->key);
 2512|  17.2k|        if (rc != 1) {
  ------------------
  |  Branch (2512:13): [True: 0, False: 17.2k]
  ------------------
 2513|      0|            SSH_LOG(SSH_LOG_TRACE, "Failed to reference EVP_PKEY");
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 2514|      0|            return NULL;
 2515|      0|        }
 2516|  17.2k|        pkey = key->key;
 2517|  17.2k|        break;
 2518|      0|    case SSH_KEYTYPE_UNKNOWN:
  ------------------
  |  Branch (2518:5): [True: 0, False: 17.2k]
  ------------------
 2519|      0|    default:
  ------------------
  |  Branch (2519:5): [True: 0, False: 17.2k]
  ------------------
 2520|      0|        SSH_LOG(SSH_LOG_TRACE, "Unknown private key algorithm for type: %d",
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 2521|      0|                key->type);
 2522|      0|        goto error;
 2523|  17.2k|    }
 2524|       |
 2525|  17.2k|    return pkey;
 2526|       |
 2527|      0|error:
 2528|      0|    EVP_PKEY_free(pkey);
 2529|       |    return NULL;
 2530|  17.2k|}

pki_ed25519_signature_to_blob:
   40|  8.64k|{
   41|  8.64k|    ssh_string sig_blob = NULL;
   42|  8.64k|    int rc;
   43|       |
   44|  8.64k|#ifdef HAVE_LIBCRYPTO
   45|       |    /* When using the OpenSSL implementation, the signature is stored in raw_sig
   46|       |     * which is shared by all algorithms.*/
   47|  8.64k|    if (sig->raw_sig == NULL) {
  ------------------
  |  Branch (47:9): [True: 0, False: 8.64k]
  ------------------
   48|      0|        return NULL;
   49|      0|    }
   50|       |#else
   51|       |    /* When using the internal implementation, the signature is stored in an
   52|       |     * algorithm specific field. */
   53|       |    if (sig->ed25519_sig == NULL) {
   54|       |        return NULL;
   55|       |    }
   56|       |#endif
   57|       |
   58|  8.64k|    sig_blob = ssh_string_new(ED25519_SIG_LEN);
  ------------------
  |  |   39|  8.64k|#define ED25519_SIG_LEN 64
  ------------------
   59|  8.64k|    if (sig_blob == NULL) {
  ------------------
  |  Branch (59:9): [True: 0, False: 8.64k]
  ------------------
   60|      0|        return NULL;
   61|      0|    }
   62|       |
   63|  8.64k|#ifdef HAVE_LIBCRYPTO
   64|  8.64k|    rc = ssh_string_fill(sig_blob, ssh_string_data(sig->raw_sig),
   65|  8.64k|                         ssh_string_len(sig->raw_sig));
   66|       |#else
   67|       |    rc = ssh_string_fill(sig_blob, sig->ed25519_sig, ED25519_SIG_LEN);
   68|       |#endif
   69|  8.64k|    if (rc < 0) {
  ------------------
  |  Branch (69:9): [True: 0, False: 8.64k]
  ------------------
   70|      0|        SSH_STRING_FREE(sig_blob);
  ------------------
  |  |  893|      0|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (893:14): [True: 0, False: 0]
  |  |  |  Branch (893:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
   71|      0|        return NULL;
   72|      0|    }
   73|       |
   74|  8.64k|    return sig_blob;
   75|  8.64k|}
pki_signature_from_ed25519_blob:
   89|  8.64k|{
   90|  8.64k|    size_t len;
   91|       |
   92|  8.64k|    len = ssh_string_len(sig_blob);
   93|  8.64k|    if (len != ED25519_SIG_LEN){
  ------------------
  |  |   39|  8.64k|#define ED25519_SIG_LEN 64
  ------------------
  |  Branch (93:9): [True: 0, False: 8.64k]
  ------------------
   94|      0|        SSH_LOG(SSH_LOG_TRACE, "Invalid ssh-ed25519 signature len: %zu", len);
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
   95|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
   96|      0|    }
   97|       |
   98|  8.64k|#ifdef HAVE_LIBCRYPTO
   99|  8.64k|    sig->raw_sig = ssh_string_copy(sig_blob);
  100|       |#else
  101|       |    sig->ed25519_sig = malloc(ED25519_SIG_LEN);
  102|       |    if (sig->ed25519_sig == NULL){
  103|       |        return SSH_ERROR;
  104|       |    }
  105|       |    memcpy(sig->ed25519_sig, ssh_string_data(sig_blob), ED25519_SIG_LEN);
  106|       |#endif
  107|       |
  108|  8.64k|    return SSH_OK;
  ------------------
  |  |  316|  8.64k|#define SSH_OK 0     /* No error */
  ------------------
  109|  8.64k|}

ssh_poll_init:
   91|      2|{
   92|      2|    return;
   93|      2|}
ssh_poll:
  115|   628k|{
  116|   628k|    return poll((struct pollfd *)fds, nfds, timeout);
  117|   628k|}
ssh_poll_new:
  396|  17.2k|{
  397|  17.2k|    ssh_poll_handle p = NULL;
  398|       |
  399|  17.2k|    p = malloc(sizeof(struct ssh_poll_handle_struct));
  400|  17.2k|    if (p == NULL) {
  ------------------
  |  Branch (400:9): [True: 0, False: 17.2k]
  ------------------
  401|      0|        return NULL;
  402|      0|    }
  403|  17.2k|    ZERO_STRUCTP(p);
  ------------------
  |  |  379|  17.2k|#define ZERO_STRUCTP(x) do { if ((x) != NULL) memset((x), 0, sizeof(*(x))); } while(0)
  |  |  ------------------
  |  |  |  Branch (379:34): [True: 17.2k, False: 0]
  |  |  |  Branch (379:85): [Folded, False: 17.2k]
  |  |  ------------------
  ------------------
  404|       |
  405|  17.2k|    p->x.fd = fd;
  406|  17.2k|    p->events = events;
  407|  17.2k|    p->cb = cb;
  408|  17.2k|    p->cb_data = userdata;
  409|       |
  410|  17.2k|    return p;
  411|  17.2k|}
ssh_poll_free:
  420|  17.2k|{
  421|  17.2k|    if (p->ctx != NULL) {
  ------------------
  |  Branch (421:9): [True: 17.2k, False: 0]
  ------------------
  422|  17.2k|        ssh_poll_ctx_remove(p->ctx, p);
  423|  17.2k|        p->ctx = NULL;
  424|  17.2k|    }
  425|       |    SAFE_FREE(p);
  ------------------
  |  |  373|  17.2k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 17.2k, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 17.2k]
  |  |  ------------------
  ------------------
  426|  17.2k|}
ssh_poll_get_ctx:
  436|   559k|{
  437|   559k|    return p->ctx;
  438|   559k|}
ssh_poll_get_events:
  448|  1.00M|{
  449|  1.00M|    return p->events;
  450|  1.00M|}
ssh_poll_set_events:
  461|  1.03M|{
  462|  1.03M|    p->events = events;
  463|  1.03M|    if (p->ctx != NULL) {
  ------------------
  |  Branch (463:9): [True: 985k, False: 51.8k]
  ------------------
  464|   985k|        if (!ssh_poll_is_locked(p)) {
  ------------------
  |  Branch (464:13): [True: 563k, False: 422k]
  ------------------
  465|   563k|            p->ctx->pollfds[p->x.idx].events = events;
  466|   563k|        } else if (!(p->ctx->pollfds[p->x.idx].events & POLLOUT)) {
  ------------------
  |  Branch (466:20): [True: 306k, False: 115k]
  ------------------
  467|       |            /* if locked, allow only setting POLLOUT to prevent recursive
  468|       |             * callbacks */
  469|       |            p->ctx->pollfds[p->x.idx].events = events & POLLOUT;
  470|   306k|        }
  471|   985k|    }
  472|  1.03M|}
ssh_poll_add_events:
  498|   848k|{
  499|   848k|    ssh_poll_set_events(p, ssh_poll_get_events(p) | events);
  500|   848k|}
ssh_poll_remove_events:
  510|   154k|{
  511|   154k|    ssh_poll_set_events(p, ssh_poll_get_events(p) & ~events);
  512|   154k|}
ssh_poll_ctx_new:
  560|  25.9k|{
  561|  25.9k|    ssh_poll_ctx ctx;
  562|       |
  563|  25.9k|    ctx = malloc(sizeof(struct ssh_poll_ctx_struct));
  564|  25.9k|    if (ctx == NULL) {
  ------------------
  |  Branch (564:9): [True: 0, False: 25.9k]
  ------------------
  565|      0|        return NULL;
  566|      0|    }
  567|  25.9k|    ZERO_STRUCTP(ctx);
  ------------------
  |  |  379|  25.9k|#define ZERO_STRUCTP(x) do { if ((x) != NULL) memset((x), 0, sizeof(*(x))); } while(0)
  |  |  ------------------
  |  |  |  Branch (379:34): [True: 25.9k, False: 0]
  |  |  |  Branch (379:85): [Folded, False: 25.9k]
  |  |  ------------------
  ------------------
  568|       |
  569|  25.9k|    if (chunk_size == 0) {
  ------------------
  |  Branch (569:9): [True: 0, False: 25.9k]
  ------------------
  570|      0|        chunk_size = SSH_POLL_CTX_CHUNK;
  ------------------
  |  |   43|      0|#define SSH_POLL_CTX_CHUNK			5
  ------------------
  571|      0|    }
  572|       |
  573|  25.9k|    ctx->chunk_size = chunk_size;
  574|       |
  575|  25.9k|    return ctx;
  576|  25.9k|}
ssh_poll_ctx_free:
  584|  25.9k|{
  585|  25.9k|    if (ctx->polls_allocated > 0) {
  ------------------
  |  Branch (585:9): [True: 25.9k, False: 0]
  ------------------
  586|  25.9k|        while (ctx->polls_used > 0) {
  ------------------
  |  Branch (586:16): [True: 0, False: 25.9k]
  ------------------
  587|      0|            ssh_poll_handle p = ctx->pollptrs[0];
  588|       |            /*
  589|       |             * The free function calls ssh_poll_ctx_remove() and decrements
  590|       |             * ctx->polls_used
  591|       |             */
  592|      0|            ssh_poll_free(p);
  593|      0|        }
  594|       |
  595|  25.9k|        SAFE_FREE(ctx->pollptrs);
  ------------------
  |  |  373|  25.9k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 25.9k, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 25.9k]
  |  |  ------------------
  ------------------
  596|  25.9k|        SAFE_FREE(ctx->pollfds);
  ------------------
  |  |  373|  25.9k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 25.9k, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 25.9k]
  |  |  ------------------
  ------------------
  597|  25.9k|    }
  598|       |
  599|       |    SAFE_FREE(ctx);
  ------------------
  |  |  373|  25.9k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 25.9k, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 25.9k]
  |  |  ------------------
  ------------------
  600|  25.9k|}
ssh_poll_ctx_add:
  647|  34.5k|{
  648|  34.5k|    socket_t fd;
  649|       |
  650|  34.5k|    if (p->ctx != NULL) {
  ------------------
  |  Branch (650:9): [True: 0, False: 34.5k]
  ------------------
  651|       |        /* already attached to a context */
  652|      0|        return -1;
  653|      0|    }
  654|       |
  655|  34.5k|    if (ctx->polls_used == ctx->polls_allocated &&
  ------------------
  |  Branch (655:9): [True: 25.9k, False: 8.64k]
  ------------------
  656|  25.9k|        ssh_poll_ctx_resize(ctx, ctx->polls_allocated + ctx->chunk_size) < 0) {
  ------------------
  |  Branch (656:9): [True: 0, False: 25.9k]
  ------------------
  657|      0|        return -1;
  658|      0|    }
  659|       |
  660|  34.5k|    fd = p->x.fd;
  661|  34.5k|    p->x.idx = ctx->polls_used++;
  662|  34.5k|    ctx->pollptrs[p->x.idx] = p;
  663|  34.5k|    ctx->pollfds[p->x.idx].fd = fd;
  664|  34.5k|    ctx->pollfds[p->x.idx].events = p->events;
  665|  34.5k|    ctx->pollfds[p->x.idx].revents = 0;
  666|  34.5k|    p->ctx = ctx;
  667|       |
  668|  34.5k|    return 0;
  669|  34.5k|}
ssh_poll_ctx_remove:
  697|  34.5k|{
  698|  34.5k|    size_t i;
  699|       |
  700|  34.5k|    i = p->x.idx;
  701|  34.5k|    p->x.fd = ctx->pollfds[i].fd;
  702|  34.5k|    p->ctx = NULL;
  703|       |
  704|  34.5k|    ctx->polls_used--;
  705|       |
  706|       |    /* fill the empty poll slot with the last one */
  707|  34.5k|    if (ctx->polls_used > 0 && ctx->polls_used != i) {
  ------------------
  |  Branch (707:9): [True: 0, False: 34.5k]
  |  Branch (707:32): [True: 0, False: 0]
  ------------------
  708|      0|        ctx->pollfds[i] = ctx->pollfds[ctx->polls_used];
  709|      0|        ctx->pollptrs[i] = ctx->pollptrs[ctx->polls_used];
  710|      0|        ctx->pollptrs[i]->x.idx = i;
  711|      0|    }
  712|       |
  713|       |    /* this will always leave at least chunk_size polls allocated */
  714|  34.5k|    if (ctx->polls_allocated - ctx->polls_used > ctx->chunk_size) {
  ------------------
  |  Branch (714:9): [True: 0, False: 34.5k]
  ------------------
  715|      0|        ssh_poll_ctx_resize(ctx, ctx->polls_allocated - ctx->chunk_size);
  716|      0|    }
  717|  34.5k|}
ssh_poll_is_locked:
  726|  1.63M|{
  727|  1.63M|    if (p == NULL) {
  ------------------
  |  Branch (727:9): [True: 0, False: 1.63M]
  ------------------
  728|      0|        return false;
  729|      0|    }
  730|  1.63M|    return p->lock_cnt > 0;
  731|  1.63M|}
ssh_poll_ctx_dopoll:
  750|   628k|{
  751|   628k|    int rc;
  752|   628k|    size_t i, used;
  753|   628k|    ssh_poll_handle p = NULL;
  754|   628k|    socket_t fd;
  755|   628k|    int revents;
  756|   628k|    struct ssh_timestamp ts;
  757|       |
  758|   628k|    if (ctx->polls_used == 0) {
  ------------------
  |  Branch (758:9): [True: 0, False: 628k]
  ------------------
  759|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  760|      0|    }
  761|       |
  762|       |    /* Allow only POLLOUT events on locked sockets as that means we are called
  763|       |     * recursively and we only want process the POLLOUT events here to flush
  764|       |     * output buffer */
  765|  1.25M|    for (i = 0; i < ctx->polls_used; i++) {
  ------------------
  |  Branch (765:17): [True: 628k, False: 628k]
  ------------------
  766|       |        /* The lock allows only POLLOUT events: drop the rest */
  767|   628k|        if (ssh_poll_is_locked(ctx->pollptrs[i])) {
  ------------------
  |  Branch (767:13): [True: 21.7k, False: 606k]
  ------------------
  768|  21.7k|            ctx->pollfds[i].events &= POLLOUT;
  769|  21.7k|        }
  770|   628k|    }
  771|   628k|    ssh_timestamp_init(&ts);
  772|   628k|    do {
  773|   628k|        int tm = ssh_timeout_update(&ts, timeout);
  774|   628k|        rc = ssh_poll(ctx->pollfds, ctx->polls_used, tm);
  775|   628k|    } while (rc == -1 && errno == EINTR);
  ------------------
  |  Branch (775:14): [True: 0, False: 628k]
  |  Branch (775:26): [True: 0, False: 0]
  ------------------
  776|       |
  777|   628k|    if (rc < 0) {
  ------------------
  |  Branch (777:9): [True: 0, False: 628k]
  ------------------
  778|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  779|      0|    }
  780|   628k|    if (rc == 0) {
  ------------------
  |  Branch (780:9): [True: 0, False: 628k]
  ------------------
  781|      0|        return SSH_AGAIN;
  ------------------
  |  |  318|      0|#define SSH_AGAIN -2 /* The nonblocking call must be repeated */
  ------------------
  782|      0|    }
  783|       |
  784|   628k|    used = ctx->polls_used;
  785|  1.24M|    for (i = 0; i < used && rc > 0; ) {
  ------------------
  |  Branch (785:17): [True: 628k, False: 620k]
  |  Branch (785:29): [True: 628k, False: 0]
  ------------------
  786|   628k|        revents = ctx->pollfds[i].revents;
  787|       |        /* Do not pass any other events except for POLLOUT to callback when
  788|       |         * called recursively more than 2 times. On s390x the poll will be
  789|       |         * spammed with POLLHUP events causing infinite recursion when the user
  790|       |         * callback issues some write/flush/poll calls. */
  791|   628k|        if (ctx->pollptrs[i]->lock_cnt > 2) {
  ------------------
  |  Branch (791:13): [True: 0, False: 628k]
  ------------------
  792|      0|            revents &= POLLOUT;
  793|      0|        }
  794|   628k|        if (revents == 0) {
  ------------------
  |  Branch (794:13): [True: 0, False: 628k]
  ------------------
  795|      0|            i++;
  796|   628k|        } else {
  797|   628k|            int ret;
  798|       |
  799|   628k|            p = ctx->pollptrs[i];
  800|   628k|            fd = ctx->pollfds[i].fd;
  801|       |            /* avoid having any event caught during callback */
  802|   628k|            ctx->pollfds[i].events = 0;
  803|   628k|            p->lock_cnt++;
  804|   628k|            if (p->cb && (ret = p->cb(p, fd, revents, p->cb_data)) < 0) {
  ------------------
  |  Branch (804:17): [True: 628k, False: 3]
  |  Branch (804:26): [True: 8.63k, False: 620k]
  ------------------
  805|  8.63k|                if (ret == -2) {
  ------------------
  |  Branch (805:21): [True: 8.63k, False: 0]
  ------------------
  806|  8.63k|                    return -1;
  807|  8.63k|                }
  808|       |                /* the poll was removed, reload the used counter and start again
  809|       |                 */
  810|      0|                used = ctx->polls_used;
  811|      0|                i = 0;
  812|   620k|            } else {
  813|   620k|                ctx->pollfds[i].revents = 0;
  814|   620k|                ctx->pollfds[i].events = p->events;
  815|   620k|                p->lock_cnt--;
  816|   620k|                i++;
  817|   620k|            }
  818|       |
  819|   620k|            rc--;
  820|   620k|        }
  821|   628k|    }
  822|       |
  823|   620k|    return rc;
  824|   628k|}
ssh_poll_get_default_ctx:
  834|  17.2k|{
  835|  17.2k|    if (session->default_poll_ctx != NULL) {
  ------------------
  |  Branch (835:9): [True: 0, False: 17.2k]
  ------------------
  836|      0|        return session->default_poll_ctx;
  837|      0|    }
  838|       |    /* 2 is enough for the default one */
  839|  17.2k|    session->default_poll_ctx = ssh_poll_ctx_new(2);
  840|  17.2k|    return session->default_poll_ctx;
  841|  17.2k|}
ssh_event_new:
  866|  8.64k|{
  867|  8.64k|    ssh_event event;
  868|       |
  869|  8.64k|    event = malloc(sizeof(struct ssh_event_struct));
  870|  8.64k|    if (event == NULL) {
  ------------------
  |  Branch (870:9): [True: 0, False: 8.64k]
  ------------------
  871|      0|        return NULL;
  872|      0|    }
  873|  8.64k|    ZERO_STRUCTP(event);
  ------------------
  |  |  379|  8.64k|#define ZERO_STRUCTP(x) do { if ((x) != NULL) memset((x), 0, sizeof(*(x))); } while(0)
  |  |  ------------------
  |  |  |  Branch (379:34): [True: 8.64k, False: 0]
  |  |  |  Branch (379:85): [Folded, False: 8.64k]
  |  |  ------------------
  ------------------
  874|       |
  875|  8.64k|    event->ctx = ssh_poll_ctx_new(2);
  876|  8.64k|    if (event->ctx == NULL) {
  ------------------
  |  Branch (876:9): [True: 0, False: 8.64k]
  ------------------
  877|      0|        free(event);
  878|      0|        return NULL;
  879|      0|    }
  880|       |
  881|  8.64k|#ifdef WITH_SERVER
  882|  8.64k|    event->sessions = ssh_list_new();
  883|  8.64k|    if (event->sessions == NULL) {
  ------------------
  |  Branch (883:9): [True: 0, False: 8.64k]
  ------------------
  884|      0|        ssh_poll_ctx_free(event->ctx);
  885|      0|        free(event);
  886|      0|        return NULL;
  887|      0|    }
  888|  8.64k|#endif
  889|       |
  890|  8.64k|    return event;
  891|  8.64k|}
ssh_event_add_session:
 1000|  8.64k|{
 1001|  8.64k|    ssh_poll_handle p = NULL;
 1002|  8.64k|#ifdef WITH_SERVER
 1003|  8.64k|    struct ssh_iterator *iterator = NULL;
 1004|  8.64k|#endif
 1005|  8.64k|    int rc;
 1006|       |
 1007|  8.64k|    if (event == NULL || event->ctx == NULL || session == NULL) {
  ------------------
  |  Branch (1007:9): [True: 0, False: 8.64k]
  |  Branch (1007:26): [True: 0, False: 8.64k]
  |  Branch (1007:48): [True: 0, False: 8.64k]
  ------------------
 1008|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 1009|      0|    }
 1010|  8.64k|    if (session->default_poll_ctx == NULL) {
  ------------------
  |  Branch (1010:9): [True: 0, False: 8.64k]
  ------------------
 1011|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 1012|      0|    }
 1013|  17.2k|    while (session->default_poll_ctx->polls_used > 0) {
  ------------------
  |  Branch (1013:12): [True: 8.64k, False: 8.64k]
  ------------------
 1014|  8.64k|        p = session->default_poll_ctx->pollptrs[0];
 1015|       |        /*
 1016|       |         * ssh_poll_ctx_remove() decrements
 1017|       |         * session->default_poll_ctx->polls_used
 1018|       |         */
 1019|  8.64k|        ssh_poll_ctx_remove(session->default_poll_ctx, p);
 1020|  8.64k|        rc = ssh_poll_ctx_add(event->ctx, p);
 1021|  8.64k|        if (rc != SSH_OK) {
  ------------------
  |  |  316|  8.64k|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (1021:13): [True: 0, False: 8.64k]
  ------------------
 1022|      0|            return rc;
 1023|      0|        }
 1024|       |        /* associate the pollhandler with a session so we can put it back
 1025|       |         * at ssh_event_free()
 1026|       |         */
 1027|  8.64k|        p->session = session;
 1028|  8.64k|    }
 1029|  8.64k|#ifdef WITH_SERVER
 1030|  8.64k|    iterator = ssh_list_get_iterator(event->sessions);
 1031|  8.64k|    while (iterator != NULL) {
  ------------------
  |  Branch (1031:12): [True: 0, False: 8.64k]
  ------------------
 1032|      0|        if ((ssh_session)iterator->data == session) {
  ------------------
  |  Branch (1032:13): [True: 0, False: 0]
  ------------------
 1033|       |            /* allow only one instance of this session */
 1034|      0|            return SSH_OK;
  ------------------
  |  |  316|      0|#define SSH_OK 0     /* No error */
  ------------------
 1035|      0|        }
 1036|      0|        iterator = iterator->next;
 1037|      0|    }
 1038|  8.64k|    if (ssh_list_append(event->sessions, session) == SSH_ERROR) {
  ------------------
  |  |  317|  8.64k|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  |  Branch (1038:9): [True: 0, False: 8.64k]
  ------------------
 1039|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 1040|      0|    }
 1041|  8.64k|#endif
 1042|  8.64k|    return SSH_OK;
  ------------------
  |  |  316|  8.64k|#define SSH_OK 0     /* No error */
  ------------------
 1043|  8.64k|}
ssh_event_dopoll:
 1082|  69.1k|{
 1083|  69.1k|    int rc;
 1084|       |
 1085|  69.1k|    if (event == NULL || event->ctx == NULL) {
  ------------------
  |  Branch (1085:9): [True: 0, False: 69.1k]
  |  Branch (1085:26): [True: 0, False: 69.1k]
  ------------------
 1086|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 1087|      0|    }
 1088|  69.1k|    rc = ssh_poll_ctx_dopoll(event->ctx, timeout);
 1089|  69.1k|    return rc;
 1090|  69.1k|}
ssh_event_free:
 1220|  8.64k|{
 1221|  8.64k|    size_t used, i;
 1222|  8.64k|    ssh_poll_handle p = NULL;
 1223|       |
 1224|  8.64k|    if (event == NULL) {
  ------------------
  |  Branch (1224:9): [True: 0, False: 8.64k]
  ------------------
 1225|      0|        return;
 1226|      0|    }
 1227|       |
 1228|  8.64k|    if (event->ctx != NULL) {
  ------------------
  |  Branch (1228:9): [True: 8.64k, False: 0]
  ------------------
 1229|  8.64k|        used = event->ctx->polls_used;
 1230|  17.2k|        for (i = 0; i < used; i++) {
  ------------------
  |  Branch (1230:21): [True: 8.64k, False: 8.64k]
  ------------------
 1231|  8.64k|            p = event->ctx->pollptrs[i];
 1232|  8.64k|            if (p->session != NULL) {
  ------------------
  |  Branch (1232:17): [True: 8.64k, False: 0]
  ------------------
 1233|  8.64k|                ssh_poll_ctx_remove(event->ctx, p);
 1234|  8.64k|                ssh_poll_ctx_add(p->session->default_poll_ctx, p);
 1235|  8.64k|                p->session = NULL;
 1236|  8.64k|                used = 0;
 1237|  8.64k|            }
 1238|  8.64k|        }
 1239|       |
 1240|  8.64k|        ssh_poll_ctx_free(event->ctx);
 1241|  8.64k|    }
 1242|  8.64k|#ifdef WITH_SERVER
 1243|  8.64k|    if (event->sessions != NULL) {
  ------------------
  |  Branch (1243:9): [True: 8.64k, False: 0]
  ------------------
 1244|  8.64k|        ssh_list_free(event->sessions);
 1245|  8.64k|    }
 1246|  8.64k|#endif
 1247|  8.64k|    free(event);
 1248|  8.64k|}
poll.c:ssh_poll_ctx_resize:
  603|  25.9k|{
  604|  25.9k|    ssh_poll_handle *pollptrs = NULL;
  605|  25.9k|    ssh_pollfd_t *pollfds = NULL;
  606|       |
  607|  25.9k|    pollptrs = realloc(ctx->pollptrs, sizeof(ssh_poll_handle) * new_size);
  608|  25.9k|    if (pollptrs == NULL) {
  ------------------
  |  Branch (608:9): [True: 0, False: 25.9k]
  ------------------
  609|       |        /* Fail, but keep the old value to be freed later */
  610|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  611|      0|    }
  612|  25.9k|    ctx->pollptrs = pollptrs;
  613|       |
  614|  25.9k|    pollfds = realloc(ctx->pollfds, sizeof(ssh_pollfd_t) * new_size);
  615|  25.9k|    if (pollfds == NULL) {
  ------------------
  |  Branch (615:9): [True: 0, False: 25.9k]
  ------------------
  616|      0|        if (ctx->polls_allocated == 0) {
  ------------------
  |  Branch (616:13): [True: 0, False: 0]
  ------------------
  617|       |            /* This was initial allocation -- just free what we allocated above
  618|       |             * and fail */
  619|      0|            SAFE_FREE(ctx->pollptrs);
  ------------------
  |  |  373|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
  620|      0|            return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  621|      0|        }
  622|       |        /* Try to realloc the pollptrs back to the original size */
  623|      0|        pollptrs = realloc(ctx->pollptrs,
  624|      0|                           sizeof(ssh_poll_handle) * ctx->polls_allocated);
  625|      0|        if (pollptrs == NULL) {
  ------------------
  |  Branch (625:13): [True: 0, False: 0]
  ------------------
  626|      0|            return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  627|      0|        }
  628|      0|        ctx->pollptrs = pollptrs;
  629|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  630|      0|    }
  631|       |
  632|  25.9k|    ctx->pollfds = pollfds;
  633|  25.9k|    ctx->polls_allocated = new_size;
  634|       |
  635|  25.9k|    return SSH_OK;
  ------------------
  |  |  316|  25.9k|#define SSH_OK 0     /* No error */
  ------------------
  636|  25.9k|}

ssh_scp_new:
   67|  8.64k|{
   68|  8.64k|    ssh_scp scp = NULL;
   69|       |
   70|  8.64k|    if (session == NULL || location == NULL) {
  ------------------
  |  Branch (70:9): [True: 0, False: 8.64k]
  |  Branch (70:28): [True: 0, False: 8.64k]
  ------------------
   71|      0|        goto error;
   72|      0|    }
   73|       |
   74|  8.64k|    scp = (ssh_scp)calloc(1, sizeof(struct ssh_scp_struct));
   75|  8.64k|    if (scp == NULL) {
  ------------------
  |  Branch (75:9): [True: 0, False: 8.64k]
  ------------------
   76|      0|        ssh_set_error(session, SSH_FATAL,
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
   77|      0|                      "Error allocating memory for ssh_scp");
   78|      0|        goto error;
   79|      0|    }
   80|       |
   81|  8.64k|    if ((mode & ~SSH_SCP_RECURSIVE) != SSH_SCP_WRITE &&
  ------------------
  |  Branch (81:9): [True: 8.64k, False: 2]
  ------------------
   82|  8.64k|        (mode & ~SSH_SCP_RECURSIVE) != SSH_SCP_READ)
  ------------------
  |  Branch (82:9): [True: 0, False: 8.64k]
  ------------------
   83|      0|    {
   84|      0|        ssh_set_error(session, SSH_FATAL,
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
   85|      0|                      "Invalid mode %d for ssh_scp_new()", mode);
   86|      0|        goto error;
   87|      0|    }
   88|       |
   89|  8.64k|    if (strlen(location) > 32 * 1024) {
  ------------------
  |  Branch (89:9): [True: 0, False: 8.64k]
  ------------------
   90|      0|        ssh_set_error(session, SSH_FATAL,
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
   91|      0|                      "Location path is too long");
   92|      0|        goto error;
   93|      0|    }
   94|       |
   95|  8.64k|    scp->location = strdup(location);
   96|  8.64k|    if (scp->location == NULL) {
  ------------------
  |  Branch (96:9): [True: 0, False: 8.64k]
  ------------------
   97|      0|        ssh_set_error(session, SSH_FATAL,
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
   98|      0|                      "Error allocating memory for ssh_scp");
   99|      0|        goto error;
  100|      0|    }
  101|       |
  102|  8.64k|    scp->session = session;
  103|  8.64k|    scp->mode = mode & ~SSH_SCP_RECURSIVE;
  104|  8.64k|    scp->recursive = (mode & SSH_SCP_RECURSIVE) != 0;
  105|  8.64k|    scp->channel = NULL;
  106|  8.64k|    scp->state = SSH_SCP_NEW;
  107|       |
  108|  8.64k|    return scp;
  109|       |
  110|      0|error:
  111|      0|    ssh_scp_free(scp);
  112|       |    return NULL;
  113|  8.64k|}
ssh_scp_init:
  127|  8.64k|{
  128|  8.64k|    int rc;
  129|  8.64k|    char execbuffer[PATH_MAX] = {0};
  130|  8.64k|    char *quoted_location = NULL;
  131|  8.64k|    size_t quoted_location_len = 0;
  132|  8.64k|    size_t scp_location_len;
  133|       |
  134|  8.64k|    if (scp == NULL) {
  ------------------
  |  Branch (134:9): [True: 0, False: 8.64k]
  ------------------
  135|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  136|      0|    }
  137|       |
  138|  8.64k|    if (scp->state != SSH_SCP_NEW) {
  ------------------
  |  Branch (138:9): [True: 0, False: 8.64k]
  ------------------
  139|      0|        ssh_set_error(scp->session, SSH_FATAL,
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  140|      0|                      "ssh_scp_init called under invalid state");
  141|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  142|      0|    }
  143|       |
  144|  8.64k|    if (scp->location == NULL) {
  ------------------
  |  Branch (144:9): [True: 0, False: 8.64k]
  ------------------
  145|      0|        ssh_set_error(scp->session, SSH_FATAL,
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  146|      0|                      "Invalid scp context: location is NULL");
  147|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  148|      0|    }
  149|       |
  150|  8.64k|    SSH_LOG(SSH_LOG_DEBUG, "Initializing scp session %s %son location '%s'",
  ------------------
  |  |  281|  34.5k|    _ssh_log(priority, __func__, __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (281:34): [True: 2, False: 8.64k]
  |  |  |  Branch (281:34): [True: 2, False: 8.64k]
  |  |  ------------------
  ------------------
  151|  8.64k|            scp->mode == SSH_SCP_WRITE?"write":"read",
  152|  8.64k|            scp->recursive ? "recursive " : "",
  153|  8.64k|            scp->location);
  154|       |
  155|  8.64k|    scp->channel = ssh_channel_new(scp->session);
  156|  8.64k|    if (scp->channel == NULL) {
  ------------------
  |  Branch (156:9): [True: 0, False: 8.64k]
  ------------------
  157|      0|        ssh_set_error(scp->session, SSH_FATAL,
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  158|      0|                      "Channel creation failed for scp");
  159|      0|        scp->state = SSH_SCP_ERROR;
  160|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  161|      0|    }
  162|       |
  163|  8.64k|    rc = ssh_channel_open_session(scp->channel);
  164|  8.64k|    if (rc == SSH_ERROR) {
  ------------------
  |  |  317|  8.64k|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  |  Branch (164:9): [True: 2, False: 8.64k]
  ------------------
  165|      2|        ssh_set_error(scp->session, SSH_FATAL,
  ------------------
  |  |  311|      2|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  166|      2|                      "Failed to open channel for scp");
  167|      2|        scp->state = SSH_SCP_ERROR;
  168|      2|        return SSH_ERROR;
  ------------------
  |  |  317|      2|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  169|      2|    }
  170|       |
  171|       |    /* In the worst case, each character would be replaced by 3 plus the string
  172|       |     * terminator '\0' */
  173|  8.64k|    scp_location_len = strlen(scp->location);
  174|  8.64k|    quoted_location_len = ((size_t)3 * scp_location_len) + 1;
  175|       |    /* Paranoia check */
  176|  8.64k|    if (quoted_location_len < scp_location_len) {
  ------------------
  |  Branch (176:9): [True: 0, False: 8.64k]
  ------------------
  177|      0|        ssh_set_error(scp->session, SSH_FATAL,
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  178|      0|                      "Buffer overflow detected");
  179|      0|        scp->state = SSH_SCP_ERROR;
  180|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  181|      0|    }
  182|       |
  183|  8.64k|    quoted_location = (char *)calloc(1, quoted_location_len);
  184|  8.64k|    if (quoted_location == NULL) {
  ------------------
  |  Branch (184:9): [True: 0, False: 8.64k]
  ------------------
  185|      0|        ssh_set_error(scp->session, SSH_FATAL,
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  186|      0|                      "Failed to allocate memory for quoted location");
  187|      0|        scp->state = SSH_SCP_ERROR;
  188|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  189|      0|    }
  190|       |
  191|  8.64k|    rc = ssh_quote_file_name(scp->location, quoted_location,
  192|  8.64k|                             quoted_location_len);
  193|  8.64k|    if (rc <= 0) {
  ------------------
  |  Branch (193:9): [True: 0, False: 8.64k]
  ------------------
  194|      0|        ssh_set_error(scp->session, SSH_FATAL,
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  195|      0|                      "Failed to single quote command location");
  196|      0|        SAFE_FREE(quoted_location);
  ------------------
  |  |  373|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
  197|      0|        scp->state = SSH_SCP_ERROR;
  198|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  199|      0|    }
  200|       |
  201|       |    /* Some servers do not handle the quoting well. Pass in the raw file
  202|       |     * location */
  203|  8.64k|    if (scp->session->flags & SSH_SESSION_FLAG_SCP_QUOTING_BROKEN) {
  ------------------
  |  |   95|  8.64k|#define SSH_SESSION_FLAG_SCP_QUOTING_BROKEN 0x0040
  ------------------
  |  Branch (203:9): [True: 0, False: 8.64k]
  ------------------
  204|      0|        free(quoted_location);
  205|      0|        quoted_location = strdup(scp->location);
  206|      0|        if (quoted_location == NULL) {
  ------------------
  |  Branch (206:13): [True: 0, False: 0]
  ------------------
  207|      0|            ssh_set_error_oom(scp->session);
  ------------------
  |  |  318|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
  208|      0|            return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  209|      0|        }
  210|      0|    }
  211|       |
  212|  8.64k|    if (scp->mode == SSH_SCP_WRITE) {
  ------------------
  |  Branch (212:9): [True: 0, False: 8.64k]
  ------------------
  213|      0|        snprintf(execbuffer, sizeof(execbuffer), "scp -t %s %s",
  214|      0|                scp->recursive ? "-r" : "", quoted_location);
  ------------------
  |  Branch (214:17): [True: 0, False: 0]
  ------------------
  215|  8.64k|    } else {
  216|  8.64k|        snprintf(execbuffer, sizeof(execbuffer), "scp -f %s %s",
  217|  8.64k|                scp->recursive ? "-r" : "", quoted_location);
  ------------------
  |  Branch (217:17): [True: 0, False: 8.64k]
  ------------------
  218|  8.64k|    }
  219|       |
  220|  8.64k|    SAFE_FREE(quoted_location);
  ------------------
  |  |  373|  8.64k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 8.64k, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 8.64k]
  |  |  ------------------
  ------------------
  221|       |
  222|  8.64k|    SSH_LOG(SSH_LOG_DEBUG, "Executing command: %s", execbuffer);
  ------------------
  |  |  281|  8.64k|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  223|       |
  224|  8.64k|    rc = ssh_channel_request_exec(scp->channel, execbuffer);
  225|  8.64k|    if (rc == SSH_ERROR){
  ------------------
  |  |  317|  8.64k|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  |  Branch (225:9): [True: 8.63k, False: 2]
  ------------------
  226|  8.63k|        ssh_set_error(scp->session, SSH_FATAL,
  ------------------
  |  |  311|  8.63k|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  227|  8.63k|                      "Failed executing command: %s", execbuffer);
  228|  8.63k|        scp->state = SSH_SCP_ERROR;
  229|  8.63k|        return SSH_ERROR;
  ------------------
  |  |  317|  8.63k|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  230|  8.63k|    }
  231|       |
  232|      2|    if (scp->mode == SSH_SCP_WRITE) {
  ------------------
  |  Branch (232:9): [True: 0, False: 2]
  ------------------
  233|      0|        rc = ssh_scp_response(scp, NULL);
  234|      0|        if (rc != 0) {
  ------------------
  |  Branch (234:13): [True: 0, False: 0]
  ------------------
  235|      0|            return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  236|      0|        }
  237|      2|    } else {
  238|      2|        ssh_channel_write(scp->channel, "", 1);
  239|      2|    }
  240|       |
  241|      2|    if (scp->mode == SSH_SCP_WRITE) {
  ------------------
  |  Branch (241:9): [True: 0, False: 2]
  ------------------
  242|      0|        scp->state = SSH_SCP_WRITE_INITED;
  243|      2|    } else {
  244|      2|        scp->state = SSH_SCP_READ_INITED;
  245|      2|    }
  246|       |
  247|      2|    return SSH_OK;
  ------------------
  |  |  316|      2|#define SSH_OK 0     /* No error */
  ------------------
  248|      2|}
ssh_scp_close:
  262|  8.64k|{
  263|  8.64k|    char buffer[128] = {0};
  264|  8.64k|    int rc;
  265|       |
  266|  8.64k|    if (scp == NULL) {
  ------------------
  |  Branch (266:9): [True: 0, False: 8.64k]
  ------------------
  267|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  268|      0|    }
  269|       |
  270|  8.64k|    if (scp->channel != NULL) {
  ------------------
  |  Branch (270:9): [True: 8.64k, False: 0]
  ------------------
  271|  8.64k|        if (ssh_channel_send_eof(scp->channel) == SSH_ERROR) {
  ------------------
  |  |  317|  8.64k|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  |  Branch (271:13): [True: 8, False: 8.63k]
  ------------------
  272|      8|            scp->state = SSH_SCP_ERROR;
  273|      8|            return SSH_ERROR;
  ------------------
  |  |  317|      8|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  274|      8|        }
  275|       |        /* avoid situations where data are buffered and
  276|       |         * not yet stored on disk. This can happen if the close is sent
  277|       |         * before we got the EOF back
  278|       |         */
  279|  8.63k|        while (!ssh_channel_is_eof(scp->channel)) {
  ------------------
  |  Branch (279:16): [True: 8.63k, False: 0]
  ------------------
  280|  8.63k|            rc = ssh_channel_read(scp->channel, buffer, sizeof(buffer), 0);
  281|  8.63k|            if (rc == SSH_ERROR || rc == SSH_AGAIN || rc == 0) {
  ------------------
  |  |  317|  17.2k|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
                          if (rc == SSH_ERROR || rc == SSH_AGAIN || rc == 0) {
  ------------------
  |  |  318|  8.63k|#define SSH_AGAIN -2 /* The nonblocking call must be repeated */
  ------------------
  |  Branch (281:17): [True: 8.63k, False: 0]
  |  Branch (281:36): [True: 0, False: 0]
  |  Branch (281:55): [True: 0, False: 0]
  ------------------
  282|  8.63k|                break;
  283|  8.63k|            }
  284|  8.63k|        }
  285|       |
  286|  8.63k|        if (ssh_channel_close(scp->channel) == SSH_ERROR) {
  ------------------
  |  |  317|  8.63k|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  |  Branch (286:13): [True: 0, False: 8.63k]
  ------------------
  287|      0|            scp->state = SSH_SCP_ERROR;
  288|      0|            return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  289|      0|        }
  290|       |
  291|  8.63k|        ssh_channel_free(scp->channel);
  292|  8.63k|        scp->channel = NULL;
  293|  8.63k|    }
  294|       |
  295|  8.63k|    scp->state = SSH_SCP_NEW;
  296|  8.63k|    return SSH_OK;
  ------------------
  |  |  316|  8.63k|#define SSH_OK 0     /* No error */
  ------------------
  297|  8.64k|}
ssh_scp_free:
  309|  8.64k|{
  310|  8.64k|    if (scp == NULL) {
  ------------------
  |  Branch (310:9): [True: 0, False: 8.64k]
  ------------------
  311|      0|        return;
  312|      0|    }
  313|       |
  314|  8.64k|    if (scp->state != SSH_SCP_NEW) {
  ------------------
  |  Branch (314:9): [True: 4, False: 8.63k]
  ------------------
  315|      4|        ssh_scp_close(scp);
  316|      4|    }
  317|       |
  318|  8.64k|    if (scp->channel) {
  ------------------
  |  Branch (318:9): [True: 4, False: 8.63k]
  ------------------
  319|      4|        ssh_channel_free(scp->channel);
  320|      4|    }
  321|       |
  322|  8.64k|    SAFE_FREE(scp->location);
  ------------------
  |  |  373|  8.64k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 8.64k, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 8.64k]
  |  |  ------------------
  ------------------
  323|  8.64k|    SAFE_FREE(scp->request_name);
  ------------------
  |  |  373|  8.64k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 8.64k]
  |  |  |  Branch (373:71): [Folded, False: 8.64k]
  |  |  ------------------
  ------------------
  324|  8.64k|    SAFE_FREE(scp->warning);
  ------------------
  |  |  373|  8.64k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 8.64k]
  |  |  |  Branch (373:71): [Folded, False: 8.64k]
  |  |  ------------------
  ------------------
  325|       |    SAFE_FREE(scp);
  ------------------
  |  |  373|  8.64k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 8.64k, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 8.64k]
  |  |  ------------------
  ------------------
  326|  8.64k|}
ssh_scp_read_string:
  760|      4|{
  761|      4|    size_t read = 0;
  762|      4|    int err = SSH_OK;
  ------------------
  |  |  316|      4|#define SSH_OK 0     /* No error */
  ------------------
  763|       |
  764|      4|    if (scp == NULL) {
  ------------------
  |  Branch (764:9): [True: 0, False: 4]
  ------------------
  765|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  766|      0|    }
  767|       |
  768|  16.3k|    while (read < len - 1) {
  ------------------
  |  Branch (768:12): [True: 16.3k, False: 4]
  ------------------
  769|  16.3k|        err = ssh_channel_read(scp->channel, &buffer[read], 1, 0);
  770|  16.3k|        if (err == SSH_ERROR) {
  ------------------
  |  |  317|  16.3k|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  |  Branch (770:13): [True: 0, False: 16.3k]
  ------------------
  771|      0|            break;
  772|      0|        }
  773|       |
  774|  16.3k|        if (err == 0) {
  ------------------
  |  Branch (774:13): [True: 0, False: 16.3k]
  ------------------
  775|      0|            ssh_set_error(scp->session, SSH_FATAL,
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  776|      0|                          "End of file while reading string");
  777|      0|            err = SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  778|      0|            break;
  779|      0|        }
  780|       |
  781|  16.3k|        if (err == SSH_AGAIN) {
  ------------------
  |  |  318|  16.3k|#define SSH_AGAIN -2 /* The nonblocking call must be repeated */
  ------------------
  |  Branch (781:13): [True: 0, False: 16.3k]
  ------------------
  782|      0|            ssh_set_error(scp->session,
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  783|      0|                          SSH_FATAL,
  784|      0|                          "SCP: ssh_channel_read timeout");
  785|      0|            err = SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  786|      0|            break;
  787|      0|        }
  788|       |
  789|  16.3k|        read++;
  790|  16.3k|        if (buffer[read - 1] == '\n') {
  ------------------
  |  Branch (790:13): [True: 0, False: 16.3k]
  ------------------
  791|      0|            break;
  792|      0|        }
  793|  16.3k|    }
  794|       |
  795|      4|    buffer[read] = 0;
  796|      4|    return err;
  797|      4|}
ssh_scp_pull_request:
  822|      4|{
  823|      4|    char buffer[PATH_MAX] = {0};
  824|      4|    char *mode = NULL;
  825|      4|    char *p, *tmp;
  826|      4|    uint64_t size;
  827|      4|    char *name = NULL;
  828|      4|    int rc;
  829|       |
  830|      4|    if (scp == NULL) {
  ------------------
  |  Branch (830:9): [True: 0, False: 4]
  ------------------
  831|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  832|      0|    }
  833|       |
  834|      4|    if (scp->state != SSH_SCP_READ_INITED) {
  ------------------
  |  Branch (834:9): [True: 0, False: 4]
  ------------------
  835|      0|        ssh_set_error(scp->session, SSH_FATAL,
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  836|      0|                      "ssh_scp_pull_request called under invalid state");
  837|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  838|      0|    }
  839|       |
  840|      4|    rc = ssh_scp_read_string(scp, buffer, sizeof(buffer));
  841|      4|    if (rc == SSH_ERROR) {
  ------------------
  |  |  317|      4|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  |  Branch (841:9): [True: 0, False: 4]
  ------------------
  842|      0|        if (ssh_channel_is_eof(scp->channel)) {
  ------------------
  |  Branch (842:13): [True: 0, False: 0]
  ------------------
  843|      0|            scp->state = SSH_SCP_TERMINATED;
  844|      0|            return SSH_SCP_REQUEST_EOF;
  845|      0|        }
  846|      0|        return rc;
  847|      0|    }
  848|       |
  849|      4|    p = strchr(buffer, '\n');
  850|      4|    if (p != NULL) {
  ------------------
  |  Branch (850:9): [True: 0, False: 4]
  ------------------
  851|      0|        *p = '\0';
  852|      0|    }
  853|       |
  854|      4|    SSH_LOG(SSH_LOG_DEBUG, "Received SCP request: '%s'", buffer);
  ------------------
  |  |  281|      4|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  855|      4|    switch(buffer[0]) {
  856|      1|    case 'C':
  ------------------
  |  Branch (856:5): [True: 1, False: 3]
  ------------------
  857|       |        /* File */
  858|      1|    case 'D':
  ------------------
  |  Branch (858:5): [True: 0, False: 4]
  ------------------
  859|       |        /* Directory */
  860|      1|        p = strchr(buffer, ' ');
  861|      1|        if (p == NULL) {
  ------------------
  |  Branch (861:13): [True: 1, False: 0]
  ------------------
  862|      1|            goto error;
  863|      1|        }
  864|      0|        *p = '\0';
  865|      0|        p++;
  866|       |        //mode = strdup(&buffer[1]);
  867|      0|        scp->request_mode = ssh_scp_integer_mode(&buffer[1]);
  868|      0|        tmp = p;
  869|      0|        p = strchr(p, ' ');
  870|      0|        if (p == NULL) {
  ------------------
  |  Branch (870:13): [True: 0, False: 0]
  ------------------
  871|      0|            goto error;
  872|      0|        }
  873|      0|        *p = 0;
  874|      0|        size = strtoull(tmp, NULL, 10);
  875|      0|        p++;
  876|      0|        name = strdup(p);
  877|       |        /* Catch invalid name:
  878|       |         *  - empty ones
  879|       |         *  - containing any forward slash -- directory traversal handled
  880|       |         *    differently
  881|       |         *  - special names "." and ".." referring to the current and parent
  882|       |         *    directories -- they are not expected either
  883|       |         */
  884|      0|        if (name == NULL || name[0] == '\0' || strchr(name, '/') ||
  ------------------
  |  Branch (884:13): [True: 0, False: 0]
  |  Branch (884:29): [True: 0, False: 0]
  |  Branch (884:48): [True: 0, False: 0]
  ------------------
  885|      0|            strcmp(name, ".") == 0 || strcmp(name, "..") == 0) {
  ------------------
  |  Branch (885:13): [True: 0, False: 0]
  |  Branch (885:39): [True: 0, False: 0]
  ------------------
  886|      0|            ssh_set_error(scp->session,
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (311:43): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  887|      0|                          SSH_FATAL,
  888|      0|                          "Received invalid filename: %s",
  889|      0|                          name == NULL ? "<NULL>" : name);
  890|      0|            SAFE_FREE(name);
  ------------------
  |  |  373|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
  891|      0|            goto error;
  892|      0|        }
  893|      0|        SAFE_FREE(scp->request_name);
  ------------------
  |  |  373|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
  894|      0|        scp->request_name = name;
  895|      0|        if (buffer[0] == 'C') {
  ------------------
  |  Branch (895:13): [True: 0, False: 0]
  ------------------
  896|      0|            scp->filelen = size;
  897|      0|            scp->request_type = SSH_SCP_REQUEST_NEWFILE;
  898|      0|        } else {
  899|      0|            scp->filelen = '0';
  900|      0|            scp->request_type = SSH_SCP_REQUEST_NEWDIR;
  901|      0|        }
  902|      0|        scp->state = SSH_SCP_READ_REQUESTED;
  903|      0|        scp->processed = 0;
  904|      0|        return scp->request_type;
  905|      0|        break;
  906|      0|    case 'E':
  ------------------
  |  Branch (906:5): [True: 0, False: 4]
  ------------------
  907|      0|        scp->request_type = SSH_SCP_REQUEST_ENDDIR;
  908|      0|        ssh_channel_write(scp->channel, "", 1);
  909|      0|        return scp->request_type;
  910|      0|    case 0x1:
  ------------------
  |  Branch (910:5): [True: 0, False: 4]
  ------------------
  911|      0|        ssh_set_error(scp->session, SSH_REQUEST_DENIED,
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  912|      0|                      "SCP: Warning: %s", &buffer[1]);
  913|      0|        scp->request_type = SSH_SCP_REQUEST_WARNING;
  914|      0|        SAFE_FREE(scp->warning);
  ------------------
  |  |  373|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
  915|      0|        scp->warning = strdup(&buffer[1]);
  916|      0|        return scp->request_type;
  917|      0|    case 0x2:
  ------------------
  |  Branch (917:5): [True: 0, False: 4]
  ------------------
  918|      0|        ssh_set_error(scp->session, SSH_FATAL,
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  919|      0|                      "SCP: Error: %s", &buffer[1]);
  920|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  921|      0|    case 'T':
  ------------------
  |  Branch (921:5): [True: 0, False: 4]
  ------------------
  922|       |        /* Timestamp */
  923|      3|    default:
  ------------------
  |  Branch (923:5): [True: 3, False: 1]
  ------------------
  924|      3|        ssh_set_error(scp->session, SSH_FATAL,
  ------------------
  |  |  311|      3|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  925|      3|                      "Unhandled message: (%d)%s", buffer[0], buffer);
  926|      3|        return SSH_ERROR;
  ------------------
  |  |  317|      3|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  927|      4|    }
  928|       |
  929|       |    /* a parsing error occurred */
  930|      1|error:
  931|      1|    SAFE_FREE(name);
  ------------------
  |  |  373|      1|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 1]
  |  |  |  Branch (373:71): [Folded, False: 1]
  |  |  ------------------
  ------------------
  932|      1|    SAFE_FREE(mode);
  ------------------
  |  |  373|      1|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 1]
  |  |  |  Branch (373:71): [Folded, False: 1]
  |  |  ------------------
  ------------------
  933|      1|    ssh_set_error(scp->session, SSH_FATAL,
  ------------------
  |  |  311|      1|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  934|      1|                  "Parsing error while parsing message: %s", buffer);
  935|      1|    return SSH_ERROR;
  ------------------
  |  |  317|      1|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  936|      4|}
ssh_scp_deny_request:
  952|      2|{
  953|      2|    char *buffer = NULL;
  954|      2|    size_t len;
  955|      2|    int rc;
  956|       |
  957|      2|    if (scp == NULL) {
  ------------------
  |  Branch (957:9): [True: 0, False: 2]
  ------------------
  958|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  959|      0|    }
  960|       |
  961|      2|    if (scp->state != SSH_SCP_READ_REQUESTED) {
  ------------------
  |  Branch (961:9): [True: 2, False: 0]
  ------------------
  962|      2|        ssh_set_error(scp->session, SSH_FATAL,
  ------------------
  |  |  311|      2|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  963|      2|                      "ssh_scp_deny_request called under invalid state");
  964|      2|        return SSH_ERROR;
  ------------------
  |  |  317|      2|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  965|      2|    }
  966|       |
  967|      0|    len = strlen(reason) + 3;
  968|      0|    buffer = malloc(len);
  969|      0|    if (buffer == NULL) {
  ------------------
  |  Branch (969:9): [True: 0, False: 0]
  ------------------
  970|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  971|      0|    }
  972|       |
  973|      0|    snprintf(buffer, len, "%c%s\n", 2, reason);
  974|      0|    rc = ssh_channel_write(scp->channel, buffer, len - 1);
  975|      0|    free(buffer);
  976|      0|    if (rc == SSH_ERROR) {
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  |  Branch (976:9): [True: 0, False: 0]
  ------------------
  977|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  978|      0|    }
  979|       |
  980|      0|    else {
  981|      0|        scp->state = SSH_SCP_READ_INITED;
  982|      0|        return SSH_OK;
  ------------------
  |  |  316|      0|#define SSH_OK 0     /* No error */
  ------------------
  983|      0|    }
  984|      0|}
ssh_scp_accept_request:
  998|      2|{
  999|      2|    char buffer[] = {0x00};
 1000|      2|    int rc;
 1001|      2|    if (scp == NULL) {
  ------------------
  |  Branch (1001:9): [True: 0, False: 2]
  ------------------
 1002|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 1003|      0|    }
 1004|       |
 1005|      2|    if (scp->state != SSH_SCP_READ_REQUESTED) {
  ------------------
  |  Branch (1005:9): [True: 2, False: 0]
  ------------------
 1006|      2|        ssh_set_error(scp->session, SSH_FATAL,
  ------------------
  |  |  311|      2|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
 1007|      2|                      "ssh_scp_deny_request called under invalid state");
 1008|      2|        return SSH_ERROR;
  ------------------
  |  |  317|      2|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 1009|      2|    }
 1010|       |
 1011|      0|    rc = ssh_channel_write(scp->channel, buffer, 1);
 1012|      0|    if (rc == SSH_ERROR) {
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  |  Branch (1012:9): [True: 0, False: 0]
  ------------------
 1013|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 1014|      0|    }
 1015|       |
 1016|      0|    if (scp->request_type == SSH_SCP_REQUEST_NEWFILE) {
  ------------------
  |  Branch (1016:9): [True: 0, False: 0]
  ------------------
 1017|      0|        scp->state = SSH_SCP_READ_READING;
 1018|      0|    } else {
 1019|      0|        scp->state = SSH_SCP_READ_INITED;
 1020|      0|    }
 1021|       |
 1022|      0|    return SSH_OK;
  ------------------
  |  |  316|      0|#define SSH_OK 0     /* No error */
  ------------------
 1023|      0|}
ssh_scp_read:
 1040|      2|{
 1041|      2|    int rc;
 1042|      2|    int code;
 1043|       |
 1044|      2|    if (scp == NULL) {
  ------------------
  |  Branch (1044:9): [True: 0, False: 2]
  ------------------
 1045|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 1046|      0|    }
 1047|       |
 1048|      2|    if (scp->state == SSH_SCP_READ_REQUESTED &&
  ------------------
  |  Branch (1048:9): [True: 0, False: 2]
  ------------------
 1049|      0|        scp->request_type == SSH_SCP_REQUEST_NEWFILE)
  ------------------
  |  Branch (1049:9): [True: 0, False: 0]
  ------------------
 1050|      0|    {
 1051|      0|        rc = ssh_scp_accept_request(scp);
 1052|      0|        if (rc == SSH_ERROR) {
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  |  Branch (1052:13): [True: 0, False: 0]
  ------------------
 1053|      0|            return rc;
 1054|      0|        }
 1055|      0|    }
 1056|       |
 1057|      2|    if (scp->state != SSH_SCP_READ_READING) {
  ------------------
  |  Branch (1057:9): [True: 2, False: 0]
  ------------------
 1058|      2|        ssh_set_error(scp->session, SSH_FATAL,
  ------------------
  |  |  311|      2|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
 1059|      2|                      "ssh_scp_read called under invalid state");
 1060|      2|        return SSH_ERROR;
  ------------------
  |  |  317|      2|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 1061|      2|    }
 1062|       |
 1063|      0|    if (scp->processed + size > scp->filelen) {
  ------------------
  |  Branch (1063:9): [True: 0, False: 0]
  ------------------
 1064|      0|        size = (size_t) (scp->filelen - scp->processed);
 1065|      0|    }
 1066|       |
 1067|      0|    if (size > 65536) {
  ------------------
  |  Branch (1067:9): [True: 0, False: 0]
  ------------------
 1068|      0|        size = 65536; /* avoid too large reads */
 1069|      0|    }
 1070|       |
 1071|      0|    rc = ssh_channel_read(scp->channel, buffer, size, 0);
 1072|      0|    if (rc == SSH_ERROR) {
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  |  Branch (1072:9): [True: 0, False: 0]
  ------------------
 1073|      0|        scp->state = SSH_SCP_ERROR;
 1074|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 1075|      0|    }
 1076|      0|    if (rc == SSH_AGAIN) {
  ------------------
  |  |  318|      0|#define SSH_AGAIN -2 /* The nonblocking call must be repeated */
  ------------------
  |  Branch (1076:9): [True: 0, False: 0]
  ------------------
 1077|      0|        ssh_set_error(scp->session, SSH_FATAL, "SCP: ssh_channel_read timeout");
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
 1078|      0|        scp->state = SSH_SCP_ERROR;
 1079|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 1080|      0|    }
 1081|      0|    scp->processed += rc;
 1082|       |
 1083|       |    /* Check if we arrived at end of file */
 1084|      0|    if (scp->processed == scp->filelen) {
  ------------------
  |  Branch (1084:9): [True: 0, False: 0]
  ------------------
 1085|      0|        scp->processed = scp->filelen = 0;
 1086|      0|        ssh_channel_write(scp->channel, "", 1);
 1087|      0|        code = ssh_scp_response(scp, NULL);
 1088|      0|        if (code == 0) {
  ------------------
  |  Branch (1088:13): [True: 0, False: 0]
  ------------------
 1089|      0|            scp->state = SSH_SCP_READ_INITED;
 1090|      0|            return rc;
 1091|      0|        }
 1092|      0|        if (code == 1) {
  ------------------
  |  Branch (1092:13): [True: 0, False: 0]
  ------------------
 1093|      0|            scp->state = SSH_SCP_READ_INITED;
 1094|      0|            return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 1095|      0|        }
 1096|      0|        scp->state = SSH_SCP_ERROR;
 1097|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 1098|      0|    }
 1099|       |
 1100|      0|    return rc;
 1101|      0|}
ssh_scp_request_get_filename:
 1113|      2|{
 1114|      2|    if (scp == NULL) {
  ------------------
  |  Branch (1114:9): [True: 0, False: 2]
  ------------------
 1115|      0|        return NULL;
 1116|      0|    }
 1117|       |
 1118|      2|    return scp->request_name;
 1119|      2|}
ssh_scp_request_get_permissions:
 1130|      2|{
 1131|      2|    if (scp == NULL) {
  ------------------
  |  Branch (1131:9): [True: 0, False: 2]
  ------------------
 1132|      0|        return -1;
 1133|      0|    }
 1134|       |
 1135|      2|    return scp->request_mode;
 1136|      2|}
ssh_scp_request_get_size:
 1149|      2|{
 1150|      2|    if (scp == NULL) {
  ------------------
  |  Branch (1150:9): [True: 0, False: 2]
  ------------------
 1151|      0|        return 0;
 1152|      0|    }
 1153|      2|    return (size_t)scp->filelen;
 1154|      2|}
ssh_scp_request_get_size64:
 1164|      2|{
 1165|      2|    if (scp == NULL) {
  ------------------
  |  Branch (1165:9): [True: 0, False: 2]
  ------------------
 1166|      0|        return 0;
 1167|      0|    }
 1168|      2|    return scp->filelen;
 1169|      2|}
ssh_scp_request_get_warning:
 1214|      2|{
 1215|      2|    if (scp == NULL) {
  ------------------
  |  Branch (1215:9): [True: 0, False: 2]
  ------------------
 1216|      0|        return NULL;
 1217|      0|    }
 1218|       |
 1219|      2|    return scp->warning;
 1220|      2|}

server_set_kex:
   93|  17.2k|{
   94|  17.2k|    struct ssh_kex_struct *server = &session->next_crypto->server_kex;
   95|  17.2k|    int i, j, rc;
   96|  17.2k|    const char *wanted = NULL, *allowed = NULL;
   97|  17.2k|    char *kept = NULL;
   98|  17.2k|    char hostkeys[128] = {0};
   99|  17.2k|    enum ssh_keytypes_e keytype;
  100|  17.2k|    size_t len;
  101|  17.2k|    int ok;
  102|       |#ifdef WITH_GSSAPI
  103|       |    char *gssapi_algs = NULL;
  104|       |#endif /* WITH_GSSAPI */
  105|       |
  106|       |    /* Skip if already set, for example for the rekey or when we do the guessing
  107|       |     * it could have been already used to make some protocol decisions. */
  108|  17.2k|    if (server->methods[0] != NULL) {
  ------------------
  |  Branch (108:9): [True: 8.64k, False: 8.64k]
  ------------------
  109|  8.64k|        return SSH_OK;
  ------------------
  |  |  316|  8.64k|#define SSH_OK 0     /* No error */
  ------------------
  110|  8.64k|    }
  111|       |
  112|  8.64k|    ok = ssh_get_random(server->cookie, 16, 0);
  113|  8.64k|    if (!ok) {
  ------------------
  |  Branch (113:9): [True: 0, False: 8.64k]
  ------------------
  114|      0|        ssh_set_error(session, SSH_FATAL, "PRNG error");
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  115|      0|        return -1;
  116|      0|    }
  117|       |
  118|  8.64k|    if (session->srv.ed25519_key != NULL) {
  ------------------
  |  Branch (118:9): [True: 8.64k, False: 0]
  ------------------
  119|  8.64k|        snprintf(hostkeys,
  120|  8.64k|                 sizeof(hostkeys),
  121|  8.64k|                 "%s",
  122|  8.64k|                 ssh_key_type_to_char(ssh_key_type(session->srv.ed25519_key)));
  123|  8.64k|    }
  124|  8.64k|#ifdef HAVE_ECC
  125|  8.64k|    if (session->srv.ecdsa_key != NULL) {
  ------------------
  |  Branch (125:9): [True: 0, False: 8.64k]
  ------------------
  126|      0|        len = strlen(hostkeys);
  127|      0|        snprintf(hostkeys + len, sizeof(hostkeys) - len,
  128|      0|                 ",%s", session->srv.ecdsa_key->type_c);
  129|      0|    }
  130|  8.64k|#endif
  131|  8.64k|    if (session->srv.rsa_key != NULL) {
  ------------------
  |  Branch (131:9): [True: 0, False: 8.64k]
  ------------------
  132|       |        /* We support also the SHA2 variants */
  133|      0|        len = strlen(hostkeys);
  134|      0|        snprintf(hostkeys + len, sizeof(hostkeys) - len,
  135|      0|                 ",rsa-sha2-512,rsa-sha2-256");
  136|       |
  137|      0|        len = strlen(hostkeys);
  138|      0|        keytype = ssh_key_type(session->srv.rsa_key);
  139|       |
  140|      0|        snprintf(hostkeys + len, sizeof(hostkeys) - len,
  141|      0|                 ",%s", ssh_key_type_to_char(keytype));
  142|      0|    }
  143|       |
  144|  8.64k|    if (session->opts.wanted_methods[SSH_HOSTKEYS]) {
  ------------------
  |  Branch (144:9): [True: 0, False: 8.64k]
  ------------------
  145|      0|        allowed = session->opts.wanted_methods[SSH_HOSTKEYS];
  146|  8.64k|    } else {
  147|  8.64k|        if (ssh_fips_mode()) {
  ------------------
  |  |  115|  8.64k|#define ssh_fips_mode() (FIPS_mode() != 0)
  |  |  ------------------
  |  |  |  Branch (115:25): [True: 0, False: 8.64k]
  |  |  ------------------
  ------------------
  148|      0|            allowed = ssh_kex_get_fips_methods(SSH_HOSTKEYS);
  149|  8.64k|        } else {
  150|  8.64k|            allowed = ssh_kex_get_default_methods(SSH_HOSTKEYS);
  151|  8.64k|        }
  152|  8.64k|    }
  153|       |
  154|  8.64k|    if (strlen(hostkeys) != 0) {
  ------------------
  |  Branch (154:9): [True: 8.64k, False: 0]
  ------------------
  155|       |        /* It is expected for the list of allowed hostkeys to be ordered by
  156|       |         * preference */
  157|  8.64k|        kept =
  158|  8.64k|            ssh_find_all_matching(hostkeys[0] == ',' ? hostkeys + 1 : hostkeys,
  ------------------
  |  Branch (158:35): [True: 0, False: 8.64k]
  ------------------
  159|  8.64k|                                  allowed);
  160|  8.64k|        if (kept == NULL) {
  ------------------
  |  Branch (160:13): [True: 0, False: 8.64k]
  ------------------
  161|       |            /* Nothing was allowed */
  162|      0|            return -1;
  163|      0|        }
  164|       |
  165|  8.64k|        rc = ssh_options_set_algo(session,
  166|  8.64k|                                  SSH_HOSTKEYS,
  167|  8.64k|                                  kept,
  168|  8.64k|                                  &session->opts.wanted_methods[SSH_HOSTKEYS]);
  169|  8.64k|        SAFE_FREE(kept);
  ------------------
  |  |  373|  8.64k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 8.64k, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 8.64k]
  |  |  ------------------
  ------------------
  170|  8.64k|        if (rc < 0) {
  ------------------
  |  Branch (170:13): [True: 0, False: 8.64k]
  ------------------
  171|      0|            return -1;
  172|      0|        }
  173|  8.64k|    }
  174|       |#ifdef WITH_GSSAPI
  175|       |    if (session->opts.gssapi_key_exchange) {
  176|       |        ok = ssh_gssapi_init(session);
  177|       |        if (ok != SSH_OK) {
  178|       |            ssh_set_error_oom(session);
  179|       |            return SSH_ERROR;
  180|       |        }
  181|       |
  182|       |        gssapi_algs = ssh_gssapi_kex_mechs(session);
  183|       |        if (gssapi_algs == NULL) {
  184|       |            return SSH_ERROR;
  185|       |        }
  186|       |        ssh_gssapi_free(session);
  187|       |
  188|       |        /* Prefix the default algorithms with gsskex algs */
  189|       |        session->opts.wanted_methods[SSH_KEX] =
  190|       |            ssh_prefix_without_duplicates(ssh_kex_get_default_methods(SSH_KEX),
  191|       |                                          gssapi_algs);
  192|       |
  193|       |        if (strlen(hostkeys) == 0) {
  194|       |            session->opts.wanted_methods[SSH_HOSTKEYS] = strdup("null");
  195|       |        }
  196|       |
  197|       |        SAFE_FREE(gssapi_algs);
  198|       |    }
  199|       |#endif /* WITH_GSSAPI */
  200|       |
  201|  95.0k|    for (i = 0; i < SSH_KEX_METHODS; i++) {
  ------------------
  |  |   27|  95.0k|#define SSH_KEX_METHODS 10
  ------------------
  |  Branch (201:17): [True: 86.4k, False: 8.64k]
  ------------------
  202|  86.4k|        wanted = session->opts.wanted_methods[i];
  203|  86.4k|        if (wanted == NULL) {
  ------------------
  |  Branch (203:13): [True: 43.2k, False: 43.2k]
  ------------------
  204|  43.2k|            if (ssh_fips_mode()) {
  ------------------
  |  |  115|  43.2k|#define ssh_fips_mode() (FIPS_mode() != 0)
  |  |  ------------------
  |  |  |  Branch (115:25): [True: 0, False: 43.2k]
  |  |  ------------------
  ------------------
  205|      0|                wanted = ssh_kex_get_fips_methods(i);
  206|  43.2k|            } else {
  207|  43.2k|                wanted = ssh_kex_get_default_methods(i);
  208|  43.2k|            }
  209|  43.2k|        }
  210|  86.4k|        if (wanted == NULL) {
  ------------------
  |  Branch (210:13): [True: 0, False: 86.4k]
  ------------------
  211|      0|            for (j = 0; j < i; j++) {
  ------------------
  |  Branch (211:25): [True: 0, False: 0]
  ------------------
  212|      0|                SAFE_FREE(server->methods[j]);
  ------------------
  |  |  373|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
  213|      0|            }
  214|      0|            return -1;
  215|      0|        }
  216|       |
  217|  86.4k|        server->methods[i] = strdup(wanted);
  218|  86.4k|        if (server->methods[i] == NULL) {
  ------------------
  |  Branch (218:13): [True: 0, False: 86.4k]
  ------------------
  219|      0|            for (j = 0; j < i; j++) {
  ------------------
  |  Branch (219:25): [True: 0, False: 0]
  ------------------
  220|      0|                SAFE_FREE(server->methods[j]);
  ------------------
  |  |  373|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
  221|      0|            }
  222|      0|            return -1;
  223|      0|        }
  224|  86.4k|    }
  225|       |
  226|       |    /* Do not append the extensions during rekey */
  227|  8.64k|    if (session->flags & SSH_SESSION_FLAG_AUTHENTICATED) {
  ------------------
  |  |   78|  8.64k|#define SSH_SESSION_FLAG_AUTHENTICATED 0x0002
  ------------------
  |  Branch (227:9): [True: 0, False: 8.64k]
  ------------------
  228|      0|        return SSH_OK;
  ------------------
  |  |  316|      0|#define SSH_OK 0     /* No error */
  ------------------
  229|      0|    }
  230|       |
  231|  8.64k|    rc = ssh_kex_append_extensions(session, server);
  232|  8.64k|    return rc;
  233|  8.64k|}
ssh_packet_kexdh_init:
  310|  8.64k|SSH_PACKET_CALLBACK(ssh_packet_kexdh_init){
  311|  8.64k|  (void)packet;
  312|  8.64k|  (void)type;
  313|  8.64k|  (void)user;
  314|       |
  315|  8.64k|  SSH_LOG(SSH_LOG_PACKET,"Received SSH_MSG_KEXDH_INIT");
  ------------------
  |  |  281|  8.64k|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  316|  8.64k|  if(session->dh_handshake_state != DH_STATE_INIT){
  ------------------
  |  Branch (316:6): [True: 0, False: 8.64k]
  ------------------
  317|      0|    SSH_LOG(SSH_LOG_RARE,"Invalid state for SSH_MSG_KEXDH_INIT");
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  318|      0|    session->session_state = SSH_SESSION_STATE_ERROR;
  319|      0|    return SSH_PACKET_USED;
  ------------------
  |  |  637|      0|#define SSH_PACKET_USED 1
  ------------------
  320|      0|  }
  321|       |
  322|       |  /* If first_kex_packet_follows guess was wrong, ignore this message. */
  323|  8.64k|  if (session->first_kex_follows_guess_wrong != 0) {
  ------------------
  |  Branch (323:7): [True: 0, False: 8.64k]
  ------------------
  324|      0|    SSH_LOG(SSH_LOG_RARE, "first_kex_packet_follows guess was wrong, "
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  325|      0|                          "ignoring first SSH_MSG_KEXDH_INIT message");
  326|      0|    session->first_kex_follows_guess_wrong = 0;
  327|       |
  328|      0|    return SSH_PACKET_USED;
  ------------------
  |  |  637|      0|#define SSH_PACKET_USED 1
  ------------------
  329|      0|  }
  330|  8.64k|  SSH_LOG(SSH_LOG_DEBUG, "Calling next KEXDH handler");
  ------------------
  |  |  281|  8.64k|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  331|  8.64k|  return SSH_PACKET_NOT_USED;
  ------------------
  |  |  640|  8.64k|#define SSH_PACKET_NOT_USED 2
  ------------------
  332|  8.64k|}
ssh_get_key_params:
  354|  8.64k|{
  355|  8.64k|    ssh_key pubkey = NULL;
  356|  8.64k|    ssh_string pubkey_blob = NULL;
  357|  8.64k|    int rc;
  358|       |
  359|  8.64k|    switch(session->srv.hostkey) {
  360|      0|      case SSH_KEYTYPE_RSA:
  ------------------
  |  Branch (360:7): [True: 0, False: 8.64k]
  ------------------
  361|      0|        *privkey = session->srv.rsa_key;
  362|      0|        break;
  363|      0|      case SSH_KEYTYPE_ECDSA_P256:
  ------------------
  |  Branch (363:7): [True: 0, False: 8.64k]
  ------------------
  364|      0|      case SSH_KEYTYPE_ECDSA_P384:
  ------------------
  |  Branch (364:7): [True: 0, False: 8.64k]
  ------------------
  365|      0|      case SSH_KEYTYPE_ECDSA_P521:
  ------------------
  |  Branch (365:7): [True: 0, False: 8.64k]
  ------------------
  366|      0|        *privkey = session->srv.ecdsa_key;
  367|      0|        break;
  368|  8.64k|      case SSH_KEYTYPE_ED25519:
  ------------------
  |  Branch (368:7): [True: 8.64k, False: 0]
  ------------------
  369|  8.64k|        *privkey = session->srv.ed25519_key;
  370|  8.64k|        break;
  371|      0|      case SSH_KEYTYPE_RSA1:
  ------------------
  |  Branch (371:7): [True: 0, False: 8.64k]
  ------------------
  372|      0|      case SSH_KEYTYPE_UNKNOWN:
  ------------------
  |  Branch (372:7): [True: 0, False: 8.64k]
  ------------------
  373|      0|      default:
  ------------------
  |  Branch (373:7): [True: 0, False: 8.64k]
  ------------------
  374|      0|        *privkey = NULL;
  375|  8.64k|    }
  376|       |
  377|  8.64k|    *digest = session->srv.hostkey_digest;
  378|  8.64k|    rc = ssh_pki_export_privkey_to_pubkey(*privkey, &pubkey);
  379|  8.64k|    if (rc < 0) {
  ------------------
  |  Branch (379:9): [True: 0, False: 8.64k]
  ------------------
  380|      0|      ssh_set_error(session, SSH_FATAL,
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  381|      0|          "Could not get the public key from the private key");
  382|       |
  383|      0|      return -1;
  384|      0|    }
  385|       |
  386|  8.64k|    rc = ssh_pki_export_pubkey_blob(pubkey, &pubkey_blob);
  387|  8.64k|    ssh_key_free(pubkey);
  388|  8.64k|    if (rc < 0) {
  ------------------
  |  Branch (388:9): [True: 0, False: 8.64k]
  ------------------
  389|      0|      ssh_set_error_oom(session);
  ------------------
  |  |  318|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
  390|      0|      return -1;
  391|      0|    }
  392|       |
  393|  8.64k|    rc = ssh_dh_import_next_pubkey_blob(session, pubkey_blob);
  394|  8.64k|    SSH_STRING_FREE(pubkey_blob);
  ------------------
  |  |  893|  8.64k|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (893:14): [True: 8.64k, False: 0]
  |  |  |  Branch (893:69): [Folded, False: 8.64k]
  |  |  ------------------
  ------------------
  395|  8.64k|    if (rc != 0) {
  ------------------
  |  Branch (395:9): [True: 0, False: 8.64k]
  ------------------
  396|      0|        ssh_set_error(session,
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  397|      0|                      SSH_FATAL,
  398|      0|                      "Could not import server public key");
  399|      0|        return -1;
  400|      0|    }
  401|       |
  402|  8.64k|    return SSH_OK;
  ------------------
  |  |  316|  8.64k|#define SSH_OK 0     /* No error */
  ------------------
  403|  8.64k|}
ssh_set_auth_methods:
  613|  8.64k|{
  614|       |    /* accept only methods in range */
  615|  8.64k|    session->auth.supported_methods = (uint32_t)auth_methods & 0x3fU;
  616|  8.64k|}
ssh_handle_key_exchange:
  645|  8.64k|{
  646|  8.64k|    int rc;
  647|       |
  648|  8.64k|    if (session->session_state != SSH_SESSION_STATE_NONE) {
  ------------------
  |  Branch (648:9): [True: 0, False: 8.64k]
  ------------------
  649|      0|        goto pending;
  650|      0|    }
  651|       |
  652|  8.64k|    rc = ssh_send_banner(session, 1);
  653|  8.64k|    if (rc < 0) {
  ------------------
  |  Branch (653:9): [True: 0, False: 8.64k]
  ------------------
  654|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  655|      0|    }
  656|       |
  657|  8.64k|    session->alive = 1;
  658|       |
  659|  8.64k|    session->ssh_connection_callback = ssh_server_connection_callback;
  660|  8.64k|    session->session_state = SSH_SESSION_STATE_SOCKET_CONNECTED;
  661|  8.64k|    ssh_socket_set_callbacks(session->socket,&session->socket_callbacks);
  662|  8.64k|    session->socket_callbacks.data = callback_receive_banner;
  663|  8.64k|    session->socket_callbacks.exception = ssh_socket_exception_callback;
  664|  8.64k|    session->socket_callbacks.userdata = session;
  665|       |
  666|  8.64k|    rc = server_set_kex(session);
  667|  8.64k|    if (rc < 0) {
  ------------------
  |  Branch (667:9): [True: 0, False: 8.64k]
  ------------------
  668|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  669|      0|    }
  670|  8.64k|pending:
  671|  8.64k|    rc = ssh_handle_packets_termination(session, SSH_TIMEOUT_USER,
  ------------------
  |  |  101|  8.64k|#define SSH_TIMEOUT_USER -2
  ------------------
  672|  8.64k|                                        ssh_server_kex_termination,session);
  673|  8.64k|    SSH_LOG(SSH_LOG_PACKET, "ssh_handle_key_exchange: current state : %d",
  ------------------
  |  |  281|  8.64k|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  674|  8.64k|            session->session_state);
  675|  8.64k|    if (rc != SSH_OK) {
  ------------------
  |  |  316|  8.64k|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (675:9): [True: 0, False: 8.64k]
  ------------------
  676|      0|        return rc;
  677|      0|    }
  678|  8.64k|    if (session->session_state == SSH_SESSION_STATE_ERROR ||
  ------------------
  |  Branch (678:9): [True: 0, False: 8.64k]
  ------------------
  679|  8.64k|        session->session_state == SSH_SESSION_STATE_DISCONNECTED) {
  ------------------
  |  Branch (679:9): [True: 0, False: 8.64k]
  ------------------
  680|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  681|      0|    }
  682|       |
  683|  8.64k|    return SSH_OK;
  ------------------
  |  |  316|  8.64k|#define SSH_OK 0     /* No error */
  ------------------
  684|  8.64k|}
ssh_message_service_reply_success:
  834|  8.64k|{
  835|  8.64k|    ssh_session session = NULL;
  836|  8.64k|    int rc;
  837|       |
  838|  8.64k|    if (msg == NULL) {
  ------------------
  |  Branch (838:9): [True: 0, False: 8.64k]
  ------------------
  839|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  840|      0|    }
  841|  8.64k|    session = msg->session;
  842|       |
  843|  8.64k|    SSH_LOG(SSH_LOG_PACKET,
  ------------------
  |  |  281|  8.64k|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  844|  8.64k|            "Sending a SERVICE_ACCEPT for service %s", msg->service_request.service);
  845|       |
  846|  8.64k|    rc = ssh_buffer_pack(session->out_buffer,
  ------------------
  |  |   50|  8.64k|    _ssh_buffer_pack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |  451|  8.64k|        (__VA_NARG_(__VA_ARGS__, __RSEQ_N()))
  |  |  |  |  ------------------
  |  |  |  |  |  |  453|  8.64k|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  448|  8.64k|#define VA_APPLY_VARIADIC_MACRO(macro, tuple) macro tuple
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  453|  8.64k|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  461|  8.64k|        _61,_62,_63,N,...) N
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                   _ssh_buffer_pack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |   28|  8.64k|#define SSH_BUFFER_PACK_END ((uint32_t) 0x4f65feb3)
  |  |  ------------------
  ------------------
  847|  8.64k|                         "bs",
  848|  8.64k|                         SSH2_MSG_SERVICE_ACCEPT,
  849|  8.64k|                         msg->service_request.service);
  850|  8.64k|    if (rc != SSH_OK){
  ------------------
  |  |  316|  8.64k|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (850:9): [True: 0, False: 8.64k]
  ------------------
  851|      0|        ssh_set_error_oom(session);
  ------------------
  |  |  318|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
  852|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  853|      0|    }
  854|  8.64k|    rc = ssh_packet_send(msg->session);
  855|  8.64k|    return rc;
  856|  8.64k|}
ssh_message_reply_default:
  933|  8.64k|int ssh_message_reply_default(ssh_message msg) {
  934|  8.64k|  if (msg == NULL) {
  ------------------
  |  Branch (934:7): [True: 0, False: 8.64k]
  ------------------
  935|      0|    return -1;
  936|      0|  }
  937|       |
  938|  8.64k|  switch(msg->type) {
  939|      0|    case SSH_REQUEST_AUTH:
  ------------------
  |  Branch (939:5): [True: 0, False: 8.64k]
  ------------------
  940|      0|      return ssh_auth_reply_default(msg->session, 0);
  941|      0|    case SSH_REQUEST_CHANNEL_OPEN:
  ------------------
  |  Branch (941:5): [True: 0, False: 8.64k]
  ------------------
  942|      0|      return ssh_message_channel_request_open_reply_default(msg);
  943|      0|    case SSH_REQUEST_CHANNEL:
  ------------------
  |  Branch (943:5): [True: 0, False: 8.64k]
  ------------------
  944|      0|      return ssh_message_channel_request_reply_default(msg);
  945|  8.64k|    case SSH_REQUEST_SERVICE:
  ------------------
  |  Branch (945:5): [True: 8.64k, False: 0]
  ------------------
  946|  8.64k|      return ssh_message_service_request_reply_default(msg);
  947|      0|    case SSH_REQUEST_GLOBAL:
  ------------------
  |  Branch (947:5): [True: 0, False: 8.64k]
  ------------------
  948|      0|      return ssh_message_global_request_reply_default(msg);
  949|      0|    default:
  ------------------
  |  Branch (949:5): [True: 0, False: 8.64k]
  ------------------
  950|      0|      SSH_LOG(SSH_LOG_PACKET,
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  951|      0|          "Don't know what to default reply to %d type",
  952|      0|          msg->type);
  953|      0|      break;
  954|  8.64k|  }
  955|       |
  956|      0|  return -1;
  957|  8.64k|}
ssh_auth_reply_success:
 1192|  8.64k|{
 1193|  8.64k|    struct ssh_crypto_struct *crypto = NULL;
 1194|  8.64k|    int r;
 1195|       |
 1196|  8.64k|    if (session == NULL) {
  ------------------
  |  Branch (1196:9): [True: 0, False: 8.64k]
  ------------------
 1197|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 1198|      0|    }
 1199|       |
 1200|  8.64k|    if (partial) {
  ------------------
  |  Branch (1200:9): [True: 0, False: 8.64k]
  ------------------
 1201|      0|        return ssh_auth_reply_default(session, partial);
 1202|      0|    }
 1203|       |
 1204|  8.64k|    r = ssh_buffer_add_u8(session->out_buffer,SSH2_MSG_USERAUTH_SUCCESS);
  ------------------
  |  |   38|  8.64k|#define SSH2_MSG_USERAUTH_SUCCESS 52
  ------------------
 1205|  8.64k|    if (r < 0) {
  ------------------
  |  Branch (1205:9): [True: 0, False: 8.64k]
  ------------------
 1206|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 1207|      0|    }
 1208|       |
 1209|  8.64k|    r = ssh_packet_send(session);
 1210|       |
 1211|       |    /*
 1212|       |     * Consider the session as having been authenticated only after sending
 1213|       |     * the `USERAUTH_SUCCESS` message.  Setting these flags after
 1214|       |     * ssh_packet_send ensures that a rekey is not triggered prematurely,
 1215|       |     * causing the message to be queued.
 1216|       |     */
 1217|  8.64k|    session->session_state = SSH_SESSION_STATE_AUTHENTICATED;
 1218|  8.64k|    session->flags |= SSH_SESSION_FLAG_AUTHENTICATED;
  ------------------
  |  |   78|  8.64k|#define SSH_SESSION_FLAG_AUTHENTICATED 0x0002
  ------------------
 1219|       |
 1220|  8.64k|    crypto = ssh_packet_get_current_crypto(session, SSH_DIRECTION_OUT);
 1221|  8.64k|    if (crypto != NULL && crypto->delayed_compress_out) {
  ------------------
  |  Branch (1221:9): [True: 8.64k, False: 0]
  |  Branch (1221:27): [True: 0, False: 8.64k]
  ------------------
 1222|      0|        SSH_LOG(SSH_LOG_DEBUG, "Enabling delayed compression OUT");
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 1223|      0|        crypto->do_compress_out = 1;
 1224|      0|    }
 1225|       |
 1226|  8.64k|    crypto = ssh_packet_get_current_crypto(session, SSH_DIRECTION_IN);
 1227|  8.64k|    if (crypto != NULL && crypto->delayed_compress_in) {
  ------------------
  |  Branch (1227:9): [True: 8.64k, False: 0]
  |  Branch (1227:27): [True: 0, False: 8.64k]
  ------------------
 1228|      0|        SSH_LOG(SSH_LOG_DEBUG, "Enabling delayed compression IN");
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 1229|      0|        crypto->do_compress_in = 1;
 1230|      0|    }
 1231|  8.64k|    return r;
 1232|  8.64k|}
ssh_message_auth_reply_success:
 1246|  8.64k|int ssh_message_auth_reply_success(ssh_message msg, int partial) {
 1247|  8.64k|	if(msg == NULL)
  ------------------
  |  Branch (1247:5): [True: 0, False: 8.64k]
  ------------------
 1248|      0|		return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 1249|  8.64k|	return ssh_auth_reply_success(msg->session, partial);
 1250|  8.64k|}
server.c:ssh_server_connection_callback:
  412|  25.9k|{
  413|  25.9k|    int rc;
  414|       |
  415|  25.9k|    switch (session->session_state) {
  416|      0|    case SSH_SESSION_STATE_NONE:
  ------------------
  |  Branch (416:5): [True: 0, False: 25.9k]
  ------------------
  417|      0|    case SSH_SESSION_STATE_CONNECTING:
  ------------------
  |  Branch (417:5): [True: 0, False: 25.9k]
  ------------------
  418|      0|    case SSH_SESSION_STATE_SOCKET_CONNECTED:
  ------------------
  |  Branch (418:5): [True: 0, False: 25.9k]
  ------------------
  419|      0|        break;
  420|  8.64k|    case SSH_SESSION_STATE_BANNER_RECEIVED:
  ------------------
  |  Branch (420:5): [True: 8.64k, False: 17.2k]
  ------------------
  421|  8.64k|        if (session->clientbanner == NULL) {
  ------------------
  |  Branch (421:13): [True: 0, False: 8.64k]
  ------------------
  422|      0|            goto error;
  423|      0|        }
  424|  8.64k|        set_status(session, 0.4f);
  ------------------
  |  |   65|  8.64k|#define set_status(session, status) do {\
  |  |   66|  8.64k|        if (session->common.callbacks && session->common.callbacks->connect_status_function) \
  |  |  ------------------
  |  |  |  Branch (66:13): [True: 0, False: 8.64k]
  |  |  |  Branch (66:42): [True: 0, False: 0]
  |  |  ------------------
  |  |   67|  8.64k|            session->common.callbacks->connect_status_function(session->common.callbacks->userdata, status); \
  |  |   68|  8.64k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (68:14): [Folded, False: 8.64k]
  |  |  ------------------
  ------------------
  425|  8.64k|        SSH_LOG(SSH_LOG_DEBUG,
  ------------------
  |  |  281|  8.64k|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  426|  8.64k|                "SSH client banner: %s", session->clientbanner);
  427|       |
  428|       |        /* Here we analyze the different protocols the server allows. */
  429|  8.64k|        rc = ssh_analyze_banner(session, 1);
  430|  8.64k|        if (rc < 0) {
  ------------------
  |  Branch (430:13): [True: 0, False: 8.64k]
  ------------------
  431|      0|            ssh_set_error(session, SSH_FATAL,
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  432|      0|                    "No version of SSH protocol usable (banner: %s)",
  433|      0|                    session->clientbanner);
  434|      0|            goto error;
  435|      0|        }
  436|       |
  437|       |        /* from now, the packet layer is handling incoming packets */
  438|  8.64k|        ssh_packet_register_socket_callback(session, session->socket);
  439|       |
  440|  8.64k|        ssh_packet_set_default_callbacks(session);
  441|  8.64k|        set_status(session, 0.5f);
  ------------------
  |  |   65|  8.64k|#define set_status(session, status) do {\
  |  |   66|  8.64k|        if (session->common.callbacks && session->common.callbacks->connect_status_function) \
  |  |  ------------------
  |  |  |  Branch (66:13): [True: 0, False: 8.64k]
  |  |  |  Branch (66:42): [True: 0, False: 0]
  |  |  ------------------
  |  |   67|  8.64k|            session->common.callbacks->connect_status_function(session->common.callbacks->userdata, status); \
  |  |   68|  8.64k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (68:14): [Folded, False: 8.64k]
  |  |  ------------------
  ------------------
  442|  8.64k|        session->session_state = SSH_SESSION_STATE_INITIAL_KEX;
  443|  8.64k|        rc = ssh_send_kex(session);
  444|  8.64k|        if (rc < 0) {
  ------------------
  |  Branch (444:13): [True: 0, False: 8.64k]
  ------------------
  445|      0|            goto error;
  446|      0|        }
  447|  8.64k|        break;
  448|  8.64k|    case SSH_SESSION_STATE_INITIAL_KEX:
  ------------------
  |  Branch (448:5): [True: 0, False: 25.9k]
  ------------------
  449|       |        /* TODO: This state should disappear in favor of get_key handle */
  450|      0|        break;
  451|  8.64k|    case SSH_SESSION_STATE_KEXINIT_RECEIVED:
  ------------------
  |  Branch (451:5): [True: 8.64k, False: 17.2k]
  ------------------
  452|  8.64k|        set_status(session, 0.6f);
  ------------------
  |  |   65|  8.64k|#define set_status(session, status) do {\
  |  |   66|  8.64k|        if (session->common.callbacks && session->common.callbacks->connect_status_function) \
  |  |  ------------------
  |  |  |  Branch (66:13): [True: 0, False: 8.64k]
  |  |  |  Branch (66:42): [True: 0, False: 0]
  |  |  ------------------
  |  |   67|  8.64k|            session->common.callbacks->connect_status_function(session->common.callbacks->userdata, status); \
  |  |   68|  8.64k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (68:14): [Folded, False: 8.64k]
  |  |  ------------------
  ------------------
  453|  8.64k|        if ((session->flags & SSH_SESSION_FLAG_KEXINIT_SENT) == 0) {
  ------------------
  |  |   86|  8.64k|#define SSH_SESSION_FLAG_KEXINIT_SENT 0x0008
  ------------------
  |  Branch (453:13): [True: 0, False: 8.64k]
  ------------------
  454|      0|            rc = server_set_kex(session);
  455|      0|            if (rc == SSH_ERROR) {
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  |  Branch (455:17): [True: 0, False: 0]
  ------------------
  456|      0|                goto error;
  457|      0|            }
  458|       |            /* We are in a rekeying, so we need to send the server kex */
  459|      0|            rc = ssh_send_kex(session);
  460|      0|            if (rc < 0) {
  ------------------
  |  Branch (460:17): [True: 0, False: 0]
  ------------------
  461|      0|                goto error;
  462|      0|            }
  463|      0|        }
  464|  8.64k|        ssh_list_kex(&session->next_crypto->client_kex); // log client kex
  465|  8.64k|        rc = ssh_kex_select_methods(session);
  466|  8.64k|        if (rc < 0) {
  ------------------
  |  Branch (466:13): [True: 0, False: 8.64k]
  ------------------
  467|      0|            goto error;
  468|      0|        }
  469|  8.64k|        rc = crypt_set_algorithms_server(session);
  470|  8.64k|        if (rc == SSH_ERROR) {
  ------------------
  |  |  317|  8.64k|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  |  Branch (470:13): [True: 0, False: 8.64k]
  ------------------
  471|      0|            goto error;
  472|      0|        }
  473|  8.64k|        set_status(session, 0.8f);
  ------------------
  |  |   65|  8.64k|#define set_status(session, status) do {\
  |  |   66|  8.64k|        if (session->common.callbacks && session->common.callbacks->connect_status_function) \
  |  |  ------------------
  |  |  |  Branch (66:13): [True: 0, False: 8.64k]
  |  |  |  Branch (66:42): [True: 0, False: 0]
  |  |  ------------------
  |  |   67|  8.64k|            session->common.callbacks->connect_status_function(session->common.callbacks->userdata, status); \
  |  |   68|  8.64k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (68:14): [Folded, False: 8.64k]
  |  |  ------------------
  ------------------
  474|  8.64k|        session->session_state = SSH_SESSION_STATE_DH;
  475|  8.64k|        break;
  476|  8.64k|    case SSH_SESSION_STATE_DH:
  ------------------
  |  Branch (476:5): [True: 8.64k, False: 17.2k]
  ------------------
  477|  8.64k|        if (session->dh_handshake_state == DH_STATE_FINISHED) {
  ------------------
  |  Branch (477:13): [True: 8.64k, False: 0]
  ------------------
  478|       |
  479|  8.64k|            rc = ssh_packet_set_newkeys(session, SSH_DIRECTION_IN);
  480|  8.64k|            if (rc != SSH_OK) {
  ------------------
  |  |  316|  8.64k|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (480:17): [True: 0, False: 8.64k]
  ------------------
  481|      0|                goto error;
  482|      0|            }
  483|       |
  484|       |            /*
  485|       |             * If the client supports extension negotiation, we will send
  486|       |             * our supported extensions now. This is the first message after
  487|       |             * sending NEWKEYS message and after turning on crypto.
  488|       |             */
  489|  8.64k|            if (session->extensions & SSH_EXT_NEGOTIATION &&
  ------------------
  |  |  123|  17.2k|#define SSH_EXT_NEGOTIATION     0x01
  ------------------
  |  Branch (489:17): [True: 8.64k, False: 0]
  ------------------
  490|  8.64k|                session->session_state != SSH_SESSION_STATE_AUTHENTICATED) {
  ------------------
  |  Branch (490:17): [True: 8.64k, False: 0]
  ------------------
  491|       |                /*
  492|       |                 * Only send an SSH_MSG_EXT_INFO message the first time the
  493|       |                 * client undergoes NEWKEYS.  It is unexpected for this message
  494|       |                 * to be sent upon rekey, and may cause clients to log error
  495|       |                 * messages.
  496|       |                 *
  497|       |                 * The session_state can not be used for this purpose because it
  498|       |                 * is re-set to SSH_SESSION_STATE_KEXINIT_RECEIVED during rekey.
  499|       |                 * So, use the connected flag which transitions from non-zero
  500|       |                 * below.
  501|       |                 *
  502|       |                 * See also:
  503|       |                 * - https://bugzilla.mindrot.org/show_bug.cgi?id=2929
  504|       |                 */
  505|  8.64k|                if (session->connected == 0) {
  ------------------
  |  Branch (505:21): [True: 8.64k, False: 0]
  ------------------
  506|  8.64k|                    ssh_server_send_extensions(session);
  507|  8.64k|                }
  508|  8.64k|            }
  509|       |
  510|  8.64k|            set_status(session, 1.0f);
  ------------------
  |  |   65|  8.64k|#define set_status(session, status) do {\
  |  |   66|  8.64k|        if (session->common.callbacks && session->common.callbacks->connect_status_function) \
  |  |  ------------------
  |  |  |  Branch (66:13): [True: 0, False: 8.64k]
  |  |  |  Branch (66:42): [True: 0, False: 0]
  |  |  ------------------
  |  |   67|  8.64k|            session->common.callbacks->connect_status_function(session->common.callbacks->userdata, status); \
  |  |   68|  8.64k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (68:14): [Folded, False: 8.64k]
  |  |  ------------------
  ------------------
  511|  8.64k|            session->connected = 1;
  512|  8.64k|            session->session_state = SSH_SESSION_STATE_AUTHENTICATING;
  513|  8.64k|            if (session->flags & SSH_SESSION_FLAG_AUTHENTICATED)
  ------------------
  |  |   78|  8.64k|#define SSH_SESSION_FLAG_AUTHENTICATED 0x0002
  ------------------
  |  Branch (513:17): [True: 0, False: 8.64k]
  ------------------
  514|      0|                session->session_state = SSH_SESSION_STATE_AUTHENTICATED;
  515|       |
  516|  8.64k|        }
  517|  8.64k|        break;
  518|  8.64k|    case SSH_SESSION_STATE_AUTHENTICATING:
  ------------------
  |  Branch (518:5): [True: 0, False: 25.9k]
  ------------------
  519|      0|        break;
  520|      0|    case SSH_SESSION_STATE_ERROR:
  ------------------
  |  Branch (520:5): [True: 0, False: 25.9k]
  ------------------
  521|      0|        goto error;
  522|      0|    default:
  ------------------
  |  Branch (522:5): [True: 0, False: 25.9k]
  ------------------
  523|      0|        ssh_set_error(session, SSH_FATAL, "Invalid state %d",
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  524|  25.9k|                      session->session_state);
  525|  25.9k|    }
  526|       |
  527|  25.9k|    return;
  528|  25.9k|error:
  529|      0|    ssh_socket_close(session->socket);
  530|      0|    session->alive = 0;
  531|      0|    session->session_state = SSH_SESSION_STATE_ERROR;
  532|      0|}
server.c:ssh_server_send_extensions:
  268|  8.64k|{
  269|  8.64k|    int rc;
  270|  8.64k|    const char *hostkey_algorithms = NULL;
  271|       |
  272|  8.64k|    SSH_LOG(SSH_LOG_PACKET, "Sending SSH_MSG_EXT_INFO");
  ------------------
  |  |  281|  8.64k|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  273|       |
  274|  8.64k|    if (session->opts.pubkey_accepted_types) {
  ------------------
  |  Branch (274:9): [True: 0, False: 8.64k]
  ------------------
  275|      0|        hostkey_algorithms = session->opts.pubkey_accepted_types;
  276|  8.64k|    } else {
  277|  8.64k|        if (ssh_fips_mode()) {
  ------------------
  |  |  115|  8.64k|#define ssh_fips_mode() (FIPS_mode() != 0)
  |  |  ------------------
  |  |  |  Branch (115:25): [True: 0, False: 8.64k]
  |  |  ------------------
  ------------------
  278|      0|            hostkey_algorithms = ssh_kex_get_fips_methods(SSH_HOSTKEYS);
  279|  8.64k|        } else {
  280|       |            /* There are no restrictions to the accepted public keys */
  281|  8.64k|            hostkey_algorithms = ssh_kex_get_default_methods(SSH_HOSTKEYS);
  282|  8.64k|        }
  283|  8.64k|    }
  284|       |
  285|  8.64k|    rc = ssh_buffer_pack(session->out_buffer,
  ------------------
  |  |   50|  8.64k|    _ssh_buffer_pack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |  451|  8.64k|        (__VA_NARG_(__VA_ARGS__, __RSEQ_N()))
  |  |  |  |  ------------------
  |  |  |  |  |  |  453|  8.64k|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  448|  8.64k|#define VA_APPLY_VARIADIC_MACRO(macro, tuple) macro tuple
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  453|  8.64k|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  461|  8.64k|        _61,_62,_63,N,...) N
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                   _ssh_buffer_pack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |   28|  8.64k|#define SSH_BUFFER_PACK_END ((uint32_t) 0x4f65feb3)
  |  |  ------------------
  ------------------
  286|  8.64k|                         "bdssssss",
  287|  8.64k|                         SSH2_MSG_EXT_INFO,
  288|  8.64k|                         3, /* nr. of extensions */
  289|  8.64k|                         "server-sig-algs",
  290|  8.64k|                         hostkey_algorithms,
  291|  8.64k|                         "publickey-hostbound@openssh.com",
  292|  8.64k|                         "0",
  293|  8.64k|                         "ping@openssh.com",
  294|  8.64k|                         "0");
  295|  8.64k|    if (rc != SSH_OK) {
  ------------------
  |  |  316|  8.64k|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (295:9): [True: 0, False: 8.64k]
  ------------------
  296|      0|        goto error;
  297|      0|    }
  298|       |
  299|  8.64k|    if (ssh_packet_send(session) == SSH_ERROR) {
  ------------------
  |  |  317|  8.64k|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  |  Branch (299:9): [True: 0, False: 8.64k]
  ------------------
  300|      0|        goto error;
  301|      0|    }
  302|       |
  303|  8.64k|    return 0;
  304|      0|error:
  305|      0|    ssh_buffer_reinit(session->out_buffer);
  306|       |
  307|      0|    return -1;
  308|  8.64k|}
server.c:callback_receive_banner:
  546|  8.64k|{
  547|  8.64k|    char *buffer = (char *)data;
  548|  8.64k|    ssh_session session = (ssh_session)user;
  549|  8.64k|    char *str = NULL;
  550|  8.64k|    size_t i;
  551|  8.64k|    size_t processed = 0;
  552|       |
  553|   198k|    for (i = 0; i < len; i++) {
  ------------------
  |  Branch (553:17): [True: 198k, False: 0]
  ------------------
  554|   198k|#ifdef WITH_PCAP
  555|   198k|        if (session->pcap_ctx && buffer[i] == '\n') {
  ------------------
  |  Branch (555:13): [True: 0, False: 198k]
  |  Branch (555:34): [True: 0, False: 0]
  ------------------
  556|      0|            ssh_pcap_context_write(session->pcap_ctx,
  557|      0|                                   SSH_PCAP_DIR_IN,
  558|      0|                                   buffer,
  559|      0|                                   (uint32_t)(i + 1),
  560|      0|                                   (uint32_t)(i + 1));
  561|      0|        }
  562|   198k|#endif
  563|   198k|        if (buffer[i] == '\r') {
  ------------------
  |  Branch (563:13): [True: 8.64k, False: 190k]
  ------------------
  564|  8.64k|            buffer[i] = '\0';
  565|  8.64k|        }
  566|       |
  567|   198k|        if (buffer[i] == '\n') {
  ------------------
  |  Branch (567:13): [True: 8.64k, False: 190k]
  ------------------
  568|  8.64k|            buffer[i] = '\0';
  569|       |
  570|  8.64k|            str = strdup(buffer);
  571|  8.64k|            if (str == NULL) {
  ------------------
  |  Branch (571:17): [True: 0, False: 8.64k]
  ------------------
  572|      0|                session->session_state = SSH_SESSION_STATE_ERROR;
  573|      0|                ssh_set_error_oom(session);
  ------------------
  |  |  318|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
  574|      0|                return 0;
  575|      0|            }
  576|       |            /* number of bytes read */
  577|  8.64k|            processed = i + 1;
  578|  8.64k|            session->clientbanner = str;
  579|  8.64k|            session->session_state = SSH_SESSION_STATE_BANNER_RECEIVED;
  580|  8.64k|            SSH_LOG(SSH_LOG_PACKET, "Received banner: %s", str);
  ------------------
  |  |  281|  8.64k|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  581|  8.64k|            session->ssh_connection_callback(session);
  582|       |
  583|  8.64k|            return processed;
  584|  8.64k|        }
  585|       |
  586|   190k|        if (i > 127) {
  ------------------
  |  Branch (586:13): [True: 0, False: 190k]
  ------------------
  587|       |            /* Too big banner */
  588|      0|            session->session_state = SSH_SESSION_STATE_ERROR;
  589|      0|            ssh_set_error(session, SSH_FATAL,
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  590|      0|                          "Receiving banner: too large banner");
  591|       |
  592|      0|            return 0;
  593|      0|        }
  594|   190k|    }
  595|       |
  596|      0|    return processed;
  597|  8.64k|}
server.c:ssh_server_kex_termination:
  600|  84.3k|static int ssh_server_kex_termination(void *s){
  601|  84.3k|  ssh_session session = s;
  602|  84.3k|  if (session->session_state != SSH_SESSION_STATE_ERROR &&
  ------------------
  |  Branch (602:7): [True: 84.3k, False: 0]
  ------------------
  603|  84.3k|      session->session_state != SSH_SESSION_STATE_AUTHENTICATING &&
  ------------------
  |  Branch (603:7): [True: 75.6k, False: 8.64k]
  ------------------
  604|  75.6k|      session->session_state != SSH_SESSION_STATE_AUTHENTICATED &&
  ------------------
  |  Branch (604:7): [True: 75.6k, False: 0]
  ------------------
  605|  75.6k|      session->session_state != SSH_SESSION_STATE_DISCONNECTED)
  ------------------
  |  Branch (605:7): [True: 75.6k, False: 0]
  ------------------
  606|  75.6k|    return 0;
  607|  8.64k|  else
  608|  8.64k|    return 1;
  609|  84.3k|}
server.c:ssh_message_service_request_reply_default:
  821|  8.64k|static int ssh_message_service_request_reply_default(ssh_message msg) {
  822|       |  /* The only return code accepted by specifications are success or disconnect */
  823|  8.64k|  return ssh_message_service_reply_success(msg);
  824|  8.64k|}

ssh_new:
   65|  17.2k|{
   66|  17.2k|    ssh_session session = NULL;
   67|  17.2k|    char *id = NULL;
   68|  17.2k|    int rc;
   69|       |
   70|  17.2k|    session = calloc(1, sizeof (struct ssh_session_struct));
   71|  17.2k|    if (session == NULL) {
  ------------------
  |  Branch (71:9): [True: 0, False: 17.2k]
  ------------------
   72|      0|        return NULL;
   73|      0|    }
   74|       |
   75|  17.2k|    session->next_crypto = crypto_new();
   76|  17.2k|    if (session->next_crypto == NULL) {
  ------------------
  |  Branch (76:9): [True: 0, False: 17.2k]
  ------------------
   77|      0|        goto err;
   78|      0|    }
   79|       |
   80|  17.2k|    session->socket = ssh_socket_new(session);
   81|  17.2k|    if (session->socket == NULL) {
  ------------------
  |  Branch (81:9): [True: 0, False: 17.2k]
  ------------------
   82|      0|        goto err;
   83|      0|    }
   84|       |
   85|  17.2k|    session->out_buffer = ssh_buffer_new();
   86|  17.2k|    if (session->out_buffer == NULL) {
  ------------------
  |  Branch (86:9): [True: 0, False: 17.2k]
  ------------------
   87|      0|        goto err;
   88|      0|    }
   89|       |
   90|  17.2k|    session->in_buffer = ssh_buffer_new();
   91|  17.2k|    if (session->in_buffer == NULL) {
  ------------------
  |  Branch (91:9): [True: 0, False: 17.2k]
  ------------------
   92|      0|        goto err;
   93|      0|    }
   94|       |
   95|  17.2k|    session->out_queue = ssh_list_new();
   96|  17.2k|    if (session->out_queue == NULL) {
  ------------------
  |  Branch (96:9): [True: 0, False: 17.2k]
  ------------------
   97|      0|        goto err;
   98|      0|    }
   99|       |
  100|  17.2k|    session->alive = 0;
  101|  17.2k|    session->auth.supported_methods = 0;
  102|  17.2k|    ssh_set_blocking(session, 1);
  103|  17.2k|    session->maxchannel = FIRST_CHANNEL;
  ------------------
  |  |   48|  17.2k|#define FIRST_CHANNEL 42 // why not ? it helps to find bugs.
  ------------------
  104|  17.2k|    session->proxy_root = true;
  105|       |
  106|  17.2k|    session->agent = ssh_agent_new(session);
  107|  17.2k|    if (session->agent == NULL) {
  ------------------
  |  Branch (107:9): [True: 0, False: 17.2k]
  ------------------
  108|      0|        goto err;
  109|      0|    }
  110|       |
  111|       |    /* Initialise a default PKI context */
  112|  17.2k|    session->pki_context = ssh_pki_ctx_new();
  113|  17.2k|    if (session->pki_context == NULL) {
  ------------------
  |  Branch (113:9): [True: 0, False: 17.2k]
  ------------------
  114|      0|        goto err;
  115|      0|    }
  116|       |
  117|       |    /* OPTIONS */
  118|  17.2k|    session->opts.StrictHostKeyChecking = SSH_STRICT_HOSTKEY_ASK;
  119|  17.2k|    session->opts.port = 22;
  120|  17.2k|    session->opts.fd = -1;
  121|  17.2k|    session->opts.compressionlevel = 7;
  122|  17.2k|    session->opts.nodelay = 0;
  123|  17.2k|    session->opts.identities_only = false;
  124|  17.2k|    session->opts.batch_mode = false;
  125|  17.2k|    session->opts.control_master = SSH_CONTROL_MASTER_NO;
  126|       |
  127|  17.2k|    session->opts.flags = SSH_OPT_FLAG_PASSWORD_AUTH |
  ------------------
  |  |  109|  17.2k|#define SSH_OPT_FLAG_PASSWORD_AUTH 0x1
  ------------------
  128|  17.2k|                          SSH_OPT_FLAG_PUBKEY_AUTH |
  ------------------
  |  |  110|  17.2k|#define SSH_OPT_FLAG_PUBKEY_AUTH 0x2
  ------------------
  129|  17.2k|                          SSH_OPT_FLAG_KBDINT_AUTH |
  ------------------
  |  |  111|  17.2k|#define SSH_OPT_FLAG_KBDINT_AUTH 0x4
  ------------------
  130|  17.2k|                          SSH_OPT_FLAG_GSSAPI_AUTH;
  ------------------
  |  |  112|  17.2k|#define SSH_OPT_FLAG_GSSAPI_AUTH 0x8
  ------------------
  131|  17.2k|    session->opts.pubkey_auth = SSH_PUBKEY_AUTH_ALL;
  132|       |
  133|  17.2k|    session->opts.exp_flags = 0;
  134|       |
  135|  17.2k|    session->opts.identity = ssh_list_new();
  136|  17.2k|    if (session->opts.identity == NULL) {
  ------------------
  |  Branch (136:9): [True: 0, False: 17.2k]
  ------------------
  137|      0|        goto err;
  138|      0|    }
  139|  17.2k|    session->opts.identity_non_exp = ssh_list_new();
  140|  17.2k|    if (session->opts.identity_non_exp == NULL) {
  ------------------
  |  Branch (140:9): [True: 0, False: 17.2k]
  ------------------
  141|      0|        goto err;
  142|      0|    }
  143|       |
  144|  17.2k|    session->opts.certificate = ssh_list_new();
  145|  17.2k|    if (session->opts.certificate == NULL) {
  ------------------
  |  Branch (145:9): [True: 0, False: 17.2k]
  ------------------
  146|      0|        goto err;
  147|      0|    }
  148|  17.2k|    session->opts.certificate_non_exp = ssh_list_new();
  149|  17.2k|    if (session->opts.certificate_non_exp == NULL) {
  ------------------
  |  Branch (149:9): [True: 0, False: 17.2k]
  ------------------
  150|      0|        goto err;
  151|      0|    }
  152|       |    /* the default certificates are loaded automatically from the default
  153|       |     * identities later */
  154|       |
  155|  17.2k|    session->opts.proxy_jumps = ssh_list_new();
  156|  17.2k|    if (session->opts.proxy_jumps == NULL) {
  ------------------
  |  Branch (156:9): [True: 0, False: 17.2k]
  ------------------
  157|      0|        goto err;
  158|      0|    }
  159|       |
  160|  17.2k|    session->opts.proxy_jumps_user_cb = ssh_list_new();
  161|  17.2k|    if (session->opts.proxy_jumps_user_cb == NULL) {
  ------------------
  |  Branch (161:9): [True: 0, False: 17.2k]
  ------------------
  162|      0|        goto err;
  163|      0|    }
  164|       |
  165|       |#ifdef WITH_GSSAPI
  166|       |    session->opts.gssapi_key_exchange_algs =
  167|       |        strdup(GSSAPI_KEY_EXCHANGE_SUPPORTED);
  168|       |    if (session->opts.gssapi_key_exchange_algs == NULL) {
  169|       |        goto err;
  170|       |    }
  171|       |#endif /* WITH_GSSAPI */
  172|       |
  173|  17.2k|    id = strdup("%d/.ssh/id_ed25519");
  174|  17.2k|    if (id == NULL) {
  ------------------
  |  Branch (174:9): [True: 0, False: 17.2k]
  ------------------
  175|      0|        goto err;
  176|      0|    }
  177|       |
  178|  17.2k|    rc = ssh_list_append(session->opts.identity_non_exp, id);
  179|  17.2k|    if (rc == SSH_ERROR) {
  ------------------
  |  |  317|  17.2k|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  |  Branch (179:9): [True: 0, False: 17.2k]
  ------------------
  180|      0|        goto err;
  181|      0|    }
  182|       |
  183|  17.2k|#ifdef HAVE_ECC
  184|  17.2k|    id = strdup("%d/.ssh/id_ecdsa");
  185|  17.2k|    if (id == NULL) {
  ------------------
  |  Branch (185:9): [True: 0, False: 17.2k]
  ------------------
  186|      0|        goto err;
  187|      0|    }
  188|  17.2k|    rc = ssh_list_append(session->opts.identity_non_exp, id);
  189|  17.2k|    if (rc == SSH_ERROR) {
  ------------------
  |  |  317|  17.2k|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  |  Branch (189:9): [True: 0, False: 17.2k]
  ------------------
  190|      0|        goto err;
  191|      0|    }
  192|  17.2k|#endif
  193|       |
  194|  17.2k|    id = strdup("%d/.ssh/id_rsa");
  195|  17.2k|    if (id == NULL) {
  ------------------
  |  Branch (195:9): [True: 0, False: 17.2k]
  ------------------
  196|      0|        goto err;
  197|      0|    }
  198|  17.2k|    rc = ssh_list_append(session->opts.identity_non_exp, id);
  199|  17.2k|    if (rc == SSH_ERROR) {
  ------------------
  |  |  317|  17.2k|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  |  Branch (199:9): [True: 0, False: 17.2k]
  ------------------
  200|      0|        goto err;
  201|      0|    }
  202|       |
  203|       |#ifdef WITH_FIDO2
  204|       |    /* Add security key identities */
  205|       |    id = strdup("%d/.ssh/id_ed25519_sk");
  206|       |    if (id == NULL) {
  207|       |        goto err;
  208|       |    }
  209|       |    rc = ssh_list_append(session->opts.identity_non_exp, id);
  210|       |    if (rc == SSH_ERROR) {
  211|       |        goto err;
  212|       |    }
  213|       |
  214|       |#ifdef HAVE_ECC
  215|       |    id = strdup("%d/.ssh/id_ecdsa_sk");
  216|       |    if (id == NULL) {
  217|       |        goto err;
  218|       |    }
  219|       |    rc = ssh_list_append(session->opts.identity_non_exp, id);
  220|       |    if (rc == SSH_ERROR) {
  221|       |        goto err;
  222|       |    }
  223|       |#endif /* HAVE_ECC */
  224|       |#endif /* WITH_FIDO2 */
  225|       |
  226|       |    /* Explicitly initialize states */
  227|  17.2k|    session->session_state = SSH_SESSION_STATE_NONE;
  228|  17.2k|    session->pending_call_state = SSH_PENDING_CALL_NONE;
  229|  17.2k|    session->packet_state = PACKET_STATE_INIT;
  230|  17.2k|    session->dh_handshake_state = DH_STATE_INIT;
  231|  17.2k|    session->global_req_state = SSH_CHANNEL_REQ_STATE_NONE;
  232|       |
  233|  17.2k|    session->auth.state = SSH_AUTH_STATE_NONE;
  234|  17.2k|    session->auth.service_state = SSH_AUTH_SERVICE_NONE;
  235|       |
  236|  17.2k|    return session;
  237|       |
  238|      0|err:
  239|      0|    free(id);
  240|      0|    ssh_free(session);
  241|       |    return NULL;
  242|  17.2k|}
ssh_free:
  253|  17.2k|{
  254|  17.2k|  int i;
  255|  17.2k|  struct ssh_iterator *it = NULL;
  256|  17.2k|  struct ssh_buffer_struct *b = NULL;
  257|       |
  258|  17.2k|  if (session == NULL) {
  ------------------
  |  Branch (258:7): [True: 0, False: 17.2k]
  ------------------
  259|      0|    return;
  260|      0|  }
  261|       |
  262|       |  /*
  263|       |   * Delete all channels
  264|       |   *
  265|       |   * This needs the first thing we clean up cause if there is still an open
  266|       |   * channel we call ssh_channel_close() first. So we need a working socket
  267|       |   * and poll context for it.
  268|       |   */
  269|  17.2k|  for (it = ssh_list_get_iterator(session->channels);
  270|  17.2k|       it != NULL;
  ------------------
  |  Branch (270:8): [True: 0, False: 17.2k]
  ------------------
  271|  17.2k|       it = ssh_list_get_iterator(session->channels)) {
  272|      0|      ssh_channel_do_free(ssh_iterator_value(ssh_channel,it));
  ------------------
  |  |  114|      0|  ((type)((iterator)->data))
  ------------------
  273|      0|      ssh_list_remove(session->channels, it);
  274|      0|  }
  275|  17.2k|  ssh_list_free(session->channels);
  276|  17.2k|  session->channels = NULL;
  277|       |
  278|  17.2k|#ifdef WITH_PCAP
  279|  17.2k|  if (session->pcap_ctx) {
  ------------------
  |  Branch (279:7): [True: 0, False: 17.2k]
  ------------------
  280|      0|      ssh_pcap_context_free(session->pcap_ctx);
  281|      0|      session->pcap_ctx = NULL;
  282|      0|  }
  283|  17.2k|#endif
  284|       |
  285|  17.2k|  ssh_socket_free(session->socket);
  286|  17.2k|  session->socket = NULL;
  287|       |
  288|  17.2k|  if (session->default_poll_ctx) {
  ------------------
  |  Branch (288:7): [True: 17.2k, False: 0]
  ------------------
  289|  17.2k|      ssh_poll_ctx_free(session->default_poll_ctx);
  290|  17.2k|  }
  291|       |
  292|  17.2k|  SSH_BUFFER_FREE(session->in_buffer);
  ------------------
  |  |  934|  17.2k|    do { if ((x) != NULL) { ssh_buffer_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (934:14): [True: 17.2k, False: 0]
  |  |  |  Branch (934:69): [Folded, False: 17.2k]
  |  |  ------------------
  ------------------
  293|  17.2k|  SSH_BUFFER_FREE(session->out_buffer);
  ------------------
  |  |  934|  17.2k|    do { if ((x) != NULL) { ssh_buffer_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (934:14): [True: 17.2k, False: 0]
  |  |  |  Branch (934:69): [Folded, False: 17.2k]
  |  |  ------------------
  ------------------
  294|  17.2k|  session->in_buffer = session->out_buffer = NULL;
  295|       |
  296|  17.2k|  if (session->in_hashbuf != NULL) {
  ------------------
  |  Branch (296:7): [True: 0, False: 17.2k]
  ------------------
  297|      0|      SSH_BUFFER_FREE(session->in_hashbuf);
  ------------------
  |  |  934|      0|    do { if ((x) != NULL) { ssh_buffer_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (934:14): [True: 0, False: 0]
  |  |  |  Branch (934:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
  298|      0|  }
  299|  17.2k|  if (session->out_hashbuf != NULL) {
  ------------------
  |  Branch (299:7): [True: 0, False: 17.2k]
  ------------------
  300|      0|      SSH_BUFFER_FREE(session->out_hashbuf);
  ------------------
  |  |  934|      0|    do { if ((x) != NULL) { ssh_buffer_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (934:14): [True: 0, False: 0]
  |  |  |  Branch (934:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
  301|      0|  }
  302|       |
  303|  17.2k|  crypto_free(session->current_crypto);
  304|  17.2k|  crypto_free(session->next_crypto);
  305|       |
  306|  17.2k|  ssh_agent_free(session->agent);
  307|       |
  308|  17.2k|  SSH_PKI_CTX_FREE(session->pki_context);
  ------------------
  |  | 1027|  17.2k|    do {                         \
  |  | 1028|  17.2k|        if ((x) != NULL) {       \
  |  |  ------------------
  |  |  |  Branch (1028:13): [True: 17.2k, False: 0]
  |  |  ------------------
  |  | 1029|  17.2k|            ssh_pki_ctx_free(x); \
  |  | 1030|  17.2k|            x = NULL;            \
  |  | 1031|  17.2k|        }                        \
  |  | 1032|  17.2k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (1032:14): [Folded, False: 17.2k]
  |  |  ------------------
  ------------------
  309|       |
  310|  17.2k|  ssh_key_free(session->srv.rsa_key);
  311|  17.2k|  session->srv.rsa_key = NULL;
  312|  17.2k|  ssh_key_free(session->srv.ecdsa_key);
  313|  17.2k|  session->srv.ecdsa_key = NULL;
  314|  17.2k|  ssh_key_free(session->srv.ed25519_key);
  315|  17.2k|  session->srv.ed25519_key = NULL;
  316|       |
  317|  17.2k|  if (session->ssh_message_list) {
  ------------------
  |  Branch (317:7): [True: 0, False: 17.2k]
  ------------------
  318|      0|      ssh_message msg;
  319|       |
  320|      0|      for (msg = ssh_list_pop_head(ssh_message, session->ssh_message_list);
  ------------------
  |  |  122|      0|  ((type)_ssh_list_pop_head(ssh_list))
  ------------------
  321|      0|           msg != NULL;
  ------------------
  |  Branch (321:12): [True: 0, False: 0]
  ------------------
  322|      0|           msg = ssh_list_pop_head(ssh_message, session->ssh_message_list)) {
  ------------------
  |  |  122|      0|  ((type)_ssh_list_pop_head(ssh_list))
  ------------------
  323|      0|          ssh_message_free(msg);
  324|      0|      }
  325|      0|      ssh_list_free(session->ssh_message_list);
  326|      0|  }
  327|       |
  328|  17.2k|  if (session->kbdint != NULL) {
  ------------------
  |  Branch (328:7): [True: 0, False: 17.2k]
  ------------------
  329|      0|    ssh_kbdint_free(session->kbdint);
  330|      0|  }
  331|       |
  332|  17.2k|  if (session->packet_callbacks) {
  ------------------
  |  Branch (332:7): [True: 0, False: 17.2k]
  ------------------
  333|      0|    ssh_list_free(session->packet_callbacks);
  334|      0|  }
  335|       |
  336|       |#ifdef WITH_GSSAPI
  337|       |    ssh_gssapi_free(session);
  338|       |    SAFE_FREE(session->opts.gssapi_key_exchange_algs);
  339|       |#endif
  340|       |
  341|       |  /* options */
  342|  17.2k|  if (session->opts.identity) {
  ------------------
  |  Branch (342:7): [True: 17.2k, False: 0]
  ------------------
  343|  17.2k|      char *id = NULL;
  344|       |
  345|  17.2k|      for (id = ssh_list_pop_head(char *, session->opts.identity);
  ------------------
  |  |  122|  17.2k|  ((type)_ssh_list_pop_head(ssh_list))
  ------------------
  346|  43.2k|           id != NULL;
  ------------------
  |  Branch (346:12): [True: 25.9k, False: 17.2k]
  ------------------
  347|  25.9k|           id = ssh_list_pop_head(char *, session->opts.identity)) {
  ------------------
  |  |  122|  25.9k|  ((type)_ssh_list_pop_head(ssh_list))
  ------------------
  348|  25.9k|          SAFE_FREE(id);
  ------------------
  |  |  373|  25.9k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 25.9k, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 25.9k]
  |  |  ------------------
  ------------------
  349|  25.9k|      }
  350|  17.2k|      ssh_list_free(session->opts.identity);
  351|  17.2k|  }
  352|       |
  353|  17.2k|  if (session->opts.identity_non_exp) {
  ------------------
  |  Branch (353:7): [True: 17.2k, False: 0]
  ------------------
  354|  17.2k|      char *id = NULL;
  355|       |
  356|  17.2k|      for (id = ssh_list_pop_head(char *, session->opts.identity_non_exp);
  ------------------
  |  |  122|  17.2k|  ((type)_ssh_list_pop_head(ssh_list))
  ------------------
  357|  43.2k|           id != NULL;
  ------------------
  |  Branch (357:12): [True: 25.9k, False: 17.2k]
  ------------------
  358|  25.9k|           id = ssh_list_pop_head(char *, session->opts.identity_non_exp)) {
  ------------------
  |  |  122|  25.9k|  ((type)_ssh_list_pop_head(ssh_list))
  ------------------
  359|  25.9k|          SAFE_FREE(id);
  ------------------
  |  |  373|  25.9k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 25.9k, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 25.9k]
  |  |  ------------------
  ------------------
  360|  25.9k|      }
  361|  17.2k|      ssh_list_free(session->opts.identity_non_exp);
  362|  17.2k|  }
  363|       |
  364|  17.2k|    if (session->opts.certificate) {
  ------------------
  |  Branch (364:9): [True: 17.2k, False: 0]
  ------------------
  365|  17.2k|        char *cert = NULL;
  366|       |
  367|  17.2k|        for (cert = ssh_list_pop_head(char *, session->opts.certificate);
  ------------------
  |  |  122|  17.2k|  ((type)_ssh_list_pop_head(ssh_list))
  ------------------
  368|  17.2k|             cert != NULL;
  ------------------
  |  Branch (368:14): [True: 0, False: 17.2k]
  ------------------
  369|  17.2k|             cert = ssh_list_pop_head(char *, session->opts.certificate)) {
  ------------------
  |  |  122|      0|  ((type)_ssh_list_pop_head(ssh_list))
  ------------------
  370|      0|            SAFE_FREE(cert);
  ------------------
  |  |  373|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
  371|      0|        }
  372|  17.2k|        ssh_list_free(session->opts.certificate);
  373|  17.2k|    }
  374|       |
  375|  17.2k|    if (session->opts.certificate_non_exp) {
  ------------------
  |  Branch (375:9): [True: 17.2k, False: 0]
  ------------------
  376|  17.2k|        char *cert = NULL;
  377|       |
  378|  17.2k|        for (cert = ssh_list_pop_head(char *, session->opts.certificate_non_exp);
  ------------------
  |  |  122|  17.2k|  ((type)_ssh_list_pop_head(ssh_list))
  ------------------
  379|  17.2k|             cert != NULL;
  ------------------
  |  Branch (379:14): [True: 0, False: 17.2k]
  ------------------
  380|  17.2k|             cert = ssh_list_pop_head(char *, session->opts.certificate_non_exp)) {
  ------------------
  |  |  122|      0|  ((type)_ssh_list_pop_head(ssh_list))
  ------------------
  381|      0|            SAFE_FREE(cert);
  ------------------
  |  |  373|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
  382|      0|        }
  383|  17.2k|        ssh_list_free(session->opts.certificate_non_exp);
  384|  17.2k|    }
  385|       |
  386|  17.2k|    ssh_proxyjumps_free(session->opts.proxy_jumps);
  387|  17.2k|    SSH_LIST_FREE(session->opts.proxy_jumps);
  ------------------
  |  |  125|  17.2k|    do { if ((x) != NULL) { ssh_list_free(x); (x) = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (125:14): [True: 17.2k, False: 0]
  |  |  |  Branch (125:69): [Folded, False: 17.2k]
  |  |  ------------------
  ------------------
  388|  17.2k|    SSH_LIST_FREE(session->opts.proxy_jumps_user_cb);
  ------------------
  |  |  125|  17.2k|    do { if ((x) != NULL) { ssh_list_free(x); (x) = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (125:14): [True: 17.2k, False: 0]
  |  |  |  Branch (125:69): [Folded, False: 17.2k]
  |  |  ------------------
  ------------------
  389|  17.2k|    SAFE_FREE(session->opts.proxy_jumps_str);
  ------------------
  |  |  373|  17.2k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 17.2k]
  |  |  |  Branch (373:71): [Folded, False: 17.2k]
  |  |  ------------------
  ------------------
  390|       |
  391|  17.2k|    while ((b = ssh_list_pop_head(struct ssh_buffer_struct *,
  ------------------
  |  |  122|  17.2k|  ((type)_ssh_list_pop_head(ssh_list))
  ------------------
  |  Branch (391:12): [True: 0, False: 17.2k]
  ------------------
  392|  17.2k|                                  session->out_queue)) != NULL) {
  393|      0|        SSH_BUFFER_FREE(b);
  ------------------
  |  |  934|      0|    do { if ((x) != NULL) { ssh_buffer_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (934:14): [True: 0, False: 0]
  |  |  |  Branch (934:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
  394|      0|    }
  395|  17.2k|    ssh_list_free(session->out_queue);
  396|       |
  397|  17.2k|  ssh_agent_state_free(session->agent_state);
  398|  17.2k|  session->agent_state = NULL;
  399|       |
  400|  17.2k|  SAFE_FREE(session->auth.auto_state);
  ------------------
  |  |  373|  17.2k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 17.2k]
  |  |  |  Branch (373:71): [Folded, False: 17.2k]
  |  |  ------------------
  ------------------
  401|  17.2k|  SAFE_FREE(session->serverbanner);
  ------------------
  |  |  373|  17.2k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 17.2k]
  |  |  |  Branch (373:71): [Folded, False: 17.2k]
  |  |  ------------------
  ------------------
  402|  17.2k|  SAFE_FREE(session->clientbanner);
  ------------------
  |  |  373|  17.2k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 17.2k]
  |  |  |  Branch (373:71): [Folded, False: 17.2k]
  |  |  ------------------
  ------------------
  403|  17.2k|  SAFE_FREE(session->banner);
  ------------------
  |  |  373|  17.2k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 17.2k]
  |  |  |  Branch (373:71): [Folded, False: 17.2k]
  |  |  ------------------
  ------------------
  404|  17.2k|  SAFE_FREE(session->disconnect_message);
  ------------------
  |  |  373|  17.2k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 17.2k]
  |  |  |  Branch (373:71): [Folded, False: 17.2k]
  |  |  ------------------
  ------------------
  405|  17.2k|  SAFE_FREE(session->peer_discon_msg);
  ------------------
  |  |  373|  17.2k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 17.2k]
  |  |  |  Branch (373:71): [Folded, False: 17.2k]
  |  |  ------------------
  ------------------
  406|       |
  407|  17.2k|  SAFE_FREE(session->opts.agent_socket);
  ------------------
  |  |  373|  17.2k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 17.2k]
  |  |  |  Branch (373:71): [Folded, False: 17.2k]
  |  |  ------------------
  ------------------
  408|  17.2k|  SAFE_FREE(session->opts.bindaddr);
  ------------------
  |  |  373|  17.2k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 17.2k]
  |  |  |  Branch (373:71): [Folded, False: 17.2k]
  |  |  ------------------
  ------------------
  409|  17.2k|  SAFE_FREE(session->opts.username);
  ------------------
  |  |  373|  17.2k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 8.64k, False: 8.64k]
  |  |  |  Branch (373:71): [Folded, False: 17.2k]
  |  |  ------------------
  ------------------
  410|  17.2k|  SAFE_FREE(session->opts.host);
  ------------------
  |  |  373|  17.2k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 8.64k, False: 8.64k]
  |  |  |  Branch (373:71): [Folded, False: 17.2k]
  |  |  ------------------
  ------------------
  411|  17.2k|  SAFE_FREE(session->opts.originalhost);
  ------------------
  |  |  373|  17.2k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 8.64k, False: 8.64k]
  |  |  |  Branch (373:71): [Folded, False: 17.2k]
  |  |  ------------------
  ------------------
  412|  17.2k|  SAFE_FREE(session->opts.config_hostname);
  ------------------
  |  |  373|  17.2k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 17.2k]
  |  |  |  Branch (373:71): [Folded, False: 17.2k]
  |  |  ------------------
  ------------------
  413|  17.2k|  SAFE_FREE(session->opts.tag);
  ------------------
  |  |  373|  17.2k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 17.2k]
  |  |  |  Branch (373:71): [Folded, False: 17.2k]
  |  |  ------------------
  ------------------
  414|  17.2k|  SAFE_FREE(session->opts.homedir);
  ------------------
  |  |  373|  17.2k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 8.64k, False: 8.64k]
  |  |  |  Branch (373:71): [Folded, False: 17.2k]
  |  |  ------------------
  ------------------
  415|  17.2k|  SAFE_FREE(session->opts.sshdir);
  ------------------
  |  |  373|  17.2k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 8.64k, False: 8.64k]
  |  |  |  Branch (373:71): [Folded, False: 17.2k]
  |  |  ------------------
  ------------------
  416|  17.2k|  SAFE_FREE(session->opts.knownhosts);
  ------------------
  |  |  373|  17.2k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 8.64k, False: 8.64k]
  |  |  |  Branch (373:71): [Folded, False: 17.2k]
  |  |  ------------------
  ------------------
  417|  17.2k|  SAFE_FREE(session->opts.global_knownhosts);
  ------------------
  |  |  373|  17.2k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 8.64k, False: 8.64k]
  |  |  |  Branch (373:71): [Folded, False: 17.2k]
  |  |  ------------------
  ------------------
  418|  17.2k|  SAFE_FREE(session->opts.ProxyCommand);
  ------------------
  |  |  373|  17.2k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 17.2k]
  |  |  |  Branch (373:71): [Folded, False: 17.2k]
  |  |  ------------------
  ------------------
  419|  17.2k|  SAFE_FREE(session->opts.gss_server_identity);
  ------------------
  |  |  373|  17.2k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 17.2k]
  |  |  |  Branch (373:71): [Folded, False: 17.2k]
  |  |  ------------------
  ------------------
  420|  17.2k|  SAFE_FREE(session->opts.gss_client_identity);
  ------------------
  |  |  373|  17.2k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 17.2k]
  |  |  |  Branch (373:71): [Folded, False: 17.2k]
  |  |  ------------------
  ------------------
  421|  17.2k|  SAFE_FREE(session->opts.pubkey_accepted_types);
  ------------------
  |  |  373|  17.2k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 17.2k]
  |  |  |  Branch (373:71): [Folded, False: 17.2k]
  |  |  ------------------
  ------------------
  422|  17.2k|  SAFE_FREE(session->opts.control_path);
  ------------------
  |  |  373|  17.2k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 17.2k]
  |  |  |  Branch (373:71): [Folded, False: 17.2k]
  |  |  ------------------
  ------------------
  423|       |
  424|   190k|  for (i = 0; i < SSH_KEX_METHODS; i++) {
  ------------------
  |  |   27|   190k|#define SSH_KEX_METHODS 10
  ------------------
  |  Branch (424:15): [True: 172k, False: 17.2k]
  ------------------
  425|   172k|      if (session->opts.wanted_methods[i]) {
  ------------------
  |  Branch (425:11): [True: 77.7k, False: 95.0k]
  ------------------
  426|  77.7k|          SAFE_FREE(session->opts.wanted_methods[i]);
  ------------------
  |  |  373|  77.7k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 77.7k, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 77.7k]
  |  |  ------------------
  ------------------
  427|  77.7k|      }
  428|   172k|  }
  429|       |
  430|  17.2k|  SAFE_FREE(session->server_opts.custombanner);
  ------------------
  |  |  373|  17.2k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 17.2k]
  |  |  |  Branch (373:71): [Folded, False: 17.2k]
  |  |  ------------------
  ------------------
  431|  17.2k|  SAFE_FREE(session->server_opts.moduli_file);
  ------------------
  |  |  373|  17.2k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 17.2k]
  |  |  |  Branch (373:71): [Folded, False: 17.2k]
  |  |  ------------------
  ------------------
  432|       |
  433|  17.2k|  _ssh_remove_legacy_log_cb();
  434|       |
  435|       |  /* burn connection, it could contain sensitive data */
  436|  17.2k|  ssh_burn(session, sizeof(struct ssh_session_struct));
  ------------------
  |  |  388|  17.2k|#define ssh_burn(ptr, len) explicit_bzero((ptr), (len))
  ------------------
  437|       |  SAFE_FREE(session);
  ------------------
  |  |  373|  17.2k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 17.2k, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 17.2k]
  |  |  ------------------
  ------------------
  438|  17.2k|}
ssh_session_socket_close:
  603|  25.9k|{
  604|  25.9k|    if (session->opts.fd == SSH_INVALID_SOCKET) {
  ------------------
  |  |  124|  25.9k|#define SSH_INVALID_SOCKET ((socket_t) -1)
  ------------------
  |  Branch (604:9): [True: 8.64k, False: 17.2k]
  ------------------
  605|  8.64k|        ssh_socket_close(session->socket);
  606|  8.64k|    }
  607|  25.9k|    session->alive = 0;
  608|  25.9k|    session->session_state = SSH_SESSION_STATE_ERROR;
  609|  25.9k|}
ssh_set_blocking:
  637|  17.2k|{
  638|  17.2k|    if (session == NULL) {
  ------------------
  |  Branch (638:9): [True: 0, False: 17.2k]
  ------------------
  639|      0|        return;
  640|      0|    }
  641|  17.2k|    session->flags &= ~SSH_SESSION_FLAG_BLOCKING;
  ------------------
  |  |   75|  17.2k|#define SSH_SESSION_FLAG_BLOCKING 0x0001
  ------------------
  642|  17.2k|    session->flags |= blocking ? SSH_SESSION_FLAG_BLOCKING : 0;
  ------------------
  |  |   75|  17.2k|#define SSH_SESSION_FLAG_BLOCKING 0x0001
  ------------------
  |  Branch (642:23): [True: 17.2k, False: 0]
  ------------------
  643|  17.2k|}
ssh_is_blocking:
  652|   128k|{
  653|   128k|    return (session->flags & SSH_SESSION_FLAG_BLOCKING) ? 1 : 0;
  ------------------
  |  |   75|   128k|#define SSH_SESSION_FLAG_BLOCKING 0x0001
  ------------------
  |  Branch (653:12): [True: 128k, False: 0]
  ------------------
  654|   128k|}
ssh_blocking_flush:
  676|  43.1k|int ssh_blocking_flush(ssh_session session, int timeout){
  677|  43.1k|    int rc;
  678|  43.1k|    if (session == NULL) {
  ------------------
  |  Branch (678:9): [True: 0, False: 43.1k]
  ------------------
  679|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  680|      0|    }
  681|       |
  682|  43.1k|    rc = ssh_handle_packets_termination(session, timeout,
  683|  43.1k|            ssh_flush_termination, session);
  684|  43.1k|    if (rc == SSH_ERROR) {
  ------------------
  |  |  317|  43.1k|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  |  Branch (684:9): [True: 0, False: 43.1k]
  ------------------
  685|      0|        return rc;
  686|      0|    }
  687|  43.1k|    if (!ssh_flush_termination(session)) {
  ------------------
  |  Branch (687:9): [True: 0, False: 43.1k]
  ------------------
  688|      0|        rc = SSH_AGAIN;
  ------------------
  |  |  318|      0|#define SSH_AGAIN -2 /* The nonblocking call must be repeated */
  ------------------
  689|      0|    }
  690|       |
  691|  43.1k|    return rc;
  692|  43.1k|}
ssh_set_fd_towrite:
  746|  8.64k|void ssh_set_fd_towrite(ssh_session session) {
  747|  8.64k|  if (session == NULL) {
  ------------------
  |  Branch (747:7): [True: 0, False: 8.64k]
  ------------------
  748|      0|    return;
  749|      0|  }
  750|       |
  751|  8.64k|  ssh_socket_set_write_wontblock(session->socket);
  752|  8.64k|}
ssh_handle_packets:
  789|   559k|{
  790|   559k|    ssh_poll_handle spoll = NULL;
  791|   559k|    ssh_poll_ctx ctx = NULL;
  792|   559k|    int tm = timeout;
  793|   559k|    int rc;
  794|       |
  795|   559k|    if (session == NULL || session->socket == NULL) {
  ------------------
  |  Branch (795:9): [True: 0, False: 559k]
  |  Branch (795:28): [True: 0, False: 559k]
  ------------------
  796|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  797|      0|    }
  798|       |
  799|   559k|    spoll = ssh_socket_get_poll_handle(session->socket);
  800|   559k|    if (spoll == NULL) {
  ------------------
  |  Branch (800:9): [True: 0, False: 559k]
  ------------------
  801|      0|        ssh_set_error_oom(session);
  ------------------
  |  |  318|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
  802|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  803|      0|    }
  804|   559k|    ssh_poll_add_events(spoll, POLLIN);
  805|   559k|    ctx = ssh_poll_get_ctx(spoll);
  806|       |
  807|   559k|    if (ctx == NULL) {
  ------------------
  |  Branch (807:9): [True: 17.2k, False: 542k]
  ------------------
  808|  17.2k|        ctx = ssh_poll_get_default_ctx(session);
  809|  17.2k|        if (ctx == NULL) {
  ------------------
  |  Branch (809:13): [True: 0, False: 17.2k]
  ------------------
  810|      0|            ssh_set_error_oom(session);
  ------------------
  |  |  318|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
  811|      0|            return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  812|      0|        }
  813|  17.2k|        rc = ssh_poll_ctx_add(ctx, spoll);
  814|  17.2k|        if (rc != SSH_OK) {
  ------------------
  |  |  316|  17.2k|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (814:13): [True: 0, False: 17.2k]
  ------------------
  815|      0|            return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  816|      0|        }
  817|  17.2k|    }
  818|       |
  819|   559k|    if (timeout == SSH_TIMEOUT_USER) {
  ------------------
  |  |  101|   559k|#define SSH_TIMEOUT_USER -2
  ------------------
  |  Branch (819:9): [True: 0, False: 559k]
  ------------------
  820|      0|        if (ssh_is_blocking(session)) {
  ------------------
  |  Branch (820:13): [True: 0, False: 0]
  ------------------
  821|      0|            tm = ssh_make_milliseconds(session->opts.timeout,
  822|      0|                                       session->opts.timeout_usec);
  823|      0|        } else {
  824|      0|            tm = 0;
  825|      0|        }
  826|      0|    }
  827|   559k|    rc = ssh_poll_ctx_dopoll(ctx, tm);
  828|   559k|    if (rc == SSH_ERROR) {
  ------------------
  |  |  317|   559k|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  |  Branch (828:9): [True: 8.63k, False: 550k]
  ------------------
  829|  8.63k|        session->session_state = SSH_SESSION_STATE_ERROR;
  830|  8.63k|    }
  831|       |
  832|   559k|    return rc;
  833|   559k|}
ssh_handle_packets_termination:
  866|   120k|{
  867|   120k|    struct ssh_timestamp ts;
  868|   120k|    int timeout_ms = SSH_TIMEOUT_INFINITE;
  ------------------
  |  |   99|   120k|#define SSH_TIMEOUT_INFINITE -1
  ------------------
  869|   120k|    int tm;
  870|   120k|    int ret = SSH_OK;
  ------------------
  |  |  316|   120k|#define SSH_OK 0     /* No error */
  ------------------
  871|       |
  872|       |    /* If a timeout has been provided, use it */
  873|   120k|    if (timeout >= 0) {
  ------------------
  |  Branch (873:9): [True: 8.64k, False: 111k]
  ------------------
  874|  8.64k|        timeout_ms = timeout;
  875|   111k|    } else {
  876|   111k|        if (ssh_is_blocking(session)) {
  ------------------
  |  Branch (876:13): [True: 111k, False: 0]
  ------------------
  877|   111k|            if (timeout == SSH_TIMEOUT_USER || timeout == SSH_TIMEOUT_DEFAULT) {
  ------------------
  |  |  101|   222k|#define SSH_TIMEOUT_USER -2
  ------------------
                          if (timeout == SSH_TIMEOUT_USER || timeout == SSH_TIMEOUT_DEFAULT) {
  ------------------
  |  |  103|  85.4k|#define SSH_TIMEOUT_DEFAULT -3
  ------------------
  |  Branch (877:17): [True: 25.9k, False: 85.4k]
  |  Branch (877:48): [True: 85.4k, False: 0]
  ------------------
  878|   111k|                if (session->opts.timeout > 0 ||
  ------------------
  |  Branch (878:21): [True: 76.8k, False: 34.5k]
  ------------------
  879|  76.8k|                    session->opts.timeout_usec > 0) {
  ------------------
  |  Branch (879:21): [True: 0, False: 34.5k]
  ------------------
  880|  76.8k|                    timeout_ms =
  881|  76.8k|                        ssh_make_milliseconds(session->opts.timeout,
  882|  76.8k|                                              session->opts.timeout_usec);
  883|  76.8k|                }
  884|   111k|            }
  885|   111k|        } else {
  886|      0|            timeout_ms = SSH_TIMEOUT_NONBLOCKING;
  ------------------
  |  |  105|      0|#define SSH_TIMEOUT_NONBLOCKING 0
  ------------------
  887|      0|        }
  888|   111k|    }
  889|       |
  890|       |    /* avoid unnecessary syscall for the SSH_TIMEOUT_NONBLOCKING case */
  891|   120k|    if (timeout_ms != SSH_TIMEOUT_NONBLOCKING) {
  ------------------
  |  |  105|   120k|#define SSH_TIMEOUT_NONBLOCKING 0
  ------------------
  |  Branch (891:9): [True: 120k, False: 0]
  ------------------
  892|   120k|        ssh_timestamp_init(&ts);
  893|   120k|    }
  894|       |
  895|   120k|    tm = timeout_ms;
  896|   670k|    while(!fct(user)) {
  ------------------
  |  Branch (896:11): [True: 559k, False: 111k]
  ------------------
  897|   559k|        ret = ssh_handle_packets(session, tm);
  898|   559k|        if (ret == SSH_ERROR) {
  ------------------
  |  |  317|   559k|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  |  Branch (898:13): [True: 8.63k, False: 550k]
  ------------------
  899|  8.63k|            break;
  900|  8.63k|        }
  901|   550k|        if (ssh_timeout_elapsed(&ts, timeout_ms)) {
  ------------------
  |  Branch (901:13): [True: 0, False: 550k]
  ------------------
  902|      0|            ret = fct(user) ? SSH_OK : SSH_AGAIN;
  ------------------
  |  |  316|      0|#define SSH_OK 0     /* No error */
  ------------------
                          ret = fct(user) ? SSH_OK : SSH_AGAIN;
  ------------------
  |  |  318|      0|#define SSH_AGAIN -2 /* The nonblocking call must be repeated */
  ------------------
  |  Branch (902:19): [True: 0, False: 0]
  ------------------
  903|      0|            break;
  904|      0|        }
  905|       |
  906|   550k|        tm = ssh_timeout_update(&ts, timeout_ms);
  907|   550k|    }
  908|       |
  909|   120k|    return ret;
  910|   120k|}
ssh_socket_exception_callback:
 1021|  17.2k|void ssh_socket_exception_callback(int code, int errno_code, void *user){
 1022|  17.2k|    ssh_session session = (ssh_session)user;
 1023|       |
 1024|  17.2k|    SSH_LOG(SSH_LOG_RARE,
  ------------------
  |  |  281|  17.2k|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 1025|  17.2k|            "Socket exception callback: %d (%d)",
 1026|  17.2k|            code,
 1027|  17.2k|            errno_code);
 1028|  17.2k|    session->session_state = SSH_SESSION_STATE_ERROR;
 1029|  17.2k|    if (errno_code == 0 && code == SSH_SOCKET_EXCEPTION_EOF) {
  ------------------
  |  |  520|  8.63k|#define SSH_SOCKET_EXCEPTION_EOF 	     1
  ------------------
  |  Branch (1029:9): [True: 8.63k, False: 8.64k]
  |  Branch (1029:28): [True: 8.63k, False: 0]
  ------------------
 1030|  8.63k|        ssh_set_error(session, SSH_FATAL, "Socket error: disconnected");
  ------------------
  |  |  311|  8.63k|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
 1031|       |#ifdef _WIN32
 1032|       |    } else if (errno_code == WSAENETDOWN) {
 1033|       |        ssh_set_error(session, SSH_FATAL, "Socket error: network down");
 1034|       |    } else if (errno_code == WSAENETUNREACH) {
 1035|       |        ssh_set_error(session, SSH_FATAL, "Socket error: network unreachable");
 1036|       |    } else if (errno_code == WSAENETRESET) {
 1037|       |        ssh_set_error(session, SSH_FATAL, "Socket error: network reset");
 1038|       |    } else if (errno_code == WSAECONNABORTED) {
 1039|       |        ssh_set_error(session, SSH_FATAL, "Socket error: connection aborted");
 1040|       |    } else if (errno_code == WSAECONNRESET) {
 1041|       |        ssh_set_error(session,
 1042|       |                      SSH_FATAL,
 1043|       |                      "Socket error: connection reset by peer");
 1044|       |    } else if (errno_code == WSAETIMEDOUT) {
 1045|       |        ssh_set_error(session, SSH_FATAL, "Socket error: connection timed out");
 1046|       |    } else if (errno_code == WSAECONNREFUSED) {
 1047|       |        ssh_set_error(session, SSH_FATAL, "Socket error: connection refused");
 1048|       |    } else if (errno_code == WSAEHOSTUNREACH) {
 1049|       |        ssh_set_error(session, SSH_FATAL, "Socket error: host unreachable");
 1050|       |#endif
 1051|  8.64k|    } else {
 1052|  8.64k|        char err_msg[SSH_ERRNO_MSG_MAX] = {0};
 1053|  8.64k|        ssh_set_error(session,
  ------------------
  |  |  311|  8.64k|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
 1054|  8.64k|                      SSH_FATAL,
 1055|  8.64k|                      "Socket error: %s",
 1056|  8.64k|                      ssh_strerror(errno_code, err_msg, SSH_ERRNO_MSG_MAX));
 1057|  8.64k|    }
 1058|       |
 1059|  17.2k|    session->ssh_connection_callback(session);
 1060|  17.2k|}
session.c:ssh_flush_termination:
  657|   108k|static int ssh_flush_termination(void *c){
  658|   108k|  ssh_session session = c;
  659|   108k|  if (ssh_socket_buffered_write_bytes(session->socket) == 0 ||
  ------------------
  |  Branch (659:7): [True: 51.8k, False: 56.2k]
  ------------------
  660|  56.2k|      session->session_state == SSH_SESSION_STATE_ERROR)
  ------------------
  |  Branch (660:7): [True: 34.5k, False: 21.7k]
  ------------------
  661|  86.3k|    return 1;
  662|  21.7k|  else
  663|  21.7k|    return 0;
  664|   108k|}

ssh_socket_init:
  132|      2|{
  133|      2|    if (sockets_initialized == 0) {
  ------------------
  |  Branch (133:9): [True: 2, False: 0]
  ------------------
  134|       |#ifdef _WIN32
  135|       |        struct WSAData wsaData;
  136|       |
  137|       |        /* Initiates use of the Winsock DLL by a process. */
  138|       |        if (WSAStartup(MAKEWORD(2, 0), &wsaData) != 0) {
  139|       |            return -1;
  140|       |        }
  141|       |#endif
  142|      2|        ssh_poll_init();
  143|       |
  144|      2|        sockets_initialized = 1;
  145|      2|    }
  146|       |
  147|      2|    return 0;
  148|      2|}
ssh_socket_new:
  182|  43.2k|{
  183|  43.2k|    ssh_socket s;
  184|       |
  185|  43.2k|    s = calloc(1, sizeof(struct ssh_socket_struct));
  186|  43.2k|    if (s == NULL) {
  ------------------
  |  Branch (186:9): [True: 0, False: 43.2k]
  ------------------
  187|      0|        ssh_set_error_oom(session);
  ------------------
  |  |  318|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
  188|      0|        return NULL;
  189|      0|    }
  190|  43.2k|    s->fd = SSH_INVALID_SOCKET;
  ------------------
  |  |  124|  43.2k|#define SSH_INVALID_SOCKET ((socket_t) -1)
  ------------------
  191|  43.2k|    s->last_errno = -1;
  192|  43.2k|    s->fd_is_socket = 1;
  193|  43.2k|    s->session = session;
  194|  43.2k|    s->in_buffer = ssh_buffer_new();
  195|  43.2k|    if (s->in_buffer == NULL) {
  ------------------
  |  Branch (195:9): [True: 0, False: 43.2k]
  ------------------
  196|      0|        ssh_set_error_oom(session);
  ------------------
  |  |  318|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
  197|      0|        SAFE_FREE(s);
  ------------------
  |  |  373|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
  198|      0|        return NULL;
  199|      0|    }
  200|  43.2k|    s->out_buffer=ssh_buffer_new();
  201|  43.2k|    if (s->out_buffer == NULL) {
  ------------------
  |  Branch (201:9): [True: 0, False: 43.2k]
  ------------------
  202|      0|        ssh_set_error_oom(session);
  ------------------
  |  |  318|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
  203|      0|        SSH_BUFFER_FREE(s->in_buffer);
  ------------------
  |  |  934|      0|    do { if ((x) != NULL) { ssh_buffer_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (934:14): [True: 0, False: 0]
  |  |  |  Branch (934:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
  204|      0|        SAFE_FREE(s);
  ------------------
  |  |  373|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
  205|      0|        return NULL;
  206|      0|    }
  207|  43.2k|    s->read_wontblock = 0;
  208|  43.2k|    s->write_wontblock = 0;
  209|  43.2k|    s->data_except = 0;
  210|       |    s->poll_handle = NULL;
  211|  43.2k|    s->state=SSH_SOCKET_NONE;
  212|  43.2k|    return s;
  213|  43.2k|}
ssh_socket_reset:
  226|  17.2k|{
  227|  17.2k|    s->fd = SSH_INVALID_SOCKET;
  ------------------
  |  |  124|  17.2k|#define SSH_INVALID_SOCKET ((socket_t) -1)
  ------------------
  228|  17.2k|    s->last_errno = -1;
  229|  17.2k|    s->fd_is_socket = 1;
  230|  17.2k|    ssh_buffer_reinit(s->in_buffer);
  231|  17.2k|    ssh_buffer_reinit(s->out_buffer);
  232|  17.2k|    s->read_wontblock = 0;
  233|  17.2k|    s->write_wontblock = 0;
  234|  17.2k|    s->data_except = 0;
  235|  17.2k|    if (s->poll_handle != NULL) {
  ------------------
  |  Branch (235:9): [True: 8.63k, False: 8.64k]
  ------------------
  236|  8.63k|        ssh_poll_free(s->poll_handle);
  237|       |        s->poll_handle = NULL;
  238|  8.63k|    }
  239|  17.2k|    s->state=SSH_SOCKET_NONE;
  240|  17.2k|#ifndef _WIN32
  241|  17.2k|    s->proxy_pid = 0;
  242|  17.2k|#endif
  243|  17.2k|}
ssh_socket_set_callbacks:
  253|  34.5k|{
  254|  34.5k|    s->callbacks = callbacks;
  255|  34.5k|}
ssh_socket_set_connected:
  269|  17.2k|{
  270|  17.2k|    s->state = SSH_SOCKET_CONNECTED;
  271|       |    /* `POLLOUT` is the event to wait for in a non-blocking connect */
  272|  17.2k|    if (p != NULL) {
  ------------------
  |  Branch (272:9): [True: 17.2k, False: 0]
  ------------------
  273|  17.2k|        ssh_poll_set_events(p, POLLIN | POLLOUT);
  274|  17.2k|    }
  275|  17.2k|}
ssh_socket_pollcallback:
  296|   628k|{
  297|   628k|    ssh_socket s = (ssh_socket)v_s;
  298|   628k|    void *buffer = NULL;
  299|   628k|    ssize_t nread = 0;
  300|   628k|    int rc;
  301|   628k|    int err = 0;
  302|   628k|    socklen_t errlen = sizeof(err);
  303|       |
  304|       |    /* Do not do anything if this socket was already closed */
  305|   628k|    if (!ssh_socket_is_open(s)) {
  ------------------
  |  Branch (305:9): [True: 0, False: 628k]
  ------------------
  306|      0|        return -1;
  307|      0|    }
  308|   628k|    SSH_LOG(SSH_LOG_TRACE,
  ------------------
  |  |  281|  3.77M|    _ssh_log(priority, __func__, __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (281:34): [True: 482k, False: 146k]
  |  |  |  Branch (281:34): [True: 179k, False: 448k]
  |  |  |  Branch (281:34): [True: 0, False: 628k]
  |  |  ------------------
  ------------------
  309|   628k|            "Poll callback on socket %d (%s%s%s), out buffer %" PRIu32, fd,
  310|   628k|            (revents & POLLIN) ? "POLLIN ":"",
  311|   628k|            (revents & POLLOUT) ? "POLLOUT ":"",
  312|   628k|            (revents & POLLERR) ? "POLLERR":"",
  313|   628k|            ssh_buffer_get_len(s->out_buffer));
  314|   628k|    if ((revents & POLLERR) || (revents & POLLHUP)) {
  ------------------
  |  Branch (314:9): [True: 14, False: 628k]
  |  Branch (314:32): [True: 27.3k, False: 601k]
  ------------------
  315|       |        /* Check if we are in a connecting state */
  316|  27.3k|        if (s->state == SSH_SOCKET_CONNECTING) {
  ------------------
  |  Branch (316:13): [True: 0, False: 27.3k]
  ------------------
  317|      0|            s->state = SSH_SOCKET_ERROR;
  318|      0|            rc = getsockopt(fd, SOL_SOCKET, SO_ERROR, (char *)&err, &errlen);
  319|      0|            if (rc < 0) {
  ------------------
  |  Branch (319:17): [True: 0, False: 0]
  ------------------
  320|      0|                err = errno;
  321|      0|            }
  322|      0|            ssh_socket_close(s);
  323|       |            /* Overwrite ssh_socket_close() error with the real socket error */
  324|      0|            s->last_errno = err;
  325|      0|            errno = err;
  326|       |
  327|      0|            if (s->callbacks != NULL && s->callbacks->connected != NULL) {
  ------------------
  |  Branch (327:17): [True: 0, False: 0]
  |  Branch (327:41): [True: 0, False: 0]
  ------------------
  328|      0|                s->callbacks->connected(SSH_SOCKET_CONNECTED_ERROR,
  ------------------
  |  |  524|      0|#define SSH_SOCKET_CONNECTED_ERROR 		2
  ------------------
  329|      0|                                        err,
  330|      0|                                        s->callbacks->userdata);
  331|      0|            }
  332|       |
  333|      0|            return -1;
  334|      0|        }
  335|       |        /* Then we are in a more standard kind of error */
  336|       |        /* force a read to get an explanation */
  337|  27.3k|        revents |= POLLIN;
  338|  27.3k|    }
  339|   628k|    if ((revents & POLLIN) && s->state == SSH_SOCKET_CONNECTED) {
  ------------------
  |  Branch (339:9): [True: 482k, False: 146k]
  |  Branch (339:31): [True: 473k, False: 8.63k]
  ------------------
  340|   473k|        s->read_wontblock = 1;
  341|   473k|        buffer = ssh_buffer_allocate(s->in_buffer, MAX_BUF_SIZE);
  ------------------
  |  |  230|   473k|#define MAX_BUF_SIZE 4096
  ------------------
  342|   473k|        if (buffer) {
  ------------------
  |  Branch (342:13): [True: 473k, False: 0]
  ------------------
  343|   473k|            nread = ssh_socket_unbuffered_read(s, buffer, MAX_BUF_SIZE);
  ------------------
  |  |  230|   473k|#define MAX_BUF_SIZE 4096
  ------------------
  344|   473k|        }
  345|   473k|        if (nread < 0) {
  ------------------
  |  Branch (345:13): [True: 0, False: 473k]
  ------------------
  346|      0|            ssh_buffer_pass_bytes_end(s->in_buffer, MAX_BUF_SIZE);
  ------------------
  |  |  230|      0|#define MAX_BUF_SIZE 4096
  ------------------
  347|      0|            if (p != NULL) {
  ------------------
  |  Branch (347:17): [True: 0, False: 0]
  ------------------
  348|      0|                ssh_poll_remove_events(p, POLLIN);
  349|      0|            }
  350|       |
  351|      0|            if (s->callbacks != NULL && s->callbacks->exception != NULL) {
  ------------------
  |  Branch (351:17): [True: 0, False: 0]
  |  Branch (351:41): [True: 0, False: 0]
  ------------------
  352|      0|                s->callbacks->exception(SSH_SOCKET_EXCEPTION_ERROR,
  ------------------
  |  |  521|      0|#define SSH_SOCKET_EXCEPTION_ERROR     2
  ------------------
  353|      0|                                        s->last_errno,
  354|      0|                                        s->callbacks->userdata);
  355|      0|            }
  356|      0|            return -2;
  357|      0|        }
  358|       |
  359|       |        /* Rollback the unused space */
  360|   473k|        ssh_buffer_pass_bytes_end(s->in_buffer,
  361|   473k|                                  (uint32_t)(MAX_BUF_SIZE - nread));
  ------------------
  |  |  230|   473k|#define MAX_BUF_SIZE 4096
  ------------------
  362|       |
  363|   473k|        if (nread == 0) {
  ------------------
  |  Branch (363:13): [True: 8.63k, False: 465k]
  ------------------
  364|  8.63k|            if (p != NULL) {
  ------------------
  |  Branch (364:17): [True: 8.63k, False: 0]
  ------------------
  365|  8.63k|                ssh_poll_remove_events(p, POLLIN);
  366|  8.63k|            }
  367|  8.63k|            if (s->callbacks != NULL && s->callbacks->exception != NULL) {
  ------------------
  |  Branch (367:17): [True: 8.63k, False: 0]
  |  Branch (367:41): [True: 8.63k, False: 0]
  ------------------
  368|  8.63k|                s->callbacks->exception(SSH_SOCKET_EXCEPTION_EOF,
  ------------------
  |  |  520|  8.63k|#define SSH_SOCKET_EXCEPTION_EOF 	     1
  ------------------
  369|  8.63k|                                        0,
  370|  8.63k|                                        s->callbacks->userdata);
  371|  8.63k|            }
  372|  8.63k|            return -2;
  373|  8.63k|        }
  374|       |
  375|   465k|        if (s->session->socket_counter != NULL) {
  ------------------
  |  Branch (375:13): [True: 0, False: 465k]
  ------------------
  376|      0|            s->session->socket_counter->in_bytes += nread;
  377|      0|        }
  378|       |
  379|       |        /* Call the callback */
  380|   465k|        if (s->callbacks != NULL && s->callbacks->data != NULL) {
  ------------------
  |  Branch (380:13): [True: 465k, False: 0]
  |  Branch (380:37): [True: 465k, False: 0]
  ------------------
  381|   465k|            size_t processed;
  382|   666k|            do {
  383|   666k|                processed = s->callbacks->data(ssh_buffer_get(s->in_buffer),
  384|   666k|                                               ssh_buffer_get_len(s->in_buffer),
  385|   666k|                                               s->callbacks->userdata);
  386|   666k|                ssh_buffer_pass_bytes(s->in_buffer, (uint32_t)processed);
  387|   666k|            } while ((processed > 0) && (s->state == SSH_SOCKET_CONNECTED));
  ------------------
  |  Branch (387:22): [True: 201k, False: 465k]
  |  Branch (387:41): [True: 201k, False: 0]
  ------------------
  388|       |
  389|       |            /* p may have been freed, so don't use it
  390|       |             * anymore in this function */
  391|   465k|            p = NULL;
  392|   465k|        }
  393|   465k|    }
  394|       |#ifdef _WIN32
  395|       |    if (revents & POLLOUT || revents & POLLWRNORM) {
  396|       |#else
  397|   620k|    if (revents & POLLOUT) {
  ------------------
  |  Branch (397:9): [True: 179k, False: 440k]
  ------------------
  398|   179k|#endif
  399|   179k|        uint32_t len;
  400|       |
  401|       |        /* First, POLLOUT is a sign we may be connected */
  402|   179k|        if (s->state == SSH_SOCKET_CONNECTING) {
  ------------------
  |  Branch (402:13): [True: 8.64k, False: 171k]
  ------------------
  403|  8.64k|            SSH_LOG(SSH_LOG_PACKET, "Received POLLOUT in connecting state");
  ------------------
  |  |  281|  8.64k|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  404|  8.64k|            ssh_socket_set_connected(s, p);
  405|       |
  406|  8.64k|            rc = ssh_socket_set_blocking(ssh_socket_get_fd(s));
  407|  8.64k|            if (rc < 0) {
  ------------------
  |  Branch (407:17): [True: 0, False: 8.64k]
  ------------------
  408|      0|                return -1;
  409|      0|            }
  410|       |
  411|  8.64k|            if (s->callbacks != NULL && s->callbacks->connected != NULL) {
  ------------------
  |  Branch (411:17): [True: 8.64k, False: 0]
  |  Branch (411:41): [True: 8.64k, False: 0]
  ------------------
  412|  8.64k|                s->callbacks->connected(SSH_SOCKET_CONNECTED_OK,
  ------------------
  |  |  523|  8.64k|#define SSH_SOCKET_CONNECTED_OK 			1
  ------------------
  413|  8.64k|                                        0,
  414|  8.64k|                                        s->callbacks->userdata);
  415|  8.64k|            }
  416|       |
  417|  8.64k|            return 0;
  418|  8.64k|        }
  419|       |
  420|       |        /* So, we can write data */
  421|   171k|        s->write_wontblock = 1;
  422|   171k|        if (p != NULL) {
  ------------------
  |  Branch (422:13): [True: 146k, False: 24.9k]
  ------------------
  423|   146k|            ssh_poll_remove_events(p, POLLOUT);
  424|   146k|        }
  425|       |
  426|       |        /* If buffered data is pending, write it */
  427|   171k|        len = ssh_buffer_get_len(s->out_buffer);
  428|   171k|        if (len > 0) {
  ------------------
  |  Branch (428:13): [True: 61.2k, False: 110k]
  ------------------
  429|  61.2k|            ssh_socket_nonblocking_flush(s);
  430|   110k|        } else if (s->callbacks != NULL && s->callbacks->controlflow != NULL) {
  ------------------
  |  Branch (430:20): [True: 110k, False: 18.4E]
  |  Branch (430:44): [True: 101k, False: 8.64k]
  ------------------
  431|       |            /* Otherwise advertise the upper level that write can be done */
  432|   101k|            SSH_LOG(SSH_LOG_TRACE, "sending control flow event");
  ------------------
  |  |  281|   101k|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  433|   101k|            s->callbacks->controlflow(SSH_SOCKET_FLOW_WRITEWONTBLOCK,
  ------------------
  |  |  518|   101k|#define SSH_SOCKET_FLOW_WRITEWONTBLOCK 2
  ------------------
  434|   101k|                                      s->callbacks->userdata);
  435|   101k|        }
  436|       |        /* TODO: Find a way to put back POLLOUT when buffering occurs */
  437|   171k|    }
  438|       |
  439|       |    /* Return -1 if the poll handler disappeared */
  440|   611k|    if (s->poll_handle == NULL) {
  ------------------
  |  Branch (440:9): [True: 0, False: 611k]
  ------------------
  441|      0|        return -1;
  442|      0|    }
  443|       |
  444|   611k|    return 0;
  445|   611k|}
ssh_socket_get_poll_handle:
  454|   585k|{
  455|   585k|    if (s->poll_handle) {
  ------------------
  |  Branch (455:9): [True: 568k, False: 17.2k]
  ------------------
  456|   568k|        return s->poll_handle;
  457|   568k|    }
  458|  17.2k|    s->poll_handle = ssh_poll_new(s->fd, 0, ssh_socket_pollcallback, s);
  459|  17.2k|    return s->poll_handle;
  460|   585k|}
ssh_socket_free:
  473|  43.2k|{
  474|  43.2k|    if (s == NULL) {
  ------------------
  |  Branch (474:9): [True: 0, False: 43.2k]
  ------------------
  475|      0|        return;
  476|      0|    }
  477|  43.2k|    ssh_socket_close(s);
  478|  43.2k|    SSH_BUFFER_FREE(s->in_buffer);
  ------------------
  |  |  934|  43.2k|    do { if ((x) != NULL) { ssh_buffer_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (934:14): [True: 43.2k, False: 0]
  |  |  |  Branch (934:69): [Folded, False: 43.2k]
  |  |  ------------------
  ------------------
  479|  43.2k|    SSH_BUFFER_FREE(s->out_buffer);
  ------------------
  |  |  934|  43.2k|    do { if ((x) != NULL) { ssh_buffer_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (934:14): [True: 43.2k, False: 0]
  |  |  |  Branch (934:69): [Folded, False: 43.2k]
  |  |  ------------------
  ------------------
  480|       |    SAFE_FREE(s);
  ------------------
  |  |  373|  43.2k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 43.2k, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 43.2k]
  |  |  ------------------
  ------------------
  481|  43.2k|}
ssh_socket_close:
  546|  77.7k|{
  547|  77.7k|    if (ssh_socket_is_open(s)) {
  ------------------
  |  Branch (547:9): [True: 17.2k, False: 60.4k]
  ------------------
  548|       |#ifdef _WIN32
  549|       |        CLOSE_SOCKET(s->fd);
  550|       |        s->last_errno = WSAGetLastError();
  551|       |#else
  552|  17.2k|        CLOSE_SOCKET(s->fd);
  ------------------
  |  |  472|  17.2k|#define CLOSE_SOCKET(s) do { if ((s) != SSH_INVALID_SOCKET) { _XCLOSESOCKET(s); (s) = SSH_INVALID_SOCKET;} } while(0)
  |  |  ------------------
  |  |  |  |  124|  17.2k|#define SSH_INVALID_SOCKET ((socket_t) -1)
  |  |  ------------------
  |  |               #define CLOSE_SOCKET(s) do { if ((s) != SSH_INVALID_SOCKET) { _XCLOSESOCKET(s); (s) = SSH_INVALID_SOCKET;} } while(0)
  |  |  ------------------
  |  |  |  |  199|  17.2k|#define _XCLOSESOCKET close
  |  |  ------------------
  |  |               #define CLOSE_SOCKET(s) do { if ((s) != SSH_INVALID_SOCKET) { _XCLOSESOCKET(s); (s) = SSH_INVALID_SOCKET;} } while(0)
  |  |  ------------------
  |  |  |  |  124|  17.2k|#define SSH_INVALID_SOCKET ((socket_t) -1)
  |  |  ------------------
  |  |  |  Branch (472:34): [True: 17.2k, False: 0]
  |  |  |  Branch (472:116): [Folded, False: 17.2k]
  |  |  ------------------
  ------------------
  553|  17.2k|        s->last_errno = errno;
  554|  17.2k|#endif
  555|  17.2k|    }
  556|       |
  557|  77.7k|    if (s->poll_handle != NULL && !ssh_poll_is_locked(s->poll_handle)) {
  ------------------
  |  Branch (557:9): [True: 17.2k, False: 60.4k]
  |  Branch (557:35): [True: 8.64k, False: 8.63k]
  ------------------
  558|  8.64k|        ssh_poll_free(s->poll_handle);
  559|  8.64k|        s->poll_handle = NULL;
  560|  8.64k|    }
  561|       |
  562|  77.7k|    s->state = SSH_SOCKET_CLOSED;
  563|       |
  564|  77.7k|#ifndef _WIN32
  565|       |    /* If the proxy command still runs try to kill it */
  566|  77.7k|    if (s->proxy_pid != 0) {
  ------------------
  |  Branch (566:9): [True: 0, False: 77.7k]
  ------------------
  567|      0|        int status;
  568|      0|        pid_t pid = s->proxy_pid;
  569|       |
  570|      0|        s->proxy_pid = 0;
  571|      0|        kill(pid, SIGTERM);
  572|      0|        while (waitpid(pid, &status, 0) == -1) {
  ------------------
  |  Branch (572:16): [True: 0, False: 0]
  ------------------
  573|      0|            if (errno != EINTR) {
  ------------------
  |  Branch (573:17): [True: 0, False: 0]
  ------------------
  574|      0|                SSH_LOG_STRERROR(SSH_LOG_TRACE, errno, "waitpid failed: %s");
  ------------------
  |  |  283|      0|    do {                                                            \
  |  |  284|      0|        char err_msg[SSH_ERRNO_MSG_MAX] = {0};                      \
  |  |  285|      0|        _ssh_log(priority,                                          \
  |  |  286|      0|                 __func__,                                          \
  |  |  287|      0|                 __VA_ARGS__,                                       \
  |  |  288|      0|                 ssh_strerror(errnum, err_msg, SSH_ERRNO_MSG_MAX)); \
  |  |  ------------------
  |  |  |  |  520|      0|#define SSH_ERRNO_MSG_MAX   1024
  |  |  ------------------
  |  |  289|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (289:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  575|      0|                return;
  576|      0|            }
  577|      0|        }
  578|      0|        if (!WIFEXITED(status)) {
  ------------------
  |  Branch (578:13): [True: 0, False: 0]
  ------------------
  579|      0|            SSH_LOG(SSH_LOG_TRACE, "Proxy command exited abnormally");
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  580|      0|            return;
  581|      0|        }
  582|      0|        SSH_LOG(SSH_LOG_TRACE, "Proxy command returned %d", WEXITSTATUS(status));
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  583|      0|    }
  584|  77.7k|#endif
  585|  77.7k|}
ssh_socket_set_fd:
  596|  17.2k|{
  597|  17.2k|    ssh_poll_handle h = NULL;
  598|       |
  599|  17.2k|    s->fd = fd;
  600|       |
  601|  17.2k|    if (s->poll_handle) {
  ------------------
  |  Branch (601:9): [True: 0, False: 17.2k]
  ------------------
  602|      0|        ssh_poll_set_fd(s->poll_handle,fd);
  603|  17.2k|    } else {
  604|  17.2k|        s->state = SSH_SOCKET_CONNECTING;
  605|  17.2k|        h = ssh_socket_get_poll_handle(s);
  606|  17.2k|        if (h == NULL) {
  ------------------
  |  Branch (606:13): [True: 0, False: 17.2k]
  ------------------
  607|      0|            return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  608|      0|        }
  609|       |
  610|       |        /* POLLOUT is the event to wait for in a nonblocking connect */
  611|  17.2k|        ssh_poll_set_events(h, POLLOUT);
  612|       |#ifdef _WIN32
  613|       |        ssh_poll_add_events(h, POLLWRNORM);
  614|       |#endif
  615|  17.2k|    }
  616|  17.2k|    return SSH_OK;
  ------------------
  |  |  316|  17.2k|#define SSH_OK 0     /* No error */
  ------------------
  617|  17.2k|}
ssh_socket_get_fd:
  629|  8.64k|{
  630|  8.64k|    return s->fd;
  631|  8.64k|}
ssh_socket_is_open:
  643|  1.23M|{
  644|  1.23M|    return s->fd != SSH_INVALID_SOCKET;
  ------------------
  |  |  124|  1.23M|#define SSH_INVALID_SOCKET ((socket_t) -1)
  ------------------
  645|  1.23M|}
ssh_socket_write:
  811|   227k|{
  812|   227k|    if (len > 0) {
  ------------------
  |  Branch (812:9): [True: 227k, False: 0]
  ------------------
  813|   227k|        if (ssh_buffer_add_data(s->out_buffer, buffer, len) < 0) {
  ------------------
  |  Branch (813:13): [True: 0, False: 227k]
  ------------------
  814|      0|            ssh_set_error_oom(s->session);
  ------------------
  |  |  318|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
  815|      0|            return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  816|      0|        }
  817|   227k|        ssh_socket_nonblocking_flush(s);
  818|   227k|    }
  819|       |
  820|   227k|    return SSH_OK;
  ------------------
  |  |  316|   227k|#define SSH_OK 0     /* No error */
  ------------------
  821|   227k|}
ssh_socket_nonblocking_flush:
  841|   288k|{
  842|   288k|    ssh_session session = s->session;
  843|   288k|    uint32_t len;
  844|       |
  845|   288k|    if (!ssh_socket_is_open(s)) {
  ------------------
  |  Branch (845:9): [True: 0, False: 288k]
  ------------------
  846|      0|        session->alive = 0;
  847|      0|        if (s->callbacks && s->callbacks->exception) {
  ------------------
  |  Branch (847:13): [True: 0, False: 0]
  |  Branch (847:29): [True: 0, False: 0]
  ------------------
  848|      0|            s->callbacks->exception(SSH_SOCKET_EXCEPTION_ERROR,
  ------------------
  |  |  521|      0|#define SSH_SOCKET_EXCEPTION_ERROR     2
  ------------------
  849|      0|                                    s->last_errno,
  850|      0|                                    s->callbacks->userdata);
  851|      0|        } else {
  852|      0|            char err_msg[SSH_ERRNO_MSG_MAX] = {0};
  853|      0|            ssh_set_error(session,
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  854|      0|                          SSH_FATAL,
  855|      0|                          "Writing packet: error on socket (or connection "
  856|      0|                          "closed): %s",
  857|      0|                          ssh_strerror(errno, err_msg, SSH_ERRNO_MSG_MAX));
  858|      0|        }
  859|       |
  860|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  861|      0|    }
  862|       |
  863|   288k|    len = ssh_buffer_get_len(s->out_buffer);
  864|   288k|    if (!s->write_wontblock && s->poll_handle && len > 0) {
  ------------------
  |  Branch (864:9): [True: 111k, False: 177k]
  |  Branch (864:32): [True: 111k, False: 0]
  |  Branch (864:50): [True: 111k, False: 0]
  ------------------
  865|       |        /* force the poll system to catch pollout events */
  866|   111k|        ssh_poll_add_events(s->poll_handle, POLLOUT);
  867|       |
  868|   111k|        return SSH_AGAIN;
  ------------------
  |  |  318|   111k|#define SSH_AGAIN -2 /* The nonblocking call must be repeated */
  ------------------
  869|   111k|    }
  870|       |
  871|   177k|    if (s->write_wontblock && len > 0) {
  ------------------
  |  Branch (871:9): [True: 177k, False: 18.4E]
  |  Branch (871:31): [True: 177k, False: 18.4E]
  ------------------
  872|   177k|        ssize_t bwritten;
  873|       |
  874|   177k|        bwritten = ssh_socket_unbuffered_write(s,
  875|   177k|                                               ssh_buffer_get(s->out_buffer),
  876|   177k|                                               len);
  877|   177k|        if (bwritten < 0) {
  ------------------
  |  Branch (877:13): [True: 8.64k, False: 168k]
  ------------------
  878|  8.64k|            session->alive = 0;
  879|  8.64k|            ssh_socket_close(s);
  880|       |
  881|  8.64k|            if (s->callbacks && s->callbacks->exception) {
  ------------------
  |  Branch (881:17): [True: 8.64k, False: 0]
  |  Branch (881:33): [True: 8.64k, False: 0]
  ------------------
  882|  8.64k|                s->callbacks->exception(SSH_SOCKET_EXCEPTION_ERROR,
  ------------------
  |  |  521|  8.64k|#define SSH_SOCKET_EXCEPTION_ERROR     2
  ------------------
  883|  8.64k|                                        s->last_errno,
  884|  8.64k|                                        s->callbacks->userdata);
  885|  8.64k|            } else {
  886|      0|                char err_msg[SSH_ERRNO_MSG_MAX] = {0};
  887|      0|                ssh_set_error(session,
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  888|      0|                              SSH_FATAL,
  889|      0|                              "Writing packet: error on socket (or connection "
  890|      0|                              "closed): %s",
  891|      0|                              ssh_strerror(errno, err_msg, SSH_ERRNO_MSG_MAX));
  892|      0|            }
  893|       |
  894|  8.64k|            return SSH_ERROR;
  ------------------
  |  |  317|  8.64k|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  895|  8.64k|        }
  896|       |
  897|   168k|        ssh_buffer_pass_bytes(s->out_buffer, (uint32_t)bwritten);
  898|   168k|        if (s->session->socket_counter != NULL) {
  ------------------
  |  Branch (898:13): [True: 0, False: 168k]
  ------------------
  899|      0|            s->session->socket_counter->out_bytes += bwritten;
  900|      0|        }
  901|   168k|    }
  902|       |
  903|       |    /* Is there some data pending? */
  904|   168k|    len = ssh_buffer_get_len(s->out_buffer);
  905|   168k|    if (s->poll_handle && len > 0) {
  ------------------
  |  Branch (905:9): [True: 168k, False: 18.4E]
  |  Branch (905:27): [True: 0, False: 168k]
  ------------------
  906|      0|        SSH_LOG(SSH_LOG_TRACE,
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  907|      0|                "did not send all the data, queuing pollout event");
  908|       |        /* force the poll system to catch pollout events */
  909|      0|        ssh_poll_add_events(s->poll_handle, POLLOUT);
  910|       |
  911|      0|        return SSH_AGAIN;
  ------------------
  |  |  318|      0|#define SSH_AGAIN -2 /* The nonblocking call must be repeated */
  ------------------
  912|      0|    }
  913|       |
  914|       |    /* all data written */
  915|   168k|    return SSH_OK;
  ------------------
  |  |  316|   168k|#define SSH_OK 0     /* No error */
  ------------------
  916|   168k|}
ssh_socket_set_write_wontblock:
  929|  8.64k|{
  930|  8.64k|    s->write_wontblock = 1;
  931|  8.64k|}
ssh_socket_buffered_write_bytes:
 1002|   108k|{
 1003|   108k|    if (s==NULL || s->out_buffer == NULL) {
  ------------------
  |  Branch (1003:9): [True: 0, False: 108k]
  |  Branch (1003:20): [True: 0, False: 108k]
  ------------------
 1004|      0|        return 0;
 1005|      0|    }
 1006|       |
 1007|   108k|    return ssh_buffer_get_len(s->out_buffer);
 1008|   108k|}
ssh_socket_set_blocking:
 1114|  8.64k|{
 1115|       |    return fcntl(fd, F_SETFL, 0);
 1116|  8.64k|}
socket.c:ssh_socket_unbuffered_read:
  665|   473k|{
  666|   473k|    ssize_t rc = -1;
  667|       |
  668|   473k|    if (s->data_except) {
  ------------------
  |  Branch (668:9): [True: 0, False: 473k]
  ------------------
  669|      0|        return -1;
  670|      0|    }
  671|   473k|    if (s->fd_is_socket) {
  ------------------
  |  Branch (671:9): [True: 473k, False: 0]
  ------------------
  672|   473k|        rc = recv(s->fd, buffer, len, 0);
  673|   473k|    } else {
  674|      0|        rc = read(s->fd, buffer, len);
  675|      0|    }
  676|       |#ifdef _WIN32
  677|       |    s->last_errno = WSAGetLastError();
  678|       |#else
  679|   473k|    s->last_errno = errno;
  680|   473k|#endif
  681|   473k|    s->read_wontblock = 0;
  682|       |
  683|   473k|    if (rc < 0) {
  ------------------
  |  Branch (683:9): [True: 0, False: 473k]
  ------------------
  684|      0|        s->data_except = 1;
  685|   473k|    } else {
  686|   473k|        SSH_LOG(SSH_LOG_TRACE, "read %zd", rc);
  ------------------
  |  |  281|   473k|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  687|   473k|    }
  688|       |
  689|   473k|    return rc;
  690|   473k|}
socket.c:ssh_socket_unbuffered_write:
  711|   177k|{
  712|   177k|    ssize_t w = -1;
  713|   177k|    int flags = 0;
  714|       |
  715|   177k|#ifdef MSG_NOSIGNAL
  716|   177k|    flags |= MSG_NOSIGNAL;
  717|   177k|#endif
  718|       |
  719|   177k|    if (s->data_except) {
  ------------------
  |  Branch (719:9): [True: 0, False: 177k]
  ------------------
  720|      0|        return -1;
  721|      0|    }
  722|       |
  723|   177k|    if (s->fd_is_socket) {
  ------------------
  |  Branch (723:9): [True: 177k, False: 0]
  ------------------
  724|   177k|        w = send(s->fd, buffer, len, flags);
  725|   177k|    } else {
  726|      0|        w = write(s->fd, buffer, len);
  727|      0|    }
  728|       |#ifdef _WIN32
  729|       |    s->last_errno = WSAGetLastError();
  730|       |#else
  731|   177k|    s->last_errno = errno;
  732|   177k|#endif
  733|   177k|    s->write_wontblock = 0;
  734|       |    /* Reactive the POLLOUT detector in the poll multiplexer system */
  735|   177k|    if (s->poll_handle) {
  ------------------
  |  Branch (735:9): [True: 177k, False: 18.4E]
  ------------------
  736|   177k|        SSH_LOG(SSH_LOG_PACKET, "Enabling POLLOUT for socket");
  ------------------
  |  |  281|   177k|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  737|   177k|        ssh_poll_add_events(s->poll_handle, POLLOUT);
  738|   177k|    }
  739|   177k|    if (w < 0) {
  ------------------
  |  Branch (739:9): [True: 8.64k, False: 168k]
  ------------------
  740|  8.64k|        s->data_except = 1;
  741|  8.64k|    }
  742|       |
  743|   177k|    SSH_LOG(SSH_LOG_TRACE, "wrote %zd", w);
  ------------------
  |  |  281|   177k|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  744|   177k|    return w;
  745|   177k|}

ssh_string_new:
   57|   744k|{
   58|   744k|    struct ssh_string_struct *str = NULL;
   59|       |
   60|   744k|    if (size > STRING_SIZE_MAX) {
  ------------------
  |  |   38|   744k|#define STRING_SIZE_MAX 0x10000000
  ------------------
  |  Branch (60:9): [True: 0, False: 744k]
  ------------------
   61|      0|        errno = EINVAL;
   62|      0|        return NULL;
   63|      0|    }
   64|       |
   65|   744k|    str = calloc(1, sizeof(struct ssh_string_struct) + size);
   66|   744k|    if (str == NULL) {
  ------------------
  |  Branch (66:9): [True: 0, False: 744k]
  ------------------
   67|      0|        return NULL;
   68|      0|    }
   69|       |
   70|   744k|    str->size = htonl((uint32_t)size);
   71|       |
   72|   744k|    return str;
   73|   744k|}
ssh_string_fill:
   87|  95.0k|{
   88|  95.0k|    if ((s == NULL) || (data == NULL) || (len == 0) ||
  ------------------
  |  Branch (88:9): [True: 0, False: 95.0k]
  |  Branch (88:24): [True: 0, False: 95.0k]
  |  Branch (88:42): [True: 0, False: 95.0k]
  ------------------
   89|  95.0k|        (len > ssh_string_len(s))) {
  ------------------
  |  Branch (89:9): [True: 0, False: 95.0k]
  ------------------
   90|      0|        return -1;
   91|      0|    }
   92|       |
   93|  95.0k|    memcpy(s->data, data, len);
   94|       |
   95|  95.0k|    return 0;
   96|  95.0k|}
ssh_string_from_char:
  109|   215k|{
  110|   215k|    struct ssh_string_struct *ptr = NULL;
  111|   215k|    size_t len;
  112|       |
  113|   215k|    if (what == NULL) {
  ------------------
  |  Branch (113:9): [True: 0, False: 215k]
  ------------------
  114|      0|        errno = EINVAL;
  115|      0|        return NULL;
  116|      0|    }
  117|       |
  118|   215k|    len = strlen(what);
  119|       |
  120|   215k|    ptr = ssh_string_new(len);
  121|   215k|    if (ptr == NULL) {
  ------------------
  |  Branch (121:9): [True: 0, False: 215k]
  ------------------
  122|      0|        return NULL;
  123|      0|    }
  124|       |
  125|   215k|    memcpy(ptr->data, what, len);
  126|       |
  127|   215k|    return ptr;
  128|   215k|}
ssh_string_len:
  177|  1.41M|{
  178|  1.41M|    size_t size;
  179|       |
  180|  1.41M|    if (s == NULL) {
  ------------------
  |  Branch (180:9): [True: 17.2k, False: 1.40M]
  ------------------
  181|  17.2k|        return 0;
  182|  17.2k|    }
  183|       |
  184|  1.40M|    size = ntohl(s->size);
  185|  1.40M|    if (size > 0 && size <= STRING_SIZE_MAX) {
  ------------------
  |  |   38|  1.26M|#define STRING_SIZE_MAX 0x10000000
  ------------------
  |  Branch (185:9): [True: 1.26M, False: 137k]
  |  Branch (185:21): [True: 1.26M, False: 18.4E]
  ------------------
  186|  1.26M|        return size;
  187|  1.26M|    }
  188|       |
  189|   137k|    return 0;
  190|  1.40M|}
ssh_string_get_char:
  202|  25.9k|{
  203|  25.9k|    if (s == NULL) {
  ------------------
  |  Branch (203:9): [True: 0, False: 25.9k]
  ------------------
  204|      0|        return NULL;
  205|      0|    }
  206|  25.9k|    s->data[ssh_string_len(s)] = '\0';
  207|       |
  208|  25.9k|    return (const char *)s->data;
  209|  25.9k|}
ssh_string_to_char:
  223|   172k|{
  224|   172k|    size_t len;
  225|   172k|    char *new = NULL;
  226|       |
  227|   172k|    if (s == NULL) {
  ------------------
  |  Branch (227:9): [True: 0, False: 172k]
  ------------------
  228|      0|        return NULL;
  229|      0|    }
  230|       |
  231|   172k|    len = ssh_string_len(s);
  232|   172k|    if (len + 1 < len) {
  ------------------
  |  Branch (232:9): [True: 0, False: 172k]
  ------------------
  233|      0|        return NULL;
  234|      0|    }
  235|       |
  236|   172k|    new = malloc(len + 1);
  237|   172k|    if (new == NULL) {
  ------------------
  |  Branch (237:9): [True: 0, False: 172k]
  ------------------
  238|      0|        return NULL;
  239|      0|    }
  240|   172k|    memcpy(new, s->data, len);
  241|   172k|    new[len] = '\0';
  242|       |
  243|   172k|    return new;
  244|   172k|}
ssh_string_copy:
  265|  25.9k|{
  266|  25.9k|    struct ssh_string_struct *new = NULL;
  267|  25.9k|    size_t len;
  268|       |
  269|  25.9k|    if (s == NULL) {
  ------------------
  |  Branch (269:9): [True: 0, False: 25.9k]
  ------------------
  270|      0|        return NULL;
  271|      0|    }
  272|       |
  273|  25.9k|    len = ssh_string_len(s);
  274|       |
  275|  25.9k|    new = ssh_string_new(len);
  276|  25.9k|    if (new == NULL) {
  ------------------
  |  Branch (276:9): [True: 0, False: 25.9k]
  ------------------
  277|      0|        return NULL;
  278|      0|    }
  279|       |
  280|  25.9k|    memcpy(new->data, s->data, len);
  281|       |
  282|  25.9k|    return new;
  283|  25.9k|}
ssh_string_burn:
  341|   155k|{
  342|   155k|    if (s == NULL || s->size == 0) {
  ------------------
  |  Branch (342:9): [True: 51.8k, False: 103k]
  |  Branch (342:22): [True: 0, False: 103k]
  ------------------
  343|  51.8k|        return;
  344|  51.8k|    }
  345|       |
  346|   103k|    ssh_burn(s->data, ssh_string_len(s));
  ------------------
  |  |  388|   103k|#define ssh_burn(ptr, len) explicit_bzero((ptr), (len))
  ------------------
  347|   103k|}
ssh_string_data:
  357|   601k|{
  358|   601k|    if (s == NULL) {
  ------------------
  |  Branch (358:9): [True: 0, False: 601k]
  ------------------
  359|      0|        return NULL;
  360|      0|    }
  361|       |
  362|   601k|    return s->data;
  363|   601k|}
ssh_string_free:
  371|   952k|{
  372|       |    SAFE_FREE(s);
  ------------------
  |  |  373|   952k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 710k, False: 241k]
  |  |  |  Branch (373:71): [Folded, False: 952k]
  |  |  ------------------
  ------------------
  373|   952k|}

ssh_threads_init:
   42|      2|{
   43|      2|    static int threads_initialized = 0;
   44|      2|    int rc;
   45|       |
   46|      2|    if (threads_initialized) {
  ------------------
  |  Branch (46:9): [True: 0, False: 2]
  ------------------
   47|      0|        return SSH_OK;
  ------------------
  |  |  316|      0|#define SSH_OK 0     /* No error */
  ------------------
   48|      0|    }
   49|       |
   50|       |    /* first initialize the user_callbacks with our default handlers if not
   51|       |     * already the case
   52|       |     */
   53|      2|    if (user_callbacks == NULL){
  ------------------
  |  Branch (53:9): [True: 2, False: 0]
  ------------------
   54|      2|        user_callbacks = ssh_threads_get_default();
   55|      2|    }
   56|       |
   57|       |    /* Then initialize the crypto libraries threading callbacks */
   58|      2|    rc = crypto_thread_init(user_callbacks);
   59|      2|    if (rc == SSH_OK) {
  ------------------
  |  |  316|      2|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (59:9): [True: 2, False: 0]
  ------------------
   60|      2|        threads_initialized = 1;
   61|      2|    }
   62|      2|    return rc;
   63|      2|}
ssh_threads_get_type:
   96|  8.64k|{
   97|  8.64k|    if (user_callbacks != NULL) {
  ------------------
  |  Branch (97:9): [True: 8.64k, False: 0]
  ------------------
   98|  8.64k|        return user_callbacks->type;
   99|  8.64k|    }
  100|      0|    return NULL;
  101|  8.64k|}

crypto_thread_init:
   28|      2|{
   29|      2|    (void) cb;
   30|      2|    return SSH_OK;
  ------------------
  |  |  316|      2|#define SSH_OK 0     /* No error */
  ------------------
   31|      2|}

ssh_mutex_lock:
  102|  8.64k|{
  103|  8.64k|    int rc;
  104|       |
  105|  8.64k|    if (mutex == NULL) {
  ------------------
  |  Branch (105:9): [True: 0, False: 8.64k]
  ------------------
  106|      0|        exit(EINVAL);
  107|      0|    }
  108|       |
  109|  8.64k|    rc = pthread_mutex_lock(mutex);
  110|       |
  111|  8.64k|    if (rc) {
  ------------------
  |  Branch (111:9): [True: 0, False: 8.64k]
  ------------------
  112|      0|        exit(rc);
  113|      0|    }
  114|  8.64k|}
ssh_mutex_unlock:
  117|  8.64k|{
  118|  8.64k|    int rc;
  119|       |
  120|  8.64k|    if (mutex == NULL) {
  ------------------
  |  Branch (120:9): [True: 0, False: 8.64k]
  ------------------
  121|      0|        exit(EINVAL);
  122|      0|    }
  123|       |
  124|  8.64k|    rc = pthread_mutex_unlock(mutex);
  125|       |
  126|  8.64k|    if (rc) {
  ------------------
  |  Branch (126:9): [True: 0, False: 8.64k]
  ------------------
  127|      0|        exit(rc);
  128|      0|    }
  129|  8.64k|}
ssh_threads_get_default:
  132|      2|{
  133|      2|    return &ssh_threads_pthread;
  134|      2|}

ssh_tokens_free:
   43|   569k|{
   44|   569k|    int i;
   45|   569k|    if (tokens == NULL) {
  ------------------
  |  Branch (45:9): [True: 0, False: 569k]
  ------------------
   46|      0|        return;
   47|      0|    }
   48|       |
   49|   569k|    if (tokens->tokens != NULL) {
  ------------------
  |  Branch (49:9): [True: 569k, False: 18.4E]
  ------------------
   50|  2.77M|        for (i = 0; tokens->tokens[i] != NULL; i++) {
  ------------------
  |  Branch (50:21): [True: 2.20M, False: 569k]
  ------------------
   51|  2.20M|            ssh_burn(tokens->tokens[i], strlen(tokens->tokens[i]));
  ------------------
  |  |  388|  2.20M|#define ssh_burn(ptr, len) explicit_bzero((ptr), (len))
  ------------------
   52|  2.20M|        }
   53|   569k|    }
   54|       |
   55|   569k|    SAFE_FREE(tokens->buffer);
  ------------------
  |  |  373|   569k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 568k, False: 147]
  |  |  |  Branch (373:71): [Folded, False: 569k]
  |  |  ------------------
  ------------------
   56|   569k|    SAFE_FREE(tokens->tokens);
  ------------------
  |  |  373|   569k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 569k, False: 18.4E]
  |  |  |  Branch (373:71): [Folded, False: 569k]
  |  |  ------------------
  ------------------
   57|       |    SAFE_FREE(tokens);
  ------------------
  |  |  373|   569k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 569k, False: 48]
  |  |  |  Branch (373:71): [Folded, False: 569k]
  |  |  ------------------
  ------------------
   58|   569k|}
ssh_tokenize:
   74|   568k|{
   75|       |
   76|   568k|    struct ssh_tokens_st *tokens = NULL;
   77|   568k|    size_t num_tokens = 1, i = 1;
   78|       |
   79|   568k|    char *found, *c;
   80|       |
   81|   568k|    if (chain == NULL) {
  ------------------
  |  Branch (81:9): [True: 0, False: 568k]
  ------------------
   82|      0|        return NULL;
   83|      0|    }
   84|       |
   85|   568k|    tokens = calloc(1, sizeof(struct ssh_tokens_st));
   86|   568k|    if (tokens == NULL) {
  ------------------
  |  Branch (86:9): [True: 0, False: 568k]
  ------------------
   87|      0|        return NULL;
   88|      0|    }
   89|       |
   90|   568k|    tokens->buffer = strdup(chain);
   91|   568k|    if (tokens->buffer == NULL) {
  ------------------
  |  Branch (91:9): [True: 0, False: 568k]
  ------------------
   92|      0|        goto error;
   93|      0|    }
   94|       |
   95|   568k|    c = tokens->buffer;
   96|  2.20M|    do {
   97|  2.20M|        found = strchr(c, separator);
   98|  2.20M|        if (found != NULL) {
  ------------------
  |  Branch (98:13): [True: 1.63M, False: 568k]
  ------------------
   99|  1.63M|            c = found + 1;
  100|  1.63M|            num_tokens++;
  101|  1.63M|        }
  102|  2.20M|    } while(found != NULL);
  ------------------
  |  Branch (102:13): [True: 1.63M, False: 568k]
  ------------------
  103|       |
  104|       |    /* Allocate tokens list */
  105|   568k|    tokens->tokens = calloc(num_tokens + 1, sizeof(char *));
  106|   568k|    if (tokens->tokens == NULL) {
  ------------------
  |  Branch (106:9): [True: 0, False: 568k]
  ------------------
  107|      0|        goto error;
  108|      0|    }
  109|       |
  110|       |    /* First token starts in the beginning of the chain */
  111|   568k|    tokens->tokens[0] = tokens->buffer;
  112|   568k|    c = tokens->buffer;
  113|       |
  114|  2.20M|    for (i = 1; i < num_tokens; i++) {
  ------------------
  |  Branch (114:17): [True: 1.63M, False: 569k]
  ------------------
  115|       |        /* Find next separator */
  116|  1.63M|        found = strchr(c, separator);
  117|  1.63M|        if (found == NULL) {
  ------------------
  |  Branch (117:13): [True: 0, False: 1.63M]
  ------------------
  118|      0|            break;
  119|      0|        }
  120|       |
  121|       |        /* Replace it with a string terminator */
  122|  1.63M|        *found = '\0';
  123|       |
  124|       |        /* The next token starts in the next byte */
  125|  1.63M|        c = found + 1;
  126|       |
  127|       |        /* If we did not reach the end of the chain yet, set the next token */
  128|  1.63M|        if (*c != '\0') {
  ------------------
  |  Branch (128:13): [True: 1.63M, False: 18.4E]
  ------------------
  129|  1.63M|            tokens->tokens[i] = c;
  130|  18.4E|        } else {
  131|  18.4E|            break;
  132|  18.4E|        }
  133|  1.63M|    }
  134|       |
  135|   568k|    return tokens;
  136|       |
  137|      0|error:
  138|      0|    ssh_tokens_free(tokens);
  139|       |    return NULL;
  140|   568k|}
ssh_find_matching:
  157|   189k|{
  158|   189k|    struct ssh_tokens_st *a_tok = NULL, *p_tok = NULL;
  159|       |
  160|   189k|    int i, j;
  161|   189k|    char *ret = NULL;
  162|       |
  163|   189k|    if ((available_list == NULL) || (preferred_list == NULL)) {
  ------------------
  |  Branch (163:9): [True: 18.4E, False: 189k]
  |  Branch (163:37): [True: 18.4E, False: 189k]
  ------------------
  164|      0|        return NULL;
  165|      0|    }
  166|       |
  167|   189k|    a_tok = ssh_tokenize(available_list, ',');
  168|   189k|    if (a_tok == NULL) {
  ------------------
  |  Branch (168:9): [True: 0, False: 189k]
  ------------------
  169|      0|        return NULL;
  170|      0|    }
  171|       |
  172|   189k|    p_tok = ssh_tokenize(preferred_list, ',');
  173|   189k|    if (p_tok == NULL) {
  ------------------
  |  Branch (173:9): [True: 0, False: 189k]
  ------------------
  174|      0|        goto out;
  175|      0|    }
  176|       |
  177|   206k|    for (i = 0; p_tok->tokens[i]; i++) {
  ------------------
  |  Branch (177:17): [True: 189k, False: 16.7k]
  ------------------
  178|   207k|        for (j = 0; a_tok->tokens[j]; j++) {
  ------------------
  |  Branch (178:21): [True: 189k, False: 17.2k]
  ------------------
  179|   189k|            if (strcmp(a_tok->tokens[j], p_tok->tokens[i]) == 0) {
  ------------------
  |  Branch (179:17): [True: 172k, False: 17.2k]
  ------------------
  180|   172k|                ret = strdup(a_tok->tokens[j]);
  181|   172k|                goto out;
  182|   172k|            }
  183|   189k|        }
  184|   189k|    }
  185|       |
  186|   189k|out:
  187|   189k|    ssh_tokens_free(a_tok);
  188|   189k|    ssh_tokens_free(p_tok);
  189|   189k|    return ret;
  190|   189k|}
ssh_find_all_matching:
  208|  95.0k|{
  209|  95.0k|    struct ssh_tokens_st *a_tok = NULL, *p_tok = NULL;
  210|  95.0k|    int i, j;
  211|  95.0k|    char *ret = NULL;
  212|  95.0k|    size_t max, len, pos = 0;
  213|  95.0k|    int match;
  214|       |
  215|  95.0k|    if ((available_list == NULL) || (preferred_list == NULL)) {
  ------------------
  |  Branch (215:9): [True: 0, False: 95.0k]
  |  Branch (215:37): [True: 0, False: 95.0k]
  ------------------
  216|      0|        return NULL;
  217|      0|    }
  218|       |
  219|  95.0k|    max = MAX(strlen(available_list), strlen(preferred_list));
  ------------------
  |  |  369|  95.0k|#define MAX(a,b) ((a) > (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (369:19): [True: 77.7k, False: 17.2k]
  |  |  ------------------
  ------------------
  220|       |
  221|  95.0k|    ret = calloc(1, max + 1);
  222|  95.0k|    if (ret == NULL) {
  ------------------
  |  Branch (222:9): [True: 0, False: 95.0k]
  ------------------
  223|      0|        return NULL;
  224|      0|    }
  225|       |
  226|  95.0k|    a_tok = ssh_tokenize(available_list, ',');
  227|  95.0k|    if (a_tok == NULL) {
  ------------------
  |  Branch (227:9): [True: 0, False: 95.0k]
  ------------------
  228|      0|        SAFE_FREE(ret);
  ------------------
  |  |  373|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
  229|      0|        goto out;
  230|      0|    }
  231|       |
  232|  95.0k|    p_tok = ssh_tokenize(preferred_list, ',');
  233|  95.0k|    if (p_tok == NULL) {
  ------------------
  |  Branch (233:9): [True: 0, False: 95.0k]
  ------------------
  234|      0|        SAFE_FREE(ret);
  ------------------
  |  |  373|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
  235|      0|        goto out;
  236|      0|    }
  237|       |
  238|   431k|    for (i = 0; p_tok->tokens[i] ; i++) {
  ------------------
  |  Branch (238:17): [True: 336k, False: 95.0k]
  ------------------
  239|  2.40M|        for (j = 0; a_tok->tokens[j]; j++) {
  ------------------
  |  Branch (239:21): [True: 2.07M, False: 336k]
  ------------------
  240|  2.07M|            match = !strcmp(a_tok->tokens[j], p_tok->tokens[i]);
  241|  2.07M|            if (match) {
  ------------------
  |  Branch (241:17): [True: 155k, False: 1.91M]
  ------------------
  242|   155k|                if (pos != 0) {
  ------------------
  |  Branch (242:21): [True: 60.4k, False: 95.0k]
  ------------------
  243|  60.4k|                    ret[pos] = ',';
  244|  60.4k|                    pos++;
  245|  60.4k|                }
  246|       |
  247|   155k|                len = strlen(a_tok->tokens[j]);
  248|   155k|                memcpy(&ret[pos], a_tok->tokens[j], len);
  249|   155k|                pos += len;
  250|   155k|                ret[pos] = '\0';
  251|   155k|            }
  252|  2.07M|        }
  253|   336k|    }
  254|       |
  255|  95.0k|    if (ret[0] == '\0') {
  ------------------
  |  Branch (255:9): [True: 0, False: 95.0k]
  ------------------
  256|      0|        SAFE_FREE(ret);
  ------------------
  |  |  373|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
  257|      0|    }
  258|       |
  259|  95.0k|out:
  260|  95.0k|    ssh_tokens_free(a_tok);
  261|  95.0k|    ssh_tokens_free(p_tok);
  262|  95.0k|    return ret;
  263|  95.0k|}

ssh_get_hmactab:
   74|  17.2k|struct ssh_hmac_struct *ssh_get_hmactab(void) {
   75|  17.2k|  return ssh_hmac_tab;
   76|  17.2k|}
hmac_digest_len:
   78|   943k|size_t hmac_digest_len(enum ssh_hmac_e type) {
   79|   943k|  switch(type) {
   80|   346k|    case SSH_HMAC_SHA1:
  ------------------
  |  Branch (80:5): [True: 346k, False: 596k]
  ------------------
   81|   346k|      return SHA_DIGEST_LEN;
  ------------------
  |  |   44|   346k|#define SHA_DIGEST_LEN SHA_DIGEST_LENGTH
  ------------------
   82|   347k|    case SSH_HMAC_SHA256:
  ------------------
  |  Branch (82:5): [True: 347k, False: 596k]
  ------------------
   83|   347k|      return SHA256_DIGEST_LEN;
  ------------------
  |  |   45|   347k|#define SHA256_DIGEST_LEN SHA256_DIGEST_LENGTH
  ------------------
   84|      0|    case SSH_HMAC_SHA512:
  ------------------
  |  Branch (84:5): [True: 0, False: 943k]
  ------------------
   85|      0|      return SHA512_DIGEST_LEN;
  ------------------
  |  |   47|      0|#define SHA512_DIGEST_LEN SHA512_DIGEST_LENGTH
  ------------------
   86|      0|    case SSH_HMAC_MD5:
  ------------------
  |  Branch (86:5): [True: 0, False: 943k]
  ------------------
   87|      0|      return MD5_DIGEST_LEN;
  ------------------
  |  |   51|      0|#define MD5_DIGEST_LEN MD5_DIGEST_LENGTH
  ------------------
   88|      0|    case SSH_HMAC_AEAD_POLY1305:
  ------------------
  |  Branch (88:5): [True: 0, False: 943k]
  ------------------
   89|      0|      return POLY1305_TAGLEN;
  ------------------
  |  |   37|      0|#define POLY1305_TAGLEN 16
  ------------------
   90|      0|    case SSH_HMAC_AEAD_GCM:
  ------------------
  |  Branch (90:5): [True: 0, False: 943k]
  ------------------
   91|      0|      return AES_GCM_TAGLEN;
  ------------------
  |  |   58|      0|#define AES_GCM_TAGLEN 16
  ------------------
   92|   249k|    default:
  ------------------
  |  Branch (92:5): [True: 249k, False: 693k]
  ------------------
   93|   249k|      return 0;
   94|   943k|  }
   95|   943k|}
ssh_cipher_clear:
  124|   103k|void ssh_cipher_clear(struct ssh_cipher_struct *cipher){
  125|       |#ifdef HAVE_LIBGCRYPT
  126|       |    unsigned int i;
  127|       |#endif
  128|       |
  129|   103k|    if (cipher == NULL) {
  ------------------
  |  Branch (129:9): [True: 69.1k, False: 34.5k]
  ------------------
  130|  69.1k|        return;
  131|  69.1k|    }
  132|       |
  133|       |#ifdef HAVE_LIBGCRYPT
  134|       |    if (cipher->key) {
  135|       |        for (i = 0; i < (cipher->keylen / sizeof(gcry_cipher_hd_t)); i++) {
  136|       |            gcry_cipher_close(cipher->key[i]);
  137|       |        }
  138|       |        SAFE_FREE(cipher->key);
  139|       |    }
  140|       |#endif
  141|       |
  142|  34.5k|    if (cipher->cleanup != NULL) {
  ------------------
  |  Branch (142:9): [True: 25.9k, False: 8.64k]
  ------------------
  143|  25.9k|        cipher->cleanup(cipher);
  144|  25.9k|    }
  145|  34.5k|}
crypto_new:
  153|  51.8k|{
  154|  51.8k|    struct ssh_crypto_struct *crypto = NULL;
  155|       |
  156|  51.8k|    crypto = calloc(1, sizeof(struct ssh_crypto_struct));
  157|  51.8k|    if (crypto == NULL) {
  ------------------
  |  Branch (157:9): [True: 0, False: 51.8k]
  ------------------
  158|      0|        return NULL;
  159|      0|    }
  160|  51.8k|    return crypto;
  161|  51.8k|}
crypto_free:
  164|  69.1k|{
  165|  69.1k|    size_t i;
  166|       |
  167|  69.1k|    if (crypto == NULL) {
  ------------------
  |  Branch (167:9): [True: 17.2k, False: 51.8k]
  ------------------
  168|  17.2k|        return;
  169|  17.2k|    }
  170|       |
  171|  51.8k|    ssh_key_free(crypto->server_pubkey);
  172|       |
  173|  51.8k|    ssh_dh_cleanup(crypto);
  174|  51.8k|    bignum_safe_free(crypto->shared_secret);
  ------------------
  |  |   71|  51.8k|#define bignum_safe_free(num) do { \
  |  |   72|  51.8k|    if ((num) != NULL) { \
  |  |  ------------------
  |  |  |  Branch (72:9): [True: 0, False: 51.8k]
  |  |  ------------------
  |  |   73|      0|        BN_clear_free((num)); \
  |  |   74|      0|        (num)=NULL; \
  |  |   75|      0|    } \
  |  |   76|  51.8k|    } while(0)
  |  |  ------------------
  |  |  |  Branch (76:13): [Folded, False: 51.8k]
  |  |  ------------------
  ------------------
  175|  51.8k|#ifdef HAVE_ECDH
  176|  51.8k|    SAFE_FREE(crypto->ecdh_client_pubkey);
  ------------------
  |  |  373|  51.8k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 51.8k]
  |  |  |  Branch (373:71): [Folded, False: 51.8k]
  |  |  ------------------
  ------------------
  177|  51.8k|    SAFE_FREE(crypto->ecdh_server_pubkey);
  ------------------
  |  |  373|  51.8k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 51.8k]
  |  |  |  Branch (373:71): [Folded, False: 51.8k]
  |  |  ------------------
  ------------------
  178|  51.8k|    if (crypto->ecdh_privkey != NULL) {
  ------------------
  |  Branch (178:9): [True: 0, False: 51.8k]
  ------------------
  179|      0|#ifdef HAVE_OPENSSL_ECC
  180|      0|#if OPENSSL_VERSION_NUMBER < 0x30000000L
  181|      0|        EC_KEY_free(crypto->ecdh_privkey);
  182|       |#else
  183|       |        EVP_PKEY_free(crypto->ecdh_privkey);
  184|       |#endif /* OPENSSL_VERSION_NUMBER */
  185|       |#elif defined HAVE_GCRYPT_ECC
  186|       |        gcry_sexp_release(crypto->ecdh_privkey);
  187|       |#elif defined HAVE_LIBMBEDCRYPTO
  188|       |        mbedtls_ecp_keypair_free(crypto->ecdh_privkey);
  189|       |        SAFE_FREE(crypto->ecdh_privkey);
  190|       |#endif /* HAVE_LIBGCRYPT */
  191|      0|        crypto->ecdh_privkey = NULL;
  192|      0|    }
  193|  51.8k|#endif
  194|  51.8k|#ifdef HAVE_LIBCRYPTO
  195|  51.8k|    EVP_PKEY_free(crypto->curve25519_privkey);
  196|       |#elif defined(HAVE_GCRYPT_CURVE25519)
  197|       |    gcry_sexp_release(crypto->curve25519_privkey);
  198|       |#endif
  199|  51.8k|    SAFE_FREE(crypto->dh_server_signature);
  ------------------
  |  |  373|  51.8k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 0, False: 51.8k]
  |  |  |  Branch (373:71): [Folded, False: 51.8k]
  |  |  ------------------
  ------------------
  200|  51.8k|    if (crypto->session_id != NULL) {
  ------------------
  |  Branch (200:9): [True: 34.5k, False: 17.2k]
  ------------------
  201|  34.5k|        ssh_burn(crypto->session_id, crypto->session_id_len);
  ------------------
  |  |  388|  34.5k|#define ssh_burn(ptr, len) explicit_bzero((ptr), (len))
  ------------------
  202|  34.5k|        SAFE_FREE(crypto->session_id);
  ------------------
  |  |  373|  34.5k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 34.5k, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 34.5k]
  |  |  ------------------
  ------------------
  203|  34.5k|    }
  204|  51.8k|    if (crypto->secret_hash != NULL) {
  ------------------
  |  Branch (204:9): [True: 17.2k, False: 34.5k]
  ------------------
  205|  17.2k|        ssh_burn(crypto->secret_hash, crypto->digest_len);
  ------------------
  |  |  388|  17.2k|#define ssh_burn(ptr, len) explicit_bzero((ptr), (len))
  ------------------
  206|  17.2k|        SAFE_FREE(crypto->secret_hash);
  ------------------
  |  |  373|  17.2k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 17.2k, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 17.2k]
  |  |  ------------------
  ------------------
  207|  17.2k|    }
  208|  51.8k|    compress_cleanup(crypto);
  209|  51.8k|    SAFE_FREE(crypto->encryptIV);
  ------------------
  |  |  373|  51.8k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 17.2k, False: 34.5k]
  |  |  |  Branch (373:71): [Folded, False: 51.8k]
  |  |  ------------------
  ------------------
  210|  51.8k|    SAFE_FREE(crypto->decryptIV);
  ------------------
  |  |  373|  51.8k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 17.2k, False: 34.5k]
  |  |  |  Branch (373:71): [Folded, False: 51.8k]
  |  |  ------------------
  ------------------
  211|  51.8k|    SAFE_FREE(crypto->encryptMAC);
  ------------------
  |  |  373|  51.8k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 17.2k, False: 34.5k]
  |  |  |  Branch (373:71): [Folded, False: 51.8k]
  |  |  ------------------
  ------------------
  212|  51.8k|    SAFE_FREE(crypto->decryptMAC);
  ------------------
  |  |  373|  51.8k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 17.2k, False: 34.5k]
  |  |  |  Branch (373:71): [Folded, False: 51.8k]
  |  |  ------------------
  ------------------
  213|  51.8k|    if (crypto->encryptkey != NULL) {
  ------------------
  |  Branch (213:9): [True: 17.2k, False: 34.5k]
  ------------------
  214|  17.2k|        ssh_burn(crypto->encryptkey, crypto->out_cipher->keysize / 8);
  ------------------
  |  |  388|  17.2k|#define ssh_burn(ptr, len) explicit_bzero((ptr), (len))
  ------------------
  215|  17.2k|        SAFE_FREE(crypto->encryptkey);
  ------------------
  |  |  373|  17.2k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 17.2k, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 17.2k]
  |  |  ------------------
  ------------------
  216|  17.2k|    }
  217|  51.8k|    if (crypto->decryptkey != NULL) {
  ------------------
  |  Branch (217:9): [True: 17.2k, False: 34.5k]
  ------------------
  218|  17.2k|        ssh_burn(crypto->decryptkey, crypto->in_cipher->keysize / 8);
  ------------------
  |  |  388|  17.2k|#define ssh_burn(ptr, len) explicit_bzero((ptr), (len))
  ------------------
  219|  17.2k|        SAFE_FREE(crypto->decryptkey);
  ------------------
  |  |  373|  17.2k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 17.2k, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 17.2k]
  |  |  ------------------
  ------------------
  220|  17.2k|    }
  221|       |
  222|  51.8k|    cipher_free(crypto->in_cipher);
  223|  51.8k|    cipher_free(crypto->out_cipher);
  224|       |
  225|   570k|    for (i = 0; i < SSH_KEX_METHODS; i++) {
  ------------------
  |  |   27|   570k|#define SSH_KEX_METHODS 10
  ------------------
  |  Branch (225:17): [True: 518k, False: 51.8k]
  ------------------
  226|   518k|        SAFE_FREE(crypto->client_kex.methods[i]);
  ------------------
  |  |  373|   518k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 172k, False: 345k]
  |  |  |  Branch (373:71): [Folded, False: 518k]
  |  |  ------------------
  ------------------
  227|   518k|        SAFE_FREE(crypto->server_kex.methods[i]);
  ------------------
  |  |  373|   518k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 172k, False: 345k]
  |  |  |  Branch (373:71): [Folded, False: 518k]
  |  |  ------------------
  ------------------
  228|   518k|        SAFE_FREE(crypto->kex_methods[i]);
  ------------------
  |  |  373|   518k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 172k, False: 345k]
  |  |  |  Branch (373:71): [Folded, False: 518k]
  |  |  ------------------
  ------------------
  229|   518k|    }
  230|       |
  231|       |#ifdef HAVE_OPENSSL_MLKEM
  232|       |    EVP_PKEY_free(crypto->mlkem_privkey);
  233|       |#else
  234|  51.8k|    if (crypto->mlkem_privkey != NULL) {
  ------------------
  |  Branch (234:9): [True: 8.64k, False: 43.2k]
  ------------------
  235|  8.64k|        ssh_burn(crypto->mlkem_privkey, crypto->mlkem_privkey_len);
  ------------------
  |  |  388|  8.64k|#define ssh_burn(ptr, len) explicit_bzero((ptr), (len))
  ------------------
  236|  8.64k|        SAFE_FREE(crypto->mlkem_privkey);
  ------------------
  |  |  373|  8.64k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 8.64k, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 8.64k]
  |  |  ------------------
  ------------------
  237|  8.64k|        crypto->mlkem_privkey_len = 0;
  238|  8.64k|    }
  239|  51.8k|#endif
  240|  51.8k|    ssh_string_burn(crypto->hybrid_shared_secret);
  241|  51.8k|    ssh_string_free(crypto->mlkem_client_pubkey);
  242|  51.8k|    ssh_string_free(crypto->mlkem_ciphertext);
  243|  51.8k|    ssh_string_free(crypto->hybrid_client_init);
  244|  51.8k|    ssh_string_free(crypto->hybrid_server_reply);
  245|  51.8k|    ssh_string_free(crypto->hybrid_shared_secret);
  246|       |
  247|  51.8k|    ssh_burn(crypto, sizeof(struct ssh_crypto_struct));
  ------------------
  |  |  388|  51.8k|#define ssh_burn(ptr, len) explicit_bzero((ptr), (len))
  ------------------
  248|       |
  249|       |    SAFE_FREE(crypto);
  ------------------
  |  |  373|  51.8k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 51.8k, False: 0]
  |  |  |  Branch (373:71): [Folded, False: 51.8k]
  |  |  ------------------
  ------------------
  250|  51.8k|}
crypt_set_algorithms_client:
  429|  8.64k|{
  430|  8.64k|    return crypt_set_algorithms2(session);
  431|  8.64k|}
crypt_set_algorithms_server:
  434|  8.64k|int crypt_set_algorithms_server(ssh_session session){
  435|  8.64k|    const char *method = NULL;
  436|  8.64k|    uint8_t i = 0;
  437|  8.64k|    struct ssh_cipher_struct *ssh_ciphertab=ssh_get_ciphertab();
  438|  8.64k|    struct ssh_hmac_struct   *ssh_hmactab=ssh_get_hmactab();
  439|  8.64k|    int cmp;
  440|  8.64k|    int rc;
  441|       |
  442|  8.64k|    if (session == NULL) {
  ------------------
  |  Branch (442:9): [True: 0, False: 8.64k]
  ------------------
  443|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  444|      0|    }
  445|       |
  446|       |    /*
  447|       |     * We must scan the kex entries to find crypto algorithms and set their
  448|       |     * appropriate structure
  449|       |     */
  450|       |    /* out */
  451|  8.64k|    method = session->next_crypto->kex_methods[SSH_CRYPT_S_C];
  452|       |
  453|  41.0k|    for (i = 0; ssh_ciphertab[i].name != NULL; i++) {
  ------------------
  |  Branch (453:17): [True: 41.0k, False: 0]
  ------------------
  454|  41.0k|        cmp = strcmp(method, ssh_ciphertab[i].name);
  455|  41.0k|        if (cmp == 0) {
  ------------------
  |  Branch (455:13): [True: 8.64k, False: 32.4k]
  ------------------
  456|  8.64k|          break;
  457|  8.64k|        }
  458|  41.0k|    }
  459|       |
  460|  8.64k|    if (ssh_ciphertab[i].name == NULL) {
  ------------------
  |  Branch (460:9): [True: 0, False: 8.64k]
  ------------------
  461|      0|        ssh_set_error(session,SSH_FATAL,"crypt_set_algorithms_server : "
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  462|      0|                "no crypto algorithm function found for %s",method);
  463|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  464|      0|    }
  465|  8.64k|    SSH_LOG(SSH_LOG_PACKET,"Set output algorithm %s",method);
  ------------------
  |  |  281|  8.64k|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  466|       |
  467|  8.64k|    session->next_crypto->out_cipher = cipher_new(i);
  468|  8.64k|    if (session->next_crypto->out_cipher == NULL) {
  ------------------
  |  Branch (468:9): [True: 0, False: 8.64k]
  ------------------
  469|      0|        ssh_set_error_oom(session);
  ------------------
  |  |  318|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
  470|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  471|      0|    }
  472|       |
  473|  8.64k|    if (session->next_crypto->out_cipher->aead_encrypt != NULL){
  ------------------
  |  Branch (473:9): [True: 0, False: 8.64k]
  ------------------
  474|       |        /* this cipher has integrated MAC */
  475|      0|        if (session->next_crypto->out_cipher->ciphertype == SSH_AEAD_CHACHA20_POLY1305) {
  ------------------
  |  Branch (475:13): [True: 0, False: 0]
  ------------------
  476|      0|            method = "aead-poly1305";
  477|      0|        } else {
  478|      0|            method = "aead-gcm";
  479|      0|        }
  480|  8.64k|    } else {
  481|       |        /* we must scan the kex entries to find hmac algorithms and set their appropriate structure */
  482|       |        /* out */
  483|  8.64k|        method = session->next_crypto->kex_methods[SSH_MAC_S_C];
  484|  8.64k|    }
  485|       |    /* HMAC algorithm selection */
  486|       |
  487|  40.3k|    for (i = 0; ssh_hmactab[i].name != NULL; i++) {
  ------------------
  |  Branch (487:17): [True: 40.3k, False: 0]
  ------------------
  488|  40.3k|        cmp = strcmp(method, ssh_hmactab[i].name);
  489|  40.3k|        if (cmp == 0) {
  ------------------
  |  Branch (489:13): [True: 8.64k, False: 31.6k]
  ------------------
  490|  8.64k|            break;
  491|  8.64k|        }
  492|  40.3k|    }
  493|       |
  494|  8.64k|    if (ssh_hmactab[i].name == NULL) {
  ------------------
  |  Branch (494:9): [True: 0, False: 8.64k]
  ------------------
  495|      0|      ssh_set_error(session, SSH_FATAL,
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  496|      0|          "crypt_set_algorithms_server: no hmac algorithm function found for %s",
  497|      0|          method);
  498|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  499|      0|    }
  500|  8.64k|    SSH_LOG(SSH_LOG_PACKET, "Set HMAC output algorithm to %s", method);
  ------------------
  |  |  281|  8.64k|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  501|       |
  502|  8.64k|    session->next_crypto->out_hmac = ssh_hmactab[i].hmac_type;
  503|  8.64k|    session->next_crypto->out_hmac_etm = ssh_hmactab[i].etm;
  504|       |
  505|       |    /* in */
  506|  8.64k|    method = session->next_crypto->kex_methods[SSH_CRYPT_C_S];
  507|       |
  508|  41.0k|    for (i = 0; ssh_ciphertab[i].name; i++) {
  ------------------
  |  Branch (508:17): [True: 41.0k, False: 0]
  ------------------
  509|  41.0k|        cmp = strcmp(method, ssh_ciphertab[i].name);
  510|  41.0k|        if (cmp == 0) {
  ------------------
  |  Branch (510:13): [True: 8.64k, False: 32.4k]
  ------------------
  511|  8.64k|            break;
  512|  8.64k|        }
  513|  41.0k|    }
  514|       |
  515|  8.64k|    if (ssh_ciphertab[i].name == NULL) {
  ------------------
  |  Branch (515:9): [True: 0, False: 8.64k]
  ------------------
  516|      0|        ssh_set_error(session,SSH_FATAL,"Crypt_set_algorithms_server :"
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  517|      0|                "no crypto algorithm function found for %s",method);
  518|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  519|      0|    }
  520|  8.64k|    SSH_LOG(SSH_LOG_PACKET,"Set input algorithm %s",method);
  ------------------
  |  |  281|  8.64k|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  521|       |
  522|  8.64k|    session->next_crypto->in_cipher = cipher_new(i);
  523|  8.64k|    if (session->next_crypto->in_cipher == NULL) {
  ------------------
  |  Branch (523:9): [True: 0, False: 8.64k]
  ------------------
  524|      0|        ssh_set_error_oom(session);
  ------------------
  |  |  318|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
  525|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  526|      0|    }
  527|       |
  528|  8.64k|    if (session->next_crypto->in_cipher->aead_encrypt != NULL){
  ------------------
  |  Branch (528:9): [True: 0, False: 8.64k]
  ------------------
  529|       |        /* this cipher has integrated MAC */
  530|      0|        if (session->next_crypto->in_cipher->ciphertype == SSH_AEAD_CHACHA20_POLY1305) {
  ------------------
  |  Branch (530:13): [True: 0, False: 0]
  ------------------
  531|      0|            method = "aead-poly1305";
  532|      0|        } else {
  533|      0|            method = "aead-gcm";
  534|      0|        }
  535|  8.64k|    } else {
  536|       |        /* we must scan the kex entries to find hmac algorithms and set their appropriate structure */
  537|  8.64k|        method = session->next_crypto->kex_methods[SSH_MAC_C_S];
  538|  8.64k|    }
  539|       |
  540|  40.3k|    for (i = 0; ssh_hmactab[i].name != NULL; i++) {
  ------------------
  |  Branch (540:17): [True: 40.3k, False: 0]
  ------------------
  541|  40.3k|        cmp = strcmp(method, ssh_hmactab[i].name);
  542|  40.3k|        if (cmp == 0) {
  ------------------
  |  Branch (542:13): [True: 8.64k, False: 31.6k]
  ------------------
  543|  8.64k|            break;
  544|  8.64k|        }
  545|  40.3k|    }
  546|       |
  547|  8.64k|    if (ssh_hmactab[i].name == NULL) {
  ------------------
  |  Branch (547:9): [True: 0, False: 8.64k]
  ------------------
  548|      0|      ssh_set_error(session, SSH_FATAL,
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  549|      0|          "crypt_set_algorithms_server: no hmac algorithm function found for %s",
  550|      0|          method);
  551|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  552|      0|    }
  553|  8.64k|    SSH_LOG(SSH_LOG_PACKET, "Set HMAC input algorithm to %s", method);
  ------------------
  |  |  281|  8.64k|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  554|       |
  555|  8.64k|    session->next_crypto->in_hmac = ssh_hmactab[i].hmac_type;
  556|  8.64k|    session->next_crypto->in_hmac_etm = ssh_hmactab[i].etm;
  557|       |
  558|       |    /* compression */
  559|  8.64k|    method = session->next_crypto->kex_methods[SSH_COMP_C_S];
  560|  8.64k|    cmp = strcmp(method, "zlib");
  561|  8.64k|    if (cmp == 0) {
  ------------------
  |  Branch (561:9): [True: 0, False: 8.64k]
  ------------------
  562|      0|        SSH_LOG(SSH_LOG_PACKET, "enabling C->S compression");
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  563|      0|        compression_enable(session, SSH_DIRECTION_IN, false);
  564|      0|    }
  565|  8.64k|    cmp = strcmp(method, "zlib@openssh.com");
  566|  8.64k|    if (cmp == 0) {
  ------------------
  |  Branch (566:9): [True: 0, False: 8.64k]
  ------------------
  567|      0|        SSH_LOG(SSH_LOG_PACKET, "enabling C->S delayed compression");
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  568|      0|        compression_enable(session, SSH_DIRECTION_IN, true);
  569|      0|    }
  570|       |
  571|  8.64k|    method = session->next_crypto->kex_methods[SSH_COMP_S_C];
  572|  8.64k|    cmp = strcmp(method, "zlib");
  573|  8.64k|    if (cmp == 0) {
  ------------------
  |  Branch (573:9): [True: 0, False: 8.64k]
  ------------------
  574|      0|        SSH_LOG(SSH_LOG_PACKET, "enabling S->C compression");
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  575|      0|        compression_enable(session, SSH_DIRECTION_OUT, false);
  576|      0|    }
  577|  8.64k|    cmp = strcmp(method, "zlib@openssh.com");
  578|  8.64k|    if (cmp == 0) {
  ------------------
  |  Branch (578:9): [True: 0, False: 8.64k]
  ------------------
  579|      0|        SSH_LOG(SSH_LOG_PACKET, "enabling S->C delayed compression");
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  580|      0|        compression_enable(session, SSH_DIRECTION_OUT, true);
  581|      0|    }
  582|       |
  583|  8.64k|    method = session->next_crypto->kex_methods[SSH_HOSTKEYS];
  584|       |
  585|       |    /* For GSSAPI key exchange, hostkey algorithm may be "null" */
  586|  8.64k|    if (strcmp(method, "null") == 0) {
  ------------------
  |  Branch (586:9): [True: 0, False: 8.64k]
  ------------------
  587|      0|        session->srv.hostkey = SSH_KEYTYPE_UNKNOWN;
  588|      0|        session->srv.hostkey_digest = SSH_DIGEST_AUTO;
  589|  8.64k|    } else {
  590|  8.64k|        rc = ssh_key_type_and_hash_from_signature_name(
  591|  8.64k|            method,
  592|  8.64k|            &session->srv.hostkey,
  593|  8.64k|            &session->srv.hostkey_digest);
  594|  8.64k|        if (rc != SSH_OK) {
  ------------------
  |  |  316|  8.64k|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (594:13): [True: 0, False: 8.64k]
  ------------------
  595|      0|            ssh_set_error(session,
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  596|      0|                          SSH_FATAL,
  597|      0|                          "unknown hostkey algorithm %s",
  598|      0|                          method);
  599|      0|            return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  600|      0|        }
  601|  8.64k|    }
  602|       |
  603|       |    /* setup DH key exchange type */
  604|  8.64k|    switch (session->next_crypto->kex_type) {
  605|      0|    case SSH_KEX_DH_GROUP1_SHA1:
  ------------------
  |  Branch (605:5): [True: 0, False: 8.64k]
  ------------------
  606|      0|    case SSH_KEX_DH_GROUP14_SHA1:
  ------------------
  |  Branch (606:5): [True: 0, False: 8.64k]
  ------------------
  607|      0|    case SSH_KEX_DH_GROUP14_SHA256:
  ------------------
  |  Branch (607:5): [True: 0, False: 8.64k]
  ------------------
  608|      0|    case SSH_KEX_DH_GROUP16_SHA512:
  ------------------
  |  Branch (608:5): [True: 0, False: 8.64k]
  ------------------
  609|      0|    case SSH_KEX_DH_GROUP18_SHA512:
  ------------------
  |  Branch (609:5): [True: 0, False: 8.64k]
  ------------------
  610|      0|      ssh_server_dh_init(session);
  611|      0|      break;
  612|       |#ifdef WITH_GSSAPI
  613|       |    case SSH_GSS_KEX_DH_GROUP14_SHA256:
  614|       |    case SSH_GSS_KEX_DH_GROUP16_SHA512:
  615|       |    case SSH_GSS_KEX_ECDH_NISTP256_SHA256:
  616|       |    case SSH_GSS_KEX_CURVE25519_SHA256:
  617|       |        ssh_server_gss_kex_init(session);
  618|       |        break;
  619|       |#endif /* WITH_GSSAPI */
  620|      0|#ifdef WITH_GEX
  621|      0|    case SSH_KEX_DH_GEX_SHA1:
  ------------------
  |  Branch (621:5): [True: 0, False: 8.64k]
  ------------------
  622|      0|    case SSH_KEX_DH_GEX_SHA256:
  ------------------
  |  Branch (622:5): [True: 0, False: 8.64k]
  ------------------
  623|      0|      ssh_server_dhgex_init(session);
  624|      0|      break;
  625|      0|#endif /* WITH_GEX */
  626|      0|#ifdef HAVE_ECDH
  627|      0|    case SSH_KEX_ECDH_SHA2_NISTP256:
  ------------------
  |  Branch (627:5): [True: 0, False: 8.64k]
  ------------------
  628|      0|    case SSH_KEX_ECDH_SHA2_NISTP384:
  ------------------
  |  Branch (628:5): [True: 0, False: 8.64k]
  ------------------
  629|      0|    case SSH_KEX_ECDH_SHA2_NISTP521:
  ------------------
  |  Branch (629:5): [True: 0, False: 8.64k]
  ------------------
  630|      0|      ssh_server_ecdh_init(session);
  631|      0|      break;
  632|      0|#endif
  633|      0|#ifdef HAVE_CURVE25519
  634|      0|    case SSH_KEX_CURVE25519_SHA256:
  ------------------
  |  Branch (634:5): [True: 0, False: 8.64k]
  ------------------
  635|      0|    case SSH_KEX_CURVE25519_SHA256_LIBSSH_ORG:
  ------------------
  |  Branch (635:5): [True: 0, False: 8.64k]
  ------------------
  636|      0|        ssh_server_curve25519_init(session);
  637|      0|        break;
  638|      0|#endif
  639|      0|#ifdef HAVE_SNTRUP761
  640|      0|    case SSH_KEX_SNTRUP761X25519_SHA512:
  ------------------
  |  Branch (640:5): [True: 0, False: 8.64k]
  ------------------
  641|      0|    case SSH_KEX_SNTRUP761X25519_SHA512_OPENSSH_COM:
  ------------------
  |  Branch (641:5): [True: 0, False: 8.64k]
  ------------------
  642|      0|        ssh_server_sntrup761x25519_init(session);
  643|      0|        break;
  644|      0|#endif
  645|  8.64k|    case SSH_KEX_MLKEM768X25519_SHA256:
  ------------------
  |  Branch (645:5): [True: 8.64k, False: 0]
  ------------------
  646|  8.64k|    case SSH_KEX_MLKEM768NISTP256_SHA256:
  ------------------
  |  Branch (646:5): [True: 0, False: 8.64k]
  ------------------
  647|       |#ifdef HAVE_MLKEM1024
  648|       |    case SSH_KEX_MLKEM1024NISTP384_SHA384:
  649|       |#endif
  650|  8.64k|        ssh_server_hybrid_mlkem_init(session);
  651|  8.64k|        break;
  652|      0|    default:
  ------------------
  |  Branch (652:5): [True: 0, False: 8.64k]
  ------------------
  653|      0|        ssh_set_error(session,
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  654|      0|                      SSH_FATAL,
  655|      0|                      "crypt_set_algorithms_server: could not find init "
  656|      0|                      "handler for kex type %d",
  657|      0|                      session->next_crypto->kex_type);
  658|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  659|  8.64k|    }
  660|  8.64k|    return SSH_OK;
  ------------------
  |  |  316|  8.64k|#define SSH_OK 0     /* No error */
  ------------------
  661|  8.64k|}
wrapper.c:cipher_free:
  147|   103k|static void cipher_free(struct ssh_cipher_struct *cipher) {
  148|   103k|  ssh_cipher_clear(cipher);
  149|       |  SAFE_FREE(cipher);
  ------------------
  |  |  373|   103k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (373:31): [True: 34.5k, False: 69.1k]
  |  |  |  Branch (373:71): [Folded, False: 103k]
  |  |  ------------------
  ------------------
  150|   103k|}
wrapper.c:crypt_set_algorithms2:
  275|  8.64k|{
  276|  8.64k|    const char *wanted = NULL;
  277|  8.64k|    const char *method = NULL;
  278|  8.64k|    struct ssh_cipher_struct *ssh_ciphertab=ssh_get_ciphertab();
  279|  8.64k|    struct ssh_hmac_struct *ssh_hmactab=ssh_get_hmactab();
  280|  8.64k|    uint8_t i = 0;
  281|  8.64k|    int cmp;
  282|       |
  283|       |    /*
  284|       |     * We must scan the kex entries to find crypto algorithms and set their
  285|       |     * appropriate structure.
  286|       |     */
  287|       |
  288|       |    /* out */
  289|  8.64k|    wanted = session->next_crypto->kex_methods[SSH_CRYPT_C_S];
  290|  41.0k|    for (i = 0; i < 64 && ssh_ciphertab[i].name != NULL; ++i) {
  ------------------
  |  Branch (290:17): [True: 41.0k, False: 0]
  |  Branch (290:27): [True: 41.0k, False: 0]
  ------------------
  291|  41.0k|        cmp = strcmp(wanted, ssh_ciphertab[i].name);
  292|  41.0k|        if (cmp == 0) {
  ------------------
  |  Branch (292:13): [True: 8.64k, False: 32.4k]
  ------------------
  293|  8.64k|            break;
  294|  8.64k|        }
  295|  41.0k|    }
  296|       |
  297|  8.64k|    if (ssh_ciphertab[i].name == NULL) {
  ------------------
  |  Branch (297:9): [True: 0, False: 8.64k]
  ------------------
  298|      0|        ssh_set_error(session, SSH_FATAL,
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  299|      0|                "crypt_set_algorithms2: no crypto algorithm function found for %s",
  300|      0|                wanted);
  301|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  302|      0|    }
  303|  8.64k|    SSH_LOG(SSH_LOG_PACKET, "Set output algorithm to %s", wanted);
  ------------------
  |  |  281|  8.64k|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  304|       |
  305|  8.64k|    session->next_crypto->out_cipher = cipher_new(i);
  306|  8.64k|    if (session->next_crypto->out_cipher == NULL) {
  ------------------
  |  Branch (306:9): [True: 0, False: 8.64k]
  ------------------
  307|      0|        ssh_set_error_oom(session);
  ------------------
  |  |  318|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
  308|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  309|      0|    }
  310|       |
  311|  8.64k|    if (session->next_crypto->out_cipher->aead_encrypt != NULL) {
  ------------------
  |  Branch (311:9): [True: 0, False: 8.64k]
  ------------------
  312|       |        /* this cipher has integrated MAC */
  313|      0|        if (session->next_crypto->out_cipher->ciphertype == SSH_AEAD_CHACHA20_POLY1305) {
  ------------------
  |  Branch (313:13): [True: 0, False: 0]
  ------------------
  314|      0|            wanted = "aead-poly1305";
  315|      0|        } else {
  316|      0|            wanted = "aead-gcm";
  317|      0|        }
  318|  8.64k|    } else {
  319|       |        /*
  320|       |         * We must scan the kex entries to find hmac algorithms and set their
  321|       |         * appropriate structure.
  322|       |         */
  323|       |
  324|       |        /* out */
  325|  8.64k|        wanted = session->next_crypto->kex_methods[SSH_MAC_C_S];
  326|  8.64k|    }
  327|       |
  328|  40.3k|    for (i = 0; ssh_hmactab[i].name != NULL; i++) {
  ------------------
  |  Branch (328:17): [True: 40.3k, False: 0]
  ------------------
  329|  40.3k|        cmp = strcmp(wanted, ssh_hmactab[i].name);
  330|  40.3k|        if (cmp == 0) {
  ------------------
  |  Branch (330:13): [True: 8.64k, False: 31.6k]
  ------------------
  331|  8.64k|            break;
  332|  8.64k|        }
  333|  40.3k|    }
  334|       |
  335|  8.64k|    if (ssh_hmactab[i].name == NULL) {
  ------------------
  |  Branch (335:9): [True: 0, False: 8.64k]
  ------------------
  336|      0|        ssh_set_error(session, SSH_FATAL,
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  337|      0|                "crypt_set_algorithms2: no hmac algorithm function found for %s",
  338|      0|                wanted);
  339|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  340|      0|    }
  341|  8.64k|    SSH_LOG(SSH_LOG_PACKET, "Set HMAC output algorithm to %s", wanted);
  ------------------
  |  |  281|  8.64k|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  342|       |
  343|  8.64k|    session->next_crypto->out_hmac = ssh_hmactab[i].hmac_type;
  344|  8.64k|    session->next_crypto->out_hmac_etm = ssh_hmactab[i].etm;
  345|       |
  346|       |    /* in */
  347|  8.64k|    wanted = session->next_crypto->kex_methods[SSH_CRYPT_S_C];
  348|       |
  349|  41.0k|    for (i = 0; ssh_ciphertab[i].name != NULL; i++) {
  ------------------
  |  Branch (349:17): [True: 41.0k, False: 0]
  ------------------
  350|  41.0k|        cmp = strcmp(wanted, ssh_ciphertab[i].name);
  351|  41.0k|        if (cmp == 0) {
  ------------------
  |  Branch (351:13): [True: 8.64k, False: 32.4k]
  ------------------
  352|  8.64k|            break;
  353|  8.64k|        }
  354|  41.0k|    }
  355|       |
  356|  8.64k|    if (ssh_ciphertab[i].name == NULL) {
  ------------------
  |  Branch (356:9): [True: 0, False: 8.64k]
  ------------------
  357|      0|        ssh_set_error(session, SSH_FATAL,
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  358|      0|                "Crypt_set_algorithms: no crypto algorithm function found for %s",
  359|      0|                wanted);
  360|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  361|      0|    }
  362|  8.64k|    SSH_LOG(SSH_LOG_PACKET, "Set input algorithm to %s", wanted);
  ------------------
  |  |  281|  8.64k|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  363|       |
  364|  8.64k|    session->next_crypto->in_cipher = cipher_new(i);
  365|  8.64k|    if (session->next_crypto->in_cipher == NULL) {
  ------------------
  |  Branch (365:9): [True: 0, False: 8.64k]
  ------------------
  366|      0|        ssh_set_error_oom(session);
  ------------------
  |  |  318|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
  367|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  368|      0|    }
  369|       |
  370|  8.64k|    if (session->next_crypto->in_cipher->aead_encrypt != NULL){
  ------------------
  |  Branch (370:9): [True: 0, False: 8.64k]
  ------------------
  371|       |        /* this cipher has integrated MAC */
  372|      0|        if (session->next_crypto->in_cipher->ciphertype == SSH_AEAD_CHACHA20_POLY1305) {
  ------------------
  |  Branch (372:13): [True: 0, False: 0]
  ------------------
  373|      0|            wanted = "aead-poly1305";
  374|      0|        } else {
  375|      0|            wanted = "aead-gcm";
  376|      0|        }
  377|  8.64k|    } else {
  378|       |        /* we must scan the kex entries to find hmac algorithms and set their appropriate structure */
  379|  8.64k|        wanted = session->next_crypto->kex_methods[SSH_MAC_S_C];
  380|  8.64k|    }
  381|       |
  382|  40.3k|    for (i = 0; ssh_hmactab[i].name != NULL; i++) {
  ------------------
  |  Branch (382:17): [True: 40.3k, False: 0]
  ------------------
  383|  40.3k|        cmp = strcmp(wanted, ssh_hmactab[i].name);
  384|  40.3k|        if (cmp == 0) {
  ------------------
  |  Branch (384:13): [True: 8.64k, False: 31.6k]
  ------------------
  385|  8.64k|            break;
  386|  8.64k|        }
  387|  40.3k|    }
  388|       |
  389|  8.64k|    if (ssh_hmactab[i].name == NULL) {
  ------------------
  |  Branch (389:9): [True: 0, False: 8.64k]
  ------------------
  390|      0|        ssh_set_error(session, SSH_FATAL,
  ------------------
  |  |  311|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  391|      0|                "crypt_set_algorithms2: no hmac algorithm function found for %s",
  392|      0|                wanted);
  393|      0|        return SSH_ERROR;
  ------------------
  |  |  317|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  394|      0|    }
  395|  8.64k|    SSH_LOG(SSH_LOG_PACKET, "Set HMAC input algorithm to %s", wanted);
  ------------------
  |  |  281|  8.64k|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  396|       |
  397|  8.64k|    session->next_crypto->in_hmac = ssh_hmactab[i].hmac_type;
  398|  8.64k|    session->next_crypto->in_hmac_etm = ssh_hmactab[i].etm;
  399|       |
  400|       |    /* compression: client */
  401|  8.64k|    method = session->next_crypto->kex_methods[SSH_COMP_C_S];
  402|  8.64k|    cmp = strcmp(method, "zlib");
  403|  8.64k|    if (cmp == 0) {
  ------------------
  |  Branch (403:9): [True: 0, False: 8.64k]
  ------------------
  404|      0|        SSH_LOG(SSH_LOG_PACKET, "enabling C->S compression");
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  405|      0|        compression_enable(session, SSH_DIRECTION_OUT, false);
  406|      0|    }
  407|  8.64k|    cmp = strcmp(method, "zlib@openssh.com");
  408|  8.64k|    if (cmp == 0) {
  ------------------
  |  Branch (408:9): [True: 0, False: 8.64k]
  ------------------
  409|      0|        SSH_LOG(SSH_LOG_PACKET, "enabling C->S delayed compression");
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  410|      0|        compression_enable(session, SSH_DIRECTION_OUT, true);
  411|      0|    }
  412|       |
  413|  8.64k|    method = session->next_crypto->kex_methods[SSH_COMP_S_C];
  414|  8.64k|    cmp = strcmp(method, "zlib");
  415|  8.64k|    if (cmp == 0) {
  ------------------
  |  Branch (415:9): [True: 0, False: 8.64k]
  ------------------
  416|      0|        SSH_LOG(SSH_LOG_PACKET, "enabling S->C compression");
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  417|      0|        compression_enable(session, SSH_DIRECTION_IN, false);
  418|      0|    }
  419|  8.64k|    cmp = strcmp(method, "zlib@openssh.com");
  420|  8.64k|    if (cmp == 0) {
  ------------------
  |  Branch (420:9): [True: 0, False: 8.64k]
  ------------------
  421|      0|        SSH_LOG(SSH_LOG_PACKET, "enabling S->C delayed compression");
  ------------------
  |  |  281|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  422|      0|        compression_enable(session, SSH_DIRECTION_IN, true);
  423|      0|    }
  424|       |
  425|  8.64k|    return SSH_OK;
  ------------------
  |  |  316|  8.64k|#define SSH_OK 0     /* No error */
  ------------------
  426|  8.64k|}
wrapper.c:cipher_new:
  110|  34.5k|static struct ssh_cipher_struct *cipher_new(uint8_t offset) {
  111|  34.5k|  struct ssh_cipher_struct *cipher = NULL;
  112|       |
  113|  34.5k|  cipher = malloc(sizeof(struct ssh_cipher_struct));
  114|  34.5k|  if (cipher == NULL) {
  ------------------
  |  Branch (114:7): [True: 0, False: 34.5k]
  ------------------
  115|      0|    return NULL;
  116|      0|  }
  117|       |
  118|       |  /* note the memcpy will copy the pointers : so, you shouldn't free them */
  119|  34.5k|  memcpy(cipher, &ssh_get_ciphertab()[offset], sizeof(*cipher));
  120|       |
  121|  34.5k|  return cipher;
  122|  34.5k|}

nalloc_init:
  114|      2|{
  115|      2|    if (nalloc_initialized) {
  ------------------
  |  Branch (115:9): [True: 0, False: 2]
  ------------------
  116|      0|        return;
  117|      0|    }
  118|      2|    nalloc_initialized = true;
  119|      2|    char *bitmask = getenv("NALLOC_FREQ");
  120|      2|    if (bitmask) {
  ------------------
  |  Branch (120:9): [True: 0, False: 2]
  ------------------
  121|      0|        int shift = atoi(bitmask);
  122|      0|        if (shift > 0 && shift < 31) {
  ------------------
  |  Branch (122:13): [True: 0, False: 0]
  |  Branch (122:26): [True: 0, False: 0]
  ------------------
  123|      0|            nalloc_bitmask = 1 << shift;
  124|      0|            nalloc_random_bitmask = false;
  125|      0|        } else if (shift == 0) {
  ------------------
  |  Branch (125:20): [True: 0, False: 0]
  ------------------
  126|      0|            nalloc_random_bitmask = false;
  127|      0|            nalloc_bitmask = 0;
  128|      0|        }
  129|      2|    } else if (prog == NULL || strstr(prog, "nalloc") == NULL) {
  ------------------
  |  Branch (129:16): [True: 0, False: 2]
  |  Branch (129:32): [True: 2, False: 0]
  ------------------
  130|      2|        nalloc_random_bitmask = false;
  131|      2|        nalloc_bitmask = 0;
  132|      2|        return;
  133|      2|    }
  134|       |
  135|      0|    char *verbose = getenv("NALLOC_VERBOSE");
  136|      0|    if (verbose) {
  ------------------
  |  Branch (136:9): [True: 0, False: 0]
  ------------------
  137|       |        nalloc_verbose = true;
  138|      0|    }
  139|      0|}
recv:
  289|   473k|{
  290|   473k|    if (nalloc_fail(count, "recv")) {
  ------------------
  |  Branch (290:9): [True: 0, False: 473k]
  ------------------
  291|      0|        errno = EIO;
  292|      0|        return -1;
  293|      0|    }
  294|   473k|    return nalloc_recv(fd, buf, count, flags);
  ------------------
  |  |  265|   473k|#define nalloc_recv(f, b, s, x) __recv(f, b, s, x)
  ------------------
  295|   473k|}
send:
  298|   177k|{
  299|   177k|    if (nalloc_fail(count, "send")) {
  ------------------
  |  Branch (299:9): [True: 0, False: 177k]
  ------------------
  300|      0|        errno = EIO;
  301|      0|        return -1;
  302|      0|    }
  303|   177k|    return nalloc_send(fd, buf, count, flags);
  ------------------
  |  |  266|   177k|#define nalloc_send(f, b, s, x) __send(f, b, s, x)
  ------------------
  304|   177k|}
calloc:
  307|  2.72M|{
  308|  2.72M|    if (nalloc_fail(size, "calloc")) {
  ------------------
  |  Branch (308:9): [True: 0, False: 2.72M]
  ------------------
  309|      0|        errno = ENOMEM;
  310|      0|        return NULL;
  311|      0|    }
  312|  2.72M|    return nalloc_calloc(nmemb, size);
  ------------------
  |  |  259|  2.72M|#define nalloc_calloc(s, n)          __libc_calloc(s, n)
  ------------------
  313|  2.72M|}
malloc:
  316|  10.0M|{
  317|  10.0M|    if (nalloc_fail(size, "malloc")) {
  ------------------
  |  Branch (317:9): [True: 0, False: 10.0M]
  ------------------
  318|      0|        errno = ENOMEM;
  319|      0|        return NULL;
  320|      0|    }
  321|  10.0M|    return nalloc_malloc(size);
  ------------------
  |  |  258|  10.0M|#define nalloc_malloc(s)             __libc_malloc(s)
  ------------------
  322|  10.0M|}
realloc:
  325|   850k|{
  326|   850k|    if (nalloc_fail(size, "realloc")) {
  ------------------
  |  Branch (326:9): [True: 0, False: 850k]
  ------------------
  327|      0|        errno = ENOMEM;
  328|      0|        return NULL;
  329|      0|    }
  330|   850k|    return nalloc_realloc(ptr, size);
  ------------------
  |  |  260|   850k|#define nalloc_realloc(p, s)         __libc_realloc(p, s)
  ------------------
  331|   850k|}
ssh_scp_fuzzer.c:nalloc_fail:
  194|  14.2M|{
  195|       |    // do not fail before thread init
  196|  14.2M|    if (nalloc_runs == 0) {
  ------------------
  |  Branch (196:9): [True: 14.2M, False: 18.4E]
  ------------------
  197|  14.2M|        return false;
  198|  14.2M|    }
  199|  18.4E|    if (__sync_fetch_and_add(&nalloc_running, 1) != 1) {
  ------------------
  |  Branch (199:9): [True: 0, False: 18.4E]
  ------------------
  200|       |        // do not fail allocations outside of fuzzer input
  201|       |        // and do not fail inside of this function
  202|      0|        __sync_fetch_and_sub(&nalloc_running, 1);
  203|      0|        return false;
  204|      0|    }
  205|  18.4E|    nalloc_random_update((uint8_t)size);
  206|  18.4E|    if (size >= 0x100) {
  ------------------
  |  Branch (206:9): [True: 0, False: 18.4E]
  ------------------
  207|      0|        nalloc_random_update((uint8_t)(size >> 8));
  208|      0|        if (size >= 0x10000) {
  ------------------
  |  Branch (208:13): [True: 0, False: 0]
  ------------------
  209|      0|            nalloc_random_update((uint8_t)(size >> 16));
  210|       |            // bigger may already fail or oom
  211|      0|        }
  212|      0|    }
  213|  18.4E|    if (((nalloc_random_state ^ nalloc_magic) & nalloc_bitmask) == 0) {
  ------------------
  |  Branch (213:9): [True: 0, False: 18.4E]
  ------------------
  214|      0|        if (nalloc_backtrace_exclude(size, op)) {
  ------------------
  |  Branch (214:13): [True: 0, False: 0]
  ------------------
  215|      0|            __sync_fetch_and_sub(&nalloc_running, 1);
  216|      0|            return false;
  217|      0|        }
  218|      0|        __sync_fetch_and_sub(&nalloc_running, 1);
  219|      0|        return true;
  220|      0|    }
  221|  18.4E|    __sync_fetch_and_sub(&nalloc_running, 1);
  222|       |    return false;
  223|  18.4E|}
ssh_scp_fuzzer.c:nalloc_start:
  151|    720|{
  152|    720|    if (nalloc_random_bitmask) {
  ------------------
  |  Branch (152:9): [True: 0, False: 720]
  ------------------
  153|      0|        if (nalloc_random_state & 0x10) {
  ------------------
  |  Branch (153:13): [True: 0, False: 0]
  ------------------
  154|      0|            nalloc_bitmask = 0xFFFFFFFF;
  155|      0|        } else {
  156|      0|            nalloc_bitmask = 1 << (5 + (nalloc_random_state & 0xF));
  157|      0|        }
  158|    720|    } else if (nalloc_bitmask == 0) {
  ------------------
  |  Branch (158:16): [True: 720, False: 0]
  ------------------
  159|       |        // nalloc disabled
  160|    720|        return 2;
  161|    720|    }
  162|      0|    nalloc_random_state = 0;
  163|      0|    for (size_t i = 0; i < size; i++) {
  ------------------
  |  Branch (163:24): [True: 0, False: 0]
  ------------------
  164|      0|        nalloc_random_update(data[i]);
  165|      0|    }
  166|      0|    if (__sync_fetch_and_add(&nalloc_running, 1)) {
  ------------------
  |  Branch (166:9): [True: 0, False: 0]
  ------------------
  167|      0|        __sync_fetch_and_sub(&nalloc_running, 1);
  168|      0|        return 0;
  169|      0|    }
  170|      0|    nalloc_runs++;
  171|      0|    return 1;
  172|      0|}
ssh_scp_fuzzer.c:nalloc_end:
  176|    720|{
  177|    720|    __sync_fetch_and_sub(&nalloc_running, 1);
  178|    720|}

LLVMFuzzerInitialize:
   39|      2|{
   40|      2|    (void)argc;
   41|      2|    nalloc_init(*argv[0]);
   42|      2|    ssh_init();
   43|      2|    atexit(_fuzz_finalize);
   44|      2|    ssh_mock_write_hostkey(SSH_MOCK_HOSTKEY_PATH);
  ------------------
  |  |   58|      2|#define SSH_MOCK_HOSTKEY_PATH "/tmp/libssh_mock_fuzz_key"
  ------------------
   45|      2|    return 0;
   46|      2|}
LLVMFuzzerTestOneInput:
  180|    720|{
  181|    720|    assert(nalloc_start(data, size) > 0);
  ------------------
  |  Branch (181:5): [True: 0, False: 720]
  |  Branch (181:5): [True: 720, False: 0]
  ------------------
  182|       |
  183|       |    /* Test all cipher/HMAC combinations exhaustively */
  184|    720|    const char *ciphers[] = {
  185|    720|        "none",
  186|    720|        "aes128-ctr",
  187|    720|        "aes256-ctr",
  188|    720|        "aes128-cbc",
  189|    720|    };
  190|       |
  191|    720|    const char *hmacs[] = {
  192|    720|        "none",
  193|    720|        "hmac-sha1",
  194|    720|        "hmac-sha2-256",
  195|    720|    };
  196|       |
  197|    720|    int num_ciphers = sizeof(ciphers) / sizeof(ciphers[0]);
  198|    720|    int num_hmacs = sizeof(hmacs) / sizeof(hmacs[0]);
  199|       |
  200|  3.60k|    for (int i = 0; i < num_ciphers; i++) {
  ------------------
  |  Branch (200:21): [True: 2.88k, False: 720]
  ------------------
  201|  11.5k|        for (int j = 0; j < num_hmacs; j++) {
  ------------------
  |  Branch (201:25): [True: 8.64k, False: 2.88k]
  ------------------
  202|  8.64k|            test_scp_with_cipher(data, size, ciphers[i], hmacs[j]);
  203|  8.64k|        }
  204|  2.88k|    }
  205|       |
  206|    720|    nalloc_end();
  207|    720|    return 0;
  208|    720|}
ssh_scp_fuzzer.c:_fuzz_finalize:
   34|      2|{
   35|      2|    ssh_finalize();
   36|      2|}
ssh_scp_fuzzer.c:test_scp_with_cipher:
   53|  8.64k|{
   54|  8.64k|    int socket_fds[2] = {-1, -1};
   55|  8.64k|    ssh_session client_session = NULL;
   56|  8.64k|    ssh_scp scp = NULL, scp_recursive = NULL;
   57|  8.64k|    char buf[256] = {0};
   58|  8.64k|    pthread_t srv_thread;
   59|       |
   60|       |    /* Configure mock SSH server with fuzzer data */
   61|  8.64k|    struct ssh_mock_server_config server_config = {
   62|  8.64k|        .protocol_data = data,
   63|  8.64k|        .protocol_data_size = size,
   64|  8.64k|        .exec_callback = ssh_mock_send_raw_data,
   65|  8.64k|        .subsystem_callback = NULL,
   66|  8.64k|        .callback_userdata = NULL,
   67|  8.64k|        .cipher = cipher,
   68|  8.64k|        .hmac = hmac,
   69|  8.64k|        .server_socket = -1,
   70|  8.64k|        .client_socket = -1,
   71|  8.64k|        .server_ready = false,
   72|  8.64k|        .server_error = false,
   73|  8.64k|    };
   74|       |
   75|  8.64k|    if (socketpair(AF_UNIX, SOCK_STREAM, 0, socket_fds) != 0) {
  ------------------
  |  Branch (75:9): [True: 0, False: 8.64k]
  ------------------
   76|      0|        goto cleanup;
   77|      0|    }
   78|       |
   79|  8.64k|    server_config.server_socket = socket_fds[0];
   80|  8.64k|    server_config.client_socket = socket_fds[1];
   81|       |
   82|  8.64k|    if (ssh_mock_server_start(&server_config, &srv_thread) != 0) {
  ------------------
  |  Branch (82:9): [True: 0, False: 8.64k]
  ------------------
   83|      0|        goto cleanup;
   84|      0|    }
   85|       |
   86|  8.64k|    client_session = ssh_new();
   87|  8.64k|    if (client_session == NULL) {
  ------------------
  |  Branch (87:9): [True: 0, False: 8.64k]
  ------------------
   88|      0|        goto cleanup_thread;
   89|      0|    }
   90|       |
   91|       |    /* Configure client with specified cipher/HMAC */
   92|  8.64k|    ssh_options_set(client_session, SSH_OPTIONS_FD, &socket_fds[1]);
   93|  8.64k|    ssh_options_set(client_session, SSH_OPTIONS_HOST, "localhost");
   94|  8.64k|    ssh_options_set(client_session, SSH_OPTIONS_USER, "fuzz");
   95|  8.64k|    ssh_options_set(client_session, SSH_OPTIONS_CIPHERS_C_S, cipher);
   96|  8.64k|    ssh_options_set(client_session, SSH_OPTIONS_CIPHERS_S_C, cipher);
   97|  8.64k|    ssh_options_set(client_session, SSH_OPTIONS_HMAC_C_S, hmac);
   98|  8.64k|    ssh_options_set(client_session, SSH_OPTIONS_HMAC_S_C, hmac);
   99|       |
  100|       |    /* Set timeout for operations (1 second) */
  101|  8.64k|    long timeout = 1;
  102|  8.64k|    ssh_options_set(client_session, SSH_OPTIONS_TIMEOUT, &timeout);
  103|       |
  104|  8.64k|    if (ssh_connect(client_session) != SSH_OK) {
  ------------------
  |  |  316|  8.64k|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (104:9): [True: 0, False: 8.64k]
  ------------------
  105|      0|        goto cleanup_thread;
  106|      0|    }
  107|       |
  108|  8.64k|    if (ssh_userauth_none(client_session, NULL) != SSH_AUTH_SUCCESS) {
  ------------------
  |  Branch (108:9): [True: 0, False: 8.64k]
  ------------------
  109|      0|        goto cleanup_thread;
  110|      0|    }
  111|       |
  112|  8.64k|    scp = ssh_scp_new(client_session, SSH_SCP_READ, "/tmp/fuzz");
  113|  8.64k|    if (scp == NULL) {
  ------------------
  |  Branch (113:9): [True: 0, False: 8.64k]
  ------------------
  114|      0|        goto cleanup_thread;
  115|      0|    }
  116|       |
  117|  8.64k|    if (ssh_scp_init(scp) != SSH_OK) {
  ------------------
  |  |  316|  8.64k|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (117:9): [True: 8.63k, False: 2]
  ------------------
  118|  8.63k|        goto cleanup_thread;
  119|  8.63k|    }
  120|       |
  121|      2|    if (size > 0) {
  ------------------
  |  Branch (121:9): [True: 2, False: 0]
  ------------------
  122|      2|        size_t copy_size = size < sizeof(buf) ? size : sizeof(buf);
  ------------------
  |  Branch (122:28): [True: 0, False: 2]
  ------------------
  123|      2|        memcpy(buf, data, copy_size);
  124|      2|    }
  125|       |
  126|       |    /* Fuzz all SCP API functions in read mode */
  127|      2|    ssh_scp_pull_request(scp);
  128|      2|    ssh_scp_request_get_filename(scp);
  129|      2|    ssh_scp_request_get_permissions(scp);
  130|      2|    ssh_scp_request_get_size64(scp);
  131|      2|    ssh_scp_request_get_size(scp);
  132|      2|    ssh_scp_request_get_warning(scp);
  133|      2|    ssh_scp_accept_request(scp);
  134|      2|    ssh_scp_deny_request(scp, "Denied by fuzzer");
  135|      2|    ssh_scp_read(scp, buf, sizeof(buf));
  136|       |
  137|       |    /* Final fuzz of scp pull request after all the calls */
  138|      2|    ssh_scp_pull_request(scp);
  139|       |
  140|       |    /* Fuzz SCP in write/upload + recursive directory mode. */
  141|      2|    scp_recursive = ssh_scp_new(client_session,
  142|      2|                                SSH_SCP_WRITE | SSH_SCP_RECURSIVE,
  143|      2|                                "/tmp/fuzz-recursive");
  144|      2|    if (scp_recursive != NULL) {
  ------------------
  |  Branch (144:9): [True: 2, False: 0]
  ------------------
  145|      2|        if (ssh_scp_init(scp_recursive) == SSH_OK) {
  ------------------
  |  |  316|      2|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (145:13): [True: 0, False: 2]
  ------------------
  146|      0|            ssh_scp_push_directory(scp_recursive, "fuzz-dir", 0755);
  147|      0|            ssh_scp_push_file(scp_recursive, "fuzz-file", sizeof(buf), 0644);
  148|      0|            ssh_scp_write(scp_recursive, buf, sizeof(buf));
  149|      0|            ssh_scp_leave_directory(scp_recursive);
  150|      0|        }
  151|      2|    }
  152|       |
  153|  8.64k|cleanup_thread:
  154|  8.64k|    shutdown(socket_fds[0], SHUT_RDWR);
  155|  8.64k|    shutdown(socket_fds[1], SHUT_RDWR);
  156|  8.64k|    pthread_join(srv_thread, NULL);
  157|       |
  158|  8.64k|cleanup:
  159|  8.64k|    if (scp_recursive != NULL) {
  ------------------
  |  Branch (159:9): [True: 2, False: 8.63k]
  ------------------
  160|      2|        ssh_scp_close(scp_recursive);
  161|      2|        ssh_scp_free(scp_recursive);
  162|      2|    }
  163|  8.64k|    if (scp) {
  ------------------
  |  Branch (163:9): [True: 8.64k, False: 0]
  ------------------
  164|  8.64k|        ssh_scp_close(scp);
  165|  8.64k|        ssh_scp_free(scp);
  166|  8.64k|    }
  167|  8.64k|    if (client_session) {
  ------------------
  |  Branch (167:9): [True: 8.64k, False: 0]
  ------------------
  168|  8.64k|        ssh_disconnect(client_session);
  169|  8.64k|        ssh_free(client_session);
  170|  8.64k|    }
  171|  8.64k|    if (socket_fds[0] >= 0)
  ------------------
  |  Branch (171:9): [True: 8.64k, False: 0]
  ------------------
  172|  8.64k|        close(socket_fds[0]);
  173|  8.64k|    if (socket_fds[1] >= 0)
  ------------------
  |  Branch (173:9): [True: 8.64k, False: 0]
  ------------------
  174|  8.64k|        close(socket_fds[1]);
  175|       |
  176|  8.64k|    return 0;
  177|  8.64k|}

ssh_mock_server_start:
  210|  8.64k|{
  211|  8.64k|    if (!config || !thread)
  ------------------
  |  Branch (211:9): [True: 0, False: 8.64k]
  |  Branch (211:20): [True: 0, False: 8.64k]
  ------------------
  212|      0|        return -1;
  213|       |
  214|  8.64k|    config->server_ready = false;
  215|  8.64k|    config->server_error = false;
  216|       |
  217|  8.64k|    if (pthread_create(thread, NULL, server_thread_func, config) != 0) {
  ------------------
  |  Branch (217:9): [True: 0, False: 8.64k]
  ------------------
  218|      0|        return -1;
  219|      0|    }
  220|       |
  221|  18.8k|    for (int i = 0; i < 50 && !config->server_ready && !config->server_error;
  ------------------
  |  Branch (221:21): [True: 18.8k, False: 0]
  |  Branch (221:31): [True: 10.2k, False: 8.64k]
  |  Branch (221:56): [True: 10.2k, False: 0]
  ------------------
  222|  10.2k|         i++) {
  223|  10.2k|        usleep(100);
  224|  10.2k|    }
  225|       |
  226|  8.64k|    return config->server_error ? -1 : 0;
  ------------------
  |  Branch (226:12): [True: 0, False: 8.64k]
  ------------------
  227|  8.64k|}
ssh_mock_send_raw_data:
  234|  8.64k|{
  235|  8.64k|    (void)userdata;
  236|       |
  237|  8.64k|    ssh_channel target_channel = (ssh_channel)channel;
  238|       |
  239|       |    /* Send raw fuzzer data - let protocol parser interpret it */
  240|  8.64k|    if (size > 0) {
  ------------------
  |  Branch (240:9): [True: 8.64k, False: 0]
  ------------------
  241|  8.64k|        ssh_channel_write(target_channel, data, size);
  242|  8.64k|    }
  243|       |
  244|       |    /* Close channel to signal completion */
  245|  8.64k|    ssh_channel_send_eof(target_channel);
  246|  8.64k|    ssh_channel_close(target_channel);
  247|  8.64k|    return SSH_OK;
  ------------------
  |  |  316|  8.64k|#define SSH_OK 0     /* No error */
  ------------------
  248|  8.64k|}
ssh_mock_write_hostkey:
  252|      2|{
  253|      2|    FILE *fp = fopen(path, "wb");
  254|      2|    if (fp == NULL)
  ------------------
  |  Branch (254:9): [True: 0, False: 2]
  ------------------
  255|      0|        return -1;
  256|       |
  257|      2|    size_t len = strlen(ssh_mock_ed25519_key_pem);
  258|      2|    size_t nwritten = fwrite(ssh_mock_ed25519_key_pem, 1, len, fp);
  259|      2|    fclose(fp);
  260|       |
  261|      2|    return (nwritten == len) ? 0 : -1;
  ------------------
  |  Branch (261:12): [True: 2, False: 0]
  ------------------
  262|      2|}
ssh_server_mock.c:server_thread_func:
  103|  8.64k|{
  104|  8.64k|    struct ssh_mock_server_config *config =
  105|  8.64k|        (struct ssh_mock_server_config *)arg;
  106|  8.64k|    ssh_bind sshbind = NULL;
  107|  8.64k|    ssh_session session = NULL;
  108|  8.64k|    ssh_event event = NULL;
  109|  8.64k|    struct mock_session_data sdata = {0};
  110|  8.64k|    sdata.config = config;
  111|       |
  112|  8.64k|    struct ssh_server_callbacks_struct server_cb = {
  113|  8.64k|        .userdata = &sdata,
  114|  8.64k|        .auth_none_function = mock_auth_none,
  115|  8.64k|        .channel_open_request_session_function = mock_channel_open,
  116|  8.64k|    };
  117|       |
  118|  8.64k|    struct ssh_channel_callbacks_struct channel_cb = {
  119|  8.64k|        .userdata = &sdata,
  120|  8.64k|        .channel_exec_request_function = mock_channel_exec,
  121|  8.64k|        .channel_subsystem_request_function = mock_channel_subsystem,
  122|  8.64k|    };
  123|       |
  124|  8.64k|    bool no = false;
  125|       |
  126|  8.64k|    sshbind = ssh_bind_new();
  127|  8.64k|    if (sshbind == NULL) {
  ------------------
  |  Branch (127:9): [True: 0, False: 8.64k]
  ------------------
  128|      0|        config->server_error = true;
  129|      0|        return NULL;
  130|      0|    }
  131|       |
  132|  8.64k|    session = ssh_new();
  133|  8.64k|    if (session == NULL) {
  ------------------
  |  Branch (133:9): [True: 0, False: 8.64k]
  ------------------
  134|      0|        ssh_bind_free(sshbind);
  135|      0|        config->server_error = true;
  136|      0|        return NULL;
  137|      0|    }
  138|       |
  139|  8.64k|    const char *cipher = config->cipher ? config->cipher : "aes128-ctr";
  ------------------
  |  Branch (139:26): [True: 8.64k, False: 0]
  ------------------
  140|  8.64k|    const char *hmac = config->hmac ? config->hmac : "hmac-sha1";
  ------------------
  |  Branch (140:24): [True: 8.64k, False: 0]
  ------------------
  141|       |
  142|  8.64k|    ssh_bind_options_set(sshbind,
  143|  8.64k|                         SSH_BIND_OPTIONS_HOSTKEY,
  144|  8.64k|                         SSH_MOCK_HOSTKEY_PATH);
  ------------------
  |  |   58|  8.64k|#define SSH_MOCK_HOSTKEY_PATH "/tmp/libssh_mock_fuzz_key"
  ------------------
  145|  8.64k|    ssh_bind_options_set(sshbind, SSH_BIND_OPTIONS_CIPHERS_C_S, cipher);
  146|  8.64k|    ssh_bind_options_set(sshbind, SSH_BIND_OPTIONS_CIPHERS_S_C, cipher);
  147|  8.64k|    ssh_bind_options_set(sshbind, SSH_BIND_OPTIONS_HMAC_C_S, hmac);
  148|  8.64k|    ssh_bind_options_set(sshbind, SSH_BIND_OPTIONS_HMAC_S_C, hmac);
  149|  8.64k|    ssh_bind_options_set(sshbind, SSH_BIND_OPTIONS_PROCESS_CONFIG, &no);
  150|       |
  151|  8.64k|    ssh_set_auth_methods(session, SSH_AUTH_METHOD_NONE);
  ------------------
  |  |  156|  8.64k|#define SSH_AUTH_METHOD_NONE         0x0001u
  ------------------
  152|  8.64k|    ssh_callbacks_init(&server_cb);
  ------------------
  |  |  534|  8.64k|#define ssh_callbacks_init(p) do {\
  |  |  535|  8.64k|	(p)->size=sizeof(*(p)); \
  |  |  536|  8.64k|} while(0);
  |  |  ------------------
  |  |  |  Branch (536:9): [Folded, False: 8.64k]
  |  |  ------------------
  ------------------
  153|  8.64k|    ssh_set_server_callbacks(session, &server_cb);
  154|       |
  155|  8.64k|    if (ssh_bind_accept_fd(sshbind, session, config->server_socket) != SSH_OK) {
  ------------------
  |  |  316|  8.64k|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (155:9): [True: 0, False: 8.64k]
  ------------------
  156|      0|        ssh_free(session);
  157|      0|        ssh_bind_free(sshbind);
  158|      0|        config->server_error = true;
  159|      0|        return NULL;
  160|      0|    }
  161|       |
  162|  8.64k|    config->server_ready = true;
  163|       |
  164|  8.64k|    event = ssh_event_new();
  165|  8.64k|    if (event == NULL) {
  ------------------
  |  Branch (165:9): [True: 0, False: 8.64k]
  ------------------
  166|      0|        ssh_disconnect(session);
  167|      0|        ssh_free(session);
  168|      0|        ssh_bind_free(sshbind);
  169|      0|        return NULL;
  170|      0|    }
  171|       |
  172|  8.64k|    if (ssh_handle_key_exchange(session) == SSH_OK) {
  ------------------
  |  |  316|  8.64k|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (172:9): [True: 8.64k, False: 0]
  ------------------
  173|  8.64k|        ssh_event_add_session(event, session);
  174|       |
  175|  60.4k|        for (int i = 0; i < 50 && !sdata.channel; i++) {
  ------------------
  |  Branch (175:25): [True: 60.4k, False: 0]
  |  Branch (175:35): [True: 51.8k, False: 8.64k]
  ------------------
  176|  51.8k|            ssh_event_dopoll(event, 1);
  177|  51.8k|        }
  178|       |
  179|  8.64k|        if (sdata.channel) {
  ------------------
  |  Branch (179:13): [True: 8.64k, False: 0]
  ------------------
  180|  8.64k|            ssh_callbacks_init(&channel_cb);
  ------------------
  |  |  534|  8.64k|#define ssh_callbacks_init(p) do {\
  |  |  535|  8.64k|	(p)->size=sizeof(*(p)); \
  |  |  536|  8.64k|} while(0);
  |  |  ------------------
  |  |  |  Branch (536:9): [Folded, False: 8.64k]
  |  |  ------------------
  ------------------
  181|  8.64k|            ssh_set_channel_callbacks(sdata.channel, &channel_cb);
  182|       |
  183|  8.64k|            int max_iterations = 30;
  184|  25.9k|            for (int iter = 0; iter < max_iterations &&
  ------------------
  |  Branch (184:32): [True: 25.9k, False: 0]
  ------------------
  185|  25.9k|                               !ssh_channel_is_closed(sdata.channel) &&
  ------------------
  |  Branch (185:32): [True: 17.2k, False: 8.64k]
  ------------------
  186|  17.2k|                               !ssh_channel_is_eof(sdata.channel);
  ------------------
  |  Branch (186:32): [True: 17.2k, False: 0]
  ------------------
  187|  17.2k|                 iter++) {
  188|  17.2k|                if (ssh_event_dopoll(event, 100) == SSH_ERROR) {
  ------------------
  |  |  317|  17.2k|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  |  Branch (188:21): [True: 0, False: 17.2k]
  ------------------
  189|      0|                    break;
  190|      0|                }
  191|  17.2k|            }
  192|  8.64k|        }
  193|  8.64k|    }
  194|       |
  195|  8.64k|    if (event)
  ------------------
  |  Branch (195:9): [True: 8.64k, False: 0]
  ------------------
  196|  8.64k|        ssh_event_free(event);
  197|  8.64k|    if (session) {
  ------------------
  |  Branch (197:9): [True: 8.64k, False: 0]
  ------------------
  198|  8.64k|        ssh_disconnect(session);
  199|  8.64k|        ssh_free(session);
  200|  8.64k|    }
  201|  8.64k|    if (sshbind)
  ------------------
  |  Branch (201:9): [True: 8.64k, False: 0]
  ------------------
  202|  8.64k|        ssh_bind_free(sshbind);
  203|       |
  204|       |    return NULL;
  205|  8.64k|}
ssh_server_mock.c:mock_auth_none:
   47|  8.64k|{
   48|  8.64k|    (void)session;
   49|  8.64k|    (void)user;
   50|  8.64k|    (void)userdata;
   51|  8.64k|    return SSH_AUTH_SUCCESS;
   52|  8.64k|}
ssh_server_mock.c:mock_channel_open:
   56|  8.64k|{
   57|  8.64k|    struct mock_session_data *sdata = (struct mock_session_data *)userdata;
   58|  8.64k|    sdata->channel = ssh_channel_new(session);
   59|  8.64k|    return sdata->channel;
   60|  8.64k|}
ssh_server_mock.c:mock_channel_exec:
   67|  8.64k|{
   68|  8.64k|    struct mock_session_data *sdata = (struct mock_session_data *)userdata;
   69|  8.64k|    (void)session;
   70|  8.64k|    (void)command;
   71|       |
   72|  8.64k|    if (sdata->config->exec_callback) {
  ------------------
  |  Branch (72:9): [True: 8.64k, False: 0]
  ------------------
   73|  8.64k|        return sdata->config->exec_callback(channel,
   74|  8.64k|                                            sdata->config->protocol_data,
   75|  8.64k|                                            sdata->config->protocol_data_size,
   76|  8.64k|                                            sdata->config->callback_userdata);
   77|  8.64k|    }
   78|      0|    return SSH_OK;
  ------------------
  |  |  316|      0|#define SSH_OK 0     /* No error */
  ------------------
   79|  8.64k|}

