ssh_dh_init:
  230|      1|{
  231|      1|    unsigned long g_int = 2 ;	/* G is defined as 2 by the ssh2 standards */
  232|      1|    int rc;
  233|      1|    if (dh_crypto_initialized) {
  ------------------
  |  Branch (233:9): [True: 0, False: 1]
  ------------------
  234|      0|        return SSH_OK;
  ------------------
  |  |  312|      0|#define SSH_OK 0     /* No error */
  ------------------
  235|      0|    }
  236|      1|    dh_crypto_initialized = 1;
  237|       |
  238|      1|    ssh_dh_generator = bignum_new();
  ------------------
  |  |   75|      1|#define bignum_new() BN_new()
  ------------------
  239|      1|    if (ssh_dh_generator == NULL) {
  ------------------
  |  Branch (239:9): [True: 0, False: 1]
  ------------------
  240|      0|        goto error;
  241|      0|    }
  242|      1|    rc = bignum_set_word(ssh_dh_generator, g_int);
  ------------------
  |  |   82|      1|#define bignum_set_word(bn,n) BN_set_word(bn,n)
  ------------------
  243|      1|    if (rc != 1) {
  ------------------
  |  Branch (243:9): [True: 0, False: 1]
  ------------------
  244|      0|        goto error;
  245|      0|    }
  246|       |
  247|      1|    bignum_bin2bn(p_group1_value, P_GROUP1_LEN, &ssh_dh_group1);
  ------------------
  |  |   84|      1|    do {                                     \
  |  |   85|      1|        (*dest) = BN_new();                  \
  |  |   86|      1|        if ((*dest) != NULL) {               \
  |  |  ------------------
  |  |  |  Branch (86:13): [True: 1, False: 0]
  |  |  ------------------
  |  |   87|      1|            BN_bin2bn(data,datalen,(*dest)); \
  |  |   88|      1|        }                                    \
  |  |   89|      1|    } while(0)
  |  |  ------------------
  |  |  |  Branch (89:13): [Folded - Ignored]
  |  |  ------------------
  ------------------
  248|      1|    if (ssh_dh_group1 == NULL) {
  ------------------
  |  Branch (248:9): [True: 0, False: 1]
  ------------------
  249|      0|        goto error;
  250|      0|    }
  251|      1|    bignum_bin2bn(p_group14_value, P_GROUP14_LEN, &ssh_dh_group14);
  ------------------
  |  |   84|      1|    do {                                     \
  |  |   85|      1|        (*dest) = BN_new();                  \
  |  |   86|      1|        if ((*dest) != NULL) {               \
  |  |  ------------------
  |  |  |  Branch (86:13): [True: 1, False: 0]
  |  |  ------------------
  |  |   87|      1|            BN_bin2bn(data,datalen,(*dest)); \
  |  |   88|      1|        }                                    \
  |  |   89|      1|    } while(0)
  |  |  ------------------
  |  |  |  Branch (89:13): [Folded - Ignored]
  |  |  ------------------
  ------------------
  252|      1|    if (ssh_dh_group14 == NULL) {
  ------------------
  |  Branch (252:9): [True: 0, False: 1]
  ------------------
  253|      0|        goto error;
  254|      0|    }
  255|      1|    bignum_bin2bn(p_group16_value, P_GROUP16_LEN, &ssh_dh_group16);
  ------------------
  |  |   84|      1|    do {                                     \
  |  |   85|      1|        (*dest) = BN_new();                  \
  |  |   86|      1|        if ((*dest) != NULL) {               \
  |  |  ------------------
  |  |  |  Branch (86:13): [True: 1, False: 0]
  |  |  ------------------
  |  |   87|      1|            BN_bin2bn(data,datalen,(*dest)); \
  |  |   88|      1|        }                                    \
  |  |   89|      1|    } while(0)
  |  |  ------------------
  |  |  |  Branch (89:13): [Folded - Ignored]
  |  |  ------------------
  ------------------
  256|      1|    if (ssh_dh_group16 == NULL) {
  ------------------
  |  Branch (256:9): [True: 0, False: 1]
  ------------------
  257|      0|        goto error;
  258|      0|    }
  259|      1|    bignum_bin2bn(p_group18_value, P_GROUP18_LEN, &ssh_dh_group18);
  ------------------
  |  |   84|      1|    do {                                     \
  |  |   85|      1|        (*dest) = BN_new();                  \
  |  |   86|      1|        if ((*dest) != NULL) {               \
  |  |  ------------------
  |  |  |  Branch (86:13): [True: 1, False: 0]
  |  |  ------------------
  |  |   87|      1|            BN_bin2bn(data,datalen,(*dest)); \
  |  |   88|      1|        }                                    \
  |  |   89|      1|    } while(0)
  |  |  ------------------
  |  |  |  Branch (89:13): [Folded - Ignored]
  |  |  ------------------
  ------------------
  260|      1|    if (ssh_dh_group18 == NULL) {
  ------------------
  |  Branch (260:9): [True: 0, False: 1]
  ------------------
  261|      0|        goto error;
  262|      0|    }
  263|       |
  264|      1|    return 0;
  265|      0|error:
  266|      0|    ssh_dh_finalize();
  267|      0|    return SSH_ERROR;
  ------------------
  |  |  313|      0|#define SSH_ERROR -1 /* Error of some kind */
  ------------------
  268|      1|}

libssh_constructor:
  114|      1|{
  115|       |
  116|      1|    int rc;
  117|       |
  118|      1|    rc = _ssh_init(1);
  119|       |
  120|      1|    if (rc < 0) {
  ------------------
  |  Branch (120:9): [True: 0, False: 1]
  ------------------
  121|      0|        fprintf(stderr, "Error in auto_init()\n");
  122|      0|    }
  123|       |
  124|      1|    return;
  125|      1|}
init.c:_ssh_init:
   62|      1|static int _ssh_init(unsigned constructor) {
   63|       |
   64|      1|    int rc = 0;
   65|       |
   66|      1|    if (!constructor) {
  ------------------
  |  Branch (66:9): [True: 0, False: 1]
  ------------------
   67|      0|        ssh_mutex_lock(&ssh_init_mutex);
   68|      0|    }
   69|       |
   70|      1|    _ssh_initialized++;
   71|       |
   72|      1|    if (_ssh_initialized > 1) {
  ------------------
  |  Branch (72:9): [True: 0, False: 1]
  ------------------
   73|      0|        rc = _ssh_init_ret;
   74|      0|        goto _ret;
   75|      0|    }
   76|       |
   77|      1|    rc = ssh_threads_init();
   78|      1|    if (rc) {
  ------------------
  |  Branch (78:9): [True: 0, False: 1]
  ------------------
   79|      0|        goto _ret;
   80|      0|    }
   81|       |
   82|      1|    rc = ssh_crypto_init();
   83|      1|    if (rc) {
  ------------------
  |  Branch (83:9): [True: 0, False: 1]
  ------------------
   84|      0|        goto _ret;
   85|      0|    }
   86|       |
   87|      1|    rc = ssh_dh_init();
   88|      1|    if (rc) {
  ------------------
  |  Branch (88:9): [True: 0, False: 1]
  ------------------
   89|      0|        goto _ret;
   90|      0|    }
   91|       |
   92|      1|    rc = ssh_socket_init();
   93|      1|    if (rc) {
  ------------------
  |  Branch (93:9): [True: 0, False: 1]
  ------------------
   94|      0|        goto _ret;
   95|      0|    }
   96|       |
   97|      1|_ret:
   98|      1|    _ssh_init_ret = rc;
   99|       |
  100|      1|    if (!constructor) {
  ------------------
  |  Branch (100:9): [True: 0, False: 1]
  ------------------
  101|      0|        ssh_mutex_unlock(&ssh_init_mutex);
  102|      0|    }
  103|       |
  104|      1|    return rc;
  105|      1|}

ssh_crypto_init:
 1373|      1|{
 1374|       |#ifndef HAVE_OPENSSL_EVP_CHACHA20
 1375|       |    size_t i;
 1376|       |#endif
 1377|       |
 1378|      1|    if (libcrypto_initialized) {
  ------------------
  |  Branch (1378:9): [True: 0, False: 1]
  ------------------
 1379|      0|        return SSH_OK;
  ------------------
  |  |  312|      0|#define SSH_OK 0     /* No error */
  ------------------
 1380|      0|    }
 1381|      1|    if (OpenSSL_version_num() != OPENSSL_VERSION_NUMBER){
  ------------------
  |  Branch (1381:9): [True: 0, False: 1]
  ------------------
 1382|      0|        SSH_LOG(SSH_LOG_DEBUG, "libssh compiled with %s "
  ------------------
  |  |  265|      0|    _ssh_log(priority, __func__, __VA_ARGS__)
  ------------------
 1383|      0|            "headers, currently running with %s.",
 1384|      0|            OPENSSL_VERSION_TEXT,
 1385|      0|            OpenSSL_version(OpenSSL_version_num())
 1386|      0|        );
 1387|      0|    }
 1388|       |#ifdef CAN_DISABLE_AESNI
 1389|       |    /*
 1390|       |     * disable AES-NI when running within Valgrind, because they generate
 1391|       |     * too many "uninitialized memory access" false positives
 1392|       |     */
 1393|       |    if (RUNNING_ON_VALGRIND){
 1394|       |        SSH_LOG(SSH_LOG_INFO, "Running within Valgrind, disabling AES-NI");
 1395|       |        /* Bit #57 denotes AES-NI instruction set extension */
 1396|       |        OPENSSL_ia32cap &= ~(1LL << 57);
 1397|       |    }
 1398|       |#endif /* CAN_DISABLE_AESNI */
 1399|       |
 1400|       |#ifndef HAVE_OPENSSL_EVP_CHACHA20
 1401|       |    for (i = 0; ssh_ciphertab[i].name != NULL; i++) {
 1402|       |        int cmp;
 1403|       |
 1404|       |        cmp = strcmp(ssh_ciphertab[i].name, "chacha20-poly1305@openssh.com");
 1405|       |        if (cmp == 0) {
 1406|       |            memcpy(&ssh_ciphertab[i],
 1407|       |                   ssh_get_chacha20poly1305_cipher(),
 1408|       |                   sizeof(struct ssh_cipher_struct));
 1409|       |            break;
 1410|       |        }
 1411|       |    }
 1412|       |#endif /* HAVE_OPENSSL_EVP_CHACHA20 */
 1413|       |
 1414|      1|    libcrypto_initialized = 1;
 1415|       |
 1416|      1|    return SSH_OK;
  ------------------
  |  |  312|      1|#define SSH_OK 0     /* No error */
  ------------------
 1417|      1|}

ssh_poll_init:
   88|      1|{
   89|      1|    return;
   90|      1|}

ssh_socket_init:
  107|      1|{
  108|      1|    if (sockets_initialized == 0) {
  ------------------
  |  Branch (108:9): [True: 1, False: 0]
  ------------------
  109|       |#ifdef _WIN32
  110|       |        struct WSAData wsaData;
  111|       |
  112|       |        /* Initiates use of the Winsock DLL by a process. */
  113|       |        if (WSAStartup(MAKEWORD(2, 0), &wsaData) != 0) {
  114|       |            return -1;
  115|       |        }
  116|       |#endif
  117|      1|        ssh_poll_init();
  118|       |
  119|      1|        sockets_initialized = 1;
  120|      1|    }
  121|       |
  122|      1|    return 0;
  123|      1|}

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

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

ssh_threads_get_default:
  132|      1|{
  133|      1|    return &ssh_threads_pthread;
  134|      1|}

