ssh_agent_new:
  170|    473|{
  171|    473|    ssh_agent agent = NULL;
  172|       |
  173|    473|    agent = calloc(1, sizeof(struct ssh_agent_struct));
  174|    473|    if (agent == NULL) {
  ------------------
  |  Branch (174:9): [True: 0, False: 473]
  ------------------
  175|      0|        return NULL;
  176|      0|    }
  177|       |
  178|    473|    agent->count = 0;
  179|    473|    agent->sock = ssh_socket_new(session);
  180|    473|    if (agent->sock == NULL) {
  ------------------
  |  Branch (180:9): [True: 0, False: 473]
  ------------------
  181|      0|        SAFE_FREE(agent);
  ------------------
  |  |  375|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (375:31): [True: 0, False: 0]
  |  |  |  Branch (375:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
  182|      0|        return NULL;
  183|      0|    }
  184|    473|    agent->channel = NULL;
  185|       |#ifdef _WIN32
  186|       |    agent->pipe_handle = NULL;
  187|       |#endif
  188|    473|    return agent;
  189|    473|}
ssh_agent_close:
  258|    473|{
  259|    473|    if (agent == NULL) {
  ------------------
  |  Branch (259:9): [True: 0, False: 473]
  ------------------
  260|      0|        return;
  261|      0|    }
  262|       |
  263|       |#ifdef _WIN32
  264|       |    if (agent_pipe_is_open(agent)) {
  265|       |        CloseHandle((HANDLE)agent->pipe_handle);
  266|       |        agent->pipe_handle = NULL;
  267|       |    }
  268|       |#endif
  269|       |
  270|    473|    ssh_socket_close(agent->sock);
  271|    473|}
ssh_agent_free:
  274|    700|{
  275|    700|    if (agent) {
  ------------------
  |  Branch (275:9): [True: 473, False: 227]
  ------------------
  276|    473|        if (agent->ident) {
  ------------------
  |  Branch (276:13): [True: 0, False: 473]
  ------------------
  277|      0|            SSH_BUFFER_FREE(agent->ident);
  ------------------
  |  |  924|      0|    do { if ((x) != NULL) { ssh_buffer_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (924:14): [True: 0, False: 0]
  |  |  |  Branch (924:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
  278|      0|        }
  279|    473|        if (agent->sock) {
  ------------------
  |  Branch (279:13): [True: 473, False: 0]
  ------------------
  280|    473|            ssh_agent_close(agent);
  281|    473|            ssh_socket_free(agent->sock);
  282|    473|        }
  283|       |        SAFE_FREE(agent);
  ------------------
  |  |  375|    473|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (375:31): [True: 473, False: 0]
  |  |  |  Branch (375:71): [Folded, False: 473]
  |  |  ------------------
  ------------------
  284|    473|    }
  285|    700|}

ssh_agent_state_free:
 1148|    700|{
 1149|    700|    struct ssh_agent_state_struct *state = data;
 1150|       |
 1151|    700|    if (state) {
  ------------------
  |  Branch (1151:9): [True: 0, False: 700]
  ------------------
 1152|       |        SSH_STRING_FREE_CHAR(state->comment);
  ------------------
  |  |  891|      0|    do { if ((x) != NULL) { ssh_string_free_char(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (891:14): [True: 0, False: 0]
  |  |  |  Branch (891:74): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1153|      0|        ssh_key_free(state->pubkey);
 1154|      0|        free(state);
 1155|      0|    }
 1156|    700|}

ssh_make_bignum_string:
   69|    173|{
   70|    173|    return make_bignum_string(num, 0);
   71|    173|}
ssh_make_string_bn:
   79|     86|{
   80|     86|    bignum bn = NULL;
   81|     86|    size_t len = ssh_string_len(string);
   82|       |
   83|       |#ifdef DEBUG_CRYPTO
   84|       |    SSH_LOG(SSH_LOG_TRACE,
   85|       |            "Importing a %zu bits, %zu bytes object ...",
   86|       |            len * 8,
   87|       |            len);
   88|       |#endif /* DEBUG_CRYPTO */
   89|       |
   90|     86|    bignum_bin2bn(string->data, (int)len, &bn);
  ------------------
  |  |   79|     86|    do {                                     \
  |  |   80|     86|        (*dest) = BN_new();                  \
  |  |   81|     86|        if ((*dest) != NULL) {               \
  |  |  ------------------
  |  |  |  Branch (81:13): [True: 86, False: 0]
  |  |  ------------------
  |  |   82|     86|            BN_bin2bn(data,datalen,(*dest)); \
  |  |   83|     86|        }                                    \
  |  |   84|     86|    } while(0)
  |  |  ------------------
  |  |  |  Branch (84:13): [Folded, False: 86]
  |  |  ------------------
  ------------------
   91|       |
   92|     86|    return bn;
   93|     86|}
bignum.c:make_bignum_string:
   31|    173|{
   32|    173|    ssh_string ptr = NULL;
   33|    173|    size_t pad = 0;
   34|    173|    size_t len = bignum_num_bytes(num);
  ------------------
  |  |   98|    173|#define bignum_num_bytes(num) (size_t)BN_num_bytes(num)
  ------------------
   35|    173|    size_t bits = bignum_num_bits(num);
  ------------------
  |  |   99|    173|#define bignum_num_bits(num) (size_t)BN_num_bits(num)
  ------------------
   36|       |
   37|    173|    if (pad_to_len == 0) {
  ------------------
  |  Branch (37:9): [True: 173, False: 0]
  ------------------
   38|       |        /* If the first bit is set we have a negative number */
   39|    173|        if (!(bits % 8) && bignum_is_bit_set(num, bits - 1)) {
  ------------------
  |  |  100|     56|#define bignum_is_bit_set(num,bit) BN_is_bit_set(num, (int)bit)
  |  |  ------------------
  |  |  |  Branch (100:36): [True: 55, False: 1]
  |  |  ------------------
  ------------------
  |  Branch (39:13): [True: 56, False: 117]
  ------------------
   40|     55|            pad++;
   41|     55|        }
   42|    173|    } else {
   43|      0|        if (len > pad_to_len) {
  ------------------
  |  Branch (43:13): [True: 0, False: 0]
  ------------------
   44|      0|            return NULL;
   45|      0|        }
   46|      0|        pad = pad_to_len - len;
   47|      0|    }
   48|       |
   49|       |#ifdef DEBUG_CRYPTO
   50|       |    SSH_LOG(SSH_LOG_TRACE, "%zu bits, %zu bytes, %zu padding", bits, len, pad);
   51|       |#endif /* DEBUG_CRYPTO */
   52|       |
   53|    173|    ptr = ssh_string_new(len + pad);
   54|    173|    if (ptr == NULL) {
  ------------------
  |  Branch (54:9): [True: 0, False: 173]
  ------------------
   55|      0|        return NULL;
   56|      0|    }
   57|       |
   58|       |    /* We have a negative number so we need a leading zero */
   59|    173|    if (pad) {
  ------------------
  |  Branch (59:9): [True: 55, False: 118]
  ------------------
   60|     55|        memset(ptr->data, 0, pad);
   61|     55|    }
   62|       |
   63|    173|    bignum_bn2bin(num, len, ptr->data + pad);
  ------------------
  |  |  101|    173|#define bignum_bn2bin(num,len, ptr) BN_bn2bin(num, ptr)
  ------------------
   64|       |
   65|    173|    return ptr;
   66|    173|}

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

_ssh_remove_legacy_log_cb:
   49|    700|{
   50|    700|    if (ssh_get_log_callback() == ssh_legacy_log_callback) {
  ------------------
  |  Branch (50:9): [True: 0, False: 700]
  ------------------
   51|      0|        _ssh_reset_log_cb();
   52|       |        ssh_set_log_userdata(NULL);
   53|      0|    }
   54|    700|}
ssh_set_callbacks:
   57|    473|{
   58|    473|    if (session == NULL || cb == NULL) {
  ------------------
  |  Branch (58:9): [True: 0, False: 473]
  |  Branch (58:28): [True: 0, False: 473]
  ------------------
   59|      0|        return SSH_ERROR;
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
   60|      0|    }
   61|       |
   62|    473|    if (!is_callback_valid(session, cb)) {
  ------------------
  |  |   31|    473|    (cb->size > 0 || cb->size <= 1024 * sizeof(void *))
  |  |  ------------------
  |  |  |  Branch (31:6): [True: 473, False: 0]
  |  |  |  Branch (31:22): [True: 0, False: 0]
  |  |  ------------------
  ------------------
   63|      0|        ssh_set_error(session,
  ------------------
  |  |  313|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
   64|      0|                      SSH_FATAL,
   65|      0|                      "Invalid callback passed in (badly initialized)");
   66|      0|        return SSH_ERROR;
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
   67|    473|    };
   68|    473|    session->common.callbacks = cb;
   69|       |
   70|       |    /* LEGACY */
   71|    473|    if (ssh_get_log_callback() == NULL && cb->log_function) {
  ------------------
  |  Branch (71:9): [True: 473, False: 0]
  |  Branch (71:43): [True: 0, False: 473]
  ------------------
   72|      0|        ssh_set_log_callback(ssh_legacy_log_callback);
   73|      0|        ssh_set_log_userdata(session);
   74|      0|    }
   75|       |
   76|    473|    return 0;
   77|    473|}

ssh_channel_free:
 1301|    930|{
 1302|    930|    ssh_session session = NULL;
 1303|       |
 1304|    930|    if (channel == NULL) {
  ------------------
  |  Branch (1304:9): [True: 930, False: 0]
  ------------------
 1305|    930|        return;
 1306|    930|    }
 1307|       |
 1308|      0|    session = channel->session;
 1309|      0|    if (session->alive) {
  ------------------
  |  Branch (1309:9): [True: 0, False: 0]
  ------------------
 1310|      0|        bool send_close = false;
 1311|       |
 1312|      0|        switch (channel->state) {
 1313|      0|        case SSH_CHANNEL_STATE_OPEN:
  ------------------
  |  Branch (1313:9): [True: 0, False: 0]
  ------------------
 1314|      0|            send_close = true;
 1315|      0|            break;
 1316|      0|        case SSH_CHANNEL_STATE_CLOSED:
  ------------------
  |  Branch (1316:9): [True: 0, False: 0]
  ------------------
 1317|      0|            if (channel->flags & SSH_CHANNEL_FLAG_CLOSED_REMOTE) {
  ------------------
  |  |   55|      0|#define SSH_CHANNEL_FLAG_CLOSED_REMOTE 0x0001
  ------------------
  |  Branch (1317:17): [True: 0, False: 0]
  ------------------
 1318|      0|                send_close = true;
 1319|      0|            }
 1320|      0|            if (channel->flags & SSH_CHANNEL_FLAG_CLOSED_LOCAL) {
  ------------------
  |  |   58|      0|#define SSH_CHANNEL_FLAG_CLOSED_LOCAL 0x0002
  ------------------
  |  Branch (1320:17): [True: 0, False: 0]
  ------------------
 1321|      0|                send_close = false;
 1322|      0|            }
 1323|      0|            break;
 1324|      0|        default:
  ------------------
  |  Branch (1324:9): [True: 0, False: 0]
  ------------------
 1325|      0|            send_close = false;
 1326|      0|            break;
 1327|      0|        }
 1328|       |
 1329|      0|        if (send_close) {
  ------------------
  |  Branch (1329:13): [True: 0, False: 0]
  ------------------
 1330|      0|            ssh_channel_close(channel);
 1331|      0|        }
 1332|      0|    }
 1333|      0|    channel->flags |= SSH_CHANNEL_FLAG_FREED_LOCAL;
  ------------------
  |  |   61|      0|#define SSH_CHANNEL_FLAG_FREED_LOCAL 0x0004
  ------------------
 1334|       |
 1335|      0|    if (channel->callbacks != NULL) {
  ------------------
  |  Branch (1335:9): [True: 0, False: 0]
  ------------------
 1336|      0|        ssh_list_free(channel->callbacks);
 1337|      0|        channel->callbacks = NULL;
 1338|      0|    }
 1339|       |
 1340|       |    /* The idea behind the flags is the following : it is well possible
 1341|       |     * that a client closes a channel that still exists on the server side.
 1342|       |     * We definitively close the channel when we receive a close message *and*
 1343|       |     * the user closed it.
 1344|       |     */
 1345|      0|    if ((channel->flags & SSH_CHANNEL_FLAG_CLOSED_REMOTE) ||
  ------------------
  |  |   55|      0|#define SSH_CHANNEL_FLAG_CLOSED_REMOTE 0x0001
  ------------------
  |  Branch (1345:9): [True: 0, False: 0]
  ------------------
 1346|      0|        (channel->flags & SSH_CHANNEL_FLAG_NOT_BOUND)) {
  ------------------
  |  |   64|      0|#define SSH_CHANNEL_FLAG_NOT_BOUND 0x0008
  ------------------
  |  Branch (1346:9): [True: 0, False: 0]
  ------------------
 1347|      0|        ssh_channel_do_free(channel);
 1348|      0|    }
 1349|      0|}

ssh_send_banner:
  187|    473|{
  188|    473|    const char *banner = CLIENT_BANNER_SSH2;
  ------------------
  |  |  223|    473|#define CLIENT_BANNER_SSH2 "SSH-2.0-libssh_" SSH_STRINGIFY(LIBSSH_VERSION)
  |  |  ------------------
  |  |  |  |   71|    473|#define SSH_STRINGIFY(s) SSH_TOSTRING(s)
  |  |  |  |  ------------------
  |  |  |  |  |  |   72|    473|#define SSH_TOSTRING(s) #s
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  189|    473|    const char *terminator = "\r\n";
  190|       |    /* The maximum banner length is 255 for SSH2 */
  191|    473|    char buffer[256] = {0};
  192|    473|    size_t len;
  193|    473|    int rc = SSH_ERROR;
  ------------------
  |  |  316|    473|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  194|       |
  195|    473|    if (server == 1) {
  ------------------
  |  Branch (195:9): [True: 0, False: 473]
  ------------------
  196|      0|        if (session->server_opts.custombanner == NULL) {
  ------------------
  |  Branch (196:13): [True: 0, False: 0]
  ------------------
  197|      0|            session->serverbanner = strdup(banner);
  198|      0|            if (session->serverbanner == NULL) {
  ------------------
  |  Branch (198:17): [True: 0, False: 0]
  ------------------
  199|      0|                goto end;
  200|      0|            }
  201|      0|        } 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|      0|        snprintf(buffer,
  214|      0|                 sizeof(buffer),
  215|      0|                 "%s%s",
  216|      0|                 session->serverbanner,
  217|      0|                 terminator);
  218|    473|    } else {
  219|    473|        session->clientbanner = strdup(banner);
  220|    473|        if (session->clientbanner == NULL) {
  ------------------
  |  Branch (220:13): [True: 0, False: 473]
  ------------------
  221|      0|            goto end;
  222|      0|        }
  223|       |
  224|    473|        snprintf(buffer,
  225|    473|                 sizeof(buffer),
  226|    473|                 "%s%s",
  227|    473|                 session->clientbanner,
  228|    473|                 terminator);
  229|    473|    }
  230|       |
  231|    473|    rc = ssh_socket_write(session->socket, buffer, (uint32_t)strlen(buffer));
  232|    473|    if (rc == SSH_ERROR) {
  ------------------
  |  |  316|    473|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  |  Branch (232:9): [True: 0, False: 473]
  ------------------
  233|      0|        goto end;
  234|      0|    }
  235|    473|#ifdef WITH_PCAP
  236|    473|    if (session->pcap_ctx != NULL) {
  ------------------
  |  Branch (236:9): [True: 0, False: 473]
  ------------------
  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|    473|#endif
  244|       |
  245|    473|    rc = SSH_OK;
  ------------------
  |  |  315|    473|#define SSH_OK 0     /* No error */
  ------------------
  246|    473|end:
  247|    473|    return rc;
  248|    473|}
dh_handshake:
  258|    166|{
  259|    166|    int rc = SSH_AGAIN;
  ------------------
  |  |  317|    166|#define SSH_AGAIN -2 /* The nonblocking call must be repeated */
  ------------------
  260|       |
  261|    166|    SSH_LOG(SSH_LOG_TRACE,
  ------------------
  |  |  283|    166|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  262|    166|            "dh_handshake_state = %d, kex_type = %d",
  263|    166|            session->dh_handshake_state,
  264|    166|            session->next_crypto->kex_type);
  265|       |
  266|    166|    switch (session->dh_handshake_state) {
  267|    166|    case DH_STATE_INIT:
  ------------------
  |  Branch (267:5): [True: 166, False: 0]
  ------------------
  268|    166|        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: 166]
  ------------------
  278|      0|        case SSH_KEX_DH_GROUP14_SHA1:
  ------------------
  |  Branch (278:9): [True: 0, False: 166]
  ------------------
  279|      4|        case SSH_KEX_DH_GROUP14_SHA256:
  ------------------
  |  Branch (279:9): [True: 4, False: 162]
  ------------------
  280|      5|        case SSH_KEX_DH_GROUP16_SHA512:
  ------------------
  |  Branch (280:9): [True: 1, False: 165]
  ------------------
  281|     23|        case SSH_KEX_DH_GROUP18_SHA512:
  ------------------
  |  Branch (281:9): [True: 18, False: 148]
  ------------------
  282|     23|            rc = ssh_client_dh_init(session);
  283|     23|            break;
  284|      0|#ifdef WITH_GEX
  285|      0|        case SSH_KEX_DH_GEX_SHA1:
  ------------------
  |  Branch (285:9): [True: 0, False: 166]
  ------------------
  286|      3|        case SSH_KEX_DH_GEX_SHA256:
  ------------------
  |  Branch (286:9): [True: 3, False: 163]
  ------------------
  287|      3|            rc = ssh_client_dhgex_init(session);
  288|      3|            break;
  289|      0|#endif /* WITH_GEX */
  290|      0|#ifdef HAVE_ECDH
  291|      4|        case SSH_KEX_ECDH_SHA2_NISTP256:
  ------------------
  |  Branch (291:9): [True: 4, False: 162]
  ------------------
  292|      5|        case SSH_KEX_ECDH_SHA2_NISTP384:
  ------------------
  |  Branch (292:9): [True: 1, False: 165]
  ------------------
  293|      8|        case SSH_KEX_ECDH_SHA2_NISTP521:
  ------------------
  |  Branch (293:9): [True: 3, False: 163]
  ------------------
  294|      8|            rc = ssh_client_ecdh_init(session);
  295|      8|            break;
  296|      0|#endif
  297|      0|#ifdef HAVE_CURVE25519
  298|     14|        case SSH_KEX_CURVE25519_SHA256:
  ------------------
  |  Branch (298:9): [True: 14, False: 152]
  ------------------
  299|     17|        case SSH_KEX_CURVE25519_SHA256_LIBSSH_ORG:
  ------------------
  |  Branch (299:9): [True: 3, False: 163]
  ------------------
  300|     17|            rc = ssh_client_curve25519_init(session);
  301|     17|            break;
  302|      0|#endif
  303|      0|#ifdef HAVE_SNTRUP761
  304|      1|        case SSH_KEX_SNTRUP761X25519_SHA512:
  ------------------
  |  Branch (304:9): [True: 1, False: 165]
  ------------------
  305|     66|        case SSH_KEX_SNTRUP761X25519_SHA512_OPENSSH_COM:
  ------------------
  |  Branch (305:9): [True: 65, False: 101]
  ------------------
  306|     66|            rc = ssh_client_sntrup761x25519_init(session);
  307|     66|            break;
  308|      0|#endif
  309|      0|        case SSH_KEX_MLKEM768X25519_SHA256:
  ------------------
  |  Branch (309:9): [True: 0, False: 166]
  ------------------
  310|     49|        case SSH_KEX_MLKEM768NISTP256_SHA256:
  ------------------
  |  Branch (310:9): [True: 49, False: 117]
  ------------------
  311|       |#ifdef HAVE_MLKEM1024
  312|       |        case SSH_KEX_MLKEM1024NISTP384_SHA384:
  313|       |#endif
  314|     49|            rc = ssh_client_hybrid_mlkem_init(session);
  315|     49|            break;
  316|      0|        default:
  ------------------
  |  Branch (316:9): [True: 0, False: 166]
  ------------------
  317|      0|            rc = SSH_ERROR;
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  318|    166|        }
  319|       |
  320|    166|        break;
  321|    166|    case DH_STATE_INIT_SENT:
  ------------------
  |  Branch (321:5): [True: 0, False: 166]
  ------------------
  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: 166]
  ------------------
  325|       |    	/* wait until ssh_packet_newkeys is called */
  326|      0|    	break;
  327|      0|    case DH_STATE_FINISHED:
  ------------------
  |  Branch (327:5): [True: 0, False: 166]
  ------------------
  328|      0|        return SSH_OK;
  ------------------
  |  |  315|      0|#define SSH_OK 0     /* No error */
  ------------------
  329|      0|    default:
  ------------------
  |  Branch (329:5): [True: 0, False: 166]
  ------------------
  330|      0|        ssh_set_error(session,
  ------------------
  |  |  313|      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;
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  336|    166|    }
  337|       |
  338|    166|    return rc;
  339|    166|}
ssh_connect:
  556|    473|{
  557|    473|    int ret;
  558|       |
  559|    473|    if (!is_ssh_initialized()) {
  ------------------
  |  Branch (559:9): [True: 0, False: 473]
  ------------------
  560|      0|        ssh_set_error(session, SSH_FATAL,
  ------------------
  |  |  313|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  561|      0|                      "Library not initialized.");
  562|       |
  563|      0|        return SSH_ERROR;
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  564|      0|    }
  565|       |
  566|    473|    if (session == NULL) {
  ------------------
  |  Branch (566:9): [True: 0, False: 473]
  ------------------
  567|      0|        return SSH_ERROR;
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  568|      0|    }
  569|       |
  570|    473|    switch(session->pending_call_state) {
  571|    473|    case SSH_PENDING_CALL_NONE:
  ------------------
  |  Branch (571:5): [True: 473, False: 0]
  ------------------
  572|    473|        break;
  573|      0|    case SSH_PENDING_CALL_CONNECT:
  ------------------
  |  Branch (573:5): [True: 0, False: 473]
  ------------------
  574|      0|        goto pending;
  575|      0|    default:
  ------------------
  |  Branch (575:5): [True: 0, False: 473]
  ------------------
  576|      0|        ssh_set_error(session, SSH_FATAL,
  ------------------
  |  |  313|      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;
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  580|    473|    }
  581|    473|    session->alive = 0;
  582|    473|    session->client = 1;
  583|       |
  584|    473|    if (session->opts.fd == SSH_INVALID_SOCKET &&
  ------------------
  |  |  123|    946|#define SSH_INVALID_SOCKET ((socket_t) -1)
  ------------------
  |  Branch (584:9): [True: 0, False: 473]
  ------------------
  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");
  ------------------
  |  |  313|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  588|      0|        return SSH_ERROR;
  ------------------
  |  |  316|      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|    473|    if (!session->opts.config_processed) {
  ------------------
  |  Branch (592:9): [True: 0, False: 473]
  ------------------
  593|      0|        ret = ssh_options_parse_config(session, NULL);
  594|      0|        if (ret != 0) {
  ------------------
  |  Branch (594:13): [True: 0, False: 0]
  ------------------
  595|      0|            ssh_set_error(session, SSH_FATAL,
  ------------------
  |  |  313|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  596|      0|                          "Failed to process system configuration files");
  597|      0|            return SSH_ERROR;
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  598|      0|        }
  599|      0|    }
  600|       |
  601|    473|    ret = ssh_options_apply(session);
  602|    473|    if (ret < 0) {
  ------------------
  |  Branch (602:9): [True: 0, False: 473]
  ------------------
  603|      0|        ssh_set_error(session, SSH_FATAL, "Couldn't apply options");
  ------------------
  |  |  313|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  604|      0|        return SSH_ERROR;
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  605|      0|    }
  606|       |
  607|    473|    SSH_LOG(SSH_LOG_DEBUG,
  ------------------
  |  |  283|    473|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  608|    473|            "libssh %s, using threading %s",
  609|    473|            ssh_copyright(),
  610|    473|            ssh_threads_get_type());
  611|       |
  612|    473|    session->ssh_connection_callback = ssh_client_connection_callback;
  613|    473|    session->session_state = SSH_SESSION_STATE_CONNECTING;
  614|    473|    ssh_socket_set_callbacks(session->socket, &session->socket_callbacks);
  615|    473|    session->socket_callbacks.connected = socket_callback_connected;
  616|    473|    session->socket_callbacks.data = callback_receive_banner;
  617|    473|    session->socket_callbacks.exception = ssh_socket_exception_callback;
  618|    473|    session->socket_callbacks.userdata = session;
  619|       |
  620|    473|    if (session->opts.fd != SSH_INVALID_SOCKET) {
  ------------------
  |  |  123|    473|#define SSH_INVALID_SOCKET ((socket_t) -1)
  ------------------
  |  Branch (620:9): [True: 473, False: 0]
  ------------------
  621|    473|        session->session_state = SSH_SESSION_STATE_SOCKET_CONNECTED;
  622|    473|        ret = ssh_socket_set_fd(session->socket, session->opts.fd);
  623|    473|#ifndef _WIN32
  624|    473|#ifdef HAVE_PTHREAD
  625|    473|    } 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,
  ------------------
  |  |  313|      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;
  ------------------
  |  |  316|      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|    473|    if (ret == SSH_ERROR) {
  ------------------
  |  |  316|    473|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  |  Branch (646:9): [True: 0, False: 473]
  ------------------
  647|      0|        return SSH_ERROR;
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  648|      0|    }
  649|       |
  650|    473|    set_status(session, 0.2f);
  ------------------
  |  |   58|    473|#define set_status(session, status) do {\
  |  |   59|    473|        if (session->common.callbacks && session->common.callbacks->connect_status_function) \
  |  |  ------------------
  |  |  |  Branch (59:13): [True: 473, False: 0]
  |  |  |  Branch (59:42): [True: 0, False: 473]
  |  |  ------------------
  |  |   60|    473|            session->common.callbacks->connect_status_function(session->common.callbacks->userdata, status); \
  |  |   61|    473|    } while (0)
  |  |  ------------------
  |  |  |  Branch (61:14): [Folded, False: 473]
  |  |  ------------------
  ------------------
  651|       |
  652|    473|    session->alive = 1;
  653|    473|    SSH_LOG(SSH_LOG_DEBUG,
  ------------------
  |  |  283|    473|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  654|    473|            "Socket connecting, now waiting for the callbacks to work");
  655|       |
  656|    473|pending:
  657|    473|    session->pending_call_state = SSH_PENDING_CALL_CONNECT;
  658|    473|    if(ssh_is_blocking(session)) {
  ------------------
  |  Branch (658:8): [True: 473, False: 0]
  ------------------
  659|    473|        int timeout = ssh_make_milliseconds(session->opts.timeout,
  660|    473|                                            session->opts.timeout_usec);
  661|    473|        SSH_LOG(SSH_LOG_PACKET, "Actual timeout : %d", timeout);
  ------------------
  |  |  283|    473|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  662|    473|        ret = ssh_handle_packets_termination(session, timeout,
  663|    473|                                             ssh_connect_termination, session);
  664|    473|        if (session->session_state != SSH_SESSION_STATE_ERROR &&
  ------------------
  |  Branch (664:13): [True: 0, False: 473]
  ------------------
  665|      0|            (ret == SSH_ERROR || !ssh_connect_termination(session)))
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  |  Branch (665:14): [True: 0, False: 0]
  |  Branch (665:34): [True: 0, False: 0]
  ------------------
  666|      0|        {
  667|      0|            ssh_set_error(session, SSH_FATAL,
  ------------------
  |  |  313|      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|    473|    } 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) {
  ------------------
  |  |  316|      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|    473|    SSH_LOG(SSH_LOG_PACKET, "current state : %d", session->session_state);
  ------------------
  |  |  283|    473|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  682|    473|    if (!ssh_is_blocking(session) && !ssh_connect_termination(session)) {
  ------------------
  |  Branch (682:9): [True: 0, False: 473]
  |  Branch (682:38): [True: 0, False: 0]
  ------------------
  683|      0|        return SSH_AGAIN;
  ------------------
  |  |  317|      0|#define SSH_AGAIN -2 /* The nonblocking call must be repeated */
  ------------------
  684|      0|    }
  685|       |
  686|    473|    session->pending_call_state = SSH_PENDING_CALL_NONE;
  687|    473|    if (session->session_state == SSH_SESSION_STATE_ERROR ||
  ------------------
  |  Branch (687:9): [True: 473, False: 0]
  ------------------
  688|      0|        session->session_state == SSH_SESSION_STATE_DISCONNECTED)
  ------------------
  |  Branch (688:9): [True: 0, False: 0]
  ------------------
  689|    473|    {
  690|    473|        return SSH_ERROR;
  ------------------
  |  |  316|    473|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  691|    473|    }
  692|       |
  693|      0|    return SSH_OK;
  ------------------
  |  |  315|      0|#define SSH_OK 0     /* No error */
  ------------------
  694|    473|}
ssh_disconnect:
  809|    930|{
  810|    930|    struct ssh_iterator *it = NULL;
  811|    930|    int rc;
  812|       |
  813|    930|    if (session == NULL) {
  ------------------
  |  Branch (813:9): [True: 457, False: 473]
  ------------------
  814|    457|        return;
  815|    457|    }
  816|       |
  817|    473|#ifndef _WIN32
  818|    473|#ifdef HAVE_PTHREAD
  819|       |    /* Only send the disconnect to all other threads when the root session calls
  820|       |     * ssh_disconnect() */
  821|    473|    if (session->proxy_root) {
  ------------------
  |  Branch (821:9): [True: 473, False: 0]
  ------------------
  822|    473|        proxy_disconnect = 1;
  823|    473|    }
  824|    473|#endif /* HAVE_PTHREAD */
  825|    473|#endif /* _WIN32 */
  826|       |
  827|    473|    if (session->disconnect_message == NULL) {
  ------------------
  |  Branch (827:9): [True: 473, False: 0]
  ------------------
  828|    473|        session->disconnect_message = strdup("Bye Bye") ;
  829|    473|        if (session->disconnect_message == NULL) {
  ------------------
  |  Branch (829:13): [True: 0, False: 473]
  ------------------
  830|      0|            ssh_set_error_oom(session);
  ------------------
  |  |  320|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
  831|      0|            goto error;
  832|      0|        }
  833|    473|    }
  834|       |
  835|    473|    if (session->socket != NULL && ssh_socket_is_open(session->socket)) {
  ------------------
  |  Branch (835:9): [True: 473, False: 0]
  |  Branch (835:36): [True: 473, False: 0]
  ------------------
  836|    473|        rc = ssh_buffer_pack(session->out_buffer,
  ------------------
  |  |   50|    473|    _ssh_buffer_pack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |  453|    473|        (__VA_NARG_(__VA_ARGS__, __RSEQ_N()))
  |  |  |  |  ------------------
  |  |  |  |  |  |  455|    473|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  450|    473|#define VA_APPLY_VARIADIC_MACRO(macro, tuple) macro tuple
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  455|    473|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  463|    473|        _61,_62,_63,N,...) N
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                   _ssh_buffer_pack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |   28|    473|#define SSH_BUFFER_PACK_END ((uint32_t) 0x4f65feb3)
  |  |  ------------------
  ------------------
  837|    473|                             "bdss",
  838|    473|                             SSH2_MSG_DISCONNECT,
  839|    473|                             SSH2_DISCONNECT_BY_APPLICATION,
  840|    473|                             session->disconnect_message,
  841|    473|                             ""); /* language tag */
  842|    473|        if (rc != SSH_OK) {
  ------------------
  |  |  315|    473|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (842:13): [True: 0, False: 473]
  ------------------
  843|      0|            ssh_set_error_oom(session);
  ------------------
  |  |  320|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
  844|      0|            goto error;
  845|      0|        }
  846|       |
  847|    473|        ssh_packet_send(session);
  848|    473|        ssh_session_socket_close(session);
  849|    473|    }
  850|       |
  851|    473|error:
  852|    473|    session->recv_seq = 0;
  853|    473|    session->send_seq = 0;
  854|    473|    session->alive = 0;
  855|    473|    if (session->socket != NULL){
  ------------------
  |  Branch (855:9): [True: 473, False: 0]
  ------------------
  856|    473|        ssh_socket_reset(session->socket);
  857|    473|    }
  858|    473|    session->opts.fd = SSH_INVALID_SOCKET;
  ------------------
  |  |  123|    473|#define SSH_INVALID_SOCKET ((socket_t) -1)
  ------------------
  859|    473|    session->session_state = SSH_SESSION_STATE_DISCONNECTED;
  860|    473|    session->pending_call_state = SSH_PENDING_CALL_NONE;
  861|    473|    session->packet_state = PACKET_STATE_INIT;
  862|       |
  863|    473|    while ((it = ssh_list_get_iterator(session->channels)) != NULL) {
  ------------------
  |  Branch (863:12): [True: 0, False: 473]
  ------------------
  864|      0|        ssh_channel_do_free(ssh_iterator_value(ssh_channel, it));
  ------------------
  |  |  122|      0|  ((type)((iterator)->data))
  ------------------
  865|      0|        ssh_list_remove(session->channels, it);
  866|      0|    }
  867|    473|    if (session->current_crypto) {
  ------------------
  |  Branch (867:9): [True: 0, False: 473]
  ------------------
  868|      0|      crypto_free(session->current_crypto);
  869|      0|      session->current_crypto = NULL;
  870|      0|    }
  871|    473|    if (session->next_crypto) {
  ------------------
  |  Branch (871:9): [True: 473, False: 0]
  ------------------
  872|    473|        crypto_free(session->next_crypto);
  873|    473|        session->next_crypto = crypto_new();
  874|    473|        if (session->next_crypto == NULL) {
  ------------------
  |  Branch (874:13): [True: 0, False: 473]
  ------------------
  875|      0|            ssh_set_error_oom(session);
  ------------------
  |  |  320|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
  876|      0|        }
  877|    473|    }
  878|    473|    if (session->in_buffer) {
  ------------------
  |  Branch (878:9): [True: 473, False: 0]
  ------------------
  879|    473|        ssh_buffer_reinit(session->in_buffer);
  880|    473|    }
  881|    473|    if (session->out_buffer) {
  ------------------
  |  Branch (881:9): [True: 473, False: 0]
  ------------------
  882|    473|        ssh_buffer_reinit(session->out_buffer);
  883|    473|    }
  884|    473|    if (session->in_hashbuf) {
  ------------------
  |  Branch (884:9): [True: 234, False: 239]
  ------------------
  885|    234|        ssh_buffer_reinit(session->in_hashbuf);
  886|    234|    }
  887|    473|    if (session->out_hashbuf) {
  ------------------
  |  Branch (887:9): [True: 384, False: 89]
  ------------------
  888|    384|        ssh_buffer_reinit(session->out_hashbuf);
  889|    384|    }
  890|    473|    session->auth.supported_methods = 0;
  891|    473|    SAFE_FREE(session->serverbanner);
  ------------------
  |  |  375|    473|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (375:31): [True: 422, False: 51]
  |  |  |  Branch (375:71): [Folded, False: 473]
  |  |  ------------------
  ------------------
  892|    473|    SAFE_FREE(session->clientbanner);
  ------------------
  |  |  375|    473|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (375:31): [True: 473, False: 0]
  |  |  |  Branch (375:71): [Folded, False: 473]
  |  |  ------------------
  ------------------
  893|    473|    SAFE_FREE(session->disconnect_message);
  ------------------
  |  |  375|    473|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (375:31): [True: 473, False: 0]
  |  |  |  Branch (375:71): [Folded, False: 473]
  |  |  ------------------
  ------------------
  894|       |
  895|    473|    if (session->ssh_message_list) {
  ------------------
  |  Branch (895:9): [True: 0, False: 473]
  ------------------
  896|      0|        ssh_message msg = NULL;
  897|       |
  898|      0|        while ((msg = ssh_list_pop_head(ssh_message,
  ------------------
  |  |  130|      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|    473|    if (session->packet_callbacks) {
  ------------------
  |  Branch (906:9): [True: 412, False: 61]
  ------------------
  907|    412|        ssh_list_free(session->packet_callbacks);
  908|       |        session->packet_callbacks = NULL;
  909|    412|    }
  910|    473|}
ssh_copyright:
  920|    473|{
  921|    473|    return SSH_STRINGIFY(LIBSSH_VERSION) " (c) 2003-2026 "
  ------------------
  |  |   71|    473|#define SSH_STRINGIFY(s) SSH_TOSTRING(s)
  |  |  ------------------
  |  |  |  |   72|    473|#define SSH_TOSTRING(s) #s
  |  |  ------------------
  ------------------
  922|    473|           "Aris Adamantiadis, Andreas Schneider "
  923|    473|           "and libssh contributors. "
  924|    473|           "Distributed under the LGPL, please refer to COPYING "
  925|    473|           "file for information about your rights";
  926|    473|}
client.c:ssh_client_connection_callback:
  427|  1.29k|{
  428|  1.29k|    int rc;
  429|       |
  430|  1.29k|    SSH_LOG(SSH_LOG_DEBUG, "session_state=%d", session->session_state);
  ------------------
  |  |  283|  1.29k|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  431|       |
  432|  1.29k|    switch (session->session_state) {
  433|      0|    case SSH_SESSION_STATE_NONE:
  ------------------
  |  Branch (433:5): [True: 0, False: 1.29k]
  ------------------
  434|      0|    case SSH_SESSION_STATE_CONNECTING:
  ------------------
  |  Branch (434:5): [True: 0, False: 1.29k]
  ------------------
  435|      0|        break;
  436|    473|    case SSH_SESSION_STATE_SOCKET_CONNECTED:
  ------------------
  |  Branch (436:5): [True: 473, False: 819]
  ------------------
  437|    473|        ssh_set_fd_towrite(session);
  438|    473|        ssh_send_banner(session, 0);
  439|       |
  440|    473|        break;
  441|    422|    case SSH_SESSION_STATE_BANNER_RECEIVED:
  ------------------
  |  Branch (441:5): [True: 422, False: 870]
  ------------------
  442|    422|        if (session->serverbanner == NULL) {
  ------------------
  |  Branch (442:13): [True: 0, False: 422]
  ------------------
  443|      0|            goto error;
  444|      0|        }
  445|    422|        set_status(session, 0.4f);
  ------------------
  |  |   58|    422|#define set_status(session, status) do {\
  |  |   59|    422|        if (session->common.callbacks && session->common.callbacks->connect_status_function) \
  |  |  ------------------
  |  |  |  Branch (59:13): [True: 422, False: 0]
  |  |  |  Branch (59:42): [True: 0, False: 422]
  |  |  ------------------
  |  |   60|    422|            session->common.callbacks->connect_status_function(session->common.callbacks->userdata, status); \
  |  |   61|    422|    } while (0)
  |  |  ------------------
  |  |  |  Branch (61:14): [Folded, False: 422]
  |  |  ------------------
  ------------------
  446|    422|        SSH_LOG(SSH_LOG_DEBUG, "SSH server banner: %s", session->serverbanner);
  ------------------
  |  |  283|    422|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  447|       |
  448|       |        /* Here we analyze the different protocols the server allows. */
  449|    422|        rc = ssh_analyze_banner(session, 0);
  450|    422|        if (rc < 0) {
  ------------------
  |  Branch (450:13): [True: 10, False: 412]
  ------------------
  451|     10|            ssh_set_error(session, SSH_FATAL,
  ------------------
  |  |  313|     10|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  452|     10|                          "No version of SSH protocol usable (banner: %s)",
  453|     10|                          session->serverbanner);
  454|     10|            goto error;
  455|     10|        }
  456|       |
  457|    412|        ssh_packet_register_socket_callback(session, session->socket);
  458|       |
  459|    412|        ssh_packet_set_default_callbacks(session);
  460|    412|        session->session_state = SSH_SESSION_STATE_INITIAL_KEX;
  461|    412|        rc = ssh_set_client_kex(session);
  462|    412|        if (rc != SSH_OK) {
  ------------------
  |  |  315|    412|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (462:13): [True: 0, False: 412]
  ------------------
  463|      0|            goto error;
  464|      0|        }
  465|    412|        rc = ssh_send_kex(session);
  466|    412|        if (rc < 0) {
  ------------------
  |  Branch (466:13): [True: 0, False: 412]
  ------------------
  467|      0|            goto error;
  468|      0|        }
  469|    412|        set_status(session, 0.5f);
  ------------------
  |  |   58|    412|#define set_status(session, status) do {\
  |  |   59|    412|        if (session->common.callbacks && session->common.callbacks->connect_status_function) \
  |  |  ------------------
  |  |  |  Branch (59:13): [True: 412, False: 0]
  |  |  |  Branch (59:42): [True: 0, False: 412]
  |  |  ------------------
  |  |   60|    412|            session->common.callbacks->connect_status_function(session->common.callbacks->userdata, status); \
  |  |   61|    412|    } while (0)
  |  |  ------------------
  |  |  |  Branch (61:14): [Folded, False: 412]
  |  |  ------------------
  ------------------
  470|       |
  471|    412|        break;
  472|      0|    case SSH_SESSION_STATE_INITIAL_KEX:
  ------------------
  |  Branch (472:5): [True: 0, False: 1.29k]
  ------------------
  473|       |        /* TODO: This state should disappear in favor of get_key handle */
  474|      0|        break;
  475|    244|    case SSH_SESSION_STATE_KEXINIT_RECEIVED:
  ------------------
  |  Branch (475:5): [True: 244, False: 1.04k]
  ------------------
  476|    244|        set_status(session, 0.6f);
  ------------------
  |  |   58|    244|#define set_status(session, status) do {\
  |  |   59|    244|        if (session->common.callbacks && session->common.callbacks->connect_status_function) \
  |  |  ------------------
  |  |  |  Branch (59:13): [True: 244, False: 0]
  |  |  |  Branch (59:42): [True: 0, False: 244]
  |  |  ------------------
  |  |   60|    244|            session->common.callbacks->connect_status_function(session->common.callbacks->userdata, status); \
  |  |   61|    244|    } while (0)
  |  |  ------------------
  |  |  |  Branch (61:14): [Folded, False: 244]
  |  |  ------------------
  ------------------
  477|    244|        ssh_list_kex(&session->next_crypto->server_kex);
  478|    244|        if ((session->flags & SSH_SESSION_FLAG_KEXINIT_SENT) == 0) {
  ------------------
  |  |   86|    244|#define SSH_SESSION_FLAG_KEXINIT_SENT 0x0008
  ------------------
  |  Branch (478:13): [True: 0, False: 244]
  ------------------
  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) {
  ------------------
  |  |  315|      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|    244|        if (ssh_kex_select_methods(session) == SSH_ERROR)
  ------------------
  |  |  316|    244|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  |  Branch (489:13): [True: 78, False: 166]
  ------------------
  490|     78|            goto error;
  491|    166|        set_status(session, 0.8f);
  ------------------
  |  |   58|    166|#define set_status(session, status) do {\
  |  |   59|    166|        if (session->common.callbacks && session->common.callbacks->connect_status_function) \
  |  |  ------------------
  |  |  |  Branch (59:13): [True: 166, False: 0]
  |  |  |  Branch (59:42): [True: 0, False: 166]
  |  |  ------------------
  |  |   60|    166|            session->common.callbacks->connect_status_function(session->common.callbacks->userdata, status); \
  |  |   61|    166|    } while (0)
  |  |  ------------------
  |  |  |  Branch (61:14): [Folded, False: 166]
  |  |  ------------------
  ------------------
  492|    166|        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|    166|        if (dh_handshake(session) == SSH_ERROR) {
  ------------------
  |  |  316|    166|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  |  Branch (496:13): [True: 0, False: 166]
  ------------------
  497|      0|            goto error;
  498|      0|        }
  499|    166|        FALL_THROUGH;
  ------------------
  |  |  496|    166|#  define FALL_THROUGH __attribute__ ((fallthrough))
  ------------------
  500|    166|    case SSH_SESSION_STATE_DH:
  ------------------
  |  Branch (500:5): [True: 0, False: 1.29k]
  ------------------
  501|    166|        if (session->dh_handshake_state == DH_STATE_FINISHED) {
  ------------------
  |  Branch (501:13): [True: 0, False: 166]
  ------------------
  502|      0|            set_status(session, 1.0f);
  ------------------
  |  |   58|      0|#define set_status(session, status) do {\
  |  |   59|      0|        if (session->common.callbacks && session->common.callbacks->connect_status_function) \
  |  |  ------------------
  |  |  |  Branch (59:13): [True: 0, False: 0]
  |  |  |  Branch (59:42): [True: 0, False: 0]
  |  |  ------------------
  |  |   60|      0|            session->common.callbacks->connect_status_function(session->common.callbacks->userdata, status); \
  |  |   61|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (61:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  503|      0|            session->connected = 1;
  504|      0|            if (session->flags & SSH_SESSION_FLAG_AUTHENTICATED) {
  ------------------
  |  |   78|      0|#define SSH_SESSION_FLAG_AUTHENTICATED 0x0002
  ------------------
  |  Branch (504:17): [True: 0, False: 0]
  ------------------
  505|      0|                session->session_state = SSH_SESSION_STATE_AUTHENTICATED;
  506|      0|            } else {
  507|      0|                session->session_state = SSH_SESSION_STATE_AUTHENTICATING;
  508|      0|            }
  509|      0|        }
  510|    166|        break;
  511|      0|    case SSH_SESSION_STATE_AUTHENTICATING:
  ------------------
  |  Branch (511:5): [True: 0, False: 1.29k]
  ------------------
  512|      0|        break;
  513|    153|    case SSH_SESSION_STATE_ERROR:
  ------------------
  |  Branch (513:5): [True: 153, False: 1.13k]
  ------------------
  514|    153|        goto error;
  515|      0|    default:
  ------------------
  |  Branch (515:5): [True: 0, False: 1.29k]
  ------------------
  516|      0|        ssh_set_error(session, SSH_FATAL, "Invalid state %d",
  ------------------
  |  |  313|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  517|  1.29k|                      session->session_state);
  518|  1.29k|    }
  519|       |
  520|  1.05k|    return;
  521|  1.05k|error:
  522|    241|    ssh_session_socket_close(session);
  523|    241|    SSH_LOG(SSH_LOG_WARN, "%s", ssh_get_error(session));
  ------------------
  |  |  283|    241|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  524|    241|}
client.c:socket_callback_connected:
   72|    473|{
   73|    473|	ssh_session session=(ssh_session)user;
   74|       |
   75|    473|	if (session->session_state != SSH_SESSION_STATE_CONNECTING &&
  ------------------
  |  Branch (75:6): [True: 473, False: 0]
  ------------------
   76|    473|	    session->session_state != SSH_SESSION_STATE_SOCKET_CONNECTED)
  ------------------
  |  Branch (76:6): [True: 0, False: 473]
  ------------------
   77|      0|	{
   78|      0|		ssh_set_error(session,SSH_FATAL, "Wrong state in socket_callback_connected : %d",
  ------------------
  |  |  313|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
   79|      0|				session->session_state);
   80|       |
   81|      0|		return;
   82|      0|	}
   83|       |
   84|    473|	SSH_LOG(SSH_LOG_TRACE,"Socket connection callback: %d (%d)",code, errno_code);
  ------------------
  |  |  283|    473|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
   85|    473|	if(code == SSH_SOCKET_CONNECTED_OK)
  ------------------
  |  |  524|    473|#define SSH_SOCKET_CONNECTED_OK 			1
  ------------------
  |  Branch (85:5): [True: 473, False: 0]
  ------------------
   86|    473|		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",
  ------------------
  |  |  313|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
   91|      0|                      ssh_strerror(errno_code, err_msg, SSH_ERRNO_MSG_MAX));
   92|      0|	}
   93|    473|	session->ssh_connection_callback(session);
   94|    473|}
client.c:callback_receive_banner:
  108|   196k|{
  109|   196k|    char *buffer = (char *)data;
  110|   196k|    ssh_session session = (ssh_session) user;
  111|   196k|    char *str = NULL;
  112|   196k|    uint32_t i;
  113|   196k|    int ret=0;
  114|       |
  115|   196k|    if (session->session_state != SSH_SESSION_STATE_SOCKET_CONNECTED) {
  ------------------
  |  Branch (115:9): [True: 10, False: 196k]
  ------------------
  116|     10|        ssh_set_error(session,SSH_FATAL,
  ------------------
  |  |  313|     10|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  117|     10|                      "Wrong state in callback_receive_banner : %d",
  118|     10|                      session->session_state);
  119|       |
  120|     10|        return 0;
  121|     10|    }
  122|   840k|    for (i = 0; i < len; ++i) {
  ------------------
  |  Branch (122:17): [True: 840k, False: 231]
  ------------------
  123|   840k|#ifdef WITH_PCAP
  124|   840k|        if (session->pcap_ctx && buffer[i] == '\n') {
  ------------------
  |  Branch (124:13): [True: 0, False: 840k]
  |  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|   840k|#endif
  131|   840k|        if (buffer[i] == '\r') {
  ------------------
  |  Branch (131:13): [True: 765, False: 839k]
  ------------------
  132|    765|            buffer[i] = '\0';
  133|    765|        }
  134|   840k|        if (buffer[i] == '\n') {
  ------------------
  |  Branch (134:13): [True: 196k, False: 643k]
  ------------------
  135|   196k|            int cmp;
  136|       |
  137|   196k|            buffer[i] = '\0';
  138|       |
  139|       |            /* The server MAY send other lines of data... */
  140|   196k|            cmp = strncmp(buffer, "SSH-", 4);
  141|   196k|            if (cmp == 0) {
  ------------------
  |  Branch (141:17): [True: 422, False: 196k]
  ------------------
  142|    422|                str = strdup(buffer);
  143|    422|                if (str == NULL) {
  ------------------
  |  Branch (143:21): [True: 0, False: 422]
  ------------------
  144|      0|                    return SSH_ERROR;
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  145|      0|                }
  146|       |                /* number of bytes read */
  147|    422|                ret = i + 1;
  148|    422|                session->serverbanner = str;
  149|    422|                session->session_state = SSH_SESSION_STATE_BANNER_RECEIVED;
  150|    422|                SSH_LOG(SSH_LOG_PACKET, "Received banner: %s", str);
  ------------------
  |  |  283|    422|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  151|    422|                session->ssh_connection_callback(session);
  152|       |
  153|    422|                return ret;
  154|   196k|            } else {
  155|   196k|                SSH_LOG(SSH_LOG_DEBUG,
  ------------------
  |  |  283|   196k|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  156|   196k|                        "ssh_protocol_version_exchange: %s",
  157|   196k|                        buffer);
  158|   196k|                ret = i + 1;
  159|   196k|                break;
  160|   196k|            }
  161|   196k|        }
  162|       |        /* According to RFC 4253 the max banner length is 255 */
  163|   643k|        if (i > 255) {
  ------------------
  |  Branch (163:13): [True: 1, False: 643k]
  ------------------
  164|       |            /* Too big banner */
  165|      1|            session->session_state=SSH_SESSION_STATE_ERROR;
  166|      1|            ssh_set_error(session,
  ------------------
  |  |  313|      1|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  167|      1|                          SSH_FATAL,
  168|      1|                          "Receiving banner: too large banner");
  169|       |
  170|      1|            return 0;
  171|      1|        }
  172|   643k|    }
  173|       |
  174|   196k|    return ret;
  175|   196k|}
client.c:ssh_connect_termination:
  530|  2.17k|{
  531|  2.17k|    ssh_session session = (ssh_session)user;
  532|       |
  533|  2.17k|    switch (session->session_state) {
  534|    320|    case SSH_SESSION_STATE_ERROR:
  ------------------
  |  Branch (534:5): [True: 320, False: 1.85k]
  ------------------
  535|    320|    case SSH_SESSION_STATE_AUTHENTICATING:
  ------------------
  |  Branch (535:5): [True: 0, False: 2.17k]
  ------------------
  536|    320|    case SSH_SESSION_STATE_DISCONNECTED:
  ------------------
  |  Branch (536:5): [True: 0, False: 2.17k]
  ------------------
  537|    320|        return 1;
  538|  1.85k|    default:
  ------------------
  |  Branch (538:5): [True: 1.85k, False: 320]
  ------------------
  539|  1.85k|        return 0;
  540|  2.17k|    }
  541|  2.17k|}

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

ssh_curve25519_create_k:
   52|      9|{
   53|      9|    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|      9|    rc = curve25519_do_create_k(session, k);
   65|      9|    return rc;
   66|      9|}
ssh_client_curve25519_init:
   72|     17|{
   73|     17|    int rc;
   74|       |
   75|     17|    rc = ssh_curve25519_init(session);
   76|     17|    if (rc != SSH_OK) {
  ------------------
  |  |  315|     17|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (76:9): [True: 0, False: 17]
  ------------------
   77|      0|        return rc;
   78|      0|    }
   79|       |
   80|     17|    rc = ssh_buffer_pack(session->out_buffer,
  ------------------
  |  |   50|     17|    _ssh_buffer_pack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |  453|     17|        (__VA_NARG_(__VA_ARGS__, __RSEQ_N()))
  |  |  |  |  ------------------
  |  |  |  |  |  |  455|     17|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  450|     17|#define VA_APPLY_VARIADIC_MACRO(macro, tuple) macro tuple
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  455|     17|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  463|     17|        _61,_62,_63,N,...) N
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                   _ssh_buffer_pack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |   28|     17|#define SSH_BUFFER_PACK_END ((uint32_t) 0x4f65feb3)
  |  |  ------------------
  ------------------
   81|     17|                         "bdP",
   82|     17|                         SSH2_MSG_KEX_ECDH_INIT,
   83|     17|                         CURVE25519_PUBKEY_SIZE,
   84|     17|                         (size_t)CURVE25519_PUBKEY_SIZE,
   85|     17|                         session->next_crypto->curve25519_client_pubkey);
   86|     17|    if (rc != SSH_OK) {
  ------------------
  |  |  315|     17|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (86:9): [True: 0, False: 17]
  ------------------
   87|      0|        ssh_set_error_oom(session);
  ------------------
  |  |  320|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
   88|      0|        return SSH_ERROR;
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
   89|      0|    }
   90|       |
   91|       |    /* register the packet callbacks */
   92|     17|    ssh_packet_set_callbacks(session, &ssh_curve25519_client_callbacks);
   93|     17|    session->dh_handshake_state = DH_STATE_INIT_SENT;
   94|     17|    rc = ssh_packet_send(session);
   95|       |
   96|     17|    return rc;
   97|     17|}
ssh_client_curve25519_remove_callbacks:
  100|     15|{
  101|     15|    ssh_packet_remove_callbacks(session, &ssh_curve25519_client_callbacks);
  102|     15|}
ssh_curve25519_build_k:
  105|      9|{
  106|      9|    ssh_curve25519_secret k;
  107|      9|    int rc;
  108|       |
  109|      9|    rc = ssh_curve25519_create_k(session, k);
  110|      9|    if (rc != SSH_OK) {
  ------------------
  |  |  315|      9|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (110:9): [True: 0, False: 9]
  ------------------
  111|      0|        return rc;
  112|      0|    }
  113|       |
  114|      9|    bignum_bin2bn(k,
  ------------------
  |  |   79|      9|    do {                                     \
  |  |   80|      9|        (*dest) = BN_new();                  \
  |  |   81|      9|        if ((*dest) != NULL) {               \
  |  |  ------------------
  |  |  |  Branch (81:13): [True: 9, False: 0]
  |  |  ------------------
  |  |   82|      9|            BN_bin2bn(data,datalen,(*dest)); \
  |  |   83|      9|        }                                    \
  |  |   84|      9|    } while(0)
  |  |  ------------------
  |  |  |  Branch (84:13): [Folded, False: 9]
  |  |  ------------------
  ------------------
  115|      9|                  CURVE25519_SECRET_SIZE,
  116|      9|                  &session->next_crypto->shared_secret);
  117|      9|    ssh_burn(k, sizeof(ssh_curve25519_secret));
  ------------------
  |  |  390|      9|#define ssh_burn(ptr, len) explicit_bzero((ptr), (len))
  ------------------
  118|      9|    if (session->next_crypto->shared_secret == NULL) {
  ------------------
  |  Branch (118:9): [True: 0, False: 9]
  ------------------
  119|      0|        return SSH_ERROR;
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  120|      0|    }
  121|       |
  122|       |#ifdef DEBUG_CRYPTO
  123|       |    ssh_print_bignum("Shared secret key", session->next_crypto->shared_secret);
  124|       |#endif
  125|       |
  126|      9|    return SSH_OK;
  ------------------
  |  |  315|      9|#define SSH_OK 0     /* No error */
  ------------------
  127|      9|}
curve25519.c:ssh_packet_client_curve25519_reply:
  134|     15|{
  135|     15|    ssh_string q_s_string = NULL;
  136|     15|    ssh_string pubkey_blob = NULL;
  137|     15|    ssh_string signature = NULL;
  138|     15|    int rc;
  139|     15|    (void)type;
  140|     15|    (void)user;
  141|       |
  142|     15|    ssh_client_curve25519_remove_callbacks(session);
  143|       |
  144|     15|    pubkey_blob = ssh_buffer_get_ssh_string(packet);
  145|     15|    if (pubkey_blob == NULL) {
  ------------------
  |  Branch (145:9): [True: 0, False: 15]
  ------------------
  146|      0|        ssh_set_error(session, SSH_FATAL, "No public key in packet");
  ------------------
  |  |  313|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  147|      0|        goto error;
  148|      0|    }
  149|       |
  150|     15|    rc = ssh_dh_import_next_pubkey_blob(session, pubkey_blob);
  151|     15|    SSH_STRING_FREE(pubkey_blob);
  ------------------
  |  |  882|     15|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (882:14): [True: 15, False: 0]
  |  |  |  Branch (882:69): [Folded, False: 15]
  |  |  ------------------
  ------------------
  152|     15|    if (rc != 0) {
  ------------------
  |  Branch (152:9): [True: 4, False: 11]
  ------------------
  153|      4|        ssh_set_error(session, SSH_FATAL, "Failed to import next public key");
  ------------------
  |  |  313|      4|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  154|      4|        goto error;
  155|      4|    }
  156|       |
  157|     11|    q_s_string = ssh_buffer_get_ssh_string(packet);
  158|     11|    if (q_s_string == NULL) {
  ------------------
  |  Branch (158:9): [True: 0, False: 11]
  ------------------
  159|      0|        ssh_set_error(session, SSH_FATAL, "No Q_S ECC point in packet");
  ------------------
  |  |  313|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  160|      0|        goto error;
  161|      0|    }
  162|     11|    if (ssh_string_len(q_s_string) != CURVE25519_PUBKEY_SIZE) {
  ------------------
  |  |   41|     11|#define CURVE25519_PUBKEY_SIZE 32
  ------------------
  |  Branch (162:9): [True: 2, False: 9]
  ------------------
  163|      2|        ssh_set_error(session,
  ------------------
  |  |  313|      2|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  164|      2|                      SSH_FATAL,
  165|      2|                      "Incorrect size for server Curve25519 public key: %zu",
  166|      2|                      ssh_string_len(q_s_string));
  167|      2|        SSH_STRING_FREE(q_s_string);
  ------------------
  |  |  882|      2|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (882:14): [True: 2, False: 0]
  |  |  |  Branch (882:69): [Folded, False: 2]
  |  |  ------------------
  ------------------
  168|      2|        goto error;
  169|      2|    }
  170|      9|    memcpy(session->next_crypto->curve25519_server_pubkey,
  171|      9|           ssh_string_data(q_s_string),
  172|      9|           CURVE25519_PUBKEY_SIZE);
  ------------------
  |  |   41|      9|#define CURVE25519_PUBKEY_SIZE 32
  ------------------
  173|      9|    SSH_STRING_FREE(q_s_string);
  ------------------
  |  |  882|      9|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (882:14): [True: 9, False: 0]
  |  |  |  Branch (882:69): [Folded, False: 9]
  |  |  ------------------
  ------------------
  174|       |
  175|      9|    signature = ssh_buffer_get_ssh_string(packet);
  176|      9|    if (signature == NULL) {
  ------------------
  |  Branch (176:9): [True: 0, False: 9]
  ------------------
  177|      0|        ssh_set_error(session, SSH_FATAL, "No signature in packet");
  ------------------
  |  |  313|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  178|      0|        goto error;
  179|      0|    }
  180|      9|    session->next_crypto->dh_server_signature = signature;
  181|      9|    signature = NULL; /* ownership changed */
  182|       |    /* TODO: verify signature now instead of waiting for NEWKEYS */
  183|      9|    if (ssh_curve25519_build_k(session) < 0) {
  ------------------
  |  Branch (183:9): [True: 0, False: 9]
  ------------------
  184|      0|        ssh_set_error(session, SSH_FATAL, "Cannot build k number");
  ------------------
  |  |  313|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  185|      0|        goto error;
  186|      0|    }
  187|       |
  188|       |    /* Send the MSG_NEWKEYS */
  189|      9|    rc = ssh_packet_send_newkeys(session);
  190|      9|    if (rc == SSH_ERROR) {
  ------------------
  |  |  316|      9|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  |  Branch (190:9): [True: 0, False: 9]
  ------------------
  191|      0|        goto error;
  192|      0|    }
  193|      9|    session->dh_handshake_state = DH_STATE_NEWKEYS_SENT;
  194|       |
  195|      9|    return SSH_PACKET_USED;
  ------------------
  |  |  638|      9|#define SSH_PACKET_USED 1
  ------------------
  196|       |
  197|      6|error:
  198|      6|    session->session_state = SSH_SESSION_STATE_ERROR;
  199|      6|    return SSH_PACKET_USED;
  ------------------
  |  |  638|      6|#define SSH_PACKET_USED 1
  ------------------
  200|      9|}

ssh_curve25519_init:
   34|     83|{
   35|     83|    ssh_curve25519_pubkey *pubkey_loc = NULL;
   36|     83|    EVP_PKEY_CTX *pctx = NULL;
   37|     83|    EVP_PKEY *pkey = NULL;
   38|     83|    size_t pubkey_len = CURVE25519_PUBKEY_SIZE;
  ------------------
  |  |   41|     83|#define CURVE25519_PUBKEY_SIZE 32
  ------------------
   39|     83|    int rc;
   40|       |
   41|     83|    if (session->server) {
  ------------------
  |  Branch (41:9): [True: 0, False: 83]
  ------------------
   42|      0|        pubkey_loc = &session->next_crypto->curve25519_server_pubkey;
   43|     83|    } else {
   44|     83|        pubkey_loc = &session->next_crypto->curve25519_client_pubkey;
   45|     83|    }
   46|       |
   47|     83|    pctx = EVP_PKEY_CTX_new_id(EVP_PKEY_X25519, NULL);
   48|     83|    if (pctx == NULL) {
  ------------------
  |  Branch (48:9): [True: 0, False: 83]
  ------------------
   49|      0|        SSH_LOG(SSH_LOG_TRACE,
  ------------------
  |  |  283|      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;
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
   53|      0|    }
   54|       |
   55|     83|    rc = EVP_PKEY_keygen_init(pctx);
   56|     83|    if (rc != 1) {
  ------------------
  |  Branch (56:9): [True: 0, False: 83]
  ------------------
   57|      0|        SSH_LOG(SSH_LOG_TRACE,
  ------------------
  |  |  283|      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;
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
   62|      0|    }
   63|       |
   64|     83|    rc = EVP_PKEY_keygen(pctx, &pkey);
   65|     83|    EVP_PKEY_CTX_free(pctx);
   66|     83|    if (rc != 1) {
  ------------------
  |  Branch (66:9): [True: 0, False: 83]
  ------------------
   67|      0|        SSH_LOG(SSH_LOG_TRACE,
  ------------------
  |  |  283|      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;
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
   71|      0|    }
   72|       |
   73|     83|    rc = EVP_PKEY_get_raw_public_key(pkey, *pubkey_loc, &pubkey_len);
   74|     83|    if (rc != 1) {
  ------------------
  |  Branch (74:9): [True: 0, False: 83]
  ------------------
   75|      0|        SSH_LOG(SSH_LOG_TRACE,
  ------------------
  |  |  283|      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;
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
   80|      0|    }
   81|       |
   82|       |    /* Free any previously allocated privkey */
   83|     83|    if (session->next_crypto->curve25519_privkey != NULL) {
  ------------------
  |  Branch (83:9): [True: 0, False: 83]
  ------------------
   84|      0|        EVP_PKEY_free(session->next_crypto->curve25519_privkey);
   85|      0|        session->next_crypto->curve25519_privkey = NULL;
   86|      0|    }
   87|       |
   88|     83|    session->next_crypto->curve25519_privkey = pkey;
   89|     83|    pkey = NULL;
   90|       |
   91|     83|    return SSH_OK;
  ------------------
  |  |  315|     83|#define SSH_OK 0     /* No error */
  ------------------
   92|     83|}
curve25519_do_create_k:
   95|      9|{
   96|      9|    ssh_curve25519_pubkey *peer_pubkey_loc = NULL;
   97|      9|    int rc, ret = SSH_ERROR;
  ------------------
  |  |  316|      9|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
   98|      9|    EVP_PKEY_CTX *pctx = NULL;
   99|      9|    EVP_PKEY *pkey = NULL, *pubkey = NULL;
  100|      9|    size_t shared_key_len = CURVE25519_SECRET_SIZE;
  ------------------
  |  |   43|      9|#define CURVE25519_SECRET_SIZE  32
  ------------------
  101|       |
  102|      9|    if (session->server) {
  ------------------
  |  Branch (102:9): [True: 0, False: 9]
  ------------------
  103|      0|        peer_pubkey_loc = &session->next_crypto->curve25519_client_pubkey;
  104|      9|    } else {
  105|      9|        peer_pubkey_loc = &session->next_crypto->curve25519_server_pubkey;
  106|      9|    }
  107|       |
  108|      9|    pkey = session->next_crypto->curve25519_privkey;
  109|      9|    if (pkey == NULL) {
  ------------------
  |  Branch (109:9): [True: 0, False: 9]
  ------------------
  110|      0|        SSH_LOG(SSH_LOG_TRACE,
  ------------------
  |  |  283|      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;
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  114|      0|    }
  115|       |
  116|      9|    pctx = EVP_PKEY_CTX_new(pkey, NULL);
  117|      9|    if (pctx == NULL) {
  ------------------
  |  Branch (117:9): [True: 0, False: 9]
  ------------------
  118|      0|        SSH_LOG(SSH_LOG_TRACE,
  ------------------
  |  |  283|      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|      9|    rc = EVP_PKEY_derive_init(pctx);
  125|      9|    if (rc != 1) {
  ------------------
  |  Branch (125:9): [True: 0, False: 9]
  ------------------
  126|      0|        SSH_LOG(SSH_LOG_TRACE,
  ------------------
  |  |  283|      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|      9|    pubkey = EVP_PKEY_new_raw_public_key(EVP_PKEY_X25519,
  133|      9|                                         NULL,
  134|      9|                                         *peer_pubkey_loc,
  135|      9|                                         CURVE25519_PUBKEY_SIZE);
  ------------------
  |  |   41|      9|#define CURVE25519_PUBKEY_SIZE 32
  ------------------
  136|      9|    if (pubkey == NULL) {
  ------------------
  |  Branch (136:9): [True: 0, False: 9]
  ------------------
  137|      0|        SSH_LOG(SSH_LOG_TRACE,
  ------------------
  |  |  283|      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|      9|    rc = EVP_PKEY_derive_set_peer(pctx, pubkey);
  144|      9|    if (rc != 1) {
  ------------------
  |  Branch (144:9): [True: 0, False: 9]
  ------------------
  145|      0|        SSH_LOG(SSH_LOG_TRACE,
  ------------------
  |  |  283|      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|      9|    rc = EVP_PKEY_derive(pctx, k, &shared_key_len);
  152|      9|    if (rc != 1) {
  ------------------
  |  Branch (152:9): [True: 0, False: 9]
  ------------------
  153|      0|        SSH_LOG(SSH_LOG_TRACE,
  ------------------
  |  |  283|      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|      9|    ret = SSH_OK;
  ------------------
  |  |  315|      9|#define SSH_OK 0     /* No error */
  ------------------
  159|       |
  160|      9|out:
  161|      9|    EVP_PKEY_free(pubkey);
  162|      9|    EVP_PKEY_CTX_free(pctx);
  163|      9|    return ret;
  164|      9|}

ssh_client_dhgex_init:
   65|      3|{
   66|      3|    int rc;
   67|       |
   68|      3|    rc = ssh_dh_init_common(session->next_crypto);
   69|      3|    if (rc != SSH_OK){
  ------------------
  |  |  315|      3|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (69:9): [True: 0, False: 3]
  ------------------
   70|      0|        goto error;
   71|      0|    }
   72|       |
   73|      3|    session->next_crypto->dh_pmin = DH_PMIN;
  ------------------
  |  |   41|      3|#define DH_PMIN 2048
  ------------------
   74|      3|    session->next_crypto->dh_pn = DH_PREQ;
  ------------------
  |  |   42|      3|#define DH_PREQ 2048
  ------------------
   75|      3|    session->next_crypto->dh_pmax = DH_PMAX;
  ------------------
  |  |   43|      3|#define DH_PMAX 8192
  ------------------
   76|       |    /* Minimum group size, preferred group size, maximum group size */
   77|      3|    rc = ssh_buffer_pack(session->out_buffer,
  ------------------
  |  |   50|      3|    _ssh_buffer_pack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |  453|      3|        (__VA_NARG_(__VA_ARGS__, __RSEQ_N()))
  |  |  |  |  ------------------
  |  |  |  |  |  |  455|      3|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  450|      3|#define VA_APPLY_VARIADIC_MACRO(macro, tuple) macro tuple
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  455|      3|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  463|      3|        _61,_62,_63,N,...) N
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                   _ssh_buffer_pack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |   28|      3|#define SSH_BUFFER_PACK_END ((uint32_t) 0x4f65feb3)
  |  |  ------------------
  ------------------
   78|      3|                         "bddd",
   79|      3|                         SSH2_MSG_KEX_DH_GEX_REQUEST,
   80|      3|                         session->next_crypto->dh_pmin,
   81|      3|                         session->next_crypto->dh_pn,
   82|      3|                         session->next_crypto->dh_pmax);
   83|      3|    if (rc != SSH_OK) {
  ------------------
  |  |  315|      3|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (83:9): [True: 0, False: 3]
  ------------------
   84|      0|        goto error;
   85|      0|    }
   86|       |
   87|       |    /* register the packet callbacks */
   88|      3|    ssh_packet_set_callbacks(session, &ssh_dhgex_client_callbacks);
   89|      3|    session->dh_handshake_state = DH_STATE_REQUEST_SENT;
   90|      3|    rc = ssh_packet_send(session);
   91|      3|    if (rc == SSH_ERROR) {
  ------------------
  |  |  316|      3|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  |  Branch (91:9): [True: 0, False: 3]
  ------------------
   92|      0|        goto error;
   93|      0|    }
   94|      3|    return rc;
   95|      0|error:
   96|      0|    ssh_dh_cleanup(session->next_crypto);
   97|      0|    return SSH_ERROR;
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
   98|      3|}
dh-gex.c:ssh_packet_client_dhgex_group:
  105|      3|{
  106|      3|    int rc;
  107|      3|    int blen;
  108|      3|    bignum pmin1 = NULL, one = NULL;
  109|      3|    bignum modulus = NULL, generator = NULL;
  110|      3|#if !defined(HAVE_LIBCRYPTO) || OPENSSL_VERSION_NUMBER < 0x30000000L
  111|      3|    const_bignum pubkey;
  112|       |#else
  113|       |    bignum pubkey = NULL;
  114|       |#endif /* OPENSSL_VERSION_NUMBER */
  115|      3|    (void) type;
  116|      3|    (void) user;
  117|       |
  118|      3|    SSH_LOG(SSH_LOG_DEBUG, "SSH_MSG_KEX_DH_GEX_GROUP received");
  ------------------
  |  |  283|      3|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  119|       |
  120|      3|    if (session->dh_handshake_state != DH_STATE_REQUEST_SENT) {
  ------------------
  |  Branch (120:9): [True: 0, False: 3]
  ------------------
  121|      0|        ssh_set_error(session,
  ------------------
  |  |  313|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  122|      0|                      SSH_FATAL,
  123|      0|                      "Received DH_GEX_GROUP in invalid state");
  124|      0|        goto error;
  125|      0|    }
  126|      3|    one = bignum_new();
  ------------------
  |  |   70|      3|#define bignum_new() BN_new()
  ------------------
  127|      3|    pmin1 = bignum_new();
  ------------------
  |  |   70|      3|#define bignum_new() BN_new()
  ------------------
  128|      3|    if (one == NULL || pmin1 == NULL) {
  ------------------
  |  Branch (128:9): [True: 0, False: 3]
  |  Branch (128:24): [True: 0, False: 3]
  ------------------
  129|      0|        ssh_set_error_oom(session);
  ------------------
  |  |  320|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
  130|      0|        goto error;
  131|      0|    }
  132|      3|    rc = ssh_buffer_unpack(packet,
  ------------------
  |  |   60|      3|    _ssh_buffer_unpack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |  453|      3|        (__VA_NARG_(__VA_ARGS__, __RSEQ_N()))
  |  |  |  |  ------------------
  |  |  |  |  |  |  455|      3|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  450|      3|#define VA_APPLY_VARIADIC_MACRO(macro, tuple) macro tuple
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  455|      3|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  463|      3|        _61,_62,_63,N,...) N
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                   _ssh_buffer_unpack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |   28|      3|#define SSH_BUFFER_PACK_END ((uint32_t) 0x4f65feb3)
  |  |  ------------------
  ------------------
  133|      3|                           "BB",
  134|      3|                           &modulus,
  135|      3|                           &generator);
  136|      3|    if (rc != SSH_OK) {
  ------------------
  |  |  315|      3|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (136:9): [True: 1, False: 2]
  ------------------
  137|      1|        ssh_set_error(session, SSH_FATAL, "Invalid DH_GEX_GROUP packet");
  ------------------
  |  |  313|      1|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  138|      1|        goto error;
  139|      1|    }
  140|       |    /* basic checks */
  141|      2|    if (ssh_fips_mode() &&
  ------------------
  |  |  115|      4|#define ssh_fips_mode() (FIPS_mode() != 0)
  |  |  ------------------
  |  |  |  Branch (115:25): [True: 0, False: 2]
  |  |  ------------------
  ------------------
  142|      0|        !ssh_dh_is_known_group(modulus, generator)) {
  ------------------
  |  Branch (142:9): [True: 0, False: 0]
  ------------------
  143|      0|        ssh_set_error(session,
  ------------------
  |  |  313|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  144|      0|                      SSH_FATAL,
  145|      0|                      "The received DH group is not FIPS approved");
  146|      0|        goto error;
  147|      0|    }
  148|      2|    rc = bignum_set_word(one, 1);
  ------------------
  |  |   77|      2|#define bignum_set_word(bn,n) BN_set_word(bn,n)
  ------------------
  149|      2|    if (rc != 1) {
  ------------------
  |  Branch (149:9): [True: 0, False: 2]
  ------------------
  150|      0|        goto error;
  151|      0|    }
  152|      2|    blen = bignum_num_bits(modulus);
  ------------------
  |  |   99|      2|#define bignum_num_bits(num) (size_t)BN_num_bits(num)
  ------------------
  153|      2|    if (blen < DH_PMIN || blen > DH_PMAX) {
  ------------------
  |  |   41|      4|#define DH_PMIN 2048
  ------------------
                  if (blen < DH_PMIN || blen > DH_PMAX) {
  ------------------
  |  |   43|      2|#define DH_PMAX 8192
  ------------------
  |  Branch (153:9): [True: 0, False: 2]
  |  Branch (153:27): [True: 0, False: 2]
  ------------------
  154|      0|        ssh_set_error(session,
  ------------------
  |  |  313|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  155|      0|                SSH_FATAL,
  156|      0|                "Invalid dh group parameter p: %d not in [%d:%d]",
  157|      0|                blen,
  158|      0|                DH_PMIN,
  159|      0|                DH_PMAX);
  160|      0|        goto error;
  161|      0|    }
  162|      2|    if (bignum_cmp(modulus, one) <= 0) {
  ------------------
  |  |  102|      2|#define bignum_cmp(num1,num2) BN_cmp(num1,num2)
  ------------------
  |  Branch (162:9): [True: 0, False: 2]
  ------------------
  163|       |        /* p must be positive and preferably bigger than one */
  164|      0|        ssh_set_error(session, SSH_FATAL, "Invalid dh group parameter p");
  ------------------
  |  |  313|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  165|      0|        goto error;
  166|      0|    }
  167|      2|    if (!bignum_is_bit_set(modulus, 0)) {
  ------------------
  |  |  100|      2|#define bignum_is_bit_set(num,bit) BN_is_bit_set(num, (int)bit)
  ------------------
  |  Branch (167:9): [True: 1, False: 1]
  ------------------
  168|       |        /* p must be a prime and therefore not divisible by 2 */
  169|      1|        ssh_set_error(session, SSH_FATAL, "Invalid dh group parameter p");
  ------------------
  |  |  313|      1|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  170|      1|        goto error;
  171|      1|    }
  172|      1|    bignum_sub(pmin1, modulus, one);
  ------------------
  |  |   96|      1|#define bignum_sub(dest, a, b) BN_sub(dest, a, b)
  ------------------
  173|      1|    if (bignum_cmp(generator, one) <= 0 ||
  ------------------
  |  |  102|      1|#define bignum_cmp(num1,num2) BN_cmp(num1,num2)
  ------------------
  |  Branch (173:9): [True: 1, False: 0]
  ------------------
  174|      1|        bignum_cmp(generator, pmin1) > 0) {
  ------------------
  |  |  102|      0|#define bignum_cmp(num1,num2) BN_cmp(num1,num2)
  ------------------
  |  Branch (174:9): [True: 0, False: 0]
  ------------------
  175|       |        /* generator must be at least 2 and smaller than p-1*/
  176|      1|        ssh_set_error(session, SSH_FATAL, "Invalid dh group parameter g");
  ------------------
  |  |  313|      1|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  177|      1|        goto error;
  178|      1|    }
  179|       |
  180|       |    /* all checks passed, set parameters (the BNs are copied in openssl backend) */
  181|      0|    rc = ssh_dh_set_parameters(session->next_crypto->dh_ctx,
  182|      0|                               modulus, generator);
  183|      0|    if (rc != SSH_OK) {
  ------------------
  |  |  315|      0|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (183:9): [True: 0, False: 0]
  ------------------
  184|      0|        goto error;
  185|      0|    }
  186|      0|#ifdef HAVE_LIBCRYPTO
  187|      0|    bignum_safe_free(modulus);
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
  188|      0|    bignum_safe_free(generator);
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
  189|      0|#endif
  190|      0|    modulus = NULL;
  191|      0|    generator = NULL;
  192|       |
  193|       |    /* compute and send DH public parameter */
  194|      0|    rc = ssh_dh_keypair_gen_keys(session->next_crypto->dh_ctx,
  195|      0|                                 DH_CLIENT_KEYPAIR);
  ------------------
  |  |   30|      0|#define DH_CLIENT_KEYPAIR 0
  ------------------
  196|      0|    if (rc == SSH_ERROR) {
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  |  Branch (196:9): [True: 0, False: 0]
  ------------------
  197|      0|        goto error;
  198|      0|    }
  199|       |
  200|      0|    rc = ssh_dh_keypair_get_keys(session->next_crypto->dh_ctx,
  201|      0|                                 DH_CLIENT_KEYPAIR, NULL, &pubkey);
  ------------------
  |  |   30|      0|#define DH_CLIENT_KEYPAIR 0
  ------------------
  202|      0|    if (rc != SSH_OK) {
  ------------------
  |  |  315|      0|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (202:9): [True: 0, False: 0]
  ------------------
  203|      0|        goto error;
  204|      0|    }
  205|       |
  206|      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)
  |  |  ------------------
  |  |  |  |  453|      0|        (__VA_NARG_(__VA_ARGS__, __RSEQ_N()))
  |  |  |  |  ------------------
  |  |  |  |  |  |  455|      0|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  450|      0|#define VA_APPLY_VARIADIC_MACRO(macro, tuple) macro tuple
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  455|      0|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  463|      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)
  |  |  ------------------
  ------------------
  207|      0|                         "bB",
  208|      0|                         SSH2_MSG_KEX_DH_GEX_INIT,
  209|      0|                         pubkey);
  210|      0|    if (rc != SSH_OK) {
  ------------------
  |  |  315|      0|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (210:9): [True: 0, False: 0]
  ------------------
  211|      0|        goto error;
  212|      0|    }
  213|       |#if defined(HAVE_LIBCRYPTO) && OPENSSL_VERSION_NUMBER >= 0x30000000L
  214|       |    bignum_safe_free(pubkey);
  215|       |#endif /* OPENSSL_VERSION_NUMBER */
  216|       |
  217|      0|    session->dh_handshake_state = DH_STATE_INIT_SENT;
  218|       |
  219|      0|    rc = ssh_packet_send(session);
  220|      0|    if (rc == SSH_ERROR) {
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  |  Branch (220:9): [True: 0, False: 0]
  ------------------
  221|      0|        goto error;
  222|      0|    }
  223|       |
  224|      0|    bignum_safe_free(one);
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
  225|      0|    bignum_safe_free(pmin1);
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
  226|      0|    return SSH_PACKET_USED;
  ------------------
  |  |  638|      0|#define SSH_PACKET_USED 1
  ------------------
  227|       |
  228|      3|error:
  229|      3|    bignum_safe_free(modulus);
  ------------------
  |  |   71|      3|#define bignum_safe_free(num) do { \
  |  |   72|      3|    if ((num) != NULL) { \
  |  |  ------------------
  |  |  |  Branch (72:9): [True: 2, False: 1]
  |  |  ------------------
  |  |   73|      2|        BN_clear_free((num)); \
  |  |   74|      2|        (num)=NULL; \
  |  |   75|      2|    } \
  |  |   76|      3|    } while(0)
  |  |  ------------------
  |  |  |  Branch (76:13): [Folded, False: 3]
  |  |  ------------------
  ------------------
  230|      3|    bignum_safe_free(generator);
  ------------------
  |  |   71|      3|#define bignum_safe_free(num) do { \
  |  |   72|      3|    if ((num) != NULL) { \
  |  |  ------------------
  |  |  |  Branch (72:9): [True: 2, False: 1]
  |  |  ------------------
  |  |   73|      2|        BN_clear_free((num)); \
  |  |   74|      2|        (num)=NULL; \
  |  |   75|      2|    } \
  |  |   76|      3|    } while(0)
  |  |  ------------------
  |  |  |  Branch (76:13): [Folded, False: 3]
  |  |  ------------------
  ------------------
  231|      3|    bignum_safe_free(one);
  ------------------
  |  |   71|      3|#define bignum_safe_free(num) do { \
  |  |   72|      3|    if ((num) != NULL) { \
  |  |  ------------------
  |  |  |  Branch (72:9): [True: 3, False: 0]
  |  |  ------------------
  |  |   73|      3|        BN_clear_free((num)); \
  |  |   74|      3|        (num)=NULL; \
  |  |   75|      3|    } \
  |  |   76|      3|    } while(0)
  |  |  ------------------
  |  |  |  Branch (76:13): [Folded, False: 3]
  |  |  ------------------
  ------------------
  232|      3|    bignum_safe_free(pmin1);
  ------------------
  |  |   71|      3|#define bignum_safe_free(num) do { \
  |  |   72|      3|    if ((num) != NULL) { \
  |  |  ------------------
  |  |  |  Branch (72:9): [True: 3, False: 0]
  |  |  ------------------
  |  |   73|      3|        BN_clear_free((num)); \
  |  |   74|      3|        (num)=NULL; \
  |  |   75|      3|    } \
  |  |   76|      3|    } while(0)
  |  |  ------------------
  |  |  |  Branch (76:13): [Folded, False: 3]
  |  |  ------------------
  ------------------
  233|       |#if defined(HAVE_LIBCRYPTO) && OPENSSL_VERSION_NUMBER >= 0x30000000L
  234|       |    bignum_safe_free(pubkey);
  235|       |#endif /* OPENSSL_VERSION_NUMBER */
  236|      3|    ssh_dh_cleanup(session->next_crypto);
  237|      3|    session->session_state = SSH_SESSION_STATE_ERROR;
  238|       |
  239|      3|    return SSH_PACKET_USED;
  ------------------
  |  |  638|      3|#define SSH_PACKET_USED 1
  ------------------
  240|      0|}

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;
  ------------------
  |  |  315|      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;
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  273|      2|}
ssh_dh_import_next_pubkey_blob:
  295|    109|{
  296|    109|    return ssh_pki_import_pubkey_blob(pubkey_blob,
  297|    109|                                      &session->next_crypto->server_pubkey);
  298|       |
  299|    109|}
ssh_client_dh_init:
  317|     23|int ssh_client_dh_init(ssh_session session){
  318|     23|  struct ssh_crypto_struct *crypto = session->next_crypto;
  319|     23|#if !defined(HAVE_LIBCRYPTO) || OPENSSL_VERSION_NUMBER < 0x30000000L
  320|     23|  const_bignum pubkey;
  321|       |#else
  322|       |  bignum pubkey = NULL;
  323|       |#endif /* OPENSSL_VERSION_NUMBER */
  324|     23|  int rc;
  325|       |
  326|     23|  rc = ssh_dh_init_common(crypto);
  327|     23|  if (rc == SSH_ERROR) {
  ------------------
  |  |  316|     23|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  |  Branch (327:7): [True: 0, False: 23]
  ------------------
  328|      0|    goto error;
  329|      0|  }
  330|       |
  331|     23|  rc = ssh_dh_keypair_gen_keys(crypto->dh_ctx, DH_CLIENT_KEYPAIR);
  ------------------
  |  |   30|     23|#define DH_CLIENT_KEYPAIR 0
  ------------------
  332|     23|  if (rc == SSH_ERROR){
  ------------------
  |  |  316|     23|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  |  Branch (332:7): [True: 0, False: 23]
  ------------------
  333|      0|      goto error;
  334|      0|  }
  335|     23|  rc = ssh_dh_keypair_get_keys(crypto->dh_ctx, DH_CLIENT_KEYPAIR,
  ------------------
  |  |   30|     23|#define DH_CLIENT_KEYPAIR 0
  ------------------
  336|     23|                               NULL, &pubkey);
  337|     23|  if (rc != SSH_OK) {
  ------------------
  |  |  315|     23|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (337:7): [True: 0, False: 23]
  ------------------
  338|      0|    goto error;
  339|      0|  }
  340|     23|  rc = ssh_buffer_pack(session->out_buffer, "bB", SSH2_MSG_KEXDH_INIT, pubkey);
  ------------------
  |  |   50|     23|    _ssh_buffer_pack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |  453|     23|        (__VA_NARG_(__VA_ARGS__, __RSEQ_N()))
  |  |  |  |  ------------------
  |  |  |  |  |  |  455|     23|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  450|     23|#define VA_APPLY_VARIADIC_MACRO(macro, tuple) macro tuple
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  455|     23|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  463|     23|        _61,_62,_63,N,...) N
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                   _ssh_buffer_pack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |   28|     23|#define SSH_BUFFER_PACK_END ((uint32_t) 0x4f65feb3)
  |  |  ------------------
  ------------------
  341|     23|  if (rc != SSH_OK) {
  ------------------
  |  |  315|     23|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (341:7): [True: 0, False: 23]
  ------------------
  342|      0|    goto error;
  343|      0|  }
  344|       |#if defined(HAVE_LIBCRYPTO) && OPENSSL_VERSION_NUMBER >= 0x30000000L
  345|       |  bignum_safe_free(pubkey);
  346|       |#endif
  347|       |
  348|       |  /* register the packet callbacks */
  349|     23|  ssh_packet_set_callbacks(session, &ssh_dh_client_callbacks);
  350|     23|  session->dh_handshake_state = DH_STATE_INIT_SENT;
  351|       |
  352|     23|  rc = ssh_packet_send(session);
  353|     23|  return rc;
  354|      0|error:
  355|       |#if defined(HAVE_LIBCRYPTO) && OPENSSL_VERSION_NUMBER >= 0x30000000L
  356|       |  bignum_safe_free(pubkey);
  357|       |#endif
  358|      0|  ssh_dh_cleanup(crypto);
  359|      0|  return SSH_ERROR;
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  360|     23|}
ssh_client_dh_remove_callbacks:
  363|     21|{
  364|     21|    ssh_packet_remove_callbacks(session, &ssh_dh_client_callbacks);
  365|     21|}
ssh_dh_get_next_server_publickey:
  676|     35|{
  677|     35|    return session->next_crypto->server_pubkey;
  678|     35|}
ssh_dh_get_next_server_publickey_blob:
  683|     28|{
  684|     28|    const ssh_key pubkey = ssh_dh_get_next_server_publickey(session);
  685|       |
  686|     28|    return ssh_pki_export_pubkey_blob(pubkey, pubkey_blob);
  687|     28|}
dh.c:ssh_packet_client_dh_reply:
  367|     21|SSH_PACKET_CALLBACK(ssh_packet_client_dh_reply){
  368|     21|  struct ssh_crypto_struct *crypto=session->next_crypto;
  369|     21|  ssh_string pubkey_blob = NULL;
  370|     21|  bignum server_pubkey;
  371|     21|  int rc;
  372|       |
  373|     21|  (void)type;
  374|     21|  (void)user;
  375|       |
  376|     21|  ssh_client_dh_remove_callbacks(session);
  377|       |
  378|     21|  rc = ssh_buffer_unpack(packet, "SBS", &pubkey_blob, &server_pubkey,
  ------------------
  |  |   60|     21|    _ssh_buffer_unpack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |  453|     21|        (__VA_NARG_(__VA_ARGS__, __RSEQ_N()))
  |  |  |  |  ------------------
  |  |  |  |  |  |  455|     21|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  450|     21|#define VA_APPLY_VARIADIC_MACRO(macro, tuple) macro tuple
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  455|     21|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  463|     21|        _61,_62,_63,N,...) N
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                   _ssh_buffer_unpack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |   28|     21|#define SSH_BUFFER_PACK_END ((uint32_t) 0x4f65feb3)
  |  |  ------------------
  ------------------
  379|     21|          &crypto->dh_server_signature);
  380|     21|  if (rc == SSH_ERROR) {
  ------------------
  |  |  316|     21|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  |  Branch (380:7): [True: 0, False: 21]
  ------------------
  381|      0|      goto error;
  382|      0|  }
  383|     21|  rc = ssh_dh_keypair_set_keys(crypto->dh_ctx, DH_SERVER_KEYPAIR,
  ------------------
  |  |   31|     21|#define DH_SERVER_KEYPAIR 1
  ------------------
  384|     21|                               NULL, server_pubkey);
  385|     21|  if (rc != SSH_OK) {
  ------------------
  |  |  315|     21|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (385:7): [True: 0, False: 21]
  ------------------
  386|      0|      SSH_STRING_FREE(pubkey_blob);
  ------------------
  |  |  882|      0|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (882:14): [True: 0, False: 0]
  |  |  |  Branch (882:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
  387|      0|      bignum_safe_free(server_pubkey);
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
  388|      0|      goto error;
  389|      0|  }
  390|     21|  rc = ssh_dh_import_next_pubkey_blob(session, pubkey_blob);
  391|     21|  SSH_STRING_FREE(pubkey_blob);
  ------------------
  |  |  882|     21|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (882:14): [True: 21, False: 0]
  |  |  |  Branch (882:69): [Folded, False: 21]
  |  |  ------------------
  ------------------
  392|     21|  if (rc != 0) {
  ------------------
  |  Branch (392:7): [True: 2, False: 19]
  ------------------
  393|      2|      goto error;
  394|      2|  }
  395|       |
  396|     19|  rc = ssh_dh_compute_shared_secret(session->next_crypto->dh_ctx,
  397|     19|                                    DH_CLIENT_KEYPAIR, DH_SERVER_KEYPAIR,
  ------------------
  |  |   30|     19|#define DH_CLIENT_KEYPAIR 0
  ------------------
                                                  DH_CLIENT_KEYPAIR, DH_SERVER_KEYPAIR,
  ------------------
  |  |   31|     19|#define DH_SERVER_KEYPAIR 1
  ------------------
  398|     19|                                    &session->next_crypto->shared_secret);
  399|     19|  ssh_dh_debug_crypto(session->next_crypto);
  400|     19|  if (rc == SSH_ERROR){
  ------------------
  |  |  316|     19|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  |  Branch (400:7): [True: 0, False: 19]
  ------------------
  401|      0|    ssh_set_error(session, SSH_FATAL, "Could not generate shared secret");
  ------------------
  |  |  313|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  402|      0|    goto error;
  403|      0|  }
  404|       |
  405|       |  /* Send the MSG_NEWKEYS */
  406|     19|  rc = ssh_packet_send_newkeys(session);
  407|     19|  if (rc == SSH_ERROR) {
  ------------------
  |  |  316|     19|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  |  Branch (407:7): [True: 0, False: 19]
  ------------------
  408|      0|    goto error;
  409|      0|  }
  410|     19|  session->dh_handshake_state = DH_STATE_NEWKEYS_SENT;
  411|     19|  return SSH_PACKET_USED;
  ------------------
  |  |  638|     19|#define SSH_PACKET_USED 1
  ------------------
  412|      2|error:
  413|      2|  ssh_dh_cleanup(session->next_crypto);
  414|      2|  session->session_state=SSH_SESSION_STATE_ERROR;
  415|      2|  return SSH_PACKET_USED;
  ------------------
  |  |  638|      2|#define SSH_PACKET_USED 1
  ------------------
  416|     19|}

ssh_dh_debug_crypto:
   56|     19|{
   57|       |#ifdef DEBUG_CRYPTO
   58|       |#if OPENSSL_VERSION_NUMBER < 0x30000000L
   59|       |    const_bignum x = NULL, y = NULL, e = NULL, f = NULL;
   60|       |#else
   61|       |    bignum x = NULL, y = NULL, e = NULL, f = NULL;
   62|       |#endif /* OPENSSL_VERSION_NUMBER */
   63|       |
   64|       |    ssh_dh_keypair_get_keys(c->dh_ctx, DH_CLIENT_KEYPAIR, &x, &e);
   65|       |    ssh_dh_keypair_get_keys(c->dh_ctx, DH_SERVER_KEYPAIR, &y, &f);
   66|       |    ssh_print_bignum("x", x);
   67|       |    ssh_print_bignum("y", y);
   68|       |    ssh_print_bignum("e", e);
   69|       |    ssh_print_bignum("f", f);
   70|       |#if OPENSSL_VERSION_NUMBER >= 0x30000000L
   71|       |    bignum_safe_free(x);
   72|       |    bignum_safe_free(y);
   73|       |    bignum_safe_free(e);
   74|       |    bignum_safe_free(f);
   75|       |#endif /* OPENSSL_VERSION_NUMBER */
   76|       |
   77|       |    ssh_log_hexdump("Session server cookie", c->server_kex.cookie, 16);
   78|       |    ssh_log_hexdump("Session client cookie", c->client_kex.cookie, 16);
   79|       |    ssh_print_bignum("k", c->shared_secret);
   80|       |
   81|       |#else
   82|     19|    (void)c; /* UNUSED_PARAM */
   83|     19|#endif /* DEBUG_CRYPTO */
   84|     19|}
ssh_dh_keypair_get_keys:
   89|     80|{
   90|     80|    if (((peer != DH_CLIENT_KEYPAIR) && (peer != DH_SERVER_KEYPAIR)) ||
  ------------------
  |  |   30|     80|#define DH_CLIENT_KEYPAIR 0
  ------------------
                  if (((peer != DH_CLIENT_KEYPAIR) && (peer != DH_SERVER_KEYPAIR)) ||
  ------------------
  |  |   31|     38|#define DH_SERVER_KEYPAIR 1
  ------------------
  |  Branch (90:10): [True: 38, False: 42]
  |  Branch (90:41): [True: 0, False: 38]
  ------------------
   91|     80|        ((priv == NULL) && (pub == NULL)) || (ctx == NULL) ||
  ------------------
  |  Branch (91:10): [True: 80, False: 0]
  |  Branch (91:28): [True: 0, False: 80]
  |  Branch (91:46): [True: 0, False: 80]
  ------------------
   92|     80|        (ctx->keypair[peer] == NULL)) {
  ------------------
  |  Branch (92:9): [True: 0, False: 80]
  ------------------
   93|      0|        return SSH_ERROR;
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
   94|      0|    }
   95|       |
   96|     80|    DH_get0_key(ctx->keypair[peer], pub, priv);
   97|       |
   98|     80|    if (priv && (*priv == NULL || bignum_num_bits(*priv) == 0)) {
  ------------------
  |  |   99|      0|#define bignum_num_bits(num) (size_t)BN_num_bits(num)
  ------------------
  |  Branch (98:9): [True: 0, False: 80]
  |  Branch (98:18): [True: 0, False: 0]
  |  Branch (98:35): [True: 0, False: 0]
  ------------------
   99|      0|        return SSH_ERROR;
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  100|      0|    }
  101|     80|    if (pub && (*pub == NULL || bignum_num_bits(*pub) == 0)) {
  ------------------
  |  |   99|     80|#define bignum_num_bits(num) (size_t)BN_num_bits(num)
  ------------------
  |  Branch (101:9): [True: 80, False: 0]
  |  Branch (101:17): [True: 0, False: 80]
  |  Branch (101:33): [True: 0, False: 80]
  ------------------
  102|      0|        return SSH_ERROR;
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  103|      0|    }
  104|       |
  105|     80|    return SSH_OK;
  ------------------
  |  |  315|     80|#define SSH_OK 0     /* No error */
  ------------------
  106|     80|}
ssh_dh_keypair_set_keys:
  158|     21|{
  159|       |#if OPENSSL_VERSION_NUMBER >= 0x30000000L
  160|       |    int rc;
  161|       |    OSSL_PARAM *params = NULL, *out_params = NULL, *merged_params = NULL;
  162|       |    OSSL_PARAM_BLD *param_bld = NULL;
  163|       |    EVP_PKEY_CTX *evp_ctx = NULL;
  164|       |#endif /* OPENSSL_VERSION_NUMBER */
  165|       |
  166|     21|    if (((peer != DH_CLIENT_KEYPAIR) && (peer != DH_SERVER_KEYPAIR)) ||
  ------------------
  |  |   30|     21|#define DH_CLIENT_KEYPAIR 0
  ------------------
                  if (((peer != DH_CLIENT_KEYPAIR) && (peer != DH_SERVER_KEYPAIR)) ||
  ------------------
  |  |   31|     21|#define DH_SERVER_KEYPAIR 1
  ------------------
  |  Branch (166:10): [True: 21, False: 0]
  |  Branch (166:41): [True: 0, False: 21]
  ------------------
  167|     21|        ((priv == NULL) && (pub == NULL)) || (ctx == NULL) ||
  ------------------
  |  Branch (167:10): [True: 21, False: 0]
  |  Branch (167:28): [True: 0, False: 21]
  |  Branch (167:46): [True: 0, False: 21]
  ------------------
  168|     21|        (ctx->keypair[peer] == NULL)) {
  ------------------
  |  Branch (168:9): [True: 0, False: 21]
  ------------------
  169|      0|        return SSH_ERROR;
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  170|      0|    }
  171|       |
  172|     21|#if OPENSSL_VERSION_NUMBER < 0x30000000L
  173|     21|    (void)DH_set0_key(ctx->keypair[peer], pub, priv);
  174|       |
  175|     21|    return SSH_OK;
  ------------------
  |  |  315|     21|#define SSH_OK 0     /* No error */
  ------------------
  176|       |#else
  177|       |    rc = EVP_PKEY_todata(ctx->keypair[peer], EVP_PKEY_KEYPAIR, &out_params);
  178|       |    if (rc != 1) {
  179|       |        return SSH_ERROR;
  180|       |    }
  181|       |
  182|       |    param_bld = OSSL_PARAM_BLD_new();
  183|       |    if (param_bld == NULL) {
  184|       |        rc = SSH_ERROR;
  185|       |        goto out;
  186|       |    }
  187|       |
  188|       |    evp_ctx = EVP_PKEY_CTX_new_from_pkey(NULL, ctx->keypair[peer], NULL);
  189|       |    if (evp_ctx == NULL) {
  190|       |        rc = SSH_ERROR;
  191|       |        goto out;
  192|       |    }
  193|       |
  194|       |    rc = EVP_PKEY_fromdata_init(evp_ctx);
  195|       |    if (rc != 1) {
  196|       |        rc = SSH_ERROR;
  197|       |        goto out;
  198|       |    }
  199|       |
  200|       |    if (priv) {
  201|       |        rc = OSSL_PARAM_BLD_push_BN(param_bld, OSSL_PKEY_PARAM_PRIV_KEY, priv);
  202|       |        if (rc != 1) {
  203|       |            rc = SSH_ERROR;
  204|       |            goto out;
  205|       |        }
  206|       |    }
  207|       |    if (pub) {
  208|       |        rc = OSSL_PARAM_BLD_push_BN(param_bld, OSSL_PKEY_PARAM_PUB_KEY, pub);
  209|       |        if (rc != 1) {
  210|       |            rc = SSH_ERROR;
  211|       |            goto out;
  212|       |        }
  213|       |    }
  214|       |
  215|       |    params = OSSL_PARAM_BLD_to_param(param_bld);
  216|       |    if (params == NULL) {
  217|       |        rc = SSH_ERROR;
  218|       |        goto out;
  219|       |    }
  220|       |    OSSL_PARAM_BLD_free(param_bld);
  221|       |
  222|       |    merged_params = OSSL_PARAM_merge(out_params, params);
  223|       |    if (merged_params == NULL) {
  224|       |        rc = SSH_ERROR;
  225|       |        goto out;
  226|       |    }
  227|       |
  228|       |    rc = EVP_PKEY_fromdata(evp_ctx,
  229|       |                           &(ctx->keypair[peer]),
  230|       |                           EVP_PKEY_PUBLIC_KEY,
  231|       |                           merged_params);
  232|       |    if (rc != 1) {
  233|       |        rc = SSH_ERROR;
  234|       |        goto out;
  235|       |    }
  236|       |
  237|       |    rc = SSH_OK;
  238|       |out:
  239|       |    bignum_safe_free(priv);
  240|       |    bignum_safe_free(pub);
  241|       |    EVP_PKEY_CTX_free(evp_ctx);
  242|       |    OSSL_PARAM_free(out_params);
  243|       |    OSSL_PARAM_free(params);
  244|       |    OSSL_PARAM_free(merged_params);
  245|       |
  246|       |    return rc;
  247|       |#endif /* OPENSSL_VERSION_NUMBER */
  248|     21|}
ssh_dh_set_parameters:
  286|     23|{
  287|     23|    size_t i;
  288|     23|    int rc;
  289|       |#if OPENSSL_VERSION_NUMBER >= 0x30000000L
  290|       |    OSSL_PARAM *params = NULL;
  291|       |    OSSL_PARAM_BLD *param_bld = NULL;
  292|       |    EVP_PKEY_CTX *evp_ctx = NULL;
  293|       |#endif /* OPENSSL_VERSION_NUMBER */
  294|       |
  295|     23|    if ((ctx == NULL) || (modulus == NULL) || (generator == NULL)) {
  ------------------
  |  Branch (295:9): [True: 0, False: 23]
  |  Branch (295:26): [True: 0, False: 23]
  |  Branch (295:47): [True: 0, False: 23]
  ------------------
  296|      0|        return SSH_ERROR;
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  297|      0|    }
  298|       |
  299|       |#if OPENSSL_VERSION_NUMBER >= 0x30000000L
  300|       |    evp_ctx = EVP_PKEY_CTX_new_from_name(NULL, "DHX", NULL);
  301|       |#endif
  302|       |
  303|     69|    for (i = 0; i < 2; i++) {
  ------------------
  |  Branch (303:17): [True: 46, False: 23]
  ------------------
  304|     46|#if OPENSSL_VERSION_NUMBER < 0x30000000L
  305|     46|        bignum p = NULL;
  306|     46|        bignum g = NULL;
  307|       |
  308|       |        /* when setting modulus or generator,
  309|       |         * make sure to invalidate existing keys */
  310|     46|        DH_free(ctx->keypair[i]);
  311|     46|        ctx->keypair[i] = DH_new();
  312|     46|        if (ctx->keypair[i] == NULL) {
  ------------------
  |  Branch (312:13): [True: 0, False: 46]
  ------------------
  313|      0|            rc = SSH_ERROR;
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  314|      0|            goto done;
  315|      0|        }
  316|       |
  317|     46|        p = BN_dup(modulus);
  318|     46|        g = BN_dup(generator);
  319|     46|        rc = DH_set0_pqg(ctx->keypair[i], p, NULL, g);
  320|     46|        if (rc != 1) {
  ------------------
  |  Branch (320:13): [True: 0, False: 46]
  ------------------
  321|      0|            BN_free(p);
  322|      0|            BN_free(g);
  323|      0|            rc = SSH_ERROR;
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  324|      0|            goto done;
  325|      0|        }
  326|       |#else
  327|       |        param_bld = OSSL_PARAM_BLD_new();
  328|       |
  329|       |        if (param_bld == NULL) {
  330|       |            rc = SSH_ERROR;
  331|       |            goto done;
  332|       |        }
  333|       |
  334|       |        rc = OSSL_PARAM_BLD_push_BN(param_bld, OSSL_PKEY_PARAM_FFC_P, modulus);
  335|       |        if (rc != 1) {
  336|       |            rc = SSH_ERROR;
  337|       |            goto done;
  338|       |        }
  339|       |        rc = OSSL_PARAM_BLD_push_BN(param_bld, OSSL_PKEY_PARAM_FFC_G, generator);
  340|       |        if (rc != 1) {
  341|       |            rc = SSH_ERROR;
  342|       |            goto done;
  343|       |        }
  344|       |        params = OSSL_PARAM_BLD_to_param(param_bld);
  345|       |        if (params == NULL) {
  346|       |            OSSL_PARAM_BLD_free(param_bld);
  347|       |            rc = SSH_ERROR;
  348|       |            goto done;
  349|       |        }
  350|       |        OSSL_PARAM_BLD_free(param_bld);
  351|       |
  352|       |        rc = EVP_PKEY_fromdata_init(evp_ctx);
  353|       |        if (rc != 1) {
  354|       |            OSSL_PARAM_free(params);
  355|       |            rc = SSH_ERROR;
  356|       |            goto done;
  357|       |        }
  358|       |
  359|       |        /* make sure to invalidate existing keys */
  360|       |        EVP_PKEY_free(ctx->keypair[i]);
  361|       |        ctx->keypair[i] = NULL;
  362|       |
  363|       |        rc = EVP_PKEY_fromdata(evp_ctx,
  364|       |                               &(ctx->keypair[i]),
  365|       |                               EVP_PKEY_KEY_PARAMETERS,
  366|       |                               params);
  367|       |        if (rc != 1) {
  368|       |            OSSL_PARAM_free(params);
  369|       |            rc = SSH_ERROR;
  370|       |            goto done;
  371|       |        }
  372|       |
  373|       |        OSSL_PARAM_free(params);
  374|       |#endif /* OPENSSL_VERSION_NUMBER */
  375|     46|    }
  376|       |
  377|     23|    rc = SSH_OK;
  ------------------
  |  |  315|     23|#define SSH_OK 0     /* No error */
  ------------------
  378|     23|#if OPENSSL_VERSION_NUMBER < 0x30000000L
  379|     23|done:
  380|     23|    if (rc != SSH_OK) {
  ------------------
  |  |  315|     23|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (380:9): [True: 0, False: 23]
  ------------------
  381|      0|        DH_free(ctx->keypair[0]);
  382|      0|        DH_free(ctx->keypair[1]);
  383|      0|    }
  384|       |#else
  385|       |done:
  386|       |    EVP_PKEY_CTX_free(evp_ctx);
  387|       |
  388|       |    if (rc != SSH_OK) {
  389|       |        EVP_PKEY_free(ctx->keypair[0]);
  390|       |        EVP_PKEY_free(ctx->keypair[1]);
  391|       |    }
  392|       |#endif /* OPENSSL_VERSION_NUMBER */
  393|     23|    if (rc != SSH_OK) {
  ------------------
  |  |  315|     23|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (393:9): [True: 0, False: 23]
  ------------------
  394|      0|        ctx->keypair[0] = NULL;
  395|      0|        ctx->keypair[1] = NULL;
  396|      0|    }
  397|       |
  398|     23|    return rc;
  399|     23|}
ssh_dh_init_common:
  406|     26|{
  407|     26|    struct dh_ctx *ctx = NULL;
  408|     26|    int rc;
  409|       |
  410|       |    /* Cleanup any previously allocated dh_ctx */
  411|     26|    if (crypto->dh_ctx != NULL) {
  ------------------
  |  Branch (411:9): [True: 0, False: 26]
  ------------------
  412|      0|        ssh_dh_cleanup(crypto);
  413|      0|    }
  414|       |
  415|     26|    ctx = calloc(1, sizeof(*ctx));
  416|     26|    if (ctx == NULL) {
  ------------------
  |  Branch (416:9): [True: 0, False: 26]
  ------------------
  417|      0|        return SSH_ERROR;
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  418|      0|    }
  419|     26|    crypto->dh_ctx = ctx;
  420|       |
  421|     26|    switch (crypto->kex_type) {
  422|      0|    case SSH_KEX_DH_GROUP1_SHA1:
  ------------------
  |  Branch (422:5): [True: 0, False: 26]
  ------------------
  423|      0|        rc = ssh_dh_set_parameters(ctx, ssh_dh_group1, ssh_dh_generator);
  424|      0|        break;
  425|      0|    case SSH_KEX_DH_GROUP14_SHA1:
  ------------------
  |  Branch (425:5): [True: 0, False: 26]
  ------------------
  426|      4|    case SSH_KEX_DH_GROUP14_SHA256:
  ------------------
  |  Branch (426:5): [True: 4, False: 22]
  ------------------
  427|      4|    case SSH_GSS_KEX_DH_GROUP14_SHA256:
  ------------------
  |  Branch (427:5): [True: 0, False: 26]
  ------------------
  428|      4|        rc = ssh_dh_set_parameters(ctx, ssh_dh_group14, ssh_dh_generator);
  429|      4|        break;
  430|      1|    case SSH_KEX_DH_GROUP16_SHA512:
  ------------------
  |  Branch (430:5): [True: 1, False: 25]
  ------------------
  431|      1|    case SSH_GSS_KEX_DH_GROUP16_SHA512:
  ------------------
  |  Branch (431:5): [True: 0, False: 26]
  ------------------
  432|      1|        rc = ssh_dh_set_parameters(ctx, ssh_dh_group16, ssh_dh_generator);
  433|      1|        break;
  434|     18|    case SSH_KEX_DH_GROUP18_SHA512:
  ------------------
  |  Branch (434:5): [True: 18, False: 8]
  ------------------
  435|     18|        rc = ssh_dh_set_parameters(ctx, ssh_dh_group18, ssh_dh_generator);
  436|     18|        break;
  437|      3|    default:
  ------------------
  |  Branch (437:5): [True: 3, False: 23]
  ------------------
  438|      3|        rc = SSH_OK;
  ------------------
  |  |  315|      3|#define SSH_OK 0     /* No error */
  ------------------
  439|      3|        break;
  440|     26|    }
  441|       |
  442|     26|    if (rc != SSH_OK) {
  ------------------
  |  |  315|     26|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (442:9): [True: 0, False: 26]
  ------------------
  443|      0|        ssh_dh_cleanup(crypto);
  444|      0|    }
  445|     26|    return rc;
  446|     26|}
ssh_dh_cleanup:
  449|  1.06k|{
  450|  1.06k|    if (crypto->dh_ctx != NULL) {
  ------------------
  |  Branch (450:9): [True: 26, False: 1.03k]
  ------------------
  451|     26|#if OPENSSL_VERSION_NUMBER < 0x30000000L
  452|     26|        DH_free(crypto->dh_ctx->keypair[0]);
  453|     26|        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|     26|        free(crypto->dh_ctx);
  459|       |        crypto->dh_ctx = NULL;
  460|     26|    }
  461|  1.06k|}
ssh_dh_keypair_gen_keys:
  474|     23|{
  475|     23|    int rc;
  476|       |#if OPENSSL_VERSION_NUMBER >= 0x30000000L
  477|       |    EVP_PKEY_CTX *evp_ctx = NULL;
  478|       |#endif
  479|       |
  480|     23|    if ((dh_ctx == NULL) || (dh_ctx->keypair[peer] == NULL)) {
  ------------------
  |  Branch (480:9): [True: 0, False: 23]
  |  Branch (480:29): [True: 0, False: 23]
  ------------------
  481|      0|        return SSH_ERROR;
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  482|      0|    }
  483|       |
  484|     23|#if OPENSSL_VERSION_NUMBER < 0x30000000L
  485|     23|    rc = DH_generate_key(dh_ctx->keypair[peer]);
  486|     23|    if (rc != 1) {
  ------------------
  |  Branch (486:9): [True: 0, False: 23]
  ------------------
  487|      0|        return SSH_ERROR;
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  488|      0|    }
  489|       |#else
  490|       |    evp_ctx = EVP_PKEY_CTX_new_from_pkey(NULL, dh_ctx->keypair[peer], NULL);
  491|       |    if (evp_ctx == NULL) {
  492|       |        return SSH_ERROR;
  493|       |    }
  494|       |
  495|       |    rc = EVP_PKEY_keygen_init(evp_ctx);
  496|       |    if (rc != 1) {
  497|       |        EVP_PKEY_CTX_free(evp_ctx);
  498|       |        return SSH_ERROR;
  499|       |    }
  500|       |
  501|       |    rc = EVP_PKEY_generate(evp_ctx, &(dh_ctx->keypair[peer]));
  502|       |    if (rc != 1) {
  503|       |        EVP_PKEY_CTX_free(evp_ctx);
  504|       |        SSH_LOG(SSH_LOG_TRACE,
  505|       |                "Failed to generate DH: %s",
  506|       |                ERR_error_string(ERR_get_error(), NULL));
  507|       |        return SSH_ERROR;
  508|       |    }
  509|       |
  510|       |    EVP_PKEY_CTX_free(evp_ctx);
  511|       |#endif /* OPENSSL_VERSION_NUMBER */
  512|       |
  513|     23|    return SSH_OK;
  ------------------
  |  |  315|     23|#define SSH_OK 0     /* No error */
  ------------------
  514|     23|}
ssh_dh_compute_shared_secret:
  529|     19|{
  530|     19|    unsigned char *kstring = NULL;
  531|     19|    int rc;
  532|     19|#if OPENSSL_VERSION_NUMBER < 0x30000000L
  533|     19|    const_bignum pub_key = NULL;
  534|     19|    int klen;
  535|       |#else
  536|       |    size_t klen;
  537|       |    EVP_PKEY_CTX *evp_ctx = NULL;
  538|       |#endif /* OPENSSL_VERSION_NUMBER */
  539|       |
  540|     19|    if ((dh_ctx == NULL) ||
  ------------------
  |  Branch (540:9): [True: 0, False: 19]
  ------------------
  541|     19|        (dh_ctx->keypair[local] == NULL) ||
  ------------------
  |  Branch (541:9): [True: 0, False: 19]
  ------------------
  542|     19|        (dh_ctx->keypair[remote] == NULL)) {
  ------------------
  |  Branch (542:9): [True: 0, False: 19]
  ------------------
  543|      0|        return SSH_ERROR;
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  544|      0|    }
  545|       |
  546|     19|#if OPENSSL_VERSION_NUMBER < 0x30000000L
  547|     19|    kstring = malloc(DH_size(dh_ctx->keypair[local]));
  548|     19|    if (kstring == NULL) {
  ------------------
  |  Branch (548:9): [True: 0, False: 19]
  ------------------
  549|      0|        rc = SSH_ERROR;
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  550|      0|        goto done;
  551|      0|    }
  552|       |
  553|     19|    rc = ssh_dh_keypair_get_keys(dh_ctx, remote, NULL, &pub_key);
  554|     19|    if (rc != SSH_OK) {
  ------------------
  |  |  315|     19|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (554:9): [True: 0, False: 19]
  ------------------
  555|      0|        rc = SSH_ERROR;
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  556|      0|        goto done;
  557|      0|    }
  558|       |
  559|     19|    klen = DH_compute_key(kstring, pub_key, dh_ctx->keypair[local]);
  560|     19|    if (klen == -1) {
  ------------------
  |  Branch (560:9): [True: 0, False: 19]
  ------------------
  561|      0|        rc = SSH_ERROR;
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  562|      0|        goto done;
  563|      0|    }
  564|       |#else
  565|       |    evp_ctx = EVP_PKEY_CTX_new_from_pkey(NULL, dh_ctx->keypair[local], NULL);
  566|       |
  567|       |    rc = EVP_PKEY_derive_init(evp_ctx);
  568|       |    if (rc != 1) {
  569|       |        rc = SSH_ERROR;
  570|       |        goto done;
  571|       |    }
  572|       |
  573|       |    rc = EVP_PKEY_derive_set_peer(evp_ctx, dh_ctx->keypair[remote]);
  574|       |    if (rc != 1) {
  575|       |        SSH_LOG(SSH_LOG_TRACE,
  576|       |                "Failed to set peer key: %s",
  577|       |                ERR_error_string(ERR_get_error(), NULL));
  578|       |        rc = SSH_ERROR;
  579|       |        goto done;
  580|       |    }
  581|       |
  582|       |    /* getting the size of the secret */
  583|       |    rc = EVP_PKEY_derive(evp_ctx, kstring, &klen);
  584|       |    if (rc != 1) {
  585|       |        rc = SSH_ERROR;
  586|       |        goto done;
  587|       |    }
  588|       |
  589|       |    kstring = malloc(klen);
  590|       |    if (kstring == NULL) {
  591|       |        rc = SSH_ERROR;
  592|       |        goto done;
  593|       |    }
  594|       |
  595|       |    rc = EVP_PKEY_derive(evp_ctx, kstring, &klen);
  596|       |    if (rc != 1) {
  597|       |        rc = SSH_ERROR;
  598|       |        goto done;
  599|       |    }
  600|       |#endif /* OPENSSL_VERSION_NUMBER */
  601|       |
  602|     19|    *dest = BN_bin2bn(kstring, (int)klen, NULL);
  603|     19|    if (*dest == NULL) {
  ------------------
  |  Branch (603:9): [True: 0, False: 19]
  ------------------
  604|      0|        rc = SSH_ERROR;
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  605|      0|        goto done;
  606|      0|    }
  607|       |
  608|     19|    rc = SSH_OK;
  ------------------
  |  |  315|     19|#define SSH_OK 0     /* No error */
  ------------------
  609|     19|done:
  610|       |#if OPENSSL_VERSION_NUMBER >= 0x30000000L
  611|       |    EVP_PKEY_CTX_free(evp_ctx);
  612|       |#endif
  613|     19|    free(kstring);
  614|     19|    return rc;
  615|     19|}

ssh_client_ecdh_remove_callbacks:
   47|      8|{
   48|      8|    ssh_packet_remove_callbacks(session, &ssh_ecdh_client_callbacks);
   49|      8|}
ecdh.c:ssh_packet_client_ecdh_reply:
   55|      8|SSH_PACKET_CALLBACK(ssh_packet_client_ecdh_reply){
   56|      8|  ssh_string q_s_string = NULL;
   57|      8|  ssh_string pubkey_blob = NULL;
   58|      8|  ssh_string signature = NULL;
   59|      8|  int rc;
   60|      8|  (void)type;
   61|      8|  (void)user;
   62|       |
   63|      8|  ssh_client_ecdh_remove_callbacks(session);
   64|      8|  pubkey_blob = ssh_buffer_get_ssh_string(packet);
   65|      8|  if (pubkey_blob == NULL) {
  ------------------
  |  Branch (65:7): [True: 0, False: 8]
  ------------------
   66|      0|    ssh_set_error(session,SSH_FATAL, "No public key in packet");
  ------------------
  |  |  313|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
   67|      0|    goto error;
   68|      0|  }
   69|       |
   70|      8|  rc = ssh_dh_import_next_pubkey_blob(session, pubkey_blob);
   71|      8|  SSH_STRING_FREE(pubkey_blob);
  ------------------
  |  |  882|      8|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (882:14): [True: 8, False: 0]
  |  |  |  Branch (882:69): [Folded, False: 8]
  |  |  ------------------
  ------------------
   72|      8|  if (rc != 0) {
  ------------------
  |  Branch (72:7): [True: 8, False: 0]
  ------------------
   73|      8|      goto error;
   74|      8|  }
   75|       |
   76|      0|  q_s_string = ssh_buffer_get_ssh_string(packet);
   77|      0|  if (q_s_string == NULL) {
  ------------------
  |  Branch (77:7): [True: 0, False: 0]
  ------------------
   78|      0|    ssh_set_error(session,SSH_FATAL, "No Q_S ECC point in packet");
  ------------------
  |  |  313|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
   79|      0|    goto error;
   80|      0|  }
   81|      0|  session->next_crypto->ecdh_server_pubkey = q_s_string;
   82|      0|  signature = ssh_buffer_get_ssh_string(packet);
   83|      0|  if (signature == NULL) {
  ------------------
  |  Branch (83:7): [True: 0, False: 0]
  ------------------
   84|      0|    ssh_set_error(session, SSH_FATAL, "No signature in packet");
  ------------------
  |  |  313|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
   85|      0|    goto error;
   86|      0|  }
   87|      0|  session->next_crypto->dh_server_signature = signature;
   88|      0|  signature=NULL; /* ownership changed */
   89|       |  /* TODO: verify signature now instead of waiting for NEWKEYS */
   90|      0|  if (ecdh_build_k(session) < 0) {
  ------------------
  |  Branch (90:7): [True: 0, False: 0]
  ------------------
   91|      0|    ssh_set_error(session, SSH_FATAL, "Cannot build k number");
  ------------------
  |  |  313|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
   92|      0|    goto error;
   93|      0|  }
   94|       |
   95|       |  /* Send the MSG_NEWKEYS */
   96|      0|  rc = ssh_packet_send_newkeys(session);
   97|      0|  if (rc == SSH_ERROR) {
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  |  Branch (97:7): [True: 0, False: 0]
  ------------------
   98|      0|    goto error;
   99|      0|  }
  100|      0|  session->dh_handshake_state = DH_STATE_NEWKEYS_SENT;
  101|       |
  102|      0|  return SSH_PACKET_USED;
  ------------------
  |  |  638|      0|#define SSH_PACKET_USED 1
  ------------------
  103|       |
  104|      8|error:
  105|      8|  session->session_state=SSH_SESSION_STATE_ERROR;
  106|      8|  return SSH_PACKET_USED;
  ------------------
  |  |  638|      8|#define SSH_PACKET_USED 1
  ------------------
  107|      0|}

ssh_ecdh_init:
  235|     57|{
  236|     57|    ssh_string pubkey = NULL;
  237|     57|    ssh_string *pubkey_loc = NULL;
  238|       |
  239|     57|    pubkey = ssh_ecdh_generate(session);
  240|     57|    if (pubkey == NULL) {
  ------------------
  |  Branch (240:9): [True: 0, False: 57]
  ------------------
  241|      0|        return SSH_ERROR;
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  242|      0|    }
  243|       |
  244|     57|    if (session->server) {
  ------------------
  |  Branch (244:9): [True: 0, False: 57]
  ------------------
  245|      0|        pubkey_loc = &session->next_crypto->ecdh_server_pubkey;
  246|     57|    } else {
  247|     57|        pubkey_loc = &session->next_crypto->ecdh_client_pubkey;
  248|     57|    }
  249|       |
  250|     57|    ssh_string_free(*pubkey_loc);
  251|     57|    *pubkey_loc = pubkey;
  252|       |
  253|     57|    return SSH_OK;
  ------------------
  |  |  315|     57|#define SSH_OK 0     /* No error */
  ------------------
  254|     57|}
ssh_client_ecdh_init:
  260|      8|{
  261|      8|    int rc;
  262|       |
  263|      8|    rc = ssh_buffer_add_u8(session->out_buffer, SSH2_MSG_KEX_ECDH_INIT);
  ------------------
  |  |   17|      8|#define SSH2_MSG_KEX_ECDH_INIT 30
  ------------------
  264|      8|    if (rc < 0) {
  ------------------
  |  Branch (264:9): [True: 0, False: 8]
  ------------------
  265|      0|        return SSH_ERROR;
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  266|      0|    }
  267|       |
  268|      8|    rc = ssh_ecdh_init(session);
  269|      8|    if (rc < 0) {
  ------------------
  |  Branch (269:9): [True: 0, False: 8]
  ------------------
  270|      0|        return SSH_ERROR;
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  271|      0|    }
  272|       |
  273|      8|    rc = ssh_buffer_add_ssh_string(session->out_buffer,
  274|      8|                                   session->next_crypto->ecdh_client_pubkey);
  275|      8|    if (rc < 0) {
  ------------------
  |  Branch (275:9): [True: 0, False: 8]
  ------------------
  276|      0|        return SSH_ERROR;
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  277|      0|    }
  278|       |
  279|       |    /* register the packet callbacks */
  280|      8|    ssh_packet_set_callbacks(session, &ssh_ecdh_client_callbacks);
  281|      8|    session->dh_handshake_state = DH_STATE_INIT_SENT;
  282|       |
  283|      8|    rc = ssh_packet_send(session);
  284|       |
  285|      8|    return rc;
  286|      8|}
ecdh_crypto.c:ssh_ecdh_generate:
   80|     57|{
   81|     57|    ssh_string pubkey_string = NULL;
   82|     57|#if OPENSSL_VERSION_NUMBER < 0x30000000L
   83|     57|    const EC_POINT *point = NULL;
   84|     57|    const EC_GROUP *group = NULL;
   85|     57|    EC_KEY *key = NULL;
   86|     57|    int curve;
   87|       |#else
   88|       |    EC_POINT *point = NULL;
   89|       |    EC_GROUP *group = NULL;
   90|       |    const char *curve = NULL;
   91|       |    EVP_PKEY *key = NULL;
   92|       |    OSSL_PARAM *out_params = NULL;
   93|       |    const OSSL_PARAM *pubkey_param = NULL;
   94|       |    const void *pubkey = NULL;
   95|       |    size_t pubkey_len;
   96|       |    int nid;
   97|       |#endif /* OPENSSL_VERSION_NUMBER */
   98|     57|    int rc;
   99|       |
  100|     57|    curve = ecdh_kex_type_to_curve(session->next_crypto->kex_type);
  101|     57|#if OPENSSL_VERSION_NUMBER < 0x30000000L
  102|     57|    if (curve == SSH_ERROR) {
  ------------------
  |  |  316|     57|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  |  Branch (102:9): [True: 0, False: 57]
  ------------------
  103|      0|        SSH_LOG(SSH_LOG_TRACE, "Failed to get curve name");
  ------------------
  |  |  283|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  104|      0|        return NULL;
  105|      0|    }
  106|       |
  107|     57|    key = EC_KEY_new_by_curve_name(curve);
  108|       |#else
  109|       |    if (curve == NULL) {
  110|       |        SSH_LOG(SSH_LOG_TRACE, "Failed to get curve name");
  111|       |        return NULL;
  112|       |    }
  113|       |
  114|       |    key = EVP_EC_gen(curve);
  115|       |#endif /* OPENSSL_VERSION_NUMBER */
  116|     57|    if (key == NULL) {
  ------------------
  |  Branch (116:9): [True: 0, False: 57]
  ------------------
  117|      0|        SSH_LOG(SSH_LOG_TRACE, "Failed to generate key");
  ------------------
  |  |  283|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  118|      0|        return NULL;
  119|      0|    }
  120|       |
  121|     57|#if OPENSSL_VERSION_NUMBER < 0x30000000L
  122|     57|    group = EC_KEY_get0_group(key);
  123|     57|    if (group == NULL) {
  ------------------
  |  Branch (123:9): [True: 0, False: 57]
  ------------------
  124|      0|        SSH_LOG(SSH_LOG_TRACE, "Failed to get group");
  ------------------
  |  |  283|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  125|      0|        EC_KEY_free(key);
  126|      0|        return NULL;
  127|      0|    }
  128|       |
  129|     57|    rc = EC_KEY_generate_key(key);
  130|     57|    if (rc != 1) {
  ------------------
  |  Branch (130:9): [True: 0, False: 57]
  ------------------
  131|      0|        SSH_LOG(SSH_LOG_TRACE, "Failed to generate EC key");
  ------------------
  |  |  283|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  132|      0|        EC_KEY_free(key);
  133|      0|        return NULL;
  134|      0|    }
  135|       |
  136|     57|    point = EC_KEY_get0_public_key(key);
  137|     57|    if (point == NULL) {
  ------------------
  |  Branch (137:9): [True: 0, False: 57]
  ------------------
  138|      0|        SSH_LOG(SSH_LOG_TRACE, "Failed to get EC point");
  ------------------
  |  |  283|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  139|      0|        EC_KEY_free(key);
  140|      0|        return NULL;
  141|      0|    }
  142|       |
  143|     57|    pubkey_string = pki_key_make_ecpoint_string(group, point);
  144|       |#else
  145|       |    rc = EVP_PKEY_todata(key, EVP_PKEY_PUBLIC_KEY, &out_params);
  146|       |    if (rc != 1) {
  147|       |        SSH_LOG(SSH_LOG_TRACE, "Failed to export public key");
  148|       |        EVP_PKEY_free(key);
  149|       |        return NULL;
  150|       |    }
  151|       |
  152|       |    pubkey_param = OSSL_PARAM_locate_const(out_params, OSSL_PKEY_PARAM_PUB_KEY);
  153|       |    if (pubkey_param == NULL) {
  154|       |        SSH_LOG(SSH_LOG_TRACE, "Failed to find public key");
  155|       |        EVP_PKEY_free(key);
  156|       |        OSSL_PARAM_free(out_params);
  157|       |        return NULL;
  158|       |    }
  159|       |
  160|       |    rc = OSSL_PARAM_get_octet_string_ptr(pubkey_param,
  161|       |                                         (const void**)&pubkey,
  162|       |                                         &pubkey_len);
  163|       |    if (rc != 1) {
  164|       |        SSH_LOG(SSH_LOG_TRACE, "Failed to read public key");
  165|       |        OSSL_PARAM_free(out_params);
  166|       |        EVP_PKEY_free(key);
  167|       |        return NULL;
  168|       |    }
  169|       |
  170|       |    /* Convert the data to low-level representation */
  171|       |    nid = pki_key_ecgroup_name_to_nid(curve);
  172|       |    group = EC_GROUP_new_by_curve_name_ex(NULL, NULL, nid);
  173|       |    if (group == NULL) {
  174|       |        ssh_set_error(session,
  175|       |                      SSH_FATAL,
  176|       |                      "Could not create group: %s",
  177|       |                      ERR_error_string(ERR_get_error(), NULL));
  178|       |        OSSL_PARAM_free(out_params);
  179|       |        EVP_PKEY_free(key);
  180|       |        return NULL;
  181|       |    }
  182|       |    point = EC_POINT_new(group);
  183|       |    if (point == NULL) {
  184|       |        ssh_set_error(session,
  185|       |                      SSH_FATAL,
  186|       |                      "Could not create point: %s",
  187|       |                      ERR_error_string(ERR_get_error(), NULL));
  188|       |        EC_GROUP_free(group);
  189|       |        OSSL_PARAM_free(out_params);
  190|       |        EVP_PKEY_free(key);
  191|       |        return NULL;
  192|       |    }
  193|       |    rc = EC_POINT_oct2point(group, point, pubkey, pubkey_len, NULL);
  194|       |    OSSL_PARAM_free(out_params);
  195|       |    if (rc != 1) {
  196|       |        SSH_LOG(SSH_LOG_TRACE, "Failed to export public key");
  197|       |        EC_GROUP_free(group);
  198|       |        EC_POINT_free(point);
  199|       |        EVP_PKEY_free(key);
  200|       |        return NULL;
  201|       |    }
  202|       |
  203|       |    pubkey_string = pki_key_make_ecpoint_string(group, point);
  204|       |    EC_GROUP_free(group);
  205|       |    EC_POINT_free(point);
  206|       |#endif /* OPENSSL_VERSION_NUMBER */
  207|     57|    if (pubkey_string == NULL) {
  ------------------
  |  Branch (207:9): [True: 0, False: 57]
  ------------------
  208|      0|        SSH_LOG(SSH_LOG_TRACE, "Failed to convert public key");
  ------------------
  |  |  283|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  209|      0|#if OPENSSL_VERSION_NUMBER < 0x30000000L
  210|      0|        EC_KEY_free(key);
  211|       |#else
  212|       |        EVP_PKEY_free(key);
  213|       |#endif /* OPENSSL_VERSION_NUMBER */
  214|      0|        return NULL;
  215|      0|    }
  216|       |
  217|       |    /* Free any previously allocated privkey */
  218|     57|    if (session->next_crypto->ecdh_privkey != NULL) {
  ------------------
  |  Branch (218:9): [True: 0, False: 57]
  ------------------
  219|      0|#if OPENSSL_VERSION_NUMBER < 0x30000000L
  220|      0|        EC_KEY_free(session->next_crypto->ecdh_privkey);
  221|       |#else
  222|       |        EVP_PKEY_free(session->next_crypto->ecdh_privkey);
  223|       |#endif
  224|      0|        session->next_crypto->ecdh_privkey = NULL;
  225|      0|    }
  226|       |
  227|     57|    session->next_crypto->ecdh_privkey = key;
  228|     57|    return pubkey_string;
  229|     57|}
ecdh_crypto.c:ecdh_kex_type_to_curve:
   50|     57|static int ecdh_kex_type_to_curve(enum ssh_key_exchange_e kex_type) {
   51|       |#else
   52|       |static const char *ecdh_kex_type_to_curve(enum ssh_key_exchange_e kex_type) {
   53|       |#endif /* OPENSSL_VERSION_NUMBER */
   54|     57|    switch (kex_type) {
   55|      4|    case SSH_KEX_ECDH_SHA2_NISTP256:
  ------------------
  |  Branch (55:5): [True: 4, False: 53]
  ------------------
   56|     53|    case SSH_KEX_MLKEM768NISTP256_SHA256:
  ------------------
  |  Branch (56:5): [True: 49, False: 8]
  ------------------
   57|     53|    case SSH_GSS_KEX_ECDH_NISTP256_SHA256:
  ------------------
  |  Branch (57:5): [True: 0, False: 57]
  ------------------
   58|     53|        return NISTP256;
  ------------------
  |  |   34|     53|#define NISTP256 NID_X9_62_prime256v1
  ------------------
   59|      1|    case SSH_KEX_ECDH_SHA2_NISTP384:
  ------------------
  |  Branch (59:5): [True: 1, False: 56]
  ------------------
   60|       |#if HAVE_MLKEM1024
   61|       |    case SSH_KEX_MLKEM1024NISTP384_SHA384:
   62|       |#endif
   63|      1|        return NISTP384;
  ------------------
  |  |   35|      1|#define NISTP384 NID_secp384r1
  ------------------
   64|      3|    case SSH_KEX_ECDH_SHA2_NISTP521:
  ------------------
  |  Branch (64:5): [True: 3, False: 54]
  ------------------
   65|      3|        return NISTP521;
  ------------------
  |  |   36|      3|#define NISTP521 NID_secp521r1
  ------------------
   66|      0|    default:
  ------------------
  |  Branch (66:5): [True: 0, False: 57]
  ------------------
   67|      0|#if OPENSSL_VERSION_NUMBER < 0x30000000L
   68|      0|        return SSH_ERROR;
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
   69|       |#else
   70|       |        return NULL;
   71|       |#endif
   72|     57|    }
   73|     57|}

_ssh_set_error:
   55|  12.1k|{
   56|  12.1k|    struct ssh_common_struct *err = error;
   57|  12.1k|    va_list va;
   58|       |
   59|  12.1k|    va_start(va, descr);
   60|  12.1k|    vsnprintf(err->error.error_buffer, ERROR_BUFFERLEN, descr, va);
  ------------------
  |  |  219|  12.1k|#define ERROR_BUFFERLEN 1024
  ------------------
   61|  12.1k|    va_end(va);
   62|       |
   63|  12.1k|    err->error.error_code = code;
   64|  12.1k|    if (ssh_get_log_level() == SSH_LOG_TRACE) {
  ------------------
  |  |  362|  12.1k|#define SSH_LOG_TRACE 4
  ------------------
  |  Branch (64:9): [True: 0, False: 12.1k]
  ------------------
   65|      0|        ssh_log_function(SSH_LOG_TRACE,
  ------------------
  |  |  362|      0|#define SSH_LOG_TRACE 4
  ------------------
   66|      0|                         function,
   67|      0|                         err->error.error_buffer);
   68|      0|    }
   69|  12.1k|}
_ssh_set_error_oom:
   81|    105|{
   82|    105|    struct error_struct *err = error;
   83|       |
   84|    105|    snprintf(err->error_buffer, sizeof(err->error_buffer),
   85|    105|            "%s: Out of memory", function);
   86|    105|    err->error_code = SSH_FATAL;
   87|    105|}
ssh_get_error:
  127|    241|const char *ssh_get_error(void *error) {
  128|    241|  struct error_struct *err = error;
  129|       |
  130|    241|  return err->error_buffer;
  131|    241|}

libcrux_ml_kem_mlkem768_portable_generate_key_pair:
 8762|     49|libcrux_ml_kem_mlkem768_portable_generate_key_pair(uint8_t randomness[64U]) {
 8763|     49|  return libcrux_ml_kem_ind_cca_instantiations_portable_generate_keypair_ce(
 8764|     49|      randomness);
 8765|     49|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_polynomial_ZERO_d6_ea:
 5317|  1.02k|libcrux_ml_kem_polynomial_ZERO_d6_ea(void) {
 5318|  1.02k|  libcrux_ml_kem_polynomial_PolynomialRingElement_1d lit;
 5319|  1.02k|  libcrux_ml_kem_vector_portable_vector_type_PortableVector
 5320|  1.02k|      repeat_expression[16U];
 5321|  17.4k|  for (size_t i = (size_t)0U; i < (size_t)16U; i++) {
  ------------------
  |  Branch (5321:31): [True: 16.4k, False: 1.02k]
  ------------------
 5322|  16.4k|    repeat_expression[i] = libcrux_ml_kem_vector_portable_ZERO_b8();
 5323|  16.4k|  }
 5324|  1.02k|  memcpy(lit.coefficients, repeat_expression,
 5325|  1.02k|         (size_t)16U *
 5326|  1.02k|             sizeof(libcrux_ml_kem_vector_portable_vector_type_PortableVector));
 5327|  1.02k|  return lit;
 5328|  1.02k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_vector_portable_ZERO_b8:
 3836|  35.2k|libcrux_ml_kem_vector_portable_ZERO_b8(void) {
 3837|  35.2k|  return libcrux_ml_kem_vector_portable_vector_type_zero();
 3838|  35.2k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_vector_portable_vector_type_zero:
 3822|  42.3k|libcrux_ml_kem_vector_portable_vector_type_zero(void) {
 3823|  42.3k|  libcrux_ml_kem_vector_portable_vector_type_PortableVector lit;
 3824|  42.3k|  int16_t ret[16U];
 3825|  42.3k|  int16_t buf[16U] = {0U};
 3826|  42.3k|  libcrux_secrets_int_public_integers_classify_27_46(buf, ret);
 3827|  42.3k|  memcpy(lit.elements, ret, (size_t)16U * sizeof(int16_t));
 3828|  42.3k|  return lit;
 3829|  42.3k|}
libcrux_mlkem768_sha3.c:libcrux_secrets_int_public_integers_classify_27_46:
 1075|  42.3k|    int16_t self[16U], int16_t ret[16U]) {
 1076|  42.3k|  memcpy(ret, self, (size_t)16U * sizeof(int16_t));
 1077|  42.3k|}
libcrux_mlkem768_sha3.c:libcrux_secrets_int_public_integers_classify_27_39:
  515|  2.45M|libcrux_secrets_int_public_integers_classify_27_39(int16_t self) {
  516|  2.45M|  return self;
  517|  2.45M|}
libcrux_mlkem768_sha3.c:libcrux_secrets_int_public_integers_declassify_d8_39:
  494|  2.61M|libcrux_secrets_int_public_integers_declassify_d8_39(int16_t self) {
  495|  2.61M|  return self;
  496|  2.61M|}
libcrux_mlkem768_sha3.c:libcrux_secrets_int_as_i32_f5:
  556|  2.50M|static KRML_MUSTINLINE int32_t libcrux_secrets_int_as_i32_f5(int16_t self) {
  557|  2.50M|  return libcrux_secrets_int_public_integers_classify_27_a8(
  558|  2.50M|      (int32_t)libcrux_secrets_int_public_integers_declassify_d8_39(self));
  559|  2.50M|}
libcrux_mlkem768_sha3.c:libcrux_secrets_int_public_integers_classify_27_a8:
  549|  2.93M|libcrux_secrets_int_public_integers_classify_27_a8(int32_t self) {
  550|  2.93M|  return self;
  551|  2.93M|}
libcrux_mlkem768_sha3.c:libcrux_secrets_int_as_i16_36:
  577|  1.84M|static KRML_MUSTINLINE int16_t libcrux_secrets_int_as_i16_36(int32_t self) {
  578|  1.84M|  return libcrux_secrets_int_public_integers_classify_27_39(
  579|  1.84M|      (int16_t)libcrux_secrets_int_public_integers_declassify_d8_a8(self));
  580|  1.84M|}
libcrux_mlkem768_sha3.c:libcrux_secrets_int_public_integers_declassify_d8_a8:
  570|  1.84M|libcrux_secrets_int_public_integers_declassify_d8_a8(int32_t self) {
  571|  1.84M|  return self;
  572|  1.84M|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_ntt_ntt_at_layer_4_plus_ea:
 5538|    882|    size_t layer, size_t _initial_coefficient_bound) {
 5539|    882|  size_t step = (size_t)1U << (uint32_t)layer;
 5540|  4.99k|  for (size_t i0 = (size_t)0U; i0 < (size_t)128U >> (uint32_t)layer; i0++) {
  ------------------
  |  Branch (5540:32): [True: 4.11k, False: 882]
  ------------------
 5541|  4.11k|    size_t round = i0;
 5542|  4.11k|    zeta_i[0U] = zeta_i[0U] + (size_t)1U;
 5543|  4.11k|    size_t offset = round * step * (size_t)2U;
 5544|  4.11k|    size_t offset_vec = offset / (size_t)16U;
 5545|  4.11k|    size_t step_vec = step / (size_t)16U;
 5546|  11.1k|    for (size_t i = offset_vec; i < offset_vec + step_vec; i++) {
  ------------------
  |  Branch (5546:33): [True: 7.05k, False: 4.11k]
  ------------------
 5547|  7.05k|      size_t j = i;
 5548|  7.05k|      libcrux_ml_kem_vector_portable_vector_type_PortableVector_x2 uu____0 =
 5549|  7.05k|          libcrux_ml_kem_ntt_ntt_layer_int_vec_step_ea(
 5550|  7.05k|              re->coefficients[j], re->coefficients[j + step_vec],
 5551|  7.05k|              libcrux_ml_kem_polynomial_zeta(zeta_i[0U]));
 5552|  7.05k|      libcrux_ml_kem_vector_portable_vector_type_PortableVector x = uu____0.fst;
 5553|  7.05k|      libcrux_ml_kem_vector_portable_vector_type_PortableVector y = uu____0.snd;
 5554|  7.05k|      re->coefficients[j] = x;
 5555|  7.05k|      re->coefficients[j + step_vec] = y;
 5556|  7.05k|    }
 5557|  4.11k|  }
 5558|    882|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_ntt_ntt_layer_int_vec_step_ea:
 5519|  7.05k|        int16_t zeta_r) {
 5520|  7.05k|  libcrux_ml_kem_vector_portable_vector_type_PortableVector t =
 5521|  7.05k|      libcrux_ml_kem_vector_portable_montgomery_multiply_by_constant_b8(b,
 5522|  7.05k|                                                                        zeta_r);
 5523|  7.05k|  b = libcrux_ml_kem_vector_portable_sub_b8(a, &t);
 5524|  7.05k|  a = libcrux_ml_kem_vector_portable_add_b8(a, &t);
 5525|  7.05k|  return (KRML_CLITERAL(
  ------------------
  |  |  154|  7.05k|#define KRML_CLITERAL(type) (type)
  ------------------
 5526|  7.05k|      libcrux_ml_kem_vector_portable_vector_type_PortableVector_x2){.fst = a,
 5527|  7.05k|                                                                    .snd = b});
 5528|  7.05k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_vector_portable_montgomery_multiply_by_constant_b8:
 4077|  9.40k|    int16_t constant) {
 4078|  9.40k|  return libcrux_ml_kem_vector_portable_arithmetic_montgomery_multiply_by_constant(
 4079|  9.40k|      vector, libcrux_secrets_int_public_integers_classify_27_39(constant));
 4080|  9.40k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_vector_portable_arithmetic_montgomery_multiply_by_constant:
 4059|  9.40k|    libcrux_ml_kem_vector_portable_vector_type_PortableVector vec, int16_t c) {
 4060|  9.40k|  for (size_t i = (size_t)0U;
 4061|   159k|       i < LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_ELEMENTS_IN_VECTOR; i++) {
  ------------------
  |  | 3772|   159k|#define LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_ELEMENTS_IN_VECTOR ((size_t)16U)
  ------------------
  |  Branch (4061:8): [True: 150k, False: 9.40k]
  ------------------
 4062|   150k|    size_t i0 = i;
 4063|   150k|    vec.elements[i0] =
 4064|   150k|        libcrux_ml_kem_vector_portable_arithmetic_montgomery_multiply_fe_by_fer(
 4065|   150k|            vec.elements[i0], c);
 4066|   150k|  }
 4067|  9.40k|  return vec;
 4068|  9.40k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_vector_portable_arithmetic_montgomery_multiply_fe_by_fer:
 4050|   263k|    int16_t fe, int16_t fer) {
 4051|   263k|  int32_t product =
 4052|   263k|      libcrux_secrets_int_as_i32_f5(fe) * libcrux_secrets_int_as_i32_f5(fer);
 4053|   263k|  return libcrux_ml_kem_vector_portable_arithmetic_montgomery_reduce_element(
 4054|   263k|      product);
 4055|   263k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_vector_portable_arithmetic_montgomery_reduce_element:
 4017|   432k|    int32_t value) {
 4018|   432k|  int32_t k =
 4019|   432k|      libcrux_secrets_int_as_i32_f5(libcrux_secrets_int_as_i16_36(value)) *
 4020|   432k|      libcrux_secrets_int_as_i32_b8(
 4021|   432k|          libcrux_secrets_int_public_integers_classify_27_df(
 4022|   432k|              LIBCRUX_ML_KEM_VECTOR_TRAITS_INVERSE_OF_MODULUS_MOD_MONTGOMERY_R));
  ------------------
  |  | 3780|   432k|  (62209U)
  ------------------
 4023|   432k|  int32_t k_times_modulus =
 4024|   432k|      libcrux_secrets_int_as_i32_f5(libcrux_secrets_int_as_i16_36(k)) *
 4025|   432k|      libcrux_secrets_int_as_i32_f5(
 4026|   432k|          libcrux_secrets_int_public_integers_classify_27_39(
 4027|   432k|              LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_MODULUS));
  ------------------
  |  | 3777|   432k|#define LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_MODULUS ((int16_t)3329)
  ------------------
 4028|   432k|  int16_t c = libcrux_secrets_int_as_i16_36(
 4029|   432k|      k_times_modulus >>
 4030|   432k|      (uint32_t)LIBCRUX_ML_KEM_VECTOR_PORTABLE_ARITHMETIC_MONTGOMERY_SHIFT);
  ------------------
  |  | 3997|   432k|#define LIBCRUX_ML_KEM_VECTOR_PORTABLE_ARITHMETIC_MONTGOMERY_SHIFT (16U)
  ------------------
 4031|   432k|  int16_t value_high = libcrux_secrets_int_as_i16_36(
 4032|   432k|      value >>
 4033|   432k|      (uint32_t)LIBCRUX_ML_KEM_VECTOR_PORTABLE_ARITHMETIC_MONTGOMERY_SHIFT);
  ------------------
  |  | 3997|   432k|#define LIBCRUX_ML_KEM_VECTOR_PORTABLE_ARITHMETIC_MONTGOMERY_SHIFT (16U)
  ------------------
 4034|   432k|  return value_high - c;
 4035|   432k|}
libcrux_mlkem768_sha3.c:libcrux_secrets_int_as_i32_b8:
  598|   432k|static KRML_MUSTINLINE int32_t libcrux_secrets_int_as_i32_b8(uint32_t self) {
  599|   432k|  return libcrux_secrets_int_public_integers_classify_27_a8(
  600|   432k|      (int32_t)libcrux_secrets_int_public_integers_declassify_d8_df(self));
  601|   432k|}
libcrux_mlkem768_sha3.c:libcrux_secrets_int_public_integers_declassify_d8_df:
  591|   432k|libcrux_secrets_int_public_integers_declassify_d8_df(uint32_t self) {
  592|   432k|  return self;
  593|   432k|}
libcrux_mlkem768_sha3.c:libcrux_secrets_int_public_integers_classify_27_df:
  675|   432k|libcrux_secrets_int_public_integers_classify_27_df(uint32_t self) {
  676|   432k|  return self;
  677|   432k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_vector_portable_sub_b8:
 3884|  9.40k|    libcrux_ml_kem_vector_portable_vector_type_PortableVector *rhs) {
 3885|  9.40k|  return libcrux_ml_kem_vector_portable_arithmetic_sub(lhs, rhs);
 3886|  9.40k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_vector_portable_arithmetic_sub:
 3867|  9.40k|    libcrux_ml_kem_vector_portable_vector_type_PortableVector *rhs) {
 3868|  9.40k|  for (size_t i = (size_t)0U;
 3869|   159k|       i < LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_ELEMENTS_IN_VECTOR; i++) {
  ------------------
  |  | 3772|   159k|#define LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_ELEMENTS_IN_VECTOR ((size_t)16U)
  ------------------
  |  Branch (3869:8): [True: 150k, False: 9.40k]
  ------------------
 3870|   150k|    size_t i0 = i;
 3871|   150k|    size_t uu____0 = i0;
 3872|   150k|    lhs.elements[uu____0] = lhs.elements[uu____0] - rhs->elements[i0];
 3873|   150k|  }
 3874|  9.40k|  return lhs;
 3875|  9.40k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_vector_portable_add_b8:
 3860|  18.8k|    libcrux_ml_kem_vector_portable_vector_type_PortableVector *rhs) {
 3861|  18.8k|  return libcrux_ml_kem_vector_portable_arithmetic_add(lhs, rhs);
 3862|  18.8k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_vector_portable_arithmetic_add:
 3843|  23.5k|    libcrux_ml_kem_vector_portable_vector_type_PortableVector *rhs) {
 3844|  23.5k|  for (size_t i = (size_t)0U;
 3845|   399k|       i < LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_ELEMENTS_IN_VECTOR; i++) {
  ------------------
  |  | 3772|   399k|#define LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_ELEMENTS_IN_VECTOR ((size_t)16U)
  ------------------
  |  Branch (3845:8): [True: 376k, False: 23.5k]
  ------------------
 3846|   376k|    size_t i0 = i;
 3847|   376k|    size_t uu____0 = i0;
 3848|   376k|    lhs.elements[uu____0] = lhs.elements[uu____0] + rhs->elements[i0];
 3849|   376k|  }
 3850|  23.5k|  return lhs;
 3851|  23.5k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_polynomial_zeta:
 3766|  68.2k|static KRML_MUSTINLINE int16_t libcrux_ml_kem_polynomial_zeta(size_t i) {
 3767|  68.2k|  return libcrux_ml_kem_polynomial_ZETAS_TIMES_MONTGOMERY_R[i];
 3768|  68.2k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_ntt_ntt_at_layer_3_ea:
 5568|    294|    size_t _initial_coefficient_bound) {
 5569|  4.99k|  for (size_t i = (size_t)0U; i < (size_t)16U; i++) {
  ------------------
  |  Branch (5569:31): [True: 4.70k, False: 294]
  ------------------
 5570|  4.70k|    size_t round = i;
 5571|  4.70k|    zeta_i[0U] = zeta_i[0U] + (size_t)1U;
 5572|  4.70k|    libcrux_ml_kem_vector_portable_vector_type_PortableVector uu____0 =
 5573|  4.70k|        libcrux_ml_kem_vector_portable_ntt_layer_3_step_b8(
 5574|  4.70k|            re->coefficients[round],
 5575|  4.70k|            libcrux_ml_kem_polynomial_zeta(zeta_i[0U]));
 5576|  4.70k|    re->coefficients[round] = uu____0;
 5577|  4.70k|  }
 5578|    294|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_vector_portable_ntt_layer_3_step_b8:
 4344|  4.70k|    libcrux_ml_kem_vector_portable_vector_type_PortableVector a, int16_t zeta) {
 4345|  4.70k|  return libcrux_ml_kem_vector_portable_ntt_ntt_layer_3_step(a, zeta);
 4346|  4.70k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_vector_portable_ntt_ntt_layer_3_step:
 4318|  4.70k|    int16_t zeta) {
 4319|  4.70k|  libcrux_ml_kem_vector_portable_ntt_ntt_step(&vec, zeta, (size_t)0U,
 4320|  4.70k|                                              (size_t)8U);
 4321|  4.70k|  libcrux_ml_kem_vector_portable_ntt_ntt_step(&vec, zeta, (size_t)1U,
 4322|  4.70k|                                              (size_t)9U);
 4323|  4.70k|  libcrux_ml_kem_vector_portable_ntt_ntt_step(&vec, zeta, (size_t)2U,
 4324|  4.70k|                                              (size_t)10U);
 4325|  4.70k|  libcrux_ml_kem_vector_portable_ntt_ntt_step(&vec, zeta, (size_t)3U,
 4326|  4.70k|                                              (size_t)11U);
 4327|  4.70k|  libcrux_ml_kem_vector_portable_ntt_ntt_step(&vec, zeta, (size_t)4U,
 4328|  4.70k|                                              (size_t)12U);
 4329|  4.70k|  libcrux_ml_kem_vector_portable_ntt_ntt_step(&vec, zeta, (size_t)5U,
 4330|  4.70k|                                              (size_t)13U);
 4331|  4.70k|  libcrux_ml_kem_vector_portable_ntt_ntt_step(&vec, zeta, (size_t)6U,
 4332|  4.70k|                                              (size_t)14U);
 4333|  4.70k|  libcrux_ml_kem_vector_portable_ntt_ntt_step(&vec, zeta, (size_t)7U,
 4334|  4.70k|                                              (size_t)15U);
 4335|  4.70k|  return vec;
 4336|  4.70k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_vector_portable_ntt_ntt_step:
 4235|   112k|    int16_t zeta, size_t i, size_t j) {
 4236|   112k|  int16_t t =
 4237|   112k|      libcrux_ml_kem_vector_portable_arithmetic_montgomery_multiply_fe_by_fer(
 4238|   112k|          vec->elements[j],
 4239|   112k|          libcrux_secrets_int_public_integers_classify_27_39(zeta));
 4240|   112k|  int16_t a_minus_t = vec->elements[i] - t;
 4241|   112k|  int16_t a_plus_t = vec->elements[i] + t;
 4242|   112k|  vec->elements[j] = a_minus_t;
 4243|   112k|  vec->elements[i] = a_plus_t;
 4244|   112k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_ntt_ntt_at_layer_2_ea:
 5588|    294|    size_t _initial_coefficient_bound) {
 5589|  4.99k|  for (size_t i = (size_t)0U; i < (size_t)16U; i++) {
  ------------------
  |  Branch (5589:31): [True: 4.70k, False: 294]
  ------------------
 5590|  4.70k|    size_t round = i;
 5591|  4.70k|    zeta_i[0U] = zeta_i[0U] + (size_t)1U;
 5592|  4.70k|    re->coefficients[round] =
 5593|  4.70k|        libcrux_ml_kem_vector_portable_ntt_layer_2_step_b8(
 5594|  4.70k|            re->coefficients[round], libcrux_ml_kem_polynomial_zeta(zeta_i[0U]),
 5595|  4.70k|            libcrux_ml_kem_polynomial_zeta(zeta_i[0U] + (size_t)1U));
 5596|  4.70k|    zeta_i[0U] = zeta_i[0U] + (size_t)1U;
 5597|  4.70k|  }
 5598|    294|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_vector_portable_ntt_layer_2_step_b8:
 4311|  4.70k|    int16_t zeta1) {
 4312|  4.70k|  return libcrux_ml_kem_vector_portable_ntt_ntt_layer_2_step(a, zeta0, zeta1);
 4313|  4.70k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_vector_portable_ntt_ntt_layer_2_step:
 4284|  4.70k|    int16_t zeta0, int16_t zeta1) {
 4285|  4.70k|  libcrux_ml_kem_vector_portable_ntt_ntt_step(&vec, zeta0, (size_t)0U,
 4286|  4.70k|                                              (size_t)4U);
 4287|  4.70k|  libcrux_ml_kem_vector_portable_ntt_ntt_step(&vec, zeta0, (size_t)1U,
 4288|  4.70k|                                              (size_t)5U);
 4289|  4.70k|  libcrux_ml_kem_vector_portable_ntt_ntt_step(&vec, zeta0, (size_t)2U,
 4290|  4.70k|                                              (size_t)6U);
 4291|  4.70k|  libcrux_ml_kem_vector_portable_ntt_ntt_step(&vec, zeta0, (size_t)3U,
 4292|  4.70k|                                              (size_t)7U);
 4293|  4.70k|  libcrux_ml_kem_vector_portable_ntt_ntt_step(&vec, zeta1, (size_t)8U,
 4294|  4.70k|                                              (size_t)12U);
 4295|  4.70k|  libcrux_ml_kem_vector_portable_ntt_ntt_step(&vec, zeta1, (size_t)9U,
 4296|  4.70k|                                              (size_t)13U);
 4297|  4.70k|  libcrux_ml_kem_vector_portable_ntt_ntt_step(&vec, zeta1, (size_t)10U,
 4298|  4.70k|                                              (size_t)14U);
 4299|  4.70k|  libcrux_ml_kem_vector_portable_ntt_ntt_step(&vec, zeta1, (size_t)11U,
 4300|  4.70k|                                              (size_t)15U);
 4301|  4.70k|  return vec;
 4302|  4.70k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_ntt_ntt_at_layer_1_ea:
 5608|    294|    size_t _initial_coefficient_bound) {
 5609|  4.99k|  for (size_t i = (size_t)0U; i < (size_t)16U; i++) {
  ------------------
  |  Branch (5609:31): [True: 4.70k, False: 294]
  ------------------
 5610|  4.70k|    size_t round = i;
 5611|  4.70k|    zeta_i[0U] = zeta_i[0U] + (size_t)1U;
 5612|  4.70k|    re->coefficients[round] =
 5613|  4.70k|        libcrux_ml_kem_vector_portable_ntt_layer_1_step_b8(
 5614|  4.70k|            re->coefficients[round], libcrux_ml_kem_polynomial_zeta(zeta_i[0U]),
 5615|  4.70k|            libcrux_ml_kem_polynomial_zeta(zeta_i[0U] + (size_t)1U),
 5616|  4.70k|            libcrux_ml_kem_polynomial_zeta(zeta_i[0U] + (size_t)2U),
 5617|  4.70k|            libcrux_ml_kem_polynomial_zeta(zeta_i[0U] + (size_t)3U));
 5618|  4.70k|    zeta_i[0U] = zeta_i[0U] + (size_t)3U;
 5619|  4.70k|  }
 5620|    294|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_vector_portable_ntt_layer_1_step_b8:
 4276|  4.70k|    int16_t zeta1, int16_t zeta2, int16_t zeta3) {
 4277|  4.70k|  return libcrux_ml_kem_vector_portable_ntt_ntt_layer_1_step(a, zeta0, zeta1,
 4278|  4.70k|                                                             zeta2, zeta3);
 4279|  4.70k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_vector_portable_ntt_ntt_layer_1_step:
 4249|  4.70k|    int16_t zeta0, int16_t zeta1, int16_t zeta2, int16_t zeta3) {
 4250|  4.70k|  libcrux_ml_kem_vector_portable_ntt_ntt_step(&vec, zeta0, (size_t)0U,
 4251|  4.70k|                                              (size_t)2U);
 4252|  4.70k|  libcrux_ml_kem_vector_portable_ntt_ntt_step(&vec, zeta0, (size_t)1U,
 4253|  4.70k|                                              (size_t)3U);
 4254|  4.70k|  libcrux_ml_kem_vector_portable_ntt_ntt_step(&vec, zeta1, (size_t)4U,
 4255|  4.70k|                                              (size_t)6U);
 4256|  4.70k|  libcrux_ml_kem_vector_portable_ntt_ntt_step(&vec, zeta1, (size_t)5U,
 4257|  4.70k|                                              (size_t)7U);
 4258|  4.70k|  libcrux_ml_kem_vector_portable_ntt_ntt_step(&vec, zeta2, (size_t)8U,
 4259|  4.70k|                                              (size_t)10U);
 4260|  4.70k|  libcrux_ml_kem_vector_portable_ntt_ntt_step(&vec, zeta2, (size_t)9U,
 4261|  4.70k|                                              (size_t)11U);
 4262|  4.70k|  libcrux_ml_kem_vector_portable_ntt_ntt_step(&vec, zeta3, (size_t)12U,
 4263|  4.70k|                                              (size_t)14U);
 4264|  4.70k|  libcrux_ml_kem_vector_portable_ntt_ntt_step(&vec, zeta3, (size_t)13U,
 4265|  4.70k|                                              (size_t)15U);
 4266|  4.70k|  return vec;
 4267|  4.70k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_polynomial_poly_barrett_reduce_d6_ea:
 5652|    294|    libcrux_ml_kem_polynomial_PolynomialRingElement_1d *self) {
 5653|    294|  libcrux_ml_kem_polynomial_poly_barrett_reduce_ea(self);
 5654|    294|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_polynomial_poly_barrett_reduce_ea:
 5629|    294|    libcrux_ml_kem_polynomial_PolynomialRingElement_1d *myself) {
 5630|    294|  for (size_t i = (size_t)0U;
 5631|  4.99k|       i < LIBCRUX_ML_KEM_POLYNOMIAL_VECTORS_IN_RING_ELEMENT; i++) {
  ------------------
  |  | 3770|  4.99k|#define LIBCRUX_ML_KEM_POLYNOMIAL_VECTORS_IN_RING_ELEMENT ((size_t)16U)
  ------------------
  |  Branch (5631:8): [True: 4.70k, False: 294]
  ------------------
 5632|  4.70k|    size_t i0 = i;
 5633|  4.70k|    libcrux_ml_kem_vector_portable_vector_type_PortableVector uu____0 =
 5634|  4.70k|        libcrux_ml_kem_vector_portable_barrett_reduce_b8(
 5635|  4.70k|            myself->coefficients[i0]);
 5636|  4.70k|    myself->coefficients[i0] = uu____0;
 5637|  4.70k|  }
 5638|    294|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_vector_portable_barrett_reduce_b8:
 3993|  7.05k|    libcrux_ml_kem_vector_portable_vector_type_PortableVector vector) {
 3994|  7.05k|  return libcrux_ml_kem_vector_portable_arithmetic_barrett_reduce(vector);
 3995|  7.05k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_vector_portable_arithmetic_barrett_reduce:
 3975|  7.05k|    libcrux_ml_kem_vector_portable_vector_type_PortableVector vec) {
 3976|  7.05k|  for (size_t i = (size_t)0U;
 3977|   119k|       i < LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_ELEMENTS_IN_VECTOR; i++) {
  ------------------
  |  | 3772|   119k|#define LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_ELEMENTS_IN_VECTOR ((size_t)16U)
  ------------------
  |  Branch (3977:8): [True: 112k, False: 7.05k]
  ------------------
 3978|   112k|    size_t i0 = i;
 3979|   112k|    int16_t vi =
 3980|   112k|        libcrux_ml_kem_vector_portable_arithmetic_barrett_reduce_element(
 3981|   112k|            vec.elements[i0]);
 3982|   112k|    vec.elements[i0] = vi;
 3983|   112k|  }
 3984|  7.05k|  return vec;
 3985|  7.05k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_vector_portable_arithmetic_barrett_reduce_element:
 3964|   112k|    int16_t value) {
 3965|   112k|  int32_t t = libcrux_secrets_int_as_i32_f5(value) *
 3966|   112k|                  LIBCRUX_ML_KEM_VECTOR_PORTABLE_ARITHMETIC_BARRETT_MULTIPLIER +
  ------------------
  |  | 3940|   112k|  ((int32_t)20159)
  ------------------
 3967|   112k|              (LIBCRUX_ML_KEM_VECTOR_TRAITS_BARRETT_R >> 1U);
  ------------------
  |  | 3945|   112k|  ((int32_t)1 << (uint32_t)LIBCRUX_ML_KEM_VECTOR_TRAITS_BARRETT_SHIFT)
  |  |  ------------------
  |  |  |  | 3942|   112k|#define LIBCRUX_ML_KEM_VECTOR_TRAITS_BARRETT_SHIFT ((int32_t)26)
  |  |  ------------------
  ------------------
 3968|   112k|  int16_t quotient = libcrux_secrets_int_as_i16_36(
 3969|   112k|      t >> (uint32_t)LIBCRUX_ML_KEM_VECTOR_TRAITS_BARRETT_SHIFT);
  ------------------
  |  | 3942|   112k|#define LIBCRUX_ML_KEM_VECTOR_TRAITS_BARRETT_SHIFT ((int32_t)26)
  ------------------
 3970|   112k|  return value - quotient * LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_MODULUS;
  ------------------
  |  | 3777|   112k|#define LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_MODULUS ((int16_t)3329)
  ------------------
 3971|   112k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_polynomial_ntt_multiply_d6_ea:
 5901|    441|    libcrux_ml_kem_polynomial_PolynomialRingElement_1d *rhs) {
 5902|    441|  return libcrux_ml_kem_polynomial_ntt_multiply_ea(self, rhs);
 5903|    441|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_polynomial_ntt_multiply_ea:
 5866|    441|    libcrux_ml_kem_polynomial_PolynomialRingElement_1d *rhs) {
 5867|    441|  libcrux_ml_kem_polynomial_PolynomialRingElement_1d out =
 5868|    441|      libcrux_ml_kem_polynomial_ZERO_ea();
 5869|    441|  for (size_t i = (size_t)0U;
 5870|  7.49k|       i < LIBCRUX_ML_KEM_POLYNOMIAL_VECTORS_IN_RING_ELEMENT; i++) {
  ------------------
  |  | 3770|  7.49k|#define LIBCRUX_ML_KEM_POLYNOMIAL_VECTORS_IN_RING_ELEMENT ((size_t)16U)
  ------------------
  |  Branch (5870:8): [True: 7.05k, False: 441]
  ------------------
 5871|  7.05k|    size_t i0 = i;
 5872|  7.05k|    libcrux_ml_kem_vector_portable_vector_type_PortableVector uu____0 =
 5873|  7.05k|        libcrux_ml_kem_vector_portable_ntt_multiply_b8(
 5874|  7.05k|            &myself->coefficients[i0], &rhs->coefficients[i0],
 5875|  7.05k|            libcrux_ml_kem_polynomial_zeta((size_t)64U + (size_t)4U * i0),
 5876|  7.05k|            libcrux_ml_kem_polynomial_zeta((size_t)64U + (size_t)4U * i0 +
 5877|  7.05k|                                           (size_t)1U),
 5878|  7.05k|            libcrux_ml_kem_polynomial_zeta((size_t)64U + (size_t)4U * i0 +
 5879|  7.05k|                                           (size_t)2U),
 5880|  7.05k|            libcrux_ml_kem_polynomial_zeta((size_t)64U + (size_t)4U * i0 +
 5881|  7.05k|                                           (size_t)3U));
 5882|  7.05k|    out.coefficients[i0] = uu____0;
 5883|  7.05k|  }
 5884|    441|  return out;
 5885|    441|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_polynomial_ZERO_ea:
 5817|  1.17k|libcrux_ml_kem_polynomial_ZERO_ea(void) {
 5818|  1.17k|  libcrux_ml_kem_polynomial_PolynomialRingElement_1d lit;
 5819|  1.17k|  libcrux_ml_kem_vector_portable_vector_type_PortableVector
 5820|  1.17k|      repeat_expression[16U];
 5821|  19.9k|  for (size_t i = (size_t)0U; i < (size_t)16U; i++) {
  ------------------
  |  Branch (5821:31): [True: 18.8k, False: 1.17k]
  ------------------
 5822|  18.8k|    repeat_expression[i] = libcrux_ml_kem_vector_portable_ZERO_b8();
 5823|  18.8k|  }
 5824|  1.17k|  memcpy(lit.coefficients, repeat_expression,
 5825|  1.17k|         (size_t)16U *
 5826|  1.17k|             sizeof(libcrux_ml_kem_vector_portable_vector_type_PortableVector));
 5827|  1.17k|  return lit;
 5828|  1.17k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_vector_portable_ntt_multiply_b8:
 4567|  7.05k|    int16_t zeta0, int16_t zeta1, int16_t zeta2, int16_t zeta3) {
 4568|  7.05k|  return libcrux_ml_kem_vector_portable_ntt_ntt_multiply(lhs, rhs, zeta0, zeta1,
 4569|  7.05k|                                                         zeta2, zeta3);
 4570|  7.05k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_vector_portable_ntt_ntt_multiply:
 4525|  7.05k|    int16_t zeta0, int16_t zeta1, int16_t zeta2, int16_t zeta3) {
 4526|  7.05k|  int16_t nzeta0 = -zeta0;
 4527|  7.05k|  int16_t nzeta1 = -zeta1;
 4528|  7.05k|  int16_t nzeta2 = -zeta2;
 4529|  7.05k|  int16_t nzeta3 = -zeta3;
 4530|  7.05k|  libcrux_ml_kem_vector_portable_vector_type_PortableVector out =
 4531|  7.05k|      libcrux_ml_kem_vector_portable_vector_type_zero();
 4532|  7.05k|  libcrux_ml_kem_vector_portable_ntt_ntt_multiply_binomials(
 4533|  7.05k|      lhs, rhs, libcrux_secrets_int_public_integers_classify_27_39(zeta0),
 4534|  7.05k|      (size_t)0U, &out);
 4535|  7.05k|  libcrux_ml_kem_vector_portable_ntt_ntt_multiply_binomials(
 4536|  7.05k|      lhs, rhs, libcrux_secrets_int_public_integers_classify_27_39(nzeta0),
 4537|  7.05k|      (size_t)1U, &out);
 4538|  7.05k|  libcrux_ml_kem_vector_portable_ntt_ntt_multiply_binomials(
 4539|  7.05k|      lhs, rhs, libcrux_secrets_int_public_integers_classify_27_39(zeta1),
 4540|  7.05k|      (size_t)2U, &out);
 4541|  7.05k|  libcrux_ml_kem_vector_portable_ntt_ntt_multiply_binomials(
 4542|  7.05k|      lhs, rhs, libcrux_secrets_int_public_integers_classify_27_39(nzeta1),
 4543|  7.05k|      (size_t)3U, &out);
 4544|  7.05k|  libcrux_ml_kem_vector_portable_ntt_ntt_multiply_binomials(
 4545|  7.05k|      lhs, rhs, libcrux_secrets_int_public_integers_classify_27_39(zeta2),
 4546|  7.05k|      (size_t)4U, &out);
 4547|  7.05k|  libcrux_ml_kem_vector_portable_ntt_ntt_multiply_binomials(
 4548|  7.05k|      lhs, rhs, libcrux_secrets_int_public_integers_classify_27_39(nzeta2),
 4549|  7.05k|      (size_t)5U, &out);
 4550|  7.05k|  libcrux_ml_kem_vector_portable_ntt_ntt_multiply_binomials(
 4551|  7.05k|      lhs, rhs, libcrux_secrets_int_public_integers_classify_27_39(zeta3),
 4552|  7.05k|      (size_t)6U, &out);
 4553|  7.05k|  libcrux_ml_kem_vector_portable_ntt_ntt_multiply_binomials(
 4554|  7.05k|      lhs, rhs, libcrux_secrets_int_public_integers_classify_27_39(nzeta3),
 4555|  7.05k|      (size_t)7U, &out);
 4556|  7.05k|  return out;
 4557|  7.05k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_vector_portable_ntt_ntt_multiply_binomials:
 4491|  56.4k|    size_t i, libcrux_ml_kem_vector_portable_vector_type_PortableVector *out) {
 4492|  56.4k|  int16_t ai = a->elements[(size_t)2U * i];
 4493|  56.4k|  int16_t bi = b->elements[(size_t)2U * i];
 4494|  56.4k|  int16_t aj = a->elements[(size_t)2U * i + (size_t)1U];
 4495|  56.4k|  int16_t bj = b->elements[(size_t)2U * i + (size_t)1U];
 4496|  56.4k|  int32_t ai_bi =
 4497|  56.4k|      libcrux_secrets_int_as_i32_f5(ai) * libcrux_secrets_int_as_i32_f5(bi);
 4498|  56.4k|  int32_t aj_bj_ =
 4499|  56.4k|      libcrux_secrets_int_as_i32_f5(aj) * libcrux_secrets_int_as_i32_f5(bj);
 4500|  56.4k|  int16_t aj_bj =
 4501|  56.4k|      libcrux_ml_kem_vector_portable_arithmetic_montgomery_reduce_element(
 4502|  56.4k|          aj_bj_);
 4503|  56.4k|  int32_t aj_bj_zeta = libcrux_secrets_int_as_i32_f5(aj_bj) *
 4504|  56.4k|                       libcrux_secrets_int_as_i32_f5(zeta);
 4505|  56.4k|  int32_t ai_bi_aj_bj = ai_bi + aj_bj_zeta;
 4506|  56.4k|  int16_t o0 =
 4507|  56.4k|      libcrux_ml_kem_vector_portable_arithmetic_montgomery_reduce_element(
 4508|  56.4k|          ai_bi_aj_bj);
 4509|  56.4k|  int32_t ai_bj =
 4510|  56.4k|      libcrux_secrets_int_as_i32_f5(ai) * libcrux_secrets_int_as_i32_f5(bj);
 4511|  56.4k|  int32_t aj_bi =
 4512|  56.4k|      libcrux_secrets_int_as_i32_f5(aj) * libcrux_secrets_int_as_i32_f5(bi);
 4513|  56.4k|  int32_t ai_bj_aj_bi = ai_bj + aj_bi;
 4514|  56.4k|  int16_t o1 =
 4515|  56.4k|      libcrux_ml_kem_vector_portable_arithmetic_montgomery_reduce_element(
 4516|  56.4k|          ai_bj_aj_bi);
 4517|  56.4k|  out->elements[(size_t)2U * i] = o0;
 4518|  56.4k|  out->elements[(size_t)2U * i + (size_t)1U] = o1;
 4519|  56.4k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_polynomial_add_to_ring_element_d6_1b:
 5946|    441|    libcrux_ml_kem_polynomial_PolynomialRingElement_1d *rhs) {
 5947|    441|  libcrux_ml_kem_polynomial_add_to_ring_element_1b(self, rhs);
 5948|    441|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_polynomial_add_to_ring_element_1b:
 5917|    441|    libcrux_ml_kem_polynomial_PolynomialRingElement_1d *rhs) {
 5918|    441|  for (size_t i = (size_t)0U;
 5919|  7.49k|       i < Eurydice_slice_len(
  ------------------
  |  |  173|  7.49k|#define Eurydice_slice_len(s, _) (s).len
  ------------------
  |  Branch (5919:8): [True: 7.05k, False: 441]
  ------------------
 5920|    441|               Eurydice_array_to_slice(
 5921|    441|                   (size_t)16U, myself->coefficients,
 5922|    441|                   libcrux_ml_kem_vector_portable_vector_type_PortableVector),
 5923|    441|               libcrux_ml_kem_vector_portable_vector_type_PortableVector);
 5924|  7.05k|       i++) {
 5925|  7.05k|    size_t i0 = i;
 5926|  7.05k|    libcrux_ml_kem_vector_portable_vector_type_PortableVector uu____0 =
 5927|  7.05k|        libcrux_ml_kem_vector_portable_add_b8(myself->coefficients[i0],
 5928|  7.05k|                                              &rhs->coefficients[i0]);
 5929|  7.05k|    myself->coefficients[i0] = uu____0;
 5930|  7.05k|  }
 5931|    441|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_serialize_to_unsigned_field_modulus_ea:
 6172|  4.70k|    libcrux_ml_kem_vector_portable_vector_type_PortableVector a) {
 6173|  4.70k|  return libcrux_ml_kem_vector_portable_to_unsigned_representative_b8(a);
 6174|  4.70k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_vector_portable_to_unsigned_representative_b8:
 4127|  4.70k|    libcrux_ml_kem_vector_portable_vector_type_PortableVector a) {
 4128|  4.70k|  return libcrux_ml_kem_vector_portable_arithmetic_to_unsigned_representative(
 4129|  4.70k|      a);
 4130|  4.70k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_vector_portable_arithmetic_to_unsigned_representative:
 4112|  4.70k|    libcrux_ml_kem_vector_portable_vector_type_PortableVector a) {
 4113|  4.70k|  libcrux_ml_kem_vector_portable_vector_type_PortableVector t =
 4114|  4.70k|      libcrux_ml_kem_vector_portable_arithmetic_shift_right_ef(a);
 4115|  4.70k|  libcrux_ml_kem_vector_portable_vector_type_PortableVector fm =
 4116|  4.70k|      libcrux_ml_kem_vector_portable_arithmetic_bitwise_and_with_constant(
 4117|  4.70k|          t, LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_MODULUS);
  ------------------
  |  | 3777|  4.70k|#define LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_MODULUS ((int16_t)3329)
  ------------------
 4118|  4.70k|  return libcrux_ml_kem_vector_portable_arithmetic_add(a, &fm);
 4119|  4.70k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_vector_portable_arithmetic_shift_right_ef:
 4101|  4.70k|    libcrux_ml_kem_vector_portable_vector_type_PortableVector vec) {
 4102|  4.70k|  for (size_t i = (size_t)0U;
 4103|  79.9k|       i < LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_ELEMENTS_IN_VECTOR; i++) {
  ------------------
  |  | 3772|  79.9k|#define LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_ELEMENTS_IN_VECTOR ((size_t)16U)
  ------------------
  |  Branch (4103:8): [True: 75.2k, False: 4.70k]
  ------------------
 4104|  75.2k|    size_t i0 = i;
 4105|  75.2k|    vec.elements[i0] = vec.elements[i0] >> (uint32_t)(int32_t)15;
 4106|  75.2k|  }
 4107|  4.70k|  return vec;
 4108|  4.70k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_vector_portable_arithmetic_bitwise_and_with_constant:
 4084|  4.70k|    libcrux_ml_kem_vector_portable_vector_type_PortableVector vec, int16_t c) {
 4085|  4.70k|  for (size_t i = (size_t)0U;
 4086|  79.9k|       i < LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_ELEMENTS_IN_VECTOR; i++) {
  ------------------
  |  | 3772|  79.9k|#define LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_ELEMENTS_IN_VECTOR ((size_t)16U)
  ------------------
  |  Branch (4086:8): [True: 75.2k, False: 4.70k]
  ------------------
 4087|  75.2k|    size_t i0 = i;
 4088|  75.2k|    size_t uu____0 = i0;
 4089|  75.2k|    vec.elements[uu____0] = vec.elements[uu____0] & c;
 4090|  75.2k|  }
 4091|  4.70k|  return vec;
 4092|  4.70k|}
libcrux_mlkem768_sha3.c:libcrux_secrets_int_as_u8_f5:
  501|   112k|static KRML_MUSTINLINE uint8_t libcrux_secrets_int_as_u8_f5(int16_t self) {
  502|   112k|  return libcrux_secrets_int_public_integers_classify_27_90(
  503|   112k|      (uint8_t)libcrux_secrets_int_public_integers_declassify_d8_39(self));
  504|   112k|}
libcrux_mlkem768_sha3.c:libcrux_secrets_int_public_integers_classify_27_90:
  481|   112k|libcrux_secrets_int_public_integers_classify_27_90(uint8_t self) {
  482|   112k|  return self;
  483|   112k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_hash_functions_portable_G_4a_e0:
 6298|     49|    Eurydice_slice input, uint8_t ret[64U]) {
 6299|     49|  libcrux_ml_kem_hash_functions_portable_G(input, ret);
 6300|     49|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_hash_functions_portable_G:
 3717|     49|    Eurydice_slice input, uint8_t ret[64U]) {
 3718|     49|  uint8_t digest[64U] = {0U};
 3719|     49|  libcrux_sha3_portable_sha512(
 3720|     49|      Eurydice_array_to_slice((size_t)64U, digest, uint8_t), input);
  ------------------
  |  |  204|     49|  EURYDICE_SLICE(x, 0,                     \
  |  |  ------------------
  |  |  |  |  169|     49|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|     49|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  205|     49|                 end) /* x is already at an array type, no need for cast */
  ------------------
 3721|     49|  memcpy(ret, digest, (size_t)64U * sizeof(uint8_t));
 3722|     49|}
libcrux_mlkem768_sha3.c:libcrux_sha3_portable_sha512:
 3128|     49|                                                         Eurydice_slice data) {
 3129|     49|  libcrux_sha3_generic_keccak_portable_keccak1_96(data, digest);
 3130|     49|}
libcrux_mlkem768_sha3.c:libcrux_sha3_generic_keccak_portable_keccak1_96:
 3092|     49|    Eurydice_slice data, Eurydice_slice out) {
 3093|     49|  libcrux_sha3_generic_keccak_KeccakState_17 s =
 3094|     49|      libcrux_sha3_generic_keccak_new_80_04();
 3095|     49|  size_t data_len = Eurydice_slice_len(data, uint8_t);
  ------------------
  |  |  173|     49|#define Eurydice_slice_len(s, _) (s).len
  ------------------
 3096|     49|  for (size_t i = (size_t)0U; i < data_len / (size_t)72U; i++) {
  ------------------
  |  Branch (3096:31): [True: 0, False: 49]
  ------------------
 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|     49|  size_t rem = data_len % (size_t)72U;
 3102|     49|  Eurydice_slice buf[1U] = {data};
 3103|     49|  libcrux_sha3_generic_keccak_absorb_final_80_9e(&s, buf, data_len - rem, rem);
 3104|     49|  size_t outlen = Eurydice_slice_len(out, uint8_t);
  ------------------
  |  |  173|     49|#define Eurydice_slice_len(s, _) (s).len
  ------------------
 3105|     49|  size_t blocks = outlen / (size_t)72U;
 3106|     49|  size_t last = outlen - outlen % (size_t)72U;
 3107|     49|  if (blocks == (size_t)0U) {
  ------------------
  |  Branch (3107:7): [True: 49, False: 0]
  ------------------
 3108|     49|    libcrux_sha3_simd_portable_squeeze_13_f8(&s, out, (size_t)0U, outlen);
 3109|     49|  } 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|     49|}
libcrux_mlkem768_sha3.c:libcrux_sha3_generic_keccak_new_80_04:
 1449|    833|libcrux_sha3_generic_keccak_new_80_04(void) {
 1450|    833|  libcrux_sha3_generic_keccak_KeccakState_17 lit;
 1451|    833|  uint64_t repeat_expression[25U];
 1452|  21.6k|  for (size_t i = (size_t)0U; i < (size_t)25U; i++) {
  ------------------
  |  Branch (1452:31): [True: 20.8k, False: 833]
  ------------------
 1453|  20.8k|    repeat_expression[i] = libcrux_sha3_simd_portable_zero_d2();
 1454|  20.8k|  }
 1455|    833|  memcpy(lit.st, repeat_expression, (size_t)25U * sizeof(uint64_t));
 1456|    833|  return lit;
 1457|    833|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_zero_d2:
 1320|  20.8k|static KRML_MUSTINLINE uint64_t libcrux_sha3_simd_portable_zero_d2(void) {
 1321|  20.8k|  return 0ULL;
 1322|  20.8k|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_load_block_f8:
 1489|     49|    uint64_t *state, Eurydice_slice blocks, size_t start) {
 1490|     49|  uint64_t state_flat[25U] = {0U};
 1491|    490|  for (size_t i = (size_t)0U; i < (size_t)72U / (size_t)8U; i++) {
  ------------------
  |  Branch (1491:31): [True: 441, False: 49]
  ------------------
 1492|    441|    size_t i0 = i;
 1493|    441|    size_t offset = start + (size_t)8U * i0;
 1494|    441|    uint8_t uu____0[8U];
 1495|    441|    Result_15 dst;
 1496|    441|    Eurydice_slice_to_array2(
  ------------------
  |  |  277|    441|  Eurydice_slice_to_array3(&(dst)->tag, (char *)&(dst)->val.case_Ok, src, \
  |  |  278|    441|                           sizeof(t_arr))
  ------------------
 1497|    441|        &dst,
 1498|    441|        Eurydice_slice_subslice3(blocks, offset, offset + (size_t)8U,
 1499|    441|                                 uint8_t *),
 1500|    441|        Eurydice_slice, uint8_t[8U], TryFromSliceError);
 1501|    441|    unwrap_26_68(dst, uu____0);
 1502|    441|    state_flat[i0] = core_num__u64__from_le_bytes(uu____0);
 1503|    441|  }
 1504|    490|  for (size_t i = (size_t)0U; i < (size_t)72U / (size_t)8U; i++) {
  ------------------
  |  Branch (1504:31): [True: 441, False: 49]
  ------------------
 1505|    441|    size_t i0 = i;
 1506|    441|    libcrux_sha3_traits_set_ij_04(
 1507|    441|        state, i0 / (size_t)5U, i0 % (size_t)5U,
 1508|    441|        libcrux_sha3_traits_get_ij_04(state, i0 / (size_t)5U,
 1509|    441|                                      i0 % (size_t)5U)[0U] ^
 1510|    441|            state_flat[i0]);
 1511|    441|  }
 1512|     49|}
libcrux_mlkem768_sha3.c:Eurydice_slice_to_array3:
  281|  34.0k|                                            Eurydice_slice src, size_t sz) {
  282|  34.0k|  *dst_tag = 0;
  283|  34.0k|  memcpy(dst_ok, src.ptr, sz);
  284|  34.0k|}
libcrux_mlkem768_sha3.c:unwrap_26_68:
 1163|  22.1k|static inline void unwrap_26_68(Result_15 self, uint8_t ret[8U]) {
 1164|  22.1k|  if (self.tag == Ok) {
  ------------------
  |  |  721|  22.1k|#define Ok 0
  ------------------
  |  Branch (1164:7): [True: 22.1k, False: 0]
  ------------------
 1165|  22.1k|    uint8_t f0[8U];
 1166|  22.1k|    memcpy(f0, self.val.case_Ok, (size_t)8U * sizeof(uint8_t));
 1167|  22.1k|    memcpy(ret, f0, (size_t)8U * sizeof(uint8_t));
 1168|  22.1k|  } 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|  22.1k|}
libcrux_mlkem768_sha3.c:core_num__u64__from_le_bytes:
  331|  22.1k|static inline uint64_t core_num__u64__from_le_bytes(uint8_t buf[8]) {
  332|  22.1k|  return load64_le(buf);
  333|  22.1k|}
libcrux_mlkem768_sha3.c:load64_le:
   61|  22.1k|{
   62|  22.1k|	return (uint64_t)(src[0]) |
   63|  22.1k|	    ((uint64_t)(src[1]) << 8) |
   64|  22.1k|	    ((uint64_t)(src[2]) << 16) |
   65|  22.1k|	    ((uint64_t)(src[3]) << 24) |
   66|  22.1k|	    ((uint64_t)(src[4]) << 32) |
   67|  22.1k|	    ((uint64_t)(src[5]) << 40) |
   68|  22.1k|	    ((uint64_t)(src[6]) << 48) |
   69|  22.1k|	    ((uint64_t)(src[7]) << 56);
   70|  22.1k|}
libcrux_mlkem768_sha3.c:libcrux_sha3_traits_set_ij_04:
 1479|  3.84M|                                                          uint64_t value) {
 1480|  3.84M|  arr[(size_t)5U * j + i] = value;
 1481|  3.84M|}
libcrux_mlkem768_sha3.c:libcrux_sha3_traits_get_ij_04:
 1467|  7.69M|                                                               size_t j) {
 1468|  7.69M|  return &arr[(size_t)5U * j + i];
 1469|  7.69M|}
libcrux_mlkem768_sha3.c:libcrux_sha3_generic_keccak_absorb_final_80_9e:
 3027|     49|    size_t start, size_t len) {
 3028|     49|  libcrux_sha3_simd_portable_load_last_a1_96(self, last, start, len);
 3029|     49|  libcrux_sha3_generic_keccak_keccakf1600_80_04(self);
 3030|     49|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_load_last_a1_96:
 3009|     49|    size_t start, size_t len) {
 3010|     49|  libcrux_sha3_simd_portable_load_last_96(self->st, input[0U], start, len);
 3011|     49|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_load_last_96:
 2983|     49|    uint64_t *state, Eurydice_slice blocks, size_t start, size_t len) {
 2984|     49|  uint8_t buffer[72U] = {0U};
 2985|     49|  Eurydice_slice_copy(
  ------------------
  |  |  229|     49|  memcpy(dst.ptr, src.ptr, dst.len * sizeof(t))
  ------------------
 2986|     49|      Eurydice_array_to_subslice3(buffer, (size_t)0U, len, uint8_t *),
 2987|     49|      Eurydice_slice_subslice3(blocks, start, start + len, uint8_t *), uint8_t);
 2988|     49|  buffer[len] = 6U;
 2989|     49|  size_t uu____0 = (size_t)72U - (size_t)1U;
 2990|     49|  buffer[uu____0] = (uint32_t)buffer[uu____0] | 128U;
 2991|     49|  libcrux_sha3_simd_portable_load_block_f8(
 2992|     49|      state, Eurydice_array_to_slice((size_t)72U, buffer, uint8_t), (size_t)0U);
  ------------------
  |  |  204|     49|  EURYDICE_SLICE(x, 0,                     \
  |  |  ------------------
  |  |  |  |  169|     49|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|     49|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  205|     49|                 end) /* x is already at an array type, no need for cast */
  ------------------
 2993|     49|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_squeeze_13_f8:
 3081|     49|    size_t start, size_t len) {
 3082|     49|  libcrux_sha3_simd_portable_store_block_f8(self->st, out, start, len);
 3083|     49|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_store_block_f8:
 3038|     49|    uint64_t *s, Eurydice_slice out, size_t start, size_t len) {
 3039|     49|  size_t octets = len / (size_t)8U;
 3040|    441|  for (size_t i = (size_t)0U; i < octets; i++) {
  ------------------
  |  Branch (3040:31): [True: 392, False: 49]
  ------------------
 3041|    392|    size_t i0 = i;
 3042|    392|    Eurydice_slice uu____0 = Eurydice_slice_subslice3(
  ------------------
  |  |  195|    392|  EURYDICE_SLICE((t_ptr)s.ptr, (start), (end))
  |  |  ------------------
  |  |  |  |  169|    392|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|    392|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3043|    392|        out, start + (size_t)8U * i0, start + (size_t)8U * i0 + (size_t)8U,
 3044|    392|        uint8_t *);
 3045|    392|    uint8_t ret[8U];
 3046|    392|    core_num__u64__to_le_bytes(
 3047|    392|        libcrux_sha3_traits_get_ij_04(s, i0 / (size_t)5U, i0 % (size_t)5U)[0U],
 3048|    392|        ret);
 3049|    392|    Eurydice_slice_copy(
  ------------------
  |  |  229|    392|  memcpy(dst.ptr, src.ptr, dst.len * sizeof(t))
  ------------------
 3050|    392|        uu____0, Eurydice_array_to_slice((size_t)8U, ret, uint8_t), uint8_t);
 3051|    392|  }
 3052|     49|  size_t remaining = len % (size_t)8U;
 3053|     49|  if (remaining > (size_t)0U) {
  ------------------
  |  Branch (3053:7): [True: 0, False: 49]
  ------------------
 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|     49|}
libcrux_mlkem768_sha3.c:core_num__u64__to_le_bytes:
  327|  33.3k|static inline void core_num__u64__to_le_bytes(uint64_t v, uint8_t buf[8]) {
  328|  33.3k|  store64_le(buf, v);
  329|  33.3k|}
libcrux_mlkem768_sha3.c:store64_le:
   48|  33.3k|{
   49|  33.3k|	dst[0] = src & 0xff;
   50|  33.3k|	dst[1] = (src >> 8) & 0xff;
   51|  33.3k|	dst[2] = (src >> 16) & 0xff;
   52|  33.3k|	dst[3] = (src >> 24) & 0xff;
   53|  33.3k|	dst[4] = (src >> 32) & 0xff;
   54|  33.3k|	dst[5] = (src >> 40) & 0xff;
   55|  33.3k|	dst[6] = (src >> 48) & 0xff;
   56|  33.3k|	dst[7] = (src >> 56) & 0xff;
   57|  33.3k|}
libcrux_mlkem768_sha3.c:libcrux_sha3_generic_keccak_keccakf1600_80_04:
 2943|  2.12k|    libcrux_sha3_generic_keccak_KeccakState_17 *self) {
 2944|  53.0k|  for (size_t i = (size_t)0U; i < (size_t)24U; i++) {
  ------------------
  |  Branch (2944:31): [True: 50.9k, False: 2.12k]
  ------------------
 2945|  50.9k|    size_t i0 = i;
 2946|  50.9k|    uint64_t t[5U];
 2947|  50.9k|    libcrux_sha3_generic_keccak_theta_80_04(self, t);
 2948|  50.9k|    libcrux_sha3_generic_keccak_KeccakState_17 *uu____0 = self;
 2949|  50.9k|    uint64_t uu____1[5U];
 2950|  50.9k|    memcpy(uu____1, t, (size_t)5U * sizeof(uint64_t));
 2951|  50.9k|    libcrux_sha3_generic_keccak_rho_80_04(uu____0, uu____1);
 2952|  50.9k|    libcrux_sha3_generic_keccak_pi_80_04(self);
 2953|  50.9k|    libcrux_sha3_generic_keccak_chi_80_04(self);
 2954|  50.9k|    libcrux_sha3_generic_keccak_iota_80_04(self, i0);
 2955|  50.9k|  }
 2956|  2.12k|}
libcrux_mlkem768_sha3.c:libcrux_sha3_generic_keccak_theta_80_04:
 1557|  50.9k|    libcrux_sha3_generic_keccak_KeccakState_17 *self, uint64_t ret[5U]) {
 1558|  50.9k|  uint64_t c[5U] = {
 1559|  50.9k|      libcrux_sha3_simd_portable_xor5_d2(
 1560|  50.9k|          libcrux_sha3_generic_keccak_index_c2_04(
 1561|  50.9k|              self, (KRML_CLITERAL(size_t_x2){.fst = (size_t)0U,
  ------------------
  |  |  154|  50.9k|#define KRML_CLITERAL(type) (type)
  ------------------
 1562|  50.9k|                                              .snd = (size_t)0U}))[0U],
 1563|  50.9k|          libcrux_sha3_generic_keccak_index_c2_04(
 1564|  50.9k|              self, (KRML_CLITERAL(size_t_x2){.fst = (size_t)1U,
  ------------------
  |  |  154|  50.9k|#define KRML_CLITERAL(type) (type)
  ------------------
 1565|  50.9k|                                              .snd = (size_t)0U}))[0U],
 1566|  50.9k|          libcrux_sha3_generic_keccak_index_c2_04(
 1567|  50.9k|              self, (KRML_CLITERAL(size_t_x2){.fst = (size_t)2U,
  ------------------
  |  |  154|  50.9k|#define KRML_CLITERAL(type) (type)
  ------------------
 1568|  50.9k|                                              .snd = (size_t)0U}))[0U],
 1569|  50.9k|          libcrux_sha3_generic_keccak_index_c2_04(
 1570|  50.9k|              self, (KRML_CLITERAL(size_t_x2){.fst = (size_t)3U,
  ------------------
  |  |  154|  50.9k|#define KRML_CLITERAL(type) (type)
  ------------------
 1571|  50.9k|                                              .snd = (size_t)0U}))[0U],
 1572|  50.9k|          libcrux_sha3_generic_keccak_index_c2_04(
 1573|  50.9k|              self, (KRML_CLITERAL(size_t_x2){.fst = (size_t)4U,
  ------------------
  |  |  154|  50.9k|#define KRML_CLITERAL(type) (type)
  ------------------
 1574|  50.9k|                                              .snd = (size_t)0U}))[0U]),
 1575|  50.9k|      libcrux_sha3_simd_portable_xor5_d2(
 1576|  50.9k|          libcrux_sha3_generic_keccak_index_c2_04(
 1577|  50.9k|              self, (KRML_CLITERAL(size_t_x2){.fst = (size_t)0U,
  ------------------
  |  |  154|  50.9k|#define KRML_CLITERAL(type) (type)
  ------------------
 1578|  50.9k|                                              .snd = (size_t)1U}))[0U],
 1579|  50.9k|          libcrux_sha3_generic_keccak_index_c2_04(
 1580|  50.9k|              self, (KRML_CLITERAL(size_t_x2){.fst = (size_t)1U,
  ------------------
  |  |  154|  50.9k|#define KRML_CLITERAL(type) (type)
  ------------------
 1581|  50.9k|                                              .snd = (size_t)1U}))[0U],
 1582|  50.9k|          libcrux_sha3_generic_keccak_index_c2_04(
 1583|  50.9k|              self, (KRML_CLITERAL(size_t_x2){.fst = (size_t)2U,
  ------------------
  |  |  154|  50.9k|#define KRML_CLITERAL(type) (type)
  ------------------
 1584|  50.9k|                                              .snd = (size_t)1U}))[0U],
 1585|  50.9k|          libcrux_sha3_generic_keccak_index_c2_04(
 1586|  50.9k|              self, (KRML_CLITERAL(size_t_x2){.fst = (size_t)3U,
  ------------------
  |  |  154|  50.9k|#define KRML_CLITERAL(type) (type)
  ------------------
 1587|  50.9k|                                              .snd = (size_t)1U}))[0U],
 1588|  50.9k|          libcrux_sha3_generic_keccak_index_c2_04(
 1589|  50.9k|              self, (KRML_CLITERAL(size_t_x2){.fst = (size_t)4U,
  ------------------
  |  |  154|  50.9k|#define KRML_CLITERAL(type) (type)
  ------------------
 1590|  50.9k|                                              .snd = (size_t)1U}))[0U]),
 1591|  50.9k|      libcrux_sha3_simd_portable_xor5_d2(
 1592|  50.9k|          libcrux_sha3_generic_keccak_index_c2_04(
 1593|  50.9k|              self, (KRML_CLITERAL(size_t_x2){.fst = (size_t)0U,
  ------------------
  |  |  154|  50.9k|#define KRML_CLITERAL(type) (type)
  ------------------
 1594|  50.9k|                                              .snd = (size_t)2U}))[0U],
 1595|  50.9k|          libcrux_sha3_generic_keccak_index_c2_04(
 1596|  50.9k|              self, (KRML_CLITERAL(size_t_x2){.fst = (size_t)1U,
  ------------------
  |  |  154|  50.9k|#define KRML_CLITERAL(type) (type)
  ------------------
 1597|  50.9k|                                              .snd = (size_t)2U}))[0U],
 1598|  50.9k|          libcrux_sha3_generic_keccak_index_c2_04(
 1599|  50.9k|              self, (KRML_CLITERAL(size_t_x2){.fst = (size_t)2U,
  ------------------
  |  |  154|  50.9k|#define KRML_CLITERAL(type) (type)
  ------------------
 1600|  50.9k|                                              .snd = (size_t)2U}))[0U],
 1601|  50.9k|          libcrux_sha3_generic_keccak_index_c2_04(
 1602|  50.9k|              self, (KRML_CLITERAL(size_t_x2){.fst = (size_t)3U,
  ------------------
  |  |  154|  50.9k|#define KRML_CLITERAL(type) (type)
  ------------------
 1603|  50.9k|                                              .snd = (size_t)2U}))[0U],
 1604|  50.9k|          libcrux_sha3_generic_keccak_index_c2_04(
 1605|  50.9k|              self, (KRML_CLITERAL(size_t_x2){.fst = (size_t)4U,
  ------------------
  |  |  154|  50.9k|#define KRML_CLITERAL(type) (type)
  ------------------
 1606|  50.9k|                                              .snd = (size_t)2U}))[0U]),
 1607|  50.9k|      libcrux_sha3_simd_portable_xor5_d2(
 1608|  50.9k|          libcrux_sha3_generic_keccak_index_c2_04(
 1609|  50.9k|              self, (KRML_CLITERAL(size_t_x2){.fst = (size_t)0U,
  ------------------
  |  |  154|  50.9k|#define KRML_CLITERAL(type) (type)
  ------------------
 1610|  50.9k|                                              .snd = (size_t)3U}))[0U],
 1611|  50.9k|          libcrux_sha3_generic_keccak_index_c2_04(
 1612|  50.9k|              self, (KRML_CLITERAL(size_t_x2){.fst = (size_t)1U,
  ------------------
  |  |  154|  50.9k|#define KRML_CLITERAL(type) (type)
  ------------------
 1613|  50.9k|                                              .snd = (size_t)3U}))[0U],
 1614|  50.9k|          libcrux_sha3_generic_keccak_index_c2_04(
 1615|  50.9k|              self, (KRML_CLITERAL(size_t_x2){.fst = (size_t)2U,
  ------------------
  |  |  154|  50.9k|#define KRML_CLITERAL(type) (type)
  ------------------
 1616|  50.9k|                                              .snd = (size_t)3U}))[0U],
 1617|  50.9k|          libcrux_sha3_generic_keccak_index_c2_04(
 1618|  50.9k|              self, (KRML_CLITERAL(size_t_x2){.fst = (size_t)3U,
  ------------------
  |  |  154|  50.9k|#define KRML_CLITERAL(type) (type)
  ------------------
 1619|  50.9k|                                              .snd = (size_t)3U}))[0U],
 1620|  50.9k|          libcrux_sha3_generic_keccak_index_c2_04(
 1621|  50.9k|              self, (KRML_CLITERAL(size_t_x2){.fst = (size_t)4U,
  ------------------
  |  |  154|  50.9k|#define KRML_CLITERAL(type) (type)
  ------------------
 1622|  50.9k|                                              .snd = (size_t)3U}))[0U]),
 1623|  50.9k|      libcrux_sha3_simd_portable_xor5_d2(
 1624|  50.9k|          libcrux_sha3_generic_keccak_index_c2_04(
 1625|  50.9k|              self, (KRML_CLITERAL(size_t_x2){.fst = (size_t)0U,
  ------------------
  |  |  154|  50.9k|#define KRML_CLITERAL(type) (type)
  ------------------
 1626|  50.9k|                                              .snd = (size_t)4U}))[0U],
 1627|  50.9k|          libcrux_sha3_generic_keccak_index_c2_04(
 1628|  50.9k|              self, (KRML_CLITERAL(size_t_x2){.fst = (size_t)1U,
  ------------------
  |  |  154|  50.9k|#define KRML_CLITERAL(type) (type)
  ------------------
 1629|  50.9k|                                              .snd = (size_t)4U}))[0U],
 1630|  50.9k|          libcrux_sha3_generic_keccak_index_c2_04(
 1631|  50.9k|              self, (KRML_CLITERAL(size_t_x2){.fst = (size_t)2U,
  ------------------
  |  |  154|  50.9k|#define KRML_CLITERAL(type) (type)
  ------------------
 1632|  50.9k|                                              .snd = (size_t)4U}))[0U],
 1633|  50.9k|          libcrux_sha3_generic_keccak_index_c2_04(
 1634|  50.9k|              self, (KRML_CLITERAL(size_t_x2){.fst = (size_t)3U,
  ------------------
  |  |  154|  50.9k|#define KRML_CLITERAL(type) (type)
  ------------------
 1635|  50.9k|                                              .snd = (size_t)4U}))[0U],
 1636|  50.9k|          libcrux_sha3_generic_keccak_index_c2_04(
 1637|  50.9k|              self, (KRML_CLITERAL(size_t_x2){.fst = (size_t)4U,
  ------------------
  |  |  154|  50.9k|#define KRML_CLITERAL(type) (type)
  ------------------
 1638|  50.9k|                                              .snd = (size_t)4U}))[0U])};
 1639|  50.9k|  uint64_t uu____0 = libcrux_sha3_simd_portable_rotate_left1_and_xor_d2(
 1640|  50.9k|      c[((size_t)0U + (size_t)4U) % (size_t)5U],
 1641|  50.9k|      c[((size_t)0U + (size_t)1U) % (size_t)5U]);
 1642|  50.9k|  uint64_t uu____1 = libcrux_sha3_simd_portable_rotate_left1_and_xor_d2(
 1643|  50.9k|      c[((size_t)1U + (size_t)4U) % (size_t)5U],
 1644|  50.9k|      c[((size_t)1U + (size_t)1U) % (size_t)5U]);
 1645|  50.9k|  uint64_t uu____2 = libcrux_sha3_simd_portable_rotate_left1_and_xor_d2(
 1646|  50.9k|      c[((size_t)2U + (size_t)4U) % (size_t)5U],
 1647|  50.9k|      c[((size_t)2U + (size_t)1U) % (size_t)5U]);
 1648|  50.9k|  uint64_t uu____3 = libcrux_sha3_simd_portable_rotate_left1_and_xor_d2(
 1649|  50.9k|      c[((size_t)3U + (size_t)4U) % (size_t)5U],
 1650|  50.9k|      c[((size_t)3U + (size_t)1U) % (size_t)5U]);
 1651|  50.9k|  ret[0U] = uu____0;
 1652|  50.9k|  ret[1U] = uu____1;
 1653|  50.9k|  ret[2U] = uu____2;
 1654|  50.9k|  ret[3U] = uu____3;
 1655|  50.9k|  ret[4U] = libcrux_sha3_simd_portable_rotate_left1_and_xor_d2(
 1656|  50.9k|      c[((size_t)4U + (size_t)4U) % (size_t)5U],
 1657|  50.9k|      c[((size_t)4U + (size_t)1U) % (size_t)5U]);
 1658|  50.9k|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_xor5_d2:
 1333|   254k|    uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e) {
 1334|   254k|  return libcrux_sha3_simd_portable__veor5q_u64(a, b, c, d, e);
 1335|   254k|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable__veor5q_u64:
 1325|   254k|    uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e) {
 1326|   254k|  return (((a ^ b) ^ c) ^ d) ^ e;
 1327|   254k|}
libcrux_mlkem768_sha3.c:libcrux_sha3_generic_keccak_index_c2_04:
 1542|  7.63M|    libcrux_sha3_generic_keccak_KeccakState_17 *self, size_t_x2 index) {
 1543|  7.63M|  return libcrux_sha3_traits_get_ij_04(self->st, index.fst, index.snd);
 1544|  7.63M|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_rotate_left1_and_xor_d2:
 1358|   254k|libcrux_sha3_simd_portable_rotate_left1_and_xor_d2(uint64_t a, uint64_t b) {
 1359|   254k|  return libcrux_sha3_simd_portable__vrax1q_u64(a, b);
 1360|   254k|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable__vrax1q_u64:
 1349|   254k|libcrux_sha3_simd_portable__vrax1q_u64(uint64_t a, uint64_t b) {
 1350|   254k|  uint64_t uu____0 = a;
 1351|   254k|  return uu____0 ^ libcrux_sha3_simd_portable_rotate_left_76(b);
 1352|   254k|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_rotate_left_76:
 1344|   305k|libcrux_sha3_simd_portable_rotate_left_76(uint64_t x) {
 1345|   305k|  return core_num__u64__rotate_left(x, (uint32_t)(int32_t)1);
 1346|   305k|}
libcrux_mlkem768_sha3.c:core_num__u64__rotate_left:
  342|  1.47M|static inline uint64_t core_num__u64__rotate_left(uint64_t x0, uint32_t x1) {
  343|  1.47M|  return (x0 << x1 | x0 >> (64 - x1));
  344|  1.47M|}
libcrux_mlkem768_sha3.c:libcrux_sha3_generic_keccak_rho_80_04:
 2540|  50.9k|    libcrux_sha3_generic_keccak_KeccakState_17 *self, uint64_t t[5U]) {
 2541|  50.9k|  libcrux_sha3_generic_keccak_set_80_04(
 2542|  50.9k|      self, (size_t)0U, (size_t)0U,
 2543|  50.9k|      libcrux_sha3_simd_portable_xor_d2(
 2544|  50.9k|          libcrux_sha3_generic_keccak_index_c2_04(
 2545|  50.9k|              self, (KRML_CLITERAL(size_t_x2){.fst = (size_t)0U,
  ------------------
  |  |  154|  50.9k|#define KRML_CLITERAL(type) (type)
  ------------------
 2546|  50.9k|                                              .snd = (size_t)0U}))[0U],
 2547|  50.9k|          t[0U]));
 2548|  50.9k|  libcrux_sha3_generic_keccak_KeccakState_17 *uu____0 = self;
 2549|  50.9k|  libcrux_sha3_generic_keccak_set_80_04(
 2550|  50.9k|      uu____0, (size_t)1U, (size_t)0U,
 2551|  50.9k|      libcrux_sha3_simd_portable_xor_and_rotate_d2_02(
 2552|  50.9k|          libcrux_sha3_generic_keccak_index_c2_04(
 2553|  50.9k|              self, (KRML_CLITERAL(size_t_x2){.fst = (size_t)1U,
  ------------------
  |  |  154|  50.9k|#define KRML_CLITERAL(type) (type)
  ------------------
 2554|  50.9k|                                              .snd = (size_t)0U}))[0U],
 2555|  50.9k|          t[0U]));
 2556|  50.9k|  libcrux_sha3_generic_keccak_KeccakState_17 *uu____1 = self;
 2557|  50.9k|  libcrux_sha3_generic_keccak_set_80_04(
 2558|  50.9k|      uu____1, (size_t)2U, (size_t)0U,
 2559|  50.9k|      libcrux_sha3_simd_portable_xor_and_rotate_d2_ac(
 2560|  50.9k|          libcrux_sha3_generic_keccak_index_c2_04(
 2561|  50.9k|              self, (KRML_CLITERAL(size_t_x2){.fst = (size_t)2U,
  ------------------
  |  |  154|  50.9k|#define KRML_CLITERAL(type) (type)
  ------------------
 2562|  50.9k|                                              .snd = (size_t)0U}))[0U],
 2563|  50.9k|          t[0U]));
 2564|  50.9k|  libcrux_sha3_generic_keccak_KeccakState_17 *uu____2 = self;
 2565|  50.9k|  libcrux_sha3_generic_keccak_set_80_04(
 2566|  50.9k|      uu____2, (size_t)3U, (size_t)0U,
 2567|  50.9k|      libcrux_sha3_simd_portable_xor_and_rotate_d2_020(
 2568|  50.9k|          libcrux_sha3_generic_keccak_index_c2_04(
 2569|  50.9k|              self, (KRML_CLITERAL(size_t_x2){.fst = (size_t)3U,
  ------------------
  |  |  154|  50.9k|#define KRML_CLITERAL(type) (type)
  ------------------
 2570|  50.9k|                                              .snd = (size_t)0U}))[0U],
 2571|  50.9k|          t[0U]));
 2572|  50.9k|  libcrux_sha3_generic_keccak_KeccakState_17 *uu____3 = self;
 2573|  50.9k|  libcrux_sha3_generic_keccak_set_80_04(
 2574|  50.9k|      uu____3, (size_t)4U, (size_t)0U,
 2575|  50.9k|      libcrux_sha3_simd_portable_xor_and_rotate_d2_a9(
 2576|  50.9k|          libcrux_sha3_generic_keccak_index_c2_04(
 2577|  50.9k|              self, (KRML_CLITERAL(size_t_x2){.fst = (size_t)4U,
  ------------------
  |  |  154|  50.9k|#define KRML_CLITERAL(type) (type)
  ------------------
 2578|  50.9k|                                              .snd = (size_t)0U}))[0U],
 2579|  50.9k|          t[0U]));
 2580|  50.9k|  libcrux_sha3_generic_keccak_KeccakState_17 *uu____4 = self;
 2581|  50.9k|  libcrux_sha3_generic_keccak_set_80_04(
 2582|  50.9k|      uu____4, (size_t)0U, (size_t)1U,
 2583|  50.9k|      libcrux_sha3_simd_portable_xor_and_rotate_d2_76(
 2584|  50.9k|          libcrux_sha3_generic_keccak_index_c2_04(
 2585|  50.9k|              self, (KRML_CLITERAL(size_t_x2){.fst = (size_t)0U,
  ------------------
  |  |  154|  50.9k|#define KRML_CLITERAL(type) (type)
  ------------------
 2586|  50.9k|                                              .snd = (size_t)1U}))[0U],
 2587|  50.9k|          t[1U]));
 2588|  50.9k|  libcrux_sha3_generic_keccak_KeccakState_17 *uu____5 = self;
 2589|  50.9k|  libcrux_sha3_generic_keccak_set_80_04(
 2590|  50.9k|      uu____5, (size_t)1U, (size_t)1U,
 2591|  50.9k|      libcrux_sha3_simd_portable_xor_and_rotate_d2_58(
 2592|  50.9k|          libcrux_sha3_generic_keccak_index_c2_04(
 2593|  50.9k|              self, (KRML_CLITERAL(size_t_x2){.fst = (size_t)1U,
  ------------------
  |  |  154|  50.9k|#define KRML_CLITERAL(type) (type)
  ------------------
 2594|  50.9k|                                              .snd = (size_t)1U}))[0U],
 2595|  50.9k|          t[1U]));
 2596|  50.9k|  libcrux_sha3_generic_keccak_KeccakState_17 *uu____6 = self;
 2597|  50.9k|  libcrux_sha3_generic_keccak_set_80_04(
 2598|  50.9k|      uu____6, (size_t)2U, (size_t)1U,
 2599|  50.9k|      libcrux_sha3_simd_portable_xor_and_rotate_d2_e0(
 2600|  50.9k|          libcrux_sha3_generic_keccak_index_c2_04(
 2601|  50.9k|              self, (KRML_CLITERAL(size_t_x2){.fst = (size_t)2U,
  ------------------
  |  |  154|  50.9k|#define KRML_CLITERAL(type) (type)
  ------------------
 2602|  50.9k|                                              .snd = (size_t)1U}))[0U],
 2603|  50.9k|          t[1U]));
 2604|  50.9k|  libcrux_sha3_generic_keccak_KeccakState_17 *uu____7 = self;
 2605|  50.9k|  libcrux_sha3_generic_keccak_set_80_04(
 2606|  50.9k|      uu____7, (size_t)3U, (size_t)1U,
 2607|  50.9k|      libcrux_sha3_simd_portable_xor_and_rotate_d2_63(
 2608|  50.9k|          libcrux_sha3_generic_keccak_index_c2_04(
 2609|  50.9k|              self, (KRML_CLITERAL(size_t_x2){.fst = (size_t)3U,
  ------------------
  |  |  154|  50.9k|#define KRML_CLITERAL(type) (type)
  ------------------
 2610|  50.9k|                                              .snd = (size_t)1U}))[0U],
 2611|  50.9k|          t[1U]));
 2612|  50.9k|  libcrux_sha3_generic_keccak_KeccakState_17 *uu____8 = self;
 2613|  50.9k|  libcrux_sha3_generic_keccak_set_80_04(
 2614|  50.9k|      uu____8, (size_t)4U, (size_t)1U,
 2615|  50.9k|      libcrux_sha3_simd_portable_xor_and_rotate_d2_6a(
 2616|  50.9k|          libcrux_sha3_generic_keccak_index_c2_04(
 2617|  50.9k|              self, (KRML_CLITERAL(size_t_x2){.fst = (size_t)4U,
  ------------------
  |  |  154|  50.9k|#define KRML_CLITERAL(type) (type)
  ------------------
 2618|  50.9k|                                              .snd = (size_t)1U}))[0U],
 2619|  50.9k|          t[1U]));
 2620|  50.9k|  libcrux_sha3_generic_keccak_KeccakState_17 *uu____9 = self;
 2621|  50.9k|  libcrux_sha3_generic_keccak_set_80_04(
 2622|  50.9k|      uu____9, (size_t)0U, (size_t)2U,
 2623|  50.9k|      libcrux_sha3_simd_portable_xor_and_rotate_d2_ab(
 2624|  50.9k|          libcrux_sha3_generic_keccak_index_c2_04(
 2625|  50.9k|              self, (KRML_CLITERAL(size_t_x2){.fst = (size_t)0U,
  ------------------
  |  |  154|  50.9k|#define KRML_CLITERAL(type) (type)
  ------------------
 2626|  50.9k|                                              .snd = (size_t)2U}))[0U],
 2627|  50.9k|          t[2U]));
 2628|  50.9k|  libcrux_sha3_generic_keccak_KeccakState_17 *uu____10 = self;
 2629|  50.9k|  libcrux_sha3_generic_keccak_set_80_04(
 2630|  50.9k|      uu____10, (size_t)1U, (size_t)2U,
 2631|  50.9k|      libcrux_sha3_simd_portable_xor_and_rotate_d2_5b(
 2632|  50.9k|          libcrux_sha3_generic_keccak_index_c2_04(
 2633|  50.9k|              self, (KRML_CLITERAL(size_t_x2){.fst = (size_t)1U,
  ------------------
  |  |  154|  50.9k|#define KRML_CLITERAL(type) (type)
  ------------------
 2634|  50.9k|                                              .snd = (size_t)2U}))[0U],
 2635|  50.9k|          t[2U]));
 2636|  50.9k|  libcrux_sha3_generic_keccak_KeccakState_17 *uu____11 = self;
 2637|  50.9k|  libcrux_sha3_generic_keccak_set_80_04(
 2638|  50.9k|      uu____11, (size_t)2U, (size_t)2U,
 2639|  50.9k|      libcrux_sha3_simd_portable_xor_and_rotate_d2_6f(
 2640|  50.9k|          libcrux_sha3_generic_keccak_index_c2_04(
 2641|  50.9k|              self, (KRML_CLITERAL(size_t_x2){.fst = (size_t)2U,
  ------------------
  |  |  154|  50.9k|#define KRML_CLITERAL(type) (type)
  ------------------
 2642|  50.9k|                                              .snd = (size_t)2U}))[0U],
 2643|  50.9k|          t[2U]));
 2644|  50.9k|  libcrux_sha3_generic_keccak_KeccakState_17 *uu____12 = self;
 2645|  50.9k|  libcrux_sha3_generic_keccak_set_80_04(
 2646|  50.9k|      uu____12, (size_t)3U, (size_t)2U,
 2647|  50.9k|      libcrux_sha3_simd_portable_xor_and_rotate_d2_62(
 2648|  50.9k|          libcrux_sha3_generic_keccak_index_c2_04(
 2649|  50.9k|              self, (KRML_CLITERAL(size_t_x2){.fst = (size_t)3U,
  ------------------
  |  |  154|  50.9k|#define KRML_CLITERAL(type) (type)
  ------------------
 2650|  50.9k|                                              .snd = (size_t)2U}))[0U],
 2651|  50.9k|          t[2U]));
 2652|  50.9k|  libcrux_sha3_generic_keccak_KeccakState_17 *uu____13 = self;
 2653|  50.9k|  libcrux_sha3_generic_keccak_set_80_04(
 2654|  50.9k|      uu____13, (size_t)4U, (size_t)2U,
 2655|  50.9k|      libcrux_sha3_simd_portable_xor_and_rotate_d2_23(
 2656|  50.9k|          libcrux_sha3_generic_keccak_index_c2_04(
 2657|  50.9k|              self, (KRML_CLITERAL(size_t_x2){.fst = (size_t)4U,
  ------------------
  |  |  154|  50.9k|#define KRML_CLITERAL(type) (type)
  ------------------
 2658|  50.9k|                                              .snd = (size_t)2U}))[0U],
 2659|  50.9k|          t[2U]));
 2660|  50.9k|  libcrux_sha3_generic_keccak_KeccakState_17 *uu____14 = self;
 2661|  50.9k|  libcrux_sha3_generic_keccak_set_80_04(
 2662|  50.9k|      uu____14, (size_t)0U, (size_t)3U,
 2663|  50.9k|      libcrux_sha3_simd_portable_xor_and_rotate_d2_37(
 2664|  50.9k|          libcrux_sha3_generic_keccak_index_c2_04(
 2665|  50.9k|              self, (KRML_CLITERAL(size_t_x2){.fst = (size_t)0U,
  ------------------
  |  |  154|  50.9k|#define KRML_CLITERAL(type) (type)
  ------------------
 2666|  50.9k|                                              .snd = (size_t)3U}))[0U],
 2667|  50.9k|          t[3U]));
 2668|  50.9k|  libcrux_sha3_generic_keccak_KeccakState_17 *uu____15 = self;
 2669|  50.9k|  libcrux_sha3_generic_keccak_set_80_04(
 2670|  50.9k|      uu____15, (size_t)1U, (size_t)3U,
 2671|  50.9k|      libcrux_sha3_simd_portable_xor_and_rotate_d2_bb(
 2672|  50.9k|          libcrux_sha3_generic_keccak_index_c2_04(
 2673|  50.9k|              self, (KRML_CLITERAL(size_t_x2){.fst = (size_t)1U,
  ------------------
  |  |  154|  50.9k|#define KRML_CLITERAL(type) (type)
  ------------------
 2674|  50.9k|                                              .snd = (size_t)3U}))[0U],
 2675|  50.9k|          t[3U]));
 2676|  50.9k|  libcrux_sha3_generic_keccak_KeccakState_17 *uu____16 = self;
 2677|  50.9k|  libcrux_sha3_generic_keccak_set_80_04(
 2678|  50.9k|      uu____16, (size_t)2U, (size_t)3U,
 2679|  50.9k|      libcrux_sha3_simd_portable_xor_and_rotate_d2_b9(
 2680|  50.9k|          libcrux_sha3_generic_keccak_index_c2_04(
 2681|  50.9k|              self, (KRML_CLITERAL(size_t_x2){.fst = (size_t)2U,
  ------------------
  |  |  154|  50.9k|#define KRML_CLITERAL(type) (type)
  ------------------
 2682|  50.9k|                                              .snd = (size_t)3U}))[0U],
 2683|  50.9k|          t[3U]));
 2684|  50.9k|  libcrux_sha3_generic_keccak_KeccakState_17 *uu____17 = self;
 2685|  50.9k|  libcrux_sha3_generic_keccak_set_80_04(
 2686|  50.9k|      uu____17, (size_t)3U, (size_t)3U,
 2687|  50.9k|      libcrux_sha3_simd_portable_xor_and_rotate_d2_54(
 2688|  50.9k|          libcrux_sha3_generic_keccak_index_c2_04(
 2689|  50.9k|              self, (KRML_CLITERAL(size_t_x2){.fst = (size_t)3U,
  ------------------
  |  |  154|  50.9k|#define KRML_CLITERAL(type) (type)
  ------------------
 2690|  50.9k|                                              .snd = (size_t)3U}))[0U],
 2691|  50.9k|          t[3U]));
 2692|  50.9k|  libcrux_sha3_generic_keccak_KeccakState_17 *uu____18 = self;
 2693|  50.9k|  libcrux_sha3_generic_keccak_set_80_04(
 2694|  50.9k|      uu____18, (size_t)4U, (size_t)3U,
 2695|  50.9k|      libcrux_sha3_simd_portable_xor_and_rotate_d2_4c(
 2696|  50.9k|          libcrux_sha3_generic_keccak_index_c2_04(
 2697|  50.9k|              self, (KRML_CLITERAL(size_t_x2){.fst = (size_t)4U,
  ------------------
  |  |  154|  50.9k|#define KRML_CLITERAL(type) (type)
  ------------------
 2698|  50.9k|                                              .snd = (size_t)3U}))[0U],
 2699|  50.9k|          t[3U]));
 2700|  50.9k|  libcrux_sha3_generic_keccak_KeccakState_17 *uu____19 = self;
 2701|  50.9k|  libcrux_sha3_generic_keccak_set_80_04(
 2702|  50.9k|      uu____19, (size_t)0U, (size_t)4U,
 2703|  50.9k|      libcrux_sha3_simd_portable_xor_and_rotate_d2_ce(
 2704|  50.9k|          libcrux_sha3_generic_keccak_index_c2_04(
 2705|  50.9k|              self, (KRML_CLITERAL(size_t_x2){.fst = (size_t)0U,
  ------------------
  |  |  154|  50.9k|#define KRML_CLITERAL(type) (type)
  ------------------
 2706|  50.9k|                                              .snd = (size_t)4U}))[0U],
 2707|  50.9k|          t[4U]));
 2708|  50.9k|  libcrux_sha3_generic_keccak_KeccakState_17 *uu____20 = self;
 2709|  50.9k|  libcrux_sha3_generic_keccak_set_80_04(
 2710|  50.9k|      uu____20, (size_t)1U, (size_t)4U,
 2711|  50.9k|      libcrux_sha3_simd_portable_xor_and_rotate_d2_77(
 2712|  50.9k|          libcrux_sha3_generic_keccak_index_c2_04(
 2713|  50.9k|              self, (KRML_CLITERAL(size_t_x2){.fst = (size_t)1U,
  ------------------
  |  |  154|  50.9k|#define KRML_CLITERAL(type) (type)
  ------------------
 2714|  50.9k|                                              .snd = (size_t)4U}))[0U],
 2715|  50.9k|          t[4U]));
 2716|  50.9k|  libcrux_sha3_generic_keccak_KeccakState_17 *uu____21 = self;
 2717|  50.9k|  libcrux_sha3_generic_keccak_set_80_04(
 2718|  50.9k|      uu____21, (size_t)2U, (size_t)4U,
 2719|  50.9k|      libcrux_sha3_simd_portable_xor_and_rotate_d2_25(
 2720|  50.9k|          libcrux_sha3_generic_keccak_index_c2_04(
 2721|  50.9k|              self, (KRML_CLITERAL(size_t_x2){.fst = (size_t)2U,
  ------------------
  |  |  154|  50.9k|#define KRML_CLITERAL(type) (type)
  ------------------
 2722|  50.9k|                                              .snd = (size_t)4U}))[0U],
 2723|  50.9k|          t[4U]));
 2724|  50.9k|  libcrux_sha3_generic_keccak_KeccakState_17 *uu____22 = self;
 2725|  50.9k|  libcrux_sha3_generic_keccak_set_80_04(
 2726|  50.9k|      uu____22, (size_t)3U, (size_t)4U,
 2727|  50.9k|      libcrux_sha3_simd_portable_xor_and_rotate_d2_af(
 2728|  50.9k|          libcrux_sha3_generic_keccak_index_c2_04(
 2729|  50.9k|              self, (KRML_CLITERAL(size_t_x2){.fst = (size_t)3U,
  ------------------
  |  |  154|  50.9k|#define KRML_CLITERAL(type) (type)
  ------------------
 2730|  50.9k|                                              .snd = (size_t)4U}))[0U],
 2731|  50.9k|          t[4U]));
 2732|  50.9k|  libcrux_sha3_generic_keccak_KeccakState_17 *uu____23 = self;
 2733|  50.9k|  libcrux_sha3_generic_keccak_set_80_04(
 2734|  50.9k|      uu____23, (size_t)4U, (size_t)4U,
 2735|  50.9k|      libcrux_sha3_simd_portable_xor_and_rotate_d2_fd(
 2736|  50.9k|          libcrux_sha3_generic_keccak_index_c2_04(
 2737|  50.9k|              self, (KRML_CLITERAL(size_t_x2){.fst = (size_t)4U,
  ------------------
  |  |  154|  50.9k|#define KRML_CLITERAL(type) (type)
  ------------------
 2738|  50.9k|                                              .snd = (size_t)4U}))[0U],
 2739|  50.9k|          t[4U]));
 2740|  50.9k|}
libcrux_mlkem768_sha3.c:libcrux_sha3_generic_keccak_set_80_04:
 1672|  3.81M|    uint64_t v) {
 1673|  3.81M|  libcrux_sha3_traits_set_ij_04(self->st, i, j, v);
 1674|  3.81M|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_xor_d2:
 1392|  50.9k|                                                                  uint64_t b) {
 1393|  50.9k|  return a ^ b;
 1394|  50.9k|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_xor_and_rotate_d2_02:
 1708|  50.9k|libcrux_sha3_simd_portable_xor_and_rotate_d2_02(uint64_t a, uint64_t b) {
 1709|  50.9k|  return libcrux_sha3_simd_portable__vxarq_u64_02(a, b);
 1710|  50.9k|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable__vxarq_u64_02:
 1694|  50.9k|libcrux_sha3_simd_portable__vxarq_u64_02(uint64_t a, uint64_t b) {
 1695|  50.9k|  return libcrux_sha3_simd_portable_rotate_left_02(a ^ b);
 1696|  50.9k|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_rotate_left_02:
 1683|  50.9k|libcrux_sha3_simd_portable_rotate_left_02(uint64_t x) {
 1684|  50.9k|  return core_num__u64__rotate_left(x, (uint32_t)(int32_t)36);
 1685|  50.9k|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_xor_and_rotate_d2_ac:
 1744|  50.9k|libcrux_sha3_simd_portable_xor_and_rotate_d2_ac(uint64_t a, uint64_t b) {
 1745|  50.9k|  return libcrux_sha3_simd_portable__vxarq_u64_ac(a, b);
 1746|  50.9k|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable__vxarq_u64_ac:
 1730|  50.9k|libcrux_sha3_simd_portable__vxarq_u64_ac(uint64_t a, uint64_t b) {
 1731|  50.9k|  return libcrux_sha3_simd_portable_rotate_left_ac(a ^ b);
 1732|  50.9k|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_rotate_left_ac:
 1719|  50.9k|libcrux_sha3_simd_portable_rotate_left_ac(uint64_t x) {
 1720|  50.9k|  return core_num__u64__rotate_left(x, (uint32_t)(int32_t)3);
 1721|  50.9k|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_xor_and_rotate_d2_020:
 1780|  50.9k|libcrux_sha3_simd_portable_xor_and_rotate_d2_020(uint64_t a, uint64_t b) {
 1781|  50.9k|  return libcrux_sha3_simd_portable__vxarq_u64_020(a, b);
 1782|  50.9k|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable__vxarq_u64_020:
 1766|  50.9k|libcrux_sha3_simd_portable__vxarq_u64_020(uint64_t a, uint64_t b) {
 1767|  50.9k|  return libcrux_sha3_simd_portable_rotate_left_020(a ^ b);
 1768|  50.9k|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_rotate_left_020:
 1755|  50.9k|libcrux_sha3_simd_portable_rotate_left_020(uint64_t x) {
 1756|  50.9k|  return core_num__u64__rotate_left(x, (uint32_t)(int32_t)41);
 1757|  50.9k|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_xor_and_rotate_d2_a9:
 1816|  50.9k|libcrux_sha3_simd_portable_xor_and_rotate_d2_a9(uint64_t a, uint64_t b) {
 1817|  50.9k|  return libcrux_sha3_simd_portable__vxarq_u64_a9(a, b);
 1818|  50.9k|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable__vxarq_u64_a9:
 1802|  50.9k|libcrux_sha3_simd_portable__vxarq_u64_a9(uint64_t a, uint64_t b) {
 1803|  50.9k|  return libcrux_sha3_simd_portable_rotate_left_a9(a ^ b);
 1804|  50.9k|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_rotate_left_a9:
 1791|  50.9k|libcrux_sha3_simd_portable_rotate_left_a9(uint64_t x) {
 1792|  50.9k|  return core_num__u64__rotate_left(x, (uint32_t)(int32_t)18);
 1793|  50.9k|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_xor_and_rotate_d2_76:
 1841|  50.9k|libcrux_sha3_simd_portable_xor_and_rotate_d2_76(uint64_t a, uint64_t b) {
 1842|  50.9k|  return libcrux_sha3_simd_portable__vxarq_u64_76(a, b);
 1843|  50.9k|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable__vxarq_u64_76:
 1827|  50.9k|libcrux_sha3_simd_portable__vxarq_u64_76(uint64_t a, uint64_t b) {
 1828|  50.9k|  return libcrux_sha3_simd_portable_rotate_left_76(a ^ b);
 1829|  50.9k|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_xor_and_rotate_d2_58:
 1877|  50.9k|libcrux_sha3_simd_portable_xor_and_rotate_d2_58(uint64_t a, uint64_t b) {
 1878|  50.9k|  return libcrux_sha3_simd_portable__vxarq_u64_58(a, b);
 1879|  50.9k|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable__vxarq_u64_58:
 1863|  50.9k|libcrux_sha3_simd_portable__vxarq_u64_58(uint64_t a, uint64_t b) {
 1864|  50.9k|  return libcrux_sha3_simd_portable_rotate_left_58(a ^ b);
 1865|  50.9k|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_rotate_left_58:
 1852|  50.9k|libcrux_sha3_simd_portable_rotate_left_58(uint64_t x) {
 1853|  50.9k|  return core_num__u64__rotate_left(x, (uint32_t)(int32_t)44);
 1854|  50.9k|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_xor_and_rotate_d2_e0:
 1913|  50.9k|libcrux_sha3_simd_portable_xor_and_rotate_d2_e0(uint64_t a, uint64_t b) {
 1914|  50.9k|  return libcrux_sha3_simd_portable__vxarq_u64_e0(a, b);
 1915|  50.9k|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable__vxarq_u64_e0:
 1899|  50.9k|libcrux_sha3_simd_portable__vxarq_u64_e0(uint64_t a, uint64_t b) {
 1900|  50.9k|  return libcrux_sha3_simd_portable_rotate_left_e0(a ^ b);
 1901|  50.9k|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_rotate_left_e0:
 1888|  50.9k|libcrux_sha3_simd_portable_rotate_left_e0(uint64_t x) {
 1889|  50.9k|  return core_num__u64__rotate_left(x, (uint32_t)(int32_t)10);
 1890|  50.9k|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_xor_and_rotate_d2_63:
 1949|  50.9k|libcrux_sha3_simd_portable_xor_and_rotate_d2_63(uint64_t a, uint64_t b) {
 1950|  50.9k|  return libcrux_sha3_simd_portable__vxarq_u64_63(a, b);
 1951|  50.9k|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable__vxarq_u64_63:
 1935|  50.9k|libcrux_sha3_simd_portable__vxarq_u64_63(uint64_t a, uint64_t b) {
 1936|  50.9k|  return libcrux_sha3_simd_portable_rotate_left_63(a ^ b);
 1937|  50.9k|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_rotate_left_63:
 1924|  50.9k|libcrux_sha3_simd_portable_rotate_left_63(uint64_t x) {
 1925|  50.9k|  return core_num__u64__rotate_left(x, (uint32_t)(int32_t)45);
 1926|  50.9k|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_xor_and_rotate_d2_6a:
 1985|  50.9k|libcrux_sha3_simd_portable_xor_and_rotate_d2_6a(uint64_t a, uint64_t b) {
 1986|  50.9k|  return libcrux_sha3_simd_portable__vxarq_u64_6a(a, b);
 1987|  50.9k|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable__vxarq_u64_6a:
 1971|  50.9k|libcrux_sha3_simd_portable__vxarq_u64_6a(uint64_t a, uint64_t b) {
 1972|  50.9k|  return libcrux_sha3_simd_portable_rotate_left_6a(a ^ b);
 1973|  50.9k|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_rotate_left_6a:
 1960|  50.9k|libcrux_sha3_simd_portable_rotate_left_6a(uint64_t x) {
 1961|  50.9k|  return core_num__u64__rotate_left(x, (uint32_t)(int32_t)2);
 1962|  50.9k|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_xor_and_rotate_d2_ab:
 2021|  50.9k|libcrux_sha3_simd_portable_xor_and_rotate_d2_ab(uint64_t a, uint64_t b) {
 2022|  50.9k|  return libcrux_sha3_simd_portable__vxarq_u64_ab(a, b);
 2023|  50.9k|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable__vxarq_u64_ab:
 2007|  50.9k|libcrux_sha3_simd_portable__vxarq_u64_ab(uint64_t a, uint64_t b) {
 2008|  50.9k|  return libcrux_sha3_simd_portable_rotate_left_ab(a ^ b);
 2009|  50.9k|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_rotate_left_ab:
 1996|  50.9k|libcrux_sha3_simd_portable_rotate_left_ab(uint64_t x) {
 1997|  50.9k|  return core_num__u64__rotate_left(x, (uint32_t)(int32_t)62);
 1998|  50.9k|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_xor_and_rotate_d2_5b:
 2057|  50.9k|libcrux_sha3_simd_portable_xor_and_rotate_d2_5b(uint64_t a, uint64_t b) {
 2058|  50.9k|  return libcrux_sha3_simd_portable__vxarq_u64_5b(a, b);
 2059|  50.9k|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable__vxarq_u64_5b:
 2043|  50.9k|libcrux_sha3_simd_portable__vxarq_u64_5b(uint64_t a, uint64_t b) {
 2044|  50.9k|  return libcrux_sha3_simd_portable_rotate_left_5b(a ^ b);
 2045|  50.9k|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_rotate_left_5b:
 2032|  50.9k|libcrux_sha3_simd_portable_rotate_left_5b(uint64_t x) {
 2033|  50.9k|  return core_num__u64__rotate_left(x, (uint32_t)(int32_t)6);
 2034|  50.9k|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_xor_and_rotate_d2_6f:
 2093|  50.9k|libcrux_sha3_simd_portable_xor_and_rotate_d2_6f(uint64_t a, uint64_t b) {
 2094|  50.9k|  return libcrux_sha3_simd_portable__vxarq_u64_6f(a, b);
 2095|  50.9k|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable__vxarq_u64_6f:
 2079|  50.9k|libcrux_sha3_simd_portable__vxarq_u64_6f(uint64_t a, uint64_t b) {
 2080|  50.9k|  return libcrux_sha3_simd_portable_rotate_left_6f(a ^ b);
 2081|  50.9k|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_rotate_left_6f:
 2068|  50.9k|libcrux_sha3_simd_portable_rotate_left_6f(uint64_t x) {
 2069|  50.9k|  return core_num__u64__rotate_left(x, (uint32_t)(int32_t)43);
 2070|  50.9k|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_xor_and_rotate_d2_62:
 2129|  50.9k|libcrux_sha3_simd_portable_xor_and_rotate_d2_62(uint64_t a, uint64_t b) {
 2130|  50.9k|  return libcrux_sha3_simd_portable__vxarq_u64_62(a, b);
 2131|  50.9k|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable__vxarq_u64_62:
 2115|  50.9k|libcrux_sha3_simd_portable__vxarq_u64_62(uint64_t a, uint64_t b) {
 2116|  50.9k|  return libcrux_sha3_simd_portable_rotate_left_62(a ^ b);
 2117|  50.9k|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_rotate_left_62:
 2104|  50.9k|libcrux_sha3_simd_portable_rotate_left_62(uint64_t x) {
 2105|  50.9k|  return core_num__u64__rotate_left(x, (uint32_t)(int32_t)15);
 2106|  50.9k|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_xor_and_rotate_d2_23:
 2165|  50.9k|libcrux_sha3_simd_portable_xor_and_rotate_d2_23(uint64_t a, uint64_t b) {
 2166|  50.9k|  return libcrux_sha3_simd_portable__vxarq_u64_23(a, b);
 2167|  50.9k|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable__vxarq_u64_23:
 2151|  50.9k|libcrux_sha3_simd_portable__vxarq_u64_23(uint64_t a, uint64_t b) {
 2152|  50.9k|  return libcrux_sha3_simd_portable_rotate_left_23(a ^ b);
 2153|  50.9k|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_rotate_left_23:
 2140|  50.9k|libcrux_sha3_simd_portable_rotate_left_23(uint64_t x) {
 2141|  50.9k|  return core_num__u64__rotate_left(x, (uint32_t)(int32_t)61);
 2142|  50.9k|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_xor_and_rotate_d2_37:
 2201|  50.9k|libcrux_sha3_simd_portable_xor_and_rotate_d2_37(uint64_t a, uint64_t b) {
 2202|  50.9k|  return libcrux_sha3_simd_portable__vxarq_u64_37(a, b);
 2203|  50.9k|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable__vxarq_u64_37:
 2187|  50.9k|libcrux_sha3_simd_portable__vxarq_u64_37(uint64_t a, uint64_t b) {
 2188|  50.9k|  return libcrux_sha3_simd_portable_rotate_left_37(a ^ b);
 2189|  50.9k|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_rotate_left_37:
 2176|  50.9k|libcrux_sha3_simd_portable_rotate_left_37(uint64_t x) {
 2177|  50.9k|  return core_num__u64__rotate_left(x, (uint32_t)(int32_t)28);
 2178|  50.9k|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_xor_and_rotate_d2_bb:
 2237|  50.9k|libcrux_sha3_simd_portable_xor_and_rotate_d2_bb(uint64_t a, uint64_t b) {
 2238|  50.9k|  return libcrux_sha3_simd_portable__vxarq_u64_bb(a, b);
 2239|  50.9k|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable__vxarq_u64_bb:
 2223|  50.9k|libcrux_sha3_simd_portable__vxarq_u64_bb(uint64_t a, uint64_t b) {
 2224|  50.9k|  return libcrux_sha3_simd_portable_rotate_left_bb(a ^ b);
 2225|  50.9k|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_rotate_left_bb:
 2212|  50.9k|libcrux_sha3_simd_portable_rotate_left_bb(uint64_t x) {
 2213|  50.9k|  return core_num__u64__rotate_left(x, (uint32_t)(int32_t)55);
 2214|  50.9k|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_xor_and_rotate_d2_b9:
 2273|  50.9k|libcrux_sha3_simd_portable_xor_and_rotate_d2_b9(uint64_t a, uint64_t b) {
 2274|  50.9k|  return libcrux_sha3_simd_portable__vxarq_u64_b9(a, b);
 2275|  50.9k|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable__vxarq_u64_b9:
 2259|  50.9k|libcrux_sha3_simd_portable__vxarq_u64_b9(uint64_t a, uint64_t b) {
 2260|  50.9k|  return libcrux_sha3_simd_portable_rotate_left_b9(a ^ b);
 2261|  50.9k|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_rotate_left_b9:
 2248|  50.9k|libcrux_sha3_simd_portable_rotate_left_b9(uint64_t x) {
 2249|  50.9k|  return core_num__u64__rotate_left(x, (uint32_t)(int32_t)25);
 2250|  50.9k|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_xor_and_rotate_d2_54:
 2309|  50.9k|libcrux_sha3_simd_portable_xor_and_rotate_d2_54(uint64_t a, uint64_t b) {
 2310|  50.9k|  return libcrux_sha3_simd_portable__vxarq_u64_54(a, b);
 2311|  50.9k|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable__vxarq_u64_54:
 2295|  50.9k|libcrux_sha3_simd_portable__vxarq_u64_54(uint64_t a, uint64_t b) {
 2296|  50.9k|  return libcrux_sha3_simd_portable_rotate_left_54(a ^ b);
 2297|  50.9k|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_rotate_left_54:
 2284|  50.9k|libcrux_sha3_simd_portable_rotate_left_54(uint64_t x) {
 2285|  50.9k|  return core_num__u64__rotate_left(x, (uint32_t)(int32_t)21);
 2286|  50.9k|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_xor_and_rotate_d2_4c:
 2345|  50.9k|libcrux_sha3_simd_portable_xor_and_rotate_d2_4c(uint64_t a, uint64_t b) {
 2346|  50.9k|  return libcrux_sha3_simd_portable__vxarq_u64_4c(a, b);
 2347|  50.9k|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable__vxarq_u64_4c:
 2331|  50.9k|libcrux_sha3_simd_portable__vxarq_u64_4c(uint64_t a, uint64_t b) {
 2332|  50.9k|  return libcrux_sha3_simd_portable_rotate_left_4c(a ^ b);
 2333|  50.9k|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_rotate_left_4c:
 2320|  50.9k|libcrux_sha3_simd_portable_rotate_left_4c(uint64_t x) {
 2321|  50.9k|  return core_num__u64__rotate_left(x, (uint32_t)(int32_t)56);
 2322|  50.9k|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_xor_and_rotate_d2_ce:
 2381|  50.9k|libcrux_sha3_simd_portable_xor_and_rotate_d2_ce(uint64_t a, uint64_t b) {
 2382|  50.9k|  return libcrux_sha3_simd_portable__vxarq_u64_ce(a, b);
 2383|  50.9k|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable__vxarq_u64_ce:
 2367|  50.9k|libcrux_sha3_simd_portable__vxarq_u64_ce(uint64_t a, uint64_t b) {
 2368|  50.9k|  return libcrux_sha3_simd_portable_rotate_left_ce(a ^ b);
 2369|  50.9k|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_rotate_left_ce:
 2356|  50.9k|libcrux_sha3_simd_portable_rotate_left_ce(uint64_t x) {
 2357|  50.9k|  return core_num__u64__rotate_left(x, (uint32_t)(int32_t)27);
 2358|  50.9k|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_xor_and_rotate_d2_77:
 2417|  50.9k|libcrux_sha3_simd_portable_xor_and_rotate_d2_77(uint64_t a, uint64_t b) {
 2418|  50.9k|  return libcrux_sha3_simd_portable__vxarq_u64_77(a, b);
 2419|  50.9k|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable__vxarq_u64_77:
 2403|  50.9k|libcrux_sha3_simd_portable__vxarq_u64_77(uint64_t a, uint64_t b) {
 2404|  50.9k|  return libcrux_sha3_simd_portable_rotate_left_77(a ^ b);
 2405|  50.9k|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_rotate_left_77:
 2392|  50.9k|libcrux_sha3_simd_portable_rotate_left_77(uint64_t x) {
 2393|  50.9k|  return core_num__u64__rotate_left(x, (uint32_t)(int32_t)20);
 2394|  50.9k|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_xor_and_rotate_d2_25:
 2453|  50.9k|libcrux_sha3_simd_portable_xor_and_rotate_d2_25(uint64_t a, uint64_t b) {
 2454|  50.9k|  return libcrux_sha3_simd_portable__vxarq_u64_25(a, b);
 2455|  50.9k|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable__vxarq_u64_25:
 2439|  50.9k|libcrux_sha3_simd_portable__vxarq_u64_25(uint64_t a, uint64_t b) {
 2440|  50.9k|  return libcrux_sha3_simd_portable_rotate_left_25(a ^ b);
 2441|  50.9k|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_rotate_left_25:
 2428|  50.9k|libcrux_sha3_simd_portable_rotate_left_25(uint64_t x) {
 2429|  50.9k|  return core_num__u64__rotate_left(x, (uint32_t)(int32_t)39);
 2430|  50.9k|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_xor_and_rotate_d2_af:
 2489|  50.9k|libcrux_sha3_simd_portable_xor_and_rotate_d2_af(uint64_t a, uint64_t b) {
 2490|  50.9k|  return libcrux_sha3_simd_portable__vxarq_u64_af(a, b);
 2491|  50.9k|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable__vxarq_u64_af:
 2475|  50.9k|libcrux_sha3_simd_portable__vxarq_u64_af(uint64_t a, uint64_t b) {
 2476|  50.9k|  return libcrux_sha3_simd_portable_rotate_left_af(a ^ b);
 2477|  50.9k|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_rotate_left_af:
 2464|  50.9k|libcrux_sha3_simd_portable_rotate_left_af(uint64_t x) {
 2465|  50.9k|  return core_num__u64__rotate_left(x, (uint32_t)(int32_t)8);
 2466|  50.9k|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_xor_and_rotate_d2_fd:
 2525|  50.9k|libcrux_sha3_simd_portable_xor_and_rotate_d2_fd(uint64_t a, uint64_t b) {
 2526|  50.9k|  return libcrux_sha3_simd_portable__vxarq_u64_fd(a, b);
 2527|  50.9k|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable__vxarq_u64_fd:
 2511|  50.9k|libcrux_sha3_simd_portable__vxarq_u64_fd(uint64_t a, uint64_t b) {
 2512|  50.9k|  return libcrux_sha3_simd_portable_rotate_left_fd(a ^ b);
 2513|  50.9k|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_rotate_left_fd:
 2500|  50.9k|libcrux_sha3_simd_portable_rotate_left_fd(uint64_t x) {
 2501|  50.9k|  return core_num__u64__rotate_left(x, (uint32_t)(int32_t)14);
 2502|  50.9k|}
libcrux_mlkem768_sha3.c:libcrux_sha3_generic_keccak_pi_80_04:
 2753|  50.9k|    libcrux_sha3_generic_keccak_KeccakState_17 *self) {
 2754|  50.9k|  libcrux_sha3_generic_keccak_KeccakState_17 old = self[0U];
 2755|  50.9k|  libcrux_sha3_generic_keccak_set_80_04(
 2756|  50.9k|      self, (size_t)1U, (size_t)0U,
 2757|  50.9k|      libcrux_sha3_generic_keccak_index_c2_04(
 2758|  50.9k|          &old, (KRML_CLITERAL(size_t_x2){.fst = (size_t)0U,
  ------------------
  |  |  154|  50.9k|#define KRML_CLITERAL(type) (type)
  ------------------
 2759|  50.9k|                                          .snd = (size_t)3U}))[0U]);
 2760|  50.9k|  libcrux_sha3_generic_keccak_set_80_04(
 2761|  50.9k|      self, (size_t)2U, (size_t)0U,
 2762|  50.9k|      libcrux_sha3_generic_keccak_index_c2_04(
 2763|  50.9k|          &old, (KRML_CLITERAL(size_t_x2){.fst = (size_t)0U,
  ------------------
  |  |  154|  50.9k|#define KRML_CLITERAL(type) (type)
  ------------------
 2764|  50.9k|                                          .snd = (size_t)1U}))[0U]);
 2765|  50.9k|  libcrux_sha3_generic_keccak_set_80_04(
 2766|  50.9k|      self, (size_t)3U, (size_t)0U,
 2767|  50.9k|      libcrux_sha3_generic_keccak_index_c2_04(
 2768|  50.9k|          &old, (KRML_CLITERAL(size_t_x2){.fst = (size_t)0U,
  ------------------
  |  |  154|  50.9k|#define KRML_CLITERAL(type) (type)
  ------------------
 2769|  50.9k|                                          .snd = (size_t)4U}))[0U]);
 2770|  50.9k|  libcrux_sha3_generic_keccak_set_80_04(
 2771|  50.9k|      self, (size_t)4U, (size_t)0U,
 2772|  50.9k|      libcrux_sha3_generic_keccak_index_c2_04(
 2773|  50.9k|          &old, (KRML_CLITERAL(size_t_x2){.fst = (size_t)0U,
  ------------------
  |  |  154|  50.9k|#define KRML_CLITERAL(type) (type)
  ------------------
 2774|  50.9k|                                          .snd = (size_t)2U}))[0U]);
 2775|  50.9k|  libcrux_sha3_generic_keccak_set_80_04(
 2776|  50.9k|      self, (size_t)0U, (size_t)1U,
 2777|  50.9k|      libcrux_sha3_generic_keccak_index_c2_04(
 2778|  50.9k|          &old, (KRML_CLITERAL(size_t_x2){.fst = (size_t)1U,
  ------------------
  |  |  154|  50.9k|#define KRML_CLITERAL(type) (type)
  ------------------
 2779|  50.9k|                                          .snd = (size_t)1U}))[0U]);
 2780|  50.9k|  libcrux_sha3_generic_keccak_set_80_04(
 2781|  50.9k|      self, (size_t)1U, (size_t)1U,
 2782|  50.9k|      libcrux_sha3_generic_keccak_index_c2_04(
 2783|  50.9k|          &old, (KRML_CLITERAL(size_t_x2){.fst = (size_t)1U,
  ------------------
  |  |  154|  50.9k|#define KRML_CLITERAL(type) (type)
  ------------------
 2784|  50.9k|                                          .snd = (size_t)4U}))[0U]);
 2785|  50.9k|  libcrux_sha3_generic_keccak_set_80_04(
 2786|  50.9k|      self, (size_t)2U, (size_t)1U,
 2787|  50.9k|      libcrux_sha3_generic_keccak_index_c2_04(
 2788|  50.9k|          &old, (KRML_CLITERAL(size_t_x2){.fst = (size_t)1U,
  ------------------
  |  |  154|  50.9k|#define KRML_CLITERAL(type) (type)
  ------------------
 2789|  50.9k|                                          .snd = (size_t)2U}))[0U]);
 2790|  50.9k|  libcrux_sha3_generic_keccak_set_80_04(
 2791|  50.9k|      self, (size_t)3U, (size_t)1U,
 2792|  50.9k|      libcrux_sha3_generic_keccak_index_c2_04(
 2793|  50.9k|          &old, (KRML_CLITERAL(size_t_x2){.fst = (size_t)1U,
  ------------------
  |  |  154|  50.9k|#define KRML_CLITERAL(type) (type)
  ------------------
 2794|  50.9k|                                          .snd = (size_t)0U}))[0U]);
 2795|  50.9k|  libcrux_sha3_generic_keccak_set_80_04(
 2796|  50.9k|      self, (size_t)4U, (size_t)1U,
 2797|  50.9k|      libcrux_sha3_generic_keccak_index_c2_04(
 2798|  50.9k|          &old, (KRML_CLITERAL(size_t_x2){.fst = (size_t)1U,
  ------------------
  |  |  154|  50.9k|#define KRML_CLITERAL(type) (type)
  ------------------
 2799|  50.9k|                                          .snd = (size_t)3U}))[0U]);
 2800|  50.9k|  libcrux_sha3_generic_keccak_set_80_04(
 2801|  50.9k|      self, (size_t)0U, (size_t)2U,
 2802|  50.9k|      libcrux_sha3_generic_keccak_index_c2_04(
 2803|  50.9k|          &old, (KRML_CLITERAL(size_t_x2){.fst = (size_t)2U,
  ------------------
  |  |  154|  50.9k|#define KRML_CLITERAL(type) (type)
  ------------------
 2804|  50.9k|                                          .snd = (size_t)2U}))[0U]);
 2805|  50.9k|  libcrux_sha3_generic_keccak_set_80_04(
 2806|  50.9k|      self, (size_t)1U, (size_t)2U,
 2807|  50.9k|      libcrux_sha3_generic_keccak_index_c2_04(
 2808|  50.9k|          &old, (KRML_CLITERAL(size_t_x2){.fst = (size_t)2U,
  ------------------
  |  |  154|  50.9k|#define KRML_CLITERAL(type) (type)
  ------------------
 2809|  50.9k|                                          .snd = (size_t)0U}))[0U]);
 2810|  50.9k|  libcrux_sha3_generic_keccak_set_80_04(
 2811|  50.9k|      self, (size_t)2U, (size_t)2U,
 2812|  50.9k|      libcrux_sha3_generic_keccak_index_c2_04(
 2813|  50.9k|          &old, (KRML_CLITERAL(size_t_x2){.fst = (size_t)2U,
  ------------------
  |  |  154|  50.9k|#define KRML_CLITERAL(type) (type)
  ------------------
 2814|  50.9k|                                          .snd = (size_t)3U}))[0U]);
 2815|  50.9k|  libcrux_sha3_generic_keccak_set_80_04(
 2816|  50.9k|      self, (size_t)3U, (size_t)2U,
 2817|  50.9k|      libcrux_sha3_generic_keccak_index_c2_04(
 2818|  50.9k|          &old, (KRML_CLITERAL(size_t_x2){.fst = (size_t)2U,
  ------------------
  |  |  154|  50.9k|#define KRML_CLITERAL(type) (type)
  ------------------
 2819|  50.9k|                                          .snd = (size_t)1U}))[0U]);
 2820|  50.9k|  libcrux_sha3_generic_keccak_set_80_04(
 2821|  50.9k|      self, (size_t)4U, (size_t)2U,
 2822|  50.9k|      libcrux_sha3_generic_keccak_index_c2_04(
 2823|  50.9k|          &old, (KRML_CLITERAL(size_t_x2){.fst = (size_t)2U,
  ------------------
  |  |  154|  50.9k|#define KRML_CLITERAL(type) (type)
  ------------------
 2824|  50.9k|                                          .snd = (size_t)4U}))[0U]);
 2825|  50.9k|  libcrux_sha3_generic_keccak_set_80_04(
 2826|  50.9k|      self, (size_t)0U, (size_t)3U,
 2827|  50.9k|      libcrux_sha3_generic_keccak_index_c2_04(
 2828|  50.9k|          &old, (KRML_CLITERAL(size_t_x2){.fst = (size_t)3U,
  ------------------
  |  |  154|  50.9k|#define KRML_CLITERAL(type) (type)
  ------------------
 2829|  50.9k|                                          .snd = (size_t)3U}))[0U]);
 2830|  50.9k|  libcrux_sha3_generic_keccak_set_80_04(
 2831|  50.9k|      self, (size_t)1U, (size_t)3U,
 2832|  50.9k|      libcrux_sha3_generic_keccak_index_c2_04(
 2833|  50.9k|          &old, (KRML_CLITERAL(size_t_x2){.fst = (size_t)3U,
  ------------------
  |  |  154|  50.9k|#define KRML_CLITERAL(type) (type)
  ------------------
 2834|  50.9k|                                          .snd = (size_t)1U}))[0U]);
 2835|  50.9k|  libcrux_sha3_generic_keccak_set_80_04(
 2836|  50.9k|      self, (size_t)2U, (size_t)3U,
 2837|  50.9k|      libcrux_sha3_generic_keccak_index_c2_04(
 2838|  50.9k|          &old, (KRML_CLITERAL(size_t_x2){.fst = (size_t)3U,
  ------------------
  |  |  154|  50.9k|#define KRML_CLITERAL(type) (type)
  ------------------
 2839|  50.9k|                                          .snd = (size_t)4U}))[0U]);
 2840|  50.9k|  libcrux_sha3_generic_keccak_set_80_04(
 2841|  50.9k|      self, (size_t)3U, (size_t)3U,
 2842|  50.9k|      libcrux_sha3_generic_keccak_index_c2_04(
 2843|  50.9k|          &old, (KRML_CLITERAL(size_t_x2){.fst = (size_t)3U,
  ------------------
  |  |  154|  50.9k|#define KRML_CLITERAL(type) (type)
  ------------------
 2844|  50.9k|                                          .snd = (size_t)2U}))[0U]);
 2845|  50.9k|  libcrux_sha3_generic_keccak_set_80_04(
 2846|  50.9k|      self, (size_t)4U, (size_t)3U,
 2847|  50.9k|      libcrux_sha3_generic_keccak_index_c2_04(
 2848|  50.9k|          &old, (KRML_CLITERAL(size_t_x2){.fst = (size_t)3U,
  ------------------
  |  |  154|  50.9k|#define KRML_CLITERAL(type) (type)
  ------------------
 2849|  50.9k|                                          .snd = (size_t)0U}))[0U]);
 2850|  50.9k|  libcrux_sha3_generic_keccak_set_80_04(
 2851|  50.9k|      self, (size_t)0U, (size_t)4U,
 2852|  50.9k|      libcrux_sha3_generic_keccak_index_c2_04(
 2853|  50.9k|          &old, (KRML_CLITERAL(size_t_x2){.fst = (size_t)4U,
  ------------------
  |  |  154|  50.9k|#define KRML_CLITERAL(type) (type)
  ------------------
 2854|  50.9k|                                          .snd = (size_t)4U}))[0U]);
 2855|  50.9k|  libcrux_sha3_generic_keccak_set_80_04(
 2856|  50.9k|      self, (size_t)1U, (size_t)4U,
 2857|  50.9k|      libcrux_sha3_generic_keccak_index_c2_04(
 2858|  50.9k|          &old, (KRML_CLITERAL(size_t_x2){.fst = (size_t)4U,
  ------------------
  |  |  154|  50.9k|#define KRML_CLITERAL(type) (type)
  ------------------
 2859|  50.9k|                                          .snd = (size_t)2U}))[0U]);
 2860|  50.9k|  libcrux_sha3_generic_keccak_set_80_04(
 2861|  50.9k|      self, (size_t)2U, (size_t)4U,
 2862|  50.9k|      libcrux_sha3_generic_keccak_index_c2_04(
 2863|  50.9k|          &old, (KRML_CLITERAL(size_t_x2){.fst = (size_t)4U,
  ------------------
  |  |  154|  50.9k|#define KRML_CLITERAL(type) (type)
  ------------------
 2864|  50.9k|                                          .snd = (size_t)0U}))[0U]);
 2865|  50.9k|  libcrux_sha3_generic_keccak_set_80_04(
 2866|  50.9k|      self, (size_t)3U, (size_t)4U,
 2867|  50.9k|      libcrux_sha3_generic_keccak_index_c2_04(
 2868|  50.9k|          &old, (KRML_CLITERAL(size_t_x2){.fst = (size_t)4U,
  ------------------
  |  |  154|  50.9k|#define KRML_CLITERAL(type) (type)
  ------------------
 2869|  50.9k|                                          .snd = (size_t)3U}))[0U]);
 2870|  50.9k|  libcrux_sha3_generic_keccak_set_80_04(
 2871|  50.9k|      self, (size_t)4U, (size_t)4U,
 2872|  50.9k|      libcrux_sha3_generic_keccak_index_c2_04(
 2873|  50.9k|          &old, (KRML_CLITERAL(size_t_x2){.fst = (size_t)4U,
  ------------------
  |  |  154|  50.9k|#define KRML_CLITERAL(type) (type)
  ------------------
 2874|  50.9k|                                          .snd = (size_t)1U}))[0U]);
 2875|  50.9k|}
libcrux_mlkem768_sha3.c:libcrux_sha3_generic_keccak_chi_80_04:
 2888|  50.9k|    libcrux_sha3_generic_keccak_KeccakState_17 *self) {
 2889|  50.9k|  libcrux_sha3_generic_keccak_KeccakState_17 old = self[0U];
 2890|   305k|  for (size_t i0 = (size_t)0U; i0 < (size_t)5U; i0++) {
  ------------------
  |  Branch (2890:32): [True: 254k, False: 50.9k]
  ------------------
 2891|   254k|    size_t i1 = i0;
 2892|  1.52M|    for (size_t i = (size_t)0U; i < (size_t)5U; i++) {
  ------------------
  |  Branch (2892:33): [True: 1.27M, False: 254k]
  ------------------
 2893|  1.27M|      size_t j = i;
 2894|  1.27M|      libcrux_sha3_generic_keccak_set_80_04(
 2895|  1.27M|          self, i1, j,
 2896|  1.27M|          libcrux_sha3_simd_portable_and_not_xor_d2(
 2897|  1.27M|              libcrux_sha3_generic_keccak_index_c2_04(
 2898|  1.27M|                  self, (KRML_CLITERAL(size_t_x2){.fst = i1, .snd = j}))[0U],
  ------------------
  |  |  154|  1.27M|#define KRML_CLITERAL(type) (type)
  ------------------
 2899|  1.27M|              libcrux_sha3_generic_keccak_index_c2_04(
 2900|  1.27M|                  &old,
 2901|  1.27M|                  (KRML_CLITERAL(size_t_x2){
  ------------------
  |  |  154|  1.27M|#define KRML_CLITERAL(type) (type)
  ------------------
 2902|  1.27M|                      .fst = i1, .snd = (j + (size_t)2U) % (size_t)5U}))[0U],
 2903|  1.27M|              libcrux_sha3_generic_keccak_index_c2_04(
 2904|  1.27M|                  &old,
 2905|  1.27M|                  (KRML_CLITERAL(size_t_x2){
  ------------------
  |  |  154|  1.27M|#define KRML_CLITERAL(type) (type)
  ------------------
 2906|  1.27M|                      .fst = i1, .snd = (j + (size_t)1U) % (size_t)5U}))[0U]));
 2907|  1.27M|    }
 2908|   254k|  }
 2909|  50.9k|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_and_not_xor_d2:
 1371|  1.27M|libcrux_sha3_simd_portable_and_not_xor_d2(uint64_t a, uint64_t b, uint64_t c) {
 1372|  1.27M|  return libcrux_sha3_simd_portable__vbcaxq_u64(a, b, c);
 1373|  1.27M|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable__vbcaxq_u64:
 1363|  1.27M|libcrux_sha3_simd_portable__vbcaxq_u64(uint64_t a, uint64_t b, uint64_t c) {
 1364|  1.27M|  return a ^ (b & ~c);
 1365|  1.27M|}
libcrux_mlkem768_sha3.c:libcrux_sha3_generic_keccak_iota_80_04:
 2922|  50.9k|    libcrux_sha3_generic_keccak_KeccakState_17 *self, size_t i) {
 2923|  50.9k|  libcrux_sha3_generic_keccak_set_80_04(
 2924|  50.9k|      self, (size_t)0U, (size_t)0U,
 2925|  50.9k|      libcrux_sha3_simd_portable_xor_constant_d2(
 2926|  50.9k|          libcrux_sha3_generic_keccak_index_c2_04(
 2927|  50.9k|              self, (KRML_CLITERAL(size_t_x2){.fst = (size_t)0U,
  ------------------
  |  |  154|  50.9k|#define KRML_CLITERAL(type) (type)
  ------------------
 2928|  50.9k|                                              .snd = (size_t)0U}))[0U],
 2929|  50.9k|          libcrux_sha3_generic_keccak_constants_ROUNDCONSTANTS[i]));
 2930|  50.9k|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_xor_constant_d2:
 1384|  50.9k|libcrux_sha3_simd_portable_xor_constant_d2(uint64_t a, uint64_t c) {
 1385|  50.9k|  return libcrux_sha3_simd_portable__veorq_n_u64(a, c);
 1386|  50.9k|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable__veorq_n_u64:
 1376|  50.9k|libcrux_sha3_simd_portable__veorq_n_u64(uint64_t a, uint64_t c) {
 1377|  50.9k|  return a ^ c;
 1378|  50.9k|}
libcrux_mlkem768_sha3.c:libcrux_sha3_portable_shake256:
 3455|    294|    Eurydice_slice digest, Eurydice_slice data) {
 3456|    294|  libcrux_sha3_generic_keccak_portable_keccak1_ad0(data, digest);
 3457|    294|}
libcrux_mlkem768_sha3.c:libcrux_sha3_generic_keccak_portable_keccak1_ad0:
 3419|    294|    Eurydice_slice data, Eurydice_slice out) {
 3420|    294|  libcrux_sha3_generic_keccak_KeccakState_17 s =
 3421|    294|      libcrux_sha3_generic_keccak_new_80_04();
 3422|    294|  size_t data_len = Eurydice_slice_len(data, uint8_t);
  ------------------
  |  |  173|    294|#define Eurydice_slice_len(s, _) (s).len
  ------------------
 3423|    294|  for (size_t i = (size_t)0U; i < data_len / (size_t)136U; i++) {
  ------------------
  |  Branch (3423:31): [True: 0, False: 294]
  ------------------
 3424|      0|    size_t i0 = i;
 3425|      0|    Eurydice_slice buf[1U] = {data};
 3426|      0|    libcrux_sha3_generic_keccak_absorb_block_80_c60(&s, buf, i0 * (size_t)136U);
 3427|      0|  }
 3428|    294|  size_t rem = data_len % (size_t)136U;
 3429|    294|  Eurydice_slice buf[1U] = {data};
 3430|    294|  libcrux_sha3_generic_keccak_absorb_final_80_9e1(&s, buf, data_len - rem, rem);
 3431|    294|  size_t outlen = Eurydice_slice_len(out, uint8_t);
  ------------------
  |  |  173|    294|#define Eurydice_slice_len(s, _) (s).len
  ------------------
 3432|    294|  size_t blocks = outlen / (size_t)136U;
 3433|    294|  size_t last = outlen - outlen % (size_t)136U;
 3434|    294|  if (blocks == (size_t)0U) {
  ------------------
  |  Branch (3434:7): [True: 294, False: 0]
  ------------------
 3435|    294|    libcrux_sha3_simd_portable_squeeze_13_5b(&s, out, (size_t)0U, outlen);
 3436|    294|  } 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|    294|}
libcrux_mlkem768_sha3.c:libcrux_sha3_generic_keccak_absorb_block_80_c60:
 3193|    392|    size_t start) {
 3194|    392|  libcrux_sha3_simd_portable_load_block_a1_5b(self, blocks, start);
 3195|    392|  libcrux_sha3_generic_keccak_keccakf1600_80_04(self);
 3196|    392|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_load_block_a1_5b:
 3176|    392|    size_t start) {
 3177|    392|  libcrux_sha3_simd_portable_load_block_5b(self->st, input[0U], start);
 3178|    392|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_load_block_5b:
 3138|    735|    uint64_t *state, Eurydice_slice blocks, size_t start) {
 3139|    735|  uint64_t state_flat[25U] = {0U};
 3140|  13.2k|  for (size_t i = (size_t)0U; i < (size_t)136U / (size_t)8U; i++) {
  ------------------
  |  Branch (3140:31): [True: 12.4k, False: 735]
  ------------------
 3141|  12.4k|    size_t i0 = i;
 3142|  12.4k|    size_t offset = start + (size_t)8U * i0;
 3143|  12.4k|    uint8_t uu____0[8U];
 3144|  12.4k|    Result_15 dst;
 3145|  12.4k|    Eurydice_slice_to_array2(
  ------------------
  |  |  277|  12.4k|  Eurydice_slice_to_array3(&(dst)->tag, (char *)&(dst)->val.case_Ok, src, \
  |  |  278|  12.4k|                           sizeof(t_arr))
  ------------------
 3146|  12.4k|        &dst,
 3147|  12.4k|        Eurydice_slice_subslice3(blocks, offset, offset + (size_t)8U,
 3148|  12.4k|                                 uint8_t *),
 3149|  12.4k|        Eurydice_slice, uint8_t[8U], TryFromSliceError);
 3150|  12.4k|    unwrap_26_68(dst, uu____0);
 3151|  12.4k|    state_flat[i0] = core_num__u64__from_le_bytes(uu____0);
 3152|  12.4k|  }
 3153|  13.2k|  for (size_t i = (size_t)0U; i < (size_t)136U / (size_t)8U; i++) {
  ------------------
  |  Branch (3153:31): [True: 12.4k, False: 735]
  ------------------
 3154|  12.4k|    size_t i0 = i;
 3155|  12.4k|    libcrux_sha3_traits_set_ij_04(
 3156|  12.4k|        state, i0 / (size_t)5U, i0 % (size_t)5U,
 3157|  12.4k|        libcrux_sha3_traits_get_ij_04(state, i0 / (size_t)5U,
 3158|  12.4k|                                      i0 % (size_t)5U)[0U] ^
 3159|  12.4k|            state_flat[i0]);
 3160|  12.4k|  }
 3161|    735|}
libcrux_mlkem768_sha3.c:libcrux_sha3_generic_keccak_absorb_final_80_9e1:
 3407|    294|    size_t start, size_t len) {
 3408|    294|  libcrux_sha3_simd_portable_load_last_a1_ad0(self, last, start, len);
 3409|    294|  libcrux_sha3_generic_keccak_keccakf1600_80_04(self);
 3410|    294|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_load_last_a1_ad0:
 3389|    294|    size_t start, size_t len) {
 3390|    294|  libcrux_sha3_simd_portable_load_last_ad0(self->st, input[0U], start, len);
 3391|    294|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_load_last_ad0:
 3362|    294|    uint64_t *state, Eurydice_slice blocks, size_t start, size_t len) {
 3363|    294|  uint8_t buffer[136U] = {0U};
 3364|    294|  Eurydice_slice_copy(
  ------------------
  |  |  229|    294|  memcpy(dst.ptr, src.ptr, dst.len * sizeof(t))
  ------------------
 3365|    294|      Eurydice_array_to_subslice3(buffer, (size_t)0U, len, uint8_t *),
 3366|    294|      Eurydice_slice_subslice3(blocks, start, start + len, uint8_t *), uint8_t);
 3367|    294|  buffer[len] = 31U;
 3368|    294|  size_t uu____0 = (size_t)136U - (size_t)1U;
 3369|    294|  buffer[uu____0] = (uint32_t)buffer[uu____0] | 128U;
 3370|    294|  libcrux_sha3_simd_portable_load_block_5b(
 3371|    294|      state, Eurydice_array_to_slice((size_t)136U, buffer, uint8_t),
  ------------------
  |  |  204|    294|  EURYDICE_SLICE(x, 0,                     \
  |  |  ------------------
  |  |  |  |  169|    294|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|    294|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  205|    294|                 end) /* x is already at an array type, no need for cast */
  ------------------
 3372|    294|      (size_t)0U);
 3373|    294|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_squeeze_13_5b:
 3304|    343|    size_t start, size_t len) {
 3305|    343|  libcrux_sha3_simd_portable_store_block_5b(self->st, out, start, len);
 3306|    343|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_store_block_5b:
 3261|    343|    uint64_t *s, Eurydice_slice out, size_t start, size_t len) {
 3262|    343|  size_t octets = len / (size_t)8U;
 3263|  5.24k|  for (size_t i = (size_t)0U; i < octets; i++) {
  ------------------
  |  Branch (3263:31): [True: 4.90k, False: 343]
  ------------------
 3264|  4.90k|    size_t i0 = i;
 3265|  4.90k|    Eurydice_slice uu____0 = Eurydice_slice_subslice3(
  ------------------
  |  |  195|  4.90k|  EURYDICE_SLICE((t_ptr)s.ptr, (start), (end))
  |  |  ------------------
  |  |  |  |  169|  4.90k|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|  4.90k|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3266|  4.90k|        out, start + (size_t)8U * i0, start + (size_t)8U * i0 + (size_t)8U,
 3267|  4.90k|        uint8_t *);
 3268|  4.90k|    uint8_t ret[8U];
 3269|  4.90k|    core_num__u64__to_le_bytes(
 3270|  4.90k|        libcrux_sha3_traits_get_ij_04(s, i0 / (size_t)5U, i0 % (size_t)5U)[0U],
 3271|  4.90k|        ret);
 3272|  4.90k|    Eurydice_slice_copy(
  ------------------
  |  |  229|  4.90k|  memcpy(dst.ptr, src.ptr, dst.len * sizeof(t))
  ------------------
 3273|  4.90k|        uu____0, Eurydice_array_to_slice((size_t)8U, ret, uint8_t), uint8_t);
 3274|  4.90k|  }
 3275|    343|  size_t remaining = len % (size_t)8U;
 3276|    343|  if (remaining > (size_t)0U) {
  ------------------
  |  Branch (3276:7): [True: 0, False: 343]
  ------------------
 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|    343|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_ind_cpa_unpacked_default_8b_1b:
 6354|     49|libcrux_ml_kem_ind_cpa_unpacked_default_8b_1b(void) {
 6355|     49|  libcrux_ml_kem_polynomial_PolynomialRingElement_1d uu____0[3U];
 6356|    196|  for (size_t i = (size_t)0U; i < (size_t)3U; i++) {
  ------------------
  |  Branch (6356:31): [True: 147, False: 49]
  ------------------
 6357|    147|    uu____0[i] = libcrux_ml_kem_polynomial_ZERO_d6_ea();
 6358|    147|  }
 6359|     49|  uint8_t uu____1[32U] = {0U};
 6360|     49|  libcrux_ml_kem_ind_cpa_unpacked_IndCpaPublicKeyUnpacked_a0 lit;
 6361|     49|  memcpy(
 6362|     49|      lit.t_as_ntt, uu____0,
 6363|     49|      (size_t)3U * sizeof(libcrux_ml_kem_polynomial_PolynomialRingElement_1d));
 6364|     49|  memcpy(lit.seed_for_A, uu____1, (size_t)32U * sizeof(uint8_t));
 6365|     49|  libcrux_ml_kem_polynomial_PolynomialRingElement_1d repeat_expression0[3U][3U];
 6366|    196|  for (size_t i0 = (size_t)0U; i0 < (size_t)3U; i0++) {
  ------------------
  |  Branch (6366:32): [True: 147, False: 49]
  ------------------
 6367|    147|    libcrux_ml_kem_polynomial_PolynomialRingElement_1d repeat_expression[3U];
 6368|    588|    for (size_t i = (size_t)0U; i < (size_t)3U; i++) {
  ------------------
  |  Branch (6368:33): [True: 441, False: 147]
  ------------------
 6369|    441|      repeat_expression[i] = libcrux_ml_kem_polynomial_ZERO_d6_ea();
 6370|    441|    }
 6371|    147|    memcpy(repeat_expression0[i0], repeat_expression,
 6372|    147|           (size_t)3U *
 6373|    147|               sizeof(libcrux_ml_kem_polynomial_PolynomialRingElement_1d));
 6374|    147|  }
 6375|     49|  memcpy(lit.A, repeat_expression0,
 6376|     49|         (size_t)3U *
 6377|     49|             sizeof(libcrux_ml_kem_polynomial_PolynomialRingElement_1d[3U]));
 6378|     49|  return lit;
 6379|     49|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_utils_into_padded_array_b6:
  903|     49|    Eurydice_slice slice, uint8_t ret[34U]) {
  904|     49|  uint8_t out[34U] = {0U};
  905|     49|  uint8_t *uu____0 = out;
  906|     49|  Eurydice_slice_copy(
  ------------------
  |  |  229|     49|  memcpy(dst.ptr, src.ptr, dst.len * sizeof(t))
  ------------------
  907|     49|      Eurydice_array_to_subslice3(
  908|     49|          uu____0, (size_t)0U, Eurydice_slice_len(slice, uint8_t), uint8_t *),
  909|     49|      slice, uint8_t);
  910|     49|  memcpy(ret, out, (size_t)34U * sizeof(uint8_t));
  911|     49|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_matrix_sample_matrix_A_2b:
 6854|     49|    uint8_t *seed, bool transpose) {
 6855|    196|  for (size_t i0 = (size_t)0U; i0 < (size_t)3U; i0++) {
  ------------------
  |  Branch (6855:32): [True: 147, False: 49]
  ------------------
 6856|    147|    size_t i1 = i0;
 6857|    147|    uint8_t seeds[3U][34U];
 6858|    588|    for (size_t i = (size_t)0U; i < (size_t)3U; i++) {
  ------------------
  |  Branch (6858:33): [True: 441, False: 147]
  ------------------
 6859|    441|      core_array__core__clone__Clone_for__Array_T__N___clone(
  ------------------
  |  |  236|    441|  (memcpy(dst, src, len * sizeof(elem_type)))
  ------------------
 6860|    441|          (size_t)34U, seed, seeds[i], uint8_t, void *);
 6861|    441|    }
 6862|    588|    for (size_t i = (size_t)0U; i < (size_t)3U; i++) {
  ------------------
  |  Branch (6862:33): [True: 441, False: 147]
  ------------------
 6863|    441|      size_t j = i;
 6864|    441|      seeds[j][32U] = (uint8_t)i1;
 6865|    441|      seeds[j][33U] = (uint8_t)j;
 6866|    441|    }
 6867|    147|    libcrux_ml_kem_polynomial_PolynomialRingElement_1d sampled[3U];
 6868|    147|    libcrux_ml_kem_sampling_sample_from_xof_2b(seeds, sampled);
 6869|    147|    for (size_t i = (size_t)0U;
 6870|    588|         i < Eurydice_slice_len(
  ------------------
  |  |  173|    588|#define Eurydice_slice_len(s, _) (s).len
  ------------------
  |  Branch (6870:10): [True: 441, False: 147]
  ------------------
 6871|    147|                 Eurydice_array_to_slice(
 6872|    147|                     (size_t)3U, sampled,
 6873|    147|                     libcrux_ml_kem_polynomial_PolynomialRingElement_1d),
 6874|    147|                 libcrux_ml_kem_polynomial_PolynomialRingElement_1d);
 6875|    441|         i++) {
 6876|    441|      size_t j = i;
 6877|    441|      libcrux_ml_kem_polynomial_PolynomialRingElement_1d sample = sampled[j];
 6878|    441|      if (transpose) {
  ------------------
  |  Branch (6878:11): [True: 441, False: 0]
  ------------------
 6879|    441|        A_transpose[j][i1] = sample;
 6880|    441|      } else {
 6881|      0|        A_transpose[i1][j] = sample;
 6882|      0|      }
 6883|    441|    }
 6884|    147|  }
 6885|     49|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_sampling_sample_from_xof_2b:
 6808|    147|    libcrux_ml_kem_polynomial_PolynomialRingElement_1d ret[3U]) {
 6809|    147|  size_t sampled_coefficients[3U] = {0U};
 6810|    147|  int16_t out[3U][272U] = {{0U}};
 6811|    147|  libcrux_ml_kem_hash_functions_portable_PortableHash_88 xof_state =
 6812|    147|      libcrux_ml_kem_hash_functions_portable_shake128_init_absorb_final_4a_e0(
 6813|    147|          seeds);
 6814|    147|  uint8_t randomness0[3U][504U];
 6815|    147|  libcrux_ml_kem_hash_functions_portable_shake128_squeeze_first_three_blocks_4a_e0(
 6816|    147|      &xof_state, randomness0);
 6817|    147|  bool done = libcrux_ml_kem_sampling_sample_from_uniform_distribution_next_89(
 6818|    147|      randomness0, sampled_coefficients, out);
 6819|    152|  while (true) {
  ------------------
  |  Branch (6819:10): [True: 152, Folded]
  ------------------
 6820|    152|    if (done) {
  ------------------
  |  Branch (6820:9): [True: 147, False: 5]
  ------------------
 6821|    147|      break;
 6822|    147|    } else {
 6823|      5|      uint8_t randomness[3U][168U];
 6824|      5|      libcrux_ml_kem_hash_functions_portable_shake128_squeeze_next_block_4a_e0(
 6825|      5|          &xof_state, randomness);
 6826|      5|      done = libcrux_ml_kem_sampling_sample_from_uniform_distribution_next_890(
 6827|      5|          randomness, sampled_coefficients, out);
 6828|      5|    }
 6829|    152|  }
 6830|       |  /* Passing arrays by value in Rust generates a copy in C */
 6831|    147|  int16_t copy_of_out[3U][272U];
 6832|    147|  memcpy(copy_of_out, out, (size_t)3U * sizeof(int16_t[272U]));
 6833|    147|  libcrux_ml_kem_polynomial_PolynomialRingElement_1d ret0[3U];
 6834|    588|  for (size_t i = (size_t)0U; i < (size_t)3U; i++) {
  ------------------
  |  Branch (6834:31): [True: 441, False: 147]
  ------------------
 6835|       |    /* original Rust expression is not an lvalue in C */
 6836|    441|    void *lvalue = (void *)0U;
 6837|    441|    ret0[i] = libcrux_ml_kem_sampling_sample_from_xof_call_mut_e7_2b(
 6838|    441|        &lvalue, copy_of_out[i]);
 6839|    441|  }
 6840|    147|  memcpy(
 6841|    147|      ret, ret0,
 6842|    147|      (size_t)3U * sizeof(libcrux_ml_kem_polynomial_PolynomialRingElement_1d));
 6843|    147|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_hash_functions_portable_shake128_init_absorb_final_4a_e0:
 6489|    147|    uint8_t (*input)[34U]) {
 6490|    147|  return libcrux_ml_kem_hash_functions_portable_shake128_init_absorb_final_e0(
 6491|    147|      input);
 6492|    147|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_hash_functions_portable_shake128_init_absorb_final_e0:
 6460|    147|    uint8_t (*input)[34U]) {
 6461|    147|  libcrux_ml_kem_hash_functions_portable_PortableHash_88 shake128_state;
 6462|    147|  libcrux_sha3_generic_keccak_KeccakState_17 repeat_expression[3U];
 6463|    588|  for (size_t i = (size_t)0U; i < (size_t)3U; i++) {
  ------------------
  |  Branch (6463:31): [True: 441, False: 147]
  ------------------
 6464|    441|    repeat_expression[i] = libcrux_sha3_portable_incremental_shake128_init();
 6465|    441|  }
 6466|    147|  memcpy(shake128_state.shake128_state, repeat_expression,
 6467|    147|         (size_t)3U * sizeof(libcrux_sha3_generic_keccak_KeccakState_17));
 6468|    588|  for (size_t i = (size_t)0U; i < (size_t)3U; i++) {
  ------------------
  |  Branch (6468:31): [True: 441, False: 147]
  ------------------
 6469|    441|    size_t i0 = i;
 6470|    441|    libcrux_sha3_portable_incremental_shake128_absorb_final(
 6471|    441|        &shake128_state.shake128_state[i0],
 6472|    441|        Eurydice_array_to_slice((size_t)34U, input[i0], uint8_t));
  ------------------
  |  |  204|    441|  EURYDICE_SLICE(x, 0,                     \
  |  |  ------------------
  |  |  |  |  169|    441|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|    441|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  205|    441|                 end) /* x is already at an array type, no need for cast */
  ------------------
 6473|    441|  }
 6474|    147|  return shake128_state;
 6475|    147|}
libcrux_mlkem768_sha3.c:libcrux_sha3_portable_incremental_shake128_init:
 3466|    441|libcrux_sha3_portable_incremental_shake128_init(void) {
 3467|    441|  return libcrux_sha3_generic_keccak_new_80_04();
 3468|    441|}
libcrux_mlkem768_sha3.c:libcrux_sha3_portable_incremental_shake128_absorb_final:
 3563|    441|    libcrux_sha3_generic_keccak_KeccakState_17 *s, Eurydice_slice data0) {
 3564|    441|  libcrux_sha3_generic_keccak_KeccakState_17 *uu____0 = s;
 3565|    441|  Eurydice_slice uu____1[1U] = {data0};
 3566|    441|  libcrux_sha3_generic_keccak_absorb_final_80_9e2(
 3567|    441|      uu____0, uu____1, (size_t)0U, Eurydice_slice_len(data0, uint8_t));
  ------------------
  |  |  173|    441|#define Eurydice_slice_len(s, _) (s).len
  ------------------
 3568|    441|}
libcrux_mlkem768_sha3.c:libcrux_sha3_generic_keccak_absorb_final_80_9e2:
 3553|    441|    size_t start, size_t len) {
 3554|    441|  libcrux_sha3_simd_portable_load_last_a1_c6(self, last, start, len);
 3555|    441|  libcrux_sha3_generic_keccak_keccakf1600_80_04(self);
 3556|    441|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_load_last_a1_c6:
 3535|    441|    size_t start, size_t len) {
 3536|    441|  libcrux_sha3_simd_portable_load_last_c6(self->st, input[0U], start, len);
 3537|    441|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_load_last_c6:
 3508|    441|    uint64_t *state, Eurydice_slice blocks, size_t start, size_t len) {
 3509|    441|  uint8_t buffer[168U] = {0U};
 3510|    441|  Eurydice_slice_copy(
  ------------------
  |  |  229|    441|  memcpy(dst.ptr, src.ptr, dst.len * sizeof(t))
  ------------------
 3511|    441|      Eurydice_array_to_subslice3(buffer, (size_t)0U, len, uint8_t *),
 3512|    441|      Eurydice_slice_subslice3(blocks, start, start + len, uint8_t *), uint8_t);
 3513|    441|  buffer[len] = 31U;
 3514|    441|  size_t uu____0 = (size_t)168U - (size_t)1U;
 3515|    441|  buffer[uu____0] = (uint32_t)buffer[uu____0] | 128U;
 3516|    441|  libcrux_sha3_simd_portable_load_block_3a(
 3517|    441|      state, Eurydice_array_to_slice((size_t)168U, buffer, uint8_t),
  ------------------
  |  |  204|    441|  EURYDICE_SLICE(x, 0,                     \
  |  |  ------------------
  |  |  |  |  169|    441|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|    441|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  205|    441|                 end) /* x is already at an array type, no need for cast */
  ------------------
 3518|    441|      (size_t)0U);
 3519|    441|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_load_block_3a:
 3476|    441|    uint64_t *state, Eurydice_slice blocks, size_t start) {
 3477|    441|  uint64_t state_flat[25U] = {0U};
 3478|  9.70k|  for (size_t i = (size_t)0U; i < (size_t)168U / (size_t)8U; i++) {
  ------------------
  |  Branch (3478:31): [True: 9.26k, False: 441]
  ------------------
 3479|  9.26k|    size_t i0 = i;
 3480|  9.26k|    size_t offset = start + (size_t)8U * i0;
 3481|  9.26k|    uint8_t uu____0[8U];
 3482|  9.26k|    Result_15 dst;
 3483|  9.26k|    Eurydice_slice_to_array2(
  ------------------
  |  |  277|  9.26k|  Eurydice_slice_to_array3(&(dst)->tag, (char *)&(dst)->val.case_Ok, src, \
  |  |  278|  9.26k|                           sizeof(t_arr))
  ------------------
 3484|  9.26k|        &dst,
 3485|  9.26k|        Eurydice_slice_subslice3(blocks, offset, offset + (size_t)8U,
 3486|  9.26k|                                 uint8_t *),
 3487|  9.26k|        Eurydice_slice, uint8_t[8U], TryFromSliceError);
 3488|  9.26k|    unwrap_26_68(dst, uu____0);
 3489|  9.26k|    state_flat[i0] = core_num__u64__from_le_bytes(uu____0);
 3490|  9.26k|  }
 3491|  9.70k|  for (size_t i = (size_t)0U; i < (size_t)168U / (size_t)8U; i++) {
  ------------------
  |  Branch (3491:31): [True: 9.26k, False: 441]
  ------------------
 3492|  9.26k|    size_t i0 = i;
 3493|  9.26k|    libcrux_sha3_traits_set_ij_04(
 3494|  9.26k|        state, i0 / (size_t)5U, i0 % (size_t)5U,
 3495|  9.26k|        libcrux_sha3_traits_get_ij_04(state, i0 / (size_t)5U,
 3496|  9.26k|                                      i0 % (size_t)5U)[0U] ^
 3497|  9.26k|            state_flat[i0]);
 3498|  9.26k|  }
 3499|    441|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_hash_functions_portable_shake128_squeeze_first_three_blocks_4a_e0:
 6527|    147|    uint8_t ret[3U][504U]) {
 6528|    147|  libcrux_ml_kem_hash_functions_portable_shake128_squeeze_first_three_blocks_e0(
 6529|    147|      self, ret);
 6530|    147|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_hash_functions_portable_shake128_squeeze_first_three_blocks_e0:
 6503|    147|    uint8_t ret[3U][504U]) {
 6504|    147|  uint8_t out[3U][504U] = {{0U}};
 6505|    588|  for (size_t i = (size_t)0U; i < (size_t)3U; i++) {
  ------------------
  |  Branch (6505:31): [True: 441, False: 147]
  ------------------
 6506|    441|    size_t i0 = i;
 6507|    441|    libcrux_sha3_portable_incremental_shake128_squeeze_first_three_blocks(
 6508|    441|        &st->shake128_state[i0],
 6509|    441|        Eurydice_array_to_slice((size_t)504U, out[i0], uint8_t));
  ------------------
  |  |  204|    441|  EURYDICE_SLICE(x, 0,                     \
  |  |  ------------------
  |  |  |  |  169|    441|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|    441|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  205|    441|                 end) /* x is already at an array type, no need for cast */
  ------------------
 6510|    441|  }
 6511|    147|  memcpy(ret, out, (size_t)3U * sizeof(uint8_t[504U]));
 6512|    147|}
libcrux_mlkem768_sha3.c:libcrux_sha3_portable_incremental_shake128_squeeze_first_three_blocks:
 3652|    441|    libcrux_sha3_generic_keccak_KeccakState_17 *s, Eurydice_slice out0) {
 3653|    441|  libcrux_sha3_generic_keccak_portable_squeeze_first_three_blocks_b4_3a(s,
 3654|    441|                                                                        out0);
 3655|    441|}
libcrux_mlkem768_sha3.c:libcrux_sha3_generic_keccak_portable_squeeze_first_three_blocks_b4_3a:
 3637|    441|    libcrux_sha3_generic_keccak_KeccakState_17 *self, Eurydice_slice out) {
 3638|    441|  libcrux_sha3_simd_portable_squeeze_13_3a(self, out, (size_t)0U, (size_t)168U);
 3639|    441|  libcrux_sha3_generic_keccak_keccakf1600_80_04(self);
 3640|    441|  libcrux_sha3_simd_portable_squeeze_13_3a(self, out, (size_t)168U,
 3641|    441|                                           (size_t)168U);
 3642|    441|  libcrux_sha3_generic_keccak_keccakf1600_80_04(self);
 3643|    441|  libcrux_sha3_simd_portable_squeeze_13_3a(self, out, (size_t)2U * (size_t)168U,
 3644|    441|                                           (size_t)168U);
 3645|    441|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_squeeze_13_3a:
 3619|  1.33k|    size_t start, size_t len) {
 3620|  1.33k|  libcrux_sha3_simd_portable_store_block_3a(self->st, out, start, len);
 3621|  1.33k|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_store_block_3a:
 3576|  1.33k|    uint64_t *s, Eurydice_slice out, size_t start, size_t len) {
 3577|  1.33k|  size_t octets = len / (size_t)8U;
 3578|  29.4k|  for (size_t i = (size_t)0U; i < octets; i++) {
  ------------------
  |  Branch (3578:31): [True: 28.0k, False: 1.33k]
  ------------------
 3579|  28.0k|    size_t i0 = i;
 3580|  28.0k|    Eurydice_slice uu____0 = Eurydice_slice_subslice3(
  ------------------
  |  |  195|  28.0k|  EURYDICE_SLICE((t_ptr)s.ptr, (start), (end))
  |  |  ------------------
  |  |  |  |  169|  28.0k|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|  28.0k|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3581|  28.0k|        out, start + (size_t)8U * i0, start + (size_t)8U * i0 + (size_t)8U,
 3582|  28.0k|        uint8_t *);
 3583|  28.0k|    uint8_t ret[8U];
 3584|  28.0k|    core_num__u64__to_le_bytes(
 3585|  28.0k|        libcrux_sha3_traits_get_ij_04(s, i0 / (size_t)5U, i0 % (size_t)5U)[0U],
 3586|  28.0k|        ret);
 3587|  28.0k|    Eurydice_slice_copy(
  ------------------
  |  |  229|  28.0k|  memcpy(dst.ptr, src.ptr, dst.len * sizeof(t))
  ------------------
 3588|  28.0k|        uu____0, Eurydice_array_to_slice((size_t)8U, ret, uint8_t), uint8_t);
 3589|  28.0k|  }
 3590|  1.33k|  size_t remaining = len % (size_t)8U;
 3591|  1.33k|  if (remaining > (size_t)0U) {
  ------------------
  |  Branch (3591:7): [True: 0, False: 1.33k]
  ------------------
 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|  1.33k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_sampling_sample_from_uniform_distribution_next_89:
 6583|    147|    int16_t (*out)[272U]) {
 6584|    588|  for (size_t i0 = (size_t)0U; i0 < (size_t)3U; i0++) {
  ------------------
  |  Branch (6584:32): [True: 441, False: 147]
  ------------------
 6585|    441|    size_t i1 = i0;
 6586|  9.70k|    for (size_t i = (size_t)0U; i < (size_t)504U / (size_t)24U; i++) {
  ------------------
  |  Branch (6586:33): [True: 9.26k, False: 441]
  ------------------
 6587|  9.26k|      size_t r = i;
 6588|  9.26k|      if (sampled_coefficients[i1] <
  ------------------
  |  Branch (6588:11): [True: 8.88k, False: 376]
  ------------------
 6589|  9.26k|          LIBCRUX_ML_KEM_CONSTANTS_COEFFICIENTS_IN_RING_ELEMENT) {
  ------------------
  |  |  447|  9.26k|#define LIBCRUX_ML_KEM_CONSTANTS_COEFFICIENTS_IN_RING_ELEMENT ((size_t)256U)
  ------------------
 6590|  8.88k|        size_t sampled = libcrux_ml_kem_vector_portable_rej_sample_b8(
 6591|  8.88k|            Eurydice_array_to_subslice3(randomness[i1], r * (size_t)24U,
  ------------------
  |  |  215|  8.88k|  EURYDICE_SLICE((t_ptr)x, (start), (end))
  |  |  ------------------
  |  |  |  |  169|  8.88k|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|  8.88k|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 6592|  8.88k|                                        r * (size_t)24U + (size_t)24U,
 6593|  8.88k|                                        uint8_t *),
 6594|  8.88k|            Eurydice_array_to_subslice3(out[i1], sampled_coefficients[i1],
  ------------------
  |  |  215|  8.88k|  EURYDICE_SLICE((t_ptr)x, (start), (end))
  |  |  ------------------
  |  |  |  |  169|  8.88k|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|  8.88k|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 6595|  8.88k|                                        sampled_coefficients[i1] + (size_t)16U,
 6596|  8.88k|                                        int16_t *));
 6597|  8.88k|        size_t uu____0 = i1;
 6598|  8.88k|        sampled_coefficients[uu____0] = sampled_coefficients[uu____0] + sampled;
 6599|  8.88k|      }
 6600|  9.26k|    }
 6601|    441|  }
 6602|    147|  bool done = true;
 6603|    588|  for (size_t i = (size_t)0U; i < (size_t)3U; i++) {
  ------------------
  |  Branch (6603:31): [True: 441, False: 147]
  ------------------
 6604|    441|    size_t i0 = i;
 6605|    441|    if (sampled_coefficients[i0] >=
  ------------------
  |  Branch (6605:9): [True: 436, False: 5]
  ------------------
 6606|    441|        LIBCRUX_ML_KEM_CONSTANTS_COEFFICIENTS_IN_RING_ELEMENT) {
  ------------------
  |  |  447|    441|#define LIBCRUX_ML_KEM_CONSTANTS_COEFFICIENTS_IN_RING_ELEMENT ((size_t)256U)
  ------------------
 6607|    436|      sampled_coefficients[i0] =
 6608|    436|          LIBCRUX_ML_KEM_CONSTANTS_COEFFICIENTS_IN_RING_ELEMENT;
  ------------------
  |  |  447|    436|#define LIBCRUX_ML_KEM_CONSTANTS_COEFFICIENTS_IN_RING_ELEMENT ((size_t)256U)
  ------------------
 6609|    436|    } else {
 6610|       |      done = false;
 6611|      5|    }
 6612|    441|  }
 6613|    147|  return done;
 6614|    147|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_vector_portable_rej_sample_b8:
 5219|  8.89k|    Eurydice_slice a, Eurydice_slice out) {
 5220|  8.89k|  return libcrux_ml_kem_vector_portable_sampling_rej_sample(a, out);
 5221|  8.89k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_vector_portable_sampling_rej_sample:
 5185|  8.89k|                                                   Eurydice_slice result) {
 5186|  8.89k|  size_t sampled = (size_t)0U;
 5187|  80.0k|  for (size_t i = (size_t)0U; i < Eurydice_slice_len(a, uint8_t) / (size_t)3U;
  ------------------
  |  |  173|  80.0k|#define Eurydice_slice_len(s, _) (s).len
  ------------------
  |  Branch (5187:31): [True: 71.1k, False: 8.89k]
  ------------------
 5188|  71.1k|       i++) {
 5189|  71.1k|    size_t i0 = i;
 5190|  71.1k|    int16_t b1 = (int16_t)Eurydice_slice_index(a, i0 * (size_t)3U + (size_t)0U,
  ------------------
  |  |  180|  71.1k|#define Eurydice_slice_index(s, i, t, t_ptr_t) (((t_ptr_t)s.ptr)[i])
  ------------------
 5191|  71.1k|                                               uint8_t, uint8_t *);
 5192|  71.1k|    int16_t b2 = (int16_t)Eurydice_slice_index(a, i0 * (size_t)3U + (size_t)1U,
  ------------------
  |  |  180|  71.1k|#define Eurydice_slice_index(s, i, t, t_ptr_t) (((t_ptr_t)s.ptr)[i])
  ------------------
 5193|  71.1k|                                               uint8_t, uint8_t *);
 5194|  71.1k|    int16_t b3 = (int16_t)Eurydice_slice_index(a, i0 * (size_t)3U + (size_t)2U,
  ------------------
  |  |  180|  71.1k|#define Eurydice_slice_index(s, i, t, t_ptr_t) (((t_ptr_t)s.ptr)[i])
  ------------------
 5195|  71.1k|                                               uint8_t, uint8_t *);
 5196|  71.1k|    int16_t d1 = (b2 & (int16_t)15) << 8U | b1;
 5197|  71.1k|    int16_t d2 = b3 << 4U | b2 >> 4U;
 5198|  71.1k|    if (d1 < LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_MODULUS) {
  ------------------
  |  | 3777|  71.1k|#define LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_MODULUS ((int16_t)3329)
  ------------------
  |  Branch (5198:9): [True: 57.8k, False: 13.3k]
  ------------------
 5199|  57.8k|      if (sampled < (size_t)16U) {
  ------------------
  |  Branch (5199:11): [True: 57.8k, False: 0]
  ------------------
 5200|  57.8k|        Eurydice_slice_index(result, sampled, int16_t, int16_t *) = d1;
  ------------------
  |  |  180|  57.8k|#define Eurydice_slice_index(s, i, t, t_ptr_t) (((t_ptr_t)s.ptr)[i])
  ------------------
 5201|  57.8k|        sampled++;
 5202|  57.8k|      }
 5203|  57.8k|    }
 5204|  71.1k|    if (d2 < LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_MODULUS) {
  ------------------
  |  | 3777|  71.1k|#define LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_MODULUS ((int16_t)3329)
  ------------------
  |  Branch (5204:9): [True: 57.8k, False: 13.2k]
  ------------------
 5205|  57.8k|      if (sampled < (size_t)16U) {
  ------------------
  |  Branch (5205:11): [True: 57.8k, False: 0]
  ------------------
 5206|  57.8k|        Eurydice_slice_index(result, sampled, int16_t, int16_t *) = d2;
  ------------------
  |  |  180|  57.8k|#define Eurydice_slice_index(s, i, t, t_ptr_t) (((t_ptr_t)s.ptr)[i])
  ------------------
 5207|  57.8k|        sampled++;
 5208|  57.8k|      }
 5209|  57.8k|    }
 5210|  71.1k|  }
 5211|  8.89k|  return sampled;
 5212|  8.89k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_hash_functions_portable_shake128_squeeze_next_block_4a_e0:
 6649|      5|    uint8_t ret[3U][168U]) {
 6650|      5|  libcrux_ml_kem_hash_functions_portable_shake128_squeeze_next_block_e0(self,
 6651|      5|                                                                        ret);
 6652|      5|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_hash_functions_portable_shake128_squeeze_next_block_e0:
 6625|      5|    uint8_t ret[3U][168U]) {
 6626|      5|  uint8_t out[3U][168U] = {{0U}};
 6627|     20|  for (size_t i = (size_t)0U; i < (size_t)3U; i++) {
  ------------------
  |  Branch (6627:31): [True: 15, False: 5]
  ------------------
 6628|     15|    size_t i0 = i;
 6629|     15|    libcrux_sha3_portable_incremental_shake128_squeeze_next_block(
 6630|     15|        &st->shake128_state[i0],
 6631|     15|        Eurydice_array_to_slice((size_t)168U, out[i0], uint8_t));
  ------------------
  |  |  204|     15|  EURYDICE_SLICE(x, 0,                     \
  |  |  ------------------
  |  |  |  |  169|     15|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|     15|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  205|     15|                 end) /* x is already at an array type, no need for cast */
  ------------------
 6632|     15|  }
 6633|      5|  memcpy(ret, out, (size_t)3U * sizeof(uint8_t[168U]));
 6634|      5|}
libcrux_mlkem768_sha3.c:libcrux_sha3_portable_incremental_shake128_squeeze_next_block:
 3681|     15|    libcrux_sha3_generic_keccak_KeccakState_17 *s, Eurydice_slice out0) {
 3682|     15|  libcrux_sha3_generic_keccak_portable_squeeze_next_block_b4_3a(s, out0,
 3683|     15|                                                                (size_t)0U);
 3684|     15|}
libcrux_mlkem768_sha3.c:libcrux_sha3_generic_keccak_portable_squeeze_next_block_b4_3a:
 3671|     15|    size_t start) {
 3672|     15|  libcrux_sha3_generic_keccak_keccakf1600_80_04(self);
 3673|     15|  libcrux_sha3_simd_portable_squeeze_13_3a(self, out, start, (size_t)168U);
 3674|     15|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_sampling_sample_from_uniform_distribution_next_890:
 6705|      5|    int16_t (*out)[272U]) {
 6706|     20|  for (size_t i0 = (size_t)0U; i0 < (size_t)3U; i0++) {
  ------------------
  |  Branch (6706:32): [True: 15, False: 5]
  ------------------
 6707|     15|    size_t i1 = i0;
 6708|    120|    for (size_t i = (size_t)0U; i < (size_t)168U / (size_t)24U; i++) {
  ------------------
  |  Branch (6708:33): [True: 105, False: 15]
  ------------------
 6709|    105|      size_t r = i;
 6710|    105|      if (sampled_coefficients[i1] <
  ------------------
  |  Branch (6710:11): [True: 5, False: 100]
  ------------------
 6711|    105|          LIBCRUX_ML_KEM_CONSTANTS_COEFFICIENTS_IN_RING_ELEMENT) {
  ------------------
  |  |  447|    105|#define LIBCRUX_ML_KEM_CONSTANTS_COEFFICIENTS_IN_RING_ELEMENT ((size_t)256U)
  ------------------
 6712|      5|        size_t sampled = libcrux_ml_kem_vector_portable_rej_sample_b8(
 6713|      5|            Eurydice_array_to_subslice3(randomness[i1], r * (size_t)24U,
  ------------------
  |  |  215|      5|  EURYDICE_SLICE((t_ptr)x, (start), (end))
  |  |  ------------------
  |  |  |  |  169|      5|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      5|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 6714|      5|                                        r * (size_t)24U + (size_t)24U,
 6715|      5|                                        uint8_t *),
 6716|      5|            Eurydice_array_to_subslice3(out[i1], sampled_coefficients[i1],
  ------------------
  |  |  215|      5|  EURYDICE_SLICE((t_ptr)x, (start), (end))
  |  |  ------------------
  |  |  |  |  169|      5|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|      5|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 6717|      5|                                        sampled_coefficients[i1] + (size_t)16U,
 6718|      5|                                        int16_t *));
 6719|      5|        size_t uu____0 = i1;
 6720|      5|        sampled_coefficients[uu____0] = sampled_coefficients[uu____0] + sampled;
 6721|      5|      }
 6722|    105|    }
 6723|     15|  }
 6724|      5|  bool done = true;
 6725|     20|  for (size_t i = (size_t)0U; i < (size_t)3U; i++) {
  ------------------
  |  Branch (6725:31): [True: 15, False: 5]
  ------------------
 6726|     15|    size_t i0 = i;
 6727|     15|    if (sampled_coefficients[i0] >=
  ------------------
  |  Branch (6727:9): [True: 15, False: 0]
  ------------------
 6728|     15|        LIBCRUX_ML_KEM_CONSTANTS_COEFFICIENTS_IN_RING_ELEMENT) {
  ------------------
  |  |  447|     15|#define LIBCRUX_ML_KEM_CONSTANTS_COEFFICIENTS_IN_RING_ELEMENT ((size_t)256U)
  ------------------
 6729|     15|      sampled_coefficients[i0] =
 6730|     15|          LIBCRUX_ML_KEM_CONSTANTS_COEFFICIENTS_IN_RING_ELEMENT;
  ------------------
  |  |  447|     15|#define LIBCRUX_ML_KEM_CONSTANTS_COEFFICIENTS_IN_RING_ELEMENT ((size_t)256U)
  ------------------
 6731|     15|    } else {
 6732|       |      done = false;
 6733|      0|    }
 6734|     15|  }
 6735|      5|  return done;
 6736|      5|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_sampling_sample_from_xof_call_mut_e7_2b:
 6792|    441|    void **_, int16_t tupled_args[272U]) {
 6793|    441|  int16_t s[272U];
 6794|    441|  memcpy(s, tupled_args, (size_t)272U * sizeof(int16_t));
 6795|    441|  return libcrux_ml_kem_polynomial_from_i16_array_d6_ea(
 6796|    441|      Eurydice_array_to_subslice3(s, (size_t)0U, (size_t)256U, int16_t *));
  ------------------
  |  |  215|    441|  EURYDICE_SLICE((t_ptr)x, (start), (end))
  |  |  ------------------
  |  |  |  |  169|    441|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|    441|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 6797|    441|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_polynomial_from_i16_array_d6_ea:
 6773|    735|libcrux_ml_kem_polynomial_from_i16_array_d6_ea(Eurydice_slice a) {
 6774|    735|  return libcrux_ml_kem_polynomial_from_i16_array_ea(a);
 6775|    735|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_polynomial_from_i16_array_ea:
 6745|    735|libcrux_ml_kem_polynomial_from_i16_array_ea(Eurydice_slice a) {
 6746|    735|  libcrux_ml_kem_polynomial_PolynomialRingElement_1d result =
 6747|    735|      libcrux_ml_kem_polynomial_ZERO_ea();
 6748|    735|  for (size_t i = (size_t)0U;
 6749|  12.4k|       i < LIBCRUX_ML_KEM_POLYNOMIAL_VECTORS_IN_RING_ELEMENT; i++) {
  ------------------
  |  | 3770|  12.4k|#define LIBCRUX_ML_KEM_POLYNOMIAL_VECTORS_IN_RING_ELEMENT ((size_t)16U)
  ------------------
  |  Branch (6749:8): [True: 11.7k, False: 735]
  ------------------
 6750|  11.7k|    size_t i0 = i;
 6751|  11.7k|    libcrux_ml_kem_vector_portable_vector_type_PortableVector uu____0 =
 6752|  11.7k|        libcrux_ml_kem_vector_portable_from_i16_array_b8(
 6753|  11.7k|            Eurydice_slice_subslice3(a, i0 * (size_t)16U,
  ------------------
  |  |  195|  11.7k|  EURYDICE_SLICE((t_ptr)s.ptr, (start), (end))
  |  |  ------------------
  |  |  |  |  169|  11.7k|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|  11.7k|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 6754|  11.7k|                                     (i0 + (size_t)1U) * (size_t)16U,
 6755|  11.7k|                                     int16_t *));
 6756|  11.7k|    result.coefficients[i0] = uu____0;
 6757|  11.7k|  }
 6758|    735|  return result;
 6759|    735|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_vector_portable_from_i16_array_b8:
 3805|  11.7k|libcrux_ml_kem_vector_portable_from_i16_array_b8(Eurydice_slice array) {
 3806|  11.7k|  return libcrux_ml_kem_vector_portable_vector_type_from_i16_array(
 3807|  11.7k|      libcrux_secrets_int_classify_public_classify_ref_9b_39(array));
 3808|  11.7k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_vector_portable_vector_type_from_i16_array:
 3788|  11.7k|    Eurydice_slice array) {
 3789|  11.7k|  libcrux_ml_kem_vector_portable_vector_type_PortableVector lit;
 3790|  11.7k|  int16_t ret[16U];
 3791|  11.7k|  Result_0a dst;
 3792|  11.7k|  Eurydice_slice_to_array2(
  ------------------
  |  |  277|  11.7k|  Eurydice_slice_to_array3(&(dst)->tag, (char *)&(dst)->val.case_Ok, src, \
  |  |  278|  11.7k|                           sizeof(t_arr))
  ------------------
 3793|  11.7k|      &dst, Eurydice_slice_subslice3(array, (size_t)0U, (size_t)16U, int16_t *),
 3794|  11.7k|      Eurydice_slice, int16_t[16U], TryFromSliceError);
 3795|  11.7k|  unwrap_26_00(dst, ret);
 3796|  11.7k|  memcpy(lit.elements, ret, (size_t)16U * sizeof(int16_t));
 3797|  11.7k|  return lit;
 3798|  11.7k|}
libcrux_mlkem768_sha3.c:unwrap_26_00:
 1129|  11.7k|static inline void unwrap_26_00(Result_0a self, int16_t ret[16U]) {
 1130|  11.7k|  if (self.tag == Ok) {
  ------------------
  |  |  721|  11.7k|#define Ok 0
  ------------------
  |  Branch (1130:7): [True: 11.7k, False: 0]
  ------------------
 1131|  11.7k|    int16_t f0[16U];
 1132|  11.7k|    memcpy(f0, self.val.case_Ok, (size_t)16U * sizeof(int16_t));
 1133|  11.7k|    memcpy(ret, f0, (size_t)16U * sizeof(int16_t));
 1134|  11.7k|  } 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|  11.7k|}
libcrux_mlkem768_sha3.c:libcrux_secrets_int_classify_public_classify_ref_9b_39:
 1103|  11.7k|libcrux_secrets_int_classify_public_classify_ref_9b_39(Eurydice_slice self) {
 1104|  11.7k|  return self;
 1105|  11.7k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_utils_into_padded_array_c8:
  884|     49|    Eurydice_slice slice, uint8_t ret[33U]) {
  885|     49|  uint8_t out[33U] = {0U};
  886|     49|  uint8_t *uu____0 = out;
  887|     49|  Eurydice_slice_copy(
  ------------------
  |  |  229|     49|  memcpy(dst.ptr, src.ptr, dst.len * sizeof(t))
  ------------------
  888|     49|      Eurydice_array_to_subslice3(
  889|     49|          uu____0, (size_t)0U, Eurydice_slice_len(slice, uint8_t), uint8_t *),
  890|     49|      slice, uint8_t);
  891|     49|  memcpy(ret, out, (size_t)33U * sizeof(uint8_t));
  892|     49|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_ind_cpa_sample_vector_cbd_then_ntt_3b:
 7177|     98|    uint8_t *prf_input, uint8_t domain_separator) {
 7178|     98|  uint8_t prf_inputs[3U][33U];
 7179|    392|  for (size_t i = (size_t)0U; i < (size_t)3U; i++) {
  ------------------
  |  Branch (7179:31): [True: 294, False: 98]
  ------------------
 7180|    294|    core_array__core__clone__Clone_for__Array_T__N___clone(
  ------------------
  |  |  236|    294|  (memcpy(dst, src, len * sizeof(elem_type)))
  ------------------
 7181|    294|        (size_t)33U, prf_input, prf_inputs[i], uint8_t, void *);
 7182|    294|  }
 7183|     98|  domain_separator =
 7184|     98|      libcrux_ml_kem_utils_prf_input_inc_e0(prf_inputs, domain_separator);
 7185|     98|  uint8_t prf_outputs[3U][128U];
 7186|     98|  libcrux_ml_kem_hash_functions_portable_PRFxN_4a_41(prf_inputs, prf_outputs);
 7187|    392|  for (size_t i = (size_t)0U; i < (size_t)3U; i++) {
  ------------------
  |  Branch (7187:31): [True: 294, False: 98]
  ------------------
 7188|    294|    size_t i0 = i;
 7189|    294|    re_as_ntt[i0] =
 7190|    294|        libcrux_ml_kem_sampling_sample_from_binomial_distribution_a0(
 7191|    294|            Eurydice_array_to_slice((size_t)128U, prf_outputs[i0], uint8_t));
  ------------------
  |  |  204|    294|  EURYDICE_SLICE(x, 0,                     \
  |  |  ------------------
  |  |  |  |  169|    294|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|    294|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  205|    294|                 end) /* x is already at an array type, no need for cast */
  ------------------
 7192|    294|    libcrux_ml_kem_ntt_ntt_binomially_sampled_ring_element_ea(&re_as_ntt[i0]);
 7193|    294|  }
 7194|     98|  return domain_separator;
 7195|     98|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_utils_prf_input_inc_e0:
  866|     98|    uint8_t (*prf_inputs)[33U], uint8_t domain_separator) {
  867|    392|  for (size_t i = (size_t)0U; i < (size_t)3U; i++) {
  ------------------
  |  Branch (867:31): [True: 294, False: 98]
  ------------------
  868|    294|    size_t i0 = i;
  869|    294|    prf_inputs[i0][32U] = domain_separator;
  870|    294|    domain_separator = (uint32_t)domain_separator + 1U;
  871|    294|  }
  872|     98|  return domain_separator;
  873|     98|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_hash_functions_portable_PRFxN_4a_41:
 7001|     98|    uint8_t (*input)[33U], uint8_t ret[3U][128U]) {
 7002|     98|  libcrux_ml_kem_hash_functions_portable_PRFxN_41(input, ret);
 7003|     98|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_hash_functions_portable_PRFxN_41:
 6979|     98|    uint8_t (*input)[33U], uint8_t ret[3U][128U]) {
 6980|     98|  uint8_t out[3U][128U] = {{0U}};
 6981|    392|  for (size_t i = (size_t)0U; i < (size_t)3U; i++) {
  ------------------
  |  Branch (6981:31): [True: 294, False: 98]
  ------------------
 6982|    294|    size_t i0 = i;
 6983|    294|    libcrux_sha3_portable_shake256(
 6984|    294|        Eurydice_array_to_slice((size_t)128U, out[i0], uint8_t),
  ------------------
  |  |  204|    294|  EURYDICE_SLICE(x, 0,                     \
  |  |  ------------------
  |  |  |  |  169|    294|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|    294|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  205|    294|                 end) /* x is already at an array type, no need for cast */
  ------------------
 6985|    294|        Eurydice_array_to_slice((size_t)33U, input[i0], uint8_t));
  ------------------
  |  |  204|    294|  EURYDICE_SLICE(x, 0,                     \
  |  |  ------------------
  |  |  |  |  169|    294|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|    294|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  205|    294|                 end) /* x is already at an array type, no need for cast */
  ------------------
 6986|    294|  }
 6987|     98|  memcpy(ret, out, (size_t)3U * sizeof(uint8_t[128U]));
 6988|     98|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_ntt_ntt_binomially_sampled_ring_element_ea:
 7143|    294|    libcrux_ml_kem_polynomial_PolynomialRingElement_1d *re) {
 7144|    294|  libcrux_ml_kem_ntt_ntt_at_layer_7_ea(re);
 7145|    294|  size_t zeta_i = (size_t)1U;
 7146|    294|  libcrux_ml_kem_ntt_ntt_at_layer_4_plus_ea(&zeta_i, re, (size_t)6U,
 7147|    294|                                            (size_t)11207U);
 7148|    294|  libcrux_ml_kem_ntt_ntt_at_layer_4_plus_ea(&zeta_i, re, (size_t)5U,
 7149|    294|                                            (size_t)11207U + (size_t)3328U);
 7150|    294|  libcrux_ml_kem_ntt_ntt_at_layer_4_plus_ea(
 7151|    294|      &zeta_i, re, (size_t)4U, (size_t)11207U + (size_t)2U * (size_t)3328U);
 7152|    294|  libcrux_ml_kem_ntt_ntt_at_layer_3_ea(
 7153|    294|      &zeta_i, re, (size_t)11207U + (size_t)3U * (size_t)3328U);
 7154|    294|  libcrux_ml_kem_ntt_ntt_at_layer_2_ea(
 7155|    294|      &zeta_i, re, (size_t)11207U + (size_t)4U * (size_t)3328U);
 7156|    294|  libcrux_ml_kem_ntt_ntt_at_layer_1_ea(
 7157|    294|      &zeta_i, re, (size_t)11207U + (size_t)5U * (size_t)3328U);
 7158|    294|  libcrux_ml_kem_polynomial_poly_barrett_reduce_d6_ea(re);
 7159|    294|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_ntt_ntt_at_layer_7_ea:
 7120|    294|    libcrux_ml_kem_polynomial_PolynomialRingElement_1d *re) {
 7121|    294|  size_t step = LIBCRUX_ML_KEM_POLYNOMIAL_VECTORS_IN_RING_ELEMENT / (size_t)2U;
  ------------------
  |  | 3770|    294|#define LIBCRUX_ML_KEM_POLYNOMIAL_VECTORS_IN_RING_ELEMENT ((size_t)16U)
  ------------------
 7122|  2.64k|  for (size_t i = (size_t)0U; i < step; i++) {
  ------------------
  |  Branch (7122:31): [True: 2.35k, False: 294]
  ------------------
 7123|  2.35k|    size_t j = i;
 7124|  2.35k|    libcrux_ml_kem_vector_portable_vector_type_PortableVector t =
 7125|  2.35k|        libcrux_ml_kem_vector_portable_multiply_by_constant_b8(
 7126|  2.35k|            re->coefficients[j + step], (int16_t)-1600);
 7127|  2.35k|    re->coefficients[j + step] =
 7128|  2.35k|        libcrux_ml_kem_vector_portable_sub_b8(re->coefficients[j], &t);
 7129|  2.35k|    libcrux_ml_kem_vector_portable_vector_type_PortableVector uu____1 =
 7130|  2.35k|        libcrux_ml_kem_vector_portable_add_b8(re->coefficients[j], &t);
 7131|  2.35k|    re->coefficients[j] = uu____1;
 7132|  2.35k|  }
 7133|    294|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_vector_portable_multiply_by_constant_b8:
 3906|  2.35k|    libcrux_ml_kem_vector_portable_vector_type_PortableVector vec, int16_t c) {
 3907|  2.35k|  return libcrux_ml_kem_vector_portable_arithmetic_multiply_by_constant(vec, c);
 3908|  2.35k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_vector_portable_arithmetic_multiply_by_constant:
 3890|  2.35k|    libcrux_ml_kem_vector_portable_vector_type_PortableVector vec, int16_t c) {
 3891|  2.35k|  for (size_t i = (size_t)0U;
 3892|  39.9k|       i < LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_ELEMENTS_IN_VECTOR; i++) {
  ------------------
  |  | 3772|  39.9k|#define LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_ELEMENTS_IN_VECTOR ((size_t)16U)
  ------------------
  |  Branch (3892:8): [True: 37.6k, False: 2.35k]
  ------------------
 3893|  37.6k|    size_t i0 = i;
 3894|  37.6k|    size_t uu____0 = i0;
 3895|  37.6k|    vec.elements[uu____0] = vec.elements[uu____0] * c;
 3896|  37.6k|  }
 3897|  2.35k|  return vec;
 3898|  2.35k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_sampling_sample_from_binomial_distribution_a0:
 7108|    294|    Eurydice_slice randomness) {
 7109|    294|  return libcrux_ml_kem_sampling_sample_from_binomial_distribution_2_ea(
 7110|    294|      randomness);
 7111|    294|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_sampling_sample_from_binomial_distribution_2_ea:
 7062|    294|    Eurydice_slice randomness) {
 7063|    294|  int16_t sampled_i16s[256U] = {0U};
 7064|    294|  for (size_t i0 = (size_t)0U;
 7065|  9.70k|       i0 < Eurydice_slice_len(randomness, uint8_t) / (size_t)4U; i0++) {
  ------------------
  |  |  173|  9.70k|#define Eurydice_slice_len(s, _) (s).len
  ------------------
  |  Branch (7065:8): [True: 9.40k, False: 294]
  ------------------
 7066|  9.40k|    size_t chunk_number = i0;
 7067|  9.40k|    Eurydice_slice byte_chunk = Eurydice_slice_subslice3(
  ------------------
  |  |  195|  9.40k|  EURYDICE_SLICE((t_ptr)s.ptr, (start), (end))
  |  |  ------------------
  |  |  |  |  169|  9.40k|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|  9.40k|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 7068|  9.40k|        randomness, chunk_number * (size_t)4U,
 7069|  9.40k|        chunk_number * (size_t)4U + (size_t)4U, uint8_t *);
 7070|  9.40k|    uint32_t random_bits_as_u32 =
 7071|  9.40k|        (((uint32_t)Eurydice_slice_index(byte_chunk, (size_t)0U, uint8_t,
  ------------------
  |  |  180|  9.40k|#define Eurydice_slice_index(s, i, t, t_ptr_t) (((t_ptr_t)s.ptr)[i])
  ------------------
 7072|  9.40k|                                         uint8_t *) |
 7073|  9.40k|          (uint32_t)Eurydice_slice_index(byte_chunk, (size_t)1U, uint8_t,
  ------------------
  |  |  180|  9.40k|#define Eurydice_slice_index(s, i, t, t_ptr_t) (((t_ptr_t)s.ptr)[i])
  ------------------
 7074|  9.40k|                                         uint8_t *)
 7075|  9.40k|              << 8U) |
 7076|  9.40k|         (uint32_t)Eurydice_slice_index(byte_chunk, (size_t)2U, uint8_t,
  ------------------
  |  |  180|  9.40k|#define Eurydice_slice_index(s, i, t, t_ptr_t) (((t_ptr_t)s.ptr)[i])
  ------------------
 7077|  9.40k|                                        uint8_t *)
 7078|  9.40k|             << 16U) |
 7079|  9.40k|        (uint32_t)Eurydice_slice_index(byte_chunk, (size_t)3U, uint8_t,
  ------------------
  |  |  180|  9.40k|#define Eurydice_slice_index(s, i, t, t_ptr_t) (((t_ptr_t)s.ptr)[i])
  ------------------
 7080|  9.40k|                                       uint8_t *)
 7081|  9.40k|            << 24U;
 7082|  9.40k|    uint32_t even_bits = random_bits_as_u32 & 1431655765U;
 7083|  9.40k|    uint32_t odd_bits = random_bits_as_u32 >> 1U & 1431655765U;
 7084|  9.40k|    uint32_t coin_toss_outcomes = even_bits + odd_bits;
 7085|  84.6k|    for (uint32_t i = 0U; i < 32U / 4U; i++) {
  ------------------
  |  Branch (7085:27): [True: 75.2k, False: 9.40k]
  ------------------
 7086|  75.2k|      uint32_t outcome_set = i;
 7087|  75.2k|      uint32_t outcome_set0 = outcome_set * 4U;
 7088|  75.2k|      int16_t outcome_1 =
 7089|  75.2k|          (int16_t)(coin_toss_outcomes >> (uint32_t)outcome_set0 & 3U);
 7090|  75.2k|      int16_t outcome_2 =
 7091|  75.2k|          (int16_t)(coin_toss_outcomes >> (uint32_t)(outcome_set0 + 2U) & 3U);
 7092|  75.2k|      size_t offset = (size_t)(outcome_set0 >> 2U);
 7093|  75.2k|      sampled_i16s[(size_t)8U * chunk_number + offset] = outcome_1 - outcome_2;
 7094|  75.2k|    }
 7095|  9.40k|  }
 7096|    294|  return libcrux_ml_kem_polynomial_from_i16_array_d6_ea(
 7097|    294|      Eurydice_array_to_slice((size_t)256U, sampled_i16s, int16_t));
  ------------------
  |  |  204|    294|  EURYDICE_SLICE(x, 0,                     \
  |  |  ------------------
  |  |  |  |  169|    294|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|    294|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  205|    294|                 end) /* x is already at an array type, no need for cast */
  ------------------
 7098|    294|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_hash_functions_portable_H_4a_e0:
 8072|     49|    Eurydice_slice input, uint8_t ret[32U]) {
 8073|     49|  libcrux_ml_kem_hash_functions_portable_H(input, ret);
 8074|     49|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_hash_functions_portable_H:
 3725|     49|    Eurydice_slice input, uint8_t ret[32U]) {
 3726|     49|  uint8_t digest[32U] = {0U};
 3727|     49|  libcrux_sha3_portable_sha256(
 3728|     49|      Eurydice_array_to_slice((size_t)32U, digest, uint8_t), input);
  ------------------
  |  |  204|     49|  EURYDICE_SLICE(x, 0,                     \
  |  |  ------------------
  |  |  |  |  169|     49|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|     49|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  205|     49|                 end) /* x is already at an array type, no need for cast */
  ------------------
 3729|     49|  memcpy(ret, digest, (size_t)32U * sizeof(uint8_t));
 3730|     49|}
libcrux_mlkem768_sha3.c:libcrux_sha3_portable_sha256:
 3351|     49|                                                         Eurydice_slice data) {
 3352|     49|  libcrux_sha3_generic_keccak_portable_keccak1_ad(data, digest);
 3353|     49|}
libcrux_mlkem768_sha3.c:libcrux_sha3_generic_keccak_portable_keccak1_ad:
 3315|     49|    Eurydice_slice data, Eurydice_slice out) {
 3316|     49|  libcrux_sha3_generic_keccak_KeccakState_17 s =
 3317|     49|      libcrux_sha3_generic_keccak_new_80_04();
 3318|     49|  size_t data_len = Eurydice_slice_len(data, uint8_t);
  ------------------
  |  |  173|     49|#define Eurydice_slice_len(s, _) (s).len
  ------------------
 3319|    441|  for (size_t i = (size_t)0U; i < data_len / (size_t)136U; i++) {
  ------------------
  |  Branch (3319:31): [True: 392, False: 49]
  ------------------
 3320|    392|    size_t i0 = i;
 3321|    392|    Eurydice_slice buf[1U] = {data};
 3322|    392|    libcrux_sha3_generic_keccak_absorb_block_80_c60(&s, buf, i0 * (size_t)136U);
 3323|    392|  }
 3324|     49|  size_t rem = data_len % (size_t)136U;
 3325|     49|  Eurydice_slice buf[1U] = {data};
 3326|     49|  libcrux_sha3_generic_keccak_absorb_final_80_9e0(&s, buf, data_len - rem, rem);
 3327|     49|  size_t outlen = Eurydice_slice_len(out, uint8_t);
  ------------------
  |  |  173|     49|#define Eurydice_slice_len(s, _) (s).len
  ------------------
 3328|     49|  size_t blocks = outlen / (size_t)136U;
 3329|     49|  size_t last = outlen - outlen % (size_t)136U;
 3330|     49|  if (blocks == (size_t)0U) {
  ------------------
  |  Branch (3330:7): [True: 49, False: 0]
  ------------------
 3331|     49|    libcrux_sha3_simd_portable_squeeze_13_5b(&s, out, (size_t)0U, outlen);
 3332|     49|  } 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|     49|}
libcrux_mlkem768_sha3.c:libcrux_sha3_generic_keccak_absorb_final_80_9e0:
 3250|     49|    size_t start, size_t len) {
 3251|     49|  libcrux_sha3_simd_portable_load_last_a1_ad(self, last, start, len);
 3252|     49|  libcrux_sha3_generic_keccak_keccakf1600_80_04(self);
 3253|     49|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_load_last_a1_ad:
 3232|     49|    size_t start, size_t len) {
 3233|     49|  libcrux_sha3_simd_portable_load_last_ad(self->st, input[0U], start, len);
 3234|     49|}
libcrux_mlkem768_sha3.c:libcrux_sha3_simd_portable_load_last_ad:
 3205|     49|    uint64_t *state, Eurydice_slice blocks, size_t start, size_t len) {
 3206|     49|  uint8_t buffer[136U] = {0U};
 3207|     49|  Eurydice_slice_copy(
  ------------------
  |  |  229|     49|  memcpy(dst.ptr, src.ptr, dst.len * sizeof(t))
  ------------------
 3208|     49|      Eurydice_array_to_subslice3(buffer, (size_t)0U, len, uint8_t *),
 3209|     49|      Eurydice_slice_subslice3(blocks, start, start + len, uint8_t *), uint8_t);
 3210|     49|  buffer[len] = 6U;
 3211|     49|  size_t uu____0 = (size_t)136U - (size_t)1U;
 3212|     49|  buffer[uu____0] = (uint32_t)buffer[uu____0] | 128U;
 3213|     49|  libcrux_sha3_simd_portable_load_block_5b(
 3214|     49|      state, Eurydice_array_to_slice((size_t)136U, buffer, uint8_t),
  ------------------
  |  |  204|     49|  EURYDICE_SLICE(x, 0,                     \
  |  |  ------------------
  |  |  |  |  169|     49|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|     49|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  205|     49|                 end) /* x is already at an array type, no need for cast */
  ------------------
 3215|     49|      (size_t)0U);
 3216|     49|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_ind_cca_instantiations_portable_generate_keypair_ce:
 8754|     49|    uint8_t *randomness) {
 8755|     49|  return libcrux_ml_kem_ind_cca_generate_keypair_15(randomness);
 8756|     49|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_ind_cca_generate_keypair_15:
 8705|     49|libcrux_ml_kem_ind_cca_generate_keypair_15(uint8_t *randomness) {
 8706|     49|  Eurydice_slice ind_cpa_keypair_randomness = Eurydice_array_to_subslice3(
  ------------------
  |  |  215|     49|  EURYDICE_SLICE((t_ptr)x, (start), (end))
  |  |  ------------------
  |  |  |  |  169|     49|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|     49|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 8707|     49|      randomness, (size_t)0U,
 8708|     49|      LIBCRUX_ML_KEM_CONSTANTS_CPA_PKE_KEY_GENERATION_SEED_SIZE, uint8_t *);
 8709|     49|  Eurydice_slice implicit_rejection_value = Eurydice_array_to_subslice_from(
  ------------------
  |  |  225|     49|  EURYDICE_SLICE((t *)x, r, size)
  |  |  ------------------
  |  |  |  |  169|     49|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|     49|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 8710|     49|      (size_t)64U, randomness,
 8711|     49|      LIBCRUX_ML_KEM_CONSTANTS_CPA_PKE_KEY_GENERATION_SEED_SIZE, uint8_t,
 8712|     49|      size_t, uint8_t[]);
 8713|     49|  libcrux_ml_kem_utils_extraction_helper_Keypair768 uu____0 =
 8714|     49|      libcrux_ml_kem_ind_cpa_generate_keypair_ea(ind_cpa_keypair_randomness);
 8715|     49|  uint8_t ind_cpa_private_key[1152U];
 8716|     49|  memcpy(ind_cpa_private_key, uu____0.fst, (size_t)1152U * sizeof(uint8_t));
 8717|     49|  uint8_t public_key[1184U];
 8718|     49|  memcpy(public_key, uu____0.snd, (size_t)1184U * sizeof(uint8_t));
 8719|     49|  uint8_t secret_key_serialized[2400U];
 8720|     49|  libcrux_ml_kem_ind_cca_serialize_kem_secret_key_d6(
 8721|     49|      Eurydice_array_to_slice((size_t)1152U, ind_cpa_private_key, uint8_t),
  ------------------
  |  |  204|     49|  EURYDICE_SLICE(x, 0,                     \
  |  |  ------------------
  |  |  |  |  169|     49|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|     49|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  205|     49|                 end) /* x is already at an array type, no need for cast */
  ------------------
 8722|     49|      Eurydice_array_to_slice((size_t)1184U, public_key, uint8_t),
  ------------------
  |  |  204|     49|  EURYDICE_SLICE(x, 0,                     \
  |  |  ------------------
  |  |  |  |  169|     49|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|     49|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  205|     49|                 end) /* x is already at an array type, no need for cast */
  ------------------
 8723|     49|      implicit_rejection_value, secret_key_serialized);
 8724|       |  /* Passing arrays by value in Rust generates a copy in C */
 8725|     49|  uint8_t copy_of_secret_key_serialized[2400U];
 8726|     49|  memcpy(copy_of_secret_key_serialized, secret_key_serialized,
 8727|     49|         (size_t)2400U * sizeof(uint8_t));
 8728|     49|  libcrux_ml_kem_types_MlKemPrivateKey_d9 private_key =
 8729|     49|      libcrux_ml_kem_types_from_77_28(copy_of_secret_key_serialized);
 8730|     49|  libcrux_ml_kem_types_MlKemPrivateKey_d9 uu____2 = private_key;
 8731|       |  /* Passing arrays by value in Rust generates a copy in C */
 8732|     49|  uint8_t copy_of_public_key[1184U];
 8733|     49|  memcpy(copy_of_public_key, public_key, (size_t)1184U * sizeof(uint8_t));
 8734|     49|  return libcrux_ml_kem_types_from_17_74(
 8735|     49|      uu____2, libcrux_ml_kem_types_from_fd_d0(copy_of_public_key));
 8736|     49|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_ind_cpa_generate_keypair_ea:
 8605|     49|libcrux_ml_kem_ind_cpa_generate_keypair_ea(Eurydice_slice key_generation_seed) {
 8606|     49|  libcrux_ml_kem_ind_cpa_unpacked_IndCpaPrivateKeyUnpacked_a0 private_key =
 8607|     49|      libcrux_ml_kem_ind_cpa_unpacked_default_70_1b();
 8608|     49|  libcrux_ml_kem_ind_cpa_unpacked_IndCpaPublicKeyUnpacked_a0 public_key =
 8609|     49|      libcrux_ml_kem_ind_cpa_unpacked_default_8b_1b();
 8610|     49|  libcrux_ml_kem_ind_cpa_generate_keypair_unpacked_1c(
 8611|     49|      key_generation_seed, &private_key, &public_key);
 8612|     49|  return libcrux_ml_kem_ind_cpa_serialize_unpacked_secret_key_6c(&public_key,
 8613|     49|                                                                 &private_key);
 8614|     49|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_ind_cpa_unpacked_default_70_1b:
 8189|     49|libcrux_ml_kem_ind_cpa_unpacked_default_70_1b(void) {
 8190|     49|  libcrux_ml_kem_ind_cpa_unpacked_IndCpaPrivateKeyUnpacked_a0 lit;
 8191|     49|  libcrux_ml_kem_polynomial_PolynomialRingElement_1d repeat_expression[3U];
 8192|    196|  for (size_t i = (size_t)0U; i < (size_t)3U; i++) {
  ------------------
  |  Branch (8192:31): [True: 147, False: 49]
  ------------------
 8193|    147|    repeat_expression[i] = libcrux_ml_kem_polynomial_ZERO_d6_ea();
 8194|    147|  }
 8195|     49|  memcpy(
 8196|     49|      lit.secret_as_ntt, repeat_expression,
 8197|     49|      (size_t)3U * sizeof(libcrux_ml_kem_polynomial_PolynomialRingElement_1d));
 8198|     49|  return lit;
 8199|     49|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_ind_cpa_generate_keypair_unpacked_1c:
 8409|     49|    libcrux_ml_kem_ind_cpa_unpacked_IndCpaPublicKeyUnpacked_a0 *public_key) {
 8410|     49|  uint8_t hashed[64U];
 8411|     49|  libcrux_ml_kem_variant_cpa_keygen_seed_39_9c(key_generation_seed, hashed);
 8412|     49|  Eurydice_slice_uint8_t_x2 uu____0 = Eurydice_slice_split_at(
  ------------------
  |  |  254|     49|  KRML_CLITERAL(ret_t) {                                                  \
  |  |  ------------------
  |  |  |  |  154|     49|#define KRML_CLITERAL(type) (type)
  |  |  ------------------
  |  |  255|     49|    EURYDICE_CFIELD(.fst =)                                               \
  |  |  256|     49|    EURYDICE_SLICE((element_type *)(slice).ptr, 0, mid),                  \
  |  |  ------------------
  |  |  |  |  169|     49|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|     49|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  257|     49|        EURYDICE_CFIELD(.snd =)                                           \
  |  |  258|     49|            EURYDICE_SLICE((element_type *)(slice).ptr, mid, (slice).len) \
  |  |  ------------------
  |  |  |  |  169|     49|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|     49|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  259|     49|  }
  ------------------
 8413|     49|      Eurydice_array_to_slice((size_t)64U, hashed, uint8_t), (size_t)32U,
 8414|     49|      uint8_t, Eurydice_slice_uint8_t_x2);
 8415|     49|  Eurydice_slice seed_for_A = uu____0.fst;
 8416|     49|  Eurydice_slice seed_for_secret_and_error = uu____0.snd;
 8417|     49|  libcrux_ml_kem_polynomial_PolynomialRingElement_1d(*uu____1)[3U] =
 8418|     49|      public_key->A;
 8419|     49|  uint8_t ret[34U];
 8420|     49|  libcrux_ml_kem_utils_into_padded_array_b6(seed_for_A, ret);
 8421|     49|  libcrux_ml_kem_matrix_sample_matrix_A_2b(uu____1, ret, true);
 8422|     49|  uint8_t prf_input[33U];
 8423|     49|  libcrux_ml_kem_utils_into_padded_array_c8(seed_for_secret_and_error,
 8424|     49|                                            prf_input);
 8425|     49|  uint8_t domain_separator =
 8426|     49|      libcrux_ml_kem_ind_cpa_sample_vector_cbd_then_ntt_3b(
 8427|     49|          private_key->secret_as_ntt, prf_input, 0U);
 8428|     49|  libcrux_ml_kem_polynomial_PolynomialRingElement_1d error_as_ntt[3U];
 8429|    196|  for (size_t i = (size_t)0U; i < (size_t)3U; i++) {
  ------------------
  |  Branch (8429:31): [True: 147, False: 49]
  ------------------
 8430|       |    /* original Rust expression is not an lvalue in C */
 8431|    147|    void *lvalue = (void *)0U;
 8432|    147|    error_as_ntt[i] =
 8433|    147|        libcrux_ml_kem_ind_cpa_generate_keypair_unpacked_call_mut_73_1c(&lvalue,
 8434|    147|                                                                        i);
 8435|    147|  }
 8436|     49|  libcrux_ml_kem_ind_cpa_sample_vector_cbd_then_ntt_3b(error_as_ntt, prf_input,
 8437|     49|                                                       domain_separator);
 8438|     49|  libcrux_ml_kem_matrix_compute_As_plus_e_1b(
 8439|     49|      public_key->t_as_ntt, public_key->A, private_key->secret_as_ntt,
 8440|     49|      error_as_ntt);
 8441|     49|  uint8_t uu____2[32U];
 8442|     49|  Result_fb dst;
 8443|     49|  Eurydice_slice_to_array2(&dst, seed_for_A, Eurydice_slice, uint8_t[32U],
  ------------------
  |  |  277|     49|  Eurydice_slice_to_array3(&(dst)->tag, (char *)&(dst)->val.case_Ok, src, \
  |  |  278|     49|                           sizeof(t_arr))
  ------------------
 8444|     49|                           TryFromSliceError);
 8445|     49|  unwrap_26_b3(dst, uu____2);
 8446|     49|  memcpy(public_key->seed_for_A, uu____2, (size_t)32U * sizeof(uint8_t));
 8447|     49|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_variant_cpa_keygen_seed_39_9c:
 8212|     49|    Eurydice_slice key_generation_seed, uint8_t ret[64U]) {
 8213|     49|  uint8_t seed[33U] = {0U};
 8214|     49|  Eurydice_slice_copy(
  ------------------
  |  |  229|     49|  memcpy(dst.ptr, src.ptr, dst.len * sizeof(t))
  ------------------
 8215|     49|      Eurydice_array_to_subslice3(
 8216|     49|          seed, (size_t)0U,
 8217|     49|          LIBCRUX_ML_KEM_CONSTANTS_CPA_PKE_KEY_GENERATION_SEED_SIZE, uint8_t *),
 8218|     49|      key_generation_seed, uint8_t);
 8219|     49|  seed[LIBCRUX_ML_KEM_CONSTANTS_CPA_PKE_KEY_GENERATION_SEED_SIZE] =
  ------------------
  |  |  455|     49|#define LIBCRUX_ML_KEM_CONSTANTS_CPA_PKE_KEY_GENERATION_SEED_SIZE ((size_t)32U)
  ------------------
 8220|     49|      (uint8_t)(size_t)3U;
 8221|     49|  uint8_t ret0[64U];
 8222|     49|  libcrux_ml_kem_hash_functions_portable_G_4a_e0(
 8223|     49|      Eurydice_array_to_slice((size_t)33U, seed, uint8_t), ret0);
  ------------------
  |  |  204|     49|  EURYDICE_SLICE(x, 0,                     \
  |  |  ------------------
  |  |  |  |  169|     49|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|     49|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  205|     49|                 end) /* x is already at an array type, no need for cast */
  ------------------
 8224|     49|  memcpy(ret, ret0, (size_t)64U * sizeof(uint8_t));
 8225|     49|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_ind_cpa_generate_keypair_unpacked_call_mut_73_1c:
 8247|    147|    void **_, size_t tupled_args) {
 8248|    147|  return libcrux_ml_kem_polynomial_ZERO_d6_ea();
 8249|    147|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_matrix_compute_As_plus_e_1b:
 8322|     49|    libcrux_ml_kem_polynomial_PolynomialRingElement_1d *error_as_ntt) {
 8323|     49|  for (size_t i = (size_t)0U;
 8324|    196|       i < Eurydice_slice_len(
  ------------------
  |  |  173|    196|#define Eurydice_slice_len(s, _) (s).len
  ------------------
  |  Branch (8324:8): [True: 147, False: 49]
  ------------------
 8325|     49|               Eurydice_array_to_slice(
 8326|     49|                   (size_t)3U, matrix_A,
 8327|     49|                   libcrux_ml_kem_polynomial_PolynomialRingElement_1d[3U]),
 8328|     49|               libcrux_ml_kem_polynomial_PolynomialRingElement_1d[3U]);
 8329|    147|       i++) {
 8330|    147|    size_t i0 = i;
 8331|    147|    libcrux_ml_kem_polynomial_PolynomialRingElement_1d *row = matrix_A[i0];
 8332|    147|    libcrux_ml_kem_polynomial_PolynomialRingElement_1d uu____0 =
 8333|    147|        libcrux_ml_kem_polynomial_ZERO_d6_ea();
 8334|    147|    t_as_ntt[i0] = uu____0;
 8335|    147|    for (size_t i1 = (size_t)0U;
 8336|    588|         i1 < Eurydice_slice_len(
  ------------------
  |  |  173|    588|#define Eurydice_slice_len(s, _) (s).len
  ------------------
  |  Branch (8336:10): [True: 441, False: 147]
  ------------------
 8337|    147|                  Eurydice_array_to_slice(
 8338|    147|                      (size_t)3U, row,
 8339|    147|                      libcrux_ml_kem_polynomial_PolynomialRingElement_1d),
 8340|    147|                  libcrux_ml_kem_polynomial_PolynomialRingElement_1d);
 8341|    441|         i1++) {
 8342|    441|      size_t j = i1;
 8343|    441|      libcrux_ml_kem_polynomial_PolynomialRingElement_1d *matrix_element =
 8344|    441|          &row[j];
 8345|    441|      libcrux_ml_kem_polynomial_PolynomialRingElement_1d product =
 8346|    441|          libcrux_ml_kem_polynomial_ntt_multiply_d6_ea(matrix_element,
 8347|    441|                                                       &s_as_ntt[j]);
 8348|    441|      libcrux_ml_kem_polynomial_add_to_ring_element_d6_1b(&t_as_ntt[i0],
 8349|    441|                                                          &product);
 8350|    441|    }
 8351|    147|    libcrux_ml_kem_polynomial_add_standard_error_reduce_d6_ea(
 8352|    147|        &t_as_ntt[i0], &error_as_ntt[i0]);
 8353|    147|  }
 8354|     49|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_polynomial_add_standard_error_reduce_d6_ea:
 8305|    147|    libcrux_ml_kem_polynomial_PolynomialRingElement_1d *error) {
 8306|    147|  libcrux_ml_kem_polynomial_add_standard_error_reduce_ea(self, error);
 8307|    147|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_polynomial_add_standard_error_reduce_ea:
 8274|    147|    libcrux_ml_kem_polynomial_PolynomialRingElement_1d *error) {
 8275|    147|  for (size_t i = (size_t)0U;
 8276|  2.49k|       i < LIBCRUX_ML_KEM_POLYNOMIAL_VECTORS_IN_RING_ELEMENT; i++) {
  ------------------
  |  | 3770|  2.49k|#define LIBCRUX_ML_KEM_POLYNOMIAL_VECTORS_IN_RING_ELEMENT ((size_t)16U)
  ------------------
  |  Branch (8276:8): [True: 2.35k, False: 147]
  ------------------
 8277|  2.35k|    size_t j = i;
 8278|  2.35k|    libcrux_ml_kem_vector_portable_vector_type_PortableVector
 8279|  2.35k|        coefficient_normal_form =
 8280|  2.35k|            libcrux_ml_kem_polynomial_to_standard_domain_ea(
 8281|  2.35k|                myself->coefficients[j]);
 8282|  2.35k|    libcrux_ml_kem_vector_portable_vector_type_PortableVector sum =
 8283|  2.35k|        libcrux_ml_kem_vector_portable_add_b8(coefficient_normal_form,
 8284|  2.35k|                                              &error->coefficients[j]);
 8285|  2.35k|    libcrux_ml_kem_vector_portable_vector_type_PortableVector red =
 8286|  2.35k|        libcrux_ml_kem_vector_portable_barrett_reduce_b8(sum);
 8287|  2.35k|    myself->coefficients[j] = red;
 8288|  2.35k|  }
 8289|    147|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_polynomial_to_standard_domain_ea:
 8259|  2.35k|    libcrux_ml_kem_vector_portable_vector_type_PortableVector vector) {
 8260|  2.35k|  return libcrux_ml_kem_vector_portable_montgomery_multiply_by_constant_b8(
 8261|  2.35k|      vector,
 8262|  2.35k|      LIBCRUX_ML_KEM_VECTOR_TRAITS_MONTGOMERY_R_SQUARED_MOD_FIELD_MODULUS);
  ------------------
  |  | 3775|  2.35k|  ((int16_t)1353)
  ------------------
 8263|  2.35k|}
libcrux_mlkem768_sha3.c:unwrap_26_b3:
  803|     49|static inline void unwrap_26_b3(Result_fb self, uint8_t ret[32U]) {
  804|     49|  if (self.tag == Ok) {
  ------------------
  |  |  721|     49|#define Ok 0
  ------------------
  |  Branch (804:7): [True: 49, False: 0]
  ------------------
  805|     49|    uint8_t f0[32U];
  806|     49|    memcpy(f0, self.val.case_Ok, (size_t)32U * sizeof(uint8_t));
  807|     49|    memcpy(ret, f0, (size_t)32U * sizeof(uint8_t));
  808|     49|  } 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|     49|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_ind_cpa_serialize_unpacked_secret_key_6c:
 8567|     49|    libcrux_ml_kem_ind_cpa_unpacked_IndCpaPrivateKeyUnpacked_a0 *private_key) {
 8568|     49|  uint8_t public_key_serialized[1184U];
 8569|     49|  libcrux_ml_kem_ind_cpa_serialize_public_key_89(
 8570|     49|      public_key->t_as_ntt,
 8571|     49|      Eurydice_array_to_slice((size_t)32U, public_key->seed_for_A, uint8_t),
  ------------------
  |  |  204|     49|  EURYDICE_SLICE(x, 0,                     \
  |  |  ------------------
  |  |  |  |  169|     49|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|     49|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  205|     49|                 end) /* x is already at an array type, no need for cast */
  ------------------
 8572|     49|      public_key_serialized);
 8573|     49|  uint8_t secret_key_serialized[1152U] = {0U};
 8574|     49|  libcrux_ml_kem_ind_cpa_serialize_vector_1b(
 8575|     49|      private_key->secret_as_ntt,
 8576|     49|      Eurydice_array_to_slice((size_t)1152U, secret_key_serialized, uint8_t));
  ------------------
  |  |  204|     49|  EURYDICE_SLICE(x, 0,                     \
  |  |  ------------------
  |  |  |  |  169|     49|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|     49|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  205|     49|                 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|     49|  uint8_t copy_of_secret_key_serialized[1152U];
 8579|     49|  memcpy(copy_of_secret_key_serialized, secret_key_serialized,
 8580|     49|         (size_t)1152U * sizeof(uint8_t));
 8581|       |  /* Passing arrays by value in Rust generates a copy in C */
 8582|     49|  uint8_t copy_of_public_key_serialized[1184U];
 8583|     49|  memcpy(copy_of_public_key_serialized, public_key_serialized,
 8584|     49|         (size_t)1184U * sizeof(uint8_t));
 8585|     49|  libcrux_ml_kem_utils_extraction_helper_Keypair768 lit;
 8586|     49|  memcpy(lit.fst, copy_of_secret_key_serialized,
 8587|     49|         (size_t)1152U * sizeof(uint8_t));
 8588|     49|  memcpy(lit.snd, copy_of_public_key_serialized,
 8589|     49|         (size_t)1184U * sizeof(uint8_t));
 8590|     49|  return lit;
 8591|     49|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_ind_cpa_serialize_public_key_89:
 8546|     49|    Eurydice_slice seed_for_a, uint8_t ret[1184U]) {
 8547|     49|  uint8_t public_key_serialized[1184U] = {0U};
 8548|     49|  libcrux_ml_kem_ind_cpa_serialize_public_key_mut_89(t_as_ntt, seed_for_a,
 8549|     49|                                                     public_key_serialized);
 8550|     49|  memcpy(ret, public_key_serialized, (size_t)1184U * sizeof(uint8_t));
 8551|     49|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_ind_cpa_serialize_public_key_mut_89:
 8519|     49|    Eurydice_slice seed_for_a, uint8_t *serialized) {
 8520|     49|  libcrux_ml_kem_ind_cpa_serialize_vector_1b(
 8521|     49|      t_as_ntt,
 8522|     49|      Eurydice_array_to_subslice3(
  ------------------
  |  |  215|     49|  EURYDICE_SLICE((t_ptr)x, (start), (end))
  |  |  ------------------
  |  |  |  |  169|     49|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|     49|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 8523|     49|          serialized, (size_t)0U,
 8524|     49|          libcrux_ml_kem_constants_ranked_bytes_per_ring_element((size_t)3U),
 8525|     49|          uint8_t *));
 8526|     49|  Eurydice_slice_copy(
  ------------------
  |  |  229|     49|  memcpy(dst.ptr, src.ptr, dst.len * sizeof(t))
  ------------------
 8527|     49|      Eurydice_array_to_subslice_from(
 8528|     49|          (size_t)1184U, serialized,
 8529|     49|          libcrux_ml_kem_constants_ranked_bytes_per_ring_element((size_t)3U),
 8530|     49|          uint8_t, size_t, uint8_t[]),
 8531|     49|      seed_for_a, uint8_t);
 8532|     49|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_constants_ranked_bytes_per_ring_element:
  468|    245|    size_t rank) {
  469|    245|  return rank * LIBCRUX_ML_KEM_CONSTANTS_BITS_PER_RING_ELEMENT / (size_t)8U;
  ------------------
  |  |  450|    245|  (LIBCRUX_ML_KEM_CONSTANTS_COEFFICIENTS_IN_RING_ELEMENT * (size_t)12U)
  |  |  ------------------
  |  |  |  |  447|    245|#define LIBCRUX_ML_KEM_CONSTANTS_COEFFICIENTS_IN_RING_ELEMENT ((size_t)256U)
  |  |  ------------------
  ------------------
  470|    245|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_ind_cpa_serialize_vector_1b:
 8486|     98|    Eurydice_slice out) {
 8487|     98|  for (size_t i = (size_t)0U;
 8488|    392|       i < Eurydice_slice_len(
  ------------------
  |  |  173|    392|#define Eurydice_slice_len(s, _) (s).len
  ------------------
  |  Branch (8488:8): [True: 294, False: 98]
  ------------------
 8489|     98|               Eurydice_array_to_slice(
 8490|     98|                   (size_t)3U, key,
 8491|     98|                   libcrux_ml_kem_polynomial_PolynomialRingElement_1d),
 8492|     98|               libcrux_ml_kem_polynomial_PolynomialRingElement_1d);
 8493|    294|       i++) {
 8494|    294|    size_t i0 = i;
 8495|    294|    libcrux_ml_kem_polynomial_PolynomialRingElement_1d re = key[i0];
 8496|    294|    Eurydice_slice uu____0 = Eurydice_slice_subslice3(
  ------------------
  |  |  195|    294|  EURYDICE_SLICE((t_ptr)s.ptr, (start), (end))
  |  |  ------------------
  |  |  |  |  169|    294|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|    294|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 8497|    294|        out, i0 * LIBCRUX_ML_KEM_CONSTANTS_BYTES_PER_RING_ELEMENT,
 8498|    294|        (i0 + (size_t)1U) * LIBCRUX_ML_KEM_CONSTANTS_BYTES_PER_RING_ELEMENT,
 8499|    294|        uint8_t *);
 8500|    294|    uint8_t ret[384U];
 8501|    294|    libcrux_ml_kem_serialize_serialize_uncompressed_ring_element_ea(&re, ret);
 8502|    294|    Eurydice_slice_copy(
  ------------------
  |  |  229|    294|  memcpy(dst.ptr, src.ptr, dst.len * sizeof(t))
  ------------------
 8503|    294|        uu____0, Eurydice_array_to_slice((size_t)384U, ret, uint8_t), uint8_t);
 8504|    294|  }
 8505|     98|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_serialize_serialize_uncompressed_ring_element_ea:
 8457|    294|    libcrux_ml_kem_polynomial_PolynomialRingElement_1d *re, uint8_t ret[384U]) {
 8458|    294|  uint8_t serialized[384U] = {0U};
 8459|    294|  for (size_t i = (size_t)0U;
 8460|  4.99k|       i < LIBCRUX_ML_KEM_POLYNOMIAL_VECTORS_IN_RING_ELEMENT; i++) {
  ------------------
  |  | 3770|  4.99k|#define LIBCRUX_ML_KEM_POLYNOMIAL_VECTORS_IN_RING_ELEMENT ((size_t)16U)
  ------------------
  |  Branch (8460:8): [True: 4.70k, False: 294]
  ------------------
 8461|  4.70k|    size_t i0 = i;
 8462|  4.70k|    libcrux_ml_kem_vector_portable_vector_type_PortableVector coefficient =
 8463|  4.70k|        libcrux_ml_kem_serialize_to_unsigned_field_modulus_ea(
 8464|  4.70k|            re->coefficients[i0]);
 8465|  4.70k|    uint8_t bytes[24U];
 8466|  4.70k|    libcrux_ml_kem_vector_portable_serialize_12_b8(coefficient, bytes);
 8467|  4.70k|    Eurydice_slice_copy(
  ------------------
  |  |  229|  4.70k|  memcpy(dst.ptr, src.ptr, dst.len * sizeof(t))
  ------------------
 8468|  4.70k|        Eurydice_array_to_subslice3(serialized, (size_t)24U * i0,
 8469|  4.70k|                                    (size_t)24U * i0 + (size_t)24U, uint8_t *),
 8470|  4.70k|        Eurydice_array_to_slice((size_t)24U, bytes, uint8_t), uint8_t);
 8471|  4.70k|  }
 8472|    294|  memcpy(ret, serialized, (size_t)384U * sizeof(uint8_t));
 8473|    294|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_vector_portable_serialize_12_b8:
 5116|  4.70k|    uint8_t ret[24U]) {
 5117|  4.70k|  libcrux_ml_kem_vector_portable_serialize_12(a, ret);
 5118|  4.70k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_vector_portable_serialize_12:
 5104|  4.70k|    uint8_t ret[24U]) {
 5105|  4.70k|  uint8_t ret0[24U];
 5106|  4.70k|  libcrux_ml_kem_vector_portable_serialize_serialize_12(a, ret0);
 5107|  4.70k|  libcrux_secrets_int_public_integers_declassify_d8_d2(ret0, ret);
 5108|  4.70k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_vector_portable_serialize_serialize_12:
 5051|  4.70k|    uint8_t ret[24U]) {
 5052|  4.70k|  uint8_t_x3 r0_2 = libcrux_ml_kem_vector_portable_serialize_serialize_12_int(
 5053|  4.70k|      Eurydice_array_to_subslice3(v.elements, (size_t)0U, (size_t)2U,
  ------------------
  |  |  215|  4.70k|  EURYDICE_SLICE((t_ptr)x, (start), (end))
  |  |  ------------------
  |  |  |  |  169|  4.70k|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|  4.70k|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5054|  4.70k|                                  int16_t *));
 5055|  4.70k|  uint8_t_x3 r3_5 = libcrux_ml_kem_vector_portable_serialize_serialize_12_int(
 5056|  4.70k|      Eurydice_array_to_subslice3(v.elements, (size_t)2U, (size_t)4U,
  ------------------
  |  |  215|  4.70k|  EURYDICE_SLICE((t_ptr)x, (start), (end))
  |  |  ------------------
  |  |  |  |  169|  4.70k|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|  4.70k|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5057|  4.70k|                                  int16_t *));
 5058|  4.70k|  uint8_t_x3 r6_8 = libcrux_ml_kem_vector_portable_serialize_serialize_12_int(
 5059|  4.70k|      Eurydice_array_to_subslice3(v.elements, (size_t)4U, (size_t)6U,
  ------------------
  |  |  215|  4.70k|  EURYDICE_SLICE((t_ptr)x, (start), (end))
  |  |  ------------------
  |  |  |  |  169|  4.70k|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|  4.70k|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5060|  4.70k|                                  int16_t *));
 5061|  4.70k|  uint8_t_x3 r9_11 = libcrux_ml_kem_vector_portable_serialize_serialize_12_int(
 5062|  4.70k|      Eurydice_array_to_subslice3(v.elements, (size_t)6U, (size_t)8U,
  ------------------
  |  |  215|  4.70k|  EURYDICE_SLICE((t_ptr)x, (start), (end))
  |  |  ------------------
  |  |  |  |  169|  4.70k|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|  4.70k|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5063|  4.70k|                                  int16_t *));
 5064|  4.70k|  uint8_t_x3 r12_14 = libcrux_ml_kem_vector_portable_serialize_serialize_12_int(
 5065|  4.70k|      Eurydice_array_to_subslice3(v.elements, (size_t)8U, (size_t)10U,
  ------------------
  |  |  215|  4.70k|  EURYDICE_SLICE((t_ptr)x, (start), (end))
  |  |  ------------------
  |  |  |  |  169|  4.70k|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|  4.70k|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5066|  4.70k|                                  int16_t *));
 5067|  4.70k|  uint8_t_x3 r15_17 = libcrux_ml_kem_vector_portable_serialize_serialize_12_int(
 5068|  4.70k|      Eurydice_array_to_subslice3(v.elements, (size_t)10U, (size_t)12U,
  ------------------
  |  |  215|  4.70k|  EURYDICE_SLICE((t_ptr)x, (start), (end))
  |  |  ------------------
  |  |  |  |  169|  4.70k|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|  4.70k|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5069|  4.70k|                                  int16_t *));
 5070|  4.70k|  uint8_t_x3 r18_20 = libcrux_ml_kem_vector_portable_serialize_serialize_12_int(
 5071|  4.70k|      Eurydice_array_to_subslice3(v.elements, (size_t)12U, (size_t)14U,
  ------------------
  |  |  215|  4.70k|  EURYDICE_SLICE((t_ptr)x, (start), (end))
  |  |  ------------------
  |  |  |  |  169|  4.70k|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|  4.70k|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5072|  4.70k|                                  int16_t *));
 5073|  4.70k|  uint8_t_x3 r21_23 = libcrux_ml_kem_vector_portable_serialize_serialize_12_int(
 5074|  4.70k|      Eurydice_array_to_subslice3(v.elements, (size_t)14U, (size_t)16U,
  ------------------
  |  |  215|  4.70k|  EURYDICE_SLICE((t_ptr)x, (start), (end))
  |  |  ------------------
  |  |  |  |  169|  4.70k|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|  4.70k|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5075|  4.70k|                                  int16_t *));
 5076|  4.70k|  ret[0U] = r0_2.fst;
 5077|  4.70k|  ret[1U] = r0_2.snd;
 5078|  4.70k|  ret[2U] = r0_2.thd;
 5079|  4.70k|  ret[3U] = r3_5.fst;
 5080|  4.70k|  ret[4U] = r3_5.snd;
 5081|  4.70k|  ret[5U] = r3_5.thd;
 5082|  4.70k|  ret[6U] = r6_8.fst;
 5083|  4.70k|  ret[7U] = r6_8.snd;
 5084|  4.70k|  ret[8U] = r6_8.thd;
 5085|  4.70k|  ret[9U] = r9_11.fst;
 5086|  4.70k|  ret[10U] = r9_11.snd;
 5087|  4.70k|  ret[11U] = r9_11.thd;
 5088|  4.70k|  ret[12U] = r12_14.fst;
 5089|  4.70k|  ret[13U] = r12_14.snd;
 5090|  4.70k|  ret[14U] = r12_14.thd;
 5091|  4.70k|  ret[15U] = r15_17.fst;
 5092|  4.70k|  ret[16U] = r15_17.snd;
 5093|  4.70k|  ret[17U] = r15_17.thd;
 5094|  4.70k|  ret[18U] = r18_20.fst;
 5095|  4.70k|  ret[19U] = r18_20.snd;
 5096|  4.70k|  ret[20U] = r18_20.thd;
 5097|  4.70k|  ret[21U] = r21_23.fst;
 5098|  4.70k|  ret[22U] = r21_23.snd;
 5099|  4.70k|  ret[23U] = r21_23.thd;
 5100|  4.70k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_vector_portable_serialize_serialize_12_int:
 5035|  37.6k|libcrux_ml_kem_vector_portable_serialize_serialize_12_int(Eurydice_slice v) {
 5036|  37.6k|  uint8_t r0 = libcrux_secrets_int_as_u8_f5(
 5037|  37.6k|      Eurydice_slice_index(v, (size_t)0U, int16_t, int16_t *) & (int16_t)255);
  ------------------
  |  |  180|  37.6k|#define Eurydice_slice_index(s, i, t, t_ptr_t) (((t_ptr_t)s.ptr)[i])
  ------------------
 5038|  37.6k|  uint8_t r1 = libcrux_secrets_int_as_u8_f5(
 5039|  37.6k|      Eurydice_slice_index(v, (size_t)0U, int16_t, int16_t *) >> 8U |
  ------------------
  |  |  180|  37.6k|#define Eurydice_slice_index(s, i, t, t_ptr_t) (((t_ptr_t)s.ptr)[i])
  ------------------
 5040|  37.6k|      (Eurydice_slice_index(v, (size_t)1U, int16_t, int16_t *) & (int16_t)15)
  ------------------
  |  |  180|  37.6k|#define Eurydice_slice_index(s, i, t, t_ptr_t) (((t_ptr_t)s.ptr)[i])
  ------------------
 5041|  37.6k|          << 4U);
 5042|  37.6k|  uint8_t r2 = libcrux_secrets_int_as_u8_f5(
 5043|  37.6k|      Eurydice_slice_index(v, (size_t)1U, int16_t, int16_t *) >> 4U &
  ------------------
  |  |  180|  37.6k|#define Eurydice_slice_index(s, i, t, t_ptr_t) (((t_ptr_t)s.ptr)[i])
  ------------------
 5044|  37.6k|      (int16_t)255);
 5045|  37.6k|  return (KRML_CLITERAL(uint8_t_x3){.fst = r0, .snd = r1, .thd = r2});
  ------------------
  |  |  154|  37.6k|#define KRML_CLITERAL(type) (type)
  ------------------
 5046|  37.6k|}
libcrux_mlkem768_sha3.c:libcrux_secrets_int_public_integers_declassify_d8_d2:
 1020|  4.70k|                                                     uint8_t ret[24U]) {
 1021|  4.70k|  memcpy(ret, self, (size_t)24U * sizeof(uint8_t));
 1022|  4.70k|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_ind_cca_serialize_kem_secret_key_d6:
 8677|     49|    Eurydice_slice implicit_rejection_value, uint8_t ret[2400U]) {
 8678|     49|  uint8_t out[2400U] = {0U};
 8679|     49|  libcrux_ml_kem_ind_cca_serialize_kem_secret_key_mut_d6(
 8680|     49|      private_key, public_key, implicit_rejection_value, out);
 8681|     49|  memcpy(ret, out, (size_t)2400U * sizeof(uint8_t));
 8682|     49|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_ind_cca_serialize_kem_secret_key_mut_d6:
 8629|     49|    Eurydice_slice implicit_rejection_value, uint8_t *serialized) {
 8630|     49|  size_t pointer = (size_t)0U;
 8631|     49|  uint8_t *uu____0 = serialized;
 8632|     49|  size_t uu____1 = pointer;
 8633|     49|  size_t uu____2 = pointer;
 8634|     49|  Eurydice_slice_copy(
  ------------------
  |  |  229|     49|  memcpy(dst.ptr, src.ptr, dst.len * sizeof(t))
  ------------------
 8635|     49|      Eurydice_array_to_subslice3(
 8636|     49|          uu____0, uu____1, uu____2 + Eurydice_slice_len(private_key, uint8_t),
 8637|     49|          uint8_t *),
 8638|     49|      private_key, uint8_t);
 8639|     49|  pointer = pointer + Eurydice_slice_len(private_key, uint8_t);
  ------------------
  |  |  173|     49|#define Eurydice_slice_len(s, _) (s).len
  ------------------
 8640|     49|  uint8_t *uu____3 = serialized;
 8641|     49|  size_t uu____4 = pointer;
 8642|     49|  size_t uu____5 = pointer;
 8643|     49|  Eurydice_slice_copy(
  ------------------
  |  |  229|     49|  memcpy(dst.ptr, src.ptr, dst.len * sizeof(t))
  ------------------
 8644|     49|      Eurydice_array_to_subslice3(
 8645|     49|          uu____3, uu____4, uu____5 + Eurydice_slice_len(public_key, uint8_t),
 8646|     49|          uint8_t *),
 8647|     49|      public_key, uint8_t);
 8648|     49|  pointer = pointer + Eurydice_slice_len(public_key, uint8_t);
  ------------------
  |  |  173|     49|#define Eurydice_slice_len(s, _) (s).len
  ------------------
 8649|     49|  Eurydice_slice uu____6 = Eurydice_array_to_subslice3(
  ------------------
  |  |  215|     49|  EURYDICE_SLICE((t_ptr)x, (start), (end))
  |  |  ------------------
  |  |  |  |  169|     49|  (KRML_CLITERAL(Eurydice_slice){(void *)(x + start), end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |  154|     49|#define KRML_CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 8650|     49|      serialized, pointer, pointer + LIBCRUX_ML_KEM_CONSTANTS_H_DIGEST_SIZE,
 8651|     49|      uint8_t *);
 8652|     49|  uint8_t ret[32U];
 8653|     49|  libcrux_ml_kem_hash_functions_portable_H_4a_e0(public_key, ret);
 8654|     49|  Eurydice_slice_copy(
  ------------------
  |  |  229|     49|  memcpy(dst.ptr, src.ptr, dst.len * sizeof(t))
  ------------------
 8655|     49|      uu____6, Eurydice_array_to_slice((size_t)32U, ret, uint8_t), uint8_t);
 8656|     49|  pointer = pointer + LIBCRUX_ML_KEM_CONSTANTS_H_DIGEST_SIZE;
  ------------------
  |  |  459|     49|#define LIBCRUX_ML_KEM_CONSTANTS_H_DIGEST_SIZE ((size_t)32U)
  ------------------
 8657|     49|  uint8_t *uu____7 = serialized;
 8658|     49|  size_t uu____8 = pointer;
 8659|     49|  size_t uu____9 = pointer;
 8660|     49|  Eurydice_slice_copy(
  ------------------
  |  |  229|     49|  memcpy(dst.ptr, src.ptr, dst.len * sizeof(t))
  ------------------
 8661|     49|      Eurydice_array_to_subslice3(
 8662|     49|          uu____7, uu____8,
 8663|     49|          uu____9 + Eurydice_slice_len(implicit_rejection_value, uint8_t),
 8664|     49|          uint8_t *),
 8665|     49|      implicit_rejection_value, uint8_t);
 8666|     49|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_types_from_77_28:
  772|     49|libcrux_ml_kem_types_from_77_28(uint8_t value[2400U]) {
  773|       |  /* Passing arrays by value in Rust generates a copy in C */
  774|     49|  uint8_t copy_of_value[2400U];
  775|     49|  memcpy(copy_of_value, value, (size_t)2400U * sizeof(uint8_t));
  776|     49|  libcrux_ml_kem_types_MlKemPrivateKey_d9 lit;
  777|     49|  memcpy(lit.value, copy_of_value, (size_t)2400U * sizeof(uint8_t));
  778|     49|  return lit;
  779|     49|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_types_from_17_74:
  757|     49|                                libcrux_ml_kem_types_MlKemPublicKey_30 pk) {
  758|     49|  return (KRML_CLITERAL(libcrux_ml_kem_mlkem768_MlKem768KeyPair){.sk = sk,
  ------------------
  |  |  154|     49|#define KRML_CLITERAL(type) (type)
  ------------------
  759|     49|                                                                 .pk = pk});
  760|     49|}
libcrux_mlkem768_sha3.c:libcrux_ml_kem_types_from_fd_d0:
  736|     49|libcrux_ml_kem_types_from_fd_d0(uint8_t value[1184U]) {
  737|       |  /* Passing arrays by value in Rust generates a copy in C */
  738|     49|  uint8_t copy_of_value[1184U];
  739|     49|  memcpy(copy_of_value, value, (size_t)1184U * sizeof(uint8_t));
  740|     49|  libcrux_ml_kem_types_MlKemPublicKey_30 lit;
  741|     49|  memcpy(lit.value, copy_of_value, (size_t)1184U * sizeof(uint8_t));
  742|     49|  return lit;
  743|     49|}

sntrup761_keypair:
  989|     66|{
  990|     66|  int i;
  991|       |
  992|     66|  ZKeyGen (pk, sk, random_ctx, random);
  993|     66|  sk += SecretKeys_bytes;
  ------------------
  |  |  906|     66|#define SecretKeys_bytes (2*Small_bytes)
  |  |  ------------------
  |  |  |  |  799|     66|#define Small_bytes ((p+3)/4)
  |  |  |  |  ------------------
  |  |  |  |  |  |  236|     66|#define p 761
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  994|  76.4k|  for (i = 0; i < PublicKeys_bytes; ++i)
  ------------------
  |  |  907|  76.4k|#define PublicKeys_bytes Rq_bytes
  |  |  ------------------
  |  |  |  |  239|  76.4k|#define Rq_bytes 1158
  |  |  ------------------
  ------------------
  |  Branch (994:15): [True: 76.4k, False: 66]
  ------------------
  995|  76.4k|    *sk++ = pk[i];
  996|     66|  random (random_ctx, Inputs_bytes, sk);
  ------------------
  |  |  903|     66|#define Inputs_bytes Small_bytes
  |  |  ------------------
  |  |  |  |  799|     66|#define Small_bytes ((p+3)/4)
  |  |  |  |  ------------------
  |  |  |  |  |  |  236|     66|#define p 761
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  997|     66|  sk += Inputs_bytes;
  ------------------
  |  |  903|     66|#define Inputs_bytes Small_bytes
  |  |  ------------------
  |  |  |  |  799|     66|#define Small_bytes ((p+3)/4)
  |  |  |  |  ------------------
  |  |  |  |  |  |  236|     66|#define p 761
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  998|     66|  Hash_prefix (sk, 4, pk, PublicKeys_bytes);
  ------------------
  |  |  907|     66|#define PublicKeys_bytes Rq_bytes
  |  |  ------------------
  |  |  |  |  239|     66|#define Rq_bytes 1158
  |  |  ------------------
  ------------------
  999|     66|}
sntrup761.c:ZKeyGen:
  913|     66|{
  914|     66|  Fq h[p];
  915|     66|  small f[p], v[p];
  916|       |
  917|     66|  KeyGen (h, f, v, random_ctx, random);
  918|     66|  Rq_encode (pk, h);
  919|     66|  Small_encode (sk, f);
  920|     66|  sk += Small_bytes;
  ------------------
  |  |  799|     66|#define Small_bytes ((p+3)/4)
  |  |  ------------------
  |  |  |  |  236|     66|#define p 761
  |  |  ------------------
  ------------------
  921|     66|  Small_encode (sk, v);
  922|     66|}
sntrup761.c:KeyGen:
  749|     66|{
  750|     66|  small g[p];
  751|     66|  Fq finv[p];
  752|       |
  753|     66|  for (;;)
  754|     66|    {
  755|     66|      Small_random (g, random_ctx, random);
  756|     66|      if (R3_recip (ginv, g) == 0)
  ------------------
  |  Branch (756:11): [True: 66, False: 0]
  ------------------
  757|     66|	break;
  758|     66|    }
  759|     66|  Short_random (f, random_ctx, random);
  760|     66|  Rq_recip3 (finv, f);		/* always works */
  761|     66|  Rq_mult_small (h, finv, g);
  762|     66|}
sntrup761.c:Small_random:
  736|     66|{
  737|     66|  int i;
  738|       |
  739|  50.2k|  for (i = 0; i < p; ++i)
  ------------------
  |  |  236|  50.2k|#define p 761
  ------------------
  |  Branch (739:15): [True: 50.2k, False: 66]
  ------------------
  740|  50.2k|    out[i] = (((urandom32 (random_ctx, random) & 0x3fffffff) * 3) >> 30) - 1;
  741|     66|}
sntrup761.c:urandom32:
  711|   100k|{
  712|   100k|  unsigned char c[4];
  713|   100k|  uint32_t out[4];
  714|       |
  715|   100k|  random (random_ctx, 4, c);
  716|   100k|  out[0] = (uint32_t) c[0];
  717|   100k|  out[1] = ((uint32_t) c[1]) << 8;
  718|   100k|  out[2] = ((uint32_t) c[2]) << 16;
  719|   100k|  out[3] = ((uint32_t) c[3]) << 24;
  720|   100k|  return out[0] + out[1] + out[2] + out[3];
  721|   100k|}
sntrup761.c:R3_recip:
  491|     66|{
  492|     66|  small f[p + 1], g[p + 1], v[p + 1], r[p + 1];
  493|     66|  int i, loop, delta;
  494|     66|  int sign, swap, t;
  495|       |
  496|  50.3k|  for (i = 0; i < p + 1; ++i)
  ------------------
  |  |  236|  50.3k|#define p 761
  ------------------
  |  Branch (496:15): [True: 50.2k, False: 66]
  ------------------
  497|  50.2k|    v[i] = 0;
  498|  50.3k|  for (i = 0; i < p + 1; ++i)
  ------------------
  |  |  236|  50.3k|#define p 761
  ------------------
  |  Branch (498:15): [True: 50.2k, False: 66]
  ------------------
  499|  50.2k|    r[i] = 0;
  500|     66|  r[0] = 1;
  501|  50.2k|  for (i = 0; i < p; ++i)
  ------------------
  |  |  236|  50.2k|#define p 761
  ------------------
  |  Branch (501:15): [True: 50.2k, False: 66]
  ------------------
  502|  50.2k|    f[i] = 0;
  503|     66|  f[0] = 1;
  504|     66|  f[p - 1] = f[p] = -1;
  ------------------
  |  |  236|     66|#define p 761
  ------------------
                f[p - 1] = f[p] = -1;
  ------------------
  |  |  236|     66|#define p 761
  ------------------
  505|  50.2k|  for (i = 0; i < p; ++i)
  ------------------
  |  |  236|  50.2k|#define p 761
  ------------------
  |  Branch (505:15): [True: 50.2k, False: 66]
  ------------------
  506|  50.2k|    g[p - 1 - i] = in[i];
  ------------------
  |  |  236|  50.2k|#define p 761
  ------------------
  507|     66|  g[p] = 0;
  ------------------
  |  |  236|     66|#define p 761
  ------------------
  508|       |
  509|     66|  delta = 1;
  510|       |
  511|   100k|  for (loop = 0; loop < 2 * p - 1; ++loop)
  ------------------
  |  |  236|   100k|#define p 761
  ------------------
  |  Branch (511:18): [True: 100k, False: 66]
  ------------------
  512|   100k|    {
  513|  76.4M|      for (i = p; i > 0; --i)
  ------------------
  |  |  236|   100k|#define p 761
  ------------------
  |  Branch (513:19): [True: 76.3M, False: 100k]
  ------------------
  514|  76.3M|	v[i] = v[i - 1];
  515|   100k|      v[0] = 0;
  516|       |
  517|   100k|      sign = -g[0] * f[0];
  518|   100k|      swap = int16_t_negative_mask (-delta) & int16_t_nonzero_mask (g[0]);
  519|   100k|      delta ^= swap & (delta ^ -delta);
  520|   100k|      delta += 1;
  521|       |
  522|  76.5M|      for (i = 0; i < p + 1; ++i)
  ------------------
  |  |  236|  76.5M|#define p 761
  ------------------
  |  Branch (522:19): [True: 76.4M, False: 100k]
  ------------------
  523|  76.4M|	{
  524|  76.4M|	  t = swap & (f[i] ^ g[i]);
  525|  76.4M|	  f[i] ^= t;
  526|  76.4M|	  g[i] ^= t;
  527|  76.4M|	  t = swap & (v[i] ^ r[i]);
  528|  76.4M|	  v[i] ^= t;
  529|  76.4M|	  r[i] ^= t;
  530|  76.4M|	}
  531|       |
  532|  76.5M|      for (i = 0; i < p + 1; ++i)
  ------------------
  |  |  236|  76.5M|#define p 761
  ------------------
  |  Branch (532:19): [True: 76.4M, False: 100k]
  ------------------
  533|  76.4M|	g[i] = F3_freeze (g[i] + sign * f[i]);
  534|  76.5M|      for (i = 0; i < p + 1; ++i)
  ------------------
  |  |  236|  76.5M|#define p 761
  ------------------
  |  Branch (534:19): [True: 76.4M, False: 100k]
  ------------------
  535|  76.4M|	r[i] = F3_freeze (r[i] + sign * v[i]);
  536|       |
  537|  76.4M|      for (i = 0; i < p; ++i)
  ------------------
  |  |  236|  76.4M|#define p 761
  ------------------
  |  Branch (537:19): [True: 76.3M, False: 100k]
  ------------------
  538|  76.3M|	g[i] = g[i + 1];
  539|   100k|      g[p] = 0;
  ------------------
  |  |  236|   100k|#define p 761
  ------------------
  540|   100k|    }
  541|       |
  542|     66|  sign = f[0];
  543|  50.2k|  for (i = 0; i < p; ++i)
  ------------------
  |  |  236|  50.2k|#define p 761
  ------------------
  |  Branch (543:15): [True: 50.2k, False: 66]
  ------------------
  544|  50.2k|    out[i] = sign * v[p - 1 - i];
  ------------------
  |  |  236|  50.2k|#define p 761
  ------------------
  545|       |
  546|     66|  return int16_t_nonzero_mask (delta);
  547|     66|}
sntrup761.c:int16_t_negative_mask:
  382|   200k|{
  383|   200k|  uint16_t u = x;
  384|   200k|  u >>= 15;
  385|   200k|  return -(int) u;
  386|       |  /* alternative with gcc -fwrapv: */
  387|       |  /* x>>15 compiles to CPU's arithmetic right shift */
  388|   200k|}
sntrup761.c:int16_t_nonzero_mask:
  371|   200k|{
  372|   200k|  uint16_t u = x;		/* 0, else 1...65535 */
  373|   200k|  uint32_t v = u;		/* 0, else 1...65535 */
  374|   200k|  v = -v;			/* 0, else 2^32-65535...2^32-1 */
  375|   200k|  v >>= 31;			/* 0, else 1 */
  376|   200k|  return -v;			/* 0, else -1 */
  377|   200k|}
sntrup761.c:F3_freeze:
  400|   152M|{
  401|   152M|  return int32_mod_uint14 (x + 1, 3) - 1;
  402|   152M|}
sntrup761.c:int32_mod_uint14:
  228|   344M|{
  229|   344M|  int32_t q;
  230|   344M|  uint16_t r;
  231|   344M|  int32_divmod_uint14 (&q, &r, x, m);
  232|   344M|  return r;
  233|   344M|}
sntrup761.c:int32_divmod_uint14:
  209|   344M|{
  210|   344M|  uint32_t uq, uq2;
  211|   344M|  uint16_t ur, ur2;
  212|   344M|  uint32_t mask;
  213|       |
  214|   344M|  uint32_divmod_uint14 (&uq, &ur, 0x80000000 + (uint32_t) x, m);
  215|   344M|  uint32_divmod_uint14 (&uq2, &ur2, 0x80000000, m);
  216|   344M|  ur -= ur2;
  217|   344M|  uq -= uq2;
  218|   344M|  mask = -(uint32_t) (ur >> 15);
  219|   344M|  ur += mask & m;
  220|   344M|  uq += mask;
  221|   344M|  *r = ur;
  222|   344M|  *q = uq;
  223|   344M|}
sntrup761.c:uint32_divmod_uint14:
  149|   689M|{
  150|   689M|  uint32_t v = 0x80000000;
  151|   689M|  uint32_t qpart;
  152|   689M|  uint32_t mask;
  153|       |
  154|   689M|  v /= m;
  155|       |
  156|       |  /* caller guarantees m > 0 */
  157|       |  /* caller guarantees m < 16384 */
  158|       |  /* vm <= 2^31 <= vm+m-1 */
  159|       |  /* xvm <= 2^31 x <= xvm+x(m-1) */
  160|       |
  161|   689M|  *q = 0;
  162|       |
  163|   689M|  qpart = (x * (uint64_t) v) >> 31;
  164|       |  /* 2^31 qpart <= xv <= 2^31 qpart + 2^31-1 */
  165|       |  /* 2^31 qpart m <= xvm <= 2^31 qpart m + (2^31-1)m */
  166|       |  /* 2^31 qpart m <= 2^31 x <= 2^31 qpart m + (2^31-1)m + x(m-1) */
  167|       |  /* 0 <= 2^31 newx <= (2^31-1)m + x(m-1) */
  168|       |  /* 0 <= newx <= (1-1/2^31)m + x(m-1)/2^31 */
  169|       |  /* 0 <= newx <= (1-1/2^31)(2^14-1) + (2^32-1)((2^14-1)-1)/2^31 */
  170|       |
  171|   689M|  x -= qpart * m;
  172|   689M|  *q += qpart;
  173|       |  /* x <= 49146 */
  174|       |
  175|   689M|  qpart = (x * (uint64_t) v) >> 31;
  176|       |  /* 0 <= newx <= (1-1/2^31)m + x(m-1)/2^31 */
  177|       |  /* 0 <= newx <= m + 49146(2^14-1)/2^31 */
  178|       |  /* 0 <= newx <= m + 0.4 */
  179|       |  /* 0 <= newx <= m */
  180|       |
  181|   689M|  x -= qpart * m;
  182|   689M|  *q += qpart;
  183|       |  /* x <= m */
  184|       |
  185|   689M|  x -= m;
  186|   689M|  *q += 1;
  187|   689M|  mask = -(x >> 31);
  188|   689M|  x += mask & (uint32_t) m;
  189|   689M|  *q += mask;
  190|       |  /* x < m */
  191|       |
  192|   689M|  *r = x;
  193|   689M|}
sntrup761.c:Rq_recip3:
  598|     66|{
  599|     66|  Fq f[p + 1], g[p + 1], v[p + 1], r[p + 1];
  600|     66|  int i, loop, delta;
  601|     66|  int swap, t;
  602|     66|  int32_t f0, g0;
  603|     66|  Fq scale;
  604|       |
  605|  50.3k|  for (i = 0; i < p + 1; ++i)
  ------------------
  |  |  236|  50.3k|#define p 761
  ------------------
  |  Branch (605:15): [True: 50.2k, False: 66]
  ------------------
  606|  50.2k|    v[i] = 0;
  607|  50.3k|  for (i = 0; i < p + 1; ++i)
  ------------------
  |  |  236|  50.3k|#define p 761
  ------------------
  |  Branch (607:15): [True: 50.2k, False: 66]
  ------------------
  608|  50.2k|    r[i] = 0;
  609|     66|  r[0] = Fq_recip (3);
  610|  50.2k|  for (i = 0; i < p; ++i)
  ------------------
  |  |  236|  50.2k|#define p 761
  ------------------
  |  Branch (610:15): [True: 50.2k, False: 66]
  ------------------
  611|  50.2k|    f[i] = 0;
  612|     66|  f[0] = 1;
  613|     66|  f[p - 1] = f[p] = -1;
  ------------------
  |  |  236|     66|#define p 761
  ------------------
                f[p - 1] = f[p] = -1;
  ------------------
  |  |  236|     66|#define p 761
  ------------------
  614|  50.2k|  for (i = 0; i < p; ++i)
  ------------------
  |  |  236|  50.2k|#define p 761
  ------------------
  |  Branch (614:15): [True: 50.2k, False: 66]
  ------------------
  615|  50.2k|    g[p - 1 - i] = in[i];
  ------------------
  |  |  236|  50.2k|#define p 761
  ------------------
  616|     66|  g[p] = 0;
  ------------------
  |  |  236|     66|#define p 761
  ------------------
  617|       |
  618|     66|  delta = 1;
  619|       |
  620|   100k|  for (loop = 0; loop < 2 * p - 1; ++loop)
  ------------------
  |  |  236|   100k|#define p 761
  ------------------
  |  Branch (620:18): [True: 100k, False: 66]
  ------------------
  621|   100k|    {
  622|  76.4M|      for (i = p; i > 0; --i)
  ------------------
  |  |  236|   100k|#define p 761
  ------------------
  |  Branch (622:19): [True: 76.3M, False: 100k]
  ------------------
  623|  76.3M|	v[i] = v[i - 1];
  624|   100k|      v[0] = 0;
  625|       |
  626|   100k|      swap = int16_t_negative_mask (-delta) & int16_t_nonzero_mask (g[0]);
  627|   100k|      delta ^= swap & (delta ^ -delta);
  628|   100k|      delta += 1;
  629|       |
  630|  76.5M|      for (i = 0; i < p + 1; ++i)
  ------------------
  |  |  236|  76.5M|#define p 761
  ------------------
  |  Branch (630:19): [True: 76.4M, False: 100k]
  ------------------
  631|  76.4M|	{
  632|  76.4M|	  t = swap & (f[i] ^ g[i]);
  633|  76.4M|	  f[i] ^= t;
  634|  76.4M|	  g[i] ^= t;
  635|  76.4M|	  t = swap & (v[i] ^ r[i]);
  636|  76.4M|	  v[i] ^= t;
  637|  76.4M|	  r[i] ^= t;
  638|  76.4M|	}
  639|       |
  640|   100k|      f0 = f[0];
  641|   100k|      g0 = g[0];
  642|  76.5M|      for (i = 0; i < p + 1; ++i)
  ------------------
  |  |  236|  76.5M|#define p 761
  ------------------
  |  Branch (642:19): [True: 76.4M, False: 100k]
  ------------------
  643|  76.4M|	g[i] = Fq_freeze (f0 * g[i] - g0 * f[i]);
  644|  76.5M|      for (i = 0; i < p + 1; ++i)
  ------------------
  |  |  236|  76.5M|#define p 761
  ------------------
  |  Branch (644:19): [True: 76.4M, False: 100k]
  ------------------
  645|  76.4M|	r[i] = Fq_freeze (f0 * r[i] - g0 * v[i]);
  646|       |
  647|  76.4M|      for (i = 0; i < p; ++i)
  ------------------
  |  |  236|  76.4M|#define p 761
  ------------------
  |  Branch (647:19): [True: 76.3M, False: 100k]
  ------------------
  648|  76.3M|	g[i] = g[i + 1];
  649|   100k|      g[p] = 0;
  ------------------
  |  |  236|   100k|#define p 761
  ------------------
  650|   100k|    }
  651|       |
  652|     66|  scale = Fq_recip (f[0]);
  653|  50.2k|  for (i = 0; i < p; ++i)
  ------------------
  |  |  236|  50.2k|#define p 761
  ------------------
  |  Branch (653:15): [True: 50.2k, False: 66]
  ------------------
  654|  50.2k|    out[i] = Fq_freeze (scale * (int32_t) v[p - 1 - i]);
  ------------------
  |  |  236|  50.2k|#define p 761
  ------------------
  655|       |
  656|     66|  return int16_t_nonzero_mask (delta);
  657|     66|}
sntrup761.c:Fq_recip:
  420|    132|{
  421|    132|  int i = 1;
  422|    132|  Fq ai = a1;
  423|       |
  424|   605k|  while (i < q - 2)
  ------------------
  |  |  237|   605k|#define q 4591
  ------------------
  |  Branch (424:10): [True: 605k, False: 132]
  ------------------
  425|   605k|    {
  426|   605k|      ai = Fq_freeze (a1 * (int32_t) ai);
  427|   605k|      i += 1;
  428|   605k|    }
  429|    132|  return ai;
  430|    132|}
sntrup761.c:Fq_freeze:
  414|   191M|{
  415|   191M|  return int32_mod_uint14 (x + q12, q) - q12;
  ------------------
  |  |  406|   191M|#define q12 ((q-1)/2)
  |  |  ------------------
  |  |  |  |  237|   191M|#define q 4591
  |  |  ------------------
  ------------------
                return int32_mod_uint14 (x + q12, q) - q12;
  ------------------
  |  |  237|   191M|#define q 4591
  ------------------
                return int32_mod_uint14 (x + q12, q) - q12;
  ------------------
  |  |  406|   191M|#define q12 ((q-1)/2)
  |  |  ------------------
  |  |  |  |  237|   191M|#define q 4591
  |  |  ------------------
  ------------------
  416|   191M|}
sntrup761.c:Rq_mult_small:
  554|     66|{
  555|     66|  Fq fg[p + p - 1];
  556|     66|  Fq result;
  557|     66|  int i, j;
  558|       |
  559|  50.2k|  for (i = 0; i < p; ++i)
  ------------------
  |  |  236|  50.2k|#define p 761
  ------------------
  |  Branch (559:15): [True: 50.2k, False: 66]
  ------------------
  560|  50.2k|    {
  561|  50.2k|      result = 0;
  562|  19.1M|      for (j = 0; j <= i; ++j)
  ------------------
  |  Branch (562:19): [True: 19.1M, False: 50.2k]
  ------------------
  563|  19.1M|	result = Fq_freeze (result + f[j] * (int32_t) g[i - j]);
  564|  50.2k|      fg[i] = result;
  565|  50.2k|    }
  566|  50.2k|  for (i = p; i < p + p - 1; ++i)
  ------------------
  |  |  236|     66|#define p 761
  ------------------
                for (i = p; i < p + p - 1; ++i)
  ------------------
  |  |  236|  50.2k|#define p 761
  ------------------
                for (i = p; i < p + p - 1; ++i)
  ------------------
  |  |  236|  50.2k|#define p 761
  ------------------
  |  Branch (566:15): [True: 50.1k, False: 66]
  ------------------
  567|  50.1k|    {
  568|  50.1k|      result = 0;
  569|  19.1M|      for (j = i - p + 1; j < p; ++j)
  ------------------
  |  |  236|  50.1k|#define p 761
  ------------------
                    for (j = i - p + 1; j < p; ++j)
  ------------------
  |  |  236|  19.1M|#define p 761
  ------------------
  |  Branch (569:27): [True: 19.0M, False: 50.1k]
  ------------------
  570|  19.0M|	result = Fq_freeze (result + f[j] * (int32_t) g[i - j]);
  571|  50.1k|      fg[i] = result;
  572|  50.1k|    }
  573|       |
  574|  50.2k|  for (i = p + p - 2; i >= p; --i)
  ------------------
  |  |  236|     66|#define p 761
  ------------------
                for (i = p + p - 2; i >= p; --i)
  ------------------
  |  |  236|     66|#define p 761
  ------------------
                for (i = p + p - 2; i >= p; --i)
  ------------------
  |  |  236|  50.2k|#define p 761
  ------------------
  |  Branch (574:23): [True: 50.1k, False: 66]
  ------------------
  575|  50.1k|    {
  576|  50.1k|      fg[i - p] = Fq_freeze (fg[i - p] + fg[i]);
  ------------------
  |  |  236|  50.1k|#define p 761
  ------------------
                    fg[i - p] = Fq_freeze (fg[i - p] + fg[i]);
  ------------------
  |  |  236|  50.1k|#define p 761
  ------------------
  577|  50.1k|      fg[i - p + 1] = Fq_freeze (fg[i - p + 1] + fg[i]);
  ------------------
  |  |  236|  50.1k|#define p 761
  ------------------
                    fg[i - p + 1] = Fq_freeze (fg[i - p + 1] + fg[i]);
  ------------------
  |  |  236|  50.1k|#define p 761
  ------------------
  578|  50.1k|    }
  579|       |
  580|  50.2k|  for (i = 0; i < p; ++i)
  ------------------
  |  |  236|  50.2k|#define p 761
  ------------------
  |  Branch (580:15): [True: 50.2k, False: 66]
  ------------------
  581|  50.2k|    h[i] = fg[i];
  582|     66|}
sntrup761.c:Rq_encode:
  846|     66|{
  847|     66|  uint16_t R[p], M[p];
  848|     66|  int i;
  849|       |
  850|  50.2k|  for (i = 0; i < p; ++i)
  ------------------
  |  |  236|  50.2k|#define p 761
  ------------------
  |  Branch (850:15): [True: 50.2k, False: 66]
  ------------------
  851|  50.2k|    R[i] = r[i] + q12;
  ------------------
  |  |  406|  50.2k|#define q12 ((q-1)/2)
  |  |  ------------------
  |  |  |  |  237|  50.2k|#define q 4591
  |  |  ------------------
  ------------------
  852|  50.2k|  for (i = 0; i < p; ++i)
  ------------------
  |  |  236|  50.2k|#define p 761
  ------------------
  |  Branch (852:15): [True: 50.2k, False: 66]
  ------------------
  853|  50.2k|    M[i] = q;
  ------------------
  |  |  237|  50.2k|#define q 4591
  ------------------
  854|     66|  Encode (s, R, M, p);
  ------------------
  |  |  236|     66|#define p 761
  ------------------
  855|     66|}
sntrup761.c:Encode:
  324|    726|{
  325|    726|  if (len == 1)
  ------------------
  |  Branch (325:7): [True: 66, False: 660]
  ------------------
  326|     66|    {
  327|     66|      uint16_t r = R[0];
  328|     66|      uint16_t m = M[0];
  329|    198|      while (m > 1)
  ------------------
  |  Branch (329:14): [True: 132, False: 66]
  ------------------
  330|    132|	{
  331|    132|	  *out++ = r;
  332|    132|	  r >>= 8;
  333|    132|	  m = (m + 255) >> 8;
  334|    132|	}
  335|     66|    }
  336|    726|  if (len > 1)
  ------------------
  |  Branch (336:7): [True: 660, False: 66]
  ------------------
  337|    660|    {
  338|    660|      uint16_t R2[(MAX_LEN + 1) / 2];
  339|    660|      uint16_t M2[(MAX_LEN + 1) / 2];
  340|    660|      long long i;
  341|  50.8k|      for (i = 0; i < len - 1; i += 2)
  ------------------
  |  Branch (341:19): [True: 50.1k, False: 660]
  ------------------
  342|  50.1k|	{
  343|  50.1k|	  uint32_t m0 = M[i];
  344|  50.1k|	  uint32_t r = R[i] + R[i + 1] * m0;
  345|  50.1k|	  uint32_t m = M[i + 1] * m0;
  346|   126k|	  while (m >= 16384)
  ------------------
  |  Branch (346:11): [True: 76.2k, False: 50.1k]
  ------------------
  347|  76.2k|	    {
  348|  76.2k|	      *out++ = r;
  349|  76.2k|	      r >>= 8;
  350|  76.2k|	      m = (m + 255) >> 8;
  351|  76.2k|	    }
  352|  50.1k|	  R2[i / 2] = r;
  353|  50.1k|	  M2[i / 2] = m;
  354|  50.1k|	}
  355|    660|      if (i < len)
  ------------------
  |  Branch (355:11): [True: 264, False: 396]
  ------------------
  356|    264|	{
  357|    264|	  R2[i / 2] = R[i];
  358|    264|	  M2[i / 2] = M[i];
  359|    264|	}
  360|    660|      Encode (out, R2, M2, (len + 1) / 2);
  361|    660|    }
  362|    726|}
sntrup761.c:Small_encode:
  805|    132|{
  806|    132|  small x;
  807|    132|  int i;
  808|       |
  809|  25.2k|  for (i = 0; i < p / 4; ++i)
  ------------------
  |  |  236|  25.2k|#define p 761
  ------------------
  |  Branch (809:15): [True: 25.0k, False: 132]
  ------------------
  810|  25.0k|    {
  811|  25.0k|      x = *f++ + 1;
  812|  25.0k|      x += (*f++ + 1) << 2;
  813|  25.0k|      x += (*f++ + 1) << 4;
  814|  25.0k|      x += (*f++ + 1) << 6;
  815|  25.0k|      *s++ = x;
  816|  25.0k|    }
  817|    132|  x = *f++ + 1;
  818|    132|  *s++ = x;
  819|    132|}
sntrup761.c:Hash_prefix:
  693|     66|{
  694|     66|#define MAX_X_LEN 1158
  695|     66|  unsigned char x[MAX_X_LEN + 1];
  696|     66|  unsigned char h[64];
  697|     66|  int i;
  698|       |
  699|     66|  x[0] = b;
  700|  76.4k|  for (i = 0; i < inlen; ++i)
  ------------------
  |  Branch (700:15): [True: 76.4k, False: 66]
  ------------------
  701|  76.4k|    x[i + 1] = in[i];
  702|     66|  sha512 (x, inlen + 1, h);
  703|  2.17k|  for (i = 0; i < 32; ++i)
  ------------------
  |  Branch (703:15): [True: 2.11k, False: 66]
  ------------------
  704|  2.11k|    out[i] = h[i];
  705|     66|}
sntrup761.c:Short_random:
  725|     66|{
  726|     66|  uint32_t L[p];
  727|     66|  int i;
  728|       |
  729|  50.2k|  for (i = 0; i < p; ++i)
  ------------------
  |  |  236|  50.2k|#define p 761
  ------------------
  |  Branch (729:15): [True: 50.2k, False: 66]
  ------------------
  730|  50.2k|    L[i] = urandom32 (random_ctx, random);
  731|     66|  Short_fromlist (out, L);
  732|     66|}
sntrup761.c:Short_fromlist:
  673|     66|{
  674|     66|  uint32_t L[p];
  675|     66|  int i;
  676|       |
  677|  18.9k|  for (i = 0; i < w; ++i)
  ------------------
  |  |  240|  18.9k|#define w 286
  ------------------
  |  Branch (677:15): [True: 18.8k, False: 66]
  ------------------
  678|  18.8k|    L[i] = in[i] & (uint32_t) - 2;
  679|  31.4k|  for (i = w; i < p; ++i)
  ------------------
  |  |  240|     66|#define w 286
  ------------------
                for (i = w; i < p; ++i)
  ------------------
  |  |  236|  31.4k|#define p 761
  ------------------
  |  Branch (679:15): [True: 31.3k, False: 66]
  ------------------
  680|  31.3k|    L[i] = (in[i] & (uint32_t) - 3) | 1;
  681|     66|  crypto_sort_uint32 (L, p);
  ------------------
  |  |  236|     66|#define p 761
  ------------------
  682|  50.2k|  for (i = 0; i < p; ++i)
  ------------------
  |  |  236|  50.2k|#define p 761
  ------------------
  |  Branch (682:15): [True: 50.2k, False: 66]
  ------------------
  683|  50.2k|    out[i] = (L[i] & 3) - 1;
  684|     66|}
sntrup761.c:crypto_sort_uint32:
  126|     66|{
  127|     66|  uint32_t *x = array;
  128|     66|  long long j;
  129|  50.2k|  for (j = 0; j < n; ++j)
  ------------------
  |  Branch (129:15): [True: 50.2k, False: 66]
  ------------------
  130|  50.2k|    x[j] ^= 0x80000000;
  131|     66|  crypto_sort_int32 (array, n);
  132|  50.2k|  for (j = 0; j < n; ++j)
  ------------------
  |  Branch (132:15): [True: 50.2k, False: 66]
  ------------------
  133|  50.2k|    x[j] ^= 0x80000000;
  134|     66|}
sntrup761.c:crypto_sort_int32:
   49|     66|{
   50|     66|  long long top, p, q, r, i, j;
   51|     66|  int32_t *x = array;
   52|       |
   53|     66|  if (n < 2)
  ------------------
  |  Branch (53:7): [True: 0, False: 66]
  ------------------
   54|      0|    return;
   55|     66|  top = 1;
   56|    660|  while (top < n - top)
  ------------------
  |  Branch (56:10): [True: 594, False: 66]
  ------------------
   57|    594|    top += top;
   58|       |
   59|    726|  for (p = top; p >= 1; p >>= 1)
  ------------------
  |  Branch (59:17): [True: 660, False: 66]
  ------------------
   60|    660|    {
   61|    660|      i = 0;
   62|  50.4k|      while (i + 2 * p <= n)
  ------------------
  |  Branch (62:14): [True: 49.7k, False: 660]
  ------------------
   63|  49.7k|	{
   64|   252k|	  for (j = i; j < i + p; ++j)
  ------------------
  |  Branch (64:16): [True: 202k, False: 49.7k]
  ------------------
   65|   202k|	    int32_MINMAX (x[j], x[j + p]);
  ------------------
  |  |   35|   202k|#define int32_MINMAX(a,b) \
  |  |   36|   202k|do { \
  |  |   37|   202k|  int64_t ab = (int64_t)b ^ (int64_t)a; \
  |  |   38|   202k|  int64_t c = (int64_t)b - (int64_t)a; \
  |  |   39|   202k|  c ^= ab & (c ^ b); \
  |  |   40|   202k|  c >>= 31; \
  |  |   41|   202k|  c &= ab; \
  |  |   42|   202k|  a ^= c; \
  |  |   43|   202k|  b ^= c; \
  |  |   44|   202k|} while(0)
  |  |  ------------------
  |  |  |  Branch (44:9): [Folded, False: 202k]
  |  |  ------------------
  ------------------
   66|  49.7k|	  i += 2 * p;
   67|  49.7k|	}
   68|  31.1k|      for (j = i; j < n - p; ++j)
  ------------------
  |  Branch (68:19): [True: 30.4k, False: 660]
  ------------------
   69|  30.4k|	int32_MINMAX (x[j], x[j + p]);
  ------------------
  |  |   35|  30.4k|#define int32_MINMAX(a,b) \
  |  |   36|  30.4k|do { \
  |  |   37|  30.4k|  int64_t ab = (int64_t)b ^ (int64_t)a; \
  |  |   38|  30.4k|  int64_t c = (int64_t)b - (int64_t)a; \
  |  |   39|  30.4k|  c ^= ab & (c ^ b); \
  |  |   40|  30.4k|  c >>= 31; \
  |  |   41|  30.4k|  c &= ab; \
  |  |   42|  30.4k|  a ^= c; \
  |  |   43|  30.4k|  b ^= c; \
  |  |   44|  30.4k|} while(0)
  |  |  ------------------
  |  |  |  Branch (44:9): [Folded, False: 30.4k]
  |  |  ------------------
  ------------------
   70|       |
   71|    660|      i = 0;
   72|    660|      j = 0;
   73|  3.63k|      for (q = top; q > p; q >>= 1)
  ------------------
  |  Branch (73:21): [True: 2.97k, False: 660]
  ------------------
   74|  2.97k|	{
   75|  2.97k|	  if (j != i)
  ------------------
  |  Branch (75:8): [True: 858, False: 2.11k]
  ------------------
   76|    858|	    for (;;)
   77|  1.65k|	      {
   78|  1.65k|		int32_t a;
   79|  1.65k|		if (j == n - q)
  ------------------
  |  Branch (79:7): [True: 0, False: 1.65k]
  ------------------
   80|      0|		  goto done;
   81|  1.65k|		a = x[j + p];
   82|  7.65k|		for (r = q; r > p; r >>= 1)
  ------------------
  |  Branch (82:15): [True: 6.00k, False: 1.65k]
  ------------------
   83|  6.00k|		  int32_MINMAX (a, x[j + r]);
  ------------------
  |  |   35|  7.65k|#define int32_MINMAX(a,b) \
  |  |   36|  7.65k|do { \
  |  |   37|  6.00k|  int64_t ab = (int64_t)b ^ (int64_t)a; \
  |  |   38|  6.00k|  int64_t c = (int64_t)b - (int64_t)a; \
  |  |   39|  6.00k|  c ^= ab & (c ^ b); \
  |  |   40|  6.00k|  c >>= 31; \
  |  |   41|  6.00k|  c &= ab; \
  |  |   42|  6.00k|  a ^= c; \
  |  |   43|  6.00k|  b ^= c; \
  |  |   44|  6.00k|} while(0)
  |  |  ------------------
  |  |  |  Branch (44:9): [Folded, False: 6.00k]
  |  |  ------------------
  ------------------
   84|  1.65k|		x[j + p] = a;
   85|  1.65k|		++j;
   86|  1.65k|		if (j == i + p)
  ------------------
  |  Branch (86:7): [True: 858, False: 792]
  ------------------
   87|    858|		  {
   88|    858|		    i += 2 * p;
   89|    858|		    break;
   90|    858|		  }
   91|  1.65k|	      }
   92|  51.6k|	  while (i + p <= n - q)
  ------------------
  |  Branch (92:11): [True: 48.7k, False: 2.97k]
  ------------------
   93|  48.7k|	    {
   94|   231k|	      for (j = i; j < i + p; ++j)
  ------------------
  |  Branch (94:20): [True: 182k, False: 48.7k]
  ------------------
   95|   182k|		{
   96|   182k|		  int32_t a = x[j + p];
   97|  1.02M|		  for (r = q; r > p; r >>= 1)
  ------------------
  |  Branch (97:17): [True: 846k, False: 182k]
  ------------------
   98|   846k|		    int32_MINMAX (a, x[j + r]);
  ------------------
  |  |   35|   846k|#define int32_MINMAX(a,b) \
  |  |   36|   846k|do { \
  |  |   37|   846k|  int64_t ab = (int64_t)b ^ (int64_t)a; \
  |  |   38|   846k|  int64_t c = (int64_t)b - (int64_t)a; \
  |  |   39|   846k|  c ^= ab & (c ^ b); \
  |  |   40|   846k|  c >>= 31; \
  |  |   41|   846k|  c &= ab; \
  |  |   42|   846k|  a ^= c; \
  |  |   43|   846k|  b ^= c; \
  |  |   44|   846k|} while(0)
  |  |  ------------------
  |  |  |  Branch (44:9): [Folded, False: 846k]
  |  |  ------------------
  ------------------
   99|   182k|		  x[j + p] = a;
  100|   182k|		}
  101|  48.7k|	      i += 2 * p;
  102|  48.7k|	    }
  103|       |	  /* now i + p > n - q */
  104|  2.97k|	  j = i;
  105|  20.3k|	  while (j < n - q)
  ------------------
  |  Branch (105:11): [True: 17.4k, False: 2.97k]
  ------------------
  106|  17.4k|	    {
  107|  17.4k|	      int32_t a = x[j + p];
  108|  38.0k|	      for (r = q; r > p; r >>= 1)
  ------------------
  |  Branch (108:20): [True: 20.6k, False: 17.4k]
  ------------------
  109|  20.6k|		int32_MINMAX (a, x[j + r]);
  ------------------
  |  |   35|  20.6k|#define int32_MINMAX(a,b) \
  |  |   36|  20.6k|do { \
  |  |   37|  20.6k|  int64_t ab = (int64_t)b ^ (int64_t)a; \
  |  |   38|  20.6k|  int64_t c = (int64_t)b - (int64_t)a; \
  |  |   39|  20.6k|  c ^= ab & (c ^ b); \
  |  |   40|  20.6k|  c >>= 31; \
  |  |   41|  20.6k|  c &= ab; \
  |  |   42|  20.6k|  a ^= c; \
  |  |   43|  20.6k|  b ^= c; \
  |  |   44|  20.6k|} while(0)
  |  |  ------------------
  |  |  |  Branch (44:9): [Folded, False: 20.6k]
  |  |  ------------------
  ------------------
  110|  17.4k|	      x[j + p] = a;
  111|  17.4k|	      ++j;
  112|  17.4k|	    }
  113|       |
  114|  2.97k|	done:;
  115|  2.97k|	}
  116|    660|    }
  117|     66|}

ssh_get_random:
   48|   102k|{
   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|   102k|    (void)strong;
   56|   102k|#endif /* HAVE_RAND_PRIV_BYTES */
   57|       |
   58|       |    /* Returns -1 when not supported, 0 on error, 1 on success */
   59|   102k|    return !!RAND_bytes(where, len);
   60|   102k|}

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

ssh_client_hybrid_mlkem_init:
  201|     49|{
  202|     49|    struct ssh_crypto_struct *crypto = session->next_crypto;
  203|     49|    ssh_buffer client_init_buffer = NULL;
  204|     49|    int rc, ret = SSH_ERROR;
  ------------------
  |  |  316|     49|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  205|       |
  206|     49|    SSH_LOG(SSH_LOG_TRACE, "Initializing hybrid ML-KEM key exchange");
  ------------------
  |  |  283|     49|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  207|       |
  208|       |    /* Prepare a buffer to concatenate ML-KEM + ECDH public keys */
  209|     49|    client_init_buffer = ssh_buffer_new();
  210|     49|    if (client_init_buffer == NULL) {
  ------------------
  |  Branch (210:9): [True: 0, False: 49]
  ------------------
  211|      0|        ssh_set_error_oom(session);
  ------------------
  |  |  320|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
  212|      0|        goto cleanup;
  213|      0|    }
  214|       |
  215|       |    /* Generate an ML-KEM keypair */
  216|     49|    rc = ssh_mlkem_init(session);
  217|     49|    if (rc != SSH_OK) {
  ------------------
  |  |  315|     49|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (217:9): [True: 0, False: 49]
  ------------------
  218|      0|        ssh_set_error(session, SSH_FATAL, "Failed to generate an ML-KEM keypair");
  ------------------
  |  |  313|      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|     49|    switch (crypto->kex_type) {
  230|      0|    case SSH_KEX_MLKEM768X25519_SHA256:
  ------------------
  |  Branch (230:5): [True: 0, False: 49]
  ------------------
  231|      0|        rc = ssh_curve25519_init(session);
  232|      0|        if (rc != SSH_OK) {
  ------------------
  |  |  315|      0|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (232:13): [True: 0, False: 0]
  ------------------
  233|      0|            ssh_set_error(session,
  ------------------
  |  |  313|      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|      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)
  |  |  ------------------
  |  |  |  |  453|      0|        (__VA_NARG_(__VA_ARGS__, __RSEQ_N()))
  |  |  |  |  ------------------
  |  |  |  |  |  |  455|      0|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  450|      0|#define VA_APPLY_VARIADIC_MACRO(macro, tuple) macro tuple
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  455|      0|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  463|      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)
  |  |  ------------------
  ------------------
  244|      0|                             "PP",
  245|      0|                             ssh_string_len(crypto->mlkem_client_pubkey),
  246|      0|                             ssh_string_data(crypto->mlkem_client_pubkey),
  247|      0|                             (size_t)CURVE25519_PUBKEY_SIZE,
  248|      0|                             crypto->curve25519_client_pubkey);
  249|      0|        break;
  250|     49|    case SSH_KEX_MLKEM768NISTP256_SHA256:
  ------------------
  |  Branch (250:5): [True: 49, False: 0]
  ------------------
  251|       |#ifdef HAVE_MLKEM1024
  252|       |    case SSH_KEX_MLKEM1024NISTP384_SHA384:
  253|       |#endif
  254|     49|        rc = ssh_ecdh_init(session);
  255|     49|        if (rc != SSH_OK) {
  ------------------
  |  |  315|     49|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (255:13): [True: 0, False: 49]
  ------------------
  256|      0|            ssh_set_error(session,
  ------------------
  |  |  313|      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|     49|        rc = ssh_buffer_pack(client_init_buffer,
  ------------------
  |  |   50|     49|    _ssh_buffer_pack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |  453|     49|        (__VA_NARG_(__VA_ARGS__, __RSEQ_N()))
  |  |  |  |  ------------------
  |  |  |  |  |  |  455|     49|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  450|     49|#define VA_APPLY_VARIADIC_MACRO(macro, tuple) macro tuple
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  455|     49|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  463|     49|        _61,_62,_63,N,...) N
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                   _ssh_buffer_pack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |   28|     49|#define SSH_BUFFER_PACK_END ((uint32_t) 0x4f65feb3)
  |  |  ------------------
  ------------------
  267|     49|                             "PP",
  268|     49|                             ssh_string_len(crypto->mlkem_client_pubkey),
  269|     49|                             ssh_string_data(crypto->mlkem_client_pubkey),
  270|     49|                             ssh_string_len(crypto->ecdh_client_pubkey),
  271|     49|                             ssh_string_data(crypto->ecdh_client_pubkey));
  272|       |
  273|     49|        break;
  274|      0|    default:
  ------------------
  |  Branch (274:5): [True: 0, False: 49]
  ------------------
  275|      0|        ssh_set_error(session, SSH_FATAL, "Unsupported KEX type");
  ------------------
  |  |  313|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  276|      0|        goto cleanup;
  277|     49|    }
  278|     49|    if (rc != SSH_OK) {
  ------------------
  |  |  315|     49|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (278:9): [True: 0, False: 49]
  ------------------
  279|      0|        ssh_set_error(session, SSH_FATAL, "Failed to construct client init buffer");
  ------------------
  |  |  313|      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|     49|    ssh_string_free(crypto->hybrid_client_init);
  285|     49|    crypto->hybrid_client_init = ssh_string_new(ssh_buffer_get_len(client_init_buffer));
  286|     49|    if (crypto->hybrid_client_init == NULL) {
  ------------------
  |  Branch (286:9): [True: 0, False: 49]
  ------------------
  287|      0|        ssh_set_error_oom(session);
  ------------------
  |  |  320|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
  288|      0|        goto cleanup;
  289|      0|    }
  290|       |
  291|     49|    rc = ssh_string_fill(crypto->hybrid_client_init,
  292|     49|                         ssh_buffer_get(client_init_buffer),
  293|     49|                         ssh_buffer_get_len(client_init_buffer));
  294|     49|    if (rc != SSH_OK) {
  ------------------
  |  |  315|     49|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (294:9): [True: 0, False: 49]
  ------------------
  295|      0|        ssh_set_error(session, SSH_FATAL, "Failed to convert client init to string");
  ------------------
  |  |  313|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  296|      0|        goto cleanup;
  297|      0|    }
  298|       |
  299|     49|    rc = ssh_buffer_pack(session->out_buffer,
  ------------------
  |  |   50|     49|    _ssh_buffer_pack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |  453|     49|        (__VA_NARG_(__VA_ARGS__, __RSEQ_N()))
  |  |  |  |  ------------------
  |  |  |  |  |  |  455|     49|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  450|     49|#define VA_APPLY_VARIADIC_MACRO(macro, tuple) macro tuple
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  455|     49|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  463|     49|        _61,_62,_63,N,...) N
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                   _ssh_buffer_pack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |   28|     49|#define SSH_BUFFER_PACK_END ((uint32_t) 0x4f65feb3)
  |  |  ------------------
  ------------------
  300|     49|                         "bS",
  301|     49|                         SSH2_MSG_KEX_HYBRID_INIT,
  302|     49|                         crypto->hybrid_client_init);
  303|     49|    if (rc != SSH_OK) {
  ------------------
  |  |  315|     49|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (303:9): [True: 0, False: 49]
  ------------------
  304|      0|        ssh_set_error(session, SSH_FATAL, "Failed to construct SSH_MSG_KEX_HYBRID_INIT");
  ------------------
  |  |  313|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  305|      0|        goto cleanup;
  306|      0|    }
  307|       |
  308|     49|    ssh_packet_set_callbacks(session, &ssh_hybrid_mlkem_client_callbacks);
  309|     49|    session->dh_handshake_state = DH_STATE_INIT_SENT;
  310|       |
  311|     49|    rc = ssh_packet_send(session);
  312|     49|    if (rc != SSH_OK) {
  ------------------
  |  |  315|     49|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (312:9): [True: 0, False: 49]
  ------------------
  313|      0|        ssh_set_error(session, SSH_FATAL, "Failed to send SSH_MSG_KEX_HYBRID_INIT");
  ------------------
  |  |  313|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  314|      0|        goto cleanup;
  315|      0|    }
  316|       |
  317|     49|    ret = SSH_OK;
  ------------------
  |  |  315|     49|#define SSH_OK 0     /* No error */
  ------------------
  318|       |
  319|     49|cleanup:
  320|     49|    ssh_buffer_free(client_init_buffer);
  321|     49|    return ret;
  322|     49|}
ssh_client_hybrid_mlkem_remove_callbacks:
  531|      6|{
  532|      6|    ssh_packet_remove_callbacks(session, &ssh_hybrid_mlkem_client_callbacks);
  533|      6|}
hybrid_mlkem.c:ssh_packet_client_hybrid_mlkem_reply:
  325|      6|{
  326|      6|    struct ssh_crypto_struct *crypto = session->next_crypto;
  327|      6|    const struct mlkem_type_info *mlkem_info = NULL;
  328|      6|    ssh_string pubkey_blob = NULL;
  329|      6|    ssh_string signature = NULL;
  330|      6|    ssh_mlkem_shared_secret mlkem_shared_secret;
  331|      6|    ssh_string ecdh_shared_secret = NULL;
  332|      6|    ssh_buffer server_reply_buffer = NULL;
  333|      6|    size_t read_len;
  334|      6|    size_t ecdh_server_pubkey_size;
  335|      6|    int rc;
  336|      6|    (void)type;
  337|      6|    (void)user;
  338|       |
  339|      6|    SSH_LOG(SSH_LOG_TRACE, "Received ML-KEM hybrid server reply");
  ------------------
  |  |  283|      6|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  340|       |
  341|      6|    ssh_client_hybrid_mlkem_remove_callbacks(session);
  342|       |
  343|      6|    mlkem_info = kex_type_to_mlkem_info(crypto->kex_type);
  344|      6|    if (mlkem_info == NULL) {
  ------------------
  |  Branch (344:9): [True: 0, False: 6]
  ------------------
  345|      0|        ssh_set_error(session, SSH_FATAL, "Unknown ML-KEM type");
  ------------------
  |  |  313|      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|      6|    pubkey_blob = ssh_buffer_get_ssh_string(packet);
  351|      6|    if (pubkey_blob == NULL) {
  ------------------
  |  Branch (351:9): [True: 0, False: 6]
  ------------------
  352|      0|        ssh_set_error(session, SSH_FATAL, "No public key in packet");
  ------------------
  |  |  313|      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|      6|    rc = ssh_dh_import_next_pubkey_blob(session, pubkey_blob);
  358|      6|    if (rc != SSH_OK) {
  ------------------
  |  |  315|      6|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (358:9): [True: 6, False: 0]
  ------------------
  359|      6|        ssh_set_error(session, SSH_FATAL, "Failed to import public key");
  ------------------
  |  |  313|      6|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  360|      6|        session->session_state = SSH_SESSION_STATE_ERROR;
  361|      6|        goto cleanup;
  362|      6|    }
  363|       |
  364|       |    /* Get server reply containing ML-KEM ciphertext + ECDH public key */
  365|      0|    ssh_string_free(crypto->hybrid_server_reply);
  366|      0|    crypto->hybrid_server_reply = ssh_buffer_get_ssh_string(packet);
  367|      0|    if (crypto->hybrid_server_reply == NULL) {
  ------------------
  |  Branch (367:9): [True: 0, False: 0]
  ------------------
  368|      0|        ssh_set_error(session, SSH_FATAL, "No server reply in packet");
  ------------------
  |  |  313|      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|      0|    server_reply_buffer = ssh_buffer_new();
  374|      0|    if (server_reply_buffer == NULL) {
  ------------------
  |  Branch (374:9): [True: 0, False: 0]
  ------------------
  375|      0|        ssh_set_error_oom(session);
  ------------------
  |  |  320|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
  376|      0|        session->session_state = SSH_SESSION_STATE_ERROR;
  377|      0|        goto cleanup;
  378|      0|    }
  379|       |
  380|      0|    rc = ssh_buffer_add_data(server_reply_buffer,
  381|      0|                             ssh_string_data(crypto->hybrid_server_reply),
  382|      0|                             ssh_string_len(crypto->hybrid_server_reply));
  383|      0|    if (rc != SSH_OK) {
  ------------------
  |  |  315|      0|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (383:9): [True: 0, False: 0]
  ------------------
  384|      0|        ssh_set_error(session, SSH_FATAL, "Failed to pack server reply to a buffer");
  ------------------
  |  |  313|      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|      0|    ssh_string_free(crypto->mlkem_ciphertext);
  391|      0|    crypto->mlkem_ciphertext = ssh_string_new(mlkem_info->ciphertext_size);
  392|      0|    if (crypto->mlkem_ciphertext == NULL) {
  ------------------
  |  Branch (392:9): [True: 0, False: 0]
  ------------------
  393|      0|        ssh_set_error_oom(session);
  ------------------
  |  |  320|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
  394|      0|        session->session_state = SSH_SESSION_STATE_ERROR;
  395|      0|        goto cleanup;
  396|      0|    }
  397|       |
  398|      0|    read_len = ssh_buffer_get_data(server_reply_buffer,
  399|      0|                                   ssh_string_data(crypto->mlkem_ciphertext),
  400|      0|                                   mlkem_info->ciphertext_size);
  401|      0|    if (read_len != mlkem_info->ciphertext_size) {
  ------------------
  |  Branch (401:9): [True: 0, False: 0]
  ------------------
  402|      0|        ssh_set_error(session,
  ------------------
  |  |  313|      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|      0|    switch (crypto->kex_type) {
  418|      0|    case SSH_KEX_MLKEM768X25519_SHA256:
  ------------------
  |  Branch (418:5): [True: 0, False: 0]
  ------------------
  419|      0|        read_len = ssh_buffer_get_data(server_reply_buffer,
  420|      0|                                       crypto->curve25519_server_pubkey,
  421|      0|                                       CURVE25519_PUBKEY_SIZE);
  ------------------
  |  |   41|      0|#define CURVE25519_PUBKEY_SIZE 32
  ------------------
  422|      0|        if (read_len != CURVE25519_PUBKEY_SIZE) {
  ------------------
  |  |   41|      0|#define CURVE25519_PUBKEY_SIZE 32
  ------------------
  |  Branch (422:13): [True: 0, False: 0]
  ------------------
  423|      0|            ssh_set_error(session,
  ------------------
  |  |  313|      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|      0|        if (ssh_buffer_get_len(server_reply_buffer) > 0) {
  ------------------
  |  Branch (430:13): [True: 0, False: 0]
  ------------------
  431|      0|            ssh_set_error(session,
  ------------------
  |  |  313|      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|      0|        break;
  443|      0|    case SSH_KEX_MLKEM768NISTP256_SHA256:
  ------------------
  |  Branch (443:5): [True: 0, False: 0]
  ------------------
  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);
  ------------------
  |  |  320|      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: 0]
  ------------------
  465|      0|        ssh_set_error(session, SSH_FATAL, "Unsupported KEX type");
  ------------------
  |  |  313|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  466|      0|        goto cleanup;
  467|      0|    }
  468|       |
  469|       |    /* Decapsulate ML-KEM shared secret */
  470|      0|    rc = ssh_mlkem_decapsulate(session, mlkem_shared_secret);
  471|      0|    if (rc != SSH_OK) {
  ------------------
  |  |  315|      0|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (471:9): [True: 0, False: 0]
  ------------------
  472|      0|        ssh_set_error(session, SSH_FATAL, "ML-KEM decapsulation failed");
  ------------------
  |  |  313|      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|      0|    ecdh_shared_secret = derive_ecdh_secret(session);
  485|      0|    if (ecdh_shared_secret == NULL) {
  ------------------
  |  Branch (485:9): [True: 0, False: 0]
  ------------------
  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|      0|    rc = derive_hybrid_secret(session, mlkem_shared_secret, ecdh_shared_secret);
  498|      0|    if (rc != SSH_OK) {
  ------------------
  |  |  315|      0|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (498:9): [True: 0, False: 0]
  ------------------
  499|      0|        session->session_state = SSH_SESSION_STATE_ERROR;
  500|      0|        goto cleanup;
  501|      0|    }
  502|       |
  503|       |    /* Get signature for verification */
  504|      0|    signature = ssh_buffer_get_ssh_string(packet);
  505|      0|    if (signature == NULL) {
  ------------------
  |  Branch (505:9): [True: 0, False: 0]
  ------------------
  506|      0|        ssh_set_error(session, SSH_FATAL, "No signature in packet");
  ------------------
  |  |  313|      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|      0|    crypto->dh_server_signature = signature;
  511|       |
  512|       |    /* Send the MSG_NEWKEYS */
  513|      0|    rc = ssh_packet_send_newkeys(session);
  514|      0|    if (rc != SSH_OK) {
  ------------------
  |  |  315|      0|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (514:9): [True: 0, False: 0]
  ------------------
  515|      0|        ssh_set_error(session, SSH_FATAL, "Failed to send SSH_MSG_NEWKEYS");
  ------------------
  |  |  313|      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|      0|    session->dh_handshake_state = DH_STATE_NEWKEYS_SENT;
  520|       |
  521|      6|cleanup:
  522|      6|    ssh_burn(mlkem_shared_secret, sizeof(mlkem_shared_secret));
  ------------------
  |  |  390|      6|#define ssh_burn(ptr, len) explicit_bzero((ptr), (len))
  ------------------
  523|      6|    ssh_string_burn(ecdh_shared_secret);
  524|      6|    ssh_string_free(ecdh_shared_secret);
  525|      6|    ssh_string_free(pubkey_blob);
  526|      6|    ssh_buffer_free(server_reply_buffer);
  527|      6|    return SSH_PACKET_USED;
  ------------------
  |  |  638|      6|#define SSH_PACKET_USED 1
  ------------------
  528|      0|}

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:
  285|    473|bool is_ssh_initialized(void) {
  286|       |
  287|    473|    bool is_initialized = false;
  288|       |
  289|    473|    ssh_mutex_lock(&ssh_init_mutex);
  290|    473|    is_initialized = _ssh_initialized > 0 && _ssh_init_ret == 0;
  ------------------
  |  Branch (290:22): [True: 473, False: 0]
  |  Branch (290:46): [True: 473, False: 0]
  ------------------
  291|    473|    ssh_mutex_unlock(&ssh_init_mutex);
  292|       |
  293|    473|    return is_initialized;
  294|    473|}
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|    168|{
  159|       |    /* Can't use VLAs with Visual Studio, so allocate the biggest
  160|       |     * digest buffer we can possibly need */
  161|    168|    unsigned char digest[DIGEST_MAX_LEN];
  162|    168|    size_t output_len = crypto->digest_len;
  163|    168|    ssh_mac_ctx ctx;
  164|    168|    int rc;
  165|       |
  166|    168|    if (DIGEST_MAX_LEN < crypto->digest_len) {
  ------------------
  |  |   56|    168|#define DIGEST_MAX_LEN 64
  ------------------
  |  Branch (166:9): [True: 0, False: 168]
  ------------------
  167|      0|        return -1;
  168|      0|    }
  169|       |
  170|    168|    ctx = ssh_mac_ctx_init(crypto->digest_type);
  171|    168|    if (ctx == NULL) {
  ------------------
  |  Branch (171:9): [True: 0, False: 168]
  ------------------
  172|      0|        return -1;
  173|      0|    }
  174|       |
  175|    168|    rc = ssh_mac_update(ctx, key, key_len);
  176|    168|    if (rc != SSH_OK) {
  ------------------
  |  |  315|    168|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (176:9): [True: 0, False: 168]
  ------------------
  177|      0|        ssh_mac_ctx_free(ctx);
  178|      0|        return -1;
  179|      0|    }
  180|    168|    rc = ssh_mac_update(ctx, crypto->secret_hash, crypto->digest_len);
  181|    168|    if (rc != SSH_OK) {
  ------------------
  |  |  315|    168|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (181:9): [True: 0, False: 168]
  ------------------
  182|      0|        ssh_mac_ctx_free(ctx);
  183|      0|        return -1;
  184|      0|    }
  185|    168|    rc = ssh_mac_update(ctx, &key_type, 1);
  186|    168|    if (rc != SSH_OK) {
  ------------------
  |  |  315|    168|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (186:9): [True: 0, False: 168]
  ------------------
  187|      0|        ssh_mac_ctx_free(ctx);
  188|      0|        return -1;
  189|      0|    }
  190|    168|    rc = ssh_mac_update(ctx, crypto->session_id, crypto->session_id_len);
  191|    168|    if (rc != SSH_OK) {
  ------------------
  |  |  315|    168|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (191:9): [True: 0, False: 168]
  ------------------
  192|      0|        ssh_mac_ctx_free(ctx);
  193|      0|        return -1;
  194|      0|    }
  195|    168|    rc = ssh_mac_final(digest, ctx);
  196|    168|    if (rc != SSH_OK) {
  ------------------
  |  |  315|    168|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (196:9): [True: 0, False: 168]
  ------------------
  197|      0|        return -1;
  198|      0|    }
  199|       |
  200|    168|    if (requested_len < output_len) {
  ------------------
  |  Branch (200:9): [True: 112, False: 56]
  ------------------
  201|    112|        output_len = requested_len;
  202|    112|    }
  203|    168|    memcpy(output, digest, output_len);
  204|       |
  205|    168|    while (requested_len > output_len) {
  ------------------
  |  Branch (205:12): [True: 0, False: 168]
  ------------------
  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) {
  ------------------
  |  |  315|      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) {
  ------------------
  |  |  315|      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) {
  ------------------
  |  |  315|      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) {
  ------------------
  |  |  315|      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|    168|    return 0;
  238|    168|}
kdf.c:ssh_mac_ctx_init:
   54|    168|{
   55|    168|    ssh_mac_ctx ctx = malloc(sizeof(struct ssh_mac_ctx_struct));
   56|    168|    if (ctx == NULL) {
  ------------------
  |  Branch (56:9): [True: 0, False: 168]
  ------------------
   57|      0|        return NULL;
   58|      0|    }
   59|       |
   60|    168|    ctx->digest_type = type;
   61|    168|    switch (type) {
  ------------------
  |  Branch (61:13): [True: 168, False: 0]
  ------------------
   62|      0|    case SSH_KDF_SHA1:
  ------------------
  |  Branch (62:5): [True: 0, False: 168]
  ------------------
   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|     72|    case SSH_KDF_SHA256:
  ------------------
  |  Branch (68:5): [True: 72, False: 96]
  ------------------
   69|     72|        ctx->ctx.sha256_ctx = sha256_init();
   70|     72|        if (ctx->ctx.sha256_ctx == NULL) {
  ------------------
  |  Branch (70:13): [True: 0, False: 72]
  ------------------
   71|      0|            goto err;
   72|      0|        }
   73|     72|        return ctx;
   74|      0|    case SSH_KDF_SHA384:
  ------------------
  |  Branch (74:5): [True: 0, False: 168]
  ------------------
   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|     96|    case SSH_KDF_SHA512:
  ------------------
  |  Branch (80:5): [True: 96, False: 72]
  ------------------
   81|     96|        ctx->ctx.sha512_ctx = sha512_init();
   82|     96|        if (ctx->ctx.sha512_ctx == NULL) {
  ------------------
  |  Branch (82:13): [True: 0, False: 96]
  ------------------
   83|      0|            goto err;
   84|      0|        }
   85|     96|        return ctx;
   86|    168|    }
   87|      0|err:
   88|      0|    SAFE_FREE(ctx);
  ------------------
  |  |  375|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (375:31): [True: 0, False: 0]
  |  |  |  Branch (375:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
   89|       |    return NULL;
   90|    168|}
kdf.c:ssh_mac_update:
  116|    672|{
  117|    672|    switch (ctx->digest_type) {
  ------------------
  |  Branch (117:13): [True: 672, False: 0]
  ------------------
  118|      0|    case SSH_KDF_SHA1:
  ------------------
  |  Branch (118:5): [True: 0, False: 672]
  ------------------
  119|      0|        return sha1_update(ctx->ctx.sha1_ctx, data, len);
  120|    288|    case SSH_KDF_SHA256:
  ------------------
  |  Branch (120:5): [True: 288, False: 384]
  ------------------
  121|    288|        return sha256_update(ctx->ctx.sha256_ctx, data, len);
  122|      0|    case SSH_KDF_SHA384:
  ------------------
  |  Branch (122:5): [True: 0, False: 672]
  ------------------
  123|      0|        return sha384_update(ctx->ctx.sha384_ctx, data, len);
  124|    384|    case SSH_KDF_SHA512:
  ------------------
  |  Branch (124:5): [True: 384, False: 288]
  ------------------
  125|    384|        return sha512_update(ctx->ctx.sha512_ctx, data, len);
  126|    672|    }
  127|      0|    return SSH_ERROR;
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  128|    672|}
kdf.c:ssh_mac_final:
  131|    168|{
  132|    168|    int rc = SSH_ERROR;
  ------------------
  |  |  316|    168|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  133|       |
  134|    168|    switch (ctx->digest_type) {
  ------------------
  |  Branch (134:13): [True: 168, False: 0]
  ------------------
  135|      0|    case SSH_KDF_SHA1:
  ------------------
  |  Branch (135:5): [True: 0, False: 168]
  ------------------
  136|      0|        rc = sha1_final(md, ctx->ctx.sha1_ctx);
  137|      0|        break;
  138|     72|    case SSH_KDF_SHA256:
  ------------------
  |  Branch (138:5): [True: 72, False: 96]
  ------------------
  139|     72|        rc = sha256_final(md, ctx->ctx.sha256_ctx);
  140|     72|        break;
  141|      0|    case SSH_KDF_SHA384:
  ------------------
  |  Branch (141:5): [True: 0, False: 168]
  ------------------
  142|      0|        rc = sha384_final(md, ctx->ctx.sha384_ctx);
  143|      0|        break;
  144|     96|    case SSH_KDF_SHA512:
  ------------------
  |  Branch (144:5): [True: 96, False: 72]
  ------------------
  145|     96|        rc = sha512_final(md, ctx->ctx.sha512_ctx);
  146|     96|        break;
  147|    168|    }
  148|    168|    SAFE_FREE(ctx);
  ------------------
  |  |  375|    168|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (375:31): [True: 168, False: 0]
  |  |  |  Branch (375:71): [Folded, False: 168]
  |  |  ------------------
  ------------------
  149|    168|    return rc;
  150|    168|}

ssh_kex_get_default_methods:
  300|    412|{
  301|    412|    if (type >= SSH_KEX_METHODS) {
  ------------------
  |  |   27|    412|#define SSH_KEX_METHODS 10
  ------------------
  |  Branch (301:9): [True: 0, False: 412]
  ------------------
  302|      0|        return NULL;
  303|      0|    }
  304|       |
  305|    412|    return default_methods[type];
  306|    412|}
ssh_packet_kexinit:
  397|    263|{
  398|    263|    int i, ok;
  399|    263|    struct ssh_crypto_struct *crypto = session->next_crypto;
  400|    263|    int server_kex = session->server;
  401|    263|    ssh_string str = NULL;
  402|    263|    char *strings[SSH_KEX_METHODS] = {0};
  403|    263|    int rc = SSH_ERROR;
  ------------------
  |  |  316|    263|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  404|    263|    size_t len;
  405|       |
  406|    263|    uint8_t first_kex_packet_follows = 0;
  407|    263|    uint32_t kexinit_reserved = 0;
  408|       |
  409|    263|    (void)type;
  410|    263|    (void)user;
  411|       |
  412|    263|    SSH_LOG(SSH_LOG_TRACE, "KEXINIT received");
  ------------------
  |  |  283|    263|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  413|       |
  414|    263|    if (session->session_state == SSH_SESSION_STATE_AUTHENTICATED) {
  ------------------
  |  Branch (414:9): [True: 0, False: 263]
  ------------------
  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");
  ------------------
  |  |  283|      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.");
  ------------------
  |  |  283|      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,
  ------------------
  |  |  313|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  426|      0|                          "SSH_KEXINIT received in wrong state");
  427|      0|            goto error;
  428|      0|        }
  429|    263|    } else if (session->session_state != SSH_SESSION_STATE_INITIAL_KEX) {
  ------------------
  |  Branch (429:16): [True: 0, False: 263]
  ------------------
  430|      0|        ssh_set_error(session, SSH_FATAL,
  ------------------
  |  |  313|      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|    263|    if (server_kex) {
  ------------------
  |  Branch (435:9): [True: 0, False: 263]
  ------------------
  436|      0|#ifdef WITH_SERVER
  437|      0|        len = ssh_buffer_get_data(packet, crypto->client_kex.cookie, 16);
  438|      0|        if (len != 16) {
  ------------------
  |  Branch (438:13): [True: 0, False: 0]
  ------------------
  439|      0|            ssh_set_error(session, SSH_FATAL,
  ------------------
  |  |  313|      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|      0|        ok = ssh_hashbufin_add_cookie(session, crypto->client_kex.cookie);
  445|      0|        if (ok < 0) {
  ------------------
  |  Branch (445:13): [True: 0, False: 0]
  ------------------
  446|      0|            ssh_set_error(session, SSH_FATAL,
  ------------------
  |  |  313|      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|      0|        ok = server_set_kex(session);
  452|      0|        if (ok == SSH_ERROR) {
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  |  Branch (452:13): [True: 0, False: 0]
  ------------------
  453|      0|            goto error;
  454|      0|        }
  455|      0|#endif /* WITH_SERVER */
  456|    263|    } else {
  457|    263|        len = ssh_buffer_get_data(packet, crypto->server_kex.cookie, 16);
  458|    263|        if (len != 16) {
  ------------------
  |  Branch (458:13): [True: 1, False: 262]
  ------------------
  459|      1|            ssh_set_error(session, SSH_FATAL,
  ------------------
  |  |  313|      1|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  460|      1|                          "ssh_packet_kexinit: no cookie in packet");
  461|      1|            goto error;
  462|      1|        }
  463|       |
  464|    262|        ok = ssh_hashbufin_add_cookie(session, crypto->server_kex.cookie);
  465|    262|        if (ok < 0) {
  ------------------
  |  Branch (465:13): [True: 0, False: 262]
  ------------------
  466|      0|            ssh_set_error(session, SSH_FATAL,
  ------------------
  |  |  313|      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|    262|        ok = ssh_set_client_kex(session);
  472|    262|        if (ok == SSH_ERROR) {
  ------------------
  |  |  316|    262|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  |  Branch (472:13): [True: 0, False: 262]
  ------------------
  473|      0|            goto error;
  474|      0|        }
  475|    262|    }
  476|       |
  477|  2.75k|    for (i = 0; i < SSH_KEX_METHODS; i++) {
  ------------------
  |  |   27|  2.75k|#define SSH_KEX_METHODS 10
  ------------------
  |  Branch (477:17): [True: 2.50k, False: 244]
  ------------------
  478|  2.50k|        str = ssh_buffer_get_ssh_string(packet);
  479|  2.50k|        if (str == NULL) {
  ------------------
  |  Branch (479:13): [True: 18, False: 2.49k]
  ------------------
  480|     18|          goto error;
  481|     18|        }
  482|       |
  483|  2.49k|        rc = ssh_buffer_add_ssh_string(session->in_hashbuf, str);
  484|  2.49k|        if (rc < 0) {
  ------------------
  |  Branch (484:13): [True: 0, False: 2.49k]
  ------------------
  485|      0|            ssh_set_error(session, SSH_FATAL,
  ------------------
  |  |  313|      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|  2.49k|        strings[i] = ssh_string_to_char(str);
  491|  2.49k|        if (strings[i] == NULL) {
  ------------------
  |  Branch (491:13): [True: 0, False: 2.49k]
  ------------------
  492|      0|            ssh_set_error_oom(session);
  ------------------
  |  |  320|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
  493|      0|            goto error;
  494|      0|        }
  495|  2.49k|        SSH_STRING_FREE(str);
  ------------------
  |  |  882|  2.49k|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (882:14): [True: 2.49k, False: 0]
  |  |  |  Branch (882:69): [Folded, False: 2.49k]
  |  |  ------------------
  ------------------
  496|  2.49k|        str = NULL;
  497|  2.49k|    }
  498|       |
  499|       |    /* copy the peer kex info into an array of strings */
  500|    244|    if (server_kex) {
  ------------------
  |  Branch (500:9): [True: 0, False: 244]
  ------------------
  501|      0|#ifdef WITH_SERVER
  502|      0|        for (i = 0; i < SSH_KEX_METHODS; i++) {
  ------------------
  |  |   27|      0|#define SSH_KEX_METHODS 10
  ------------------
  |  Branch (502:21): [True: 0, False: 0]
  ------------------
  503|      0|            crypto->client_kex.methods[i] = strings[i];
  504|      0|        }
  505|      0|#endif /* WITH_SERVER */
  506|    244|    } else { /* client */
  507|  2.68k|        for (i = 0; i < SSH_KEX_METHODS; i++) {
  ------------------
  |  |   27|  2.68k|#define SSH_KEX_METHODS 10
  ------------------
  |  Branch (507:21): [True: 2.44k, False: 244]
  ------------------
  508|  2.44k|            crypto->server_kex.methods[i] = strings[i];
  509|  2.44k|        }
  510|    244|    }
  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|    244|    rc = ssh_buffer_get_u8(packet, &first_kex_packet_follows);
  524|    244|    if (rc != 1) {
  ------------------
  |  Branch (524:9): [True: 0, False: 244]
  ------------------
  525|      0|        goto error;
  526|      0|    }
  527|       |
  528|    244|    rc = ssh_buffer_add_u8(session->in_hashbuf, first_kex_packet_follows);
  529|    244|    if (rc < 0) {
  ------------------
  |  Branch (529:9): [True: 0, False: 244]
  ------------------
  530|      0|        goto error;
  531|      0|    }
  532|       |
  533|    244|    rc = ssh_buffer_add_u32(session->in_hashbuf, kexinit_reserved);
  534|    244|    if (rc < 0) {
  ------------------
  |  Branch (534:9): [True: 0, False: 244]
  ------------------
  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|    244|    if (first_kex_packet_follows || session->send_first_kex_follows) {
  ------------------
  |  Branch (544:9): [True: 154, False: 90]
  |  Branch (544:37): [True: 0, False: 90]
  ------------------
  545|    154|        char **client_methods = crypto->client_kex.methods;
  546|    154|        char **server_methods = crypto->server_kex.methods;
  547|    154|        session->first_kex_follows_guess_wrong =
  548|    154|            cmp_first_kex_algo(client_methods[SSH_KEX],
  ------------------
  |  Branch (548:13): [True: 154, False: 0]
  ------------------
  549|    154|                               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|    154|            SSH_LOG(SSH_LOG_DEBUG, "The initial guess was %s.",
  ------------------
  |  |  283|    308|    _ssh_log(priority, __func__, __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (283:34): [True: 154, False: 0]
  |  |  ------------------
  ------------------
  553|    154|                    session->first_kex_follows_guess_wrong ? "wrong" : "right");
  554|    154|    }
  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|    244|    if (server_kex) {
  ------------------
  |  Branch (560:9): [True: 0, False: 244]
  ------------------
  561|      0|        ok = match_group(crypto->client_kex.methods[SSH_KEX],
  562|      0|                         KEX_STRICT_CLIENT);
  ------------------
  |  |  196|      0|#define KEX_STRICT_CLIENT "kex-strict-c-v00@openssh.com"
  ------------------
  563|      0|        if (ok) {
  ------------------
  |  Branch (563:13): [True: 0, False: 0]
  ------------------
  564|      0|            SSH_LOG(SSH_LOG_DEBUG, "Client supports strict kex, enabling.");
  ------------------
  |  |  283|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  565|      0|            session->flags |= SSH_SESSION_FLAG_KEX_STRICT;
  ------------------
  |  |   90|      0|#define SSH_SESSION_FLAG_KEX_STRICT 0x0010
  ------------------
  566|      0|        }
  567|    244|    } else {
  568|       |        /* client kex */
  569|    244|        ok = match_group(crypto->server_kex.methods[SSH_KEX],
  570|    244|                         KEX_STRICT_SERVER);
  ------------------
  |  |  197|    244|#define KEX_STRICT_SERVER "kex-strict-s-v00@openssh.com"
  ------------------
  571|    244|        if (ok) {
  ------------------
  |  Branch (571:13): [True: 3, False: 241]
  ------------------
  572|      3|            SSH_LOG(SSH_LOG_DEBUG, "Server supports strict kex, enabling.");
  ------------------
  |  |  283|      3|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  573|      3|            session->flags |= SSH_SESSION_FLAG_KEX_STRICT;
  ------------------
  |  |   90|      3|#define SSH_SESSION_FLAG_KEX_STRICT 0x0010
  ------------------
  574|      3|        }
  575|    244|    }
  576|    244|#ifdef WITH_SERVER
  577|    244|    if (server_kex) {
  ------------------
  |  Branch (577:9): [True: 0, False: 244]
  ------------------
  578|       |        /*
  579|       |         * If client sent a ext-info-c message in the kex list, it supports
  580|       |         * RFC 8308 extension negotiation.
  581|       |         */
  582|      0|        ok = match_group(crypto->client_kex.methods[SSH_KEX],
  583|      0|                         KEX_EXTENSION_CLIENT);
  ------------------
  |  |  194|      0|#define KEX_EXTENSION_CLIENT "ext-info-c"
  ------------------
  584|      0|        if (ok) {
  ------------------
  |  Branch (584:13): [True: 0, False: 0]
  ------------------
  585|      0|            const char *hostkeys = NULL, *wanted_hostkeys = NULL;
  586|       |
  587|       |            /* The client supports extension negotiation */
  588|      0|            session->extensions |= SSH_EXT_NEGOTIATION;
  ------------------
  |  |  124|      0|#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|      0|            hostkeys = crypto->client_kex.methods[SSH_HOSTKEYS];
  596|      0|            wanted_hostkeys = session->opts.wanted_methods[SSH_HOSTKEYS];
  597|      0|            ok = match_group(hostkeys, "rsa-sha2-512");
  598|      0|            if (ok) {
  ------------------
  |  Branch (598:17): [True: 0, False: 0]
  ------------------
  599|       |                /* Check if rsa-sha2-512 is allowed by config */
  600|      0|                if (wanted_hostkeys != NULL) {
  ------------------
  |  Branch (600:21): [True: 0, False: 0]
  ------------------
  601|      0|                    char *is_allowed = ssh_find_matching(wanted_hostkeys,
  602|      0|                                                         "rsa-sha2-512");
  603|      0|                    if (is_allowed != NULL) {
  ------------------
  |  Branch (603:25): [True: 0, False: 0]
  ------------------
  604|      0|                        session->extensions |= SSH_EXT_SIG_RSA_SHA512;
  ------------------
  |  |  127|      0|#define SSH_EXT_SIG_RSA_SHA512  0x04
  ------------------
  605|      0|                    }
  606|      0|                    SAFE_FREE(is_allowed);
  ------------------
  |  |  375|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (375:31): [True: 0, False: 0]
  |  |  |  Branch (375:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
  607|      0|                }
  608|      0|            }
  609|      0|            ok = match_group(hostkeys, "rsa-sha2-256");
  610|      0|            if (ok) {
  ------------------
  |  Branch (610:17): [True: 0, False: 0]
  ------------------
  611|       |                /* Check if rsa-sha2-256 is allowed by config */
  612|      0|                if (wanted_hostkeys != NULL) {
  ------------------
  |  Branch (612:21): [True: 0, False: 0]
  ------------------
  613|      0|                    char *is_allowed = ssh_find_matching(wanted_hostkeys,
  614|      0|                                                         "rsa-sha2-256");
  615|      0|                    if (is_allowed != NULL) {
  ------------------
  |  Branch (615:25): [True: 0, False: 0]
  ------------------
  616|      0|                        session->extensions |= SSH_EXT_SIG_RSA_SHA256;
  ------------------
  |  |  126|      0|#define SSH_EXT_SIG_RSA_SHA256  0x02
  ------------------
  617|      0|                    }
  618|      0|                    SAFE_FREE(is_allowed);
  ------------------
  |  |  375|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (375:31): [True: 0, False: 0]
  |  |  |  Branch (375:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
  619|      0|                }
  620|      0|            }
  621|       |
  622|       |            /*
  623|       |             * Ensure that the client preference is honored for the case
  624|       |             * both signature types are enabled.
  625|       |             */
  626|      0|            if ((session->extensions & SSH_EXT_SIG_RSA_SHA256) &&
  ------------------
  |  |  126|      0|#define SSH_EXT_SIG_RSA_SHA256  0x02
  ------------------
  |  Branch (626:17): [True: 0, False: 0]
  ------------------
  627|      0|                (session->extensions & SSH_EXT_SIG_RSA_SHA512)) {
  ------------------
  |  |  127|      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);
  ------------------
  |  |  126|      0|#define SSH_EXT_SIG_RSA_SHA256  0x02
  ------------------
                              session->extensions &= ~(SSH_EXT_SIG_RSA_SHA256 | SSH_EXT_SIG_RSA_SHA512);
  ------------------
  |  |  127|      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;
  ------------------
  |  |  127|      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;
  ------------------
  |  |  126|      0|#define SSH_EXT_SIG_RSA_SHA256  0x02
  ------------------
  638|      0|                } else {
  639|      0|                    SAFE_FREE(rsa_sig_ext);
  ------------------
  |  |  375|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (375:31): [True: 0, False: 0]
  |  |  |  Branch (375:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
  640|      0|                    goto error; /* should never happen */
  641|      0|                }
  642|      0|                SAFE_FREE(rsa_sig_ext);
  ------------------
  |  |  375|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (375:31): [True: 0, False: 0]
  |  |  |  Branch (375:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
  643|      0|            }
  644|       |
  645|      0|            SSH_LOG(SSH_LOG_DEBUG, "The client supports extension "
  ------------------
  |  |  283|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (283:34): [True: 0, False: 0]
  |  |  |  Branch (283:34): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  646|      0|                    "negotiation. Enabled signature algorithms: %s%s",
  647|      0|                    session->extensions & SSH_EXT_SIG_RSA_SHA256 ? "SHA256" : "",
  648|      0|                    session->extensions & SSH_EXT_SIG_RSA_SHA512 ? " SHA512" : "");
  649|      0|        }
  650|      0|    }
  651|    244|#endif /* WITH_SERVER */
  652|       |
  653|       |    /* Note, that his overwrites authenticated state in case of rekeying */
  654|    244|    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|    244|    if (session->send_first_kex_follows == false) {
  ------------------
  |  Branch (658:9): [True: 244, False: 0]
  ------------------
  659|    244|        session->dh_handshake_state = DH_STATE_INIT;
  660|    244|    }
  661|    244|    session->ssh_connection_callback(session);
  662|    244|    return SSH_PACKET_USED;
  ------------------
  |  |  638|    244|#define SSH_PACKET_USED 1
  ------------------
  663|       |
  664|     19|error:
  665|     19|    SSH_STRING_FREE(str);
  ------------------
  |  |  882|     19|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (882:14): [True: 0, False: 19]
  |  |  |  Branch (882:69): [Folded, False: 19]
  |  |  ------------------
  ------------------
  666|    209|    for (i = 0; i < SSH_KEX_METHODS; i++) {
  ------------------
  |  |   27|    209|#define SSH_KEX_METHODS 10
  ------------------
  |  Branch (666:17): [True: 190, False: 19]
  ------------------
  667|    190|        if (server_kex) {
  ------------------
  |  Branch (667:13): [True: 0, False: 190]
  ------------------
  668|      0|#ifdef WITH_SERVER
  669|      0|            session->next_crypto->client_kex.methods[i] = NULL;
  670|      0|#endif /* WITH_SERVER */
  671|    190|        } else { /* client */
  672|    190|            session->next_crypto->server_kex.methods[i] = NULL;
  673|    190|        }
  674|    190|        SAFE_FREE(strings[i]);
  ------------------
  |  |  375|    190|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (375:31): [True: 50, False: 140]
  |  |  |  Branch (375:71): [Folded, False: 190]
  |  |  ------------------
  ------------------
  675|    190|    }
  676|       |
  677|     19|    session->session_state = SSH_SESSION_STATE_ERROR;
  678|       |
  679|     19|    return SSH_PACKET_USED;
  ------------------
  |  |  638|     19|#define SSH_PACKET_USED 1
  ------------------
  680|    244|}
ssh_list_kex:
  682|    656|void ssh_list_kex(struct ssh_kex_struct *kex) {
  683|    656|  int i = 0;
  684|       |
  685|       |#ifdef DEBUG_CRYPTO
  686|       |  ssh_log_hexdump("session cookie", kex->cookie, 16);
  687|       |#endif
  688|       |
  689|  7.21k|  for(i = 0; i < SSH_KEX_METHODS; i++) {
  ------------------
  |  |   27|  7.21k|#define SSH_KEX_METHODS 10
  ------------------
  |  Branch (689:14): [True: 6.56k, False: 656]
  ------------------
  690|  6.56k|    if (kex->methods[i] == NULL) {
  ------------------
  |  Branch (690:9): [True: 0, False: 6.56k]
  ------------------
  691|      0|      continue;
  692|      0|    }
  693|  6.56k|    SSH_LOG(SSH_LOG_FUNCTIONS, "%s: %s",
  ------------------
  |  |  283|  6.56k|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  694|  6.56k|        ssh_kex_descriptions[i], kex->methods[i]);
  695|  6.56k|  }
  696|    656|}
ssh_client_select_hostkeys:
  708|    412|{
  709|    412|    const char *wanted = NULL;
  710|    412|    char *wanted_without_certs = NULL;
  711|    412|    char *known_hosts_algorithms = NULL;
  712|    412|    char *known_hosts_ordered = NULL;
  713|    412|    char *new_hostkeys = NULL;
  714|    412|    char *fips_hostkeys = NULL;
  715|       |
  716|    412|    wanted = session->opts.wanted_methods[SSH_HOSTKEYS];
  717|    412|    if (wanted == NULL) {
  ------------------
  |  Branch (717:9): [True: 412, False: 0]
  ------------------
  718|    412|        if (ssh_fips_mode()) {
  ------------------
  |  |  115|    412|#define ssh_fips_mode() (FIPS_mode() != 0)
  |  |  ------------------
  |  |  |  Branch (115:25): [True: 0, False: 412]
  |  |  ------------------
  ------------------
  719|      0|            wanted = ssh_kex_get_fips_methods(SSH_HOSTKEYS);
  720|    412|        } else {
  721|    412|            wanted = ssh_kex_get_default_methods(SSH_HOSTKEYS);
  722|    412|        }
  723|    412|    }
  724|       |
  725|       |    /* This removes the certificate types, unsupported for now */
  726|    412|    wanted_without_certs = ssh_find_all_matching(HOSTKEYS, wanted);
  ------------------
  |  |  142|    412|#define HOSTKEYS "ssh-ed25519," \
  |  |  143|    412|                 EC_HOSTKEYS \
  |  |  144|    412|                 "sk-ssh-ed25519@openssh.com," \
  |  |  145|    412|                 EC_SK_HOSTKEYS \
  |  |  146|    412|                 "rsa-sha2-512," \
  |  |  147|    412|                 "rsa-sha2-256," \
  |  |  148|    412|                 "ssh-rsa"
  ------------------
  727|    412|    if (wanted_without_certs == NULL) {
  ------------------
  |  Branch (727:9): [True: 0, False: 412]
  ------------------
  728|      0|        SSH_LOG(SSH_LOG_TRACE,
  ------------------
  |  |  283|      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|    412|    SSH_LOG(SSH_LOG_DEBUG,
  ------------------
  |  |  283|    412|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  735|    412|            "Order of wanted host keys: \"%s\"",
  736|    412|            wanted_without_certs);
  737|       |
  738|    412|    known_hosts_algorithms = ssh_known_hosts_get_algorithms_names(session);
  739|    412|    if (known_hosts_algorithms == NULL) {
  ------------------
  |  Branch (739:9): [True: 412, False: 0]
  ------------------
  740|    412|        SSH_LOG(SSH_LOG_DEBUG,
  ------------------
  |  |  283|    412|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  741|    412|                "No key found in known_hosts; "
  742|    412|                "changing host key method to \"%s\"",
  743|    412|                wanted_without_certs);
  744|       |
  745|    412|        return wanted_without_certs;
  746|    412|    }
  747|       |
  748|      0|    SSH_LOG(SSH_LOG_DEBUG,
  ------------------
  |  |  283|      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);
  ------------------
  |  |  375|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (375:31): [True: 0, False: 0]
  |  |  |  Branch (375: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,
  ------------------
  |  |  283|      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);
  ------------------
  |  |  375|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (375:31): [True: 0, False: 0]
  |  |  |  Branch (375:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
  770|      0|    SAFE_FREE(wanted_without_certs);
  ------------------
  |  |  375|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (375:31): [True: 0, False: 0]
  |  |  |  Branch (375:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
  771|      0|    if (new_hostkeys == NULL) {
  ------------------
  |  Branch (771:9): [True: 0, False: 0]
  ------------------
  772|      0|        ssh_set_error_oom(session);
  ------------------
  |  |  320|      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);
  ------------------
  |  |  375|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (375:31): [True: 0, False: 0]
  |  |  |  Branch (375:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
  780|      0|        if (fips_hostkeys == NULL) {
  ------------------
  |  Branch (780:13): [True: 0, False: 0]
  ------------------
  781|      0|            SSH_LOG(SSH_LOG_TRACE,
  ------------------
  |  |  283|      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,
  ------------------
  |  |  283|      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|    674|{
  802|    674|    struct ssh_kex_struct *client = &session->next_crypto->client_kex;
  803|    674|    const char *wanted = NULL;
  804|    674|    int ok;
  805|    674|    int i;
  806|    674|    bool gssapi_null_alg = false;
  807|    674|    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|    674|    if (client->methods[0] != NULL) {
  ------------------
  |  Branch (811:9): [True: 262, False: 412]
  ------------------
  812|    262|        return SSH_OK;
  ------------------
  |  |  315|    262|#define SSH_OK 0     /* No error */
  ------------------
  813|    262|    }
  814|       |
  815|    412|    ok = ssh_get_random(client->cookie, 16, 0);
  816|    412|    if (!ok) {
  ------------------
  |  Branch (816:9): [True: 0, False: 412]
  ------------------
  817|      0|        ssh_set_error(session, SSH_FATAL, "PRNG error");
  ------------------
  |  |  313|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  818|      0|        return SSH_ERROR;
  ------------------
  |  |  316|      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|  4.53k|    for (i = 0; i < SSH_KEX_METHODS; i++) {
  ------------------
  |  |   27|  4.53k|#define SSH_KEX_METHODS 10
  ------------------
  |  Branch (859:17): [True: 4.12k, False: 412]
  ------------------
  860|  4.12k|        if (i == SSH_HOSTKEYS) {
  ------------------
  |  Branch (860:13): [True: 412, False: 3.70k]
  ------------------
  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|    412|            client->methods[i] = ssh_client_select_hostkeys(session);
  865|    412|            if (client->methods[i] == NULL) {
  ------------------
  |  Branch (865:17): [True: 0, False: 412]
  ------------------
  866|      0|                ssh_set_error_oom(session);
  ------------------
  |  |  320|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
  867|      0|                return SSH_ERROR;
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  868|      0|            }
  869|    412|            if (gssapi_null_alg) {
  ------------------
  |  Branch (869:17): [True: 0, False: 412]
  ------------------
  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);
  ------------------
  |  |  320|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
  874|      0|                    return SSH_ERROR;
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  875|      0|                }
  876|      0|                SAFE_FREE(client->methods[i]);
  ------------------
  |  |  375|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (375:31): [True: 0, False: 0]
  |  |  |  Branch (375:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
  877|      0|                client->methods[i] = hostkeys;
  878|      0|            }
  879|    412|            continue;
  880|    412|        }
  881|       |
  882|  3.70k|        wanted = session->opts.wanted_methods[i];
  883|  3.70k|        if (wanted == NULL) {
  ------------------
  |  Branch (883:13): [True: 2.06k, False: 1.64k]
  ------------------
  884|  2.06k|            if (ssh_fips_mode()) {
  ------------------
  |  |  115|  2.06k|#define ssh_fips_mode() (FIPS_mode() != 0)
  |  |  ------------------
  |  |  |  Branch (115:25): [True: 0, False: 2.06k]
  |  |  ------------------
  ------------------
  885|      0|                wanted = fips_methods[i];
  886|  2.06k|            } else {
  887|  2.06k|                wanted = default_methods[i];
  888|  2.06k|            }
  889|  2.06k|        }
  890|  3.70k|        client->methods[i] = strdup(wanted);
  891|  3.70k|        if (client->methods[i] == NULL) {
  ------------------
  |  Branch (891:13): [True: 0, False: 3.70k]
  ------------------
  892|      0|            ssh_set_error_oom(session);
  ------------------
  |  |  320|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
  893|      0|            return SSH_ERROR;
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  894|      0|        }
  895|  3.70k|    }
  896|       |
  897|       |    /* For rekeying, skip the extension negotiation */
  898|    412|    if (session->flags & SSH_SESSION_FLAG_AUTHENTICATED) {
  ------------------
  |  |   78|    412|#define SSH_SESSION_FLAG_AUTHENTICATED 0x0002
  ------------------
  |  Branch (898:9): [True: 0, False: 412]
  ------------------
  899|      0|        return SSH_OK;
  ------------------
  |  |  315|      0|#define SSH_OK 0     /* No error */
  ------------------
  900|      0|    }
  901|       |
  902|    412|    ok = ssh_kex_append_extensions(session, client);
  903|    412|    if (ok != SSH_OK){
  ------------------
  |  |  315|    412|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (903:9): [True: 0, False: 412]
  ------------------
  904|      0|        return ok;
  905|      0|    }
  906|       |
  907|    412|    return SSH_OK;
  ------------------
  |  |  315|    412|#define SSH_OK 0     /* No error */
  ------------------
  908|    412|}
ssh_kex_append_extensions:
  911|    412|{
  912|    412|    char *kex = NULL;
  913|    412|    char *kex_tmp = NULL;
  914|    412|    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|    412|    kex = pkex->methods[SSH_KEX];
  920|    412|    len = strlen(kex);
  921|    412|    if (session->server) {
  ------------------
  |  Branch (921:9): [True: 0, False: 412]
  ------------------
  922|       |        /* Comma, nul byte */
  923|      0|        kex_len = len + 1 + strlen(KEX_STRICT_SERVER) + 1;
  ------------------
  |  |  197|      0|#define KEX_STRICT_SERVER "kex-strict-s-v00@openssh.com"
  ------------------
  924|    412|    } else {
  925|       |        /* Comma, comma, nul byte */
  926|    412|        kex_len = len + 1 + strlen(KEX_EXTENSION_CLIENT) + 1 +
  ------------------
  |  |  194|    412|#define KEX_EXTENSION_CLIENT "ext-info-c"
  ------------------
  927|    412|                  strlen(KEX_STRICT_CLIENT) + 1;
  ------------------
  |  |  196|    412|#define KEX_STRICT_CLIENT "kex-strict-c-v00@openssh.com"
  ------------------
  928|    412|    }
  929|    412|    if (kex_len >= MAX_PACKET_LEN) {
  ------------------
  |  |  216|    412|#define MAX_PACKET_LEN 262144
  ------------------
  |  Branch (929:9): [True: 0, False: 412]
  ------------------
  930|       |        /* Overflow */
  931|      0|        return SSH_ERROR;
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  932|      0|    }
  933|    412|    kex_tmp = realloc(kex, kex_len);
  934|    412|    if (kex_tmp == NULL) {
  ------------------
  |  Branch (934:9): [True: 0, False: 412]
  ------------------
  935|      0|        ssh_set_error_oom(session);
  ------------------
  |  |  320|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
  936|      0|        return SSH_ERROR;
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  937|      0|    }
  938|    412|    if (session->server){
  ------------------
  |  Branch (938:9): [True: 0, False: 412]
  ------------------
  939|      0|        snprintf(kex_tmp + len, kex_len - len, ",%s", KEX_STRICT_SERVER);
  ------------------
  |  |  197|      0|#define KEX_STRICT_SERVER "kex-strict-s-v00@openssh.com"
  ------------------
  940|    412|    } else {
  941|    412|        snprintf(kex_tmp + len,
  942|    412|                 kex_len - len,
  943|    412|                 ",%s,%s",
  944|    412|                 KEX_EXTENSION_CLIENT,
  ------------------
  |  |  194|    412|#define KEX_EXTENSION_CLIENT "ext-info-c"
  ------------------
  945|    412|                 KEX_STRICT_CLIENT);
  ------------------
  |  |  196|    412|#define KEX_STRICT_CLIENT "kex-strict-c-v00@openssh.com"
  ------------------
  946|    412|    }
  947|    412|    pkex->methods[SSH_KEX] = kex_tmp;
  948|    412|    return SSH_OK;
  ------------------
  |  |  315|    412|#define SSH_OK 0     /* No error */
  ------------------
  949|    412|}
ssh_kex_select_methods:
 1082|    244|{
 1083|    244|    struct ssh_crypto_struct *crypto = session->next_crypto;
 1084|    244|    struct ssh_kex_struct *server = &crypto->server_kex;
 1085|    244|    struct ssh_kex_struct *client = &crypto->client_kex;
 1086|    244|    char *ext_start = NULL;
 1087|    244|    const char *aead_hmac = NULL;
 1088|    244|    enum ssh_key_exchange_e kex_type;
 1089|    244|    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|    244|    if (session->client) {
  ------------------
  |  Branch (1093:9): [True: 244, False: 0]
  ------------------
 1094|    244|        ext_start = strstr(client->methods[SSH_KEX], "," KEX_EXTENSION_CLIENT);
  ------------------
  |  |  194|    244|#define KEX_EXTENSION_CLIENT "ext-info-c"
  ------------------
 1095|    244|        if (ext_start != NULL) {
  ------------------
  |  Branch (1095:13): [True: 244, False: 0]
  ------------------
 1096|    244|            ext_start[0] = '\0';
 1097|    244|        }
 1098|    244|    }
 1099|    244|    if (session->server) {
  ------------------
  |  Branch (1099:9): [True: 0, False: 244]
  ------------------
 1100|      0|        ext_start = strstr(server->methods[SSH_KEX], "," KEX_STRICT_SERVER);
  ------------------
  |  |  197|      0|#define KEX_STRICT_SERVER "kex-strict-s-v00@openssh.com"
  ------------------
 1101|      0|        if (ext_start != NULL) {
  ------------------
  |  Branch (1101:13): [True: 0, False: 0]
  ------------------
 1102|      0|            ext_start[0] = '\0';
 1103|      0|        }
 1104|      0|    }
 1105|       |
 1106|  1.92k|    for (i = 0; i < SSH_KEX_METHODS; i++) {
  ------------------
  |  |   27|  1.92k|#define SSH_KEX_METHODS 10
  ------------------
  |  Branch (1106:17): [True: 1.76k, False: 166]
  ------------------
 1107|  1.76k|        crypto->kex_methods[i] = ssh_find_matching(server->methods[i],
 1108|  1.76k|                                                   client->methods[i]);
 1109|       |
 1110|  1.76k|        if (i == SSH_MAC_C_S || i == SSH_MAC_S_C) {
  ------------------
  |  Branch (1110:13): [True: 169, False: 1.59k]
  |  Branch (1110:33): [True: 166, False: 1.42k]
  ------------------
 1111|    335|            aead_hmac = ssh_find_aead_hmac(crypto->kex_methods[i - 2]);
 1112|    335|            if (aead_hmac) {
  ------------------
  |  Branch (1112:17): [True: 0, False: 335]
  ------------------
 1113|      0|                free(crypto->kex_methods[i]);
 1114|      0|                crypto->kex_methods[i] = strdup(aead_hmac);
 1115|      0|            }
 1116|    335|        }
 1117|  1.76k|        if (crypto->kex_methods[i] == NULL && i < SSH_LANG_C_S) {
  ------------------
  |  Branch (1117:13): [True: 81, False: 1.67k]
  |  Branch (1117:47): [True: 78, False: 3]
  ------------------
 1118|     78|            ssh_set_error(session, SSH_FATAL,
  ------------------
  |  |  313|     78|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
 1119|     78|                          "kex error : no match for method %s: server [%s], "
 1120|     78|                          "client [%s]", ssh_kex_descriptions[i],
 1121|     78|                          server->methods[i], client->methods[i]);
 1122|     78|            return SSH_ERROR;
  ------------------
  |  |  316|     78|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 1123|  1.68k|        } else if ((i >= SSH_LANG_C_S) && (crypto->kex_methods[i] == NULL)) {
  ------------------
  |  Branch (1123:20): [True: 332, False: 1.35k]
  |  Branch (1123:43): [True: 3, False: 329]
  ------------------
 1124|       |            /* we can safely do that for languages */
 1125|      3|            crypto->kex_methods[i] = strdup("");
 1126|      3|        }
 1127|  1.76k|    }
 1128|       |
 1129|       |    /* We can not set this value directly as the old value is needed to revert
 1130|       |     * callbacks if we are client */
 1131|    166|    kex_type = kex_select_kex_type(crypto->kex_methods[SSH_KEX]);
 1132|    166|    if (session->client && session->first_kex_follows_guess_wrong) {
  ------------------
  |  Branch (1132:9): [True: 166, False: 0]
  |  Branch (1132:28): [True: 126, False: 40]
  ------------------
 1133|    126|        SSH_LOG(SSH_LOG_DEBUG, "Our guess was wrong. Restarting the KEX");
  ------------------
  |  |  283|    126|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 1134|       |        /* We need to remove the wrong callbacks and start kex again */
 1135|    126|        revert_kex_callbacks(session);
 1136|    126|        session->dh_handshake_state = DH_STATE_INIT;
 1137|    126|        session->first_kex_follows_guess_wrong = false;
 1138|    126|    }
 1139|    166|    crypto->kex_type = kex_type;
 1140|       |
 1141|    166|    SSH_LOG(SSH_LOG_DEBUG, "Negotiated %s,%s,%s,%s,%s,%s,%s,%s,%s,%s",
  ------------------
  |  |  283|    166|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 1142|    166|            session->next_crypto->kex_methods[SSH_KEX],
 1143|    166|            session->next_crypto->kex_methods[SSH_HOSTKEYS],
 1144|    166|            session->next_crypto->kex_methods[SSH_CRYPT_C_S],
 1145|    166|            session->next_crypto->kex_methods[SSH_CRYPT_S_C],
 1146|    166|            session->next_crypto->kex_methods[SSH_MAC_C_S],
 1147|    166|            session->next_crypto->kex_methods[SSH_MAC_S_C],
 1148|    166|            session->next_crypto->kex_methods[SSH_COMP_C_S],
 1149|    166|            session->next_crypto->kex_methods[SSH_COMP_S_C],
 1150|    166|            session->next_crypto->kex_methods[SSH_LANG_C_S],
 1151|    166|            session->next_crypto->kex_methods[SSH_LANG_S_C]
 1152|    166|    );
 1153|    166|    return SSH_OK;
  ------------------
  |  |  315|    166|#define SSH_OK 0     /* No error */
  ------------------
 1154|    244|}
ssh_send_kex:
 1159|    412|{
 1160|    412|    struct ssh_kex_struct *kex = (session->server ?
  ------------------
  |  Branch (1160:35): [True: 0, False: 412]
  ------------------
 1161|      0|        &session->next_crypto->server_kex :
 1162|    412|        &session->next_crypto->client_kex);
 1163|    412|    ssh_string str = NULL;
 1164|    412|    int i;
 1165|    412|    int rc;
 1166|    412|    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|    412|    if (session->client &&
  ------------------
  |  Branch (1170:9): [True: 412, False: 0]
  ------------------
 1171|    412|        session->session_state != SSH_SESSION_STATE_KEXINIT_RECEIVED &&
  ------------------
  |  Branch (1171:9): [True: 412, False: 0]
  ------------------
 1172|    412|        session->send_first_kex_follows) {
  ------------------
  |  Branch (1172:9): [True: 0, False: 412]
  ------------------
 1173|      0|        first_kex_packet_follows = 1;
 1174|      0|    }
 1175|       |
 1176|    412|    SSH_LOG(SSH_LOG_TRACE,
  ------------------
  |  |  283|    412|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 1177|    412|            "Sending KEXINIT packet, first_kex_packet_follows = %d",
 1178|    412|            first_kex_packet_follows);
 1179|       |
 1180|    412|    rc = ssh_buffer_pack(session->out_buffer,
  ------------------
  |  |   50|    412|    _ssh_buffer_pack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |  453|    412|        (__VA_NARG_(__VA_ARGS__, __RSEQ_N()))
  |  |  |  |  ------------------
  |  |  |  |  |  |  455|    412|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  450|    412|#define VA_APPLY_VARIADIC_MACRO(macro, tuple) macro tuple
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  455|    412|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  463|    412|        _61,_62,_63,N,...) N
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                   _ssh_buffer_pack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |   28|    412|#define SSH_BUFFER_PACK_END ((uint32_t) 0x4f65feb3)
  |  |  ------------------
  ------------------
 1181|    412|                         "bP",
 1182|    412|                         SSH2_MSG_KEXINIT,
 1183|    412|                         (size_t)16,
 1184|    412|                         kex->cookie); /* cookie */
 1185|    412|    if (rc != SSH_OK)
  ------------------
  |  |  315|    412|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (1185:9): [True: 0, False: 412]
  ------------------
 1186|      0|        goto error;
 1187|    412|    if (ssh_hashbufout_add_cookie(session) < 0) {
  ------------------
  |  Branch (1187:9): [True: 0, False: 412]
  ------------------
 1188|      0|        goto error;
 1189|      0|    }
 1190|       |
 1191|    412|    ssh_list_kex(kex);
 1192|       |
 1193|  4.53k|    for (i = 0; i < SSH_KEX_METHODS; i++) {
  ------------------
  |  |   27|  4.53k|#define SSH_KEX_METHODS 10
  ------------------
  |  Branch (1193:17): [True: 4.12k, False: 412]
  ------------------
 1194|  4.12k|        str = ssh_string_from_char(kex->methods[i]);
 1195|  4.12k|        if (str == NULL) {
  ------------------
  |  Branch (1195:13): [True: 0, False: 4.12k]
  ------------------
 1196|      0|            goto error;
 1197|      0|        }
 1198|       |
 1199|  4.12k|        rc = ssh_buffer_add_ssh_string(session->out_hashbuf, str);
 1200|  4.12k|        if (rc < 0) {
  ------------------
  |  Branch (1200:13): [True: 0, False: 4.12k]
  ------------------
 1201|      0|            goto error;
 1202|      0|        }
 1203|  4.12k|        rc = ssh_buffer_add_ssh_string(session->out_buffer, str);
 1204|  4.12k|        if (rc < 0) {
  ------------------
  |  Branch (1204:13): [True: 0, False: 4.12k]
  ------------------
 1205|      0|            goto error;
 1206|      0|        }
 1207|  4.12k|        SSH_STRING_FREE(str);
  ------------------
  |  |  882|  4.12k|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (882:14): [True: 4.12k, False: 0]
  |  |  |  Branch (882:69): [Folded, False: 4.12k]
  |  |  ------------------
  ------------------
 1208|  4.12k|        str = NULL;
 1209|  4.12k|    }
 1210|       |
 1211|    412|    rc = ssh_buffer_pack(session->out_buffer,
  ------------------
  |  |   50|    412|    _ssh_buffer_pack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |  453|    412|        (__VA_NARG_(__VA_ARGS__, __RSEQ_N()))
  |  |  |  |  ------------------
  |  |  |  |  |  |  455|    412|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  450|    412|#define VA_APPLY_VARIADIC_MACRO(macro, tuple) macro tuple
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  455|    412|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  463|    412|        _61,_62,_63,N,...) N
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                   _ssh_buffer_pack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |   28|    412|#define SSH_BUFFER_PACK_END ((uint32_t) 0x4f65feb3)
  |  |  ------------------
  ------------------
 1212|    412|                         "bd",
 1213|    412|                         first_kex_packet_follows,
 1214|    412|                         0);
 1215|    412|    if (rc != SSH_OK) {
  ------------------
  |  |  315|    412|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (1215:9): [True: 0, False: 412]
  ------------------
 1216|      0|        goto error;
 1217|      0|    }
 1218|       |
 1219|       |    /* Prepare also the first_kex_packet_follows and reserved to 0 */
 1220|    412|    rc = ssh_buffer_add_u8(session->out_hashbuf, first_kex_packet_follows);
 1221|    412|    if (rc < 0) {
  ------------------
  |  Branch (1221:9): [True: 0, False: 412]
  ------------------
 1222|      0|        goto error;
 1223|      0|    }
 1224|    412|    rc = ssh_buffer_add_u32(session->out_hashbuf, 0);
 1225|    412|    if (rc < 0) {
  ------------------
  |  Branch (1225:9): [True: 0, False: 412]
  ------------------
 1226|      0|        goto error;
 1227|      0|    }
 1228|       |
 1229|    412|    rc = ssh_packet_send(session);
 1230|    412|    if (rc == SSH_ERROR) {
  ------------------
  |  |  316|    412|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  |  Branch (1230:9): [True: 0, False: 412]
  ------------------
 1231|      0|        return -1;
 1232|      0|    }
 1233|       |
 1234|    412|    session->flags |= SSH_SESSION_FLAG_KEXINIT_SENT;
  ------------------
  |  |   86|    412|#define SSH_SESSION_FLAG_KEXINIT_SENT 0x0008
  ------------------
 1235|    412|    SSH_LOG(SSH_LOG_PACKET, "SSH_MSG_KEXINIT sent");
  ------------------
  |  |  283|    412|    _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|    412|    if (first_kex_packet_follows == 1) {
  ------------------
  |  Branch (1239:9): [True: 0, False: 412]
  ------------------
 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);
  ------------------
  |  |  320|      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);
  ------------------
  |  |  283|      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) {
  ------------------
  |  |  316|      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|    412|    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);
  ------------------
  |  |  882|      0|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (882:14): [True: 0, False: 0]
  |  |  |  Branch (882:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1266|       |
 1267|      0|    return -1;
 1268|    412|}
ssh_keep_known_algos:
 1324|  1.89k|{
 1325|  1.89k|    if (algo > SSH_LANG_S_C) {
  ------------------
  |  Branch (1325:9): [True: 0, False: 1.89k]
  ------------------
 1326|      0|        return NULL;
 1327|      0|    }
 1328|       |
 1329|  1.89k|    return ssh_find_all_matching(supported_methods[algo], list);
 1330|  1.89k|}
ssh_make_sessionid:
 1459|     28|{
 1460|     28|    ssh_string num = NULL;
 1461|     28|    ssh_buffer server_hash = NULL;
 1462|     28|    ssh_buffer client_hash = NULL;
 1463|     28|    ssh_buffer buf = NULL;
 1464|     28|    ssh_string server_pubkey_blob = NULL;
 1465|     28|#if !defined(HAVE_LIBCRYPTO) || OPENSSL_VERSION_NUMBER < 0x30000000L
 1466|     28|    const_bignum client_pubkey, server_pubkey;
 1467|       |#else
 1468|       |    bignum client_pubkey = NULL, server_pubkey = NULL;
 1469|       |#endif /* OPENSSL_VERSION_NUMBER */
 1470|     28|#ifdef WITH_GEX
 1471|     28|#if !defined(HAVE_LIBCRYPTO) || OPENSSL_VERSION_NUMBER < 0x30000000L
 1472|     28|    const_bignum modulus, generator;
 1473|       |#else
 1474|       |    bignum modulus = NULL, generator = NULL;
 1475|       |#endif /* OPENSSL_VERSION_NUMBER */
 1476|     28|#endif /* WITH_GEX */
 1477|     28|    int rc = SSH_ERROR;
  ------------------
  |  |  316|     28|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 1478|       |
 1479|     28|    buf = ssh_buffer_new();
 1480|     28|    if (buf == NULL) {
  ------------------
  |  Branch (1480:9): [True: 0, False: 28]
  ------------------
 1481|      0|        ssh_set_error_oom(session);
  ------------------
  |  |  320|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
 1482|      0|        return rc;
 1483|      0|    }
 1484|       |
 1485|     28|    rc = ssh_buffer_pack(buf,
  ------------------
  |  |   50|     28|    _ssh_buffer_pack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |  453|     28|        (__VA_NARG_(__VA_ARGS__, __RSEQ_N()))
  |  |  |  |  ------------------
  |  |  |  |  |  |  455|     28|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  450|     28|#define VA_APPLY_VARIADIC_MACRO(macro, tuple) macro tuple
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  455|     28|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  463|     28|        _61,_62,_63,N,...) N
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                   _ssh_buffer_pack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |   28|     28|#define SSH_BUFFER_PACK_END ((uint32_t) 0x4f65feb3)
  |  |  ------------------
  ------------------
 1486|     28|                         "ss",
 1487|     28|                         session->clientbanner,
 1488|     28|                         session->serverbanner);
 1489|     28|    if (rc == SSH_ERROR) {
  ------------------
  |  |  316|     28|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  |  Branch (1489:9): [True: 0, False: 28]
  ------------------
 1490|      0|        ssh_set_error(session,
  ------------------
  |  |  313|      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|     28|    if (session->client) {
  ------------------
  |  Branch (1496:9): [True: 28, False: 0]
  ------------------
 1497|     28|        server_hash = session->in_hashbuf;
 1498|     28|        client_hash = session->out_hashbuf;
 1499|     28|    } else {
 1500|      0|        server_hash = session->out_hashbuf;
 1501|      0|        client_hash = session->in_hashbuf;
 1502|      0|    }
 1503|       |
 1504|     28|    rc = ssh_dh_get_next_server_publickey_blob(session, &server_pubkey_blob);
 1505|     28|    if (rc != SSH_OK) {
  ------------------
  |  |  315|     28|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (1505:9): [True: 0, False: 28]
  ------------------
 1506|      0|        ssh_set_error(session,
  ------------------
  |  |  313|      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|     28|    if (server_pubkey_blob == NULL) {
  ------------------
  |  Branch (1512:9): [True: 0, False: 28]
  ------------------
 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);
  ------------------
  |  |  320|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
 1518|      0|                rc = SSH_ERROR;
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 1519|      0|                goto error;
 1520|      0|            }
 1521|      0|        }
 1522|      0|    }
 1523|       |
 1524|     28|    rc = ssh_buffer_pack(buf,
  ------------------
  |  |   50|     28|    _ssh_buffer_pack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |  453|     28|        (__VA_NARG_(__VA_ARGS__, __RSEQ_N()))
  |  |  |  |  ------------------
  |  |  |  |  |  |  455|     28|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  450|     28|#define VA_APPLY_VARIADIC_MACRO(macro, tuple) macro tuple
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  455|     28|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  463|     28|        _61,_62,_63,N,...) N
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                   _ssh_buffer_pack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |   28|     28|#define SSH_BUFFER_PACK_END ((uint32_t) 0x4f65feb3)
  |  |  ------------------
  ------------------
 1525|     28|                         "dPdPS",
 1526|     28|                         ssh_buffer_get_len(client_hash),
 1527|     28|                         (size_t)ssh_buffer_get_len(client_hash),
 1528|     28|                         ssh_buffer_get(client_hash),
 1529|     28|                         ssh_buffer_get_len(server_hash),
 1530|     28|                         (size_t)ssh_buffer_get_len(server_hash),
 1531|     28|                         ssh_buffer_get(server_hash),
 1532|     28|                         server_pubkey_blob);
 1533|     28|    SSH_STRING_FREE(server_pubkey_blob);
  ------------------
  |  |  882|     28|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (882:14): [True: 28, False: 0]
  |  |  |  Branch (882:69): [Folded, False: 28]
  |  |  ------------------
  ------------------
 1534|     28|    if (rc != SSH_OK){
  ------------------
  |  |  315|     28|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (1534:9): [True: 0, False: 28]
  ------------------
 1535|      0|        ssh_set_error(session,
  ------------------
  |  |  313|      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|     28|    switch(session->next_crypto->kex_type) {
 1542|      0|    case SSH_KEX_DH_GROUP1_SHA1:
  ------------------
  |  Branch (1542:5): [True: 0, False: 28]
  ------------------
 1543|      0|    case SSH_KEX_DH_GROUP14_SHA1:
  ------------------
  |  Branch (1543:5): [True: 0, False: 28]
  ------------------
 1544|      3|    case SSH_KEX_DH_GROUP14_SHA256:
  ------------------
  |  Branch (1544:5): [True: 3, False: 25]
  ------------------
 1545|      3|    case SSH_GSS_KEX_DH_GROUP14_SHA256:
  ------------------
  |  Branch (1545:5): [True: 0, False: 28]
  ------------------
 1546|      3|    case SSH_KEX_DH_GROUP16_SHA512:
  ------------------
  |  Branch (1546:5): [True: 0, False: 28]
  ------------------
 1547|      3|    case SSH_GSS_KEX_DH_GROUP16_SHA512:
  ------------------
  |  Branch (1547:5): [True: 0, False: 28]
  ------------------
 1548|     19|    case SSH_KEX_DH_GROUP18_SHA512:
  ------------------
  |  Branch (1548:5): [True: 16, False: 12]
  ------------------
 1549|     19|        rc = ssh_dh_keypair_get_keys(session->next_crypto->dh_ctx,
 1550|     19|                                     DH_CLIENT_KEYPAIR, NULL, &client_pubkey);
  ------------------
  |  |   30|     19|#define DH_CLIENT_KEYPAIR 0
  ------------------
 1551|     19|        if (rc != SSH_OK) {
  ------------------
  |  |  315|     19|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (1551:13): [True: 0, False: 19]
  ------------------
 1552|      0|            goto error;
 1553|      0|        }
 1554|     19|        rc = ssh_dh_keypair_get_keys(session->next_crypto->dh_ctx,
 1555|     19|                                     DH_SERVER_KEYPAIR, NULL, &server_pubkey);
  ------------------
  |  |   31|     19|#define DH_SERVER_KEYPAIR 1
  ------------------
 1556|     19|        if (rc != SSH_OK) {
  ------------------
  |  |  315|     19|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (1556:13): [True: 0, False: 19]
  ------------------
 1557|      0|            goto error;
 1558|      0|        }
 1559|     19|        rc = ssh_buffer_pack(buf,
  ------------------
  |  |   50|     19|    _ssh_buffer_pack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |  453|     19|        (__VA_NARG_(__VA_ARGS__, __RSEQ_N()))
  |  |  |  |  ------------------
  |  |  |  |  |  |  455|     19|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  450|     19|#define VA_APPLY_VARIADIC_MACRO(macro, tuple) macro tuple
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  455|     19|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  463|     19|        _61,_62,_63,N,...) N
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                   _ssh_buffer_pack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |   28|     19|#define SSH_BUFFER_PACK_END ((uint32_t) 0x4f65feb3)
  |  |  ------------------
  ------------------
 1560|     19|                             "BB",
 1561|     19|                             client_pubkey,
 1562|     19|                             server_pubkey);
 1563|     19|        if (rc != SSH_OK) {
  ------------------
  |  |  315|     19|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (1563:13): [True: 0, False: 19]
  ------------------
 1564|      0|            ssh_set_error(session, SSH_FATAL, "Failed to pack DH pubkeys");
  ------------------
  |  |  313|      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|     19|        break;
 1572|     19|#ifdef WITH_GEX
 1573|     19|    case SSH_KEX_DH_GEX_SHA1:
  ------------------
  |  Branch (1573:5): [True: 0, False: 28]
  ------------------
 1574|      0|    case SSH_KEX_DH_GEX_SHA256:
  ------------------
  |  Branch (1574:5): [True: 0, False: 28]
  ------------------
 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) {
  ------------------
  |  |  315|      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) {
  ------------------
  |  |  315|      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) {
  ------------------
  |  |  315|      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)
  |  |  ------------------
  |  |  |  |  453|      0|        (__VA_NARG_(__VA_ARGS__, __RSEQ_N()))
  |  |  |  |  ------------------
  |  |  |  |  |  |  455|      0|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  450|      0|#define VA_APPLY_VARIADIC_MACRO(macro, tuple) macro tuple
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  455|      0|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  463|      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) {
  ------------------
  |  |  315|      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");
  ------------------
  |  |  313|      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: 28]
  ------------------
 1611|      0|    case SSH_KEX_ECDH_SHA2_NISTP384:
  ------------------
  |  Branch (1611:5): [True: 0, False: 28]
  ------------------
 1612|      0|    case SSH_KEX_ECDH_SHA2_NISTP521:
  ------------------
  |  Branch (1612:5): [True: 0, False: 28]
  ------------------
 1613|      0|    case SSH_GSS_KEX_ECDH_NISTP256_SHA256:
  ------------------
  |  Branch (1613:5): [True: 0, False: 28]
  ------------------
 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");
  ------------------
  |  |  283|      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)
  |  |  ------------------
  |  |  |  |  453|      0|        (__VA_NARG_(__VA_ARGS__, __RSEQ_N()))
  |  |  |  |  ------------------
  |  |  |  |  |  |  455|      0|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  450|      0|#define VA_APPLY_VARIADIC_MACRO(macro, tuple) macro tuple
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  455|      0|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  463|      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) {
  ------------------
  |  |  315|      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");
  ------------------
  |  |  313|      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|      8|    case SSH_KEX_CURVE25519_SHA256:
  ------------------
  |  Branch (1630:5): [True: 8, False: 20]
  ------------------
 1631|      9|    case SSH_KEX_CURVE25519_SHA256_LIBSSH_ORG:
  ------------------
  |  Branch (1631:5): [True: 1, False: 27]
  ------------------
 1632|      9|    case SSH_GSS_KEX_CURVE25519_SHA256:
  ------------------
  |  Branch (1632:5): [True: 0, False: 28]
  ------------------
 1633|      9|        rc = ssh_buffer_pack(buf,
  ------------------
  |  |   50|      9|    _ssh_buffer_pack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |  453|      9|        (__VA_NARG_(__VA_ARGS__, __RSEQ_N()))
  |  |  |  |  ------------------
  |  |  |  |  |  |  455|      9|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  450|      9|#define VA_APPLY_VARIADIC_MACRO(macro, tuple) macro tuple
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  455|      9|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  463|      9|        _61,_62,_63,N,...) N
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                   _ssh_buffer_pack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |   28|      9|#define SSH_BUFFER_PACK_END ((uint32_t) 0x4f65feb3)
  |  |  ------------------
  ------------------
 1634|      9|                             "dPdP",
 1635|      9|                             CURVE25519_PUBKEY_SIZE,
 1636|      9|                             (size_t)CURVE25519_PUBKEY_SIZE,
 1637|      9|                             session->next_crypto->curve25519_client_pubkey,
 1638|      9|                             CURVE25519_PUBKEY_SIZE,
 1639|      9|                             (size_t)CURVE25519_PUBKEY_SIZE,
 1640|      9|                             session->next_crypto->curve25519_server_pubkey);
 1641|       |
 1642|      9|        if (rc != SSH_OK) {
  ------------------
  |  |  315|      9|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (1642:13): [True: 0, False: 9]
  ------------------
 1643|      0|            ssh_set_error(session,
  ------------------
  |  |  313|      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|      9|        break;
 1649|      9|#endif /* HAVE_CURVE25519 */
 1650|      9|#ifdef HAVE_SNTRUP761
 1651|      9|    case SSH_KEX_SNTRUP761X25519_SHA512:
  ------------------
  |  Branch (1651:5): [True: 0, False: 28]
  ------------------
 1652|      0|    case SSH_KEX_SNTRUP761X25519_SHA512_OPENSSH_COM:
  ------------------
  |  Branch (1652:5): [True: 0, False: 28]
  ------------------
 1653|      0|        rc = ssh_buffer_pack(buf,
  ------------------
  |  |   50|      0|    _ssh_buffer_pack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |  453|      0|        (__VA_NARG_(__VA_ARGS__, __RSEQ_N()))
  |  |  |  |  ------------------
  |  |  |  |  |  |  455|      0|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  450|      0|#define VA_APPLY_VARIADIC_MACRO(macro, tuple) macro tuple
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  455|      0|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  463|      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) {
  ------------------
  |  |  315|      0|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (1666:13): [True: 0, False: 0]
  ------------------
 1667|      0|            ssh_set_error(session,
  ------------------
  |  |  313|      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|      0|    case SSH_KEX_MLKEM768X25519_SHA256:
  ------------------
  |  Branch (1674:5): [True: 0, False: 28]
  ------------------
 1675|      0|    case SSH_KEX_MLKEM768NISTP256_SHA256:
  ------------------
  |  Branch (1675:5): [True: 0, False: 28]
  ------------------
 1676|       |#ifdef HAVE_MLKEM1024
 1677|       |    case SSH_KEX_MLKEM1024NISTP384_SHA384:
 1678|       |#endif
 1679|      0|        rc = ssh_buffer_pack(buf,
  ------------------
  |  |   50|      0|    _ssh_buffer_pack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |  453|      0|        (__VA_NARG_(__VA_ARGS__, __RSEQ_N()))
  |  |  |  |  ------------------
  |  |  |  |  |  |  455|      0|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  450|      0|#define VA_APPLY_VARIADIC_MACRO(macro, tuple) macro tuple
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  455|      0|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  463|      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)
  |  |  ------------------
  ------------------
 1680|      0|                             "SS",
 1681|      0|                             session->next_crypto->hybrid_client_init,
 1682|      0|                             session->next_crypto->hybrid_server_reply);
 1683|      0|        if (rc != SSH_OK) {
  ------------------
  |  |  315|      0|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (1683:13): [True: 0, False: 0]
  ------------------
 1684|      0|            ssh_set_error(session,
  ------------------
  |  |  313|      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|      0|        break;
 1690|      0|    default:
  ------------------
  |  Branch (1690:5): [True: 0, False: 28]
  ------------------
 1691|       |        /* Handle unsupported kex types - this should not happen in normal operation */
 1692|      0|        rc = SSH_ERROR;
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 1693|      0|        ssh_set_error(session, SSH_FATAL, "Unsupported KEX algorithm");
  ------------------
  |  |  313|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
 1694|      0|        goto error;
 1695|     28|    }
 1696|     28|    switch (session->next_crypto->kex_type) {
 1697|      0|    case SSH_KEX_SNTRUP761X25519_SHA512:
  ------------------
  |  Branch (1697:5): [True: 0, False: 28]
  ------------------
 1698|      0|    case SSH_KEX_SNTRUP761X25519_SHA512_OPENSSH_COM:
  ------------------
  |  Branch (1698:5): [True: 0, False: 28]
  ------------------
 1699|      0|    case SSH_KEX_MLKEM768X25519_SHA256:
  ------------------
  |  Branch (1699:5): [True: 0, False: 28]
  ------------------
 1700|      0|    case SSH_KEX_MLKEM768NISTP256_SHA256:
  ------------------
  |  Branch (1700:5): [True: 0, False: 28]
  ------------------
 1701|       |#ifdef HAVE_MLKEM1024
 1702|       |    case SSH_KEX_MLKEM1024NISTP384_SHA384:
 1703|       |#endif
 1704|      0|        rc = ssh_buffer_pack(buf, "S", session->next_crypto->hybrid_shared_secret);
  ------------------
  |  |   50|      0|    _ssh_buffer_pack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |  453|      0|        (__VA_NARG_(__VA_ARGS__, __RSEQ_N()))
  |  |  |  |  ------------------
  |  |  |  |  |  |  455|      0|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  450|      0|#define VA_APPLY_VARIADIC_MACRO(macro, tuple) macro tuple
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  455|      0|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  463|      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)
  |  |  ------------------
  ------------------
 1705|      0|        break;
 1706|     28|    default:
  ------------------
  |  Branch (1706:5): [True: 28, False: 0]
  ------------------
 1707|     28|        rc = ssh_buffer_pack(buf, "B", session->next_crypto->shared_secret);
  ------------------
  |  |   50|     28|    _ssh_buffer_pack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |  453|     28|        (__VA_NARG_(__VA_ARGS__, __RSEQ_N()))
  |  |  |  |  ------------------
  |  |  |  |  |  |  455|     28|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  450|     28|#define VA_APPLY_VARIADIC_MACRO(macro, tuple) macro tuple
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  455|     28|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  463|     28|        _61,_62,_63,N,...) N
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                   _ssh_buffer_pack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |   28|     28|#define SSH_BUFFER_PACK_END ((uint32_t) 0x4f65feb3)
  |  |  ------------------
  ------------------
 1708|     28|        break;
 1709|     28|    }
 1710|     28|    if (rc != SSH_OK) {
  ------------------
  |  |  315|     28|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (1710:9): [True: 0, False: 28]
  ------------------
 1711|      0|        ssh_set_error(session, SSH_FATAL, "Failed to pack shared secret");
  ------------------
  |  |  313|      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|     28|    rc = SSH_ERROR;
  ------------------
  |  |  316|     28|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 1721|     28|    switch (session->next_crypto->kex_type) {
 1722|      0|    case SSH_KEX_DH_GROUP1_SHA1:
  ------------------
  |  Branch (1722:5): [True: 0, False: 28]
  ------------------
 1723|      0|    case SSH_KEX_DH_GROUP14_SHA1:
  ------------------
  |  Branch (1723:5): [True: 0, False: 28]
  ------------------
 1724|      0|#ifdef WITH_GEX
 1725|      0|    case SSH_KEX_DH_GEX_SHA1:
  ------------------
  |  Branch (1725:5): [True: 0, False: 28]
  ------------------
 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);
  ------------------
  |  |  320|      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|      3|    case SSH_KEX_DH_GROUP14_SHA256:
  ------------------
  |  Branch (1737:5): [True: 3, False: 25]
  ------------------
 1738|      3|    case SSH_GSS_KEX_DH_GROUP14_SHA256:
  ------------------
  |  Branch (1738:5): [True: 0, False: 28]
  ------------------
 1739|      3|    case SSH_KEX_ECDH_SHA2_NISTP256:
  ------------------
  |  Branch (1739:5): [True: 0, False: 28]
  ------------------
 1740|     11|    case SSH_KEX_CURVE25519_SHA256:
  ------------------
  |  Branch (1740:5): [True: 8, False: 20]
  ------------------
 1741|     12|    case SSH_KEX_CURVE25519_SHA256_LIBSSH_ORG:
  ------------------
  |  Branch (1741:5): [True: 1, False: 27]
  ------------------
 1742|     12|    case SSH_KEX_MLKEM768X25519_SHA256:
  ------------------
  |  Branch (1742:5): [True: 0, False: 28]
  ------------------
 1743|     12|    case SSH_KEX_MLKEM768NISTP256_SHA256:
  ------------------
  |  Branch (1743:5): [True: 0, False: 28]
  ------------------
 1744|     12|    case SSH_GSS_KEX_ECDH_NISTP256_SHA256:
  ------------------
  |  Branch (1744:5): [True: 0, False: 28]
  ------------------
 1745|     12|    case SSH_GSS_KEX_CURVE25519_SHA256:
  ------------------
  |  Branch (1745:5): [True: 0, False: 28]
  ------------------
 1746|     12|#ifdef WITH_GEX
 1747|     12|    case SSH_KEX_DH_GEX_SHA256:
  ------------------
  |  Branch (1747:5): [True: 0, False: 28]
  ------------------
 1748|     12|#endif /* WITH_GEX */
 1749|     12|        session->next_crypto->digest_len = SHA256_DIGEST_LENGTH;
 1750|     12|        session->next_crypto->digest_type = SSH_KDF_SHA256;
 1751|     12|        session->next_crypto->secret_hash = malloc(session->next_crypto->digest_len);
 1752|     12|        if (session->next_crypto->secret_hash == NULL) {
  ------------------
  |  Branch (1752:13): [True: 0, False: 12]
  ------------------
 1753|      0|            ssh_set_error_oom(session);
  ------------------
  |  |  320|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
 1754|      0|            goto error;
 1755|      0|        }
 1756|     12|        sha256(ssh_buffer_get(buf), ssh_buffer_get_len(buf),
 1757|     12|                                     session->next_crypto->secret_hash);
 1758|     12|        break;
 1759|      0|    case SSH_KEX_ECDH_SHA2_NISTP384:
  ------------------
  |  Branch (1759:5): [True: 0, False: 28]
  ------------------
 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);
  ------------------
  |  |  320|      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: 28]
  ------------------
 1774|      0|    case SSH_GSS_KEX_DH_GROUP16_SHA512:
  ------------------
  |  Branch (1774:5): [True: 0, False: 28]
  ------------------
 1775|     16|    case SSH_KEX_DH_GROUP18_SHA512:
  ------------------
  |  Branch (1775:5): [True: 16, False: 12]
  ------------------
 1776|     16|    case SSH_KEX_ECDH_SHA2_NISTP521:
  ------------------
  |  Branch (1776:5): [True: 0, False: 28]
  ------------------
 1777|     16|    case SSH_KEX_SNTRUP761X25519_SHA512:
  ------------------
  |  Branch (1777:5): [True: 0, False: 28]
  ------------------
 1778|     16|    case SSH_KEX_SNTRUP761X25519_SHA512_OPENSSH_COM:
  ------------------
  |  Branch (1778:5): [True: 0, False: 28]
  ------------------
 1779|     16|        session->next_crypto->digest_len = SHA512_DIGEST_LENGTH;
 1780|     16|        session->next_crypto->digest_type = SSH_KDF_SHA512;
 1781|     16|        session->next_crypto->secret_hash = malloc(session->next_crypto->digest_len);
 1782|     16|        if (session->next_crypto->secret_hash == NULL) {
  ------------------
  |  Branch (1782:13): [True: 0, False: 16]
  ------------------
 1783|      0|            ssh_set_error_oom(session);
  ------------------
  |  |  320|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
 1784|      0|            goto error;
 1785|      0|        }
 1786|     16|        sha512(ssh_buffer_get(buf),
 1787|     16|               ssh_buffer_get_len(buf),
 1788|     16|               session->next_crypto->secret_hash);
 1789|     16|        break;
 1790|      0|    default:
  ------------------
  |  Branch (1790:5): [True: 0, False: 28]
  ------------------
 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");
  ------------------
  |  |  313|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
 1793|      0|        rc = SSH_ERROR;
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 1794|      0|        goto error;
 1795|     28|    }
 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|     28|    if (!session->next_crypto->session_id) {
  ------------------
  |  Branch (1801:9): [True: 28, False: 0]
  ------------------
 1802|     28|        session->next_crypto->session_id = malloc(session->next_crypto->digest_len);
 1803|     28|        if (session->next_crypto->session_id == NULL) {
  ------------------
  |  Branch (1803:13): [True: 0, False: 28]
  ------------------
 1804|      0|            ssh_set_error_oom(session);
  ------------------
  |  |  320|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
 1805|      0|            rc = SSH_ERROR;
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 1806|      0|            goto error;
 1807|      0|        }
 1808|     28|        memcpy(session->next_crypto->session_id, session->next_crypto->secret_hash,
 1809|     28|                session->next_crypto->digest_len);
 1810|       |	/* Initial length is the same as secret hash */
 1811|     28|	session->next_crypto->session_id_len = session->next_crypto->digest_len;
 1812|     28|    }
 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|     28|    rc = SSH_OK;
  ------------------
  |  |  315|     28|#define SSH_OK 0     /* No error */
  ------------------
 1820|     28|error:
 1821|     28|    SSH_BUFFER_FREE(buf);
  ------------------
  |  |  924|     28|    do { if ((x) != NULL) { ssh_buffer_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (924:14): [True: 28, False: 0]
  |  |  |  Branch (924:69): [Folded, False: 28]
  |  |  ------------------
  ------------------
 1822|     28|    SSH_BUFFER_FREE(client_hash);
  ------------------
  |  |  924|     28|    do { if ((x) != NULL) { ssh_buffer_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (924:14): [True: 28, False: 0]
  |  |  |  Branch (924:69): [Folded, False: 28]
  |  |  ------------------
  ------------------
 1823|     28|    SSH_BUFFER_FREE(server_hash);
  ------------------
  |  |  924|     28|    do { if ((x) != NULL) { ssh_buffer_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (924:14): [True: 28, False: 0]
  |  |  |  Branch (924:69): [Folded, False: 28]
  |  |  ------------------
  ------------------
 1824|       |
 1825|     28|    session->in_hashbuf = NULL;
 1826|     28|    session->out_hashbuf = NULL;
 1827|       |
 1828|     28|    SSH_STRING_FREE(num);
  ------------------
  |  |  882|     28|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (882:14): [True: 0, False: 28]
  |  |  |  Branch (882:69): [Folded, False: 28]
  |  |  ------------------
  ------------------
 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|     28|    return rc;
 1835|     28|}
ssh_hashbufout_add_cookie:
 1838|    412|{
 1839|    412|    int rc;
 1840|       |
 1841|    412|    session->out_hashbuf = ssh_buffer_new();
 1842|    412|    if (session->out_hashbuf == NULL) {
  ------------------
  |  Branch (1842:9): [True: 0, False: 412]
  ------------------
 1843|      0|        return -1;
 1844|      0|    }
 1845|       |
 1846|    412|    rc = ssh_buffer_allocate_size(session->out_hashbuf,
 1847|    412|            sizeof(uint8_t) + 16);
 1848|    412|    if (rc < 0) {
  ------------------
  |  Branch (1848:9): [True: 0, False: 412]
  ------------------
 1849|      0|        ssh_buffer_reinit(session->out_hashbuf);
 1850|      0|        return -1;
 1851|      0|    }
 1852|       |
 1853|    412|    if (ssh_buffer_add_u8(session->out_hashbuf, 20) < 0) {
  ------------------
  |  Branch (1853:9): [True: 0, False: 412]
  ------------------
 1854|      0|        ssh_buffer_reinit(session->out_hashbuf);
 1855|      0|        return -1;
 1856|      0|    }
 1857|       |
 1858|    412|    if (session->server) {
  ------------------
  |  Branch (1858:9): [True: 0, False: 412]
  ------------------
 1859|      0|        if (ssh_buffer_add_data(session->out_hashbuf,
  ------------------
  |  Branch (1859:13): [True: 0, False: 0]
  ------------------
 1860|      0|                    session->next_crypto->server_kex.cookie, 16) < 0) {
 1861|      0|            ssh_buffer_reinit(session->out_hashbuf);
 1862|      0|            return -1;
 1863|      0|        }
 1864|    412|    } else {
 1865|    412|        if (ssh_buffer_add_data(session->out_hashbuf,
  ------------------
  |  Branch (1865:13): [True: 0, False: 412]
  ------------------
 1866|    412|                    session->next_crypto->client_kex.cookie, 16) < 0) {
 1867|      0|            ssh_buffer_reinit(session->out_hashbuf);
 1868|      0|            return -1;
 1869|      0|        }
 1870|    412|    }
 1871|       |
 1872|    412|    return 0;
 1873|    412|}
ssh_hashbufin_add_cookie:
 1876|    262|{
 1877|    262|    int rc;
 1878|       |
 1879|    262|    session->in_hashbuf = ssh_buffer_new();
 1880|    262|    if (session->in_hashbuf == NULL) {
  ------------------
  |  Branch (1880:9): [True: 0, False: 262]
  ------------------
 1881|      0|        return -1;
 1882|      0|    }
 1883|       |
 1884|    262|    rc = ssh_buffer_allocate_size(session->in_hashbuf,
 1885|    262|            sizeof(uint8_t) + 20 + 16);
 1886|    262|    if (rc < 0) {
  ------------------
  |  Branch (1886:9): [True: 0, False: 262]
  ------------------
 1887|      0|        ssh_buffer_reinit(session->in_hashbuf);
 1888|      0|        return -1;
 1889|      0|    }
 1890|       |
 1891|    262|    if (ssh_buffer_add_u8(session->in_hashbuf, 20) < 0) {
  ------------------
  |  Branch (1891:9): [True: 0, False: 262]
  ------------------
 1892|      0|        ssh_buffer_reinit(session->in_hashbuf);
 1893|      0|        return -1;
 1894|      0|    }
 1895|    262|    if (ssh_buffer_add_data(session->in_hashbuf,cookie, 16) < 0) {
  ------------------
  |  Branch (1895:9): [True: 0, False: 262]
  ------------------
 1896|      0|        ssh_buffer_reinit(session->in_hashbuf);
 1897|      0|        return -1;
 1898|      0|    }
 1899|       |
 1900|    262|    return 0;
 1901|    262|}
ssh_generate_session_keys:
 1904|     28|{
 1905|     28|    ssh_string k_string = NULL;
 1906|     28|    struct ssh_crypto_struct *crypto = session->next_crypto;
 1907|     28|    unsigned char *key = NULL;
 1908|     28|    unsigned char *IV_cli_to_srv = NULL;
 1909|     28|    unsigned char *IV_srv_to_cli = NULL;
 1910|     28|    unsigned char *enckey_cli_to_srv = NULL;
 1911|     28|    unsigned char *enckey_srv_to_cli = NULL;
 1912|     28|    unsigned char *intkey_cli_to_srv = NULL;
 1913|     28|    unsigned char *intkey_srv_to_cli = NULL;
 1914|     28|    size_t key_len = 0;
 1915|     28|    size_t IV_len = 0;
 1916|     28|    size_t enckey_cli_to_srv_len = 0;
 1917|     28|    size_t enckey_srv_to_cli_len = 0;
 1918|     28|    size_t intkey_cli_to_srv_len = 0;
 1919|     28|    size_t intkey_srv_to_cli_len = 0;
 1920|     28|    int rc = -1;
 1921|       |
 1922|     28|    switch (session->next_crypto->kex_type) {
 1923|      0|    case SSH_KEX_SNTRUP761X25519_SHA512:
  ------------------
  |  Branch (1923:5): [True: 0, False: 28]
  ------------------
 1924|      0|    case SSH_KEX_SNTRUP761X25519_SHA512_OPENSSH_COM:
  ------------------
  |  Branch (1924:5): [True: 0, False: 28]
  ------------------
 1925|      0|    case SSH_KEX_MLKEM768X25519_SHA256:
  ------------------
  |  Branch (1925:5): [True: 0, False: 28]
  ------------------
 1926|      0|    case SSH_KEX_MLKEM768NISTP256_SHA256:
  ------------------
  |  Branch (1926:5): [True: 0, False: 28]
  ------------------
 1927|       |#ifdef HAVE_MLKEM1024
 1928|       |    case SSH_KEX_MLKEM1024NISTP384_SHA384:
 1929|       |#endif
 1930|      0|        k_string = ssh_string_copy(crypto->hybrid_shared_secret);
 1931|      0|        break;
 1932|     28|    default:
  ------------------
  |  Branch (1932:5): [True: 28, False: 0]
  ------------------
 1933|     28|        k_string = ssh_make_bignum_string(crypto->shared_secret);
 1934|     28|        break;
 1935|     28|    }
 1936|     28|    if (k_string == NULL) {
  ------------------
  |  Branch (1936:9): [True: 0, False: 28]
  ------------------
 1937|      0|        ssh_set_error_oom(session);
  ------------------
  |  |  320|      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|     28|    key = (unsigned char *)k_string;
 1943|     28|    key_len = ssh_string_len(k_string) + 4;
 1944|       |
 1945|     28|    IV_len = crypto->digest_len;
 1946|     28|    if (session->client) {
  ------------------
  |  Branch (1946:9): [True: 28, False: 0]
  ------------------
 1947|     28|        enckey_cli_to_srv_len = crypto->out_cipher->keysize / 8;
 1948|     28|        enckey_srv_to_cli_len = crypto->in_cipher->keysize / 8;
 1949|     28|        intkey_cli_to_srv_len = hmac_digest_len(crypto->out_hmac);
 1950|     28|        intkey_srv_to_cli_len = hmac_digest_len(crypto->in_hmac);
 1951|     28|    } else {
 1952|      0|        enckey_cli_to_srv_len = crypto->in_cipher->keysize / 8;
 1953|      0|        enckey_srv_to_cli_len = crypto->out_cipher->keysize / 8;
 1954|      0|        intkey_cli_to_srv_len = hmac_digest_len(crypto->in_hmac);
 1955|      0|        intkey_srv_to_cli_len = hmac_digest_len(crypto->out_hmac);
 1956|      0|    }
 1957|       |
 1958|     28|    IV_cli_to_srv = malloc(IV_len);
 1959|     28|    IV_srv_to_cli = malloc(IV_len);
 1960|     28|    enckey_cli_to_srv = malloc(enckey_cli_to_srv_len);
 1961|     28|    enckey_srv_to_cli = malloc(enckey_srv_to_cli_len);
 1962|     28|    intkey_cli_to_srv = malloc(intkey_cli_to_srv_len);
 1963|     28|    intkey_srv_to_cli = malloc(intkey_srv_to_cli_len);
 1964|     28|    if (IV_cli_to_srv == NULL || IV_srv_to_cli == NULL ||
  ------------------
  |  Branch (1964:9): [True: 0, False: 28]
  |  Branch (1964:34): [True: 0, False: 28]
  ------------------
 1965|     28|        enckey_cli_to_srv == NULL || enckey_srv_to_cli == NULL ||
  ------------------
  |  Branch (1965:9): [True: 0, False: 28]
  |  Branch (1965:38): [True: 0, False: 28]
  ------------------
 1966|     28|        intkey_cli_to_srv == NULL || intkey_srv_to_cli == NULL) {
  ------------------
  |  Branch (1966:9): [True: 0, False: 28]
  |  Branch (1966:38): [True: 0, False: 28]
  ------------------
 1967|      0|        ssh_set_error_oom(session);
  ------------------
  |  |  320|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
 1968|      0|        goto error;
 1969|      0|    }
 1970|       |
 1971|       |    /* IV */
 1972|     28|    rc = ssh_kdf(crypto, key, key_len, 'A', IV_cli_to_srv, IV_len);
 1973|     28|    if (rc < 0) {
  ------------------
  |  Branch (1973:9): [True: 0, False: 28]
  ------------------
 1974|      0|        goto error;
 1975|      0|    }
 1976|     28|    rc = ssh_kdf(crypto, key, key_len, 'B', IV_srv_to_cli, IV_len);
 1977|     28|    if (rc < 0) {
  ------------------
  |  Branch (1977:9): [True: 0, False: 28]
  ------------------
 1978|      0|        goto error;
 1979|      0|    }
 1980|       |    /* Encryption Key */
 1981|     28|    rc = ssh_kdf(crypto, key, key_len, 'C', enckey_cli_to_srv,
 1982|     28|                 enckey_cli_to_srv_len);
 1983|     28|    if (rc < 0) {
  ------------------
  |  Branch (1983:9): [True: 0, False: 28]
  ------------------
 1984|      0|        goto error;
 1985|      0|    }
 1986|     28|    rc = ssh_kdf(crypto, key, key_len, 'D', enckey_srv_to_cli,
 1987|     28|                 enckey_srv_to_cli_len);
 1988|     28|    if (rc < 0) {
  ------------------
  |  Branch (1988:9): [True: 0, False: 28]
  ------------------
 1989|      0|        goto error;
 1990|      0|    }
 1991|       |    /* Integrity Key */
 1992|     28|    rc = ssh_kdf(crypto, key, key_len, 'E', intkey_cli_to_srv,
 1993|     28|                 intkey_cli_to_srv_len);
 1994|     28|    if (rc < 0) {
  ------------------
  |  Branch (1994:9): [True: 0, False: 28]
  ------------------
 1995|      0|        goto error;
 1996|      0|    }
 1997|     28|    rc = ssh_kdf(crypto, key, key_len, 'F', intkey_srv_to_cli,
 1998|     28|                 intkey_srv_to_cli_len);
 1999|     28|    if (rc < 0) {
  ------------------
  |  Branch (1999:9): [True: 0, False: 28]
  ------------------
 2000|      0|        goto error;
 2001|      0|    }
 2002|       |
 2003|     28|    if (session->client) {
  ------------------
  |  Branch (2003:9): [True: 28, False: 0]
  ------------------
 2004|     28|        crypto->encryptIV = IV_cli_to_srv;
 2005|     28|        crypto->decryptIV = IV_srv_to_cli;
 2006|     28|        crypto->encryptkey = enckey_cli_to_srv;
 2007|     28|        crypto->decryptkey = enckey_srv_to_cli;
 2008|     28|        crypto->encryptMAC = intkey_cli_to_srv;
 2009|     28|        crypto->decryptMAC = intkey_srv_to_cli;
 2010|     28|    } else {
 2011|      0|        crypto->encryptIV = IV_srv_to_cli;
 2012|      0|        crypto->decryptIV = IV_cli_to_srv;
 2013|      0|        crypto->encryptkey = enckey_srv_to_cli;
 2014|      0|        crypto->decryptkey = enckey_cli_to_srv;
 2015|      0|        crypto->encryptMAC = intkey_srv_to_cli;
 2016|      0|        crypto->decryptMAC = intkey_cli_to_srv;
 2017|      0|    }
 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|     28|    rc = 0;
 2033|     28|error:
 2034|     28|    ssh_string_burn(k_string);
 2035|     28|    SSH_STRING_FREE(k_string);
  ------------------
  |  |  882|     28|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (882:14): [True: 28, False: 0]
  |  |  |  Branch (882:69): [Folded, False: 28]
  |  |  ------------------
  ------------------
 2036|     28|    if (rc != 0) {
  ------------------
  |  Branch (2036:9): [True: 0, False: 28]
  ------------------
 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|     28|    return rc;
 2046|     28|}
kex.c:cmp_first_kex_algo:
  361|    154|                              const char *server_str) {
  362|    154|    size_t client_kex_len;
  363|    154|    size_t server_kex_len;
  364|       |
  365|    154|    const char *colon = NULL;
  366|       |
  367|    154|    int is_wrong = 1;
  368|       |
  369|    154|    if (client_str == NULL || server_str == NULL) {
  ------------------
  |  Branch (369:9): [True: 0, False: 154]
  |  Branch (369:31): [True: 0, False: 154]
  ------------------
  370|      0|        return is_wrong;
  371|      0|    }
  372|       |
  373|    154|    colon = strchr(client_str, ',');
  374|    154|    if (colon == NULL) {
  ------------------
  |  Branch (374:9): [True: 0, False: 154]
  ------------------
  375|      0|        client_kex_len = strlen(client_str);
  376|    154|    } else {
  377|    154|        client_kex_len = colon - client_str;
  378|    154|    }
  379|       |
  380|    154|    colon = strchr(server_str, ',');
  381|    154|    if (colon == NULL) {
  ------------------
  |  Branch (381:9): [True: 10, False: 144]
  ------------------
  382|     10|        server_kex_len = strlen(server_str);
  383|    144|    } else {
  384|    144|        server_kex_len = colon - server_str;
  385|    144|    }
  386|       |
  387|    154|    if (client_kex_len != server_kex_len) {
  ------------------
  |  Branch (387:9): [True: 140, False: 14]
  ------------------
  388|    140|        return is_wrong;
  389|    140|    }
  390|       |
  391|     14|    is_wrong = (strncmp(client_str, server_str, client_kex_len) != 0);
  392|       |
  393|     14|    return is_wrong;
  394|    154|}
kex.c:ssh_find_aead_hmac:
  952|    335|{
  953|    335|    if (cipher == NULL) {
  ------------------
  |  Branch (953:9): [True: 0, False: 335]
  ------------------
  954|      0|        return NULL;
  955|    335|    } else if (strcmp(cipher, "chacha20-poly1305@openssh.com") == 0) {
  ------------------
  |  Branch (955:16): [True: 0, False: 335]
  ------------------
  956|      0|        return "aead-poly1305";
  957|    335|    } else if (strcmp(cipher, "aes256-gcm@openssh.com") == 0) {
  ------------------
  |  Branch (957:16): [True: 0, False: 335]
  ------------------
  958|      0|        return "aead-gcm";
  959|    335|    } else if (strcmp(cipher, "aes128-gcm@openssh.com") == 0) {
  ------------------
  |  Branch (959:16): [True: 0, False: 335]
  ------------------
  960|      0|        return "aead-gcm";
  961|      0|    }
  962|    335|    return NULL;
  963|    335|}
kex.c:kex_select_kex_type:
  967|    166|{
  968|    166|    if (strcmp(kex, "diffie-hellman-group1-sha1") == 0) {
  ------------------
  |  Branch (968:9): [True: 0, False: 166]
  ------------------
  969|      0|        return SSH_KEX_DH_GROUP1_SHA1;
  970|    166|    } else if (strncmp(kex, "gss-group14-sha256-", 19) == 0) {
  ------------------
  |  Branch (970:16): [True: 0, False: 166]
  ------------------
  971|      0|        return SSH_GSS_KEX_DH_GROUP14_SHA256;
  972|    166|    } else if (strncmp(kex, "gss-group16-sha512-", 19) == 0) {
  ------------------
  |  Branch (972:16): [True: 0, False: 166]
  ------------------
  973|      0|        return SSH_GSS_KEX_DH_GROUP16_SHA512;
  974|    166|    } else if (strncmp(kex, "gss-nistp256-sha256-", 20) == 0) {
  ------------------
  |  Branch (974:16): [True: 0, False: 166]
  ------------------
  975|      0|        return SSH_GSS_KEX_ECDH_NISTP256_SHA256;
  976|    166|    } else if (strncmp(kex, "gss-curve25519-sha256-", 22) == 0) {
  ------------------
  |  Branch (976:16): [True: 0, False: 166]
  ------------------
  977|      0|        return SSH_GSS_KEX_CURVE25519_SHA256;
  978|    166|    } else if (strcmp(kex, "diffie-hellman-group14-sha1") == 0) {
  ------------------
  |  Branch (978:16): [True: 0, False: 166]
  ------------------
  979|      0|        return SSH_KEX_DH_GROUP14_SHA1;
  980|    166|    } else if (strcmp(kex, "diffie-hellman-group14-sha256") == 0) {
  ------------------
  |  Branch (980:16): [True: 4, False: 162]
  ------------------
  981|      4|        return SSH_KEX_DH_GROUP14_SHA256;
  982|    162|    } else if (strcmp(kex, "diffie-hellman-group16-sha512") == 0) {
  ------------------
  |  Branch (982:16): [True: 1, False: 161]
  ------------------
  983|      1|        return SSH_KEX_DH_GROUP16_SHA512;
  984|    161|    } else if (strcmp(kex, "diffie-hellman-group18-sha512") == 0) {
  ------------------
  |  Branch (984:16): [True: 18, False: 143]
  ------------------
  985|     18|        return SSH_KEX_DH_GROUP18_SHA512;
  986|     18|#ifdef WITH_GEX
  987|    143|    } else if (strcmp(kex, "diffie-hellman-group-exchange-sha1") == 0) {
  ------------------
  |  Branch (987:16): [True: 0, False: 143]
  ------------------
  988|      0|        return SSH_KEX_DH_GEX_SHA1;
  989|    143|    } else if (strcmp(kex, "diffie-hellman-group-exchange-sha256") == 0) {
  ------------------
  |  Branch (989:16): [True: 3, False: 140]
  ------------------
  990|      3|        return SSH_KEX_DH_GEX_SHA256;
  991|      3|#endif /* WITH_GEX */
  992|    140|    } else if (strcmp(kex, "ecdh-sha2-nistp256") == 0) {
  ------------------
  |  Branch (992:16): [True: 4, False: 136]
  ------------------
  993|      4|        return SSH_KEX_ECDH_SHA2_NISTP256;
  994|    136|    } else if (strcmp(kex, "ecdh-sha2-nistp384") == 0) {
  ------------------
  |  Branch (994:16): [True: 1, False: 135]
  ------------------
  995|      1|        return SSH_KEX_ECDH_SHA2_NISTP384;
  996|    135|    } else if (strcmp(kex, "ecdh-sha2-nistp521") == 0) {
  ------------------
  |  Branch (996:16): [True: 3, False: 132]
  ------------------
  997|      3|        return SSH_KEX_ECDH_SHA2_NISTP521;
  998|    132|    } else if (strcmp(kex, "curve25519-sha256@libssh.org") == 0) {
  ------------------
  |  Branch (998:16): [True: 3, False: 129]
  ------------------
  999|      3|        return SSH_KEX_CURVE25519_SHA256_LIBSSH_ORG;
 1000|    129|    } else if (strcmp(kex, "curve25519-sha256") == 0) {
  ------------------
  |  Branch (1000:16): [True: 14, False: 115]
  ------------------
 1001|     14|        return SSH_KEX_CURVE25519_SHA256;
 1002|    115|    } else if (strcmp(kex, "sntrup761x25519-sha512@openssh.com") == 0) {
  ------------------
  |  Branch (1002:16): [True: 65, False: 50]
  ------------------
 1003|     65|        return SSH_KEX_SNTRUP761X25519_SHA512_OPENSSH_COM;
 1004|     65|    } else if (strcmp(kex, "sntrup761x25519-sha512") == 0) {
  ------------------
  |  Branch (1004:16): [True: 1, False: 49]
  ------------------
 1005|      1|        return SSH_KEX_SNTRUP761X25519_SHA512;
 1006|     49|    } else if (strcmp(kex, "mlkem768x25519-sha256") == 0) {
  ------------------
  |  Branch (1006:16): [True: 0, False: 49]
  ------------------
 1007|      0|        return SSH_KEX_MLKEM768X25519_SHA256;
 1008|     49|    } else if (strcmp(kex, "mlkem768nistp256-sha256") == 0) {
  ------------------
  |  Branch (1008:16): [True: 49, False: 0]
  ------------------
 1009|     49|        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|     49|    }
 1015|       |    /* should not happen. We should be getting only valid names at this stage */
 1016|      0|    return 0;
 1017|    166|}
kex.c:revert_kex_callbacks:
 1026|    126|{
 1027|    126|    switch (session->next_crypto->kex_type) {
  ------------------
  |  Branch (1027:13): [True: 0, False: 126]
  ------------------
 1028|      0|    case SSH_KEX_DH_GROUP1_SHA1:
  ------------------
  |  Branch (1028:5): [True: 0, False: 126]
  ------------------
 1029|      0|    case SSH_KEX_DH_GROUP14_SHA1:
  ------------------
  |  Branch (1029:5): [True: 0, False: 126]
  ------------------
 1030|      0|    case SSH_KEX_DH_GROUP14_SHA256:
  ------------------
  |  Branch (1030:5): [True: 0, False: 126]
  ------------------
 1031|      0|    case SSH_KEX_DH_GROUP16_SHA512:
  ------------------
  |  Branch (1031:5): [True: 0, False: 126]
  ------------------
 1032|      0|    case SSH_KEX_DH_GROUP18_SHA512:
  ------------------
  |  Branch (1032:5): [True: 0, False: 126]
  ------------------
 1033|      0|        ssh_client_dh_remove_callbacks(session);
 1034|      0|        break;
 1035|      0|    case SSH_GSS_KEX_DH_GROUP14_SHA256:
  ------------------
  |  Branch (1035:5): [True: 0, False: 126]
  ------------------
 1036|      0|    case SSH_GSS_KEX_DH_GROUP16_SHA512:
  ------------------
  |  Branch (1036:5): [True: 0, False: 126]
  ------------------
 1037|      0|    case SSH_GSS_KEX_ECDH_NISTP256_SHA256:
  ------------------
  |  Branch (1037:5): [True: 0, False: 126]
  ------------------
 1038|      0|    case SSH_GSS_KEX_CURVE25519_SHA256:
  ------------------
  |  Branch (1038:5): [True: 0, False: 126]
  ------------------
 1039|       |#ifdef WITH_GSSAPI
 1040|       |        ssh_client_gss_kex_remove_callbacks(session);
 1041|       |#endif /* WITH_GSSAPI */
 1042|      0|        break;
 1043|      0|#ifdef WITH_GEX
 1044|      0|    case SSH_KEX_DH_GEX_SHA1:
  ------------------
  |  Branch (1044:5): [True: 0, False: 126]
  ------------------
 1045|      0|    case SSH_KEX_DH_GEX_SHA256:
  ------------------
  |  Branch (1045:5): [True: 0, False: 126]
  ------------------
 1046|      0|        ssh_client_dhgex_remove_callbacks(session);
 1047|      0|        break;
 1048|      0|#endif /* WITH_GEX */
 1049|      0|#ifdef HAVE_ECDH
 1050|      0|    case SSH_KEX_ECDH_SHA2_NISTP256:
  ------------------
  |  Branch (1050:5): [True: 0, False: 126]
  ------------------
 1051|      0|    case SSH_KEX_ECDH_SHA2_NISTP384:
  ------------------
  |  Branch (1051:5): [True: 0, False: 126]
  ------------------
 1052|      0|    case SSH_KEX_ECDH_SHA2_NISTP521:
  ------------------
  |  Branch (1052:5): [True: 0, False: 126]
  ------------------
 1053|      0|        ssh_client_ecdh_remove_callbacks(session);
 1054|      0|        break;
 1055|      0|#endif
 1056|      0|#ifdef HAVE_CURVE25519
 1057|      0|    case SSH_KEX_CURVE25519_SHA256:
  ------------------
  |  Branch (1057:5): [True: 0, False: 126]
  ------------------
 1058|      0|    case SSH_KEX_CURVE25519_SHA256_LIBSSH_ORG:
  ------------------
  |  Branch (1058:5): [True: 0, False: 126]
  ------------------
 1059|      0|        ssh_client_curve25519_remove_callbacks(session);
 1060|      0|        break;
 1061|      0|#endif
 1062|      0|#ifdef HAVE_SNTRUP761
 1063|      0|    case SSH_KEX_SNTRUP761X25519_SHA512:
  ------------------
  |  Branch (1063:5): [True: 0, False: 126]
  ------------------
 1064|      0|    case SSH_KEX_SNTRUP761X25519_SHA512_OPENSSH_COM:
  ------------------
  |  Branch (1064:5): [True: 0, False: 126]
  ------------------
 1065|      0|        ssh_client_sntrup761x25519_remove_callbacks(session);
 1066|      0|        break;
 1067|      0|#endif
 1068|      0|    case SSH_KEX_MLKEM768X25519_SHA256:
  ------------------
  |  Branch (1068:5): [True: 0, False: 126]
  ------------------
 1069|      0|    case SSH_KEX_MLKEM768NISTP256_SHA256:
  ------------------
  |  Branch (1069:5): [True: 0, False: 126]
  ------------------
 1070|       |#ifdef HAVE_MLKEM1024
 1071|       |    case SSH_KEX_MLKEM1024NISTP384_SHA384:
 1072|       |#endif
 1073|      0|        ssh_client_hybrid_mlkem_remove_callbacks(session);
 1074|      0|        break;
 1075|    126|    }
 1076|    126|}

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

ssh_kdf:
  337|    168|{
  338|    168|    return sshkdf_derive_key(crypto, key, key_len,
  339|    168|                             key_type, output, requested_len);
  340|    168|}
ssh_get_ciphertab:
 1382|     84|{
 1383|     84|    return ssh_ciphertab;
 1384|     84|}
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;
  ------------------
  |  |  315|      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,
  ------------------
  |  |  283|      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;
  ------------------
  |  |  315|      2|#define SSH_OK 0     /* No error */
  ------------------
 1435|      2|}
pki_key_make_ecpoint_string:
 1621|     57|{
 1622|     57|    ssh_string s = NULL;
 1623|     57|    size_t len;
 1624|       |
 1625|     57|    len = EC_POINT_point2oct(g,
 1626|     57|                             p,
 1627|     57|                             POINT_CONVERSION_UNCOMPRESSED,
 1628|     57|                             NULL,
 1629|     57|                             0,
 1630|     57|                             NULL);
 1631|     57|    if (len == 0) {
  ------------------
  |  Branch (1631:9): [True: 0, False: 57]
  ------------------
 1632|      0|        return NULL;
 1633|      0|    }
 1634|       |
 1635|     57|    s = ssh_string_new(len);
 1636|     57|    if (s == NULL) {
  ------------------
  |  Branch (1636:9): [True: 0, False: 57]
  ------------------
 1637|      0|        return NULL;
 1638|      0|    }
 1639|       |
 1640|     57|    len = EC_POINT_point2oct(g,
 1641|     57|                             p,
 1642|     57|                             POINT_CONVERSION_UNCOMPRESSED,
 1643|     57|                             ssh_string_data(s),
 1644|     57|                             ssh_string_len(s),
 1645|     57|                             NULL);
 1646|     57|    if (len != ssh_string_len(s)) {
  ------------------
  |  Branch (1646:9): [True: 0, False: 57]
  ------------------
 1647|      0|        SSH_STRING_FREE(s);
  ------------------
  |  |  882|      0|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (882:14): [True: 0, False: 0]
  |  |  |  Branch (882:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1648|      0|        return NULL;
 1649|      0|    }
 1650|       |
 1651|     57|    return s;
 1652|     57|}
libcrypto.c:none_crypt:
 1217|  1.70k|{
 1218|  1.70k|    memcpy(out, in, len);
 1219|  1.70k|}

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

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

sha256_init:
   97|     84|{
   98|     84|    int rc;
   99|     84|    SHA256CTX c = EVP_MD_CTX_new();
  100|     84|    if (c == NULL) {
  ------------------
  |  Branch (100:9): [True: 0, False: 84]
  ------------------
  101|      0|        return NULL;
  102|      0|    }
  103|     84|    rc = EVP_DigestInit_ex(c, EVP_sha256(), NULL);
  104|     84|    if (rc == 0) {
  ------------------
  |  Branch (104:9): [True: 0, False: 84]
  ------------------
  105|      0|        EVP_MD_CTX_free(c);
  106|       |        c = NULL;
  107|      0|    }
  108|     84|    return c;
  109|     84|}
sha256_update:
  119|    300|{
  120|    300|    int rc = EVP_DigestUpdate(c, data, len);
  121|    300|    if (rc != 1) {
  ------------------
  |  Branch (121:9): [True: 0, False: 300]
  ------------------
  122|      0|        return SSH_ERROR;
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  123|      0|    }
  124|    300|    return SSH_OK;
  ------------------
  |  |  315|    300|#define SSH_OK 0     /* No error */
  ------------------
  125|    300|}
sha256_final:
  129|     84|{
  130|     84|    unsigned int mdlen = 0;
  131|     84|    int rc = EVP_DigestFinal(c, md, &mdlen);
  132|       |
  133|     84|    EVP_MD_CTX_free(c);
  134|     84|    if (rc != 1) {
  ------------------
  |  Branch (134:9): [True: 0, False: 84]
  ------------------
  135|      0|        return SSH_ERROR;
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  136|      0|    }
  137|     84|    return SSH_OK;
  ------------------
  |  |  315|     84|#define SSH_OK 0     /* No error */
  ------------------
  138|     84|}
sha256:
  142|     12|{
  143|     12|    SHA256CTX c = sha256_init();
  144|     12|    int rc;
  145|       |
  146|     12|    if (c == NULL) {
  ------------------
  |  Branch (146:9): [True: 0, False: 12]
  ------------------
  147|      0|        return SSH_ERROR;
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  148|      0|    }
  149|     12|    rc = sha256_update(c, digest, len);
  150|     12|    if (rc != SSH_OK) {
  ------------------
  |  |  315|     12|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (150:9): [True: 0, False: 12]
  ------------------
  151|      0|        EVP_MD_CTX_free(c);
  152|      0|        return SSH_ERROR;
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  153|      0|    }
  154|     12|    return sha256_final(hash, c);
  155|     12|}
sha512_init:
  221|    178|{
  222|    178|    int rc = 0;
  223|    178|    SHA512CTX c = EVP_MD_CTX_new();
  224|    178|    if (c == NULL) {
  ------------------
  |  Branch (224:9): [True: 0, False: 178]
  ------------------
  225|      0|        return NULL;
  226|      0|    }
  227|    178|    rc = EVP_DigestInit_ex(c, EVP_sha512(), NULL);
  228|    178|    if (rc == 0) {
  ------------------
  |  Branch (228:9): [True: 0, False: 178]
  ------------------
  229|      0|        EVP_MD_CTX_free(c);
  230|       |        c = NULL;
  231|      0|    }
  232|    178|    return c;
  233|    178|}
sha512_update:
  243|    466|{
  244|    466|    int rc = EVP_DigestUpdate(c, data, len);
  245|    466|    if (rc != 1) {
  ------------------
  |  Branch (245:9): [True: 0, False: 466]
  ------------------
  246|      0|        return SSH_ERROR;
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  247|      0|    }
  248|    466|    return SSH_OK;
  ------------------
  |  |  315|    466|#define SSH_OK 0     /* No error */
  ------------------
  249|    466|}
sha512_final:
  253|    178|{
  254|    178|    unsigned int mdlen = 0;
  255|    178|    int rc = EVP_DigestFinal(c, md, &mdlen);
  256|       |
  257|    178|    EVP_MD_CTX_free(c);
  258|    178|    if (rc != 1) {
  ------------------
  |  Branch (258:9): [True: 0, False: 178]
  ------------------
  259|      0|        return SSH_ERROR;
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  260|      0|    }
  261|    178|    return SSH_OK;
  ------------------
  |  |  315|    178|#define SSH_OK 0     /* No error */
  ------------------
  262|    178|}
sha512:
  266|     82|{
  267|     82|    SHA512CTX c = sha512_init();
  268|     82|    int rc;
  269|       |
  270|     82|    if (c == NULL) {
  ------------------
  |  Branch (270:9): [True: 0, False: 82]
  ------------------
  271|      0|        return SSH_ERROR;
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  272|      0|    }
  273|     82|    rc = sha512_update(c, digest, len);
  274|     82|    if (rc != SSH_OK) {
  ------------------
  |  |  315|     82|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (274:9): [True: 0, False: 82]
  ------------------
  275|      0|        EVP_MD_CTX_free(c);
  276|      0|        return SSH_ERROR;
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  277|      0|    }
  278|     82|    return sha512_final(hash, c);
  279|     82|}

ssh_is_ipaddr_v4:
  423|  1.41k|{
  424|  1.41k|    int rc = -1;
  425|  1.41k|    struct in_addr dest;
  426|       |
  427|  1.41k|    rc = inet_pton(AF_INET, str, &dest);
  428|  1.41k|    if (rc > 0) {
  ------------------
  |  Branch (428:9): [True: 1.41k, False: 0]
  ------------------
  429|  1.41k|        return 1;
  430|  1.41k|    }
  431|       |
  432|      0|    return 0;
  433|  1.41k|}
ssh_is_ipaddr:
  443|  1.41k|{
  444|  1.41k|    int rc = -1;
  445|  1.41k|    char *s = strdup(str);
  446|       |
  447|  1.41k|    if (s == NULL) {
  ------------------
  |  Branch (447:9): [True: 0, False: 1.41k]
  ------------------
  448|      0|        return -1;
  449|      0|    }
  450|  1.41k|    if (strchr(s, ':')) {
  ------------------
  |  Branch (450:9): [True: 0, False: 1.41k]
  ------------------
  451|      0|        struct in6_addr dest6;
  452|      0|        char *network_interface = strchr(s, '%');
  453|       |
  454|       |        /* link-local (IP:v6:addr%ifname). */
  455|      0|        if (network_interface != NULL) {
  ------------------
  |  Branch (455:13): [True: 0, False: 0]
  ------------------
  456|      0|            rc = if_nametoindex(network_interface + 1);
  457|      0|            if (rc == 0) {
  ------------------
  |  Branch (457:17): [True: 0, False: 0]
  ------------------
  458|      0|                free(s);
  459|      0|                return 0;
  460|      0|            }
  461|      0|            *network_interface = '\0';
  462|      0|        }
  463|      0|        rc = inet_pton(AF_INET6, s, &dest6);
  464|      0|        if (rc > 0) {
  ------------------
  |  Branch (464:13): [True: 0, False: 0]
  ------------------
  465|      0|            free(s);
  466|      0|            return 1;
  467|      0|        }
  468|      0|    }
  469|       |
  470|  1.41k|    free(s);
  471|  1.41k|    return ssh_is_ipaddr_v4(str);
  472|  1.41k|}
ssh_get_user_home_dir:
  488|  2.36k|{
  489|  2.36k|    char *szPath = NULL;
  490|       |
  491|       |    /* If used previously, reuse cached value */
  492|  2.36k|    if (session != NULL && session->opts.homedir != NULL) {
  ------------------
  |  Branch (492:9): [True: 1.89k, False: 473]
  |  Branch (492:28): [True: 1.41k, False: 473]
  ------------------
  493|  1.41k|        return strdup(session->opts.homedir);
  494|  1.41k|    }
  495|       |
  496|    946|    szPath = ssh_get_user_home_dir_internal();
  497|    946|    if (szPath == NULL) {
  ------------------
  |  Branch (497:9): [True: 0, False: 946]
  ------------------
  498|      0|        return NULL;
  499|      0|    }
  500|       |
  501|    946|    if (session != NULL) {
  ------------------
  |  Branch (501:9): [True: 473, False: 473]
  ------------------
  502|       |        /* cache it:
  503|       |         * failure is not fatal -- at worst we will just not cache it */
  504|    473|        session->opts.homedir = strdup(szPath);
  505|    473|    }
  506|       |
  507|    946|    return szPath;
  508|    946|}
ssh_lowercase:
  519|    412|{
  520|    412|    char *new = NULL, *p = NULL;
  521|       |
  522|    412|    if (str == NULL) {
  ------------------
  |  Branch (522:9): [True: 0, False: 412]
  ------------------
  523|      0|        return NULL;
  524|      0|    }
  525|       |
  526|    412|    new = strdup(str);
  527|    412|    if (new == NULL) {
  ------------------
  |  Branch (527:9): [True: 0, False: 412]
  ------------------
  528|      0|        return NULL;
  529|      0|    }
  530|       |
  531|  4.12k|    for (p = new; *p; p++) {
  ------------------
  |  Branch (531:19): [True: 3.70k, False: 412]
  ------------------
  532|  3.70k|        *p = tolower(*p);
  ------------------
  |  Branch (532:14): [True: 0, False: 0]
  |  Branch (532:14): [True: 0, False: 0]
  |  Branch (532:14): [Folded, False: 3.70k]
  ------------------
  533|  3.70k|    }
  534|       |
  535|    412|    return new;
  536|    412|}
ssh_list_new:
  858|  2.30k|{
  859|  2.30k|    struct ssh_list *ret = malloc(sizeof(struct ssh_list));
  860|  2.30k|    if (ret == NULL) {
  ------------------
  |  Branch (860:9): [True: 1, False: 2.30k]
  ------------------
  861|      1|        return NULL;
  862|      1|    }
  863|  2.30k|    ret->root = ret->end = NULL;
  864|  2.30k|    return ret;
  865|  2.30k|}
ssh_list_free:
  875|  3.23k|{
  876|  3.23k|    struct ssh_iterator *ptr = NULL, *next = NULL;
  877|  3.23k|    if (!list)
  ------------------
  |  Branch (877:9): [True: 927, False: 2.30k]
  ------------------
  878|    927|        return;
  879|  2.30k|    ptr = list->root;
  880|  2.77k|    while (ptr) {
  ------------------
  |  Branch (880:12): [True: 468, False: 2.30k]
  ------------------
  881|    468|        next = ptr->next;
  882|    468|        SAFE_FREE(ptr);
  ------------------
  |  |  375|    468|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (375:31): [True: 468, False: 0]
  |  |  |  Branch (375:71): [Folded, False: 468]
  |  |  ------------------
  ------------------
  883|    468|        ptr = next;
  884|    468|    }
  885|       |    SAFE_FREE(list);
  ------------------
  |  |  375|  2.30k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (375:31): [True: 2.30k, False: 0]
  |  |  |  Branch (375:71): [Folded, False: 2.30k]
  |  |  ------------------
  ------------------
  886|  2.30k|}
ssh_list_get_iterator:
  896|  21.4k|{
  897|  21.4k|    if (!list)
  ------------------
  |  Branch (897:9): [True: 1.59k, False: 19.8k]
  ------------------
  898|  1.59k|        return NULL;
  899|  19.8k|    return list->root;
  900|  21.4k|}
ssh_list_find:
  911|    110|{
  912|    110|    struct ssh_iterator *it = NULL;
  913|       |
  914|    220|    for (it = ssh_list_get_iterator(list); it != NULL ; it = it->next)
  ------------------
  |  Branch (914:44): [True: 220, False: 0]
  ------------------
  915|    220|        if (it->data == value)
  ------------------
  |  Branch (915:13): [True: 110, False: 110]
  ------------------
  916|    110|            return it;
  917|      0|    return NULL;
  918|    110|}
ssh_list_append:
  962|  3.41k|{
  963|  3.41k|  struct ssh_iterator *iterator = NULL;
  964|       |
  965|  3.41k|  if (list == NULL) {
  ------------------
  |  Branch (965:7): [True: 0, False: 3.41k]
  ------------------
  966|      0|      return SSH_ERROR;
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  967|      0|  }
  968|       |
  969|  3.41k|  iterator = ssh_iterator_new(data);
  970|  3.41k|  if (iterator == NULL) {
  ------------------
  |  Branch (970:7): [True: 0, False: 3.41k]
  ------------------
  971|      0|      return SSH_ERROR;
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  972|      0|  }
  973|       |
  974|  3.41k|  if(!list->end){
  ------------------
  |  Branch (974:6): [True: 1.35k, False: 2.05k]
  ------------------
  975|       |    /* list is empty */
  976|  1.35k|    list->root=list->end=iterator;
  977|  2.05k|  } else {
  978|       |    /* put it on end of list */
  979|  2.05k|    list->end->next=iterator;
  980|  2.05k|    list->end=iterator;
  981|  2.05k|  }
  982|  3.41k|  return SSH_OK;
  ------------------
  |  |  315|  3.41k|#define SSH_OK 0     /* No error */
  ------------------
  983|  3.41k|}
ssh_list_remove:
 1025|    110|{
 1026|    110|    struct ssh_iterator *ptr = NULL, *prev = NULL;
 1027|       |
 1028|    110|    if (list == NULL) {
  ------------------
  |  Branch (1028:9): [True: 0, False: 110]
  ------------------
 1029|      0|        return;
 1030|      0|    }
 1031|       |
 1032|    110|    prev = NULL;
 1033|    110|    ptr = list->root;
 1034|    220|    while (ptr && ptr != iterator) {
  ------------------
  |  Branch (1034:12): [True: 220, False: 0]
  |  Branch (1034:19): [True: 110, False: 110]
  ------------------
 1035|    110|        prev = ptr;
 1036|    110|        ptr = ptr->next;
 1037|    110|    }
 1038|    110|    if (!ptr) {
  ------------------
  |  Branch (1038:9): [True: 0, False: 110]
  ------------------
 1039|       |        /* we did not find the element */
 1040|      0|        return;
 1041|      0|    }
 1042|       |    /* unlink it */
 1043|    110|    if (prev)
  ------------------
  |  Branch (1043:9): [True: 110, False: 0]
  ------------------
 1044|    110|        prev->next = ptr->next;
 1045|       |    /* if iterator was the head */
 1046|    110|    if (list->root == iterator)
  ------------------
  |  Branch (1046:9): [True: 0, False: 110]
  ------------------
 1047|      0|        list->root = iterator->next;
 1048|       |    /* if iterator was the tail */
 1049|    110|    if (list->end == iterator)
  ------------------
  |  Branch (1049:9): [True: 110, False: 0]
  ------------------
 1050|    110|        list->end = prev;
 1051|       |    SAFE_FREE(iterator);
  ------------------
  |  |  375|    110|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (375:31): [True: 110, False: 0]
  |  |  |  Branch (375:71): [Folded, False: 110]
  |  |  ------------------
  ------------------
 1052|    110|}
_ssh_list_pop_head:
 1066|  6.60k|{
 1067|  6.60k|  struct ssh_iterator *iterator = NULL;
 1068|  6.60k|  const void *data = NULL;
 1069|       |
 1070|  6.60k|  if (list == NULL) {
  ------------------
  |  Branch (1070:7): [True: 1.40k, False: 5.20k]
  ------------------
 1071|  1.40k|      return NULL;
 1072|  1.40k|  }
 1073|       |
 1074|  5.20k|  iterator = list->root;
 1075|  5.20k|  if (iterator == NULL) {
  ------------------
  |  Branch (1075:7): [True: 2.36k, False: 2.83k]
  ------------------
 1076|  2.36k|      return NULL;
 1077|  2.36k|  }
 1078|  2.83k|  data=iterator->data;
 1079|  2.83k|  list->root=iterator->next;
 1080|  2.83k|  if(list->end==iterator)
  ------------------
  |  Branch (1080:6): [True: 946, False: 1.89k]
  ------------------
 1081|    946|    list->end=NULL;
 1082|       |  SAFE_FREE(iterator);
  ------------------
  |  |  375|  2.83k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (375:31): [True: 2.83k, False: 0]
  |  |  |  Branch (375:71): [Folded, False: 2.83k]
  |  |  ------------------
  ------------------
 1083|  2.83k|  return data;
 1084|  5.20k|}
ssh_path_expand_tilde:
 1302|  2.36k|{
 1303|  2.36k|    char *h = NULL, *r = NULL;
 1304|  2.36k|    const char *p = NULL;
 1305|  2.36k|    size_t ld;
 1306|  2.36k|    size_t lh = 0;
 1307|  2.36k|    int add_slash = 0;
 1308|       |
 1309|  2.36k|    if (d[0] != '~') {
  ------------------
  |  Branch (1309:9): [True: 1.89k, False: 473]
  ------------------
 1310|  1.89k|        return strdup(d);
 1311|  1.89k|    }
 1312|    473|    d++;
 1313|       |
 1314|       |    /* handle ~user/path */
 1315|    473|    p = strchr(d, '/');
 1316|    473|    if (p != NULL && p > d) {
  ------------------
  |  Branch (1316:9): [True: 473, False: 0]
  |  Branch (1316:22): [True: 0, False: 473]
  ------------------
 1317|       |#ifdef _WIN32
 1318|       |        return strdup(d);
 1319|       |#else
 1320|      0|        struct passwd *pw = NULL;
 1321|      0|        size_t s = p - d;
 1322|      0|        char u[128];
 1323|       |
 1324|      0|        if (s >= sizeof(u)) {
  ------------------
  |  Branch (1324:13): [True: 0, False: 0]
  ------------------
 1325|      0|            return NULL;
 1326|      0|        }
 1327|      0|        memcpy(u, d, s);
 1328|      0|        u[s] = '\0';
 1329|      0|        pw = getpwnam(u);
 1330|      0|        if (pw == NULL) {
  ------------------
  |  Branch (1330:13): [True: 0, False: 0]
  ------------------
 1331|      0|            return NULL;
 1332|      0|        }
 1333|      0|        h = strdup(pw->pw_dir);
 1334|      0|#endif
 1335|    473|    } else {
 1336|    473|        p = (char *) d;
 1337|    473|        h = ssh_get_user_home_dir(NULL);
 1338|    473|    }
 1339|       |
 1340|    473|    if (h == NULL) {
  ------------------
  |  Branch (1340:9): [True: 0, False: 473]
  ------------------
 1341|      0|        return NULL;
 1342|      0|    }
 1343|    473|    lh = strlen(h);
 1344|       |
 1345|       |    /* Strip all leading slashes from the suffix path */
 1346|    946|    while (*p == '/') {
  ------------------
  |  Branch (1346:12): [True: 473, False: 473]
  ------------------
 1347|    473|        p++;
 1348|    473|    }
 1349|    473|    ld = strlen(p);
 1350|       |
 1351|       |    /* Does the home directory path end with a slash? */
 1352|    473|    add_slash = (lh > 0 && h[lh - 1] == '/') ? 0 : 1;
  ------------------
  |  Branch (1352:18): [True: 473, False: 0]
  |  Branch (1352:28): [True: 0, False: 473]
  ------------------
 1353|       |
 1354|    473|    r = malloc(lh + add_slash + ld + 1);
 1355|    473|    if (r == NULL) {
  ------------------
  |  Branch (1355:9): [True: 0, False: 473]
  ------------------
 1356|      0|        SAFE_FREE(h);
  ------------------
  |  |  375|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (375:31): [True: 0, False: 0]
  |  |  |  Branch (375:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1357|      0|        return NULL;
 1358|      0|    }
 1359|       |
 1360|    473|    if (lh > 0) {
  ------------------
  |  Branch (1360:9): [True: 473, False: 0]
  ------------------
 1361|    473|        memcpy(r, h, lh);
 1362|    473|    }
 1363|    473|    SAFE_FREE(h);
  ------------------
  |  |  375|    473|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (375:31): [True: 473, False: 0]
  |  |  |  Branch (375:71): [Folded, False: 473]
  |  |  ------------------
  ------------------
 1364|       |
 1365|    473|    if (add_slash) {
  ------------------
  |  Branch (1365:9): [True: 473, False: 0]
  ------------------
 1366|    473|        r[lh] = '/';
 1367|    473|    }
 1368|    473|    memcpy(r + lh + add_slash, p, ld + 1);
 1369|       |
 1370|    473|    return r;
 1371|    473|}
ssh_path_expand_escape:
 1708|  1.89k|{
 1709|  1.89k|    return ssh_path_expand_internal(session, s, false, true);
 1710|  1.89k|}
ssh_string_expand_escape:
 1713|    473|{
 1714|    473|    return ssh_path_expand_internal(session, s, false, false);
 1715|    473|}
ssh_analyze_banner:
 1748|    422|{
 1749|    422|    const char *banner = NULL;
 1750|    422|    const char *openssh = NULL;
 1751|    422|    const char *ios = NULL;
 1752|       |
 1753|    422|    if (server) {
  ------------------
  |  Branch (1753:9): [True: 0, False: 422]
  ------------------
 1754|      0|        banner = session->clientbanner;
 1755|    422|    } else {
 1756|    422|        banner = session->serverbanner;
 1757|    422|    }
 1758|       |
 1759|    422|    if (banner == NULL) {
  ------------------
  |  Branch (1759:9): [True: 0, False: 422]
  ------------------
 1760|      0|        ssh_set_error(session, SSH_FATAL, "Invalid banner");
  ------------------
  |  |  313|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
 1761|      0|        return -1;
 1762|      0|    }
 1763|       |
 1764|       |    /*
 1765|       |     * Typical banners e.g. are:
 1766|       |     *
 1767|       |     * SSH-1.5-openSSH_5.4
 1768|       |     * SSH-1.99-openSSH_3.0
 1769|       |     *
 1770|       |     * SSH-2.0-something
 1771|       |     * 012345678901234567890
 1772|       |     */
 1773|    422|    if (strlen(banner) < 6 ||
  ------------------
  |  Branch (1773:9): [True: 1, False: 421]
  ------------------
 1774|    421|        strncmp(banner, "SSH-", 4) != 0) {
  ------------------
  |  Branch (1774:9): [True: 0, False: 421]
  ------------------
 1775|      1|          ssh_set_error(session, SSH_FATAL, "Protocol mismatch: %s", banner);
  ------------------
  |  |  313|      1|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
 1776|      1|          return -1;
 1777|      1|    }
 1778|       |
 1779|    421|    SSH_LOG(SSH_LOG_DEBUG, "Analyzing banner: %s", banner);
  ------------------
  |  |  283|    421|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 1780|       |
 1781|    421|    switch (banner[4]) {
 1782|    404|        case '2':
  ------------------
  |  Branch (1782:9): [True: 404, False: 17]
  ------------------
 1783|    404|            break;
 1784|     15|        case '1':
  ------------------
  |  Branch (1784:9): [True: 15, False: 406]
  ------------------
 1785|     15|            if (strlen(banner) > 6) {
  ------------------
  |  Branch (1785:17): [True: 15, False: 0]
  ------------------
 1786|     15|                if (banner[6] == '9') {
  ------------------
  |  Branch (1786:21): [True: 8, False: 7]
  ------------------
 1787|      8|                    break;
 1788|      8|                }
 1789|     15|            }
 1790|      7|            FALL_THROUGH;
  ------------------
  |  |  496|      7|#  define FALL_THROUGH __attribute__ ((fallthrough))
  ------------------
 1791|      9|        default:
  ------------------
  |  Branch (1791:9): [True: 2, False: 419]
  ------------------
 1792|      9|            ssh_set_error(session, SSH_FATAL, "Protocol mismatch: %s", banner);
  ------------------
  |  |  313|      9|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
 1793|      9|            return -1;
 1794|    421|    }
 1795|       |
 1796|       |    /* Make a best-effort to extract OpenSSH version numbers. */
 1797|    412|    openssh = strstr(banner, "OpenSSH");
 1798|    412|    if (openssh != NULL) {
  ------------------
  |  Branch (1798:9): [True: 92, False: 320]
  ------------------
 1799|     92|        char *tmp = NULL;
 1800|     92|        unsigned long int major = 0UL;
 1801|     92|        unsigned long int minor = 0UL;
 1802|     92|        int off = 0;
 1803|       |
 1804|       |        /*
 1805|       |         * The banner is typical:
 1806|       |         * OpenSSH_5.4
 1807|       |         * 012345678901234567890
 1808|       |         */
 1809|     92|        if (strlen(openssh) > 9) {
  ------------------
  |  Branch (1809:13): [True: 91, False: 1]
  ------------------
 1810|     91|            errno = 0;
 1811|     91|            major = strtoul(openssh + 8, &tmp, 10);
 1812|     91|            if ((tmp == (openssh + 8)) ||
  ------------------
  |  Branch (1812:17): [True: 3, False: 88]
  ------------------
 1813|     88|                ((errno == ERANGE) && (major == ULONG_MAX)) ||
  ------------------
  |  Branch (1813:18): [True: 0, False: 88]
  |  Branch (1813:39): [True: 0, False: 0]
  ------------------
 1814|     88|                ((errno != 0) && (major == 0)) ||
  ------------------
  |  Branch (1814:18): [True: 0, False: 88]
  |  Branch (1814:34): [True: 0, False: 0]
  ------------------
 1815|     88|                ((major < 1) || (major > 100))) {
  ------------------
  |  Branch (1815:18): [True: 0, False: 88]
  |  Branch (1815:33): [True: 56, False: 32]
  ------------------
 1816|       |                /* invalid major */
 1817|     59|                errno = 0;
 1818|     59|                goto done;
 1819|     59|            }
 1820|       |
 1821|     91|            errno = 0;
 1822|     32|            off = major >= 10 ? 11 : 10;
  ------------------
  |  Branch (1822:19): [True: 6, False: 26]
  ------------------
 1823|     32|            minor = strtoul(openssh + off, &tmp, 10);
 1824|     32|            if ((tmp == (openssh + off)) ||
  ------------------
  |  Branch (1824:17): [True: 4, False: 28]
  ------------------
 1825|     28|                ((errno == ERANGE) && (major == ULONG_MAX)) ||
  ------------------
  |  Branch (1825:18): [True: 0, False: 28]
  |  Branch (1825:39): [True: 0, False: 0]
  ------------------
 1826|     28|                ((errno != 0) && (major == 0)) ||
  ------------------
  |  Branch (1826:18): [True: 0, False: 28]
  |  Branch (1826:34): [True: 0, False: 0]
  ------------------
 1827|     30|                (minor > 100)) {
  ------------------
  |  Branch (1827:17): [True: 26, False: 2]
  ------------------
 1828|       |                /* invalid minor */
 1829|     30|                errno = 0;
 1830|     30|                goto done;
 1831|     30|            }
 1832|       |
 1833|      2|            session->openssh = SSH_VERSION_INT(((int) major), ((int) minor), 0);
  ------------------
  |  |   25|      2|#define SSH_VERSION_INT(a, b, c) ((a) << 16 | (b) << 8 | (c))
  ------------------
 1834|       |
 1835|      2|            SSH_LOG(SSH_LOG_DEBUG,
  ------------------
  |  |  283|      4|    _ssh_log(priority, __func__, __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (283:34): [True: 0, False: 2]
  |  |  ------------------
  ------------------
 1836|      2|                    "We are talking to an OpenSSH %s version: %lu.%lu (%x)",
 1837|      2|                    server ? "client" : "server",
 1838|      2|                    major, minor, session->openssh);
 1839|      2|        }
 1840|     92|    }
 1841|       |    /* Cisco devices have odd scp implementation which breaks */
 1842|    323|    ios = strstr(banner, "Cisco");
 1843|    323|    if (ios != NULL) {
  ------------------
  |  Branch (1843:9): [True: 2, False: 321]
  ------------------
 1844|      2|        session->flags |= SSH_SESSION_FLAG_SCP_QUOTING_BROKEN;
  ------------------
  |  |   95|      2|#define SSH_SESSION_FLAG_SCP_QUOTING_BROKEN 0x0040
  ------------------
 1845|      2|    }
 1846|       |
 1847|    412|done:
 1848|    412|    return 0;
 1849|    323|}
ssh_timestamp_init:
 1864|  7.58k|{
 1865|  7.58k|#ifdef HAVE_CLOCK_GETTIME
 1866|  7.58k|  struct timespec tp;
 1867|  7.58k|  clock_gettime(CLOCK, &tp);
  ------------------
  |  | 1853|  7.58k|#define CLOCK CLOCK_MONOTONIC
  ------------------
 1868|  7.58k|  ts->useconds = tp.tv_nsec / 1000;
 1869|       |#else
 1870|       |  struct timeval tp;
 1871|       |  gettimeofday(&tp, NULL);
 1872|       |  ts->useconds = tp.tv_usec;
 1873|       |#endif
 1874|  7.58k|  ts->seconds = tp.tv_sec;
 1875|  7.58k|}
ssh_make_milliseconds:
 1912|    473|{
 1913|    473|    unsigned long res;
 1914|       |
 1915|    473|    if (sec == (unsigned long)SSH_TIMEOUT_INFINITE) {
  ------------------
  |  |   99|    473|#define SSH_TIMEOUT_INFINITE -1
  ------------------
  |  Branch (1915:9): [True: 0, False: 473]
  ------------------
 1916|      0|        return SSH_TIMEOUT_INFINITE;
  ------------------
  |  |   99|      0|#define SSH_TIMEOUT_INFINITE -1
  ------------------
 1917|      0|    }
 1918|    473|    if (sec > (unsigned long)INT_MAX / 1000) {
  ------------------
  |  Branch (1918:9): [True: 0, False: 473]
  ------------------
 1919|      0|        return INT_MAX;
 1920|      0|    }
 1921|       |
 1922|    473|    res = usec / 1000;
 1923|    473|    res += (sec * 1000);
 1924|    473|    if (res == 0) {
  ------------------
  |  Branch (1924:9): [True: 0, False: 473]
  ------------------
 1925|      0|        res = 10 * 1000; /* use a reasonable default value in case
 1926|       |                          * SSH_OPTIONS_TIMEOUT is not set in options. */
 1927|      0|    }
 1928|       |
 1929|    473|    if (res > INT_MAX) {
  ------------------
  |  Branch (1929:9): [True: 0, False: 473]
  ------------------
 1930|      0|        return INT_MAX;
 1931|    473|    } else {
 1932|    473|        return (int)res;
 1933|    473|    }
 1934|    473|}
ssh_timeout_elapsed:
 1947|  1.70k|{
 1948|  1.70k|    struct ssh_timestamp now;
 1949|       |
 1950|  1.70k|    switch(timeout) {
 1951|      0|        case -2: /*
  ------------------
  |  Branch (1951:9): [True: 0, False: 1.70k]
  ------------------
 1952|       |                  * -2 means user-defined timeout as available in
 1953|       |                  * session->timeout, session->timeout_usec.
 1954|       |                  */
 1955|      0|            SSH_LOG(SSH_LOG_DEBUG, "ssh_timeout_elapsed called with -2. this needs to "
  ------------------
  |  |  283|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 1956|      0|                            "be fixed. please set a breakpoint on misc.c:%d and "
 1957|      0|                            "fix the caller\n", __LINE__);
 1958|      0|            return 0;
 1959|      0|        case -1: /* -1 means infinite timeout */
  ------------------
  |  Branch (1959:9): [True: 0, False: 1.70k]
  ------------------
 1960|      0|            return 0;
 1961|      0|        case 0: /* 0 means no timeout */
  ------------------
  |  Branch (1961:9): [True: 0, False: 1.70k]
  ------------------
 1962|      0|            return 1;
 1963|  1.70k|        default:
  ------------------
  |  Branch (1963:9): [True: 1.70k, False: 0]
  ------------------
 1964|  1.70k|            break;
 1965|  1.70k|    }
 1966|       |
 1967|  1.70k|    ssh_timestamp_init(&now);
 1968|       |
 1969|  1.70k|    return (ssh_timestamp_difference(ts,&now) >= timeout);
 1970|  1.70k|}
ssh_timeout_update:
 1980|  3.55k|{
 1981|  3.55k|  struct ssh_timestamp now;
 1982|  3.55k|  int ms, ret;
 1983|  3.55k|  if (timeout <= 0) {
  ------------------
  |  Branch (1983:7): [True: 0, False: 3.55k]
  ------------------
 1984|      0|      return timeout;
 1985|      0|  }
 1986|  3.55k|  ssh_timestamp_init(&now);
 1987|  3.55k|  ms = ssh_timestamp_difference(ts,&now);
 1988|  3.55k|  if(ms < 0)
  ------------------
  |  Branch (1988:6): [True: 0, False: 3.55k]
  ------------------
 1989|      0|    ms = 0;
 1990|  3.55k|  ret = timeout - ms;
 1991|  3.55k|  return ret >= 0 ? ret: 0;
  ------------------
  |  Branch (1991:10): [True: 3.55k, False: 0]
  ------------------
 1992|  3.55k|}
ssh_strerror:
 2410|  1.64k|{
 2411|       |#if ((defined(__linux__) && defined(__GLIBC__)) || defined(__CYGWIN__)) && defined(_GNU_SOURCE)
 2412|       |    /* GNU extension on Linux */
 2413|       |    return strerror_r(err_num, buf, buflen);
 2414|       |#else
 2415|  1.64k|    int rv;
 2416|       |
 2417|       |#if defined(_WIN32)
 2418|       |    rv = strerror_s(buf, buflen, err_num);
 2419|       |#else
 2420|       |    /* POSIX version available for example on FreeBSD or in musl libc */
 2421|  1.64k|    rv = strerror_r(err_num, buf, buflen);
 2422|  1.64k|#endif /* _WIN32 */
 2423|       |
 2424|       |    /* make sure the buffer is initialized and terminated with NULL */
 2425|  1.64k|    if (-rv == ERANGE) {
  ------------------
  |  Branch (2425:9): [True: 0, False: 1.64k]
  ------------------
 2426|      0|        buf[0] = '\0';
 2427|      0|    }
 2428|  1.64k|    return buf;
 2429|  1.64k|#endif /* ((defined(__linux__) && defined(__GLIBC__)) || defined(__CYGWIN__)) && defined(_GNU_SOURCE) */
 2430|  1.64k|}
ssh_check_username_syntax:
 2620|    473|{
 2621|    473|    size_t username_len;
 2622|       |
 2623|    473|    if (username == NULL || *username == '-') {
  ------------------
  |  Branch (2623:9): [True: 0, False: 473]
  |  Branch (2623:29): [True: 0, False: 473]
  ------------------
 2624|      0|        return SSH_ERROR;
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 2625|      0|    }
 2626|       |
 2627|    473|    username_len = strlen(username);
 2628|    473|    if (username_len == 0 || username[username_len - 1] == '\\' ||
  ------------------
  |  Branch (2628:9): [True: 0, False: 473]
  |  Branch (2628:30): [True: 0, False: 473]
  ------------------
 2629|    473|        strpbrk(username, SSH_DANGEROUS_SHELL_CHARS) != NULL) {
  ------------------
  |  |  260|    473|#define SSH_DANGEROUS_SHELL_CHARS "'`\";&<>|(){}$\\,"
  ------------------
  |  Branch (2629:9): [True: 0, False: 473]
  ------------------
 2630|      0|        return SSH_ERROR;
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 2631|      0|    }
 2632|  2.83k|    for (size_t i = 0; i < username_len; i++) {
  ------------------
  |  Branch (2632:24): [True: 2.36k, False: 473]
  ------------------
 2633|  2.36k|        unsigned char c = (unsigned char)username[i];
 2634|  2.36k|        if (iscntrl(c) != 0 || (isspace(c) != 0 && username[i + 1] == '-')) {
  ------------------
  |  Branch (2634:13): [True: 0, False: 2.36k]
  |  Branch (2634:33): [True: 0, False: 2.36k]
  |  Branch (2634:52): [True: 0, False: 0]
  ------------------
 2635|      0|            return SSH_ERROR;
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 2636|      0|        }
 2637|  2.36k|    }
 2638|       |
 2639|    473|    return SSH_OK;
  ------------------
  |  |  315|    473|#define SSH_OK 0     /* No error */
  ------------------
 2640|    473|}
ssh_proxyjumps_free:
 2667|    700|{
 2668|    700|    struct ssh_jump_info_struct *jump = NULL;
 2669|       |
 2670|    700|    for (jump =
 2671|    700|             ssh_list_pop_head(struct ssh_jump_info_struct *, proxy_jump_list);
  ------------------
  |  |  130|    700|  ((type)_ssh_list_pop_head(ssh_list))
  ------------------
 2672|    700|         jump != NULL;
  ------------------
  |  Branch (2672:10): [True: 0, False: 700]
  ------------------
 2673|    700|         jump = ssh_list_pop_head(struct ssh_jump_info_struct *,
  ------------------
  |  |  130|      0|  ((type)_ssh_list_pop_head(ssh_list))
  ------------------
 2674|    700|                                  proxy_jump_list)) {
 2675|      0|        ssh_jump_info_free(jump);
 2676|      0|    }
 2677|    700|}
ssh_strict_fopen:
 2711|    824|{
 2712|    824|    FILE *f = NULL;
 2713|    824|    struct stat sb;
 2714|    824|    int r, fd;
 2715|       |
 2716|       |    /* open first to avoid TOCTOU */
 2717|    824|    fd = open(filename, O_RDONLY);
 2718|    824|    if (fd == -1) {
  ------------------
  |  Branch (2718:9): [True: 824, False: 0]
  ------------------
 2719|    824|        SSH_LOG_STRERROR(SSH_LOG_TRACE,
  ------------------
  |  |  285|    824|    do {                                                            \
  |  |  286|    824|        char err_msg[SSH_ERRNO_MSG_MAX] = {0};                      \
  |  |  287|    824|        _ssh_log(priority,                                          \
  |  |  288|    824|                 __func__,                                          \
  |  |  289|    824|                 __VA_ARGS__,                                       \
  |  |  290|    824|                 ssh_strerror(errnum, err_msg, SSH_ERRNO_MSG_MAX)); \
  |  |  ------------------
  |  |  |  |  522|    824|#define SSH_ERRNO_MSG_MAX   1024
  |  |  ------------------
  |  |  291|    824|    } while (0)
  |  |  ------------------
  |  |  |  Branch (291:14): [Folded, False: 824]
  |  |  ------------------
  ------------------
 2720|    824|                         errno,
 2721|    824|                         "Failed to open a file %s for reading: %s",
 2722|    824|                         filename);
 2723|    824|        return NULL;
 2724|    824|    }
 2725|       |
 2726|       |    /* Check the file is sensible for a configuration file */
 2727|      0|    r = fstat(fd, &sb);
 2728|      0|    if (r != 0) {
  ------------------
  |  Branch (2728:9): [True: 0, False: 0]
  ------------------
 2729|      0|        SSH_LOG_STRERROR(SSH_LOG_TRACE,
  ------------------
  |  |  285|      0|    do {                                                            \
  |  |  286|      0|        char err_msg[SSH_ERRNO_MSG_MAX] = {0};                      \
  |  |  287|      0|        _ssh_log(priority,                                          \
  |  |  288|      0|                 __func__,                                          \
  |  |  289|      0|                 __VA_ARGS__,                                       \
  |  |  290|      0|                 ssh_strerror(errnum, err_msg, SSH_ERRNO_MSG_MAX)); \
  |  |  ------------------
  |  |  |  |  522|      0|#define SSH_ERRNO_MSG_MAX   1024
  |  |  ------------------
  |  |  291|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (291:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2730|      0|                         errno,
 2731|      0|                         "Failed to stat %s: %s",
 2732|      0|                         filename);
 2733|      0|        close(fd);
 2734|      0|        return NULL;
 2735|      0|    }
 2736|      0|    if ((sb.st_mode & S_IFMT) != S_IFREG) {
  ------------------
  |  Branch (2736:9): [True: 0, False: 0]
  ------------------
 2737|      0|        SSH_LOG(SSH_LOG_TRACE,
  ------------------
  |  |  283|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 2738|      0|                "The file %s is not a regular file: skipping",
 2739|      0|                filename);
 2740|      0|        close(fd);
 2741|      0|        return NULL;
 2742|      0|    }
 2743|       |
 2744|      0|    if ((size_t)sb.st_size > max_file_size) {
  ------------------
  |  Branch (2744:9): [True: 0, False: 0]
  ------------------
 2745|      0|        SSH_LOG(SSH_LOG_TRACE,
  ------------------
  |  |  283|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 2746|      0|                "The file %s is too large (%jd MB > %zu MB): skipping",
 2747|      0|                filename,
 2748|      0|                (intmax_t)sb.st_size / 1024 / 1024,
 2749|      0|                max_file_size / 1024 / 1024);
 2750|      0|        close(fd);
 2751|      0|        return NULL;
 2752|      0|    }
 2753|       |
 2754|      0|    f = fdopen(fd, "r");
 2755|      0|    if (f == NULL) {
  ------------------
  |  Branch (2755:9): [True: 0, False: 0]
  ------------------
 2756|      0|        SSH_LOG_STRERROR(SSH_LOG_TRACE,
  ------------------
  |  |  285|      0|    do {                                                            \
  |  |  286|      0|        char err_msg[SSH_ERRNO_MSG_MAX] = {0};                      \
  |  |  287|      0|        _ssh_log(priority,                                          \
  |  |  288|      0|                 __func__,                                          \
  |  |  289|      0|                 __VA_ARGS__,                                       \
  |  |  290|      0|                 ssh_strerror(errnum, err_msg, SSH_ERRNO_MSG_MAX)); \
  |  |  ------------------
  |  |  |  |  522|      0|#define SSH_ERRNO_MSG_MAX   1024
  |  |  ------------------
  |  |  291|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (291:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2757|      0|                         errno,
 2758|      0|                         "Failed to open a file %s for reading: %s",
 2759|      0|                         filename);
 2760|      0|        close(fd);
 2761|      0|        return NULL;
 2762|      0|    }
 2763|       |
 2764|       |    /* the flcose() will close also the underlying fd */
 2765|      0|    return f;
 2766|      0|}
strlcpy:
 2777|  1.89k|{
 2778|  1.89k|    size_t len = strlen(src);
 2779|       |
 2780|  1.89k|    if (size != 0) {
  ------------------
  |  Branch (2780:9): [True: 1.89k, False: 0]
  ------------------
 2781|  1.89k|        size_t copy_len = (len >= size) ? size - 1 : len;
  ------------------
  |  Branch (2781:27): [True: 0, False: 1.89k]
  ------------------
 2782|       |
 2783|  1.89k|        memcpy(dst, src, copy_len);
 2784|  1.89k|        dst[copy_len] = '\0';
 2785|  1.89k|    }
 2786|       |
 2787|  1.89k|    return len;
 2788|  1.89k|}
ssh_normalize_loose_ip:
 2825|    946|{
 2826|    946|    struct in_addr addr;
 2827|    946|    char buf[INET_ADDRSTRLEN];
 2828|    946|    const char *p = NULL;
 2829|    946|    int rc;
 2830|    946|    int is_ip;
 2831|       |#ifdef _WIN32
 2832|       |    unsigned long ip;
 2833|       |    int is_broadcast;
 2834|       |#endif
 2835|       |
 2836|    946|    if (host == NULL || result == NULL) {
  ------------------
  |  Branch (2836:9): [True: 0, False: 946]
  |  Branch (2836:25): [True: 0, False: 946]
  ------------------
 2837|      0|        return -1;
 2838|      0|    }
 2839|       |
 2840|       |    /* We don't want to normalize stricter IP checks already handled by valid
 2841|       |     * IPv4/IPv6 */
 2842|    946|    is_ip = ssh_is_ipaddr(host);
 2843|    946|    if (is_ip) {
  ------------------
  |  Branch (2843:9): [True: 946, False: 0]
  ------------------
 2844|    946|        return 1; /* not a loose IP — already a strict address */
 2845|    946|    }
 2846|       |
 2847|       |#ifdef _WIN32
 2848|       |    ip = inet_addr(host);
 2849|       |    is_broadcast = strcmp(host, "255.255.255.255");
 2850|       |    if (ip == INADDR_NONE && is_broadcast != 0) {
 2851|       |        return 1; /* not a loose IP */
 2852|       |    }
 2853|       |    addr.S_un.S_addr = ip;
 2854|       |#else
 2855|      0|    rc = inet_aton(host, &addr);
 2856|      0|    if (rc == 0) {
  ------------------
  |  Branch (2856:9): [True: 0, False: 0]
  ------------------
 2857|      0|        return 1; /* not a loose IP */
 2858|      0|    }
 2859|      0|#endif
 2860|       |
 2861|      0|    p = inet_ntop(AF_INET, &addr, buf, sizeof(buf));
 2862|      0|    if (p == NULL) {
  ------------------
  |  Branch (2862:9): [True: 0, False: 0]
  ------------------
 2863|      0|        return -1;
 2864|      0|    }
 2865|       |
 2866|      0|    *result = strdup(p);
 2867|      0|    if (*result == NULL) {
  ------------------
  |  Branch (2867:9): [True: 0, False: 0]
  ------------------
 2868|      0|        return -1;
 2869|      0|    }
 2870|       |
 2871|      0|    return 0;
 2872|      0|}
misc.c:ssh_get_user_home_dir_internal:
  322|    946|{
  323|    946|    char *szPath = NULL;
  324|    946|    struct passwd pwd;
  325|    946|    struct passwd *pwdbuf = NULL;
  326|    946|    char buf[NSS_BUFLEN_PASSWD] = {0};
  327|    946|    int rc;
  328|       |
  329|    946|    rc = getpwuid_r(getuid(), &pwd, buf, NSS_BUFLEN_PASSWD, &pwdbuf);
  330|    946|    if (rc != 0 || pwdbuf == NULL ) {
  ------------------
  |  Branch (330:9): [True: 0, False: 946]
  |  Branch (330:20): [True: 0, False: 946]
  ------------------
  331|      0|        szPath = getenv("HOME");
  332|      0|        if (szPath == NULL) {
  ------------------
  |  Branch (332:13): [True: 0, False: 0]
  ------------------
  333|      0|            return NULL;
  334|      0|        }
  335|      0|        snprintf(buf, sizeof(buf), "%s", szPath);
  336|      0|        return strdup(buf);
  337|      0|    }
  338|       |
  339|    946|    szPath = strdup(pwd.pw_dir);
  340|       |
  341|    946|    return szPath;
  342|    946|}
misc.c:ssh_iterator_new:
  940|  3.41k|{
  941|  3.41k|    struct ssh_iterator *iterator = malloc(sizeof(struct ssh_iterator));
  942|       |
  943|  3.41k|    if (iterator == NULL) {
  ------------------
  |  Branch (943:9): [True: 0, False: 3.41k]
  ------------------
  944|      0|        return NULL;
  945|      0|    }
  946|  3.41k|    iterator->next = NULL;
  947|  3.41k|    iterator->data = data;
  948|  3.41k|    return iterator;
  949|  3.41k|}
misc.c:ssh_path_expand_internal:
 1485|  2.36k|{
 1486|  2.36k|    char *buf = NULL;
 1487|  2.36k|    char *r = NULL;
 1488|  2.36k|    char *x = NULL;
 1489|  2.36k|    const char *p = NULL;
 1490|  2.36k|    size_t i, l;
 1491|       |
 1492|  2.36k|    if (expand_tilde) {
  ------------------
  |  Branch (1492:9): [True: 1.89k, False: 473]
  ------------------
 1493|  1.89k|        r = ssh_path_expand_tilde(s);
 1494|  1.89k|    } else {
 1495|    473|        r = strdup(s);
 1496|    473|    }
 1497|  2.36k|    if (r == NULL) {
  ------------------
  |  Branch (1497:9): [True: 0, False: 2.36k]
  ------------------
 1498|      0|        ssh_set_error_oom(session);
  ------------------
  |  |  320|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
 1499|      0|        return NULL;
 1500|      0|    }
 1501|       |
 1502|  2.36k|    if (strlen(r) > MAX_BUF_SIZE) {
  ------------------
  |  |  230|  2.36k|#define MAX_BUF_SIZE 4096
  ------------------
  |  Branch (1502:9): [True: 0, False: 2.36k]
  ------------------
 1503|      0|        ssh_set_error(session, SSH_FATAL, "string to expand too long");
  ------------------
  |  |  313|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
 1504|      0|        free(r);
 1505|      0|        return NULL;
 1506|      0|    }
 1507|       |
 1508|  2.36k|    buf = malloc(MAX_BUF_SIZE);
  ------------------
  |  |  230|  2.36k|#define MAX_BUF_SIZE 4096
  ------------------
 1509|  2.36k|    if (buf == NULL) {
  ------------------
  |  Branch (1509:9): [True: 0, False: 2.36k]
  ------------------
 1510|      0|        ssh_set_error_oom(session);
  ------------------
  |  |  320|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
 1511|      0|        free(r);
 1512|      0|        return NULL;
 1513|      0|    }
 1514|       |
 1515|  2.36k|    p = r;
 1516|  2.36k|    buf[0] = '\0';
 1517|       |
 1518|  34.5k|    for (i = 0; *p != '\0'; p++) {
  ------------------
  |  Branch (1518:17): [True: 32.1k, False: 2.36k]
  ------------------
 1519|  32.1k|        if (*p != '%') {
  ------------------
  |  Branch (1519:13): [True: 30.2k, False: 1.89k]
  ------------------
 1520|  30.2k|            buf[i] = *p;
 1521|  30.2k|            i++;
 1522|  30.2k|            if (i >= MAX_BUF_SIZE) {
  ------------------
  |  |  230|  30.2k|#define MAX_BUF_SIZE 4096
  ------------------
  |  Branch (1522:17): [True: 0, False: 30.2k]
  ------------------
 1523|      0|                free(buf);
 1524|      0|                free(r);
 1525|      0|                return NULL;
 1526|      0|            }
 1527|  30.2k|            buf[i] = '\0';
 1528|  30.2k|            continue;
 1529|  30.2k|        }
 1530|       |
 1531|  1.89k|        p++;
 1532|  1.89k|        if (*p == '\0') {
  ------------------
  |  Branch (1532:13): [True: 0, False: 1.89k]
  ------------------
 1533|       |            /* HostName expansion rejects trailing '%' to match the parse-time
 1534|       |             * scan. Keep the general expansion path unchanged, where a
 1535|       |             * trailing '%' is truncated.
 1536|       |             */
 1537|      0|            if (hostname_lenient) {
  ------------------
  |  Branch (1537:17): [True: 0, False: 0]
  ------------------
 1538|      0|                ssh_set_error(session, SSH_FATAL, "Incomplete Hostname token");
  ------------------
  |  |  313|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
 1539|      0|                free(buf);
 1540|      0|                free(r);
 1541|      0|                return NULL;
 1542|      0|            }
 1543|      0|            break;
 1544|      0|        }
 1545|       |
 1546|  1.89k|        if (hostname_lenient && *p != '%' && *p != 'h') {
  ------------------
  |  Branch (1546:13): [True: 0, False: 1.89k]
  |  Branch (1546:33): [True: 0, False: 0]
  |  Branch (1546:46): [True: 0, False: 0]
  ------------------
 1547|      0|            buf[i] = '%';
 1548|      0|            i++;
 1549|      0|            if (i >= MAX_BUF_SIZE) {
  ------------------
  |  |  230|      0|#define MAX_BUF_SIZE 4096
  ------------------
  |  Branch (1549:17): [True: 0, False: 0]
  ------------------
 1550|      0|                ssh_set_error(session, SSH_FATAL, "String too long");
  ------------------
  |  |  313|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
 1551|      0|                free(buf);
 1552|      0|                free(r);
 1553|      0|                return NULL;
 1554|      0|            }
 1555|      0|            buf[i] = *p;
 1556|      0|            i++;
 1557|      0|            if (i >= MAX_BUF_SIZE) {
  ------------------
  |  |  230|      0|#define MAX_BUF_SIZE 4096
  ------------------
  |  Branch (1557:17): [True: 0, False: 0]
  ------------------
 1558|      0|                ssh_set_error(session, SSH_FATAL, "String too long");
  ------------------
  |  |  313|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
 1559|      0|                free(buf);
 1560|      0|                free(r);
 1561|      0|                return NULL;
 1562|      0|            }
 1563|      0|            buf[i] = '\0';
 1564|      0|            continue;
 1565|      0|        }
 1566|       |
 1567|  1.89k|        switch (*p) {
 1568|      0|        case '%':
  ------------------
  |  Branch (1568:9): [True: 0, False: 1.89k]
  ------------------
 1569|      0|            buf[i] = '%';
 1570|      0|            i++;
 1571|      0|            if (i >= MAX_BUF_SIZE) {
  ------------------
  |  |  230|      0|#define MAX_BUF_SIZE 4096
  ------------------
  |  Branch (1571:17): [True: 0, False: 0]
  ------------------
 1572|      0|                free(buf);
 1573|      0|                free(r);
 1574|      0|                return NULL;
 1575|      0|            }
 1576|      0|            buf[i] = '\0';
 1577|      0|            continue;
 1578|  1.89k|        case 'd':
  ------------------
  |  Branch (1578:9): [True: 1.89k, False: 0]
  ------------------
 1579|  1.89k|            x = ssh_get_user_home_dir(session);
 1580|  1.89k|            if (x == NULL) {
  ------------------
  |  Branch (1580:17): [True: 0, False: 1.89k]
  ------------------
 1581|      0|                ssh_set_error(session, SSH_FATAL, "Cannot expand homedir");
  ------------------
  |  |  313|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
 1582|      0|                free(buf);
 1583|      0|                free(r);
 1584|      0|                return NULL;
 1585|      0|            }
 1586|  1.89k|            break;
 1587|  1.89k|        case 'u':
  ------------------
  |  Branch (1587:9): [True: 0, False: 1.89k]
  ------------------
 1588|      0|            x = ssh_get_local_username();
 1589|      0|            break;
 1590|      0|        case 'l':
  ------------------
  |  Branch (1590:9): [True: 0, False: 1.89k]
  ------------------
 1591|      0|            x = ssh_get_local_hostname();
 1592|      0|            break;
 1593|      0|        case 'h':
  ------------------
  |  Branch (1593:9): [True: 0, False: 1.89k]
  ------------------
 1594|      0|            if (session->opts.host) {
  ------------------
  |  Branch (1594:17): [True: 0, False: 0]
  ------------------
 1595|      0|                x = strdup(session->opts.host);
 1596|      0|            } else if (session->opts.originalhost) {
  ------------------
  |  Branch (1596:24): [True: 0, False: 0]
  ------------------
 1597|      0|                x = strdup(session->opts.originalhost);
 1598|      0|            } else {
 1599|      0|                ssh_set_error(session, SSH_FATAL, "Cannot expand host");
  ------------------
  |  |  313|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
 1600|      0|                free(buf);
 1601|      0|                free(r);
 1602|      0|                return NULL;
 1603|      0|            }
 1604|      0|            break;
 1605|      0|        case 'n':
  ------------------
  |  Branch (1605:9): [True: 0, False: 1.89k]
  ------------------
 1606|      0|            if (session->opts.originalhost) {
  ------------------
  |  Branch (1606:17): [True: 0, False: 0]
  ------------------
 1607|      0|                x = strdup(session->opts.originalhost);
 1608|      0|            } else {
 1609|      0|                ssh_set_error(session,
  ------------------
  |  |  313|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
 1610|      0|                              SSH_FATAL,
 1611|      0|                              "Cannot expand original host");
 1612|      0|                free(buf);
 1613|      0|                free(r);
 1614|      0|                return NULL;
 1615|      0|            }
 1616|      0|            break;
 1617|      0|        case 'r':
  ------------------
  |  Branch (1617:9): [True: 0, False: 1.89k]
  ------------------
 1618|      0|            if (session->opts.username) {
  ------------------
  |  Branch (1618:17): [True: 0, False: 0]
  ------------------
 1619|      0|                x = strdup(session->opts.username);
 1620|      0|            } else {
 1621|      0|                ssh_set_error(session, SSH_FATAL, "Cannot expand username");
  ------------------
  |  |  313|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
 1622|      0|                free(buf);
 1623|      0|                free(r);
 1624|      0|                return NULL;
 1625|      0|            }
 1626|      0|            break;
 1627|      0|        case 'p': {
  ------------------
  |  Branch (1627:9): [True: 0, False: 1.89k]
  ------------------
 1628|      0|            char tmp[6];
 1629|      0|            unsigned int port;
 1630|       |
 1631|      0|            ssh_options_get_port(session, &port);
 1632|      0|            snprintf(tmp, sizeof(tmp), "%u", port);
 1633|      0|            x = strdup(tmp);
 1634|      0|            break;
 1635|      0|        }
 1636|      0|        case 'j':
  ------------------
  |  Branch (1636:9): [True: 0, False: 1.89k]
  ------------------
 1637|      0|            if (session->opts.proxy_jumps_str != NULL) {
  ------------------
  |  Branch (1637:17): [True: 0, False: 0]
  ------------------
 1638|      0|                x = strdup(session->opts.proxy_jumps_str);
 1639|      0|            } else {
 1640|      0|                x = strdup("");
 1641|      0|            }
 1642|      0|            break;
 1643|      0|        case 'C':
  ------------------
  |  Branch (1643:9): [True: 0, False: 1.89k]
  ------------------
 1644|      0|            x = get_connection_hash(session);
 1645|      0|            break;
 1646|      0|        default:
  ------------------
  |  Branch (1646:9): [True: 0, False: 1.89k]
  ------------------
 1647|      0|            ssh_set_error(session, SSH_FATAL, "Wrong escape sequence detected");
  ------------------
  |  |  313|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
 1648|      0|            free(buf);
 1649|      0|            free(r);
 1650|      0|            return NULL;
 1651|  1.89k|        }
 1652|       |
 1653|  1.89k|        if (x == NULL) {
  ------------------
  |  Branch (1653:13): [True: 0, False: 1.89k]
  ------------------
 1654|      0|            ssh_set_error_oom(session);
  ------------------
  |  |  320|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
 1655|      0|            free(buf);
 1656|      0|            free(r);
 1657|      0|            return NULL;
 1658|      0|        }
 1659|       |
 1660|  1.89k|        i += strlen(x);
 1661|  1.89k|        if (i >= MAX_BUF_SIZE) {
  ------------------
  |  |  230|  1.89k|#define MAX_BUF_SIZE 4096
  ------------------
  |  Branch (1661:13): [True: 0, False: 1.89k]
  ------------------
 1662|      0|            ssh_set_error(session, SSH_FATAL, "String too long");
  ------------------
  |  |  313|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
 1663|      0|            free(buf);
 1664|      0|            free(x);
 1665|      0|            free(r);
 1666|      0|            return NULL;
 1667|      0|        }
 1668|  1.89k|        l = strlen(buf);
 1669|  1.89k|        strlcpy(buf + l, x, MAX_BUF_SIZE - l);
  ------------------
  |  |  230|  1.89k|#define MAX_BUF_SIZE 4096
  ------------------
 1670|  1.89k|        buf[i] = '\0';
 1671|  1.89k|        SAFE_FREE(x);
  ------------------
  |  |  375|  1.89k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (375:31): [True: 1.89k, False: 0]
  |  |  |  Branch (375:71): [Folded, False: 1.89k]
  |  |  ------------------
  ------------------
 1672|  1.89k|    }
 1673|       |
 1674|  2.36k|    free(r);
 1675|       |
 1676|       |    /* strip the unused space by realloc */
 1677|  2.36k|    x = realloc(buf, strlen(buf) + 1);
 1678|  2.36k|    if (x == NULL) {
  ------------------
  |  Branch (1678:9): [True: 0, False: 2.36k]
  ------------------
 1679|      0|        ssh_set_error_oom(session);
  ------------------
  |  |  320|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
 1680|      0|        free(buf);
 1681|      0|    }
 1682|  2.36k|    return x;
 1683|  2.36k|}
misc.c:ssh_timestamp_difference:
 1889|  5.25k|{
 1890|  5.25k|    long seconds, usecs, msecs;
 1891|  5.25k|    seconds = new->seconds - old->seconds;
 1892|  5.25k|    usecs = new->useconds - old->useconds;
 1893|  5.25k|    if (usecs < 0){
  ------------------
  |  Branch (1893:9): [True: 82, False: 5.17k]
  ------------------
 1894|     82|        seconds--;
 1895|     82|        usecs += 1000000;
 1896|     82|    }
 1897|  5.25k|    msecs = seconds * 1000 + usecs/1000;
 1898|  5.25k|    return msecs;
 1899|  5.25k|}

kex_type_to_mlkem_info:
   28|     55|{
   29|     55|    switch (kex_type) {
   30|      0|    case SSH_KEX_MLKEM768X25519_SHA256:
  ------------------
  |  Branch (30:5): [True: 0, False: 55]
  ------------------
   31|     55|    case SSH_KEX_MLKEM768NISTP256_SHA256:
  ------------------
  |  Branch (31:5): [True: 55, False: 0]
  ------------------
   32|     55|        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: 55]
  ------------------
   38|       |        return NULL;
   39|     55|    }
   40|     55|}

ssh_mlkem_init:
   41|     49|{
   42|     49|    int ret = SSH_ERROR;
  ------------------
  |  |  316|     49|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
   43|     49|    struct ssh_crypto_struct *crypto = session->next_crypto;
   44|     49|    const struct mlkem_type_info *mlkem_info = NULL;
   45|     49|    unsigned char rnd[LIBCRUX_ML_KEM_KEY_PAIR_PRNG_LEN];
   46|     49|    struct libcrux_mlkem768_keypair keypair;
   47|     49|    int err;
   48|       |
   49|     49|    mlkem_info = kex_type_to_mlkem_info(crypto->kex_type);
   50|     49|    if (mlkem_info == NULL) {
  ------------------
  |  Branch (50:9): [True: 0, False: 49]
  ------------------
   51|      0|        SSH_LOG(SSH_LOG_WARNING, "Unknown ML-KEM type");
  ------------------
  |  |  283|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
   52|      0|        goto cleanup;
   53|      0|    }
   54|       |
   55|     49|    err = ssh_get_random(rnd, sizeof(rnd), 0);
   56|     49|    if (err != 1) {
  ------------------
  |  Branch (56:9): [True: 0, False: 49]
  ------------------
   57|      0|        SSH_LOG(SSH_LOG_WARNING,
  ------------------
  |  |  283|      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|     49|    keypair = libcrux_ml_kem_mlkem768_portable_generate_key_pair(rnd);
   63|       |
   64|     49|    if (ssh_string_len(crypto->mlkem_client_pubkey) < mlkem_info->pubkey_size) {
  ------------------
  |  Branch (64:9): [True: 49, False: 0]
  ------------------
   65|     49|        SSH_STRING_FREE(crypto->mlkem_client_pubkey);
  ------------------
  |  |  882|     49|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (882:14): [True: 0, False: 49]
  |  |  |  Branch (882:69): [Folded, False: 49]
  |  |  ------------------
  ------------------
   66|     49|    }
   67|     49|    if (crypto->mlkem_client_pubkey == NULL) {
  ------------------
  |  Branch (67:9): [True: 49, False: 0]
  ------------------
   68|     49|        crypto->mlkem_client_pubkey = ssh_string_new(mlkem_info->pubkey_size);
   69|     49|        if (crypto->mlkem_client_pubkey == NULL) {
  ------------------
  |  Branch (69:13): [True: 0, False: 49]
  ------------------
   70|      0|            ssh_set_error_oom(session);
  ------------------
  |  |  320|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
   71|      0|            goto cleanup;
   72|      0|        }
   73|     49|    }
   74|     49|    err = ssh_string_fill(crypto->mlkem_client_pubkey,
   75|     49|                          keypair.pk.value,
   76|     49|                          mlkem_info->pubkey_size);
   77|     49|    if (err) {
  ------------------
  |  Branch (77:9): [True: 0, False: 49]
  ------------------
   78|      0|        SSH_LOG(SSH_LOG_WARNING,
  ------------------
  |  |  283|      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|     49|    if (crypto->mlkem_privkey == NULL) {
  ------------------
  |  Branch (83:9): [True: 49, False: 0]
  ------------------
   84|     49|        crypto->mlkem_privkey = malloc(mlkem_info->privkey_size);
   85|     49|        if (crypto->mlkem_privkey == NULL) {
  ------------------
  |  Branch (85:13): [True: 0, False: 49]
  ------------------
   86|      0|            ssh_set_error_oom(session);
  ------------------
  |  |  320|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
   87|      0|            goto cleanup;
   88|      0|        }
   89|     49|    }
   90|     49|    memcpy(crypto->mlkem_privkey, keypair.sk.value, mlkem_info->privkey_size);
   91|     49|    crypto->mlkem_privkey_len = mlkem_info->privkey_size;
   92|       |
   93|     49|    ret = SSH_OK;
  ------------------
  |  |  315|     49|#define SSH_OK 0     /* No error */
  ------------------
   94|       |
   95|     49|cleanup:
   96|     49|    ssh_burn(&keypair, sizeof(keypair));
  ------------------
  |  |  390|     49|#define ssh_burn(ptr, len) explicit_bzero((ptr), (len))
  ------------------
   97|     49|    ssh_burn(rnd, sizeof(rnd));
  ------------------
  |  |  390|     49|#define ssh_burn(ptr, len) explicit_bzero((ptr), (len))
  ------------------
   98|     49|    return ret;
   99|     49|}

ssh_options_set_algo:
  468|  1.89k|{
  469|       |    /* When the list start with +,-,^ the filtration of unknown algorithms
  470|       |     * gets handled inside the helper functions, otherwise the list is taken
  471|       |     * as it is. */
  472|  1.89k|    char *p = (char *)list;
  473|       |
  474|  1.89k|    if (algo < SSH_COMP_C_S) {
  ------------------
  |  Branch (474:9): [True: 1.89k, False: 0]
  ------------------
  475|  1.89k|        if (list[0] == '+') {
  ------------------
  |  Branch (475:13): [True: 0, False: 1.89k]
  ------------------
  476|      0|            p = ssh_add_to_default_algos(algo, list+1);
  477|  1.89k|        } else if (list[0] == '-') {
  ------------------
  |  Branch (477:20): [True: 0, False: 1.89k]
  ------------------
  478|      0|            p = ssh_remove_from_default_algos(algo, list+1);
  479|  1.89k|        } else if (list[0] == '^') {
  ------------------
  |  Branch (479:20): [True: 0, False: 1.89k]
  ------------------
  480|      0|            p = ssh_prefix_default_algos(algo, list+1);
  481|      0|        }
  482|  1.89k|    }
  483|       |
  484|  1.89k|    if (p == list) {
  ------------------
  |  Branch (484:9): [True: 1.89k, False: 0]
  ------------------
  485|  1.89k|        if (ssh_fips_mode()) {
  ------------------
  |  |  115|  1.89k|#define ssh_fips_mode() (FIPS_mode() != 0)
  |  |  ------------------
  |  |  |  Branch (115:25): [True: 0, False: 1.89k]
  |  |  ------------------
  ------------------
  486|      0|            p = ssh_keep_fips_algos(algo, list);
  487|  1.89k|        } else {
  488|  1.89k|            p = ssh_keep_known_algos(algo, list);
  489|  1.89k|        }
  490|  1.89k|    }
  491|       |
  492|  1.89k|    if (p == NULL) {
  ------------------
  |  Branch (492:9): [True: 0, False: 1.89k]
  ------------------
  493|      0|        ssh_set_error(session, SSH_REQUEST_DENIED,
  ------------------
  |  |  313|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  494|      0|                "Setting method: no allowed algorithm for method \"%s\" (%s)",
  495|      0|                ssh_kex_get_description(algo), list);
  496|      0|        return -1;
  497|      0|    }
  498|       |
  499|  1.89k|    SAFE_FREE(*place);
  ------------------
  |  |  375|  1.89k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (375:31): [True: 0, False: 1.89k]
  |  |  |  Branch (375:71): [Folded, False: 1.89k]
  |  |  ------------------
  ------------------
  500|  1.89k|    *place = p;
  501|       |
  502|  1.89k|    return 0;
  503|  1.89k|}
ssh_options_set:
 1219|  4.73k|{
 1220|  4.73k|    const char *v = NULL;
 1221|  4.73k|    char *p = NULL, *q = NULL;
 1222|  4.73k|    long int i;
 1223|  4.73k|    unsigned int u;
 1224|  4.73k|    int rc;
 1225|  4.73k|    char **wanted_methods = session->opts.wanted_methods;
 1226|  4.73k|    struct ssh_jump_callbacks_struct *j = NULL;
 1227|  4.73k|    enum ssh_config_opcode_e opcode;
 1228|       |
 1229|  4.73k|    if (session == NULL) {
  ------------------
  |  Branch (1229:9): [True: 0, False: 4.73k]
  ------------------
 1230|      0|        return -1;
 1231|      0|    }
 1232|       |
 1233|  4.73k|    switch (type) {
 1234|    473|        case SSH_OPTIONS_HOST:
  ------------------
  |  Branch (1234:9): [True: 473, False: 4.25k]
  ------------------
 1235|    473|            v = value;
 1236|    473|            if (v == NULL || v[0] == '\0') {
  ------------------
  |  Branch (1236:17): [True: 0, False: 473]
  |  Branch (1236:30): [True: 0, False: 473]
  ------------------
 1237|      0|                ssh_set_error_invalid(session);
  ------------------
  |  |  324|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 1238|      0|                return -1;
 1239|    473|            } else if (session->opts.config_hostname_only) {
  ------------------
  |  Branch (1239:24): [True: 0, False: 473]
  ------------------
 1240|       |                /* HostName values are plain hostnames, not user@host URIs */
 1241|      0|                SAFE_FREE(session->opts.host);
  ------------------
  |  |  375|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (375:31): [True: 0, False: 0]
  |  |  |  Branch (375:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1242|      0|                session->opts.host = strdup(value);
 1243|      0|                if (session->opts.host == NULL) {
  ------------------
  |  Branch (1243:21): [True: 0, False: 0]
  ------------------
 1244|      0|                    ssh_set_error_oom(session);
  ------------------
  |  |  320|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
 1245|      0|                    return -1;
 1246|      0|                }
 1247|    473|            } else {
 1248|    473|                char *username = NULL, *hostname = NULL;
 1249|    473|                char *strict_hostname = NULL;
 1250|    473|                char *normalized = NULL;
 1251|       |
 1252|       |                /* Non-strict parse: reject shell metacharacters */
 1253|    473|                rc = ssh_config_parse_uri(value,
 1254|    473|                                          &username,
 1255|    473|                                          &hostname,
 1256|    473|                                          NULL,
 1257|    473|                                          true,
 1258|    473|                                          false);
 1259|    473|                if (rc != SSH_OK || hostname == NULL) {
  ------------------
  |  |  315|    946|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (1259:21): [True: 0, False: 473]
  |  Branch (1259:37): [True: 0, False: 473]
  ------------------
 1260|      0|                    SAFE_FREE(username);
  ------------------
  |  |  375|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (375:31): [True: 0, False: 0]
  |  |  |  Branch (375:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1261|      0|                    SAFE_FREE(hostname);
  ------------------
  |  |  375|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (375:31): [True: 0, False: 0]
  |  |  |  Branch (375:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1262|      0|                    ssh_set_error_invalid(session);
  ------------------
  |  |  324|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 1263|      0|                    return -1;
 1264|      0|                }
 1265|       |
 1266|       |                /* Non-strict passed: set username and originalhost */
 1267|    473|                if (username != NULL) {
  ------------------
  |  Branch (1267:21): [True: 0, False: 473]
  ------------------
 1268|      0|                    SAFE_FREE(session->opts.username);
  ------------------
  |  |  375|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (375:31): [True: 0, False: 0]
  |  |  |  Branch (375:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1269|      0|                    session->opts.username = username;
 1270|      0|                }
 1271|    473|                SAFE_FREE(session->opts.config_hostname);
  ------------------
  |  |  375|    473|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (375:31): [True: 0, False: 473]
  |  |  |  Branch (375:71): [Folded, False: 473]
  |  |  ------------------
  ------------------
 1272|    473|                SAFE_FREE(session->opts.originalhost);
  ------------------
  |  |  375|    473|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (375:31): [True: 0, False: 473]
  |  |  |  Branch (375:71): [Folded, False: 473]
  |  |  ------------------
  ------------------
 1273|    473|                session->opts.originalhost = hostname;
 1274|       |
 1275|       |                /* Strict parse: set host only if valid hostname or IP */
 1276|    473|                rc = ssh_normalize_loose_ip(value, &normalized);
 1277|    473|                if (rc == -1) {
  ------------------
  |  Branch (1277:21): [True: 0, False: 473]
  ------------------
 1278|       |                    /* Error */
 1279|      0|                    SAFE_FREE(username);
  ------------------
  |  |  375|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (375:31): [True: 0, False: 0]
  |  |  |  Branch (375:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1280|      0|                    ssh_set_error_oom(session);
  ------------------
  |  |  320|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
 1281|      0|                    return -1;
 1282|      0|                }
 1283|    473|                rc = ssh_config_parse_uri(
 1284|    473|                    (normalized != NULL) ? normalized : value,
  ------------------
  |  Branch (1284:21): [True: 0, False: 473]
  ------------------
 1285|    473|                    NULL,
 1286|    473|                    &strict_hostname,
 1287|    473|                    NULL,
 1288|    473|                    true,
 1289|    473|                    true);
 1290|    473|                SAFE_FREE(normalized);
  ------------------
  |  |  375|    473|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (375:31): [True: 0, False: 473]
  |  |  |  Branch (375:71): [Folded, False: 473]
  |  |  ------------------
  ------------------
 1291|       |
 1292|    473|                if (rc != SSH_OK || strict_hostname == NULL) {
  ------------------
  |  |  315|    946|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (1292:21): [True: 0, False: 473]
  |  Branch (1292:37): [True: 0, False: 473]
  ------------------
 1293|      0|                    SAFE_FREE(session->opts.host);
  ------------------
  |  |  375|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (375:31): [True: 0, False: 0]
  |  |  |  Branch (375:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1294|      0|                    SAFE_FREE(strict_hostname);
  ------------------
  |  |  375|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (375:31): [True: 0, False: 0]
  |  |  |  Branch (375:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1295|    473|                } else {
 1296|    473|                    SAFE_FREE(session->opts.host);
  ------------------
  |  |  375|    473|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (375:31): [True: 0, False: 473]
  |  |  |  Branch (375:71): [Folded, False: 473]
  |  |  ------------------
  ------------------
 1297|    473|                    session->opts.host = strict_hostname;
 1298|    473|                }
 1299|    473|            }
 1300|    473|            break;
 1301|    473|        case SSH_OPTIONS_PORT:
  ------------------
  |  Branch (1301:9): [True: 0, False: 4.73k]
  ------------------
 1302|      0|            if (value == NULL) {
  ------------------
  |  Branch (1302:17): [True: 0, False: 0]
  ------------------
 1303|      0|                ssh_set_error_invalid(session);
  ------------------
  |  |  324|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 1304|      0|                return -1;
 1305|      0|            } else {
 1306|      0|                int *x = (int *) value;
 1307|      0|                if (*x <= 0 || *x > 65535) {
  ------------------
  |  Branch (1307:21): [True: 0, False: 0]
  |  Branch (1307:32): [True: 0, False: 0]
  ------------------
 1308|      0|                    ssh_set_error_invalid(session);
  ------------------
  |  |  324|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 1309|      0|                    return -1;
 1310|      0|                }
 1311|       |
 1312|      0|                session->opts.port = *x;
 1313|      0|            }
 1314|      0|            break;
 1315|      0|        case SSH_OPTIONS_PORT_STR:
  ------------------
  |  Branch (1315:9): [True: 0, False: 4.73k]
  ------------------
 1316|      0|            v = value;
 1317|      0|            if (v == NULL || v[0] == '\0') {
  ------------------
  |  Branch (1317:17): [True: 0, False: 0]
  |  Branch (1317:30): [True: 0, False: 0]
  ------------------
 1318|      0|                ssh_set_error_invalid(session);
  ------------------
  |  |  324|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 1319|      0|                return -1;
 1320|      0|            } else {
 1321|      0|                q = strdup(v);
 1322|      0|                if (q == NULL) {
  ------------------
  |  Branch (1322:21): [True: 0, False: 0]
  ------------------
 1323|      0|                    ssh_set_error_oom(session);
  ------------------
  |  |  320|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
 1324|      0|                    return -1;
 1325|      0|                }
 1326|      0|                i = strtol(q, &p, 10);
 1327|      0|                if (q == p || *p != '\0') {
  ------------------
  |  Branch (1327:21): [True: 0, False: 0]
  |  Branch (1327:31): [True: 0, False: 0]
  ------------------
 1328|      0|                    SSH_LOG(SSH_LOG_DEBUG, "No port number was parsed");
  ------------------
  |  |  283|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 1329|      0|                    SAFE_FREE(q);
  ------------------
  |  |  375|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (375:31): [True: 0, False: 0]
  |  |  |  Branch (375:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1330|      0|                    return -1;
 1331|      0|                }
 1332|      0|                SAFE_FREE(q);
  ------------------
  |  |  375|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (375:31): [True: 0, False: 0]
  |  |  |  Branch (375:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1333|      0|                if (i <= 0 || i > 65535) {
  ------------------
  |  Branch (1333:21): [True: 0, False: 0]
  |  Branch (1333:31): [True: 0, False: 0]
  ------------------
 1334|      0|                    ssh_set_error_invalid(session);
  ------------------
  |  |  324|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 1335|      0|                    return -1;
 1336|      0|                }
 1337|       |
 1338|      0|                session->opts.port = i;
 1339|      0|            }
 1340|      0|            break;
 1341|    473|        case SSH_OPTIONS_FD:
  ------------------
  |  Branch (1341:9): [True: 473, False: 4.25k]
  ------------------
 1342|    473|            if (value == NULL) {
  ------------------
  |  Branch (1342:17): [True: 0, False: 473]
  ------------------
 1343|      0|                session->opts.fd = SSH_INVALID_SOCKET;
  ------------------
  |  |  123|      0|#define SSH_INVALID_SOCKET ((socket_t) -1)
  ------------------
 1344|      0|                ssh_set_error_invalid(session);
  ------------------
  |  |  324|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 1345|      0|                return -1;
 1346|    473|            } else {
 1347|    473|                socket_t *x = (socket_t *) value;
 1348|    473|                if (*x < 0) {
  ------------------
  |  Branch (1348:21): [True: 0, False: 473]
  ------------------
 1349|      0|                    session->opts.fd = SSH_INVALID_SOCKET;
  ------------------
  |  |  123|      0|#define SSH_INVALID_SOCKET ((socket_t) -1)
  ------------------
 1350|      0|                    ssh_set_error_invalid(session);
  ------------------
  |  |  324|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 1351|      0|                    return -1;
 1352|      0|                }
 1353|       |
 1354|    473|                session->opts.fd = *x & 0xffff;
 1355|    473|            }
 1356|    473|            break;
 1357|    473|        case SSH_OPTIONS_BINDADDR:
  ------------------
  |  Branch (1357:9): [True: 0, False: 4.73k]
  ------------------
 1358|      0|            v = value;
 1359|      0|            if (v == NULL || v[0] == '\0') {
  ------------------
  |  Branch (1359:17): [True: 0, False: 0]
  |  Branch (1359:30): [True: 0, False: 0]
  ------------------
 1360|      0|                ssh_set_error_invalid(session);
  ------------------
  |  |  324|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 1361|      0|                return -1;
 1362|      0|            }
 1363|       |
 1364|      0|            q = strdup(v);
 1365|      0|            if (q == NULL) {
  ------------------
  |  Branch (1365:17): [True: 0, False: 0]
  ------------------
 1366|      0|                return -1;
 1367|      0|            }
 1368|      0|            SAFE_FREE(session->opts.bindaddr);
  ------------------
  |  |  375|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (375:31): [True: 0, False: 0]
  |  |  |  Branch (375:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1369|      0|            session->opts.bindaddr = q;
 1370|      0|            break;
 1371|    473|        case SSH_OPTIONS_USER:
  ------------------
  |  Branch (1371:9): [True: 473, False: 4.25k]
  ------------------
 1372|    473|            v = value;
 1373|    473|            SAFE_FREE(session->opts.username);
  ------------------
  |  |  375|    473|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (375:31): [True: 0, False: 473]
  |  |  |  Branch (375:71): [Folded, False: 473]
  |  |  ------------------
  ------------------
 1374|    473|            if (v == NULL) {
  ------------------
  |  Branch (1374:17): [True: 0, False: 473]
  ------------------
 1375|      0|                q = ssh_get_local_username();
 1376|      0|                if (q == NULL) {
  ------------------
  |  Branch (1376:21): [True: 0, False: 0]
  ------------------
 1377|      0|                    ssh_set_error_oom(session);
  ------------------
  |  |  320|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
 1378|      0|                    return -1;
 1379|      0|                }
 1380|      0|                session->opts.username = q;
 1381|    473|            } else if (v[0] == '\0') {
  ------------------
  |  Branch (1381:24): [True: 0, False: 473]
  ------------------
 1382|      0|                ssh_set_error_invalid(session);
  ------------------
  |  |  324|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 1383|      0|                return -1;
 1384|    473|            } else { /* username provided */
 1385|    473|                session->opts.username = strdup(value);
 1386|    473|                if (session->opts.username == NULL) {
  ------------------
  |  Branch (1386:21): [True: 0, False: 473]
  ------------------
 1387|      0|                    ssh_set_error_oom(session);
  ------------------
  |  |  320|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
 1388|      0|                    return -1;
 1389|      0|                }
 1390|    473|                rc = ssh_check_username_syntax(session->opts.username);
 1391|    473|                if (rc != SSH_OK) {
  ------------------
  |  |  315|    473|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (1391:21): [True: 0, False: 473]
  ------------------
 1392|      0|                    ssh_set_error_invalid(session);
  ------------------
  |  |  324|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 1393|      0|                    return -1;
 1394|      0|                }
 1395|    473|            }
 1396|    473|            break;
 1397|    473|        case SSH_OPTIONS_SSH_DIR:
  ------------------
  |  Branch (1397:9): [True: 473, False: 4.25k]
  ------------------
 1398|    473|            v = value;
 1399|    473|            SAFE_FREE(session->opts.sshdir);
  ------------------
  |  |  375|    473|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (375:31): [True: 0, False: 473]
  |  |  |  Branch (375:71): [Folded, False: 473]
  |  |  ------------------
  ------------------
 1400|    473|            if (v == NULL) {
  ------------------
  |  Branch (1400:17): [True: 473, False: 0]
  ------------------
 1401|    473|                session->opts.sshdir = ssh_path_expand_tilde("~/.ssh");
 1402|    473|                if (session->opts.sshdir == NULL) {
  ------------------
  |  Branch (1402:21): [True: 0, False: 473]
  ------------------
 1403|      0|                    return -1;
 1404|      0|                }
 1405|    473|            } else if (v[0] == '\0') {
  ------------------
  |  Branch (1405:24): [True: 0, False: 0]
  ------------------
 1406|      0|                ssh_set_error_invalid(session);
  ------------------
  |  |  324|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 1407|      0|                return -1;
 1408|      0|            } else {
 1409|      0|                session->opts.sshdir = ssh_path_expand_tilde(v);
 1410|      0|                if (session->opts.sshdir == NULL) {
  ------------------
  |  Branch (1410:21): [True: 0, False: 0]
  ------------------
 1411|      0|                    ssh_set_error_oom(session);
  ------------------
  |  |  320|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
 1412|      0|                    return -1;
 1413|      0|                }
 1414|      0|            }
 1415|    473|            break;
 1416|    473|        case SSH_OPTIONS_IDENTITY:
  ------------------
  |  Branch (1416:9): [True: 0, False: 4.73k]
  ------------------
 1417|      0|        case SSH_OPTIONS_ADD_IDENTITY: {
  ------------------
  |  Branch (1417:9): [True: 0, False: 4.73k]
  ------------------
 1418|      0|            struct ssh_iterator *id_it = NULL;
 1419|       |
 1420|      0|            v = value;
 1421|      0|            if (v == NULL || v[0] == '\0') {
  ------------------
  |  Branch (1421:17): [True: 0, False: 0]
  |  Branch (1421:30): [True: 0, False: 0]
  ------------------
 1422|      0|                ssh_set_error_invalid(session);
  ------------------
  |  |  324|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 1423|      0|                return -1;
 1424|      0|            }
 1425|      0|            q = strdup(v);
 1426|      0|            if (q == NULL) {
  ------------------
  |  Branch (1426:17): [True: 0, False: 0]
  ------------------
 1427|      0|                return -1;
 1428|      0|            }
 1429|       |            /* Deduplicate: skip if the same path is already in the list */
 1430|      0|            for (id_it = ssh_list_get_iterator(session->opts.identity_non_exp);
 1431|      0|                 id_it != NULL; id_it = id_it->next) {
  ------------------
  |  Branch (1431:18): [True: 0, False: 0]
  ------------------
 1432|      0|                int cmp = strcmp(ssh_iterator_value(char *, id_it), q);
  ------------------
  |  |  122|      0|  ((type)((iterator)->data))
  ------------------
 1433|      0|                if (cmp == 0) {
  ------------------
  |  Branch (1433:21): [True: 0, False: 0]
  ------------------
 1434|      0|                    free(q);
 1435|      0|                    return 0;
 1436|      0|                }
 1437|      0|            }
 1438|      0|            if (session->opts.exp_flags & SSH_OPT_EXP_FLAG_IDENTITY) {
  ------------------
  |  |  118|      0|#define SSH_OPT_EXP_FLAG_IDENTITY 0x8
  ------------------
  |  Branch (1438:17): [True: 0, False: 0]
  ------------------
 1439|      0|                rc = ssh_list_append(session->opts.identity_non_exp, q);
 1440|      0|            } else {
 1441|      0|                rc = ssh_list_prepend(session->opts.identity_non_exp, q);
 1442|      0|            }
 1443|      0|            if (rc < 0) {
  ------------------
  |  Branch (1443:17): [True: 0, False: 0]
  ------------------
 1444|      0|                free(q);
 1445|      0|                return -1;
 1446|      0|            }
 1447|      0|            break;
 1448|      0|        }
 1449|      0|        case SSH_OPTIONS_CERTIFICATE: {
  ------------------
  |  Branch (1449:9): [True: 0, False: 4.73k]
  ------------------
 1450|      0|            struct ssh_iterator *cert_it = NULL;
 1451|       |
 1452|      0|            v = value;
 1453|      0|            if (v == NULL || v[0] == '\0') {
  ------------------
  |  Branch (1453:17): [True: 0, False: 0]
  |  Branch (1453:30): [True: 0, False: 0]
  ------------------
 1454|      0|                ssh_set_error_invalid(session);
  ------------------
  |  |  324|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 1455|      0|                return -1;
 1456|      0|            }
 1457|      0|            q = strdup(v);
 1458|      0|            if (q == NULL) {
  ------------------
  |  Branch (1458:17): [True: 0, False: 0]
  ------------------
 1459|      0|                return -1;
 1460|      0|            }
 1461|       |            /* Allocate on first use (no longer pre-allocated in ssh_new()) */
 1462|      0|            if (session->opts.certificate_non_exp == NULL) {
  ------------------
  |  Branch (1462:17): [True: 0, False: 0]
  ------------------
 1463|      0|                session->opts.certificate_non_exp = ssh_list_new();
 1464|      0|                if (session->opts.certificate_non_exp == NULL) {
  ------------------
  |  Branch (1464:21): [True: 0, False: 0]
  ------------------
 1465|      0|                    free(q);
 1466|      0|                    return -1;
 1467|      0|                }
 1468|      0|            }
 1469|       |
 1470|       |            /* Deduplicate: skip if the same path is already in the list */
 1471|      0|            for (cert_it = ssh_list_get_iterator(session->opts.certificate_non_exp);
 1472|      0|                 cert_it != NULL; cert_it = cert_it->next) {
  ------------------
  |  Branch (1472:18): [True: 0, False: 0]
  ------------------
 1473|      0|                int cmp = strcmp(ssh_iterator_value(char *, cert_it), q);
  ------------------
  |  |  122|      0|  ((type)((iterator)->data))
  ------------------
 1474|      0|                if (cmp == 0) {
  ------------------
  |  Branch (1474:21): [True: 0, False: 0]
  ------------------
 1475|      0|                    free(q);
 1476|      0|                    return 0;
 1477|      0|                }
 1478|      0|            }
 1479|      0|            rc = ssh_list_append(session->opts.certificate_non_exp, q);
 1480|      0|            if (rc < 0) {
  ------------------
  |  Branch (1480:17): [True: 0, False: 0]
  ------------------
 1481|      0|                free(q);
 1482|      0|                return -1;
 1483|      0|            }
 1484|      0|            break;
 1485|      0|        }
 1486|      0|        case SSH_OPTIONS_KNOWNHOSTS:
  ------------------
  |  Branch (1486:9): [True: 0, False: 4.73k]
  ------------------
 1487|      0|            v = value;
 1488|      0|            SAFE_FREE(session->opts.knownhosts);
  ------------------
  |  |  375|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (375:31): [True: 0, False: 0]
  |  |  |  Branch (375:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1489|      0|            if (v == NULL) {
  ------------------
  |  Branch (1489:17): [True: 0, False: 0]
  ------------------
 1490|       |                /* The default value will be set by the ssh_options_apply() */
 1491|      0|            } else if (v[0] == '\0') {
  ------------------
  |  Branch (1491:24): [True: 0, False: 0]
  ------------------
 1492|      0|                ssh_set_error_invalid(session);
  ------------------
  |  |  324|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 1493|      0|                return -1;
 1494|      0|            } else {
 1495|      0|                session->opts.knownhosts = strdup(v);
 1496|      0|                if (session->opts.knownhosts == NULL) {
  ------------------
  |  Branch (1496:21): [True: 0, False: 0]
  ------------------
 1497|      0|                    ssh_set_error_oom(session);
  ------------------
  |  |  320|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
 1498|      0|                    return -1;
 1499|      0|                }
 1500|      0|                session->opts.exp_flags &= ~SSH_OPT_EXP_FLAG_KNOWNHOSTS;
  ------------------
  |  |  115|      0|#define SSH_OPT_EXP_FLAG_KNOWNHOSTS 0x1
  ------------------
 1501|      0|            }
 1502|      0|            break;
 1503|      0|        case SSH_OPTIONS_GLOBAL_KNOWNHOSTS:
  ------------------
  |  Branch (1503:9): [True: 0, False: 4.73k]
  ------------------
 1504|      0|            v = value;
 1505|      0|            SAFE_FREE(session->opts.global_knownhosts);
  ------------------
  |  |  375|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (375:31): [True: 0, False: 0]
  |  |  |  Branch (375:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1506|      0|            if (v == NULL) {
  ------------------
  |  Branch (1506:17): [True: 0, False: 0]
  ------------------
 1507|      0|                session->opts.global_knownhosts =
 1508|      0|                    strdup(GLOBAL_CONF_DIR "/ssh_known_hosts");
  ------------------
  |  |   13|      0|#define GLOBAL_CONF_DIR "/etc/ssh"
  ------------------
 1509|      0|                if (session->opts.global_knownhosts == NULL) {
  ------------------
  |  Branch (1509:21): [True: 0, False: 0]
  ------------------
 1510|      0|                    ssh_set_error_oom(session);
  ------------------
  |  |  320|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
 1511|      0|                    return -1;
 1512|      0|                }
 1513|      0|            } else if (v[0] == '\0') {
  ------------------
  |  Branch (1513:24): [True: 0, False: 0]
  ------------------
 1514|      0|                ssh_set_error_invalid(session);
  ------------------
  |  |  324|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 1515|      0|                return -1;
 1516|      0|            } else {
 1517|      0|                session->opts.global_knownhosts = strdup(v);
 1518|      0|                if (session->opts.global_knownhosts == NULL) {
  ------------------
  |  Branch (1518:21): [True: 0, False: 0]
  ------------------
 1519|      0|                    ssh_set_error_oom(session);
  ------------------
  |  |  320|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
 1520|      0|                    return -1;
 1521|      0|                }
 1522|      0|                session->opts.exp_flags &= ~SSH_OPT_EXP_FLAG_GLOBAL_KNOWNHOSTS;
  ------------------
  |  |  116|      0|#define SSH_OPT_EXP_FLAG_GLOBAL_KNOWNHOSTS 0x2
  ------------------
 1523|      0|            }
 1524|      0|            break;
 1525|    473|        case SSH_OPTIONS_TIMEOUT:
  ------------------
  |  Branch (1525:9): [True: 473, False: 4.25k]
  ------------------
 1526|    473|            if (value == NULL) {
  ------------------
  |  Branch (1526:17): [True: 0, False: 473]
  ------------------
 1527|      0|                ssh_set_error_invalid(session);
  ------------------
  |  |  324|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 1528|      0|                return -1;
 1529|    473|            } else {
 1530|    473|                long *x = (long *) value;
 1531|    473|                if (*x < 0) {
  ------------------
  |  Branch (1531:21): [True: 0, False: 473]
  ------------------
 1532|      0|                    ssh_set_error_invalid(session);
  ------------------
  |  |  324|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 1533|      0|                    return -1;
 1534|      0|                }
 1535|       |
 1536|    473|                session->opts.timeout = *x & 0xffffffffU;
 1537|    473|            }
 1538|    473|            break;
 1539|    473|        case SSH_OPTIONS_TIMEOUT_USEC:
  ------------------
  |  Branch (1539:9): [True: 0, False: 4.73k]
  ------------------
 1540|      0|            if (value == NULL) {
  ------------------
  |  Branch (1540:17): [True: 0, False: 0]
  ------------------
 1541|      0|                ssh_set_error_invalid(session);
  ------------------
  |  |  324|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 1542|      0|                return -1;
 1543|      0|            } else {
 1544|      0|                long *x = (long *) value;
 1545|      0|                if (*x < 0) {
  ------------------
  |  Branch (1545:21): [True: 0, False: 0]
  ------------------
 1546|      0|                    ssh_set_error_invalid(session);
  ------------------
  |  |  324|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 1547|      0|                    return -1;
 1548|      0|                }
 1549|       |
 1550|      0|                session->opts.timeout_usec = *x & 0xffffffffU;
 1551|      0|            }
 1552|      0|            break;
 1553|      0|        case SSH_OPTIONS_SSH1:
  ------------------
  |  Branch (1553:9): [True: 0, False: 4.73k]
  ------------------
 1554|      0|            break;
 1555|      0|        case SSH_OPTIONS_SSH2:
  ------------------
  |  Branch (1555:9): [True: 0, False: 4.73k]
  ------------------
 1556|      0|            break;
 1557|      0|        case SSH_OPTIONS_LOG_VERBOSITY:
  ------------------
  |  Branch (1557:9): [True: 0, False: 4.73k]
  ------------------
 1558|      0|            if (value == NULL) {
  ------------------
  |  Branch (1558:17): [True: 0, False: 0]
  ------------------
 1559|      0|                ssh_set_error_invalid(session);
  ------------------
  |  |  324|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 1560|      0|                return -1;
 1561|      0|            } else {
 1562|      0|                int *x = (int *) value;
 1563|      0|                if (*x < 0) {
  ------------------
  |  Branch (1563:21): [True: 0, False: 0]
  ------------------
 1564|      0|                    ssh_set_error_invalid(session);
  ------------------
  |  |  324|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 1565|      0|                    return -1;
 1566|      0|                }
 1567|       |
 1568|      0|                session->common.log_verbosity = *x & 0xffffU;
 1569|      0|                ssh_set_log_level(*x & 0xffffU);
 1570|      0|            }
 1571|      0|            break;
 1572|      0|        case SSH_OPTIONS_LOG_VERBOSITY_STR:
  ------------------
  |  Branch (1572:9): [True: 0, False: 4.73k]
  ------------------
 1573|      0|            v = value;
 1574|      0|            if (v == NULL || v[0] == '\0') {
  ------------------
  |  Branch (1574:17): [True: 0, False: 0]
  |  Branch (1574:30): [True: 0, False: 0]
  ------------------
 1575|      0|                session->common.log_verbosity = 0;
 1576|      0|                ssh_set_error_invalid(session);
  ------------------
  |  |  324|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 1577|      0|                return -1;
 1578|      0|            } else {
 1579|      0|                q = strdup(v);
 1580|      0|                if (q == NULL) {
  ------------------
  |  Branch (1580:21): [True: 0, False: 0]
  ------------------
 1581|      0|                    ssh_set_error_oom(session);
  ------------------
  |  |  320|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
 1582|      0|                    return -1;
 1583|      0|                }
 1584|      0|                i = strtol(q, &p, 10);
 1585|      0|                if (q == p) {
  ------------------
  |  Branch (1585:21): [True: 0, False: 0]
  ------------------
 1586|      0|                    SSH_LOG(SSH_LOG_DEBUG, "No log verbositiy was parsed");
  ------------------
  |  |  283|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 1587|      0|                    SAFE_FREE(q);
  ------------------
  |  |  375|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (375:31): [True: 0, False: 0]
  |  |  |  Branch (375:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1588|      0|                    return -1;
 1589|      0|                }
 1590|      0|                SAFE_FREE(q);
  ------------------
  |  |  375|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (375:31): [True: 0, False: 0]
  |  |  |  Branch (375:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1591|      0|                if (i < 0) {
  ------------------
  |  Branch (1591:21): [True: 0, False: 0]
  ------------------
 1592|      0|                    ssh_set_error_invalid(session);
  ------------------
  |  |  324|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 1593|      0|                    return -1;
 1594|      0|                }
 1595|       |
 1596|      0|                session->common.log_verbosity = i & 0xffffU;
 1597|      0|                ssh_set_log_level(i & 0xffffU);
 1598|      0|            }
 1599|      0|            break;
 1600|    473|        case SSH_OPTIONS_CIPHERS_C_S:
  ------------------
  |  Branch (1600:9): [True: 473, False: 4.25k]
  ------------------
 1601|    473|            v = value;
 1602|    473|            if (v == NULL || v[0] == '\0') {
  ------------------
  |  Branch (1602:17): [True: 0, False: 473]
  |  Branch (1602:30): [True: 0, False: 473]
  ------------------
 1603|      0|                ssh_set_error_invalid(session);
  ------------------
  |  |  324|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 1604|      0|                return -1;
 1605|    473|            } else {
 1606|    473|                rc = ssh_options_set_algo(session,
 1607|    473|                                          SSH_CRYPT_C_S,
 1608|    473|                                          v,
 1609|    473|                                          &wanted_methods[SSH_CRYPT_C_S]);
 1610|    473|                if (rc < 0)
  ------------------
  |  Branch (1610:21): [True: 0, False: 473]
  ------------------
 1611|      0|                    return -1;
 1612|    473|            }
 1613|    473|            break;
 1614|    473|        case SSH_OPTIONS_CIPHERS_S_C:
  ------------------
  |  Branch (1614:9): [True: 473, False: 4.25k]
  ------------------
 1615|    473|            v = value;
 1616|    473|            if (v == NULL || v[0] == '\0') {
  ------------------
  |  Branch (1616:17): [True: 0, False: 473]
  |  Branch (1616:30): [True: 0, False: 473]
  ------------------
 1617|      0|                ssh_set_error_invalid(session);
  ------------------
  |  |  324|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 1618|      0|                return -1;
 1619|    473|            } else {
 1620|    473|                rc = ssh_options_set_algo(session,
 1621|    473|                                          SSH_CRYPT_S_C,
 1622|    473|                                          v,
 1623|    473|                                          &wanted_methods[SSH_CRYPT_S_C]);
 1624|    473|                if (rc < 0)
  ------------------
  |  Branch (1624:21): [True: 0, False: 473]
  ------------------
 1625|      0|                    return -1;
 1626|    473|            }
 1627|    473|            break;
 1628|    473|        case SSH_OPTIONS_KEY_EXCHANGE:
  ------------------
  |  Branch (1628:9): [True: 0, False: 4.73k]
  ------------------
 1629|      0|            v = value;
 1630|      0|            if (v == NULL || v[0] == '\0') {
  ------------------
  |  Branch (1630:17): [True: 0, False: 0]
  |  Branch (1630:30): [True: 0, False: 0]
  ------------------
 1631|      0|                ssh_set_error_invalid(session);
  ------------------
  |  |  324|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 1632|      0|                return -1;
 1633|      0|            } else {
 1634|      0|                rc = ssh_options_set_algo(session,
 1635|      0|                                          SSH_KEX,
 1636|      0|                                          v,
 1637|      0|                                          &wanted_methods[SSH_KEX]);
 1638|      0|                if (rc < 0)
  ------------------
  |  Branch (1638:21): [True: 0, False: 0]
  ------------------
 1639|      0|                    return -1;
 1640|      0|            }
 1641|      0|            break;
 1642|      0|        case SSH_OPTIONS_HOSTKEYS:
  ------------------
  |  Branch (1642:9): [True: 0, False: 4.73k]
  ------------------
 1643|      0|            v = value;
 1644|      0|            if (v == NULL || v[0] == '\0') {
  ------------------
  |  Branch (1644:17): [True: 0, False: 0]
  |  Branch (1644:30): [True: 0, False: 0]
  ------------------
 1645|      0|                ssh_set_error_invalid(session);
  ------------------
  |  |  324|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 1646|      0|                return -1;
 1647|      0|            } else {
 1648|      0|                rc = ssh_options_set_algo(session,
 1649|      0|                                          SSH_HOSTKEYS,
 1650|      0|                                          v,
 1651|      0|                                          &wanted_methods[SSH_HOSTKEYS]);
 1652|      0|                if (rc < 0)
  ------------------
  |  Branch (1652:21): [True: 0, False: 0]
  ------------------
 1653|      0|                    return -1;
 1654|      0|            }
 1655|      0|            break;
 1656|      0|        case SSH_OPTIONS_PUBLICKEY_ACCEPTED_TYPES:
  ------------------
  |  Branch (1656:9): [True: 0, False: 4.73k]
  ------------------
 1657|      0|            v = value;
 1658|      0|            if (v == NULL || v[0] == '\0') {
  ------------------
  |  Branch (1658:17): [True: 0, False: 0]
  |  Branch (1658:30): [True: 0, False: 0]
  ------------------
 1659|      0|                ssh_set_error_invalid(session);
  ------------------
  |  |  324|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 1660|      0|                return -1;
 1661|      0|            } else {
 1662|      0|                rc = ssh_options_set_algo(session,
 1663|      0|                                          SSH_HOSTKEYS,
 1664|      0|                                          v,
 1665|      0|                                          &session->opts.pubkey_accepted_types);
 1666|      0|                if (rc < 0)
  ------------------
  |  Branch (1666:21): [True: 0, False: 0]
  ------------------
 1667|      0|                    return -1;
 1668|      0|            }
 1669|      0|            break;
 1670|    473|        case SSH_OPTIONS_HMAC_C_S:
  ------------------
  |  Branch (1670:9): [True: 473, False: 4.25k]
  ------------------
 1671|    473|            v = value;
 1672|    473|            if (v == NULL || v[0] == '\0') {
  ------------------
  |  Branch (1672:17): [True: 0, False: 473]
  |  Branch (1672:30): [True: 0, False: 473]
  ------------------
 1673|      0|                ssh_set_error_invalid(session);
  ------------------
  |  |  324|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 1674|      0|                return -1;
 1675|    473|            } else {
 1676|    473|                rc = ssh_options_set_algo(session,
 1677|    473|                                          SSH_MAC_C_S,
 1678|    473|                                          v,
 1679|    473|                                          &wanted_methods[SSH_MAC_C_S]);
 1680|    473|                if (rc < 0)
  ------------------
  |  Branch (1680:21): [True: 0, False: 473]
  ------------------
 1681|      0|                    return -1;
 1682|    473|            }
 1683|    473|            break;
 1684|    473|         case SSH_OPTIONS_HMAC_S_C:
  ------------------
  |  Branch (1684:10): [True: 473, False: 4.25k]
  ------------------
 1685|    473|            v = value;
 1686|    473|            if (v == NULL || v[0] == '\0') {
  ------------------
  |  Branch (1686:17): [True: 0, False: 473]
  |  Branch (1686:30): [True: 0, False: 473]
  ------------------
 1687|      0|                ssh_set_error_invalid(session);
  ------------------
  |  |  324|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 1688|      0|                return -1;
 1689|    473|            } else {
 1690|    473|                rc = ssh_options_set_algo(session,
 1691|    473|                                          SSH_MAC_S_C,
 1692|    473|                                          v,
 1693|    473|                                          &wanted_methods[SSH_MAC_S_C]);
 1694|    473|                if (rc < 0)
  ------------------
  |  Branch (1694:21): [True: 0, False: 473]
  ------------------
 1695|      0|                    return -1;
 1696|    473|            }
 1697|    473|            break;
 1698|    473|        case SSH_OPTIONS_COMPRESSION_C_S:
  ------------------
  |  Branch (1698:9): [True: 0, False: 4.73k]
  ------------------
 1699|      0|            v = value;
 1700|      0|            if (v == NULL || v[0] == '\0') {
  ------------------
  |  Branch (1700:17): [True: 0, False: 0]
  |  Branch (1700:30): [True: 0, False: 0]
  ------------------
 1701|      0|                ssh_set_error_invalid(session);
  ------------------
  |  |  324|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 1702|      0|                return -1;
 1703|      0|            } else {
 1704|      0|                const char *tmp = v;
 1705|      0|                if (strcasecmp(value, "yes") == 0){
  ------------------
  |  Branch (1705:21): [True: 0, False: 0]
  ------------------
 1706|      0|                    tmp = "zlib@openssh.com,none";
 1707|      0|                } else if (strcasecmp(value, "no") == 0){
  ------------------
  |  Branch (1707:28): [True: 0, False: 0]
  ------------------
 1708|      0|                    tmp = "none,zlib@openssh.com";
 1709|      0|                }
 1710|      0|                rc = ssh_options_set_algo(session,
 1711|      0|                                          SSH_COMP_C_S,
 1712|      0|                                          tmp,
 1713|      0|                                          &wanted_methods[SSH_COMP_C_S]);
 1714|      0|                if (rc < 0)
  ------------------
  |  Branch (1714:21): [True: 0, False: 0]
  ------------------
 1715|      0|                    return -1;
 1716|      0|            }
 1717|      0|            break;
 1718|      0|        case SSH_OPTIONS_COMPRESSION_S_C:
  ------------------
  |  Branch (1718:9): [True: 0, False: 4.73k]
  ------------------
 1719|      0|            v = value;
 1720|      0|            if (v == NULL || v[0] == '\0') {
  ------------------
  |  Branch (1720:17): [True: 0, False: 0]
  |  Branch (1720:30): [True: 0, False: 0]
  ------------------
 1721|      0|                ssh_set_error_invalid(session);
  ------------------
  |  |  324|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 1722|      0|                return -1;
 1723|      0|            } else {
 1724|      0|                const char *tmp = v;
 1725|      0|                if (strcasecmp(value, "yes") == 0){
  ------------------
  |  Branch (1725:21): [True: 0, False: 0]
  ------------------
 1726|      0|                    tmp = "zlib@openssh.com,none";
 1727|      0|                } else if (strcasecmp(value, "no") == 0){
  ------------------
  |  Branch (1727:28): [True: 0, False: 0]
  ------------------
 1728|      0|                    tmp = "none,zlib@openssh.com";
 1729|      0|                }
 1730|       |
 1731|      0|                rc = ssh_options_set_algo(session,
 1732|      0|                                          SSH_COMP_S_C,
 1733|      0|                                          tmp,
 1734|      0|                                          &wanted_methods[SSH_COMP_S_C]);
 1735|      0|                if (rc < 0)
  ------------------
  |  Branch (1735:21): [True: 0, False: 0]
  ------------------
 1736|      0|                    return -1;
 1737|      0|            }
 1738|      0|            break;
 1739|      0|        case SSH_OPTIONS_COMPRESSION:
  ------------------
  |  Branch (1739:9): [True: 0, False: 4.73k]
  ------------------
 1740|      0|            v = value;
 1741|      0|            if (v == NULL || v[0] == '\0') {
  ------------------
  |  Branch (1741:17): [True: 0, False: 0]
  |  Branch (1741:30): [True: 0, False: 0]
  ------------------
 1742|      0|                ssh_set_error_invalid(session);
  ------------------
  |  |  324|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 1743|      0|                return -1;
 1744|      0|            }
 1745|      0|            if(ssh_options_set(session,SSH_OPTIONS_COMPRESSION_C_S, v) < 0)
  ------------------
  |  Branch (1745:16): [True: 0, False: 0]
  ------------------
 1746|      0|                return -1;
 1747|      0|            if(ssh_options_set(session,SSH_OPTIONS_COMPRESSION_S_C, v) < 0)
  ------------------
  |  Branch (1747:16): [True: 0, False: 0]
  ------------------
 1748|      0|                return -1;
 1749|      0|            break;
 1750|      0|        case SSH_OPTIONS_COMPRESSION_LEVEL:
  ------------------
  |  Branch (1750:9): [True: 0, False: 4.73k]
  ------------------
 1751|      0|            if (value == NULL) {
  ------------------
  |  Branch (1751:17): [True: 0, False: 0]
  ------------------
 1752|      0|                ssh_set_error_invalid(session);
  ------------------
  |  |  324|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 1753|      0|                return -1;
 1754|      0|            } else {
 1755|      0|                int *x = (int *)value;
 1756|      0|                if (*x < 1 || *x > 9) {
  ------------------
  |  Branch (1756:21): [True: 0, False: 0]
  |  Branch (1756:31): [True: 0, False: 0]
  ------------------
 1757|      0|                    ssh_set_error_invalid(session);
  ------------------
  |  |  324|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 1758|      0|                    return -1;
 1759|      0|                }
 1760|      0|                session->opts.compressionlevel = *x & 0xff;
 1761|      0|            }
 1762|      0|            break;
 1763|      0|        case SSH_OPTIONS_STRICTHOSTKEYCHECK:
  ------------------
  |  Branch (1763:9): [True: 0, False: 4.73k]
  ------------------
 1764|      0|            if (value == NULL) {
  ------------------
  |  Branch (1764:17): [True: 0, False: 0]
  ------------------
 1765|      0|                ssh_set_error_invalid(session);
  ------------------
  |  |  324|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 1766|      0|                return -1;
 1767|      0|            } else {
 1768|      0|                int *x = (int *) value;
 1769|      0|                int mode = *x;
 1770|       |
 1771|      0|                switch (mode) {
 1772|      0|                case SSH_STRICT_HOSTKEY_OFF:
  ------------------
  |  Branch (1772:17): [True: 0, False: 0]
  ------------------
 1773|      0|                case SSH_STRICT_HOSTKEY_YES:
  ------------------
  |  Branch (1773:17): [True: 0, False: 0]
  ------------------
 1774|      0|                case SSH_STRICT_HOSTKEY_ASK:
  ------------------
  |  Branch (1774:17): [True: 0, False: 0]
  ------------------
 1775|      0|                case SSH_STRICT_HOSTKEY_ACCEPT_NEW:
  ------------------
  |  Branch (1775:17): [True: 0, False: 0]
  ------------------
 1776|      0|                    session->opts.StrictHostKeyChecking = mode;
 1777|      0|                    break;
 1778|      0|                default:
  ------------------
  |  Branch (1778:17): [True: 0, False: 0]
  ------------------
 1779|       |                    /* Preserve the legacy low-byte "non-zero means yes"
 1780|       |                     * normalization.
 1781|       |                     */
 1782|      0|                    session->opts.StrictHostKeyChecking =
 1783|      0|                        (mode & 0xff) > 0 ? SSH_STRICT_HOSTKEY_YES
  ------------------
  |  Branch (1783:25): [True: 0, False: 0]
  ------------------
 1784|      0|                                          : SSH_STRICT_HOSTKEY_OFF;
 1785|      0|                    break;
 1786|      0|                }
 1787|      0|            }
 1788|      0|            break;
 1789|      0|        case SSH_OPTIONS_PROXYCOMMAND:
  ------------------
  |  Branch (1789:9): [True: 0, False: 4.73k]
  ------------------
 1790|      0|            v = value;
 1791|      0|            if (v == NULL || v[0] == '\0') {
  ------------------
  |  Branch (1791:17): [True: 0, False: 0]
  |  Branch (1791:30): [True: 0, False: 0]
  ------------------
 1792|      0|                ssh_set_error_invalid(session);
  ------------------
  |  |  324|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 1793|      0|                return -1;
 1794|      0|            } else {
 1795|      0|                SAFE_FREE(session->opts.ProxyCommand);
  ------------------
  |  |  375|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (375:31): [True: 0, False: 0]
  |  |  |  Branch (375:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1796|       |                /* Setting the command to 'none' disables this option. */
 1797|      0|                rc = strcasecmp(v, "none");
 1798|      0|                if (rc != 0) {
  ------------------
  |  Branch (1798:21): [True: 0, False: 0]
  ------------------
 1799|      0|                    q = strdup(v);
 1800|      0|                    if (q == NULL) {
  ------------------
  |  Branch (1800:25): [True: 0, False: 0]
  ------------------
 1801|      0|                        return -1;
 1802|      0|                    }
 1803|      0|                    session->opts.ProxyCommand = q;
 1804|      0|                    session->opts.exp_flags &= ~SSH_OPT_EXP_FLAG_PROXYCOMMAND;
  ------------------
  |  |  117|      0|#define SSH_OPT_EXP_FLAG_PROXYCOMMAND 0x4
  ------------------
 1805|      0|                }
 1806|      0|            }
 1807|      0|            break;
 1808|      0|        case SSH_OPTIONS_PROXYJUMP:
  ------------------
  |  Branch (1808:9): [True: 0, False: 4.73k]
  ------------------
 1809|      0|            v = value;
 1810|      0|            if (v == NULL || v[0] == '\0') {
  ------------------
  |  Branch (1810:17): [True: 0, False: 0]
  |  Branch (1810:30): [True: 0, False: 0]
  ------------------
 1811|      0|                ssh_set_error_invalid(session);
  ------------------
  |  |  324|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 1812|      0|                return -1;
 1813|      0|            } else {
 1814|      0|                rc = ssh_config_parse_proxy_jump(session, v, true);
 1815|      0|                if (rc != SSH_OK) {
  ------------------
  |  |  315|      0|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (1815:21): [True: 0, False: 0]
  ------------------
 1816|      0|                    return SSH_ERROR;
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 1817|      0|                }
 1818|      0|            }
 1819|      0|            break;
 1820|      0|        case SSH_OPTIONS_PROXYJUMP_CB_LIST_APPEND:
  ------------------
  |  Branch (1820:9): [True: 0, False: 4.73k]
  ------------------
 1821|      0|            j = (struct ssh_jump_callbacks_struct *)value;
 1822|      0|            if (j == NULL) {
  ------------------
  |  Branch (1822:17): [True: 0, False: 0]
  ------------------
 1823|      0|                ssh_set_error_invalid(session);
  ------------------
  |  |  324|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 1824|      0|                return -1;
 1825|      0|            } else {
 1826|       |                /* Allocate on first use (no longer pre-allocated in ssh_new()) */
 1827|      0|                if (session->opts.proxy_jumps_user_cb == NULL) {
  ------------------
  |  Branch (1827:21): [True: 0, False: 0]
  ------------------
 1828|      0|                    session->opts.proxy_jumps_user_cb = ssh_list_new();
 1829|      0|                    if (session->opts.proxy_jumps_user_cb == NULL) {
  ------------------
  |  Branch (1829:25): [True: 0, False: 0]
  ------------------
 1830|      0|                        ssh_set_error_oom(session);
  ------------------
  |  |  320|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
 1831|      0|                        return SSH_ERROR;
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 1832|      0|                    }
 1833|      0|                }
 1834|      0|                rc = ssh_list_prepend(session->opts.proxy_jumps_user_cb, j);
 1835|      0|                if (rc != SSH_OK) {
  ------------------
  |  |  315|      0|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (1835:21): [True: 0, False: 0]
  ------------------
 1836|      0|                    ssh_set_error_oom(session);
  ------------------
  |  |  320|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
 1837|      0|                    return SSH_ERROR;
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 1838|      0|                }
 1839|      0|            }
 1840|      0|            break;
 1841|      0|        case SSH_OPTIONS_GSSAPI_SERVER_IDENTITY:
  ------------------
  |  Branch (1841:9): [True: 0, False: 4.73k]
  ------------------
 1842|      0|            v = value;
 1843|      0|            if (v == NULL || v[0] == '\0') {
  ------------------
  |  Branch (1843:17): [True: 0, False: 0]
  |  Branch (1843:30): [True: 0, False: 0]
  ------------------
 1844|      0|                ssh_set_error_invalid(session);
  ------------------
  |  |  324|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 1845|      0|                return -1;
 1846|      0|            } else {
 1847|      0|                SAFE_FREE(session->opts.gss_server_identity);
  ------------------
  |  |  375|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (375:31): [True: 0, False: 0]
  |  |  |  Branch (375:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1848|      0|                session->opts.gss_server_identity = strdup(v);
 1849|      0|                if (session->opts.gss_server_identity == NULL) {
  ------------------
  |  Branch (1849:21): [True: 0, False: 0]
  ------------------
 1850|      0|                    ssh_set_error_oom(session);
  ------------------
  |  |  320|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
 1851|      0|                    return -1;
 1852|      0|                }
 1853|      0|            }
 1854|      0|            break;
 1855|      0|        case SSH_OPTIONS_GSSAPI_CLIENT_IDENTITY:
  ------------------
  |  Branch (1855:9): [True: 0, False: 4.73k]
  ------------------
 1856|      0|            v = value;
 1857|      0|            if (v == NULL || v[0] == '\0') {
  ------------------
  |  Branch (1857:17): [True: 0, False: 0]
  |  Branch (1857:30): [True: 0, False: 0]
  ------------------
 1858|      0|                ssh_set_error_invalid(session);
  ------------------
  |  |  324|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 1859|      0|                return -1;
 1860|      0|            } else {
 1861|      0|                SAFE_FREE(session->opts.gss_client_identity);
  ------------------
  |  |  375|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (375:31): [True: 0, False: 0]
  |  |  |  Branch (375:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1862|      0|                session->opts.gss_client_identity = strdup(v);
 1863|      0|                if (session->opts.gss_client_identity == NULL) {
  ------------------
  |  Branch (1863:21): [True: 0, False: 0]
  ------------------
 1864|      0|                    ssh_set_error_oom(session);
  ------------------
  |  |  320|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
 1865|      0|                    return -1;
 1866|      0|                }
 1867|      0|            }
 1868|      0|            break;
 1869|      0|        case SSH_OPTIONS_GSSAPI_DELEGATE_CREDENTIALS:
  ------------------
  |  Branch (1869:9): [True: 0, False: 4.73k]
  ------------------
 1870|      0|            if (value == NULL) {
  ------------------
  |  Branch (1870:17): [True: 0, False: 0]
  ------------------
 1871|      0|                ssh_set_error_invalid(session);
  ------------------
  |  |  324|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 1872|      0|                return -1;
 1873|      0|            } else {
 1874|      0|                int x = *(int *)value;
 1875|       |
 1876|      0|                session->opts.gss_delegate_creds = (x & 0xff);
 1877|      0|            }
 1878|      0|            break;
 1879|       |#ifdef WITH_GSSAPI
 1880|       |        case SSH_OPTIONS_GSSAPI_KEY_EXCHANGE:
 1881|       |            if (value == NULL) {
 1882|       |                ssh_set_error_invalid(session);
 1883|       |                return -1;
 1884|       |            } else {
 1885|       |                bool *x = (bool *)value;
 1886|       |                session->opts.gssapi_key_exchange = *x;
 1887|       |            }
 1888|       |            break;
 1889|       |        case SSH_OPTIONS_GSSAPI_KEY_EXCHANGE_ALGS:
 1890|       |            v = value;
 1891|       |            if (v == NULL || v[0] == '\0') {
 1892|       |                ssh_set_error_invalid(session);
 1893|       |                return -1;
 1894|       |            } else {
 1895|       |                /* Check if algorithms are supported */
 1896|       |                char *ret =
 1897|       |                    ssh_find_all_matching(GSSAPI_KEY_EXCHANGE_SUPPORTED, v);
 1898|       |                if (ret == NULL) {
 1899|       |                    ssh_set_error(session,
 1900|       |                                  SSH_FATAL,
 1901|       |                                  "GSSAPI key exchange algorithms not "
 1902|       |                                  "supported or invalid");
 1903|       |                    return -1;
 1904|       |                }
 1905|       |                SAFE_FREE(session->opts.gssapi_key_exchange_algs);
 1906|       |                session->opts.gssapi_key_exchange_algs = ret;
 1907|       |            }
 1908|       |            break;
 1909|       |#endif
 1910|      0|        case SSH_OPTIONS_PASSWORD_AUTH:
  ------------------
  |  Branch (1910:9): [True: 0, False: 4.73k]
  ------------------
 1911|      0|        case SSH_OPTIONS_PUBKEY_AUTH:
  ------------------
  |  Branch (1911:9): [True: 0, False: 4.73k]
  ------------------
 1912|      0|        case SSH_OPTIONS_KBDINT_AUTH:
  ------------------
  |  Branch (1912:9): [True: 0, False: 4.73k]
  ------------------
 1913|      0|        case SSH_OPTIONS_GSSAPI_AUTH:
  ------------------
  |  Branch (1913:9): [True: 0, False: 4.73k]
  ------------------
 1914|      0|            if (value == NULL) {
  ------------------
  |  Branch (1914:17): [True: 0, False: 0]
  ------------------
 1915|      0|                ssh_set_error_invalid(session);
  ------------------
  |  |  324|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 1916|      0|                return -1;
 1917|      0|            } else {
 1918|      0|                int x = *(int *)value;
 1919|      0|                u = type == SSH_OPTIONS_PASSWORD_AUTH ?
  ------------------
  |  Branch (1919:21): [True: 0, False: 0]
  ------------------
 1920|      0|                    SSH_OPT_FLAG_PASSWORD_AUTH:
  ------------------
  |  |  109|      0|#define SSH_OPT_FLAG_PASSWORD_AUTH 0x1
  ------------------
 1921|      0|                    type == SSH_OPTIONS_PUBKEY_AUTH ?
  ------------------
  |  Branch (1921:21): [True: 0, False: 0]
  ------------------
 1922|      0|                        SSH_OPT_FLAG_PUBKEY_AUTH:
  ------------------
  |  |  110|      0|#define SSH_OPT_FLAG_PUBKEY_AUTH 0x2
  ------------------
 1923|      0|                        type == SSH_OPTIONS_KBDINT_AUTH ?
  ------------------
  |  Branch (1923:25): [True: 0, False: 0]
  ------------------
 1924|      0|                            SSH_OPT_FLAG_KBDINT_AUTH:
  ------------------
  |  |  111|      0|#define SSH_OPT_FLAG_KBDINT_AUTH 0x4
  ------------------
 1925|      0|                            SSH_OPT_FLAG_GSSAPI_AUTH;
  ------------------
  |  |  112|      0|#define SSH_OPT_FLAG_GSSAPI_AUTH 0x8
  ------------------
 1926|      0|                if (x != 0) {
  ------------------
  |  Branch (1926:21): [True: 0, False: 0]
  ------------------
 1927|      0|                    session->opts.flags |= u;
 1928|      0|                } else {
 1929|      0|                    session->opts.flags &= ~u;
 1930|      0|                }
 1931|      0|                if (type == SSH_OPTIONS_PUBKEY_AUTH) {
  ------------------
  |  Branch (1931:21): [True: 0, False: 0]
  ------------------
 1932|       |                    /*
 1933|       |                     * Keep the legacy enabled/disabled auth flag semantics in
 1934|       |                     * sync above while also storing the selected
 1935|       |                     * PubkeyAuthentication mode here.
 1936|       |                     */
 1937|      0|                    switch (x) {
 1938|      0|                    case SSH_PUBKEY_AUTH_NO:
  ------------------
  |  Branch (1938:21): [True: 0, False: 0]
  ------------------
 1939|      0|                    case SSH_PUBKEY_AUTH_ALL:
  ------------------
  |  Branch (1939:21): [True: 0, False: 0]
  ------------------
 1940|      0|                    case SSH_PUBKEY_AUTH_UNBOUND:
  ------------------
  |  Branch (1940:21): [True: 0, False: 0]
  ------------------
 1941|      0|                    case SSH_PUBKEY_AUTH_HOST_BOUND:
  ------------------
  |  Branch (1941:21): [True: 0, False: 0]
  ------------------
 1942|      0|                        session->opts.pubkey_auth = x;
 1943|      0|                        break;
 1944|      0|                    default:
  ------------------
  |  Branch (1944:21): [True: 0, False: 0]
  ------------------
 1945|       |                        /* Preserve the legacy non-zero "yes" normalization
 1946|       |                         * here so callers passing -1 still land on
 1947|       |                         * SSH_PUBKEY_AUTH_ALL.
 1948|       |                         */
 1949|      0|                        session->opts.pubkey_auth = SSH_PUBKEY_AUTH_ALL;
 1950|      0|                        break;
 1951|      0|                    }
 1952|      0|                }
 1953|      0|            }
 1954|      0|            break;
 1955|      0|        case SSH_OPTIONS_NODELAY:
  ------------------
  |  Branch (1955:9): [True: 0, False: 4.73k]
  ------------------
 1956|      0|            if (value == NULL) {
  ------------------
  |  Branch (1956:17): [True: 0, False: 0]
  ------------------
 1957|      0|                ssh_set_error_invalid(session);
  ------------------
  |  |  324|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 1958|      0|                return -1;
 1959|      0|            } else {
 1960|      0|                int *x = (int *) value;
 1961|      0|                session->opts.nodelay = (*x & 0xff) > 0 ? 1 : 0;
  ------------------
  |  Branch (1961:41): [True: 0, False: 0]
  ------------------
 1962|      0|            }
 1963|      0|            break;
 1964|    473|        case SSH_OPTIONS_PROCESS_CONFIG:
  ------------------
  |  Branch (1964:9): [True: 473, False: 4.25k]
  ------------------
 1965|    473|            if (value == NULL) {
  ------------------
  |  Branch (1965:17): [True: 0, False: 473]
  ------------------
 1966|      0|                ssh_set_error_invalid(session);
  ------------------
  |  |  324|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 1967|      0|                return -1;
 1968|    473|            } else {
 1969|    473|                bool *x = (bool *)value;
 1970|    473|                session->opts.config_processed = !(*x);
 1971|    473|            }
 1972|    473|            break;
 1973|    473|        case SSH_OPTIONS_REKEY_DATA:
  ------------------
  |  Branch (1973:9): [True: 0, False: 4.73k]
  ------------------
 1974|      0|            if (value == NULL) {
  ------------------
  |  Branch (1974:17): [True: 0, False: 0]
  ------------------
 1975|      0|                ssh_set_error_invalid(session);
  ------------------
  |  |  324|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 1976|      0|                return -1;
 1977|      0|            } else {
 1978|      0|                uint64_t *x = (uint64_t *)value;
 1979|      0|                session->opts.rekey_data = *x;
 1980|      0|            }
 1981|      0|            break;
 1982|      0|        case SSH_OPTIONS_REKEY_TIME:
  ------------------
  |  Branch (1982:9): [True: 0, False: 4.73k]
  ------------------
 1983|      0|            if (value == NULL) {
  ------------------
  |  Branch (1983:17): [True: 0, False: 0]
  ------------------
 1984|      0|                ssh_set_error_invalid(session);
  ------------------
  |  |  324|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 1985|      0|                return -1;
 1986|      0|            } else {
 1987|      0|                uint32_t *x = (uint32_t *)value;
 1988|      0|                if (*x > UINT32_MAX / 1000) {
  ------------------
  |  Branch (1988:21): [True: 0, False: 0]
  ------------------
 1989|      0|                    ssh_set_error(session, SSH_REQUEST_DENIED,
  ------------------
  |  |  313|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
 1990|      0|                                  "The provided value (%" PRIu32 ") for rekey"
 1991|      0|                                  " time is too large", *x);
 1992|      0|                    return -1;
 1993|      0|                }
 1994|      0|                session->opts.rekey_time = (*x) * 1000;
 1995|      0|            }
 1996|      0|            break;
 1997|      0|        case SSH_OPTIONS_RSA_MIN_SIZE:
  ------------------
  |  Branch (1997:9): [True: 0, False: 4.73k]
  ------------------
 1998|      0|            if (value == NULL) {
  ------------------
  |  Branch (1998:17): [True: 0, False: 0]
  ------------------
 1999|      0|                ssh_set_error_invalid(session);
  ------------------
  |  |  324|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 2000|      0|                return -1;
 2001|      0|            } else {
 2002|      0|                int *x = (int *)value;
 2003|       |
 2004|      0|                if (*x < 0) {
  ------------------
  |  Branch (2004:21): [True: 0, False: 0]
  ------------------
 2005|      0|                    ssh_set_error_invalid(session);
  ------------------
  |  |  324|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 2006|      0|                    return -1;
 2007|      0|                }
 2008|       |
 2009|       |                /* (*x == 0) is allowed as it is used to revert to default */
 2010|       |
 2011|      0|                if (*x > 0 && *x < RSA_MIN_KEY_SIZE) {
  ------------------
  |  |   49|      0|#define RSA_MIN_KEY_SIZE      1024
  ------------------
  |  Branch (2011:21): [True: 0, False: 0]
  |  Branch (2011:31): [True: 0, False: 0]
  ------------------
 2012|      0|                    ssh_set_error(session,
  ------------------
  |  |  313|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
 2013|      0|                                  SSH_REQUEST_DENIED,
 2014|      0|                                  "The provided value (%d) for minimal RSA key "
 2015|      0|                                  "size is too small. Use at least %d bits.",
 2016|      0|                                  *x,
 2017|      0|                                  RSA_MIN_KEY_SIZE);
 2018|      0|                    return -1;
 2019|      0|                }
 2020|      0|                session->opts.rsa_min_size = *x;
 2021|      0|            }
 2022|      0|            break;
 2023|      0|        case SSH_OPTIONS_IDENTITY_AGENT:
  ------------------
  |  Branch (2023:9): [True: 0, False: 4.73k]
  ------------------
 2024|      0|            v = value;
 2025|      0|            SAFE_FREE(session->opts.agent_socket);
  ------------------
  |  |  375|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (375:31): [True: 0, False: 0]
  |  |  |  Branch (375:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2026|      0|            if (v == NULL) {
  ------------------
  |  Branch (2026:17): [True: 0, False: 0]
  ------------------
 2027|       |                /* The default value will be set by the ssh_options_apply() */
 2028|      0|            } else if (v[0] == '\0') {
  ------------------
  |  Branch (2028:24): [True: 0, False: 0]
  ------------------
 2029|      0|                ssh_set_error_invalid(session);
  ------------------
  |  |  324|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 2030|      0|                return -1;
 2031|      0|            } else {
 2032|      0|                session->opts.agent_socket = ssh_path_expand_tilde(v);
 2033|      0|                if (session->opts.agent_socket == NULL) {
  ------------------
  |  Branch (2033:21): [True: 0, False: 0]
  ------------------
 2034|      0|                    ssh_set_error_oom(session);
  ------------------
  |  |  320|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
 2035|      0|                    return -1;
 2036|      0|                }
 2037|      0|            }
 2038|      0|            break;
 2039|      0|        case SSH_OPTIONS_IDENTITIES_ONLY:
  ------------------
  |  Branch (2039:9): [True: 0, False: 4.73k]
  ------------------
 2040|      0|            if (value == NULL) {
  ------------------
  |  Branch (2040:17): [True: 0, False: 0]
  ------------------
 2041|      0|                ssh_set_error_invalid(session);
  ------------------
  |  |  324|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 2042|      0|                return -1;
 2043|      0|            } else {
 2044|      0|                bool *x = (bool *)value;
 2045|      0|                session->opts.identities_only = *x;
 2046|      0|            }
 2047|      0|            break;
 2048|      0|        case SSH_OPTIONS_CONTROL_MASTER:
  ------------------
  |  Branch (2048:9): [True: 0, False: 4.73k]
  ------------------
 2049|      0|            if (value == NULL) {
  ------------------
  |  Branch (2049:17): [True: 0, False: 0]
  ------------------
 2050|      0|                ssh_set_error_invalid(session);
  ------------------
  |  |  324|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 2051|      0|                return -1;
 2052|      0|            } else {
 2053|      0|                int *x = (int *) value;
 2054|      0|                if (*x < SSH_CONTROL_MASTER_NO || *x > SSH_CONTROL_MASTER_AUTOASK) {
  ------------------
  |  Branch (2054:21): [True: 0, False: 0]
  |  Branch (2054:51): [True: 0, False: 0]
  ------------------
 2055|      0|                    ssh_set_error_invalid(session);
  ------------------
  |  |  324|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 2056|      0|                    return -1;
 2057|      0|                }
 2058|      0|                session->opts.control_master = *x;
 2059|      0|            }
 2060|      0|            break;
 2061|      0|        case SSH_OPTIONS_CONTROL_PATH:
  ------------------
  |  Branch (2061:9): [True: 0, False: 4.73k]
  ------------------
 2062|      0|            v = value;
 2063|      0|            if (v == NULL || v[0] == '\0') {
  ------------------
  |  Branch (2063:17): [True: 0, False: 0]
  |  Branch (2063:30): [True: 0, False: 0]
  ------------------
 2064|      0|                ssh_set_error_invalid(session);
  ------------------
  |  |  324|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 2065|      0|                return -1;
 2066|      0|            } else {
 2067|      0|                SAFE_FREE(session->opts.control_path);
  ------------------
  |  |  375|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (375:31): [True: 0, False: 0]
  |  |  |  Branch (375:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2068|      0|                rc = strcasecmp(v, "none");
 2069|      0|                if (rc != 0) {
  ------------------
  |  Branch (2069:21): [True: 0, False: 0]
  ------------------
 2070|      0|                    session->opts.control_path = ssh_path_expand_tilde(v);
 2071|      0|                    if (session->opts.control_path == NULL) {
  ------------------
  |  Branch (2071:25): [True: 0, False: 0]
  ------------------
 2072|      0|                        ssh_set_error_oom(session);
  ------------------
  |  |  320|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
 2073|      0|                        return -1;
 2074|      0|                    }
 2075|      0|                    session->opts.exp_flags &= ~SSH_OPT_EXP_FLAG_CONTROL_PATH;
  ------------------
  |  |  119|      0|#define SSH_OPT_EXP_FLAG_CONTROL_PATH 0x10
  ------------------
 2076|      0|                }
 2077|      0|            }
 2078|      0|            break;
 2079|      0|        case SSH_OPTIONS_PKI_CONTEXT:
  ------------------
  |  Branch (2079:9): [True: 0, False: 4.73k]
  ------------------
 2080|      0|            if (value == NULL) {
  ------------------
  |  Branch (2080:17): [True: 0, False: 0]
  ------------------
 2081|      0|                ssh_set_error_invalid(session);
  ------------------
  |  |  324|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 2082|      0|                return -1;
 2083|      0|            }
 2084|       |
 2085|      0|            SSH_PKI_CTX_FREE(session->pki_context);
  ------------------
  |  | 1017|      0|    do {                         \
  |  | 1018|      0|        if ((x) != NULL) {       \
  |  |  ------------------
  |  |  |  Branch (1018:13): [True: 0, False: 0]
  |  |  ------------------
  |  | 1019|      0|            ssh_pki_ctx_free(x); \
  |  | 1020|      0|            x = NULL;            \
  |  | 1021|      0|        }                        \
  |  | 1022|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (1022:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2086|       |
 2087|      0|            session->pki_context = ssh_pki_ctx_dup((const ssh_pki_ctx)value);
 2088|      0|            if (session->pki_context == NULL) {
  ------------------
  |  Branch (2088:17): [True: 0, False: 0]
  ------------------
 2089|      0|                ssh_set_error_oom(session);
  ------------------
  |  |  320|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
 2090|      0|                return -1;
 2091|      0|            }
 2092|      0|            break;
 2093|      0|        case SSH_OPTIONS_ADDRESS_FAMILY:
  ------------------
  |  Branch (2093:9): [True: 0, False: 4.73k]
  ------------------
 2094|      0|            if (value == NULL) {
  ------------------
  |  Branch (2094:17): [True: 0, False: 0]
  ------------------
 2095|      0|                ssh_set_error_invalid(session);
  ------------------
  |  |  324|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 2096|      0|                return -1;
 2097|      0|            } else {
 2098|      0|                int *x = (int *)value;
 2099|      0|                if (*x < SSH_ADDRESS_FAMILY_ANY ||
  ------------------
  |  Branch (2099:21): [True: 0, False: 0]
  ------------------
 2100|      0|                    *x > SSH_ADDRESS_FAMILY_INET6) {
  ------------------
  |  Branch (2100:21): [True: 0, False: 0]
  ------------------
 2101|      0|                    ssh_set_error_invalid(session);
  ------------------
  |  |  324|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 2102|      0|                    return -1;
 2103|      0|                }
 2104|      0|                session->opts.address_family = *x;
 2105|      0|            }
 2106|      0|            break;
 2107|      0|        case SSH_OPTIONS_BATCH_MODE:
  ------------------
  |  Branch (2107:9): [True: 0, False: 4.73k]
  ------------------
 2108|      0|            if (value == NULL) {
  ------------------
  |  Branch (2108:17): [True: 0, False: 0]
  ------------------
 2109|      0|                ssh_set_error_invalid(session);
  ------------------
  |  |  324|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 2110|      0|                return -1;
 2111|      0|            } else {
 2112|      0|                bool *x = (bool *)value;
 2113|      0|                session->opts.batch_mode = *x;
 2114|      0|            }
 2115|      0|            break;
 2116|      0|        case SSH_OPTIONS_SERVER_ALIVE_INTERVAL:
  ------------------
  |  Branch (2116:9): [True: 0, False: 4.73k]
  ------------------
 2117|      0|            if (value == NULL) {
  ------------------
  |  Branch (2117:17): [True: 0, False: 0]
  ------------------
 2118|      0|                ssh_set_error_invalid(session);
  ------------------
  |  |  324|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 2119|      0|                return -1;
 2120|      0|            } else {
 2121|      0|                int *x = (int *)value;
 2122|      0|                if (*x < 0) {
  ------------------
  |  Branch (2122:21): [True: 0, False: 0]
  ------------------
 2123|      0|                    ssh_set_error_invalid(session);
  ------------------
  |  |  324|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 2124|      0|                    return -1;
 2125|      0|                }
 2126|      0|                session->opts.server_alive_interval = *x;
 2127|      0|            }
 2128|      0|            break;
 2129|      0|        case SSH_OPTIONS_SERVER_ALIVE_COUNT_MAX:
  ------------------
  |  Branch (2129:9): [True: 0, False: 4.73k]
  ------------------
 2130|      0|            if (value == NULL) {
  ------------------
  |  Branch (2130:17): [True: 0, False: 0]
  ------------------
 2131|      0|                ssh_set_error_invalid(session);
  ------------------
  |  |  324|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 2132|      0|                return -1;
 2133|      0|            } else {
 2134|      0|                int *x = (int *)value;
 2135|      0|                if (*x < 0) {
  ------------------
  |  Branch (2135:21): [True: 0, False: 0]
  ------------------
 2136|      0|                    ssh_set_error_invalid(session);
  ------------------
  |  |  324|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 2137|      0|                    return -1;
 2138|      0|                }
 2139|      0|                session->opts.server_alive_count_max = *x;
 2140|      0|            }
 2141|      0|            break;
 2142|      0|        case SSH_OPTIONS_ESCAPE_CHAR:
  ------------------
  |  Branch (2142:9): [True: 0, False: 4.73k]
  ------------------
 2143|      0|            if (value == NULL) {
  ------------------
  |  Branch (2143:17): [True: 0, False: 0]
  ------------------
 2144|      0|                ssh_set_error_invalid(session);
  ------------------
  |  |  324|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 2145|      0|                return -1;
 2146|      0|            } else {
 2147|      0|                int *x = (int *)value;
 2148|      0|                if (*x == 0 || *x < -1 || *x > 255) {
  ------------------
  |  Branch (2148:21): [True: 0, False: 0]
  |  Branch (2148:32): [True: 0, False: 0]
  |  Branch (2148:43): [True: 0, False: 0]
  ------------------
 2149|      0|                    ssh_set_error_invalid(session);
  ------------------
  |  |  324|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 2150|      0|                    return -1;
 2151|      0|                }
 2152|      0|                session->opts.escape_char = *x;
 2153|      0|            }
 2154|      0|            break;
 2155|      0|        case SSH_OPTIONS_LOCAL_FORWARD:
  ------------------
  |  Branch (2155:9): [True: 0, False: 4.73k]
  ------------------
 2156|      0|            v = value;
 2157|      0|            if (v == NULL || v[0] == '\0') {
  ------------------
  |  Branch (2157:17): [True: 0, False: 0]
  |  Branch (2157:30): [True: 0, False: 0]
  ------------------
 2158|      0|                ssh_set_error_invalid(session);
  ------------------
  |  |  324|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 2159|      0|                return -1;
 2160|      0|            }
 2161|      0|            q = strdup(v);
 2162|      0|            if (q == NULL) {
  ------------------
  |  Branch (2162:17): [True: 0, False: 0]
  ------------------
 2163|      0|                ssh_set_error_oom(session);
  ------------------
  |  |  320|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
 2164|      0|                return -1;
 2165|      0|            }
 2166|       |            /* Allocate on first use (no longer pre-allocated in ssh_new()) */
 2167|      0|            if (session->opts.local_forward == NULL) {
  ------------------
  |  Branch (2167:17): [True: 0, False: 0]
  ------------------
 2168|      0|                session->opts.local_forward = ssh_list_new();
 2169|      0|                if (session->opts.local_forward == NULL) {
  ------------------
  |  Branch (2169:21): [True: 0, False: 0]
  ------------------
 2170|      0|                    free(q);
 2171|      0|                    ssh_set_error_oom(session);
  ------------------
  |  |  320|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
 2172|      0|                    return -1;
 2173|      0|                }
 2174|      0|            }
 2175|      0|            rc = ssh_list_append(session->opts.local_forward, q);
 2176|      0|            if (rc < 0) {
  ------------------
  |  Branch (2176:17): [True: 0, False: 0]
  ------------------
 2177|      0|                free(q);
 2178|      0|                ssh_set_error_oom(session);
  ------------------
  |  |  320|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
 2179|      0|                return -1;
 2180|      0|            }
 2181|      0|            break;
 2182|      0|        case SSH_OPTIONS_REMOTE_FORWARD:
  ------------------
  |  Branch (2182:9): [True: 0, False: 4.73k]
  ------------------
 2183|      0|            v = value;
 2184|      0|            if (v == NULL || v[0] == '\0') {
  ------------------
  |  Branch (2184:17): [True: 0, False: 0]
  |  Branch (2184:30): [True: 0, False: 0]
  ------------------
 2185|      0|                ssh_set_error_invalid(session);
  ------------------
  |  |  324|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 2186|      0|                return -1;
 2187|      0|            }
 2188|      0|            q = strdup(v);
 2189|      0|            if (q == NULL) {
  ------------------
  |  Branch (2189:17): [True: 0, False: 0]
  ------------------
 2190|      0|                ssh_set_error_oom(session);
  ------------------
  |  |  320|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
 2191|      0|                return -1;
 2192|      0|            }
 2193|       |            /* Lazy allocation: allocate list on first use */
 2194|      0|            if (session->opts.remote_forward == NULL) {
  ------------------
  |  Branch (2194:17): [True: 0, False: 0]
  ------------------
 2195|      0|                session->opts.remote_forward = ssh_list_new();
 2196|      0|                if (session->opts.remote_forward == NULL) {
  ------------------
  |  Branch (2196:21): [True: 0, False: 0]
  ------------------
 2197|      0|                    free(q);
 2198|      0|                    ssh_set_error_oom(session);
  ------------------
  |  |  320|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
 2199|      0|                    return -1;
 2200|      0|                }
 2201|      0|            }
 2202|      0|            rc = ssh_list_append(session->opts.remote_forward, q);
 2203|      0|            if (rc < 0) {
  ------------------
  |  Branch (2203:17): [True: 0, False: 0]
  ------------------
 2204|      0|                free(q);
 2205|      0|                ssh_set_error_oom(session);
  ------------------
  |  |  320|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
 2206|      0|                return -1;
 2207|      0|            }
 2208|      0|            break;
 2209|      0|        case SSH_OPTIONS_PREFERRED_AUTHENTICATIONS:
  ------------------
  |  Branch (2209:9): [True: 0, False: 4.73k]
  ------------------
 2210|      0|            v = value;
 2211|      0|            SAFE_FREE(session->opts.preferred_authentications);
  ------------------
  |  |  375|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (375:31): [True: 0, False: 0]
  |  |  |  Branch (375:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2212|      0|            if (v != NULL) {
  ------------------
  |  Branch (2212:17): [True: 0, False: 0]
  ------------------
 2213|      0|                if (v[0] == '\0') {
  ------------------
  |  Branch (2213:21): [True: 0, False: 0]
  ------------------
 2214|      0|                    ssh_set_error_invalid(session);
  ------------------
  |  |  324|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 2215|      0|                    return -1;
 2216|      0|                }
 2217|      0|                session->opts.preferred_authentications = strdup(v);
 2218|      0|                if (session->opts.preferred_authentications == NULL) {
  ------------------
  |  Branch (2218:21): [True: 0, False: 0]
  ------------------
 2219|      0|                    ssh_set_error_oom(session);
  ------------------
  |  |  320|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
 2220|      0|                    return -1;
 2221|      0|                }
 2222|      0|            }
 2223|      0|            break;
 2224|      0|        case SSH_OPTIONS_NUMBER_OF_PASSWORD_PROMPTS:
  ------------------
  |  Branch (2224:9): [True: 0, False: 4.73k]
  ------------------
 2225|      0|            if (value == NULL) {
  ------------------
  |  Branch (2225:17): [True: 0, False: 0]
  ------------------
 2226|      0|                ssh_set_error_invalid(session);
  ------------------
  |  |  324|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 2227|      0|                return -1;
 2228|      0|            } else {
 2229|      0|                int *x = (int *)value;
 2230|      0|                if (*x <= 0) {
  ------------------
  |  Branch (2230:21): [True: 0, False: 0]
  ------------------
 2231|      0|                    ssh_set_error_invalid(session);
  ------------------
  |  |  324|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 2232|      0|                    return -1;
 2233|      0|                }
 2234|      0|                session->opts.number_of_password_prompts = *x;
 2235|      0|            }
 2236|      0|            break;
 2237|      0|        case SSH_OPTIONS_REQUEST_TTY:
  ------------------
  |  Branch (2237:9): [True: 0, False: 4.73k]
  ------------------
 2238|      0|            if (value == NULL) {
  ------------------
  |  Branch (2238:17): [True: 0, False: 0]
  ------------------
 2239|      0|                ssh_set_error_invalid(session);
  ------------------
  |  |  324|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 2240|      0|                return -1;
 2241|      0|            } else {
 2242|      0|                int *x = (int *)value;
 2243|      0|                if (*x < SSH_REQUEST_TTY_NO || *x > SSH_REQUEST_TTY_FORCE) {
  ------------------
  |  Branch (2243:21): [True: 0, False: 0]
  |  Branch (2243:48): [True: 0, False: 0]
  ------------------
 2244|      0|                    ssh_set_error_invalid(session);
  ------------------
  |  |  324|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 2245|      0|                    return -1;
 2246|      0|                }
 2247|      0|                session->opts.request_tty = *x;
 2248|      0|            }
 2249|      0|            break;
 2250|      0|        case SSH_OPTIONS_SEND_ENV:
  ------------------
  |  Branch (2250:9): [True: 0, False: 4.73k]
  ------------------
 2251|      0|            v = value;
 2252|      0|            if (v == NULL || v[0] == '\0') {
  ------------------
  |  Branch (2252:17): [True: 0, False: 0]
  |  Branch (2252:30): [True: 0, False: 0]
  ------------------
 2253|      0|                ssh_set_error_invalid(session);
  ------------------
  |  |  324|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 2254|      0|                return -1;
 2255|      0|            }
 2256|       |            /* A leading '-' removes the pattern from the list */
 2257|      0|            if (v[0] == '-') {
  ------------------
  |  Branch (2257:17): [True: 0, False: 0]
  ------------------
 2258|      0|                const char *pattern = NULL;
 2259|      0|                const char *env_value = NULL;
 2260|      0|                struct ssh_iterator *it = NULL;
 2261|      0|                struct ssh_iterator *next = NULL;
 2262|      0|                int cmp = 0;
 2263|       |
 2264|      0|                pattern = v + 1;
 2265|      0|                if (pattern[0] == '\0') {
  ------------------
  |  Branch (2265:21): [True: 0, False: 0]
  ------------------
 2266|      0|                    ssh_set_error_invalid(session);
  ------------------
  |  |  324|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 2267|      0|                    return -1;
 2268|      0|                }
 2269|      0|                it = ssh_list_get_iterator(session->opts.send_env);
 2270|      0|                while (it != NULL) {
  ------------------
  |  Branch (2270:24): [True: 0, False: 0]
  ------------------
 2271|      0|                    env_value = ssh_iterator_value(const char *, it);
  ------------------
  |  |  122|      0|  ((type)((iterator)->data))
  ------------------
 2272|      0|                    cmp = strcmp(env_value, pattern);
 2273|      0|                    next = it->next;
 2274|      0|                    if (cmp == 0) {
  ------------------
  |  Branch (2274:25): [True: 0, False: 0]
  ------------------
 2275|      0|                        free((void *)env_value);
 2276|      0|                        ssh_list_remove(session->opts.send_env, it);
 2277|      0|                    }
 2278|      0|                    it = next;
 2279|      0|                }
 2280|      0|                rc = SSH_OK;
  ------------------
  |  |  315|      0|#define SSH_OK 0     /* No error */
  ------------------
 2281|      0|            } else {
 2282|      0|                q = strdup(v);
 2283|      0|                if (q == NULL) {
  ------------------
  |  Branch (2283:21): [True: 0, False: 0]
  ------------------
 2284|      0|                    ssh_set_error_oom(session);
  ------------------
  |  |  320|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
 2285|      0|                    return -1;
 2286|      0|                }
 2287|       |                /* Allocate on first use (no longer pre-allocated in ssh_new()) */
 2288|      0|                if (session->opts.send_env == NULL) {
  ------------------
  |  Branch (2288:21): [True: 0, False: 0]
  ------------------
 2289|      0|                    session->opts.send_env = ssh_list_new();
 2290|      0|                    if (session->opts.send_env == NULL) {
  ------------------
  |  Branch (2290:25): [True: 0, False: 0]
  ------------------
 2291|      0|                        free(q);
 2292|      0|                        ssh_set_error_oom(session);
  ------------------
  |  |  320|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
 2293|      0|                        return -1;
 2294|      0|                    }
 2295|      0|                }
 2296|      0|                rc = ssh_list_append(session->opts.send_env, q);
 2297|      0|                if (rc < 0) {
  ------------------
  |  Branch (2297:21): [True: 0, False: 0]
  ------------------
 2298|      0|                    free(q);
 2299|      0|                    ssh_set_error_oom(session);
  ------------------
  |  |  320|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
 2300|      0|                    return -1;
 2301|      0|                }
 2302|      0|            }
 2303|      0|            break;
 2304|      0|        case SSH_OPTIONS_EXIT_ON_FORWARD_FAILURE:
  ------------------
  |  Branch (2304:9): [True: 0, False: 4.73k]
  ------------------
 2305|      0|            if (value == NULL) {
  ------------------
  |  Branch (2305:17): [True: 0, False: 0]
  ------------------
 2306|      0|                ssh_set_error_invalid(session);
  ------------------
  |  |  324|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 2307|      0|                return -1;
 2308|      0|            } else {
 2309|      0|                bool *x = (bool *)value;
 2310|      0|                session->opts.exit_on_forward_failure = *x;
 2311|      0|            }
 2312|      0|            break;
 2313|      0|        case SSH_OPTIONS_FORWARD_AGENT:
  ------------------
  |  Branch (2313:9): [True: 0, False: 4.73k]
  ------------------
 2314|      0|            if (value == NULL) {
  ------------------
  |  Branch (2314:17): [True: 0, False: 0]
  ------------------
 2315|      0|                ssh_set_error_invalid(session);
  ------------------
  |  |  324|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 2316|      0|                return -1;
 2317|      0|            } else {
 2318|      0|                bool *x = (bool *)value;
 2319|      0|                session->opts.forward_agent = *x;
 2320|      0|            }
 2321|      0|            break;
 2322|      0|        case SSH_OPTIONS_FORWARD_AGENT_SOCK_PATH:
  ------------------
  |  Branch (2322:9): [True: 0, False: 4.73k]
  ------------------
 2323|      0|            v = value;
 2324|      0|            SAFE_FREE(session->opts.forward_agent_sock_path);
  ------------------
  |  |  375|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (375:31): [True: 0, False: 0]
  |  |  |  Branch (375:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2325|      0|            if (v == NULL || v[0] == '\0') {
  ------------------
  |  Branch (2325:17): [True: 0, False: 0]
  |  Branch (2325:30): [True: 0, False: 0]
  ------------------
 2326|      0|                ssh_set_error_invalid(session);
  ------------------
  |  |  324|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 2327|      0|                return -1;
 2328|      0|            } else {
 2329|      0|                session->opts.forward_agent_sock_path =
 2330|      0|                    ssh_path_expand_tilde(v);
 2331|      0|                if (session->opts.forward_agent_sock_path == NULL) {
  ------------------
  |  Branch (2331:21): [True: 0, False: 0]
  ------------------
 2332|      0|                    ssh_set_error_oom(session);
  ------------------
  |  |  320|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
 2333|      0|                    return -1;
 2334|      0|                }
 2335|      0|            }
 2336|      0|            break;
 2337|      0|        case SSH_OPTIONS_GATEWAY_PORTS:
  ------------------
  |  Branch (2337:9): [True: 0, False: 4.73k]
  ------------------
 2338|      0|            if (value == NULL) {
  ------------------
  |  Branch (2338:17): [True: 0, False: 0]
  ------------------
 2339|      0|                ssh_set_error_invalid(session);
  ------------------
  |  |  324|      0|    _ssh_set_error_invalid(error, __func__)
  ------------------
 2340|      0|                return -1;
 2341|      0|            } else {
 2342|      0|                bool *x = (bool *)value;
 2343|      0|                session->opts.gateway_ports = *x;
 2344|      0|            }
 2345|      0|            break;
 2346|      0|        default:
  ------------------
  |  Branch (2346:9): [True: 0, False: 4.73k]
  ------------------
 2347|      0|            ssh_set_error(session, SSH_REQUEST_DENIED, "Unknown ssh option %d", type);
  ------------------
  |  |  313|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
 2348|      0|            return -1;
 2349|      0|            break;
 2350|  4.73k|    }
 2351|       |
 2352|       |    /*
 2353|       |     * The option was set successfully. Mark config-backed options as
 2354|       |     * explicitly set so that later processing of OpenSSH configuration files
 2355|       |     * keeps the application's value (issue #365). Options that map to
 2356|       |     * SOC_UNKNOWN are intentionally left unmarked.
 2357|       |     */
 2358|  4.73k|    opcode = ssh_opt_type_to_opcode(type);
 2359|  4.73k|    if (opcode != SOC_UNKNOWN) {
  ------------------
  |  Branch (2359:9): [True: 2.83k, False: 1.89k]
  ------------------
 2360|  2.83k|        session->opts.options_seen[opcode] = 1;
 2361|  2.83k|    }
 2362|       |
 2363|  4.73k|    return 0;
 2364|  4.73k|}
ssh_options_apply:
 3212|    473|{
 3213|    473|    char *tmp = NULL;
 3214|    473|    int rc;
 3215|       |
 3216|    473|    if (session->opts.host != NULL) {
  ------------------
  |  Branch (3216:9): [True: 473, False: 0]
  ------------------
 3217|    473|        char *normalized_host = NULL;
 3218|    473|        rc = ssh_normalize_loose_ip(session->opts.host, &normalized_host);
 3219|    473|        if (rc == -1) {
  ------------------
  |  Branch (3219:13): [True: 0, False: 473]
  ------------------
 3220|       |            /* Error (e.g. NULL input or OOM) — leave host as it is */
 3221|    473|        } else if (rc == 0) {
  ------------------
  |  Branch (3221:20): [True: 0, False: 473]
  ------------------
 3222|       |            /* Was a loose IP — use the normalized dotted-quad form */
 3223|      0|            SAFE_FREE(session->opts.host);
  ------------------
  |  |  375|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (375:31): [True: 0, False: 0]
  |  |  |  Branch (375:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
 3224|      0|            session->opts.host = normalized_host;
 3225|    473|        } else {
 3226|       |            /* rc == 1: not a loose IP — lowercase if it's not a strict IP */
 3227|    473|            bool requires_lowercase = ssh_host_requires_lowercase(session->opts.host);
 3228|    473|            if (requires_lowercase) {
  ------------------
  |  Branch (3228:17): [True: 0, False: 473]
  ------------------
 3229|      0|                char *lower = ssh_lowercase(session->opts.host);
 3230|      0|                if (lower != NULL) {
  ------------------
  |  Branch (3230:21): [True: 0, False: 0]
  ------------------
 3231|      0|                    SAFE_FREE(session->opts.host);
  ------------------
  |  |  375|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (375:31): [True: 0, False: 0]
  |  |  |  Branch (375:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
 3232|      0|                    session->opts.host = lower;
 3233|      0|                }
 3234|      0|            }
 3235|    473|        }
 3236|    473|    }
 3237|       |
 3238|    473|    if (session->opts.sshdir == NULL) {
  ------------------
  |  Branch (3238:9): [True: 473, False: 0]
  ------------------
 3239|    473|        rc = ssh_options_set(session, SSH_OPTIONS_SSH_DIR, NULL);
 3240|    473|        if (rc < 0) {
  ------------------
  |  Branch (3240:13): [True: 0, False: 473]
  ------------------
 3241|      0|            return -1;
 3242|      0|        }
 3243|    473|    }
 3244|       |
 3245|    473|    if (session->opts.username == NULL) {
  ------------------
  |  Branch (3245:9): [True: 0, False: 473]
  ------------------
 3246|      0|        rc = ssh_options_set(session, SSH_OPTIONS_USER, NULL);
 3247|      0|        if (rc < 0) {
  ------------------
  |  Branch (3247:13): [True: 0, False: 0]
  ------------------
 3248|      0|            return -1;
 3249|      0|        }
 3250|      0|    }
 3251|       |
 3252|    473|    if (session->opts.config_hostname != NULL) {
  ------------------
  |  Branch (3252:9): [True: 0, False: 473]
  ------------------
 3253|      0|        char *saved_host = NULL;
 3254|       |
 3255|      0|        tmp = ssh_path_expand_hostname(session, session->opts.config_hostname);
 3256|      0|        if (tmp == NULL) {
  ------------------
  |  Branch (3256:13): [True: 0, False: 0]
  ------------------
 3257|      0|            return -1;
 3258|      0|        }
 3259|      0|        if (session->opts.host != NULL) {
  ------------------
  |  Branch (3259:13): [True: 0, False: 0]
  ------------------
 3260|      0|            saved_host = strdup(session->opts.host);
 3261|      0|            if (saved_host == NULL) {
  ------------------
  |  Branch (3261:17): [True: 0, False: 0]
  ------------------
 3262|      0|                free(tmp);
 3263|      0|                ssh_set_error_oom(session);
  ------------------
  |  |  320|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
 3264|      0|                return -1;
 3265|      0|            }
 3266|      0|        }
 3267|      0|        session->opts.config_hostname_only = true;
 3268|      0|        rc = ssh_options_set(session, SSH_OPTIONS_HOST, tmp);
 3269|      0|        session->opts.config_hostname_only = false;
 3270|      0|        if (rc != SSH_OK) {
  ------------------
  |  |  315|      0|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (3270:13): [True: 0, False: 0]
  ------------------
 3271|       |            /* If HostName expansion leaves a literal '%', keep the current
 3272|       |             * host instead of treating the deferred HostName as fatal.
 3273|       |             */
 3274|      0|            if (strchr(tmp, '%') == NULL) {
  ------------------
  |  Branch (3274:17): [True: 0, False: 0]
  ------------------
 3275|      0|                SAFE_FREE(saved_host);
  ------------------
  |  |  375|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (375:31): [True: 0, False: 0]
  |  |  |  Branch (375:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
 3276|      0|                free(tmp);
 3277|      0|                return -1;
 3278|      0|            }
 3279|      0|            SSH_LOG(SSH_LOG_WARN,
  ------------------
  |  |  283|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 3280|      0|                    "HostName %s contains unknown expansion tokens and could "
 3281|      0|                    "not be applied; falling back to current host",
 3282|      0|                    tmp);
 3283|      0|            SAFE_FREE(session->opts.host);
  ------------------
  |  |  375|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (375:31): [True: 0, False: 0]
  |  |  |  Branch (375:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
 3284|      0|            session->opts.host = saved_host;
 3285|      0|            saved_host = NULL;
 3286|      0|        }
 3287|      0|        SAFE_FREE(saved_host);
  ------------------
  |  |  375|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (375:31): [True: 0, False: 0]
  |  |  |  Branch (375:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
 3288|      0|        free(tmp);
 3289|      0|        SAFE_FREE(session->opts.config_hostname);
  ------------------
  |  |  375|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (375:31): [True: 0, False: 0]
  |  |  |  Branch (375:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
 3290|      0|    }
 3291|       |
 3292|       |    /* Expand percent tokens in the username at apply time, matching OpenSSH
 3293|       |     * which defers User expansion to after all options are resolved.
 3294|       |     */
 3295|    473|    if ((session->opts.exp_flags & SSH_OPT_EXP_FLAG_USERNAME) == 0 &&
  ------------------
  |  |  120|    473|#define SSH_OPT_EXP_FLAG_USERNAME 0x20
  ------------------
  |  Branch (3295:9): [True: 473, False: 0]
  ------------------
 3296|    473|        session->opts.username != NULL) {
  ------------------
  |  Branch (3296:9): [True: 473, False: 0]
  ------------------
 3297|    473|        tmp = ssh_string_expand_escape(session, session->opts.username);
 3298|    473|        if (tmp != NULL) {
  ------------------
  |  Branch (3298:13): [True: 473, False: 0]
  ------------------
 3299|    473|            free(session->opts.username);
 3300|    473|            session->opts.username = tmp;
 3301|    473|            tmp = NULL;
 3302|    473|        }
 3303|       |        /* On failure, keep the raw string — best-effort expansion */
 3304|    473|        session->opts.exp_flags |= SSH_OPT_EXP_FLAG_USERNAME;
  ------------------
  |  |  120|    473|#define SSH_OPT_EXP_FLAG_USERNAME 0x20
  ------------------
 3305|    473|    }
 3306|       |
 3307|    473|    if ((session->opts.exp_flags & SSH_OPT_EXP_FLAG_KNOWNHOSTS) == 0) {
  ------------------
  |  |  115|    473|#define SSH_OPT_EXP_FLAG_KNOWNHOSTS 0x1
  ------------------
  |  Branch (3307:9): [True: 473, False: 0]
  ------------------
 3308|    473|        if (session->opts.knownhosts == NULL) {
  ------------------
  |  Branch (3308:13): [True: 473, False: 0]
  ------------------
 3309|    473|            tmp = ssh_path_expand_escape(session, "%d/.ssh/known_hosts");
 3310|    473|        } else {
 3311|      0|            tmp = ssh_path_expand_escape(session, session->opts.knownhosts);
 3312|      0|        }
 3313|    473|        if (tmp == NULL) {
  ------------------
  |  Branch (3313:13): [True: 0, False: 473]
  ------------------
 3314|      0|            return -1;
 3315|      0|        }
 3316|    473|        free(session->opts.knownhosts);
 3317|    473|        session->opts.knownhosts = tmp;
 3318|    473|        session->opts.exp_flags |= SSH_OPT_EXP_FLAG_KNOWNHOSTS;
  ------------------
  |  |  115|    473|#define SSH_OPT_EXP_FLAG_KNOWNHOSTS 0x1
  ------------------
 3319|    473|    }
 3320|       |
 3321|    473|    if ((session->opts.exp_flags & SSH_OPT_EXP_FLAG_GLOBAL_KNOWNHOSTS) == 0) {
  ------------------
  |  |  116|    473|#define SSH_OPT_EXP_FLAG_GLOBAL_KNOWNHOSTS 0x2
  ------------------
  |  Branch (3321:9): [True: 473, False: 0]
  ------------------
 3322|    473|        if (session->opts.global_knownhosts == NULL) {
  ------------------
  |  Branch (3322:13): [True: 473, False: 0]
  ------------------
 3323|    473|            tmp = strdup(GLOBAL_CONF_DIR "/ssh_known_hosts");
  ------------------
  |  |   13|    473|#define GLOBAL_CONF_DIR "/etc/ssh"
  ------------------
 3324|    473|        } else {
 3325|      0|            tmp = ssh_path_expand_escape(session,
 3326|      0|                                         session->opts.global_knownhosts);
 3327|      0|        }
 3328|    473|        if (tmp == NULL) {
  ------------------
  |  Branch (3328:13): [True: 0, False: 473]
  ------------------
 3329|      0|            return -1;
 3330|      0|        }
 3331|    473|        free(session->opts.global_knownhosts);
 3332|    473|        session->opts.global_knownhosts = tmp;
 3333|    473|        session->opts.exp_flags |= SSH_OPT_EXP_FLAG_GLOBAL_KNOWNHOSTS;
  ------------------
  |  |  116|    473|#define SSH_OPT_EXP_FLAG_GLOBAL_KNOWNHOSTS 0x2
  ------------------
 3334|    473|    }
 3335|       |
 3336|       |
 3337|    473|    if ((session->opts.exp_flags & SSH_OPT_EXP_FLAG_PROXYCOMMAND) == 0) {
  ------------------
  |  |  117|    473|#define SSH_OPT_EXP_FLAG_PROXYCOMMAND 0x4
  ------------------
  |  Branch (3337:9): [True: 473, False: 0]
  ------------------
 3338|    473|        if (session->opts.ProxyCommand != NULL) {
  ------------------
  |  Branch (3338:13): [True: 0, False: 473]
  ------------------
 3339|      0|            char *p = NULL;
 3340|      0|            size_t plen = strlen(session->opts.ProxyCommand) +
 3341|      0|                          5 /* strlen("exec ") */;
 3342|       |
 3343|      0|            if (strncmp(session->opts.ProxyCommand, "exec ", 5) != 0) {
  ------------------
  |  Branch (3343:17): [True: 0, False: 0]
  ------------------
 3344|      0|                p = malloc(plen + 1 /* \0 */);
 3345|      0|                if (p == NULL) {
  ------------------
  |  Branch (3345:21): [True: 0, False: 0]
  ------------------
 3346|      0|                    return -1;
 3347|      0|                }
 3348|       |
 3349|      0|                rc = snprintf(p, plen + 1, "exec %s", session->opts.ProxyCommand);
 3350|      0|                if ((size_t)rc != plen) {
  ------------------
  |  Branch (3350:21): [True: 0, False: 0]
  ------------------
 3351|      0|                    free(p);
 3352|      0|                    return -1;
 3353|      0|                }
 3354|      0|                tmp = ssh_path_expand_escape(session, p);
 3355|      0|                free(p);
 3356|      0|            } else {
 3357|      0|                tmp = ssh_path_expand_escape(session,
 3358|      0|                                             session->opts.ProxyCommand);
 3359|      0|            }
 3360|       |
 3361|      0|            if (tmp == NULL) {
  ------------------
  |  Branch (3361:17): [True: 0, False: 0]
  ------------------
 3362|      0|                return -1;
 3363|      0|            }
 3364|      0|            free(session->opts.ProxyCommand);
 3365|      0|            session->opts.ProxyCommand = tmp;
 3366|      0|            session->opts.exp_flags |= SSH_OPT_EXP_FLAG_PROXYCOMMAND;
  ------------------
  |  |  117|      0|#define SSH_OPT_EXP_FLAG_PROXYCOMMAND 0x4
  ------------------
 3367|      0|        }
 3368|    473|    }
 3369|       |
 3370|    473|    if ((session->opts.exp_flags & SSH_OPT_EXP_FLAG_CONTROL_PATH) == 0) {
  ------------------
  |  |  119|    473|#define SSH_OPT_EXP_FLAG_CONTROL_PATH 0x10
  ------------------
  |  Branch (3370:9): [True: 473, False: 0]
  ------------------
 3371|    473|        if (session->opts.control_path != NULL) {
  ------------------
  |  Branch (3371:13): [True: 0, False: 473]
  ------------------
 3372|      0|            tmp = ssh_path_expand_escape(session, session->opts.control_path);
 3373|      0|            if (tmp == NULL) {
  ------------------
  |  Branch (3373:17): [True: 0, False: 0]
  ------------------
 3374|      0|                return -1;
 3375|      0|            }
 3376|      0|            free(session->opts.control_path);
 3377|      0|            session->opts.control_path = tmp;
 3378|      0|            session->opts.exp_flags |= SSH_OPT_EXP_FLAG_CONTROL_PATH;
  ------------------
  |  |  119|      0|#define SSH_OPT_EXP_FLAG_CONTROL_PATH 0x10
  ------------------
 3379|      0|        }
 3380|    473|    }
 3381|       |
 3382|       |    /* Allocate on first use (no longer pre-allocated in ssh_new()) */
 3383|    473|    if (session->opts.identity == NULL) {
  ------------------
  |  Branch (3383:9): [True: 473, False: 0]
  ------------------
 3384|    473|        session->opts.identity = ssh_list_new();
 3385|    473|        if (session->opts.identity == NULL) {
  ------------------
  |  Branch (3385:13): [True: 0, False: 473]
  ------------------
 3386|      0|            return -1;
 3387|      0|        }
 3388|    473|    }
 3389|       |
 3390|    473|    for (tmp = ssh_list_pop_head(char *, session->opts.identity_non_exp);
  ------------------
  |  |  130|    473|  ((type)_ssh_list_pop_head(ssh_list))
  ------------------
 3391|  1.89k|         tmp != NULL;
  ------------------
  |  Branch (3391:10): [True: 1.41k, False: 473]
  ------------------
 3392|  1.41k|         tmp = ssh_list_pop_head(char *, session->opts.identity_non_exp)) {
  ------------------
  |  |  130|  1.41k|  ((type)_ssh_list_pop_head(ssh_list))
  ------------------
 3393|  1.41k|        char *id = tmp;
 3394|  1.41k|        if (strncmp(id, "pkcs11:", 6) != 0) {
  ------------------
  |  Branch (3394:13): [True: 1.41k, False: 0]
  ------------------
 3395|       |            /* PKCS#11 URIs are using percent-encoding so we can not mix
 3396|       |             * it with ssh expansion of ssh escape characters.
 3397|       |             */
 3398|  1.41k|            tmp = ssh_path_expand_escape(session, id);
 3399|  1.41k|            free(id);
 3400|  1.41k|            if (tmp == NULL) {
  ------------------
  |  Branch (3400:17): [True: 0, False: 1.41k]
  ------------------
 3401|      0|                return -1;
 3402|      0|            }
 3403|  1.41k|        }
 3404|       |
 3405|       |        /* use append to keep the order at first call and use prepend
 3406|       |         * to put anything that comes on the nth calls to the beginning */
 3407|  1.41k|        if (session->opts.exp_flags & SSH_OPT_EXP_FLAG_IDENTITY) {
  ------------------
  |  |  118|  1.41k|#define SSH_OPT_EXP_FLAG_IDENTITY 0x8
  ------------------
  |  Branch (3407:13): [True: 0, False: 1.41k]
  ------------------
 3408|      0|            rc = ssh_list_prepend(session->opts.identity, tmp);
 3409|  1.41k|        } else {
 3410|  1.41k|            rc = ssh_list_append(session->opts.identity, tmp);
 3411|  1.41k|        }
 3412|  1.41k|        if (rc != SSH_OK) {
  ------------------
  |  |  315|  1.41k|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (3412:13): [True: 0, False: 1.41k]
  ------------------
 3413|      0|            free(tmp);
 3414|      0|            return -1;
 3415|      0|        }
 3416|  1.41k|    }
 3417|    473|    session->opts.exp_flags |= SSH_OPT_EXP_FLAG_IDENTITY;
  ------------------
  |  |  118|    473|#define SSH_OPT_EXP_FLAG_IDENTITY 0x8
  ------------------
 3418|       |
 3419|       |    /* Allocate on first use (no longer pre-allocated in ssh_new()) */
 3420|    473|    if (session->opts.certificate == NULL) {
  ------------------
  |  Branch (3420:9): [True: 473, False: 0]
  ------------------
 3421|    473|        session->opts.certificate = ssh_list_new();
 3422|    473|        if (session->opts.certificate == NULL) {
  ------------------
  |  Branch (3422:13): [True: 0, False: 473]
  ------------------
 3423|      0|            return -1;
 3424|      0|        }
 3425|    473|    }
 3426|       |
 3427|    473|    for (tmp = ssh_list_pop_head(char *, session->opts.certificate_non_exp);
  ------------------
  |  |  130|    473|  ((type)_ssh_list_pop_head(ssh_list))
  ------------------
 3428|    473|         tmp != NULL;
  ------------------
  |  Branch (3428:10): [True: 0, False: 473]
  ------------------
 3429|    473|         tmp = ssh_list_pop_head(char *, session->opts.certificate_non_exp)) {
  ------------------
  |  |  130|      0|  ((type)_ssh_list_pop_head(ssh_list))
  ------------------
 3430|      0|        char *id = tmp;
 3431|       |
 3432|      0|        tmp = ssh_path_expand_escape(session, id);
 3433|      0|        free(id);
 3434|      0|        if (tmp == NULL) {
  ------------------
  |  Branch (3434:13): [True: 0, False: 0]
  ------------------
 3435|      0|            return -1;
 3436|      0|        }
 3437|       |
 3438|      0|        rc = ssh_list_append(session->opts.certificate, tmp);
 3439|      0|        if (rc != SSH_OK) {
  ------------------
  |  |  315|      0|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (3439:13): [True: 0, False: 0]
  ------------------
 3440|      0|            free(tmp);
 3441|      0|            return -1;
 3442|      0|        }
 3443|      0|    }
 3444|       |
 3445|       |#ifdef WITH_GSSAPI
 3446|       |    if (session->opts.gssapi_key_exchange) {
 3447|       |        rc = ssh_gssapi_check_client_config(session);
 3448|       |        if (rc != SSH_OK) {
 3449|       |            SSH_LOG(SSH_LOG_WARN, "Disabled GSSAPI key exchange");
 3450|       |            session->opts.gssapi_key_exchange = false;
 3451|       |        }
 3452|       |    }
 3453|       |#endif
 3454|       |
 3455|    473|    return 0;
 3456|    473|}
options.c:ssh_opt_type_to_opcode:
  520|  4.73k|{
  521|  4.73k|    switch (type) {
  ------------------
  |  Branch (521:13): [True: 4.73k, False: 0]
  ------------------
  522|      0|    case SSH_OPTIONS_PORT:
  ------------------
  |  Branch (522:5): [True: 0, False: 4.73k]
  ------------------
  523|      0|    case SSH_OPTIONS_PORT_STR:
  ------------------
  |  Branch (523:5): [True: 0, False: 4.73k]
  ------------------
  524|      0|        return SOC_PORT;
  525|    473|    case SSH_OPTIONS_USER:
  ------------------
  |  Branch (525:5): [True: 473, False: 4.25k]
  ------------------
  526|    473|        return SOC_USERNAME;
  527|      0|    case SSH_OPTIONS_KNOWNHOSTS:
  ------------------
  |  Branch (527:5): [True: 0, False: 4.73k]
  ------------------
  528|      0|        return SOC_KNOWNHOSTS;
  529|      0|    case SSH_OPTIONS_GLOBAL_KNOWNHOSTS:
  ------------------
  |  Branch (529:5): [True: 0, False: 4.73k]
  ------------------
  530|      0|        return SOC_GLOBALKNOWNHOSTSFILE;
  531|    473|    case SSH_OPTIONS_TIMEOUT:
  ------------------
  |  Branch (531:5): [True: 473, False: 4.25k]
  ------------------
  532|    473|        return SOC_TIMEOUT;
  533|    473|    case SSH_OPTIONS_CIPHERS_C_S:
  ------------------
  |  Branch (533:5): [True: 473, False: 4.25k]
  ------------------
  534|    946|    case SSH_OPTIONS_CIPHERS_S_C:
  ------------------
  |  Branch (534:5): [True: 473, False: 4.25k]
  ------------------
  535|    946|        return SOC_CIPHERS;
  536|      0|    case SSH_OPTIONS_COMPRESSION:
  ------------------
  |  Branch (536:5): [True: 0, False: 4.73k]
  ------------------
  537|      0|    case SSH_OPTIONS_COMPRESSION_C_S:
  ------------------
  |  Branch (537:5): [True: 0, False: 4.73k]
  ------------------
  538|      0|    case SSH_OPTIONS_COMPRESSION_S_C:
  ------------------
  |  Branch (538:5): [True: 0, False: 4.73k]
  ------------------
  539|      0|        return SOC_COMPRESSION;
  540|      0|    case SSH_OPTIONS_PROXYCOMMAND:
  ------------------
  |  Branch (540:5): [True: 0, False: 4.73k]
  ------------------
  541|      0|        return SOC_PROXYCOMMAND;
  542|      0|    case SSH_OPTIONS_PROXYJUMP:
  ------------------
  |  Branch (542:5): [True: 0, False: 4.73k]
  ------------------
  543|      0|        return SOC_PROXYJUMP;
  544|      0|    case SSH_OPTIONS_BINDADDR:
  ------------------
  |  Branch (544:5): [True: 0, False: 4.73k]
  ------------------
  545|      0|        return SOC_BINDADDRESS;
  546|      0|    case SSH_OPTIONS_STRICTHOSTKEYCHECK:
  ------------------
  |  Branch (546:5): [True: 0, False: 4.73k]
  ------------------
  547|      0|        return SOC_STRICTHOSTKEYCHECK;
  548|      0|    case SSH_OPTIONS_KEY_EXCHANGE:
  ------------------
  |  Branch (548:5): [True: 0, False: 4.73k]
  ------------------
  549|      0|        return SOC_KEXALGORITHMS;
  550|      0|    case SSH_OPTIONS_HOSTKEYS:
  ------------------
  |  Branch (550:5): [True: 0, False: 4.73k]
  ------------------
  551|      0|        return SOC_HOSTKEYALGORITHMS;
  552|      0|    case SSH_OPTIONS_PUBLICKEY_ACCEPTED_TYPES:
  ------------------
  |  Branch (552:5): [True: 0, False: 4.73k]
  ------------------
  553|      0|        return SOC_PUBKEYACCEPTEDKEYTYPES;
  554|    473|    case SSH_OPTIONS_HMAC_C_S:
  ------------------
  |  Branch (554:5): [True: 473, False: 4.25k]
  ------------------
  555|    946|    case SSH_OPTIONS_HMAC_S_C:
  ------------------
  |  Branch (555:5): [True: 473, False: 4.25k]
  ------------------
  556|    946|        return SOC_MACS;
  557|      0|    case SSH_OPTIONS_GSSAPI_SERVER_IDENTITY:
  ------------------
  |  Branch (557:5): [True: 0, False: 4.73k]
  ------------------
  558|      0|        return SOC_GSSAPISERVERIDENTITY;
  559|      0|    case SSH_OPTIONS_GSSAPI_CLIENT_IDENTITY:
  ------------------
  |  Branch (559:5): [True: 0, False: 4.73k]
  ------------------
  560|      0|        return SOC_GSSAPICLIENTIDENTITY;
  561|      0|    case SSH_OPTIONS_GSSAPI_DELEGATE_CREDENTIALS:
  ------------------
  |  Branch (561:5): [True: 0, False: 4.73k]
  ------------------
  562|      0|        return SOC_GSSAPIDELEGATECREDENTIALS;
  563|      0|    case SSH_OPTIONS_GSSAPI_KEY_EXCHANGE:
  ------------------
  |  Branch (563:5): [True: 0, False: 4.73k]
  ------------------
  564|      0|        return SOC_GSSAPIKEYEXCHANGE;
  565|      0|    case SSH_OPTIONS_GSSAPI_KEY_EXCHANGE_ALGS:
  ------------------
  |  Branch (565:5): [True: 0, False: 4.73k]
  ------------------
  566|      0|        return SOC_GSSAPIKEXALGORITHMS;
  567|      0|    case SSH_OPTIONS_PASSWORD_AUTH:
  ------------------
  |  Branch (567:5): [True: 0, False: 4.73k]
  ------------------
  568|      0|        return SOC_PASSWORDAUTHENTICATION;
  569|      0|    case SSH_OPTIONS_PUBKEY_AUTH:
  ------------------
  |  Branch (569:5): [True: 0, False: 4.73k]
  ------------------
  570|      0|        return SOC_PUBKEYAUTHENTICATION;
  571|      0|    case SSH_OPTIONS_KBDINT_AUTH:
  ------------------
  |  Branch (571:5): [True: 0, False: 4.73k]
  ------------------
  572|      0|        return SOC_KBDINTERACTIVEAUTHENTICATION;
  573|      0|    case SSH_OPTIONS_GSSAPI_AUTH:
  ------------------
  |  Branch (573:5): [True: 0, False: 4.73k]
  ------------------
  574|      0|        return SOC_GSSAPIAUTHENTICATION;
  575|      0|    case SSH_OPTIONS_PREFERRED_AUTHENTICATIONS:
  ------------------
  |  Branch (575:5): [True: 0, False: 4.73k]
  ------------------
  576|      0|        return SOC_PREFERRED_AUTHENTICATIONS;
  577|      0|    case SSH_OPTIONS_REKEY_DATA:
  ------------------
  |  Branch (577:5): [True: 0, False: 4.73k]
  ------------------
  578|      0|    case SSH_OPTIONS_REKEY_TIME:
  ------------------
  |  Branch (578:5): [True: 0, False: 4.73k]
  ------------------
  579|      0|        return SOC_REKEYLIMIT;
  580|      0|    case SSH_OPTIONS_RSA_MIN_SIZE:
  ------------------
  |  Branch (580:5): [True: 0, False: 4.73k]
  ------------------
  581|      0|        return SOC_REQUIRED_RSA_SIZE;
  582|      0|    case SSH_OPTIONS_IDENTITY_AGENT:
  ------------------
  |  Branch (582:5): [True: 0, False: 4.73k]
  ------------------
  583|      0|        return SOC_IDENTITYAGENT;
  584|      0|    case SSH_OPTIONS_IDENTITIES_ONLY:
  ------------------
  |  Branch (584:5): [True: 0, False: 4.73k]
  ------------------
  585|      0|        return SOC_IDENTITIESONLY;
  586|      0|    case SSH_OPTIONS_CONTROL_MASTER:
  ------------------
  |  Branch (586:5): [True: 0, False: 4.73k]
  ------------------
  587|      0|        return SOC_CONTROLMASTER;
  588|      0|    case SSH_OPTIONS_CONTROL_PATH:
  ------------------
  |  Branch (588:5): [True: 0, False: 4.73k]
  ------------------
  589|      0|        return SOC_CONTROLPATH;
  590|      0|    case SSH_OPTIONS_ADDRESS_FAMILY:
  ------------------
  |  Branch (590:5): [True: 0, False: 4.73k]
  ------------------
  591|      0|        return SOC_ADDRESSFAMILY;
  592|      0|    case SSH_OPTIONS_SERVER_ALIVE_INTERVAL:
  ------------------
  |  Branch (592:5): [True: 0, False: 4.73k]
  ------------------
  593|      0|        return SOC_SERVERALIVEINTERVAL;
  594|      0|    case SSH_OPTIONS_SERVER_ALIVE_COUNT_MAX:
  ------------------
  |  Branch (594:5): [True: 0, False: 4.73k]
  ------------------
  595|      0|        return SOC_SERVERALIVECOUNTMAX;
  596|      0|    case SSH_OPTIONS_BATCH_MODE:
  ------------------
  |  Branch (596:5): [True: 0, False: 4.73k]
  ------------------
  597|      0|        return SOC_BATCHMODE;
  598|      0|    case SSH_OPTIONS_NUMBER_OF_PASSWORD_PROMPTS:
  ------------------
  |  Branch (598:5): [True: 0, False: 4.73k]
  ------------------
  599|      0|        return SOC_NUMBER_OF_PASSWORD_PROMPTS;
  600|      0|    case SSH_OPTIONS_REQUEST_TTY:
  ------------------
  |  Branch (600:5): [True: 0, False: 4.73k]
  ------------------
  601|      0|        return SOC_REQUEST_TTY;
  602|      0|    case SSH_OPTIONS_ESCAPE_CHAR:
  ------------------
  |  Branch (602:5): [True: 0, False: 4.73k]
  ------------------
  603|      0|        return SOC_ESCAPE_CHAR;
  604|      0|    case SSH_OPTIONS_EXIT_ON_FORWARD_FAILURE:
  ------------------
  |  Branch (604:5): [True: 0, False: 4.73k]
  ------------------
  605|      0|        return SOC_EXIT_ON_FORWARD_FAILURE;
  606|      0|    case SSH_OPTIONS_FORWARD_AGENT:
  ------------------
  |  Branch (606:5): [True: 0, False: 4.73k]
  ------------------
  607|      0|    case SSH_OPTIONS_FORWARD_AGENT_SOCK_PATH:
  ------------------
  |  Branch (607:5): [True: 0, False: 4.73k]
  ------------------
  608|      0|        return SOC_FORWARD_AGENT;
  609|      0|    case SSH_OPTIONS_GATEWAY_PORTS:
  ------------------
  |  Branch (609:5): [True: 0, False: 4.73k]
  ------------------
  610|      0|        return SOC_GATEWAY_PORTS;
  611|       |    /*
  612|       |     * Accumulative options append to a list instead of replacing a value, so
  613|       |     * the "first value wins" precedence between config and the application does
  614|       |     * not apply to them.
  615|       |     */
  616|      0|    case SSH_OPTIONS_IDENTITY:
  ------------------
  |  Branch (616:5): [True: 0, False: 4.73k]
  ------------------
  617|      0|    case SSH_OPTIONS_ADD_IDENTITY:
  ------------------
  |  Branch (617:5): [True: 0, False: 4.73k]
  ------------------
  618|      0|    case SSH_OPTIONS_CERTIFICATE:
  ------------------
  |  Branch (618:5): [True: 0, False: 4.73k]
  ------------------
  619|      0|    case SSH_OPTIONS_PROXYJUMP_CB_LIST_APPEND:
  ------------------
  |  Branch (619:5): [True: 0, False: 4.73k]
  ------------------
  620|      0|    case SSH_OPTIONS_LOCAL_FORWARD:
  ------------------
  |  Branch (620:5): [True: 0, False: 4.73k]
  ------------------
  621|      0|    case SSH_OPTIONS_REMOTE_FORWARD:
  ------------------
  |  Branch (621:5): [True: 0, False: 4.73k]
  ------------------
  622|      0|    case SSH_OPTIONS_SEND_ENV:
  ------------------
  |  Branch (622:5): [True: 0, False: 4.73k]
  ------------------
  623|       |    /*
  624|       |     * SSH_OPTIONS_HOST carries the destination as given by the application,
  625|       |     * which is OpenSSH's "host" (the Host/Match lookup key), not its
  626|       |     * "hostname". Config HostName resolves that key to the real hostname and
  627|       |     * must keep doing so. HostName has its own "first value wins" precedence
  628|       |     * between config entries, enforced independently via seen[SOC_HOSTNAME]
  629|       |     * while parsing the configuration.
  630|       |     */
  631|    473|    case SSH_OPTIONS_HOST:
  ------------------
  |  Branch (631:5): [True: 473, False: 4.25k]
  ------------------
  632|       |    /*
  633|       |     * Operational settings that applications and frameworks routinely set on
  634|       |     * their own, independent of the connection configuration. OpenSSH's config
  635|       |     * parser notably does not let a previously-set value suppress LogLevel, so
  636|       |     * we follow it and leave log verbosity unprotected.
  637|       |     */
  638|    473|    case SSH_OPTIONS_LOG_VERBOSITY:
  ------------------
  |  Branch (638:5): [True: 0, False: 4.73k]
  ------------------
  639|    473|    case SSH_OPTIONS_LOG_VERBOSITY_STR:
  ------------------
  |  Branch (639:5): [True: 0, False: 4.73k]
  ------------------
  640|       |    /*
  641|       |     * Options with no OpenSSH ssh_config equivalent (or that are never applied
  642|       |     * from a config file), so there is no config value that could override the
  643|       |     * application's choice.
  644|       |     */
  645|    946|    case SSH_OPTIONS_FD:
  ------------------
  |  Branch (645:5): [True: 473, False: 4.25k]
  ------------------
  646|  1.41k|    case SSH_OPTIONS_SSH_DIR:
  ------------------
  |  Branch (646:5): [True: 473, False: 4.25k]
  ------------------
  647|  1.41k|    case SSH_OPTIONS_SSH1:
  ------------------
  |  Branch (647:5): [True: 0, False: 4.73k]
  ------------------
  648|  1.41k|    case SSH_OPTIONS_SSH2:
  ------------------
  |  Branch (648:5): [True: 0, False: 4.73k]
  ------------------
  649|  1.41k|    case SSH_OPTIONS_TIMEOUT_USEC:
  ------------------
  |  Branch (649:5): [True: 0, False: 4.73k]
  ------------------
  650|  1.41k|    case SSH_OPTIONS_COMPRESSION_LEVEL:
  ------------------
  |  Branch (650:5): [True: 0, False: 4.73k]
  ------------------
  651|  1.41k|    case SSH_OPTIONS_NODELAY:
  ------------------
  |  Branch (651:5): [True: 0, False: 4.73k]
  ------------------
  652|  1.89k|    case SSH_OPTIONS_PROCESS_CONFIG:
  ------------------
  |  Branch (652:5): [True: 473, False: 4.25k]
  ------------------
  653|  1.89k|    case SSH_OPTIONS_PKI_CONTEXT:
  ------------------
  |  Branch (653:5): [True: 0, False: 4.73k]
  ------------------
  654|       |    /*
  655|       |     * Getter-only options: ssh_options_set() rejects them, so they never reach
  656|       |     * the marking step. Listed to keep the switch exhaustive.
  657|       |     */
  658|  1.89k|    case SSH_OPTIONS_NEXT_IDENTITY:
  ------------------
  |  Branch (658:5): [True: 0, False: 4.73k]
  ------------------
  659|  1.89k|    case SSH_OPTIONS_NEXT_LOCAL_FORWARD:
  ------------------
  |  Branch (659:5): [True: 0, False: 4.73k]
  ------------------
  660|  1.89k|    case SSH_OPTIONS_NEXT_REMOTE_FORWARD:
  ------------------
  |  Branch (660:5): [True: 0, False: 4.73k]
  ------------------
  661|  1.89k|    case SSH_OPTIONS_NEXT_SEND_ENV:
  ------------------
  |  Branch (661:5): [True: 0, False: 4.73k]
  ------------------
  662|  1.89k|        return SOC_UNKNOWN;
  663|  4.73k|    }
  664|       |
  665|      0|    return SOC_UNKNOWN;
  666|  4.73k|}
options.c:ssh_host_requires_lowercase:
 3194|    473|static bool ssh_host_requires_lowercase(const char *host) {
 3195|    473|    if (strchr(host, '%') != NULL || strchr(host, ':') != NULL ||
  ------------------
  |  Branch (3195:9): [True: 0, False: 473]
  |  Branch (3195:38): [True: 0, False: 473]
  ------------------
 3196|    473|        strspn(host, "0123456789.") == strlen(host)) {
  ------------------
  |  Branch (3196:9): [True: 473, False: 0]
  ------------------
 3197|    473|        return false;
 3198|    473|    }
 3199|      0|    return !ssh_is_ipaddr(host);
 3200|    473|}

ssh_packet_get_current_crypto:
 1159|   150k|{
 1160|   150k|    struct ssh_crypto_struct *crypto = NULL;
 1161|       |
 1162|   150k|    if (session == NULL) {
  ------------------
  |  Branch (1162:9): [True: 0, False: 150k]
  ------------------
 1163|      0|        return NULL;
 1164|      0|    }
 1165|       |
 1166|   150k|    if (session->current_crypto != NULL &&
  ------------------
  |  Branch (1166:9): [True: 0, False: 150k]
  ------------------
 1167|      0|        session->current_crypto->used & direction) {
  ------------------
  |  Branch (1167:9): [True: 0, False: 0]
  ------------------
 1168|      0|        crypto = session->current_crypto;
 1169|   150k|    } else if (session->next_crypto != NULL &&
  ------------------
  |  Branch (1169:16): [True: 150k, False: 0]
  ------------------
 1170|   150k|               session->next_crypto->used & direction) {
  ------------------
  |  Branch (1170:16): [True: 3.40k, False: 146k]
  ------------------
 1171|  3.40k|        crypto = session->next_crypto;
 1172|   146k|    } else {
 1173|   146k|        return NULL;
 1174|   146k|    }
 1175|       |
 1176|  3.40k|    switch (direction) {
  ------------------
  |  Branch (1176:13): [True: 3.40k, False: 0]
  ------------------
 1177|      0|    case SSH_DIRECTION_IN:
  ------------------
  |  Branch (1177:5): [True: 0, False: 3.40k]
  ------------------
 1178|      0|        if (crypto->in_cipher != NULL) {
  ------------------
  |  Branch (1178:13): [True: 0, False: 0]
  ------------------
 1179|      0|            return crypto;
 1180|      0|        }
 1181|      0|        break;
 1182|  3.40k|    case SSH_DIRECTION_OUT:
  ------------------
  |  Branch (1182:5): [True: 3.40k, False: 0]
  ------------------
 1183|  3.40k|        if (crypto->out_cipher != NULL) {
  ------------------
  |  Branch (1183:13): [True: 3.40k, False: 0]
  ------------------
 1184|  3.40k|            return crypto;
 1185|  3.40k|        }
 1186|      0|        break;
 1187|      0|    case SSH_DIRECTION_BOTH:
  ------------------
  |  Branch (1187:5): [True: 0, False: 3.40k]
  ------------------
 1188|      0|        if (crypto->in_cipher != NULL &&
  ------------------
  |  Branch (1188:13): [True: 0, False: 0]
  ------------------
 1189|      0|            crypto->out_cipher != NULL) {
  ------------------
  |  Branch (1189:13): [True: 0, False: 0]
  ------------------
 1190|      0|            return crypto;
 1191|      0|        }
 1192|  3.40k|    }
 1193|       |
 1194|      0|    return NULL;
 1195|  3.40k|}
ssh_packet_socket_callback:
 1287|  47.4k|{
 1288|  47.4k|    ssh_session session = (ssh_session)user;
 1289|  47.4k|    uint32_t blocksize = 8;
 1290|  47.4k|    uint32_t lenfield_blocksize = 8;
 1291|  47.4k|    size_t current_macsize = 0;
 1292|  47.4k|    uint8_t *ptr = NULL;
 1293|  47.4k|    ssize_t to_be_read;
 1294|  47.4k|    int rc;
 1295|  47.4k|    uint8_t *cleartext_packet = NULL;
 1296|  47.4k|    uint8_t *packet_second_block = NULL;
 1297|  47.4k|    uint8_t *mac = NULL;
 1298|  47.4k|    size_t packet_remaining, packet_offset;
 1299|  47.4k|    uint32_t packet_len, compsize, payloadsize;
 1300|  47.4k|    uint8_t padding;
 1301|  47.4k|    size_t processed = 0; /* number of bytes processed from the callback */
 1302|  47.4k|    enum ssh_packet_filter_result_e filter_result;
 1303|  47.4k|    struct ssh_crypto_struct *crypto = NULL;
 1304|  47.4k|    bool etm = false;
 1305|  47.4k|    uint32_t etm_packet_offset = 0;
 1306|  47.4k|    bool ok;
 1307|       |
 1308|  47.4k|    crypto = ssh_packet_get_current_crypto(session, SSH_DIRECTION_IN);
 1309|  47.4k|    if (crypto != NULL) {
  ------------------
  |  Branch (1309:9): [True: 0, False: 47.4k]
  ------------------
 1310|      0|        current_macsize = hmac_digest_len(crypto->in_hmac);
 1311|      0|        blocksize = crypto->in_cipher->blocksize;
 1312|      0|        lenfield_blocksize = crypto->in_cipher->lenfield_blocksize;
 1313|      0|        etm = crypto->in_hmac_etm;
 1314|      0|    }
 1315|       |
 1316|  47.4k|    if (etm) {
  ------------------
  |  Branch (1316:9): [True: 0, False: 47.4k]
  ------------------
 1317|       |        /* In EtM mode packet size is unencrypted. This means
 1318|       |         * we need to use this offset and set the block size
 1319|       |         * that is part of the encrypted part to 0.
 1320|       |         */
 1321|      0|        etm_packet_offset = sizeof(uint32_t);
 1322|      0|        lenfield_blocksize = 0;
 1323|  47.4k|    } else if (lenfield_blocksize == 0) {
  ------------------
  |  Branch (1323:16): [True: 0, False: 47.4k]
  ------------------
 1324|      0|        lenfield_blocksize = blocksize;
 1325|      0|    }
 1326|  47.4k|    if (data == NULL) {
  ------------------
  |  Branch (1326:9): [True: 0, False: 47.4k]
  ------------------
 1327|      0|        goto error;
 1328|      0|    }
 1329|       |
 1330|  47.4k|    if (session->session_state == SSH_SESSION_STATE_ERROR) {
  ------------------
  |  Branch (1330:9): [True: 309, False: 47.1k]
  ------------------
 1331|    309|        goto error;
 1332|    309|    }
 1333|       |#ifdef DEBUG_PACKET
 1334|       |    SSH_LOG(SSH_LOG_PACKET,
 1335|       |            "rcv packet cb (len=%zu, state=%s)",
 1336|       |            receivedlen,
 1337|       |            session->packet_state == PACKET_STATE_INIT ?
 1338|       |                "INIT" :
 1339|       |                session->packet_state == PACKET_STATE_SIZEREAD ?
 1340|       |                    "SIZE_READ" :
 1341|       |                    session->packet_state == PACKET_STATE_PROCESSING ?
 1342|       |                    "PROCESSING" : "unknown");
 1343|       |#endif
 1344|  47.1k|    switch (session->packet_state) {
  ------------------
  |  Branch (1344:13): [True: 47.1k, False: 0]
  ------------------
 1345|  46.6k|        case PACKET_STATE_INIT:
  ------------------
  |  Branch (1345:9): [True: 46.6k, False: 478]
  ------------------
 1346|  46.6k|            if (receivedlen < lenfield_blocksize + etm_packet_offset) {
  ------------------
  |  Branch (1346:17): [True: 166, False: 46.4k]
  ------------------
 1347|       |                /*
 1348|       |                 * We didn't receive enough data to read either at least one
 1349|       |                 * block size or the unencrypted length in EtM mode.
 1350|       |                 */
 1351|       |#ifdef DEBUG_PACKET
 1352|       |                SSH_LOG(SSH_LOG_PACKET,
 1353|       |                        "Waiting for more data (%zu < %u)",
 1354|       |                        receivedlen,
 1355|       |                        lenfield_blocksize);
 1356|       |#endif
 1357|    166|                return 0;
 1358|    166|            }
 1359|       |
 1360|  46.4k|            session->in_packet = (struct packet_struct) {
 1361|  46.4k|                .type = 0,
 1362|  46.4k|            };
 1363|       |
 1364|  46.4k|            if (session->in_buffer) {
  ------------------
  |  Branch (1364:17): [True: 46.4k, False: 0]
  ------------------
 1365|  46.4k|                rc = ssh_buffer_reinit(session->in_buffer);
 1366|  46.4k|                if (rc < 0) {
  ------------------
  |  Branch (1366:21): [True: 0, False: 46.4k]
  ------------------
 1367|      0|                    goto error;
 1368|      0|                }
 1369|  46.4k|            } else {
 1370|      0|                session->in_buffer = ssh_buffer_new();
 1371|      0|                if (session->in_buffer == NULL) {
  ------------------
  |  Branch (1371:21): [True: 0, False: 0]
  ------------------
 1372|      0|                    goto error;
 1373|      0|                }
 1374|      0|            }
 1375|       |
 1376|  46.4k|            if (!etm) {
  ------------------
  |  Branch (1376:17): [True: 46.4k, False: 0]
  ------------------
 1377|  46.4k|                ptr = ssh_buffer_allocate(session->in_buffer,
 1378|  46.4k|                                          lenfield_blocksize);
 1379|  46.4k|                if (ptr == NULL) {
  ------------------
  |  Branch (1379:21): [True: 0, False: 46.4k]
  ------------------
 1380|      0|                    goto error;
 1381|      0|                }
 1382|  46.4k|                packet_len = ssh_packet_decrypt_len(session, ptr,
 1383|  46.4k|                                                    (uint8_t *)data);
 1384|  46.4k|                to_be_read = packet_len - lenfield_blocksize + sizeof(uint32_t);
 1385|  46.4k|            } else {
 1386|       |                /* Length is unencrypted in case of Encrypt-then-MAC */
 1387|      0|                packet_len = PULL_BE_U32(data, 0);
  ------------------
  |  |   75|      0|    ((((uint32_t)PULL_BE_U16(data, pos)) << 16) | (uint32_t)(PULL_BE_U16(data, (pos) + 2)))
  |  |  ------------------
  |  |  |  |   72|      0|    ((((uint16_t)(PULL_BE_U8(data, pos))) << 8) | (uint16_t)PULL_BE_U8(data, (pos) + 1))
  |  |  |  |  ------------------
  |  |  |  |  |  |   69|      0|    (_DATA_BYTE_CONST(data, pos))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   28|      0|    ((uint8_t)(((const uint8_t *)(data))[(pos)]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |                   ((((uint16_t)(PULL_BE_U8(data, pos))) << 8) | (uint16_t)PULL_BE_U8(data, (pos) + 1))
  |  |  |  |  ------------------
  |  |  |  |  |  |   69|      0|    (_DATA_BYTE_CONST(data, pos))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   28|      0|    ((uint8_t)(((const uint8_t *)(data))[(pos)]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                   ((((uint32_t)PULL_BE_U16(data, pos)) << 16) | (uint32_t)(PULL_BE_U16(data, (pos) + 2)))
  |  |  ------------------
  |  |  |  |   72|      0|    ((((uint16_t)(PULL_BE_U8(data, pos))) << 8) | (uint16_t)PULL_BE_U8(data, (pos) + 1))
  |  |  |  |  ------------------
  |  |  |  |  |  |   69|      0|    (_DATA_BYTE_CONST(data, pos))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   28|      0|    ((uint8_t)(((const uint8_t *)(data))[(pos)]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |                   ((((uint16_t)(PULL_BE_U8(data, pos))) << 8) | (uint16_t)PULL_BE_U8(data, (pos) + 1))
  |  |  |  |  ------------------
  |  |  |  |  |  |   69|      0|    (_DATA_BYTE_CONST(data, pos))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   28|      0|    ((uint8_t)(((const uint8_t *)(data))[(pos)]))
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1388|      0|                to_be_read = packet_len - etm_packet_offset;
 1389|      0|            }
 1390|       |
 1391|  46.4k|            processed += lenfield_blocksize + etm_packet_offset;
 1392|  46.4k|            if (packet_len > MAX_PACKET_LEN) {
  ------------------
  |  |  216|  46.4k|#define MAX_PACKET_LEN 262144
  ------------------
  |  Branch (1392:17): [True: 63, False: 46.3k]
  ------------------
 1393|     63|                ssh_set_error(session,
  ------------------
  |  |  313|     63|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
 1394|     63|                              SSH_FATAL,
 1395|     63|                              "read_packet(): Packet len too high(%" PRIu32 " %.4" PRIx32 ")",
 1396|     63|                              packet_len, packet_len);
 1397|     63|                goto error;
 1398|     63|            }
 1399|  46.3k|            if (to_be_read < 0) {
  ------------------
  |  Branch (1399:17): [True: 0, False: 46.3k]
  ------------------
 1400|       |                /* remote sshd sends invalid sizes? */
 1401|      0|                ssh_set_error(session,
  ------------------
  |  |  313|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
 1402|      0|                              SSH_FATAL,
 1403|      0|                              "Given numbers of bytes left to be read < 0 (%zd)!",
 1404|      0|                              to_be_read);
 1405|      0|                goto error;
 1406|      0|            }
 1407|       |
 1408|  46.3k|            session->in_packet.len = packet_len;
 1409|  46.3k|            session->packet_state = PACKET_STATE_SIZEREAD;
 1410|  46.3k|            FALL_THROUGH;
  ------------------
  |  |  496|  46.3k|#  define FALL_THROUGH __attribute__ ((fallthrough))
  ------------------
 1411|  46.8k|        case PACKET_STATE_SIZEREAD:
  ------------------
  |  Branch (1411:9): [True: 478, False: 46.6k]
  ------------------
 1412|  46.8k|            packet_len = session->in_packet.len;
 1413|  46.8k|            packet_offset = processed = lenfield_blocksize + etm_packet_offset;
 1414|  46.8k|            to_be_read = packet_len + sizeof(uint32_t) + current_macsize;
 1415|       |            /* if to_be_read is zero, the whole packet was blocksize bytes. */
 1416|  46.8k|            if (to_be_read != 0) {
  ------------------
  |  Branch (1416:17): [True: 46.8k, False: 0]
  ------------------
 1417|  46.8k|                if (receivedlen < (unsigned long)to_be_read) {
  ------------------
  |  Branch (1417:21): [True: 512, False: 46.3k]
  ------------------
 1418|       |                    /* give up, not enough data in buffer */
 1419|    512|                    SSH_LOG(SSH_LOG_PACKET,
  ------------------
  |  |  283|    512|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 1420|    512|                            "packet: partial packet (read len) "
 1421|    512|                            "[len=%" PRIu32 ", receivedlen=%zu, to_be_read=%zd]",
 1422|    512|                            packet_len,
 1423|    512|                            receivedlen,
 1424|    512|                            to_be_read);
 1425|    512|                    return 0;
 1426|    512|                }
 1427|       |
 1428|  46.3k|                packet_second_block = (uint8_t*)data + packet_offset;
 1429|  46.3k|                processed = to_be_read - current_macsize;
 1430|  46.3k|            }
 1431|       |
 1432|  46.3k|            if (packet_offset - sizeof(uint32_t) > (size_t)packet_len) {
  ------------------
  |  Branch (1432:17): [True: 17, False: 46.3k]
  ------------------
 1433|     17|                ssh_set_error(session,
  ------------------
  |  |  313|     17|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
 1434|     17|                              SSH_FATAL,
 1435|     17|                              "Invalid packet length %" PRIu32 ", required %zu",
 1436|     17|                              packet_len,
 1437|     17|                              packet_offset + sizeof(uint32_t));
 1438|     17|                goto error;
 1439|     17|            }
 1440|       |
 1441|       |            /* remaining encrypted bytes from the packet, MAC not included */
 1442|  46.3k|            packet_remaining = packet_len - (packet_offset - sizeof(uint32_t));
 1443|  46.3k|            cleartext_packet = ssh_buffer_allocate(session->in_buffer,
 1444|  46.3k|                                                   (uint32_t)packet_remaining);
 1445|  46.3k|            if (cleartext_packet == NULL) {
  ------------------
  |  Branch (1445:17): [True: 0, False: 46.3k]
  ------------------
 1446|      0|                goto error;
 1447|      0|            }
 1448|       |
 1449|  46.3k|            if (packet_second_block != NULL) {
  ------------------
  |  Branch (1449:17): [True: 46.3k, False: 0]
  ------------------
 1450|  46.3k|                if (crypto != NULL) {
  ------------------
  |  Branch (1450:21): [True: 0, False: 46.3k]
  ------------------
 1451|      0|                    mac = packet_second_block + packet_remaining;
 1452|       |
 1453|      0|                    if (crypto->in_hmac != SSH_HMAC_NONE && etm) {
  ------------------
  |  Branch (1453:25): [True: 0, False: 0]
  |  Branch (1453:61): [True: 0, False: 0]
  ------------------
 1454|      0|                        rc = ssh_packet_hmac_verify(session,
 1455|      0|                                                    data,
 1456|      0|                                                    processed,
 1457|      0|                                                    mac,
 1458|      0|                                                    crypto->in_hmac);
 1459|      0|                        if (rc < 0) {
  ------------------
  |  Branch (1459:29): [True: 0, False: 0]
  ------------------
 1460|      0|                            ssh_set_error(session, SSH_FATAL, "HMAC error");
  ------------------
  |  |  313|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
 1461|      0|                            goto error;
 1462|      0|                        }
 1463|      0|                    }
 1464|       |                    /*
 1465|       |                     * Decrypt the packet. In case of EtM mode, the length is
 1466|       |                     * already known as it's unencrypted. In the other case,
 1467|       |                     * lenfield_blocksize bytes already have been decrypted.
 1468|       |                     */
 1469|      0|                    if (packet_remaining > 0) {
  ------------------
  |  Branch (1469:25): [True: 0, False: 0]
  ------------------
 1470|      0|                        rc = ssh_packet_decrypt(session,
 1471|      0|                                                cleartext_packet,
 1472|      0|                                                (uint8_t *)data,
 1473|      0|                                                packet_offset,
 1474|      0|                                                processed - packet_offset);
 1475|      0|                        if (rc < 0) {
  ------------------
  |  Branch (1475:29): [True: 0, False: 0]
  ------------------
 1476|      0|                            ssh_set_error(session,
  ------------------
  |  |  313|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
 1477|      0|                                          SSH_FATAL,
 1478|      0|                                          "Decryption error");
 1479|      0|                            goto error;
 1480|      0|                        }
 1481|      0|                    }
 1482|       |
 1483|      0|                    if (crypto->in_hmac != SSH_HMAC_NONE && !etm) {
  ------------------
  |  Branch (1483:25): [True: 0, False: 0]
  |  Branch (1483:61): [True: 0, False: 0]
  ------------------
 1484|      0|                        ssh_buffer in = session->in_buffer;
 1485|      0|                        rc = ssh_packet_hmac_verify(session,
 1486|      0|                                                    ssh_buffer_get(in),
 1487|      0|                                                    ssh_buffer_get_len(in),
 1488|      0|                                                    mac,
 1489|      0|                                                    crypto->in_hmac);
 1490|      0|                        if (rc < 0) {
  ------------------
  |  Branch (1490:29): [True: 0, False: 0]
  ------------------
 1491|      0|                            ssh_set_error(session, SSH_FATAL, "HMAC error");
  ------------------
  |  |  313|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
 1492|      0|                            goto error;
 1493|      0|                        }
 1494|      0|                    }
 1495|      0|                    processed += current_macsize;
 1496|  46.3k|                } else {
 1497|  46.3k|                    memcpy(cleartext_packet,
 1498|  46.3k|                           packet_second_block,
 1499|  46.3k|                           packet_remaining);
 1500|  46.3k|                }
 1501|  46.3k|            }
 1502|       |
 1503|  46.3k|#ifdef WITH_PCAP
 1504|  46.3k|            if (session->pcap_ctx != NULL) {
  ------------------
  |  Branch (1504:17): [True: 0, False: 46.3k]
  ------------------
 1505|      0|                ssh_pcap_context_write(session->pcap_ctx,
 1506|      0|                                       SSH_PCAP_DIR_IN,
 1507|      0|                                       ssh_buffer_get(session->in_buffer),
 1508|      0|                                       ssh_buffer_get_len(session->in_buffer),
 1509|      0|                                       ssh_buffer_get_len(session->in_buffer));
 1510|      0|            }
 1511|  46.3k|#endif
 1512|       |
 1513|  46.3k|            if (!etm) {
  ------------------
  |  Branch (1513:17): [True: 46.3k, False: 0]
  ------------------
 1514|       |                /* skip the size field which has been processed before */
 1515|  46.3k|                ssh_buffer_pass_bytes(session->in_buffer, sizeof(uint32_t));
 1516|  46.3k|            }
 1517|       |
 1518|  46.3k|            rc = ssh_buffer_get_u8(session->in_buffer, &padding);
 1519|  46.3k|            if (rc == 0) {
  ------------------
  |  Branch (1519:17): [True: 0, False: 46.3k]
  ------------------
 1520|      0|                ssh_set_error(session,
  ------------------
  |  |  313|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
 1521|      0|                              SSH_FATAL,
 1522|      0|                              "Packet too short to read padding");
 1523|      0|                goto error;
 1524|      0|            }
 1525|       |
 1526|  46.3k|            if (padding > ssh_buffer_get_len(session->in_buffer)) {
  ------------------
  |  Branch (1526:17): [True: 7, False: 46.3k]
  ------------------
 1527|      7|                ssh_set_error(session,
  ------------------
  |  |  313|      7|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
 1528|      7|                              SSH_FATAL,
 1529|      7|                              "Invalid padding: %d (%" PRIu32 " left)",
 1530|      7|                              padding,
 1531|      7|                              ssh_buffer_get_len(session->in_buffer));
 1532|      7|                goto error;
 1533|      7|            }
 1534|  46.3k|            ssh_buffer_pass_bytes_end(session->in_buffer, padding);
 1535|  46.3k|            compsize = ssh_buffer_get_len(session->in_buffer);
 1536|       |
 1537|  46.3k|            if (crypto && crypto->do_compress_in &&
  ------------------
  |  Branch (1537:17): [True: 0, False: 46.3k]
  |  Branch (1537:27): [True: 0, False: 0]
  ------------------
 1538|      0|                ssh_buffer_get_len(session->in_buffer) > 0) {
  ------------------
  |  Branch (1538:17): [True: 0, False: 0]
  ------------------
 1539|      0|                rc = decompress_buffer(session, session->in_buffer,
 1540|      0|                                       MAX_PACKET_LEN);
  ------------------
  |  |  216|      0|#define MAX_PACKET_LEN 262144
  ------------------
 1541|      0|                if (rc < 0) {
  ------------------
  |  Branch (1541:21): [True: 0, False: 0]
  ------------------
 1542|      0|                    goto error;
 1543|      0|                }
 1544|      0|            }
 1545|  46.3k|            payloadsize = ssh_buffer_get_len(session->in_buffer);
 1546|  46.3k|            if (session->recv_seq == UINT32_MAX) {
  ------------------
  |  Branch (1546:17): [True: 0, False: 46.3k]
  ------------------
 1547|       |                /* Overflowing sequence numbers is always fishy */
 1548|      0|                if (crypto == NULL) {
  ------------------
  |  Branch (1548:21): [True: 0, False: 0]
  ------------------
 1549|       |                    /* don't allow sequence number overflow when unencrypted */
 1550|      0|                    ssh_set_error(session,
  ------------------
  |  |  313|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
 1551|      0|                                  SSH_FATAL,
 1552|      0|                                  "Incoming sequence number overflow");
 1553|      0|                    goto error;
 1554|      0|                } else {
 1555|      0|                    SSH_LOG(SSH_LOG_WARNING,
  ------------------
  |  |  283|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 1556|      0|                            "Incoming sequence number overflow");
 1557|      0|                }
 1558|      0|            }
 1559|  46.3k|            session->recv_seq++;
 1560|  46.3k|            if (crypto != NULL) {
  ------------------
  |  Branch (1560:17): [True: 0, False: 46.3k]
  ------------------
 1561|      0|                struct ssh_cipher_struct *cipher = NULL;
 1562|       |
 1563|      0|                cipher = crypto->in_cipher;
 1564|      0|                cipher->packets++;
 1565|      0|                cipher->blocks += payloadsize / cipher->blocksize;
 1566|      0|            }
 1567|  46.3k|            if (session->raw_counter != NULL) {
  ------------------
  |  Branch (1567:17): [True: 0, False: 46.3k]
  ------------------
 1568|      0|                session->raw_counter->in_bytes += payloadsize;
 1569|      0|                session->raw_counter->in_packets++;
 1570|      0|            }
 1571|       |
 1572|       |            /*
 1573|       |             * We don't want to rewrite a new packet while still executing the
 1574|       |             * packet callbacks
 1575|       |             */
 1576|  46.3k|            session->packet_state = PACKET_STATE_PROCESSING;
 1577|  46.3k|            ssh_packet_parse_type(session);
 1578|  46.3k|            SSH_LOG(SSH_LOG_PACKET,
  ------------------
  |  |  283|  46.3k|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 1579|  46.3k|                    "packet: read type %hhd [len=%" PRIu32 ",padding=%hhd,"
 1580|  46.3k|                    "comp=%" PRIu32 ",payload=%" PRIu32 "]",
 1581|  46.3k|                    session->in_packet.type, packet_len, padding, compsize,
 1582|  46.3k|                    payloadsize);
 1583|  46.3k|            if (crypto == NULL) {
  ------------------
  |  Branch (1583:17): [True: 46.3k, False: 0]
  ------------------
 1584|       |                /* In strict kex, only a few packets are allowed. Taint the session
 1585|       |                 * if we received packets that are normally allowed but to be
 1586|       |                 * refused if we are in strict kex when KEX is over.
 1587|       |                 */
 1588|  46.3k|                uint8_t type = session->in_packet.type;
 1589|       |
 1590|  46.3k|                if (type != SSH2_MSG_KEXINIT && type != SSH2_MSG_NEWKEYS &&
  ------------------
  |  |   12|  92.6k|#define SSH2_MSG_KEXINIT	 20
  ------------------
                              if (type != SSH2_MSG_KEXINIT && type != SSH2_MSG_NEWKEYS &&
  ------------------
  |  |   13|  92.4k|#define SSH2_MSG_NEWKEYS 21
  ------------------
  |  Branch (1590:21): [True: 46.0k, False: 263]
  |  Branch (1590:49): [True: 46.0k, False: 7]
  ------------------
 1591|  46.0k|                    (type < SSH2_MSG_KEXDH_INIT ||
  ------------------
  |  |   15|  92.1k|#define SSH2_MSG_KEXDH_INIT 30
  ------------------
  |  Branch (1591:22): [True: 30.6k, False: 15.4k]
  ------------------
 1592|  45.4k|                     type > SSH2_MSG_KEX_DH_GEX_REQUEST)) {
  ------------------
  |  |   26|  15.4k|#define SSH2_MSG_KEX_DH_GEX_REQUEST 34
  ------------------
  |  Branch (1592:22): [True: 14.7k, False: 618]
  ------------------
 1593|  45.4k|                    session->flags |= SSH_SESSION_FLAG_KEX_TAINTED;
  ------------------
  |  |   92|  45.4k|#define SSH_SESSION_FLAG_KEX_TAINTED 0x0020
  ------------------
 1594|  45.4k|                }
 1595|  46.3k|            }
 1596|       |            /* Check if the packet is expected */
 1597|  46.3k|            filter_result = ssh_packet_incoming_filter(session);
 1598|       |
 1599|  46.3k|            switch (filter_result) {
  ------------------
  |  Branch (1599:21): [True: 46.3k, False: 0]
  ------------------
 1600|  19.6k|            case SSH_PACKET_ALLOWED:
  ------------------
  |  Branch (1600:13): [True: 19.6k, False: 26.6k]
  ------------------
 1601|       |                /* Execute callbacks */
 1602|  19.6k|                ssh_packet_process(session, session->in_packet.type);
 1603|  19.6k|                break;
 1604|     24|            case SSH_PACKET_DENIED:
  ------------------
  |  Branch (1604:13): [True: 24, False: 46.3k]
  ------------------
 1605|     24|                ssh_set_error(session,
  ------------------
  |  |  313|     24|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
 1606|     24|                              SSH_FATAL,
 1607|     24|                              "Packet filter: rejected packet (type %d)",
 1608|     24|                              session->in_packet.type);
 1609|     24|                goto error;
 1610|  26.6k|            case SSH_PACKET_UNKNOWN:
  ------------------
  |  Branch (1610:13): [True: 26.6k, False: 19.7k]
  ------------------
 1611|  26.6k|                if (crypto == NULL) {
  ------------------
  |  Branch (1611:21): [True: 26.6k, False: 0]
  ------------------
 1612|  26.6k|                    session->flags |= SSH_SESSION_FLAG_KEX_TAINTED;
  ------------------
  |  |   92|  26.6k|#define SSH_SESSION_FLAG_KEX_TAINTED 0x0020
  ------------------
 1613|  26.6k|                }
 1614|  26.6k|                ssh_packet_send_unimplemented(session, session->recv_seq - 1);
 1615|  26.6k|                break;
 1616|  46.3k|            }
 1617|       |
 1618|  46.3k|            session->packet_state = PACKET_STATE_INIT;
 1619|  46.3k|            if (processed < receivedlen) {
  ------------------
  |  Branch (1619:17): [True: 46.2k, False: 34]
  ------------------
 1620|  46.2k|                SSH_LOG(SSH_LOG_PACKET,
  ------------------
  |  |  283|  46.2k|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 1621|  46.2k|                        "packet: %zu bytes still remaining in socket buffer "
 1622|  46.2k|                        "after processing",
 1623|  46.2k|                        receivedlen-processed);
 1624|  46.2k|            }
 1625|       |
 1626|  46.3k|            ok = ssh_packet_need_rekey(session, 0);
 1627|  46.3k|            if (ok) {
  ------------------
  |  Branch (1627:17): [True: 0, False: 46.3k]
  ------------------
 1628|      0|                SSH_LOG(SSH_LOG_PACKET, "Incoming packet triggered rekey");
  ------------------
  |  |  283|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 1629|      0|                rc = ssh_send_rekex(session);
 1630|      0|                if (rc != SSH_OK) {
  ------------------
  |  |  315|      0|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (1630:21): [True: 0, False: 0]
  ------------------
 1631|      0|                    SSH_LOG(SSH_LOG_PACKET, "Rekey failed: rc = %d", rc);
  ------------------
  |  |  283|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 1632|      0|                    goto error;
 1633|      0|                }
 1634|      0|            }
 1635|       |
 1636|  46.3k|            return processed;
 1637|      0|        case PACKET_STATE_PROCESSING:
  ------------------
  |  Branch (1637:9): [True: 0, False: 47.1k]
  ------------------
 1638|      0|            SSH_LOG(SSH_LOG_PACKET, "Nested packet processing. Delaying.");
  ------------------
  |  |  283|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 1639|      0|            return 0;
 1640|  47.1k|    }
 1641|       |
 1642|      0|    ssh_set_error(session,
  ------------------
  |  |  313|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
 1643|      0|                  SSH_FATAL,
 1644|      0|                  "Invalid state into packet_read2(): %d",
 1645|      0|                  session->packet_state);
 1646|       |
 1647|    420|error:
 1648|    420|    session->session_state = SSH_SESSION_STATE_ERROR;
 1649|    420|    SSH_LOG(SSH_LOG_PACKET, "Packet: processed %zu bytes", processed);
  ------------------
  |  |  283|    420|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 1650|    420|    return processed;
 1651|      0|}
ssh_packet_register_socket_callback:
 1678|    412|{
 1679|    412|    struct ssh_socket_callbacks_struct *callbacks = &session->socket_callbacks;
 1680|       |
 1681|    412|    callbacks->data = ssh_packet_socket_callback;
 1682|       |    callbacks->connected = NULL;
 1683|    412|    callbacks->controlflow = ssh_packet_socket_controlflow_callback;
 1684|    412|    callbacks->userdata = session;
 1685|    412|    ssh_socket_set_callbacks(s, callbacks);
 1686|    412|}
ssh_packet_set_callbacks:
 1693|    578|{
 1694|    578|    if (session->packet_callbacks == NULL) {
  ------------------
  |  Branch (1694:9): [True: 412, False: 166]
  ------------------
 1695|    412|        session->packet_callbacks = ssh_list_new();
 1696|    412|        if (session->packet_callbacks == NULL) {
  ------------------
  |  Branch (1696:13): [True: 0, False: 412]
  ------------------
 1697|      0|            ssh_set_error_oom(session);
  ------------------
  |  |  320|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
 1698|      0|            return;
 1699|      0|        }
 1700|    412|    }
 1701|    578|    ssh_list_append(session->packet_callbacks, callbacks);
 1702|    578|}
ssh_packet_remove_callbacks:
 1709|    110|{
 1710|    110|    struct ssh_iterator *it = NULL;
 1711|       |
 1712|    110|    it = ssh_list_find(session->packet_callbacks, callbacks);
 1713|    110|    if (it != NULL) {
  ------------------
  |  Branch (1713:9): [True: 110, False: 0]
  ------------------
 1714|    110|        ssh_list_remove(session->packet_callbacks, it);
 1715|    110|    }
 1716|    110|}
ssh_packet_set_default_callbacks:
 1722|    412|{
 1723|    412|    struct ssh_packet_callbacks_struct *c = &session->default_packet_callbacks;
 1724|       |
 1725|    412|    c->start = 1;
 1726|    412|    c->n_callbacks = sizeof(default_packet_handlers) / sizeof(ssh_packet_callback);
 1727|    412|    c->user = session;
 1728|    412|    c->callbacks = default_packet_handlers;
 1729|    412|    ssh_packet_set_callbacks(session, c);
 1730|    412|}
ssh_packet_process:
 1737|  19.6k|{
 1738|  19.6k|    struct ssh_iterator *i = NULL;
 1739|  19.6k|    int rc = SSH_PACKET_NOT_USED;
  ------------------
  |  |  641|  19.6k|#define SSH_PACKET_NOT_USED 2
  ------------------
 1740|  19.6k|    ssh_packet_callbacks cb;
 1741|       |
 1742|  19.6k|    SSH_LOG(SSH_LOG_PACKET, "Dispatching handler for packet type %d", type);
  ------------------
  |  |  283|  19.6k|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 1743|  19.6k|    if (session->packet_callbacks == NULL) {
  ------------------
  |  Branch (1743:9): [True: 0, False: 19.6k]
  ------------------
 1744|      0|        SSH_LOG(SSH_LOG_RARE, "Packet callback is not initialized !");
  ------------------
  |  |  283|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 1745|      0|        return;
 1746|      0|    }
 1747|       |
 1748|  19.6k|    i = ssh_list_get_iterator(session->packet_callbacks);
 1749|  20.8k|    while (i != NULL) {
  ------------------
  |  Branch (1749:12): [True: 20.3k, False: 503]
  ------------------
 1750|  20.3k|        cb = ssh_iterator_value(ssh_packet_callbacks, i);
  ------------------
  |  |  122|  20.3k|  ((type)((iterator)->data))
  ------------------
 1751|  20.3k|        i = i->next;
 1752|       |
 1753|  20.3k|        if (!cb) {
  ------------------
  |  Branch (1753:13): [True: 0, False: 20.3k]
  ------------------
 1754|      0|            continue;
 1755|      0|        }
 1756|       |
 1757|  20.3k|        if (cb->start > type) {
  ------------------
  |  Branch (1757:13): [True: 0, False: 20.3k]
  ------------------
 1758|      0|            continue;
 1759|      0|        }
 1760|       |
 1761|  20.3k|        if (cb->start + cb->n_callbacks <= type) {
  ------------------
  |  Branch (1761:13): [True: 503, False: 19.8k]
  ------------------
 1762|    503|            continue;
 1763|    503|        }
 1764|       |
 1765|  19.8k|        if (cb->callbacks[type - cb->start] == NULL) {
  ------------------
  |  Branch (1765:13): [True: 616, False: 19.1k]
  ------------------
 1766|    616|            continue;
 1767|    616|        }
 1768|       |
 1769|  19.1k|        rc = cb->callbacks[type - cb->start](session, type, session->in_buffer,
 1770|  19.1k|                                             cb->user);
 1771|  19.1k|        if (rc == SSH_PACKET_USED) {
  ------------------
  |  |  638|  19.1k|#define SSH_PACKET_USED 1
  ------------------
  |  Branch (1771:13): [True: 19.1k, False: 0]
  ------------------
 1772|  19.1k|            break;
 1773|  19.1k|        }
 1774|  19.1k|    }
 1775|       |
 1776|  19.6k|    if (rc == SSH_PACKET_NOT_USED) {
  ------------------
  |  |  641|  19.6k|#define SSH_PACKET_NOT_USED 2
  ------------------
  |  Branch (1776:9): [True: 503, False: 19.1k]
  ------------------
 1777|    503|        SSH_LOG(SSH_LOG_RARE, "Couldn't do anything with packet type %d", type);
  ------------------
  |  |  283|    503|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 1778|    503|        rc = ssh_packet_send_unimplemented(session, session->recv_seq - 1);
 1779|    503|        if (rc != SSH_OK) {
  ------------------
  |  |  315|    503|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (1779:13): [True: 0, False: 503]
  ------------------
 1780|      0|            SSH_LOG(SSH_LOG_RARE, "Failed to send unimplemented: %s",
  ------------------
  |  |  283|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 1781|      0|                    ssh_get_error(session));
 1782|      0|        }
 1783|    503|        if (session->current_crypto == NULL) {
  ------------------
  |  Branch (1783:13): [True: 503, False: 0]
  ------------------
 1784|    503|            session->flags |= SSH_SESSION_FLAG_KEX_TAINTED;
  ------------------
  |  |   92|    503|#define SSH_SESSION_FLAG_KEX_TAINTED 0x0020
  ------------------
 1785|    503|        }
 1786|    503|    }
 1787|  19.6k|}
ssh_packet_send_newkeys:
 1795|     28|{
 1796|     28|    int rc;
 1797|       |
 1798|       |    /* Send the MSG_NEWKEYS */
 1799|     28|    rc = ssh_buffer_add_u8(session->out_buffer, SSH2_MSG_NEWKEYS);
  ------------------
  |  |   13|     28|#define SSH2_MSG_NEWKEYS 21
  ------------------
 1800|     28|    if (rc < 0) {
  ------------------
  |  Branch (1800:9): [True: 0, False: 28]
  ------------------
 1801|      0|        return rc;
 1802|      0|    }
 1803|       |
 1804|     28|    rc = ssh_packet_send(session);
 1805|     28|    if (rc == SSH_ERROR) {
  ------------------
  |  |  316|     28|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  |  Branch (1805:9): [True: 0, False: 28]
  ------------------
 1806|      0|        return rc;
 1807|      0|    }
 1808|     28|    SSH_LOG(SSH_LOG_DEBUG, "SSH_MSG_NEWKEYS sent");
  ------------------
  |  |  283|     28|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 1809|     28|    return rc;
 1810|     28|}
ssh_packet_send_unimplemented:
 1818|  27.1k|int ssh_packet_send_unimplemented(ssh_session session, uint32_t seqnum){
 1819|  27.1k|    int rc;
 1820|       |
 1821|  27.1k|    rc = ssh_buffer_pack(session->out_buffer,
  ------------------
  |  |   50|  27.1k|    _ssh_buffer_pack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |  453|  27.1k|        (__VA_NARG_(__VA_ARGS__, __RSEQ_N()))
  |  |  |  |  ------------------
  |  |  |  |  |  |  455|  27.1k|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  450|  27.1k|#define VA_APPLY_VARIADIC_MACRO(macro, tuple) macro tuple
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  455|  27.1k|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  463|  27.1k|        _61,_62,_63,N,...) N
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                   _ssh_buffer_pack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |   28|  27.1k|#define SSH_BUFFER_PACK_END ((uint32_t) 0x4f65feb3)
  |  |  ------------------
  ------------------
 1822|  27.1k|                         "bd",
 1823|  27.1k|                         SSH2_MSG_UNIMPLEMENTED,
 1824|  27.1k|                         seqnum);
 1825|  27.1k|    if (rc != SSH_OK) {
  ------------------
  |  |  315|  27.1k|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (1825:9): [True: 0, False: 27.1k]
  ------------------
 1826|      0|        ssh_set_error_oom(session);
  ------------------
  |  |  320|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
 1827|      0|        return SSH_ERROR;
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 1828|      0|    }
 1829|  27.1k|    rc = ssh_packet_send(session);
 1830|       |
 1831|  27.1k|    return rc;
 1832|  27.1k|}
ssh_packet_unimplemented:
 1837|     99|SSH_PACKET_CALLBACK(ssh_packet_unimplemented){
 1838|     99|    uint32_t seq;
 1839|     99|    int rc;
 1840|       |
 1841|     99|    (void)session; /* unused */
 1842|     99|    (void)type;
 1843|     99|    (void)user;
 1844|       |
 1845|     99|    rc = ssh_buffer_unpack(packet, "d", &seq);
  ------------------
  |  |   60|     99|    _ssh_buffer_unpack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |  453|     99|        (__VA_NARG_(__VA_ARGS__, __RSEQ_N()))
  |  |  |  |  ------------------
  |  |  |  |  |  |  455|     99|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  450|     99|#define VA_APPLY_VARIADIC_MACRO(macro, tuple) macro tuple
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  455|     99|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  463|     99|        _61,_62,_63,N,...) N
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                   _ssh_buffer_unpack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |   28|     99|#define SSH_BUFFER_PACK_END ((uint32_t) 0x4f65feb3)
  |  |  ------------------
  ------------------
 1846|     99|    if (rc != SSH_OK) {
  ------------------
  |  |  315|     99|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (1846:9): [True: 32, False: 67]
  ------------------
 1847|     32|        SSH_LOG(SSH_LOG_TRACE,
  ------------------
  |  |  283|     32|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 1848|     32|                "Could not unpack SSH_MSG_UNIMPLEMENTED packet");
 1849|     32|        return SSH_PACKET_USED;
  ------------------
  |  |  638|     32|#define SSH_PACKET_USED 1
  ------------------
 1850|     32|    }
 1851|       |
 1852|     67|    SSH_LOG(SSH_LOG_RARE,
  ------------------
  |  |  283|     67|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 1853|     67|            "Received SSH_MSG_UNIMPLEMENTED (sequence number %" PRIu32 ")",seq);
 1854|       |
 1855|     67|    return SSH_PACKET_USED;
  ------------------
  |  |  638|     67|#define SSH_PACKET_USED 1
  ------------------
 1856|     99|}
ssh_packet_parse_type:
 1862|  46.3k|{
 1863|  46.3k|    session->in_packet = (struct packet_struct) {
 1864|  46.3k|        .type = 0,
 1865|  46.3k|    };
 1866|       |
 1867|  46.3k|    if (session->in_buffer == NULL) {
  ------------------
  |  Branch (1867:9): [True: 0, False: 46.3k]
  ------------------
 1868|      0|        return SSH_ERROR;
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 1869|      0|    }
 1870|       |
 1871|  46.3k|    if (ssh_buffer_get_u8(session->in_buffer, &session->in_packet.type) == 0) {
  ------------------
  |  Branch (1871:9): [True: 11.7k, False: 34.6k]
  ------------------
 1872|  11.7k|        ssh_set_error(session, SSH_FATAL, "Packet too short to read type");
  ------------------
  |  |  313|  11.7k|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
 1873|  11.7k|        return SSH_ERROR;
  ------------------
  |  |  316|  11.7k|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 1874|  11.7k|    }
 1875|       |
 1876|  34.6k|    session->in_packet.valid = 1;
 1877|       |
 1878|  34.6k|    return SSH_OK;
  ------------------
  |  |  315|  34.6k|#define SSH_OK 0     /* No error */
  ------------------
 1879|  46.3k|}
ssh_packet_send:
 2067|  28.2k|{
 2068|  28.2k|    uint32_t payloadsize;
 2069|  28.2k|    uint8_t type, *payload;
 2070|  28.2k|    bool need_rekey, in_rekey;
 2071|  28.2k|    int rc;
 2072|       |
 2073|  28.2k|    if (session->socket == NULL || !ssh_socket_is_open(session->socket)) {
  ------------------
  |  Branch (2073:9): [True: 0, False: 28.2k]
  |  Branch (2073:36): [True: 0, False: 28.2k]
  ------------------
 2074|      0|        ssh_buffer_reinit(session->out_buffer);
 2075|      0|        return SSH_ERROR;
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 2076|      0|    }
 2077|       |
 2078|  28.2k|    payloadsize = ssh_buffer_get_len(session->out_buffer);
 2079|  28.2k|    if (payloadsize < 1) {
  ------------------
  |  Branch (2079:9): [True: 0, False: 28.2k]
  ------------------
 2080|      0|        return SSH_ERROR;
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 2081|      0|    }
 2082|       |
 2083|  28.2k|    payload = (uint8_t *)ssh_buffer_get(session->out_buffer);
 2084|  28.2k|    type = payload[0]; /* type is the first byte of the packet now */
 2085|  28.2k|    need_rekey = ssh_packet_need_rekey(session, payloadsize);
 2086|  28.2k|    in_rekey = ssh_packet_in_rekey(session);
 2087|       |
 2088|       |    /* The rekey is triggered here. After that, only the key exchange
 2089|       |     * packets can be sent, until we send our NEWKEYS.
 2090|       |     */
 2091|  28.2k|    if (need_rekey || (in_rekey && !ssh_packet_is_kex(type))) {
  ------------------
  |  Branch (2091:9): [True: 0, False: 28.2k]
  |  Branch (2091:24): [True: 0, False: 28.2k]
  |  Branch (2091:36): [True: 0, False: 0]
  ------------------
 2092|      0|        if (need_rekey) {
  ------------------
  |  Branch (2092:13): [True: 0, False: 0]
  ------------------
 2093|      0|            SSH_LOG(SSH_LOG_PACKET, "Outgoing packet triggered rekey");
  ------------------
  |  |  283|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 2094|      0|        }
 2095|       |        /* Queue the current packet -- we will send it after the rekey */
 2096|      0|        SSH_LOG(SSH_LOG_PACKET, "Queuing packet type %d", type);
  ------------------
  |  |  283|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 2097|      0|        rc = ssh_list_append(session->out_queue, session->out_buffer);
 2098|      0|        if (rc != SSH_OK) {
  ------------------
  |  |  315|      0|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (2098:13): [True: 0, False: 0]
  ------------------
 2099|      0|            return SSH_ERROR;
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 2100|      0|        }
 2101|      0|        session->out_buffer = ssh_buffer_new();
 2102|      0|        if (session->out_buffer == NULL) {
  ------------------
  |  Branch (2102:13): [True: 0, False: 0]
  ------------------
 2103|      0|            ssh_set_error_oom(session);
  ------------------
  |  |  320|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
 2104|      0|            return SSH_ERROR;
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 2105|      0|        }
 2106|       |
 2107|      0|        if (need_rekey) {
  ------------------
  |  Branch (2107:13): [True: 0, False: 0]
  ------------------
 2108|       |            /* Send the KEXINIT packet instead.
 2109|       |             * This recursively calls the packet_send(), but it should
 2110|       |             * not get into rekeying again.
 2111|       |             * After that we need to handle the key exchange responses
 2112|       |             * up to the point where we can send the rest of the queue.
 2113|       |             */
 2114|      0|            return ssh_send_rekex(session);
 2115|      0|        }
 2116|      0|        return SSH_OK;
  ------------------
  |  |  315|      0|#define SSH_OK 0     /* No error */
  ------------------
 2117|      0|    }
 2118|       |
 2119|       |    /* Send the packet normally */
 2120|  28.2k|    rc = packet_send2(session);
 2121|       |
 2122|       |    /* We finished the key exchange so we can try to send our queue now */
 2123|  28.2k|    if (rc == SSH_OK && type == SSH2_MSG_NEWKEYS) {
  ------------------
  |  |  315|  56.4k|#define SSH_OK 0     /* No error */
  ------------------
                  if (rc == SSH_OK && type == SSH2_MSG_NEWKEYS) {
  ------------------
  |  |   13|  28.2k|#define SSH2_MSG_NEWKEYS 21
  ------------------
  |  Branch (2123:9): [True: 28.2k, False: 0]
  |  Branch (2123:25): [True: 28, False: 28.1k]
  ------------------
 2124|     28|        struct ssh_iterator *it = NULL;
 2125|       |
 2126|     28|        if (session->flags & SSH_SESSION_FLAG_KEX_STRICT) {
  ------------------
  |  |   90|     28|#define SSH_SESSION_FLAG_KEX_STRICT 0x0010
  ------------------
  |  Branch (2126:13): [True: 1, False: 27]
  ------------------
 2127|       |            /* reset packet sequence number when running in strict kex mode */
 2128|      1|            session->send_seq = 0;
 2129|      1|        }
 2130|     28|        for (it = ssh_list_get_iterator(session->out_queue);
 2131|     28|             it != NULL;
  ------------------
  |  Branch (2131:14): [True: 0, False: 28]
  ------------------
 2132|     28|             it = ssh_list_get_iterator(session->out_queue)) {
 2133|      0|            struct ssh_buffer_struct *next_buffer = NULL;
 2134|       |
 2135|       |            /* Peek only -- do not remove from queue yet */
 2136|      0|            next_buffer = ssh_iterator_value(struct ssh_buffer_struct *, it);
  ------------------
  |  |  122|      0|  ((type)((iterator)->data))
  ------------------
 2137|      0|            payloadsize = ssh_buffer_get_len(next_buffer);
 2138|      0|            if (ssh_packet_need_rekey(session, payloadsize)) {
  ------------------
  |  Branch (2138:17): [True: 0, False: 0]
  ------------------
 2139|       |                /* Sigh ... we still can not send this packet. Repeat. */
 2140|      0|                SSH_LOG(SSH_LOG_PACKET, "Queued packet triggered rekey");
  ------------------
  |  |  283|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 2141|      0|                return ssh_send_rekex(session);
 2142|      0|            }
 2143|      0|            SSH_BUFFER_FREE(session->out_buffer);
  ------------------
  |  |  924|      0|    do { if ((x) != NULL) { ssh_buffer_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (924:14): [True: 0, False: 0]
  |  |  |  Branch (924:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2144|      0|            session->out_buffer = ssh_list_pop_head(struct ssh_buffer_struct *,
  ------------------
  |  |  130|      0|  ((type)_ssh_list_pop_head(ssh_list))
  ------------------
 2145|      0|                                                    session->out_queue);
 2146|      0|            payload = (uint8_t *)ssh_buffer_get(session->out_buffer);
 2147|      0|            type = payload[0];
 2148|      0|            SSH_LOG(SSH_LOG_PACKET, "Dequeue packet type %d", type);
  ------------------
  |  |  283|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 2149|      0|            rc = packet_send2(session);
 2150|      0|            if (rc != SSH_OK) {
  ------------------
  |  |  315|      0|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (2150:17): [True: 0, False: 0]
  ------------------
 2151|      0|                return rc;
 2152|      0|            }
 2153|      0|        }
 2154|     28|    }
 2155|       |
 2156|  28.2k|    return rc;
 2157|  28.2k|}
ssh_packet_set_newkeys:
 2272|     28|{
 2273|     28|    struct ssh_cipher_struct *in_cipher = NULL, *out_cipher = NULL;
 2274|     28|    int rc;
 2275|       |
 2276|     28|    SSH_LOG(SSH_LOG_TRACE,
  ------------------
  |  |  283|    112|    _ssh_log(priority, __func__, __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (283:34): [True: 0, False: 28]
  |  |  |  Branch (283:34): [True: 28, False: 0]
  |  |  ------------------
  ------------------
 2277|     28|            "called, direction =%s%s",
 2278|     28|            direction & SSH_DIRECTION_IN ? " IN " : "",
 2279|     28|            direction & SSH_DIRECTION_OUT ? " OUT " : "");
 2280|       |
 2281|     28|    if (session->next_crypto == NULL) {
  ------------------
  |  Branch (2281:9): [True: 0, False: 28]
  ------------------
 2282|      0|        return SSH_ERROR;
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 2283|      0|    }
 2284|       |
 2285|     28|    session->next_crypto->used |= direction;
 2286|     28|    if (session->current_crypto != NULL) {
  ------------------
  |  Branch (2286:9): [True: 0, False: 28]
  ------------------
 2287|      0|        if (session->current_crypto->used & direction) {
  ------------------
  |  Branch (2287:13): [True: 0, False: 0]
  ------------------
 2288|      0|            SSH_LOG(SSH_LOG_TRACE, "This direction isn't used anymore.");
  ------------------
  |  |  283|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 2289|      0|        }
 2290|       |        /* Mark the current requested direction unused */
 2291|      0|        session->current_crypto->used &= ~direction;
 2292|      0|    }
 2293|       |
 2294|       |    /* Both sides switched: do the actual switch now */
 2295|     28|    if (session->next_crypto->used == SSH_DIRECTION_BOTH) {
  ------------------
  |  Branch (2295:9): [True: 0, False: 28]
  ------------------
 2296|      0|        size_t session_id_len;
 2297|       |
 2298|      0|        if (session->current_crypto != NULL) {
  ------------------
  |  Branch (2298:13): [True: 0, False: 0]
  ------------------
 2299|      0|            crypto_free(session->current_crypto);
 2300|      0|            session->current_crypto = NULL;
 2301|      0|        }
 2302|       |
 2303|      0|        session->current_crypto = session->next_crypto;
 2304|      0|        session->current_crypto->used = SSH_DIRECTION_BOTH;
 2305|       |
 2306|       |        /* Initialize the next_crypto structure */
 2307|      0|        session->next_crypto = crypto_new();
 2308|      0|        if (session->next_crypto == NULL) {
  ------------------
  |  Branch (2308:13): [True: 0, False: 0]
  ------------------
 2309|      0|            ssh_set_error_oom(session);
  ------------------
  |  |  320|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
 2310|      0|            return SSH_ERROR;
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 2311|      0|        }
 2312|       |
 2313|      0|        session_id_len = session->current_crypto->session_id_len;
 2314|      0|        session->next_crypto->session_id = malloc(session_id_len);
 2315|      0|        if (session->next_crypto->session_id == NULL) {
  ------------------
  |  Branch (2315:13): [True: 0, False: 0]
  ------------------
 2316|      0|            ssh_set_error_oom(session);
  ------------------
  |  |  320|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
 2317|      0|            return SSH_ERROR;
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 2318|      0|        }
 2319|       |
 2320|      0|        memcpy(session->next_crypto->session_id,
 2321|      0|               session->current_crypto->session_id,
 2322|      0|               session_id_len);
 2323|      0|        session->next_crypto->session_id_len = session_id_len;
 2324|       |
 2325|      0|        return SSH_OK;
  ------------------
  |  |  315|      0|#define SSH_OK 0     /* No error */
  ------------------
 2326|      0|    }
 2327|       |
 2328|       |    /* Initialize common structures so the next context can be used in
 2329|       |     * either direction */
 2330|     28|    if (session->client) {
  ------------------
  |  Branch (2330:9): [True: 28, False: 0]
  ------------------
 2331|       |        /* The server has this part already done */
 2332|     28|        rc = ssh_make_sessionid(session);
 2333|     28|        if (rc != SSH_OK) {
  ------------------
  |  |  315|     28|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (2333:13): [True: 0, False: 28]
  ------------------
 2334|      0|            return SSH_ERROR;
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 2335|      0|        }
 2336|       |
 2337|       |        /*
 2338|       |         * Set the cryptographic functions for the next crypto
 2339|       |         * (it is needed for ssh_generate_session_keys for key lengths)
 2340|       |         */
 2341|     28|        rc = crypt_set_algorithms_client(session);
 2342|     28|        if (rc < 0) {
  ------------------
  |  Branch (2342:13): [True: 0, False: 28]
  ------------------
 2343|      0|            return SSH_ERROR;
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 2344|      0|        }
 2345|     28|    }
 2346|       |
 2347|     28|    if (ssh_generate_session_keys(session) < 0) {
  ------------------
  |  Branch (2347:9): [True: 0, False: 28]
  ------------------
 2348|      0|        return SSH_ERROR;
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 2349|      0|    }
 2350|       |
 2351|     28|    in_cipher = session->next_crypto->in_cipher;
 2352|     28|    out_cipher = session->next_crypto->out_cipher;
 2353|     28|    if (in_cipher == NULL || out_cipher == NULL) {
  ------------------
  |  Branch (2353:9): [True: 0, False: 28]
  |  Branch (2353:30): [True: 0, False: 28]
  ------------------
 2354|      0|        return SSH_ERROR;
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 2355|      0|    }
 2356|       |
 2357|       |    /* Initialize rekeying states */
 2358|     28|    ssh_init_rekey_state(session, out_cipher);
 2359|     28|    ssh_init_rekey_state(session, in_cipher);
 2360|     28|    if (session->opts.rekey_time != 0) {
  ------------------
  |  Branch (2360:9): [True: 0, False: 28]
  ------------------
 2361|      0|        ssh_timestamp_init(&session->last_rekey_time);
 2362|      0|        SSH_LOG(SSH_LOG_DEBUG, "Set rekey after %" PRIu32 " seconds",
  ------------------
  |  |  283|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 2363|      0|                session->opts.rekey_time/1000);
 2364|      0|    }
 2365|       |
 2366|     28|    if (in_cipher->set_decrypt_key) {
  ------------------
  |  Branch (2366:9): [True: 0, False: 28]
  ------------------
 2367|       |        /* Initialize the encryption and decryption keys in next_crypto */
 2368|      0|        rc = in_cipher->set_decrypt_key(in_cipher,
 2369|      0|                                        session->next_crypto->decryptkey,
 2370|      0|                                        session->next_crypto->decryptIV);
 2371|      0|        if (rc < 0) {
  ------------------
  |  Branch (2371:13): [True: 0, False: 0]
  ------------------
 2372|       |            /* On error, make sure it is not used */
 2373|      0|            session->next_crypto->used = 0;
 2374|      0|            return SSH_ERROR;
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 2375|      0|        }
 2376|      0|    }
 2377|       |
 2378|     28|    if (out_cipher->set_encrypt_key) {
  ------------------
  |  Branch (2378:9): [True: 0, False: 28]
  ------------------
 2379|      0|        rc = out_cipher->set_encrypt_key(out_cipher,
 2380|      0|                                         session->next_crypto->encryptkey,
 2381|      0|                                         session->next_crypto->encryptIV);
 2382|      0|        if (rc < 0) {
  ------------------
  |  Branch (2382:13): [True: 0, False: 0]
  ------------------
 2383|       |            /* On error, make sure it is not used */
 2384|      0|            session->next_crypto->used = 0;
 2385|      0|            return SSH_ERROR;
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 2386|      0|        }
 2387|      0|    }
 2388|       |
 2389|     28|    return SSH_OK;
  ------------------
  |  |  315|     28|#define SSH_OK 0     /* No error */
  ------------------
 2390|     28|}
packet.c:ssh_packet_incoming_filter:
  143|  46.3k|{
  144|  46.3k|    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|  46.3k|    switch(session->in_packet.type) {
  152|      7|    case SSH2_MSG_DISCONNECT:                         // 1
  ------------------
  |  |    4|      7|#define SSH2_MSG_DISCONNECT 1
  ------------------
  |  Branch (152:5): [True: 7, False: 46.3k]
  ------------------
  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|      7|        rc = SSH_PACKET_ALLOWED;
  164|      7|        break;
  165|      5|    case SSH2_MSG_IGNORE:                             // 2
  ------------------
  |  |    5|      5|#define SSH2_MSG_IGNORE	 2
  ------------------
  |  Branch (165:5): [True: 5, False: 46.3k]
  ------------------
  166|       |        /*
  167|       |         * States required:
  168|       |         * - None
  169|       |         *
  170|       |         * Transitions:
  171|       |         * - None
  172|       |         * */
  173|       |
  174|       |        /* Always allowed */
  175|      5|        rc = SSH_PACKET_ALLOWED;
  176|      5|        break;
  177|     99|    case SSH2_MSG_UNIMPLEMENTED:                      // 3
  ------------------
  |  |    6|     99|#define SSH2_MSG_UNIMPLEMENTED 3
  ------------------
  |  Branch (177:5): [True: 99, False: 46.2k]
  ------------------
  178|       |        /*
  179|       |         * States required:
  180|       |         * - None
  181|       |         *
  182|       |         * Transitions:
  183|       |         * - None
  184|       |         * */
  185|       |
  186|       |        /* Always allowed */
  187|     99|        rc = SSH_PACKET_ALLOWED;
  188|     99|        break;
  189|  18.6k|    case SSH2_MSG_DEBUG:                              // 4
  ------------------
  |  |    7|  18.6k|#define SSH2_MSG_DEBUG	4
  ------------------
  |  Branch (189:5): [True: 18.6k, False: 27.6k]
  ------------------
  190|       |        /*
  191|       |         * States required:
  192|       |         * - None
  193|       |         *
  194|       |         * Transitions:
  195|       |         * - None
  196|       |         * */
  197|       |
  198|       |        /* Always allowed */
  199|  18.6k|        rc = SSH_PACKET_ALLOWED;
  200|  18.6k|        break;
  201|      1|    case SSH2_MSG_SERVICE_REQUEST:                    // 5
  ------------------
  |  |    8|      1|#define SSH2_MSG_SERVICE_REQUEST	5
  ------------------
  |  Branch (201:5): [True: 1, False: 46.3k]
  ------------------
  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|      1|        if (session->client) {
  ------------------
  |  Branch (215:13): [True: 1, False: 0]
  ------------------
  216|      1|            rc = SSH_PACKET_DENIED;
  217|      1|            break;
  218|      1|        }
  219|       |
  220|      0|        if ((session->session_state != SSH_SESSION_STATE_AUTHENTICATING) &&
  ------------------
  |  Branch (220:13): [True: 0, False: 0]
  ------------------
  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|      0|        if (session->dh_handshake_state != DH_STATE_FINISHED) {
  ------------------
  |  Branch (227:13): [True: 0, False: 0]
  ------------------
  228|      0|            rc = SSH_PACKET_DENIED;
  229|      0|            break;
  230|      0|        }
  231|       |
  232|      0|        rc = SSH_PACKET_ALLOWED;
  233|      0|        break;
  234|      0|    case SSH2_MSG_SERVICE_ACCEPT:                     // 6
  ------------------
  |  |    9|      0|#define SSH2_MSG_SERVICE_ACCEPT 6
  ------------------
  |  Branch (234:5): [True: 0, False: 46.3k]
  ------------------
  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|      0|        if ((session->session_state != SSH_SESSION_STATE_AUTHENTICATING) &&
  ------------------
  |  Branch (246:13): [True: 0, False: 0]
  ------------------
  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|      0|        if (session->dh_handshake_state != DH_STATE_FINISHED) {
  ------------------
  |  Branch (253:13): [True: 0, False: 0]
  ------------------
  254|      0|            rc = SSH_PACKET_DENIED;
  255|      0|            break;
  256|      0|        }
  257|       |
  258|       |        /* TODO check if only auth service can be requested */
  259|      0|        if (session->auth.service_state != SSH_AUTH_SERVICE_SENT) {
  ------------------
  |  Branch (259:13): [True: 0, False: 0]
  ------------------
  260|      0|            rc = SSH_PACKET_DENIED;
  261|      0|            break;
  262|      0|        }
  263|       |
  264|      0|        rc = SSH_PACKET_ALLOWED;
  265|      0|        break;
  266|      1|    case SSH2_MSG_EXT_INFO:                           // 7
  ------------------
  |  |   10|      1|#define SSH2_MSG_EXT_INFO 7
  ------------------
  |  Branch (266:5): [True: 1, False: 46.3k]
  ------------------
  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|      1|        if ((session->session_state != SSH_SESSION_STATE_AUTHENTICATING) &&
  ------------------
  |  Branch (278:13): [True: 1, False: 0]
  ------------------
  279|      1|            (session->session_state != SSH_SESSION_STATE_AUTHENTICATED))
  ------------------
  |  Branch (279:13): [True: 1, False: 0]
  ------------------
  280|      1|        {
  281|      1|            rc = SSH_PACKET_DENIED;
  282|      1|            break;
  283|      1|        }
  284|       |
  285|      0|        if (session->dh_handshake_state != DH_STATE_FINISHED) {
  ------------------
  |  Branch (285:13): [True: 0, False: 0]
  ------------------
  286|      0|            rc = SSH_PACKET_DENIED;
  287|      0|            break;
  288|      0|        }
  289|       |
  290|      0|        rc = SSH_PACKET_ALLOWED;
  291|      0|        break;
  292|    263|    case SSH2_MSG_KEXINIT:                            // 20
  ------------------
  |  |   12|    263|#define SSH2_MSG_KEXINIT	 20
  ------------------
  |  Branch (292:5): [True: 263, False: 46.0k]
  ------------------
  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|    263|        if ((session->session_state != SSH_SESSION_STATE_AUTHENTICATED) &&
  ------------------
  |  Branch (310:13): [True: 263, False: 0]
  ------------------
  311|    263|            (session->session_state != SSH_SESSION_STATE_INITIAL_KEX))
  ------------------
  |  Branch (311:13): [True: 0, False: 263]
  ------------------
  312|      0|        {
  313|      0|            rc = SSH_PACKET_DENIED;
  314|      0|            break;
  315|      0|        }
  316|       |
  317|    263|        if ((session->dh_handshake_state != DH_STATE_INIT) &&
  ------------------
  |  Branch (317:13): [True: 0, False: 263]
  ------------------
  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|    263|        rc = SSH_PACKET_ALLOWED;
  327|    263|        break;
  328|      7|    case SSH2_MSG_NEWKEYS:                            // 21
  ------------------
  |  |   13|      7|#define SSH2_MSG_NEWKEYS 21
  ------------------
  |  Branch (328:5): [True: 7, False: 46.3k]
  ------------------
  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|      7|        if (session->session_state != SSH_SESSION_STATE_DH) {
  ------------------
  |  Branch (342:13): [True: 0, False: 7]
  ------------------
  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|      7|        if (session->dh_handshake_state != DH_STATE_NEWKEYS_SENT) {
  ------------------
  |  Branch (348:13): [True: 0, False: 7]
  ------------------
  349|      0|            rc = SSH_PACKET_DENIED;
  350|      0|            break;
  351|      0|        }
  352|       |
  353|      7|        rc = SSH_PACKET_ALLOWED;
  354|      7|        break;
  355|      0|    case SSH2_MSG_KEXDH_INIT:                         // 30
  ------------------
  |  |   15|      0|#define SSH2_MSG_KEXDH_INIT 30
  ------------------
  |  Branch (355:5): [True: 0, False: 46.3k]
  ------------------
  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|      0|        if (session->client) {
  ------------------
  |  Branch (373:13): [True: 0, False: 0]
  ------------------
  374|      0|            rc = SSH_PACKET_DENIED;
  375|      0|            break;
  376|      0|        }
  377|       |
  378|      0|        if (session->session_state != SSH_SESSION_STATE_DH) {
  ------------------
  |  Branch (378:13): [True: 0, False: 0]
  ------------------
  379|      0|            rc = SSH_PACKET_DENIED;
  380|      0|            break;
  381|      0|        }
  382|       |
  383|       |        /* Only allowed if dh_handshake_state is in initial state */
  384|      0|        if (session->dh_handshake_state != DH_STATE_INIT) {
  ------------------
  |  Branch (384:13): [True: 0, False: 0]
  ------------------
  385|      0|            rc = SSH_PACKET_DENIED;
  386|      0|            break;
  387|      0|        }
  388|       |
  389|      0|        rc = SSH_PACKET_ALLOWED;
  390|      0|        break;
  391|    113|    case SSH2_MSG_KEXDH_REPLY:                        // 31
  ------------------
  |  |   16|    113|#define SSH2_MSG_KEXDH_REPLY 31
  ------------------
  |  Branch (391:5): [True: 113, False: 46.2k]
  ------------------
  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|    113|        if (session->server) {
  ------------------
  |  Branch (408:13): [True: 0, False: 113]
  ------------------
  409|      0|            rc = SSH_PACKET_DENIED;
  410|      0|            break;
  411|      0|        }
  412|       |
  413|    113|        if (session->session_state != SSH_SESSION_STATE_DH) {
  ------------------
  |  Branch (413:13): [True: 0, False: 113]
  ------------------
  414|      0|            rc = SSH_PACKET_DENIED;
  415|      0|            break;
  416|      0|        }
  417|       |
  418|    113|        if (session->dh_handshake_state != DH_STATE_INIT_SENT &&
  ------------------
  |  Branch (418:13): [True: 3, False: 110]
  ------------------
  419|      3|            session->dh_handshake_state != DH_STATE_REQUEST_SENT) {
  ------------------
  |  Branch (419:13): [True: 0, False: 3]
  ------------------
  420|      0|            rc = SSH_PACKET_DENIED;
  421|      0|            break;
  422|      0|        }
  423|       |
  424|    113|        rc = SSH_PACKET_ALLOWED;
  425|    113|        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: 46.3k]
  ------------------
  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|    505|    case SSH2_MSG_KEX_DH_GEX_REPLY:                   // 33
  ------------------
  |  |   25|    505|#define SSH2_MSG_KEX_DH_GEX_REPLY 33
  ------------------
  |  Branch (490:5): [True: 505, False: 45.8k]
  ------------------
  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|    505|        if (session->server) {
  ------------------
  |  Branch (503:13): [True: 0, False: 505]
  ------------------
  504|      0|            rc = SSH_PACKET_DENIED;
  505|      0|            break;
  506|      0|        }
  507|       |
  508|    505|        if (session->session_state != SSH_SESSION_STATE_DH) {
  ------------------
  |  Branch (508:13): [True: 1, False: 504]
  ------------------
  509|      1|            rc = SSH_PACKET_DENIED;
  510|      1|            break;
  511|      1|        }
  512|       |
  513|    504|        if (session->dh_handshake_state != DH_STATE_INIT_SENT) {
  ------------------
  |  Branch (513:13): [True: 1, False: 503]
  ------------------
  514|      1|            rc = SSH_PACKET_DENIED;
  515|      1|            break;
  516|      1|        }
  517|       |
  518|    503|        rc = SSH_PACKET_ALLOWED;
  519|    503|        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: 46.3k]
  ------------------
  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|      1|    case SSH2_MSG_USERAUTH_REQUEST:                   // 50
  ------------------
  |  |   36|      1|#define SSH2_MSG_USERAUTH_REQUEST 50
  ------------------
  |  Branch (553:5): [True: 1, False: 46.3k]
  ------------------
  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|      1|        if (session->client) {
  ------------------
  |  Branch (567:13): [True: 1, False: 0]
  ------------------
  568|      1|            rc = SSH_PACKET_DENIED;
  569|      1|            break;
  570|      1|        }
  571|       |
  572|      0|        if (session->dh_handshake_state != DH_STATE_FINISHED) {
  ------------------
  |  Branch (572:13): [True: 0, False: 0]
  ------------------
  573|      0|            rc = SSH_PACKET_DENIED;
  574|      0|            break;
  575|      0|        }
  576|       |
  577|      0|        if (session->session_state != SSH_SESSION_STATE_AUTHENTICATING) {
  ------------------
  |  Branch (577:13): [True: 0, False: 0]
  ------------------
  578|      0|            rc = SSH_PACKET_DENIED;
  579|      0|            break;
  580|      0|        }
  581|       |
  582|      0|        rc = SSH_PACKET_ALLOWED;
  583|      0|        break;
  584|      1|    case SSH2_MSG_USERAUTH_FAILURE:                   // 51
  ------------------
  |  |   37|      1|#define SSH2_MSG_USERAUTH_FAILURE 51
  ------------------
  |  Branch (584:5): [True: 1, False: 46.3k]
  ------------------
  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|      1|        if (session->server) {
  ------------------
  |  Branch (605:13): [True: 0, False: 1]
  ------------------
  606|      0|            rc = SSH_PACKET_DENIED;
  607|      0|            break;
  608|      0|        }
  609|       |
  610|      1|        if (session->dh_handshake_state != DH_STATE_FINISHED) {
  ------------------
  |  Branch (610:13): [True: 1, False: 0]
  ------------------
  611|      1|            rc = SSH_PACKET_DENIED;
  612|      1|            break;
  613|      1|        }
  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|      0|    case SSH2_MSG_USERAUTH_SUCCESS:                   // 52
  ------------------
  |  |   38|      0|#define SSH2_MSG_USERAUTH_SUCCESS 52
  ------------------
  |  Branch (622:5): [True: 0, False: 46.3k]
  ------------------
  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|      0|        if (session->server) {
  ------------------
  |  Branch (642:13): [True: 0, False: 0]
  ------------------
  643|      0|            rc = SSH_PACKET_DENIED;
  644|      0|            break;
  645|      0|        }
  646|       |
  647|      0|        if (session->dh_handshake_state != DH_STATE_FINISHED) {
  ------------------
  |  Branch (647:13): [True: 0, False: 0]
  ------------------
  648|      0|            rc = SSH_PACKET_DENIED;
  649|      0|            break;
  650|      0|        }
  651|       |
  652|      0|        if (session->session_state != SSH_SESSION_STATE_AUTHENTICATING) {
  ------------------
  |  Branch (652:13): [True: 0, False: 0]
  ------------------
  653|      0|            rc = SSH_PACKET_DENIED;
  654|      0|            break;
  655|      0|        }
  656|       |
  657|      0|        if ((session->auth.state != SSH_AUTH_STATE_KBDINT_SENT) &&
  ------------------
  |  Branch (657:13): [True: 0, False: 0]
  ------------------
  658|      0|            (session->auth.state != SSH_AUTH_STATE_PUBKEY_AUTH_SENT) &&
  ------------------
  |  Branch (658:13): [True: 0, False: 0]
  ------------------
  659|      0|            (session->auth.state != SSH_AUTH_STATE_PASSWORD_AUTH_SENT) &&
  ------------------
  |  Branch (659:13): [True: 0, False: 0]
  ------------------
  660|      0|            (session->auth.state != SSH_AUTH_STATE_GSSAPI_MIC_SENT) &&
  ------------------
  |  Branch (660:13): [True: 0, False: 0]
  ------------------
  661|      0|            (session->auth.state != SSH_AUTH_STATE_GSSAPI_KEYEX_MIC_SENT) &&
  ------------------
  |  Branch (661:13): [True: 0, False: 0]
  ------------------
  662|      0|            (session->auth.state != SSH_AUTH_STATE_AUTH_NONE_SENT)) {
  ------------------
  |  Branch (662:13): [True: 0, False: 0]
  ------------------
  663|      0|            rc = SSH_PACKET_DENIED;
  664|      0|            break;
  665|      0|        }
  666|       |
  667|      0|        rc = SSH_PACKET_ALLOWED;
  668|      0|        break;
  669|      1|    case SSH2_MSG_USERAUTH_BANNER:                    // 53
  ------------------
  |  |   39|      1|#define SSH2_MSG_USERAUTH_BANNER 53
  ------------------
  |  Branch (669:5): [True: 1, False: 46.3k]
  ------------------
  670|       |        /*
  671|       |         * States required:
  672|       |         * - session_state == SSH_SESSION_STATE_AUTHENTICATING
  673|       |         *
  674|       |         * Transitions:
  675|       |         * - None
  676|       |         * */
  677|       |
  678|      1|        if (session->session_state != SSH_SESSION_STATE_AUTHENTICATING) {
  ------------------
  |  Branch (678:13): [True: 1, False: 0]
  ------------------
  679|      1|            rc = SSH_PACKET_DENIED;
  680|      1|            break;
  681|      1|        }
  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: 46.3k]
  ------------------
  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|      1|    case SSH2_MSG_USERAUTH_INFO_RESPONSE:             // 61
  ------------------
  |  |   44|      1|#define SSH2_MSG_USERAUTH_INFO_RESPONSE 61
  ------------------
  |  Branch (725:5): [True: 1, False: 46.3k]
  ------------------
  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|      1|        if (session->session_state != SSH_SESSION_STATE_AUTHENTICATING) {
  ------------------
  |  Branch (739:13): [True: 1, False: 0]
  ------------------
  740|      1|            rc = SSH_PACKET_DENIED;
  741|      1|            break;
  742|      1|        }
  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|      1|    case SSH2_MSG_USERAUTH_GSSAPI_EXCHANGE_COMPLETE:  // 63
  ------------------
  |  |   46|      1|#define SSH2_MSG_USERAUTH_GSSAPI_EXCHANGE_COMPLETE 63
  ------------------
  |  Branch (753:5): [True: 1, False: 46.3k]
  ------------------
  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|      1|        rc = SSH_PACKET_DENIED;
  784|      1|        break;
  785|      0|#endif  /* WITH_GSSAPI */
  786|      6|    case SSH2_MSG_USERAUTH_GSSAPI_ERROR:              // 64
  ------------------
  |  |   47|      6|#define SSH2_MSG_USERAUTH_GSSAPI_ERROR 64
  ------------------
  |  Branch (786:5): [True: 6, False: 46.3k]
  ------------------
  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|      6|        rc = SSH_PACKET_DENIED;
  809|      6|        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: 46.3k]
  ------------------
  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: 46.3k]
  ------------------
  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|      1|    case SSH2_MSG_GLOBAL_REQUEST:                     // 80
  ------------------
  |  |   51|      1|#define SSH2_MSG_GLOBAL_REQUEST 80
  ------------------
  |  Branch (873:5): [True: 1, False: 46.3k]
  ------------------
  874|       |        /*
  875|       |         * States required:
  876|       |         * - session_state == SSH_SESSION_STATE_AUTHENTICATED
  877|       |         *
  878|       |         * Transitions:
  879|       |         * - None
  880|       |         * */
  881|       |
  882|      1|        if (session->session_state != SSH_SESSION_STATE_AUTHENTICATED) {
  ------------------
  |  Branch (882:13): [True: 1, False: 0]
  ------------------
  883|      1|            rc = SSH_PACKET_DENIED;
  884|      1|            break;
  885|      1|        }
  886|       |
  887|      0|        rc = SSH_PACKET_ALLOWED;
  888|      0|        break;
  889|      1|    case SSH2_MSG_REQUEST_SUCCESS:                    // 81
  ------------------
  |  |   52|      1|#define SSH2_MSG_REQUEST_SUCCESS 81
  ------------------
  |  Branch (889:5): [True: 1, False: 46.3k]
  ------------------
  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|      1|        if (session->session_state != SSH_SESSION_STATE_AUTHENTICATED) {
  ------------------
  |  Branch (901:13): [True: 1, False: 0]
  ------------------
  902|      1|            rc = SSH_PACKET_DENIED;
  903|      1|            break;
  904|      1|        }
  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: 46.3k]
  ------------------
  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|      1|    case SSH2_MSG_CHANNEL_OPEN:                       // 90
  ------------------
  |  |   54|      1|#define SSH2_MSG_CHANNEL_OPEN 90
  ------------------
  |  Branch (927:5): [True: 1, False: 46.3k]
  ------------------
  928|       |        /*
  929|       |         * States required:
  930|       |         * - session_state == SSH_SESSION_STATE_AUTHENTICATED
  931|       |         *
  932|       |         * Transitions:
  933|       |         * - None
  934|       |         * */
  935|       |
  936|      1|        if (session->session_state != SSH_SESSION_STATE_AUTHENTICATED) {
  ------------------
  |  Branch (936:13): [True: 1, False: 0]
  ------------------
  937|      1|            rc = SSH_PACKET_DENIED;
  938|      1|            break;
  939|      1|        }
  940|       |
  941|      0|        rc = SSH_PACKET_ALLOWED;
  942|      0|        break;
  943|      1|    case SSH2_MSG_CHANNEL_OPEN_CONFIRMATION:          // 91
  ------------------
  |  |   55|      1|#define SSH2_MSG_CHANNEL_OPEN_CONFIRMATION 91
  ------------------
  |  Branch (943:5): [True: 1, False: 46.3k]
  ------------------
  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|      1|        if (session->session_state != SSH_SESSION_STATE_AUTHENTICATED) {
  ------------------
  |  Branch (953:13): [True: 1, False: 0]
  ------------------
  954|      1|            rc = SSH_PACKET_DENIED;
  955|      1|            break;
  956|      1|        }
  957|       |
  958|      0|        rc = SSH_PACKET_ALLOWED;
  959|      0|        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: 46.3k]
  ------------------
  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|      1|    case SSH2_MSG_CHANNEL_WINDOW_ADJUST:              // 93
  ------------------
  |  |   57|      1|#define SSH2_MSG_CHANNEL_WINDOW_ADJUST 93
  ------------------
  |  Branch (976:5): [True: 1, False: 46.3k]
  ------------------
  977|       |        /*
  978|       |         * States required:
  979|       |         * - session_state == SSH_SESSION_STATE_AUTHENTICATED
  980|       |         *
  981|       |         * Transitions:
  982|       |         * - None
  983|       |         * */
  984|       |
  985|      1|        if (session->session_state != SSH_SESSION_STATE_AUTHENTICATED) {
  ------------------
  |  Branch (985:13): [True: 1, False: 0]
  ------------------
  986|      1|            rc = SSH_PACKET_DENIED;
  987|      1|            break;
  988|      1|        }
  989|       |
  990|      0|        rc = SSH_PACKET_ALLOWED;
  991|      0|        break;
  992|      2|    case SSH2_MSG_CHANNEL_DATA:                       // 94
  ------------------
  |  |   58|      2|#define SSH2_MSG_CHANNEL_DATA 94
  ------------------
  |  Branch (992:5): [True: 2, False: 46.3k]
  ------------------
  993|       |        /*
  994|       |         * States required:
  995|       |         * - session_state == SSH_SESSION_STATE_AUTHENTICATED
  996|       |         *
  997|       |         * Transitions:
  998|       |         * - None
  999|       |         * */
 1000|       |
 1001|      2|        if (session->session_state != SSH_SESSION_STATE_AUTHENTICATED) {
  ------------------
  |  Branch (1001:13): [True: 2, False: 0]
  ------------------
 1002|      2|            rc = SSH_PACKET_DENIED;
 1003|      2|            break;
 1004|      2|        }
 1005|       |
 1006|      0|        rc = SSH_PACKET_ALLOWED;
 1007|      0|        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: 46.3k]
  ------------------
 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|      0|    case SSH2_MSG_CHANNEL_EOF:                        // 96
  ------------------
  |  |   60|      0|#define SSH2_MSG_CHANNEL_EOF	96
  ------------------
  |  Branch (1024:5): [True: 0, False: 46.3k]
  ------------------
 1025|       |        /*
 1026|       |         * States required:
 1027|       |         * - session_state == SSH_SESSION_STATE_AUTHENTICATED
 1028|       |         *
 1029|       |         * Transitions:
 1030|       |         * - None
 1031|       |         * */
 1032|       |
 1033|      0|        if (session->session_state != SSH_SESSION_STATE_AUTHENTICATED) {
  ------------------
  |  Branch (1033:13): [True: 0, False: 0]
  ------------------
 1034|      0|            rc = SSH_PACKET_DENIED;
 1035|      0|            break;
 1036|      0|        }
 1037|       |
 1038|      0|        rc = SSH_PACKET_ALLOWED;
 1039|      0|        break;
 1040|      0|    case SSH2_MSG_CHANNEL_CLOSE:                      // 97
  ------------------
  |  |   61|      0|#define SSH2_MSG_CHANNEL_CLOSE 97
  ------------------
  |  Branch (1040:5): [True: 0, False: 46.3k]
  ------------------
 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|      0|        if (session->session_state != SSH_SESSION_STATE_AUTHENTICATED) {
  ------------------
  |  Branch (1050:13): [True: 0, False: 0]
  ------------------
 1051|      0|            rc = SSH_PACKET_DENIED;
 1052|      0|            break;
 1053|      0|        }
 1054|       |
 1055|      0|        rc = SSH_PACKET_ALLOWED;
 1056|      0|        break;
 1057|      1|    case SSH2_MSG_CHANNEL_REQUEST:                    // 98
  ------------------
  |  |   62|      1|#define SSH2_MSG_CHANNEL_REQUEST 98
  ------------------
  |  Branch (1057:5): [True: 1, False: 46.3k]
  ------------------
 1058|       |        /*
 1059|       |         * States required:
 1060|       |         * - session_state == SSH_SESSION_STATE_AUTHENTICATED
 1061|       |         *
 1062|       |         * Transitions:
 1063|       |         * - Depends on the request
 1064|       |         * */
 1065|       |
 1066|      1|        if (session->session_state != SSH_SESSION_STATE_AUTHENTICATED) {
  ------------------
  |  Branch (1066:13): [True: 1, False: 0]
  ------------------
 1067|      1|            rc = SSH_PACKET_DENIED;
 1068|      1|            break;
 1069|      1|        }
 1070|       |
 1071|      0|        rc = SSH_PACKET_ALLOWED;
 1072|      0|        break;
 1073|      0|    case SSH2_MSG_CHANNEL_SUCCESS:                    // 99
  ------------------
  |  |   63|      0|#define SSH2_MSG_CHANNEL_SUCCESS 99
  ------------------
  |  Branch (1073:5): [True: 0, False: 46.3k]
  ------------------
 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|      0|        if (session->session_state != SSH_SESSION_STATE_AUTHENTICATED) {
  ------------------
  |  Branch (1085:13): [True: 0, False: 0]
  ------------------
 1086|      0|            rc = SSH_PACKET_DENIED;
 1087|      0|            break;
 1088|      0|        }
 1089|       |
 1090|      0|        rc = SSH_PACKET_ALLOWED;
 1091|      0|        break;
 1092|      1|    case SSH2_MSG_CHANNEL_FAILURE:                    // 100
  ------------------
  |  |   64|      1|#define SSH2_MSG_CHANNEL_FAILURE 100
  ------------------
  |  Branch (1092:5): [True: 1, False: 46.3k]
  ------------------
 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|      1|        if (session->session_state != SSH_SESSION_STATE_AUTHENTICATED) {
  ------------------
  |  Branch (1104:13): [True: 1, False: 0]
  ------------------
 1105|      1|            rc = SSH_PACKET_DENIED;
 1106|      1|            break;
 1107|      1|        }
 1108|       |
 1109|      0|        rc = SSH_PACKET_ALLOWED;
 1110|      0|        break;
 1111|     12|    case SSH2_MSG_PING: // 192
  ------------------
  |  |   69|     12|#define SSH2_MSG_PING 192
  ------------------
  |  Branch (1111:5): [True: 12, False: 46.3k]
  ------------------
 1112|     14|    case SSH2_MSG_PONG: // 193
  ------------------
  |  |   70|     14|#define SSH2_MSG_PONG 193
  ------------------
  |  Branch (1112:5): [True: 2, False: 46.3k]
  ------------------
 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|     14|        rc = SSH_PACKET_ALLOWED;
 1128|     14|        break;
 1129|  26.6k|    default:
  ------------------
  |  Branch (1129:5): [True: 26.6k, False: 19.7k]
  ------------------
 1130|       |        /* Unknown message, do not filter */
 1131|  26.6k|        rc = SSH_PACKET_UNKNOWN;
 1132|  26.6k|        goto end;
 1133|  46.3k|    }
 1134|       |
 1135|  46.3k|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|  46.3k|    return rc;
 1149|  46.3k|}
packet.c:ssh_packet_need_rekey:
 1201|  74.5k|{
 1202|  74.5k|    bool data_rekey_needed = false;
 1203|  74.5k|    struct ssh_crypto_struct *crypto = NULL;
 1204|  74.5k|    struct ssh_cipher_struct *out_cipher = NULL, *in_cipher = NULL;
 1205|  74.5k|    uint32_t next_blocks;
 1206|       |
 1207|       |    /* We can safely rekey only in authenticated state */
 1208|  74.5k|    if ((session->flags & SSH_SESSION_FLAG_AUTHENTICATED) == 0) {
  ------------------
  |  |   78|  74.5k|#define SSH_SESSION_FLAG_AUTHENTICATED 0x0002
  ------------------
  |  Branch (1208:9): [True: 74.5k, False: 0]
  ------------------
 1209|  74.5k|        return false;
 1210|  74.5k|    }
 1211|       |
 1212|       |    /* Do not rekey if the rekey/key-exchange is in progress */
 1213|      0|    if (session->dh_handshake_state != DH_STATE_FINISHED) {
  ------------------
  |  Branch (1213:9): [True: 0, False: 0]
  ------------------
 1214|      0|        return false;
 1215|      0|    }
 1216|       |
 1217|      0|    crypto = ssh_packet_get_current_crypto(session, SSH_DIRECTION_BOTH);
 1218|      0|    if (crypto == NULL) {
  ------------------
  |  Branch (1218:9): [True: 0, False: 0]
  ------------------
 1219|      0|        return false;
 1220|      0|    }
 1221|       |
 1222|      0|    out_cipher = crypto->out_cipher;
 1223|      0|    in_cipher = crypto->in_cipher;
 1224|       |
 1225|       |    /* Make sure we can send at least something for very small limits */
 1226|      0|    if ((out_cipher->packets == 0) && (in_cipher->packets == 0)) {
  ------------------
  |  Branch (1226:9): [True: 0, False: 0]
  |  Branch (1226:39): [True: 0, False: 0]
  ------------------
 1227|      0|        return false;
 1228|      0|    }
 1229|       |
 1230|       |    /* Time based rekeying */
 1231|      0|    if (session->opts.rekey_time != 0 &&
  ------------------
  |  Branch (1231:9): [True: 0, False: 0]
  ------------------
 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|      0|    if (out_cipher->packets > MAX_PACKETS ||
  ------------------
  |  | 1197|      0|#define MAX_PACKETS    (1UL<<31)
  ------------------
  |  Branch (1240:9): [True: 0, False: 0]
  ------------------
 1241|      0|        in_cipher->packets > MAX_PACKETS) {
  ------------------
  |  | 1197|      0|#define MAX_PACKETS    (1UL<<31)
  ------------------
  |  Branch (1241:9): [True: 0, False: 0]
  ------------------
 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|      0|    next_blocks = payloadsize / out_cipher->blocksize;
 1251|      0|    data_rekey_needed = (out_cipher->max_blocks != 0 &&
  ------------------
  |  Branch (1251:26): [True: 0, False: 0]
  ------------------
 1252|      0|                         out_cipher->blocks + next_blocks > out_cipher->max_blocks) ||
  ------------------
  |  Branch (1252:26): [True: 0, False: 0]
  ------------------
 1253|      0|                         (in_cipher->max_blocks != 0 &&
  ------------------
  |  Branch (1253:27): [True: 0, False: 0]
  ------------------
 1254|      0|                         in_cipher->blocks + next_blocks > in_cipher->max_blocks);
  ------------------
  |  Branch (1254:26): [True: 0, False: 0]
  ------------------
 1255|       |
 1256|      0|    SSH_LOG(SSH_LOG_PACKET,
  ------------------
  |  |  283|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 1257|      0|            "rekey: [data_rekey_needed=%d, out_blocks=%" PRIu64 ", in_blocks=%" PRIu64 "]",
 1258|      0|            data_rekey_needed,
 1259|      0|            out_cipher->blocks + next_blocks,
 1260|      0|            in_cipher->blocks + next_blocks);
 1261|       |
 1262|      0|    return data_rekey_needed;
 1263|      0|}
packet.c:ssh_packet_socket_controlflow_callback:
 1654|    422|{
 1655|    422|    ssh_session session = userdata;
 1656|    422|    struct ssh_iterator *it = NULL;
 1657|    422|    ssh_channel channel = NULL;
 1658|       |
 1659|    422|    if (code == SSH_SOCKET_FLOW_WRITEWONTBLOCK) {
  ------------------
  |  |  519|    422|#define SSH_SOCKET_FLOW_WRITEWONTBLOCK 2
  ------------------
  |  Branch (1659:9): [True: 422, False: 0]
  ------------------
 1660|    422|        SSH_LOG(SSH_LOG_TRACE, "sending channel_write_wontblock callback");
  ------------------
  |  |  283|    422|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 1661|       |
 1662|       |        /* the out pipe is empty so we can forward this to channels */
 1663|    422|        it = ssh_list_get_iterator(session->channels);
 1664|    422|        while (it != NULL) {
  ------------------
  |  Branch (1664:16): [True: 0, False: 422]
  ------------------
 1665|      0|            channel = ssh_iterator_value(ssh_channel, it);
  ------------------
  |  |  122|      0|  ((type)((iterator)->data))
  ------------------
 1666|       |            ssh_callbacks_execute_list(channel->callbacks,
  ------------------
  |  |  567|      0|    do {                                                      \
  |  |  568|      0|        struct ssh_iterator *i = ssh_list_get_iterator(list); \
  |  |  569|      0|        cbtype cb;                                            \
  |  |  570|      0|        while (i != NULL){                                    \
  |  |  ------------------
  |  |  |  Branch (570:16): [True: 0, False: 0]
  |  |  ------------------
  |  |  571|      0|            cb = ssh_iterator_value(cbtype, i);               \
  |  |  ------------------
  |  |  |  |  122|      0|  ((type)((iterator)->data))
  |  |  ------------------
  |  |  572|      0|            if (ssh_callbacks_exists(cb, c))                  \
  |  |  ------------------
  |  |  |  |  548|      0|#define ssh_callbacks_exists(p,c) (\
  |  |  |  |  549|      0|  (p != NULL) && ( (char *)&((p)-> c) < (char *)(p) + (p)->size ) && \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (549:3): [True: 0, False: 0]
  |  |  |  |  |  Branch (549:18): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  550|      0|  ((p)-> c != NULL) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (550:3): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  551|      0|  )
  |  |  ------------------
  |  |  573|      0|                cb-> c (__VA_ARGS__, cb->userdata);           \
  |  |  574|      0|            i = i->next;                                      \
  |  |  575|      0|        }                                                     \
  |  |  576|      0|    } while(0)
  |  |  ------------------
  |  |  |  Branch (576:13): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1667|      0|                                       ssh_channel_callbacks,
 1668|      0|                                       channel_write_wontblock_function,
 1669|      0|                                       session,
 1670|      0|                                       channel,
 1671|      0|                                       channel->remote_window);
 1672|      0|            it = it->next;
 1673|      0|        }
 1674|    422|    }
 1675|    422|}
packet.c:ssh_packet_in_rekey:
 2056|  28.2k|{
 2057|       |    /* We know we are rekeying if we are authenticated and the DH
 2058|       |     * status is not finished, but we only queue packets until we've
 2059|       |     * sent our NEWKEYS.
 2060|       |     */
 2061|  28.2k|    return (session->flags & SSH_SESSION_FLAG_AUTHENTICATED) &&
  ------------------
  |  |   78|  28.2k|#define SSH_SESSION_FLAG_AUTHENTICATED 0x0002
  ------------------
  |  Branch (2061:12): [True: 0, False: 28.2k]
  ------------------
 2062|      0|           (session->dh_handshake_state != DH_STATE_FINISHED) &&
  ------------------
  |  Branch (2062:12): [True: 0, False: 0]
  ------------------
 2063|      0|           (session->dh_handshake_state != DH_STATE_NEWKEYS_SENT);
  ------------------
  |  Branch (2063:12): [True: 0, False: 0]
  ------------------
 2064|  28.2k|}
packet.c:packet_send2:
 1896|  28.2k|{
 1897|  28.2k|    unsigned int blocksize = 8;
 1898|  28.2k|    unsigned int lenfield_blocksize = 0;
 1899|  28.2k|    enum ssh_hmac_e hmac_type;
 1900|  28.2k|    uint32_t currentlen = ssh_buffer_get_len(session->out_buffer);
 1901|  28.2k|    struct ssh_crypto_struct *crypto = NULL;
 1902|  28.2k|    unsigned char *hmac = NULL;
 1903|  28.2k|    uint8_t padding_data[32] = { 0 };
 1904|  28.2k|    uint8_t padding_size;
 1905|  28.2k|    uint32_t finallen, payloadsize, compsize;
 1906|  28.2k|    uint8_t header[5] = {0};
 1907|  28.2k|    uint8_t type, *payload;
 1908|  28.2k|    int rc = SSH_ERROR;
  ------------------
  |  |  316|  28.2k|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 1909|  28.2k|    bool etm = false;
 1910|  28.2k|    int etm_packet_offset = 0;
 1911|       |
 1912|  28.2k|    crypto = ssh_packet_get_current_crypto(session, SSH_DIRECTION_OUT);
 1913|  28.2k|    if (crypto) {
  ------------------
  |  Branch (1913:9): [True: 1.70k, False: 26.5k]
  ------------------
 1914|  1.70k|        blocksize = crypto->out_cipher->blocksize;
 1915|  1.70k|        lenfield_blocksize = crypto->out_cipher->lenfield_blocksize;
 1916|  1.70k|        hmac_type = crypto->out_hmac;
 1917|  1.70k|        etm = crypto->out_hmac_etm;
 1918|  26.5k|    } else {
 1919|  26.5k|        hmac_type = session->next_crypto->out_hmac;
 1920|  26.5k|    }
 1921|       |
 1922|  28.2k|    payload = (uint8_t *)ssh_buffer_get(session->out_buffer);
 1923|  28.2k|    type = payload[0]; /* type is the first byte of the packet now */
 1924|       |
 1925|  28.2k|    payloadsize = currentlen;
 1926|  28.2k|    if (etm) {
  ------------------
  |  Branch (1926:9): [True: 0, False: 28.2k]
  ------------------
 1927|      0|        etm_packet_offset = sizeof(uint32_t);
 1928|      0|        lenfield_blocksize = 0;
 1929|      0|    }
 1930|       |
 1931|  28.2k|    if (crypto != NULL && crypto->do_compress_out &&
  ------------------
  |  Branch (1931:9): [True: 1.70k, False: 26.5k]
  |  Branch (1931:27): [True: 0, False: 1.70k]
  ------------------
 1932|      0|        ssh_buffer_get_len(session->out_buffer) > 0) {
  ------------------
  |  Branch (1932:9): [True: 0, False: 0]
  ------------------
 1933|      0|        rc = compress_buffer(session,session->out_buffer);
 1934|      0|        if (rc < 0) {
  ------------------
  |  Branch (1934:13): [True: 0, False: 0]
  ------------------
 1935|      0|            goto error;
 1936|      0|        }
 1937|      0|        currentlen = ssh_buffer_get_len(session->out_buffer);
 1938|      0|    }
 1939|  28.2k|    compsize = currentlen;
 1940|       |    /* compressed payload + packet len (4) + padding_size len (1) */
 1941|       |    /* totallen - lenfield_blocksize - etm_packet_offset must be equal to 0 (mod blocksize) */
 1942|  28.2k|    padding_size = (blocksize - ((blocksize - lenfield_blocksize - etm_packet_offset + currentlen + 5) % blocksize));
 1943|  28.2k|    if (padding_size < 4) {
  ------------------
  |  Branch (1943:9): [True: 31, False: 28.1k]
  ------------------
 1944|     31|        padding_size += blocksize;
 1945|     31|    }
 1946|       |
 1947|  28.2k|    if (crypto != NULL) {
  ------------------
  |  Branch (1947:9): [True: 1.70k, False: 26.5k]
  ------------------
 1948|  1.70k|        int ok;
 1949|       |
 1950|  1.70k|        ok = ssh_get_random(padding_data, padding_size, 0);
 1951|  1.70k|        if (!ok) {
  ------------------
  |  Branch (1951:13): [True: 0, False: 1.70k]
  ------------------
 1952|      0|            ssh_set_error(session, SSH_FATAL, "PRNG error");
  ------------------
  |  |  313|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
 1953|      0|            goto error;
 1954|      0|        }
 1955|  1.70k|    }
 1956|       |
 1957|  28.2k|    finallen = currentlen - etm_packet_offset + padding_size + 1;
 1958|       |
 1959|  28.2k|    PUSH_BE_U32(header, 0, finallen);
  ------------------
  |  |   89|  28.2k|    (PUSH_BE_U16((data), (pos), (uint16_t)(((uint32_t)(val)) >> 16)), PUSH_BE_U16((data), (pos) + 2, (uint16_t)((val) & 0xffff)))
  |  |  ------------------
  |  |  |  |   86|  28.2k|    (PUSH_BE_U8((data), (pos), (uint8_t)(((uint16_t)(val)) >> 8)), PUSH_BE_U8((data), (pos) + 1, (uint8_t)((val) & 0xff)))
  |  |  |  |  ------------------
  |  |  |  |  |  |   83|  28.2k|    (_DATA_BYTE(data, pos) = ((uint8_t)(val)))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   31|  28.2k|    (((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|  28.2k|    (_DATA_BYTE(data, pos) = ((uint8_t)(val)))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   31|  28.2k|    (((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|  28.2k|    (PUSH_BE_U8((data), (pos), (uint8_t)(((uint16_t)(val)) >> 8)), PUSH_BE_U8((data), (pos) + 1, (uint8_t)((val) & 0xff)))
  |  |  |  |  ------------------
  |  |  |  |  |  |   83|  28.2k|    (_DATA_BYTE(data, pos) = ((uint8_t)(val)))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   31|  28.2k|    (((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|  28.2k|    (_DATA_BYTE(data, pos) = ((uint8_t)(val)))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   31|  28.2k|    (((uint8_t *)(data))[(pos)])
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1960|  28.2k|    PUSH_BE_U8(header, 4, padding_size);
  ------------------
  |  |   83|  28.2k|    (_DATA_BYTE(data, pos) = ((uint8_t)(val)))
  |  |  ------------------
  |  |  |  |   31|  28.2k|    (((uint8_t *)(data))[(pos)])
  |  |  ------------------
  ------------------
 1961|       |
 1962|  28.2k|    rc = ssh_buffer_prepend_data(session->out_buffer,
 1963|  28.2k|                                 header,
 1964|  28.2k|                                 sizeof(header));
 1965|  28.2k|    if (rc < 0) {
  ------------------
  |  Branch (1965:9): [True: 0, False: 28.2k]
  ------------------
 1966|      0|        goto error;
 1967|      0|    }
 1968|       |
 1969|  28.2k|    rc = ssh_buffer_add_data(session->out_buffer, padding_data, padding_size);
 1970|  28.2k|    if (rc < 0) {
  ------------------
  |  Branch (1970:9): [True: 0, False: 28.2k]
  ------------------
 1971|      0|        goto error;
 1972|      0|    }
 1973|       |
 1974|  28.2k|#ifdef WITH_PCAP
 1975|  28.2k|    if (session->pcap_ctx != NULL) {
  ------------------
  |  Branch (1975:9): [True: 0, False: 28.2k]
  ------------------
 1976|      0|        ssh_pcap_context_write(session->pcap_ctx,
 1977|      0|                               SSH_PCAP_DIR_OUT,
 1978|      0|                               ssh_buffer_get(session->out_buffer),
 1979|      0|                               ssh_buffer_get_len(session->out_buffer),
 1980|      0|                               ssh_buffer_get_len(session->out_buffer));
 1981|      0|    }
 1982|  28.2k|#endif
 1983|       |
 1984|  28.2k|    hmac = ssh_packet_encrypt(session,
 1985|  28.2k|                              ssh_buffer_get(session->out_buffer),
 1986|  28.2k|                              ssh_buffer_get_len(session->out_buffer));
 1987|       |    /* XXX This returns null before switching on crypto, with none MAC
 1988|       |     * and on various errors.
 1989|       |     * We should distinguish between these cases to avoid hiding errors. */
 1990|  28.2k|    if (hmac != NULL) {
  ------------------
  |  Branch (1990:9): [True: 1.70k, False: 26.5k]
  ------------------
 1991|  1.70k|        rc = ssh_buffer_add_data(session->out_buffer,
 1992|  1.70k|                                 hmac,
 1993|  1.70k|                                 (uint32_t)hmac_digest_len(hmac_type));
 1994|  1.70k|        if (rc < 0) {
  ------------------
  |  Branch (1994:13): [True: 0, False: 1.70k]
  ------------------
 1995|      0|            goto error;
 1996|      0|        }
 1997|  1.70k|    }
 1998|       |
 1999|  28.2k|    rc = ssh_packet_write(session);
 2000|  28.2k|    if (rc == SSH_ERROR) {
  ------------------
  |  |  316|  28.2k|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  |  Branch (2000:9): [True: 0, False: 28.2k]
  ------------------
 2001|      0|        goto error;
 2002|      0|    }
 2003|  28.2k|    session->send_seq++;
 2004|  28.2k|    if (crypto != NULL) {
  ------------------
  |  Branch (2004:9): [True: 1.70k, False: 26.5k]
  ------------------
 2005|  1.70k|        struct ssh_cipher_struct *cipher = NULL;
 2006|       |
 2007|  1.70k|        cipher = crypto->out_cipher;
 2008|  1.70k|        cipher->packets++;
 2009|  1.70k|        cipher->blocks += payloadsize / cipher->blocksize;
 2010|  1.70k|    }
 2011|  28.2k|    if (session->raw_counter != NULL) {
  ------------------
  |  Branch (2011:9): [True: 0, False: 28.2k]
  ------------------
 2012|      0|        session->raw_counter->out_bytes += payloadsize;
 2013|      0|        session->raw_counter->out_packets++;
 2014|      0|    }
 2015|       |
 2016|  28.2k|    SSH_LOG(SSH_LOG_PACKET,
  ------------------
  |  |  283|  28.2k|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 2017|  28.2k|            "packet: wrote [type=%u, len=%" PRIu32 ", padding_size=%hhd, comp=%" PRIu32 ", "
 2018|  28.2k|            "payload=%" PRIu32 "]",
 2019|  28.2k|            type,
 2020|  28.2k|            finallen,
 2021|  28.2k|            padding_size,
 2022|  28.2k|            compsize,
 2023|  28.2k|            payloadsize);
 2024|       |
 2025|  28.2k|    rc = ssh_buffer_reinit(session->out_buffer);
 2026|  28.2k|    if (rc < 0) {
  ------------------
  |  Branch (2026:9): [True: 0, False: 28.2k]
  ------------------
 2027|      0|        rc = SSH_ERROR;
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 2028|      0|        goto error;
 2029|      0|    }
 2030|       |
 2031|       |    /* We sent the NEWKEYS so any further packet needs to be encrypted
 2032|       |     * with the new keys. We can not switch both directions (need to decrypt
 2033|       |     * peer NEWKEYS) and we do not want to wait for the peer NEWKEYS
 2034|       |     * too, so we will switch only the OUT direction now.
 2035|       |     */
 2036|  28.2k|    if (type == SSH2_MSG_NEWKEYS) {
  ------------------
  |  |   13|  28.2k|#define SSH2_MSG_NEWKEYS 21
  ------------------
  |  Branch (2036:9): [True: 28, False: 28.1k]
  ------------------
 2037|     28|        rc = ssh_packet_set_newkeys(session, SSH_DIRECTION_OUT);
 2038|     28|    }
 2039|  28.2k|error:
 2040|  28.2k|    return rc; /* SSH_OK, AGAIN or ERROR */
 2041|  28.2k|}
packet.c:ssh_packet_write:
 1885|  28.2k|static int ssh_packet_write(ssh_session session) {
 1886|  28.2k|  int rc = SSH_ERROR;
  ------------------
  |  |  316|  28.2k|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 1887|       |
 1888|  28.2k|  rc=ssh_socket_write(session->socket,
 1889|  28.2k|      ssh_buffer_get(session->out_buffer),
 1890|  28.2k|      ssh_buffer_get_len(session->out_buffer));
 1891|       |
 1892|  28.2k|  return rc;
 1893|  28.2k|}
packet.c:ssh_init_rekey_state:
 2241|     56|{
 2242|       |    /* Reset the counters: should be NOOP */
 2243|     56|    cipher->packets = 0;
 2244|     56|    cipher->blocks = 0;
 2245|       |
 2246|       |    /* Default rekey limits for ciphers as specified in RFC4344, Section 3.2 */
 2247|     56|    if (cipher->blocksize >= 16) {
  ------------------
  |  Branch (2247:9): [True: 0, False: 56]
  ------------------
 2248|       |        /* For larger block size (L bits) use maximum of 2**(L/4) blocks */
 2249|      0|        cipher->max_blocks = (uint64_t)1 << (cipher->blocksize*2);
 2250|     56|    } else {
 2251|       |        /* For smaller blocks use limit of 1 GB as recommended in RFC4253 */
 2252|     56|        cipher->max_blocks = ((uint64_t)1 << 30) / cipher->blocksize;
 2253|     56|    }
 2254|       |    /* If we have limit provided by user, use the smaller one */
 2255|     56|    if (session->opts.rekey_data != 0) {
  ------------------
  |  Branch (2255:9): [True: 0, False: 56]
  ------------------
 2256|      0|        cipher->max_blocks = MIN(cipher->max_blocks,
  ------------------
  |  |  367|      0|#define MIN(a,b) ((a) < (b) ? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (367:19): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 2257|      0|                                 session->opts.rekey_data / cipher->blocksize);
 2258|      0|    }
 2259|       |
 2260|     56|    SSH_LOG(SSH_LOG_DEBUG,
  ------------------
  |  |  283|     56|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 2261|     56|            "Set rekey after %" PRIu64 " blocks",
 2262|     56|            cipher->max_blocks);
 2263|     56|}

ssh_packet_disconnect_callback:
   53|      7|{
   54|      7|    int rc;
   55|      7|    uint32_t code = 0;
   56|      7|    char *error = NULL;
   57|      7|    ssh_string error_s = NULL;
   58|       |
   59|      7|    (void)user;
   60|      7|    (void)type;
   61|       |
   62|      7|    rc = ssh_buffer_get_u32(packet, &code);
   63|      7|    if (rc != 0) {
  ------------------
  |  Branch (63:9): [True: 7, False: 0]
  ------------------
   64|      7|        code = ntohl(code);
   65|      7|    }
   66|       |
   67|      7|    error_s = ssh_buffer_get_ssh_string(packet);
   68|      7|    if (error_s != NULL) {
  ------------------
  |  Branch (68:9): [True: 2, False: 5]
  ------------------
   69|      2|        error = ssh_string_to_char(error_s);
   70|      2|        SSH_STRING_FREE(error_s);
  ------------------
  |  |  882|      2|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (882:14): [True: 2, False: 0]
  |  |  |  Branch (882:69): [Folded, False: 2]
  |  |  ------------------
  ------------------
   71|      2|    }
   72|       |
   73|      7|    if (error != NULL) {
  ------------------
  |  Branch (73:9): [True: 2, False: 5]
  ------------------
   74|      2|        session->peer_discon_msg = strdup(error);
   75|      2|    }
   76|       |
   77|      7|    SSH_LOG(SSH_LOG_PACKET,
  ------------------
  |  |  283|     14|    _ssh_log(priority, __func__, __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (283:34): [True: 2, False: 5]
  |  |  ------------------
  ------------------
   78|      7|            "Received SSH_MSG_DISCONNECT %" PRIu32 ":%s",
   79|      7|            code,
   80|      7|            error != NULL ? error : "no error");
   81|      7|    ssh_set_error(session,
  ------------------
  |  |  313|     14|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (313:43): [True: 2, False: 5]
  |  |  ------------------
  ------------------
   82|      7|                  SSH_FATAL,
   83|      7|                  "Received SSH_MSG_DISCONNECT: %" PRIu32 ":%s",
   84|      7|                  code,
   85|      7|                  error != NULL ? error : "no error");
   86|      7|    SAFE_FREE(error);
  ------------------
  |  |  375|      7|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (375:31): [True: 2, False: 5]
  |  |  |  Branch (375:71): [Folded, False: 7]
  |  |  ------------------
  ------------------
   87|       |
   88|      7|    ssh_session_socket_close(session);
   89|       |    /* correctly handle disconnect during authorization */
   90|      7|    session->auth.state = SSH_AUTH_STATE_FAILED;
   91|       |
   92|       |    /* TODO: handle a graceful disconnect */
   93|      7|    return SSH_PACKET_USED;
  ------------------
  |  |  638|      7|#define SSH_PACKET_USED 1
  ------------------
   94|      7|}
ssh_packet_ignore_callback:
  102|      5|{
  103|      5|    (void)session; /* unused */
  104|      5|    (void)user;
  105|      5|    (void)type;
  106|      5|    (void)packet;
  107|       |
  108|      5|    SSH_LOG(SSH_LOG_DEBUG, "Received SSH_MSG_IGNORE packet");
  ------------------
  |  |  283|      5|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  109|       |
  110|      5|    return SSH_PACKET_USED;
  ------------------
  |  |  638|      5|#define SSH_PACKET_USED 1
  ------------------
  111|      5|}
ssh_packet_debug_callback:
  119|  18.6k|{
  120|  18.6k|    uint8_t always_display = -1;
  121|  18.6k|    char *message = NULL;
  122|  18.6k|    int rc;
  123|       |
  124|  18.6k|    (void)session; /* unused */
  125|  18.6k|    (void)type;
  126|  18.6k|    (void)user;
  127|       |
  128|  18.6k|    rc = ssh_buffer_unpack(packet, "bs", &always_display, &message);
  ------------------
  |  |   60|  18.6k|    _ssh_buffer_unpack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |  453|  18.6k|        (__VA_NARG_(__VA_ARGS__, __RSEQ_N()))
  |  |  |  |  ------------------
  |  |  |  |  |  |  455|  18.6k|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  450|  18.6k|#define VA_APPLY_VARIADIC_MACRO(macro, tuple) macro tuple
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  455|  18.6k|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  463|  18.6k|        _61,_62,_63,N,...) N
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                   _ssh_buffer_unpack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |   28|  18.6k|#define SSH_BUFFER_PACK_END ((uint32_t) 0x4f65feb3)
  |  |  ------------------
  ------------------
  129|  18.6k|    if (rc != SSH_OK) {
  ------------------
  |  |  315|  18.6k|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (129:9): [True: 15.9k, False: 2.74k]
  ------------------
  130|  15.9k|        SSH_LOG(SSH_LOG_PACKET, "Error reading debug message");
  ------------------
  |  |  283|  15.9k|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  131|  15.9k|        return SSH_PACKET_USED;
  ------------------
  |  |  638|  15.9k|#define SSH_PACKET_USED 1
  ------------------
  132|  15.9k|    }
  133|  2.74k|    SSH_LOG(SSH_LOG_DEBUG,
  ------------------
  |  |  283|  5.49k|    _ssh_log(priority, __func__, __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (283:34): [True: 2.74k, False: 2]
  |  |  ------------------
  ------------------
  134|  2.74k|            "Received SSH_MSG_DEBUG packet with message %s%s",
  135|  2.74k|            message,
  136|  2.74k|            always_display != 0 ? " (always display)" : "");
  137|  2.74k|    SAFE_FREE(message);
  ------------------
  |  |  375|  2.74k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (375:31): [True: 2.74k, False: 0]
  |  |  |  Branch (375:71): [Folded, False: 2.74k]
  |  |  ------------------
  ------------------
  138|       |
  139|  2.74k|    return SSH_PACKET_USED;
  ------------------
  |  |  638|  2.74k|#define SSH_PACKET_USED 1
  ------------------
  140|  18.6k|}
ssh_packet_newkeys:
  143|      7|{
  144|      7|    ssh_string sig_blob = NULL;
  145|      7|    ssh_signature sig = NULL;
  146|      7|    int rc;
  147|       |
  148|      7|    (void)packet;
  149|      7|    (void)user;
  150|      7|    (void)type;
  151|       |
  152|      7|    SSH_LOG(SSH_LOG_DEBUG, "Received SSH_MSG_NEWKEYS");
  ------------------
  |  |  283|      7|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  153|       |
  154|      7|    if (session->session_state != SSH_SESSION_STATE_DH ||
  ------------------
  |  Branch (154:9): [True: 0, False: 7]
  ------------------
  155|      7|        session->dh_handshake_state != DH_STATE_NEWKEYS_SENT) {
  ------------------
  |  Branch (155:9): [True: 0, False: 7]
  ------------------
  156|      0|        ssh_set_error(session,
  ------------------
  |  |  313|      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|      7|    if (session->flags & SSH_SESSION_FLAG_KEX_STRICT) {
  ------------------
  |  |   90|      7|#define SSH_SESSION_FLAG_KEX_STRICT 0x0010
  ------------------
  |  Branch (164:9): [True: 1, False: 6]
  ------------------
  165|       |        /* reset packet sequence number when running in strict kex mode */
  166|      1|        session->recv_seq = 0;
  167|       |        /* Check that we aren't tainted */
  168|      1|        if (session->flags & SSH_SESSION_FLAG_KEX_TAINTED) {
  ------------------
  |  |   92|      1|#define SSH_SESSION_FLAG_KEX_TAINTED 0x0020
  ------------------
  |  Branch (168:13): [True: 0, False: 1]
  ------------------
  169|      0|            ssh_set_error(session,
  ------------------
  |  |  313|      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|      1|    }
  175|       |
  176|      7|    if (session->server) {
  ------------------
  |  Branch (176:9): [True: 0, False: 7]
  ------------------
  177|       |        /* server things are done in server.c */
  178|      0|        session->dh_handshake_state=DH_STATE_FINISHED;
  179|      7|    } 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|      7|        {
  218|      7|            ssh_key server_key = NULL;
  219|       |
  220|       |            /* client */
  221|       |
  222|       |            /* Verify the host's signature. FIXME do it sooner */
  223|      7|            sig_blob = session->next_crypto->dh_server_signature;
  224|      7|            session->next_crypto->dh_server_signature = NULL;
  225|       |
  226|       |            /* get the server public key */
  227|      7|            server_key = ssh_dh_get_next_server_publickey(session);
  228|      7|            if (server_key == NULL) {
  ------------------
  |  Branch (228:17): [True: 0, False: 7]
  ------------------
  229|      0|                goto error;
  230|      0|            }
  231|       |
  232|      7|            rc = ssh_pki_import_signature_blob(sig_blob, server_key, &sig);
  233|      7|            ssh_string_burn(sig_blob);
  234|      7|            SSH_STRING_FREE(sig_blob);
  ------------------
  |  |  882|      7|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (882:14): [True: 7, False: 0]
  |  |  |  Branch (882:69): [Folded, False: 7]
  |  |  ------------------
  ------------------
  235|      7|            if (rc != SSH_OK) {
  ------------------
  |  |  315|      7|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (235:17): [True: 4, False: 3]
  ------------------
  236|      4|                goto error;
  237|      4|            }
  238|       |
  239|       |            /* Check if signature from server matches user preferences */
  240|      3|            if (session->opts.wanted_methods[SSH_HOSTKEYS]) {
  ------------------
  |  Branch (240:17): [True: 0, False: 3]
  ------------------
  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(
  ------------------
  |  |  313|      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|      3|            rc = ssh_pki_signature_verify(session,
  256|      3|                                          sig,
  257|      3|                                          server_key,
  258|      3|                                          session->next_crypto->secret_hash,
  259|      3|                                          session->next_crypto->digest_len);
  260|      3|            SSH_SIGNATURE_FREE(sig);
  ------------------
  |  |  161|      3|    do { ssh_signature_free(x); x = NULL; } while(0)
  |  |  ------------------
  |  |  |  Branch (161:51): [Folded, False: 3]
  |  |  ------------------
  ------------------
  261|      3|            if (rc == SSH_ERROR) {
  ------------------
  |  |  316|      3|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  |  Branch (261:17): [True: 3, False: 0]
  ------------------
  262|      3|                ssh_set_error(session,
  ------------------
  |  |  313|      3|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  263|      3|                              SSH_FATAL,
  264|      3|                              "Failed to verify server hostkey signature");
  265|      3|                goto error;
  266|      3|            }
  267|      3|        }
  268|      0|        SSH_LOG(SSH_LOG_DEBUG, "Signature verified and valid");
  ------------------
  |  |  283|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  269|       |
  270|       |        /* When receiving this packet, we switch on the incoming crypto. */
  271|      0|        rc = ssh_packet_set_newkeys(session, SSH_DIRECTION_IN);
  272|      0|        if (rc != SSH_OK) {
  ------------------
  |  |  315|      0|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (272:13): [True: 0, False: 0]
  ------------------
  273|      0|            goto error;
  274|      0|        }
  275|      0|    }
  276|      0|    session->dh_handshake_state = DH_STATE_FINISHED;
  277|      0|    session->ssh_connection_callback(session);
  278|      0|    return SSH_PACKET_USED;
  ------------------
  |  |  638|      0|#define SSH_PACKET_USED 1
  ------------------
  279|       |
  280|      7|error:
  281|       |#ifdef WITH_GSSAPI
  282|       |    SSH_STRING_FREE(session->gssapi_key_exchange_mic);
  283|       |#endif
  284|      7|    SSH_SIGNATURE_FREE(sig);
  ------------------
  |  |  161|      7|    do { ssh_signature_free(x); x = NULL; } while(0)
  |  |  ------------------
  |  |  |  Branch (161:51): [Folded, False: 7]
  |  |  ------------------
  ------------------
  285|      7|    ssh_string_burn(sig_blob);
  286|      7|    SSH_STRING_FREE(sig_blob);
  ------------------
  |  |  882|      7|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (882:14): [True: 0, False: 7]
  |  |  |  Branch (882:69): [Folded, False: 7]
  |  |  ------------------
  ------------------
  287|      7|    session->session_state = SSH_SESSION_STATE_ERROR;
  288|      7|    return SSH_PACKET_USED;
  ------------------
  |  |  638|      7|#define SSH_PACKET_USED 1
  ------------------
  289|      7|}
ssh_packet_ping:
  388|     12|{
  389|     12|    int rc;
  390|     12|    ssh_string payload = NULL;
  391|       |
  392|     12|    (void)type;
  393|     12|    (void)user;
  394|       |
  395|     12|    SSH_LOG(SSH_LOG_PACKET, "Received SSH2_MSG_PING");
  ------------------
  |  |  283|     12|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  396|       |
  397|       |    /* Drop PING before the initial key exchange completes. During rekeying,
  398|       |     * ssh_packet_send() queues the PONG response automatically via out_queue.
  399|       |     */
  400|     12|    if (!(session->flags & SSH_SESSION_FLAG_AUTHENTICATED) &&
  ------------------
  |  |   78|     12|#define SSH_SESSION_FLAG_AUTHENTICATED 0x0002
  ------------------
  |  Branch (400:9): [True: 12, False: 0]
  ------------------
  401|     12|        session->dh_handshake_state != DH_STATE_FINISHED) {
  ------------------
  |  Branch (401:9): [True: 12, False: 0]
  ------------------
  402|     12|        SSH_LOG(SSH_LOG_DEBUG,
  ------------------
  |  |  283|     12|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  403|     12|                "Ignoring PING before initial key exchange is complete");
  404|     12|        return SSH_PACKET_USED;
  ------------------
  |  |  638|     12|#define SSH_PACKET_USED 1
  ------------------
  405|     12|    }
  406|       |
  407|      0|    payload = ssh_buffer_get_ssh_string(packet);
  408|      0|    if (payload == NULL) {
  ------------------
  |  Branch (408:9): [True: 0, False: 0]
  ------------------
  409|      0|        SSH_LOG(SSH_LOG_PACKET, "SSH2_MSG_PING: missing string payload");
  ------------------
  |  |  283|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  410|      0|        ssh_set_error(session,
  ------------------
  |  |  313|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  411|      0|                      SSH_FATAL,
  412|      0|                      "SSH2_MSG_PING: missing string payload");
  413|      0|        session->session_state = SSH_SESSION_STATE_ERROR;
  414|      0|        return SSH_PACKET_USED;
  ------------------
  |  |  638|      0|#define SSH_PACKET_USED 1
  ------------------
  415|      0|    }
  416|       |
  417|      0|    if (ssh_buffer_get_len(packet) != 0) {
  ------------------
  |  Branch (417:9): [True: 0, False: 0]
  ------------------
  418|      0|        SSH_LOG(SSH_LOG_PACKET,
  ------------------
  |  |  283|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  419|      0|                "SSH2_MSG_PING: unexpected trailing data after payload");
  420|      0|        ssh_set_error(session,
  ------------------
  |  |  313|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  421|      0|                      SSH_FATAL,
  422|      0|                      "SSH2_MSG_PING: unexpected trailing data after payload");
  423|      0|        session->session_state = SSH_SESSION_STATE_ERROR;
  424|      0|        SSH_STRING_FREE(payload);
  ------------------
  |  |  882|      0|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (882:14): [True: 0, False: 0]
  |  |  |  Branch (882:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
  425|      0|        return SSH_PACKET_USED;
  ------------------
  |  |  638|      0|#define SSH_PACKET_USED 1
  ------------------
  426|      0|    }
  427|       |
  428|      0|    rc = ssh_buffer_pack(session->out_buffer, "bS", SSH2_MSG_PONG, payload);
  ------------------
  |  |   50|      0|    _ssh_buffer_pack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |  453|      0|        (__VA_NARG_(__VA_ARGS__, __RSEQ_N()))
  |  |  |  |  ------------------
  |  |  |  |  |  |  455|      0|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  450|      0|#define VA_APPLY_VARIADIC_MACRO(macro, tuple) macro tuple
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  455|      0|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  463|      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)
  |  |  ------------------
  ------------------
  429|      0|    SSH_STRING_FREE(payload);
  ------------------
  |  |  882|      0|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (882:14): [True: 0, False: 0]
  |  |  |  Branch (882:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
  430|      0|    if (rc != SSH_OK) {
  ------------------
  |  |  315|      0|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (430:9): [True: 0, False: 0]
  ------------------
  431|      0|        ssh_set_error_oom(session);
  ------------------
  |  |  320|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
  432|      0|        ssh_buffer_reinit(session->out_buffer);
  433|      0|        return SSH_PACKET_USED;
  ------------------
  |  |  638|      0|#define SSH_PACKET_USED 1
  ------------------
  434|      0|    }
  435|       |
  436|      0|    rc = ssh_packet_send(session);
  437|      0|    if (rc != SSH_OK) {
  ------------------
  |  |  315|      0|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (437:9): [True: 0, False: 0]
  ------------------
  438|      0|        SSH_LOG(SSH_LOG_PACKET, "Failed to send SSH2_MSG_PONG");
  ------------------
  |  |  283|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  439|      0|        return SSH_PACKET_USED;
  ------------------
  |  |  638|      0|#define SSH_PACKET_USED 1
  ------------------
  440|      0|    }
  441|       |
  442|      0|    return SSH_PACKET_USED;
  ------------------
  |  |  638|      0|#define SSH_PACKET_USED 1
  ------------------
  443|      0|}
ssh_packet_pong:
  454|      2|{
  455|      2|    const void *payload_data = NULL;
  456|      2|    ssh_string payload = NULL;
  457|      2|    size_t payload_len = 0;
  458|       |
  459|      2|    (void)type;
  460|      2|    (void)user;
  461|       |
  462|      2|    SSH_LOG(SSH_LOG_DEBUG, "Received SSH2_MSG_PONG");
  ------------------
  |  |  283|      2|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  463|       |
  464|      2|    if (session->pending_pings == 0) {
  ------------------
  |  Branch (464:9): [True: 2, False: 0]
  ------------------
  465|      2|        SSH_LOG(SSH_LOG_PACKET, "Received unsolicited SSH2_MSG_PONG");
  ------------------
  |  |  283|      2|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  466|      2|        ssh_set_error(session, SSH_FATAL, "Received unsolicited SSH2_MSG_PONG");
  ------------------
  |  |  313|      2|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  467|      2|        session->session_state = SSH_SESSION_STATE_ERROR;
  468|      2|        return SSH_PACKET_USED;
  ------------------
  |  |  638|      2|#define SSH_PACKET_USED 1
  ------------------
  469|      2|    }
  470|       |
  471|      0|    payload = ssh_buffer_get_ssh_string(packet);
  472|      0|    if (payload == NULL) {
  ------------------
  |  Branch (472:9): [True: 0, False: 0]
  ------------------
  473|      0|        SSH_LOG(SSH_LOG_PACKET, "SSH2_MSG_PONG: missing string payload");
  ------------------
  |  |  283|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  474|      0|        ssh_set_error(session,
  ------------------
  |  |  313|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  475|      0|                      SSH_FATAL,
  476|      0|                      "SSH2_MSG_PONG: missing string payload");
  477|      0|        session->session_state = SSH_SESSION_STATE_ERROR;
  478|      0|        return SSH_PACKET_USED;
  ------------------
  |  |  638|      0|#define SSH_PACKET_USED 1
  ------------------
  479|      0|    }
  480|       |
  481|      0|    if (ssh_buffer_get_len(packet) != 0) {
  ------------------
  |  Branch (481:9): [True: 0, False: 0]
  ------------------
  482|      0|        SSH_LOG(SSH_LOG_PACKET,
  ------------------
  |  |  283|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  483|      0|                "SSH2_MSG_PONG: unexpected trailing data after payload");
  484|      0|        ssh_set_error(session,
  ------------------
  |  |  313|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  485|      0|                      SSH_FATAL,
  486|      0|                      "SSH2_MSG_PONG: unexpected trailing data after payload");
  487|      0|        session->session_state = SSH_SESSION_STATE_ERROR;
  488|      0|        SSH_STRING_FREE(payload);
  ------------------
  |  |  882|      0|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (882:14): [True: 0, False: 0]
  |  |  |  Branch (882:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
  489|      0|        return SSH_PACKET_USED;
  ------------------
  |  |  638|      0|#define SSH_PACKET_USED 1
  ------------------
  490|      0|    }
  491|       |
  492|      0|    payload_data = ssh_string_data(payload);
  493|      0|    payload_len = ssh_string_len(payload);
  494|       |
  495|       |    /* If user provided a high-level PONG callback, decode and invoke it. */
  496|      0|    if (ssh_callbacks_exists(session->common.callbacks, pong_function)) {
  ------------------
  |  |  548|      0|#define ssh_callbacks_exists(p,c) (\
  |  |  549|      0|  (p != NULL) && ( (char *)&((p)-> c) < (char *)(p) + (p)->size ) && \
  |  |  ------------------
  |  |  |  Branch (549:3): [True: 0, False: 0]
  |  |  |  Branch (549:18): [True: 0, False: 0]
  |  |  ------------------
  |  |  550|      0|  ((p)-> c != NULL) \
  |  |  ------------------
  |  |  |  Branch (550:3): [True: 0, False: 0]
  |  |  ------------------
  |  |  551|      0|  )
  ------------------
  497|      0|        session->common.callbacks->pong_function(
  498|      0|            session,
  499|      0|            payload_data,
  500|      0|            payload_len,
  501|      0|            session->common.callbacks->userdata);
  502|      0|    }
  503|       |
  504|      0|    SSH_STRING_FREE(payload);
  ------------------
  |  |  882|      0|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (882:14): [True: 0, False: 0]
  |  |  |  Branch (882:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
  505|      0|    session->pending_pings--;
  506|       |
  507|      0|    return SSH_PACKET_USED;
  ------------------
  |  |  638|      0|#define SSH_PACKET_USED 1
  ------------------
  508|      0|}

ssh_packet_decrypt_len:
   55|  46.4k|{
   56|  46.4k|    struct ssh_crypto_struct *crypto = NULL;
   57|  46.4k|    uint32_t decrypted;
   58|  46.4k|    int rc;
   59|       |
   60|  46.4k|    crypto = ssh_packet_get_current_crypto(session, SSH_DIRECTION_IN);
   61|  46.4k|    if (crypto != NULL) {
  ------------------
  |  Branch (61:9): [True: 0, False: 46.4k]
  ------------------
   62|      0|        if (crypto->in_cipher->aead_decrypt_length != NULL) {
  ------------------
  |  Branch (62:13): [True: 0, False: 0]
  ------------------
   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|      0|        } else {
   68|      0|            rc = ssh_packet_decrypt(
   69|      0|                    session,
   70|      0|                    destination,
   71|      0|                    source,
   72|      0|                    0,
   73|      0|                    crypto->in_cipher->blocksize);
   74|      0|        }
   75|      0|        if (rc < 0) {
  ------------------
  |  Branch (75:13): [True: 0, False: 0]
  ------------------
   76|      0|            return 0;
   77|      0|        }
   78|  46.4k|    } else {
   79|  46.4k|        memcpy(destination, source, 8);
   80|  46.4k|    }
   81|  46.4k|    memcpy(&decrypted,destination,sizeof(decrypted));
   82|       |
   83|       |    return ntohl(decrypted);
   84|  46.4k|}
ssh_packet_encrypt:
  134|  28.2k|{
  135|  28.2k|  struct ssh_crypto_struct *crypto = NULL;
  136|  28.2k|  struct ssh_cipher_struct *cipher = NULL;
  137|  28.2k|  HMACCTX ctx = NULL;
  138|  28.2k|  char *out = NULL;
  139|  28.2k|  int etm_packet_offset = 0, rc;
  140|  28.2k|  unsigned int blocksize;
  141|  28.2k|  size_t finallen = DIGEST_MAX_LEN;
  ------------------
  |  |   56|  28.2k|#define DIGEST_MAX_LEN 64
  ------------------
  142|  28.2k|  uint32_t seq, lenfield_blocksize;
  143|  28.2k|  enum ssh_hmac_e type;
  144|  28.2k|  bool etm;
  145|       |
  146|  28.2k|  assert(len);
  ------------------
  |  Branch (146:3): [True: 0, False: 28.2k]
  |  Branch (146:3): [True: 28.2k, False: 0]
  ------------------
  147|       |
  148|  28.2k|  crypto = ssh_packet_get_current_crypto(session, SSH_DIRECTION_OUT);
  149|  28.2k|  if (crypto == NULL) {
  ------------------
  |  Branch (149:7): [True: 26.5k, False: 1.70k]
  ------------------
  150|  26.5k|      return NULL; /* nothing to do here */
  151|  26.5k|  }
  152|       |
  153|  1.70k|  blocksize = crypto->out_cipher->blocksize;
  154|  1.70k|  lenfield_blocksize = crypto->out_cipher->lenfield_blocksize;
  155|       |
  156|  1.70k|  type = crypto->out_hmac;
  157|  1.70k|  etm = crypto->out_hmac_etm;
  158|       |
  159|  1.70k|  if (etm) {
  ------------------
  |  Branch (159:7): [True: 0, False: 1.70k]
  ------------------
  160|      0|      etm_packet_offset = sizeof(uint32_t);
  161|      0|  }
  162|       |
  163|  1.70k|  if ((len - lenfield_blocksize - etm_packet_offset) % blocksize != 0) {
  ------------------
  |  Branch (163:7): [True: 0, False: 1.70k]
  ------------------
  164|      0|      ssh_set_error(session, SSH_FATAL, "Cryptographic functions must be set"
  ------------------
  |  |  313|      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|  1.70k|  out = calloc(1, len);
  169|  1.70k|  if (out == NULL) {
  ------------------
  |  Branch (169:7): [True: 0, False: 1.70k]
  ------------------
  170|      0|    return NULL;
  171|      0|  }
  172|       |
  173|  1.70k|  seq = ntohl(session->send_seq);
  174|  1.70k|  cipher = crypto->out_cipher;
  175|       |
  176|  1.70k|  if (cipher->aead_encrypt != NULL) {
  ------------------
  |  Branch (176:7): [True: 0, False: 1.70k]
  ------------------
  177|      0|      cipher->aead_encrypt(cipher, data, out, len,
  178|      0|            crypto->hmacbuf, session->send_seq);
  179|      0|      memcpy(data, out, len);
  180|  1.70k|  } else {
  181|  1.70k|      if (type != SSH_HMAC_NONE) {
  ------------------
  |  Branch (181:11): [True: 0, False: 1.70k]
  ------------------
  182|      0|          ctx = hmac_init(crypto->encryptMAC, hmac_digest_len(type), type);
  183|      0|          if (ctx == NULL) {
  ------------------
  |  Branch (183:15): [True: 0, False: 0]
  ------------------
  184|      0|              SAFE_FREE(out);
  ------------------
  |  |  375|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (375:31): [True: 0, False: 0]
  |  |  |  Branch (375:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
  185|      0|              return NULL;
  186|      0|          }
  187|       |
  188|      0|          if (!etm) {
  ------------------
  |  Branch (188:15): [True: 0, False: 0]
  ------------------
  189|      0|              rc = hmac_update(ctx, (unsigned char *)&seq, sizeof(uint32_t));
  190|      0|              if (rc != 1) {
  ------------------
  |  Branch (190:19): [True: 0, False: 0]
  ------------------
  191|      0|                  SAFE_FREE(out);
  ------------------
  |  |  375|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (375:31): [True: 0, False: 0]
  |  |  |  Branch (375:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
  192|      0|                  return NULL;
  193|      0|              }
  194|      0|              rc = hmac_update(ctx, data, len);
  195|      0|              if (rc != 1) {
  ------------------
  |  Branch (195:19): [True: 0, False: 0]
  ------------------
  196|      0|                  SAFE_FREE(out);
  ------------------
  |  |  375|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (375:31): [True: 0, False: 0]
  |  |  |  Branch (375:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
  197|      0|                  return NULL;
  198|      0|              }
  199|      0|              rc = hmac_final(ctx, crypto->hmacbuf, &finallen);
  200|      0|              if (rc != 1) {
  ------------------
  |  Branch (200:19): [True: 0, False: 0]
  ------------------
  201|      0|                  SAFE_FREE(out);
  ------------------
  |  |  375|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (375:31): [True: 0, False: 0]
  |  |  |  Branch (375:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
  202|      0|                  return NULL;
  203|      0|              }
  204|      0|          }
  205|      0|      }
  206|       |
  207|  1.70k|      cipher->encrypt(cipher, (uint8_t*)data + etm_packet_offset, out, len - etm_packet_offset);
  208|  1.70k|      memcpy((uint8_t*)data + etm_packet_offset, out, len - etm_packet_offset);
  209|       |
  210|  1.70k|      if (type != SSH_HMAC_NONE) {
  ------------------
  |  Branch (210:11): [True: 0, False: 1.70k]
  ------------------
  211|      0|          if (etm) {
  ------------------
  |  Branch (211:15): [True: 0, False: 0]
  ------------------
  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);
  ------------------
  |  |  375|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (375:31): [True: 0, False: 0]
  |  |  |  Branch (375: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);
  ------------------
  |  |  375|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (375:31): [True: 0, False: 0]
  |  |  |  Branch (375: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);
  ------------------
  |  |  375|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (375:31): [True: 0, False: 0]
  |  |  |  Branch (375: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|      0|      }
  237|  1.70k|  }
  238|  1.70k|  ssh_burn(out, len);
  ------------------
  |  |  390|  1.70k|#define ssh_burn(ptr, len) explicit_bzero((ptr), (len))
  ------------------
  239|  1.70k|  SAFE_FREE(out);
  ------------------
  |  |  375|  1.70k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (375:31): [True: 1.70k, False: 0]
  |  |  |  Branch (375:71): [Folded, False: 1.70k]
  |  |  ------------------
  ------------------
  240|       |
  241|  1.70k|  return crypto->hmacbuf;
  242|  1.70k|}

ssh_key_new:
  113|     33|{
  114|     33|    ssh_key ptr = malloc (sizeof (struct ssh_key_struct));
  115|     33|    if (ptr == NULL) {
  ------------------
  |  Branch (115:9): [True: 0, False: 33]
  ------------------
  116|      0|        return NULL;
  117|      0|    }
  118|     33|    ZERO_STRUCTP(ptr);
  ------------------
  |  |  381|     33|#define ZERO_STRUCTP(x) do { if ((x) != NULL) memset((x), 0, sizeof(*(x))); } while(0)
  |  |  ------------------
  |  |  |  Branch (381:34): [True: 33, False: 0]
  |  |  |  Branch (381:85): [Folded, False: 33]
  |  |  ------------------
  ------------------
  119|     33|    return ptr;
  120|     33|}
ssh_key_clean:
  222|     33|{
  223|     33|    if (key == NULL)
  ------------------
  |  Branch (223:9): [True: 0, False: 33]
  ------------------
  224|      0|        return;
  225|       |
  226|     33|    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|     33|    if (key->cert != NULL) {
  ------------------
  |  Branch (235:9): [True: 0, False: 33]
  ------------------
  236|      0|        SSH_BUFFER_FREE(key->cert);
  ------------------
  |  |  924|      0|    do { if ((x) != NULL) { ssh_buffer_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (924:14): [True: 0, False: 0]
  |  |  |  Branch (924:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
  237|      0|    }
  238|     33|    if (is_sk_key_type(key->type)) {
  ------------------
  |  |  153|     33|    ((kt) == SSH_KEYTYPE_SK_ECDSA || (kt) == SSH_KEYTYPE_SK_ED25519 || \
  |  |  ------------------
  |  |  |  Branch (153:6): [True: 0, False: 33]
  |  |  |  Branch (153:38): [True: 0, False: 33]
  |  |  ------------------
  |  |  154|     33|     (kt) == SSH_KEYTYPE_SK_ECDSA_CERT01 ||                            \
  |  |  ------------------
  |  |  |  Branch (154:6): [True: 0, False: 33]
  |  |  ------------------
  |  |  155|     33|     (kt) == SSH_KEYTYPE_SK_ED25519_CERT01)
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 0, False: 33]
  |  |  ------------------
  ------------------
  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|     33|    key->cert_type = SSH_KEYTYPE_UNKNOWN;
  250|     33|    key->flags = SSH_KEY_FLAG_EMPTY;
  ------------------
  |  |   53|     33|#define SSH_KEY_FLAG_EMPTY   0x0
  ------------------
  251|     33|    key->type = SSH_KEYTYPE_UNKNOWN;
  252|     33|    key->ecdsa_nid = 0;
  253|       |    key->type_c = NULL;
  254|     33|}
ssh_key_free:
  261|  3.16k|{
  262|  3.16k|    if (key) {
  ------------------
  |  Branch (262:9): [True: 33, False: 3.12k]
  ------------------
  263|     33|        ssh_key_clean(key);
  264|       |        SAFE_FREE(key);
  ------------------
  |  |  375|     33|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (375:31): [True: 33, False: 0]
  |  |  |  Branch (375:71): [Folded, False: 33]
  |  |  ------------------
  ------------------
  265|     33|    }
  266|  3.16k|}
ssh_key_type:
  280|      3|{
  281|      3|    if (key == NULL) {
  ------------------
  |  Branch (281:9): [True: 0, False: 3]
  ------------------
  282|      0|        return SSH_KEYTYPE_UNKNOWN;
  283|      0|    }
  284|      3|    return key->type;
  285|      3|}
ssh_key_signature_to_char:
  367|      3|{
  368|      3|    switch (type) {
  369|      3|    case SSH_KEYTYPE_RSA:
  ------------------
  |  Branch (369:5): [True: 3, False: 0]
  ------------------
  370|      3|        switch (hash_type) {
  371|      1|        case SSH_DIGEST_SHA256:
  ------------------
  |  Branch (371:9): [True: 1, False: 2]
  ------------------
  372|      1|            return "rsa-sha2-256";
  373|      2|        case SSH_DIGEST_SHA512:
  ------------------
  |  Branch (373:9): [True: 2, False: 1]
  ------------------
  374|      2|            return "rsa-sha2-512";
  375|      0|        case SSH_DIGEST_SHA1:
  ------------------
  |  Branch (375:9): [True: 0, False: 3]
  ------------------
  376|      0|        case SSH_DIGEST_AUTO:
  ------------------
  |  Branch (376:9): [True: 0, False: 3]
  ------------------
  377|      0|            return "ssh-rsa";
  378|      0|        default:
  ------------------
  |  Branch (378:9): [True: 0, False: 3]
  ------------------
  379|      0|            return NULL;
  380|      3|        }
  381|      0|        break;
  382|      0|    case SSH_KEYTYPE_RSA_CERT01:
  ------------------
  |  Branch (382:5): [True: 0, False: 3]
  ------------------
  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|      0|    default:
  ------------------
  |  Branch (395:5): [True: 0, False: 3]
  ------------------
  396|      0|        return ssh_key_type_to_char(type);
  397|      3|    }
  398|       |
  399|       |    /* We should never reach this */
  400|      0|    return NULL;
  401|      3|}
ssh_key_type_to_char:
  410|     35|const char *ssh_key_type_to_char(enum ssh_keytypes_e type) {
  411|     35|  switch (type) {
  ------------------
  |  Branch (411:11): [True: 35, False: 0]
  ------------------
  412|     30|    case SSH_KEYTYPE_RSA:
  ------------------
  |  Branch (412:5): [True: 30, False: 5]
  ------------------
  413|     30|      return "ssh-rsa";
  414|      0|    case SSH_KEYTYPE_ECDSA:
  ------------------
  |  Branch (414:5): [True: 0, False: 35]
  ------------------
  415|      0|      return "ssh-ecdsa"; /* deprecated. invalid value */
  416|      2|    case SSH_KEYTYPE_ECDSA_P256:
  ------------------
  |  Branch (416:5): [True: 2, False: 33]
  ------------------
  417|      2|      return "ecdsa-sha2-nistp256";
  418|      1|    case SSH_KEYTYPE_ECDSA_P384:
  ------------------
  |  Branch (418:5): [True: 1, False: 34]
  ------------------
  419|      1|      return "ecdsa-sha2-nistp384";
  420|      0|    case SSH_KEYTYPE_ECDSA_P521:
  ------------------
  |  Branch (420:5): [True: 0, False: 35]
  ------------------
  421|      0|      return "ecdsa-sha2-nistp521";
  422|      0|    case SSH_KEYTYPE_ED25519:
  ------------------
  |  Branch (422:5): [True: 0, False: 35]
  ------------------
  423|      0|      return "ssh-ed25519";
  424|      0|    case SSH_KEYTYPE_RSA_CERT01:
  ------------------
  |  Branch (424:5): [True: 0, False: 35]
  ------------------
  425|      0|      return "ssh-rsa-cert-v01@openssh.com";
  426|      0|    case SSH_KEYTYPE_ECDSA_P256_CERT01:
  ------------------
  |  Branch (426:5): [True: 0, False: 35]
  ------------------
  427|      0|      return "ecdsa-sha2-nistp256-cert-v01@openssh.com";
  428|      2|    case SSH_KEYTYPE_ECDSA_P384_CERT01:
  ------------------
  |  Branch (428:5): [True: 2, False: 33]
  ------------------
  429|      2|      return "ecdsa-sha2-nistp384-cert-v01@openssh.com";
  430|      0|    case SSH_KEYTYPE_ECDSA_P521_CERT01:
  ------------------
  |  Branch (430:5): [True: 0, False: 35]
  ------------------
  431|      0|      return "ecdsa-sha2-nistp521-cert-v01@openssh.com";
  432|      0|    case SSH_KEYTYPE_ED25519_CERT01:
  ------------------
  |  Branch (432:5): [True: 0, False: 35]
  ------------------
  433|      0|      return "ssh-ed25519-cert-v01@openssh.com";
  434|      0|    case SSH_KEYTYPE_SK_ECDSA:
  ------------------
  |  Branch (434:5): [True: 0, False: 35]
  ------------------
  435|      0|      return "sk-ecdsa-sha2-nistp256@openssh.com";
  436|      0|    case SSH_KEYTYPE_SK_ED25519:
  ------------------
  |  Branch (436:5): [True: 0, False: 35]
  ------------------
  437|      0|      return "sk-ssh-ed25519@openssh.com";
  438|      0|    case SSH_KEYTYPE_SK_ECDSA_CERT01:
  ------------------
  |  Branch (438:5): [True: 0, False: 35]
  ------------------
  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: 35]
  ------------------
  441|      0|      return "sk-ssh-ed25519-cert-v01@openssh.com";
  442|      0|    case SSH_KEYTYPE_DSS:   /* deprecated */
  ------------------
  |  Branch (442:5): [True: 0, False: 35]
  ------------------
  443|      0|    case SSH_KEYTYPE_RSA1:
  ------------------
  |  Branch (443:5): [True: 0, False: 35]
  ------------------
  444|      0|    case SSH_KEYTYPE_DSS_CERT01:    /* deprecated */
  ------------------
  |  Branch (444:5): [True: 0, False: 35]
  ------------------
  445|      0|    case SSH_KEYTYPE_UNKNOWN:
  ------------------
  |  Branch (445:5): [True: 0, False: 35]
  ------------------
  446|      0|      return NULL;
  447|     35|  }
  448|       |
  449|       |  /* We should never reach this */
  450|      0|  return NULL;
  451|     35|}
ssh_key_type_and_hash_from_signature_name:
  472|      7|{
  473|      7|    size_t len;
  474|       |
  475|      7|    if (name == NULL || type == NULL || hash_type == NULL) {
  ------------------
  |  Branch (475:9): [True: 0, False: 7]
  |  Branch (475:25): [True: 0, False: 7]
  |  Branch (475:41): [True: 0, False: 7]
  ------------------
  476|      0|        return SSH_ERROR;
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  477|      0|    }
  478|       |
  479|      7|    len = strlen(name);
  480|       |
  481|      7|    if (len == 7 && strcmp(name, "ssh-rsa") == 0) {
  ------------------
  |  Branch (481:9): [True: 0, False: 7]
  |  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;
  ------------------
  |  |  315|      0|#define SSH_OK 0     /* No error */
  ------------------
  485|      0|    }
  486|       |
  487|      7|    if (len == 11 && strcmp(name, "ssh-ed25519") == 0) {
  ------------------
  |  Branch (487:9): [True: 0, False: 7]
  |  Branch (487:22): [True: 0, False: 0]
  ------------------
  488|      0|        *type = SSH_KEYTYPE_ED25519;
  489|      0|        *hash_type = SSH_DIGEST_AUTO;
  490|      0|        return SSH_OK;
  ------------------
  |  |  315|      0|#define SSH_OK 0     /* No error */
  ------------------
  491|      0|    }
  492|       |
  493|      7|    if (len == 12) {
  ------------------
  |  Branch (493:9): [True: 7, False: 0]
  ------------------
  494|      7|        if (strcmp(name, "rsa-sha2-256") == 0) {
  ------------------
  |  Branch (494:13): [True: 1, False: 6]
  ------------------
  495|      1|            *type = SSH_KEYTYPE_RSA;
  496|      1|            *hash_type = SSH_DIGEST_SHA256;
  497|      1|            return SSH_OK;
  ------------------
  |  |  315|      1|#define SSH_OK 0     /* No error */
  ------------------
  498|      1|        }
  499|      6|        if (strcmp(name, "rsa-sha2-512") == 0) {
  ------------------
  |  Branch (499:13): [True: 3, False: 3]
  ------------------
  500|      3|            *type = SSH_KEYTYPE_RSA;
  501|      3|            *hash_type = SSH_DIGEST_SHA512;
  502|      3|            return SSH_OK;
  ------------------
  |  |  315|      3|#define SSH_OK 0     /* No error */
  ------------------
  503|      3|        }
  504|      6|    }
  505|       |
  506|      3|    if (len == 19) {
  ------------------
  |  Branch (506:9): [True: 0, False: 3]
  ------------------
  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;
  ------------------
  |  |  315|      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;
  ------------------
  |  |  315|      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;
  ------------------
  |  |  315|      0|#define SSH_OK 0     /* No error */
  ------------------
  522|      0|        }
  523|      0|    }
  524|       |
  525|      3|    if (len == 26 && strcmp(name, "sk-ssh-ed25519@openssh.com") == 0) {
  ------------------
  |  Branch (525:9): [True: 0, False: 3]
  |  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;
  ------------------
  |  |  315|      0|#define SSH_OK 0     /* No error */
  ------------------
  529|      0|    }
  530|       |
  531|      3|    if (len == 28 && strcmp(name, "ssh-rsa-cert-v01@openssh.com") == 0) {
  ------------------
  |  Branch (531:9): [True: 0, False: 3]
  |  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;
  ------------------
  |  |  315|      0|#define SSH_OK 0     /* No error */
  ------------------
  535|      0|    }
  536|       |
  537|      3|    if (len == 32 && strcmp(name, "ssh-ed25519-cert-v01@openssh.com") == 0) {
  ------------------
  |  Branch (537:9): [True: 0, False: 3]
  |  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;
  ------------------
  |  |  315|      0|#define SSH_OK 0     /* No error */
  ------------------
  541|      0|    }
  542|       |
  543|      3|    if (len == 33) {
  ------------------
  |  Branch (543:9): [True: 0, False: 3]
  ------------------
  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;
  ------------------
  |  |  315|      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;
  ------------------
  |  |  315|      0|#define SSH_OK 0     /* No error */
  ------------------
  553|      0|        }
  554|      0|    }
  555|       |
  556|      3|    if (len == 34 && strcmp(name, "sk-ecdsa-sha2-nistp256@openssh.com") == 0) {
  ------------------
  |  Branch (556:9): [True: 0, False: 3]
  |  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;
  ------------------
  |  |  315|      0|#define SSH_OK 0     /* No error */
  ------------------
  560|      0|    }
  561|       |
  562|      3|    if (len == 40) {
  ------------------
  |  Branch (562:9): [True: 0, False: 3]
  ------------------
  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;
  ------------------
  |  |  315|      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;
  ------------------
  |  |  315|      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;
  ------------------
  |  |  315|      0|#define SSH_OK 0     /* No error */
  ------------------
  577|      0|        }
  578|      0|    }
  579|       |
  580|      3|    SSH_LOG(SSH_LOG_TRACE, "Unknown signature name %s", name);
  ------------------
  |  |  283|      3|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  581|      3|    return SSH_ERROR;
  ------------------
  |  |  316|      3|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  582|      3|}
ssh_key_size_allowed_rsa:
  624|      3|{
  625|      3|    int key_size = ssh_key_size(key);
  626|       |
  627|      3|    if (min_size < RSA_MIN_KEY_SIZE) {
  ------------------
  |  |   49|      3|#define RSA_MIN_KEY_SIZE      1024
  ------------------
  |  Branch (627:9): [True: 3, False: 0]
  ------------------
  628|      3|        if (ssh_fips_mode()) {
  ------------------
  |  |  115|      3|#define ssh_fips_mode() (FIPS_mode() != 0)
  |  |  ------------------
  |  |  |  Branch (115:25): [True: 0, False: 3]
  |  |  ------------------
  ------------------
  629|      0|            min_size = RSA_MIN_FIPS_KEY_SIZE;
  ------------------
  |  |   50|      0|#define RSA_MIN_FIPS_KEY_SIZE 2048
  ------------------
  630|      3|        } else {
  631|      3|            min_size = RSA_MIN_KEY_SIZE;
  ------------------
  |  |   49|      3|#define RSA_MIN_KEY_SIZE      1024
  ------------------
  632|      3|        }
  633|      3|    }
  634|      3|    return (key_size >= min_size);
  635|      3|}
ssh_key_size_allowed:
  646|      3|{
  647|      3|    int min_size = 0;
  648|       |
  649|      3|    switch (ssh_key_type(key)) {
  650|      3|    case SSH_KEYTYPE_RSA:
  ------------------
  |  Branch (650:5): [True: 3, False: 0]
  ------------------
  651|      3|    case SSH_KEYTYPE_RSA_CERT01:
  ------------------
  |  Branch (651:5): [True: 0, False: 3]
  ------------------
  652|      3|        min_size = session->opts.rsa_min_size;
  653|      3|        return ssh_key_size_allowed_rsa(min_size, key);
  654|      0|    default:
  ------------------
  |  Branch (654:5): [True: 0, False: 3]
  ------------------
  655|       |        return true;
  656|      3|    }
  657|      3|}
ssh_key_type_from_name:
  808|    108|{
  809|    108|    if (name == NULL) {
  ------------------
  |  Branch (809:9): [True: 0, False: 108]
  ------------------
  810|      0|        return SSH_KEYTYPE_UNKNOWN;
  811|      0|    }
  812|       |
  813|    108|    if (strcmp(name, "rsa") == 0) {
  ------------------
  |  Branch (813:9): [True: 0, False: 108]
  ------------------
  814|      0|        return SSH_KEYTYPE_RSA;
  815|    108|    } else if (strcmp(name, "ssh-rsa") == 0) {
  ------------------
  |  Branch (815:16): [True: 30, False: 78]
  ------------------
  816|     30|        return SSH_KEYTYPE_RSA;
  817|     78|    } else if (strcmp(name, "ssh-ecdsa") == 0
  ------------------
  |  Branch (817:16): [True: 0, False: 78]
  ------------------
  818|     78|            || strcmp(name, "ecdsa") == 0
  ------------------
  |  Branch (818:16): [True: 1, False: 77]
  ------------------
  819|     77|            || strcmp(name, "ecdsa-sha2-nistp256") == 0) {
  ------------------
  |  Branch (819:16): [True: 1, False: 76]
  ------------------
  820|      2|        return SSH_KEYTYPE_ECDSA_P256;
  821|     76|    } else if (strcmp(name, "ecdsa-sha2-nistp384") == 0) {
  ------------------
  |  Branch (821:16): [True: 0, False: 76]
  ------------------
  822|      0|        return SSH_KEYTYPE_ECDSA_P384;
  823|     76|    } else if (strcmp(name, "ecdsa-sha2-nistp521") == 0) {
  ------------------
  |  Branch (823:16): [True: 0, False: 76]
  ------------------
  824|      0|        return SSH_KEYTYPE_ECDSA_P521;
  825|     76|    } else if (strcmp(name, "ssh-ed25519") == 0){
  ------------------
  |  Branch (825:16): [True: 0, False: 76]
  ------------------
  826|      0|        return SSH_KEYTYPE_ED25519;
  827|     76|    } else if (strcmp(name, "ssh-rsa-cert-v01@openssh.com") == 0) {
  ------------------
  |  Branch (827:16): [True: 0, False: 76]
  ------------------
  828|      0|        return SSH_KEYTYPE_RSA_CERT01;
  829|     76|    } else if (strcmp(name, "ecdsa-sha2-nistp256-cert-v01@openssh.com") == 0) {
  ------------------
  |  Branch (829:16): [True: 0, False: 76]
  ------------------
  830|      0|        return SSH_KEYTYPE_ECDSA_P256_CERT01;
  831|     76|    } else if (strcmp(name, "ecdsa-sha2-nistp384-cert-v01@openssh.com") == 0) {
  ------------------
  |  Branch (831:16): [True: 2, False: 74]
  ------------------
  832|      2|        return SSH_KEYTYPE_ECDSA_P384_CERT01;
  833|     74|    } else if (strcmp(name, "ecdsa-sha2-nistp521-cert-v01@openssh.com") == 0) {
  ------------------
  |  Branch (833:16): [True: 0, False: 74]
  ------------------
  834|      0|        return SSH_KEYTYPE_ECDSA_P521_CERT01;
  835|     74|    } else if (strcmp(name, "ssh-ed25519-cert-v01@openssh.com") == 0) {
  ------------------
  |  Branch (835:16): [True: 0, False: 74]
  ------------------
  836|      0|        return SSH_KEYTYPE_ED25519_CERT01;
  837|     74|    } else if(strcmp(name, "sk-ecdsa-sha2-nistp256@openssh.com") == 0) {
  ------------------
  |  Branch (837:15): [True: 0, False: 74]
  ------------------
  838|      0|        return SSH_KEYTYPE_SK_ECDSA;
  839|     74|    } else if(strcmp(name, "sk-ecdsa-sha2-nistp256-cert-v01@openssh.com") == 0) {
  ------------------
  |  Branch (839:15): [True: 0, False: 74]
  ------------------
  840|      0|        return SSH_KEYTYPE_SK_ECDSA_CERT01;
  841|     74|    } else if(strcmp(name, "sk-ssh-ed25519@openssh.com") == 0) {
  ------------------
  |  Branch (841:15): [True: 0, False: 74]
  ------------------
  842|      0|        return SSH_KEYTYPE_SK_ED25519;
  843|     74|    } else if(strcmp(name, "sk-ssh-ed25519-cert-v01@openssh.com") == 0) {
  ------------------
  |  Branch (843:15): [True: 0, False: 74]
  ------------------
  844|      0|        return SSH_KEYTYPE_SK_ED25519_CERT01;
  845|      0|    }
  846|       |
  847|     74|    return SSH_KEYTYPE_UNKNOWN;
  848|    108|}
ssh_key_type_plain:
  858|      6|{
  859|      6|    switch (type) {
  860|      0|        case SSH_KEYTYPE_RSA_CERT01:
  ------------------
  |  Branch (860:9): [True: 0, False: 6]
  ------------------
  861|      0|            return SSH_KEYTYPE_RSA;
  862|      0|        case SSH_KEYTYPE_ECDSA_P256_CERT01:
  ------------------
  |  Branch (862:9): [True: 0, False: 6]
  ------------------
  863|      0|            return SSH_KEYTYPE_ECDSA_P256;
  864|      0|        case SSH_KEYTYPE_ECDSA_P384_CERT01:
  ------------------
  |  Branch (864:9): [True: 0, False: 6]
  ------------------
  865|      0|            return SSH_KEYTYPE_ECDSA_P384;
  866|      0|        case SSH_KEYTYPE_ECDSA_P521_CERT01:
  ------------------
  |  Branch (866:9): [True: 0, False: 6]
  ------------------
  867|      0|            return SSH_KEYTYPE_ECDSA_P521;
  868|      0|        case SSH_KEYTYPE_ED25519_CERT01:
  ------------------
  |  Branch (868:9): [True: 0, False: 6]
  ------------------
  869|      0|            return SSH_KEYTYPE_ED25519;
  870|      0|        case SSH_KEYTYPE_SK_ECDSA_CERT01:
  ------------------
  |  Branch (870:9): [True: 0, False: 6]
  ------------------
  871|      0|            return SSH_KEYTYPE_SK_ECDSA;
  872|      0|        case SSH_KEYTYPE_SK_ED25519_CERT01:
  ------------------
  |  Branch (872:9): [True: 0, False: 6]
  ------------------
  873|      0|            return SSH_KEYTYPE_SK_ED25519;
  874|      6|        default:
  ------------------
  |  Branch (874:9): [True: 6, False: 0]
  ------------------
  875|      6|            return type;
  876|      6|    }
  877|      6|}
ssh_key_is_private:
  902|      3|int ssh_key_is_private(const ssh_key k) {
  903|      3|    if (k == NULL) {
  ------------------
  |  Branch (903:9): [True: 0, False: 3]
  ------------------
  904|      0|        return 0;
  905|      0|    }
  906|       |
  907|      3|    return (k->flags & SSH_KEY_FLAG_PRIVATE) == SSH_KEY_FLAG_PRIVATE;
  ------------------
  |  |   55|      3|#define SSH_KEY_FLAG_PRIVATE 0x0002
  ------------------
                  return (k->flags & SSH_KEY_FLAG_PRIVATE) == SSH_KEY_FLAG_PRIVATE;
  ------------------
  |  |   55|      3|#define SSH_KEY_FLAG_PRIVATE 0x0002
  ------------------
  908|      3|}
ssh_signature_new:
  997|      3|{
  998|      3|    struct ssh_signature_struct *sig = NULL;
  999|       |
 1000|      3|    sig = calloc(1, sizeof(struct ssh_signature_struct));
 1001|      3|    if (sig == NULL) {
  ------------------
  |  Branch (1001:9): [True: 0, False: 3]
  ------------------
 1002|      0|        return NULL;
 1003|      0|    }
 1004|       |
 1005|      3|    return sig;
 1006|      3|}
ssh_signature_free:
 1009|     10|{
 1010|     10|    if (sig == NULL) {
  ------------------
  |  Branch (1010:9): [True: 7, False: 3]
  ------------------
 1011|      7|        return;
 1012|      7|    }
 1013|       |
 1014|      3|    switch(sig->type) {
  ------------------
  |  Branch (1014:12): [True: 3, False: 0]
  ------------------
 1015|      3|        case SSH_KEYTYPE_RSA:
  ------------------
  |  Branch (1015:9): [True: 3, False: 0]
  ------------------
 1016|       |#ifdef HAVE_LIBMBEDCRYPTO
 1017|       |            SAFE_FREE(sig->rsa_sig);
 1018|       |#endif /* HAVE_LIBMBEDCRYPTO */
 1019|      3|            break;
 1020|      0|        case SSH_KEYTYPE_ECDSA_P256:
  ------------------
  |  Branch (1020:9): [True: 0, False: 3]
  ------------------
 1021|      0|        case SSH_KEYTYPE_ECDSA_P384:
  ------------------
  |  Branch (1021:9): [True: 0, False: 3]
  ------------------
 1022|      0|        case SSH_KEYTYPE_ECDSA_P521:
  ------------------
  |  Branch (1022:9): [True: 0, False: 3]
  ------------------
 1023|      0|        case SSH_KEYTYPE_SK_ECDSA:
  ------------------
  |  Branch (1023:9): [True: 0, False: 3]
  ------------------
 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|      0|        case SSH_KEYTYPE_ED25519:
  ------------------
  |  Branch (1031:9): [True: 0, False: 3]
  ------------------
 1032|      0|        case SSH_KEYTYPE_SK_ED25519:
  ------------------
  |  Branch (1032:9): [True: 0, False: 3]
  ------------------
 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|      0|            break;
 1038|      0|        case SSH_KEYTYPE_DSS:   /* deprecated */
  ------------------
  |  Branch (1038:9): [True: 0, False: 3]
  ------------------
 1039|      0|        case SSH_KEYTYPE_DSS_CERT01:    /* deprecated */
  ------------------
  |  Branch (1039:9): [True: 0, False: 3]
  ------------------
 1040|      0|        case SSH_KEYTYPE_RSA_CERT01:
  ------------------
  |  Branch (1040:9): [True: 0, False: 3]
  ------------------
 1041|      0|        case SSH_KEYTYPE_ECDSA_P256_CERT01:
  ------------------
  |  Branch (1041:9): [True: 0, False: 3]
  ------------------
 1042|      0|        case SSH_KEYTYPE_ECDSA_P384_CERT01:
  ------------------
  |  Branch (1042:9): [True: 0, False: 3]
  ------------------
 1043|      0|        case SSH_KEYTYPE_ECDSA_P521_CERT01:
  ------------------
  |  Branch (1043:9): [True: 0, False: 3]
  ------------------
 1044|      0|        case SSH_KEYTYPE_ED25519_CERT01:
  ------------------
  |  Branch (1044:9): [True: 0, False: 3]
  ------------------
 1045|      0|        case SSH_KEYTYPE_SK_ECDSA_CERT01:
  ------------------
  |  Branch (1045:9): [True: 0, False: 3]
  ------------------
 1046|      0|        case SSH_KEYTYPE_SK_ED25519_CERT01:
  ------------------
  |  Branch (1046:9): [True: 0, False: 3]
  ------------------
 1047|      0|        case SSH_KEYTYPE_RSA1:
  ------------------
  |  Branch (1047:9): [True: 0, False: 3]
  ------------------
 1048|      0|        case SSH_KEYTYPE_ECDSA:
  ------------------
  |  Branch (1048:9): [True: 0, False: 3]
  ------------------
 1049|      0|        case SSH_KEYTYPE_UNKNOWN:
  ------------------
  |  Branch (1049:9): [True: 0, False: 3]
  ------------------
 1050|      0|            break;
 1051|      3|    }
 1052|       |
 1053|       |    /* Explicitly zero the signature content before free */
 1054|      3|    ssh_string_burn(sig->raw_sig);
 1055|      3|    SSH_STRING_FREE(sig->raw_sig);
  ------------------
  |  |  882|      3|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (882:14): [True: 3, False: 0]
  |  |  |  Branch (882:69): [Folded, False: 3]
  |  |  ------------------
  ------------------
 1056|       |    SAFE_FREE(sig);
  ------------------
  |  |  375|      3|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (375:31): [True: 3, False: 0]
  |  |  |  Branch (375:71): [Folded, False: 3]
  |  |  ------------------
  ------------------
 1057|      3|}
ssh_pki_import_pubkey_blob:
 2027|    109|{
 2028|    109|    ssh_buffer buffer = NULL;
 2029|    109|    ssh_string type_s = NULL;
 2030|    109|    enum ssh_keytypes_e type;
 2031|    109|    int rc;
 2032|       |
 2033|    109|    if (key_blob == NULL || pkey == NULL) {
  ------------------
  |  Branch (2033:9): [True: 0, False: 109]
  |  Branch (2033:29): [True: 0, False: 109]
  ------------------
 2034|      0|        return SSH_ERROR;
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 2035|      0|    }
 2036|       |
 2037|    109|    buffer = ssh_buffer_new();
 2038|    109|    if (buffer == NULL) {
  ------------------
  |  Branch (2038:9): [True: 0, False: 109]
  ------------------
 2039|      0|        SSH_LOG(SSH_LOG_TRACE, "Out of memory!");
  ------------------
  |  |  283|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 2040|      0|        return SSH_ERROR;
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 2041|      0|    }
 2042|       |
 2043|    109|    rc = ssh_buffer_add_data(buffer,
 2044|    109|                             ssh_string_data(key_blob),
 2045|    109|                             (uint32_t)ssh_string_len(key_blob));
 2046|    109|    if (rc < 0) {
  ------------------
  |  Branch (2046:9): [True: 0, False: 109]
  ------------------
 2047|      0|        SSH_LOG(SSH_LOG_TRACE, "Out of memory!");
  ------------------
  |  |  283|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 2048|      0|        goto fail;
 2049|      0|    }
 2050|       |
 2051|    109|    type_s = ssh_buffer_get_ssh_string(buffer);
 2052|    109|    if (type_s == NULL) {
  ------------------
  |  Branch (2052:9): [True: 1, False: 108]
  ------------------
 2053|      1|        SSH_LOG(SSH_LOG_TRACE, "Out of memory!");
  ------------------
  |  |  283|      1|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 2054|      1|        goto fail;
 2055|      1|    }
 2056|       |
 2057|    108|    type = ssh_key_type_from_name(ssh_string_get_char(type_s));
 2058|    108|    if (type == SSH_KEYTYPE_UNKNOWN) {
  ------------------
  |  Branch (2058:9): [True: 74, False: 34]
  ------------------
 2059|     74|        SSH_LOG(SSH_LOG_TRACE, "Unknown key type found!");
  ------------------
  |  |  283|     74|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 2060|     74|        goto fail;
 2061|     74|    }
 2062|     34|    SSH_STRING_FREE(type_s);
  ------------------
  |  |  882|     34|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (882:14): [True: 34, False: 0]
  |  |  |  Branch (882:69): [Folded, False: 34]
  |  |  ------------------
  ------------------
 2063|       |
 2064|     34|    if (is_cert_type(type)) {
  ------------------
  |  |  146|     34|    ((kt) == SSH_KEYTYPE_RSA_CERT01 ||\
  |  |  ------------------
  |  |  |  Branch (146:6): [True: 0, False: 34]
  |  |  ------------------
  |  |  147|     34|     (kt) == SSH_KEYTYPE_SK_ECDSA_CERT01 ||\
  |  |  ------------------
  |  |  |  Branch (147:6): [True: 0, False: 34]
  |  |  ------------------
  |  |  148|     34|     (kt) == SSH_KEYTYPE_SK_ED25519_CERT01 ||\
  |  |  ------------------
  |  |  |  Branch (148:6): [True: 0, False: 34]
  |  |  ------------------
  |  |  149|     34|    ((kt) >= SSH_KEYTYPE_ECDSA_P256_CERT01 &&\
  |  |  ------------------
  |  |  |  Branch (149:6): [True: 2, False: 32]
  |  |  ------------------
  |  |  150|     34|     (kt) <= SSH_KEYTYPE_ED25519_CERT01))
  |  |  ------------------
  |  |  |  Branch (150:6): [True: 2, False: 0]
  |  |  ------------------
  ------------------
 2065|      2|        rc = pki_import_cert_buffer(buffer, type, pkey);
 2066|     32|    } else {
 2067|     32|        rc = pki_import_pubkey_buffer(buffer, type, pkey);
 2068|     32|    }
 2069|       |
 2070|     34|    SSH_BUFFER_FREE(buffer);
  ------------------
  |  |  924|     34|    do { if ((x) != NULL) { ssh_buffer_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (924:14): [True: 34, False: 0]
  |  |  |  Branch (924:69): [Folded, False: 34]
  |  |  ------------------
  ------------------
 2071|       |
 2072|     34|    return rc;
 2073|     75|fail:
 2074|     75|    SSH_BUFFER_FREE(buffer);
  ------------------
  |  |  924|     75|    do { if ((x) != NULL) { ssh_buffer_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (924:14): [True: 75, False: 0]
  |  |  |  Branch (924:69): [Folded, False: 75]
  |  |  ------------------
  ------------------
 2075|     75|    SSH_STRING_FREE(type_s);
  ------------------
  |  |  882|     75|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (882:14): [True: 74, False: 1]
  |  |  |  Branch (882:69): [Folded, False: 75]
  |  |  ------------------
  ------------------
 2076|       |
 2077|     75|    return SSH_ERROR;
  ------------------
  |  |  316|     75|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 2078|    108|}
ssh_pki_export_pubkey_blob:
 2666|     28|{
 2667|     28|    ssh_string blob = NULL;
 2668|       |
 2669|     28|    if (key == NULL) {
  ------------------
  |  Branch (2669:9): [True: 0, False: 28]
  ------------------
 2670|      0|        return SSH_OK;
  ------------------
  |  |  315|      0|#define SSH_OK 0     /* No error */
  ------------------
 2671|      0|    }
 2672|       |
 2673|     28|    blob = pki_key_to_blob(key, SSH_KEY_PUBLIC);
 2674|     28|    if (blob == NULL) {
  ------------------
  |  Branch (2674:9): [True: 0, False: 28]
  ------------------
 2675|      0|        return SSH_ERROR;
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 2676|      0|    }
 2677|       |
 2678|     28|    *pblob = blob;
 2679|     28|    return SSH_OK;
  ------------------
  |  |  315|     28|#define SSH_OK 0     /* No error */
  ------------------
 2680|     28|}
ssh_pki_import_signature_blob:
 2947|      7|{
 2948|      7|    ssh_signature sig = NULL;
 2949|      7|    enum ssh_keytypes_e type;
 2950|      7|    enum ssh_digest_e hash_type;
 2951|      7|    ssh_string algorithm = NULL, blob = NULL;
 2952|      7|    ssh_buffer buf = NULL;
 2953|      7|    const char *alg = NULL;
 2954|      7|    uint8_t flags = 0;
 2955|      7|    uint32_t counter = 0;
 2956|      7|    int rc;
 2957|       |
 2958|      7|    if (sig_blob == NULL || psig == NULL) {
  ------------------
  |  Branch (2958:9): [True: 0, False: 7]
  |  Branch (2958:29): [True: 0, False: 7]
  ------------------
 2959|      0|        return SSH_ERROR;
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 2960|      0|    }
 2961|       |
 2962|      7|    buf = ssh_buffer_new();
 2963|      7|    if (buf == NULL) {
  ------------------
  |  Branch (2963:9): [True: 0, False: 7]
  ------------------
 2964|      0|        return SSH_ERROR;
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 2965|      0|    }
 2966|       |
 2967|      7|    rc = ssh_buffer_add_data(buf,
 2968|      7|                             ssh_string_data(sig_blob),
 2969|      7|                             (uint32_t)ssh_string_len(sig_blob));
 2970|      7|    if (rc < 0) {
  ------------------
  |  Branch (2970:9): [True: 0, False: 7]
  ------------------
 2971|      0|        SSH_BUFFER_FREE(buf);
  ------------------
  |  |  924|      0|    do { if ((x) != NULL) { ssh_buffer_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (924:14): [True: 0, False: 0]
  |  |  |  Branch (924:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2972|      0|        return SSH_ERROR;
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 2973|      0|    }
 2974|       |
 2975|      7|    algorithm = ssh_buffer_get_ssh_string(buf);
 2976|      7|    if (algorithm == NULL) {
  ------------------
  |  Branch (2976:9): [True: 0, False: 7]
  ------------------
 2977|      0|        SSH_BUFFER_FREE(buf);
  ------------------
  |  |  924|      0|    do { if ((x) != NULL) { ssh_buffer_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (924:14): [True: 0, False: 0]
  |  |  |  Branch (924:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2978|      0|        return SSH_ERROR;
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 2979|      0|    }
 2980|       |
 2981|      7|    alg = ssh_string_get_char(algorithm);
 2982|      7|    rc = ssh_key_type_and_hash_from_signature_name(alg, &type, &hash_type);
 2983|      7|    if (rc != SSH_OK) {
  ------------------
  |  |  315|      7|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (2983:9): [True: 3, False: 4]
  ------------------
 2984|      3|        SSH_BUFFER_FREE(buf);
  ------------------
  |  |  924|      3|    do { if ((x) != NULL) { ssh_buffer_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (924:14): [True: 3, False: 0]
  |  |  |  Branch (924:69): [Folded, False: 3]
  |  |  ------------------
  ------------------
 2985|      3|        SSH_STRING_FREE(algorithm);
  ------------------
  |  |  882|      3|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (882:14): [True: 3, False: 0]
  |  |  |  Branch (882:69): [Folded, False: 3]
  |  |  ------------------
  ------------------
 2986|      3|        return SSH_ERROR;
  ------------------
  |  |  316|      3|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 2987|      3|    }
 2988|      4|    SSH_STRING_FREE(algorithm);
  ------------------
  |  |  882|      4|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (882:14): [True: 4, False: 0]
  |  |  |  Branch (882:69): [Folded, False: 4]
  |  |  ------------------
  ------------------
 2989|       |
 2990|      4|    blob = ssh_buffer_get_ssh_string(buf);
 2991|      4|    if (blob == NULL) {
  ------------------
  |  Branch (2991:9): [True: 1, False: 3]
  ------------------
 2992|      1|        SSH_BUFFER_FREE(buf);
  ------------------
  |  |  924|      1|    do { if ((x) != NULL) { ssh_buffer_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (924:14): [True: 1, False: 0]
  |  |  |  Branch (924:69): [Folded, False: 1]
  |  |  ------------------
  ------------------
 2993|      1|        return SSH_ERROR;
  ------------------
  |  |  316|      1|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 2994|      1|    }
 2995|       |
 2996|      3|    if (type == SSH_KEYTYPE_SK_ECDSA ||
  ------------------
  |  Branch (2996:9): [True: 0, False: 3]
  ------------------
 2997|      3|        type == SSH_KEYTYPE_SK_ED25519) {
  ------------------
  |  Branch (2997:9): [True: 0, False: 3]
  ------------------
 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)
  |  |  ------------------
  |  |  |  |  453|      0|        (__VA_NARG_(__VA_ARGS__, __RSEQ_N()))
  |  |  |  |  ------------------
  |  |  |  |  |  |  455|      0|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  450|      0|#define VA_APPLY_VARIADIC_MACRO(macro, tuple) macro tuple
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  455|      0|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  463|      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);
  ------------------
  |  |  924|      0|    do { if ((x) != NULL) { ssh_buffer_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (924:14): [True: 0, False: 0]
  |  |  |  Branch (924:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
 3001|      0|            SSH_STRING_FREE(blob);
  ------------------
  |  |  882|      0|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (882:14): [True: 0, False: 0]
  |  |  |  Branch (882:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
 3002|      0|            return SSH_ERROR;
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 3003|      0|        }
 3004|      0|    }
 3005|      3|    SSH_BUFFER_FREE(buf);
  ------------------
  |  |  924|      3|    do { if ((x) != NULL) { ssh_buffer_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (924:14): [True: 3, False: 0]
  |  |  |  Branch (924:69): [Folded, False: 3]
  |  |  ------------------
  ------------------
 3006|       |
 3007|      3|    sig = pki_signature_from_blob(pubkey, blob, type, hash_type);
 3008|      3|    SSH_STRING_FREE(blob);
  ------------------
  |  |  882|      3|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (882:14): [True: 3, False: 0]
  |  |  |  Branch (882:69): [Folded, False: 3]
  |  |  ------------------
  ------------------
 3009|      3|    if (sig == NULL) {
  ------------------
  |  Branch (3009:9): [True: 0, False: 3]
  ------------------
 3010|      0|        return SSH_ERROR;
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 3011|      0|    }
 3012|       |
 3013|       |    /* Set SK specific values */
 3014|      3|    sig->sk_flags = flags;
 3015|      3|    sig->sk_counter = counter;
 3016|       |
 3017|      3|    *psig = sig;
 3018|      3|    return SSH_OK;
  ------------------
  |  |  315|      3|#define SSH_OK 0     /* No error */
  ------------------
 3019|      3|}
pki_key_check_hash_compatible:
 3034|      6|{
 3035|      6|    if (key == NULL) {
  ------------------
  |  Branch (3035:9): [True: 0, False: 6]
  ------------------
 3036|      0|        SSH_LOG(SSH_LOG_TRACE, "Null pointer provided as key to "
  ------------------
  |  |  283|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 3037|      0|                               "pki_key_check_hash_compatible()");
 3038|      0|        return SSH_ERROR;
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 3039|      0|    }
 3040|       |
 3041|      6|    switch(key->type) {
  ------------------
  |  Branch (3041:12): [True: 6, False: 0]
  ------------------
 3042|      0|    case SSH_KEYTYPE_RSA_CERT01:
  ------------------
  |  Branch (3042:5): [True: 0, False: 6]
  ------------------
 3043|      6|    case SSH_KEYTYPE_RSA:
  ------------------
  |  Branch (3043:5): [True: 6, False: 0]
  ------------------
 3044|      6|        if (hash_type == SSH_DIGEST_SHA1) {
  ------------------
  |  Branch (3044:13): [True: 0, False: 6]
  ------------------
 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");
  ------------------
  |  |  283|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 3047|      0|                return SSH_ERROR;
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 3048|      0|            } else {
 3049|      0|                return SSH_OK;
  ------------------
  |  |  315|      0|#define SSH_OK 0     /* No error */
  ------------------
 3050|      0|            }
 3051|      0|        }
 3052|       |
 3053|      6|        if (hash_type == SSH_DIGEST_SHA256 ||
  ------------------
  |  Branch (3053:13): [True: 2, False: 4]
  ------------------
 3054|      4|            hash_type == SSH_DIGEST_SHA512)
  ------------------
  |  Branch (3054:13): [True: 4, False: 0]
  ------------------
 3055|      6|        {
 3056|      6|            return SSH_OK;
  ------------------
  |  |  315|      6|#define SSH_OK 0     /* No error */
  ------------------
 3057|      6|        }
 3058|      0|        break;
 3059|      0|    case SSH_KEYTYPE_ECDSA_P256_CERT01:
  ------------------
  |  Branch (3059:5): [True: 0, False: 6]
  ------------------
 3060|      0|    case SSH_KEYTYPE_ECDSA_P256:
  ------------------
  |  Branch (3060:5): [True: 0, False: 6]
  ------------------
 3061|      0|    case SSH_KEYTYPE_SK_ECDSA_CERT01:
  ------------------
  |  Branch (3061:5): [True: 0, False: 6]
  ------------------
 3062|      0|    case SSH_KEYTYPE_SK_ECDSA:
  ------------------
  |  Branch (3062:5): [True: 0, False: 6]
  ------------------
 3063|      0|        if (hash_type == SSH_DIGEST_SHA256) {
  ------------------
  |  Branch (3063:13): [True: 0, False: 0]
  ------------------
 3064|      0|            return SSH_OK;
  ------------------
  |  |  315|      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: 6]
  ------------------
 3068|      0|    case SSH_KEYTYPE_ECDSA_P384:
  ------------------
  |  Branch (3068:5): [True: 0, False: 6]
  ------------------
 3069|      0|        if (hash_type == SSH_DIGEST_SHA384) {
  ------------------
  |  Branch (3069:13): [True: 0, False: 0]
  ------------------
 3070|      0|            return SSH_OK;
  ------------------
  |  |  315|      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: 6]
  ------------------
 3074|      0|    case SSH_KEYTYPE_ECDSA_P521:
  ------------------
  |  Branch (3074:5): [True: 0, False: 6]
  ------------------
 3075|      0|        if (hash_type == SSH_DIGEST_SHA512) {
  ------------------
  |  Branch (3075:13): [True: 0, False: 0]
  ------------------
 3076|      0|            return SSH_OK;
  ------------------
  |  |  315|      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: 6]
  ------------------
 3080|      0|    case SSH_KEYTYPE_ED25519:
  ------------------
  |  Branch (3080:5): [True: 0, False: 6]
  ------------------
 3081|      0|    case SSH_KEYTYPE_SK_ED25519_CERT01:
  ------------------
  |  Branch (3081:5): [True: 0, False: 6]
  ------------------
 3082|      0|    case SSH_KEYTYPE_SK_ED25519:
  ------------------
  |  Branch (3082:5): [True: 0, False: 6]
  ------------------
 3083|      0|        if (hash_type == SSH_DIGEST_AUTO) {
  ------------------
  |  Branch (3083:13): [True: 0, False: 0]
  ------------------
 3084|      0|            return SSH_OK;
  ------------------
  |  |  315|      0|#define SSH_OK 0     /* No error */
  ------------------
 3085|      0|        }
 3086|      0|        break;
 3087|      0|    case SSH_KEYTYPE_DSS:   /* deprecated */
  ------------------
  |  Branch (3087:5): [True: 0, False: 6]
  ------------------
 3088|      0|    case SSH_KEYTYPE_DSS_CERT01:    /* deprecated */
  ------------------
  |  Branch (3088:5): [True: 0, False: 6]
  ------------------
 3089|      0|    case SSH_KEYTYPE_RSA1:
  ------------------
  |  Branch (3089:5): [True: 0, False: 6]
  ------------------
 3090|      0|    case SSH_KEYTYPE_ECDSA:
  ------------------
  |  Branch (3090:5): [True: 0, False: 6]
  ------------------
 3091|      0|    case SSH_KEYTYPE_UNKNOWN:
  ------------------
  |  Branch (3091:5): [True: 0, False: 6]
  ------------------
 3092|      0|        SSH_LOG(SSH_LOG_TRACE, "Unknown key type %d", key->type);
  ------------------
  |  |  283|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 3093|      0|        return SSH_ERROR;
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 3094|      6|    }
 3095|       |
 3096|      0|    SSH_LOG(SSH_LOG_TRACE, "Key type %d incompatible with hash type  %d",
  ------------------
  |  |  283|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 3097|      0|            key->type, hash_type);
 3098|       |
 3099|      0|    return SSH_ERROR;
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 3100|      6|}
ssh_pki_signature_verify:
 3190|      3|{
 3191|      3|    int rc;
 3192|      3|    bool allowed;
 3193|      3|    enum ssh_keytypes_e key_type;
 3194|       |
 3195|      3|    if (session == NULL || sig == NULL || key == NULL || input == NULL) {
  ------------------
  |  Branch (3195:9): [True: 0, False: 3]
  |  Branch (3195:28): [True: 0, False: 3]
  |  Branch (3195:43): [True: 0, False: 3]
  |  Branch (3195:58): [True: 0, False: 3]
  ------------------
 3196|      0|        SSH_LOG(SSH_LOG_TRACE, "Bad parameter(s) provided to %s()", __func__);
  ------------------
  |  |  283|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 3197|      0|        return SSH_ERROR;
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 3198|      0|    }
 3199|      3|    key_type = ssh_key_type_plain(key->type);
 3200|       |
 3201|      3|    SSH_LOG(SSH_LOG_FUNCTIONS,
  ------------------
  |  |  283|      3|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 3202|      3|            "Going to verify a %s type signature",
 3203|      3|            sig->type_c);
 3204|       |
 3205|      3|    if (key_type != sig->type) {
  ------------------
  |  Branch (3205:9): [True: 0, False: 3]
  ------------------
 3206|      0|        SSH_LOG(SSH_LOG_TRACE,
  ------------------
  |  |  283|      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;
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 3210|      0|    }
 3211|       |
 3212|      3|    allowed = ssh_key_size_allowed(session, key);
 3213|      3|    if (!allowed) {
  ------------------
  |  Branch (3213:9): [True: 0, False: 3]
  ------------------
 3214|      0|        ssh_set_error(session,
  ------------------
  |  |  313|      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;
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 3220|      0|    }
 3221|       |
 3222|       |    /* Check if public key and hash type are compatible */
 3223|      3|    rc = pki_key_check_hash_compatible(key, sig->hash_type);
 3224|      3|    if (rc != SSH_OK) {
  ------------------
  |  |  315|      3|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (3224:9): [True: 0, False: 3]
  ------------------
 3225|      0|        return SSH_ERROR;
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 3226|      0|    }
 3227|       |
 3228|      3|    if (is_sk_key_type(key->type)) {
  ------------------
  |  |  153|      3|    ((kt) == SSH_KEYTYPE_SK_ECDSA || (kt) == SSH_KEYTYPE_SK_ED25519 || \
  |  |  ------------------
  |  |  |  Branch (153:6): [True: 0, False: 3]
  |  |  |  Branch (153:38): [True: 0, False: 3]
  |  |  ------------------
  |  |  154|      3|     (kt) == SSH_KEYTYPE_SK_ECDSA_CERT01 ||                            \
  |  |  ------------------
  |  |  |  Branch (154:6): [True: 0, False: 3]
  |  |  ------------------
  |  |  155|      3|     (kt) == SSH_KEYTYPE_SK_ED25519_CERT01)
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 0, False: 3]
  |  |  ------------------
  ------------------
 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) {
  ------------------
  |  |  315|      0|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (3236:13): [True: 0, False: 0]
  ------------------
 3237|      0|            return SSH_ERROR;
  ------------------
  |  |  316|      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);
  ------------------
  |  |  924|      0|    do { if ((x) != NULL) { ssh_buffer_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (924:14): [True: 0, False: 0]
  |  |  |  Branch (924:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
 3245|      0|        return rc;
 3246|      0|    }
 3247|       |
 3248|      3|    return pki_verify_data_signature(sig, key, input, input_len);
 3249|      3|}
pki.c:pki_import_cert_buffer:
 1877|      2|{
 1878|      2|    ssh_buffer cert = NULL;
 1879|      2|    ssh_string tmp_s = NULL;
 1880|      2|    const char *type_c = NULL;
 1881|      2|    ssh_key key = NULL;
 1882|      2|    int rc;
 1883|       |
 1884|       |    /*
 1885|       |     * The cert blob starts with the key type as an ssh_string, but this
 1886|       |     * string has been read out of the buffer to identify the key type.
 1887|       |     * Simply add it again as first element before copying the rest.
 1888|       |     */
 1889|      2|    cert = ssh_buffer_new();
 1890|      2|    if (cert == NULL) {
  ------------------
  |  Branch (1890:9): [True: 0, False: 2]
  ------------------
 1891|      0|        goto fail;
 1892|      0|    }
 1893|      2|    type_c = ssh_key_type_to_char(type);
 1894|      2|    tmp_s = ssh_string_from_char(type_c);
 1895|      2|    if (tmp_s == NULL) {
  ------------------
  |  Branch (1895:9): [True: 0, False: 2]
  ------------------
 1896|      0|        goto fail;
 1897|      0|    }
 1898|      2|    rc = ssh_buffer_add_ssh_string(cert, tmp_s);
 1899|      2|    SSH_STRING_FREE(tmp_s);
  ------------------
  |  |  882|      2|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (882:14): [True: 2, False: 0]
  |  |  |  Branch (882:69): [Folded, False: 2]
  |  |  ------------------
  ------------------
 1900|      2|    if (rc != 0) {
  ------------------
  |  Branch (1900:9): [True: 0, False: 2]
  ------------------
 1901|      0|        goto fail;
 1902|      0|    }
 1903|      2|    rc = ssh_buffer_add_buffer(cert, buffer);
 1904|      2|    if (rc != 0) {
  ------------------
  |  Branch (1904:9): [True: 0, False: 2]
  ------------------
 1905|      0|        goto fail;
 1906|      0|    }
 1907|       |
 1908|       |    /*
 1909|       |     * After the key type, comes an ssh_string nonce. Just after this comes the
 1910|       |     * cert public key, which can be parsed out of the buffer.
 1911|       |     */
 1912|      2|    tmp_s = ssh_buffer_get_ssh_string(buffer);
 1913|      2|    if (tmp_s == NULL) {
  ------------------
  |  Branch (1913:9): [True: 1, False: 1]
  ------------------
 1914|      1|        goto fail;
 1915|      1|    }
 1916|      1|    SSH_STRING_FREE(tmp_s);
  ------------------
  |  |  882|      1|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (882:14): [True: 1, False: 0]
  |  |  |  Branch (882:69): [Folded, False: 1]
  |  |  ------------------
  ------------------
 1917|       |
 1918|      1|    switch (type) {
 1919|      0|        case SSH_KEYTYPE_RSA_CERT01:
  ------------------
  |  Branch (1919:9): [True: 0, False: 1]
  ------------------
 1920|      0|            rc = pki_import_pubkey_buffer(buffer, SSH_KEYTYPE_RSA, &key);
 1921|      0|            break;
 1922|      0|        case SSH_KEYTYPE_ECDSA_P256_CERT01:
  ------------------
  |  Branch (1922:9): [True: 0, False: 1]
  ------------------
 1923|      0|            rc = pki_import_pubkey_buffer(buffer, SSH_KEYTYPE_ECDSA_P256, &key);
 1924|      0|            break;
 1925|      1|        case SSH_KEYTYPE_ECDSA_P384_CERT01:
  ------------------
  |  Branch (1925:9): [True: 1, False: 0]
  ------------------
 1926|      1|            rc = pki_import_pubkey_buffer(buffer, SSH_KEYTYPE_ECDSA_P384, &key);
 1927|      1|            break;
 1928|      0|        case SSH_KEYTYPE_ECDSA_P521_CERT01:
  ------------------
  |  Branch (1928:9): [True: 0, False: 1]
  ------------------
 1929|      0|            rc = pki_import_pubkey_buffer(buffer, SSH_KEYTYPE_ECDSA_P521, &key);
 1930|      0|            break;
 1931|      0|        case SSH_KEYTYPE_ED25519_CERT01:
  ------------------
  |  Branch (1931:9): [True: 0, False: 1]
  ------------------
 1932|      0|            rc = pki_import_pubkey_buffer(buffer, SSH_KEYTYPE_ED25519, &key);
 1933|      0|            break;
 1934|      0|        case SSH_KEYTYPE_SK_ECDSA_CERT01:
  ------------------
  |  Branch (1934:9): [True: 0, False: 1]
  ------------------
 1935|      0|            rc = pki_import_pubkey_buffer(buffer, SSH_KEYTYPE_SK_ECDSA, &key);
 1936|      0|            break;
 1937|      0|        case SSH_KEYTYPE_SK_ED25519_CERT01:
  ------------------
  |  Branch (1937:9): [True: 0, False: 1]
  ------------------
 1938|      0|            rc = pki_import_pubkey_buffer(buffer, SSH_KEYTYPE_SK_ED25519, &key);
 1939|      0|            break;
 1940|      0|        default:
  ------------------
  |  Branch (1940:9): [True: 0, False: 1]
  ------------------
 1941|      0|            key = ssh_key_new();
 1942|      1|    }
 1943|      1|    if (rc != 0 || key == NULL) {
  ------------------
  |  Branch (1943:9): [True: 1, False: 0]
  |  Branch (1943:20): [True: 0, False: 0]
  ------------------
 1944|      1|        goto fail;
 1945|      1|    }
 1946|       |
 1947|      0|    key->type = type;
 1948|      0|    key->type_c = type_c;
 1949|      0|    key->cert = cert;
 1950|       |
 1951|      0|    *pkey = key;
 1952|      0|    return SSH_OK;
  ------------------
  |  |  315|      0|#define SSH_OK 0     /* No error */
  ------------------
 1953|       |
 1954|      2|fail:
 1955|      2|    ssh_key_free(key);
 1956|      2|    SSH_BUFFER_FREE(cert);
  ------------------
  |  |  924|      2|    do { if ((x) != NULL) { ssh_buffer_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (924:14): [True: 2, False: 0]
  |  |  |  Branch (924:69): [Folded, False: 2]
  |  |  ------------------
  ------------------
 1957|      2|    return SSH_ERROR;
  ------------------
  |  |  316|      2|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 1958|      1|}
pki.c:pki_import_pubkey_buffer:
 1736|     33|{
 1737|     33|    ssh_key key = NULL;
 1738|     33|    int rc;
 1739|       |
 1740|     33|    key = ssh_key_new();
 1741|     33|    if (key == NULL) {
  ------------------
  |  Branch (1741:9): [True: 0, False: 33]
  ------------------
 1742|      0|        return SSH_ERROR;
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 1743|      0|    }
 1744|       |
 1745|     33|    key->type = type;
 1746|     33|    key->type_c = ssh_key_type_to_char(type);
 1747|     33|    key->flags = SSH_KEY_FLAG_PUBLIC;
  ------------------
  |  |   54|     33|#define SSH_KEY_FLAG_PUBLIC  0x0001
  ------------------
 1748|       |
 1749|     33|    switch (type) {
 1750|     30|        case SSH_KEYTYPE_RSA:
  ------------------
  |  Branch (1750:9): [True: 30, False: 3]
  ------------------
 1751|     30|            {
 1752|     30|                ssh_string e = NULL;
 1753|     30|                ssh_string n = NULL;
 1754|       |
 1755|     30|                rc = ssh_buffer_unpack(buffer, "SS", &e, &n);
  ------------------
  |  |   60|     30|    _ssh_buffer_unpack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |  453|     30|        (__VA_NARG_(__VA_ARGS__, __RSEQ_N()))
  |  |  |  |  ------------------
  |  |  |  |  |  |  455|     30|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  450|     30|#define VA_APPLY_VARIADIC_MACRO(macro, tuple) macro tuple
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  455|     30|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  463|     30|        _61,_62,_63,N,...) N
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                   _ssh_buffer_unpack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |   28|     30|#define SSH_BUFFER_PACK_END ((uint32_t) 0x4f65feb3)
  |  |  ------------------
  ------------------
 1756|     30|                if (rc != SSH_OK) {
  ------------------
  |  |  315|     30|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (1756:21): [True: 0, False: 30]
  ------------------
 1757|      0|                    SSH_LOG(SSH_LOG_TRACE, "Unpack error");
  ------------------
  |  |  283|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 1758|      0|                    goto fail;
 1759|      0|                }
 1760|       |
 1761|     30|                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|     30|                ssh_string_burn(e);
 1767|     30|                SSH_STRING_FREE(e);
  ------------------
  |  |  882|     30|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (882:14): [True: 30, False: 0]
  |  |  |  Branch (882:69): [Folded, False: 30]
  |  |  ------------------
  ------------------
 1768|     30|                ssh_string_burn(n);
 1769|     30|                SSH_STRING_FREE(n);
  ------------------
  |  |  882|     30|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (882:14): [True: 30, False: 0]
  |  |  |  Branch (882:69): [Folded, False: 30]
  |  |  ------------------
  ------------------
 1770|     30|                if (rc == SSH_ERROR) {
  ------------------
  |  |  316|     30|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  |  Branch (1770:21): [True: 0, False: 30]
  ------------------
 1771|      0|                    SSH_LOG(SSH_LOG_TRACE, "Failed to build RSA public key");
  ------------------
  |  |  283|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 1772|      0|                    goto fail;
 1773|      0|                }
 1774|     30|            }
 1775|     30|            break;
 1776|     30|#ifdef HAVE_ECC
 1777|     30|        case SSH_KEYTYPE_ECDSA: /* deprecated */
  ------------------
  |  Branch (1777:9): [True: 0, False: 33]
  ------------------
 1778|      2|        case SSH_KEYTYPE_ECDSA_P256:
  ------------------
  |  Branch (1778:9): [True: 2, False: 31]
  ------------------
 1779|      3|        case SSH_KEYTYPE_ECDSA_P384:
  ------------------
  |  Branch (1779:9): [True: 1, False: 32]
  ------------------
 1780|      3|        case SSH_KEYTYPE_ECDSA_P521:
  ------------------
  |  Branch (1780:9): [True: 0, False: 33]
  ------------------
 1781|      3|        case SSH_KEYTYPE_SK_ECDSA:
  ------------------
  |  Branch (1781:9): [True: 0, False: 33]
  ------------------
 1782|      3|            {
 1783|      3|                ssh_string e = NULL;
 1784|      3|                ssh_string i = NULL;
 1785|      3|                int nid;
 1786|       |
 1787|      3|                rc = ssh_buffer_unpack(buffer, "SS", &i, &e);
  ------------------
  |  |   60|      3|    _ssh_buffer_unpack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |  453|      3|        (__VA_NARG_(__VA_ARGS__, __RSEQ_N()))
  |  |  |  |  ------------------
  |  |  |  |  |  |  455|      3|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  450|      3|#define VA_APPLY_VARIADIC_MACRO(macro, tuple) macro tuple
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  455|      3|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  463|      3|        _61,_62,_63,N,...) N
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                   _ssh_buffer_unpack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |   28|      3|#define SSH_BUFFER_PACK_END ((uint32_t) 0x4f65feb3)
  |  |  ------------------
  ------------------
 1788|      3|                if (rc != SSH_OK) {
  ------------------
  |  |  315|      3|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (1788:21): [True: 3, False: 0]
  ------------------
 1789|      3|                    SSH_LOG(SSH_LOG_TRACE, "Unpack error");
  ------------------
  |  |  283|      3|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 1790|      3|                    goto fail;
 1791|      3|                }
 1792|       |
 1793|      0|                nid = pki_key_ecdsa_nid_from_name(ssh_string_get_char(i));
 1794|      0|                SSH_STRING_FREE(i);
  ------------------
  |  |  882|      0|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (882:14): [True: 0, False: 0]
  |  |  |  Branch (882: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);
  ------------------
  |  |  882|      0|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (882:14): [True: 0, False: 0]
  |  |  |  Branch (882: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);
  ------------------
  |  |  882|      0|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (882:14): [True: 0, False: 0]
  |  |  |  Branch (882: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");
  ------------------
  |  |  283|      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");
  ------------------
  |  |  283|      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|      0|        case SSH_KEYTYPE_ED25519:
  ------------------
  |  Branch (1822:9): [True: 0, False: 33]
  ------------------
 1823|      0|        case SSH_KEYTYPE_SK_ED25519:
  ------------------
  |  Branch (1823:9): [True: 0, False: 33]
  ------------------
 1824|      0|        {
 1825|      0|            ssh_string pubkey = ssh_buffer_get_ssh_string(buffer);
 1826|       |
 1827|      0|            if (ssh_string_len(pubkey) != ED25519_KEY_LEN) {
  ------------------
  |  |   44|      0|#define ED25519_KEY_LEN 32
  ------------------
  |  Branch (1827:17): [True: 0, False: 0]
  ------------------
 1828|      0|                SSH_LOG(SSH_LOG_TRACE, "Invalid public key length");
  ------------------
  |  |  283|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 1829|      0|                ssh_string_burn(pubkey);
 1830|      0|                SSH_STRING_FREE(pubkey);
  ------------------
  |  |  882|      0|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (882:14): [True: 0, False: 0]
  |  |  |  Branch (882:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1831|      0|                goto fail;
 1832|      0|            }
 1833|       |
 1834|      0|            rc = pki_pubkey_build_ed25519(key, pubkey);
 1835|      0|            ssh_string_burn(pubkey);
 1836|      0|            SSH_STRING_FREE(pubkey);
  ------------------
  |  |  882|      0|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (882:14): [True: 0, False: 0]
  |  |  |  Branch (882:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1837|      0|            if (rc < 0) {
  ------------------
  |  Branch (1837:17): [True: 0, False: 0]
  ------------------
 1838|      0|                SSH_LOG(SSH_LOG_TRACE, "Failed to build ED25519 public key");
  ------------------
  |  |  283|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 1839|      0|                goto fail;
 1840|      0|            }
 1841|       |
 1842|      0|            if (type == SSH_KEYTYPE_SK_ED25519) {
  ------------------
  |  Branch (1842:17): [True: 0, False: 0]
  ------------------
 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");
  ------------------
  |  |  283|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 1846|      0|                    goto fail;
 1847|      0|                }
 1848|      0|                key->sk_application = application;
 1849|      0|            }
 1850|      0|        }
 1851|      0|        break;
 1852|      0|        case SSH_KEYTYPE_RSA_CERT01:
  ------------------
  |  Branch (1852:9): [True: 0, False: 33]
  ------------------
 1853|      0|        case SSH_KEYTYPE_ECDSA_P256_CERT01:
  ------------------
  |  Branch (1853:9): [True: 0, False: 33]
  ------------------
 1854|      0|        case SSH_KEYTYPE_ECDSA_P384_CERT01:
  ------------------
  |  Branch (1854:9): [True: 0, False: 33]
  ------------------
 1855|      0|        case SSH_KEYTYPE_ECDSA_P521_CERT01:
  ------------------
  |  Branch (1855:9): [True: 0, False: 33]
  ------------------
 1856|      0|        case SSH_KEYTYPE_SK_ECDSA_CERT01:
  ------------------
  |  Branch (1856:9): [True: 0, False: 33]
  ------------------
 1857|      0|        case SSH_KEYTYPE_ED25519_CERT01:
  ------------------
  |  Branch (1857:9): [True: 0, False: 33]
  ------------------
 1858|      0|        case SSH_KEYTYPE_SK_ED25519_CERT01:
  ------------------
  |  Branch (1858:9): [True: 0, False: 33]
  ------------------
 1859|      0|        case SSH_KEYTYPE_RSA1:
  ------------------
  |  Branch (1859:9): [True: 0, False: 33]
  ------------------
 1860|      0|        case SSH_KEYTYPE_UNKNOWN:
  ------------------
  |  Branch (1860:9): [True: 0, False: 33]
  ------------------
 1861|      0|        default:
  ------------------
  |  Branch (1861:9): [True: 0, False: 33]
  ------------------
 1862|      0|            SSH_LOG(SSH_LOG_TRACE, "Unknown public key type %d", type);
  ------------------
  |  |  283|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 1863|      0|            goto fail;
 1864|     33|    }
 1865|       |
 1866|     30|    *pkey = key;
 1867|     30|    return SSH_OK;
  ------------------
  |  |  315|     30|#define SSH_OK 0     /* No error */
  ------------------
 1868|      3|fail:
 1869|      3|    ssh_key_free(key);
 1870|       |
 1871|      3|    return SSH_ERROR;
  ------------------
  |  |  316|      3|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 1872|     33|}

ssh_pki_ctx_new:
   49|    473|{
   50|    473|    struct ssh_pki_ctx_struct *ctx = NULL;
   51|       |
   52|    473|    ctx = calloc(1, sizeof(struct ssh_pki_ctx_struct));
   53|    473|    if (ctx == NULL) {
  ------------------
  |  Branch (53:9): [True: 0, False: 473]
  ------------------
   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|    473|    return ctx;
   77|    473|}
ssh_pki_ctx_free:
   86|    473|{
   87|    473|    if (context == NULL) {
  ------------------
  |  Branch (87:9): [True: 0, False: 473]
  ------------------
   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|    473|    SAFE_FREE(context);
  ------------------
  |  |  375|    473|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (375:31): [True: 473, False: 0]
  |  |  |  Branch (375:71): [Folded, False: 473]
  |  |  ------------------
  ------------------
   99|    473|}

pki_key_clean:
   96|     33|{
   97|     33|    if (key == NULL)
  ------------------
  |  Branch (97:9): [True: 0, False: 33]
  ------------------
   98|      0|        return;
   99|     33|    EVP_PKEY_free(key->key);
  100|       |    key->key = NULL;
  101|     33|}
pki_pubkey_build_rsa:
 1415|     30|                         ssh_string n) {
 1416|     30|    int rc;
 1417|     30|    BIGNUM *be = NULL, *bn = NULL;
 1418|       |#if OPENSSL_VERSION_NUMBER >= 0x30000000L
 1419|       |    OSSL_PARAM_BLD *param_bld = OSSL_PARAM_BLD_new();
 1420|       |    if (param_bld == NULL) {
 1421|       |        return SSH_ERROR;
 1422|       |    }
 1423|       |#else
 1424|     30|    RSA *key_rsa = RSA_new();
 1425|     30|    if (key_rsa == NULL) {
  ------------------
  |  Branch (1425:9): [True: 0, False: 30]
  ------------------
 1426|      0|        return SSH_ERROR;
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 1427|      0|    }
 1428|     30|#endif /* OPENSSL_VERSION_NUMBER */
 1429|       |
 1430|     30|    be = ssh_make_string_bn(e);
 1431|     30|    if (be == NULL) {
  ------------------
  |  Branch (1431:9): [True: 0, False: 30]
  ------------------
 1432|      0|        rc = SSH_ERROR;
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 1433|      0|        goto fail;
 1434|      0|    }
 1435|     30|    bn = ssh_make_string_bn(n);
 1436|     30|    if (bn == NULL) {
  ------------------
  |  Branch (1436:9): [True: 0, False: 30]
  ------------------
 1437|      0|        rc = SSH_ERROR;
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 1438|      0|        goto fail;
 1439|      0|    }
 1440|       |
 1441|     30|#if OPENSSL_VERSION_NUMBER < 0x30000000L
 1442|     30|    rc = RSA_set0_key(key_rsa, bn, be, NULL);
 1443|     30|    if (rc == 0) {
  ------------------
  |  Branch (1443:9): [True: 0, False: 30]
  ------------------
 1444|      0|        goto fail;
 1445|      0|    }
 1446|       |    /* Memory management of bn and be is transferred to RSA object */
 1447|     30|    bn = NULL;
 1448|     30|    be = NULL;
 1449|       |
 1450|     30|    key->key = EVP_PKEY_new();
 1451|     30|    if (key->key == NULL) {
  ------------------
  |  Branch (1451:9): [True: 0, False: 30]
  ------------------
 1452|      0|        goto fail;
 1453|      0|    }
 1454|       |
 1455|     30|    rc = EVP_PKEY_assign_RSA(key->key, key_rsa);
 1456|     30|    if (rc != 1) {
  ------------------
  |  Branch (1456:9): [True: 0, False: 30]
  ------------------
 1457|      0|        goto fail;
 1458|      0|    }
 1459|       |
 1460|     30|    return SSH_OK;
  ------------------
  |  |  315|     30|#define SSH_OK 0     /* No error */
  ------------------
 1461|       |#else
 1462|       |    rc = OSSL_PARAM_BLD_push_BN(param_bld, OSSL_PKEY_PARAM_RSA_N, bn);
 1463|       |    if (rc != 1) {
 1464|       |        rc = SSH_ERROR;
 1465|       |        goto fail;
 1466|       |    }
 1467|       |    rc = OSSL_PARAM_BLD_push_BN(param_bld, OSSL_PKEY_PARAM_RSA_E, be);
 1468|       |    if (rc != 1) {
 1469|       |        rc = SSH_ERROR;
 1470|       |        goto fail;
 1471|       |    }
 1472|       |
 1473|       |    rc = evp_build_pkey("RSA", param_bld, &(key->key), EVP_PKEY_PUBLIC_KEY);
 1474|       |#endif /* OPENSSL_VERSION_NUMBER */
 1475|       |
 1476|      0|fail:
 1477|      0|    bignum_safe_free(bn);
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
 1478|      0|    bignum_safe_free(be);
  ------------------
  |  |   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]
  |  |  ------------------
  ------------------
 1479|      0|#if OPENSSL_VERSION_NUMBER < 0x30000000L
 1480|      0|    RSA_free(key_rsa);
 1481|       |
 1482|      0|    return SSH_ERROR;
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 1483|       |#else
 1484|       |    OSSL_PARAM_BLD_free(param_bld);
 1485|       |
 1486|       |    return rc;
 1487|       |#endif /* OPENSSL_VERSION_NUMBER */
 1488|     30|}
pki_key_to_blob:
 1491|     28|{
 1492|     28|    ssh_buffer buffer = NULL;
 1493|     28|    ssh_string type_s = NULL;
 1494|     28|    ssh_string str = NULL;
 1495|     28|    ssh_string e = NULL;
 1496|     28|    ssh_string n = NULL;
 1497|     28|    ssh_string p = NULL;
 1498|     28|    ssh_string g = NULL;
 1499|     28|    ssh_string q = NULL;
 1500|     28|    ssh_string d = NULL;
 1501|     28|    ssh_string iqmp = NULL;
 1502|     28|    int rc;
 1503|       |#if OPENSSL_VERSION_NUMBER >= 0x30000000L
 1504|       |    BIGNUM *bp = NULL, *bq = NULL, *bg = NULL, *bpub_key = NULL,
 1505|       |           *bn = NULL, *be = NULL,
 1506|       |           *bd = NULL, *biqmp = NULL;
 1507|       |    OSSL_PARAM *params = NULL;
 1508|       |#endif /* OPENSSL_VERSION_NUMBER */
 1509|     28|    uint8_t *ed25519_pubkey = NULL;
 1510|     28|    uint8_t *ed25519_privkey = NULL;
 1511|     28|    size_t key_len = 0;
 1512|       |
 1513|     28|    buffer = ssh_buffer_new();
 1514|     28|    if (buffer == NULL) {
  ------------------
  |  Branch (1514:9): [True: 0, False: 28]
  ------------------
 1515|      0|        return NULL;
 1516|      0|    }
 1517|       |    /* The buffer will contain sensitive information. Make sure it is erased */
 1518|     28|    ssh_buffer_set_secure(buffer);
 1519|       |
 1520|     28|    if (key->cert != NULL) {
  ------------------
  |  Branch (1520:9): [True: 0, False: 28]
  ------------------
 1521|      0|        rc = ssh_buffer_add_buffer(buffer, key->cert);
 1522|      0|        if (rc < 0) {
  ------------------
  |  Branch (1522:13): [True: 0, False: 0]
  ------------------
 1523|      0|            SSH_BUFFER_FREE(buffer);
  ------------------
  |  |  924|      0|    do { if ((x) != NULL) { ssh_buffer_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (924:14): [True: 0, False: 0]
  |  |  |  Branch (924:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1524|      0|            return NULL;
 1525|      0|        }
 1526|      0|        goto makestring;
 1527|      0|    }
 1528|       |
 1529|     28|    type_s = ssh_string_from_char(key->type_c);
 1530|     28|    if (type_s == NULL) {
  ------------------
  |  Branch (1530:9): [True: 0, False: 28]
  ------------------
 1531|      0|        SSH_BUFFER_FREE(buffer);
  ------------------
  |  |  924|      0|    do { if ((x) != NULL) { ssh_buffer_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (924:14): [True: 0, False: 0]
  |  |  |  Branch (924:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1532|      0|        return NULL;
 1533|      0|    }
 1534|       |
 1535|     28|    rc = ssh_buffer_add_ssh_string(buffer, type_s);
 1536|     28|    SSH_STRING_FREE(type_s);
  ------------------
  |  |  882|     28|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (882:14): [True: 28, False: 0]
  |  |  |  Branch (882:69): [Folded, False: 28]
  |  |  ------------------
  ------------------
 1537|     28|    if (rc < 0) {
  ------------------
  |  Branch (1537:9): [True: 0, False: 28]
  ------------------
 1538|      0|        SSH_BUFFER_FREE(buffer);
  ------------------
  |  |  924|      0|    do { if ((x) != NULL) { ssh_buffer_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (924:14): [True: 0, False: 0]
  |  |  |  Branch (924:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1539|      0|        return NULL;
 1540|      0|    }
 1541|       |
 1542|     28|    switch (key->type) {
 1543|     28|    case SSH_KEYTYPE_RSA:
  ------------------
  |  Branch (1543:5): [True: 28, False: 0]
  ------------------
 1544|     28|    case SSH_KEYTYPE_RSA1: {
  ------------------
  |  Branch (1544:5): [True: 0, False: 28]
  ------------------
 1545|     28|#if OPENSSL_VERSION_NUMBER < 0x30000000L
 1546|     28|        const BIGNUM *be = NULL, *bn = NULL;
 1547|     28|        const RSA *key_rsa = EVP_PKEY_get0_RSA(key->key);
 1548|     28|        RSA_get0_key(key_rsa, &bn, &be, NULL);
 1549|       |#else
 1550|       |        const OSSL_PARAM *out_param = NULL;
 1551|       |        rc = EVP_PKEY_todata(key->key, EVP_PKEY_PUBLIC_KEY, &params);
 1552|       |        if (rc != 1) {
 1553|       |            goto fail;
 1554|       |        }
 1555|       |        out_param = OSSL_PARAM_locate_const(params, OSSL_PKEY_PARAM_RSA_E);
 1556|       |        if (out_param == NULL) {
 1557|       |            SSH_LOG(SSH_LOG_TRACE, "RSA: No param E has been found");
 1558|       |            goto fail;
 1559|       |        }
 1560|       |        rc = OSSL_PARAM_get_BN(out_param, &be);
 1561|       |        if (rc != 1) {
 1562|       |            goto fail;
 1563|       |        }
 1564|       |        out_param = OSSL_PARAM_locate_const(params, OSSL_PKEY_PARAM_RSA_N);
 1565|       |        if (out_param == NULL) {
 1566|       |            SSH_LOG(SSH_LOG_TRACE, "RSA: No param N has been found");
 1567|       |            goto fail;
 1568|       |        }
 1569|       |        rc = OSSL_PARAM_get_BN(out_param, &bn);
 1570|       |        if (rc != 1) {
 1571|       |            goto fail;
 1572|       |        }
 1573|       |#endif /* OPENSSL_VERSION_NUMBER */
 1574|     28|        e = ssh_make_bignum_string((BIGNUM *)be);
 1575|     28|        if (e == NULL) {
  ------------------
  |  Branch (1575:13): [True: 0, False: 28]
  ------------------
 1576|      0|            goto fail;
 1577|      0|        }
 1578|       |
 1579|     28|        n = ssh_make_bignum_string((BIGNUM *)bn);
 1580|     28|        if (n == NULL) {
  ------------------
  |  Branch (1580:13): [True: 0, False: 28]
  ------------------
 1581|      0|            goto fail;
 1582|      0|        }
 1583|       |
 1584|     28|        if (type == SSH_KEY_PUBLIC) {
  ------------------
  |  Branch (1584:13): [True: 28, False: 0]
  ------------------
 1585|       |            /* The N and E parts are swapped in the public key export ! */
 1586|     28|            rc = ssh_buffer_add_ssh_string(buffer, e);
 1587|     28|            if (rc < 0) {
  ------------------
  |  Branch (1587:17): [True: 0, False: 28]
  ------------------
 1588|      0|                goto fail;
 1589|      0|            }
 1590|     28|            rc = ssh_buffer_add_ssh_string(buffer, n);
 1591|     28|            if (rc < 0) {
  ------------------
  |  Branch (1591:17): [True: 0, False: 28]
  ------------------
 1592|      0|                goto fail;
 1593|      0|            }
 1594|     28|        } else if (type == SSH_KEY_PRIVATE) {
  ------------------
  |  Branch (1594:20): [True: 0, False: 0]
  ------------------
 1595|      0|#if OPENSSL_VERSION_NUMBER < 0x30000000L
 1596|      0|            const BIGNUM *bd, *biqmp, *bp, *bq;
 1597|      0|            RSA_get0_key(key_rsa, NULL, NULL, &bd);
 1598|      0|            RSA_get0_factors(key_rsa, &bp, &bq);
 1599|      0|            RSA_get0_crt_params(key_rsa, NULL, NULL, &biqmp);
 1600|       |#else
 1601|       |            OSSL_PARAM_free(params);
 1602|       |            rc = EVP_PKEY_todata(key->key, EVP_PKEY_KEYPAIR, &params);
 1603|       |            if (rc != 1) {
 1604|       |                goto fail;
 1605|       |            }
 1606|       |
 1607|       |            out_param = OSSL_PARAM_locate_const(params, OSSL_PKEY_PARAM_RSA_D);
 1608|       |            if (out_param == NULL) {
 1609|       |                SSH_LOG(SSH_LOG_TRACE, "RSA: No param D has been found");
 1610|       |                goto fail;
 1611|       |            }
 1612|       |            rc = OSSL_PARAM_get_BN(out_param, &bd);
 1613|       |            if (rc != 1) {
 1614|       |                goto fail;
 1615|       |            }
 1616|       |
 1617|       |            out_param = OSSL_PARAM_locate_const(params, OSSL_PKEY_PARAM_RSA_FACTOR1);
 1618|       |            if (out_param == NULL) {
 1619|       |                SSH_LOG(SSH_LOG_TRACE, "RSA: No param P has been found");
 1620|       |                goto fail;
 1621|       |            }
 1622|       |            rc = OSSL_PARAM_get_BN(out_param, &bp);
 1623|       |            if (rc != 1) {
 1624|       |                goto fail;
 1625|       |            }
 1626|       |
 1627|       |            out_param = OSSL_PARAM_locate_const(params, OSSL_PKEY_PARAM_RSA_FACTOR2);
 1628|       |            if (out_param == NULL) {
 1629|       |                SSH_LOG(SSH_LOG_TRACE, "RSA: No param Q has been found");
 1630|       |                goto fail;
 1631|       |            }
 1632|       |            rc = OSSL_PARAM_get_BN(out_param, &bq);
 1633|       |            if (rc != 1) {
 1634|       |                goto fail;
 1635|       |            }
 1636|       |
 1637|       |            out_param = OSSL_PARAM_locate_const(params, OSSL_PKEY_PARAM_RSA_COEFFICIENT1);
 1638|       |            if (out_param == NULL) {
 1639|       |                SSH_LOG(SSH_LOG_TRACE, "RSA: No param IQMP has been found");
 1640|       |                goto fail;
 1641|       |            }
 1642|       |            rc = OSSL_PARAM_get_BN(out_param, &biqmp);
 1643|       |            if (rc != 1) {
 1644|       |                goto fail;
 1645|       |            }
 1646|       |#endif /* OPENSSL_VERSION_NUMBER */
 1647|      0|            rc = ssh_buffer_add_ssh_string(buffer, n);
 1648|      0|            if (rc < 0) {
  ------------------
  |  Branch (1648:17): [True: 0, False: 0]
  ------------------
 1649|      0|                goto fail;
 1650|      0|            }
 1651|      0|            rc = ssh_buffer_add_ssh_string(buffer, e);
 1652|      0|            if (rc < 0) {
  ------------------
  |  Branch (1652:17): [True: 0, False: 0]
  ------------------
 1653|      0|                goto fail;
 1654|      0|            }
 1655|       |
 1656|      0|            d = ssh_make_bignum_string((BIGNUM *)bd);
 1657|      0|            if (d == NULL) {
  ------------------
  |  Branch (1657:17): [True: 0, False: 0]
  ------------------
 1658|      0|                goto fail;
 1659|      0|            }
 1660|       |
 1661|      0|            iqmp = ssh_make_bignum_string((BIGNUM *)biqmp);
 1662|      0|            if (iqmp == NULL) {
  ------------------
  |  Branch (1662:17): [True: 0, False: 0]
  ------------------
 1663|      0|                goto fail;
 1664|      0|            }
 1665|       |
 1666|      0|            p = ssh_make_bignum_string((BIGNUM *)bp);
 1667|      0|            if (p == NULL) {
  ------------------
  |  Branch (1667:17): [True: 0, False: 0]
  ------------------
 1668|      0|                goto fail;
 1669|      0|            }
 1670|       |
 1671|      0|            q = ssh_make_bignum_string((BIGNUM *)bq);
 1672|      0|            if (q == NULL) {
  ------------------
  |  Branch (1672:17): [True: 0, False: 0]
  ------------------
 1673|      0|                goto fail;
 1674|      0|            }
 1675|       |
 1676|      0|            rc = ssh_buffer_add_ssh_string(buffer, d);
 1677|      0|            if (rc < 0) {
  ------------------
  |  Branch (1677:17): [True: 0, False: 0]
  ------------------
 1678|      0|                goto fail;
 1679|      0|            }
 1680|      0|            rc = ssh_buffer_add_ssh_string(buffer, iqmp);
 1681|      0|            if (rc < 0) {
  ------------------
  |  Branch (1681:17): [True: 0, False: 0]
  ------------------
 1682|      0|                goto fail;
 1683|      0|            }
 1684|      0|            rc = ssh_buffer_add_ssh_string(buffer, p);
 1685|      0|            if (rc < 0) {
  ------------------
  |  Branch (1685:17): [True: 0, False: 0]
  ------------------
 1686|      0|                goto fail;
 1687|      0|            }
 1688|      0|            rc = ssh_buffer_add_ssh_string(buffer, q);
 1689|      0|            if (rc < 0) {
  ------------------
  |  Branch (1689:17): [True: 0, False: 0]
  ------------------
 1690|      0|                goto fail;
 1691|      0|            }
 1692|       |
 1693|      0|            ssh_string_burn(d);
 1694|      0|            SSH_STRING_FREE(d);
  ------------------
  |  |  882|      0|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (882:14): [True: 0, False: 0]
  |  |  |  Branch (882:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1695|      0|            ssh_string_burn(iqmp);
 1696|      0|            SSH_STRING_FREE(iqmp);
  ------------------
  |  |  882|      0|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (882:14): [True: 0, False: 0]
  |  |  |  Branch (882:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1697|      0|            ssh_string_burn(p);
 1698|      0|            SSH_STRING_FREE(p);
  ------------------
  |  |  882|      0|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (882:14): [True: 0, False: 0]
  |  |  |  Branch (882:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1699|      0|            ssh_string_burn(q);
 1700|      0|            SSH_STRING_FREE(q);
  ------------------
  |  |  882|      0|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (882:14): [True: 0, False: 0]
  |  |  |  Branch (882:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1701|       |#if OPENSSL_VERSION_NUMBER >= 0x30000000L
 1702|       |            bignum_safe_free(bd);
 1703|       |            bignum_safe_free(biqmp);
 1704|       |            bignum_safe_free(bp);
 1705|       |            bignum_safe_free(bq);
 1706|       |#endif /* OPENSSL_VERSION_NUMBER */
 1707|      0|        }
 1708|     28|        ssh_string_burn(e);
 1709|     28|        SSH_STRING_FREE(e);
  ------------------
  |  |  882|     28|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (882:14): [True: 28, False: 0]
  |  |  |  Branch (882:69): [Folded, False: 28]
  |  |  ------------------
  ------------------
 1710|     28|        ssh_string_burn(n);
 1711|     28|        SSH_STRING_FREE(n);
  ------------------
  |  |  882|     28|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (882:14): [True: 28, False: 0]
  |  |  |  Branch (882:69): [Folded, False: 28]
  |  |  ------------------
  ------------------
 1712|       |#if OPENSSL_VERSION_NUMBER >= 0x30000000L
 1713|       |        bignum_safe_free(bn);
 1714|       |        bignum_safe_free(be);
 1715|       |        OSSL_PARAM_free(params);
 1716|       |        params = NULL;
 1717|       |#endif /* OPENSSL_VERSION_NUMBER */
 1718|     28|        break;
 1719|     28|    }
 1720|      0|    case SSH_KEYTYPE_ED25519:
  ------------------
  |  Branch (1720:5): [True: 0, False: 28]
  ------------------
 1721|      0|    case SSH_KEYTYPE_SK_ED25519:
  ------------------
  |  Branch (1721:5): [True: 0, False: 28]
  ------------------
 1722|      0|        rc = EVP_PKEY_get_raw_public_key(key->key, NULL, &key_len);
 1723|      0|        if (rc != 1) {
  ------------------
  |  Branch (1723:13): [True: 0, False: 0]
  ------------------
 1724|      0|            SSH_LOG(SSH_LOG_TRACE,
  ------------------
  |  |  283|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 1725|      0|                    "Failed to get ed25519 raw public key length: %s",
 1726|      0|                    ERR_error_string(ERR_get_error(), NULL));
 1727|      0|            goto fail;
 1728|      0|        }
 1729|       |
 1730|      0|        if (key_len != ED25519_KEY_LEN) {
  ------------------
  |  |   44|      0|#define ED25519_KEY_LEN 32
  ------------------
  |  Branch (1730:13): [True: 0, False: 0]
  ------------------
 1731|      0|            SSH_LOG(SSH_LOG_TRACE,
  ------------------
  |  |  283|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 1732|      0|                    "Unexpected length of private key %zu. Expected %d.",
 1733|      0|                    key_len,
 1734|      0|                    ED25519_KEY_LEN);
 1735|      0|            goto fail;
 1736|      0|        }
 1737|       |
 1738|      0|        ed25519_pubkey = malloc(key_len);
 1739|      0|        if (ed25519_pubkey == NULL) {
  ------------------
  |  Branch (1739:13): [True: 0, False: 0]
  ------------------
 1740|      0|            SSH_LOG(SSH_LOG_TRACE, "Out of memory");
  ------------------
  |  |  283|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 1741|      0|            goto fail;
 1742|      0|        }
 1743|       |
 1744|      0|        rc = EVP_PKEY_get_raw_public_key(key->key,
 1745|      0|                                         (uint8_t *)ed25519_pubkey,
 1746|      0|                                         &key_len);
 1747|      0|        if (rc != 1) {
  ------------------
  |  Branch (1747:13): [True: 0, False: 0]
  ------------------
 1748|      0|            SSH_LOG(SSH_LOG_TRACE,
  ------------------
  |  |  283|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 1749|      0|                    "Failed to get ed25519 raw public key:  %s",
 1750|      0|                    ERR_error_string(ERR_get_error(), NULL));
 1751|      0|            goto fail;
 1752|      0|        }
 1753|       |
 1754|      0|        rc = ssh_buffer_pack(buffer,
  ------------------
  |  |   50|      0|    _ssh_buffer_pack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |  453|      0|        (__VA_NARG_(__VA_ARGS__, __RSEQ_N()))
  |  |  |  |  ------------------
  |  |  |  |  |  |  455|      0|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  450|      0|#define VA_APPLY_VARIADIC_MACRO(macro, tuple) macro tuple
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  455|      0|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  463|      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)
  |  |  ------------------
  ------------------
 1755|      0|                             "dP",
 1756|      0|                             (uint32_t)ED25519_KEY_LEN,
 1757|      0|                             (size_t)ED25519_KEY_LEN,
 1758|      0|                             ed25519_pubkey);
 1759|      0|        if (rc == SSH_ERROR) {
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  |  Branch (1759:13): [True: 0, False: 0]
  ------------------
 1760|      0|            goto fail;
 1761|      0|        }
 1762|       |
 1763|      0|        if (type == SSH_KEY_PRIVATE && key->type == SSH_KEYTYPE_ED25519) {
  ------------------
  |  Branch (1763:13): [True: 0, False: 0]
  |  Branch (1763:40): [True: 0, False: 0]
  ------------------
 1764|      0|            key_len = 0;
 1765|      0|            rc = EVP_PKEY_get_raw_private_key(key->key, NULL, &key_len);
 1766|      0|            if (rc != 1) {
  ------------------
  |  Branch (1766:17): [True: 0, False: 0]
  ------------------
 1767|      0|                SSH_LOG(SSH_LOG_TRACE,
  ------------------
  |  |  283|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 1768|      0|                        "Failed to get ed25519 raw private key length: %s",
 1769|      0|                        ERR_error_string(ERR_get_error(), NULL));
 1770|      0|                goto fail;
 1771|      0|            }
 1772|       |
 1773|      0|            if (key_len != ED25519_KEY_LEN) {
  ------------------
  |  |   44|      0|#define ED25519_KEY_LEN 32
  ------------------
  |  Branch (1773:17): [True: 0, False: 0]
  ------------------
 1774|      0|                SSH_LOG(SSH_LOG_TRACE,
  ------------------
  |  |  283|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 1775|      0|                        "Unexpected length of private key %zu. Expected %d.",
 1776|      0|                        key_len,
 1777|      0|                        ED25519_KEY_LEN);
 1778|      0|                goto fail;
 1779|      0|            }
 1780|       |
 1781|      0|            ed25519_privkey = malloc(key_len);
 1782|      0|            if (ed25519_privkey == NULL) {
  ------------------
  |  Branch (1782:17): [True: 0, False: 0]
  ------------------
 1783|      0|                SSH_LOG(SSH_LOG_TRACE, "Out of memory");
  ------------------
  |  |  283|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 1784|      0|                goto fail;
 1785|      0|            }
 1786|       |
 1787|      0|            rc = EVP_PKEY_get_raw_private_key(key->key,
 1788|      0|                                              ed25519_privkey,
 1789|      0|                                              &key_len);
 1790|      0|            if (rc != 1) {
  ------------------
  |  Branch (1790:17): [True: 0, False: 0]
  ------------------
 1791|      0|                SSH_LOG(SSH_LOG_TRACE,
  ------------------
  |  |  283|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 1792|      0|                        "Failed to get ed25519 raw private key: %s",
 1793|      0|                        ERR_error_string(ERR_get_error(), NULL));
 1794|      0|                goto fail;
 1795|      0|            }
 1796|       |
 1797|      0|            rc = ssh_buffer_pack(buffer,
  ------------------
  |  |   50|      0|    _ssh_buffer_pack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |  453|      0|        (__VA_NARG_(__VA_ARGS__, __RSEQ_N()))
  |  |  |  |  ------------------
  |  |  |  |  |  |  455|      0|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  450|      0|#define VA_APPLY_VARIADIC_MACRO(macro, tuple) macro tuple
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  455|      0|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  463|      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)
  |  |  ------------------
  ------------------
 1798|      0|                                 "dPP",
 1799|      0|                                 (uint32_t)(2 * ED25519_KEY_LEN),
 1800|      0|                                 (size_t)ED25519_KEY_LEN,
 1801|      0|                                 ed25519_privkey,
 1802|      0|                                 (size_t)ED25519_KEY_LEN,
 1803|      0|                                 ed25519_pubkey);
 1804|      0|            if (rc == SSH_ERROR) {
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  |  Branch (1804:17): [True: 0, False: 0]
  ------------------
 1805|      0|                goto fail;
 1806|      0|            }
 1807|      0|            ssh_burn(ed25519_privkey, ED25519_KEY_LEN);
  ------------------
  |  |  390|      0|#define ssh_burn(ptr, len) explicit_bzero((ptr), (len))
  ------------------
 1808|      0|            SAFE_FREE(ed25519_privkey);
  ------------------
  |  |  375|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (375:31): [True: 0, False: 0]
  |  |  |  Branch (375:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1809|      0|        } else if (type == SSH_KEY_PRIVATE &&
  ------------------
  |  Branch (1809:20): [True: 0, False: 0]
  ------------------
 1810|      0|                   key->type == SSH_KEYTYPE_SK_ED25519) {
  ------------------
  |  Branch (1810:20): [True: 0, False: 0]
  ------------------
 1811|       |
 1812|      0|            rc = pki_buffer_pack_sk_priv_data(buffer, key);
 1813|      0|            if (rc == SSH_ERROR) {
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  |  Branch (1813:17): [True: 0, False: 0]
  ------------------
 1814|      0|                goto fail;
 1815|      0|            }
 1816|      0|        } else if (type == SSH_KEY_PUBLIC &&
  ------------------
  |  Branch (1816:20): [True: 0, False: 0]
  ------------------
 1817|      0|                   key->type == SSH_KEYTYPE_SK_ED25519) {
  ------------------
  |  Branch (1817:20): [True: 0, False: 0]
  ------------------
 1818|       |            /* public key can contain certificate sk information */
 1819|      0|            rc = ssh_buffer_add_ssh_string(buffer, key->sk_application);
 1820|      0|            if (rc != SSH_OK) {
  ------------------
  |  |  315|      0|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (1820:17): [True: 0, False: 0]
  ------------------
 1821|      0|                goto fail;
 1822|      0|            }
 1823|      0|        }
 1824|       |
 1825|      0|        SAFE_FREE(ed25519_pubkey);
  ------------------
  |  |  375|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (375:31): [True: 0, False: 0]
  |  |  |  Branch (375:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1826|      0|        break;
 1827|      0|    case SSH_KEYTYPE_ECDSA_P256:
  ------------------
  |  Branch (1827:5): [True: 0, False: 28]
  ------------------
 1828|      0|    case SSH_KEYTYPE_ECDSA_P384:
  ------------------
  |  Branch (1828:5): [True: 0, False: 28]
  ------------------
 1829|      0|    case SSH_KEYTYPE_ECDSA_P521:
  ------------------
  |  Branch (1829:5): [True: 0, False: 28]
  ------------------
 1830|      0|    case SSH_KEYTYPE_SK_ECDSA:
  ------------------
  |  Branch (1830:5): [True: 0, False: 28]
  ------------------
 1831|      0|#ifdef HAVE_OPENSSL_ECC
 1832|      0|    {
 1833|       |#if OPENSSL_VERSION_NUMBER >= 0x30000000L
 1834|       |        EC_GROUP *group = NULL;
 1835|       |        EC_POINT *point = NULL;
 1836|       |        const void *pubkey = NULL;
 1837|       |        size_t pubkey_len;
 1838|       |        OSSL_PARAM *locate_param = NULL;
 1839|       |#else
 1840|      0|        const EC_GROUP *group = NULL;
 1841|      0|        const EC_POINT *point = NULL;
 1842|      0|        const BIGNUM *exp = NULL;
 1843|      0|        EC_KEY *ec = NULL;
 1844|      0|#endif /* OPENSSL_VERSION_NUMBER */
 1845|       |
 1846|      0|        type_s = ssh_string_from_char(pki_key_ecdsa_nid_to_char(key->ecdsa_nid));
 1847|      0|        if (type_s == NULL) {
  ------------------
  |  Branch (1847:13): [True: 0, False: 0]
  ------------------
 1848|      0|            SSH_BUFFER_FREE(buffer);
  ------------------
  |  |  924|      0|    do { if ((x) != NULL) { ssh_buffer_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (924:14): [True: 0, False: 0]
  |  |  |  Branch (924:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1849|      0|            return NULL;
 1850|      0|        }
 1851|       |
 1852|      0|        rc = ssh_buffer_add_ssh_string(buffer, type_s);
 1853|      0|        SSH_STRING_FREE(type_s);
  ------------------
  |  |  882|      0|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (882:14): [True: 0, False: 0]
  |  |  |  Branch (882:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1854|      0|        if (rc < 0) {
  ------------------
  |  Branch (1854:13): [True: 0, False: 0]
  ------------------
 1855|      0|            SSH_BUFFER_FREE(buffer);
  ------------------
  |  |  924|      0|    do { if ((x) != NULL) { ssh_buffer_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (924:14): [True: 0, False: 0]
  |  |  |  Branch (924:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1856|      0|            return NULL;
 1857|      0|        }
 1858|       |
 1859|      0|#if OPENSSL_VERSION_NUMBER < 0x30000000L
 1860|      0|        ec = EVP_PKEY_get0_EC_KEY(key->key);
 1861|      0|        if (ec == NULL) {
  ------------------
  |  Branch (1861:13): [True: 0, False: 0]
  ------------------
 1862|      0|            goto fail;
 1863|      0|        }
 1864|       |#ifdef WITH_PKCS11_URI
 1865|       |        if (ssh_key_is_private(key) && !EC_KEY_get0_public_key(ec)) {
 1866|       |            SSH_LOG(SSH_LOG_TRACE,
 1867|       |                    "It is mandatory to have separate"
 1868|       |                    " public ECDSA key objects in the PKCS #11 device."
 1869|       |                    " Unlike RSA, ECDSA public keys cannot be derived"
 1870|       |                    " from their private keys.");
 1871|       |            goto fail;
 1872|       |        }
 1873|       |#endif /* WITH_PKCS11_URI */
 1874|      0|        group = EC_KEY_get0_group(ec);
 1875|      0|        point = EC_KEY_get0_public_key(ec);
 1876|      0|        if (group == NULL || point == NULL) {
  ------------------
  |  Branch (1876:13): [True: 0, False: 0]
  |  Branch (1876:30): [True: 0, False: 0]
  ------------------
 1877|      0|            goto fail;
 1878|      0|        }
 1879|      0|        e = pki_key_make_ecpoint_string(group, point);
 1880|       |#else
 1881|       |        rc = EVP_PKEY_todata(key->key, EVP_PKEY_PUBLIC_KEY, &params);
 1882|       |        if (rc < 0) {
 1883|       |            goto fail;
 1884|       |        }
 1885|       |
 1886|       |        locate_param = OSSL_PARAM_locate(params, OSSL_PKEY_PARAM_PUB_KEY);
 1887|       |#ifdef WITH_PKCS11_URI
 1888|       |        if (ssh_key_is_private(key) && !locate_param) {
 1889|       |            SSH_LOG(SSH_LOG_TRACE,
 1890|       |                    "It is mandatory to have separate"
 1891|       |                    " public ECDSA key objects in the PKCS #11 device."
 1892|       |                    " Unlike RSA, ECDSA public keys cannot be derived"
 1893|       |                    " from their private keys.");
 1894|       |            goto fail;
 1895|       |        }
 1896|       |#endif /* WITH_PKCS11_URI */
 1897|       |
 1898|       |        rc = OSSL_PARAM_get_octet_string_ptr(locate_param, &pubkey, &pubkey_len);
 1899|       |        if (rc != 1) {
 1900|       |            goto fail;
 1901|       |        }
 1902|       |        /* Convert the data to low-level representation */
 1903|       |        group = EC_GROUP_new_by_curve_name_ex(NULL, NULL, key->ecdsa_nid);
 1904|       |        point = EC_POINT_new(group);
 1905|       |        rc = EC_POINT_oct2point(group, point, pubkey, pubkey_len, NULL);
 1906|       |        if (group == NULL || point == NULL || rc != 1) {
 1907|       |            EC_GROUP_free(group);
 1908|       |            EC_POINT_free(point);
 1909|       |            goto fail;
 1910|       |        }
 1911|       |
 1912|       |        e = pki_key_make_ecpoint_string(group, point);
 1913|       |        EC_GROUP_free(group);
 1914|       |        EC_POINT_free(point);
 1915|       |#endif /* OPENSSL_VERSION_NUMBER */
 1916|      0|        if (e == NULL) {
  ------------------
  |  Branch (1916:13): [True: 0, False: 0]
  ------------------
 1917|      0|            SSH_BUFFER_FREE(buffer);
  ------------------
  |  |  924|      0|    do { if ((x) != NULL) { ssh_buffer_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (924:14): [True: 0, False: 0]
  |  |  |  Branch (924:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1918|      0|            return NULL;
 1919|      0|        }
 1920|       |
 1921|      0|        rc = ssh_buffer_add_ssh_string(buffer, e);
 1922|      0|        if (rc < 0) {
  ------------------
  |  Branch (1922:13): [True: 0, False: 0]
  ------------------
 1923|      0|            goto fail;
 1924|      0|        }
 1925|       |
 1926|      0|        ssh_string_burn(e);
 1927|      0|        SSH_STRING_FREE(e);
  ------------------
  |  |  882|      0|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (882:14): [True: 0, False: 0]
  |  |  |  Branch (882:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1928|      0|        e = NULL;
 1929|       |
 1930|      0|        if (type == SSH_KEY_PRIVATE && key->type != SSH_KEYTYPE_SK_ECDSA) {
  ------------------
  |  Branch (1930:13): [True: 0, False: 0]
  |  Branch (1930:40): [True: 0, False: 0]
  ------------------
 1931|       |#if OPENSSL_VERSION_NUMBER >= 0x30000000L
 1932|       |            OSSL_PARAM_free(params);
 1933|       |            rc = EVP_PKEY_todata(key->key, EVP_PKEY_KEYPAIR, &params);
 1934|       |            if (rc < 0) {
 1935|       |                goto fail;
 1936|       |            }
 1937|       |
 1938|       |            locate_param = OSSL_PARAM_locate(params, OSSL_PKEY_PARAM_PRIV_KEY);
 1939|       |            rc = OSSL_PARAM_get_BN(locate_param, &bd);
 1940|       |            if (rc != 1) {
 1941|       |                goto fail;
 1942|       |            }
 1943|       |            d = ssh_make_bignum_string((BIGNUM *)bd);
 1944|       |            if (d == NULL) {
 1945|       |                goto fail;
 1946|       |            }
 1947|       |            if (ssh_buffer_add_ssh_string(buffer, d) < 0) {
 1948|       |                goto fail;
 1949|       |            }
 1950|       |#else
 1951|      0|            exp = EC_KEY_get0_private_key(ec);
 1952|      0|            if (exp == NULL) {
  ------------------
  |  Branch (1952:17): [True: 0, False: 0]
  ------------------
 1953|      0|                goto fail;
 1954|      0|            }
 1955|      0|            d = ssh_make_bignum_string((BIGNUM *)exp);
 1956|      0|            if (d == NULL) {
  ------------------
  |  Branch (1956:17): [True: 0, False: 0]
  ------------------
 1957|      0|                goto fail;
 1958|      0|            }
 1959|      0|            rc = ssh_buffer_add_ssh_string(buffer, d);
 1960|      0|            if (rc < 0) {
  ------------------
  |  Branch (1960:17): [True: 0, False: 0]
  ------------------
 1961|      0|                goto fail;
 1962|      0|            }
 1963|      0|#endif /* OPENSSL_VERSION_NUMBER */
 1964|      0|            ssh_string_burn(d);
 1965|      0|            SSH_STRING_FREE(d);
  ------------------
  |  |  882|      0|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (882:14): [True: 0, False: 0]
  |  |  |  Branch (882:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1966|      0|            d = NULL;
 1967|      0|        } else if (type == SSH_KEY_PRIVATE &&
  ------------------
  |  Branch (1967:20): [True: 0, False: 0]
  ------------------
 1968|      0|                   key->type == SSH_KEYTYPE_SK_ECDSA) {
  ------------------
  |  Branch (1968:20): [True: 0, False: 0]
  ------------------
 1969|       |
 1970|      0|            rc = pki_buffer_pack_sk_priv_data(buffer, key);
 1971|      0|            if (rc == SSH_ERROR) {
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  |  Branch (1971:17): [True: 0, False: 0]
  ------------------
 1972|      0|                goto fail;
 1973|      0|            }
 1974|      0|        } else if (type == SSH_KEY_PUBLIC &&
  ------------------
  |  Branch (1974:20): [True: 0, False: 0]
  ------------------
 1975|      0|                   key->type == SSH_KEYTYPE_SK_ECDSA) {
  ------------------
  |  Branch (1975:20): [True: 0, False: 0]
  ------------------
 1976|       |            /* public key can contain certificate sk information */
 1977|      0|            rc = ssh_buffer_add_ssh_string(buffer, key->sk_application);
 1978|      0|            if (rc != SSH_OK) {
  ------------------
  |  |  315|      0|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (1978:17): [True: 0, False: 0]
  ------------------
 1979|      0|                goto fail;
 1980|      0|            }
 1981|      0|        }
 1982|       |#if OPENSSL_VERSION_NUMBER >= 0x30000000L
 1983|       |        bignum_safe_free(bd);
 1984|       |        OSSL_PARAM_free(params);
 1985|       |        params = NULL;
 1986|       |#endif /* OPENSSL_VERSION_NUMBER */
 1987|      0|        break;
 1988|      0|    }
 1989|      0|#endif /* HAVE_OPENSSL_ECC */
 1990|      0|    case SSH_KEYTYPE_UNKNOWN:
  ------------------
  |  Branch (1990:5): [True: 0, False: 28]
  ------------------
 1991|      0|    default:
  ------------------
  |  Branch (1991:5): [True: 0, False: 28]
  ------------------
 1992|      0|        goto fail;
 1993|     28|    }
 1994|       |
 1995|     28|makestring:
 1996|     28|    str = ssh_string_new(ssh_buffer_get_len(buffer));
 1997|     28|    if (str == NULL) {
  ------------------
  |  Branch (1997:9): [True: 0, False: 28]
  ------------------
 1998|      0|        goto fail;
 1999|      0|    }
 2000|       |
 2001|     28|    rc = ssh_string_fill(str, ssh_buffer_get(buffer), ssh_buffer_get_len(buffer));
 2002|     28|    if (rc < 0) {
  ------------------
  |  Branch (2002:9): [True: 0, False: 28]
  ------------------
 2003|      0|        goto fail;
 2004|      0|    }
 2005|     28|    SSH_BUFFER_FREE(buffer);
  ------------------
  |  |  924|     28|    do { if ((x) != NULL) { ssh_buffer_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (924:14): [True: 28, False: 0]
  |  |  |  Branch (924:69): [Folded, False: 28]
  |  |  ------------------
  ------------------
 2006|       |
 2007|     28|    return str;
 2008|      0|fail:
 2009|      0|    SSH_BUFFER_FREE(buffer);
  ------------------
  |  |  924|      0|    do { if ((x) != NULL) { ssh_buffer_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (924:14): [True: 0, False: 0]
  |  |  |  Branch (924:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2010|      0|    ssh_string_burn(str);
 2011|      0|    SSH_STRING_FREE(str);
  ------------------
  |  |  882|      0|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (882:14): [True: 0, False: 0]
  |  |  |  Branch (882:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2012|      0|    ssh_string_burn(e);
 2013|      0|    SSH_STRING_FREE(e);
  ------------------
  |  |  882|      0|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (882:14): [True: 0, False: 0]
  |  |  |  Branch (882:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2014|      0|    ssh_string_burn(p);
 2015|      0|    SSH_STRING_FREE(p);
  ------------------
  |  |  882|      0|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (882:14): [True: 0, False: 0]
  |  |  |  Branch (882:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2016|      0|    ssh_string_burn(g);
 2017|      0|    SSH_STRING_FREE(g);
  ------------------
  |  |  882|      0|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (882:14): [True: 0, False: 0]
  |  |  |  Branch (882:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2018|      0|    ssh_string_burn(q);
 2019|      0|    SSH_STRING_FREE(q);
  ------------------
  |  |  882|      0|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (882:14): [True: 0, False: 0]
  |  |  |  Branch (882:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2020|      0|    ssh_string_burn(n);
 2021|      0|    SSH_STRING_FREE(n);
  ------------------
  |  |  882|      0|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (882:14): [True: 0, False: 0]
  |  |  |  Branch (882:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2022|      0|    ssh_string_burn(d);
 2023|      0|    SSH_STRING_FREE(d);
  ------------------
  |  |  882|      0|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (882:14): [True: 0, False: 0]
  |  |  |  Branch (882:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2024|      0|    ssh_string_burn(iqmp);
 2025|      0|    SSH_STRING_FREE(iqmp);
  ------------------
  |  |  882|      0|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (882:14): [True: 0, False: 0]
  |  |  |  Branch (882:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2026|       |#if OPENSSL_VERSION_NUMBER >= 0x30000000L
 2027|       |    bignum_safe_free(bp);
 2028|       |    bignum_safe_free(bq);
 2029|       |    bignum_safe_free(bg);
 2030|       |    bignum_safe_free(bpub_key);
 2031|       |    bignum_safe_free(bn);
 2032|       |    bignum_safe_free(be);
 2033|       |    bignum_safe_free(bd);
 2034|       |    bignum_safe_free(biqmp);
 2035|       |    OSSL_PARAM_free(params);
 2036|       |#endif /* OPENSSL_VERSION_NUMBER */
 2037|      0|    free(ed25519_pubkey);
 2038|      0|    if (ed25519_privkey) {
  ------------------
  |  Branch (2038:9): [True: 0, False: 0]
  ------------------
 2039|      0|        ssh_burn(ed25519_privkey, ED25519_KEY_LEN);
  ------------------
  |  |  390|      0|#define ssh_burn(ptr, len) explicit_bzero((ptr), (len))
  ------------------
 2040|      0|        free(ed25519_privkey);
 2041|      0|    }
 2042|       |
 2043|       |    return NULL;
 2044|     28|}
pki_signature_from_blob:
 2391|      3|{
 2392|      3|    ssh_signature sig;
 2393|      3|    int rc;
 2394|       |
 2395|      3|    if (ssh_key_type_plain(pubkey->type) != type) {
  ------------------
  |  Branch (2395:9): [True: 0, False: 3]
  ------------------
 2396|      0|        SSH_LOG(SSH_LOG_TRACE,
  ------------------
  |  |  283|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 2397|      0|                "Incompatible public key provided (%d) expecting (%d)",
 2398|      0|                type,
 2399|      0|                pubkey->type);
 2400|      0|        return NULL;
 2401|      0|    }
 2402|       |
 2403|      3|    sig = ssh_signature_new();
 2404|      3|    if (sig == NULL) {
  ------------------
  |  Branch (2404:9): [True: 0, False: 3]
  ------------------
 2405|      0|        return NULL;
 2406|      0|    }
 2407|       |
 2408|      3|    sig->type = type;
 2409|      3|    sig->type_c = ssh_key_signature_to_char(type, hash_type);
 2410|      3|    sig->hash_type = hash_type;
 2411|       |
 2412|      3|    switch(type) {
 2413|      3|        case SSH_KEYTYPE_RSA:
  ------------------
  |  Branch (2413:9): [True: 3, False: 0]
  ------------------
 2414|      3|        case SSH_KEYTYPE_RSA1:
  ------------------
  |  Branch (2414:9): [True: 0, False: 3]
  ------------------
 2415|      3|            rc = pki_signature_from_rsa_blob(pubkey, sig_blob, sig);
 2416|      3|            if (rc != SSH_OK) {
  ------------------
  |  |  315|      3|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (2416:17): [True: 0, False: 3]
  ------------------
 2417|      0|                goto error;
 2418|      0|            }
 2419|      3|            break;
 2420|      3|        case SSH_KEYTYPE_ED25519:
  ------------------
  |  Branch (2420:9): [True: 0, False: 3]
  ------------------
 2421|      0|        case SSH_KEYTYPE_SK_ED25519:
  ------------------
  |  Branch (2421:9): [True: 0, False: 3]
  ------------------
 2422|      0|            rc = pki_signature_from_ed25519_blob(sig, sig_blob);
 2423|      0|            if (rc != SSH_OK){
  ------------------
  |  |  315|      0|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (2423:17): [True: 0, False: 0]
  ------------------
 2424|      0|                goto error;
 2425|      0|            }
 2426|      0|            break;
 2427|      0|        case SSH_KEYTYPE_ECDSA_P256:
  ------------------
  |  Branch (2427:9): [True: 0, False: 3]
  ------------------
 2428|      0|        case SSH_KEYTYPE_ECDSA_P384:
  ------------------
  |  Branch (2428:9): [True: 0, False: 3]
  ------------------
 2429|      0|        case SSH_KEYTYPE_ECDSA_P521:
  ------------------
  |  Branch (2429:9): [True: 0, False: 3]
  ------------------
 2430|      0|        case SSH_KEYTYPE_ECDSA_P256_CERT01:
  ------------------
  |  Branch (2430:9): [True: 0, False: 3]
  ------------------
 2431|      0|        case SSH_KEYTYPE_ECDSA_P384_CERT01:
  ------------------
  |  Branch (2431:9): [True: 0, False: 3]
  ------------------
 2432|      0|        case SSH_KEYTYPE_ECDSA_P521_CERT01:
  ------------------
  |  Branch (2432:9): [True: 0, False: 3]
  ------------------
 2433|      0|        case SSH_KEYTYPE_SK_ECDSA:
  ------------------
  |  Branch (2433:9): [True: 0, False: 3]
  ------------------
 2434|      0|        case SSH_KEYTYPE_SK_ECDSA_CERT01:
  ------------------
  |  Branch (2434:9): [True: 0, False: 3]
  ------------------
 2435|      0|#ifdef HAVE_OPENSSL_ECC
 2436|      0|            rc = pki_signature_from_ecdsa_blob(pubkey, sig_blob, sig);
 2437|      0|            if (rc != SSH_OK) {
  ------------------
  |  |  315|      0|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (2437:17): [True: 0, False: 0]
  ------------------
 2438|      0|                goto error;
 2439|      0|            }
 2440|      0|            break;
 2441|      0|#endif
 2442|      0|        default:
  ------------------
  |  Branch (2442:9): [True: 0, False: 3]
  ------------------
 2443|      0|        case SSH_KEYTYPE_UNKNOWN:
  ------------------
  |  Branch (2443:9): [True: 0, False: 3]
  ------------------
 2444|      0|            SSH_LOG(SSH_LOG_TRACE, "Unknown signature type");
  ------------------
  |  |  283|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 2445|      0|            goto error;
 2446|      3|    }
 2447|       |
 2448|      3|    return sig;
 2449|       |
 2450|      0|error:
 2451|      0|    ssh_signature_free(sig);
 2452|       |    return NULL;
 2453|      3|}
pki_verify_data_signature:
 2674|      3|{
 2675|      3|    const EVP_MD *md = NULL;
 2676|      3|    EVP_MD_CTX *ctx = NULL;
 2677|      3|    EVP_PKEY *pkey = NULL;
 2678|       |
 2679|      3|    unsigned char *raw_sig_data = NULL;
 2680|      3|    size_t raw_sig_len;
 2681|       |
 2682|       |    /* Function return code
 2683|       |     * Do not change this variable throughout the function until the signature
 2684|       |     * is successfully verified!
 2685|       |     */
 2686|      3|    int rc = SSH_ERROR;
  ------------------
  |  |  316|      3|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 2687|      3|    int ok;
 2688|       |
 2689|      3|    if (pubkey == NULL || ssh_key_is_private(pubkey) || input == NULL ||
  ------------------
  |  Branch (2689:9): [True: 0, False: 3]
  |  Branch (2689:27): [True: 0, False: 3]
  |  Branch (2689:57): [True: 0, False: 3]
  ------------------
 2690|      3|        signature == NULL || signature->raw_sig == NULL)
  ------------------
  |  Branch (2690:9): [True: 0, False: 3]
  |  Branch (2690:30): [True: 0, False: 3]
  ------------------
 2691|      0|    {
 2692|      0|        SSH_LOG(SSH_LOG_TRACE, "Bad parameter provided to "
  ------------------
  |  |  283|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 2693|      0|                               "pki_verify_data_signature()");
 2694|      0|        return SSH_ERROR;
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 2695|      0|    }
 2696|       |
 2697|       |    /* Check if public key and hash type are compatible */
 2698|      3|    ok = pki_key_check_hash_compatible(pubkey, signature->hash_type);
 2699|      3|    if (ok != SSH_OK) {
  ------------------
  |  |  315|      3|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (2699:9): [True: 0, False: 3]
  ------------------
 2700|      0|        return SSH_ERROR;
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 2701|      0|    }
 2702|       |
 2703|       |    /* Get the signature to be verified */
 2704|      3|    raw_sig_data = ssh_string_data(signature->raw_sig);
 2705|      3|    raw_sig_len = ssh_string_len(signature->raw_sig);
 2706|      3|    if (raw_sig_data == NULL) {
  ------------------
  |  Branch (2706:9): [True: 0, False: 3]
  ------------------
 2707|      0|        return SSH_ERROR;
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 2708|      0|    }
 2709|       |
 2710|       |    /* Set hash algorithm to be used */
 2711|      3|    md = pki_digest_to_md(signature->hash_type);
 2712|      3|    if (md == NULL) {
  ------------------
  |  Branch (2712:9): [True: 0, False: 3]
  ------------------
 2713|      0|        if (signature->hash_type != SSH_DIGEST_AUTO) {
  ------------------
  |  Branch (2713:13): [True: 0, False: 0]
  ------------------
 2714|      0|            return SSH_ERROR;
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 2715|      0|        }
 2716|      0|    }
 2717|       |
 2718|       |    /* Setup public key EVP_PKEY */
 2719|      3|    pkey = pki_key_to_pkey(pubkey);
 2720|      3|    if (pkey == NULL) {
  ------------------
  |  Branch (2720:9): [True: 0, False: 3]
  ------------------
 2721|      0|        return SSH_ERROR;
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 2722|      0|    }
 2723|       |
 2724|       |    /* Create the context */
 2725|      3|    ctx = EVP_MD_CTX_new();
 2726|      3|    if (ctx == NULL) {
  ------------------
  |  Branch (2726:9): [True: 0, False: 3]
  ------------------
 2727|      0|        SSH_LOG(SSH_LOG_TRACE,
  ------------------
  |  |  283|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 2728|      0|                "Failed to create EVP_MD_CTX: %s",
 2729|      0|                ERR_error_string(ERR_get_error(), NULL));
 2730|      0|        goto out;
 2731|      0|    }
 2732|       |
 2733|       |    /* Verify the signature */
 2734|      3|    ok = EVP_DigestVerifyInit(ctx, NULL, md, NULL, pkey);
 2735|      3|    if (ok != 1){
  ------------------
  |  Branch (2735:9): [True: 0, False: 3]
  ------------------
 2736|      0|        SSH_LOG(SSH_LOG_TRACE,
  ------------------
  |  |  283|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 2737|      0|                "EVP_DigestVerifyInit() failed: %s",
 2738|      0|                ERR_error_string(ERR_get_error(), NULL));
 2739|      0|        goto out;
 2740|      0|    }
 2741|       |
 2742|      3|    ok = EVP_DigestVerify(ctx, raw_sig_data, raw_sig_len, input, input_len);
 2743|      3|    if (ok != 1) {
  ------------------
  |  Branch (2743:9): [True: 3, False: 0]
  ------------------
 2744|      3|        SSH_LOG(SSH_LOG_TRACE,
  ------------------
  |  |  283|      3|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 2745|      3|                "Signature invalid: %s",
 2746|      3|                ERR_error_string(ERR_get_error(), NULL));
 2747|      3|        goto out;
 2748|      3|    }
 2749|       |
 2750|      0|    SSH_LOG(SSH_LOG_TRACE, "Signature valid");
  ------------------
  |  |  283|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 2751|      0|    rc = SSH_OK;
  ------------------
  |  |  315|      0|#define SSH_OK 0     /* No error */
  ------------------
 2752|       |
 2753|      3|out:
 2754|      3|    EVP_MD_CTX_free(ctx);
 2755|      3|    EVP_PKEY_free(pkey);
 2756|      3|    return rc;
 2757|      0|}
ssh_key_size:
 2760|      3|{
 2761|      3|    int bits = 0;
 2762|      3|    EVP_PKEY *pkey = NULL;
 2763|       |
 2764|      3|    switch (key->type) {
 2765|      3|    case SSH_KEYTYPE_RSA:
  ------------------
  |  Branch (2765:5): [True: 3, False: 0]
  ------------------
 2766|      3|    case SSH_KEYTYPE_RSA_CERT01:
  ------------------
  |  Branch (2766:5): [True: 0, False: 3]
  ------------------
 2767|      3|    case SSH_KEYTYPE_RSA1:
  ------------------
  |  Branch (2767:5): [True: 0, False: 3]
  ------------------
 2768|      3|    case SSH_KEYTYPE_ECDSA_P256:
  ------------------
  |  Branch (2768:5): [True: 0, False: 3]
  ------------------
 2769|      3|    case SSH_KEYTYPE_ECDSA_P256_CERT01:
  ------------------
  |  Branch (2769:5): [True: 0, False: 3]
  ------------------
 2770|      3|    case SSH_KEYTYPE_ECDSA_P384:
  ------------------
  |  Branch (2770:5): [True: 0, False: 3]
  ------------------
 2771|      3|    case SSH_KEYTYPE_ECDSA_P384_CERT01:
  ------------------
  |  Branch (2771:5): [True: 0, False: 3]
  ------------------
 2772|      3|    case SSH_KEYTYPE_ECDSA_P521:
  ------------------
  |  Branch (2772:5): [True: 0, False: 3]
  ------------------
 2773|      3|    case SSH_KEYTYPE_ECDSA_P521_CERT01:
  ------------------
  |  Branch (2773:5): [True: 0, False: 3]
  ------------------
 2774|      3|    case SSH_KEYTYPE_SK_ECDSA:
  ------------------
  |  Branch (2774:5): [True: 0, False: 3]
  ------------------
 2775|      3|    case SSH_KEYTYPE_SK_ECDSA_CERT01:
  ------------------
  |  Branch (2775:5): [True: 0, False: 3]
  ------------------
 2776|      3|        pkey = pki_key_to_pkey(key);
 2777|      3|        if (pkey == NULL) {
  ------------------
  |  Branch (2777:13): [True: 0, False: 3]
  ------------------
 2778|      0|            return SSH_ERROR;
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 2779|      0|        }
 2780|      3|        bits = EVP_PKEY_bits(pkey);
 2781|      3|        EVP_PKEY_free(pkey);
 2782|      3|        return bits;
 2783|      0|    case SSH_KEYTYPE_ED25519:
  ------------------
  |  Branch (2783:5): [True: 0, False: 3]
  ------------------
 2784|      0|    case SSH_KEYTYPE_ED25519_CERT01:
  ------------------
  |  Branch (2784:5): [True: 0, False: 3]
  ------------------
 2785|      0|    case SSH_KEYTYPE_SK_ED25519:
  ------------------
  |  Branch (2785:5): [True: 0, False: 3]
  ------------------
 2786|      0|    case SSH_KEYTYPE_SK_ED25519_CERT01:
  ------------------
  |  Branch (2786:5): [True: 0, False: 3]
  ------------------
 2787|       |        /* ed25519 keys have fixed size */
 2788|      0|        return 255;
 2789|      0|    case SSH_KEYTYPE_DSS:   /* deprecated */
  ------------------
  |  Branch (2789:5): [True: 0, False: 3]
  ------------------
 2790|      0|    case SSH_KEYTYPE_DSS_CERT01:    /* deprecated */
  ------------------
  |  Branch (2790:5): [True: 0, False: 3]
  ------------------
 2791|      0|    case SSH_KEYTYPE_UNKNOWN:
  ------------------
  |  Branch (2791:5): [True: 0, False: 3]
  ------------------
 2792|      0|    default:
  ------------------
  |  Branch (2792:5): [True: 0, False: 3]
  ------------------
 2793|      0|        return SSH_ERROR;
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 2794|      3|    }
 2795|      3|}
pki_crypto.c:pki_signature_from_rsa_blob:
 2169|      3|{
 2170|      3|    size_t pad_len = 0;
 2171|      3|    char *blob_orig = NULL;
 2172|      3|    char *blob_padded_data = NULL;
 2173|      3|    ssh_string sig_blob_padded = NULL;
 2174|       |
 2175|      3|    size_t rsalen = 0;
 2176|      3|    size_t len = ssh_string_len(sig_blob);
 2177|       |
 2178|      3|#if OPENSSL_VERSION_NUMBER < 0x30000000L
 2179|      3|    const RSA *rsa = EVP_PKEY_get0_RSA(pubkey->key);
 2180|       |
 2181|      3|    if (rsa == NULL) {
  ------------------
  |  Branch (2181:9): [True: 0, False: 3]
  ------------------
 2182|      0|        SSH_LOG(SSH_LOG_TRACE, "RSA field NULL");
  ------------------
  |  |  283|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 2183|      0|        goto errout;
 2184|      0|    }
 2185|       |
 2186|      3|    rsalen = RSA_size(rsa);
 2187|       |#else
 2188|       |    if (EVP_PKEY_get_base_id(pubkey->key) != EVP_PKEY_RSA) {
 2189|       |        SSH_LOG(SSH_LOG_TRACE, "Key has no RSA pubkey");
 2190|       |        goto errout;
 2191|       |    }
 2192|       |
 2193|       |    rsalen = EVP_PKEY_size(pubkey->key);
 2194|       |#endif /* OPENSSL_VERSION_NUMBER */
 2195|      3|    if (len > rsalen) {
  ------------------
  |  Branch (2195:9): [True: 0, False: 3]
  ------------------
 2196|      0|        SSH_LOG(SSH_LOG_TRACE,
  ------------------
  |  |  283|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 2197|      0|                "Signature is too big: %lu > %lu",
 2198|      0|                (unsigned long)len,
 2199|      0|                (unsigned long)rsalen);
 2200|      0|        goto errout;
 2201|      0|    }
 2202|       |
 2203|       |#ifdef DEBUG_CRYPTO
 2204|       |    SSH_LOG(SSH_LOG_DEBUG, "RSA signature len: %lu", (unsigned long)len);
 2205|       |    ssh_log_hexdump("RSA signature", ssh_string_data(sig_blob), len);
 2206|       |#endif /* DEBUG_CRYPTO */
 2207|       |
 2208|      3|    if (len == rsalen) {
  ------------------
  |  Branch (2208:9): [True: 3, False: 0]
  ------------------
 2209|      3|        sig->raw_sig = ssh_string_copy(sig_blob);
 2210|      3|    } else {
 2211|       |        /* pad the blob to the expected rsalen size */
 2212|      0|        SSH_LOG(SSH_LOG_DEBUG,
  ------------------
  |  |  283|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 2213|      0|                "RSA signature len %lu < %lu",
 2214|      0|                (unsigned long)len,
 2215|      0|                (unsigned long)rsalen);
 2216|       |
 2217|      0|        pad_len = rsalen - len;
 2218|       |
 2219|      0|        sig_blob_padded = ssh_string_new(rsalen);
 2220|      0|        if (sig_blob_padded == NULL) {
  ------------------
  |  Branch (2220:13): [True: 0, False: 0]
  ------------------
 2221|      0|            goto errout;
 2222|      0|        }
 2223|       |
 2224|      0|        blob_padded_data = (char *) ssh_string_data(sig_blob_padded);
 2225|      0|        blob_orig = (char *) ssh_string_data(sig_blob);
 2226|       |
 2227|      0|        if (blob_padded_data == NULL || blob_orig == NULL) {
  ------------------
  |  Branch (2227:13): [True: 0, False: 0]
  |  Branch (2227:41): [True: 0, False: 0]
  ------------------
 2228|      0|            goto errout;
 2229|      0|        }
 2230|       |
 2231|       |        /* front-pad the buffer with zeroes */
 2232|      0|        ssh_burn(blob_padded_data, pad_len);
  ------------------
  |  |  390|      0|#define ssh_burn(ptr, len) explicit_bzero((ptr), (len))
  ------------------
 2233|       |        /* fill the rest with the actual signature blob */
 2234|      0|        memcpy(blob_padded_data + pad_len, blob_orig, len);
 2235|       |
 2236|      0|        sig->raw_sig = sig_blob_padded;
 2237|      0|    }
 2238|       |
 2239|      3|    return SSH_OK;
  ------------------
  |  |  315|      3|#define SSH_OK 0     /* No error */
  ------------------
 2240|       |
 2241|      0|errout:
 2242|      0|    SSH_STRING_FREE(sig_blob_padded);
  ------------------
  |  |  882|      0|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (882:14): [True: 0, False: 0]
  |  |  |  Branch (882:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2243|      0|    return SSH_ERROR;
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
 2244|      3|}
pki_crypto.c:pki_digest_to_md:
 2456|      3|{
 2457|      3|    const EVP_MD *md = NULL;
 2458|       |
 2459|      3|    switch (hash_type) {
 2460|      1|    case SSH_DIGEST_SHA256:
  ------------------
  |  Branch (2460:5): [True: 1, False: 2]
  ------------------
 2461|      1|        md = EVP_sha256();
 2462|      1|        break;
 2463|      0|    case SSH_DIGEST_SHA384:
  ------------------
  |  Branch (2463:5): [True: 0, False: 3]
  ------------------
 2464|      0|        md = EVP_sha384();
 2465|      0|        break;
 2466|      2|    case SSH_DIGEST_SHA512:
  ------------------
  |  Branch (2466:5): [True: 2, False: 1]
  ------------------
 2467|      2|        md = EVP_sha512();
 2468|      2|        break;
 2469|      0|    case SSH_DIGEST_SHA1:
  ------------------
  |  Branch (2469:5): [True: 0, False: 3]
  ------------------
 2470|      0|        md = EVP_sha1();
 2471|      0|        break;
 2472|      0|    case SSH_DIGEST_AUTO:
  ------------------
  |  Branch (2472:5): [True: 0, False: 3]
  ------------------
 2473|      0|        md = NULL;
 2474|      0|        break;
 2475|      0|    default:
  ------------------
  |  Branch (2475:5): [True: 0, False: 3]
  ------------------
 2476|      0|        SSH_LOG(SSH_LOG_TRACE, "Unknown hash algorithm for type: %d",
  ------------------
  |  |  283|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 2477|      0|                hash_type);
 2478|      0|        return NULL;
 2479|      3|    }
 2480|       |
 2481|      3|    return md;
 2482|      3|}
pki_crypto.c:pki_key_to_pkey:
 2485|      6|{
 2486|      6|    EVP_PKEY *pkey = NULL;
 2487|      6|    int rc = 0;
 2488|       |
 2489|      6|    switch (key->type) {
 2490|      6|    case SSH_KEYTYPE_RSA:
  ------------------
  |  Branch (2490:5): [True: 6, False: 0]
  ------------------
 2491|      6|    case SSH_KEYTYPE_RSA1:
  ------------------
  |  Branch (2491:5): [True: 0, False: 6]
  ------------------
 2492|      6|    case SSH_KEYTYPE_RSA_CERT01:
  ------------------
  |  Branch (2492:5): [True: 0, False: 6]
  ------------------
 2493|      6|    case SSH_KEYTYPE_ECDSA_P256:
  ------------------
  |  Branch (2493:5): [True: 0, False: 6]
  ------------------
 2494|      6|    case SSH_KEYTYPE_ECDSA_P384:
  ------------------
  |  Branch (2494:5): [True: 0, False: 6]
  ------------------
 2495|      6|    case SSH_KEYTYPE_ECDSA_P521:
  ------------------
  |  Branch (2495:5): [True: 0, False: 6]
  ------------------
 2496|      6|    case SSH_KEYTYPE_ECDSA_P256_CERT01:
  ------------------
  |  Branch (2496:5): [True: 0, False: 6]
  ------------------
 2497|      6|    case SSH_KEYTYPE_ECDSA_P384_CERT01:
  ------------------
  |  Branch (2497:5): [True: 0, False: 6]
  ------------------
 2498|      6|    case SSH_KEYTYPE_ECDSA_P521_CERT01:
  ------------------
  |  Branch (2498:5): [True: 0, False: 6]
  ------------------
 2499|      6|    case SSH_KEYTYPE_SK_ECDSA:
  ------------------
  |  Branch (2499:5): [True: 0, False: 6]
  ------------------
 2500|      6|    case SSH_KEYTYPE_SK_ECDSA_CERT01:
  ------------------
  |  Branch (2500:5): [True: 0, False: 6]
  ------------------
 2501|      6|    case SSH_KEYTYPE_ED25519:
  ------------------
  |  Branch (2501:5): [True: 0, False: 6]
  ------------------
 2502|      6|    case SSH_KEYTYPE_ED25519_CERT01:
  ------------------
  |  Branch (2502:5): [True: 0, False: 6]
  ------------------
 2503|      6|    case SSH_KEYTYPE_SK_ED25519:
  ------------------
  |  Branch (2503:5): [True: 0, False: 6]
  ------------------
 2504|      6|    case SSH_KEYTYPE_SK_ED25519_CERT01:
  ------------------
  |  Branch (2504:5): [True: 0, False: 6]
  ------------------
 2505|      6|        if (key->key == NULL) {
  ------------------
  |  Branch (2505:13): [True: 0, False: 6]
  ------------------
 2506|      0|            SSH_LOG(SSH_LOG_TRACE, "NULL key->key");
  ------------------
  |  |  283|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 2507|      0|            goto error;
 2508|      0|        }
 2509|      6|        rc = EVP_PKEY_up_ref(key->key);
 2510|      6|        if (rc != 1) {
  ------------------
  |  Branch (2510:13): [True: 0, False: 6]
  ------------------
 2511|      0|            SSH_LOG(SSH_LOG_TRACE, "Failed to reference EVP_PKEY");
  ------------------
  |  |  283|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 2512|      0|            return NULL;
 2513|      0|        }
 2514|      6|        pkey = key->key;
 2515|      6|        break;
 2516|      0|    case SSH_KEYTYPE_UNKNOWN:
  ------------------
  |  Branch (2516:5): [True: 0, False: 6]
  ------------------
 2517|      0|    default:
  ------------------
  |  Branch (2517:5): [True: 0, False: 6]
  ------------------
 2518|      0|        SSH_LOG(SSH_LOG_TRACE, "Unknown private key algorithm for type: %d",
  ------------------
  |  |  283|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 2519|      0|                key->type);
 2520|      0|        goto error;
 2521|      6|    }
 2522|       |
 2523|      6|    return pkey;
 2524|       |
 2525|      0|error:
 2526|      0|    EVP_PKEY_free(pkey);
 2527|       |    return NULL;
 2528|      6|}

ssh_poll_init:
   91|      2|{
   92|      2|    return;
   93|      2|}
ssh_poll:
  115|  1.85k|{
  116|  1.85k|    return poll((struct pollfd *)fds, nfds, timeout);
  117|  1.85k|}
ssh_poll_new:
  396|    473|{
  397|    473|    ssh_poll_handle p = NULL;
  398|       |
  399|    473|    p = malloc(sizeof(struct ssh_poll_handle_struct));
  400|    473|    if (p == NULL) {
  ------------------
  |  Branch (400:9): [True: 0, False: 473]
  ------------------
  401|      0|        return NULL;
  402|      0|    }
  403|    473|    ZERO_STRUCTP(p);
  ------------------
  |  |  381|    473|#define ZERO_STRUCTP(x) do { if ((x) != NULL) memset((x), 0, sizeof(*(x))); } while(0)
  |  |  ------------------
  |  |  |  Branch (381:34): [True: 473, False: 0]
  |  |  |  Branch (381:85): [Folded, False: 473]
  |  |  ------------------
  ------------------
  404|       |
  405|    473|    p->x.fd = fd;
  406|    473|    p->events = events;
  407|    473|    p->cb = cb;
  408|    473|    p->cb_data = userdata;
  409|       |
  410|    473|    return p;
  411|    473|}
ssh_poll_free:
  420|    473|{
  421|    473|    if (p->ctx != NULL) {
  ------------------
  |  Branch (421:9): [True: 473, False: 0]
  ------------------
  422|    473|        ssh_poll_ctx_remove(p->ctx, p);
  423|    473|        p->ctx = NULL;
  424|    473|    }
  425|       |    SAFE_FREE(p);
  ------------------
  |  |  375|    473|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (375:31): [True: 473, False: 0]
  |  |  |  Branch (375:71): [Folded, False: 473]
  |  |  ------------------
  ------------------
  426|    473|}
ssh_poll_get_ctx:
  436|  1.85k|{
  437|  1.85k|    return p->ctx;
  438|  1.85k|}
ssh_poll_get_events:
  448|  31.2k|{
  449|  31.2k|    return p->events;
  450|  31.2k|}
ssh_poll_set_events:
  461|  32.1k|{
  462|  32.1k|    p->events = events;
  463|  32.1k|    if (p->ctx != NULL) {
  ------------------
  |  Branch (463:9): [True: 31.2k, False: 946]
  ------------------
  464|  31.2k|        if (!ssh_poll_is_locked(p)) {
  ------------------
  |  Branch (464:13): [True: 1.70k, False: 29.5k]
  ------------------
  465|  1.70k|            p->ctx->pollfds[p->x.idx].events = events;
  466|  29.5k|        } else if (!(p->ctx->pollfds[p->x.idx].events & POLLOUT)) {
  ------------------
  |  Branch (466:20): [True: 1.19k, False: 28.3k]
  ------------------
  467|       |            /* if locked, allow only setting POLLOUT to prevent recursive
  468|       |             * callbacks */
  469|       |            p->ctx->pollfds[p->x.idx].events = events & POLLOUT;
  470|  1.19k|        }
  471|  31.2k|    }
  472|  32.1k|}
ssh_poll_add_events:
  498|  31.0k|{
  499|  31.0k|    ssh_poll_set_events(p, ssh_poll_get_events(p) | events);
  500|  31.0k|}
ssh_poll_remove_events:
  510|    153|{
  511|    153|    ssh_poll_set_events(p, ssh_poll_get_events(p) & ~events);
  512|    153|}
ssh_poll_ctx_new:
  560|    473|{
  561|    473|    ssh_poll_ctx ctx;
  562|       |
  563|    473|    ctx = malloc(sizeof(struct ssh_poll_ctx_struct));
  564|    473|    if (ctx == NULL) {
  ------------------
  |  Branch (564:9): [True: 0, False: 473]
  ------------------
  565|      0|        return NULL;
  566|      0|    }
  567|    473|    ZERO_STRUCTP(ctx);
  ------------------
  |  |  381|    473|#define ZERO_STRUCTP(x) do { if ((x) != NULL) memset((x), 0, sizeof(*(x))); } while(0)
  |  |  ------------------
  |  |  |  Branch (381:34): [True: 473, False: 0]
  |  |  |  Branch (381:85): [Folded, False: 473]
  |  |  ------------------
  ------------------
  568|       |
  569|    473|    if (chunk_size == 0) {
  ------------------
  |  Branch (569:9): [True: 0, False: 473]
  ------------------
  570|      0|        chunk_size = SSH_POLL_CTX_CHUNK;
  ------------------
  |  |   43|      0|#define SSH_POLL_CTX_CHUNK			5
  ------------------
  571|      0|    }
  572|       |
  573|    473|    ctx->chunk_size = chunk_size;
  574|       |
  575|    473|    return ctx;
  576|    473|}
ssh_poll_ctx_free:
  584|    473|{
  585|    473|    if (ctx->polls_allocated > 0) {
  ------------------
  |  Branch (585:9): [True: 473, False: 0]
  ------------------
  586|    473|        while (ctx->polls_used > 0) {
  ------------------
  |  Branch (586:16): [True: 0, False: 473]
  ------------------
  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|    473|        SAFE_FREE(ctx->pollptrs);
  ------------------
  |  |  375|    473|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (375:31): [True: 473, False: 0]
  |  |  |  Branch (375:71): [Folded, False: 473]
  |  |  ------------------
  ------------------
  596|    473|        SAFE_FREE(ctx->pollfds);
  ------------------
  |  |  375|    473|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (375:31): [True: 473, False: 0]
  |  |  |  Branch (375:71): [Folded, False: 473]
  |  |  ------------------
  ------------------
  597|    473|    }
  598|       |
  599|       |    SAFE_FREE(ctx);
  ------------------
  |  |  375|    473|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (375:31): [True: 473, False: 0]
  |  |  |  Branch (375:71): [Folded, False: 473]
  |  |  ------------------
  ------------------
  600|    473|}
ssh_poll_ctx_add:
  647|    473|{
  648|    473|    socket_t fd;
  649|       |
  650|    473|    if (p->ctx != NULL) {
  ------------------
  |  Branch (650:9): [True: 0, False: 473]
  ------------------
  651|       |        /* already attached to a context */
  652|      0|        return -1;
  653|      0|    }
  654|       |
  655|    473|    if (ctx->polls_used == ctx->polls_allocated &&
  ------------------
  |  Branch (655:9): [True: 473, False: 0]
  ------------------
  656|    473|        ssh_poll_ctx_resize(ctx, ctx->polls_allocated + ctx->chunk_size) < 0) {
  ------------------
  |  Branch (656:9): [True: 0, False: 473]
  ------------------
  657|      0|        return -1;
  658|      0|    }
  659|       |
  660|    473|    fd = p->x.fd;
  661|    473|    p->x.idx = ctx->polls_used++;
  662|    473|    ctx->pollptrs[p->x.idx] = p;
  663|    473|    ctx->pollfds[p->x.idx].fd = fd;
  664|    473|    ctx->pollfds[p->x.idx].events = p->events;
  665|    473|    ctx->pollfds[p->x.idx].revents = 0;
  666|    473|    p->ctx = ctx;
  667|       |
  668|    473|    return 0;
  669|    473|}
ssh_poll_ctx_remove:
  697|    473|{
  698|    473|    size_t i;
  699|       |
  700|    473|    i = p->x.idx;
  701|    473|    p->x.fd = ctx->pollfds[i].fd;
  702|    473|    p->ctx = NULL;
  703|       |
  704|    473|    ctx->polls_used--;
  705|       |
  706|       |    /* fill the empty poll slot with the last one */
  707|    473|    if (ctx->polls_used > 0 && ctx->polls_used != i) {
  ------------------
  |  Branch (707:9): [True: 0, False: 473]
  |  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|    473|    if (ctx->polls_allocated - ctx->polls_used > ctx->chunk_size) {
  ------------------
  |  Branch (714:9): [True: 0, False: 473]
  ------------------
  715|      0|        ssh_poll_ctx_resize(ctx, ctx->polls_allocated - ctx->chunk_size);
  716|      0|    }
  717|    473|}
ssh_poll_is_locked:
  726|  33.0k|{
  727|  33.0k|    if (p == NULL) {
  ------------------
  |  Branch (727:9): [True: 0, False: 33.0k]
  ------------------
  728|      0|        return false;
  729|      0|    }
  730|  33.0k|    return p->lock_cnt > 0;
  731|  33.0k|}
ssh_poll_ctx_dopoll:
  750|  1.85k|{
  751|  1.85k|    int rc;
  752|  1.85k|    size_t i, used;
  753|  1.85k|    ssh_poll_handle p = NULL;
  754|  1.85k|    socket_t fd;
  755|  1.85k|    int revents;
  756|  1.85k|    struct ssh_timestamp ts;
  757|       |
  758|  1.85k|    if (ctx->polls_used == 0) {
  ------------------
  |  Branch (758:9): [True: 0, False: 1.85k]
  ------------------
  759|      0|        return SSH_ERROR;
  ------------------
  |  |  316|      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|  3.71k|    for (i = 0; i < ctx->polls_used; i++) {
  ------------------
  |  Branch (765:17): [True: 1.85k, False: 1.85k]
  ------------------
  766|       |        /* The lock allows only POLLOUT events: drop the rest */
  767|  1.85k|        if (ssh_poll_is_locked(ctx->pollptrs[i])) {
  ------------------
  |  Branch (767:13): [True: 0, False: 1.85k]
  ------------------
  768|      0|            ctx->pollfds[i].events &= POLLOUT;
  769|      0|        }
  770|  1.85k|    }
  771|  1.85k|    ssh_timestamp_init(&ts);
  772|  1.85k|    do {
  773|  1.85k|        int tm = ssh_timeout_update(&ts, timeout);
  774|  1.85k|        rc = ssh_poll(ctx->pollfds, ctx->polls_used, tm);
  775|  1.85k|    } while (rc == -1 && errno == EINTR);
  ------------------
  |  Branch (775:14): [True: 0, False: 1.85k]
  |  Branch (775:26): [True: 0, False: 0]
  ------------------
  776|       |
  777|  1.85k|    if (rc < 0) {
  ------------------
  |  Branch (777:9): [True: 0, False: 1.85k]
  ------------------
  778|      0|        return SSH_ERROR;
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  779|      0|    }
  780|  1.85k|    if (rc == 0) {
  ------------------
  |  Branch (780:9): [True: 0, False: 1.85k]
  ------------------
  781|      0|        return SSH_AGAIN;
  ------------------
  |  |  317|      0|#define SSH_AGAIN -2 /* The nonblocking call must be repeated */
  ------------------
  782|      0|    }
  783|       |
  784|  1.85k|    used = ctx->polls_used;
  785|  3.55k|    for (i = 0; i < used && rc > 0; ) {
  ------------------
  |  Branch (785:17): [True: 1.85k, False: 1.70k]
  |  Branch (785:29): [True: 1.85k, False: 0]
  ------------------
  786|  1.85k|        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|  1.85k|        if (ctx->pollptrs[i]->lock_cnt > 2) {
  ------------------
  |  Branch (791:13): [True: 0, False: 1.85k]
  ------------------
  792|      0|            revents &= POLLOUT;
  793|      0|        }
  794|  1.85k|        if (revents == 0) {
  ------------------
  |  Branch (794:13): [True: 0, False: 1.85k]
  ------------------
  795|      0|            i++;
  796|  1.85k|        } else {
  797|  1.85k|            int ret;
  798|       |
  799|  1.85k|            p = ctx->pollptrs[i];
  800|  1.85k|            fd = ctx->pollfds[i].fd;
  801|       |            /* avoid having any event caught during callback */
  802|  1.85k|            ctx->pollfds[i].events = 0;
  803|  1.85k|            p->lock_cnt++;
  804|  1.85k|            if (p->cb && (ret = p->cb(p, fd, revents, p->cb_data)) < 0) {
  ------------------
  |  Branch (804:17): [True: 1.85k, False: 0]
  |  Branch (804:26): [True: 153, False: 1.70k]
  ------------------
  805|    153|                if (ret == -2) {
  ------------------
  |  Branch (805:21): [True: 153, False: 0]
  ------------------
  806|    153|                    return -1;
  807|    153|                }
  808|       |                /* the poll was removed, reload the used counter and start again
  809|       |                 */
  810|      0|                used = ctx->polls_used;
  811|      0|                i = 0;
  812|  1.70k|            } else {
  813|  1.70k|                ctx->pollfds[i].revents = 0;
  814|  1.70k|                ctx->pollfds[i].events = p->events;
  815|  1.70k|                p->lock_cnt--;
  816|  1.70k|                i++;
  817|  1.70k|            }
  818|       |
  819|  1.70k|            rc--;
  820|  1.70k|        }
  821|  1.85k|    }
  822|       |
  823|  1.70k|    return rc;
  824|  1.85k|}
ssh_poll_get_default_ctx:
  834|    473|{
  835|    473|    if (session->default_poll_ctx != NULL) {
  ------------------
  |  Branch (835:9): [True: 0, False: 473]
  ------------------
  836|      0|        return session->default_poll_ctx;
  837|      0|    }
  838|       |    /* 2 is enough for the default one */
  839|    473|    session->default_poll_ctx = ssh_poll_ctx_new(2);
  840|    473|    return session->default_poll_ctx;
  841|    473|}
poll.c:ssh_poll_ctx_resize:
  603|    473|{
  604|    473|    ssh_poll_handle *pollptrs = NULL;
  605|    473|    ssh_pollfd_t *pollfds = NULL;
  606|       |
  607|    473|    pollptrs = realloc(ctx->pollptrs, sizeof(ssh_poll_handle) * new_size);
  608|    473|    if (pollptrs == NULL) {
  ------------------
  |  Branch (608:9): [True: 0, False: 473]
  ------------------
  609|       |        /* Fail, but keep the old value to be freed later */
  610|      0|        return SSH_ERROR;
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  611|      0|    }
  612|    473|    ctx->pollptrs = pollptrs;
  613|       |
  614|    473|    pollfds = realloc(ctx->pollfds, sizeof(ssh_pollfd_t) * new_size);
  615|    473|    if (pollfds == NULL) {
  ------------------
  |  Branch (615:9): [True: 0, False: 473]
  ------------------
  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);
  ------------------
  |  |  375|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (375:31): [True: 0, False: 0]
  |  |  |  Branch (375:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
  620|      0|            return SSH_ERROR;
  ------------------
  |  |  316|      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;
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  627|      0|        }
  628|      0|        ctx->pollptrs = pollptrs;
  629|      0|        return SSH_ERROR;
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  630|      0|    }
  631|       |
  632|    473|    ctx->pollfds = pollfds;
  633|    473|    ctx->polls_allocated = new_size;
  634|       |
  635|    473|    return SSH_OK;
  ------------------
  |  |  315|    473|#define SSH_OK 0     /* No error */
  ------------------
  636|    473|}

ssh_new:
   66|    930|{
   67|    930|    ssh_session session = NULL;
   68|    930|    char *id = NULL;
   69|    930|    int rc;
   70|       |
   71|    930|    session = calloc(1, sizeof (struct ssh_session_struct));
   72|    930|    if (session == NULL) {
  ------------------
  |  Branch (72:9): [True: 230, False: 700]
  ------------------
   73|    230|        return NULL;
   74|    230|    }
   75|       |
   76|    700|    session->next_crypto = crypto_new();
   77|    700|    if (session->next_crypto == NULL) {
  ------------------
  |  Branch (77:9): [True: 116, False: 584]
  ------------------
   78|    116|        goto err;
   79|    116|    }
   80|       |
   81|    584|    session->socket = ssh_socket_new(session);
   82|    584|    if (session->socket == NULL) {
  ------------------
  |  Branch (82:9): [True: 105, False: 479]
  ------------------
   83|    105|        goto err;
   84|    105|    }
   85|       |
   86|    479|    session->out_buffer = ssh_buffer_new();
   87|    479|    if (session->out_buffer == NULL) {
  ------------------
  |  Branch (87:9): [True: 4, False: 475]
  ------------------
   88|      4|        goto err;
   89|      4|    }
   90|       |
   91|    475|    session->in_buffer = ssh_buffer_new();
   92|    475|    if (session->in_buffer == NULL) {
  ------------------
  |  Branch (92:9): [True: 1, False: 474]
  ------------------
   93|      1|        goto err;
   94|      1|    }
   95|       |
   96|    474|    session->out_queue = ssh_list_new();
   97|    474|    if (session->out_queue == NULL) {
  ------------------
  |  Branch (97:9): [True: 1, False: 473]
  ------------------
   98|      1|        goto err;
   99|      1|    }
  100|       |
  101|    473|    session->alive = 0;
  102|    473|    session->auth.supported_methods = 0;
  103|    473|    ssh_set_blocking(session, 1);
  104|    473|    session->maxchannel = FIRST_CHANNEL;
  ------------------
  |  |   49|    473|#define FIRST_CHANNEL 42 // why not ? it helps to find bugs.
  ------------------
  105|    473|    session->proxy_root = true;
  106|       |
  107|    473|    session->agent = ssh_agent_new(session);
  108|    473|    if (session->agent == NULL) {
  ------------------
  |  Branch (108:9): [True: 0, False: 473]
  ------------------
  109|      0|        goto err;
  110|      0|    }
  111|       |
  112|       |    /* Initialise a default PKI context */
  113|    473|    session->pki_context = ssh_pki_ctx_new();
  114|    473|    if (session->pki_context == NULL) {
  ------------------
  |  Branch (114:9): [True: 0, False: 473]
  ------------------
  115|      0|        goto err;
  116|      0|    }
  117|       |
  118|       |    /* OPTIONS */
  119|    473|    session->opts.StrictHostKeyChecking = SSH_STRICT_HOSTKEY_ASK;
  120|    473|    session->opts.port = 22;
  121|    473|    session->opts.fd = -1;
  122|    473|    session->opts.compressionlevel = 7;
  123|    473|    session->opts.nodelay = 0;
  124|    473|    session->opts.identities_only = false;
  125|    473|    session->opts.server_alive_interval = 0;
  126|    473|    session->opts.server_alive_count_max = 3;
  127|    473|    session->opts.batch_mode = false;
  128|    473|    session->opts.gateway_ports = false;
  129|    473|    session->opts.control_master = SSH_CONTROL_MASTER_NO;
  130|       |
  131|    473|    session->opts.flags = SSH_OPT_FLAG_PASSWORD_AUTH |
  ------------------
  |  |  109|    473|#define SSH_OPT_FLAG_PASSWORD_AUTH 0x1
  ------------------
  132|    473|                          SSH_OPT_FLAG_PUBKEY_AUTH |
  ------------------
  |  |  110|    473|#define SSH_OPT_FLAG_PUBKEY_AUTH 0x2
  ------------------
  133|    473|                          SSH_OPT_FLAG_KBDINT_AUTH |
  ------------------
  |  |  111|    473|#define SSH_OPT_FLAG_KBDINT_AUTH 0x4
  ------------------
  134|    473|                          SSH_OPT_FLAG_GSSAPI_AUTH;
  ------------------
  |  |  112|    473|#define SSH_OPT_FLAG_GSSAPI_AUTH 0x8
  ------------------
  135|    473|    session->opts.pubkey_auth = SSH_PUBKEY_AUTH_ALL;
  136|       |
  137|    473|    session->opts.exp_flags = 0;
  138|       |
  139|       |#ifdef WITH_GSSAPI
  140|       |    session->opts.gssapi_key_exchange_algs =
  141|       |        strdup(GSSAPI_KEY_EXCHANGE_SUPPORTED);
  142|       |    if (session->opts.gssapi_key_exchange_algs == NULL) {
  143|       |        goto err;
  144|       |    }
  145|       |#endif /* WITH_GSSAPI */
  146|       |
  147|       |    /* Lazy allocation for identity_non_exp before populating the defaults */
  148|    473|    if (session->opts.identity_non_exp == NULL) {
  ------------------
  |  Branch (148:9): [True: 473, False: 0]
  ------------------
  149|    473|        session->opts.identity_non_exp = ssh_list_new();
  150|    473|        if (session->opts.identity_non_exp == NULL) {
  ------------------
  |  Branch (150:13): [True: 0, False: 473]
  ------------------
  151|      0|            goto err;
  152|      0|        }
  153|    473|    }
  154|       |
  155|    473|    id = strdup("%d/.ssh/id_ed25519");
  156|    473|    if (id == NULL) {
  ------------------
  |  Branch (156:9): [True: 0, False: 473]
  ------------------
  157|      0|        goto err;
  158|      0|    }
  159|       |
  160|    473|    rc = ssh_list_append(session->opts.identity_non_exp, id);
  161|    473|    if (rc == SSH_ERROR) {
  ------------------
  |  |  316|    473|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  |  Branch (161:9): [True: 0, False: 473]
  ------------------
  162|      0|        goto err;
  163|      0|    }
  164|       |
  165|    473|#ifdef HAVE_ECC
  166|    473|    id = strdup("%d/.ssh/id_ecdsa");
  167|    473|    if (id == NULL) {
  ------------------
  |  Branch (167:9): [True: 0, False: 473]
  ------------------
  168|      0|        goto err;
  169|      0|    }
  170|    473|    rc = ssh_list_append(session->opts.identity_non_exp, id);
  171|    473|    if (rc == SSH_ERROR) {
  ------------------
  |  |  316|    473|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  |  Branch (171:9): [True: 0, False: 473]
  ------------------
  172|      0|        goto err;
  173|      0|    }
  174|    473|#endif
  175|       |
  176|    473|    id = strdup("%d/.ssh/id_rsa");
  177|    473|    if (id == NULL) {
  ------------------
  |  Branch (177:9): [True: 0, False: 473]
  ------------------
  178|      0|        goto err;
  179|      0|    }
  180|    473|    rc = ssh_list_append(session->opts.identity_non_exp, id);
  181|    473|    if (rc == SSH_ERROR) {
  ------------------
  |  |  316|    473|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  |  Branch (181:9): [True: 0, False: 473]
  ------------------
  182|      0|        goto err;
  183|      0|    }
  184|       |
  185|       |#ifdef WITH_FIDO2
  186|       |    /* Add security key identities */
  187|       |    id = strdup("%d/.ssh/id_ed25519_sk");
  188|       |    if (id == NULL) {
  189|       |        goto err;
  190|       |    }
  191|       |    rc = ssh_list_append(session->opts.identity_non_exp, id);
  192|       |    if (rc == SSH_ERROR) {
  193|       |        goto err;
  194|       |    }
  195|       |
  196|       |#ifdef HAVE_ECC
  197|       |    id = strdup("%d/.ssh/id_ecdsa_sk");
  198|       |    if (id == NULL) {
  199|       |        goto err;
  200|       |    }
  201|       |    rc = ssh_list_append(session->opts.identity_non_exp, id);
  202|       |    if (rc == SSH_ERROR) {
  203|       |        goto err;
  204|       |    }
  205|       |#endif /* HAVE_ECC */
  206|       |#endif /* WITH_FIDO2 */
  207|       |
  208|       |    /* Explicitly initialize states */
  209|    473|    session->session_state = SSH_SESSION_STATE_NONE;
  210|    473|    session->pending_call_state = SSH_PENDING_CALL_NONE;
  211|    473|    session->packet_state = PACKET_STATE_INIT;
  212|    473|    session->dh_handshake_state = DH_STATE_INIT;
  213|    473|    session->global_req_state = SSH_CHANNEL_REQ_STATE_NONE;
  214|       |
  215|    473|    session->auth.state = SSH_AUTH_STATE_NONE;
  216|    473|    session->auth.service_state = SSH_AUTH_SERVICE_NONE;
  217|       |
  218|    473|    return session;
  219|       |
  220|    227|err:
  221|    227|    free(id);
  222|    227|    ssh_free(session);
  223|       |    return NULL;
  224|    473|}
ssh_free:
  235|  1.15k|{
  236|  1.15k|  int i;
  237|  1.15k|  struct ssh_iterator *it = NULL;
  238|  1.15k|  struct ssh_buffer_struct *b = NULL;
  239|       |
  240|  1.15k|  if (session == NULL) {
  ------------------
  |  Branch (240:7): [True: 457, False: 700]
  ------------------
  241|    457|    return;
  242|    457|  }
  243|       |
  244|       |  /*
  245|       |   * Delete all channels
  246|       |   *
  247|       |   * This needs the first thing we clean up cause if there is still an open
  248|       |   * channel we call ssh_channel_close() first. So we need a working socket
  249|       |   * and poll context for it.
  250|       |   */
  251|    700|  for (it = ssh_list_get_iterator(session->channels);
  252|    700|       it != NULL;
  ------------------
  |  Branch (252:8): [True: 0, False: 700]
  ------------------
  253|    700|       it = ssh_list_get_iterator(session->channels)) {
  254|      0|      ssh_channel_do_free(ssh_iterator_value(ssh_channel,it));
  ------------------
  |  |  122|      0|  ((type)((iterator)->data))
  ------------------
  255|      0|      ssh_list_remove(session->channels, it);
  256|      0|  }
  257|    700|  ssh_list_free(session->channels);
  258|    700|  session->channels = NULL;
  259|       |
  260|    700|#ifdef WITH_PCAP
  261|    700|  if (session->pcap_ctx) {
  ------------------
  |  Branch (261:7): [True: 0, False: 700]
  ------------------
  262|      0|      ssh_pcap_context_free(session->pcap_ctx);
  263|      0|      session->pcap_ctx = NULL;
  264|      0|  }
  265|    700|#endif
  266|       |
  267|    700|  ssh_socket_free(session->socket);
  268|    700|  session->socket = NULL;
  269|       |
  270|    700|  if (session->default_poll_ctx) {
  ------------------
  |  Branch (270:7): [True: 473, False: 227]
  ------------------
  271|    473|      ssh_poll_ctx_free(session->default_poll_ctx);
  272|    473|  }
  273|       |
  274|    700|  SSH_BUFFER_FREE(session->in_buffer);
  ------------------
  |  |  924|    700|    do { if ((x) != NULL) { ssh_buffer_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (924:14): [True: 474, False: 226]
  |  |  |  Branch (924:69): [Folded, False: 700]
  |  |  ------------------
  ------------------
  275|    700|  SSH_BUFFER_FREE(session->out_buffer);
  ------------------
  |  |  924|    700|    do { if ((x) != NULL) { ssh_buffer_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (924:14): [True: 475, False: 225]
  |  |  |  Branch (924:69): [Folded, False: 700]
  |  |  ------------------
  ------------------
  276|    700|  session->in_buffer = session->out_buffer = NULL;
  277|       |
  278|    700|  if (session->in_hashbuf != NULL) {
  ------------------
  |  Branch (278:7): [True: 234, False: 466]
  ------------------
  279|    234|      SSH_BUFFER_FREE(session->in_hashbuf);
  ------------------
  |  |  924|    234|    do { if ((x) != NULL) { ssh_buffer_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (924:14): [True: 234, False: 0]
  |  |  |  Branch (924:69): [Folded, False: 234]
  |  |  ------------------
  ------------------
  280|    234|  }
  281|    700|  if (session->out_hashbuf != NULL) {
  ------------------
  |  Branch (281:7): [True: 384, False: 316]
  ------------------
  282|    384|      SSH_BUFFER_FREE(session->out_hashbuf);
  ------------------
  |  |  924|    384|    do { if ((x) != NULL) { ssh_buffer_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (924:14): [True: 384, False: 0]
  |  |  |  Branch (924:69): [Folded, False: 384]
  |  |  ------------------
  ------------------
  283|    384|  }
  284|       |
  285|    700|  crypto_free(session->current_crypto);
  286|    700|  crypto_free(session->next_crypto);
  287|       |
  288|    700|  ssh_agent_free(session->agent);
  289|       |
  290|    700|  SSH_PKI_CTX_FREE(session->pki_context);
  ------------------
  |  | 1017|    700|    do {                         \
  |  | 1018|    700|        if ((x) != NULL) {       \
  |  |  ------------------
  |  |  |  Branch (1018:13): [True: 473, False: 227]
  |  |  ------------------
  |  | 1019|    473|            ssh_pki_ctx_free(x); \
  |  | 1020|    473|            x = NULL;            \
  |  | 1021|    473|        }                        \
  |  | 1022|    700|    } while (0)
  |  |  ------------------
  |  |  |  Branch (1022:14): [Folded, False: 700]
  |  |  ------------------
  ------------------
  291|       |
  292|    700|  ssh_key_free(session->srv.rsa_key);
  293|    700|  session->srv.rsa_key = NULL;
  294|    700|  ssh_key_free(session->srv.ecdsa_key);
  295|    700|  session->srv.ecdsa_key = NULL;
  296|    700|  ssh_key_free(session->srv.ed25519_key);
  297|    700|  session->srv.ed25519_key = NULL;
  298|       |
  299|    700|  if (session->ssh_message_list) {
  ------------------
  |  Branch (299:7): [True: 0, False: 700]
  ------------------
  300|      0|      ssh_message msg;
  301|       |
  302|      0|      for (msg = ssh_list_pop_head(ssh_message, session->ssh_message_list);
  ------------------
  |  |  130|      0|  ((type)_ssh_list_pop_head(ssh_list))
  ------------------
  303|      0|           msg != NULL;
  ------------------
  |  Branch (303:12): [True: 0, False: 0]
  ------------------
  304|      0|           msg = ssh_list_pop_head(ssh_message, session->ssh_message_list)) {
  ------------------
  |  |  130|      0|  ((type)_ssh_list_pop_head(ssh_list))
  ------------------
  305|      0|          ssh_message_free(msg);
  306|      0|      }
  307|      0|      ssh_list_free(session->ssh_message_list);
  308|      0|  }
  309|       |
  310|    700|  if (session->kbdint != NULL) {
  ------------------
  |  Branch (310:7): [True: 0, False: 700]
  ------------------
  311|      0|    ssh_kbdint_free(session->kbdint);
  312|      0|  }
  313|       |
  314|    700|  if (session->packet_callbacks) {
  ------------------
  |  Branch (314:7): [True: 0, False: 700]
  ------------------
  315|      0|    ssh_list_free(session->packet_callbacks);
  316|      0|  }
  317|       |
  318|       |#ifdef WITH_GSSAPI
  319|       |    ssh_gssapi_free(session);
  320|       |    SAFE_FREE(session->opts.gssapi_key_exchange_algs);
  321|       |#endif
  322|       |
  323|       |  /* options */
  324|    700|  if (session->opts.identity) {
  ------------------
  |  Branch (324:7): [True: 473, False: 227]
  ------------------
  325|    473|      char *id = NULL;
  326|       |
  327|    473|      for (id = ssh_list_pop_head(char *, session->opts.identity);
  ------------------
  |  |  130|    473|  ((type)_ssh_list_pop_head(ssh_list))
  ------------------
  328|  1.89k|           id != NULL;
  ------------------
  |  Branch (328:12): [True: 1.41k, False: 473]
  ------------------
  329|  1.41k|           id = ssh_list_pop_head(char *, session->opts.identity)) {
  ------------------
  |  |  130|  1.41k|  ((type)_ssh_list_pop_head(ssh_list))
  ------------------
  330|  1.41k|          SAFE_FREE(id);
  ------------------
  |  |  375|  1.41k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (375:31): [True: 1.41k, False: 0]
  |  |  |  Branch (375:71): [Folded, False: 1.41k]
  |  |  ------------------
  ------------------
  331|  1.41k|      }
  332|    473|      ssh_list_free(session->opts.identity);
  333|    473|  }
  334|       |
  335|    700|  if (session->opts.identity_non_exp) {
  ------------------
  |  Branch (335:7): [True: 473, False: 227]
  ------------------
  336|    473|      char *id = NULL;
  337|       |
  338|    473|      for (id = ssh_list_pop_head(char *, session->opts.identity_non_exp);
  ------------------
  |  |  130|    473|  ((type)_ssh_list_pop_head(ssh_list))
  ------------------
  339|    473|           id != NULL;
  ------------------
  |  Branch (339:12): [True: 0, False: 473]
  ------------------
  340|    473|           id = ssh_list_pop_head(char *, session->opts.identity_non_exp)) {
  ------------------
  |  |  130|      0|  ((type)_ssh_list_pop_head(ssh_list))
  ------------------
  341|      0|          SAFE_FREE(id);
  ------------------
  |  |  375|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (375:31): [True: 0, False: 0]
  |  |  |  Branch (375:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
  342|      0|      }
  343|    473|      ssh_list_free(session->opts.identity_non_exp);
  344|    473|  }
  345|       |
  346|    700|    if (session->opts.certificate) {
  ------------------
  |  Branch (346:9): [True: 473, False: 227]
  ------------------
  347|    473|        char *cert = NULL;
  348|       |
  349|    473|        for (cert = ssh_list_pop_head(char *, session->opts.certificate);
  ------------------
  |  |  130|    473|  ((type)_ssh_list_pop_head(ssh_list))
  ------------------
  350|    473|             cert != NULL;
  ------------------
  |  Branch (350:14): [True: 0, False: 473]
  ------------------
  351|    473|             cert = ssh_list_pop_head(char *, session->opts.certificate)) {
  ------------------
  |  |  130|      0|  ((type)_ssh_list_pop_head(ssh_list))
  ------------------
  352|      0|            SAFE_FREE(cert);
  ------------------
  |  |  375|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (375:31): [True: 0, False: 0]
  |  |  |  Branch (375:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
  353|      0|        }
  354|    473|        ssh_list_free(session->opts.certificate);
  355|    473|    }
  356|       |
  357|    700|    if (session->opts.certificate_non_exp) {
  ------------------
  |  Branch (357:9): [True: 0, False: 700]
  ------------------
  358|      0|        char *cert = NULL;
  359|       |
  360|      0|        for (cert = ssh_list_pop_head(char *, session->opts.certificate_non_exp);
  ------------------
  |  |  130|      0|  ((type)_ssh_list_pop_head(ssh_list))
  ------------------
  361|      0|             cert != NULL;
  ------------------
  |  Branch (361:14): [True: 0, False: 0]
  ------------------
  362|      0|             cert = ssh_list_pop_head(char *, session->opts.certificate_non_exp)) {
  ------------------
  |  |  130|      0|  ((type)_ssh_list_pop_head(ssh_list))
  ------------------
  363|      0|            SAFE_FREE(cert);
  ------------------
  |  |  375|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (375:31): [True: 0, False: 0]
  |  |  |  Branch (375:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
  364|      0|        }
  365|      0|        ssh_list_free(session->opts.certificate_non_exp);
  366|      0|    }
  367|       |
  368|    700|    ssh_proxyjumps_free(session->opts.proxy_jumps);
  369|    700|    SSH_LIST_FREE(session->opts.proxy_jumps);
  ------------------
  |  |  133|    700|    do { if ((x) != NULL) { ssh_list_free(x); (x) = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (133:14): [True: 0, False: 700]
  |  |  |  Branch (133:69): [Folded, False: 700]
  |  |  ------------------
  ------------------
  370|    700|    SSH_LIST_FREE(session->opts.proxy_jumps_user_cb);
  ------------------
  |  |  133|    700|    do { if ((x) != NULL) { ssh_list_free(x); (x) = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (133:14): [True: 0, False: 700]
  |  |  |  Branch (133:69): [Folded, False: 700]
  |  |  ------------------
  ------------------
  371|    700|    SAFE_FREE(session->opts.proxy_jumps_str);
  ------------------
  |  |  375|    700|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (375:31): [True: 0, False: 700]
  |  |  |  Branch (375:71): [Folded, False: 700]
  |  |  ------------------
  ------------------
  372|       |
  373|    700|    if (session->opts.send_env) {
  ------------------
  |  Branch (373:9): [True: 0, False: 700]
  ------------------
  374|      0|        char *pattern = NULL;
  375|       |
  376|      0|        for (pattern = ssh_list_pop_head(char *, session->opts.send_env);
  ------------------
  |  |  130|      0|  ((type)_ssh_list_pop_head(ssh_list))
  ------------------
  377|      0|             pattern != NULL;
  ------------------
  |  Branch (377:14): [True: 0, False: 0]
  ------------------
  378|      0|             pattern = ssh_list_pop_head(char *, session->opts.send_env)) {
  ------------------
  |  |  130|      0|  ((type)_ssh_list_pop_head(ssh_list))
  ------------------
  379|      0|            SAFE_FREE(pattern);
  ------------------
  |  |  375|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (375:31): [True: 0, False: 0]
  |  |  |  Branch (375:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
  380|      0|        }
  381|      0|        ssh_list_free(session->opts.send_env);
  382|      0|    }
  383|       |
  384|    700|    while ((b = ssh_list_pop_head(struct ssh_buffer_struct *,
  ------------------
  |  |  130|    700|  ((type)_ssh_list_pop_head(ssh_list))
  ------------------
  |  Branch (384:12): [True: 0, False: 700]
  ------------------
  385|    700|                                  session->out_queue)) != NULL) {
  386|      0|        SSH_BUFFER_FREE(b);
  ------------------
  |  |  924|      0|    do { if ((x) != NULL) { ssh_buffer_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (924:14): [True: 0, False: 0]
  |  |  |  Branch (924:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
  387|      0|    }
  388|    700|    ssh_list_free(session->out_queue);
  389|       |
  390|    700|  ssh_agent_state_free(session->agent_state);
  391|    700|  session->agent_state = NULL;
  392|       |
  393|    700|  SAFE_FREE(session->auth.auto_state);
  ------------------
  |  |  375|    700|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (375:31): [True: 0, False: 700]
  |  |  |  Branch (375:71): [Folded, False: 700]
  |  |  ------------------
  ------------------
  394|    700|  SAFE_FREE(session->serverbanner);
  ------------------
  |  |  375|    700|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (375:31): [True: 0, False: 700]
  |  |  |  Branch (375:71): [Folded, False: 700]
  |  |  ------------------
  ------------------
  395|    700|  SAFE_FREE(session->clientbanner);
  ------------------
  |  |  375|    700|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (375:31): [True: 0, False: 700]
  |  |  |  Branch (375:71): [Folded, False: 700]
  |  |  ------------------
  ------------------
  396|    700|  SAFE_FREE(session->banner);
  ------------------
  |  |  375|    700|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (375:31): [True: 0, False: 700]
  |  |  |  Branch (375:71): [Folded, False: 700]
  |  |  ------------------
  ------------------
  397|    700|  SAFE_FREE(session->disconnect_message);
  ------------------
  |  |  375|    700|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (375:31): [True: 0, False: 700]
  |  |  |  Branch (375:71): [Folded, False: 700]
  |  |  ------------------
  ------------------
  398|    700|  SAFE_FREE(session->peer_discon_msg);
  ------------------
  |  |  375|    700|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (375:31): [True: 2, False: 698]
  |  |  |  Branch (375:71): [Folded, False: 700]
  |  |  ------------------
  ------------------
  399|       |
  400|    700|  SAFE_FREE(session->opts.agent_socket);
  ------------------
  |  |  375|    700|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (375:31): [True: 0, False: 700]
  |  |  |  Branch (375:71): [Folded, False: 700]
  |  |  ------------------
  ------------------
  401|    700|  SAFE_FREE(session->opts.bindaddr);
  ------------------
  |  |  375|    700|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (375:31): [True: 0, False: 700]
  |  |  |  Branch (375:71): [Folded, False: 700]
  |  |  ------------------
  ------------------
  402|    700|  SAFE_FREE(session->opts.username);
  ------------------
  |  |  375|    700|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (375:31): [True: 473, False: 227]
  |  |  |  Branch (375:71): [Folded, False: 700]
  |  |  ------------------
  ------------------
  403|    700|  SAFE_FREE(session->opts.host);
  ------------------
  |  |  375|    700|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (375:31): [True: 473, False: 227]
  |  |  |  Branch (375:71): [Folded, False: 700]
  |  |  ------------------
  ------------------
  404|    700|  SAFE_FREE(session->opts.originalhost);
  ------------------
  |  |  375|    700|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (375:31): [True: 473, False: 227]
  |  |  |  Branch (375:71): [Folded, False: 700]
  |  |  ------------------
  ------------------
  405|    700|  SAFE_FREE(session->opts.config_hostname);
  ------------------
  |  |  375|    700|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (375:31): [True: 0, False: 700]
  |  |  |  Branch (375:71): [Folded, False: 700]
  |  |  ------------------
  ------------------
  406|    700|  SAFE_FREE(session->opts.tag);
  ------------------
  |  |  375|    700|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (375:31): [True: 0, False: 700]
  |  |  |  Branch (375:71): [Folded, False: 700]
  |  |  ------------------
  ------------------
  407|    700|  SAFE_FREE(session->opts.homedir);
  ------------------
  |  |  375|    700|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (375:31): [True: 473, False: 227]
  |  |  |  Branch (375:71): [Folded, False: 700]
  |  |  ------------------
  ------------------
  408|    700|  SAFE_FREE(session->opts.sshdir);
  ------------------
  |  |  375|    700|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (375:31): [True: 473, False: 227]
  |  |  |  Branch (375:71): [Folded, False: 700]
  |  |  ------------------
  ------------------
  409|    700|  SAFE_FREE(session->opts.knownhosts);
  ------------------
  |  |  375|    700|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (375:31): [True: 473, False: 227]
  |  |  |  Branch (375:71): [Folded, False: 700]
  |  |  ------------------
  ------------------
  410|    700|  SAFE_FREE(session->opts.global_knownhosts);
  ------------------
  |  |  375|    700|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (375:31): [True: 473, False: 227]
  |  |  |  Branch (375:71): [Folded, False: 700]
  |  |  ------------------
  ------------------
  411|    700|  SAFE_FREE(session->opts.ProxyCommand);
  ------------------
  |  |  375|    700|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (375:31): [True: 0, False: 700]
  |  |  |  Branch (375:71): [Folded, False: 700]
  |  |  ------------------
  ------------------
  412|    700|  SAFE_FREE(session->opts.gss_server_identity);
  ------------------
  |  |  375|    700|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (375:31): [True: 0, False: 700]
  |  |  |  Branch (375:71): [Folded, False: 700]
  |  |  ------------------
  ------------------
  413|    700|  SAFE_FREE(session->opts.gss_client_identity);
  ------------------
  |  |  375|    700|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (375:31): [True: 0, False: 700]
  |  |  |  Branch (375:71): [Folded, False: 700]
  |  |  ------------------
  ------------------
  414|    700|  SAFE_FREE(session->opts.pubkey_accepted_types);
  ------------------
  |  |  375|    700|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (375:31): [True: 0, False: 700]
  |  |  |  Branch (375:71): [Folded, False: 700]
  |  |  ------------------
  ------------------
  415|    700|  SAFE_FREE(session->opts.control_path);
  ------------------
  |  |  375|    700|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (375:31): [True: 0, False: 700]
  |  |  |  Branch (375:71): [Folded, False: 700]
  |  |  ------------------
  ------------------
  416|    700|  SAFE_FREE(session->opts.preferred_authentications);
  ------------------
  |  |  375|    700|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (375:31): [True: 0, False: 700]
  |  |  |  Branch (375:71): [Folded, False: 700]
  |  |  ------------------
  ------------------
  417|    700|  SAFE_FREE(session->opts.forward_agent_sock_path);
  ------------------
  |  |  375|    700|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (375:31): [True: 0, False: 700]
  |  |  |  Branch (375:71): [Folded, False: 700]
  |  |  ------------------
  ------------------
  418|       |
  419|    700|  if (session->opts.local_forward) {
  ------------------
  |  Branch (419:7): [True: 0, False: 700]
  ------------------
  420|      0|      char *entry = NULL;
  421|       |
  422|      0|      for (entry = ssh_list_pop_head(char *, session->opts.local_forward);
  ------------------
  |  |  130|      0|  ((type)_ssh_list_pop_head(ssh_list))
  ------------------
  423|      0|           entry != NULL;
  ------------------
  |  Branch (423:12): [True: 0, False: 0]
  ------------------
  424|      0|           entry = ssh_list_pop_head(char *, session->opts.local_forward)) {
  ------------------
  |  |  130|      0|  ((type)_ssh_list_pop_head(ssh_list))
  ------------------
  425|      0|          SAFE_FREE(entry);
  ------------------
  |  |  375|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (375:31): [True: 0, False: 0]
  |  |  |  Branch (375:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
  426|      0|      }
  427|      0|      ssh_list_free(session->opts.local_forward);
  428|      0|  }
  429|       |
  430|    700|  if (session->opts.remote_forward) {
  ------------------
  |  Branch (430:7): [True: 0, False: 700]
  ------------------
  431|      0|      char *entry = NULL;
  432|       |
  433|      0|      for (entry = ssh_list_pop_head(char *, session->opts.remote_forward);
  ------------------
  |  |  130|      0|  ((type)_ssh_list_pop_head(ssh_list))
  ------------------
  434|      0|           entry != NULL;
  ------------------
  |  Branch (434:12): [True: 0, False: 0]
  ------------------
  435|      0|           entry = ssh_list_pop_head(char *, session->opts.remote_forward)) {
  ------------------
  |  |  130|      0|  ((type)_ssh_list_pop_head(ssh_list))
  ------------------
  436|      0|          SAFE_FREE(entry);
  ------------------
  |  |  375|      0|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (375:31): [True: 0, False: 0]
  |  |  |  Branch (375:71): [Folded, False: 0]
  |  |  ------------------
  ------------------
  437|      0|      }
  438|      0|      ssh_list_free(session->opts.remote_forward);
  439|      0|  }
  440|       |
  441|  7.70k|  for (i = 0; i < SSH_KEX_METHODS; i++) {
  ------------------
  |  |   27|  7.70k|#define SSH_KEX_METHODS 10
  ------------------
  |  Branch (441:15): [True: 7.00k, False: 700]
  ------------------
  442|  7.00k|      if (session->opts.wanted_methods[i]) {
  ------------------
  |  Branch (442:11): [True: 1.89k, False: 5.10k]
  ------------------
  443|  1.89k|          SAFE_FREE(session->opts.wanted_methods[i]);
  ------------------
  |  |  375|  1.89k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (375:31): [True: 1.89k, False: 0]
  |  |  |  Branch (375:71): [Folded, False: 1.89k]
  |  |  ------------------
  ------------------
  444|  1.89k|      }
  445|  7.00k|  }
  446|       |
  447|    700|  SAFE_FREE(session->server_opts.custombanner);
  ------------------
  |  |  375|    700|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (375:31): [True: 0, False: 700]
  |  |  |  Branch (375:71): [Folded, False: 700]
  |  |  ------------------
  ------------------
  448|    700|  SAFE_FREE(session->server_opts.moduli_file);
  ------------------
  |  |  375|    700|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (375:31): [True: 0, False: 700]
  |  |  |  Branch (375:71): [Folded, False: 700]
  |  |  ------------------
  ------------------
  449|       |
  450|    700|  _ssh_remove_legacy_log_cb();
  451|       |
  452|       |  /* burn connection, it could contain sensitive data */
  453|    700|  ssh_burn(session, sizeof(struct ssh_session_struct));
  ------------------
  |  |  390|    700|#define ssh_burn(ptr, len) explicit_bzero((ptr), (len))
  ------------------
  454|       |  SAFE_FREE(session);
  ------------------
  |  |  375|    700|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (375:31): [True: 700, False: 0]
  |  |  |  Branch (375:71): [Folded, False: 700]
  |  |  ------------------
  ------------------
  455|    700|}
ssh_session_socket_close:
  635|    721|{
  636|    721|    if (session->opts.fd == SSH_INVALID_SOCKET) {
  ------------------
  |  |  123|    721|#define SSH_INVALID_SOCKET ((socket_t) -1)
  ------------------
  |  Branch (636:9): [True: 0, False: 721]
  ------------------
  637|      0|        ssh_socket_close(session->socket);
  638|      0|    }
  639|    721|    session->alive = 0;
  640|    721|    session->session_state = SSH_SESSION_STATE_ERROR;
  641|    721|}
ssh_set_blocking:
  669|    473|{
  670|    473|    if (session == NULL) {
  ------------------
  |  Branch (670:9): [True: 0, False: 473]
  ------------------
  671|      0|        return;
  672|      0|    }
  673|    473|    session->flags &= ~SSH_SESSION_FLAG_BLOCKING;
  ------------------
  |  |   75|    473|#define SSH_SESSION_FLAG_BLOCKING 0x0001
  ------------------
  674|    473|    session->flags |= blocking ? SSH_SESSION_FLAG_BLOCKING : 0;
  ------------------
  |  |   75|    473|#define SSH_SESSION_FLAG_BLOCKING 0x0001
  ------------------
  |  Branch (674:23): [True: 473, False: 0]
  ------------------
  675|    473|}
ssh_is_blocking:
  684|    946|{
  685|    946|    return (session->flags & SSH_SESSION_FLAG_BLOCKING) ? 1 : 0;
  ------------------
  |  |   75|    946|#define SSH_SESSION_FLAG_BLOCKING 0x0001
  ------------------
  |  Branch (685:12): [True: 946, False: 0]
  ------------------
  686|    946|}
ssh_set_fd_towrite:
  778|    473|void ssh_set_fd_towrite(ssh_session session) {
  779|    473|  if (session == NULL) {
  ------------------
  |  Branch (779:7): [True: 0, False: 473]
  ------------------
  780|      0|    return;
  781|      0|  }
  782|       |
  783|    473|  ssh_socket_set_write_wontblock(session->socket);
  784|    473|}
ssh_handle_packets:
  821|  1.85k|{
  822|  1.85k|    ssh_poll_handle spoll = NULL;
  823|  1.85k|    ssh_poll_ctx ctx = NULL;
  824|  1.85k|    int tm = timeout;
  825|  1.85k|    int rc;
  826|       |
  827|  1.85k|    if (session == NULL || session->socket == NULL) {
  ------------------
  |  Branch (827:9): [True: 0, False: 1.85k]
  |  Branch (827:28): [True: 0, False: 1.85k]
  ------------------
  828|      0|        return SSH_ERROR;
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  829|      0|    }
  830|       |
  831|  1.85k|    spoll = ssh_socket_get_poll_handle(session->socket);
  832|  1.85k|    if (spoll == NULL) {
  ------------------
  |  Branch (832:9): [True: 0, False: 1.85k]
  ------------------
  833|      0|        ssh_set_error_oom(session);
  ------------------
  |  |  320|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
  834|      0|        return SSH_ERROR;
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  835|      0|    }
  836|  1.85k|    ssh_poll_add_events(spoll, POLLIN);
  837|  1.85k|    ctx = ssh_poll_get_ctx(spoll);
  838|       |
  839|  1.85k|    if (ctx == NULL) {
  ------------------
  |  Branch (839:9): [True: 473, False: 1.38k]
  ------------------
  840|    473|        ctx = ssh_poll_get_default_ctx(session);
  841|    473|        if (ctx == NULL) {
  ------------------
  |  Branch (841:13): [True: 0, False: 473]
  ------------------
  842|      0|            ssh_set_error_oom(session);
  ------------------
  |  |  320|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
  843|      0|            return SSH_ERROR;
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  844|      0|        }
  845|    473|        rc = ssh_poll_ctx_add(ctx, spoll);
  846|    473|        if (rc != SSH_OK) {
  ------------------
  |  |  315|    473|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (846:13): [True: 0, False: 473]
  ------------------
  847|      0|            return SSH_ERROR;
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  848|      0|        }
  849|    473|    }
  850|       |
  851|  1.85k|    if (timeout == SSH_TIMEOUT_USER) {
  ------------------
  |  |  101|  1.85k|#define SSH_TIMEOUT_USER -2
  ------------------
  |  Branch (851:9): [True: 0, False: 1.85k]
  ------------------
  852|      0|        if (ssh_is_blocking(session)) {
  ------------------
  |  Branch (852:13): [True: 0, False: 0]
  ------------------
  853|      0|            tm = ssh_make_milliseconds(session->opts.timeout,
  854|      0|                                       session->opts.timeout_usec);
  855|      0|        } else {
  856|      0|            tm = 0;
  857|      0|        }
  858|      0|    }
  859|  1.85k|    rc = ssh_poll_ctx_dopoll(ctx, tm);
  860|  1.85k|    if (rc == SSH_ERROR) {
  ------------------
  |  |  316|  1.85k|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  |  Branch (860:9): [True: 153, False: 1.70k]
  ------------------
  861|    153|        session->session_state = SSH_SESSION_STATE_ERROR;
  862|    153|    }
  863|       |
  864|  1.85k|    return rc;
  865|  1.85k|}
ssh_handle_packets_termination:
  898|    473|{
  899|    473|    struct ssh_timestamp ts;
  900|    473|    int timeout_ms = SSH_TIMEOUT_INFINITE;
  ------------------
  |  |   99|    473|#define SSH_TIMEOUT_INFINITE -1
  ------------------
  901|    473|    int tm;
  902|    473|    int ret = SSH_OK;
  ------------------
  |  |  315|    473|#define SSH_OK 0     /* No error */
  ------------------
  903|       |
  904|       |    /* If a timeout has been provided, use it */
  905|    473|    if (timeout >= 0) {
  ------------------
  |  Branch (905:9): [True: 473, False: 0]
  ------------------
  906|    473|        timeout_ms = timeout;
  907|    473|    } else {
  908|      0|        if (ssh_is_blocking(session)) {
  ------------------
  |  Branch (908:13): [True: 0, False: 0]
  ------------------
  909|      0|            if (timeout == SSH_TIMEOUT_USER || timeout == SSH_TIMEOUT_DEFAULT) {
  ------------------
  |  |  101|      0|#define SSH_TIMEOUT_USER -2
  ------------------
                          if (timeout == SSH_TIMEOUT_USER || timeout == SSH_TIMEOUT_DEFAULT) {
  ------------------
  |  |  103|      0|#define SSH_TIMEOUT_DEFAULT -3
  ------------------
  |  Branch (909:17): [True: 0, False: 0]
  |  Branch (909:48): [True: 0, False: 0]
  ------------------
  910|      0|                if (session->opts.timeout > 0 ||
  ------------------
  |  Branch (910:21): [True: 0, False: 0]
  ------------------
  911|      0|                    session->opts.timeout_usec > 0) {
  ------------------
  |  Branch (911:21): [True: 0, False: 0]
  ------------------
  912|      0|                    timeout_ms =
  913|      0|                        ssh_make_milliseconds(session->opts.timeout,
  914|      0|                                              session->opts.timeout_usec);
  915|      0|                }
  916|      0|            }
  917|      0|        } else {
  918|      0|            timeout_ms = SSH_TIMEOUT_NONBLOCKING;
  ------------------
  |  |  105|      0|#define SSH_TIMEOUT_NONBLOCKING 0
  ------------------
  919|      0|        }
  920|      0|    }
  921|       |
  922|       |    /* avoid unnecessary syscall for the SSH_TIMEOUT_NONBLOCKING case */
  923|    473|    if (timeout_ms != SSH_TIMEOUT_NONBLOCKING) {
  ------------------
  |  |  105|    473|#define SSH_TIMEOUT_NONBLOCKING 0
  ------------------
  |  Branch (923:9): [True: 473, False: 0]
  ------------------
  924|    473|        ssh_timestamp_init(&ts);
  925|    473|    }
  926|       |
  927|    473|    tm = timeout_ms;
  928|  2.17k|    while(!fct(user)) {
  ------------------
  |  Branch (928:11): [True: 1.85k, False: 320]
  ------------------
  929|  1.85k|        ret = ssh_handle_packets(session, tm);
  930|  1.85k|        if (ret == SSH_ERROR) {
  ------------------
  |  |  316|  1.85k|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  |  Branch (930:13): [True: 153, False: 1.70k]
  ------------------
  931|    153|            break;
  932|    153|        }
  933|  1.70k|        if (ssh_timeout_elapsed(&ts, timeout_ms)) {
  ------------------
  |  Branch (933:13): [True: 0, False: 1.70k]
  ------------------
  934|      0|            ret = fct(user) ? SSH_OK : SSH_AGAIN;
  ------------------
  |  |  315|      0|#define SSH_OK 0     /* No error */
  ------------------
                          ret = fct(user) ? SSH_OK : SSH_AGAIN;
  ------------------
  |  |  317|      0|#define SSH_AGAIN -2 /* The nonblocking call must be repeated */
  ------------------
  |  Branch (934:19): [True: 0, False: 0]
  ------------------
  935|      0|            break;
  936|      0|        }
  937|       |
  938|  1.70k|        tm = ssh_timeout_update(&ts, timeout_ms);
  939|  1.70k|    }
  940|       |
  941|    473|    return ret;
  942|    473|}
ssh_socket_exception_callback:
 1053|    153|void ssh_socket_exception_callback(int code, int errno_code, void *user){
 1054|    153|    ssh_session session = (ssh_session)user;
 1055|       |
 1056|    153|    SSH_LOG(SSH_LOG_RARE,
  ------------------
  |  |  283|    153|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 1057|    153|            "Socket exception callback: %d (%d)",
 1058|    153|            code,
 1059|    153|            errno_code);
 1060|    153|    session->session_state = SSH_SESSION_STATE_ERROR;
 1061|    153|    if (errno_code == 0 && code == SSH_SOCKET_EXCEPTION_EOF) {
  ------------------
  |  |  521|    153|#define SSH_SOCKET_EXCEPTION_EOF 	     1
  ------------------
  |  Branch (1061:9): [True: 153, False: 0]
  |  Branch (1061:28): [True: 153, False: 0]
  ------------------
 1062|    153|        ssh_set_error(session, SSH_FATAL, "Socket error: disconnected");
  ------------------
  |  |  313|    153|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
 1063|       |#ifdef _WIN32
 1064|       |    } else if (errno_code == WSAENETDOWN) {
 1065|       |        ssh_set_error(session, SSH_FATAL, "Socket error: network down");
 1066|       |    } else if (errno_code == WSAENETUNREACH) {
 1067|       |        ssh_set_error(session, SSH_FATAL, "Socket error: network unreachable");
 1068|       |    } else if (errno_code == WSAENETRESET) {
 1069|       |        ssh_set_error(session, SSH_FATAL, "Socket error: network reset");
 1070|       |    } else if (errno_code == WSAECONNABORTED) {
 1071|       |        ssh_set_error(session, SSH_FATAL, "Socket error: connection aborted");
 1072|       |    } else if (errno_code == WSAECONNRESET) {
 1073|       |        ssh_set_error(session,
 1074|       |                      SSH_FATAL,
 1075|       |                      "Socket error: connection reset by peer");
 1076|       |    } else if (errno_code == WSAETIMEDOUT) {
 1077|       |        ssh_set_error(session, SSH_FATAL, "Socket error: connection timed out");
 1078|       |    } else if (errno_code == WSAECONNREFUSED) {
 1079|       |        ssh_set_error(session, SSH_FATAL, "Socket error: connection refused");
 1080|       |    } else if (errno_code == WSAEHOSTUNREACH) {
 1081|       |        ssh_set_error(session, SSH_FATAL, "Socket error: host unreachable");
 1082|       |#endif
 1083|    153|    } else {
 1084|      0|        char err_msg[SSH_ERRNO_MSG_MAX] = {0};
 1085|      0|        ssh_set_error(session,
  ------------------
  |  |  313|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
 1086|      0|                      SSH_FATAL,
 1087|      0|                      "Socket error: %s",
 1088|      0|                      ssh_strerror(errno_code, err_msg, SSH_ERRNO_MSG_MAX));
 1089|      0|    }
 1090|       |
 1091|    153|    session->ssh_connection_callback(session);
 1092|    153|}

ssh_client_sntrup761x25519_init:
  105|     66|{
  106|     66|    int rc;
  107|       |
  108|     66|    rc = ssh_sntrup761x25519_init(session);
  109|     66|    if (rc != SSH_OK) {
  ------------------
  |  |  315|     66|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (109:9): [True: 0, False: 66]
  ------------------
  110|      0|        return rc;
  111|      0|    }
  112|       |
  113|     66|    rc = ssh_buffer_pack(session->out_buffer,
  ------------------
  |  |   50|     66|    _ssh_buffer_pack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |  453|     66|        (__VA_NARG_(__VA_ARGS__, __RSEQ_N()))
  |  |  |  |  ------------------
  |  |  |  |  |  |  455|     66|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  450|     66|#define VA_APPLY_VARIADIC_MACRO(macro, tuple) macro tuple
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  455|     66|        VA_APPLY_VARIADIC_MACRO(__VA_ARG_N, (__VA_ARGS__))
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  463|     66|        _61,_62,_63,N,...) N
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                   _ssh_buffer_pack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
  |  |  ------------------
  |  |  |  |   28|     66|#define SSH_BUFFER_PACK_END ((uint32_t) 0x4f65feb3)
  |  |  ------------------
  ------------------
  114|     66|                         "bdPP",
  115|     66|                         SSH2_MSG_KEX_ECDH_INIT,
  116|     66|                         CURVE25519_PUBKEY_SIZE + SNTRUP761_PUBLICKEY_SIZE,
  117|     66|                         (size_t)SNTRUP761_PUBLICKEY_SIZE,
  118|     66|                         session->next_crypto->sntrup761_client_pubkey,
  119|     66|                         (size_t)CURVE25519_PUBKEY_SIZE,
  120|     66|                         session->next_crypto->curve25519_client_pubkey);
  121|     66|    if (rc != SSH_OK) {
  ------------------
  |  |  315|     66|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (121:9): [True: 0, False: 66]
  ------------------
  122|      0|        ssh_set_error_oom(session);
  ------------------
  |  |  320|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
  123|      0|        return SSH_ERROR;
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  124|      0|    }
  125|       |
  126|       |    /* register the packet callbacks */
  127|     66|    ssh_packet_set_callbacks(session, &ssh_sntrup761x25519_client_callbacks);
  128|     66|    session->dh_handshake_state = DH_STATE_INIT_SENT;
  129|     66|    rc = ssh_packet_send(session);
  130|       |
  131|     66|    return rc;
  132|     66|}
ssh_client_sntrup761x25519_remove_callbacks:
  135|     60|{
  136|     60|    ssh_packet_remove_callbacks(session, &ssh_sntrup761x25519_client_callbacks);
  137|     60|}
sntrup761.c:ssh_sntrup761x25519_init:
   62|     66|{
   63|     66|    int rc;
   64|       |
   65|     66|    rc = ssh_curve25519_init(session);
   66|     66|    if (rc != SSH_OK) {
  ------------------
  |  |  315|     66|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (66:9): [True: 0, False: 66]
  ------------------
   67|      0|        return rc;
   68|      0|    }
   69|       |
   70|     66|    if (!session->server) {
  ------------------
  |  Branch (70:9): [True: 66, False: 0]
  ------------------
   71|       |#ifdef HAVE_LIBGCRYPT
   72|       |        gcry_error_t err;
   73|       |
   74|       |        err = gcry_kem_keypair(GCRY_KEM_SNTRUP761,
   75|       |                               session->next_crypto->sntrup761_client_pubkey,
   76|       |                               SNTRUP761_PUBLICKEY_SIZE,
   77|       |                               session->next_crypto->sntrup761_privkey,
   78|       |                               SNTRUP761_SECRETKEY_SIZE);
   79|       |        if (err) {
   80|       |            SSH_LOG(SSH_LOG_TRACE,
   81|       |                    "Failed to generate sntrup761 key: %s",
   82|       |                    gpg_strerror(err));
   83|       |            return SSH_ERROR;
   84|       |        }
   85|       |#else
   86|     66|        sntrup761_keypair(session->next_crypto->sntrup761_client_pubkey,
   87|     66|                          session->next_crypto->sntrup761_privkey,
   88|     66|                          &rc,
   89|     66|                          crypto_random);
   90|     66|        if (rc != 1) {
  ------------------
  |  Branch (90:13): [True: 0, False: 66]
  ------------------
   91|      0|            SSH_LOG(SSH_LOG_TRACE,
  ------------------
  |  |  283|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
   92|      0|                    "Failed to generate sntrup761 key: PRNG failure");
   93|      0|            return SSH_ERROR;
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
   94|      0|        }
   95|     66|#endif /* HAVE_LIBGCRYPT */
   96|     66|    }
   97|       |
   98|     66|    return SSH_OK;
  ------------------
  |  |  315|     66|#define SSH_OK 0     /* No error */
  ------------------
   99|     66|}
sntrup761.c:crypto_random:
   41|   100k|{
   42|   100k|    int *err = ctx;
   43|   100k|    *err = ssh_get_random(dst, length, 1);
   44|   100k|}
sntrup761.c:ssh_packet_client_sntrup761x25519_reply:
  248|     60|{
  249|     60|    ssh_string q_s_string = NULL;
  250|     60|    ssh_string pubkey_blob = NULL;
  251|     60|    ssh_string signature = NULL;
  252|     60|    int rc;
  253|     60|    (void)type;
  254|     60|    (void)user;
  255|       |
  256|     60|    ssh_client_sntrup761x25519_remove_callbacks(session);
  257|       |
  258|     60|    pubkey_blob = ssh_buffer_get_ssh_string(packet);
  259|     60|    if (pubkey_blob == NULL) {
  ------------------
  |  Branch (259:9): [True: 1, False: 59]
  ------------------
  260|      1|        ssh_set_error(session, SSH_FATAL, "No public key in packet");
  ------------------
  |  |  313|      1|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  261|      1|        goto error;
  262|      1|    }
  263|       |
  264|     59|    rc = ssh_dh_import_next_pubkey_blob(session, pubkey_blob);
  265|     59|    SSH_STRING_FREE(pubkey_blob);
  ------------------
  |  |  882|     59|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (882:14): [True: 59, False: 0]
  |  |  |  Branch (882:69): [Folded, False: 59]
  |  |  ------------------
  ------------------
  266|     59|    if (rc != 0) {
  ------------------
  |  Branch (266:9): [True: 59, False: 0]
  ------------------
  267|     59|        ssh_set_error(session, SSH_FATAL, "Failed to import next public key");
  ------------------
  |  |  313|     59|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  268|     59|        goto error;
  269|     59|    }
  270|       |
  271|      0|    q_s_string = ssh_buffer_get_ssh_string(packet);
  272|      0|    if (q_s_string == NULL) {
  ------------------
  |  Branch (272:9): [True: 0, False: 0]
  ------------------
  273|      0|        ssh_set_error(session, SSH_FATAL, "No sntrup761x25519 Q_S in packet");
  ------------------
  |  |  313|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  274|      0|        goto error;
  275|      0|    }
  276|      0|    if (ssh_string_len(q_s_string) != (SNTRUP761_CIPHERTEXT_SIZE + CURVE25519_PUBKEY_SIZE)) {
  ------------------
  |  |   51|      0|#define SNTRUP761_CIPHERTEXT_SIZE 1039
  ------------------
                  if (ssh_string_len(q_s_string) != (SNTRUP761_CIPHERTEXT_SIZE + CURVE25519_PUBKEY_SIZE)) {
  ------------------
  |  |   41|      0|#define CURVE25519_PUBKEY_SIZE 32
  ------------------
  |  Branch (276:9): [True: 0, False: 0]
  ------------------
  277|      0|        ssh_set_error(session,
  ------------------
  |  |  313|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  278|      0|                      SSH_FATAL,
  279|      0|                      "Incorrect size for server sntrup761x25519 ciphertext+key: %d",
  280|      0|                      (int)ssh_string_len(q_s_string));
  281|      0|        SSH_STRING_FREE(q_s_string);
  ------------------
  |  |  882|      0|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (882:14): [True: 0, False: 0]
  |  |  |  Branch (882:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
  282|      0|        goto error;
  283|      0|    }
  284|      0|    memcpy(session->next_crypto->sntrup761_ciphertext,
  285|      0|           ssh_string_data(q_s_string),
  286|      0|           SNTRUP761_CIPHERTEXT_SIZE);
  ------------------
  |  |   51|      0|#define SNTRUP761_CIPHERTEXT_SIZE 1039
  ------------------
  287|      0|    memcpy(session->next_crypto->curve25519_server_pubkey,
  288|      0|           (char *)ssh_string_data(q_s_string) + SNTRUP761_CIPHERTEXT_SIZE,
  ------------------
  |  |   51|      0|#define SNTRUP761_CIPHERTEXT_SIZE 1039
  ------------------
  289|      0|           CURVE25519_PUBKEY_SIZE);
  ------------------
  |  |   41|      0|#define CURVE25519_PUBKEY_SIZE 32
  ------------------
  290|      0|    SSH_STRING_FREE(q_s_string);
  ------------------
  |  |  882|      0|    do { if ((x) != NULL) { ssh_string_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (882:14): [True: 0, False: 0]
  |  |  |  Branch (882:69): [Folded, False: 0]
  |  |  ------------------
  ------------------
  291|       |
  292|      0|    signature = ssh_buffer_get_ssh_string(packet);
  293|      0|    if (signature == NULL) {
  ------------------
  |  Branch (293:9): [True: 0, False: 0]
  ------------------
  294|      0|        ssh_set_error(session, SSH_FATAL, "No signature in packet");
  ------------------
  |  |  313|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  295|      0|        goto error;
  296|      0|    }
  297|      0|    session->next_crypto->dh_server_signature = signature;
  298|      0|    signature = NULL; /* ownership changed */
  299|       |    /* TODO: verify signature now instead of waiting for NEWKEYS */
  300|      0|    if (ssh_sntrup761x25519_build_k(session) < 0) {
  ------------------
  |  Branch (300:9): [True: 0, False: 0]
  ------------------
  301|      0|        ssh_set_error(session, SSH_FATAL, "Cannot build k number");
  ------------------
  |  |  313|      0|    _ssh_set_error(error, code, __func__, __VA_ARGS__)
  ------------------
  302|      0|        goto error;
  303|      0|    }
  304|       |
  305|       |    /* Send the MSG_NEWKEYS */
  306|      0|    if (ssh_buffer_add_u8(session->out_buffer, SSH2_MSG_NEWKEYS) < 0) {
  ------------------
  |  |   13|      0|#define SSH2_MSG_NEWKEYS 21
  ------------------
  |  Branch (306:9): [True: 0, False: 0]
  ------------------
  307|      0|        goto error;
  308|      0|    }
  309|       |
  310|      0|    rc = ssh_packet_send(session);
  311|      0|    if (rc == SSH_ERROR) {
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  |  Branch (311:9): [True: 0, False: 0]
  ------------------
  312|      0|        goto error;
  313|      0|    }
  314|       |
  315|      0|    SSH_LOG(SSH_LOG_DEBUG, "SSH_MSG_NEWKEYS sent");
  ------------------
  |  |  283|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  316|      0|    session->dh_handshake_state = DH_STATE_NEWKEYS_SENT;
  317|       |
  318|      0|    return SSH_PACKET_USED;
  ------------------
  |  |  638|      0|#define SSH_PACKET_USED 1
  ------------------
  319|       |
  320|     60|error:
  321|     60|    session->session_state = SSH_SESSION_STATE_ERROR;
  322|     60|    return SSH_PACKET_USED;
  ------------------
  |  |  638|     60|#define SSH_PACKET_USED 1
  ------------------
  323|      0|}

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|  1.05k|{
  183|  1.05k|    ssh_socket s;
  184|       |
  185|  1.05k|    s = calloc(1, sizeof(struct ssh_socket_struct));
  186|  1.05k|    if (s == NULL) {
  ------------------
  |  Branch (186:9): [True: 51, False: 1.00k]
  ------------------
  187|     51|        ssh_set_error_oom(session);
  ------------------
  |  |  320|     51|    _ssh_set_error_oom(error, __func__)
  ------------------
  188|     51|        return NULL;
  189|     51|    }
  190|  1.00k|    s->fd = SSH_INVALID_SOCKET;
  ------------------
  |  |  123|  1.00k|#define SSH_INVALID_SOCKET ((socket_t) -1)
  ------------------
  191|  1.00k|    s->last_errno = -1;
  192|  1.00k|    s->fd_is_socket = 1;
  193|  1.00k|    s->session = session;
  194|  1.00k|    s->in_buffer = ssh_buffer_new();
  195|  1.00k|    if (s->in_buffer == NULL) {
  ------------------
  |  Branch (195:9): [True: 47, False: 959]
  ------------------
  196|     47|        ssh_set_error_oom(session);
  ------------------
  |  |  320|     47|    _ssh_set_error_oom(error, __func__)
  ------------------
  197|     47|        SAFE_FREE(s);
  ------------------
  |  |  375|     47|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (375:31): [True: 47, False: 0]
  |  |  |  Branch (375:71): [Folded, False: 47]
  |  |  ------------------
  ------------------
  198|     47|        return NULL;
  199|     47|    }
  200|    959|    s->out_buffer=ssh_buffer_new();
  201|    959|    if (s->out_buffer == NULL) {
  ------------------
  |  Branch (201:9): [True: 7, False: 952]
  ------------------
  202|      7|        ssh_set_error_oom(session);
  ------------------
  |  |  320|      7|    _ssh_set_error_oom(error, __func__)
  ------------------
  203|      7|        SSH_BUFFER_FREE(s->in_buffer);
  ------------------
  |  |  924|      7|    do { if ((x) != NULL) { ssh_buffer_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (924:14): [True: 7, False: 0]
  |  |  |  Branch (924:69): [Folded, False: 7]
  |  |  ------------------
  ------------------
  204|      7|        SAFE_FREE(s);
  ------------------
  |  |  375|      7|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (375:31): [True: 7, False: 0]
  |  |  |  Branch (375:71): [Folded, False: 7]
  |  |  ------------------
  ------------------
  205|      7|        return NULL;
  206|      7|    }
  207|    952|    s->read_wontblock = 0;
  208|    952|    s->write_wontblock = 0;
  209|    952|    s->data_except = 0;
  210|       |    s->poll_handle = NULL;
  211|    952|    s->state=SSH_SOCKET_NONE;
  212|    952|    return s;
  213|    959|}
ssh_socket_reset:
  226|    473|{
  227|    473|    s->fd = SSH_INVALID_SOCKET;
  ------------------
  |  |  123|    473|#define SSH_INVALID_SOCKET ((socket_t) -1)
  ------------------
  228|    473|    s->last_errno = -1;
  229|    473|    s->fd_is_socket = 1;
  230|    473|    ssh_buffer_reinit(s->in_buffer);
  231|    473|    ssh_buffer_reinit(s->out_buffer);
  232|    473|    s->read_wontblock = 0;
  233|    473|    s->write_wontblock = 0;
  234|    473|    s->data_except = 0;
  235|    473|    if (s->poll_handle != NULL) {
  ------------------
  |  Branch (235:9): [True: 473, False: 0]
  ------------------
  236|    473|        ssh_poll_free(s->poll_handle);
  237|       |        s->poll_handle = NULL;
  238|    473|    }
  239|    473|    s->state=SSH_SOCKET_NONE;
  240|    473|#ifndef _WIN32
  241|    473|    s->proxy_pid = 0;
  242|    473|#endif
  243|    473|}
ssh_socket_set_callbacks:
  253|    885|{
  254|    885|    s->callbacks = callbacks;
  255|    885|}
ssh_socket_set_connected:
  269|    473|{
  270|    473|    s->state = SSH_SOCKET_CONNECTED;
  271|       |    /* `POLLOUT` is the event to wait for in a non-blocking connect */
  272|    473|    if (p != NULL) {
  ------------------
  |  Branch (272:9): [True: 473, False: 0]
  ------------------
  273|    473|        ssh_poll_set_events(p, POLLIN | POLLOUT);
  274|    473|    }
  275|    473|}
ssh_socket_pollcallback:
  296|  1.85k|{
  297|  1.85k|    ssh_socket s = (ssh_socket)v_s;
  298|  1.85k|    void *buffer = NULL;
  299|  1.85k|    ssize_t nread = 0;
  300|  1.85k|    int rc;
  301|  1.85k|    int err = 0;
  302|  1.85k|    socklen_t errlen = sizeof(err);
  303|       |
  304|       |    /* Do not do anything if this socket was already closed */
  305|  1.85k|    if (!ssh_socket_is_open(s)) {
  ------------------
  |  Branch (305:9): [True: 0, False: 1.85k]
  ------------------
  306|      0|        return -1;
  307|      0|    }
  308|  1.85k|    SSH_LOG(SSH_LOG_TRACE,
  ------------------
  |  |  283|  11.1k|    _ssh_log(priority, __func__, __VA_ARGS__)
  |  |  ------------------
  |  |  |  Branch (283:34): [True: 1.85k, False: 0]
  |  |  |  Branch (283:34): [True: 1.83k, False: 19]
  |  |  |  Branch (283:34): [True: 0, False: 1.85k]
  |  |  ------------------
  ------------------
  309|  1.85k|            "Poll callback on socket %d (%s%s%s), out buffer %" PRIu32, fd,
  310|  1.85k|            (revents & POLLIN) ? "POLLIN ":"",
  311|  1.85k|            (revents & POLLOUT) ? "POLLOUT ":"",
  312|  1.85k|            (revents & POLLERR) ? "POLLERR":"",
  313|  1.85k|            ssh_buffer_get_len(s->out_buffer));
  314|  1.85k|    if ((revents & POLLERR) || (revents & POLLHUP)) {
  ------------------
  |  Branch (314:9): [True: 0, False: 1.85k]
  |  Branch (314:32): [True: 0, False: 1.85k]
  ------------------
  315|       |        /* Check if we are in a connecting state */
  316|      0|        if (s->state == SSH_SOCKET_CONNECTING) {
  ------------------
  |  Branch (316:13): [True: 0, False: 0]
  ------------------
  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,
  ------------------
  |  |  525|      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|      0|        revents |= POLLIN;
  338|      0|    }
  339|  1.85k|    if ((revents & POLLIN) && s->state == SSH_SOCKET_CONNECTED) {
  ------------------
  |  Branch (339:9): [True: 1.85k, False: 0]
  |  Branch (339:31): [True: 1.38k, False: 473]
  ------------------
  340|  1.38k|        s->read_wontblock = 1;
  341|  1.38k|        buffer = ssh_buffer_allocate(s->in_buffer, MAX_BUF_SIZE);
  ------------------
  |  |  230|  1.38k|#define MAX_BUF_SIZE 4096
  ------------------
  342|  1.38k|        if (buffer) {
  ------------------
  |  Branch (342:13): [True: 1.38k, False: 0]
  ------------------
  343|  1.38k|            nread = ssh_socket_unbuffered_read(s, buffer, MAX_BUF_SIZE);
  ------------------
  |  |  230|  1.38k|#define MAX_BUF_SIZE 4096
  ------------------
  344|  1.38k|        }
  345|  1.38k|        if (nread < 0) {
  ------------------
  |  Branch (345:13): [True: 0, False: 1.38k]
  ------------------
  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,
  ------------------
  |  |  522|      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|  1.38k|        ssh_buffer_pass_bytes_end(s->in_buffer,
  361|  1.38k|                                  (uint32_t)(MAX_BUF_SIZE - nread));
  ------------------
  |  |  230|  1.38k|#define MAX_BUF_SIZE 4096
  ------------------
  362|       |
  363|  1.38k|        if (nread == 0) {
  ------------------
  |  Branch (363:13): [True: 153, False: 1.22k]
  ------------------
  364|    153|            if (p != NULL) {
  ------------------
  |  Branch (364:17): [True: 153, False: 0]
  ------------------
  365|    153|                ssh_poll_remove_events(p, POLLIN);
  366|    153|            }
  367|    153|            if (s->callbacks != NULL && s->callbacks->exception != NULL) {
  ------------------
  |  Branch (367:17): [True: 153, False: 0]
  |  Branch (367:41): [True: 153, False: 0]
  ------------------
  368|    153|                s->callbacks->exception(SSH_SOCKET_EXCEPTION_EOF,
  ------------------
  |  |  521|    153|#define SSH_SOCKET_EXCEPTION_EOF 	     1
  ------------------
  369|    153|                                        0,
  370|    153|                                        s->callbacks->userdata);
  371|    153|            }
  372|    153|            return -2;
  373|    153|        }
  374|       |
  375|  1.22k|        if (s->session->socket_counter != NULL) {
  ------------------
  |  Branch (375:13): [True: 0, False: 1.22k]
  ------------------
  376|      0|            s->session->socket_counter->in_bytes += nread;
  377|      0|        }
  378|       |
  379|       |        /* Call the callback */
  380|  1.22k|        if (s->callbacks != NULL && s->callbacks->data != NULL) {
  ------------------
  |  Branch (380:13): [True: 1.22k, False: 0]
  |  Branch (380:37): [True: 1.22k, False: 0]
  ------------------
  381|  1.22k|            size_t processed;
  382|   244k|            do {
  383|   244k|                processed = s->callbacks->data(ssh_buffer_get(s->in_buffer),
  384|   244k|                                               ssh_buffer_get_len(s->in_buffer),
  385|   244k|                                               s->callbacks->userdata);
  386|   244k|                ssh_buffer_pass_bytes(s->in_buffer, (uint32_t)processed);
  387|   244k|            } while ((processed > 0) && (s->state == SSH_SOCKET_CONNECTED));
  ------------------
  |  Branch (387:22): [True: 243k, False: 1.22k]
  |  Branch (387:41): [True: 243k, False: 0]
  ------------------
  388|       |
  389|       |            /* p may have been freed, so don't use it
  390|       |             * anymore in this function */
  391|  1.22k|            p = NULL;
  392|  1.22k|        }
  393|  1.22k|    }
  394|       |#ifdef _WIN32
  395|       |    if (revents & POLLOUT || revents & POLLWRNORM) {
  396|       |#else
  397|  1.70k|    if (revents & POLLOUT) {
  ------------------
  |  Branch (397:9): [True: 1.68k, False: 18]
  ------------------
  398|  1.68k|#endif
  399|  1.68k|        uint32_t len;
  400|       |
  401|       |        /* First, POLLOUT is a sign we may be connected */
  402|  1.68k|        if (s->state == SSH_SOCKET_CONNECTING) {
  ------------------
  |  Branch (402:13): [True: 473, False: 1.21k]
  ------------------
  403|    473|            SSH_LOG(SSH_LOG_PACKET, "Received POLLOUT in connecting state");
  ------------------
  |  |  283|    473|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  404|    473|            ssh_socket_set_connected(s, p);
  405|       |
  406|    473|            rc = ssh_socket_set_blocking(ssh_socket_get_fd(s));
  407|    473|            if (rc < 0) {
  ------------------
  |  Branch (407:17): [True: 0, False: 473]
  ------------------
  408|      0|                return -1;
  409|      0|            }
  410|       |
  411|    473|            if (s->callbacks != NULL && s->callbacks->connected != NULL) {
  ------------------
  |  Branch (411:17): [True: 473, False: 0]
  |  Branch (411:41): [True: 473, False: 0]
  ------------------
  412|    473|                s->callbacks->connected(SSH_SOCKET_CONNECTED_OK,
  ------------------
  |  |  524|    473|#define SSH_SOCKET_CONNECTED_OK 			1
  ------------------
  413|    473|                                        0,
  414|    473|                                        s->callbacks->userdata);
  415|    473|            }
  416|       |
  417|    473|            return 0;
  418|    473|        }
  419|       |
  420|       |        /* So, we can write data */
  421|  1.21k|        s->write_wontblock = 1;
  422|  1.21k|        if (p != NULL) {
  ------------------
  |  Branch (422:13): [True: 0, False: 1.21k]
  ------------------
  423|      0|            ssh_poll_remove_events(p, POLLOUT);
  424|      0|        }
  425|       |
  426|       |        /* If buffered data is pending, write it */
  427|  1.21k|        len = ssh_buffer_get_len(s->out_buffer);
  428|  1.21k|        if (len > 0) {
  ------------------
  |  Branch (428:13): [True: 547, False: 664]
  ------------------
  429|    547|            ssh_socket_nonblocking_flush(s);
  430|    664|        } else if (s->callbacks != NULL && s->callbacks->controlflow != NULL) {
  ------------------
  |  Branch (430:20): [True: 664, False: 0]
  |  Branch (430:44): [True: 422, False: 242]
  ------------------
  431|       |            /* Otherwise advertise the upper level that write can be done */
  432|    422|            SSH_LOG(SSH_LOG_TRACE, "sending control flow event");
  ------------------
  |  |  283|    422|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  433|    422|            s->callbacks->controlflow(SSH_SOCKET_FLOW_WRITEWONTBLOCK,
  ------------------
  |  |  519|    422|#define SSH_SOCKET_FLOW_WRITEWONTBLOCK 2
  ------------------
  434|    422|                                      s->callbacks->userdata);
  435|    422|        }
  436|       |        /* TODO: Find a way to put back POLLOUT when buffering occurs */
  437|  1.21k|    }
  438|       |
  439|       |    /* Return -1 if the poll handler disappeared */
  440|  1.22k|    if (s->poll_handle == NULL) {
  ------------------
  |  Branch (440:9): [True: 0, False: 1.22k]
  ------------------
  441|      0|        return -1;
  442|      0|    }
  443|       |
  444|  1.22k|    return 0;
  445|  1.22k|}
ssh_socket_get_poll_handle:
  454|  2.32k|{
  455|  2.32k|    if (s->poll_handle) {
  ------------------
  |  Branch (455:9): [True: 1.85k, False: 473]
  ------------------
  456|  1.85k|        return s->poll_handle;
  457|  1.85k|    }
  458|    473|    s->poll_handle = ssh_poll_new(s->fd, 0, ssh_socket_pollcallback, s);
  459|    473|    return s->poll_handle;
  460|  2.32k|}
ssh_socket_free:
  473|  1.17k|{
  474|  1.17k|    if (s == NULL) {
  ------------------
  |  Branch (474:9): [True: 221, False: 952]
  ------------------
  475|    221|        return;
  476|    221|    }
  477|    952|    ssh_socket_close(s);
  478|    952|    SSH_BUFFER_FREE(s->in_buffer);
  ------------------
  |  |  924|    952|    do { if ((x) != NULL) { ssh_buffer_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (924:14): [True: 952, False: 0]
  |  |  |  Branch (924:69): [Folded, False: 952]
  |  |  ------------------
  ------------------
  479|    952|    SSH_BUFFER_FREE(s->out_buffer);
  ------------------
  |  |  924|    952|    do { if ((x) != NULL) { ssh_buffer_free(x); x = NULL; } } while(0)
  |  |  ------------------
  |  |  |  Branch (924:14): [True: 952, False: 0]
  |  |  |  Branch (924:69): [Folded, False: 952]
  |  |  ------------------
  ------------------
  480|       |    SAFE_FREE(s);
  ------------------
  |  |  375|    952|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (375:31): [True: 952, False: 0]
  |  |  |  Branch (375:71): [Folded, False: 952]
  |  |  ------------------
  ------------------
  481|    952|}
ssh_socket_close:
  546|  1.42k|{
  547|  1.42k|    if (ssh_socket_is_open(s)) {
  ------------------
  |  Branch (547:9): [True: 0, False: 1.42k]
  ------------------
  548|       |#ifdef _WIN32
  549|       |        CLOSE_SOCKET(s->fd);
  550|       |        s->last_errno = WSAGetLastError();
  551|       |#else
  552|      0|        CLOSE_SOCKET(s->fd);
  ------------------
  |  |  474|      0|#define CLOSE_SOCKET(s) do { if ((s) != SSH_INVALID_SOCKET) { _XCLOSESOCKET(s); (s) = SSH_INVALID_SOCKET;} } while(0)
  |  |  ------------------
  |  |  |  |  123|      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)
  |  |  ------------------
  |  |  |  |  123|      0|#define SSH_INVALID_SOCKET ((socket_t) -1)
  |  |  ------------------
  |  |  |  Branch (474:34): [True: 0, False: 0]
  |  |  |  Branch (474:116): [Folded, False: 0]
  |  |  ------------------
  ------------------
  553|      0|        s->last_errno = errno;
  554|      0|#endif
  555|      0|    }
  556|       |
  557|  1.42k|    if (s->poll_handle != NULL && !ssh_poll_is_locked(s->poll_handle)) {
  ------------------
  |  Branch (557:9): [True: 0, False: 1.42k]
  |  Branch (557:35): [True: 0, False: 0]
  ------------------
  558|      0|        ssh_poll_free(s->poll_handle);
  559|      0|        s->poll_handle = NULL;
  560|      0|    }
  561|       |
  562|  1.42k|    s->state = SSH_SOCKET_CLOSED;
  563|       |
  564|  1.42k|#ifndef _WIN32
  565|       |    /* If the proxy command still runs try to kill it */
  566|  1.42k|    if (s->proxy_pid != 0) {
  ------------------
  |  Branch (566:9): [True: 0, False: 1.42k]
  ------------------
  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");
  ------------------
  |  |  285|      0|    do {                                                            \
  |  |  286|      0|        char err_msg[SSH_ERRNO_MSG_MAX] = {0};                      \
  |  |  287|      0|        _ssh_log(priority,                                          \
  |  |  288|      0|                 __func__,                                          \
  |  |  289|      0|                 __VA_ARGS__,                                       \
  |  |  290|      0|                 ssh_strerror(errnum, err_msg, SSH_ERRNO_MSG_MAX)); \
  |  |  ------------------
  |  |  |  |  522|      0|#define SSH_ERRNO_MSG_MAX   1024
  |  |  ------------------
  |  |  291|      0|    } while (0)
  |  |  ------------------
  |  |  |  Branch (291: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");
  ------------------
  |  |  283|      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));
  ------------------
  |  |  283|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  583|      0|    }
  584|  1.42k|#endif
  585|  1.42k|}
ssh_socket_set_fd:
  596|    473|{
  597|    473|    ssh_poll_handle h = NULL;
  598|       |
  599|    473|    s->fd = fd;
  600|       |
  601|    473|    if (s->poll_handle) {
  ------------------
  |  Branch (601:9): [True: 0, False: 473]
  ------------------
  602|      0|        ssh_poll_set_fd(s->poll_handle,fd);
  603|    473|    } else {
  604|    473|        s->state = SSH_SOCKET_CONNECTING;
  605|    473|        h = ssh_socket_get_poll_handle(s);
  606|    473|        if (h == NULL) {
  ------------------
  |  Branch (606:13): [True: 0, False: 473]
  ------------------
  607|      0|            return SSH_ERROR;
  ------------------
  |  |  316|      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|    473|        ssh_poll_set_events(h, POLLOUT);
  612|       |#ifdef _WIN32
  613|       |        ssh_poll_add_events(h, POLLWRNORM);
  614|       |#endif
  615|    473|    }
  616|    473|    return SSH_OK;
  ------------------
  |  |  315|    473|#define SSH_OK 0     /* No error */
  ------------------
  617|    473|}
ssh_socket_get_fd:
  629|    473|{
  630|    473|    return s->fd;
  631|    473|}
ssh_socket_is_open:
  643|  61.1k|{
  644|  61.1k|    return s->fd != SSH_INVALID_SOCKET;
  ------------------
  |  |  123|  61.1k|#define SSH_INVALID_SOCKET ((socket_t) -1)
  ------------------
  645|  61.1k|}
ssh_socket_write:
  811|  28.6k|{
  812|  28.6k|    if (len > 0) {
  ------------------
  |  Branch (812:9): [True: 28.6k, False: 0]
  ------------------
  813|  28.6k|        if (ssh_buffer_add_data(s->out_buffer, buffer, len) < 0) {
  ------------------
  |  Branch (813:13): [True: 0, False: 28.6k]
  ------------------
  814|      0|            ssh_set_error_oom(s->session);
  ------------------
  |  |  320|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
  815|      0|            return SSH_ERROR;
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  816|      0|        }
  817|  28.6k|        ssh_socket_nonblocking_flush(s);
  818|  28.6k|    }
  819|       |
  820|  28.6k|    return SSH_OK;
  ------------------
  |  |  315|  28.6k|#define SSH_OK 0     /* No error */
  ------------------
  821|  28.6k|}
ssh_socket_nonblocking_flush:
  841|  29.2k|{
  842|  29.2k|    ssh_session session = s->session;
  843|  29.2k|    uint32_t len;
  844|       |
  845|  29.2k|    if (!ssh_socket_is_open(s)) {
  ------------------
  |  Branch (845:9): [True: 0, False: 29.2k]
  ------------------
  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,
  ------------------
  |  |  522|      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,
  ------------------
  |  |  313|      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;
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  861|      0|    }
  862|       |
  863|  29.2k|    len = ssh_buffer_get_len(s->out_buffer);
  864|  29.2k|    if (!s->write_wontblock && s->poll_handle && len > 0) {
  ------------------
  |  Branch (864:9): [True: 28.0k, False: 1.12k]
  |  Branch (864:32): [True: 28.0k, False: 0]
  |  Branch (864:50): [True: 28.0k, False: 0]
  ------------------
  865|       |        /* force the poll system to catch pollout events */
  866|  28.0k|        ssh_poll_add_events(s->poll_handle, POLLOUT);
  867|       |
  868|  28.0k|        return SSH_AGAIN;
  ------------------
  |  |  317|  28.0k|#define SSH_AGAIN -2 /* The nonblocking call must be repeated */
  ------------------
  869|  28.0k|    }
  870|       |
  871|  1.12k|    if (s->write_wontblock && len > 0) {
  ------------------
  |  Branch (871:9): [True: 1.12k, False: 0]
  |  Branch (871:31): [True: 1.12k, False: 0]
  ------------------
  872|  1.12k|        ssize_t bwritten;
  873|       |
  874|  1.12k|        bwritten = ssh_socket_unbuffered_write(s,
  875|  1.12k|                                               ssh_buffer_get(s->out_buffer),
  876|  1.12k|                                               len);
  877|  1.12k|        if (bwritten < 0) {
  ------------------
  |  Branch (877:13): [True: 0, False: 1.12k]
  ------------------
  878|      0|            session->alive = 0;
  879|      0|            ssh_socket_close(s);
  880|       |
  881|      0|            if (s->callbacks && s->callbacks->exception) {
  ------------------
  |  Branch (881:17): [True: 0, False: 0]
  |  Branch (881:33): [True: 0, False: 0]
  ------------------
  882|      0|                s->callbacks->exception(SSH_SOCKET_EXCEPTION_ERROR,
  ------------------
  |  |  522|      0|#define SSH_SOCKET_EXCEPTION_ERROR     2
  ------------------
  883|      0|                                        s->last_errno,
  884|      0|                                        s->callbacks->userdata);
  885|      0|            } else {
  886|      0|                char err_msg[SSH_ERRNO_MSG_MAX] = {0};
  887|      0|                ssh_set_error(session,
  ------------------
  |  |  313|      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|      0|            return SSH_ERROR;
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  895|      0|        }
  896|       |
  897|  1.12k|        ssh_buffer_pass_bytes(s->out_buffer, (uint32_t)bwritten);
  898|  1.12k|        if (s->session->socket_counter != NULL) {
  ------------------
  |  Branch (898:13): [True: 0, False: 1.12k]
  ------------------
  899|      0|            s->session->socket_counter->out_bytes += bwritten;
  900|      0|        }
  901|  1.12k|    }
  902|       |
  903|       |    /* Is there some data pending? */
  904|  1.12k|    len = ssh_buffer_get_len(s->out_buffer);
  905|  1.12k|    if (s->poll_handle && len > 0) {
  ------------------
  |  Branch (905:9): [True: 1.12k, False: 0]
  |  Branch (905:27): [True: 0, False: 1.12k]
  ------------------
  906|      0|        SSH_LOG(SSH_LOG_TRACE,
  ------------------
  |  |  283|      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;
  ------------------
  |  |  317|      0|#define SSH_AGAIN -2 /* The nonblocking call must be repeated */
  ------------------
  912|      0|    }
  913|       |
  914|       |    /* all data written */
  915|  1.12k|    return SSH_OK;
  ------------------
  |  |  315|  1.12k|#define SSH_OK 0     /* No error */
  ------------------
  916|  1.12k|}
ssh_socket_set_write_wontblock:
  929|    473|{
  930|    473|    s->write_wontblock = 1;
  931|    473|}
ssh_socket_set_blocking:
 1114|    473|{
 1115|       |    return fcntl(fd, F_SETFL, 0);
 1116|    473|}
socket.c:ssh_socket_unbuffered_read:
  665|  1.38k|{
  666|  1.38k|    ssize_t rc = -1;
  667|       |
  668|  1.38k|    if (s->data_except) {
  ------------------
  |  Branch (668:9): [True: 0, False: 1.38k]
  ------------------
  669|      0|        return -1;
  670|      0|    }
  671|  1.38k|    if (s->fd_is_socket) {
  ------------------
  |  Branch (671:9): [True: 1.38k, False: 0]
  ------------------
  672|  1.38k|        rc = recv(s->fd, buffer, len, 0);
  673|  1.38k|    } else {
  674|      0|        rc = read(s->fd, buffer, len);
  675|      0|    }
  676|       |#ifdef _WIN32
  677|       |    s->last_errno = WSAGetLastError();
  678|       |#else
  679|  1.38k|    s->last_errno = errno;
  680|  1.38k|#endif
  681|  1.38k|    s->read_wontblock = 0;
  682|       |
  683|  1.38k|    if (rc < 0) {
  ------------------
  |  Branch (683:9): [True: 0, False: 1.38k]
  ------------------
  684|      0|        s->data_except = 1;
  685|  1.38k|    } else {
  686|  1.38k|        SSH_LOG(SSH_LOG_TRACE, "read %zd", rc);
  ------------------
  |  |  283|  1.38k|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  687|  1.38k|    }
  688|       |
  689|  1.38k|    return rc;
  690|  1.38k|}
socket.c:ssh_socket_unbuffered_write:
  711|  1.12k|{
  712|  1.12k|    ssize_t w = -1;
  713|  1.12k|    int flags = 0;
  714|       |
  715|  1.12k|#ifdef MSG_NOSIGNAL
  716|  1.12k|    flags |= MSG_NOSIGNAL;
  717|  1.12k|#endif
  718|       |
  719|  1.12k|    if (s->data_except) {
  ------------------
  |  Branch (719:9): [True: 0, False: 1.12k]
  ------------------
  720|      0|        return -1;
  721|      0|    }
  722|       |
  723|  1.12k|    if (s->fd_is_socket) {
  ------------------
  |  Branch (723:9): [True: 1.12k, False: 0]
  ------------------
  724|  1.12k|        w = send(s->fd, buffer, len, flags);
  725|  1.12k|    } else {
  726|      0|        w = write(s->fd, buffer, len);
  727|      0|    }
  728|       |#ifdef _WIN32
  729|       |    s->last_errno = WSAGetLastError();
  730|       |#else
  731|  1.12k|    s->last_errno = errno;
  732|  1.12k|#endif
  733|  1.12k|    s->write_wontblock = 0;
  734|       |    /* Reactive the POLLOUT detector in the poll multiplexer system */
  735|  1.12k|    if (s->poll_handle) {
  ------------------
  |  Branch (735:9): [True: 1.12k, False: 0]
  ------------------
  736|  1.12k|        SSH_LOG(SSH_LOG_PACKET, "Enabling POLLOUT for socket");
  ------------------
  |  |  283|  1.12k|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  737|  1.12k|        ssh_poll_add_events(s->poll_handle, POLLOUT);
  738|  1.12k|    }
  739|  1.12k|    if (w < 0) {
  ------------------
  |  Branch (739:9): [True: 0, False: 1.12k]
  ------------------
  740|      0|        s->data_except = 1;
  741|      0|    }
  742|       |
  743|  1.12k|    SSH_LOG(SSH_LOG_TRACE, "wrote %zd", w);
  ------------------
  |  |  283|  1.12k|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  744|  1.12k|    return w;
  745|  1.12k|}

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

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;
  ------------------
  |  |  315|      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) {
  ------------------
  |  |  315|      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|    473|{
   97|    473|    if (user_callbacks != NULL) {
  ------------------
  |  Branch (97:9): [True: 473, False: 0]
  ------------------
   98|    473|        return user_callbacks->type;
   99|    473|    }
  100|      0|    return NULL;
  101|    473|}

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

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

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

ssh_get_hmactab:
   74|     28|struct ssh_hmac_struct *ssh_get_hmactab(void) {
   75|     28|  return ssh_hmac_tab;
   76|     28|}
hmac_digest_len:
   78|  1.75k|size_t hmac_digest_len(enum ssh_hmac_e type) {
   79|  1.75k|  switch(type) {
   80|      0|    case SSH_HMAC_SHA1:
  ------------------
  |  Branch (80:5): [True: 0, False: 1.75k]
  ------------------
   81|      0|      return SHA_DIGEST_LEN;
  ------------------
  |  |   44|      0|#define SHA_DIGEST_LEN SHA_DIGEST_LENGTH
  ------------------
   82|      0|    case SSH_HMAC_SHA256:
  ------------------
  |  Branch (82:5): [True: 0, False: 1.75k]
  ------------------
   83|      0|      return SHA256_DIGEST_LEN;
  ------------------
  |  |   45|      0|#define SHA256_DIGEST_LEN SHA256_DIGEST_LENGTH
  ------------------
   84|      0|    case SSH_HMAC_SHA512:
  ------------------
  |  Branch (84:5): [True: 0, False: 1.75k]
  ------------------
   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: 1.75k]
  ------------------
   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: 1.75k]
  ------------------
   89|      0|      return POLY1305_TAGLEN;
  ------------------
  |  |   37|      0|#define POLY1305_TAGLEN 16
  ------------------
   90|      0|    case SSH_HMAC_AEAD_GCM:
  ------------------
  |  Branch (90:5): [True: 0, False: 1.75k]
  ------------------
   91|      0|      return AES_GCM_TAGLEN;
  ------------------
  |  |   58|      0|#define AES_GCM_TAGLEN 16
  ------------------
   92|  1.75k|    default:
  ------------------
  |  Branch (92:5): [True: 1.75k, False: 0]
  ------------------
   93|  1.75k|      return 0;
   94|  1.75k|  }
   95|  1.75k|}
ssh_cipher_clear:
  124|  2.11k|void ssh_cipher_clear(struct ssh_cipher_struct *cipher){
  125|       |#ifdef HAVE_LIBGCRYPT
  126|       |    unsigned int i;
  127|       |#endif
  128|       |
  129|  2.11k|    if (cipher == NULL) {
  ------------------
  |  Branch (129:9): [True: 2.05k, False: 56]
  ------------------
  130|  2.05k|        return;
  131|  2.05k|    }
  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|     56|    if (cipher->cleanup != NULL) {
  ------------------
  |  Branch (142:9): [True: 0, False: 56]
  ------------------
  143|      0|        cipher->cleanup(cipher);
  144|      0|    }
  145|     56|}
crypto_new:
  153|  1.17k|{
  154|  1.17k|    struct ssh_crypto_struct *crypto = NULL;
  155|       |
  156|  1.17k|    crypto = calloc(1, sizeof(struct ssh_crypto_struct));
  157|  1.17k|    if (crypto == NULL) {
  ------------------
  |  Branch (157:9): [True: 116, False: 1.05k]
  ------------------
  158|    116|        return NULL;
  159|    116|    }
  160|  1.05k|    return crypto;
  161|  1.17k|}
crypto_free:
  164|  1.87k|{
  165|  1.87k|    size_t i;
  166|       |
  167|  1.87k|    if (crypto == NULL) {
  ------------------
  |  Branch (167:9): [True: 816, False: 1.05k]
  ------------------
  168|    816|        return;
  169|    816|    }
  170|       |
  171|  1.05k|    ssh_key_free(crypto->server_pubkey);
  172|       |
  173|  1.05k|    ssh_dh_cleanup(crypto);
  174|  1.05k|    bignum_safe_free(crypto->shared_secret);
  ------------------
  |  |   71|  1.05k|#define bignum_safe_free(num) do { \
  |  |   72|  1.05k|    if ((num) != NULL) { \
  |  |  ------------------
  |  |  |  Branch (72:9): [True: 28, False: 1.02k]
  |  |  ------------------
  |  |   73|     28|        BN_clear_free((num)); \
  |  |   74|     28|        (num)=NULL; \
  |  |   75|     28|    } \
  |  |   76|  1.05k|    } while(0)
  |  |  ------------------
  |  |  |  Branch (76:13): [Folded, False: 1.05k]
  |  |  ------------------
  ------------------
  175|  1.05k|#ifdef HAVE_ECDH
  176|  1.05k|    SAFE_FREE(crypto->ecdh_client_pubkey);
  ------------------
  |  |  375|  1.05k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (375:31): [True: 57, False: 1.00k]
  |  |  |  Branch (375:71): [Folded, False: 1.05k]
  |  |  ------------------
  ------------------
  177|  1.05k|    SAFE_FREE(crypto->ecdh_server_pubkey);
  ------------------
  |  |  375|  1.05k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (375:31): [True: 0, False: 1.05k]
  |  |  |  Branch (375:71): [Folded, False: 1.05k]
  |  |  ------------------
  ------------------
  178|  1.05k|    if (crypto->ecdh_privkey != NULL) {
  ------------------
  |  Branch (178:9): [True: 57, False: 1.00k]
  ------------------
  179|     57|#ifdef HAVE_OPENSSL_ECC
  180|     57|#if OPENSSL_VERSION_NUMBER < 0x30000000L
  181|     57|        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|     57|        crypto->ecdh_privkey = NULL;
  192|     57|    }
  193|  1.05k|#endif
  194|  1.05k|#ifdef HAVE_LIBCRYPTO
  195|  1.05k|    EVP_PKEY_free(crypto->curve25519_privkey);
  196|       |#elif defined(HAVE_GCRYPT_CURVE25519)
  197|       |    gcry_sexp_release(crypto->curve25519_privkey);
  198|       |#endif
  199|  1.05k|    SAFE_FREE(crypto->dh_server_signature);
  ------------------
  |  |  375|  1.05k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (375:31): [True: 23, False: 1.03k]
  |  |  |  Branch (375:71): [Folded, False: 1.05k]
  |  |  ------------------
  ------------------
  200|  1.05k|    if (crypto->session_id != NULL) {
  ------------------
  |  Branch (200:9): [True: 28, False: 1.02k]
  ------------------
  201|     28|        ssh_burn(crypto->session_id, crypto->session_id_len);
  ------------------
  |  |  390|     28|#define ssh_burn(ptr, len) explicit_bzero((ptr), (len))
  ------------------
  202|     28|        SAFE_FREE(crypto->session_id);
  ------------------
  |  |  375|     28|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (375:31): [True: 28, False: 0]
  |  |  |  Branch (375:71): [Folded, False: 28]
  |  |  ------------------
  ------------------
  203|     28|    }
  204|  1.05k|    if (crypto->secret_hash != NULL) {
  ------------------
  |  Branch (204:9): [True: 28, False: 1.02k]
  ------------------
  205|     28|        ssh_burn(crypto->secret_hash, crypto->digest_len);
  ------------------
  |  |  390|     28|#define ssh_burn(ptr, len) explicit_bzero((ptr), (len))
  ------------------
  206|     28|        SAFE_FREE(crypto->secret_hash);
  ------------------
  |  |  375|     28|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (375:31): [True: 28, False: 0]
  |  |  |  Branch (375:71): [Folded, False: 28]
  |  |  ------------------
  ------------------
  207|     28|    }
  208|  1.05k|    compress_cleanup(crypto);
  209|  1.05k|    SAFE_FREE(crypto->encryptIV);
  ------------------
  |  |  375|  1.05k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (375:31): [True: 28, False: 1.02k]
  |  |  |  Branch (375:71): [Folded, False: 1.05k]
  |  |  ------------------
  ------------------
  210|  1.05k|    SAFE_FREE(crypto->decryptIV);
  ------------------
  |  |  375|  1.05k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (375:31): [True: 28, False: 1.02k]
  |  |  |  Branch (375:71): [Folded, False: 1.05k]
  |  |  ------------------
  ------------------
  211|  1.05k|    SAFE_FREE(crypto->encryptMAC);
  ------------------
  |  |  375|  1.05k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (375:31): [True: 28, False: 1.02k]
  |  |  |  Branch (375:71): [Folded, False: 1.05k]
  |  |  ------------------
  ------------------
  212|  1.05k|    SAFE_FREE(crypto->decryptMAC);
  ------------------
  |  |  375|  1.05k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (375:31): [True: 28, False: 1.02k]
  |  |  |  Branch (375:71): [Folded, False: 1.05k]
  |  |  ------------------
  ------------------
  213|  1.05k|    if (crypto->encryptkey != NULL) {
  ------------------
  |  Branch (213:9): [True: 28, False: 1.02k]
  ------------------
  214|     28|        ssh_burn(crypto->encryptkey, crypto->out_cipher->keysize / 8);
  ------------------
  |  |  390|     28|#define ssh_burn(ptr, len) explicit_bzero((ptr), (len))
  ------------------
  215|     28|        SAFE_FREE(crypto->encryptkey);
  ------------------
  |  |  375|     28|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (375:31): [True: 28, False: 0]
  |  |  |  Branch (375:71): [Folded, False: 28]
  |  |  ------------------
  ------------------
  216|     28|    }
  217|  1.05k|    if (crypto->decryptkey != NULL) {
  ------------------
  |  Branch (217:9): [True: 28, False: 1.02k]
  ------------------
  218|     28|        ssh_burn(crypto->decryptkey, crypto->in_cipher->keysize / 8);
  ------------------
  |  |  390|     28|#define ssh_burn(ptr, len) explicit_bzero((ptr), (len))
  ------------------
  219|     28|        SAFE_FREE(crypto->decryptkey);
  ------------------
  |  |  375|     28|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (375:31): [True: 28, False: 0]
  |  |  |  Branch (375:71): [Folded, False: 28]
  |  |  ------------------
  ------------------
  220|     28|    }
  221|       |
  222|  1.05k|    cipher_free(crypto->in_cipher);
  223|  1.05k|    cipher_free(crypto->out_cipher);
  224|       |
  225|  11.6k|    for (i = 0; i < SSH_KEX_METHODS; i++) {
  ------------------
  |  |   27|  11.6k|#define SSH_KEX_METHODS 10
  ------------------
  |  Branch (225:17): [True: 10.5k, False: 1.05k]
  ------------------
  226|  10.5k|        SAFE_FREE(crypto->client_kex.methods[i]);
  ------------------
  |  |  375|  10.5k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (375:31): [True: 4.12k, False: 6.45k]
  |  |  |  Branch (375:71): [Folded, False: 10.5k]
  |  |  ------------------
  ------------------
  227|  10.5k|        SAFE_FREE(crypto->server_kex.methods[i]);
  ------------------
  |  |  375|  10.5k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (375:31): [True: 2.44k, False: 8.13k]
  |  |  |  Branch (375:71): [Folded, False: 10.5k]
  |  |  ------------------
  ------------------
  228|  10.5k|        SAFE_FREE(crypto->kex_methods[i]);
  ------------------
  |  |  375|  10.5k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (375:31): [True: 1.68k, False: 8.88k]
  |  |  |  Branch (375:71): [Folded, False: 10.5k]
  |  |  ------------------
  ------------------
  229|  10.5k|    }
  230|       |
  231|       |#ifdef HAVE_OPENSSL_MLKEM
  232|       |    EVP_PKEY_free(crypto->mlkem_privkey);
  233|       |#else
  234|  1.05k|    if (crypto->mlkem_privkey != NULL) {
  ------------------
  |  Branch (234:9): [True: 49, False: 1.00k]
  ------------------
  235|     49|        ssh_burn(crypto->mlkem_privkey, crypto->mlkem_privkey_len);
  ------------------
  |  |  390|     49|#define ssh_burn(ptr, len) explicit_bzero((ptr), (len))
  ------------------
  236|     49|        SAFE_FREE(crypto->mlkem_privkey);
  ------------------
  |  |  375|     49|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (375:31): [True: 49, False: 0]
  |  |  |  Branch (375:71): [Folded, False: 49]
  |  |  ------------------
  ------------------
  237|     49|        crypto->mlkem_privkey_len = 0;
  238|     49|    }
  239|  1.05k|#endif
  240|  1.05k|    ssh_string_burn(crypto->hybrid_shared_secret);
  241|  1.05k|    ssh_string_free(crypto->mlkem_client_pubkey);
  242|  1.05k|    ssh_string_free(crypto->mlkem_ciphertext);
  243|  1.05k|    ssh_string_free(crypto->hybrid_client_init);
  244|  1.05k|    ssh_string_free(crypto->hybrid_server_reply);
  245|  1.05k|    ssh_string_free(crypto->hybrid_shared_secret);
  246|       |
  247|  1.05k|    ssh_burn(crypto, sizeof(struct ssh_crypto_struct));
  ------------------
  |  |  390|  1.05k|#define ssh_burn(ptr, len) explicit_bzero((ptr), (len))
  ------------------
  248|       |
  249|       |    SAFE_FREE(crypto);
  ------------------
  |  |  375|  1.05k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (375:31): [True: 1.05k, False: 0]
  |  |  |  Branch (375:71): [Folded, False: 1.05k]
  |  |  ------------------
  ------------------
  250|  1.05k|}
crypt_set_algorithms_client:
  429|     28|{
  430|     28|    return crypt_set_algorithms2(session);
  431|     28|}
wrapper.c:cipher_free:
  147|  2.11k|static void cipher_free(struct ssh_cipher_struct *cipher) {
  148|  2.11k|  ssh_cipher_clear(cipher);
  149|       |  SAFE_FREE(cipher);
  ------------------
  |  |  375|  2.11k|#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
  |  |  ------------------
  |  |  |  Branch (375:31): [True: 56, False: 2.05k]
  |  |  |  Branch (375:71): [Folded, False: 2.11k]
  |  |  ------------------
  ------------------
  150|  2.11k|}
wrapper.c:crypt_set_algorithms2:
  275|     28|{
  276|     28|    const char *wanted = NULL;
  277|     28|    const char *method = NULL;
  278|     28|    struct ssh_cipher_struct *ssh_ciphertab=ssh_get_ciphertab();
  279|     28|    struct ssh_hmac_struct *ssh_hmactab=ssh_get_hmactab();
  280|     28|    uint8_t i = 0;
  281|     28|    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|     28|    wanted = session->next_crypto->kex_methods[SSH_CRYPT_C_S];
  290|    308|    for (i = 0; i < 64 && ssh_ciphertab[i].name != NULL; ++i) {
  ------------------
  |  Branch (290:17): [True: 308, False: 0]
  |  Branch (290:27): [True: 308, False: 0]
  ------------------
  291|    308|        cmp = strcmp(wanted, ssh_ciphertab[i].name);
  292|    308|        if (cmp == 0) {
  ------------------
  |  Branch (292:13): [True: 28, False: 280]
  ------------------
  293|     28|            break;
  294|     28|        }
  295|    308|    }
  296|       |
  297|     28|    if (ssh_ciphertab[i].name == NULL) {
  ------------------
  |  Branch (297:9): [True: 0, False: 28]
  ------------------
  298|      0|        ssh_set_error(session, SSH_FATAL,
  ------------------
  |  |  313|      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;
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  302|      0|    }
  303|     28|    SSH_LOG(SSH_LOG_PACKET, "Set output algorithm to %s", wanted);
  ------------------
  |  |  283|     28|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  304|       |
  305|     28|    session->next_crypto->out_cipher = cipher_new(i);
  306|     28|    if (session->next_crypto->out_cipher == NULL) {
  ------------------
  |  Branch (306:9): [True: 0, False: 28]
  ------------------
  307|      0|        ssh_set_error_oom(session);
  ------------------
  |  |  320|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
  308|      0|        return SSH_ERROR;
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  309|      0|    }
  310|       |
  311|     28|    if (session->next_crypto->out_cipher->aead_encrypt != NULL) {
  ------------------
  |  Branch (311:9): [True: 0, False: 28]
  ------------------
  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|     28|    } else {
  319|       |        /*
  320|       |         * We must scan the kex entries to find hmac algorithms and set their
  321|       |         * appropriate structure.
  322|       |         */
  323|       |
  324|       |        /* out */
  325|     28|        wanted = session->next_crypto->kex_methods[SSH_MAC_C_S];
  326|     28|    }
  327|       |
  328|    308|    for (i = 0; ssh_hmactab[i].name != NULL; i++) {
  ------------------
  |  Branch (328:17): [True: 308, False: 0]
  ------------------
  329|    308|        cmp = strcmp(wanted, ssh_hmactab[i].name);
  330|    308|        if (cmp == 0) {
  ------------------
  |  Branch (330:13): [True: 28, False: 280]
  ------------------
  331|     28|            break;
  332|     28|        }
  333|    308|    }
  334|       |
  335|     28|    if (ssh_hmactab[i].name == NULL) {
  ------------------
  |  Branch (335:9): [True: 0, False: 28]
  ------------------
  336|      0|        ssh_set_error(session, SSH_FATAL,
  ------------------
  |  |  313|      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;
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  340|      0|    }
  341|     28|    SSH_LOG(SSH_LOG_PACKET, "Set HMAC output algorithm to %s", wanted);
  ------------------
  |  |  283|     28|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  342|       |
  343|     28|    session->next_crypto->out_hmac = ssh_hmactab[i].hmac_type;
  344|     28|    session->next_crypto->out_hmac_etm = ssh_hmactab[i].etm;
  345|       |
  346|       |    /* in */
  347|     28|    wanted = session->next_crypto->kex_methods[SSH_CRYPT_S_C];
  348|       |
  349|    308|    for (i = 0; ssh_ciphertab[i].name != NULL; i++) {
  ------------------
  |  Branch (349:17): [True: 308, False: 0]
  ------------------
  350|    308|        cmp = strcmp(wanted, ssh_ciphertab[i].name);
  351|    308|        if (cmp == 0) {
  ------------------
  |  Branch (351:13): [True: 28, False: 280]
  ------------------
  352|     28|            break;
  353|     28|        }
  354|    308|    }
  355|       |
  356|     28|    if (ssh_ciphertab[i].name == NULL) {
  ------------------
  |  Branch (356:9): [True: 0, False: 28]
  ------------------
  357|      0|        ssh_set_error(session, SSH_FATAL,
  ------------------
  |  |  313|      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;
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  361|      0|    }
  362|     28|    SSH_LOG(SSH_LOG_PACKET, "Set input algorithm to %s", wanted);
  ------------------
  |  |  283|     28|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  363|       |
  364|     28|    session->next_crypto->in_cipher = cipher_new(i);
  365|     28|    if (session->next_crypto->in_cipher == NULL) {
  ------------------
  |  Branch (365:9): [True: 0, False: 28]
  ------------------
  366|      0|        ssh_set_error_oom(session);
  ------------------
  |  |  320|      0|    _ssh_set_error_oom(error, __func__)
  ------------------
  367|      0|        return SSH_ERROR;
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  368|      0|    }
  369|       |
  370|     28|    if (session->next_crypto->in_cipher->aead_encrypt != NULL){
  ------------------
  |  Branch (370:9): [True: 0, False: 28]
  ------------------
  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|     28|    } else {
  378|       |        /* we must scan the kex entries to find hmac algorithms and set their appropriate structure */
  379|     28|        wanted = session->next_crypto->kex_methods[SSH_MAC_S_C];
  380|     28|    }
  381|       |
  382|    308|    for (i = 0; ssh_hmactab[i].name != NULL; i++) {
  ------------------
  |  Branch (382:17): [True: 308, False: 0]
  ------------------
  383|    308|        cmp = strcmp(wanted, ssh_hmactab[i].name);
  384|    308|        if (cmp == 0) {
  ------------------
  |  Branch (384:13): [True: 28, False: 280]
  ------------------
  385|     28|            break;
  386|     28|        }
  387|    308|    }
  388|       |
  389|     28|    if (ssh_hmactab[i].name == NULL) {
  ------------------
  |  Branch (389:9): [True: 0, False: 28]
  ------------------
  390|      0|        ssh_set_error(session, SSH_FATAL,
  ------------------
  |  |  313|      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;
  ------------------
  |  |  316|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  394|      0|    }
  395|     28|    SSH_LOG(SSH_LOG_PACKET, "Set HMAC input algorithm to %s", wanted);
  ------------------
  |  |  283|     28|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  396|       |
  397|     28|    session->next_crypto->in_hmac = ssh_hmactab[i].hmac_type;
  398|     28|    session->next_crypto->in_hmac_etm = ssh_hmactab[i].etm;
  399|       |
  400|       |    /* compression: client */
  401|     28|    method = session->next_crypto->kex_methods[SSH_COMP_C_S];
  402|     28|    cmp = strcmp(method, "zlib");
  403|     28|    if (cmp == 0) {
  ------------------
  |  Branch (403:9): [True: 0, False: 28]
  ------------------
  404|      0|        SSH_LOG(SSH_LOG_PACKET, "enabling C->S compression");
  ------------------
  |  |  283|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  405|      0|        compression_enable(session, SSH_DIRECTION_OUT, false);
  406|      0|    }
  407|     28|    cmp = strcmp(method, "zlib@openssh.com");
  408|     28|    if (cmp == 0) {
  ------------------
  |  Branch (408:9): [True: 0, False: 28]
  ------------------
  409|      0|        SSH_LOG(SSH_LOG_PACKET, "enabling C->S delayed compression");
  ------------------
  |  |  283|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  410|      0|        compression_enable(session, SSH_DIRECTION_OUT, true);
  411|      0|    }
  412|       |
  413|     28|    method = session->next_crypto->kex_methods[SSH_COMP_S_C];
  414|     28|    cmp = strcmp(method, "zlib");
  415|     28|    if (cmp == 0) {
  ------------------
  |  Branch (415:9): [True: 0, False: 28]
  ------------------
  416|      0|        SSH_LOG(SSH_LOG_PACKET, "enabling S->C compression");
  ------------------
  |  |  283|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  417|      0|        compression_enable(session, SSH_DIRECTION_IN, false);
  418|      0|    }
  419|     28|    cmp = strcmp(method, "zlib@openssh.com");
  420|     28|    if (cmp == 0) {
  ------------------
  |  Branch (420:9): [True: 0, False: 28]
  ------------------
  421|      0|        SSH_LOG(SSH_LOG_PACKET, "enabling S->C delayed compression");
  ------------------
  |  |  283|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
  422|      0|        compression_enable(session, SSH_DIRECTION_IN, true);
  423|      0|    }
  424|       |
  425|     28|    return SSH_OK;
  ------------------
  |  |  315|     28|#define SSH_OK 0     /* No error */
  ------------------
  426|     28|}
wrapper.c:cipher_new:
  110|     56|static struct ssh_cipher_struct *cipher_new(uint8_t offset) {
  111|     56|  struct ssh_cipher_struct *cipher = NULL;
  112|       |
  113|     56|  cipher = malloc(sizeof(struct ssh_cipher_struct));
  114|     56|  if (cipher == NULL) {
  ------------------
  |  Branch (114:7): [True: 0, False: 56]
  ------------------
  115|      0|    return NULL;
  116|      0|  }
  117|       |
  118|       |  /* note the memcpy will copy the pointers : so, you shouldn't free them */
  119|     56|  memcpy(cipher, &ssh_get_ciphertab()[offset], sizeof(*cipher));
  120|       |
  121|     56|  return cipher;
  122|     56|}

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: 0, False: 2]
  ------------------
  130|      0|        nalloc_random_bitmask = false;
  131|      0|        nalloc_bitmask = 0;
  132|      0|        return;
  133|      0|    }
  134|       |
  135|      2|    char *verbose = getenv("NALLOC_VERBOSE");
  136|      2|    if (verbose) {
  ------------------
  |  Branch (136:9): [True: 0, False: 2]
  ------------------
  137|       |        nalloc_verbose = true;
  138|      0|    }
  139|      2|}
recv:
  289|  1.38k|{
  290|  1.38k|    if (nalloc_fail(count, "recv")) {
  ------------------
  |  Branch (290:9): [True: 0, False: 1.38k]
  ------------------
  291|      0|        errno = EIO;
  292|      0|        return -1;
  293|      0|    }
  294|  1.38k|    return nalloc_recv(fd, buf, count, flags);
  ------------------
  |  |  265|  1.38k|#define nalloc_recv(f, b, s, x) __recv(f, b, s, x)
  ------------------
  295|  1.38k|}
send:
  298|  2.05k|{
  299|  2.05k|    if (nalloc_fail(count, "send")) {
  ------------------
  |  Branch (299:9): [True: 0, False: 2.05k]
  ------------------
  300|      0|        errno = EIO;
  301|      0|        return -1;
  302|      0|    }
  303|  2.05k|    return nalloc_send(fd, buf, count, flags);
  ------------------
  |  |  266|  2.05k|#define nalloc_send(f, b, s, x) __send(f, b, s, x)
  ------------------
  304|  2.05k|}
calloc:
  307|  35.5k|{
  308|  35.5k|    if (nalloc_fail(size, "calloc")) {
  ------------------
  |  Branch (308:9): [True: 438, False: 35.1k]
  ------------------
  309|    438|        errno = ENOMEM;
  310|    438|        return NULL;
  311|    438|    }
  312|  35.1k|    return nalloc_calloc(nmemb, size);
  ------------------
  |  |  259|  35.1k|#define nalloc_calloc(s, n)          __libc_calloc(s, n)
  ------------------
  313|  35.5k|}
malloc:
  316|   377k|{
  317|   377k|    if (nalloc_fail(size, "malloc")) {
  ------------------
  |  Branch (317:9): [True: 1, False: 377k]
  ------------------
  318|      1|        errno = ENOMEM;
  319|      1|        return NULL;
  320|      1|    }
  321|   377k|    return nalloc_malloc(size);
  ------------------
  |  |  258|   377k|#define nalloc_malloc(s)             __libc_malloc(s)
  ------------------
  322|   377k|}
realloc:
  325|  11.6k|{
  326|  11.6k|    if (nalloc_fail(size, "realloc")) {
  ------------------
  |  Branch (326:9): [True: 18, False: 11.6k]
  ------------------
  327|     18|        errno = ENOMEM;
  328|     18|        return NULL;
  329|     18|    }
  330|  11.6k|    return nalloc_realloc(ptr, size);
  ------------------
  |  |  260|  11.6k|#define nalloc_realloc(p, s)         __libc_realloc(p, s)
  ------------------
  331|  11.6k|}
ssh_client_fuzzer.c:nalloc_fail:
  194|   427k|{
  195|       |    // do not fail before thread init
  196|   427k|    if (nalloc_runs == 0) {
  ------------------
  |  Branch (196:9): [True: 8.59k, False: 419k]
  ------------------
  197|  8.59k|        return false;
  198|  8.59k|    }
  199|   419k|    if (__sync_fetch_and_add(&nalloc_running, 1) != 1) {
  ------------------
  |  Branch (199:9): [True: 5.59k, False: 413k]
  ------------------
  200|       |        // do not fail allocations outside of fuzzer input
  201|       |        // and do not fail inside of this function
  202|  5.59k|        __sync_fetch_and_sub(&nalloc_running, 1);
  203|  5.59k|        return false;
  204|  5.59k|    }
  205|   413k|    nalloc_random_update((uint8_t)size);
  206|   413k|    if (size >= 0x100) {
  ------------------
  |  Branch (206:9): [True: 325k, False: 88.6k]
  ------------------
  207|   325k|        nalloc_random_update((uint8_t)(size >> 8));
  208|   325k|        if (size >= 0x10000) {
  ------------------
  |  Branch (208:13): [True: 67, False: 324k]
  ------------------
  209|     67|            nalloc_random_update((uint8_t)(size >> 16));
  210|       |            // bigger may already fail or oom
  211|     67|        }
  212|   325k|    }
  213|   413k|    if (((nalloc_random_state ^ nalloc_magic) & nalloc_bitmask) == 0) {
  ------------------
  |  Branch (213:9): [True: 457, False: 413k]
  ------------------
  214|    457|        if (nalloc_backtrace_exclude(size, op)) {
  ------------------
  |  Branch (214:13): [True: 0, False: 457]
  ------------------
  215|      0|            __sync_fetch_and_sub(&nalloc_running, 1);
  216|      0|            return false;
  217|      0|        }
  218|    457|        __sync_fetch_and_sub(&nalloc_running, 1);
  219|    457|        return true;
  220|    457|    }
  221|   413k|    __sync_fetch_and_sub(&nalloc_running, 1);
  222|       |    return false;
  223|   413k|}
ssh_client_fuzzer.c:nalloc_random_update:
  143|  10.4M|{
  144|  10.4M|    nalloc_random_state =
  145|  10.4M|        ((uint32_t)((uint32_t)nalloc_random_state << 8)) ^
  146|  10.4M|        nalloc_crc32_table[((nalloc_random_state >> 24) ^ b) & 0xFF];
  147|  10.4M|}
ssh_client_fuzzer.c:nalloc_backtrace_exclude:
  181|    457|{
  182|    457|    if (nalloc_verbose) {
  ------------------
  |  Branch (182:9): [True: 0, False: 457]
  ------------------
  183|      0|        fprintf(stderr, "failed %s(%zu) \n", op, size);
  184|       |#ifdef NALLOC_ASAN
  185|       |        __sanitizer_print_stack_trace();
  186|       |#endif
  187|      0|    }
  188|       |
  189|       |    return false;
  190|    457|}
ssh_client_fuzzer.c:nalloc_start:
  151|    930|{
  152|    930|    if (nalloc_random_bitmask) {
  ------------------
  |  Branch (152:9): [True: 930, False: 0]
  ------------------
  153|    930|        if (nalloc_random_state & 0x10) {
  ------------------
  |  Branch (153:13): [True: 473, False: 457]
  ------------------
  154|    473|            nalloc_bitmask = 0xFFFFFFFF;
  155|    473|        } else {
  156|    457|            nalloc_bitmask = 1 << (5 + (nalloc_random_state & 0xF));
  157|    457|        }
  158|    930|    } else if (nalloc_bitmask == 0) {
  ------------------
  |  Branch (158:16): [True: 0, False: 0]
  ------------------
  159|       |        // nalloc disabled
  160|      0|        return 2;
  161|      0|    }
  162|    930|    nalloc_random_state = 0;
  163|  9.75M|    for (size_t i = 0; i < size; i++) {
  ------------------
  |  Branch (163:24): [True: 9.75M, False: 930]
  ------------------
  164|  9.75M|        nalloc_random_update(data[i]);
  165|  9.75M|    }
  166|    930|    if (__sync_fetch_and_add(&nalloc_running, 1)) {
  ------------------
  |  Branch (166:9): [True: 0, False: 930]
  ------------------
  167|      0|        __sync_fetch_and_sub(&nalloc_running, 1);
  168|      0|        return 0;
  169|      0|    }
  170|    930|    nalloc_runs++;
  171|    930|    return 1;
  172|    930|}
ssh_client_fuzzer.c:nalloc_end:
  176|    930|{
  177|    930|    __sync_fetch_and_sub(&nalloc_running, 1);
  178|    930|}

LLVMFuzzerInitialize:
   35|      2|{
   36|      2|    (void)argc;
   37|       |
   38|      2|    nalloc_init(*argv[0]);
   39|       |
   40|      2|    ssh_init();
   41|       |
   42|      2|    atexit(_fuzz_finalize);
   43|       |
   44|      2|    return 0;
   45|      2|}
LLVMFuzzerTestOneInput:
  108|    933|{
  109|    933|    ssh_session session = NULL;
  110|    933|    ssh_channel channel = NULL;
  111|    933|    const char *env = NULL;
  112|    933|    int socket_fds[2] = {-1, -1};
  113|    933|    ssize_t nwritten;
  114|    933|    bool no = false;
  115|    933|    int rc;
  116|    933|    long timeout = 1; /* use short timeout to avoid timeouts during fuzzing */
  117|       |
  118|       |    /* This is the maximum that can be handled by the socket buffer before the
  119|       |     * other side will read some data. Other option would be feeding the socket
  120|       |     * from different thread which would not mind if it would be blocked, but I
  121|       |     * believe all the important inputs should fit into this size */
  122|    933|    if (size > 219264) {
  ------------------
  |  Branch (122:9): [True: 3, False: 930]
  ------------------
  123|      3|        return -1;
  124|      3|    }
  125|       |
  126|       |    /* Set up the socket to send data */
  127|    930|    rc = socketpair(AF_UNIX, SOCK_STREAM, 0, socket_fds);
  128|    930|    assert(rc == 0);
  ------------------
  |  Branch (128:5): [True: 0, False: 930]
  |  Branch (128:5): [True: 930, False: 0]
  ------------------
  129|       |
  130|    930|    nwritten = send(socket_fds[1], data, size, 0);
  131|    930|    assert((size_t)nwritten == size);
  ------------------
  |  Branch (131:5): [True: 0, False: 930]
  |  Branch (131:5): [True: 930, False: 0]
  ------------------
  132|       |
  133|    930|    rc = shutdown(socket_fds[1], SHUT_WR);
  134|    930|    assert(rc == 0);
  ------------------
  |  Branch (134:5): [True: 0, False: 930]
  |  Branch (134:5): [True: 930, False: 0]
  ------------------
  135|       |
  136|    930|    assert(nalloc_start(data, size) > 0);
  ------------------
  |  Branch (136:5): [True: 0, False: 930]
  |  Branch (136:5): [True: 930, False: 0]
  ------------------
  137|       |
  138|    930|    session = ssh_new();
  139|    930|    if (session == NULL) {
  ------------------
  |  Branch (139:9): [True: 457, False: 473]
  ------------------
  140|    457|        goto out;
  141|    457|    }
  142|       |
  143|    473|    env = getenv("LIBSSH_VERBOSITY");
  144|    473|    if (env != NULL && strlen(env) > 0) {
  ------------------
  |  Branch (144:9): [True: 0, False: 473]
  |  Branch (144:24): [True: 0, False: 0]
  ------------------
  145|      0|        ssh_options_set(session, SSH_OPTIONS_LOG_VERBOSITY_STR, env);
  146|      0|    }
  147|    473|    rc = ssh_options_set(session, SSH_OPTIONS_FD, &socket_fds[0]);
  148|    473|    if (rc != SSH_OK) {
  ------------------
  |  |  315|    473|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (148:9): [True: 0, False: 473]
  ------------------
  149|      0|        goto out;
  150|      0|    }
  151|    473|    rc = ssh_options_set(session, SSH_OPTIONS_HOST, "127.0.0.1");
  152|    473|    if (rc != SSH_OK) {
  ------------------
  |  |  315|    473|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (152:9): [True: 0, False: 473]
  ------------------
  153|      0|        goto out;
  154|      0|    }
  155|    473|    rc = ssh_options_set(session, SSH_OPTIONS_USER, "alice");
  156|    473|    if (rc != SSH_OK) {
  ------------------
  |  |  315|    473|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (156:9): [True: 0, False: 473]
  ------------------
  157|      0|        goto out;
  158|      0|    }
  159|    473|    rc = ssh_options_set(session, SSH_OPTIONS_CIPHERS_C_S, "none");
  160|    473|    if (rc != SSH_OK) {
  ------------------
  |  |  315|    473|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (160:9): [True: 0, False: 473]
  ------------------
  161|      0|        goto out;
  162|      0|    }
  163|    473|    rc = ssh_options_set(session, SSH_OPTIONS_CIPHERS_S_C, "none");
  164|    473|    if (rc != SSH_OK) {
  ------------------
  |  |  315|    473|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (164:9): [True: 0, False: 473]
  ------------------
  165|      0|        goto out;
  166|      0|    }
  167|    473|    rc = ssh_options_set(session, SSH_OPTIONS_HMAC_C_S, "none");
  168|    473|    if (rc != SSH_OK) {
  ------------------
  |  |  315|    473|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (168:9): [True: 0, False: 473]
  ------------------
  169|      0|        goto out;
  170|      0|    }
  171|    473|    rc = ssh_options_set(session, SSH_OPTIONS_HMAC_S_C, "none");
  172|    473|    if (rc != SSH_OK) {
  ------------------
  |  |  315|    473|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (172:9): [True: 0, False: 473]
  ------------------
  173|      0|        goto out;
  174|      0|    }
  175|    473|    rc = ssh_options_set(session, SSH_OPTIONS_PROCESS_CONFIG, &no);
  176|    473|    if (rc != SSH_OK) {
  ------------------
  |  |  315|    473|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (176:9): [True: 0, False: 473]
  ------------------
  177|      0|        goto out;
  178|      0|    }
  179|    473|    rc = ssh_options_set(session, SSH_OPTIONS_TIMEOUT, &timeout);
  180|    473|    if (rc != SSH_OK) {
  ------------------
  |  |  315|    473|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (180:9): [True: 0, False: 473]
  ------------------
  181|      0|        goto out;
  182|      0|    }
  183|       |
  184|    473|    ssh_callbacks_init(&cb);
  ------------------
  |  |  535|    473|#define ssh_callbacks_init(p) do {\
  |  |  536|    473|	(p)->size=sizeof(*(p)); \
  |  |  537|    473|} while(0);
  |  |  ------------------
  |  |  |  Branch (537:9): [Folded, False: 473]
  |  |  ------------------
  ------------------
  185|    473|    ssh_set_callbacks(session, &cb);
  186|       |
  187|    473|    rc = ssh_connect(session);
  188|    473|    if (rc != SSH_OK) {
  ------------------
  |  |  315|    473|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (188:9): [True: 473, False: 0]
  ------------------
  189|    473|        goto out;
  190|    473|    }
  191|       |
  192|      0|    rc = ssh_userauth_none(session, NULL);
  193|      0|    if (rc != SSH_OK) {
  ------------------
  |  |  315|      0|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (193:9): [True: 0, False: 0]
  ------------------
  194|      0|        goto out;
  195|      0|    }
  196|       |
  197|      0|    channel = ssh_channel_new(session);
  198|      0|    if (channel == NULL) {
  ------------------
  |  Branch (198:9): [True: 0, False: 0]
  ------------------
  199|      0|        goto out;
  200|      0|    }
  201|       |
  202|      0|    rc = ssh_channel_open_session(channel);
  203|      0|    if (rc != SSH_OK) {
  ------------------
  |  |  315|      0|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (203:9): [True: 0, False: 0]
  ------------------
  204|      0|        goto out;
  205|      0|    }
  206|       |
  207|      0|    rc = ssh_channel_request_exec(channel, "ls");
  208|      0|    if (rc != SSH_OK) {
  ------------------
  |  |  315|      0|#define SSH_OK 0     /* No error */
  ------------------
  |  Branch (208:9): [True: 0, False: 0]
  ------------------
  209|      0|        goto out;
  210|      0|    }
  211|       |
  212|      0|    select_loop(session, channel);
  213|       |
  214|    930|out:
  215|    930|    ssh_channel_free(channel);
  216|    930|    ssh_disconnect(session);
  217|    930|    ssh_free(session);
  218|       |
  219|    930|    close(socket_fds[0]);
  220|    930|    close(socket_fds[1]);
  221|       |
  222|    930|    nalloc_end();
  223|    930|    return 0;
  224|      0|}
ssh_client_fuzzer.c:_fuzz_finalize:
   30|      2|{
   31|      2|    ssh_finalize();
   32|      2|}

