fuzz_early_setup:
   23|      2|void fuzz_early_setup(void) {
   24|       |    /* Set stderr to point to normal stderr by default */
   25|       |    fuzz.fake_stderr = stderr;
   26|      2|}
fuzz_common_setup:
   28|      1|void fuzz_common_setup(void) {
   29|      1|	disallow_core();
   30|      1|    fuzz.fuzzing = 1;
   31|      1|    fuzz.wrapfds = 1;
   32|      1|    fuzz.do_jmp = 1;
   33|      1|    fuzz.input = m_malloc(sizeof(buffer));
   34|      1|    _dropbear_log = fuzz_dropbear_log;
   35|      1|    crypto_init();
   36|      1|    fuzz_seed("start", 5);
   37|       |    /* let any messages get flushed */
   38|      1|    setlinebuf(stdout);
   39|       |#if DEBUG_TRACE
   40|       |    if (debug_trace)
   41|       |    {
   42|       |        fprintf(stderr, "Dropbear fuzzer: -v specified, not disabling stderr output\n");
   43|       |    }
   44|       |    else
   45|       |#endif
   46|      1|    if (getenv("DROPBEAR_KEEP_STDERR")) {
  ------------------
  |  Branch (46:9): [True: 0, False: 1]
  ------------------
   47|      0|        fprintf(stderr, "Dropbear fuzzer: DROPBEAR_KEEP_STDERR, not disabling stderr output\n");
   48|      0|    } 
   49|      1|    else 
   50|      1|    {
   51|      1|        fprintf(stderr, "Dropbear fuzzer: Disabling stderr output\n");
   52|      1|        fuzz.fake_stderr = fopen("/dev/null", "w");
   53|       |        assert(fuzz.fake_stderr);
  ------------------
  |  Branch (53:9): [True: 0, False: 1]
  |  Branch (53:9): [True: 1, False: 0]
  ------------------
   54|      1|    }
   55|      1|}
fuzz_set_input:
   57|  3.41k|int fuzz_set_input(const uint8_t *Data, size_t Size) {
   58|       |
   59|  3.41k|    fuzz.input->data = (unsigned char*)Data;
   60|  3.41k|    fuzz.input->size = Size;
   61|  3.41k|    fuzz.input->len = Size;
   62|  3.41k|    fuzz.input->pos = 0;
   63|       |
   64|  3.41k|    memset(&ses, 0x0, sizeof(ses));
   65|  3.41k|    memset(&svr_ses, 0x0, sizeof(svr_ses));
   66|  3.41k|    memset(&cli_ses, 0x0, sizeof(cli_ses));
   67|  3.41k|    wrapfd_setup(fuzz.input);
   68|       |    // printhex("input", fuzz.input->data, fuzz.input->len);
   69|       |
   70|  3.41k|    fuzz_seed(fuzz.input->data, MIN(fuzz.input->len, 16));
  ------------------
  |  Branch (70:33): [True: 296, False: 3.12k]
  ------------------
   71|       |
   72|  3.41k|    return DROPBEAR_SUCCESS;
  ------------------
  |  |  111|  3.41k|#define DROPBEAR_SUCCESS 0
  ------------------
   73|  3.41k|}
fuzz_cli_setup:
  112|      1|void fuzz_cli_setup(void) {
  113|      1|    fuzz_common_setup();
  114|       |    
  115|      1|	_dropbear_exit = cli_dropbear_exit;
  116|      1|	_dropbear_log = cli_dropbear_log;
  117|       |
  118|      1|    char *argv[] = { 
  119|      1|		"dbclient",
  120|      1|		"-y",
  121|      1|        "localhost",
  122|      1|        "uptime"
  123|      1|    };
  124|       |
  125|      1|    int argc = sizeof(argv) / sizeof(*argv);
  126|      1|    cli_getopts(argc, argv);
  127|       |
  128|      1|    load_fixed_client_key();
  129|       |    /* Avoid password prompt */
  130|      1|    setenv(DROPBEAR_PASSWORD_ENV, "password", 1);
  ------------------
  |  |  114|      1|#define DROPBEAR_PASSWORD_ENV "DROPBEAR_PASSWORD"
  ------------------
  131|      1|}
fuzz_kex_fakealgos:
  197|  2.39k|void fuzz_kex_fakealgos(void) {
  198|  2.39k|    ses.newkeys->recv.crypt_mode = &dropbear_mode_none;
  199|  2.39k|    ses.newkeys->recv.algo_mac = &dropbear_nohash;
  200|  2.39k|}
fuzz_run_client:
  299|  3.41k|int fuzz_run_client(const uint8_t *Data, size_t Size, int skip_kexmaths) {
  300|  3.41k|    static int once = 0;
  301|  3.41k|    if (!once) {
  ------------------
  |  Branch (301:9): [True: 1, False: 3.41k]
  ------------------
  302|      1|        fuzz_cli_setup();
  303|      1|        fuzz.skip_kexmaths = skip_kexmaths;
  304|      1|        once = 1;
  305|      1|    }
  306|       |
  307|  3.41k|    if (fuzz_set_input(Data, Size) == DROPBEAR_FAILURE) {
  ------------------
  |  |  112|  3.41k|#define DROPBEAR_FAILURE -1
  ------------------
  |  Branch (307:9): [True: 0, False: 3.41k]
  ------------------
  308|      0|        return 0;
  309|      0|    }
  310|       |
  311|       |    // Allow to proceed sooner
  312|  3.41k|    ses.kexstate.donefirstkex = 1;
  313|       |
  314|  3.41k|    uint32_t wrapseed;
  315|  3.41k|    genrandom((void*)&wrapseed, sizeof(wrapseed));
  316|  3.41k|    wrapfd_setseed(wrapseed);
  317|       |
  318|  3.41k|    int fakesock = wrapfd_new_fuzzinput();
  319|       |
  320|  3.41k|    m_malloc_set_epoch(1);
  321|  3.41k|    fuzz.do_jmp = 1;
  322|  3.41k|    if (setjmp(fuzz.jmp) == 0) {
  ------------------
  |  Branch (322:9): [True: 3.41k, False: 0]
  ------------------
  323|  3.41k|        cli_session(fakesock, fakesock, NULL, 0);
  324|      0|        m_malloc_free_epoch(1, 0);
  325|      0|    } else {
  326|      0|        fuzz.do_jmp = 0;
  327|      0|        m_malloc_free_epoch(1, 1);
  328|      0|        TRACE(("dropbear_exit longjmped"))
  329|       |        /* dropbear_exit jumped here */
  330|      0|    }
  331|       |
  332|      0|    return 0;
  333|  3.41k|}
fuzz_dump:
  345|   108k|void fuzz_dump(const unsigned char* data, size_t len) {
  346|   108k|    if (fuzz.dumping) {
  ------------------
  |  Branch (346:9): [True: 0, False: 108k]
  ------------------
  347|      0|        TRACE(("dump %zu", len))
  348|       |        assert(atomicio(vwrite, fuzz.recv_dumpfd, (void*)data, len) == len);
  ------------------
  |  Branch (348:9): [True: 0, False: 0]
  |  Branch (348:9): [True: 0, False: 0]
  ------------------
  349|      0|    }
  350|   108k|}
fuzz_getpwuid:
  386|      1|struct passwd* fuzz_getpwuid(uid_t uid) {
  387|      1|    if (!fuzz.fuzzing) {
  ------------------
  |  Branch (387:9): [True: 0, False: 1]
  ------------------
  388|      0|        return getpwuid(uid);
  389|      0|    }
  390|      1|    if (uid == pwd_other.pw_uid) {
  ------------------
  |  Branch (390:9): [True: 0, False: 1]
  ------------------
  391|      0|        return &pwd_other;
  392|      0|    }
  393|      1|    if (uid == pwd_root.pw_uid) {
  ------------------
  |  Branch (393:9): [True: 1, False: 0]
  ------------------
  394|      1|        return &pwd_root;
  395|      1|    }
  396|      0|    return NULL;
  397|      1|}
fuzz-common.c:load_fixed_client_key:
  135|      1|static void load_fixed_client_key(void) {
  136|       |
  137|      1|    buffer *b = buf_new(3000);
  138|      1|    sign_key *key;
  139|      1|    enum signkey_type keytype;
  140|       |
  141|      1|    key = new_sign_key();
  142|      1|    keytype = DROPBEAR_SIGNKEY_ANY;
  143|      1|    buf_putbytes(b, keyed25519, keyed25519_len);
  144|      1|    buf_setpos(b, 0);
  145|      1|    if (buf_get_priv_key(b, key, &keytype) == DROPBEAR_FAILURE) {
  ------------------
  |  |  112|      1|#define DROPBEAR_FAILURE -1
  ------------------
  |  Branch (145:9): [True: 0, False: 1]
  ------------------
  146|      0|        dropbear_exit("failed fixed ed25519 hostkey");
  147|      0|    }
  148|      1|    list_append(cli_opts.privkeys, key);
  149|       |
  150|      1|    buf_free(b);
  151|      1|}

fuzz-sshpacketmutator.c:alloc_static_buffers:
  126|      2|static void alloc_static_buffers() {
  127|       |
  128|      2|    int i;
  129|      2|    oup = buf_new(MAX_OUT_SIZE);
  130|      2|    alloc_packetA = buf_new(RECV_MAX_PACKET_LEN);
  ------------------
  |  |  249|      2|#define RECV_MAX_PACKET_LEN (MAX(35000, ((RECV_MAX_PAYLOAD_LEN)+100)))
  ------------------
  |  Branch (130:29): [True: 2, Folded]
  ------------------
  131|      2|    alloc_packetB = buf_new(RECV_MAX_PACKET_LEN);
  ------------------
  |  |  249|      2|#define RECV_MAX_PACKET_LEN (MAX(35000, ((RECV_MAX_PAYLOAD_LEN)+100)))
  ------------------
  |  Branch (131:29): [True: 2, Folded]
  ------------------
  132|       |
  133|  1.00k|    for (i = 0; i < MAX_FUZZ_PACKETS; i++) {
  ------------------
  |  |   20|  1.00k|#define MAX_FUZZ_PACKETS 500
  ------------------
  |  Branch (133:17): [True: 1.00k, False: 2]
  ------------------
  134|  1.00k|        packets1[i] = buf_new(RECV_MAX_PACKET_LEN);
  ------------------
  |  |  249|  1.00k|#define RECV_MAX_PACKET_LEN (MAX(35000, ((RECV_MAX_PAYLOAD_LEN)+100)))
  ------------------
  |  Branch (134:31): [True: 1.00k, Folded]
  ------------------
  135|  1.00k|    }
  136|  1.00k|    for (i = 0; i < MAX_FUZZ_PACKETS; i++) {
  ------------------
  |  |   20|  1.00k|#define MAX_FUZZ_PACKETS 500
  ------------------
  |  Branch (136:17): [True: 1.00k, False: 2]
  ------------------
  137|       |        packets2[i] = buf_new(RECV_MAX_PACKET_LEN);
  ------------------
  |  |  249|  1.00k|#define RECV_MAX_PACKET_LEN (MAX(35000, ((RECV_MAX_PAYLOAD_LEN)+100)))
  ------------------
  |  Branch (137:31): [True: 1.00k, Folded]
  ------------------
  138|  1.00k|    }
  139|      2|}

wrapfd_setup:
   32|  3.41k|void wrapfd_setup(buffer *buf) {
   33|  3.41k|	TRACE(("wrapfd_setup"))
   34|       |
   35|       |	// clean old ones
   36|  3.41k|	int i;
   37|  27.3k|	for (i = 0; i <= wrapfd_maxfd; i++) {
  ------------------
  |  Branch (37:14): [True: 23.9k, False: 3.41k]
  ------------------
   38|  23.9k|		if (wrap_fds[i].mode != UNUSED) {
  ------------------
  |  Branch (38:7): [True: 2.55k, False: 21.3k]
  ------------------
   39|  2.55k|			wrapfd_remove(i);
   40|  2.55k|		}
   41|  23.9k|	}
   42|  3.41k|	wrapfd_maxfd = -1;
   43|       |
   44|  3.41k|	memset(rand_state, 0x0, sizeof(rand_state));
   45|  3.41k|	wrapfd_setseed(50);
   46|  3.41k|	input_buf = buf;
   47|  3.41k|}
wrapfd_setseed:
   49|  6.83k|void wrapfd_setseed(uint32_t seed) {
   50|  6.83k|	memcpy(rand_state, &seed, sizeof(seed));
   51|  6.83k|	nrand48(rand_state);
   52|  6.83k|}
wrapfd_new_fuzzinput:
   54|  3.41k|int wrapfd_new_fuzzinput() {
   55|  3.41k|	if (devnull_fd == -1) {
  ------------------
  |  Branch (55:6): [True: 1, False: 3.41k]
  ------------------
   56|      1|		devnull_fd = open("/dev/null", O_RDONLY);
   57|      1|		assert(devnull_fd != -1);
  ------------------
  |  Branch (57:3): [True: 0, False: 1]
  |  Branch (57:3): [True: 1, False: 0]
  ------------------
   58|      1|	}
   59|       |
   60|  3.41k|	int fd = dup(devnull_fd);
   61|  3.41k|	assert(fd != -1);
  ------------------
  |  Branch (61:2): [True: 0, False: 3.41k]
  |  Branch (61:2): [True: 3.41k, False: 0]
  ------------------
   62|  3.41k|	assert(wrap_fds[fd].mode == UNUSED);
  ------------------
  |  Branch (62:2): [True: 0, False: 3.41k]
  |  Branch (62:2): [True: 3.41k, False: 0]
  ------------------
   63|  3.41k|	wrap_fds[fd].mode = COMMONBUF;
   64|  3.41k|	wrap_fds[fd].closein = 0;
   65|  3.41k|	wrap_fds[fd].closeout = 0;
   66|  3.41k|	wrapfd_maxfd = MAX(fd, wrapfd_maxfd);
  ------------------
  |  Branch (66:17): [True: 3.41k, False: 0]
  ------------------
   67|       |
   68|  3.41k|	return fd;
   69|  3.41k|}
wrapfd_close:
  105|  11.9k|int wrapfd_close(int fd) {
  106|  11.9k|	if (fd >= 0 && fd <= IOWRAP_MAXFD && wrap_fds[fd].mode != UNUSED) {
  ------------------
  |  |    9|  23.9k|#define IOWRAP_MAXFD (FD_SETSIZE-1)
  ------------------
  |  Branch (106:6): [True: 11.9k, False: 0]
  |  Branch (106:17): [True: 11.9k, False: 0]
  |  Branch (106:39): [True: 861, False: 11.1k]
  ------------------
  107|    861|		wrapfd_remove(fd);
  108|    861|		return 0;
  109|  11.1k|	} else {
  110|  11.1k|		return close(fd);
  111|  11.1k|	}
  112|  11.9k|}
wrapfd_read:
  114|   180k|int wrapfd_read(int fd, void *out, size_t count) {
  115|   180k|	size_t maxread;
  116|       |
  117|   180k|	if (!fuzz.wrapfds) {
  ------------------
  |  Branch (117:6): [True: 0, False: 180k]
  ------------------
  118|      0|		return read(fd, out, count);
  119|      0|	}
  120|       |
  121|   180k|	if (fd < 0 || fd > IOWRAP_MAXFD || wrap_fds[fd].mode == UNUSED) {
  ------------------
  |  |    9|   361k|#define IOWRAP_MAXFD (FD_SETSIZE-1)
  ------------------
  |  Branch (121:6): [True: 0, False: 180k]
  |  Branch (121:16): [True: 0, False: 180k]
  |  Branch (121:37): [True: 0, False: 180k]
  ------------------
  122|       |		/* XXX - assertion failure? */
  123|      0|		TRACE(("Bad read descriptor %d\n", fd))
  124|      0|		errno = EBADF;
  125|      0|		return -1;
  126|      0|	}
  127|       |
  128|   180k|	assert(count != 0);
  ------------------
  |  Branch (128:2): [True: 0, False: 180k]
  |  Branch (128:2): [True: 180k, False: 0]
  ------------------
  129|       |
  130|   180k|	if (wrap_fds[fd].closein || erand48(rand_state) < CHANCE_CLOSE) {
  ------------------
  |  Branch (130:6): [True: 0, False: 180k]
  |  Branch (130:30): [True: 21, False: 180k]
  ------------------
  131|     21|		wrap_fds[fd].closein = 1;
  132|     21|		errno = ECONNRESET;
  133|     21|		return -1;
  134|     21|	}
  135|       |
  136|   180k|	if (erand48(rand_state) < CHANCE_INTR) {
  ------------------
  |  Branch (136:6): [True: 260, False: 180k]
  ------------------
  137|    260|		errno = EINTR;
  138|    260|		return -1;
  139|    260|	}
  140|       |
  141|   180k|	if (input_buf && wrap_fds[fd].mode == COMMONBUF) {
  ------------------
  |  Branch (141:6): [True: 180k, False: 0]
  |  Branch (141:19): [True: 180k, False: 0]
  ------------------
  142|   180k|		maxread = MIN(input_buf->len - input_buf->pos, count);
  ------------------
  |  Branch (142:13): [True: 3.93k, False: 176k]
  ------------------
  143|       |		/* returns 0 if buf is EOF, as intended */
  144|   180k|		if (maxread > 0) {
  ------------------
  |  Branch (144:7): [True: 177k, False: 3.40k]
  ------------------
  145|   177k|			maxread = nrand48(rand_state) % maxread + 1;
  146|   177k|		}
  147|   180k|		memcpy(out, buf_getptr(input_buf, maxread), maxread);
  148|   180k|		buf_incrpos(input_buf, maxread);
  149|   180k|		return maxread;
  150|   180k|	}
  151|       |
  152|       |	// return fixed output, of random length
  153|      0|	maxread = MIN(MAX_RANDOM_IN, count);
  ------------------
  |  Branch (153:12): [True: 0, False: 0]
  ------------------
  154|      0|	maxread = nrand48(rand_state) % maxread + 1;
  155|      0|	memset(out, 0xef, maxread);
  156|      0|	return maxread;
  157|   180k|}
wrapfd_select:
  196|   190k|	fd_set *exceptfds, struct timeval *timeout) {
  197|   190k|	int i, nset, sel;
  198|   190k|	int ret = 0;
  199|   190k|	int fdlist[IOWRAP_MAXFD+1];
  200|       |
  201|   190k|	if (!fuzz.wrapfds) {
  ------------------
  |  Branch (201:6): [True: 0, False: 190k]
  ------------------
  202|      0|		return select(nfds, readfds, writefds, exceptfds, timeout);
  203|      0|	}
  204|       |
  205|   190k|	assert(nfds <= IOWRAP_MAXFD+1);
  ------------------
  |  Branch (205:2): [True: 0, False: 190k]
  |  Branch (205:2): [True: 190k, False: 0]
  ------------------
  206|       |
  207|   190k|	if (erand48(rand_state) < CHANCE_INTR) {
  ------------------
  |  Branch (207:6): [True: 335, False: 189k]
  ------------------
  208|    335|		errno = EINTR;
  209|    335|		return -1;
  210|    335|	}
  211|       |
  212|       |	/* read */
  213|   189k|	if (readfds != NULL && erand48(rand_state) < CHANCE_READ1) {
  ------------------
  |  Branch (213:6): [True: 189k, False: 0]
  |  Branch (213:25): [True: 180k, False: 8.82k]
  ------------------
  214|  1.44M|		for (i = 0, nset = 0; i < nfds; i++) {
  ------------------
  |  Branch (214:25): [True: 1.26M, False: 180k]
  ------------------
  215|  1.26M|			if (FD_ISSET(i, readfds)) {
  ------------------
  |  Branch (215:8): [True: 170k, False: 1.09M]
  ------------------
  216|   170k|				assert(wrap_fds[i].mode != UNUSED);
  ------------------
  |  Branch (216:5): [True: 0, False: 170k]
  |  Branch (216:5): [True: 170k, False: 0]
  ------------------
  217|   170k|				fdlist[nset] = i;
  218|   170k|				nset++;
  219|   170k|			}
  220|  1.26M|		}
  221|   180k|		DROPBEAR_FD_ZERO(readfds);
  ------------------
  |  |  109|   180k|#define DROPBEAR_FD_ZERO(fds) FD_ZERO(fds)
  ------------------
  |  Branch (221:3): [True: 2.89M, False: 180k]
  |  Branch (221:3): [Folded, False: 180k]
  ------------------
  222|       |
  223|   180k|		if (nset > 0) {
  ------------------
  |  Branch (223:7): [True: 170k, False: 10.0k]
  ------------------
  224|       |			/* set one */
  225|   170k|			sel = fdlist[nrand48(rand_state) % nset];
  226|   170k|			FD_SET(sel, readfds);
  227|   170k|			ret++;
  228|       |
  229|   170k|			if (erand48(rand_state) < CHANCE_READ2) {
  ------------------
  |  Branch (229:8): [True: 78.3k, False: 92.6k]
  ------------------
  230|  78.3k|				sel = fdlist[nrand48(rand_state) % nset];
  231|  78.3k|				if (!FD_ISSET(sel, readfds)) {
  ------------------
  |  Branch (231:9): [True: 0, False: 78.3k]
  ------------------
  232|      0|					FD_SET(sel, readfds);
  233|      0|					ret++;
  234|      0|				}
  235|  78.3k|			}
  236|   170k|		}
  237|   180k|	}
  238|       |
  239|       |	/* write */
  240|   189k|	if (writefds != NULL && erand48(rand_state) < CHANCE_WRITE1) {
  ------------------
  |  Branch (240:6): [True: 97.4k, False: 92.3k]
  |  Branch (240:26): [True: 93.9k, False: 3.48k]
  ------------------
  241|   751k|		for (i = 0, nset = 0; i < nfds; i++) {
  ------------------
  |  Branch (241:25): [True: 657k, False: 93.9k]
  ------------------
  242|   657k|			if (FD_ISSET(i, writefds)) {
  ------------------
  |  Branch (242:8): [True: 10.0k, False: 647k]
  ------------------
  243|  10.0k|				assert(wrap_fds[i].mode != UNUSED);
  ------------------
  |  Branch (243:5): [True: 0, False: 10.0k]
  |  Branch (243:5): [True: 10.0k, False: 0]
  ------------------
  244|  10.0k|				fdlist[nset] = i;
  245|  10.0k|				nset++;
  246|  10.0k|			}
  247|   657k|		}
  248|  93.9k|		DROPBEAR_FD_ZERO(writefds);
  ------------------
  |  |  109|  93.9k|#define DROPBEAR_FD_ZERO(fds) FD_ZERO(fds)
  ------------------
  |  Branch (248:3): [True: 1.50M, False: 93.9k]
  |  Branch (248:3): [Folded, False: 93.9k]
  ------------------
  249|       |
  250|       |		/* set one */
  251|  93.9k|		if (nset > 0) {
  ------------------
  |  Branch (251:7): [True: 10.0k, False: 83.9k]
  ------------------
  252|  10.0k|			sel = fdlist[nrand48(rand_state) % nset];
  253|  10.0k|			FD_SET(sel, writefds);
  254|  10.0k|			ret++;
  255|       |
  256|  10.0k|			if (erand48(rand_state) < CHANCE_WRITE2) {
  ------------------
  |  Branch (256:8): [True: 4.19k, False: 5.86k]
  ------------------
  257|  4.19k|				sel = fdlist[nrand48(rand_state) % nset];
  258|  4.19k|				if (!FD_ISSET(sel, writefds)) {
  ------------------
  |  Branch (258:9): [True: 0, False: 4.19k]
  ------------------
  259|      0|					FD_SET(sel, writefds);
  260|      0|					ret++;
  261|      0|				}
  262|  4.19k|			}
  263|  10.0k|		}
  264|  93.9k|	}
  265|   189k|	return ret;
  266|   189k|}
fuzz-wrapfd.c:wrapfd_remove:
   96|  3.41k|static void wrapfd_remove(int fd) {
   97|  3.41k|	TRACE(("wrapfd_remove %d", fd))
   98|  3.41k|	assert(fd >= 0);
  ------------------
  |  Branch (98:2): [True: 0, False: 3.41k]
  |  Branch (98:2): [True: 3.41k, False: 0]
  ------------------
   99|  3.41k|	assert(fd <= IOWRAP_MAXFD);
  ------------------
  |  Branch (99:2): [True: 0, False: 3.41k]
  |  Branch (99:2): [True: 3.41k, False: 0]
  ------------------
  100|  3.41k|	assert(wrap_fds[fd].mode != UNUSED);
  ------------------
  |  Branch (100:2): [True: 0, False: 3.41k]
  |  Branch (100:2): [True: 3.41k, False: 0]
  ------------------
  101|  3.41k|	wrap_fds[fd].mode = UNUSED;
  102|  3.41k|	close(fd);
  103|  3.41k|}

LLVMFuzzerTestOneInput:
    3|  3.41k|int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
    4|  3.41k|	return fuzz_run_client(Data, Size, 0);
    5|  3.41k|}

sha1_init:
  164|    668|{
  165|    668|   LTC_ARGCHK(md != NULL);
  ------------------
  |  |   32|    668|#define LTC_ARGCHK(x) do { if (!(x)) { crypt_argchk(#x, __FILE__, __LINE__); } }while(0)
  |  |  ------------------
  |  |  |  Branch (32:32): [True: 0, False: 668]
  |  |  |  Branch (32:87): [Folded, False: 668]
  |  |  ------------------
  ------------------
  166|    668|   md->sha1.state[0] = 0x67452301UL;
  167|    668|   md->sha1.state[1] = 0xefcdab89UL;
  168|    668|   md->sha1.state[2] = 0x98badcfeUL;
  169|    668|   md->sha1.state[3] = 0x10325476UL;
  170|    668|   md->sha1.state[4] = 0xc3d2e1f0UL;
  171|    668|   md->sha1.curlen = 0;
  172|    668|   md->sha1.length = 0;
  173|    668|   return CRYPT_OK;
  174|    668|}
sha1_done:
  192|    668|{
  193|    668|    int i;
  194|       |
  195|    668|    LTC_ARGCHK(md  != NULL);
  ------------------
  |  |   32|    668|#define LTC_ARGCHK(x) do { if (!(x)) { crypt_argchk(#x, __FILE__, __LINE__); } }while(0)
  |  |  ------------------
  |  |  |  Branch (32:32): [True: 0, False: 668]
  |  |  |  Branch (32:87): [Folded, False: 668]
  |  |  ------------------
  ------------------
  196|    668|    LTC_ARGCHK(out != NULL);
  ------------------
  |  |   32|    668|#define LTC_ARGCHK(x) do { if (!(x)) { crypt_argchk(#x, __FILE__, __LINE__); } }while(0)
  |  |  ------------------
  |  |  |  Branch (32:32): [True: 0, False: 668]
  |  |  |  Branch (32:87): [Folded, False: 668]
  |  |  ------------------
  ------------------
  197|       |
  198|    668|    if (md->sha1.curlen >= sizeof(md->sha1.buf)) {
  ------------------
  |  Branch (198:9): [True: 0, False: 668]
  ------------------
  199|      0|       return CRYPT_INVALID_ARG;
  200|      0|    }
  201|       |
  202|       |    /* increase the length of the message */
  203|    668|    md->sha1.length += md->sha1.curlen * 8;
  204|       |
  205|       |    /* append the '1' bit */
  206|    668|    md->sha1.buf[md->sha1.curlen++] = (unsigned char)0x80;
  207|       |
  208|       |    /* if the length is currently above 56 bytes we append zeros
  209|       |     * then compress.  Then we can fall back to padding zeros and length
  210|       |     * encoding like normal.
  211|       |     */
  212|    668|    if (md->sha1.curlen > 56) {
  ------------------
  |  Branch (212:9): [True: 0, False: 668]
  ------------------
  213|      0|        while (md->sha1.curlen < 64) {
  ------------------
  |  Branch (213:16): [True: 0, False: 0]
  ------------------
  214|      0|            md->sha1.buf[md->sha1.curlen++] = (unsigned char)0;
  215|      0|        }
  216|      0|        sha1_compress(md, md->sha1.buf);
  217|      0|        md->sha1.curlen = 0;
  218|      0|    }
  219|       |
  220|       |    /* pad upto 56 bytes of zeroes */
  221|  16.0k|    while (md->sha1.curlen < 56) {
  ------------------
  |  Branch (221:12): [True: 15.3k, False: 668]
  ------------------
  222|  15.3k|        md->sha1.buf[md->sha1.curlen++] = (unsigned char)0;
  223|  15.3k|    }
  224|       |
  225|       |    /* store length */
  226|    668|    STORE64H(md->sha1.length, md->sha1.buf+56);
  ------------------
  |  |  101|    668|#define STORE64H(x, y)                          \
  |  |  102|    668|do { ulong64 __t = __builtin_bswap64 ((x));     \
  |  |  103|    668|      XMEMCPY ((y), &__t, 8); } while(0)
  |  |  ------------------
  |  |  |  |   39|    668|#define XMEMCPY  memcpy
  |  |  ------------------
  |  |  |  Branch (103:39): [Folded, False: 668]
  |  |  ------------------
  ------------------
  227|    668|    sha1_compress(md, md->sha1.buf);
  228|       |
  229|       |    /* copy output */
  230|  4.00k|    for (i = 0; i < 5; i++) {
  ------------------
  |  Branch (230:17): [True: 3.34k, False: 668]
  ------------------
  231|  3.34k|        STORE32H(md->sha1.state[i], out+(4*i));
  ------------------
  |  |   62|  3.34k|#define STORE32H(x, y)                          \
  |  |   63|  3.34k|do { ulong32 __t = __builtin_bswap32 ((x));     \
  |  |   64|  3.34k|      XMEMCPY ((y), &__t, 4); } while(0)
  |  |  ------------------
  |  |  |  |   39|  3.34k|#define XMEMCPY  memcpy
  |  |  ------------------
  |  |  |  Branch (64:39): [Folded, False: 3.34k]
  |  |  ------------------
  ------------------
  232|  3.34k|    }
  233|       |#ifdef LTC_CLEAN_STACK
  234|       |    zeromem(md, sizeof(hash_state));
  235|       |#endif
  236|    668|    return CRYPT_OK;
  237|    668|}
sha1.c:sha1_compress:
   47|    668|{
   48|    668|    ulong32 a,b,c,d,e,W[80],i;
   49|    668|#ifdef LTC_SMALL_CODE
   50|    668|    ulong32 t;
   51|    668|#endif
   52|       |
   53|       |    /* copy the state into 512-bits into W[0..15] */
   54|  11.3k|    for (i = 0; i < 16; i++) {
  ------------------
  |  Branch (54:17): [True: 10.6k, False: 668]
  ------------------
   55|  10.6k|        LOAD32H(W[i], buf + (4*i));
  ------------------
  |  |   66|  10.6k|#define LOAD32H(x, y)                           \
  |  |   67|  10.6k|do { XMEMCPY (&(x), (y), 4);                    \
  |  |  ------------------
  |  |  |  |   39|  10.6k|#define XMEMCPY  memcpy
  |  |  ------------------
  |  |   68|  10.6k|      (x) = __builtin_bswap32 ((x)); } while(0)
  |  |  ------------------
  |  |  |  Branch (68:46): [Folded, False: 10.6k]
  |  |  ------------------
  ------------------
   56|  10.6k|    }
   57|       |
   58|       |    /* copy state */
   59|    668|    a = md->sha1.state[0];
   60|    668|    b = md->sha1.state[1];
   61|    668|    c = md->sha1.state[2];
   62|    668|    d = md->sha1.state[3];
   63|    668|    e = md->sha1.state[4];
   64|       |
   65|       |    /* expand it */
   66|  43.4k|    for (i = 16; i < 80; i++) {
  ------------------
  |  Branch (66:18): [True: 42.7k, False: 668]
  ------------------
   67|  42.7k|        W[i] = ROL(W[i-3] ^ W[i-8] ^ W[i-14] ^ W[i-16], 1);
   68|  42.7k|    }
   69|       |
   70|       |    /* compress */
   71|       |    /* round one */
   72|    668|    #define FF0(a,b,c,d,e,i) e = (ROLc(a, 5) + F0(b,c,d) + e + W[i] + 0x5a827999UL); b = ROLc(b, 30);
   73|    668|    #define FF1(a,b,c,d,e,i) e = (ROLc(a, 5) + F1(b,c,d) + e + W[i] + 0x6ed9eba1UL); b = ROLc(b, 30);
   74|    668|    #define FF2(a,b,c,d,e,i) e = (ROLc(a, 5) + F2(b,c,d) + e + W[i] + 0x8f1bbcdcUL); b = ROLc(b, 30);
   75|    668|    #define FF3(a,b,c,d,e,i) e = (ROLc(a, 5) + F3(b,c,d) + e + W[i] + 0xca62c1d6UL); b = ROLc(b, 30);
   76|       |
   77|    668|#ifdef LTC_SMALL_CODE
   78|       |
   79|  14.0k|    for (i = 0; i < 20; ) {
  ------------------
  |  Branch (79:17): [True: 13.3k, False: 668]
  ------------------
   80|  13.3k|       FF0(a,b,c,d,e,i++); t = e; e = d; d = c; c = b; b = a; a = t;
  ------------------
  |  |   72|  13.3k|    #define FF0(a,b,c,d,e,i) e = (ROLc(a, 5) + F0(b,c,d) + e + W[i] + 0x5a827999UL); b = ROLc(b, 30);
  |  |  ------------------
  |  |  |  |  275|  13.3k|#define ROLc(word,i) ({ \
  |  |  |  |  276|  13.3k|   ulong32 __ROLc_tmp = (word); \
  |  |  |  |  277|  13.3k|   __asm__ ("roll %2, %0" : \
  |  |  |  |  278|  13.3k|            "=r" (__ROLc_tmp) : \
  |  |  |  |  279|  13.3k|            "0" (__ROLc_tmp), \
  |  |  |  |  280|  13.3k|            "I" (i)); \
  |  |  |  |  281|  13.3k|            __ROLc_tmp; \
  |  |  |  |  282|  13.3k|   })
  |  |  ------------------
  |  |                   #define FF0(a,b,c,d,e,i) e = (ROLc(a, 5) + F0(b,c,d) + e + W[i] + 0x5a827999UL); b = ROLc(b, 30);
  |  |  ------------------
  |  |  |  |   37|  13.3k|#define F0(x,y,z)  (z ^ (x & (y ^ z)))
  |  |  ------------------
  |  |                   #define FF0(a,b,c,d,e,i) e = (ROLc(a, 5) + F0(b,c,d) + e + W[i] + 0x5a827999UL); b = ROLc(b, 30);
  |  |  ------------------
  |  |  |  |  275|  13.3k|#define ROLc(word,i) ({ \
  |  |  |  |  276|  13.3k|   ulong32 __ROLc_tmp = (word); \
  |  |  |  |  277|  13.3k|   __asm__ ("roll %2, %0" : \
  |  |  |  |  278|  13.3k|            "=r" (__ROLc_tmp) : \
  |  |  |  |  279|  13.3k|            "0" (__ROLc_tmp), \
  |  |  |  |  280|  13.3k|            "I" (i)); \
  |  |  |  |  281|  13.3k|            __ROLc_tmp; \
  |  |  |  |  282|  13.3k|   })
  |  |  ------------------
  ------------------
   81|  13.3k|    }
   82|       |
   83|  14.0k|    for (; i < 40; ) {
  ------------------
  |  Branch (83:12): [True: 13.3k, False: 668]
  ------------------
   84|  13.3k|       FF1(a,b,c,d,e,i++); t = e; e = d; d = c; c = b; b = a; a = t;
  ------------------
  |  |   73|  13.3k|    #define FF1(a,b,c,d,e,i) e = (ROLc(a, 5) + F1(b,c,d) + e + W[i] + 0x6ed9eba1UL); b = ROLc(b, 30);
  |  |  ------------------
  |  |  |  |  275|  13.3k|#define ROLc(word,i) ({ \
  |  |  |  |  276|  13.3k|   ulong32 __ROLc_tmp = (word); \
  |  |  |  |  277|  13.3k|   __asm__ ("roll %2, %0" : \
  |  |  |  |  278|  13.3k|            "=r" (__ROLc_tmp) : \
  |  |  |  |  279|  13.3k|            "0" (__ROLc_tmp), \
  |  |  |  |  280|  13.3k|            "I" (i)); \
  |  |  |  |  281|  13.3k|            __ROLc_tmp; \
  |  |  |  |  282|  13.3k|   })
  |  |  ------------------
  |  |                   #define FF1(a,b,c,d,e,i) e = (ROLc(a, 5) + F1(b,c,d) + e + W[i] + 0x6ed9eba1UL); b = ROLc(b, 30);
  |  |  ------------------
  |  |  |  |   38|  13.3k|#define F1(x,y,z)  (x ^ y ^ z)
  |  |  ------------------
  |  |                   #define FF1(a,b,c,d,e,i) e = (ROLc(a, 5) + F1(b,c,d) + e + W[i] + 0x6ed9eba1UL); b = ROLc(b, 30);
  |  |  ------------------
  |  |  |  |  275|  13.3k|#define ROLc(word,i) ({ \
  |  |  |  |  276|  13.3k|   ulong32 __ROLc_tmp = (word); \
  |  |  |  |  277|  13.3k|   __asm__ ("roll %2, %0" : \
  |  |  |  |  278|  13.3k|            "=r" (__ROLc_tmp) : \
  |  |  |  |  279|  13.3k|            "0" (__ROLc_tmp), \
  |  |  |  |  280|  13.3k|            "I" (i)); \
  |  |  |  |  281|  13.3k|            __ROLc_tmp; \
  |  |  |  |  282|  13.3k|   })
  |  |  ------------------
  ------------------
   85|  13.3k|    }
   86|       |
   87|  14.0k|    for (; i < 60; ) {
  ------------------
  |  Branch (87:12): [True: 13.3k, False: 668]
  ------------------
   88|  13.3k|       FF2(a,b,c,d,e,i++); t = e; e = d; d = c; c = b; b = a; a = t;
  ------------------
  |  |   74|  13.3k|    #define FF2(a,b,c,d,e,i) e = (ROLc(a, 5) + F2(b,c,d) + e + W[i] + 0x8f1bbcdcUL); b = ROLc(b, 30);
  |  |  ------------------
  |  |  |  |  275|  13.3k|#define ROLc(word,i) ({ \
  |  |  |  |  276|  13.3k|   ulong32 __ROLc_tmp = (word); \
  |  |  |  |  277|  13.3k|   __asm__ ("roll %2, %0" : \
  |  |  |  |  278|  13.3k|            "=r" (__ROLc_tmp) : \
  |  |  |  |  279|  13.3k|            "0" (__ROLc_tmp), \
  |  |  |  |  280|  13.3k|            "I" (i)); \
  |  |  |  |  281|  13.3k|            __ROLc_tmp; \
  |  |  |  |  282|  13.3k|   })
  |  |  ------------------
  |  |                   #define FF2(a,b,c,d,e,i) e = (ROLc(a, 5) + F2(b,c,d) + e + W[i] + 0x8f1bbcdcUL); b = ROLc(b, 30);
  |  |  ------------------
  |  |  |  |   39|  13.3k|#define F2(x,y,z)  ((x & y) | (z & (x | y)))
  |  |  ------------------
  |  |                   #define FF2(a,b,c,d,e,i) e = (ROLc(a, 5) + F2(b,c,d) + e + W[i] + 0x8f1bbcdcUL); b = ROLc(b, 30);
  |  |  ------------------
  |  |  |  |  275|  13.3k|#define ROLc(word,i) ({ \
  |  |  |  |  276|  13.3k|   ulong32 __ROLc_tmp = (word); \
  |  |  |  |  277|  13.3k|   __asm__ ("roll %2, %0" : \
  |  |  |  |  278|  13.3k|            "=r" (__ROLc_tmp) : \
  |  |  |  |  279|  13.3k|            "0" (__ROLc_tmp), \
  |  |  |  |  280|  13.3k|            "I" (i)); \
  |  |  |  |  281|  13.3k|            __ROLc_tmp; \
  |  |  |  |  282|  13.3k|   })
  |  |  ------------------
  ------------------
   89|  13.3k|    }
   90|       |
   91|  14.0k|    for (; i < 80; ) {
  ------------------
  |  Branch (91:12): [True: 13.3k, False: 668]
  ------------------
   92|  13.3k|       FF3(a,b,c,d,e,i++); t = e; e = d; d = c; c = b; b = a; a = t;
  ------------------
  |  |   75|  13.3k|    #define FF3(a,b,c,d,e,i) e = (ROLc(a, 5) + F3(b,c,d) + e + W[i] + 0xca62c1d6UL); b = ROLc(b, 30);
  |  |  ------------------
  |  |  |  |  275|  13.3k|#define ROLc(word,i) ({ \
  |  |  |  |  276|  13.3k|   ulong32 __ROLc_tmp = (word); \
  |  |  |  |  277|  13.3k|   __asm__ ("roll %2, %0" : \
  |  |  |  |  278|  13.3k|            "=r" (__ROLc_tmp) : \
  |  |  |  |  279|  13.3k|            "0" (__ROLc_tmp), \
  |  |  |  |  280|  13.3k|            "I" (i)); \
  |  |  |  |  281|  13.3k|            __ROLc_tmp; \
  |  |  |  |  282|  13.3k|   })
  |  |  ------------------
  |  |                   #define FF3(a,b,c,d,e,i) e = (ROLc(a, 5) + F3(b,c,d) + e + W[i] + 0xca62c1d6UL); b = ROLc(b, 30);
  |  |  ------------------
  |  |  |  |   40|  13.3k|#define F3(x,y,z)  (x ^ y ^ z)
  |  |  ------------------
  |  |                   #define FF3(a,b,c,d,e,i) e = (ROLc(a, 5) + F3(b,c,d) + e + W[i] + 0xca62c1d6UL); b = ROLc(b, 30);
  |  |  ------------------
  |  |  |  |  275|  13.3k|#define ROLc(word,i) ({ \
  |  |  |  |  276|  13.3k|   ulong32 __ROLc_tmp = (word); \
  |  |  |  |  277|  13.3k|   __asm__ ("roll %2, %0" : \
  |  |  |  |  278|  13.3k|            "=r" (__ROLc_tmp) : \
  |  |  |  |  279|  13.3k|            "0" (__ROLc_tmp), \
  |  |  |  |  280|  13.3k|            "I" (i)); \
  |  |  |  |  281|  13.3k|            __ROLc_tmp; \
  |  |  |  |  282|  13.3k|   })
  |  |  ------------------
  ------------------
   93|  13.3k|    }
   94|       |
   95|       |#else
   96|       |
   97|       |    for (i = 0; i < 20; ) {
   98|       |       FF0(a,b,c,d,e,i++);
   99|       |       FF0(e,a,b,c,d,i++);
  100|       |       FF0(d,e,a,b,c,i++);
  101|       |       FF0(c,d,e,a,b,i++);
  102|       |       FF0(b,c,d,e,a,i++);
  103|       |    }
  104|       |
  105|       |    /* round two */
  106|       |    for (; i < 40; )  {
  107|       |       FF1(a,b,c,d,e,i++);
  108|       |       FF1(e,a,b,c,d,i++);
  109|       |       FF1(d,e,a,b,c,i++);
  110|       |       FF1(c,d,e,a,b,i++);
  111|       |       FF1(b,c,d,e,a,i++);
  112|       |    }
  113|       |
  114|       |    /* round three */
  115|       |    for (; i < 60; )  {
  116|       |       FF2(a,b,c,d,e,i++);
  117|       |       FF2(e,a,b,c,d,i++);
  118|       |       FF2(d,e,a,b,c,i++);
  119|       |       FF2(c,d,e,a,b,i++);
  120|       |       FF2(b,c,d,e,a,i++);
  121|       |    }
  122|       |
  123|       |    /* round four */
  124|       |    for (; i < 80; )  {
  125|       |       FF3(a,b,c,d,e,i++);
  126|       |       FF3(e,a,b,c,d,i++);
  127|       |       FF3(d,e,a,b,c,i++);
  128|       |       FF3(c,d,e,a,b,i++);
  129|       |       FF3(b,c,d,e,a,i++);
  130|       |    }
  131|       |#endif
  132|       |
  133|    668|    #undef FF0
  134|    668|    #undef FF1
  135|    668|    #undef FF2
  136|    668|    #undef FF3
  137|       |
  138|       |    /* store */
  139|    668|    md->sha1.state[0] = md->sha1.state[0] + a;
  140|    668|    md->sha1.state[1] = md->sha1.state[1] + b;
  141|    668|    md->sha1.state[2] = md->sha1.state[2] + c;
  142|    668|    md->sha1.state[3] = md->sha1.state[3] + d;
  143|    668|    md->sha1.state[4] = md->sha1.state[4] + e;
  144|       |
  145|    668|    return CRYPT_OK;
  146|    668|}

sha256_init:
  205|  5.36M|{
  206|  5.36M|    LTC_ARGCHK(md != NULL);
  ------------------
  |  |   32|  5.36M|#define LTC_ARGCHK(x) do { if (!(x)) { crypt_argchk(#x, __FILE__, __LINE__); } }while(0)
  |  |  ------------------
  |  |  |  Branch (32:32): [True: 0, False: 5.36M]
  |  |  |  Branch (32:87): [Folded, False: 5.36M]
  |  |  ------------------
  ------------------
  207|       |
  208|  5.36M|    md->sha256.curlen = 0;
  209|  5.36M|    md->sha256.length = 0;
  210|  5.36M|    md->sha256.state[0] = 0x6A09E667UL;
  211|  5.36M|    md->sha256.state[1] = 0xBB67AE85UL;
  212|  5.36M|    md->sha256.state[2] = 0x3C6EF372UL;
  213|  5.36M|    md->sha256.state[3] = 0xA54FF53AUL;
  214|  5.36M|    md->sha256.state[4] = 0x510E527FUL;
  215|  5.36M|    md->sha256.state[5] = 0x9B05688CUL;
  216|  5.36M|    md->sha256.state[6] = 0x1F83D9ABUL;
  217|  5.36M|    md->sha256.state[7] = 0x5BE0CD19UL;
  218|  5.36M|    return CRYPT_OK;
  219|  5.36M|}
sha256_done:
  237|  5.36M|{
  238|  5.36M|    int i;
  239|       |
  240|  5.36M|    LTC_ARGCHK(md  != NULL);
  ------------------
  |  |   32|  5.36M|#define LTC_ARGCHK(x) do { if (!(x)) { crypt_argchk(#x, __FILE__, __LINE__); } }while(0)
  |  |  ------------------
  |  |  |  Branch (32:32): [True: 0, False: 5.36M]
  |  |  |  Branch (32:87): [Folded, False: 5.36M]
  |  |  ------------------
  ------------------
  241|  5.36M|    LTC_ARGCHK(out != NULL);
  ------------------
  |  |   32|  5.36M|#define LTC_ARGCHK(x) do { if (!(x)) { crypt_argchk(#x, __FILE__, __LINE__); } }while(0)
  |  |  ------------------
  |  |  |  Branch (32:32): [True: 0, False: 5.36M]
  |  |  |  Branch (32:87): [Folded, False: 5.36M]
  |  |  ------------------
  ------------------
  242|       |
  243|  5.36M|    if (md->sha256.curlen >= sizeof(md->sha256.buf)) {
  ------------------
  |  Branch (243:9): [True: 0, False: 5.36M]
  ------------------
  244|      0|       return CRYPT_INVALID_ARG;
  245|      0|    }
  246|       |
  247|       |
  248|       |    /* increase the length of the message */
  249|  5.36M|    md->sha256.length += md->sha256.curlen * 8;
  250|       |
  251|       |    /* append the '1' bit */
  252|  5.36M|    md->sha256.buf[md->sha256.curlen++] = (unsigned char)0x80;
  253|       |
  254|       |    /* if the length is currently above 56 bytes we append zeros
  255|       |     * then compress.  Then we can fall back to padding zeros and length
  256|       |     * encoding like normal.
  257|       |     */
  258|  5.36M|    if (md->sha256.curlen > 56) {
  ------------------
  |  Branch (258:9): [True: 114, False: 5.36M]
  ------------------
  259|    513|        while (md->sha256.curlen < 64) {
  ------------------
  |  Branch (259:16): [True: 399, False: 114]
  ------------------
  260|    399|            md->sha256.buf[md->sha256.curlen++] = (unsigned char)0;
  261|    399|        }
  262|    114|        sha256_compress(md, md->sha256.buf);
  263|    114|        md->sha256.curlen = 0;
  264|    114|    }
  265|       |
  266|       |    /* pad upto 56 bytes of zeroes */
  267|   107M|    while (md->sha256.curlen < 56) {
  ------------------
  |  Branch (267:12): [True: 101M, False: 5.36M]
  ------------------
  268|   101M|        md->sha256.buf[md->sha256.curlen++] = (unsigned char)0;
  269|   101M|    }
  270|       |
  271|       |    /* store length */
  272|  5.36M|    STORE64H(md->sha256.length, md->sha256.buf+56);
  ------------------
  |  |  101|  5.36M|#define STORE64H(x, y)                          \
  |  |  102|  5.36M|do { ulong64 __t = __builtin_bswap64 ((x));     \
  |  |  103|  5.36M|      XMEMCPY ((y), &__t, 8); } while(0)
  |  |  ------------------
  |  |  |  |   39|  5.36M|#define XMEMCPY  memcpy
  |  |  ------------------
  |  |  |  Branch (103:39): [Folded, False: 5.36M]
  |  |  ------------------
  ------------------
  273|  5.36M|    sha256_compress(md, md->sha256.buf);
  274|       |
  275|       |    /* copy output */
  276|  48.2M|    for (i = 0; i < 8; i++) {
  ------------------
  |  Branch (276:17): [True: 42.9M, False: 5.36M]
  ------------------
  277|  42.9M|        STORE32H(md->sha256.state[i], out+(4*i));
  ------------------
  |  |   62|  42.9M|#define STORE32H(x, y)                          \
  |  |   63|  42.9M|do { ulong32 __t = __builtin_bswap32 ((x));     \
  |  |   64|  42.9M|      XMEMCPY ((y), &__t, 4); } while(0)
  |  |  ------------------
  |  |  |  |   39|  42.9M|#define XMEMCPY  memcpy
  |  |  ------------------
  |  |  |  Branch (64:39): [Folded, False: 42.9M]
  |  |  ------------------
  ------------------
  278|  42.9M|    }
  279|       |#ifdef LTC_CLEAN_STACK
  280|       |    zeromem(md, sizeof(hash_state));
  281|       |#endif
  282|  5.36M|    return CRYPT_OK;
  283|  5.36M|}
sha256.c:sha256_compress:
   71|  5.39M|{
   72|  5.39M|    ulong32 S[8], W[64], t0, t1;
   73|  5.39M|#ifdef LTC_SMALL_CODE
   74|  5.39M|    ulong32 t;
   75|  5.39M|#endif
   76|  5.39M|    int i;
   77|       |
   78|       |    /* copy state into S */
   79|  48.5M|    for (i = 0; i < 8; i++) {
  ------------------
  |  Branch (79:17): [True: 43.1M, False: 5.39M]
  ------------------
   80|  43.1M|        S[i] = md->sha256.state[i];
   81|  43.1M|    }
   82|       |
   83|       |    /* copy the state into 512-bits into W[0..15] */
   84|  91.7M|    for (i = 0; i < 16; i++) {
  ------------------
  |  Branch (84:17): [True: 86.3M, False: 5.39M]
  ------------------
   85|  86.3M|        LOAD32H(W[i], buf + (4*i));
  ------------------
  |  |   66|  86.3M|#define LOAD32H(x, y)                           \
  |  |   67|  86.3M|do { XMEMCPY (&(x), (y), 4);                    \
  |  |  ------------------
  |  |  |  |   39|  86.3M|#define XMEMCPY  memcpy
  |  |  ------------------
  |  |   68|  86.3M|      (x) = __builtin_bswap32 ((x)); } while(0)
  |  |  ------------------
  |  |  |  Branch (68:46): [Folded, False: 86.3M]
  |  |  ------------------
  ------------------
   86|  86.3M|    }
   87|       |
   88|       |    /* fill W[16..63] */
   89|   264M|    for (i = 16; i < 64; i++) {
  ------------------
  |  Branch (89:18): [True: 259M, False: 5.39M]
  ------------------
   90|   259M|        W[i] = Gamma1(W[i - 2]) + W[i - 7] + Gamma0(W[i - 15]) + W[i - 16];
  ------------------
  |  |   63|   259M|#define Gamma1(x)       (S(x, 17) ^ S(x, 19) ^ R(x, 10))
  |  |  ------------------
  |  |  |  |   58|   259M|#define S(x, n)         RORc((x),(n))
  |  |  |  |  ------------------
  |  |  |  |  |  |  283|   259M|#define RORc(word,i) ({ \
  |  |  |  |  |  |  284|   259M|   ulong32 __RORc_tmp = (word); \
  |  |  |  |  |  |  285|   259M|   __asm__ ("rorl %2, %0" : \
  |  |  |  |  |  |  286|   259M|            "=r" (__RORc_tmp) : \
  |  |  |  |  |  |  287|   259M|            "0" (__RORc_tmp), \
  |  |  |  |  |  |  288|   259M|            "I" (i)); \
  |  |  |  |  |  |  289|   259M|            __RORc_tmp; \
  |  |  |  |  |  |  290|   259M|   })
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define Gamma1(x)       (S(x, 17) ^ S(x, 19) ^ R(x, 10))
  |  |  ------------------
  |  |  |  |   58|   259M|#define S(x, n)         RORc((x),(n))
  |  |  |  |  ------------------
  |  |  |  |  |  |  283|   259M|#define RORc(word,i) ({ \
  |  |  |  |  |  |  284|   259M|   ulong32 __RORc_tmp = (word); \
  |  |  |  |  |  |  285|   259M|   __asm__ ("rorl %2, %0" : \
  |  |  |  |  |  |  286|   259M|            "=r" (__RORc_tmp) : \
  |  |  |  |  |  |  287|   259M|            "0" (__RORc_tmp), \
  |  |  |  |  |  |  288|   259M|            "I" (i)); \
  |  |  |  |  |  |  289|   259M|            __RORc_tmp; \
  |  |  |  |  |  |  290|   259M|   })
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define Gamma1(x)       (S(x, 17) ^ S(x, 19) ^ R(x, 10))
  |  |  ------------------
  |  |  |  |   59|   259M|#define R(x, n)         (((x)&0xFFFFFFFFUL)>>(n))
  |  |  ------------------
  ------------------
                      W[i] = Gamma1(W[i - 2]) + W[i - 7] + Gamma0(W[i - 15]) + W[i - 16];
  ------------------
  |  |   62|   259M|#define Gamma0(x)       (S(x, 7) ^ S(x, 18) ^ R(x, 3))
  |  |  ------------------
  |  |  |  |   58|   259M|#define S(x, n)         RORc((x),(n))
  |  |  |  |  ------------------
  |  |  |  |  |  |  283|   259M|#define RORc(word,i) ({ \
  |  |  |  |  |  |  284|   259M|   ulong32 __RORc_tmp = (word); \
  |  |  |  |  |  |  285|   259M|   __asm__ ("rorl %2, %0" : \
  |  |  |  |  |  |  286|   259M|            "=r" (__RORc_tmp) : \
  |  |  |  |  |  |  287|   259M|            "0" (__RORc_tmp), \
  |  |  |  |  |  |  288|   259M|            "I" (i)); \
  |  |  |  |  |  |  289|   259M|            __RORc_tmp; \
  |  |  |  |  |  |  290|   259M|   })
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define Gamma0(x)       (S(x, 7) ^ S(x, 18) ^ R(x, 3))
  |  |  ------------------
  |  |  |  |   58|   259M|#define S(x, n)         RORc((x),(n))
  |  |  |  |  ------------------
  |  |  |  |  |  |  283|   259M|#define RORc(word,i) ({ \
  |  |  |  |  |  |  284|   259M|   ulong32 __RORc_tmp = (word); \
  |  |  |  |  |  |  285|   259M|   __asm__ ("rorl %2, %0" : \
  |  |  |  |  |  |  286|   259M|            "=r" (__RORc_tmp) : \
  |  |  |  |  |  |  287|   259M|            "0" (__RORc_tmp), \
  |  |  |  |  |  |  288|   259M|            "I" (i)); \
  |  |  |  |  |  |  289|   259M|            __RORc_tmp; \
  |  |  |  |  |  |  290|   259M|   })
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define Gamma0(x)       (S(x, 7) ^ S(x, 18) ^ R(x, 3))
  |  |  ------------------
  |  |  |  |   59|   259M|#define R(x, n)         (((x)&0xFFFFFFFFUL)>>(n))
  |  |  ------------------
  ------------------
   91|   259M|    }
   92|       |
   93|       |    /* Compress */
   94|  5.39M|#ifdef LTC_SMALL_CODE
   95|  5.39M|#define RND(a,b,c,d,e,f,g,h,i)                         \
   96|  5.39M|     t0 = h + Sigma1(e) + Ch(e, f, g) + K[i] + W[i];   \
   97|  5.39M|     t1 = Sigma0(a) + Maj(a, b, c);                    \
   98|  5.39M|     d += t0;                                          \
   99|  5.39M|     h  = t0 + t1;
  100|       |
  101|   350M|     for (i = 0; i < 64; ++i) {
  ------------------
  |  Branch (101:18): [True: 345M, False: 5.39M]
  ------------------
  102|   345M|         RND(S[0],S[1],S[2],S[3],S[4],S[5],S[6],S[7],i);
  ------------------
  |  |   96|   345M|     t0 = h + Sigma1(e) + Ch(e, f, g) + K[i] + W[i];   \
  |  |  ------------------
  |  |  |  |   61|   345M|#define Sigma1(x)       (S(x, 6) ^ S(x, 11) ^ S(x, 25))
  |  |  |  |  ------------------
  |  |  |  |  |  |   58|   345M|#define S(x, n)         RORc((x),(n))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  283|   345M|#define RORc(word,i) ({ \
  |  |  |  |  |  |  |  |  284|   345M|   ulong32 __RORc_tmp = (word); \
  |  |  |  |  |  |  |  |  285|   345M|   __asm__ ("rorl %2, %0" : \
  |  |  |  |  |  |  |  |  286|   345M|            "=r" (__RORc_tmp) : \
  |  |  |  |  |  |  |  |  287|   345M|            "0" (__RORc_tmp), \
  |  |  |  |  |  |  |  |  288|   345M|            "I" (i)); \
  |  |  |  |  |  |  |  |  289|   345M|            __RORc_tmp; \
  |  |  |  |  |  |  |  |  290|   345M|   })
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define Sigma1(x)       (S(x, 6) ^ S(x, 11) ^ S(x, 25))
  |  |  |  |  ------------------
  |  |  |  |  |  |   58|   345M|#define S(x, n)         RORc((x),(n))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  283|   345M|#define RORc(word,i) ({ \
  |  |  |  |  |  |  |  |  284|   345M|   ulong32 __RORc_tmp = (word); \
  |  |  |  |  |  |  |  |  285|   345M|   __asm__ ("rorl %2, %0" : \
  |  |  |  |  |  |  |  |  286|   345M|            "=r" (__RORc_tmp) : \
  |  |  |  |  |  |  |  |  287|   345M|            "0" (__RORc_tmp), \
  |  |  |  |  |  |  |  |  288|   345M|            "I" (i)); \
  |  |  |  |  |  |  |  |  289|   345M|            __RORc_tmp; \
  |  |  |  |  |  |  |  |  290|   345M|   })
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define Sigma1(x)       (S(x, 6) ^ S(x, 11) ^ S(x, 25))
  |  |  |  |  ------------------
  |  |  |  |  |  |   58|   345M|#define S(x, n)         RORc((x),(n))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  283|   345M|#define RORc(word,i) ({ \
  |  |  |  |  |  |  |  |  284|   345M|   ulong32 __RORc_tmp = (word); \
  |  |  |  |  |  |  |  |  285|   345M|   __asm__ ("rorl %2, %0" : \
  |  |  |  |  |  |  |  |  286|   345M|            "=r" (__RORc_tmp) : \
  |  |  |  |  |  |  |  |  287|   345M|            "0" (__RORc_tmp), \
  |  |  |  |  |  |  |  |  288|   345M|            "I" (i)); \
  |  |  |  |  |  |  |  |  289|   345M|            __RORc_tmp; \
  |  |  |  |  |  |  |  |  290|   345M|   })
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                    t0 = h + Sigma1(e) + Ch(e, f, g) + K[i] + W[i];   \
  |  |  ------------------
  |  |  |  |   56|   345M|#define Ch(x,y,z)       (z ^ (x & (y ^ z)))
  |  |  ------------------
  |  |   97|   345M|     t1 = Sigma0(a) + Maj(a, b, c);                    \
  |  |  ------------------
  |  |  |  |   60|   345M|#define Sigma0(x)       (S(x, 2) ^ S(x, 13) ^ S(x, 22))
  |  |  |  |  ------------------
  |  |  |  |  |  |   58|   345M|#define S(x, n)         RORc((x),(n))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  283|   345M|#define RORc(word,i) ({ \
  |  |  |  |  |  |  |  |  284|   345M|   ulong32 __RORc_tmp = (word); \
  |  |  |  |  |  |  |  |  285|   345M|   __asm__ ("rorl %2, %0" : \
  |  |  |  |  |  |  |  |  286|   345M|            "=r" (__RORc_tmp) : \
  |  |  |  |  |  |  |  |  287|   345M|            "0" (__RORc_tmp), \
  |  |  |  |  |  |  |  |  288|   345M|            "I" (i)); \
  |  |  |  |  |  |  |  |  289|   345M|            __RORc_tmp; \
  |  |  |  |  |  |  |  |  290|   345M|   })
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define Sigma0(x)       (S(x, 2) ^ S(x, 13) ^ S(x, 22))
  |  |  |  |  ------------------
  |  |  |  |  |  |   58|   345M|#define S(x, n)         RORc((x),(n))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  283|   345M|#define RORc(word,i) ({ \
  |  |  |  |  |  |  |  |  284|   345M|   ulong32 __RORc_tmp = (word); \
  |  |  |  |  |  |  |  |  285|   345M|   __asm__ ("rorl %2, %0" : \
  |  |  |  |  |  |  |  |  286|   345M|            "=r" (__RORc_tmp) : \
  |  |  |  |  |  |  |  |  287|   345M|            "0" (__RORc_tmp), \
  |  |  |  |  |  |  |  |  288|   345M|            "I" (i)); \
  |  |  |  |  |  |  |  |  289|   345M|            __RORc_tmp; \
  |  |  |  |  |  |  |  |  290|   345M|   })
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define Sigma0(x)       (S(x, 2) ^ S(x, 13) ^ S(x, 22))
  |  |  |  |  ------------------
  |  |  |  |  |  |   58|   345M|#define S(x, n)         RORc((x),(n))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  283|   345M|#define RORc(word,i) ({ \
  |  |  |  |  |  |  |  |  284|   345M|   ulong32 __RORc_tmp = (word); \
  |  |  |  |  |  |  |  |  285|   345M|   __asm__ ("rorl %2, %0" : \
  |  |  |  |  |  |  |  |  286|   345M|            "=r" (__RORc_tmp) : \
  |  |  |  |  |  |  |  |  287|   345M|            "0" (__RORc_tmp), \
  |  |  |  |  |  |  |  |  288|   345M|            "I" (i)); \
  |  |  |  |  |  |  |  |  289|   345M|            __RORc_tmp; \
  |  |  |  |  |  |  |  |  290|   345M|   })
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                    t1 = Sigma0(a) + Maj(a, b, c);                    \
  |  |  ------------------
  |  |  |  |   57|   345M|#define Maj(x,y,z)      (((x | y) & z) | (x & y))
  |  |  ------------------
  |  |   98|   345M|     d += t0;                                          \
  |  |   99|   345M|     h  = t0 + t1;
  ------------------
  103|   345M|         t = S[7]; S[7] = S[6]; S[6] = S[5]; S[5] = S[4];
  104|   345M|         S[4] = S[3]; S[3] = S[2]; S[2] = S[1]; S[1] = S[0]; S[0] = t;
  105|   345M|     }
  106|       |#else
  107|       |#define RND(a,b,c,d,e,f,g,h,i,ki)                    \
  108|       |     t0 = h + Sigma1(e) + Ch(e, f, g) + ki + W[i];   \
  109|       |     t1 = Sigma0(a) + Maj(a, b, c);                  \
  110|       |     d += t0;                                        \
  111|       |     h  = t0 + t1;
  112|       |
  113|       |    RND(S[0],S[1],S[2],S[3],S[4],S[5],S[6],S[7],0,0x428a2f98);
  114|       |    RND(S[7],S[0],S[1],S[2],S[3],S[4],S[5],S[6],1,0x71374491);
  115|       |    RND(S[6],S[7],S[0],S[1],S[2],S[3],S[4],S[5],2,0xb5c0fbcf);
  116|       |    RND(S[5],S[6],S[7],S[0],S[1],S[2],S[3],S[4],3,0xe9b5dba5);
  117|       |    RND(S[4],S[5],S[6],S[7],S[0],S[1],S[2],S[3],4,0x3956c25b);
  118|       |    RND(S[3],S[4],S[5],S[6],S[7],S[0],S[1],S[2],5,0x59f111f1);
  119|       |    RND(S[2],S[3],S[4],S[5],S[6],S[7],S[0],S[1],6,0x923f82a4);
  120|       |    RND(S[1],S[2],S[3],S[4],S[5],S[6],S[7],S[0],7,0xab1c5ed5);
  121|       |    RND(S[0],S[1],S[2],S[3],S[4],S[5],S[6],S[7],8,0xd807aa98);
  122|       |    RND(S[7],S[0],S[1],S[2],S[3],S[4],S[5],S[6],9,0x12835b01);
  123|       |    RND(S[6],S[7],S[0],S[1],S[2],S[3],S[4],S[5],10,0x243185be);
  124|       |    RND(S[5],S[6],S[7],S[0],S[1],S[2],S[3],S[4],11,0x550c7dc3);
  125|       |    RND(S[4],S[5],S[6],S[7],S[0],S[1],S[2],S[3],12,0x72be5d74);
  126|       |    RND(S[3],S[4],S[5],S[6],S[7],S[0],S[1],S[2],13,0x80deb1fe);
  127|       |    RND(S[2],S[3],S[4],S[5],S[6],S[7],S[0],S[1],14,0x9bdc06a7);
  128|       |    RND(S[1],S[2],S[3],S[4],S[5],S[6],S[7],S[0],15,0xc19bf174);
  129|       |    RND(S[0],S[1],S[2],S[3],S[4],S[5],S[6],S[7],16,0xe49b69c1);
  130|       |    RND(S[7],S[0],S[1],S[2],S[3],S[4],S[5],S[6],17,0xefbe4786);
  131|       |    RND(S[6],S[7],S[0],S[1],S[2],S[3],S[4],S[5],18,0x0fc19dc6);
  132|       |    RND(S[5],S[6],S[7],S[0],S[1],S[2],S[3],S[4],19,0x240ca1cc);
  133|       |    RND(S[4],S[5],S[6],S[7],S[0],S[1],S[2],S[3],20,0x2de92c6f);
  134|       |    RND(S[3],S[4],S[5],S[6],S[7],S[0],S[1],S[2],21,0x4a7484aa);
  135|       |    RND(S[2],S[3],S[4],S[5],S[6],S[7],S[0],S[1],22,0x5cb0a9dc);
  136|       |    RND(S[1],S[2],S[3],S[4],S[5],S[6],S[7],S[0],23,0x76f988da);
  137|       |    RND(S[0],S[1],S[2],S[3],S[4],S[5],S[6],S[7],24,0x983e5152);
  138|       |    RND(S[7],S[0],S[1],S[2],S[3],S[4],S[5],S[6],25,0xa831c66d);
  139|       |    RND(S[6],S[7],S[0],S[1],S[2],S[3],S[4],S[5],26,0xb00327c8);
  140|       |    RND(S[5],S[6],S[7],S[0],S[1],S[2],S[3],S[4],27,0xbf597fc7);
  141|       |    RND(S[4],S[5],S[6],S[7],S[0],S[1],S[2],S[3],28,0xc6e00bf3);
  142|       |    RND(S[3],S[4],S[5],S[6],S[7],S[0],S[1],S[2],29,0xd5a79147);
  143|       |    RND(S[2],S[3],S[4],S[5],S[6],S[7],S[0],S[1],30,0x06ca6351);
  144|       |    RND(S[1],S[2],S[3],S[4],S[5],S[6],S[7],S[0],31,0x14292967);
  145|       |    RND(S[0],S[1],S[2],S[3],S[4],S[5],S[6],S[7],32,0x27b70a85);
  146|       |    RND(S[7],S[0],S[1],S[2],S[3],S[4],S[5],S[6],33,0x2e1b2138);
  147|       |    RND(S[6],S[7],S[0],S[1],S[2],S[3],S[4],S[5],34,0x4d2c6dfc);
  148|       |    RND(S[5],S[6],S[7],S[0],S[1],S[2],S[3],S[4],35,0x53380d13);
  149|       |    RND(S[4],S[5],S[6],S[7],S[0],S[1],S[2],S[3],36,0x650a7354);
  150|       |    RND(S[3],S[4],S[5],S[6],S[7],S[0],S[1],S[2],37,0x766a0abb);
  151|       |    RND(S[2],S[3],S[4],S[5],S[6],S[7],S[0],S[1],38,0x81c2c92e);
  152|       |    RND(S[1],S[2],S[3],S[4],S[5],S[6],S[7],S[0],39,0x92722c85);
  153|       |    RND(S[0],S[1],S[2],S[3],S[4],S[5],S[6],S[7],40,0xa2bfe8a1);
  154|       |    RND(S[7],S[0],S[1],S[2],S[3],S[4],S[5],S[6],41,0xa81a664b);
  155|       |    RND(S[6],S[7],S[0],S[1],S[2],S[3],S[4],S[5],42,0xc24b8b70);
  156|       |    RND(S[5],S[6],S[7],S[0],S[1],S[2],S[3],S[4],43,0xc76c51a3);
  157|       |    RND(S[4],S[5],S[6],S[7],S[0],S[1],S[2],S[3],44,0xd192e819);
  158|       |    RND(S[3],S[4],S[5],S[6],S[7],S[0],S[1],S[2],45,0xd6990624);
  159|       |    RND(S[2],S[3],S[4],S[5],S[6],S[7],S[0],S[1],46,0xf40e3585);
  160|       |    RND(S[1],S[2],S[3],S[4],S[5],S[6],S[7],S[0],47,0x106aa070);
  161|       |    RND(S[0],S[1],S[2],S[3],S[4],S[5],S[6],S[7],48,0x19a4c116);
  162|       |    RND(S[7],S[0],S[1],S[2],S[3],S[4],S[5],S[6],49,0x1e376c08);
  163|       |    RND(S[6],S[7],S[0],S[1],S[2],S[3],S[4],S[5],50,0x2748774c);
  164|       |    RND(S[5],S[6],S[7],S[0],S[1],S[2],S[3],S[4],51,0x34b0bcb5);
  165|       |    RND(S[4],S[5],S[6],S[7],S[0],S[1],S[2],S[3],52,0x391c0cb3);
  166|       |    RND(S[3],S[4],S[5],S[6],S[7],S[0],S[1],S[2],53,0x4ed8aa4a);
  167|       |    RND(S[2],S[3],S[4],S[5],S[6],S[7],S[0],S[1],54,0x5b9cca4f);
  168|       |    RND(S[1],S[2],S[3],S[4],S[5],S[6],S[7],S[0],55,0x682e6ff3);
  169|       |    RND(S[0],S[1],S[2],S[3],S[4],S[5],S[6],S[7],56,0x748f82ee);
  170|       |    RND(S[7],S[0],S[1],S[2],S[3],S[4],S[5],S[6],57,0x78a5636f);
  171|       |    RND(S[6],S[7],S[0],S[1],S[2],S[3],S[4],S[5],58,0x84c87814);
  172|       |    RND(S[5],S[6],S[7],S[0],S[1],S[2],S[3],S[4],59,0x8cc70208);
  173|       |    RND(S[4],S[5],S[6],S[7],S[0],S[1],S[2],S[3],60,0x90befffa);
  174|       |    RND(S[3],S[4],S[5],S[6],S[7],S[0],S[1],S[2],61,0xa4506ceb);
  175|       |    RND(S[2],S[3],S[4],S[5],S[6],S[7],S[0],S[1],62,0xbef9a3f7);
  176|       |    RND(S[1],S[2],S[3],S[4],S[5],S[6],S[7],S[0],63,0xc67178f2);
  177|       |
  178|       |#undef RND
  179|       |
  180|       |#endif
  181|       |
  182|       |    /* feedback */
  183|  48.5M|    for (i = 0; i < 8; i++) {
  ------------------
  |  Branch (183:17): [True: 43.1M, False: 5.39M]
  ------------------
  184|  43.1M|        md->sha256.state[i] = md->sha256.state[i] + S[i];
  185|  43.1M|    }
  186|  5.39M|    return CRYPT_OK;
  187|  5.39M|}

sha512_init:
  174|  3.91k|{
  175|  3.91k|    LTC_ARGCHK(md != NULL);
  ------------------
  |  |   32|  3.91k|#define LTC_ARGCHK(x) do { if (!(x)) { crypt_argchk(#x, __FILE__, __LINE__); } }while(0)
  |  |  ------------------
  |  |  |  Branch (32:32): [True: 0, False: 3.91k]
  |  |  |  Branch (32:87): [Folded, False: 3.91k]
  |  |  ------------------
  ------------------
  176|  3.91k|    md->sha512.curlen = 0;
  177|  3.91k|    md->sha512.length = 0;
  178|  3.91k|    md->sha512.state[0] = CONST64(0x6a09e667f3bcc908);
  ------------------
  |  |  200|  3.91k|   #define CONST64(n) n ## ULL
  ------------------
  179|  3.91k|    md->sha512.state[1] = CONST64(0xbb67ae8584caa73b);
  ------------------
  |  |  200|  3.91k|   #define CONST64(n) n ## ULL
  ------------------
  180|  3.91k|    md->sha512.state[2] = CONST64(0x3c6ef372fe94f82b);
  ------------------
  |  |  200|  3.91k|   #define CONST64(n) n ## ULL
  ------------------
  181|  3.91k|    md->sha512.state[3] = CONST64(0xa54ff53a5f1d36f1);
  ------------------
  |  |  200|  3.91k|   #define CONST64(n) n ## ULL
  ------------------
  182|  3.91k|    md->sha512.state[4] = CONST64(0x510e527fade682d1);
  ------------------
  |  |  200|  3.91k|   #define CONST64(n) n ## ULL
  ------------------
  183|  3.91k|    md->sha512.state[5] = CONST64(0x9b05688c2b3e6c1f);
  ------------------
  |  |  200|  3.91k|   #define CONST64(n) n ## ULL
  ------------------
  184|  3.91k|    md->sha512.state[6] = CONST64(0x1f83d9abfb41bd6b);
  ------------------
  |  |  200|  3.91k|   #define CONST64(n) n ## ULL
  ------------------
  185|  3.91k|    md->sha512.state[7] = CONST64(0x5be0cd19137e2179);
  ------------------
  |  |  200|  3.91k|   #define CONST64(n) n ## ULL
  ------------------
  186|  3.91k|    return CRYPT_OK;
  187|  3.91k|}
sha512_done:
  205|  3.91k|{
  206|  3.91k|    int i;
  207|       |
  208|  3.91k|    LTC_ARGCHK(md  != NULL);
  ------------------
  |  |   32|  3.91k|#define LTC_ARGCHK(x) do { if (!(x)) { crypt_argchk(#x, __FILE__, __LINE__); } }while(0)
  |  |  ------------------
  |  |  |  Branch (32:32): [True: 0, False: 3.91k]
  |  |  |  Branch (32:87): [Folded, False: 3.91k]
  |  |  ------------------
  ------------------
  209|  3.91k|    LTC_ARGCHK(out != NULL);
  ------------------
  |  |   32|  3.91k|#define LTC_ARGCHK(x) do { if (!(x)) { crypt_argchk(#x, __FILE__, __LINE__); } }while(0)
  |  |  ------------------
  |  |  |  Branch (32:32): [True: 0, False: 3.91k]
  |  |  |  Branch (32:87): [Folded, False: 3.91k]
  |  |  ------------------
  ------------------
  210|       |
  211|  3.91k|    if (md->sha512.curlen >= sizeof(md->sha512.buf)) {
  ------------------
  |  Branch (211:9): [True: 0, False: 3.91k]
  ------------------
  212|      0|       return CRYPT_INVALID_ARG;
  213|      0|    }
  214|       |
  215|       |    /* increase the length of the message */
  216|  3.91k|    md->sha512.length += md->sha512.curlen * CONST64(8);
  ------------------
  |  |  200|  3.91k|   #define CONST64(n) n ## ULL
  ------------------
  217|       |
  218|       |    /* append the '1' bit */
  219|  3.91k|    md->sha512.buf[md->sha512.curlen++] = (unsigned char)0x80;
  220|       |
  221|       |    /* if the length is currently above 112 bytes we append zeros
  222|       |     * then compress.  Then we can fall back to padding zeros and length
  223|       |     * encoding like normal.
  224|       |     */
  225|  3.91k|    if (md->sha512.curlen > 112) {
  ------------------
  |  Branch (225:9): [True: 41, False: 3.87k]
  ------------------
  226|    350|        while (md->sha512.curlen < 128) {
  ------------------
  |  Branch (226:16): [True: 309, False: 41]
  ------------------
  227|    309|            md->sha512.buf[md->sha512.curlen++] = (unsigned char)0;
  228|    309|        }
  229|     41|        sha512_compress(md, md->sha512.buf);
  230|     41|        md->sha512.curlen = 0;
  231|     41|    }
  232|       |
  233|       |    /* pad upto 120 bytes of zeroes
  234|       |     * note: that from 112 to 120 is the 64 MSB of the length.  We assume that you won't hash
  235|       |     * > 2^64 bits of data... :-)
  236|       |     */
  237|   423k|    while (md->sha512.curlen < 120) {
  ------------------
  |  Branch (237:12): [True: 419k, False: 3.91k]
  ------------------
  238|   419k|        md->sha512.buf[md->sha512.curlen++] = (unsigned char)0;
  239|   419k|    }
  240|       |
  241|       |    /* store length */
  242|  3.91k|    STORE64H(md->sha512.length, md->sha512.buf+120);
  ------------------
  |  |  101|  3.91k|#define STORE64H(x, y)                          \
  |  |  102|  3.91k|do { ulong64 __t = __builtin_bswap64 ((x));     \
  |  |  103|  3.91k|      XMEMCPY ((y), &__t, 8); } while(0)
  |  |  ------------------
  |  |  |  |   39|  3.91k|#define XMEMCPY  memcpy
  |  |  ------------------
  |  |  |  Branch (103:39): [Folded, False: 3.91k]
  |  |  ------------------
  ------------------
  243|  3.91k|    sha512_compress(md, md->sha512.buf);
  244|       |
  245|       |    /* copy output */
  246|  35.2k|    for (i = 0; i < 8; i++) {
  ------------------
  |  Branch (246:17): [True: 31.3k, False: 3.91k]
  ------------------
  247|  31.3k|        STORE64H(md->sha512.state[i], out+(8*i));
  ------------------
  |  |  101|  31.3k|#define STORE64H(x, y)                          \
  |  |  102|  31.3k|do { ulong64 __t = __builtin_bswap64 ((x));     \
  |  |  103|  31.3k|      XMEMCPY ((y), &__t, 8); } while(0)
  |  |  ------------------
  |  |  |  |   39|  31.3k|#define XMEMCPY  memcpy
  |  |  ------------------
  |  |  |  Branch (103:39): [Folded, False: 31.3k]
  |  |  ------------------
  ------------------
  248|  31.3k|    }
  249|       |#ifdef LTC_CLEAN_STACK
  250|       |    zeromem(md, sizeof(hash_state));
  251|       |#endif
  252|  3.91k|    return CRYPT_OK;
  253|  3.91k|}
sha512.c:sha512_compress:
   96|  45.4k|{
   97|  45.4k|    ulong64 S[8], W[80], t0, t1;
   98|  45.4k|    int i;
   99|       |
  100|       |    /* copy state into S */
  101|   408k|    for (i = 0; i < 8; i++) {
  ------------------
  |  Branch (101:17): [True: 363k, False: 45.4k]
  ------------------
  102|   363k|        S[i] = md->sha512.state[i];
  103|   363k|    }
  104|       |
  105|       |    /* copy the state into 1024-bits into W[0..15] */
  106|   772k|    for (i = 0; i < 16; i++) {
  ------------------
  |  Branch (106:17): [True: 726k, False: 45.4k]
  ------------------
  107|   726k|        LOAD64H(W[i], buf + (8*i));
  ------------------
  |  |  105|   726k|#define LOAD64H(x, y)                           \
  |  |  106|   726k|do { XMEMCPY (&(x), (y), 8);                    \
  |  |  ------------------
  |  |  |  |   39|   726k|#define XMEMCPY  memcpy
  |  |  ------------------
  |  |  107|   726k|      (x) = __builtin_bswap64 ((x)); } while(0)
  |  |  ------------------
  |  |  |  Branch (107:46): [Folded, False: 726k]
  |  |  ------------------
  ------------------
  108|   726k|    }
  109|       |
  110|       |    /* fill W[16..79] */
  111|  2.95M|    for (i = 16; i < 80; i++) {
  ------------------
  |  Branch (111:18): [True: 2.90M, False: 45.4k]
  ------------------
  112|  2.90M|        W[i] = Gamma1(W[i - 2]) + W[i - 7] + Gamma0(W[i - 15]) + W[i - 16];
  ------------------
  |  |   88|  2.90M|#define Gamma1(x)       (S(x, 19) ^ S(x, 61) ^ R(x, 6))
  |  |  ------------------
  |  |  |  |   83|  2.90M|#define S(x, n)         ROR64c(x, n)
  |  |  |  |  ------------------
  |  |  |  |  |  |  384|  2.90M|#define ROR64c(word,i) ({ \
  |  |  |  |  |  |  385|  2.90M|   ulong64 __ROR64c_tmp = word; \
  |  |  |  |  |  |  386|  2.90M|   __asm__ ("rorq %2, %0" : \
  |  |  |  |  |  |  387|  2.90M|            "=r" (__ROR64c_tmp) : \
  |  |  |  |  |  |  388|  2.90M|            "0" (__ROR64c_tmp), \
  |  |  |  |  |  |  389|  2.90M|            "J" (i)); \
  |  |  |  |  |  |  390|  2.90M|            __ROR64c_tmp; \
  |  |  |  |  |  |  391|  2.90M|   })
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define Gamma1(x)       (S(x, 19) ^ S(x, 61) ^ R(x, 6))
  |  |  ------------------
  |  |  |  |   83|  2.90M|#define S(x, n)         ROR64c(x, n)
  |  |  |  |  ------------------
  |  |  |  |  |  |  384|  2.90M|#define ROR64c(word,i) ({ \
  |  |  |  |  |  |  385|  2.90M|   ulong64 __ROR64c_tmp = word; \
  |  |  |  |  |  |  386|  2.90M|   __asm__ ("rorq %2, %0" : \
  |  |  |  |  |  |  387|  2.90M|            "=r" (__ROR64c_tmp) : \
  |  |  |  |  |  |  388|  2.90M|            "0" (__ROR64c_tmp), \
  |  |  |  |  |  |  389|  2.90M|            "J" (i)); \
  |  |  |  |  |  |  390|  2.90M|            __ROR64c_tmp; \
  |  |  |  |  |  |  391|  2.90M|   })
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define Gamma1(x)       (S(x, 19) ^ S(x, 61) ^ R(x, 6))
  |  |  ------------------
  |  |  |  |   84|  2.90M|#define R(x, n)         (((x)&CONST64(0xFFFFFFFFFFFFFFFF))>>((ulong64)n))
  |  |  |  |  ------------------
  |  |  |  |  |  |  200|  2.90M|   #define CONST64(n) n ## ULL
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                      W[i] = Gamma1(W[i - 2]) + W[i - 7] + Gamma0(W[i - 15]) + W[i - 16];
  ------------------
  |  |   87|  2.90M|#define Gamma0(x)       (S(x, 1) ^ S(x, 8) ^ R(x, 7))
  |  |  ------------------
  |  |  |  |   83|  2.90M|#define S(x, n)         ROR64c(x, n)
  |  |  |  |  ------------------
  |  |  |  |  |  |  384|  2.90M|#define ROR64c(word,i) ({ \
  |  |  |  |  |  |  385|  2.90M|   ulong64 __ROR64c_tmp = word; \
  |  |  |  |  |  |  386|  2.90M|   __asm__ ("rorq %2, %0" : \
  |  |  |  |  |  |  387|  2.90M|            "=r" (__ROR64c_tmp) : \
  |  |  |  |  |  |  388|  2.90M|            "0" (__ROR64c_tmp), \
  |  |  |  |  |  |  389|  2.90M|            "J" (i)); \
  |  |  |  |  |  |  390|  2.90M|            __ROR64c_tmp; \
  |  |  |  |  |  |  391|  2.90M|   })
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define Gamma0(x)       (S(x, 1) ^ S(x, 8) ^ R(x, 7))
  |  |  ------------------
  |  |  |  |   83|  2.90M|#define S(x, n)         ROR64c(x, n)
  |  |  |  |  ------------------
  |  |  |  |  |  |  384|  2.90M|#define ROR64c(word,i) ({ \
  |  |  |  |  |  |  385|  2.90M|   ulong64 __ROR64c_tmp = word; \
  |  |  |  |  |  |  386|  2.90M|   __asm__ ("rorq %2, %0" : \
  |  |  |  |  |  |  387|  2.90M|            "=r" (__ROR64c_tmp) : \
  |  |  |  |  |  |  388|  2.90M|            "0" (__ROR64c_tmp), \
  |  |  |  |  |  |  389|  2.90M|            "J" (i)); \
  |  |  |  |  |  |  390|  2.90M|            __ROR64c_tmp; \
  |  |  |  |  |  |  391|  2.90M|   })
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define Gamma0(x)       (S(x, 1) ^ S(x, 8) ^ R(x, 7))
  |  |  ------------------
  |  |  |  |   84|  2.90M|#define R(x, n)         (((x)&CONST64(0xFFFFFFFFFFFFFFFF))>>((ulong64)n))
  |  |  |  |  ------------------
  |  |  |  |  |  |  200|  2.90M|   #define CONST64(n) n ## ULL
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  113|  2.90M|    }
  114|       |
  115|       |    /* Compress */
  116|  45.4k|#ifdef LTC_SMALL_CODE
  117|  3.67M|    for (i = 0; i < 80; i++) {
  ------------------
  |  Branch (117:17): [True: 3.63M, False: 45.4k]
  ------------------
  118|  3.63M|        t0 = S[7] + Sigma1(S[4]) + Ch(S[4], S[5], S[6]) + K[i] + W[i];
  ------------------
  |  |   86|  3.63M|#define Sigma1(x)       (S(x, 14) ^ S(x, 18) ^ S(x, 41))
  |  |  ------------------
  |  |  |  |   83|  3.63M|#define S(x, n)         ROR64c(x, n)
  |  |  |  |  ------------------
  |  |  |  |  |  |  384|  3.63M|#define ROR64c(word,i) ({ \
  |  |  |  |  |  |  385|  3.63M|   ulong64 __ROR64c_tmp = word; \
  |  |  |  |  |  |  386|  3.63M|   __asm__ ("rorq %2, %0" : \
  |  |  |  |  |  |  387|  3.63M|            "=r" (__ROR64c_tmp) : \
  |  |  |  |  |  |  388|  3.63M|            "0" (__ROR64c_tmp), \
  |  |  |  |  |  |  389|  3.63M|            "J" (i)); \
  |  |  |  |  |  |  390|  3.63M|            __ROR64c_tmp; \
  |  |  |  |  |  |  391|  3.63M|   })
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define Sigma1(x)       (S(x, 14) ^ S(x, 18) ^ S(x, 41))
  |  |  ------------------
  |  |  |  |   83|  3.63M|#define S(x, n)         ROR64c(x, n)
  |  |  |  |  ------------------
  |  |  |  |  |  |  384|  3.63M|#define ROR64c(word,i) ({ \
  |  |  |  |  |  |  385|  3.63M|   ulong64 __ROR64c_tmp = word; \
  |  |  |  |  |  |  386|  3.63M|   __asm__ ("rorq %2, %0" : \
  |  |  |  |  |  |  387|  3.63M|            "=r" (__ROR64c_tmp) : \
  |  |  |  |  |  |  388|  3.63M|            "0" (__ROR64c_tmp), \
  |  |  |  |  |  |  389|  3.63M|            "J" (i)); \
  |  |  |  |  |  |  390|  3.63M|            __ROR64c_tmp; \
  |  |  |  |  |  |  391|  3.63M|   })
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define Sigma1(x)       (S(x, 14) ^ S(x, 18) ^ S(x, 41))
  |  |  ------------------
  |  |  |  |   83|  3.63M|#define S(x, n)         ROR64c(x, n)
  |  |  |  |  ------------------
  |  |  |  |  |  |  384|  3.63M|#define ROR64c(word,i) ({ \
  |  |  |  |  |  |  385|  3.63M|   ulong64 __ROR64c_tmp = word; \
  |  |  |  |  |  |  386|  3.63M|   __asm__ ("rorq %2, %0" : \
  |  |  |  |  |  |  387|  3.63M|            "=r" (__ROR64c_tmp) : \
  |  |  |  |  |  |  388|  3.63M|            "0" (__ROR64c_tmp), \
  |  |  |  |  |  |  389|  3.63M|            "J" (i)); \
  |  |  |  |  |  |  390|  3.63M|            __ROR64c_tmp; \
  |  |  |  |  |  |  391|  3.63M|   })
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                      t0 = S[7] + Sigma1(S[4]) + Ch(S[4], S[5], S[6]) + K[i] + W[i];
  ------------------
  |  |   81|  3.63M|#define Ch(x,y,z)       (z ^ (x & (y ^ z)))
  ------------------
  119|  3.63M|        t1 = Sigma0(S[0]) + Maj(S[0], S[1], S[2]);
  ------------------
  |  |   85|  3.63M|#define Sigma0(x)       (S(x, 28) ^ S(x, 34) ^ S(x, 39))
  |  |  ------------------
  |  |  |  |   83|  3.63M|#define S(x, n)         ROR64c(x, n)
  |  |  |  |  ------------------
  |  |  |  |  |  |  384|  3.63M|#define ROR64c(word,i) ({ \
  |  |  |  |  |  |  385|  3.63M|   ulong64 __ROR64c_tmp = word; \
  |  |  |  |  |  |  386|  3.63M|   __asm__ ("rorq %2, %0" : \
  |  |  |  |  |  |  387|  3.63M|            "=r" (__ROR64c_tmp) : \
  |  |  |  |  |  |  388|  3.63M|            "0" (__ROR64c_tmp), \
  |  |  |  |  |  |  389|  3.63M|            "J" (i)); \
  |  |  |  |  |  |  390|  3.63M|            __ROR64c_tmp; \
  |  |  |  |  |  |  391|  3.63M|   })
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define Sigma0(x)       (S(x, 28) ^ S(x, 34) ^ S(x, 39))
  |  |  ------------------
  |  |  |  |   83|  3.63M|#define S(x, n)         ROR64c(x, n)
  |  |  |  |  ------------------
  |  |  |  |  |  |  384|  3.63M|#define ROR64c(word,i) ({ \
  |  |  |  |  |  |  385|  3.63M|   ulong64 __ROR64c_tmp = word; \
  |  |  |  |  |  |  386|  3.63M|   __asm__ ("rorq %2, %0" : \
  |  |  |  |  |  |  387|  3.63M|            "=r" (__ROR64c_tmp) : \
  |  |  |  |  |  |  388|  3.63M|            "0" (__ROR64c_tmp), \
  |  |  |  |  |  |  389|  3.63M|            "J" (i)); \
  |  |  |  |  |  |  390|  3.63M|            __ROR64c_tmp; \
  |  |  |  |  |  |  391|  3.63M|   })
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define Sigma0(x)       (S(x, 28) ^ S(x, 34) ^ S(x, 39))
  |  |  ------------------
  |  |  |  |   83|  3.63M|#define S(x, n)         ROR64c(x, n)
  |  |  |  |  ------------------
  |  |  |  |  |  |  384|  3.63M|#define ROR64c(word,i) ({ \
  |  |  |  |  |  |  385|  3.63M|   ulong64 __ROR64c_tmp = word; \
  |  |  |  |  |  |  386|  3.63M|   __asm__ ("rorq %2, %0" : \
  |  |  |  |  |  |  387|  3.63M|            "=r" (__ROR64c_tmp) : \
  |  |  |  |  |  |  388|  3.63M|            "0" (__ROR64c_tmp), \
  |  |  |  |  |  |  389|  3.63M|            "J" (i)); \
  |  |  |  |  |  |  390|  3.63M|            __ROR64c_tmp; \
  |  |  |  |  |  |  391|  3.63M|   })
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                      t1 = Sigma0(S[0]) + Maj(S[0], S[1], S[2]);
  ------------------
  |  |   82|  3.63M|#define Maj(x,y,z)      (((x | y) & z) | (x & y))
  ------------------
  120|  3.63M|        S[7] = S[6];
  121|  3.63M|        S[6] = S[5];
  122|  3.63M|        S[5] = S[4];
  123|  3.63M|        S[4] = S[3] + t0;
  124|  3.63M|        S[3] = S[2];
  125|  3.63M|        S[2] = S[1];
  126|  3.63M|        S[1] = S[0];
  127|  3.63M|        S[0] = t0 + t1;
  128|  3.63M|    }
  129|       |#else
  130|       |#define RND(a,b,c,d,e,f,g,h,i)                    \
  131|       |     t0 = h + Sigma1(e) + Ch(e, f, g) + K[i] + W[i];   \
  132|       |     t1 = Sigma0(a) + Maj(a, b, c);                  \
  133|       |     d += t0;                                        \
  134|       |     h  = t0 + t1;
  135|       |
  136|       |    for (i = 0; i < 80; i += 8) {
  137|       |        RND(S[0],S[1],S[2],S[3],S[4],S[5],S[6],S[7],i+0);
  138|       |        RND(S[7],S[0],S[1],S[2],S[3],S[4],S[5],S[6],i+1);
  139|       |        RND(S[6],S[7],S[0],S[1],S[2],S[3],S[4],S[5],i+2);
  140|       |        RND(S[5],S[6],S[7],S[0],S[1],S[2],S[3],S[4],i+3);
  141|       |        RND(S[4],S[5],S[6],S[7],S[0],S[1],S[2],S[3],i+4);
  142|       |        RND(S[3],S[4],S[5],S[6],S[7],S[0],S[1],S[2],i+5);
  143|       |        RND(S[2],S[3],S[4],S[5],S[6],S[7],S[0],S[1],i+6);
  144|       |        RND(S[1],S[2],S[3],S[4],S[5],S[6],S[7],S[0],i+7);
  145|       |    }
  146|       |#endif
  147|       |
  148|       |
  149|       |    /* feedback */
  150|   408k|    for (i = 0; i < 8; i++) {
  ------------------
  |  Branch (150:17): [True: 363k, False: 45.4k]
  ------------------
  151|   363k|        md->sha512.state[i] = md->sha512.state[i] + S[i];
  152|   363k|    }
  153|       |
  154|  45.4k|    return CRYPT_OK;
  155|  45.4k|}

sha1_process:
  491|    668|int func_name (hash_state * md, const unsigned char *in, unsigned long inlen)               \
  492|    668|{                                                                                           \
  493|    668|    unsigned long n;                                                                        \
  494|    668|    int           err;                                                                      \
  495|    668|    LTC_ARGCHK(md != NULL);                                                                 \
  ------------------
  |  |   32|    668|#define LTC_ARGCHK(x) do { if (!(x)) { crypt_argchk(#x, __FILE__, __LINE__); } }while(0)
  |  |  ------------------
  |  |  |  Branch (32:32): [True: 0, False: 668]
  |  |  |  Branch (32:87): [Folded, False: 668]
  |  |  ------------------
  ------------------
  496|    668|    LTC_ARGCHK(in != NULL);                                                                 \
  ------------------
  |  |   32|    668|#define LTC_ARGCHK(x) do { if (!(x)) { crypt_argchk(#x, __FILE__, __LINE__); } }while(0)
  |  |  ------------------
  |  |  |  Branch (32:32): [True: 0, False: 668]
  |  |  |  Branch (32:87): [Folded, False: 668]
  |  |  ------------------
  ------------------
  497|    668|    if (md-> state_var .curlen > sizeof(md-> state_var .buf)) {                             \
  ------------------
  |  Branch (497:9): [True: 0, False: 668]
  ------------------
  498|      0|       return CRYPT_INVALID_ARG;                                                            \
  499|      0|    }                                                                                       \
  500|    668|    if ((md-> state_var .length + inlen) < md-> state_var .length) {                        \
  ------------------
  |  Branch (500:9): [True: 0, False: 668]
  ------------------
  501|      0|      return CRYPT_HASH_OVERFLOW;                                                           \
  502|      0|    }                                                                                       \
  503|  1.33k|    while (inlen > 0) {                                                                     \
  ------------------
  |  Branch (503:12): [True: 668, False: 668]
  ------------------
  504|    668|        if (md-> state_var .curlen == 0 && inlen >= block_size) {                           \
  ------------------
  |  Branch (504:13): [True: 668, False: 0]
  |  Branch (504:44): [True: 0, False: 668]
  ------------------
  505|      0|           if ((err = compress_name (md, (unsigned char *)in)) != CRYPT_OK) {               \
  ------------------
  |  Branch (505:16): [True: 0, False: 0]
  ------------------
  506|      0|              return err;                                                                   \
  507|      0|           }                                                                                \
  508|      0|           md-> state_var .length += block_size * 8;                                        \
  509|      0|           in             += block_size;                                                    \
  510|      0|           inlen          -= block_size;                                                    \
  511|    668|        } else {                                                                            \
  512|    668|           n = MIN(inlen, (block_size - md-> state_var .curlen));                           \
  ------------------
  |  |  425|    668|   #define MIN(x, y) ( ((x)<(y))?(x):(y) )
  |  |  ------------------
  |  |  |  Branch (425:24): [True: 668, False: 0]
  |  |  ------------------
  ------------------
  513|    668|           XMEMCPY(md-> state_var .buf + md-> state_var.curlen, in, (size_t)n);             \
  ------------------
  |  |   39|    668|#define XMEMCPY  memcpy
  ------------------
  514|    668|           md-> state_var .curlen += n;                                                     \
  515|    668|           in             += n;                                                             \
  516|    668|           inlen          -= n;                                                             \
  517|    668|           if (md-> state_var .curlen == block_size) {                                      \
  ------------------
  |  Branch (517:16): [True: 0, False: 668]
  ------------------
  518|      0|              if ((err = compress_name (md, md-> state_var .buf)) != CRYPT_OK) {            \
  ------------------
  |  Branch (518:19): [True: 0, False: 0]
  ------------------
  519|      0|                 return err;                                                                \
  520|      0|              }                                                                             \
  521|      0|              md-> state_var .length += 8*block_size;                                       \
  522|      0|              md-> state_var .curlen = 0;                                                   \
  523|      0|           }                                                                                \
  524|    668|       }                                                                                    \
  525|    668|    }                                                                                       \
  526|    668|    return CRYPT_OK;                                                                        \
  527|    668|}
sha256_process:
  491|  10.7M|int func_name (hash_state * md, const unsigned char *in, unsigned long inlen)               \
  492|  10.7M|{                                                                                           \
  493|  10.7M|    unsigned long n;                                                                        \
  494|  10.7M|    int           err;                                                                      \
  495|  10.7M|    LTC_ARGCHK(md != NULL);                                                                 \
  ------------------
  |  |   32|  10.7M|#define LTC_ARGCHK(x) do { if (!(x)) { crypt_argchk(#x, __FILE__, __LINE__); } }while(0)
  |  |  ------------------
  |  |  |  Branch (32:32): [True: 0, False: 10.7M]
  |  |  |  Branch (32:87): [Folded, False: 10.7M]
  |  |  ------------------
  ------------------
  496|  10.7M|    LTC_ARGCHK(in != NULL);                                                                 \
  ------------------
  |  |   32|  10.7M|#define LTC_ARGCHK(x) do { if (!(x)) { crypt_argchk(#x, __FILE__, __LINE__); } }while(0)
  |  |  ------------------
  |  |  |  Branch (32:32): [True: 0, False: 10.7M]
  |  |  |  Branch (32:87): [Folded, False: 10.7M]
  |  |  ------------------
  ------------------
  497|  10.7M|    if (md-> state_var .curlen > sizeof(md-> state_var .buf)) {                             \
  ------------------
  |  Branch (497:9): [True: 0, False: 10.7M]
  ------------------
  498|      0|       return CRYPT_INVALID_ARG;                                                            \
  499|      0|    }                                                                                       \
  500|  10.7M|    if ((md-> state_var .length + inlen) < md-> state_var .length) {                        \
  ------------------
  |  Branch (500:9): [True: 0, False: 10.7M]
  ------------------
  501|      0|      return CRYPT_HASH_OVERFLOW;                                                           \
  502|      0|    }                                                                                       \
  503|  21.4M|    while (inlen > 0) {                                                                     \
  ------------------
  |  Branch (503:12): [True: 10.7M, False: 10.7M]
  ------------------
  504|  10.7M|        if (md-> state_var .curlen == 0 && inlen >= block_size) {                           \
  ------------------
  |  Branch (504:13): [True: 5.39M, False: 5.36M]
  |  Branch (504:44): [True: 36.6k, False: 5.36M]
  ------------------
  505|  36.6k|           if ((err = compress_name (md, (unsigned char *)in)) != CRYPT_OK) {               \
  ------------------
  |  Branch (505:16): [True: 0, False: 36.6k]
  ------------------
  506|      0|              return err;                                                                   \
  507|      0|           }                                                                                \
  508|  36.6k|           md-> state_var .length += block_size * 8;                                        \
  509|  36.6k|           in             += block_size;                                                    \
  510|  36.6k|           inlen          -= block_size;                                                    \
  511|  10.7M|        } else {                                                                            \
  512|  10.7M|           n = MIN(inlen, (block_size - md-> state_var .curlen));                           \
  ------------------
  |  |  425|  10.7M|   #define MIN(x, y) ( ((x)<(y))?(x):(y) )
  |  |  ------------------
  |  |  |  Branch (425:24): [True: 10.7M, False: 0]
  |  |  ------------------
  ------------------
  513|  10.7M|           XMEMCPY(md-> state_var .buf + md-> state_var.curlen, in, (size_t)n);             \
  ------------------
  |  |   39|  10.7M|#define XMEMCPY  memcpy
  ------------------
  514|  10.7M|           md-> state_var .curlen += n;                                                     \
  515|  10.7M|           in             += n;                                                             \
  516|  10.7M|           inlen          -= n;                                                             \
  517|  10.7M|           if (md-> state_var .curlen == block_size) {                                      \
  ------------------
  |  Branch (517:16): [True: 0, False: 10.7M]
  ------------------
  518|      0|              if ((err = compress_name (md, md-> state_var .buf)) != CRYPT_OK) {            \
  ------------------
  |  Branch (518:19): [True: 0, False: 0]
  ------------------
  519|      0|                 return err;                                                                \
  520|      0|              }                                                                             \
  521|      0|              md-> state_var .length += 8*block_size;                                       \
  522|      0|              md-> state_var .curlen = 0;                                                   \
  523|      0|           }                                                                                \
  524|  10.7M|       }                                                                                    \
  525|  10.7M|    }                                                                                       \
  526|  10.7M|    return CRYPT_OK;                                                                        \
  527|  10.7M|}
sha512_process:
  491|  3.95k|int func_name (hash_state * md, const unsigned char *in, unsigned long inlen)               \
  492|  3.95k|{                                                                                           \
  493|  3.95k|    unsigned long n;                                                                        \
  494|  3.95k|    int           err;                                                                      \
  495|  3.95k|    LTC_ARGCHK(md != NULL);                                                                 \
  ------------------
  |  |   32|  3.95k|#define LTC_ARGCHK(x) do { if (!(x)) { crypt_argchk(#x, __FILE__, __LINE__); } }while(0)
  |  |  ------------------
  |  |  |  Branch (32:32): [True: 0, False: 3.95k]
  |  |  |  Branch (32:87): [Folded, False: 3.95k]
  |  |  ------------------
  ------------------
  496|  3.95k|    LTC_ARGCHK(in != NULL);                                                                 \
  ------------------
  |  |   32|  3.95k|#define LTC_ARGCHK(x) do { if (!(x)) { crypt_argchk(#x, __FILE__, __LINE__); } }while(0)
  |  |  ------------------
  |  |  |  Branch (32:32): [True: 0, False: 3.95k]
  |  |  |  Branch (32:87): [Folded, False: 3.95k]
  |  |  ------------------
  ------------------
  497|  3.95k|    if (md-> state_var .curlen > sizeof(md-> state_var .buf)) {                             \
  ------------------
  |  Branch (497:9): [True: 0, False: 3.95k]
  ------------------
  498|      0|       return CRYPT_INVALID_ARG;                                                            \
  499|      0|    }                                                                                       \
  500|  3.95k|    if ((md-> state_var .length + inlen) < md-> state_var .length) {                        \
  ------------------
  |  Branch (500:9): [True: 0, False: 3.95k]
  ------------------
  501|      0|      return CRYPT_HASH_OVERFLOW;                                                           \
  502|      0|    }                                                                                       \
  503|  49.3k|    while (inlen > 0) {                                                                     \
  ------------------
  |  Branch (503:12): [True: 45.4k, False: 3.95k]
  ------------------
  504|  45.4k|        if (md-> state_var .curlen == 0 && inlen >= block_size) {                           \
  ------------------
  |  Branch (504:13): [True: 45.3k, False: 34]
  |  Branch (504:44): [True: 41.4k, False: 3.91k]
  ------------------
  505|  41.4k|           if ((err = compress_name (md, (unsigned char *)in)) != CRYPT_OK) {               \
  ------------------
  |  Branch (505:16): [True: 0, False: 41.4k]
  ------------------
  506|      0|              return err;                                                                   \
  507|      0|           }                                                                                \
  508|  41.4k|           md-> state_var .length += block_size * 8;                                        \
  509|  41.4k|           in             += block_size;                                                    \
  510|  41.4k|           inlen          -= block_size;                                                    \
  511|  41.4k|        } else {                                                                            \
  512|  3.94k|           n = MIN(inlen, (block_size - md-> state_var .curlen));                           \
  ------------------
  |  |  425|  3.94k|   #define MIN(x, y) ( ((x)<(y))?(x):(y) )
  |  |  ------------------
  |  |  |  Branch (425:24): [True: 3.94k, False: 0]
  |  |  ------------------
  ------------------
  513|  3.94k|           XMEMCPY(md-> state_var .buf + md-> state_var.curlen, in, (size_t)n);             \
  ------------------
  |  |   39|  3.94k|#define XMEMCPY  memcpy
  ------------------
  514|  3.94k|           md-> state_var .curlen += n;                                                     \
  515|  3.94k|           in             += n;                                                             \
  516|  3.94k|           inlen          -= n;                                                             \
  517|  3.94k|           if (md-> state_var .curlen == block_size) {                                      \
  ------------------
  |  Branch (517:16): [True: 0, False: 3.94k]
  ------------------
  518|      0|              if ((err = compress_name (md, md-> state_var .buf)) != CRYPT_OK) {            \
  ------------------
  |  Branch (518:19): [True: 0, False: 0]
  ------------------
  519|      0|                 return err;                                                                \
  520|      0|              }                                                                             \
  521|      0|              md-> state_var .length += 8*block_size;                                       \
  522|      0|              md-> state_var .curlen = 0;                                                   \
  523|      0|           }                                                                                \
  524|  3.94k|       }                                                                                    \
  525|  45.4k|    }                                                                                       \
  526|  3.95k|    return CRYPT_OK;                                                                        \
  527|  3.95k|}

sha1.c:ROL:
  258|  42.7k|{
  259|  42.7k|   asm ("roll %%cl,%0"
  260|  42.7k|      :"=r" (word)
  261|  42.7k|      :"0" (word),"c" (i));
  262|  42.7k|   return word;
  263|  42.7k|}

ltm_desc.c:init:
   58|  3.04M|{
   59|  3.04M|   int err;
   60|       |
   61|  3.04M|   LTC_ARGCHK(a != NULL);
  ------------------
  |  |   32|  3.04M|#define LTC_ARGCHK(x) do { if (!(x)) { crypt_argchk(#x, __FILE__, __LINE__); } }while(0)
  |  |  ------------------
  |  |  |  Branch (32:32): [True: 0, False: 3.04M]
  |  |  |  Branch (32:87): [Folded, False: 3.04M]
  |  |  ------------------
  ------------------
   62|       |
   63|  3.04M|   if ((err = init_mpi(a)) != CRYPT_OK) {
  ------------------
  |  Branch (63:8): [True: 0, False: 3.04M]
  ------------------
   64|      0|      return err;
   65|      0|   }
   66|  3.04M|   if ((err = mpi_to_ltc_error(mp_init(*a))) != CRYPT_OK) {
  ------------------
  |  Branch (66:8): [True: 0, False: 3.04M]
  ------------------
   67|      0|      XFREE(*a);
  ------------------
  |  |   17|      0|#define XFREE m_free_direct
  ------------------
   68|      0|   }
   69|  3.04M|   return err;
   70|  3.04M|}
ltm_desc.c:init_mpi:
   46|  3.04M|{
   47|  3.04M|   LTC_ARGCHK(a != NULL);
  ------------------
  |  |   32|  3.04M|#define LTC_ARGCHK(x) do { if (!(x)) { crypt_argchk(#x, __FILE__, __LINE__); } }while(0)
  |  |  ------------------
  |  |  |  Branch (32:32): [True: 0, False: 3.04M]
  |  |  |  Branch (32:87): [Folded, False: 3.04M]
  |  |  ------------------
  ------------------
   48|       |
   49|  3.04M|   *a = XCALLOC(1, sizeof(mp_int));
  ------------------
  |  |   19|  3.04M|#define XCALLOC m_calloc
  ------------------
   50|  3.04M|   if (*a == NULL) {
  ------------------
  |  Branch (50:8): [True: 0, False: 3.04M]
  ------------------
   51|      0|      return CRYPT_MEM;
   52|  3.04M|   } else {
   53|  3.04M|      return CRYPT_OK;
   54|  3.04M|   }
   55|  3.04M|}
ltm_desc.c:mpi_to_ltc_error:
   34|  41.1M|{
   35|  41.1M|   size_t x;
   36|       |
   37|  41.1M|   for (x = 0; x < sizeof(mpi_to_ltc_codes)/sizeof(mpi_to_ltc_codes[0]); x++) {
  ------------------
  |  Branch (37:16): [True: 41.1M, False: 0]
  ------------------
   38|  41.1M|       if (err == mpi_to_ltc_codes[x].mpi_code) {
  ------------------
  |  Branch (38:12): [True: 41.1M, False: 0]
  ------------------
   39|  41.1M|          return mpi_to_ltc_codes[x].ltc_code;
   40|  41.1M|       }
   41|  41.1M|   }
   42|      0|   return CRYPT_ERROR;
   43|  41.1M|}
ltm_desc.c:deinit:
   73|  3.04M|{
   74|  3.04M|   LTC_ARGCHKVD(a != NULL);
  ------------------
  |  |   33|  3.04M|#define LTC_ARGCHKVD(x) do { if (!(x)) { crypt_argchk(#x, __FILE__, __LINE__); } }while(0)
  |  |  ------------------
  |  |  |  Branch (33:34): [True: 0, False: 3.04M]
  |  |  |  Branch (33:89): [Folded, False: 3.04M]
  |  |  ------------------
  ------------------
   75|  3.04M|   mp_clear(a);
   76|  3.04M|   XFREE(a);
  ------------------
  |  |   17|  3.04M|#define XFREE m_free_direct
  ------------------
   77|  3.04M|}
ltm_desc.c:copy:
   87|  2.63M|{
   88|  2.63M|   LTC_ARGCHK(a != NULL);
  ------------------
  |  |   32|  2.63M|#define LTC_ARGCHK(x) do { if (!(x)) { crypt_argchk(#x, __FILE__, __LINE__); } }while(0)
  |  |  ------------------
  |  |  |  Branch (32:32): [True: 0, False: 2.63M]
  |  |  |  Branch (32:87): [Folded, False: 2.63M]
  |  |  ------------------
  ------------------
   89|  2.63M|   LTC_ARGCHK(b != NULL);
  ------------------
  |  |   32|  2.63M|#define LTC_ARGCHK(x) do { if (!(x)) { crypt_argchk(#x, __FILE__, __LINE__); } }while(0)
  |  |  ------------------
  |  |  |  Branch (32:32): [True: 0, False: 2.63M]
  |  |  |  Branch (32:87): [Folded, False: 2.63M]
  |  |  ------------------
  ------------------
   90|  2.63M|   return mpi_to_ltc_error(mp_copy(a, b));
   91|  2.63M|}
ltm_desc.c:set_int:
  104|  1.70k|{
  105|  1.70k|   LTC_ARGCHK(a != NULL);
  ------------------
  |  |   32|  1.70k|#define LTC_ARGCHK(x) do { if (!(x)) { crypt_argchk(#x, __FILE__, __LINE__); } }while(0)
  |  |  ------------------
  |  |  |  Branch (32:32): [True: 0, False: 1.70k]
  |  |  |  Branch (32:87): [Folded, False: 1.70k]
  |  |  ------------------
  ------------------
  106|  1.70k|   mp_set_u32(a, b);
  107|  1.70k|   return CRYPT_OK;
  108|  1.70k|}
ltm_desc.c:get_digit:
  117|   876k|{
  118|   876k|   mp_int *A;
  119|   876k|   LTC_ARGCHK(a != NULL);
  ------------------
  |  |   32|   876k|#define LTC_ARGCHK(x) do { if (!(x)) { crypt_argchk(#x, __FILE__, __LINE__); } }while(0)
  |  |  ------------------
  |  |  |  Branch (32:32): [True: 0, False: 876k]
  |  |  |  Branch (32:87): [Folded, False: 876k]
  |  |  ------------------
  ------------------
  120|   876k|   A = a;
  121|   876k|   return (n >= A->used || n < 0) ? 0 : A->dp[n];
  ------------------
  |  Branch (121:12): [True: 0, False: 876k]
  |  Branch (121:28): [True: 0, False: 876k]
  ------------------
  122|   876k|}
ltm_desc.c:get_digit_count:
  125|   870k|{
  126|   870k|   mp_int *A;
  127|   870k|   LTC_ARGCHK(a != NULL);
  ------------------
  |  |   32|   870k|#define LTC_ARGCHK(x) do { if (!(x)) { crypt_argchk(#x, __FILE__, __LINE__); } }while(0)
  |  |  ------------------
  |  |  |  Branch (32:32): [True: 0, False: 870k]
  |  |  |  Branch (32:87): [Folded, False: 870k]
  |  |  ------------------
  ------------------
  128|   870k|   A = a;
  129|   870k|   return A->used;
  130|   870k|}
ltm_desc.c:compare:
  133|  4.34M|{
  134|  4.34M|   LTC_ARGCHK(a != NULL);
  ------------------
  |  |   32|  4.34M|#define LTC_ARGCHK(x) do { if (!(x)) { crypt_argchk(#x, __FILE__, __LINE__); } }while(0)
  |  |  ------------------
  |  |  |  Branch (32:32): [True: 0, False: 4.34M]
  |  |  |  Branch (32:87): [Folded, False: 4.34M]
  |  |  ------------------
  ------------------
  135|  4.34M|   LTC_ARGCHK(b != NULL);
  ------------------
  |  |   32|  4.34M|#define LTC_ARGCHK(x) do { if (!(x)) { crypt_argchk(#x, __FILE__, __LINE__); } }while(0)
  |  |  ------------------
  |  |  |  Branch (32:32): [True: 0, False: 4.34M]
  |  |  |  Branch (32:87): [Folded, False: 4.34M]
  |  |  ------------------
  ------------------
  136|  4.34M|   switch (mp_cmp(a, b)) {
  137|  2.21M|      case MP_LT: return LTC_MP_LT;
  ------------------
  |  |  154|  2.21M|#define MP_LT        -1   /* less than */
  ------------------
                    case MP_LT: return LTC_MP_LT;
  ------------------
  |  |   12|  2.21M|#define LTC_MP_LT   -1
  ------------------
  |  Branch (137:7): [True: 2.21M, False: 2.13M]
  ------------------
  138|      0|      case MP_EQ: return LTC_MP_EQ;
  ------------------
  |  |  155|      0|#define MP_EQ         0   /* equal to */
  ------------------
                    case MP_EQ: return LTC_MP_EQ;
  ------------------
  |  |   13|      0|#define LTC_MP_EQ    0
  ------------------
  |  Branch (138:7): [True: 0, False: 4.34M]
  ------------------
  139|  2.13M|      case MP_GT: return LTC_MP_GT;
  ------------------
  |  |  156|  2.13M|#define MP_GT         1   /* greater than */
  ------------------
                    case MP_GT: return LTC_MP_GT;
  ------------------
  |  |   14|  2.13M|#define LTC_MP_GT    1
  ------------------
  |  Branch (139:7): [True: 2.13M, False: 2.21M]
  ------------------
  140|      0|      default:    return 0;
  ------------------
  |  Branch (140:7): [True: 0, False: 4.34M]
  ------------------
  141|  4.34M|   }
  142|  4.34M|}
ltm_desc.c:compare_d:
  145|  4.77M|{
  146|  4.77M|   LTC_ARGCHK(a != NULL);
  ------------------
  |  |   32|  4.77M|#define LTC_ARGCHK(x) do { if (!(x)) { crypt_argchk(#x, __FILE__, __LINE__); } }while(0)
  |  |  ------------------
  |  |  |  Branch (32:32): [True: 0, False: 4.77M]
  |  |  |  Branch (32:87): [Folded, False: 4.77M]
  |  |  ------------------
  ------------------
  147|  4.77M|   switch (mp_cmp_d(a, b)) {
  148|  2.37M|      case MP_LT: return LTC_MP_LT;
  ------------------
  |  |  154|  2.37M|#define MP_LT        -1   /* less than */
  ------------------
                    case MP_LT: return LTC_MP_LT;
  ------------------
  |  |   12|  2.37M|#define LTC_MP_LT   -1
  ------------------
  |  Branch (148:7): [True: 2.37M, False: 2.39M]
  ------------------
  149|      3|      case MP_EQ: return LTC_MP_EQ;
  ------------------
  |  |  155|      3|#define MP_EQ         0   /* equal to */
  ------------------
                    case MP_EQ: return LTC_MP_EQ;
  ------------------
  |  |   13|      3|#define LTC_MP_EQ    0
  ------------------
  |  Branch (149:7): [True: 3, False: 4.77M]
  ------------------
  150|  2.39M|      case MP_GT: return LTC_MP_GT;
  ------------------
  |  |  156|  2.39M|#define MP_GT         1   /* greater than */
  ------------------
                    case MP_GT: return LTC_MP_GT;
  ------------------
  |  |   14|  2.39M|#define LTC_MP_GT    1
  ------------------
  |  Branch (150:7): [True: 2.39M, False: 2.37M]
  ------------------
  151|      0|      default:    return 0;
  ------------------
  |  Branch (151:7): [True: 0, False: 4.77M]
  ------------------
  152|  4.77M|   }
  153|  4.77M|}
ltm_desc.c:read_radix:
  178|  3.25k|{
  179|  3.25k|   LTC_ARGCHK(a != NULL);
  ------------------
  |  |   32|  3.25k|#define LTC_ARGCHK(x) do { if (!(x)) { crypt_argchk(#x, __FILE__, __LINE__); } }while(0)
  |  |  ------------------
  |  |  |  Branch (32:32): [True: 0, False: 3.25k]
  |  |  |  Branch (32:87): [Folded, False: 3.25k]
  |  |  ------------------
  ------------------
  180|  3.25k|   LTC_ARGCHK(b != NULL);
  ------------------
  |  |   32|  3.25k|#define LTC_ARGCHK(x) do { if (!(x)) { crypt_argchk(#x, __FILE__, __LINE__); } }while(0)
  |  |  ------------------
  |  |  |  Branch (32:32): [True: 0, False: 3.25k]
  |  |  |  Branch (32:87): [Folded, False: 3.25k]
  |  |  ------------------
  ------------------
  181|  3.25k|   return mpi_to_ltc_error(mp_read_radix(a, b, radix));
  182|  3.25k|}
ltm_desc.c:unsigned_size:
  194|  2.12k|{
  195|  2.12k|   LTC_ARGCHK(a != NULL);
  ------------------
  |  |   32|  2.12k|#define LTC_ARGCHK(x) do { if (!(x)) { crypt_argchk(#x, __FILE__, __LINE__); } }while(0)
  |  |  ------------------
  |  |  |  Branch (32:32): [True: 0, False: 2.12k]
  |  |  |  Branch (32:87): [Folded, False: 2.12k]
  |  |  ------------------
  ------------------
  196|  2.12k|   return (unsigned long)mp_ubin_size(a);
  197|  2.12k|}
ltm_desc.c:unsigned_write:
  201|  2.12k|{
  202|  2.12k|   LTC_ARGCHK(a != NULL);
  ------------------
  |  |   32|  2.12k|#define LTC_ARGCHK(x) do { if (!(x)) { crypt_argchk(#x, __FILE__, __LINE__); } }while(0)
  |  |  ------------------
  |  |  |  Branch (32:32): [True: 0, False: 2.12k]
  |  |  |  Branch (32:87): [Folded, False: 2.12k]
  |  |  ------------------
  ------------------
  203|  2.12k|   LTC_ARGCHK(b != NULL);
  ------------------
  |  |   32|  2.12k|#define LTC_ARGCHK(x) do { if (!(x)) { crypt_argchk(#x, __FILE__, __LINE__); } }while(0)
  |  |  ------------------
  |  |  |  Branch (32:32): [True: 0, False: 2.12k]
  |  |  |  Branch (32:87): [Folded, False: 2.12k]
  |  |  ------------------
  ------------------
  204|  2.12k|   return mpi_to_ltc_error(mp_to_ubin(a, b, SIZE_MAX, NULL));
  205|  2.12k|}
ltm_desc.c:unsigned_read:
  209|    817|{
  210|    817|   LTC_ARGCHK(a != NULL);
  ------------------
  |  |   32|    817|#define LTC_ARGCHK(x) do { if (!(x)) { crypt_argchk(#x, __FILE__, __LINE__); } }while(0)
  |  |  ------------------
  |  |  |  Branch (32:32): [True: 0, False: 817]
  |  |  |  Branch (32:87): [Folded, False: 817]
  |  |  ------------------
  ------------------
  211|    817|   LTC_ARGCHK(b != NULL);
  ------------------
  |  |   32|    817|#define LTC_ARGCHK(x) do { if (!(x)) { crypt_argchk(#x, __FILE__, __LINE__); } }while(0)
  |  |  ------------------
  |  |  |  Branch (32:32): [True: 0, False: 817]
  |  |  |  Branch (32:87): [Folded, False: 817]
  |  |  ------------------
  ------------------
  212|    817|   return mpi_to_ltc_error(mp_from_ubin(a, b, (size_t)len));
  213|    817|}
ltm_desc.c:add:
  217|  6.71M|{
  218|  6.71M|   LTC_ARGCHK(a != NULL);
  ------------------
  |  |   32|  6.71M|#define LTC_ARGCHK(x) do { if (!(x)) { crypt_argchk(#x, __FILE__, __LINE__); } }while(0)
  |  |  ------------------
  |  |  |  Branch (32:32): [True: 0, False: 6.71M]
  |  |  |  Branch (32:87): [Folded, False: 6.71M]
  |  |  ------------------
  ------------------
  219|  6.71M|   LTC_ARGCHK(b != NULL);
  ------------------
  |  |   32|  6.71M|#define LTC_ARGCHK(x) do { if (!(x)) { crypt_argchk(#x, __FILE__, __LINE__); } }while(0)
  |  |  ------------------
  |  |  |  Branch (32:32): [True: 0, False: 6.71M]
  |  |  |  Branch (32:87): [Folded, False: 6.71M]
  |  |  ------------------
  ------------------
  220|  6.71M|   LTC_ARGCHK(c != NULL);
  ------------------
  |  |   32|  6.71M|#define LTC_ARGCHK(x) do { if (!(x)) { crypt_argchk(#x, __FILE__, __LINE__); } }while(0)
  |  |  ------------------
  |  |  |  Branch (32:32): [True: 0, False: 6.71M]
  |  |  |  Branch (32:87): [Folded, False: 6.71M]
  |  |  ------------------
  ------------------
  221|  6.71M|   return mpi_to_ltc_error(mp_add(a, b, c));
  222|  6.71M|}
ltm_desc.c:sub:
  233|  7.12M|{
  234|  7.12M|   LTC_ARGCHK(a != NULL);
  ------------------
  |  |   32|  7.12M|#define LTC_ARGCHK(x) do { if (!(x)) { crypt_argchk(#x, __FILE__, __LINE__); } }while(0)
  |  |  ------------------
  |  |  |  Branch (32:32): [True: 0, False: 7.12M]
  |  |  |  Branch (32:87): [Folded, False: 7.12M]
  |  |  ------------------
  ------------------
  235|  7.12M|   LTC_ARGCHK(b != NULL);
  ------------------
  |  |   32|  7.12M|#define LTC_ARGCHK(x) do { if (!(x)) { crypt_argchk(#x, __FILE__, __LINE__); } }while(0)
  |  |  ------------------
  |  |  |  Branch (32:32): [True: 0, False: 7.12M]
  |  |  |  Branch (32:87): [Folded, False: 7.12M]
  |  |  ------------------
  ------------------
  236|  7.12M|   LTC_ARGCHK(c != NULL);
  ------------------
  |  |   32|  7.12M|#define LTC_ARGCHK(x) do { if (!(x)) { crypt_argchk(#x, __FILE__, __LINE__); } }while(0)
  |  |  ------------------
  |  |  |  Branch (32:32): [True: 0, False: 7.12M]
  |  |  |  Branch (32:87): [Folded, False: 7.12M]
  |  |  ------------------
  ------------------
  237|  7.12M|   return mpi_to_ltc_error(mp_sub(a, b, c));
  238|  7.12M|}
ltm_desc.c:mul:
  249|  6.89M|{
  250|  6.89M|   LTC_ARGCHK(a != NULL);
  ------------------
  |  |   32|  6.89M|#define LTC_ARGCHK(x) do { if (!(x)) { crypt_argchk(#x, __FILE__, __LINE__); } }while(0)
  |  |  ------------------
  |  |  |  Branch (32:32): [True: 0, False: 6.89M]
  |  |  |  Branch (32:87): [Folded, False: 6.89M]
  |  |  ------------------
  ------------------
  251|  6.89M|   LTC_ARGCHK(b != NULL);
  ------------------
  |  |   32|  6.89M|#define LTC_ARGCHK(x) do { if (!(x)) { crypt_argchk(#x, __FILE__, __LINE__); } }while(0)
  |  |  ------------------
  |  |  |  Branch (32:32): [True: 0, False: 6.89M]
  |  |  |  Branch (32:87): [Folded, False: 6.89M]
  |  |  ------------------
  ------------------
  252|  6.89M|   LTC_ARGCHK(c != NULL);
  ------------------
  |  |   32|  6.89M|#define LTC_ARGCHK(x) do { if (!(x)) { crypt_argchk(#x, __FILE__, __LINE__); } }while(0)
  |  |  ------------------
  |  |  |  Branch (32:32): [True: 0, False: 6.89M]
  |  |  |  Branch (32:87): [Folded, False: 6.89M]
  |  |  ------------------
  ------------------
  253|  6.89M|   return mpi_to_ltc_error(mp_mul(a, b, c));
  254|  6.89M|}
ltm_desc.c:sqr:
  265|  3.47M|{
  266|  3.47M|   LTC_ARGCHK(a != NULL);
  ------------------
  |  |   32|  3.47M|#define LTC_ARGCHK(x) do { if (!(x)) { crypt_argchk(#x, __FILE__, __LINE__); } }while(0)
  |  |  ------------------
  |  |  |  Branch (32:32): [True: 0, False: 3.47M]
  |  |  |  Branch (32:87): [Folded, False: 3.47M]
  |  |  ------------------
  ------------------
  267|  3.47M|   LTC_ARGCHK(b != NULL);
  ------------------
  |  |   32|  3.47M|#define LTC_ARGCHK(x) do { if (!(x)) { crypt_argchk(#x, __FILE__, __LINE__); } }while(0)
  |  |  ------------------
  |  |  |  Branch (32:32): [True: 0, False: 3.47M]
  |  |  |  Branch (32:87): [Folded, False: 3.47M]
  |  |  ------------------
  ------------------
  268|  3.47M|   return mpi_to_ltc_error(mp_sqr(a, b));
  269|  3.47M|}
ltm_desc.c:divide:
  273|  2.40k|{
  274|  2.40k|   LTC_ARGCHK(a != NULL);
  ------------------
  |  |   32|  2.40k|#define LTC_ARGCHK(x) do { if (!(x)) { crypt_argchk(#x, __FILE__, __LINE__); } }while(0)
  |  |  ------------------
  |  |  |  Branch (32:32): [True: 0, False: 2.40k]
  |  |  |  Branch (32:87): [Folded, False: 2.40k]
  |  |  ------------------
  ------------------
  275|  2.40k|   LTC_ARGCHK(b != NULL);
  ------------------
  |  |   32|  2.40k|#define LTC_ARGCHK(x) do { if (!(x)) { crypt_argchk(#x, __FILE__, __LINE__); } }while(0)
  |  |  ------------------
  |  |  |  Branch (32:32): [True: 0, False: 2.40k]
  |  |  |  Branch (32:87): [Folded, False: 2.40k]
  |  |  ------------------
  ------------------
  276|  2.40k|   return mpi_to_ltc_error(mp_div(a, b, c, d));
  277|  2.40k|}
ltm_desc.c:div_2:
  280|   869k|{
  281|   869k|   LTC_ARGCHK(a != NULL);
  ------------------
  |  |   32|   869k|#define LTC_ARGCHK(x) do { if (!(x)) { crypt_argchk(#x, __FILE__, __LINE__); } }while(0)
  |  |  ------------------
  |  |  |  Branch (32:32): [True: 0, False: 869k]
  |  |  |  Branch (32:87): [Folded, False: 869k]
  |  |  ------------------
  ------------------
  282|   869k|   LTC_ARGCHK(b != NULL);
  ------------------
  |  |   32|   869k|#define LTC_ARGCHK(x) do { if (!(x)) { crypt_argchk(#x, __FILE__, __LINE__); } }while(0)
  |  |  ------------------
  |  |  |  Branch (32:32): [True: 0, False: 869k]
  |  |  |  Branch (32:87): [Folded, False: 869k]
  |  |  ------------------
  ------------------
  283|   869k|   return mpi_to_ltc_error(mp_div_2(a, b));
  284|   869k|}
ltm_desc.c:mulmod:
  339|  2.92k|{
  340|  2.92k|   LTC_ARGCHK(a != NULL);
  ------------------
  |  |   32|  2.92k|#define LTC_ARGCHK(x) do { if (!(x)) { crypt_argchk(#x, __FILE__, __LINE__); } }while(0)
  |  |  ------------------
  |  |  |  Branch (32:32): [True: 0, False: 2.92k]
  |  |  |  Branch (32:87): [Folded, False: 2.92k]
  |  |  ------------------
  ------------------
  341|  2.92k|   LTC_ARGCHK(b != NULL);
  ------------------
  |  |   32|  2.92k|#define LTC_ARGCHK(x) do { if (!(x)) { crypt_argchk(#x, __FILE__, __LINE__); } }while(0)
  |  |  ------------------
  |  |  |  Branch (32:32): [True: 0, False: 2.92k]
  |  |  |  Branch (32:87): [Folded, False: 2.92k]
  |  |  ------------------
  ------------------
  342|  2.92k|   LTC_ARGCHK(c != NULL);
  ------------------
  |  |   32|  2.92k|#define LTC_ARGCHK(x) do { if (!(x)) { crypt_argchk(#x, __FILE__, __LINE__); } }while(0)
  |  |  ------------------
  |  |  |  Branch (32:32): [True: 0, False: 2.92k]
  |  |  |  Branch (32:87): [Folded, False: 2.92k]
  |  |  ------------------
  ------------------
  343|  2.92k|   LTC_ARGCHK(d != NULL);
  ------------------
  |  |   32|  2.92k|#define LTC_ARGCHK(x) do { if (!(x)) { crypt_argchk(#x, __FILE__, __LINE__); } }while(0)
  |  |  ------------------
  |  |  |  Branch (32:32): [True: 0, False: 2.92k]
  |  |  |  Branch (32:87): [Folded, False: 2.92k]
  |  |  ------------------
  ------------------
  344|  2.92k|   return mpi_to_ltc_error(mp_mulmod(a,b,c,d));
  345|  2.92k|}
ltm_desc.c:invmod:
  357|    940|{
  358|    940|   LTC_ARGCHK(a != NULL);
  ------------------
  |  |   32|    940|#define LTC_ARGCHK(x) do { if (!(x)) { crypt_argchk(#x, __FILE__, __LINE__); } }while(0)
  |  |  ------------------
  |  |  |  Branch (32:32): [True: 0, False: 940]
  |  |  |  Branch (32:87): [Folded, False: 940]
  |  |  ------------------
  ------------------
  359|    940|   LTC_ARGCHK(b != NULL);
  ------------------
  |  |   32|    940|#define LTC_ARGCHK(x) do { if (!(x)) { crypt_argchk(#x, __FILE__, __LINE__); } }while(0)
  |  |  ------------------
  |  |  |  Branch (32:32): [True: 0, False: 940]
  |  |  |  Branch (32:87): [Folded, False: 940]
  |  |  ------------------
  ------------------
  360|    940|   LTC_ARGCHK(c != NULL);
  ------------------
  |  |   32|    940|#define LTC_ARGCHK(x) do { if (!(x)) { crypt_argchk(#x, __FILE__, __LINE__); } }while(0)
  |  |  ------------------
  |  |  |  Branch (32:32): [True: 0, False: 940]
  |  |  |  Branch (32:87): [Folded, False: 940]
  |  |  ------------------
  ------------------
  361|    940|   return mpi_to_ltc_error(mp_invmod(a, b, c));
  362|    940|}
ltm_desc.c:montgomery_setup:
  366|    890|{
  367|    890|   int err;
  368|    890|   LTC_ARGCHK(a != NULL);
  ------------------
  |  |   32|    890|#define LTC_ARGCHK(x) do { if (!(x)) { crypt_argchk(#x, __FILE__, __LINE__); } }while(0)
  |  |  ------------------
  |  |  |  Branch (32:32): [True: 0, False: 890]
  |  |  |  Branch (32:87): [Folded, False: 890]
  |  |  ------------------
  ------------------
  369|    890|   LTC_ARGCHK(b != NULL);
  ------------------
  |  |   32|    890|#define LTC_ARGCHK(x) do { if (!(x)) { crypt_argchk(#x, __FILE__, __LINE__); } }while(0)
  |  |  ------------------
  |  |  |  Branch (32:32): [True: 0, False: 890]
  |  |  |  Branch (32:87): [Folded, False: 890]
  |  |  ------------------
  ------------------
  370|    890|   *b = XCALLOC(1, sizeof(mp_digit));
  ------------------
  |  |   19|    890|#define XCALLOC m_calloc
  ------------------
  371|    890|   if (*b == NULL) {
  ------------------
  |  Branch (371:8): [True: 0, False: 890]
  ------------------
  372|      0|      return CRYPT_MEM;
  373|      0|   }
  374|    890|   if ((err = mpi_to_ltc_error(mp_montgomery_setup(a, (mp_digit *)*b))) != CRYPT_OK) {
  ------------------
  |  Branch (374:8): [True: 0, False: 890]
  ------------------
  375|      0|      XFREE(*b);
  ------------------
  |  |   17|      0|#define XFREE m_free_direct
  ------------------
  376|      0|   }
  377|    890|   return err;
  378|    890|}
ltm_desc.c:montgomery_normalization:
  382|    890|{
  383|    890|   LTC_ARGCHK(a != NULL);
  ------------------
  |  |   32|    890|#define LTC_ARGCHK(x) do { if (!(x)) { crypt_argchk(#x, __FILE__, __LINE__); } }while(0)
  |  |  ------------------
  |  |  |  Branch (32:32): [True: 0, False: 890]
  |  |  |  Branch (32:87): [Folded, False: 890]
  |  |  ------------------
  ------------------
  384|    890|   LTC_ARGCHK(b != NULL);
  ------------------
  |  |   32|    890|#define LTC_ARGCHK(x) do { if (!(x)) { crypt_argchk(#x, __FILE__, __LINE__); } }while(0)
  |  |  ------------------
  |  |  |  Branch (32:32): [True: 0, False: 890]
  |  |  |  Branch (32:87): [Folded, False: 890]
  |  |  ------------------
  ------------------
  385|    890|   return mpi_to_ltc_error(mp_montgomery_calc_normalization(a, b));
  386|    890|}
ltm_desc.c:montgomery_reduce:
  390|  10.3M|{
  391|  10.3M|   LTC_ARGCHK(a != NULL);
  ------------------
  |  |   32|  10.3M|#define LTC_ARGCHK(x) do { if (!(x)) { crypt_argchk(#x, __FILE__, __LINE__); } }while(0)
  |  |  ------------------
  |  |  |  Branch (32:32): [True: 0, False: 10.3M]
  |  |  |  Branch (32:87): [Folded, False: 10.3M]
  |  |  ------------------
  ------------------
  392|  10.3M|   LTC_ARGCHK(b != NULL);
  ------------------
  |  |   32|  10.3M|#define LTC_ARGCHK(x) do { if (!(x)) { crypt_argchk(#x, __FILE__, __LINE__); } }while(0)
  |  |  ------------------
  |  |  |  Branch (32:32): [True: 0, False: 10.3M]
  |  |  |  Branch (32:87): [Folded, False: 10.3M]
  |  |  ------------------
  ------------------
  393|  10.3M|   LTC_ARGCHK(c != NULL);
  ------------------
  |  |   32|  10.3M|#define LTC_ARGCHK(x) do { if (!(x)) { crypt_argchk(#x, __FILE__, __LINE__); } }while(0)
  |  |  ------------------
  |  |  |  Branch (32:32): [True: 0, False: 10.3M]
  |  |  |  Branch (32:87): [Folded, False: 10.3M]
  |  |  ------------------
  ------------------
  394|  10.3M|   return mpi_to_ltc_error(mp_montgomery_reduce(a, b, *((mp_digit *)c)));
  395|  10.3M|}
ltm_desc.c:montgomery_deinit:
  399|    890|{
  400|    890|   XFREE(a);
  ------------------
  |  |   17|    890|#define XFREE m_free_direct
  ------------------
  401|    890|}

ltc_init_multi:
   15|   876k|{
   16|   876k|   void    **cur = a;
   17|   876k|   int       np  = 0;
   18|   876k|   va_list   args;
   19|       |
   20|   876k|   va_start(args, a);
   21|  3.91M|   while (cur != NULL) {
  ------------------
  |  Branch (21:11): [True: 3.04M, False: 876k]
  ------------------
   22|  3.04M|       if (mp_init(cur) != CRYPT_OK) {
  ------------------
  |  |  516|  3.04M|#define mp_init(a)                   ltc_mp.init(a)
  ------------------
  |  Branch (22:12): [True: 0, False: 3.04M]
  ------------------
   23|       |          /* failed */
   24|      0|          va_list clean_list;
   25|       |
   26|      0|          va_start(clean_list, a);
   27|      0|          cur = a;
   28|      0|          while (np--) {
  ------------------
  |  Branch (28:18): [True: 0, False: 0]
  ------------------
   29|      0|              mp_clear(*cur);
  ------------------
  |  |  518|      0|#define mp_clear(a)                  ltc_mp.deinit(a)
  ------------------
   30|      0|              cur = va_arg(clean_list, void**);
   31|      0|          }
   32|      0|          va_end(clean_list);
   33|      0|          va_end(args);
   34|      0|          return CRYPT_MEM;
   35|      0|       }
   36|  3.04M|       ++np;
   37|  3.04M|       cur = va_arg(args, void**);
   38|  3.04M|   }
   39|   876k|   va_end(args);
   40|   876k|   return CRYPT_OK;
   41|   876k|}
ltc_deinit_multi:
   44|   876k|{
   45|   876k|   void     *cur = a;
   46|   876k|   va_list   args;
   47|       |
   48|   876k|   va_start(args, a);
   49|  3.91M|   while (cur != NULL) {
  ------------------
  |  Branch (49:11): [True: 3.04M, False: 876k]
  ------------------
   50|  3.04M|       mp_clear(cur);
  ------------------
  |  |  518|  3.04M|#define mp_clear(a)                  ltc_mp.deinit(a)
  ------------------
   51|  3.04M|       cur = va_arg(args, void *);
   52|  3.04M|   }
   53|       |   va_end(args);
   54|   876k|}

prng_is_valid:
   22|    762|{
   23|    762|   LTC_MUTEX_LOCK(&ltc_prng_mutex);
   24|    762|   if (idx < 0 || idx >= TAB_SIZE || prng_descriptor[idx].name == NULL) {
  ------------------
  |  |   14|  1.52k|#define TAB_SIZE      5
  ------------------
  |  Branch (24:8): [True: 0, False: 762]
  |  Branch (24:19): [True: 0, False: 762]
  |  Branch (24:38): [True: 0, False: 762]
  ------------------
   25|      0|      LTC_MUTEX_UNLOCK(&ltc_prng_mutex);
   26|      0|      return CRYPT_INVALID_PRNG;
   27|      0|   }
   28|    762|   LTC_MUTEX_UNLOCK(&ltc_prng_mutex);
   29|    762|   return CRYPT_OK;
   30|    762|}

register_cipher:
   22|      1|{
   23|      1|   int x;
   24|       |
   25|      1|   LTC_ARGCHK(cipher != NULL);
  ------------------
  |  |   32|      1|#define LTC_ARGCHK(x) do { if (!(x)) { crypt_argchk(#x, __FILE__, __LINE__); } }while(0)
  |  |  ------------------
  |  |  |  Branch (32:32): [True: 0, False: 1]
  |  |  |  Branch (32:87): [Folded, False: 1]
  |  |  ------------------
  ------------------
   26|       |
   27|       |   /* is it already registered? */
   28|      1|   LTC_MUTEX_LOCK(&ltc_cipher_mutex);
   29|      6|   for (x = 0; x < TAB_SIZE; x++) {
  ------------------
  |  |   14|      6|#define TAB_SIZE      5
  ------------------
  |  Branch (29:16): [True: 5, False: 1]
  ------------------
   30|      5|       if (cipher_descriptor[x].name != NULL && cipher_descriptor[x].ID == cipher->ID) {
  ------------------
  |  Branch (30:12): [True: 0, False: 5]
  |  Branch (30:49): [True: 0, False: 0]
  ------------------
   31|      0|          LTC_MUTEX_UNLOCK(&ltc_cipher_mutex);
   32|      0|          return x;
   33|      0|       }
   34|      5|   }
   35|       |
   36|       |   /* find a blank spot */
   37|      1|   for (x = 0; x < TAB_SIZE; x++) {
  ------------------
  |  |   14|      1|#define TAB_SIZE      5
  ------------------
  |  Branch (37:16): [True: 1, False: 0]
  ------------------
   38|      1|       if (cipher_descriptor[x].name == NULL) {
  ------------------
  |  Branch (38:12): [True: 1, False: 0]
  ------------------
   39|      1|          XMEMCPY(&cipher_descriptor[x], cipher, sizeof(struct ltc_cipher_descriptor));
  ------------------
  |  |   39|      1|#define XMEMCPY  memcpy
  ------------------
   40|      1|          LTC_MUTEX_UNLOCK(&ltc_cipher_mutex);
   41|      1|          return x;
   42|      1|       }
   43|      1|   }
   44|       |
   45|       |   /* no spot */
   46|      0|   LTC_MUTEX_UNLOCK(&ltc_cipher_mutex);
   47|      0|   return -1;
   48|      1|}

register_hash:
   22|      3|{
   23|      3|   int x;
   24|       |
   25|      3|   LTC_ARGCHK(hash != NULL);
  ------------------
  |  |   32|      3|#define LTC_ARGCHK(x) do { if (!(x)) { crypt_argchk(#x, __FILE__, __LINE__); } }while(0)
  |  |  ------------------
  |  |  |  Branch (32:32): [True: 0, False: 3]
  |  |  |  Branch (32:87): [Folded, False: 3]
  |  |  ------------------
  ------------------
   26|       |
   27|       |   /* is it already registered? */
   28|      3|   LTC_MUTEX_LOCK(&ltc_hash_mutex);
   29|     18|   for (x = 0; x < TAB_SIZE; x++) {
  ------------------
  |  |   14|     18|#define TAB_SIZE      5
  ------------------
  |  Branch (29:16): [True: 15, False: 3]
  ------------------
   30|     15|       if (XMEMCMP(&hash_descriptor[x], hash, sizeof(struct ltc_hash_descriptor)) == 0) {
  ------------------
  |  |   45|     15|#define XMEMCMP  memcmp
  ------------------
  |  Branch (30:12): [True: 0, False: 15]
  ------------------
   31|      0|          LTC_MUTEX_UNLOCK(&ltc_hash_mutex);
   32|      0|          return x;
   33|      0|       }
   34|     15|   }
   35|       |
   36|       |   /* find a blank spot */
   37|      6|   for (x = 0; x < TAB_SIZE; x++) {
  ------------------
  |  |   14|      6|#define TAB_SIZE      5
  ------------------
  |  Branch (37:16): [True: 6, False: 0]
  ------------------
   38|      6|       if (hash_descriptor[x].name == NULL) {
  ------------------
  |  Branch (38:12): [True: 3, False: 3]
  ------------------
   39|      3|          XMEMCPY(&hash_descriptor[x], hash, sizeof(struct ltc_hash_descriptor));
  ------------------
  |  |   39|      3|#define XMEMCPY  memcpy
  ------------------
   40|      3|          LTC_MUTEX_UNLOCK(&ltc_hash_mutex);
   41|      3|          return x;
   42|      3|       }
   43|      6|   }
   44|       |
   45|       |   /* no spot */
   46|      0|   LTC_MUTEX_UNLOCK(&ltc_hash_mutex);
   47|      0|   return -1;
   48|      3|}

register_prng:
   22|      1|{
   23|      1|   int x;
   24|       |
   25|      1|   LTC_ARGCHK(prng != NULL);
  ------------------
  |  |   32|      1|#define LTC_ARGCHK(x) do { if (!(x)) { crypt_argchk(#x, __FILE__, __LINE__); } }while(0)
  |  |  ------------------
  |  |  |  Branch (32:32): [True: 0, False: 1]
  |  |  |  Branch (32:87): [Folded, False: 1]
  |  |  ------------------
  ------------------
   26|       |
   27|       |   /* is it already registered? */
   28|      1|   LTC_MUTEX_LOCK(&ltc_prng_mutex);
   29|      6|   for (x = 0; x < TAB_SIZE; x++) {
  ------------------
  |  |   14|      6|#define TAB_SIZE      5
  ------------------
  |  Branch (29:16): [True: 5, False: 1]
  ------------------
   30|      5|       if (XMEMCMP(&prng_descriptor[x], prng, sizeof(struct ltc_prng_descriptor)) == 0) {
  ------------------
  |  |   45|      5|#define XMEMCMP  memcmp
  ------------------
  |  Branch (30:12): [True: 0, False: 5]
  ------------------
   31|      0|          LTC_MUTEX_UNLOCK(&ltc_prng_mutex);
   32|      0|          return x;
   33|      0|       }
   34|      5|   }
   35|       |
   36|       |   /* find a blank spot */
   37|      1|   for (x = 0; x < TAB_SIZE; x++) {
  ------------------
  |  |   14|      1|#define TAB_SIZE      5
  ------------------
  |  Branch (37:16): [True: 1, False: 0]
  ------------------
   38|      1|       if (prng_descriptor[x].name == NULL) {
  ------------------
  |  Branch (38:12): [True: 1, False: 0]
  ------------------
   39|      1|          XMEMCPY(&prng_descriptor[x], prng, sizeof(struct ltc_prng_descriptor));
  ------------------
  |  |   39|      1|#define XMEMCPY  memcpy
  ------------------
   40|      1|          LTC_MUTEX_UNLOCK(&ltc_prng_mutex);
   41|      1|          return x;
   42|      1|       }
   43|      1|   }
   44|       |
   45|       |   /* no spot */
   46|      0|   LTC_MUTEX_UNLOCK(&ltc_prng_mutex);
   47|      0|   return -1;
   48|      1|}

zeromem:
   23|  2.02k|{
   24|  2.02k|   m_burn((void*)out, outlen);
   25|  2.02k|}

ecc_ansi_x963_export:
   31|  1.01k|{
   32|  1.01k|   unsigned char buf[ECC_BUF_SIZE];
   33|  1.01k|   unsigned long numlen, xlen, ylen;
   34|       |
   35|  1.01k|   LTC_ARGCHK(key    != NULL);
  ------------------
  |  |   32|  1.01k|#define LTC_ARGCHK(x) do { if (!(x)) { crypt_argchk(#x, __FILE__, __LINE__); } }while(0)
  |  |  ------------------
  |  |  |  Branch (32:32): [True: 0, False: 1.01k]
  |  |  |  Branch (32:87): [Folded, False: 1.01k]
  |  |  ------------------
  ------------------
   36|  1.01k|   LTC_ARGCHK(outlen != NULL);
  ------------------
  |  |   32|  1.01k|#define LTC_ARGCHK(x) do { if (!(x)) { crypt_argchk(#x, __FILE__, __LINE__); } }while(0)
  |  |  ------------------
  |  |  |  Branch (32:32): [True: 0, False: 1.01k]
  |  |  |  Branch (32:87): [Folded, False: 1.01k]
  |  |  ------------------
  ------------------
   37|       |
   38|  1.01k|   if (ltc_ecc_is_valid_idx(key->idx) == 0) {
  ------------------
  |  Branch (38:8): [True: 0, False: 1.01k]
  ------------------
   39|      0|      return CRYPT_INVALID_ARG;
   40|      0|   }
   41|  1.01k|   numlen = key->dp->size;
   42|  1.01k|   xlen = mp_unsigned_bin_size(key->pubkey.x);
  ------------------
  |  |  539|  1.01k|#define mp_unsigned_bin_size(a)      ltc_mp.unsigned_size(a)
  ------------------
   43|  1.01k|   ylen = mp_unsigned_bin_size(key->pubkey.y);
  ------------------
  |  |  539|  1.01k|#define mp_unsigned_bin_size(a)      ltc_mp.unsigned_size(a)
  ------------------
   44|       |
   45|  1.01k|   if (xlen > numlen || ylen > numlen || sizeof(buf) < numlen) {
  ------------------
  |  Branch (45:8): [True: 0, False: 1.01k]
  |  Branch (45:25): [True: 0, False: 1.01k]
  |  Branch (45:42): [True: 0, False: 1.01k]
  ------------------
   46|      0|      return CRYPT_BUFFER_OVERFLOW;
   47|      0|   }
   48|       |
   49|  1.01k|   if (*outlen < (1 + 2*numlen)) {
  ------------------
  |  Branch (49:8): [True: 0, False: 1.01k]
  ------------------
   50|      0|      *outlen = 1 + 2*numlen;
   51|      0|      return CRYPT_BUFFER_OVERFLOW;
   52|      0|   }
   53|       |
   54|  1.01k|   LTC_ARGCHK(out    != NULL);
  ------------------
  |  |   32|  1.01k|#define LTC_ARGCHK(x) do { if (!(x)) { crypt_argchk(#x, __FILE__, __LINE__); } }while(0)
  |  |  ------------------
  |  |  |  Branch (32:32): [True: 0, False: 1.01k]
  |  |  |  Branch (32:87): [Folded, False: 1.01k]
  |  |  ------------------
  ------------------
   55|       |
   56|       |   /* store byte 0x04 */
   57|  1.01k|   out[0] = 0x04;
   58|       |
   59|       |   /* pad and store x */
   60|  1.01k|   zeromem(buf, sizeof(buf));
   61|  1.01k|   mp_to_unsigned_bin(key->pubkey.x, buf + (numlen - xlen));
  ------------------
  |  |  540|  1.01k|#define mp_to_unsigned_bin(a, b)     ltc_mp.unsigned_write(a, b)
  ------------------
   62|  1.01k|   XMEMCPY(out+1, buf, numlen);
  ------------------
  |  |   39|  1.01k|#define XMEMCPY  memcpy
  ------------------
   63|       |
   64|       |   /* pad and store y */
   65|  1.01k|   zeromem(buf, sizeof(buf));
   66|  1.01k|   mp_to_unsigned_bin(key->pubkey.y, buf + (numlen - ylen));
  ------------------
  |  |  540|  1.01k|#define mp_to_unsigned_bin(a, b)     ltc_mp.unsigned_write(a, b)
  ------------------
   67|  1.01k|   XMEMCPY(out+1+numlen, buf, numlen);
  ------------------
  |  |   39|  1.01k|#define XMEMCPY  memcpy
  ------------------
   68|       |
   69|  1.01k|   *outlen = 1 + 2*numlen;
   70|  1.01k|   return CRYPT_OK;
   71|  1.01k|}

ecc_free:
   29|    168|{
   30|    168|   LTC_ARGCHKVD(key != NULL);
  ------------------
  |  |   33|    168|#define LTC_ARGCHKVD(x) do { if (!(x)) { crypt_argchk(#x, __FILE__, __LINE__); } }while(0)
  |  |  ------------------
  |  |  |  Branch (33:34): [True: 0, False: 168]
  |  |  |  Branch (33:89): [Folded, False: 168]
  |  |  ------------------
  ------------------
   31|    168|   mp_clear_multi(key->pubkey.x, key->pubkey.y, key->pubkey.z, key->k, NULL);
  ------------------
  |  |  519|    168|#define mp_clear_multi               ltc_deinit_multi
  ------------------
   32|    168|}

ecc_make_key_ex:
   49|    762|{
   50|    762|   int            err;
   51|    762|   ecc_point     *base;
   52|    762|   void          *prime, *order;
   53|    762|   unsigned char *buf;
   54|    762|   int            keysize;
   55|       |
   56|    762|   LTC_ARGCHK(key         != NULL);
  ------------------
  |  |   32|    762|#define LTC_ARGCHK(x) do { if (!(x)) { crypt_argchk(#x, __FILE__, __LINE__); } }while(0)
  |  |  ------------------
  |  |  |  Branch (32:32): [True: 0, False: 762]
  |  |  |  Branch (32:87): [Folded, False: 762]
  |  |  ------------------
  ------------------
   57|    762|   LTC_ARGCHK(ltc_mp.name != NULL);
  ------------------
  |  |   32|    762|#define LTC_ARGCHK(x) do { if (!(x)) { crypt_argchk(#x, __FILE__, __LINE__); } }while(0)
  |  |  ------------------
  |  |  |  Branch (32:32): [True: 0, False: 762]
  |  |  |  Branch (32:87): [Folded, False: 762]
  |  |  ------------------
  ------------------
   58|    762|   LTC_ARGCHK(dp          != NULL);
  ------------------
  |  |   32|    762|#define LTC_ARGCHK(x) do { if (!(x)) { crypt_argchk(#x, __FILE__, __LINE__); } }while(0)
  |  |  ------------------
  |  |  |  Branch (32:32): [True: 0, False: 762]
  |  |  |  Branch (32:87): [Folded, False: 762]
  |  |  ------------------
  ------------------
   59|       |
   60|       |   /* good prng? */
   61|    762|   if ((err = prng_is_valid(wprng)) != CRYPT_OK) {
  ------------------
  |  Branch (61:8): [True: 0, False: 762]
  ------------------
   62|      0|      return err;
   63|      0|   }
   64|       |
   65|    762|   key->idx = -1;
   66|    762|   key->dp  = dp;
   67|    762|   keysize  = dp->size;
   68|       |
   69|       |   /* allocate ram */
   70|    762|   base = NULL;
   71|    762|   buf  = XMALLOC(ECC_MAXSIZE);
  ------------------
  |  |   16|    762|#define XMALLOC m_malloc
  ------------------
                 buf  = XMALLOC(ECC_MAXSIZE);
  ------------------
  |  |  249|    762|#define ECC_MAXSIZE  66
  ------------------
   72|    762|   if (buf == NULL) {
  ------------------
  |  Branch (72:8): [True: 0, False: 762]
  ------------------
   73|      0|      return CRYPT_MEM;
   74|      0|   }
   75|       |
   76|       |   /* make up random string */
   77|    762|   if (prng_descriptor[wprng].read(buf, (unsigned long)keysize, prng) != (unsigned long)keysize) {
  ------------------
  |  Branch (77:8): [True: 0, False: 762]
  ------------------
   78|      0|      err = CRYPT_ERROR_READPRNG;
   79|      0|      goto ERR_BUF;
   80|      0|   }
   81|       |
   82|       |   /* setup the key variables */
   83|    762|   if ((err = mp_init_multi(&key->pubkey.x, &key->pubkey.y, &key->pubkey.z, &key->k, &prime, &order, NULL)) != CRYPT_OK) {
  ------------------
  |  |  517|    762|#define mp_init_multi                ltc_init_multi
  ------------------
  |  Branch (83:8): [True: 0, False: 762]
  ------------------
   84|      0|      goto ERR_BUF;
   85|      0|   }
   86|    762|   base = ltc_ecc_new_point();
   87|    762|   if (base == NULL) {
  ------------------
  |  Branch (87:8): [True: 0, False: 762]
  ------------------
   88|      0|      err = CRYPT_MEM;
   89|      0|      goto errkey;
   90|      0|   }
   91|       |
   92|       |   /* read in the specs for this key */
   93|    762|   if ((err = mp_read_radix(prime,   (char *)key->dp->prime, 16)) != CRYPT_OK)                  { goto errkey; }
  ------------------
  |  |  537|    762|#define mp_read_radix(a, b, c)       ltc_mp.read_radix(a, b, c)
  ------------------
  |  Branch (93:8): [True: 0, False: 762]
  ------------------
   94|    762|   if ((err = mp_read_radix(order,   (char *)key->dp->order, 16)) != CRYPT_OK)                  { goto errkey; }
  ------------------
  |  |  537|    762|#define mp_read_radix(a, b, c)       ltc_mp.read_radix(a, b, c)
  ------------------
  |  Branch (94:8): [True: 0, False: 762]
  ------------------
   95|    762|   if ((err = mp_read_radix(base->x, (char *)key->dp->Gx, 16)) != CRYPT_OK)                     { goto errkey; }
  ------------------
  |  |  537|    762|#define mp_read_radix(a, b, c)       ltc_mp.read_radix(a, b, c)
  ------------------
  |  Branch (95:8): [True: 0, False: 762]
  ------------------
   96|    762|   if ((err = mp_read_radix(base->y, (char *)key->dp->Gy, 16)) != CRYPT_OK)                     { goto errkey; }
  ------------------
  |  |  537|    762|#define mp_read_radix(a, b, c)       ltc_mp.read_radix(a, b, c)
  ------------------
  |  Branch (96:8): [True: 0, False: 762]
  ------------------
   97|    762|   if ((err = mp_set(base->z, 1)) != CRYPT_OK)                                                  { goto errkey; }
  ------------------
  |  |  526|    762|#define mp_set(a, b)                 ltc_mp.set_int(a, b)
  ------------------
  |  Branch (97:8): [True: 0, False: 762]
  ------------------
   98|    762|   if ((err = mp_read_unsigned_bin(key->k, (unsigned char *)buf, keysize)) != CRYPT_OK)         { goto errkey; }
  ------------------
  |  |  541|    762|#define mp_read_unsigned_bin(a, b, c) ltc_mp.unsigned_read(a, b, c)
  ------------------
  |  Branch (98:8): [True: 0, False: 762]
  ------------------
   99|       |
  100|       |   /* the key should be smaller than the order of base point */
  101|    762|   if (mp_cmp(key->k, order) != LTC_MP_LT) {
  ------------------
  |  |  531|    762|#define mp_cmp(a, b)                 ltc_mp.compare(a, b)
  ------------------
                 if (mp_cmp(key->k, order) != LTC_MP_LT) {
  ------------------
  |  |   12|    762|#define LTC_MP_LT   -1
  ------------------
  |  Branch (101:8): [True: 571, False: 191]
  ------------------
  102|    571|       if((err = mp_mod(key->k, order, key->k)) != CRYPT_OK)                                    { goto errkey; }
  ------------------
  |  |  552|    571|#define mp_mod(a, b, c)              ltc_mp.mpdiv(a, b, NULL, c)
  ------------------
  |  Branch (102:11): [True: 0, False: 571]
  ------------------
  103|    571|   }
  104|       |   /* make the public key */
  105|    762|   if ((err = ltc_mp.ecc_ptmul(key->k, base, &key->pubkey, prime, 1)) != CRYPT_OK)              { goto errkey; }
  ------------------
  |  Branch (105:8): [True: 0, False: 762]
  ------------------
  106|    762|   key->type = PK_PRIVATE;
  107|       |
  108|       |   /* free up ram */
  109|    762|   err = CRYPT_OK;
  110|    762|   goto cleanup;
  111|      0|errkey:
  112|      0|   mp_clear_multi(key->pubkey.x, key->pubkey.y, key->pubkey.z, key->k, NULL);
  ------------------
  |  |  519|      0|#define mp_clear_multi               ltc_deinit_multi
  ------------------
  113|    762|cleanup:
  114|    762|   ltc_ecc_del_point(base);
  115|    762|   mp_clear_multi(prime, order, NULL);
  ------------------
  |  |  519|    762|#define mp_clear_multi               ltc_deinit_multi
  ------------------
  116|    762|ERR_BUF:
  117|       |#ifdef LTC_CLEAN_STACK
  118|       |   zeromem(buf, ECC_MAXSIZE);
  119|       |#endif
  120|    762|   XFREE(buf);
  ------------------
  |  |   17|    762|#define XFREE m_free_direct
  ------------------
  121|    762|   return err;
  122|    762|}

ltc_ecc_is_valid_idx:
   29|  1.01k|{
   30|  1.01k|   int x;
   31|       |
   32|  4.05k|   for (x = 0; ltc_ecc_sets[x].size != 0; x++);
  ------------------
  |  Branch (32:16): [True: 3.03k, False: 1.01k]
  ------------------
   33|       |   /* -1 is a valid index --- indicating that the domain params were supplied by the user */
   34|  1.01k|   if ((n >= -1) && (n < x)) {
  ------------------
  |  Branch (34:8): [True: 1.01k, False: 0]
  |  Branch (34:21): [True: 1.01k, False: 0]
  ------------------
   35|  1.01k|      return 1;
   36|  1.01k|   }
   37|      0|   return 0;
   38|  1.01k|}

ltc_ecc_map:
   32|    890|{
   33|    890|   void *t1, *t2;
   34|    890|   int   err;
   35|       |
   36|    890|   LTC_ARGCHK(P       != NULL);
  ------------------
  |  |   32|    890|#define LTC_ARGCHK(x) do { if (!(x)) { crypt_argchk(#x, __FILE__, __LINE__); } }while(0)
  |  |  ------------------
  |  |  |  Branch (32:32): [True: 0, False: 890]
  |  |  |  Branch (32:87): [Folded, False: 890]
  |  |  ------------------
  ------------------
   37|    890|   LTC_ARGCHK(modulus != NULL);
  ------------------
  |  |   32|    890|#define LTC_ARGCHK(x) do { if (!(x)) { crypt_argchk(#x, __FILE__, __LINE__); } }while(0)
  |  |  ------------------
  |  |  |  Branch (32:32): [True: 0, False: 890]
  |  |  |  Branch (32:87): [Folded, False: 890]
  |  |  ------------------
  ------------------
   38|    890|   LTC_ARGCHK(mp      != NULL);
  ------------------
  |  |   32|    890|#define LTC_ARGCHK(x) do { if (!(x)) { crypt_argchk(#x, __FILE__, __LINE__); } }while(0)
  |  |  ------------------
  |  |  |  Branch (32:32): [True: 0, False: 890]
  |  |  |  Branch (32:87): [Folded, False: 890]
  |  |  ------------------
  ------------------
   39|       |
   40|    890|   if ((err = mp_init_multi(&t1, &t2, NULL)) != CRYPT_OK) {
  ------------------
  |  |  517|    890|#define mp_init_multi                ltc_init_multi
  ------------------
  |  Branch (40:8): [True: 0, False: 890]
  ------------------
   41|      0|      return err;
   42|      0|   }
   43|       |
   44|       |   /* first map z back to normal */
   45|    890|   if ((err = mp_montgomery_reduce(P->z, modulus, mp)) != CRYPT_OK)           { goto done; }
  ------------------
  |  |  565|    890|#define mp_montgomery_reduce(a, b, c)   ltc_mp.montgomery_reduce(a, b, c)
  ------------------
  |  Branch (45:8): [True: 0, False: 890]
  ------------------
   46|       |
   47|       |   /* get 1/z */
   48|    890|   if ((err = mp_invmod(P->z, modulus, t1)) != CRYPT_OK)                      { goto done; }
  ------------------
  |  |  561|    890|#define mp_invmod(a, b, c)           ltc_mp.invmod(a, b, c)
  ------------------
  |  Branch (48:8): [True: 0, False: 890]
  ------------------
   49|       |
   50|       |   /* get 1/z^2 and 1/z^3 */
   51|    890|   if ((err = mp_sqr(t1, t2)) != CRYPT_OK)                                    { goto done; }
  ------------------
  |  |  549|    890|#define mp_sqr(a, b)                 ltc_mp.sqr(a, b)
  ------------------
  |  Branch (51:8): [True: 0, False: 890]
  ------------------
   52|    890|   if ((err = mp_mod(t2, modulus, t2)) != CRYPT_OK)                           { goto done; }
  ------------------
  |  |  552|    890|#define mp_mod(a, b, c)              ltc_mp.mpdiv(a, b, NULL, c)
  ------------------
  |  Branch (52:8): [True: 0, False: 890]
  ------------------
   53|    890|   if ((err = mp_mul(t1, t2, t1)) != CRYPT_OK)                                { goto done; }
  ------------------
  |  |  547|    890|#define mp_mul(a, b, c)              ltc_mp.mul(a, b, c)
  ------------------
  |  Branch (53:8): [True: 0, False: 890]
  ------------------
   54|    890|   if ((err = mp_mod(t1, modulus, t1)) != CRYPT_OK)                           { goto done; }
  ------------------
  |  |  552|    890|#define mp_mod(a, b, c)              ltc_mp.mpdiv(a, b, NULL, c)
  ------------------
  |  Branch (54:8): [True: 0, False: 890]
  ------------------
   55|       |
   56|       |   /* multiply against x/y */
   57|    890|   if ((err = mp_mul(P->x, t2, P->x)) != CRYPT_OK)                            { goto done; }
  ------------------
  |  |  547|    890|#define mp_mul(a, b, c)              ltc_mp.mul(a, b, c)
  ------------------
  |  Branch (57:8): [True: 0, False: 890]
  ------------------
   58|    890|   if ((err = mp_montgomery_reduce(P->x, modulus, mp)) != CRYPT_OK)           { goto done; }
  ------------------
  |  |  565|    890|#define mp_montgomery_reduce(a, b, c)   ltc_mp.montgomery_reduce(a, b, c)
  ------------------
  |  Branch (58:8): [True: 0, False: 890]
  ------------------
   59|    890|   if ((err = mp_mul(P->y, t1, P->y)) != CRYPT_OK)                            { goto done; }
  ------------------
  |  |  547|    890|#define mp_mul(a, b, c)              ltc_mp.mul(a, b, c)
  ------------------
  |  Branch (59:8): [True: 0, False: 890]
  ------------------
   60|    890|   if ((err = mp_montgomery_reduce(P->y, modulus, mp)) != CRYPT_OK)           { goto done; }
  ------------------
  |  |  565|    890|#define mp_montgomery_reduce(a, b, c)   ltc_mp.montgomery_reduce(a, b, c)
  ------------------
  |  Branch (60:8): [True: 0, False: 890]
  ------------------
   61|    890|   if ((err = mp_set(P->z, 1)) != CRYPT_OK)                                   { goto done; }
  ------------------
  |  |  526|    890|#define mp_set(a, b)                 ltc_mp.set_int(a, b)
  ------------------
  |  Branch (61:8): [True: 0, False: 890]
  ------------------
   62|       |
   63|    890|   err = CRYPT_OK;
   64|    890|done:
   65|    890|   mp_clear_multi(t1, t2, NULL);
  ------------------
  |  |  519|    890|#define mp_clear_multi               ltc_deinit_multi
  ------------------
   66|    890|   return err;
   67|    890|}

ltc_ecc_mul2add:
   39|     50|{
   40|     50|  ecc_point     *precomp[16];
   41|     50|  unsigned       bitbufA, bitbufB, lenA, lenB, len, x, y, nA, nB, nibble;
   42|     50|  unsigned char *tA, *tB;
   43|     50|  int            err, first;
   44|     50|  void          *mp, *mu;
   45|       |
   46|       |  /* argchks */
   47|     50|  LTC_ARGCHK(A       != NULL);
  ------------------
  |  |   32|     50|#define LTC_ARGCHK(x) do { if (!(x)) { crypt_argchk(#x, __FILE__, __LINE__); } }while(0)
  |  |  ------------------
  |  |  |  Branch (32:32): [True: 0, False: 50]
  |  |  |  Branch (32:87): [Folded, False: 50]
  |  |  ------------------
  ------------------
   48|     50|  LTC_ARGCHK(B       != NULL);
  ------------------
  |  |   32|     50|#define LTC_ARGCHK(x) do { if (!(x)) { crypt_argchk(#x, __FILE__, __LINE__); } }while(0)
  |  |  ------------------
  |  |  |  Branch (32:32): [True: 0, False: 50]
  |  |  |  Branch (32:87): [Folded, False: 50]
  |  |  ------------------
  ------------------
   49|     50|  LTC_ARGCHK(C       != NULL);
  ------------------
  |  |   32|     50|#define LTC_ARGCHK(x) do { if (!(x)) { crypt_argchk(#x, __FILE__, __LINE__); } }while(0)
  |  |  ------------------
  |  |  |  Branch (32:32): [True: 0, False: 50]
  |  |  |  Branch (32:87): [Folded, False: 50]
  |  |  ------------------
  ------------------
   50|     50|  LTC_ARGCHK(kA      != NULL);
  ------------------
  |  |   32|     50|#define LTC_ARGCHK(x) do { if (!(x)) { crypt_argchk(#x, __FILE__, __LINE__); } }while(0)
  |  |  ------------------
  |  |  |  Branch (32:32): [True: 0, False: 50]
  |  |  |  Branch (32:87): [Folded, False: 50]
  |  |  ------------------
  ------------------
   51|     50|  LTC_ARGCHK(kB      != NULL);
  ------------------
  |  |   32|     50|#define LTC_ARGCHK(x) do { if (!(x)) { crypt_argchk(#x, __FILE__, __LINE__); } }while(0)
  |  |  ------------------
  |  |  |  Branch (32:32): [True: 0, False: 50]
  |  |  |  Branch (32:87): [Folded, False: 50]
  |  |  ------------------
  ------------------
   52|     50|  LTC_ARGCHK(modulus != NULL);
  ------------------
  |  |   32|     50|#define LTC_ARGCHK(x) do { if (!(x)) { crypt_argchk(#x, __FILE__, __LINE__); } }while(0)
  |  |  ------------------
  |  |  |  Branch (32:32): [True: 0, False: 50]
  |  |  |  Branch (32:87): [Folded, False: 50]
  |  |  ------------------
  ------------------
   53|       |
   54|       |  /* allocate memory */
   55|     50|  tA = XCALLOC(1, ECC_BUF_SIZE);
  ------------------
  |  |   19|     50|#define XCALLOC m_calloc
  ------------------
                tA = XCALLOC(1, ECC_BUF_SIZE);
  ------------------
  |  |  246|     50|#define ECC_BUF_SIZE 256
  ------------------
   56|     50|  if (tA == NULL) {
  ------------------
  |  Branch (56:7): [True: 0, False: 50]
  ------------------
   57|      0|     return CRYPT_MEM;
   58|      0|  }
   59|     50|  tB = XCALLOC(1, ECC_BUF_SIZE);
  ------------------
  |  |   19|     50|#define XCALLOC m_calloc
  ------------------
                tB = XCALLOC(1, ECC_BUF_SIZE);
  ------------------
  |  |  246|     50|#define ECC_BUF_SIZE 256
  ------------------
   60|     50|  if (tB == NULL) {
  ------------------
  |  Branch (60:7): [True: 0, False: 50]
  ------------------
   61|      0|     XFREE(tA);
  ------------------
  |  |   17|      0|#define XFREE m_free_direct
  ------------------
   62|      0|     return CRYPT_MEM;
   63|      0|  }
   64|       |
   65|       |  /* get sizes */
   66|     50|  lenA = mp_unsigned_bin_size(kA);
  ------------------
  |  |  539|     50|#define mp_unsigned_bin_size(a)      ltc_mp.unsigned_size(a)
  ------------------
   67|     50|  lenB = mp_unsigned_bin_size(kB);
  ------------------
  |  |  539|     50|#define mp_unsigned_bin_size(a)      ltc_mp.unsigned_size(a)
  ------------------
   68|     50|  len  = MAX(lenA, lenB);
  ------------------
  |  |  421|     50|   #define MAX(x, y) ( ((x)>(y))?(x):(y) )
  |  |  ------------------
  |  |  |  Branch (421:24): [True: 35, False: 15]
  |  |  ------------------
  ------------------
   69|       |
   70|       |  /* sanity check */
   71|     50|  if ((lenA > ECC_BUF_SIZE) || (lenB > ECC_BUF_SIZE)) {
  ------------------
  |  |  246|     50|#define ECC_BUF_SIZE 256
  ------------------
                if ((lenA > ECC_BUF_SIZE) || (lenB > ECC_BUF_SIZE)) {
  ------------------
  |  |  246|     50|#define ECC_BUF_SIZE 256
  ------------------
  |  Branch (71:7): [True: 0, False: 50]
  |  Branch (71:32): [True: 0, False: 50]
  ------------------
   72|      0|     err = CRYPT_INVALID_ARG;
   73|      0|     goto ERR_T;
   74|      0|  }
   75|       |
   76|       |  /* extract and justify kA */
   77|     50|  mp_to_unsigned_bin(kA, (len - lenA) + tA);
  ------------------
  |  |  540|     50|#define mp_to_unsigned_bin(a, b)     ltc_mp.unsigned_write(a, b)
  ------------------
   78|       |
   79|       |  /* extract and justify kB */
   80|     50|  mp_to_unsigned_bin(kB, (len - lenB) + tB);
  ------------------
  |  |  540|     50|#define mp_to_unsigned_bin(a, b)     ltc_mp.unsigned_write(a, b)
  ------------------
   81|       |
   82|       |  /* allocate the table */
   83|    850|  for (x = 0; x < 16; x++) {
  ------------------
  |  Branch (83:15): [True: 800, False: 50]
  ------------------
   84|    800|     precomp[x] = ltc_ecc_new_point();
   85|    800|     if (precomp[x] == NULL) {
  ------------------
  |  Branch (85:10): [True: 0, False: 800]
  ------------------
   86|      0|         for (y = 0; y < x; ++y) {
  ------------------
  |  Branch (86:22): [True: 0, False: 0]
  ------------------
   87|      0|            ltc_ecc_del_point(precomp[y]);
   88|      0|         }
   89|      0|         err = CRYPT_MEM;
   90|      0|         goto ERR_T;
   91|      0|     }
   92|    800|  }
   93|       |
   94|       |  /* init montgomery reduction */
   95|     50|  if ((err = mp_montgomery_setup(modulus, &mp)) != CRYPT_OK) {
  ------------------
  |  |  563|     50|#define mp_montgomery_setup(a, b)    ltc_mp.montgomery_setup(a, b)
  ------------------
  |  Branch (95:7): [True: 0, False: 50]
  ------------------
   96|      0|      goto ERR_P;
   97|      0|  }
   98|     50|  if ((err = mp_init(&mu)) != CRYPT_OK) {
  ------------------
  |  |  516|     50|#define mp_init(a)                   ltc_mp.init(a)
  ------------------
  |  Branch (98:7): [True: 0, False: 50]
  ------------------
   99|      0|      goto ERR_MP;
  100|      0|  }
  101|     50|  if ((err = mp_montgomery_normalization(mu, modulus)) != CRYPT_OK) {
  ------------------
  |  |  564|     50|#define mp_montgomery_normalization(a, b) ltc_mp.montgomery_normalization(a, b)
  ------------------
  |  Branch (101:7): [True: 0, False: 50]
  ------------------
  102|      0|      goto ERR_MU;
  103|      0|  }
  104|       |
  105|       |  /* copy ones ... */
  106|     50|  if ((err = mp_mulmod(A->x, mu, modulus, precomp[1]->x)) != CRYPT_OK)                                         { goto ERR_MU; }
  ------------------
  |  |  559|     50|#define mp_mulmod(a, b, c, d)        ltc_mp.mulmod(a, b, c, d)
  ------------------
  |  Branch (106:7): [True: 0, False: 50]
  ------------------
  107|     50|  if ((err = mp_mulmod(A->y, mu, modulus, precomp[1]->y)) != CRYPT_OK)                                         { goto ERR_MU; }
  ------------------
  |  |  559|     50|#define mp_mulmod(a, b, c, d)        ltc_mp.mulmod(a, b, c, d)
  ------------------
  |  Branch (107:7): [True: 0, False: 50]
  ------------------
  108|     50|  if ((err = mp_mulmod(A->z, mu, modulus, precomp[1]->z)) != CRYPT_OK)                                         { goto ERR_MU; }
  ------------------
  |  |  559|     50|#define mp_mulmod(a, b, c, d)        ltc_mp.mulmod(a, b, c, d)
  ------------------
  |  Branch (108:7): [True: 0, False: 50]
  ------------------
  109|       |
  110|     50|  if ((err = mp_mulmod(B->x, mu, modulus, precomp[1<<2]->x)) != CRYPT_OK)                                      { goto ERR_MU; }
  ------------------
  |  |  559|     50|#define mp_mulmod(a, b, c, d)        ltc_mp.mulmod(a, b, c, d)
  ------------------
  |  Branch (110:7): [True: 0, False: 50]
  ------------------
  111|     50|  if ((err = mp_mulmod(B->y, mu, modulus, precomp[1<<2]->y)) != CRYPT_OK)                                      { goto ERR_MU; }
  ------------------
  |  |  559|     50|#define mp_mulmod(a, b, c, d)        ltc_mp.mulmod(a, b, c, d)
  ------------------
  |  Branch (111:7): [True: 0, False: 50]
  ------------------
  112|     50|  if ((err = mp_mulmod(B->z, mu, modulus, precomp[1<<2]->z)) != CRYPT_OK)                                      { goto ERR_MU; }
  ------------------
  |  |  559|     50|#define mp_mulmod(a, b, c, d)        ltc_mp.mulmod(a, b, c, d)
  ------------------
  |  Branch (112:7): [True: 0, False: 50]
  ------------------
  113|       |
  114|       |  /* precomp [i,0](A + B) table */
  115|     50|  if ((err = ltc_mp.ecc_ptdbl(precomp[1], precomp[2], modulus, mp)) != CRYPT_OK)                               { goto ERR_MU; }
  ------------------
  |  Branch (115:7): [True: 0, False: 50]
  ------------------
  116|     50|  if ((err = ltc_mp.ecc_ptadd(precomp[1], precomp[2], precomp[3], modulus, mp)) != CRYPT_OK)                   { goto ERR_MU; }
  ------------------
  |  Branch (116:7): [True: 0, False: 50]
  ------------------
  117|       |
  118|       |  /* precomp [0,i](A + B) table */
  119|     50|  if ((err = ltc_mp.ecc_ptdbl(precomp[1<<2], precomp[2<<2], modulus, mp)) != CRYPT_OK)                         { goto ERR_MU; }
  ------------------
  |  Branch (119:7): [True: 0, False: 50]
  ------------------
  120|     50|  if ((err = ltc_mp.ecc_ptadd(precomp[1<<2], precomp[2<<2], precomp[3<<2], modulus, mp)) != CRYPT_OK)          { goto ERR_MU; }
  ------------------
  |  Branch (120:7): [True: 0, False: 50]
  ------------------
  121|       |
  122|       |  /* precomp [i,j](A + B) table (i != 0, j != 0) */
  123|    200|  for (x = 1; x < 4; x++) {
  ------------------
  |  Branch (123:15): [True: 150, False: 50]
  ------------------
  124|    600|     for (y = 1; y < 4; y++) {
  ------------------
  |  Branch (124:18): [True: 450, False: 150]
  ------------------
  125|    450|        if ((err = ltc_mp.ecc_ptadd(precomp[x], precomp[(y<<2)], precomp[x+(y<<2)], modulus, mp)) != CRYPT_OK) { goto ERR_MU; }
  ------------------
  |  Branch (125:13): [True: 0, False: 450]
  ------------------
  126|    450|     }
  127|    150|  }
  128|       |
  129|     50|  nibble  = 3;
  130|     50|  first   = 1;
  131|     50|  bitbufA = tA[0];
  132|     50|  bitbufB = tB[0];
  133|       |
  134|       |  /* for every byte of the multiplicands */
  135|  13.1k|  for (x = 0;; ) {
  136|       |     /* grab a nibble */
  137|  13.1k|     if (++nibble == 4) {
  ------------------
  |  Branch (137:10): [True: 3.32k, False: 9.83k]
  ------------------
  138|  3.32k|        if (x == len) break;
  ------------------
  |  Branch (138:13): [True: 50, False: 3.27k]
  ------------------
  139|  3.27k|        bitbufA = tA[x];
  140|  3.27k|        bitbufB = tB[x];
  141|  3.27k|        nibble  = 0;
  142|  3.27k|        ++x;
  143|  3.27k|     }
  144|       |
  145|       |     /* extract two bits from both, shift/update */
  146|  13.1k|     nA = (bitbufA >> 6) & 0x03;
  147|  13.1k|     nB = (bitbufB >> 6) & 0x03;
  148|  13.1k|     bitbufA = (bitbufA << 2) & 0xFF;
  149|  13.1k|     bitbufB = (bitbufB << 2) & 0xFF;
  150|       |
  151|       |     /* if both zero, if first, continue */
  152|  13.1k|     if ((nA == 0) && (nB == 0) && (first == 1)) {
  ------------------
  |  Branch (152:10): [True: 3.55k, False: 9.56k]
  |  Branch (152:23): [True: 2.05k, False: 1.50k]
  |  Branch (152:36): [True: 101, False: 1.95k]
  ------------------
  153|    101|        continue;
  154|    101|     }
  155|       |
  156|       |     /* double twice, only if this isn't the first */
  157|  13.0k|     if (first == 0) {
  ------------------
  |  Branch (157:10): [True: 12.9k, False: 50]
  ------------------
  158|       |        /* double twice */
  159|  12.9k|        if ((err = ltc_mp.ecc_ptdbl(C, C, modulus, mp)) != CRYPT_OK)                  { goto ERR_MU; }
  ------------------
  |  Branch (159:13): [True: 0, False: 12.9k]
  ------------------
  160|  12.9k|        if ((err = ltc_mp.ecc_ptdbl(C, C, modulus, mp)) != CRYPT_OK)                  { goto ERR_MU; }
  ------------------
  |  Branch (160:13): [True: 0, False: 12.9k]
  ------------------
  161|  12.9k|     }
  162|       |
  163|       |     /* if not both zero */
  164|  13.0k|     if ((nA != 0) || (nB != 0)) {
  ------------------
  |  Branch (164:10): [True: 9.56k, False: 3.45k]
  |  Branch (164:23): [True: 1.50k, False: 1.95k]
  ------------------
  165|  11.0k|        if (first == 1) {
  ------------------
  |  Branch (165:13): [True: 50, False: 11.0k]
  ------------------
  166|       |           /* if first, copy from table */
  167|     50|           first = 0;
  168|     50|           if ((err = mp_copy(precomp[nA + (nB<<2)]->x, C->x)) != CRYPT_OK)           { goto ERR_MU; }
  ------------------
  |  |  524|     50|#define mp_copy(a, b)                ltc_mp.copy(a, b)
  ------------------
  |  Branch (168:16): [True: 0, False: 50]
  ------------------
  169|     50|           if ((err = mp_copy(precomp[nA + (nB<<2)]->y, C->y)) != CRYPT_OK)           { goto ERR_MU; }
  ------------------
  |  |  524|     50|#define mp_copy(a, b)                ltc_mp.copy(a, b)
  ------------------
  |  Branch (169:16): [True: 0, False: 50]
  ------------------
  170|     50|           if ((err = mp_copy(precomp[nA + (nB<<2)]->z, C->z)) != CRYPT_OK)           { goto ERR_MU; }
  ------------------
  |  |  524|     50|#define mp_copy(a, b)                ltc_mp.copy(a, b)
  ------------------
  |  Branch (170:16): [True: 0, False: 50]
  ------------------
  171|  11.0k|        } else {
  172|       |           /* if not first, add from table */
  173|  11.0k|           if ((err = ltc_mp.ecc_ptadd(C, precomp[nA + (nB<<2)], C, modulus, mp)) != CRYPT_OK) { goto ERR_MU; }
  ------------------
  |  Branch (173:16): [True: 0, False: 11.0k]
  ------------------
  174|  11.0k|        }
  175|  11.0k|     }
  176|  13.0k|  }
  177|       |
  178|       |  /* reduce to affine */
  179|     50|  err = ltc_ecc_map(C, modulus, mp);
  180|       |
  181|       |  /* clean up */
  182|     50|ERR_MU:
  183|     50|   mp_clear(mu);
  ------------------
  |  |  518|     50|#define mp_clear(a)                  ltc_mp.deinit(a)
  ------------------
  184|     50|ERR_MP:
  185|     50|   mp_montgomery_free(mp);
  ------------------
  |  |  566|     50|#define mp_montgomery_free(a)        ltc_mp.montgomery_deinit(a)
  ------------------
  186|     50|ERR_P:
  187|    850|   for (x = 0; x < 16; x++) {
  ------------------
  |  Branch (187:16): [True: 800, False: 50]
  ------------------
  188|    800|       ltc_ecc_del_point(precomp[x]);
  189|    800|   }
  190|     50|ERR_T:
  191|       |#ifdef LTC_CLEAN_STACK
  192|       |   zeromem(tA, ECC_BUF_SIZE);
  193|       |   zeromem(tB, ECC_BUF_SIZE);
  194|       |#endif
  195|     50|   XFREE(tA);
  ------------------
  |  |   17|     50|#define XFREE m_free_direct
  ------------------
  196|     50|   XFREE(tB);
  ------------------
  |  |   17|     50|#define XFREE m_free_direct
  ------------------
  197|       |
  198|     50|   return err;
  199|     50|}

ltc_ecc_mulmod:
   36|    840|{
   37|    840|   ecc_point *tG, *M[3];
   38|    840|   int        i, j, err;
   39|    840|   void       *mu, *mp;
   40|    840|   ltc_mp_digit buf;
   41|    840|   int        bitcnt, mode, digidx;
   42|       |
   43|    840|   LTC_ARGCHK(k       != NULL);
  ------------------
  |  |   32|    840|#define LTC_ARGCHK(x) do { if (!(x)) { crypt_argchk(#x, __FILE__, __LINE__); } }while(0)
  |  |  ------------------
  |  |  |  Branch (32:32): [True: 0, False: 840]
  |  |  |  Branch (32:87): [Folded, False: 840]
  |  |  ------------------
  ------------------
   44|    840|   LTC_ARGCHK(G       != NULL);
  ------------------
  |  |   32|    840|#define LTC_ARGCHK(x) do { if (!(x)) { crypt_argchk(#x, __FILE__, __LINE__); } }while(0)
  |  |  ------------------
  |  |  |  Branch (32:32): [True: 0, False: 840]
  |  |  |  Branch (32:87): [Folded, False: 840]
  |  |  ------------------
  ------------------
   45|    840|   LTC_ARGCHK(R       != NULL);
  ------------------
  |  |   32|    840|#define LTC_ARGCHK(x) do { if (!(x)) { crypt_argchk(#x, __FILE__, __LINE__); } }while(0)
  |  |  ------------------
  |  |  |  Branch (32:32): [True: 0, False: 840]
  |  |  |  Branch (32:87): [Folded, False: 840]
  |  |  ------------------
  ------------------
   46|    840|   LTC_ARGCHK(modulus != NULL);
  ------------------
  |  |   32|    840|#define LTC_ARGCHK(x) do { if (!(x)) { crypt_argchk(#x, __FILE__, __LINE__); } }while(0)
  |  |  ------------------
  |  |  |  Branch (32:32): [True: 0, False: 840]
  |  |  |  Branch (32:87): [Folded, False: 840]
  |  |  ------------------
  ------------------
   47|       |
   48|       |   /* init montgomery reduction */
   49|    840|   if ((err = mp_montgomery_setup(modulus, &mp)) != CRYPT_OK) {
  ------------------
  |  |  563|    840|#define mp_montgomery_setup(a, b)    ltc_mp.montgomery_setup(a, b)
  ------------------
  |  Branch (49:8): [True: 0, False: 840]
  ------------------
   50|      0|      return err;
   51|      0|   }
   52|    840|   if ((err = mp_init(&mu)) != CRYPT_OK) {
  ------------------
  |  |  516|    840|#define mp_init(a)                   ltc_mp.init(a)
  ------------------
  |  Branch (52:8): [True: 0, False: 840]
  ------------------
   53|      0|      mp_montgomery_free(mp);
  ------------------
  |  |  566|      0|#define mp_montgomery_free(a)        ltc_mp.montgomery_deinit(a)
  ------------------
   54|      0|      return err;
   55|      0|   }
   56|    840|   if ((err = mp_montgomery_normalization(mu, modulus)) != CRYPT_OK) {
  ------------------
  |  |  564|    840|#define mp_montgomery_normalization(a, b) ltc_mp.montgomery_normalization(a, b)
  ------------------
  |  Branch (56:8): [True: 0, False: 840]
  ------------------
   57|      0|      mp_clear(mu);
  ------------------
  |  |  518|      0|#define mp_clear(a)                  ltc_mp.deinit(a)
  ------------------
   58|      0|      mp_montgomery_free(mp);
  ------------------
  |  |  566|      0|#define mp_montgomery_free(a)        ltc_mp.montgomery_deinit(a)
  ------------------
   59|      0|      return err;
   60|      0|   }
   61|       |
   62|       |   /* alloc ram for window temps */
   63|  3.36k|   for (i = 0; i < 3; i++) {
  ------------------
  |  Branch (63:16): [True: 2.52k, False: 840]
  ------------------
   64|  2.52k|      M[i] = ltc_ecc_new_point();
   65|  2.52k|      if (M[i] == NULL) {
  ------------------
  |  Branch (65:11): [True: 0, False: 2.52k]
  ------------------
   66|      0|         for (j = 0; j < i; j++) {
  ------------------
  |  Branch (66:22): [True: 0, False: 0]
  ------------------
   67|      0|             ltc_ecc_del_point(M[j]);
   68|      0|         }
   69|      0|         mp_clear(mu);
  ------------------
  |  |  518|      0|#define mp_clear(a)                  ltc_mp.deinit(a)
  ------------------
   70|      0|         mp_montgomery_free(mp);
  ------------------
  |  |  566|      0|#define mp_montgomery_free(a)        ltc_mp.montgomery_deinit(a)
  ------------------
   71|      0|         return CRYPT_MEM;
   72|      0|      }
   73|  2.52k|   }
   74|       |
   75|       |   /* make a copy of G incase R==G */
   76|    840|   tG = ltc_ecc_new_point();
   77|    840|   if (tG == NULL)                                                                   { err = CRYPT_MEM; goto done; }
  ------------------
  |  Branch (77:8): [True: 0, False: 840]
  ------------------
   78|       |
   79|       |   /* tG = G  and convert to montgomery */
   80|    840|   if ((err = mp_mulmod(G->x, mu, modulus, tG->x)) != CRYPT_OK)                      { goto done; }
  ------------------
  |  |  559|    840|#define mp_mulmod(a, b, c, d)        ltc_mp.mulmod(a, b, c, d)
  ------------------
  |  Branch (80:8): [True: 0, False: 840]
  ------------------
   81|    840|   if ((err = mp_mulmod(G->y, mu, modulus, tG->y)) != CRYPT_OK)                      { goto done; }
  ------------------
  |  |  559|    840|#define mp_mulmod(a, b, c, d)        ltc_mp.mulmod(a, b, c, d)
  ------------------
  |  Branch (81:8): [True: 0, False: 840]
  ------------------
   82|    840|   if ((err = mp_mulmod(G->z, mu, modulus, tG->z)) != CRYPT_OK)                      { goto done; }
  ------------------
  |  |  559|    840|#define mp_mulmod(a, b, c, d)        ltc_mp.mulmod(a, b, c, d)
  ------------------
  |  Branch (82:8): [True: 0, False: 840]
  ------------------
   83|    840|   mp_clear(mu);
  ------------------
  |  |  518|    840|#define mp_clear(a)                  ltc_mp.deinit(a)
  ------------------
   84|    840|   mu = NULL;
   85|       |
   86|       |   /* calc the M tab */
   87|       |   /* M[0] == G */
   88|    840|   if ((err = mp_copy(tG->x, M[0]->x)) != CRYPT_OK)                                  { goto done; }
  ------------------
  |  |  524|    840|#define mp_copy(a, b)                ltc_mp.copy(a, b)
  ------------------
  |  Branch (88:8): [True: 0, False: 840]
  ------------------
   89|    840|   if ((err = mp_copy(tG->y, M[0]->y)) != CRYPT_OK)                                  { goto done; }
  ------------------
  |  |  524|    840|#define mp_copy(a, b)                ltc_mp.copy(a, b)
  ------------------
  |  Branch (89:8): [True: 0, False: 840]
  ------------------
   90|    840|   if ((err = mp_copy(tG->z, M[0]->z)) != CRYPT_OK)                                  { goto done; }
  ------------------
  |  |  524|    840|#define mp_copy(a, b)                ltc_mp.copy(a, b)
  ------------------
  |  Branch (90:8): [True: 0, False: 840]
  ------------------
   91|       |   /* M[1] == 2G */
   92|    840|   if ((err = ltc_mp.ecc_ptdbl(tG, M[1], modulus, mp)) != CRYPT_OK)                  { goto done; }
  ------------------
  |  Branch (92:8): [True: 0, False: 840]
  ------------------
   93|       |
   94|       |   /* setup sliding window */
   95|    840|   mode   = 0;
   96|    840|   bitcnt = 1;
   97|    840|   buf    = 0;
   98|    840|   digidx = mp_get_digit_count(k) - 1;
  ------------------
  |  |  530|    840|#define mp_get_digit_count(a)        ltc_mp.get_digit_count(a)
  ------------------
   99|       |
  100|       |   /* perform ops */
  101|   416k|   for (;;) {
  102|       |     /* grab next digit as required */
  103|   416k|      if (--bitcnt == 0) {
  ------------------
  |  Branch (103:11): [True: 7.76k, False: 408k]
  ------------------
  104|  7.76k|         if (digidx == -1) {
  ------------------
  |  Branch (104:14): [True: 840, False: 6.92k]
  ------------------
  105|    840|            break;
  106|    840|         }
  107|  6.92k|         buf    = mp_get_digit(k, digidx);
  ------------------
  |  |  529|  6.92k|#define mp_get_digit(a, n)           ltc_mp.get_digit(a, n)
  ------------------
  108|  6.92k|         bitcnt = (int) MP_DIGIT_BIT;
  ------------------
  |  |  513|  6.92k|#define MP_DIGIT_BIT                 ltc_mp.bits_per_digit
  ------------------
  109|  6.92k|         --digidx;
  110|  6.92k|      }
  111|       |
  112|       |      /* grab the next msb from the ltiplicand */
  113|   415k|      i = (buf >> (MP_DIGIT_BIT - 1)) & 1;
  ------------------
  |  |  513|   415k|#define MP_DIGIT_BIT                 ltc_mp.bits_per_digit
  ------------------
  114|   415k|      buf <<= 1;
  115|       |
  116|   415k|      if (mode == 0 && i == 0) {
  ------------------
  |  Branch (116:11): [True: 21.4k, False: 394k]
  |  Branch (116:24): [True: 20.6k, False: 840]
  ------------------
  117|       |         /* dummy operations */
  118|  20.6k|         if ((err = ltc_mp.ecc_ptadd(M[0], M[1], M[2], modulus, mp)) != CRYPT_OK)    { goto done; }
  ------------------
  |  Branch (118:14): [True: 0, False: 20.6k]
  ------------------
  119|  20.6k|         if ((err = ltc_mp.ecc_ptdbl(M[1], M[2], modulus, mp)) != CRYPT_OK)          { goto done; }
  ------------------
  |  Branch (119:14): [True: 0, False: 20.6k]
  ------------------
  120|  20.6k|         continue;
  121|  20.6k|      }
  122|       |
  123|   394k|      if (mode == 0 && i == 1) {
  ------------------
  |  Branch (123:11): [True: 840, False: 394k]
  |  Branch (123:24): [True: 840, False: 0]
  ------------------
  124|    840|         mode = 1;
  125|       |         /* dummy operations */
  126|    840|         if ((err = ltc_mp.ecc_ptadd(M[0], M[1], M[2], modulus, mp)) != CRYPT_OK)    { goto done; }
  ------------------
  |  Branch (126:14): [True: 0, False: 840]
  ------------------
  127|    840|         if ((err = ltc_mp.ecc_ptdbl(M[1], M[2], modulus, mp)) != CRYPT_OK)          { goto done; }
  ------------------
  |  Branch (127:14): [True: 0, False: 840]
  ------------------
  128|    840|         continue;
  129|    840|      }
  130|       |
  131|   394k|      if ((err = ltc_mp.ecc_ptadd(M[0], M[1], M[i^1], modulus, mp)) != CRYPT_OK)     { goto done; }
  ------------------
  |  Branch (131:11): [True: 0, False: 394k]
  ------------------
  132|   394k|      if ((err = ltc_mp.ecc_ptdbl(M[i], M[i], modulus, mp)) != CRYPT_OK)             { goto done; }
  ------------------
  |  Branch (132:11): [True: 0, False: 394k]
  ------------------
  133|   394k|   }
  134|       |
  135|       |   /* copy result out */
  136|    840|   if ((err = mp_copy(M[0]->x, R->x)) != CRYPT_OK)                                   { goto done; }
  ------------------
  |  |  524|    840|#define mp_copy(a, b)                ltc_mp.copy(a, b)
  ------------------
  |  Branch (136:8): [True: 0, False: 840]
  ------------------
  137|    840|   if ((err = mp_copy(M[0]->y, R->y)) != CRYPT_OK)                                   { goto done; }
  ------------------
  |  |  524|    840|#define mp_copy(a, b)                ltc_mp.copy(a, b)
  ------------------
  |  Branch (137:8): [True: 0, False: 840]
  ------------------
  138|    840|   if ((err = mp_copy(M[0]->z, R->z)) != CRYPT_OK)                                   { goto done; }
  ------------------
  |  |  524|    840|#define mp_copy(a, b)                ltc_mp.copy(a, b)
  ------------------
  |  Branch (138:8): [True: 0, False: 840]
  ------------------
  139|       |
  140|       |   /* map R back from projective space */
  141|    840|   if (map) {
  ------------------
  |  Branch (141:8): [True: 840, False: 0]
  ------------------
  142|    840|      err = ltc_ecc_map(R, modulus, mp);
  143|    840|   } else {
  144|      0|      err = CRYPT_OK;
  145|      0|   }
  146|    840|done:
  147|    840|   if (mu != NULL) {
  ------------------
  |  Branch (147:8): [True: 0, False: 840]
  ------------------
  148|      0|      mp_clear(mu);
  ------------------
  |  |  518|      0|#define mp_clear(a)                  ltc_mp.deinit(a)
  ------------------
  149|      0|   }
  150|    840|   mp_montgomery_free(mp);
  ------------------
  |  |  566|    840|#define mp_montgomery_free(a)        ltc_mp.montgomery_deinit(a)
  ------------------
  151|    840|   ltc_ecc_del_point(tG);
  152|  3.36k|   for (i = 0; i < 3; i++) {
  ------------------
  |  Branch (152:16): [True: 2.52k, False: 840]
  ------------------
  153|  2.52k|       ltc_ecc_del_point(M[i]);
  154|  2.52k|   }
  155|    840|   return err;
  156|    840|}

ltc_ecc_new_point:
   29|  5.18k|{
   30|  5.18k|   ecc_point *p;
   31|  5.18k|   p = XCALLOC(1, sizeof(*p));
  ------------------
  |  |   19|  5.18k|#define XCALLOC m_calloc
  ------------------
   32|  5.18k|   if (p == NULL) {
  ------------------
  |  Branch (32:8): [True: 0, False: 5.18k]
  ------------------
   33|      0|      return NULL;
   34|      0|   }
   35|  5.18k|   if (mp_init_multi(&p->x, &p->y, &p->z, NULL) != CRYPT_OK) {
  ------------------
  |  |  517|  5.18k|#define mp_init_multi                ltc_init_multi
  ------------------
  |  Branch (35:8): [True: 0, False: 5.18k]
  ------------------
   36|      0|      XFREE(p);
  ------------------
  |  |   17|      0|#define XFREE m_free_direct
  ------------------
   37|      0|      return NULL;
   38|      0|   }
   39|  5.18k|   return p;
   40|  5.18k|}
ltc_ecc_del_point:
   46|  5.18k|{
   47|       |   /* prevents free'ing null arguments */
   48|  5.18k|   if (p != NULL) {
  ------------------
  |  Branch (48:8): [True: 5.18k, False: 0]
  ------------------
   49|  5.18k|      mp_clear_multi(p->x, p->y, p->z, NULL); /* note: p->z may be NULL but that's ok with this function anyways */
  ------------------
  |  |  519|  5.18k|#define mp_clear_multi               ltc_deinit_multi
  ------------------
   50|  5.18k|      XFREE(p);
  ------------------
  |  |   17|  5.18k|#define XFREE m_free_direct
  ------------------
   51|  5.18k|   }
   52|  5.18k|}

ltc_ecc_projective_add_point:
   34|   427k|{
   35|   427k|   void  *t1, *t2, *x, *y, *z;
   36|   427k|   int    err;
   37|       |
   38|   427k|   LTC_ARGCHK(P       != NULL);
  ------------------
  |  |   32|   427k|#define LTC_ARGCHK(x) do { if (!(x)) { crypt_argchk(#x, __FILE__, __LINE__); } }while(0)
  |  |  ------------------
  |  |  |  Branch (32:32): [True: 0, False: 427k]
  |  |  |  Branch (32:87): [Folded, False: 427k]
  |  |  ------------------
  ------------------
   39|   427k|   LTC_ARGCHK(Q       != NULL);
  ------------------
  |  |   32|   427k|#define LTC_ARGCHK(x) do { if (!(x)) { crypt_argchk(#x, __FILE__, __LINE__); } }while(0)
  |  |  ------------------
  |  |  |  Branch (32:32): [True: 0, False: 427k]
  |  |  |  Branch (32:87): [Folded, False: 427k]
  |  |  ------------------
  ------------------
   40|   427k|   LTC_ARGCHK(R       != NULL);
  ------------------
  |  |   32|   427k|#define LTC_ARGCHK(x) do { if (!(x)) { crypt_argchk(#x, __FILE__, __LINE__); } }while(0)
  |  |  ------------------
  |  |  |  Branch (32:32): [True: 0, False: 427k]
  |  |  |  Branch (32:87): [Folded, False: 427k]
  |  |  ------------------
  ------------------
   41|   427k|   LTC_ARGCHK(modulus != NULL);
  ------------------
  |  |   32|   427k|#define LTC_ARGCHK(x) do { if (!(x)) { crypt_argchk(#x, __FILE__, __LINE__); } }while(0)
  |  |  ------------------
  |  |  |  Branch (32:32): [True: 0, False: 427k]
  |  |  |  Branch (32:87): [Folded, False: 427k]
  |  |  ------------------
  ------------------
   42|   427k|   LTC_ARGCHK(mp      != NULL);
  ------------------
  |  |   32|   427k|#define LTC_ARGCHK(x) do { if (!(x)) { crypt_argchk(#x, __FILE__, __LINE__); } }while(0)
  |  |  ------------------
  |  |  |  Branch (32:32): [True: 0, False: 427k]
  |  |  |  Branch (32:87): [Folded, False: 427k]
  |  |  ------------------
  ------------------
   43|       |
   44|   427k|   if ((err = mp_init_multi(&t1, &t2, &x, &y, &z, NULL)) != CRYPT_OK) {
  ------------------
  |  |  517|   427k|#define mp_init_multi                ltc_init_multi
  ------------------
  |  Branch (44:8): [True: 0, False: 427k]
  ------------------
   45|      0|      return err;
   46|      0|   }
   47|       |
   48|       |   /* should we dbl instead? */
   49|   427k|   if ((err = mp_sub(modulus, Q->y, t1)) != CRYPT_OK)                          { goto done; }
  ------------------
  |  |  545|   427k|#define mp_sub(a, b, c)              ltc_mp.sub(a, b, c)
  ------------------
  |  Branch (49:8): [True: 0, False: 427k]
  ------------------
   50|       |
   51|   427k|   if ( (mp_cmp(P->x, Q->x) == LTC_MP_EQ) &&
  ------------------
  |  |  531|   427k|#define mp_cmp(a, b)                 ltc_mp.compare(a, b)
  ------------------
                 if ( (mp_cmp(P->x, Q->x) == LTC_MP_EQ) &&
  ------------------
  |  |   13|   427k|#define LTC_MP_EQ    0
  ------------------
  |  Branch (51:9): [True: 0, False: 427k]
  ------------------
   52|      0|        (Q->z != NULL && mp_cmp(P->z, Q->z) == LTC_MP_EQ) &&
  ------------------
  |  |  531|      0|#define mp_cmp(a, b)                 ltc_mp.compare(a, b)
  ------------------
                      (Q->z != NULL && mp_cmp(P->z, Q->z) == LTC_MP_EQ) &&
  ------------------
  |  |   13|      0|#define LTC_MP_EQ    0
  ------------------
  |  Branch (52:10): [True: 0, False: 0]
  |  Branch (52:26): [True: 0, False: 0]
  ------------------
   53|      0|        (mp_cmp(P->y, Q->y) == LTC_MP_EQ || mp_cmp(P->y, t1) == LTC_MP_EQ)) {
  ------------------
  |  |  531|      0|#define mp_cmp(a, b)                 ltc_mp.compare(a, b)
  ------------------
                      (mp_cmp(P->y, Q->y) == LTC_MP_EQ || mp_cmp(P->y, t1) == LTC_MP_EQ)) {
  ------------------
  |  |   13|      0|#define LTC_MP_EQ    0
  ------------------
                      (mp_cmp(P->y, Q->y) == LTC_MP_EQ || mp_cmp(P->y, t1) == LTC_MP_EQ)) {
  ------------------
  |  |  531|      0|#define mp_cmp(a, b)                 ltc_mp.compare(a, b)
  ------------------
                      (mp_cmp(P->y, Q->y) == LTC_MP_EQ || mp_cmp(P->y, t1) == LTC_MP_EQ)) {
  ------------------
  |  |   13|      0|#define LTC_MP_EQ    0
  ------------------
  |  Branch (53:10): [True: 0, False: 0]
  |  Branch (53:45): [True: 0, False: 0]
  ------------------
   54|      0|        mp_clear_multi(t1, t2, x, y, z, NULL);
  ------------------
  |  |  519|      0|#define mp_clear_multi               ltc_deinit_multi
  ------------------
   55|      0|        return ltc_ecc_projective_dbl_point(P, R, modulus, mp);
   56|      0|   }
   57|       |
   58|   427k|   if ((err = mp_copy(P->x, x)) != CRYPT_OK)                                   { goto done; }
  ------------------
  |  |  524|   427k|#define mp_copy(a, b)                ltc_mp.copy(a, b)
  ------------------
  |  Branch (58:8): [True: 0, False: 427k]
  ------------------
   59|   427k|   if ((err = mp_copy(P->y, y)) != CRYPT_OK)                                   { goto done; }
  ------------------
  |  |  524|   427k|#define mp_copy(a, b)                ltc_mp.copy(a, b)
  ------------------
  |  Branch (59:8): [True: 0, False: 427k]
  ------------------
   60|   427k|   if ((err = mp_copy(P->z, z)) != CRYPT_OK)                                   { goto done; }
  ------------------
  |  |  524|   427k|#define mp_copy(a, b)                ltc_mp.copy(a, b)
  ------------------
  |  Branch (60:8): [True: 0, False: 427k]
  ------------------
   61|       |
   62|       |   /* if Z is one then these are no-operations */
   63|   427k|   if (Q->z != NULL) {
  ------------------
  |  Branch (63:8): [True: 427k, False: 0]
  ------------------
   64|       |      /* T1 = Z' * Z' */
   65|   427k|      if ((err = mp_sqr(Q->z, t1)) != CRYPT_OK)                                { goto done; }
  ------------------
  |  |  549|   427k|#define mp_sqr(a, b)                 ltc_mp.sqr(a, b)
  ------------------
  |  Branch (65:11): [True: 0, False: 427k]
  ------------------
   66|   427k|      if ((err = mp_montgomery_reduce(t1, modulus, mp)) != CRYPT_OK)           { goto done; }
  ------------------
  |  |  565|   427k|#define mp_montgomery_reduce(a, b, c)   ltc_mp.montgomery_reduce(a, b, c)
  ------------------
  |  Branch (66:11): [True: 0, False: 427k]
  ------------------
   67|       |      /* X = X * T1 */
   68|   427k|      if ((err = mp_mul(t1, x, x)) != CRYPT_OK)                                { goto done; }
  ------------------
  |  |  547|   427k|#define mp_mul(a, b, c)              ltc_mp.mul(a, b, c)
  ------------------
  |  Branch (68:11): [True: 0, False: 427k]
  ------------------
   69|   427k|      if ((err = mp_montgomery_reduce(x, modulus, mp)) != CRYPT_OK)            { goto done; }
  ------------------
  |  |  565|   427k|#define mp_montgomery_reduce(a, b, c)   ltc_mp.montgomery_reduce(a, b, c)
  ------------------
  |  Branch (69:11): [True: 0, False: 427k]
  ------------------
   70|       |      /* T1 = Z' * T1 */
   71|   427k|      if ((err = mp_mul(Q->z, t1, t1)) != CRYPT_OK)                            { goto done; }
  ------------------
  |  |  547|   427k|#define mp_mul(a, b, c)              ltc_mp.mul(a, b, c)
  ------------------
  |  Branch (71:11): [True: 0, False: 427k]
  ------------------
   72|   427k|      if ((err = mp_montgomery_reduce(t1, modulus, mp)) != CRYPT_OK)           { goto done; }
  ------------------
  |  |  565|   427k|#define mp_montgomery_reduce(a, b, c)   ltc_mp.montgomery_reduce(a, b, c)
  ------------------
  |  Branch (72:11): [True: 0, False: 427k]
  ------------------
   73|       |      /* Y = Y * T1 */
   74|   427k|      if ((err = mp_mul(t1, y, y)) != CRYPT_OK)                                { goto done; }
  ------------------
  |  |  547|   427k|#define mp_mul(a, b, c)              ltc_mp.mul(a, b, c)
  ------------------
  |  Branch (74:11): [True: 0, False: 427k]
  ------------------
   75|   427k|      if ((err = mp_montgomery_reduce(y, modulus, mp)) != CRYPT_OK)            { goto done; }
  ------------------
  |  |  565|   427k|#define mp_montgomery_reduce(a, b, c)   ltc_mp.montgomery_reduce(a, b, c)
  ------------------
  |  Branch (75:11): [True: 0, False: 427k]
  ------------------
   76|   427k|   }
   77|       |
   78|       |   /* T1 = Z*Z */
   79|   427k|   if ((err = mp_sqr(z, t1)) != CRYPT_OK)                                      { goto done; }
  ------------------
  |  |  549|   427k|#define mp_sqr(a, b)                 ltc_mp.sqr(a, b)
  ------------------
  |  Branch (79:8): [True: 0, False: 427k]
  ------------------
   80|   427k|   if ((err = mp_montgomery_reduce(t1, modulus, mp)) != CRYPT_OK)              { goto done; }
  ------------------
  |  |  565|   427k|#define mp_montgomery_reduce(a, b, c)   ltc_mp.montgomery_reduce(a, b, c)
  ------------------
  |  Branch (80:8): [True: 0, False: 427k]
  ------------------
   81|       |   /* T2 = X' * T1 */
   82|   427k|   if ((err = mp_mul(Q->x, t1, t2)) != CRYPT_OK)                               { goto done; }
  ------------------
  |  |  547|   427k|#define mp_mul(a, b, c)              ltc_mp.mul(a, b, c)
  ------------------
  |  Branch (82:8): [True: 0, False: 427k]
  ------------------
   83|   427k|   if ((err = mp_montgomery_reduce(t2, modulus, mp)) != CRYPT_OK)              { goto done; }
  ------------------
  |  |  565|   427k|#define mp_montgomery_reduce(a, b, c)   ltc_mp.montgomery_reduce(a, b, c)
  ------------------
  |  Branch (83:8): [True: 0, False: 427k]
  ------------------
   84|       |   /* T1 = Z * T1 */
   85|   427k|   if ((err = mp_mul(z, t1, t1)) != CRYPT_OK)                                  { goto done; }
  ------------------
  |  |  547|   427k|#define mp_mul(a, b, c)              ltc_mp.mul(a, b, c)
  ------------------
  |  Branch (85:8): [True: 0, False: 427k]
  ------------------
   86|   427k|   if ((err = mp_montgomery_reduce(t1, modulus, mp)) != CRYPT_OK)              { goto done; }
  ------------------
  |  |  565|   427k|#define mp_montgomery_reduce(a, b, c)   ltc_mp.montgomery_reduce(a, b, c)
  ------------------
  |  Branch (86:8): [True: 0, False: 427k]
  ------------------
   87|       |   /* T1 = Y' * T1 */
   88|   427k|   if ((err = mp_mul(Q->y, t1, t1)) != CRYPT_OK)                               { goto done; }
  ------------------
  |  |  547|   427k|#define mp_mul(a, b, c)              ltc_mp.mul(a, b, c)
  ------------------
  |  Branch (88:8): [True: 0, False: 427k]
  ------------------
   89|   427k|   if ((err = mp_montgomery_reduce(t1, modulus, mp)) != CRYPT_OK)              { goto done; }
  ------------------
  |  |  565|   427k|#define mp_montgomery_reduce(a, b, c)   ltc_mp.montgomery_reduce(a, b, c)
  ------------------
  |  Branch (89:8): [True: 0, False: 427k]
  ------------------
   90|       |
   91|       |   /* Y = Y - T1 */
   92|   427k|   if ((err = mp_sub(y, t1, y)) != CRYPT_OK)                                   { goto done; }
  ------------------
  |  |  545|   427k|#define mp_sub(a, b, c)              ltc_mp.sub(a, b, c)
  ------------------
  |  Branch (92:8): [True: 0, False: 427k]
  ------------------
   93|   427k|   if (mp_cmp_d(y, 0) == LTC_MP_LT) {
  ------------------
  |  |  532|   427k|#define mp_cmp_d(a, b)               ltc_mp.compare_d(a, b)
  ------------------
                 if (mp_cmp_d(y, 0) == LTC_MP_LT) {
  ------------------
  |  |   12|   427k|#define LTC_MP_LT   -1
  ------------------
  |  Branch (93:8): [True: 199k, False: 227k]
  ------------------
   94|   199k|      if ((err = mp_add(y, modulus, y)) != CRYPT_OK)                           { goto done; }
  ------------------
  |  |  543|   199k|#define mp_add(a, b, c)              ltc_mp.add(a, b, c)
  ------------------
  |  Branch (94:11): [True: 0, False: 199k]
  ------------------
   95|   199k|   }
   96|       |   /* T1 = 2T1 */
   97|   427k|   if ((err = mp_add(t1, t1, t1)) != CRYPT_OK)                                 { goto done; }
  ------------------
  |  |  543|   427k|#define mp_add(a, b, c)              ltc_mp.add(a, b, c)
  ------------------
  |  Branch (97:8): [True: 0, False: 427k]
  ------------------
   98|   427k|   if (mp_cmp(t1, modulus) != LTC_MP_LT) {
  ------------------
  |  |  531|   427k|#define mp_cmp(a, b)                 ltc_mp.compare(a, b)
  ------------------
                 if (mp_cmp(t1, modulus) != LTC_MP_LT) {
  ------------------
  |  |   12|   427k|#define LTC_MP_LT   -1
  ------------------
  |  Branch (98:8): [True: 212k, False: 215k]
  ------------------
   99|   212k|      if ((err = mp_sub(t1, modulus, t1)) != CRYPT_OK)                         { goto done; }
  ------------------
  |  |  545|   212k|#define mp_sub(a, b, c)              ltc_mp.sub(a, b, c)
  ------------------
  |  Branch (99:11): [True: 0, False: 212k]
  ------------------
  100|   212k|   }
  101|       |   /* T1 = Y + T1 */
  102|   427k|   if ((err = mp_add(t1, y, t1)) != CRYPT_OK)                                  { goto done; }
  ------------------
  |  |  543|   427k|#define mp_add(a, b, c)              ltc_mp.add(a, b, c)
  ------------------
  |  Branch (102:8): [True: 0, False: 427k]
  ------------------
  103|   427k|   if (mp_cmp(t1, modulus) != LTC_MP_LT) {
  ------------------
  |  |  531|   427k|#define mp_cmp(a, b)                 ltc_mp.compare(a, b)
  ------------------
                 if (mp_cmp(t1, modulus) != LTC_MP_LT) {
  ------------------
  |  |   12|   427k|#define LTC_MP_LT   -1
  ------------------
  |  Branch (103:8): [True: 206k, False: 220k]
  ------------------
  104|   206k|      if ((err = mp_sub(t1, modulus, t1)) != CRYPT_OK)                         { goto done; }
  ------------------
  |  |  545|   206k|#define mp_sub(a, b, c)              ltc_mp.sub(a, b, c)
  ------------------
  |  Branch (104:11): [True: 0, False: 206k]
  ------------------
  105|   206k|   }
  106|       |   /* X = X - T2 */
  107|   427k|   if ((err = mp_sub(x, t2, x)) != CRYPT_OK)                                   { goto done; }
  ------------------
  |  |  545|   427k|#define mp_sub(a, b, c)              ltc_mp.sub(a, b, c)
  ------------------
  |  Branch (107:8): [True: 0, False: 427k]
  ------------------
  108|   427k|   if (mp_cmp_d(x, 0) == LTC_MP_LT) {
  ------------------
  |  |  532|   427k|#define mp_cmp_d(a, b)               ltc_mp.compare_d(a, b)
  ------------------
                 if (mp_cmp_d(x, 0) == LTC_MP_LT) {
  ------------------
  |  |   12|   427k|#define LTC_MP_LT   -1
  ------------------
  |  Branch (108:8): [True: 219k, False: 207k]
  ------------------
  109|   219k|      if ((err = mp_add(x, modulus, x)) != CRYPT_OK)                           { goto done; }
  ------------------
  |  |  543|   219k|#define mp_add(a, b, c)              ltc_mp.add(a, b, c)
  ------------------
  |  Branch (109:11): [True: 0, False: 219k]
  ------------------
  110|   219k|   }
  111|       |   /* T2 = 2T2 */
  112|   427k|   if ((err = mp_add(t2, t2, t2)) != CRYPT_OK)                                 { goto done; }
  ------------------
  |  |  543|   427k|#define mp_add(a, b, c)              ltc_mp.add(a, b, c)
  ------------------
  |  Branch (112:8): [True: 0, False: 427k]
  ------------------
  113|   427k|   if (mp_cmp(t2, modulus) != LTC_MP_LT) {
  ------------------
  |  |  531|   427k|#define mp_cmp(a, b)                 ltc_mp.compare(a, b)
  ------------------
                 if (mp_cmp(t2, modulus) != LTC_MP_LT) {
  ------------------
  |  |   12|   427k|#define LTC_MP_LT   -1
  ------------------
  |  Branch (113:8): [True: 204k, False: 222k]
  ------------------
  114|   204k|      if ((err = mp_sub(t2, modulus, t2)) != CRYPT_OK)                         { goto done; }
  ------------------
  |  |  545|   204k|#define mp_sub(a, b, c)              ltc_mp.sub(a, b, c)
  ------------------
  |  Branch (114:11): [True: 0, False: 204k]
  ------------------
  115|   204k|   }
  116|       |   /* T2 = X + T2 */
  117|   427k|   if ((err = mp_add(t2, x, t2)) != CRYPT_OK)                                  { goto done; }
  ------------------
  |  |  543|   427k|#define mp_add(a, b, c)              ltc_mp.add(a, b, c)
  ------------------
  |  Branch (117:8): [True: 0, False: 427k]
  ------------------
  118|   427k|   if (mp_cmp(t2, modulus) != LTC_MP_LT) {
  ------------------
  |  |  531|   427k|#define mp_cmp(a, b)                 ltc_mp.compare(a, b)
  ------------------
                 if (mp_cmp(t2, modulus) != LTC_MP_LT) {
  ------------------
  |  |   12|   427k|#define LTC_MP_LT   -1
  ------------------
  |  Branch (118:8): [True: 219k, False: 207k]
  ------------------
  119|   219k|      if ((err = mp_sub(t2, modulus, t2)) != CRYPT_OK)                         { goto done; }
  ------------------
  |  |  545|   219k|#define mp_sub(a, b, c)              ltc_mp.sub(a, b, c)
  ------------------
  |  Branch (119:11): [True: 0, False: 219k]
  ------------------
  120|   219k|   }
  121|       |
  122|       |   /* if Z' != 1 */
  123|   427k|   if (Q->z != NULL) {
  ------------------
  |  Branch (123:8): [True: 427k, False: 0]
  ------------------
  124|       |      /* Z = Z * Z' */
  125|   427k|      if ((err = mp_mul(z, Q->z, z)) != CRYPT_OK)                              { goto done; }
  ------------------
  |  |  547|   427k|#define mp_mul(a, b, c)              ltc_mp.mul(a, b, c)
  ------------------
  |  Branch (125:11): [True: 0, False: 427k]
  ------------------
  126|   427k|      if ((err = mp_montgomery_reduce(z, modulus, mp)) != CRYPT_OK)            { goto done; }
  ------------------
  |  |  565|   427k|#define mp_montgomery_reduce(a, b, c)   ltc_mp.montgomery_reduce(a, b, c)
  ------------------
  |  Branch (126:11): [True: 0, False: 427k]
  ------------------
  127|   427k|   }
  128|       |
  129|       |   /* Z = Z * X */
  130|   427k|   if ((err = mp_mul(z, x, z)) != CRYPT_OK)                                    { goto done; }
  ------------------
  |  |  547|   427k|#define mp_mul(a, b, c)              ltc_mp.mul(a, b, c)
  ------------------
  |  Branch (130:8): [True: 0, False: 427k]
  ------------------
  131|   427k|   if ((err = mp_montgomery_reduce(z, modulus, mp)) != CRYPT_OK)               { goto done; }
  ------------------
  |  |  565|   427k|#define mp_montgomery_reduce(a, b, c)   ltc_mp.montgomery_reduce(a, b, c)
  ------------------
  |  Branch (131:8): [True: 0, False: 427k]
  ------------------
  132|       |
  133|       |   /* T1 = T1 * X  */
  134|   427k|   if ((err = mp_mul(t1, x, t1)) != CRYPT_OK)                                  { goto done; }
  ------------------
  |  |  547|   427k|#define mp_mul(a, b, c)              ltc_mp.mul(a, b, c)
  ------------------
  |  Branch (134:8): [True: 0, False: 427k]
  ------------------
  135|   427k|   if ((err = mp_montgomery_reduce(t1, modulus, mp)) != CRYPT_OK)              { goto done; }
  ------------------
  |  |  565|   427k|#define mp_montgomery_reduce(a, b, c)   ltc_mp.montgomery_reduce(a, b, c)
  ------------------
  |  Branch (135:8): [True: 0, False: 427k]
  ------------------
  136|       |   /* X = X * X */
  137|   427k|   if ((err = mp_sqr(x, x)) != CRYPT_OK)                                       { goto done; }
  ------------------
  |  |  549|   427k|#define mp_sqr(a, b)                 ltc_mp.sqr(a, b)
  ------------------
  |  Branch (137:8): [True: 0, False: 427k]
  ------------------
  138|   427k|   if ((err = mp_montgomery_reduce(x, modulus, mp)) != CRYPT_OK)               { goto done; }
  ------------------
  |  |  565|   427k|#define mp_montgomery_reduce(a, b, c)   ltc_mp.montgomery_reduce(a, b, c)
  ------------------
  |  Branch (138:8): [True: 0, False: 427k]
  ------------------
  139|       |   /* T2 = T2 * x */
  140|   427k|   if ((err = mp_mul(t2, x, t2)) != CRYPT_OK)                                  { goto done; }
  ------------------
  |  |  547|   427k|#define mp_mul(a, b, c)              ltc_mp.mul(a, b, c)
  ------------------
  |  Branch (140:8): [True: 0, False: 427k]
  ------------------
  141|   427k|   if ((err = mp_montgomery_reduce(t2, modulus, mp)) != CRYPT_OK)              { goto done; }
  ------------------
  |  |  565|   427k|#define mp_montgomery_reduce(a, b, c)   ltc_mp.montgomery_reduce(a, b, c)
  ------------------
  |  Branch (141:8): [True: 0, False: 427k]
  ------------------
  142|       |   /* T1 = T1 * X  */
  143|   427k|   if ((err = mp_mul(t1, x, t1)) != CRYPT_OK)                                  { goto done; }
  ------------------
  |  |  547|   427k|#define mp_mul(a, b, c)              ltc_mp.mul(a, b, c)
  ------------------
  |  Branch (143:8): [True: 0, False: 427k]
  ------------------
  144|   427k|   if ((err = mp_montgomery_reduce(t1, modulus, mp)) != CRYPT_OK)              { goto done; }
  ------------------
  |  |  565|   427k|#define mp_montgomery_reduce(a, b, c)   ltc_mp.montgomery_reduce(a, b, c)
  ------------------
  |  Branch (144:8): [True: 0, False: 427k]
  ------------------
  145|       |
  146|       |   /* X = Y*Y */
  147|   427k|   if ((err = mp_sqr(y, x)) != CRYPT_OK)                                       { goto done; }
  ------------------
  |  |  549|   427k|#define mp_sqr(a, b)                 ltc_mp.sqr(a, b)
  ------------------
  |  Branch (147:8): [True: 0, False: 427k]
  ------------------
  148|   427k|   if ((err = mp_montgomery_reduce(x, modulus, mp)) != CRYPT_OK)               { goto done; }
  ------------------
  |  |  565|   427k|#define mp_montgomery_reduce(a, b, c)   ltc_mp.montgomery_reduce(a, b, c)
  ------------------
  |  Branch (148:8): [True: 0, False: 427k]
  ------------------
  149|       |   /* X = X - T2 */
  150|   427k|   if ((err = mp_sub(x, t2, x)) != CRYPT_OK)                                   { goto done; }
  ------------------
  |  |  545|   427k|#define mp_sub(a, b, c)              ltc_mp.sub(a, b, c)
  ------------------
  |  Branch (150:8): [True: 0, False: 427k]
  ------------------
  151|   427k|   if (mp_cmp_d(x, 0) == LTC_MP_LT) {
  ------------------
  |  |  532|   427k|#define mp_cmp_d(a, b)               ltc_mp.compare_d(a, b)
  ------------------
                 if (mp_cmp_d(x, 0) == LTC_MP_LT) {
  ------------------
  |  |   12|   427k|#define LTC_MP_LT   -1
  ------------------
  |  Branch (151:8): [True: 215k, False: 211k]
  ------------------
  152|   215k|      if ((err = mp_add(x, modulus, x)) != CRYPT_OK)                           { goto done; }
  ------------------
  |  |  543|   215k|#define mp_add(a, b, c)              ltc_mp.add(a, b, c)
  ------------------
  |  Branch (152:11): [True: 0, False: 215k]
  ------------------
  153|   215k|   }
  154|       |
  155|       |   /* T2 = T2 - X */
  156|   427k|   if ((err = mp_sub(t2, x, t2)) != CRYPT_OK)                                  { goto done; }
  ------------------
  |  |  545|   427k|#define mp_sub(a, b, c)              ltc_mp.sub(a, b, c)
  ------------------
  |  Branch (156:8): [True: 0, False: 427k]
  ------------------
  157|   427k|   if (mp_cmp_d(t2, 0) == LTC_MP_LT) {
  ------------------
  |  |  532|   427k|#define mp_cmp_d(a, b)               ltc_mp.compare_d(a, b)
  ------------------
                 if (mp_cmp_d(t2, 0) == LTC_MP_LT) {
  ------------------
  |  |   12|   427k|#define LTC_MP_LT   -1
  ------------------
  |  Branch (157:8): [True: 224k, False: 202k]
  ------------------
  158|   224k|      if ((err = mp_add(t2, modulus, t2)) != CRYPT_OK)                         { goto done; }
  ------------------
  |  |  543|   224k|#define mp_add(a, b, c)              ltc_mp.add(a, b, c)
  ------------------
  |  Branch (158:11): [True: 0, False: 224k]
  ------------------
  159|   224k|   }
  160|       |   /* T2 = T2 - X */
  161|   427k|   if ((err = mp_sub(t2, x, t2)) != CRYPT_OK)                                  { goto done; }
  ------------------
  |  |  545|   427k|#define mp_sub(a, b, c)              ltc_mp.sub(a, b, c)
  ------------------
  |  Branch (161:8): [True: 0, False: 427k]
  ------------------
  162|   427k|   if (mp_cmp_d(t2, 0) == LTC_MP_LT) {
  ------------------
  |  |  532|   427k|#define mp_cmp_d(a, b)               ltc_mp.compare_d(a, b)
  ------------------
                 if (mp_cmp_d(t2, 0) == LTC_MP_LT) {
  ------------------
  |  |   12|   427k|#define LTC_MP_LT   -1
  ------------------
  |  Branch (162:8): [True: 218k, False: 208k]
  ------------------
  163|   218k|      if ((err = mp_add(t2, modulus, t2)) != CRYPT_OK)                         { goto done; }
  ------------------
  |  |  543|   218k|#define mp_add(a, b, c)              ltc_mp.add(a, b, c)
  ------------------
  |  Branch (163:11): [True: 0, False: 218k]
  ------------------
  164|   218k|   }
  165|       |   /* T2 = T2 * Y */
  166|   427k|   if ((err = mp_mul(t2, y, t2)) != CRYPT_OK)                                  { goto done; }
  ------------------
  |  |  547|   427k|#define mp_mul(a, b, c)              ltc_mp.mul(a, b, c)
  ------------------
  |  Branch (166:8): [True: 0, False: 427k]
  ------------------
  167|   427k|   if ((err = mp_montgomery_reduce(t2, modulus, mp)) != CRYPT_OK)              { goto done; }
  ------------------
  |  |  565|   427k|#define mp_montgomery_reduce(a, b, c)   ltc_mp.montgomery_reduce(a, b, c)
  ------------------
  |  Branch (167:8): [True: 0, False: 427k]
  ------------------
  168|       |   /* Y = T2 - T1 */
  169|   427k|   if ((err = mp_sub(t2, t1, y)) != CRYPT_OK)                                  { goto done; }
  ------------------
  |  |  545|   427k|#define mp_sub(a, b, c)              ltc_mp.sub(a, b, c)
  ------------------
  |  Branch (169:8): [True: 0, False: 427k]
  ------------------
  170|   427k|   if (mp_cmp_d(y, 0) == LTC_MP_LT) {
  ------------------
  |  |  532|   427k|#define mp_cmp_d(a, b)               ltc_mp.compare_d(a, b)
  ------------------
                 if (mp_cmp_d(y, 0) == LTC_MP_LT) {
  ------------------
  |  |   12|   427k|#define LTC_MP_LT   -1
  ------------------
  |  Branch (170:8): [True: 224k, False: 202k]
  ------------------
  171|   224k|      if ((err = mp_add(y, modulus, y)) != CRYPT_OK)                           { goto done; }
  ------------------
  |  |  543|   224k|#define mp_add(a, b, c)              ltc_mp.add(a, b, c)
  ------------------
  |  Branch (171:11): [True: 0, False: 224k]
  ------------------
  172|   224k|   }
  173|       |   /* Y = Y/2 */
  174|   427k|   if (mp_isodd(y)) {
  ------------------
  |  |  572|   427k|#define mp_isodd(a)                  (mp_get_digit_count(a) > 0 ? (mp_get_digit(a, 0) & 1 ? LTC_MP_YES : LTC_MP_NO) : LTC_MP_NO)
  |  |  ------------------
  |  |  |  |  530|   427k|#define mp_get_digit_count(a)        ltc_mp.get_digit_count(a)
  |  |  ------------------
  |  |               #define mp_isodd(a)                  (mp_get_digit_count(a) > 0 ? (mp_get_digit(a, 0) & 1 ? LTC_MP_YES : LTC_MP_NO) : LTC_MP_NO)
  |  |  ------------------
  |  |  |  |  529|   427k|#define mp_get_digit(a, n)           ltc_mp.get_digit(a, n)
  |  |  ------------------
  |  |               #define mp_isodd(a)                  (mp_get_digit_count(a) > 0 ? (mp_get_digit(a, 0) & 1 ? LTC_MP_YES : LTC_MP_NO) : LTC_MP_NO)
  |  |  ------------------
  |  |  |  |   17|   210k|#define LTC_MP_YES   1
  |  |  ------------------
  |  |               #define mp_isodd(a)                  (mp_get_digit_count(a) > 0 ? (mp_get_digit(a, 0) & 1 ? LTC_MP_YES : LTC_MP_NO) : LTC_MP_NO)
  |  |  ------------------
  |  |  |  |   16|   216k|#define LTC_MP_NO    0
  |  |  ------------------
  |  |               #define mp_isodd(a)                  (mp_get_digit_count(a) > 0 ? (mp_get_digit(a, 0) & 1 ? LTC_MP_YES : LTC_MP_NO) : LTC_MP_NO)
  |  |  ------------------
  |  |  |  |   16|      0|#define LTC_MP_NO    0
  |  |  ------------------
  |  |  |  Branch (572:38): [True: 210k, False: 216k]
  |  |  |  Branch (572:39): [True: 427k, False: 0]
  |  |  |  Branch (572:68): [True: 210k, False: 216k]
  |  |  ------------------
  ------------------
  175|   210k|      if ((err = mp_add(y, modulus, y)) != CRYPT_OK)                           { goto done; }
  ------------------
  |  |  543|   210k|#define mp_add(a, b, c)              ltc_mp.add(a, b, c)
  ------------------
  |  Branch (175:11): [True: 0, False: 210k]
  ------------------
  176|   210k|   }
  177|   427k|   if ((err = mp_div_2(y, y)) != CRYPT_OK)                                     { goto done; }
  ------------------
  |  |  551|   427k|#define mp_div_2(a, b)               ltc_mp.div_2(a, b)
  ------------------
  |  Branch (177:8): [True: 0, False: 427k]
  ------------------
  178|       |
  179|   427k|   if ((err = mp_copy(x, R->x)) != CRYPT_OK)                                   { goto done; }
  ------------------
  |  |  524|   427k|#define mp_copy(a, b)                ltc_mp.copy(a, b)
  ------------------
  |  Branch (179:8): [True: 0, False: 427k]
  ------------------
  180|   427k|   if ((err = mp_copy(y, R->y)) != CRYPT_OK)                                   { goto done; }
  ------------------
  |  |  524|   427k|#define mp_copy(a, b)                ltc_mp.copy(a, b)
  ------------------
  |  Branch (180:8): [True: 0, False: 427k]
  ------------------
  181|   427k|   if ((err = mp_copy(z, R->z)) != CRYPT_OK)                                   { goto done; }
  ------------------
  |  |  524|   427k|#define mp_copy(a, b)                ltc_mp.copy(a, b)
  ------------------
  |  Branch (181:8): [True: 0, False: 427k]
  ------------------
  182|       |
  183|   427k|   err = CRYPT_OK;
  184|   427k|done:
  185|   427k|   mp_clear_multi(t1, t2, x, y, z, NULL);
  ------------------
  |  |  519|   427k|#define mp_clear_multi               ltc_deinit_multi
  ------------------
  186|   427k|   return err;
  187|   427k|}

ltc_ecc_projective_dbl_point:
   33|   442k|{
   34|   442k|   void *t1, *t2;
   35|   442k|   int   err;
   36|       |
   37|   442k|   LTC_ARGCHK(P       != NULL);
  ------------------
  |  |   32|   442k|#define LTC_ARGCHK(x) do { if (!(x)) { crypt_argchk(#x, __FILE__, __LINE__); } }while(0)
  |  |  ------------------
  |  |  |  Branch (32:32): [True: 0, False: 442k]
  |  |  |  Branch (32:87): [Folded, False: 442k]
  |  |  ------------------
  ------------------
   38|   442k|   LTC_ARGCHK(R       != NULL);
  ------------------
  |  |   32|   442k|#define LTC_ARGCHK(x) do { if (!(x)) { crypt_argchk(#x, __FILE__, __LINE__); } }while(0)
  |  |  ------------------
  |  |  |  Branch (32:32): [True: 0, False: 442k]
  |  |  |  Branch (32:87): [Folded, False: 442k]
  |  |  ------------------
  ------------------
   39|   442k|   LTC_ARGCHK(modulus != NULL);
  ------------------
  |  |   32|   442k|#define LTC_ARGCHK(x) do { if (!(x)) { crypt_argchk(#x, __FILE__, __LINE__); } }while(0)
  |  |  ------------------
  |  |  |  Branch (32:32): [True: 0, False: 442k]
  |  |  |  Branch (32:87): [Folded, False: 442k]
  |  |  ------------------
  ------------------
   40|   442k|   LTC_ARGCHK(mp      != NULL);
  ------------------
  |  |   32|   442k|#define LTC_ARGCHK(x) do { if (!(x)) { crypt_argchk(#x, __FILE__, __LINE__); } }while(0)
  |  |  ------------------
  |  |  |  Branch (32:32): [True: 0, False: 442k]
  |  |  |  Branch (32:87): [Folded, False: 442k]
  |  |  ------------------
  ------------------
   41|       |
   42|   442k|   if ((err = mp_init_multi(&t1, &t2, NULL)) != CRYPT_OK) {
  ------------------
  |  |  517|   442k|#define mp_init_multi                ltc_init_multi
  ------------------
  |  Branch (42:8): [True: 0, False: 442k]
  ------------------
   43|      0|      return err;
   44|      0|   }
   45|       |
   46|   442k|   if (P != R) {
  ------------------
  |  Branch (46:8): [True: 22.4k, False: 419k]
  ------------------
   47|  22.4k|      if ((err = mp_copy(P->x, R->x)) != CRYPT_OK)                                { goto done; }
  ------------------
  |  |  524|  22.4k|#define mp_copy(a, b)                ltc_mp.copy(a, b)
  ------------------
  |  Branch (47:11): [True: 0, False: 22.4k]
  ------------------
   48|  22.4k|      if ((err = mp_copy(P->y, R->y)) != CRYPT_OK)                                { goto done; }
  ------------------
  |  |  524|  22.4k|#define mp_copy(a, b)                ltc_mp.copy(a, b)
  ------------------
  |  Branch (48:11): [True: 0, False: 22.4k]
  ------------------
   49|  22.4k|      if ((err = mp_copy(P->z, R->z)) != CRYPT_OK)                                { goto done; }
  ------------------
  |  |  524|  22.4k|#define mp_copy(a, b)                ltc_mp.copy(a, b)
  ------------------
  |  Branch (49:11): [True: 0, False: 22.4k]
  ------------------
   50|  22.4k|   }
   51|       |
   52|       |   /* t1 = Z * Z */
   53|   442k|   if ((err = mp_sqr(R->z, t1)) != CRYPT_OK)                                      { goto done; }
  ------------------
  |  |  549|   442k|#define mp_sqr(a, b)                 ltc_mp.sqr(a, b)
  ------------------
  |  Branch (53:8): [True: 0, False: 442k]
  ------------------
   54|   442k|   if ((err = mp_montgomery_reduce(t1, modulus, mp)) != CRYPT_OK)                 { goto done; }
  ------------------
  |  |  565|   442k|#define mp_montgomery_reduce(a, b, c)   ltc_mp.montgomery_reduce(a, b, c)
  ------------------
  |  Branch (54:8): [True: 0, False: 442k]
  ------------------
   55|       |   /* Z = Y * Z */
   56|   442k|   if ((err = mp_mul(R->z, R->y, R->z)) != CRYPT_OK)                              { goto done; }
  ------------------
  |  |  547|   442k|#define mp_mul(a, b, c)              ltc_mp.mul(a, b, c)
  ------------------
  |  Branch (56:8): [True: 0, False: 442k]
  ------------------
   57|   442k|   if ((err = mp_montgomery_reduce(R->z, modulus, mp)) != CRYPT_OK)               { goto done; }
  ------------------
  |  |  565|   442k|#define mp_montgomery_reduce(a, b, c)   ltc_mp.montgomery_reduce(a, b, c)
  ------------------
  |  Branch (57:8): [True: 0, False: 442k]
  ------------------
   58|       |   /* Z = 2Z */
   59|   442k|   if ((err = mp_add(R->z, R->z, R->z)) != CRYPT_OK)                              { goto done; }
  ------------------
  |  |  543|   442k|#define mp_add(a, b, c)              ltc_mp.add(a, b, c)
  ------------------
  |  Branch (59:8): [True: 0, False: 442k]
  ------------------
   60|   442k|   if (mp_cmp(R->z, modulus) != LTC_MP_LT) {
  ------------------
  |  |  531|   442k|#define mp_cmp(a, b)                 ltc_mp.compare(a, b)
  ------------------
                 if (mp_cmp(R->z, modulus) != LTC_MP_LT) {
  ------------------
  |  |   12|   442k|#define LTC_MP_LT   -1
  ------------------
  |  Branch (60:8): [True: 218k, False: 223k]
  ------------------
   61|   218k|      if ((err = mp_sub(R->z, modulus, R->z)) != CRYPT_OK)                        { goto done; }
  ------------------
  |  |  545|   218k|#define mp_sub(a, b, c)              ltc_mp.sub(a, b, c)
  ------------------
  |  Branch (61:11): [True: 0, False: 218k]
  ------------------
   62|   218k|   }
   63|       |
   64|       |   /* T2 = X - T1 */
   65|   442k|   if ((err = mp_sub(R->x, t1, t2)) != CRYPT_OK)                                  { goto done; }
  ------------------
  |  |  545|   442k|#define mp_sub(a, b, c)              ltc_mp.sub(a, b, c)
  ------------------
  |  Branch (65:8): [True: 0, False: 442k]
  ------------------
   66|   442k|   if (mp_cmp_d(t2, 0) == LTC_MP_LT) {
  ------------------
  |  |  532|   442k|#define mp_cmp_d(a, b)               ltc_mp.compare_d(a, b)
  ------------------
                 if (mp_cmp_d(t2, 0) == LTC_MP_LT) {
  ------------------
  |  |   12|   442k|#define LTC_MP_LT   -1
  ------------------
  |  Branch (66:8): [True: 213k, False: 229k]
  ------------------
   67|   213k|      if ((err = mp_add(t2, modulus, t2)) != CRYPT_OK)                            { goto done; }
  ------------------
  |  |  543|   213k|#define mp_add(a, b, c)              ltc_mp.add(a, b, c)
  ------------------
  |  Branch (67:11): [True: 0, False: 213k]
  ------------------
   68|   213k|   }
   69|       |   /* T1 = X + T1 */
   70|   442k|   if ((err = mp_add(t1, R->x, t1)) != CRYPT_OK)                                  { goto done; }
  ------------------
  |  |  543|   442k|#define mp_add(a, b, c)              ltc_mp.add(a, b, c)
  ------------------
  |  Branch (70:8): [True: 0, False: 442k]
  ------------------
   71|   442k|   if (mp_cmp(t1, modulus) != LTC_MP_LT) {
  ------------------
  |  |  531|   442k|#define mp_cmp(a, b)                 ltc_mp.compare(a, b)
  ------------------
                 if (mp_cmp(t1, modulus) != LTC_MP_LT) {
  ------------------
  |  |   12|   442k|#define LTC_MP_LT   -1
  ------------------
  |  Branch (71:8): [True: 211k, False: 231k]
  ------------------
   72|   211k|      if ((err = mp_sub(t1, modulus, t1)) != CRYPT_OK)                            { goto done; }
  ------------------
  |  |  545|   211k|#define mp_sub(a, b, c)              ltc_mp.sub(a, b, c)
  ------------------
  |  Branch (72:11): [True: 0, False: 211k]
  ------------------
   73|   211k|   }
   74|       |   /* T2 = T1 * T2 */
   75|   442k|   if ((err = mp_mul(t1, t2, t2)) != CRYPT_OK)                                    { goto done; }
  ------------------
  |  |  547|   442k|#define mp_mul(a, b, c)              ltc_mp.mul(a, b, c)
  ------------------
  |  Branch (75:8): [True: 0, False: 442k]
  ------------------
   76|   442k|   if ((err = mp_montgomery_reduce(t2, modulus, mp)) != CRYPT_OK)                 { goto done; }
  ------------------
  |  |  565|   442k|#define mp_montgomery_reduce(a, b, c)   ltc_mp.montgomery_reduce(a, b, c)
  ------------------
  |  Branch (76:8): [True: 0, False: 442k]
  ------------------
   77|       |   /* T1 = 2T2 */
   78|   442k|   if ((err = mp_add(t2, t2, t1)) != CRYPT_OK)                                    { goto done; }
  ------------------
  |  |  543|   442k|#define mp_add(a, b, c)              ltc_mp.add(a, b, c)
  ------------------
  |  Branch (78:8): [True: 0, False: 442k]
  ------------------
   79|   442k|   if (mp_cmp(t1, modulus) != LTC_MP_LT) {
  ------------------
  |  |  531|   442k|#define mp_cmp(a, b)                 ltc_mp.compare(a, b)
  ------------------
                 if (mp_cmp(t1, modulus) != LTC_MP_LT) {
  ------------------
  |  |   12|   442k|#define LTC_MP_LT   -1
  ------------------
  |  Branch (79:8): [True: 222k, False: 220k]
  ------------------
   80|   222k|      if ((err = mp_sub(t1, modulus, t1)) != CRYPT_OK)                            { goto done; }
  ------------------
  |  |  545|   222k|#define mp_sub(a, b, c)              ltc_mp.sub(a, b, c)
  ------------------
  |  Branch (80:11): [True: 0, False: 222k]
  ------------------
   81|   222k|   }
   82|       |   /* T1 = T1 + T2 */
   83|   442k|   if ((err = mp_add(t1, t2, t1)) != CRYPT_OK)                                    { goto done; }
  ------------------
  |  |  543|   442k|#define mp_add(a, b, c)              ltc_mp.add(a, b, c)
  ------------------
  |  Branch (83:8): [True: 0, False: 442k]
  ------------------
   84|   442k|   if (mp_cmp(t1, modulus) != LTC_MP_LT) {
  ------------------
  |  |  531|   442k|#define mp_cmp(a, b)                 ltc_mp.compare(a, b)
  ------------------
                 if (mp_cmp(t1, modulus) != LTC_MP_LT) {
  ------------------
  |  |   12|   442k|#define LTC_MP_LT   -1
  ------------------
  |  Branch (84:8): [True: 207k, False: 234k]
  ------------------
   85|   207k|      if ((err = mp_sub(t1, modulus, t1)) != CRYPT_OK)                            { goto done; }
  ------------------
  |  |  545|   207k|#define mp_sub(a, b, c)              ltc_mp.sub(a, b, c)
  ------------------
  |  Branch (85:11): [True: 0, False: 207k]
  ------------------
   86|   207k|   }
   87|       |
   88|       |   /* Y = 2Y */
   89|   442k|   if ((err = mp_add(R->y, R->y, R->y)) != CRYPT_OK)                              { goto done; }
  ------------------
  |  |  543|   442k|#define mp_add(a, b, c)              ltc_mp.add(a, b, c)
  ------------------
  |  Branch (89:8): [True: 0, False: 442k]
  ------------------
   90|   442k|   if (mp_cmp(R->y, modulus) != LTC_MP_LT) {
  ------------------
  |  |  531|   442k|#define mp_cmp(a, b)                 ltc_mp.compare(a, b)
  ------------------
                 if (mp_cmp(R->y, modulus) != LTC_MP_LT) {
  ------------------
  |  |   12|   442k|#define LTC_MP_LT   -1
  ------------------
  |  Branch (90:8): [True: 222k, False: 219k]
  ------------------
   91|   222k|      if ((err = mp_sub(R->y, modulus, R->y)) != CRYPT_OK)                        { goto done; }
  ------------------
  |  |  545|   222k|#define mp_sub(a, b, c)              ltc_mp.sub(a, b, c)
  ------------------
  |  Branch (91:11): [True: 0, False: 222k]
  ------------------
   92|   222k|   }
   93|       |   /* Y = Y * Y */
   94|   442k|   if ((err = mp_sqr(R->y, R->y)) != CRYPT_OK)                                    { goto done; }
  ------------------
  |  |  549|   442k|#define mp_sqr(a, b)                 ltc_mp.sqr(a, b)
  ------------------
  |  Branch (94:8): [True: 0, False: 442k]
  ------------------
   95|   442k|   if ((err = mp_montgomery_reduce(R->y, modulus, mp)) != CRYPT_OK)               { goto done; }
  ------------------
  |  |  565|   442k|#define mp_montgomery_reduce(a, b, c)   ltc_mp.montgomery_reduce(a, b, c)
  ------------------
  |  Branch (95:8): [True: 0, False: 442k]
  ------------------
   96|       |   /* T2 = Y * Y */
   97|   442k|   if ((err = mp_sqr(R->y, t2)) != CRYPT_OK)                                      { goto done; }
  ------------------
  |  |  549|   442k|#define mp_sqr(a, b)                 ltc_mp.sqr(a, b)
  ------------------
  |  Branch (97:8): [True: 0, False: 442k]
  ------------------
   98|   442k|   if ((err = mp_montgomery_reduce(t2, modulus, mp)) != CRYPT_OK)                 { goto done; }
  ------------------
  |  |  565|   442k|#define mp_montgomery_reduce(a, b, c)   ltc_mp.montgomery_reduce(a, b, c)
  ------------------
  |  Branch (98:8): [True: 0, False: 442k]
  ------------------
   99|       |   /* T2 = T2/2 */
  100|   442k|   if (mp_isodd(t2)) {
  ------------------
  |  |  572|   442k|#define mp_isodd(a)                  (mp_get_digit_count(a) > 0 ? (mp_get_digit(a, 0) & 1 ? LTC_MP_YES : LTC_MP_NO) : LTC_MP_NO)
  |  |  ------------------
  |  |  |  |  530|   442k|#define mp_get_digit_count(a)        ltc_mp.get_digit_count(a)
  |  |  ------------------
  |  |               #define mp_isodd(a)                  (mp_get_digit_count(a) > 0 ? (mp_get_digit(a, 0) & 1 ? LTC_MP_YES : LTC_MP_NO) : LTC_MP_NO)
  |  |  ------------------
  |  |  |  |  529|   442k|#define mp_get_digit(a, n)           ltc_mp.get_digit(a, n)
  |  |  ------------------
  |  |               #define mp_isodd(a)                  (mp_get_digit_count(a) > 0 ? (mp_get_digit(a, 0) & 1 ? LTC_MP_YES : LTC_MP_NO) : LTC_MP_NO)
  |  |  ------------------
  |  |  |  |   17|   205k|#define LTC_MP_YES   1
  |  |  ------------------
  |  |               #define mp_isodd(a)                  (mp_get_digit_count(a) > 0 ? (mp_get_digit(a, 0) & 1 ? LTC_MP_YES : LTC_MP_NO) : LTC_MP_NO)
  |  |  ------------------
  |  |  |  |   16|   236k|#define LTC_MP_NO    0
  |  |  ------------------
  |  |               #define mp_isodd(a)                  (mp_get_digit_count(a) > 0 ? (mp_get_digit(a, 0) & 1 ? LTC_MP_YES : LTC_MP_NO) : LTC_MP_NO)
  |  |  ------------------
  |  |  |  |   16|      0|#define LTC_MP_NO    0
  |  |  ------------------
  |  |  |  Branch (572:38): [True: 205k, False: 236k]
  |  |  |  Branch (572:39): [True: 442k, False: 0]
  |  |  |  Branch (572:68): [True: 205k, False: 236k]
  |  |  ------------------
  ------------------
  101|   205k|      if ((err = mp_add(t2, modulus, t2)) != CRYPT_OK)                            { goto done; }
  ------------------
  |  |  543|   205k|#define mp_add(a, b, c)              ltc_mp.add(a, b, c)
  ------------------
  |  Branch (101:11): [True: 0, False: 205k]
  ------------------
  102|   205k|   }
  103|   442k|   if ((err = mp_div_2(t2, t2)) != CRYPT_OK)                                      { goto done; }
  ------------------
  |  |  551|   442k|#define mp_div_2(a, b)               ltc_mp.div_2(a, b)
  ------------------
  |  Branch (103:8): [True: 0, False: 442k]
  ------------------
  104|       |   /* Y = Y * X */
  105|   442k|   if ((err = mp_mul(R->y, R->x, R->y)) != CRYPT_OK)                              { goto done; }
  ------------------
  |  |  547|   442k|#define mp_mul(a, b, c)              ltc_mp.mul(a, b, c)
  ------------------
  |  Branch (105:8): [True: 0, False: 442k]
  ------------------
  106|   442k|   if ((err = mp_montgomery_reduce(R->y, modulus, mp)) != CRYPT_OK)               { goto done; }
  ------------------
  |  |  565|   442k|#define mp_montgomery_reduce(a, b, c)   ltc_mp.montgomery_reduce(a, b, c)
  ------------------
  |  Branch (106:8): [True: 0, False: 442k]
  ------------------
  107|       |
  108|       |   /* X  = T1 * T1 */
  109|   442k|   if ((err = mp_sqr(t1, R->x)) != CRYPT_OK)                                      { goto done; }
  ------------------
  |  |  549|   442k|#define mp_sqr(a, b)                 ltc_mp.sqr(a, b)
  ------------------
  |  Branch (109:8): [True: 0, False: 442k]
  ------------------
  110|   442k|   if ((err = mp_montgomery_reduce(R->x, modulus, mp)) != CRYPT_OK)               { goto done; }
  ------------------
  |  |  565|   442k|#define mp_montgomery_reduce(a, b, c)   ltc_mp.montgomery_reduce(a, b, c)
  ------------------
  |  Branch (110:8): [True: 0, False: 442k]
  ------------------
  111|       |   /* X = X - Y */
  112|   442k|   if ((err = mp_sub(R->x, R->y, R->x)) != CRYPT_OK)                              { goto done; }
  ------------------
  |  |  545|   442k|#define mp_sub(a, b, c)              ltc_mp.sub(a, b, c)
  ------------------
  |  Branch (112:8): [True: 0, False: 442k]
  ------------------
  113|   442k|   if (mp_cmp_d(R->x, 0) == LTC_MP_LT) {
  ------------------
  |  |  532|   442k|#define mp_cmp_d(a, b)               ltc_mp.compare_d(a, b)
  ------------------
                 if (mp_cmp_d(R->x, 0) == LTC_MP_LT) {
  ------------------
  |  |   12|   442k|#define LTC_MP_LT   -1
  ------------------
  |  Branch (113:8): [True: 209k, False: 233k]
  ------------------
  114|   209k|      if ((err = mp_add(R->x, modulus, R->x)) != CRYPT_OK)                        { goto done; }
  ------------------
  |  |  543|   209k|#define mp_add(a, b, c)              ltc_mp.add(a, b, c)
  ------------------
  |  Branch (114:11): [True: 0, False: 209k]
  ------------------
  115|   209k|   }
  116|       |   /* X = X - Y */
  117|   442k|   if ((err = mp_sub(R->x, R->y, R->x)) != CRYPT_OK)                              { goto done; }
  ------------------
  |  |  545|   442k|#define mp_sub(a, b, c)              ltc_mp.sub(a, b, c)
  ------------------
  |  Branch (117:8): [True: 0, False: 442k]
  ------------------
  118|   442k|   if (mp_cmp_d(R->x, 0) == LTC_MP_LT) {
  ------------------
  |  |  532|   442k|#define mp_cmp_d(a, b)               ltc_mp.compare_d(a, b)
  ------------------
                 if (mp_cmp_d(R->x, 0) == LTC_MP_LT) {
  ------------------
  |  |   12|   442k|#define LTC_MP_LT   -1
  ------------------
  |  Branch (118:8): [True: 212k, False: 230k]
  ------------------
  119|   212k|      if ((err = mp_add(R->x, modulus, R->x)) != CRYPT_OK)                        { goto done; }
  ------------------
  |  |  543|   212k|#define mp_add(a, b, c)              ltc_mp.add(a, b, c)
  ------------------
  |  Branch (119:11): [True: 0, False: 212k]
  ------------------
  120|   212k|   }
  121|       |
  122|       |   /* Y = Y - X */
  123|   442k|   if ((err = mp_sub(R->y, R->x, R->y)) != CRYPT_OK)                              { goto done; }
  ------------------
  |  |  545|   442k|#define mp_sub(a, b, c)              ltc_mp.sub(a, b, c)
  ------------------
  |  Branch (123:8): [True: 0, False: 442k]
  ------------------
  124|   442k|   if (mp_cmp_d(R->y, 0) == LTC_MP_LT) {
  ------------------
  |  |  532|   442k|#define mp_cmp_d(a, b)               ltc_mp.compare_d(a, b)
  ------------------
                 if (mp_cmp_d(R->y, 0) == LTC_MP_LT) {
  ------------------
  |  |   12|   442k|#define LTC_MP_LT   -1
  ------------------
  |  Branch (124:8): [True: 228k, False: 213k]
  ------------------
  125|   228k|      if ((err = mp_add(R->y, modulus, R->y)) != CRYPT_OK)                        { goto done; }
  ------------------
  |  |  543|   228k|#define mp_add(a, b, c)              ltc_mp.add(a, b, c)
  ------------------
  |  Branch (125:11): [True: 0, False: 228k]
  ------------------
  126|   228k|   }
  127|       |   /* Y = Y * T1 */
  128|   442k|   if ((err = mp_mul(R->y, t1, R->y)) != CRYPT_OK)                                { goto done; }
  ------------------
  |  |  547|   442k|#define mp_mul(a, b, c)              ltc_mp.mul(a, b, c)
  ------------------
  |  Branch (128:8): [True: 0, False: 442k]
  ------------------
  129|   442k|   if ((err = mp_montgomery_reduce(R->y, modulus, mp)) != CRYPT_OK)               { goto done; }
  ------------------
  |  |  565|   442k|#define mp_montgomery_reduce(a, b, c)   ltc_mp.montgomery_reduce(a, b, c)
  ------------------
  |  Branch (129:8): [True: 0, False: 442k]
  ------------------
  130|       |   /* Y = Y - T2 */
  131|   442k|   if ((err = mp_sub(R->y, t2, R->y)) != CRYPT_OK)                                { goto done; }
  ------------------
  |  |  545|   442k|#define mp_sub(a, b, c)              ltc_mp.sub(a, b, c)
  ------------------
  |  Branch (131:8): [True: 0, False: 442k]
  ------------------
  132|   442k|   if (mp_cmp_d(R->y, 0) == LTC_MP_LT) {
  ------------------
  |  |  532|   442k|#define mp_cmp_d(a, b)               ltc_mp.compare_d(a, b)
  ------------------
                 if (mp_cmp_d(R->y, 0) == LTC_MP_LT) {
  ------------------
  |  |   12|   442k|#define LTC_MP_LT   -1
  ------------------
  |  Branch (132:8): [True: 214k, False: 228k]
  ------------------
  133|   214k|      if ((err = mp_add(R->y, modulus, R->y)) != CRYPT_OK)                        { goto done; }
  ------------------
  |  |  543|   214k|#define mp_add(a, b, c)              ltc_mp.add(a, b, c)
  ------------------
  |  Branch (133:11): [True: 0, False: 214k]
  ------------------
  134|   214k|   }
  135|       |
  136|   442k|   err = CRYPT_OK;
  137|   442k|done:
  138|   442k|   mp_clear_multi(t1, t2, NULL);
  ------------------
  |  |  519|   442k|#define mp_clear_multi               ltc_deinit_multi
  ------------------
  139|   442k|   return err;
  140|   442k|}

mp_2expt:
   12|  3.69k|{
   13|  3.69k|   mp_err    err;
   14|       |
   15|  3.69k|   if (b < 0) {
  ------------------
  |  Branch (15:8): [True: 0, False: 3.69k]
  ------------------
   16|      0|      return MP_VAL;
  ------------------
  |  |  164|      0|#define MP_VAL        -3  /* invalid input */
  ------------------
   17|      0|   }
   18|       |
   19|       |   /* zero a as per default */
   20|  3.69k|   mp_zero(a);
   21|       |
   22|       |   /* grow a to accomodate the single bit */
   23|  3.69k|   if ((err = mp_grow(a, (b / MP_DIGIT_BIT) + 1)) != MP_OKAY) {
  ------------------
  |  |   82|  3.69k|#   define MP_DIGIT_BIT 60
  ------------------
                 if ((err = mp_grow(a, (b / MP_DIGIT_BIT) + 1)) != MP_OKAY) {
  ------------------
  |  |  161|  3.69k|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (23:8): [True: 0, False: 3.69k]
  ------------------
   24|      0|      return err;
   25|      0|   }
   26|       |
   27|       |   /* set the used count of where the bit will go */
   28|  3.69k|   a->used = (b / MP_DIGIT_BIT) + 1;
  ------------------
  |  |   82|  3.69k|#   define MP_DIGIT_BIT 60
  ------------------
   29|       |
   30|       |   /* put the single bit in its place */
   31|  3.69k|   a->dp[b / MP_DIGIT_BIT] = (mp_digit)1 << (mp_digit)(b % MP_DIGIT_BIT);
  ------------------
  |  |   82|  3.69k|#   define MP_DIGIT_BIT 60
  ------------------
                 a->dp[b / MP_DIGIT_BIT] = (mp_digit)1 << (mp_digit)(b % MP_DIGIT_BIT);
  ------------------
  |  |   82|  3.69k|#   define MP_DIGIT_BIT 60
  ------------------
   32|       |
   33|  3.69k|   return MP_OKAY;
  ------------------
  |  |  161|  3.69k|#define MP_OKAY       0   /* no error */
  ------------------
   34|  3.69k|}

mp_add:
    8|  6.72M|{
    9|  6.72M|   mp_sign sa, sb;
   10|  6.72M|   mp_err err;
   11|       |
   12|       |   /* get sign of both inputs */
   13|  6.72M|   sa = a->sign;
   14|  6.72M|   sb = b->sign;
   15|       |
   16|       |   /* handle two cases, not four */
   17|  6.72M|   if (sa == sb) {
  ------------------
  |  Branch (17:8): [True: 4.34M, False: 2.38M]
  ------------------
   18|       |      /* both positive or both negative */
   19|       |      /* add their magnitudes, copy the sign */
   20|  4.34M|      c->sign = sa;
   21|  4.34M|      err = s_mp_add(a, b, c);
   22|  4.34M|   } else {
   23|       |      /* one positive, the other negative */
   24|       |      /* subtract the one with the greater magnitude from */
   25|       |      /* the one of the lesser magnitude.  The result gets */
   26|       |      /* the sign of the one with the greater magnitude. */
   27|  2.38M|      if (mp_cmp_mag(a, b) == MP_LT) {
  ------------------
  |  |  154|  2.38M|#define MP_LT        -1   /* less than */
  ------------------
  |  Branch (27:11): [True: 2.38M, False: 410]
  ------------------
   28|  2.38M|         c->sign = sb;
   29|  2.38M|         err = s_mp_sub(b, a, c);
   30|  2.38M|      } else {
   31|    410|         c->sign = sa;
   32|    410|         err = s_mp_sub(a, b, c);
   33|    410|      }
   34|  2.38M|   }
   35|  6.72M|   return err;
   36|  6.72M|}

mp_add_d:
    8|   441k|{
    9|   441k|   mp_err     err;
   10|   441k|   int ix, oldused;
   11|   441k|   mp_digit *tmpa, *tmpc;
   12|       |
   13|       |   /* grow c as required */
   14|   441k|   if (c->alloc < (a->used + 1)) {
  ------------------
  |  Branch (14:8): [True: 0, False: 441k]
  ------------------
   15|      0|      if ((err = mp_grow(c, a->used + 1)) != MP_OKAY) {
  ------------------
  |  |  161|      0|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (15:11): [True: 0, False: 0]
  ------------------
   16|      0|         return err;
   17|      0|      }
   18|      0|   }
   19|       |
   20|       |   /* if a is negative and |a| >= b, call c = |a| - b */
   21|   441k|   if ((a->sign == MP_NEG) && ((a->used > 1) || (a->dp[0] >= b))) {
  ------------------
  |  |  152|   441k|#define MP_NEG        1   /* negative */
  ------------------
  |  Branch (21:8): [True: 0, False: 441k]
  |  Branch (21:32): [True: 0, False: 0]
  |  Branch (21:49): [True: 0, False: 0]
  ------------------
   22|      0|      mp_int a_ = *a;
   23|       |      /* temporarily fix sign of a */
   24|      0|      a_.sign = MP_ZPOS;
  ------------------
  |  |  151|      0|#define MP_ZPOS       0   /* positive integer */
  ------------------
   25|       |
   26|       |      /* c = |a| - b */
   27|      0|      err = mp_sub_d(&a_, b, c);
   28|       |
   29|       |      /* fix sign  */
   30|      0|      c->sign = MP_NEG;
  ------------------
  |  |  152|      0|#define MP_NEG        1   /* negative */
  ------------------
   31|       |
   32|       |      /* clamp */
   33|      0|      mp_clamp(c);
   34|       |
   35|      0|      return err;
   36|      0|   }
   37|       |
   38|       |   /* old number of used digits in c */
   39|   441k|   oldused = c->used;
   40|       |
   41|       |   /* source alias */
   42|   441k|   tmpa    = a->dp;
   43|       |
   44|       |   /* destination alias */
   45|   441k|   tmpc    = c->dp;
   46|       |
   47|       |   /* if a is positive */
   48|   441k|   if (a->sign == MP_ZPOS) {
  ------------------
  |  |  151|   441k|#define MP_ZPOS       0   /* positive integer */
  ------------------
  |  Branch (48:8): [True: 441k, False: 0]
  ------------------
   49|       |      /* add digits, mu is carry */
   50|   441k|      mp_digit mu = b;
   51|  2.48M|      for (ix = 0; ix < a->used; ix++) {
  ------------------
  |  Branch (51:20): [True: 2.04M, False: 441k]
  ------------------
   52|  2.04M|         *tmpc   = *tmpa++ + mu;
   53|  2.04M|         mu      = *tmpc >> MP_DIGIT_BIT;
  ------------------
  |  |   82|  2.04M|#   define MP_DIGIT_BIT 60
  ------------------
   54|  2.04M|         *tmpc++ &= MP_MASK;
  ------------------
  |  |  106|  2.04M|#define MP_MASK          ((((mp_digit)1)<<((mp_digit)MP_DIGIT_BIT))-((mp_digit)1))
  |  |  ------------------
  |  |  |  |   82|  2.04M|#   define MP_DIGIT_BIT 60
  |  |  ------------------
  ------------------
   55|  2.04M|      }
   56|       |      /* set final carry */
   57|   441k|      ix++;
   58|   441k|      *tmpc++  = mu;
   59|       |
   60|       |      /* setup size */
   61|   441k|      c->used = a->used + 1;
   62|   441k|   } else {
   63|       |      /* a was negative and |a| < b */
   64|      0|      c->used  = 1;
   65|       |
   66|       |      /* the result is a single digit */
   67|      0|      if (a->used == 1) {
  ------------------
  |  Branch (67:11): [True: 0, False: 0]
  ------------------
   68|      0|         *tmpc++  =  b - a->dp[0];
   69|      0|      } else {
   70|      0|         *tmpc++  =  b;
   71|      0|      }
   72|       |
   73|       |      /* setup count so the clearing of oldused
   74|       |       * can fall through correctly
   75|       |       */
   76|      0|      ix       = 1;
   77|      0|   }
   78|       |
   79|       |   /* sign always positive */
   80|   441k|   c->sign = MP_ZPOS;
  ------------------
  |  |  151|   441k|#define MP_ZPOS       0   /* positive integer */
  ------------------
   81|       |
   82|       |   /* now zero to oldused */
   83|   441k|   MP_ZERO_DIGITS(tmpc, oldused - ix);
  ------------------
  |  |   89|   441k|#  define MP_ZERO_DIGITS(mem, digits)                   \
  |  |   90|   441k|do {                                                    \
  |  |   91|   441k|   int zd_ = (digits);                                  \
  |  |   92|   441k|   mp_digit* zm_ = (mem);                               \
  |  |   93|   441k|   while (zd_-- > 0) {                                  \
  |  |  ------------------
  |  |  |  Branch (93:11): [True: 0, False: 441k]
  |  |  ------------------
  |  |   94|      0|      *zm_++ = 0;                                       \
  |  |   95|      0|   }                                                    \
  |  |   96|   441k|} while (0)
  |  |  ------------------
  |  |  |  Branch (96:10): [Folded, False: 441k]
  |  |  ------------------
  ------------------
   84|   441k|   mp_clamp(c);
   85|       |
   86|   441k|   return MP_OKAY;
  ------------------
  |  |  161|   441k|#define MP_OKAY       0   /* no error */
  ------------------
   87|   441k|}

mp_clamp:
   14|  76.5M|{
   15|       |   /* decrease used while the most significant digit is
   16|       |    * zero.
   17|       |    */
   18|   157M|   while ((a->used > 0) && (a->dp[a->used - 1] == 0u)) {
  ------------------
  |  Branch (18:11): [True: 157M, False: 127k]
  |  Branch (18:28): [True: 81.1M, False: 76.4M]
  ------------------
   19|  81.1M|      --(a->used);
   20|  81.1M|   }
   21|       |
   22|       |   /* reset the sign flag if used == 0 */
   23|  76.5M|   if (a->used == 0) {
  ------------------
  |  Branch (23:8): [True: 127k, False: 76.4M]
  ------------------
   24|   127k|      a->sign = MP_ZPOS;
  ------------------
  |  |  151|   127k|#define MP_ZPOS       0   /* positive integer */
  ------------------
   25|   127k|   }
   26|  76.5M|}

mp_clear:
    8|  3.29M|{
    9|       |   /* only do anything if a hasn't been freed previously */
   10|  3.29M|   if (a->dp != NULL) {
  ------------------
  |  Branch (10:8): [True: 3.29M, False: 0]
  ------------------
   11|       |      /* free ram */
   12|  3.29M|      MP_FREE_DIGITS(a->dp, a->alloc);
  ------------------
  |  |   58|  3.29M|#  define MP_FREE_DIGITS(mem, digits)                   \
  |  |   59|  3.29M|do {                                                    \
  |  |   60|  3.29M|   int fd_ = (digits);                                  \
  |  |   61|  3.29M|   void* fm_ = (mem);                                   \
  |  |   62|  3.29M|   if (fm_ != NULL) {                                   \
  |  |  ------------------
  |  |  |  Branch (62:8): [True: 3.29M, False: 0]
  |  |  ------------------
  |  |   63|  3.29M|      size_t fs_ = sizeof (mp_digit) * (size_t)fd_;     \
  |  |   64|  3.29M|      MP_ZERO_BUFFER(fm_, fs_);                         \
  |  |  ------------------
  |  |  |  |   81|  3.29M|#  define MP_ZERO_BUFFER(mem, size)                     \
  |  |  |  |   82|  3.29M|do {                                                    \
  |  |  |  |   83|  3.29M|   size_t zs_ = (size);                                 \
  |  |  |  |   84|  3.29M|   char* zm_ = (char*)(mem);                            \
  |  |  |  |   85|   883M|   while (zs_-- > 0u) {                                 \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (85:11): [True: 879M, False: 3.29M]
  |  |  |  |  ------------------
  |  |  |  |   86|   879M|      *zm_++ = '\0';                                    \
  |  |  |  |   87|   879M|   }                                                    \
  |  |  |  |   88|  3.29M|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (88:10): [Folded, False: 3.29M]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   65|  3.29M|      MP_FREE(fm_, fs_);                                \
  |  |  ------------------
  |  |  |  | 1324|  3.29M|#define MP_FREE      m_free_ltm
  |  |  ------------------
  |  |   66|  3.29M|   }                                                    \
  |  |   67|  3.29M|} while (0)
  |  |  ------------------
  |  |  |  Branch (67:10): [Folded, False: 3.29M]
  |  |  ------------------
  ------------------
   13|       |
   14|       |      /* reset members to make debugging easier */
   15|  3.29M|      a->dp    = NULL;
   16|  3.29M|      a->alloc = a->used = 0;
   17|  3.29M|      a->sign  = MP_ZPOS;
  ------------------
  |  |  151|  3.29M|#define MP_ZPOS       0   /* positive integer */
  ------------------
   18|  3.29M|   }
   19|  3.29M|}

mp_clear_multi:
    9|  5.04k|{
   10|  5.04k|   mp_int *next_mp = mp;
   11|  5.04k|   va_list args;
   12|  5.04k|   va_start(args, mp);
   13|  21.8k|   while (next_mp != NULL) {
  ------------------
  |  Branch (13:11): [True: 16.7k, False: 5.04k]
  ------------------
   14|  16.7k|      mp_clear(next_mp);
   15|  16.7k|      next_mp = va_arg(args, mp_int *);
   16|  16.7k|   }
   17|       |   va_end(args);
   18|  5.04k|}

mp_cmp:
    8|  4.76M|{
    9|       |   /* compare based on sign */
   10|  4.76M|   if (a->sign != b->sign) {
  ------------------
  |  Branch (10:8): [True: 0, False: 4.76M]
  ------------------
   11|      0|      if (a->sign == MP_NEG) {
  ------------------
  |  |  152|      0|#define MP_NEG        1   /* negative */
  ------------------
  |  Branch (11:11): [True: 0, False: 0]
  ------------------
   12|      0|         return MP_LT;
  ------------------
  |  |  154|      0|#define MP_LT        -1   /* less than */
  ------------------
   13|      0|      } else {
   14|      0|         return MP_GT;
  ------------------
  |  |  156|      0|#define MP_GT         1   /* greater than */
  ------------------
   15|      0|      }
   16|      0|   }
   17|       |
   18|       |   /* compare digits */
   19|  4.76M|   if (a->sign == MP_NEG) {
  ------------------
  |  |  152|  4.76M|#define MP_NEG        1   /* negative */
  ------------------
  |  Branch (19:8): [True: 0, False: 4.76M]
  ------------------
   20|       |      /* if negative compare opposite direction */
   21|      0|      return mp_cmp_mag(b, a);
   22|  4.76M|   } else {
   23|  4.76M|      return mp_cmp_mag(a, b);
   24|  4.76M|   }
   25|  4.76M|}

mp_cmp_d:
    8|  4.80M|{
    9|       |   /* compare based on sign */
   10|  4.80M|   if (a->sign == MP_NEG) {
  ------------------
  |  |  152|  4.80M|#define MP_NEG        1   /* negative */
  ------------------
  |  Branch (10:8): [True: 2.37M, False: 2.42M]
  ------------------
   11|  2.37M|      return MP_LT;
  ------------------
  |  |  154|  2.37M|#define MP_LT        -1   /* less than */
  ------------------
   12|  2.37M|   }
   13|       |
   14|       |   /* compare based on magnitude */
   15|  2.42M|   if (a->used > 1) {
  ------------------
  |  Branch (15:8): [True: 2.41M, False: 13.0k]
  ------------------
   16|  2.41M|      return MP_GT;
  ------------------
  |  |  156|  2.41M|#define MP_GT         1   /* greater than */
  ------------------
   17|  2.41M|   }
   18|       |
   19|       |   /* compare the only digit of a to b */
   20|  13.0k|   if (a->dp[0] > b) {
  ------------------
  |  Branch (20:8): [True: 2.73k, False: 10.3k]
  ------------------
   21|  2.73k|      return MP_GT;
  ------------------
  |  |  156|  2.73k|#define MP_GT         1   /* greater than */
  ------------------
   22|  10.3k|   } else if (a->dp[0] < b) {
  ------------------
  |  Branch (22:15): [True: 3, False: 10.3k]
  ------------------
   23|      3|      return MP_LT;
  ------------------
  |  |  154|      3|#define MP_LT        -1   /* less than */
  ------------------
   24|  10.3k|   } else {
   25|  10.3k|      return MP_EQ;
  ------------------
  |  |  155|  10.3k|#define MP_EQ         0   /* equal to */
  ------------------
   26|  10.3k|   }
   27|  13.0k|}

mp_cmp_mag:
    8|  35.6M|{
    9|  35.6M|   int     n;
   10|  35.6M|   const mp_digit *tmpa, *tmpb;
   11|       |
   12|       |   /* compare based on # of non-zero digits */
   13|  35.6M|   if (a->used > b->used) {
  ------------------
  |  Branch (13:8): [True: 4.87M, False: 30.7M]
  ------------------
   14|  4.87M|      return MP_GT;
  ------------------
  |  |  156|  4.87M|#define MP_GT         1   /* greater than */
  ------------------
   15|  4.87M|   }
   16|       |
   17|  30.7M|   if (a->used < b->used) {
  ------------------
  |  Branch (17:8): [True: 313k, False: 30.4M]
  ------------------
   18|   313k|      return MP_LT;
  ------------------
  |  |  154|   313k|#define MP_LT        -1   /* less than */
  ------------------
   19|   313k|   }
   20|       |
   21|       |   /* alias for a */
   22|  30.4M|   tmpa = a->dp + (a->used - 1);
   23|       |
   24|       |   /* alias for b */
   25|  30.4M|   tmpb = b->dp + (a->used - 1);
   26|       |
   27|       |   /* compare based on digits  */
   28|  30.6M|   for (n = 0; n < a->used; ++n, --tmpa, --tmpb) {
  ------------------
  |  Branch (28:16): [True: 30.6M, False: 12.0k]
  ------------------
   29|  30.6M|      if (*tmpa > *tmpb) {
  ------------------
  |  Branch (29:11): [True: 7.79M, False: 22.8M]
  ------------------
   30|  7.79M|         return MP_GT;
  ------------------
  |  |  156|  7.79M|#define MP_GT         1   /* greater than */
  ------------------
   31|  7.79M|      }
   32|       |
   33|  22.8M|      if (*tmpa < *tmpb) {
  ------------------
  |  Branch (33:11): [True: 22.6M, False: 217k]
  ------------------
   34|  22.6M|         return MP_LT;
  ------------------
  |  |  154|  22.6M|#define MP_LT        -1   /* less than */
  ------------------
   35|  22.6M|      }
   36|  22.8M|   }
   37|  12.0k|   return MP_EQ;
  ------------------
  |  |  155|  12.0k|#define MP_EQ         0   /* equal to */
  ------------------
   38|  30.4M|}

mp_copy:
    8|  13.8M|{
    9|  13.8M|   int n;
   10|  13.8M|   mp_digit *tmpa, *tmpb;
   11|  13.8M|   mp_err err;
   12|       |
   13|       |   /* if dst == src do nothing */
   14|  13.8M|   if (a == b) {
  ------------------
  |  Branch (14:8): [True: 6.11M, False: 7.70M]
  ------------------
   15|  6.11M|      return MP_OKAY;
  ------------------
  |  |  161|  6.11M|#define MP_OKAY       0   /* no error */
  ------------------
   16|  6.11M|   }
   17|       |
   18|       |   /* grow dest */
   19|  7.70M|   if (b->alloc < a->used) {
  ------------------
  |  Branch (19:8): [True: 5.69k, False: 7.70M]
  ------------------
   20|  5.69k|      if ((err = mp_grow(b, a->used)) != MP_OKAY) {
  ------------------
  |  |  161|  5.69k|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (20:11): [True: 0, False: 5.69k]
  ------------------
   21|      0|         return err;
   22|      0|      }
   23|  5.69k|   }
   24|       |
   25|       |   /* zero b and copy the parameters over */
   26|       |   /* pointer aliases */
   27|       |
   28|       |   /* source */
   29|  7.70M|   tmpa = a->dp;
   30|       |
   31|       |   /* destination */
   32|  7.70M|   tmpb = b->dp;
   33|       |
   34|       |   /* copy all the digits */
   35|   162M|   for (n = 0; n < a->used; n++) {
  ------------------
  |  Branch (35:16): [True: 154M, False: 7.70M]
  ------------------
   36|   154M|      *tmpb++ = *tmpa++;
   37|   154M|   }
   38|       |
   39|       |   /* clear high digits */
   40|  7.70M|   MP_ZERO_DIGITS(tmpb, b->used - n);
  ------------------
  |  |   89|  7.70M|#  define MP_ZERO_DIGITS(mem, digits)                   \
  |  |   90|  7.70M|do {                                                    \
  |  |   91|  7.70M|   int zd_ = (digits);                                  \
  |  |   92|  7.70M|   mp_digit* zm_ = (mem);                               \
  |  |   93|  7.70M|   while (zd_-- > 0) {                                  \
  |  |  ------------------
  |  |  |  Branch (93:11): [True: 890, False: 7.70M]
  |  |  ------------------
  |  |   94|    890|      *zm_++ = 0;                                       \
  |  |   95|    890|   }                                                    \
  |  |   96|  7.70M|} while (0)
  |  |  ------------------
  |  |  |  Branch (96:10): [Folded, False: 7.70M]
  |  |  ------------------
  ------------------
   41|       |
   42|       |   /* copy used count and sign */
   43|  7.70M|   b->used = a->used;
   44|  7.70M|   b->sign = a->sign;
   45|  7.70M|   return MP_OKAY;
  ------------------
  |  |  161|  7.70M|#define MP_OKAY       0   /* no error */
  ------------------
   46|  7.70M|}

mp_count_bits:
    8|  45.0k|{
    9|  45.0k|   int     r;
   10|  45.0k|   mp_digit q;
   11|       |
   12|       |   /* shortcut */
   13|  45.0k|   if (MP_IS_ZERO(a)) {
  ------------------
  |  |  163|  45.0k|#define MP_IS_ZERO(a) ((a)->used == 0)
  |  |  ------------------
  |  |  |  Branch (163:23): [True: 788, False: 44.2k]
  |  |  ------------------
  ------------------
   14|    788|      return 0;
   15|    788|   }
   16|       |
   17|       |   /* get number of digits and add that */
   18|  44.2k|   r = (a->used - 1) * MP_DIGIT_BIT;
  ------------------
  |  |   82|  44.2k|#   define MP_DIGIT_BIT 60
  ------------------
   19|       |
   20|       |   /* take the last digit and count the bits in it */
   21|  44.2k|   q = a->dp[a->used - 1];
   22|   896k|   while (q > 0u) {
  ------------------
  |  Branch (22:11): [True: 852k, False: 44.2k]
  ------------------
   23|   852k|      ++r;
   24|   852k|      q >>= 1u;
   25|   852k|   }
   26|  44.2k|   return r;
   27|  45.0k|}

mp_div:
   87|  10.2k|{
   88|  10.2k|   mp_int  q, x, y, t1, t2;
   89|  10.2k|   int     n, t, i, norm;
   90|  10.2k|   mp_sign neg;
   91|  10.2k|   mp_err  err;
   92|       |
   93|       |   /* is divisor zero ? */
   94|  10.2k|   if (MP_IS_ZERO(b)) {
  ------------------
  |  |  163|  10.2k|#define MP_IS_ZERO(a) ((a)->used == 0)
  |  |  ------------------
  |  |  |  Branch (163:23): [True: 0, False: 10.2k]
  |  |  ------------------
  ------------------
   95|      0|      return MP_VAL;
  ------------------
  |  |  164|      0|#define MP_VAL        -3  /* invalid input */
  ------------------
   96|      0|   }
   97|       |
   98|       |   /* if a < b then q=0, r = a */
   99|  10.2k|   if (mp_cmp_mag(a, b) == MP_LT) {
  ------------------
  |  |  154|  10.2k|#define MP_LT        -1   /* less than */
  ------------------
  |  Branch (99:8): [True: 4.10k, False: 6.14k]
  ------------------
  100|  4.10k|      if (d != NULL) {
  ------------------
  |  Branch (100:11): [True: 4.10k, False: 0]
  ------------------
  101|  4.10k|         err = mp_copy(a, d);
  102|  4.10k|      } else {
  103|      0|         err = MP_OKAY;
  ------------------
  |  |  161|      0|#define MP_OKAY       0   /* no error */
  ------------------
  104|      0|      }
  105|  4.10k|      if (c != NULL) {
  ------------------
  |  Branch (105:11): [True: 0, False: 4.10k]
  ------------------
  106|      0|         mp_zero(c);
  107|      0|      }
  108|  4.10k|      return err;
  109|  4.10k|   }
  110|       |
  111|  6.14k|   if ((err = mp_init_size(&q, a->used + 2)) != MP_OKAY) {
  ------------------
  |  |  161|  6.14k|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (111:8): [True: 0, False: 6.14k]
  ------------------
  112|      0|      return err;
  113|      0|   }
  114|  6.14k|   q.used = a->used + 2;
  115|       |
  116|  6.14k|   if ((err = mp_init(&t1)) != MP_OKAY)                           goto LBL_Q;
  ------------------
  |  |  161|  6.14k|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (116:8): [True: 0, False: 6.14k]
  ------------------
  117|       |
  118|  6.14k|   if ((err = mp_init(&t2)) != MP_OKAY)                           goto LBL_T1;
  ------------------
  |  |  161|  6.14k|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (118:8): [True: 0, False: 6.14k]
  ------------------
  119|       |
  120|  6.14k|   if ((err = mp_init_copy(&x, a)) != MP_OKAY)                    goto LBL_T2;
  ------------------
  |  |  161|  6.14k|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (120:8): [True: 0, False: 6.14k]
  ------------------
  121|       |
  122|  6.14k|   if ((err = mp_init_copy(&y, b)) != MP_OKAY)                    goto LBL_X;
  ------------------
  |  |  161|  6.14k|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (122:8): [True: 0, False: 6.14k]
  ------------------
  123|       |
  124|       |   /* fix the sign */
  125|  6.14k|   neg = (a->sign == b->sign) ? MP_ZPOS : MP_NEG;
  ------------------
  |  |  151|  6.14k|#define MP_ZPOS       0   /* positive integer */
  ------------------
                 neg = (a->sign == b->sign) ? MP_ZPOS : MP_NEG;
  ------------------
  |  |  152|  6.14k|#define MP_NEG        1   /* negative */
  ------------------
  |  Branch (125:10): [True: 6.14k, False: 3]
  ------------------
  126|  6.14k|   x.sign = y.sign = MP_ZPOS;
  ------------------
  |  |  151|  6.14k|#define MP_ZPOS       0   /* positive integer */
  ------------------
  127|       |
  128|       |   /* normalize both x and y, ensure that y >= b/2, [b == 2**MP_DIGIT_BIT] */
  129|  6.14k|   norm = mp_count_bits(&y) % MP_DIGIT_BIT;
  ------------------
  |  |   82|  6.14k|#   define MP_DIGIT_BIT 60
  ------------------
  130|  6.14k|   if (norm < (MP_DIGIT_BIT - 1)) {
  ------------------
  |  |   82|  6.14k|#   define MP_DIGIT_BIT 60
  ------------------
  |  Branch (130:8): [True: 6.14k, False: 4]
  ------------------
  131|  6.14k|      norm = (MP_DIGIT_BIT - 1) - norm;
  ------------------
  |  |   82|  6.14k|#   define MP_DIGIT_BIT 60
  ------------------
  132|  6.14k|      if ((err = mp_mul_2d(&x, norm, &x)) != MP_OKAY)             goto LBL_Y;
  ------------------
  |  |  161|  6.14k|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (132:11): [True: 0, False: 6.14k]
  ------------------
  133|  6.14k|      if ((err = mp_mul_2d(&y, norm, &y)) != MP_OKAY)             goto LBL_Y;
  ------------------
  |  |  161|  6.14k|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (133:11): [True: 0, False: 6.14k]
  ------------------
  134|  6.14k|   } else {
  135|      4|      norm = 0;
  136|      4|   }
  137|       |
  138|       |   /* note hac does 0 based, so if used==5 then its 0,1,2,3,4, e.g. use 4 */
  139|  6.14k|   n = x.used - 1;
  140|  6.14k|   t = y.used - 1;
  141|       |
  142|       |   /* while (x >= y*b**n-t) do { q[n-t] += 1; x -= y*b**{n-t} } */
  143|       |   /* y = y*b**{n-t} */
  144|  6.14k|   if ((err = mp_lshd(&y, n - t)) != MP_OKAY)                     goto LBL_Y;
  ------------------
  |  |  161|  6.14k|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (144:8): [True: 0, False: 6.14k]
  ------------------
  145|       |
  146|  6.23k|   while (mp_cmp(&x, &y) != MP_LT) {
  ------------------
  |  |  154|  6.23k|#define MP_LT        -1   /* less than */
  ------------------
  |  Branch (146:11): [True: 91, False: 6.14k]
  ------------------
  147|     91|      ++(q.dp[n - t]);
  148|     91|      if ((err = mp_sub(&x, &y, &x)) != MP_OKAY)                  goto LBL_Y;
  ------------------
  |  |  161|     91|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (148:11): [True: 0, False: 91]
  ------------------
  149|     91|   }
  150|       |
  151|       |   /* reset y by shifting it back down */
  152|  6.14k|   mp_rshd(&y, n - t);
  153|       |
  154|       |   /* step 3. for i from n down to (t + 1) */
  155|  37.2k|   for (i = n; i >= (t + 1); i--) {
  ------------------
  |  Branch (155:16): [True: 31.0k, False: 6.14k]
  ------------------
  156|  31.0k|      if (i > x.used) {
  ------------------
  |  Branch (156:11): [True: 170, False: 30.9k]
  ------------------
  157|    170|         continue;
  158|    170|      }
  159|       |
  160|       |      /* step 3.1 if xi == yt then set q{i-t-1} to b-1,
  161|       |       * otherwise set q{i-t-1} to (xi*b + x{i-1})/yt */
  162|  30.9k|      if (x.dp[i] == y.dp[t]) {
  ------------------
  |  Branch (162:11): [True: 45, False: 30.8k]
  ------------------
  163|     45|         q.dp[(i - t) - 1] = ((mp_digit)1 << (mp_digit)MP_DIGIT_BIT) - (mp_digit)1;
  ------------------
  |  |   82|     45|#   define MP_DIGIT_BIT 60
  ------------------
  164|  30.8k|      } else {
  165|  30.8k|         mp_word tmp;
  166|  30.8k|         tmp = (mp_word)x.dp[i] << (mp_word)MP_DIGIT_BIT;
  ------------------
  |  |   82|  30.8k|#   define MP_DIGIT_BIT 60
  ------------------
  167|  30.8k|         tmp |= (mp_word)x.dp[i - 1];
  168|  30.8k|         tmp /= (mp_word)y.dp[t];
  169|  30.8k|         if (tmp > (mp_word)MP_MASK) {
  ------------------
  |  |  106|  30.8k|#define MP_MASK          ((((mp_digit)1)<<((mp_digit)MP_DIGIT_BIT))-((mp_digit)1))
  |  |  ------------------
  |  |  |  |   82|  30.8k|#   define MP_DIGIT_BIT 60
  |  |  ------------------
  ------------------
  |  Branch (169:14): [True: 0, False: 30.8k]
  ------------------
  170|      0|            tmp = MP_MASK;
  ------------------
  |  |  106|      0|#define MP_MASK          ((((mp_digit)1)<<((mp_digit)MP_DIGIT_BIT))-((mp_digit)1))
  |  |  ------------------
  |  |  |  |   82|      0|#   define MP_DIGIT_BIT 60
  |  |  ------------------
  ------------------
  171|      0|         }
  172|  30.8k|         q.dp[(i - t) - 1] = (mp_digit)(tmp & (mp_word)MP_MASK);
  ------------------
  |  |  106|  30.8k|#define MP_MASK          ((((mp_digit)1)<<((mp_digit)MP_DIGIT_BIT))-((mp_digit)1))
  |  |  ------------------
  |  |  |  |   82|  30.8k|#   define MP_DIGIT_BIT 60
  |  |  ------------------
  ------------------
  173|  30.8k|      }
  174|       |
  175|       |      /* while (q{i-t-1} * (yt * b + y{t-1})) >
  176|       |               xi * b**2 + xi-1 * b + xi-2
  177|       |
  178|       |         do q{i-t-1} -= 1;
  179|       |      */
  180|  30.9k|      q.dp[(i - t) - 1] = (q.dp[(i - t) - 1] + 1uL) & (mp_digit)MP_MASK;
  ------------------
  |  |  106|  30.9k|#define MP_MASK          ((((mp_digit)1)<<((mp_digit)MP_DIGIT_BIT))-((mp_digit)1))
  |  |  ------------------
  |  |  |  |   82|  30.9k|#   define MP_DIGIT_BIT 60
  |  |  ------------------
  ------------------
  181|  50.2k|      do {
  182|  50.2k|         q.dp[(i - t) - 1] = (q.dp[(i - t) - 1] - 1uL) & (mp_digit)MP_MASK;
  ------------------
  |  |  106|  50.2k|#define MP_MASK          ((((mp_digit)1)<<((mp_digit)MP_DIGIT_BIT))-((mp_digit)1))
  |  |  ------------------
  |  |  |  |   82|  50.2k|#   define MP_DIGIT_BIT 60
  |  |  ------------------
  ------------------
  183|       |
  184|       |         /* find left hand */
  185|  50.2k|         mp_zero(&t1);
  186|  50.2k|         t1.dp[0] = ((t - 1) < 0) ? 0u : y.dp[t - 1];
  ------------------
  |  Branch (186:21): [True: 0, False: 50.2k]
  ------------------
  187|  50.2k|         t1.dp[1] = y.dp[t];
  188|  50.2k|         t1.used = 2;
  189|  50.2k|         if ((err = mp_mul_d(&t1, q.dp[(i - t) - 1], &t1)) != MP_OKAY) goto LBL_Y;
  ------------------
  |  |  161|  50.2k|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (189:14): [True: 0, False: 50.2k]
  ------------------
  190|       |
  191|       |         /* find right hand */
  192|  50.2k|         t2.dp[0] = ((i - 2) < 0) ? 0u : x.dp[i - 2];
  ------------------
  |  Branch (192:21): [True: 0, False: 50.2k]
  ------------------
  193|  50.2k|         t2.dp[1] = x.dp[i - 1]; /* i >= 1 always holds */
  194|  50.2k|         t2.dp[2] = x.dp[i];
  195|  50.2k|         t2.used = 3;
  196|  50.2k|      } while (mp_cmp_mag(&t1, &t2) == MP_GT);
  ------------------
  |  |  156|  50.2k|#define MP_GT         1   /* greater than */
  ------------------
  |  Branch (196:16): [True: 19.2k, False: 30.9k]
  ------------------
  197|       |
  198|       |      /* step 3.3 x = x - q{i-t-1} * y * b**{i-t-1} */
  199|  30.9k|      if ((err = mp_mul_d(&y, q.dp[(i - t) - 1], &t1)) != MP_OKAY) goto LBL_Y;
  ------------------
  |  |  161|  30.9k|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (199:11): [True: 0, False: 30.9k]
  ------------------
  200|       |
  201|  30.9k|      if ((err = mp_lshd(&t1, (i - t) - 1)) != MP_OKAY)           goto LBL_Y;
  ------------------
  |  |  161|  30.9k|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (201:11): [True: 0, False: 30.9k]
  ------------------
  202|       |
  203|  30.9k|      if ((err = mp_sub(&x, &t1, &x)) != MP_OKAY)                 goto LBL_Y;
  ------------------
  |  |  161|  30.9k|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (203:11): [True: 0, False: 30.9k]
  ------------------
  204|       |
  205|       |      /* if x < 0 then { x = x + y*b**{i-t-1}; q{i-t-1} -= 1; } */
  206|  30.9k|      if (x.sign == MP_NEG) {
  ------------------
  |  |  152|  30.9k|#define MP_NEG        1   /* negative */
  ------------------
  |  Branch (206:11): [True: 58, False: 30.8k]
  ------------------
  207|     58|         if ((err = mp_copy(&y, &t1)) != MP_OKAY)                 goto LBL_Y;
  ------------------
  |  |  161|     58|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (207:14): [True: 0, False: 58]
  ------------------
  208|     58|         if ((err = mp_lshd(&t1, (i - t) - 1)) != MP_OKAY)        goto LBL_Y;
  ------------------
  |  |  161|     58|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (208:14): [True: 0, False: 58]
  ------------------
  209|     58|         if ((err = mp_add(&x, &t1, &x)) != MP_OKAY)              goto LBL_Y;
  ------------------
  |  |  161|     58|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (209:14): [True: 0, False: 58]
  ------------------
  210|       |
  211|     58|         q.dp[(i - t) - 1] = (q.dp[(i - t) - 1] - 1uL) & MP_MASK;
  ------------------
  |  |  106|     58|#define MP_MASK          ((((mp_digit)1)<<((mp_digit)MP_DIGIT_BIT))-((mp_digit)1))
  |  |  ------------------
  |  |  |  |   82|     58|#   define MP_DIGIT_BIT 60
  |  |  ------------------
  ------------------
  212|     58|      }
  213|  30.9k|   }
  214|       |
  215|       |   /* now q is the quotient and x is the remainder
  216|       |    * [which we have to normalize]
  217|       |    */
  218|       |
  219|       |   /* get sign before writing to c */
  220|  6.14k|   x.sign = (x.used == 0) ? MP_ZPOS : a->sign;
  ------------------
  |  |  151|      3|#define MP_ZPOS       0   /* positive integer */
  ------------------
  |  Branch (220:13): [True: 3, False: 6.14k]
  ------------------
  221|       |
  222|  6.14k|   if (c != NULL) {
  ------------------
  |  Branch (222:8): [True: 313, False: 5.83k]
  ------------------
  223|    313|      mp_clamp(&q);
  224|    313|      mp_exch(&q, c);
  225|    313|      c->sign = neg;
  226|    313|   }
  227|       |
  228|  6.14k|   if (d != NULL) {
  ------------------
  |  Branch (228:8): [True: 5.83k, False: 313]
  ------------------
  229|  5.83k|      if ((err = mp_div_2d(&x, norm, &x, NULL)) != MP_OKAY)       goto LBL_Y;
  ------------------
  |  |  161|  5.83k|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (229:11): [True: 0, False: 5.83k]
  ------------------
  230|  5.83k|      mp_exch(&x, d);
  231|  5.83k|   }
  232|       |
  233|  6.14k|   err = MP_OKAY;
  ------------------
  |  |  161|  6.14k|#define MP_OKAY       0   /* no error */
  ------------------
  234|       |
  235|  6.14k|LBL_Y:
  236|  6.14k|   mp_clear(&y);
  237|  6.14k|LBL_X:
  238|  6.14k|   mp_clear(&x);
  239|  6.14k|LBL_T2:
  240|  6.14k|   mp_clear(&t2);
  241|  6.14k|LBL_T1:
  242|  6.14k|   mp_clear(&t1);
  243|  6.14k|LBL_Q:
  244|  6.14k|   mp_clear(&q);
  245|  6.14k|   return err;
  246|  6.14k|}

mp_div_2:
    8|  2.16M|{
    9|  2.16M|   int     x, oldused;
   10|  2.16M|   mp_digit r, rr, *tmpa, *tmpb;
   11|  2.16M|   mp_err err;
   12|       |
   13|       |   /* copy */
   14|  2.16M|   if (b->alloc < a->used) {
  ------------------
  |  Branch (14:8): [True: 1.08k, False: 2.16M]
  ------------------
   15|  1.08k|      if ((err = mp_grow(b, a->used)) != MP_OKAY) {
  ------------------
  |  |  161|  1.08k|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (15:11): [True: 0, False: 1.08k]
  ------------------
   16|      0|         return err;
   17|      0|      }
   18|  1.08k|   }
   19|       |
   20|  2.16M|   oldused = b->used;
   21|  2.16M|   b->used = a->used;
   22|       |
   23|       |   /* source alias */
   24|  2.16M|   tmpa = a->dp + b->used - 1;
   25|       |
   26|       |   /* dest alias */
   27|  2.16M|   tmpb = b->dp + b->used - 1;
   28|       |
   29|       |   /* carry */
   30|  2.16M|   r = 0;
   31|  17.7M|   for (x = b->used - 1; x >= 0; x--) {
  ------------------
  |  Branch (31:26): [True: 15.6M, False: 2.16M]
  ------------------
   32|       |      /* get the carry for the next iteration */
   33|  15.6M|      rr = *tmpa & 1u;
   34|       |
   35|       |      /* shift the current digit, add in carry and store */
   36|  15.6M|      *tmpb-- = (*tmpa-- >> 1) | (r << (MP_DIGIT_BIT - 1));
  ------------------
  |  |   82|  15.6M|#   define MP_DIGIT_BIT 60
  ------------------
   37|       |
   38|       |      /* forward carry to next iteration */
   39|  15.6M|      r = rr;
   40|  15.6M|   }
   41|       |
   42|       |   /* zero excess digits */
   43|  2.16M|   MP_ZERO_DIGITS(b->dp + b->used, oldused - b->used);
  ------------------
  |  |   89|  2.16M|#  define MP_ZERO_DIGITS(mem, digits)                   \
  |  |   90|  2.16M|do {                                                    \
  |  |   91|  2.16M|   int zd_ = (digits);                                  \
  |  |   92|  2.16M|   mp_digit* zm_ = (mem);                               \
  |  |   93|  2.16M|   while (zd_-- > 0) {                                  \
  |  |  ------------------
  |  |  |  Branch (93:11): [True: 0, False: 2.16M]
  |  |  ------------------
  |  |   94|      0|      *zm_++ = 0;                                       \
  |  |   95|      0|   }                                                    \
  |  |   96|  2.16M|} while (0)
  |  |  ------------------
  |  |  |  Branch (96:10): [Folded, False: 2.16M]
  |  |  ------------------
  ------------------
   44|       |
   45|  2.16M|   b->sign = a->sign;
   46|  2.16M|   mp_clamp(b);
   47|  2.16M|   return MP_OKAY;
  ------------------
  |  |  161|  2.16M|#define MP_OKAY       0   /* no error */
  ------------------
   48|  2.16M|}

mp_div_2d:
    8|  6.08M|{
    9|  6.08M|   mp_digit D, r, rr;
   10|  6.08M|   int     x;
   11|  6.08M|   mp_err err;
   12|       |
   13|       |   /* if the shift count is <= 0 then we do no work */
   14|  6.08M|   if (b <= 0) {
  ------------------
  |  Branch (14:8): [True: 3, False: 6.08M]
  ------------------
   15|      3|      err = mp_copy(a, c);
   16|      3|      if (d != NULL) {
  ------------------
  |  Branch (16:11): [True: 0, False: 3]
  ------------------
   17|      0|         mp_zero(d);
   18|      0|      }
   19|      3|      return err;
   20|      3|   }
   21|       |
   22|       |   /* copy */
   23|  6.08M|   if ((err = mp_copy(a, c)) != MP_OKAY) {
  ------------------
  |  |  161|  6.08M|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (23:8): [True: 0, False: 6.08M]
  ------------------
   24|      0|      return err;
   25|      0|   }
   26|       |   /* 'a' should not be used after here - it might be the same as d */
   27|       |
   28|       |   /* get the remainder */
   29|  6.08M|   if (d != NULL) {
  ------------------
  |  Branch (29:8): [True: 5.01M, False: 1.07M]
  ------------------
   30|  5.01M|      if ((err = mp_mod_2d(a, b, d)) != MP_OKAY) {
  ------------------
  |  |  161|  5.01M|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (30:11): [True: 0, False: 5.01M]
  ------------------
   31|      0|         return err;
   32|      0|      }
   33|  5.01M|   }
   34|       |
   35|       |   /* shift by as many digits in the bit count */
   36|  6.08M|   if (b >= MP_DIGIT_BIT) {
  ------------------
  |  |   82|  6.08M|#   define MP_DIGIT_BIT 60
  ------------------
  |  Branch (36:8): [True: 5.01M, False: 1.07M]
  ------------------
   37|  5.01M|      mp_rshd(c, b / MP_DIGIT_BIT);
  ------------------
  |  |   82|  5.01M|#   define MP_DIGIT_BIT 60
  ------------------
   38|  5.01M|   }
   39|       |
   40|       |   /* shift any bit count < MP_DIGIT_BIT */
   41|  6.08M|   D = (mp_digit)(b % MP_DIGIT_BIT);
  ------------------
  |  |   82|  6.08M|#   define MP_DIGIT_BIT 60
  ------------------
   42|  6.08M|   if (D != 0u) {
  ------------------
  |  Branch (42:8): [True: 5.91M, False: 174k]
  ------------------
   43|  5.91M|      mp_digit *tmpc, mask, shift;
   44|       |
   45|       |      /* mask */
   46|  5.91M|      mask = ((mp_digit)1 << D) - 1uL;
   47|       |
   48|       |      /* shift for lsb */
   49|  5.91M|      shift = (mp_digit)MP_DIGIT_BIT - D;
  ------------------
  |  |   82|  5.91M|#   define MP_DIGIT_BIT 60
  ------------------
   50|       |
   51|       |      /* alias */
   52|  5.91M|      tmpc = c->dp + (c->used - 1);
   53|       |
   54|       |      /* carry */
   55|  5.91M|      r = 0;
   56|  65.8M|      for (x = c->used - 1; x >= 0; x--) {
  ------------------
  |  Branch (56:29): [True: 59.9M, False: 5.91M]
  ------------------
   57|       |         /* get the lower  bits of this word in a temp */
   58|  59.9M|         rr = *tmpc & mask;
   59|       |
   60|       |         /* shift the current word and mix in the carry bits from the previous word */
   61|  59.9M|         *tmpc = (*tmpc >> D) | (r << shift);
   62|  59.9M|         --tmpc;
   63|       |
   64|       |         /* set the carry to the carry bits of the current word found above */
   65|  59.9M|         r = rr;
   66|  59.9M|      }
   67|  5.91M|   }
   68|  6.08M|   mp_clamp(c);
   69|  6.08M|   return MP_OKAY;
  ------------------
  |  |  161|  6.08M|#define MP_OKAY       0   /* no error */
  ------------------
   70|  6.08M|}

mp_dr_is_modulus:
    8|  2.68k|{
    9|  2.68k|   int ix;
   10|       |
   11|       |   /* must be at least two digits */
   12|  2.68k|   if (a->used < 2) {
  ------------------
  |  Branch (12:8): [True: 0, False: 2.68k]
  ------------------
   13|      0|      return MP_NO;
  ------------------
  |  |  159|      0|#define MP_NO         0
  ------------------
   14|      0|   }
   15|       |
   16|       |   /* must be of the form b**k - a [a <= b] so all
   17|       |    * but the first digit must be equal to -1 (mod b).
   18|       |    */
   19|  2.79k|   for (ix = 1; ix < a->used; ix++) {
  ------------------
  |  Branch (19:17): [True: 2.79k, False: 0]
  ------------------
   20|  2.79k|      if (a->dp[ix] != MP_MASK) {
  ------------------
  |  |  106|  2.79k|#define MP_MASK          ((((mp_digit)1)<<((mp_digit)MP_DIGIT_BIT))-((mp_digit)1))
  |  |  ------------------
  |  |  |  |   82|  2.79k|#   define MP_DIGIT_BIT 60
  |  |  ------------------
  ------------------
  |  Branch (20:11): [True: 2.68k, False: 112]
  ------------------
   21|  2.68k|         return MP_NO;
  ------------------
  |  |  159|  2.68k|#define MP_NO         0
  ------------------
   22|  2.68k|      }
   23|  2.79k|   }
   24|      0|   return MP_YES;
  ------------------
  |  |  158|      0|#define MP_YES        1
  ------------------
   25|  2.68k|}

mp_exch:
   10|  17.5k|{
   11|  17.5k|   mp_int  t;
   12|       |
   13|  17.5k|   t  = *a;
   14|  17.5k|   *a = *b;
   15|  17.5k|   *b = t;
   16|  17.5k|}

mp_exptmod:
   12|  2.80k|{
   13|  2.80k|   int dr;
   14|       |
   15|       |   /* modulus P must be positive */
   16|  2.80k|   if (P->sign == MP_NEG) {
  ------------------
  |  |  152|  2.80k|#define MP_NEG        1   /* negative */
  ------------------
  |  Branch (16:8): [True: 0, False: 2.80k]
  ------------------
   17|      0|      return MP_VAL;
  ------------------
  |  |  164|      0|#define MP_VAL        -3  /* invalid input */
  ------------------
   18|      0|   }
   19|       |
   20|       |   /* if exponent X is negative we have to recurse */
   21|  2.80k|   if (X->sign == MP_NEG) {
  ------------------
  |  |  152|  2.80k|#define MP_NEG        1   /* negative */
  ------------------
  |  Branch (21:8): [True: 0, False: 2.80k]
  ------------------
   22|      0|      mp_int tmpG, tmpX;
   23|      0|      mp_err err;
   24|       |
   25|      0|      if (!MP_HAS(MP_INVMOD)) {
  ------------------
  |  |  150|      0|#define MP_HAS(x)        (sizeof(MP_STRINGIZE(BN_##x##_C)) == 1u)
  |  |  ------------------
  |  |  |  |  148|      0|#define MP_STRINGIZE(x)  MP__STRINGIZE(x)
  |  |  |  |  ------------------
  |  |  |  |  |  |  149|      0|#define MP__STRINGIZE(x) ""#x""
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (25:11): [Folded, False: 0]
  ------------------
   26|      0|         return MP_VAL;
  ------------------
  |  |  164|      0|#define MP_VAL        -3  /* invalid input */
  ------------------
   27|      0|      }
   28|       |
   29|      0|      if ((err = mp_init_multi(&tmpG, &tmpX, NULL)) != MP_OKAY) {
  ------------------
  |  |  161|      0|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (29:11): [True: 0, False: 0]
  ------------------
   30|      0|         return err;
   31|      0|      }
   32|       |
   33|       |      /* first compute 1/G mod P */
   34|      0|      if ((err = mp_invmod(G, P, &tmpG)) != MP_OKAY) {
  ------------------
  |  |  161|      0|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (34:11): [True: 0, False: 0]
  ------------------
   35|      0|         goto LBL_ERR;
   36|      0|      }
   37|       |
   38|       |      /* now get |X| */
   39|      0|      if ((err = mp_abs(X, &tmpX)) != MP_OKAY) {
  ------------------
  |  |  161|      0|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (39:11): [True: 0, False: 0]
  ------------------
   40|      0|         goto LBL_ERR;
   41|      0|      }
   42|       |
   43|       |      /* and now compute (1/G)**|X| instead of G**X [X < 0] */
   44|      0|      err = mp_exptmod(&tmpG, &tmpX, P, Y);
   45|      0|LBL_ERR:
   46|      0|      mp_clear_multi(&tmpG, &tmpX, NULL);
   47|      0|      return err;
   48|      0|   }
   49|       |
   50|       |   /* modified diminished radix reduction */
   51|  2.80k|   if (MP_HAS(MP_REDUCE_IS_2K_L) && MP_HAS(MP_REDUCE_2K_L) && MP_HAS(S_MP_EXPTMOD) &&
  ------------------
  |  |  150|  5.61k|#define MP_HAS(x)        (sizeof(MP_STRINGIZE(BN_##x##_C)) == 1u)
  |  |  ------------------
  |  |  |  |  148|  2.80k|#define MP_STRINGIZE(x)  MP__STRINGIZE(x)
  |  |  |  |  ------------------
  |  |  |  |  |  |  149|  2.80k|#define MP__STRINGIZE(x) ""#x""
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (150:26): [True: 0, Folded]
  |  |  ------------------
  ------------------
                 if (MP_HAS(MP_REDUCE_IS_2K_L) && MP_HAS(MP_REDUCE_2K_L) && MP_HAS(S_MP_EXPTMOD) &&
  ------------------
  |  |  150|  2.80k|#define MP_HAS(x)        (sizeof(MP_STRINGIZE(BN_##x##_C)) == 1u)
  |  |  ------------------
  |  |  |  |  148|      0|#define MP_STRINGIZE(x)  MP__STRINGIZE(x)
  |  |  |  |  ------------------
  |  |  |  |  |  |  149|      0|#define MP__STRINGIZE(x) ""#x""
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (150:26): [True: 0, Folded]
  |  |  ------------------
  ------------------
                 if (MP_HAS(MP_REDUCE_IS_2K_L) && MP_HAS(MP_REDUCE_2K_L) && MP_HAS(S_MP_EXPTMOD) &&
  ------------------
  |  |  150|  2.80k|#define MP_HAS(x)        (sizeof(MP_STRINGIZE(BN_##x##_C)) == 1u)
  |  |  ------------------
  |  |  |  |  148|      0|#define MP_STRINGIZE(x)  MP__STRINGIZE(x)
  |  |  |  |  ------------------
  |  |  |  |  |  |  149|      0|#define MP__STRINGIZE(x) ""#x""
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (150:26): [True: 0, Folded]
  |  |  ------------------
  ------------------
   52|  2.80k|       (mp_reduce_is_2k_l(P) == MP_YES)) {
  ------------------
  |  |  158|  2.80k|#define MP_YES        1
  ------------------
  |  Branch (52:8): [True: 128, False: 2.68k]
  ------------------
   53|    128|      return s_mp_exptmod(G, X, P, Y, 1);
   54|    128|   }
   55|       |
   56|       |   /* is it a DR modulus? default to no */
   57|  2.68k|   dr = (MP_HAS(MP_DR_IS_MODULUS) && (mp_dr_is_modulus(P) == MP_YES)) ? 1 : 0;
  ------------------
  |  |  150|  5.36k|#define MP_HAS(x)        (sizeof(MP_STRINGIZE(BN_##x##_C)) == 1u)
  |  |  ------------------
  |  |  |  |  148|  2.68k|#define MP_STRINGIZE(x)  MP__STRINGIZE(x)
  |  |  |  |  ------------------
  |  |  |  |  |  |  149|  2.68k|#define MP__STRINGIZE(x) ""#x""
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (150:26): [True: 2.68k, Folded]
  |  |  ------------------
  ------------------
                 dr = (MP_HAS(MP_DR_IS_MODULUS) && (mp_dr_is_modulus(P) == MP_YES)) ? 1 : 0;
  ------------------
  |  |  158|  2.68k|#define MP_YES        1
  ------------------
  |  Branch (57:38): [True: 0, False: 2.68k]
  ------------------
   58|       |
   59|       |   /* if not, is it a unrestricted DR modulus? */
   60|  2.68k|   if (MP_HAS(MP_REDUCE_IS_2K) && (dr == 0)) {
  ------------------
  |  |  150|  5.36k|#define MP_HAS(x)        (sizeof(MP_STRINGIZE(BN_##x##_C)) == 1u)
  |  |  ------------------
  |  |  |  |  148|  2.68k|#define MP_STRINGIZE(x)  MP__STRINGIZE(x)
  |  |  |  |  ------------------
  |  |  |  |  |  |  149|  2.68k|#define MP__STRINGIZE(x) ""#x""
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (150:26): [True: 2.68k, Folded]
  |  |  ------------------
  ------------------
  |  Branch (60:35): [True: 2.68k, False: 0]
  ------------------
   61|  2.68k|      dr = (mp_reduce_is_2k(P) == MP_YES) ? 2 : 0;
  ------------------
  |  |  158|  2.68k|#define MP_YES        1
  ------------------
  |  Branch (61:12): [True: 0, False: 2.68k]
  ------------------
   62|  2.68k|   }
   63|       |
   64|       |   /* if the modulus is odd or dr != 0 use the montgomery method */
   65|  2.68k|   if (MP_HAS(S_MP_EXPTMOD_FAST) && (MP_IS_ODD(P) || (dr != 0))) {
  ------------------
  |  |  150|  5.36k|#define MP_HAS(x)        (sizeof(MP_STRINGIZE(BN_##x##_C)) == 1u)
  |  |  ------------------
  |  |  |  |  148|  2.68k|#define MP_STRINGIZE(x)  MP__STRINGIZE(x)
  |  |  |  |  ------------------
  |  |  |  |  |  |  149|  2.68k|#define MP__STRINGIZE(x) ""#x""
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (150:26): [True: 2.68k, Folded]
  |  |  ------------------
  ------------------
                 if (MP_HAS(S_MP_EXPTMOD_FAST) && (MP_IS_ODD(P) || (dr != 0))) {
  ------------------
  |  |  165|  5.36k|#define MP_IS_ODD(a)  (((a)->used > 0) && (((a)->dp[0] & 1u) == 1u))
  |  |  ------------------
  |  |  |  Branch (165:24): [True: 2.68k, False: 0]
  |  |  |  Branch (165:43): [True: 2.36k, False: 313]
  |  |  ------------------
  ------------------
  |  Branch (65:54): [True: 0, False: 313]
  ------------------
   66|  2.36k|      return s_mp_exptmod_fast(G, X, P, Y, dr);
   67|  2.36k|   } else if (MP_HAS(S_MP_EXPTMOD)) {
  ------------------
  |  |  150|    313|#define MP_HAS(x)        (sizeof(MP_STRINGIZE(BN_##x##_C)) == 1u)
  |  |  ------------------
  |  |  |  |  148|    313|#define MP_STRINGIZE(x)  MP__STRINGIZE(x)
  |  |  |  |  ------------------
  |  |  |  |  |  |  149|    313|#define MP__STRINGIZE(x) ""#x""
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (150:26): [True: 313, Folded]
  |  |  ------------------
  ------------------
   68|       |      /* otherwise use the generic Barrett reduction technique */
   69|    313|      return s_mp_exptmod(G, X, P, Y, 0);
   70|    313|   } else {
   71|       |      /* no exptmod for evens */
   72|      0|      return MP_VAL;
  ------------------
  |  |  164|      0|#define MP_VAL        -3  /* invalid input */
  ------------------
   73|      0|   }
   74|  2.68k|}

mp_from_ubin:
    8|  9.06k|{
    9|  9.06k|   mp_err err;
   10|       |
   11|       |   /* make sure there are at least two digits */
   12|  9.06k|   if (a->alloc < 2) {
  ------------------
  |  Branch (12:8): [True: 0, False: 9.06k]
  ------------------
   13|      0|      if ((err = mp_grow(a, 2)) != MP_OKAY) {
  ------------------
  |  |  161|      0|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (13:11): [True: 0, False: 0]
  ------------------
   14|      0|         return err;
   15|      0|      }
   16|      0|   }
   17|       |
   18|       |   /* zero the int */
   19|  9.06k|   mp_zero(a);
   20|       |
   21|       |   /* read the bytes in */
   22|  1.51M|   while (size-- > 0u) {
  ------------------
  |  Branch (22:11): [True: 1.50M, False: 9.06k]
  ------------------
   23|  1.50M|      if ((err = mp_mul_2d(a, 8, a)) != MP_OKAY) {
  ------------------
  |  |  161|  1.50M|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (23:11): [True: 0, False: 1.50M]
  ------------------
   24|      0|         return err;
   25|      0|      }
   26|       |
   27|  1.50M|#ifndef MP_8BIT
   28|  1.50M|      a->dp[0] |= *buf++;
   29|  1.50M|      a->used += 1;
   30|       |#else
   31|       |      a->dp[0] = (*buf & MP_MASK);
   32|       |      a->dp[1] |= ((*buf++ >> 7) & 1u);
   33|       |      a->used += 2;
   34|       |#endif
   35|  1.50M|   }
   36|  9.06k|   mp_clamp(a);
   37|  9.06k|   return MP_OKAY;
  ------------------
  |  |  161|  9.06k|#define MP_OKAY       0   /* no error */
  ------------------
   38|  9.06k|}

mp_grow:
    8|   260k|{
    9|   260k|   int     i;
   10|   260k|   mp_digit *tmp;
   11|       |
   12|   260k|   if (size < 0) {
  ------------------
  |  Branch (12:8): [True: 0, False: 260k]
  ------------------
   13|      0|      return MP_VAL;
  ------------------
  |  |  164|      0|#define MP_VAL        -3  /* invalid input */
  ------------------
   14|      0|   }
   15|       |
   16|       |   /* if the alloc size is smaller alloc more ram */
   17|   260k|   if (a->alloc < size) {
  ------------------
  |  Branch (17:8): [True: 256k, False: 3.38k]
  ------------------
   18|       |      /* reallocate the array a->dp
   19|       |       *
   20|       |       * We store the return in a temporary variable
   21|       |       * in case the operation failed we don't want
   22|       |       * to overwrite the dp member of a.
   23|       |       */
   24|   256k|      tmp = (mp_digit *) MP_REALLOC(a->dp,
  ------------------
  |  | 1325|   256k|#define MP_REALLOC   m_realloc_ltm
  ------------------
   25|   256k|                                    (size_t)a->alloc * sizeof(mp_digit),
   26|   256k|                                    (size_t)size * sizeof(mp_digit));
   27|   256k|      if (tmp == NULL) {
  ------------------
  |  Branch (27:11): [True: 0, False: 256k]
  ------------------
   28|       |         /* reallocation failed but "a" is still valid [can be freed] */
   29|      0|         return MP_MEM;
  ------------------
  |  |  163|      0|#define MP_MEM        -2  /* out of mem */
  ------------------
   30|      0|      }
   31|       |
   32|       |      /* reallocation succeeded so set a->dp */
   33|   256k|      a->dp = tmp;
   34|       |
   35|       |      /* zero excess digits */
   36|   256k|      i        = a->alloc;
   37|   256k|      a->alloc = size;
   38|   256k|      MP_ZERO_DIGITS(a->dp + i, a->alloc - i);
  ------------------
  |  |   89|   256k|#  define MP_ZERO_DIGITS(mem, digits)                   \
  |  |   90|   256k|do {                                                    \
  |  |   91|   256k|   int zd_ = (digits);                                  \
  |  |   92|   256k|   mp_digit* zm_ = (mem);                               \
  |  |   93|  5.28M|   while (zd_-- > 0) {                                  \
  |  |  ------------------
  |  |  |  Branch (93:11): [True: 5.03M, False: 256k]
  |  |  ------------------
  |  |   94|  5.03M|      *zm_++ = 0;                                       \
  |  |   95|  5.03M|   }                                                    \
  |  |   96|   256k|} while (0)
  |  |  ------------------
  |  |  |  Branch (96:10): [Folded, False: 256k]
  |  |  ------------------
  ------------------
   39|   256k|   }
   40|   260k|   return MP_OKAY;
  ------------------
  |  |  161|   260k|#define MP_OKAY       0   /* no error */
  ------------------
   41|   260k|}

mp_init:
    8|  3.09M|{
    9|       |   /* allocate memory required and clear it */
   10|  3.09M|   a->dp = (mp_digit *) MP_CALLOC((size_t)MP_PREC, sizeof(mp_digit));
  ------------------
  |  | 1326|  3.09M|#define MP_CALLOC    m_calloc
  ------------------
                 a->dp = (mp_digit *) MP_CALLOC((size_t)MP_PREC, sizeof(mp_digit));
  ------------------
  |  |  177|  3.09M|#   define MP_PREC PRIVATE_MP_PREC
  |  |  ------------------
  |  |  |  |  193|  3.09M|#      define PRIVATE_MP_PREC 32        /* default digits of precision */
  |  |  ------------------
  ------------------
   11|  3.09M|   if (a->dp == NULL) {
  ------------------
  |  Branch (11:8): [True: 0, False: 3.09M]
  ------------------
   12|      0|      return MP_MEM;
  ------------------
  |  |  163|      0|#define MP_MEM        -2  /* out of mem */
  ------------------
   13|      0|   }
   14|       |
   15|       |   /* set the used to zero, allocated digits to the default precision
   16|       |    * and sign to positive */
   17|  3.09M|   a->used  = 0;
   18|  3.09M|   a->alloc = MP_PREC;
  ------------------
  |  |  177|  3.09M|#   define MP_PREC PRIVATE_MP_PREC
  |  |  ------------------
  |  |  |  |  193|  3.09M|#      define PRIVATE_MP_PREC 32        /* default digits of precision */
  |  |  ------------------
  ------------------
   19|  3.09M|   a->sign  = MP_ZPOS;
  ------------------
  |  |  151|  3.09M|#define MP_ZPOS       0   /* positive integer */
  ------------------
   20|       |
   21|  3.09M|   return MP_OKAY;
  ------------------
  |  |  161|  3.09M|#define MP_OKAY       0   /* no error */
  ------------------
   22|  3.09M|}

mp_init_copy:
    8|  46.7k|{
    9|  46.7k|   mp_err     err;
   10|       |
   11|  46.7k|   if ((err = mp_init_size(a, b->used)) != MP_OKAY) {
  ------------------
  |  |  161|  46.7k|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (11:8): [True: 0, False: 46.7k]
  ------------------
   12|      0|      return err;
   13|      0|   }
   14|       |
   15|  46.7k|   if ((err = mp_copy(b, a)) != MP_OKAY) {
  ------------------
  |  |  161|  46.7k|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (15:8): [True: 0, False: 46.7k]
  ------------------
   16|      0|      mp_clear(a);
   17|      0|   }
   18|       |
   19|  46.7k|   return err;
   20|  46.7k|}

mp_init_multi:
    9|  1.05k|{
   10|  1.05k|   mp_err err = MP_OKAY;      /* Assume ok until proven otherwise */
  ------------------
  |  |  161|  1.05k|#define MP_OKAY       0   /* no error */
  ------------------
   11|  1.05k|   int n = 0;                 /* Number of ok inits */
   12|  1.05k|   mp_int *cur_arg = mp;
   13|  1.05k|   va_list args;
   14|       |
   15|  1.05k|   va_start(args, mp);        /* init args to next argument from caller */
   16|  7.47k|   while (cur_arg != NULL) {
  ------------------
  |  Branch (16:11): [True: 6.42k, False: 1.05k]
  ------------------
   17|  6.42k|      if (mp_init(cur_arg) != MP_OKAY) {
  ------------------
  |  |  161|  6.42k|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (17:11): [True: 0, False: 6.42k]
  ------------------
   18|       |         /* Oops - error! Back-track and mp_clear what we already
   19|       |            succeeded in init-ing, then return error.
   20|       |         */
   21|      0|         va_list clean_args;
   22|       |
   23|       |         /* now start cleaning up */
   24|      0|         cur_arg = mp;
   25|      0|         va_start(clean_args, mp);
   26|      0|         while (n-- != 0) {
  ------------------
  |  Branch (26:17): [True: 0, False: 0]
  ------------------
   27|      0|            mp_clear(cur_arg);
   28|      0|            cur_arg = va_arg(clean_args, mp_int *);
   29|      0|         }
   30|      0|         va_end(clean_args);
   31|      0|         err = MP_MEM;
  ------------------
  |  |  163|      0|#define MP_MEM        -2  /* out of mem */
  ------------------
   32|      0|         break;
   33|      0|      }
   34|  6.42k|      n++;
   35|  6.42k|      cur_arg = va_arg(args, mp_int *);
   36|  6.42k|   }
   37|       |   va_end(args);
   38|  1.05k|   return err;                /* Assumed ok, if error flagged above. */
   39|  1.05k|}

mp_init_size:
    8|   204k|{
    9|       |
   10|   204k|   if (size < 0) {
  ------------------
  |  Branch (10:8): [True: 0, False: 204k]
  ------------------
   11|      0|      return MP_VAL;
  ------------------
  |  |  164|      0|#define MP_VAL        -3  /* invalid input */
  ------------------
   12|      0|   }
   13|       |
   14|   204k|   size = MP_MAX(MP_MIN_PREC, size);
  ------------------
  |  |  157|   204k|#define MP_MAX(x, y) (((x) > (y)) ? (x) : (y))
  |  |  ------------------
  |  |  |  Branch (157:23): [True: 12.2k, False: 192k]
  |  |  ------------------
  ------------------
   15|       |
   16|       |   /* alloc mem */
   17|   204k|   a->dp = (mp_digit *) MP_CALLOC((size_t)size, sizeof(mp_digit));
  ------------------
  |  | 1326|   204k|#define MP_CALLOC    m_calloc
  ------------------
   18|   204k|   if (a->dp == NULL) {
  ------------------
  |  Branch (18:8): [True: 0, False: 204k]
  ------------------
   19|      0|      return MP_MEM;
  ------------------
  |  |  163|      0|#define MP_MEM        -2  /* out of mem */
  ------------------
   20|      0|   }
   21|       |
   22|       |   /* set the members */
   23|   204k|   a->used  = 0;
   24|   204k|   a->alloc = size;
   25|   204k|   a->sign  = MP_ZPOS;
  ------------------
  |  |  151|   204k|#define MP_ZPOS       0   /* positive integer */
  ------------------
   26|       |
   27|   204k|   return MP_OKAY;
  ------------------
  |  |  161|   204k|#define MP_OKAY       0   /* no error */
  ------------------
   28|   204k|}

mp_invmod:
    8|  1.05k|{
    9|       |   /* b cannot be negative and has to be >1 */
   10|  1.05k|   if ((b->sign == MP_NEG) || (mp_cmp_d(b, 1uL) != MP_GT)) {
  ------------------
  |  |  152|  1.05k|#define MP_NEG        1   /* negative */
  ------------------
                 if ((b->sign == MP_NEG) || (mp_cmp_d(b, 1uL) != MP_GT)) {
  ------------------
  |  |  156|  1.05k|#define MP_GT         1   /* greater than */
  ------------------
  |  Branch (10:8): [True: 0, False: 1.05k]
  |  Branch (10:31): [True: 0, False: 1.05k]
  ------------------
   11|      0|      return MP_VAL;
  ------------------
  |  |  164|      0|#define MP_VAL        -3  /* invalid input */
  ------------------
   12|      0|   }
   13|       |
   14|       |   /* if the modulus is odd we can use a faster routine instead */
   15|  1.05k|   if (MP_HAS(S_MP_INVMOD_FAST) && MP_IS_ODD(b)) {
  ------------------
  |  |  150|  2.10k|#define MP_HAS(x)        (sizeof(MP_STRINGIZE(BN_##x##_C)) == 1u)
  |  |  ------------------
  |  |  |  |  148|  1.05k|#define MP_STRINGIZE(x)  MP__STRINGIZE(x)
  |  |  |  |  ------------------
  |  |  |  |  |  |  149|  1.05k|#define MP__STRINGIZE(x) ""#x""
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (150:26): [True: 1.05k, Folded]
  |  |  ------------------
  ------------------
                 if (MP_HAS(S_MP_INVMOD_FAST) && MP_IS_ODD(b)) {
  ------------------
  |  |  165|  1.05k|#define MP_IS_ODD(a)  (((a)->used > 0) && (((a)->dp[0] & 1u) == 1u))
  |  |  ------------------
  |  |  |  Branch (165:24): [True: 1.05k, False: 0]
  |  |  |  Branch (165:43): [True: 1.00k, False: 53]
  |  |  ------------------
  ------------------
   16|  1.00k|      return s_mp_invmod_fast(a, b, c);
   17|  1.00k|   }
   18|       |
   19|     53|   return MP_HAS(S_MP_INVMOD_SLOW)
  ------------------
  |  |  150|     53|#define MP_HAS(x)        (sizeof(MP_STRINGIZE(BN_##x##_C)) == 1u)
  |  |  ------------------
  |  |  |  |  148|     53|#define MP_STRINGIZE(x)  MP__STRINGIZE(x)
  |  |  |  |  ------------------
  |  |  |  |  |  |  149|     53|#define MP__STRINGIZE(x) ""#x""
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (150:26): [True: 53, Folded]
  |  |  ------------------
  ------------------
   20|     53|          ? s_mp_invmod_slow(a, b, c)
   21|     53|          : MP_VAL;
  ------------------
  |  |  164|      0|#define MP_VAL        -3  /* invalid input */
  ------------------
   22|  1.05k|}

mp_lshd:
    8|  37.6k|{
    9|  37.6k|   int x;
   10|  37.6k|   mp_err err;
   11|  37.6k|   mp_digit *top, *bottom;
   12|       |
   13|       |   /* if its less than zero return */
   14|  37.6k|   if (b <= 0) {
  ------------------
  |  Branch (14:8): [True: 6.12k, False: 31.5k]
  ------------------
   15|  6.12k|      return MP_OKAY;
  ------------------
  |  |  161|  6.12k|#define MP_OKAY       0   /* no error */
  ------------------
   16|  6.12k|   }
   17|       |   /* no need to shift 0 around */
   18|  31.5k|   if (MP_IS_ZERO(a)) {
  ------------------
  |  |  163|  31.5k|#define MP_IS_ZERO(a) ((a)->used == 0)
  |  |  ------------------
  |  |  |  Branch (163:23): [True: 111, False: 31.4k]
  |  |  ------------------
  ------------------
   19|    111|      return MP_OKAY;
  ------------------
  |  |  161|    111|#define MP_OKAY       0   /* no error */
  ------------------
   20|    111|   }
   21|       |
   22|       |   /* grow to fit the new digits */
   23|  31.4k|   if (a->alloc < (a->used + b)) {
  ------------------
  |  Branch (23:8): [True: 3.71k, False: 27.7k]
  ------------------
   24|  3.71k|      if ((err = mp_grow(a, a->used + b)) != MP_OKAY) {
  ------------------
  |  |  161|  3.71k|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (24:11): [True: 0, False: 3.71k]
  ------------------
   25|      0|         return err;
   26|      0|      }
   27|  3.71k|   }
   28|       |
   29|       |   /* increment the used by the shift amount then copy upwards */
   30|  31.4k|   a->used += b;
   31|       |
   32|       |   /* top */
   33|  31.4k|   top = a->dp + a->used - 1;
   34|       |
   35|       |   /* base */
   36|  31.4k|   bottom = (a->dp + a->used - 1) - b;
   37|       |
   38|       |   /* much like mp_rshd this is implemented using a sliding window
   39|       |    * except the window goes the otherway around.  Copying from
   40|       |    * the bottom to the top.  see bn_mp_rshd.c for more info.
   41|       |    */
   42|   421k|   for (x = a->used - 1; x >= b; x--) {
  ------------------
  |  Branch (42:26): [True: 389k, False: 31.4k]
  ------------------
   43|   389k|      *top-- = *bottom--;
   44|   389k|   }
   45|       |
   46|       |   /* zero the lower digits */
   47|  31.4k|   MP_ZERO_DIGITS(a->dp, b);
  ------------------
  |  |   89|  31.4k|#  define MP_ZERO_DIGITS(mem, digits)                   \
  |  |   90|  31.4k|do {                                                    \
  |  |   91|  31.4k|   int zd_ = (digits);                                  \
  |  |   92|  31.4k|   mp_digit* zm_ = (mem);                               \
  |  |   93|   210k|   while (zd_-- > 0) {                                  \
  |  |  ------------------
  |  |  |  Branch (93:11): [True: 179k, False: 31.4k]
  |  |  ------------------
  |  |   94|   179k|      *zm_++ = 0;                                       \
  |  |   95|   179k|   }                                                    \
  |  |   96|  31.4k|} while (0)
  |  |  ------------------
  |  |  |  Branch (96:10): [Folded, False: 31.4k]
  |  |  ------------------
  ------------------
   48|       |
   49|  31.4k|   return MP_OKAY;
  ------------------
  |  |  161|  31.4k|#define MP_OKAY       0   /* no error */
  ------------------
   50|  31.4k|}

mp_mod:
    8|  7.53k|{
    9|  7.53k|   mp_int  t;
   10|  7.53k|   mp_err  err;
   11|       |
   12|  7.53k|   if ((err = mp_init_size(&t, b->used)) != MP_OKAY) {
  ------------------
  |  |  161|  7.53k|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (12:8): [True: 0, False: 7.53k]
  ------------------
   13|      0|      return err;
   14|      0|   }
   15|       |
   16|  7.53k|   if ((err = mp_div(a, b, NULL, &t)) != MP_OKAY) {
  ------------------
  |  |  161|  7.53k|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (16:8): [True: 0, False: 7.53k]
  ------------------
   17|      0|      goto LBL_ERR;
   18|      0|   }
   19|       |
   20|  7.53k|   if (MP_IS_ZERO(&t) || (t.sign == b->sign)) {
  ------------------
  |  |  163|  15.0k|#define MP_IS_ZERO(a) ((a)->used == 0)
  |  |  ------------------
  |  |  |  Branch (163:23): [True: 539, False: 6.99k]
  |  |  ------------------
  ------------------
  |  Branch (20:26): [True: 6.99k, False: 3]
  ------------------
   21|  7.53k|      err = MP_OKAY;
  ------------------
  |  |  161|  7.53k|#define MP_OKAY       0   /* no error */
  ------------------
   22|  7.53k|      mp_exch(&t, c);
   23|  7.53k|   } else {
   24|      3|      err = mp_add(b, &t, c);
   25|      3|   }
   26|       |
   27|  7.53k|LBL_ERR:
   28|  7.53k|   mp_clear(&t);
   29|  7.53k|   return err;
   30|  7.53k|}

mp_mod_2d:
    8|  5.04M|{
    9|  5.04M|   int x;
   10|  5.04M|   mp_err err;
   11|       |
   12|       |   /* if b is <= 0 then zero the int */
   13|  5.04M|   if (b <= 0) {
  ------------------
  |  Branch (13:8): [True: 0, False: 5.04M]
  ------------------
   14|      0|      mp_zero(c);
   15|      0|      return MP_OKAY;
  ------------------
  |  |  161|      0|#define MP_OKAY       0   /* no error */
  ------------------
   16|      0|   }
   17|       |
   18|       |   /* if the modulus is larger than the value than return */
   19|  5.04M|   if (b >= (a->used * MP_DIGIT_BIT)) {
  ------------------
  |  |   82|  5.04M|#   define MP_DIGIT_BIT 60
  ------------------
  |  Branch (19:8): [True: 17.0k, False: 5.02M]
  ------------------
   20|  17.0k|      return mp_copy(a, c);
   21|  17.0k|   }
   22|       |
   23|       |   /* copy */
   24|  5.02M|   if ((err = mp_copy(a, c)) != MP_OKAY) {
  ------------------
  |  |  161|  5.02M|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (24:8): [True: 0, False: 5.02M]
  ------------------
   25|      0|      return err;
   26|      0|   }
   27|       |
   28|       |   /* zero digits above the last digit of the modulus */
   29|  5.02M|   x = (b / MP_DIGIT_BIT) + (((b % MP_DIGIT_BIT) == 0) ? 0 : 1);
  ------------------
  |  |   82|  5.02M|#   define MP_DIGIT_BIT 60
  ------------------
                 x = (b / MP_DIGIT_BIT) + (((b % MP_DIGIT_BIT) == 0) ? 0 : 1);
  ------------------
  |  |   82|  5.02M|#   define MP_DIGIT_BIT 60
  ------------------
  |  Branch (29:30): [True: 186k, False: 4.83M]
  ------------------
   30|  5.02M|   MP_ZERO_DIGITS(c->dp + x, c->used - x);
  ------------------
  |  |   89|  5.02M|#  define MP_ZERO_DIGITS(mem, digits)                   \
  |  |   90|  5.02M|do {                                                    \
  |  |   91|  5.02M|   int zd_ = (digits);                                  \
  |  |   92|  5.02M|   mp_digit* zm_ = (mem);                               \
  |  |   93|  46.1M|   while (zd_-- > 0) {                                  \
  |  |  ------------------
  |  |  |  Branch (93:11): [True: 41.1M, False: 5.02M]
  |  |  ------------------
  |  |   94|  41.1M|      *zm_++ = 0;                                       \
  |  |   95|  41.1M|   }                                                    \
  |  |   96|  5.02M|} while (0)
  |  |  ------------------
  |  |  |  Branch (96:10): [Folded, False: 5.02M]
  |  |  ------------------
  ------------------
   31|       |
   32|       |   /* clear the digit that is not completely outside/inside the modulus */
   33|  5.02M|   c->dp[b / MP_DIGIT_BIT] &=
  ------------------
  |  |   82|  5.02M|#   define MP_DIGIT_BIT 60
  ------------------
   34|  5.02M|      ((mp_digit)1 << (mp_digit)(b % MP_DIGIT_BIT)) - (mp_digit)1;
  ------------------
  |  |   82|  5.02M|#   define MP_DIGIT_BIT 60
  ------------------
   35|  5.02M|   mp_clamp(c);
   36|  5.02M|   return MP_OKAY;
  ------------------
  |  |  161|  5.02M|#define MP_OKAY       0   /* no error */
  ------------------
   37|  5.02M|}

mp_montgomery_calc_normalization:
   13|  3.25k|{
   14|  3.25k|   int    x, bits;
   15|  3.25k|   mp_err err;
   16|       |
   17|       |   /* how many bits of last digit does b use */
   18|  3.25k|   bits = mp_count_bits(b) % MP_DIGIT_BIT;
  ------------------
  |  |   82|  3.25k|#   define MP_DIGIT_BIT 60
  ------------------
   19|       |
   20|  3.25k|   if (b->used > 1) {
  ------------------
  |  Branch (20:8): [True: 3.25k, False: 0]
  ------------------
   21|  3.25k|      if ((err = mp_2expt(a, ((b->used - 1) * MP_DIGIT_BIT) + bits - 1)) != MP_OKAY) {
  ------------------
  |  |   82|  3.25k|#   define MP_DIGIT_BIT 60
  ------------------
                    if ((err = mp_2expt(a, ((b->used - 1) * MP_DIGIT_BIT) + bits - 1)) != MP_OKAY) {
  ------------------
  |  |  161|  3.25k|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (21:11): [True: 0, False: 3.25k]
  ------------------
   22|      0|         return err;
   23|      0|      }
   24|  3.25k|   } else {
   25|      0|      mp_set(a, 1uL);
   26|      0|      bits = 1;
   27|      0|   }
   28|       |
   29|       |
   30|       |   /* now compute C = A * B mod b */
   31|   149k|   for (x = bits - 1; x < (int)MP_DIGIT_BIT; x++) {
  ------------------
  |  |   82|   149k|#   define MP_DIGIT_BIT 60
  ------------------
  |  Branch (31:23): [True: 146k, False: 3.25k]
  ------------------
   32|   146k|      if ((err = mp_mul_2(a, a)) != MP_OKAY) {
  ------------------
  |  |  161|   146k|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (32:11): [True: 0, False: 146k]
  ------------------
   33|      0|         return err;
   34|      0|      }
   35|   146k|      if (mp_cmp_mag(a, b) != MP_LT) {
  ------------------
  |  |  154|   146k|#define MP_LT        -1   /* less than */
  ------------------
  |  Branch (35:11): [True: 10.3k, False: 136k]
  ------------------
   36|  10.3k|         if ((err = s_mp_sub(a, b, a)) != MP_OKAY) {
  ------------------
  |  |  161|  10.3k|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (36:14): [True: 0, False: 10.3k]
  ------------------
   37|      0|            return err;
   38|      0|         }
   39|  10.3k|      }
   40|   146k|   }
   41|       |
   42|  3.25k|   return MP_OKAY;
  ------------------
  |  |  161|  3.25k|#define MP_OKAY       0   /* no error */
  ------------------
   43|  3.25k|}

mp_montgomery_reduce:
    8|  10.3M|{
    9|  10.3M|   int      ix, digs;
   10|  10.3M|   mp_err   err;
   11|  10.3M|   mp_digit mu;
   12|       |
   13|       |   /* can the fast reduction [comba] method be used?
   14|       |    *
   15|       |    * Note that unlike in mul you're safely allowed *less*
   16|       |    * than the available columns [255 per default] since carries
   17|       |    * are fixed up in the inner loop.
   18|       |    */
   19|  10.3M|   digs = (n->used * 2) + 1;
   20|  10.3M|   if ((digs < MP_WARRAY) &&
  ------------------
  |  |  172|  10.3M|#define MP_WARRAY PRIVATE_MP_WARRAY
  |  |  ------------------
  |  |  |  |  203|  10.3M|#define PRIVATE_MP_WARRAY (int)(1uLL << (((CHAR_BIT * sizeof(private_mp_word)) - (2 * MP_DIGIT_BIT)) + 1))
  |  |  |  |  ------------------
  |  |  |  |  |  |   82|  10.3M|#   define MP_DIGIT_BIT 60
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (20:8): [True: 10.3M, False: 0]
  ------------------
   21|  10.3M|       (x->used <= MP_WARRAY) &&
  ------------------
  |  |  172|  10.3M|#define MP_WARRAY PRIVATE_MP_WARRAY
  |  |  ------------------
  |  |  |  |  203|  10.3M|#define PRIVATE_MP_WARRAY (int)(1uLL << (((CHAR_BIT * sizeof(private_mp_word)) - (2 * MP_DIGIT_BIT)) + 1))
  |  |  |  |  ------------------
  |  |  |  |  |  |   82|  10.3M|#   define MP_DIGIT_BIT 60
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (21:8): [True: 10.3M, False: 0]
  ------------------
   22|  10.3M|       (n->used < MP_MAXFAST)) {
  ------------------
  |  |  168|  10.3M|#define MP_MAXFAST              (int)(1uL << (MP_SIZEOF_BITS(mp_word) - (2u * (size_t)MP_DIGIT_BIT)))
  |  |  ------------------
  |  |  |  |  167|  10.3M|#define MP_SIZEOF_BITS(type)    ((size_t)CHAR_BIT * sizeof(type))
  |  |  ------------------
  |  |               #define MP_MAXFAST              (int)(1uL << (MP_SIZEOF_BITS(mp_word) - (2u * (size_t)MP_DIGIT_BIT)))
  |  |  ------------------
  |  |  |  |   82|  10.3M|#   define MP_DIGIT_BIT 60
  |  |  ------------------
  ------------------
  |  Branch (22:8): [True: 10.3M, False: 0]
  ------------------
   23|  10.3M|      return s_mp_montgomery_reduce_fast(x, n, rho);
   24|  10.3M|   }
   25|       |
   26|       |   /* grow the input as required */
   27|      0|   if (x->alloc < digs) {
  ------------------
  |  Branch (27:8): [True: 0, False: 0]
  ------------------
   28|      0|      if ((err = mp_grow(x, digs)) != MP_OKAY) {
  ------------------
  |  |  161|      0|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (28:11): [True: 0, False: 0]
  ------------------
   29|      0|         return err;
   30|      0|      }
   31|      0|   }
   32|      0|   x->used = digs;
   33|       |
   34|      0|   for (ix = 0; ix < n->used; ix++) {
  ------------------
  |  Branch (34:17): [True: 0, False: 0]
  ------------------
   35|       |      /* mu = ai * rho mod b
   36|       |       *
   37|       |       * The value of rho must be precalculated via
   38|       |       * montgomery_setup() such that
   39|       |       * it equals -1/n0 mod b this allows the
   40|       |       * following inner loop to reduce the
   41|       |       * input one digit at a time
   42|       |       */
   43|      0|      mu = (mp_digit)(((mp_word)x->dp[ix] * (mp_word)rho) & MP_MASK);
  ------------------
  |  |  106|      0|#define MP_MASK          ((((mp_digit)1)<<((mp_digit)MP_DIGIT_BIT))-((mp_digit)1))
  |  |  ------------------
  |  |  |  |   82|      0|#   define MP_DIGIT_BIT 60
  |  |  ------------------
  ------------------
   44|       |
   45|       |      /* a = a + mu * m * b**i */
   46|      0|      {
   47|      0|         int iy;
   48|      0|         mp_digit *tmpn, *tmpx, u;
   49|      0|         mp_word r;
   50|       |
   51|       |         /* alias for digits of the modulus */
   52|      0|         tmpn = n->dp;
   53|       |
   54|       |         /* alias for the digits of x [the input] */
   55|      0|         tmpx = x->dp + ix;
   56|       |
   57|       |         /* set the carry to zero */
   58|      0|         u = 0;
   59|       |
   60|       |         /* Multiply and add in place */
   61|      0|         for (iy = 0; iy < n->used; iy++) {
  ------------------
  |  Branch (61:23): [True: 0, False: 0]
  ------------------
   62|       |            /* compute product and sum */
   63|      0|            r       = ((mp_word)mu * (mp_word)*tmpn++) +
   64|      0|                      (mp_word)u + (mp_word)*tmpx;
   65|       |
   66|       |            /* get carry */
   67|      0|            u       = (mp_digit)(r >> (mp_word)MP_DIGIT_BIT);
  ------------------
  |  |   82|      0|#   define MP_DIGIT_BIT 60
  ------------------
   68|       |
   69|       |            /* fix digit */
   70|      0|            *tmpx++ = (mp_digit)(r & (mp_word)MP_MASK);
  ------------------
  |  |  106|      0|#define MP_MASK          ((((mp_digit)1)<<((mp_digit)MP_DIGIT_BIT))-((mp_digit)1))
  |  |  ------------------
  |  |  |  |   82|      0|#   define MP_DIGIT_BIT 60
  |  |  ------------------
  ------------------
   71|      0|         }
   72|       |         /* At this point the ix'th digit of x should be zero */
   73|       |
   74|       |
   75|       |         /* propagate carries upwards as required*/
   76|      0|         while (u != 0u) {
  ------------------
  |  Branch (76:17): [True: 0, False: 0]
  ------------------
   77|      0|            *tmpx   += u;
   78|      0|            u        = *tmpx >> MP_DIGIT_BIT;
  ------------------
  |  |   82|      0|#   define MP_DIGIT_BIT 60
  ------------------
   79|      0|            *tmpx++ &= MP_MASK;
  ------------------
  |  |  106|      0|#define MP_MASK          ((((mp_digit)1)<<((mp_digit)MP_DIGIT_BIT))-((mp_digit)1))
  |  |  ------------------
  |  |  |  |   82|      0|#   define MP_DIGIT_BIT 60
  |  |  ------------------
  ------------------
   80|      0|         }
   81|      0|      }
   82|      0|   }
   83|       |
   84|       |   /* at this point the n.used'th least
   85|       |    * significant digits of x are all zero
   86|       |    * which means we can shift x to the
   87|       |    * right by n.used digits and the
   88|       |    * residue is unchanged.
   89|       |    */
   90|       |
   91|       |   /* x = x/b**n.used */
   92|      0|   mp_clamp(x);
   93|      0|   mp_rshd(x, n->used);
   94|       |
   95|       |   /* if x >= n then x = x - n */
   96|      0|   if (mp_cmp_mag(x, n) != MP_LT) {
  ------------------
  |  |  154|      0|#define MP_LT        -1   /* less than */
  ------------------
  |  Branch (96:8): [True: 0, False: 0]
  ------------------
   97|      0|      return s_mp_sub(x, n, x);
   98|      0|   }
   99|       |
  100|      0|   return MP_OKAY;
  ------------------
  |  |  161|      0|#define MP_OKAY       0   /* no error */
  ------------------
  101|      0|}

mp_montgomery_setup:
    8|  3.25k|{
    9|  3.25k|   mp_digit x, b;
   10|       |
   11|       |   /* fast inversion mod 2**k
   12|       |    *
   13|       |    * Based on the fact that
   14|       |    *
   15|       |    * XA = 1 (mod 2**n)  =>  (X(2-XA)) A = 1 (mod 2**2n)
   16|       |    *                    =>  2*X*A - X*X*A*A = 1
   17|       |    *                    =>  2*(1) - (1)     = 1
   18|       |    */
   19|  3.25k|   b = n->dp[0];
   20|       |
   21|  3.25k|   if ((b & 1u) == 0u) {
  ------------------
  |  Branch (21:8): [True: 0, False: 3.25k]
  ------------------
   22|      0|      return MP_VAL;
  ------------------
  |  |  164|      0|#define MP_VAL        -3  /* invalid input */
  ------------------
   23|      0|   }
   24|       |
   25|  3.25k|   x = (((b + 2u) & 4u) << 1) + b; /* here x*a==1 mod 2**4 */
   26|  3.25k|   x *= 2u - (b * x);              /* here x*a==1 mod 2**8 */
   27|  3.25k|#if !defined(MP_8BIT)
   28|  3.25k|   x *= 2u - (b * x);              /* here x*a==1 mod 2**16 */
   29|  3.25k|#endif
   30|  3.25k|#if defined(MP_64BIT) || !(defined(MP_8BIT) || defined(MP_16BIT))
   31|  3.25k|   x *= 2u - (b * x);              /* here x*a==1 mod 2**32 */
   32|  3.25k|#endif
   33|  3.25k|#ifdef MP_64BIT
   34|  3.25k|   x *= 2u - (b * x);              /* here x*a==1 mod 2**64 */
   35|  3.25k|#endif
   36|       |
   37|       |   /* rho = -1/m mod b */
   38|  3.25k|   *rho = (mp_digit)(((mp_word)1 << (mp_word)MP_DIGIT_BIT) - x) & MP_MASK;
  ------------------
  |  |   82|  3.25k|#   define MP_DIGIT_BIT 60
  ------------------
                 *rho = (mp_digit)(((mp_word)1 << (mp_word)MP_DIGIT_BIT) - x) & MP_MASK;
  ------------------
  |  |  106|  3.25k|#define MP_MASK          ((((mp_digit)1)<<((mp_digit)MP_DIGIT_BIT))-((mp_digit)1))
  |  |  ------------------
  |  |  |  |   82|  3.25k|#   define MP_DIGIT_BIT 60
  |  |  ------------------
  ------------------
   39|       |
   40|  3.25k|   return MP_OKAY;
  ------------------
  |  |  161|  3.25k|#define MP_OKAY       0   /* no error */
  ------------------
   41|  3.25k|}

mp_mul:
    8|  12.5M|{
    9|  12.5M|   mp_err err;
   10|  12.5M|   int min_len = MP_MIN(a->used, b->used),
  ------------------
  |  |  156|  12.5M|#define MP_MIN(x, y) (((x) < (y)) ? (x) : (y))
  |  |  ------------------
  |  |  |  Branch (156:23): [True: 5.00M, False: 7.58M]
  |  |  ------------------
  ------------------
   11|  12.5M|       max_len = MP_MAX(a->used, b->used),
  ------------------
  |  |  157|  12.5M|#define MP_MAX(x, y) (((x) > (y)) ? (x) : (y))
  |  |  ------------------
  |  |  |  Branch (157:23): [True: 115k, False: 12.4M]
  |  |  ------------------
  ------------------
   12|  12.5M|       digs = a->used + b->used + 1;
   13|  12.5M|   mp_sign neg = (a->sign == b->sign) ? MP_ZPOS : MP_NEG;
  ------------------
  |  |  151|  12.5M|#define MP_ZPOS       0   /* positive integer */
  ------------------
                 mp_sign neg = (a->sign == b->sign) ? MP_ZPOS : MP_NEG;
  ------------------
  |  |  152|      0|#define MP_NEG        1   /* negative */
  ------------------
  |  Branch (13:18): [True: 12.5M, False: 0]
  ------------------
   14|       |
   15|  12.5M|   if (MP_HAS(S_MP_BALANCE_MUL) &&
  ------------------
  |  |  150|  25.1M|#define MP_HAS(x)        (sizeof(MP_STRINGIZE(BN_##x##_C)) == 1u)
  |  |  ------------------
  |  |  |  |  148|  12.5M|#define MP_STRINGIZE(x)  MP__STRINGIZE(x)
  |  |  |  |  ------------------
  |  |  |  |  |  |  149|  12.5M|#define MP__STRINGIZE(x) ""#x""
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (150:26): [True: 12.5M, Folded]
  |  |  ------------------
  ------------------
   16|       |       /* Check sizes. The smaller one needs to be larger than the Karatsuba cut-off.
   17|       |        * The bigger one needs to be at least about one MP_KARATSUBA_MUL_CUTOFF bigger
   18|       |        * to make some sense, but it depends on architecture, OS, position of the
   19|       |        * stars... so YMMV.
   20|       |        * Using it to cut the input into slices small enough for fast_s_mp_mul_digs
   21|       |        * was actually slower on the author's machine, but YMMV.
   22|       |        */
   23|  12.5M|       (min_len >= MP_KARATSUBA_MUL_CUTOFF) &&
  ------------------
  |  |  121|  12.5M|#  define MP_KARATSUBA_MUL_CUTOFF KARATSUBA_MUL_CUTOFF
  ------------------
  |  Branch (23:8): [True: 0, False: 12.5M]
  ------------------
   24|      0|       ((max_len / 2) >= MP_KARATSUBA_MUL_CUTOFF) &&
  ------------------
  |  |  121|      0|#  define MP_KARATSUBA_MUL_CUTOFF KARATSUBA_MUL_CUTOFF
  ------------------
  |  Branch (24:8): [True: 0, False: 0]
  ------------------
   25|       |       /* Not much effect was observed below a ratio of 1:2, but again: YMMV. */
   26|      0|       (max_len >= (2 * min_len))) {
  ------------------
  |  Branch (26:8): [True: 0, False: 0]
  ------------------
   27|      0|      err = s_mp_balance_mul(a,b,c);
   28|  12.5M|   } else if (MP_HAS(S_MP_TOOM_MUL) &&
  ------------------
  |  |  150|  25.1M|#define MP_HAS(x)        (sizeof(MP_STRINGIZE(BN_##x##_C)) == 1u)
  |  |  ------------------
  |  |  |  |  148|  12.5M|#define MP_STRINGIZE(x)  MP__STRINGIZE(x)
  |  |  |  |  ------------------
  |  |  |  |  |  |  149|  12.5M|#define MP__STRINGIZE(x) ""#x""
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (150:26): [Folded, False: 12.5M]
  |  |  ------------------
  ------------------
   29|      0|              (min_len >= MP_TOOM_MUL_CUTOFF)) {
  ------------------
  |  |  123|      0|#  define MP_TOOM_MUL_CUTOFF      TOOM_MUL_CUTOFF
  ------------------
  |  Branch (29:15): [True: 0, False: 0]
  ------------------
   30|      0|      err = s_mp_toom_mul(a, b, c);
   31|  12.5M|   } else if (MP_HAS(S_MP_KARATSUBA_MUL) &&
  ------------------
  |  |  150|  25.1M|#define MP_HAS(x)        (sizeof(MP_STRINGIZE(BN_##x##_C)) == 1u)
  |  |  ------------------
  |  |  |  |  148|  12.5M|#define MP_STRINGIZE(x)  MP__STRINGIZE(x)
  |  |  |  |  ------------------
  |  |  |  |  |  |  149|  12.5M|#define MP__STRINGIZE(x) ""#x""
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (150:26): [Folded, False: 12.5M]
  |  |  ------------------
  ------------------
   32|      0|              (min_len >= MP_KARATSUBA_MUL_CUTOFF)) {
  ------------------
  |  |  121|      0|#  define MP_KARATSUBA_MUL_CUTOFF KARATSUBA_MUL_CUTOFF
  ------------------
  |  Branch (32:15): [True: 0, False: 0]
  ------------------
   33|      0|      err = s_mp_karatsuba_mul(a, b, c);
   34|  12.5M|   } else if (MP_HAS(S_MP_MUL_DIGS_FAST) &&
  ------------------
  |  |  150|  25.1M|#define MP_HAS(x)        (sizeof(MP_STRINGIZE(BN_##x##_C)) == 1u)
  |  |  ------------------
  |  |  |  |  148|  12.5M|#define MP_STRINGIZE(x)  MP__STRINGIZE(x)
  |  |  |  |  ------------------
  |  |  |  |  |  |  149|  12.5M|#define MP__STRINGIZE(x) ""#x""
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (150:26): [True: 12.5M, Folded]
  |  |  ------------------
  ------------------
   35|       |              /* can we use the fast multiplier?
   36|       |               *
   37|       |               * The fast multiplier can be used if the output will
   38|       |               * have less than MP_WARRAY digits and the number of
   39|       |               * digits won't affect carry propagation
   40|       |               */
   41|  12.5M|              (digs < MP_WARRAY) &&
  ------------------
  |  |  172|  12.5M|#define MP_WARRAY PRIVATE_MP_WARRAY
  |  |  ------------------
  |  |  |  |  203|  12.5M|#define PRIVATE_MP_WARRAY (int)(1uLL << (((CHAR_BIT * sizeof(private_mp_word)) - (2 * MP_DIGIT_BIT)) + 1))
  |  |  |  |  ------------------
  |  |  |  |  |  |   82|  12.5M|#   define MP_DIGIT_BIT 60
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (41:15): [True: 12.5M, False: 0]
  ------------------
   42|  12.5M|              (min_len <= MP_MAXFAST)) {
  ------------------
  |  |  168|  12.5M|#define MP_MAXFAST              (int)(1uL << (MP_SIZEOF_BITS(mp_word) - (2u * (size_t)MP_DIGIT_BIT)))
  |  |  ------------------
  |  |  |  |  167|  12.5M|#define MP_SIZEOF_BITS(type)    ((size_t)CHAR_BIT * sizeof(type))
  |  |  ------------------
  |  |               #define MP_MAXFAST              (int)(1uL << (MP_SIZEOF_BITS(mp_word) - (2u * (size_t)MP_DIGIT_BIT)))
  |  |  ------------------
  |  |  |  |   82|  12.5M|#   define MP_DIGIT_BIT 60
  |  |  ------------------
  ------------------
  |  Branch (42:15): [True: 12.5M, False: 0]
  ------------------
   43|  12.5M|      err = s_mp_mul_digs_fast(a, b, c, digs);
   44|  12.5M|   } else if (MP_HAS(S_MP_MUL_DIGS)) {
  ------------------
  |  |  150|      0|#define MP_HAS(x)        (sizeof(MP_STRINGIZE(BN_##x##_C)) == 1u)
  |  |  ------------------
  |  |  |  |  148|      0|#define MP_STRINGIZE(x)  MP__STRINGIZE(x)
  |  |  |  |  ------------------
  |  |  |  |  |  |  149|      0|#define MP__STRINGIZE(x) ""#x""
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (150:26): [True: 0, Folded]
  |  |  ------------------
  ------------------
   45|      0|      err = s_mp_mul_digs(a, b, c, digs);
   46|      0|   } else {
   47|      0|      err = MP_VAL;
  ------------------
  |  |  164|      0|#define MP_VAL        -3  /* invalid input */
  ------------------
   48|      0|   }
   49|  12.5M|   c->sign = (c->used > 0) ? neg : MP_ZPOS;
  ------------------
  |  |  151|  12.6M|#define MP_ZPOS       0   /* positive integer */
  ------------------
  |  Branch (49:14): [True: 12.5M, False: 14.9k]
  ------------------
   50|  12.5M|   return err;
   51|  12.5M|}

mp_mul_2:
    8|   146k|{
    9|   146k|   int     x, oldused;
   10|   146k|   mp_err err;
   11|       |
   12|       |   /* grow to accomodate result */
   13|   146k|   if (b->alloc < (a->used + 1)) {
  ------------------
  |  Branch (13:8): [True: 0, False: 146k]
  ------------------
   14|      0|      if ((err = mp_grow(b, a->used + 1)) != MP_OKAY) {
  ------------------
  |  |  161|      0|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (14:11): [True: 0, False: 0]
  ------------------
   15|      0|         return err;
   16|      0|      }
   17|      0|   }
   18|       |
   19|   146k|   oldused = b->used;
   20|   146k|   b->used = a->used;
   21|       |
   22|   146k|   {
   23|   146k|      mp_digit r, rr, *tmpa, *tmpb;
   24|       |
   25|       |      /* alias for source */
   26|   146k|      tmpa = a->dp;
   27|       |
   28|       |      /* alias for dest */
   29|   146k|      tmpb = b->dp;
   30|       |
   31|       |      /* carry */
   32|   146k|      r = 0;
   33|  4.18M|      for (x = 0; x < a->used; x++) {
  ------------------
  |  Branch (33:19): [True: 4.04M, False: 146k]
  ------------------
   34|       |
   35|       |         /* get what will be the *next* carry bit from the
   36|       |          * MSB of the current digit
   37|       |          */
   38|  4.04M|         rr = *tmpa >> (mp_digit)(MP_DIGIT_BIT - 1);
  ------------------
  |  |   82|  4.04M|#   define MP_DIGIT_BIT 60
  ------------------
   39|       |
   40|       |         /* now shift up this digit, add in the carry [from the previous] */
   41|  4.04M|         *tmpb++ = ((*tmpa++ << 1uL) | r) & MP_MASK;
  ------------------
  |  |  106|  4.04M|#define MP_MASK          ((((mp_digit)1)<<((mp_digit)MP_DIGIT_BIT))-((mp_digit)1))
  |  |  ------------------
  |  |  |  |   82|  4.04M|#   define MP_DIGIT_BIT 60
  |  |  ------------------
  ------------------
   42|       |
   43|       |         /* copy the carry that would be from the source
   44|       |          * digit into the next iteration
   45|       |          */
   46|  4.04M|         r = rr;
   47|  4.04M|      }
   48|       |
   49|       |      /* new leading digit? */
   50|   146k|      if (r != 0u) {
  ------------------
  |  Branch (50:11): [True: 1.25k, False: 145k]
  ------------------
   51|       |         /* add a MSB which is always 1 at this point */
   52|  1.25k|         *tmpb = 1;
   53|  1.25k|         ++(b->used);
   54|  1.25k|      }
   55|       |
   56|       |      /* now zero any excess digits on the destination
   57|       |       * that we didn't write to
   58|       |       */
   59|   146k|      MP_ZERO_DIGITS(b->dp + b->used, oldused - b->used);
  ------------------
  |  |   89|   146k|#  define MP_ZERO_DIGITS(mem, digits)                   \
  |  |   90|   146k|do {                                                    \
  |  |   91|   146k|   int zd_ = (digits);                                  \
  |  |   92|   146k|   mp_digit* zm_ = (mem);                               \
  |  |   93|   146k|   while (zd_-- > 0) {                                  \
  |  |  ------------------
  |  |  |  Branch (93:11): [True: 0, False: 146k]
  |  |  ------------------
  |  |   94|      0|      *zm_++ = 0;                                       \
  |  |   95|      0|   }                                                    \
  |  |   96|   146k|} while (0)
  |  |  ------------------
  |  |  |  Branch (96:10): [Folded, False: 146k]
  |  |  ------------------
  ------------------
   60|   146k|   }
   61|   146k|   b->sign = a->sign;
   62|   146k|   return MP_OKAY;
  ------------------
  |  |  161|   146k|#define MP_OKAY       0   /* no error */
  ------------------
   63|   146k|}

mp_mul_2d:
    8|  1.51M|{
    9|  1.51M|   mp_digit d;
   10|  1.51M|   mp_err   err;
   11|       |
   12|  1.51M|   if (b < 0) {
  ------------------
  |  Branch (12:8): [True: 0, False: 1.51M]
  ------------------
   13|      0|      return MP_VAL;
  ------------------
  |  |  164|      0|#define MP_VAL        -3  /* invalid input */
  ------------------
   14|      0|   }
   15|       |
   16|       |   /* copy */
   17|  1.51M|   if (a != c) {
  ------------------
  |  Branch (17:8): [True: 0, False: 1.51M]
  ------------------
   18|      0|      if ((err = mp_copy(a, c)) != MP_OKAY) {
  ------------------
  |  |  161|      0|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (18:11): [True: 0, False: 0]
  ------------------
   19|      0|         return err;
   20|      0|      }
   21|      0|   }
   22|       |
   23|  1.51M|   if (c->alloc < (c->used + (b / MP_DIGIT_BIT) + 1)) {
  ------------------
  |  |   82|  1.51M|#   define MP_DIGIT_BIT 60
  ------------------
  |  Branch (23:8): [True: 65.2k, False: 1.45M]
  ------------------
   24|  65.2k|      if ((err = mp_grow(c, c->used + (b / MP_DIGIT_BIT) + 1)) != MP_OKAY) {
  ------------------
  |  |   82|  65.2k|#   define MP_DIGIT_BIT 60
  ------------------
                    if ((err = mp_grow(c, c->used + (b / MP_DIGIT_BIT) + 1)) != MP_OKAY) {
  ------------------
  |  |  161|  65.2k|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (24:11): [True: 0, False: 65.2k]
  ------------------
   25|      0|         return err;
   26|      0|      }
   27|  65.2k|   }
   28|       |
   29|       |   /* shift by as many digits in the bit count */
   30|  1.51M|   if (b >= MP_DIGIT_BIT) {
  ------------------
  |  |   82|  1.51M|#   define MP_DIGIT_BIT 60
  ------------------
  |  Branch (30:8): [True: 0, False: 1.51M]
  ------------------
   31|      0|      if ((err = mp_lshd(c, b / MP_DIGIT_BIT)) != MP_OKAY) {
  ------------------
  |  |   82|      0|#   define MP_DIGIT_BIT 60
  ------------------
                    if ((err = mp_lshd(c, b / MP_DIGIT_BIT)) != MP_OKAY) {
  ------------------
  |  |  161|      0|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (31:11): [True: 0, False: 0]
  ------------------
   32|      0|         return err;
   33|      0|      }
   34|      0|   }
   35|       |
   36|       |   /* shift any bit count < MP_DIGIT_BIT */
   37|  1.51M|   d = (mp_digit)(b % MP_DIGIT_BIT);
  ------------------
  |  |   82|  1.51M|#   define MP_DIGIT_BIT 60
  ------------------
   38|  1.51M|   if (d != 0u) {
  ------------------
  |  Branch (38:8): [True: 1.51M, False: 0]
  ------------------
   39|  1.51M|      mp_digit *tmpc, shift, mask, r, rr;
   40|  1.51M|      int x;
   41|       |
   42|       |      /* bitmask for carries */
   43|  1.51M|      mask = ((mp_digit)1 << d) - (mp_digit)1;
   44|       |
   45|       |      /* shift for msbs */
   46|  1.51M|      shift = (mp_digit)MP_DIGIT_BIT - d;
  ------------------
  |  |   82|  1.51M|#   define MP_DIGIT_BIT 60
  ------------------
   47|       |
   48|       |      /* alias */
   49|  1.51M|      tmpc = c->dp;
   50|       |
   51|       |      /* carry */
   52|  1.51M|      r    = 0;
   53|   462M|      for (x = 0; x < c->used; x++) {
  ------------------
  |  Branch (53:19): [True: 461M, False: 1.51M]
  ------------------
   54|       |         /* get the higher bits of the current word */
   55|   461M|         rr = (*tmpc >> shift) & mask;
   56|       |
   57|       |         /* shift the current word and OR in the carry */
   58|   461M|         *tmpc = ((*tmpc << d) | r) & MP_MASK;
  ------------------
  |  |  106|   461M|#define MP_MASK          ((((mp_digit)1)<<((mp_digit)MP_DIGIT_BIT))-((mp_digit)1))
  |  |  ------------------
  |  |  |  |   82|   461M|#   define MP_DIGIT_BIT 60
  |  |  ------------------
  ------------------
   59|   461M|         ++tmpc;
   60|       |
   61|       |         /* set the carry to the carry bits of the current word */
   62|   461M|         r = rr;
   63|   461M|      }
   64|       |
   65|       |      /* set final carry */
   66|  1.51M|      if (r != 0u) {
  ------------------
  |  Branch (66:11): [True: 3.63k, False: 1.51M]
  ------------------
   67|  3.63k|         c->dp[(c->used)++] = r;
   68|  3.63k|      }
   69|  1.51M|   }
   70|  1.51M|   mp_clamp(c);
   71|  1.51M|   return MP_OKAY;
  ------------------
  |  |  161|  1.51M|#define MP_OKAY       0   /* no error */
  ------------------
   72|  1.51M|}

mp_mul_d:
    8|   522k|{
    9|   522k|   mp_digit u, *tmpa, *tmpc;
   10|   522k|   mp_word  r;
   11|   522k|   mp_err   err;
   12|   522k|   int      ix, olduse;
   13|       |
   14|       |   /* make sure c is big enough to hold a*b */
   15|   522k|   if (c->alloc < (a->used + 1)) {
  ------------------
  |  Branch (15:8): [True: 826, False: 522k]
  ------------------
   16|    826|      if ((err = mp_grow(c, a->used + 1)) != MP_OKAY) {
  ------------------
  |  |  161|    826|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (16:11): [True: 0, False: 826]
  ------------------
   17|      0|         return err;
   18|      0|      }
   19|    826|   }
   20|       |
   21|       |   /* get the original destinations used count */
   22|   522k|   olduse = c->used;
   23|       |
   24|       |   /* set the sign */
   25|   522k|   c->sign = a->sign;
   26|       |
   27|       |   /* alias for a->dp [source] */
   28|   522k|   tmpa = a->dp;
   29|       |
   30|       |   /* alias for c->dp [dest] */
   31|   522k|   tmpc = c->dp;
   32|       |
   33|       |   /* zero carry */
   34|   522k|   u = 0;
   35|       |
   36|       |   /* compute columns */
   37|  3.00M|   for (ix = 0; ix < a->used; ix++) {
  ------------------
  |  Branch (37:17): [True: 2.48M, False: 522k]
  ------------------
   38|       |      /* compute product and carry sum for this term */
   39|  2.48M|      r       = (mp_word)u + ((mp_word)*tmpa++ * (mp_word)b);
   40|       |
   41|       |      /* mask off higher bits to get a single digit */
   42|  2.48M|      *tmpc++ = (mp_digit)(r & (mp_word)MP_MASK);
  ------------------
  |  |  106|  2.48M|#define MP_MASK          ((((mp_digit)1)<<((mp_digit)MP_DIGIT_BIT))-((mp_digit)1))
  |  |  ------------------
  |  |  |  |   82|  2.48M|#   define MP_DIGIT_BIT 60
  |  |  ------------------
  ------------------
   43|       |
   44|       |      /* send carry into next iteration */
   45|  2.48M|      u       = (mp_digit)(r >> (mp_word)MP_DIGIT_BIT);
  ------------------
  |  |   82|  2.48M|#   define MP_DIGIT_BIT 60
  ------------------
   46|  2.48M|   }
   47|       |
   48|       |   /* store final carry [if any] and increment ix offset  */
   49|   522k|   *tmpc++ = u;
   50|   522k|   ++ix;
   51|       |
   52|       |   /* now zero digits above the top */
   53|   522k|   MP_ZERO_DIGITS(tmpc, olduse - ix);
  ------------------
  |  |   89|   522k|#  define MP_ZERO_DIGITS(mem, digits)                   \
  |  |   90|   522k|do {                                                    \
  |  |   91|   522k|   int zd_ = (digits);                                  \
  |  |   92|   522k|   mp_digit* zm_ = (mem);                               \
  |  |   93|   522k|   while (zd_-- > 0) {                                  \
  |  |  ------------------
  |  |  |  Branch (93:11): [True: 0, False: 522k]
  |  |  ------------------
  |  |   94|      0|      *zm_++ = 0;                                       \
  |  |   95|      0|   }                                                    \
  |  |   96|   522k|} while (0)
  |  |  ------------------
  |  |  |  Branch (96:10): [Folded, False: 522k]
  |  |  ------------------
  ------------------
   54|       |
   55|       |   /* set used count */
   56|   522k|   c->used = a->used + 1;
   57|   522k|   mp_clamp(c);
   58|       |
   59|   522k|   return MP_OKAY;
  ------------------
  |  |  161|   522k|#define MP_OKAY       0   /* no error */
  ------------------
   60|   522k|}

mp_mulmod:
    8|  5.57k|{
    9|  5.57k|   mp_err err;
   10|  5.57k|   mp_int t;
   11|       |
   12|  5.57k|   if ((err = mp_init_size(&t, c->used)) != MP_OKAY) {
  ------------------
  |  |  161|  5.57k|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (12:8): [True: 0, False: 5.57k]
  ------------------
   13|      0|      return err;
   14|      0|   }
   15|       |
   16|  5.57k|   if ((err = mp_mul(a, b, &t)) != MP_OKAY) {
  ------------------
  |  |  161|  5.57k|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (16:8): [True: 0, False: 5.57k]
  ------------------
   17|      0|      goto LBL_ERR;
   18|      0|   }
   19|  5.57k|   err = mp_mod(&t, c, d);
   20|       |
   21|  5.57k|LBL_ERR:
   22|  5.57k|   mp_clear(&t);
   23|  5.57k|   return err;
   24|  5.57k|}

mp_rand_source:
   10|      1|{
   11|       |   /* Dropbear, don't reset to platform if source==NULL */
   12|      1|   s_mp_rand_source = source;
   13|      1|}

mp_read_radix:
   10|  3.70k|{
   11|  3.70k|   mp_err   err;
   12|  3.70k|   int      y;
   13|  3.70k|   mp_sign  neg;
   14|  3.70k|   unsigned pos;
   15|  3.70k|   char     ch;
   16|       |
   17|       |   /* zero the digit bignum */
   18|  3.70k|   mp_zero(a);
   19|       |
   20|       |   /* make sure the radix is ok */
   21|  3.70k|   if ((radix < 2) || (radix > 64)) {
  ------------------
  |  Branch (21:8): [True: 0, False: 3.70k]
  |  Branch (21:23): [True: 0, False: 3.70k]
  ------------------
   22|      0|      return MP_VAL;
  ------------------
  |  |  164|      0|#define MP_VAL        -3  /* invalid input */
  ------------------
   23|      0|   }
   24|       |
   25|       |   /* if the leading digit is a
   26|       |    * minus set the sign to negative.
   27|       |    */
   28|  3.70k|   if (*str == '-') {
  ------------------
  |  Branch (28:8): [True: 0, False: 3.70k]
  ------------------
   29|      0|      ++str;
   30|      0|      neg = MP_NEG;
  ------------------
  |  |  152|      0|#define MP_NEG        1   /* negative */
  ------------------
   31|  3.70k|   } else {
   32|  3.70k|      neg = MP_ZPOS;
  ------------------
  |  |  151|  3.70k|#define MP_ZPOS       0   /* positive integer */
  ------------------
   33|  3.70k|   }
   34|       |
   35|       |   /* set the integer to the default of zero */
   36|  3.70k|   mp_zero(a);
   37|       |
   38|       |   /* process each digit of the string */
   39|   445k|   while (*str != '\0') {
  ------------------
  |  Branch (39:11): [True: 441k, False: 3.70k]
  ------------------
   40|       |      /* if the radix <= 36 the conversion is case insensitive
   41|       |       * this allows numbers like 1AB and 1ab to represent the same  value
   42|       |       * [e.g. in hex]
   43|       |       */
   44|   441k|      ch = (radix <= 36) ? (char)MP_TOUPPER((int)*str) : *str;
  ------------------
  |  |    6|   441k|#define MP_TOUPPER(c) ((((c) >= 'a') && ((c) <= 'z')) ? (((c) + 'A') - 'a') : (c))
  |  |  ------------------
  |  |  |  Branch (6:25): [True: 0, False: 441k]
  |  |  |  Branch (6:41): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (44:12): [True: 441k, False: 0]
  ------------------
   45|   441k|      pos = (unsigned)(ch - '(');
   46|   441k|      if (mp_s_rmap_reverse_sz < pos) {
  ------------------
  |  Branch (46:11): [True: 0, False: 441k]
  ------------------
   47|      0|         break;
   48|      0|      }
   49|   441k|      y = (int)mp_s_rmap_reverse[pos];
   50|       |
   51|       |      /* if the char was found in the map
   52|       |       * and is less than the given radix add it
   53|       |       * to the number, otherwise exit the loop.
   54|       |       */
   55|   441k|      if ((y == 0xff) || (y >= radix)) {
  ------------------
  |  Branch (55:11): [True: 0, False: 441k]
  |  Branch (55:26): [True: 0, False: 441k]
  ------------------
   56|      0|         break;
   57|      0|      }
   58|   441k|      if ((err = mp_mul_d(a, (mp_digit)radix, a)) != MP_OKAY) {
  ------------------
  |  |  161|   441k|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (58:11): [True: 0, False: 441k]
  ------------------
   59|      0|         return err;
   60|      0|      }
   61|   441k|      if ((err = mp_add_d(a, (mp_digit)y, a)) != MP_OKAY) {
  ------------------
  |  |  161|   441k|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (61:11): [True: 0, False: 441k]
  ------------------
   62|      0|         return err;
   63|      0|      }
   64|   441k|      ++str;
   65|   441k|   }
   66|       |
   67|       |   /* if an illegal character was found, fail. */
   68|  3.70k|   if (!((*str == '\0') || (*str == '\r') || (*str == '\n'))) {
  ------------------
  |  Branch (68:10): [True: 3.70k, False: 0]
  |  Branch (68:28): [True: 0, False: 0]
  |  Branch (68:46): [True: 0, False: 0]
  ------------------
   69|      0|      mp_zero(a);
   70|      0|      return MP_VAL;
  ------------------
  |  |  164|      0|#define MP_VAL        -3  /* invalid input */
  ------------------
   71|      0|   }
   72|       |
   73|       |   /* set the sign only if a != 0 */
   74|  3.70k|   if (!MP_IS_ZERO(a)) {
  ------------------
  |  |  163|  3.70k|#define MP_IS_ZERO(a) ((a)->used == 0)
  ------------------
  |  Branch (74:8): [True: 3.70k, False: 0]
  ------------------
   75|  3.70k|      a->sign = neg;
   76|  3.70k|   }
   77|  3.70k|   return MP_OKAY;
  ------------------
  |  |  161|  3.70k|#define MP_OKAY       0   /* no error */
  ------------------
   78|  3.70k|}

mp_reduce:
   11|  26.3k|{
   12|  26.3k|   mp_int  q;
   13|  26.3k|   mp_err  err;
   14|  26.3k|   int     um = m->used;
   15|       |
   16|       |   /* q = x */
   17|  26.3k|   if ((err = mp_init_copy(&q, x)) != MP_OKAY) {
  ------------------
  |  |  161|  26.3k|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (17:8): [True: 0, False: 26.3k]
  ------------------
   18|      0|      return err;
   19|      0|   }
   20|       |
   21|       |   /* q1 = x / b**(k-1)  */
   22|  26.3k|   mp_rshd(&q, um - 1);
   23|       |
   24|       |   /* according to HAC this optimization is ok */
   25|  26.3k|   if ((mp_digit)um > ((mp_digit)1 << (MP_DIGIT_BIT - 1))) {
  ------------------
  |  |   82|  26.3k|#   define MP_DIGIT_BIT 60
  ------------------
  |  Branch (25:8): [True: 0, False: 26.3k]
  ------------------
   26|      0|      if ((err = mp_mul(&q, mu, &q)) != MP_OKAY) {
  ------------------
  |  |  161|      0|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (26:11): [True: 0, False: 0]
  ------------------
   27|      0|         goto CLEANUP;
   28|      0|      }
   29|  26.3k|   } else if (MP_HAS(S_MP_MUL_HIGH_DIGS)) {
  ------------------
  |  |  150|  26.3k|#define MP_HAS(x)        (sizeof(MP_STRINGIZE(BN_##x##_C)) == 1u)
  |  |  ------------------
  |  |  |  |  148|  26.3k|#define MP_STRINGIZE(x)  MP__STRINGIZE(x)
  |  |  |  |  ------------------
  |  |  |  |  |  |  149|  26.3k|#define MP__STRINGIZE(x) ""#x""
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (150:26): [True: 26.3k, Folded]
  |  |  ------------------
  ------------------
   30|  26.3k|      if ((err = s_mp_mul_high_digs(&q, mu, &q, um)) != MP_OKAY) {
  ------------------
  |  |  161|  26.3k|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (30:11): [True: 0, False: 26.3k]
  ------------------
   31|      0|         goto CLEANUP;
   32|      0|      }
   33|  26.3k|   } else if (MP_HAS(S_MP_MUL_HIGH_DIGS_FAST)) {
  ------------------
  |  |  150|      0|#define MP_HAS(x)        (sizeof(MP_STRINGIZE(BN_##x##_C)) == 1u)
  |  |  ------------------
  |  |  |  |  148|      0|#define MP_STRINGIZE(x)  MP__STRINGIZE(x)
  |  |  |  |  ------------------
  |  |  |  |  |  |  149|      0|#define MP__STRINGIZE(x) ""#x""
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (150:26): [True: 0, Folded]
  |  |  ------------------
  ------------------
   34|      0|      if ((err = s_mp_mul_high_digs_fast(&q, mu, &q, um)) != MP_OKAY) {
  ------------------
  |  |  161|      0|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (34:11): [True: 0, False: 0]
  ------------------
   35|      0|         goto CLEANUP;
   36|      0|      }
   37|      0|   } else {
   38|      0|      err = MP_VAL;
  ------------------
  |  |  164|      0|#define MP_VAL        -3  /* invalid input */
  ------------------
   39|      0|      goto CLEANUP;
   40|      0|   }
   41|       |
   42|       |   /* q3 = q2 / b**(k+1) */
   43|  26.3k|   mp_rshd(&q, um + 1);
   44|       |
   45|       |   /* x = x mod b**(k+1), quick (no division) */
   46|  26.3k|   if ((err = mp_mod_2d(x, MP_DIGIT_BIT * (um + 1), x)) != MP_OKAY) {
  ------------------
  |  |   82|  26.3k|#   define MP_DIGIT_BIT 60
  ------------------
                 if ((err = mp_mod_2d(x, MP_DIGIT_BIT * (um + 1), x)) != MP_OKAY) {
  ------------------
  |  |  161|  26.3k|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (46:8): [True: 0, False: 26.3k]
  ------------------
   47|      0|      goto CLEANUP;
   48|      0|   }
   49|       |
   50|       |   /* q = q * m mod b**(k+1), quick (no division) */
   51|  26.3k|   if ((err = s_mp_mul_digs(&q, m, &q, um + 1)) != MP_OKAY) {
  ------------------
  |  |  161|  26.3k|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (51:8): [True: 0, False: 26.3k]
  ------------------
   52|      0|      goto CLEANUP;
   53|      0|   }
   54|       |
   55|       |   /* x = x - q */
   56|  26.3k|   if ((err = mp_sub(x, &q, x)) != MP_OKAY) {
  ------------------
  |  |  161|  26.3k|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (56:8): [True: 0, False: 26.3k]
  ------------------
   57|      0|      goto CLEANUP;
   58|      0|   }
   59|       |
   60|       |   /* If x < 0, add b**(k+1) to it */
   61|  26.3k|   if (mp_cmp_d(x, 0uL) == MP_LT) {
  ------------------
  |  |  154|  26.3k|#define MP_LT        -1   /* less than */
  ------------------
  |  Branch (61:8): [True: 571, False: 25.8k]
  ------------------
   62|    571|      mp_set(&q, 1uL);
   63|    571|      if ((err = mp_lshd(&q, um + 1)) != MP_OKAY) {
  ------------------
  |  |  161|    571|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (63:11): [True: 0, False: 571]
  ------------------
   64|      0|         goto CLEANUP;
   65|      0|      }
   66|    571|      if ((err = mp_add(x, &q, x)) != MP_OKAY) {
  ------------------
  |  |  161|    571|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (66:11): [True: 0, False: 571]
  ------------------
   67|      0|         goto CLEANUP;
   68|      0|      }
   69|    571|   }
   70|       |
   71|       |   /* Back off if it's too big */
   72|  77.2k|   while (mp_cmp(x, m) != MP_LT) {
  ------------------
  |  |  154|  77.2k|#define MP_LT        -1   /* less than */
  ------------------
  |  Branch (72:11): [True: 50.8k, False: 26.3k]
  ------------------
   73|  50.8k|      if ((err = s_mp_sub(x, m, x)) != MP_OKAY) {
  ------------------
  |  |  161|  50.8k|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (73:11): [True: 0, False: 50.8k]
  ------------------
   74|      0|         goto CLEANUP;
   75|      0|      }
   76|  50.8k|   }
   77|       |
   78|  26.3k|CLEANUP:
   79|  26.3k|   mp_clear(&q);
   80|       |
   81|  26.3k|   return err;
   82|  26.3k|}

mp_reduce_2k_l:
   11|  9.41k|{
   12|  9.41k|   mp_int q;
   13|  9.41k|   mp_err err;
   14|  9.41k|   int    p;
   15|       |
   16|  9.41k|   if ((err = mp_init(&q)) != MP_OKAY) {
  ------------------
  |  |  161|  9.41k|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (16:8): [True: 0, False: 9.41k]
  ------------------
   17|      0|      return err;
   18|      0|   }
   19|       |
   20|  9.41k|   p = mp_count_bits(n);
   21|  5.01M|top:
   22|       |   /* q = a/2**p, a = a mod 2**p */
   23|  5.01M|   if ((err = mp_div_2d(a, p, &q, a)) != MP_OKAY) {
  ------------------
  |  |  161|  5.01M|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (23:8): [True: 0, False: 5.01M]
  ------------------
   24|      0|      goto LBL_ERR;
   25|      0|   }
   26|       |
   27|       |   /* q = q * d */
   28|  5.01M|   if ((err = mp_mul(&q, d, &q)) != MP_OKAY) {
  ------------------
  |  |  161|  5.01M|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (28:8): [True: 0, False: 5.01M]
  ------------------
   29|      0|      goto LBL_ERR;
   30|      0|   }
   31|       |
   32|       |   /* a = a + q */
   33|  5.01M|   if ((err = s_mp_add(a, &q, a)) != MP_OKAY) {
  ------------------
  |  |  161|  5.01M|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (33:8): [True: 0, False: 5.01M]
  ------------------
   34|      0|      goto LBL_ERR;
   35|      0|   }
   36|       |
   37|  5.01M|   if (mp_cmp_mag(a, n) != MP_LT) {
  ------------------
  |  |  154|  5.01M|#define MP_LT        -1   /* less than */
  ------------------
  |  Branch (37:8): [True: 5.00M, False: 9.41k]
  ------------------
   38|  5.00M|      if ((err = s_mp_sub(a, n, a)) != MP_OKAY) {
  ------------------
  |  |  161|  5.00M|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (38:11): [True: 0, False: 5.00M]
  ------------------
   39|      0|         goto LBL_ERR;
   40|      0|      }
   41|  5.00M|      goto top;
   42|  5.00M|   }
   43|       |
   44|  9.41k|LBL_ERR:
   45|  9.41k|   mp_clear(&q);
   46|  9.41k|   return err;
   47|  5.01M|}

mp_reduce_2k_setup_l:
    8|    128|{
    9|    128|   mp_err err;
   10|    128|   mp_int tmp;
   11|       |
   12|    128|   if ((err = mp_init(&tmp)) != MP_OKAY) {
  ------------------
  |  |  161|    128|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (12:8): [True: 0, False: 128]
  ------------------
   13|      0|      return err;
   14|      0|   }
   15|       |
   16|    128|   if ((err = mp_2expt(&tmp, mp_count_bits(a))) != MP_OKAY) {
  ------------------
  |  |  161|    128|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (16:8): [True: 0, False: 128]
  ------------------
   17|      0|      goto LBL_ERR;
   18|      0|   }
   19|       |
   20|    128|   if ((err = s_mp_sub(&tmp, a, d)) != MP_OKAY) {
  ------------------
  |  |  161|    128|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (20:8): [True: 0, False: 128]
  ------------------
   21|      0|      goto LBL_ERR;
   22|      0|   }
   23|       |
   24|    128|LBL_ERR:
   25|    128|   mp_clear(&tmp);
   26|    128|   return err;
   27|    128|}

mp_reduce_is_2k:
    8|  2.68k|{
    9|  2.68k|   int ix, iy, iw;
   10|  2.68k|   mp_digit iz;
   11|       |
   12|  2.68k|   if (a->used == 0) {
  ------------------
  |  Branch (12:8): [True: 0, False: 2.68k]
  ------------------
   13|      0|      return MP_NO;
  ------------------
  |  |  159|      0|#define MP_NO         0
  ------------------
   14|  2.68k|   } else if (a->used == 1) {
  ------------------
  |  Branch (14:15): [True: 0, False: 2.68k]
  ------------------
   15|      0|      return MP_YES;
  ------------------
  |  |  158|      0|#define MP_YES        1
  ------------------
   16|  2.68k|   } else if (a->used > 1) {
  ------------------
  |  Branch (16:15): [True: 2.68k, False: 0]
  ------------------
   17|  2.68k|      iy = mp_count_bits(a);
   18|  2.68k|      iz = 1;
   19|  2.68k|      iw = 1;
   20|       |
   21|       |      /* Test every bit from the second digit up, must be 1 */
   22|  22.8k|      for (ix = MP_DIGIT_BIT; ix < iy; ix++) {
  ------------------
  |  |   82|  2.68k|#   define MP_DIGIT_BIT 60
  ------------------
  |  Branch (22:31): [True: 22.8k, False: 0]
  ------------------
   23|  22.8k|         if ((a->dp[iw] & iz) == 0u) {
  ------------------
  |  Branch (23:14): [True: 2.68k, False: 20.1k]
  ------------------
   24|  2.68k|            return MP_NO;
  ------------------
  |  |  159|  2.68k|#define MP_NO         0
  ------------------
   25|  2.68k|         }
   26|  20.1k|         iz <<= 1;
   27|  20.1k|         if (iz > MP_DIGIT_MAX) {
  ------------------
  |  |  107|  20.1k|#define MP_DIGIT_MAX     MP_MASK
  |  |  ------------------
  |  |  |  |  106|  20.1k|#define MP_MASK          ((((mp_digit)1)<<((mp_digit)MP_DIGIT_BIT))-((mp_digit)1))
  |  |  |  |  ------------------
  |  |  |  |  |  |   82|  20.1k|#   define MP_DIGIT_BIT 60
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (27:14): [True: 112, False: 20.0k]
  ------------------
   28|    112|            ++iw;
   29|    112|            iz = 1;
   30|    112|         }
   31|  20.1k|      }
   32|      0|      return MP_YES;
  ------------------
  |  |  158|      0|#define MP_YES        1
  ------------------
   33|  2.68k|   } else {
   34|      0|      return MP_YES;
  ------------------
  |  |  158|      0|#define MP_YES        1
  ------------------
   35|      0|   }
   36|  2.68k|}

mp_reduce_is_2k_l:
    8|  2.80k|{
    9|  2.80k|   int ix, iy;
   10|       |
   11|  2.80k|   if (a->used == 0) {
  ------------------
  |  Branch (11:8): [True: 0, False: 2.80k]
  ------------------
   12|      0|      return MP_NO;
  ------------------
  |  |  159|      0|#define MP_NO         0
  ------------------
   13|  2.80k|   } else if (a->used == 1) {
  ------------------
  |  Branch (13:15): [True: 0, False: 2.80k]
  ------------------
   14|      0|      return MP_YES;
  ------------------
  |  |  158|      0|#define MP_YES        1
  ------------------
   15|  2.80k|   } else if (a->used > 1) {
  ------------------
  |  Branch (15:15): [True: 2.80k, False: 0]
  ------------------
   16|       |      /* if more than half of the digits are -1 we're sold */
   17|  88.8k|      for (iy = ix = 0; ix < a->used; ix++) {
  ------------------
  |  Branch (17:25): [True: 86.0k, False: 2.80k]
  ------------------
   18|  86.0k|         if (a->dp[ix] == MP_DIGIT_MAX) {
  ------------------
  |  |  107|  86.0k|#define MP_DIGIT_MAX     MP_MASK
  |  |  ------------------
  |  |  |  |  106|  86.0k|#define MP_MASK          ((((mp_digit)1)<<((mp_digit)MP_DIGIT_BIT))-((mp_digit)1))
  |  |  |  |  ------------------
  |  |  |  |  |  |   82|  86.0k|#   define MP_DIGIT_BIT 60
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (18:14): [True: 4.26k, False: 81.7k]
  ------------------
   19|  4.26k|            ++iy;
   20|  4.26k|         }
   21|  86.0k|      }
   22|  2.80k|      return (iy >= (a->used/2)) ? MP_YES : MP_NO;
  ------------------
  |  |  158|    128|#define MP_YES        1
  ------------------
                    return (iy >= (a->used/2)) ? MP_YES : MP_NO;
  ------------------
  |  |  159|  2.68k|#define MP_NO         0
  ------------------
  |  Branch (22:14): [True: 128, False: 2.68k]
  ------------------
   23|  2.80k|   } else {
   24|      0|      return MP_NO;
  ------------------
  |  |  159|      0|#define MP_NO         0
  ------------------
   25|      0|   }
   26|  2.80k|}

mp_reduce_setup:
   10|    313|{
   11|    313|   mp_err err;
   12|    313|   if ((err = mp_2expt(a, b->used * 2 * MP_DIGIT_BIT)) != MP_OKAY) {
  ------------------
  |  |   82|    313|#   define MP_DIGIT_BIT 60
  ------------------
                 if ((err = mp_2expt(a, b->used * 2 * MP_DIGIT_BIT)) != MP_OKAY) {
  ------------------
  |  |  161|    313|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (12:8): [True: 0, False: 313]
  ------------------
   13|      0|      return err;
   14|      0|   }
   15|    313|   return mp_div(a, b, a, NULL);
   16|    313|}

mp_rshd:
    8|  5.07M|{
    9|  5.07M|   int     x;
   10|  5.07M|   mp_digit *bottom, *top;
   11|       |
   12|       |   /* if b <= 0 then ignore it */
   13|  5.07M|   if (b <= 0) {
  ------------------
  |  Branch (13:8): [True: 22, False: 5.07M]
  ------------------
   14|     22|      return;
   15|     22|   }
   16|       |
   17|       |   /* if b > used then simply zero it and return */
   18|  5.07M|   if (a->used <= b) {
  ------------------
  |  Branch (18:8): [True: 28.6k, False: 5.04M]
  ------------------
   19|  28.6k|      mp_zero(a);
   20|  28.6k|      return;
   21|  28.6k|   }
   22|       |
   23|       |   /* shift the digits down */
   24|       |
   25|       |   /* bottom */
   26|  5.04M|   bottom = a->dp;
   27|       |
   28|       |   /* top [offset into digits] */
   29|  5.04M|   top = a->dp + b;
   30|       |
   31|       |   /* this is implemented as a sliding window where
   32|       |    * the window is b-digits long and digits from
   33|       |    * the top of the window are copied to the bottom
   34|       |    *
   35|       |    * e.g.
   36|       |
   37|       |    b-2 | b-1 | b0 | b1 | b2 | ... | bb |   ---->
   38|       |                /\                   |      ---->
   39|       |                 \-------------------/      ---->
   40|       |    */
   41|  51.3M|   for (x = 0; x < (a->used - b); x++) {
  ------------------
  |  Branch (41:16): [True: 46.2M, False: 5.04M]
  ------------------
   42|  46.2M|      *bottom++ = *top++;
   43|  46.2M|   }
   44|       |
   45|       |   /* zero the top digits */
   46|  5.04M|   MP_ZERO_DIGITS(bottom, a->used - x);
  ------------------
  |  |   89|  5.04M|#  define MP_ZERO_DIGITS(mem, digits)                   \
  |  |   90|  5.04M|do {                                                    \
  |  |   91|  5.04M|   int zd_ = (digits);                                  \
  |  |   92|  5.04M|   mp_digit* zm_ = (mem);                               \
  |  |   93|  91.3M|   while (zd_-- > 0) {                                  \
  |  |  ------------------
  |  |  |  Branch (93:11): [True: 86.2M, False: 5.04M]
  |  |  ------------------
  |  |   94|  86.2M|      *zm_++ = 0;                                       \
  |  |   95|  86.2M|   }                                                    \
  |  |   96|  5.04M|} while (0)
  |  |  ------------------
  |  |  |  Branch (96:10): [Folded, False: 5.04M]
  |  |  ------------------
  ------------------
   47|       |
   48|       |   /* remove excess digits */
   49|  5.04M|   a->used -= b;
   50|  5.04M|}

mp_set:
    8|  2.30k|{
    9|  2.30k|   a->dp[0] = b & MP_MASK;
  ------------------
  |  |  106|  2.30k|#define MP_MASK          ((((mp_digit)1)<<((mp_digit)MP_DIGIT_BIT))-((mp_digit)1))
  |  |  ------------------
  |  |  |  |   82|  2.30k|#   define MP_DIGIT_BIT 60
  |  |  ------------------
  ------------------
   10|  2.30k|   a->sign  = MP_ZPOS;
  ------------------
  |  |  151|  2.30k|#define MP_ZPOS       0   /* positive integer */
  ------------------
   11|  2.30k|   a->used  = (a->dp[0] != 0u) ? 1 : 0;
  ------------------
  |  Branch (11:15): [True: 2.30k, False: 0]
  ------------------
   12|  2.30k|   MP_ZERO_DIGITS(a->dp + a->used, a->alloc - a->used);
  ------------------
  |  |   89|  2.30k|#  define MP_ZERO_DIGITS(mem, digits)                   \
  |  |   90|  2.30k|do {                                                    \
  |  |   91|  2.30k|   int zd_ = (digits);                                  \
  |  |   92|  2.30k|   mp_digit* zm_ = (mem);                               \
  |  |   93|  76.2k|   while (zd_-- > 0) {                                  \
  |  |  ------------------
  |  |  |  Branch (93:11): [True: 73.9k, False: 2.30k]
  |  |  ------------------
  |  |   94|  73.9k|      *zm_++ = 0;                                       \
  |  |   95|  73.9k|   }                                                    \
  |  |   96|  2.30k|} while (0)
  |  |  ------------------
  |  |  |  Branch (96:10): [Folded, False: 2.30k]
  |  |  ------------------
  ------------------
   13|  2.30k|}

mp_sqr:
    8|  7.76M|{
    9|  7.76M|   mp_err err;
   10|  7.76M|   if (MP_HAS(S_MP_TOOM_SQR) && /* use Toom-Cook? */
  ------------------
  |  |  150|  15.5M|#define MP_HAS(x)        (sizeof(MP_STRINGIZE(BN_##x##_C)) == 1u)
  |  |  ------------------
  |  |  |  |  148|  7.76M|#define MP_STRINGIZE(x)  MP__STRINGIZE(x)
  |  |  |  |  ------------------
  |  |  |  |  |  |  149|  7.76M|#define MP__STRINGIZE(x) ""#x""
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (150:26): [Folded, False: 7.76M]
  |  |  ------------------
  ------------------
   11|      0|       (a->used >= MP_TOOM_SQR_CUTOFF)) {
  ------------------
  |  |  124|      0|#  define MP_TOOM_SQR_CUTOFF      TOOM_SQR_CUTOFF
  ------------------
  |  Branch (11:8): [True: 0, False: 0]
  ------------------
   12|      0|      err = s_mp_toom_sqr(a, b);
   13|  7.76M|   } else if (MP_HAS(S_MP_KARATSUBA_SQR) &&  /* Karatsuba? */
  ------------------
  |  |  150|  15.5M|#define MP_HAS(x)        (sizeof(MP_STRINGIZE(BN_##x##_C)) == 1u)
  |  |  ------------------
  |  |  |  |  148|  7.76M|#define MP_STRINGIZE(x)  MP__STRINGIZE(x)
  |  |  |  |  ------------------
  |  |  |  |  |  |  149|  7.76M|#define MP__STRINGIZE(x) ""#x""
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (150:26): [Folded, False: 7.76M]
  |  |  ------------------
  ------------------
   14|      0|              (a->used >= MP_KARATSUBA_SQR_CUTOFF)) {
  ------------------
  |  |  122|      0|#  define MP_KARATSUBA_SQR_CUTOFF KARATSUBA_SQR_CUTOFF
  ------------------
  |  Branch (14:15): [True: 0, False: 0]
  ------------------
   15|      0|      err = s_mp_karatsuba_sqr(a, b);
   16|  7.76M|   } else if (MP_HAS(S_MP_SQR_FAST) && /* can we use the fast comba multiplier? */
  ------------------
  |  |  150|  15.5M|#define MP_HAS(x)        (sizeof(MP_STRINGIZE(BN_##x##_C)) == 1u)
  |  |  ------------------
  |  |  |  |  148|  7.76M|#define MP_STRINGIZE(x)  MP__STRINGIZE(x)
  |  |  |  |  ------------------
  |  |  |  |  |  |  149|  7.76M|#define MP__STRINGIZE(x) ""#x""
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (150:26): [True: 7.76M, Folded]
  |  |  ------------------
  ------------------
   17|  7.76M|              (((a->used * 2) + 1) < MP_WARRAY) &&
  ------------------
  |  |  172|  7.76M|#define MP_WARRAY PRIVATE_MP_WARRAY
  |  |  ------------------
  |  |  |  |  203|  7.76M|#define PRIVATE_MP_WARRAY (int)(1uLL << (((CHAR_BIT * sizeof(private_mp_word)) - (2 * MP_DIGIT_BIT)) + 1))
  |  |  |  |  ------------------
  |  |  |  |  |  |   82|  7.76M|#   define MP_DIGIT_BIT 60
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (17:15): [True: 7.76M, False: 0]
  ------------------
   18|  7.76M|              (a->used < (MP_MAXFAST / 2))) {
  ------------------
  |  |  168|  7.76M|#define MP_MAXFAST              (int)(1uL << (MP_SIZEOF_BITS(mp_word) - (2u * (size_t)MP_DIGIT_BIT)))
  |  |  ------------------
  |  |  |  |  167|  7.76M|#define MP_SIZEOF_BITS(type)    ((size_t)CHAR_BIT * sizeof(type))
  |  |  ------------------
  |  |               #define MP_MAXFAST              (int)(1uL << (MP_SIZEOF_BITS(mp_word) - (2u * (size_t)MP_DIGIT_BIT)))
  |  |  ------------------
  |  |  |  |   82|  7.76M|#   define MP_DIGIT_BIT 60
  |  |  ------------------
  ------------------
  |  Branch (18:15): [True: 7.76M, False: 0]
  ------------------
   19|  7.76M|      err = s_mp_sqr_fast(a, b);
   20|  7.76M|   } else if (MP_HAS(S_MP_SQR)) {
  ------------------
  |  |  150|      0|#define MP_HAS(x)        (sizeof(MP_STRINGIZE(BN_##x##_C)) == 1u)
  |  |  ------------------
  |  |  |  |  148|      0|#define MP_STRINGIZE(x)  MP__STRINGIZE(x)
  |  |  |  |  ------------------
  |  |  |  |  |  |  149|      0|#define MP__STRINGIZE(x) ""#x""
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (150:26): [True: 0, Folded]
  |  |  ------------------
  ------------------
   21|      0|      err = s_mp_sqr(a, b);
   22|      0|   } else {
   23|      0|      err = MP_VAL;
  ------------------
  |  |  164|      0|#define MP_VAL        -3  /* invalid input */
  ------------------
   24|      0|   }
   25|  7.76M|   b->sign = MP_ZPOS;
  ------------------
  |  |  151|  7.76M|#define MP_ZPOS       0   /* positive integer */
  ------------------
   26|  7.76M|   return err;
   27|  7.76M|}

mp_sub:
    8|  8.26M|{
    9|  8.26M|   mp_sign sa = a->sign, sb = b->sign;
   10|  8.26M|   mp_err err;
   11|       |
   12|  8.26M|   if (sa != sb) {
  ------------------
  |  Branch (12:8): [True: 323k, False: 7.93M]
  ------------------
   13|       |      /* subtract a negative from a positive, OR */
   14|       |      /* subtract a positive from a negative. */
   15|       |      /* In either case, ADD their magnitudes, */
   16|       |      /* and use the sign of the first number. */
   17|   323k|      c->sign = sa;
   18|   323k|      err = s_mp_add(a, b, c);
   19|  7.93M|   } else {
   20|       |      /* subtract a positive from a positive, OR */
   21|       |      /* subtract a negative from a negative. */
   22|       |      /* First, take the difference between their */
   23|       |      /* magnitudes, then... */
   24|  7.93M|      if (mp_cmp_mag(a, b) != MP_LT) {
  ------------------
  |  |  154|  7.93M|#define MP_LT        -1   /* less than */
  ------------------
  |  Branch (24:11): [True: 5.28M, False: 2.65M]
  ------------------
   25|       |         /* Copy the sign from the first */
   26|  5.28M|         c->sign = sa;
   27|       |         /* The first has a larger or equal magnitude */
   28|  5.28M|         err = s_mp_sub(a, b, c);
   29|  5.28M|      } else {
   30|       |         /* The result has the *opposite* sign from */
   31|       |         /* the first number. */
   32|  2.65M|         c->sign = (sa == MP_ZPOS) ? MP_NEG : MP_ZPOS;
  ------------------
  |  |  151|  2.65M|#define MP_ZPOS       0   /* positive integer */
  ------------------
                       c->sign = (sa == MP_ZPOS) ? MP_NEG : MP_ZPOS;
  ------------------
  |  |  152|  2.51M|#define MP_NEG        1   /* negative */
  ------------------
                       c->sign = (sa == MP_ZPOS) ? MP_NEG : MP_ZPOS;
  ------------------
  |  |  151|  2.79M|#define MP_ZPOS       0   /* positive integer */
  ------------------
  |  Branch (32:20): [True: 2.51M, False: 137k]
  ------------------
   33|       |         /* The second has a larger magnitude */
   34|  2.65M|         err = s_mp_sub(b, a, c);
   35|  2.65M|      }
   36|  7.93M|   }
   37|  8.26M|   return err;
   38|  8.26M|}

mp_sub_d:
    8|  2.07k|{
    9|  2.07k|   mp_digit *tmpa, *tmpc;
   10|  2.07k|   mp_err    err;
   11|  2.07k|   int       ix, oldused;
   12|       |
   13|       |   /* grow c as required */
   14|  2.07k|   if (c->alloc < (a->used + 1)) {
  ------------------
  |  Branch (14:8): [True: 2.07k, False: 0]
  ------------------
   15|  2.07k|      if ((err = mp_grow(c, a->used + 1)) != MP_OKAY) {
  ------------------
  |  |  161|  2.07k|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (15:11): [True: 0, False: 2.07k]
  ------------------
   16|      0|         return err;
   17|      0|      }
   18|  2.07k|   }
   19|       |
   20|       |   /* if a is negative just do an unsigned
   21|       |    * addition [with fudged signs]
   22|       |    */
   23|  2.07k|   if (a->sign == MP_NEG) {
  ------------------
  |  |  152|  2.07k|#define MP_NEG        1   /* negative */
  ------------------
  |  Branch (23:8): [True: 0, False: 2.07k]
  ------------------
   24|      0|      mp_int a_ = *a;
   25|      0|      a_.sign = MP_ZPOS;
  ------------------
  |  |  151|      0|#define MP_ZPOS       0   /* positive integer */
  ------------------
   26|      0|      err     = mp_add_d(&a_, b, c);
   27|      0|      c->sign = MP_NEG;
  ------------------
  |  |  152|      0|#define MP_NEG        1   /* negative */
  ------------------
   28|       |
   29|       |      /* clamp */
   30|      0|      mp_clamp(c);
   31|       |
   32|      0|      return err;
   33|      0|   }
   34|       |
   35|       |   /* setup regs */
   36|  2.07k|   oldused = c->used;
   37|  2.07k|   tmpa    = a->dp;
   38|  2.07k|   tmpc    = c->dp;
   39|       |
   40|       |   /* if a <= b simply fix the single digit */
   41|  2.07k|   if (((a->used == 1) && (a->dp[0] <= b)) || (a->used == 0)) {
  ------------------
  |  Branch (41:9): [True: 0, False: 2.07k]
  |  Branch (41:27): [True: 0, False: 0]
  |  Branch (41:47): [True: 0, False: 2.07k]
  ------------------
   42|      0|      if (a->used == 1) {
  ------------------
  |  Branch (42:11): [True: 0, False: 0]
  ------------------
   43|      0|         *tmpc++ = b - *tmpa;
   44|      0|      } else {
   45|      0|         *tmpc++ = b;
   46|      0|      }
   47|      0|      ix      = 1;
   48|       |
   49|       |      /* negative/1digit */
   50|      0|      c->sign = MP_NEG;
  ------------------
  |  |  152|      0|#define MP_NEG        1   /* negative */
  ------------------
   51|      0|      c->used = 1;
   52|  2.07k|   } else {
   53|  2.07k|      mp_digit mu = b;
   54|       |
   55|       |      /* positive/size */
   56|  2.07k|      c->sign = MP_ZPOS;
  ------------------
  |  |  151|  2.07k|#define MP_ZPOS       0   /* positive integer */
  ------------------
   57|  2.07k|      c->used = a->used;
   58|       |
   59|       |      /* subtract digits, mu is carry */
   60|  74.6k|      for (ix = 0; ix < a->used; ix++) {
  ------------------
  |  Branch (60:20): [True: 72.5k, False: 2.07k]
  ------------------
   61|  72.5k|         *tmpc    = *tmpa++ - mu;
   62|  72.5k|         mu       = *tmpc >> (MP_SIZEOF_BITS(mp_digit) - 1u);
  ------------------
  |  |  167|  72.5k|#define MP_SIZEOF_BITS(type)    ((size_t)CHAR_BIT * sizeof(type))
  ------------------
   63|  72.5k|         *tmpc++ &= MP_MASK;
  ------------------
  |  |  106|  72.5k|#define MP_MASK          ((((mp_digit)1)<<((mp_digit)MP_DIGIT_BIT))-((mp_digit)1))
  |  |  ------------------
  |  |  |  |   82|  72.5k|#   define MP_DIGIT_BIT 60
  |  |  ------------------
  ------------------
   64|  72.5k|      }
   65|  2.07k|   }
   66|       |
   67|       |   /* zero excess digits */
   68|  2.07k|   MP_ZERO_DIGITS(tmpc, oldused - ix);
  ------------------
  |  |   89|  2.07k|#  define MP_ZERO_DIGITS(mem, digits)                   \
  |  |   90|  2.07k|do {                                                    \
  |  |   91|  2.07k|   int zd_ = (digits);                                  \
  |  |   92|  2.07k|   mp_digit* zm_ = (mem);                               \
  |  |   93|  2.07k|   while (zd_-- > 0) {                                  \
  |  |  ------------------
  |  |  |  Branch (93:11): [True: 0, False: 2.07k]
  |  |  ------------------
  |  |   94|      0|      *zm_++ = 0;                                       \
  |  |   95|      0|   }                                                    \
  |  |   96|  2.07k|} while (0)
  |  |  ------------------
  |  |  |  Branch (96:10): [Folded, False: 2.07k]
  |  |  ------------------
  ------------------
   69|       |
   70|  2.07k|   mp_clamp(c);
   71|  2.07k|   return MP_OKAY;
  ------------------
  |  |  161|  2.07k|#define MP_OKAY       0   /* no error */
  ------------------
   72|  2.07k|}

mp_to_ubin:
    8|  8.09k|{
    9|  8.09k|   size_t  x, count;
   10|  8.09k|   mp_err  err;
   11|  8.09k|   mp_int  t;
   12|       |
   13|  8.09k|   count = mp_ubin_size(a);
   14|  8.09k|   if (count > maxlen) {
  ------------------
  |  Branch (14:8): [True: 0, False: 8.09k]
  ------------------
   15|      0|      return MP_BUF;
  ------------------
  |  |  167|      0|#define MP_BUF        -5  /* buffer overflow, supplied buffer too small */
  ------------------
   16|      0|   }
   17|       |
   18|  8.09k|   if ((err = mp_init_copy(&t, a)) != MP_OKAY) {
  ------------------
  |  |  161|  8.09k|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (18:8): [True: 0, False: 8.09k]
  ------------------
   19|      0|      return err;
   20|      0|   }
   21|       |
   22|  1.07M|   for (x = count; x --> 0u;) {
  ------------------
  |  Branch (22:20): [True: 1.06M, False: 8.09k]
  ------------------
   23|  1.06M|#ifndef MP_8BIT
   24|  1.06M|      buf[x] = (unsigned char)(t.dp[0] & 255u);
   25|       |#else
   26|       |      buf[x] = (unsigned char)(t.dp[0] | ((t.dp[1] & 1u) << 7));
   27|       |#endif
   28|  1.06M|      if ((err = mp_div_2d(&t, 8, &t, NULL)) != MP_OKAY) {
  ------------------
  |  |  161|  1.06M|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (28:11): [True: 0, False: 1.06M]
  ------------------
   29|      0|         goto LBL_ERR;
   30|      0|      }
   31|  1.06M|   }
   32|       |
   33|  8.09k|   if (written != NULL) {
  ------------------
  |  Branch (33:8): [True: 5.97k, False: 2.12k]
  ------------------
   34|  5.97k|      *written = count;
   35|  5.97k|   }
   36|       |
   37|  8.09k|LBL_ERR:
   38|  8.09k|   mp_clear(&t);
   39|  8.09k|   return err;
   40|  8.09k|}

mp_ubin_size:
    8|  11.4k|{
    9|  11.4k|   size_t size = (size_t)mp_count_bits(a);
   10|  11.4k|   return (size / 8u) + (((size & 7u) != 0u) ? 1u : 0u);
  ------------------
  |  Branch (10:26): [True: 6.89k, False: 4.51k]
  ------------------
   11|  11.4k|}

mp_zero:
    8|  99.8k|{
    9|  99.8k|   a->sign = MP_ZPOS;
  ------------------
  |  |  151|  99.8k|#define MP_ZPOS       0   /* positive integer */
  ------------------
   10|  99.8k|   a->used = 0;
   11|  99.8k|   MP_ZERO_DIGITS(a->dp, a->alloc);
  ------------------
  |  |   89|  99.8k|#  define MP_ZERO_DIGITS(mem, digits)                   \
  |  |   90|  99.8k|do {                                                    \
  |  |   91|  99.8k|   int zd_ = (digits);                                  \
  |  |   92|  99.8k|   mp_digit* zm_ = (mem);                               \
  |  |   93|  2.85M|   while (zd_-- > 0) {                                  \
  |  |  ------------------
  |  |  |  Branch (93:11): [True: 2.75M, False: 99.8k]
  |  |  ------------------
  |  |   94|  2.75M|      *zm_++ = 0;                                       \
  |  |   95|  2.75M|   }                                                    \
  |  |   96|  99.8k|} while (0)
  |  |  ------------------
  |  |  |  Branch (96:10): [Folded, False: 99.8k]
  |  |  ------------------
  ------------------
   12|  99.8k|}

s_mp_add:
    8|  9.67M|{
    9|  9.67M|   const mp_int *x;
   10|  9.67M|   mp_err err;
   11|  9.67M|   int     olduse, min, max;
   12|       |
   13|       |   /* find sizes, we let |a| <= |b| which means we have to sort
   14|       |    * them.  "x" will point to the input with the most digits
   15|       |    */
   16|  9.67M|   if (a->used > b->used) {
  ------------------
  |  Branch (16:8): [True: 13.4k, False: 9.66M]
  ------------------
   17|  13.4k|      min = b->used;
   18|  13.4k|      max = a->used;
   19|  13.4k|      x = a;
   20|  9.66M|   } else {
   21|  9.66M|      min = a->used;
   22|  9.66M|      max = b->used;
   23|  9.66M|      x = b;
   24|  9.66M|   }
   25|       |
   26|       |   /* init result */
   27|  9.67M|   if (c->alloc < (max + 1)) {
  ------------------
  |  Branch (27:8): [True: 24, False: 9.67M]
  ------------------
   28|     24|      if ((err = mp_grow(c, max + 1)) != MP_OKAY) {
  ------------------
  |  |  161|     24|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (28:11): [True: 0, False: 24]
  ------------------
   29|      0|         return err;
   30|      0|      }
   31|     24|   }
   32|       |
   33|       |   /* get old used digit count and set new one */
   34|  9.67M|   olduse = c->used;
   35|  9.67M|   c->used = max + 1;
   36|       |
   37|  9.67M|   {
   38|  9.67M|      mp_digit u, *tmpa, *tmpb, *tmpc;
   39|  9.67M|      int i;
   40|       |
   41|       |      /* alias for digit pointers */
   42|       |
   43|       |      /* first input */
   44|  9.67M|      tmpa = a->dp;
   45|       |
   46|       |      /* second input */
   47|  9.67M|      tmpb = b->dp;
   48|       |
   49|       |      /* destination */
   50|  9.67M|      tmpc = c->dp;
   51|       |
   52|       |      /* zero the carry */
   53|  9.67M|      u = 0;
   54|   139M|      for (i = 0; i < min; i++) {
  ------------------
  |  Branch (54:19): [True: 130M, False: 9.67M]
  ------------------
   55|       |         /* Compute the sum at one digit, T[i] = A[i] + B[i] + U */
   56|   130M|         *tmpc = *tmpa++ + *tmpb++ + u;
   57|       |
   58|       |         /* U = carry bit of T[i] */
   59|   130M|         u = *tmpc >> (mp_digit)MP_DIGIT_BIT;
  ------------------
  |  |   82|   130M|#   define MP_DIGIT_BIT 60
  ------------------
   60|       |
   61|       |         /* take away carry bit from T[i] */
   62|   130M|         *tmpc++ &= MP_MASK;
  ------------------
  |  |  106|   130M|#define MP_MASK          ((((mp_digit)1)<<((mp_digit)MP_DIGIT_BIT))-((mp_digit)1))
  |  |  ------------------
  |  |  |  |   82|   130M|#   define MP_DIGIT_BIT 60
  |  |  ------------------
  ------------------
   63|   130M|      }
   64|       |
   65|       |      /* now copy higher words if any, that is in A+B
   66|       |       * if A or B has more digits add those in
   67|       |       */
   68|  9.67M|      if (min != max) {
  ------------------
  |  Branch (68:11): [True: 4.75M, False: 4.91M]
  ------------------
   69|  45.8M|         for (; i < max; i++) {
  ------------------
  |  Branch (69:17): [True: 41.1M, False: 4.75M]
  ------------------
   70|       |            /* T[i] = X[i] + U */
   71|  41.1M|            *tmpc = x->dp[i] + u;
   72|       |
   73|       |            /* U = carry bit of T[i] */
   74|  41.1M|            u = *tmpc >> (mp_digit)MP_DIGIT_BIT;
  ------------------
  |  |   82|  41.1M|#   define MP_DIGIT_BIT 60
  ------------------
   75|       |
   76|       |            /* take away carry bit from T[i] */
   77|  41.1M|            *tmpc++ &= MP_MASK;
  ------------------
  |  |  106|  41.1M|#define MP_MASK          ((((mp_digit)1)<<((mp_digit)MP_DIGIT_BIT))-((mp_digit)1))
  |  |  ------------------
  |  |  |  |   82|  41.1M|#   define MP_DIGIT_BIT 60
  |  |  ------------------
  ------------------
   78|  41.1M|         }
   79|  4.75M|      }
   80|       |
   81|       |      /* add carry */
   82|  9.67M|      *tmpc++ = u;
   83|       |
   84|       |      /* clear digits above oldused */
   85|  9.67M|      MP_ZERO_DIGITS(tmpc, olduse - c->used);
  ------------------
  |  |   89|  9.67M|#  define MP_ZERO_DIGITS(mem, digits)                   \
  |  |   90|  9.67M|do {                                                    \
  |  |   91|  9.67M|   int zd_ = (digits);                                  \
  |  |   92|  9.67M|   mp_digit* zm_ = (mem);                               \
  |  |   93|  9.67M|   while (zd_-- > 0) {                                  \
  |  |  ------------------
  |  |  |  Branch (93:11): [True: 0, False: 9.67M]
  |  |  ------------------
  |  |   94|      0|      *zm_++ = 0;                                       \
  |  |   95|      0|   }                                                    \
  |  |   96|  9.67M|} while (0)
  |  |  ------------------
  |  |  |  Branch (96:10): [Folded, False: 9.67M]
  |  |  ------------------
  ------------------
   86|  9.67M|   }
   87|       |
   88|  9.67M|   mp_clamp(c);
   89|  9.67M|   return MP_OKAY;
  ------------------
  |  |  161|  9.67M|#define MP_OKAY       0   /* no error */
  ------------------
   90|  9.67M|}

s_mp_exptmod:
   15|    441|{
   16|    441|   mp_int  M[TAB_SIZE], res, mu;
   17|    441|   mp_digit buf;
   18|    441|   mp_err   err;
   19|    441|   int      bitbuf, bitcpy, bitcnt, mode, digidx, x, y, winsize;
   20|    441|   mp_err(*redux)(mp_int *x, const mp_int *m, const mp_int *mu);
   21|       |
   22|       |   /* find window size */
   23|    441|   x = mp_count_bits(X);
   24|    441|   if (x <= 7) {
  ------------------
  |  Branch (24:8): [True: 131, False: 310]
  ------------------
   25|    131|      winsize = 2;
   26|    310|   } else if (x <= 36) {
  ------------------
  |  Branch (26:15): [True: 35, False: 275]
  ------------------
   27|     35|      winsize = 3;
   28|    275|   } else if (x <= 140) {
  ------------------
  |  Branch (28:15): [True: 172, False: 103]
  ------------------
   29|    172|      winsize = 4;
   30|    172|   } else if (x <= 450) {
  ------------------
  |  Branch (30:15): [True: 103, False: 0]
  ------------------
   31|    103|      winsize = 5;
   32|    103|   } else if (x <= 1303) {
  ------------------
  |  Branch (32:15): [True: 0, False: 0]
  ------------------
   33|      0|      winsize = 6;
   34|      0|   } else if (x <= 3529) {
  ------------------
  |  Branch (34:15): [True: 0, False: 0]
  ------------------
   35|      0|      winsize = 7;
   36|      0|   } else {
   37|      0|      winsize = 8;
   38|      0|   }
   39|       |
   40|    441|   winsize = MAX_WINSIZE ? MP_MIN(MAX_WINSIZE, winsize) : winsize;
  ------------------
  |  |   11|    441|#   define MAX_WINSIZE 0
  |  |  ------------------
  |  |  |  Branch (11:24): [Folded, False: 441]
  |  |  ------------------
  ------------------
                 winsize = MAX_WINSIZE ? MP_MIN(MAX_WINSIZE, winsize) : winsize;
  ------------------
  |  |  156|      0|#define MP_MIN(x, y) (((x) < (y)) ? (x) : (y))
  |  |  ------------------
  |  |  |  Branch (156:23): [True: 0, False: 0]
  |  |  ------------------
  ------------------
   41|       |
   42|       |   /* init M array */
   43|       |   /* init first cell */
   44|    441|   if ((err = mp_init(&M[1])) != MP_OKAY) {
  ------------------
  |  |  161|    441|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (44:8): [True: 0, False: 441]
  ------------------
   45|      0|      return err;
   46|      0|   }
   47|       |
   48|       |   /* now init the second half of the array */
   49|  3.86k|   for (x = 1<<(winsize-1); x < (1 << winsize); x++) {
  ------------------
  |  Branch (49:29): [True: 3.42k, False: 441]
  ------------------
   50|  3.42k|      if ((err = mp_init(&M[x])) != MP_OKAY) {
  ------------------
  |  |  161|  3.42k|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (50:11): [True: 0, False: 3.42k]
  ------------------
   51|      0|         for (y = 1<<(winsize-1); y < x; y++) {
  ------------------
  |  Branch (51:35): [True: 0, False: 0]
  ------------------
   52|      0|            mp_clear(&M[y]);
   53|      0|         }
   54|      0|         mp_clear(&M[1]);
   55|      0|         return err;
   56|      0|      }
   57|  3.42k|   }
   58|       |
   59|       |   /* create mu, used for Barrett reduction */
   60|    441|   if ((err = mp_init(&mu)) != MP_OKAY)                           goto LBL_M;
  ------------------
  |  |  161|    441|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (60:8): [True: 0, False: 441]
  ------------------
   61|       |
   62|    441|   if (redmode == 0) {
  ------------------
  |  Branch (62:8): [True: 313, False: 128]
  ------------------
   63|    313|      if ((err = mp_reduce_setup(&mu, P)) != MP_OKAY)             goto LBL_MU;
  ------------------
  |  |  161|    313|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (63:11): [True: 0, False: 313]
  ------------------
   64|    313|      redux = mp_reduce;
   65|    313|   } else {
   66|    128|      if ((err = mp_reduce_2k_setup_l(P, &mu)) != MP_OKAY)        goto LBL_MU;
  ------------------
  |  |  161|    128|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (66:11): [True: 0, False: 128]
  ------------------
   67|    128|      redux = mp_reduce_2k_l;
   68|    128|   }
   69|       |
   70|       |   /* create M table
   71|       |    *
   72|       |    * The M table contains powers of the base,
   73|       |    * e.g. M[x] = G**x mod P
   74|       |    *
   75|       |    * The first half of the table is not
   76|       |    * computed though accept for M[0] and M[1]
   77|       |    */
   78|    441|   if ((err = mp_mod(G, P, &M[1])) != MP_OKAY)                    goto LBL_MU;
  ------------------
  |  |  161|    441|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (78:8): [True: 0, False: 441]
  ------------------
   79|       |
   80|       |   /* compute the value at M[1<<(winsize-1)] by squaring
   81|       |    * M[1] (winsize-1) times
   82|       |    */
   83|    441|   if ((err = mp_copy(&M[1], &M[(size_t)1 << (winsize - 1)])) != MP_OKAY) goto LBL_MU;
  ------------------
  |  |  161|    441|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (83:8): [True: 0, False: 441]
  ------------------
   84|       |
   85|  1.57k|   for (x = 0; x < (winsize - 1); x++) {
  ------------------
  |  Branch (85:16): [True: 1.12k, False: 441]
  ------------------
   86|       |      /* square it */
   87|  1.12k|      if ((err = mp_sqr(&M[(size_t)1 << (winsize - 1)],
  ------------------
  |  Branch (87:11): [True: 0, False: 1.12k]
  ------------------
   88|  1.12k|                        &M[(size_t)1 << (winsize - 1)])) != MP_OKAY) goto LBL_MU;
  ------------------
  |  |  161|  1.12k|#define MP_OKAY       0   /* no error */
  ------------------
   89|       |
   90|       |      /* reduce modulo P */
   91|  1.12k|      if ((err = redux(&M[(size_t)1 << (winsize - 1)], P, &mu)) != MP_OKAY) goto LBL_MU;
  ------------------
  |  |  161|  1.12k|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (91:11): [True: 0, False: 1.12k]
  ------------------
   92|  1.12k|   }
   93|       |
   94|       |   /* create upper table, that is M[x] = M[x-1] * M[1] (mod P)
   95|       |    * for x = (2**(winsize - 1) + 1) to (2**winsize - 1)
   96|       |    */
   97|  3.42k|   for (x = (1 << (winsize - 1)) + 1; x < (1 << winsize); x++) {
  ------------------
  |  Branch (97:39): [True: 2.98k, False: 441]
  ------------------
   98|  2.98k|      if ((err = mp_mul(&M[x - 1], &M[1], &M[x])) != MP_OKAY)     goto LBL_MU;
  ------------------
  |  |  161|  2.98k|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (98:11): [True: 0, False: 2.98k]
  ------------------
   99|  2.98k|      if ((err = redux(&M[x], P, &mu)) != MP_OKAY)                goto LBL_MU;
  ------------------
  |  |  161|  2.98k|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (99:11): [True: 0, False: 2.98k]
  ------------------
  100|  2.98k|   }
  101|       |
  102|       |   /* setup result */
  103|    441|   if ((err = mp_init(&res)) != MP_OKAY)                          goto LBL_MU;
  ------------------
  |  |  161|    441|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (103:8): [True: 0, False: 441]
  ------------------
  104|    441|   mp_set(&res, 1uL);
  105|       |
  106|       |   /* set initial mode and bit cnt */
  107|    441|   mode   = 0;
  108|    441|   bitcnt = 1;
  109|    441|   buf    = 0;
  110|    441|   digidx = X->used - 1;
  111|    441|   bitcpy = 0;
  112|    441|   bitbuf = 0;
  113|       |
  114|  34.2k|   for (;;) {
  115|       |      /* grab next digit as required */
  116|  34.2k|      if (--bitcnt == 0) {
  ------------------
  |  Branch (116:11): [True: 1.00k, False: 33.2k]
  ------------------
  117|       |         /* if digidx == -1 we are out of digits */
  118|  1.00k|         if (digidx == -1) {
  ------------------
  |  Branch (118:14): [True: 441, False: 564]
  ------------------
  119|    441|            break;
  120|    441|         }
  121|       |         /* read next digit and reset the bitcnt */
  122|    564|         buf    = X->dp[digidx--];
  123|    564|         bitcnt = (int)MP_DIGIT_BIT;
  ------------------
  |  |   82|    564|#   define MP_DIGIT_BIT 60
  ------------------
  124|    564|      }
  125|       |
  126|       |      /* grab the next msb from the exponent */
  127|  33.8k|      y     = (buf >> (mp_digit)(MP_DIGIT_BIT - 1)) & 1uL;
  ------------------
  |  |   82|  33.8k|#   define MP_DIGIT_BIT 60
  ------------------
  128|  33.8k|      buf <<= (mp_digit)1;
  129|       |
  130|       |      /* if the bit is zero and mode == 0 then we ignore it
  131|       |       * These represent the leading zero bits before the first 1 bit
  132|       |       * in the exponent.  Technically this opt is not required but it
  133|       |       * does lower the # of trivial squaring/reductions used
  134|       |       */
  135|  33.8k|      if ((mode == 0) && (y == 0)) {
  ------------------
  |  Branch (135:11): [True: 6.83k, False: 27.0k]
  |  Branch (135:26): [True: 6.50k, False: 322]
  ------------------
  136|  6.50k|         continue;
  137|  6.50k|      }
  138|       |
  139|       |      /* if the bit is zero and mode == 1 then we square */
  140|  27.3k|      if ((mode == 1) && (y == 0)) {
  ------------------
  |  Branch (140:11): [True: 12.0k, False: 15.2k]
  |  Branch (140:26): [True: 8.13k, False: 3.92k]
  ------------------
  141|  8.13k|         if ((err = mp_sqr(&res, &res)) != MP_OKAY)               goto LBL_RES;
  ------------------
  |  |  161|  8.13k|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (141:14): [True: 0, False: 8.13k]
  ------------------
  142|  8.13k|         if ((err = redux(&res, P, &mu)) != MP_OKAY)              goto LBL_RES;
  ------------------
  |  |  161|  8.13k|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (142:14): [True: 0, False: 8.13k]
  ------------------
  143|  8.13k|         continue;
  144|  8.13k|      }
  145|       |
  146|       |      /* else we add it to the window */
  147|  19.1k|      bitbuf |= (y << (winsize - ++bitcpy));
  148|  19.1k|      mode    = 2;
  149|       |
  150|  19.1k|      if (bitcpy == winsize) {
  ------------------
  |  Branch (150:11): [True: 4.10k, False: 15.0k]
  ------------------
  151|       |         /* ok window is filled so square as required and multiply  */
  152|       |         /* square first */
  153|  22.9k|         for (x = 0; x < winsize; x++) {
  ------------------
  |  Branch (153:22): [True: 18.8k, False: 4.10k]
  ------------------
  154|  18.8k|            if ((err = mp_sqr(&res, &res)) != MP_OKAY)            goto LBL_RES;
  ------------------
  |  |  161|  18.8k|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (154:17): [True: 0, False: 18.8k]
  ------------------
  155|  18.8k|            if ((err = redux(&res, P, &mu)) != MP_OKAY)           goto LBL_RES;
  ------------------
  |  |  161|  18.8k|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (155:17): [True: 0, False: 18.8k]
  ------------------
  156|  18.8k|         }
  157|       |
  158|       |         /* then multiply */
  159|  4.10k|         if ((err = mp_mul(&res, &M[bitbuf], &res)) != MP_OKAY)  goto LBL_RES;
  ------------------
  |  |  161|  4.10k|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (159:14): [True: 0, False: 4.10k]
  ------------------
  160|  4.10k|         if ((err = redux(&res, P, &mu)) != MP_OKAY)             goto LBL_RES;
  ------------------
  |  |  161|  4.10k|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (160:14): [True: 0, False: 4.10k]
  ------------------
  161|       |
  162|       |         /* empty window and reset */
  163|  4.10k|         bitcpy = 0;
  164|  4.10k|         bitbuf = 0;
  165|  4.10k|         mode   = 1;
  166|  4.10k|      }
  167|  19.1k|   }
  168|       |
  169|       |   /* if bits remain then square/multiply */
  170|    441|   if ((mode == 2) && (bitcpy > 0)) {
  ------------------
  |  Branch (170:8): [True: 146, False: 295]
  |  Branch (170:23): [True: 146, False: 0]
  ------------------
  171|       |      /* square then multiply if the bit is set */
  172|    492|      for (x = 0; x < bitcpy; x++) {
  ------------------
  |  Branch (172:19): [True: 346, False: 146]
  ------------------
  173|    346|         if ((err = mp_sqr(&res, &res)) != MP_OKAY)               goto LBL_RES;
  ------------------
  |  |  161|    346|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (173:14): [True: 0, False: 346]
  ------------------
  174|    346|         if ((err = redux(&res, P, &mu)) != MP_OKAY)              goto LBL_RES;
  ------------------
  |  |  161|    346|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (174:14): [True: 0, False: 346]
  ------------------
  175|       |
  176|    346|         bitbuf <<= 1;
  177|    346|         if ((bitbuf & (1 << winsize)) != 0) {
  ------------------
  |  Branch (177:14): [True: 248, False: 98]
  ------------------
  178|       |            /* then multiply */
  179|    248|            if ((err = mp_mul(&res, &M[1], &res)) != MP_OKAY)     goto LBL_RES;
  ------------------
  |  |  161|    248|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (179:17): [True: 0, False: 248]
  ------------------
  180|    248|            if ((err = redux(&res, P, &mu)) != MP_OKAY)           goto LBL_RES;
  ------------------
  |  |  161|    248|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (180:17): [True: 0, False: 248]
  ------------------
  181|    248|         }
  182|    346|      }
  183|    146|   }
  184|       |
  185|    441|   mp_exch(&res, Y);
  186|    441|   err = MP_OKAY;
  ------------------
  |  |  161|    441|#define MP_OKAY       0   /* no error */
  ------------------
  187|    441|LBL_RES:
  188|    441|   mp_clear(&res);
  189|    441|LBL_MU:
  190|    441|   mp_clear(&mu);
  191|    441|LBL_M:
  192|    441|   mp_clear(&M[1]);
  193|  3.86k|   for (x = 1<<(winsize-1); x < (1 << winsize); x++) {
  ------------------
  |  Branch (193:29): [True: 3.42k, False: 441]
  ------------------
  194|  3.42k|      mp_clear(&M[x]);
  195|  3.42k|   }
  196|    441|   return err;
  197|    441|}

s_mp_exptmod_fast:
   23|  2.36k|{
   24|  2.36k|   mp_int  M[TAB_SIZE], res;
   25|  2.36k|   mp_digit buf, mp;
   26|  2.36k|   int     bitbuf, bitcpy, bitcnt, mode, digidx, x, y, winsize;
   27|  2.36k|   mp_err   err;
   28|       |
   29|       |   /* use a pointer to the reduction algorithm.  This allows us to use
   30|       |    * one of many reduction algorithms without modding the guts of
   31|       |    * the code with if statements everywhere.
   32|       |    */
   33|  2.36k|   mp_err(*redux)(mp_int *x, const mp_int *n, mp_digit rho);
   34|       |
   35|       |   /* find window size */
   36|  2.36k|   x = mp_count_bits(X);
   37|  2.36k|   if (x <= 7) {
  ------------------
  |  Branch (37:8): [True: 174, False: 2.19k]
  ------------------
   38|    174|      winsize = 2;
   39|  2.19k|   } else if (x <= 36) {
  ------------------
  |  Branch (39:15): [True: 14, False: 2.18k]
  ------------------
   40|     14|      winsize = 3;
   41|  2.18k|   } else if (x <= 140) {
  ------------------
  |  Branch (41:15): [True: 58, False: 2.12k]
  ------------------
   42|     58|      winsize = 4;
   43|  2.12k|   } else if (x <= 450) {
  ------------------
  |  Branch (43:15): [True: 53, False: 2.06k]
  ------------------
   44|     53|      winsize = 5;
   45|  2.06k|   } else if (x <= 1303) {
  ------------------
  |  Branch (45:15): [True: 0, False: 2.06k]
  ------------------
   46|      0|      winsize = 6;
   47|  2.06k|   } else if (x <= 3529) {
  ------------------
  |  Branch (47:15): [True: 2.06k, False: 0]
  ------------------
   48|  2.06k|      winsize = 7;
   49|  2.06k|   } else {
   50|      0|      winsize = 8;
   51|      0|   }
   52|       |
   53|  2.36k|   winsize = MAX_WINSIZE ? MP_MIN(MAX_WINSIZE, winsize) : winsize;
  ------------------
  |  |   19|  2.36k|#   define MAX_WINSIZE 0
  |  |  ------------------
  |  |  |  Branch (19:24): [Folded, False: 2.36k]
  |  |  ------------------
  ------------------
                 winsize = MAX_WINSIZE ? MP_MIN(MAX_WINSIZE, winsize) : winsize;
  ------------------
  |  |  156|      0|#define MP_MIN(x, y) (((x) < (y)) ? (x) : (y))
  |  |  ------------------
  |  |  |  Branch (156:23): [True: 0, False: 0]
  |  |  ------------------
  ------------------
   54|       |
   55|       |   /* init M array */
   56|       |   /* init first cell */
   57|  2.36k|   if ((err = mp_init_size(&M[1], P->alloc)) != MP_OKAY) {
  ------------------
  |  |  161|  2.36k|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (57:8): [True: 0, False: 2.36k]
  ------------------
   58|      0|      return err;
   59|      0|   }
   60|       |
   61|       |   /* now init the second half of the array */
   62|   136k|   for (x = 1<<(winsize-1); x < (1 << winsize); x++) {
  ------------------
  |  Branch (62:29): [True: 134k, False: 2.36k]
  ------------------
   63|   134k|      if ((err = mp_init_size(&M[x], P->alloc)) != MP_OKAY) {
  ------------------
  |  |  161|   134k|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (63:11): [True: 0, False: 134k]
  ------------------
   64|      0|         for (y = 1<<(winsize-1); y < x; y++) {
  ------------------
  |  Branch (64:35): [True: 0, False: 0]
  ------------------
   65|      0|            mp_clear(&M[y]);
   66|      0|         }
   67|      0|         mp_clear(&M[1]);
   68|      0|         return err;
   69|      0|      }
   70|   134k|   }
   71|       |
   72|       |   /* determine and setup reduction code */
   73|  2.36k|   if (redmode == 0) {
  ------------------
  |  Branch (73:8): [True: 2.36k, False: 0]
  ------------------
   74|  2.36k|      if (MP_HAS(MP_MONTGOMERY_SETUP)) {
  ------------------
  |  |  150|  2.36k|#define MP_HAS(x)        (sizeof(MP_STRINGIZE(BN_##x##_C)) == 1u)
  |  |  ------------------
  |  |  |  |  148|  2.36k|#define MP_STRINGIZE(x)  MP__STRINGIZE(x)
  |  |  |  |  ------------------
  |  |  |  |  |  |  149|  2.36k|#define MP__STRINGIZE(x) ""#x""
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (150:26): [True: 2.36k, Folded]
  |  |  ------------------
  ------------------
   75|       |         /* now setup montgomery  */
   76|  2.36k|         if ((err = mp_montgomery_setup(P, &mp)) != MP_OKAY)      goto LBL_M;
  ------------------
  |  |  161|  2.36k|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (76:14): [True: 0, False: 2.36k]
  ------------------
   77|  2.36k|      } else {
   78|      0|         err = MP_VAL;
  ------------------
  |  |  164|      0|#define MP_VAL        -3  /* invalid input */
  ------------------
   79|      0|         goto LBL_M;
   80|      0|      }
   81|       |
   82|       |      /* automatically pick the comba one if available (saves quite a few calls/ifs) */
   83|  2.36k|      if (MP_HAS(S_MP_MONTGOMERY_REDUCE_FAST) &&
  ------------------
  |  |  150|  4.73k|#define MP_HAS(x)        (sizeof(MP_STRINGIZE(BN_##x##_C)) == 1u)
  |  |  ------------------
  |  |  |  |  148|  2.36k|#define MP_STRINGIZE(x)  MP__STRINGIZE(x)
  |  |  |  |  ------------------
  |  |  |  |  |  |  149|  2.36k|#define MP__STRINGIZE(x) ""#x""
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (150:26): [True: 2.36k, Folded]
  |  |  ------------------
  ------------------
   84|  2.36k|          (((P->used * 2) + 1) < MP_WARRAY) &&
  ------------------
  |  |  172|  2.36k|#define MP_WARRAY PRIVATE_MP_WARRAY
  |  |  ------------------
  |  |  |  |  203|  2.36k|#define PRIVATE_MP_WARRAY (int)(1uLL << (((CHAR_BIT * sizeof(private_mp_word)) - (2 * MP_DIGIT_BIT)) + 1))
  |  |  |  |  ------------------
  |  |  |  |  |  |   82|  2.36k|#   define MP_DIGIT_BIT 60
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (84:11): [True: 2.36k, False: 0]
  ------------------
   85|  2.36k|          (P->used < MP_MAXFAST)) {
  ------------------
  |  |  168|  2.36k|#define MP_MAXFAST              (int)(1uL << (MP_SIZEOF_BITS(mp_word) - (2u * (size_t)MP_DIGIT_BIT)))
  |  |  ------------------
  |  |  |  |  167|  2.36k|#define MP_SIZEOF_BITS(type)    ((size_t)CHAR_BIT * sizeof(type))
  |  |  ------------------
  |  |               #define MP_MAXFAST              (int)(1uL << (MP_SIZEOF_BITS(mp_word) - (2u * (size_t)MP_DIGIT_BIT)))
  |  |  ------------------
  |  |  |  |   82|  2.36k|#   define MP_DIGIT_BIT 60
  |  |  ------------------
  ------------------
  |  Branch (85:11): [True: 2.36k, False: 0]
  ------------------
   86|  2.36k|         redux = s_mp_montgomery_reduce_fast;
   87|  2.36k|      } else if (MP_HAS(MP_MONTGOMERY_REDUCE)) {
  ------------------
  |  |  150|      0|#define MP_HAS(x)        (sizeof(MP_STRINGIZE(BN_##x##_C)) == 1u)
  |  |  ------------------
  |  |  |  |  148|      0|#define MP_STRINGIZE(x)  MP__STRINGIZE(x)
  |  |  |  |  ------------------
  |  |  |  |  |  |  149|      0|#define MP__STRINGIZE(x) ""#x""
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (150:26): [True: 0, Folded]
  |  |  ------------------
  ------------------
   88|       |         /* use slower baseline Montgomery method */
   89|      0|         redux = mp_montgomery_reduce;
   90|      0|      } else {
   91|      0|         err = MP_VAL;
  ------------------
  |  |  164|      0|#define MP_VAL        -3  /* invalid input */
  ------------------
   92|      0|         goto LBL_M;
   93|      0|      }
   94|  2.36k|   } else if (redmode == 1) {
  ------------------
  |  Branch (94:15): [True: 0, False: 0]
  ------------------
   95|      0|      if (MP_HAS(MP_DR_SETUP) && MP_HAS(MP_DR_REDUCE)) {
  ------------------
  |  |  150|      0|#define MP_HAS(x)        (sizeof(MP_STRINGIZE(BN_##x##_C)) == 1u)
  |  |  ------------------
  |  |  |  |  148|      0|#define MP_STRINGIZE(x)  MP__STRINGIZE(x)
  |  |  |  |  ------------------
  |  |  |  |  |  |  149|      0|#define MP__STRINGIZE(x) ""#x""
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (150:26): [True: 0, Folded]
  |  |  ------------------
  ------------------
                    if (MP_HAS(MP_DR_SETUP) && MP_HAS(MP_DR_REDUCE)) {
  ------------------
  |  |  150|      0|#define MP_HAS(x)        (sizeof(MP_STRINGIZE(BN_##x##_C)) == 1u)
  |  |  ------------------
  |  |  |  |  148|      0|#define MP_STRINGIZE(x)  MP__STRINGIZE(x)
  |  |  |  |  ------------------
  |  |  |  |  |  |  149|      0|#define MP__STRINGIZE(x) ""#x""
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (150:26): [True: 0, Folded]
  |  |  ------------------
  ------------------
   96|       |         /* setup DR reduction for moduli of the form B**k - b */
   97|      0|         mp_dr_setup(P, &mp);
   98|      0|         redux = mp_dr_reduce;
   99|      0|      } else {
  100|      0|         err = MP_VAL;
  ------------------
  |  |  164|      0|#define MP_VAL        -3  /* invalid input */
  ------------------
  101|      0|         goto LBL_M;
  102|      0|      }
  103|      0|   } else if (MP_HAS(MP_REDUCE_2K_SETUP) && MP_HAS(MP_REDUCE_2K)) {
  ------------------
  |  |  150|      0|#define MP_HAS(x)        (sizeof(MP_STRINGIZE(BN_##x##_C)) == 1u)
  |  |  ------------------
  |  |  |  |  148|      0|#define MP_STRINGIZE(x)  MP__STRINGIZE(x)
  |  |  |  |  ------------------
  |  |  |  |  |  |  149|      0|#define MP__STRINGIZE(x) ""#x""
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (150:26): [True: 0, Folded]
  |  |  ------------------
  ------------------
                 } else if (MP_HAS(MP_REDUCE_2K_SETUP) && MP_HAS(MP_REDUCE_2K)) {
  ------------------
  |  |  150|      0|#define MP_HAS(x)        (sizeof(MP_STRINGIZE(BN_##x##_C)) == 1u)
  |  |  ------------------
  |  |  |  |  148|      0|#define MP_STRINGIZE(x)  MP__STRINGIZE(x)
  |  |  |  |  ------------------
  |  |  |  |  |  |  149|      0|#define MP__STRINGIZE(x) ""#x""
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (150:26): [True: 0, Folded]
  |  |  ------------------
  ------------------
  104|       |      /* setup DR reduction for moduli of the form 2**k - b */
  105|      0|      if ((err = mp_reduce_2k_setup(P, &mp)) != MP_OKAY)          goto LBL_M;
  ------------------
  |  |  161|      0|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (105:11): [True: 0, False: 0]
  ------------------
  106|      0|      redux = mp_reduce_2k;
  107|      0|   } else {
  108|      0|      err = MP_VAL;
  ------------------
  |  |  164|      0|#define MP_VAL        -3  /* invalid input */
  ------------------
  109|      0|      goto LBL_M;
  110|      0|   }
  111|       |
  112|       |   /* setup result */
  113|  2.36k|   if ((err = mp_init_size(&res, P->alloc)) != MP_OKAY)           goto LBL_M;
  ------------------
  |  |  161|  2.36k|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (113:8): [True: 0, False: 2.36k]
  ------------------
  114|       |
  115|       |   /* create M table
  116|       |    *
  117|       |
  118|       |    *
  119|       |    * The first half of the table is not computed though accept for M[0] and M[1]
  120|       |    */
  121|       |
  122|  2.36k|   if (redmode == 0) {
  ------------------
  |  Branch (122:8): [True: 2.36k, False: 0]
  ------------------
  123|  2.36k|      if (MP_HAS(MP_MONTGOMERY_CALC_NORMALIZATION)) {
  ------------------
  |  |  150|  2.36k|#define MP_HAS(x)        (sizeof(MP_STRINGIZE(BN_##x##_C)) == 1u)
  |  |  ------------------
  |  |  |  |  148|  2.36k|#define MP_STRINGIZE(x)  MP__STRINGIZE(x)
  |  |  |  |  ------------------
  |  |  |  |  |  |  149|  2.36k|#define MP__STRINGIZE(x) ""#x""
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (150:26): [True: 2.36k, Folded]
  |  |  ------------------
  ------------------
  124|       |         /* now we need R mod m */
  125|  2.36k|         if ((err = mp_montgomery_calc_normalization(&res, P)) != MP_OKAY) goto LBL_RES;
  ------------------
  |  |  161|  2.36k|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (125:14): [True: 0, False: 2.36k]
  ------------------
  126|       |
  127|       |         /* now set M[1] to G * R mod m */
  128|  2.36k|         if ((err = mp_mulmod(G, &res, P, &M[1])) != MP_OKAY)     goto LBL_RES;
  ------------------
  |  |  161|  2.36k|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (128:14): [True: 0, False: 2.36k]
  ------------------
  129|  2.36k|      } else {
  130|      0|         err = MP_VAL;
  ------------------
  |  |  164|      0|#define MP_VAL        -3  /* invalid input */
  ------------------
  131|      0|         goto LBL_RES;
  132|      0|      }
  133|  2.36k|   } else {
  134|      0|      mp_set(&res, 1uL);
  135|      0|      if ((err = mp_mod(G, P, &M[1])) != MP_OKAY)                 goto LBL_RES;
  ------------------
  |  |  161|      0|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (135:11): [True: 0, False: 0]
  ------------------
  136|      0|   }
  137|       |
  138|       |   /* compute the value at M[1<<(winsize-1)] by squaring M[1] (winsize-1) times */
  139|  2.36k|   if ((err = mp_copy(&M[1], &M[(size_t)1 << (winsize - 1)])) != MP_OKAY) goto LBL_RES;
  ------------------
  |  |  161|  2.36k|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (139:8): [True: 0, False: 2.36k]
  ------------------
  140|       |
  141|  15.3k|   for (x = 0; x < (winsize - 1); x++) {
  ------------------
  |  Branch (141:16): [True: 13.0k, False: 2.36k]
  ------------------
  142|  13.0k|      if ((err = mp_sqr(&M[(size_t)1 << (winsize - 1)], &M[(size_t)1 << (winsize - 1)])) != MP_OKAY) goto LBL_RES;
  ------------------
  |  |  161|  13.0k|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (142:11): [True: 0, False: 13.0k]
  ------------------
  143|  13.0k|      if ((err = redux(&M[(size_t)1 << (winsize - 1)], P, mp)) != MP_OKAY) goto LBL_RES;
  ------------------
  |  |  161|  13.0k|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (143:11): [True: 0, False: 13.0k]
  ------------------
  144|  13.0k|   }
  145|       |
  146|       |   /* create upper table */
  147|   134k|   for (x = (1 << (winsize - 1)) + 1; x < (1 << winsize); x++) {
  ------------------
  |  Branch (147:39): [True: 131k, False: 2.36k]
  ------------------
  148|   131k|      if ((err = mp_mul(&M[x - 1], &M[1], &M[x])) != MP_OKAY)     goto LBL_RES;
  ------------------
  |  |  161|   131k|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (148:11): [True: 0, False: 131k]
  ------------------
  149|   131k|      if ((err = redux(&M[x], P, mp)) != MP_OKAY)                 goto LBL_RES;
  ------------------
  |  |  161|   131k|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (149:11): [True: 0, False: 131k]
  ------------------
  150|   131k|   }
  151|       |
  152|       |   /* set initial mode and bit cnt */
  153|  2.36k|   mode   = 0;
  154|  2.36k|   bitcnt = 1;
  155|  2.36k|   buf    = 0;
  156|  2.36k|   digidx = X->used - 1;
  157|  2.36k|   bitcpy = 0;
  158|  2.36k|   bitbuf = 0;
  159|       |
  160|  4.36M|   for (;;) {
  161|       |      /* grab next digit as required */
  162|  4.36M|      if (--bitcnt == 0) {
  ------------------
  |  Branch (162:11): [True: 75.0k, False: 4.28M]
  ------------------
  163|       |         /* if digidx == -1 we are out of digits so break */
  164|  75.0k|         if (digidx == -1) {
  ------------------
  |  Branch (164:14): [True: 2.36k, False: 72.6k]
  ------------------
  165|  2.36k|            break;
  166|  2.36k|         }
  167|       |         /* read next digit and reset bitcnt */
  168|  72.6k|         buf    = X->dp[digidx--];
  169|  72.6k|         bitcnt = (int)MP_DIGIT_BIT;
  ------------------
  |  |   82|  72.6k|#   define MP_DIGIT_BIT 60
  ------------------
  170|  72.6k|      }
  171|       |
  172|       |      /* grab the next msb from the exponent */
  173|  4.35M|      y     = (mp_digit)(buf >> (MP_DIGIT_BIT - 1)) & 1uL;
  ------------------
  |  |   82|  4.35M|#   define MP_DIGIT_BIT 60
  ------------------
  174|  4.35M|      buf <<= (mp_digit)1;
  175|       |
  176|       |      /* if the bit is zero and mode == 0 then we ignore it
  177|       |       * These represent the leading zero bits before the first 1 bit
  178|       |       * in the exponent.  Technically this opt is not required but it
  179|       |       * does lower the # of trivial squaring/reductions used
  180|       |       */
  181|  4.35M|      if ((mode == 0) && (y == 0)) {
  ------------------
  |  Branch (181:11): [True: 115k, False: 4.24M]
  |  Branch (181:26): [True: 113k, False: 2.20k]
  ------------------
  182|   113k|         continue;
  183|   113k|      }
  184|       |
  185|       |      /* if the bit is zero and mode == 1 then we square */
  186|  4.24M|      if ((mode == 1) && (y == 0)) {
  ------------------
  |  Branch (186:11): [True: 1.06M, False: 3.18M]
  |  Branch (186:26): [True: 534k, False: 529k]
  ------------------
  187|   534k|         if ((err = mp_sqr(&res, &res)) != MP_OKAY)               goto LBL_RES;
  ------------------
  |  |  161|   534k|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (187:14): [True: 0, False: 534k]
  ------------------
  188|   534k|         if ((err = redux(&res, P, mp)) != MP_OKAY)               goto LBL_RES;
  ------------------
  |  |  161|   534k|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (188:14): [True: 0, False: 534k]
  ------------------
  189|   534k|         continue;
  190|   534k|      }
  191|       |
  192|       |      /* else we add it to the window */
  193|  3.71M|      bitbuf |= (y << (winsize - ++bitcpy));
  194|  3.71M|      mode    = 2;
  195|       |
  196|  3.71M|      if (bitcpy == winsize) {
  ------------------
  |  Branch (196:11): [True: 529k, False: 3.18M]
  ------------------
  197|       |         /* ok window is filled so square as required and multiply  */
  198|       |         /* square first */
  199|  4.23M|         for (x = 0; x < winsize; x++) {
  ------------------
  |  Branch (199:22): [True: 3.70M, False: 529k]
  ------------------
  200|  3.70M|            if ((err = mp_sqr(&res, &res)) != MP_OKAY)            goto LBL_RES;
  ------------------
  |  |  161|  3.70M|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (200:17): [True: 0, False: 3.70M]
  ------------------
  201|  3.70M|            if ((err = redux(&res, P, mp)) != MP_OKAY)            goto LBL_RES;
  ------------------
  |  |  161|  3.70M|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (201:17): [True: 0, False: 3.70M]
  ------------------
  202|  3.70M|         }
  203|       |
  204|       |         /* then multiply */
  205|   529k|         if ((err = mp_mul(&res, &M[bitbuf], &res)) != MP_OKAY)   goto LBL_RES;
  ------------------
  |  |  161|   529k|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (205:14): [True: 0, False: 529k]
  ------------------
  206|   529k|         if ((err = redux(&res, P, mp)) != MP_OKAY)               goto LBL_RES;
  ------------------
  |  |  161|   529k|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (206:14): [True: 0, False: 529k]
  ------------------
  207|       |
  208|       |         /* empty window and reset */
  209|   529k|         bitcpy = 0;
  210|   529k|         bitbuf = 0;
  211|   529k|         mode   = 1;
  212|   529k|      }
  213|  3.71M|   }
  214|       |
  215|       |   /* if bits remain then square/multiply */
  216|  2.36k|   if ((mode == 2) && (bitcpy > 0)) {
  ------------------
  |  Branch (216:8): [True: 1.72k, False: 639]
  |  Branch (216:23): [True: 1.72k, False: 0]
  ------------------
  217|       |      /* square then multiply if the bit is set */
  218|  8.12k|      for (x = 0; x < bitcpy; x++) {
  ------------------
  |  Branch (218:19): [True: 6.39k, False: 1.72k]
  ------------------
  219|  6.39k|         if ((err = mp_sqr(&res, &res)) != MP_OKAY)               goto LBL_RES;
  ------------------
  |  |  161|  6.39k|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (219:14): [True: 0, False: 6.39k]
  ------------------
  220|  6.39k|         if ((err = redux(&res, P, mp)) != MP_OKAY)               goto LBL_RES;
  ------------------
  |  |  161|  6.39k|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (220:14): [True: 0, False: 6.39k]
  ------------------
  221|       |
  222|       |         /* get next bit of the window */
  223|  6.39k|         bitbuf <<= 1;
  224|  6.39k|         if ((bitbuf & (1 << winsize)) != 0) {
  ------------------
  |  Branch (224:14): [True: 3.78k, False: 2.61k]
  ------------------
  225|       |            /* then multiply */
  226|  3.78k|            if ((err = mp_mul(&res, &M[1], &res)) != MP_OKAY)     goto LBL_RES;
  ------------------
  |  |  161|  3.78k|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (226:17): [True: 0, False: 3.78k]
  ------------------
  227|  3.78k|            if ((err = redux(&res, P, mp)) != MP_OKAY)            goto LBL_RES;
  ------------------
  |  |  161|  3.78k|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (227:17): [True: 0, False: 3.78k]
  ------------------
  228|  3.78k|         }
  229|  6.39k|      }
  230|  1.72k|   }
  231|       |
  232|  2.36k|   if (redmode == 0) {
  ------------------
  |  Branch (232:8): [True: 2.36k, False: 0]
  ------------------
  233|       |      /* fixup result if Montgomery reduction is used
  234|       |       * recall that any value in a Montgomery system is
  235|       |       * actually multiplied by R mod n.  So we have
  236|       |       * to reduce one more time to cancel out the factor
  237|       |       * of R.
  238|       |       */
  239|  2.36k|      if ((err = redux(&res, P, mp)) != MP_OKAY)                  goto LBL_RES;
  ------------------
  |  |  161|  2.36k|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (239:11): [True: 0, False: 2.36k]
  ------------------
  240|  2.36k|   }
  241|       |
  242|       |   /* swap res with Y */
  243|  2.36k|   mp_exch(&res, Y);
  244|  2.36k|   err = MP_OKAY;
  ------------------
  |  |  161|  2.36k|#define MP_OKAY       0   /* no error */
  ------------------
  245|  2.36k|LBL_RES:
  246|  2.36k|   mp_clear(&res);
  247|  2.36k|LBL_M:
  248|  2.36k|   mp_clear(&M[1]);
  249|   136k|   for (x = 1<<(winsize-1); x < (1 << winsize); x++) {
  ------------------
  |  Branch (249:29): [True: 134k, False: 2.36k]
  ------------------
  250|   134k|      mp_clear(&M[x]);
  251|   134k|   }
  252|  2.36k|   return err;
  253|  2.36k|}

s_mp_invmod_fast:
   13|  1.00k|{
   14|  1.00k|   mp_int  x, y, u, v, B, D;
   15|  1.00k|   mp_sign neg;
   16|  1.00k|   mp_err  err;
   17|       |
   18|       |   /* 2. [modified] b must be odd   */
   19|  1.00k|   if (MP_IS_EVEN(b)) {
  ------------------
  |  |  164|  1.00k|#define MP_IS_EVEN(a) (((a)->used == 0) || (((a)->dp[0] & 1u) == 0u))
  |  |  ------------------
  |  |  |  Branch (164:24): [True: 0, False: 1.00k]
  |  |  |  Branch (164:44): [True: 0, False: 1.00k]
  |  |  ------------------
  ------------------
   20|      0|      return MP_VAL;
  ------------------
  |  |  164|      0|#define MP_VAL        -3  /* invalid input */
  ------------------
   21|      0|   }
   22|       |
   23|       |   /* init all our temps */
   24|  1.00k|   if ((err = mp_init_multi(&x, &y, &u, &v, &B, &D, NULL)) != MP_OKAY) {
  ------------------
  |  |  161|  1.00k|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (24:8): [True: 0, False: 1.00k]
  ------------------
   25|      0|      return err;
   26|      0|   }
   27|       |
   28|       |   /* x == modulus, y == value to invert */
   29|  1.00k|   if ((err = mp_copy(b, &x)) != MP_OKAY)                         goto LBL_ERR;
  ------------------
  |  |  161|  1.00k|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (29:8): [True: 0, False: 1.00k]
  ------------------
   30|       |
   31|       |   /* we need y = |a| */
   32|  1.00k|   if ((err = mp_mod(a, b, &y)) != MP_OKAY)                       goto LBL_ERR;
  ------------------
  |  |  161|  1.00k|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (32:8): [True: 0, False: 1.00k]
  ------------------
   33|       |
   34|       |   /* if one of x,y is zero return an error! */
   35|  1.00k|   if (MP_IS_ZERO(&x) || MP_IS_ZERO(&y)) {
  ------------------
  |  |  163|  2.00k|#define MP_IS_ZERO(a) ((a)->used == 0)
  |  |  ------------------
  |  |  |  Branch (163:23): [True: 0, False: 1.00k]
  |  |  ------------------
  ------------------
                 if (MP_IS_ZERO(&x) || MP_IS_ZERO(&y)) {
  ------------------
  |  |  163|  1.00k|#define MP_IS_ZERO(a) ((a)->used == 0)
  |  |  ------------------
  |  |  |  Branch (163:23): [True: 0, False: 1.00k]
  |  |  ------------------
  ------------------
   36|      0|      err = MP_VAL;
  ------------------
  |  |  164|      0|#define MP_VAL        -3  /* invalid input */
  ------------------
   37|      0|      goto LBL_ERR;
   38|      0|   }
   39|       |
   40|       |   /* 3. u=x, v=y, A=1, B=0, C=0,D=1 */
   41|  1.00k|   if ((err = mp_copy(&x, &u)) != MP_OKAY)                        goto LBL_ERR;
  ------------------
  |  |  161|  1.00k|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (41:8): [True: 0, False: 1.00k]
  ------------------
   42|  1.00k|   if ((err = mp_copy(&y, &v)) != MP_OKAY)                        goto LBL_ERR;
  ------------------
  |  |  161|  1.00k|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (42:8): [True: 0, False: 1.00k]
  ------------------
   43|  1.00k|   mp_set(&D, 1uL);
   44|       |
   45|   322k|top:
   46|       |   /* 4.  while u is even do */
   47|   655k|   while (MP_IS_EVEN(&u)) {
  ------------------
  |  |  164|   655k|#define MP_IS_EVEN(a) (((a)->used == 0) || (((a)->dp[0] & 1u) == 0u))
  |  |  ------------------
  |  |  |  Branch (164:24): [True: 0, False: 655k]
  |  |  |  Branch (164:44): [True: 332k, False: 322k]
  |  |  ------------------
  ------------------
   48|       |      /* 4.1 u = u/2 */
   49|   332k|      if ((err = mp_div_2(&u, &u)) != MP_OKAY)                    goto LBL_ERR;
  ------------------
  |  |  161|   332k|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (49:11): [True: 0, False: 332k]
  ------------------
   50|       |
   51|       |      /* 4.2 if B is odd then */
   52|   332k|      if (MP_IS_ODD(&B)) {
  ------------------
  |  |  165|   332k|#define MP_IS_ODD(a)  (((a)->used > 0) && (((a)->dp[0] & 1u) == 1u))
  |  |  ------------------
  |  |  |  Branch (165:24): [True: 332k, False: 0]
  |  |  |  Branch (165:43): [True: 170k, False: 162k]
  |  |  ------------------
  ------------------
   53|   170k|         if ((err = mp_sub(&B, &x, &B)) != MP_OKAY)               goto LBL_ERR;
  ------------------
  |  |  161|   170k|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (53:14): [True: 0, False: 170k]
  ------------------
   54|   170k|      }
   55|       |      /* B = B/2 */
   56|   332k|      if ((err = mp_div_2(&B, &B)) != MP_OKAY)                    goto LBL_ERR;
  ------------------
  |  |  161|   332k|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (56:11): [True: 0, False: 332k]
  ------------------
   57|   332k|   }
   58|       |
   59|       |   /* 5.  while v is even do */
   60|   623k|   while (MP_IS_EVEN(&v)) {
  ------------------
  |  |  164|   623k|#define MP_IS_EVEN(a) (((a)->used == 0) || (((a)->dp[0] & 1u) == 0u))
  |  |  ------------------
  |  |  |  Branch (164:24): [True: 0, False: 623k]
  |  |  |  Branch (164:44): [True: 300k, False: 322k]
  |  |  ------------------
  ------------------
   61|       |      /* 5.1 v = v/2 */
   62|   300k|      if ((err = mp_div_2(&v, &v)) != MP_OKAY)                    goto LBL_ERR;
  ------------------
  |  |  161|   300k|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (62:11): [True: 0, False: 300k]
  ------------------
   63|       |
   64|       |      /* 5.2 if D is odd then */
   65|   300k|      if (MP_IS_ODD(&D)) {
  ------------------
  |  |  165|   300k|#define MP_IS_ODD(a)  (((a)->used > 0) && (((a)->dp[0] & 1u) == 1u))
  |  |  ------------------
  |  |  |  Branch (165:24): [True: 300k, False: 0]
  |  |  |  Branch (165:43): [True: 244k, False: 56.5k]
  |  |  ------------------
  ------------------
   66|       |         /* D = (D-x)/2 */
   67|   244k|         if ((err = mp_sub(&D, &x, &D)) != MP_OKAY)               goto LBL_ERR;
  ------------------
  |  |  161|   244k|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (67:14): [True: 0, False: 244k]
  ------------------
   68|   244k|      }
   69|       |      /* D = D/2 */
   70|   300k|      if ((err = mp_div_2(&D, &D)) != MP_OKAY)                    goto LBL_ERR;
  ------------------
  |  |  161|   300k|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (70:11): [True: 0, False: 300k]
  ------------------
   71|   300k|   }
   72|       |
   73|       |   /* 6.  if u >= v then */
   74|   322k|   if (mp_cmp(&u, &v) != MP_LT) {
  ------------------
  |  |  154|   322k|#define MP_LT        -1   /* less than */
  ------------------
  |  Branch (74:8): [True: 170k, False: 152k]
  ------------------
   75|       |      /* u = u - v, B = B - D */
   76|   170k|      if ((err = mp_sub(&u, &v, &u)) != MP_OKAY)                  goto LBL_ERR;
  ------------------
  |  |  161|   170k|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (76:11): [True: 0, False: 170k]
  ------------------
   77|       |
   78|   170k|      if ((err = mp_sub(&B, &D, &B)) != MP_OKAY)                  goto LBL_ERR;
  ------------------
  |  |  161|   170k|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (78:11): [True: 0, False: 170k]
  ------------------
   79|   170k|   } else {
   80|       |      /* v - v - u, D = D - B */
   81|   152k|      if ((err = mp_sub(&v, &u, &v)) != MP_OKAY)                  goto LBL_ERR;
  ------------------
  |  |  161|   152k|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (81:11): [True: 0, False: 152k]
  ------------------
   82|       |
   83|   152k|      if ((err = mp_sub(&D, &B, &D)) != MP_OKAY)                  goto LBL_ERR;
  ------------------
  |  |  161|   152k|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (83:11): [True: 0, False: 152k]
  ------------------
   84|   152k|   }
   85|       |
   86|       |   /* if not zero goto step 4 */
   87|   322k|   if (!MP_IS_ZERO(&u)) {
  ------------------
  |  |  163|   322k|#define MP_IS_ZERO(a) ((a)->used == 0)
  ------------------
  |  Branch (87:8): [True: 321k, False: 1.00k]
  ------------------
   88|   321k|      goto top;
   89|   321k|   }
   90|       |
   91|       |   /* now a = C, b = D, gcd == g*v */
   92|       |
   93|       |   /* if v != 1 then there is no inverse */
   94|  1.00k|   if (mp_cmp_d(&v, 1uL) != MP_EQ) {
  ------------------
  |  |  155|  1.00k|#define MP_EQ         0   /* equal to */
  ------------------
  |  Branch (94:8): [True: 4, False: 996]
  ------------------
   95|      4|      err = MP_VAL;
  ------------------
  |  |  164|      4|#define MP_VAL        -3  /* invalid input */
  ------------------
   96|      4|      goto LBL_ERR;
   97|      4|   }
   98|       |
   99|       |   /* b is now the inverse */
  100|    996|   neg = a->sign;
  101|  1.91k|   while (D.sign == MP_NEG) {
  ------------------
  |  |  152|  1.91k|#define MP_NEG        1   /* negative */
  ------------------
  |  Branch (101:11): [True: 923, False: 996]
  ------------------
  102|    923|      if ((err = mp_add(&D, b, &D)) != MP_OKAY)                   goto LBL_ERR;
  ------------------
  |  |  161|    923|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (102:11): [True: 0, False: 923]
  ------------------
  103|    923|   }
  104|       |
  105|       |   /* too big */
  106|    997|   while (mp_cmp_mag(&D, b) != MP_LT) {
  ------------------
  |  |  154|    997|#define MP_LT        -1   /* less than */
  ------------------
  |  Branch (106:11): [True: 1, False: 996]
  ------------------
  107|      1|      if ((err = mp_sub(&D, b, &D)) != MP_OKAY)                   goto LBL_ERR;
  ------------------
  |  |  161|      1|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (107:11): [True: 0, False: 1]
  ------------------
  108|      1|   }
  109|       |
  110|    996|   mp_exch(&D, c);
  111|    996|   c->sign = neg;
  112|    996|   err = MP_OKAY;
  ------------------
  |  |  161|    996|#define MP_OKAY       0   /* no error */
  ------------------
  113|       |
  114|  1.00k|LBL_ERR:
  115|       |   mp_clear_multi(&x, &y, &u, &v, &B, &D, NULL);
  116|  1.00k|   return err;
  117|    996|}

s_mp_invmod_slow:
    8|     53|{
    9|     53|   mp_int  x, y, u, v, A, B, C, D;
   10|     53|   mp_err  err;
   11|       |
   12|       |   /* b cannot be negative */
   13|     53|   if ((b->sign == MP_NEG) || MP_IS_ZERO(b)) {
  ------------------
  |  |  152|     53|#define MP_NEG        1   /* negative */
  ------------------
                 if ((b->sign == MP_NEG) || MP_IS_ZERO(b)) {
  ------------------
  |  |  163|     53|#define MP_IS_ZERO(a) ((a)->used == 0)
  |  |  ------------------
  |  |  |  Branch (163:23): [True: 0, False: 53]
  |  |  ------------------
  ------------------
  |  Branch (13:8): [True: 0, False: 53]
  ------------------
   14|      0|      return MP_VAL;
  ------------------
  |  |  164|      0|#define MP_VAL        -3  /* invalid input */
  ------------------
   15|      0|   }
   16|       |
   17|       |   /* init temps */
   18|     53|   if ((err = mp_init_multi(&x, &y, &u, &v,
  ------------------
  |  Branch (18:8): [True: 0, False: 53]
  ------------------
   19|     53|                            &A, &B, &C, &D, NULL)) != MP_OKAY) {
  ------------------
  |  |  161|     53|#define MP_OKAY       0   /* no error */
  ------------------
   20|      0|      return err;
   21|      0|   }
   22|       |
   23|       |   /* x = a, y = b */
   24|     53|   if ((err = mp_mod(a, b, &x)) != MP_OKAY)                       goto LBL_ERR;
  ------------------
  |  |  161|     53|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (24:8): [True: 0, False: 53]
  ------------------
   25|     53|   if ((err = mp_copy(b, &y)) != MP_OKAY)                         goto LBL_ERR;
  ------------------
  |  |  161|     53|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (25:8): [True: 0, False: 53]
  ------------------
   26|       |
   27|       |   /* 2. [modified] if x,y are both even then return an error! */
   28|     53|   if (MP_IS_EVEN(&x) && MP_IS_EVEN(&y)) {
  ------------------
  |  |  164|    106|#define MP_IS_EVEN(a) (((a)->used == 0) || (((a)->dp[0] & 1u) == 0u))
  |  |  ------------------
  |  |  |  Branch (164:24): [True: 0, False: 53]
  |  |  |  Branch (164:44): [True: 1, False: 52]
  |  |  ------------------
  ------------------
                 if (MP_IS_EVEN(&x) && MP_IS_EVEN(&y)) {
  ------------------
  |  |  164|      1|#define MP_IS_EVEN(a) (((a)->used == 0) || (((a)->dp[0] & 1u) == 0u))
  |  |  ------------------
  |  |  |  Branch (164:24): [True: 0, False: 1]
  |  |  |  Branch (164:44): [True: 1, False: 0]
  |  |  ------------------
  ------------------
   29|      1|      err = MP_VAL;
  ------------------
  |  |  164|      1|#define MP_VAL        -3  /* invalid input */
  ------------------
   30|      1|      goto LBL_ERR;
   31|      1|   }
   32|       |
   33|       |   /* 3. u=x, v=y, A=1, B=0, C=0,D=1 */
   34|     52|   if ((err = mp_copy(&x, &u)) != MP_OKAY)                        goto LBL_ERR;
  ------------------
  |  |  161|     52|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (34:8): [True: 0, False: 52]
  ------------------
   35|     52|   if ((err = mp_copy(&y, &v)) != MP_OKAY)                        goto LBL_ERR;
  ------------------
  |  |  161|     52|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (35:8): [True: 0, False: 52]
  ------------------
   36|     52|   mp_set(&A, 1uL);
   37|     52|   mp_set(&D, 1uL);
   38|       |
   39|  4.51k|top:
   40|       |   /* 4.  while u is even do */
   41|  8.38k|   while (MP_IS_EVEN(&u)) {
  ------------------
  |  |  164|  8.38k|#define MP_IS_EVEN(a) (((a)->used == 0) || (((a)->dp[0] & 1u) == 0u))
  |  |  ------------------
  |  |  |  Branch (164:24): [True: 0, False: 8.38k]
  |  |  |  Branch (164:44): [True: 3.86k, False: 4.51k]
  |  |  ------------------
  ------------------
   42|       |      /* 4.1 u = u/2 */
   43|  3.86k|      if ((err = mp_div_2(&u, &u)) != MP_OKAY)                    goto LBL_ERR;
  ------------------
  |  |  161|  3.86k|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (43:11): [True: 0, False: 3.86k]
  ------------------
   44|       |
   45|       |      /* 4.2 if A or B is odd then */
   46|  3.86k|      if (MP_IS_ODD(&A) || MP_IS_ODD(&B)) {
  ------------------
  |  |  165|  7.73k|#define MP_IS_ODD(a)  (((a)->used > 0) && (((a)->dp[0] & 1u) == 1u))
  |  |  ------------------
  |  |  |  Branch (165:24): [True: 3.86k, False: 0]
  |  |  |  Branch (165:43): [True: 0, False: 3.86k]
  |  |  ------------------
  ------------------
                    if (MP_IS_ODD(&A) || MP_IS_ODD(&B)) {
  ------------------
  |  |  165|  3.86k|#define MP_IS_ODD(a)  (((a)->used > 0) && (((a)->dp[0] & 1u) == 1u))
  |  |  ------------------
  |  |  |  Branch (165:24): [True: 3.86k, False: 0]
  |  |  |  Branch (165:43): [True: 1.81k, False: 2.05k]
  |  |  ------------------
  ------------------
   47|       |         /* A = (A+y)/2, B = (B-x)/2 */
   48|  1.81k|         if ((err = mp_add(&A, &y, &A)) != MP_OKAY)               goto LBL_ERR;
  ------------------
  |  |  161|  1.81k|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (48:14): [True: 0, False: 1.81k]
  ------------------
   49|  1.81k|         if ((err = mp_sub(&B, &x, &B)) != MP_OKAY)               goto LBL_ERR;
  ------------------
  |  |  161|  1.81k|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (49:14): [True: 0, False: 1.81k]
  ------------------
   50|  1.81k|      }
   51|       |      /* A = A/2, B = B/2 */
   52|  3.86k|      if ((err = mp_div_2(&A, &A)) != MP_OKAY)                    goto LBL_ERR;
  ------------------
  |  |  161|  3.86k|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (52:11): [True: 0, False: 3.86k]
  ------------------
   53|  3.86k|      if ((err = mp_div_2(&B, &B)) != MP_OKAY)                    goto LBL_ERR;
  ------------------
  |  |  161|  3.86k|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (53:11): [True: 0, False: 3.86k]
  ------------------
   54|  3.86k|   }
   55|       |
   56|       |   /* 5.  while v is even do */
   57|  10.9k|   while (MP_IS_EVEN(&v)) {
  ------------------
  |  |  164|  10.9k|#define MP_IS_EVEN(a) (((a)->used == 0) || (((a)->dp[0] & 1u) == 0u))
  |  |  ------------------
  |  |  |  Branch (164:24): [True: 0, False: 10.9k]
  |  |  |  Branch (164:44): [True: 6.39k, False: 4.51k]
  |  |  ------------------
  ------------------
   58|       |      /* 5.1 v = v/2 */
   59|  6.39k|      if ((err = mp_div_2(&v, &v)) != MP_OKAY)                    goto LBL_ERR;
  ------------------
  |  |  161|  6.39k|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (59:11): [True: 0, False: 6.39k]
  ------------------
   60|       |
   61|       |      /* 5.2 if C or D is odd then */
   62|  6.39k|      if (MP_IS_ODD(&C) || MP_IS_ODD(&D)) {
  ------------------
  |  |  165|  12.7k|#define MP_IS_ODD(a)  (((a)->used > 0) && (((a)->dp[0] & 1u) == 1u))
  |  |  ------------------
  |  |  |  Branch (165:24): [True: 6.34k, False: 52]
  |  |  |  Branch (165:43): [True: 0, False: 6.34k]
  |  |  ------------------
  ------------------
                    if (MP_IS_ODD(&C) || MP_IS_ODD(&D)) {
  ------------------
  |  |  165|  6.39k|#define MP_IS_ODD(a)  (((a)->used > 0) && (((a)->dp[0] & 1u) == 1u))
  |  |  ------------------
  |  |  |  Branch (165:24): [True: 6.24k, False: 158]
  |  |  |  Branch (165:43): [True: 3.84k, False: 2.39k]
  |  |  ------------------
  ------------------
   63|       |         /* C = (C+y)/2, D = (D-x)/2 */
   64|  3.84k|         if ((err = mp_add(&C, &y, &C)) != MP_OKAY)               goto LBL_ERR;
  ------------------
  |  |  161|  3.84k|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (64:14): [True: 0, False: 3.84k]
  ------------------
   65|  3.84k|         if ((err = mp_sub(&D, &x, &D)) != MP_OKAY)               goto LBL_ERR;
  ------------------
  |  |  161|  3.84k|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (65:14): [True: 0, False: 3.84k]
  ------------------
   66|  3.84k|      }
   67|       |      /* C = C/2, D = D/2 */
   68|  6.39k|      if ((err = mp_div_2(&C, &C)) != MP_OKAY)                    goto LBL_ERR;
  ------------------
  |  |  161|  6.39k|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (68:11): [True: 0, False: 6.39k]
  ------------------
   69|  6.39k|      if ((err = mp_div_2(&D, &D)) != MP_OKAY)                    goto LBL_ERR;
  ------------------
  |  |  161|  6.39k|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (69:11): [True: 0, False: 6.39k]
  ------------------
   70|  6.39k|   }
   71|       |
   72|       |   /* 6.  if u >= v then */
   73|  4.51k|   if (mp_cmp(&u, &v) != MP_LT) {
  ------------------
  |  |  154|  4.51k|#define MP_LT        -1   /* less than */
  ------------------
  |  Branch (73:8): [True: 1.87k, False: 2.64k]
  ------------------
   74|       |      /* u = u - v, A = A - C, B = B - D */
   75|  1.87k|      if ((err = mp_sub(&u, &v, &u)) != MP_OKAY)                  goto LBL_ERR;
  ------------------
  |  |  161|  1.87k|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (75:11): [True: 0, False: 1.87k]
  ------------------
   76|       |
   77|  1.87k|      if ((err = mp_sub(&A, &C, &A)) != MP_OKAY)                  goto LBL_ERR;
  ------------------
  |  |  161|  1.87k|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (77:11): [True: 0, False: 1.87k]
  ------------------
   78|       |
   79|  1.87k|      if ((err = mp_sub(&B, &D, &B)) != MP_OKAY)                  goto LBL_ERR;
  ------------------
  |  |  161|  1.87k|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (79:11): [True: 0, False: 1.87k]
  ------------------
   80|  2.64k|   } else {
   81|       |      /* v - v - u, C = C - A, D = D - B */
   82|  2.64k|      if ((err = mp_sub(&v, &u, &v)) != MP_OKAY)                  goto LBL_ERR;
  ------------------
  |  |  161|  2.64k|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (82:11): [True: 0, False: 2.64k]
  ------------------
   83|       |
   84|  2.64k|      if ((err = mp_sub(&C, &A, &C)) != MP_OKAY)                  goto LBL_ERR;
  ------------------
  |  |  161|  2.64k|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (84:11): [True: 0, False: 2.64k]
  ------------------
   85|       |
   86|  2.64k|      if ((err = mp_sub(&D, &B, &D)) != MP_OKAY)                  goto LBL_ERR;
  ------------------
  |  |  161|  2.64k|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (86:11): [True: 0, False: 2.64k]
  ------------------
   87|  2.64k|   }
   88|       |
   89|       |   /* if not zero goto step 4 */
   90|  4.51k|   if (!MP_IS_ZERO(&u)) {
  ------------------
  |  |  163|  4.51k|#define MP_IS_ZERO(a) ((a)->used == 0)
  ------------------
  |  Branch (90:8): [True: 4.46k, False: 52]
  ------------------
   91|  4.46k|      goto top;
   92|  4.46k|   }
   93|       |
   94|       |   /* now a = C, b = D, gcd == g*v */
   95|       |
   96|       |   /* if v != 1 then there is no inverse */
   97|     52|   if (mp_cmp_d(&v, 1uL) != MP_EQ) {
  ------------------
  |  |  155|     52|#define MP_EQ         0   /* equal to */
  ------------------
  |  Branch (97:8): [True: 10, False: 42]
  ------------------
   98|     10|      err = MP_VAL;
  ------------------
  |  |  164|     10|#define MP_VAL        -3  /* invalid input */
  ------------------
   99|     10|      goto LBL_ERR;
  100|     10|   }
  101|       |
  102|       |   /* if its too low */
  103|     55|   while (mp_cmp_d(&C, 0uL) == MP_LT) {
  ------------------
  |  |  154|     55|#define MP_LT        -1   /* less than */
  ------------------
  |  Branch (103:11): [True: 13, False: 42]
  ------------------
  104|     13|      if ((err = mp_add(&C, b, &C)) != MP_OKAY)                   goto LBL_ERR;
  ------------------
  |  |  161|     13|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (104:11): [True: 0, False: 13]
  ------------------
  105|     13|   }
  106|       |
  107|       |   /* too big */
  108|     45|   while (mp_cmp_mag(&C, b) != MP_LT) {
  ------------------
  |  |  154|     45|#define MP_LT        -1   /* less than */
  ------------------
  |  Branch (108:11): [True: 3, False: 42]
  ------------------
  109|      3|      if ((err = mp_sub(&C, b, &C)) != MP_OKAY)                   goto LBL_ERR;
  ------------------
  |  |  161|      3|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (109:11): [True: 0, False: 3]
  ------------------
  110|      3|   }
  111|       |
  112|       |   /* C is now the inverse */
  113|     42|   mp_exch(&C, c);
  114|     42|   err = MP_OKAY;
  ------------------
  |  |  161|     42|#define MP_OKAY       0   /* no error */
  ------------------
  115|     53|LBL_ERR:
  116|       |   mp_clear_multi(&x, &y, &u, &v, &A, &B, &C, &D, NULL);
  117|     53|   return err;
  118|     42|}

s_mp_montgomery_reduce_fast:
   15|  15.3M|{
   16|  15.3M|   int     ix, olduse;
   17|  15.3M|   mp_err  err;
   18|  15.3M|   mp_word W[MP_WARRAY];
   19|       |
   20|  15.3M|   if (x->used > MP_WARRAY) {
  ------------------
  |  |  172|  15.3M|#define MP_WARRAY PRIVATE_MP_WARRAY
  |  |  ------------------
  |  |  |  |  203|  15.3M|#define PRIVATE_MP_WARRAY (int)(1uLL << (((CHAR_BIT * sizeof(private_mp_word)) - (2 * MP_DIGIT_BIT)) + 1))
  |  |  |  |  ------------------
  |  |  |  |  |  |   82|  15.3M|#   define MP_DIGIT_BIT 60
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (20:8): [True: 0, False: 15.3M]
  ------------------
   21|      0|      return MP_VAL;
  ------------------
  |  |  164|      0|#define MP_VAL        -3  /* invalid input */
  ------------------
   22|      0|   }
   23|       |
   24|       |   /* get old used count */
   25|  15.3M|   olduse = x->used;
   26|       |
   27|       |   /* grow a as required */
   28|  15.3M|   if (x->alloc < (n->used + 1)) {
  ------------------
  |  Branch (28:8): [True: 0, False: 15.3M]
  ------------------
   29|      0|      if ((err = mp_grow(x, n->used + 1)) != MP_OKAY) {
  ------------------
  |  |  161|      0|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (29:11): [True: 0, False: 0]
  ------------------
   30|      0|         return err;
   31|      0|      }
   32|      0|   }
   33|       |
   34|       |   /* first we have to get the digits of the input into
   35|       |    * an array of double precision words W[...]
   36|       |    */
   37|  15.3M|   {
   38|  15.3M|      mp_word *_W;
   39|  15.3M|      mp_digit *tmpx;
   40|       |
   41|       |      /* alias for the W[] array */
   42|  15.3M|      _W   = W;
   43|       |
   44|       |      /* alias for the digits of  x*/
   45|  15.3M|      tmpx = x->dp;
   46|       |
   47|       |      /* copy the digits of a into W[0..a->used-1] */
   48|   528M|      for (ix = 0; ix < x->used; ix++) {
  ------------------
  |  Branch (48:20): [True: 513M, False: 15.3M]
  ------------------
   49|   513M|         *_W++ = *tmpx++;
   50|   513M|      }
   51|       |
   52|       |      /* zero the high words of W[a->used..m->used*2] */
   53|  15.3M|      if (ix < ((n->used * 2) + 1)) {
  ------------------
  |  Branch (53:11): [True: 15.3M, False: 0]
  ------------------
   54|  15.3M|         MP_ZERO_BUFFER(_W, sizeof(mp_word) * (size_t)(((n->used * 2) + 1) - ix));
  ------------------
  |  |   81|  15.3M|#  define MP_ZERO_BUFFER(mem, size)                     \
  |  |   82|  15.3M|do {                                                    \
  |  |   83|  15.3M|   size_t zs_ = (size);                                 \
  |  |   84|  15.3M|   char* zm_ = (char*)(mem);                            \
  |  |   85|   386M|   while (zs_-- > 0u) {                                 \
  |  |  ------------------
  |  |  |  Branch (85:11): [True: 370M, False: 15.3M]
  |  |  ------------------
  |  |   86|   370M|      *zm_++ = '\0';                                    \
  |  |   87|   370M|   }                                                    \
  |  |   88|  15.3M|} while (0)
  |  |  ------------------
  |  |  |  Branch (88:10): [Folded, False: 15.3M]
  |  |  ------------------
  ------------------
   55|  15.3M|      }
   56|  15.3M|   }
   57|       |
   58|       |   /* now we proceed to zero successive digits
   59|       |    * from the least significant upwards
   60|       |    */
   61|   275M|   for (ix = 0; ix < n->used; ix++) {
  ------------------
  |  Branch (61:17): [True: 260M, False: 15.3M]
  ------------------
   62|       |      /* mu = ai * m' mod b
   63|       |       *
   64|       |       * We avoid a double precision multiplication (which isn't required)
   65|       |       * by casting the value down to a mp_digit.  Note this requires
   66|       |       * that W[ix-1] have  the carry cleared (see after the inner loop)
   67|       |       */
   68|   260M|      mp_digit mu;
   69|   260M|      mu = ((W[ix] & MP_MASK) * rho) & MP_MASK;
  ------------------
  |  |  106|   260M|#define MP_MASK          ((((mp_digit)1)<<((mp_digit)MP_DIGIT_BIT))-((mp_digit)1))
  |  |  ------------------
  |  |  |  |   82|   260M|#   define MP_DIGIT_BIT 60
  |  |  ------------------
  ------------------
                    mu = ((W[ix] & MP_MASK) * rho) & MP_MASK;
  ------------------
  |  |  106|   260M|#define MP_MASK          ((((mp_digit)1)<<((mp_digit)MP_DIGIT_BIT))-((mp_digit)1))
  |  |  ------------------
  |  |  |  |   82|   260M|#   define MP_DIGIT_BIT 60
  |  |  ------------------
  ------------------
   70|       |
   71|       |      /* a = a + mu * m * b**i
   72|       |       *
   73|       |       * This is computed in place and on the fly.  The multiplication
   74|       |       * by b**i is handled by offseting which columns the results
   75|       |       * are added to.
   76|       |       *
   77|       |       * Note the comba method normally doesn't handle carries in the
   78|       |       * inner loop In this case we fix the carry from the previous
   79|       |       * column since the Montgomery reduction requires digits of the
   80|       |       * result (so far) [see above] to work.  This is
   81|       |       * handled by fixing up one carry after the inner loop.  The
   82|       |       * carry fixups are done in order so after these loops the
   83|       |       * first m->used words of W[] have the carries fixed
   84|       |       */
   85|   260M|      {
   86|   260M|         int iy;
   87|   260M|         mp_digit *tmpn;
   88|   260M|         mp_word *_W;
   89|       |
   90|       |         /* alias for the digits of the modulus */
   91|   260M|         tmpn = n->dp;
   92|       |
   93|       |         /* Alias for the columns set by an offset of ix */
   94|   260M|         _W = W + ix;
   95|       |
   96|       |         /* inner loop */
   97|  7.05G|         for (iy = 0; iy < n->used; iy++) {
  ------------------
  |  Branch (97:23): [True: 6.79G, False: 260M]
  ------------------
   98|  6.79G|            *_W++ += (mp_word)mu * (mp_word)*tmpn++;
   99|  6.79G|         }
  100|   260M|      }
  101|       |
  102|       |      /* now fix carry for next digit, W[ix+1] */
  103|   260M|      W[ix + 1] += W[ix] >> (mp_word)MP_DIGIT_BIT;
  ------------------
  |  |   82|   260M|#   define MP_DIGIT_BIT 60
  ------------------
  104|   260M|   }
  105|       |
  106|       |   /* now we have to propagate the carries and
  107|       |    * shift the words downward [all those least
  108|       |    * significant digits we zeroed].
  109|       |    */
  110|  15.3M|   {
  111|  15.3M|      mp_digit *tmpx;
  112|  15.3M|      mp_word *_W, *_W1;
  113|       |
  114|       |      /* nox fix rest of carries */
  115|       |
  116|       |      /* alias for current word */
  117|  15.3M|      _W1 = W + ix;
  118|       |
  119|       |      /* alias for next word, where the carry goes */
  120|  15.3M|      _W = W + ++ix;
  121|       |
  122|   275M|      for (; ix < ((n->used * 2) + 1); ix++) {
  ------------------
  |  Branch (122:14): [True: 260M, False: 15.3M]
  ------------------
  123|   260M|         *_W++ += *_W1++ >> (mp_word)MP_DIGIT_BIT;
  ------------------
  |  |   82|   260M|#   define MP_DIGIT_BIT 60
  ------------------
  124|   260M|      }
  125|       |
  126|       |      /* copy out, A = A/b**n
  127|       |       *
  128|       |       * The result is A/b**n but instead of converting from an
  129|       |       * array of mp_word to mp_digit than calling mp_rshd
  130|       |       * we just copy them in the right order
  131|       |       */
  132|       |
  133|       |      /* alias for destination word */
  134|  15.3M|      tmpx = x->dp;
  135|       |
  136|       |      /* alias for shifted double precision result */
  137|  15.3M|      _W = W + n->used;
  138|       |
  139|   291M|      for (ix = 0; ix < (n->used + 1); ix++) {
  ------------------
  |  Branch (139:20): [True: 275M, False: 15.3M]
  ------------------
  140|   275M|         *tmpx++ = *_W++ & (mp_word)MP_MASK;
  ------------------
  |  |  106|   275M|#define MP_MASK          ((((mp_digit)1)<<((mp_digit)MP_DIGIT_BIT))-((mp_digit)1))
  |  |  ------------------
  |  |  |  |   82|   275M|#   define MP_DIGIT_BIT 60
  |  |  ------------------
  ------------------
  141|   275M|      }
  142|       |
  143|       |      /* zero oldused digits, if the input a was larger than
  144|       |       * m->used+1 we'll have to clear the digits
  145|       |       */
  146|  15.3M|      MP_ZERO_DIGITS(tmpx, olduse - ix);
  ------------------
  |  |   89|  15.3M|#  define MP_ZERO_DIGITS(mem, digits)                   \
  |  |   90|  15.3M|do {                                                    \
  |  |   91|  15.3M|   int zd_ = (digits);                                  \
  |  |   92|  15.3M|   mp_digit* zm_ = (mem);                               \
  |  |   93|   253M|   while (zd_-- > 0) {                                  \
  |  |  ------------------
  |  |  |  Branch (93:11): [True: 237M, False: 15.3M]
  |  |  ------------------
  |  |   94|   237M|      *zm_++ = 0;                                       \
  |  |   95|   237M|   }                                                    \
  |  |   96|  15.3M|} while (0)
  |  |  ------------------
  |  |  |  Branch (96:10): [Folded, False: 15.3M]
  |  |  ------------------
  ------------------
  147|  15.3M|   }
  148|       |
  149|       |   /* set the max used and clamp */
  150|  15.3M|   x->used = n->used + 1;
  151|  15.3M|   mp_clamp(x);
  152|       |
  153|       |   /* if A >= m then A = A - m */
  154|  15.3M|   if (mp_cmp_mag(x, n) != MP_LT) {
  ------------------
  |  |  154|  15.3M|#define MP_LT        -1   /* less than */
  ------------------
  |  Branch (154:8): [True: 143, False: 15.3M]
  ------------------
  155|    143|      return s_mp_sub(x, n, x);
  156|    143|   }
  157|  15.3M|   return MP_OKAY;
  ------------------
  |  |  161|  15.3M|#define MP_OKAY       0   /* no error */
  ------------------
  158|  15.3M|}

s_mp_mul_digs:
   11|  26.3k|{
   12|  26.3k|   mp_int  t;
   13|  26.3k|   mp_err  err;
   14|  26.3k|   int     pa, pb, ix, iy;
   15|  26.3k|   mp_digit u;
   16|  26.3k|   mp_word r;
   17|  26.3k|   mp_digit tmpx, *tmpt, *tmpy;
   18|       |
   19|  26.3k|   if (digs < 0) {
  ------------------
  |  Branch (19:8): [True: 0, False: 26.3k]
  ------------------
   20|      0|      return MP_VAL;
  ------------------
  |  |  164|      0|#define MP_VAL        -3  /* invalid input */
  ------------------
   21|      0|   }
   22|       |
   23|       |   /* can we use the fast multiplier? */
   24|  26.3k|   if ((digs < MP_WARRAY) &&
  ------------------
  |  |  172|  26.3k|#define MP_WARRAY PRIVATE_MP_WARRAY
  |  |  ------------------
  |  |  |  |  203|  26.3k|#define PRIVATE_MP_WARRAY (int)(1uLL << (((CHAR_BIT * sizeof(private_mp_word)) - (2 * MP_DIGIT_BIT)) + 1))
  |  |  |  |  ------------------
  |  |  |  |  |  |   82|  26.3k|#   define MP_DIGIT_BIT 60
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (24:8): [True: 26.3k, False: 0]
  ------------------
   25|  26.3k|       (MP_MIN(a->used, b->used) < MP_MAXFAST)) {
  ------------------
  |  |  156|  26.3k|#define MP_MIN(x, y) (((x) < (y)) ? (x) : (y))
  |  |  ------------------
  |  |  |  Branch (156:23): [True: 18.0k, False: 8.32k]
  |  |  ------------------
  ------------------
                     (MP_MIN(a->used, b->used) < MP_MAXFAST)) {
  ------------------
  |  |  168|  26.3k|#define MP_MAXFAST              (int)(1uL << (MP_SIZEOF_BITS(mp_word) - (2u * (size_t)MP_DIGIT_BIT)))
  |  |  ------------------
  |  |  |  |  167|  26.3k|#define MP_SIZEOF_BITS(type)    ((size_t)CHAR_BIT * sizeof(type))
  |  |  ------------------
  |  |               #define MP_MAXFAST              (int)(1uL << (MP_SIZEOF_BITS(mp_word) - (2u * (size_t)MP_DIGIT_BIT)))
  |  |  ------------------
  |  |  |  |   82|  26.3k|#   define MP_DIGIT_BIT 60
  |  |  ------------------
  ------------------
  |  Branch (25:8): [True: 26.3k, False: 0]
  ------------------
   26|  26.3k|      return s_mp_mul_digs_fast(a, b, c, digs);
   27|  26.3k|   }
   28|       |
   29|      0|   if ((err = mp_init_size(&t, digs)) != MP_OKAY) {
  ------------------
  |  |  161|      0|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (29:8): [True: 0, False: 0]
  ------------------
   30|      0|      return err;
   31|      0|   }
   32|      0|   t.used = digs;
   33|       |
   34|       |   /* compute the digits of the product directly */
   35|      0|   pa = a->used;
   36|      0|   for (ix = 0; ix < pa; ix++) {
  ------------------
  |  Branch (36:17): [True: 0, False: 0]
  ------------------
   37|       |      /* set the carry to zero */
   38|      0|      u = 0;
   39|       |
   40|       |      /* limit ourselves to making digs digits of output */
   41|      0|      pb = MP_MIN(b->used, digs - ix);
  ------------------
  |  |  156|      0|#define MP_MIN(x, y) (((x) < (y)) ? (x) : (y))
  |  |  ------------------
  |  |  |  Branch (156:23): [True: 0, False: 0]
  |  |  ------------------
  ------------------
   42|       |
   43|       |      /* setup some aliases */
   44|       |      /* copy of the digit from a used within the nested loop */
   45|      0|      tmpx = a->dp[ix];
   46|       |
   47|       |      /* an alias for the destination shifted ix places */
   48|      0|      tmpt = t.dp + ix;
   49|       |
   50|       |      /* an alias for the digits of b */
   51|      0|      tmpy = b->dp;
   52|       |
   53|       |      /* compute the columns of the output and propagate the carry */
   54|      0|      for (iy = 0; iy < pb; iy++) {
  ------------------
  |  Branch (54:20): [True: 0, False: 0]
  ------------------
   55|       |         /* compute the column as a mp_word */
   56|      0|         r       = (mp_word)*tmpt +
   57|      0|                   ((mp_word)tmpx * (mp_word)*tmpy++) +
   58|      0|                   (mp_word)u;
   59|       |
   60|       |         /* the new column is the lower part of the result */
   61|      0|         *tmpt++ = (mp_digit)(r & (mp_word)MP_MASK);
  ------------------
  |  |  106|      0|#define MP_MASK          ((((mp_digit)1)<<((mp_digit)MP_DIGIT_BIT))-((mp_digit)1))
  |  |  ------------------
  |  |  |  |   82|      0|#   define MP_DIGIT_BIT 60
  |  |  ------------------
  ------------------
   62|       |
   63|       |         /* get the carry word from the result */
   64|      0|         u       = (mp_digit)(r >> (mp_word)MP_DIGIT_BIT);
  ------------------
  |  |   82|      0|#   define MP_DIGIT_BIT 60
  ------------------
   65|      0|      }
   66|       |      /* set carry if it is placed below digs */
   67|      0|      if ((ix + iy) < digs) {
  ------------------
  |  Branch (67:11): [True: 0, False: 0]
  ------------------
   68|      0|         *tmpt = u;
   69|      0|      }
   70|      0|   }
   71|       |
   72|      0|   mp_clamp(&t);
   73|      0|   mp_exch(&t, c);
   74|       |
   75|      0|   mp_clear(&t);
   76|      0|   return MP_OKAY;
  ------------------
  |  |  161|      0|#define MP_OKAY       0   /* no error */
  ------------------
   77|      0|}

s_mp_mul_digs_fast:
   23|  12.6M|{
   24|  12.6M|   int      olduse, pa, ix, iz;
   25|  12.6M|   mp_err   err;
   26|  12.6M|   mp_digit W[MP_WARRAY];
   27|  12.6M|   mp_word  _W;
   28|       |
   29|  12.6M|   if (digs < 0) {
  ------------------
  |  Branch (29:8): [True: 0, False: 12.6M]
  ------------------
   30|      0|      return MP_VAL;
  ------------------
  |  |  164|      0|#define MP_VAL        -3  /* invalid input */
  ------------------
   31|      0|   }
   32|       |
   33|       |   /* grow the destination as required */
   34|  12.6M|   if (c->alloc < digs) {
  ------------------
  |  Branch (34:8): [True: 145k, False: 12.4M]
  ------------------
   35|   145k|      if ((err = mp_grow(c, digs)) != MP_OKAY) {
  ------------------
  |  |  161|   145k|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (35:11): [True: 0, False: 145k]
  ------------------
   36|      0|         return err;
   37|      0|      }
   38|   145k|   }
   39|       |
   40|       |   /* number of output digits to produce */
   41|  12.6M|   pa = MP_MIN(digs, a->used + b->used);
  ------------------
  |  |  156|  12.6M|#define MP_MIN(x, y) (((x) < (y)) ? (x) : (y))
  |  |  ------------------
  |  |  |  Branch (156:23): [True: 13.3k, False: 12.6M]
  |  |  ------------------
  ------------------
   42|       |
   43|       |   /* clear the carry */
   44|  12.6M|   _W = 0;
   45|   312M|   for (ix = 0; ix < pa; ix++) {
  ------------------
  |  Branch (45:17): [True: 299M, False: 12.6M]
  ------------------
   46|   299M|      int      tx, ty;
   47|   299M|      int      iy;
   48|   299M|      mp_digit *tmpx, *tmpy;
   49|       |
   50|       |      /* get offsets into the two bignums */
   51|   299M|      ty = MP_MIN(b->used-1, ix);
  ------------------
  |  |  156|   299M|#define MP_MIN(x, y) (((x) < (y)) ? (x) : (y))
  |  |  ------------------
  |  |  |  Branch (156:23): [True: 126M, False: 172M]
  |  |  ------------------
  ------------------
   52|   299M|      tx = ix - ty;
   53|       |
   54|       |      /* setup temp aliases */
   55|   299M|      tmpx = a->dp + tx;
   56|   299M|      tmpy = b->dp + ty;
   57|       |
   58|       |      /* this is the number of times the loop will iterrate, essentially
   59|       |         while (tx++ < a->used && ty-- >= 0) { ... }
   60|       |       */
   61|   299M|      iy = MP_MIN(a->used-tx, ty+1);
  ------------------
  |  |  156|   299M|#define MP_MIN(x, y) (((x) < (y)) ? (x) : (y))
  |  |  ------------------
  |  |  |  Branch (156:23): [True: 172M, False: 126M]
  |  |  ------------------
  ------------------
   62|       |
   63|       |      /* execute loop */
   64|  2.42G|      for (iz = 0; iz < iy; ++iz) {
  ------------------
  |  Branch (64:20): [True: 2.12G, False: 299M]
  ------------------
   65|  2.12G|         _W += (mp_word)*tmpx++ * (mp_word)*tmpy--;
   66|       |
   67|  2.12G|      }
   68|       |
   69|       |      /* store term */
   70|   299M|      W[ix] = (mp_digit)_W & MP_MASK;
  ------------------
  |  |  106|   299M|#define MP_MASK          ((((mp_digit)1)<<((mp_digit)MP_DIGIT_BIT))-((mp_digit)1))
  |  |  ------------------
  |  |  |  |   82|   299M|#   define MP_DIGIT_BIT 60
  |  |  ------------------
  ------------------
   71|       |
   72|       |      /* make next carry */
   73|   299M|      _W = _W >> (mp_word)MP_DIGIT_BIT;
  ------------------
  |  |   82|   299M|#   define MP_DIGIT_BIT 60
  ------------------
   74|   299M|   }
   75|       |
   76|       |   /* setup dest */
   77|  12.6M|   olduse  = c->used;
   78|  12.6M|   c->used = pa;
   79|       |
   80|  12.6M|   {
   81|  12.6M|      mp_digit *tmpc;
   82|  12.6M|      tmpc = c->dp;
   83|   312M|      for (ix = 0; ix < pa; ix++) {
  ------------------
  |  Branch (83:20): [True: 299M, False: 12.6M]
  ------------------
   84|       |         /* now extract the previous digit [below the carry] */
   85|   299M|         *tmpc++ = W[ix];
   86|   299M|      }
   87|       |
   88|       |      /* clear unused digits [that existed in the old copy of c] */
   89|  12.6M|      MP_ZERO_DIGITS(tmpc, olduse - ix);
  ------------------
  |  |   89|  12.6M|#  define MP_ZERO_DIGITS(mem, digits)                   \
  |  |   90|  12.6M|do {                                                    \
  |  |   91|  12.6M|   int zd_ = (digits);                                  \
  |  |   92|  12.6M|   mp_digit* zm_ = (mem);                               \
  |  |   93|  12.6M|   while (zd_-- > 0) {                                  \
  |  |  ------------------
  |  |  |  Branch (93:11): [True: 0, False: 12.6M]
  |  |  ------------------
  |  |   94|      0|      *zm_++ = 0;                                       \
  |  |   95|      0|   }                                                    \
  |  |   96|  12.6M|} while (0)
  |  |  ------------------
  |  |  |  Branch (96:10): [Folded, False: 12.6M]
  |  |  ------------------
  ------------------
   90|  12.6M|   }
   91|  12.6M|   mp_clamp(c);
   92|  12.6M|   return MP_OKAY;
  ------------------
  |  |  161|  12.6M|#define MP_OKAY       0   /* no error */
  ------------------
   93|  12.6M|}

s_mp_mul_high_digs:
   10|  26.3k|{
   11|  26.3k|   mp_int   t;
   12|  26.3k|   int      pa, pb, ix, iy;
   13|  26.3k|   mp_err   err;
   14|  26.3k|   mp_digit u;
   15|  26.3k|   mp_word  r;
   16|  26.3k|   mp_digit tmpx, *tmpt, *tmpy;
   17|       |
   18|  26.3k|   if (digs < 0) {
  ------------------
  |  Branch (18:8): [True: 0, False: 26.3k]
  ------------------
   19|      0|      return MP_VAL;
  ------------------
  |  |  164|      0|#define MP_VAL        -3  /* invalid input */
  ------------------
   20|      0|   }
   21|       |
   22|       |   /* can we use the fast multiplier? */
   23|  26.3k|   if (MP_HAS(S_MP_MUL_HIGH_DIGS_FAST)
  ------------------
  |  |  150|  52.7k|#define MP_HAS(x)        (sizeof(MP_STRINGIZE(BN_##x##_C)) == 1u)
  |  |  ------------------
  |  |  |  |  148|  26.3k|#define MP_STRINGIZE(x)  MP__STRINGIZE(x)
  |  |  |  |  ------------------
  |  |  |  |  |  |  149|  26.3k|#define MP__STRINGIZE(x) ""#x""
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (150:26): [True: 26.3k, Folded]
  |  |  ------------------
  ------------------
   24|  26.3k|       && ((a->used + b->used + 1) < MP_WARRAY)
  ------------------
  |  |  172|  26.3k|#define MP_WARRAY PRIVATE_MP_WARRAY
  |  |  ------------------
  |  |  |  |  203|  26.3k|#define PRIVATE_MP_WARRAY (int)(1uLL << (((CHAR_BIT * sizeof(private_mp_word)) - (2 * MP_DIGIT_BIT)) + 1))
  |  |  |  |  ------------------
  |  |  |  |  |  |   82|  26.3k|#   define MP_DIGIT_BIT 60
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (24:11): [True: 26.3k, False: 0]
  ------------------
   25|  26.3k|       && (MP_MIN(a->used, b->used) < MP_MAXFAST)) {
  ------------------
  |  |  156|  26.3k|#define MP_MIN(x, y) (((x) < (y)) ? (x) : (y))
  |  |  ------------------
  |  |  |  Branch (156:23): [True: 26.0k, False: 361]
  |  |  ------------------
  ------------------
                     && (MP_MIN(a->used, b->used) < MP_MAXFAST)) {
  ------------------
  |  |  168|  26.3k|#define MP_MAXFAST              (int)(1uL << (MP_SIZEOF_BITS(mp_word) - (2u * (size_t)MP_DIGIT_BIT)))
  |  |  ------------------
  |  |  |  |  167|  26.3k|#define MP_SIZEOF_BITS(type)    ((size_t)CHAR_BIT * sizeof(type))
  |  |  ------------------
  |  |               #define MP_MAXFAST              (int)(1uL << (MP_SIZEOF_BITS(mp_word) - (2u * (size_t)MP_DIGIT_BIT)))
  |  |  ------------------
  |  |  |  |   82|  26.3k|#   define MP_DIGIT_BIT 60
  |  |  ------------------
  ------------------
  |  Branch (25:11): [True: 26.3k, False: 0]
  ------------------
   26|  26.3k|      return s_mp_mul_high_digs_fast(a, b, c, digs);
   27|  26.3k|   }
   28|       |
   29|      0|   if ((err = mp_init_size(&t, a->used + b->used + 1)) != MP_OKAY) {
  ------------------
  |  |  161|      0|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (29:8): [True: 0, False: 0]
  ------------------
   30|      0|      return err;
   31|      0|   }
   32|      0|   t.used = a->used + b->used + 1;
   33|       |
   34|      0|   pa = a->used;
   35|      0|   pb = b->used;
   36|      0|   for (ix = 0; ix < pa; ix++) {
  ------------------
  |  Branch (36:17): [True: 0, False: 0]
  ------------------
   37|       |      /* clear the carry */
   38|      0|      u = 0;
   39|       |
   40|       |      /* left hand side of A[ix] * B[iy] */
   41|      0|      tmpx = a->dp[ix];
   42|       |
   43|       |      /* alias to the address of where the digits will be stored */
   44|      0|      tmpt = &(t.dp[digs]);
   45|       |
   46|       |      /* alias for where to read the right hand side from */
   47|      0|      tmpy = b->dp + (digs - ix);
   48|       |
   49|      0|      for (iy = digs - ix; iy < pb; iy++) {
  ------------------
  |  Branch (49:28): [True: 0, False: 0]
  ------------------
   50|       |         /* calculate the double precision result */
   51|      0|         r       = (mp_word)*tmpt +
   52|      0|                   ((mp_word)tmpx * (mp_word)*tmpy++) +
   53|      0|                   (mp_word)u;
   54|       |
   55|       |         /* get the lower part */
   56|      0|         *tmpt++ = (mp_digit)(r & (mp_word)MP_MASK);
  ------------------
  |  |  106|      0|#define MP_MASK          ((((mp_digit)1)<<((mp_digit)MP_DIGIT_BIT))-((mp_digit)1))
  |  |  ------------------
  |  |  |  |   82|      0|#   define MP_DIGIT_BIT 60
  |  |  ------------------
  ------------------
   57|       |
   58|       |         /* carry the carry */
   59|      0|         u       = (mp_digit)(r >> (mp_word)MP_DIGIT_BIT);
  ------------------
  |  |   82|      0|#   define MP_DIGIT_BIT 60
  ------------------
   60|      0|      }
   61|      0|      *tmpt = u;
   62|      0|   }
   63|      0|   mp_clamp(&t);
   64|      0|   mp_exch(&t, c);
   65|      0|   mp_clear(&t);
   66|      0|   return MP_OKAY;
  ------------------
  |  |  161|      0|#define MP_OKAY       0   /* no error */
  ------------------
   67|      0|}

s_mp_mul_high_digs_fast:
   16|  26.3k|{
   17|  26.3k|   int     olduse, pa, ix, iz;
   18|  26.3k|   mp_err   err;
   19|  26.3k|   mp_digit W[MP_WARRAY];
   20|  26.3k|   mp_word  _W;
   21|       |
   22|  26.3k|   if (digs < 0) {
  ------------------
  |  Branch (22:8): [True: 0, False: 26.3k]
  ------------------
   23|      0|      return MP_VAL;
  ------------------
  |  |  164|      0|#define MP_VAL        -3  /* invalid input */
  ------------------
   24|      0|   }
   25|       |
   26|       |   /* grow the destination as required */
   27|  26.3k|   pa = a->used + b->used;
   28|  26.3k|   if (c->alloc < pa) {
  ------------------
  |  Branch (28:8): [True: 26.3k, False: 0]
  ------------------
   29|  26.3k|      if ((err = mp_grow(c, pa)) != MP_OKAY) {
  ------------------
  |  |  161|  26.3k|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (29:11): [True: 0, False: 26.3k]
  ------------------
   30|      0|         return err;
   31|      0|      }
   32|  26.3k|   }
   33|       |
   34|       |   /* number of output digits to produce */
   35|  26.3k|   pa = a->used + b->used;
   36|  26.3k|   _W = 0;
   37|   271k|   for (ix = digs; ix < pa; ix++) {
  ------------------
  |  Branch (37:20): [True: 244k, False: 26.3k]
  ------------------
   38|   244k|      int      tx, ty, iy;
   39|   244k|      mp_digit *tmpx, *tmpy;
   40|       |
   41|       |      /* get offsets into the two bignums */
   42|   244k|      ty = MP_MIN(b->used-1, ix);
  ------------------
  |  |  156|   244k|#define MP_MIN(x, y) (((x) < (y)) ? (x) : (y))
  |  |  ------------------
  |  |  |  Branch (156:23): [True: 218k, False: 26.3k]
  |  |  ------------------
  ------------------
   43|   244k|      tx = ix - ty;
   44|       |
   45|       |      /* setup temp aliases */
   46|   244k|      tmpx = a->dp + tx;
   47|   244k|      tmpy = b->dp + ty;
   48|       |
   49|       |      /* this is the number of times the loop will iterrate, essentially its
   50|       |         while (tx++ < a->used && ty-- >= 0) { ... }
   51|       |       */
   52|   244k|      iy = MP_MIN(a->used-tx, ty+1);
  ------------------
  |  |  156|   244k|#define MP_MIN(x, y) (((x) < (y)) ? (x) : (y))
  |  |  ------------------
  |  |  |  Branch (156:23): [True: 244k, False: 361]
  |  |  ------------------
  ------------------
   53|       |
   54|       |      /* execute loop */
   55|  2.29M|      for (iz = 0; iz < iy; iz++) {
  ------------------
  |  Branch (55:20): [True: 2.05M, False: 244k]
  ------------------
   56|  2.05M|         _W += (mp_word)*tmpx++ * (mp_word)*tmpy--;
   57|  2.05M|      }
   58|       |
   59|       |      /* store term */
   60|   244k|      W[ix] = (mp_digit)_W & MP_MASK;
  ------------------
  |  |  106|   244k|#define MP_MASK          ((((mp_digit)1)<<((mp_digit)MP_DIGIT_BIT))-((mp_digit)1))
  |  |  ------------------
  |  |  |  |   82|   244k|#   define MP_DIGIT_BIT 60
  |  |  ------------------
  ------------------
   61|       |
   62|       |      /* make next carry */
   63|   244k|      _W = _W >> (mp_word)MP_DIGIT_BIT;
  ------------------
  |  |   82|   244k|#   define MP_DIGIT_BIT 60
  ------------------
   64|   244k|   }
   65|       |
   66|       |   /* setup dest */
   67|  26.3k|   olduse  = c->used;
   68|  26.3k|   c->used = pa;
   69|       |
   70|  26.3k|   {
   71|  26.3k|      mp_digit *tmpc;
   72|       |
   73|  26.3k|      tmpc = c->dp + digs;
   74|   271k|      for (ix = digs; ix < pa; ix++) {
  ------------------
  |  Branch (74:23): [True: 244k, False: 26.3k]
  ------------------
   75|       |         /* now extract the previous digit [below the carry] */
   76|   244k|         *tmpc++ = W[ix];
   77|   244k|      }
   78|       |
   79|       |      /* clear unused digits [that existed in the old copy of c] */
   80|  26.3k|      MP_ZERO_DIGITS(tmpc, olduse - ix);
  ------------------
  |  |   89|  26.3k|#  define MP_ZERO_DIGITS(mem, digits)                   \
  |  |   90|  26.3k|do {                                                    \
  |  |   91|  26.3k|   int zd_ = (digits);                                  \
  |  |   92|  26.3k|   mp_digit* zm_ = (mem);                               \
  |  |   93|  26.3k|   while (zd_-- > 0) {                                  \
  |  |  ------------------
  |  |  |  Branch (93:11): [True: 0, False: 26.3k]
  |  |  ------------------
  |  |   94|      0|      *zm_++ = 0;                                       \
  |  |   95|      0|   }                                                    \
  |  |   96|  26.3k|} while (0)
  |  |  ------------------
  |  |  |  Branch (96:10): [Folded, False: 26.3k]
  |  |  ------------------
  ------------------
   81|  26.3k|   }
   82|  26.3k|   mp_clamp(c);
   83|  26.3k|   return MP_OKAY;
  ------------------
  |  |  161|  26.3k|#define MP_OKAY       0   /* no error */
  ------------------
   84|  26.3k|}

s_mp_sqr_fast:
   17|  7.76M|{
   18|  7.76M|   int       olduse, pa, ix, iz;
   19|  7.76M|   mp_digit  W[MP_WARRAY], *tmpx;
   20|  7.76M|   mp_word   W1;
   21|  7.76M|   mp_err    err;
   22|       |
   23|       |   /* grow the destination as required */
   24|  7.76M|   pa = a->used + a->used;
   25|  7.76M|   if (b->alloc < pa) {
  ------------------
  |  Branch (25:8): [True: 5.80k, False: 7.76M]
  ------------------
   26|  5.80k|      if ((err = mp_grow(b, pa)) != MP_OKAY) {
  ------------------
  |  |  161|  5.80k|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (26:11): [True: 0, False: 5.80k]
  ------------------
   27|      0|         return err;
   28|      0|      }
   29|  5.80k|   }
   30|       |
   31|       |   /* number of output digits to produce */
   32|  7.76M|   W1 = 0;
   33|   364M|   for (ix = 0; ix < pa; ix++) {
  ------------------
  |  Branch (33:17): [True: 357M, False: 7.76M]
  ------------------
   34|   357M|      int      tx, ty, iy;
   35|   357M|      mp_word  _W;
   36|   357M|      mp_digit *tmpy;
   37|       |
   38|       |      /* clear counter */
   39|   357M|      _W = 0;
   40|       |
   41|       |      /* get offsets into the two bignums */
   42|   357M|      ty = MP_MIN(a->used-1, ix);
  ------------------
  |  |  156|   357M|#define MP_MIN(x, y) (((x) < (y)) ? (x) : (y))
  |  |  ------------------
  |  |  |  Branch (156:23): [True: 178M, False: 178M]
  |  |  ------------------
  ------------------
   43|   357M|      tx = ix - ty;
   44|       |
   45|       |      /* setup temp aliases */
   46|   357M|      tmpx = a->dp + tx;
   47|   357M|      tmpy = a->dp + ty;
   48|       |
   49|       |      /* this is the number of times the loop will iterrate, essentially
   50|       |         while (tx++ < a->used && ty-- >= 0) { ... }
   51|       |       */
   52|   357M|      iy = MP_MIN(a->used-tx, ty+1);
  ------------------
  |  |  156|   357M|#define MP_MIN(x, y) (((x) < (y)) ? (x) : (y))
  |  |  ------------------
  |  |  |  Branch (156:23): [True: 178M, False: 178M]
  |  |  ------------------
  ------------------
   53|       |
   54|       |      /* now for squaring tx can never equal ty
   55|       |       * we halve the distance since they approach at a rate of 2x
   56|       |       * and we have to round because odd cases need to be executed
   57|       |       */
   58|   357M|      iy = MP_MIN(iy, ((ty-tx)+1)>>1);
  ------------------
  |  |  156|   357M|#define MP_MIN(x, y) (((x) < (y)) ? (x) : (y))
  |  |  ------------------
  |  |  |  Branch (156:23): [True: 0, False: 357M]
  |  |  ------------------
  ------------------
   59|       |
   60|       |      /* execute loop */
   61|  3.00G|      for (iz = 0; iz < iy; iz++) {
  ------------------
  |  Branch (61:20): [True: 2.64G, False: 357M]
  ------------------
   62|  2.64G|         _W += (mp_word)*tmpx++ * (mp_word)*tmpy--;
   63|  2.64G|      }
   64|       |
   65|       |      /* double the inner product and add carry */
   66|   357M|      _W = _W + _W + W1;
   67|       |
   68|       |      /* even columns have the square term in them */
   69|   357M|      if (((unsigned)ix & 1u) == 0u) {
  ------------------
  |  Branch (69:11): [True: 178M, False: 178M]
  ------------------
   70|   178M|         _W += (mp_word)a->dp[ix>>1] * (mp_word)a->dp[ix>>1];
   71|   178M|      }
   72|       |
   73|       |      /* store it */
   74|   357M|      W[ix] = (mp_digit)_W & MP_MASK;
  ------------------
  |  |  106|   357M|#define MP_MASK          ((((mp_digit)1)<<((mp_digit)MP_DIGIT_BIT))-((mp_digit)1))
  |  |  ------------------
  |  |  |  |   82|   357M|#   define MP_DIGIT_BIT 60
  |  |  ------------------
  ------------------
   75|       |
   76|       |      /* make next carry */
   77|   357M|      W1 = _W >> (mp_word)MP_DIGIT_BIT;
  ------------------
  |  |   82|   357M|#   define MP_DIGIT_BIT 60
  ------------------
   78|   357M|   }
   79|       |
   80|       |   /* setup dest */
   81|  7.76M|   olduse  = b->used;
   82|  7.76M|   b->used = a->used+a->used;
   83|       |
   84|  7.76M|   {
   85|  7.76M|      mp_digit *tmpb;
   86|  7.76M|      tmpb = b->dp;
   87|   364M|      for (ix = 0; ix < pa; ix++) {
  ------------------
  |  Branch (87:20): [True: 357M, False: 7.76M]
  ------------------
   88|   357M|         *tmpb++ = W[ix] & MP_MASK;
  ------------------
  |  |  106|   357M|#define MP_MASK          ((((mp_digit)1)<<((mp_digit)MP_DIGIT_BIT))-((mp_digit)1))
  |  |  ------------------
  |  |  |  |   82|   357M|#   define MP_DIGIT_BIT 60
  |  |  ------------------
  ------------------
   89|   357M|      }
   90|       |
   91|       |      /* clear unused digits [that existed in the old copy of c] */
   92|  7.76M|      MP_ZERO_DIGITS(tmpb, olduse - ix);
  ------------------
  |  |   89|  7.76M|#  define MP_ZERO_DIGITS(mem, digits)                   \
  |  |   90|  7.76M|do {                                                    \
  |  |   91|  7.76M|   int zd_ = (digits);                                  \
  |  |   92|  7.76M|   mp_digit* zm_ = (mem);                               \
  |  |   93|  7.88M|   while (zd_-- > 0) {                                  \
  |  |  ------------------
  |  |  |  Branch (93:11): [True: 118k, False: 7.76M]
  |  |  ------------------
  |  |   94|   118k|      *zm_++ = 0;                                       \
  |  |   95|   118k|   }                                                    \
  |  |   96|  7.76M|} while (0)
  |  |  ------------------
  |  |  |  Branch (96:10): [Folded, False: 7.76M]
  |  |  ------------------
  ------------------
   93|  7.76M|   }
   94|  7.76M|   mp_clamp(b);
   95|  7.76M|   return MP_OKAY;
  ------------------
  |  |  161|  7.76M|#define MP_OKAY       0   /* no error */
  ------------------
   96|  7.76M|}

s_mp_sub:
    8|  15.3M|{
    9|  15.3M|   int    olduse, min, max;
   10|  15.3M|   mp_err err;
   11|       |
   12|       |   /* find sizes */
   13|  15.3M|   min = b->used;
   14|  15.3M|   max = a->used;
   15|       |
   16|       |   /* init result */
   17|  15.3M|   if (c->alloc < max) {
  ------------------
  |  Branch (17:8): [True: 0, False: 15.3M]
  ------------------
   18|      0|      if ((err = mp_grow(c, max)) != MP_OKAY) {
  ------------------
  |  |  161|      0|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (18:11): [True: 0, False: 0]
  ------------------
   19|      0|         return err;
   20|      0|      }
   21|      0|   }
   22|  15.3M|   olduse = c->used;
   23|  15.3M|   c->used = max;
   24|       |
   25|  15.3M|   {
   26|  15.3M|      mp_digit u, *tmpa, *tmpb, *tmpc;
   27|  15.3M|      int i;
   28|       |
   29|       |      /* alias for digit pointers */
   30|  15.3M|      tmpa = a->dp;
   31|  15.3M|      tmpb = b->dp;
   32|  15.3M|      tmpc = c->dp;
   33|       |
   34|       |      /* set carry to zero */
   35|  15.3M|      u = 0;
   36|   193M|      for (i = 0; i < min; i++) {
  ------------------
  |  Branch (36:19): [True: 178M, False: 15.3M]
  ------------------
   37|       |         /* T[i] = A[i] - B[i] - U */
   38|   178M|         *tmpc = (*tmpa++ - *tmpb++) - u;
   39|       |
   40|       |         /* U = carry bit of T[i]
   41|       |          * Note this saves performing an AND operation since
   42|       |          * if a carry does occur it will propagate all the way to the
   43|       |          * MSB.  As a result a single shift is enough to get the carry
   44|       |          */
   45|   178M|         u = *tmpc >> (MP_SIZEOF_BITS(mp_digit) - 1u);
  ------------------
  |  |  167|   178M|#define MP_SIZEOF_BITS(type)    ((size_t)CHAR_BIT * sizeof(type))
  ------------------
   46|       |
   47|       |         /* Clear carry from T[i] */
   48|   178M|         *tmpc++ &= MP_MASK;
  ------------------
  |  |  106|   178M|#define MP_MASK          ((((mp_digit)1)<<((mp_digit)MP_DIGIT_BIT))-((mp_digit)1))
  |  |  ------------------
  |  |  |  |   82|   178M|#   define MP_DIGIT_BIT 60
  |  |  ------------------
  ------------------
   49|   178M|      }
   50|       |
   51|       |      /* now copy higher words if any, e.g. if A has more digits than B  */
   52|  56.5M|      for (; i < max; i++) {
  ------------------
  |  Branch (52:14): [True: 41.1M, False: 15.3M]
  ------------------
   53|       |         /* T[i] = A[i] - U */
   54|  41.1M|         *tmpc = *tmpa++ - u;
   55|       |
   56|       |         /* U = carry bit of T[i] */
   57|  41.1M|         u = *tmpc >> (MP_SIZEOF_BITS(mp_digit) - 1u);
  ------------------
  |  |  167|  41.1M|#define MP_SIZEOF_BITS(type)    ((size_t)CHAR_BIT * sizeof(type))
  ------------------
   58|       |
   59|       |         /* Clear carry from T[i] */
   60|  41.1M|         *tmpc++ &= MP_MASK;
  ------------------
  |  |  106|  41.1M|#define MP_MASK          ((((mp_digit)1)<<((mp_digit)MP_DIGIT_BIT))-((mp_digit)1))
  |  |  ------------------
  |  |  |  |   82|  41.1M|#   define MP_DIGIT_BIT 60
  |  |  ------------------
  ------------------
   61|  41.1M|      }
   62|       |
   63|       |      /* clear digits above used (since we may not have grown result above) */
   64|  15.3M|      MP_ZERO_DIGITS(tmpc, olduse - c->used);
  ------------------
  |  |   89|  15.3M|#  define MP_ZERO_DIGITS(mem, digits)                   \
  |  |   90|  15.3M|do {                                                    \
  |  |   91|  15.3M|   int zd_ = (digits);                                  \
  |  |   92|  15.3M|   mp_digit* zm_ = (mem);                               \
  |  |   93|  15.3M|   while (zd_-- > 0) {                                  \
  |  |  ------------------
  |  |  |  Branch (93:11): [True: 19, False: 15.3M]
  |  |  ------------------
  |  |   94|     19|      *zm_++ = 0;                                       \
  |  |   95|     19|   }                                                    \
  |  |   96|  15.3M|} while (0)
  |  |  ------------------
  |  |  |  Branch (96:10): [Folded, False: 15.3M]
  |  |  ------------------
  ------------------
   65|  15.3M|   }
   66|       |
   67|  15.3M|   mp_clamp(c);
   68|  15.3M|   return MP_OKAY;
  ------------------
  |  |  161|  15.3M|#define MP_OKAY       0   /* no error */
  ------------------
   69|  15.3M|}

m_mp_init:
   31|  1.15k|void m_mp_init(mp_int *mp) {
   32|       |
   33|  1.15k|	if (mp_init(mp) != MP_OKAY) {
  ------------------
  |  |  161|  1.15k|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (33:6): [True: 0, False: 1.15k]
  ------------------
   34|      0|		dropbear_exit("Mem alloc error");
   35|      0|	}
   36|  1.15k|}
m_mp_init_multi:
   41|  2.83k|{
   42|  2.83k|	mp_int* cur_arg = mp;
   43|  2.83k|	va_list args;
   44|       |
   45|  2.83k|	va_start(args, mp);        /* init args to next argument from caller */
   46|  12.6k|	while (cur_arg != NULL) {
  ------------------
  |  Branch (46:9): [True: 9.80k, False: 2.83k]
  ------------------
   47|  9.80k|		if (mp_init(cur_arg) != MP_OKAY) {
  ------------------
  |  |  161|  9.80k|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (47:7): [True: 0, False: 9.80k]
  ------------------
   48|      0|			dropbear_exit("Mem alloc error");
   49|      0|		}
   50|  9.80k|		cur_arg = va_arg(args, mp_int*);
   51|  9.80k|	}
   52|  2.83k|	va_end(args);
   53|  2.83k|}
m_mp_alloc_init_multi:
   56|  2.83k|{
   57|  2.83k|	mp_int** cur_arg = mp;
   58|  2.83k|	va_list args;
   59|       |
   60|  2.83k|	va_start(args, mp);        /* init args to next argument from caller */
   61|  8.53k|	while (cur_arg != NULL) {
  ------------------
  |  Branch (61:9): [True: 5.70k, False: 2.83k]
  ------------------
   62|  5.70k|		*cur_arg = m_malloc(sizeof(mp_int));
   63|  5.70k|		if (mp_init(*cur_arg) != MP_OKAY) {
  ------------------
  |  |  161|  5.70k|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (63:7): [True: 0, False: 5.70k]
  ------------------
   64|      0|			dropbear_exit("Mem alloc error");
   65|      0|		}
   66|  5.70k|		cur_arg = va_arg(args, mp_int**);
   67|  5.70k|	}
   68|  2.83k|	va_end(args);
   69|  2.83k|}
m_mp_free_multi:
   72|    290|{
   73|    290|	mp_int** cur_arg = mp;
   74|    290|	va_list args;
   75|       |
   76|    290|	va_start(args, mp);        /* init args to next argument from caller */
   77|  1.48k|	while (cur_arg != NULL) {
  ------------------
  |  Branch (77:9): [True: 1.19k, False: 290]
  ------------------
   78|  1.19k|		if (*cur_arg) {
  ------------------
  |  Branch (78:7): [True: 468, False: 725]
  ------------------
   79|    468|			mp_clear(*cur_arg);
   80|    468|		}
   81|  1.19k|		m_free(*cur_arg);
  ------------------
  |  |   24|  1.19k|#define m_free(X) do {m_free_direct(X); (X) = NULL;} while (0)
  |  |  ------------------
  |  |  |  Branch (24:61): [Folded, False: 1.19k]
  |  |  ------------------
  ------------------
   82|  1.19k|		cur_arg = va_arg(args, mp_int**);
   83|  1.19k|	}
   84|       |	va_end(args);
   85|    290|}
bytes_to_mp:
   87|  4.26k|void bytes_to_mp(mp_int *mp, const unsigned char* bytes, unsigned int len) {
   88|       |
   89|  4.26k|	if (mp_from_ubin(mp, (unsigned char*)bytes, len) != MP_OKAY) {
  ------------------
  |  |  161|  4.26k|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (89:6): [True: 0, False: 4.26k]
  ------------------
   90|      0|		dropbear_exit("Mem alloc error");
   91|      0|	}
   92|  4.26k|}

buf_new:
   41|  71.4k|buffer* buf_new(unsigned int size) {
   42|  71.4k|	buffer* buf;
   43|  71.4k|	if (size > BUF_MAX_SIZE) {
  ------------------
  |  |   35|  71.4k|#define BUF_MAX_SIZE 1000000000
  ------------------
  |  Branch (43:6): [True: 0, False: 71.4k]
  ------------------
   44|      0|		dropbear_exit("buf->size too big");
   45|      0|	}
   46|       |
   47|  71.4k|	buf = (buffer*)m_malloc(sizeof(buffer)+size);
   48|  71.4k|	buf->data = (unsigned char*)buf + sizeof(buffer);
   49|  71.4k|	buf->size = size;
   50|  71.4k|	return buf;
   51|  71.4k|}
buf_free:
   54|  50.9k|void buf_free(buffer* buf) {
   55|       |	m_free(buf);
  ------------------
  |  |   24|  50.9k|#define m_free(X) do {m_free_direct(X); (X) = NULL;} while (0)
  |  |  ------------------
  |  |  |  Branch (24:61): [Folded, False: 50.9k]
  |  |  ------------------
  ------------------
   56|  50.9k|}
buf_burn_free:
   59|  15.6k|void buf_burn_free(buffer* buf) {
   60|  15.6k|	m_burn(buf->data, buf->size);
   61|       |	m_free(buf);
  ------------------
  |  |   24|  15.6k|#define m_free(X) do {m_free_direct(X); (X) = NULL;} while (0)
  |  |  ------------------
  |  |  |  Branch (24:61): [Folded, False: 15.6k]
  |  |  ------------------
  ------------------
   62|  15.6k|}
buf_resize:
   67|  4.17k|buffer* buf_resize(buffer *buf, unsigned int newsize) {
   68|  4.17k|	if (newsize > BUF_MAX_SIZE) {
  ------------------
  |  |   35|  4.17k|#define BUF_MAX_SIZE 1000000000
  ------------------
  |  Branch (68:6): [True: 0, False: 4.17k]
  ------------------
   69|      0|		dropbear_exit("buf->size too big");
   70|      0|	}
   71|       |
   72|  4.17k|	buf = m_realloc(buf, sizeof(buffer)+newsize);
   73|  4.17k|	buf->data = (unsigned char*)buf + sizeof(buffer);
   74|  4.17k|	buf->size = newsize;
   75|  4.17k|	buf->len = MIN(newsize, buf->len);
  ------------------
  |  Branch (75:13): [True: 0, False: 4.17k]
  ------------------
   76|       |	buf->pos = MIN(newsize, buf->pos);
  ------------------
  |  Branch (76:13): [True: 0, False: 4.17k]
  ------------------
   77|  4.17k|	return buf;
   78|  4.17k|}
buf_newcopy:
   82|  5.26k|buffer* buf_newcopy(const buffer* buf) {
   83|       |	
   84|  5.26k|	buffer* ret;
   85|       |
   86|  5.26k|	ret = buf_new(buf->len);
   87|  5.26k|	ret->len = buf->len;
   88|  5.26k|	if (buf->len > 0) {
  ------------------
  |  Branch (88:6): [True: 5.26k, False: 0]
  ------------------
   89|  5.26k|		memcpy(ret->data, buf->data, buf->len);
   90|  5.26k|	}
   91|  5.26k|	return ret;
   92|  5.26k|}
buf_setlen:
   95|  87.4k|void buf_setlen(buffer* buf, unsigned int len) {
   96|  87.4k|	if (len > buf->size) {
  ------------------
  |  Branch (96:6): [True: 0, False: 87.4k]
  ------------------
   97|      0|		dropbear_exit("Bad buf_setlen");
   98|      0|	}
   99|  87.4k|	buf->len = len;
  100|       |	buf->pos = MIN(buf->pos, buf->len);
  ------------------
  |  Branch (100:13): [True: 63.5k, False: 23.8k]
  ------------------
  101|  87.4k|}
buf_incrlen:
  104|   186k|void buf_incrlen(buffer* buf, unsigned int incr) {
  105|   186k|	if (incr > BUF_MAX_INCR || buf->len + incr > buf->size) {
  ------------------
  |  |   34|   372k|#define BUF_MAX_INCR 1000000000
  ------------------
  |  Branch (105:6): [True: 0, False: 186k]
  |  Branch (105:29): [True: 0, False: 186k]
  ------------------
  106|      0|		dropbear_exit("Bad buf_incrlen");
  107|      0|	}
  108|   186k|	buf->len += incr;
  109|   186k|}
buf_setpos:
  111|   347k|void buf_setpos(buffer* buf, unsigned int pos) {
  112|       |
  113|   347k|	if (pos > buf->len) {
  ------------------
  |  Branch (113:6): [True: 0, False: 347k]
  ------------------
  114|      0|		dropbear_exit("Bad buf_setpos");
  115|      0|	}
  116|   347k|	buf->pos = pos;
  117|   347k|}
buf_incrwritepos:
  120|   412k|void buf_incrwritepos(buffer* buf, unsigned int incr) {
  121|   412k|	if (incr > BUF_MAX_INCR || buf->pos + incr > buf->size) {
  ------------------
  |  |   34|   824k|#define BUF_MAX_INCR 1000000000
  ------------------
  |  Branch (121:6): [True: 0, False: 412k]
  |  Branch (121:29): [True: 0, False: 412k]
  ------------------
  122|      0|		dropbear_exit("Bad buf_incrwritepos");
  123|      0|	}
  124|   412k|	buf->pos += incr;
  125|   412k|	if (buf->pos > buf->len) {
  ------------------
  |  Branch (125:6): [True: 304k, False: 108k]
  ------------------
  126|   304k|		buf->len = buf->pos;
  127|   304k|	}
  128|   412k|}
buf_incrpos:
  131|   359k|void buf_incrpos(buffer* buf, unsigned int incr) {
  132|   359k|	if (incr > BUF_MAX_INCR 
  ------------------
  |  |   34|   719k|#define BUF_MAX_INCR 1000000000
  ------------------
  |  Branch (132:6): [True: 10, False: 359k]
  ------------------
  133|   359k|		|| (buf->pos + incr) > buf->len) {
  ------------------
  |  Branch (133:6): [True: 86, False: 359k]
  ------------------
  134|     96|		dropbear_exit("Bad buf_incrpos");
  135|     96|	}
  136|   359k|	buf->pos += incr;
  137|   359k|}
buf_decrpos:
  140|  1.78k|void buf_decrpos(buffer* buf, unsigned int decr) {
  141|  1.78k|	if (decr > buf->pos) {
  ------------------
  |  Branch (141:6): [True: 0, False: 1.78k]
  ------------------
  142|      0|		dropbear_exit("Bad buf_decrpos");
  143|      0|	}
  144|  1.78k|	buf->pos -= decr;
  145|  1.78k|}
buf_getbyte:
  148|  65.1k|unsigned char buf_getbyte(buffer* buf) {
  149|       |
  150|       |	/* This check is really just ==, but the >= allows us to check for the
  151|       |	 * bad case of pos > len, which should _never_ happen. */
  152|  65.1k|	if (buf->pos >= buf->len) {
  ------------------
  |  Branch (152:6): [True: 5, False: 65.1k]
  ------------------
  153|      5|		dropbear_exit("Bad buf_getbyte");
  154|      5|	}
  155|  65.1k|	return buf->data[buf->pos++];
  156|  65.1k|}
buf_getbool:
  159|  2.39k|unsigned char buf_getbool(buffer* buf) {
  160|       |
  161|  2.39k|	unsigned char b;
  162|  2.39k|	b = buf_getbyte(buf);
  163|  2.39k|	if (b != 0)
  ------------------
  |  Branch (163:6): [True: 174, False: 2.21k]
  ------------------
  164|    174|		b = 1;
  165|  2.39k|	return b;
  166|  2.39k|}
buf_putbyte:
  169|   185k|void buf_putbyte(buffer* buf, unsigned char val) {
  170|       |
  171|   185k|	if (buf->pos >= buf->len) {
  ------------------
  |  Branch (171:6): [True: 162k, False: 23.3k]
  ------------------
  172|   162k|		buf_incrlen(buf, 1);
  173|   162k|	}
  174|   185k|	buf->data[buf->pos] = val;
  175|   185k|	buf->pos++;
  176|   185k|}
buf_getptr:
  180|   464k|unsigned char* buf_getptr(const buffer* buf, unsigned int len) {
  181|       |
  182|   464k|	if (len > BUF_MAX_INCR || buf->pos + len > buf->len) {
  ------------------
  |  |   34|   929k|#define BUF_MAX_INCR 1000000000
  ------------------
  |  Branch (182:6): [True: 7, False: 464k]
  |  Branch (182:28): [True: 529, False: 464k]
  ------------------
  183|    536|		dropbear_exit("Bad buf_getptr");
  184|    536|	}
  185|   464k|	return &buf->data[buf->pos];
  186|   464k|}
buf_getwriteptr:
  190|   449k|unsigned char* buf_getwriteptr(const buffer* buf, unsigned int len) {
  191|       |
  192|   449k|	if (len > BUF_MAX_INCR || buf->pos + len > buf->size) {
  ------------------
  |  |   34|   899k|#define BUF_MAX_INCR 1000000000
  ------------------
  |  Branch (192:6): [True: 0, False: 449k]
  |  Branch (192:28): [True: 9, False: 449k]
  ------------------
  193|      9|		dropbear_exit("Bad buf_getwriteptr");
  194|      9|	}
  195|   449k|	return &buf->data[buf->pos];
  196|   449k|}
buf_getstring:
  201|  26.8k|char* buf_getstring(buffer* buf, unsigned int *retlen) {
  202|       |
  203|  26.8k|	unsigned int len;
  204|  26.8k|	char* ret;
  205|  26.8k|	void* src = NULL;
  206|  26.8k|	len = buf_getint(buf);
  207|  26.8k|	if (len > MAX_STRING_LEN) {
  ------------------
  |  |  259|  26.8k|#define MAX_STRING_LEN (MAX(MAX_CMD_LEN, 2400)) /* Sun SSH needs 2400 for algos,
  ------------------
  |  Branch (207:6): [True: 63, False: 26.8k]
  |  Branch (207:12): [True: 26.7k, Folded]
  ------------------
  208|     63|		dropbear_exit("String too long");
  209|     63|	}
  210|       |
  211|  26.8k|	if (retlen != NULL) {
  ------------------
  |  Branch (211:6): [True: 26.7k, False: 118]
  ------------------
  212|  26.7k|		*retlen = len;
  213|  26.7k|	}
  214|  26.8k|	src = buf_getptr(buf, len);
  215|  26.8k|	ret = m_malloc(len+1);
  216|  26.8k|	memcpy(ret, src, len);
  217|  26.8k|	buf_incrpos(buf, len);
  218|  26.8k|	ret[len] = '\0';
  219|       |
  220|  26.8k|	return ret;
  221|  26.8k|}
buf_getstringbuf:
  246|    622|buffer * buf_getstringbuf(buffer *buf) {
  247|    622|	return buf_getstringbuf_int(buf, 0);
  248|    622|}
buf_getptrcopy:
  256|     57|buffer * buf_getptrcopy(const buffer* buf, unsigned int len) {
  257|     57|	unsigned char *src = buf_getptr(buf, len);
  258|     57|	buffer *ret = buf_new(len);
  259|     57|	buf_putbytes(ret, src, len);
  260|     57|	buf_setpos(ret, 0);
  261|     57|	return ret;
  262|     57|}
buf_eatstring:
  266|  4.89k|void buf_eatstring(buffer *buf) {
  267|       |
  268|  4.89k|	buf_incrpos( buf, buf_getint(buf) );
  269|  4.89k|}
buf_getint:
  272|  62.8k|unsigned int buf_getint(buffer* buf) {
  273|  62.8k|	unsigned int ret;
  274|       |
  275|  62.8k|	LOAD32H(ret, buf_getptr(buf, 4));
  ------------------
  |  |   66|  62.8k|#define LOAD32H(x, y)                           \
  |  |   67|  62.8k|do { XMEMCPY (&(x), (y), 4);                    \
  |  |  ------------------
  |  |  |  |   39|  62.8k|#define XMEMCPY  memcpy
  |  |  ------------------
  |  |   68|  62.8k|      (x) = __builtin_bswap32 ((x)); } while(0)
  |  |  ------------------
  |  |  |  Branch (68:46): [Folded, False: 62.8k]
  |  |  ------------------
  ------------------
  276|  62.8k|	buf_incrpos(buf, 4);
  277|  62.8k|	return ret;
  278|  62.8k|}
buf_putint:
  281|   128k|void buf_putint(buffer* buf, int unsigned val) {
  282|       |
  283|   128k|	STORE32H(val, buf_getwriteptr(buf, 4));
  ------------------
  |  |   62|   128k|#define STORE32H(x, y)                          \
  |  |   63|   128k|do { ulong32 __t = __builtin_bswap32 ((x));     \
  |  |   64|   128k|      XMEMCPY ((y), &__t, 4); } while(0)
  |  |  ------------------
  |  |  |  |   39|   128k|#define XMEMCPY  memcpy
  |  |  ------------------
  |  |  |  Branch (64:39): [Folded, False: 128k]
  |  |  ------------------
  ------------------
  284|   128k|	buf_incrwritepos(buf, 4);
  285|       |
  286|   128k|}
buf_putstring:
  289|  24.9k|void buf_putstring(buffer* buf, const char* str, unsigned int len) {
  290|       |	
  291|  24.9k|	buf_putint(buf, len);
  292|  24.9k|	buf_putbytes(buf, (const unsigned char*)str, len);
  293|       |
  294|  24.9k|}
buf_putbufstring:
  297|  4.97k|void buf_putbufstring(buffer *buf, const buffer* buf_str) {
  298|  4.97k|	buf_putstring(buf, (const char*)buf_str->data, buf_str->len);
  299|  4.97k|}
buf_putbytes:
  303|   161k|void buf_putbytes(buffer *buf, const unsigned char *bytes, unsigned int len) {
  304|   161k|	memcpy(buf_getwriteptr(buf, len), bytes, len);
  305|   161k|	buf_incrwritepos(buf, len);
  306|   161k|}
buf_putmpint:
  311|  6.58k|void buf_putmpint(buffer* buf, const mp_int * mp) {
  312|  6.58k|	size_t written;
  313|  6.58k|	unsigned int len, pad = 0;
  314|  6.58k|	TRACE2(("enter buf_putmpint"))
  315|       |
  316|  6.58k|	dropbear_assert(mp != NULL);
  ------------------
  |  |   86|  6.58k|#define dropbear_assert(X) do { if (!(X)) { fail_assert(#X, __FILE__, __LINE__); } } while (0)
  |  |  ------------------
  |  |  |  Branch (86:37): [True: 0, False: 6.58k]
  |  |  |  Branch (86:93): [Folded, False: 6.58k]
  |  |  ------------------
  ------------------
  317|       |
  318|  6.58k|	if (mp_isneg(mp)) {
  ------------------
  |  |  295|  6.58k|#define mp_isneg(a)  (((a)->sign != MP_ZPOS) ? MP_YES : MP_NO)
  |  |  ------------------
  |  |  |  |  151|  6.58k|#define MP_ZPOS       0   /* positive integer */
  |  |  ------------------
  |  |               #define mp_isneg(a)  (((a)->sign != MP_ZPOS) ? MP_YES : MP_NO)
  |  |  ------------------
  |  |  |  |  158|      0|#define MP_YES        1
  |  |  ------------------
  |  |               #define mp_isneg(a)  (((a)->sign != MP_ZPOS) ? MP_YES : MP_NO)
  |  |  ------------------
  |  |  |  |  159|  6.58k|#define MP_NO         0
  |  |  ------------------
  |  |  |  Branch (295:22): [True: 0, False: 6.58k]
  |  |  |  Branch (295:23): [True: 0, False: 6.58k]
  |  |  ------------------
  ------------------
  319|      0|		dropbear_exit("negative bignum");
  320|      0|	}
  321|       |
  322|       |	/* zero check */
  323|  6.58k|	if (mp_iszero(mp)) {
  ------------------
  |  |  292|  6.58k|#define mp_iszero(a) (((a)->used == 0) ? MP_YES : MP_NO)
  |  |  ------------------
  |  |  |  |  158|    607|#define MP_YES        1
  |  |  ------------------
  |  |               #define mp_iszero(a) (((a)->used == 0) ? MP_YES : MP_NO)
  |  |  ------------------
  |  |  |  |  159|  5.98k|#define MP_NO         0
  |  |  ------------------
  |  |  |  Branch (292:22): [True: 607, False: 5.98k]
  |  |  |  Branch (292:23): [True: 607, False: 5.98k]
  |  |  ------------------
  ------------------
  324|    607|		len = 0;
  325|  5.98k|	} else {
  326|       |		/* SSH spec requires padding for mpints with the MSB set, this code
  327|       |		 * implements it */
  328|  5.98k|		len = mp_count_bits(mp);
  329|       |		/* if the top bit of MSB is set, we need to pad */
  330|  5.98k|		pad = (len%8 == 0) ? 1 : 0;
  ------------------
  |  Branch (330:9): [True: 2.25k, False: 3.73k]
  ------------------
  331|  5.98k|		len = len / 8 + 1; /* don't worry about rounding, we need it for
  332|       |							  padding anyway when len%8 == 0 */
  333|       |
  334|  5.98k|	}
  335|       |
  336|       |	/* store the length */
  337|  6.58k|	buf_putint(buf, len);
  338|       |	
  339|       |	/* store the actual value */
  340|  6.58k|	if (len > 0) {
  ------------------
  |  Branch (340:6): [True: 5.98k, False: 607]
  ------------------
  341|  5.98k|		if (pad) {
  ------------------
  |  Branch (341:7): [True: 2.25k, False: 3.73k]
  ------------------
  342|  2.25k|			buf_putbyte(buf, 0x00);
  343|  2.25k|		}
  344|  5.98k|		if (mp_to_ubin(mp, buf_getwriteptr(buf, len-pad), len-pad, &written) != MP_OKAY) {
  ------------------
  |  |  161|  5.98k|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (344:7): [True: 0, False: 5.98k]
  ------------------
  345|      0|			dropbear_exit("mpint error");
  346|      0|		}
  347|  5.98k|		buf_incrwritepos(buf, written);
  348|  5.98k|	}
  349|       |
  350|  6.58k|	TRACE2(("leave buf_putmpint"))
  351|  6.58k|}
buf_getmpint:
  356|  3.93k|int buf_getmpint(buffer* buf, mp_int* mp) {
  357|       |
  358|  3.93k|	unsigned int len;
  359|  3.93k|	len = buf_getint(buf);
  360|       |	
  361|  3.93k|	if (len == 0) {
  ------------------
  |  Branch (361:6): [True: 780, False: 3.15k]
  ------------------
  362|    780|		mp_zero(mp);
  363|    780|		return DROPBEAR_SUCCESS;
  ------------------
  |  |  111|    780|#define DROPBEAR_SUCCESS 0
  ------------------
  364|    780|	}
  365|       |
  366|  3.15k|	if (len > BUF_MAX_MPINT) {
  ------------------
  |  |   38|  3.15k|#define BUF_MAX_MPINT (8240 / 8)
  ------------------
  |  Branch (366:6): [True: 71, False: 3.08k]
  ------------------
  367|     71|		return DROPBEAR_FAILURE;
  ------------------
  |  |  112|     71|#define DROPBEAR_FAILURE -1
  ------------------
  368|     71|	}
  369|       |
  370|       |	/* check for negative */
  371|  3.08k|	if (*buf_getptr(buf, 1) & (1 << (CHAR_BIT-1))) {
  ------------------
  |  Branch (371:6): [True: 13, False: 3.07k]
  ------------------
  372|     13|		return DROPBEAR_FAILURE;
  ------------------
  |  |  112|     13|#define DROPBEAR_FAILURE -1
  ------------------
  373|     13|	}
  374|       |
  375|  3.07k|	if (mp_from_ubin(mp, buf_getptr(buf, len), len) != MP_OKAY) {
  ------------------
  |  |  161|  3.07k|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (375:6): [True: 0, False: 3.07k]
  ------------------
  376|      0|		return DROPBEAR_FAILURE;
  ------------------
  |  |  112|      0|#define DROPBEAR_FAILURE -1
  ------------------
  377|      0|	}
  378|       |
  379|  3.07k|	buf_incrpos(buf, len);
  380|  3.07k|	return DROPBEAR_SUCCESS;
  ------------------
  |  |  111|  3.07k|#define DROPBEAR_SUCCESS 0
  ------------------
  381|  3.07k|}
buffer.c:buf_getstringbuf_int:
  224|    622|static buffer * buf_getstringbuf_int(buffer *buf, int incllen) {
  225|    622|	buffer *ret = NULL;
  226|    622|	unsigned int len = buf_getint(buf);
  227|    622|	int extra = 0;
  228|    622|	if (len > MAX_STRING_LEN) {
  ------------------
  |  |  259|    622|#define MAX_STRING_LEN (MAX(MAX_CMD_LEN, 2400)) /* Sun SSH needs 2400 for algos,
  ------------------
  |  Branch (228:6): [True: 36, False: 586]
  |  Branch (228:12): [True: 608, Folded]
  ------------------
  229|     36|		dropbear_exit("String too long");
  230|     36|	}
  231|    586|	if (incllen) {
  ------------------
  |  Branch (231:6): [True: 0, False: 586]
  ------------------
  232|      0|		extra = 4;
  233|      0|	}
  234|    586|	ret = buf_new(len+extra);
  235|    586|	if (incllen) {
  ------------------
  |  Branch (235:6): [True: 0, False: 586]
  ------------------
  236|      0|		buf_putint(ret, len);
  237|      0|	}
  238|    586|	memcpy(buf_getwriteptr(ret, len), buf_getptr(buf, len), len);
  239|    586|	buf_incrpos(buf, len);
  240|    586|	buf_incrlen(ret, len);
  241|    586|	buf_setpos(ret, 0);
  242|    586|	return ret;
  243|    622|}

cli_auth_getmethods:
   36|    248|void cli_auth_getmethods() {
   37|    248|	TRACE(("enter cli_auth_getmethods"))
   38|    248|	CHECKCLEARTOWRITE();
   39|    248|	buf_putbyte(ses.writepayload, SSH_MSG_USERAUTH_REQUEST);
  ------------------
  |  |   42|    248|#define SSH_MSG_USERAUTH_REQUEST            50
  ------------------
   40|    248|	buf_putstring(ses.writepayload, cli_opts.username,
   41|    248|			strlen(cli_opts.username));
   42|    248|	buf_putstring(ses.writepayload, SSH_SERVICE_CONNECTION,
  ------------------
  |  |  110|    248|#define SSH_SERVICE_CONNECTION "ssh-connection"
  ------------------
   43|    248|			SSH_SERVICE_CONNECTION_LEN);
  ------------------
  |  |  111|    248|#define SSH_SERVICE_CONNECTION_LEN 14
  ------------------
   44|    248|	buf_putstring(ses.writepayload, "none", 4); /* 'none' method */
   45|       |
   46|    248|	encrypt_packet();
   47|       |
   48|       |#if DROPBEAR_CLI_IMMEDIATE_AUTH
   49|       |	/* We can't haven't two auth requests in-flight with delayed zlib mode
   50|       |	since if the first one succeeds then the remote side will 
   51|       |	expect the second one to be compressed. 
   52|       |	Race described at
   53|       |	http://www.chiark.greenend.org.uk/~sgtatham/putty/wishlist/zlib-openssh.html
   54|       |	*/
   55|       |	if (ses.keys->trans.algo_comp != DROPBEAR_COMP_ZLIB_DELAY) {
   56|       |		ses.authstate.authtypes = AUTH_TYPE_PUBKEY;
   57|       |#if DROPBEAR_USE_PASSWORD_ENV
   58|       |		if (getenv(DROPBEAR_PASSWORD_ENV)) {
   59|       |			ses.authstate.authtypes |= AUTH_TYPE_PASSWORD | AUTH_TYPE_INTERACT;
   60|       |		}
   61|       |#endif
   62|       |		if (cli_auth_try() == DROPBEAR_SUCCESS) {
   63|       |			TRACE(("skipped initial none auth query"))
   64|       |			/* Note that there will be two auth responses in-flight */
   65|       |			cli_ses.ignore_next_auth_response = 1;
   66|       |		}
   67|       |	}
   68|       |#endif
   69|    248|	TRACE(("leave cli_auth_getmethods"))
   70|    248|}

cli_tty_cleanup:
  135|  3.41k|void cli_tty_cleanup() {
  136|       |
  137|  3.41k|	TRACE(("enter cli_tty_cleanup"))
  138|       |
  139|  3.41k|	if (cli_ses.tty_raw_mode == 0) {
  ------------------
  |  Branch (139:6): [True: 3.41k, False: 0]
  ------------------
  140|  3.41k|		TRACE(("leave cli_tty_cleanup: not in raw mode"))
  141|  3.41k|		return;
  142|  3.41k|	}
  143|       |
  144|      0|	if (tcsetattr(STDIN_FILENO, TCSADRAIN, &cli_ses.saved_tio) == -1) {
  ------------------
  |  Branch (144:6): [True: 0, False: 0]
  ------------------
  145|      0|		dropbear_log(LOG_WARNING, "Failed restoring TTY");
  146|      0|	} else {
  147|      0|		cli_ses.tty_raw_mode = 0; 
  148|      0|	}
  149|       |
  150|      0|	TRACE(("leave cli_tty_cleanup"))
  151|      0|}

send_msg_kexdh_init:
   72|  5.80k|void send_msg_kexdh_init() {
   73|  5.80k|	TRACE(("send_msg_kexdh_init()"))	
   74|       |
   75|  5.80k|	CHECKCLEARTOWRITE();
   76|       |
   77|  5.80k|#if DROPBEAR_FUZZ
   78|  5.80k|	if (fuzz.fuzzing && fuzz.skip_kexmaths) {
  ------------------
  |  Branch (78:6): [True: 5.80k, False: 0]
  |  Branch (78:22): [True: 0, False: 5.80k]
  ------------------
   79|      0|		return;
   80|      0|	}
   81|  5.80k|#endif
   82|       |
   83|  5.80k|	cli_kex_free_param();
   84|       |
   85|  5.80k|	buf_putbyte(ses.writepayload, SSH_MSG_KEXDH_INIT);
  ------------------
  |  |   38|  5.80k|#define SSH_MSG_KEXDH_INIT             30
  ------------------
   86|  5.80k|	switch (ses.newkeys->algo_kex->mode) {
  ------------------
  |  Branch (86:10): [True: 5.80k, False: 0]
  ------------------
   87|      0|#if DROPBEAR_NORMAL_DH
   88|  1.08k|		case DROPBEAR_KEX_NORMAL_DH:
  ------------------
  |  Branch (88:3): [True: 1.08k, False: 4.72k]
  ------------------
   89|  1.08k|			cli_ses.dh_param = gen_kexdh_param();
   90|  1.08k|			buf_putmpint(ses.writepayload, &cli_ses.dh_param->pub);
   91|  1.08k|			break;
   92|      0|#endif
   93|      0|#if DROPBEAR_ECDH
   94|    762|		case DROPBEAR_KEX_ECDH:
  ------------------
  |  Branch (94:3): [True: 762, False: 5.04k]
  ------------------
   95|    762|			cli_ses.ecdh_param = gen_kexecdh_param();
   96|    762|			buf_put_ecc_raw_pubkey_string(ses.writepayload, &cli_ses.ecdh_param->key);
   97|    762|			break;
   98|      0|#endif
   99|      0|#if DROPBEAR_CURVE25519
  100|    430|		case DROPBEAR_KEX_CURVE25519:
  ------------------
  |  Branch (100:3): [True: 430, False: 5.37k]
  ------------------
  101|    430|			cli_ses.curve25519_param = gen_kexcurve25519_param();
  102|    430|			buf_putstring(ses.writepayload, cli_ses.curve25519_param->pub, CURVE25519_LEN);
  ------------------
  |  |  122|    430|#define CURVE25519_LEN 32
  ------------------
  103|    430|			break;
  104|      0|#endif
  105|      0|#if DROPBEAR_PQHYBRID
  106|  3.53k|		case DROPBEAR_KEX_PQHYBRID:
  ------------------
  |  Branch (106:3): [True: 3.53k, False: 2.27k]
  ------------------
  107|  3.53k|			cli_ses.pqhybrid_param = gen_kexpqhybrid_param();
  108|  3.53k|			buf_putbufstring(ses.writepayload, cli_ses.pqhybrid_param->concat_public);
  109|  3.53k|			break;
  110|  5.80k|#endif
  111|  5.80k|	}
  112|       |
  113|  5.80k|	encrypt_packet();
  114|  5.80k|}
recv_msg_kexdh_reply:
  117|  1.96k|void recv_msg_kexdh_reply() {
  118|       |
  119|  1.96k|	sign_key *hostkey = NULL;
  120|  1.96k|	unsigned int keytype, keybloblen;
  121|  1.96k|	unsigned char* keyblob = NULL;
  122|       |
  123|  1.96k|	TRACE(("enter recv_msg_kexdh_reply"))
  124|       |	
  125|  1.96k|#if DROPBEAR_FUZZ
  126|  1.96k|	if (fuzz.fuzzing && fuzz.skip_kexmaths) {
  ------------------
  |  Branch (126:6): [True: 1.96k, False: 0]
  |  Branch (126:22): [True: 0, False: 1.96k]
  ------------------
  127|      0|		return;
  128|      0|	}
  129|  1.96k|#endif
  130|       |
  131|  1.96k|	if (cli_ses.kex_state != KEXDH_INIT_SENT) {
  ------------------
  |  Branch (131:6): [True: 0, False: 1.96k]
  ------------------
  132|      0|		dropbear_exit("Received out-of-order kexdhreply");
  133|      0|	}
  134|  1.96k|	keytype = ses.newkeys->algo_hostkey;
  135|  1.96k|	TRACE(("keytype is %d", keytype))
  136|       |
  137|  1.96k|	hostkey = new_sign_key();
  138|  1.96k|	keybloblen = buf_getint(ses.payload);
  139|       |
  140|  1.96k|	keyblob = buf_getptr(ses.payload, keybloblen);
  141|  1.96k|	if (!ses.kexstate.donefirstkex) {
  ------------------
  |  Branch (141:6): [True: 0, False: 1.96k]
  ------------------
  142|       |		/* Only makes sense the first time */
  143|      0|		checkhostkey(keyblob, keybloblen);
  144|      0|	}
  145|       |
  146|  1.96k|	if (buf_get_pub_key(ses.payload, hostkey, &keytype) != DROPBEAR_SUCCESS) {
  ------------------
  |  |  111|  1.96k|#define DROPBEAR_SUCCESS 0
  ------------------
  |  Branch (146:6): [True: 336, False: 1.63k]
  ------------------
  147|    336|		TRACE(("failed getting pubkey"))
  148|    336|		dropbear_exit("Bad KEX packet");
  149|    336|	}
  150|       |
  151|       |	/* Derive the shared secret */
  152|  1.63k|	switch (ses.newkeys->algo_kex->mode) {
  ------------------
  |  Branch (152:10): [True: 1.51k, False: 117]
  ------------------
  153|      0|#if DROPBEAR_NORMAL_DH
  154|  1.00k|		case DROPBEAR_KEX_NORMAL_DH:
  ------------------
  |  Branch (154:3): [True: 1.00k, False: 631]
  ------------------
  155|  1.00k|			{
  156|  1.00k|			DEF_MP_INT(dh_f);
  ------------------
  |  |   83|  1.00k|#define DEF_MP_INT(X) mp_int X = {0, 0, 0, NULL}
  ------------------
  157|  1.00k|			m_mp_init(&dh_f);
  158|  1.00k|			if (buf_getmpint(ses.payload, &dh_f) != DROPBEAR_SUCCESS) {
  ------------------
  |  |  111|  1.00k|#define DROPBEAR_SUCCESS 0
  ------------------
  |  Branch (158:8): [True: 6, False: 995]
  ------------------
  159|      6|				TRACE(("failed getting mpint"))
  160|      6|				dropbear_exit("Bad KEX packet");
  161|      6|			}
  162|       |
  163|    995|			kexdh_comb_key(cli_ses.dh_param, &dh_f, hostkey);
  164|    995|			mp_clear(&dh_f);
  165|    995|			}
  166|      0|			break;
  167|      0|#endif
  168|      0|#if DROPBEAR_ECDH
  169|    132|		case DROPBEAR_KEX_ECDH:
  ------------------
  |  Branch (169:3): [True: 132, False: 1.50k]
  ------------------
  170|    132|			{
  171|    132|			buffer *ecdh_qs = buf_getstringbuf(ses.payload);
  172|    132|			kexecdh_comb_key(cli_ses.ecdh_param, ecdh_qs, hostkey);
  173|    132|			buf_free(ecdh_qs);
  174|    132|			}
  175|    132|			break;
  176|      0|#endif
  177|      0|#if DROPBEAR_CURVE25519
  178|    323|		case DROPBEAR_KEX_CURVE25519:
  ------------------
  |  Branch (178:3): [True: 323, False: 1.30k]
  ------------------
  179|    323|			{
  180|    323|			buffer *ecdh_qs = buf_getstringbuf(ses.payload);
  181|    323|			kexcurve25519_comb_key(cli_ses.curve25519_param, ecdh_qs, hostkey);
  182|    323|			buf_free(ecdh_qs);
  183|    323|			}
  184|    323|			break;
  185|      0|#endif
  186|      0|#if DROPBEAR_PQHYBRID
  187|     59|		case DROPBEAR_KEX_PQHYBRID:
  ------------------
  |  Branch (187:3): [True: 59, False: 1.57k]
  ------------------
  188|     59|			{
  189|     59|			buffer *q_s = buf_getstringbuf(ses.payload);
  190|     59|			kexpqhybrid_comb_key(cli_ses.pqhybrid_param, q_s, hostkey);
  191|     59|			buf_free(q_s);
  192|     59|			}
  193|     59|			break;
  194|  1.63k|#endif
  195|  1.63k|	}
  196|       |
  197|       |	/* Clear the local parameter */
  198|  1.35k|	cli_kex_free_param();
  199|       |
  200|  1.35k|	if (buf_verify(ses.payload, hostkey, ses.newkeys->algo_signature, 
  ------------------
  |  Branch (200:6): [True: 933, False: 418]
  ------------------
  201|  1.35k|			ses.hash) != DROPBEAR_SUCCESS) {
  ------------------
  |  |  111|  1.35k|#define DROPBEAR_SUCCESS 0
  ------------------
  202|    933|		dropbear_exit("Bad hostkey signature");
  203|    933|	}
  204|       |
  205|    418|	sign_key_free(hostkey);
  206|    418|	hostkey = NULL;
  207|       |
  208|    418|	send_msg_newkeys();
  209|    418|	ses.requirenext = SSH_MSG_NEWKEYS;
  ------------------
  |  |   37|    418|#define SSH_MSG_NEWKEYS                21
  ------------------
  210|    418|	TRACE(("leave recv_msg_kexdh_init"))
  211|    418|}
cli-kex.c:cli_kex_free_param:
   45|  7.15k|static void cli_kex_free_param(void) {
   46|  7.15k|#if DROPBEAR_NORMAL_DH
   47|  7.15k|	if (cli_ses.dh_param) {
  ------------------
  |  Branch (47:6): [True: 981, False: 6.17k]
  ------------------
   48|    981|		free_kexdh_param(cli_ses.dh_param);
   49|    981|		cli_ses.dh_param = NULL;
   50|    981|	}
   51|  7.15k|#endif
   52|  7.15k|#if DROPBEAR_ECDH
   53|  7.15k|	if (cli_ses.ecdh_param) {
  ------------------
  |  Branch (53:6): [True: 78, False: 7.07k]
  ------------------
   54|     78|		free_kexecdh_param(cli_ses.ecdh_param);
   55|     78|		cli_ses.ecdh_param = NULL;
   56|     78|	}
   57|  7.15k|#endif
   58|  7.15k|#if DROPBEAR_CURVE25519
   59|  7.15k|	if (cli_ses.curve25519_param) {
  ------------------
  |  Branch (59:6): [True: 244, False: 6.91k]
  ------------------
   60|    244|		free_kexcurve25519_param(cli_ses.curve25519_param);
   61|    244|		cli_ses.curve25519_param = NULL;
   62|    244|	}
   63|  7.15k|#endif
   64|  7.15k|#if DROPBEAR_PQHYBRID
   65|  7.15k|	if (cli_ses.pqhybrid_param) {
  ------------------
  |  Branch (65:6): [True: 2.43k, False: 4.72k]
  ------------------
   66|  2.43k|		free_kexpqhybrid_param(cli_ses.pqhybrid_param);
   67|       |		cli_ses.pqhybrid_param = NULL;
   68|  2.43k|	}
   69|  7.15k|#endif
   70|  7.15k|}

cli_getopts:
  114|      1|void cli_getopts(int argc, char ** argv) {
  115|      1|	unsigned int i, j;
  116|      1|	const char ** next = NULL;
  117|      1|	enum {
  118|      1|		OPT_EXTENDED_OPTIONS,
  119|      1|#if DROPBEAR_CLI_PUBKEY_AUTH
  120|      1|		OPT_AUTHKEY,
  121|      1|#endif
  122|      1|#if DROPBEAR_CLI_LOCALTCPFWD
  123|      1|		OPT_LOCALTCPFWD,
  124|      1|#endif
  125|      1|#if DROPBEAR_CLI_REMOTETCPFWD
  126|      1|		OPT_REMOTETCPFWD,
  127|      1|#endif
  128|      1|#if DROPBEAR_CLI_NETCAT
  129|      1|		OPT_NETCAT,
  130|      1|#endif
  131|       |		/* a flag (no arg) if 'next' is NULL, a string-valued option otherwise */
  132|      1|		OPT_OTHER
  133|      1|	} opt;
  134|      1|	unsigned int cmdlen;
  135|       |
  136|      1|	const char* recv_window_arg = NULL;
  137|      1|	const char* idle_timeout_arg = NULL;
  138|      1|	const char* max_duration_arg = NULL;
  139|      1|	const char *host_arg = NULL;
  140|      1|	const char *proxycmd_arg = NULL;
  141|      1|	const char *remoteport_arg = NULL;
  142|      1|	const char *username_arg = NULL;
  143|      1|	const char *algo_print_arg = NULL;
  144|      1|	char c;
  145|       |
  146|       |	/* see printhelp() for options */
  147|      1|	cli_opts.progname = argv[0];
  148|      1|	cli_opts.remotehost = NULL;
  149|      1|	cli_opts.remotehostfixed = 0;
  150|      1|	cli_opts.remoteport = NULL;
  151|      1|	cli_opts.username = NULL;
  152|      1|	cli_opts.cmd = NULL;
  153|      1|	cli_opts.no_cmd = 0;
  154|      1|	cli_opts.quiet = 0;
  155|      1|	cli_opts.backgrounded = 0;
  156|      1|	cli_opts.wantpty = 9; /* 9 means "it hasn't been touched", gets set later */
  157|      1|	cli_opts.always_accept_key = 0;
  158|      1|	cli_opts.ask_hostkey = 1;
  159|      1|	cli_opts.no_hostkey_check = 0;
  160|      1|	cli_opts.is_subsystem = 0;
  161|      1|#if DROPBEAR_CLI_PUBKEY_AUTH
  162|      1|	cli_opts.privkeys = list_new();
  163|      1|#endif
  164|      1|#if DROPBEAR_CLI_ANYTCPFWD
  165|      1|	cli_opts.exit_on_fwd_failure = 0;
  166|      1|#endif
  167|      1|	cli_opts.disable_trivial_auth = 0;
  168|      1|	cli_opts.password_authentication = 1;
  169|      1|	cli_opts.batch_mode = 0;
  170|      1|#if DROPBEAR_CLI_LOCALTCPFWD
  171|      1|	cli_opts.localfwds = list_new();
  172|      1|	opts.listen_fwd_all = 0;
  173|      1|#endif
  174|      1|#if DROPBEAR_CLI_REMOTETCPFWD
  175|      1|	cli_opts.remotefwds = list_new();
  176|      1|#endif
  177|      1|#if DROPBEAR_CLI_AGENTFWD
  178|      1|	cli_opts.agent_fwd = 0;
  179|      1|	cli_opts.agent_fd = -1;
  180|      1|	cli_opts.agent_keys_loaded = 0;
  181|      1|#endif
  182|      1|#if DROPBEAR_CLI_PROXYCMD
  183|      1|	cli_opts.proxycmd = NULL;
  184|      1|#endif
  185|      1|	cli_opts.bind_arg = NULL;
  186|      1|	cli_opts.bind_address = NULL;
  187|      1|	cli_opts.bind_port = NULL;
  188|      1|	cli_opts.keepalive_arg = NULL;
  189|       |#ifndef DISABLE_ZLIB
  190|       |	opts.compression = DROPBEAR_CLI_COMPRESSION;
  191|       |#endif
  192|      1|#if DROPBEAR_USER_ALGO_LIST
  193|      1|	opts.cipher_list = NULL;
  194|      1|	opts.mac_list = NULL;
  195|      1|#endif
  196|      1|#ifndef DISABLE_SYSLOG
  197|      1|	opts.usingsyslog = 0;
  198|      1|#endif
  199|       |	/* not yet
  200|       |	opts.ipv4 = 1;
  201|       |	opts.ipv6 = 1;
  202|       |	*/
  203|      1|	opts.recv_window = DEFAULT_RECV_WINDOW;
  ------------------
  |  |  550|      1|#define DEFAULT_RECV_WINDOW 24576
  ------------------
  204|      1|	opts.keepalive_secs = DEFAULT_KEEPALIVE;
  ------------------
  |  |  566|      1|#define DEFAULT_KEEPALIVE 0
  ------------------
  205|      1|	opts.idle_timeout_secs = DEFAULT_IDLE_TIMEOUT;
  ------------------
  |  |  579|      1|#define DEFAULT_IDLE_TIMEOUT 0
  ------------------
  206|      1|	opts.max_duration_secs = DEFAULT_MAX_DURATION;
  ------------------
  |  |  585|      1|#define DEFAULT_MAX_DURATION 0
  ------------------
  207|       |
  208|      1|	fill_own_user();
  209|       |
  210|      3|	for (i = 1; i < (unsigned int)argc; i++) {
  ------------------
  |  Branch (210:14): [True: 3, False: 0]
  ------------------
  211|       |		/* Handle non-flag arguments such as hostname or commands for the remote host */
  212|      3|		if (argv[i][0] != '-')
  ------------------
  |  Branch (212:7): [True: 2, False: 1]
  ------------------
  213|      2|		{
  214|      2|			if (host_arg == NULL) {
  ------------------
  |  Branch (214:8): [True: 1, False: 1]
  ------------------
  215|      1|				host_arg = argv[i];
  216|      1|				continue;
  217|      1|			}
  218|       |			/* Commands to pass to the remote host. No more flag handling,
  219|       |			commands are consumed below */
  220|      1|			break;
  221|      2|		}
  222|      1|		if (strcmp(argv[i], "--") == 0)
  ------------------
  |  Branch (222:7): [True: 0, False: 1]
  ------------------
  223|      0|		{
  224|      0|			i++;
  225|      0|			break;
  226|      0|		}
  227|       |
  228|       |		/* Begins with '-' */
  229|      1|		opt = OPT_OTHER;
  230|      2|		for (j = 1; (c = argv[i][j]) != '\0' && !next && opt == OPT_OTHER; j++) {
  ------------------
  |  Branch (230:15): [True: 1, False: 1]
  |  Branch (230:43): [True: 1, False: 0]
  |  Branch (230:52): [True: 1, False: 0]
  ------------------
  231|      1|			switch (c) {
  232|      1|				case 'y':
  ------------------
  |  Branch (232:5): [True: 1, False: 0]
  ------------------
  233|       |					/* once is always accept the remote hostkey,
  234|       |					 * the same as stricthostkeychecking=accept-new */
  235|      1|					if (cli_opts.always_accept_key) {
  ------------------
  |  Branch (235:10): [True: 0, False: 1]
  ------------------
  236|       |						/* twice means no checking at all
  237|       |						 * (stricthostkeychecking=no) */
  238|      0|						cli_opts.no_hostkey_check = 1;
  239|      0|					}
  240|      1|					cli_opts.always_accept_key = 1;
  241|      1|					break;
  242|      0|				case 'q': /* quiet */
  ------------------
  |  Branch (242:5): [True: 0, False: 1]
  ------------------
  243|      0|					cli_opts.quiet = 1;
  244|      0|					break;
  245|      0|				case 'p': /* remoteport */
  ------------------
  |  Branch (245:5): [True: 0, False: 1]
  ------------------
  246|      0|					next = &remoteport_arg;
  247|      0|					break;
  248|      0|#if DROPBEAR_CLI_PUBKEY_AUTH
  249|      0|				case 'i': /* an identityfile */
  ------------------
  |  Branch (249:5): [True: 0, False: 1]
  ------------------
  250|      0|					opt = OPT_AUTHKEY;
  251|      0|					break;
  252|      0|#endif
  253|      0|				case 't': /* we want a pty */
  ------------------
  |  Branch (253:5): [True: 0, False: 1]
  ------------------
  254|      0|					cli_opts.wantpty = 1;
  255|      0|					break;
  256|      0|				case 'T': /* don't want a pty */
  ------------------
  |  Branch (256:5): [True: 0, False: 1]
  ------------------
  257|      0|					cli_opts.wantpty = 0;
  258|      0|					break;
  259|      0|				case 'N':
  ------------------
  |  Branch (259:5): [True: 0, False: 1]
  ------------------
  260|      0|					cli_opts.no_cmd = 1;
  261|      0|					break;
  262|      0|				case 'f':
  ------------------
  |  Branch (262:5): [True: 0, False: 1]
  ------------------
  263|      0|					cli_opts.backgrounded = 1;
  264|      0|					break;
  265|      0|				case 's':
  ------------------
  |  Branch (265:5): [True: 0, False: 1]
  ------------------
  266|      0|					cli_opts.is_subsystem = 1;
  267|      0|					break;
  268|      0|				case 'o':
  ------------------
  |  Branch (268:5): [True: 0, False: 1]
  ------------------
  269|      0|					opt = OPT_EXTENDED_OPTIONS;
  270|      0|					break;
  271|      0|#if DROPBEAR_CLI_LOCALTCPFWD
  272|      0|				case 'L':
  ------------------
  |  Branch (272:5): [True: 0, False: 1]
  ------------------
  273|      0|					opt = OPT_LOCALTCPFWD;
  274|      0|					break;
  275|      0|				case 'g':
  ------------------
  |  Branch (275:5): [True: 0, False: 1]
  ------------------
  276|      0|					opts.listen_fwd_all = 1;
  277|      0|					break;
  278|      0|#endif
  279|      0|#if DROPBEAR_CLI_REMOTETCPFWD
  280|      0|				case 'R':
  ------------------
  |  Branch (280:5): [True: 0, False: 1]
  ------------------
  281|      0|					opt = OPT_REMOTETCPFWD;
  282|      0|					break;
  283|      0|#endif
  284|      0|#if DROPBEAR_CLI_NETCAT
  285|      0|				case 'B':
  ------------------
  |  Branch (285:5): [True: 0, False: 1]
  ------------------
  286|      0|					opt = OPT_NETCAT;
  287|      0|					break;
  288|      0|#endif
  289|      0|#if DROPBEAR_CLI_PROXYCMD
  290|      0|				case 'J':
  ------------------
  |  Branch (290:5): [True: 0, False: 1]
  ------------------
  291|      0|					next = &proxycmd_arg;
  292|      0|					break;
  293|      0|#endif
  294|      0|				case 'l':
  ------------------
  |  Branch (294:5): [True: 0, False: 1]
  ------------------
  295|      0|					next = &username_arg;
  296|      0|					break;
  297|      0|				case 'Q':
  ------------------
  |  Branch (297:5): [True: 0, False: 1]
  ------------------
  298|      0|					next = &algo_print_arg;
  299|      0|					break;
  300|      0|				case 'h':
  ------------------
  |  Branch (300:5): [True: 0, False: 1]
  ------------------
  301|      0|					printhelp();
  302|      0|					exit(EXIT_SUCCESS);
  303|      0|					break;
  304|      0|				case 'u':
  ------------------
  |  Branch (304:5): [True: 0, False: 1]
  ------------------
  305|       |					/* backwards compatibility with old urandom option */
  306|      0|					break;
  307|      0|				case 'W':
  ------------------
  |  Branch (307:5): [True: 0, False: 1]
  ------------------
  308|      0|					next = &recv_window_arg;
  309|      0|					break;
  310|      0|				case 'K':
  ------------------
  |  Branch (310:5): [True: 0, False: 1]
  ------------------
  311|      0|					next = &cli_opts.keepalive_arg;
  312|      0|					break;
  313|      0|				case 'I':
  ------------------
  |  Branch (313:5): [True: 0, False: 1]
  ------------------
  314|      0|					next = &idle_timeout_arg;
  315|      0|					break;
  316|      0|				case 'M':
  ------------------
  |  Branch (316:5): [True: 0, False: 1]
  ------------------
  317|      0|					next = &max_duration_arg;
  318|      0|					break;
  319|      0|#if DROPBEAR_CLI_AGENTFWD
  320|      0|				case 'A':
  ------------------
  |  Branch (320:5): [True: 0, False: 1]
  ------------------
  321|      0|					cli_opts.agent_fwd = 1;
  322|      0|					break;
  323|      0|#endif
  324|      0|#if DROPBEAR_USER_ALGO_LIST
  325|      0|				case 'c':
  ------------------
  |  Branch (325:5): [True: 0, False: 1]
  ------------------
  326|      0|					next = &opts.cipher_list;
  327|      0|					break;
  328|      0|				case 'm':
  ------------------
  |  Branch (328:5): [True: 0, False: 1]
  ------------------
  329|      0|					next = &opts.mac_list;
  330|      0|					break;
  331|      0|#endif
  332|       |#if DEBUG_TRACE
  333|       |				case 'v':
  334|       |					debug_trace++;
  335|       |					break;
  336|       |#endif
  337|      0|				case 'F':
  ------------------
  |  Branch (337:5): [True: 0, False: 1]
  ------------------
  338|      0|				case 'e':
  ------------------
  |  Branch (338:5): [True: 0, False: 1]
  ------------------
  339|       |#if !DROPBEAR_USER_ALGO_LIST
  340|       |				case 'c':
  341|       |				case 'm':
  342|       |#endif
  343|      0|				case 'D':
  ------------------
  |  Branch (343:5): [True: 0, False: 1]
  ------------------
  344|       |#if !DROPBEAR_CLI_REMOTETCPFWD
  345|       |				case 'R':
  346|       |#endif
  347|       |#if !DROPBEAR_CLI_LOCALTCPFWD
  348|       |				case 'L':
  349|       |#endif
  350|      0|				case 'V':
  ------------------
  |  Branch (350:5): [True: 0, False: 1]
  ------------------
  351|      0|					print_version();
  352|      0|					exit(EXIT_SUCCESS);
  353|      0|					break;
  354|      0|				case 'b':
  ------------------
  |  Branch (354:5): [True: 0, False: 1]
  ------------------
  355|      0|					next = &cli_opts.bind_arg;
  356|      0|					break;
  357|      0|				case 'z':
  ------------------
  |  Branch (357:5): [True: 0, False: 1]
  ------------------
  358|      0|					opts.disable_ip_tos = 1;
  359|      0|					break;
  360|      0|				default:
  ------------------
  |  Branch (360:5): [True: 0, False: 1]
  ------------------
  361|      0|					fprintf(stderr,
  ------------------
  |  |  100|      0|#define stderr (fuzz.fake_stderr)
  ------------------
  362|      0|						"WARNING: Ignoring unknown option -%c\n", c);
  363|      0|					break;
  364|      1|			} /* Switch */
  365|      1|		}
  366|       |
  367|      1|		if (!next && opt == OPT_OTHER) /* got a flag */
  ------------------
  |  Branch (367:7): [True: 1, False: 0]
  |  Branch (367:16): [True: 1, False: 0]
  ------------------
  368|      1|			continue;
  369|       |
  370|      0|		if (c == '\0') {
  ------------------
  |  Branch (370:7): [True: 0, False: 0]
  ------------------
  371|      0|			i++;
  372|      0|			j = 0;
  373|      0|			if (!argv[i])
  ------------------
  |  Branch (373:8): [True: 0, False: 0]
  ------------------
  374|      0|				dropbear_exit("Missing argument");
  375|      0|		}
  376|       |
  377|      0|		if (opt == OPT_EXTENDED_OPTIONS) {
  ------------------
  |  Branch (377:7): [True: 0, False: 0]
  ------------------
  378|      0|			TRACE(("opt extended"))
  379|      0|			add_extendedopt(&argv[i][j]);
  380|      0|		}
  381|      0|		else
  382|      0|#if DROPBEAR_CLI_PUBKEY_AUTH
  383|      0|		if (opt == OPT_AUTHKEY) {
  ------------------
  |  Branch (383:7): [True: 0, False: 0]
  ------------------
  384|      0|			TRACE(("opt authkey"))
  385|      0|			loadidentityfile(&argv[i][j], 1);
  386|      0|		}
  387|      0|		else
  388|      0|#endif
  389|      0|#if DROPBEAR_CLI_REMOTETCPFWD
  390|      0|		if (opt == OPT_REMOTETCPFWD) {
  ------------------
  |  Branch (390:7): [True: 0, False: 0]
  ------------------
  391|      0|			TRACE(("opt remotetcpfwd"))
  392|      0|			addforward(&argv[i][j], cli_opts.remotefwds);
  393|      0|		}
  394|      0|		else
  395|      0|#endif
  396|      0|#if DROPBEAR_CLI_LOCALTCPFWD
  397|      0|		if (opt == OPT_LOCALTCPFWD) {
  ------------------
  |  Branch (397:7): [True: 0, False: 0]
  ------------------
  398|      0|			TRACE(("opt localtcpfwd"))
  399|      0|			addforward(&argv[i][j], cli_opts.localfwds);
  400|      0|		}
  401|      0|		else
  402|      0|#endif
  403|      0|#if DROPBEAR_CLI_NETCAT
  404|      0|		if (opt == OPT_NETCAT) {
  ------------------
  |  Branch (404:7): [True: 0, False: 0]
  ------------------
  405|      0|			TRACE(("opt netcat"))
  406|      0|			add_netcat(&argv[i][j]);
  407|      0|		}
  408|      0|		else
  409|      0|#endif
  410|      0|		if (next) {
  ------------------
  |  Branch (410:7): [True: 0, False: 0]
  ------------------
  411|       |			/* The previous flag set a value to assign */
  412|      0|			*next = &argv[i][j];
  413|      0|			if (*next == NULL)
  ------------------
  |  Branch (413:8): [True: 0, False: 0]
  ------------------
  414|      0|				dropbear_exit("Invalid null argument");
  415|      0|			next = NULL;
  416|      0|		}
  417|      0|	}
  418|       |
  419|      1|#if DROPBEAR_USER_ALGO_LIST
  420|       |	/* -c help doesn't need a hostname */
  421|      1|	parse_ciphers_macs();
  422|      1|#endif
  423|       |
  424|      1|	if (algo_print_arg) {
  ------------------
  |  Branch (424:6): [True: 0, False: 1]
  ------------------
  425|      0|		print_algos(algo_print_arg);
  426|       |		/* No return */
  427|      0|	}
  428|       |
  429|      1|	if (host_arg == NULL) { /* missing hostname */
  ------------------
  |  Branch (429:6): [True: 0, False: 1]
  ------------------
  430|      0|		printhelp();
  431|      0|		dropbear_exit("Remote host needs to be provided.");
  432|      0|	}
  433|      1|	TRACE(("host is: %s", host_arg))
  434|       |
  435|      1|#if DROPBEAR_USE_SSH_CONFIG
  436|      1|	apply_config_settings(host_arg);
  437|      1|#endif
  438|       |
  439|       |	/* Apply needed defaults if missing from command line or config file. */
  440|      1|	if (remoteport_arg) {
  ------------------
  |  Branch (440:6): [True: 0, False: 1]
  ------------------
  441|      0|		m_free(cli_opts.remoteport);
  ------------------
  |  |   24|      0|#define m_free(X) do {m_free_direct(X); (X) = NULL;} while (0)
  |  |  ------------------
  |  |  |  Branch (24:61): [Folded, False: 0]
  |  |  ------------------
  ------------------
  442|      0|		cli_opts.remoteport = m_strdup(remoteport_arg);
  443|      1|	} else if (!cli_opts.remoteport) {
  ------------------
  |  Branch (443:13): [True: 1, False: 0]
  ------------------
  444|      1|		cli_opts.remoteport = m_strdup("22");
  445|      1|	}
  446|       |
  447|      1|	if (username_arg) {
  ------------------
  |  Branch (447:6): [True: 0, False: 1]
  ------------------
  448|      0|		m_free(cli_opts.username);
  ------------------
  |  |   24|      0|#define m_free(X) do {m_free_direct(X); (X) = NULL;} while (0)
  |  |  ------------------
  |  |  |  Branch (24:61): [Folded, False: 0]
  |  |  ------------------
  ------------------
  449|      0|		cli_opts.username = m_strdup(username_arg);
  450|      1|	} else if(!cli_opts.username) {
  ------------------
  |  Branch (450:12): [True: 1, False: 0]
  ------------------
  451|      1|		cli_opts.username = m_strdup(cli_opts.own_user);
  452|      1|	}
  453|       |
  454|       |	/* Done with options/flags; now handle the hostname (which may not
  455|       |	 * start with a hyphen) and optional command */
  456|       |
  457|      1|	if (i < (unsigned int)argc) {
  ------------------
  |  Branch (457:6): [True: 1, False: 0]
  ------------------
  458|       |		/* Build the command to send */
  459|      1|		cmdlen = 0;
  460|      2|		for (j = i; j < (unsigned int)argc; j++)
  ------------------
  |  Branch (460:15): [True: 1, False: 1]
  ------------------
  461|      1|			cmdlen += strlen(argv[j]) + 1; /* +1 for spaces */
  462|       |
  463|       |		/* Allocate the space */
  464|      1|		cli_opts.cmd = (char*)m_malloc(cmdlen);
  465|      1|		cli_opts.cmd[0] = '\0';
  466|       |
  467|       |		/* Append all the bits */
  468|      2|		for (j = i; j < (unsigned int)argc; j++) {
  ------------------
  |  Branch (468:15): [True: 1, False: 1]
  ------------------
  469|      1|			strlcat(cli_opts.cmd, argv[j], cmdlen);
  470|      1|			strlcat(cli_opts.cmd, " ", cmdlen);
  471|      1|		}
  472|       |		/* It'll be null-terminated here */
  473|      1|		TRACE(("cmd is: %s", cli_opts.cmd))
  474|      1|	}
  475|       |
  476|       |	/* And now a few sanity checks and setup */
  477|       |
  478|      1|#if DROPBEAR_CLI_PROXYCMD
  479|      1|	if (proxycmd_arg) {
  ------------------
  |  Branch (479:6): [True: 0, False: 1]
  ------------------
  480|       |		/* To match the common path of m_freeing it */
  481|      0|		cli_opts.proxycmd = m_strdup(proxycmd_arg);
  482|      0|	}
  483|      1|#endif
  484|       |
  485|      1|	if (cli_opts.bind_arg) {
  ------------------
  |  Branch (485:6): [True: 0, False: 1]
  ------------------
  486|      0|		if (split_address_port(cli_opts.bind_arg,
  ------------------
  |  Branch (486:7): [True: 0, False: 0]
  ------------------
  487|      0|			&cli_opts.bind_address, &cli_opts.bind_port)
  488|      0|				== DROPBEAR_FAILURE) {
  ------------------
  |  |  112|      0|#define DROPBEAR_FAILURE -1
  ------------------
  489|      0|			dropbear_exit("Bad -b argument");
  490|      0|		}
  491|      0|	}
  492|       |
  493|       |	/* If not explicitly specified with -t or -T, we don't want a pty if
  494|       |	 * there's a command, but we do otherwise */
  495|      1|	if (cli_opts.wantpty == 9) {
  ------------------
  |  Branch (495:6): [True: 1, False: 0]
  ------------------
  496|      1|		if (cli_opts.cmd == NULL) {
  ------------------
  |  Branch (496:7): [True: 0, False: 1]
  ------------------
  497|      0|			if (isatty(STDIN_FILENO)) {
  ------------------
  |  Branch (497:8): [True: 0, False: 0]
  ------------------
  498|      0|				cli_opts.wantpty = 1;
  499|      0|			} else {
  500|      0|				TRACE(("Not a TTY"));
  501|      0|				cli_opts.wantpty = 0;
  502|      0|			}
  503|      1|		} else {
  504|      1|			cli_opts.wantpty = 0;
  505|      1|		}
  506|      1|	}
  507|       |
  508|      1|	if (cli_opts.backgrounded && cli_opts.cmd == NULL
  ------------------
  |  Branch (508:6): [True: 0, False: 1]
  |  Branch (508:31): [True: 0, False: 0]
  ------------------
  509|      0|			&& cli_opts.no_cmd == 0) {
  ------------------
  |  Branch (509:7): [True: 0, False: 0]
  ------------------
  510|      0|		dropbear_exit("Command required for -f");
  511|      0|	}
  512|       |
  513|      1|	if (recv_window_arg) {
  ------------------
  |  Branch (513:6): [True: 0, False: 1]
  ------------------
  514|      0|		parse_recv_window(recv_window_arg);
  515|      0|	}
  516|      1|	if (cli_opts.keepalive_arg) {
  ------------------
  |  Branch (516:6): [True: 0, False: 1]
  ------------------
  517|      0|		unsigned int val;
  518|      0|		if (m_str_to_uint(cli_opts.keepalive_arg, &val) == DROPBEAR_FAILURE) {
  ------------------
  |  |  112|      0|#define DROPBEAR_FAILURE -1
  ------------------
  |  Branch (518:7): [True: 0, False: 0]
  ------------------
  519|      0|			dropbear_exit("Bad keepalive '%s'", cli_opts.keepalive_arg);
  520|      0|		}
  521|      0|		opts.keepalive_secs = val;
  522|      0|	}
  523|       |
  524|      1|	if (idle_timeout_arg) {
  ------------------
  |  Branch (524:6): [True: 0, False: 1]
  ------------------
  525|      0|		unsigned int val;
  526|      0|		if (m_str_to_uint(idle_timeout_arg, &val) == DROPBEAR_FAILURE) {
  ------------------
  |  |  112|      0|#define DROPBEAR_FAILURE -1
  ------------------
  |  Branch (526:7): [True: 0, False: 0]
  ------------------
  527|      0|			dropbear_exit("Bad idle_timeout '%s'", idle_timeout_arg);
  528|      0|		}
  529|      0|		opts.idle_timeout_secs = val;
  530|      0|	}
  531|       |
  532|      1|	if (max_duration_arg) {
  ------------------
  |  Branch (532:6): [True: 0, False: 1]
  ------------------
  533|      0|		unsigned int val;
  534|      0|		if (m_str_to_uint(max_duration_arg, &val) == DROPBEAR_FAILURE) {
  ------------------
  |  |  112|      0|#define DROPBEAR_FAILURE -1
  ------------------
  |  Branch (534:7): [True: 0, False: 0]
  ------------------
  535|      0|			dropbear_exit("Bad max_duration '%s'", max_duration_arg);
  536|      0|		}
  537|      0|		opts.max_duration_secs = val;
  538|      0|	}
  539|       |
  540|      1|#if DROPBEAR_CLI_NETCAT
  541|      1|	if (cli_opts.cmd && cli_opts.netcat_host) {
  ------------------
  |  Branch (541:6): [True: 1, False: 0]
  |  Branch (541:22): [True: 0, False: 1]
  ------------------
  542|      0|		dropbear_log(LOG_INFO, "Ignoring command '%s' in netcat mode", cli_opts.cmd);
  543|      0|	}
  544|      1|#endif
  545|       |
  546|       |	/* The hostname gets set up last, since
  547|       |	 * in multi-hop mode it will require knowledge
  548|       |	 * of other flags such as -i */
  549|      1|#if DROPBEAR_CLI_MULTIHOP
  550|      1|	parse_multihop_hostname(host_arg, argv[0]);
  551|       |#else
  552|       |	parse_hostname(host_arg);
  553|       |#endif
  554|       |
  555|       |	/* We don't want to include default id_dropbear as a
  556|       |	   -i argument for multihop, so handle it later. */
  557|      1|#if (DROPBEAR_CLI_PUBKEY_AUTH)
  558|      1|	{
  559|      1|		loadidentityfile(DROPBEAR_DEFAULT_CLI_AUTHKEY, 0);
  ------------------
  |  |  408|      1|#define DROPBEAR_DEFAULT_CLI_AUTHKEY "~/.ssh/id_dropbear"
  ------------------
  560|      1|	}
  561|      1|#endif
  562|      1|}
loadidentityfile:
  565|      1|void loadidentityfile(const char* filename, int warnfail) {
  566|      1|	sign_key *key;
  567|      1|	enum signkey_type keytype;
  568|       |
  569|      1|	char *id_key_path = expand_homedir_path(filename);
  570|      1|	TRACE(("loadidentityfile %s", id_key_path))
  571|       |
  572|      1|	key = new_sign_key();
  573|      1|	keytype = DROPBEAR_SIGNKEY_ANY;
  574|      1|	if ( readhostkey(id_key_path, key, &keytype) != DROPBEAR_SUCCESS ) {
  ------------------
  |  |  111|      1|#define DROPBEAR_SUCCESS 0
  ------------------
  |  Branch (574:7): [True: 1, False: 0]
  ------------------
  575|      1|		if (warnfail) {
  ------------------
  |  Branch (575:7): [True: 0, False: 1]
  ------------------
  576|      0|			dropbear_log(LOG_WARNING, "Failed loading keyfile '%s'\n", id_key_path);
  577|      0|		}
  578|      1|		sign_key_free(key);
  579|      1|		m_free(id_key_path);
  ------------------
  |  |   24|      1|#define m_free(X) do {m_free_direct(X); (X) = NULL;} while (0)
  |  |  ------------------
  |  |  |  Branch (24:61): [Folded, False: 1]
  |  |  ------------------
  ------------------
  580|      1|	} else {
  581|      0|		key->type = keytype;
  582|      0|		key->source = SIGNKEY_SOURCE_RAW_FILE;
  583|      0|		key->filename = id_key_path;
  584|      0|		list_append(cli_opts.privkeys, key);
  585|      0|	}
  586|      1|}
cli-runopts.c:parse_multihop_hostname:
  702|      1|static void parse_multihop_hostname(const char* orighostarg, const char* argv0) {
  703|      1|	char *userhostarg = NULL;
  704|      1|	char *hostbuf = NULL;
  705|      1|	char *last_hop = NULL;
  706|      1|	char *prior_hops = NULL;
  707|       |
  708|       |	/* both scp and rsync parse a user@host argument
  709|       |	 * and turn it into "-l user host". This breaks
  710|       |	 * for our multihop syntax, so we suture it back together.
  711|       |	 * This will break usernames that have both '@' and ',' in them,
  712|       |	 * though that should be fairly uncommon. */
  713|      1|	if (cli_opts.username
  ------------------
  |  Branch (713:6): [True: 1, False: 0]
  ------------------
  714|      1|			&& strchr(cli_opts.username, ',')
  ------------------
  |  Branch (714:7): [True: 0, False: 1]
  ------------------
  715|      0|			&& strchr(cli_opts.username, '@')) {
  ------------------
  |  Branch (715:7): [True: 0, False: 0]
  ------------------
  716|      0|		unsigned int len = strlen(orighostarg) + strlen(cli_opts.username) + 2;
  717|      0|		hostbuf = m_malloc(len);
  718|      0|		m_snprintf(hostbuf, len, "%s@%s", cli_opts.username, orighostarg);
  719|      1|	} else {
  720|      1|		hostbuf = m_strdup(orighostarg);
  721|      1|	}
  722|      1|	userhostarg = hostbuf;
  723|       |
  724|       |	/* Split off any last hostname and use that as remotehost/remoteport.
  725|       |	 * That is used for authorized_keys checking etc */
  726|      1|	last_hop = strrchr(userhostarg, ',');
  727|      1|	if (last_hop) {
  ------------------
  |  Branch (727:6): [True: 0, False: 1]
  ------------------
  728|      0|		if (last_hop == userhostarg) {
  ------------------
  |  Branch (728:7): [True: 0, False: 0]
  ------------------
  729|      0|			dropbear_exit("Bad multi-hop hostnames");
  730|      0|		}
  731|      0|		*last_hop = '\0';
  732|      0|		last_hop++;
  733|      0|		prior_hops = userhostarg;
  734|      0|		userhostarg = last_hop;
  735|      0|	}
  736|       |
  737|       |	/* Update cli_opts.remotehost and cli_opts.remoteport */
  738|      1|	parse_hostname(userhostarg);
  739|       |
  740|       |	/* Construct any multihop proxy command. Use proxyexec to
  741|       |	 * avoid worrying about shell escaping. */
  742|      1|	if (prior_hops) {
  ------------------
  |  Branch (742:6): [True: 0, False: 1]
  ------------------
  743|      0|		cli_opts.proxyexec = multihop_args(argv0, prior_hops);
  744|       |		/* Any -J argument has been copied to proxyexec */
  745|      0|		if (cli_opts.proxycmd) {
  ------------------
  |  Branch (745:7): [True: 0, False: 0]
  ------------------
  746|      0|			m_free(cli_opts.proxycmd);
  ------------------
  |  |   24|      0|#define m_free(X) do {m_free_direct(X); (X) = NULL;} while (0)
  |  |  ------------------
  |  |  |  Branch (24:61): [Folded, False: 0]
  |  |  ------------------
  ------------------
  747|      0|		}
  748|       |
  749|       |#ifndef DISABLE_ZLIB
  750|       |		/* This outer stream will be incompressible since it's encrypted. */
  751|       |		opts.compression = 0;
  752|       |#endif
  753|      0|	}
  754|       |
  755|       |	m_free(hostbuf);
  ------------------
  |  |   24|      1|#define m_free(X) do {m_free_direct(X); (X) = NULL;} while (0)
  |  |  ------------------
  |  |  |  Branch (24:61): [Folded, False: 1]
  |  |  ------------------
  ------------------
  756|      1|}
cli-runopts.c:parse_hostname:
  760|      1|static void parse_hostname(const char* orighostarg) {
  761|      1|	char *userhostarg = NULL;
  762|      1|	char *port = NULL;
  763|      1|	char* remotehost = NULL;
  764|       |
  765|      1|	userhostarg = m_strdup(orighostarg);
  766|       |
  767|      1|	remotehost = strchr(userhostarg, '@');
  768|      1|	if (remotehost == NULL) {
  ------------------
  |  Branch (768:6): [True: 1, False: 0]
  ------------------
  769|       |		/* no username portion, the cli-auth.c code can figure the
  770|       |		 * local user's name */
  771|      1|		remotehost = userhostarg;
  772|      1|	} else {
  773|      0|		remotehost[0] = '\0'; /* Split the user/host */
  774|      0|		remotehost++;
  775|      0|		cli_opts.username = m_strdup(userhostarg);
  776|      0|	}
  777|       |
  778|      1|	port = strchr(remotehost, '^');
  779|      1|	if (!port)  {
  ------------------
  |  Branch (779:6): [True: 1, False: 0]
  ------------------
  780|       |		/* legacy separator */
  781|      1|		port = strchr(remotehost, '/');
  782|      1|	}
  783|      1|	if (port) {
  ------------------
  |  Branch (783:6): [True: 0, False: 1]
  ------------------
  784|      0|		*port = '\0';
  785|      0|		cli_opts.remoteport = m_strdup(port+1);
  786|      0|	}
  787|       |
  788|      1|	if (remotehost[0] == '\0') {
  ------------------
  |  Branch (788:6): [True: 0, False: 1]
  ------------------
  789|      0|		dropbear_exit("Bad hostname.");
  790|      0|	}
  791|       |
  792|      1|	if (!cli_opts.remotehostfixed) {
  ------------------
  |  Branch (792:6): [True: 1, False: 0]
  ------------------
  793|      1|		cli_opts.remotehost = m_strdup(remotehost);
  794|      1|	}
  795|       |	m_free(userhostarg);
  ------------------
  |  |   24|      1|#define m_free(X) do {m_free_direct(X); (X) = NULL;} while (0)
  |  |  ------------------
  |  |  |  Branch (24:61): [Folded, False: 1]
  |  |  ------------------
  ------------------
  796|      1|}
cli-runopts.c:fill_own_user:
  835|      1|static void fill_own_user() {
  836|      1|	uid_t uid;
  837|      1|	struct passwd *pw = NULL;
  838|       |
  839|      1|	uid = getuid();
  840|       |
  841|      1|	pw = getpwuid(uid);
  ------------------
  |  |  109|      1|#define getpwuid(x) fuzz_getpwuid(x)
  ------------------
  842|      1|	if (pw && pw->pw_name != NULL) {
  ------------------
  |  Branch (842:6): [True: 1, False: 0]
  |  Branch (842:12): [True: 1, False: 0]
  ------------------
  843|      1|		cli_opts.own_user = m_strdup(pw->pw_name);
  844|      1|	} else {
  845|      0|		dropbear_log(LOG_INFO, "Warning: failed to identify current user. Trying anyway.");
  846|      0|		cli_opts.own_user = m_strdup("unknown");
  847|      0|	}
  848|       |
  849|      1|}
cli-runopts.c:apply_config_settings:
 1145|      1|static void apply_config_settings(const char* cli_host_arg) {
 1146|      1|	const char* is_multi_hop_host_target = strchr(cli_host_arg, ',');
 1147|      1|	if (!is_multi_hop_host_target) {
  ------------------
  |  Branch (1147:6): [True: 1, False: 0]
  ------------------
 1148|      1|		char* config_path = expand_homedir_path(DROPBEAR_DEFAULT_SSH_CONFIG);
  ------------------
  |  |  118|      1|#define DROPBEAR_DEFAULT_SSH_CONFIG "~/.ssh/dropbear_config"
  ------------------
 1149|      1|		FILE* f;
 1150|      1|		if ((f = fopen(config_path, "r")) == NULL) {
  ------------------
  |  Branch (1150:7): [True: 1, False: 0]
  ------------------
 1151|      1|			DEBUG1(("Configuration file '%.200s' not found.", config_path));
 1152|      1|		}
 1153|      0|		else {
 1154|      0|			parse_hostname(cli_host_arg); /* Needed as key into the config. */
 1155|      0|			read_config_file(config_path, f, &cli_opts);
 1156|      0|			fclose(f);
 1157|      0|		}
 1158|       |		m_free(config_path);
  ------------------
  |  |   24|      1|#define m_free(X) do {m_free_direct(X); (X) = NULL;} while (0)
  |  |  ------------------
  |  |  |  Branch (24:61): [Folded, False: 1]
  |  |  ------------------
  ------------------
 1159|      1|	}
 1160|      1|}

cli_session:
  112|  3.41k|void cli_session(int sock_in, int sock_out, struct dropbear_progress_connection *progress, pid_t proxy_cmd_pid) {
  113|       |
  114|  3.41k|	common_session_init(sock_in, sock_out);
  115|       |
  116|  3.41k|	if (progress) {
  ------------------
  |  Branch (116:6): [True: 0, False: 3.41k]
  ------------------
  117|      0|		connect_set_writequeue(progress, &ses.writequeue);
  118|      0|	}
  119|       |
  120|  3.41k|	chaninitialise(cli_chantypes);
  121|  3.41k|	cli_algos_initialise();
  122|       |
  123|       |	/* Set up cli_ses vars */
  124|  3.41k|	cli_session_init(proxy_cmd_pid);
  125|       |
  126|       |	/* Ready to go */
  127|  3.41k|	ses.init_done = 1;
  128|       |
  129|       |	/* Exchange identification */
  130|  3.41k|	send_session_identification();
  131|       |
  132|  3.41k|	kexfirstinitialise(); /* initialise the kex state */
  133|       |
  134|  3.41k|	send_msg_kexinit();
  135|       |
  136|  3.41k|	session_loop(cli_sessionloop);
  137|       |
  138|       |	/* Not reached */
  139|       |
  140|  3.41k|}
kill_proxy_command:
  338|  3.41k|void kill_proxy_command(void) {
  339|       |	/*
  340|       |	 * Send SIGHUP to proxy command if used. We don't wait() in
  341|       |	 * case it hangs and instead rely on init to reap the child
  342|       |	 */
  343|  3.41k|	if (cli_ses.proxy_cmd_pid > 1) {
  ------------------
  |  Branch (343:6): [True: 0, False: 3.41k]
  ------------------
  344|      0|		TRACE(("killing proxy command with PID='%d'", cli_ses.proxy_cmd_pid));
  345|      0|		kill(cli_ses.proxy_cmd_pid, SIGHUP);
  ------------------
  |  |   57|      0|#define kill(pid, sig) fuzz_kill(pid, sig)
  ------------------
  346|      0|	}
  347|  3.41k|}
cli_dropbear_exit:
  409|  3.41k|void cli_dropbear_exit(int exitcode, const char* format, va_list param) {
  410|  3.41k|	char exitmsg[400];
  411|  3.41k|	char fullmsg[550];
  412|       |
  413|       |	/* Note that exit message must be rendered before session cleanup */
  414|       |
  415|       |	/* Render the formatted exit message */
  416|  3.41k|	vsnprintf(exitmsg, sizeof(exitmsg), format, param);
  417|  3.41k|	TRACE(("Exited, cleaning up: %s", exitmsg))
  418|       |
  419|       |	/* Add the prefix depending on session/auth state */
  420|  3.41k|	if (!ses.init_done) {
  ------------------
  |  Branch (420:6): [True: 0, False: 3.41k]
  ------------------
  421|      0|		snprintf(fullmsg, sizeof(fullmsg), "Exited: %s", exitmsg);
  422|  3.41k|	} else {
  423|  3.41k|		if (strchr(cli_opts.remotehost, ':') != NULL) {
  ------------------
  |  Branch (423:7): [True: 0, False: 3.41k]
  ------------------
  424|      0|			snprintf(fullmsg, sizeof(fullmsg), 
  425|      0|				"Connection to %s@[%s]:%s exited: %s", 
  426|      0|				cli_opts.username, cli_opts.remotehost, 
  427|      0|				cli_opts.remoteport, exitmsg);
  428|  3.41k|		} else {
  429|  3.41k|			snprintf(fullmsg, sizeof(fullmsg), 
  430|  3.41k|				"Connection to %s@%s:%s exited: %s", 
  431|  3.41k|				cli_opts.username, cli_opts.remotehost, 
  432|  3.41k|				cli_opts.remoteport, exitmsg);
  433|  3.41k|		}
  434|  3.41k|	}
  435|       |
  436|       |	/* Do the cleanup first, since then the terminal will be reset */
  437|  3.41k|	session_cleanup();
  438|       |	
  439|  3.41k|#if DROPBEAR_FUZZ
  440|  3.41k|    if (fuzz.do_jmp) {
  ------------------
  |  Branch (440:9): [True: 3.41k, False: 0]
  ------------------
  441|  3.41k|        longjmp(fuzz.jmp, 1);
  442|  3.41k|    }
  443|      0|#endif
  444|       |
  445|       |	/* Avoid printing onwards from terminal cruft */
  446|      0|	fprintf(stderr, "\n");
  ------------------
  |  |  100|      0|#define stderr (fuzz.fake_stderr)
  ------------------
  447|       |
  448|      0|	dropbear_log(LOG_INFO, "%s", fullmsg);
  449|       |
  450|      0|	exit(exitcode);
  451|  3.41k|}
cli_dropbear_log:
  453|     71|void cli_dropbear_log(int priority, const char* format, va_list param) {
  454|       |
  455|     71|	char printbuf[1024];
  456|     71|	const char *name;
  457|       |
  458|     71|	name = cli_opts.progname;
  459|     71|	if (!name) {
  ------------------
  |  Branch (459:6): [True: 0, False: 71]
  ------------------
  460|      0|		name = "dbclient";
  461|      0|	}
  462|       |
  463|     71|	vsnprintf(printbuf, sizeof(printbuf), format, param);
  464|       |
  465|     71|#ifndef DISABLE_SYSLOG
  466|     71|	if (opts.usingsyslog) {
  ------------------
  |  Branch (466:6): [True: 0, False: 71]
  ------------------
  467|      0|		syslog(priority, "%s", printbuf);
  468|      0|	}
  469|     71|#endif
  470|       |
  471|     71|	fprintf(stderr, "%s: %s\n", name, printbuf);
  ------------------
  |  |  100|     71|#define stderr (fuzz.fake_stderr)
  ------------------
  472|     71|	fflush(stderr);
  ------------------
  |  |  100|     71|#define stderr (fuzz.fake_stderr)
  ------------------
  473|     71|}
cli-session.c:cli_session_init:
  148|  3.41k|static void cli_session_init(pid_t proxy_cmd_pid) {
  149|       |
  150|  3.41k|	cli_ses.state = STATE_NOTHING;
  151|  3.41k|	cli_ses.kex_state = KEX_NOTHING;
  152|       |
  153|  3.41k|	cli_ses.tty_raw_mode = 0;
  154|  3.41k|	cli_ses.winchange = 0;
  155|       |
  156|       |	/* We store std{in,out,err}'s flags, so we can set them back on exit
  157|       |	 * (otherwise busybox's ash isn't happy */
  158|  3.41k|	cli_ses.stdincopy = dup(STDIN_FILENO);
  159|  3.41k|	cli_ses.stdinflags = fcntl(STDIN_FILENO, F_GETFL, 0);
  160|  3.41k|	cli_ses.stdoutcopy = dup(STDOUT_FILENO);
  161|  3.41k|	cli_ses.stdoutflags = fcntl(STDOUT_FILENO, F_GETFL, 0);
  162|  3.41k|	cli_ses.stderrcopy = dup(STDERR_FILENO);
  163|  3.41k|	cli_ses.stderrflags = fcntl(STDERR_FILENO, F_GETFL, 0);
  164|       |
  165|  3.41k|	cli_ses.retval = EXIT_SUCCESS; /* Assume it's clean if we don't get a
  166|       |									  specific exit status */
  167|  3.41k|	cli_ses.proxy_cmd_pid = proxy_cmd_pid;
  168|  3.41k|	TRACE(("proxy command PID='%d'", proxy_cmd_pid));
  169|       |
  170|       |	/* Auth */
  171|  3.41k|	cli_ses.lastprivkey = NULL;
  172|  3.41k|	cli_ses.lastauthtype = 0;
  173|  3.41k|	cli_ses.is_trivial_auth = 1;
  174|       |
  175|       |	/* For printing "remote host closed" for the user */
  176|  3.41k|	ses.remoteclosed = cli_remoteclosed;
  177|       |
  178|  3.41k|	ses.extra_session_cleanup = cli_session_cleanup;
  179|       |
  180|       |	/* packet handlers */
  181|  3.41k|	ses.packettypes = cli_packettypes;
  182|       |
  183|  3.41k|	ses.isserver = 0;
  184|       |
  185|  3.41k|#if DROPBEAR_KEX_FIRST_FOLLOWS
  186|  3.41k|	ses.send_kex_first_guess = cli_send_kex_first_guess;
  187|  3.41k|#endif
  188|       |
  189|  3.41k|}
cli-session.c:cli_remoteclosed:
  384|    861|static void cli_remoteclosed() {
  385|       |
  386|       |	/* XXX TODO perhaps print a friendlier message if we get this but have
  387|       |	 * already sent/received disconnect message(s) ??? */
  388|    861|	m_close(ses.sock_in);
  389|    861|	m_close(ses.sock_out);
  390|    861|	ses.sock_in = -1;
  391|    861|	ses.sock_out = -1;
  392|    861|	dropbear_exit("Remote closed the connection");
  393|    861|}
cli-session.c:cli_session_cleanup:
  349|  3.41k|static void cli_session_cleanup(void) {
  350|       |
  351|  3.41k|	if (!ses.init_done) {
  ------------------
  |  Branch (351:6): [True: 0, False: 3.41k]
  ------------------
  352|      0|		return;
  353|      0|	}
  354|       |
  355|  3.41k|	kill_proxy_command();
  356|       |
  357|       |	/* Set std{in,out,err} back to non-blocking - busybox ash dies nastily if
  358|       |	 * we don't revert the flags */
  359|       |	/* Ignore return value since there's nothing we can do */
  360|  3.41k|	(void)fcntl(cli_ses.stdincopy, F_SETFL, cli_ses.stdinflags);
  361|  3.41k|	(void)fcntl(cli_ses.stdoutcopy, F_SETFL, cli_ses.stdoutflags);
  362|  3.41k|	(void)fcntl(cli_ses.stderrcopy, F_SETFL, cli_ses.stderrflags);
  363|       |
  364|       |	/* Don't leak */
  365|  3.41k|	m_close(cli_ses.stdincopy);
  366|  3.41k|	m_close(cli_ses.stdoutcopy);
  367|  3.41k|	m_close(cli_ses.stderrcopy);
  368|       |
  369|  3.41k|	cli_tty_cleanup();
  370|  3.41k|	if (cli_ses.server_sig_algs) {
  ------------------
  |  Branch (370:6): [True: 0, False: 3.41k]
  ------------------
  371|      0|		buf_free(cli_ses.server_sig_algs);
  372|      0|	}
  373|  3.41k|}
cli-session.c:cli_send_kex_first_guess:
  143|  3.41k|static void cli_send_kex_first_guess() {
  144|  3.41k|	send_msg_kexdh_init();
  145|  3.41k|}
cli-session.c:cli_sessionloop:
  210|  94.1k|static void cli_sessionloop() {
  211|       |
  212|  94.1k|	TRACE2(("enter cli_sessionloop"))
  213|       |
  214|  94.1k|	if (ses.lastpacket == 0) {
  ------------------
  |  Branch (214:6): [True: 30.0k, False: 64.0k]
  ------------------
  215|  30.0k|		TRACE2(("exit cli_sessionloop: no real packets yet"))
  216|  30.0k|		return;
  217|  30.0k|	}
  218|       |
  219|  64.0k|	if (ses.lastpacket == SSH_MSG_KEXINIT && cli_ses.kex_state == KEX_NOTHING) {
  ------------------
  |  |   36|   128k|#define SSH_MSG_KEXINIT                20
  ------------------
  |  Branch (219:6): [True: 15.2k, False: 48.8k]
  |  Branch (219:43): [True: 2.38k, False: 12.9k]
  ------------------
  220|       |		/* We initiate the KEXDH. If DH wasn't the correct type, the KEXINIT
  221|       |		 * negotiation would have failed. */
  222|  2.38k|		if (!ses.kexstate.our_first_follows_matches) {
  ------------------
  |  Branch (222:7): [True: 2.38k, False: 0]
  ------------------
  223|  2.38k|			send_msg_kexdh_init();
  224|  2.38k|		}
  225|  2.38k|		cli_ses.kex_state = KEXDH_INIT_SENT;			
  226|  2.38k|		TRACE(("leave cli_sessionloop: done with KEXINIT_RCVD"))
  227|  2.38k|		return;
  228|  2.38k|	}
  229|       |
  230|       |	/* A KEX has finished, so we should go back to our KEX_NOTHING state */
  231|  61.7k|	if (cli_ses.kex_state != KEX_NOTHING && ses.kexstate.sentnewkeys) {
  ------------------
  |  Branch (231:6): [True: 14.8k, False: 46.8k]
  |  Branch (231:42): [True: 0, False: 14.8k]
  ------------------
  232|      0|		cli_ses.kex_state = KEX_NOTHING;
  233|      0|	}
  234|       |
  235|       |	/* We shouldn't do anything else if a KEX is in progress */
  236|  61.7k|	if (cli_ses.kex_state != KEX_NOTHING) {
  ------------------
  |  Branch (236:6): [True: 14.8k, False: 46.8k]
  ------------------
  237|  14.8k|		TRACE(("leave cli_sessionloop: kex_state != KEX_NOTHING"))
  238|  14.8k|		return;
  239|  14.8k|	}
  240|       |
  241|  46.8k|	if (ses.kexstate.donefirstkex == 0) {
  ------------------
  |  Branch (241:6): [True: 0, False: 46.8k]
  ------------------
  242|       |		/* We might reach here if we have partial packet reads or have
  243|       |		 * received SSG_MSG_IGNORE etc. Just skip it */
  244|      0|		TRACE2(("donefirstkex false\n"))
  245|      0|		return;
  246|      0|	}
  247|       |
  248|  46.8k|	switch (cli_ses.state) {
  249|       |
  250|    248|		case STATE_NOTHING:
  ------------------
  |  Branch (250:3): [True: 248, False: 46.5k]
  ------------------
  251|       |			/* We've got the transport layer sorted, we now need to request
  252|       |			 * userauth */
  253|    248|			send_msg_service_request(SSH_SERVICE_USERAUTH);
  ------------------
  |  |  108|    248|#define SSH_SERVICE_USERAUTH "ssh-userauth"
  ------------------
  254|       |			/* We aren't using any "implicit server authentication" methods,
  255|       |			so don't need to wait for a response for SSH_SERVICE_USERAUTH
  256|       |			before sending the auth messages (rfc4253 10) */
  257|    248|			cli_auth_getmethods();
  258|    248|			cli_ses.state = USERAUTH_REQ_SENT;
  259|    248|			TRACE(("leave cli_sessionloop: sent userauth methods req"))
  260|    248|			return;
  261|       |
  262|  46.5k|		case USERAUTH_REQ_SENT:
  ------------------
  |  Branch (262:3): [True: 46.5k, False: 248]
  ------------------
  263|  46.5k|			TRACE(("leave cli_sessionloop: waiting, req_sent"))
  264|  46.5k|			return;
  265|       |			
  266|      0|		case USERAUTH_FAIL_RCVD:
  ------------------
  |  Branch (266:3): [True: 0, False: 46.8k]
  ------------------
  267|      0|			if (cli_auth_try() == DROPBEAR_FAILURE) {
  ------------------
  |  |  112|      0|#define DROPBEAR_FAILURE -1
  ------------------
  |  Branch (267:8): [True: 0, False: 0]
  ------------------
  268|      0|				dropbear_exit("No auth methods could be used.");
  269|      0|			}
  270|      0|			cli_ses.state = USERAUTH_REQ_SENT;
  271|      0|			TRACE(("leave cli_sessionloop: cli_auth_try"))
  272|      0|			return;
  273|       |
  274|      0|		case USERAUTH_SUCCESS_RCVD:
  ------------------
  |  Branch (274:3): [True: 0, False: 46.8k]
  ------------------
  275|      0|#ifndef DISABLE_SYSLOG
  276|      0|			if (opts.usingsyslog) {
  ------------------
  |  Branch (276:8): [True: 0, False: 0]
  ------------------
  277|      0|				dropbear_log(LOG_INFO, "Authentication succeeded.");
  278|      0|			}
  279|      0|#endif
  280|       |
  281|      0|			if (cli_opts.backgrounded) {
  ------------------
  |  Branch (281:8): [True: 0, False: 0]
  ------------------
  282|      0|				int devnull;
  283|       |				/* keeping stdin open steals input from the terminal and
  284|       |				   is confusing, though stdout/stderr could be useful. */
  285|      0|				devnull = open(DROPBEAR_PATH_DEVNULL, O_RDONLY);
  ------------------
  |  |   53|      0|#define DROPBEAR_PATH_DEVNULL "/dev/null"
  ------------------
  286|      0|				if (devnull < 0) {
  ------------------
  |  Branch (286:9): [True: 0, False: 0]
  ------------------
  287|      0|					dropbear_exit("Opening /dev/null: %d %s",
  288|      0|							errno, strerror(errno));
  289|      0|				}
  290|      0|				dup2(devnull, STDIN_FILENO);
  291|      0|				if (daemon(0, 1) < 0) {
  ------------------
  |  Branch (291:9): [True: 0, False: 0]
  ------------------
  292|      0|					dropbear_exit("Backgrounding failed: %d %s", 
  293|      0|							errno, strerror(errno));
  294|      0|				}
  295|      0|			}
  296|       |			
  297|      0|#if DROPBEAR_CLI_NETCAT
  298|      0|			if (cli_opts.netcat_host) {
  ------------------
  |  Branch (298:8): [True: 0, False: 0]
  ------------------
  299|      0|				cli_send_netcat_request();
  300|      0|			} else 
  301|      0|#endif
  302|      0|			if (!cli_opts.no_cmd) {
  ------------------
  |  Branch (302:8): [True: 0, False: 0]
  ------------------
  303|      0|				cli_send_chansess_request();
  304|      0|			}
  305|       |
  306|      0|#if DROPBEAR_CLI_LOCALTCPFWD
  307|      0|			setup_localtcp();
  308|      0|#endif
  309|      0|#if DROPBEAR_CLI_REMOTETCPFWD
  310|      0|			setup_remotetcp();
  311|      0|#endif
  312|       |
  313|      0|			TRACE(("leave cli_sessionloop: running"))
  314|      0|			cli_ses.state = SESSION_RUNNING;
  315|      0|			return;
  316|       |
  317|      0|		case SESSION_RUNNING:
  ------------------
  |  Branch (317:3): [True: 0, False: 46.8k]
  ------------------
  318|      0|			if (ses.chancount < 1 && !cli_opts.no_cmd) {
  ------------------
  |  Branch (318:8): [True: 0, False: 0]
  |  Branch (318:29): [True: 0, False: 0]
  ------------------
  319|      0|				cli_finished();
  320|      0|			}
  321|       |
  322|      0|			if (cli_ses.winchange) {
  ------------------
  |  Branch (322:8): [True: 0, False: 0]
  ------------------
  323|      0|				cli_chansess_winchange();
  324|      0|			}
  325|      0|			return;
  326|       |
  327|       |		/* XXX more here needed */
  328|       |
  329|       |
  330|      0|	default:
  ------------------
  |  Branch (330:2): [True: 0, False: 46.8k]
  ------------------
  331|      0|		break;
  332|  46.8k|	}
  333|       |
  334|  46.8k|	TRACE2(("leave cli_sessionloop: fell out"))
  335|       |
  336|  46.8k|}
cli-session.c:send_msg_service_request:
  191|    248|static void send_msg_service_request(const char* servicename) {
  192|       |
  193|    248|	TRACE(("enter send_msg_service_request: servicename='%s'", servicename))
  194|       |
  195|    248|	CHECKCLEARTOWRITE();
  196|       |
  197|    248|	buf_putbyte(ses.writepayload, SSH_MSG_SERVICE_REQUEST);
  ------------------
  |  |   33|    248|#define SSH_MSG_SERVICE_REQUEST        5
  ------------------
  198|    248|	buf_putstring(ses.writepayload, servicename, strlen(servicename));
  199|       |
  200|    248|	encrypt_packet();
  201|    248|	TRACE(("leave send_msg_service_request"))
  202|    248|}
cli-session.c:cli_algos_initialise:
  475|  3.41k|static void cli_algos_initialise(void) {
  476|  3.41k|	algo_type *algo;
  477|  47.8k|	for (algo = sshkex; algo->name; algo++) {
  ------------------
  |  Branch (477:22): [True: 44.4k, False: 3.41k]
  ------------------
  478|  44.4k|		if (strcmp(algo->name, SSH_STRICT_KEX_S) == 0) {
  ------------------
  |  |  104|  44.4k|#define SSH_STRICT_KEX_S "kex-strict-s-v00@openssh.com"
  ------------------
  |  Branch (478:7): [True: 3.41k, False: 41.0k]
  ------------------
  479|  3.41k|			algo->usable = 0;
  480|  3.41k|		}
  481|  44.4k|	}
  482|  3.41k|}

buf_put_algolist_all:
  361|  27.3k|void buf_put_algolist_all(buffer * buf, const algo_type localalgos[], int useall) {
  362|  27.3k|	unsigned int i, len;
  363|  27.3k|	unsigned int donefirst = 0;
  364|  27.3k|	unsigned int startpos;
  365|       |
  366|  27.3k|	startpos = buf->pos;
  367|       |	/* Placeholder for length */
  368|  27.3k|	buf_putint(buf, 0); 
  369|   136k|	for (i = 0; localalgos[i].name != NULL; i++) {
  ------------------
  |  Branch (369:14): [True: 109k, False: 27.3k]
  ------------------
  370|   109k|		if (localalgos[i].usable || useall) {
  ------------------
  |  Branch (370:7): [True: 105k, False: 3.41k]
  |  Branch (370:31): [True: 0, False: 3.41k]
  ------------------
  371|   105k|			if (donefirst) {
  ------------------
  |  Branch (371:8): [True: 78.6k, False: 27.3k]
  ------------------
  372|  78.6k|				buf_putbyte(buf, ',');
  373|  78.6k|			}
  374|   105k|			donefirst = 1;
  375|   105k|			len = strlen(localalgos[i].name);
  376|   105k|			buf_putbytes(buf, (const unsigned char *) localalgos[i].name, len);
  377|   105k|		}
  378|   109k|	}
  379|       |	/* Fill out the length */
  380|  27.3k|	len = buf->pos - startpos - 4;
  381|  27.3k|	buf_setpos(buf, startpos);
  382|  27.3k|	buf_putint(buf, len);
  383|  27.3k|	TRACE(("algolist add %d '%.*s'", len, len, buf_getptr(buf, len)))
  384|  27.3k|	buf_incrwritepos(buf, len);
  385|  27.3k|}
buf_put_algolist:
  387|  27.3k|void buf_put_algolist(buffer * buf, const algo_type localalgos[]) {
  388|  27.3k|	buf_put_algolist_all(buf, localalgos, 0);
  389|  27.3k|}
buf_has_algo:
  433|  2.77k|int buf_has_algo(buffer *buf, const char *algo) {
  434|  2.77k|	unsigned char* algolist = NULL;
  435|  2.77k|	unsigned int orig_pos = buf->pos;
  436|  2.77k|	unsigned int len, remotecount, i;
  437|  2.77k|	const char *remotenames[MAX_PROPOSED_ALGO];
  438|  2.77k|	int ret = DROPBEAR_FAILURE;
  ------------------
  |  |  112|  2.77k|#define DROPBEAR_FAILURE -1
  ------------------
  439|       |
  440|  2.77k|	algolist = buf_getstring(buf, &len);
  441|  2.77k|	remotecount = MAX_PROPOSED_ALGO;
  ------------------
  |  |  243|  2.77k|#define MAX_PROPOSED_ALGO 50
  ------------------
  442|  2.77k|	get_algolist(algolist, len, remotenames, &remotecount);
  443|  14.1k|	for (i = 0; i < remotecount; i++)
  ------------------
  |  Branch (443:14): [True: 11.4k, False: 2.73k]
  ------------------
  444|  11.4k|	{
  445|  11.4k|		if (strcmp(remotenames[i], algo) == 0) {
  ------------------
  |  Branch (445:7): [True: 37, False: 11.4k]
  ------------------
  446|     37|			ret = DROPBEAR_SUCCESS;
  ------------------
  |  |  111|     37|#define DROPBEAR_SUCCESS 0
  ------------------
  447|     37|			break;
  448|     37|		}
  449|  11.4k|	}
  450|  2.77k|	if (algolist) {
  ------------------
  |  Branch (450:6): [True: 2.71k, False: 57]
  ------------------
  451|       |		m_free(algolist);
  ------------------
  |  |   24|  2.71k|#define m_free(X) do {m_free_direct(X); (X) = NULL;} while (0)
  |  |  ------------------
  |  |  |  Branch (24:61): [Folded, False: 2.71k]
  |  |  ------------------
  ------------------
  452|  2.71k|	}
  453|  2.77k|	buf_setpos(buf, orig_pos);
  454|  2.77k|	return ret;
  455|  2.77k|}
first_usable_algo:
  457|  6.83k|algo_type * first_usable_algo(algo_type algos[]) {
  458|  6.83k|	int i;
  459|  6.83k|	for (i = 0; algos[i].name != NULL; i++) {
  ------------------
  |  Branch (459:14): [True: 6.83k, False: 0]
  ------------------
  460|  6.83k|		if (algos[i].usable) {
  ------------------
  |  Branch (460:7): [True: 6.83k, False: 0]
  ------------------
  461|  6.83k|			return &algos[i];
  462|  6.83k|		}
  463|  6.83k|	}
  464|      0|	return NULL;
  465|  6.83k|}
buf_match_algo:
  473|  20.2k|		int kexguess2, int *goodguess) {
  474|  20.2k|	char * algolist = NULL;
  475|  20.2k|	const char *remotenames[MAX_PROPOSED_ALGO], *localnames[MAX_PROPOSED_ALGO];
  476|  20.2k|	unsigned int len;
  477|  20.2k|	unsigned int remotecount, localcount, clicount, servcount, i, j;
  478|  20.2k|	algo_type * ret = NULL;
  479|  20.2k|	const char **clinames, **servnames;
  480|       |
  481|  20.2k|	if (goodguess) {
  ------------------
  |  Branch (481:6): [True: 5.25k, False: 15.0k]
  ------------------
  482|  5.25k|		*goodguess = 0;
  483|  5.25k|	}
  484|       |
  485|       |	/* get the comma-separated list from the buffer ie "algo1,algo2,algo3" */
  486|  20.2k|	algolist = buf_getstring(buf, &len);
  487|  20.2k|	DEBUG3(("buf_match_algo: %s", algolist))
  488|  20.2k|	remotecount = MAX_PROPOSED_ALGO;
  ------------------
  |  |  243|  20.2k|#define MAX_PROPOSED_ALGO 50
  ------------------
  489|  20.2k|	get_algolist(algolist, len, remotenames, &remotecount);
  490|       |
  491|   103k|	for (i = 0; localalgos[i].name != NULL; i++) {
  ------------------
  |  Branch (491:14): [True: 83.0k, False: 20.2k]
  ------------------
  492|  83.0k|		if (localalgos[i].usable) {
  ------------------
  |  Branch (492:7): [True: 80.3k, False: 2.71k]
  ------------------
  493|  80.3k|			localnames[i] = localalgos[i].name;
  494|  80.3k|		} else {
  495|  2.71k|			localnames[i] = NULL;
  496|  2.71k|		}
  497|  83.0k|	}
  498|  20.2k|	localcount = i;
  499|       |
  500|  20.2k|	if (IS_DROPBEAR_SERVER) {
  ------------------
  |  |  383|  20.2k|#define IS_DROPBEAR_SERVER (ses.isserver == 1)
  |  |  ------------------
  |  |  |  Branch (383:28): [True: 0, False: 20.2k]
  |  |  ------------------
  ------------------
  501|      0|		clinames = remotenames;
  502|      0|		clicount = remotecount;
  503|      0|		servnames = localnames;
  504|      0|		servcount = localcount;
  505|  20.2k|	} else {
  506|  20.2k|		clinames = localnames;
  507|  20.2k|		clicount = localcount;
  508|  20.2k|		servnames = remotenames;
  509|  20.2k|		servcount = remotecount;
  510|  20.2k|	}
  511|       |
  512|       |	/* iterate and find the first match */
  513|  59.5k|	for (i = 0; i < clicount; i++) {
  ------------------
  |  Branch (513:14): [True: 58.8k, False: 661]
  ------------------
  514|   168k|		for (j = 0; j < servcount; j++) {
  ------------------
  |  Branch (514:15): [True: 129k, False: 39.2k]
  ------------------
  515|   129k|			if (!(servnames[j] && clinames[i])) {
  ------------------
  |  Branch (515:10): [True: 129k, False: 0]
  |  Branch (515:26): [True: 128k, False: 392]
  ------------------
  516|       |				/* unusable algos are NULL */
  517|    392|				continue;
  518|    392|			}
  519|   128k|			if (strcmp(servnames[j], clinames[i]) == 0) {
  ------------------
  |  Branch (519:8): [True: 19.6k, False: 109k]
  ------------------
  520|       |				/* set if it was a good guess */
  521|  19.6k|				if (goodguess != NULL) {
  ------------------
  |  Branch (521:9): [True: 5.06k, False: 14.5k]
  ------------------
  522|  5.06k|					if (kexguess2) {
  ------------------
  |  Branch (522:10): [True: 71, False: 4.99k]
  ------------------
  523|     71|						if (i == 0) {
  ------------------
  |  Branch (523:11): [True: 1, False: 70]
  ------------------
  524|      1|							*goodguess = 1;
  525|      1|						}
  526|  4.99k|					} else {
  527|  4.99k|						if (i == 0 && j == 0) {
  ------------------
  |  Branch (527:11): [True: 506, False: 4.48k]
  |  Branch (527:21): [True: 136, False: 370]
  ------------------
  528|    136|							*goodguess = 1;
  529|    136|						}
  530|  4.99k|					}
  531|  5.06k|				}
  532|       |				/* set the algo to return */
  533|  19.6k|				if (IS_DROPBEAR_SERVER) {
  ------------------
  |  |  383|  19.6k|#define IS_DROPBEAR_SERVER (ses.isserver == 1)
  |  |  ------------------
  |  |  |  Branch (383:28): [True: 0, False: 19.6k]
  |  |  ------------------
  ------------------
  534|      0|					ret = &localalgos[j];
  535|  19.6k|				} else {
  536|  19.6k|					ret = &localalgos[i];
  537|  19.6k|				}
  538|  19.6k|				goto out;
  539|  19.6k|			}
  540|   128k|		}
  541|  58.8k|	}
  542|       |
  543|  20.2k|out:
  544|       |	m_free(algolist);
  ------------------
  |  |   24|  20.2k|#define m_free(X) do {m_free_direct(X); (X) = NULL;} while (0)
  |  |  ------------------
  |  |  |  Branch (24:61): [Folded, False: 20.2k]
  |  |  ------------------
  ------------------
  545|  20.2k|	return ret;
  546|  20.2k|}
common-algo.c:void_cipher:
   43|  62.2k|		unsigned long len, void* UNUSED(cipher_state)) {
   44|  62.2k|	if (in != out) {
  ------------------
  |  Branch (44:6): [True: 0, False: 62.2k]
  ------------------
   45|      0|		memmove(out, in, len);
   46|      0|	}
   47|  62.2k|	return CRYPT_OK;
   48|  62.2k|}
common-algo.c:get_algolist:
  396|  22.9k|				const char* *ret_list, unsigned int *ret_count) {
  397|  22.9k|	unsigned int max_count = *ret_count;
  398|  22.9k|	unsigned int i;
  399|       |
  400|  22.9k|	if (*ret_count == 0) {
  ------------------
  |  Branch (400:6): [True: 0, False: 22.9k]
  ------------------
  401|      0|		return;
  402|      0|	}
  403|  22.9k|	if (algolist_len > MAX_PROPOSED_ALGO*(MAX_NAME_LEN+1)) {
  ------------------
  |  |  243|  22.9k|#define MAX_PROPOSED_ALGO 50
  ------------------
              	if (algolist_len > MAX_PROPOSED_ALGO*(MAX_NAME_LEN+1)) {
  ------------------
  |  |  239|  22.9k|#define MAX_NAME_LEN 64 /* maximum length of a protocol name, isn't
  ------------------
  |  Branch (403:6): [True: 5, False: 22.9k]
  ------------------
  404|      5|		*ret_count = 0;
  405|      5|	}
  406|       |
  407|       |	/* ret_list will contain a list of the strings parsed out.
  408|       |	   We will have at least one string (even if it's just "") */
  409|  22.9k|	ret_list[0] = algolist;
  410|  22.9k|	*ret_count = 1;
  411|   446k|	for (i = 0; i < algolist_len; i++) {
  ------------------
  |  Branch (411:14): [True: 423k, False: 22.9k]
  ------------------
  412|   423k|		if (algolist[i] == '\0') {
  ------------------
  |  Branch (412:7): [True: 45, False: 423k]
  ------------------
  413|       |			/* someone is trying something strange */
  414|     45|			*ret_count = 0;
  415|     45|			return;
  416|     45|		}
  417|       |
  418|   423k|		if (algolist[i] == ',') {
  ------------------
  |  Branch (418:7): [True: 21.2k, False: 402k]
  ------------------
  419|  21.2k|			if (*ret_count >= max_count) {
  ------------------
  |  Branch (419:8): [True: 2, False: 21.2k]
  ------------------
  420|      2|				dropbear_exit("Too many remote algorithms");
  421|      0|				*ret_count = 0;
  422|      0|				return;
  423|      2|			}
  424|  21.2k|			algolist[i] = '\0';
  425|  21.2k|			ret_list[*ret_count] = &algolist[i+1];
  426|  21.2k|			(*ret_count)++;
  427|  21.2k|		}
  428|   423k|	}
  429|  22.9k|}

chaninitialise:
   70|  3.41k|void chaninitialise(const struct ChanType *chantypes[]) {
   71|       |
   72|       |	/* may as well create space for a single channel */
   73|  3.41k|	ses.channels = (struct Channel**)m_malloc(sizeof(struct Channel*));
   74|  3.41k|	ses.chansize = 1;
   75|  3.41k|	ses.channels[0] = NULL;
   76|  3.41k|	ses.chancount = 0;
   77|       |
   78|  3.41k|	ses.chantypes = chantypes;
   79|       |
   80|  3.41k|#if DROPBEAR_LISTENERS
   81|  3.41k|	listeners_initialise();
   82|  3.41k|#endif
   83|       |
   84|  3.41k|}
chancleanup:
   87|  3.41k|void chancleanup() {
   88|       |
   89|  3.41k|	unsigned int i;
   90|       |
   91|  3.41k|	TRACE(("enter chancleanup"))
   92|  6.83k|	for (i = 0; i < ses.chansize; i++) {
  ------------------
  |  Branch (92:14): [True: 3.41k, False: 3.41k]
  ------------------
   93|  3.41k|		if (ses.channels[i] != NULL) {
  ------------------
  |  Branch (93:7): [True: 0, False: 3.41k]
  ------------------
   94|      0|			TRACE(("channel %d closing", i))
   95|      0|			remove_channel(ses.channels[i]);
   96|      0|		}
   97|  3.41k|	}
   98|       |	m_free(ses.channels);
  ------------------
  |  |   24|  3.41k|#define m_free(X) do {m_free_direct(X); (X) = NULL;} while (0)
  |  |  ------------------
  |  |  |  Branch (24:61): [Folded, False: 3.41k]
  |  |  ------------------
  ------------------
   99|  3.41k|	TRACE(("leave chancleanup"))
  100|  3.41k|}
channelio:
  199|  94.1k|void channelio(const fd_set *readfds, const fd_set *writefds) {
  200|       |
  201|       |	/* Listeners such as TCP, X11, agent-auth */
  202|  94.1k|	struct Channel *channel;
  203|  94.1k|	unsigned int i;
  204|       |
  205|       |	/* foreach channel */
  206|   188k|	for (i = 0; i < ses.chansize; i++) {
  ------------------
  |  Branch (206:14): [True: 94.1k, False: 94.1k]
  ------------------
  207|       |		/* Close checking only needs to occur for channels that had IO events */
  208|  94.1k|		int do_check_close = 0;
  209|       |
  210|  94.1k|		channel = ses.channels[i];
  211|  94.1k|		if (channel == NULL) {
  ------------------
  |  Branch (211:7): [True: 94.1k, False: 0]
  ------------------
  212|       |			/* only process in-use channels */
  213|  94.1k|			continue;
  214|  94.1k|		}
  215|       |
  216|       |		/* read data and send it over the wire */
  217|      0|		if (channel->readfd >= 0 && FD_ISSET(channel->readfd, readfds)) {
  ------------------
  |  Branch (217:7): [True: 0, False: 0]
  |  Branch (217:31): [True: 0, False: 0]
  ------------------
  218|      0|			TRACE(("send normal readfd"))
  219|      0|			send_msg_channel_data(channel, 0);
  220|      0|			do_check_close = 1;
  221|      0|		}
  222|       |
  223|       |		/* read stderr data and send it over the wire */
  224|      0|		if (ERRFD_IS_READ(channel) && channel->errfd >= 0 
  ------------------
  |  |   59|      0|#define ERRFD_IS_READ(channel) ((channel)->extrabuf == NULL)
  |  |  ------------------
  |  |  |  Branch (59:32): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (224:33): [True: 0, False: 0]
  ------------------
  225|      0|			&& FD_ISSET(channel->errfd, readfds)) {
  ------------------
  |  Branch (225:7): [True: 0, False: 0]
  ------------------
  226|      0|				TRACE(("send normal errfd"))
  227|      0|				send_msg_channel_data(channel, 1);
  228|      0|			do_check_close = 1;
  229|      0|		}
  230|       |
  231|       |		/* write to program/pipe stdin */
  232|      0|		if (channel->writefd >= 0 && FD_ISSET(channel->writefd, writefds)) {
  ------------------
  |  Branch (232:7): [True: 0, False: 0]
  |  Branch (232:32): [True: 0, False: 0]
  ------------------
  233|      0|			writechannel(channel, channel->writefd, channel->writebuf, NULL, NULL);
  234|      0|			do_check_close = 1;
  235|      0|		}
  236|       |		
  237|       |		/* stderr for client mode */
  238|      0|		if (ERRFD_IS_WRITE(channel)
  ------------------
  |  |   60|      0|#define ERRFD_IS_WRITE(channel) (!ERRFD_IS_READ(channel))
  |  |  ------------------
  |  |  |  |   59|      0|#define ERRFD_IS_READ(channel) ((channel)->extrabuf == NULL)
  |  |  ------------------
  |  |  |  Branch (60:33): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  239|      0|				&& channel->errfd >= 0 && FD_ISSET(channel->errfd, writefds)) {
  ------------------
  |  Branch (239:8): [True: 0, False: 0]
  |  Branch (239:31): [True: 0, False: 0]
  ------------------
  240|      0|			writechannel(channel, channel->errfd, channel->extrabuf, NULL, NULL);
  241|      0|			do_check_close = 1;
  242|      0|		}
  243|       |
  244|      0|		if (ses.channel_signal_pending) {
  ------------------
  |  Branch (244:7): [True: 0, False: 0]
  ------------------
  245|       |			/* SIGCHLD can change channel state for server sessions */
  246|      0|			do_check_close = 1;
  247|      0|		}
  248|       |	
  249|       |		/* handle any channel closing etc */
  250|      0|		if (do_check_close) {
  ------------------
  |  Branch (250:7): [True: 0, False: 0]
  ------------------
  251|      0|			check_close(channel);
  252|      0|		}
  253|      0|	}
  254|       |
  255|  94.1k|#if DROPBEAR_LISTENERS
  256|  94.1k|	handle_listeners(readfds);
  257|  94.1k|#endif
  258|  94.1k|}
setchannelfds:
  542|  97.5k|void setchannelfds(fd_set *readfds, fd_set *writefds, int allow_reads) {
  543|       |	
  544|  97.5k|	unsigned int i;
  545|  97.5k|	struct Channel * channel;
  546|       |	
  547|   195k|	for (i = 0; i < ses.chansize; i++) {
  ------------------
  |  Branch (547:14): [True: 97.5k, False: 97.5k]
  ------------------
  548|       |
  549|  97.5k|		channel = ses.channels[i];
  550|  97.5k|		if (channel == NULL) {
  ------------------
  |  Branch (550:7): [True: 97.5k, False: 0]
  ------------------
  551|  97.5k|			continue;
  552|  97.5k|		}
  553|       |
  554|       |		/* Stuff to put over the wire. 
  555|       |		Avoid queueing data to send if we're in the middle of a 
  556|       |		key re-exchange (!dataallowed), but still read from the 
  557|       |		FD if there's the possibility of "~."" to kill an 
  558|       |		interactive session (the read_mangler) */
  559|      0|		if (channel->transwindow > 0
  ------------------
  |  Branch (559:7): [True: 0, False: 0]
  ------------------
  560|      0|		   && ((ses.dataallowed && allow_reads) || channel->read_mangler)) {
  ------------------
  |  Branch (560:11): [True: 0, False: 0]
  |  Branch (560:30): [True: 0, False: 0]
  |  Branch (560:46): [True: 0, False: 0]
  ------------------
  561|       |
  562|      0|			if (channel->readfd >= 0) {
  ------------------
  |  Branch (562:8): [True: 0, False: 0]
  ------------------
  563|      0|				dropbear_fd_set(channel->readfd, readfds);
  564|      0|			}
  565|       |			
  566|      0|			if (ERRFD_IS_READ(channel) && channel->errfd >= 0) {
  ------------------
  |  |   59|      0|#define ERRFD_IS_READ(channel) ((channel)->extrabuf == NULL)
  |  |  ------------------
  |  |  |  Branch (59:32): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (566:34): [True: 0, False: 0]
  ------------------
  567|      0|					dropbear_fd_set(channel->errfd, readfds);
  568|      0|			}
  569|      0|		}
  570|       |
  571|       |		/* Stuff from the wire */
  572|      0|		if (channel->writefd >= 0 && cbuf_getused(channel->writebuf) > 0) {
  ------------------
  |  Branch (572:7): [True: 0, False: 0]
  |  Branch (572:32): [True: 0, False: 0]
  ------------------
  573|      0|				dropbear_fd_set(channel->writefd, writefds);
  574|      0|		}
  575|       |
  576|      0|		if (ERRFD_IS_WRITE(channel) && channel->errfd >= 0 
  ------------------
  |  |   60|      0|#define ERRFD_IS_WRITE(channel) (!ERRFD_IS_READ(channel))
  |  |  ------------------
  |  |  |  |   59|      0|#define ERRFD_IS_READ(channel) ((channel)->extrabuf == NULL)
  |  |  ------------------
  |  |  |  Branch (60:33): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (576:34): [True: 0, False: 0]
  ------------------
  577|      0|				&& cbuf_getused(channel->extrabuf) > 0) {
  ------------------
  |  Branch (577:8): [True: 0, False: 0]
  ------------------
  578|      0|				dropbear_fd_set(channel->errfd, writefds);
  579|      0|		}
  580|       |
  581|      0|	} /* foreach channel */
  582|       |
  583|  97.5k|#if DROPBEAR_LISTENERS
  584|  97.5k|	set_listener_fds(readfds);
  585|  97.5k|#endif
  586|       |
  587|  97.5k|}

send_msg_kexinit:
   51|  3.41k|void send_msg_kexinit() {
   52|       |
   53|  3.41k|	CHECKCLEARTOWRITE();
   54|  3.41k|	buf_putbyte(ses.writepayload, SSH_MSG_KEXINIT);
  ------------------
  |  |   36|  3.41k|#define SSH_MSG_KEXINIT                20
  ------------------
   55|       |
   56|       |	/* cookie */
   57|  3.41k|	genrandom(buf_getwriteptr(ses.writepayload, 16), 16);
   58|  3.41k|	buf_incrwritepos(ses.writepayload, 16);
   59|       |
   60|       |	/* kex algos */
   61|  3.41k|	buf_put_algolist(ses.writepayload, sshkex);
   62|       |
   63|       |	/* server_host_key_algorithms */
   64|  3.41k|	buf_put_algolist(ses.writepayload, sigalgs);
   65|       |
   66|       |	/* encryption_algorithms_client_to_server */
   67|  3.41k|	buf_put_algolist(ses.writepayload, sshciphers);
   68|       |
   69|       |	/* encryption_algorithms_server_to_client */
   70|  3.41k|	buf_put_algolist(ses.writepayload, sshciphers);
   71|       |
   72|       |	/* mac_algorithms_client_to_server */
   73|  3.41k|	buf_put_algolist(ses.writepayload, sshhashes);
   74|       |
   75|       |	/* mac_algorithms_server_to_client */
   76|  3.41k|	buf_put_algolist(ses.writepayload, sshhashes);
   77|       |
   78|       |
   79|       |	/* compression_algorithms_client_to_server */
   80|  3.41k|	buf_put_algolist(ses.writepayload, ses.compress_algos_c2s);
   81|       |
   82|       |	/* compression_algorithms_server_to_client */
   83|  3.41k|	buf_put_algolist(ses.writepayload, ses.compress_algos_s2c);
   84|       |
   85|       |	/* languages_client_to_server */
   86|  3.41k|	buf_putstring(ses.writepayload, "", 0);
   87|       |
   88|       |	/* languages_server_to_client */
   89|  3.41k|	buf_putstring(ses.writepayload, "", 0);
   90|       |
   91|       |	/* first_kex_packet_follows */
   92|  3.41k|	buf_putbyte(ses.writepayload, (ses.send_kex_first_guess != NULL));
   93|       |
   94|       |	/* reserved unit32 */
   95|  3.41k|	buf_putint(ses.writepayload, 0);
   96|       |
   97|       |	/* set up transmitted kex packet buffer for hashing. 
   98|       |	 * This is freed after the end of the kex */
   99|  3.41k|	ses.transkexinit = buf_newcopy(ses.writepayload);
  100|       |
  101|  3.41k|	encrypt_packet();
  102|  3.41k|	ses.dataallowed = 0; /* don't send other packets during kex */
  103|       |
  104|  3.41k|	ses.kexstate.sentkexinit = 1;
  105|       |
  106|  3.41k|	ses.newkeys = (struct key_context*)m_malloc(sizeof(struct key_context));
  107|       |
  108|  3.41k|	if (ses.send_kex_first_guess) {
  ------------------
  |  Branch (108:6): [True: 3.41k, False: 0]
  ------------------
  109|  3.41k|		ses.newkeys->algo_kex = first_usable_algo(sshkex)->data;
  110|  3.41k|		ses.newkeys->algo_signature = first_usable_algo(sigalgs)->val;
  111|  3.41k|		ses.newkeys->algo_hostkey = signkey_type_from_signature(ses.newkeys->algo_signature);
  112|  3.41k|		ses.send_kex_first_guess();
  113|  3.41k|	}
  114|       |
  115|  3.41k|	TRACE(("DATAALLOWED=0"))
  116|  3.41k|	TRACE(("-> KEXINIT"))
  117|       |
  118|  3.41k|}
kexfirstinitialise:
  230|  3.41k|void kexfirstinitialise() {
  231|  3.41k|	kex_setup_compress();
  232|  3.41k|	kexinitialise();
  233|  3.41k|}
recv_msg_kexinit:
  492|  2.77k|void recv_msg_kexinit() {
  493|       |	
  494|  2.77k|	unsigned int kexhashbuf_len = 0;
  495|  2.77k|	unsigned int remote_ident_len = 0;
  496|  2.77k|	unsigned int local_ident_len = 0;
  497|       |
  498|  2.77k|	TRACE(("<- KEXINIT"))
  499|  2.77k|	TRACE(("enter recv_msg_kexinit"))
  500|       |	
  501|  2.77k|	if (!ses.kexstate.sentkexinit) {
  ------------------
  |  Branch (501:6): [True: 0, False: 2.77k]
  ------------------
  502|       |		/* we need to send a kex packet */
  503|      0|		send_msg_kexinit();
  504|      0|		TRACE(("continue recv_msg_kexinit: sent kexinit"))
  505|      0|	}
  506|       |
  507|       |	/* "Once a party has sent a SSH_MSG_KEXINIT message ...
  508|       |	further SSH_MSG_KEXINIT messages MUST NOT be sent" */
  509|  2.77k|	if (ses.kexstate.recvkexinit) {
  ------------------
  |  Branch (509:6): [True: 0, False: 2.77k]
  ------------------
  510|      0|		dropbear_exit("Unexpected KEXINIT");
  511|      0|	}
  512|       |
  513|       |	/* start the kex hash */
  514|  2.77k|	local_ident_len = strlen(LOCAL_IDENT);
  ------------------
  |  |   14|  2.77k|#define LOCAL_IDENT "SSH-2.0-dropbear" IDENT_VERSION_PART
  |  |  ------------------
  |  |  |  |   12|  2.77k|#define IDENT_VERSION_PART "_" DROPBEAR_VERSION
  |  |  |  |  ------------------
  |  |  |  |  |  |    7|  2.77k|#define DROPBEAR_VERSION "2026.94"
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  515|  2.77k|	remote_ident_len = strlen(ses.remoteident);
  516|       |
  517|  2.77k|	kexhashbuf_len = local_ident_len + remote_ident_len
  518|  2.77k|		+ ses.transkexinit->len + ses.payload->len
  519|  2.77k|		+ KEXHASHBUF_MAX_INTS;
  ------------------
  |  |  300|  2.77k|#define KEXHASHBUF_MAX_INTS (MAX_PUBKEY_SIZE + MAX_KEX_PARTS)
  |  |  ------------------
  |  |  |  |  271|  2.77k|#define MAX_PUBKEY_SIZE 600
  |  |  ------------------
  |  |               #define KEXHASHBUF_MAX_INTS (MAX_PUBKEY_SIZE + MAX_KEX_PARTS)
  |  |  ------------------
  |  |  |  |  284|  2.77k|#define MAX_KEX_PARTS (2*4 + 1184 + 1088 + 32*2 + 68)
  |  |  ------------------
  ------------------
  520|       |
  521|  2.77k|	ses.kexhashbuf = buf_new(kexhashbuf_len);
  522|       |
  523|  2.77k|	if (IS_DROPBEAR_CLIENT) {
  ------------------
  |  |  384|  2.77k|#define IS_DROPBEAR_CLIENT (ses.isserver == 0)
  |  |  ------------------
  |  |  |  Branch (384:28): [True: 2.77k, False: 0]
  |  |  ------------------
  ------------------
  524|       |
  525|       |		/* read the peer's choice of algos */
  526|  2.77k|		read_kex_algos();
  527|       |
  528|       |		/* V_C, the client's version string (CR and NL excluded) */
  529|  2.77k|		buf_putstring(ses.kexhashbuf, LOCAL_IDENT, local_ident_len);
  ------------------
  |  |   14|  2.77k|#define LOCAL_IDENT "SSH-2.0-dropbear" IDENT_VERSION_PART
  |  |  ------------------
  |  |  |  |   12|  2.77k|#define IDENT_VERSION_PART "_" DROPBEAR_VERSION
  |  |  |  |  ------------------
  |  |  |  |  |  |    7|  2.77k|#define DROPBEAR_VERSION "2026.94"
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  530|       |		/* V_S, the server's version string (CR and NL excluded) */
  531|  2.77k|		buf_putstring(ses.kexhashbuf, ses.remoteident, remote_ident_len);
  532|       |
  533|       |		/* I_C, the payload of the client's SSH_MSG_KEXINIT */
  534|  2.77k|		buf_putstring(ses.kexhashbuf,
  535|  2.77k|			(const char*)ses.transkexinit->data, ses.transkexinit->len);
  536|       |		/* I_S, the payload of the server's SSH_MSG_KEXINIT */
  537|  2.77k|		buf_setpos(ses.payload, ses.payload_beginning);
  538|  2.77k|		buf_putstring(ses.kexhashbuf,
  539|  2.77k|			(const char*)buf_getptr(ses.payload, ses.payload->len-ses.payload->pos),
  540|  2.77k|			ses.payload->len-ses.payload->pos);
  541|  2.77k|		ses.requirenext = SSH_MSG_KEXDH_REPLY;
  ------------------
  |  |   39|  2.77k|#define SSH_MSG_KEXDH_REPLY            31
  ------------------
  542|  2.77k|	} else {
  543|       |		/* SERVER */
  544|       |
  545|       |		/* read the peer's choice of algos */
  546|      0|		read_kex_algos();
  547|       |		/* V_C, the client's version string (CR and NL excluded) */
  548|      0|		buf_putstring(ses.kexhashbuf, ses.remoteident, remote_ident_len);
  549|       |		/* V_S, the server's version string (CR and NL excluded) */
  550|      0|		buf_putstring(ses.kexhashbuf, LOCAL_IDENT, local_ident_len);
  ------------------
  |  |   14|      0|#define LOCAL_IDENT "SSH-2.0-dropbear" IDENT_VERSION_PART
  |  |  ------------------
  |  |  |  |   12|      0|#define IDENT_VERSION_PART "_" DROPBEAR_VERSION
  |  |  |  |  ------------------
  |  |  |  |  |  |    7|      0|#define DROPBEAR_VERSION "2026.94"
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  551|       |
  552|       |		/* I_C, the payload of the client's SSH_MSG_KEXINIT */
  553|      0|		buf_setpos(ses.payload, ses.payload_beginning);
  554|      0|		buf_putstring(ses.kexhashbuf, 
  555|      0|			(const char*)buf_getptr(ses.payload, ses.payload->len-ses.payload->pos),
  556|      0|			ses.payload->len-ses.payload->pos);
  557|       |
  558|       |		/* I_S, the payload of the server's SSH_MSG_KEXINIT */
  559|      0|		buf_putstring(ses.kexhashbuf,
  560|      0|			(const char*)ses.transkexinit->data, ses.transkexinit->len);
  561|       |
  562|      0|		ses.requirenext = SSH_MSG_KEXDH_INIT;
  ------------------
  |  |   38|      0|#define SSH_MSG_KEXDH_INIT             30
  ------------------
  563|      0|	}
  564|       |
  565|  2.77k|	buf_free(ses.transkexinit);
  566|  2.77k|	ses.transkexinit = NULL;
  567|       |	/* the rest of ses.kexhashbuf will be done after DH exchange */
  568|       |
  569|  2.77k|	ses.kexstate.recvkexinit = 1;
  570|       |
  571|  2.77k|	if (ses.kexstate.strict_kex && !ses.kexstate.donefirstkex && ses.recvseq != 1) {
  ------------------
  |  Branch (571:6): [True: 0, False: 2.77k]
  |  Branch (571:33): [True: 0, False: 0]
  |  Branch (571:63): [True: 0, False: 0]
  ------------------
  572|      0|		dropbear_exit("First packet wasn't kexinit");
  573|      0|	}
  574|       |
  575|  2.77k|	TRACE(("leave recv_msg_kexinit"))
  576|  2.77k|}
finish_kexhashbuf:
  579|  1.35k|void finish_kexhashbuf(void) {
  580|  1.35k|	hash_state hs;
  581|  1.35k|	const struct ltc_hash_descriptor *hash_desc = ses.newkeys->algo_kex->hash_desc;
  582|       |
  583|  1.35k|	hash_desc->init(&hs);
  584|  1.35k|	buf_setpos(ses.kexhashbuf, 0);
  585|  1.35k|	hash_desc->process(&hs, buf_getptr(ses.kexhashbuf, ses.kexhashbuf->len),
  586|  1.35k|			ses.kexhashbuf->len);
  587|  1.35k|	ses.hash = buf_new(hash_desc->hashsize);
  588|  1.35k|	hash_desc->done(&hs, buf_getwriteptr(ses.hash, hash_desc->hashsize));
  589|  1.35k|	buf_setlen(ses.hash, hash_desc->hashsize);
  590|       |
  591|       |#if defined(DEBUG_KEXHASH) && DEBUG_TRACE
  592|       |	if (!debug_trace) {
  593|       |		printhex("kexhashbuf", ses.kexhashbuf->data, ses.kexhashbuf->len);
  594|       |		printhex("kexhash", ses.hash->data, ses.hash->len);
  595|       |	}
  596|       |#endif
  597|       |
  598|  1.35k|	buf_burn_free(ses.kexhashbuf);
  599|  1.35k|	m_burn(&hs, sizeof(hash_state));
  600|  1.35k|	ses.kexhashbuf = NULL;
  601|       |	
  602|       |	/* first time around, we set the session_id to H */
  603|  1.35k|	if (ses.session_id == NULL) {
  ------------------
  |  Branch (603:6): [True: 1.35k, False: 0]
  ------------------
  604|       |		/* create the session_id, this never needs freeing */
  605|  1.35k|		ses.session_id = buf_newcopy(ses.hash);
  606|  1.35k|	}
  607|  1.35k|}
common-kex.c:kex_setup_compress:
  204|  3.41k|static void kex_setup_compress(void) {
  205|  3.41k|#ifdef DISABLE_ZLIB
  206|  3.41k|	ses.compress_algos_c2s = ssh_nocompress;
  207|  3.41k|	ses.compress_algos_s2c = ssh_nocompress;
  208|       |#else
  209|       |
  210|       |	if (!opts.compression) {
  211|       |		ses.compress_algos_c2s = ssh_nocompress;
  212|       |		ses.compress_algos_s2c = ssh_nocompress;
  213|       |		return;
  214|       |	}
  215|       |
  216|       |	if (IS_DROPBEAR_CLIENT) {
  217|       |		/* TODO: should c2s in dbclient be disabled?
  218|       |		 * Current Dropbear server disables it. Disabling it also
  219|       |		 * lets DROPBEAR_CLI_IMMEDIATE_AUTH work (see comment there) */
  220|       |		ses.compress_algos_c2s = ssh_compress;
  221|       |		ses.compress_algos_s2c = ssh_compress;
  222|       |	} else {
  223|       |		ses.compress_algos_c2s = ssh_nocompress;
  224|       |		ses.compress_algos_s2c = ssh_compress;
  225|       |	}
  226|       |#endif
  227|  3.41k|}
common-kex.c:kexinitialise:
  236|  3.41k|static void kexinitialise() {
  237|       |
  238|  3.41k|	TRACE(("kexinitialise()"))
  239|       |
  240|       |	/* sent/recv'd MSG_KEXINIT */
  241|  3.41k|	ses.kexstate.sentkexinit = 0;
  242|  3.41k|	ses.kexstate.recvkexinit = 0;
  243|       |
  244|       |	/* sent/recv'd MSG_NEWKEYS */
  245|  3.41k|	ses.kexstate.recvnewkeys = 0;
  246|  3.41k|	ses.kexstate.sentnewkeys = 0;
  247|       |
  248|       |	/* first_packet_follows */
  249|  3.41k|	ses.kexstate.them_firstfollows = 0;
  250|       |
  251|  3.41k|	ses.kexstate.datatrans = 0;
  252|  3.41k|	ses.kexstate.datarecv = 0;
  253|       |
  254|  3.41k|	ses.kexstate.our_first_follows_matches = 0;
  255|       |
  256|  3.41k|	ses.kexstate.lastkextime = monotonic_now();
  257|       |
  258|  3.41k|}
common-kex.c:read_kex_algos:
  611|  2.77k|static void read_kex_algos() {
  612|       |
  613|       |	/* for asymmetry */
  614|  2.77k|	algo_type * c2s_hash_algo = NULL;
  615|  2.77k|	algo_type * s2c_hash_algo = NULL;
  616|  2.77k|	algo_type * c2s_cipher_algo = NULL;
  617|  2.77k|	algo_type * s2c_cipher_algo = NULL;
  618|  2.77k|	algo_type * c2s_comp_algo = NULL;
  619|  2.77k|	algo_type * s2c_comp_algo = NULL;
  620|       |	/* the generic one */
  621|  2.77k|	algo_type * algo = NULL;
  622|       |
  623|       |	/* which algo couldn't match */
  624|  2.77k|	char * erralgo = NULL;
  625|       |
  626|  2.77k|	int goodguess = 0;
  627|  2.77k|	int allgood = 1; /* we AND this with each goodguess and see if its still
  628|       |						true after */
  629|  2.77k|	int kexguess2 = 0;
  630|       |
  631|  2.77k|	buf_incrpos(ses.payload, 16); /* start after the cookie */
  632|       |
  633|  2.77k|	memset(ses.newkeys, 0x0, sizeof(*ses.newkeys));
  634|       |
  635|       |	/* kex_algorithms */
  636|  2.77k|#if DROPBEAR_KEXGUESS2
  637|  2.77k|	if (buf_has_algo(ses.payload, KEXGUESS2_ALGO_NAME) == DROPBEAR_SUCCESS) {
  ------------------
  |  |  137|  2.77k|#define KEXGUESS2_ALGO_NAME "kexguess2@matt.ucc.asn.au"
  ------------------
              	if (buf_has_algo(ses.payload, KEXGUESS2_ALGO_NAME) == DROPBEAR_SUCCESS) {
  ------------------
  |  |  111|  2.77k|#define DROPBEAR_SUCCESS 0
  ------------------
  |  Branch (637:6): [True: 37, False: 2.74k]
  ------------------
  638|     37|		kexguess2 = 1;
  639|     37|	}
  640|  2.77k|#endif
  641|       |
  642|  2.77k|#if DROPBEAR_EXT_INFO
  643|       |	/* Determine if SSH_MSG_EXT_INFO messages should be sent.
  644|       |	Should be done for the first key exchange. Only required on server side
  645|       |    for server-sig-algs */
  646|  2.77k|	if (IS_DROPBEAR_SERVER) {
  ------------------
  |  |  383|  2.77k|#define IS_DROPBEAR_SERVER (ses.isserver == 1)
  |  |  ------------------
  |  |  |  Branch (383:28): [True: 0, False: 2.77k]
  |  |  ------------------
  ------------------
  647|      0|		if (!ses.kexstate.donefirstkex) {
  ------------------
  |  Branch (647:7): [True: 0, False: 0]
  ------------------
  648|      0|			if (buf_has_algo(ses.payload, SSH_EXT_INFO_C) == DROPBEAR_SUCCESS) {
  ------------------
  |  |  100|      0|#define SSH_EXT_INFO_C "ext-info-c"
  ------------------
              			if (buf_has_algo(ses.payload, SSH_EXT_INFO_C) == DROPBEAR_SUCCESS) {
  ------------------
  |  |  111|      0|#define DROPBEAR_SUCCESS 0
  ------------------
  |  Branch (648:8): [True: 0, False: 0]
  ------------------
  649|      0|				ses.allow_ext_info = 1;
  650|      0|			}
  651|      0|		}
  652|      0|	}
  653|  2.77k|#endif
  654|       |
  655|  2.77k|	if (!ses.kexstate.donefirstkex) {
  ------------------
  |  Branch (655:6): [True: 0, False: 2.77k]
  ------------------
  656|      0|		const char* strict_name;
  657|      0|		if (IS_DROPBEAR_CLIENT) {
  ------------------
  |  |  384|      0|#define IS_DROPBEAR_CLIENT (ses.isserver == 0)
  |  |  ------------------
  |  |  |  Branch (384:28): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  658|      0|			strict_name = SSH_STRICT_KEX_S;
  ------------------
  |  |  104|      0|#define SSH_STRICT_KEX_S "kex-strict-s-v00@openssh.com"
  ------------------
  659|      0|		} else {
  660|      0|			strict_name = SSH_STRICT_KEX_C;
  ------------------
  |  |  105|      0|#define SSH_STRICT_KEX_C "kex-strict-c-v00@openssh.com"
  ------------------
  661|      0|		}
  662|      0|		if (buf_has_algo(ses.payload, strict_name) == DROPBEAR_SUCCESS) {
  ------------------
  |  |  111|      0|#define DROPBEAR_SUCCESS 0
  ------------------
  |  Branch (662:7): [True: 0, False: 0]
  ------------------
  663|      0|			ses.kexstate.strict_kex = 1;
  664|      0|		}
  665|      0|	}
  666|       |
  667|  2.77k|	algo = buf_match_algo(ses.payload, sshkex, kexguess2, &goodguess);
  668|  2.77k|	allgood &= goodguess;
  669|  2.77k|	if (algo == NULL || algo->data == NULL) {
  ------------------
  |  Branch (669:6): [True: 237, False: 2.54k]
  |  Branch (669:22): [True: 6, False: 2.53k]
  ------------------
  670|       |		/* kexguess2, ext-info-c, ext-info-s should not match negotiation */
  671|    180|		erralgo = "kex";
  672|    180|		goto error;
  673|    180|	}
  674|  2.59k|	TRACE(("kexguess2 %d", kexguess2))
  675|  2.59k|	DEBUG3(("kex algo %s", algo->name))
  676|  2.59k|	ses.newkeys->algo_kex = algo->data;
  677|       |
  678|       |	/* server_host_key_algorithms */
  679|  2.59k|	algo = buf_match_algo(ses.payload, sigalgs, kexguess2, &goodguess);
  680|  2.59k|	allgood &= goodguess;
  681|  2.59k|	if (algo == NULL) {
  ------------------
  |  Branch (681:6): [True: 2, False: 2.59k]
  ------------------
  682|      2|		erralgo = "hostkey";
  683|      2|		goto error;
  684|      2|	}
  685|  2.59k|	DEBUG2(("hostkey algo %s", algo->name))
  686|  2.59k|	ses.newkeys->algo_signature = algo->val;
  687|  2.59k|	ses.newkeys->algo_hostkey = signkey_type_from_signature(ses.newkeys->algo_signature);
  688|       |
  689|       |	/* encryption_algorithms_client_to_server */
  690|  2.59k|	c2s_cipher_algo = buf_match_algo(ses.payload, sshciphers, 0, NULL);
  691|  2.59k|	if (c2s_cipher_algo == NULL) {
  ------------------
  |  Branch (691:6): [True: 3, False: 2.59k]
  ------------------
  692|      3|		erralgo = "enc c->s";
  693|      3|		goto error;
  694|      3|	}
  695|  2.59k|	DEBUG2(("enc  c2s is %s", c2s_cipher_algo->name))
  696|       |
  697|       |	/* encryption_algorithms_server_to_client */
  698|  2.59k|	s2c_cipher_algo = buf_match_algo(ses.payload, sshciphers, 0, NULL);
  699|  2.59k|	if (s2c_cipher_algo == NULL) {
  ------------------
  |  Branch (699:6): [True: 3, False: 2.59k]
  ------------------
  700|      3|		erralgo = "enc s->c";
  701|      3|		goto error;
  702|      3|	}
  703|  2.59k|	DEBUG2(("enc  s2c is %s", s2c_cipher_algo->name))
  704|       |
  705|       |	/* mac_algorithms_client_to_server */
  706|  2.59k|	c2s_hash_algo = buf_match_algo(ses.payload, sshhashes, 0, NULL);
  707|  2.59k|#if DROPBEAR_AEAD_MODE
  708|  2.59k|	if (((struct dropbear_cipher_mode*)c2s_cipher_algo->mode)->aead_crypt != NULL) {
  ------------------
  |  Branch (708:6): [True: 252, False: 2.33k]
  ------------------
  709|    252|		c2s_hash_algo = NULL;
  710|    252|	} else
  711|  2.33k|#endif
  712|  2.33k|	if (c2s_hash_algo == NULL) {
  ------------------
  |  Branch (712:6): [True: 4, False: 2.33k]
  ------------------
  713|      4|		erralgo = "mac c->s";
  714|      4|		goto error;
  715|      4|	}
  716|  2.58k|	DEBUG2(("hmac c2s is %s", c2s_hash_algo ? c2s_hash_algo->name : "<implicit>"))
  717|       |
  718|       |	/* mac_algorithms_server_to_client */
  719|  2.58k|	s2c_hash_algo = buf_match_algo(ses.payload, sshhashes, 0, NULL);
  720|  2.58k|#if DROPBEAR_AEAD_MODE
  721|  2.58k|	if (((struct dropbear_cipher_mode*)s2c_cipher_algo->mode)->aead_crypt != NULL) {
  ------------------
  |  Branch (721:6): [True: 229, False: 2.35k]
  ------------------
  722|    229|		s2c_hash_algo = NULL;
  723|    229|	} else
  724|  2.35k|#endif
  725|  2.35k|	if (s2c_hash_algo == NULL) {
  ------------------
  |  Branch (725:6): [True: 3, False: 2.35k]
  ------------------
  726|      3|		erralgo = "mac s->c";
  727|      3|		goto error;
  728|      3|	}
  729|  2.58k|	DEBUG2(("hmac s2c is %s", s2c_hash_algo ? s2c_hash_algo->name : "<implicit>"))
  730|       |
  731|       |	/* compression_algorithms_client_to_server */
  732|  2.58k|	c2s_comp_algo = buf_match_algo(ses.payload, ses.compress_algos_c2s, 0, NULL);
  733|  2.58k|	if (c2s_comp_algo == NULL) {
  ------------------
  |  Branch (733:6): [True: 6, False: 2.57k]
  ------------------
  734|      6|		erralgo = "comp c->s";
  735|      6|		goto error;
  736|      6|	}
  737|  2.57k|	DEBUG2(("comp c2s is %s", c2s_comp_algo->name))
  738|       |
  739|       |	/* compression_algorithms_server_to_client */
  740|  2.57k|	s2c_comp_algo = buf_match_algo(ses.payload, ses.compress_algos_s2c, 0, NULL);
  741|  2.57k|	if (s2c_comp_algo == NULL) {
  ------------------
  |  Branch (741:6): [True: 3, False: 2.57k]
  ------------------
  742|      3|		erralgo = "comp s->c";
  743|      3|		goto error;
  744|      3|	}
  745|  2.57k|	DEBUG2(("comp s2c is %s", s2c_comp_algo->name))
  746|       |
  747|       |	/* languages_client_to_server */
  748|  2.57k|	buf_eatstring(ses.payload);
  749|       |
  750|       |	/* languages_server_to_client */
  751|  2.57k|	buf_eatstring(ses.payload);
  752|       |
  753|       |	/* their first_kex_packet_follows */
  754|  2.57k|	if (buf_getbool(ses.payload)) {
  ------------------
  |  Branch (754:6): [True: 174, False: 2.40k]
  ------------------
  755|    174|		TRACE(("them kex firstfollows. allgood %d", allgood))
  756|    174|		ses.kexstate.them_firstfollows = 1;
  757|       |		/* if the guess wasn't good, we ignore the packet sent */
  758|    174|		if (!allgood) {
  ------------------
  |  Branch (758:7): [True: 174, False: 0]
  ------------------
  759|    174|			ses.ignorenext = 1;
  760|    174|		}
  761|    174|	}
  762|       |
  763|       |	/* Handle the asymmetry */
  764|  2.57k|	if (IS_DROPBEAR_CLIENT) {
  ------------------
  |  |  384|  2.57k|#define IS_DROPBEAR_CLIENT (ses.isserver == 0)
  |  |  ------------------
  |  |  |  Branch (384:28): [True: 2.39k, False: 184]
  |  |  ------------------
  ------------------
  765|  2.39k|		ses.newkeys->recv.algo_crypt = 
  766|  2.39k|			(struct dropbear_cipher*)s2c_cipher_algo->data;
  767|  2.39k|		ses.newkeys->trans.algo_crypt = 
  768|  2.39k|			(struct dropbear_cipher*)c2s_cipher_algo->data;
  769|  2.39k|		ses.newkeys->recv.crypt_mode = 
  770|  2.39k|			(struct dropbear_cipher_mode*)s2c_cipher_algo->mode;
  771|  2.39k|		ses.newkeys->trans.crypt_mode =
  772|  2.39k|			(struct dropbear_cipher_mode*)c2s_cipher_algo->mode;
  773|  2.39k|		ses.newkeys->recv.algo_mac = 
  774|  2.39k|#if DROPBEAR_AEAD_MODE
  775|  2.39k|			s2c_hash_algo == NULL ? ses.newkeys->recv.crypt_mode->aead_mac :
  ------------------
  |  Branch (775:4): [True: 223, False: 2.16k]
  ------------------
  776|  2.39k|#endif
  777|  2.39k|			(struct dropbear_hash*)s2c_hash_algo->data;
  778|  2.39k|		ses.newkeys->trans.algo_mac = 
  779|  2.39k|#if DROPBEAR_AEAD_MODE
  780|  2.39k|			c2s_hash_algo == NULL ? ses.newkeys->trans.crypt_mode->aead_mac :
  ------------------
  |  Branch (780:4): [True: 245, False: 2.14k]
  ------------------
  781|  2.39k|#endif
  782|  2.39k|			(struct dropbear_hash*)c2s_hash_algo->data;
  783|  2.39k|		ses.newkeys->recv.algo_comp = s2c_comp_algo->val;
  784|  2.39k|		ses.newkeys->trans.algo_comp = c2s_comp_algo->val;
  785|  2.39k|	} else {
  786|       |		/* SERVER */
  787|    184|		ses.newkeys->recv.algo_crypt = 
  788|    184|			(struct dropbear_cipher*)c2s_cipher_algo->data;
  789|    184|		ses.newkeys->trans.algo_crypt = 
  790|    184|			(struct dropbear_cipher*)s2c_cipher_algo->data;
  791|    184|		ses.newkeys->recv.crypt_mode =
  792|    184|			(struct dropbear_cipher_mode*)c2s_cipher_algo->mode;
  793|    184|		ses.newkeys->trans.crypt_mode =
  794|    184|			(struct dropbear_cipher_mode*)s2c_cipher_algo->mode;
  795|    184|		ses.newkeys->recv.algo_mac = 
  796|    184|#if DROPBEAR_AEAD_MODE
  797|    184|			c2s_hash_algo == NULL ? ses.newkeys->recv.crypt_mode->aead_mac :
  ------------------
  |  Branch (797:4): [True: 0, False: 184]
  ------------------
  798|    184|#endif
  799|    184|			(struct dropbear_hash*)c2s_hash_algo->data;
  800|    184|		ses.newkeys->trans.algo_mac = 
  801|    184|#if DROPBEAR_AEAD_MODE
  802|    184|			s2c_hash_algo == NULL ? ses.newkeys->trans.crypt_mode->aead_mac :
  ------------------
  |  Branch (802:4): [True: 0, False: 184]
  ------------------
  803|    184|#endif
  804|    184|			(struct dropbear_hash*)s2c_hash_algo->data;
  805|    184|		ses.newkeys->recv.algo_comp = c2s_comp_algo->val;
  806|    184|		ses.newkeys->trans.algo_comp = s2c_comp_algo->val;
  807|    184|	}
  808|       |
  809|  2.57k|#if DROPBEAR_FUZZ
  810|  2.57k|	if (fuzz.fuzzing) {
  ------------------
  |  Branch (810:6): [True: 2.39k, False: 184]
  ------------------
  811|  2.39k|		fuzz_kex_fakealgos();
  812|  2.39k|	}
  813|  2.57k|#endif
  814|       |
  815|       |	/* reserved for future extensions */
  816|  2.57k|	buf_getint(ses.payload);
  817|       |
  818|  2.57k|	if (ses.send_kex_first_guess && allgood) {
  ------------------
  |  Branch (818:6): [True: 2.38k, False: 188]
  |  Branch (818:34): [True: 0, False: 2.38k]
  ------------------
  819|      0|		TRACE(("our_first_follows_matches 1"))
  820|      0|		ses.kexstate.our_first_follows_matches = 1;
  821|      0|	}
  822|  2.57k|	return;
  823|       |
  824|    204|error:
  825|    204|	dropbear_exit("No matching algo %s", erralgo);
  826|  2.57k|}

readhostkey:
   39|      1|	enum signkey_type *type) {
   40|       |
   41|      1|	int ret = DROPBEAR_FAILURE;
  ------------------
  |  |  112|      1|#define DROPBEAR_FAILURE -1
  ------------------
   42|      1|	buffer *buf;
   43|       |
   44|      1|	buf = buf_new(MAX_PRIVKEY_SIZE);
  ------------------
  |  |  272|      1|#define MAX_PRIVKEY_SIZE 1700
  ------------------
   45|       |
   46|      1|	if (buf_readfile(buf, filename) == DROPBEAR_FAILURE) {
  ------------------
  |  |  112|      1|#define DROPBEAR_FAILURE -1
  ------------------
  |  Branch (46:6): [True: 1, False: 0]
  ------------------
   47|      1|		goto out;
   48|      1|	}
   49|      0|	buf_setpos(buf, 0);
   50|       |
   51|      0|	addrandom(buf_getptr(buf, buf->len), buf->len);
   52|       |
   53|      0|	if (buf_get_priv_key(buf, hostkey, type) == DROPBEAR_FAILURE) {
  ------------------
  |  |  112|      0|#define DROPBEAR_FAILURE -1
  ------------------
  |  Branch (53:6): [True: 0, False: 0]
  ------------------
   54|      0|		goto out;
   55|      0|	}
   56|       |
   57|      0|	ret = DROPBEAR_SUCCESS;
  ------------------
  |  |  111|      0|#define DROPBEAR_SUCCESS 0
  ------------------
   58|      1|out:
   59|       |
   60|      1|	buf_burn_free(buf);
   61|      1|	return ret;
   62|      0|}
parse_ciphers_macs:
   66|      1|parse_ciphers_macs() {
   67|      1|	int printed_help = 0;
   68|      1|	if (opts.cipher_list) {
  ------------------
  |  Branch (68:6): [True: 0, False: 1]
  ------------------
   69|      0|		if (strcmp(opts.cipher_list, "help") == 0) {
  ------------------
  |  Branch (69:7): [True: 0, False: 0]
  ------------------
   70|      0|			char *ciphers = algolist_string(sshciphers);
   71|      0|			dropbear_log(LOG_INFO, "Available ciphers: %s", ciphers);
   72|      0|			m_free(ciphers);
  ------------------
  |  |   24|      0|#define m_free(X) do {m_free_direct(X); (X) = NULL;} while (0)
  |  |  ------------------
  |  |  |  Branch (24:61): [Folded, False: 0]
  |  |  ------------------
  ------------------
   73|      0|			printed_help = 1;
   74|      0|		} else {
   75|      0|			if (check_user_algos(opts.cipher_list, sshciphers, "cipher") == 0) {
  ------------------
  |  Branch (75:8): [True: 0, False: 0]
  ------------------
   76|      0|				dropbear_exit("No valid ciphers specified for '-c'");
   77|      0|			}
   78|      0|		}
   79|      0|	}
   80|       |
   81|      1|	if (opts.mac_list) {
  ------------------
  |  Branch (81:6): [True: 0, False: 1]
  ------------------
   82|      0|		if (strcmp(opts.mac_list, "help") == 0) {
  ------------------
  |  Branch (82:7): [True: 0, False: 0]
  ------------------
   83|      0|			char *macs = algolist_string(sshhashes);
   84|      0|			dropbear_log(LOG_INFO, "Available MACs: %s", macs);
   85|      0|			m_free(macs);
  ------------------
  |  |   24|      0|#define m_free(X) do {m_free_direct(X); (X) = NULL;} while (0)
  |  |  ------------------
  |  |  |  Branch (24:61): [Folded, False: 0]
  |  |  ------------------
  ------------------
   86|      0|			printed_help = 1;
   87|      0|		} else {
   88|      0|			if (check_user_algos(opts.mac_list, sshhashes, "MAC") == 0) {
  ------------------
  |  Branch (88:8): [True: 0, False: 0]
  ------------------
   89|      0|				dropbear_exit("No valid MACs specified for '-m'");
   90|      0|			}
   91|      0|		}
   92|      0|	}
   93|      1|	if (printed_help) {
  ------------------
  |  Branch (93:6): [True: 0, False: 1]
  ------------------
   94|      0|		dropbear_exit(".");
   95|      0|	}
   96|      1|}

common_session_init:
   47|  3.41k|void common_session_init(int sock_in, int sock_out) {
   48|  3.41k|	time_t now;
   49|       |
   50|       |#if DEBUG_TRACE
   51|       |	debug_start_net();
   52|       |#endif
   53|       |
   54|  3.41k|	TRACE(("enter session_init"))
   55|       |
   56|  3.41k|	ses.sock_in = sock_in;
   57|  3.41k|	ses.sock_out = sock_out;
   58|  3.41k|	ses.maxfd = MAX(sock_in, sock_out);
  ------------------
  |  Branch (58:14): [True: 0, False: 3.41k]
  ------------------
   59|       |
   60|  3.41k|	if (sock_in >= 0) {
  ------------------
  |  Branch (60:6): [True: 3.41k, False: 0]
  ------------------
   61|  3.41k|		setnonblocking(sock_in);
   62|  3.41k|	}
   63|  3.41k|	if (sock_out >= 0) {
  ------------------
  |  Branch (63:6): [True: 3.41k, False: 0]
  ------------------
   64|  3.41k|		setnonblocking(sock_out);
   65|  3.41k|	}
   66|       |
   67|  3.41k|	ses.socket_prio = DROPBEAR_PRIO_NORMAL;
   68|       |	/* Sets it to lowdelay */
   69|  3.41k|	update_channel_prio();
   70|       |
   71|       |#if !DROPBEAR_SVR_MULTIUSER
   72|       |	/* A sanity check to prevent an accidental configuration option
   73|       |	   leaving multiuser systems exposed */
   74|       |	{
   75|       |		int ret;
   76|       |		errno = 0;
   77|       |		ret = getgroups(0, NULL);
   78|       |		if (!(ret == -1 && errno == ENOSYS)) {
   79|       |			dropbear_exit("Non-multiuser Dropbear requires a non-multiuser kernel");
   80|       |		}
   81|       |	}
   82|       |#endif
   83|       |
   84|  3.41k|	now = monotonic_now();
   85|  3.41k|	ses.connect_time = now;
   86|  3.41k|	ses.last_packet_time_keepalive_recv = now;
   87|  3.41k|	ses.last_packet_time_idle = now;
   88|  3.41k|	ses.last_packet_time_any_sent = 0;
   89|  3.41k|	ses.last_packet_time_keepalive_sent = 0;
   90|       |	
   91|  3.41k|#if DROPBEAR_FUZZ
   92|  3.41k|	if (!fuzz.fuzzing)
  ------------------
  |  Branch (92:6): [True: 0, False: 3.41k]
  ------------------
   93|      0|#endif
   94|      0|	{
   95|      0|	if (pipe(ses.signal_pipe) < 0) {
  ------------------
  |  Branch (95:6): [True: 0, False: 0]
  ------------------
   96|      0|		dropbear_exit("Signal pipe failed");
   97|      0|	}
   98|      0|	setnonblocking(ses.signal_pipe[0]);
   99|      0|	setnonblocking(ses.signal_pipe[1]);
  100|      0|	ses.maxfd = MAX(ses.maxfd, ses.signal_pipe[0]);
  ------------------
  |  Branch (100:14): [True: 0, False: 0]
  ------------------
  101|      0|	ses.maxfd = MAX(ses.maxfd, ses.signal_pipe[1]);
  ------------------
  |  Branch (101:14): [True: 0, False: 0]
  ------------------
  102|      0|	}
  103|       |	
  104|  3.41k|	ses.writepayload = buf_new(TRANS_MAX_PAYLOAD_LEN);
  ------------------
  |  |  560|  3.41k|#define TRANS_MAX_PAYLOAD_LEN 16384
  ------------------
  105|  3.41k|	ses.transseq = 0;
  106|       |
  107|  3.41k|	ses.readbuf = NULL;
  108|  3.41k|	ses.payload = NULL;
  109|  3.41k|	ses.recvseq = 0;
  110|       |
  111|  3.41k|	initqueue(&ses.writequeue);
  112|       |
  113|  3.41k|	ses.requirenext = SSH_MSG_KEXINIT;
  ------------------
  |  |   36|  3.41k|#define SSH_MSG_KEXINIT                20
  ------------------
  114|  3.41k|	ses.dataallowed = 1; /* we can send data until we actually 
  115|       |							send the SSH_MSG_KEXINIT */
  116|  3.41k|	ses.ignorenext = 0;
  117|  3.41k|	ses.lastpacket = 0;
  118|  3.41k|	ses.reply_queue_head = NULL;
  119|  3.41k|	ses.reply_queue_tail = NULL;
  120|  3.41k|	ses.reply_queue_len = 0;
  121|       |
  122|       |	/* set all the algos to none */
  123|  3.41k|	ses.keys = (struct key_context*)m_malloc(sizeof(struct key_context));
  124|  3.41k|	ses.newkeys = NULL;
  125|  3.41k|	ses.keys->recv.algo_crypt = &dropbear_nocipher;
  126|  3.41k|	ses.keys->trans.algo_crypt = &dropbear_nocipher;
  127|  3.41k|	ses.keys->recv.crypt_mode = &dropbear_mode_none;
  128|  3.41k|	ses.keys->trans.crypt_mode = &dropbear_mode_none;
  129|       |	
  130|  3.41k|	ses.keys->recv.algo_mac = &dropbear_nohash;
  131|  3.41k|	ses.keys->trans.algo_mac = &dropbear_nohash;
  132|       |
  133|  3.41k|	ses.keys->algo_kex = NULL;
  134|  3.41k|	ses.keys->algo_hostkey = -1;
  135|  3.41k|	ses.keys->recv.algo_comp = DROPBEAR_COMP_NONE;
  136|  3.41k|	ses.keys->trans.algo_comp = DROPBEAR_COMP_NONE;
  137|       |
  138|       |#ifndef DISABLE_ZLIB
  139|       |	ses.keys->recv.zstream = NULL;
  140|       |	ses.keys->trans.zstream = NULL;
  141|       |#endif
  142|       |
  143|       |	/* key exchange buffers */
  144|  3.41k|	ses.session_id = NULL;
  145|  3.41k|	ses.kexhashbuf = NULL;
  146|  3.41k|	ses.transkexinit = NULL;
  147|  3.41k|	ses.dh_K = NULL;
  148|  3.41k|	ses.remoteident = NULL;
  149|       |
  150|  3.41k|	ses.chantypes = NULL;
  151|       |
  152|  3.41k|	ses.allowprivport = 0;
  153|       |
  154|  3.41k|	TRACE(("leave session_init"))
  155|  3.41k|}
session_loop:
  157|  3.41k|void session_loop(void(*loophandler)(void)) {
  158|       |
  159|  3.41k|	fd_set readfd, writefd;
  160|  3.41k|	struct timeval timeout;
  161|  3.41k|	int val;
  162|       |
  163|       |	/* main loop, select()s for all sockets in use */
  164|  97.5k|	for(;;) {
  165|  97.5k|		const int writequeue_has_space = (ses.writequeue_len <= 2*TRANS_MAX_PAYLOAD_LEN);
  ------------------
  |  |  560|  97.5k|#define TRANS_MAX_PAYLOAD_LEN 16384
  ------------------
  166|       |
  167|  97.5k|		timeout.tv_sec = select_timeout();
  168|  97.5k|		timeout.tv_usec = 0;
  169|  97.5k|		DROPBEAR_FD_ZERO(&writefd);
  ------------------
  |  |  109|  97.5k|#define DROPBEAR_FD_ZERO(fds) FD_ZERO(fds)
  ------------------
  |  Branch (169:3): [True: 1.56M, False: 97.5k]
  |  Branch (169:3): [Folded, False: 97.5k]
  ------------------
  170|  97.5k|		DROPBEAR_FD_ZERO(&readfd);
  ------------------
  |  |  109|  97.5k|#define DROPBEAR_FD_ZERO(fds) FD_ZERO(fds)
  ------------------
  |  Branch (170:3): [True: 1.56M, False: 97.5k]
  |  Branch (170:3): [Folded, False: 97.5k]
  ------------------
  171|       |
  172|  97.5k|		dropbear_assert(ses.payload == NULL);
  ------------------
  |  |   86|  97.5k|#define dropbear_assert(X) do { if (!(X)) { fail_assert(#X, __FILE__, __LINE__); } } while (0)
  |  |  ------------------
  |  |  |  Branch (86:37): [True: 0, False: 97.5k]
  |  |  |  Branch (86:93): [Folded, False: 97.5k]
  |  |  ------------------
  ------------------
  173|       |
  174|       |		/* We get woken up when signal handlers write to this pipe.
  175|       |		   SIGCHLD in svr-chansession is the only one currently. */
  176|  97.5k|#if DROPBEAR_FUZZ
  177|  97.5k|		if (!fuzz.fuzzing) 
  ------------------
  |  Branch (177:7): [True: 0, False: 97.5k]
  ------------------
  178|      0|#endif
  179|      0|		{
  180|      0|		dropbear_fd_set(ses.signal_pipe[0], &readfd);
  181|      0|		}
  182|       |
  183|       |		/* set up for channels which can be read/written */
  184|  97.5k|		setchannelfds(&readfd, &writefd, writequeue_has_space);
  185|       |
  186|       |		/* Pending connections to test */
  187|  97.5k|		set_connect_fds(&writefd);
  188|       |
  189|       |		/* We delay reading from the input socket during initial setup until
  190|       |		after we have written out our initial KEXINIT packet (empty writequeue). 
  191|       |		This means our initial packet can be in-flight while we're doing a blocking
  192|       |		read for the remote ident.
  193|       |		We also avoid reading from the socket if the writequeue is full, that avoids
  194|       |		replies backing up */
  195|  97.5k|		if (ses.sock_in != -1 
  ------------------
  |  Branch (195:7): [True: 97.5k, False: 0]
  ------------------
  196|  97.5k|			&& (ses.remoteident || isempty(&ses.writequeue)) 
  ------------------
  |  Branch (196:8): [True: 83.7k, False: 13.8k]
  |  Branch (196:27): [True: 3.58k, False: 10.2k]
  ------------------
  197|  87.3k|			&& writequeue_has_space) {
  ------------------
  |  Branch (197:7): [True: 87.3k, False: 0]
  ------------------
  198|  87.3k|			dropbear_fd_set(ses.sock_in, &readfd);
  199|  87.3k|		}
  200|       |
  201|       |		/* Ordering is important, this test must occur after any other function
  202|       |		might have queued packets (such as connection handlers) */
  203|  97.5k|		if (ses.sock_out != -1 && !isempty(&ses.writequeue)) {
  ------------------
  |  Branch (203:7): [True: 97.5k, False: 0]
  |  Branch (203:29): [True: 10.2k, False: 87.3k]
  ------------------
  204|  10.2k|			dropbear_fd_set(ses.sock_out, &writefd);
  205|  10.2k|		}
  206|       |
  207|  97.5k|		val = select(ses.maxfd+1, &readfd, &writefd, NULL, &timeout);
  ------------------
  |  |   53|  97.5k|        wrapfd_select(nfds, readfds, writefds, exceptfds, timeout)
  ------------------
  208|       |
  209|  97.5k|		if (ses.exitflag) {
  ------------------
  |  Branch (209:7): [True: 0, False: 97.5k]
  ------------------
  210|      0|			dropbear_exit("Terminated by signal");
  211|      0|		}
  212|       |		
  213|  97.5k|		if (val < 0 && errno != EINTR) {
  ------------------
  |  Branch (213:7): [True: 124, False: 97.4k]
  |  Branch (213:18): [True: 0, False: 124]
  ------------------
  214|      0|			dropbear_exit("Error in select");
  215|      0|		}
  216|       |
  217|  97.5k|		if (val <= 0) {
  ------------------
  |  Branch (217:7): [True: 3.43k, False: 94.1k]
  ------------------
  218|       |			/* If we were interrupted or the select timed out, we still
  219|       |			 * want to iterate over channels etc for reading, to handle
  220|       |			 * server processes exiting etc. 
  221|       |			 * We don't want to read/write FDs. */
  222|  3.43k|			DROPBEAR_FD_ZERO(&writefd);
  ------------------
  |  |  109|  3.43k|#define DROPBEAR_FD_ZERO(fds) FD_ZERO(fds)
  ------------------
  |  Branch (222:4): [True: 54.8k, False: 3.43k]
  |  Branch (222:4): [Folded, False: 3.43k]
  ------------------
  223|  3.43k|			DROPBEAR_FD_ZERO(&readfd);
  ------------------
  |  |  109|  3.43k|#define DROPBEAR_FD_ZERO(fds) FD_ZERO(fds)
  ------------------
  |  Branch (223:4): [True: 54.8k, False: 3.43k]
  |  Branch (223:4): [Folded, False: 3.43k]
  ------------------
  224|  3.43k|		}
  225|       |		
  226|       |		/* We'll just empty out the pipe if required. We don't do
  227|       |		any thing with the data, since the pipe's purpose is purely to
  228|       |		wake up the select() above. */
  229|  97.5k|		ses.channel_signal_pending = 0;
  230|  97.5k|		if (FD_ISSET(ses.signal_pipe[0], &readfd)) {
  ------------------
  |  Branch (230:7): [True: 0, False: 97.5k]
  ------------------
  231|      0|			char x;
  232|      0|			TRACE(("signal pipe set"))
  233|      0|			while (read(ses.signal_pipe[0], &x, 1) > 0) {}
  ------------------
  |  |   55|      0|#define read(fd, buf, count) wrapfd_read(fd, buf, count)
  ------------------
  |  Branch (233:11): [True: 0, False: 0]
  ------------------
  234|      0|			ses.channel_signal_pending = 1;
  235|      0|		}
  236|       |
  237|       |		/* check for auth timeout, rekeying required etc */
  238|  97.5k|		checktimeouts();
  239|       |
  240|       |		/* process session socket's incoming data */
  241|  97.5k|		if (ses.sock_in != -1) {
  ------------------
  |  Branch (241:7): [True: 97.5k, False: 0]
  ------------------
  242|  97.5k|			if (FD_ISSET(ses.sock_in, &readfd)) {
  ------------------
  |  Branch (242:8): [True: 84.0k, False: 13.4k]
  ------------------
  243|  84.0k|				if (!ses.remoteident) {
  ------------------
  |  Branch (243:9): [True: 3.41k, False: 80.6k]
  ------------------
  244|       |					/* blocking read of the version string */
  245|  3.41k|					read_session_identification();
  246|  80.6k|				} else {
  247|  80.6k|					read_packet();
  248|  80.6k|				}
  249|  84.0k|			}
  250|       |			
  251|       |			/* Process the decrypted packet. After this, the read buffer
  252|       |			 * will be ready for a new packet */
  253|  97.5k|			if (ses.payload != NULL) {
  ------------------
  |  Branch (253:8): [True: 19.3k, False: 78.2k]
  ------------------
  254|  19.3k|				process_packet();
  255|  19.3k|			}
  256|  97.5k|		}
  257|       |
  258|       |		/* if required, flush out any queued reply packets that
  259|       |		were being held up during a KEX */
  260|  97.5k|		maybe_flush_reply_queue();
  261|       |
  262|  97.5k|		handle_connect_fds(&writefd);
  263|       |
  264|       |		/* loop handler prior to channelio, in case the server loophandler closes
  265|       |		channels on process exit */
  266|  97.5k|		loophandler();
  267|       |
  268|       |		/* process pipes etc for the channels, ses.dataallowed == 0
  269|       |		 * during rekeying ) */
  270|  97.5k|		channelio(&readfd, &writefd);
  271|       |
  272|       |		/* process session socket's outgoing data */
  273|  97.5k|		if (ses.sock_out != -1) {
  ------------------
  |  Branch (273:7): [True: 94.1k, False: 3.41k]
  ------------------
  274|  94.1k|			if (!isempty(&ses.writequeue)) {
  ------------------
  |  Branch (274:8): [True: 26.7k, False: 67.3k]
  ------------------
  275|  26.7k|				write_packet();
  276|  26.7k|			}
  277|  94.1k|		}
  278|       |
  279|  97.5k|	} /* for(;;) */
  280|       |	
  281|       |	/* Not reached */
  282|  3.41k|}
session_cleanup:
  293|  3.41k|void session_cleanup() {
  294|       |	
  295|  3.41k|	TRACE(("enter session_cleanup"))
  296|       |	
  297|       |	/* we can't cleanup if we don't know the session state */
  298|  3.41k|	if (!ses.init_done) {
  ------------------
  |  Branch (298:6): [True: 0, False: 3.41k]
  ------------------
  299|      0|		TRACE(("leave session_cleanup: !ses.init_done"))
  300|      0|		return;
  301|      0|	}
  302|       |
  303|       |	/* BEWARE of changing order of functions here. */
  304|       |
  305|       |	/* Must be before extra_session_cleanup() */
  306|  3.41k|	chancleanup();
  307|       |
  308|  3.41k|	if (ses.extra_session_cleanup) {
  ------------------
  |  Branch (308:6): [True: 3.41k, False: 0]
  ------------------
  309|  3.41k|		ses.extra_session_cleanup();
  310|  3.41k|	}
  311|       |
  312|       |	/* After these are freed most functions will fail */
  313|  3.41k|#if DROPBEAR_CLEANUP
  314|       |	/* listeners call cleanup functions, this should occur before
  315|       |	other session state is freed. */
  316|  3.41k|	remove_all_listeners();
  317|       |
  318|  3.41k|	remove_connect_pending();
  319|       |
  320|  3.41k|	while (!isempty(&ses.writequeue)) {
  ------------------
  |  Branch (320:9): [True: 0, False: 3.41k]
  ------------------
  321|      0|		buf_free(dequeue(&ses.writequeue));
  322|      0|	}
  323|       |
  324|  3.41k|	m_free(ses.newkeys);
  ------------------
  |  |   24|  3.41k|#define m_free(X) do {m_free_direct(X); (X) = NULL;} while (0)
  |  |  ------------------
  |  |  |  Branch (24:61): [Folded, False: 3.41k]
  |  |  ------------------
  ------------------
  325|       |#ifndef DISABLE_ZLIB
  326|       |	if (ses.keys->recv.zstream != NULL) {
  327|       |		if (inflateEnd(ses.keys->recv.zstream) == Z_STREAM_ERROR) {
  328|       |			dropbear_exit("Crypto error");
  329|       |		}
  330|       |		m_free(ses.keys->recv.zstream);
  331|       |	}
  332|       |	if (ses.keys->trans.zstream != NULL) {
  333|       |		if (deflateEnd(ses.keys->trans.zstream) == Z_STREAM_ERROR) {
  334|       |			dropbear_exit("Crypto error");
  335|       |		}
  336|       |		m_free(ses.keys->trans.zstream);
  337|       |	}
  338|       |#endif
  339|       |
  340|  3.41k|	m_free(ses.remoteident);
  ------------------
  |  |   24|  3.41k|#define m_free(X) do {m_free_direct(X); (X) = NULL;} while (0)
  |  |  ------------------
  |  |  |  Branch (24:61): [Folded, False: 3.41k]
  |  |  ------------------
  ------------------
  341|  3.41k|	m_free(ses.authstate.pw_dir);
  ------------------
  |  |   24|  3.41k|#define m_free(X) do {m_free_direct(X); (X) = NULL;} while (0)
  |  |  ------------------
  |  |  |  Branch (24:61): [Folded, False: 3.41k]
  |  |  ------------------
  ------------------
  342|  3.41k|	m_free(ses.authstate.pw_name);
  ------------------
  |  |   24|  3.41k|#define m_free(X) do {m_free_direct(X); (X) = NULL;} while (0)
  |  |  ------------------
  |  |  |  Branch (24:61): [Folded, False: 3.41k]
  |  |  ------------------
  ------------------
  343|  3.41k|	m_free(ses.authstate.pw_shell);
  ------------------
  |  |   24|  3.41k|#define m_free(X) do {m_free_direct(X); (X) = NULL;} while (0)
  |  |  ------------------
  |  |  |  Branch (24:61): [Folded, False: 3.41k]
  |  |  ------------------
  ------------------
  344|  3.41k|	m_free(ses.authstate.pw_passwd);
  ------------------
  |  |   24|  3.41k|#define m_free(X) do {m_free_direct(X); (X) = NULL;} while (0)
  |  |  ------------------
  |  |  |  Branch (24:61): [Folded, False: 3.41k]
  |  |  ------------------
  ------------------
  345|  3.41k|	m_free(ses.authstate.username);
  ------------------
  |  |   24|  3.41k|#define m_free(X) do {m_free_direct(X); (X) = NULL;} while (0)
  |  |  ------------------
  |  |  |  Branch (24:61): [Folded, False: 3.41k]
  |  |  ------------------
  ------------------
  346|  3.41k|#endif
  347|       |
  348|  3.41k|	cleanup_buf(&ses.session_id);
  349|  3.41k|	cleanup_buf(&ses.hash);
  350|  3.41k|	cleanup_buf(&ses.payload);
  351|  3.41k|	cleanup_buf(&ses.readbuf);
  352|  3.41k|	cleanup_buf(&ses.writepayload);
  353|  3.41k|	cleanup_buf(&ses.kexhashbuf);
  354|  3.41k|	cleanup_buf(&ses.transkexinit);
  355|  3.41k|	if (ses.dh_K) {
  ------------------
  |  Branch (355:6): [True: 1.31k, False: 2.10k]
  ------------------
  356|  1.31k|		mp_clear(ses.dh_K);
  357|  1.31k|	}
  358|  3.41k|	m_free(ses.dh_K);
  ------------------
  |  |   24|  3.41k|#define m_free(X) do {m_free_direct(X); (X) = NULL;} while (0)
  |  |  ------------------
  |  |  |  Branch (24:61): [Folded, False: 3.41k]
  |  |  ------------------
  ------------------
  359|  3.41k|	if (ses.dh_K_bytes) {
  ------------------
  |  Branch (359:6): [True: 48, False: 3.37k]
  ------------------
  360|     48|		buf_burn_free(ses.dh_K_bytes);
  361|     48|	}
  362|       |
  363|  3.41k|	m_burn(ses.keys, sizeof(struct key_context));
  364|  3.41k|	m_free(ses.keys);
  ------------------
  |  |   24|  3.41k|#define m_free(X) do {m_free_direct(X); (X) = NULL;} while (0)
  |  |  ------------------
  |  |  |  Branch (24:61): [Folded, False: 3.41k]
  |  |  ------------------
  ------------------
  365|       |
  366|  3.41k|	TRACE(("leave session_cleanup"))
  367|  3.41k|}
send_session_identification:
  369|  3.41k|void send_session_identification() {
  370|  3.41k|	buffer *writebuf = buf_new(strlen(LOCAL_IDENT "\r\n") + 1);
  ------------------
  |  |   14|  3.41k|#define LOCAL_IDENT "SSH-2.0-dropbear" IDENT_VERSION_PART
  ------------------
  371|  3.41k|	buf_putbytes(writebuf, (const unsigned char *) LOCAL_IDENT "\r\n", strlen(LOCAL_IDENT "\r\n"));
  ------------------
  |  |   14|  3.41k|#define LOCAL_IDENT "SSH-2.0-dropbear" IDENT_VERSION_PART
  ------------------
              	buf_putbytes(writebuf, (const unsigned char *) LOCAL_IDENT "\r\n", strlen(LOCAL_IDENT "\r\n"));
  ------------------
  |  |   14|  3.41k|#define LOCAL_IDENT "SSH-2.0-dropbear" IDENT_VERSION_PART
  ------------------
  372|  3.41k|	writebuf_enqueue(writebuf);
  373|  3.41k|}
update_channel_prio:
  696|  3.41k|void update_channel_prio() {
  697|  3.41k|	enum dropbear_prio new_prio;
  698|  3.41k|	int any = 0;
  699|  3.41k|	unsigned int i;
  700|       |
  701|  3.41k|	TRACE(("update_channel_prio"))
  702|       |
  703|  3.41k|	if (ses.sock_out < 0) {
  ------------------
  |  Branch (703:6): [True: 0, False: 3.41k]
  ------------------
  704|      0|		TRACE(("leave update_channel_prio: no socket"))
  705|      0|		return;
  706|      0|	}
  707|       |
  708|  3.41k|	new_prio = DROPBEAR_PRIO_NORMAL;
  709|  3.41k|	for (i = 0; i < ses.chansize; i++) {
  ------------------
  |  Branch (709:14): [True: 0, False: 3.41k]
  ------------------
  710|      0|		struct Channel *channel = ses.channels[i];
  711|      0|		if (!channel) {
  ------------------
  |  Branch (711:7): [True: 0, False: 0]
  ------------------
  712|      0|			continue;
  713|      0|		}
  714|      0|		any = 1;
  715|      0|		if (channel->prio == DROPBEAR_PRIO_LOWDELAY) {
  ------------------
  |  Branch (715:7): [True: 0, False: 0]
  ------------------
  716|      0|			new_prio = DROPBEAR_PRIO_LOWDELAY;
  717|      0|			break;
  718|      0|		}
  719|      0|	}
  720|       |
  721|  3.41k|	if (any == 0) {
  ------------------
  |  Branch (721:6): [True: 3.41k, False: 0]
  ------------------
  722|       |		/* lowdelay during setup */
  723|  3.41k|		TRACE(("update_channel_prio: not any"))
  724|  3.41k|		new_prio = DROPBEAR_PRIO_LOWDELAY;
  725|  3.41k|	}
  726|       |
  727|  3.41k|	if (new_prio != ses.socket_prio) {
  ------------------
  |  Branch (727:6): [True: 3.41k, False: 0]
  ------------------
  728|  3.41k|		TRACE(("Dropbear priority transitioning %d -> %d", ses.socket_prio, new_prio))
  729|  3.41k|		set_sock_priority(ses.sock_out, new_prio);
  730|  3.41k|		ses.socket_prio = new_prio;
  731|  3.41k|	}
  732|  3.41k|}
common-session.c:cleanup_buf:
  284|  23.9k|static void cleanup_buf(buffer **buf) {
  285|  23.9k|	if (!*buf) {
  ------------------
  |  Branch (285:6): [True: 12.1k, False: 11.7k]
  ------------------
  286|  12.1k|		return;
  287|  12.1k|	}
  288|  11.7k|	buf_burn_free(*buf);
  289|       |	*buf = NULL;
  290|  11.7k|}
common-session.c:read_session_identification:
  375|  3.41k|static void read_session_identification() {
  376|       |	/* max length of 255 chars */
  377|  3.41k|	char linebuf[256];
  378|  3.41k|	int len = 0;
  379|  3.41k|	char done = 0;
  380|  3.41k|	int i;
  381|       |
  382|       |	/* Servers may send other lines of data before sending the
  383|       |	 * version string, client must be able to process such lines.
  384|       |	 * If they send more than 50 lines, something is wrong */
  385|  6.43k|	for (i = IS_DROPBEAR_CLIENT ? 50 : 1; i > 0; i--) {
  ------------------
  |  |  384|  3.41k|#define IS_DROPBEAR_CLIENT (ses.isserver == 0)
  |  |  ------------------
  |  |  |  Branch (384:28): [True: 3.41k, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (385:40): [True: 6.37k, False: 53]
  ------------------
  386|  6.37k|		len = ident_readln(ses.sock_in, linebuf, sizeof(linebuf));
  387|       |
  388|  6.37k|		if (len < 0 && errno != EINTR) {
  ------------------
  |  Branch (388:7): [True: 2.70k, False: 3.67k]
  |  Branch (388:18): [True: 97, False: 2.61k]
  ------------------
  389|       |			/* It failed */
  390|     97|			break;
  391|     97|		}
  392|       |
  393|  6.28k|		if (len >= 4 && memcmp(linebuf, "SSH-", 4) == 0) {
  ------------------
  |  Branch (393:7): [True: 3.59k, False: 2.68k]
  |  Branch (393:19): [True: 3.26k, False: 328]
  ------------------
  394|       |			/* start of line matches */
  395|  3.26k|			done = 1;
  396|  3.26k|			break;
  397|  3.26k|		}
  398|  6.28k|	}
  399|       |
  400|  3.41k|	if (!done) {
  ------------------
  |  Branch (400:6): [True: 150, False: 3.26k]
  ------------------
  401|    150|		TRACE(("error reading remote ident: %s\n", strerror(errno)))
  402|    150|		ses.remoteclosed();
  403|  3.26k|	} else {
  404|       |		/* linebuf is already null terminated */
  405|  3.26k|		ses.remoteident = m_malloc(len);
  406|  3.26k|		memcpy(ses.remoteident, linebuf, len);
  407|  3.26k|	}
  408|       |
  409|       |	/* Shall assume that 2.x will be backwards compatible. */
  410|  3.41k|	if (strncmp(ses.remoteident, "SSH-2.", 6) != 0
  ------------------
  |  Branch (410:6): [True: 62, False: 3.35k]
  ------------------
  411|     62|			&& strncmp(ses.remoteident, "SSH-1.99-", 9) != 0) {
  ------------------
  |  Branch (411:7): [True: 61, False: 1]
  ------------------
  412|     61|		dropbear_exit("Incompatible remote version '%s'", ses.remoteident);
  413|     61|	}
  414|       |
  415|  3.41k|	DEBUG1(("remoteident: %s", ses.remoteident))
  416|       |
  417|  3.41k|}
common-session.c:ident_readln:
  421|  6.37k|static int ident_readln(int fd, char* buf, int count) {
  422|       |	
  423|  6.37k|	char in;
  424|  6.37k|	int pos = 0;
  425|  6.37k|	int num = 0;
  426|  6.37k|	fd_set fds;
  427|  6.37k|	struct timeval timeout;
  428|       |
  429|  6.37k|	TRACE(("enter ident_readln"))
  430|       |
  431|  6.37k|	if (count < 1) {
  ------------------
  |  Branch (431:6): [True: 0, False: 6.37k]
  ------------------
  432|      0|		return -1;
  433|      0|	}
  434|       |
  435|  6.37k|	DROPBEAR_FD_ZERO(&fds);
  ------------------
  |  |  109|  6.37k|#define DROPBEAR_FD_ZERO(fds) FD_ZERO(fds)
  ------------------
  |  Branch (435:2): [True: 102k, False: 6.37k]
  |  Branch (435:2): [Folded, False: 6.37k]
  ------------------
  436|       |
  437|       |	/* select since it's a non-blocking fd */
  438|       |	
  439|       |	/* leave space to null-terminate */
  440|  92.6k|	while (pos < count-1) {
  ------------------
  |  Branch (440:9): [True: 92.5k, False: 130]
  ------------------
  441|       |
  442|  92.5k|		dropbear_fd_set(fd, &fds);
  443|       |
  444|  92.5k|		timeout.tv_sec = 1;
  445|  92.5k|		timeout.tv_usec = 0;
  446|  92.5k|		if (select(fd+1, &fds, NULL, NULL, &timeout) < 0) {
  ------------------
  |  |   53|  92.5k|        wrapfd_select(nfds, readfds, writefds, exceptfds, timeout)
  ------------------
  |  Branch (446:7): [True: 211, False: 92.3k]
  ------------------
  447|    211|			if (errno == EINTR) {
  ------------------
  |  Branch (447:8): [True: 211, False: 0]
  ------------------
  448|    211|				continue;
  449|    211|			}
  450|      0|			TRACE(("leave ident_readln: select error"))
  451|      0|			return -1;
  452|    211|		}
  453|       |
  454|  92.3k|		checktimeouts();
  455|       |		
  456|       |		/* Have to go one byte at a time, since we don't want to read past
  457|       |		 * the end, and have to somehow shove bytes back into the normal
  458|       |		 * packet reader */
  459|  92.3k|		if (FD_ISSET(fd, &fds)) {
  ------------------
  |  Branch (459:7): [True: 92.3k, False: 0]
  ------------------
  460|  92.3k|			num = read(fd, &in, 1);
  ------------------
  |  |   55|  92.3k|#define read(fd, buf, count) wrapfd_read(fd, buf, count)
  ------------------
  461|       |			/* a "\n" is a newline, "\r" we want to read in and keep going
  462|       |			 * so that it won't be read as part of the next line */
  463|  92.3k|			if (num < 0) {
  ------------------
  |  Branch (463:8): [True: 148, False: 92.2k]
  ------------------
  464|       |				/* error */
  465|    148|				if (errno == EINTR) {
  ------------------
  |  Branch (465:9): [True: 133, False: 15]
  ------------------
  466|    133|					continue; /* not a real error */
  467|    133|				}
  468|     15|				TRACE(("leave ident_readln: read error"))
  469|     15|				return -1;
  470|    148|			}
  471|  92.2k|			if (num == 0) {
  ------------------
  |  Branch (471:8): [True: 2.69k, False: 89.5k]
  ------------------
  472|       |				/* EOF */
  473|  2.69k|				TRACE(("leave ident_readln: EOF"))
  474|  2.69k|				return -1;
  475|  2.69k|			}
  476|       |
  477|  89.5k|#if DROPBEAR_FUZZ
  478|  89.5k|			fuzz_dump(&in, 1);
  479|  89.5k|#endif
  480|       |
  481|  89.5k|			if (in == '\n') {
  ------------------
  |  Branch (481:8): [True: 3.54k, False: 85.9k]
  ------------------
  482|       |				/* end of ident string */
  483|  3.54k|				break;
  484|  3.54k|			}
  485|       |			/* we don't want to include '\r's */
  486|  85.9k|			if (in != '\r') {
  ------------------
  |  Branch (486:8): [True: 83.4k, False: 2.51k]
  ------------------
  487|  83.4k|				buf[pos] = in;
  488|  83.4k|				pos++;
  489|  83.4k|			}
  490|  85.9k|		}
  491|  92.3k|	}
  492|       |
  493|  3.67k|	buf[pos] = '\0';
  494|  3.67k|	TRACE(("leave ident_readln: return %d", pos+1))
  495|  3.67k|	return pos+1;
  496|  6.37k|}
common-session.c:checktimeouts:
  542|   189k|static void checktimeouts() {
  543|       |
  544|   189k|	time_t now;
  545|   189k|	now = monotonic_now();
  546|       |
  547|   189k|	if (IS_DROPBEAR_SERVER && ses.authstate.authdone != 1
  ------------------
  |  |  383|   379k|#define IS_DROPBEAR_SERVER (ses.isserver == 1)
  |  |  ------------------
  |  |  |  Branch (383:28): [True: 0, False: 189k]
  |  |  ------------------
  ------------------
  |  Branch (547:28): [True: 0, False: 0]
  ------------------
  548|      0|		&& elapsed(now, ses.connect_time) >= AUTH_TIMEOUT) {
  ------------------
  |  |   35|      0|#define AUTH_TIMEOUT 300 /* we choose 5 minutes */
  ------------------
  |  Branch (548:6): [True: 0, False: 0]
  ------------------
  549|      0|			dropbear_close("Timeout before auth");
  550|      0|	}
  551|       |
  552|       |	/* we can't rekey if we haven't done remote ident exchange yet */
  553|   189k|	if (ses.remoteident == NULL) {
  ------------------
  |  Branch (553:6): [True: 106k, False: 83.7k]
  ------------------
  554|   106k|		return;
  555|   106k|	}
  556|       |
  557|  83.7k|	if (!ses.kexstate.sentkexinit
  ------------------
  |  Branch (557:6): [True: 0, False: 83.7k]
  ------------------
  558|      0|			&& (elapsed(now, ses.kexstate.lastkextime) >= KEX_REKEY_TIMEOUT
  ------------------
  |  |   28|      0|#define KEX_REKEY_TIMEOUT (3600 * 8)
  ------------------
  |  Branch (558:8): [True: 0, False: 0]
  ------------------
  559|      0|			|| ses.kexstate.datarecv+ses.kexstate.datatrans >= KEX_REKEY_DATA
  ------------------
  |  |   31|      0|#define KEX_REKEY_DATA (1<<30) /* 2^30 == 1GB, this value must be < INT_MAX */
  ------------------
  |  Branch (559:7): [True: 0, False: 0]
  ------------------
  560|      0|			|| ses.kexstate.needrekey)) {
  ------------------
  |  Branch (560:7): [True: 0, False: 0]
  ------------------
  561|      0|		TRACE(("rekeying after timeout or max data reached"))
  562|      0|		ses.kexstate.needrekey = 0;
  563|      0|		send_msg_kexinit();
  564|      0|	}
  565|       |
  566|  83.7k|	if (opts.keepalive_secs > 0 && ses.authstate.authdone) {
  ------------------
  |  Branch (566:6): [True: 0, False: 83.7k]
  |  Branch (566:33): [True: 0, False: 0]
  ------------------
  567|       |		/* Avoid sending keepalives prior to auth - those are
  568|       |		not valid pre-auth packet types */
  569|       |
  570|       |		/* Send keepalives if we've been idle */
  571|      0|		if (elapsed(now, ses.last_packet_time_any_sent) >= opts.keepalive_secs) {
  ------------------
  |  Branch (571:7): [True: 0, False: 0]
  ------------------
  572|      0|			send_msg_keepalive();
  573|      0|		}
  574|       |
  575|       |		/* Also send an explicit keepalive message to trigger a response
  576|       |		if the remote end hasn't sent us anything */
  577|      0|		if (elapsed(now, ses.last_packet_time_keepalive_recv) >= opts.keepalive_secs
  ------------------
  |  Branch (577:7): [True: 0, False: 0]
  ------------------
  578|      0|			&& elapsed(now, ses.last_packet_time_keepalive_sent) >= opts.keepalive_secs) {
  ------------------
  |  Branch (578:7): [True: 0, False: 0]
  ------------------
  579|      0|			send_msg_keepalive();
  580|      0|		}
  581|       |
  582|      0|		if (elapsed(now, ses.last_packet_time_keepalive_recv)
  ------------------
  |  Branch (582:7): [True: 0, False: 0]
  ------------------
  583|      0|			>= opts.keepalive_secs * DEFAULT_KEEPALIVE_LIMIT) {
  ------------------
  |  |  573|      0|#define DEFAULT_KEEPALIVE_LIMIT 3
  ------------------
  584|      0|			dropbear_exit("Keepalive timeout");
  585|      0|		}
  586|      0|	}
  587|       |
  588|  83.7k|	if (opts.idle_timeout_secs > 0
  ------------------
  |  Branch (588:6): [True: 0, False: 83.7k]
  ------------------
  589|      0|			&& elapsed(now, ses.last_packet_time_idle) >= opts.idle_timeout_secs) {
  ------------------
  |  Branch (589:7): [True: 0, False: 0]
  ------------------
  590|      0|		dropbear_close("Idle timeout");
  591|      0|	}
  592|       |
  593|  83.7k|	if (opts.max_duration_secs > 0
  ------------------
  |  Branch (593:6): [True: 0, False: 83.7k]
  ------------------
  594|      0|			&& elapsed(now, ses.connect_time) >= opts.max_duration_secs) {
  ------------------
  |  Branch (594:7): [True: 0, False: 0]
  ------------------
  595|      0|		dropbear_close("Max duration reached");
  596|      0|	}
  597|  83.7k|}
common-session.c:select_timeout:
  610|  97.5k|static long select_timeout() {
  611|       |	/* determine the minimum timeout that might be required, so
  612|       |	as to avoid waking when unneccessary */
  613|  97.5k|	long timeout = KEX_REKEY_TIMEOUT;
  ------------------
  |  |   28|  97.5k|#define KEX_REKEY_TIMEOUT (3600 * 8)
  ------------------
  614|  97.5k|	time_t now = monotonic_now();
  615|       |
  616|  97.5k|	if (!ses.kexstate.sentkexinit) {
  ------------------
  |  Branch (616:6): [True: 0, False: 97.5k]
  ------------------
  617|      0|		update_timeout(KEX_REKEY_TIMEOUT, now, ses.kexstate.lastkextime, &timeout);
  ------------------
  |  |   28|      0|#define KEX_REKEY_TIMEOUT (3600 * 8)
  ------------------
  618|      0|	}
  619|  97.5k|	if (ses.kexstate.needrekey) {
  ------------------
  |  Branch (619:6): [True: 0, False: 97.5k]
  ------------------
  620|      0|		timeout = 0;
  621|      0|	}
  622|       |
  623|  97.5k|	if (ses.authstate.authdone != 1 && IS_DROPBEAR_SERVER) {
  ------------------
  |  |  383|  97.5k|#define IS_DROPBEAR_SERVER (ses.isserver == 1)
  |  |  ------------------
  |  |  |  Branch (383:28): [True: 0, False: 97.5k]
  |  |  ------------------
  ------------------
  |  Branch (623:6): [True: 97.5k, False: 0]
  ------------------
  624|       |		/* AUTH_TIMEOUT is only relevant before authdone */
  625|      0|		update_timeout(AUTH_TIMEOUT, now, ses.connect_time, &timeout);
  ------------------
  |  |   35|      0|#define AUTH_TIMEOUT 300 /* we choose 5 minutes */
  ------------------
  626|      0|	}
  627|       |
  628|  97.5k|	if (ses.authstate.authdone) {
  ------------------
  |  Branch (628:6): [True: 0, False: 97.5k]
  ------------------
  629|      0|		update_timeout(opts.keepalive_secs, now,
  630|      0|			MAX(ses.last_packet_time_keepalive_recv, ses.last_packet_time_keepalive_sent),
  ------------------
  |  Branch (630:4): [True: 0, False: 0]
  ------------------
  631|      0|			&timeout);
  632|      0|	}
  633|       |
  634|  97.5k|	update_timeout(opts.idle_timeout_secs, now, ses.last_packet_time_idle,
  635|  97.5k|		&timeout);
  636|       |
  637|  97.5k|	update_timeout(opts.max_duration_secs, now, ses.connect_time,
  638|  97.5k|		&timeout);
  639|       |
  640|       |	/* clamp negative timeouts to zero - event has already triggered */
  641|       |	return MAX(timeout, 0);
  ------------------
  |  Branch (641:9): [True: 97.5k, False: 0]
  ------------------
  642|  97.5k|}
common-session.c:update_timeout:
  599|   195k|static void update_timeout(long limit, time_t now, time_t last_event, long * timeout) {
  600|   195k|	TRACE2(("update_timeout limit %ld, now %llu, last %llu, timeout %ld",
  601|   195k|		limit,
  602|   195k|		(unsigned long long)now,
  603|   195k|		(unsigned long long)last_event, *timeout))
  604|   195k|	if (last_event > 0 && limit > 0) {
  ------------------
  |  Branch (604:6): [True: 195k, False: 0]
  |  Branch (604:24): [True: 0, False: 195k]
  ------------------
  605|       |		*timeout = MIN(*timeout, MAX(0, limit - elapsed(now, last_event)));
  ------------------
  |  Branch (605:14): [True: 0, False: 0]
  |  Branch (605:14): [True: 0, False: 0]
  |  Branch (605:14): [True: 0, False: 0]
  ------------------
  606|      0|		TRACE2(("new timeout %ld", *timeout))
  607|      0|	}
  608|   195k|}

crypto_init:
   21|      1|void crypto_init() {
   22|       |
   23|      1|	const struct ltc_cipher_descriptor *regciphers[] = {
   24|      1|#if DROPBEAR_AES
   25|      1|		&aes_desc,
   26|      1|#endif
   27|       |#if DROPBEAR_3DES
   28|       |		&des3_desc,
   29|       |#endif
   30|      1|		NULL
   31|      1|	};
   32|       |
   33|      1|	const struct ltc_hash_descriptor *reghashes[] = {
   34|       |#if DROPBEAR_SHA1_HMAC
   35|       |		&sha1_desc,
   36|       |#endif
   37|      1|#if DROPBEAR_SHA256
   38|      1|		&sha256_desc,
   39|      1|#endif
   40|      1|#if DROPBEAR_SHA384
   41|      1|		&sha384_desc,
   42|      1|#endif
   43|      1|#if DROPBEAR_SHA512
   44|      1|		&sha512_desc,
   45|      1|#endif
   46|      1|		NULL
   47|      1|	};
   48|      1|	int i;
   49|       |
   50|      2|	for (i = 0; regciphers[i] != NULL; i++) {
  ------------------
  |  Branch (50:14): [True: 1, False: 1]
  ------------------
   51|      1|		if (register_cipher(regciphers[i]) == -1) {
  ------------------
  |  Branch (51:7): [True: 0, False: 1]
  ------------------
   52|      0|			dropbear_exit("Error registering crypto");
   53|      0|		}
   54|      1|	}
   55|       |
   56|      4|	for (i = 0; reghashes[i] != NULL; i++) {
  ------------------
  |  Branch (56:14): [True: 3, False: 1]
  ------------------
   57|      3|		if (register_hash(reghashes[i]) == -1) {
  ------------------
  |  Branch (57:7): [True: 0, False: 3]
  ------------------
   58|      0|			dropbear_exit("Error registering crypto");
   59|      0|		}
   60|      3|	}
   61|       |
   62|      1|#if DROPBEAR_LTC_PRNG
   63|      1|	dropbear_ltc_prng = register_prng(&dropbear_prng_desc);
   64|      1|	if (dropbear_ltc_prng == -1) {
  ------------------
  |  Branch (64:6): [True: 0, False: 1]
  ------------------
   65|      0|		dropbear_exit("Error registering crypto");
   66|      0|	}
   67|      1|#endif
   68|       |
   69|      1|	mp_rand_source(dropbear_rand_source);
   70|       |
   71|      1|#if DROPBEAR_ECC
   72|      1|	ltc_mp = ltm_desc;
   73|      1|	dropbear_ecc_fill_dp();
   74|      1|#endif
   75|      1|}

dropbear_curve25519_scalarmult:
  214|  4.25k|{
  215|  4.25k|  u8 z[32];
  216|  4.25k|  i64 x[80],r,i;
  217|  4.25k|  gf a,b,c,d,e,f;
  218|   131k|  FOR(i,31) z[i]=n[i];
  ------------------
  |  |   34|   136k|#define FOR(i,n) for (i = 0;i < n;++i)
  |  |  ------------------
  |  |  |  Branch (34:29): [True: 131k, False: 4.25k]
  |  |  ------------------
  ------------------
  219|  4.25k|  z[31]=(n[31]&127)|64;
  220|  4.25k|  z[0]&=248;
  221|  4.25k|  unpack25519(x,p);
  222|  68.1k|  FOR(i,16) {
  ------------------
  |  |   34|  72.3k|#define FOR(i,n) for (i = 0;i < n;++i)
  |  |  ------------------
  |  |  |  Branch (34:29): [True: 68.1k, False: 4.25k]
  |  |  ------------------
  ------------------
  223|  68.1k|    b[i]=x[i];
  224|  68.1k|    d[i]=a[i]=c[i]=0;
  225|  68.1k|  }
  226|  4.25k|  a[0]=d[0]=1;
  227|  1.08M|  for(i=254;i>=0;--i) {
  ------------------
  |  Branch (227:13): [True: 1.08M, False: 4.25k]
  ------------------
  228|  1.08M|    r=(z[i>>3]>>(i&7))&1;
  229|  1.08M|    sel25519(a,b,r);
  230|  1.08M|    sel25519(c,d,r);
  231|  1.08M|    A(e,a,c);
  232|  1.08M|    Z(a,a,c);
  233|  1.08M|    A(c,b,d);
  234|  1.08M|    Z(b,b,d);
  235|  1.08M|    S(d,e);
  236|  1.08M|    S(f,a);
  237|  1.08M|    M(a,c,a);
  238|  1.08M|    M(c,b,e);
  239|  1.08M|    A(e,a,c);
  240|  1.08M|    Z(a,a,c);
  241|  1.08M|    S(b,a);
  242|  1.08M|    Z(c,d,f);
  243|  1.08M|    M(a,c,_121665);
  244|  1.08M|    A(a,a,d);
  245|  1.08M|    M(c,c,a);
  246|  1.08M|    M(a,d,f);
  247|  1.08M|    M(d,b,x);
  248|  1.08M|    S(b,e);
  249|  1.08M|    sel25519(a,b,r);
  250|  1.08M|    sel25519(c,d,r);
  251|  1.08M|  }
  252|  68.1k|  FOR(i,16) {
  ------------------
  |  |   34|  72.3k|#define FOR(i,n) for (i = 0;i < n;++i)
  |  |  ------------------
  |  |  |  Branch (34:29): [True: 68.1k, False: 4.25k]
  |  |  ------------------
  ------------------
  253|  68.1k|    x[i+16]=a[i];
  254|  68.1k|    x[i+32]=c[i];
  255|  68.1k|    x[i+48]=b[i];
  256|  68.1k|    x[i+64]=d[i];
  257|  68.1k|  }
  258|  4.25k|  inv25519(x+32,x+32);
  259|  4.25k|  M(x+16,x+16,x+32);
  260|  4.25k|  pack25519(q,x+16);
  261|  4.25k|}
dropbear_ed25519_verify:
  506|     39|{
  507|     39|  hash_state hs;
  508|     39|  u8 t[32],h[64];
  509|     39|  gf p[4],q[4];
  510|       |
  511|     39|  if (slen < 64) return -1;
  ------------------
  |  Branch (511:7): [True: 0, False: 39]
  ------------------
  512|       |
  513|     39|  if (s_lt_l(s + 32) == -1) {
  ------------------
  |  Branch (513:7): [True: 11, False: 28]
  ------------------
  514|     11|    return -1;
  515|     11|  }
  516|       |
  517|     28|  if (unpackneg(q,pk)) return -1;
  ------------------
  |  Branch (517:7): [True: 11, False: 17]
  ------------------
  518|       |
  519|     17|  sha512_init(&hs);
  520|     17|  sha512_process(&hs,s,32);
  521|     17|  sha512_process(&hs,pk,32);
  522|     17|  sha512_process(&hs,m,mlen);
  523|     17|  sha512_done(&hs,h);
  524|       |
  525|     17|  reduce(h);
  526|     17|  scalarmult(p,q,h);
  527|       |
  528|     17|  scalarbase(q,s + 32);
  529|     17|  add(p,q);
  530|     17|  pack(t,p);
  531|       |
  532|     17|  if (crypto_verify_32(s, t))
  ------------------
  |  Branch (532:7): [True: 17, False: 0]
  ------------------
  533|     17|    return -1;
  534|       |
  535|      0|  return 0;
  536|     17|}
curve25519.c:unpack25519:
  152|  4.28k|{
  153|  4.28k|  int i;
  154|  68.5k|  FOR(i,16) o[i]=n[2*i]+((i64)n[2*i+1]<<8);
  ------------------
  |  |   34|  72.8k|#define FOR(i,n) for (i = 0;i < n;++i)
  |  |  ------------------
  |  |  |  Branch (34:29): [True: 68.5k, False: 4.28k]
  |  |  ------------------
  ------------------
  155|  4.28k|  o[15]&=0x7fff;
  156|  4.28k|}
curve25519.c:sel25519:
   98|  4.42M|{
   99|  4.42M|  i64 t,i,c=~(b-1);
  100|  70.7M|  FOR(i,16) {
  ------------------
  |  |   34|  75.1M|#define FOR(i,n) for (i = 0;i < n;++i)
  |  |  ------------------
  |  |  |  Branch (34:29): [True: 70.7M, False: 4.42M]
  |  |  ------------------
  ------------------
  101|  70.7M|    t= c&(p[i]^q[i]);
  102|  70.7M|    p[i]^=t;
  103|  70.7M|    q[i]^=t;
  104|  70.7M|  }
  105|  4.42M|}
curve25519.c:A:
  159|  4.42M|{
  160|  4.42M|  int i;
  161|  70.8M|  FOR(i,16) o[i]=a[i]+b[i];
  ------------------
  |  |   34|  75.2M|#define FOR(i,n) for (i = 0;i < n;++i)
  |  |  ------------------
  |  |  |  Branch (34:29): [True: 70.8M, False: 4.42M]
  |  |  ------------------
  ------------------
  162|  4.42M|}
curve25519.c:Z:
  165|  4.41M|{
  166|  4.41M|  int i;
  167|  70.5M|  FOR(i,16) o[i]=a[i]-b[i];
  ------------------
  |  |   34|  75.0M|#define FOR(i,n) for (i = 0;i < n;++i)
  |  |  ------------------
  |  |  |  Branch (34:29): [True: 70.5M, False: 4.41M]
  |  |  ------------------
  ------------------
  168|  4.41M|}
curve25519.c:S:
  182|  5.43M|{
  183|  5.43M|  M(o,a,a);
  184|  5.43M|}
curve25519.c:M:
  171|  13.1M|{
  172|  13.1M|  i64 i,j,t[31];
  173|   408M|  FOR(i,31) t[i]=0;
  ------------------
  |  |   34|   422M|#define FOR(i,n) for (i = 0;i < n;++i)
  |  |  ------------------
  |  |  |  Branch (34:29): [True: 408M, False: 13.1M]
  |  |  ------------------
  ------------------
  174|  3.37G|  FOR(i,16) FOR(j,16) t[i+j]+=a[i]*b[j];
  ------------------
  |  |   34|   224M|#define FOR(i,n) for (i = 0;i < n;++i)
  |  |  ------------------
  |  |  |  Branch (34:29): [True: 211M, False: 13.1M]
  |  |  ------------------
  ------------------
                FOR(i,16) FOR(j,16) t[i+j]+=a[i]*b[j];
  ------------------
  |  |   34|  3.58G|#define FOR(i,n) for (i = 0;i < n;++i)
  |  |  ------------------
  |  |  |  Branch (34:29): [True: 3.37G, False: 211M]
  |  |  ------------------
  ------------------
  175|   197M|  FOR(i,15) t[i]+=38*t[i+16];
  ------------------
  |  |   34|   211M|#define FOR(i,n) for (i = 0;i < n;++i)
  |  |  ------------------
  |  |  |  Branch (34:29): [True: 197M, False: 13.1M]
  |  |  ------------------
  ------------------
  176|   211M|  FOR(i,16) o[i]=t[i];
  ------------------
  |  |   34|   224M|#define FOR(i,n) for (i = 0;i < n;++i)
  |  |  ------------------
  |  |  |  Branch (34:29): [True: 211M, False: 13.1M]
  |  |  ------------------
  ------------------
  177|  13.1M|  car25519(o);
  178|  13.1M|  car25519(o);
  179|  13.1M|}
curve25519.c:car25519:
   86|  26.3M|{
   87|  26.3M|  int i;
   88|  26.3M|  i64 c;
   89|   422M|  FOR(i,16) {
  ------------------
  |  |   34|   448M|#define FOR(i,n) for (i = 0;i < n;++i)
  |  |  ------------------
  |  |  |  Branch (34:29): [True: 422M, False: 26.3M]
  |  |  ------------------
  ------------------
   90|   422M|    o[i]+=(1LL<<16);
   91|   422M|    c=o[i]>>16;
   92|   422M|    o[(i+1)*(i<15)]+=c-1+37*(c-1)*(i==15);
   93|   422M|    o[i]-=((u64)c)<<16;
   94|   422M|  }
   95|  26.3M|}
curve25519.c:inv25519:
  187|  4.27k|{
  188|  4.27k|  gf c;
  189|  4.27k|  int a;
  190|  68.3k|  FOR(a,16) c[a]=i[a];
  ------------------
  |  |   34|  72.6k|#define FOR(i,n) for (i = 0;i < n;++i)
  |  |  ------------------
  |  |  |  Branch (34:29): [True: 68.3k, False: 4.27k]
  |  |  ------------------
  ------------------
  191|  1.08M|  for(a=253;a>=0;a--) {
  ------------------
  |  Branch (191:13): [True: 1.08M, False: 4.27k]
  ------------------
  192|  1.08M|    S(c,c);
  193|  1.08M|    if(a!=2&&a!=4) M(c,c,i);
  ------------------
  |  Branch (193:8): [True: 1.08M, False: 4.27k]
  |  Branch (193:14): [True: 1.07M, False: 4.27k]
  ------------------
  194|  1.08M|  }
  195|  68.3k|  FOR(a,16) o[a]=c[a];
  ------------------
  |  |   34|  72.6k|#define FOR(i,n) for (i = 0;i < n;++i)
  |  |  ------------------
  |  |  |  Branch (34:29): [True: 68.3k, False: 4.27k]
  |  |  ------------------
  ------------------
  196|  4.27k|}
curve25519.c:pack25519:
  108|  4.41k|{
  109|  4.41k|  int i,j,b;
  110|  4.41k|  gf m,t;
  111|  70.6k|  FOR(i,16) t[i]=n[i];
  ------------------
  |  |   34|  75.0k|#define FOR(i,n) for (i = 0;i < n;++i)
  |  |  ------------------
  |  |  |  Branch (34:29): [True: 70.6k, False: 4.41k]
  |  |  ------------------
  ------------------
  112|  4.41k|  car25519(t);
  113|  4.41k|  car25519(t);
  114|  4.41k|  car25519(t);
  115|  8.83k|  FOR(j,2) {
  ------------------
  |  |   34|  13.2k|#define FOR(i,n) for (i = 0;i < n;++i)
  |  |  ------------------
  |  |  |  Branch (34:29): [True: 8.83k, False: 4.41k]
  |  |  ------------------
  ------------------
  116|  8.83k|    m[0]=t[0]-0xffed;
  117|   132k|    for(i=1;i<15;i++) {
  ------------------
  |  Branch (117:13): [True: 123k, False: 8.83k]
  ------------------
  118|   123k|      m[i]=t[i]-0xffff-((m[i-1]>>16)&1);
  119|   123k|      m[i-1]&=0xffff;
  120|   123k|    }
  121|  8.83k|    m[15]=t[15]-0x7fff-((m[14]>>16)&1);
  122|  8.83k|    b=(m[15]>>16)&1;
  123|  8.83k|    m[14]&=0xffff;
  124|  8.83k|    sel25519(t,m,1-b);
  125|  8.83k|  }
  126|  70.6k|  FOR(i,16) {
  ------------------
  |  |   34|  75.0k|#define FOR(i,n) for (i = 0;i < n;++i)
  |  |  ------------------
  |  |  |  Branch (34:29): [True: 70.6k, False: 4.41k]
  |  |  ------------------
  ------------------
  127|  70.6k|    o[2*i]=t[i]&0xff;
  128|  70.6k|    o[2*i+1]=t[i]>>8;
  129|  70.6k|  }
  130|  4.41k|}
curve25519.c:scalarbase:
  333|     17|{
  334|     17|  gf q[4];
  335|     17|  set25519(q[0],X);
  336|     17|  set25519(q[1],Y);
  337|     17|  set25519(q[2],gf1);
  338|     17|  M(q[3],X,Y);
  339|     17|  scalarmult(p,q,s);
  340|     17|}
curve25519.c:set25519:
   79|    215|{
   80|    215|  int i;
   81|  3.44k|  FOR(i,16) r[i]=a[i];
  ------------------
  |  |   34|  3.65k|#define FOR(i,n) for (i = 0;i < n;++i)
  |  |  ------------------
  |  |  |  Branch (34:29): [True: 3.44k, False: 215]
  |  |  ------------------
  ------------------
   82|    215|}
curve25519.c:pack:
  307|     17|{
  308|     17|  gf tx, ty, zi;
  309|     17|  inv25519(zi, p[2]); 
  310|     17|  M(tx, p[0], zi);
  311|     17|  M(ty, p[1], zi);
  312|     17|  pack25519(r, ty);
  313|     17|  r[31] ^= par25519(tx) << 7;
  314|     17|}
curve25519.c:par25519:
  144|     34|{
  145|     34|  u8 d[32];
  146|     34|  pack25519(d,a);
  147|     34|  return d[0]&1;
  148|     34|}
curve25519.c:reduce:
  387|     17|{
  388|     17|  i64 x[64],i;
  389|  1.08k|  FOR(i,64) x[i] = (u64) r[i];
  ------------------
  |  |   34|  1.10k|#define FOR(i,n) for (i = 0;i < n;++i)
  |  |  ------------------
  |  |  |  Branch (34:29): [True: 1.08k, False: 17]
  |  |  ------------------
  ------------------
  390|  1.08k|  FOR(i,64) r[i] = 0;
  ------------------
  |  |   34|  1.10k|#define FOR(i,n) for (i = 0;i < n;++i)
  |  |  ------------------
  |  |  |  Branch (34:29): [True: 1.08k, False: 17]
  |  |  ------------------
  ------------------
  391|     17|  modL(r,x);
  392|     17|}
curve25519.c:modL:
  361|     17|{
  362|     17|  i64 carry,i,j;
  363|    561|  for (i = 63;i >= 32;--i) {
  ------------------
  |  Branch (363:15): [True: 544, False: 17]
  ------------------
  364|    544|    carry = 0;
  365|  11.4k|    for (j = i - 32;j < i - 12;++j) {
  ------------------
  |  Branch (365:21): [True: 10.8k, False: 544]
  ------------------
  366|  10.8k|      x[j] += carry - 16 * x[i] * L[j - (i - 32)];
  367|  10.8k|      carry = (x[j] + 128) >> 8;
  368|  10.8k|      x[j] -= ((u64)carry) << 8;
  369|  10.8k|    }
  370|    544|    x[j] += carry;
  371|    544|    x[i] = 0;
  372|    544|  }
  373|     17|  carry = 0;
  374|    544|  FOR(j,32) {
  ------------------
  |  |   34|    561|#define FOR(i,n) for (i = 0;i < n;++i)
  |  |  ------------------
  |  |  |  Branch (34:29): [True: 544, False: 17]
  |  |  ------------------
  ------------------
  375|    544|    x[j] += carry - (x[31] >> 4) * L[j];
  376|    544|    carry = x[j] >> 8;
  377|    544|    x[j] &= 255;
  378|    544|  }
  379|    544|  FOR(j,32) x[j] -= carry * L[j];
  ------------------
  |  |   34|    561|#define FOR(i,n) for (i = 0;i < n;++i)
  |  |  ------------------
  |  |  |  Branch (34:29): [True: 544, False: 17]
  |  |  ------------------
  ------------------
  380|    544|  FOR(i,32) {
  ------------------
  |  |   34|    561|#define FOR(i,n) for (i = 0;i < n;++i)
  |  |  ------------------
  |  |  |  Branch (34:29): [True: 544, False: 17]
  |  |  ------------------
  ------------------
  381|    544|    x[i+1] += x[i] >> 8;
  382|    544|    r[i] = x[i] & 255;
  383|    544|  }
  384|     17|}
curve25519.c:s_lt_l:
  434|     39|static int s_lt_l(const u8 *s) {
  435|     39|  int i;
  436|     93|  for (i = 31; i >= 0; i--) {
  ------------------
  |  Branch (436:16): [True: 93, False: 0]
  ------------------
  437|     93|    if (s[i] < L[i]) {
  ------------------
  |  Branch (437:9): [True: 28, False: 65]
  ------------------
  438|     28|      return 0;
  439|     28|    }
  440|     65|    if (s[i] > L[i]) {
  ------------------
  |  Branch (440:9): [True: 11, False: 54]
  ------------------
  441|     11|      return -1;
  442|     11|    }
  443|     65|  }
  444|      0|  return -1;
  445|     39|}
curve25519.c:unpackneg:
  464|     28|{
  465|     28|  gf t, chk, num, den, den2, den4, den6;
  466|     28|  set25519(r[2],gf1);
  467|     28|  unpack25519(r[1],p);
  468|       |
  469|       |  /* Check that pubkey y < 2^255 - 19 */
  470|     28|  if (y_lt_p(r[1])) {
  ------------------
  |  Branch (470:7): [True: 1, False: 27]
  ------------------
  471|      1|    return -1;
  472|      1|  }
  473|       |
  474|     27|  S(num,r[1]);
  475|     27|  M(den,num,D);
  476|     27|  Z(num,num,r[2]);
  477|     27|  A(den,r[2],den);
  478|       |
  479|     27|  S(den2,den);
  480|     27|  S(den4,den2);
  481|     27|  M(den6,den4,den2);
  482|     27|  M(t,den6,num);
  483|     27|  M(t,t,den);
  484|       |
  485|     27|  pow2523(t,t);
  486|     27|  M(t,t,num);
  487|     27|  M(t,t,den);
  488|     27|  M(t,t,den);
  489|     27|  M(r[0],t,den);
  490|       |
  491|     27|  S(chk,r[0]);
  492|     27|  M(chk,chk,den);
  493|     27|  if (neq25519(chk, num)) M(r[0],r[0],I);
  ------------------
  |  Branch (493:7): [True: 16, False: 11]
  ------------------
  494|       |
  495|     27|  S(chk,r[0]);
  496|     27|  M(chk,chk,den);
  497|     27|  if (neq25519(chk, num)) return -1;
  ------------------
  |  Branch (497:7): [True: 10, False: 17]
  ------------------
  498|       |
  499|     17|  if (par25519(r[0]) == (p[31]>>7)) Z(r[0],gf0,r[0]);
  ------------------
  |  Branch (499:7): [True: 4, False: 13]
  ------------------
  500|       |
  501|     17|  M(r[3],r[0],r[1]);
  502|     17|  return 0;
  503|     27|}
curve25519.c:y_lt_p:
  450|     28|static int y_lt_p(const gf y) {
  451|     28|  int i;
  452|     77|  for (i = 15; i >= 0; i--) {
  ------------------
  |  Branch (452:16): [True: 77, False: 0]
  ------------------
  453|     77|    if (y[i] < field_prime[i]) {
  ------------------
  |  Branch (453:9): [True: 27, False: 50]
  ------------------
  454|     27|      return 0;
  455|     27|    }
  456|     50|    if (y[i] > field_prime[i]) {
  ------------------
  |  Branch (456:9): [True: 1, False: 49]
  ------------------
  457|      1|      return -1;
  458|      1|    }
  459|     50|  }
  460|      0|  return -1;
  461|     28|}
curve25519.c:pow2523:
  200|     27|{
  201|     27|  gf c;
  202|     27|  int a;
  203|    432|  FOR(a,16) c[a]=i[a];
  ------------------
  |  |   34|    459|#define FOR(i,n) for (i = 0;i < n;++i)
  |  |  ------------------
  |  |  |  Branch (34:29): [True: 432, False: 27]
  |  |  ------------------
  ------------------
  204|  6.80k|  for(a=250;a>=0;a--) {
  ------------------
  |  Branch (204:13): [True: 6.77k, False: 27]
  ------------------
  205|  6.77k|    S(c,c);
  206|  6.77k|    if(a!=1) M(c,c,i);
  ------------------
  |  Branch (206:8): [True: 6.75k, False: 27]
  ------------------
  207|  6.77k|  }
  208|    432|  FOR(a,16) o[a]=c[a];
  ------------------
  |  |   34|    459|#define FOR(i,n) for (i = 0;i < n;++i)
  |  |  ------------------
  |  |  |  Branch (34:29): [True: 432, False: 27]
  |  |  ------------------
  ------------------
  209|     27|}
curve25519.c:neq25519:
  135|     54|{
  136|     54|  u8 c[32],d[32];
  137|     54|  pack25519(c,a);
  138|     54|  pack25519(d,b);
  139|     54|  return crypto_verify_32(c,d);
  140|     54|}
curve25519.c:scalarmult:
  317|     34|{
  318|     34|  int i;
  319|     34|  set25519(p[0],gf0);
  320|     34|  set25519(p[1],gf1);
  321|     34|  set25519(p[2],gf1);
  322|     34|  set25519(p[3],gf0);
  323|  8.73k|  for (i = 255;i >= 0;--i) {
  ------------------
  |  Branch (323:16): [True: 8.70k, False: 34]
  ------------------
  324|  8.70k|    u8 b = (s[i/8]>>(i&7))&1;
  325|  8.70k|    cswap(p,q,b);
  326|  8.70k|    add(q,p);
  327|  8.70k|    add(p,p);
  328|  8.70k|    cswap(p,q,b);
  329|  8.70k|  }
  330|     34|}
curve25519.c:cswap:
  300|  17.4k|{
  301|  17.4k|  int i;
  302|  17.4k|  FOR(i,4)
  ------------------
  |  |   34|  87.0k|#define FOR(i,n) for (i = 0;i < n;++i)
  |  |  ------------------
  |  |  |  Branch (34:29): [True: 69.6k, False: 17.4k]
  |  |  ------------------
  ------------------
  303|  69.6k|    sel25519(p[i],q[i],b);
  304|  17.4k|}
curve25519.c:add:
  275|  17.4k|{
  276|  17.4k|  gf a,b,c,d,t,e,f,g,h;
  277|       |  
  278|  17.4k|  Z(a, p[1], p[0]);
  279|  17.4k|  Z(t, q[1], q[0]);
  280|  17.4k|  M(a, a, t);
  281|  17.4k|  A(b, p[0], p[1]);
  282|  17.4k|  A(t, q[0], q[1]);
  283|  17.4k|  M(b, b, t);
  284|  17.4k|  M(c, p[3], q[3]);
  285|  17.4k|  M(c, c, D2);
  286|  17.4k|  M(d, p[2], q[2]);
  287|  17.4k|  A(d, d, d);
  288|  17.4k|  Z(e, b, a);
  289|  17.4k|  Z(f, d, c);
  290|  17.4k|  A(g, d, c);
  291|  17.4k|  A(h, b, a);
  292|       |
  293|  17.4k|  M(p[0], e, f);
  294|  17.4k|  M(p[1], h, g);
  295|  17.4k|  M(p[2], g, f);
  296|  17.4k|  M(p[3], e, h);
  297|  17.4k|}
curve25519.c:crypto_verify_32:
   73|     71|{
   74|     71|  return vn(x,y,32);
   75|     71|}
curve25519.c:vn:
   66|     71|{
   67|     71|  u32 i,d = 0;
   68|  2.27k|  FOR(i,n) d |= x[i]^y[i];
  ------------------
  |  |   34|  2.34k|#define FOR(i,n) for (i = 0;i < n;++i)
  |  |  ------------------
  |  |  |  Branch (34:29): [True: 2.27k, False: 71]
  |  |  ------------------
  ------------------
   69|     71|  return (1 & ((d - 1) >> 8)) - 1;
   70|     71|}

m_burn:
    5|  5.35M|void m_burn(void *data, unsigned int len) {
    6|       |
    7|       |#if defined(HAVE_MEMSET_S)
    8|       |	memset_s(data, len, 0x0, len);
    9|       |#elif defined(HAVE_EXPLICIT_BZERO)
   10|       |	explicit_bzero(data, len);
   11|       |#else
   12|       |	/* This must be volatile to avoid compiler optimisation */
   13|       |	volatile void *p = data;
   14|       |	memset((void*)p, 0x0, len);
   15|       |#endif
   16|  5.35M|}

m_calloc:
    5|  6.34M|void * m_calloc(size_t nmemb, size_t size) {
    6|  6.34M|    if (SIZE_T_MAX / nmemb < size) {
  ------------------
  |  |  175|  6.34M|#define SIZE_T_MAX ULONG_MAX
  ------------------
  |  Branch (6:9): [True: 0, False: 6.34M]
  ------------------
    7|      0|        dropbear_exit("m_calloc failed");
    8|      0|    }
    9|  6.34M|    return m_malloc(nmemb*size);
   10|  6.34M|}
m_strdup:
   12|      6|void * m_strdup(const char * str) {
   13|      6|    char* ret;
   14|      6|    unsigned int len;
   15|      6|    len = strlen(str);
   16|       |
   17|      6|    ret = m_malloc(len+1);
   18|      6|    if (ret == NULL) {
  ------------------
  |  Branch (18:9): [True: 0, False: 6]
  ------------------
   19|      0|        dropbear_exit("m_strdup failed");
   20|      0|    }
   21|      6|    memcpy(ret, str, len+1);
   22|      6|    return ret;
   23|      6|}
m_malloc_set_epoch:
   76|  3.41k|void m_malloc_set_epoch(unsigned int epoch) {
   77|  3.41k|    current_epoch = epoch;
   78|  3.41k|}
m_malloc_free_epoch:
   80|  3.41k|void m_malloc_free_epoch(unsigned int epoch, int dofree) {
   81|  3.41k|    struct dbmalloc_header* header;
   82|  3.41k|    struct dbmalloc_header* nextheader = NULL;
   83|  3.41k|    struct dbmalloc_header* oldstaple = staple;
   84|  3.41k|    staple = NULL;
   85|       |    /* free allocations from this epoch, create a new staple-anchored list from
   86|       |    the remainder */
   87|  3.49M|    for (header = oldstaple; header; header = nextheader)
  ------------------
  |  Branch (87:30): [True: 3.49M, False: 3.41k]
  ------------------
   88|  3.49M|    {
   89|  3.49M|        nextheader = header->next;
   90|  3.49M|        if (header->epoch == epoch) {
  ------------------
  |  Branch (90:13): [True: 21.5k, False: 3.46M]
  ------------------
   91|  21.5k|            if (dofree) {
  ------------------
  |  Branch (91:17): [True: 21.5k, False: 0]
  ------------------
   92|  21.5k|                free(header);
   93|  21.5k|            }
   94|  3.46M|        } else {
   95|  3.46M|            header->prev = NULL;
   96|       |            header->next = NULL;
   97|  3.46M|            put_alloc(header);
   98|  3.46M|        }
   99|  3.49M|    }
  100|  3.41k|}
m_malloc:
  131|  6.51M|void * m_malloc(size_t size) {
  132|  6.51M|    char* mem = NULL;
  133|  6.51M|    struct dbmalloc_header* header = NULL;
  134|       |
  135|  6.51M|    if (size == 0 || size > 1e9) {
  ------------------
  |  Branch (135:9): [True: 0, False: 6.51M]
  |  Branch (135:22): [True: 0, False: 6.51M]
  ------------------
  136|      0|        dropbear_exit("m_malloc failed");
  137|      0|    }
  138|       |
  139|  6.51M|    size = size + sizeof(struct dbmalloc_header);
  140|       |
  141|  6.51M|    mem = calloc(1, size);
  142|  6.51M|    if (mem == NULL) {
  ------------------
  |  Branch (142:9): [True: 0, False: 6.51M]
  ------------------
  143|      0|        dropbear_exit("m_malloc failed");
  144|      0|    }
  145|  6.51M|    header = (struct dbmalloc_header*)mem;
  146|  6.51M|    put_alloc(header);
  147|  6.51M|    header->epoch = current_epoch;
  148|  6.51M|    return &mem[sizeof(struct dbmalloc_header)];
  149|  6.51M|}
m_realloc:
  151|   260k|void * m_realloc(void* ptr, size_t size) {
  152|   260k|    char* mem = NULL;
  153|   260k|    struct dbmalloc_header* header = NULL;
  154|   260k|    if (size == 0 || size > 1e9) {
  ------------------
  |  Branch (154:9): [True: 0, False: 260k]
  |  Branch (154:22): [True: 0, False: 260k]
  ------------------
  155|      0|        dropbear_exit("m_realloc failed");
  156|      0|    }
  157|       |
  158|   260k|    header = get_header(ptr);
  159|   260k|    remove_alloc(header);
  160|       |
  161|   260k|    size = size + sizeof(struct dbmalloc_header);
  162|   260k|    mem = realloc(header, size);
  163|   260k|    if (mem == NULL) {
  ------------------
  |  Branch (163:9): [True: 0, False: 260k]
  ------------------
  164|      0|        dropbear_exit("m_realloc failed");
  165|      0|    }
  166|       |
  167|   260k|    header = (struct dbmalloc_header*)mem;
  168|   260k|    put_alloc(header);
  169|   260k|    return &mem[sizeof(struct dbmalloc_header)];
  170|   260k|}
m_free_direct:
  172|  6.50M|void m_free_direct(void* ptr) {
  173|  6.50M|    struct dbmalloc_header* header = NULL;
  174|  6.50M|    if (!ptr) {
  ------------------
  |  Branch (174:9): [True: 20.0k, False: 6.48M]
  ------------------
  175|  20.0k|        return;
  176|  20.0k|    }
  177|  6.48M|    header = get_header(ptr);
  178|  6.48M|    remove_alloc(header);
  179|  6.48M|    free(header);
  180|  6.48M|}
m_realloc_ltm:
  184|   256k|void * m_realloc_ltm(void* ptr, size_t oldsize, size_t newsize) {
  185|   256k|   (void)oldsize;
  186|   256k|   return m_realloc(ptr, newsize);
  187|   256k|}
m_free_ltm:
  189|  3.29M|void m_free_ltm(void *mem, size_t size) {
  190|  3.29M|   (void)size;
  191|  3.29M|   m_free_direct(mem);
  192|  3.29M|}
dbmalloc.c:put_alloc:
  102|  10.2M|static void put_alloc(struct dbmalloc_header *header) {
  103|  10.2M|    assert(header->next == NULL);
  ------------------
  |  Branch (103:5): [True: 0, False: 10.2M]
  |  Branch (103:5): [True: 10.2M, False: 0]
  ------------------
  104|  10.2M|    assert(header->prev == NULL);
  ------------------
  |  Branch (104:5): [True: 0, False: 10.2M]
  |  Branch (104:5): [True: 10.2M, False: 0]
  ------------------
  105|  10.2M|    if (staple) {
  ------------------
  |  Branch (105:9): [True: 10.2M, False: 3.42k]
  ------------------
  106|  10.2M|        staple->prev = header;
  107|  10.2M|    }
  108|  10.2M|    header->next = staple;
  109|  10.2M|    staple = header;
  110|  10.2M|}
dbmalloc.c:get_header:
  126|  6.74M|static struct dbmalloc_header* get_header(void* ptr) {
  127|  6.74M|    char* bptr = ptr;
  128|  6.74M|    return (struct dbmalloc_header*)&bptr[-sizeof(struct dbmalloc_header)];
  129|  6.74M|}
dbmalloc.c:remove_alloc:
  112|  6.74M|static void remove_alloc(struct dbmalloc_header *header) {
  113|  6.74M|    if (header->prev) {
  ------------------
  |  Branch (113:9): [True: 4.76M, False: 1.98M]
  ------------------
  114|  4.76M|        header->prev->next = header->next;
  115|  4.76M|    }
  116|  6.74M|    if (header->next) {
  ------------------
  |  Branch (116:9): [True: 6.74M, False: 0]
  ------------------
  117|  6.74M|        header->next->prev = header->prev;
  118|  6.74M|    }
  119|  6.74M|    if (staple == header) {
  ------------------
  |  Branch (119:9): [True: 1.98M, False: 4.76M]
  ------------------
  120|  1.98M|        staple = header->next;
  121|  1.98M|    }
  122|  6.74M|    header->prev = NULL;
  123|       |    header->next = NULL;
  124|  6.74M|}

fuzz_seed:
  153|  3.41k|void fuzz_seed(const unsigned char* dat, unsigned int len) {
  154|  3.41k|	hash_state hs;
  155|  3.41k|	sha256_init(&hs);
  156|  3.41k|	sha256_process(&hs, "fuzzfuzzfuzz", strlen("fuzzfuzzfuzz"));
  157|  3.41k|	sha256_process(&hs, dat, len);
  158|  3.41k|	sha256_done(&hs, hashpool);
  159|  3.41k|	counter = 0;
  160|  3.41k|	donerandinit = 1;
  161|  3.41k|}
genrandom:
  313|  5.33M|void genrandom(unsigned char* buf, unsigned int len) {
  314|       |
  315|  5.33M|	hash_state hs;
  316|  5.33M|	unsigned char hash[SHA256_HASH_SIZE];
  317|  5.33M|	unsigned int copylen;
  318|       |
  319|  5.33M|	if (!donerandinit) {
  ------------------
  |  Branch (319:6): [True: 0, False: 5.33M]
  ------------------
  320|      0|		dropbear_exit("seedrandom not done");
  321|      0|	}
  322|       |
  323|  10.6M|	while (len > 0) {
  ------------------
  |  Branch (323:9): [True: 5.35M, False: 5.33M]
  ------------------
  324|  5.35M|		sha256_init(&hs);
  325|  5.35M|		sha256_process(&hs, (void*)hashpool, sizeof(hashpool));
  326|  5.35M|		sha256_process(&hs, (void*)&counter, sizeof(counter));
  327|  5.35M|		sha256_done(&hs, hash);
  328|       |
  329|  5.35M|		counter++;
  330|  5.35M|		if (counter > MAX_COUNTER) {
  ------------------
  |  |   35|  5.35M|#define MAX_COUNTER (1<<30)
  ------------------
  |  Branch (330:7): [True: 0, False: 5.35M]
  ------------------
  331|      0|			seedrandom();
  332|      0|		}
  333|       |
  334|       |		copylen = MIN(len, SHA256_HASH_SIZE);
  ------------------
  |  Branch (334:13): [True: 5.32M, False: 31.4k]
  ------------------
  335|  5.35M|		memcpy(buf, hash, copylen);
  336|  5.35M|		len -= copylen;
  337|  5.35M|		buf += copylen;
  338|  5.35M|	}
  339|  5.33M|	m_burn(hash, sizeof(hash));
  340|  5.33M|}
gen_random_mpint:
  347|  1.08k|void gen_random_mpint(const mp_int *max, mp_int *rand) {
  348|       |
  349|  1.08k|	unsigned char *randbuf = NULL;
  350|  1.08k|	unsigned int len = 0;
  351|  1.08k|	const unsigned char masks[] = {0xff, 0x01, 0x03, 0x07, 0x0f, 0x1f, 0x3f, 0x7f};
  352|       |
  353|  1.08k|	const int size_bits = mp_count_bits(max);
  354|       |
  355|  1.08k|	len = size_bits / 8;
  356|  1.08k|	if ((size_bits % 8) != 0) {
  ------------------
  |  Branch (356:6): [True: 1.08k, False: 0]
  ------------------
  357|  1.08k|		len += 1;
  358|  1.08k|	}
  359|       |
  360|  1.08k|	randbuf = (unsigned char*)m_malloc(len);
  361|  1.08k|	do {
  362|  1.08k|		genrandom(randbuf, len);
  363|       |		/* Mask out the unrequired bits - mp_read_unsigned_bin expects
  364|       |		 * MSB first.*/
  365|  1.08k|		randbuf[0] &= masks[size_bits % 8];
  366|       |
  367|  1.08k|		bytes_to_mp(rand, randbuf, len);
  368|       |
  369|       |		/* keep regenerating until we get one satisfying
  370|       |		 * 0 < rand < max    */
  371|  1.08k|	} while (!(mp_cmp(rand, max) == MP_LT && mp_cmp_d(rand, 0) == MP_GT));
  ------------------
  |  |  154|  2.16k|#define MP_LT        -1   /* less than */
  ------------------
              	} while (!(mp_cmp(rand, max) == MP_LT && mp_cmp_d(rand, 0) == MP_GT));
  ------------------
  |  |  156|  1.08k|#define MP_GT         1   /* greater than */
  ------------------
  |  Branch (371:13): [True: 1.08k, False: 0]
  |  Branch (371:43): [True: 1.08k, False: 0]
  ------------------
  372|  1.08k|	m_burn(randbuf, len);
  373|       |	m_free(randbuf);
  ------------------
  |  |   24|  1.08k|#define m_free(X) do {m_free_direct(X); (X) = NULL;} while (0)
  |  |  ------------------
  |  |  |  Branch (24:61): [Folded, False: 1.08k]
  |  |  ------------------
  ------------------
  374|  1.08k|}

dropbear_close:
   95|      4|void dropbear_close(const char* format, ...) {
   96|       |
   97|      4|	va_list param;
   98|       |
   99|      4|	va_start(param, format);
  100|      4|	_dropbear_exit(EXIT_SUCCESS, format, param);
  101|      4|	va_end(param);
  102|       |
  103|      0|}
dropbear_exit:
  105|  3.41k|void dropbear_exit(const char* format, ...) {
  106|       |
  107|  3.41k|	va_list param;
  108|       |
  109|  3.41k|	va_start(param, format);
  110|  3.41k|	_dropbear_exit(EXIT_FAILURE, format, param);
  111|  3.41k|	va_end(param);
  112|      0|}
dropbear_log:
  148|     71|void dropbear_log(int priority, const char* format, ...) {
  149|       |
  150|     71|	va_list param;
  151|       |
  152|     71|	va_start(param, format);
  153|     71|	_dropbear_log(priority, format, param);
  154|       |	va_end(param);
  155|     71|}
buf_readfile:
  489|      1|int buf_readfile(buffer* buf, const char* filename) {
  490|       |
  491|      1|	int fd = -1;
  492|      1|	int len;
  493|      1|	int maxlen;
  494|      1|	int ret = DROPBEAR_FAILURE;
  ------------------
  |  |  112|      1|#define DROPBEAR_FAILURE -1
  ------------------
  495|       |
  496|      1|	fd = open(filename, O_RDONLY);
  497|       |
  498|      1|	if (fd < 0) {
  ------------------
  |  Branch (498:6): [True: 1, False: 0]
  ------------------
  499|      1|		goto out;
  500|      1|	}
  501|       |	
  502|      0|	do {
  503|      0|		maxlen = buf->size - buf->pos;
  504|      0|		len = read(fd, buf_getwriteptr(buf, maxlen), maxlen);
  ------------------
  |  |   55|      0|#define read(fd, buf, count) wrapfd_read(fd, buf, count)
  ------------------
  505|      0|		if (len < 0) {
  ------------------
  |  Branch (505:7): [True: 0, False: 0]
  ------------------
  506|      0|			if (errno == EINTR || errno == EAGAIN) {
  ------------------
  |  Branch (506:8): [True: 0, False: 0]
  |  Branch (506:26): [True: 0, False: 0]
  ------------------
  507|      0|				continue;
  508|      0|			}
  509|      0|			goto out;
  510|      0|		}
  511|      0|		buf_incrwritepos(buf, len);
  512|      0|	} while (len < maxlen && len > 0);
  ------------------
  |  Branch (512:11): [True: 0, False: 0]
  |  Branch (512:27): [True: 0, False: 0]
  ------------------
  513|       |
  514|      0|	ret = DROPBEAR_SUCCESS;
  ------------------
  |  |  111|      0|#define DROPBEAR_SUCCESS 0
  ------------------
  515|       |
  516|      1|out:
  517|      1|	if (fd >= 0) {
  ------------------
  |  Branch (517:6): [True: 0, False: 1]
  ------------------
  518|      0|		m_close(fd);
  519|      0|	}
  520|      1|	return ret;
  521|      0|}
m_close:
  615|  11.9k|void m_close(int fd) {
  616|  11.9k|	int val;
  617|       |
  618|  11.9k|	if (fd < 0) {
  ------------------
  |  Branch (618:6): [True: 0, False: 11.9k]
  ------------------
  619|      0|		return;
  620|      0|	}
  621|       |
  622|  11.9k|	do {
  623|  11.9k|		val = close(fd);
  ------------------
  |  |   56|  11.9k|#define close(fd) wrapfd_close(fd)
  ------------------
  624|  11.9k|	} while (val < 0 && errno == EINTR);
  ------------------
  |  Branch (624:11): [True: 861, False: 11.1k]
  |  Branch (624:22): [True: 0, False: 861]
  ------------------
  625|       |
  626|  11.9k|	if (val < 0 && errno != EBADF) {
  ------------------
  |  Branch (626:6): [True: 861, False: 11.1k]
  |  Branch (626:17): [True: 0, False: 861]
  ------------------
  627|       |		/* Linux says EIO can happen */
  628|       |		dropbear_exit("Error closing fd %d, %s", fd, strerror(errno));
  629|      0|	}
  630|  11.9k|}
setnonblocking:
  632|  6.83k|void setnonblocking(int fd) {
  633|       |
  634|  6.83k|	int fl = 0;
  635|  6.83k|	TRACE(("setnonblocking: %d", fd))
  636|       |
  637|  6.83k|#if DROPBEAR_FUZZ
  638|  6.83k|	if (fuzz.fuzzing) {
  ------------------
  |  Branch (638:6): [True: 6.83k, False: 0]
  ------------------
  639|  6.83k|		return;
  640|  6.83k|	}
  641|      0|#endif
  642|      0|	fl = fcntl(fd, F_GETFL, 0);
  643|      0|	if (fl == -1) {
  ------------------
  |  Branch (643:6): [True: 0, False: 0]
  ------------------
  644|       |		/* F_GETFL shouldn't fail */
  645|      0|		dropbear_exit("Couldn't set nonblocking");
  646|      0|	}
  647|       |
  648|      0|	if (fcntl(fd, F_SETFL, fl | O_NONBLOCK) == -1) {
  ------------------
  |  Branch (648:6): [True: 0, False: 0]
  ------------------
  649|      0|		if (errno == ENODEV) {
  ------------------
  |  Branch (649:7): [True: 0, False: 0]
  ------------------
  650|       |			/* Some devices (like /dev/null redirected in)
  651|       |			 * can't be set to non-blocking */
  652|      0|			TRACE(("ignoring ENODEV for setnonblocking"))
  653|      0|		} else {
  654|      0|			dropbear_exit("Couldn't set nonblocking");
  655|      0|		}
  656|      0|	}
  657|      0|	TRACE(("leave setnonblocking"))
  658|      0|}
disallow_core:
  660|      1|void disallow_core() {
  661|      1|	struct rlimit lim = {0};
  662|      1|	if (getrlimit(RLIMIT_CORE, &lim) < 0) {
  ------------------
  |  Branch (662:6): [True: 0, False: 1]
  ------------------
  663|      0|		TRACE(("getrlimit(RLIMIT_CORE) failed"));
  664|      0|	}
  665|      1|	lim.rlim_cur = 0;
  666|      1|	if (setrlimit(RLIMIT_CORE, &lim) < 0) {
  ------------------
  |  Branch (666:6): [True: 0, False: 1]
  ------------------
  667|      0|		TRACE(("setrlimit(RLIMIT_CORE) failed"));
  668|      0|	}
  669|      1|}
expand_homedir_path_home:
  697|      2|char * expand_homedir_path_home(const char *inpath, const char *homedir) {
  698|      2|	if (strncmp(inpath, "~/", 2) == 0 && homedir) {
  ------------------
  |  Branch (698:6): [True: 2, False: 0]
  |  Branch (698:39): [True: 2, False: 0]
  ------------------
  699|      2|		size_t len = strlen(inpath)-2 + strlen(homedir) + 2;
  700|      2|		char *buf = m_malloc(len);
  701|      2|		snprintf(buf, len, "%s/%s", homedir, inpath+2);
  702|      2|		return buf;
  703|      2|	}
  704|       |	/* Fallback */
  705|      0|	return m_strdup(inpath);
  706|      2|}
expand_homedir_path:
  710|      2|char * expand_homedir_path(const char *inpath) {
  711|      2|	struct passwd *pw = NULL;
  712|      2|	char *homedir = getenv("HOME");
  713|       |
  714|      2|	if (!homedir) {
  ------------------
  |  Branch (714:6): [True: 0, False: 2]
  ------------------
  715|      0|		pw = getpwuid(getuid());
  ------------------
  |  |  109|      0|#define getpwuid(x) fuzz_getpwuid(x)
  ------------------
  716|      0|		if (pw) {
  ------------------
  |  Branch (716:7): [True: 0, False: 0]
  ------------------
  717|      0|			homedir = pw->pw_dir;
  718|      0|		}
  719|      0|	}
  720|      2|	return expand_homedir_path_home(inpath, homedir);
  721|      2|}
constant_time_memcmp:
  724|    295|{
  725|    295|	const char *xa = a, *xb = b;
  726|    295|	uint8_t c = 0;
  727|    295|	size_t i;
  728|  9.73k|	for (i = 0; i < n; i++)
  ------------------
  |  Branch (728:14): [True: 9.44k, False: 295]
  ------------------
  729|  9.44k|	{
  730|  9.44k|		c |= (xa[i] ^ xb[i]);
  731|  9.44k|	}
  732|    295|	return c;
  733|    295|}
gettime_wrapper:
  736|   337k|void gettime_wrapper(struct timespec *now) {
  737|   337k|	struct timeval tv;
  738|   337k|#if DROPBEAR_FUZZ
  739|   337k|	if (fuzz.fuzzing) {
  ------------------
  |  Branch (739:6): [True: 337k, False: 0]
  ------------------
  740|       |		/* time stands still when fuzzing */
  741|   337k|		now->tv_sec = 5;
  742|   337k|		now->tv_nsec = 0;
  743|   337k|	}
  744|   337k|#endif
  745|       |
  746|   337k|#if defined(HAVE_CLOCK_GETTIME) && defined(CLOCK_MONOTONIC)
  747|       |	/* POSIX monotonic clock. Newer Linux, BSD, MacOSX >10.12 */
  748|   337k|	if (clock_gettime(CLOCK_MONOTONIC, now) == 0) {
  ------------------
  |  Branch (748:6): [True: 337k, False: 0]
  ------------------
  749|   337k|		return;
  750|   337k|	}
  751|      0|#endif
  752|       |
  753|      0|#if defined(__linux__) && defined(SYS_clock_gettime)
  754|      0|	{
  755|       |	/* Old linux toolchain - kernel might support it but not the build headers */
  756|       |	/* Also glibc <2.17 requires -lrt which we neglect to add */
  757|      0|	static int linux_monotonic_failed = 0;
  758|      0|	if (!linux_monotonic_failed) {
  ------------------
  |  Branch (758:6): [True: 0, False: 0]
  ------------------
  759|       |		/* CLOCK_MONOTONIC isn't in some headers */
  760|      0|		int clock_source_monotonic = 1; 
  761|      0|		if (syscall(SYS_clock_gettime, clock_source_monotonic, now) == 0) {
  ------------------
  |  Branch (761:7): [True: 0, False: 0]
  ------------------
  762|      0|			return;
  763|      0|		} else {
  764|       |			/* Don't try again */
  765|      0|			linux_monotonic_failed = 1;
  766|      0|		}
  767|      0|	}
  768|      0|	}
  769|      0|#endif /* linux fallback clock_gettime */
  770|       |
  771|       |#if defined(HAVE_MACH_ABSOLUTE_TIME)
  772|       |	{
  773|       |	/* OS X pre 10.12, see https://developer.apple.com/library/mac/qa/qa1398/_index.html */
  774|       |	static mach_timebase_info_data_t timebase_info;
  775|       |	uint64_t scaled_time;
  776|       |	if (timebase_info.denom == 0) {
  777|       |		mach_timebase_info(&timebase_info);
  778|       |	}
  779|       |	scaled_time = mach_absolute_time() * timebase_info.numer / timebase_info.denom;
  780|       |	now->tv_sec = scaled_time / 1000000000;
  781|       |	now->tv_nsec = scaled_time % 1000000000;
  782|       |	}
  783|       |#endif /* osx mach_absolute_time */
  784|       |
  785|       |	/* Fallback for everything else - this will sometimes go backwards */
  786|      0|	gettimeofday(&tv, NULL);
  787|      0|	now->tv_sec = tv.tv_sec;
  788|      0|	now->tv_nsec = 1000*(long)tv.tv_usec;
  789|      0|}
monotonic_now:
  792|   337k|time_t monotonic_now() {
  793|   337k|	struct timespec ts;
  794|   337k|	gettime_wrapper(&ts);
  795|   337k|	return ts.tv_sec;
  796|   337k|}
dropbear_fd_set:
  837|   190k|void dropbear_fd_set(int fd, fd_set *set) {
  838|   190k|	if (fd < 0) {
  ------------------
  |  Branch (838:6): [True: 0, False: 190k]
  ------------------
  839|      0|		return;
  840|      0|	}
  841|   190k|	if (fd >= FD_SETSIZE) {
  ------------------
  |  Branch (841:6): [True: 0, False: 190k]
  ------------------
  842|      0|		dropbear_exit("fd limit %d", fd);
  843|      0|	}
  844|   190k|	FD_SET(fd, set);
  845|   190k|}

buf_get_dss_pub_key:
   46|    260|int buf_get_dss_pub_key(buffer* buf, dropbear_dss_key *key) {
   47|    260|	int ret = DROPBEAR_FAILURE;
  ------------------
  |  |  112|    260|#define DROPBEAR_FAILURE -1
  ------------------
   48|       |
   49|    260|	TRACE(("enter buf_get_dss_pub_key"))
   50|    260|	dropbear_assert(key != NULL);
  ------------------
  |  |   86|    260|#define dropbear_assert(X) do { if (!(X)) { fail_assert(#X, __FILE__, __LINE__); } } while (0)
  |  |  ------------------
  |  |  |  Branch (86:37): [True: 0, False: 260]
  |  |  |  Branch (86:93): [Folded, False: 260]
  |  |  ------------------
  ------------------
   51|    260|	m_mp_alloc_init_multi(&key->p, &key->q, &key->g, &key->y, NULL);
   52|    260|	key->x = NULL;
   53|       |
   54|    260|	buf_incrpos(buf, 4+SSH_SIGNKEY_DSS_LEN); /* int + "ssh-dss" */
  ------------------
  |  |  115|    260|#define SSH_SIGNKEY_DSS_LEN 7
  ------------------
   55|    260|	if (buf_getmpint(buf, key->p) == DROPBEAR_FAILURE
  ------------------
  |  |  112|    520|#define DROPBEAR_FAILURE -1
  ------------------
  |  Branch (55:6): [True: 52, False: 208]
  ------------------
   56|    208|	 || buf_getmpint(buf, key->q) == DROPBEAR_FAILURE
  ------------------
  |  |  112|    468|#define DROPBEAR_FAILURE -1
  ------------------
  |  Branch (56:6): [True: 29, False: 179]
  ------------------
   57|    179|	 || buf_getmpint(buf, key->g) == DROPBEAR_FAILURE
  ------------------
  |  |  112|    439|#define DROPBEAR_FAILURE -1
  ------------------
  |  Branch (57:6): [True: 9, False: 170]
  ------------------
   58|    170|	 || buf_getmpint(buf, key->y) == DROPBEAR_FAILURE) {
  ------------------
  |  |  112|    170|#define DROPBEAR_FAILURE -1
  ------------------
  |  Branch (58:6): [True: 7, False: 163]
  ------------------
   59|     64|		TRACE(("leave buf_get_dss_pub_key: failed reading mpints"))
   60|     64|		ret = DROPBEAR_FAILURE;
  ------------------
  |  |  112|     64|#define DROPBEAR_FAILURE -1
  ------------------
   61|     64|		goto out;
   62|     64|	}
   63|       |
   64|    196|	if (mp_count_bits(key->p) != DSS_P_BITS) {
  ------------------
  |  |   44|    196|#define DSS_P_BITS 1024
  ------------------
  |  Branch (64:6): [True: 15, False: 181]
  ------------------
   65|     15|		dropbear_log(LOG_WARNING, "Bad DSS p");
   66|     15|		ret = DROPBEAR_FAILURE;
  ------------------
  |  |  112|     15|#define DROPBEAR_FAILURE -1
  ------------------
   67|     15|		goto out;
   68|     15|	}
   69|       |
   70|    181|	if (mp_count_bits(key->q) != DSS_Q_BITS) {
  ------------------
  |  |   45|    181|#define DSS_Q_BITS 160
  ------------------
  |  Branch (70:6): [True: 8, False: 173]
  ------------------
   71|      8|		dropbear_log(LOG_WARNING, "Bad DSS q");
   72|      8|		ret = DROPBEAR_FAILURE;
  ------------------
  |  |  112|      8|#define DROPBEAR_FAILURE -1
  ------------------
   73|      8|		goto out;
   74|      8|	}
   75|       |
   76|       |	/* test 1 < g < p */
   77|    173|	if (mp_cmp_d(key->g, 1) != MP_GT) {
  ------------------
  |  |  156|    173|#define MP_GT         1   /* greater than */
  ------------------
  |  Branch (77:6): [True: 1, False: 172]
  ------------------
   78|      1|		dropbear_log(LOG_WARNING, "Bad DSS g");
   79|      1|		ret = DROPBEAR_FAILURE;
  ------------------
  |  |  112|      1|#define DROPBEAR_FAILURE -1
  ------------------
   80|      1|		goto out;
   81|      1|	}
   82|    172|	if (mp_cmp(key->g, key->p) != MP_LT) {
  ------------------
  |  |  154|    172|#define MP_LT        -1   /* less than */
  ------------------
  |  Branch (82:6): [True: 1, False: 171]
  ------------------
   83|      1|		dropbear_log(LOG_WARNING, "Bad DSS g");
   84|      1|		ret = DROPBEAR_FAILURE;
  ------------------
  |  |  112|      1|#define DROPBEAR_FAILURE -1
  ------------------
   85|      1|		goto out;
   86|      1|	}
   87|       |
   88|    171|	ret = DROPBEAR_SUCCESS;
  ------------------
  |  |  111|    171|#define DROPBEAR_SUCCESS 0
  ------------------
   89|    171|	TRACE(("leave buf_get_dss_pub_key: success"))
   90|    227|out:
   91|    227|	if (ret == DROPBEAR_FAILURE) {
  ------------------
  |  |  112|    227|#define DROPBEAR_FAILURE -1
  ------------------
  |  Branch (91:6): [True: 89, False: 138]
  ------------------
   92|       |		m_mp_free_multi(&key->p, &key->q, &key->g, &key->y, NULL);
   93|     89|	}
   94|    227|	return ret;
   95|    171|}
dss_key_free:
  122|    350|void dss_key_free(dropbear_dss_key *key) {
  123|       |
  124|    350|	TRACE2(("enter dsa_key_free"))
  125|    350|	if (key == NULL) {
  ------------------
  |  Branch (125:6): [True: 261, False: 89]
  ------------------
  126|    261|		TRACE2(("enter dsa_key_free: key == NULL"))
  127|    261|		return;
  128|    261|	}
  129|     89|	m_mp_free_multi(&key->p, &key->q, &key->g, &key->y, &key->x, NULL);
  130|       |	m_free(key);
  ------------------
  |  |   24|     89|#define m_free(X) do {m_free_direct(X); (X) = NULL;} while (0)
  |  |  ------------------
  |  |  |  Branch (24:61): [Folded, False: 89]
  |  |  ------------------
  ------------------
  131|     89|	TRACE2(("leave dsa_key_free"))
  132|     89|}
buf_put_dss_pub_key:
  142|    132|void buf_put_dss_pub_key(buffer* buf, const dropbear_dss_key *key) {
  143|       |
  144|    132|	dropbear_assert(key != NULL);
  ------------------
  |  |   86|    132|#define dropbear_assert(X) do { if (!(X)) { fail_assert(#X, __FILE__, __LINE__); } } while (0)
  |  |  ------------------
  |  |  |  Branch (86:37): [True: 0, False: 132]
  |  |  |  Branch (86:93): [Folded, False: 132]
  |  |  ------------------
  ------------------
  145|    132|	buf_putstring(buf, SSH_SIGNKEY_DSS, SSH_SIGNKEY_DSS_LEN);
  ------------------
  |  |  114|    132|#define SSH_SIGNKEY_DSS "ssh-dss"
  ------------------
              	buf_putstring(buf, SSH_SIGNKEY_DSS, SSH_SIGNKEY_DSS_LEN);
  ------------------
  |  |  115|    132|#define SSH_SIGNKEY_DSS_LEN 7
  ------------------
  146|    132|	buf_putmpint(buf, key->p);
  147|    132|	buf_putmpint(buf, key->q);
  148|    132|	buf_putmpint(buf, key->g);
  149|    132|	buf_putmpint(buf, key->y);
  150|       |
  151|    132|}
buf_dss_verify:
  165|    128|int buf_dss_verify(buffer* buf, const dropbear_dss_key *key, const buffer *data_buf) {
  166|    128|	unsigned char msghash[SHA1_HASH_SIZE];
  167|    128|	hash_state hs;
  168|    128|	int ret = DROPBEAR_FAILURE;
  ------------------
  |  |  112|    128|#define DROPBEAR_FAILURE -1
  ------------------
  169|    128|	DEF_MP_INT(val1);
  ------------------
  |  |   83|    128|#define DEF_MP_INT(X) mp_int X = {0, 0, 0, NULL}
  ------------------
  170|    128|	DEF_MP_INT(val2);
  ------------------
  |  |   83|    128|#define DEF_MP_INT(X) mp_int X = {0, 0, 0, NULL}
  ------------------
  171|    128|	DEF_MP_INT(val3);
  ------------------
  |  |   83|    128|#define DEF_MP_INT(X) mp_int X = {0, 0, 0, NULL}
  ------------------
  172|    128|	DEF_MP_INT(val4);
  ------------------
  |  |   83|    128|#define DEF_MP_INT(X) mp_int X = {0, 0, 0, NULL}
  ------------------
  173|    128|	char * string = NULL;
  174|    128|	unsigned int stringlen;
  175|       |
  176|    128|	TRACE(("enter buf_dss_verify"))
  177|    128|	dropbear_assert(key != NULL);
  ------------------
  |  |   86|    128|#define dropbear_assert(X) do { if (!(X)) { fail_assert(#X, __FILE__, __LINE__); } } while (0)
  |  |  ------------------
  |  |  |  Branch (86:37): [True: 0, False: 128]
  |  |  |  Branch (86:93): [Folded, False: 128]
  |  |  ------------------
  ------------------
  178|       |
  179|    128|	m_mp_init_multi(&val1, &val2, &val3, &val4, NULL);
  180|       |
  181|       |	/* get blob, check length */
  182|    128|	string = buf_getstring(buf, &stringlen);
  183|    128|	if (stringlen != 2*SHA1_HASH_SIZE) {
  ------------------
  |  |  133|    128|#define SHA1_HASH_SIZE 20
  ------------------
  |  Branch (183:6): [True: 10, False: 118]
  ------------------
  184|     10|		goto out;
  185|     10|	}
  186|       |
  187|       |#if DEBUG_DSS_VERIFY
  188|       |	printmpint("dss verify p", key->p);
  189|       |	printmpint("dss verify q", key->q);
  190|       |	printmpint("dss verify g", key->g);
  191|       |	printmpint("dss verify y", key->y);
  192|       |#endif
  193|       |
  194|       |	/* hash the data */
  195|    118|	sha1_init(&hs);
  196|    118|	sha1_process(&hs, data_buf->data, data_buf->len);
  197|    118|	sha1_done(&hs, msghash);
  198|       |
  199|       |	/* create the signature - s' and r' are the received signatures in buf */
  200|       |	/* w = (s')-1 mod q */
  201|       |	/* let val1 = s' */
  202|    118|	bytes_to_mp(&val1, (const unsigned char*) &string[SHA1_HASH_SIZE], SHA1_HASH_SIZE);
  ------------------
  |  |  133|    118|#define SHA1_HASH_SIZE 20
  ------------------
              	bytes_to_mp(&val1, (const unsigned char*) &string[SHA1_HASH_SIZE], SHA1_HASH_SIZE);
  ------------------
  |  |  133|    118|#define SHA1_HASH_SIZE 20
  ------------------
  203|       |#if DEBUG_DSS_VERIFY
  204|       |	printmpint("dss verify s'", &val1);
  205|       |#endif
  206|       |
  207|    118|	if (mp_cmp(&val1, key->q) != MP_LT) {
  ------------------
  |  |  154|    118|#define MP_LT        -1   /* less than */
  ------------------
  |  Branch (207:6): [True: 2, False: 116]
  ------------------
  208|      2|		TRACE(("verify failed, s' >= q"))
  209|      2|		goto out;
  210|      2|	}
  211|    116|	if (mp_cmp_d(&val1, 0) != MP_GT) {
  ------------------
  |  |  156|    116|#define MP_GT         1   /* greater than */
  ------------------
  |  Branch (211:6): [True: 1, False: 115]
  ------------------
  212|      1|		TRACE(("verify failed, s' <= 0"))
  213|      1|		goto out;
  214|      1|	}
  215|       |	/* let val2 = w = (s')^-1 mod q*/
  216|    115|	if (mp_invmod(&val1, key->q, &val2) != MP_OKAY) {
  ------------------
  |  |  161|    115|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (216:6): [True: 15, False: 100]
  ------------------
  217|     15|		goto out;
  218|     15|	}
  219|       |
  220|       |	/* u1 = ((SHA(M')w) mod q */
  221|       |	/* let val1 = SHA(M') = msghash */
  222|    100|	bytes_to_mp(&val1, msghash, SHA1_HASH_SIZE);
  ------------------
  |  |  133|    100|#define SHA1_HASH_SIZE 20
  ------------------
  223|       |#if DEBUG_DSS_VERIFY
  224|       |	printmpint("dss verify r'", &val1);
  225|       |#endif
  226|       |
  227|       |	/* let val3 = u1 = ((SHA(M')w) mod q */
  228|    100|	if (mp_mulmod(&val1, &val2, key->q, &val3) != MP_OKAY) {
  ------------------
  |  |  161|    100|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (228:6): [True: 0, False: 100]
  ------------------
  229|      0|		goto out;
  230|      0|	}
  231|       |
  232|       |	/* u2 = ((r')w) mod q */
  233|       |	/* let val1 = r' */
  234|    100|	bytes_to_mp(&val1, (const unsigned char*) &string[0], SHA1_HASH_SIZE);
  ------------------
  |  |  133|    100|#define SHA1_HASH_SIZE 20
  ------------------
  235|    100|	if (mp_cmp(&val1, key->q) != MP_LT) {
  ------------------
  |  |  154|    100|#define MP_LT        -1   /* less than */
  ------------------
  |  Branch (235:6): [True: 3, False: 97]
  ------------------
  236|      3|		TRACE(("verify failed, r' >= q"))
  237|      3|		goto out;
  238|      3|	}
  239|     97|	if (mp_cmp_d(&val1, 0) != MP_GT) {
  ------------------
  |  |  156|     97|#define MP_GT         1   /* greater than */
  ------------------
  |  Branch (239:6): [True: 1, False: 96]
  ------------------
  240|      1|		TRACE(("verify failed, r' <= 0"))
  241|      1|		goto out;
  242|      1|	}
  243|       |	/* let val4 = u2 = ((r')w) mod q */
  244|     96|	if (mp_mulmod(&val1, &val2, key->q, &val4) != MP_OKAY) {
  ------------------
  |  |  161|     96|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (244:6): [True: 0, False: 96]
  ------------------
  245|      0|		goto out;
  246|      0|	}
  247|       |
  248|       |	/* v = (((g)^u1 (y)^u2) mod p) mod q */
  249|       |	/* val2 = g^u1 mod p */
  250|     96|	if (mp_exptmod(key->g, &val3, key->p, &val2) != MP_OKAY) {
  ------------------
  |  |  161|     96|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (250:6): [True: 0, False: 96]
  ------------------
  251|      0|		goto out;
  252|      0|	}
  253|       |	/* val3 = y^u2 mod p */
  254|     96|	if (mp_exptmod(key->y, &val4, key->p, &val3) != MP_OKAY) {
  ------------------
  |  |  161|     96|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (254:6): [True: 0, False: 96]
  ------------------
  255|      0|		goto out;
  256|      0|	}
  257|       |	/* val4 = ((g)^u1 (y)^u2) mod p */
  258|     96|	if (mp_mulmod(&val2, &val3, key->p, &val4) != MP_OKAY) {
  ------------------
  |  |  161|     96|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (258:6): [True: 0, False: 96]
  ------------------
  259|      0|		goto out;
  260|      0|	}
  261|       |	/* val2 = v = (((g)^u1 (y)^u2) mod p) mod q */
  262|     96|	if (mp_mod(&val4, key->q, &val2) != MP_OKAY) {
  ------------------
  |  |  161|     96|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (262:6): [True: 0, False: 96]
  ------------------
  263|      0|		goto out;
  264|      0|	}
  265|       |	
  266|       |	/* check whether signatures verify */
  267|     96|	if (mp_cmp(&val2, &val1) == MP_EQ) {
  ------------------
  |  |  155|     96|#define MP_EQ         0   /* equal to */
  ------------------
  |  Branch (267:6): [True: 0, False: 96]
  ------------------
  268|       |		/* good sig */
  269|      0|		ret = DROPBEAR_SUCCESS;
  ------------------
  |  |  111|      0|#define DROPBEAR_SUCCESS 0
  ------------------
  270|      0|	}
  271|       |
  272|    126|out:
  273|    126|	mp_clear_multi(&val1, &val2, &val3, &val4, NULL);
  274|    126|	m_free(string);
  ------------------
  |  |   24|    126|#define m_free(X) do {m_free_direct(X); (X) = NULL;} while (0)
  |  |  ------------------
  |  |  |  Branch (24:61): [Folded, False: 126]
  |  |  ------------------
  ------------------
  275|       |
  276|    126|	return ret;
  277|       |
  278|     96|}

dropbear_ecc_fill_dp:
   47|      1|void dropbear_ecc_fill_dp() {
   48|      1|	struct dropbear_ecc_curve **curve;
   49|       |	/* libtomcrypt guarantees they're ordered by size */
   50|      1|	const ltc_ecc_set_type *dp = ltc_ecc_sets;
   51|      4|	for (curve = dropbear_ecc_curves; *curve; curve++) {
  ------------------
  |  Branch (51:36): [True: 3, False: 1]
  ------------------
   52|      5|		for (;dp->size > 0; dp++) {
  ------------------
  |  Branch (52:9): [True: 5, False: 0]
  ------------------
   53|      5|			if (dp->size == (*curve)->ltc_size) {
  ------------------
  |  Branch (53:8): [True: 3, False: 2]
  ------------------
   54|      3|				(*curve)->dp = dp;
   55|      3|				break;
   56|      3|			}
   57|      5|		}
   58|      3|		if (!(*curve)->dp) {
  ------------------
  |  Branch (58:7): [True: 0, False: 3]
  ------------------
   59|      0|			dropbear_exit("Missing ECC params %s", (*curve)->name);
   60|      0|		}
   61|      3|	}
   62|      1|}
curve_for_dp:
   64|    189|struct dropbear_ecc_curve* curve_for_dp(const ltc_ecc_set_type *dp) {
   65|    189|	struct dropbear_ecc_curve **curve = NULL;
   66|    567|	for (curve = dropbear_ecc_curves; *curve; curve++) {
  ------------------
  |  Branch (66:36): [True: 567, False: 0]
  ------------------
   67|    567|		if ((*curve)->dp == dp) {
  ------------------
  |  Branch (67:7): [True: 189, False: 378]
  ------------------
   68|    189|			break;
   69|    189|		}
   70|    567|	}
   71|    189|	assert(*curve);
  ------------------
  |  Branch (71:2): [True: 0, False: 189]
  |  Branch (71:2): [True: 189, False: 0]
  ------------------
   72|    189|	return *curve;
   73|    189|}
new_ecc_key:
   75|    186|ecc_key * new_ecc_key(void) {
   76|    186|	ecc_key *key = m_malloc(sizeof(*key));
   77|    186|	m_mp_alloc_init_multi((mp_int**)&key->pubkey.x, (mp_int**)&key->pubkey.y, 
   78|       |		(mp_int**)&key->pubkey.z, (mp_int**)&key->k, NULL);
   79|    186|	return key;
   80|    186|}
buf_put_ecc_raw_pubkey_string:
  135|  1.01k|void buf_put_ecc_raw_pubkey_string(buffer *buf, ecc_key *key) {
  136|  1.01k|	unsigned long len = key->dp->size*2 + 1;
  137|  1.01k|	int err;
  138|  1.01k|	buf_putint(buf, len);
  139|  1.01k|	err = ecc_ansi_x963_export(key, buf_getwriteptr(buf, len), &len);
  140|  1.01k|	if (err != CRYPT_OK) {
  ------------------
  |  Branch (140:6): [True: 0, False: 1.01k]
  ------------------
  141|      0|		dropbear_exit("ECC error");
  142|      0|	}
  143|  1.01k|	buf_incrwritepos(buf, len);
  144|  1.01k|}
buf_get_ecc_raw_pubkey:
  147|    227|ecc_key * buf_get_ecc_raw_pubkey(buffer *buf, const struct dropbear_ecc_curve *curve) {
  148|    227|	ecc_key *key = NULL;
  149|    227|	int ret = DROPBEAR_FAILURE;
  ------------------
  |  |  112|    227|#define DROPBEAR_FAILURE -1
  ------------------
  150|    227|	const unsigned int size = curve->dp->size;
  151|    227|	unsigned char first;
  152|       |
  153|    227|	TRACE(("enter buf_get_ecc_raw_pubkey"))
  154|       |
  155|    227|	buf_setpos(buf, 0);
  156|    227|	first = buf_getbyte(buf);
  157|    227|	if (first == 2 || first == 3) {
  ------------------
  |  Branch (157:6): [True: 5, False: 222]
  |  Branch (157:20): [True: 1, False: 221]
  ------------------
  158|      2|		dropbear_log(LOG_WARNING, "Dropbear doesn't support ECC point compression");
  159|      2|		return NULL;
  160|      2|	}
  161|    225|	if (first != 4 || buf->len != 1+2*size) {
  ------------------
  |  Branch (161:6): [True: 22, False: 203]
  |  Branch (161:20): [True: 17, False: 186]
  ------------------
  162|     35|		TRACE(("leave, wrong size"))
  163|     35|		return NULL;
  164|     35|	}
  165|       |
  166|    190|	key = new_ecc_key();
  167|    190|	key->dp = curve->dp;
  168|       |
  169|    190|	if (mp_from_ubin(key->pubkey.x, buf_getptr(buf, size), size) != MP_OKAY) {
  ------------------
  |  |  161|    190|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (169:6): [True: 0, False: 190]
  ------------------
  170|      0|		TRACE(("failed to read x"))
  171|      0|		goto out;
  172|      0|	}
  173|    190|	buf_incrpos(buf, size);
  174|       |
  175|    190|	if (mp_from_ubin(key->pubkey.y, buf_getptr(buf, size), size) != MP_OKAY) {
  ------------------
  |  |  161|    190|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (175:6): [True: 0, False: 190]
  ------------------
  176|      0|		TRACE(("failed to read y"))
  177|      0|		goto out;
  178|      0|	}
  179|    190|	buf_incrpos(buf, size);
  180|       |
  181|    190|	mp_set(key->pubkey.z, 1);
  182|       |
  183|    190|	if (ecc_is_point(key) != CRYPT_OK) {
  ------------------
  |  Branch (183:6): [True: 12, False: 178]
  ------------------
  184|     12|		TRACE(("failed, not a point"))
  185|     12|		goto out;
  186|     12|	}
  187|       |
  188|       |   /* SEC1 3.2.3.1 Check that Q != 0 */
  189|    178|	if (mp_cmp_d(key->pubkey.x, 0) == LTC_MP_EQ) {
  ------------------
  |  |   13|    178|#define LTC_MP_EQ    0
  ------------------
  |  Branch (189:6): [True: 0, False: 178]
  ------------------
  190|      0|		TRACE(("failed, x == 0"))
  191|      0|		goto out;
  192|      0|	}
  193|    178|	if (mp_cmp_d(key->pubkey.y, 0) == LTC_MP_EQ) {
  ------------------
  |  |   13|    178|#define LTC_MP_EQ    0
  ------------------
  |  Branch (193:6): [True: 0, False: 178]
  ------------------
  194|      0|		TRACE(("failed, y == 0"))
  195|      0|		goto out;
  196|      0|	}
  197|       |
  198|    178|	ret = DROPBEAR_SUCCESS;
  ------------------
  |  |  111|    178|#define DROPBEAR_SUCCESS 0
  ------------------
  199|       |
  200|    186|	out:
  201|    186|	if (ret == DROPBEAR_FAILURE) {
  ------------------
  |  |  112|    186|#define DROPBEAR_FAILURE -1
  ------------------
  |  Branch (201:6): [True: 12, False: 174]
  ------------------
  202|     12|		if (key) {
  ------------------
  |  Branch (202:7): [True: 12, False: 0]
  ------------------
  203|     12|			ecc_free(key);
  204|     12|			m_free(key);
  ------------------
  |  |   24|     12|#define m_free(X) do {m_free_direct(X); (X) = NULL;} while (0)
  |  |  ------------------
  |  |  |  Branch (24:61): [Folded, False: 12]
  |  |  ------------------
  ------------------
  205|     12|			key = NULL;
  206|     12|		}
  207|     12|	}
  208|       |
  209|    186|	return key;
  210|       |
  211|    178|}
dropbear_ecc_shared_secret:
  216|     78|{
  217|     78|	ecc_point *result = NULL;
  218|     78|	mp_int *prime = NULL, *shared_secret = NULL;
  219|     78|	int err = DROPBEAR_FAILURE;
  ------------------
  |  |  112|     78|#define DROPBEAR_FAILURE -1
  ------------------
  220|       |
  221|       |   /* type valid? */
  222|     78|	if (private_key->type != PK_PRIVATE) {
  ------------------
  |  Branch (222:6): [True: 0, False: 78]
  ------------------
  223|      0|		goto out;
  224|      0|	}
  225|       |
  226|     78|	if (private_key->dp != public_key->dp) {
  ------------------
  |  Branch (226:6): [True: 0, False: 78]
  ------------------
  227|      0|		goto out;
  228|      0|	}
  229|       |
  230|       |   /* make new point */
  231|     78|	result = ltc_ecc_new_point();
  232|     78|	if (result == NULL) {
  ------------------
  |  Branch (232:6): [True: 0, False: 78]
  ------------------
  233|      0|		goto out;
  234|      0|	}
  235|       |
  236|     78|	prime = m_malloc(sizeof(*prime));
  237|     78|	m_mp_init(prime);
  238|       |
  239|     78|	if (mp_read_radix(prime, (char *)private_key->dp->prime, 16) != CRYPT_OK) { 
  ------------------
  |  Branch (239:6): [True: 0, False: 78]
  ------------------
  240|      0|		goto out;
  241|      0|	}
  242|     78|	if (ltc_mp.ecc_ptmul(private_key->k, &public_key->pubkey, result, prime, 1) != CRYPT_OK) { 
  ------------------
  |  Branch (242:6): [True: 0, False: 78]
  ------------------
  243|      0|		goto out;
  244|      0|	}
  245|       |
  246|     78|	shared_secret = m_malloc(sizeof(*shared_secret));
  247|     78|	m_mp_init(shared_secret);
  248|     78|	if (mp_copy(result->x, shared_secret) != CRYPT_OK) {
  ------------------
  |  Branch (248:6): [True: 0, False: 78]
  ------------------
  249|      0|		goto out;
  250|      0|	}
  251|       |
  252|     78|	mp_clear(prime);
  253|     78|	m_free(prime);
  ------------------
  |  |   24|     78|#define m_free(X) do {m_free_direct(X); (X) = NULL;} while (0)
  |  |  ------------------
  |  |  |  Branch (24:61): [Folded, False: 78]
  |  |  ------------------
  ------------------
  254|     78|	ltc_ecc_del_point(result);
  255|       |
  256|     78|	err = DROPBEAR_SUCCESS;
  ------------------
  |  |  111|     78|#define DROPBEAR_SUCCESS 0
  ------------------
  257|     78|	out:
  258|     78|	if (err == DROPBEAR_FAILURE) {
  ------------------
  |  |  112|     78|#define DROPBEAR_FAILURE -1
  ------------------
  |  Branch (258:6): [True: 0, False: 78]
  ------------------
  259|      0|		dropbear_exit("ECC error");
  260|      0|	}
  261|     78|	return shared_secret;
  262|     78|}
ecc.c:ecc_is_point:
   85|    186|{
   86|    186|	mp_int *prime, *b, *t1, *t2;
   87|    186|	int err;
   88|       |	
   89|    186|	m_mp_alloc_init_multi(&prime, &b, &t1, &t2, NULL);
   90|       |	
   91|       |   /* load prime and b */
   92|    186|	if ((err = mp_read_radix(prime, key->dp->prime, 16)) != CRYPT_OK)                          { goto error; }
  ------------------
  |  Branch (92:6): [True: 0, False: 186]
  ------------------
   93|    186|	if ((err = mp_read_radix(b, key->dp->B, 16)) != CRYPT_OK)                                  { goto error; }
  ------------------
  |  Branch (93:6): [True: 0, False: 186]
  ------------------
   94|       |	
   95|       |   /* compute y^2 */
   96|    186|	if ((err = mp_sqr(key->pubkey.y, t1)) != CRYPT_OK)                                         { goto error; }
  ------------------
  |  Branch (96:6): [True: 0, False: 186]
  ------------------
   97|       |	
   98|       |   /* compute x^3 */
   99|    186|	if ((err = mp_sqr(key->pubkey.x, t2)) != CRYPT_OK)                                         { goto error; }
  ------------------
  |  Branch (99:6): [True: 0, False: 186]
  ------------------
  100|    186|	if ((err = mp_mod(t2, prime, t2)) != CRYPT_OK)                                             { goto error; }
  ------------------
  |  Branch (100:6): [True: 0, False: 186]
  ------------------
  101|    186|	if ((err = mp_mul(key->pubkey.x, t2, t2)) != CRYPT_OK)                                     { goto error; }
  ------------------
  |  Branch (101:6): [True: 0, False: 186]
  ------------------
  102|       |	
  103|       |   /* compute y^2 - x^3 */
  104|    186|	if ((err = mp_sub(t1, t2, t1)) != CRYPT_OK)                                                { goto error; }
  ------------------
  |  Branch (104:6): [True: 0, False: 186]
  ------------------
  105|       |	
  106|       |   /* compute y^2 - x^3 + 3x */
  107|    186|	if ((err = mp_add(t1, key->pubkey.x, t1)) != CRYPT_OK)                                     { goto error; }
  ------------------
  |  Branch (107:6): [True: 0, False: 186]
  ------------------
  108|    186|	if ((err = mp_add(t1, key->pubkey.x, t1)) != CRYPT_OK)                                     { goto error; }
  ------------------
  |  Branch (108:6): [True: 0, False: 186]
  ------------------
  109|    186|	if ((err = mp_add(t1, key->pubkey.x, t1)) != CRYPT_OK)                                     { goto error; }
  ------------------
  |  Branch (109:6): [True: 0, False: 186]
  ------------------
  110|    186|	if ((err = mp_mod(t1, prime, t1)) != CRYPT_OK)                                             { goto error; }
  ------------------
  |  Branch (110:6): [True: 0, False: 186]
  ------------------
  111|    186|	while (mp_cmp_d(t1, 0) == LTC_MP_LT) {
  ------------------
  |  |   12|    186|#define LTC_MP_LT   -1
  ------------------
  |  Branch (111:9): [True: 0, False: 186]
  ------------------
  112|      0|		if ((err = mp_add(t1, prime, t1)) != CRYPT_OK)                                          { goto error; }
  ------------------
  |  Branch (112:7): [True: 0, False: 0]
  ------------------
  113|      0|	}
  114|    186|	while (mp_cmp(t1, prime) != LTC_MP_LT) {
  ------------------
  |  |   12|    186|#define LTC_MP_LT   -1
  ------------------
  |  Branch (114:9): [True: 0, False: 186]
  ------------------
  115|      0|		if ((err = mp_sub(t1, prime, t1)) != CRYPT_OK)                                          { goto error; }
  ------------------
  |  Branch (115:7): [True: 0, False: 0]
  ------------------
  116|      0|	}
  117|       |	
  118|       |   /* compare to b */
  119|    186|	if (mp_cmp(t1, b) != LTC_MP_EQ) {
  ------------------
  |  |   13|    186|#define LTC_MP_EQ    0
  ------------------
  |  Branch (119:6): [True: 12, False: 174]
  ------------------
  120|     12|		err = CRYPT_INVALID_PACKET;
  121|    174|	} else {
  122|    174|		err = CRYPT_OK;
  123|    174|	}
  124|       |	
  125|    186|	error:
  126|    186|	mp_clear_multi(prime, b, t1, t2, NULL);
  127|    186|	m_free(prime);
  ------------------
  |  |   24|    186|#define m_free(X) do {m_free_direct(X); (X) = NULL;} while (0)
  |  |  ------------------
  |  |  |  Branch (24:61): [Folded, False: 186]
  |  |  ------------------
  ------------------
  128|    186|	m_free(b);
  ------------------
  |  |   24|    186|#define m_free(X) do {m_free_direct(X); (X) = NULL;} while (0)
  |  |  ------------------
  |  |  |  Branch (24:61): [Folded, False: 186]
  |  |  ------------------
  ------------------
  129|    186|	m_free(t1);
  ------------------
  |  |   24|    186|#define m_free(X) do {m_free_direct(X); (X) = NULL;} while (0)
  |  |  ------------------
  |  |  |  Branch (24:61): [Folded, False: 186]
  |  |  ------------------
  ------------------
  130|       |	m_free(t2);
  ------------------
  |  |   24|    186|#define m_free(X) do {m_free_direct(X); (X) = NULL;} while (0)
  |  |  ------------------
  |  |  |  Branch (24:61): [Folded, False: 186]
  |  |  ------------------
  ------------------
  131|    186|	return err;
  132|    186|}

signkey_is_ecdsa:
   11|  3.27k|{
   12|  3.27k|	return type == DROPBEAR_SIGNKEY_ECDSA_NISTP256
  ------------------
  |  Branch (12:9): [True: 0, False: 3.27k]
  ------------------
   13|  3.27k|		|| type == DROPBEAR_SIGNKEY_ECDSA_NISTP384
  ------------------
  |  Branch (13:6): [True: 0, False: 3.27k]
  ------------------
   14|  3.27k|		|| type == DROPBEAR_SIGNKEY_ECDSA_NISTP521;
  ------------------
  |  Branch (14:6): [True: 322, False: 2.94k]
  ------------------
   15|  3.27k|}
buf_get_ecdsa_pub_key:
   77|    133|ecc_key *buf_get_ecdsa_pub_key(buffer* buf) {
   78|    133|	unsigned char *key_ident = NULL, *identifier = NULL;
   79|    133|	unsigned int key_ident_len, identifier_len;
   80|    133|	buffer *q_buf = NULL;
   81|    133|	struct dropbear_ecc_curve **curve;
   82|    133|	ecc_key *new_key = NULL;
   83|       |
   84|       |	/* string   "ecdsa-sha2-[identifier]" or "sk-ecdsa-sha2-nistp256@openssh.com" */
   85|    133|	key_ident = (unsigned char*)buf_getstring(buf, &key_ident_len);
   86|       |	/* string   "[identifier]" */
   87|    133|	identifier = (unsigned char*)buf_getstring(buf, &identifier_len);
   88|       |
   89|    133|	if (strcmp (key_ident, "sk-ecdsa-sha2-nistp256@openssh.com") == 0) {
  ------------------
  |  Branch (89:6): [True: 0, False: 133]
  ------------------
   90|      0|		if (strcmp (identifier, "nistp256") != 0) {
  ------------------
  |  Branch (90:7): [True: 0, False: 0]
  ------------------
   91|      0|			TRACE(("mismatching identifiers"))
   92|      0|			goto out;
   93|      0|		}
   94|    133|	} else {
   95|    133|		if (key_ident_len != identifier_len + strlen ("ecdsa-sha2-")) {
  ------------------
  |  Branch (95:7): [True: 15, False: 118]
  ------------------
   96|     15|			TRACE(("Bad identifier lengths"))
   97|     15|			goto out;
   98|     15|		}
   99|    118|		if (memcmp(&key_ident[strlen ("ecdsa-sha2-")], identifier, identifier_len) != 0) {
  ------------------
  |  Branch (99:7): [True: 9, False: 109]
  ------------------
  100|      9|			TRACE(("mismatching identifiers"))
  101|      9|			goto out;
  102|      9|		}
  103|    118|	}
  104|       |
  105|    325|	for (curve = dropbear_ecc_curves; *curve; curve++) {
  ------------------
  |  Branch (105:36): [True: 324, False: 1]
  ------------------
  106|    324|		if (strcmp((char*)identifier, (*curve)->name) == 0) {
  ------------------
  |  Branch (106:7): [True: 108, False: 216]
  ------------------
  107|    108|			break;
  108|    108|		}
  109|    324|	}
  110|    109|	if (!*curve) {
  ------------------
  |  Branch (110:6): [True: 0, False: 109]
  ------------------
  111|      0|		TRACE(("couldn't match ecc curve"))
  112|      0|		goto out;
  113|      0|	}
  114|       |
  115|       |	/* string Q */
  116|    109|	q_buf = buf_getstringbuf(buf);
  117|    109|	new_key = buf_get_ecc_raw_pubkey(q_buf, *curve);
  118|       |
  119|    132|out:
  120|    132|	m_free(key_ident);
  ------------------
  |  |   24|    132|#define m_free(X) do {m_free_direct(X); (X) = NULL;} while (0)
  |  |  ------------------
  |  |  |  Branch (24:61): [Folded, False: 132]
  |  |  ------------------
  ------------------
  121|    132|	m_free(identifier);
  ------------------
  |  |   24|    132|#define m_free(X) do {m_free_direct(X); (X) = NULL;} while (0)
  |  |  ------------------
  |  |  |  Branch (24:61): [Folded, False: 132]
  |  |  ------------------
  ------------------
  122|    132|	if (q_buf) {
  ------------------
  |  Branch (122:6): [True: 108, False: 24]
  ------------------
  123|    108|		buf_free(q_buf);
  124|       |		q_buf = NULL;
  125|    108|	}
  126|    132|	TRACE(("leave buf_get_ecdsa_pub_key"))	
  127|    132|	return new_key;
  128|    109|}
buf_put_ecdsa_pub_key:
  147|     95|void buf_put_ecdsa_pub_key(buffer *buf, ecc_key *key) {
  148|     95|	struct dropbear_ecc_curve *curve = NULL;
  149|     95|	char key_ident[30];
  150|       |
  151|     95|	curve = curve_for_dp(key->dp);
  152|     95|	snprintf(key_ident, sizeof(key_ident), "ecdsa-sha2-%s", curve->name);
  153|     95|	buf_putstring(buf, key_ident, strlen(key_ident));
  154|     95|	buf_putstring(buf, curve->name, strlen(curve->name));
  155|     95|	buf_put_ecc_raw_pubkey_string(buf, key);
  156|     95|}
buf_ecdsa_verify:
  281|     94|int buf_ecdsa_verify(buffer *buf, const ecc_key *key, const buffer *data_buf) {
  282|       |	/* Based on libtomcrypt's ecc_verify_hash but without the asn1 */
  283|     94|	int ret = DROPBEAR_FAILURE;
  ------------------
  |  |  112|     94|#define DROPBEAR_FAILURE -1
  ------------------
  284|     94|	hash_state hs;
  285|     94|	struct dropbear_ecc_curve *curve = NULL;
  286|     94|	unsigned char hash[64];
  287|     94|	ecc_point *mG = NULL, *mQ = NULL;
  288|     94|	void *r = NULL, *s = NULL, *v = NULL, *w = NULL, *u1 = NULL, *u2 = NULL, 
  289|     94|		*e = NULL, *p = NULL, *m = NULL;
  290|     94|	void *mp = NULL;
  291|       |
  292|       |	/* verify 
  293|       |	 *
  294|       |	 * w  = s^-1 mod n
  295|       |	 * u1 = xw 
  296|       |	 * u2 = rw
  297|       |	 * X = u1*G + u2*Q
  298|       |	 * v = X_x1 mod n
  299|       |	 * accept if v == r
  300|       |	 */
  301|       |
  302|     94|	TRACE(("buf_ecdsa_verify"))
  303|     94|	curve = curve_for_dp(key->dp);
  304|       |
  305|     94|	mG = ltc_ecc_new_point();
  306|     94|	mQ = ltc_ecc_new_point();
  307|     94|	if (ltc_init_multi(&r, &s, &v, &w, &u1, &u2, &p, &e, &m, NULL) != CRYPT_OK
  ------------------
  |  Branch (307:6): [True: 0, False: 94]
  ------------------
  308|     94|		|| !mG
  ------------------
  |  Branch (308:6): [True: 0, False: 94]
  ------------------
  309|     94|		|| !mQ) {
  ------------------
  |  Branch (309:6): [True: 0, False: 94]
  ------------------
  310|      0|		dropbear_exit("ECC error");
  311|      0|	}
  312|       |
  313|     94|	if (buf_get_ecdsa_verify_params(buf, r, s) != DROPBEAR_SUCCESS) {
  ------------------
  |  |  111|     94|#define DROPBEAR_SUCCESS 0
  ------------------
  |  Branch (313:6): [True: 38, False: 56]
  ------------------
  314|     38|		goto out;
  315|     38|	}
  316|       |
  317|     56|	curve->hash_desc->init(&hs);
  318|     56|	curve->hash_desc->process(&hs, data_buf->data, data_buf->len);
  319|     56|	curve->hash_desc->done(&hs, hash);
  320|       |
  321|     56|	if (ltc_mp.unsigned_read(e, hash, curve->hash_desc->hashsize) != CRYPT_OK) {
  ------------------
  |  Branch (321:6): [True: 0, False: 56]
  ------------------
  322|      0|		goto out;
  323|      0|	}
  324|       |
  325|       |   /* get the order */
  326|     56|	if (ltc_mp.read_radix(p, (char *)key->dp->order, 16) != CRYPT_OK) { 
  ------------------
  |  Branch (326:6): [True: 0, False: 56]
  ------------------
  327|      0|		goto out; 
  328|      0|	}
  329|       |
  330|       |   /* get the modulus */
  331|     56|	if (ltc_mp.read_radix(m, (char *)key->dp->prime, 16) != CRYPT_OK) { 
  ------------------
  |  Branch (331:6): [True: 0, False: 56]
  ------------------
  332|      0|		goto out; 
  333|      0|	}
  334|       |
  335|       |   /* check for zero */
  336|     56|	if (ltc_mp.compare_d(r, 0) == LTC_MP_EQ 
  ------------------
  |  |   13|    112|#define LTC_MP_EQ    0
  ------------------
  |  Branch (336:6): [True: 3, False: 53]
  ------------------
  337|     53|		|| ltc_mp.compare_d(s, 0) == LTC_MP_EQ 
  ------------------
  |  |   13|    109|#define LTC_MP_EQ    0
  ------------------
  |  Branch (337:6): [True: 1, False: 52]
  ------------------
  338|     52|		|| ltc_mp.compare(r, p) != LTC_MP_LT 
  ------------------
  |  |   12|    108|#define LTC_MP_LT   -1
  ------------------
  |  Branch (338:6): [True: 1, False: 51]
  ------------------
  339|     51|		|| ltc_mp.compare(s, p) != LTC_MP_LT) {
  ------------------
  |  |   12|     51|#define LTC_MP_LT   -1
  ------------------
  |  Branch (339:6): [True: 1, False: 50]
  ------------------
  340|      5|		goto out;
  341|      5|	}
  342|       |
  343|       |   /*  w  = s^-1 mod n */
  344|     51|	if (ltc_mp.invmod(s, p, w) != CRYPT_OK) { 
  ------------------
  |  Branch (344:6): [True: 0, False: 51]
  ------------------
  345|      0|		goto out; 
  346|      0|	}
  347|       |
  348|       |   /* u1 = ew */
  349|     51|	if (ltc_mp.mulmod(e, w, p, u1) != CRYPT_OK) { 
  ------------------
  |  Branch (349:6): [True: 0, False: 51]
  ------------------
  350|      0|		goto out; 
  351|      0|	}
  352|       |
  353|       |   /* u2 = rw */
  354|     51|	if (ltc_mp.mulmod(r, w, p, u2) != CRYPT_OK) { 
  ------------------
  |  Branch (354:6): [True: 0, False: 51]
  ------------------
  355|      0|		goto out; 
  356|      0|	}
  357|       |
  358|       |   /* find mG and mQ */
  359|     51|	if (ltc_mp.read_radix(mG->x, (char *)key->dp->Gx, 16) != CRYPT_OK) { 
  ------------------
  |  Branch (359:6): [True: 0, False: 51]
  ------------------
  360|      0|		goto out; 
  361|      0|	}
  362|     51|	if (ltc_mp.read_radix(mG->y, (char *)key->dp->Gy, 16) != CRYPT_OK) { 
  ------------------
  |  Branch (362:6): [True: 0, False: 51]
  ------------------
  363|      0|		goto out; 
  364|      0|	}
  365|     51|	if (ltc_mp.set_int(mG->z, 1) != CRYPT_OK) { 
  ------------------
  |  Branch (365:6): [True: 0, False: 51]
  ------------------
  366|      0|		goto out; 
  367|      0|	}
  368|       |
  369|     51|	if (ltc_mp.copy(key->pubkey.x, mQ->x) != CRYPT_OK
  ------------------
  |  Branch (369:6): [True: 1, False: 50]
  ------------------
  370|     50|		|| ltc_mp.copy(key->pubkey.y, mQ->y) != CRYPT_OK
  ------------------
  |  Branch (370:6): [True: 0, False: 50]
  ------------------
  371|     50|		|| ltc_mp.copy(key->pubkey.z, mQ->z) != CRYPT_OK) { 
  ------------------
  |  Branch (371:6): [True: 0, False: 50]
  ------------------
  372|      0|		goto out; 
  373|      0|	}
  374|       |
  375|       |   /* compute u1*mG + u2*mQ = mG */
  376|     51|	if (ltc_mp.ecc_mul2add == NULL) {
  ------------------
  |  Branch (376:6): [True: 0, False: 51]
  ------------------
  377|      0|		if (ltc_mp.ecc_ptmul(u1, mG, mG, m, 0) != CRYPT_OK) { 
  ------------------
  |  Branch (377:7): [True: 0, False: 0]
  ------------------
  378|      0|			goto out; 
  379|      0|		}
  380|      0|		if (ltc_mp.ecc_ptmul(u2, mQ, mQ, m, 0) != CRYPT_OK) {
  ------------------
  |  Branch (380:7): [True: 0, False: 0]
  ------------------
  381|      0|			goto out; 
  382|      0|		}
  383|       |
  384|       |		/* find the montgomery mp */
  385|      0|		if (ltc_mp.montgomery_setup(m, &mp) != CRYPT_OK) { 
  ------------------
  |  Branch (385:7): [True: 0, False: 0]
  ------------------
  386|      0|			goto out; 
  387|      0|		}
  388|       |
  389|       |		/* add them */
  390|      0|		if (ltc_mp.ecc_ptadd(mQ, mG, mG, m, mp) != CRYPT_OK) { 
  ------------------
  |  Branch (390:7): [True: 0, False: 0]
  ------------------
  391|      0|			goto out; 
  392|      0|		}
  393|       |
  394|       |		/* reduce */
  395|      0|		if (ltc_mp.ecc_map(mG, m, mp) != CRYPT_OK) { 
  ------------------
  |  Branch (395:7): [True: 0, False: 0]
  ------------------
  396|      0|			goto out; 
  397|      0|		}
  398|     51|	} else {
  399|       |		/* use Shamir's trick to compute u1*mG + u2*mQ using half of the doubles */
  400|     51|		if (ltc_mp.ecc_mul2add(mG, u1, mQ, u2, mG, m) != CRYPT_OK) { 
  ------------------
  |  Branch (400:7): [True: 0, False: 51]
  ------------------
  401|      0|			goto out; 
  402|      0|		}
  403|     51|	}
  404|       |
  405|       |   /* v = X_x1 mod n */
  406|     51|	if (ltc_mp.mpdiv(mG->x, p, NULL, v) != CRYPT_OK) { 
  ------------------
  |  Branch (406:6): [True: 0, False: 51]
  ------------------
  407|      0|		goto out; 
  408|      0|	}
  409|       |
  410|       |   /* does v == r */
  411|     51|	if (ltc_mp.compare(v, r) == LTC_MP_EQ) {
  ------------------
  |  |   13|     51|#define LTC_MP_EQ    0
  ------------------
  |  Branch (411:6): [True: 0, False: 51]
  ------------------
  412|      0|		ret = DROPBEAR_SUCCESS;
  ------------------
  |  |  111|      0|#define DROPBEAR_SUCCESS 0
  ------------------
  413|      0|	}
  414|       |
  415|     93|out:
  416|     93|	ltc_ecc_del_point(mG);
  417|     93|	ltc_ecc_del_point(mQ);
  418|     93|	ltc_deinit_multi(r, s, v, w, u1, u2, p, e, m, NULL);
  419|     93|	if (mp != NULL) { 
  ------------------
  |  Branch (419:6): [True: 0, False: 93]
  ------------------
  420|      0|		ltc_mp.montgomery_deinit(mp);
  421|      0|	}
  422|     93|	return ret;
  423|     51|}
ecdsa.c:buf_get_ecdsa_verify_params:
  258|     94|			void *r, void* s) {
  259|     94|	int ret = DROPBEAR_FAILURE;
  ------------------
  |  |  112|     94|#define DROPBEAR_FAILURE -1
  ------------------
  260|     94|	unsigned int sig_len;
  261|     94|	unsigned int sig_pos;
  262|       |
  263|     94|	sig_len = buf_getint(buf);
  264|     94|	sig_pos = buf->pos;
  265|     94|	if (buf_getmpint(buf, r) != DROPBEAR_SUCCESS) {
  ------------------
  |  |  111|     94|#define DROPBEAR_SUCCESS 0
  ------------------
  |  Branch (265:6): [True: 1, False: 93]
  ------------------
  266|      1|		goto out;
  267|      1|	}
  268|     93|	if (buf_getmpint(buf, s) != DROPBEAR_SUCCESS) {
  ------------------
  |  |  111|     93|#define DROPBEAR_SUCCESS 0
  ------------------
  |  Branch (268:6): [True: 1, False: 92]
  ------------------
  269|      1|		goto out;
  270|      1|	}
  271|     92|	if (buf->pos - sig_pos != sig_len) {
  ------------------
  |  Branch (271:6): [True: 36, False: 56]
  ------------------
  272|     36|		goto out;
  273|     36|	}
  274|     56|	ret = DROPBEAR_SUCCESS;
  ------------------
  |  |  111|     56|#define DROPBEAR_SUCCESS 0
  ------------------
  275|       |
  276|     93|out:
  277|     93|	return ret;
  278|     56|}

buf_get_ed25519_pub_key:
   42|    421|	enum signkey_type expect_keytype) {
   43|       |
   44|       |
   45|    421|	unsigned int len, typelen;
   46|    421|	char *keytype = NULL;
   47|    421|	enum signkey_type buf_keytype;
   48|       |
   49|    421|	TRACE(("enter buf_get_ed25519_pub_key"))
   50|    421|	dropbear_assert(key != NULL);
  ------------------
  |  |   86|    421|#define dropbear_assert(X) do { if (!(X)) { fail_assert(#X, __FILE__, __LINE__); } } while (0)
  |  |  ------------------
  |  |  |  Branch (86:37): [True: 0, False: 421]
  |  |  |  Branch (86:93): [Folded, False: 421]
  |  |  ------------------
  ------------------
   51|       |
   52|       |	/* consume and check the key string */
   53|    421|	keytype = buf_getstring(buf, &typelen);
   54|    421|	buf_keytype = signkey_type_from_name(keytype, typelen);
   55|    421|	m_free(keytype);
  ------------------
  |  |   24|    421|#define m_free(X) do {m_free_direct(X); (X) = NULL;} while (0)
  |  |  ------------------
  |  |  |  Branch (24:61): [Folded, False: 421]
  |  |  ------------------
  ------------------
   56|    421|	if (buf_keytype != expect_keytype) {
  ------------------
  |  Branch (56:6): [True: 0, False: 421]
  ------------------
   57|      0|		TRACE(("leave buf_get_ed25519_pub_key: mismatch key type"))
   58|      0|		return DROPBEAR_FAILURE;
  ------------------
  |  |  112|      0|#define DROPBEAR_FAILURE -1
  ------------------
   59|      0|	}
   60|       |
   61|    421|	len = buf_getint(buf);
   62|    421|	if (len != CURVE25519_LEN || buf->len - buf->pos < len) {
  ------------------
  |  |   34|    842|#define CURVE25519_LEN 32
  ------------------
  |  Branch (62:6): [True: 39, False: 382]
  |  Branch (62:31): [True: 8, False: 374]
  ------------------
   63|     47|		TRACE(("leave buf_get_ed25519_pub_key: failure"))
   64|     47|		return DROPBEAR_FAILURE;
  ------------------
  |  |  112|     47|#define DROPBEAR_FAILURE -1
  ------------------
   65|     47|	}
   66|       |
   67|    374|	m_burn(key->priv, CURVE25519_LEN);
  ------------------
  |  |   34|    374|#define CURVE25519_LEN 32
  ------------------
   68|    374|	memcpy(key->pub, buf_getptr(buf, CURVE25519_LEN), CURVE25519_LEN);
  ------------------
  |  |   34|    374|#define CURVE25519_LEN 32
  ------------------
              	memcpy(key->pub, buf_getptr(buf, CURVE25519_LEN), CURVE25519_LEN);
  ------------------
  |  |   34|    374|#define CURVE25519_LEN 32
  ------------------
   69|    374|	buf_incrpos(buf, CURVE25519_LEN);
  ------------------
  |  |   34|    374|#define CURVE25519_LEN 32
  ------------------
   70|       |
   71|    374|	TRACE(("leave buf_get_ed25519_pub_key: success"))
   72|    374|	return DROPBEAR_SUCCESS;
  ------------------
  |  |  111|    374|#define DROPBEAR_SUCCESS 0
  ------------------
   73|    421|}
buf_get_ed25519_priv_key:
   78|      1|int buf_get_ed25519_priv_key(buffer *buf, dropbear_ed25519_key *key) {
   79|       |
   80|      1|	unsigned int len;
   81|       |
   82|      1|	TRACE(("enter buf_get_ed25519_priv_key"))
   83|      1|	dropbear_assert(key != NULL);
  ------------------
  |  |   86|      1|#define dropbear_assert(X) do { if (!(X)) { fail_assert(#X, __FILE__, __LINE__); } } while (0)
  |  |  ------------------
  |  |  |  Branch (86:37): [True: 0, False: 1]
  |  |  |  Branch (86:93): [Folded, False: 1]
  |  |  ------------------
  ------------------
   84|       |
   85|      1|	buf_incrpos(buf, 4+SSH_SIGNKEY_ED25519_LEN); /* int + "ssh-ed25519" */
  ------------------
  |  |  119|      1|#define SSH_SIGNKEY_ED25519_LEN 11
  ------------------
   86|       |
   87|      1|	len = buf_getint(buf);
   88|      1|	if (len != CURVE25519_LEN*2 || buf->len - buf->pos < len) {
  ------------------
  |  |   34|      1|#define CURVE25519_LEN 32
  ------------------
  |  Branch (88:6): [True: 0, False: 1]
  |  Branch (88:33): [True: 0, False: 1]
  ------------------
   89|      0|		TRACE(("leave buf_get_ed25519_priv_key: failure"))
   90|      0|		return DROPBEAR_FAILURE;
  ------------------
  |  |  112|      0|#define DROPBEAR_FAILURE -1
  ------------------
   91|      0|	}
   92|       |
   93|      1|	memcpy(key->priv, buf_getptr(buf, CURVE25519_LEN), CURVE25519_LEN);
  ------------------
  |  |   34|      1|#define CURVE25519_LEN 32
  ------------------
              	memcpy(key->priv, buf_getptr(buf, CURVE25519_LEN), CURVE25519_LEN);
  ------------------
  |  |   34|      1|#define CURVE25519_LEN 32
  ------------------
   94|      1|	buf_incrpos(buf, CURVE25519_LEN);
  ------------------
  |  |   34|      1|#define CURVE25519_LEN 32
  ------------------
   95|      1|	memcpy(key->pub, buf_getptr(buf, CURVE25519_LEN), CURVE25519_LEN);
  ------------------
  |  |   34|      1|#define CURVE25519_LEN 32
  ------------------
              	memcpy(key->pub, buf_getptr(buf, CURVE25519_LEN), CURVE25519_LEN);
  ------------------
  |  |   34|      1|#define CURVE25519_LEN 32
  ------------------
   96|      1|	buf_incrpos(buf, CURVE25519_LEN);
  ------------------
  |  |   34|      1|#define CURVE25519_LEN 32
  ------------------
   97|       |
   98|      1|	TRACE(("leave buf_get_ed25519_priv_key: success"))
   99|      1|	return DROPBEAR_SUCCESS;
  ------------------
  |  |  111|      1|#define DROPBEAR_SUCCESS 0
  ------------------
  100|      1|}
ed25519_key_free:
  103|    423|void ed25519_key_free(dropbear_ed25519_key *key) {
  104|       |
  105|    423|	TRACE2(("enter ed25519_key_free"))
  106|       |
  107|    423|	if (key == NULL) {
  ------------------
  |  Branch (107:6): [True: 423, False: 0]
  ------------------
  108|    423|		TRACE2(("leave ed25519_key_free: key == NULL"))
  109|    423|		return;
  110|    423|	}
  111|      0|	m_burn(key->priv, CURVE25519_LEN);
  ------------------
  |  |   34|      0|#define CURVE25519_LEN 32
  ------------------
  112|      0|	m_free(key);
  ------------------
  |  |   24|      0|#define m_free(X) do {m_free_direct(X); (X) = NULL;} while (0)
  |  |  ------------------
  |  |  |  Branch (24:61): [Folded, False: 0]
  |  |  ------------------
  ------------------
  113|       |
  114|      0|	TRACE2(("leave ed25519_key_free"))
  115|      0|}
buf_put_ed25519_pub_key:
  118|    275|void buf_put_ed25519_pub_key(buffer *buf, const dropbear_ed25519_key *key) {
  119|       |
  120|    275|	TRACE(("enter buf_put_ed25519_pub_key"))
  121|    275|	dropbear_assert(key != NULL);
  ------------------
  |  |   86|    275|#define dropbear_assert(X) do { if (!(X)) { fail_assert(#X, __FILE__, __LINE__); } } while (0)
  |  |  ------------------
  |  |  |  Branch (86:37): [True: 0, False: 275]
  |  |  |  Branch (86:93): [Folded, False: 275]
  |  |  ------------------
  ------------------
  122|       |
  123|    275|	buf_putstring(buf, SSH_SIGNKEY_ED25519, SSH_SIGNKEY_ED25519_LEN);
  ------------------
  |  |  118|    275|#define SSH_SIGNKEY_ED25519 "ssh-ed25519"
  ------------------
              	buf_putstring(buf, SSH_SIGNKEY_ED25519, SSH_SIGNKEY_ED25519_LEN);
  ------------------
  |  |  119|    275|#define SSH_SIGNKEY_ED25519_LEN 11
  ------------------
  124|    275|	buf_putstring(buf, key->pub, CURVE25519_LEN);
  ------------------
  |  |   34|    275|#define CURVE25519_LEN 32
  ------------------
  125|       |
  126|    275|	TRACE(("leave buf_put_ed25519_pub_key"))
  127|    275|}
buf_ed25519_verify:
  163|     80|int buf_ed25519_verify(buffer *buf, const dropbear_ed25519_key *key, const buffer *data_buf) {
  164|       |
  165|     80|	int ret = DROPBEAR_FAILURE;
  ------------------
  |  |  112|     80|#define DROPBEAR_FAILURE -1
  ------------------
  166|     80|	unsigned char *s;
  167|     80|	unsigned long slen;
  168|       |
  169|     80|	TRACE(("enter buf_ed25519_verify"))
  170|     80|	dropbear_assert(key != NULL);
  ------------------
  |  |   86|     80|#define dropbear_assert(X) do { if (!(X)) { fail_assert(#X, __FILE__, __LINE__); } } while (0)
  |  |  ------------------
  |  |  |  Branch (86:37): [True: 0, False: 80]
  |  |  |  Branch (86:93): [Folded, False: 80]
  |  |  ------------------
  ------------------
  171|       |
  172|     80|	slen = buf_getint(buf);
  173|     80|	if (slen != 64 || buf->len - buf->pos < slen) {
  ------------------
  |  Branch (173:6): [True: 34, False: 46]
  |  Branch (173:20): [True: 7, False: 39]
  ------------------
  174|     41|		TRACE(("leave buf_ed25519_verify: bad size"))
  175|     41|		goto out;
  176|     41|	}
  177|     39|	s = buf_getptr(buf, slen);
  178|       |
  179|     39|	if (dropbear_ed25519_verify(data_buf->data, data_buf->len,
  ------------------
  |  Branch (179:6): [True: 0, False: 39]
  ------------------
  180|     39|				    s, slen, key->pub) == 0) {
  181|       |		/* signature is valid */
  182|      0|		TRACE(("leave buf_ed25519_verify: success!"))
  183|      0|		ret = DROPBEAR_SUCCESS;
  ------------------
  |  |  111|      0|#define DROPBEAR_SUCCESS 0
  ------------------
  184|      0|	}
  185|       |
  186|     80|out:
  187|     80|	TRACE(("leave buf_ed25519_verify: ret %d", ret))
  188|     80|	return ret;
  189|     39|}

gen_kexdh_param:
   21|  1.08k|struct kex_dh_param *gen_kexdh_param() {
   22|  1.08k|    struct kex_dh_param *param = NULL;
   23|       |
   24|  1.08k|    DEF_MP_INT(dh_p);
  ------------------
  |  |   83|  1.08k|#define DEF_MP_INT(X) mp_int X = {0, 0, 0, NULL}
  ------------------
   25|  1.08k|    DEF_MP_INT(dh_q);
  ------------------
  |  |   83|  1.08k|#define DEF_MP_INT(X) mp_int X = {0, 0, 0, NULL}
  ------------------
   26|  1.08k|    DEF_MP_INT(dh_g);
  ------------------
  |  |   83|  1.08k|#define DEF_MP_INT(X) mp_int X = {0, 0, 0, NULL}
  ------------------
   27|       |
   28|  1.08k|    TRACE(("enter gen_kexdh_vals"))
   29|       |
   30|  1.08k|    param = m_malloc(sizeof(*param));
   31|  1.08k|    m_mp_init_multi(&param->pub, &param->priv, &dh_g, &dh_p, &dh_q, NULL);
   32|       |
   33|       |    /* read the prime and generator*/
   34|  1.08k|    load_dh_p(&dh_p);
   35|       |    
   36|  1.08k|    mp_set_ul(&dh_g, DH_G_VAL);
   37|       |
   38|       |    /* calculate q = (p-1)/2 */
   39|       |    /* dh_priv is just a temp var here */
   40|  1.08k|    if (mp_sub_d(&dh_p, 1, &param->priv) != MP_OKAY) { 
  ------------------
  |  |  161|  1.08k|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (40:9): [True: 0, False: 1.08k]
  ------------------
   41|      0|        dropbear_exit("Diffie-Hellman error");
   42|      0|    }
   43|  1.08k|    if (mp_div_2(&param->priv, &dh_q) != MP_OKAY) {
  ------------------
  |  |  161|  1.08k|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (43:9): [True: 0, False: 1.08k]
  ------------------
   44|      0|        dropbear_exit("Diffie-Hellman error");
   45|      0|    }
   46|       |
   47|       |    /* Generate a private portion 0 < dh_priv < dh_q */
   48|  1.08k|    gen_random_mpint(&dh_q, &param->priv);
   49|       |
   50|       |    /* f = g^y mod p */
   51|  1.08k|    if (mp_exptmod(&dh_g, &param->priv, &dh_p, &param->pub) != MP_OKAY) {
  ------------------
  |  |  161|  1.08k|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (51:9): [True: 0, False: 1.08k]
  ------------------
   52|      0|        dropbear_exit("Diffie-Hellman error");
   53|      0|    }
   54|  1.08k|    mp_clear_multi(&dh_g, &dh_p, &dh_q, NULL);
   55|  1.08k|    return param;
   56|  1.08k|}
free_kexdh_param:
   59|    981|{
   60|    981|    mp_clear_multi(&param->pub, &param->priv, NULL);
   61|       |    m_free(param);
  ------------------
  |  |   24|    981|#define m_free(X) do {m_free_direct(X); (X) = NULL;} while (0)
  |  |  ------------------
  |  |  |  Branch (24:61): [Folded, False: 981]
  |  |  ------------------
  ------------------
   62|    981|}
kexdh_comb_key:
   69|    994|        sign_key *hostkey) {
   70|       |
   71|    994|    DEF_MP_INT(dh_p);
  ------------------
  |  |   83|    994|#define DEF_MP_INT(X) mp_int X = {0, 0, 0, NULL}
  ------------------
   72|    994|    DEF_MP_INT(dh_p_min1);
  ------------------
  |  |   83|    994|#define DEF_MP_INT(X) mp_int X = {0, 0, 0, NULL}
  ------------------
   73|    994|    mp_int *dh_e = NULL, *dh_f = NULL;
   74|       |
   75|    994|    m_mp_init_multi(&dh_p, &dh_p_min1, NULL);
   76|    994|    load_dh_p(&dh_p);
   77|       |
   78|    994|    if (mp_sub_d(&dh_p, 1, &dh_p_min1) != MP_OKAY) { 
  ------------------
  |  |  161|    994|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (78:9): [True: 0, False: 994]
  ------------------
   79|      0|        dropbear_exit("Diffie-Hellman error");
   80|      0|    }
   81|       |
   82|       |    /* Check that dh_pub_them (dh_e or dh_f) is in the range [2, p-2] */
   83|    994|    if (mp_cmp(dh_pub_them, &dh_p_min1) != MP_LT 
  ------------------
  |  |  154|  1.98k|#define MP_LT        -1   /* less than */
  ------------------
  |  Branch (83:9): [True: 2, False: 992]
  ------------------
   84|    992|            || mp_cmp_d(dh_pub_them, 1) != MP_GT) {
  ------------------
  |  |  156|    992|#define MP_GT         1   /* greater than */
  ------------------
  |  Branch (84:16): [True: 3, False: 989]
  ------------------
   85|      5|        dropbear_exit("Diffie-Hellman error");
   86|      5|    }
   87|       |    
   88|       |    /* K = e^y mod p = f^x mod p */
   89|    989|    m_mp_alloc_init_multi(&ses.dh_K, NULL);
   90|    989|    if (mp_exptmod(dh_pub_them, &param->priv, &dh_p, ses.dh_K) != MP_OKAY) {
  ------------------
  |  |  161|    989|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (90:9): [True: 0, False: 989]
  ------------------
   91|      0|        dropbear_exit("Diffie-Hellman error");
   92|      0|    }
   93|       |
   94|       |    /* clear no longer needed vars */
   95|    989|    mp_clear_multi(&dh_p, &dh_p_min1, NULL);
   96|       |
   97|       |    /* From here on, the code needs to work with the _same_ vars on each side,
   98|       |     * not vice-versaing for client/server */
   99|    989|    if (IS_DROPBEAR_CLIENT) {
  ------------------
  |  |  384|    989|#define IS_DROPBEAR_CLIENT (ses.isserver == 0)
  |  |  ------------------
  |  |  |  Branch (384:28): [True: 989, False: 0]
  |  |  ------------------
  ------------------
  100|    989|        dh_e = &param->pub;
  101|    989|        dh_f = dh_pub_them;
  102|    989|    } else {
  103|      0|        dh_e = dh_pub_them;
  104|      0|        dh_f = &param->pub;
  105|      0|    } 
  106|       |
  107|       |    /* Create the remainder of the hash buffer, to generate the exchange hash */
  108|       |    /* K_S, the host key */
  109|    989|    buf_put_pub_key(ses.kexhashbuf, hostkey, ses.newkeys->algo_hostkey);
  110|       |    /* e, exchange value sent by the client */
  111|    989|    buf_putmpint(ses.kexhashbuf, dh_e);
  112|       |    /* f, exchange value sent by the server */
  113|    989|    buf_putmpint(ses.kexhashbuf, dh_f);
  114|       |    /* K, the shared secret */
  115|    989|    buf_putmpint(ses.kexhashbuf, ses.dh_K);
  116|       |
  117|       |    /* calculate the hash H to sign */
  118|    989|    finish_kexhashbuf();
  119|    989|}
kex-dh.c:load_dh_p:
   13|  2.07k|{
   14|  2.07k|    bytes_to_mp(dh_p, ses.newkeys->algo_kex->dh_p_bytes, 
   15|  2.07k|        ses.newkeys->algo_kex->dh_p_len);
   16|  2.07k|}

gen_kexecdh_param:
   11|    762|struct kex_ecdh_param *gen_kexecdh_param() {
   12|    762|    struct kex_ecdh_param *param = m_malloc(sizeof(*param));
   13|    762|    const struct dropbear_ecc_curve *curve = ses.newkeys->algo_kex->details;
   14|    762|    if (ecc_make_key_ex(NULL, dropbear_ltc_prng, 
  ------------------
  |  Branch (14:9): [True: 0, False: 762]
  ------------------
   15|    762|        &param->key, curve->dp) != CRYPT_OK) {
   16|      0|        dropbear_exit("ECC error");
   17|      0|    }
   18|    762|    return param;
   19|    762|}
free_kexecdh_param:
   21|     78|void free_kexecdh_param(struct kex_ecdh_param *param) {
   22|     78|    ecc_free(&param->key);
   23|     78|    m_free(param);
  ------------------
  |  |   24|     78|#define m_free(X) do {m_free_direct(X); (X) = NULL;} while (0)
  |  |  ------------------
  |  |  |  Branch (24:61): [Folded, False: 78]
  |  |  ------------------
  ------------------
   24|       |
   25|     78|}
kexecdh_comb_key:
   27|    119|        sign_key *hostkey) {
   28|    119|    const struct dropbear_ecc_curve *curve
   29|    119|        = ses.newkeys->algo_kex->details;
   30|       |    /* public keys from client and server */
   31|    119|    ecc_key *Q_C, *Q_S, *Q_them;
   32|       |
   33|    119|    Q_them = buf_get_ecc_raw_pubkey(pub_them, curve);
   34|    119|    if (Q_them == NULL) {
  ------------------
  |  Branch (34:9): [True: 37, False: 82]
  ------------------
   35|     37|        dropbear_exit("ECC error");
   36|     37|    }
   37|       |
   38|     82|    ses.dh_K = dropbear_ecc_shared_secret(Q_them, &param->key);
   39|       |
   40|       |    /* Create the remainder of the hash buffer, to generate the exchange hash
   41|       |       See RFC5656 section 4 page 7 */
   42|     82|    if (IS_DROPBEAR_CLIENT) {
  ------------------
  |  |  384|     82|#define IS_DROPBEAR_CLIENT (ses.isserver == 0)
  |  |  ------------------
  |  |  |  Branch (384:28): [True: 78, False: 4]
  |  |  ------------------
  ------------------
   43|     78|        Q_C = &param->key;
   44|     78|        Q_S = Q_them;
   45|     78|    } else {
   46|      4|        Q_C = Q_them;
   47|      4|        Q_S = &param->key;
   48|      4|    } 
   49|       |
   50|       |    /* K_S, the host key */
   51|     82|    buf_put_pub_key(ses.kexhashbuf, hostkey, ses.newkeys->algo_hostkey);
   52|       |    /* Q_C, client's ephemeral public key octet string */
   53|     82|    buf_put_ecc_raw_pubkey_string(ses.kexhashbuf, Q_C);
   54|       |    /* Q_S, server's ephemeral public key octet string */
   55|     82|    buf_put_ecc_raw_pubkey_string(ses.kexhashbuf, Q_S);
   56|       |    /* K, the shared secret */
   57|     82|    buf_putmpint(ses.kexhashbuf, ses.dh_K);
   58|       |
   59|     82|    ecc_free(Q_them);
   60|     82|    m_free(Q_them);
  ------------------
  |  |   24|     82|#define m_free(X) do {m_free_direct(X); (X) = NULL;} while (0)
  |  |  ------------------
  |  |  |  Branch (24:61): [Folded, False: 82]
  |  |  ------------------
  ------------------
   61|       |
   62|       |    /* calculate the hash H to sign */
   63|     82|    finish_kexhashbuf();
   64|     82|}

gen_kexpqhybrid_param:
   13|  3.53k|struct kex_pqhybrid_param *gen_kexpqhybrid_param() {
   14|  3.53k|    struct kex_pqhybrid_param *param = m_malloc(sizeof(*param));
   15|  3.53k|    const struct dropbear_kem_desc *kem = ses.newkeys->algo_kex->details;
   16|       |
   17|  3.53k|    param->curve25519 = gen_kexcurve25519_param();
   18|       |
   19|  3.53k|    if (IS_DROPBEAR_CLIENT) {
  ------------------
  |  |  384|  3.53k|#define IS_DROPBEAR_CLIENT (ses.isserver == 0)
  |  |  ------------------
  |  |  |  Branch (384:28): [True: 3.53k, False: 0]
  |  |  ------------------
  ------------------
   20|  3.53k|        param->kem_cli_secret = buf_new(kem->secret_len);
   21|  3.53k|        param->concat_public = buf_new(kem->public_len + CURVE25519_LEN);
  ------------------
  |  |  122|  3.53k|#define CURVE25519_LEN 32
  ------------------
   22|  3.53k|        kem->kem_gen(
   23|  3.53k|            buf_getwriteptr(param->concat_public, kem->public_len),
   24|  3.53k|            buf_getwriteptr(param->kem_cli_secret, kem->secret_len));
   25|  3.53k|        buf_incrwritepos(param->concat_public, kem->public_len);
   26|  3.53k|        buf_incrwritepos(param->kem_cli_secret, kem->secret_len);
   27|  3.53k|        buf_setpos(param->kem_cli_secret, 0);
   28|       |        /* Append the curve25519 parameter */
   29|  3.53k|        buf_putbytes(param->concat_public, param->curve25519->pub, CURVE25519_LEN);
  ------------------
  |  |  122|  3.53k|#define CURVE25519_LEN 32
  ------------------
   30|  3.53k|    }
   31|       |
   32|  3.53k|    return param;
   33|  3.53k|}
free_kexpqhybrid_param:
   35|  2.43k|void free_kexpqhybrid_param(struct kex_pqhybrid_param *param) {
   36|  2.43k|    free_kexcurve25519_param(param->curve25519);
   37|  2.43k|    if (param->kem_cli_secret) {
  ------------------
  |  Branch (37:9): [True: 2.38k, False: 48]
  ------------------
   38|  2.38k|        buf_burn_free(param->kem_cli_secret);
   39|  2.38k|        param->kem_cli_secret = NULL;
   40|  2.38k|    }
   41|  2.43k|    buf_free(param->concat_public);
   42|       |    m_free(param);
  ------------------
  |  |   24|  2.43k|#define m_free(X) do {m_free_direct(X); (X) = NULL;} while (0)
  |  |  ------------------
  |  |  |  Branch (24:61): [Folded, False: 2.43k]
  |  |  ------------------
  ------------------
   43|  2.43k|}
kexpqhybrid_comb_key:
   46|     58|    buffer *buf_pub, sign_key *hostkey) {
   47|       |
   48|     58|    const struct dropbear_kem_desc *kem = ses.newkeys->algo_kex->details;
   49|     58|    const struct ltc_hash_descriptor *hash_desc
   50|     58|        = ses.newkeys->algo_kex->hash_desc;
   51|       |
   52|       |    /* Either public key (from client) or ciphertext (from server) */
   53|     58|    unsigned char *remote_pub_kem = NULL;
   54|     58|    buffer *pub_25519 = NULL;
   55|     58|    buffer *k_out = NULL;
   56|     58|    unsigned int remote_len;
   57|     58|    hash_state hs;
   58|     58|    const buffer * Q_C = NULL;
   59|     58|    const buffer * Q_S = NULL;
   60|       |
   61|       |    /* Extract input parts from the remote peer */
   62|     58|    if (IS_DROPBEAR_CLIENT) {
  ------------------
  |  |  384|     58|#define IS_DROPBEAR_CLIENT (ses.isserver == 0)
  |  |  ------------------
  |  |  |  Branch (384:28): [True: 58, False: 0]
  |  |  ------------------
  ------------------
   63|       |        /* S_REPLY = S_CT2 || S_PK1 */
   64|     58|        remote_len = kem->ciphertext_len;
   65|     58|    } else {
   66|       |        /* C_INIT = C_PK2 || C_PK1 */
   67|      0|        remote_len = kem->public_len;
   68|      0|    }
   69|     58|    remote_pub_kem = buf_getptr(buf_pub, remote_len);
   70|     58|    buf_incrpos(buf_pub, remote_len);
   71|     58|    pub_25519 = buf_getptrcopy(buf_pub, CURVE25519_LEN);
  ------------------
  |  |  122|     58|#define CURVE25519_LEN 32
  ------------------
   72|     58|    buf_incrpos(buf_pub, CURVE25519_LEN);
  ------------------
  |  |  122|     58|#define CURVE25519_LEN 32
  ------------------
   73|       |    /* Check all is consumed */
   74|     58|    if (buf_pub->pos != buf_pub->len) {
  ------------------
  |  Branch (74:9): [True: 4, False: 54]
  ------------------
   75|      4|        dropbear_exit("Bad sntrup");
   76|      4|    }
   77|       |
   78|       |    /* k_out = K_PQ || K_CL */
   79|     54|    k_out = buf_new(kem->output_len + CURVE25519_LEN);
  ------------------
  |  |  122|     54|#define CURVE25519_LEN 32
  ------------------
   80|       |
   81|       |    /* Derive pq kem part (K_PQ) */
   82|     54|    if (IS_DROPBEAR_CLIENT) {
  ------------------
  |  |  384|     54|#define IS_DROPBEAR_CLIENT (ses.isserver == 0)
  |  |  ------------------
  |  |  |  Branch (384:28): [True: 49, False: 5]
  |  |  ------------------
  ------------------
   83|     49|        kem->kem_dec(
   84|     49|            buf_getwriteptr(k_out, kem->output_len),
   85|     49|            remote_pub_kem,
   86|     49|            buf_getptr(param->kem_cli_secret, kem->secret_len));
   87|     49|        buf_burn_free(param->kem_cli_secret);
   88|     49|        param->kem_cli_secret = NULL;
   89|     49|    } else {
   90|       |        /* Server returns ciphertext */
   91|      5|        assert(param->concat_public == NULL);
  ------------------
  |  Branch (91:9): [True: 0, False: 5]
  |  Branch (91:9): [True: 0, False: 5]
  ------------------
   92|      5|        param->concat_public = buf_new(kem->ciphertext_len + CURVE25519_LEN);
  ------------------
  |  |  122|      0|#define CURVE25519_LEN 32
  ------------------
   93|      0|        kem->kem_enc(
   94|      0|            buf_getwriteptr(param->concat_public, kem->ciphertext_len),
   95|      0|            buf_getwriteptr(k_out, kem->output_len),
   96|      0|            remote_pub_kem);
   97|      0|        buf_incrwritepos(param->concat_public, kem->ciphertext_len);
   98|       |        /* Append the curve25519 parameter */
   99|      0|        buf_putbytes(param->concat_public, param->curve25519->pub, CURVE25519_LEN);
  ------------------
  |  |  122|      0|#define CURVE25519_LEN 32
  ------------------
  100|      0|    }
  101|     54|    buf_incrwritepos(k_out, kem->output_len);
  102|       |
  103|       |    /* Derive ec part (K_CL) */
  104|     49|    kexcurve25519_derive(param->curve25519, pub_25519,
  105|     49|        buf_getwriteptr(k_out, CURVE25519_LEN));
  ------------------
  |  |  122|     49|#define CURVE25519_LEN 32
  ------------------
  106|     49|    buf_incrwritepos(k_out, CURVE25519_LEN);
  ------------------
  |  |  122|     49|#define CURVE25519_LEN 32
  ------------------
  107|       |
  108|       |    /* dh_K_bytes = HASH(k_out)
  109|       |       dh_K_bytes is a SSH string with length prefix, since
  110|       |       that is what needs to be hashed in gen_new_keys() */
  111|     49|    ses.dh_K_bytes = buf_new(4 + hash_desc->hashsize);
  112|     49|    buf_putint(ses.dh_K_bytes, hash_desc->hashsize);
  113|     49|    hash_desc->init(&hs);
  114|     49|    hash_desc->process(&hs, k_out->data, k_out->len);
  115|     49|    hash_desc->done(&hs, buf_getwriteptr(ses.dh_K_bytes, hash_desc->hashsize));
  116|     49|    m_burn(&hs, sizeof(hash_state));
  117|     49|    buf_incrwritepos(ses.dh_K_bytes, hash_desc->hashsize);
  118|       |
  119|       |    /* Create the remainder of the hash buffer */
  120|     49|    if (IS_DROPBEAR_CLIENT) {
  ------------------
  |  |  384|     49|#define IS_DROPBEAR_CLIENT (ses.isserver == 0)
  |  |  ------------------
  |  |  |  Branch (384:28): [True: 48, False: 1]
  |  |  ------------------
  ------------------
  121|     48|        Q_C = param->concat_public;
  122|     48|        Q_S = buf_pub;
  123|     48|    } else {
  124|      1|        Q_S = param->concat_public;
  125|      1|        Q_C = buf_pub;
  126|      1|    }
  127|       |
  128|       |    /* K_S, the host key */
  129|     49|    buf_put_pub_key(ses.kexhashbuf, hostkey, ses.newkeys->algo_hostkey);
  130|     49|    buf_putbufstring(ses.kexhashbuf, Q_C);
  131|     49|    buf_putbufstring(ses.kexhashbuf, Q_S);
  132|       |    /* K, the shared secret */
  133|     49|    buf_putbytes(ses.kexhashbuf, ses.dh_K_bytes->data, ses.dh_K_bytes->len);
  134|       |
  135|       |    /* calculate the hash H to sign */
  136|     49|    finish_kexhashbuf();
  137|       |
  138|     49|    buf_burn_free(k_out);
  139|     49|    buf_free(pub_25519);
  140|     49|}

gen_kexcurve25519_param:
   14|  3.96k|struct kex_curve25519_param *gen_kexcurve25519_param() {
   15|       |    /* Per http://cr.yp.to/ecdh.html */
   16|  3.96k|    struct kex_curve25519_param *param = m_malloc(sizeof(*param));
   17|  3.96k|    const unsigned char basepoint[32] = {9};
   18|       |
   19|  3.96k|    genrandom(param->priv, CURVE25519_LEN);
  ------------------
  |  |  122|  3.96k|#define CURVE25519_LEN 32
  ------------------
   20|  3.96k|    dropbear_curve25519_scalarmult(param->pub, param->priv, basepoint);
   21|       |
   22|  3.96k|    return param;
   23|  3.96k|}
free_kexcurve25519_param:
   25|  2.67k|void free_kexcurve25519_param(struct kex_curve25519_param *param) {
   26|  2.67k|    m_burn(param->priv, CURVE25519_LEN);
  ------------------
  |  |  122|  2.67k|#define CURVE25519_LEN 32
  ------------------
   27|       |    m_free(param);
  ------------------
  |  |   24|  2.67k|#define m_free(X) do {m_free_direct(X); (X) = NULL;} while (0)
  |  |  ------------------
  |  |  |  Branch (24:61): [Folded, False: 2.67k]
  |  |  ------------------
  ------------------
   28|  2.67k|}
kexcurve25519_derive:
   32|    309|    unsigned char *out) {
   33|    309|    char zeroes[CURVE25519_LEN] = {0};
   34|    309|    if (buf_pub_them->len != CURVE25519_LEN)
  ------------------
  |  |  122|    309|#define CURVE25519_LEN 32
  ------------------
  |  Branch (34:9): [True: 14, False: 295]
  ------------------
   35|     14|    {
   36|     14|        dropbear_exit("Bad curve25519");
   37|     14|    }
   38|       |
   39|    295|    dropbear_curve25519_scalarmult(out, param->priv, buf_pub_them->data);
   40|       |
   41|    295|    if (constant_time_memcmp(zeroes, out, CURVE25519_LEN) == 0) {
  ------------------
  |  |  122|    295|#define CURVE25519_LEN 32
  ------------------
  |  Branch (41:9): [True: 2, False: 293]
  ------------------
   42|      2|        dropbear_exit("Bad curve25519");
   43|      2|    }
   44|    295|}
kexcurve25519_comb_key:
   52|    260|    sign_key *hostkey) {
   53|    260|    unsigned char out[CURVE25519_LEN];
   54|    260|    const unsigned char* Q_C = NULL;
   55|    260|    const unsigned char* Q_S = NULL;
   56|       |
   57|    260|    kexcurve25519_derive(param, buf_pub_them, out);
   58|       |
   59|    260|    m_mp_alloc_init_multi(&ses.dh_K, NULL);
   60|    260|    bytes_to_mp(ses.dh_K, out, CURVE25519_LEN);
  ------------------
  |  |  122|    260|#define CURVE25519_LEN 32
  ------------------
   61|    260|    m_burn(out, sizeof(out));
   62|       |
   63|       |    /* Create the remainder of the hash buffer, to generate the exchange hash.
   64|       |       See RFC5656 section 4 page 7 */
   65|    260|    if (IS_DROPBEAR_CLIENT) {
  ------------------
  |  |  384|    260|#define IS_DROPBEAR_CLIENT (ses.isserver == 0)
  |  |  ------------------
  |  |  |  Branch (384:28): [True: 245, False: 15]
  |  |  ------------------
  ------------------
   66|    245|        Q_C = param->pub;
   67|    245|        Q_S = buf_pub_them->data;
   68|    245|    } else {
   69|     15|        Q_S = param->pub;
   70|     15|        Q_C = buf_pub_them->data;
   71|     15|    }
   72|       |
   73|       |    /* K_S, the host key */
   74|    260|    buf_put_pub_key(ses.kexhashbuf, hostkey, ses.newkeys->algo_hostkey);
   75|       |    /* Q_C, client's ephemeral public key octet string */
   76|    260|    buf_putstring(ses.kexhashbuf, (const char*)Q_C, CURVE25519_LEN);
  ------------------
  |  |  122|    260|#define CURVE25519_LEN 32
  ------------------
   77|       |    /* Q_S, server's ephemeral public key octet string */
   78|    260|    buf_putstring(ses.kexhashbuf, (const char*)Q_S, CURVE25519_LEN);
  ------------------
  |  |  122|    260|#define CURVE25519_LEN 32
  ------------------
   79|       |    /* K, the shared secret */
   80|    260|    buf_putmpint(ses.kexhashbuf, ses.dh_K);
   81|       |
   82|       |    /* calculate the hash H to sign */
   83|    260|    finish_kexhashbuf();
   84|    260|}

mlkem768.c:libcrux_ml_kem_mlkem768_portable_generate_key_pair:
11618|     55|libcrux_ml_kem_mlkem768_portable_generate_key_pair(uint8_t randomness[64U]) {
11619|       |  /* Passing arrays by value in Rust generates a copy in C */
11620|     55|  uint8_t copy_of_randomness[64U];
11621|     55|  memcpy(copy_of_randomness, randomness, (size_t)64U * sizeof(uint8_t));
11622|     55|  return libcrux_ml_kem_ind_cca_instantiations_portable_generate_keypair_d5(
11623|     55|      copy_of_randomness);
11624|     55|}
mlkem768.c:libcrux_ml_kem_ind_cca_instantiations_portable_generate_keypair_d5:
11607|     55|    uint8_t randomness[64U]) {
11608|       |  /* Passing arrays by value in Rust generates a copy in C */
11609|     55|  uint8_t copy_of_randomness[64U];
11610|     55|  memcpy(copy_of_randomness, randomness, (size_t)64U * sizeof(uint8_t));
11611|     55|  return libcrux_ml_kem_ind_cca_generate_keypair_8c(copy_of_randomness);
11612|     55|}
mlkem768.c:libcrux_ml_kem_ind_cca_generate_keypair_8c:
11557|     55|libcrux_ml_kem_ind_cca_generate_keypair_8c(uint8_t randomness[64U]) {
11558|     55|  Eurydice_slice ind_cpa_keypair_randomness = Eurydice_array_to_subslice2(
  ------------------
  |  |  113|     55|  EURYDICE_SLICE((t *)x, start, end)
  |  |  ------------------
  |  |  |  |   88|     55|  (CLITERAL(Eurydice_slice){.ptr = (void *)(x + start), .len = end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |   61|     55|#define CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
11559|     55|      randomness, (size_t)0U,
11560|     55|      LIBCRUX_ML_KEM_CONSTANTS_CPA_PKE_KEY_GENERATION_SEED_SIZE, uint8_t);
11561|     55|  Eurydice_slice implicit_rejection_value = Eurydice_array_to_subslice_from(
  ------------------
  |  |  117|     55|  EURYDICE_SLICE((t *)x, r, size)
  |  |  ------------------
  |  |  |  |   88|     55|  (CLITERAL(Eurydice_slice){.ptr = (void *)(x + start), .len = end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |   61|     55|#define CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
11562|     55|      (size_t)64U, randomness,
11563|     55|      LIBCRUX_ML_KEM_CONSTANTS_CPA_PKE_KEY_GENERATION_SEED_SIZE, uint8_t,
11564|     55|      size_t);
11565|     55|  libcrux_ml_kem_utils_extraction_helper_Keypair768 uu____0 =
11566|     55|      libcrux_ml_kem_ind_cpa_generate_keypair_fc(ind_cpa_keypair_randomness);
11567|     55|  uint8_t ind_cpa_private_key[1152U];
11568|     55|  memcpy(ind_cpa_private_key, uu____0.fst, (size_t)1152U * sizeof(uint8_t));
11569|     55|  uint8_t public_key[1184U];
11570|     55|  memcpy(public_key, uu____0.snd, (size_t)1184U * sizeof(uint8_t));
11571|     55|  uint8_t secret_key_serialized[2400U];
11572|     55|  libcrux_ml_kem_ind_cca_serialize_kem_secret_key_48(
11573|     55|      Eurydice_array_to_slice((size_t)1152U, ind_cpa_private_key, uint8_t),
  ------------------
  |  |  107|     55|  EURYDICE_SLICE(x, 0,                     \
  |  |  ------------------
  |  |  |  |   88|     55|  (CLITERAL(Eurydice_slice){.ptr = (void *)(x + start), .len = end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |   61|     55|#define CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  108|     55|                 end) /* x is already at an array type, no need for cast */
  ------------------
11574|     55|      Eurydice_array_to_slice((size_t)1184U, public_key, uint8_t),
  ------------------
  |  |  107|     55|  EURYDICE_SLICE(x, 0,                     \
  |  |  ------------------
  |  |  |  |   88|     55|  (CLITERAL(Eurydice_slice){.ptr = (void *)(x + start), .len = end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |   61|     55|#define CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  108|     55|                 end) /* x is already at an array type, no need for cast */
  ------------------
11575|     55|      implicit_rejection_value, secret_key_serialized);
11576|       |  /* Passing arrays by value in Rust generates a copy in C */
11577|     55|  uint8_t copy_of_secret_key_serialized[2400U];
11578|     55|  memcpy(copy_of_secret_key_serialized, secret_key_serialized,
11579|     55|         (size_t)2400U * sizeof(uint8_t));
11580|     55|  libcrux_ml_kem_types_MlKemPrivateKey_55 private_key =
11581|     55|      libcrux_ml_kem_types_from_05_f2(copy_of_secret_key_serialized);
11582|     55|  libcrux_ml_kem_types_MlKemPrivateKey_55 uu____2 = private_key;
11583|       |  /* Passing arrays by value in Rust generates a copy in C */
11584|     55|  uint8_t copy_of_public_key[1184U];
11585|     55|  memcpy(copy_of_public_key, public_key, (size_t)1184U * sizeof(uint8_t));
11586|     55|  return libcrux_ml_kem_types_from_17_35(
11587|     55|      uu____2, libcrux_ml_kem_types_from_b6_da(copy_of_public_key));
11588|     55|}
mlkem768.c:libcrux_ml_kem_ind_cpa_generate_keypair_fc:
11418|     55|libcrux_ml_kem_ind_cpa_generate_keypair_fc(Eurydice_slice key_generation_seed) {
11419|     55|  uint8_t hashed[64U];
11420|     55|  libcrux_ml_kem_variant_cpa_keygen_seed_d8_0e(key_generation_seed, hashed);
11421|     55|  Eurydice_slice_uint8_t_x2 uu____0 = Eurydice_slice_split_at(
  ------------------
  |  |  139|     55|  (CLITERAL(ret_t){                                              \
  |  |  ------------------
  |  |  |  |   61|     55|#define CLITERAL(type) (type)
  |  |  ------------------
  |  |  140|     55|      .fst = EURYDICE_SLICE((element_type *)slice.ptr, 0, mid),  \
  |  |  ------------------
  |  |  |  |   88|     55|  (CLITERAL(Eurydice_slice){.ptr = (void *)(x + start), .len = end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |   61|     55|#define CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  141|     55|      .snd = EURYDICE_SLICE((element_type *)slice.ptr, mid, slice.len)})
  |  |  ------------------
  |  |  |  |   88|     55|  (CLITERAL(Eurydice_slice){.ptr = (void *)(x + start), .len = end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |   61|     55|#define CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
11422|     55|      Eurydice_array_to_slice((size_t)64U, hashed, uint8_t), (size_t)32U,
11423|     55|      uint8_t, Eurydice_slice_uint8_t_x2);
11424|     55|  Eurydice_slice seed_for_A0 = uu____0.fst;
11425|     55|  Eurydice_slice seed_for_secret_and_error = uu____0.snd;
11426|     55|  libcrux_ml_kem_polynomial_PolynomialRingElement_f0 A_transpose[3U][3U];
11427|     55|  uint8_t ret[34U];
11428|     55|  libcrux_ml_kem_utils_into_padded_array_ea1(seed_for_A0, ret);
11429|     55|  libcrux_ml_kem_matrix_sample_matrix_A_38(ret, true, A_transpose);
11430|     55|  uint8_t prf_input[33U];
11431|     55|  libcrux_ml_kem_utils_into_padded_array_ea2(seed_for_secret_and_error,
11432|     55|                                             prf_input);
11433|       |  /* Passing arrays by value in Rust generates a copy in C */
11434|     55|  uint8_t copy_of_prf_input0[33U];
11435|     55|  memcpy(copy_of_prf_input0, prf_input, (size_t)33U * sizeof(uint8_t));
11436|     55|  tuple_b0 uu____2 = libcrux_ml_kem_ind_cpa_sample_vector_cbd_then_ntt_fc(
11437|     55|      copy_of_prf_input0, 0U);
11438|     55|  libcrux_ml_kem_polynomial_PolynomialRingElement_f0 secret_as_ntt[3U];
11439|     55|  memcpy(
11440|     55|      secret_as_ntt, uu____2.fst,
11441|     55|      (size_t)3U * sizeof(libcrux_ml_kem_polynomial_PolynomialRingElement_f0));
11442|     55|  uint8_t domain_separator = uu____2.snd;
11443|       |  /* Passing arrays by value in Rust generates a copy in C */
11444|     55|  uint8_t copy_of_prf_input[33U];
11445|     55|  memcpy(copy_of_prf_input, prf_input, (size_t)33U * sizeof(uint8_t));
11446|     55|  libcrux_ml_kem_polynomial_PolynomialRingElement_f0 error_as_ntt[3U];
11447|     55|  memcpy(
11448|     55|      error_as_ntt,
11449|     55|      libcrux_ml_kem_ind_cpa_sample_vector_cbd_then_ntt_fc(copy_of_prf_input,
11450|     55|                                                           domain_separator)
11451|     55|          .fst,
11452|     55|      (size_t)3U * sizeof(libcrux_ml_kem_polynomial_PolynomialRingElement_f0));
11453|     55|  libcrux_ml_kem_polynomial_PolynomialRingElement_f0 t_as_ntt[3U];
11454|     55|  libcrux_ml_kem_matrix_compute_As_plus_e_60(A_transpose, secret_as_ntt,
11455|     55|                                             error_as_ntt, t_as_ntt);
11456|     55|  uint8_t seed_for_A[32U];
11457|     55|  Result_00 dst;
11458|     55|  Eurydice_slice_to_array2(&dst, seed_for_A0, Eurydice_slice, uint8_t[32U]);
  ------------------
  |  |  152|     55|  Eurydice_slice_to_array3(&(dst)->tag, (char *)&(dst)->val.case_Ok, src, \
  |  |  153|     55|                           sizeof(t_arr))
  ------------------
11459|     55|  unwrap_41_83(dst, seed_for_A);
11460|     55|  uint8_t public_key_serialized[1184U];
11461|     55|  libcrux_ml_kem_ind_cpa_serialize_public_key_79(
11462|     55|      t_as_ntt, Eurydice_array_to_slice((size_t)32U, seed_for_A, uint8_t),
  ------------------
  |  |  107|     55|  EURYDICE_SLICE(x, 0,                     \
  |  |  ------------------
  |  |  |  |   88|     55|  (CLITERAL(Eurydice_slice){.ptr = (void *)(x + start), .len = end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |   61|     55|#define CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  108|     55|                 end) /* x is already at an array type, no need for cast */
  ------------------
11463|     55|      public_key_serialized);
11464|     55|  uint8_t secret_key_serialized[1152U];
11465|     55|  libcrux_ml_kem_ind_cpa_serialize_secret_key_b5(secret_as_ntt,
11466|     55|                                                 secret_key_serialized);
11467|       |  /* Passing arrays by value in Rust generates a copy in C */
11468|     55|  uint8_t copy_of_secret_key_serialized[1152U];
11469|     55|  memcpy(copy_of_secret_key_serialized, secret_key_serialized,
11470|     55|         (size_t)1152U * sizeof(uint8_t));
11471|       |  /* Passing arrays by value in Rust generates a copy in C */
11472|     55|  uint8_t copy_of_public_key_serialized[1184U];
11473|     55|  memcpy(copy_of_public_key_serialized, public_key_serialized,
11474|     55|         (size_t)1184U * sizeof(uint8_t));
11475|     55|  libcrux_ml_kem_utils_extraction_helper_Keypair768 lit;
11476|     55|  memcpy(lit.fst, copy_of_secret_key_serialized,
11477|     55|         (size_t)1152U * sizeof(uint8_t));
11478|     55|  memcpy(lit.snd, copy_of_public_key_serialized,
11479|     55|         (size_t)1184U * sizeof(uint8_t));
11480|     55|  return lit;
11481|     55|}
mlkem768.c:libcrux_ml_kem_variant_cpa_keygen_seed_d8_0e:
11197|     55|    Eurydice_slice key_generation_seed, uint8_t ret[64U]) {
11198|     55|  uint8_t seed[33U] = {0U};
11199|     55|  Eurydice_slice_copy(
  ------------------
  |  |  120|     55|  memcpy(dst.ptr, src.ptr, dst.len * sizeof(t))
  ------------------
11200|     55|      Eurydice_array_to_subslice2(
11201|     55|          seed, (size_t)0U,
11202|     55|          LIBCRUX_ML_KEM_CONSTANTS_CPA_PKE_KEY_GENERATION_SEED_SIZE, uint8_t),
11203|     55|      key_generation_seed, uint8_t);
11204|     55|  seed[LIBCRUX_ML_KEM_CONSTANTS_CPA_PKE_KEY_GENERATION_SEED_SIZE] =
  ------------------
  |  |  290|     55|#define LIBCRUX_ML_KEM_CONSTANTS_CPA_PKE_KEY_GENERATION_SEED_SIZE ((size_t)32U)
  ------------------
11205|     55|      (uint8_t)(size_t)3U;
11206|     55|  uint8_t ret0[64U];
11207|     55|  libcrux_ml_kem_hash_functions_portable_G_f1_e4(
11208|     55|      Eurydice_array_to_slice((size_t)33U, seed, uint8_t), ret0);
  ------------------
  |  |  107|     55|  EURYDICE_SLICE(x, 0,                     \
  |  |  ------------------
  |  |  |  |   88|     55|  (CLITERAL(Eurydice_slice){.ptr = (void *)(x + start), .len = end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |   61|     55|#define CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  108|     55|                 end) /* x is already at an array type, no need for cast */
  ------------------
11209|     55|  memcpy(ret, ret0, (size_t)64U * sizeof(uint8_t));
11210|     55|}
mlkem768.c:libcrux_ml_kem_hash_functions_portable_G_f1_e4:
 9293|     55|    Eurydice_slice input, uint8_t ret[64U]) {
 9294|     55|  libcrux_ml_kem_hash_functions_portable_G(input, ret);
 9295|     55|}
mlkem768.c:libcrux_ml_kem_hash_functions_portable_G:
 5799|     55|    Eurydice_slice input, uint8_t ret[64U]) {
 5800|     55|  uint8_t digest[64U] = {0U};
 5801|     55|  libcrux_sha3_portable_sha512(
 5802|     55|      Eurydice_array_to_slice((size_t)64U, digest, uint8_t), input);
  ------------------
  |  |  107|     55|  EURYDICE_SLICE(x, 0,                     \
  |  |  ------------------
  |  |  |  |   88|     55|  (CLITERAL(Eurydice_slice){.ptr = (void *)(x + start), .len = end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |   61|     55|#define CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  108|     55|                 end) /* x is already at an array type, no need for cast */
  ------------------
 5803|     55|  memcpy(ret, digest, (size_t)64U * sizeof(uint8_t));
 5804|     55|}
mlkem768.c:libcrux_sha3_portable_sha512:
 2529|     55|                                                         Eurydice_slice data) {
 2530|     55|  Eurydice_slice buf0[1U] = {data};
 2531|     55|  Eurydice_slice buf[1U] = {digest};
 2532|     55|  libcrux_sha3_portable_keccakx1_ce(buf0, buf);
 2533|     55|}
mlkem768.c:libcrux_sha3_portable_keccakx1_ce:
 2518|     55|    Eurydice_slice data[1U], Eurydice_slice out[1U]) {
 2519|       |  /* Passing arrays by value in Rust generates a copy in C */
 2520|     55|  Eurydice_slice copy_of_data[1U];
 2521|     55|  memcpy(copy_of_data, data, (size_t)1U * sizeof(Eurydice_slice));
 2522|     55|  libcrux_sha3_generic_keccak_keccak_e9(copy_of_data, out);
 2523|     55|}
mlkem768.c:libcrux_sha3_generic_keccak_keccak_e9:
 2447|     55|    Eurydice_slice data[1U], Eurydice_slice out[1U]) {
 2448|     55|  libcrux_sha3_generic_keccak_KeccakState_48 s =
 2449|     55|      libcrux_sha3_generic_keccak_new_1e_f4();
 2450|     55|  for (size_t i = (size_t)0U;
 2451|     55|       i < Eurydice_slice_len(data[0U], uint8_t) / (size_t)72U; i++) {
  ------------------
  |  |  118|     55|#define Eurydice_slice_len(s, t) EURYDICE_SLICE_LEN(s, t)
  |  |  ------------------
  |  |  |  |   89|     55|#define EURYDICE_SLICE_LEN(s, _) s.len
  |  |  ------------------
  ------------------
  |  Branch (2451:8): [True: 0, False: 55]
  ------------------
 2452|      0|    size_t i0 = i;
 2453|      0|    libcrux_sha3_generic_keccak_KeccakState_48 *uu____0 = &s;
 2454|       |    /* Passing arrays by value in Rust generates a copy in C */
 2455|      0|    Eurydice_slice copy_of_data[1U];
 2456|      0|    memcpy(copy_of_data, data, (size_t)1U * sizeof(Eurydice_slice));
 2457|      0|    Eurydice_slice ret[1U];
 2458|      0|    libcrux_sha3_portable_keccak_slice_n_5a(copy_of_data, i0 * (size_t)72U,
 2459|      0|                                            (size_t)72U, ret);
 2460|      0|    libcrux_sha3_generic_keccak_absorb_block_df(uu____0, ret);
 2461|      0|  }
 2462|     55|  size_t rem = Eurydice_slice_len(data[0U], uint8_t) % (size_t)72U;
  ------------------
  |  |  118|     55|#define Eurydice_slice_len(s, t) EURYDICE_SLICE_LEN(s, t)
  |  |  ------------------
  |  |  |  |   89|     55|#define EURYDICE_SLICE_LEN(s, _) s.len
  |  |  ------------------
  ------------------
 2463|     55|  libcrux_sha3_generic_keccak_KeccakState_48 *uu____2 = &s;
 2464|       |  /* Passing arrays by value in Rust generates a copy in C */
 2465|     55|  Eurydice_slice copy_of_data[1U];
 2466|     55|  memcpy(copy_of_data, data, (size_t)1U * sizeof(Eurydice_slice));
 2467|     55|  Eurydice_slice ret[1U];
 2468|     55|  libcrux_sha3_portable_keccak_slice_n_5a(
 2469|     55|      copy_of_data, Eurydice_slice_len(data[0U], uint8_t) - rem, rem, ret);
  ------------------
  |  |  118|     55|#define Eurydice_slice_len(s, t) EURYDICE_SLICE_LEN(s, t)
  |  |  ------------------
  |  |  |  |   89|     55|#define EURYDICE_SLICE_LEN(s, _) s.len
  |  |  ------------------
  ------------------
 2470|     55|  libcrux_sha3_generic_keccak_absorb_final_c7(uu____2, ret);
 2471|     55|  size_t outlen = Eurydice_slice_len(out[0U], uint8_t);
  ------------------
  |  |  118|     55|#define Eurydice_slice_len(s, t) EURYDICE_SLICE_LEN(s, t)
  |  |  ------------------
  |  |  |  |   89|     55|#define EURYDICE_SLICE_LEN(s, _) s.len
  |  |  ------------------
  ------------------
 2472|     55|  size_t blocks = outlen / (size_t)72U;
 2473|     55|  size_t last = outlen - outlen % (size_t)72U;
 2474|     55|  if (blocks == (size_t)0U) {
  ------------------
  |  Branch (2474:7): [True: 55, False: 0]
  ------------------
 2475|     55|    libcrux_sha3_generic_keccak_squeeze_first_and_last_c5(&s, out);
 2476|     55|  } else {
 2477|      0|    Eurydice_slice_uint8_t_1size_t__x2 uu____4 =
 2478|      0|        libcrux_sha3_portable_keccak_split_at_mut_n_5a(out, (size_t)72U);
 2479|      0|    Eurydice_slice o0[1U];
 2480|      0|    memcpy(o0, uu____4.fst, (size_t)1U * sizeof(Eurydice_slice));
 2481|      0|    Eurydice_slice o1[1U];
 2482|      0|    memcpy(o1, uu____4.snd, (size_t)1U * sizeof(Eurydice_slice));
 2483|      0|    libcrux_sha3_generic_keccak_squeeze_first_block_84(&s, o0);
 2484|      0|    core_ops_range_Range_b3 iter =
 2485|      0|        core_iter_traits_collect___core__iter__traits__collect__IntoIterator_for_I__1__into_iter(
  ------------------
  |  |  208|      0|  Eurydice_into_iter
  |  |  ------------------
  |  |  |  |  206|      0|#define Eurydice_into_iter(x, t, _ret_t) (x)
  |  |  ------------------
  ------------------
 2486|      0|            (CLITERAL(core_ops_range_Range_b3){.start = (size_t)1U,
 2487|      0|                                               .end = blocks}),
 2488|      0|            core_ops_range_Range_b3, core_ops_range_Range_b3);
 2489|      0|    while (true) {
  ------------------
  |  Branch (2489:12): [True: 0, Folded]
  ------------------
 2490|      0|      if (core_iter_range___core__iter__traits__iterator__Iterator_for_core__ops__range__Range_A___6__next(
  ------------------
  |  |  203|      0|  Eurydice_range_iter_next
  |  |  ------------------
  |  |  |  |  198|      0|  (((iter_ptr)->start == (iter_ptr)->end)            \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (198:4): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  199|      0|       ? (CLITERAL(ret_t){.tag = None})              \
  |  |  |  |  ------------------
  |  |  |  |  |  |   61|      0|#define CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  |  |                      ? (CLITERAL(ret_t){.tag = None})              \
  |  |  |  |  ------------------
  |  |  |  |  |  |  251|      0|#define None 0
  |  |  |  |  ------------------
  |  |  |  |  200|      0|       : (CLITERAL(ret_t){.tag = Some, .f0 = (iter_ptr)->start++}))
  |  |  |  |  ------------------
  |  |  |  |  |  |   61|      0|#define CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  |  |                      : (CLITERAL(ret_t){.tag = Some, .f0 = (iter_ptr)->start++}))
  |  |  |  |  ------------------
  |  |  |  |  |  |  252|      0|#define Some 1
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (2490:11): [True: 0, False: 0]
  ------------------
 2491|      0|              &iter, size_t, Option_b3)
 2492|      0|              .tag == None) {
  ------------------
  |  |  251|      0|#define None 0
  ------------------
 2493|      0|        break;
 2494|      0|      } else {
 2495|      0|        Eurydice_slice_uint8_t_1size_t__x2 uu____5 =
 2496|      0|            libcrux_sha3_portable_keccak_split_at_mut_n_5a(o1, (size_t)72U);
 2497|      0|        Eurydice_slice o[1U];
 2498|      0|        memcpy(o, uu____5.fst, (size_t)1U * sizeof(Eurydice_slice));
 2499|      0|        Eurydice_slice orest[1U];
 2500|      0|        memcpy(orest, uu____5.snd, (size_t)1U * sizeof(Eurydice_slice));
 2501|      0|        libcrux_sha3_generic_keccak_squeeze_next_block_fc(&s, o);
 2502|      0|        memcpy(o1, orest, (size_t)1U * sizeof(Eurydice_slice));
 2503|      0|      }
 2504|      0|    }
 2505|      0|    if (last < outlen) {
  ------------------
  |  Branch (2505:9): [True: 0, False: 0]
  ------------------
 2506|      0|      libcrux_sha3_generic_keccak_squeeze_last_cf(s, o1);
 2507|      0|    }
 2508|      0|  }
 2509|     55|}
mlkem768.c:libcrux_sha3_generic_keccak_new_1e_f4:
 1068|    935|libcrux_sha3_generic_keccak_new_1e_f4(void) {
 1069|    935|  libcrux_sha3_generic_keccak_KeccakState_48 lit;
 1070|    935|  lit.st[0U][0U] = libcrux_sha3_portable_keccak_zero_5a();
 1071|    935|  lit.st[0U][1U] = libcrux_sha3_portable_keccak_zero_5a();
 1072|    935|  lit.st[0U][2U] = libcrux_sha3_portable_keccak_zero_5a();
 1073|    935|  lit.st[0U][3U] = libcrux_sha3_portable_keccak_zero_5a();
 1074|    935|  lit.st[0U][4U] = libcrux_sha3_portable_keccak_zero_5a();
 1075|    935|  lit.st[1U][0U] = libcrux_sha3_portable_keccak_zero_5a();
 1076|    935|  lit.st[1U][1U] = libcrux_sha3_portable_keccak_zero_5a();
 1077|    935|  lit.st[1U][2U] = libcrux_sha3_portable_keccak_zero_5a();
 1078|    935|  lit.st[1U][3U] = libcrux_sha3_portable_keccak_zero_5a();
 1079|    935|  lit.st[1U][4U] = libcrux_sha3_portable_keccak_zero_5a();
 1080|    935|  lit.st[2U][0U] = libcrux_sha3_portable_keccak_zero_5a();
 1081|    935|  lit.st[2U][1U] = libcrux_sha3_portable_keccak_zero_5a();
 1082|    935|  lit.st[2U][2U] = libcrux_sha3_portable_keccak_zero_5a();
 1083|    935|  lit.st[2U][3U] = libcrux_sha3_portable_keccak_zero_5a();
 1084|    935|  lit.st[2U][4U] = libcrux_sha3_portable_keccak_zero_5a();
 1085|    935|  lit.st[3U][0U] = libcrux_sha3_portable_keccak_zero_5a();
 1086|    935|  lit.st[3U][1U] = libcrux_sha3_portable_keccak_zero_5a();
 1087|    935|  lit.st[3U][2U] = libcrux_sha3_portable_keccak_zero_5a();
 1088|    935|  lit.st[3U][3U] = libcrux_sha3_portable_keccak_zero_5a();
 1089|    935|  lit.st[3U][4U] = libcrux_sha3_portable_keccak_zero_5a();
 1090|    935|  lit.st[4U][0U] = libcrux_sha3_portable_keccak_zero_5a();
 1091|    935|  lit.st[4U][1U] = libcrux_sha3_portable_keccak_zero_5a();
 1092|    935|  lit.st[4U][2U] = libcrux_sha3_portable_keccak_zero_5a();
 1093|    935|  lit.st[4U][3U] = libcrux_sha3_portable_keccak_zero_5a();
 1094|    935|  lit.st[4U][4U] = libcrux_sha3_portable_keccak_zero_5a();
 1095|    935|  return lit;
 1096|    935|}
mlkem768.c:libcrux_sha3_portable_keccak_zero_5a:
  918|  23.3k|static KRML_MUSTINLINE uint64_t libcrux_sha3_portable_keccak_zero_5a(void) {
  919|  23.3k|  return 0ULL;
  920|  23.3k|}
mlkem768.c:libcrux_sha3_portable_keccak_slice_n_5a:
 1012|    880|    Eurydice_slice a[1U], size_t start, size_t len, Eurydice_slice ret[1U]) {
 1013|       |  /* Passing arrays by value in Rust generates a copy in C */
 1014|    880|  Eurydice_slice copy_of_a[1U];
 1015|    880|  memcpy(copy_of_a, a, (size_t)1U * sizeof(Eurydice_slice));
 1016|    880|  Eurydice_slice ret0[1U];
 1017|    880|  libcrux_sha3_portable_keccak_slice_1(copy_of_a, start, len, ret0);
 1018|    880|  memcpy(ret, ret0, (size_t)1U * sizeof(Eurydice_slice));
 1019|    880|}
mlkem768.c:libcrux_sha3_portable_keccak_slice_1:
 1003|    880|    Eurydice_slice a[1U], size_t start, size_t len, Eurydice_slice ret[1U]) {
 1004|    880|  ret[0U] = Eurydice_slice_subslice2(a[0U], start, start + len, uint8_t);
  ------------------
  |  |  101|    880|  EURYDICE_SLICE((t *)s.ptr, start, end)
  |  |  ------------------
  |  |  |  |   88|    880|  (CLITERAL(Eurydice_slice){.ptr = (void *)(x + start), .len = end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |   61|    880|#define CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1005|    880|}
mlkem768.c:libcrux_sha3_portable_keccak_load_block_2c:
 1104|     55|    uint64_t (*s)[5U], Eurydice_slice blocks[1U]) {
 1105|    550|  for (size_t i = (size_t)0U; i < (size_t)72U / (size_t)8U; i++) {
  ------------------
  |  Branch (1105:31): [True: 495, False: 55]
  ------------------
 1106|    495|    size_t i0 = i;
 1107|    495|    uint8_t uu____0[8U];
 1108|    495|    Result_56 dst;
 1109|    495|    Eurydice_slice_to_array2(
  ------------------
  |  |  152|    495|  Eurydice_slice_to_array3(&(dst)->tag, (char *)&(dst)->val.case_Ok, src, \
  |  |  153|    495|                           sizeof(t_arr))
  ------------------
 1110|    495|        &dst,
 1111|    495|        Eurydice_slice_subslice2(blocks[0U], (size_t)8U * i0,
 1112|    495|                                 (size_t)8U * i0 + (size_t)8U, uint8_t),
 1113|    495|        Eurydice_slice, uint8_t[8U]);
 1114|    495|    unwrap_41_ac(dst, uu____0);
 1115|    495|    size_t uu____1 = i0 / (size_t)5U;
 1116|    495|    size_t uu____2 = i0 % (size_t)5U;
 1117|    495|    s[uu____1][uu____2] =
 1118|    495|        s[uu____1][uu____2] ^ core_num__u64_9__from_le_bytes(uu____0);
 1119|    495|  }
 1120|     55|}
mlkem768.c:unwrap_41_ac:
  727|  24.9k|static inline void unwrap_41_ac(Result_56 self, uint8_t ret[8U]) {
  728|  24.9k|  if (self.tag == Ok) {
  ------------------
  |  |  246|  24.9k|#define Ok 0
  ------------------
  |  Branch (728:7): [True: 24.9k, False: 0]
  ------------------
  729|  24.9k|    uint8_t f0[8U];
  730|  24.9k|    memcpy(f0, self.val.case_Ok, (size_t)8U * sizeof(uint8_t));
  731|  24.9k|    memcpy(ret, f0, (size_t)8U * sizeof(uint8_t));
  732|  24.9k|  } else {
  733|      0|    KRML_HOST_EPRINTF("KaRaMeL abort at %s:%d\n%s\n", __FILE__, __LINE__,
  734|      0|                      "unwrap not Ok");
  735|      0|    KRML_HOST_EXIT(255U);
  ------------------
  |  |   35|      0|#define KRML_HOST_EXIT(x) dropbear_exit("mlkem")
  ------------------
  736|      0|  }
  737|  24.9k|}
mlkem768.c:core_num__u64_9__from_le_bytes:
  167|  24.9k|static inline uint64_t core_num__u64_9__from_le_bytes(uint8_t buf[8]) {
  168|  24.9k|  uint64_t v;
  169|  24.9k|  memcpy(&v, buf, sizeof(v));
  170|       |  return le64toh(v);
  171|  24.9k|}
mlkem768.c:libcrux_sha3_generic_keccak_keccakf1600_21:
 2209|  2.48k|    libcrux_sha3_generic_keccak_KeccakState_48 *s) {
 2210|  62.0k|  for (size_t i = (size_t)0U; i < (size_t)24U; i++) {
  ------------------
  |  Branch (2210:31): [True: 59.5k, False: 2.48k]
  ------------------
 2211|  59.5k|    size_t i0 = i;
 2212|  59.5k|    libcrux_sha3_generic_keccak_theta_rho_16(s);
 2213|  59.5k|    libcrux_sha3_generic_keccak_pi_1d(s);
 2214|  59.5k|    libcrux_sha3_generic_keccak_chi_12(s);
 2215|  59.5k|    libcrux_sha3_generic_keccak_iota_62(s, i0);
 2216|  59.5k|  }
 2217|  2.48k|}
mlkem768.c:libcrux_sha3_generic_keccak_theta_rho_16:
 2048|  59.5k|    libcrux_sha3_generic_keccak_KeccakState_48 *s) {
 2049|  59.5k|  uint64_t c[5U] = {
 2050|  59.5k|      libcrux_sha3_portable_keccak_xor5_5a(s->st[0U][0U], s->st[1U][0U],
 2051|  59.5k|                                           s->st[2U][0U], s->st[3U][0U],
 2052|  59.5k|                                           s->st[4U][0U]),
 2053|  59.5k|      libcrux_sha3_portable_keccak_xor5_5a(s->st[0U][1U], s->st[1U][1U],
 2054|  59.5k|                                           s->st[2U][1U], s->st[3U][1U],
 2055|  59.5k|                                           s->st[4U][1U]),
 2056|  59.5k|      libcrux_sha3_portable_keccak_xor5_5a(s->st[0U][2U], s->st[1U][2U],
 2057|  59.5k|                                           s->st[2U][2U], s->st[3U][2U],
 2058|  59.5k|                                           s->st[4U][2U]),
 2059|  59.5k|      libcrux_sha3_portable_keccak_xor5_5a(s->st[0U][3U], s->st[1U][3U],
 2060|  59.5k|                                           s->st[2U][3U], s->st[3U][3U],
 2061|  59.5k|                                           s->st[4U][3U]),
 2062|  59.5k|      libcrux_sha3_portable_keccak_xor5_5a(s->st[0U][4U], s->st[1U][4U],
 2063|  59.5k|                                           s->st[2U][4U], s->st[3U][4U],
 2064|  59.5k|                                           s->st[4U][4U])};
 2065|  59.5k|  uint64_t uu____0 = libcrux_sha3_portable_keccak_rotate_left1_and_xor_5a(
 2066|  59.5k|      c[((size_t)0U + (size_t)4U) % (size_t)5U],
 2067|  59.5k|      c[((size_t)0U + (size_t)1U) % (size_t)5U]);
 2068|  59.5k|  uint64_t uu____1 = libcrux_sha3_portable_keccak_rotate_left1_and_xor_5a(
 2069|  59.5k|      c[((size_t)1U + (size_t)4U) % (size_t)5U],
 2070|  59.5k|      c[((size_t)1U + (size_t)1U) % (size_t)5U]);
 2071|  59.5k|  uint64_t uu____2 = libcrux_sha3_portable_keccak_rotate_left1_and_xor_5a(
 2072|  59.5k|      c[((size_t)2U + (size_t)4U) % (size_t)5U],
 2073|  59.5k|      c[((size_t)2U + (size_t)1U) % (size_t)5U]);
 2074|  59.5k|  uint64_t uu____3 = libcrux_sha3_portable_keccak_rotate_left1_and_xor_5a(
 2075|  59.5k|      c[((size_t)3U + (size_t)4U) % (size_t)5U],
 2076|  59.5k|      c[((size_t)3U + (size_t)1U) % (size_t)5U]);
 2077|  59.5k|  uint64_t t[5U] = {uu____0, uu____1, uu____2, uu____3,
 2078|  59.5k|                    libcrux_sha3_portable_keccak_rotate_left1_and_xor_5a(
 2079|  59.5k|                        c[((size_t)4U + (size_t)4U) % (size_t)5U],
 2080|  59.5k|                        c[((size_t)4U + (size_t)1U) % (size_t)5U])};
 2081|  59.5k|  s->st[0U][0U] = libcrux_sha3_portable_keccak_xor_5a(s->st[0U][0U], t[0U]);
 2082|  59.5k|  s->st[1U][0U] =
 2083|  59.5k|      libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb(s->st[1U][0U], t[0U]);
 2084|  59.5k|  s->st[2U][0U] =
 2085|  59.5k|      libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb0(s->st[2U][0U], t[0U]);
 2086|  59.5k|  s->st[3U][0U] =
 2087|  59.5k|      libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb1(s->st[3U][0U], t[0U]);
 2088|  59.5k|  s->st[4U][0U] =
 2089|  59.5k|      libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb2(s->st[4U][0U], t[0U]);
 2090|  59.5k|  s->st[0U][1U] =
 2091|  59.5k|      libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb3(s->st[0U][1U], t[1U]);
 2092|  59.5k|  s->st[1U][1U] =
 2093|  59.5k|      libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb4(s->st[1U][1U], t[1U]);
 2094|  59.5k|  s->st[2U][1U] =
 2095|  59.5k|      libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb5(s->st[2U][1U], t[1U]);
 2096|  59.5k|  s->st[3U][1U] =
 2097|  59.5k|      libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb6(s->st[3U][1U], t[1U]);
 2098|  59.5k|  s->st[4U][1U] =
 2099|  59.5k|      libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb7(s->st[4U][1U], t[1U]);
 2100|  59.5k|  s->st[0U][2U] =
 2101|  59.5k|      libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb8(s->st[0U][2U], t[2U]);
 2102|  59.5k|  s->st[1U][2U] =
 2103|  59.5k|      libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb9(s->st[1U][2U], t[2U]);
 2104|  59.5k|  s->st[2U][2U] =
 2105|  59.5k|      libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb10(s->st[2U][2U], t[2U]);
 2106|  59.5k|  s->st[3U][2U] =
 2107|  59.5k|      libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb11(s->st[3U][2U], t[2U]);
 2108|  59.5k|  s->st[4U][2U] =
 2109|  59.5k|      libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb12(s->st[4U][2U], t[2U]);
 2110|  59.5k|  s->st[0U][3U] =
 2111|  59.5k|      libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb13(s->st[0U][3U], t[3U]);
 2112|  59.5k|  s->st[1U][3U] =
 2113|  59.5k|      libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb14(s->st[1U][3U], t[3U]);
 2114|  59.5k|  s->st[2U][3U] =
 2115|  59.5k|      libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb15(s->st[2U][3U], t[3U]);
 2116|  59.5k|  s->st[3U][3U] =
 2117|  59.5k|      libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb16(s->st[3U][3U], t[3U]);
 2118|  59.5k|  s->st[4U][3U] =
 2119|  59.5k|      libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb17(s->st[4U][3U], t[3U]);
 2120|  59.5k|  s->st[0U][4U] =
 2121|  59.5k|      libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb18(s->st[0U][4U], t[4U]);
 2122|  59.5k|  s->st[1U][4U] =
 2123|  59.5k|      libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb19(s->st[1U][4U], t[4U]);
 2124|  59.5k|  s->st[2U][4U] =
 2125|  59.5k|      libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb20(s->st[2U][4U], t[4U]);
 2126|  59.5k|  s->st[3U][4U] =
 2127|  59.5k|      libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb21(s->st[3U][4U], t[4U]);
 2128|  59.5k|  uint64_t uu____27 =
 2129|  59.5k|      libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb22(s->st[4U][4U], t[4U]);
 2130|  59.5k|  s->st[4U][4U] = uu____27;
 2131|  59.5k|}
mlkem768.c:libcrux_sha3_portable_keccak_xor5_5a:
  935|   297k|    uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e) {
  936|   297k|  return libcrux_sha3_portable_keccak__veor5q_u64(a, b, c, d, e);
  937|   297k|}
mlkem768.c:libcrux_sha3_portable_keccak__veor5q_u64:
  923|   297k|    uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e) {
  924|   297k|  uint64_t ab = a ^ b;
  925|   297k|  uint64_t cd = c ^ d;
  926|   297k|  uint64_t abcd = ab ^ cd;
  927|   297k|  return abcd ^ e;
  928|   297k|}
mlkem768.c:libcrux_sha3_portable_keccak_rotate_left1_and_xor_5a:
  961|   297k|libcrux_sha3_portable_keccak_rotate_left1_and_xor_5a(uint64_t a, uint64_t b) {
  962|   297k|  return libcrux_sha3_portable_keccak__vrax1q_u64(a, b);
  963|   297k|}
mlkem768.c:libcrux_sha3_portable_keccak__vrax1q_u64:
  951|   297k|libcrux_sha3_portable_keccak__vrax1q_u64(uint64_t a, uint64_t b) {
  952|   297k|  uint64_t uu____0 = a;
  953|   297k|  return uu____0 ^ libcrux_sha3_portable_keccak_rotate_left_cb(b);
  954|   297k|}
mlkem768.c:libcrux_sha3_portable_keccak_rotate_left_cb:
  946|   357k|libcrux_sha3_portable_keccak_rotate_left_cb(uint64_t x) {
  947|   357k|  return x << (uint32_t)(int32_t)1 | x >> (uint32_t)(int32_t)63;
  948|   357k|}
mlkem768.c:libcrux_sha3_portable_keccak_xor_5a:
  998|  59.5k|libcrux_sha3_portable_keccak_xor_5a(uint64_t a, uint64_t b) {
  999|  59.5k|  return a ^ b;
 1000|  59.5k|}
mlkem768.c:libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb:
 1174|  59.5k|libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb(uint64_t a, uint64_t b) {
 1175|  59.5k|  return libcrux_sha3_portable_keccak__vxarq_u64_42(a, b);
 1176|  59.5k|}
mlkem768.c:libcrux_sha3_portable_keccak__vxarq_u64_42:
 1158|  59.5k|libcrux_sha3_portable_keccak__vxarq_u64_42(uint64_t a, uint64_t b) {
 1159|  59.5k|  uint64_t ab = a ^ b;
 1160|  59.5k|  return libcrux_sha3_portable_keccak_rotate_left_cb0(ab);
 1161|  59.5k|}
mlkem768.c:libcrux_sha3_portable_keccak_rotate_left_cb0:
 1147|  59.5k|libcrux_sha3_portable_keccak_rotate_left_cb0(uint64_t x) {
 1148|  59.5k|  return x << (uint32_t)(int32_t)36 | x >> (uint32_t)(int32_t)28;
 1149|  59.5k|}
mlkem768.c:libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb0:
 1212|  59.5k|libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb0(uint64_t a, uint64_t b) {
 1213|  59.5k|  return libcrux_sha3_portable_keccak__vxarq_u64_420(a, b);
 1214|  59.5k|}
mlkem768.c:libcrux_sha3_portable_keccak__vxarq_u64_420:
 1196|  59.5k|libcrux_sha3_portable_keccak__vxarq_u64_420(uint64_t a, uint64_t b) {
 1197|  59.5k|  uint64_t ab = a ^ b;
 1198|  59.5k|  return libcrux_sha3_portable_keccak_rotate_left_cb1(ab);
 1199|  59.5k|}
mlkem768.c:libcrux_sha3_portable_keccak_rotate_left_cb1:
 1185|  59.5k|libcrux_sha3_portable_keccak_rotate_left_cb1(uint64_t x) {
 1186|  59.5k|  return x << (uint32_t)(int32_t)3 | x >> (uint32_t)(int32_t)61;
 1187|  59.5k|}
mlkem768.c:libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb1:
 1250|  59.5k|libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb1(uint64_t a, uint64_t b) {
 1251|  59.5k|  return libcrux_sha3_portable_keccak__vxarq_u64_421(a, b);
 1252|  59.5k|}
mlkem768.c:libcrux_sha3_portable_keccak__vxarq_u64_421:
 1234|  59.5k|libcrux_sha3_portable_keccak__vxarq_u64_421(uint64_t a, uint64_t b) {
 1235|  59.5k|  uint64_t ab = a ^ b;
 1236|  59.5k|  return libcrux_sha3_portable_keccak_rotate_left_cb2(ab);
 1237|  59.5k|}
mlkem768.c:libcrux_sha3_portable_keccak_rotate_left_cb2:
 1223|  59.5k|libcrux_sha3_portable_keccak_rotate_left_cb2(uint64_t x) {
 1224|  59.5k|  return x << (uint32_t)(int32_t)41 | x >> (uint32_t)(int32_t)23;
 1225|  59.5k|}
mlkem768.c:libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb2:
 1288|  59.5k|libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb2(uint64_t a, uint64_t b) {
 1289|  59.5k|  return libcrux_sha3_portable_keccak__vxarq_u64_422(a, b);
 1290|  59.5k|}
mlkem768.c:libcrux_sha3_portable_keccak__vxarq_u64_422:
 1272|  59.5k|libcrux_sha3_portable_keccak__vxarq_u64_422(uint64_t a, uint64_t b) {
 1273|  59.5k|  uint64_t ab = a ^ b;
 1274|  59.5k|  return libcrux_sha3_portable_keccak_rotate_left_cb3(ab);
 1275|  59.5k|}
mlkem768.c:libcrux_sha3_portable_keccak_rotate_left_cb3:
 1261|  59.5k|libcrux_sha3_portable_keccak_rotate_left_cb3(uint64_t x) {
 1262|  59.5k|  return x << (uint32_t)(int32_t)18 | x >> (uint32_t)(int32_t)46;
 1263|  59.5k|}
mlkem768.c:libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb3:
 1315|  59.5k|libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb3(uint64_t a, uint64_t b) {
 1316|  59.5k|  return libcrux_sha3_portable_keccak__vxarq_u64_423(a, b);
 1317|  59.5k|}
mlkem768.c:libcrux_sha3_portable_keccak__vxarq_u64_423:
 1299|  59.5k|libcrux_sha3_portable_keccak__vxarq_u64_423(uint64_t a, uint64_t b) {
 1300|  59.5k|  uint64_t ab = a ^ b;
 1301|  59.5k|  return libcrux_sha3_portable_keccak_rotate_left_cb(ab);
 1302|  59.5k|}
mlkem768.c:libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb4:
 1353|  59.5k|libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb4(uint64_t a, uint64_t b) {
 1354|  59.5k|  return libcrux_sha3_portable_keccak__vxarq_u64_424(a, b);
 1355|  59.5k|}
mlkem768.c:libcrux_sha3_portable_keccak__vxarq_u64_424:
 1337|  59.5k|libcrux_sha3_portable_keccak__vxarq_u64_424(uint64_t a, uint64_t b) {
 1338|  59.5k|  uint64_t ab = a ^ b;
 1339|  59.5k|  return libcrux_sha3_portable_keccak_rotate_left_cb4(ab);
 1340|  59.5k|}
mlkem768.c:libcrux_sha3_portable_keccak_rotate_left_cb4:
 1326|  59.5k|libcrux_sha3_portable_keccak_rotate_left_cb4(uint64_t x) {
 1327|  59.5k|  return x << (uint32_t)(int32_t)44 | x >> (uint32_t)(int32_t)20;
 1328|  59.5k|}
mlkem768.c:libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb5:
 1391|  59.5k|libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb5(uint64_t a, uint64_t b) {
 1392|  59.5k|  return libcrux_sha3_portable_keccak__vxarq_u64_425(a, b);
 1393|  59.5k|}
mlkem768.c:libcrux_sha3_portable_keccak__vxarq_u64_425:
 1375|  59.5k|libcrux_sha3_portable_keccak__vxarq_u64_425(uint64_t a, uint64_t b) {
 1376|  59.5k|  uint64_t ab = a ^ b;
 1377|  59.5k|  return libcrux_sha3_portable_keccak_rotate_left_cb5(ab);
 1378|  59.5k|}
mlkem768.c:libcrux_sha3_portable_keccak_rotate_left_cb5:
 1364|  59.5k|libcrux_sha3_portable_keccak_rotate_left_cb5(uint64_t x) {
 1365|  59.5k|  return x << (uint32_t)(int32_t)10 | x >> (uint32_t)(int32_t)54;
 1366|  59.5k|}
mlkem768.c:libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb6:
 1429|  59.5k|libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb6(uint64_t a, uint64_t b) {
 1430|  59.5k|  return libcrux_sha3_portable_keccak__vxarq_u64_426(a, b);
 1431|  59.5k|}
mlkem768.c:libcrux_sha3_portable_keccak__vxarq_u64_426:
 1413|  59.5k|libcrux_sha3_portable_keccak__vxarq_u64_426(uint64_t a, uint64_t b) {
 1414|  59.5k|  uint64_t ab = a ^ b;
 1415|  59.5k|  return libcrux_sha3_portable_keccak_rotate_left_cb6(ab);
 1416|  59.5k|}
mlkem768.c:libcrux_sha3_portable_keccak_rotate_left_cb6:
 1402|  59.5k|libcrux_sha3_portable_keccak_rotate_left_cb6(uint64_t x) {
 1403|  59.5k|  return x << (uint32_t)(int32_t)45 | x >> (uint32_t)(int32_t)19;
 1404|  59.5k|}
mlkem768.c:libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb7:
 1467|  59.5k|libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb7(uint64_t a, uint64_t b) {
 1468|  59.5k|  return libcrux_sha3_portable_keccak__vxarq_u64_427(a, b);
 1469|  59.5k|}
mlkem768.c:libcrux_sha3_portable_keccak__vxarq_u64_427:
 1451|  59.5k|libcrux_sha3_portable_keccak__vxarq_u64_427(uint64_t a, uint64_t b) {
 1452|  59.5k|  uint64_t ab = a ^ b;
 1453|  59.5k|  return libcrux_sha3_portable_keccak_rotate_left_cb7(ab);
 1454|  59.5k|}
mlkem768.c:libcrux_sha3_portable_keccak_rotate_left_cb7:
 1440|  59.5k|libcrux_sha3_portable_keccak_rotate_left_cb7(uint64_t x) {
 1441|  59.5k|  return x << (uint32_t)(int32_t)2 | x >> (uint32_t)(int32_t)62;
 1442|  59.5k|}
mlkem768.c:libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb8:
 1505|  59.5k|libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb8(uint64_t a, uint64_t b) {
 1506|  59.5k|  return libcrux_sha3_portable_keccak__vxarq_u64_428(a, b);
 1507|  59.5k|}
mlkem768.c:libcrux_sha3_portable_keccak__vxarq_u64_428:
 1489|  59.5k|libcrux_sha3_portable_keccak__vxarq_u64_428(uint64_t a, uint64_t b) {
 1490|  59.5k|  uint64_t ab = a ^ b;
 1491|  59.5k|  return libcrux_sha3_portable_keccak_rotate_left_cb8(ab);
 1492|  59.5k|}
mlkem768.c:libcrux_sha3_portable_keccak_rotate_left_cb8:
 1478|  59.5k|libcrux_sha3_portable_keccak_rotate_left_cb8(uint64_t x) {
 1479|  59.5k|  return x << (uint32_t)(int32_t)62 | x >> (uint32_t)(int32_t)2;
 1480|  59.5k|}
mlkem768.c:libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb9:
 1543|  59.5k|libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb9(uint64_t a, uint64_t b) {
 1544|  59.5k|  return libcrux_sha3_portable_keccak__vxarq_u64_429(a, b);
 1545|  59.5k|}
mlkem768.c:libcrux_sha3_portable_keccak__vxarq_u64_429:
 1527|  59.5k|libcrux_sha3_portable_keccak__vxarq_u64_429(uint64_t a, uint64_t b) {
 1528|  59.5k|  uint64_t ab = a ^ b;
 1529|  59.5k|  return libcrux_sha3_portable_keccak_rotate_left_cb9(ab);
 1530|  59.5k|}
mlkem768.c:libcrux_sha3_portable_keccak_rotate_left_cb9:
 1516|  59.5k|libcrux_sha3_portable_keccak_rotate_left_cb9(uint64_t x) {
 1517|  59.5k|  return x << (uint32_t)(int32_t)6 | x >> (uint32_t)(int32_t)58;
 1518|  59.5k|}
mlkem768.c:libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb10:
 1581|  59.5k|libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb10(uint64_t a, uint64_t b) {
 1582|  59.5k|  return libcrux_sha3_portable_keccak__vxarq_u64_4210(a, b);
 1583|  59.5k|}
mlkem768.c:libcrux_sha3_portable_keccak__vxarq_u64_4210:
 1565|  59.5k|libcrux_sha3_portable_keccak__vxarq_u64_4210(uint64_t a, uint64_t b) {
 1566|  59.5k|  uint64_t ab = a ^ b;
 1567|  59.5k|  return libcrux_sha3_portable_keccak_rotate_left_cb10(ab);
 1568|  59.5k|}
mlkem768.c:libcrux_sha3_portable_keccak_rotate_left_cb10:
 1554|  59.5k|libcrux_sha3_portable_keccak_rotate_left_cb10(uint64_t x) {
 1555|  59.5k|  return x << (uint32_t)(int32_t)43 | x >> (uint32_t)(int32_t)21;
 1556|  59.5k|}
mlkem768.c:libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb11:
 1619|  59.5k|libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb11(uint64_t a, uint64_t b) {
 1620|  59.5k|  return libcrux_sha3_portable_keccak__vxarq_u64_4211(a, b);
 1621|  59.5k|}
mlkem768.c:libcrux_sha3_portable_keccak__vxarq_u64_4211:
 1603|  59.5k|libcrux_sha3_portable_keccak__vxarq_u64_4211(uint64_t a, uint64_t b) {
 1604|  59.5k|  uint64_t ab = a ^ b;
 1605|  59.5k|  return libcrux_sha3_portable_keccak_rotate_left_cb11(ab);
 1606|  59.5k|}
mlkem768.c:libcrux_sha3_portable_keccak_rotate_left_cb11:
 1592|  59.5k|libcrux_sha3_portable_keccak_rotate_left_cb11(uint64_t x) {
 1593|  59.5k|  return x << (uint32_t)(int32_t)15 | x >> (uint32_t)(int32_t)49;
 1594|  59.5k|}
mlkem768.c:libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb12:
 1657|  59.5k|libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb12(uint64_t a, uint64_t b) {
 1658|  59.5k|  return libcrux_sha3_portable_keccak__vxarq_u64_4212(a, b);
 1659|  59.5k|}
mlkem768.c:libcrux_sha3_portable_keccak__vxarq_u64_4212:
 1641|  59.5k|libcrux_sha3_portable_keccak__vxarq_u64_4212(uint64_t a, uint64_t b) {
 1642|  59.5k|  uint64_t ab = a ^ b;
 1643|  59.5k|  return libcrux_sha3_portable_keccak_rotate_left_cb12(ab);
 1644|  59.5k|}
mlkem768.c:libcrux_sha3_portable_keccak_rotate_left_cb12:
 1630|  59.5k|libcrux_sha3_portable_keccak_rotate_left_cb12(uint64_t x) {
 1631|  59.5k|  return x << (uint32_t)(int32_t)61 | x >> (uint32_t)(int32_t)3;
 1632|  59.5k|}
mlkem768.c:libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb13:
 1695|  59.5k|libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb13(uint64_t a, uint64_t b) {
 1696|  59.5k|  return libcrux_sha3_portable_keccak__vxarq_u64_4213(a, b);
 1697|  59.5k|}
mlkem768.c:libcrux_sha3_portable_keccak__vxarq_u64_4213:
 1679|  59.5k|libcrux_sha3_portable_keccak__vxarq_u64_4213(uint64_t a, uint64_t b) {
 1680|  59.5k|  uint64_t ab = a ^ b;
 1681|  59.5k|  return libcrux_sha3_portable_keccak_rotate_left_cb13(ab);
 1682|  59.5k|}
mlkem768.c:libcrux_sha3_portable_keccak_rotate_left_cb13:
 1668|  59.5k|libcrux_sha3_portable_keccak_rotate_left_cb13(uint64_t x) {
 1669|  59.5k|  return x << (uint32_t)(int32_t)28 | x >> (uint32_t)(int32_t)36;
 1670|  59.5k|}
mlkem768.c:libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb14:
 1733|  59.5k|libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb14(uint64_t a, uint64_t b) {
 1734|  59.5k|  return libcrux_sha3_portable_keccak__vxarq_u64_4214(a, b);
 1735|  59.5k|}
mlkem768.c:libcrux_sha3_portable_keccak__vxarq_u64_4214:
 1717|  59.5k|libcrux_sha3_portable_keccak__vxarq_u64_4214(uint64_t a, uint64_t b) {
 1718|  59.5k|  uint64_t ab = a ^ b;
 1719|  59.5k|  return libcrux_sha3_portable_keccak_rotate_left_cb14(ab);
 1720|  59.5k|}
mlkem768.c:libcrux_sha3_portable_keccak_rotate_left_cb14:
 1706|  59.5k|libcrux_sha3_portable_keccak_rotate_left_cb14(uint64_t x) {
 1707|  59.5k|  return x << (uint32_t)(int32_t)55 | x >> (uint32_t)(int32_t)9;
 1708|  59.5k|}
mlkem768.c:libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb15:
 1771|  59.5k|libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb15(uint64_t a, uint64_t b) {
 1772|  59.5k|  return libcrux_sha3_portable_keccak__vxarq_u64_4215(a, b);
 1773|  59.5k|}
mlkem768.c:libcrux_sha3_portable_keccak__vxarq_u64_4215:
 1755|  59.5k|libcrux_sha3_portable_keccak__vxarq_u64_4215(uint64_t a, uint64_t b) {
 1756|  59.5k|  uint64_t ab = a ^ b;
 1757|  59.5k|  return libcrux_sha3_portable_keccak_rotate_left_cb15(ab);
 1758|  59.5k|}
mlkem768.c:libcrux_sha3_portable_keccak_rotate_left_cb15:
 1744|  59.5k|libcrux_sha3_portable_keccak_rotate_left_cb15(uint64_t x) {
 1745|  59.5k|  return x << (uint32_t)(int32_t)25 | x >> (uint32_t)(int32_t)39;
 1746|  59.5k|}
mlkem768.c:libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb16:
 1809|  59.5k|libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb16(uint64_t a, uint64_t b) {
 1810|  59.5k|  return libcrux_sha3_portable_keccak__vxarq_u64_4216(a, b);
 1811|  59.5k|}
mlkem768.c:libcrux_sha3_portable_keccak__vxarq_u64_4216:
 1793|  59.5k|libcrux_sha3_portable_keccak__vxarq_u64_4216(uint64_t a, uint64_t b) {
 1794|  59.5k|  uint64_t ab = a ^ b;
 1795|  59.5k|  return libcrux_sha3_portable_keccak_rotate_left_cb16(ab);
 1796|  59.5k|}
mlkem768.c:libcrux_sha3_portable_keccak_rotate_left_cb16:
 1782|  59.5k|libcrux_sha3_portable_keccak_rotate_left_cb16(uint64_t x) {
 1783|  59.5k|  return x << (uint32_t)(int32_t)21 | x >> (uint32_t)(int32_t)43;
 1784|  59.5k|}
mlkem768.c:libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb17:
 1847|  59.5k|libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb17(uint64_t a, uint64_t b) {
 1848|  59.5k|  return libcrux_sha3_portable_keccak__vxarq_u64_4217(a, b);
 1849|  59.5k|}
mlkem768.c:libcrux_sha3_portable_keccak__vxarq_u64_4217:
 1831|  59.5k|libcrux_sha3_portable_keccak__vxarq_u64_4217(uint64_t a, uint64_t b) {
 1832|  59.5k|  uint64_t ab = a ^ b;
 1833|  59.5k|  return libcrux_sha3_portable_keccak_rotate_left_cb17(ab);
 1834|  59.5k|}
mlkem768.c:libcrux_sha3_portable_keccak_rotate_left_cb17:
 1820|  59.5k|libcrux_sha3_portable_keccak_rotate_left_cb17(uint64_t x) {
 1821|  59.5k|  return x << (uint32_t)(int32_t)56 | x >> (uint32_t)(int32_t)8;
 1822|  59.5k|}
mlkem768.c:libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb18:
 1885|  59.5k|libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb18(uint64_t a, uint64_t b) {
 1886|  59.5k|  return libcrux_sha3_portable_keccak__vxarq_u64_4218(a, b);
 1887|  59.5k|}
mlkem768.c:libcrux_sha3_portable_keccak__vxarq_u64_4218:
 1869|  59.5k|libcrux_sha3_portable_keccak__vxarq_u64_4218(uint64_t a, uint64_t b) {
 1870|  59.5k|  uint64_t ab = a ^ b;
 1871|  59.5k|  return libcrux_sha3_portable_keccak_rotate_left_cb18(ab);
 1872|  59.5k|}
mlkem768.c:libcrux_sha3_portable_keccak_rotate_left_cb18:
 1858|  59.5k|libcrux_sha3_portable_keccak_rotate_left_cb18(uint64_t x) {
 1859|  59.5k|  return x << (uint32_t)(int32_t)27 | x >> (uint32_t)(int32_t)37;
 1860|  59.5k|}
mlkem768.c:libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb19:
 1923|  59.5k|libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb19(uint64_t a, uint64_t b) {
 1924|  59.5k|  return libcrux_sha3_portable_keccak__vxarq_u64_4219(a, b);
 1925|  59.5k|}
mlkem768.c:libcrux_sha3_portable_keccak__vxarq_u64_4219:
 1907|  59.5k|libcrux_sha3_portable_keccak__vxarq_u64_4219(uint64_t a, uint64_t b) {
 1908|  59.5k|  uint64_t ab = a ^ b;
 1909|  59.5k|  return libcrux_sha3_portable_keccak_rotate_left_cb19(ab);
 1910|  59.5k|}
mlkem768.c:libcrux_sha3_portable_keccak_rotate_left_cb19:
 1896|  59.5k|libcrux_sha3_portable_keccak_rotate_left_cb19(uint64_t x) {
 1897|  59.5k|  return x << (uint32_t)(int32_t)20 | x >> (uint32_t)(int32_t)44;
 1898|  59.5k|}
mlkem768.c:libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb20:
 1961|  59.5k|libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb20(uint64_t a, uint64_t b) {
 1962|  59.5k|  return libcrux_sha3_portable_keccak__vxarq_u64_4220(a, b);
 1963|  59.5k|}
mlkem768.c:libcrux_sha3_portable_keccak__vxarq_u64_4220:
 1945|  59.5k|libcrux_sha3_portable_keccak__vxarq_u64_4220(uint64_t a, uint64_t b) {
 1946|  59.5k|  uint64_t ab = a ^ b;
 1947|  59.5k|  return libcrux_sha3_portable_keccak_rotate_left_cb20(ab);
 1948|  59.5k|}
mlkem768.c:libcrux_sha3_portable_keccak_rotate_left_cb20:
 1934|  59.5k|libcrux_sha3_portable_keccak_rotate_left_cb20(uint64_t x) {
 1935|  59.5k|  return x << (uint32_t)(int32_t)39 | x >> (uint32_t)(int32_t)25;
 1936|  59.5k|}
mlkem768.c:libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb21:
 1999|  59.5k|libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb21(uint64_t a, uint64_t b) {
 2000|  59.5k|  return libcrux_sha3_portable_keccak__vxarq_u64_4221(a, b);
 2001|  59.5k|}
mlkem768.c:libcrux_sha3_portable_keccak__vxarq_u64_4221:
 1983|  59.5k|libcrux_sha3_portable_keccak__vxarq_u64_4221(uint64_t a, uint64_t b) {
 1984|  59.5k|  uint64_t ab = a ^ b;
 1985|  59.5k|  return libcrux_sha3_portable_keccak_rotate_left_cb21(ab);
 1986|  59.5k|}
mlkem768.c:libcrux_sha3_portable_keccak_rotate_left_cb21:
 1972|  59.5k|libcrux_sha3_portable_keccak_rotate_left_cb21(uint64_t x) {
 1973|  59.5k|  return x << (uint32_t)(int32_t)8 | x >> (uint32_t)(int32_t)56;
 1974|  59.5k|}
mlkem768.c:libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb22:
 2037|  59.5k|libcrux_sha3_portable_keccak_xor_and_rotate_5a_bb22(uint64_t a, uint64_t b) {
 2038|  59.5k|  return libcrux_sha3_portable_keccak__vxarq_u64_4222(a, b);
 2039|  59.5k|}
mlkem768.c:libcrux_sha3_portable_keccak__vxarq_u64_4222:
 2021|  59.5k|libcrux_sha3_portable_keccak__vxarq_u64_4222(uint64_t a, uint64_t b) {
 2022|  59.5k|  uint64_t ab = a ^ b;
 2023|  59.5k|  return libcrux_sha3_portable_keccak_rotate_left_cb22(ab);
 2024|  59.5k|}
mlkem768.c:libcrux_sha3_portable_keccak_rotate_left_cb22:
 2010|  59.5k|libcrux_sha3_portable_keccak_rotate_left_cb22(uint64_t x) {
 2011|  59.5k|  return x << (uint32_t)(int32_t)14 | x >> (uint32_t)(int32_t)50;
 2012|  59.5k|}
mlkem768.c:libcrux_sha3_generic_keccak_pi_1d:
 2140|  59.5k|    libcrux_sha3_generic_keccak_KeccakState_48 *s) {
 2141|  59.5k|  uint64_t old[5U][5U];
 2142|  59.5k|  memcpy(old, s->st, (size_t)5U * sizeof(uint64_t[5U]));
 2143|  59.5k|  s->st[0U][1U] = old[1U][1U];
 2144|  59.5k|  s->st[0U][2U] = old[2U][2U];
 2145|  59.5k|  s->st[0U][3U] = old[3U][3U];
 2146|  59.5k|  s->st[0U][4U] = old[4U][4U];
 2147|  59.5k|  s->st[1U][0U] = old[0U][3U];
 2148|  59.5k|  s->st[1U][1U] = old[1U][4U];
 2149|  59.5k|  s->st[1U][2U] = old[2U][0U];
 2150|  59.5k|  s->st[1U][3U] = old[3U][1U];
 2151|  59.5k|  s->st[1U][4U] = old[4U][2U];
 2152|  59.5k|  s->st[2U][0U] = old[0U][1U];
 2153|  59.5k|  s->st[2U][1U] = old[1U][2U];
 2154|  59.5k|  s->st[2U][2U] = old[2U][3U];
 2155|  59.5k|  s->st[2U][3U] = old[3U][4U];
 2156|  59.5k|  s->st[2U][4U] = old[4U][0U];
 2157|  59.5k|  s->st[3U][0U] = old[0U][4U];
 2158|  59.5k|  s->st[3U][1U] = old[1U][0U];
 2159|  59.5k|  s->st[3U][2U] = old[2U][1U];
 2160|  59.5k|  s->st[3U][3U] = old[3U][2U];
 2161|  59.5k|  s->st[3U][4U] = old[4U][3U];
 2162|  59.5k|  s->st[4U][0U] = old[0U][2U];
 2163|  59.5k|  s->st[4U][1U] = old[1U][3U];
 2164|  59.5k|  s->st[4U][2U] = old[2U][4U];
 2165|  59.5k|  s->st[4U][3U] = old[3U][0U];
 2166|  59.5k|  s->st[4U][4U] = old[4U][1U];
 2167|  59.5k|}
mlkem768.c:libcrux_sha3_generic_keccak_chi_12:
 2176|  59.5k|    libcrux_sha3_generic_keccak_KeccakState_48 *s) {
 2177|  59.5k|  uint64_t old[5U][5U];
 2178|  59.5k|  memcpy(old, s->st, (size_t)5U * sizeof(uint64_t[5U]));
 2179|   357k|  for (size_t i0 = (size_t)0U; i0 < (size_t)5U; i0++) {
  ------------------
  |  Branch (2179:32): [True: 297k, False: 59.5k]
  ------------------
 2180|   297k|    size_t i1 = i0;
 2181|  1.78M|    for (size_t i = (size_t)0U; i < (size_t)5U; i++) {
  ------------------
  |  Branch (2181:33): [True: 1.48M, False: 297k]
  ------------------
 2182|  1.48M|      size_t j = i;
 2183|  1.48M|      s->st[i1][j] = libcrux_sha3_portable_keccak_and_not_xor_5a(
 2184|  1.48M|          s->st[i1][j], old[i1][(j + (size_t)2U) % (size_t)5U],
 2185|  1.48M|          old[i1][(j + (size_t)1U) % (size_t)5U]);
 2186|  1.48M|    }
 2187|   297k|  }
 2188|  59.5k|}
mlkem768.c:libcrux_sha3_portable_keccak_and_not_xor_5a:
  975|  1.48M|    uint64_t a, uint64_t b, uint64_t c) {
  976|  1.48M|  return libcrux_sha3_portable_keccak__vbcaxq_u64(a, b, c);
  977|  1.48M|}
mlkem768.c:libcrux_sha3_portable_keccak__vbcaxq_u64:
  966|  1.48M|libcrux_sha3_portable_keccak__vbcaxq_u64(uint64_t a, uint64_t b, uint64_t c) {
  967|  1.48M|  return a ^ (b & ~c);
  968|  1.48M|}
mlkem768.c:libcrux_sha3_generic_keccak_iota_62:
 2197|  59.5k|    libcrux_sha3_generic_keccak_KeccakState_48 *s, size_t i) {
 2198|  59.5k|  s->st[0U][0U] = libcrux_sha3_portable_keccak_xor_constant_5a(
 2199|  59.5k|      s->st[0U][0U], libcrux_sha3_generic_keccak_ROUNDCONSTANTS[i]);
 2200|  59.5k|}
mlkem768.c:libcrux_sha3_portable_keccak_xor_constant_5a:
  989|  59.5k|libcrux_sha3_portable_keccak_xor_constant_5a(uint64_t a, uint64_t c) {
  990|  59.5k|  return libcrux_sha3_portable_keccak__veorq_n_u64(a, c);
  991|  59.5k|}
mlkem768.c:libcrux_sha3_portable_keccak__veorq_n_u64:
  980|  59.5k|libcrux_sha3_portable_keccak__veorq_n_u64(uint64_t a, uint64_t c) {
  981|  59.5k|  return a ^ c;
  982|  59.5k|}
mlkem768.c:libcrux_sha3_generic_keccak_absorb_final_c7:
 2274|     55|    libcrux_sha3_generic_keccak_KeccakState_48 *s, Eurydice_slice last[1U]) {
 2275|     55|  size_t last_len = Eurydice_slice_len(last[0U], uint8_t);
  ------------------
  |  |  118|     55|#define Eurydice_slice_len(s, t) EURYDICE_SLICE_LEN(s, t)
  |  |  ------------------
  |  |  |  |   89|     55|#define EURYDICE_SLICE_LEN(s, _) s.len
  |  |  ------------------
  ------------------
 2276|     55|  uint8_t blocks[1U][200U] = {{0U}};
 2277|    110|  for (size_t i = (size_t)0U; i < (size_t)1U; i++) {
  ------------------
  |  Branch (2277:31): [True: 55, False: 55]
  ------------------
 2278|     55|    size_t i0 = i;
 2279|     55|    if (last_len > (size_t)0U) {
  ------------------
  |  Branch (2279:9): [True: 55, False: 0]
  ------------------
 2280|     55|      Eurydice_slice uu____0 = Eurydice_array_to_subslice2(
  ------------------
  |  |  113|     55|  EURYDICE_SLICE((t *)x, start, end)
  |  |  ------------------
  |  |  |  |   88|     55|  (CLITERAL(Eurydice_slice){.ptr = (void *)(x + start), .len = end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |   61|     55|#define CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2281|     55|          blocks[i0], (size_t)0U, last_len, uint8_t);
 2282|     55|      Eurydice_slice_copy(uu____0, last[i0], uint8_t);
  ------------------
  |  |  120|     55|  memcpy(dst.ptr, src.ptr, dst.len * sizeof(t))
  ------------------
 2283|     55|    }
 2284|     55|    blocks[i0][last_len] = 6U;
 2285|     55|    size_t uu____1 = i0;
 2286|     55|    size_t uu____2 = (size_t)72U - (size_t)1U;
 2287|     55|    blocks[uu____1][uu____2] = (uint32_t)blocks[uu____1][uu____2] | 128U;
 2288|     55|  }
 2289|     55|  uint64_t(*uu____3)[5U] = s->st;
 2290|     55|  uint8_t uu____4[1U][200U];
 2291|     55|  memcpy(uu____4, blocks, (size_t)1U * sizeof(uint8_t[200U]));
 2292|     55|  libcrux_sha3_portable_keccak_load_block_full_5a_d2(uu____3, uu____4);
 2293|     55|  libcrux_sha3_generic_keccak_keccakf1600_21(s);
 2294|     55|}
mlkem768.c:libcrux_sha3_portable_keccak_load_block_full_5a_d2:
 2257|     55|    uint64_t (*a)[5U], uint8_t b[1U][200U]) {
 2258|     55|  uint64_t(*uu____0)[5U] = a;
 2259|       |  /* Passing arrays by value in Rust generates a copy in C */
 2260|     55|  uint8_t copy_of_b[1U][200U];
 2261|     55|  memcpy(copy_of_b, b, (size_t)1U * sizeof(uint8_t[200U]));
 2262|     55|  libcrux_sha3_portable_keccak_load_block_full_df(uu____0, copy_of_b);
 2263|     55|}
mlkem768.c:libcrux_sha3_portable_keccak_load_block_full_df:
 2241|     55|    uint64_t (*s)[5U], uint8_t blocks[1U][200U]) {
 2242|     55|  Eurydice_slice buf[1U] = {
 2243|     55|      Eurydice_array_to_slice((size_t)200U, blocks[0U], uint8_t)};
  ------------------
  |  |  107|     55|  EURYDICE_SLICE(x, 0,                     \
  |  |  ------------------
  |  |  |  |   88|     55|  (CLITERAL(Eurydice_slice){.ptr = (void *)(x + start), .len = end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |   61|     55|#define CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  108|     55|                 end) /* x is already at an array type, no need for cast */
  ------------------
 2244|     55|  libcrux_sha3_portable_keccak_load_block_2c(s, buf);
 2245|     55|}
mlkem768.c:libcrux_sha3_generic_keccak_squeeze_first_and_last_c5:
 2354|     55|    libcrux_sha3_generic_keccak_KeccakState_48 *s, Eurydice_slice out[1U]) {
 2355|     55|  uint8_t b[1U][200U];
 2356|     55|  libcrux_sha3_portable_keccak_store_block_full_5a_29(s->st, b);
 2357|    110|  for (size_t i = (size_t)0U; i < (size_t)1U; i++) {
  ------------------
  |  Branch (2357:31): [True: 55, False: 55]
  ------------------
 2358|     55|    size_t i0 = i;
 2359|     55|    Eurydice_slice uu____0 = out[i0];
 2360|     55|    uint8_t *uu____1 = b[i0];
 2361|     55|    core_ops_range_Range_b3 lit;
 2362|     55|    lit.start = (size_t)0U;
 2363|     55|    lit.end = Eurydice_slice_len(out[i0], uint8_t);
  ------------------
  |  |  118|     55|#define Eurydice_slice_len(s, t) EURYDICE_SLICE_LEN(s, t)
  |  |  ------------------
  |  |  |  |   89|     55|#define EURYDICE_SLICE_LEN(s, _) s.len
  |  |  ------------------
  ------------------
 2364|     55|    Eurydice_slice_copy(
  ------------------
  |  |  120|     55|  memcpy(dst.ptr, src.ptr, dst.len * sizeof(t))
  ------------------
 2365|     55|        uu____0,
 2366|     55|        Eurydice_array_to_subslice((size_t)200U, uu____1, lit, uint8_t,
 2367|     55|                                   core_ops_range_Range_b3),
 2368|     55|        uint8_t);
 2369|     55|  }
 2370|     55|}
mlkem768.c:libcrux_sha3_portable_keccak_store_block_full_5a_29:
 2341|     55|    uint64_t (*a)[5U], uint8_t ret[1U][200U]) {
 2342|     55|  libcrux_sha3_portable_keccak_store_block_full_2d(a, ret);
 2343|     55|}
mlkem768.c:libcrux_sha3_portable_keccak_store_block_full_2d:
 2320|     55|    uint64_t (*s)[5U], uint8_t ret[1U][200U]) {
 2321|     55|  uint8_t out[200U] = {0U};
 2322|     55|  Eurydice_slice buf[1U] = {
 2323|     55|      Eurydice_array_to_slice((size_t)200U, out, uint8_t)};
  ------------------
  |  |  107|     55|  EURYDICE_SLICE(x, 0,                     \
  |  |  ------------------
  |  |  |  |   88|     55|  (CLITERAL(Eurydice_slice){.ptr = (void *)(x + start), .len = end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |   61|     55|#define CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  108|     55|                 end) /* x is already at an array type, no need for cast */
  ------------------
 2324|     55|  libcrux_sha3_portable_keccak_store_block_58(s, buf);
 2325|       |  /* Passing arrays by value in Rust generates a copy in C */
 2326|     55|  uint8_t copy_of_out[200U];
 2327|     55|  memcpy(copy_of_out, out, (size_t)200U * sizeof(uint8_t));
 2328|     55|  memcpy(ret[0U], copy_of_out, (size_t)200U * sizeof(uint8_t));
 2329|     55|}
mlkem768.c:libcrux_sha3_portable_keccak_store_block_58:
 2302|     55|    uint64_t (*s)[5U], Eurydice_slice out[1U]) {
 2303|    550|  for (size_t i = (size_t)0U; i < (size_t)72U / (size_t)8U; i++) {
  ------------------
  |  Branch (2303:31): [True: 495, False: 55]
  ------------------
 2304|    495|    size_t i0 = i;
 2305|    495|    Eurydice_slice uu____0 = Eurydice_slice_subslice2(
  ------------------
  |  |  101|    495|  EURYDICE_SLICE((t *)s.ptr, start, end)
  |  |  ------------------
  |  |  |  |   88|    495|  (CLITERAL(Eurydice_slice){.ptr = (void *)(x + start), .len = end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |   61|    495|#define CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2306|    495|        out[0U], (size_t)8U * i0, (size_t)8U * i0 + (size_t)8U, uint8_t);
 2307|    495|    uint8_t ret[8U];
 2308|    495|    core_num__u64_9__to_le_bytes(s[i0 / (size_t)5U][i0 % (size_t)5U], ret);
 2309|    495|    Eurydice_slice_copy(
  ------------------
  |  |  120|    495|  memcpy(dst.ptr, src.ptr, dst.len * sizeof(t))
  ------------------
 2310|    495|        uu____0, Eurydice_array_to_slice((size_t)8U, ret, uint8_t), uint8_t);
 2311|    495|  }
 2312|     55|}
mlkem768.c:core_num__u64_9__to_le_bytes:
  163|  40.6k|static inline void core_num__u64_9__to_le_bytes(uint64_t v, uint8_t buf[8]) {
  164|       |  v = htole64(v);
  165|  40.6k|  memcpy(buf, &v, sizeof(v));
  166|  40.6k|}
mlkem768.c:libcrux_sha3_portable_keccak_split_at_mut_n_5a:
 1040|    990|                                               size_t mid) {
 1041|    990|  return libcrux_sha3_portable_keccak_split_at_mut_1(a, mid);
 1042|    990|}
mlkem768.c:libcrux_sha3_portable_keccak_split_at_mut_1:
 1023|    990|                                            size_t mid) {
 1024|    990|  Eurydice_slice_uint8_t_x2 uu____0 = Eurydice_slice_split_at_mut(
  ------------------
  |  |  143|    990|  (CLITERAL(ret_t){                                                  \
  |  |  ------------------
  |  |  |  |   61|    990|#define CLITERAL(type) (type)
  |  |  ------------------
  |  |  144|    990|      .fst = {.ptr = slice.ptr, .len = mid},                         \
  |  |  145|    990|      .snd = {.ptr = (char *)slice.ptr + mid * sizeof(element_type), \
  |  |  146|    990|              .len = slice.len - mid}})
  ------------------
 1025|    990|      out[0U], mid, uint8_t, Eurydice_slice_uint8_t_x2);
 1026|    990|  Eurydice_slice out00 = uu____0.fst;
 1027|    990|  Eurydice_slice out01 = uu____0.snd;
 1028|    990|  Eurydice_slice_uint8_t_1size_t__x2 lit;
 1029|    990|  lit.fst[0U] = out00;
 1030|    990|  lit.snd[0U] = out01;
 1031|    990|  return lit;
 1032|    990|}
mlkem768.c:libcrux_ml_kem_utils_into_padded_array_ea1:
  611|     55|    Eurydice_slice slice, uint8_t ret[34U]) {
  612|     55|  uint8_t out[34U] = {0U};
  613|     55|  uint8_t *uu____0 = out;
  614|     55|  Eurydice_slice_copy(
  ------------------
  |  |  120|     55|  memcpy(dst.ptr, src.ptr, dst.len * sizeof(t))
  ------------------
  615|     55|      Eurydice_array_to_subslice2(uu____0, (size_t)0U,
  616|     55|                                  Eurydice_slice_len(slice, uint8_t), uint8_t),
  617|     55|      slice, uint8_t);
  618|     55|  memcpy(ret, out, (size_t)34U * sizeof(uint8_t));
  619|     55|}
mlkem768.c:libcrux_ml_kem_matrix_sample_matrix_A_38:
 9838|     55|    libcrux_ml_kem_polynomial_PolynomialRingElement_f0 ret[3U][3U]) {
 9839|     55|  libcrux_ml_kem_polynomial_PolynomialRingElement_f0 A_transpose[3U][3U];
 9840|    220|  for (size_t i = (size_t)0U; i < (size_t)3U; i++) {
  ------------------
  |  Branch (9840:31): [True: 165, False: 55]
  ------------------
 9841|    165|    libcrux_ml_kem_matrix_sample_matrix_A_closure_4b(i, A_transpose[i]);
 9842|    165|  }
 9843|    220|  for (size_t i0 = (size_t)0U; i0 < (size_t)3U; i0++) {
  ------------------
  |  Branch (9843:32): [True: 165, False: 55]
  ------------------
 9844|    165|    size_t i1 = i0;
 9845|       |    /* Passing arrays by value in Rust generates a copy in C */
 9846|    165|    uint8_t copy_of_seed[34U];
 9847|    165|    memcpy(copy_of_seed, seed, (size_t)34U * sizeof(uint8_t));
 9848|    165|    uint8_t seeds[3U][34U];
 9849|    660|    for (size_t i = (size_t)0U; i < (size_t)3U; i++) {
  ------------------
  |  Branch (9849:33): [True: 495, False: 165]
  ------------------
 9850|    495|      memcpy(seeds[i], copy_of_seed, (size_t)34U * sizeof(uint8_t));
 9851|    495|    }
 9852|    660|    for (size_t i = (size_t)0U; i < (size_t)3U; i++) {
  ------------------
  |  Branch (9852:33): [True: 495, False: 165]
  ------------------
 9853|    495|      size_t j = i;
 9854|    495|      seeds[j][32U] = (uint8_t)i1;
 9855|    495|      seeds[j][33U] = (uint8_t)j;
 9856|    495|    }
 9857|       |    /* Passing arrays by value in Rust generates a copy in C */
 9858|    165|    uint8_t copy_of_seeds[3U][34U];
 9859|    165|    memcpy(copy_of_seeds, seeds, (size_t)3U * sizeof(uint8_t[34U]));
 9860|    165|    libcrux_ml_kem_polynomial_PolynomialRingElement_f0 sampled[3U];
 9861|    165|    libcrux_ml_kem_sampling_sample_from_xof_3f(copy_of_seeds, sampled);
 9862|    165|    for (size_t i = (size_t)0U;
 9863|    660|         i < Eurydice_slice_len(
  ------------------
  |  |  118|    660|#define Eurydice_slice_len(s, t) EURYDICE_SLICE_LEN(s, t)
  |  |  ------------------
  |  |  |  |   89|    660|#define EURYDICE_SLICE_LEN(s, _) s.len
  |  |  ------------------
  ------------------
  |  Branch (9863:10): [True: 495, False: 165]
  ------------------
 9864|    165|                 Eurydice_array_to_slice(
 9865|    165|                     (size_t)3U, sampled,
 9866|    165|                     libcrux_ml_kem_polynomial_PolynomialRingElement_f0),
 9867|    165|                 libcrux_ml_kem_polynomial_PolynomialRingElement_f0);
 9868|    495|         i++) {
 9869|    495|      size_t j = i;
 9870|    495|      libcrux_ml_kem_polynomial_PolynomialRingElement_f0 sample = sampled[j];
 9871|    495|      if (transpose) {
  ------------------
  |  Branch (9871:11): [True: 495, False: 0]
  ------------------
 9872|    495|        A_transpose[j][i1] = sample;
 9873|    495|      } else {
 9874|      0|        A_transpose[i1][j] = sample;
 9875|      0|      }
 9876|    495|    }
 9877|    165|  }
 9878|     55|  memcpy(ret, A_transpose,
 9879|     55|         (size_t)3U *
 9880|     55|             sizeof(libcrux_ml_kem_polynomial_PolynomialRingElement_f0[3U]));
 9881|     55|}
mlkem768.c:libcrux_ml_kem_matrix_sample_matrix_A_closure_4b:
 9430|    165|    size_t _i, libcrux_ml_kem_polynomial_PolynomialRingElement_f0 ret[3U]) {
 9431|    660|  for (size_t i = (size_t)0U; i < (size_t)3U; i++) {
  ------------------
  |  Branch (9431:31): [True: 495, False: 165]
  ------------------
 9432|    495|    ret[i] = libcrux_ml_kem_polynomial_ZERO_89_ea();
 9433|    495|  }
 9434|    165|}
mlkem768.c:libcrux_ml_kem_polynomial_ZERO_89_ea:
 8196|  2.31k|libcrux_ml_kem_polynomial_ZERO_89_ea(void) {
 8197|  2.31k|  libcrux_ml_kem_polynomial_PolynomialRingElement_f0 lit;
 8198|  2.31k|  lit.coefficients[0U] = libcrux_ml_kem_vector_portable_ZERO_0d();
 8199|  2.31k|  lit.coefficients[1U] = libcrux_ml_kem_vector_portable_ZERO_0d();
 8200|  2.31k|  lit.coefficients[2U] = libcrux_ml_kem_vector_portable_ZERO_0d();
 8201|  2.31k|  lit.coefficients[3U] = libcrux_ml_kem_vector_portable_ZERO_0d();
 8202|  2.31k|  lit.coefficients[4U] = libcrux_ml_kem_vector_portable_ZERO_0d();
 8203|  2.31k|  lit.coefficients[5U] = libcrux_ml_kem_vector_portable_ZERO_0d();
 8204|  2.31k|  lit.coefficients[6U] = libcrux_ml_kem_vector_portable_ZERO_0d();
 8205|  2.31k|  lit.coefficients[7U] = libcrux_ml_kem_vector_portable_ZERO_0d();
 8206|  2.31k|  lit.coefficients[8U] = libcrux_ml_kem_vector_portable_ZERO_0d();
 8207|  2.31k|  lit.coefficients[9U] = libcrux_ml_kem_vector_portable_ZERO_0d();
 8208|  2.31k|  lit.coefficients[10U] = libcrux_ml_kem_vector_portable_ZERO_0d();
 8209|  2.31k|  lit.coefficients[11U] = libcrux_ml_kem_vector_portable_ZERO_0d();
 8210|  2.31k|  lit.coefficients[12U] = libcrux_ml_kem_vector_portable_ZERO_0d();
 8211|  2.31k|  lit.coefficients[13U] = libcrux_ml_kem_vector_portable_ZERO_0d();
 8212|  2.31k|  lit.coefficients[14U] = libcrux_ml_kem_vector_portable_ZERO_0d();
 8213|  2.31k|  lit.coefficients[15U] = libcrux_ml_kem_vector_portable_ZERO_0d();
 8214|  2.31k|  return lit;
 8215|  2.31k|}
mlkem768.c:libcrux_ml_kem_vector_portable_ZERO_0d:
 6701|  36.9k|libcrux_ml_kem_vector_portable_ZERO_0d(void) {
 6702|  36.9k|  return libcrux_ml_kem_vector_portable_vector_type_zero();
 6703|  36.9k|}
mlkem768.c:libcrux_ml_kem_vector_portable_vector_type_zero:
 6106|  44.8k|libcrux_ml_kem_vector_portable_vector_type_zero(void) {
 6107|  44.8k|  libcrux_ml_kem_vector_portable_vector_type_PortableVector lit;
 6108|  44.8k|  lit.elements[0U] = (int16_t)0;
 6109|  44.8k|  lit.elements[1U] = (int16_t)0;
 6110|  44.8k|  lit.elements[2U] = (int16_t)0;
 6111|  44.8k|  lit.elements[3U] = (int16_t)0;
 6112|  44.8k|  lit.elements[4U] = (int16_t)0;
 6113|  44.8k|  lit.elements[5U] = (int16_t)0;
 6114|  44.8k|  lit.elements[6U] = (int16_t)0;
 6115|  44.8k|  lit.elements[7U] = (int16_t)0;
 6116|  44.8k|  lit.elements[8U] = (int16_t)0;
 6117|  44.8k|  lit.elements[9U] = (int16_t)0;
 6118|  44.8k|  lit.elements[10U] = (int16_t)0;
 6119|  44.8k|  lit.elements[11U] = (int16_t)0;
 6120|  44.8k|  lit.elements[12U] = (int16_t)0;
 6121|  44.8k|  lit.elements[13U] = (int16_t)0;
 6122|  44.8k|  lit.elements[14U] = (int16_t)0;
 6123|  44.8k|  lit.elements[15U] = (int16_t)0;
 6124|  44.8k|  return lit;
 6125|  44.8k|}
mlkem768.c:libcrux_ml_kem_sampling_sample_from_xof_3f:
 9784|    165|    libcrux_ml_kem_polynomial_PolynomialRingElement_f0 ret[3U]) {
 9785|    165|  size_t sampled_coefficients[3U] = {0U};
 9786|    165|  int16_t out[3U][272U] = {{0U}};
 9787|       |  /* Passing arrays by value in Rust generates a copy in C */
 9788|    165|  uint8_t copy_of_seeds[3U][34U];
 9789|    165|  memcpy(copy_of_seeds, seeds, (size_t)3U * sizeof(uint8_t[34U]));
 9790|    165|  libcrux_ml_kem_hash_functions_portable_PortableHash_58 xof_state =
 9791|    165|      libcrux_ml_kem_hash_functions_portable_shake128_init_absorb_f1_8c(
 9792|    165|          copy_of_seeds);
 9793|    165|  uint8_t randomness0[3U][504U];
 9794|    165|  libcrux_ml_kem_hash_functions_portable_shake128_squeeze_three_blocks_f1_69(
 9795|    165|      &xof_state, randomness0);
 9796|       |  /* Passing arrays by value in Rust generates a copy in C */
 9797|    165|  uint8_t copy_of_randomness0[3U][504U];
 9798|    165|  memcpy(copy_of_randomness0, randomness0, (size_t)3U * sizeof(uint8_t[504U]));
 9799|    165|  bool done = libcrux_ml_kem_sampling_sample_from_uniform_distribution_next_db(
 9800|    165|      copy_of_randomness0, sampled_coefficients, out);
 9801|    204|  while (true) {
  ------------------
  |  Branch (9801:10): [True: 204, Folded]
  ------------------
 9802|    204|    if (done) {
  ------------------
  |  Branch (9802:9): [True: 165, False: 39]
  ------------------
 9803|    165|      break;
 9804|    165|    } else {
 9805|     39|      uint8_t randomness[3U][168U];
 9806|     39|      libcrux_ml_kem_hash_functions_portable_shake128_squeeze_block_f1_60(
 9807|     39|          &xof_state, randomness);
 9808|       |      /* Passing arrays by value in Rust generates a copy in C */
 9809|     39|      uint8_t copy_of_randomness[3U][168U];
 9810|     39|      memcpy(copy_of_randomness, randomness,
 9811|     39|             (size_t)3U * sizeof(uint8_t[168U]));
 9812|     39|      done = libcrux_ml_kem_sampling_sample_from_uniform_distribution_next_db0(
 9813|     39|          copy_of_randomness, sampled_coefficients, out);
 9814|     39|    }
 9815|    204|  }
 9816|       |  /* Passing arrays by value in Rust generates a copy in C */
 9817|    165|  int16_t copy_of_out[3U][272U];
 9818|    165|  memcpy(copy_of_out, out, (size_t)3U * sizeof(int16_t[272U]));
 9819|    165|  libcrux_ml_kem_polynomial_PolynomialRingElement_f0 ret0[3U];
 9820|    660|  for (size_t i = (size_t)0U; i < (size_t)3U; i++) {
  ------------------
  |  Branch (9820:31): [True: 495, False: 165]
  ------------------
 9821|    495|    ret0[i] =
 9822|    495|        libcrux_ml_kem_sampling_sample_from_xof_closure_04(copy_of_out[i]);
 9823|    495|  }
 9824|    165|  memcpy(
 9825|    165|      ret, ret0,
 9826|    165|      (size_t)3U * sizeof(libcrux_ml_kem_polynomial_PolynomialRingElement_f0));
 9827|    165|}
mlkem768.c:libcrux_ml_kem_hash_functions_portable_shake128_init_absorb_f1_8c:
 9485|    165|    uint8_t input[3U][34U]) {
 9486|       |  /* Passing arrays by value in Rust generates a copy in C */
 9487|    165|  uint8_t copy_of_input[3U][34U];
 9488|    165|  memcpy(copy_of_input, input, (size_t)3U * sizeof(uint8_t[34U]));
 9489|    165|  return libcrux_ml_kem_hash_functions_portable_shake128_init_absorb_b7(
 9490|    165|      copy_of_input);
 9491|    165|}
mlkem768.c:libcrux_ml_kem_hash_functions_portable_shake128_init_absorb_b7:
 9452|    165|    uint8_t input[3U][34U]) {
 9453|    165|  libcrux_sha3_generic_keccak_KeccakState_48 shake128_state[3U];
 9454|    660|  for (size_t i = (size_t)0U; i < (size_t)3U; i++) {
  ------------------
  |  Branch (9454:31): [True: 495, False: 165]
  ------------------
 9455|    495|    shake128_state[i] = libcrux_sha3_portable_incremental_shake128_init();
 9456|    495|  }
 9457|    660|  for (size_t i = (size_t)0U; i < (size_t)3U; i++) {
  ------------------
  |  Branch (9457:31): [True: 495, False: 165]
  ------------------
 9458|    495|    size_t i0 = i;
 9459|    495|    libcrux_sha3_portable_incremental_shake128_absorb_final(
 9460|    495|        &shake128_state[i0],
 9461|    495|        Eurydice_array_to_slice((size_t)34U, input[i0], uint8_t));
  ------------------
  |  |  107|    495|  EURYDICE_SLICE(x, 0,                     \
  |  |  ------------------
  |  |  |  |   88|    495|  (CLITERAL(Eurydice_slice){.ptr = (void *)(x + start), .len = end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |   61|    495|#define CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  108|    495|                 end) /* x is already at an array type, no need for cast */
  ------------------
 9462|    495|  }
 9463|       |  /* Passing arrays by value in Rust generates a copy in C */
 9464|    165|  libcrux_sha3_generic_keccak_KeccakState_48 copy_of_shake128_state[3U];
 9465|    165|  memcpy(copy_of_shake128_state, shake128_state,
 9466|    165|         (size_t)3U * sizeof(libcrux_sha3_generic_keccak_KeccakState_48));
 9467|    165|  libcrux_ml_kem_hash_functions_portable_PortableHash_58 lit;
 9468|    165|  memcpy(lit.shake128_state, copy_of_shake128_state,
 9469|    165|         (size_t)3U * sizeof(libcrux_sha3_generic_keccak_KeccakState_48));
 9470|    165|  return lit;
 9471|    165|}
mlkem768.c:libcrux_sha3_portable_incremental_shake128_init:
 3029|    495|libcrux_sha3_portable_incremental_shake128_init(void) {
 3030|    495|  return libcrux_sha3_generic_keccak_new_1e_f4();
 3031|    495|}
mlkem768.c:libcrux_sha3_portable_incremental_shake128_absorb_final:
 3123|    495|    libcrux_sha3_generic_keccak_KeccakState_48 *s, Eurydice_slice data0) {
 3124|    495|  Eurydice_slice buf[1U] = {data0};
 3125|    495|  libcrux_sha3_generic_keccak_absorb_final_c72(s, buf);
 3126|    495|}
mlkem768.c:libcrux_sha3_generic_keccak_absorb_final_c72:
 3096|    495|    libcrux_sha3_generic_keccak_KeccakState_48 *s, Eurydice_slice last[1U]) {
 3097|    495|  size_t last_len = Eurydice_slice_len(last[0U], uint8_t);
  ------------------
  |  |  118|    495|#define Eurydice_slice_len(s, t) EURYDICE_SLICE_LEN(s, t)
  |  |  ------------------
  |  |  |  |   89|    495|#define EURYDICE_SLICE_LEN(s, _) s.len
  |  |  ------------------
  ------------------
 3098|    495|  uint8_t blocks[1U][200U] = {{0U}};
 3099|    990|  for (size_t i = (size_t)0U; i < (size_t)1U; i++) {
  ------------------
  |  Branch (3099:31): [True: 495, False: 495]
  ------------------
 3100|    495|    size_t i0 = i;
 3101|    495|    if (last_len > (size_t)0U) {
  ------------------
  |  Branch (3101:9): [True: 495, False: 0]
  ------------------
 3102|    495|      Eurydice_slice uu____0 = Eurydice_array_to_subslice2(
  ------------------
  |  |  113|    495|  EURYDICE_SLICE((t *)x, start, end)
  |  |  ------------------
  |  |  |  |   88|    495|  (CLITERAL(Eurydice_slice){.ptr = (void *)(x + start), .len = end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |   61|    495|#define CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3103|    495|          blocks[i0], (size_t)0U, last_len, uint8_t);
 3104|    495|      Eurydice_slice_copy(uu____0, last[i0], uint8_t);
  ------------------
  |  |  120|    495|  memcpy(dst.ptr, src.ptr, dst.len * sizeof(t))
  ------------------
 3105|    495|    }
 3106|    495|    blocks[i0][last_len] = 31U;
 3107|    495|    size_t uu____1 = i0;
 3108|    495|    size_t uu____2 = (size_t)168U - (size_t)1U;
 3109|    495|    blocks[uu____1][uu____2] = (uint32_t)blocks[uu____1][uu____2] | 128U;
 3110|    495|  }
 3111|    495|  uint64_t(*uu____3)[5U] = s->st;
 3112|    495|  uint8_t uu____4[1U][200U];
 3113|    495|  memcpy(uu____4, blocks, (size_t)1U * sizeof(uint8_t[200U]));
 3114|    495|  libcrux_sha3_portable_keccak_load_block_full_5a_d21(uu____3, uu____4);
 3115|    495|  libcrux_sha3_generic_keccak_keccakf1600_21(s);
 3116|    495|}
mlkem768.c:libcrux_sha3_portable_keccak_load_block_full_5a_d21:
 3079|    495|    uint64_t (*a)[5U], uint8_t b[1U][200U]) {
 3080|    495|  uint64_t(*uu____0)[5U] = a;
 3081|       |  /* Passing arrays by value in Rust generates a copy in C */
 3082|    495|  uint8_t copy_of_b[1U][200U];
 3083|    495|  memcpy(copy_of_b, b, (size_t)1U * sizeof(uint8_t[200U]));
 3084|    495|  libcrux_sha3_portable_keccak_load_block_full_df1(uu____0, copy_of_b);
 3085|    495|}
mlkem768.c:libcrux_sha3_portable_keccak_load_block_full_df1:
 3063|    495|    uint64_t (*s)[5U], uint8_t blocks[1U][200U]) {
 3064|    495|  Eurydice_slice buf[1U] = {
 3065|    495|      Eurydice_array_to_slice((size_t)200U, blocks[0U], uint8_t)};
  ------------------
  |  |  107|    495|  EURYDICE_SLICE(x, 0,                     \
  |  |  ------------------
  |  |  |  |   88|    495|  (CLITERAL(Eurydice_slice){.ptr = (void *)(x + start), .len = end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |   61|    495|#define CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  108|    495|                 end) /* x is already at an array type, no need for cast */
  ------------------
 3066|    495|  libcrux_sha3_portable_keccak_load_block_2c1(s, buf);
 3067|    495|}
mlkem768.c:libcrux_sha3_portable_keccak_load_block_2c1:
 3039|    495|    uint64_t (*s)[5U], Eurydice_slice blocks[1U]) {
 3040|  10.8k|  for (size_t i = (size_t)0U; i < (size_t)168U / (size_t)8U; i++) {
  ------------------
  |  Branch (3040:31): [True: 10.3k, False: 495]
  ------------------
 3041|  10.3k|    size_t i0 = i;
 3042|  10.3k|    uint8_t uu____0[8U];
 3043|  10.3k|    Result_56 dst;
 3044|  10.3k|    Eurydice_slice_to_array2(
  ------------------
  |  |  152|  10.3k|  Eurydice_slice_to_array3(&(dst)->tag, (char *)&(dst)->val.case_Ok, src, \
  |  |  153|  10.3k|                           sizeof(t_arr))
  ------------------
 3045|  10.3k|        &dst,
 3046|  10.3k|        Eurydice_slice_subslice2(blocks[0U], (size_t)8U * i0,
 3047|  10.3k|                                 (size_t)8U * i0 + (size_t)8U, uint8_t),
 3048|  10.3k|        Eurydice_slice, uint8_t[8U]);
 3049|  10.3k|    unwrap_41_ac(dst, uu____0);
 3050|  10.3k|    size_t uu____1 = i0 / (size_t)5U;
 3051|  10.3k|    size_t uu____2 = i0 % (size_t)5U;
 3052|  10.3k|    s[uu____1][uu____2] =
 3053|  10.3k|        s[uu____1][uu____2] ^ core_num__u64_9__from_le_bytes(uu____0);
 3054|  10.3k|  }
 3055|    495|}
mlkem768.c:libcrux_ml_kem_hash_functions_portable_shake128_squeeze_three_blocks_f1_69:
 9526|    165|    uint8_t ret[3U][504U]) {
 9527|    165|  libcrux_ml_kem_hash_functions_portable_shake128_squeeze_three_blocks_ca(self,
 9528|    165|                                                                          ret);
 9529|    165|}
mlkem768.c:libcrux_ml_kem_hash_functions_portable_shake128_squeeze_three_blocks_ca:
 9502|    165|    uint8_t ret[3U][504U]) {
 9503|    165|  uint8_t out[3U][504U] = {{0U}};
 9504|    660|  for (size_t i = (size_t)0U; i < (size_t)3U; i++) {
  ------------------
  |  Branch (9504:31): [True: 495, False: 165]
  ------------------
 9505|    495|    size_t i0 = i;
 9506|    495|    libcrux_sha3_portable_incremental_shake128_squeeze_first_three_blocks(
 9507|    495|        &st->shake128_state[i0],
 9508|    495|        Eurydice_array_to_slice((size_t)504U, out[i0], uint8_t));
  ------------------
  |  |  107|    495|  EURYDICE_SLICE(x, 0,                     \
  |  |  ------------------
  |  |  |  |   88|    495|  (CLITERAL(Eurydice_slice){.ptr = (void *)(x + start), .len = end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |   61|    495|#define CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  108|    495|                 end) /* x is already at an array type, no need for cast */
  ------------------
 9509|    495|  }
 9510|    165|  memcpy(ret, out, (size_t)3U * sizeof(uint8_t[504U]));
 9511|    165|}
mlkem768.c:libcrux_sha3_portable_incremental_shake128_squeeze_first_three_blocks:
 3227|    495|    libcrux_sha3_generic_keccak_KeccakState_48 *s, Eurydice_slice out0) {
 3228|    495|  Eurydice_slice buf[1U] = {out0};
 3229|    495|  libcrux_sha3_generic_keccak_squeeze_first_three_blocks_cc(s, buf);
 3230|    495|}
mlkem768.c:libcrux_sha3_generic_keccak_squeeze_first_three_blocks_cc:
 3204|    495|    libcrux_sha3_generic_keccak_KeccakState_48 *s, Eurydice_slice out[1U]) {
 3205|    495|  Eurydice_slice_uint8_t_1size_t__x2 uu____0 =
 3206|    495|      libcrux_sha3_portable_keccak_split_at_mut_n_5a(out, (size_t)168U);
 3207|    495|  Eurydice_slice o0[1U];
 3208|    495|  memcpy(o0, uu____0.fst, (size_t)1U * sizeof(Eurydice_slice));
 3209|    495|  Eurydice_slice o10[1U];
 3210|    495|  memcpy(o10, uu____0.snd, (size_t)1U * sizeof(Eurydice_slice));
 3211|    495|  libcrux_sha3_generic_keccak_squeeze_first_block_841(s, o0);
 3212|    495|  Eurydice_slice_uint8_t_1size_t__x2 uu____1 =
 3213|    495|      libcrux_sha3_portable_keccak_split_at_mut_n_5a(o10, (size_t)168U);
 3214|    495|  Eurydice_slice o1[1U];
 3215|    495|  memcpy(o1, uu____1.fst, (size_t)1U * sizeof(Eurydice_slice));
 3216|    495|  Eurydice_slice o2[1U];
 3217|    495|  memcpy(o2, uu____1.snd, (size_t)1U * sizeof(Eurydice_slice));
 3218|    495|  libcrux_sha3_generic_keccak_squeeze_next_block_fc1(s, o1);
 3219|    495|  libcrux_sha3_generic_keccak_squeeze_next_block_fc1(s, o2);
 3220|    495|}
mlkem768.c:libcrux_sha3_generic_keccak_squeeze_first_block_841:
 3191|    495|    libcrux_sha3_generic_keccak_KeccakState_48 *s, Eurydice_slice out[1U]) {
 3192|    495|  libcrux_sha3_portable_keccak_store_block_5a_591(s->st, out);
 3193|    495|}
mlkem768.c:libcrux_sha3_portable_keccak_store_block_5a_591:
 3156|  1.60k|    uint64_t (*a)[5U], Eurydice_slice b[1U]) {
 3157|  1.60k|  libcrux_sha3_portable_keccak_store_block_581(a, b);
 3158|  1.60k|}
mlkem768.c:libcrux_sha3_portable_keccak_store_block_581:
 3134|  1.60k|    uint64_t (*s)[5U], Eurydice_slice out[1U]) {
 3135|  35.2k|  for (size_t i = (size_t)0U; i < (size_t)168U / (size_t)8U; i++) {
  ------------------
  |  Branch (3135:31): [True: 33.6k, False: 1.60k]
  ------------------
 3136|  33.6k|    size_t i0 = i;
 3137|  33.6k|    Eurydice_slice uu____0 = Eurydice_slice_subslice2(
  ------------------
  |  |  101|  33.6k|  EURYDICE_SLICE((t *)s.ptr, start, end)
  |  |  ------------------
  |  |  |  |   88|  33.6k|  (CLITERAL(Eurydice_slice){.ptr = (void *)(x + start), .len = end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |   61|  33.6k|#define CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3138|  33.6k|        out[0U], (size_t)8U * i0, (size_t)8U * i0 + (size_t)8U, uint8_t);
 3139|  33.6k|    uint8_t ret[8U];
 3140|  33.6k|    core_num__u64_9__to_le_bytes(s[i0 / (size_t)5U][i0 % (size_t)5U], ret);
 3141|  33.6k|    Eurydice_slice_copy(
  ------------------
  |  |  120|  33.6k|  memcpy(dst.ptr, src.ptr, dst.len * sizeof(t))
  ------------------
 3142|  33.6k|        uu____0, Eurydice_array_to_slice((size_t)8U, ret, uint8_t), uint8_t);
 3143|  33.6k|  }
 3144|  1.60k|}
mlkem768.c:libcrux_sha3_generic_keccak_squeeze_next_block_fc1:
 3168|  1.10k|    libcrux_sha3_generic_keccak_KeccakState_48 *s, Eurydice_slice out[1U]) {
 3169|  1.10k|  libcrux_sha3_generic_keccak_keccakf1600_21(s);
 3170|  1.10k|  libcrux_sha3_portable_keccak_store_block_5a_591(s->st, out);
 3171|  1.10k|}
mlkem768.c:libcrux_ml_kem_sampling_sample_from_uniform_distribution_next_db:
 9582|    165|    int16_t (*out)[272U]) {
 9583|    660|  for (size_t i0 = (size_t)0U; i0 < (size_t)3U; i0++) {
  ------------------
  |  Branch (9583:32): [True: 495, False: 165]
  ------------------
 9584|    495|    size_t i1 = i0;
 9585|  10.8k|    for (size_t i = (size_t)0U; i < (size_t)504U / (size_t)24U; i++) {
  ------------------
  |  Branch (9585:33): [True: 10.3k, False: 495]
  ------------------
 9586|  10.3k|      size_t r = i;
 9587|  10.3k|      if (sampled_coefficients[i1] <
  ------------------
  |  Branch (9587:11): [True: 10.0k, False: 356]
  ------------------
 9588|  10.3k|          LIBCRUX_ML_KEM_CONSTANTS_COEFFICIENTS_IN_RING_ELEMENT) {
  ------------------
  |  |  282|  10.3k|#define LIBCRUX_ML_KEM_CONSTANTS_COEFFICIENTS_IN_RING_ELEMENT ((size_t)256U)
  ------------------
 9589|  10.0k|        Eurydice_slice uu____0 =
 9590|  10.0k|            Eurydice_array_to_subslice2(randomness[i1], r * (size_t)24U,
  ------------------
  |  |  113|  10.0k|  EURYDICE_SLICE((t *)x, start, end)
  |  |  ------------------
  |  |  |  |   88|  10.0k|  (CLITERAL(Eurydice_slice){.ptr = (void *)(x + start), .len = end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |   61|  10.0k|#define CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 9591|  10.0k|                                        r * (size_t)24U + (size_t)24U, uint8_t);
 9592|  10.0k|        size_t sampled = libcrux_ml_kem_vector_portable_rej_sample_0d(
 9593|  10.0k|            uu____0, Eurydice_array_to_subslice2(
  ------------------
  |  |  113|  10.0k|  EURYDICE_SLICE((t *)x, start, end)
  |  |  ------------------
  |  |  |  |   88|  10.0k|  (CLITERAL(Eurydice_slice){.ptr = (void *)(x + start), .len = end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |   61|  10.0k|#define CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 9594|  10.0k|                         out[i1], sampled_coefficients[i1],
 9595|  10.0k|                         sampled_coefficients[i1] + (size_t)16U, int16_t));
 9596|  10.0k|        size_t uu____1 = i1;
 9597|  10.0k|        sampled_coefficients[uu____1] = sampled_coefficients[uu____1] + sampled;
 9598|  10.0k|      }
 9599|  10.3k|    }
 9600|    495|  }
 9601|    165|  bool done = true;
 9602|    660|  for (size_t i = (size_t)0U; i < (size_t)3U; i++) {
  ------------------
  |  Branch (9602:31): [True: 495, False: 165]
  ------------------
 9603|    495|    size_t i0 = i;
 9604|    495|    if (sampled_coefficients[i0] >=
  ------------------
  |  Branch (9604:9): [True: 455, False: 40]
  ------------------
 9605|    495|        LIBCRUX_ML_KEM_CONSTANTS_COEFFICIENTS_IN_RING_ELEMENT) {
  ------------------
  |  |  282|    495|#define LIBCRUX_ML_KEM_CONSTANTS_COEFFICIENTS_IN_RING_ELEMENT ((size_t)256U)
  ------------------
 9606|    455|      sampled_coefficients[i0] =
 9607|    455|          LIBCRUX_ML_KEM_CONSTANTS_COEFFICIENTS_IN_RING_ELEMENT;
  ------------------
  |  |  282|    455|#define LIBCRUX_ML_KEM_CONSTANTS_COEFFICIENTS_IN_RING_ELEMENT ((size_t)256U)
  ------------------
 9608|    455|    } else {
 9609|       |      done = false;
 9610|     40|    }
 9611|    495|  }
 9612|    165|  return done;
 9613|    165|}
mlkem768.c:libcrux_ml_kem_vector_portable_rej_sample_0d:
 8109|  10.0k|    Eurydice_slice a, Eurydice_slice out) {
 8110|  10.0k|  return libcrux_ml_kem_vector_portable_sampling_rej_sample(a, out);
 8111|  10.0k|}
mlkem768.c:libcrux_ml_kem_vector_portable_sampling_rej_sample:
 8045|  10.0k|                                                   Eurydice_slice result) {
 8046|  10.0k|  size_t sampled = (size_t)0U;
 8047|  90.7k|  for (size_t i = (size_t)0U; i < Eurydice_slice_len(a, uint8_t) / (size_t)3U;
  ------------------
  |  |  118|  90.7k|#define Eurydice_slice_len(s, t) EURYDICE_SLICE_LEN(s, t)
  |  |  ------------------
  |  |  |  |   89|  90.7k|#define EURYDICE_SLICE_LEN(s, _) s.len
  |  |  ------------------
  ------------------
  |  Branch (8047:31): [True: 80.6k, False: 10.0k]
  ------------------
 8048|  80.6k|       i++) {
 8049|  80.6k|    size_t i0 = i;
 8050|  80.6k|    int16_t b1 = (int16_t)Eurydice_slice_index(a, i0 * (size_t)3U + (size_t)0U,
  ------------------
  |  |   95|  80.6k|#define Eurydice_slice_index(s, i, t, t_ptr_t) (((t_ptr_t)s.ptr)[i])
  ------------------
 8051|  80.6k|                                               uint8_t, uint8_t *);
 8052|  80.6k|    int16_t b2 = (int16_t)Eurydice_slice_index(a, i0 * (size_t)3U + (size_t)1U,
  ------------------
  |  |   95|  80.6k|#define Eurydice_slice_index(s, i, t, t_ptr_t) (((t_ptr_t)s.ptr)[i])
  ------------------
 8053|  80.6k|                                               uint8_t, uint8_t *);
 8054|  80.6k|    int16_t b3 = (int16_t)Eurydice_slice_index(a, i0 * (size_t)3U + (size_t)2U,
  ------------------
  |  |   95|  80.6k|#define Eurydice_slice_index(s, i, t, t_ptr_t) (((t_ptr_t)s.ptr)[i])
  ------------------
 8055|  80.6k|                                               uint8_t, uint8_t *);
 8056|  80.6k|    int16_t d1 = (b2 & (int16_t)15) << 8U | b1;
 8057|  80.6k|    int16_t d2 = b3 << 4U | b2 >> 4U;
 8058|  80.6k|    bool uu____0;
 8059|  80.6k|    int16_t uu____1;
 8060|  80.6k|    bool uu____2;
 8061|  80.6k|    size_t uu____3;
 8062|  80.6k|    int16_t uu____4;
 8063|  80.6k|    size_t uu____5;
 8064|  80.6k|    int16_t uu____6;
 8065|  80.6k|    if (d1 < LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_MODULUS) {
  ------------------
  |  | 5863|  80.6k|#define LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_MODULUS ((int16_t)3329)
  ------------------
  |  Branch (8065:9): [True: 64.9k, False: 15.7k]
  ------------------
 8066|  64.9k|      if (sampled < (size_t)16U) {
  ------------------
  |  Branch (8066:11): [True: 64.9k, False: 0]
  ------------------
 8067|  64.9k|        Eurydice_slice_index(result, sampled, int16_t, int16_t *) = d1;
  ------------------
  |  |   95|  64.9k|#define Eurydice_slice_index(s, i, t, t_ptr_t) (((t_ptr_t)s.ptr)[i])
  ------------------
 8068|  64.9k|        sampled++;
 8069|  64.9k|        uu____1 = d2;
 8070|  64.9k|        uu____6 = LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_MODULUS;
  ------------------
  |  | 5863|  64.9k|#define LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_MODULUS ((int16_t)3329)
  ------------------
 8071|  64.9k|        uu____0 = uu____1 < uu____6;
 8072|  64.9k|        if (uu____0) {
  ------------------
  |  Branch (8072:13): [True: 52.2k, False: 12.7k]
  ------------------
 8073|  52.2k|          uu____3 = sampled;
 8074|  52.2k|          uu____2 = uu____3 < (size_t)16U;
 8075|  52.2k|          if (uu____2) {
  ------------------
  |  Branch (8075:15): [True: 52.2k, False: 0]
  ------------------
 8076|  52.2k|            uu____4 = d2;
 8077|  52.2k|            uu____5 = sampled;
 8078|  52.2k|            Eurydice_slice_index(result, uu____5, int16_t, int16_t *) = uu____4;
  ------------------
  |  |   95|  52.2k|#define Eurydice_slice_index(s, i, t, t_ptr_t) (((t_ptr_t)s.ptr)[i])
  ------------------
 8079|  52.2k|            sampled++;
 8080|  52.2k|            continue;
 8081|  52.2k|          }
 8082|  52.2k|        }
 8083|  12.7k|        continue;
 8084|  64.9k|      }
 8085|  64.9k|    }
 8086|  15.7k|    uu____1 = d2;
 8087|  15.7k|    uu____6 = LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_MODULUS;
  ------------------
  |  | 5863|  15.7k|#define LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_MODULUS ((int16_t)3329)
  ------------------
 8088|  15.7k|    uu____0 = uu____1 < uu____6;
 8089|  15.7k|    if (uu____0) {
  ------------------
  |  Branch (8089:9): [True: 12.6k, False: 3.02k]
  ------------------
 8090|  12.6k|      uu____3 = sampled;
 8091|  12.6k|      uu____2 = uu____3 < (size_t)16U;
 8092|  12.6k|      if (uu____2) {
  ------------------
  |  Branch (8092:11): [True: 12.6k, False: 0]
  ------------------
 8093|  12.6k|        uu____4 = d2;
 8094|  12.6k|        uu____5 = sampled;
 8095|  12.6k|        Eurydice_slice_index(result, uu____5, int16_t, int16_t *) = uu____4;
  ------------------
  |  |   95|  12.6k|#define Eurydice_slice_index(s, i, t, t_ptr_t) (((t_ptr_t)s.ptr)[i])
  ------------------
 8096|  12.6k|        sampled++;
 8097|  12.6k|        continue;
 8098|  12.6k|      }
 8099|  12.6k|    }
 8100|  15.7k|  }
 8101|  10.0k|  return sampled;
 8102|  10.0k|}
mlkem768.c:libcrux_ml_kem_hash_functions_portable_shake128_squeeze_block_f1_60:
 9648|     39|    uint8_t ret[3U][168U]) {
 9649|     39|  libcrux_ml_kem_hash_functions_portable_shake128_squeeze_block_dd(self, ret);
 9650|     39|}
mlkem768.c:libcrux_ml_kem_hash_functions_portable_shake128_squeeze_block_dd:
 9624|     39|    uint8_t ret[3U][168U]) {
 9625|     39|  uint8_t out[3U][168U] = {{0U}};
 9626|    156|  for (size_t i = (size_t)0U; i < (size_t)3U; i++) {
  ------------------
  |  Branch (9626:31): [True: 117, False: 39]
  ------------------
 9627|    117|    size_t i0 = i;
 9628|    117|    libcrux_sha3_portable_incremental_shake128_squeeze_next_block(
 9629|    117|        &st->shake128_state[i0],
 9630|    117|        Eurydice_array_to_slice((size_t)168U, out[i0], uint8_t));
  ------------------
  |  |  107|    117|  EURYDICE_SLICE(x, 0,                     \
  |  |  ------------------
  |  |  |  |   88|    117|  (CLITERAL(Eurydice_slice){.ptr = (void *)(x + start), .len = end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |   61|    117|#define CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  108|    117|                 end) /* x is already at an array type, no need for cast */
  ------------------
 9631|    117|  }
 9632|     39|  memcpy(ret, out, (size_t)3U * sizeof(uint8_t[168U]));
 9633|     39|}
mlkem768.c:libcrux_sha3_portable_incremental_shake128_squeeze_next_block:
 3178|    117|    libcrux_sha3_generic_keccak_KeccakState_48 *s, Eurydice_slice out0) {
 3179|    117|  Eurydice_slice buf[1U] = {out0};
 3180|    117|  libcrux_sha3_generic_keccak_squeeze_next_block_fc1(s, buf);
 3181|    117|}
mlkem768.c:libcrux_ml_kem_sampling_sample_from_uniform_distribution_next_db0:
 9703|     39|    int16_t (*out)[272U]) {
 9704|    156|  for (size_t i0 = (size_t)0U; i0 < (size_t)3U; i0++) {
  ------------------
  |  Branch (9704:32): [True: 117, False: 39]
  ------------------
 9705|    117|    size_t i1 = i0;
 9706|    936|    for (size_t i = (size_t)0U; i < (size_t)168U / (size_t)24U; i++) {
  ------------------
  |  Branch (9706:33): [True: 819, False: 117]
  ------------------
 9707|    819|      size_t r = i;
 9708|    819|      if (sampled_coefficients[i1] <
  ------------------
  |  Branch (9708:11): [True: 42, False: 777]
  ------------------
 9709|    819|          LIBCRUX_ML_KEM_CONSTANTS_COEFFICIENTS_IN_RING_ELEMENT) {
  ------------------
  |  |  282|    819|#define LIBCRUX_ML_KEM_CONSTANTS_COEFFICIENTS_IN_RING_ELEMENT ((size_t)256U)
  ------------------
 9710|     42|        Eurydice_slice uu____0 =
 9711|     42|            Eurydice_array_to_subslice2(randomness[i1], r * (size_t)24U,
  ------------------
  |  |  113|     42|  EURYDICE_SLICE((t *)x, start, end)
  |  |  ------------------
  |  |  |  |   88|     42|  (CLITERAL(Eurydice_slice){.ptr = (void *)(x + start), .len = end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |   61|     42|#define CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 9712|     42|                                        r * (size_t)24U + (size_t)24U, uint8_t);
 9713|     42|        size_t sampled = libcrux_ml_kem_vector_portable_rej_sample_0d(
 9714|     42|            uu____0, Eurydice_array_to_subslice2(
  ------------------
  |  |  113|     42|  EURYDICE_SLICE((t *)x, start, end)
  |  |  ------------------
  |  |  |  |   88|     42|  (CLITERAL(Eurydice_slice){.ptr = (void *)(x + start), .len = end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |   61|     42|#define CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 9715|     42|                         out[i1], sampled_coefficients[i1],
 9716|     42|                         sampled_coefficients[i1] + (size_t)16U, int16_t));
 9717|     42|        size_t uu____1 = i1;
 9718|     42|        sampled_coefficients[uu____1] = sampled_coefficients[uu____1] + sampled;
 9719|     42|      }
 9720|    819|    }
 9721|    117|  }
 9722|     39|  bool done = true;
 9723|    156|  for (size_t i = (size_t)0U; i < (size_t)3U; i++) {
  ------------------
  |  Branch (9723:31): [True: 117, False: 39]
  ------------------
 9724|    117|    size_t i0 = i;
 9725|    117|    if (sampled_coefficients[i0] >=
  ------------------
  |  Branch (9725:9): [True: 117, False: 0]
  ------------------
 9726|    117|        LIBCRUX_ML_KEM_CONSTANTS_COEFFICIENTS_IN_RING_ELEMENT) {
  ------------------
  |  |  282|    117|#define LIBCRUX_ML_KEM_CONSTANTS_COEFFICIENTS_IN_RING_ELEMENT ((size_t)256U)
  ------------------
 9727|    117|      sampled_coefficients[i0] =
 9728|    117|          LIBCRUX_ML_KEM_CONSTANTS_COEFFICIENTS_IN_RING_ELEMENT;
  ------------------
  |  |  282|    117|#define LIBCRUX_ML_KEM_CONSTANTS_COEFFICIENTS_IN_RING_ELEMENT ((size_t)256U)
  ------------------
 9729|    117|    } else {
 9730|       |      done = false;
 9731|      0|    }
 9732|    117|  }
 9733|     39|  return done;
 9734|     39|}
mlkem768.c:libcrux_ml_kem_sampling_sample_from_xof_closure_04:
 9770|    495|libcrux_ml_kem_sampling_sample_from_xof_closure_04(int16_t s[272U]) {
 9771|    495|  return libcrux_ml_kem_polynomial_from_i16_array_89_c1(
 9772|    495|      Eurydice_array_to_subslice2(s, (size_t)0U, (size_t)256U, int16_t));
  ------------------
  |  |  113|    495|  EURYDICE_SLICE((t *)x, start, end)
  |  |  ------------------
  |  |  |  |   88|    495|  (CLITERAL(Eurydice_slice){.ptr = (void *)(x + start), .len = end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |   61|    495|#define CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 9773|    495|}
mlkem768.c:libcrux_ml_kem_polynomial_from_i16_array_89_c1:
 9747|    825|libcrux_ml_kem_polynomial_from_i16_array_89_c1(Eurydice_slice a) {
 9748|    825|  libcrux_ml_kem_polynomial_PolynomialRingElement_f0 result =
 9749|    825|      libcrux_ml_kem_polynomial_ZERO_89_ea();
 9750|    825|  for (size_t i = (size_t)0U;
 9751|  14.0k|       i < LIBCRUX_ML_KEM_POLYNOMIAL_VECTORS_IN_RING_ELEMENT; i++) {
  ------------------
  |  | 5860|  14.0k|  (LIBCRUX_ML_KEM_CONSTANTS_COEFFICIENTS_IN_RING_ELEMENT / \
  |  |  ------------------
  |  |  |  |  282|  14.0k|#define LIBCRUX_ML_KEM_CONSTANTS_COEFFICIENTS_IN_RING_ELEMENT ((size_t)256U)
  |  |  ------------------
  |  | 5861|  14.0k|   LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_ELEMENTS_IN_VECTOR)
  |  |  ------------------
  |  |  |  | 5857|  14.0k|#define LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_ELEMENTS_IN_VECTOR ((size_t)16U)
  |  |  ------------------
  ------------------
  |  Branch (9751:8): [True: 13.2k, False: 825]
  ------------------
 9752|  13.2k|    size_t i0 = i;
 9753|  13.2k|    libcrux_ml_kem_vector_portable_vector_type_PortableVector uu____0 =
 9754|  13.2k|        libcrux_ml_kem_vector_portable_from_i16_array_0d(
 9755|  13.2k|            Eurydice_slice_subslice2(a, i0 * (size_t)16U,
  ------------------
  |  |  101|  13.2k|  EURYDICE_SLICE((t *)s.ptr, start, end)
  |  |  ------------------
  |  |  |  |   88|  13.2k|  (CLITERAL(Eurydice_slice){.ptr = (void *)(x + start), .len = end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |   61|  13.2k|#define CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 9756|  13.2k|                                     (i0 + (size_t)1U) * (size_t)16U, int16_t));
 9757|  13.2k|    result.coefficients[i0] = uu____0;
 9758|  13.2k|  }
 9759|    825|  return result;
 9760|    825|}
mlkem768.c:libcrux_ml_kem_vector_portable_from_i16_array_0d:
 5894|  13.2k|libcrux_ml_kem_vector_portable_from_i16_array_0d(Eurydice_slice array) {
 5895|  13.2k|  return libcrux_ml_kem_vector_portable_vector_type_from_i16_array(array);
 5896|  13.2k|}
mlkem768.c:libcrux_ml_kem_vector_portable_vector_type_from_i16_array:
 5877|  13.2k|    Eurydice_slice array) {
 5878|  13.2k|  libcrux_ml_kem_vector_portable_vector_type_PortableVector lit;
 5879|  13.2k|  int16_t ret[16U];
 5880|  13.2k|  Result_c0 dst;
 5881|  13.2k|  Eurydice_slice_to_array2(
  ------------------
  |  |  152|  13.2k|  Eurydice_slice_to_array3(&(dst)->tag, (char *)&(dst)->val.case_Ok, src, \
  |  |  153|  13.2k|                           sizeof(t_arr))
  ------------------
 5882|  13.2k|      &dst, Eurydice_slice_subslice2(array, (size_t)0U, (size_t)16U, int16_t),
 5883|  13.2k|      Eurydice_slice, int16_t[16U]);
 5884|  13.2k|  unwrap_41_f9(dst, ret);
 5885|  13.2k|  memcpy(lit.elements, ret, (size_t)16U * sizeof(int16_t));
 5886|  13.2k|  return lit;
 5887|  13.2k|}
mlkem768.c:unwrap_41_f9:
  694|  13.2k|static inline void unwrap_41_f9(Result_c0 self, int16_t ret[16U]) {
  695|  13.2k|  if (self.tag == Ok) {
  ------------------
  |  |  246|  13.2k|#define Ok 0
  ------------------
  |  Branch (695:7): [True: 13.2k, False: 0]
  ------------------
  696|  13.2k|    int16_t f0[16U];
  697|  13.2k|    memcpy(f0, self.val.case_Ok, (size_t)16U * sizeof(int16_t));
  698|  13.2k|    memcpy(ret, f0, (size_t)16U * sizeof(int16_t));
  699|  13.2k|  } else {
  700|      0|    KRML_HOST_EPRINTF("KaRaMeL abort at %s:%d\n%s\n", __FILE__, __LINE__,
  701|      0|                      "unwrap not Ok");
  702|      0|    KRML_HOST_EXIT(255U);
  ------------------
  |  |   35|      0|#define KRML_HOST_EXIT(x) dropbear_exit("mlkem")
  ------------------
  703|      0|  }
  704|  13.2k|}
mlkem768.c:libcrux_ml_kem_utils_into_padded_array_ea2:
  592|     55|    Eurydice_slice slice, uint8_t ret[33U]) {
  593|     55|  uint8_t out[33U] = {0U};
  594|     55|  uint8_t *uu____0 = out;
  595|     55|  Eurydice_slice_copy(
  ------------------
  |  |  120|     55|  memcpy(dst.ptr, src.ptr, dst.len * sizeof(t))
  ------------------
  596|     55|      Eurydice_array_to_subslice2(uu____0, (size_t)0U,
  597|     55|                                  Eurydice_slice_len(slice, uint8_t), uint8_t),
  598|     55|      slice, uint8_t);
  599|     55|  memcpy(ret, out, (size_t)33U * sizeof(uint8_t));
  600|     55|}
mlkem768.c:libcrux_ml_kem_ind_cpa_sample_vector_cbd_then_ntt_fc:
10155|    110|                                                     uint8_t domain_separator) {
10156|    110|  libcrux_ml_kem_polynomial_PolynomialRingElement_f0 re_as_ntt[3U];
10157|    440|  for (size_t i = (size_t)0U; i < (size_t)3U; i++) {
  ------------------
  |  Branch (10157:31): [True: 330, False: 110]
  ------------------
10158|    330|    re_as_ntt[i] = libcrux_ml_kem_polynomial_ZERO_89_ea();
10159|    330|  }
10160|       |  /* Passing arrays by value in Rust generates a copy in C */
10161|    110|  uint8_t copy_of_prf_input[33U];
10162|    110|  memcpy(copy_of_prf_input, prf_input, (size_t)33U * sizeof(uint8_t));
10163|    110|  uint8_t prf_inputs[3U][33U];
10164|    440|  for (size_t i = (size_t)0U; i < (size_t)3U; i++) {
  ------------------
  |  Branch (10164:31): [True: 330, False: 110]
  ------------------
10165|    330|    memcpy(prf_inputs[i], copy_of_prf_input, (size_t)33U * sizeof(uint8_t));
10166|    330|  }
10167|    440|  for (size_t i = (size_t)0U; i < (size_t)3U; i++) {
  ------------------
  |  Branch (10167:31): [True: 330, False: 110]
  ------------------
10168|    330|    size_t i0 = i;
10169|    330|    prf_inputs[i0][32U] = domain_separator;
10170|    330|    domain_separator = (uint32_t)domain_separator + 1U;
10171|    330|  }
10172|    110|  uint8_t prf_outputs[3U][128U];
10173|    110|  libcrux_ml_kem_hash_functions_portable_PRFxN_f1_93(prf_inputs, prf_outputs);
10174|    440|  for (size_t i = (size_t)0U; i < (size_t)3U; i++) {
  ------------------
  |  Branch (10174:31): [True: 330, False: 110]
  ------------------
10175|    330|    size_t i0 = i;
10176|    330|    re_as_ntt[i0] =
10177|    330|        libcrux_ml_kem_sampling_sample_from_binomial_distribution_c6(
10178|    330|            Eurydice_array_to_slice((size_t)128U, prf_outputs[i0], uint8_t));
  ------------------
  |  |  107|    330|  EURYDICE_SLICE(x, 0,                     \
  |  |  ------------------
  |  |  |  |   88|    330|  (CLITERAL(Eurydice_slice){.ptr = (void *)(x + start), .len = end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |   61|    330|#define CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  108|    330|                 end) /* x is already at an array type, no need for cast */
  ------------------
10179|    330|    libcrux_ml_kem_ntt_ntt_binomially_sampled_ring_element_0f(&re_as_ntt[i0]);
10180|    330|  }
10181|       |  /* Passing arrays by value in Rust generates a copy in C */
10182|    110|  libcrux_ml_kem_polynomial_PolynomialRingElement_f0 copy_of_re_as_ntt[3U];
10183|    110|  memcpy(
10184|    110|      copy_of_re_as_ntt, re_as_ntt,
10185|    110|      (size_t)3U * sizeof(libcrux_ml_kem_polynomial_PolynomialRingElement_f0));
10186|    110|  tuple_b0 lit;
10187|    110|  memcpy(
10188|    110|      lit.fst, copy_of_re_as_ntt,
10189|    110|      (size_t)3U * sizeof(libcrux_ml_kem_polynomial_PolynomialRingElement_f0));
10190|    110|  lit.snd = domain_separator;
10191|    110|  return lit;
10192|    110|}
mlkem768.c:libcrux_ml_kem_hash_functions_portable_PRFxN_f1_93:
 9938|    110|    uint8_t (*input)[33U], uint8_t ret[3U][128U]) {
 9939|    110|  libcrux_ml_kem_hash_functions_portable_PRFxN_c5(input, ret);
 9940|    110|}
mlkem768.c:libcrux_ml_kem_hash_functions_portable_PRFxN_c5:
 9916|    110|    uint8_t (*input)[33U], uint8_t ret[3U][128U]) {
 9917|    110|  uint8_t out[3U][128U] = {{0U}};
 9918|    440|  for (size_t i = (size_t)0U; i < (size_t)3U; i++) {
  ------------------
  |  Branch (9918:31): [True: 330, False: 110]
  ------------------
 9919|    330|    size_t i0 = i;
 9920|    330|    libcrux_sha3_portable_shake256(
 9921|    330|        Eurydice_array_to_slice((size_t)128U, out[i0], uint8_t),
  ------------------
  |  |  107|    330|  EURYDICE_SLICE(x, 0,                     \
  |  |  ------------------
  |  |  |  |   88|    330|  (CLITERAL(Eurydice_slice){.ptr = (void *)(x + start), .len = end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |   61|    330|#define CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  108|    330|                 end) /* x is already at an array type, no need for cast */
  ------------------
 9922|    330|        Eurydice_array_to_slice((size_t)33U, input[i0], uint8_t));
  ------------------
  |  |  107|    330|  EURYDICE_SLICE(x, 0,                     \
  |  |  ------------------
  |  |  |  |   88|    330|  (CLITERAL(Eurydice_slice){.ptr = (void *)(x + start), .len = end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |   61|    330|#define CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  108|    330|                 end) /* x is already at an array type, no need for cast */
  ------------------
 9923|    330|  }
 9924|    110|  memcpy(ret, out, (size_t)3U * sizeof(uint8_t[128U]));
 9925|    110|}
mlkem768.c:libcrux_sha3_portable_shake256:
 3016|    330|    Eurydice_slice digest, Eurydice_slice data) {
 3017|    330|  Eurydice_slice buf0[1U] = {data};
 3018|    330|  Eurydice_slice buf[1U] = {digest};
 3019|    330|  libcrux_sha3_portable_keccakx1_ce1(buf0, buf);
 3020|    330|}
mlkem768.c:libcrux_sha3_portable_keccakx1_ce1:
 3005|    330|    Eurydice_slice data[1U], Eurydice_slice out[1U]) {
 3006|       |  /* Passing arrays by value in Rust generates a copy in C */
 3007|    330|  Eurydice_slice copy_of_data[1U];
 3008|    330|  memcpy(copy_of_data, data, (size_t)1U * sizeof(Eurydice_slice));
 3009|    330|  libcrux_sha3_generic_keccak_keccak_e91(copy_of_data, out);
 3010|    330|}
mlkem768.c:libcrux_sha3_generic_keccak_keccak_e91:
 2934|    330|    Eurydice_slice data[1U], Eurydice_slice out[1U]) {
 2935|    330|  libcrux_sha3_generic_keccak_KeccakState_48 s =
 2936|    330|      libcrux_sha3_generic_keccak_new_1e_f4();
 2937|    330|  for (size_t i = (size_t)0U;
 2938|    330|       i < Eurydice_slice_len(data[0U], uint8_t) / (size_t)136U; i++) {
  ------------------
  |  |  118|    330|#define Eurydice_slice_len(s, t) EURYDICE_SLICE_LEN(s, t)
  |  |  ------------------
  |  |  |  |   89|    330|#define EURYDICE_SLICE_LEN(s, _) s.len
  |  |  ------------------
  ------------------
  |  Branch (2938:8): [True: 0, False: 330]
  ------------------
 2939|      0|    size_t i0 = i;
 2940|      0|    libcrux_sha3_generic_keccak_KeccakState_48 *uu____0 = &s;
 2941|       |    /* Passing arrays by value in Rust generates a copy in C */
 2942|      0|    Eurydice_slice copy_of_data[1U];
 2943|      0|    memcpy(copy_of_data, data, (size_t)1U * sizeof(Eurydice_slice));
 2944|      0|    Eurydice_slice ret[1U];
 2945|      0|    libcrux_sha3_portable_keccak_slice_n_5a(copy_of_data, i0 * (size_t)136U,
 2946|      0|                                            (size_t)136U, ret);
 2947|      0|    libcrux_sha3_generic_keccak_absorb_block_df0(uu____0, ret);
 2948|      0|  }
 2949|    330|  size_t rem = Eurydice_slice_len(data[0U], uint8_t) % (size_t)136U;
  ------------------
  |  |  118|    330|#define Eurydice_slice_len(s, t) EURYDICE_SLICE_LEN(s, t)
  |  |  ------------------
  |  |  |  |   89|    330|#define EURYDICE_SLICE_LEN(s, _) s.len
  |  |  ------------------
  ------------------
 2950|    330|  libcrux_sha3_generic_keccak_KeccakState_48 *uu____2 = &s;
 2951|       |  /* Passing arrays by value in Rust generates a copy in C */
 2952|    330|  Eurydice_slice copy_of_data[1U];
 2953|    330|  memcpy(copy_of_data, data, (size_t)1U * sizeof(Eurydice_slice));
 2954|    330|  Eurydice_slice ret[1U];
 2955|    330|  libcrux_sha3_portable_keccak_slice_n_5a(
 2956|    330|      copy_of_data, Eurydice_slice_len(data[0U], uint8_t) - rem, rem, ret);
  ------------------
  |  |  118|    330|#define Eurydice_slice_len(s, t) EURYDICE_SLICE_LEN(s, t)
  |  |  ------------------
  |  |  |  |   89|    330|#define EURYDICE_SLICE_LEN(s, _) s.len
  |  |  ------------------
  ------------------
 2957|    330|  libcrux_sha3_generic_keccak_absorb_final_c71(uu____2, ret);
 2958|    330|  size_t outlen = Eurydice_slice_len(out[0U], uint8_t);
  ------------------
  |  |  118|    330|#define Eurydice_slice_len(s, t) EURYDICE_SLICE_LEN(s, t)
  |  |  ------------------
  |  |  |  |   89|    330|#define EURYDICE_SLICE_LEN(s, _) s.len
  |  |  ------------------
  ------------------
 2959|    330|  size_t blocks = outlen / (size_t)136U;
 2960|    330|  size_t last = outlen - outlen % (size_t)136U;
 2961|    330|  if (blocks == (size_t)0U) {
  ------------------
  |  Branch (2961:7): [True: 330, False: 0]
  ------------------
 2962|    330|    libcrux_sha3_generic_keccak_squeeze_first_and_last_c50(&s, out);
 2963|    330|  } else {
 2964|      0|    Eurydice_slice_uint8_t_1size_t__x2 uu____4 =
 2965|      0|        libcrux_sha3_portable_keccak_split_at_mut_n_5a(out, (size_t)136U);
 2966|      0|    Eurydice_slice o0[1U];
 2967|      0|    memcpy(o0, uu____4.fst, (size_t)1U * sizeof(Eurydice_slice));
 2968|      0|    Eurydice_slice o1[1U];
 2969|      0|    memcpy(o1, uu____4.snd, (size_t)1U * sizeof(Eurydice_slice));
 2970|      0|    libcrux_sha3_generic_keccak_squeeze_first_block_840(&s, o0);
 2971|      0|    core_ops_range_Range_b3 iter =
 2972|      0|        core_iter_traits_collect___core__iter__traits__collect__IntoIterator_for_I__1__into_iter(
  ------------------
  |  |  208|      0|  Eurydice_into_iter
  |  |  ------------------
  |  |  |  |  206|      0|#define Eurydice_into_iter(x, t, _ret_t) (x)
  |  |  ------------------
  ------------------
 2973|      0|            (CLITERAL(core_ops_range_Range_b3){.start = (size_t)1U,
 2974|      0|                                               .end = blocks}),
 2975|      0|            core_ops_range_Range_b3, core_ops_range_Range_b3);
 2976|      0|    while (true) {
  ------------------
  |  Branch (2976:12): [True: 0, Folded]
  ------------------
 2977|      0|      if (core_iter_range___core__iter__traits__iterator__Iterator_for_core__ops__range__Range_A___6__next(
  ------------------
  |  |  203|      0|  Eurydice_range_iter_next
  |  |  ------------------
  |  |  |  |  198|      0|  (((iter_ptr)->start == (iter_ptr)->end)            \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (198:4): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  199|      0|       ? (CLITERAL(ret_t){.tag = None})              \
  |  |  |  |  ------------------
  |  |  |  |  |  |   61|      0|#define CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  |  |                      ? (CLITERAL(ret_t){.tag = None})              \
  |  |  |  |  ------------------
  |  |  |  |  |  |  251|      0|#define None 0
  |  |  |  |  ------------------
  |  |  |  |  200|      0|       : (CLITERAL(ret_t){.tag = Some, .f0 = (iter_ptr)->start++}))
  |  |  |  |  ------------------
  |  |  |  |  |  |   61|      0|#define CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  |  |                      : (CLITERAL(ret_t){.tag = Some, .f0 = (iter_ptr)->start++}))
  |  |  |  |  ------------------
  |  |  |  |  |  |  252|      0|#define Some 1
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (2977:11): [True: 0, False: 0]
  ------------------
 2978|      0|              &iter, size_t, Option_b3)
 2979|      0|              .tag == None) {
  ------------------
  |  |  251|      0|#define None 0
  ------------------
 2980|      0|        break;
 2981|      0|      } else {
 2982|      0|        Eurydice_slice_uint8_t_1size_t__x2 uu____5 =
 2983|      0|            libcrux_sha3_portable_keccak_split_at_mut_n_5a(o1, (size_t)136U);
 2984|      0|        Eurydice_slice o[1U];
 2985|      0|        memcpy(o, uu____5.fst, (size_t)1U * sizeof(Eurydice_slice));
 2986|      0|        Eurydice_slice orest[1U];
 2987|      0|        memcpy(orest, uu____5.snd, (size_t)1U * sizeof(Eurydice_slice));
 2988|      0|        libcrux_sha3_generic_keccak_squeeze_next_block_fc0(&s, o);
 2989|      0|        memcpy(o1, orest, (size_t)1U * sizeof(Eurydice_slice));
 2990|      0|      }
 2991|      0|    }
 2992|      0|    if (last < outlen) {
  ------------------
  |  Branch (2992:9): [True: 0, False: 0]
  ------------------
 2993|      0|      libcrux_sha3_generic_keccak_squeeze_last_cf0(s, o1);
 2994|      0|    }
 2995|      0|  }
 2996|    330|}
mlkem768.c:libcrux_sha3_generic_keccak_absorb_block_df0:
 2585|    440|    libcrux_sha3_generic_keccak_KeccakState_48 *s, Eurydice_slice blocks[1U]) {
 2586|    440|  uint64_t(*uu____0)[5U] = s->st;
 2587|    440|  Eurydice_slice uu____1[1U];
 2588|    440|  memcpy(uu____1, blocks, (size_t)1U * sizeof(Eurydice_slice));
 2589|    440|  libcrux_sha3_portable_keccak_load_block_5a_b80(uu____0, uu____1);
 2590|    440|  libcrux_sha3_generic_keccak_keccakf1600_21(s);
 2591|    440|}
mlkem768.c:libcrux_sha3_portable_keccak_load_block_5a_b80:
 2569|    440|    uint64_t (*a)[5U], Eurydice_slice b[1U]) {
 2570|    440|  uint64_t(*uu____0)[5U] = a;
 2571|       |  /* Passing arrays by value in Rust generates a copy in C */
 2572|    440|  Eurydice_slice copy_of_b[1U];
 2573|    440|  memcpy(copy_of_b, b, (size_t)1U * sizeof(Eurydice_slice));
 2574|    440|  libcrux_sha3_portable_keccak_load_block_2c0(uu____0, copy_of_b);
 2575|    440|}
mlkem768.c:libcrux_sha3_portable_keccak_load_block_2c0:
 2541|    825|    uint64_t (*s)[5U], Eurydice_slice blocks[1U]) {
 2542|  14.8k|  for (size_t i = (size_t)0U; i < (size_t)136U / (size_t)8U; i++) {
  ------------------
  |  Branch (2542:31): [True: 14.0k, False: 825]
  ------------------
 2543|  14.0k|    size_t i0 = i;
 2544|  14.0k|    uint8_t uu____0[8U];
 2545|  14.0k|    Result_56 dst;
 2546|  14.0k|    Eurydice_slice_to_array2(
  ------------------
  |  |  152|  14.0k|  Eurydice_slice_to_array3(&(dst)->tag, (char *)&(dst)->val.case_Ok, src, \
  |  |  153|  14.0k|                           sizeof(t_arr))
  ------------------
 2547|  14.0k|        &dst,
 2548|  14.0k|        Eurydice_slice_subslice2(blocks[0U], (size_t)8U * i0,
 2549|  14.0k|                                 (size_t)8U * i0 + (size_t)8U, uint8_t),
 2550|  14.0k|        Eurydice_slice, uint8_t[8U]);
 2551|  14.0k|    unwrap_41_ac(dst, uu____0);
 2552|  14.0k|    size_t uu____1 = i0 / (size_t)5U;
 2553|  14.0k|    size_t uu____2 = i0 % (size_t)5U;
 2554|  14.0k|    s[uu____1][uu____2] =
 2555|  14.0k|        s[uu____1][uu____2] ^ core_num__u64_9__from_le_bytes(uu____0);
 2556|  14.0k|  }
 2557|    825|}
mlkem768.c:libcrux_sha3_generic_keccak_absorb_final_c71:
 2903|    330|    libcrux_sha3_generic_keccak_KeccakState_48 *s, Eurydice_slice last[1U]) {
 2904|    330|  size_t last_len = Eurydice_slice_len(last[0U], uint8_t);
  ------------------
  |  |  118|    330|#define Eurydice_slice_len(s, t) EURYDICE_SLICE_LEN(s, t)
  |  |  ------------------
  |  |  |  |   89|    330|#define EURYDICE_SLICE_LEN(s, _) s.len
  |  |  ------------------
  ------------------
 2905|    330|  uint8_t blocks[1U][200U] = {{0U}};
 2906|    660|  for (size_t i = (size_t)0U; i < (size_t)1U; i++) {
  ------------------
  |  Branch (2906:31): [True: 330, False: 330]
  ------------------
 2907|    330|    size_t i0 = i;
 2908|    330|    if (last_len > (size_t)0U) {
  ------------------
  |  Branch (2908:9): [True: 330, False: 0]
  ------------------
 2909|    330|      Eurydice_slice uu____0 = Eurydice_array_to_subslice2(
  ------------------
  |  |  113|    330|  EURYDICE_SLICE((t *)x, start, end)
  |  |  ------------------
  |  |  |  |   88|    330|  (CLITERAL(Eurydice_slice){.ptr = (void *)(x + start), .len = end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |   61|    330|#define CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2910|    330|          blocks[i0], (size_t)0U, last_len, uint8_t);
 2911|    330|      Eurydice_slice_copy(uu____0, last[i0], uint8_t);
  ------------------
  |  |  120|    330|  memcpy(dst.ptr, src.ptr, dst.len * sizeof(t))
  ------------------
 2912|    330|    }
 2913|    330|    blocks[i0][last_len] = 31U;
 2914|    330|    size_t uu____1 = i0;
 2915|    330|    size_t uu____2 = (size_t)136U - (size_t)1U;
 2916|    330|    blocks[uu____1][uu____2] = (uint32_t)blocks[uu____1][uu____2] | 128U;
 2917|    330|  }
 2918|    330|  uint64_t(*uu____3)[5U] = s->st;
 2919|    330|  uint8_t uu____4[1U][200U];
 2920|    330|  memcpy(uu____4, blocks, (size_t)1U * sizeof(uint8_t[200U]));
 2921|    330|  libcrux_sha3_portable_keccak_load_block_full_5a_d20(uu____3, uu____4);
 2922|    330|  libcrux_sha3_generic_keccak_keccakf1600_21(s);
 2923|    330|}
mlkem768.c:libcrux_sha3_portable_keccak_load_block_full_5a_d20:
 2615|    385|    uint64_t (*a)[5U], uint8_t b[1U][200U]) {
 2616|    385|  uint64_t(*uu____0)[5U] = a;
 2617|       |  /* Passing arrays by value in Rust generates a copy in C */
 2618|    385|  uint8_t copy_of_b[1U][200U];
 2619|    385|  memcpy(copy_of_b, b, (size_t)1U * sizeof(uint8_t[200U]));
 2620|    385|  libcrux_sha3_portable_keccak_load_block_full_df0(uu____0, copy_of_b);
 2621|    385|}
mlkem768.c:libcrux_sha3_portable_keccak_load_block_full_df0:
 2599|    385|    uint64_t (*s)[5U], uint8_t blocks[1U][200U]) {
 2600|    385|  Eurydice_slice buf[1U] = {
 2601|    385|      Eurydice_array_to_slice((size_t)200U, blocks[0U], uint8_t)};
  ------------------
  |  |  107|    385|  EURYDICE_SLICE(x, 0,                     \
  |  |  ------------------
  |  |  |  |   88|    385|  (CLITERAL(Eurydice_slice){.ptr = (void *)(x + start), .len = end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |   61|    385|#define CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  108|    385|                 end) /* x is already at an array type, no need for cast */
  ------------------
 2602|    385|  libcrux_sha3_portable_keccak_load_block_2c0(s, buf);
 2603|    385|}
mlkem768.c:libcrux_sha3_generic_keccak_squeeze_first_and_last_c50:
 2713|    385|    libcrux_sha3_generic_keccak_KeccakState_48 *s, Eurydice_slice out[1U]) {
 2714|    385|  uint8_t b[1U][200U];
 2715|    385|  libcrux_sha3_portable_keccak_store_block_full_5a_290(s->st, b);
 2716|    770|  for (size_t i = (size_t)0U; i < (size_t)1U; i++) {
  ------------------
  |  Branch (2716:31): [True: 385, False: 385]
  ------------------
 2717|    385|    size_t i0 = i;
 2718|    385|    Eurydice_slice uu____0 = out[i0];
 2719|    385|    uint8_t *uu____1 = b[i0];
 2720|    385|    core_ops_range_Range_b3 lit;
 2721|    385|    lit.start = (size_t)0U;
 2722|    385|    lit.end = Eurydice_slice_len(out[i0], uint8_t);
  ------------------
  |  |  118|    385|#define Eurydice_slice_len(s, t) EURYDICE_SLICE_LEN(s, t)
  |  |  ------------------
  |  |  |  |   89|    385|#define EURYDICE_SLICE_LEN(s, _) s.len
  |  |  ------------------
  ------------------
 2723|    385|    Eurydice_slice_copy(
  ------------------
  |  |  120|    385|  memcpy(dst.ptr, src.ptr, dst.len * sizeof(t))
  ------------------
 2724|    385|        uu____0,
 2725|    385|        Eurydice_array_to_subslice((size_t)200U, uu____1, lit, uint8_t,
 2726|    385|                                   core_ops_range_Range_b3),
 2727|    385|        uint8_t);
 2728|    385|  }
 2729|    385|}
mlkem768.c:libcrux_sha3_portable_keccak_store_block_full_5a_290:
 2700|    385|                                                     uint8_t ret[1U][200U]) {
 2701|    385|  libcrux_sha3_portable_keccak_store_block_full_2d0(a, ret);
 2702|    385|}
mlkem768.c:libcrux_sha3_portable_keccak_store_block_full_2d0:
 2678|    385|    uint64_t (*s)[5U], uint8_t ret[1U][200U]) {
 2679|    385|  uint8_t out[200U] = {0U};
 2680|    385|  Eurydice_slice buf[1U] = {
 2681|    385|      Eurydice_array_to_slice((size_t)200U, out, uint8_t)};
  ------------------
  |  |  107|    385|  EURYDICE_SLICE(x, 0,                     \
  |  |  ------------------
  |  |  |  |   88|    385|  (CLITERAL(Eurydice_slice){.ptr = (void *)(x + start), .len = end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |   61|    385|#define CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  108|    385|                 end) /* x is already at an array type, no need for cast */
  ------------------
 2682|    385|  libcrux_sha3_portable_keccak_store_block_580(s, buf);
 2683|       |  /* Passing arrays by value in Rust generates a copy in C */
 2684|    385|  uint8_t copy_of_out[200U];
 2685|    385|  memcpy(copy_of_out, out, (size_t)200U * sizeof(uint8_t));
 2686|    385|  memcpy(ret[0U], copy_of_out, (size_t)200U * sizeof(uint8_t));
 2687|    385|}
mlkem768.c:libcrux_sha3_portable_keccak_store_block_580:
 2660|    385|    uint64_t (*s)[5U], Eurydice_slice out[1U]) {
 2661|  6.93k|  for (size_t i = (size_t)0U; i < (size_t)136U / (size_t)8U; i++) {
  ------------------
  |  Branch (2661:31): [True: 6.54k, False: 385]
  ------------------
 2662|  6.54k|    size_t i0 = i;
 2663|  6.54k|    Eurydice_slice uu____0 = Eurydice_slice_subslice2(
  ------------------
  |  |  101|  6.54k|  EURYDICE_SLICE((t *)s.ptr, start, end)
  |  |  ------------------
  |  |  |  |   88|  6.54k|  (CLITERAL(Eurydice_slice){.ptr = (void *)(x + start), .len = end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |   61|  6.54k|#define CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2664|  6.54k|        out[0U], (size_t)8U * i0, (size_t)8U * i0 + (size_t)8U, uint8_t);
 2665|  6.54k|    uint8_t ret[8U];
 2666|  6.54k|    core_num__u64_9__to_le_bytes(s[i0 / (size_t)5U][i0 % (size_t)5U], ret);
 2667|  6.54k|    Eurydice_slice_copy(
  ------------------
  |  |  120|  6.54k|  memcpy(dst.ptr, src.ptr, dst.len * sizeof(t))
  ------------------
 2668|  6.54k|        uu____0, Eurydice_array_to_slice((size_t)8U, ret, uint8_t), uint8_t);
 2669|  6.54k|  }
 2670|    385|}
mlkem768.c:libcrux_ml_kem_sampling_sample_from_binomial_distribution_c6:
10090|    330|    Eurydice_slice randomness) {
10091|    330|  return libcrux_ml_kem_sampling_sample_from_binomial_distribution_2_85(
10092|    330|      randomness);
10093|    330|}
mlkem768.c:libcrux_ml_kem_sampling_sample_from_binomial_distribution_2_85:
 9999|    330|    Eurydice_slice randomness) {
10000|    330|  int16_t sampled_i16s[256U] = {0U};
10001|    330|  for (size_t i0 = (size_t)0U;
10002|  10.8k|       i0 < Eurydice_slice_len(randomness, uint8_t) / (size_t)4U; i0++) {
  ------------------
  |  |  118|  10.8k|#define Eurydice_slice_len(s, t) EURYDICE_SLICE_LEN(s, t)
  |  |  ------------------
  |  |  |  |   89|  10.8k|#define EURYDICE_SLICE_LEN(s, _) s.len
  |  |  ------------------
  ------------------
  |  Branch (10002:8): [True: 10.5k, False: 330]
  ------------------
10003|  10.5k|    size_t chunk_number = i0;
10004|  10.5k|    Eurydice_slice byte_chunk = Eurydice_slice_subslice2(
  ------------------
  |  |  101|  10.5k|  EURYDICE_SLICE((t *)s.ptr, start, end)
  |  |  ------------------
  |  |  |  |   88|  10.5k|  (CLITERAL(Eurydice_slice){.ptr = (void *)(x + start), .len = end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |   61|  10.5k|#define CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
10005|  10.5k|        randomness, chunk_number * (size_t)4U,
10006|  10.5k|        chunk_number * (size_t)4U + (size_t)4U, uint8_t);
10007|  10.5k|    uint32_t random_bits_as_u32 =
10008|  10.5k|        (((uint32_t)Eurydice_slice_index(byte_chunk, (size_t)0U, uint8_t,
  ------------------
  |  |   95|  10.5k|#define Eurydice_slice_index(s, i, t, t_ptr_t) (((t_ptr_t)s.ptr)[i])
  ------------------
10009|  10.5k|                                         uint8_t *) |
10010|  10.5k|          (uint32_t)Eurydice_slice_index(byte_chunk, (size_t)1U, uint8_t,
  ------------------
  |  |   95|  10.5k|#define Eurydice_slice_index(s, i, t, t_ptr_t) (((t_ptr_t)s.ptr)[i])
  ------------------
10011|  10.5k|                                         uint8_t *)
10012|  10.5k|              << 8U) |
10013|  10.5k|         (uint32_t)Eurydice_slice_index(byte_chunk, (size_t)2U, uint8_t,
  ------------------
  |  |   95|  10.5k|#define Eurydice_slice_index(s, i, t, t_ptr_t) (((t_ptr_t)s.ptr)[i])
  ------------------
10014|  10.5k|                                        uint8_t *)
10015|  10.5k|             << 16U) |
10016|  10.5k|        (uint32_t)Eurydice_slice_index(byte_chunk, (size_t)3U, uint8_t,
  ------------------
  |  |   95|  10.5k|#define Eurydice_slice_index(s, i, t, t_ptr_t) (((t_ptr_t)s.ptr)[i])
  ------------------
10017|  10.5k|                                       uint8_t *)
10018|  10.5k|            << 24U;
10019|  10.5k|    uint32_t even_bits = random_bits_as_u32 & 1431655765U;
10020|  10.5k|    uint32_t odd_bits = random_bits_as_u32 >> 1U & 1431655765U;
10021|  10.5k|    uint32_t coin_toss_outcomes = even_bits + odd_bits;
10022|  95.0k|    for (uint32_t i = 0U; i < CORE_NUM__U32_8__BITS / 4U; i++) {
  ------------------
  |  |  268|  95.0k|#define CORE_NUM__U32_8__BITS (32U)
  ------------------
  |  Branch (10022:27): [True: 84.4k, False: 10.5k]
  ------------------
10023|  84.4k|      uint32_t outcome_set = i;
10024|  84.4k|      uint32_t outcome_set0 = outcome_set * 4U;
10025|  84.4k|      int16_t outcome_1 =
10026|  84.4k|          (int16_t)(coin_toss_outcomes >> (uint32_t)outcome_set0 & 3U);
10027|  84.4k|      int16_t outcome_2 =
10028|  84.4k|          (int16_t)(coin_toss_outcomes >> (uint32_t)(outcome_set0 + 2U) & 3U);
10029|  84.4k|      size_t offset = (size_t)(outcome_set0 >> 2U);
10030|  84.4k|      sampled_i16s[(size_t)8U * chunk_number + offset] = outcome_1 - outcome_2;
10031|  84.4k|    }
10032|  10.5k|  }
10033|    330|  return libcrux_ml_kem_polynomial_from_i16_array_89_c1(
10034|    330|      Eurydice_array_to_slice((size_t)256U, sampled_i16s, int16_t));
  ------------------
  |  |  107|    330|  EURYDICE_SLICE(x, 0,                     \
  |  |  ------------------
  |  |  |  |   88|    330|  (CLITERAL(Eurydice_slice){.ptr = (void *)(x + start), .len = end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |   61|    330|#define CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  108|    330|                 end) /* x is already at an array type, no need for cast */
  ------------------
10035|    330|}
mlkem768.c:libcrux_ml_kem_ntt_ntt_binomially_sampled_ring_element_0f:
10125|    330|    libcrux_ml_kem_polynomial_PolynomialRingElement_f0 *re) {
10126|    330|  libcrux_ml_kem_ntt_ntt_at_layer_7_f4(re);
10127|    330|  size_t zeta_i = (size_t)1U;
10128|    330|  libcrux_ml_kem_ntt_ntt_at_layer_4_plus_51(&zeta_i, re, (size_t)6U,
10129|    330|                                            (size_t)3U);
10130|    330|  libcrux_ml_kem_ntt_ntt_at_layer_4_plus_51(&zeta_i, re, (size_t)5U,
10131|    330|                                            (size_t)3U);
10132|    330|  libcrux_ml_kem_ntt_ntt_at_layer_4_plus_51(&zeta_i, re, (size_t)4U,
10133|    330|                                            (size_t)3U);
10134|    330|  libcrux_ml_kem_ntt_ntt_at_layer_3_fd(&zeta_i, re, (size_t)3U, (size_t)3U);
10135|    330|  libcrux_ml_kem_ntt_ntt_at_layer_2_ad(&zeta_i, re, (size_t)2U, (size_t)3U);
10136|    330|  libcrux_ml_kem_ntt_ntt_at_layer_1_a2(&zeta_i, re, (size_t)1U, (size_t)3U);
10137|    330|  libcrux_ml_kem_polynomial_poly_barrett_reduce_89_8b(re);
10138|    330|}
mlkem768.c:libcrux_ml_kem_ntt_ntt_at_layer_7_f4:
10102|    330|    libcrux_ml_kem_polynomial_PolynomialRingElement_f0 *re) {
10103|    330|  size_t step = LIBCRUX_ML_KEM_POLYNOMIAL_VECTORS_IN_RING_ELEMENT / (size_t)2U;
  ------------------
  |  | 5860|    330|  (LIBCRUX_ML_KEM_CONSTANTS_COEFFICIENTS_IN_RING_ELEMENT / \
  |  |  ------------------
  |  |  |  |  282|    330|#define LIBCRUX_ML_KEM_CONSTANTS_COEFFICIENTS_IN_RING_ELEMENT ((size_t)256U)
  |  |  ------------------
  |  | 5861|    330|   LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_ELEMENTS_IN_VECTOR)
  |  |  ------------------
  |  |  |  | 5857|    330|#define LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_ELEMENTS_IN_VECTOR ((size_t)16U)
  |  |  ------------------
  ------------------
10104|  2.97k|  for (size_t i = (size_t)0U; i < step; i++) {
  ------------------
  |  Branch (10104:31): [True: 2.64k, False: 330]
  ------------------
10105|  2.64k|    size_t j = i;
10106|  2.64k|    libcrux_ml_kem_vector_portable_vector_type_PortableVector t =
10107|  2.64k|        libcrux_ml_kem_vector_portable_multiply_by_constant_0d(
10108|  2.64k|            re->coefficients[j + step], (int16_t)-1600);
10109|  2.64k|    re->coefficients[j + step] =
10110|  2.64k|        libcrux_ml_kem_vector_portable_sub_0d(re->coefficients[j], &t);
10111|  2.64k|    libcrux_ml_kem_vector_portable_vector_type_PortableVector uu____1 =
10112|  2.64k|        libcrux_ml_kem_vector_portable_add_0d(re->coefficients[j], &t);
10113|  2.64k|    re->coefficients[j] = uu____1;
10114|  2.64k|  }
10115|    330|}
mlkem768.c:libcrux_ml_kem_vector_portable_multiply_by_constant_0d:
 6771|  2.64k|    libcrux_ml_kem_vector_portable_vector_type_PortableVector v, int16_t c) {
 6772|  2.64k|  return libcrux_ml_kem_vector_portable_arithmetic_multiply_by_constant(v, c);
 6773|  2.64k|}
mlkem768.c:libcrux_ml_kem_vector_portable_arithmetic_multiply_by_constant:
 6755|  2.64k|    libcrux_ml_kem_vector_portable_vector_type_PortableVector v, int16_t c) {
 6756|  2.64k|  for (size_t i = (size_t)0U;
 6757|  44.8k|       i < LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_ELEMENTS_IN_VECTOR; i++) {
  ------------------
  |  | 5857|  44.8k|#define LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_ELEMENTS_IN_VECTOR ((size_t)16U)
  ------------------
  |  Branch (6757:8): [True: 42.2k, False: 2.64k]
  ------------------
 6758|  42.2k|    size_t i0 = i;
 6759|  42.2k|    size_t uu____0 = i0;
 6760|  42.2k|    v.elements[uu____0] = v.elements[uu____0] * c;
 6761|  42.2k|  }
 6762|  2.64k|  return v;
 6763|  2.64k|}
mlkem768.c:libcrux_ml_kem_vector_portable_sub_0d:
 6749|  10.5k|    libcrux_ml_kem_vector_portable_vector_type_PortableVector *rhs) {
 6750|  10.5k|  return libcrux_ml_kem_vector_portable_arithmetic_sub(lhs, rhs);
 6751|  10.5k|}
mlkem768.c:libcrux_ml_kem_vector_portable_arithmetic_sub:
 6732|  10.5k|    libcrux_ml_kem_vector_portable_vector_type_PortableVector *rhs) {
 6733|  10.5k|  for (size_t i = (size_t)0U;
 6734|   179k|       i < LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_ELEMENTS_IN_VECTOR; i++) {
  ------------------
  |  | 5857|   179k|#define LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_ELEMENTS_IN_VECTOR ((size_t)16U)
  ------------------
  |  Branch (6734:8): [True: 168k, False: 10.5k]
  ------------------
 6735|   168k|    size_t i0 = i;
 6736|   168k|    size_t uu____0 = i0;
 6737|   168k|    lhs.elements[uu____0] = lhs.elements[uu____0] - rhs->elements[i0];
 6738|   168k|  }
 6739|  10.5k|  return lhs;
 6740|  10.5k|}
mlkem768.c:libcrux_ml_kem_vector_portable_add_0d:
 6725|  26.4k|    libcrux_ml_kem_vector_portable_vector_type_PortableVector *rhs) {
 6726|  26.4k|  return libcrux_ml_kem_vector_portable_arithmetic_add(lhs, rhs);
 6727|  26.4k|}
mlkem768.c:libcrux_ml_kem_vector_portable_arithmetic_add:
 6708|  26.4k|    libcrux_ml_kem_vector_portable_vector_type_PortableVector *rhs) {
 6709|  26.4k|  for (size_t i = (size_t)0U;
 6710|   448k|       i < LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_ELEMENTS_IN_VECTOR; i++) {
  ------------------
  |  | 5857|   448k|#define LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_ELEMENTS_IN_VECTOR ((size_t)16U)
  ------------------
  |  Branch (6710:8): [True: 422k, False: 26.4k]
  ------------------
 6711|   422k|    size_t i0 = i;
 6712|   422k|    size_t uu____0 = i0;
 6713|   422k|    lhs.elements[uu____0] = lhs.elements[uu____0] + rhs->elements[i0];
 6714|   422k|  }
 6715|  26.4k|  return lhs;
 6716|  26.4k|}
mlkem768.c:libcrux_ml_kem_ntt_ntt_at_layer_4_plus_51:
 8497|    990|    size_t layer, size_t _initial_coefficient_bound) {
 8498|    990|  size_t step = (size_t)1U << (uint32_t)layer;
 8499|  5.61k|  for (size_t i0 = (size_t)0U; i0 < (size_t)128U >> (uint32_t)layer; i0++) {
  ------------------
  |  Branch (8499:32): [True: 4.62k, False: 990]
  ------------------
 8500|  4.62k|    size_t round = i0;
 8501|  4.62k|    zeta_i[0U] = zeta_i[0U] + (size_t)1U;
 8502|  4.62k|    size_t offset = round * step * (size_t)2U;
 8503|  4.62k|    size_t offset_vec = offset / (size_t)16U;
 8504|  4.62k|    size_t step_vec = step / (size_t)16U;
 8505|  12.5k|    for (size_t i = offset_vec; i < offset_vec + step_vec; i++) {
  ------------------
  |  Branch (8505:33): [True: 7.92k, False: 4.62k]
  ------------------
 8506|  7.92k|      size_t j = i;
 8507|  7.92k|      libcrux_ml_kem_vector_portable_vector_type_PortableVector_x2 uu____0 =
 8508|  7.92k|          libcrux_ml_kem_ntt_ntt_layer_int_vec_step_0c(
 8509|  7.92k|              re->coefficients[j], re->coefficients[j + step_vec],
 8510|  7.92k|              libcrux_ml_kem_polynomial_ZETAS_TIMES_MONTGOMERY_R[zeta_i[0U]]);
 8511|  7.92k|      libcrux_ml_kem_vector_portable_vector_type_PortableVector x = uu____0.fst;
 8512|  7.92k|      libcrux_ml_kem_vector_portable_vector_type_PortableVector y = uu____0.snd;
 8513|  7.92k|      re->coefficients[j] = x;
 8514|  7.92k|      re->coefficients[j + step_vec] = y;
 8515|  7.92k|    }
 8516|  4.62k|  }
 8517|    990|}
mlkem768.c:libcrux_ml_kem_ntt_ntt_layer_int_vec_step_0c:
 8479|  7.92k|        int16_t zeta_r) {
 8480|  7.92k|  libcrux_ml_kem_vector_portable_vector_type_PortableVector t =
 8481|  7.92k|      libcrux_ml_kem_vector_traits_montgomery_multiply_fe_67(b, zeta_r);
 8482|  7.92k|  b = libcrux_ml_kem_vector_portable_sub_0d(a, &t);
 8483|  7.92k|  a = libcrux_ml_kem_vector_portable_add_0d(a, &t);
 8484|  7.92k|  return (
 8485|  7.92k|      CLITERAL(libcrux_ml_kem_vector_portable_vector_type_PortableVector_x2){
  ------------------
  |  |   61|  7.92k|#define CLITERAL(type) (type)
  ------------------
 8486|  7.92k|          .fst = a, .snd = b});
 8487|  7.92k|}
mlkem768.c:libcrux_ml_kem_vector_traits_montgomery_multiply_fe_67:
 8463|  7.92k|    libcrux_ml_kem_vector_portable_vector_type_PortableVector v, int16_t fer) {
 8464|  7.92k|  return libcrux_ml_kem_vector_portable_montgomery_multiply_by_constant_0d(v,
 8465|  7.92k|                                                                           fer);
 8466|  7.92k|}
mlkem768.c:libcrux_ml_kem_vector_portable_montgomery_multiply_by_constant_0d:
 6967|  10.5k|    libcrux_ml_kem_vector_portable_vector_type_PortableVector v, int16_t r) {
 6968|  10.5k|  return libcrux_ml_kem_vector_portable_arithmetic_montgomery_multiply_by_constant(
 6969|  10.5k|      v, r);
 6970|  10.5k|}
mlkem768.c:libcrux_ml_kem_vector_portable_arithmetic_montgomery_multiply_by_constant:
 6950|  10.5k|    libcrux_ml_kem_vector_portable_vector_type_PortableVector v, int16_t c) {
 6951|  10.5k|  for (size_t i = (size_t)0U;
 6952|   179k|       i < LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_ELEMENTS_IN_VECTOR; i++) {
  ------------------
  |  | 5857|   179k|#define LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_ELEMENTS_IN_VECTOR ((size_t)16U)
  ------------------
  |  Branch (6952:8): [True: 168k, False: 10.5k]
  ------------------
 6953|   168k|    size_t i0 = i;
 6954|   168k|    v.elements[i0] =
 6955|   168k|        libcrux_ml_kem_vector_portable_arithmetic_montgomery_multiply_fe_by_fer(
 6956|   168k|            v.elements[i0], c);
 6957|   168k|  }
 6958|  10.5k|  return v;
 6959|  10.5k|}
mlkem768.c:libcrux_ml_kem_vector_portable_arithmetic_montgomery_multiply_fe_by_fer:
 6943|   295k|    int16_t fe, int16_t fer) {
 6944|   295k|  return libcrux_ml_kem_vector_portable_arithmetic_montgomery_reduce_element(
 6945|   295k|      (int32_t)fe * (int32_t)fer);
 6946|   295k|}
mlkem768.c:libcrux_ml_kem_vector_portable_arithmetic_montgomery_reduce_element:
 6913|   485k|    int32_t value) {
 6914|   485k|  int32_t k =
 6915|   485k|      (int32_t)(int16_t)value *
 6916|   485k|      (int32_t)LIBCRUX_ML_KEM_VECTOR_TRAITS_INVERSE_OF_MODULUS_MOD_MONTGOMERY_R;
  ------------------
  |  | 5869|   485k|  (62209U)
  ------------------
 6917|   485k|  int32_t k_times_modulus =
 6918|   485k|      (int32_t)(int16_t)k * (int32_t)LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_MODULUS;
  ------------------
  |  | 5863|   485k|#define LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_MODULUS ((int16_t)3329)
  ------------------
 6919|   485k|  int16_t c =
 6920|   485k|      (int16_t)(k_times_modulus >>
 6921|   485k|                (uint32_t)
 6922|   485k|                    LIBCRUX_ML_KEM_VECTOR_PORTABLE_ARITHMETIC_MONTGOMERY_SHIFT);
  ------------------
  |  | 6891|   485k|#define LIBCRUX_ML_KEM_VECTOR_PORTABLE_ARITHMETIC_MONTGOMERY_SHIFT (16U)
  ------------------
 6923|   485k|  int16_t value_high =
 6924|   485k|      (int16_t)(value >>
 6925|   485k|                (uint32_t)
 6926|   485k|                    LIBCRUX_ML_KEM_VECTOR_PORTABLE_ARITHMETIC_MONTGOMERY_SHIFT);
  ------------------
  |  | 6891|   485k|#define LIBCRUX_ML_KEM_VECTOR_PORTABLE_ARITHMETIC_MONTGOMERY_SHIFT (16U)
  ------------------
 6927|   485k|  return value_high - c;
 6928|   485k|}
mlkem768.c:libcrux_ml_kem_ntt_ntt_at_layer_3_fd:
 8527|    330|    size_t _layer, size_t _initial_coefficient_bound) {
 8528|  5.61k|  for (size_t i = (size_t)0U; i < (size_t)16U; i++) {
  ------------------
  |  Branch (8528:31): [True: 5.28k, False: 330]
  ------------------
 8529|  5.28k|    size_t round = i;
 8530|  5.28k|    zeta_i[0U] = zeta_i[0U] + (size_t)1U;
 8531|  5.28k|    libcrux_ml_kem_vector_portable_vector_type_PortableVector uu____0 =
 8532|  5.28k|        libcrux_ml_kem_vector_portable_ntt_layer_3_step_0d(
 8533|  5.28k|            re->coefficients[round],
 8534|  5.28k|            libcrux_ml_kem_polynomial_ZETAS_TIMES_MONTGOMERY_R[zeta_i[0U]]);
 8535|  5.28k|    re->coefficients[round] = uu____0;
 8536|  5.28k|  }
 8537|    330|}
mlkem768.c:libcrux_ml_kem_vector_portable_ntt_layer_3_step_0d:
 7150|  5.28k|    libcrux_ml_kem_vector_portable_vector_type_PortableVector a, int16_t zeta) {
 7151|  5.28k|  return libcrux_ml_kem_vector_portable_ntt_ntt_layer_3_step(a, zeta);
 7152|  5.28k|}
mlkem768.c:libcrux_ml_kem_vector_portable_ntt_ntt_layer_3_step:
 7126|  5.28k|    libcrux_ml_kem_vector_portable_vector_type_PortableVector v, int16_t zeta) {
 7127|  5.28k|  libcrux_ml_kem_vector_portable_ntt_ntt_step(&v, zeta, (size_t)0U, (size_t)8U);
 7128|  5.28k|  libcrux_ml_kem_vector_portable_ntt_ntt_step(&v, zeta, (size_t)1U, (size_t)9U);
 7129|  5.28k|  libcrux_ml_kem_vector_portable_ntt_ntt_step(&v, zeta, (size_t)2U,
 7130|  5.28k|                                              (size_t)10U);
 7131|  5.28k|  libcrux_ml_kem_vector_portable_ntt_ntt_step(&v, zeta, (size_t)3U,
 7132|  5.28k|                                              (size_t)11U);
 7133|  5.28k|  libcrux_ml_kem_vector_portable_ntt_ntt_step(&v, zeta, (size_t)4U,
 7134|  5.28k|                                              (size_t)12U);
 7135|  5.28k|  libcrux_ml_kem_vector_portable_ntt_ntt_step(&v, zeta, (size_t)5U,
 7136|  5.28k|                                              (size_t)13U);
 7137|  5.28k|  libcrux_ml_kem_vector_portable_ntt_ntt_step(&v, zeta, (size_t)6U,
 7138|  5.28k|                                              (size_t)14U);
 7139|  5.28k|  libcrux_ml_kem_vector_portable_ntt_ntt_step(&v, zeta, (size_t)7U,
 7140|  5.28k|                                              (size_t)15U);
 7141|  5.28k|  return v;
 7142|  5.28k|}
mlkem768.c:libcrux_ml_kem_vector_portable_ntt_ntt_step:
 7047|   126k|    size_t i, size_t j) {
 7048|   126k|  int16_t t =
 7049|   126k|      libcrux_ml_kem_vector_portable_arithmetic_montgomery_multiply_fe_by_fer(
 7050|   126k|          v->elements[j], zeta);
 7051|   126k|  v->elements[j] = v->elements[i] - t;
 7052|   126k|  v->elements[i] = v->elements[i] + t;
 7053|   126k|}
mlkem768.c:libcrux_ml_kem_ntt_ntt_at_layer_2_ad:
 8547|    330|    size_t _layer, size_t _initial_coefficient_bound) {
 8548|  5.61k|  for (size_t i = (size_t)0U; i < (size_t)16U; i++) {
  ------------------
  |  Branch (8548:31): [True: 5.28k, False: 330]
  ------------------
 8549|  5.28k|    size_t round = i;
 8550|  5.28k|    zeta_i[0U] = zeta_i[0U] + (size_t)1U;
 8551|  5.28k|    re->coefficients[round] =
 8552|  5.28k|        libcrux_ml_kem_vector_portable_ntt_layer_2_step_0d(
 8553|  5.28k|            re->coefficients[round],
 8554|  5.28k|            libcrux_ml_kem_polynomial_ZETAS_TIMES_MONTGOMERY_R[zeta_i[0U]],
 8555|  5.28k|            libcrux_ml_kem_polynomial_ZETAS_TIMES_MONTGOMERY_R[zeta_i[0U] +
 8556|  5.28k|                                                               (size_t)1U]);
 8557|  5.28k|    zeta_i[0U] = zeta_i[0U] + (size_t)1U;
 8558|  5.28k|  }
 8559|    330|}
mlkem768.c:libcrux_ml_kem_vector_portable_ntt_layer_2_step_0d:
 7120|  5.28k|    int16_t zeta1) {
 7121|  5.28k|  return libcrux_ml_kem_vector_portable_ntt_ntt_layer_2_step(a, zeta0, zeta1);
 7122|  5.28k|}
mlkem768.c:libcrux_ml_kem_vector_portable_ntt_ntt_layer_2_step:
 7093|  5.28k|    int16_t zeta1) {
 7094|  5.28k|  libcrux_ml_kem_vector_portable_ntt_ntt_step(&v, zeta0, (size_t)0U,
 7095|  5.28k|                                              (size_t)4U);
 7096|  5.28k|  libcrux_ml_kem_vector_portable_ntt_ntt_step(&v, zeta0, (size_t)1U,
 7097|  5.28k|                                              (size_t)5U);
 7098|  5.28k|  libcrux_ml_kem_vector_portable_ntt_ntt_step(&v, zeta0, (size_t)2U,
 7099|  5.28k|                                              (size_t)6U);
 7100|  5.28k|  libcrux_ml_kem_vector_portable_ntt_ntt_step(&v, zeta0, (size_t)3U,
 7101|  5.28k|                                              (size_t)7U);
 7102|  5.28k|  libcrux_ml_kem_vector_portable_ntt_ntt_step(&v, zeta1, (size_t)8U,
 7103|  5.28k|                                              (size_t)12U);
 7104|  5.28k|  libcrux_ml_kem_vector_portable_ntt_ntt_step(&v, zeta1, (size_t)9U,
 7105|  5.28k|                                              (size_t)13U);
 7106|  5.28k|  libcrux_ml_kem_vector_portable_ntt_ntt_step(&v, zeta1, (size_t)10U,
 7107|  5.28k|                                              (size_t)14U);
 7108|  5.28k|  libcrux_ml_kem_vector_portable_ntt_ntt_step(&v, zeta1, (size_t)11U,
 7109|  5.28k|                                              (size_t)15U);
 7110|  5.28k|  return v;
 7111|  5.28k|}
mlkem768.c:libcrux_ml_kem_ntt_ntt_at_layer_1_a2:
 8569|    330|    size_t _layer, size_t _initial_coefficient_bound) {
 8570|  5.61k|  for (size_t i = (size_t)0U; i < (size_t)16U; i++) {
  ------------------
  |  Branch (8570:31): [True: 5.28k, False: 330]
  ------------------
 8571|  5.28k|    size_t round = i;
 8572|  5.28k|    zeta_i[0U] = zeta_i[0U] + (size_t)1U;
 8573|  5.28k|    re->coefficients[round] =
 8574|  5.28k|        libcrux_ml_kem_vector_portable_ntt_layer_1_step_0d(
 8575|  5.28k|            re->coefficients[round],
 8576|  5.28k|            libcrux_ml_kem_polynomial_ZETAS_TIMES_MONTGOMERY_R[zeta_i[0U]],
 8577|  5.28k|            libcrux_ml_kem_polynomial_ZETAS_TIMES_MONTGOMERY_R[zeta_i[0U] +
 8578|  5.28k|                                                               (size_t)1U],
 8579|  5.28k|            libcrux_ml_kem_polynomial_ZETAS_TIMES_MONTGOMERY_R[zeta_i[0U] +
 8580|  5.28k|                                                               (size_t)2U],
 8581|  5.28k|            libcrux_ml_kem_polynomial_ZETAS_TIMES_MONTGOMERY_R[zeta_i[0U] +
 8582|  5.28k|                                                               (size_t)3U]);
 8583|  5.28k|    zeta_i[0U] = zeta_i[0U] + (size_t)3U;
 8584|  5.28k|  }
 8585|    330|}
mlkem768.c:libcrux_ml_kem_vector_portable_ntt_layer_1_step_0d:
 7085|  5.28k|    int16_t zeta1, int16_t zeta2, int16_t zeta3) {
 7086|  5.28k|  return libcrux_ml_kem_vector_portable_ntt_ntt_layer_1_step(a, zeta0, zeta1,
 7087|  5.28k|                                                             zeta2, zeta3);
 7088|  5.28k|}
mlkem768.c:libcrux_ml_kem_vector_portable_ntt_ntt_layer_1_step:
 7058|  5.28k|    int16_t zeta1, int16_t zeta2, int16_t zeta3) {
 7059|  5.28k|  libcrux_ml_kem_vector_portable_ntt_ntt_step(&v, zeta0, (size_t)0U,
 7060|  5.28k|                                              (size_t)2U);
 7061|  5.28k|  libcrux_ml_kem_vector_portable_ntt_ntt_step(&v, zeta0, (size_t)1U,
 7062|  5.28k|                                              (size_t)3U);
 7063|  5.28k|  libcrux_ml_kem_vector_portable_ntt_ntt_step(&v, zeta1, (size_t)4U,
 7064|  5.28k|                                              (size_t)6U);
 7065|  5.28k|  libcrux_ml_kem_vector_portable_ntt_ntt_step(&v, zeta1, (size_t)5U,
 7066|  5.28k|                                              (size_t)7U);
 7067|  5.28k|  libcrux_ml_kem_vector_portable_ntt_ntt_step(&v, zeta2, (size_t)8U,
 7068|  5.28k|                                              (size_t)10U);
 7069|  5.28k|  libcrux_ml_kem_vector_portable_ntt_ntt_step(&v, zeta2, (size_t)9U,
 7070|  5.28k|                                              (size_t)11U);
 7071|  5.28k|  libcrux_ml_kem_vector_portable_ntt_ntt_step(&v, zeta3, (size_t)12U,
 7072|  5.28k|                                              (size_t)14U);
 7073|  5.28k|  libcrux_ml_kem_vector_portable_ntt_ntt_step(&v, zeta3, (size_t)13U,
 7074|  5.28k|                                              (size_t)15U);
 7075|  5.28k|  return v;
 7076|  5.28k|}
mlkem768.c:libcrux_ml_kem_polynomial_poly_barrett_reduce_89_8b:
 8598|    330|    libcrux_ml_kem_polynomial_PolynomialRingElement_f0 *self) {
 8599|    330|  for (size_t i = (size_t)0U;
 8600|  5.61k|       i < LIBCRUX_ML_KEM_POLYNOMIAL_VECTORS_IN_RING_ELEMENT; i++) {
  ------------------
  |  | 5860|  5.61k|  (LIBCRUX_ML_KEM_CONSTANTS_COEFFICIENTS_IN_RING_ELEMENT / \
  |  |  ------------------
  |  |  |  |  282|  5.61k|#define LIBCRUX_ML_KEM_CONSTANTS_COEFFICIENTS_IN_RING_ELEMENT ((size_t)256U)
  |  |  ------------------
  |  | 5861|  5.61k|   LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_ELEMENTS_IN_VECTOR)
  |  |  ------------------
  |  |  |  | 5857|  5.61k|#define LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_ELEMENTS_IN_VECTOR ((size_t)16U)
  |  |  ------------------
  ------------------
  |  Branch (8600:8): [True: 5.28k, False: 330]
  ------------------
 8601|  5.28k|    size_t i0 = i;
 8602|  5.28k|    libcrux_ml_kem_vector_portable_vector_type_PortableVector uu____0 =
 8603|  5.28k|        libcrux_ml_kem_vector_portable_barrett_reduce_0d(
 8604|  5.28k|            self->coefficients[i0]);
 8605|  5.28k|    self->coefficients[i0] = uu____0;
 8606|  5.28k|  }
 8607|    330|}
mlkem768.c:libcrux_ml_kem_vector_portable_barrett_reduce_0d:
 6887|  7.92k|    libcrux_ml_kem_vector_portable_vector_type_PortableVector v) {
 6888|  7.92k|  return libcrux_ml_kem_vector_portable_arithmetic_barrett_reduce(v);
 6889|  7.92k|}
mlkem768.c:libcrux_ml_kem_vector_portable_arithmetic_barrett_reduce:
 6870|  7.92k|    libcrux_ml_kem_vector_portable_vector_type_PortableVector v) {
 6871|  7.92k|  for (size_t i = (size_t)0U;
 6872|   134k|       i < LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_ELEMENTS_IN_VECTOR; i++) {
  ------------------
  |  | 5857|   134k|#define LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_ELEMENTS_IN_VECTOR ((size_t)16U)
  ------------------
  |  Branch (6872:8): [True: 126k, False: 7.92k]
  ------------------
 6873|   126k|    size_t i0 = i;
 6874|   126k|    v.elements[i0] =
 6875|   126k|        libcrux_ml_kem_vector_portable_arithmetic_barrett_reduce_element(
 6876|   126k|            v.elements[i0]);
 6877|   126k|  }
 6878|  7.92k|  return v;
 6879|  7.92k|}
mlkem768.c:libcrux_ml_kem_vector_portable_arithmetic_barrett_reduce_element:
 6857|   126k|    int16_t value) {
 6858|   126k|  int32_t t = (int32_t)value *
 6859|   126k|                  LIBCRUX_ML_KEM_VECTOR_PORTABLE_ARITHMETIC_BARRETT_MULTIPLIER +
  ------------------
  |  | 6834|   126k|  ((int32_t)20159)
  ------------------
 6860|   126k|              (LIBCRUX_ML_KEM_VECTOR_PORTABLE_ARITHMETIC_BARRETT_R >> 1U);
  ------------------
  |  | 6839|   126k|  ((int32_t)1 << (uint32_t)                                 \
  |  | 6840|   126k|       LIBCRUX_ML_KEM_VECTOR_PORTABLE_ARITHMETIC_BARRETT_SHIFT)
  |  |  ------------------
  |  |  |  | 6836|   126k|#define LIBCRUX_ML_KEM_VECTOR_PORTABLE_ARITHMETIC_BARRETT_SHIFT ((int32_t)26)
  |  |  ------------------
  ------------------
 6861|   126k|  int16_t quotient =
 6862|   126k|      (int16_t)(t >>
 6863|   126k|                (uint32_t)
 6864|   126k|                    LIBCRUX_ML_KEM_VECTOR_PORTABLE_ARITHMETIC_BARRETT_SHIFT);
  ------------------
  |  | 6836|   126k|#define LIBCRUX_ML_KEM_VECTOR_PORTABLE_ARITHMETIC_BARRETT_SHIFT ((int32_t)26)
  ------------------
 6865|   126k|  return value - quotient * LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_MODULUS;
  ------------------
  |  | 5863|   126k|#define LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_MODULUS ((int16_t)3329)
  ------------------
 6866|   126k|}
mlkem768.c:libcrux_ml_kem_matrix_compute_As_plus_e_60:
11278|     55|    libcrux_ml_kem_polynomial_PolynomialRingElement_f0 ret[3U]) {
11279|     55|  libcrux_ml_kem_polynomial_PolynomialRingElement_f0 result[3U];
11280|    220|  for (size_t i = (size_t)0U; i < (size_t)3U; i++) {
  ------------------
  |  Branch (11280:31): [True: 165, False: 55]
  ------------------
11281|    165|    result[i] = libcrux_ml_kem_polynomial_ZERO_89_ea();
11282|    165|  }
11283|     55|  for (size_t i0 = (size_t)0U;
11284|    220|       i0 < Eurydice_slice_len(
  ------------------
  |  |  118|    220|#define Eurydice_slice_len(s, t) EURYDICE_SLICE_LEN(s, t)
  |  |  ------------------
  |  |  |  |   89|    220|#define EURYDICE_SLICE_LEN(s, _) s.len
  |  |  ------------------
  ------------------
  |  Branch (11284:8): [True: 165, False: 55]
  ------------------
11285|     55|                Eurydice_array_to_slice(
11286|     55|                    (size_t)3U, matrix_A,
11287|     55|                    libcrux_ml_kem_polynomial_PolynomialRingElement_f0[3U]),
11288|     55|                libcrux_ml_kem_polynomial_PolynomialRingElement_f0[3U]);
11289|    165|       i0++) {
11290|    165|    size_t i1 = i0;
11291|    165|    libcrux_ml_kem_polynomial_PolynomialRingElement_f0 *row = matrix_A[i1];
11292|    165|    for (size_t i = (size_t)0U;
11293|    660|         i < Eurydice_slice_len(
  ------------------
  |  |  118|    660|#define Eurydice_slice_len(s, t) EURYDICE_SLICE_LEN(s, t)
  |  |  ------------------
  |  |  |  |   89|    660|#define EURYDICE_SLICE_LEN(s, _) s.len
  |  |  ------------------
  ------------------
  |  Branch (11293:10): [True: 495, False: 165]
  ------------------
11294|    165|                 Eurydice_array_to_slice(
11295|    165|                     (size_t)3U, row,
11296|    165|                     libcrux_ml_kem_polynomial_PolynomialRingElement_f0),
11297|    165|                 libcrux_ml_kem_polynomial_PolynomialRingElement_f0);
11298|    495|         i++) {
11299|    495|      size_t j = i;
11300|    495|      libcrux_ml_kem_polynomial_PolynomialRingElement_f0 *matrix_element =
11301|    495|          &row[j];
11302|    495|      libcrux_ml_kem_polynomial_PolynomialRingElement_f0 product =
11303|    495|          libcrux_ml_kem_polynomial_ntt_multiply_89_2a(matrix_element,
11304|    495|                                                       &s_as_ntt[j]);
11305|    495|      libcrux_ml_kem_polynomial_add_to_ring_element_89_84(&result[i1],
11306|    495|                                                          &product);
11307|    495|    }
11308|    165|    libcrux_ml_kem_polynomial_add_standard_error_reduce_89_03(
11309|    165|        &result[i1], &error_as_ntt[i1]);
11310|    165|  }
11311|     55|  memcpy(
11312|     55|      ret, result,
11313|     55|      (size_t)3U * sizeof(libcrux_ml_kem_polynomial_PolynomialRingElement_f0));
11314|     55|}
mlkem768.c:libcrux_ml_kem_polynomial_ntt_multiply_89_2a:
 8859|    495|    libcrux_ml_kem_polynomial_PolynomialRingElement_f0 *rhs) {
 8860|    495|  libcrux_ml_kem_polynomial_PolynomialRingElement_f0 out =
 8861|    495|      libcrux_ml_kem_polynomial_ZERO_89_ea();
 8862|    495|  for (size_t i = (size_t)0U;
 8863|  8.41k|       i < LIBCRUX_ML_KEM_POLYNOMIAL_VECTORS_IN_RING_ELEMENT; i++) {
  ------------------
  |  | 5860|  8.41k|  (LIBCRUX_ML_KEM_CONSTANTS_COEFFICIENTS_IN_RING_ELEMENT / \
  |  |  ------------------
  |  |  |  |  282|  8.41k|#define LIBCRUX_ML_KEM_CONSTANTS_COEFFICIENTS_IN_RING_ELEMENT ((size_t)256U)
  |  |  ------------------
  |  | 5861|  8.41k|   LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_ELEMENTS_IN_VECTOR)
  |  |  ------------------
  |  |  |  | 5857|  8.41k|#define LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_ELEMENTS_IN_VECTOR ((size_t)16U)
  |  |  ------------------
  ------------------
  |  Branch (8863:8): [True: 7.92k, False: 495]
  ------------------
 8864|  7.92k|    size_t i0 = i;
 8865|  7.92k|    libcrux_ml_kem_vector_portable_vector_type_PortableVector uu____0 =
 8866|  7.92k|        libcrux_ml_kem_vector_portable_ntt_multiply_0d(
 8867|  7.92k|            &self->coefficients[i0], &rhs->coefficients[i0],
 8868|  7.92k|            libcrux_ml_kem_polynomial_ZETAS_TIMES_MONTGOMERY_R[(size_t)64U +
 8869|  7.92k|                                                               (size_t)4U * i0],
 8870|  7.92k|            libcrux_ml_kem_polynomial_ZETAS_TIMES_MONTGOMERY_R[(size_t)64U +
 8871|  7.92k|                                                               (size_t)4U * i0 +
 8872|  7.92k|                                                               (size_t)1U],
 8873|  7.92k|            libcrux_ml_kem_polynomial_ZETAS_TIMES_MONTGOMERY_R[(size_t)64U +
 8874|  7.92k|                                                               (size_t)4U * i0 +
 8875|  7.92k|                                                               (size_t)2U],
 8876|  7.92k|            libcrux_ml_kem_polynomial_ZETAS_TIMES_MONTGOMERY_R[(size_t)64U +
 8877|  7.92k|                                                               (size_t)4U * i0 +
 8878|  7.92k|                                                               (size_t)3U]);
 8879|  7.92k|    out.coefficients[i0] = uu____0;
 8880|  7.92k|  }
 8881|    495|  return out;
 8882|    495|}
mlkem768.c:libcrux_ml_kem_vector_portable_ntt_multiply_0d:
 7344|  7.92k|    int16_t zeta0, int16_t zeta1, int16_t zeta2, int16_t zeta3) {
 7345|  7.92k|  return libcrux_ml_kem_vector_portable_ntt_ntt_multiply(lhs, rhs, zeta0, zeta1,
 7346|  7.92k|                                                         zeta2, zeta3);
 7347|  7.92k|}
mlkem768.c:libcrux_ml_kem_vector_portable_ntt_ntt_multiply:
 7314|  7.92k|    int16_t zeta0, int16_t zeta1, int16_t zeta2, int16_t zeta3) {
 7315|  7.92k|  libcrux_ml_kem_vector_portable_vector_type_PortableVector out =
 7316|  7.92k|      libcrux_ml_kem_vector_portable_vector_type_zero();
 7317|  7.92k|  libcrux_ml_kem_vector_portable_ntt_ntt_multiply_binomials(
 7318|  7.92k|      lhs, rhs, zeta0, (size_t)0U, (size_t)1U, &out);
 7319|  7.92k|  libcrux_ml_kem_vector_portable_ntt_ntt_multiply_binomials(
 7320|  7.92k|      lhs, rhs, -zeta0, (size_t)2U, (size_t)3U, &out);
 7321|  7.92k|  libcrux_ml_kem_vector_portable_ntt_ntt_multiply_binomials(
 7322|  7.92k|      lhs, rhs, zeta1, (size_t)4U, (size_t)5U, &out);
 7323|  7.92k|  libcrux_ml_kem_vector_portable_ntt_ntt_multiply_binomials(
 7324|  7.92k|      lhs, rhs, -zeta1, (size_t)6U, (size_t)7U, &out);
 7325|  7.92k|  libcrux_ml_kem_vector_portable_ntt_ntt_multiply_binomials(
 7326|  7.92k|      lhs, rhs, zeta2, (size_t)8U, (size_t)9U, &out);
 7327|  7.92k|  libcrux_ml_kem_vector_portable_ntt_ntt_multiply_binomials(
 7328|  7.92k|      lhs, rhs, -zeta2, (size_t)10U, (size_t)11U, &out);
 7329|  7.92k|  libcrux_ml_kem_vector_portable_ntt_ntt_multiply_binomials(
 7330|  7.92k|      lhs, rhs, zeta3, (size_t)12U, (size_t)13U, &out);
 7331|  7.92k|  libcrux_ml_kem_vector_portable_ntt_ntt_multiply_binomials(
 7332|  7.92k|      lhs, rhs, -zeta3, (size_t)14U, (size_t)15U, &out);
 7333|  7.92k|  return out;
 7334|  7.92k|}
mlkem768.c:libcrux_ml_kem_vector_portable_ntt_ntt_multiply_binomials:
 7295|  63.3k|    libcrux_ml_kem_vector_portable_vector_type_PortableVector *out) {
 7296|  63.3k|  int16_t o0 = libcrux_ml_kem_vector_portable_arithmetic_montgomery_reduce_element(
 7297|  63.3k|      (int32_t)a->elements[i] * (int32_t)b->elements[i] +
 7298|  63.3k|      (int32_t)
 7299|  63.3k|              libcrux_ml_kem_vector_portable_arithmetic_montgomery_reduce_element(
 7300|  63.3k|                  (int32_t)a->elements[j] * (int32_t)b->elements[j]) *
 7301|  63.3k|          (int32_t)zeta);
 7302|  63.3k|  int16_t o1 =
 7303|  63.3k|      libcrux_ml_kem_vector_portable_arithmetic_montgomery_reduce_element(
 7304|  63.3k|          (int32_t)a->elements[i] * (int32_t)b->elements[j] +
 7305|  63.3k|          (int32_t)a->elements[j] * (int32_t)b->elements[i]);
 7306|  63.3k|  out->elements[i] = o0;
 7307|  63.3k|  out->elements[j] = o1;
 7308|  63.3k|}
mlkem768.c:libcrux_ml_kem_polynomial_add_to_ring_element_89_84:
 8900|    495|    libcrux_ml_kem_polynomial_PolynomialRingElement_f0 *rhs) {
 8901|    495|  for (size_t i = (size_t)0U;
 8902|  8.41k|       i < Eurydice_slice_len(
  ------------------
  |  |  118|  8.41k|#define Eurydice_slice_len(s, t) EURYDICE_SLICE_LEN(s, t)
  |  |  ------------------
  |  |  |  |   89|  8.41k|#define EURYDICE_SLICE_LEN(s, _) s.len
  |  |  ------------------
  ------------------
  |  Branch (8902:8): [True: 7.92k, False: 495]
  ------------------
 8903|    495|               Eurydice_array_to_slice(
 8904|    495|                   (size_t)16U, self->coefficients,
 8905|    495|                   libcrux_ml_kem_vector_portable_vector_type_PortableVector),
 8906|    495|               libcrux_ml_kem_vector_portable_vector_type_PortableVector);
 8907|  7.92k|       i++) {
 8908|  7.92k|    size_t i0 = i;
 8909|  7.92k|    libcrux_ml_kem_vector_portable_vector_type_PortableVector uu____0 =
 8910|  7.92k|        libcrux_ml_kem_vector_portable_add_0d(self->coefficients[i0],
 8911|  7.92k|                                              &rhs->coefficients[i0]);
 8912|  7.92k|    self->coefficients[i0] = uu____0;
 8913|  7.92k|  }
 8914|    495|}
mlkem768.c:libcrux_ml_kem_polynomial_add_standard_error_reduce_89_03:
11249|    165|    libcrux_ml_kem_polynomial_PolynomialRingElement_f0 *error) {
11250|    165|  for (size_t i = (size_t)0U;
11251|  2.80k|       i < LIBCRUX_ML_KEM_POLYNOMIAL_VECTORS_IN_RING_ELEMENT; i++) {
  ------------------
  |  | 5860|  2.80k|  (LIBCRUX_ML_KEM_CONSTANTS_COEFFICIENTS_IN_RING_ELEMENT / \
  |  |  ------------------
  |  |  |  |  282|  2.80k|#define LIBCRUX_ML_KEM_CONSTANTS_COEFFICIENTS_IN_RING_ELEMENT ((size_t)256U)
  |  |  ------------------
  |  | 5861|  2.80k|   LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_ELEMENTS_IN_VECTOR)
  |  |  ------------------
  |  |  |  | 5857|  2.80k|#define LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_ELEMENTS_IN_VECTOR ((size_t)16U)
  |  |  ------------------
  ------------------
  |  Branch (11251:8): [True: 2.64k, False: 165]
  ------------------
11252|  2.64k|    size_t j = i;
11253|  2.64k|    libcrux_ml_kem_vector_portable_vector_type_PortableVector
11254|  2.64k|        coefficient_normal_form =
11255|  2.64k|            libcrux_ml_kem_vector_traits_to_standard_domain_59(
11256|  2.64k|                self->coefficients[j]);
11257|  2.64k|    libcrux_ml_kem_vector_portable_vector_type_PortableVector uu____0 =
11258|  2.64k|        libcrux_ml_kem_vector_portable_barrett_reduce_0d(
11259|  2.64k|            libcrux_ml_kem_vector_portable_add_0d(coefficient_normal_form,
11260|  2.64k|                                                  &error->coefficients[j]));
11261|  2.64k|    self->coefficients[j] = uu____0;
11262|  2.64k|  }
11263|    165|}
mlkem768.c:libcrux_ml_kem_vector_traits_to_standard_domain_59:
11231|  2.64k|    libcrux_ml_kem_vector_portable_vector_type_PortableVector v) {
11232|  2.64k|  return libcrux_ml_kem_vector_portable_montgomery_multiply_by_constant_0d(
11233|  2.64k|      v, LIBCRUX_ML_KEM_VECTOR_TRAITS_MONTGOMERY_R_SQUARED_MOD_FIELD_MODULUS);
  ------------------
  |  | 5866|  2.64k|  ((int16_t)1353)
  ------------------
11234|  2.64k|}
mlkem768.c:Eurydice_slice_to_array3:
  156|  38.1k|                                            Eurydice_slice src, size_t sz) {
  157|  38.1k|  *dst_tag = 0;
  158|  38.1k|  memcpy(dst_ok, src.ptr, sz);
  159|  38.1k|}
mlkem768.c:unwrap_41_83:
  525|     55|static inline void unwrap_41_83(Result_00 self, uint8_t ret[32U]) {
  526|     55|  if (self.tag == Ok) {
  ------------------
  |  |  246|     55|#define Ok 0
  ------------------
  |  Branch (526:7): [True: 55, False: 0]
  ------------------
  527|     55|    uint8_t f0[32U];
  528|     55|    memcpy(f0, self.val.case_Ok, (size_t)32U * sizeof(uint8_t));
  529|     55|    memcpy(ret, f0, (size_t)32U * sizeof(uint8_t));
  530|     55|  } else {
  531|      0|    KRML_HOST_EPRINTF("KaRaMeL abort at %s:%d\n%s\n", __FILE__, __LINE__,
  532|      0|                      "unwrap not Ok");
  533|      0|    KRML_HOST_EXIT(255U);
  ------------------
  |  |   35|      0|#define KRML_HOST_EXIT(x) dropbear_exit("mlkem")
  ------------------
  534|      0|  }
  535|     55|}
mlkem768.c:libcrux_ml_kem_ind_cpa_serialize_public_key_79:
11390|     55|    Eurydice_slice seed_for_a, uint8_t ret[1184U]) {
11391|     55|  uint8_t public_key_serialized[1184U] = {0U};
11392|     55|  Eurydice_slice uu____0 = Eurydice_array_to_subslice2(
  ------------------
  |  |  113|     55|  EURYDICE_SLICE((t *)x, start, end)
  |  |  ------------------
  |  |  |  |   88|     55|  (CLITERAL(Eurydice_slice){.ptr = (void *)(x + start), .len = end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |   61|     55|#define CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
11393|     55|      public_key_serialized, (size_t)0U, (size_t)1152U, uint8_t);
11394|     55|  uint8_t ret0[1152U];
11395|     55|  libcrux_ml_kem_ind_cpa_serialize_secret_key_b5(t_as_ntt, ret0);
11396|     55|  Eurydice_slice_copy(
  ------------------
  |  |  120|     55|  memcpy(dst.ptr, src.ptr, dst.len * sizeof(t))
  ------------------
11397|     55|      uu____0, Eurydice_array_to_slice((size_t)1152U, ret0, uint8_t), uint8_t);
11398|     55|  Eurydice_slice_copy(
  ------------------
  |  |  120|     55|  memcpy(dst.ptr, src.ptr, dst.len * sizeof(t))
  ------------------
11399|     55|      Eurydice_array_to_subslice_from((size_t)1184U, public_key_serialized,
11400|     55|                                      (size_t)1152U, uint8_t, size_t),
11401|     55|      seed_for_a, uint8_t);
11402|     55|  memcpy(ret, public_key_serialized, (size_t)1184U * sizeof(uint8_t));
11403|     55|}
mlkem768.c:libcrux_ml_kem_ind_cpa_serialize_secret_key_b5:
11354|    110|    uint8_t ret[1152U]) {
11355|    110|  uint8_t out[1152U] = {0U};
11356|    110|  for (size_t i = (size_t)0U;
11357|    440|       i < Eurydice_slice_len(
  ------------------
  |  |  118|    440|#define Eurydice_slice_len(s, t) EURYDICE_SLICE_LEN(s, t)
  |  |  ------------------
  |  |  |  |   89|    440|#define EURYDICE_SLICE_LEN(s, _) s.len
  |  |  ------------------
  ------------------
  |  Branch (11357:8): [True: 330, False: 110]
  ------------------
11358|    110|               Eurydice_array_to_slice(
11359|    110|                   (size_t)3U, key,
11360|    110|                   libcrux_ml_kem_polynomial_PolynomialRingElement_f0),
11361|    110|               libcrux_ml_kem_polynomial_PolynomialRingElement_f0);
11362|    330|       i++) {
11363|    330|    size_t i0 = i;
11364|    330|    libcrux_ml_kem_polynomial_PolynomialRingElement_f0 re = key[i0];
11365|    330|    Eurydice_slice uu____0 = Eurydice_array_to_subslice2(
  ------------------
  |  |  113|    330|  EURYDICE_SLICE((t *)x, start, end)
  |  |  ------------------
  |  |  |  |   88|    330|  (CLITERAL(Eurydice_slice){.ptr = (void *)(x + start), .len = end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |   61|    330|#define CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
11366|    330|        out, i0 * LIBCRUX_ML_KEM_CONSTANTS_BYTES_PER_RING_ELEMENT,
11367|    330|        (i0 + (size_t)1U) * LIBCRUX_ML_KEM_CONSTANTS_BYTES_PER_RING_ELEMENT,
11368|    330|        uint8_t);
11369|    330|    uint8_t ret0[384U];
11370|    330|    libcrux_ml_kem_serialize_serialize_uncompressed_ring_element_5b(&re, ret0);
11371|    330|    Eurydice_slice_copy(
  ------------------
  |  |  120|    330|  memcpy(dst.ptr, src.ptr, dst.len * sizeof(t))
  ------------------
11372|    330|        uu____0, Eurydice_array_to_slice((size_t)384U, ret0, uint8_t), uint8_t);
11373|    330|  }
11374|    110|  memcpy(ret, out, (size_t)1152U * sizeof(uint8_t));
11375|    110|}
mlkem768.c:libcrux_ml_kem_serialize_serialize_uncompressed_ring_element_5b:
11324|    330|    libcrux_ml_kem_polynomial_PolynomialRingElement_f0 *re, uint8_t ret[384U]) {
11325|    330|  uint8_t serialized[384U] = {0U};
11326|    330|  for (size_t i = (size_t)0U;
11327|  5.61k|       i < LIBCRUX_ML_KEM_POLYNOMIAL_VECTORS_IN_RING_ELEMENT; i++) {
  ------------------
  |  | 5860|  5.61k|  (LIBCRUX_ML_KEM_CONSTANTS_COEFFICIENTS_IN_RING_ELEMENT / \
  |  |  ------------------
  |  |  |  |  282|  5.61k|#define LIBCRUX_ML_KEM_CONSTANTS_COEFFICIENTS_IN_RING_ELEMENT ((size_t)256U)
  |  |  ------------------
  |  | 5861|  5.61k|   LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_ELEMENTS_IN_VECTOR)
  |  |  ------------------
  |  |  |  | 5857|  5.61k|#define LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_ELEMENTS_IN_VECTOR ((size_t)16U)
  |  |  ------------------
  ------------------
  |  Branch (11327:8): [True: 5.28k, False: 330]
  ------------------
11328|  5.28k|    size_t i0 = i;
11329|  5.28k|    libcrux_ml_kem_vector_portable_vector_type_PortableVector coefficient =
11330|  5.28k|        libcrux_ml_kem_vector_traits_to_unsigned_representative_db(
11331|  5.28k|            re->coefficients[i0]);
11332|  5.28k|    uint8_t bytes[24U];
11333|  5.28k|    libcrux_ml_kem_vector_portable_serialize_12_0d(coefficient, bytes);
11334|  5.28k|    Eurydice_slice uu____0 = Eurydice_array_to_subslice2(
  ------------------
  |  |  113|  5.28k|  EURYDICE_SLICE((t *)x, start, end)
  |  |  ------------------
  |  |  |  |   88|  5.28k|  (CLITERAL(Eurydice_slice){.ptr = (void *)(x + start), .len = end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |   61|  5.28k|#define CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
11335|  5.28k|        serialized, (size_t)24U * i0, (size_t)24U * i0 + (size_t)24U, uint8_t);
11336|  5.28k|    Eurydice_slice_copy(
  ------------------
  |  |  120|  5.28k|  memcpy(dst.ptr, src.ptr, dst.len * sizeof(t))
  ------------------
11337|  5.28k|        uu____0, Eurydice_array_to_slice((size_t)24U, bytes, uint8_t), uint8_t);
11338|  5.28k|  }
11339|    330|  memcpy(ret, serialized, (size_t)384U * sizeof(uint8_t));
11340|    330|}
mlkem768.c:libcrux_ml_kem_vector_traits_to_unsigned_representative_db:
 9163|  5.28k|    libcrux_ml_kem_vector_portable_vector_type_PortableVector a) {
 9164|  5.28k|  libcrux_ml_kem_vector_portable_vector_type_PortableVector t =
 9165|  5.28k|      libcrux_ml_kem_vector_portable_shift_right_0d_19(a);
 9166|  5.28k|  libcrux_ml_kem_vector_portable_vector_type_PortableVector fm =
 9167|  5.28k|      libcrux_ml_kem_vector_portable_bitwise_and_with_constant_0d(
 9168|  5.28k|          t, LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_MODULUS);
  ------------------
  |  | 5863|  5.28k|#define LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_MODULUS ((int16_t)3329)
  ------------------
 9169|  5.28k|  return libcrux_ml_kem_vector_portable_add_0d(a, &fm);
 9170|  5.28k|}
mlkem768.c:libcrux_ml_kem_vector_portable_shift_right_0d_19:
 9151|  5.28k|    libcrux_ml_kem_vector_portable_vector_type_PortableVector v) {
 9152|  5.28k|  return libcrux_ml_kem_vector_portable_arithmetic_shift_right_94(v);
 9153|  5.28k|}
mlkem768.c:libcrux_ml_kem_vector_portable_arithmetic_shift_right_94:
 9131|  5.28k|    libcrux_ml_kem_vector_portable_vector_type_PortableVector v) {
 9132|  5.28k|  for (size_t i = (size_t)0U;
 9133|  89.7k|       i < LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_ELEMENTS_IN_VECTOR; i++) {
  ------------------
  |  | 5857|  89.7k|#define LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_ELEMENTS_IN_VECTOR ((size_t)16U)
  ------------------
  |  Branch (9133:8): [True: 84.4k, False: 5.28k]
  ------------------
 9134|  84.4k|    size_t i0 = i;
 9135|  84.4k|    v.elements[i0] = v.elements[i0] >> (uint32_t)(int32_t)15;
 9136|  84.4k|  }
 9137|  5.28k|  return v;
 9138|  5.28k|}
mlkem768.c:libcrux_ml_kem_vector_portable_bitwise_and_with_constant_0d:
 6793|  5.28k|    libcrux_ml_kem_vector_portable_vector_type_PortableVector v, int16_t c) {
 6794|  5.28k|  return libcrux_ml_kem_vector_portable_arithmetic_bitwise_and_with_constant(v,
 6795|  5.28k|                                                                             c);
 6796|  5.28k|}
mlkem768.c:libcrux_ml_kem_vector_portable_arithmetic_bitwise_and_with_constant:
 6777|  5.28k|    libcrux_ml_kem_vector_portable_vector_type_PortableVector v, int16_t c) {
 6778|  5.28k|  for (size_t i = (size_t)0U;
 6779|  89.7k|       i < LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_ELEMENTS_IN_VECTOR; i++) {
  ------------------
  |  | 5857|  89.7k|#define LIBCRUX_ML_KEM_VECTOR_TRAITS_FIELD_ELEMENTS_IN_VECTOR ((size_t)16U)
  ------------------
  |  Branch (6779:8): [True: 84.4k, False: 5.28k]
  ------------------
 6780|  84.4k|    size_t i0 = i;
 6781|  84.4k|    size_t uu____0 = i0;
 6782|  84.4k|    v.elements[uu____0] = v.elements[uu____0] & c;
 6783|  84.4k|  }
 6784|  5.28k|  return v;
 6785|  5.28k|}
mlkem768.c:libcrux_ml_kem_vector_portable_serialize_12_0d:
 7969|  5.28k|    uint8_t ret[24U]) {
 7970|  5.28k|  libcrux_ml_kem_vector_portable_serialize_serialize_12(a, ret);
 7971|  5.28k|}
mlkem768.c:libcrux_ml_kem_vector_portable_serialize_serialize_12:
 7914|  5.28k|    uint8_t ret[24U]) {
 7915|  5.28k|  uint8_t_x3 r0_2 = libcrux_ml_kem_vector_portable_serialize_serialize_12_int(
 7916|  5.28k|      Eurydice_array_to_subslice2(v.elements, (size_t)0U, (size_t)2U, int16_t));
  ------------------
  |  |  113|  5.28k|  EURYDICE_SLICE((t *)x, start, end)
  |  |  ------------------
  |  |  |  |   88|  5.28k|  (CLITERAL(Eurydice_slice){.ptr = (void *)(x + start), .len = end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |   61|  5.28k|#define CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 7917|  5.28k|  uint8_t_x3 r3_5 = libcrux_ml_kem_vector_portable_serialize_serialize_12_int(
 7918|  5.28k|      Eurydice_array_to_subslice2(v.elements, (size_t)2U, (size_t)4U, int16_t));
  ------------------
  |  |  113|  5.28k|  EURYDICE_SLICE((t *)x, start, end)
  |  |  ------------------
  |  |  |  |   88|  5.28k|  (CLITERAL(Eurydice_slice){.ptr = (void *)(x + start), .len = end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |   61|  5.28k|#define CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 7919|  5.28k|  uint8_t_x3 r6_8 = libcrux_ml_kem_vector_portable_serialize_serialize_12_int(
 7920|  5.28k|      Eurydice_array_to_subslice2(v.elements, (size_t)4U, (size_t)6U, int16_t));
  ------------------
  |  |  113|  5.28k|  EURYDICE_SLICE((t *)x, start, end)
  |  |  ------------------
  |  |  |  |   88|  5.28k|  (CLITERAL(Eurydice_slice){.ptr = (void *)(x + start), .len = end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |   61|  5.28k|#define CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 7921|  5.28k|  uint8_t_x3 r9_11 = libcrux_ml_kem_vector_portable_serialize_serialize_12_int(
 7922|  5.28k|      Eurydice_array_to_subslice2(v.elements, (size_t)6U, (size_t)8U, int16_t));
  ------------------
  |  |  113|  5.28k|  EURYDICE_SLICE((t *)x, start, end)
  |  |  ------------------
  |  |  |  |   88|  5.28k|  (CLITERAL(Eurydice_slice){.ptr = (void *)(x + start), .len = end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |   61|  5.28k|#define CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 7923|  5.28k|  uint8_t_x3 r12_14 = libcrux_ml_kem_vector_portable_serialize_serialize_12_int(
 7924|  5.28k|      Eurydice_array_to_subslice2(v.elements, (size_t)8U, (size_t)10U,
  ------------------
  |  |  113|  5.28k|  EURYDICE_SLICE((t *)x, start, end)
  |  |  ------------------
  |  |  |  |   88|  5.28k|  (CLITERAL(Eurydice_slice){.ptr = (void *)(x + start), .len = end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |   61|  5.28k|#define CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 7925|  5.28k|                                  int16_t));
 7926|  5.28k|  uint8_t_x3 r15_17 = libcrux_ml_kem_vector_portable_serialize_serialize_12_int(
 7927|  5.28k|      Eurydice_array_to_subslice2(v.elements, (size_t)10U, (size_t)12U,
  ------------------
  |  |  113|  5.28k|  EURYDICE_SLICE((t *)x, start, end)
  |  |  ------------------
  |  |  |  |   88|  5.28k|  (CLITERAL(Eurydice_slice){.ptr = (void *)(x + start), .len = end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |   61|  5.28k|#define CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 7928|  5.28k|                                  int16_t));
 7929|  5.28k|  uint8_t_x3 r18_20 = libcrux_ml_kem_vector_portable_serialize_serialize_12_int(
 7930|  5.28k|      Eurydice_array_to_subslice2(v.elements, (size_t)12U, (size_t)14U,
  ------------------
  |  |  113|  5.28k|  EURYDICE_SLICE((t *)x, start, end)
  |  |  ------------------
  |  |  |  |   88|  5.28k|  (CLITERAL(Eurydice_slice){.ptr = (void *)(x + start), .len = end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |   61|  5.28k|#define CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 7931|  5.28k|                                  int16_t));
 7932|  5.28k|  uint8_t_x3 r21_23 = libcrux_ml_kem_vector_portable_serialize_serialize_12_int(
 7933|  5.28k|      Eurydice_array_to_subslice2(v.elements, (size_t)14U, (size_t)16U,
  ------------------
  |  |  113|  5.28k|  EURYDICE_SLICE((t *)x, start, end)
  |  |  ------------------
  |  |  |  |   88|  5.28k|  (CLITERAL(Eurydice_slice){.ptr = (void *)(x + start), .len = end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |   61|  5.28k|#define CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 7934|  5.28k|                                  int16_t));
 7935|  5.28k|  uint8_t result[24U] = {0U};
 7936|  5.28k|  result[0U] = r0_2.fst;
 7937|  5.28k|  result[1U] = r0_2.snd;
 7938|  5.28k|  result[2U] = r0_2.thd;
 7939|  5.28k|  result[3U] = r3_5.fst;
 7940|  5.28k|  result[4U] = r3_5.snd;
 7941|  5.28k|  result[5U] = r3_5.thd;
 7942|  5.28k|  result[6U] = r6_8.fst;
 7943|  5.28k|  result[7U] = r6_8.snd;
 7944|  5.28k|  result[8U] = r6_8.thd;
 7945|  5.28k|  result[9U] = r9_11.fst;
 7946|  5.28k|  result[10U] = r9_11.snd;
 7947|  5.28k|  result[11U] = r9_11.thd;
 7948|  5.28k|  result[12U] = r12_14.fst;
 7949|  5.28k|  result[13U] = r12_14.snd;
 7950|  5.28k|  result[14U] = r12_14.thd;
 7951|  5.28k|  result[15U] = r15_17.fst;
 7952|  5.28k|  result[16U] = r15_17.snd;
 7953|  5.28k|  result[17U] = r15_17.thd;
 7954|  5.28k|  result[18U] = r18_20.fst;
 7955|  5.28k|  result[19U] = r18_20.snd;
 7956|  5.28k|  result[20U] = r18_20.thd;
 7957|  5.28k|  result[21U] = r21_23.fst;
 7958|  5.28k|  result[22U] = r21_23.snd;
 7959|  5.28k|  result[23U] = r21_23.thd;
 7960|  5.28k|  memcpy(ret, result, (size_t)24U * sizeof(uint8_t));
 7961|  5.28k|}
mlkem768.c:libcrux_ml_kem_vector_portable_serialize_serialize_12_int:
 7896|  42.2k|libcrux_ml_kem_vector_portable_serialize_serialize_12_int(Eurydice_slice v) {
 7897|  42.2k|  uint8_t r0 =
 7898|  42.2k|      (uint8_t)(Eurydice_slice_index(v, (size_t)0U, int16_t, int16_t *) &
  ------------------
  |  |   95|  42.2k|#define Eurydice_slice_index(s, i, t, t_ptr_t) (((t_ptr_t)s.ptr)[i])
  ------------------
 7899|  42.2k|                (int16_t)255);
 7900|  42.2k|  uint8_t r1 =
 7901|  42.2k|      (uint8_t)(Eurydice_slice_index(v, (size_t)0U, int16_t, int16_t *) >> 8U |
  ------------------
  |  |   95|  42.2k|#define Eurydice_slice_index(s, i, t, t_ptr_t) (((t_ptr_t)s.ptr)[i])
  ------------------
 7902|  42.2k|                (Eurydice_slice_index(v, (size_t)1U, int16_t, int16_t *) &
  ------------------
  |  |   95|  42.2k|#define Eurydice_slice_index(s, i, t, t_ptr_t) (((t_ptr_t)s.ptr)[i])
  ------------------
 7903|  42.2k|                 (int16_t)15)
 7904|  42.2k|                    << 4U);
 7905|  42.2k|  uint8_t r2 =
 7906|  42.2k|      (uint8_t)(Eurydice_slice_index(v, (size_t)1U, int16_t, int16_t *) >> 4U &
  ------------------
  |  |   95|  42.2k|#define Eurydice_slice_index(s, i, t, t_ptr_t) (((t_ptr_t)s.ptr)[i])
  ------------------
 7907|  42.2k|                (int16_t)255);
 7908|  42.2k|  return (CLITERAL(uint8_t_x3){.fst = r0, .snd = r1, .thd = r2});
  ------------------
  |  |   61|  42.2k|#define CLITERAL(type) (type)
  ------------------
 7909|  42.2k|}
mlkem768.c:libcrux_ml_kem_ind_cca_serialize_kem_secret_key_48:
11495|     55|    Eurydice_slice implicit_rejection_value, uint8_t ret[2400U]) {
11496|     55|  uint8_t out[2400U] = {0U};
11497|     55|  size_t pointer = (size_t)0U;
11498|     55|  uint8_t *uu____0 = out;
11499|     55|  size_t uu____1 = pointer;
11500|     55|  size_t uu____2 = pointer;
11501|     55|  Eurydice_slice_copy(
  ------------------
  |  |  120|     55|  memcpy(dst.ptr, src.ptr, dst.len * sizeof(t))
  ------------------
11502|     55|      Eurydice_array_to_subslice2(
11503|     55|          uu____0, uu____1, uu____2 + Eurydice_slice_len(private_key, uint8_t),
11504|     55|          uint8_t),
11505|     55|      private_key, uint8_t);
11506|     55|  pointer = pointer + Eurydice_slice_len(private_key, uint8_t);
  ------------------
  |  |  118|     55|#define Eurydice_slice_len(s, t) EURYDICE_SLICE_LEN(s, t)
  |  |  ------------------
  |  |  |  |   89|     55|#define EURYDICE_SLICE_LEN(s, _) s.len
  |  |  ------------------
  ------------------
11507|     55|  uint8_t *uu____3 = out;
11508|     55|  size_t uu____4 = pointer;
11509|     55|  size_t uu____5 = pointer;
11510|     55|  Eurydice_slice_copy(
  ------------------
  |  |  120|     55|  memcpy(dst.ptr, src.ptr, dst.len * sizeof(t))
  ------------------
11511|     55|      Eurydice_array_to_subslice2(
11512|     55|          uu____3, uu____4, uu____5 + Eurydice_slice_len(public_key, uint8_t),
11513|     55|          uint8_t),
11514|     55|      public_key, uint8_t);
11515|     55|  pointer = pointer + Eurydice_slice_len(public_key, uint8_t);
  ------------------
  |  |  118|     55|#define Eurydice_slice_len(s, t) EURYDICE_SLICE_LEN(s, t)
  |  |  ------------------
  |  |  |  |   89|     55|#define EURYDICE_SLICE_LEN(s, _) s.len
  |  |  ------------------
  ------------------
11516|     55|  Eurydice_slice uu____6 = Eurydice_array_to_subslice2(
  ------------------
  |  |  113|     55|  EURYDICE_SLICE((t *)x, start, end)
  |  |  ------------------
  |  |  |  |   88|     55|  (CLITERAL(Eurydice_slice){.ptr = (void *)(x + start), .len = end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |   61|     55|#define CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
11517|     55|      out, pointer, pointer + LIBCRUX_ML_KEM_CONSTANTS_H_DIGEST_SIZE, uint8_t);
11518|     55|  uint8_t ret0[32U];
11519|     55|  libcrux_ml_kem_hash_functions_portable_H_f1_1a(public_key, ret0);
11520|     55|  Eurydice_slice_copy(
  ------------------
  |  |  120|     55|  memcpy(dst.ptr, src.ptr, dst.len * sizeof(t))
  ------------------
11521|     55|      uu____6, Eurydice_array_to_slice((size_t)32U, ret0, uint8_t), uint8_t);
11522|     55|  pointer = pointer + LIBCRUX_ML_KEM_CONSTANTS_H_DIGEST_SIZE;
  ------------------
  |  |  292|     55|#define LIBCRUX_ML_KEM_CONSTANTS_H_DIGEST_SIZE ((size_t)32U)
  ------------------
11523|     55|  uint8_t *uu____7 = out;
11524|     55|  size_t uu____8 = pointer;
11525|     55|  size_t uu____9 = pointer;
11526|     55|  Eurydice_slice_copy(
  ------------------
  |  |  120|     55|  memcpy(dst.ptr, src.ptr, dst.len * sizeof(t))
  ------------------
11527|     55|      Eurydice_array_to_subslice2(
11528|     55|          uu____7, uu____8,
11529|     55|          uu____9 + Eurydice_slice_len(implicit_rejection_value, uint8_t),
11530|     55|          uint8_t),
11531|     55|      implicit_rejection_value, uint8_t);
11532|     55|  memcpy(ret, out, (size_t)2400U * sizeof(uint8_t));
11533|     55|}
mlkem768.c:libcrux_ml_kem_hash_functions_portable_H_f1_1a:
11061|     55|    Eurydice_slice input, uint8_t ret[32U]) {
11062|     55|  libcrux_ml_kem_hash_functions_portable_H(input, ret);
11063|     55|}
mlkem768.c:libcrux_ml_kem_hash_functions_portable_H:
 5807|     55|    Eurydice_slice input, uint8_t ret[32U]) {
 5808|     55|  uint8_t digest[32U] = {0U};
 5809|     55|  libcrux_sha3_portable_sha256(
 5810|     55|      Eurydice_array_to_slice((size_t)32U, digest, uint8_t), input);
  ------------------
  |  |  107|     55|  EURYDICE_SLICE(x, 0,                     \
  |  |  ------------------
  |  |  |  |   88|     55|  (CLITERAL(Eurydice_slice){.ptr = (void *)(x + start), .len = end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |   61|     55|#define CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  108|     55|                 end) /* x is already at an array type, no need for cast */
  ------------------
 5811|     55|  memcpy(ret, digest, (size_t)32U * sizeof(uint8_t));
 5812|     55|}
mlkem768.c:libcrux_sha3_portable_sha256:
 2888|     55|                                                         Eurydice_slice data) {
 2889|     55|  Eurydice_slice buf0[1U] = {data};
 2890|     55|  Eurydice_slice buf[1U] = {digest};
 2891|     55|  libcrux_sha3_portable_keccakx1_ce0(buf0, buf);
 2892|     55|}
mlkem768.c:libcrux_sha3_portable_keccakx1_ce0:
 2877|     55|    Eurydice_slice data[1U], Eurydice_slice out[1U]) {
 2878|       |  /* Passing arrays by value in Rust generates a copy in C */
 2879|     55|  Eurydice_slice copy_of_data[1U];
 2880|     55|  memcpy(copy_of_data, data, (size_t)1U * sizeof(Eurydice_slice));
 2881|     55|  libcrux_sha3_generic_keccak_keccak_e90(copy_of_data, out);
 2882|     55|}
mlkem768.c:libcrux_sha3_generic_keccak_keccak_e90:
 2806|     55|    Eurydice_slice data[1U], Eurydice_slice out[1U]) {
 2807|     55|  libcrux_sha3_generic_keccak_KeccakState_48 s =
 2808|     55|      libcrux_sha3_generic_keccak_new_1e_f4();
 2809|     55|  for (size_t i = (size_t)0U;
 2810|    495|       i < Eurydice_slice_len(data[0U], uint8_t) / (size_t)136U; i++) {
  ------------------
  |  |  118|    495|#define Eurydice_slice_len(s, t) EURYDICE_SLICE_LEN(s, t)
  |  |  ------------------
  |  |  |  |   89|    495|#define EURYDICE_SLICE_LEN(s, _) s.len
  |  |  ------------------
  ------------------
  |  Branch (2810:8): [True: 440, False: 55]
  ------------------
 2811|    440|    size_t i0 = i;
 2812|    440|    libcrux_sha3_generic_keccak_KeccakState_48 *uu____0 = &s;
 2813|       |    /* Passing arrays by value in Rust generates a copy in C */
 2814|    440|    Eurydice_slice copy_of_data[1U];
 2815|    440|    memcpy(copy_of_data, data, (size_t)1U * sizeof(Eurydice_slice));
 2816|    440|    Eurydice_slice ret[1U];
 2817|    440|    libcrux_sha3_portable_keccak_slice_n_5a(copy_of_data, i0 * (size_t)136U,
 2818|    440|                                            (size_t)136U, ret);
 2819|    440|    libcrux_sha3_generic_keccak_absorb_block_df0(uu____0, ret);
 2820|    440|  }
 2821|     55|  size_t rem = Eurydice_slice_len(data[0U], uint8_t) % (size_t)136U;
  ------------------
  |  |  118|     55|#define Eurydice_slice_len(s, t) EURYDICE_SLICE_LEN(s, t)
  |  |  ------------------
  |  |  |  |   89|     55|#define EURYDICE_SLICE_LEN(s, _) s.len
  |  |  ------------------
  ------------------
 2822|     55|  libcrux_sha3_generic_keccak_KeccakState_48 *uu____2 = &s;
 2823|       |  /* Passing arrays by value in Rust generates a copy in C */
 2824|     55|  Eurydice_slice copy_of_data[1U];
 2825|     55|  memcpy(copy_of_data, data, (size_t)1U * sizeof(Eurydice_slice));
 2826|     55|  Eurydice_slice ret[1U];
 2827|     55|  libcrux_sha3_portable_keccak_slice_n_5a(
 2828|     55|      copy_of_data, Eurydice_slice_len(data[0U], uint8_t) - rem, rem, ret);
  ------------------
  |  |  118|     55|#define Eurydice_slice_len(s, t) EURYDICE_SLICE_LEN(s, t)
  |  |  ------------------
  |  |  |  |   89|     55|#define EURYDICE_SLICE_LEN(s, _) s.len
  |  |  ------------------
  ------------------
 2829|     55|  libcrux_sha3_generic_keccak_absorb_final_c70(uu____2, ret);
 2830|     55|  size_t outlen = Eurydice_slice_len(out[0U], uint8_t);
  ------------------
  |  |  118|     55|#define Eurydice_slice_len(s, t) EURYDICE_SLICE_LEN(s, t)
  |  |  ------------------
  |  |  |  |   89|     55|#define EURYDICE_SLICE_LEN(s, _) s.len
  |  |  ------------------
  ------------------
 2831|     55|  size_t blocks = outlen / (size_t)136U;
 2832|     55|  size_t last = outlen - outlen % (size_t)136U;
 2833|     55|  if (blocks == (size_t)0U) {
  ------------------
  |  Branch (2833:7): [True: 55, False: 0]
  ------------------
 2834|     55|    libcrux_sha3_generic_keccak_squeeze_first_and_last_c50(&s, out);
 2835|     55|  } else {
 2836|      0|    Eurydice_slice_uint8_t_1size_t__x2 uu____4 =
 2837|      0|        libcrux_sha3_portable_keccak_split_at_mut_n_5a(out, (size_t)136U);
 2838|      0|    Eurydice_slice o0[1U];
 2839|      0|    memcpy(o0, uu____4.fst, (size_t)1U * sizeof(Eurydice_slice));
 2840|      0|    Eurydice_slice o1[1U];
 2841|      0|    memcpy(o1, uu____4.snd, (size_t)1U * sizeof(Eurydice_slice));
 2842|      0|    libcrux_sha3_generic_keccak_squeeze_first_block_840(&s, o0);
 2843|      0|    core_ops_range_Range_b3 iter =
 2844|      0|        core_iter_traits_collect___core__iter__traits__collect__IntoIterator_for_I__1__into_iter(
  ------------------
  |  |  208|      0|  Eurydice_into_iter
  |  |  ------------------
  |  |  |  |  206|      0|#define Eurydice_into_iter(x, t, _ret_t) (x)
  |  |  ------------------
  ------------------
 2845|      0|            (CLITERAL(core_ops_range_Range_b3){.start = (size_t)1U,
 2846|      0|                                               .end = blocks}),
 2847|      0|            core_ops_range_Range_b3, core_ops_range_Range_b3);
 2848|      0|    while (true) {
  ------------------
  |  Branch (2848:12): [True: 0, Folded]
  ------------------
 2849|      0|      if (core_iter_range___core__iter__traits__iterator__Iterator_for_core__ops__range__Range_A___6__next(
  ------------------
  |  |  203|      0|  Eurydice_range_iter_next
  |  |  ------------------
  |  |  |  |  198|      0|  (((iter_ptr)->start == (iter_ptr)->end)            \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (198:4): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  199|      0|       ? (CLITERAL(ret_t){.tag = None})              \
  |  |  |  |  ------------------
  |  |  |  |  |  |   61|      0|#define CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  |  |                      ? (CLITERAL(ret_t){.tag = None})              \
  |  |  |  |  ------------------
  |  |  |  |  |  |  251|      0|#define None 0
  |  |  |  |  ------------------
  |  |  |  |  200|      0|       : (CLITERAL(ret_t){.tag = Some, .f0 = (iter_ptr)->start++}))
  |  |  |  |  ------------------
  |  |  |  |  |  |   61|      0|#define CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  |  |                      : (CLITERAL(ret_t){.tag = Some, .f0 = (iter_ptr)->start++}))
  |  |  |  |  ------------------
  |  |  |  |  |  |  252|      0|#define Some 1
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (2849:11): [True: 0, False: 0]
  ------------------
 2850|      0|              &iter, size_t, Option_b3)
 2851|      0|              .tag == None) {
  ------------------
  |  |  251|      0|#define None 0
  ------------------
 2852|      0|        break;
 2853|      0|      } else {
 2854|      0|        Eurydice_slice_uint8_t_1size_t__x2 uu____5 =
 2855|      0|            libcrux_sha3_portable_keccak_split_at_mut_n_5a(o1, (size_t)136U);
 2856|      0|        Eurydice_slice o[1U];
 2857|      0|        memcpy(o, uu____5.fst, (size_t)1U * sizeof(Eurydice_slice));
 2858|      0|        Eurydice_slice orest[1U];
 2859|      0|        memcpy(orest, uu____5.snd, (size_t)1U * sizeof(Eurydice_slice));
 2860|      0|        libcrux_sha3_generic_keccak_squeeze_next_block_fc0(&s, o);
 2861|      0|        memcpy(o1, orest, (size_t)1U * sizeof(Eurydice_slice));
 2862|      0|      }
 2863|      0|    }
 2864|      0|    if (last < outlen) {
  ------------------
  |  Branch (2864:9): [True: 0, False: 0]
  ------------------
 2865|      0|      libcrux_sha3_generic_keccak_squeeze_last_cf0(s, o1);
 2866|      0|    }
 2867|      0|  }
 2868|     55|}
mlkem768.c:libcrux_sha3_generic_keccak_absorb_final_c70:
 2632|     55|    libcrux_sha3_generic_keccak_KeccakState_48 *s, Eurydice_slice last[1U]) {
 2633|     55|  size_t last_len = Eurydice_slice_len(last[0U], uint8_t);
  ------------------
  |  |  118|     55|#define Eurydice_slice_len(s, t) EURYDICE_SLICE_LEN(s, t)
  |  |  ------------------
  |  |  |  |   89|     55|#define EURYDICE_SLICE_LEN(s, _) s.len
  |  |  ------------------
  ------------------
 2634|     55|  uint8_t blocks[1U][200U] = {{0U}};
 2635|    110|  for (size_t i = (size_t)0U; i < (size_t)1U; i++) {
  ------------------
  |  Branch (2635:31): [True: 55, False: 55]
  ------------------
 2636|     55|    size_t i0 = i;
 2637|     55|    if (last_len > (size_t)0U) {
  ------------------
  |  Branch (2637:9): [True: 55, False: 0]
  ------------------
 2638|     55|      Eurydice_slice uu____0 = Eurydice_array_to_subslice2(
  ------------------
  |  |  113|     55|  EURYDICE_SLICE((t *)x, start, end)
  |  |  ------------------
  |  |  |  |   88|     55|  (CLITERAL(Eurydice_slice){.ptr = (void *)(x + start), .len = end - start})
  |  |  |  |  ------------------
  |  |  |  |  |  |   61|     55|#define CLITERAL(type) (type)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2639|     55|          blocks[i0], (size_t)0U, last_len, uint8_t);
 2640|     55|      Eurydice_slice_copy(uu____0, last[i0], uint8_t);
  ------------------
  |  |  120|     55|  memcpy(dst.ptr, src.ptr, dst.len * sizeof(t))
  ------------------
 2641|     55|    }
 2642|     55|    blocks[i0][last_len] = 6U;
 2643|     55|    size_t uu____1 = i0;
 2644|     55|    size_t uu____2 = (size_t)136U - (size_t)1U;
 2645|     55|    blocks[uu____1][uu____2] = (uint32_t)blocks[uu____1][uu____2] | 128U;
 2646|     55|  }
 2647|     55|  uint64_t(*uu____3)[5U] = s->st;
 2648|     55|  uint8_t uu____4[1U][200U];
 2649|     55|  memcpy(uu____4, blocks, (size_t)1U * sizeof(uint8_t[200U]));
 2650|     55|  libcrux_sha3_portable_keccak_load_block_full_5a_d20(uu____3, uu____4);
 2651|     55|  libcrux_sha3_generic_keccak_keccakf1600_21(s);
 2652|     55|}
mlkem768.c:libcrux_ml_kem_types_from_05_f2:
  495|     55|libcrux_ml_kem_types_from_05_f2(uint8_t value[2400U]) {
  496|       |  /* Passing arrays by value in Rust generates a copy in C */
  497|     55|  uint8_t copy_of_value[2400U];
  498|     55|  memcpy(copy_of_value, value, (size_t)2400U * sizeof(uint8_t));
  499|     55|  libcrux_ml_kem_types_MlKemPrivateKey_55 lit;
  500|     55|  memcpy(lit.value, copy_of_value, (size_t)2400U * sizeof(uint8_t));
  501|     55|  return lit;
  502|     55|}
mlkem768.c:libcrux_ml_kem_types_from_17_35:
  480|     55|                                libcrux_ml_kem_types_MlKemPublicKey_15 pk) {
  481|     55|  return (
  482|     55|      CLITERAL(libcrux_ml_kem_mlkem768_MlKem768KeyPair){.sk = sk, .pk = pk});
  ------------------
  |  |   61|     55|#define CLITERAL(type) (type)
  ------------------
  483|     55|}
mlkem768.c:libcrux_ml_kem_types_from_b6_da:
  442|     55|libcrux_ml_kem_types_from_b6_da(uint8_t value[1184U]) {
  443|       |  /* Passing arrays by value in Rust generates a copy in C */
  444|     55|  uint8_t copy_of_value[1184U];
  445|     55|  memcpy(copy_of_value, value, (size_t)1184U * sizeof(uint8_t));
  446|     55|  libcrux_ml_kem_types_MlKemPublicKey_15 lit;
  447|     55|  memcpy(lit.value, copy_of_value, (size_t)1184U * sizeof(uint8_t));
  448|     55|  return lit;
  449|     55|}

list_append:
    5|      1|void list_append(m_list *list, void *item) {
    6|      1|	m_list_elem *elem;
    7|       |	
    8|      1|	elem = m_malloc(sizeof(*elem));
    9|      1|	elem->item = item;
   10|      1|	elem->list = list;
   11|      1|	elem->next = NULL;
   12|      1|	if (!list->first) {
  ------------------
  |  Branch (12:6): [True: 1, False: 0]
  ------------------
   13|      1|		list->first = elem;
   14|      1|		elem->prev = NULL;
   15|      1|	} else {
   16|      0|		elem->prev = list->last;
   17|      0|		list->last->next = elem;
   18|      0|	}
   19|      1|	list->last = elem;
   20|      1|}
list_new:
   22|      3|m_list * list_new() {
   23|      3|	m_list *ret = m_malloc(sizeof(m_list));
   24|       |	ret->first = ret->last = NULL;
   25|      3|	return ret;
   26|      3|}

listeners_initialise:
   30|  3.41k|void listeners_initialise() {
   31|       |
   32|       |	/* just one slot to start with */
   33|  3.41k|	ses.listeners = (struct Listener**)m_malloc(sizeof(struct Listener*));
   34|  3.41k|	ses.listensize = 1;
   35|  3.41k|	ses.listeners[0] = NULL;
   36|       |
   37|  3.41k|}
set_listener_fds:
   39|  97.5k|void set_listener_fds(fd_set * readfds) {
   40|       |
   41|  97.5k|	unsigned int i, j;
   42|  97.5k|	struct Listener *listener;
   43|       |
   44|       |	/* check each in turn */
   45|   195k|	for (i = 0; i < ses.listensize; i++) {
  ------------------
  |  Branch (45:14): [True: 97.5k, False: 97.5k]
  ------------------
   46|  97.5k|		listener = ses.listeners[i];
   47|  97.5k|		if (listener != NULL) {
  ------------------
  |  Branch (47:7): [True: 0, False: 97.5k]
  ------------------
   48|      0|			for (j = 0; j < listener->nsocks; j++) {
  ------------------
  |  Branch (48:16): [True: 0, False: 0]
  ------------------
   49|      0|				dropbear_fd_set(listener->socks[j], readfds);
   50|      0|			}
   51|      0|		}
   52|  97.5k|	}
   53|  97.5k|}
handle_listeners:
   56|  94.1k|void handle_listeners(const fd_set * readfds) {
   57|       |
   58|  94.1k|	unsigned int i, j;
   59|  94.1k|	struct Listener *listener;
   60|  94.1k|	int sock;
   61|       |
   62|       |	/* check each in turn */
   63|   188k|	for (i = 0; i < ses.listensize; i++) {
  ------------------
  |  Branch (63:14): [True: 94.1k, False: 94.1k]
  ------------------
   64|  94.1k|		listener = ses.listeners[i];
   65|  94.1k|		if (listener != NULL) {
  ------------------
  |  Branch (65:7): [True: 0, False: 94.1k]
  ------------------
   66|      0|			for (j = 0; j < listener->nsocks; j++) {
  ------------------
  |  Branch (66:16): [True: 0, False: 0]
  ------------------
   67|      0|				sock = listener->socks[j];
   68|      0|				if (FD_ISSET(sock, readfds)) {
  ------------------
  |  Branch (68:9): [True: 0, False: 0]
  ------------------
   69|      0|					listener->acceptor(listener, sock);
   70|      0|				}
   71|      0|			}
   72|      0|		}
   73|  94.1k|	}
   74|  94.1k|} /* Woo brace matching */
remove_all_listeners:
  166|  3.41k|void remove_all_listeners(void) {
  167|  3.41k|	unsigned int i;
  168|  6.83k|	for (i = 0; i < ses.listensize; i++) {
  ------------------
  |  Branch (168:14): [True: 3.41k, False: 3.41k]
  ------------------
  169|  3.41k|		if (ses.listeners[i]) {
  ------------------
  |  Branch (169:7): [True: 0, False: 3.41k]
  ------------------
  170|      0|			remove_listener(ses.listeners[i]);
  171|      0|		}
  172|  3.41k|	}
  173|       |	m_free(ses.listeners);
  ------------------
  |  |   24|  3.41k|#define m_free(X) do {m_free_direct(X); (X) = NULL;} while (0)
  |  |  ------------------
  |  |  |  Branch (24:61): [Folded, False: 3.41k]
  |  |  ------------------
  ------------------
  174|  3.41k|}

dropbear_prng_read:
   70|    762|{
   71|    762|   LTC_ARGCHK(out != NULL);
  ------------------
  |  |   32|    762|#define LTC_ARGCHK(x) do { if (!(x)) { crypt_argchk(#x, __FILE__, __LINE__); } }while(0)
  |  |  ------------------
  |  |  |  Branch (32:32): [True: 0, False: 762]
  |  |  |  Branch (32:87): [Folded, False: 762]
  |  |  ------------------
  ------------------
   72|    762|   genrandom(out, outlen);
   73|    762|   return outlen;
   74|    762|}

crypto_kem_mlkem768_keypair:
   59|     55|{
   60|     55|	unsigned char rnd[LIBCRUX_ML_KEM_KEY_PAIR_PRNG_LEN];
   61|     55|	struct libcrux_mlkem768_keypair keypair;
   62|       |
   63|     55|	static_assert(sizeof(keypair.sk.value) == crypto_kem_mlkem768_SECRETKEYBYTES, "len");
   64|     55|	static_assert(sizeof(keypair.pk.value) == crypto_kem_mlkem768_PUBLICKEYBYTES, "len");
   65|       |
   66|     55|	genrandom(rnd, sizeof(rnd));
   67|     55|	keypair = libcrux_ml_kem_mlkem768_portable_generate_key_pair(rnd);
   68|     55|	memcpy(pk, keypair.pk.value, crypto_kem_mlkem768_PUBLICKEYBYTES);
  ------------------
  |  |    3|     55|#define crypto_kem_mlkem768_PUBLICKEYBYTES 1184
  ------------------
   69|     55|	memcpy(sk, keypair.sk.value, crypto_kem_mlkem768_SECRETKEYBYTES);
  ------------------
  |  |    4|     55|#define crypto_kem_mlkem768_SECRETKEYBYTES 2400
  ------------------
   70|     55|	m_burn(rnd, sizeof(rnd));
   71|     55|	m_burn(&keypair, sizeof(keypair));
   72|     55|	return 0;
   73|     55|}

remove_connect_pending:
  291|  3.41k|void remove_connect_pending() {
  292|  3.41k|	while (ses.conn_pending.first) {
  ------------------
  |  Branch (292:9): [True: 0, False: 3.41k]
  ------------------
  293|      0|		struct dropbear_progress_connection *c = ses.conn_pending.first->item;
  294|      0|		remove_connect(c, ses.conn_pending.first);
  295|      0|	}
  296|  3.41k|}
set_connect_fds:
  299|  97.5k|void set_connect_fds(fd_set *writefd) {
  300|  97.5k|	m_list_elem *iter;
  301|  97.5k|	iter = ses.conn_pending.first;
  302|  97.5k|	while (iter) {
  ------------------
  |  Branch (302:9): [True: 0, False: 97.5k]
  ------------------
  303|      0|		m_list_elem *next_iter = iter->next;
  304|      0|		struct dropbear_progress_connection *c = iter->item;
  305|       |		/* Set one going */
  306|      0|		while (c->res_iter && c->sock < 0) {
  ------------------
  |  Branch (306:10): [True: 0, False: 0]
  |  Branch (306:25): [True: 0, False: 0]
  ------------------
  307|      0|			connect_try_next(c);
  308|      0|		}
  309|      0|		if (c->sock >= 0) {
  ------------------
  |  Branch (309:7): [True: 0, False: 0]
  ------------------
  310|      0|			dropbear_fd_set(c->sock, writefd);
  311|      0|		} else {
  312|       |			/* Final failure */
  313|      0|			if (!c->errstring) {
  ------------------
  |  Branch (313:8): [True: 0, False: 0]
  ------------------
  314|      0|				c->errstring = m_strdup("unexpected failure");
  315|      0|			}
  316|      0|			c->cb(DROPBEAR_FAILURE, -1, c->cb_data, c->errstring);
  ------------------
  |  |  112|      0|#define DROPBEAR_FAILURE -1
  ------------------
  317|      0|			remove_connect(c, iter);
  318|      0|		}
  319|      0|		iter = next_iter;
  320|      0|	}
  321|  97.5k|}
handle_connect_fds:
  323|  94.1k|void handle_connect_fds(const fd_set *writefd) {
  324|  94.1k|	m_list_elem *iter;
  325|  94.1k|	for (iter = ses.conn_pending.first; iter; iter = iter->next) {
  ------------------
  |  Branch (325:38): [True: 0, False: 94.1k]
  ------------------
  326|      0|		int val;
  327|      0|		socklen_t vallen = sizeof(val);
  328|      0|		struct dropbear_progress_connection *c = iter->item;
  329|       |
  330|      0|		if (c->sock < 0 || !FD_ISSET(c->sock, writefd)) {
  ------------------
  |  Branch (330:7): [True: 0, False: 0]
  |  Branch (330:22): [True: 0, False: 0]
  ------------------
  331|      0|			continue;
  332|      0|		}
  333|       |
  334|      0|		TRACE(("handling %s port %s socket %d", c->remotehost, c->remoteport, c->sock));
  335|       |
  336|      0|		if (getsockopt(c->sock, SOL_SOCKET, SO_ERROR, &val, &vallen) != 0) {
  ------------------
  |  Branch (336:7): [True: 0, False: 0]
  ------------------
  337|      0|			TRACE(("handle_connect_fds getsockopt(%d) SO_ERROR failed: %s", c->sock, strerror(errno)))
  338|       |			/* This isn't expected to happen - Unix has surprises though, continue gracefully. */
  339|      0|			m_close(c->sock);
  340|      0|			c->sock = -1;
  341|      0|		} else if (val != 0) {
  ------------------
  |  Branch (341:14): [True: 0, False: 0]
  ------------------
  342|       |			/* Connect failed */
  343|      0|			TRACE(("connect to %s port %s failed.", c->remotehost, c->remoteport))
  344|      0|			m_close(c->sock);
  345|      0|			c->sock = -1;
  346|       |
  347|      0|			m_free(c->errstring);
  ------------------
  |  |   24|      0|#define m_free(X) do {m_free_direct(X); (X) = NULL;} while (0)
  |  |  ------------------
  |  |  |  Branch (24:61): [Folded, False: 0]
  |  |  ------------------
  ------------------
  348|      0|			c->errstring = m_strdup(strerror(val));
  349|      0|		} else {
  350|       |			/* New connection has been established */
  351|      0|			c->cb(DROPBEAR_SUCCESS, c->sock, c->cb_data, NULL);
  ------------------
  |  |  111|      0|#define DROPBEAR_SUCCESS 0
  ------------------
  352|      0|			remove_connect(c, iter);
  353|      0|			TRACE(("leave handle_connect_fds - success"))
  354|       |			/* Must return here - remove_connect() invalidates iter */
  355|      0|			return; 
  356|      0|		}
  357|      0|	}
  358|  94.1k|}
packet_queue_to_iovec:
  364|  26.7k|void packet_queue_to_iovec(const struct Queue *queue, struct iovec *iov, unsigned int *iov_count) {
  365|  26.7k|	struct Link *l;
  366|  26.7k|	unsigned int i;
  367|  26.7k|	int len;
  368|  26.7k|	buffer *writebuf;
  369|       |
  370|       |#ifndef IOV_MAX
  371|       |	#if (defined(__CYGWIN__) || defined(__GNU__)) && !defined(UIO_MAXIOV)
  372|       |		#define IOV_MAX 1024
  373|       |	#elif defined(__sgi)
  374|       |		#define IOV_MAX 512 
  375|       |	#else 
  376|       |		#define IOV_MAX UIO_MAXIOV
  377|       |	#endif
  378|       |#endif
  379|       |
  380|  26.7k|	*iov_count = MIN(MIN(queue->count, IOV_MAX), *iov_count);
  ------------------
  |  Branch (380:15): [True: 26.7k, False: 0]
  |  Branch (380:15): [True: 26.7k, False: 0]
  |  Branch (380:15): [True: 26.7k, False: 0]
  ------------------
  381|       |
  382|  63.8k|	for (l = queue->head, i = 0; i < *iov_count; l = l->link, i++)
  ------------------
  |  Branch (382:31): [True: 37.0k, False: 26.7k]
  ------------------
  383|  37.0k|	{
  384|  37.0k|		writebuf = (buffer*)l->item;
  385|  37.0k|		len = writebuf->len - writebuf->pos;
  386|  37.0k|		dropbear_assert(len > 0);
  ------------------
  |  |   86|  37.0k|#define dropbear_assert(X) do { if (!(X)) { fail_assert(#X, __FILE__, __LINE__); } } while (0)
  |  |  ------------------
  |  |  |  Branch (86:37): [True: 0, False: 37.0k]
  |  |  |  Branch (86:93): [Folded, False: 37.0k]
  |  |  ------------------
  ------------------
  387|  37.0k|		TRACE2(("write_packet writev #%d len %d/%d", i,
  388|  37.0k|				len, writebuf->len))
  389|  37.0k|		iov[i].iov_base = buf_getptr(writebuf, len);
  390|  37.0k|		iov[i].iov_len = len;
  391|  37.0k|	}
  392|  26.7k|}
packet_queue_consume:
  394|  26.7k|void packet_queue_consume(struct Queue *queue, ssize_t written) {
  395|  26.7k|	buffer *writebuf;
  396|  26.7k|	int len;
  397|  53.5k|	while (written > 0) {
  ------------------
  |  Branch (397:9): [True: 26.7k, False: 26.7k]
  ------------------
  398|  26.7k|		writebuf = (buffer*)examine(queue);
  399|  26.7k|		len = writebuf->len - writebuf->pos;
  400|  26.7k|		if (len > written) {
  ------------------
  |  Branch (400:7): [True: 0, False: 26.7k]
  ------------------
  401|       |			/* partial buffer write */
  402|      0|			buf_incrpos(writebuf, written);
  403|      0|			written = 0;
  404|  26.7k|		} else {
  405|  26.7k|			written -= len;
  406|  26.7k|			dequeue(queue);
  407|  26.7k|			buf_free(writebuf);
  408|  26.7k|		}
  409|  26.7k|	}
  410|  26.7k|}
set_sock_priority:
  430|  3.41k|void set_sock_priority(int sock, enum dropbear_prio prio) {
  431|       |
  432|  3.41k|	int rc;
  433|  3.41k|	int val;
  434|       |
  435|  3.41k|#if DROPBEAR_FUZZ
  436|  3.41k|	if (fuzz.fuzzing) {
  ------------------
  |  Branch (436:6): [True: 3.41k, False: 0]
  ------------------
  437|  3.41k|		TRACE(("fuzzing skips set_sock_prio"))
  438|  3.41k|		return;
  439|  3.41k|	}
  440|      0|#endif
  441|       |	/* Don't log ENOTSOCK errors so that this can harmlessly be called
  442|       |	 * on a client '-J' proxy pipe */
  443|       |
  444|      0|	if (opts.disable_ip_tos == 0) {
  ------------------
  |  Branch (444:6): [True: 0, False: 0]
  ------------------
  445|      0|#ifdef IP_TOS
  446|       |	/* Set the DSCP field for outbound IP packet priority.
  447|       |	rfc4594 has some guidance to meanings.
  448|       |
  449|       |	We set AF21 as "Low-Latency" class for interactive (tty session,
  450|       |	also handshake/setup packets). Other traffic is left at the default.
  451|       |
  452|       |	OpenSSH at present uses AF21/CS1, rationale
  453|       |	https://cvsweb.openbsd.org/src/usr.bin/ssh/readconf.c#rev1.284
  454|       |
  455|       |	Old Dropbear/OpenSSH and Debian/Ubuntu OpenSSH (at Jan 2022) use
  456|       |	IPTOS_LOWDELAY/IPTOS_THROUGHPUT
  457|       |
  458|       |	DSCP constants are from Linux headers, applicable to other platforms
  459|       |	such as macos.
  460|       |	*/
  461|      0|	if (prio == DROPBEAR_PRIO_LOWDELAY) {
  ------------------
  |  Branch (461:6): [True: 0, False: 0]
  ------------------
  462|      0|		val = 0x48; /* IPTOS_DSCP_AF21 */
  463|      0|	} else {
  464|      0|		val = 0; /* default */
  465|      0|	}
  466|      0|#if defined(IPPROTO_IPV6) && defined(IPV6_TCLASS)
  467|      0|	rc = setsockopt(sock, IPPROTO_IPV6, IPV6_TCLASS, (void*)&val, sizeof(val));
  468|      0|	if (rc < 0 && errno != ENOTSOCK) {
  ------------------
  |  Branch (468:6): [True: 0, False: 0]
  |  Branch (468:16): [True: 0, False: 0]
  ------------------
  469|      0|		TRACE(("Couldn't set IPV6_TCLASS (%s)", strerror(errno)));
  470|      0|	}
  471|      0|#endif
  472|      0|	rc = setsockopt(sock, IPPROTO_IP, IP_TOS, (void*)&val, sizeof(val));
  473|      0|	if (rc < 0 && errno != ENOTSOCK) {
  ------------------
  |  Branch (473:6): [True: 0, False: 0]
  |  Branch (473:16): [True: 0, False: 0]
  ------------------
  474|      0|		TRACE(("Couldn't set IP_TOS (%s)", strerror(errno)));
  475|      0|	}
  476|      0|#endif /* IP_TOS */
  477|      0|	}
  478|       |
  479|      0|#ifdef HAVE_LINUX_PKT_SCHED_H
  480|       |	/* Set scheduling priority within the local Linux network stack */
  481|      0|	if (prio == DROPBEAR_PRIO_LOWDELAY) {
  ------------------
  |  Branch (481:6): [True: 0, False: 0]
  ------------------
  482|      0|		val = TC_PRIO_INTERACTIVE;
  483|      0|	} else {
  484|      0|		val = 0;
  485|      0|	}
  486|       |	/* linux specific, sets QoS class. see tc-prio(8) */
  487|      0|	rc = setsockopt(sock, SOL_SOCKET, SO_PRIORITY, (void*) &val, sizeof(val));
  488|      0|	if (rc < 0 && errno != ENOTSOCK) {
  ------------------
  |  Branch (488:6): [True: 0, False: 0]
  |  Branch (488:16): [True: 0, False: 0]
  ------------------
  489|      0|		TRACE(("Couldn't set SO_PRIORITY (%s)", strerror(errno)))
  490|      0|    }
  491|      0|#endif
  492|       |
  493|      0|}

write_packet:
   58|  26.7k|void write_packet() {
   59|       |
   60|  26.7k|	ssize_t written;
   61|  26.7k|#if defined(HAVE_WRITEV) && (defined(IOV_MAX) || defined(UIO_MAXIOV))
   62|       |	/* 50 is somewhat arbitrary */
   63|  26.7k|	unsigned int iov_count = 50;
   64|  26.7k|	struct iovec iov[50];
   65|       |#else
   66|       |	int len;
   67|       |	buffer* writebuf;
   68|       |#endif
   69|       |	
   70|  26.7k|	TRACE2(("enter write_packet"))
   71|  26.7k|	dropbear_assert(!isempty(&ses.writequeue));
  ------------------
  |  |   86|  26.7k|#define dropbear_assert(X) do { if (!(X)) { fail_assert(#X, __FILE__, __LINE__); } } while (0)
  |  |  ------------------
  |  |  |  Branch (86:37): [True: 0, False: 26.7k]
  |  |  |  Branch (86:93): [Folded, False: 26.7k]
  |  |  ------------------
  ------------------
   72|       |
   73|  26.7k|#if defined(HAVE_WRITEV) && (defined(IOV_MAX) || defined(UIO_MAXIOV))
   74|       |
   75|  26.7k|	packet_queue_to_iovec(&ses.writequeue, iov, &iov_count);
   76|       |	/* This may return EAGAIN. The main loop sometimes
   77|       |	calls write_packet() without bothering to test with select() since
   78|       |	it's likely to be necessary */
   79|  26.7k|#if DROPBEAR_FUZZ
   80|  26.7k|	if (fuzz.fuzzing) {
  ------------------
  |  Branch (80:6): [True: 26.7k, False: 0]
  ------------------
   81|       |		/* pretend to write one packet at a time */
   82|       |		/* TODO(fuzz): randomise amount written based on the fuzz input */
   83|  26.7k|		written = iov[0].iov_len;
   84|  26.7k|	}
   85|      0|	else
   86|      0|#endif
   87|      0|	{
   88|      0|	written = writev(ses.sock_out, iov, iov_count);
   89|      0|	if (written < 0) {
  ------------------
  |  Branch (89:6): [True: 0, False: 0]
  ------------------
   90|      0|		if (errno == EINTR || errno == EAGAIN) {
  ------------------
  |  Branch (90:7): [True: 0, False: 0]
  |  Branch (90:25): [True: 0, False: 0]
  ------------------
   91|      0|			TRACE2(("leave write_packet: EINTR"))
   92|      0|			return;
   93|      0|		} else {
   94|      0|			dropbear_exit("Error writing: %s", strerror(errno));
   95|      0|		}
   96|      0|	}
   97|      0|	}
   98|       |
   99|  26.7k|	packet_queue_consume(&ses.writequeue, written);
  100|  26.7k|	ses.writequeue_len -= written;
  101|       |
  102|  26.7k|	if (written == 0) {
  ------------------
  |  Branch (102:6): [True: 0, False: 26.7k]
  ------------------
  103|      0|		ses.remoteclosed();
  104|      0|	}
  105|       |
  106|       |#else /* No writev () */
  107|       |#if DROPBEAR_FUZZ
  108|       |	_Static_assert(0, "No fuzzing code for no-writev writes");
  109|       |#endif
  110|       |	/* Get the next buffer in the queue of encrypted packets to write*/
  111|       |	writebuf = (buffer*)examine(&ses.writequeue);
  112|       |
  113|       |	len = writebuf->len - writebuf->pos;
  114|       |	dropbear_assert(len > 0);
  115|       |	/* Try to write as much as possible */
  116|       |	written = write(ses.sock_out, buf_getptr(writebuf, len), len);
  117|       |
  118|       |	if (written < 0) {
  119|       |		if (errno == EINTR || errno == EAGAIN) {
  120|       |			TRACE2(("leave writepacket: EINTR"))
  121|       |			return;
  122|       |		} else {
  123|       |			dropbear_exit("Error writing: %s", strerror(errno));
  124|       |		}
  125|       |	} 
  126|       |
  127|       |	if (written == 0) {
  128|       |		ses.remoteclosed();
  129|       |	}
  130|       |
  131|       |	ses.writequeue_len -= written;
  132|       |
  133|       |	if (written == len) {
  134|       |		/* We've finished with the packet, free it */
  135|       |		dequeue(&ses.writequeue);
  136|       |		buf_free(writebuf);
  137|       |		writebuf = NULL;
  138|       |	} else {
  139|       |		/* More packet left to write, leave it in the queue for later */
  140|       |		buf_incrpos(writebuf, written);
  141|       |	}
  142|       |#endif /* writev */
  143|       |
  144|  26.7k|	TRACE2(("leave write_packet"))
  145|  26.7k|}
read_packet:
  150|  80.6k|void read_packet() {
  151|       |
  152|  80.6k|	int len;
  153|  80.6k|	unsigned int maxlen;
  154|  80.6k|	unsigned char blocksize;
  155|       |
  156|  80.6k|	TRACE2(("enter read_packet"))
  157|  80.6k|	blocksize = ses.keys->recv.algo_crypt->blocksize;
  158|       |	
  159|  80.6k|	if (ses.readbuf == NULL || ses.readbuf->len < blocksize) {
  ------------------
  |  Branch (159:6): [True: 20.1k, False: 60.5k]
  |  Branch (159:29): [True: 33.7k, False: 26.7k]
  ------------------
  160|  53.9k|		int ret;
  161|       |		/* In the first blocksize of a packet */
  162|       |
  163|       |		/* Read the first blocksize of the packet, so we can decrypt it and
  164|       |		 * find the length of the whole packet */
  165|  53.9k|		ret = read_packet_init();
  166|       |
  167|  53.9k|		if (ret == DROPBEAR_FAILURE) {
  ------------------
  |  |  112|  53.9k|#define DROPBEAR_FAILURE -1
  ------------------
  |  Branch (167:7): [True: 33.7k, False: 20.1k]
  ------------------
  168|       |			/* didn't read enough to determine the length */
  169|  33.7k|			TRACE2(("leave read_packet: packetinit done"))
  170|  33.7k|			return;
  171|  33.7k|		}
  172|  53.9k|	}
  173|       |
  174|       |	/* Attempt to read the remainder of the packet, note that there
  175|       |	 * mightn't be any available (EAGAIN) */
  176|  46.8k|	maxlen = ses.readbuf->len - ses.readbuf->pos;
  177|  46.8k|	if (maxlen == 0) {
  ------------------
  |  Branch (177:6): [True: 11.8k, False: 35.0k]
  ------------------
  178|       |		/* Occurs when the packet is only a single block long and has all
  179|       |		 * been read in read_packet_init().  Usually means that MAC is disabled
  180|       |		 */
  181|  11.8k|		len = 0;
  182|  35.0k|	} else {
  183|  35.0k|		len = read(ses.sock_in, buf_getptr(ses.readbuf, maxlen), maxlen);
  ------------------
  |  |   55|  35.0k|#define read(fd, buf, count) wrapfd_read(fd, buf, count)
  ------------------
  184|       |
  185|  35.0k|		if (len == 0) {
  ------------------
  |  Branch (185:7): [True: 125, False: 34.9k]
  ------------------
  186|    125|			ses.remoteclosed();
  187|    125|		}
  188|       |
  189|  35.0k|		if (len < 0) {
  ------------------
  |  Branch (189:7): [True: 41, False: 35.0k]
  ------------------
  190|     41|			if (errno == EINTR || errno == EAGAIN) {
  ------------------
  |  Branch (190:8): [True: 40, False: 1]
  |  Branch (190:26): [True: 0, False: 1]
  ------------------
  191|     40|				TRACE2(("leave read_packet: EINTR or EAGAIN"))
  192|     40|				return;
  193|     40|			} else {
  194|      1|				dropbear_exit("Error reading: %s", strerror(errno));
  195|      1|			}
  196|     41|		}
  197|       |
  198|  35.0k|		buf_incrpos(ses.readbuf, len);
  199|  35.0k|	}
  200|       |
  201|  46.8k|	if ((unsigned int)len == maxlen) {
  ------------------
  |  Branch (201:6): [True: 19.3k, False: 27.4k]
  ------------------
  202|       |		/* The whole packet has been read */
  203|  19.3k|		decrypt_packet();
  204|       |		/* The main select() loop process_packet() to
  205|       |		 * handle the packet contents... */
  206|  19.3k|	}
  207|  46.8k|	TRACE2(("leave read_packet"))
  208|  46.8k|}
decrypt_packet:
  298|  19.3k|void decrypt_packet() {
  299|       |
  300|  19.3k|	unsigned char blocksize;
  301|  19.3k|	unsigned char macsize;
  302|  19.3k|	unsigned int padlen;
  303|  19.3k|	unsigned int len;
  304|       |
  305|  19.3k|	TRACE2(("enter decrypt_packet"))
  306|  19.3k|	blocksize = ses.keys->recv.algo_crypt->blocksize;
  307|  19.3k|	macsize = ses.keys->recv.algo_mac->hashsize;
  308|       |
  309|  19.3k|	ses.kexstate.datarecv += ses.readbuf->len;
  310|       |
  311|  19.3k|#if DROPBEAR_AEAD_MODE
  312|  19.3k|	if (ses.keys->recv.crypt_mode->aead_crypt) {
  ------------------
  |  Branch (312:6): [True: 0, False: 19.3k]
  ------------------
  313|       |		/* first blocksize is not decrypted yet */
  314|      0|		buf_setpos(ses.readbuf, 0);
  315|       |
  316|       |		/* decrypt it in-place */
  317|      0|		len = ses.readbuf->len - macsize - ses.readbuf->pos;
  318|      0|		if (ses.keys->recv.crypt_mode->aead_crypt(ses.recvseq,
  ------------------
  |  Branch (318:7): [True: 0, False: 0]
  ------------------
  319|      0|					buf_getptr(ses.readbuf, len + macsize),
  320|      0|					buf_getwriteptr(ses.readbuf, len),
  321|      0|					len, macsize,
  322|      0|					&ses.keys->recv.cipher_state, LTC_DECRYPT) != CRYPT_OK) {
  ------------------
  |  |   70|      0|#define LTC_DECRYPT 1
  ------------------
  323|      0|			dropbear_exit("Error decrypting");
  324|      0|		}
  325|      0|		buf_incrpos(ses.readbuf, len);
  326|      0|	} else
  327|  19.3k|#endif
  328|  19.3k|	{
  329|       |		/* we've already decrypted the first blocksize in read_packet_init */
  330|  19.3k|		buf_setpos(ses.readbuf, blocksize);
  331|       |
  332|       |		/* decrypt it in-place */
  333|  19.3k|		len = ses.readbuf->len - macsize - ses.readbuf->pos;
  334|  19.3k|		if (ses.keys->recv.crypt_mode->decrypt(
  ------------------
  |  Branch (334:7): [True: 0, False: 19.3k]
  ------------------
  335|  19.3k|					buf_getptr(ses.readbuf, len), 
  336|  19.3k|					buf_getwriteptr(ses.readbuf, len),
  337|  19.3k|					len,
  338|  19.3k|					&ses.keys->recv.cipher_state) != CRYPT_OK) {
  339|      0|			dropbear_exit("Error decrypting");
  340|      0|		}
  341|  19.3k|		buf_incrpos(ses.readbuf, len);
  342|       |
  343|       |		/* check the hmac */
  344|  19.3k|		if (checkmac() != DROPBEAR_SUCCESS) {
  ------------------
  |  |  111|  19.3k|#define DROPBEAR_SUCCESS 0
  ------------------
  |  Branch (344:7): [True: 0, False: 19.3k]
  ------------------
  345|      0|			dropbear_exit("Integrity error");
  346|      0|		}
  347|       |
  348|  19.3k|	}
  349|       |	
  350|  19.3k|#if DROPBEAR_FUZZ
  351|  19.3k|	fuzz_dump(ses.readbuf->data, ses.readbuf->len);
  352|  19.3k|#endif
  353|       |
  354|       |	/* get padding length */
  355|  19.3k|	buf_setpos(ses.readbuf, PACKET_PADDING_OFF);
  ------------------
  |  |   48|  19.3k|#define PACKET_PADDING_OFF 4
  ------------------
  356|  19.3k|	padlen = buf_getbyte(ses.readbuf);
  357|       |		
  358|       |	/* payload length */
  359|       |	/* - 4 - 1 is for LEN and PADLEN values */
  360|  19.3k|	len = ses.readbuf->len - padlen - 4 - 1 - macsize;
  361|  19.3k|	if ((len > RECV_MAX_PAYLOAD_LEN+ZLIB_COMPRESS_EXPANSION) || (len < 1)) {
  ------------------
  |  |  555|  19.3k|#define RECV_MAX_PAYLOAD_LEN 32768
  ------------------
              	if ((len > RECV_MAX_PAYLOAD_LEN+ZLIB_COMPRESS_EXPANSION) || (len < 1)) {
  ------------------
  |  |   50|  19.3k|#define ZLIB_COMPRESS_EXPANSION (((RECV_MAX_PAYLOAD_LEN/16384)+1)*5 + 6)
  |  |  ------------------
  |  |  |  |  555|  19.3k|#define RECV_MAX_PAYLOAD_LEN 32768
  |  |  ------------------
  ------------------
  |  Branch (361:6): [True: 15, False: 19.3k]
  |  Branch (361:62): [True: 1, False: 19.3k]
  ------------------
  362|     16|		dropbear_exit("Bad packet size %u", len);
  363|     16|	}
  364|       |
  365|  19.3k|	buf_setpos(ses.readbuf, PACKET_PAYLOAD_OFF);
  ------------------
  |  |   49|  19.3k|#define PACKET_PAYLOAD_OFF 5
  ------------------
  366|       |
  367|       |#ifndef DISABLE_ZLIB
  368|       |	if (is_compress_recv()) {
  369|       |		/* decompress */
  370|       |		ses.payload = buf_decompress(ses.readbuf, len);
  371|       |		buf_setpos(ses.payload, 0);
  372|       |		ses.payload_beginning = 0;
  373|       |		buf_free(ses.readbuf);
  374|       |	} else 
  375|       |#endif
  376|  19.3k|	{
  377|  19.3k|		ses.payload = ses.readbuf;
  378|  19.3k|		ses.payload_beginning = ses.payload->pos;
  379|  19.3k|		buf_setlen(ses.payload, ses.payload->pos + len);
  380|  19.3k|	}
  381|  19.3k|	ses.readbuf = NULL;
  382|       |
  383|  19.3k|	ses.recvseq++;
  384|       |
  385|  19.3k|	TRACE2(("leave decrypt_packet"))
  386|  19.3k|}
maybe_flush_reply_queue:
  502|  94.1k|void maybe_flush_reply_queue() {
  503|  94.1k|	struct packetlist *tmp_item = NULL, *curr_item = NULL;
  504|  94.1k|	if (!ses.dataallowed)
  ------------------
  |  Branch (504:6): [True: 94.1k, False: 0]
  ------------------
  505|  94.1k|	{
  506|  94.1k|		TRACE(("maybe_empty_reply_queue - no data allowed"))
  507|  94.1k|		return;
  508|  94.1k|	}
  509|       |		
  510|      0|	for (curr_item = ses.reply_queue_head; curr_item; ) {
  ------------------
  |  Branch (510:41): [True: 0, False: 0]
  ------------------
  511|      0|		CHECKCLEARTOWRITE();
  512|      0|		buf_putbytes(ses.writepayload,
  513|      0|			curr_item->payload->data, curr_item->payload->len);
  514|       |			
  515|      0|		buf_free(curr_item->payload);
  516|      0|		tmp_item = curr_item;
  517|      0|		curr_item = curr_item->next;
  518|      0|		m_free(tmp_item);
  ------------------
  |  |   24|      0|#define m_free(X) do {m_free_direct(X); (X) = NULL;} while (0)
  |  |  ------------------
  |  |  |  Branch (24:61): [Folded, False: 0]
  |  |  ------------------
  ------------------
  519|      0|		encrypt_packet();
  520|      0|	}
  521|       |	ses.reply_queue_head = ses.reply_queue_tail = NULL;
  522|      0|	ses.reply_queue_len = 0;
  523|      0|}
encrypt_packet:
  527|  23.8k|void encrypt_packet() {
  528|       |
  529|  23.8k|	unsigned char padlen;
  530|  23.8k|	unsigned char blocksize, mac_size;
  531|  23.8k|	buffer * writebuf; /* the packet which will go on the wire. This is 
  532|       |	                      encrypted in-place. */
  533|  23.8k|	unsigned char packet_type;
  534|  23.8k|	unsigned int len, encrypt_buf_size;
  535|  23.8k|	unsigned char mac_bytes[MAX_MAC_LEN];
  536|       |
  537|  23.8k|	time_t now;
  538|       |	
  539|  23.8k|	TRACE2(("enter encrypt_packet()"))
  540|       |
  541|  23.8k|	buf_setpos(ses.writepayload, 0);
  542|  23.8k|	packet_type = buf_getbyte(ses.writepayload);
  543|  23.8k|	buf_setpos(ses.writepayload, 0);
  544|       |
  545|  23.8k|	TRACE2(("encrypt_packet type is %d", packet_type))
  546|       |	
  547|  23.8k|	if ((!ses.dataallowed && !packet_is_okay_kex(packet_type))) {
  ------------------
  |  Branch (547:7): [True: 20.4k, False: 3.41k]
  |  Branch (547:27): [True: 496, False: 19.9k]
  ------------------
  548|       |		/* During key exchange only particular packets are allowed.
  549|       |			Since this packet_type isn't OK we just enqueue it to send 
  550|       |			after the KEX, see maybe_flush_reply_queue */
  551|    496|		enqueue_reply_packet();
  552|    496|		return;
  553|    496|	}
  554|       |		
  555|  23.3k|	blocksize = ses.keys->trans.algo_crypt->blocksize;
  556|  23.3k|	mac_size = ses.keys->trans.algo_mac->hashsize;
  557|       |
  558|       |	/* Encrypted packet len is payload+5. We need to then make sure
  559|       |	 * there is enough space for padding or MIN_PACKET_LEN. 
  560|       |	 * Add extra 3 since we need at least 4 bytes of padding */
  561|  23.3k|	encrypt_buf_size = (ses.writepayload->len+4+1) 
  562|  23.3k|		+ MAX(MIN_PACKET_LEN, blocksize) + 3
  ------------------
  |  Branch (562:5): [True: 23.3k, False: 0]
  ------------------
  563|       |	/* add space for the MAC at the end */
  564|  23.3k|				+ mac_size
  565|       |#ifndef DISABLE_ZLIB
  566|       |	/* some extra in case 'compression' makes it larger */
  567|       |				+ ZLIB_COMPRESS_EXPANSION
  568|       |#endif
  569|       |	/* and an extra cleartext (stripped before transmission) byte for the
  570|       |	 * packet type */
  571|  23.3k|				+ 1;
  572|       |
  573|  23.3k|	writebuf = buf_new(encrypt_buf_size);
  574|  23.3k|	buf_setlen(writebuf, PACKET_PAYLOAD_OFF);
  ------------------
  |  |   49|  23.3k|#define PACKET_PAYLOAD_OFF 5
  ------------------
  575|  23.3k|	buf_setpos(writebuf, PACKET_PAYLOAD_OFF);
  ------------------
  |  |   49|  23.3k|#define PACKET_PAYLOAD_OFF 5
  ------------------
  576|       |
  577|       |#ifndef DISABLE_ZLIB
  578|       |	/* compression */
  579|       |	if (is_compress_trans()) {
  580|       |		buf_compress(writebuf, ses.writepayload, ses.writepayload->len);
  581|       |	} else
  582|       |#endif
  583|  23.3k|	{
  584|  23.3k|		memcpy(buf_getwriteptr(writebuf, ses.writepayload->len),
  585|  23.3k|				buf_getptr(ses.writepayload, ses.writepayload->len),
  586|  23.3k|				ses.writepayload->len);
  587|  23.3k|		buf_incrwritepos(writebuf, ses.writepayload->len);
  588|  23.3k|	}
  589|       |
  590|       |	/* finished with payload */
  591|  23.3k|	buf_setpos(ses.writepayload, 0);
  592|  23.3k|	buf_setlen(ses.writepayload, 0);
  593|       |
  594|       |	/* length of padding - packet length excluding the packetlength uint32
  595|       |	 * field in aead mode must be a multiple of blocksize, with a minimum of
  596|       |	 * 4 bytes of padding */
  597|  23.3k|	len = writebuf->len;
  598|  23.3k|#if DROPBEAR_AEAD_MODE
  599|  23.3k|	if (ses.keys->trans.crypt_mode->aead_crypt) {
  ------------------
  |  Branch (599:6): [True: 0, False: 23.3k]
  ------------------
  600|      0|		len -= 4;
  601|      0|	}
  602|  23.3k|#endif
  603|  23.3k|	padlen = blocksize - len % blocksize;
  604|  23.3k|	if (padlen < 4) {
  ------------------
  |  Branch (604:6): [True: 574, False: 22.7k]
  ------------------
  605|    574|		padlen += blocksize;
  606|    574|	}
  607|       |	/* check for min packet length */
  608|  23.3k|	if (writebuf->len + padlen < MIN_PACKET_LEN) {
  ------------------
  |  |  247|  23.3k|#define MIN_PACKET_LEN 16
  ------------------
  |  Branch (608:6): [True: 0, False: 23.3k]
  ------------------
  609|      0|		padlen += blocksize;
  610|      0|	}
  611|       |
  612|  23.3k|	buf_setpos(writebuf, 0);
  613|       |	/* packet length excluding the packetlength uint32 */
  614|  23.3k|	buf_putint(writebuf, writebuf->len + padlen - 4);
  615|       |
  616|       |	/* padding len */
  617|  23.3k|	buf_putbyte(writebuf, padlen);
  618|       |	/* actual padding */
  619|  23.3k|	buf_setpos(writebuf, writebuf->len);
  620|  23.3k|	buf_incrlen(writebuf, padlen);
  621|  23.3k|	genrandom(buf_getptr(writebuf, padlen), padlen);
  622|       |
  623|  23.3k|#if DROPBEAR_AEAD_MODE
  624|  23.3k|	if (ses.keys->trans.crypt_mode->aead_crypt) {
  ------------------
  |  Branch (624:6): [True: 0, False: 23.3k]
  ------------------
  625|       |		/* do the actual encryption, in-place */
  626|      0|		buf_setpos(writebuf, 0);
  627|       |		/* encrypt it in-place*/
  628|      0|		len = writebuf->len;
  629|      0|		buf_incrlen(writebuf, mac_size);
  630|      0|		if (ses.keys->trans.crypt_mode->aead_crypt(ses.transseq,
  ------------------
  |  Branch (630:7): [True: 0, False: 0]
  ------------------
  631|      0|					buf_getptr(writebuf, len),
  632|      0|					buf_getwriteptr(writebuf, len + mac_size),
  633|      0|					len, mac_size,
  634|      0|					&ses.keys->trans.cipher_state, LTC_ENCRYPT) != CRYPT_OK) {
  ------------------
  |  |   68|      0|#define LTC_ENCRYPT 0
  ------------------
  635|      0|			dropbear_exit("Error encrypting");
  636|      0|		}
  637|      0|		buf_incrpos(writebuf, len + mac_size);
  638|      0|	} else
  639|  23.3k|#endif
  640|  23.3k|	{
  641|  23.3k|		make_mac(ses.transseq, &ses.keys->trans, writebuf, writebuf->len, mac_bytes);
  642|       |
  643|       |		/* do the actual encryption, in-place */
  644|  23.3k|		buf_setpos(writebuf, 0);
  645|       |		/* encrypt it in-place*/
  646|  23.3k|		len = writebuf->len;
  647|  23.3k|		if (ses.keys->trans.crypt_mode->encrypt(
  ------------------
  |  Branch (647:7): [True: 0, False: 23.3k]
  ------------------
  648|  23.3k|					buf_getptr(writebuf, len),
  649|  23.3k|					buf_getwriteptr(writebuf, len),
  650|  23.3k|					len,
  651|  23.3k|					&ses.keys->trans.cipher_state) != CRYPT_OK) {
  652|      0|			dropbear_exit("Error encrypting");
  653|      0|		}
  654|  23.3k|		buf_incrpos(writebuf, len);
  655|       |
  656|       |		/* stick the MAC on it */
  657|  23.3k|		buf_putbytes(writebuf, mac_bytes, mac_size);
  658|  23.3k|	}
  659|       |
  660|       |	/* Update counts */
  661|  23.3k|	ses.kexstate.datatrans += writebuf->len;
  662|       |
  663|  23.3k|	writebuf_enqueue(writebuf);
  664|       |
  665|       |	/* Update counts */
  666|  23.3k|	ses.transseq++;
  667|       |
  668|  23.3k|	now = monotonic_now();
  669|  23.3k|	ses.last_packet_time_any_sent = now;
  670|       |	/* idle timeout shouldn't be affected by responses to keepalives.
  671|       |	send_msg_keepalive() itself also does tricks with 
  672|       |	ses.last_packet_idle_time - read that if modifying this code */
  673|  23.3k|	if (packet_type != SSH_MSG_REQUEST_FAILURE
  ------------------
  |  |   65|  46.7k|#define SSH_MSG_REQUEST_FAILURE                 82
  ------------------
  |  Branch (673:6): [True: 23.3k, False: 0]
  ------------------
  674|  23.3k|		&& packet_type != SSH_MSG_UNIMPLEMENTED
  ------------------
  |  |   31|  46.7k|#define SSH_MSG_UNIMPLEMENTED          3
  ------------------
  |  Branch (674:6): [True: 9.22k, False: 14.1k]
  ------------------
  675|  9.22k|		&& packet_type != SSH_MSG_IGNORE) {
  ------------------
  |  |   30|  9.22k|#define SSH_MSG_IGNORE                 2
  ------------------
  |  Branch (675:6): [True: 9.22k, False: 0]
  ------------------
  676|  9.22k|		ses.last_packet_time_idle = now;
  677|       |
  678|  9.22k|	}
  679|       |
  680|  23.3k|	TRACE2(("leave encrypt_packet()"))
  681|  23.3k|}
writebuf_enqueue:
  683|  26.7k|void writebuf_enqueue(buffer * writebuf) {
  684|       |	/* enqueue the packet for sending. It will get freed after transmission. */
  685|  26.7k|	buf_setpos(writebuf, 0);
  686|  26.7k|	enqueue(&ses.writequeue, (void*)writebuf);
  687|  26.7k|	ses.writequeue_len += writebuf->len;
  688|  26.7k|}
packet.c:read_packet_init:
  214|  53.9k|static int read_packet_init() {
  215|       |
  216|  53.9k|	unsigned int maxlen;
  217|  53.9k|	int slen;
  218|  53.9k|	unsigned int len, plen;
  219|  53.9k|	unsigned int blocksize;
  220|  53.9k|	unsigned int macsize;
  221|       |
  222|       |
  223|  53.9k|	blocksize = ses.keys->recv.algo_crypt->blocksize;
  224|  53.9k|	macsize = ses.keys->recv.algo_mac->hashsize;
  225|       |
  226|  53.9k|	if (ses.readbuf == NULL) {
  ------------------
  |  Branch (226:6): [True: 20.1k, False: 33.7k]
  ------------------
  227|       |		/* start of a new packet */
  228|  20.1k|		ses.readbuf = buf_new(INIT_READBUF);
  ------------------
  |  |   51|  20.1k|#define INIT_READBUF 128
  ------------------
  229|  20.1k|	}
  230|       |
  231|  53.9k|	maxlen = blocksize - ses.readbuf->pos;
  232|       |			
  233|       |	/* read the rest of the packet if possible */
  234|  53.9k|	slen = read(ses.sock_in, buf_getwriteptr(ses.readbuf, maxlen),
  ------------------
  |  |   55|  53.9k|#define read(fd, buf, count) wrapfd_read(fd, buf, count)
  ------------------
  235|  53.9k|			maxlen);
  236|  53.9k|	if (slen == 0) {
  ------------------
  |  Branch (236:6): [True: 586, False: 53.3k]
  ------------------
  237|    586|		ses.remoteclosed();
  238|    586|	}
  239|  53.9k|	if (slen < 0) {
  ------------------
  |  Branch (239:6): [True: 92, False: 53.8k]
  ------------------
  240|     92|		if (errno == EINTR || errno == EAGAIN) {
  ------------------
  |  Branch (240:7): [True: 87, False: 5]
  |  Branch (240:25): [True: 0, False: 5]
  ------------------
  241|     87|			TRACE2(("leave read_packet_init: EINTR"))
  242|     87|			return DROPBEAR_FAILURE;
  ------------------
  |  |  112|     87|#define DROPBEAR_FAILURE -1
  ------------------
  243|     87|		}
  244|      5|		dropbear_exit("Error reading: %s", strerror(errno));
  245|     92|	}
  246|       |
  247|  53.8k|	buf_incrwritepos(ses.readbuf, slen);
  248|       |
  249|  53.8k|	if ((unsigned int)slen != maxlen) {
  ------------------
  |  Branch (249:6): [True: 33.7k, False: 20.1k]
  ------------------
  250|       |		/* don't have enough bytes to determine length, get next time */
  251|  33.7k|		return DROPBEAR_FAILURE;
  ------------------
  |  |  112|  33.7k|#define DROPBEAR_FAILURE -1
  ------------------
  252|  33.7k|	}
  253|       |
  254|       |	/* now we have the first block, need to get packet length, so we decrypt
  255|       |	 * the first block (only need first 4 bytes) */
  256|  20.1k|	buf_setpos(ses.readbuf, 0);
  257|  20.1k|#if DROPBEAR_AEAD_MODE
  258|  20.1k|	if (ses.keys->recv.crypt_mode->aead_crypt) {
  ------------------
  |  Branch (258:6): [True: 0, False: 20.1k]
  ------------------
  259|      0|		if (ses.keys->recv.crypt_mode->aead_getlength(ses.recvseq,
  ------------------
  |  Branch (259:7): [True: 0, False: 0]
  ------------------
  260|      0|					buf_getptr(ses.readbuf, blocksize), &plen,
  261|      0|					blocksize,
  262|      0|					&ses.keys->recv.cipher_state) != CRYPT_OK) {
  263|      0|			dropbear_exit("Error decrypting");
  264|      0|		}
  265|      0|		len = plen + 4 + macsize;
  266|      0|	} else
  267|  20.1k|#endif
  268|  20.1k|	{
  269|  20.1k|		if (ses.keys->recv.crypt_mode->decrypt(buf_getptr(ses.readbuf, blocksize), 
  ------------------
  |  Branch (269:7): [True: 0, False: 20.1k]
  ------------------
  270|  20.1k|					buf_getwriteptr(ses.readbuf, blocksize),
  271|  20.1k|					blocksize,
  272|  20.1k|					&ses.keys->recv.cipher_state) != CRYPT_OK) {
  273|      0|			dropbear_exit("Error decrypting");
  274|      0|		}
  275|  20.1k|		plen = buf_getint(ses.readbuf) + 4;
  276|  20.1k|		len = plen + macsize;
  277|  20.1k|	}
  278|       |
  279|  20.1k|	TRACE2(("packet size is %u, block %u mac %u", len, blocksize, macsize))
  280|       |
  281|       |	/* check packet length. plen max to catch integer wraparound. */
  282|  20.1k|	if ((len > RECV_MAX_PACKET_LEN) ||
  ------------------
  |  |  249|  20.1k|#define RECV_MAX_PACKET_LEN (MAX(35000, ((RECV_MAX_PAYLOAD_LEN)+100)))
  ------------------
  |  Branch (282:6): [True: 625, False: 19.5k]
  |  Branch (282:13): [True: 19.5k, Folded]
  ------------------
  283|  19.5k|	    (plen > RECV_MAX_PACKET_LEN) ||
  ------------------
  |  |  249|  19.5k|#define RECV_MAX_PACKET_LEN (MAX(35000, ((RECV_MAX_PAYLOAD_LEN)+100)))
  ------------------
  |  Branch (283:6): [True: 0, False: 19.5k]
  |  Branch (283:14): [True: 19.5k, Folded]
  ------------------
  284|  19.5k|		(plen < blocksize) ||
  ------------------
  |  Branch (284:3): [True: 5, False: 19.5k]
  ------------------
  285|  19.5k|		(plen % blocksize != 0)) {
  ------------------
  |  Branch (285:3): [True: 15, False: 19.4k]
  ------------------
  286|     59|		dropbear_exit("Integrity error (bad packet size %u)", plen);
  287|     59|	}
  288|       |
  289|  20.0k|	if (len > ses.readbuf->size) {
  ------------------
  |  Branch (289:6): [True: 4.17k, False: 15.8k]
  ------------------
  290|  4.17k|		ses.readbuf = buf_resize(ses.readbuf, len);		
  291|  4.17k|	}
  292|  20.0k|	buf_setlen(ses.readbuf, len);
  293|  20.0k|	buf_setpos(ses.readbuf, blocksize);
  294|  20.0k|	return DROPBEAR_SUCCESS;
  ------------------
  |  |  111|  20.0k|#define DROPBEAR_SUCCESS 0
  ------------------
  295|  20.1k|}
packet.c:checkmac:
  390|  19.3k|static int checkmac() {
  391|       |
  392|  19.3k|	unsigned char mac_bytes[MAX_MAC_LEN];
  393|  19.3k|	unsigned int mac_size, contents_len;
  394|       |	
  395|  19.3k|	mac_size = ses.keys->recv.algo_mac->hashsize;
  396|  19.3k|	contents_len = ses.readbuf->len - mac_size;
  397|       |
  398|  19.3k|	buf_setpos(ses.readbuf, 0);
  399|  19.3k|	make_mac(ses.recvseq, &ses.keys->recv, ses.readbuf, contents_len, mac_bytes);
  400|       |
  401|  19.3k|#if DROPBEAR_FUZZ
  402|  19.3k|	if (fuzz.fuzzing) {
  ------------------
  |  Branch (402:6): [True: 19.3k, False: 0]
  ------------------
  403|       |	 	/* fail 1 in 2000 times to test error path. */
  404|  19.3k|		unsigned int value = 0;
  405|  19.3k|		if (mac_size > sizeof(value)) {
  ------------------
  |  Branch (405:7): [True: 0, False: 19.3k]
  ------------------
  406|      0|			memcpy(&value, mac_bytes, sizeof(value));
  407|      0|		}
  408|  19.3k|		if (value % 2000 == 99) {
  ------------------
  |  Branch (408:7): [True: 0, False: 19.3k]
  ------------------
  409|      0|			return DROPBEAR_FAILURE;
  ------------------
  |  |  112|      0|#define DROPBEAR_FAILURE -1
  ------------------
  410|      0|		}
  411|  19.3k|		return DROPBEAR_SUCCESS;
  ------------------
  |  |  111|  19.3k|#define DROPBEAR_SUCCESS 0
  ------------------
  412|  19.3k|	}
  413|      0|#endif
  414|       |
  415|       |	/* compare the hash */
  416|      0|	buf_setpos(ses.readbuf, contents_len);
  417|      0|	if (constant_time_memcmp(mac_bytes, buf_getptr(ses.readbuf, mac_size), mac_size) != 0) {
  ------------------
  |  Branch (417:6): [True: 0, False: 0]
  ------------------
  418|      0|		return DROPBEAR_FAILURE;
  ------------------
  |  |  112|      0|#define DROPBEAR_FAILURE -1
  ------------------
  419|      0|	} else {
  420|      0|		return DROPBEAR_SUCCESS;
  ------------------
  |  |  111|      0|#define DROPBEAR_SUCCESS 0
  ------------------
  421|      0|	}
  422|      0|}
packet.c:packet_is_okay_kex:
  464|  20.4k|static int packet_is_okay_kex(unsigned char type) {
  465|  20.4k|	if (type >= SSH_MSG_USERAUTH_REQUEST) {
  ------------------
  |  |   42|  20.4k|#define SSH_MSG_USERAUTH_REQUEST            50
  ------------------
  |  Branch (465:6): [True: 248, False: 20.2k]
  ------------------
  466|    248|		return 0;
  467|    248|	}
  468|  20.2k|	if (type == SSH_MSG_SERVICE_REQUEST || type == SSH_MSG_SERVICE_ACCEPT) {
  ------------------
  |  |   33|  40.4k|#define SSH_MSG_SERVICE_REQUEST        5
  ------------------
              	if (type == SSH_MSG_SERVICE_REQUEST || type == SSH_MSG_SERVICE_ACCEPT) {
  ------------------
  |  |   34|  19.9k|#define SSH_MSG_SERVICE_ACCEPT         6
  ------------------
  |  Branch (468:6): [True: 248, False: 19.9k]
  |  Branch (468:41): [True: 0, False: 19.9k]
  ------------------
  469|    248|		return 0;
  470|    248|	}
  471|  19.9k|	if (type == SSH_MSG_KEXINIT) {
  ------------------
  |  |   36|  19.9k|#define SSH_MSG_KEXINIT                20
  ------------------
  |  Branch (471:6): [True: 0, False: 19.9k]
  ------------------
  472|       |		/* XXX should this die horribly if !dataallowed ?? */
  473|      0|		return 0;
  474|      0|	}
  475|  19.9k|	return 1;
  476|  19.9k|}
packet.c:enqueue_reply_packet:
  478|    496|static void enqueue_reply_packet(void) {
  479|    496|	struct packetlist * new_item = NULL;
  480|       |
  481|    496|	if (ses.reply_queue_len > MAX_DEFER_REPLY_QUEUE) {
  ------------------
  |  |  265|    496|#define MAX_DEFER_REPLY_QUEUE MAX_CHANNELS
  |  |  ------------------
  |  |  |  |  256|    496|#define MAX_CHANNELS 1000 /* simple mem restriction, includes each tcp/x11
  |  |  ------------------
  ------------------
  |  Branch (481:6): [True: 0, False: 496]
  ------------------
  482|       |		/* This limit should never be reached by a normal peer. */
  483|      0|		dropbear_exit("Full reply queue");
  484|      0|	}
  485|       |
  486|    496|	new_item = m_malloc(sizeof(struct packetlist));
  487|    496|	new_item->next = NULL;
  488|       |	
  489|    496|	new_item->payload = buf_newcopy(ses.writepayload);
  490|    496|	buf_setpos(ses.writepayload, 0);
  491|    496|	buf_setlen(ses.writepayload, 0);
  492|       |	
  493|    496|	if (ses.reply_queue_tail) {
  ------------------
  |  Branch (493:6): [True: 248, False: 248]
  ------------------
  494|    248|		ses.reply_queue_tail->next = new_item;
  495|    248|	} else {
  496|    248|		ses.reply_queue_head = new_item;
  497|    248|	}
  498|    496|	ses.reply_queue_tail = new_item;
  499|    496|	ses.reply_queue_len++;
  500|    496|}
packet.c:make_mac:
  695|  42.7k|		unsigned char *output_mac) {
  696|  42.7k|	unsigned char seqbuf[4];
  697|  42.7k|	unsigned long bufsize;
  698|  42.7k|	hmac_state hmac;
  699|       |
  700|  42.7k|	if (key_state->algo_mac->hashsize > 0) {
  ------------------
  |  Branch (700:6): [True: 0, False: 42.7k]
  ------------------
  701|       |		/* calculate the mac */
  702|      0|		if (hmac_init(&hmac, 
  ------------------
  |  Branch (702:7): [True: 0, False: 0]
  ------------------
  703|      0|					key_state->hash_index,
  704|      0|					key_state->mackey,
  705|      0|					key_state->algo_mac->keysize) != CRYPT_OK) {
  706|      0|			dropbear_exit("HMAC error");
  707|      0|		}
  708|       |	
  709|       |		/* sequence number */
  710|      0|		STORE32H(seqno, seqbuf);
  ------------------
  |  |   62|      0|#define STORE32H(x, y)                          \
  |  |   63|      0|do { ulong32 __t = __builtin_bswap32 ((x));     \
  |  |   64|      0|      XMEMCPY ((y), &__t, 4); } while(0)
  |  |  ------------------
  |  |  |  |   39|      0|#define XMEMCPY  memcpy
  |  |  ------------------
  |  |  |  Branch (64:39): [Folded, False: 0]
  |  |  ------------------
  ------------------
  711|      0|		if (hmac_process(&hmac, seqbuf, 4) != CRYPT_OK) {
  ------------------
  |  Branch (711:7): [True: 0, False: 0]
  ------------------
  712|      0|			dropbear_exit("HMAC error");
  713|      0|		}
  714|       |	
  715|       |		/* the actual contents */
  716|      0|		buf_setpos(clear_buf, 0);
  717|      0|		if (hmac_process(&hmac, 
  ------------------
  |  Branch (717:7): [True: 0, False: 0]
  ------------------
  718|      0|					buf_getptr(clear_buf, clear_len),
  719|      0|					clear_len) != CRYPT_OK) {
  720|      0|			dropbear_exit("HMAC error");
  721|      0|		}
  722|       |	
  723|      0|		bufsize = MAX_MAC_LEN;
  ------------------
  |  |  147|      0|#define MAX_MAC_LEN 32
  ------------------
  724|      0|		if (hmac_done(&hmac, output_mac, &bufsize) != CRYPT_OK) {
  ------------------
  |  Branch (724:7): [True: 0, False: 0]
  ------------------
  725|      0|			dropbear_exit("HMAC error");
  726|      0|		}
  727|      0|	}
  728|  42.7k|	TRACE2(("leave writemac"))
  729|  42.7k|}

process_packet:
   43|  19.3k|void process_packet() {
   44|       |
   45|  19.3k|	unsigned char type;
   46|  19.3k|	unsigned int i;
   47|  19.3k|	unsigned int first_strict_kex = ses.kexstate.strict_kex && !ses.kexstate.recvfirstnewkeys;
  ------------------
  |  Branch (47:34): [True: 0, False: 19.3k]
  |  Branch (47:61): [True: 0, False: 0]
  ------------------
   48|  19.3k|	time_t now;
   49|       |
   50|  19.3k|	TRACE2(("enter process_packet"))
   51|       |
   52|  19.3k|	type = buf_getbyte(ses.payload);
   53|  19.3k|	TRACE(("process_packet: packet type = %d,  len %d", type, ses.payload->len))
   54|       |
   55|  19.3k|	now = monotonic_now();
   56|  19.3k|	ses.last_packet_time_keepalive_recv = now;
   57|       |
   58|       |
   59|  19.3k|	if (type == SSH_MSG_DISCONNECT) {
  ------------------
  |  |   29|  19.3k|#define SSH_MSG_DISCONNECT             1
  ------------------
  |  Branch (59:6): [True: 4, False: 19.3k]
  ------------------
   60|       |		/* Allowed at any time */
   61|      4|		dropbear_close("Disconnect received");
   62|      4|	}
   63|       |
   64|       |	/* These packets may be received at any time,
   65|       |	   except during first kex with strict kex */
   66|  19.3k|	if (!first_strict_kex) {
  ------------------
  |  Branch (66:6): [True: 19.3k, False: 4]
  ------------------
   67|  19.3k|		switch(type) {
  ------------------
  |  Branch (67:10): [True: 390, False: 18.9k]
  ------------------
   68|     77|			case SSH_MSG_IGNORE:
  ------------------
  |  |   30|     77|#define SSH_MSG_IGNORE                 2
  ------------------
  |  Branch (68:4): [True: 77, False: 19.2k]
  ------------------
   69|     77|				goto out;
   70|    247|			case SSH_MSG_DEBUG:
  ------------------
  |  |   32|    247|#define SSH_MSG_DEBUG                  4
  ------------------
  |  Branch (70:4): [True: 247, False: 19.0k]
  ------------------
   71|    247|				goto out;
   72|     66|			case SSH_MSG_UNIMPLEMENTED:
  ------------------
  |  |   31|     66|#define SSH_MSG_UNIMPLEMENTED          3
  ------------------
  |  Branch (72:4): [True: 66, False: 19.2k]
  ------------------
   73|     66|				TRACE(("SSH_MSG_UNIMPLEMENTED"))
   74|     66|				goto out;
   75|  19.3k|		}
   76|  19.3k|	}
   77|       |
   78|       |	/* Ignore these packet types so that keepalives don't interfere with
   79|       |	idle detection. This is slightly incorrect since a tcp forwarded
   80|       |	global request with failure won't trigger the idle timeout,
   81|       |	but that's probably acceptable */
   82|  18.9k|	if (!(type == SSH_MSG_GLOBAL_REQUEST 
  ------------------
  |  |   63|  37.9k|#define SSH_MSG_GLOBAL_REQUEST                  80
  ------------------
  |  Branch (82:8): [True: 5, False: 18.9k]
  ------------------
   83|  18.9k|		|| type == SSH_MSG_REQUEST_FAILURE
  ------------------
  |  |   65|  37.9k|#define SSH_MSG_REQUEST_FAILURE                 82
  ------------------
  |  Branch (83:6): [True: 1, False: 18.9k]
  ------------------
   84|  18.9k|		|| type == SSH_MSG_CHANNEL_FAILURE)) {
  ------------------
  |  |   76|  18.9k|#define SSH_MSG_CHANNEL_FAILURE                 100
  ------------------
  |  Branch (84:6): [True: 1, False: 18.9k]
  ------------------
   85|  18.9k|		ses.last_packet_time_idle = now;
   86|  18.9k|	}
   87|       |
   88|       |	/* This applies for KEX, where the spec says the next packet MUST be
   89|       |	 * NEWKEYS */
   90|  18.9k|	if (ses.requirenext != 0) {
  ------------------
  |  Branch (90:6): [True: 18.9k, False: 4]
  ------------------
   91|  18.9k|		if (ses.requirenext == type)
  ------------------
  |  Branch (91:7): [True: 4.74k, False: 14.2k]
  ------------------
   92|  4.74k|		{
   93|       |			/* Got what we expected */
   94|  4.74k|			TRACE(("got expected packet %d during kexinit", type))
   95|  4.74k|		}
   96|  14.2k|		else
   97|  14.2k|		{
   98|       |			/* RFC4253 7.1 - various messages are allowed at this point.
   99|       |			The only ones we know about have already been handled though,
  100|       |			so just return "unimplemented" */
  101|  14.2k|			if (type >= 1 && type <= 49
  ------------------
  |  Branch (101:8): [True: 14.1k, False: 18]
  |  Branch (101:21): [True: 14.1k, False: 29]
  ------------------
  102|  14.1k|				&& type != SSH_MSG_SERVICE_REQUEST
  ------------------
  |  |   33|  28.3k|#define SSH_MSG_SERVICE_REQUEST        5
  ------------------
  |  Branch (102:8): [True: 14.1k, False: 2]
  ------------------
  103|  14.1k|				&& type != SSH_MSG_SERVICE_ACCEPT
  ------------------
  |  |   34|  28.3k|#define SSH_MSG_SERVICE_ACCEPT         6
  ------------------
  |  Branch (103:8): [True: 14.1k, False: 1]
  ------------------
  104|  14.1k|				&& type != SSH_MSG_KEXINIT
  ------------------
  |  |   36|  28.3k|#define SSH_MSG_KEXINIT                20
  ------------------
  |  Branch (104:8): [True: 14.1k, False: 1]
  ------------------
  105|  14.1k|				&& !first_strict_kex)
  ------------------
  |  Branch (105:8): [True: 14.1k, False: 0]
  ------------------
  106|  14.1k|			{
  107|  14.1k|				TRACE(("unknown allowed packet during kexinit"))
  108|  14.1k|				recv_unimplemented();
  109|  14.1k|				goto out;
  110|  14.1k|			}
  111|     51|			else
  112|     51|			{
  113|     51|				TRACE(("disallowed packet during kexinit"))
  114|     51|				dropbear_exit("Unexpected packet type %d, expected %d", type,
  115|     51|						ses.requirenext);
  116|     51|			}
  117|  14.2k|		}
  118|  18.9k|	}
  119|       |
  120|       |	/* Check if we should ignore this packet. Used currently only for
  121|       |	 * KEX code, with first_kex_packet_follows */
  122|  4.75k|	if (ses.ignorenext) {
  ------------------
  |  Branch (122:6): [True: 3, False: 4.75k]
  ------------------
  123|      3|		TRACE(("Ignoring packet, type = %d", type))
  124|      3|		ses.ignorenext = 0;
  125|      3|		goto out;
  126|      3|	}
  127|       |
  128|       |	/* Only clear the flag after we have checked ignorenext */
  129|  4.75k|	if (ses.requirenext != 0 && ses.requirenext == type)
  ------------------
  |  Branch (129:6): [True: 4.74k, False: 4]
  |  Branch (129:30): [True: 4.74k, False: 0]
  ------------------
  130|  4.74k|	{
  131|  4.74k|		ses.requirenext = 0;
  132|  4.74k|	}
  133|       |
  134|       |
  135|       |	/* Kindly the protocol authors gave all the preauth packets type values
  136|       |	 * less-than-or-equal-to 60 ( == MAX_UNAUTH_PACKET_TYPE ).
  137|       |	 * NOTE: if the protocol changes and new types are added, revisit this 
  138|       |	 * assumption */
  139|  4.75k|	if ( !ses.authstate.authdone && type > MAX_UNAUTH_PACKET_TYPE ) {
  ------------------
  |  |   38|  4.74k|#define MAX_UNAUTH_PACKET_TYPE SSH_MSG_USERAUTH_PK_OK
  |  |  ------------------
  |  |  |  |   52|  4.74k|#define SSH_MSG_USERAUTH_PK_OK				60
  |  |  ------------------
  ------------------
  |  Branch (139:7): [True: 4.74k, False: 4]
  |  Branch (139:34): [True: 0, False: 4.74k]
  ------------------
  140|      0|		dropbear_exit("Received message %d before userauth", type);
  141|      0|	}
  142|       |
  143|  30.4k|	for (i = 0; ; i++) {
  144|  30.4k|		if (ses.packettypes[i].type == 0) {
  ------------------
  |  Branch (144:7): [True: 0, False: 30.4k]
  ------------------
  145|       |			/* end of list */
  146|      0|			break;
  147|      0|		}
  148|       |
  149|  30.4k|		if (ses.packettypes[i].type == type) {
  ------------------
  |  Branch (149:7): [True: 4.74k, False: 25.6k]
  ------------------
  150|  4.74k|			ses.packettypes[i].handler();
  151|  4.74k|			goto out;
  152|  4.74k|		}
  153|  30.4k|	}
  154|       |
  155|       |	
  156|       |	/* TODO do something more here? */
  157|      4|	TRACE(("preauth unknown packet"))
  158|      4|	recv_unimplemented();
  159|       |
  160|  16.9k|out:
  161|  16.9k|	ses.lastpacket = type;
  162|  16.9k|	buf_free(ses.payload);
  163|  16.9k|	ses.payload = NULL;
  164|       |
  165|  16.9k|	TRACE2(("leave process_packet"))
  166|  16.9k|}
process-packet.c:recv_unimplemented:
  174|  14.1k|static void recv_unimplemented() {
  175|       |
  176|  14.1k|	CHECKCLEARTOWRITE();
  177|       |
  178|  14.1k|	buf_putbyte(ses.writepayload, SSH_MSG_UNIMPLEMENTED);
  ------------------
  |  |   31|  14.1k|#define SSH_MSG_UNIMPLEMENTED          3
  ------------------
  179|       |	/* the decryption routine increments the sequence number, we must
  180|       |	 * decrement */
  181|  14.1k|	buf_putint(ses.writepayload, ses.recvseq - 1);
  182|       |
  183|  14.1k|	encrypt_packet();
  184|  14.1k|}

initqueue:
   29|  3.41k|void initqueue(struct Queue* queue) {
   30|       |
   31|  3.41k|	queue->head = NULL;
   32|       |	queue->tail = NULL;
   33|  3.41k|	queue->count = 0;
   34|  3.41k|}
isempty:
   36|   289k|int isempty(const struct Queue* queue) {
   37|       |
   38|       |	return (queue->head == NULL);
   39|   289k|}
dequeue:
   41|  26.7k|void* dequeue(struct Queue* queue) {
   42|       |
   43|  26.7k|	void* ret;
   44|  26.7k|	struct Link* oldhead;
   45|  26.7k|	dropbear_assert(!isempty(queue));
  ------------------
  |  |   86|  26.7k|#define dropbear_assert(X) do { if (!(X)) { fail_assert(#X, __FILE__, __LINE__); } } while (0)
  |  |  ------------------
  |  |  |  Branch (86:37): [True: 0, False: 26.7k]
  |  |  |  Branch (86:93): [Folded, False: 26.7k]
  |  |  ------------------
  ------------------
   46|       |	
   47|  26.7k|	ret = queue->head->item;
   48|  26.7k|	oldhead = queue->head;
   49|       |	
   50|  26.7k|	if (oldhead->link != NULL) {
  ------------------
  |  Branch (50:6): [True: 6.83k, False: 19.9k]
  ------------------
   51|  6.83k|		queue->head = oldhead->link;
   52|  19.9k|	} else {
   53|  19.9k|		queue->head = NULL;
   54|  19.9k|		queue->tail = NULL;
   55|  19.9k|		TRACE(("empty queue dequeing"))
   56|  19.9k|	}
   57|       |
   58|       |	m_free(oldhead);
  ------------------
  |  |   24|  26.7k|#define m_free(X) do {m_free_direct(X); (X) = NULL;} while (0)
  |  |  ------------------
  |  |  |  Branch (24:61): [Folded, False: 26.7k]
  |  |  ------------------
  ------------------
   59|  26.7k|	queue->count--;
   60|  26.7k|	return ret;
   61|  26.7k|}
examine:
   63|  26.7k|void *examine(const struct Queue* queue) {
   64|       |
   65|  26.7k|	dropbear_assert(!isempty(queue));
  ------------------
  |  |   86|  26.7k|#define dropbear_assert(X) do { if (!(X)) { fail_assert(#X, __FILE__, __LINE__); } } while (0)
  |  |  ------------------
  |  |  |  Branch (86:37): [True: 0, False: 26.7k]
  |  |  |  Branch (86:93): [Folded, False: 26.7k]
  |  |  ------------------
  ------------------
   66|  26.7k|	return queue->head->item;
   67|  26.7k|}
enqueue:
   69|  26.7k|void enqueue(struct Queue* queue, void* item) {
   70|       |
   71|  26.7k|	struct Link* newlink;
   72|       |
   73|  26.7k|	newlink = (struct Link*)m_malloc(sizeof(struct Link));
   74|       |
   75|  26.7k|	newlink->item = item;
   76|  26.7k|	newlink->link = NULL;
   77|       |
   78|  26.7k|	if (queue->tail != NULL) {
  ------------------
  |  Branch (78:6): [True: 6.83k, False: 19.9k]
  ------------------
   79|  6.83k|		queue->tail->link = newlink;
   80|  6.83k|	}
   81|  26.7k|	queue->tail = newlink;
   82|       |
   83|  26.7k|	if (queue->head == NULL) {
  ------------------
  |  Branch (83:6): [True: 19.9k, False: 6.83k]
  ------------------
   84|  19.9k|		queue->head = newlink;
   85|  19.9k|	}
   86|  26.7k|	queue->count++;
   87|  26.7k|}

buf_get_rsa_pub_key:
   53|    970|int buf_get_rsa_pub_key(buffer* buf, dropbear_rsa_key *key) {
   54|       |
   55|    970|	int ret = DROPBEAR_FAILURE;
  ------------------
  |  |  112|    970|#define DROPBEAR_FAILURE -1
  ------------------
   56|    970|	TRACE(("enter buf_get_rsa_pub_key"))
   57|    970|	dropbear_assert(key != NULL);
  ------------------
  |  |   86|    970|#define dropbear_assert(X) do { if (!(X)) { fail_assert(#X, __FILE__, __LINE__); } } while (0)
  |  |  ------------------
  |  |  |  Branch (86:37): [True: 0, False: 970]
  |  |  |  Branch (86:93): [Folded, False: 970]
  |  |  ------------------
  ------------------
   58|    970|	m_mp_alloc_init_multi(&key->e, &key->n, NULL);
   59|    970|	key->d = NULL;
   60|    970|	key->p = NULL;
   61|    970|	key->q = NULL;
   62|       |
   63|    970|	buf_incrpos(buf, 4+SSH_SIGNKEY_RSA_LEN); /* int + "ssh-rsa" */
  ------------------
  |  |  117|    970|#define SSH_SIGNKEY_RSA_LEN 7
  ------------------
   64|       |
   65|    970|	if (buf_getmpint(buf, key->e) == DROPBEAR_FAILURE
  ------------------
  |  |  112|  1.94k|#define DROPBEAR_FAILURE -1
  ------------------
  |  Branch (65:6): [True: 6, False: 964]
  ------------------
   66|    964|	 || buf_getmpint(buf, key->n) == DROPBEAR_FAILURE) {
  ------------------
  |  |  112|    964|#define DROPBEAR_FAILURE -1
  ------------------
  |  Branch (66:6): [True: 13, False: 951]
  ------------------
   67|     12|		TRACE(("leave buf_get_rsa_pub_key: failure"))
   68|     12|		goto out;
   69|     12|	}
   70|       |
   71|    958|	if (mp_count_bits(key->n) < MIN_RSA_KEYLEN) {
  ------------------
  |  |   69|    958|#define MIN_RSA_KEYLEN 1024
  ------------------
  |  Branch (71:6): [True: 40, False: 918]
  ------------------
   72|     40|		dropbear_log(LOG_WARNING, "RSA key too short");
   73|     40|		goto out;
   74|     40|	}
   75|       |
   76|       |	/* 64 bit is limit used by openssl, so we won't block any keys in the wild */
   77|    918|	if (mp_count_bits(key->e) > 64) {
  ------------------
  |  Branch (77:6): [True: 4, False: 914]
  ------------------
   78|      4|		dropbear_log(LOG_WARNING, "RSA key bad e");
   79|      4|		goto out;
   80|      4|	}
   81|       |
   82|    914|	TRACE(("leave buf_get_rsa_pub_key: success"))
   83|    914|	ret = DROPBEAR_SUCCESS;
  ------------------
  |  |  111|    914|#define DROPBEAR_SUCCESS 0
  ------------------
   84|    963|out:
   85|    963|	if (ret == DROPBEAR_FAILURE) {
  ------------------
  |  |  112|    963|#define DROPBEAR_FAILURE -1
  ------------------
  |  Branch (85:6): [True: 56, False: 907]
  ------------------
   86|       |		m_mp_free_multi(&key->e, &key->n, NULL);
   87|     56|	}
   88|    963|	return ret;
   89|    914|}
rsa_key_free:
  143|  1.02k|void rsa_key_free(dropbear_rsa_key *key) {
  144|       |
  145|  1.02k|	TRACE2(("enter rsa_key_free"))
  146|       |
  147|  1.02k|	if (key == NULL) {
  ------------------
  |  Branch (147:6): [True: 971, False: 56]
  ------------------
  148|    971|		TRACE2(("leave rsa_key_free: key == NULL"))
  149|    971|		return;
  150|    971|	}
  151|     56|	m_mp_free_multi(&key->d, &key->e, &key->p, &key->q, &key->n, NULL);
  152|       |	m_free(key);
  ------------------
  |  |   24|     56|#define m_free(X) do {m_free_direct(X); (X) = NULL;} while (0)
  |  |  ------------------
  |  |  |  Branch (24:61): [Folded, False: 56]
  |  |  ------------------
  ------------------
  153|     56|	TRACE2(("leave rsa_key_free"))
  154|     56|}
buf_put_rsa_pub_key:
  162|    858|void buf_put_rsa_pub_key(buffer* buf, const dropbear_rsa_key *key) {
  163|       |
  164|    858|	TRACE(("enter buf_put_rsa_pub_key"))
  165|    858|	dropbear_assert(key != NULL);
  ------------------
  |  |   86|    858|#define dropbear_assert(X) do { if (!(X)) { fail_assert(#X, __FILE__, __LINE__); } } while (0)
  |  |  ------------------
  |  |  |  Branch (86:37): [True: 0, False: 858]
  |  |  |  Branch (86:93): [Folded, False: 858]
  |  |  ------------------
  ------------------
  166|       |
  167|    858|	buf_putstring(buf, SSH_SIGNKEY_RSA, SSH_SIGNKEY_RSA_LEN);
  ------------------
  |  |  116|    858|#define SSH_SIGNKEY_RSA "ssh-rsa"
  ------------------
              	buf_putstring(buf, SSH_SIGNKEY_RSA, SSH_SIGNKEY_RSA_LEN);
  ------------------
  |  |  117|    858|#define SSH_SIGNKEY_RSA_LEN 7
  ------------------
  168|    858|	buf_putmpint(buf, key->e);
  169|    858|	buf_putmpint(buf, key->n);
  170|       |
  171|    858|	TRACE(("leave buf_put_rsa_pub_key"))
  172|       |
  173|    858|}
buf_rsa_verify:
  201|    634|		enum signature_type sigtype, const buffer *data_buf) {
  202|    634|	unsigned int slen;
  203|    634|	DEF_MP_INT(rsa_s);
  ------------------
  |  |   83|    634|#define DEF_MP_INT(X) mp_int X = {0, 0, 0, NULL}
  ------------------
  204|    634|	DEF_MP_INT(rsa_mdash);
  ------------------
  |  |   83|    634|#define DEF_MP_INT(X) mp_int X = {0, 0, 0, NULL}
  ------------------
  205|    634|	DEF_MP_INT(rsa_em);
  ------------------
  |  |   83|    634|#define DEF_MP_INT(X) mp_int X = {0, 0, 0, NULL}
  ------------------
  206|    634|	int ret = DROPBEAR_FAILURE;
  ------------------
  |  |  112|    634|#define DROPBEAR_FAILURE -1
  ------------------
  207|       |
  208|    634|	TRACE(("enter buf_rsa_verify"))
  209|       |
  210|    634|	dropbear_assert(key != NULL);
  ------------------
  |  |   86|    634|#define dropbear_assert(X) do { if (!(X)) { fail_assert(#X, __FILE__, __LINE__); } } while (0)
  |  |  ------------------
  |  |  |  Branch (86:37): [True: 0, False: 634]
  |  |  |  Branch (86:93): [Folded, False: 634]
  |  |  ------------------
  ------------------
  211|       |
  212|    634|	m_mp_init_multi(&rsa_mdash, &rsa_s, &rsa_em, NULL);
  213|       |
  214|    634|	slen = buf_getint(buf);
  215|    634|	if (slen != (unsigned int)mp_ubin_size(key->n)) {
  ------------------
  |  Branch (215:6): [True: 49, False: 585]
  ------------------
  216|     49|		TRACE(("bad size"))
  217|     49|		goto out;
  218|     49|	}
  219|       |
  220|    585|	if (mp_from_ubin(&rsa_s, buf_getptr(buf, buf->len - buf->pos),
  ------------------
  |  Branch (220:6): [True: 0, False: 585]
  ------------------
  221|    585|				buf->len - buf->pos) != MP_OKAY) {
  ------------------
  |  |  161|    585|#define MP_OKAY       0   /* no error */
  ------------------
  222|      0|		TRACE(("failed reading rsa_s"))
  223|      0|		goto out;
  224|      0|	}
  225|       |
  226|       |	/* check that s <= n-1 */
  227|    585|	if (mp_cmp(&rsa_s, key->n) != MP_LT) {
  ------------------
  |  |  154|    585|#define MP_LT        -1   /* less than */
  ------------------
  |  Branch (227:6): [True: 33, False: 552]
  ------------------
  228|     33|		TRACE(("s > n-1"))
  229|     33|		goto out;
  230|     33|	}
  231|       |
  232|       |	/* create the magic PKCS padded value */
  233|    552|	rsa_pad_em(key, data_buf, &rsa_em, sigtype);
  234|       |
  235|    552|	if (mp_exptmod(&rsa_s, key->e, key->n, &rsa_mdash) != MP_OKAY) {
  ------------------
  |  |  161|    552|#define MP_OKAY       0   /* no error */
  ------------------
  |  Branch (235:6): [True: 0, False: 552]
  ------------------
  236|      0|		TRACE(("failed exptmod rsa_s"))
  237|      0|		goto out;
  238|      0|	}
  239|       |
  240|    552|	if (mp_cmp(&rsa_em, &rsa_mdash) == MP_EQ) {
  ------------------
  |  |  155|    552|#define MP_EQ         0   /* equal to */
  ------------------
  |  Branch (240:6): [True: 0, False: 552]
  ------------------
  241|       |		/* signature is valid */
  242|      0|		TRACE(("success!"))
  243|      0|		ret = DROPBEAR_SUCCESS;
  ------------------
  |  |  111|      0|#define DROPBEAR_SUCCESS 0
  ------------------
  244|      0|	}
  245|       |
  246|    634|out:
  247|       |	mp_clear_multi(&rsa_mdash, &rsa_s, &rsa_em, NULL);
  248|    634|	TRACE(("leave buf_rsa_verify: ret %d", ret))
  249|    634|	return ret;
  250|    552|}
rsa.c:rsa_pad_em:
  398|    552|	const buffer *data_buf, mp_int * rsa_em, enum signature_type sigtype) {
  399|       |    /* EM = 0x00 || 0x01 || PS || 0x00 || T 
  400|       |	   PS is padding of 0xff to make EM the size of key->n
  401|       |
  402|       |	   T is the DER encoding of the hash alg (sha1 or sha256)
  403|       |	*/
  404|       |
  405|       |	/* From rfc8017 page 46 */
  406|    552|#if DROPBEAR_RSA_SHA1
  407|    552|	const unsigned char T_sha1[] =
  408|    552|		{0x30, 0x21, 0x30, 0x09, 0x06, 0x05, 0x2b,
  409|    552|		 0x0e, 0x03, 0x02, 0x1a, 0x05, 0x00, 0x04, 0x14};
  410|    552|#endif
  411|    552|#if DROPBEAR_RSA_SHA256
  412|    552|	const unsigned char T_sha256[] =
  413|    552|		{0x30, 0x31, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01,
  414|    552|		 0x65, 0x03, 0x04, 0x02, 0x01, 0x05, 0x00, 0x04, 0x20};
  415|    552|#endif
  416|       |
  417|    552|    int Tlen = 0;
  418|    552|    const unsigned char *T = NULL;
  419|    552|	const struct ltc_hash_descriptor *hash_desc = NULL;
  420|    552|	buffer * rsa_EM = NULL;
  421|    552|	hash_state hs;
  422|    552|	unsigned int nsize;
  423|       |
  424|    552|	switch (sigtype) {
  425|      0|#if DROPBEAR_RSA_SHA1
  426|    552|		case DROPBEAR_SIGNATURE_RSA_SHA1:
  ------------------
  |  Branch (426:3): [True: 552, False: 0]
  ------------------
  427|    552|			Tlen = sizeof(T_sha1);
  428|    552|			T = T_sha1;
  429|    552|			hash_desc = &sha1_desc;
  430|    552|			break;
  431|      0|#endif
  432|      0|#if DROPBEAR_RSA_SHA256
  433|      0|		case DROPBEAR_SIGNATURE_RSA_SHA256:
  ------------------
  |  Branch (433:3): [True: 0, False: 552]
  ------------------
  434|      0|			Tlen = sizeof(T_sha256);
  435|      0|			T = T_sha256;
  436|      0|			hash_desc = &sha256_desc;
  437|      0|			break;
  438|      0|#endif
  439|      0|		default:
  ------------------
  |  Branch (439:3): [True: 0, False: 552]
  ------------------
  440|      0|			assert(0);
  ------------------
  |  Branch (440:4): [Folded, False: 0]
  |  Branch (440:4): [Folded, False: 0]
  ------------------
  441|    552|	}
  442|       |	
  443|       |
  444|    552|	nsize = mp_ubin_size(key->n);
  445|       |
  446|    552|	rsa_EM = buf_new(nsize);
  447|       |	/* type byte */
  448|    552|	buf_putbyte(rsa_EM, 0x00);
  449|    552|	buf_putbyte(rsa_EM, 0x01);
  450|       |	/* Padding with PS 0xFF bytes */
  451|  53.2k|	while(rsa_EM->pos != rsa_EM->size - (1 + Tlen + hash_desc->hashsize)) {
  ------------------
  |  Branch (451:8): [True: 52.7k, False: 552]
  ------------------
  452|  52.7k|		buf_putbyte(rsa_EM, 0xff);
  453|  52.7k|	}
  454|    552|	buf_putbyte(rsa_EM, 0x00);
  455|       |	/* Magic ASN1 stuff */
  456|    552|	buf_putbytes(rsa_EM, T, Tlen);
  457|       |
  458|       |	/* The hash of the data */
  459|    552|	hash_desc->init(&hs);
  460|    552|	hash_desc->process(&hs, data_buf->data, data_buf->len);
  461|    552|	hash_desc->done(&hs, buf_getwriteptr(rsa_EM, hash_desc->hashsize));
  462|    552|	buf_incrwritepos(rsa_EM, hash_desc->hashsize);
  463|       |
  464|    552|	dropbear_assert(rsa_EM->pos == rsa_EM->size);
  ------------------
  |  |   86|    552|#define dropbear_assert(X) do { if (!(X)) { fail_assert(#X, __FILE__, __LINE__); } } while (0)
  |  |  ------------------
  |  |  |  Branch (86:37): [True: 0, False: 552]
  |  |  |  Branch (86:93): [Folded, False: 552]
  |  |  ------------------
  ------------------
  465|       |
  466|       |	/* Create the mp_int from the encoded bytes */
  467|    552|	buf_setpos(rsa_EM, 0);
  468|    552|	bytes_to_mp(rsa_em, buf_getptr(rsa_EM, rsa_EM->size),
  469|    552|			rsa_EM->size);
  470|    552|	buf_free(rsa_EM);
  471|    552|}

new_sign_key:
   62|  1.97k|sign_key * new_sign_key() {
   63|       |
   64|  1.97k|	sign_key * ret;
   65|       |
   66|  1.97k|	ret = (sign_key*)m_malloc(sizeof(sign_key));
   67|  1.97k|	ret->type = DROPBEAR_SIGNKEY_NONE;
   68|  1.97k|	ret->source = SIGNKEY_SOURCE_INVALID;
   69|  1.97k|	return ret;
   70|  1.97k|}
signkey_type_from_name:
   86|  3.32k|enum signkey_type signkey_type_from_name(const char* name, unsigned int namelen) {
   87|  3.32k|	int i;
   88|  11.5k|	for (i = 0; i < DROPBEAR_SIGNKEY_NUM_NAMED; i++) {
  ------------------
  |  Branch (88:14): [True: 11.3k, False: 170]
  ------------------
   89|  11.3k|		const char *fixed_name = signkey_names[i];
   90|  11.3k|		if (namelen == strlen(fixed_name)
  ------------------
  |  Branch (90:7): [True: 4.24k, False: 7.12k]
  ------------------
   91|  4.24k|			&& memcmp(fixed_name, name, namelen) == 0) {
  ------------------
  |  Branch (91:7): [True: 3.15k, False: 1.09k]
  ------------------
   92|       |
   93|  3.15k|#if DROPBEAR_ECDSA
   94|       |			/* Some of the ECDSA key sizes are defined even if they're not compiled in */
   95|  3.15k|			if (0
  ------------------
  |  Branch (95:8): [Folded, False: 3.15k]
  ------------------
   96|       |#if !DROPBEAR_ECC_256
   97|       |				|| i == DROPBEAR_SIGNKEY_ECDSA_NISTP256
   98|       |#endif
   99|       |#if !DROPBEAR_ECC_384
  100|       |				|| i == DROPBEAR_SIGNKEY_ECDSA_NISTP384
  101|       |#endif
  102|       |#if !DROPBEAR_ECC_521
  103|       |				|| i == DROPBEAR_SIGNKEY_ECDSA_NISTP521
  104|       |#endif
  105|  3.15k|				) {
  106|      0|				TRACE(("attempt to use ecdsa type %d not compiled in", i))
  107|      0|				return DROPBEAR_SIGNKEY_NONE;
  108|      0|			}
  109|  3.15k|#endif
  110|       |
  111|  3.15k|			return (enum signkey_type)i;
  112|  3.15k|		}
  113|  11.3k|	}
  114|       |
  115|    170|	TRACE(("signkey_type_from_name unexpected key type."))
  116|       |
  117|    170|	return DROPBEAR_SIGNKEY_NONE;
  118|  3.32k|}
signature_type_from_name:
  145|  1.00k|enum signature_type signature_type_from_name(const char* name, unsigned int namelen) {
  146|  1.00k|	enum signkey_type keytype = signkey_type_from_name(name, namelen);
  147|  1.00k|#if DROPBEAR_RSA
  148|  1.00k|#if DROPBEAR_RSA_SHA256
  149|  1.00k|	if (namelen == strlen(SSH_SIGNATURE_RSA_SHA256) 
  ------------------
  |  |  121|  1.00k|#define SSH_SIGNATURE_RSA_SHA256 "rsa-sha2-256"
  ------------------
  |  Branch (149:6): [True: 19, False: 989]
  ------------------
  150|     19|		&& memcmp(name, SSH_SIGNATURE_RSA_SHA256, namelen) == 0) {
  ------------------
  |  |  121|     19|#define SSH_SIGNATURE_RSA_SHA256 "rsa-sha2-256"
  ------------------
  |  Branch (150:6): [True: 2, False: 17]
  ------------------
  151|      2|		return DROPBEAR_SIGNATURE_RSA_SHA256;
  152|      2|	}
  153|  1.00k|#endif
  154|       |	/* keytype == DROPBEAR_SIGNKEY_RSA iff name is "ssh-rsa" (SHA1 sig algo) */
  155|  1.00k|	if (keytype == DROPBEAR_SIGNKEY_RSA) {
  ------------------
  |  Branch (155:6): [True: 635, False: 371]
  ------------------
  156|    635|#if DROPBEAR_RSA_SHA1
  157|    635|		return DROPBEAR_SIGNATURE_RSA_SHA1;
  158|       |#else
  159|       |		return DROPBEAR_SIGNATURE_NONE;
  160|       |#endif
  161|    635|	}
  162|    371|#endif /* DROPBEAR_RSA */
  163|    371|	return (enum signature_type)keytype;
  164|  1.00k|}
signkey_type_from_signature:
  176|  6.87k|enum signkey_type signkey_type_from_signature(enum signature_type sigtype) {
  177|  6.87k|#if DROPBEAR_RSA
  178|  6.87k|#if DROPBEAR_RSA_SHA256
  179|  6.87k|	if (sigtype == DROPBEAR_SIGNATURE_RSA_SHA256) {
  ------------------
  |  Branch (179:6): [True: 10, False: 6.86k]
  ------------------
  180|     10|		return DROPBEAR_SIGNKEY_RSA;
  181|     10|	}
  182|  6.86k|#endif
  183|  6.86k|#if DROPBEAR_RSA_SHA1
  184|  6.86k|	if (sigtype == DROPBEAR_SIGNATURE_RSA_SHA1) {
  ------------------
  |  Branch (184:6): [True: 1.75k, False: 5.11k]
  ------------------
  185|  1.75k|		return DROPBEAR_SIGNKEY_RSA;
  186|  1.75k|	}
  187|  5.11k|#endif
  188|  5.11k|#endif /* DROPBEAR_RSA */
  189|  6.86k|	assert((int)sigtype < (int)DROPBEAR_SIGNKEY_NUM_NAMED);
  ------------------
  |  Branch (189:2): [True: 0, False: 5.11k]
  |  Branch (189:2): [True: 5.11k, False: 0]
  ------------------
  190|  5.11k|	return (enum signkey_type)sigtype;
  191|  5.11k|}
signkey_key_ptr:
  196|    322|signkey_key_ptr(sign_key *key, enum signkey_type type) {
  197|    322|	switch (type) {
  198|      0|#if DROPBEAR_ED25519
  199|      0|		case DROPBEAR_SIGNKEY_ED25519:
  ------------------
  |  Branch (199:3): [True: 0, False: 322]
  ------------------
  200|      0|#if DROPBEAR_SK_ED25519
  201|      0|		case DROPBEAR_SIGNKEY_SK_ED25519:
  ------------------
  |  Branch (201:3): [True: 0, False: 322]
  ------------------
  202|      0|#endif
  203|      0|			return (void**)&key->ed25519key;
  204|      0|#endif
  205|      0|#if DROPBEAR_ECDSA
  206|      0|#if DROPBEAR_ECC_256
  207|      0|		case DROPBEAR_SIGNKEY_ECDSA_NISTP256:
  ------------------
  |  Branch (207:3): [True: 0, False: 322]
  ------------------
  208|      0|#if DROPBEAR_SK_ECDSA
  209|      0|		case DROPBEAR_SIGNKEY_SK_ECDSA_NISTP256:
  ------------------
  |  Branch (209:3): [True: 0, False: 322]
  ------------------
  210|      0|#endif
  211|      0|			return (void**)&key->ecckey256;
  212|      0|#endif
  213|      0|#if DROPBEAR_ECC_384
  214|      0|		case DROPBEAR_SIGNKEY_ECDSA_NISTP384:
  ------------------
  |  Branch (214:3): [True: 0, False: 322]
  ------------------
  215|      0|			return (void**)&key->ecckey384;
  216|      0|#endif
  217|      0|#if DROPBEAR_ECC_521
  218|    322|		case DROPBEAR_SIGNKEY_ECDSA_NISTP521:
  ------------------
  |  Branch (218:3): [True: 322, False: 0]
  ------------------
  219|    322|			return (void**)&key->ecckey521;
  220|      0|#endif
  221|      0|#endif /* DROPBEAR_ECDSA */
  222|      0|#if DROPBEAR_RSA
  223|      0|		case DROPBEAR_SIGNKEY_RSA:
  ------------------
  |  Branch (223:3): [True: 0, False: 322]
  ------------------
  224|      0|			return (void**)&key->rsakey;
  225|      0|#endif
  226|      0|#if DROPBEAR_DSS
  227|      0|		case DROPBEAR_SIGNKEY_DSS:
  ------------------
  |  Branch (227:3): [True: 0, False: 322]
  ------------------
  228|      0|			return (void**)&key->dsskey;
  229|      0|#endif
  230|      0|		default:
  ------------------
  |  Branch (230:3): [True: 0, False: 322]
  ------------------
  231|       |			return NULL;
  232|    322|	}
  233|    322|}
buf_get_pub_key:
  238|  1.89k|int buf_get_pub_key(buffer *buf, sign_key *key, enum signkey_type *type) {
  239|       |
  240|  1.89k|	char *ident;
  241|  1.89k|	unsigned int len;
  242|  1.89k|	enum signkey_type keytype;
  243|  1.89k|	int ret = DROPBEAR_FAILURE;
  ------------------
  |  |  112|  1.89k|#define DROPBEAR_FAILURE -1
  ------------------
  244|       |
  245|  1.89k|	TRACE2(("enter buf_get_pub_key"))
  246|       |
  247|  1.89k|	ident = buf_getstring(buf, &len);
  248|  1.89k|	keytype = signkey_type_from_name(ident, len);
  249|  1.89k|	m_free(ident);
  ------------------
  |  |   24|  1.89k|#define m_free(X) do {m_free_direct(X); (X) = NULL;} while (0)
  |  |  ------------------
  |  |  |  Branch (24:61): [Folded, False: 1.89k]
  |  |  ------------------
  ------------------
  250|       |
  251|  1.89k|	if (*type != DROPBEAR_SIGNKEY_ANY && *type != keytype) {
  ------------------
  |  Branch (251:6): [True: 1.89k, False: 1]
  |  Branch (251:39): [True: 108, False: 1.78k]
  ------------------
  252|    108|		TRACE(("buf_get_pub_key bad type - got %d, expected %d", keytype, *type))
  253|    108|		return DROPBEAR_FAILURE;
  ------------------
  |  |  112|    108|#define DROPBEAR_FAILURE -1
  ------------------
  254|    108|	}
  255|       |	
  256|  1.78k|	TRACE2(("buf_get_pub_key keytype is %d", keytype))
  257|       |
  258|  1.78k|	*type = keytype;
  259|       |
  260|       |	/* Rewind the buffer back before "ssh-rsa" etc */
  261|  1.78k|	buf_decrpos(buf, len + 4);
  262|       |
  263|  1.78k|#if DROPBEAR_DSS
  264|  1.78k|	if (keytype == DROPBEAR_SIGNKEY_DSS) {
  ------------------
  |  Branch (264:6): [True: 260, False: 1.52k]
  ------------------
  265|    260|		dss_key_free(key->dsskey);
  266|    260|		key->dsskey = m_malloc(sizeof(*key->dsskey));
  267|    260|		ret = buf_get_dss_pub_key(buf, key->dsskey);
  268|    260|		if (ret == DROPBEAR_FAILURE) {
  ------------------
  |  |  112|    260|#define DROPBEAR_FAILURE -1
  ------------------
  |  Branch (268:7): [True: 89, False: 171]
  ------------------
  269|     89|			dss_key_free(key->dsskey);
  270|     89|			key->dsskey = NULL;
  271|     89|		}
  272|    260|	}
  273|  1.78k|#endif
  274|  1.78k|#if DROPBEAR_RSA
  275|  1.78k|	if (keytype == DROPBEAR_SIGNKEY_RSA) {
  ------------------
  |  Branch (275:6): [True: 970, False: 815]
  ------------------
  276|    970|		rsa_key_free(key->rsakey);
  277|    970|		key->rsakey = m_malloc(sizeof(*key->rsakey));
  278|    970|		ret = buf_get_rsa_pub_key(buf, key->rsakey);
  279|    970|		if (ret == DROPBEAR_FAILURE) {
  ------------------
  |  |  112|    970|#define DROPBEAR_FAILURE -1
  ------------------
  |  Branch (279:7): [True: 56, False: 914]
  ------------------
  280|     56|			rsa_key_free(key->rsakey);
  281|     56|			key->rsakey = NULL;
  282|     56|		}
  283|    970|	}
  284|  1.78k|#endif
  285|  1.78k|#if DROPBEAR_ECDSA
  286|  1.78k|	if (signkey_is_ecdsa(keytype)
  ------------------
  |  Branch (286:6): [True: 174, False: 1.61k]
  ------------------
  287|  1.61k|#if DROPBEAR_SK_ECDSA
  288|  1.61k|		|| keytype == DROPBEAR_SIGNKEY_SK_ECDSA_NISTP256
  ------------------
  |  Branch (288:6): [True: 0, False: 1.61k]
  ------------------
  289|  1.78k|#endif
  290|  1.78k|	) {
  291|    133|		ecc_key **eck = (ecc_key**)signkey_key_ptr(key, keytype);
  292|    133|		if (eck) {
  ------------------
  |  Branch (292:7): [True: 133, False: 0]
  ------------------
  293|    133|			if (*eck) {
  ------------------
  |  Branch (293:8): [True: 0, False: 133]
  ------------------
  294|      0|				ecc_free(*eck);
  295|      0|				m_free(*eck);
  ------------------
  |  |   24|      0|#define m_free(X) do {m_free_direct(X); (X) = NULL;} while (0)
  |  |  ------------------
  |  |  |  Branch (24:61): [Folded, False: 0]
  |  |  ------------------
  ------------------
  296|      0|				*eck = NULL;
  297|      0|			}
  298|    133|			*eck = buf_get_ecdsa_pub_key(buf);
  299|    133|			if (*eck) {
  ------------------
  |  Branch (299:8): [True: 96, False: 37]
  ------------------
  300|     96|				ret = DROPBEAR_SUCCESS;
  ------------------
  |  |  111|     96|#define DROPBEAR_SUCCESS 0
  ------------------
  301|     96|			}
  302|    133|		}
  303|    133|	}
  304|  1.78k|#endif
  305|  1.78k|#if DROPBEAR_ED25519
  306|  1.78k|	if (keytype == DROPBEAR_SIGNKEY_ED25519
  ------------------
  |  Branch (306:6): [True: 463, False: 1.32k]
  ------------------
  307|  1.32k|#if DROPBEAR_SK_ED25519
  308|  1.32k|		|| keytype == DROPBEAR_SIGNKEY_SK_ED25519
  ------------------
  |  Branch (308:6): [True: 0, False: 1.32k]
  ------------------
  309|  1.78k|#endif
  310|  1.78k|    ) {
  311|    421|		ed25519_key_free(key->ed25519key);
  312|    421|		key->ed25519key = m_malloc(sizeof(*key->ed25519key));
  313|    421|		ret = buf_get_ed25519_pub_key(buf, key->ed25519key, keytype);
  314|    421|		if (ret == DROPBEAR_FAILURE) {
  ------------------
  |  |  112|    421|#define DROPBEAR_FAILURE -1
  ------------------
  |  Branch (314:7): [True: 47, False: 374]
  ------------------
  315|     47|			m_free(key->ed25519key);
  ------------------
  |  |   24|     47|#define m_free(X) do {m_free_direct(X); (X) = NULL;} while (0)
  |  |  ------------------
  |  |  |  Branch (24:61): [Folded, False: 47]
  |  |  ------------------
  ------------------
  316|     47|			key->ed25519key = NULL;
  317|     47|		}
  318|    421|	}
  319|  1.78k|#endif
  320|       |
  321|  1.78k|#if DROPBEAR_SK_ECDSA || DROPBEAR_SK_ED25519
  322|  1.78k|	if (0
  ------------------
  |  Branch (322:6): [Folded, False: 1.74k]
  ------------------
  323|  1.74k|#if DROPBEAR_SK_ED25519
  324|  1.74k|		|| keytype == DROPBEAR_SIGNKEY_SK_ED25519
  ------------------
  |  Branch (324:6): [True: 0, False: 1.74k]
  ------------------
  325|  1.74k|#endif
  326|  1.74k|#if DROPBEAR_SK_ECDSA
  327|  1.74k|		|| keytype == DROPBEAR_SIGNKEY_SK_ECDSA_NISTP256
  ------------------
  |  Branch (327:6): [True: 0, False: 1.74k]
  ------------------
  328|  1.78k|#endif
  329|  1.78k|	) {
  330|      0|		key->sk_app = buf_getstring(buf, &key->sk_applen);
  331|      0|	}
  332|  1.78k|#endif
  333|       |
  334|  1.78k|	TRACE2(("leave buf_get_pub_key"))
  335|       |
  336|  1.78k|	return ret;
  337|  1.89k|}
buf_get_priv_key:
  342|      1|int buf_get_priv_key(buffer *buf, sign_key *key, enum signkey_type *type) {
  343|       |
  344|      1|	char *ident;
  345|      1|	unsigned int len;
  346|      1|	enum signkey_type keytype;
  347|      1|	int ret = DROPBEAR_FAILURE;
  ------------------
  |  |  112|      1|#define DROPBEAR_FAILURE -1
  ------------------
  348|       |
  349|      1|	TRACE2(("enter buf_get_priv_key"))
  350|       |
  351|      1|	ident = buf_getstring(buf, &len);
  352|      1|	keytype = signkey_type_from_name(ident, len);
  353|      1|	m_free(ident);
  ------------------
  |  |   24|      1|#define m_free(X) do {m_free_direct(X); (X) = NULL;} while (0)
  |  |  ------------------
  |  |  |  Branch (24:61): [Folded, False: 1]
  |  |  ------------------
  ------------------
  354|       |
  355|      1|	if (*type != DROPBEAR_SIGNKEY_ANY && *type != keytype) {
  ------------------
  |  Branch (355:6): [True: 0, False: 1]
  |  Branch (355:39): [True: 0, False: 0]
  ------------------
  356|      0|		TRACE(("wrong key type: %d %d", *type, keytype))
  357|      0|		return DROPBEAR_FAILURE;
  ------------------
  |  |  112|      0|#define DROPBEAR_FAILURE -1
  ------------------
  358|      0|	}
  359|       |
  360|      1|	*type = keytype;
  361|       |
  362|       |	/* Rewind the buffer back before "ssh-rsa" etc */
  363|      1|	buf_decrpos(buf, len + 4);
  364|       |
  365|      1|#if DROPBEAR_DSS
  366|      1|	if (keytype == DROPBEAR_SIGNKEY_DSS) {
  ------------------
  |  Branch (366:6): [True: 0, False: 1]
  ------------------
  367|      0|		dss_key_free(key->dsskey);
  368|      0|		key->dsskey = m_malloc(sizeof(*key->dsskey));
  369|      0|		ret = buf_get_dss_priv_key(buf, key->dsskey);
  370|      0|		if (ret == DROPBEAR_FAILURE) {
  ------------------
  |  |  112|      0|#define DROPBEAR_FAILURE -1
  ------------------
  |  Branch (370:7): [True: 0, False: 0]
  ------------------
  371|      0|			dss_key_free(key->dsskey);
  372|      0|			key->dsskey = NULL;
  373|      0|		}
  374|      0|	}
  375|      1|#endif
  376|      1|#if DROPBEAR_RSA
  377|      1|	if (keytype == DROPBEAR_SIGNKEY_RSA) {
  ------------------
  |  Branch (377:6): [True: 0, False: 1]
  ------------------
  378|      0|		rsa_key_free(key->rsakey);
  379|      0|		key->rsakey = m_malloc(sizeof(*key->rsakey));
  380|      0|		ret = buf_get_rsa_priv_key(buf, key->rsakey);
  381|      0|		if (ret == DROPBEAR_FAILURE) {
  ------------------
  |  |  112|      0|#define DROPBEAR_FAILURE -1
  ------------------
  |  Branch (381:7): [True: 0, False: 0]
  ------------------
  382|      0|			rsa_key_free(key->rsakey);
  383|      0|			key->rsakey = NULL;
  384|      0|		}
  385|      0|	}
  386|      1|#endif
  387|      1|#if DROPBEAR_ECDSA
  388|      1|	if (signkey_is_ecdsa(keytype)) {
  ------------------
  |  Branch (388:6): [True: 0, False: 1]
  ------------------
  389|      0|		ecc_key **eck = (ecc_key**)signkey_key_ptr(key, keytype);
  390|      0|		if (eck) {
  ------------------
  |  Branch (390:7): [True: 0, False: 0]
  ------------------
  391|      0|			if (*eck) {
  ------------------
  |  Branch (391:8): [True: 0, False: 0]
  ------------------
  392|      0|				ecc_free(*eck);
  393|      0|				m_free(*eck);
  ------------------
  |  |   24|      0|#define m_free(X) do {m_free_direct(X); (X) = NULL;} while (0)
  |  |  ------------------
  |  |  |  Branch (24:61): [Folded, False: 0]
  |  |  ------------------
  ------------------
  394|      0|				*eck = NULL;
  395|      0|			}
  396|      0|			*eck = buf_get_ecdsa_priv_key(buf);
  397|      0|			if (*eck) {
  ------------------
  |  Branch (397:8): [True: 0, False: 0]
  ------------------
  398|      0|				ret = DROPBEAR_SUCCESS;
  ------------------
  |  |  111|      0|#define DROPBEAR_SUCCESS 0
  ------------------
  399|      0|			}
  400|      0|		}
  401|      0|	}
  402|      1|#endif
  403|      1|#if DROPBEAR_ED25519
  404|      1|	if (keytype == DROPBEAR_SIGNKEY_ED25519) {
  ------------------
  |  Branch (404:6): [True: 1, False: 0]
  ------------------
  405|      1|		ed25519_key_free(key->ed25519key);
  406|      1|		key->ed25519key = m_malloc(sizeof(*key->ed25519key));
  407|      1|		ret = buf_get_ed25519_priv_key(buf, key->ed25519key);
  408|      1|		if (ret == DROPBEAR_FAILURE) {
  ------------------
  |  |  112|      1|#define DROPBEAR_FAILURE -1
  ------------------
  |  Branch (408:7): [True: 0, False: 1]
  ------------------
  409|      0|			m_free(key->ed25519key);
  ------------------
  |  |   24|      0|#define m_free(X) do {m_free_direct(X); (X) = NULL;} while (0)
  |  |  ------------------
  |  |  |  Branch (24:61): [Folded, False: 0]
  |  |  ------------------
  ------------------
  410|      0|			key->ed25519key = NULL;
  411|      0|		}
  412|      1|	}
  413|      1|#endif
  414|       |
  415|      1|	TRACE2(("leave buf_get_priv_key"))
  416|       |
  417|      1|	return ret;
  418|       |	
  419|      1|}
buf_put_pub_key:
  422|  1.36k|void buf_put_pub_key(buffer* buf, sign_key *key, enum signkey_type type) {
  423|       |
  424|  1.36k|	buffer *pubkeys;
  425|       |
  426|  1.36k|	TRACE2(("enter buf_put_pub_key"))
  427|  1.36k|	pubkeys = buf_new(MAX_PUBKEY_SIZE);
  ------------------
  |  |  271|  1.36k|#define MAX_PUBKEY_SIZE 600
  ------------------
  428|       |	
  429|  1.36k|#if DROPBEAR_DSS
  430|  1.36k|	if (type == DROPBEAR_SIGNKEY_DSS) {
  ------------------
  |  Branch (430:6): [True: 132, False: 1.22k]
  ------------------
  431|    132|		buf_put_dss_pub_key(pubkeys, key->dsskey);
  432|    132|	}
  433|  1.36k|#endif
  434|  1.36k|#if DROPBEAR_RSA
  435|  1.36k|	if (type == DROPBEAR_SIGNKEY_RSA) {
  ------------------
  |  Branch (435:6): [True: 858, False: 502]
  ------------------
  436|    858|		buf_put_rsa_pub_key(pubkeys, key->rsakey);
  437|    858|	}
  438|  1.36k|#endif
  439|  1.36k|#if DROPBEAR_ECDSA
  440|  1.36k|	if (signkey_is_ecdsa(type)
  ------------------
  |  Branch (440:6): [True: 104, False: 1.25k]
  ------------------
  441|  1.25k|#if DROPBEAR_SK_ECDSA
  442|  1.25k|		|| type == DROPBEAR_SIGNKEY_SK_ECDSA_NISTP256
  ------------------
  |  Branch (442:6): [True: 0, False: 1.25k]
  ------------------
  443|  1.36k|#endif
  444|  1.36k|		) {
  445|     95|		ecc_key **eck = (ecc_key**)signkey_key_ptr(key, type);
  446|     95|		if (eck && *eck) {
  ------------------
  |  Branch (446:7): [True: 95, False: 0]
  |  Branch (446:14): [True: 95, False: 0]
  ------------------
  447|     95|			buf_put_ecdsa_pub_key(pubkeys, *eck);
  448|     95|		}
  449|     95|	}
  450|  1.36k|#endif
  451|  1.36k|#if DROPBEAR_ED25519
  452|  1.36k|	if (type == DROPBEAR_SIGNKEY_ED25519
  ------------------
  |  Branch (452:6): [True: 284, False: 1.07k]
  ------------------
  453|  1.07k|#if DROPBEAR_SK_ED25519
  454|  1.07k|		|| type == DROPBEAR_SIGNKEY_SK_ED25519
  ------------------
  |  Branch (454:6): [True: 0, False: 1.07k]
  ------------------
  455|  1.36k|#endif
  456|  1.36k|	) {
  457|    275|		buf_put_ed25519_pub_key(pubkeys, key->ed25519key);
  458|    275|	}
  459|  1.36k|#endif
  460|  1.36k|	if (pubkeys->len == 0) {
  ------------------
  |  Branch (460:6): [True: 0, False: 1.36k]
  ------------------
  461|      0|		dropbear_exit("Bad key types in buf_put_pub_key");
  462|      0|	}
  463|       |
  464|  1.36k|	buf_putbufstring(buf, pubkeys);
  465|  1.36k|	buf_free(pubkeys);
  466|  1.36k|	TRACE2(("leave buf_put_pub_key"))
  467|  1.36k|}
sign_key_free:
  509|      1|void sign_key_free(sign_key *key) {
  510|       |
  511|      1|	TRACE2(("enter sign_key_free"))
  512|       |
  513|      1|#if DROPBEAR_DSS
  514|      1|	dss_key_free(key->dsskey);
  515|      1|	key->dsskey = NULL;
  516|      1|#endif
  517|      1|#if DROPBEAR_RSA
  518|      1|	rsa_key_free(key->rsakey);
  519|      1|	key->rsakey = NULL;
  520|      1|#endif
  521|      1|#if DROPBEAR_ECDSA
  522|      1|#if DROPBEAR_ECC_256
  523|      1|	if (key->ecckey256) {
  ------------------
  |  Branch (523:6): [True: 0, False: 1]
  ------------------
  524|      0|		ecc_free(key->ecckey256);
  525|      0|		m_free(key->ecckey256);
  ------------------
  |  |   24|      0|#define m_free(X) do {m_free_direct(X); (X) = NULL;} while (0)
  |  |  ------------------
  |  |  |  Branch (24:61): [Folded, False: 0]
  |  |  ------------------
  ------------------
  526|      0|		key->ecckey256 = NULL;
  527|      0|	}
  528|      1|#endif
  529|      1|#if DROPBEAR_ECC_384
  530|      1|	if (key->ecckey384) {
  ------------------
  |  Branch (530:6): [True: 0, False: 1]
  ------------------
  531|      0|		ecc_free(key->ecckey384);
  532|      0|		m_free(key->ecckey384);
  ------------------
  |  |   24|      0|#define m_free(X) do {m_free_direct(X); (X) = NULL;} while (0)
  |  |  ------------------
  |  |  |  Branch (24:61): [Folded, False: 0]
  |  |  ------------------
  ------------------
  533|      0|		key->ecckey384 = NULL;
  534|      0|	}
  535|      1|#endif
  536|      1|#if DROPBEAR_ECC_521
  537|      1|	if (key->ecckey521) {
  ------------------
  |  Branch (537:6): [True: 0, False: 1]
  ------------------
  538|      0|		ecc_free(key->ecckey521);
  539|      0|		m_free(key->ecckey521);
  ------------------
  |  |   24|      0|#define m_free(X) do {m_free_direct(X); (X) = NULL;} while (0)
  |  |  ------------------
  |  |  |  Branch (24:61): [Folded, False: 0]
  |  |  ------------------
  ------------------
  540|      0|		key->ecckey521 = NULL;
  541|      0|	}
  542|      1|#endif
  543|      1|#endif
  544|      1|#if DROPBEAR_ED25519
  545|      1|	ed25519_key_free(key->ed25519key);
  546|      1|	key->ed25519key = NULL;
  547|      1|#endif
  548|       |
  549|      1|	m_free(key->filename);
  ------------------
  |  |   24|      1|#define m_free(X) do {m_free_direct(X); (X) = NULL;} while (0)
  |  |  ------------------
  |  |  |  Branch (24:61): [Folded, False: 1]
  |  |  ------------------
  ------------------
  550|      1|#if DROPBEAR_SK_ECDSA || DROPBEAR_SK_ED25519
  551|      1|	if (key->sk_app) {
  ------------------
  |  Branch (551:6): [True: 0, False: 1]
  ------------------
  552|      0|		m_free(key->sk_app);
  ------------------
  |  |   24|      0|#define m_free(X) do {m_free_direct(X); (X) = NULL;} while (0)
  |  |  ------------------
  |  |  |  Branch (24:61): [Folded, False: 0]
  |  |  ------------------
  ------------------
  553|      0|	}
  554|      1|#endif
  555|       |
  556|       |	m_free(key);
  ------------------
  |  |   24|      1|#define m_free(X) do {m_free_direct(X); (X) = NULL;} while (0)
  |  |  ------------------
  |  |  |  Branch (24:61): [Folded, False: 1]
  |  |  ------------------
  ------------------
  557|      1|	TRACE2(("leave sign_key_free"))
  558|      1|}
buf_verify:
  648|  1.35k|int buf_verify(buffer * buf, sign_key *key, enum signature_type expect_sigtype, const buffer *data_buf) {
  649|       |	
  650|  1.35k|	char *type_name = NULL;
  651|  1.35k|	unsigned int type_name_len = 0;
  652|  1.35k|	enum signature_type sigtype;
  653|  1.35k|	enum signkey_type keytype;
  654|       |
  655|  1.35k|	TRACE(("enter buf_verify"))
  656|       |
  657|  1.35k|	buf_getint(buf); /* blob length */
  658|  1.35k|	type_name = buf_getstring(buf, &type_name_len);
  659|  1.35k|	sigtype = signature_type_from_name(type_name, type_name_len);
  660|  1.35k|	m_free(type_name);
  ------------------
  |  |   24|  1.35k|#define m_free(X) do {m_free_direct(X); (X) = NULL;} while (0)
  |  |  ------------------
  |  |  |  Branch (24:61): [Folded, False: 1.35k]
  |  |  ------------------
  ------------------
  661|       |
  662|  1.35k|	if (expect_sigtype != sigtype) {
  ------------------
  |  Branch (662:6): [True: 72, False: 1.27k]
  ------------------
  663|     72|			dropbear_exit("Non-matching signing type");
  664|     72|	}
  665|       |
  666|  1.27k|	keytype = signkey_type_from_signature(sigtype);
  667|  1.27k|#if DROPBEAR_DSS
  668|  1.27k|	if (keytype == DROPBEAR_SIGNKEY_DSS) {
  ------------------
  |  Branch (668:6): [True: 128, False: 1.15k]
  ------------------
  669|    128|		if (key->dsskey == NULL) {
  ------------------
  |  Branch (669:7): [True: 0, False: 128]
  ------------------
  670|      0|			dropbear_exit("No DSS key to verify signature");
  671|      0|		}
  672|    128|		return buf_dss_verify(buf, key->dsskey, data_buf);
  673|    128|	}
  674|  1.15k|#endif
  675|       |
  676|  1.15k|#if DROPBEAR_RSA
  677|  1.15k|	if (keytype == DROPBEAR_SIGNKEY_RSA) {
  ------------------
  |  Branch (677:6): [True: 634, False: 517]
  ------------------
  678|    634|		if (key->rsakey == NULL) {
  ------------------
  |  Branch (678:7): [True: 0, False: 634]
  ------------------
  679|      0|			dropbear_exit("No RSA key to verify signature");
  680|      0|		}
  681|    634|		return buf_rsa_verify(buf, key->rsakey, sigtype, data_buf);
  682|    634|	}
  683|    517|#endif
  684|    517|#if DROPBEAR_ECDSA
  685|    517|	if (signkey_is_ecdsa(keytype)) {
  ------------------
  |  Branch (685:6): [True: 94, False: 423]
  ------------------
  686|     94|		ecc_key **eck = (ecc_key**)signkey_key_ptr(key, keytype);
  687|     94|		if (eck && *eck) {
  ------------------
  |  Branch (687:7): [True: 94, False: 0]
  |  Branch (687:14): [True: 94, False: 0]
  ------------------
  688|     94|			return buf_ecdsa_verify(buf, *eck, data_buf);
  689|     94|		}
  690|     94|	}
  691|    423|#endif
  692|    423|#if DROPBEAR_ED25519
  693|    423|	if (keytype == DROPBEAR_SIGNKEY_ED25519) {
  ------------------
  |  Branch (693:6): [True: 80, False: 343]
  ------------------
  694|     80|		if (key->ed25519key == NULL) {
  ------------------
  |  Branch (694:7): [True: 0, False: 80]
  ------------------
  695|      0|			dropbear_exit("No Ed25519 key to verify signature");
  696|      0|		}
  697|     80|		return buf_ed25519_verify(buf, key->ed25519key, data_buf);
  698|     80|	}
  699|    343|#endif
  700|    343|#if DROPBEAR_SK_ECDSA
  701|    343|	if (keytype == DROPBEAR_SIGNKEY_SK_ECDSA_NISTP256) {
  ------------------
  |  Branch (701:6): [True: 0, False: 343]
  ------------------
  702|      0|		ecc_key **eck = (ecc_key**)signkey_key_ptr(key, keytype);
  703|      0|		if (eck && *eck) {
  ------------------
  |  Branch (703:7): [True: 0, False: 0]
  |  Branch (703:14): [True: 0, False: 0]
  ------------------
  704|      0|			return buf_sk_ecdsa_verify(buf, *eck, data_buf, key->sk_app, key->sk_applen, key->sk_flags_mask);
  705|      0|		}
  706|      0|	}
  707|    343|#endif
  708|    343|#if DROPBEAR_SK_ED25519
  709|    343|	if (keytype == DROPBEAR_SIGNKEY_SK_ED25519) {
  ------------------
  |  Branch (709:6): [True: 0, False: 343]
  ------------------
  710|      0|		dropbear_ed25519_key **eck = (dropbear_ed25519_key**)signkey_key_ptr(key, keytype);
  711|      0|		if (eck && *eck) {
  ------------------
  |  Branch (711:7): [True: 0, False: 0]
  |  Branch (711:14): [True: 0, False: 0]
  ------------------
  712|      0|			return buf_sk_ed25519_verify(buf, *eck, data_buf, key->sk_app, key->sk_applen, key->sk_flags_mask);
  713|      0|		}
  714|      0|	}
  715|    343|#endif
  716|       |
  717|    343|	dropbear_exit("Non-matching signing type");
  718|      0|	return DROPBEAR_FAILURE;
  ------------------
  |  |  112|      0|#define DROPBEAR_FAILURE -1
  ------------------
  719|    343|}

crypto_kem_sntrup761_keypair:
 2170|  3.47k|int crypto_kem_sntrup761_keypair(unsigned char *pk, unsigned char *sk) {
 2171|  3.47k|  int i;
 2172|  3.47k|  ZKeyGen(pk, sk);
 2173|  3.47k|  sk += SecretKeys_bytes;
  ------------------
  |  | 1763|  3.47k|#define SecretKeys_bytes (2 * Small_bytes)
  |  |  ------------------
  |  |  |  | 1761|  3.47k|#define Small_bytes ((p + 3) / 4)
  |  |  |  |  ------------------
  |  |  |  |  |  | 1754|  3.47k|#define p 761
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2174|  4.02M|  for (i = 0; i < crypto_kem_sntrup761_PUBLICKEYBYTES; ++i) *sk++ = pk[i];
  ------------------
  |  |    4|  4.02M|#define crypto_kem_sntrup761_PUBLICKEYBYTES 1158
  ------------------
  |  Branch (2174:15): [True: 4.02M, False: 3.47k]
  ------------------
 2175|  3.47k|  randombytes(sk, Small_bytes);
  ------------------
  |  | 1761|  3.47k|#define Small_bytes ((p + 3) / 4)
  |  |  ------------------
  |  |  |  | 1754|  3.47k|#define p 761
  |  |  ------------------
  ------------------
 2176|  3.47k|  Hash_prefix(sk + Small_bytes, 4, pk, crypto_kem_sntrup761_PUBLICKEYBYTES);
  ------------------
  |  | 1761|  3.47k|#define Small_bytes ((p + 3) / 4)
  |  |  ------------------
  |  |  |  | 1754|  3.47k|#define p 761
  |  |  ------------------
  ------------------
                Hash_prefix(sk + Small_bytes, 4, pk, crypto_kem_sntrup761_PUBLICKEYBYTES);
  ------------------
  |  |    4|  3.47k|#define crypto_kem_sntrup761_PUBLICKEYBYTES 1158
  ------------------
 2177|  3.47k|  return 0;
 2178|  3.47k|}
crypto_kem_sntrup761_dec:
 2203|     49|int crypto_kem_sntrup761_dec(unsigned char *k, const unsigned char *c, const unsigned char *sk) {
 2204|     49|  const unsigned char *pk = sk + SecretKeys_bytes;
  ------------------
  |  | 1763|     49|#define SecretKeys_bytes (2 * Small_bytes)
  |  |  ------------------
  |  |  |  | 1761|     49|#define Small_bytes ((p + 3) / 4)
  |  |  |  |  ------------------
  |  |  |  |  |  | 1754|     49|#define p 761
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2205|     49|  const unsigned char *rho = pk + crypto_kem_sntrup761_PUBLICKEYBYTES;
  ------------------
  |  |    4|     49|#define crypto_kem_sntrup761_PUBLICKEYBYTES 1158
  ------------------
 2206|     49|  const unsigned char *cache = rho + Small_bytes;
  ------------------
  |  | 1761|     49|#define Small_bytes ((p + 3) / 4)
  |  |  ------------------
  |  |  |  | 1754|     49|#define p 761
  |  |  ------------------
  ------------------
 2207|     49|  Inputs r;
 2208|     49|  unsigned char r_enc[Small_bytes], cnew[crypto_kem_sntrup761_CIPHERTEXTBYTES];
 2209|     49|  int mask, i;
 2210|     49|  ZDecrypt(r, c, sk);
 2211|     49|  Hide(cnew, r_enc, r, pk, cache);
 2212|     49|  mask = Ciphertexts_diff_mask(c, cnew);
 2213|  9.40k|  for (i = 0; i < Small_bytes; ++i) r_enc[i] ^= mask & (r_enc[i] ^ rho[i]);
  ------------------
  |  | 1761|  9.40k|#define Small_bytes ((p + 3) / 4)
  |  |  ------------------
  |  |  |  | 1754|  9.40k|#define p 761
  |  |  ------------------
  ------------------
  |  Branch (2213:15): [True: 9.35k, False: 49]
  ------------------
 2214|     49|  HashSession(k, 1 + mask, r_enc, c);
 2215|     49|  return 0;
 2216|     49|}
sntrup761.c:ZKeyGen:
 2129|  3.47k|static void ZKeyGen(unsigned char *pk, unsigned char *sk) {
 2130|  3.47k|  Fq h[p];
 2131|  3.47k|  small f[p], v[p];
 2132|  3.47k|  KeyGen(h, f, v);
 2133|  3.47k|  Rq_encode(pk, h);
 2134|  3.47k|  Small_encode(sk, f);
 2135|  3.47k|  Small_encode(sk + Small_bytes, v);
  ------------------
  |  | 1761|  3.47k|#define Small_bytes ((p + 3) / 4)
  |  |  ------------------
  |  |  |  | 1754|  3.47k|#define p 761
  |  |  ------------------
  ------------------
 2136|  3.47k|}
sntrup761.c:KeyGen:
 2044|  3.47k|static void KeyGen(Fq *h, small *f, small *ginv) {
 2045|  3.47k|  small g[p];
 2046|  3.47k|  Fq finv[p];
 2047|  3.47k|  for (;;) {
 2048|  3.47k|    int result;
 2049|  3.47k|    Small_random(g);
 2050|  3.47k|    result = R3_recip(ginv, g);
 2051|  3.47k|    crypto_declassify(&result, sizeof result);
  ------------------
  |  |   14|  3.47k|#define crypto_declassify(x, y) do {} while (0)
  |  |  ------------------
  |  |  |  Branch (14:46): [Folded, False: 3.47k]
  |  |  ------------------
  ------------------
 2052|  3.47k|    if (result == 0) break;
  ------------------
  |  Branch (2052:9): [True: 3.47k, False: 1]
  ------------------
 2053|  3.47k|  }
 2054|  3.47k|  Short_random(f);
 2055|  3.47k|  Rq_recip3(finv, f);
 2056|  3.47k|  Rq_mult_small(h, finv, g);
 2057|  3.47k|}
sntrup761.c:Small_random:
 2039|  3.47k|static void Small_random(small *out) {
 2040|  3.47k|  int i;
 2041|  2.65M|  for (i = 0; i < p; ++i) out[i] = (((urandom32() & 0x3fffffff) * 3) >> 30) - 1;
  ------------------
  |  | 1754|  2.65M|#define p 761
  ------------------
  |  Branch (2041:15): [True: 2.64M, False: 3.47k]
  ------------------
 2042|  3.47k|}
sntrup761.c:urandom32:
 2023|  5.29M|static uint32_t urandom32(void) {
 2024|  5.29M|  unsigned char c[4];
 2025|  5.29M|  uint32_t result = 0;
 2026|  5.29M|  int i;
 2027|  5.29M|  randombytes(c, 4);
 2028|  26.4M|  for (i = 0; i < 4; ++i) result += ((uint32_t)c[i]) << (8 * i);
  ------------------
  |  Branch (2028:15): [True: 21.1M, False: 5.29M]
  ------------------
 2029|  5.29M|  return result;
 2030|  5.29M|}
sntrup761.c:R3_recip:
 1900|  3.47k|static int R3_recip(small *out, const small *in) {
 1901|  3.47k|  small f[p + 1], g[p + 1], v[p + 1], r[p + 1];
 1902|  3.47k|  int sign, swap, t, i, loop, delta = 1;
 1903|  2.65M|  for (i = 0; i < p + 1; ++i) v[i] = 0;
  ------------------
  |  | 1754|  2.65M|#define p 761
  ------------------
  |  Branch (1903:15): [True: 2.65M, False: 3.47k]
  ------------------
 1904|  2.65M|  for (i = 0; i < p + 1; ++i) r[i] = 0;
  ------------------
  |  | 1754|  2.65M|#define p 761
  ------------------
  |  Branch (1904:15): [True: 2.65M, False: 3.47k]
  ------------------
 1905|  3.47k|  r[0] = 1;
 1906|  2.65M|  for (i = 0; i < p; ++i) f[i] = 0;
  ------------------
  |  | 1754|  2.65M|#define p 761
  ------------------
  |  Branch (1906:15): [True: 2.64M, False: 3.47k]
  ------------------
 1907|  3.47k|  f[0] = 1;
 1908|  3.47k|  f[p - 1] = f[p] = -1;
  ------------------
  |  | 1754|  3.47k|#define p 761
  ------------------
                f[p - 1] = f[p] = -1;
  ------------------
  |  | 1754|  3.47k|#define p 761
  ------------------
 1909|  2.65M|  for (i = 0; i < p; ++i) g[p - 1 - i] = in[i];
  ------------------
  |  | 1754|  2.65M|#define p 761
  ------------------
                for (i = 0; i < p; ++i) g[p - 1 - i] = in[i];
  ------------------
  |  | 1754|  2.64M|#define p 761
  ------------------
  |  Branch (1909:15): [True: 2.64M, False: 3.47k]
  ------------------
 1910|  3.47k|  g[p] = 0;
  ------------------
  |  | 1754|  3.47k|#define p 761
  ------------------
 1911|  5.29M|  for (loop = 0; loop < 2 * p - 1; ++loop) {
  ------------------
  |  | 1754|  5.29M|#define p 761
  ------------------
  |  Branch (1911:18): [True: 5.29M, False: 3.47k]
  ------------------
 1912|  4.03G|    for (i = p; i > 0; --i) v[i] = v[i - 1];
  ------------------
  |  | 1754|  5.29M|#define p 761
  ------------------
  |  Branch (1912:17): [True: 4.02G, False: 5.29M]
  ------------------
 1913|  5.29M|    v[0] = 0;
 1914|  5.29M|    sign = -g[0] * f[0];
 1915|  5.29M|    swap = crypto_int16_negative_mask(-delta) & crypto_int16_nonzero_mask(g[0]);
 1916|  5.29M|    delta ^= swap & (delta ^ -delta);
 1917|  5.29M|    delta += 1;
 1918|  4.03G|    for (i = 0; i < p + 1; ++i) {
  ------------------
  |  | 1754|  4.03G|#define p 761
  ------------------
  |  Branch (1918:17): [True: 4.03G, False: 5.29M]
  ------------------
 1919|  4.03G|      t = swap & (f[i] ^ g[i]);
 1920|  4.03G|      f[i] ^= t;
 1921|  4.03G|      g[i] ^= t;
 1922|  4.03G|      t = swap & (v[i] ^ r[i]);
 1923|  4.03G|      v[i] ^= t;
 1924|  4.03G|      r[i] ^= t;
 1925|  4.03G|    }
 1926|  4.03G|    for (i = 0; i < p + 1; ++i) g[i] = F3_freeze(g[i] + sign * f[i]);
  ------------------
  |  | 1754|  4.03G|#define p 761
  ------------------
  |  Branch (1926:17): [True: 4.03G, False: 5.29M]
  ------------------
 1927|  4.03G|    for (i = 0; i < p + 1; ++i) r[i] = F3_freeze(r[i] + sign * v[i]);
  ------------------
  |  | 1754|  4.03G|#define p 761
  ------------------
  |  Branch (1927:17): [True: 4.03G, False: 5.29M]
  ------------------
 1928|  4.03G|    for (i = 0; i < p; ++i) g[i] = g[i + 1];
  ------------------
  |  | 1754|  4.03G|#define p 761
  ------------------
  |  Branch (1928:17): [True: 4.02G, False: 5.29M]
  ------------------
 1929|  5.29M|    g[p] = 0;
  ------------------
  |  | 1754|  5.29M|#define p 761
  ------------------
 1930|  5.29M|  }
 1931|  3.47k|  sign = f[0];
 1932|  2.65M|  for (i = 0; i < p; ++i) out[i] = sign * v[p - 1 - i];
  ------------------
  |  | 1754|  2.65M|#define p 761
  ------------------
                for (i = 0; i < p; ++i) out[i] = sign * v[p - 1 - i];
  ------------------
  |  | 1754|  2.64M|#define p 761
  ------------------
  |  Branch (1932:15): [True: 2.64M, False: 3.47k]
  ------------------
 1933|  3.47k|  return crypto_int16_nonzero_mask(delta);
 1934|  3.47k|}
sntrup761.c:crypto_int16_negative_mask:
   74|  10.5M|crypto_int16 crypto_int16_negative_mask(crypto_int16 crypto_int16_x) {
   75|  10.5M|#if defined(__GNUC__) && defined(__x86_64__)
   76|  10.5M|  __asm__ ("sarw $15,%0" : "+r"(crypto_int16_x) : : "cc");
   77|  10.5M|  return crypto_int16_x;
   78|       |#elif defined(__GNUC__) && defined(__aarch64__)
   79|       |  crypto_int16 crypto_int16_y;
   80|       |  __asm__ ("sbfx %w0,%w1,15,1" : "=r"(crypto_int16_y) : "r"(crypto_int16_x) : );
   81|       |  return crypto_int16_y;
   82|       |#else
   83|       |  crypto_int16_x >>= 16-6;
   84|       |  crypto_int16_x += crypto_int16_optblocker;
   85|       |  crypto_int16_x >>= 5;
   86|       |  return crypto_int16_x;
   87|       |#endif
   88|  10.5M|}
sntrup761.c:crypto_int16_nonzero_mask:
  232|  10.5M|crypto_int16 crypto_int16_nonzero_mask(crypto_int16 crypto_int16_x) {
  233|  10.5M|#if defined(__GNUC__) && defined(__x86_64__)
  234|  10.5M|  crypto_int16 crypto_int16_q,crypto_int16_z;
  ------------------
  |  |   35|  10.5M|#define crypto_int16 int16_t
  ------------------
  235|  10.5M|  __asm__ ("xorw %0,%0\n movw $-1,%1\n testw %2,%2\n cmovnew %1,%0" : "=&r"(crypto_int16_z), "=&r"(crypto_int16_q) : "r"(crypto_int16_x) : "cc");
  236|  10.5M|  return crypto_int16_z;
  237|       |#elif defined(__GNUC__) && defined(__aarch64__)
  238|       |  crypto_int16 crypto_int16_z;
  239|       |  __asm__ ("tst %w1,65535\n csetm %w0,ne" : "=r"(crypto_int16_z) : "r"(crypto_int16_x) : "cc");
  240|       |  return crypto_int16_z;
  241|       |#else
  242|       |  crypto_int16_x |= -crypto_int16_x;
  243|       |  return crypto_int16_negative_mask(crypto_int16_x);
  244|       |#endif
  245|  10.5M|}
sntrup761.c:F3_freeze:
 1766|  8.06G|static small F3_freeze(int16_t x) { return x - 3 * ((10923 * x + 16384) >> 15); }
sntrup761.c:Rq_recip3:
 1962|  3.47k|static int Rq_recip3(Fq *out, const small *in) {
 1963|  3.47k|  Fq f[p + 1], g[p + 1], v[p + 1], r[p + 1], scale;
 1964|  3.47k|  int swap, t, i, loop, delta = 1;
 1965|  3.47k|  int32_t f0, g0;
 1966|  2.65M|  for (i = 0; i < p + 1; ++i) v[i] = 0;
  ------------------
  |  | 1754|  2.65M|#define p 761
  ------------------
  |  Branch (1966:15): [True: 2.64M, False: 3.47k]
  ------------------
 1967|  2.65M|  for (i = 0; i < p + 1; ++i) r[i] = 0;
  ------------------
  |  | 1754|  2.65M|#define p 761
  ------------------
  |  Branch (1967:15): [True: 2.64M, False: 3.47k]
  ------------------
 1968|  3.47k|  r[0] = Fq_recip(3);
 1969|  2.64M|  for (i = 0; i < p; ++i) f[i] = 0;
  ------------------
  |  | 1754|  2.64M|#define p 761
  ------------------
  |  Branch (1969:15): [True: 2.64M, False: 3.47k]
  ------------------
 1970|  3.47k|  f[0] = 1;
 1971|  3.47k|  f[p - 1] = f[p] = -1;
  ------------------
  |  | 1754|  3.47k|#define p 761
  ------------------
                f[p - 1] = f[p] = -1;
  ------------------
  |  | 1754|  3.47k|#define p 761
  ------------------
 1972|  2.64M|  for (i = 0; i < p; ++i) g[p - 1 - i] = in[i];
  ------------------
  |  | 1754|  2.64M|#define p 761
  ------------------
                for (i = 0; i < p; ++i) g[p - 1 - i] = in[i];
  ------------------
  |  | 1754|  2.64M|#define p 761
  ------------------
  |  Branch (1972:15): [True: 2.64M, False: 3.47k]
  ------------------
 1973|  3.47k|  g[p] = 0;
  ------------------
  |  | 1754|  3.47k|#define p 761
  ------------------
 1974|  5.29M|  for (loop = 0; loop < 2 * p - 1; ++loop) {
  ------------------
  |  | 1754|  5.29M|#define p 761
  ------------------
  |  Branch (1974:18): [True: 5.28M, False: 3.47k]
  ------------------
 1975|  4.02G|    for (i = p; i > 0; --i) v[i] = v[i - 1];
  ------------------
  |  | 1754|  5.28M|#define p 761
  ------------------
  |  Branch (1975:17): [True: 4.02G, False: 5.28M]
  ------------------
 1976|  5.28M|    v[0] = 0;
 1977|  5.28M|    swap = crypto_int16_negative_mask(-delta) & crypto_int16_nonzero_mask(g[0]);
 1978|  5.28M|    delta ^= swap & (delta ^ -delta);
 1979|  5.28M|    delta += 1;
 1980|  4.03G|    for (i = 0; i < p + 1; ++i) {
  ------------------
  |  | 1754|  4.03G|#define p 761
  ------------------
  |  Branch (1980:17): [True: 4.02G, False: 5.28M]
  ------------------
 1981|  4.02G|      t = swap & (f[i] ^ g[i]);
 1982|  4.02G|      f[i] ^= t;
 1983|  4.02G|      g[i] ^= t;
 1984|  4.02G|      t = swap & (v[i] ^ r[i]);
 1985|  4.02G|      v[i] ^= t;
 1986|  4.02G|      r[i] ^= t;
 1987|  4.02G|    }
 1988|  5.28M|    f0 = f[0];
 1989|  5.28M|    g0 = g[0];
 1990|  4.03G|    for (i = 0; i < p + 1; ++i) g[i] = Fq_freeze(f0 * g[i] - g0 * f[i]);
  ------------------
  |  | 1754|  4.03G|#define p 761
  ------------------
  |  Branch (1990:17): [True: 4.02G, False: 5.28M]
  ------------------
 1991|  4.03G|    for (i = 0; i < p + 1; ++i) r[i] = Fq_freeze(f0 * r[i] - g0 * v[i]);
  ------------------
  |  | 1754|  4.03G|#define p 761
  ------------------
  |  Branch (1991:17): [True: 4.02G, False: 5.28M]
  ------------------
 1992|  4.02G|    for (i = 0; i < p; ++i) g[i] = g[i + 1];
  ------------------
  |  | 1754|  4.02G|#define p 761
  ------------------
  |  Branch (1992:17): [True: 4.02G, False: 5.28M]
  ------------------
 1993|  5.28M|    g[p] = 0;
  ------------------
  |  | 1754|  5.28M|#define p 761
  ------------------
 1994|  5.28M|  }
 1995|  3.47k|  scale = Fq_recip(f[0]);
 1996|  2.64M|  for (i = 0; i < p; ++i) out[i] = Fq_freeze(scale * (int32_t)v[p - 1 - i]);
  ------------------
  |  | 1754|  2.64M|#define p 761
  ------------------
                for (i = 0; i < p; ++i) out[i] = Fq_freeze(scale * (int32_t)v[p - 1 - i]);
  ------------------
  |  | 1754|  2.64M|#define p 761
  ------------------
  |  Branch (1996:15): [True: 2.64M, False: 3.47k]
  ------------------
 1997|  3.47k|  return crypto_int16_nonzero_mask(delta);
 1998|  3.47k|}
sntrup761.c:Fq_recip:
 1952|  6.95k|static Fq Fq_recip(Fq a1) {
 1953|  6.95k|  int i = 1;
 1954|  6.95k|  Fq ai = a1;
 1955|  31.9M|  while (i < q - 2) {
  ------------------
  |  | 1755|  31.9M|#define q 4591
  ------------------
  |  Branch (1955:10): [True: 31.9M, False: 6.95k]
  ------------------
 1956|  31.9M|    ai = Fq_freeze(a1 * (int32_t)ai);
 1957|  31.9M|    i += 1;
 1958|  31.9M|  }
 1959|  6.95k|  return ai;
 1960|  6.95k|}
sntrup761.c:Fq_freeze:
 1768|  8.09G|static Fq Fq_freeze(int32_t x) {
 1769|  8.09G|  const int32_t q16 = (0x10000 + q / 2) / q;
  ------------------
  |  | 1755|  8.09G|#define q 4591
  ------------------
                const int32_t q16 = (0x10000 + q / 2) / q;
  ------------------
  |  | 1755|  8.09G|#define q 4591
  ------------------
 1770|  8.09G|  const int32_t q20 = (0x100000 + q / 2) / q;
  ------------------
  |  | 1755|  8.09G|#define q 4591
  ------------------
                const int32_t q20 = (0x100000 + q / 2) / q;
  ------------------
  |  | 1755|  8.09G|#define q 4591
  ------------------
 1771|  8.09G|  const int32_t q28 = (0x10000000 + q / 2) / q;
  ------------------
  |  | 1755|  8.09G|#define q 4591
  ------------------
                const int32_t q28 = (0x10000000 + q / 2) / q;
  ------------------
  |  | 1755|  8.09G|#define q 4591
  ------------------
 1772|  8.09G|  x -= q * ((q16 * x) >> 16);
  ------------------
  |  | 1755|  8.09G|#define q 4591
  ------------------
 1773|  8.09G|  x -= q * ((q20 * x) >> 20);
  ------------------
  |  | 1755|  8.09G|#define q 4591
  ------------------
 1774|  8.09G|  return x - q * ((q28 * x + 0x8000000) >> 28);
  ------------------
  |  | 1755|  8.09G|#define q 4591
  ------------------
 1775|  8.09G|}
sntrup761.c:Rq_mult_small:
 1936|  3.57k|static void Rq_mult_small(Fq *h, const Fq *f, const small *g) {
 1937|  3.57k|  int32_t fg[p + p - 1];
 1938|  3.57k|  int i, j;
 1939|  5.44M|  for (i = 0; i < p + p - 1; ++i) fg[i] = 0;
  ------------------
  |  | 1754|  5.44M|#define p 761
  ------------------
                for (i = 0; i < p + p - 1; ++i) fg[i] = 0;
  ------------------
  |  | 1754|  5.44M|#define p 761
  ------------------
  |  Branch (1939:15): [True: 5.43M, False: 3.57k]
  ------------------
 1940|  2.72M|  for (i = 0; i < p; ++i)
  ------------------
  |  | 1754|  2.72M|#define p 761
  ------------------
  |  Branch (1940:15): [True: 2.72M, False: 3.57k]
  ------------------
 1941|  2.07G|    for (j = 0; j < p; ++j) fg[i + j] += f[i] * (int32_t)g[j];
  ------------------
  |  | 1754|  2.07G|#define p 761
  ------------------
  |  Branch (1941:17): [True: 2.07G, False: 2.72M]
  ------------------
 1942|  2.72M|  for (i = p; i < p + p - 1; ++i) fg[i - p] += fg[i];
  ------------------
  |  | 1754|  3.57k|#define p 761
  ------------------
                for (i = p; i < p + p - 1; ++i) fg[i - p] += fg[i];
  ------------------
  |  | 1754|  2.72M|#define p 761
  ------------------
                for (i = p; i < p + p - 1; ++i) fg[i - p] += fg[i];
  ------------------
  |  | 1754|  2.72M|#define p 761
  ------------------
                for (i = p; i < p + p - 1; ++i) fg[i - p] += fg[i];
  ------------------
  |  | 1754|  2.71M|#define p 761
  ------------------
  |  Branch (1942:15): [True: 2.71M, False: 3.57k]
  ------------------
 1943|  2.72M|  for (i = p; i < p + p - 1; ++i) fg[i - p + 1] += fg[i];
  ------------------
  |  | 1754|  3.57k|#define p 761
  ------------------
                for (i = p; i < p + p - 1; ++i) fg[i - p + 1] += fg[i];
  ------------------
  |  | 1754|  2.72M|#define p 761
  ------------------
                for (i = p; i < p + p - 1; ++i) fg[i - p + 1] += fg[i];
  ------------------
  |  | 1754|  2.72M|#define p 761
  ------------------
                for (i = p; i < p + p - 1; ++i) fg[i - p + 1] += fg[i];
  ------------------
  |  | 1754|  2.71M|#define p 761
  ------------------
  |  Branch (1943:15): [True: 2.71M, False: 3.57k]
  ------------------
 1944|  2.72M|  for (i = 0; i < p; ++i) h[i] = Fq_freeze(fg[i]);
  ------------------
  |  | 1754|  2.72M|#define p 761
  ------------------
  |  Branch (1944:15): [True: 2.72M, False: 3.57k]
  ------------------
 1945|  3.57k|}
sntrup761.c:Rq_encode:
 2097|  3.47k|static void Rq_encode(unsigned char *s, const Fq *r) {
 2098|  3.47k|  uint16_t R[p], M[p];
 2099|  3.47k|  int i;
 2100|  2.64M|  for (i = 0; i < p; ++i) R[i] = r[i] + q12;
  ------------------
  |  | 1754|  2.64M|#define p 761
  ------------------
                for (i = 0; i < p; ++i) R[i] = r[i] + q12;
  ------------------
  |  | 1757|  2.64M|#define q12 ((q - 1) / 2)
  |  |  ------------------
  |  |  |  | 1755|  2.64M|#define q 4591
  |  |  ------------------
  ------------------
  |  Branch (2100:15): [True: 2.64M, False: 3.47k]
  ------------------
 2101|  2.64M|  for (i = 0; i < p; ++i) M[i] = q;
  ------------------
  |  | 1754|  2.64M|#define p 761
  ------------------
                for (i = 0; i < p; ++i) M[i] = q;
  ------------------
  |  | 1755|  2.64M|#define q 4591
  ------------------
  |  Branch (2101:15): [True: 2.64M, False: 3.47k]
  ------------------
 2102|  3.47k|  Encode(s, R, M, p);
  ------------------
  |  | 1754|  3.47k|#define p 761
  ------------------
 2103|  3.47k|}
sntrup761.c:Encode:
 1806|  38.7k|static void Encode(unsigned char *out, const uint16_t *R, const uint16_t *M, long long len) {
 1807|  38.7k|  if (len == 1) {
  ------------------
  |  Branch (1807:7): [True: 3.52k, False: 35.2k]
  ------------------
 1808|  3.52k|    uint16_t r = R[0], m = M[0];
 1809|  10.5k|    while (m > 1) {
  ------------------
  |  Branch (1809:12): [True: 7.05k, False: 3.52k]
  ------------------
 1810|  7.05k|      *out++ = r;
 1811|  7.05k|      r >>= 8;
 1812|  7.05k|      m = (m + 255) >> 8;
 1813|  7.05k|    }
 1814|  3.52k|  }
 1815|  38.7k|  if (len > 1) {
  ------------------
  |  Branch (1815:7): [True: 35.2k, False: 3.52k]
  ------------------
 1816|  35.2k|    uint16_t R2[(len + 1) / 2], M2[(len + 1) / 2];
 1817|  35.2k|    long long i;
 1818|  2.71M|    for (i = 0; i < len - 1; i += 2) {
  ------------------
  |  Branch (1818:17): [True: 2.67M, False: 35.2k]
  ------------------
 1819|  2.67M|      uint32_t m0 = M[i];
 1820|  2.67M|      uint32_t r = R[i] + R[i + 1] * m0;
 1821|  2.67M|      uint32_t m = M[i + 1] * m0;
 1822|  6.74M|      while (m >= 16384) {
  ------------------
  |  Branch (1822:14): [True: 4.06M, False: 2.67M]
  ------------------
 1823|  4.06M|        *out++ = r;
 1824|  4.06M|        r >>= 8;
 1825|  4.06M|        m = (m + 255) >> 8;
 1826|  4.06M|      }
 1827|  2.67M|      R2[i / 2] = r;
 1828|  2.67M|      M2[i / 2] = m;
 1829|  2.67M|    }
 1830|  35.2k|    if (i < len) {
  ------------------
  |  Branch (1830:9): [True: 14.1k, False: 21.1k]
  ------------------
 1831|  14.1k|      R2[i / 2] = R[i];
 1832|  14.1k|      M2[i / 2] = M[i];
 1833|  14.1k|    }
 1834|  35.2k|    Encode(out, R2, M2, (len + 1) / 2);
 1835|  35.2k|  }
 1836|  38.7k|}
sntrup761.c:Small_encode:
 2078|  7.00k|static void Small_encode(unsigned char *s, const small *f) {
 2079|  7.00k|  int i, j;
 2080|  1.33M|  for (i = 0; i < p / 4; ++i) {
  ------------------
  |  | 1754|  1.33M|#define p 761
  ------------------
  |  Branch (2080:15): [True: 1.33M, False: 7.00k]
  ------------------
 2081|  1.33M|    small x = 0;
 2082|  6.65M|    for (j = 0;j < 4;++j) x += (*f++ + 1) << (2 * j);
  ------------------
  |  Branch (2082:16): [True: 5.32M, False: 1.33M]
  ------------------
 2083|  1.33M|    *s++ = x;
 2084|  1.33M|  }
 2085|  7.00k|  *s = *f++ + 1;
 2086|  7.00k|}
sntrup761.c:Hash_prefix:
 2014|  3.67k|static void Hash_prefix(unsigned char *out, int b, const unsigned char *in, int inlen) {
 2015|  3.67k|  unsigned char x[inlen + 1], h[64];
 2016|  3.67k|  int i;
 2017|  3.67k|  x[0] = b;
 2018|  4.10M|  for (i = 0; i < inlen; ++i) x[i + 1] = in[i];
  ------------------
  |  Branch (2018:15): [True: 4.10M, False: 3.67k]
  ------------------
 2019|  3.67k|  crypto_hash_sha512(h, x, inlen + 1);
 2020|   121k|  for (i = 0; i < 32; ++i) out[i] = h[i];
  ------------------
  |  Branch (2020:15): [True: 117k, False: 3.67k]
  ------------------
 2021|  3.67k|}
sntrup761.c:Short_random:
 2032|  3.47k|static void Short_random(small *out) {
 2033|  3.47k|  uint32_t L[p];
 2034|  3.47k|  int i;
 2035|  2.64M|  for (i = 0; i < p; ++i) L[i] = urandom32();
  ------------------
  |  | 1754|  2.64M|#define p 761
  ------------------
  |  Branch (2035:15): [True: 2.64M, False: 3.47k]
  ------------------
 2036|  3.47k|  Short_fromlist(out, L);
 2037|  3.47k|}
sntrup761.c:Short_fromlist:
 2005|  3.47k|static void Short_fromlist(small *out, const uint32_t *in) {
 2006|  3.47k|  uint32_t L[p];
 2007|  3.47k|  int i;
 2008|   997k|  for (i = 0; i < w; ++i) L[i] = in[i] & (uint32_t)-2;
  ------------------
  |  | 1756|   997k|#define w 286
  ------------------
  |  Branch (2008:15): [True: 994k, False: 3.47k]
  ------------------
 2009|  1.65M|  for (i = w; i < p; ++i) L[i] = (in[i] & (uint32_t)-3) | 1;
  ------------------
  |  | 1756|  3.47k|#define w 286
  ------------------
                for (i = w; i < p; ++i) L[i] = (in[i] & (uint32_t)-3) | 1;
  ------------------
  |  | 1754|  1.65M|#define p 761
  ------------------
  |  Branch (2009:15): [True: 1.65M, False: 3.47k]
  ------------------
 2010|  3.47k|  crypto_sort_uint32(L, p);
  ------------------
  |  | 1754|  3.47k|#define p 761
  ------------------
 2011|  2.64M|  for (i = 0; i < p; ++i) out[i] = (L[i] & 3) - 1;
  ------------------
  |  | 1754|  2.64M|#define p 761
  ------------------
  |  Branch (2011:15): [True: 2.64M, False: 3.47k]
  ------------------
 2012|  3.47k|}
sntrup761.c:crypto_sort_uint32:
 1743|  3.47k|{
 1744|  3.47k|  crypto_uint32 *x = array;
 1745|  3.47k|  long long j;
 1746|  2.64M|  for (j = 0;j < n;++j) x[j] ^= 0x80000000;
  ------------------
  |  Branch (1746:14): [True: 2.64M, False: 3.47k]
  ------------------
 1747|  3.47k|  crypto_sort_int32(array,n);
 1748|  2.64M|  for (j = 0;j < n;++j) x[j] ^= 0x80000000;
  ------------------
  |  Branch (1748:14): [True: 2.64M, False: 3.47k]
  ------------------
 1749|  3.47k|}
sntrup761.c:crypto_sort_int32:
 1680|  3.47k|{
 1681|  3.47k|  long long top,p,q,r,i,j;
 1682|  3.47k|  int32 *x = array;
  ------------------
  |  |   20|  3.47k|#define int32 crypto_int32
  |  |  ------------------
  |  |  |  |  574|  3.47k|#define crypto_int32 int32_t
  |  |  ------------------
  ------------------
 1683|       |
 1684|  3.47k|  if (n < 2) return;
  ------------------
  |  Branch (1684:7): [True: 0, False: 3.47k]
  ------------------
 1685|  3.47k|  top = 1;
 1686|  34.7k|  while (top < n - top) top += top;
  ------------------
  |  Branch (1686:10): [True: 31.2k, False: 3.47k]
  ------------------
 1687|       |
 1688|  38.2k|  for (p = top;p >= 1;p >>= 1) {
  ------------------
  |  Branch (1688:16): [True: 34.7k, False: 3.47k]
  ------------------
 1689|  34.7k|    i = 0;
 1690|  2.65M|    while (i + 2 * p <= n) {
  ------------------
  |  Branch (1690:12): [True: 2.62M, False: 34.7k]
  ------------------
 1691|  13.2M|      for (j = i;j < i + p;++j)
  ------------------
  |  Branch (1691:18): [True: 10.6M, False: 2.62M]
  ------------------
 1692|  10.6M|        int32_MINMAX(x[j],x[j+p]);
  ------------------
  |  | 1677|  10.6M|#define int32_MINMAX(a,b) crypto_int32_minmax(&a,&b)
  ------------------
 1693|  2.62M|      i += 2 * p;
 1694|  2.62M|    }
 1695|  1.64M|    for (j = i;j < n - p;++j)
  ------------------
  |  Branch (1695:16): [True: 1.60M, False: 34.7k]
  ------------------
 1696|  1.60M|      int32_MINMAX(x[j],x[j+p]);
  ------------------
  |  | 1677|  1.60M|#define int32_MINMAX(a,b) crypto_int32_minmax(&a,&b)
  ------------------
 1697|       |
 1698|  34.7k|    i = 0;
 1699|  34.7k|    j = 0;
 1700|   191k|    for (q = top;q > p;q >>= 1) {
  ------------------
  |  Branch (1700:18): [True: 156k, False: 34.7k]
  ------------------
 1701|   156k|      if (j != i) for (;;) {
  ------------------
  |  Branch (1701:11): [True: 45.2k, False: 111k]
  ------------------
 1702|  86.9k|        if (j == n - q) goto done;
  ------------------
  |  Branch (1702:13): [True: 0, False: 86.9k]
  ------------------
 1703|  86.9k|        int32 a = x[j + p];
  ------------------
  |  |   20|  86.9k|#define int32 crypto_int32
  |  |  ------------------
  |  |  |  |  574|  86.9k|#define crypto_int32 int32_t
  |  |  ------------------
  ------------------
 1704|   403k|        for (r = q;r > p;r >>= 1)
  ------------------
  |  Branch (1704:20): [True: 316k, False: 86.9k]
  ------------------
 1705|   316k|          int32_MINMAX(a,x[j + r]);
  ------------------
  |  | 1677|   403k|#define int32_MINMAX(a,b) crypto_int32_minmax(&a,&b)
  ------------------
 1706|  86.9k|        x[j + p] = a;
 1707|  86.9k|        ++j;
 1708|  86.9k|        if (j == i + p) {
  ------------------
  |  Branch (1708:13): [True: 45.2k, False: 41.7k]
  ------------------
 1709|  45.2k|          i += 2 * p;
 1710|  45.2k|          break;
 1711|  45.2k|        }
 1712|  86.9k|      }
 1713|  2.72M|      while (i + p <= n - q) {
  ------------------
  |  Branch (1713:14): [True: 2.56M, False: 156k]
  ------------------
 1714|  12.1M|        for (j = i;j < i + p;++j) {
  ------------------
  |  Branch (1714:20): [True: 9.62M, False: 2.56M]
  ------------------
 1715|  9.62M|          int32 a = x[j + p];
  ------------------
  |  |   20|  9.62M|#define int32 crypto_int32
  |  |  ------------------
  |  |  |  |  574|  9.62M|#define crypto_int32 int32_t
  |  |  ------------------
  ------------------
 1716|  54.2M|          for (r = q;r > p;r >>= 1)
  ------------------
  |  Branch (1716:22): [True: 44.6M, False: 9.62M]
  ------------------
 1717|  44.6M|            int32_MINMAX(a,x[j+r]);
  ------------------
  |  | 1677|  44.6M|#define int32_MINMAX(a,b) crypto_int32_minmax(&a,&b)
  ------------------
 1718|  9.62M|          x[j + p] = a;
 1719|  9.62M|        }
 1720|  2.56M|        i += 2 * p;
 1721|  2.56M|      }
 1722|       |      /* now i + p > n - q */
 1723|   156k|      j = i;
 1724|  1.07M|      while (j < n - q) {
  ------------------
  |  Branch (1724:14): [True: 917k, False: 156k]
  ------------------
 1725|   917k|        int32 a = x[j + p];
  ------------------
  |  |   20|   917k|#define int32 crypto_int32
  |  |  ------------------
  |  |  |  |  574|   917k|#define crypto_int32 int32_t
  |  |  ------------------
  ------------------
 1726|  2.00M|        for (r = q;r > p;r >>= 1)
  ------------------
  |  Branch (1726:20): [True: 1.08M, False: 917k]
  ------------------
 1727|  1.08M|          int32_MINMAX(a,x[j+r]);
  ------------------
  |  | 1677|  1.08M|#define int32_MINMAX(a,b) crypto_int32_minmax(&a,&b)
  ------------------
 1728|   917k|        x[j + p] = a;
 1729|   917k|        ++j;
 1730|   917k|      }
 1731|       |
 1732|   156k|      done: ;
 1733|   156k|    }
 1734|  34.7k|  }
 1735|  3.47k|}
sntrup761.c:crypto_int32_minmax:
  981|  58.2M|void crypto_int32_minmax(crypto_int32 *crypto_int32_p,crypto_int32 *crypto_int32_q) {
  982|  58.2M|  crypto_int32 crypto_int32_x = *crypto_int32_p;
  ------------------
  |  |  574|  58.2M|#define crypto_int32 int32_t
  ------------------
  983|  58.2M|  crypto_int32 crypto_int32_y = *crypto_int32_q;
  ------------------
  |  |  574|  58.2M|#define crypto_int32 int32_t
  ------------------
  984|  58.2M|#if defined(__GNUC__) && defined(__x86_64__)
  985|  58.2M|  crypto_int32 crypto_int32_z;
  ------------------
  |  |  574|  58.2M|#define crypto_int32 int32_t
  ------------------
  986|  58.2M|  __asm__ ("cmpl %2,%1\n movl %1,%0\n cmovgl %2,%1\n cmovgl %0,%2" : "=&r"(crypto_int32_z), "+&r"(crypto_int32_x), "+r"(crypto_int32_y) : : "cc");
  987|  58.2M|  *crypto_int32_p = crypto_int32_x;
  988|  58.2M|  *crypto_int32_q = crypto_int32_y;
  989|       |#elif defined(__GNUC__) && defined(__aarch64__)
  990|       |  crypto_int32 crypto_int32_r, crypto_int32_s;
  991|       |  __asm__ ("cmp %w2,%w3\n csel %w0,%w2,%w3,lt\n csel %w1,%w3,%w2,lt" : "=&r"(crypto_int32_r), "=r"(crypto_int32_s) : "r"(crypto_int32_x), "r"(crypto_int32_y) : "cc");
  992|       |  *crypto_int32_p = crypto_int32_r;
  993|       |  *crypto_int32_q = crypto_int32_s;
  994|       |#else
  995|       |  crypto_int64 crypto_int32_r = (crypto_int64)crypto_int32_y ^ (crypto_int64)crypto_int32_x;
  996|       |  crypto_int64 crypto_int32_z = (crypto_int64)crypto_int32_y - (crypto_int64)crypto_int32_x;
  997|       |  crypto_int32_z ^= crypto_int32_r & (crypto_int32_z ^ crypto_int32_y);
  998|       |  crypto_int32_z = crypto_int32_negative_mask(crypto_int32_z);
  999|       |  crypto_int32_z &= crypto_int32_r;
 1000|       |  crypto_int32_x ^= crypto_int32_z;
 1001|       |  crypto_int32_y ^= crypto_int32_z;
 1002|       |  *crypto_int32_p = crypto_int32_x;
 1003|       |  *crypto_int32_q = crypto_int32_y;
 1004|       |#endif
 1005|  58.2M|}
sntrup761.c:Hide:
 2180|     49|static void Hide(unsigned char *c, unsigned char *r_enc, const Inputs r, const unsigned char *pk, const unsigned char *cache) {
 2181|     49|  Small_encode(r_enc, r);
 2182|     49|  ZEncrypt(c, r, pk);
 2183|     49|  HashConfirm(c + crypto_kem_sntrup761_CIPHERTEXTBYTES - Confirm_bytes, r_enc, cache);
  ------------------
  |  |    6|     49|#define crypto_kem_sntrup761_CIPHERTEXTBYTES 1039
  ------------------
                HashConfirm(c + crypto_kem_sntrup761_CIPHERTEXTBYTES - Confirm_bytes, r_enc, cache);
  ------------------
  |  | 1764|     49|#define Confirm_bytes 32
  ------------------
 2184|     49|}
sntrup761.c:ZEncrypt:
 2138|     49|static void ZEncrypt(unsigned char *C, const Inputs r, const unsigned char *pk) {
 2139|     49|  Fq h[p], c[p];
 2140|     49|  Rq_decode(h, pk);
 2141|     49|  Encrypt(c, r, h);
 2142|     49|  Rounded_encode(C, c);
 2143|     49|}
sntrup761.c:Rq_decode:
 2105|     49|static void Rq_decode(Fq *r, const unsigned char *s) {
 2106|     49|  uint16_t R[p], M[p];
 2107|     49|  int i;
 2108|  37.3k|  for (i = 0; i < p; ++i) M[i] = q;
  ------------------
  |  | 1754|  37.3k|#define p 761
  ------------------
                for (i = 0; i < p; ++i) M[i] = q;
  ------------------
  |  | 1755|  37.2k|#define q 4591
  ------------------
  |  Branch (2108:15): [True: 37.2k, False: 49]
  ------------------
 2109|     49|  Decode(R, s, M, p);
  ------------------
  |  | 1754|     49|#define p 761
  ------------------
 2110|  37.3k|  for (i = 0; i < p; ++i) r[i] = ((Fq)R[i]) - q12;
  ------------------
  |  | 1754|  37.3k|#define p 761
  ------------------
                for (i = 0; i < p; ++i) r[i] = ((Fq)R[i]) - q12;
  ------------------
  |  | 1757|  37.2k|#define q12 ((q - 1) / 2)
  |  |  ------------------
  |  |  |  | 1755|  37.2k|#define q 4591
  |  |  ------------------
  ------------------
  |  Branch (2110:15): [True: 37.2k, False: 49]
  ------------------
 2111|     49|}
sntrup761.c:Decode:
 1838|  1.07k|static void Decode(uint16_t *out, const unsigned char *S, const uint16_t *M, long long len) {
 1839|  1.07k|  if (len == 1) {
  ------------------
  |  Branch (1839:7): [True: 98, False: 980]
  ------------------
 1840|     98|    if (M[0] == 1)
  ------------------
  |  Branch (1840:9): [True: 0, False: 98]
  ------------------
 1841|      0|      *out = 0;
 1842|     98|    else if (M[0] <= 256)
  ------------------
  |  Branch (1842:14): [True: 0, False: 98]
  ------------------
 1843|      0|      *out = uint32_mod_uint14(S[0], M[0]);
 1844|     98|    else
 1845|     98|      *out = uint32_mod_uint14(S[0] + (((uint16_t)S[1]) << 8), M[0]);
 1846|     98|  }
 1847|  1.07k|  if (len > 1) {
  ------------------
  |  Branch (1847:7): [True: 980, False: 98]
  ------------------
 1848|    980|    uint16_t R2[(len + 1) / 2], M2[(len + 1) / 2], bottomr[len / 2];
 1849|    980|    uint32_t bottomt[len / 2];
 1850|    980|    long long i;
 1851|  75.4k|    for (i = 0; i < len - 1; i += 2) {
  ------------------
  |  Branch (1851:17): [True: 74.4k, False: 980]
  ------------------
 1852|  74.4k|      uint32_t m = M[i] * (uint32_t)M[i + 1];
 1853|  74.4k|      if (m > 256 * 16383) {
  ------------------
  |  Branch (1853:11): [True: 31.4k, False: 43.0k]
  ------------------
 1854|  31.4k|        bottomt[i / 2] = 256 * 256;
 1855|  31.4k|        bottomr[i / 2] = S[0] + 256 * S[1];
 1856|  31.4k|        S += 2;
 1857|  31.4k|        M2[i / 2] = (((m + 255) >> 8) + 255) >> 8;
 1858|  43.0k|      } else if (m >= 16384) {
  ------------------
  |  Branch (1858:18): [True: 43.0k, False: 0]
  ------------------
 1859|  43.0k|        bottomt[i / 2] = 256;
 1860|  43.0k|        bottomr[i / 2] = S[0];
 1861|  43.0k|        S += 1;
 1862|  43.0k|        M2[i / 2] = (m + 255) >> 8;
 1863|  43.0k|      } else {
 1864|      0|        bottomt[i / 2] = 1;
 1865|      0|        bottomr[i / 2] = 0;
 1866|      0|        M2[i / 2] = m;
 1867|      0|      }
 1868|  74.4k|    }
 1869|    980|    if (i < len) M2[i / 2] = M[i];
  ------------------
  |  Branch (1869:9): [True: 392, False: 588]
  ------------------
 1870|    980|    Decode(R2, S, M2, (len + 1) / 2);
 1871|  75.4k|    for (i = 0; i < len - 1; i += 2) {
  ------------------
  |  Branch (1871:17): [True: 74.4k, False: 980]
  ------------------
 1872|  74.4k|      uint32_t r1, r = bottomr[i / 2];
 1873|  74.4k|      uint16_t r0;
 1874|  74.4k|      r += bottomt[i / 2] * R2[i / 2];
 1875|  74.4k|      uint32_divmod_uint14(&r1, &r0, r, M[i]);
 1876|  74.4k|      r1 = uint32_mod_uint14(r1, M[i + 1]);
 1877|  74.4k|      *out++ = r0;
 1878|  74.4k|      *out++ = r1;
 1879|  74.4k|    }
 1880|    980|    if (i < len) *out++ = R2[i / 2];
  ------------------
  |  Branch (1880:9): [True: 392, False: 588]
  ------------------
 1881|    980|  }
 1882|  1.07k|}
sntrup761.c:uint32_mod_uint14:
 1799|  74.5k|static uint16_t uint32_mod_uint14(uint32_t x, uint16_t m) {
 1800|  74.5k|  uint32_t Q;
 1801|  74.5k|  uint16_t r;
 1802|  74.5k|  uint32_divmod_uint14(&Q, &r, x, m);
 1803|  74.5k|  return r;
 1804|  74.5k|}
sntrup761.c:uint32_divmod_uint14:
 1783|   149k|static void uint32_divmod_uint14(uint32_t *Q, uint16_t *r, uint32_t x, uint16_t m) {
 1784|   149k|  uint32_t qpart, mask, v = 0x80000000 / m;
 1785|   149k|  qpart = (x * (uint64_t)v) >> 31;
 1786|   149k|  x -= qpart * m;
 1787|   149k|  *Q = qpart;
 1788|   149k|  qpart = (x * (uint64_t)v) >> 31;
 1789|   149k|  x -= qpart * m;
 1790|   149k|  *Q += qpart;
 1791|   149k|  x -= m;
 1792|   149k|  *Q += 1;
 1793|   149k|  mask = crypto_int32_negative_mask(x);
 1794|   149k|  x += mask & (uint32_t)m;
 1795|   149k|  *Q += mask;
 1796|   149k|  *r = x;
 1797|   149k|}
sntrup761.c:crypto_int32_negative_mask:
  621|   149k|crypto_int32 crypto_int32_negative_mask(crypto_int32 crypto_int32_x) {
  622|   149k|#if defined(__GNUC__) && defined(__x86_64__)
  623|   149k|  __asm__ ("sarl $31,%0" : "+r"(crypto_int32_x) : : "cc");
  624|   149k|  return crypto_int32_x;
  625|       |#elif defined(__GNUC__) && defined(__aarch64__)
  626|       |  crypto_int32 crypto_int32_y;
  627|       |  __asm__ ("asr %w0,%w1,31" : "=r"(crypto_int32_y) : "r"(crypto_int32_x) : );
  628|       |  return crypto_int32_y;
  629|       |#else
  630|       |  crypto_int32_x >>= 32-6;
  631|       |  crypto_int32_x += crypto_int32_optblocker;
  632|       |  crypto_int32_x >>= 5;
  633|       |  return crypto_int32_x;
  634|       |#endif
  635|   149k|}
sntrup761.c:Encrypt:
 2059|     49|static void Encrypt(Fq *c, const small *r, const Fq *h) {
 2060|     49|  Fq hr[p];
 2061|     49|  Rq_mult_small(hr, h, r);
 2062|     49|  Round(c, hr);
 2063|     49|}
sntrup761.c:Round:
 2000|     49|static void Round(Fq *out, const Fq *a) {
 2001|     49|  int i;
 2002|  37.3k|  for (i = 0; i < p; ++i) out[i] = a[i] - F3_freeze(a[i]);
  ------------------
  |  | 1754|  37.3k|#define p 761
  ------------------
  |  Branch (2002:15): [True: 37.2k, False: 49]
  ------------------
 2003|     49|}
sntrup761.c:Rounded_encode:
 2113|     49|static void Rounded_encode(unsigned char *s, const Fq *r) {
 2114|     49|  uint16_t R[p], M[p];
 2115|     49|  int i;
 2116|  37.3k|  for (i = 0; i < p; ++i) R[i] = ((r[i] + q12) * 10923) >> 15;
  ------------------
  |  | 1754|  37.3k|#define p 761
  ------------------
                for (i = 0; i < p; ++i) R[i] = ((r[i] + q12) * 10923) >> 15;
  ------------------
  |  | 1757|  37.2k|#define q12 ((q - 1) / 2)
  |  |  ------------------
  |  |  |  | 1755|  37.2k|#define q 4591
  |  |  ------------------
  ------------------
  |  Branch (2116:15): [True: 37.2k, False: 49]
  ------------------
 2117|  37.3k|  for (i = 0; i < p; ++i) M[i] = (q + 2) / 3;
  ------------------
  |  | 1754|  37.3k|#define p 761
  ------------------
                for (i = 0; i < p; ++i) M[i] = (q + 2) / 3;
  ------------------
  |  | 1755|  37.2k|#define q 4591
  ------------------
  |  Branch (2117:15): [True: 37.2k, False: 49]
  ------------------
 2118|     49|  Encode(s, R, M, p);
  ------------------
  |  | 1754|     49|#define p 761
  ------------------
 2119|     49|}
sntrup761.c:HashConfirm:
 2154|     49|static void HashConfirm(unsigned char *h, const unsigned char *r, const unsigned char *cache) {
 2155|     49|  unsigned char x[Hash_bytes * 2];
 2156|     49|  int i;
 2157|     49|  Hash_prefix(x, 3, r, Small_bytes);
  ------------------
  |  | 1761|     49|#define Small_bytes ((p + 3) / 4)
  |  |  ------------------
  |  |  |  | 1754|     49|#define p 761
  |  |  ------------------
  ------------------
 2158|  1.61k|  for (i = 0; i < Hash_bytes; ++i) x[Hash_bytes + i] = cache[i];
  ------------------
  |  | 1760|  1.61k|#define Hash_bytes 32
  ------------------
                for (i = 0; i < Hash_bytes; ++i) x[Hash_bytes + i] = cache[i];
  ------------------
  |  | 1760|  1.56k|#define Hash_bytes 32
  ------------------
  |  Branch (2158:15): [True: 1.56k, False: 49]
  ------------------
 2159|     49|  Hash_prefix(h, 2, x, sizeof x);
 2160|     49|}
sntrup761.c:HashSession:
 2162|     49|static void HashSession(unsigned char *k, int b, const unsigned char *y, const unsigned char *z) {
 2163|     49|  unsigned char x[Hash_bytes + crypto_kem_sntrup761_CIPHERTEXTBYTES];
 2164|     49|  int i;
 2165|     49|  Hash_prefix(x, 3, y, Small_bytes);
  ------------------
  |  | 1761|     49|#define Small_bytes ((p + 3) / 4)
  |  |  ------------------
  |  |  |  | 1754|     49|#define p 761
  |  |  ------------------
  ------------------
 2166|  50.9k|  for (i = 0; i < crypto_kem_sntrup761_CIPHERTEXTBYTES; ++i) x[Hash_bytes + i] = z[i];
  ------------------
  |  |    6|  50.9k|#define crypto_kem_sntrup761_CIPHERTEXTBYTES 1039
  ------------------
                for (i = 0; i < crypto_kem_sntrup761_CIPHERTEXTBYTES; ++i) x[Hash_bytes + i] = z[i];
  ------------------
  |  | 1760|  50.9k|#define Hash_bytes 32
  ------------------
  |  Branch (2166:15): [True: 50.9k, False: 49]
  ------------------
 2167|     49|  Hash_prefix(k, b, x, sizeof x);
 2168|     49|}
sntrup761.c:ZDecrypt:
 2145|     49|static void ZDecrypt(Inputs r, const unsigned char *C, const unsigned char *sk) {
 2146|     49|  small f[p], v[p];
 2147|     49|  Fq c[p];
 2148|     49|  Small_decode(f, sk);
 2149|     49|  Small_decode(v, sk + Small_bytes);
  ------------------
  |  | 1761|     49|#define Small_bytes ((p + 3) / 4)
  |  |  ------------------
  |  |  |  | 1754|     49|#define p 761
  |  |  ------------------
  ------------------
 2150|     49|  Rounded_decode(c, C);
 2151|     49|  Decrypt(r, c, f, v);
 2152|     49|}
sntrup761.c:Small_decode:
 2088|     98|static void Small_decode(small *f, const unsigned char *s) {
 2089|     98|  int i, j;
 2090|  18.7k|  for (i = 0; i < p / 4; ++i) {
  ------------------
  |  | 1754|  18.7k|#define p 761
  ------------------
  |  Branch (2090:15): [True: 18.6k, False: 98]
  ------------------
 2091|  18.6k|    unsigned char x = *s++;
 2092|  93.1k|    for (j = 0;j < 4;++j) *f++ = ((small)((x >> (2 * j)) & 3)) - 1;
  ------------------
  |  Branch (2092:16): [True: 74.4k, False: 18.6k]
  ------------------
 2093|  18.6k|  }
 2094|     98|  *f++ = ((small)(*s & 3)) - 1;
 2095|     98|}
sntrup761.c:Rounded_decode:
 2121|     49|static void Rounded_decode(Fq *r, const unsigned char *s) {
 2122|     49|  uint16_t R[p], M[p];
 2123|     49|  int i;
 2124|  37.3k|  for (i = 0; i < p; ++i) M[i] = (q + 2) / 3;
  ------------------
  |  | 1754|  37.3k|#define p 761
  ------------------
                for (i = 0; i < p; ++i) M[i] = (q + 2) / 3;
  ------------------
  |  | 1755|  37.2k|#define q 4591
  ------------------
  |  Branch (2124:15): [True: 37.2k, False: 49]
  ------------------
 2125|     49|  Decode(R, s, M, p);
  ------------------
  |  | 1754|     49|#define p 761
  ------------------
 2126|  37.3k|  for (i = 0; i < p; ++i) r[i] = R[i] * 3 - q12;
  ------------------
  |  | 1754|  37.3k|#define p 761
  ------------------
                for (i = 0; i < p; ++i) r[i] = R[i] * 3 - q12;
  ------------------
  |  | 1757|  37.2k|#define q12 ((q - 1) / 2)
  |  |  ------------------
  |  |  |  | 1755|  37.2k|#define q 4591
  |  |  ------------------
  ------------------
  |  Branch (2126:15): [True: 37.2k, False: 49]
  ------------------
 2127|     49|}
sntrup761.c:Decrypt:
 2065|     49|static void Decrypt(small *r, const Fq *c, const small *f, const small *ginv) {
 2066|     49|  Fq cf[p], cf3[p];
 2067|     49|  small e[p], ev[p];
 2068|     49|  int mask, i;
 2069|     49|  Rq_mult_small(cf, c, f);
 2070|     49|  Rq_mult3(cf3, cf);
 2071|     49|  R3_fromRq(e, cf3);
 2072|     49|  R3_mult(ev, e, ginv);
 2073|     49|  mask = Weightw_mask(ev);
 2074|  14.0k|  for (i = 0; i < w; ++i) r[i] = ((ev[i] ^ 1) & ~mask) ^ 1;
  ------------------
  |  | 1756|  14.0k|#define w 286
  ------------------
  |  Branch (2074:15): [True: 14.0k, False: 49]
  ------------------
 2075|  23.3k|  for (i = w; i < p; ++i) r[i] = ev[i] & ~mask;
  ------------------
  |  | 1756|     49|#define w 286
  ------------------
                for (i = w; i < p; ++i) r[i] = ev[i] & ~mask;
  ------------------
  |  | 1754|  23.3k|#define p 761
  ------------------
  |  Branch (2075:15): [True: 23.2k, False: 49]
  ------------------
 2076|     49|}
sntrup761.c:Rq_mult3:
 1947|     49|static void Rq_mult3(Fq *h, const Fq *f) {
 1948|     49|  int i;
 1949|  37.3k|  for (i = 0; i < p; ++i) h[i] = Fq_freeze(3 * f[i]);
  ------------------
  |  | 1754|  37.3k|#define p 761
  ------------------
  |  Branch (1949:15): [True: 37.2k, False: 49]
  ------------------
 1950|     49|}
sntrup761.c:R3_fromRq:
 1884|     49|static void R3_fromRq(small *out, const Fq *r) {
 1885|     49|  int i;
 1886|  37.3k|  for (i = 0; i < p; ++i) out[i] = F3_freeze(r[i]);
  ------------------
  |  | 1754|  37.3k|#define p 761
  ------------------
  |  Branch (1886:15): [True: 37.2k, False: 49]
  ------------------
 1887|     49|}
sntrup761.c:R3_mult:
 1889|     49|static void R3_mult(small *h, const small *f, const small *g) {
 1890|     49|  int16_t fg[p + p - 1];
 1891|     49|  int i, j;
 1892|  74.5k|  for (i = 0; i < p + p - 1; ++i) fg[i] = 0;
  ------------------
  |  | 1754|  74.5k|#define p 761
  ------------------
                for (i = 0; i < p + p - 1; ++i) fg[i] = 0;
  ------------------
  |  | 1754|  74.5k|#define p 761
  ------------------
  |  Branch (1892:15): [True: 74.5k, False: 49]
  ------------------
 1893|  37.3k|  for (i = 0; i < p; ++i)
  ------------------
  |  | 1754|  37.3k|#define p 761
  ------------------
  |  Branch (1893:15): [True: 37.2k, False: 49]
  ------------------
 1894|  28.4M|    for (j = 0; j < p; ++j) fg[i + j] += f[i] * (int16_t)g[j];
  ------------------
  |  | 1754|  28.4M|#define p 761
  ------------------
  |  Branch (1894:17): [True: 28.3M, False: 37.2k]
  ------------------
 1895|  37.2k|  for (i = p; i < p + p - 1; ++i) fg[i - p] += fg[i];
  ------------------
  |  | 1754|     49|#define p 761
  ------------------
                for (i = p; i < p + p - 1; ++i) fg[i - p] += fg[i];
  ------------------
  |  | 1754|  37.2k|#define p 761
  ------------------
                for (i = p; i < p + p - 1; ++i) fg[i - p] += fg[i];
  ------------------
  |  | 1754|  37.2k|#define p 761
  ------------------
                for (i = p; i < p + p - 1; ++i) fg[i - p] += fg[i];
  ------------------
  |  | 1754|  37.2k|#define p 761
  ------------------
  |  Branch (1895:15): [True: 37.2k, False: 49]
  ------------------
 1896|  37.2k|  for (i = p; i < p + p - 1; ++i) fg[i - p + 1] += fg[i];
  ------------------
  |  | 1754|     49|#define p 761
  ------------------
                for (i = p; i < p + p - 1; ++i) fg[i - p + 1] += fg[i];
  ------------------
  |  | 1754|  37.2k|#define p 761
  ------------------
                for (i = p; i < p + p - 1; ++i) fg[i - p + 1] += fg[i];
  ------------------
  |  | 1754|  37.2k|#define p 761
  ------------------
                for (i = p; i < p + p - 1; ++i) fg[i - p + 1] += fg[i];
  ------------------
  |  | 1754|  37.2k|#define p 761
  ------------------
  |  Branch (1896:15): [True: 37.2k, False: 49]
  ------------------
 1897|  37.3k|  for (i = 0; i < p; ++i) h[i] = F3_freeze(fg[i]);
  ------------------
  |  | 1754|  37.3k|#define p 761
  ------------------
  |  Branch (1897:15): [True: 37.2k, False: 49]
  ------------------
 1898|     49|}
sntrup761.c:Weightw_mask:
 1777|     49|static int Weightw_mask(small *r) {
 1778|     49|  int i, weight = 0;
 1779|  37.3k|  for (i = 0; i < p; ++i) weight += crypto_int64_bottombit_01(r[i]);
  ------------------
  |  | 1754|  37.3k|#define p 761
  ------------------
  |  Branch (1779:15): [True: 37.2k, False: 49]
  ------------------
 1780|     49|  return crypto_int16_nonzero_mask(weight - w);
  ------------------
  |  | 1756|     49|#define w 286
  ------------------
 1781|     49|}
sntrup761.c:crypto_int64_bottombit_01:
 1253|  37.3k|crypto_int64 crypto_int64_bottombit_01(crypto_int64 crypto_int64_x) {
 1254|  37.3k|#if defined(__GNUC__) && defined(__x86_64__)
 1255|  37.3k|  __asm__ ("andq $1,%0" : "+r"(crypto_int64_x) : : "cc");
 1256|  37.3k|  return crypto_int64_x;
 1257|       |#elif defined(__GNUC__) && defined(__aarch64__)
 1258|       |  crypto_int64 crypto_int64_y;
 1259|       |  __asm__ ("ubfx %0,%1,0,1" : "=r"(crypto_int64_y) : "r"(crypto_int64_x) : );
 1260|       |  return crypto_int64_y;
 1261|       |#else
 1262|       |  crypto_int64_x &= 1 + crypto_int64_optblocker;
 1263|       |  return crypto_int64_x;
 1264|       |#endif
 1265|  37.3k|}
sntrup761.c:Ciphertexts_diff_mask:
 2196|     49|static int Ciphertexts_diff_mask(const unsigned char *c, const unsigned char *c2) {
 2197|     49|  uint16_t differentbits = 0;
 2198|     49|  int len = crypto_kem_sntrup761_CIPHERTEXTBYTES;
  ------------------
  |  |    6|     49|#define crypto_kem_sntrup761_CIPHERTEXTBYTES 1039
  ------------------
 2199|  50.9k|  while (len-- > 0) differentbits |= (*c++) ^ (*c2++);
  ------------------
  |  Branch (2199:10): [True: 50.9k, False: 49]
  ------------------
 2200|     49|  return (crypto_int64_bitmod_01((differentbits - 1),8)) - 1;
 2201|     49|}
sntrup761.c:crypto_int64_bitmod_01:
 1332|     49|crypto_int64 crypto_int64_bitmod_01(crypto_int64 crypto_int64_x,crypto_int64 crypto_int64_s) {
 1333|     49|  crypto_int64_x = crypto_int64_shrmod(crypto_int64_x,crypto_int64_s);
 1334|     49|  return crypto_int64_bottombit_01(crypto_int64_x);
 1335|     49|}
sntrup761.c:crypto_int64_shrmod:
 1310|     49|crypto_int64 crypto_int64_shrmod(crypto_int64 crypto_int64_x,crypto_int64 crypto_int64_s) {
 1311|     49|#if defined(__GNUC__) && defined(__x86_64__)
 1312|     49|  __asm__ ("sarq %%cl,%0" : "+r"(crypto_int64_x) : "c"(crypto_int64_s) : "cc");
 1313|       |#elif defined(__GNUC__) && defined(__aarch64__)
 1314|       |  __asm__ ("asr %0,%0,%1" : "+r"(crypto_int64_x) : "r"(crypto_int64_s) : );
 1315|       |#else
 1316|       |  int crypto_int64_k, crypto_int64_l;
 1317|       |  for (crypto_int64_l = 0,crypto_int64_k = 1;crypto_int64_k < 64;++crypto_int64_l,crypto_int64_k *= 2)
 1318|       |    crypto_int64_x ^= (crypto_int64_x ^ (crypto_int64_x >> crypto_int64_k)) & crypto_int64_bitinrangepublicpos_mask(crypto_int64_s,crypto_int64_l);
 1319|       |#endif
 1320|     49|  return crypto_int64_x;
 1321|     49|}

sntrup761.c:randombytes:
   24|  5.29M|static inline void randombytes(unsigned char* buf, unsigned int len) {
   25|  5.29M|    genrandom(buf, len);
   26|  5.29M|}
sntrup761.c:crypto_hash_sha512:
   36|  3.67k|{
   37|  3.67k|  hash_state hs;
   38|       |
   39|  3.67k|  sha512_init(&hs);
   40|  3.67k|  sha512_process(&hs, m, n);
   41|  3.67k|  return sha512_done(&hs, out);
   42|  3.67k|}

